summaryrefslogtreecommitdiff
path: root/networking/udhcp/d6_dhcpc.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-01-16 21:35:39 +0100
committerDenys Vlasenko2018-01-16 21:35:39 +0100
commit1e8d79ba12d715d4375856418173c5375fbfce40 (patch)
tree65d4b9743d27ae1f6e6b282cfbeaf4f53434e755 /networking/udhcp/d6_dhcpc.c
parent688cb3bc1979bad4236315517a7c7bb3a51289f1 (diff)
downloadbusybox-1e8d79ba12d715d4375856418173c5375fbfce40.zip
busybox-1e8d79ba12d715d4375856418173c5375fbfce40.tar.gz
udhcpc6: preparatory patch, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/d6_dhcpc.c')
-rw-r--r--networking/udhcp/d6_dhcpc.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 65ff5de..57ad968 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -1589,44 +1589,44 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
* . .
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- free(client6_data.ia_na);
- client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA);
- if (!client6_data.ia_na) {
- bb_error_msg("no %s option, ignoring packet", "IA_NA");
- continue;
- }
- if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) {
- bb_error_msg("IA_NA option is too short:%d bytes", client6_data.ia_na->len);
- continue;
- }
- iaaddr = d6_find_option(client6_data.ia_na->data + 4 + 4 + 4,
- client6_data.ia_na->data + client6_data.ia_na->len,
- D6_OPT_IAADDR
- );
- if (!iaaddr) {
- bb_error_msg("no %s option, ignoring packet", "IAADDR");
- continue;
- }
- if (iaaddr->len < (16 + 4 + 4)) {
- bb_error_msg("IAADDR option is too short:%d bytes", iaaddr->len);
- continue;
- }
- /* Note: the address is sufficiently aligned for cast:
- * we _copied_ IA-NA, and copy is always well-aligned.
- */
- requested_ipv6 = (struct in6_addr*) iaaddr->data;
- move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4);
- lease_seconds = ntohl(lease_seconds);
- /* paranoia: must not be too small and not prone to overflows */
- if (lease_seconds < 0x10)
- lease_seconds = 0x10;
+ free(client6_data.ia_na);
+ client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA);
+ if (!client6_data.ia_na) {
+ bb_error_msg("no %s option, ignoring packet", "IA_NA");
+ continue;
+ }
+ if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) {
+ bb_error_msg("IA_NA option is too short:%d bytes", client6_data.ia_na->len);
+ continue;
+ }
+ iaaddr = d6_find_option(client6_data.ia_na->data + 4 + 4 + 4,
+ client6_data.ia_na->data + client6_data.ia_na->len,
+ D6_OPT_IAADDR
+ );
+ if (!iaaddr) {
+ bb_error_msg("no %s option, ignoring packet", "IAADDR");
+ continue;
+ }
+ if (iaaddr->len < (16 + 4 + 4)) {
+ bb_error_msg("IAADDR option is too short:%d bytes", iaaddr->len);
+ continue;
+ }
+ /* Note: the address is sufficiently aligned for cast:
+ * we _copied_ IA-NA, and copy is always well-aligned.
+ */
+ requested_ipv6 = (struct in6_addr*) iaaddr->data;
+ move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4);
+ lease_seconds = ntohl(lease_seconds);
+ /* paranoia: must not be too small and not prone to overflows */
+ if (lease_seconds < 0x10)
+ lease_seconds = 0x10;
/// TODO: check for 0 lease time?
- if (lease_seconds > 0x7fffffff / 1000)
- lease_seconds = 0x7fffffff / 1000;
- /* enter bound state */
- timeout = lease_seconds / 2;
- bb_error_msg("lease obtained, lease time %u",
- /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
+ if (lease_seconds > 0x7fffffff / 1000)
+ lease_seconds = 0x7fffffff / 1000;
+ /* enter bound state */
+ timeout = lease_seconds / 2;
+ bb_error_msg("lease obtained, lease time %u",
+ /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
d6_run_script(&packet, state == REQUESTING ? "bound" : "renew");
state = BOUND;