Mercurial > hg > dhcpcd
changeset 1885:158c55bbce72 draft
Respect xidhwaddr option for DHCPv6
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 28 Mar 2013 06:38:27 +0000 |
| parents | 3d4a3711a436 |
| children | 23ca5addb202 |
| files | dhcp6.c |
| diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcp6.c Wed Mar 27 16:36:56 2013 +0000 +++ b/dhcp6.c Thu Mar 28 06:38:27 2013 +0000 @@ -328,11 +328,18 @@ } 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 @@ return -1; } - dhcp6_newxid(state->send); + dhcp6_newxid(ifp, state->send); o = D6_FIRST_OPTION(state->send); o->code = htons(D6_OPTION_CLIENTID);
