diff --git a/dhcpv4/option_relay_agent_information.go b/dhcpv4/option_relay_agent_information.go index 4f974dd9..d26367ad 100644 --- a/dhcpv4/option_relay_agent_information.go +++ b/dhcpv4/option_relay_agent_information.go @@ -12,6 +12,14 @@ type RelayOptions struct { var relayHumanizer = OptionHumanizer{ ValueHumanizer: func(code OptionCode, data []byte) fmt.Stringer { + var d OptionDecoder + switch code { + case LinkSelectionSubOption, ServerIdentifierOverrideSubOption: + d = &IPs{} + } + if d != nil && d.FromBytes(data) == nil { + return d + } return raiSubOptionValue{data} }, CodeHumanizer: func(c uint8) OptionCode { diff --git a/dhcpv4/option_relay_agent_information_test.go b/dhcpv4/option_relay_agent_information_test.go index a875d14e..a0e12bcb 100644 --- a/dhcpv4/option_relay_agent_information_test.go +++ b/dhcpv4/option_relay_agent_information_test.go @@ -36,12 +36,14 @@ func TestOptRelayAgentInfo(t *testing.T) { opt := OptRelayAgentInfo( OptGeneric(GenericOptionCode(1), []byte("linux")), OptGeneric(GenericOptionCode(2), []byte("boot")), + OptGeneric(GenericOptionCode(LinkSelectionSubOption), []byte{192, 0, 2, 1}), ) wantBytes := []byte{ 1, 5, 'l', 'i', 'n', 'u', 'x', 2, 4, 'b', 'o', 'o', 't', + 5, 4, 192, 0, 2, 1, } - wantString := "Relay Agent Information:\n\n Agent Circuit ID Sub-option: linux ([108 105 110 117 120])\n Agent Remote ID Sub-option: boot ([98 111 111 116])\n" + wantString := "Relay Agent Information:\n\n Agent Circuit ID Sub-option: linux ([108 105 110 117 120])\n Agent Remote ID Sub-option: boot ([98 111 111 116])\n Link Selection Sub-option: 192.0.2.1\n" require.Equal(t, wantBytes, opt.Value.ToBytes()) require.Equal(t, OptionRelayAgentInformation, opt.Code) require.Equal(t, wantString, opt.String()) diff --git a/dhcpv4/options.go b/dhcpv4/options.go index 1e5fcbdb..b31a14b1 100644 --- a/dhcpv4/options.go +++ b/dhcpv4/options.go @@ -344,7 +344,8 @@ func getOption(code OptionCode, data []byte, vendorDecoder OptionDecoder) fmt.St d = &OptionCodeList{} case OptionHostName, OptionDomainName, OptionRootPath, - OptionClassIdentifier, OptionTFTPServerName, OptionBootfileName: + OptionClassIdentifier, OptionTFTPServerName, OptionBootfileName, + OptionMessage, OptionReferenceToTZDatabase: var s String d = &s @@ -354,7 +355,9 @@ func getOption(code OptionCode, data []byte, vendorDecoder OptionDecoder) fmt.St case OptionDNSDomainSearchList: d = &rfc1035label.Labels{} - case OptionIPAddressLeaseTime, OptionRenewTimeValue, OptionRebindingTimeValue, OptionIPv6OnlyPreferred: + case OptionIPAddressLeaseTime, OptionRenewTimeValue, + OptionRebindingTimeValue, OptionIPv6OnlyPreferred, OptionArpCacheTimeout, + OptionTimeOffset: var dur Duration d = &dur