dhcpv4

package
v0.0.0-...-430ae03 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2018 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerPort = 67
	ClientPort = 68
)
View Source
const HeaderSize = 236

HeaderSize is the DHCPv4 header size in bytes.

View Source
const MaxMessageSize = 576

MaxMessageSize is the maximum size in bytes that a DHCPv4 packet can hold.

View Source
const (
	MaxUDPReceivedPacketSize = 8192
)

MaxUDPReceivedPacketSize is the (arbitrary) maximum UDP packet size supported by this library. Theoretically could be up to 65kb.

Variables

View Source
var (
	// DefaultReadTimeout is the time to wait after listening in which the
	// exchange is considered failed.
	DefaultReadTimeout = 3 * time.Second

	// DefaultWriteTimeout is the time to wait after sending in which the
	// exchange is considered failed.
	DefaultWriteTimeout = 3 * time.Second
)
View Source
var ErrShortByteStream = errors.New("short byte stream")

ErrShortByteStream is an error that is thrown any time a short byte stream is detected during option parsing.

View Source
var ErrZeroLengthByteStream = errors.New("zero-length byte stream")

ErrZeroLengthByteStream is an error that is thrown any time a zero-length byte stream is encountered.

View Source
var MagicCookie = []byte{99, 130, 83, 99}

MagicCookie is the magic 4-byte value at the beginning of the list of options in a DHCPv4 packet.

View Source
var MessageTypeToString = map[MessageType]string{
	MessageTypeDiscover: "DISCOVER",
	MessageTypeOffer:    "OFFER",
	MessageTypeRequest:  "REQUEST",
	MessageTypeDecline:  "DECLINE",
	MessageTypeAck:      "ACK",
	MessageTypeNak:      "NAK",
	MessageTypeRelease:  "RELEASE",
	MessageTypeInform:   "INFORM",
}

MessageTypeToString maps DHCP message types to human-readable strings.

View Source
var OpcodeToString = map[OpcodeType]string{
	OpcodeBootRequest: "BootRequest",
	OpcodeBootReply:   "BootReply",
}

OpcodeToString maps an OpcodeType to its mnemonic name

View Source
var OptionCodeToString = map[OptionCode]string{}/* 149 elements not displayed */

OptionCodeToString maps an OptionCode to its mnemonic name

Functions

func BindToInterface

func BindToInterface(fd int, ifname string) error

func GenerateTransactionID

func GenerateTransactionID() (*uint32, error)

GenerateTransactionID generates a random 32-bits number suitable for use as TransactionID

func IPv4AddrsForInterface

func IPv4AddrsForInterface(iface *net.Interface) ([]net.IP, error)

IPv4AddrsForInterface obtains the currently-configured, non-loopback IPv4 addresses for iface.

func MakeBroadcastSocket

func MakeBroadcastSocket(ifname string) (int, error)

MakeBroadcastSocket creates a socket that can be passed to syscall.Sendto that will send packets out to the broadcast address.

func MakeListeningSocket

func MakeListeningSocket(ifname string) (int, error)

MakeListeningSocket creates a listening socket on 0.0.0.0 for the DHCP client port and returns it.

func MakeRawBroadcastPacket

func MakeRawBroadcastPacket(payload []byte) ([]byte, error)

MakeRawBroadcastPacket converts payload (a serialized DHCPv4 packet) into a raw packet suitable for UDP broadcast.

Types

type Client

type Client struct {
	ReadTimeout, WriteTimeout time.Duration
}

Client is the object that actually performs the DHCP exchange. It currently only has read and write timeout values.

func NewClient

func NewClient() *Client

NewClient generates a new client to perform a DHCP exchange with, setting the read and write timeout fields to defaults.

func (*Client) Exchange

func (c *Client) Exchange(ifname string, discover *DHCPv4) ([]DHCPv4, error)

Exchange runs a full DORA transaction: Discover, Offer, Request, Acknowledge, over UDP. Does not retry in case of failures. Returns a list of DHCPv4 structures representing the exchange. It can contain up to four elements, ordered as Discovery, Offer, Request and Acknowledge. In case of errors, an error is returned, and the list of DHCPv4 objects will be shorted than 4, containing all the sent and received DHCPv4 messages.

type DHCPv4

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

