mirror of https://github.com/vishvananda/netlink
Add support for IPv6 in NewIPNet
This commit is contained in:
parent
a57a12c1b1
commit
39cd2806f3
|
@ -33,7 +33,10 @@ func ParseIPNet(s string) (*net.IPNet, error) {
|
||||||
return &net.IPNet{IP: ip, Mask: ipNet.Mask}, nil
|
return &net.IPNet{IP: ip, Mask: ipNet.Mask}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIPNet generates an IPNet from an ip address using a netmask of 32.
|
// NewIPNet generates an IPNet from an ip address using a netmask of 32 or 128.
|
||||||
func NewIPNet(ip net.IP) *net.IPNet {
|
func NewIPNet(ip net.IP) *net.IPNet {
|
||||||
|
if ip.To4() != nil {
|
||||||
return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)}
|
return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)}
|
||||||
|
}
|
||||||
|
return &net.IPNet{IP: ip, Mask: net.CIDRMask(128, 128)}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue