aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/packet.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/packet.c
parent68af8e7a084317191effa9b257483a50d994b11c (diff)
downloadbusybox-w32-6884f665bd7bc101f56ff9047afaffbc06dc99e2.tar.gz
busybox-w32-6884f665bd7bc101f56ff9047afaffbc06dc99e2.tar.bz2
busybox-w32-6884f665bd7bc101f56ff9047afaffbc06dc99e2.zip
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/packet.c')
-rw-r--r--networking/udhcp/packet.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 41cd32135..0abe851a4 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -57,7 +57,7 @@ int udhcp_get_packet(struct dhcpMessage *packet, int fd)
57 return -1; 57 return -1;
58 } 58 }
59 59
60 if (ntohl(packet->cookie) != DHCP_MAGIC) { 60 if (packet->cookie != htonl(DHCP_MAGIC)) {
61 bb_error_msg("received bogus message, ignoring"); 61 bb_error_msg("received bogus message, ignoring");
62 return -2; 62 return -2;
63 } 63 }
@@ -123,7 +123,6 @@ uint16_t udhcp_checksum(void *addr, int count)
123 123
124 124
125/* Construct a ip/udp header for a packet, and specify the source and dest hardware address */ 125/* Construct a ip/udp header for a packet, and specify the source and dest hardware address */
126void BUG_sizeof_struct_udp_dhcp_packet_must_be_576(void);
127int udhcp_raw_packet(struct dhcpMessage *payload, 126int udhcp_raw_packet(struct dhcpMessage *payload,
128 uint32_t source_ip, int source_port, 127 uint32_t source_ip, int source_port,
129 uint32_t dest_ip, int dest_port, const uint8_t *dest_arp, int ifindex) 128 uint32_t dest_ip, int dest_port, const uint8_t *dest_arp, int ifindex)
@@ -169,9 +168,6 @@ int udhcp_raw_packet(struct dhcpMessage *payload,
169 packet.ip.ttl = IPDEFTTL; 168 packet.ip.ttl = IPDEFTTL;
170 packet.ip.check = udhcp_checksum(&(packet.ip), sizeof(packet.ip)); 169 packet.ip.check = udhcp_checksum(&(packet.ip), sizeof(packet.ip));
171 170
172 if (sizeof(struct udp_dhcp_packet) != 576)
173 BUG_sizeof_struct_udp_dhcp_packet_must_be_576();
174
175 result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, 171 result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0,
176 (struct sockaddr *) &dest, sizeof(dest)); 172 (struct sockaddr *) &dest, sizeof(dest));
177 if (result <= 0) { 173 if (result <= 0) {