mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 01:23:48 +08:00
task #14597: cleanup pbuf_header usages (use pbuf_add_header/pbuf_remove_header instead)
This commit is contained in:
@@ -152,7 +152,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
}
|
||||
#endif
|
||||
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
||||
if (pbuf_header(p, (s16_t)(hlen + PBUF_LINK_HLEN + PBUF_LINK_ENCAPSULATION_HLEN))) {
|
||||
if (pbuf_add_header(p, hlen + PBUF_LINK_HLEN + PBUF_LINK_ENCAPSULATION_HLEN)) {
|
||||
/* p is not big enough to contain link headers
|
||||
* allocate a new one and copy p into it
|
||||
*/
|
||||
@@ -176,7 +176,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
/* copy the ip header */
|
||||
MEMCPY(r->payload, iphdr_in, hlen);
|
||||
/* switch r->payload back to icmp header (cannot fail) */
|
||||
if (pbuf_header(r, (s16_t)-hlen)) {
|
||||
if (pbuf_remove_header(r, hlen)) {
|
||||
LWIP_ASSERT("icmp_input: moving r->payload to icmp header failed\n", 0);
|
||||
pbuf_free(r);
|
||||
goto icmperr;
|
||||
@@ -193,7 +193,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
p = r;
|
||||
} else {
|
||||
/* restore p->payload to point to icmp header (cannot fail) */
|
||||
if (pbuf_header(p, (s16_t)-(s16_t)(hlen + PBUF_LINK_HLEN + PBUF_LINK_ENCAPSULATION_HLEN))) {
|
||||
if (pbuf_remove_header(p, hlen + PBUF_LINK_HLEN + PBUF_LINK_ENCAPSULATION_HLEN)) {
|
||||
LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0);
|
||||
goto icmperr;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
/* We generate an answer by switching the dest and src ip addresses,
|
||||
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
||||
iecho = (struct icmp_echo_hdr *)p->payload;
|
||||
if (pbuf_header(p, (s16_t)hlen)) {
|
||||
if (pbuf_add_header(p, hlen)) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Can't move over header in packet"));
|
||||
} else {
|
||||
err_t ret;
|
||||
|
||||
@@ -674,7 +674,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
if (raw_input(p, inp) == 0)
|
||||
#endif /* LWIP_RAW */
|
||||
{
|
||||
pbuf_header(p, (s16_t)-(s16_t)iphdr_hlen); /* Move to payload, no check necessary. */
|
||||
pbuf_remove_header(p, iphdr_hlen); /* Move to payload, no check necessary. */
|
||||
|
||||
switch (IPH_PROTO(iphdr)) {
|
||||
#if LWIP_UDP
|
||||
@@ -847,7 +847,7 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d
|
||||
optlen_aligned = (u16_t)((optlen + 3) & ~3);
|
||||
ip_hlen = (u16_t)(ip_hlen + optlen_aligned);
|
||||
/* First write in the IP options */
|
||||
if (pbuf_header(p, (s16_t)optlen_aligned)) {
|
||||
if (pbuf_add_header(p, optlen_aligned)) {
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip4_output_if_opt: not enough room for IP options in pbuf\n"));
|
||||
IP_STATS_INC(ip.err);
|
||||
MIB2_STATS_INC(mib2.ipoutdiscards);
|
||||
@@ -866,7 +866,7 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d
|
||||
}
|
||||
#endif /* IP_OPTIONS_SEND */
|
||||
/* generate IP header */
|
||||
if (pbuf_header(p, IP_HLEN)) {
|
||||
if (pbuf_add_header(p, IP_HLEN)) {
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip4_output: not enough room for IP header in pbuf\n"));
|
||||
|
||||
IP_STATS_INC(ip.err);
|
||||
|
||||
@@ -651,7 +651,7 @@ ip4_reass(struct pbuf *p)
|
||||
iprh = (struct ip_reass_helper*)r->payload;
|
||||
|
||||
/* hide the ip header for every succeeding fragment */
|
||||
pbuf_header(r, -IP_HLEN);
|
||||
pbuf_remove_header(r, IP_HLEN);
|
||||
pbuf_cat(p, r);
|
||||
r = iprh->next_pbuf;
|
||||
}
|
||||
@@ -779,7 +779,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
|
||||
(rambuf->len == rambuf->tot_len) && (rambuf->next == NULL));
|
||||
poff += pbuf_copy_partial(p, rambuf->payload, fragsize, poff);
|
||||
/* make room for the IP header */
|
||||
if (pbuf_header(rambuf, IP_HLEN)) {
|
||||
if (pbuf_add_header(rambuf, IP_HLEN)) {
|
||||
pbuf_free(rambuf);
|
||||
goto memerr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user