diff --git a/doc/rawapi.txt b/doc/rawapi.txt index 763a0efc..9a5c3e00 100644 --- a/doc/rawapi.txt +++ b/doc/rawapi.txt @@ -456,9 +456,8 @@ introduction to this subject. Other significant improvements can be made by supplying assembly or inline replacements for htons() and htonl() if you're using a little-endian architecture. -#define LWIP_PLATFORM_BYTESWAP 1 -#define LWIP_PLATFORM_HTONS(x) -#define LWIP_PLATFORM_HTONL(x) +#define lwip_htons(x) +#define lwip_htonl(x) Check your network interface driver if it reads at a higher speed than the maximum wire-speed. If the diff --git a/src/api/netdb.c b/src/api/netdb.c index 670f6b97..ef0c79b1 100644 --- a/src/api/netdb.c +++ b/src/api/netdb.c @@ -375,7 +375,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname, inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr)); sa6->sin6_family = AF_INET6; sa6->sin6_len = sizeof(struct sockaddr_in6); - sa6->sin6_port = htons((u16_t)port_nr); + sa6->sin6_port = lwip_htons((u16_t)port_nr); ai->ai_family = AF_INET6; #endif /* LWIP_IPV6 */ } else { @@ -385,7 +385,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname, inet_addr_from_ipaddr(&sa4->sin_addr, ip_2_ip4(&addr)); sa4->sin_family = AF_INET; sa4->sin_len = sizeof(struct sockaddr_in); - sa4->sin_port = htons((u16_t)port_nr); + sa4->sin_port = lwip_htons((u16_t)port_nr); ai->ai_family = AF_INET; #endif /* LWIP_IPV4 */ } diff --git a/src/api/sockets.c b/src/api/sockets.c index dbf91399..87878fb4 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -81,25 +81,25 @@ #define IP4ADDR_PORT_TO_SOCKADDR(sin, ipaddr, port) do { \ (sin)->sin_len = sizeof(struct sockaddr_in); \ (sin)->sin_family = AF_INET; \ - (sin)->sin_port = htons((port)); \ + (sin)->sin_port = lwip_htons((port)); \ inet_addr_from_ipaddr(&(sin)->sin_addr, ipaddr); \ memset((sin)->sin_zero, 0, SIN_ZERO_LEN); }while(0) #define SOCKADDR4_TO_IP4ADDR_PORT(sin, ipaddr, port) do { \ inet_addr_to_ipaddr(ip_2_ip4(ipaddr), &((sin)->sin_addr)); \ - (port) = ntohs((sin)->sin_port); }while(0) + (port) = lwip_ntohs((sin)->sin_port); }while(0) #endif /* LWIP_IPV4 */ #if LWIP_IPV6 #define IP6ADDR_PORT_TO_SOCKADDR(sin6, ipaddr, port) do { \ (sin6)->sin6_len = sizeof(struct sockaddr_in6); \ (sin6)->sin6_family = AF_INET6; \ - (sin6)->sin6_port = htons((port)); \ + (sin6)->sin6_port = lwip_htons((port)); \ (sin6)->sin6_flowinfo = 0; \ inet6_addr_from_ip6addr(&(sin6)->sin6_addr, ipaddr); \ (sin6)->sin6_scope_id = 0; }while(0) #define SOCKADDR6_TO_IP6ADDR_PORT(sin6, ipaddr, port) do { \ inet6_addr_to_ip6addr(ip_2_ip6(ipaddr), &((sin6)->sin6_addr)); \ - (port) = ntohs((sin6)->sin6_port); }while(0) + (port) = lwip_ntohs((sin6)->sin6_port); }while(0) #endif /* LWIP_IPV6 */ #if LWIP_IPV4 && LWIP_IPV6 diff --git a/src/apps/lwiperf/lwiperf.c b/src/apps/lwiperf/lwiperf.c index 255e282a..1996cd1a 100644 --- a/src/apps/lwiperf/lwiperf.c +++ b/src/apps/lwiperf/lwiperf.c @@ -262,7 +262,7 @@ lwiperf_tcp_client_send_more(lwiperf_state_tcp_t* conn) /* this session is time-limited */ u32_t now = sys_now(); u32_t diff_ms = now - conn->time_started; - u32_t time = (u32_t)-(s32_t)htonl(conn->settings.amount); + u32_t time = (u32_t)-(s32_t)lwip_htonl(conn->settings.amount); u32_t time_ms = time * 10; if (diff_ms >= time_ms) { /* time specified by the client is over -> close the connection */ @@ -271,7 +271,7 @@ lwiperf_tcp_client_send_more(lwiperf_state_tcp_t* conn) } } else { /* this session is byte-limited */ - u32_t amount_bytes = htonl(conn->settings.amount); + u32_t amount_bytes = lwip_htonl(conn->settings.amount); /* @todo: this can send up to 1*MSS more than requested... */ if (amount_bytes >= conn->bytes_transferred) { /* all requested bytes transferred -> close the connection */ @@ -390,7 +390,7 @@ lwiperf_tx_start(lwiperf_state_tcp_t* conn) tcp_err(newpcb, lwiperf_tcp_err); ip_addr_copy(remote_addr, conn->conn_pcb->remote_ip); - remote_port = (u16_t)htonl(client_conn->settings.remote_port); + remote_port = (u16_t)lwip_htonl(client_conn->settings.remote_port); err = tcp_connect(newpcb, &remote_addr, remote_port, lwiperf_tcp_client_connected); if (err != ERR_OK) { diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index d9ef9a3e..49bcab5b 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -820,7 +820,7 @@ mdns_write_domain(struct mdns_outpacket *outpkt, struct mdns_domain *domain) } if (jump_offset) { /* Write jump */ - jump = htons(DOMAIN_JUMP | jump_offset); + jump = lwip_htons(DOMAIN_JUMP | jump_offset); res = pbuf_take_at(outpkt->pbuf, &jump, DOMAIN_JUMP_SIZE, outpkt->write_offset); if (res != ERR_OK) { return res; @@ -872,7 +872,7 @@ mdns_add_question(struct mdns_outpacket *outpkt, struct mdns_domain *domain, u16 } /* Write type */ - field16 = htons(type); + field16 = lwip_htons(type); res = pbuf_take_at(outpkt->pbuf, &field16, sizeof(field16), outpkt->write_offset); if (res != ERR_OK) { return res; @@ -883,7 +883,7 @@ mdns_add_question(struct mdns_outpacket *outpkt, struct mdns_domain *domain, u16 if (unicast) { klass |= 0x8000; } - field16 = htons(klass); + field16 = lwip_htons(klass); res = pbuf_take_at(outpkt->pbuf, &field16, sizeof(field16), outpkt->write_offset); if (res != ERR_OK) { return res; @@ -947,7 +947,7 @@ mdns_add_answer(struct mdns_outpacket *reply, struct mdns_domain *domain, u16_t mdns_add_question(reply, domain, type, klass, cache_flush); /* Write TTL */ - field32 = htonl(ttl); + field32 = lwip_htonl(ttl); res = pbuf_take_at(reply->pbuf, &field32, sizeof(field32), reply->write_offset); if (res != ERR_OK) { return res; @@ -977,7 +977,7 @@ mdns_add_answer(struct mdns_outpacket *reply, struct mdns_domain *domain, u16_t } /* Write rd_length after when we know the answer size */ - field16 = htons(reply->write_offset - answer_offset); + field16 = lwip_htons(reply->write_offset - answer_offset); res = pbuf_take_at(reply->pbuf, &field16, sizeof(field16), rdlen_offset); return res; @@ -1005,14 +1005,14 @@ mdns_read_rr_info(struct mdns_packet *pkt, struct mdns_rr_info *info) return ERR_VAL; } pkt->parse_offset += copied; - info->type = ntohs(field16); + info->type = lwip_ntohs(field16); copied = pbuf_copy_partial(pkt->pbuf, &field16, sizeof(field16), pkt->parse_offset); if (copied != sizeof(field16)) { return ERR_VAL; } pkt->parse_offset += copied; - info->klass = ntohs(field16); + info->klass = lwip_ntohs(field16); return ERR_OK; } @@ -1094,14 +1094,14 @@ mdns_read_answer(struct mdns_packet *pkt, struct mdns_answer *answer) return ERR_VAL; } pkt->parse_offset += copied; - answer->ttl = ntohl(ttl); + answer->ttl = lwip_ntohl(ttl); copied = pbuf_copy_partial(pkt->pbuf, &field16, sizeof(field16), pkt->parse_offset); if (copied != sizeof(field16)) { return ERR_VAL; } pkt->parse_offset += copied; - answer->rd_length = ntohs(field16); + answer->rd_length = lwip_ntohs(field16); answer->rd_offset = pkt->parse_offset; pkt->parse_offset += answer->rd_length; @@ -1194,9 +1194,9 @@ mdns_add_srv_answer(struct mdns_outpacket *reply, u16_t cache_flush, struct mdns */ srvhost.skip_compression = 1; } - srvdata[0] = htons(SRV_PRIORITY); - srvdata[1] = htons(SRV_WEIGHT); - srvdata[2] = htons(service->port); + srvdata[0] = lwip_htons(SRV_PRIORITY); + srvdata[1] = lwip_htons(SRV_WEIGHT); + srvdata[2] = lwip_htons(service->port); LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Responding with SRV record\n")); return mdns_add_answer(reply, &service_instance, DNS_RRTYPE_SRV, DNS_RRCLASS_IN, cache_flush, service->dns_ttl, (const u8_t *) &srvdata, sizeof(srvdata), &srvhost); @@ -1411,11 +1411,11 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) /* Write header */ memset(&hdr, 0, sizeof(hdr)); hdr.flags1 = DNS_FLAG1_RESPONSE | DNS_FLAG1_AUTHORATIVE; - hdr.numanswers = htons(outpkt->answers); - hdr.numextrarr = htons(outpkt->additional); + hdr.numanswers = lwip_htons(outpkt->answers); + hdr.numextrarr = lwip_htons(outpkt->additional); if (outpkt->legacy_query) { - hdr.numquestions = htons(1); - hdr.id = htons(outpkt->tx_id); + hdr.numquestions = lwip_htons(1); + hdr.id = lwip_htons(outpkt->tx_id); } pbuf_take(outpkt->pbuf, &hdr, sizeof(hdr)); @@ -1657,19 +1657,19 @@ mdns_handle_question(struct mdns_packet *pkt) do { /* Check priority field */ len = pbuf_copy_partial(pkt->pbuf, &field16, sizeof(field16), read_pos); - if (len != sizeof(field16) || ntohs(field16) != SRV_PRIORITY) { + if (len != sizeof(field16) || lwip_ntohs(field16) != SRV_PRIORITY) { break; } read_pos += len; /* Check weight field */ len = pbuf_copy_partial(pkt->pbuf, &field16, sizeof(field16), read_pos); - if (len != sizeof(field16) || ntohs(field16) != SRV_WEIGHT) { + if (len != sizeof(field16) || lwip_ntohs(field16) != SRV_WEIGHT) { break; } read_pos += len; /* Check port field */ len = pbuf_copy_partial(pkt->pbuf, &field16, sizeof(field16), read_pos); - if (len != sizeof(field16) || ntohs(field16) != service->port) { + if (len != sizeof(field16) || lwip_ntohs(field16) != service->port) { break; } read_pos += len; @@ -1780,9 +1780,9 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, packet.netif = recv_netif; packet.pbuf = p; packet.parse_offset = offset; - packet.tx_id = ntohs(hdr.id); - packet.questions = packet.questions_left = ntohs(hdr.numquestions); - packet.answers = packet.answers_left = ntohs(hdr.numanswers) + ntohs(hdr.numauthrr) + ntohs(hdr.numextrarr); + packet.tx_id = lwip_ntohs(hdr.id); + packet.questions = packet.questions_left = lwip_ntohs(hdr.numquestions); + packet.answers = packet.answers_left = lwip_ntohs(hdr.numanswers) + lwip_ntohs(hdr.numauthrr) + lwip_ntohs(hdr.numextrarr); #if LWIP_IPV6 if (IP_IS_V6(ip_current_dest_addr())) { diff --git a/src/apps/sntp/sntp.c b/src/apps/sntp/sntp.c index 9f8a1dc8..fb952111 100644 --- a/src/apps/sntp/sntp.c +++ b/src/apps/sntp/sntp.c @@ -212,13 +212,13 @@ sntp_process(u32_t *receive_timestamp) /* convert SNTP time (1900-based) to unix GMT time (1970-based) * if MSB is 0, SNTP time is 2036-based! */ - u32_t rx_secs = ntohl(receive_timestamp[0]); + u32_t rx_secs = lwip_ntohl(receive_timestamp[0]); int is_1900_based = ((rx_secs & 0x80000000) != 0); u32_t t = is_1900_based ? (rx_secs - DIFF_SEC_1900_1970) : (rx_secs + DIFF_SEC_1970_2036); time_t tim = t; #if SNTP_CALC_TIME_US - u32_t us = ntohl(receive_timestamp[1]) / 4295; + u32_t us = lwip_ntohl(receive_timestamp[1]) / 4295; SNTP_SET_SYSTEM_TIME_US(t, us); /* display local time from GMT time */ LWIP_DEBUGF(SNTP_DEBUG_TRACE, ("sntp_process: %s, %"U32_F" us", ctime(&tim), us)); @@ -247,10 +247,10 @@ sntp_initialize_request(struct sntp_msg *req) u32_t sntp_time_sec, sntp_time_us; /* fill in transmit timestamp and save it in 'sntp_last_timestamp_sent' */ SNTP_GET_SYSTEM_TIME(sntp_time_sec, sntp_time_us); - sntp_last_timestamp_sent[0] = htonl(sntp_time_sec + DIFF_SEC_1900_1970); + sntp_last_timestamp_sent[0] = lwip_htonl(sntp_time_sec + DIFF_SEC_1900_1970); req->transmit_timestamp[0] = sntp_last_timestamp_sent[0]; /* we send/save us instead of fraction to be faster... */ - sntp_last_timestamp_sent[1] = htonl(sntp_time_us); + sntp_last_timestamp_sent[1] = lwip_htonl(sntp_time_us); req->transmit_timestamp[1] = sntp_last_timestamp_sent[1]; } #endif /* SNTP_CHECK_RESPONSE >= 2 */ diff --git a/src/apps/tftp/tftp_server.c b/src/apps/tftp/tftp_server.c index b96031c4..243b0924 100644 --- a/src/apps/tftp/tftp_server.c +++ b/src/apps/tftp/tftp_server.c @@ -128,7 +128,7 @@ send_error(const ip_addr_t *addr, u16_t port, enum tftp_error code, const char * payload = (u16_t*) p->payload; payload[0] = PP_HTONS(TFTP_ERROR); - payload[1] = htons(code); + payload[1] = lwip_htons(code); MEMCPY(&payload[2], str, str_length + 1); udp_sendto(tftp_state.upcb, p, addr, port); @@ -148,7 +148,7 @@ send_ack(u16_t blknum) payload = (u16_t*) p->payload; payload[0] = PP_HTONS(TFTP_ACK); - payload[1] = htons(blknum); + payload[1] = lwip_htons(blknum); udp_sendto(tftp_state.upcb, p, &tftp_state.addr, tftp_state.port); pbuf_free(p); } @@ -187,7 +187,7 @@ send_data(void) payload = (u16_t *) tftp_state.last_data->payload; payload[0] = PP_HTONS(TFTP_DATA); - payload[1] = htons(tftp_state.blknum); + payload[1] = lwip_htons(tftp_state.blknum); ret = tftp_state.ctx->read(tftp_state.handle, &payload[2], TFTP_MAX_PAYLOAD_SIZE); if (ret < 0) { @@ -295,7 +295,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 break; } - blknum = ntohs(sbuf[1]); + blknum = lwip_ntohs(sbuf[1]); pbuf_header(p, -TFTP_HEADER_LENGTH); ret = tftp_state.ctx->write(tftp_state.handle, p); @@ -327,7 +327,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 break; } - blknum = ntohs(sbuf[1]); + blknum = lwip_ntohs(sbuf[1]); if (blknum != tftp_state.blknum) { send_error(addr, port, TFTP_ERROR_UNKNOWN_TRFR_ID, "Wrong block number"); break; diff --git a/src/core/def.c b/src/core/def.c index 68137ed6..88f5724d 100644 --- a/src/core/def.c +++ b/src/core/def.c @@ -7,11 +7,10 @@ * Byte swapping is the second thing you would want to optimize. You will * need to port it to your architecture and in your cc.h: * - * \#define LWIP_PLATFORM_BYTESWAP 1 - * \#define LWIP_PLATFORM_HTONS(x) your_htons - * \#define LWIP_PLATFORM_HTONL(x) your_htonl + * \#define lwip_htons(x) your_htons + * \#define lwip_htonl(x) your_htonl * - * Note ntohs() and ntohl() are merely references to the htonx counterparts. + * Note lwip_ntohs() and lwip_ntohl() are merely references to the htonx counterparts. */ /* @@ -51,8 +50,9 @@ #include -#if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) +#if BYTE_ORDER == LITTLE_ENDIAN +#if !defined(lwip_htons) /** * Convert an u16_t from host- to network byte order. * @@ -64,19 +64,9 @@ lwip_htons(u16_t n) { return (u16_t)PP_HTONS(n); } +#endif /* lwip_htons */ -/** - * Convert an u16_t from network- to host byte order. - * - * @param n u16_t in network byte order - * @return n in host byte order - */ -u16_t -lwip_ntohs(u16_t n) -{ - return lwip_htons(n); -} - +#if !defined(lwip_htonl) /** * Convert an u32_t from host- to network byte order. * @@ -88,20 +78,9 @@ lwip_htonl(u32_t n) { return (u32_t)PP_HTONL(n); } +#endif /* lwip_htonl */ -/** - * Convert an u32_t from network- to host byte order. - * - * @param n u32_t in network byte order - * @return n in host byte order - */ -u32_t -lwip_ntohl(u32_t n) -{ - return lwip_htonl(n); -} - -#endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ #ifndef lwip_strnstr /** Like strstr but does not need 'buffer' to be NULL-terminated */ diff --git a/src/core/dns.c b/src/core/dns.c index 22368f04..f1b0f436 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -680,7 +680,7 @@ dns_send(u8_t idx) if (p != NULL) { /* fill dns header */ memset(&hdr, 0, SIZEOF_DNS_HDR); - hdr.id = htons(entry->txid); + hdr.id = lwip_htons(entry->txid); hdr.flags1 = DNS_FLAG1_RD; hdr.numquestions = PP_HTONS(1); pbuf_take(p, &hdr, SIZEOF_DNS_HDR); @@ -1041,7 +1041,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, /* copy dns payload inside static buffer for processing */ if (pbuf_copy_partial(p, &hdr, SIZEOF_DNS_HDR, 0) == SIZEOF_DNS_HDR) { /* Match the ID in the DNS header with the name table. */ - txid = htons(hdr.id); + txid = lwip_htons(hdr.id); for (i = 0; i < DNS_TABLE_SIZE; i++) { const struct dns_table_entry *entry = &dns_table[i]; if ((entry->state == DNS_STATE_ASKING) && @@ -1049,8 +1049,8 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, /* We only care about the question(s) and the answers. The authrr and the extrarr are simply discarded. */ - nquestions = htons(hdr.numquestions); - nanswers = htons(hdr.numanswers); + nquestions = lwip_htons(hdr.numquestions); + nanswers = lwip_htons(hdr.numanswers); /* Check for correct response. */ if ((hdr.flags1 & DNS_FLAG1_RESPONSE) == 0) { @@ -1121,7 +1121,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, ip_addr_copy_from_ip4(dns_table[i].ipaddr, ip4addr); pbuf_free(p); /* handle correct response */ - dns_correct_response(i, ntohl(ans.ttl)); + dns_correct_response(i, lwip_ntohl(ans.ttl)); return; } } @@ -1140,17 +1140,17 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, ip_addr_copy_from_ip6(dns_table[i].ipaddr, ip6addr); pbuf_free(p); /* handle correct response */ - dns_correct_response(i, ntohl(ans.ttl)); + dns_correct_response(i, lwip_ntohl(ans.ttl)); return; } } #endif /* LWIP_IPV6 */ } /* skip this answer */ - if ((int)(res_idx + htons(ans.len)) > 0xFFFF) { + if ((int)(res_idx + lwip_htons(ans.len)) > 0xFFFF) { goto memerr; /* ignore this packet */ } - res_idx += htons(ans.len); + res_idx += lwip_htons(ans.len); --nanswers; } #if LWIP_IPV4 && LWIP_IPV6 diff --git a/src/core/inet_chksum.c b/src/core/inet_chksum.c index 6ccf8391..80289528 100644 --- a/src/core/inet_chksum.c +++ b/src/core/inet_chksum.c @@ -108,10 +108,10 @@ lwip_standard_chksum(const void *dataptr, int len) if ((acc & 0xffff0000UL) != 0) { acc = (acc >> 16) + (acc & 0x0000ffffUL); } - /* This maybe a little confusing: reorder sum using htons() - instead of ntohs() since it has a little less call overhead. + /* This maybe a little confusing: reorder sum using lwip_htons() + instead of lwip_ntohs() since it has a little less call overhead. The caller must invert bits for Internet sum ! */ - return htons((u16_t)acc); + return lwip_htons((u16_t)acc); } #endif @@ -283,8 +283,8 @@ inet_cksum_pseudo_base(struct pbuf *p, u8_t proto, u16_t proto_len, u32_t acc) acc = SWAP_BYTES_IN_WORD(acc); } - acc += (u32_t)htons((u16_t)proto); - acc += (u32_t)htons(proto_len); + acc += (u32_t)lwip_htons((u16_t)proto); + acc += (u32_t)lwip_htons(proto_len); /* Fold 32-bit sum to 16 bits calling this twice is probably faster than if statements... */ @@ -429,8 +429,8 @@ inet_cksum_pseudo_partial_base(struct pbuf *p, u8_t proto, u16_t proto_len, acc = SWAP_BYTES_IN_WORD(acc); } - acc += (u32_t)htons((u16_t)proto); - acc += (u32_t)htons(proto_len); + acc += (u32_t)lwip_htons((u16_t)proto); + acc += (u32_t)lwip_htons(proto_len); /* Fold 32-bit sum to 16 bits calling this twice is probably faster than if statements... */ diff --git a/src/core/ipv4/autoip.c b/src/core/ipv4/autoip.c index ad494feb..86a4aed3 100644 --- a/src/core/ipv4/autoip.c +++ b/src/core/ipv4/autoip.c @@ -87,7 +87,7 @@ */ #ifndef LWIP_AUTOIP_CREATE_SEED_ADDR #define LWIP_AUTOIP_CREATE_SEED_ADDR(netif) \ - htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \ + lwip_htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \ ((u32_t)((u8_t)(netif->hwaddr[5]))) << 8))) #endif /* LWIP_AUTOIP_CREATE_SEED_ADDR */ @@ -176,7 +176,7 @@ autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr) * compliant to RFC 3927 Section 2.1 * We have 254 * 256 possibilities */ - u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif)); + u32_t addr = lwip_ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif)); addr += autoip->tried_llipaddr; addr = AUTOIP_NET | (addr & 0xffff); /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */ @@ -189,7 +189,7 @@ autoip_create_addr(struct netif *netif, ip4_addr_t *ipaddr) } LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) && (addr <= AUTOIP_RANGE_END)); - ip4_addr_set_u32(ipaddr, htonl(addr)); + ip4_addr_set_u32(ipaddr, lwip_htonl(addr)); LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index 62a32c52..ecf19bdb 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -311,7 +311,7 @@ dhcp_handle_offer(struct netif *netif) (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* obtain the server address */ if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) { - ip_addr_set_ip4_u32(&dhcp->server_ip_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); + ip_addr_set_ip4_u32(&dhcp->server_ip_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr)))); /* remember offered address */ @@ -353,10 +353,10 @@ dhcp_select(struct netif *netif) /* MUST request the offered IP address */ dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); + dhcp_option_long(dhcp, lwip_ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr)))); + dhcp_option_long(dhcp, lwip_ntohl(ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr)))); dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, LWIP_ARRAYSIZE(dhcp_discover_request_options)); for (i = 0; i < LWIP_ARRAYSIZE(dhcp_discover_request_options); i++) { @@ -621,7 +621,7 @@ dhcp_handle_ack(struct netif *netif) /* subnet mask given? */ if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SUBNET_MASK)) { /* remember given subnet mask */ - ip4_addr_set_u32(&dhcp->offered_sn_mask, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SUBNET_MASK))); + ip4_addr_set_u32(&dhcp->offered_sn_mask, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SUBNET_MASK))); dhcp->subnet_mask_given = 1; } else { dhcp->subnet_mask_given = 0; @@ -629,13 +629,13 @@ dhcp_handle_ack(struct netif *netif) /* gateway router */ if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_ROUTER)) { - ip4_addr_set_u32(&dhcp->offered_gw_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_ROUTER))); + ip4_addr_set_u32(&dhcp->offered_gw_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_ROUTER))); } #if LWIP_DHCP_GET_NTP_SRV /* NTP servers */ for (n = 0; (n < LWIP_DHCP_MAX_NTP_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_NTP_SERVER + n); n++) { - ip4_addr_set_u32(&ntp_server_addrs[n], htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_NTP_SERVER + n))); + ip4_addr_set_u32(&ntp_server_addrs[n], lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_NTP_SERVER + n))); } dhcp_set_ntp_servers(n, ntp_server_addrs); #endif /* LWIP_DHCP_GET_NTP_SRV */ @@ -644,7 +644,7 @@ dhcp_handle_ack(struct netif *netif) /* DNS servers */ for (n = 0; (n < DNS_MAX_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n); n++) { ip_addr_t dns_addr; - ip_addr_set_ip4_u32(&dns_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n))); + ip_addr_set_ip4_u32(&dns_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n))); dns_setserver(n, &dns_addr); } #endif /* LWIP_DNS */ @@ -913,7 +913,7 @@ dhcp_decline(struct netif *netif) result = dhcp_create_msg(netif, dhcp, DHCP_DECLINE); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); + dhcp_option_long(dhcp, lwip_ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); dhcp_option_trailer(dhcp); /* resize pbuf to reflect true size of options */ @@ -1228,7 +1228,7 @@ dhcp_reboot(struct netif *netif) dhcp_option_short(dhcp, 576); dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); + dhcp_option_long(dhcp, lwip_ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr))); dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, LWIP_ARRAYSIZE(dhcp_discover_request_options)); for (i = 0; i < LWIP_ARRAYSIZE(dhcp_discover_request_options); i++) { @@ -1300,7 +1300,7 @@ dhcp_release(struct netif *netif) result = dhcp_create_msg(netif, dhcp, DHCP_RELEASE); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); - dhcp_option_long(dhcp, ntohl(ip4_addr_get_u32(ip_2_ip4(&server_ip_addr)))); + dhcp_option_long(dhcp, lwip_ntohl(ip4_addr_get_u32(ip_2_ip4(&server_ip_addr)))); dhcp_option_trailer(dhcp); @@ -1579,13 +1579,13 @@ decode_next: /* decode more than one u32_t */ LWIP_ERROR("decode_len % 4 == 0", decode_len % 4 == 0, return ERR_VAL;); dhcp_got_option(dhcp, decode_idx); - dhcp_set_option_value(dhcp, decode_idx, htonl(value)); + dhcp_set_option_value(dhcp, decode_idx, lwip_htonl(value)); decode_len -= 4; val_offset += 4; decode_idx++; goto decode_next; } else if (decode_len == 4) { - value = ntohl(value); + value = lwip_ntohl(value); } else { LWIP_ERROR("invalid decode_len", decode_len == 1, return ERR_VAL;); value = ((u8_t*)&value)[0]; @@ -1704,9 +1704,9 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, } } /* match transaction ID against what we expected */ - if (ntohl(reply_msg->xid) != dhcp->xid) { + if (lwip_ntohl(reply_msg->xid) != dhcp->xid) { LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, - ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",ntohl(reply_msg->xid),dhcp->xid)); + ("transaction id mismatch reply_msg->xid(%"X32_F")!=dhcp->xid(%"X32_F")\n",lwip_ntohl(reply_msg->xid),dhcp->xid)); goto free_pbuf_and_return; } /* option fields could be unfold? */ @@ -1835,7 +1835,7 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type) dhcp->msg_out->htype = DHCP_HTYPE_ETH; dhcp->msg_out->hlen = netif->hwaddr_len; dhcp->msg_out->hops = 0; - dhcp->msg_out->xid = htonl(dhcp->xid); + dhcp->msg_out->xid = lwip_htonl(dhcp->xid); dhcp->msg_out->secs = 0; /* we don't need the broadcast flag since we can receive unicast traffic before being fully configured! */ diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c index 2040f390..7b41dd94 100644 --- a/src/core/ipv4/etharp.c +++ b/src/core/ipv4/etharp.c @@ -701,7 +701,7 @@ etharp_input(struct pbuf *p, struct netif *netif) /* Re-use pbuf to send ARP reply. Since we are re-using an existing pbuf, we can't call etharp_raw since that would allocate a new pbuf. */ - hdr->opcode = htons(ARP_REPLY); + hdr->opcode = lwip_htons(ARP_REPLY); IPADDR2_COPY(&hdr->dipaddr, &hdr->sipaddr); IPADDR2_COPY(&hdr->sipaddr, netif_ip4_addr(netif)); @@ -750,7 +750,7 @@ etharp_input(struct pbuf *p, struct netif *netif) #endif /* (LWIP_DHCP && DHCP_DOES_ARP_CHECK) */ break; default: - LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode))); + LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: ARP unknown opcode type %"S16_F"\n", lwip_htons(hdr->opcode))); ETHARP_STATS_INC(etharp.err); break; } @@ -1144,7 +1144,7 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, hdr = (struct etharp_hdr *)p->payload; LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_raw: sending raw ARP packet.\n")); - hdr->opcode = htons(opcode); + hdr->opcode = lwip_htons(opcode); LWIP_ASSERT("netif->hwaddr_len must be the same as ETH_HWADDR_LEN for etharp!", (netif->hwaddr_len == ETH_HWADDR_LEN)); diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 1f1b3ac0..5ddd9ffe 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -228,7 +228,7 @@ ip4_route(const ip4_addr_t *dest) static int ip4_canforward(struct pbuf *p) { - u32_t addr = htonl(ip4_addr_get_u32(ip4_current_dest_addr())); + u32_t addr = lwip_htonl(ip4_addr_get_u32(ip4_current_dest_addr())); if (p->flags & PBUF_FLAG_LLBCAST) { /* don't route link-layer broadcasts */ @@ -405,7 +405,7 @@ ip4_input(struct pbuf *p, struct netif *inp) /* calculate IP header length in bytes */ iphdr_hlen *= 4; /* obtain ip length in bytes */ - iphdr_len = ntohs(IPH_LEN(iphdr)); + iphdr_len = lwip_ntohs(IPH_LEN(iphdr)); /* Trim pbuf. This is especially required for packets < 60 bytes. */ if (iphdr_len < p->tot_len) { @@ -545,7 +545,7 @@ ip4_input(struct pbuf *p, struct netif *inp) if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)iphdr + iphdr_hlen); LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip4_input: UDP packet to DHCP client port %"U16_F"\n", - ntohs(udphdr->dest))); + lwip_ntohs(udphdr->dest))); if (IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(udphdr->dest)) { LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip4_input: DHCP packet accepted.\n")); netif = inp; @@ -600,7 +600,7 @@ ip4_input(struct pbuf *p, struct netif *inp) if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) { #if IP_REASSEMBLY /* packet fragment reassembly code present? */ LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip4_reass()\n", - ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), (u16_t)!!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (u16_t)((ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8))); + lwip_ntohs(IPH_ID(iphdr)), p->tot_len, lwip_ntohs(IPH_LEN(iphdr)), (u16_t)!!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (u16_t)((lwip_ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8))); /* reassemble the packet*/ p = ip4_reass(p); /* packet not fully reassembled yet? */ @@ -611,7 +611,7 @@ ip4_input(struct pbuf *p, struct netif *inp) #else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */ pbuf_free(p); LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n", - ntohs(IPH_OFFSET(iphdr)))); + lwip_ntohs(IPH_OFFSET(iphdr)))); IP_STATS_INC(ip.opterr); IP_STATS_INC(ip.drop); /* unsupported protocol feature */ @@ -869,12 +869,12 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d #if CHECKSUM_GEN_IP_INLINE chk_sum += LWIP_MAKE_U16(tos, iphdr->_v_hl); #endif /* CHECKSUM_GEN_IP_INLINE */ - IPH_LEN_SET(iphdr, htons(p->tot_len)); + IPH_LEN_SET(iphdr, lwip_htons(p->tot_len)); #if CHECKSUM_GEN_IP_INLINE chk_sum += iphdr->_len; #endif /* CHECKSUM_GEN_IP_INLINE */ IPH_OFFSET_SET(iphdr, 0); - IPH_ID_SET(iphdr, htons(ip_id)); + IPH_ID_SET(iphdr, lwip_htons(ip_id)); #if CHECKSUM_GEN_IP_INLINE chk_sum += iphdr->_id; #endif /* CHECKSUM_GEN_IP_INLINE */ @@ -1041,19 +1041,19 @@ ip4_debug_print(struct pbuf *p) (u16_t)IPH_V(iphdr), (u16_t)IPH_HL(iphdr), (u16_t)IPH_TOS(iphdr), - ntohs(IPH_LEN(iphdr)))); + lwip_ntohs(IPH_LEN(iphdr)))); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" |%"U16_F"%"U16_F"%"U16_F"| %4"U16_F" | (id, flags, offset)\n", - ntohs(IPH_ID(iphdr)), - (u16_t)(ntohs(IPH_OFFSET(iphdr)) >> 15 & 1), - (u16_t)(ntohs(IPH_OFFSET(iphdr)) >> 14 & 1), - (u16_t)(ntohs(IPH_OFFSET(iphdr)) >> 13 & 1), - (u16_t)(ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK))); + lwip_ntohs(IPH_ID(iphdr)), + (u16_t)(lwip_ntohs(IPH_OFFSET(iphdr)) >> 15 & 1), + (u16_t)(lwip_ntohs(IPH_OFFSET(iphdr)) >> 14 & 1), + (u16_t)(lwip_ntohs(IPH_OFFSET(iphdr)) >> 13 & 1), + (u16_t)(lwip_ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK))); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%04"X16_F" | (ttl, proto, chksum)\n", (u16_t)IPH_TTL(iphdr), (u16_t)IPH_PROTO(iphdr), - ntohs(IPH_CHKSUM(iphdr)))); + lwip_ntohs(IPH_CHKSUM(iphdr)))); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (src)\n", ip4_addr1_16(&iphdr->src), diff --git a/src/core/ipv4/ip4_addr.c b/src/core/ipv4/ip4_addr.c index d0a81072..eb812afb 100644 --- a/src/core/ipv4/ip4_addr.c +++ b/src/core/ipv4/ip4_addr.c @@ -260,7 +260,7 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr) break; } if (addr) { - ip4_addr_set_u32(addr, htonl(val)); + ip4_addr_set_u32(addr, lwip_htonl(val)); } return 1; } diff --git a/src/core/ipv4/ip4_frag.c b/src/core/ipv4/ip4_frag.c index 8f65b736..dc4c3d45 100644 --- a/src/core/ipv4/ip4_frag.c +++ b/src/core/ipv4/ip4_frag.c @@ -346,8 +346,8 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct /* Extract length and fragment offset from current fragment */ fraghdr = (struct ip_hdr*)new_p->payload; - len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; - offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; + len = lwip_ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; + offset = (lwip_ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; /* overwrite the fragment's ip header from the pbuf with our helper struct, * and setup the embedded helper structure. */ @@ -500,8 +500,8 @@ ip4_reass(struct pbuf *p) goto nullreturn; } - offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; - len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; + offset = (lwip_ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; + len = lwip_ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; /* Check if we are allowed to enqueue more datagrams. */ clen = pbuf_clen(p); @@ -529,7 +529,7 @@ ip4_reass(struct pbuf *p) fragment into the buffer. */ if (IP_ADDRESSES_AND_ID_MATCH(&ipr->iphdr, fraghdr)) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: matching previous fragment ID=%"X16_F"\n", - ntohs(IPH_ID(fraghdr)))); + lwip_ntohs(IPH_ID(fraghdr)))); IPFRAG_STATS_INC(ip_frag.cachehit); break; } @@ -543,8 +543,8 @@ ip4_reass(struct pbuf *p) goto nullreturn; } } else { - if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && - ((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { + if (((lwip_ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && + ((lwip_ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { /* ipr->iphdr is not the header from the first fragment, but fraghdr is * -> copy fraghdr into ipr->iphdr since we want to have the header * of the first fragment (for ICMP time exceeded and later, for copying @@ -581,7 +581,7 @@ ip4_reass(struct pbuf *p) /* copy the original ip header back to the first pbuf */ fraghdr = (struct ip_hdr*)(ipr->p->payload); SMEMCPY(fraghdr, &ipr->iphdr, IP_HLEN); - IPH_LEN_SET(fraghdr, htons(ipr->datagram_len)); + IPH_LEN_SET(fraghdr, lwip_htons(ipr->datagram_len)); IPH_OFFSET_SET(fraghdr, 0); IPH_CHKSUM_SET(fraghdr, 0); /* @todo: do we need to set/calculate the correct checksum? */ @@ -706,7 +706,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest) iphdr = original_iphdr; /* Save original offset */ - tmp = ntohs(IPH_OFFSET(iphdr)); + tmp = lwip_ntohs(IPH_OFFSET(iphdr)); ofo = tmp & IP_OFFMASK; omf = tmp & IP_MF; @@ -799,8 +799,8 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest) #endif /* LWIP_NETIF_TX_SINGLE_PBUF */ /* Correct header */ - IPH_OFFSET_SET(iphdr, htons(tmp)); - IPH_LEN_SET(iphdr, htons(cop + IP_HLEN)); + IPH_OFFSET_SET(iphdr, lwip_htons(tmp)); + IPH_LEN_SET(iphdr, lwip_htons(cop + IP_HLEN)); IPH_CHKSUM_SET(iphdr, 0); #if CHECKSUM_GEN_IP IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_IP) { diff --git a/src/core/ipv6/ip6_addr.c b/src/core/ipv6/ip6_addr.c index 1792f62e..964291ee 100644 --- a/src/core/ipv6/ip6_addr.c +++ b/src/core/ipv6/ip6_addr.c @@ -152,7 +152,7 @@ ip6addr_aton(const char *cp, ip6_addr_t *addr) /* convert to network byte order. */ if (addr) { for (addr_index = 0; addr_index < 4; addr_index++) { - addr->addr[addr_index] = htonl(addr->addr[addr_index]); + addr->addr[addr_index] = lwip_htonl(addr->addr[addr_index]); } } @@ -199,7 +199,7 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen) for (current_block_index = 0; current_block_index < 8; current_block_index++) { /* get the current 16-bit block */ - current_block_value = htonl(addr->addr[current_block_index >> 1]); + current_block_value = lwip_htonl(addr->addr[current_block_index >> 1]); if ((current_block_index & 0x1) == 0) { current_block_value = current_block_value >> 16; } @@ -218,7 +218,7 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen) if (empty_block_flag == 0) { /* generate empty block "::", but only if more than one contiguous zero block, * according to current formatting suggestions RFC 5952. */ - next_block_value = htonl(addr->addr[(current_block_index + 1) >> 1]); + next_block_value = lwip_htonl(addr->addr[(current_block_index + 1) >> 1]); if ((current_block_index & 0x1) == 0x01) { next_block_value = next_block_value >> 16; } diff --git a/src/core/ipv6/ip6_frag.c b/src/core/ipv6/ip6_frag.c index a7e88e4f..1f746732 100644 --- a/src/core/ipv6/ip6_frag.c +++ b/src/core/ipv6/ip6_frag.c @@ -279,12 +279,12 @@ ip6_reass(struct pbuf *p) clen = pbuf_clen(p); - offset = ntohs(frag_hdr->_fragment_offset); + offset = lwip_ntohs(frag_hdr->_fragment_offset); /* Calculate fragment length from IPv6 payload length. * Adjust for headers before Fragment Header. * And finally adjust by Fragment Header length. */ - len = ntohs(ip6_current_header()->_plen); + len = lwip_ntohs(ip6_current_header()->_plen); len -= (u16_t)(((u8_t*)p->payload - (const u8_t*)ip6_current_header()) - IP6_HLEN); len -= IP6_FRAG_HLEN; @@ -560,7 +560,7 @@ ip6_reass(struct pbuf *p) - IP6_HLEN); /* Set payload length in ip header. */ - iphdr_ptr->_plen = htons(ipr->datagram_len); + iphdr_ptr->_plen = lwip_htons(ipr->datagram_len); /* Get the first pbuf. */ p = ipr->p; @@ -748,8 +748,8 @@ ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest) /* Set headers */ frag_hdr->_nexth = original_ip6hdr->_nexth; frag_hdr->reserved = 0; - frag_hdr->_fragment_offset = htons((fragment_offset & IP6_FRAG_OFFSET_MASK) | (last ? 0 : IP6_FRAG_MORE_FLAG)); - frag_hdr->_identification = htonl(identification); + frag_hdr->_fragment_offset = lwip_htons((fragment_offset & IP6_FRAG_OFFSET_MASK) | (last ? 0 : IP6_FRAG_MORE_FLAG)); + frag_hdr->_identification = lwip_htonl(identification); IP6H_NEXTH_SET(ip6hdr, IP6_NEXTH_FRAGMENT); IP6H_PLEN_SET(ip6hdr, cop + IP6_FRAG_HLEN); diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c index c06b1780..ec996e42 100644 --- a/src/core/ipv6/nd6.c +++ b/src/core/ipv6/nd6.c @@ -420,15 +420,15 @@ nd6_input(struct pbuf *p, struct netif *inp) } /* Re-set invalidation timer. */ - default_router_list[i].invalidation_timer = htons(ra_hdr->router_lifetime); + default_router_list[i].invalidation_timer = lwip_htons(ra_hdr->router_lifetime); /* Re-set default timer values. */ #if LWIP_ND6_ALLOW_RA_UPDATES if (ra_hdr->retrans_timer > 0) { - retrans_timer = htonl(ra_hdr->retrans_timer); + retrans_timer = lwip_htonl(ra_hdr->retrans_timer); } if (ra_hdr->reachable_time > 0) { - reachable_time = htonl(ra_hdr->reachable_time); + reachable_time = lwip_htonl(ra_hdr->reachable_time); } #endif /* LWIP_ND6_ALLOW_RA_UPDATES */ @@ -479,9 +479,9 @@ nd6_input(struct pbuf *p, struct netif *inp) { struct mtu_option *mtu_opt; mtu_opt = (struct mtu_option *)buffer; - if (htonl(mtu_opt->mtu) >= 1280) { + if (lwip_htonl(mtu_opt->mtu) >= 1280) { #if LWIP_ND6_ALLOW_RA_UPDATES - inp->mtu = (u16_t)htonl(mtu_opt->mtu); + inp->mtu = (u16_t)lwip_htonl(mtu_opt->mtu); #endif /* LWIP_ND6_ALLOW_RA_UPDATES */ } break; @@ -507,7 +507,7 @@ nd6_input(struct pbuf *p, struct netif *inp) prefix = nd6_new_onlink_prefix(ip6_current_dest_addr(), inp); } if (prefix >= 0) { - prefix_list[prefix].invalidation_timer = htonl(prefix_opt->valid_lifetime); + prefix_list[prefix].invalidation_timer = lwip_htonl(prefix_opt->valid_lifetime); #if LWIP_IPV6_AUTOCONFIG if (prefix_opt->flags & ND6_PREFIX_FLAG_AUTONOMOUS) { @@ -640,7 +640,7 @@ nd6_input(struct pbuf *p, struct netif *inp) } /* Change the Path MTU. */ - pmtu = htonl(icmp6hdr->data); + pmtu = lwip_htonl(icmp6hdr->data); destination_cache[i].pmtu = (u16_t)LWIP_MIN(pmtu, 0xFFFF); break; /* ICMP6_TYPE_PTB */ diff --git a/src/core/netif.c b/src/core/netif.c index 79b4652c..d9f595e6 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -1175,11 +1175,11 @@ netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit) /* Generate interface ID. */ if (from_mac_48bit) { /* Assume hwaddr is a 48-bit IEEE 802 MAC. Convert to EUI-64 address. Complement Group bit. */ - ip_2_ip6(&netif->ip6_addr[0])->addr[2] = htonl((((u32_t)(netif->hwaddr[0] ^ 0x02)) << 24) | + ip_2_ip6(&netif->ip6_addr[0])->addr[2] = lwip_htonl((((u32_t)(netif->hwaddr[0] ^ 0x02)) << 24) | ((u32_t)(netif->hwaddr[1]) << 16) | ((u32_t)(netif->hwaddr[2]) << 8) | (0xff)); - ip_2_ip6(&netif->ip6_addr[0])->addr[3] = htonl((0xfeul << 24) | + ip_2_ip6(&netif->ip6_addr[0])->addr[3] = lwip_htonl((0xfeul << 24) | ((u32_t)(netif->hwaddr[3]) << 16) | ((u32_t)(netif->hwaddr[4]) << 8) | (netif->hwaddr[5])); diff --git a/src/core/tcp.c b/src/core/tcp.c index a91c1f4e..1d700980 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -1972,13 +1972,13 @@ tcp_debug_print(struct tcp_hdr *tcphdr) LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", - ntohs(tcphdr->src), ntohs(tcphdr->dest))); + lwip_ntohs(tcphdr->src), lwip_ntohs(tcphdr->dest))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (seq no)\n", - ntohl(tcphdr->seqno))); + lwip_ntohl(tcphdr->seqno))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (ack no)\n", - ntohl(tcphdr->ackno))); + lwip_ntohl(tcphdr->ackno))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %2"U16_F" | |%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"| %5"U16_F" | (hdrlen, flags (", TCPH_HDRLEN(tcphdr), @@ -1988,12 +1988,12 @@ tcp_debug_print(struct tcp_hdr *tcphdr) (u16_t)(TCPH_FLAGS(tcphdr) >> 2 & 1), (u16_t)(TCPH_FLAGS(tcphdr) >> 1 & 1), (u16_t)(TCPH_FLAGS(tcphdr) & 1), - ntohs(tcphdr->wnd))); + lwip_ntohs(tcphdr->wnd))); tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); LWIP_DEBUGF(TCP_DEBUG, ("), win)\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04"X16_F" | %5"U16_F" | (chksum, urgp)\n", - ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); + lwip_ntohs(tcphdr->chksum), lwip_ntohs(tcphdr->urgp))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); } diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 1ee0e127..8925d7a6 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -209,11 +209,11 @@ tcp_input(struct pbuf *p, struct netif *inp) } /* Convert fields in TCP header to host byte order. */ - tcphdr->src = ntohs(tcphdr->src); - tcphdr->dest = ntohs(tcphdr->dest); - seqno = tcphdr->seqno = ntohl(tcphdr->seqno); - ackno = tcphdr->ackno = ntohl(tcphdr->ackno); - tcphdr->wnd = ntohs(tcphdr->wnd); + tcphdr->src = lwip_ntohs(tcphdr->src); + tcphdr->dest = lwip_ntohs(tcphdr->dest); + seqno = tcphdr->seqno = lwip_ntohl(tcphdr->seqno); + ackno = tcphdr->ackno = lwip_ntohl(tcphdr->ackno); + tcphdr->wnd = lwip_ntohs(tcphdr->wnd); flags = TCPH_FLAGS(tcphdr); tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0); @@ -747,7 +747,7 @@ tcp_process(struct tcp_pcb *pcb) switch (pcb->state) { case SYN_SENT: LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %"U32_F" pcb->snd_nxt %"U32_F" unacked %"U32_F"\n", ackno, - pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); + pcb->snd_nxt, lwip_ntohl(pcb->unacked->tcphdr->seqno))); /* received SYN ACK with expected sequence number? */ if ((flags & TCP_ACK) && (flags & TCP_SYN) && (ackno == pcb->lastack + 1)) { @@ -1140,18 +1140,18 @@ tcp_receive(struct tcp_pcb *pcb) LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n", ackno, pcb->unacked != NULL? - ntohl(pcb->unacked->tcphdr->seqno): 0, + lwip_ntohl(pcb->unacked->tcphdr->seqno): 0, pcb->unacked != NULL? - ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); + lwip_ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); /* Remove segment from the unacknowledged list if the incoming ACK acknowledges them. */ while (pcb->unacked != NULL && - TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + + TCP_SEQ_LEQ(lwip_ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked), ackno)) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unacked\n", - ntohl(pcb->unacked->tcphdr->seqno), - ntohl(pcb->unacked->tcphdr->seqno) + + lwip_ntohl(pcb->unacked->tcphdr->seqno), + lwip_ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked))); next = pcb->unacked; @@ -1199,10 +1199,10 @@ tcp_receive(struct tcp_pcb *pcb) ->unsent list after a retransmission, so these segments may in fact have been sent once. */ while (pcb->unsent != NULL && - TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + + TCP_SEQ_BETWEEN(ackno, lwip_ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", - ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + + lwip_ntohl(pcb->unsent->tcphdr->seqno), lwip_ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent))); next = pcb->unsent; @@ -1779,12 +1779,12 @@ tcp_parseopt(struct tcp_pcb *pcb) tsval |= (tcp_getoptbyte() << 16); tsval |= (tcp_getoptbyte() << 24); if (flags & TCP_SYN) { - pcb->ts_recent = ntohl(tsval); + pcb->ts_recent = lwip_ntohl(tsval); /* Enable sending timestamps in every segment now that we know the remote host supports it. */ pcb->flags |= TF_TIMESTAMP; } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno+tcplen)) { - pcb->ts_recent = ntohl(tsval); + pcb->ts_recent = lwip_ntohl(tsval); } /* Advance to next option (6 bytes already read) */ tcp_optidx += LWIP_TCP_OPT_LEN_TS - 6; diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 78ff0a1a..5a9c0319 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -114,12 +114,12 @@ tcp_output_alloc_header(struct tcp_pcb *pcb, u16_t optlen, u16_t datalen, LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", (p->len >= TCP_HLEN + optlen)); tcphdr = (struct tcp_hdr *)p->payload; - tcphdr->src = htons(pcb->local_port); - tcphdr->dest = htons(pcb->remote_port); + tcphdr->src = lwip_htons(pcb->local_port); + tcphdr->dest = lwip_htons(pcb->remote_port); tcphdr->seqno = seqno_be; - tcphdr->ackno = htonl(pcb->rcv_nxt); + tcphdr->ackno = lwip_htonl(pcb->rcv_nxt); TCPH_HDRLEN_FLAGS_SET(tcphdr, (5 + optlen / 4), TCP_ACK); - tcphdr->wnd = htons(TCPWND_MIN16(RCV_WND_SCALE(pcb, pcb->rcv_ann_wnd))); + tcphdr->wnd = lwip_htons(TCPWND_MIN16(RCV_WND_SCALE(pcb, pcb->rcv_ann_wnd))); tcphdr->chksum = 0; tcphdr->urgp = 0; @@ -204,9 +204,9 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, return NULL; } seg->tcphdr = (struct tcp_hdr *)seg->p->payload; - seg->tcphdr->src = htons(pcb->local_port); - seg->tcphdr->dest = htons(pcb->remote_port); - seg->tcphdr->seqno = htonl(seqno); + seg->tcphdr->src = lwip_htons(pcb->local_port); + seg->tcphdr->dest = lwip_htons(pcb->remote_port); + seg->tcphdr->seqno = lwip_htonl(seqno); /* ackno is set in tcp_output */ TCPH_HDRLEN_FLAGS_SET(seg->tcphdr, (5 + optlen / 4), flags); /* wnd and chksum are set in tcp_output */ @@ -633,8 +633,8 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) prev_seg = seg; LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_write: queueing %"U32_F":%"U32_F"\n", - ntohl(seg->tcphdr->seqno), - ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); + lwip_ntohl(seg->tcphdr->seqno), + lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); pos += seglen; } @@ -808,8 +808,8 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_enqueue_flags: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n", - ntohl(seg->tcphdr->seqno), - ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), + lwip_ntohl(seg->tcphdr->seqno), + lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), (u16_t)flags)); /* Now append seg to pcb->unsent queue */ @@ -856,8 +856,8 @@ tcp_build_timestamp_option(struct tcp_pcb *pcb, u32_t *opts) { /* Pad with two NOP options to make everything nicely aligned */ opts[0] = PP_HTONL(0x0101080A); - opts[1] = htonl(sys_now()); - opts[2] = htonl(pcb->ts_recent); + opts[1] = lwip_htonl(sys_now()); + opts[2] = lwip_htonl(pcb->ts_recent); } #endif @@ -896,7 +896,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) } #endif - p = tcp_output_alloc_header(pcb, optlen, 0, htonl(pcb->snd_nxt)); + p = tcp_output_alloc_header(pcb, optlen, 0, lwip_htonl(pcb->snd_nxt)); if (p == NULL) { /* let tcp_fasttmr retry sending this ACK */ pcb->flags |= (TF_ACK_DELAY | TF_ACK_NOW); @@ -989,7 +989,7 @@ tcp_output(struct tcp_pcb *pcb) */ if (pcb->flags & TF_ACK_NOW && (seg == NULL || - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) { + lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) { return tcp_send_empty_ack(pcb); } @@ -1030,13 +1030,13 @@ tcp_output(struct tcp_pcb *pcb) ("tcp_output: snd_wnd %"TCPWNDSIZE_F", cwnd %"TCPWNDSIZE_F", wnd %"U32_F ", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, - ntohl(seg->tcphdr->seqno), pcb->lastack)); + lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, + lwip_ntohl(seg->tcphdr->seqno), pcb->lastack)); } #endif /* TCP_CWND_DEBUG */ /* data available and window allows it to be sent? */ while (seg != NULL && - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { + lwip_ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { LWIP_ASSERT("RST not expected here!", (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0); /* Stop sending if the nagle algorithm would prevent it @@ -1053,9 +1053,9 @@ tcp_output(struct tcp_pcb *pcb) #if TCP_CWND_DEBUG LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"TCPWNDSIZE_F", cwnd %"TCPWNDSIZE_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F", i %"S16_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, - ntohl(seg->tcphdr->seqno) + seg->len - + lwip_ntohl(seg->tcphdr->seqno) + seg->len - pcb->lastack, - ntohl(seg->tcphdr->seqno), pcb->lastack, i)); + lwip_ntohl(seg->tcphdr->seqno), pcb->lastack, i)); ++i; #endif /* TCP_CWND_DEBUG */ @@ -1076,7 +1076,7 @@ tcp_output(struct tcp_pcb *pcb) if (pcb->state != SYN_SENT) { pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); } - snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); + snd_nxt = lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) { pcb->snd_nxt = snd_nxt; } @@ -1092,11 +1092,11 @@ tcp_output(struct tcp_pcb *pcb) /* In the case of fast retransmit, the packet should not go to the tail * of the unacked queue, but rather somewhere before it. We need to check for * this case. -STJ Jul 27, 2004 */ - if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) { + if (TCP_SEQ_LT(lwip_ntohl(seg->tcphdr->seqno), lwip_ntohl(useg->tcphdr->seqno))) { /* add segment to before tail of unacked list, keeping the list sorted */ struct tcp_seg **cur_seg = &(pcb->unacked); while (*cur_seg && - TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { + TCP_SEQ_LT(lwip_ntohl((*cur_seg)->tcphdr->seqno), lwip_ntohl(seg->tcphdr->seqno))) { cur_seg = &((*cur_seg)->next ); } seg->next = (*cur_seg); @@ -1147,18 +1147,18 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif /* The TCP header has already been constructed, but the ackno and wnd fields remain. */ - seg->tcphdr->ackno = htonl(pcb->rcv_nxt); + seg->tcphdr->ackno = lwip_htonl(pcb->rcv_nxt); /* advertise our receive window size in this TCP segment */ #if LWIP_WND_SCALE if (seg->flags & TF_SEG_OPTS_WND_SCALE) { /* The Window field in a SYN segment itself (the only type where we send the window scale option) is never scaled. */ - seg->tcphdr->wnd = htons(TCPWND_MIN16(pcb->rcv_ann_wnd)); + seg->tcphdr->wnd = lwip_htons(TCPWND_MIN16(pcb->rcv_ann_wnd)); } else #endif /* LWIP_WND_SCALE */ { - seg->tcphdr->wnd = htons(TCPWND_MIN16(RCV_WND_SCALE(pcb, pcb->rcv_ann_wnd))); + seg->tcphdr->wnd = lwip_htons(TCPWND_MIN16(RCV_WND_SCALE(pcb, pcb->rcv_ann_wnd))); } pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; @@ -1200,12 +1200,12 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif if (pcb->rttest == 0) { pcb->rttest = tcp_ticks; - pcb->rtseq = ntohl(seg->tcphdr->seqno); + pcb->rtseq = lwip_ntohl(seg->tcphdr->seqno); LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %"U32_F"\n", pcb->rtseq)); } LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %"U32_F":%"U32_F"\n", - htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + + lwip_htonl(seg->tcphdr->seqno), lwip_htonl(seg->tcphdr->seqno) + seg->len)); len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload); @@ -1303,10 +1303,10 @@ tcp_rst(u32_t seqno, u32_t ackno, (p->len >= sizeof(struct tcp_hdr))); tcphdr = (struct tcp_hdr *)p->payload; - tcphdr->src = htons(local_port); - tcphdr->dest = htons(remote_port); - tcphdr->seqno = htonl(seqno); - tcphdr->ackno = htonl(ackno); + tcphdr->src = lwip_htons(local_port); + tcphdr->dest = lwip_htons(remote_port); + tcphdr->seqno = lwip_htonl(seqno); + tcphdr->ackno = lwip_htonl(ackno); TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN/4, TCP_RST | TCP_ACK); #if LWIP_WND_SCALE tcphdr->wnd = PP_HTONS(((TCP_WND >> TCP_RCV_SCALE) & 0xFFFF)); @@ -1399,7 +1399,7 @@ tcp_rexmit(struct tcp_pcb *pcb) cur_seg = &(pcb->unsent); while (*cur_seg && - TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { + TCP_SEQ_LT(lwip_ntohl((*cur_seg)->tcphdr->seqno), lwip_ntohl(seg->tcphdr->seqno))) { cur_seg = &((*cur_seg)->next ); } seg->next = *cur_seg; @@ -1437,7 +1437,7 @@ tcp_rexmit_fast(struct tcp_pcb *pcb) ("tcp_receive: dupacks %"U16_F" (%"U32_F "), fast retransmit %"U32_F"\n", (u16_t)pcb->dupacks, pcb->lastack, - ntohl(pcb->unacked->tcphdr->seqno))); + lwip_ntohl(pcb->unacked->tcphdr->seqno))); tcp_rexmit(pcb); /* Set ssthresh to half of the minimum of the current @@ -1488,7 +1488,7 @@ tcp_keepalive(struct tcp_pcb *pcb) LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", tcp_ticks, pcb->tmr, (u16_t)pcb->keep_cnt_sent)); - p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1)); + p = tcp_output_alloc_header(pcb, 0, 0, lwip_htonl(pcb->snd_nxt - 1)); if (p == NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: could not allocate memory for pbuf\n")); @@ -1583,7 +1583,7 @@ tcp_zero_window_probe(struct tcp_pcb *pcb) } /* The byte may be acknowledged without the window being opened. */ - snd_nxt = ntohl(seg->tcphdr->seqno) + 1; + snd_nxt = lwip_ntohl(seg->tcphdr->seqno) + 1; if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) { pcb->snd_nxt = snd_nxt; } diff --git a/src/core/udp.c b/src/core/udp.c index 67b6c94b..f9aee732 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -242,17 +242,17 @@ udp_input(struct pbuf *p, struct netif *inp) LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); /* convert src and dest ports to host byte order */ - src = ntohs(udphdr->src); - dest = ntohs(udphdr->dest); + src = lwip_ntohs(udphdr->src); + dest = lwip_ntohs(udphdr->dest); udp_debug_print(udphdr); /* print the UDP source and destination */ LWIP_DEBUGF(UDP_DEBUG, ("udp (")); ip_addr_debug_print(UDP_DEBUG, ip_current_dest_addr()); - LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", ntohs(udphdr->dest))); + LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", lwip_ntohs(udphdr->dest))); ip_addr_debug_print(UDP_DEBUG, ip_current_src_addr()); - LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", ntohs(udphdr->src))); + LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", lwip_ntohs(udphdr->src))); pcb = NULL; prev = NULL; @@ -331,7 +331,7 @@ udp_input(struct pbuf *p, struct netif *inp) #if LWIP_UDPLITE if (ip_current_header_proto() == IP_PROTO_UDPLITE) { /* Do the UDP Lite checksum */ - u16_t chklen = ntohs(udphdr->len); + u16_t chklen = lwip_ntohs(udphdr->len); if (chklen < sizeof(struct udp_hdr)) { if (chklen == 0) { /* For UDP-Lite, checksum length of 0 means checksum @@ -752,8 +752,8 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d (q->len >= sizeof(struct udp_hdr))); /* q now represents the packet to be sent */ udphdr = (struct udp_hdr *)q->payload; - udphdr->src = htons(pcb->local_port); - udphdr->dest = htons(dst_port); + udphdr->src = lwip_htons(pcb->local_port); + udphdr->dest = lwip_htons(dst_port); /* in UDP, 0 checksum means 'no checksum' */ udphdr->chksum = 0x0000; @@ -786,7 +786,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d chklen_hdr = 0; chklen = q->tot_len; } - udphdr->len = htons(chklen_hdr); + udphdr->len = lwip_htons(chklen_hdr); /* calculate checksum */ #if CHECKSUM_GEN_UDP IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_UDP) { @@ -817,7 +817,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d #endif /* LWIP_UDPLITE */ { /* UDP */ LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); - udphdr->len = htons(q->tot_len); + udphdr->len = lwip_htons(q->tot_len); /* calculate checksum */ #if CHECKSUM_GEN_UDP IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_UDP) { @@ -1200,10 +1200,10 @@ udp_debug_print(struct udp_hdr *udphdr) LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", - ntohs(udphdr->src), ntohs(udphdr->dest))); + lwip_ntohs(udphdr->src), lwip_ntohs(udphdr->dest))); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n", - ntohs(udphdr->len), ntohs(udphdr->chksum))); + lwip_ntohs(udphdr->len), lwip_ntohs(udphdr->chksum))); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); } #endif /* UDP_DEBUG */ diff --git a/src/include/lwip/def.h b/src/include/lwip/def.h index 35359b3a..aafbd7cc 100644 --- a/src/include/lwip/def.h +++ b/src/include/lwip/def.h @@ -72,32 +72,6 @@ extern "C" { #define LWIP_MAKE_U16(a, b) ((b << 8) | a) #endif -#ifndef LWIP_PLATFORM_BYTESWAP -#define LWIP_PLATFORM_BYTESWAP 0 -#endif - -#ifndef LWIP_PREFIX_BYTEORDER_FUNCS -/* workaround for naming collisions on some platforms */ - -#ifdef htons -#undef htons -#endif /* htons */ -#ifdef htonl -#undef htonl -#endif /* htonl */ -#ifdef ntohs -#undef ntohs -#endif /* ntohs */ -#ifdef ntohl -#undef ntohl -#endif /* ntohl */ - -#define htons(x) lwip_htons(x) -#define ntohs(x) lwip_ntohs(x) -#define htonl(x) lwip_htonl(x) -#define ntohl(x) lwip_ntohl(x) -#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ - #if BYTE_ORDER == BIG_ENDIAN #define lwip_htons(x) (x) #define lwip_ntohs(x) (x) @@ -108,17 +82,15 @@ extern "C" { #define PP_HTONL(x) (x) #define PP_NTOHL(x) (x) #else /* BYTE_ORDER != BIG_ENDIAN */ -#if LWIP_PLATFORM_BYTESWAP -#define lwip_htons(x) LWIP_PLATFORM_HTONS(x) -#define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) -#define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) -#define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) -#else /* LWIP_PLATFORM_BYTESWAP */ +#ifndef lwip_htons u16_t lwip_htons(u16_t x); -u16_t lwip_ntohs(u16_t x); +#endif +#define lwip_ntohs(x) lwip_htons(x) + +#ifndef lwip_htonl u32_t lwip_htonl(u32_t x); -u32_t lwip_ntohl(u32_t x); -#endif /* LWIP_PLATFORM_BYTESWAP */ +#endif +#define lwip_ntohl(x) lwip_htonl(x) /* These macros should be calculated by the preprocessor and are used with compile-time constants only (so that there is no little-endian diff --git a/src/include/lwip/inet_chksum.h b/src/include/lwip/inet_chksum.h index 52d76d38..4e23d7f1 100644 --- a/src/include/lwip/inet_chksum.h +++ b/src/include/lwip/inet_chksum.h @@ -42,15 +42,9 @@ #include "lwip/pbuf.h" #include "lwip/ip_addr.h" -/** Swap the bytes in an u16_t: much like htons() for little-endian */ +/** Swap the bytes in an u16_t: much like lwip_htons() for little-endian */ #ifndef SWAP_BYTES_IN_WORD -#if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) -/* little endian and PLATFORM_BYTESWAP defined */ -#define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) -#else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ -/* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) -#endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ #endif /* SWAP_BYTES_IN_WORD */ /** Split an u32_t in two u16_ts and add them up */ diff --git a/src/include/lwip/ip4_addr.h b/src/include/lwip/ip4_addr.h index 2db8bd51..166acfab 100644 --- a/src/include/lwip/ip4_addr.h +++ b/src/include/lwip/ip4_addr.h @@ -141,7 +141,7 @@ struct netif; (u32_t)((d) & 0xff) #else /** Set an IP address given by the four byte-parts. - Little-endian version that prevents the use of htonl. */ + Little-endian version that prevents the use of lwip_htonl. */ #define IP4_ADDR(ipaddr, a,b,c,d) \ (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \ ((u32_t)((c) & 0xff) << 16) | \ @@ -164,7 +164,7 @@ struct netif; (src)->addr)) /** Set complete address to zero */ #define ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) -/** Set address to IPADDR_ANY (no need for htonl()) */ +/** Set address to IPADDR_ANY (no need for lwip_htonl()) */ #define ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) /** Set address to loopback address */ #define ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) @@ -174,7 +174,7 @@ struct netif; * from host- to network-order. */ #define ip4_addr_set_hton(dest, src) ((dest)->addr = \ ((src) == NULL ? 0:\ - htonl((src)->addr))) + lwip_htonl((src)->addr))) /** IPv4 only: set the IP address given as an u32_t */ #define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) /** IPv4 only: get the IP address as an u32_t */ diff --git a/src/include/lwip/ip6_addr.h b/src/include/lwip/ip6_addr.h index 2d269a6e..14d0f7cf 100644 --- a/src/include/lwip/ip6_addr.h +++ b/src/include/lwip/ip6_addr.h @@ -86,7 +86,7 @@ typedef struct ip6_addr_packed ip6_addr_p_t; (u32_t)((d) & 0xff) #else /** Set an IPv6 partial address given by byte-parts. -Little-endian version, stored in network order (no htonl). */ +Little-endian version, stored in network order (no lwip_htonl). */ #define IP6_ADDR_PART(ip6addr, index, a,b,c,d) \ (ip6addr)->addr[index] = ((u32_t)((d) & 0xff) << 24) | \ ((u32_t)((c) & 0xff) << 16) | \ @@ -103,21 +103,21 @@ Little-endian version, stored in network order (no htonl). */ (ip6addr)->addr[3] = idx3; } while(0) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)((htonl((ip6addr)->addr[0]) >> 16) & 0xffff)) +#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)((htonl((ip6addr)->addr[0])) & 0xffff)) +#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)((htonl((ip6addr)->addr[1]) >> 16) & 0xffff)) +#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)((htonl((ip6addr)->addr[1])) & 0xffff)) +#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)((htonl((ip6addr)->addr[2]) >> 16) & 0xffff)) +#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)((htonl((ip6addr)->addr[2])) & 0xffff)) +#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)((htonl((ip6addr)->addr[3]) >> 16) & 0xffff)) +#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff)) /** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)((htonl((ip6addr)->addr[3])) & 0xffff)) +#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3])) & 0xffff)) /** Copy IPv6 address - faster than ip6_addr_set: no NULL check */ #define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \ @@ -136,7 +136,7 @@ Little-endian version, stored in network order (no htonl). */ (ip6addr)->addr[2] = 0; \ (ip6addr)->addr[3] = 0;}while(0) -/** Set address to ipv6 'any' (no need for htonl()) */ +/** Set address to ipv6 'any' (no need for lwip_htonl()) */ #define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr) /** Set address to ipv6 loopback address */ #define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \ @@ -145,10 +145,10 @@ Little-endian version, stored in network order (no htonl). */ (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) /** Safely copy one IPv6 address to another and change byte order * from host- to network-order. */ -#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : htonl((src)->addr[0]); \ - (dest)->addr[1] = (src) == NULL ? 0 : htonl((src)->addr[1]); \ - (dest)->addr[2] = (src) == NULL ? 0 : htonl((src)->addr[2]); \ - (dest)->addr[3] = (src) == NULL ? 0 : htonl((src)->addr[3]);}while(0) +#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : lwip_htonl((src)->addr[0]); \ + (dest)->addr[1] = (src) == NULL ? 0 : lwip_htonl((src)->addr[1]); \ + (dest)->addr[2] = (src) == NULL ? 0 : lwip_htonl((src)->addr[2]); \ + (dest)->addr[3] = (src) == NULL ? 0 : lwip_htonl((src)->addr[3]);}while(0) /** @@ -166,7 +166,7 @@ Little-endian version, stored in network order (no htonl). */ ((addr1)->addr[2] == (addr2)->addr[2]) && \ ((addr1)->addr[3] == (addr2)->addr[3])) -#define ip6_get_subnet_id(ip6addr) (htonl((ip6addr)->addr[2]) & 0x0000ffffUL) +#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[2]) & 0x0000ffffUL) #define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \ ((ip6addr).addr[1] == 0) && \ @@ -193,7 +193,7 @@ Little-endian version, stored in network order (no htonl). */ #define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL)) #define ip6_addr_multicast_prefix_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00200000UL)) #define ip6_addr_multicast_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL)) -#define ip6_addr_multicast_scope(ip6addr) ((htonl((ip6addr)->addr[0]) >> 16) & 0xf) +#define ip6_addr_multicast_scope(ip6addr) ((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xf) #define IP6_MULTICAST_SCOPE_RESERVED 0x0 #define IP6_MULTICAST_SCOPE_RESERVED0 0x0 #define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1 diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h index 736dc325..51747e0f 100644 --- a/src/include/lwip/priv/tcp_priv.h +++ b/src/include/lwip/priv/tcp_priv.h @@ -290,7 +290,7 @@ struct tcp_seg { (flags & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0) /** This returns a TCP header option for MSS in an u32_t */ -#define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF)) +#define TCP_BUILD_MSS_OPTION(mss) lwip_htonl(0x02040000 | ((mss) & 0xFFFF)) #if LWIP_WND_SCALE #define TCPWNDSIZE_F U32_F diff --git a/src/include/lwip/prot/ethernet.h b/src/include/lwip/prot/ethernet.h index 792f5a22..e4baa29d 100644 --- a/src/include/lwip/prot/ethernet.h +++ b/src/include/lwip/prot/ethernet.h @@ -100,7 +100,7 @@ PACK_STRUCT_END #endif #define SIZEOF_VLAN_HDR 4 -#define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF) +#define VLAN_ID(vlan_hdr) (lwip_htons((vlan_hdr)->prio_vid) & 0xFFF) /** * @ingroup ethernet diff --git a/src/include/lwip/prot/ip6.h b/src/include/lwip/prot/ip6.h index 9a1aaa9f..4e3ca37d 100644 --- a/src/include/lwip/prot/ip6.h +++ b/src/include/lwip/prot/ip6.h @@ -134,16 +134,16 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif -#define IP6H_V(hdr) ((ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) -#define IP6H_TC(hdr) ((ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) -#define IP6H_FL(hdr) (ntohl((hdr)->_v_tc_fl) & 0x000fffff) -#define IP6H_PLEN(hdr) (ntohs((hdr)->_plen)) +#define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) +#define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) +#define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff) +#define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen)) #define IP6H_NEXTH(hdr) ((hdr)->_nexth) #define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) #define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) -#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) -#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = htons(plen) +#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) +#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen) #define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) #define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) diff --git a/src/include/lwip/prot/tcp.h b/src/include/lwip/prot/tcp.h index 8ef0bf1d..c2c03aa4 100644 --- a/src/include/lwip/prot/tcp.h +++ b/src/include/lwip/prot/tcp.h @@ -80,15 +80,15 @@ PACK_STRUCT_END /* Valid TCP header flags */ #define TCP_FLAGS 0x3fU -#define TCPH_HDRLEN(phdr) ((u16_t)(ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) -#define TCPH_FLAGS(phdr) ((u16_t)(ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)) +#define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) +#define TCPH_FLAGS(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)) -#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr)) -#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | htons(flags)) -#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags)) +#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr)) +#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags)) +#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | (flags)) -#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags)) -#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~htons(flags)) +#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags)) +#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags)) #ifdef __cplusplus } diff --git a/src/include/netif/ppp/eui64.h b/src/include/netif/ppp/eui64.h index 1b5147f4..20ac22ee 100644 --- a/src/include/netif/ppp/eui64.h +++ b/src/include/netif/ppp/eui64.h @@ -84,7 +84,7 @@ typedef union #define eui64_set32(e, l) do { \ (e).e32[0] = 0; \ - (e).e32[1] = htonl(l); \ + (e).e32[1] = lwip_htonl(l); \ } while (0) #define eui64_setlo32(e, l) eui64_set32(e, l) diff --git a/src/include/netif/ppp/mppe.h b/src/include/netif/ppp/mppe.h index 551a47e5..1ae8a5d9 100644 --- a/src/include/netif/ppp/mppe.h +++ b/src/include/netif/ppp/mppe.h @@ -59,7 +59,7 @@ * This is not nice ... the alternative is a bitfield struct though. * And unfortunately, we cannot share the same bits for the option * names above since C and H are the same bit. We could do a u_int32 - * but then we have to do a htonl() all the time and/or we still need + * but then we have to do a lwip_htonl() all the time and/or we still need * to know which octet is which. */ #define MPPE_C_BIT 0x01 /* MPPC */ diff --git a/src/netif/ethernet.c b/src/netif/ethernet.c index 621838e1..246eb459 100644 --- a/src/netif/ethernet.c +++ b/src/netif/ethernet.c @@ -98,7 +98,7 @@ ethernet_input(struct pbuf *p, struct netif *netif) (unsigned)ethhdr->dest.addr[3], (unsigned)ethhdr->dest.addr[4], (unsigned)ethhdr->dest.addr[5], (unsigned)ethhdr->src.addr[0], (unsigned)ethhdr->src.addr[1], (unsigned)ethhdr->src.addr[2], (unsigned)ethhdr->src.addr[3], (unsigned)ethhdr->src.addr[4], (unsigned)ethhdr->src.addr[5], - htons(ethhdr->type))); + lwip_htons(ethhdr->type))); type = ethhdr->type; #if ETHARP_SUPPORT_VLAN @@ -130,7 +130,7 @@ ethernet_input(struct pbuf *p, struct netif *netif) #endif /* ETHARP_SUPPORT_VLAN */ #if LWIP_ARP_FILTER_NETIF - netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, htons(type)); + netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, lwip_htons(type)); #endif /* LWIP_ARP_FILTER_NETIF*/ if (ethhdr->dest.addr[0] & 1) { @@ -262,7 +262,7 @@ ethernet_output(struct netif* netif, struct pbuf* p, u16_t eth_type) { struct eth_hdr* ethhdr; - u16_t eth_type_be = htons(eth_type); + u16_t eth_type_be = lwip_htons(eth_type); #if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) s32_t vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type); @@ -276,7 +276,7 @@ ethernet_output(struct netif* netif, struct pbuf* p, } vlanhdr = (struct eth_vlan_hdr*)(((u8_t*)p->payload) + SIZEOF_ETH_HDR); vlanhdr->tpid = eth_type_be; - vlanhdr->prio_vid = htons((u16_t)vlan_prio_vid); + vlanhdr->prio_vid = lwip_htons((u16_t)vlan_prio_vid); eth_type_be = PP_HTONS(ETHTYPE_VLAN); } else diff --git a/src/netif/lowpan6.c b/src/netif/lowpan6.c index 407848c4..eb0fe71d 100644 --- a/src/netif/lowpan6.c +++ b/src/netif/lowpan6.c @@ -160,13 +160,13 @@ lowpan6_get_address_mode(const ip6_addr_t *ip6addr, const struct ieee_802154_add if (mac_addr->addr_len == 2) { if ((ip6addr->addr[2] == (u32_t)PP_HTONL(0x000000ff)) && ((ip6addr->addr[3] & PP_HTONL(0xffff0000)) == PP_NTOHL(0xfe000000))) { - if ((ip6addr->addr[3] & PP_HTONL(0x0000ffff)) == ntohl((mac_addr->addr[0] << 8) | mac_addr->addr[1])) { + if ((ip6addr->addr[3] & PP_HTONL(0x0000ffff)) == lwip_ntohl((mac_addr->addr[0] << 8) | mac_addr->addr[1])) { return 3; } } } else if (mac_addr->addr_len == 8) { - if ((ip6addr->addr[2] == ntohl(((mac_addr->addr[0] ^ 2) << 24) | (mac_addr->addr[1] << 16) | mac_addr->addr[2] << 8 | mac_addr->addr[3])) && - (ip6addr->addr[3] == ntohl((mac_addr->addr[4] << 24) | (mac_addr->addr[5] << 16) | mac_addr->addr[6] << 8 | mac_addr->addr[7]))) { + if ((ip6addr->addr[2] == lwip_ntohl(((mac_addr->addr[0] ^ 2) << 24) | (mac_addr->addr[1] << 16) | mac_addr->addr[2] << 8 | mac_addr->addr[3])) && + (ip6addr->addr[3] == lwip_ntohl((mac_addr->addr[4] << 24) | (mac_addr->addr[5] << 16) | mac_addr->addr[6] << 8 | mac_addr->addr[7]))) { return 3; } } @@ -768,7 +768,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8 ip6hdr->src.addr[0] = PP_HTONL(0xfe800000UL); ip6hdr->src.addr[1] = 0; ip6hdr->src.addr[2] = PP_HTONL(0x000000ffUL); - ip6hdr->src.addr[3] = htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | + ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset+1]); lowpan6_offset += 2; } else if ((lowpan6_buffer[1] & 0x30) == 0x30) { @@ -776,11 +776,11 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8 ip6hdr->src.addr[1] = 0; if (src->addr_len == 2) { ip6hdr->src.addr[2] = PP_HTONL(0x000000ffUL); - ip6hdr->src.addr[3] = htonl(0xfe000000UL | (src->addr[0] << 8) | src->addr[1]); + ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (src->addr[0] << 8) | src->addr[1]); } else { - ip6hdr->src.addr[2] = htonl(((src->addr[0] ^ 2) << 24) | (src->addr[1] << 16) | + ip6hdr->src.addr[2] = lwip_htonl(((src->addr[0] ^ 2) << 24) | (src->addr[1] << 16) | (src->addr[2] << 8) | src->addr[3]); - ip6hdr->src.addr[3] = htonl((src->addr[4] << 24) | (src->addr[5] << 16) | + ip6hdr->src.addr[3] = lwip_htonl((src->addr[4] << 24) | (src->addr[5] << 16) | (src->addr[6] << 8) | src->addr[7]); } } @@ -815,15 +815,15 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8 lowpan6_offset += 8; } else if ((lowpan6_buffer[1] & 0x30) == 0x20) { ip6hdr->src.addr[2] = PP_HTONL(0x000000ffUL); - ip6hdr->src.addr[3] = htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset+1]); + ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset+1]); lowpan6_offset += 2; } else if ((lowpan6_buffer[1] & 0x30) == 0x30) { if (src->addr_len == 2) { ip6hdr->src.addr[2] = PP_HTONL(0x000000ffUL); - ip6hdr->src.addr[3] = htonl(0xfe000000UL | (src->addr[0] << 8) | src->addr[1]); + ip6hdr->src.addr[3] = lwip_htonl(0xfe000000UL | (src->addr[0] << 8) | src->addr[1]); } else { - ip6hdr->src.addr[2] = htonl(((src->addr[0] ^ 2) << 24) | (src->addr[1] << 16) | (src->addr[2] << 8) | src->addr[3]); - ip6hdr->src.addr[3] = htonl((src->addr[4] << 24) | (src->addr[5] << 16) | (src->addr[6] << 8) | src->addr[7]); + ip6hdr->src.addr[2] = lwip_htonl(((src->addr[0] ^ 2) << 24) | (src->addr[1] << 16) | (src->addr[2] << 8) | src->addr[3]); + ip6hdr->src.addr[3] = lwip_htonl((src->addr[4] << 24) | (src->addr[5] << 16) | (src->addr[6] << 8) | src->addr[7]); } } } @@ -843,22 +843,22 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8 MEMCPY(&ip6hdr->dest.addr[0], lowpan6_buffer + lowpan6_offset, 16); lowpan6_offset += 16; } else if ((lowpan6_buffer[1] & 0x03) == 0x01) { - ip6hdr->dest.addr[0] = htonl(0xff000000UL | (lowpan6_buffer[lowpan6_offset++] << 16)); + ip6hdr->dest.addr[0] = lwip_htonl(0xff000000UL | (lowpan6_buffer[lowpan6_offset++] << 16)); ip6hdr->dest.addr[1] = 0; - ip6hdr->dest.addr[2] = htonl(lowpan6_buffer[lowpan6_offset++]); - ip6hdr->dest.addr[3] = htonl((lowpan6_buffer[lowpan6_offset] << 24) | (lowpan6_buffer[lowpan6_offset + 1] << 16) | (lowpan6_buffer[lowpan6_offset + 2] << 8) | lowpan6_buffer[lowpan6_offset + 3]); + ip6hdr->dest.addr[2] = lwip_htonl(lowpan6_buffer[lowpan6_offset++]); + ip6hdr->dest.addr[3] = lwip_htonl((lowpan6_buffer[lowpan6_offset] << 24) | (lowpan6_buffer[lowpan6_offset + 1] << 16) | (lowpan6_buffer[lowpan6_offset + 2] << 8) | lowpan6_buffer[lowpan6_offset + 3]); lowpan6_offset += 4; } else if ((lowpan6_buffer[1] & 0x03) == 0x02) { - ip6hdr->dest.addr[0] = htonl(0xff000000UL | lowpan6_buffer[lowpan6_offset++]); + ip6hdr->dest.addr[0] = lwip_htonl(0xff000000UL | lowpan6_buffer[lowpan6_offset++]); ip6hdr->dest.addr[1] = 0; ip6hdr->dest.addr[2] = 0; - ip6hdr->dest.addr[3] = htonl((lowpan6_buffer[lowpan6_offset] << 16) | (lowpan6_buffer[lowpan6_offset + 1] << 8) | lowpan6_buffer[lowpan6_offset + 2]); + ip6hdr->dest.addr[3] = lwip_htonl((lowpan6_buffer[lowpan6_offset] << 16) | (lowpan6_buffer[lowpan6_offset + 1] << 8) | lowpan6_buffer[lowpan6_offset + 2]); lowpan6_offset += 3; } else if ((lowpan6_buffer[1] & 0x03) == 0x03) { ip6hdr->dest.addr[0] = PP_HTONL(0xff020000UL); ip6hdr->dest.addr[1] = 0; ip6hdr->dest.addr[2] = 0; - ip6hdr->dest.addr[3] = htonl(lowpan6_buffer[lowpan6_offset++]); + ip6hdr->dest.addr[3] = lwip_htonl(lowpan6_buffer[lowpan6_offset++]); } } else { @@ -894,15 +894,15 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8 lowpan6_offset += 8; } else if ((lowpan6_buffer[1] & 0x03) == 0x02) { ip6hdr->dest.addr[2] = PP_HTONL(0x000000ffUL); - ip6hdr->dest.addr[3] = htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset + 1]); + ip6hdr->dest.addr[3] = lwip_htonl(0xfe000000UL | (lowpan6_buffer[lowpan6_offset] << 8) | lowpan6_buffer[lowpan6_offset + 1]); lowpan6_offset += 2; } else if ((lowpan6_buffer[1] & 0x03) == 0x03) { if (dest->addr_len == 2) { ip6hdr->dest.addr[2] = PP_HTONL(0x000000ffUL); - ip6hdr->dest.addr[3] = htonl(0xfe000000UL | (dest->addr[0] << 8) | dest->addr[1]); + ip6hdr->dest.addr[3] = lwip_htonl(0xfe000000UL | (dest->addr[0] << 8) | dest->addr[1]); } else { - ip6hdr->dest.addr[2] = htonl(((dest->addr[0] ^ 2) << 24) | (dest->addr[1] << 16) | dest->addr[2] << 8 | dest->addr[3]); - ip6hdr->dest.addr[3] = htonl((dest->addr[4] << 24) | (dest->addr[5] << 16) | dest->addr[6] << 8 | dest->addr[7]); + ip6hdr->dest.addr[2] = lwip_htonl(((dest->addr[0] ^ 2) << 24) | (dest->addr[1] << 16) | dest->addr[2] << 8 | dest->addr[3]); + ip6hdr->dest.addr[3] = lwip_htonl((dest->addr[4] << 24) | (dest->addr[5] << 16) | dest->addr[6] << 8 | dest->addr[7]); } } } @@ -927,26 +927,26 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8 /* Decompress ports */ i = lowpan6_buffer[lowpan6_offset++] & 0x03; if (i == 0) { - udphdr->src = htons(lowpan6_buffer[lowpan6_offset] << 8 | lowpan6_buffer[lowpan6_offset + 1]); - udphdr->dest = htons(lowpan6_buffer[lowpan6_offset + 2] << 8 | lowpan6_buffer[lowpan6_offset + 3]); + udphdr->src = lwip_htons(lowpan6_buffer[lowpan6_offset] << 8 | lowpan6_buffer[lowpan6_offset + 1]); + udphdr->dest = lwip_htons(lowpan6_buffer[lowpan6_offset + 2] << 8 | lowpan6_buffer[lowpan6_offset + 3]); lowpan6_offset += 4; } else if (i == 0x01) { - udphdr->src = htons(lowpan6_buffer[lowpan6_offset] << 8 | lowpan6_buffer[lowpan6_offset + 1]); - udphdr->dest = htons(0xf000 | lowpan6_buffer[lowpan6_offset + 2]); + udphdr->src = lwip_htons(lowpan6_buffer[lowpan6_offset] << 8 | lowpan6_buffer[lowpan6_offset + 1]); + udphdr->dest = lwip_htons(0xf000 | lowpan6_buffer[lowpan6_offset + 2]); lowpan6_offset += 3; } else if (i == 0x02) { - udphdr->src = htons(0xf000 | lowpan6_buffer[lowpan6_offset]); - udphdr->dest = htons(lowpan6_buffer[lowpan6_offset + 1] << 8 | lowpan6_buffer[lowpan6_offset + 2]); + udphdr->src = lwip_htons(0xf000 | lowpan6_buffer[lowpan6_offset]); + udphdr->dest = lwip_htons(lowpan6_buffer[lowpan6_offset + 1] << 8 | lowpan6_buffer[lowpan6_offset + 2]); lowpan6_offset += 3; } else if (i == 0x03) { - udphdr->src = htons(0xf0b0 | ((lowpan6_buffer[lowpan6_offset] >> 4) & 0x0f)); - udphdr->dest = htons(0xf0b0 | (lowpan6_buffer[lowpan6_offset] & 0x0f)); + udphdr->src = lwip_htons(0xf0b0 | ((lowpan6_buffer[lowpan6_offset] >> 4) & 0x0f)); + udphdr->dest = lwip_htons(0xf0b0 | (lowpan6_buffer[lowpan6_offset] & 0x0f)); lowpan6_offset += 1; } - udphdr->chksum = htons(lowpan6_buffer[lowpan6_offset] << 8 | lowpan6_buffer[lowpan6_offset + 1]); + udphdr->chksum = lwip_htons(lowpan6_buffer[lowpan6_offset] << 8 | lowpan6_buffer[lowpan6_offset + 1]); lowpan6_offset += 2; - udphdr->len = htons(p->tot_len - lowpan6_offset + UDP_HLEN); + udphdr->len = lwip_htons(p->tot_len - lowpan6_offset + UDP_HLEN); ip6_offset += UDP_HLEN; } else { diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index 109c1467..c8673ad0 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -2121,10 +2121,10 @@ set_allowed_addrs(unit, addrs, opts) } else { np = getnetbyname (ptr_word); if (np != NULL && np->n_addrtype == AF_INET) { - a = htonl ((u32_t)np->n_net); + a = lwip_htonl ((u32_t)np->n_net); if (ptr_mask == NULL) { /* calculate appropriate mask for net */ - ah = ntohl(a); + ah = lwip_ntohl(a); if (IN_CLASSA(ah)) mask = IN_CLASSA_NET; else if (IN_CLASSB(ah)) @@ -2150,10 +2150,10 @@ set_allowed_addrs(unit, addrs, opts) ifunit, ptr_word); continue; } - a = htonl((ntohl(a) & mask) + offset); + a = lwip_htonl((lwip_ntohl(a) & mask) + offset); mask = ~(u32_t)0; } - ip[n].mask = htonl(mask); + ip[n].mask = lwip_htonl(mask); ip[n].base = a & ip[n].mask; ++n; if (~mask == 0 && suggested_ip == 0) @@ -2234,7 +2234,7 @@ int bad_ip_adrs(addr) u32_t addr; { - addr = ntohl(addr); + addr = lwip_ntohl(addr); return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || IN_MULTICAST(addr) || IN_BADCLASS(addr); } diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index 2cdcba85..7d9d6fd8 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -542,7 +542,7 @@ setnetmask(argv) p = *argv; n = parse_dotted_ip(p, &mask); - mask = htonl(mask); + mask = lwip_htonl(mask); if (n == 0 || p[n] != 0 || (netmask & ~mask) != 0) { option_error("invalid netmask value '%s'", *argv); @@ -822,9 +822,9 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { u32_t l; \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_ADDRS, ucp); \ - l = ntohl(val1); \ + l = lwip_ntohl(val1); \ PUTLONG(l, ucp); \ - l = ntohl(val2); \ + l = lwip_ntohl(val2); \ PUTLONG(l, ucp); \ len -= CILEN_ADDRS; \ } else \ @@ -855,7 +855,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { u32_t l; \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_ADDR, ucp); \ - l = ntohl(val); \ + l = lwip_ntohl(val); \ PUTLONG(l, ucp); \ len -= CILEN_ADDR; \ } else \ @@ -869,7 +869,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { u32_t l; \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_ADDR, ucp); \ - l = ntohl(addr); \ + l = lwip_ntohl(addr); \ PUTLONG(l, ucp); \ len -= CILEN_ADDR; \ } else \ @@ -884,7 +884,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { u32_t l; \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_ADDR, ucp); \ - l = ntohl(addr); \ + l = lwip_ntohl(addr); \ PUTLONG(l, ucp); \ len -= CILEN_ADDR; \ } else \ @@ -953,11 +953,11 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { citype != opt) \ goto bad; \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ if (val1 != cilong) \ goto bad; \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ if (val2 != cilong) \ goto bad; \ } @@ -998,7 +998,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { citype != opt) \ goto bad; \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ if (val != cilong) \ goto bad; \ } @@ -1014,7 +1014,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { if (cilen != CILEN_ADDR || citype != opt) \ goto bad; \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ if (addr != cilong) \ goto bad; \ } @@ -1031,7 +1031,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { if (cilen != CILEN_ADDR || citype != opt) \ goto bad; \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ if (addr != cilong) \ goto bad; \ } @@ -1112,9 +1112,9 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - ciaddr1 = htonl(l); \ + ciaddr1 = lwip_htonl(l); \ GETLONG(l, p); \ - ciaddr2 = htonl(l); \ + ciaddr2 = lwip_htonl(l); \ no.old_addrs = 1; \ code \ } @@ -1141,7 +1141,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - ciaddr1 = htonl(l); \ + ciaddr1 = lwip_htonl(l); \ no.neg = 1; \ code \ } @@ -1155,7 +1155,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - cidnsaddr = htonl(l); \ + cidnsaddr = lwip_htonl(l); \ no.neg = 1; \ code \ } @@ -1271,11 +1271,11 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { goto bad; try_.neg_addr = 0; GETLONG(l, p); - ciaddr1 = htonl(l); + ciaddr1 = lwip_htonl(l); if (ciaddr1 && go->accept_local) try_.ouraddr = ciaddr1; GETLONG(l, p); - ciaddr2 = htonl(l); + ciaddr2 = lwip_htonl(l); if (ciaddr2 && go->accept_remote) try_.hisaddr = ciaddr2; no.old_addrs = 1; @@ -1285,7 +1285,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { goto bad; try_.old_addrs = 0; GETLONG(l, p); - ciaddr1 = htonl(l); + ciaddr1 = lwip_htonl(l); if (ciaddr1 && go->accept_local) try_.ouraddr = ciaddr1; if (try_.ouraddr != 0) @@ -1297,7 +1297,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR) goto bad; GETLONG(l, p); - try_.dnsaddr[0] = htonl(l); + try_.dnsaddr[0] = lwip_htonl(l); try_.req_dns1 = 1; no.req_dns1 = 1; break; @@ -1305,7 +1305,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR) goto bad; GETLONG(l, p); - try_.dnsaddr[1] = htonl(l); + try_.dnsaddr[1] = lwip_htonl(l); try_.req_dns2 = 1; no.req_dns2 = 1; break; @@ -1316,7 +1316,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { if (cilen != CILEN_ADDR) goto bad; GETLONG(l, p); - ciaddr1 = htonl(l); + ciaddr1 = lwip_htonl(l); if (ciaddr1) try_.winsaddr[citype == CI_MS_WINS2] = ciaddr1; break; @@ -1372,12 +1372,12 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ /* Check rejected value. */ \ if (cilong != val1) \ goto bad; \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ /* Check rejected value. */ \ if (cilong != val2) \ goto bad; \ @@ -1417,7 +1417,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ /* Check rejected value. */ \ if (cilong != val) \ goto bad; \ @@ -1434,7 +1434,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ /* Check rejected value. */ \ if (cilong != dnsaddr) \ goto bad; \ @@ -1452,7 +1452,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ - cilong = htonl(l); \ + cilong = lwip_htonl(l); \ /* Check rejected value. */ \ if (cilong != addr) \ goto bad; \ @@ -1575,13 +1575,13 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { * then accept it. */ GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = htonl(tl); + ciaddr1 = lwip_htonl(tl); if (ciaddr1 != wo->hisaddr && (ciaddr1 == 0 || !wo->accept_remote)) { orc = CONFNAK; if (!reject_if_disagree) { DECPTR(sizeof(u32_t), p); - tl = ntohl(wo->hisaddr); + tl = lwip_ntohl(wo->hisaddr); PUTLONG(tl, p); } } else if (ciaddr1 == 0 && wo->hisaddr == 0) { @@ -1598,13 +1598,13 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { * but disagree about it, then NAK it with our idea. */ GETLONG(tl, p); /* Parse desination address (ours) */ - ciaddr2 = htonl(tl); + ciaddr2 = lwip_htonl(tl); if (ciaddr2 != wo->ouraddr) { if (ciaddr2 == 0 || !wo->accept_local) { orc = CONFNAK; if (!reject_if_disagree) { DECPTR(sizeof(u32_t), p); - tl = ntohl(wo->ouraddr); + tl = lwip_ntohl(wo->ouraddr); PUTLONG(tl, p); } } else { @@ -1631,13 +1631,13 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { * then accept it. */ GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = htonl(tl); + ciaddr1 = lwip_htonl(tl); if (ciaddr1 != wo->hisaddr && (ciaddr1 == 0 || !wo->accept_remote)) { orc = CONFNAK; if (!reject_if_disagree) { DECPTR(sizeof(u32_t), p); - tl = ntohl(wo->hisaddr); + tl = lwip_ntohl(wo->hisaddr); PUTLONG(tl, p); } } else if (ciaddr1 == 0 && wo->hisaddr == 0) { @@ -1666,9 +1666,9 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { break; } GETLONG(tl, p); - if (htonl(tl) != ao->dnsaddr[d]) { + if (lwip_htonl(tl) != ao->dnsaddr[d]) { DECPTR(sizeof(u32_t), p); - tl = ntohl(ao->dnsaddr[d]); + tl = lwip_ntohl(ao->dnsaddr[d]); PUTLONG(tl, p); orc = CONFNAK; } @@ -1688,9 +1688,9 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { break; } GETLONG(tl, p); - if (htonl(tl) != ao->winsaddr[d]) { + if (lwip_htonl(tl) != ao->winsaddr[d]) { DECPTR(sizeof(u32_t), p); - tl = ntohl(ao->winsaddr[d]); + tl = lwip_ntohl(ao->winsaddr[d]); PUTLONG(tl, p); orc = CONFNAK; } @@ -1793,7 +1793,7 @@ endswitch: } PUTCHAR(CI_ADDR, ucp); PUTCHAR(CILEN_ADDR, ucp); - tl = ntohl(wo->hisaddr); + tl = lwip_ntohl(wo->hisaddr); PUTLONG(tl, ucp); } @@ -1850,12 +1850,12 @@ ip_demand_conf(u) if (wo->hisaddr == 0 && !pcb->settings.noremoteip) { /* make up an arbitrary address for the peer */ - wo->hisaddr = htonl(0x0a707070 + ifunit); + wo->hisaddr = lwip_htonl(0x0a707070 + ifunit); wo->accept_remote = 1; } if (wo->ouraddr == 0) { /* make up an arbitrary address for us */ - wo->ouraddr = htonl(0x0a404040 + ifunit); + wo->ouraddr = lwip_htonl(0x0a404040 + ifunit); wo->accept_local = 1; ask_for_local = 0; /* don't tell the peer this address */ } @@ -1917,7 +1917,7 @@ static void ipcp_up(fsm *f) { return; } if (ho->hisaddr == 0 && !pcb->settings.noremoteip) { - ho->hisaddr = htonl(0x0a404040); + ho->hisaddr = lwip_htonl(0x0a404040); ppp_warn("Could not determine remote IP address: defaulting to %I", ho->hisaddr); } @@ -2271,9 +2271,9 @@ static int ipcp_printpkt(const u_char *p, int plen, if (olen == CILEN_ADDRS) { p += 2; GETLONG(cilong, p); - printer(arg, "addrs %I", htonl(cilong)); + printer(arg, "addrs %I", lwip_htonl(cilong)); GETLONG(cilong, p); - printer(arg, " %I", htonl(cilong)); + printer(arg, " %I", lwip_htonl(cilong)); } break; #if VJ_SUPPORT @@ -2299,7 +2299,7 @@ static int ipcp_printpkt(const u_char *p, int plen, if (olen == CILEN_ADDR) { p += 2; GETLONG(cilong, p); - printer(arg, "addr %I", htonl(cilong)); + printer(arg, "addr %I", lwip_htonl(cilong)); } break; #if LWIP_DNS @@ -2316,7 +2316,7 @@ static int ipcp_printpkt(const u_char *p, int plen, case CI_MS_WINS2: p += 2; GETLONG(cilong, p); - printer(arg, "ms-wins %I", htonl(cilong)); + printer(arg, "ms-wins %I", lwip_htonl(cilong)); break; #endif /* UNUSED - WINS */ default: diff --git a/src/netif/ppp/ipv6cp.c b/src/netif/ppp/ipv6cp.c index f0f4eee0..11c18df7 100644 --- a/src/netif/ppp/ipv6cp.c +++ b/src/netif/ppp/ipv6cp.c @@ -1093,7 +1093,7 @@ static void ipv6_check_options() { if (!wo->opt_local) { /* init interface identifier */ if (wo->use_ip && eui64_iszero(wo->ourid)) { - eui64_setlo32(wo->ourid, ntohl(ipcp_wantoptions[0].ouraddr)); + eui64_setlo32(wo->ourid, lwip_ntohl(ipcp_wantoptions[0].ouraddr)); if (!eui64_iszero(wo->ourid)) wo->opt_local = 1; } @@ -1104,7 +1104,7 @@ static void ipv6_check_options() { if (!wo->opt_remote) { if (wo->use_ip && eui64_iszero(wo->hisid)) { - eui64_setlo32(wo->hisid, ntohl(ipcp_wantoptions[0].hisaddr)); + eui64_setlo32(wo->hisid, lwip_ntohl(ipcp_wantoptions[0].hisaddr)); if (!eui64_iszero(wo->hisid)) wo->opt_remote = 1; } diff --git a/src/netif/ppp/multilink.c b/src/netif/ppp/multilink.c index 0d617a0f..62014e8c 100644 --- a/src/netif/ppp/multilink.c +++ b/src/netif/ppp/multilink.c @@ -469,7 +469,7 @@ get_default_epdisc(ep) if (hp != NULL) { addr = *(u32_t *)hp->h_addr; if (!bad_ip_adrs(addr)) { - addr = ntohl(addr); + addr = lwip_ntohl(addr); if (!LOCAL_IP_ADDR(addr)) { ep->class = EPD_IP; set_ip_epdisc(ep, addr); @@ -504,7 +504,7 @@ epdisc_to_str(ep) u32_t addr; GETLONG(addr, p); - slprintf(str, sizeof(str), "IP:%I", htonl(addr)); + slprintf(str, sizeof(str), "IP:%I", lwip_htonl(addr)); return str; } diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 4bd17003..39c3c240 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -1219,7 +1219,7 @@ u32_t get_mask(u32_t addr) { #if 0 u32_t mask, nmask; - addr = htonl(addr); + addr = lwip_htonl(addr); if (IP_CLASSA(addr)) { /* determine network mask for address class */ nmask = IP_CLASSA_NET; } else if (IP_CLASSB(addr)) { @@ -1229,7 +1229,7 @@ u32_t get_mask(u32_t addr) { } /* class D nets are disallowed by bad_ip_adrs */ - mask = PP_HTONL(0xffffff00UL) | htonl(nmask); + mask = PP_HTONL(0xffffff00UL) | lwip_htonl(nmask); /* XXX * Scan through the system's network interfaces. diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index 768d22be..ed061c31 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -419,8 +419,8 @@ pppoe_disc_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_DEBUG, ("pppoe: unknown version/type packet: 0x%x\n", ph->vertype)); goto done; } - session = ntohs(ph->session); - plen = ntohs(ph->plen); + session = lwip_ntohs(ph->session); + plen = lwip_ntohs(ph->plen); off += sizeof(*ph); if (plen + off > pb->len) { @@ -436,8 +436,8 @@ pppoe_disc_input(struct netif *netif, struct pbuf *pb) sc = NULL; while (off + sizeof(pt) <= pb->len) { MEMCPY(&pt, (u8_t*)pb->payload + off, sizeof(pt)); - tag = ntohs(pt.tag); - len = ntohs(pt.len); + tag = lwip_ntohs(pt.tag); + len = lwip_ntohs(pt.len); if (off + sizeof(pt) + len > pb->len) { PPPDEBUG(LOG_DEBUG, ("pppoe: tag 0x%x len 0x%x is too long\n", tag, len)); goto done; @@ -680,7 +680,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) goto drop; } - session = ntohs(ph->session); + session = lwip_ntohs(ph->session); sc = pppoe_find_softc_by_session(session, netif); if (sc == NULL) { #ifdef PPPOE_TERM_UNKNOWN_SESSIONS @@ -690,7 +690,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) goto drop; } - plen = ntohs(ph->plen); + plen = lwip_ntohs(ph->plen); if (pbuf_header(pb, -(s16_t)(PPPOE_HEADERLEN)) != 0) { /* bail out */ @@ -732,7 +732,7 @@ pppoe_output(struct pppoe_softc *sc, struct pbuf *pb) } ethhdr = (struct eth_hdr *)pb->payload; etype = sc->sc_state == PPPOE_STATE_SESSION ? ETHTYPE_PPPOE : ETHTYPE_PPPOEDISC; - ethhdr->type = htons(etype); + ethhdr->type = lwip_htons(etype); MEMCPY(ðhdr->dest.addr, &sc->sc_dest.addr, sizeof(ethhdr->dest.addr)); MEMCPY(ðhdr->src.addr, &sc->sc_ethif->hwaddr, sizeof(ethhdr->src.addr)); diff --git a/src/netif/ppp/utils.c b/src/netif/ppp/utils.c index 1d44e9c3..a5ae86f0 100644 --- a/src/netif/ppp/utils.c +++ b/src/netif/ppp/utils.c @@ -267,7 +267,7 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { #endif /* do we always have strerror() in embedded ? */ case 'I': ip = va_arg(args, u32_t); - ip = ntohl(ip); + ip = lwip_ntohl(ip); ppp_slprintf(num, sizeof(num), "%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); str = num; diff --git a/src/netif/ppp/vj.c b/src/netif/ppp/vj.c index dadb38d6..168c3400 100644 --- a/src/netif/ppp/vj.c +++ b/src/netif/ppp/vj.c @@ -95,32 +95,32 @@ vj_compress_init(struct vjcompress *comp) #define DECODEL(f) { \ if (*cp == 0) {\ - u32_t tmp_ = ntohl(f) + ((cp[1] << 8) | cp[2]); \ - (f) = htonl(tmp_); \ + u32_t tmp_ = lwip_ntohl(f) + ((cp[1] << 8) | cp[2]); \ + (f) = lwip_htonl(tmp_); \ cp += 3; \ } else { \ - u32_t tmp_ = ntohl(f) + (u32_t)*cp++; \ - (f) = htonl(tmp_); \ + u32_t tmp_ = lwip_ntohl(f) + (u32_t)*cp++; \ + (f) = lwip_htonl(tmp_); \ } \ } #define DECODES(f) { \ if (*cp == 0) {\ - u16_t tmp_ = ntohs(f) + (((u16_t)cp[1] << 8) | cp[2]); \ - (f) = htons(tmp_); \ + u16_t tmp_ = lwip_ntohs(f) + (((u16_t)cp[1] << 8) | cp[2]); \ + (f) = lwip_htons(tmp_); \ cp += 3; \ } else { \ - u16_t tmp_ = ntohs(f) + (u16_t)*cp++; \ - (f) = htons(tmp_); \ + u16_t tmp_ = lwip_ntohs(f) + (u16_t)*cp++; \ + (f) = lwip_htons(tmp_); \ } \ } #define DECODEU(f) { \ if (*cp == 0) {\ - (f) = htons(((u16_t)cp[1] << 8) | cp[2]); \ + (f) = lwip_htons(((u16_t)cp[1] << 8) | cp[2]); \ cp += 3; \ } else { \ - (f) = htons((u16_t)*cp++); \ + (f) = lwip_htons((u16_t)*cp++); \ } \ } @@ -306,7 +306,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) * needed in this section of code). */ if (TCPH_FLAGS(th) & TCP_URG) { - deltaS = ntohs(th->urgp); + deltaS = lwip_ntohs(th->urgp); ENCODEZ(deltaS); changes |= NEW_U; } else if (th->urgp != oth->urgp) { @@ -317,12 +317,12 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) goto uncompressed; } - if ((deltaS = (u16_t)(ntohs(th->wnd) - ntohs(oth->wnd))) != 0) { + if ((deltaS = (u16_t)(lwip_ntohs(th->wnd) - lwip_ntohs(oth->wnd))) != 0) { ENCODE(deltaS); changes |= NEW_W; } - if ((deltaL = ntohl(th->ackno) - ntohl(oth->ackno)) != 0) { + if ((deltaL = lwip_ntohl(th->ackno) - lwip_ntohl(oth->ackno)) != 0) { if (deltaL > 0xffff) { goto uncompressed; } @@ -331,7 +331,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) changes |= NEW_A; } - if ((deltaL = ntohl(th->seqno) - ntohl(oth->seqno)) != 0) { + if ((deltaL = lwip_ntohl(th->seqno) - lwip_ntohl(oth->seqno)) != 0) { if (deltaL > 0xffff) { goto uncompressed; } @@ -351,7 +351,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) * in case the other side missed the compressed version. */ if (IPH_LEN(ip) != IPH_LEN(&cs->cs_ip) && - ntohs(IPH_LEN(&cs->cs_ip)) == hlen) { + lwip_ntohs(IPH_LEN(&cs->cs_ip)) == hlen) { break; } /* no break */ @@ -366,7 +366,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) goto uncompressed; case NEW_S|NEW_A: - if (deltaS == deltaA && deltaS == ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { + if (deltaS == deltaA && deltaS == lwip_ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { /* special case for echoed terminal traffic */ changes = SPECIAL_I; cp = new_seq; @@ -374,7 +374,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) break; case NEW_S: - if (deltaS == ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { + if (deltaS == lwip_ntohs(IPH_LEN(&cs->cs_ip)) - hlen) { /* special case for data xfer */ changes = SPECIAL_D; cp = new_seq; @@ -384,7 +384,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) break; } - deltaS = (u16_t)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip))); + deltaS = (u16_t)(lwip_ntohs(IPH_ID(ip)) - lwip_ntohs(IPH_ID(&cs->cs_ip))); if (deltaS != 1) { ENCODEZ(deltaS); changes |= NEW_I; @@ -396,7 +396,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) * Grab the cksum before we overwrite it below. Then update our * state with this packet's header. */ - deltaA = ntohs(th->chksum); + deltaA = lwip_ntohs(th->chksum); MEMCPY(&cs->cs_ip, ip, hlen); /* @@ -538,7 +538,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) cs = &comp->rstate[comp->last_recv]; hlen = IPH_HL(&cs->cs_ip) << 2; th = (struct tcp_hdr *)&((u8_t*)&cs->cs_ip)[hlen]; - th->chksum = htons((*cp << 8) | cp[1]); + th->chksum = lwip_htons((*cp << 8) | cp[1]); cp += 2; if (changes & TCP_PUSH_BIT) { TCPH_SET_FLAG(th, TCP_PSH); @@ -549,19 +549,19 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) switch (changes & SPECIALS_MASK) { case SPECIAL_I: { - u32_t i = ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; + u32_t i = lwip_ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; /* some compilers can't nest inline assembler.. */ - tmp = ntohl(th->ackno) + i; - th->ackno = htonl(tmp); - tmp = ntohl(th->seqno) + i; - th->seqno = htonl(tmp); + tmp = lwip_ntohl(th->ackno) + i; + th->ackno = lwip_htonl(tmp); + tmp = lwip_ntohl(th->seqno) + i; + th->seqno = lwip_htonl(tmp); } break; case SPECIAL_D: /* some compilers can't nest inline assembler.. */ - tmp = ntohl(th->seqno) + ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; - th->seqno = htonl(tmp); + tmp = lwip_ntohl(th->seqno) + lwip_ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; + th->seqno = lwip_htonl(tmp); break; default: @@ -585,8 +585,8 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) if (changes & NEW_I) { DECODES(cs->cs_ip._id); } else { - IPH_ID_SET(&cs->cs_ip, ntohs(IPH_ID(&cs->cs_ip)) + 1); - IPH_ID_SET(&cs->cs_ip, htons(IPH_ID(&cs->cs_ip))); + IPH_ID_SET(&cs->cs_ip, lwip_ntohs(IPH_ID(&cs->cs_ip)) + 1); + IPH_ID_SET(&cs->cs_ip, lwip_htons(IPH_ID(&cs->cs_ip))); } /* @@ -607,9 +607,9 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) #if BYTE_ORDER == LITTLE_ENDIAN tmp = n0->tot_len - vjlen + cs->cs_hlen; - IPH_LEN_SET(&cs->cs_ip, htons((u16_t)tmp)); + IPH_LEN_SET(&cs->cs_ip, lwip_htons((u16_t)tmp)); #else - IPH_LEN_SET(&cs->cs_ip, htons(n0->tot_len - vjlen + cs->cs_hlen)); + IPH_LEN_SET(&cs->cs_ip, lwip_htons(n0->tot_len - vjlen + cs->cs_hlen)); #endif /* recompute the ip header checksum */