dhcpalloc

package
v0.0.0-...-a810e79 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 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 initialises 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 []shared.IPRange, 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() []shared.IPRange
	DHCPv6Ranges() []shared.IPRange
}

Network represents a LXD network responsible for running dnsmasq.

type Options

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

Options to initialise 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