package dhcp import ( "fmt" "io" ) type OptionTag uint8 func (opt OptionTag) String() string { s, ok := optionStrings[opt] if !ok { panic(fmt.Sprintf("no string for option %d", opt)) } return s } type Option func(req *BootRequest, r io.Reader) error const ( OptionTagPadding OptionTag = 0 OptionTagSubnetMask OptionTag = 1 OptionTagTimeOffset OptionTag = 2 OptionTagRouter OptionTag = 3 OptionTagDomainNameServer OptionTag = 6 OptionTagHostName OptionTag = 12 OptionTagDomainName OptionTag = 15 OptionTagInterfaceMTU OptionTag = 26 OptionTagBroadcastAddress OptionTag = 28 OptionTagNTPServers OptionTag = 42 OptionTagNBNS OptionTag = 44 OptionTagNBScope OptionTag = 47 OptionTagMessageType OptionTag = 53 OptionTagParameterRequestList OptionTag = 55 OptionTagDHCPMaxMessageSize OptionTag = 57 OptionTagClientID OptionTag = 61 OptionTagDomainSearch OptionTag = 119 OptionTagClasslessStaticRoute OptionTag = 121 OptionTagEnd OptionTag = 255 ) var optionStrings = map[OptionTag]string{ OptionTagPadding: "pad", OptionTagSubnetMask: "subnet mask", OptionTagTimeOffset: "time offset from UTC", OptionTagRouter: "routers", OptionTagDomainNameServer: "domain name servers", OptionTagHostName: "host name", OptionTagDomainName: "domain name", OptionTagInterfaceMTU: "interface MTU", OptionTagBroadcastAddress: "broadcast address", OptionTagNTPServers: "NTP servers", OptionTagNBNS: "NetBIOS name servers", OptionTagNBScope: "NetBIOS scope", OptionTagMessageType: "message type", OptionTagParameterRequestList: "parameter request list", OptionTagDHCPMaxMessageSize: "DHCP max message size", OptionTagClientID: "client ID", OptionTagDomainSearch: "search domain", OptionTagClasslessStaticRoute: "classless static route", OptionTagEnd: "end", } type DHCPMessageType uint8 const ( DHCPMessageTypeDiscover DHCPMessageType = 1 DHCPMessageTypeOffer DHCPMessageType = 2 DHCPMessageTypeRequest DHCPMessageType = 3 DHCPMessageTypeDecline DHCPMessageType = 4 DHCPMessageTypeAck DHCPMessageType = 5 DHCPMessageTypeNAK DHCPMessageType = 6 DHCPMessageTypeRelease DHCPMessageType = 7 DHCPMessageTypeInform DHCPMessageType = 8 )