diff options
Diffstat (limited to 'dhcpv4/bsdp')
-rw-r--r-- | dhcpv4/bsdp/bsdp.go | 2 | ||||
-rw-r--r-- | dhcpv4/bsdp/bsdp_option_misc_test.go | 12 | ||||
-rw-r--r-- | dhcpv4/bsdp/option_vendor_specific_information.go | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/dhcpv4/bsdp/bsdp.go b/dhcpv4/bsdp/bsdp.go index c9f7c26..d90e884 100644 --- a/dhcpv4/bsdp/bsdp.go +++ b/dhcpv4/bsdp/bsdp.go @@ -93,7 +93,7 @@ func NewInformListForInterface(ifname string, replyPort uint16) (*Packet, error) if err != nil { return nil, fmt.Errorf("could not get local IPv4 addr for %s: %v", iface.Name, err) } - if localIPs == nil || len(localIPs) == 0 { + if len(localIPs) == 0 { return nil, fmt.Errorf("could not get local IPv4 addr for %s", iface.Name) } return NewInformList(iface.HardwareAddr, localIPs[0], replyPort) diff --git a/dhcpv4/bsdp/bsdp_option_misc_test.go b/dhcpv4/bsdp/bsdp_option_misc_test.go index 44e2813..675a5db 100644 --- a/dhcpv4/bsdp/bsdp_option_misc_test.go +++ b/dhcpv4/bsdp/bsdp_option_misc_test.go @@ -22,7 +22,7 @@ func TestGetReplyPort(t *testing.T) { require.Equal(t, uint16(1234), port) o = VendorOptions{dhcpv4.Options{}} - port, err = o.ReplyPort() + _, err = o.ReplyPort() require.Error(t, err, "no reply port present") } @@ -40,7 +40,7 @@ func TestGetServerPriority(t *testing.T) { require.Equal(t, uint16(1234), prio) o = VendorOptions{dhcpv4.Options{}} - prio, err = o.ServerPriority() + _, err = o.ServerPriority() require.Error(t, err, "no server prio present") } @@ -73,19 +73,19 @@ func TestGetVersion(t *testing.T) { require.Equal(t, ver, Version1_1) o = VendorOptions{dhcpv4.Options{}} - ver, err = o.Version() + _, err = o.Version() require.Error(t, err, "no version present") o = VendorOptions{dhcpv4.Options{OptionVersion.Code(): []byte{}}} - ver, err = o.Version() + _, err = o.Version() require.Error(t, err, "empty version field") o = VendorOptions{dhcpv4.Options{OptionVersion.Code(): []byte{1}}} - ver, err = o.Version() + _, err = o.Version() require.Error(t, err, "version option too short") o = VendorOptions{dhcpv4.Options{OptionVersion.Code(): []byte{1, 2, 3}}} - ver, err = o.Version() + _, err = o.Version() require.Error(t, err, "version option too long") } diff --git a/dhcpv4/bsdp/option_vendor_specific_information.go b/dhcpv4/bsdp/option_vendor_specific_information.go index abdd9a5..4c2365c 100644 --- a/dhcpv4/bsdp/option_vendor_specific_information.go +++ b/dhcpv4/bsdp/option_vendor_specific_information.go @@ -153,5 +153,5 @@ func parseOption(code dhcpv4.OptionCode, data []byte) fmt.Stringer { if d != nil && d.FromBytes(data) == nil { return d } - return dhcpv4.OptionGeneric{data} + return dhcpv4.OptionGeneric{Data: data} } |