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
This commit is contained in:
Denis Vlasenko
2007-11-23 00:08:54 +00:00
parent 68af8e7a08
commit 6884f665bd
5 changed files with 23 additions and 19 deletions

View File

@@ -38,12 +38,18 @@ struct dhcpMessage {
uint8_t file[128];
uint32_t cookie;
uint8_t options[308]; /* 312 - cookie */
};
} ATTRIBUTE_PACKED;
struct udp_dhcp_packet {
struct iphdr ip;
struct udphdr udp;
struct dhcpMessage data;
} ATTRIBUTE_PACKED;
/* Let's see whether compiler understood us right */
struct BUG_bad_sizeof_struct_udp_dhcp_packet {
char BUG_bad_sizeof_struct_udp_dhcp_packet
[sizeof(struct udp_dhcp_packet) != 576 ? -1 : 1];
};
void udhcp_init_header(struct dhcpMessage *packet, char type);