mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 17:43:39 +08:00
Cleanup hton*/ntoh* function handling and platform abstraction
Let lwip use functions/macros prefixed by lwip_ internally to avoid naming clashes with external #includes. Remove over-complicated #define handling in def.h Make functions easier to override in cc.h. The following is sufficient now (no more LWIP_PLATFORM_BYTESWAP): #define lwip_htons(x) <your_htons> #define lwip_htonl(x) <your_htonl>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user