diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-03-04 21:24:31 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2020-03-04 21:31:14 +0000 |
commit | 9e4750895995d4d3f4dd36d4fff26d7b3927a34b (patch) | |
tree | b143dcb213f9e32bc3bbffc1bc53a94c591b140c /dhcpv6/option_iaprefix_test.go | |
parent | 81b9770086ea37a41d98163431b0c53ec70c823c (diff) |
dhcpv6: allow using OptIAPrefix without initializing
Set the IPv6 prefix field to zero if the prefix is invalid
or not initialized.
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
Diffstat (limited to 'dhcpv6/option_iaprefix_test.go')
-rw-r--r-- | dhcpv6/option_iaprefix_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dhcpv6/option_iaprefix_test.go b/dhcpv6/option_iaprefix_test.go index 7a24d2b..a1c140e 100644 --- a/dhcpv6/option_iaprefix_test.go +++ b/dhcpv6/option_iaprefix_test.go @@ -56,6 +56,21 @@ func TestOptIAPrefixToBytes(t *testing.T) { } } +func TestOptIAPrefixToBytesDefault(t *testing.T) { + buf := []byte{ + 0, 0, 0, 0, // preferredLifetime + 0, 0, 0, 0, // validLifetime + 0, // prefixLength + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ipv6Prefix + } + opt := OptIAPrefix{ + } + toBytes := opt.ToBytes() + if !bytes.Equal(toBytes, buf) { + t.Fatalf("Invalid ToBytes result. Expected %v, got %v", buf, toBytes) + } +} + func TestOptIAPrefixParseInvalidTooShort(t *testing.T) { buf := []byte{ 0xaa, 0xbb, 0xcc, 0xdd, // preferredLifetime |