mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-12 10:33:37 +08:00
More pbuf_header -> pbuf_add/remove_header replacements
This commit is contained in:
@@ -207,7 +207,7 @@ mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t proto
|
||||
}
|
||||
|
||||
/* Hide MPPE header + protocol */
|
||||
pbuf_header(np, -(s16_t)(MPPE_OVHD + sizeof(protocol)));
|
||||
pbuf_remove_header(np, MPPE_OVHD + sizeof(protocol));
|
||||
|
||||
if ((err = pbuf_copy(np, *pb)) != ERR_OK) {
|
||||
pbuf_free(np);
|
||||
@@ -215,7 +215,7 @@ mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t proto
|
||||
}
|
||||
|
||||
/* Reveal MPPE header + protocol */
|
||||
pbuf_header(np, (s16_t)(MPPE_OVHD + sizeof(protocol)));
|
||||
pbuf_add_header(np, MPPE_OVHD + sizeof(protocol));
|
||||
|
||||
*pb = np;
|
||||
pl = (u8_t*)np->payload;
|
||||
@@ -246,7 +246,7 @@ mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t proto
|
||||
pl[1] = protocol;
|
||||
|
||||
/* Hide MPPE header */
|
||||
pbuf_header(np, -(s16_t)MPPE_OVHD);
|
||||
pbuf_remove_header(np, MPPE_OVHD);
|
||||
|
||||
/* Encrypt packet */
|
||||
for (n = np; n != NULL; n = n->next) {
|
||||
@@ -382,7 +382,7 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb)
|
||||
}
|
||||
|
||||
/* Hide MPPE header */
|
||||
pbuf_header(n0, -(s16_t)(MPPE_OVHD));
|
||||
pbuf_remove_header(n0, MPPE_OVHD);
|
||||
|
||||
/* Decrypt the packet. */
|
||||
for (n = n0; n != NULL; n = n->next) {
|
||||
|
||||
@@ -784,7 +784,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
ppp_dump_packet(pcb, "rcvd", (unsigned char *)pb->payload, pb->len);
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
|
||||
pbuf_header(pb, -(s16_t)sizeof(protocol));
|
||||
pbuf_remove_header(pb, sizeof(protocol));
|
||||
|
||||
LINK_STATS_INC(link.recv);
|
||||
MIB2_STATS_NETIF_INC(pcb->netif, ifinucastpkts);
|
||||
@@ -860,10 +860,10 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
pl = (u8_t*)pb->payload;
|
||||
if (pl[0] & 0x01) {
|
||||
protocol = pl[0];
|
||||
pbuf_header(pb, -(s16_t)1);
|
||||
pbuf_remove_header(pb, 1);
|
||||
} else {
|
||||
protocol = (pl[0] << 8) | pl[1];
|
||||
pbuf_header(pb, -(s16_t)2);
|
||||
pbuf_remove_header(pb, 2);
|
||||
}
|
||||
}
|
||||
#endif /* CCP_SUPPORT */
|
||||
|
||||
@@ -210,7 +210,7 @@ static err_t pppoe_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
|
||||
#endif /* MIB2_STATS */
|
||||
|
||||
/* skip address & flags */
|
||||
pbuf_header(p, -(s16_t)2);
|
||||
pbuf_remove_header(p, 2);
|
||||
|
||||
ph = pbuf_alloc(PBUF_LINK, (u16_t)(PPPOE_HEADERLEN), PBUF_RAM);
|
||||
if(!ph) {
|
||||
@@ -221,7 +221,7 @@ static err_t pppoe_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
pbuf_header(ph, -(s16_t)PPPOE_HEADERLEN); /* hide PPPoE header */
|
||||
pbuf_remove_header(ph, PPPOE_HEADERLEN); /* hide PPPoE header */
|
||||
pbuf_cat(ph, p);
|
||||
#if MIB2_STATS
|
||||
tot_len = ph->tot_len;
|
||||
@@ -261,7 +261,7 @@ static err_t pppoe_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_short
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
pbuf_header(pb, -(s16_t)PPPOE_HEADERLEN);
|
||||
pbuf_remove_header(pb, PPPOE_HEADERLEN);
|
||||
|
||||
pl = (u8_t*)pb->payload;
|
||||
PUTSHORT(protocol, pl);
|
||||
@@ -660,7 +660,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
||||
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
|
||||
MEMCPY(shost, ((struct eth_hdr *)pb->payload)->src.addr, sizeof(shost));
|
||||
#endif
|
||||
if (pbuf_header(pb, -(s16_t)sizeof(struct eth_hdr)) != 0) {
|
||||
if (pbuf_remove_header(pb, sizeof(struct eth_hdr)) != 0) {
|
||||
/* bail out */
|
||||
PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header failed\n"));
|
||||
LINK_STATS_INC(link.lenerr);
|
||||
@@ -693,7 +693,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
||||
|
||||
plen = lwip_ntohs(ph->plen);
|
||||
|
||||
if (pbuf_header(pb, -(s16_t)(PPPOE_HEADERLEN)) != 0) {
|
||||
if (pbuf_remove_header(pb, PPPOE_HEADERLEN) != 0) {
|
||||
/* bail out */
|
||||
PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n"));
|
||||
LINK_STATS_INC(link.lenerr);
|
||||
|
||||
@@ -181,7 +181,7 @@ static err_t pppol2tp_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
pbuf_header(ph, -(s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN); /* hide L2TP header */
|
||||
pbuf_remove_header(ph, PPPOL2TP_OUTPUT_DATA_HEADER_LEN); /* hide L2TP header */
|
||||
pbuf_cat(ph, p);
|
||||
#if MIB2_STATS
|
||||
tot_len = ph->tot_len;
|
||||
@@ -221,7 +221,7 @@ static err_t pppol2tp_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_sh
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
pbuf_header(pb, -(s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN);
|
||||
pbuf_remove_header(pb, PPPOL2TP_OUTPUT_DATA_HEADER_LEN);
|
||||
|
||||
pl = (u8_t*)pb->payload;
|
||||
PUTSHORT(protocol, pl);
|
||||
@@ -434,7 +434,7 @@ static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, const
|
||||
/* printf("HLEN = %d\n", hlen); */
|
||||
|
||||
/* skip L2TP header */
|
||||
if (pbuf_header(p, -(s16_t)hlen) != 0) {
|
||||
if (pbuf_remove_header(p, hlen) != 0) {
|
||||
goto free_and_return;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, const
|
||||
if (p->len >= 2) {
|
||||
GETSHORT(hflags, inp);
|
||||
if (hflags == 0xff03) {
|
||||
pbuf_header(p, -(s16_t)2);
|
||||
pbuf_remove_header(p, 2);
|
||||
}
|
||||
}
|
||||
/* Dispatch the packet thereby consuming it. */
|
||||
@@ -654,7 +654,7 @@ skipavp:
|
||||
nextavp:
|
||||
/* printf("AVP Found, vendor=%d, attribute=%d, len=%d\n", vendorid, attributetype, avplen); */
|
||||
/* next AVP */
|
||||
if (pbuf_header(p, -(s16_t)(avplen + sizeof(avpflags) + sizeof(vendorid) + sizeof(attributetype)) ) != 0) {
|
||||
if (pbuf_remove_header(p, avplen + sizeof(avpflags) + sizeof(vendorid) + sizeof(attributetype)) != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l)
|
||||
pppos->in_tail = NULL;
|
||||
#if IP_FORWARD || LWIP_IPV6_FORWARD
|
||||
/* hide the room for Ethernet forwarding header */
|
||||
pbuf_header(inp, -(s16_t)(PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN));
|
||||
pbuf_remove_header(inp, PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN);
|
||||
#endif /* IP_FORWARD || LWIP_IPV6_FORWARD */
|
||||
#if PPP_INPROC_IRQ_SAFE
|
||||
if(tcpip_try_callback(pppos_input_callback, inp) != ERR_OK) {
|
||||
@@ -704,7 +704,7 @@ static void pppos_input_callback(void *arg) {
|
||||
ppp_pcb *ppp;
|
||||
|
||||
ppp = ((struct pppos_input_header*)pb->payload)->ppp;
|
||||
if(pbuf_header(pb, -(s16_t)sizeof(struct pppos_input_header))) {
|
||||
if(pbuf_remove_header(pb, sizeof(struct pppos_input_header))) {
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb)
|
||||
if (!comp->compressSlot || comp->last_xmit != cs->cs_id) {
|
||||
comp->last_xmit = cs->cs_id;
|
||||
hlen -= deltaS + 4;
|
||||
if (pbuf_header(np, -(s16_t)hlen)){
|
||||
if (pbuf_remove_header(np, hlen)){
|
||||
/* Can we cope with this failing? Just assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
}
|
||||
@@ -416,7 +416,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb)
|
||||
*cp++ = cs->cs_id;
|
||||
} else {
|
||||
hlen -= deltaS + 3;
|
||||
if (pbuf_header(np, -(s16_t)hlen)) {
|
||||
if (pbuf_remove_header(np, hlen)) {
|
||||
/* Can we cope with this failing? Just assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
}
|
||||
@@ -619,7 +619,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
|
||||
IPH_CHKSUM_SET(&cs->cs_ip, (u16_t)(~tmp));
|
||||
|
||||
/* Remove the compressed header and prepend the uncompressed header. */
|
||||
if (pbuf_header(n0, -(s16_t)vjlen)) {
|
||||
if (pbuf_remove_header(n0, vjlen)) {
|
||||
/* Can we cope with this failing? Just assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
goto bad;
|
||||
@@ -642,7 +642,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (pbuf_header(np, -(s16_t)cs->cs_hlen)) {
|
||||
if (pbuf_remove_header(np, cs->cs_hlen)) {
|
||||
/* Can we cope with this failing? Just assert for now */
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
goto bad;
|
||||
@@ -658,7 +658,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
|
||||
n0 = np;
|
||||
}
|
||||
|
||||
if (pbuf_header(n0, (s16_t)cs->cs_hlen)) {
|
||||
if (pbuf_add_header(n0, cs->cs_hlen)) {
|
||||
struct pbuf *np;
|
||||
|
||||
LWIP_ASSERT("vj_uncompress_tcp: cs->cs_hlen <= PBUF_POOL_BUFSIZE", cs->cs_hlen <= PBUF_POOL_BUFSIZE);
|
||||
|
||||
Reference in New Issue
Block a user