DHCPv4 represents a DHCPv4 packet header and options. See the New* functions to build DHCPv4 packets.

func BroadcastSendReceive

func BroadcastSendReceive(sendFd, recvFd int, packet *DHCPv4, readTimeout, writeTimeout time.Duration) (*DHCPv4, error)

BroadcastSendReceive broadcasts packet (with some write timeout) and waits for a response up to some read timeout value.

func FromBytes

func FromBytes(data []byte) (*DHCPv4, error)

FromBytes encodes the DHCPv4 packet into a sequence of bytes, and returns an error if the packet is not valid.

func New

func New() (*DHCPv4, error)

New creates a new DHCPv4 structure and fill it up with default values. It won't be a valid DHCPv4 message so you will need to adjust its fields. See also NewDiscovery, NewOffer, NewRequest, NewAcknowledge, NewInform and NewRelease .

func NewDiscoveryForInterface

func NewDiscoveryForInterface(ifname string) (*DHCPv4, error)

NewDiscoveryForInterface builds a new DHCPv4 Discovery message, with a default Ethernet HW type and the hardware address obtained from the specified interface.

func NewInformForInterface

func NewInformForInterface(ifname string, needsBroadcast bool) (*DHCPv4, error)

NewInformForInterface builds a new DHCPv4 Informational message with default Ethernet HW type and the hardware address obtained from the specified interface. It does NOT put a DHCP End option at the end.

func RequestFromOffer

func RequestFromOffer(offer DHCPv4) (*DHCPv4, error)

RequestFromOffer builds a DHCPv4 request from an offer.

func (*DHCPv4) AddOption

func (d *DHCPv4) AddOption(option Option)

AddOption appends an option to the existing ones.

func (*DHCPv4) BootFileName

func (d *DHCPv4) BootFileName() [128]byte

BootFileName returns the boot file name as a sequence of bytes.

func (*DHCPv4) BootFileNameToString

func (d *DHCPv4) BootFileNameToString() string

BootFileNameToString returns the boot file name as a string, after trimming the null bytes at the end.

func (*DHCPv4) ClientHwAddr

func (d *DHCPv4) ClientHwAddr() [16]byte

ClientHwAddr returns the client hardware (MAC) address.

func (*DHCPv4) ClientHwAddrToString

func (d *DHCPv4) ClientHwAddrToString() string

ClientHwAddrToString converts the hardware address field to a string.

func (*DHCPv4) ClientIPAddr

func (d *DHCPv4) ClientIPAddr() net.IP

ClientIPAddr returns the client IP address.

func (*DHCPv4) Flags

func (d *DHCPv4) Flags() uint16

Flags returns the DHCP flags portion of the packet.

func (*DHCPv4) FlagsToString

func (d *DHCPv4) FlagsToString() string

FlagsToString returns a human-readable representation of the flags field.

func (*DHCPv4) GatewayIPAddr

func (d *DHCPv4) GatewayIPAddr() net.IP

GatewayIPAddr returns the gateway IP address.

func (*DHCPv4) GetOneOption

func (d *DHCPv4) GetOneOption(code OptionCode) Option

GetOneOption will attempt to get an option that match a Option code. If there are multiple options with the same OptionCode it will only return the first one found. If no matching option is found nil will be returned.

func (*DHCPv4) GetOption

func (d *DHCPv4) GetOption(code OptionCode) []Option

GetOption will attempt to get all options that match a DHCPv4 option from its OptionCode. If the option was not found it will return an empty list.

func (*DHCPv4) HopCount

func (d *DHCPv4) HopCount() uint8

HopCount returns the hop count field.

func (*DHCPv4) HwAddrLen

func (d *DHCPv4) HwAddrLen() uint8

HwAddrLen returns the hardware address length. E.g. for Ethernet it would return 6.

func (*DHCPv4) HwType

func (d *DHCPv4) HwType() iana.HwTypeType

HwType returns the hardware type as defined by IANA.

func (*DHCPv4) HwTypeToString

func (d *DHCPv4) HwTypeToString() string

HwTypeToString returns the mnemonic name for the hardware type, e.g. "Ethernet". If the type is unknown, it returns "Unknown".

func (*DHCPv4) IsBroadcast

func (d *DHCPv4) IsBroadcast() bool

