Documentation ¶
Overview ¶
Package iputil implements some useful functions for manipulating IP addresses
Index ¶
- func CIDRToIPNet(cidr string) (*net.IPNet, error)
- func FirstAddr(n *net.IPNet) net.IP
- func IPAdd(ip net.IP, offset int) net.IP
- func IPBefore(ip, ip2 net.IP) bool
- func IPDiff(ip, ip2 net.IP) int
- func LastAddr(n *net.IPNet) net.IP
- func NetworkID(n *net.IPNet) *net.IPNet
- func RandAddr(n *net.IPNet) net.IP
- func RandAddrWithExclude(n *net.IPNet, xf, xl int) net.IP
- func SubnetContainsSubnet(supernet, subnet *net.IPNet) bool
- func SubnetEqualSubnet(net1, net2 *net.IPNet) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NetworkID ¶
NetworkID returns an IPNet representing the network, based on an IPNet of any IP in a network
func RandAddrWithExclude ¶
RandAddrWithExclude Generates a random address in an IPNet, excluding the first xf and last xl addresses. To generate a random address, excluding the network and broadcast addresses use 1 for xf and xl
func SubnetContainsSubnet ¶
SubnetContainsSubnet returns true if the first subnet contains the second nil is considered to be a global supernet "0.0.0.0/0" or "::/0"
func SubnetEqualSubnet ¶
SubnetEqualSubnet returns true if to IPNets are equal nil is considered to be a global supernet "0.0.0.0/0" or "::/0"
Types ¶
This section is empty.