From: Roy Marples Date: Thu, 28 Mar 2013 06:38:27 +0000 (+0000) Subject: Respect xidhwaddr option for DHCPv6 X-Git-Tag: v5.99.6~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af1151109741d4a3faffa5f9c2e3671107ad7362;p=thirdparty%2Fdhcpcd.git Respect xidhwaddr option for DHCPv6 --- diff --git a/dhcp6.c b/dhcp6.c index 0679c2f0..5d09236b 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -328,11 +328,18 @@ dhcp6_updateelapsed(struct interface *ifp, struct dhcp6_message *m, ssize_t len) } static void -dhcp6_newxid(struct dhcp6_message *m) +dhcp6_newxid(const struct interface *ifp, struct dhcp6_message *m) { uint32_t xid; - xid = arc4random(); + if (ifp->options->options & DHCPCD_XID_HWADDR && + ifp->hwlen >= sizeof(xid)) + /* The lower bits are probably more unique on the network */ + memcpy(&xid, (ifp->hwaddr + ifp->hwlen) - sizeof(xid), + sizeof(xid)); + else + xid = arc4random(); + m->xid[0] = (xid >> 16) & 0xff; m->xid[1] = (xid >> 8) & 0xff; m->xid[2] = xid & 0xff; @@ -451,7 +458,7 @@ dhcp6_makemessage(struct interface *ifp) return -1; } - dhcp6_newxid(state->send); + dhcp6_newxid(ifp, state->send); o = D6_FIRST_OPTION(state->send); o->code = htons(D6_OPTION_CLIENTID);