IsBroadcast indicates whether the packet is a broadcast packet.

func (*DHCPv4) IsUnicast

func (d *DHCPv4) IsUnicast() bool

IsUnicast indicates whether the packet is a unicast packet.

func (*DHCPv4) NumSeconds

func (d *DHCPv4) NumSeconds() uint16

NumSeconds returns the number of seconds.

func (*DHCPv4) Opcode

func (d *DHCPv4) Opcode() OpcodeType

Opcode returns the OpcodeType for the packet,

func (*DHCPv4) OpcodeToString

func (d *DHCPv4) OpcodeToString() string

OpcodeToString returns the mnemonic name for the packet's opcode.

func (*DHCPv4) Options

func (d *DHCPv4) Options() []Option

Options returns the DHCPv4 options defined for the packet.

func (*DHCPv4) ServerHostName

func (d *DHCPv4) ServerHostName() [64]byte

ServerHostName returns the server host name as a sequence of bytes.

func (*DHCPv4) ServerHostNameToString

func (d *DHCPv4) ServerHostNameToString() string

ServerHostNameToString returns the server host name as a string, after trimming the null bytes at the end.

func (*DHCPv4) ServerIPAddr

func (d *DHCPv4) ServerIPAddr() net.IP

ServerIPAddr returns the server IP address.

func (*DHCPv4) SetBootFileName

func (d *DHCPv4) SetBootFileName(bootFileName []byte)

SetBootFileName replaces the boot file name, from a sequence of bytes, truncating it to the maximum length oh 128.

func (*DHCPv4) SetBroadcast

func (d *DHCPv4) SetBroadcast()

SetBroadcast sets the packet to be a broadcast packet.

func (*DHCPv4) SetClientHwAddr

func (d *DHCPv4) SetClientHwAddr(clientHwAddr []byte)

SetClientHwAddr sets the client hardware address.

func (*DHCPv4) SetClientIPAddr

func (d *DHCPv4) SetClientIPAddr(clientIPAddr net.IP)

SetClientIPAddr sets the client IP address.

func (*DHCPv4) SetFlags

func (d *DHCPv4) SetFlags(flags uint16)

SetFlags sets the flags field in the packet.

func (*DHCPv4) SetGatewayIPAddr

func (d *DHCPv4) SetGatewayIPAddr(gatewayIPAddr net.IP)

SetGatewayIPAddr sets the gateway IP address.

func (*DHCPv4) SetHopCount

func (d *DHCPv4) SetHopCount(hopCount uint8)

SetHopCount sets the hop count value.

func (*DHCPv4) SetHwAddrLen

func (d *DHCPv4) SetHwAddrLen(hwAddrLen uint8)

SetHwAddrLen sets the hardware address length, limiting it to the maximum size 16 that the standard allows.

func (*DHCPv4) SetHwType

func (d *DHCPv4) SetHwType(hwType iana.HwTypeType)

SetHwType returns the hardware type as defined by IANA.

func (*DHCPv4) SetNumSeconds

func (d *DHCPv4) SetNumSeconds(numSeconds uint16)

SetNumSeconds sets the seconds field.

func (*DHCPv4) SetOpcode

func (d *DHCPv4) SetOpcode(opcode OpcodeType)

SetOpcode sets a new opcode for the packet. It prints a warning if the opcode is unknown, but does not generate an error.

func (*DHCPv4) SetOptions

func (d *DHCPv4) SetOptions(options []Option)

SetOptions replaces the current options with the provided ones.

func (*DHCPv4) SetServerHostName

func (d *DHCPv4) SetServerHostName(serverHostName []byte)

SetServerHostName replaces the server host name, from a sequence of bytes, truncating it to the maximum length of 64.

func (*DHCPv4) SetServerIPAddr

func (d *DHCPv4) SetServerIPAddr(serverIPAddr net.IP)

SetServerIPAddr sets the server IP address.

func (*DHCPv4) SetTransactionID

func (d *DHCPv4) SetTransactionID(transactionID uint32)

SetTransactionID sets the value for the transaction ID.

func (*DHCPv4) SetUnicast

func (d *DHCPv4) SetUnicast()

SetUnicast sets the packet to be a unicast packet.

func (*DHCPv4) SetYourIPAddr

