netutil

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignFirstHostIP

func AssignFirstHostIP(ifaceName, cidr string) error

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(link netlink.Link, cidr string) error

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

func AssignIfaceIP(ifaceName, cidr string) error

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

func FirstHostCIDR(subnet *net.IPNet) string

FirstHostCIDR returns the first host address of subnet as "ip/prefix" (e.g. 10.8.0.0/24 → 10.8.0.1/24).

func NextIP

func NextIP(ip net.IP) net.IP

NextIP returns ip+1 (e.g. 10.9.5.0 → 10.9.5.1).

func RemoveFirstHostIP added in v1.1.0

func RemoveFirstHostIP(ifaceName, cidr string)

RemoveFirstHostIP removes only the address installed for this lab binding.

func SubnetForIndex

func SubnetForIndex(baseCIDR string, childBits int, n uint) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL