dhcphosts

package
v0.0.0-...-cfe5e5d Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHWAddrNotFound   error = errors.New("hardware address not found")
	ErrIPAddrNotFound   error = errors.New("IP address not found")
	ErrBadHWAddrFormat  error = errors.New("Malformed hardware address address")
	ErrBadIPFormat      error = errors.New("Malformed IP address")
	ErrBadBindingFormat error = errors.New("Malformed Binding Pair")
	ErrDuplicateFound   error = errors.New("Entry already found")
)

Functions

This section is empty.

Types

type Binding

type Binding struct {
	HW net.HardwareAddr
	IP net.IP
}

Binding represents the binding between a MAC and an IP

func ParseBinding

func ParseBinding(hw, ip string) (Binding, error)

ParseBinding creates a Binding between a MAC and a IP, expressed as strings

func ParseBindingString

func ParseBindingString(s string) (Binding, error)

ParseBindingString parses a string in the dhcphosts format (man 8 dnsmasq) and returns a Binding

func (Binding) Duplicate

func (b Binding) Duplicate(x Binding) bool

func (Binding) Equal

func (b Binding) Equal(x Binding) bool

Equal returns true if the Binding is equal to the argument, false otherwise

func (Binding) EqualHW

func (b Binding) EqualHW(x net.HardwareAddr) bool

EqualHW returns true if the Binding has the MAC part equal to the argument, false otherwise

func (Binding) EqualIP

func (b Binding) EqualIP(x net.IP) bool

EqualIP returns true if the Binding has the IP part equal to the argument, false otherwise

func (Binding) String

func (b Binding) String() string

String converts the binding in its dhcphosts (man 8 dnsmasq) representation

type Conf

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

Conf represents the configured Bindings

func NewConf

func NewConf() *Conf

func Parse

func Parse(r io.Reader) (*Conf, error)

Parse creates a Conf from a reader, which must return content in dhcphosts (man 8 dnsmasq) format

func (*Conf) Add

func (m *Conf) Add(mac, ip string) (Binding, error, bool)

Add registers a new Binding

func (*Conf) GetByHWAddr

func (m *Conf) GetByHWAddr(hw string) (Binding, error)

func (*Conf) GetByIP

func (m *Conf) GetByIP(ip string) (Binding, error)

func (*Conf) Len

func (m *Conf) Len() int

Len returns the number of configured Bindings

func (*Conf) Remove

func (m *Conf) Remove(mac string) (Binding, bool)

func (*Conf) String

func (m *Conf) String() string

String converts all the registered bindings in the Conf in content in dhcphosts (man 8 dnsmasq) representation

Jump to

Keyboard shortcuts

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