func (d *DHCPv4) SetYourIPAddr(yourIPAddr net.IP)

SetYourIPAddr sets the "your IP address" field.

func (*DHCPv4) String

func (d *DHCPv4) String() string

func (*DHCPv4) StrippedOptions

func (d *DHCPv4) StrippedOptions() []Option

StrippedOptions works like Options, but it does not return anything after the End option.

func (*DHCPv4) Summary

func (d *DHCPv4) Summary() string

Summary prints detailed information about the packet.

func (*DHCPv4) ToBytes

func (d *DHCPv4) ToBytes() []byte

ToBytes encodes a DHCPv4 structure into a sequence of bytes in its wire format.

func (*DHCPv4) TransactionID

func (d *DHCPv4) TransactionID() uint32

TransactionID returns the transaction ID as 32 bit unsigned integer.

func (*DHCPv4) ValidateOptions

func (d *DHCPv4) ValidateOptions()

ValidateOptions runs sanity checks on the DHCPv4 packet and prints a number of warnings if something is incorrect.

func (*DHCPv4) YourIPAddr

func (d *DHCPv4) YourIPAddr() net.IP

YourIPAddr returns the "your IP address" field.

type MessageType

type MessageType byte

MessageType represents the possible DHCP message types - DISCOVER, OFFER, etc

const (
	MessageTypeDiscover MessageType = 1
	MessageTypeOffer    MessageType = 2
	MessageTypeRequest  MessageType = 3
	MessageTypeDecline  MessageType = 4
	MessageTypeAck      MessageType = 5
	MessageTypeNak      MessageType = 6
	MessageTypeRelease  MessageType = 7
	MessageTypeInform   MessageType = 8
)

DHCP message types

type OpcodeType

type OpcodeType uint8

OpcodeType represents a DHCPv4 opcode.

const (
	OpcodeBootRequest OpcodeType = 1
	OpcodeBootReply   OpcodeType = 2
)

constants that represent valid values for OpcodeType

type OptBroadcastAddress

type OptBroadcastAddress struct {
	BroadcastAddress net.IP
}

OptBroadcastAddress represents an option encapsulating the server identifier.

func ParseOptBroadcastAddress

func ParseOptBroadcastAddress(data []byte) (*OptBroadcastAddress, error)

ParseOptBroadcastAddress returns a new OptBroadcastAddress from a byte stream, or error if any.

func (*OptBroadcastAddress) Code

func (o *OptBroadcastAddress) Code() OptionCode

Code returns the option code.

func (*OptBroadcastAddress) Length

func (o *OptBroadcastAddress) Length() int

Length returns the length of the data portion (excluding option code an byte length).

func (*OptBroadcastAddress) String

func (o *OptBroadcastAddress) String() string

String returns a human-readable string.

func (*OptBroadcastAddress) ToBytes

func (o *OptBroadcastAddress) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptClassIdentifier

type OptClassIdentifier struct {
	Identifier string
}

OptClassIdentifier represents the DHCP message type option.

func ParseOptClassIdentifier

func ParseOptClassIdentifier(data []byte) (*OptClassIdentifier, error)

ParseOptClassIdentifier constructs an OptClassIdentifier struct from a sequence of bytes and returns it, or an error.

func (*OptClassIdentifier) Code

func (o *OptClassIdentifier) Code() OptionCode

Code returns the option code.

func (*OptClassIdentifier) Length

func (o *OptClassIdentifier) Length() int

Length returns the length of the data portion (excluding option code and byte for length, if any).

func (*OptClassIdentifier) String

func (o *OptClassIdentifier) String() string

String returns a human-readable string for this option.

func (*OptClassIdentifier) ToBytes

func (o *OptClassIdentifier) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptDomainName

type OptDomainName struct {
	DomainName string
}

OptDomainName represents an option encapsulating the server identifier.

func ParseOptDomainName

func ParseOptDomainName(data []byte) (*OptDomainName, error)

ParseOptDomainName returns a new OptDomainName from a byte stream, or error if any.

func (*OptDomainName) Code

func (o *OptDomainName) Code() OptionCode

Code returns the option code.

func (*OptDomainName) Length

func (o *OptDomainName) Length() int

Length returns the length of the data portion (excluding option code an byte length).

