dhcp

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: GPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const InternalIPAMType = "internal"
View Source
const MaxDatagram = 1 << 16

MaxDatagram is the maximum length of message that can be received.

Variables

This section is empty.

Functions

This section is empty.

Types

type APILease

type APILease struct {
	Info             *APILeaseInfo `json:"info"`
	Identifier       string        `json:"identifier" required:"true"`
	Address          string        `json:"address" required:"true"`
	Hostname         string        `json:"hostname" required:"true"`
	AddressLeaseTime string        `json:"addressLeaseTime" required:"true"`
	ScopeKey         string        `json:"scopeKey" required:"true"`
	DNSZone          string        `json:"dnsZone"`
	Expiry           int64         `json:"expiry"`
}

type APILeaseInfo added in v0.3.13

type APILeaseInfo struct {
	Vendor string `json:"vendor"`
}

type APILeasesDeleteInput

type APILeasesDeleteInput struct {
	Identifier string `query:"identifier"`
	Scope      string `query:"scope"`
}

type APILeasesGetInput

type APILeasesGetInput struct {
	ScopeName  string `query:"scope"`
	Identifier string `query:"identifier" description:"Optional identifier of a lease to get"`
}

type APILeasesGetOutput

type APILeasesGetOutput struct {
	Leases []*APILease `json:"leases" required:"true"`
}

type APILeasesPutInput

type APILeasesPutInput struct {
	Identifier string `query:"identifier" required:"true" maxLength:"255"`
	Scope      string `query:"scope" required:"true" maxLength:"255"`

	Address          string `json:"address" required:"true" maxLength:"40"`
	Hostname         string `json:"hostname" required:"true" maxLength:"255"`
	AddressLeaseTime string `json:"addressLeaseTime" required:"true" maxLength:"40"`
	DNSZone          string `json:"dnsZone" maxLength:"255"`
	Expiry           int64  `json:"expiry"`
}

type APILeasesWOLInput

type APILeasesWOLInput struct {
	Identifier string `query:"identifier" required:"true"`
	Scope      string `query:"scope" required:"true"`
}

type APIRoleConfigInput

type APIRoleConfigInput struct {
	Config RoleConfig `json:"config" required:"true"`
}

type APIRoleConfigOutput

type APIRoleConfigOutput struct {
	Config RoleConfig `json:"config" required:"true"`
}

type APIScope

type APIScope struct {
	IPAM       map[string]string   `json:"ipam" required:"true"`
	DNS        *ScopeDNS           `json:"dns"`
	Name       string              `json:"scope" required:"true"`
	SubnetCIDR string              `json:"subnetCidr" required:"true"`
	Options    []*types.DHCPOption `json:"options" required:"true"`
	TTL        int64               `json:"ttl" required:"true"`
	Default    bool                `json:"default" required:"true"`
	Hook       string              `json:"hook" required:"true"`
	Statistics APIScopeStatistics  `json:"statistics" required:"true"`
}

type APIScopeStatistics added in v0.11.0

type APIScopeStatistics struct {
	Usable uint64 `json:"usable" required:"true"`
	Used   uint64 `json:"used" required:"true"`
}

type APIScopesDeleteInput

type APIScopesDeleteInput struct {
	Scope string `query:"scope" required:"true"`
}

type APIScopesGetInput added in v0.4.6

type APIScopesGetInput struct {
	Name string `query:"name" description:"Optionally get DHCP Scope by name"`
}

type APIScopesGetOutput

type APIScopesGetOutput struct {
	Scopes     []*APIScope        `json:"scopes" required:"true"`
	Statistics APIScopeStatistics `json:"statistics" required:"true"`
}

type APIScopesPutInput

type APIScopesPutInput struct {
	IPAM map[string]string `json:"ipam"`
	DNS  *ScopeDNS         `json:"dns"`
	Name string            `query:"scope" required:"true" maxLength:"255"`

	SubnetCIDR string              `json:"subnetCidr" required:"true" maxLength:"40"`
	Options    []*types.DHCPOption `json:"options" required:"true"`
	TTL        int64               `json:"ttl" required:"true"`
	Default    bool                `json:"default" required:"true"`
	Hook       string              `json:"hook" required:"true"`
}

type Handler4

type Handler4 func(req *Request4) *dhcpv4.DHCPv4

type IPAM

type IPAM interface {
	// Return the next free IP address, could be sequential or random
	NextFreeAddress(identifier string) *netip.Addr
	// Check if IP address is in usage (should also check if IP is in specified range and subnet)
	// Can optionally also check if the IP address is pingable
	// `identifier` might be given as well for a device that could request an address
	// that it had already taken
	IsIPFree(addr netip.Addr, identifier *string) bool
	// Get the subnet mask of the scope
	GetSubnetMask() net.IPMask
	// Mark an IP as used
	UseIP(addr netip.Addr, identifier string)
	// Update config when scope is updated
	UpdateConfig(s *Scope) error
	// Amount of usable IPs excluding any exclusions
	UsableSize() *big.Int
}

type IPUse added in v0.9.0

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

type InternalIPAM

type InternalIPAM struct {
	Start netip.Addr
	End   netip.Addr

	SubnetCIDR netip.Prefix
	// contains filtered or unexported fields
}

func NewInternalIPAM

