// OverlapsPrefix return the list of ServiceCIDR that overlaps with the prefix passed as argument func OverlapsPrefix(serviceCIDRLister networkinglisters.ServiceCIDRLister, prefix netip.Prefix) []*networkingv1beta1.ServiceCIDR { … } // ContainsPrefix return the list of ServiceCIDR that contains the prefix passed as argument func ContainsPrefix(serviceCIDRLister networkinglisters.ServiceCIDRLister, prefix netip.Prefix) []*networkingv1beta1.ServiceCIDR { … } // ContainsIP return the list of ServiceCIDR that contains the IP address passed as argument func ContainsIP(serviceCIDRLister networkinglisters.ServiceCIDRLister, ip net.IP) []*networkingv1beta1.ServiceCIDR { … } // ContainsAddress return the list of ServiceCIDR that contains the address passed as argument func ContainsAddress(serviceCIDRLister networkinglisters.ServiceCIDRLister, address netip.Addr) []*networkingv1beta1.ServiceCIDR { … } // PrefixContainsIP returns true if the given IP is contained with the prefix, // is not the network address and also, if IPv4, is not the broadcast address. // This is required (rather than just `prefix.Contains(ip)`) because a ServiceCIDR // covering prefix will not allocate those IPs, so a service with one of those IPs // can't belong to that ServiceCIDR. func PrefixContainsIP(prefix netip.Prefix, ip netip.Addr) bool { … } // broadcastAddress returns the broadcast address of the subnet // The broadcast address is obtained by setting all the host bits // in a subnet to 1. // network 192.168.0.0/24 : subnet bits 24 host bits 32 - 24 = 8 // broadcast address 192.168.0.255 func broadcastAddress(subnet netip.Prefix) (netip.Addr, error) { … } // IPToAddr converts a net.IP to a netip.Addr // if the net.IP is not valid it returns an empty netip.Addr{} func IPToAddr(ip net.IP) netip.Addr { … }