func (*OptDomainName) String

func (o *OptDomainName) String() string

String returns a human-readable string.

func (*OptDomainName) ToBytes

func (o *OptDomainName) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptMaximumDHCPMessageSize

type OptMaximumDHCPMessageSize struct {
	Size uint16
}

OptMaximumDHCPMessageSize represents the DHCP message type option.

func ParseOptMaximumDHCPMessageSize

func ParseOptMaximumDHCPMessageSize(data []byte) (*OptMaximumDHCPMessageSize, error)

ParseOptMaximumDHCPMessageSize constructs an OptMaximumDHCPMessageSize struct from a sequence of bytes and returns it, or an error.

func (*OptMaximumDHCPMessageSize) Code

Code returns the option code.

func (*OptMaximumDHCPMessageSize) Length

func (o *OptMaximumDHCPMessageSize) Length() int

Length returns the length of the data portion (excluding option code and byte for length, if any).

func (*OptMaximumDHCPMessageSize) String

func (o *OptMaximumDHCPMessageSize) String() string

String returns a human-readable string for this option.

func (*OptMaximumDHCPMessageSize) ToBytes

func (o *OptMaximumDHCPMessageSize) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptMessageType

type OptMessageType struct {
	MessageType MessageType
}

OptMessageType represents the DHCP message type option.

func ParseOptMessageType

func ParseOptMessageType(data []byte) (*OptMessageType, error)

ParseOptMessageType constructs an OptMessageType struct from a sequence of bytes and returns it, or an error.

func (*OptMessageType) Code

func (o *OptMessageType) Code() OptionCode

Code returns the option code.

func (*OptMessageType) Length

func (o *OptMessageType) Length() int

Length returns the length of the data portion (excluding option code and byte for length, if any).

func (*OptMessageType) String

func (o *OptMessageType) String() string

String returns a human-readable string for this option.

func (*OptMessageType) ToBytes

func (o *OptMessageType) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptParameterRequestList

type OptParameterRequestList struct {
	RequestedOpts []OptionCode
}

OptParameterRequestList represents the parameter request list option.

func ParseOptParameterRequestList

func ParseOptParameterRequestList(data []byte) (*OptParameterRequestList, error)

ParseOptParameterRequestList returns a new OptParameterRequestList from a byte stream, or error if any.

func (*OptParameterRequestList) Code

Code returns the option code.

func (*OptParameterRequestList) Length

func (o *OptParameterRequestList) Length() int

Length returns the length of the data portion (excluding option code and byte for length, if any).

func (*OptParameterRequestList) String

func (o *OptParameterRequestList) String() string

String returns a human-readable string for this option.

func (*OptParameterRequestList) ToBytes

func (o *OptParameterRequestList) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptRequestedIPAddress

type OptRequestedIPAddress struct {
	RequestedAddr net.IP
}

OptRequestedIPAddress represents an option encapsulating the server identifier.

func ParseOptRequestedIPAddress

func ParseOptRequestedIPAddress(data []byte) (*OptRequestedIPAddress, error)

ParseOptRequestedIPAddress returns a new OptServerIdentifier from a byte stream, or error if any.

func (*OptRequestedIPAddress) Code

Code returns the option code.

func (*OptRequestedIPAddress) Length

func (o *OptRequestedIPAddress) Length() int

Length returns the length of the data portion (excluding option code an byte length).

func (*OptRequestedIPAddress) String

func (o *OptRequestedIPAddress) String() string

String returns a human-readable string.

func (*OptRequestedIPAddress) ToBytes

func (o *OptRequestedIPAddress) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptServerIdentifier

type OptServerIdentifier struct {
	ServerID net.IP
}

OptServerIdentifier represents an option encapsulating the server identifier.

func ParseOptServerIdentifier

func ParseOptServerIdentifier(data []byte) (*OptServerIdentifier, error)

ParseOptServerIdentifier returns a new OptServerIdentifier from a byte stream, or error if any.

func (*OptServerIdentifier) Code

func (o *OptServerIdentifier) Code() OptionCode

Code returns the option code.

func (*OptServerIdentifier) Length

func (o *OptServerIdentifier) Length() int

Length returns the length of the data portion (excluding option code an byte length).

