aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-11-07 16:21:24 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-11-07 16:21:24 +0100
commit68c5b28156450d686605bd4715980037cabf1286 (patch)
tree3360e61ad92015c5a34819b1a9c177524c237c02
parent9ba75048c0099ed90b9a64cb7bb57bf12be93528 (diff)
downloadbusybox-68c5b28156450d686605bd4715980037cabf1286.tar.gz
udhcpc6: fix endianness
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/d6_common.h4
-rw-r--r--networking/udhcp/d6_dhcpc.c16
2 files changed, 10 insertions, 10 deletions
diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h
index 88afaf8af..36d822f7e 100644
--- a/networking/udhcp/d6_common.h
+++ b/networking/udhcp/d6_common.h
@@ -54,10 +54,10 @@ struct udp_d6_packet {
/*** Options ***/
struct d6_option {
- uint8_t code;
uint8_t code_hi;
- uint8_t len;
+ uint8_t code;
uint8_t len_hi;
+ uint8_t len;
uint8_t data[1];
} PACKED;
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index d1baaae9b..62d79b363 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -97,20 +97,20 @@ static void *d6_find_option(uint8_t *option, uint8_t *option_end, unsigned code)
int len_m4 = option_end - option - 4;
while (len_m4 >= 0) {
/* Next option's len is too big? */
- if (option[2] > len_m4)
+ if (option[3] > len_m4)
return NULL; /* yes. bogus packet! */
/* So far we treat any opts with code >255
* or len >255 as bogus, and stop at once.
* This simplifies big-endian handling.
*/
- if (option[1] != 0 || option[3] != 0)
+ if (option[0] != 0 || option[2] != 0)
return NULL;
/* Option seems to be valid */
/* Does its code match? */
- if (option[0] == code)
+ if (option[1] == code)
return option; /* yes! */
- option += option[2] + 4;
- len_m4 -= option[2] + 4;
+ option += option[3] + 4;
+ len_m4 -= option[3] + 4;
}
return NULL;
}
@@ -120,7 +120,7 @@ static void *d6_copy_option(uint8_t *option, uint8_t *option_end, unsigned code)
uint8_t *opt = d6_find_option(option, option_end, code);
if (!opt)
return opt;
- return memcpy(xmalloc(opt[2] + 4), opt, opt[2] + 4);
+ return memcpy(xmalloc(opt[3] + 4), opt, opt[3] + 4);
}
static void *d6_store_blob(void *dst, const void *src, unsigned len)
@@ -920,8 +920,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
clientid = xzalloc(2+2+2+2+6);
clientid->code = D6_OPT_CLIENTID;
clientid->len = 2+2+6;
- clientid->data[0] = 3; /* DUID-LL */
- clientid->data[2] = 1; /* ethernet */
+ clientid->data[1] = 3; /* DUID-LL */
+ clientid->data[3] = 1; /* ethernet */
clientid_mac_ptr = clientid->data + 2+2;
memcpy(clientid_mac_ptr, client_config.client_mac, 6);
client_config.clientid = (void*)clientid;