aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-23 00:08:54 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-23 00:08:54 +0000
commit6884f665bd7bc101f56ff9047afaffbc06dc99e2 (patch)
tree9eb497068cdee02c112c2f55bd0def8ae6354e92 /networking/udhcp/clientpacket.c
parent68af8e7a084317191effa9b257483a50d994b11c (diff)
downloadbusybox-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/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index e7eeb58b1..4a5c627f4 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -171,7 +171,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
bytes = read(fd, &packet, sizeof(struct udp_dhcp_packet));
if (bytes < 0) {
DEBUG("Cannot read on raw listening socket - ignoring");
- usleep(500000); /* possible down interface, looping condition */
+ sleep(1); /* possible down interface, looping condition */
return -1;
}
@@ -190,7 +190,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
/* Make sure its the right packet for us, and that it passes sanity checks */
if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION
- || packet.ip.ihl != sizeof(packet.ip) >> 2
+ || packet.ip.ihl != (sizeof(packet.ip) >> 2)
|| packet.udp.dest != htons(CLIENT_PORT)
|| bytes > (int) sizeof(struct udp_dhcp_packet)
|| ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
@@ -207,7 +207,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
return -1;
}
- /* verify the UDP checksum by replacing the header with a psuedo header */
+ /* verify the UDP checksum by replacing the header with a pseudo header */
source = packet.ip.saddr;
dest = packet.ip.daddr;
check = packet.udp.check;
@@ -225,7 +225,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
memcpy(payload, &(packet.data), bytes - (sizeof(packet.ip) + sizeof(packet.udp)));
- if (ntohl(payload->cookie) != DHCP_MAGIC) {
+ if (payload->cookie != htonl(DHCP_MAGIC)) {
bb_error_msg("received bogus message (bad magic) - ignoring");
return -2;
}