X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fdhcpv6.c;h=846df9d2285ab49857117bb47bfc6d2ce3ec1042;hp=8be70af19797ffde5ed2ddf73646a13a90463280;hb=a300c7335c5ad78fb053e7c73b45e95e1f3c2ad1;hpb=e9de72f3fc41466819f8027b6cc7a978c388ed28 diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 8be70af..846df9d 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2012 Steven Barth + * Copyright (C) 2012-2013 Steven Barth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License v2 as published by @@ -520,7 +520,7 @@ static int dhcpv6_handle_advert(_unused enum dhcpv6_msg orig, cand.preference -= 2000; } else if (otype == DHCPV6_OPT_PREF && olen >= 1 && cand.preference >= 0) { - cand.preference = odata[1]; + cand.preference = odata[0]; } else if (otype == DHCPV6_OPT_RECONF_ACCEPT) { cand.wants_reconfigure = true; } else if (otype == DHCPV6_OPT_IA_PD && request_prefix) { @@ -623,7 +623,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, if (t3 < 0) t3 = 0; } else { - t1 = t2 = t3 = 86400; + t1 = t2 = t3 = UINT32_MAX; } if (opt) { @@ -647,6 +647,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, if (ia_hdr->iaid != 1 || l_t2 < l_t1) continue; + bool error = false; uint16_t stype, slen; uint8_t *sdata; // Test status and bail if error @@ -654,7 +655,10 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, stype, slen, sdata) if (stype == DHCPV6_OPT_STATUS && slen >= 2 && (sdata[0] || sdata[1])) - continue; + error = true; + + if (error) + continue; // Update times if (l_t1 > 0 && t1 > l_t1) @@ -674,6 +678,12 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, if (n < t3) t3 = n; + if (t2 >= t3) + t2 = 8 * t3 / 10; + + if (t1 >= t2) + t1 = 5 * t2 / 8; + } else if (otype == DHCPV6_OPT_DNS_SERVERS) { if (olen % 16 == 0) odhcp6c_add_state(STATE_DNS, odata, olen);