Add preprocessor-macros for compile-time htonl calculation (and use them throughout the stack where applicable)

This commit is contained in:
goldsimon
2010-05-16 15:57:42 +00:00
parent 81df8bdabd
commit dae247809b
15 changed files with 62 additions and 57 deletions

View File

@@ -325,7 +325,7 @@ ChapMS_NT( char *rchallenge,
MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */
if (low_byte_first == -1) {
low_byte_first = (htons((unsigned short int)1) != 1);
low_byte_first = (PP_HTONS((unsigned short int)1) != 1);
}
if (low_byte_first == 0) {
/* @todo: arg type - u_long* or u_int* ? */

View File

@@ -439,7 +439,7 @@ pppInit(void)
magicInit();
subnetMask = htonl(0xffffff00);
subnetMask = PP_HTONL(0xffffff00);
for (i = 0; i < NUM_PPP; i++) {
/* Initialize each protocol to the standard option set. */

View File

@@ -958,7 +958,7 @@ pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest)
LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len);
ethhdr = (struct eth_hdr *)pb->payload;
ethhdr->type = htons(ETHTYPE_PPPOEDISC);
ethhdr->type = PP_HTONS(ETHTYPE_PPPOEDISC);
MEMCPY(ethhdr->dest.addr, dest, sizeof(ethhdr->dest.addr));
MEMCPY(ethhdr->src.addr, ((struct eth_addr *)outgoing_if->hwaddr)->addr, sizeof(ethhdr->src.addr));

View File

@@ -160,7 +160,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb)
* `compressible' (i.e., ACK isn't set or some other control bit is
* set).
*/
if ((IPH_OFFSET(ip) & htons(0x3fff)) || pb->tot_len < 40) {
if ((IPH_OFFSET(ip) & PP_HTONS(0x3fff)) || pb->tot_len < 40) {
return (TYPE_IP);
}
th = (struct tcp_hdr *)&((long *)ip)[hlen];