dhcp

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDatagram = 1 << 16

Variables

View Source
var (
	ErrDropRequest = errors.New("request should be dropped")
)

Functions

func AddDHCPMock

func AddDHCPMock(registry endpoint.HandlerRegistry, logger logging.Logger, emitter audit.Emitter, stateStore state.KVStore)

func New

func New(logger logging.Logger, emitter audit.Emitter, stateStore state.KVStore) endpoint.ProtocolHandler

Types

type ConditionalHandler

type ConditionalHandler struct {
	Handlers HandlerChain
	Chain    FilterChain
}

type DHCPv4MessageHandler

type DHCPv4MessageHandler interface {
	Handle(req, resp *dhcpv4.DHCPv4) error
}
var NoOpHandler DHCPv4MessageHandler = DHCPv4MessageHandlerFunc(func(_, _ *dhcpv4.DHCPv4) error {
	return nil
})

func DNSHandler

func DNSHandler(opts HandlerOptions, args ...rules.Param) (DHCPv4MessageHandler, error)

func IPRangeHandler

func IPRangeHandler(opts HandlerOptions, args ...rules.Param) (DHCPv4MessageHandler, error)

func NetmaskHandler

func NetmaskHandler(opts HandlerOptions, args ...rules.Param) (DHCPv4MessageHandler, error)

func RouterIPHandler

func RouterIPHandler(opts HandlerOptions, args ...rules.Param) (DHCPv4MessageHandler, error)

func StaticIPHandler

func StaticIPHandler(opts HandlerOptions, args ...rules.Param) (DHCPv4MessageHandler, error)

type DHCPv4MessageHandlerFunc

type DHCPv4MessageHandlerFunc func(req, resp *dhcpv4.DHCPv4) error

func (DHCPv4MessageHandlerFunc) Handle

func (f DHCPv4MessageHandlerFunc) Handle(req, resp *dhcpv4.DHCPv4) error

type DefaultOptions

type DefaultOptions struct {
	ServerID  net.IP
	DNS       []net.IP
	Router    net.IP
	Netmask   net.IP
	LeaseTime time.Duration
}

type EmittingHandler

type EmittingHandler struct {
	Upstream DHCPv4MessageHandler
	Emitter  audit.Emitter
}

func (*EmittingHandler) Handle

func (h *EmittingHandler) Handle(req, resp *dhcpv4.DHCPv4) error

type FallbackHandler

type FallbackHandler struct {
	Previous DHCPv4MessageHandler
	Logger   logging.Logger
	DefaultOptions
}

func (*FallbackHandler) Handle

func (h *FallbackHandler) Handle(req, resp *dhcpv4.DHCPv4) error

type FilterChain

type FilterChain []RequestFilter

func RequestFiltersForRoutingRule

func RequestFiltersForRoutingRule(rule rules.FilteredPipeline) (filters FilterChain, err error)

func (FilterChain) Matches

func (c FilterChain) Matches(m *dhcpv4.DHCPv4) bool

type HandlerChain

type HandlerChain []DHCPv4MessageHandler

func HandlerForRoutingRule

func HandlerForRoutingRule(rule *rules.ChainedResponsePipeline, opts HandlerOptions) (HandlerChain, error)

func (HandlerChain) Apply

func (c HandlerChain) Apply(req, resp *dhcpv4.DHCPv4) error

type HandlerOptions

type HandlerOptions struct {
	ProtocolOptions
	Logger     logging.Logger
	StateStore state.KVStore
}

type ProtocolOptions

type ProtocolOptions struct {
	Rules    []string
	Default  DefaultOptions
	Fallback DHCPv4MessageHandler
}

func LoadFromConfig

func LoadFromConfig(startupSpec *endpoint.StartupSpec, stateStore state.KVStore) (opts ProtocolOptions, err error)

type RangeLease

type RangeLease struct {
	IP  net.IP
	MAC net.HardwareAddr
}

type RangeMessageHandler

type RangeMessageHandler struct {
	Store   state.KVStore
	TTL     time.Duration
	StartIP net.IP
	EndIP   net.IP
	// contains filtered or unexported fields
}

func (*RangeMessageHandler) Handle

func (h *RangeMessageHandler) Handle(req, resp *dhcpv4.DHCPv4) (err error)

type RequestFilter

type RequestFilter interface {
	Matches(msg *dhcpv4.DHCPv4) bool
}

func ExactMACMatcher

func ExactMACMatcher(args ...rules.Param) (RequestFilter, error)

func MatchMACMatcher

func MatchMACMatcher(args ...rules.Param) (RequestFilter, error)

type RequestFilterFunc

type RequestFilterFunc func(msg *dhcpv4.DHCPv4) bool

func (RequestFilterFunc) Matches

func (f RequestFilterFunc) Matches(msg *dhcpv4.DHCPv4) bool

type RuledHandler

type RuledHandler struct {
	HandlerName     string
	ProtocolOptions ProtocolOptions
	Logger          logging.Logger
	StateStore      state.KVStore
	// contains filtered or unexported fields
}

func (*RuledHandler) Handle

func (h *RuledHandler) Handle(req, resp *dhcpv4.DHCPv4) error

func (*RuledHandler) RegisterRule

func (h *RuledHandler) RegisterRule(rawRule string) error

type Server4

type Server4 struct {
	PacketConn *ipv4.PacketConn
	Handler    DHCPv4MessageHandler
	Logger     logging.Logger
}

func (*Server4) HandleMessage

func (s *Server4) HandleMessage(req *dhcpv4.DHCPv4, oob *ipv4.ControlMessage, addr net.Addr)

func (*Server4) Serve

func (s *Server4) Serve() error

func (*Server4) Shutdown added in v0.9.0

func (s *Server4) Shutdown() error

Jump to

Keyboard shortcuts

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