Documentation ¶
Index ¶
- Constants
- Variables
- func BindToInterface(fd int, ifname string) error
- func GenerateTransactionID() (*uint32, error)
- func IPv4AddrsForInterface(iface *net.Interface) ([]net.IP, error)
- func MakeBroadcastSocket(ifname string) (int, error)
- func MakeListeningSocket(ifname string) (int, error)
- func MakeRawBroadcastPacket(payload []byte) ([]byte, error)
- type Client
- type DHCPv4
- func BroadcastSendReceive(sendFd, recvFd int, packet *DHCPv4, readTimeout, writeTimeout time.Duration) (*DHCPv4, error)
- func FromBytes(data []byte) (*DHCPv4, error)
- func New() (*DHCPv4, error)
- func NewDiscoveryForInterface(ifname string) (*DHCPv4, error)
- func NewInformForInterface(ifname string, needsBroadcast bool) (*DHCPv4, error)
- func RequestFromOffer(offer DHCPv4) (*DHCPv4, error)
- func (d *DHCPv4) AddOption(option Option)
- func (d *DHCPv4) BootFileName() [128]byte
- func (d *DHCPv4) BootFileNameToString() string
- func (d *DHCPv4) ClientHwAddr() [16]byte
- func (d *DHCPv4) ClientHwAddrToString() string
- func (d *DHCPv4) ClientIPAddr() net.IP
- func (d *DHCPv4) Flags() uint16
- func (d *DHCPv4) FlagsToString() string
- func (d *DHCPv4) GatewayIPAddr() net.IP
- func (d *DHCPv4) GetOneOption(code OptionCode) Option
- func (d *DHCPv4) GetOption(code OptionCode) []Option
- func (d *DHCPv4) HopCount() uint8
- func (d *DHCPv4) HwAddrLen() uint8
- func (d *DHCPv4) HwType() iana.HwTypeType
- func (d *DHCPv4) HwTypeToString() string
- func (d *DHCPv4) IsBroadcast() bool
- func (d *DHCPv4) IsUnicast() bool
- func (d *DHCPv4) NumSeconds() uint16
- func (d *DHCPv4) Opcode() OpcodeType
- func (d *DHCPv4) OpcodeToString() string
- func (d *DHCPv4) Options() []Option
- func (d *DHCPv4) ServerHostName() [64]byte
- func (d *DHCPv4) ServerHostNameToString() string
- func (d *DHCPv4) ServerIPAddr() net.IP
- func (d *DHCPv4) SetBootFileName(bootFileName []byte)
- func (d *DHCPv4) SetBroadcast()
- func (d *DHCPv4) SetClientHwAddr(clientHwAddr []byte)
- func (d *DHCPv4) SetClientIPAddr(clientIPAddr net.IP)
- func (d *DHCPv4) SetFlags(flags uint16)
- func (d *DHCPv4) SetGatewayIPAddr(gatewayIPAddr net.IP)
- func (d *DHCPv4) SetHopCount(hopCount uint8)
- func (d *DHCPv4) SetHwAddrLen(hwAddrLen uint8)
- func (d *DHCPv4) SetHwType(hwType iana.HwTypeType)
- func (d *DHCPv4) SetNumSeconds(numSeconds uint16)
- func (d *DHCPv4) SetOpcode(opcode OpcodeType)
- func (d *DHCPv4) SetOptions(options []Option)
- func (d *DHCPv4) SetServerHostName(serverHostName []byte)
- func (d *DHCPv4) SetServerIPAddr(serverIPAddr net.IP)
- func (d *DHCPv4) SetTransactionID(transactionID uint32)
- func (d *DHCPv4) SetUnicast()
- func (d *DHCPv4) SetYourIPAddr(yourIPAddr net.IP)
- func (d *DHCPv4) String() string
- func (d *DHCPv4) StrippedOptions() []Option
- func (d *DHCPv4) Summary() string
- func (d *DHCPv4) ToBytes() []byte
- func (d *DHCPv4) TransactionID() uint32
- func (d *DHCPv4) ValidateOptions()
- func (d *DHCPv4) YourIPAddr() net.IP
- type MessageType
- type OpcodeType
- type OptBroadcastAddress
- type OptClassIdentifier
- type OptDomainName
- type OptMaximumDHCPMessageSize
- type OptMessageType
- type OptParameterRequestList
- type OptRequestedIPAddress
- type OptServerIdentifier
- type OptVIVC
- type Option
- type OptionCode
- type OptionGeneric
- type VIVCIdentifier
Constants ¶
const ( ServerPort = 67 ClientPort = 68 )
const HeaderSize = 236
HeaderSize is the DHCPv4 header size in bytes.
const MaxMessageSize = 576
MaxMessageSize is the maximum size in bytes that a DHCPv4 packet can hold.
const (
MaxUDPReceivedPacketSize = 8192
)
MaxUDPReceivedPacketSize is the (arbitrary) maximum UDP packet size supported by this library. Theoretically could be up to 65kb.
Variables ¶
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 )
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.
var ErrZeroLengthByteStream = errors.New("zero-length byte stream")
ErrZeroLengthByteStream is an error that is thrown any time a zero-length byte stream is encountered.
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.
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.
var OpcodeToString = map[OpcodeType]string{ OpcodeBootRequest: "BootRequest", OpcodeBootReply: "BootReply", }
OpcodeToString maps an OpcodeType to its mnemonic name
var OptionCodeToString = map[OptionCode]string{}/* 149 elements not displayed */
OptionCodeToString maps an OptionCode to its mnemonic name
Functions ¶
func BindToInterface ¶
func GenerateTransactionID ¶
GenerateTransactionID generates a random 32-bits number suitable for use as TransactionID
func IPv4AddrsForInterface ¶
IPv4AddrsForInterface obtains the currently-configured, non-loopback IPv4 addresses for iface.
func MakeBroadcastSocket ¶
MakeBroadcastSocket creates a socket that can be passed to syscall.Sendto that will send packets out to the broadcast address.
func MakeListeningSocket ¶
MakeListeningSocket creates a listening socket on 0.0.0.0 for the DHCP client port and returns it.
func MakeRawBroadcastPacket ¶
MakeRawBroadcastPacket converts payload (a serialized DHCPv4 packet) into a raw packet suitable for UDP broadcast.
Types ¶
type Client ¶
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 ¶
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 ¶
FromBytes encodes the DHCPv4 packet into a sequence of bytes, and returns an error if the packet is not valid.
func New ¶
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 ¶
NewDiscoveryForInterface builds a new DHCPv4 Discovery message, with a default Ethernet HW type and the hardware address obtained from the specified interface.
func NewInformForInterface ¶
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 ¶
RequestFromOffer builds a DHCPv4 request from an offer.
func (*DHCPv4) BootFileName ¶
BootFileName returns the boot file name as a sequence of bytes.
func (*DHCPv4) BootFileNameToString ¶
BootFileNameToString returns the boot file name as a string, after trimming the null bytes at the end.
func (*DHCPv4) ClientHwAddr ¶
ClientHwAddr returns the client hardware (MAC) address.
func (*DHCPv4) ClientHwAddrToString ¶
ClientHwAddrToString converts the hardware address field to a string.
func (*DHCPv4) ClientIPAddr ¶
ClientIPAddr returns the client IP address.
func (*DHCPv4) FlagsToString ¶
FlagsToString returns a human-readable representation of the flags field.
func (*DHCPv4) GatewayIPAddr ¶
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) HwAddrLen ¶
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 ¶
HwTypeToString returns the mnemonic name for the hardware type, e.g. "Ethernet". If the type is unknown, it returns "Unknown".
func (*DHCPv4) IsBroadcast ¶
IsBroadcast indicates whether the packet is a broadcast packet.
func (*DHCPv4) NumSeconds ¶
NumSeconds returns the number of seconds.
func (*DHCPv4) Opcode ¶
func (d *DHCPv4) Opcode() OpcodeType
Opcode returns the OpcodeType for the packet,
func (*DHCPv4) OpcodeToString ¶
OpcodeToString returns the mnemonic name for the packet's opcode.
func (*DHCPv4) ServerHostName ¶
ServerHostName returns the server host name as a sequence of bytes.
func (*DHCPv4) ServerHostNameToString ¶
ServerHostNameToString returns the server host name as a string, after trimming the null bytes at the end.
func (*DHCPv4) ServerIPAddr ¶
ServerIPAddr returns the server IP address.
func (*DHCPv4) SetBootFileName ¶
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 ¶
SetClientHwAddr sets the client hardware address.
func (*DHCPv4) SetClientIPAddr ¶
SetClientIPAddr sets the client IP address.
func (*DHCPv4) SetGatewayIPAddr ¶
SetGatewayIPAddr sets the gateway IP address.
func (*DHCPv4) SetHopCount ¶
SetHopCount sets the hop count value.
func (*DHCPv4) SetHwAddrLen ¶
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 ¶
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 ¶
SetOptions replaces the current options with the provided ones.
func (*DHCPv4) SetServerHostName ¶
SetServerHostName replaces the server host name, from a sequence of bytes, truncating it to the maximum length of 64.
func (*DHCPv4) SetServerIPAddr ¶
SetServerIPAddr sets the server IP address.
func (*DHCPv4) SetTransactionID ¶
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 ¶
SetYourIPAddr sets the "your IP address" field.
func (*DHCPv4) StrippedOptions ¶
StrippedOptions works like Options, but it does not return anything after the End option.
func (*DHCPv4) ToBytes ¶
ToBytes encodes a DHCPv4 structure into a sequence of bytes in its wire format.
func (*DHCPv4) TransactionID ¶
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 ¶
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 ¶
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 ¶
func (o *OptMaximumDHCPMessageSize) Code() OptionCode
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 ¶
func (o *OptParameterRequestList) Code() OptionCode
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 ¶
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 ¶
func (o *OptRequestedIPAddress) Code() OptionCode
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 ¶
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 ¶
ParseOptVIVC contructs an OptVIVC tsruct from a sequence of bytes and returns it, or an error.
func (*OptVIVC) Length ¶
Length returns the length of the data portion (excluding option code and byte for length, if any).
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 ¶
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 ¶
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 ¶
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 ¶
VIVCIdentifier represents one Vendor-Identifying vendor class option.
Source Files ¶
- bindtodevice_linux.go
- client.go
- defaults.go
- dhcpv4.go
- option_broadcast_address.go
- option_class_identifier.go
- option_domain_name.go
- option_generic.go
- option_maximum_dhcp_message_size.go
- option_message_type.go
- option_parameter_request_list.go
- option_requested_ip_address.go
- option_server_identifier.go
- option_vivc.go
- options.go
- types.go