state->new = NULL;
state->new_len = 0;
- /* XXX remove this line when we fix discover stamping on assigned */
dhcp6_freedrop_addrs(ifp, 0);
if (dhcp6_makemessage(ifp) == -1)
o = dhcp6_findoption(D6_OPTION_STATUS_CODE, p, len);
else
o = dhcp6_getoption(D6_OPTION_STATUS_CODE, m, len);
- if (o && dhcp6_getstatus(o) != D6_STATUS_OK) {
+ if (o == NULL) {
+ //syslog(LOG_DEBUG, "%s: no status", ifp->name);
+ return 0;
+ }
+ if (dhcp6_getstatus(o) != D6_STATUS_OK) {
syslog(LOG_ERR, "%s: DHCPv6 REPLY: %s", ifp->name, status);
return -1;
}
- return 0;
+ //syslog(LOG_DEBUG, "%s: status: %s", ifp->name, status);
+ return 1;
}
static struct ipv6_addr *
return -1;
}
+ if (dhcp6_checkstatusok(ifp, m, NULL, len) == -1)
+ return -1;
+
state->renew = state->rebind = state->expire = 0;
state->lowpl = ND6_INFINITE_LIFETIME;
len -= (const char *)o - (const char *)m;
const struct dhcp_opt *opt;
const struct if_options *ifo;
const struct ipv6_addr *ap;
- uint8_t stale;
+ uint8_t has_new;
+ int error;
len = recvmsg(sock, &rcvhdr, 0);
if (len == -1) {
break;
switch(state->state) {
case DH6S_CONFIRM:
- if (dhcp6_checkstatusok(ifp, r, NULL, len) == -1) {
+ error = dhcp6_checkstatusok(ifp, r, NULL, len);
+ /* If we got an OK status the chances are that we
+ * didn't get the IA's returned, so preserve them
+ * from our saved response */
+ if (error == 1)
+ goto recv;
+ if (error == -1 ||
+ dhcp6_validatelease(ifp, r, len, sfrom) == -1) {
dhcp6_startdiscover(ifp);
return;
}
- goto recv;
+ break;
case DH6S_REQUEST: /* FALLTHROUGH */
case DH6S_RENEW: /* FALLTHROUGH */
case DH6S_REBIND:
- goto replyok;
+ if (dhcp6_validatelease(ifp, r, len, sfrom) == -1)
+ return;
+ break;
default:
op = NULL;
}
op = NULL;
break;
}
-replyok:
if (dhcp6_validatelease(ifp, r, len, sfrom) == -1)
return;
break;
}
recv:
- stale = 1;
+ has_new = 0;
TAILQ_FOREACH(ap, &state->addrs, next) {
if (ap->flags & IPV6_AF_NEW) {
- stale = 0;
+ has_new = 1;
break;
}
}
- syslog(stale ? LOG_DEBUG : LOG_INFO,
+ syslog(has_new ? LOG_INFO : LOG_DEBUG,
"%s: %s received from %s", ifp->name, op, sfrom);
state->reason = NULL;
dhcp6_delegate_prefix(ifp);
ipv6ns_probeaddrs(&state->addrs);
if (state->renew || state->rebind)
- syslog(stale ? LOG_DEBUG : LOG_INFO,
+ syslog(has_new ? LOG_INFO : LOG_DEBUG,
"%s: renew in %"PRIu32" seconds,"
" rebind in %"PRIu32" seconds",
ifp->name, state->renew, state->rebind);