Version: v0.0.0-...-72e9078 Latest Latest

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 14 Imported by: 0



Package ipam is a very simple IPAM it administers a single CIDR range, e.g "1000::/124".

The functions are NOT thread safe.



This section is empty.


This section is empty.


func IPExists

func IPExists(ip net.IP) (bool, error)

func LinkAddAddr

func LinkAddAddr(linkName, IP string) error

func LinkAddGateway

func LinkAddGateway(linkName, gatewayIP string) error

func LinkRename

func LinkRename(old, new string) error

func LinkSetMaster

func LinkSetMaster(linkName, masterName string) error

func LinkSetNsByFile

func LinkSetNsByFile(filename, linkName string) error

func LinkSetup

func LinkSetup(linkName string) error

func MountNewNetworkNamespace

func MountNewNetworkNamespace(nsTarget string) (filesystem.Unmounter, error)

func SetupBridge

func SetupBridge(name string) error

func SetupVirtualEthernet

func SetupVirtualEthernet(name, peer string) error


type IPAM

type IPAM struct {
	// contains filtered or unexported fields

IPAM holds the ipam state

func NewIPAM

func NewIPAM(fn, cidr string) (*IPAM, error)

New creates a new IPAM for the passed CIDR. Error if the passed CIDR is invalid.

func (*IPAM) Allocate

func (i *IPAM) Allocate() (net.IP, error)

Allocate allocates a new address. An error is returned if there is no addresses left.

func (*IPAM) Free

func (i *IPAM) Free(a net.IP)

Free frees an allocated address. To free a non-allocated address is a no-op.

func (*IPAM) MarshalJSON

func (i *IPAM) MarshalJSON() ([]byte, error)

func (*IPAM) Reserve

func (i *IPAM) Reserve(a net.IP) error

Reserve reserves an address. Error if the address is outside the CIDR or if the address is allocated already.

func (*IPAM) ReserveFirstAndLast

func (i *IPAM) ReserveFirstAndLast()

ReserveFirstAndLast reserves the first and last address. These are valid addresses but some programs may refuse to use them. Note that the number of Unallocated addresses may become zero.

func (*IPAM) Unallocated

func (i *IPAM) Unallocated() uint32

Unallocated returns the number of unallocated addresses.

func (*IPAM) UnmarshalJSON

func (i *IPAM) UnmarshalJSON(bs []byte) error

type Releaser

type Releaser func() error

type Unsetter

type Unsetter func() error

func SetNetNSByFile

func SetNetNSByFile(filename string) (Unsetter, error)

Jump to

Keyboard shortcuts

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