diff options
author | Andrea Barberio <insomniac@slackware.it> | 2019-04-23 23:09:44 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2019-04-24 21:37:02 +0100 |
commit | 8166b9a9db9b180c02622ebf3dcff01ff2b2e0a6 (patch) | |
tree | 31d3044177cebed28784b1b282a9ea73fc9b65a6 /dhcpv6/dhcpv6_test.go | |
parent | ebf43962e121b9c5c982d6a647a29fa4ae9b6a14 (diff) |
[dhcpv6] Solicit messages derive default IAID from MAC address
IAID must be set by the client. This patch generates the IAID from the
MAC address of the interface. To do so, a new WithIAID modifier is
added, the interface of NewSolicitWithCID now requires a hwaddr
parameter, and NewAdvertiseFromSolicit copies the IA_NA option from the
solicit if present.
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
Diffstat (limited to 'dhcpv6/dhcpv6_test.go')
-rw-r--r-- | dhcpv6/dhcpv6_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go index d509572..10a7296 100644 --- a/dhcpv6/dhcpv6_test.go +++ b/dhcpv6/dhcpv6_test.go @@ -197,7 +197,7 @@ func TestNewReplyFromMessage(t *testing.T) { require.Error(t, err) } -func TestNewMessageTypeSolicitWithCID(t *testing.T) { +func TestNewMessageTypeSolicit(t *testing.T) { hwAddr, err := net.ParseMAC("24:0A:9E:9F:EB:2B") require.NoError(t, err) @@ -207,7 +207,7 @@ func TestNewMessageTypeSolicitWithCID(t *testing.T) { LinkLayerAddr: hwAddr, } - s, err := NewSolicitWithCID(duid) + s, err := NewSolicit(hwAddr, WithClientID(duid)) require.NoError(t, err) require.Equal(t, s.Type(), MessageTypeSolicit) @@ -227,6 +227,14 @@ func TestNewMessageTypeSolicitWithCID(t *testing.T) { require.Contains(t, opts, OptionDNSRecursiveNameServer) require.Contains(t, opts, OptionDomainSearchList) require.Equal(t, len(opts), 2) + + // Check IA_NA + iaid := [4]byte{hwAddr[2], hwAddr[3], hwAddr[4], hwAddr[5]} + iaNaOption := s.GetOneOption(OptionIANA) + require.NotNil(t, iaNaOption) + iaNa, ok := iaNaOption.(*OptIANA) + require.True(t, ok) + require.Equal(t, iaid, iaNa.IaId) } func TestIsUsingUEFIArchTypeTrue(t *testing.T) { |