summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv6/option_4rd.go10
-rw-r--r--dhcpv6/option_archtype.go2
-rw-r--r--dhcpv6/option_bootfileparam.go2
-rw-r--r--dhcpv6/option_bootfileurl.go2
-rw-r--r--dhcpv6/option_clientid.go2
-rw-r--r--dhcpv6/option_clientid_test.go2
-rw-r--r--dhcpv6/option_clientlinklayeraddress.go2
-rw-r--r--dhcpv6/option_clientlinklayeraddress_test.go2
-rw-r--r--dhcpv6/option_dhcpv4_msg.go2
-rw-r--r--dhcpv6/option_dhcpv4_o_dhcpv6_server.go2
-rw-r--r--dhcpv6/option_dhcpv4_o_dhcpv6_server_test.go5
-rw-r--r--dhcpv6/option_dns.go2
-rw-r--r--dhcpv6/option_domainsearchlist.go2
-rw-r--r--dhcpv6/option_elapsedtime.go2
-rw-r--r--dhcpv6/option_elapsedtime_test.go2
-rw-r--r--dhcpv6/option_fqdn.go2
-rw-r--r--dhcpv6/option_fqdn_test.go4
-rw-r--r--dhcpv6/option_iaaddress.go4
-rw-r--r--dhcpv6/option_iapd.go4
-rw-r--r--dhcpv6/option_iapd_test.go6
-rw-r--r--dhcpv6/option_iaprefix.go4
-rw-r--r--dhcpv6/option_informationrefreshtime.go2
-rw-r--r--dhcpv6/option_informationrefreshtime_test.go4
-rw-r--r--dhcpv6/option_interfaceid.go2
-rw-r--r--dhcpv6/option_nii.go2
-rw-r--r--dhcpv6/option_nontemporaryaddress.go4
-rw-r--r--dhcpv6/option_nontemporaryaddress_test.go6
-rw-r--r--dhcpv6/option_relaymsg.go2
-rw-r--r--dhcpv6/option_relaymsg_test.go2
-rw-r--r--dhcpv6/option_relayport.go2
-rw-r--r--dhcpv6/option_remoteid.go4
-rw-r--r--dhcpv6/option_remoteid_test.go4
-rw-r--r--dhcpv6/option_requestedoption.go2
-rw-r--r--dhcpv6/option_requestedoption_test.go2
-rw-r--r--dhcpv6/option_serverid.go2
-rw-r--r--dhcpv6/option_serverid_test.go2
-rw-r--r--dhcpv6/option_statuscode.go4
-rw-r--r--dhcpv6/option_statuscode_test.go2
-rw-r--r--dhcpv6/option_temporaryaddress.go3
-rw-r--r--dhcpv6/option_temporaryaddress_test.go4
-rw-r--r--dhcpv6/option_userclass.go2
-rw-r--r--dhcpv6/option_userclass_test.go2
-rw-r--r--dhcpv6/option_vendor_opts.go4
-rw-r--r--dhcpv6/option_vendorclass.go2
-rw-r--r--dhcpv6/option_vendorclass_test.go4
-rw-r--r--dhcpv6/options.go5
-rw-r--r--dhcpv6/types.go20
47 files changed, 79 insertions, 80 deletions
diff --git a/dhcpv6/option_4rd.go b/dhcpv6/option_4rd.go
index d9ac0a4..317f13a 100644
--- a/dhcpv6/option_4rd.go
+++ b/dhcpv6/option_4rd.go
@@ -24,7 +24,7 @@ func (op *Opt4RD) ToBytes() []byte {
// String returns a human-readable representation of the option
func (op *Opt4RD) String() string {
- return fmt.Sprintf("Opt4RD{%v}", op.Options)
+ return fmt.Sprintf("%s: {Options=%v}", op.Code(), op.Options)
}
// ParseOpt4RD builds an Opt4RD structure from a sequence of bytes.
@@ -96,8 +96,8 @@ func (op *Opt4RDMapRule) ToBytes() []byte {
// String returns a human-readable description of this option
func (op *Opt4RDMapRule) String() string {
- return fmt.Sprintf("Opt4RDMapRule{Prefix4=%s, Prefix6=%s, EA-Bits=%d, WKPAuthorized=%t}",
- op.Prefix4.String(), op.Prefix6.String(), op.EABitsLength, op.WKPAuthorized)
+ return fmt.Sprintf("%s: {Prefix4=%s, Prefix6=%s, EA-Bits=%d, WKPAuthorized=%t}",
+ op.Code(), op.Prefix4.String(), op.Prefix6.String(), op.EABitsLength, op.WKPAuthorized)
}
// ParseOpt4RDMapRule builds an Opt4RDMapRule structure from a sequence of bytes.
@@ -156,8 +156,8 @@ func (op *Opt4RDNonMapRule) String() string {
tClass = *op.TrafficClass
}
- return fmt.Sprintf("Opt4RDNonMapRule{HubAndSpoke=%t, TrafficClass=%v, DomainPMTU=%d}",
- op.HubAndSpoke, tClass, op.DomainPMTU)
+ return fmt.Sprintf("%s: {HubAndSpoke=%t, TrafficClass=%v, DomainPMTU=%d}",
+ op.Code(), op.HubAndSpoke, tClass, op.DomainPMTU)
}
// ParseOpt4RDNonMapRule builds an Opt4RDNonMapRule structure from a sequence of bytes.
diff --git a/dhcpv6/option_archtype.go b/dhcpv6/option_archtype.go
index 1461056..a5514cd 100644
--- a/dhcpv6/option_archtype.go
+++ b/dhcpv6/option_archtype.go
@@ -23,7 +23,7 @@ func (op *optClientArchType) Code() OptionCode {
}
func (op optClientArchType) String() string {
- return fmt.Sprintf("ClientArchType: %s", op.Archs.String())
+ return fmt.Sprintf("%s: %s", op.Code(), op.Archs)
}
// parseOptClientArchType builds an OptClientArchType structure from
diff --git a/dhcpv6/option_bootfileparam.go b/dhcpv6/option_bootfileparam.go
index 1bd54bc..7618080 100644
--- a/dhcpv6/option_bootfileparam.go
+++ b/dhcpv6/option_bootfileparam.go
@@ -42,7 +42,7 @@ func (op optBootFileParam) ToBytes() []byte {
}
func (op optBootFileParam) String() string {
- return fmt.Sprintf("BootFileParam: %v", ([]string)(op))
+ return fmt.Sprintf("%s: %v", op.Code(), ([]string)(op))
}
// parseOptBootFileParam builds an OptBootFileParam structure from a sequence
diff --git a/dhcpv6/option_bootfileurl.go b/dhcpv6/option_bootfileurl.go
index 695f164..1461189 100644
--- a/dhcpv6/option_bootfileurl.go
+++ b/dhcpv6/option_bootfileurl.go
@@ -22,7 +22,7 @@ func (op optBootFileURL) ToBytes() []byte {
}
func (op optBootFileURL) String() string {
- return fmt.Sprintf("BootFileURL: %s", string(op))
+ return fmt.Sprintf("%s: %s", op.Code(), string(op))
}
// parseOptBootFileURL builds an optBootFileURL structure from a sequence
diff --git a/dhcpv6/option_clientid.go b/dhcpv6/option_clientid.go
index 0941bcc..d08f6d3 100644
--- a/dhcpv6/option_clientid.go
+++ b/dhcpv6/option_clientid.go
@@ -19,7 +19,7 @@ func (*optClientID) Code() OptionCode {
}
func (op *optClientID) String() string {
- return fmt.Sprintf("ClientID: %v", op.Duid.String())
+ return fmt.Sprintf("%s: %s", op.Code(), op.Duid.String())
}
// parseOptClientID builds an OptClientId structure from a sequence
diff --git a/dhcpv6/option_clientid_test.go b/dhcpv6/option_clientid_test.go
index 2f1f1f0..f60356e 100644
--- a/dhcpv6/option_clientid_test.go
+++ b/dhcpv6/option_clientid_test.go
@@ -60,7 +60,7 @@ func TestOptionClientId(t *testing.T) {
require.Contains(
t,
opt.String(),
- "ClientID: DUID{type=DUID-LL hwtype=Ethernet hwaddr=de:ad:00:00:be:ef}",
+ "Client ID: DUID{type=DUID-LL hwtype=Ethernet hwaddr=de:ad:00:00:be:ef}",
"String() should contain the correct cid output",
)
}
diff --git a/dhcpv6/option_clientlinklayeraddress.go b/dhcpv6/option_clientlinklayeraddress.go
index 7fe5bee..d5ec028 100644
--- a/dhcpv6/option_clientlinklayeraddress.go
+++ b/dhcpv6/option_clientlinklayeraddress.go
@@ -33,7 +33,7 @@ func (op *optClientLinkLayerAddress) ToBytes() []byte {
}
func (op *optClientLinkLayerAddress) String() string {
- return fmt.Sprintf("ClientLinkLayerAddress: Type=%s LinkLayerAddress=%s", op.LinkLayerType, op.LinkLayerAddress)
+ return fmt.Sprintf("%s: Type=%s LinkLayerAddress=%s", op.Code(), op.LinkLayerType, op.LinkLayerAddress)
}
// parseOptClientLinkLayerAddress deserializes from bytes
diff --git a/dhcpv6/option_clientlinklayeraddress_test.go b/dhcpv6/option_clientlinklayeraddress_test.go
index a25e882..9e243a4 100644
--- a/dhcpv6/option_clientlinklayeraddress_test.go
+++ b/dhcpv6/option_clientlinklayeraddress_test.go
@@ -20,7 +20,7 @@ func TestParseOptClientLinkLayerAddress(t *testing.T) {
require.Equal(t, OptionClientLinkLayerAddr, opt.Code())
require.Equal(t, iana.HWTypeEthernet, opt.LinkLayerType)
require.Equal(t, net.HardwareAddr(data[2:]), opt.LinkLayerAddress)
- require.Equal(t, "ClientLinkLayerAddress: Type=Ethernet LinkLayerAddress=a4:83:e7:e3:df:88", opt.String())
+ require.Equal(t, "Client Link-Layer Address: Type=Ethernet LinkLayerAddress=a4:83:e7:e3:df:88", opt.String())
}
func TestOptClientLinkLayerAddressToBytes(t *testing.T) {
diff --git a/dhcpv6/option_dhcpv4_msg.go b/dhcpv6/option_dhcpv4_msg.go
index 0a1a2b3..2cf988a 100644
--- a/dhcpv6/option_dhcpv4_msg.go
+++ b/dhcpv6/option_dhcpv4_msg.go
@@ -25,7 +25,7 @@ func (op *OptDHCPv4Msg) ToBytes() []byte {
}
func (op *OptDHCPv4Msg) String() string {
- return fmt.Sprintf("OptDHCPv4Msg{%v}", op.Msg)
+ return fmt.Sprintf("%s: %v", op.Code(), op.Msg)
}
// ParseOptDHCPv4Msg builds an OptDHCPv4Msg structure
diff --git a/dhcpv6/option_dhcpv4_o_dhcpv6_server.go b/dhcpv6/option_dhcpv4_o_dhcpv6_server.go
index 27a0079..f1f2d27 100644
--- a/dhcpv6/option_dhcpv4_o_dhcpv6_server.go
+++ b/dhcpv6/option_dhcpv4_o_dhcpv6_server.go
@@ -30,7 +30,7 @@ func (op *OptDHCP4oDHCP6Server) ToBytes() []byte {
}
func (op *OptDHCP4oDHCP6Server) String() string {
- return fmt.Sprintf("OptDHCP4oDHCP6Server{4o6-servers=%v}", op.DHCP4oDHCP6Servers)
+ return fmt.Sprintf("%s: %v", op.Code(), op.DHCP4oDHCP6Servers)
}
// ParseOptDHCP4oDHCP6Server builds an OptDHCP4oDHCP6Server structure
diff --git a/dhcpv6/option_dhcpv4_o_dhcpv6_server_test.go b/dhcpv6/option_dhcpv4_o_dhcpv6_server_test.go
index de86594..ae5bcdc 100644
--- a/dhcpv6/option_dhcpv4_o_dhcpv6_server_test.go
+++ b/dhcpv6/option_dhcpv4_o_dhcpv6_server_test.go
@@ -18,7 +18,7 @@ func TestParseOptDHCP4oDHCP6Server(t *testing.T) {
require.NoError(t, err)
require.Equal(t, expected, opt.DHCP4oDHCP6Servers)
require.Equal(t, OptionDHCP4oDHCP6Server, opt.Code())
- require.Contains(t, opt.String(), "4o6-servers=[2a03:2880:fffe:c:face:b00c:0:35]", "String() should contain the correct DHCP4-over-DHCP6 server output")
+ require.Contains(t, opt.String(), "[2a03:2880:fffe:c:face:b00c:0:35]", "String() should contain the correct DHCP4-over-DHCP6 server output")
}
func TestOptDHCP4oDHCP6ServerToBytes(t *testing.T) {
@@ -32,8 +32,7 @@ func TestOptDHCP4oDHCP6ServerToBytes(t *testing.T) {
}
func TestParseOptDHCP4oDHCP6ServerParseNoAddr(t *testing.T) {
- data := []byte{
- }
+ data := []byte{}
var expected []net.IP
opt, err := ParseOptDHCP4oDHCP6Server(data)
require.NoError(t, err)
diff --git a/dhcpv6/option_dns.go b/dhcpv6/option_dns.go
index c7bbf83..f69973a 100644
--- a/dhcpv6/option_dns.go
+++ b/dhcpv6/option_dns.go
@@ -31,7 +31,7 @@ func (op *optDNS) ToBytes() []byte {
}
func (op *optDNS) String() string {
- return fmt.Sprintf("DNS: %v", op.NameServers)
+ return fmt.Sprintf("%s: %v", op.Code(), op.NameServers)
}
// parseOptDNS builds an optDNS structure
diff --git a/dhcpv6/option_domainsearchlist.go b/dhcpv6/option_domainsearchlist.go
index e71a8d5..e94799d 100644
--- a/dhcpv6/option_domainsearchlist.go
+++ b/dhcpv6/option_domainsearchlist.go
@@ -25,7 +25,7 @@ func (op *optDomainSearchList) ToBytes() []byte {
}
func (op *optDomainSearchList) String() string {
- return fmt.Sprintf("DomainSearchList: %s", op.DomainSearchList)
+ return fmt.Sprintf("%s: %s", op.Code(), op.DomainSearchList)
}
// ParseOptDomainSearchList builds an OptDomainSearchList structure from a sequence
diff --git a/dhcpv6/option_elapsedtime.go b/dhcpv6/option_elapsedtime.go
index 93e43b9..823c942 100644
--- a/dhcpv6/option_elapsedtime.go
+++ b/dhcpv6/option_elapsedtime.go
@@ -29,7 +29,7 @@ func (op *optElapsedTime) ToBytes() []byte {
}
func (op *optElapsedTime) String() string {
- return fmt.Sprintf("ElapsedTime: %s", op.ElapsedTime)
+ return fmt.Sprintf("%s: %s", op.Code(), op.ElapsedTime)
}
// build an optElapsedTime structure from a sequence of bytes.
diff --git a/dhcpv6/option_elapsedtime_test.go b/dhcpv6/option_elapsedtime_test.go
index 91fab45..2155539 100644
--- a/dhcpv6/option_elapsedtime_test.go
+++ b/dhcpv6/option_elapsedtime_test.go
@@ -28,7 +28,7 @@ func TestOptElapsedTimeToBytes(t *testing.T) {
func TestOptElapsedTimeString(t *testing.T) {
opt := OptElapsedTime(100 * time.Millisecond)
- expected := "ElapsedTime: 100ms"
+ expected := "Elapsed Time: 100ms"
if optString := opt.String(); optString != expected {
t.Fatalf("Invalid elapsed time string. Expected %v, got %v", expected, optString)
}
diff --git a/dhcpv6/option_fqdn.go b/dhcpv6/option_fqdn.go
index 62affc7..73a525a 100644
--- a/dhcpv6/option_fqdn.go
+++ b/dhcpv6/option_fqdn.go
@@ -29,7 +29,7 @@ func (op *OptFQDN) ToBytes() []byte {
}
func (op *OptFQDN) String() string {
- return fmt.Sprintf("OptFQDN{flags=%d, domainname=%s}", op.Flags, op.DomainName)
+ return fmt.Sprintf("%s: {Flags=%d DomainName=%s}", op.Code(), op.Flags, op.DomainName)
}
// ParseOptFQDN deserializes from bytes to build a OptFQDN structure.
diff --git a/dhcpv6/option_fqdn_test.go b/dhcpv6/option_fqdn_test.go
index f698c93..69720ba 100644
--- a/dhcpv6/option_fqdn_test.go
+++ b/dhcpv6/option_fqdn_test.go
@@ -20,12 +20,12 @@ func TestParseOptFQDN(t *testing.T) {
require.Equal(t, OptionFQDN, opt.Code())
require.Equal(t, uint8(0), opt.Flags)
require.Equal(t, "cnos.localhost", opt.DomainName.Labels[0])
- require.Equal(t, "OptFQDN{flags=0, domainname=[cnos.localhost]}", opt.String())
+ require.Equal(t, "FQDN: {Flags=0 DomainName=[cnos.localhost]}", opt.String())
}
func TestOptFQDNToBytes(t *testing.T) {
opt := OptFQDN{
- Flags: 0,
+ Flags: 0,
DomainName: &rfc1035label.Labels{
Labels: []string{"cnos.localhost"},
},
diff --git a/dhcpv6/option_iaaddress.go b/dhcpv6/option_iaaddress.go
index a701f8d..c107b83 100644
--- a/dhcpv6/option_iaaddress.go
+++ b/dhcpv6/option_iaaddress.go
@@ -59,8 +59,8 @@ func (op *OptIAAddress) ToBytes() []byte {
}
func (op *OptIAAddress) String() string {
- return fmt.Sprintf("IAAddress: IP=%v PreferredLifetime=%v ValidLifetime=%v Options=%v",
- op.IPv6Addr, op.PreferredLifetime, op.ValidLifetime, op.Options)
+ return fmt.Sprintf("%s: {IP=%v PreferredLifetime=%v ValidLifetime=%v Options=%v}",
+ op.Code(), op.IPv6Addr, op.PreferredLifetime, op.ValidLifetime, op.Options)
}
// ParseOptIAAddress builds an OptIAAddress structure from a sequence
diff --git a/dhcpv6/option_iapd.go b/dhcpv6/option_iapd.go
index 00bc424..c71b0f6 100644
--- a/dhcpv6/option_iapd.go
+++ b/dhcpv6/option_iapd.go
@@ -70,8 +70,8 @@ func (op *OptIAPD) ToBytes() []byte {
// String returns a string representation of the OptIAPD data
func (op *OptIAPD) String() string {
- return fmt.Sprintf("IAPD: {IAID=%v, t1=%v, t2=%v, Options=[%v]}",
- op.IaId, op.T1, op.T2, op.Options)
+ return fmt.Sprintf("%s: {IAID=%#x T1=%v T2=%v Options=%v}",
+ op.Code(), op.IaId, op.T1, op.T2, op.Options)
}
// ParseOptIAPD builds an OptIAPD structure from a sequence of bytes.
diff --git a/dhcpv6/option_iapd_test.go b/dhcpv6/option_iapd_test.go
index b2b9d3f..13175f4 100644
--- a/dhcpv6/option_iapd_test.go
+++ b/dhcpv6/option_iapd_test.go
@@ -98,17 +98,17 @@ func TestOptIAPDString(t *testing.T) {
str := opt.String()
require.Contains(
t, str,
- "IAID=[1 0 0 0]",
+ "IAID=0x01000000",
"String() should return the IAID",
)
require.Contains(
t, str,
- "t1=1s, t2=2s",
+ "T1=1s T2=2s",
"String() should return the T1/T2 options",
)
require.Contains(
t, str,
- "Options=[",
+ "Options={",
"String() should return a list of options",
)
}
diff --git a/dhcpv6/option_iaprefix.go b/dhcpv6/option_iaprefix.go
index 6edacf3..fc41e0a 100644
--- a/dhcpv6/option_iaprefix.go
+++ b/dhcpv6/option_iaprefix.go
@@ -70,8 +70,8 @@ func (op *OptIAPrefix) ToBytes() []byte {
}
func (op *OptIAPrefix) String() string {
- return fmt.Sprintf("IAPrefix: {PreferredLifetime=%v, ValidLifetime=%v, Prefix=%s, Options=%v}",
- op.PreferredLifetime, op.ValidLifetime, op.Prefix, op.Options)
+ return fmt.Sprintf("%s: {PreferredLifetime=%v, ValidLifetime=%v, Prefix=%s, Options=%v}",
+ op.Code(), op.PreferredLifetime, op.ValidLifetime, op.Prefix, op.Options)
}
// ParseOptIAPrefix an OptIAPrefix structure from a sequence of bytes. The
diff --git a/dhcpv6/option_informationrefreshtime.go b/dhcpv6/option_informationrefreshtime.go
index 20d8b5c..8b47b46 100644
--- a/dhcpv6/option_informationrefreshtime.go
+++ b/dhcpv6/option_informationrefreshtime.go
@@ -32,7 +32,7 @@ func (op *optInformationRefreshTime) ToBytes() []byte {
}
func (op *optInformationRefreshTime) String() string {
- return fmt.Sprintf("InformationRefreshTime: %v", op.InformationRefreshtime)
+ return fmt.Sprintf("%s: %v", op.Code(), op.InformationRefreshtime)
}
// parseOptInformationRefreshTime builds an optInformationRefreshTime structure from a sequence
diff --git a/dhcpv6/option_informationrefreshtime_test.go b/dhcpv6/option_informationrefreshtime_test.go
index 68f0855..0428a1c 100644
--- a/dhcpv6/option_informationrefreshtime_test.go
+++ b/dhcpv6/option_informationrefreshtime_test.go
@@ -11,7 +11,7 @@ func TestOptInformationRefreshTime(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if informationRefreshTime := opt.InformationRefreshtime; informationRefreshTime != time.Duration(0xaabbccdd) * time.Second {
+ if informationRefreshTime := opt.InformationRefreshtime; informationRefreshTime != time.Duration(0xaabbccdd)*time.Second {
t.Fatalf("Invalid information refresh time. Expected 0xaabb, got %v", informationRefreshTime)
}
}
@@ -26,7 +26,7 @@ func TestOptInformationRefreshTimeToBytes(t *testing.T) {
func TestOptInformationRefreshTimeString(t *testing.T) {
opt := OptInformationRefreshTime(3600 * time.Second)
- expected := "InformationRefreshTime: 1h0m0s"
+ expected := "Information Refresh Time: 1h0m0s"
if optString := opt.String(); optString != expected {
t.Fatalf("Invalid elapsed time string. Expected %v, got %v", expected, optString)
}
diff --git a/dhcpv6/option_interfaceid.go b/dhcpv6/option_interfaceid.go
index ce85714..163af7b 100644
--- a/dhcpv6/option_interfaceid.go
+++ b/dhcpv6/option_interfaceid.go
@@ -23,7 +23,7 @@ func (op *optInterfaceID) ToBytes() []byte {
}
func (op *optInterfaceID) String() string {
- return fmt.Sprintf("InterfaceID: %v", op.ID)
+ return fmt.Sprintf("%s: %v", op.Code(), op.ID)
}
// build an optInterfaceID structure from a sequence of bytes.
diff --git a/dhcpv6/option_nii.go b/dhcpv6/option_nii.go
index fc9f579..c9953ac 100644
--- a/dhcpv6/option_nii.go
+++ b/dhcpv6/option_nii.go
@@ -59,7 +59,7 @@ func (op *OptNetworkInterfaceID) ToBytes() []byte {
}
func (op *OptNetworkInterfaceID) String() string {
- return fmt.Sprintf("NetworkInterfaceID: %s (Revision %d.%d)", op.Typ, op.Major, op.Minor)
+ return fmt.Sprintf("%s: %s (Revision %d.%d)", op.Code(), op.Typ, op.Major, op.Minor)
}
// FromBytes builds an OptNetworkInterfaceID structure from a sequence of
diff --git a/dhcpv6/option_nontemporaryaddress.go b/dhcpv6/option_nontemporaryaddress.go
index 6e5ddee..9232bb5 100644
--- a/dhcpv6/option_nontemporaryaddress.go
+++ b/dhcpv6/option_nontemporaryaddress.go
@@ -93,8 +93,8 @@ func (op *OptIANA) ToBytes() []byte {
}
func (op *OptIANA) String() string {
- return fmt.Sprintf("IANA: {IAID=%v, t1=%v, t2=%v, options=%v}",
- op.IaId, op.T1, op.T2, op.Options)
+ return fmt.Sprintf("%s: {IAID=%#x T1=%v T2=%v Options=%v}",
+ op.Code(), op.IaId, op.T1, op.T2, op.Options)
}
// ParseOptIANA builds an OptIANA structure from a sequence of bytes. The
diff --git a/dhcpv6/option_nontemporaryaddress_test.go b/dhcpv6/option_nontemporaryaddress_test.go
index 50cb11b..1ec58e8 100644
--- a/dhcpv6/option_nontemporaryaddress_test.go
+++ b/dhcpv6/option_nontemporaryaddress_test.go
@@ -124,17 +124,17 @@ func TestOptIANAString(t *testing.T) {
str := opt.String()
require.Contains(
t, str,
- "IAID=[1 0 0 0]",
+ "IAID=0x01000000",
"String() should return the IAID",
)
require.Contains(
t, str,
- "t1=1s, t2=2s",
+ "T1=1s T2=2s",
"String() should return the T1/T2 options",
)
require.Contains(
t, str,
- "options={",
+ "Options={",
"String() should return a list of options",
)
}
diff --git a/dhcpv6/option_relaymsg.go b/dhcpv6/option_relaymsg.go
index 48d9716..5e1d902 100644
--- a/dhcpv6/option_relaymsg.go
+++ b/dhcpv6/option_relaymsg.go
@@ -25,7 +25,7 @@ func (op *optRelayMsg) ToBytes() []byte {
}
func (op *optRelayMsg) String() string {
- return fmt.Sprintf("RelayMsg: %v", op.Msg)
+ return fmt.Sprintf("%s: %v", op.Code(), op.Msg)
}
// build an optRelayMsg structure from a sequence of bytes.
diff --git a/dhcpv6/option_relaymsg_test.go b/dhcpv6/option_relaymsg_test.go
index b898a75..e77a6c6 100644
--- a/dhcpv6/option_relaymsg_test.go
+++ b/dhcpv6/option_relaymsg_test.go
@@ -169,7 +169,7 @@ func TestRelayMsgString(t *testing.T) {
require.Contains(
t,
opt.String(),
- "RelayMsg: Message",
+ "Relay Message: Message",
"String() should contain the relaymsg contents",
)
}
diff --git a/dhcpv6/option_relayport.go b/dhcpv6/option_relayport.go
index fd51948..4873693 100644
--- a/dhcpv6/option_relayport.go
+++ b/dhcpv6/option_relayport.go
@@ -29,7 +29,7 @@ func (op *optRelayPort) ToBytes() []byte {
}
func (op *optRelayPort) String() string {
- return fmt.Sprintf("RelayPort: %d", op.DownstreamSourcePort)
+ return fmt.Sprintf("%s: %d", op.Code(), op.DownstreamSourcePort)
}
// build an optRelayPort structure from a sequence of bytes.
diff --git a/dhcpv6/option_remoteid.go b/dhcpv6/option_remoteid.go
index fb028e6..9833149 100644
--- a/dhcpv6/option_remoteid.go
+++ b/dhcpv6/option_remoteid.go
@@ -26,8 +26,8 @@ func (op *OptRemoteID) ToBytes() []byte {
}
func (op *OptRemoteID) String() string {
- return fmt.Sprintf("RemoteID: EnterpriseNumber %d RemoteID %v",
- op.EnterpriseNumber, op.RemoteID,
+ return fmt.Sprintf("%s: {EnterpriseNumber=%d RemoteID=%#x}",
+ op.Code(), op.EnterpriseNumber, op.RemoteID,
)
}
diff --git a/dhcpv6/option_remoteid_test.go b/dhcpv6/option_remoteid_test.go
index 5c1ee52..77835de 100644
--- a/dhcpv6/option_remoteid_test.go
+++ b/dhcpv6/option_remoteid_test.go
@@ -52,13 +52,13 @@ func TestOptRemoteIDString(t *testing.T) {
require.Contains(
t,
str,
- "EnterpriseNumber 2864434397",
+ "EnterpriseNumber=2864434397",
"String() should contain the enterprisenum",
)
require.Contains(
t,
str,
- "RemoteID [84 101 115 116 49 50 51 52]",
+ "RemoteID=0x5465737431323334",
"String() should contain the remoteid bytes",
)
}
diff --git a/dhcpv6/option_requestedoption.go b/dhcpv6/option_requestedoption.go
index 3281a61..bba5e48 100644
--- a/dhcpv6/option_requestedoption.go
+++ b/dhcpv6/option_requestedoption.go
@@ -71,5 +71,5 @@ func (*optRequestedOption) Code() OptionCode {
}
func (op *optRequestedOption) String() string {
- return fmt.Sprintf("RequestedOptions: %s", op.OptionCodes)
+ return fmt.Sprintf("%s: %s", op.Code(), op.OptionCodes)
}
diff --git a/dhcpv6/option_requestedoption_test.go b/dhcpv6/option_requestedoption_test.go
index 9941a89..e5d7bfc 100644
--- a/dhcpv6/option_requestedoption_test.go
+++ b/dhcpv6/option_requestedoption_test.go
@@ -28,7 +28,7 @@ func TestOptRequestedOptionString(t *testing.T) {
require.Contains(
t,
o.String(),
- "Client Identifier, Server Identifier",
+ "Client ID, Server ID",
"String() should contain the options specified",
)
o.OptionCodes = append(o.OptionCodes, 12345)
diff --git a/dhcpv6/option_serverid.go b/dhcpv6/option_serverid.go
index c2c10da..b461e8d 100644
--- a/dhcpv6/option_serverid.go
+++ b/dhcpv6/option_serverid.go
@@ -19,7 +19,7 @@ func (*optServerID) Code() OptionCode {
}
func (op *optServerID) String() string {
- return fmt.Sprintf("ServerID: %v", op.Duid.String())
+ return fmt.Sprintf("%s: %v", op.Code(), op.Duid.String())
}
// parseOptServerID builds an optServerID structure from a sequence of bytes.
diff --git a/dhcpv6/option_serverid_test.go b/dhcpv6/option_serverid_test.go
index 05158c4..0e5cb2f 100644
--- a/dhcpv6/option_serverid_test.go
+++ b/dhcpv6/option_serverid_test.go
@@ -60,7 +60,7 @@ func TestOptionServerId(t *testing.T) {
require.Contains(
t,
opt.String(),
- "ServerID: DUID{type=DUID-LL hwtype=Ethernet hwaddr=de:ad:00:00:be:ef}",
+ "Server ID: DUID{type=DUID-LL hwtype=Ethernet hwaddr=de:ad:00:00:be:ef}",
"String() should contain the correct sid output",
)
}
diff --git a/dhcpv6/option_statuscode.go b/dhcpv6/option_statuscode.go
index b6b5a14..067b973 100644
--- a/dhcpv6/option_statuscode.go
+++ b/dhcpv6/option_statuscode.go
@@ -31,8 +31,8 @@ func (op *OptStatusCode) ToBytes() []byte {
// String returns a human-readable option.
func (op *OptStatusCode) String() string {
- return fmt.Sprintf("StatusCode: Code: %s (%d); Message: %s",
- op.StatusCode, op.StatusCode, op.StatusMessage)
+ return fmt.Sprintf("%s: {Code=%s (%d); Message=%s}",
+ op.Code(), op.StatusCode, op.StatusCode, op.StatusMessage)
}
// ParseOptStatusCode builds an OptStatusCode structure from a sequence of
diff --git a/dhcpv6/option_statuscode_test.go b/dhcpv6/option_statuscode_test.go
index 1478678..82225e0 100644
--- a/dhcpv6/option_statuscode_test.go
+++ b/dhcpv6/option_statuscode_test.go
@@ -47,7 +47,7 @@ func TestOptStatusCodeString(t *testing.T) {
require.Contains(
t,
opt.String(),
- "Code: UseMulticast (5); Message: use multicast",
+ "Code=UseMulticast (5); Message=use multicast",
"String() should contain the code and message",
)
}
diff --git a/dhcpv6/option_temporaryaddress.go b/dhcpv6/option_temporaryaddress.go
index f9dd3ca..624b4f9 100644
--- a/dhcpv6/option_temporaryaddress.go
+++ b/dhcpv6/option_temporaryaddress.go
@@ -30,8 +30,7 @@ func (op *OptIATA) ToBytes() []byte {
}
func (op *OptIATA) String() string {
- return fmt.Sprintf("IATA: {IAID=%v, options=%v}",
- op.IaId, op.Options)
+ return fmt.Sprintf("%s: {IAID=%#x, Options=%v}", op.Code(), op.IaId, op.Options)
}
// ParseOptIATA builds an OptIATA structure from a sequence of bytes. The
diff --git a/dhcpv6/option_temporaryaddress_test.go b/dhcpv6/option_temporaryaddress_test.go
index de7fe39..9b48d5a 100644
--- a/dhcpv6/option_temporaryaddress_test.go
+++ b/dhcpv6/option_temporaryaddress_test.go
@@ -112,12 +112,12 @@ func TestOptIATAString(t *testing.T) {
str := opt.String()
require.Contains(
t, str,
- "IAID=[1 0 0 0]",
+ "IAID=0x01000000",
"String() should return the IAID",
)
require.Contains(
t, str,
- "options={",
+ "Options={",
"String() should return a list of options",
)
}
diff --git a/dhcpv6/option_userclass.go b/dhcpv6/option_userclass.go
index e5d7b31..00abcbd 100644
--- a/dhcpv6/option_userclass.go
+++ b/dhcpv6/option_userclass.go
@@ -35,7 +35,7 @@ func (op *OptUserClass) String() string {
for _, uc := range op.UserClasses {
ucStrings = append(ucStrings, string(uc))
}
- return fmt.Sprintf("OptUserClass{userclass=[%s]}", strings.Join(ucStrings, ", "))
+ return fmt.Sprintf("%s: [%s]", op.Code(), strings.Join(ucStrings, ", "))
}
// ParseOptUserClass builds an OptUserClass structure from a sequence of
diff --git a/dhcpv6/option_userclass_test.go b/dhcpv6/option_userclass_test.go
index 16fae72..50bc438 100644
--- a/dhcpv6/option_userclass_test.go
+++ b/dhcpv6/option_userclass_test.go
@@ -87,7 +87,7 @@ func TestOptUserClassString(t *testing.T) {
require.Contains(
t,
opt.String(),
- "userclass=[linuxboot, test]",
+ "User Class: [linuxboot, test]",
"String() should contain the list of user classes",
)
}
diff --git a/dhcpv6/option_vendor_opts.go b/dhcpv6/option_vendor_opts.go
index 7965908..74a4b70 100644
--- a/dhcpv6/option_vendor_opts.go
+++ b/dhcpv6/option_vendor_opts.go
@@ -30,9 +30,7 @@ func (op *OptVendorOpts) ToBytes() []byte {
// String returns a string representation of the VendorOpts data
func (op *OptVendorOpts) String() string {
- return fmt.Sprintf("OptVendorOpts{enterprisenum=%v, vendorOpts=%v}",
- op.EnterpriseNumber, op.VendorOpts,
- )
+ return fmt.Sprintf("%s: {EnterpriseNumber=%v VendorOptions=%v}", op.Code(), op.EnterpriseNumber, op.VendorOpts)
}
// ParseOptVendorOpts builds an OptVendorOpts structure from a sequence of bytes.
diff --git a/dhcpv6/option_vendorclass.go b/dhcpv6/option_vendorclass.go
index 1144974..33297dc 100644
--- a/dhcpv6/option_vendorclass.go
+++ b/dhcpv6/option_vendorclass.go
@@ -36,7 +36,7 @@ func (op *OptVendorClass) String() string {
for _, data := range op.Data {
vcStrings = append(vcStrings, string(data))
}
- return fmt.Sprintf("OptVendorClass{enterprisenum=%d, data=[%s]}", op.EnterpriseNumber, strings.Join(vcStrings, ", "))
+ return fmt.Sprintf("%s: {EnterpriseNumber=%d Data=[%s]}", op.Code(), op.EnterpriseNumber, strings.Join(vcStrings, ", "))
}
// ParseOptVendorClass builds an OptVendorClass structure from a sequence of
diff --git a/dhcpv6/option_vendorclass_test.go b/dhcpv6/option_vendorclass_test.go
index 685b8b0..819f5f6 100644
--- a/dhcpv6/option_vendorclass_test.go
+++ b/dhcpv6/option_vendorclass_test.go
@@ -81,13 +81,13 @@ func TestOptVendorClassString(t *testing.T) {
require.Contains(
t,
str,
- "enterprisenum=2864434397",
+ "EnterpriseNumber=2864434397",
"String() should contain the enterprisenum",
)
require.Contains(
t,
str,
- "data=[linuxboot, test]",
+ "Data=[linuxboot, test]",
"String() should contain the list of vendor classes",
)
}
diff --git a/dhcpv6/options.go b/dhcpv6/options.go
index f8445bb..8bf1321 100644
--- a/dhcpv6/options.go
+++ b/dhcpv6/options.go
@@ -27,7 +27,10 @@ func (og *OptionGeneric) ToBytes() []byte {
}
func (og *OptionGeneric) String() string {
- return fmt.Sprintf("%s -> %v", og.OptionCode, og.OptionData)
+ if len(og.OptionData) == 0 {
+ return og.OptionCode.String()
+ }
+ return fmt.Sprintf("%s: %v", og.OptionCode, og.OptionData)
}
// ParseOption parses data according to the given code.
diff --git a/dhcpv6/types.go b/dhcpv6/types.go
index 7c4052f..be5d925 100644
--- a/dhcpv6/types.go
+++ b/dhcpv6/types.go
@@ -234,10 +234,10 @@ const (
// optionCodeToString maps DHCPv6 OptionCodes to human-readable strings.
var optionCodeToString = map[OptionCode]string{
- OptionClientID: "Client Identifier",
- OptionServerID: "Server Identifier",
- OptionIANA: "IA_NA",
- OptionIATA: "IA_TA",
+ OptionClientID: "Client ID",
+ OptionServerID: "Server ID",
+ OptionIANA: "IANA",
+ OptionIATA: "IATA",
OptionIAAddr: "IA IP Address",
OptionORO: "Requested Options",
OptionPreference: "Preference",
@@ -255,9 +255,9 @@ var optionCodeToString = map[OptionCode]string{
OptionReconfAccept: "Reconfig Accept",
OptionSIPServersDomainNameList: "SIP Servers Domain Name List",
OptionSIPServersIPv6AddressList: "SIP Servers IPv6 Address List",
- OptionDNSRecursiveNameServer: "DNS Recursive Name Server",
+ OptionDNSRecursiveNameServer: "DNS",
OptionDomainSearchList: "Domain Search List",
- OptionIAPD: "IA_PD",
+ OptionIAPD: "IAPD",
OptionIAPrefix: "IA Prefix",
OptionNISServers: "NIS Servers",
OptionNISPServers: "NISP Servers",
@@ -284,7 +284,7 @@ var optionCodeToString = map[OptionCode]string{
OptionMIPv6VisitedHomeNetworkInformation: "MIPv6 Visited Home Network Information",
OptionLoSTServer: "LoST Server",
OptionCAPWAPAccessControllerAddresses: "CAPWAP Access Controller Addresses",
- OptionRelayID: "RELAY_ID",
+ OptionRelayID: "Relay ID",
OptionIPv6AddressMOS: "OPTION-IPv6_Address-MoS",
OptionIPv6FQDNMOS: "OPTION-IPv6-FQDN-MoS",
OptionNTPServer: "NTP Server",
@@ -328,9 +328,9 @@ var optionCodeToString = map[OptionCode]string{
OptionS46ContMapE: "Softwire46 MAP-E Container",
OptionS46ContMapT: "Softwire46 MAP-T Container",
OptionS46ContLW: "Softwire46 Lightweight 4over6 Container",
- Option4RD: "IPv4 Residual Deployment",
- Option4RDMapRule: "IPv4 Residual Deployment Mapping Rule",
- Option4RDNonMapRule: "IPv4 Residual Deployment Non-Mapping Rule",
+ Option4RD: "4RD",
+ Option4RDMapRule: "4RD Mapping Rule",
+ Option4RDNonMapRule: "4RD Non-Mapping Rule",
OptionLQBaseTime: "Leasequery Server Base time",
OptionLQStartTime: "Leasequery Server Query Start Time",
OptionLQEndTime: "Leasequery Server Query End Time",