diff options
-rw-r--r-- | dhcpv4/option_generic_test.go | 2 | ||||
-rw-r--r-- | dhcpv4/option_message_type_test.go | 2 | ||||
-rw-r--r-- | dhcpv4/types.go | 10 |
3 files changed, 9 insertions, 5 deletions
diff --git a/dhcpv4/option_generic_test.go b/dhcpv4/option_generic_test.go index 10bfa5f..ee35d65 100644 --- a/dhcpv4/option_generic_test.go +++ b/dhcpv4/option_generic_test.go @@ -43,5 +43,5 @@ func TestOptionGenericStringUnknown(t *testing.T) { OptionCode: optionCode(102), // Returned option code. Data: []byte{byte(MessageTypeDiscover)}, } - require.Equal(t, "unknown -> [1]", o.String()) + require.Equal(t, "unknown (102) -> [1]", o.String()) } diff --git a/dhcpv4/option_message_type_test.go b/dhcpv4/option_message_type_test.go index f5ad424..c3b4904 100644 --- a/dhcpv4/option_message_type_test.go +++ b/dhcpv4/option_message_type_test.go @@ -37,5 +37,5 @@ func TestOptMessageTypeString(t *testing.T) { // unknown o = OptMessageType{MessageType: 99} - require.Equal(t, "DHCP Message Type -> Unknown", o.String()) + require.Equal(t, "DHCP Message Type -> unknown (99)", o.String()) } diff --git a/dhcpv4/types.go b/dhcpv4/types.go index 402a646..46ec3c6 100644 --- a/dhcpv4/types.go +++ b/dhcpv4/types.go @@ -1,5 +1,9 @@ package dhcpv4 +import ( + "fmt" +) + // values from http://www.networksorcery.com/enp/protocol/dhcp.htm and // http://www.networksorcery.com/enp/protocol/bootp/options.htm @@ -31,7 +35,7 @@ func (m MessageType) String() string { if s, ok := messageTypeToString[m]; ok { return s } - return "Unknown" + return fmt.Sprintf("unknown (%d)", byte(m)) } var messageTypeToString = map[MessageType]string{ @@ -58,7 +62,7 @@ func (o OpcodeType) String() string { if s, ok := opcodeToString[o]; ok { return s } - return "Unknown" + return fmt.Sprintf("unknown (%d)", uint8(o)) } var opcodeToString = map[OpcodeType]string{ @@ -87,7 +91,7 @@ func (o optionCode) String() string { if s, ok := optionCodeToString[o]; ok { return s } - return "unknown" + return fmt.Sprintf("unknown (%d)", o) } // DHCPv4 Options |