task #14597: cleanup pbuf_header usages (use pbuf_add_header/pbuf_remove_header instead)

This commit is contained in:
goldsimon
2017-08-04 22:38:11 +02:00
parent 1981cf39d1
commit a1c7924cb6
16 changed files with 59 additions and 59 deletions

View File

@@ -83,7 +83,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
struct eth_hdr* ethhdr;
u16_t type;
#if LWIP_ARP || ETHARP_SUPPORT_VLAN || LWIP_IPV6
s16_t ip_hdr_offset = SIZEOF_ETH_HDR;
u16_t next_hdr_offset = SIZEOF_ETH_HDR;
#endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */
if (p->len <= SIZEOF_ETH_HDR) {
@@ -133,7 +133,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
}
#endif /* defined(LWIP_HOOK_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) */
type = vlan->tpid;
ip_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR;
next_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR;
}
#endif /* ETHARP_SUPPORT_VLAN */
@@ -173,10 +173,10 @@ ethernet_input(struct pbuf *p, struct netif *netif)
goto free_and_return;
}
/* skip Ethernet header */
if ((p->len < ip_hdr_offset) || pbuf_header(p, (s16_t)-ip_hdr_offset)) {
if ((p->len < next_hdr_offset) || pbuf_remove_header(p, next_hdr_offset)) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("ethernet_input: IPv4 packet dropped, too short (%"S16_F"/%"S16_F")\n",
p->tot_len, ip_hdr_offset));
("ethernet_input: IPv4 packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("Can't move over header in packet"));
goto free_and_return;
} else {
@@ -190,10 +190,10 @@ ethernet_input(struct pbuf *p, struct netif *netif)
goto free_and_return;
}
/* skip Ethernet header */
if ((p->len < ip_hdr_offset) || pbuf_header(p, (s16_t)-ip_hdr_offset)) {
if ((p->len < next_hdr_offset) || pbuf_remove_header(p, next_hdr_offset)) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("ethernet_input: ARP response packet dropped, too short (%"S16_F"/%"S16_F")\n",
p->tot_len, ip_hdr_offset));
("ethernet_input: ARP response packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("Can't move over header in packet"));
ETHARP_STATS_INC(etharp.lenerr);
ETHARP_STATS_INC(etharp.drop);
@@ -217,10 +217,10 @@ ethernet_input(struct pbuf *p, struct netif *netif)
#if LWIP_IPV6
case PP_HTONS(ETHTYPE_IPV6): /* IPv6 */
/* skip Ethernet header */
if ((p->len < ip_hdr_offset) || pbuf_header(p, (s16_t)-ip_hdr_offset)) {
if ((p->len < next_hdr_offset) || pbuf_remove_header(p, next_hdr_offset)) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("ethernet_input: IPv6 packet dropped, too short (%"S16_F"/%"S16_F")\n",
p->tot_len, ip_hdr_offset));
("ethernet_input: IPv6 packet dropped, too short (%"U16_F"/%"U16_F")\n",
p->tot_len, next_hdr_offset));
goto free_and_return;
} else {
/* pass to IPv6 layer */

View File

@@ -142,7 +142,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
initiate transfer();
#if ETH_PAD_SIZE
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
pbuf_remove_header(p, ETH_PAD_SIZE); /* drop the padding word */
#endif
for (q = p; q != NULL; q = q->next) {
@@ -165,7 +165,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
/* increase ifoutdiscards or ifouterrors on error */
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
pbuf_add_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
#endif
LINK_STATS_INC(link.xmit);
@@ -202,7 +202,7 @@ low_level_input(struct netif *netif)
if (p != NULL) {
#if ETH_PAD_SIZE
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
pbuf_remove_header(p, ETH_PAD_SIZE); /* drop the padding word */
#endif
/* We iterate over the pbuf chain until we have read the entire
@@ -229,7 +229,7 @@ low_level_input(struct netif *netif)
MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
}
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
pbuf_add_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
#endif
LINK_STATS_INC(link.recv);

View File

@@ -411,7 +411,7 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
}
/* Move to payload. */
pbuf_header(p, -IP6_HLEN);
pbuf_remove_header(p, IP6_HLEN);
#if LWIP_UDP
/* Compress UDP header? */
@@ -451,7 +451,7 @@ lowpan6_frag(struct netif *netif, struct pbuf *p, const struct ieee_802154_addr
buffer[ieee_header_len + lowpan6_header_len++] = ((u8_t *)p->payload)[6];
buffer[ieee_header_len + lowpan6_header_len++] = ((u8_t *)p->payload)[7];
pbuf_header(p, -UDP_HLEN);
pbuf_remove_header(p, UDP_HLEN);
}
#endif /* LWIP_UDP */
}
@@ -695,7 +695,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
{
struct pbuf * q;
u8_t * lowpan6_buffer;
s8_t lowpan6_offset;
u16_t lowpan6_offset;
struct ip6_hdr *ip6hdr;
s8_t i;
s8_t ip6_offset = IP6_HLEN;
@@ -963,7 +963,7 @@ lowpan6_decompress(struct pbuf * p, struct ieee_802154_addr * src, struct ieee_8
/* Now we copy leftover contents from p to q, so we have all L2 and L3 headers (and L4?) in a single PBUF.
* Replace p with q, and free p */
pbuf_header(p, -lowpan6_offset);
pbuf_remove_header(p, lowpan6_offset);
MEMCPY((u8_t*)q->payload + ip6_offset, p->payload, p->len);
q->len = q->tot_len = ip6_offset + p->len;
if (p->next != NULL) {
@@ -1021,7 +1021,7 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
datagram_offset += 2;
}
pbuf_header(p, -datagram_offset); /* hide IEEE802.15.4 header. */
pbuf_remove_header(p, datagram_offset); /* hide IEEE802.15.4 header. */
/* Check dispatch. */
puc = (u8_t*)p->payload;
@@ -1058,7 +1058,7 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
}
}
pbuf_header(p, -4); /* hide frag1 dispatch */
pbuf_remove_header(p, 4); /* hide frag1 dispatch */
lrh = (struct lowpan6_reass_helper *) mem_malloc(sizeof(struct lowpan6_reass_helper));
if (lrh == NULL) {
@@ -1084,7 +1084,7 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
datagram_size = ((u16_t)(puc[0] & 0x07) << 8) | (u16_t)puc[1];
datagram_tag = ((u16_t)puc[2] << 8) | (u16_t)puc[3];
datagram_offset = (u16_t)puc[4] << 3;
pbuf_header(p, -5); /* hide frag1 dispatch */
pbuf_remove_header(p, 5); /* hide frag1 dispatch */
for (lrh = reass_list; lrh != NULL; lrh = lrh->next_packet) {
if ((lrh->sender_addr.addr_len == src.addr_len) &&
@@ -1141,7 +1141,7 @@ lowpan6_input(struct pbuf * p, struct netif *netif)
if (*puc == 0x41) {
/* This is a complete IPv6 packet, just skip dispatch byte. */
pbuf_header(p, -1); /* hide dispatch byte. */
pbuf_remove_header(p, 1); /* hide dispatch byte. */
} else if ((*puc & 0xe0 )== 0x60) {
/* IPv6 headers are compressed using IPHC. */
p = lowpan6_decompress(p, &src, &dest);