From 060633e1afd24f6c69dccf9ee99b85dddbdee651 Mon Sep 17 00:00:00 2001 From: Pablo Mazzini Date: Sun, 11 Nov 2018 22:15:57 +0000 Subject: OptRelayAgentInformation: increase coverage --- dhcpv4/options.go | 2 +- dhcpv4/options_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'dhcpv4') 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) -- cgit v1.2.3