func (*OptServerIdentifier) String

func (o *OptServerIdentifier) String() string

String returns a human-readable string.

func (*OptServerIdentifier) ToBytes

func (o *OptServerIdentifier) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type OptVIVC

type OptVIVC struct {
	Identifiers []VIVCIdentifier
}

OptVIVC represents the DHCP message type option.

func ParseOptVIVC

func ParseOptVIVC(data []byte) (*OptVIVC, error)

ParseOptVIVC contructs an OptVIVC tsruct from a sequence of bytes and returns it, or an error.

func (*OptVIVC) Code

func (o *OptVIVC) Code() OptionCode

Code returns the option code.

func (*OptVIVC) Length

func (o *OptVIVC) Length() int

Length returns the length of the data portion (excluding option code and byte for length, if any).

func (*OptVIVC) String

func (o *OptVIVC) String() string

String returns a human-readable string for this option.

func (*OptVIVC) ToBytes

func (o *OptVIVC) ToBytes() []byte

ToBytes returns a serialized stream of bytes for this option.

type Option

type Option interface {
	Code() OptionCode
	ToBytes() []byte
	Length() int
	String() string
}

Option is an interface that all DHCP v4 options adhere to.

func OptionsFromBytes

func OptionsFromBytes(data []byte) ([]Option, error)

OptionsFromBytes parses a sequence of bytes until the end and builds a list of options from it. The sequence must contain the Magic Cookie. Returns an error if any invalid option or length is found.

func OptionsFromBytesWithoutMagicCookie

func OptionsFromBytesWithoutMagicCookie(data []byte) ([]Option, error)

OptionsFromBytesWithoutMagicCookie parses a sequence of bytes until the end and builds a list of options from it. The sequence should not contain the DHCP magic cookie. Returns an error if any invalid option or length is found.

func ParseOption

func ParseOption(data []byte) (Option, error)

ParseOption parses a sequence of bytes as a single DHCPv4 option, returning the specific option structure or error, if any.

type OptionCode

type OptionCode byte

OptionCode is a single byte representing the code for a given Option.

