From 495884b3195de482dc610a2a002db7e053188a32 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 17 Dec 2021 14:46:15 +0100 Subject: use libnetwork from c/common The libpod/network packages were moved to c/common so that buildah can use it as well. To prevent duplication use it in podman as well and remove it from here. Signed-off-by: Paul Holzinger --- libpod/network/util/ip.go | 56 ----------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 libpod/network/util/ip.go (limited to 'libpod/network/util/ip.go') diff --git a/libpod/network/util/ip.go b/libpod/network/util/ip.go deleted file mode 100644 index e82b4a781..000000000 --- a/libpod/network/util/ip.go +++ /dev/null @@ -1,56 +0,0 @@ -package util - -import ( - "net" -) - -// IsIPv6 returns true if netIP is IPv6. -func IsIPv6(netIP net.IP) bool { - return netIP != nil && netIP.To4() == nil -} - -// IsIPv4 returns true if netIP is IPv4. -func IsIPv4(netIP net.IP) bool { - return netIP != nil && netIP.To4() != nil -} - -// LastIPInSubnet gets the last IP in a subnet -func LastIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer - // re-parse to ensure clean network address - _, cidr, err := net.ParseCIDR(addr.String()) - if err != nil { - return nil, err - } - - ones, bits := cidr.Mask.Size() - if ones == bits { - return cidr.IP, nil - } - for i := range cidr.IP { - cidr.IP[i] = cidr.IP[i] | ^cidr.Mask[i] - } - return cidr.IP, nil -} - -// FirstIPInSubnet gets the first IP in a subnet -func FirstIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer - // re-parse to ensure clean network address - _, cidr, err := net.ParseCIDR(addr.String()) - if err != nil { - return nil, err - } - ones, bits := cidr.Mask.Size() - if ones == bits { - return cidr.IP, nil - } - cidr.IP[len(cidr.IP)-1]++ - return cidr.IP, nil -} - -// NormalizeIP will transform the given ip to the 4 byte len ipv4 if possible -func NormalizeIP(ip *net.IP) { - ipv4 := ip.To4() - if ipv4 != nil { - *ip = ipv4 - } -} -- cgit v1.2.3-54-g00ecf