#define HMAC_LENGTH 16
+void
+dhcp_auth_reset(struct authstate *state)
+{
+
+ if (state->reconf) {
+ free(state->reconf);
+ state->reconf = NULL;
+ }
+}
+
/*
* Authenticate a DHCP message.
* m and mlen refer to the whole message.
/* Nothing to validate, just accepting the key */
return state->reconf;
case 2:
+ if (!((mp == 4 && mt == DHCP_FORCERENEW) ||
+ (mp == 6 && mt == DHCP6_RECONFIGURE)))
+ {
+ errno = EINVAL;
+ return NULL;
+ }
if (state->reconf == NULL) {
errno = ENOENT;
return NULL;
#define DHCPCD_AUTH_REQUIRE (1 << 1)
#define DHCPCD_AUTH_RDM_COUNTER (1 << 2)
+#define DHCPCD_AUTH_SENDREQUIRE (DHCPCD_AUTH_SEND | DHCPCD_AUTH_REQUIRE)
+
#define AUTH_PROTO_TOKEN 0
#define AUTH_PROTO_DELAYED 1
#define AUTH_PROTO_DELAYEDREALM 2
struct token *reconf;
};
+void dhcp_auth_reset(struct authstate *);
+
const struct token * dhcp_auth_validate(struct authstate *,
const struct auth *,
const uint8_t *, unsigned int, int, int,
p += ifo->vendor[0] + 1;
}
- /* We support HMAC-MD5 */
- *p++ = DHO_FORCERENEW_NONCE;
- *p++ = 1;
- *p++ = AUTH_ALG_HMAC_MD5;
+ if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) !=
+ DHCPCD_AUTH_SENDREQUIRE)
+ {
+ /* We support HMAC-MD5 */
+ *p++ = DHO_FORCERENEW_NONCE;
+ *p++ = 1;
+ *p++ = AUTH_ALG_HMAC_MD5;
+ }
if (ifo->vivco_len) {
*p++ = DHO_VIVCO;
state = D_STATE(ifp);
if (state == NULL)
return;
+ dhcp_auth_reset(&state->auth);
dhcp_close(ifp);
arp_close(ifp);
eloop_timeouts_delete(ifp, dhcp_expire, NULL);
if (fqdn != FQDN_DISABLE)
len += sizeof(*o) + 1 + encode_rfc1035(hostname, NULL);
- len += sizeof(*o); /* Reconfigure Accept */
+ if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) !=
+ DHCPCD_AUTH_SENDREQUIRE)
+ len += sizeof(*o); /* Reconfigure Accept */
}
len += sizeof(*state->send);
o->len = htons(l + 1);
}
- o = D6_NEXT_OPTION(o);
- o->code = htons(D6_OPTION_RECONF_ACCEPT);
- o->len = 0;
+ if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) !=
+ DHCPCD_AUTH_SENDREQUIRE)
+ {
+ o = D6_NEXT_OPTION(o);
+ o->code = htons(D6_OPTION_RECONF_ACCEPT);
+ o->len = 0;
+ }
if (n_options) {
o = D6_NEXT_OPTION(o);
* of which interface is delegating as we remeber it by pointer.
* So if we need to change this behaviour, we need to change
* how we remember which interface delegated.
+ *
+ * XXX The below is no longer true due to the change of the
+ * default IAID, but do PPP links have stable ethernet addresses?
+ *
* To make it more interesting, on some OS's with PPP links
* there is no guarantee the delegating interface will have
* the same name or index so think very hard before changing
state = D6_STATE(ifp);
if (state) {
+ dhcp_auth_reset(&state->auth);
if (ifp->options->options & DHCPCD_RELEASE) {
if (ifp->carrier != LINK_DOWN)
dhcp6_startrelease(ifp);