X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fdhcpv6.c;h=5a6fd8303646a8f1902ba9d8ff42c4e8642cef6b;hp=42e512161161ae43cdab56927c1e1f1fadf1645f;hb=7489874cd84cc77c97f475fd1ed842b642eed3c5;hpb=efb1a99e7cbaf9841226bb7564d07a76411a2552 diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 42e5121..5a6fd83 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -564,7 +564,7 @@ static bool dhcpv6_response_is_valid(const void *buf, ssize_t len, if (r->protocol != 3 || r->algorithm != 1 || r->reconf_type != 2) continue; - md5_state_t md5; + md5_ctx_t md5; uint8_t serverhash[16], secretbytes[16], hash[16]; memcpy(serverhash, r->key, sizeof(serverhash)); memset(r->key, 0, sizeof(r->key)); @@ -573,20 +573,20 @@ static bool dhcpv6_response_is_valid(const void *buf, ssize_t len, for (size_t i = 0; i < sizeof(secretbytes); ++i) secretbytes[i] ^= 0x36; - md5_init(&md5); - md5_append(&md5, secretbytes, sizeof(secretbytes)); - md5_append(&md5, buf, len); - md5_finish(&md5, hash); + md5_begin(&md5); + md5_hash(secretbytes, sizeof(secretbytes), &md5); + md5_hash(buf, len, &md5); + md5_end(hash, &md5); for (size_t i = 0; i < sizeof(secretbytes); ++i) { secretbytes[i] ^= 0x36; secretbytes[i] ^= 0x5c; } - md5_init(&md5); - md5_append(&md5, secretbytes, sizeof(secretbytes)); - md5_append(&md5, hash, 16); - md5_finish(&md5, hash); + md5_begin(&md5); + md5_hash(secretbytes, sizeof(secretbytes), &md5); + md5_hash(hash, 16, &md5); + md5_end(hash, &md5); rcauth_ok = !memcmp(hash, serverhash, sizeof(hash)); } else if (otype == DHCPV6_OPT_RECONF_MESSAGE && olen == 1) { @@ -1116,6 +1116,8 @@ static int dhcpv6_calc_refresh_timers(void) t1 = l_t1; t2 = l_t2; t3 = l_t3; + } else { + t1 = 600; } return (int)(ia_pd_entries + ia_na_entries); @@ -1253,7 +1255,8 @@ int dhcpv6_promote_server_cand(void) size_t cand_len; struct dhcpv6_server_cand *cand = odhcp6c_get_state(STATE_SERVER_CAND, &cand_len); uint16_t hdr[2]; - int ret = DHCPV6_STATELESS; + int ret = (na_mode == IA_MODE_NONE && pd_mode == IA_MODE_NONE) ? + DHCPV6_STATELESS : DHCPV6_STATEFUL; // Clear lingering candidate state info odhcp6c_clear_state(STATE_SERVER_ID);