summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/iputils_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6/iputils_test.go')
-rw-r--r--dhcpv6/iputils_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/dhcpv6/iputils_test.go b/dhcpv6/iputils_test.go
index 765792e..1da249d 100644
--- a/dhcpv6/iputils_test.go
+++ b/dhcpv6/iputils_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/mock"
+ "github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
@@ -101,3 +102,31 @@ func (s *MatchingAddressTestSuite) TestGetGlobalAddr() {
func TestMatchingAddressTestSuite(t *testing.T) {
suite.Run(t, new(MatchingAddressTestSuite))
}
+
+func Test_ExtractMAC(t *testing.T) {
+ //SOLICIT message wrapped in Relay-Forw
+ var relayForwBytesDuidUUID = []byte{
+ 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x26, 0x8a, 0x07, 0xff, 0xfe, 0x56,
+ 0xdc, 0xa4, 0x00, 0x12, 0x00, 0x06, 0x24, 0x8a,
+ 0x07, 0x56, 0xdc, 0xa4, 0x00, 0x09, 0x00, 0x5a,
+ 0x06, 0x7d, 0x9b, 0xca, 0x00, 0x01, 0x00, 0x12,
+ 0x00, 0x04, 0xb7, 0xfd, 0x0a, 0x8c, 0x1b, 0x14,
+ 0x10, 0xaa, 0xeb, 0x0a, 0x5b, 0x3f, 0xe8, 0x9d,
+ 0x0f, 0x56, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x17,
+ 0x00, 0x18, 0x00, 0x17, 0x00, 0x18, 0x00, 0x01,
+ 0x00, 0x08, 0x00, 0x02, 0xff, 0xff, 0x00, 0x03,
+ 0x00, 0x28, 0x07, 0x56, 0xdc, 0xa4, 0x00, 0x00,
+ 0x0e, 0x10, 0x00, 0x00, 0x15, 0x18, 0x00, 0x05,
+ 0x00, 0x18, 0x26, 0x20, 0x01, 0x0d, 0xc0, 0x82,
+ 0x90, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xaf, 0xa0, 0x00, 0x00, 0x1c, 0x20, 0x00, 0x00,
+ 0x1d, 0x4c}
+ packet, err := FromBytes(relayForwBytesDuidUUID)
+ require.NoError(t, err)
+ mac, err := ExtractMAC(packet)
+ require.NoError(t, err)
+ require.Equal(t, mac.String(), "24:8a:07:56:dc:a4")
+}