summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/modifiers.go
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2019-04-23 23:09:44 +0100
committerinsomniac <insomniacslk@users.noreply.github.com>2019-04-24 21:37:02 +0100
commit8166b9a9db9b180c02622ebf3dcff01ff2b2e0a6 (patch)
tree31d3044177cebed28784b1b282a9ea73fc9b65a6 /dhcpv6/modifiers.go
parentebf43962e121b9c5c982d6a647a29fa4ae9b6a14 (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/modifiers.go')
-rw-r--r--dhcpv6/modifiers.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/dhcpv6/modifiers.go b/dhcpv6/modifiers.go
index eaa370d..200a602 100644
--- a/dhcpv6/modifiers.go
+++ b/dhcpv6/modifiers.go
@@ -77,6 +77,21 @@ func WithIANA(addrs ...OptIAAddress) Modifier {
}
}
+// WithIAID updates an OptIANA option with the provided IAID
+func WithIAID(iaid [4]byte) Modifier {
+ return func(d DHCPv6) {
+ opt := d.GetOneOption(OptionIANA)
+ if opt == nil {
+ opt = &OptIANA{
+ Options: Options{},
+ }
+ }
+ iaNa := opt.(*OptIANA)
+ copy(iaNa.IaId[:], iaid[:])
+ d.UpdateOption(iaNa)
+ }
+}
+
// WithDNS adds or updates an OptDNSRecursiveNameServer
func WithDNS(dnses ...net.IP) Modifier {
return func(d DHCPv6) {