summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6_test.go
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2019-04-23 09:24:48 +0100
committerAndrea Barberio <insomniac@slackware.it>2019-04-23 20:05:31 +0100
commitb071bdc86a58037f6c745647c97fca202f3caef9 (patch)
treea64975a795bad93f7e58256cfecdb01aaf45067f /dhcpv6/dhcpv6_test.go
parentef6ad8a08ce25eeca699f984c59062c6ca107ee1 (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.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go
index d509572..ac44314 100644
--- a/dhcpv6/dhcpv6_test.go
+++ b/dhcpv6/dhcpv6_test.go
@@ -144,6 +144,7 @@ func TestNewAdvertiseFromSolicit(t *testing.T) {
cid := OptClientId{}
s.AddOption(&cid)
duid := Duid{}
+ WithIAID([4]byte{1, 2, 3, 4})(&s)
a, err := NewAdvertiseFromSolicit(&s, WithServerID(duid))
require.NoError(t, err)
@@ -207,7 +208,7 @@ func TestNewMessageTypeSolicitWithCID(t *testing.T) {
LinkLayerAddr: hwAddr,
}
- s, err := NewSolicitWithCID(duid)
+ s, err := NewSolicitWithCID(duid, hwAddr)
require.NoError(t, err)
require.Equal(t, s.Type(), MessageTypeSolicit)
@@ -227,6 +228,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) {