summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/iputils.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2023-02-18 23:55:40 -0800
committerChris K <c@chrisko.ch>2023-02-19 13:39:52 -0800
commit93dbaf95ae931da311e1671fd0f470f2aa5f6980 (patch)
tree9e316e50ebcece3b96f0c4261c63d32af8fa2c32 /dhcpv6/iputils.go
parentf51b4d4530334a45ccb40368ada7930d269ef44a (diff)
dhcpv6: proper DUID types
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/iputils.go')
-rw-r--r--dhcpv6/iputils.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/dhcpv6/iputils.go b/dhcpv6/iputils.go
index d2cac47..c4926e1 100644
--- a/dhcpv6/iputils.go
+++ b/dhcpv6/iputils.go
@@ -90,8 +90,15 @@ func ExtractMAC(packet DHCPv6) (net.HardwareAddr, error) {
if duid == nil {
return nil, fmt.Errorf("client ID not found in packet")
}
- if duid.LinkLayerAddr == nil {
- return nil, fmt.Errorf("failed to extract MAC")
+ switch d := duid.(type) {
+ case *DUIDLL:
+ if d.LinkLayerAddr != nil {
+ return d.LinkLayerAddr, nil
+ }
+ case *DUIDLLT:
+ if d.LinkLayerAddr != nil {
+ return d.LinkLayerAddr, nil
+ }
}
- return duid.LinkLayerAddr, nil
+ return nil, fmt.Errorf("failed to extract MAC")
}