diff options
| author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-01-13 18:06:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-13 18:06:54 +0100 |
| commit | eeb76db0fd0dc2a1115c2f2ad12c82eadbc62509 (patch) | |
| tree | 4666b0a66a98bd3f29586b3d3ac2c3028bd7443a /libpod/network/util/ip.go | |
| parent | ab7228b3c27719e447de4dffe9b3fd7f67d6f346 (diff) | |
| parent | ece768ff9e7d2b0166c0b1850467a489556b93fc (diff) | |
| download | podman-eeb76db0fd0dc2a1115c2f2ad12c82eadbc62509.tar.gz podman-eeb76db0fd0dc2a1115c2f2ad12c82eadbc62509.tar.bz2 podman-eeb76db0fd0dc2a1115c2f2ad12c82eadbc62509.zip | |
Merge pull request #12642 from Luap99/libnetwork
use libnetwork from c/common
Diffstat (limited to 'libpod/network/util/ip.go')
| -rw-r--r-- | libpod/network/util/ip.go | 56 |
1 files changed, 0 insertions, 56 deletions
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 - } -} |
