diff options
author | Denis Vlasenko | 2007-11-23 00:08:54 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-11-23 00:08:54 +0000 |
commit | 6884f665bd7bc101f56ff9047afaffbc06dc99e2 (patch) | |
tree | 9eb497068cdee02c112c2f55bd0def8ae6354e92 /networking/udhcp/options.c | |
parent | 68af8e7a084317191effa9b257483a50d994b11c (diff) | |
download | busybox-6884f665bd7bc101f56ff9047afaffbc06dc99e2.zip busybox-6884f665bd7bc101f56ff9047afaffbc06dc99e2.tar.gz |
dhcp: stop using magic constants; use (htonl(CONST) != a) - it's smaller
function old new delta
udhcp_get_packet 146 134 -12
get_raw_packet 368 353 -15
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r-- | networking/udhcp/options.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 3168fc6..2b4f164 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c @@ -73,12 +73,13 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) { int i, length; uint8_t *optionptr; - int over = 0, done = 0, curr = OPTION_FIELD; + int over = 0; + int curr = OPTION_FIELD; optionptr = packet->options; i = 0; - length = 308; - while (!done) { + length = sizeof(packet->options); + while (1) { if (i >= length) { bb_error_msg("bogus packet, option fields too long"); return NULL; @@ -103,17 +104,18 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) i += optionptr[OPT_LEN] + 2; break; case DHCP_END: - if (curr == OPTION_FIELD && over & FILE_FIELD) { + if (curr == OPTION_FIELD && (over & FILE_FIELD)) { optionptr = packet->file; i = 0; - length = 128; + length = sizeof(packet->file); curr = FILE_FIELD; - } else if (curr == FILE_FIELD && over & SNAME_FIELD) { + } else if (curr == FILE_FIELD && (over & SNAME_FIELD)) { optionptr = packet->sname; i = 0; - length = 64; + length = sizeof(packet->sname); curr = SNAME_FIELD; - } else done = 1; + } else + return NULL; break; default: i += optionptr[OPT_LEN + i] + 2; |