dhcpmsg

package
v0.0.0-...-11e78ec Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpRequest = 1
	OpReply   = 2
)
View Source
const (
	MsgTypeDiscover = 1
	MsgTypeOffer    = 2
	MsgTypeRequest  = 3
	MsgTypeAck      = 5
	MsgTypeNack     = 6
)
View Source
const (
	OptPadding                = 0
	OptSubnetMask             = 1
	OptRouter                 = 3
	OptDNS                    = 6
	OptHostname               = 12
	OptDomainName             = 15
	OptInterfaceMTU           = 26
	OptBroadcastAddress       = 28
	OptNTP                    = 42
	OptRequestedIP            = 50
	OptIPAddressLeaseDuration = 51
	OptMessageType            = 53
	OptServerIdentifier       = 54
	OptParametersList         = 55
	OptMessage                = 56
	OptMaxMessageSize         = 57
	OptRenewalDuration        = 58
	OptRebindDuration         = 59
	OptClientIdentifier       = 61
	OptEnd                    = 255
)
View Source
const (
	DHCPCookie = 0x63825363
)
View Source
const (
	FlagBroadcast = 1 << 15
)
View Source
const (
	HtypeETHER = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DHCPOpt

type DHCPOpt struct {
	Option uint8
	Data   []byte
}

func OptionClientIdentifier

func OptionClientIdentifier(hwaddr net.HardwareAddr) DHCPOpt

func OptionDNS

func OptionDNS(ip ...net.IP) DHCPOpt

func OptionDomainName

func OptionDomainName(n string) DHCPOpt

func OptionHostname

func OptionHostname(n string) DHCPOpt

func OptionIPAddressLeaseDuration

func OptionIPAddressLeaseDuration(d time.Duration) DHCPOpt

func OptionInterfaceMTU

func OptionInterfaceMTU(size uint16) DHCPOpt

func OptionMaxMessageSize

func OptionMaxMessageSize(size uint16) DHCPOpt

func OptionNTP

func OptionNTP(ip ...net.IP) DHCPOpt

func OptionParametersList

func OptionParametersList(params ...uint8) DHCPOpt

func OptionRequestedIP

func OptionRequestedIP(ip net.IP) DHCPOpt

func OptionRouter

func OptionRouter(ip net.IP) DHCPOpt

func OptionServerIdentifier

func OptionServerIdentifier(ip net.IP) DHCPOpt

func OptionSubnetMask

func OptionSubnetMask(mask net.IPMask) DHCPOpt

func OptionType

func OptionType(t uint8) DHCPOpt

type DecodedOptions

type DecodedOptions struct {
	MessageType            uint8
	MaxMessageSize         uint16
	InterfaceMTU           uint16
	RequestedIP            net.IP
	ServerIdentifier       net.IP
	BroadcastAddress       net.IP
	SubnetMask             net.IPMask
	Routers                []net.IP
	DNS                    []net.IP
	IPAddressLeaseDuration time.Duration
	RenewalDuration        time.Duration
	RebindDuration         time.Duration
	DomainName             string
	ClientIdentifier       []byte
	Message                string
	ParametersList         []uint8
}

func DecodeOptions

func DecodeOptions(opts []DHCPOpt) DecodedOptions

type Message

type Message struct {
	Op             uint8
	Htype          uint8
	Hops           uint8
	Xid            uint32
	Secs           uint16
	Flags          uint16
	ClientIP       net.IP
	YourIP         net.IP
	NextIP         net.IP
	RelayIP        net.IP
	ClientMAC      net.HardwareAddr
	ServerHostName [64]byte
	BootFilename   [128]byte
	Cookie         uint32
	Options        []DHCPOpt
}

func Decode

func Decode(b []byte) (*Message, error)

func (Message) Assemble

func (msg Message) Assemble() []byte

Assemble assembles a dhcp message into raw bytes.

Jump to

Keyboard shortcuts

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