summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/iputils_test.go
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2018-11-18 12:41:03 +0000
committerPablo Mazzini <pmazzini@gmail.com>2018-11-18 12:41:03 +0000
commitf93d4677fa8de27c1fbf70d0fec117492ed432bb (patch)
treedab0ca59173ba656a96c4f28a17c056181741bf9 /dhcpv6/iputils_test.go
parent70409af21497e0d61e42e48e718b1f2b68e1ce84 (diff)
iputils: add ExtractMAC
Diffstat (limited to 'dhcpv6/iputils_test.go')
-rw-r--r--dhcpv6/iputils_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/dhcpv6/iputils_test.go b/dhcpv6/iputils_test.go
index d2d8a95..faa13a8 100644
--- a/dhcpv6/iputils_test.go
+++ b/dhcpv6/iputils_test.go
@@ -131,6 +131,7 @@ func Test_ExtractMAC(t *testing.T) {
require.NoError(t, err)
require.Equal(t, mac.String(), "24:8a:07:56:dc:a4")
+ // MAC extracted from DUID
duid := Duid{
Type: DUID_LL,
HwType: iana.HwTypeEthernet,
@@ -142,4 +143,17 @@ func Test_ExtractMAC(t *testing.T) {
require.NoError(t, err)
mac, err = ExtractMAC(relay)
require.Equal(t, mac.String(), "aa:aa:aa:aa:aa:aa")
+
+ // no client ID
+ solicit, err = NewMessage()
+ require.NoError(t, err)
+ mac, err = ExtractMAC(solicit)
+ require.Error(t, err)
+
+ // DUID is not DuidLL or DuidLLT
+ duid = Duid{}
+ solicit, err = NewMessage(WithClientID(duid))
+ require.NoError(t, err)
+ mac, err = ExtractMAC(solicit)
+ require.Error(t, err)
}