dhcpalloc

package
v6.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDHCPNotSupported error = errors.New("Network doesn't support DHCP")

ErrDHCPNotSupported indicates network doesn't support DHCP for this IP protocol.

Functions

func AllocateTask

func AllocateTask(opts *Options, f func(*Transaction) error) error

AllocateTask initializes a new locked Transaction for a specific host and executes the supplied function on it. The lock on the dnsmasq config is released when the function returns.

func DHCPValidIP

func DHCPValidIP(subnet *net.IPNet, ranges []iprange.Range, IP net.IP) bool

DHCPValidIP returns whether an IP fits inside one of the supplied DHCP ranges and subnet.

func GetIP

func GetIP(subnet *net.IPNet, host int64) net.IP

GetIP returns a net.IP representing the IP belonging to the subnet for the host number supplied.

Types

type Network

type Network interface {
	Name() string
	Type() string
	Config() map[string]string
	DHCPv4Subnet() *net.IPNet
	DHCPv6Subnet() *net.IPNet
	DHCPv4Ranges() []iprange.Range
	DHCPv6Ranges() []iprange.Range
}

Network represents an Incus network responsible for running dnsmasq.

type Options

type Options struct {
	ProjectName string
	HostName    string
	DeviceName  string
	HostMAC     net.HardwareAddr
	Network     Network
}

Options to initialize the allocator with.

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

Transaction is a locked transaction of the dnsmasq config files that allows IP allocations for a host.

func (*Transaction) AllocateIPv4

func (t *Transaction) AllocateIPv4() (net.IP, error)

AllocateIPv4 allocate an IPv4 static DHCP allocation.

func (*Transaction) AllocateIPv6

func (t *Transaction) AllocateIPv6() (net.IP, error)

AllocateIPv6 allocate an IPv6 static DHCP allocation.

Jump to

Keyboard shortcuts

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