Documentation ¶
Index ¶
- Constants
- func Allocate(ctx context.Context, parent types.Prefix, name string, length int, ...) (types.Prefix, error)
- func AllocateWithBlocklist(ctx context.Context, parent types.Prefix, name string, length int, ...) (types.Prefix, error)
- func CollideWith(prefix string, childs []string) []string
- func IsCIDR(cidr string) bool
- func LastIP(ipNet *net.IPNet) net.IP
- func New(name string, cidr string, parent types.Prefix) types.Prefix
- func NextPrefix(ipNet *net.IPNet) *net.IPNet
- func OverlappingPrefixes(cidr1 string, cidr2 string) bool
- func PrefixCollideWith(prefix types.Prefix, childs []types.Prefix) []types.Prefix
- type IPFamily
- type Prefix
Constants ¶
const ( IPv4 = 0 IPv6 = 1 )
Variables ¶
This section is empty.
Functions ¶
func Allocate ¶
func Allocate(ctx context.Context, parent types.Prefix, name string, length int, store types.Storage) (types.Prefix, error)
Allocate 1. Checks if parent length is superior or equals to length 2. Generates a first candidate with parent-IP/length 3. Gets childs of parent (with store) 4. Checks if there is any collision with childs and candidate (If there is no, go to 6) 5. If there is a collision, get next prefix, set as candidate, and got to 4, if candidate = first candidate, returns an error 6. Save in with the store 7. Gets the childs 8. Checks if only 1 collision (the one we just added)
func AllocateWithBlocklist ¶
func CollideWith ¶
func NextPrefix ¶
NextPrefix returns the next prefix e.g.: 169.16.0.0/24 will return 169.16.1.0/24
func OverlappingPrefixes ¶
OverlappingPrefixes checks if the 2 parameters are colliding/overlapping e.g.: 192.168.2.1/32 - 192.168.2.0/24 will return true