diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-11-11 22:15:57 +0000 |
---|---|---|
committer | Pablo Mazzini <pmazzini@gmail.com> | 2018-11-11 22:15:57 +0000 |
commit | 060633e1afd24f6c69dccf9ee99b85dddbdee651 (patch) | |
tree | 84958f34050a90427350ff8dc665707c17f3b9b7 /dhcpv4 | |
parent | 1d591269d345af65c9f1c2c3a9d6b1c8ea327cb2 (diff) |
OptRelayAgentInformation: increase coverage
Diffstat (limited to 'dhcpv4')
-rw-r--r-- | dhcpv4/options.go | 2 | ||||
-rw-r--r-- | dhcpv4/options_test.go | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/dhcpv4/options.go b/dhcpv4/options.go index b117728..dc4a724 100644 --- a/dhcpv4/options.go +++ b/dhcpv4/options.go @@ -145,7 +145,7 @@ func OptionsFromBytesWithParser(data []byte, parser OptionParser) ([]Option, err // Options with zero length have no length byte, so here we handle the // ones with nonzero length - if opt.Length() > 0 { + if opt.Code() != OptionPad { idx++ } idx += opt.Length() diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go index a4bf6d7..3c1de67 100644 --- a/dhcpv4/options_test.go +++ b/dhcpv4/options_test.go @@ -151,6 +151,14 @@ func TestParseOption(t *testing.T) { require.Equal(t, 5, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") + // Option relay agent information + option = []byte{82, 2, 1, 0} + opt, err = ParseOption(option) + require.NoError(t, err) + require.Equal(t, OptionRelayAgentInformation, opt.Code(), "Code") + require.Equal(t, 2, opt.Length(), "Length") + require.Equal(t, option, opt.ToBytes(), "ToBytes") + // Option client system architecture type option option = []byte{93, 4, 't', 'e', 's', 't'} opt, err = ParseOption(option) |