Documentation
¶
Index ¶
- func AssignFirstHostIP(ifaceName, cidr string) error
- func AssignFirstHostIPToLink(link netlink.Link, cidr string) error
- func AssignIfaceIP(ifaceName, cidr string) error
- func FirstHostCIDR(subnet *net.IPNet) string
- func NextIP(ip net.IP) net.IP
- func RemoveFirstHostIP(ifaceName, cidr string)
- func SubnetCount(baseCIDR string, childBits int) (uint, error)
- func SubnetForIndex(baseCIDR string, childBits int, n uint) (string, error)
- func SubnetIndex(baseCIDR string, childBits int, cidr string) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignFirstHostIP ¶
AssignFirstHostIP assigns the first host IP of cidr to the named interface. e.g. cidr="10.9.5.0/24" → assigns 10.9.5.1/24 to ifaceName.
func AssignFirstHostIPToLink ¶
AssignFirstHostIPToLink assigns the first host IP of cidr to an already-resolved link. Use when the caller already holds a netlink.Link (avoids a second LinkByName lookup).
func AssignIfaceIP ¶
AssignIfaceIP assigns cidr (e.g. "10.8.0.1/24") to the named interface and brings it up. Idempotent — EEXIST is not an error.
func FirstHostCIDR ¶
FirstHostCIDR returns the first host address of subnet as "ip/prefix" (e.g. 10.8.0.0/24 → 10.8.0.1/24).
func RemoveFirstHostIP ¶ added in v1.1.0
func RemoveFirstHostIP(ifaceName, cidr string)
RemoveFirstHostIP removes only the address installed for this lab binding.
func SubnetCount ¶ added in v1.10.0
SubnetCount is the number of child subnets of childBits that SubnetForIndex can give from baseCIDR (numbers 0 .. count-1). It counts from the literal host address of the base, like SubnetForIndex: "10.8.0.0/10" has the subnets from 10.8.0.0 to the end of its /10.
func SubnetForIndex ¶
SubnetForIndex computes a child subnet by adding n * 2^(32-childBits) to the literal host address in baseCIDR (NOT the masked network address). This lets you write "10.8.0.0/10" to mean "start from 10.8.0.0 within the /10 space". Example: SubnetForIndex("10.8.0.0/10", 24, 5) → "10.8.5.0/24"
Types ¶
This section is empty.