Documentation ¶
Index ¶
Constants ¶
View Source
const ( SizeHeader = 44 // Magic Cookie offset measured from the start of the UDP payload. MagicCookieOffset = SizeHeader + sizeSName + sizeBootFile // Expected Magic Cookie value. MagicCookie uint32 = 0x63825363 // DHCP Options offset measured from the start of the UDP payload. OptionsOffset = MagicCookieOffset + 4 DefaultClientPort = 68 DefaultServerPort = 67 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientState ¶
type ClientState uint8
ClientState represents the state of a DHCP client. Below is a state diagram of a DHCP client.
const ( // On clean slate boot, abort, NAK or decline enter the INIT state. StateInit ClientState // After sending out a Discover enter SELECTING. StateSelecting // After receiving a worthy offer enter REQUESTING. StateRequesting // On reboot enter INIT-REBOOT state. // StateInitReboot // On sending out a Request enter REBOOTING. // StateRebooting // On ACK to Request enter BOUND. StateBound )
install stringer with `go install golang.org/x/tools/cmd/stringer@latest`
func (ClientState) IsValid ¶
func (s ClientState) IsValid() bool
IsValid returns true if the state is within the valid range.
func (ClientState) String ¶
func (i ClientState) String() string
type HeaderV4 ¶
type HeaderV4 struct { OP Op // 0:1 // Htype is the hardware address type. 1 for Ethernet. HType byte // 1:2 HLen uint8 // 2:3 HOps uint8 // 3:4 Xid uint32 // 4:8 Secs uint16 // 8:10 Flags uint16 // 10:12 // CIAddr is the client IP address. If the client has not obtained an IP // address yet, this field is set to 0. CIAddr [4]byte // 12:16 // YIAddr is the IP address offered by the server to the client. YIAddr [4]byte // 16:20 // SIAddr is the IP address of the next server to use in bootstrap. This // field is used in DHCPOFFER and DHCPACK messages. SIAddr [4]byte // 20:24 // GIAddr is the gateway IP address. GIAddr [4]byte // 24:28 // CHAddr is the client hardware address. Can be up to 16 bytes in length but // is usually 6 bytes for Ethernet. CHAddr [16]byte // 28:44 }
HeaderV4 specifies the first 44 bytes of a DHCP packet payload. It does not include BOOTP, magic cookie and options. Reference: https://lists.gnu.org/archive/html/lwip-users/2012-12/msg00016.html
func DecodeHeaderV4 ¶
type MessageType ¶
type MessageType uint8
const ( MsgDiscover MessageType = iota + 1 MsgOffer MsgRequest MsgDecline MsgAck MsgNak MsgRelease MsgInform )
func (MessageType) String ¶
func (i MessageType) String() string
type OptNum ¶
type OptNum uint8
const ( OptWordAligned OptNum = 0 OptSubnetMask OptNum = 1 OptTimeOffset OptNum = 2 // Time offset in seconds from UTC OptRouter OptNum = 3 // N/4 router addresses OptTimeServers OptNum = 4 // N/4 time server addresses OptNameServers OptNum = 5 // N/4 IEN-116 server addresses OptDNSServers OptNum = 6 // N/4 DNS server addresses OptLogServers OptNum = 7 // N/4 logging server addresses OptCookieServers OptNum = 8 // N/4 quote server addresses OptLPRServers OptNum = 9 // N/4 printer server addresses OptImpressServers OptNum = 10 // N/4 impress server addresses OptRLPServers OptNum = 11 // N/4 RLP server addresses OptHostName OptNum = 12 // Hostname string OptBootFileSize OptNum = 13 // Size of boot file in 512 byte chunks OptMeritDumpFile OptNum = 14 // Client to dump and name of file to dump to OptDomainName OptNum = 15 // The DNS domain name of the client OptSwapServer OptNum = 16 // Swap server addresses OptRootPath OptNum = 17 // Path name for root disk OptExtensionFile OptNum = 18 // Patch name for more BOOTP info OptIPLayerForwarding OptNum = 19 // Enable or disable IP forwarding OptSrcrouteenabler OptNum = 20 // Enable or disable source routing OptPolicyFilter OptNum = 21 // Routing policy filters OptMaximumDGReassemblySize OptNum = 22 // Maximum datagram reassembly size OptDefaultIPTTL OptNum = 23 // Default IP time-to-live OptPathMTUAgingTimeout OptNum = 24 // Path MTU aging timeout OptMTUPlateau OptNum = 25 // Path MTU plateau table OptInterfaceMTUSize OptNum = 26 // Interface MTU size OptAllSubnetsAreLocal OptNum = 27 // All subnets are local OptBroadcastAddress OptNum = 28 // Broadcast address OptPerformMaskDiscovery OptNum = 29 // Perform mask discovery OptProvideMasktoOthers OptNum = 30 // Provide mask to others OptPerformRouterDiscovery OptNum = 31 // Perform router discovery OptRouterSolicitationAddress OptNum = 32 // Router solicitation address OptStaticRoutingTable OptNum = 33 // Static routing table OptTrailerEncapsulation OptNum = 34 // Trailer encapsulation OptARPCacheTimeout OptNum = 35 // ARP cache timeout OptEthernetEncapsulation OptNum = 36 // Ethernet encapsulation OptDefaultTCPTimetoLive OptNum = 37 // Default TCP time to live OptTCPKeepaliveInterval OptNum = 38 // TCP keepalive interval OptTCPKeepaliveGarbage OptNum = 39 // TCP keepalive garbage OptNISDomainName OptNum = 40 // NIS domain name OptNISServerAddresses OptNum = 41 // NIS server addresses OptNTPServersAddresses OptNum = 42 // NTP servers addresses OptVendorSpecificInformation OptNum = 43 // Vendor specific information OptNetBIOSNameServer OptNum = 44 // NetBIOS name server OptNetBIOSDatagramDistribution OptNum = 45 // NetBIOS datagram distribution OptNetBIOSNodeType OptNum = 46 // NetBIOS node type OptNetBIOSScope OptNum = 47 // NetBIOS scope OptXWindowFontServer OptNum = 48 // X window font server OptXWindowDisplayManager OptNum = 49 // X window display manager OptRequestedIPaddress OptNum = 50 // Requested IP address OptIPAddressLeaseTime OptNum = 51 // IP address lease time OptOptionOverload OptNum = 52 // Overload “sname” or “file” OptMessageType OptNum = 53 // DHCP message type. OptServerIdentification OptNum = 54 // DHCP server identification OptParameterRequestList OptNum = 55 // Parameter request list OptMessage OptNum = 56 // DHCP error message OptMaximumMessageSize OptNum = 57 // DHCP maximum message size OptRenewTimeValue OptNum = 58 // DHCP renewal (T1) time OptRebindingTimeValue OptNum = 59 // DHCP rebinding (T2) time OptClientIdentifier OptNum = 60 // Client identifier OptClientIdentifier1 OptNum = 61 // Client identifier )
DHCP options. Taken from https://help.sonicwall.com/help/sw/eng/6800/26/2/3/content/Network_DHCP_Server.042.12.htm.
Click to show internal directories.
Click to hide internal directories.