diff options
Diffstat (limited to 'dhcpv4')
-rw-r--r-- | dhcpv4/bsdp/bsdp_option_generic.go | 6 | ||||
-rw-r--r-- | dhcpv4/bsdp/bsdp_option_generic_test.go | 4 | ||||
-rw-r--r-- | dhcpv4/bsdp/option_vendor_specific_information.go | 7 | ||||
-rw-r--r-- | dhcpv4/bsdp/types.go | 48 | ||||
-rw-r--r-- | dhcpv4/option_generic_test.go | 4 | ||||
-rw-r--r-- | dhcpv4/option_parameter_request_list.go | 4 | ||||
-rw-r--r-- | dhcpv4/option_relay_agent_information.go | 2 | ||||
-rw-r--r-- | dhcpv4/option_relay_agent_information_test.go | 8 | ||||
-rw-r--r-- | dhcpv4/options.go | 43 | ||||
-rw-r--r-- | dhcpv4/options_test.go | 20 | ||||
-rw-r--r-- | dhcpv4/types.go | 331 |
11 files changed, 258 insertions, 219 deletions
diff --git a/dhcpv4/bsdp/bsdp_option_generic.go b/dhcpv4/bsdp/bsdp_option_generic.go index 3859d8b..e9e163f 100644 --- a/dhcpv4/bsdp/bsdp_option_generic.go +++ b/dhcpv4/bsdp/bsdp_option_generic.go @@ -32,9 +32,5 @@ func (o OptGeneric) ToBytes() []byte { // String returns a human-readable representation of a generic option. func (o OptGeneric) String() string { - code, ok := optionCodeToString[o.Code()] - if !ok { - code = "Unknown" - } - return fmt.Sprintf("%v -> %v", code, o.Data) + return fmt.Sprintf("%s -> %v", o.OptionCode, o.Data) } diff --git a/dhcpv4/bsdp/bsdp_option_generic_test.go b/dhcpv4/bsdp/bsdp_option_generic_test.go index fe78242..a813f95 100644 --- a/dhcpv4/bsdp/bsdp_option_generic_test.go +++ b/dhcpv4/bsdp/bsdp_option_generic_test.go @@ -50,8 +50,8 @@ func TestOptGenericString(t *testing.T) { func TestOptGenericStringUnknown(t *testing.T) { o := OptGeneric{ - OptionCode: 102, // Returend option code. + OptionCode: optionCode(102), // Returned option code. Data: []byte{5}, } - require.Equal(t, "Unknown -> [5]", o.String()) + require.Equal(t, "unknown -> [5]", o.String()) } diff --git a/dhcpv4/bsdp/option_vendor_specific_information.go b/dhcpv4/bsdp/option_vendor_specific_information.go index 7d68f7f..de144b3 100644 --- a/dhcpv4/bsdp/option_vendor_specific_information.go +++ b/dhcpv4/bsdp/option_vendor_specific_information.go @@ -48,10 +48,15 @@ func parseOption(code dhcpv4.OptionCode, data []byte) (dhcpv4.Option, error) { return opt, nil } +// codeGetter is a dhcpv4.OptionCodeGetter for BSDP optionCodes. +func codeGetter(c uint8) dhcpv4.OptionCode { + return optionCode(c) +} + // ParseOptVendorSpecificInformation constructs an OptVendorSpecificInformation struct from a sequence of // bytes and returns it, or an error. func ParseOptVendorSpecificInformation(data []byte) (*OptVendorSpecificInformation, error) { - options, err := dhcpv4.OptionsFromBytesWithParser(data, parseOption, false /* don't check for OptionEnd tag */) + options, err := dhcpv4.OptionsFromBytesWithParser(data, codeGetter, parseOption, false /* don't check for OptionEnd tag */) if err != nil { return nil, err } diff --git a/dhcpv4/bsdp/types.go b/dhcpv4/bsdp/types.go index aa9a824..4ce840f 100644 --- a/dhcpv4/bsdp/types.go +++ b/dhcpv4/bsdp/types.go @@ -1,34 +1,48 @@ package bsdp -import "github.com/insomniacslk/dhcp/dhcpv4" - // DefaultMacOSVendorClassIdentifier is a default vendor class identifier used // on non-darwin hosts where the vendor class identifier cannot be determined. // It should mostly be used for debugging if testing BSDP on a non-darwin // system. const DefaultMacOSVendorClassIdentifier = AppleVendorID + "/i386/MacMini6,1" +// optionCode are BSDP option codes. +// +// optionCode implements the dhcpv4.OptionCode interface. +type optionCode uint8 + +func (o optionCode) Code() uint8 { + return uint8(o) +} + +func (o optionCode) String() string { + if s, ok := optionCodeToString[o]; ok { + return s + } + return "unknown" +} + // Options (occur as sub-options of DHCP option 43). const ( - OptionMessageType dhcpv4.OptionCode = 1 - OptionVersion dhcpv4.OptionCode = 2 - OptionServerIdentifier dhcpv4.OptionCode = 3 - OptionServerPriority dhcpv4.OptionCode = 4 - OptionReplyPort dhcpv4.OptionCode = 5 - OptionBootImageListPath dhcpv4.OptionCode = 6 // Not used - OptionDefaultBootImageID dhcpv4.OptionCode = 7 - OptionSelectedBootImageID dhcpv4.OptionCode = 8 - OptionBootImageList dhcpv4.OptionCode = 9 - OptionNetboot1_0Firmware dhcpv4.OptionCode = 10 - OptionBootImageAttributesFilterList dhcpv4.OptionCode = 11 - OptionShadowMountPath dhcpv4.OptionCode = 128 - OptionShadowFilePath dhcpv4.OptionCode = 129 - OptionMachineName dhcpv4.OptionCode = 130 + OptionMessageType optionCode = 1 + OptionVersion optionCode = 2 + OptionServerIdentifier optionCode = 3 + OptionServerPriority optionCode = 4 + OptionReplyPort optionCode = 5 + OptionBootImageListPath optionCode = 6 // Not used + OptionDefaultBootImageID optionCode = 7 + OptionSelectedBootImageID optionCode = 8 + OptionBootImageList optionCode = 9 + OptionNetboot1_0Firmware optionCode = 10 + OptionBootImageAttributesFilterList optionCode = 11 + OptionShadowMountPath optionCode = 128 + OptionShadowFilePath optionCode = 129 + OptionMachineName optionCode = 130 ) // optionCodeToString maps BSDP OptionCodes to human-readable strings // describing what they are. -var optionCodeToString = map[dhcpv4.OptionCode]string{ +var optionCodeToString = map[optionCode]string{ OptionMessageType: "BSDP Message Type", OptionVersion: "BSDP Version", OptionServerIdentifier: "BSDP Server Identifier", diff --git a/dhcpv4/option_generic_test.go b/dhcpv4/option_generic_test.go index 1a35841..10bfa5f 100644 --- a/dhcpv4/option_generic_test.go +++ b/dhcpv4/option_generic_test.go @@ -40,8 +40,8 @@ func TestOptionGenericString(t *testing.T) { func TestOptionGenericStringUnknown(t *testing.T) { o := OptionGeneric{ - OptionCode: 102, // Returend option code. + OptionCode: optionCode(102), // Returned option code. Data: []byte{byte(MessageTypeDiscover)}, } - require.Equal(t, "Unknown -> [1]", o.String()) + require.Equal(t, "unknown -> [1]", o.String()) } diff --git a/dhcpv4/option_parameter_request_list.go b/dhcpv4/option_parameter_request_list.go index d1ad2a1..c246f5c 100644 --- a/dhcpv4/option_parameter_request_list.go +++ b/dhcpv4/option_parameter_request_list.go @@ -21,7 +21,7 @@ func ParseOptParameterRequestList(data []byte) (*OptParameterRequestList, error) buf := uio.NewBigEndianBuffer(data) requestedOpts := make([]OptionCode, 0, buf.Len()) for buf.Len() > 0 { - requestedOpts = append(requestedOpts, OptionCode(buf.Read8())) + requestedOpts = append(requestedOpts, optionCode(buf.Read8())) } return &OptParameterRequestList{RequestedOpts: requestedOpts}, buf.Error() } @@ -35,7 +35,7 @@ func (o *OptParameterRequestList) Code() OptionCode { func (o *OptParameterRequestList) ToBytes() []byte { buf := uio.NewBigEndianBuffer(nil) for _, req := range o.RequestedOpts { - buf.Write8(uint8(req)) + buf.Write8(req.Code()) } return buf.Data() } diff --git a/dhcpv4/option_relay_agent_information.go b/dhcpv4/option_relay_agent_information.go index d3fac80..4b93bdd 100644 --- a/dhcpv4/option_relay_agent_information.go +++ b/dhcpv4/option_relay_agent_information.go @@ -18,7 +18,7 @@ type OptRelayAgentInformation struct { // ParseOptRelayAgentInformation returns a new OptRelayAgentInformation from a // byte stream, or error if any. func ParseOptRelayAgentInformation(data []byte) (*OptRelayAgentInformation, error) { - options, err := OptionsFromBytesWithParser(data, ParseOptionGeneric, false /* don't check for OptionEnd tag */) + options, err := OptionsFromBytesWithParser(data, codeGetter, ParseOptionGeneric, false /* don't check for OptionEnd tag */) if err != nil { return nil, err } diff --git a/dhcpv4/option_relay_agent_information_test.go b/dhcpv4/option_relay_agent_information_test.go index d1aeee2..bb5fae0 100644 --- a/dhcpv4/option_relay_agent_information_test.go +++ b/dhcpv4/option_relay_agent_information_test.go @@ -23,9 +23,9 @@ func TestParseOptRelayAgentInformation(t *testing.T) { opt, err = ParseOptRelayAgentInformation(data) require.NoError(t, err) require.Equal(t, len(opt.Options), 2) - circuit := opt.Options.GetOne(1).(*OptionGeneric) + circuit := opt.Options.GetOne(optionCode(1)).(*OptionGeneric) require.NoError(t, err) - remote := opt.Options.GetOne(2).(*OptionGeneric) + remote := opt.Options.GetOne(optionCode(2)).(*OptionGeneric) require.NoError(t, err) require.Equal(t, circuit.Data, []byte("linux")) require.Equal(t, remote.Data, []byte("boot")) @@ -34,8 +34,8 @@ func TestParseOptRelayAgentInformation(t *testing.T) { func TestParseOptRelayAgentInformationToBytes(t *testing.T) { opt := OptRelayAgentInformation{ Options: Options{ - &OptionGeneric{OptionCode: 1, Data: []byte("linux")}, - &OptionGeneric{OptionCode: 2, Data: []byte("boot")}, + &OptionGeneric{OptionCode: optionCode(1), Data: []byte("linux")}, + &OptionGeneric{OptionCode: optionCode(2), Data: []byte("boot")}, }, } data := opt.ToBytes() diff --git a/dhcpv4/options.go b/dhcpv4/options.go index 905495e..44bf1d3 100644 --- a/dhcpv4/options.go +++ b/dhcpv4/options.go @@ -24,9 +24,6 @@ var ( ErrInvalidOptions = errors.New("invalid options data") ) -// OptionCode is a single byte representing the code for a given Option. -type OptionCode byte - // Option is an interface that all DHCP v4 options adhere to. type Option interface { Code() OptionCode @@ -137,15 +134,23 @@ func (o Options) Has(code OptionCode) bool { // // Returns an error if any invalid option or length is found. func OptionsFromBytes(data []byte) (Options, error) { - return OptionsFromBytesWithParser(data, ParseOption, true) + return OptionsFromBytesWithParser(data, codeGetter, ParseOption, true) } -// OptionParser is a function signature for option parsing +// OptionParser is a function signature for option parsing. type OptionParser func(code OptionCode, data []byte) (Option, error) +// OptionCodeGetter parses a code into an OptionCode. +type OptionCodeGetter func(code uint8) OptionCode + +// codeGetter is an OptionCodeGetter for DHCP optionCodes. +func codeGetter(c uint8) OptionCode { + return optionCode(c) +} + // OptionsFromBytesWithParser parses Options from byte sequences using the // parsing function that is passed in as a paremeter -func OptionsFromBytesWithParser(data []byte, parser OptionParser, checkEndOption bool) (Options, error) { +func OptionsFromBytesWithParser(data []byte, coder OptionCodeGetter, parser OptionParser, checkEndOption bool) (Options, error) { if len(data) == 0 { return nil, nil } @@ -160,11 +165,11 @@ func OptionsFromBytesWithParser(data []byte, parser OptionParser, checkEndOption // 1 byte: option code // 1 byte: option length n // n bytes: data - code := OptionCode(buf.Read8()) + code := buf.Read8() - if code == OptionPad { + if code == OptionPad.Code() { continue - } else if code == OptionEnd { + } else if code == OptionEnd.Code() { end = true break } @@ -177,12 +182,14 @@ func OptionsFromBytesWithParser(data []byte, parser OptionParser, checkEndOption } data = data[:length:length] - if _, ok := options[code]; !ok { - order = append(order, code) + // Get the OptionCode for this guy. + c := coder(code) + if _, ok := options[c]; !ok { + order = append(order, c) } // RFC 3396: Just concatenate the data if the option code was // specified multiple times. - options[code] = append(options[code], data...) + options[c] = append(options[c], data...) } // If we never read the End option, the sender of this packet screwed @@ -193,7 +200,7 @@ func OptionsFromBytesWithParser(data []byte, parser OptionParser, checkEndOption // Any bytes left must be padding. for buf.Len() >= 1 { - if OptionCode(buf.Read8()) != OptionPad { + if buf.Read8() != OptionPad.Code() { return nil, ErrInvalidOptions } } @@ -212,16 +219,16 @@ func OptionsFromBytesWithParser(data []byte, parser OptionParser, checkEndOption // Marshal writes options binary representations to b. func (o Options) Marshal(b *uio.Lexer) { for _, opt := range o { - code := opt.Code() + code := opt.Code().Code() // Even if the End option is in there, don't marshal it until // the end. - if code == OptionEnd { + if code == OptionEnd.Code() { continue - } else if code == OptionPad { + } else if code == OptionPad.Code() { // Some DHCPv4 options have fixed length and do not put // length on the wire. - b.Write8(uint8(code)) + b.Write8(code) continue } @@ -231,7 +238,7 @@ func (o Options) Marshal(b *uio.Lexer) { // option is simply listed multiple times. for len(data) > 0 { // 1 byte: option code - b.Write8(uint8(code)) + b.Write8(code) n := len(data) if n > math.MaxUint8 { diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go index 6e50768..0c1c1fa 100644 --- a/dhcpv4/options_test.go +++ b/dhcpv4/options_test.go @@ -173,7 +173,7 @@ func TestOptionsMarshal(t *testing.T) { { opts: Options{ &OptionGeneric{ - OptionCode: 5, + OptionCode: optionCode(5), Data: []byte{1, 2, 3, 4}, }, }, @@ -185,11 +185,11 @@ func TestOptionsMarshal(t *testing.T) { // Test sorted key order. opts: Options{ &OptionGeneric{ - OptionCode: 5, + OptionCode: optionCode(5), Data: []byte{1, 2, 3}, }, &OptionGeneric{ - OptionCode: 100, + OptionCode: optionCode(100), Data: []byte{101, 102, 103}, }, }, @@ -202,7 +202,7 @@ func TestOptionsMarshal(t *testing.T) { // Test RFC 3396. opts: Options{ &OptionGeneric{ - OptionCode: 5, + OptionCode: optionCode(5), Data: bytes.Repeat([]byte{10}, math.MaxUint8+1), }, }, @@ -263,7 +263,7 @@ func TestOptionsUnmarshal(t *testing.T) { }, want: Options{ &OptionGeneric{ - OptionCode: 3, + OptionCode: optionCode(3), Data: []byte{5, 6}, }, }, @@ -277,7 +277,7 @@ func TestOptionsUnmarshal(t *testing.T) { ), want: Options{ &OptionGeneric{ - OptionCode: 3, + OptionCode: optionCode(3), Data: bytes.Repeat([]byte{10}, math.MaxUint8+5), }, }, @@ -290,11 +290,11 @@ func TestOptionsUnmarshal(t *testing.T) { }, want: Options{ &OptionGeneric{ - OptionCode: 10, + OptionCode: optionCode(10), Data: []byte{255, 254}, }, &OptionGeneric{ - OptionCode: 11, + OptionCode: optionCode(11), Data: []byte{5, 5, 5}, }, }, @@ -306,14 +306,14 @@ func TestOptionsUnmarshal(t *testing.T) { ), want: Options{ &OptionGeneric{ - OptionCode: 10, + OptionCode: optionCode(10), Data: []byte{255, 254}, }, }, }, } { t.Run(fmt.Sprintf("Test %02d", i), func(t *testing.T) { - opt, err := OptionsFromBytesWithParser(tt.input, ParseOptionGeneric, true) + opt, err := OptionsFromBytesWithParser(tt.input, codeGetter, ParseOptionGeneric, true) if tt.wantError { require.Error(t, err) } else { diff --git a/dhcpv4/types.go b/dhcpv4/types.go index c352292..402a646 100644 --- a/dhcpv4/types.go +++ b/dhcpv4/types.go @@ -66,178 +66,195 @@ var opcodeToString = map[OpcodeType]string{ OpcodeBootReply: "BootReply", } +// OptionCode is a single byte representing the code for a given Option. +// +// OptionCode is an interface purely to support different stringers on options +// with the same Code value, as vendor-specific options use option codes that +// have the same value, but mean a different thing. +type OptionCode interface { + Code() uint8 + String() string +} + +// optionCode is a DHCP option code. +type optionCode uint8 + +func (o optionCode) Code() uint8 { + return uint8(o) +} + +func (o optionCode) String() string { + if s, ok := optionCodeToString[o]; ok { + return s + } + return "unknown" +} + // DHCPv4 Options 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + OptionSubnetAllocation optionCode = 220 + OptionVirtualSubnetAllocation optionCode = 221 // Options 222-223 returned in RFC 3679 // Options 224-254 are reserved for private use - OptionEnd OptionCode = 255 + OptionEnd optionCode = 255 ) -func (o OptionCode) String() string { - if s, ok := optionCodeToString[o]; ok { - return s - } - return "Unknown" -} - -var optionCodeToString = map[OptionCode]string{ +var optionCodeToString = map[optionCode]string{ OptionPad: "Pad", OptionSubnetMask: "Subnet Mask", OptionTimeOffset: "Time Offset", |