Documentation ¶
Overview ¶
Package ipam provides IP address management functionality. Mostly a copy/paste from https://github.com/giantswarm/ipam without prioprietary service/error handling
Index ¶
- func Add(ip net.IP, number int) net.IP
- func Broadcast(network net.IPNet) net.IP
- func CalculateSubnetMask(networkMask net.IPMask, n uint) (net.IPMask, error)
- func CanonicalizeSubnets(networkRange net.IPNet, subnets []net.IPNet) []net.IPNet
- func Contains(network, subnet net.IPNet) bool
- func Free(network net.IPNet, mask net.IPMask, subnets []net.IPNet) (net.IPNet, error)
- func Half(network net.IPNet) (first, second net.IPNet, err error)
- func IPLessThan(a, b net.IP) bool
- func NetIPInSlice(a net.IP, list []net.IP) int
- func Split(network net.IPNet, n uint) ([]net.IPNet, error)
- func SubnetWithin(network net.IPNet, hostNumber int) (net.IPNet, error)
- type IPNets
- type IPRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add increments the given IP by the number. e.g: add(10.0.4.0, 1) -> 10.0.4.1. Negative values are allowed for decrementing.
func CalculateSubnetMask ¶
CalculateSubnetMask calculates new subnet mask to accommodate n subnets.
func CanonicalizeSubnets ¶
CanonicalizeSubnets iterates over subnets and returns deduplicated list of networks that belong to networkRange. Subnets that overlap each other but aren't exactly the same are not removed. Subnets are returned in the same order as they appear in input.
Example:
networkRange: 192.168.2.0/24 subnets: [172.168.2.0/25, 192.168.2.0/25, 192.168.3.128/25, 192.168.2.0/25, 192.168.2.128/25] returned: [192.168.2.0/25, 192.168.2.128/25]
Example 2:
networkRange: 10.0.0.0/8 subnets: [10.1.0.0/16, 10.1.0.0/24, 10.1.1.0/24] returned: [10.1.0.0/16, 10.1.0.0/24, 10.1.1.0/24]
func Free ¶
Free takes a network, a mask, and a list of subnets. An available network, within the first network, is returned.
func IPLessThan ¶
IPLessThan compare two ip addresses by section left-most is most significant
func NetIPInSlice ¶
NetIPInSlice makes it easy to assess if an IP address is present in a list of ips