func NewInternalIPAM(role *Role, s *Scope) (*InternalIPAM, error)

func (*InternalIPAM) GetSubnetMask

func (i *InternalIPAM) GetSubnetMask() net.IPMask

func (*InternalIPAM) IsIPFree

func (i *InternalIPAM) IsIPFree(ip netip.Addr, identifier *string) bool

func (*InternalIPAM) NextFreeAddress

func (i *InternalIPAM) NextFreeAddress(identifier string) *netip.Addr

func (*InternalIPAM) UpdateConfig added in v0.9.0

func (i *InternalIPAM) UpdateConfig(s *Scope) error

func (*InternalIPAM) UsableSize added in v0.11.0

func (i *InternalIPAM) UsableSize() *big.Int

func (*InternalIPAM) UseIP added in v0.9.0

func (i *InternalIPAM) UseIP(ip netip.Addr, identifier string)

type Lease

type Lease struct {
	Identifier string `json:"-"`

	Address          string `json:"address"`
	Hostname         string `json:"hostname"`
	AddressLeaseTime string `json:"addressLeaseTime,omitempty"`
	ScopeKey         string `json:"scopeKey"`
	DNSZone          string `json:"dnsZone,omitempty"`
	// Set to -1 for a reservation
	Expiry int64 `json:"expiry"`
	// contains filtered or unexported fields
}

func (*Lease) IsReservation added in v0.6.18

func (l *Lease) IsReservation() bool

func (*Lease) Put

func (l *Lease) Put(ctx context.Context, expiry int64, opts ...clientv3.OpOption) error

type Request4

type Request4 struct {
	*dhcpv4.DHCPv4

	Context context.Context
	// contains filtered or unexported fields
}

func (*Request4) LocalIP added in v0.9.0

func (req *Request4) LocalIP() string

Use the instance ip unless the the interface is not bound

type Role

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

func New

func New(instance roles.Instance) *Role

func (*Role) APILeasesDelete

func (r *Role) APILeasesDelete() usecase.Interactor

func (*Role) APILeasesGet

func (r *Role) APILeasesGet() usecase.Interactor

func (*Role) APILeasesPut

func (r *Role) APILeasesPut() usecase.Interactor

func (*Role) APILeasesWOL

func (r *Role) APILeasesWOL() usecase.Interactor

func (*Role) APIRoleConfigGet

func (r *Role) APIRoleConfigGet() usecase.Interactor

func (*Role) APIRoleConfigPut

func (r *Role) APIRoleConfigPut() usecase.Interactor

func (*Role) APIScopesDelete

func (r *Role) APIScopesDelete() usecase.Interactor

func (*Role) APIScopesGet

func (r *Role) APIScopesGet() usecase.Interactor

func (*Role) APIScopesPut

func (r *Role) APIScopesPut() usecase.Interactor

func (*Role) DeviceIdentifier

func (r *Role) DeviceIdentifier(m *dhcpv4.DHCPv4) string

func (*Role) FindLease

func (r *Role) FindLease(req *Request4) *Lease

func (*Role) HandleDHCPDecline4

func (r *Role) HandleDHCPDecline4(req *Request4) *dhcpv4.DHCPv4

func (*Role) HandleDHCPDiscover4

func (r *Role) HandleDHCPDiscover4(req *Request4) *dhcpv4.DHCPv4

func (*Role) HandleDHCPRequest4

func (r *Role) HandleDHCPRequest4(req *Request4) *dhcpv4.DHCPv4

func (*Role) Handler4

func (r *Role) Handler4(re *Request4) *dhcpv4.DHCPv4

func (*Role) NewLease

func (r *Role) NewLease(identifier string) *Lease

func (*Role) NewRequest4

func (r *Role) NewRequest4(dhcp *dhcpv4.DHCPv4) *Request4

func (*Role) NewScope

func (r *Role) NewScope(name string) *Scope

func (*Role) Start

func (r *Role) Start(ctx context.Context, config []byte) error

func (*Role) Stop

func (r *Role) Stop()

type RoleConfig

type RoleConfig struct {
	Port                  int `json:"port"`
	LeaseNegotiateTimeout int `json:"leaseNegotiateTimeout"`
}

type Scope

type Scope struct {
	DNS *ScopeDNS `json:"dns"`

	IPAM map[string]string `json:"ipam"`

	Name string `json:"-"`

	SubnetCIDR string              `json:"subnetCidr"`
	Options    []*types.DHCPOption `json:"options"`
	TTL        int64               `json:"ttl"`
	Default    bool                `json:"default"`
	Hook       string              `json:"hook"`
	// contains filtered or unexported fields
}

func (*Scope) Put

func (s *Scope) Put(ctx context.Context, expiry int64, opts ...clientv3.OpOption) error

type ScopeDNS

type ScopeDNS struct {
	Zone              string   `json:"zone"`
	Search            []string `json:"search"`
	AddZoneInHostname bool     `json:"addZoneInHostname"`
}

Directories

Path Synopsis
Updated version of https://github.com/dutchcoders/go-ouitools Package go-oui provides functions to work with MAC and OUI's
Updated version of https://github.com/dutchcoders/go-ouitools Package go-oui provides functions to work with MAC and OUI's

Jump to

Keyboard shortcuts

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