diff options
| author | Roy Marples <roy@marples.name> | 2008-10-28 09:24:23 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-10-28 09:24:23 +0000 |
| commit | 503f4fe18e2ce1ab0676104a07127b2ad2e68547 (patch) | |
| tree | b92a16c56bb38ceaff398356a166849aad96484d /dhcp.c | |
| parent | 3179cfaac73d770b28cf36211a3d67aa2d001d04 (diff) | |
| download | dhcpcd-503f4fe18e2ce1ab0676104a07127b2ad2e68547.tar.xz | |
Explain why we decline the address in a message.
Diffstat (limited to 'dhcp.c')
| -rw-r--r-- | dhcp.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -53,6 +53,8 @@ #define IPV4R IPV4 | REQUEST +#define DAD "Duplicate address detected" + /* Our aggregate option buffer. * We ONLY use this when options are split, which for most purposes is * practically never. See RFC3396 for details. */ @@ -760,6 +762,7 @@ make_message(struct dhcp_message **message, time_t up = uptime() - iface->start_uptime; uint32_t ul; uint16_t sz; + size_t len; const struct dhcp_opt *opt; const struct if_options *ifo = iface->state->options; const struct dhcp_lease *lease = &iface->state->lease; @@ -794,15 +797,18 @@ make_message(struct dhcp_message **message, case ARPHRD_IEEE1394: case ARPHRD_INFINIBAND: dhcp->hwlen = 0; - if (dhcp->ciaddr == 0) + if (dhcp->ciaddr == 0 && + type != DHCP_DECLINE && type != DHCP_RELEASE) dhcp->flags = htons(BROADCAST_FLAG); break; } - if (up < 0 || up > (time_t)UINT16_MAX) - dhcp->secs = htons((uint16_t)UINT16_MAX); - else - dhcp->secs = htons(up); + if (type != DHCP_DECLINE && type != DHCP_RELEASE) { + if (up < 0 || up > (time_t)UINT16_MAX) + dhcp->secs = htons((uint16_t)UINT16_MAX); + else + dhcp->secs = htons(up); + } dhcp->xid = iface->state->xid; dhcp->cookie = htonl(MAGIC_COOKIE); @@ -833,6 +839,14 @@ make_message(struct dhcp_message **message, } } + if (type == DHCP_DECLINE) { + *p++ = DHO_MESSAGE; + len = strlen(DAD); + *p++ = len; + memcpy(p, DAD, len); + p += len; + } + if (type == DHCP_DISCOVER || type == DHCP_INFORM || type == DHCP_REQUEST) |