const (
	OptionPad                                        OptionCode = 0
	OptionSubnetMask                                 OptionCode = 1
	OptionTimeOffset                                 OptionCode = 2
	OptionRouter                                     OptionCode = 3
	OptionTimeServer                                 OptionCode = 4
	OptionNameServer                                 OptionCode = 5
	OptionDomainNameServer                           OptionCode = 6
	OptionLogServer                                  OptionCode = 7
	OptionQuoteServer                                OptionCode = 8
	OptionLPRServer                                  OptionCode = 9
	OptionImpressServer                              OptionCode = 10
	OptionResourceLocationServer                     OptionCode = 11
	OptionHostName                                   OptionCode = 12
	OptionBootFileSize                               OptionCode = 13
	OptionMeritDumpFile                              OptionCode = 14
	OptionDomainName                                 OptionCode = 15
	OptionSwapServer                                 OptionCode = 16
	OptionRootPath                                   OptionCode = 17
	OptionExtensionsPath                             OptionCode = 18
	OptionIPForwarding                               OptionCode = 19
	OptionNonLocalSourceRouting                      OptionCode = 20
	OptionPolicyFilter                               OptionCode = 21
	OptionMaximumDatagramAssemblySize                OptionCode = 22
	OptionDefaultIPTTL                               OptionCode = 23
	OptionPathMTUAgingTimeout                        OptionCode = 24
	OptionPathMTUPlateauTable                        OptionCode = 25
	OptionInterfaceMTU                               OptionCode = 26
	OptionAllSubnetsAreLocal                         OptionCode = 27
	OptionBroadcastAddress                           OptionCode = 28
	OptionPerformMaskDiscovery                       OptionCode = 29
	OptionMaskSupplier                               OptionCode = 30
	OptionPerformRouterDiscovery                     OptionCode = 31
	OptionRouterSolicitationAddress                  OptionCode = 32
	OptionStaticRoutingTable                         OptionCode = 33
	OptionTrailerEncapsulation                       OptionCode = 34
	OptionArpCacheTimeout                            OptionCode = 35
	OptionEthernetEncapsulation                      OptionCode = 36
	OptionDefaulTCPTTL                               OptionCode = 37
	OptionTCPKeepaliveInterval                       OptionCode = 38
	OptionTCPKeepaliveGarbage                        OptionCode = 39
	OptionNetworkInformationServiceDomain            OptionCode = 40
	OptionNetworkInformationServers                  OptionCode = 41
	OptionNTPServers                                 OptionCode = 42
	OptionVendorSpecificInformation                  OptionCode = 43
	OptionNetBIOSOverTCPIPNameServer                 OptionCode = 44
	OptionNetBIOSOverTCPIPDatagramDistributionServer OptionCode = 45
	OptionNetBIOSOverTCPIPNodeType                   OptionCode = 46
	OptionNetBIOSOverTCPIPScope                      OptionCode = 47
	OptionXWindowSystemFontServer                    OptionCode = 48
	OptionXWindowSystemDisplayManger                 OptionCode = 49
	OptionRequestedIPAddress                         OptionCode = 50
	OptionIPAddressLeaseTime                         OptionCode = 51
	OptionOptionOverload                             OptionCode = 52
	OptionDHCPMessageType                            OptionCode = 53
	OptionServerIdentifier                           OptionCode = 54
	OptionParameterRequestList                       OptionCode = 55
	OptionMessage                                    OptionCode = 56
	OptionMaximumDHCPMessageSize                     OptionCode = 57
	OptionRenewTimeValue                             OptionCode = 58
	OptionRebindingTimeValue                         OptionCode = 59
	OptionClassIdentifier                            OptionCode = 60
	OptionClientIdentifier                           OptionCode = 61
	OptionNetWareIPDomainName                        OptionCode = 62
	OptionNetWareIPInformation                       OptionCode = 63
	OptionNetworkInformationServicePlusDomain        OptionCode = 64
	OptionNetworkInformationServicePlusServers       OptionCode = 65
	OptionTFTPServerName                             OptionCode = 66
	OptionBootfileName                               OptionCode = 67
	OptionMobileIPHomeAgent                          OptionCode = 68
	OptionSimpleMailTransportProtocolServer          OptionCode = 69
	OptionPostOfficeProtocolServer                   OptionCode = 70
	OptionNetworkNewsTransportProtocolServer         OptionCode = 71
	OptionDefaultWorldWideWebServer                  OptionCode = 72
	OptionDefaultFingerServer                        OptionCode = 73
	OptionDefaultInternetRelayChatServer             OptionCode = 74
	OptionStreetTalkServer                           OptionCode = 75
	OptionStreetTalkDirectoryAssistanceServer        OptionCode = 76
	OptionUserClassInformation                       OptionCode = 77
	OptionSLPDirectoryAgent                          OptionCode = 78
	OptionSLPServiceScope                            OptionCode = 79
	OptionRapidCommit                                OptionCode = 80
	OptionFQDN                                       OptionCode = 81
	OptionRelayAgentInformation                      OptionCode = 82
	OptionInternetStorageNameService                 OptionCode = 83
	// Option 84 returned in RFC 3679
	OptionNDSServers                       OptionCode = 85
	OptionNDSTreeName                      OptionCode = 86
	OptionNDSContext                       OptionCode = 87
	OptionBCMCSControllerDomainNameList    OptionCode = 88
	OptionBCMCSControllerIPv4AddressList   OptionCode = 89
	OptionAuthentication                   OptionCode = 90
	OptionClientLastTransactionTime        OptionCode = 91
	OptionAssociatedIP                     OptionCode = 92
	OptionClientSystemArchitectureType     OptionCode = 93
	OptionClientNetworkInterfaceIdentifier OptionCode = 94
	OptionLDAP                             OptionCode = 95
	// Option 96 returned in RFC 3679
	OptionClientMachineIdentifier     OptionCode = 97
	OptionOpenGroupUserAuthentication OptionCode = 98
	OptionGeoConfCivic                OptionCode = 99
	OptionIEEE10031TZString           OptionCode = 100
	OptionReferenceToTZDatabase       OptionCode = 101
	// Options 102-111 returned in RFC 3679
	OptionNetInfoParentServerAddress OptionCode = 112
	OptionNetInfoParentServerTag     OptionCode = 113
	OptionURL                        OptionCode = 114
	// Option 115 returned in RFC 3679
	OptionAutoConfigure                   OptionCode = 116
	OptionNameServiceSearch               OptionCode = 117
	OptionSubnetSelection                 OptionCode = 118
	OptionDNSDomainSearchList             OptionCode = 119
	OptionSIPServersDHCPOption            OptionCode = 120
	OptionClasslessStaticRouteOption      OptionCode = 121
	OptionCCC                             OptionCode = 122
	OptionGeoConf                         OptionCode = 123
	OptionVendorIdentifyingVendorClass    OptionCode = 124
	OptionVendorIdentifyingVendorSpecific OptionCode = 125
	// Options 126-127 returned in RFC 3679
	OptionTFTPServerIPAddress                   OptionCode = 128
	OptionCallServerIPAddress                   OptionCode = 129
	OptionDiscriminationString                  OptionCode = 130
	OptionRemoteStatisticsServerIPAddress       OptionCode = 131
	Option8021PVLANID                           OptionCode = 132
	Option8021QL2Priority                       OptionCode = 133
	OptionDiffservCodePoint                     OptionCode = 134
	OptionHTTPProxyForPhoneSpecificApplications OptionCode = 135
	OptionPANAAuthenticationAgent               OptionCode = 136
	OptionLoSTServer                            OptionCode = 137
	OptionCAPWAPAccessControllerAddresses       OptionCode = 138
	OptionOPTIONIPv4AddressMoS                  OptionCode = 139
	OptionOPTIONIPv4FQDNMoS                     OptionCode = 140
	OptionSIPUAConfigurationServiceDomains      OptionCode = 141
	OptionOPTIONIPv4AddressANDSF                OptionCode = 142
	OptionOPTIONIPv6AddressANDSF                OptionCode = 143
	// Options 144-149 returned in RFC 3679
	OptionTFTPServerAddress OptionCode = 150
	OptionStatusCode        OptionCode = 151
	OptionBaseTime          OptionCode = 152
	OptionStartTimeOfState  OptionCode = 153
	OptionQueryStartTime    OptionCode = 154
	OptionQueryEndTime      OptionCode = 155
	OptionDHCPState         OptionCode = 156
	OptionDataSource        OptionCode = 157
	// Options 158-174 returned in RFC 3679
	OptionEtherboot                        OptionCode = 175
	OptionIPTelephone                      OptionCode = 176
	OptionEtherbootPacketCableAndCableHome OptionCode = 177
	// Options 178-207 returned in RFC 3679
	OptionPXELinuxMagicString  OptionCode = 208
	OptionPXELinuxConfigFile   OptionCode = 209
	OptionPXELinuxPathPrefix   OptionCode = 210
	OptionPXELinuxRebootTime   OptionCode = 211
	OptionOPTION6RD            OptionCode = 212
	OptionOPTIONv4AccessDomain OptionCode = 213
	// Options 214-219 returned in RFC 3679
	OptionSubnetAllocation        OptionCode = 220
	OptionVirtualSubnetAllocation OptionCode = 221
	// Options 222-223 returned in RFC 3679
	// Options 224-254 are reserved for private use
	OptionEnd OptionCode = 255
)

DHCPv4 Options

type OptionGeneric

type OptionGeneric struct {
	OptionCode OptionCode
	Data       []byte
}

OptionGeneric is an option that only contains the option code and associated data. Every option that does not have a specific implementation will fall back to this option.

func ParseOptionGeneric

func ParseOptionGeneric(data []byte) (*OptionGeneric, error)

ParseOptionGeneric parses a bytestream and creates a new OptionGeneric from it, or an error.

func (OptionGeneric) Code

func (o OptionGeneric) Code() OptionCode

Code returns the generic option code.

func (OptionGeneric) Length

func (o OptionGeneric) Length() int

Length returns the number of bytes comprising the data section of the option.

func (OptionGeneric) String

func (o OptionGeneric) String() string

String returns a human-readable representation of a generic option.

func (OptionGeneric) ToBytes

func (o OptionGeneric) ToBytes() []byte

ToBytes returns a serialized generic option as a slice of bytes.

type VIVCIdentifier

type VIVCIdentifier struct {
	EntID uint32
	Data  []byte
}

VIVCIdentifier represents one Vendor-Identifying vendor class option.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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