mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-25 07:33:11 +00:00
Even more pbuf_header -> pbuf_add/remove_header replacements (also in strings)
This commit is contained in:
parent
07434aa73a
commit
991f751305
@ -459,10 +459,8 @@ altcp_mbedtls_bio_recv(void *ctx, unsigned char *buf, size_t len)
|
|||||||
}
|
}
|
||||||
return MBEDTLS_ERR_SSL_WANT_READ;
|
return MBEDTLS_ERR_SSL_WANT_READ;
|
||||||
}
|
}
|
||||||
/* limit number of bytes to copy to fit into an s16_t for pbuf_header */
|
|
||||||
copy_len = (u16_t)LWIP_MIN(len, 0x7FFF);
|
|
||||||
/* limit number of bytes again to copy from first pbuf in a chain only */
|
/* limit number of bytes again to copy from first pbuf in a chain only */
|
||||||
copy_len = LWIP_MIN(copy_len, p->len);
|
copy_len = (u16_t)LWIP_MIN(len, p->len);
|
||||||
/* copy the data */
|
/* copy the data */
|
||||||
ret = pbuf_copy_partial(p, buf, copy_len, 0);
|
ret = pbuf_copy_partial(p, buf, copy_len, 0);
|
||||||
LWIP_ASSERT("ret == copy_len", ret == copy_len);
|
LWIP_ASSERT("ret == copy_len", ret == copy_len);
|
||||||
|
@ -472,7 +472,7 @@ lwiperf_tcp_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
|
|||||||
}
|
}
|
||||||
conn->next_num = 4; /* 24 bytes received... */
|
conn->next_num = 4; /* 24 bytes received... */
|
||||||
tmp = pbuf_remove_header(p, 24);
|
tmp = pbuf_remove_header(p, 24);
|
||||||
LWIP_ASSERT("pbuf_header failed", tmp == 0);
|
LWIP_ASSERT("pbuf_remove_header failed", tmp == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_idx = 0;
|
packet_idx = 0;
|
||||||
|
@ -495,7 +495,7 @@ pbuf_add_header_impl(struct pbuf *p, size_t header_size_increment, u8_t force)
|
|||||||
/* boundary check fails? */
|
/* boundary check fails? */
|
||||||
if ((u8_t *)payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) {
|
if ((u8_t *)payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) {
|
||||||
LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE,
|
LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE,
|
||||||
("pbuf_header: failed as %p < %p (not enough space for new header size)\n",
|
("pbuf_add_header: failed as %p < %p (not enough space for new header size)\n",
|
||||||
(void *)payload, (void *)((u8_t *)p + SIZEOF_STRUCT_PBUF)));
|
(void *)payload, (void *)((u8_t *)p + SIZEOF_STRUCT_PBUF)));
|
||||||
/* bail out unsuccessfully */
|
/* bail out unsuccessfully */
|
||||||
return 1;
|
return 1;
|
||||||
@ -511,7 +511,7 @@ pbuf_add_header_impl(struct pbuf *p, size_t header_size_increment, u8_t force)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"U16_F")\n",
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_add_header: old %p new %p (%"U16_F")\n",
|
||||||
(void *)p->payload, (void *)payload, increment_magnitude));
|
(void *)p->payload, (void *)payload, increment_magnitude));
|
||||||
|
|
||||||
/* modify pbuf fields */
|
/* modify pbuf fields */
|
||||||
@ -605,7 +605,7 @@ pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
|
|||||||
p->len = (u16_t)(p->len - increment_magnitude);
|
p->len = (u16_t)(p->len - increment_magnitude);
|
||||||
p->tot_len = (u16_t)(p->tot_len - increment_magnitude);
|
p->tot_len = (u16_t)(p->tot_len - increment_magnitude);
|
||||||
|
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"U16_F")\n",
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_remove_header: old %p new %p (%"U16_F")\n",
|
||||||
(void *)payload, (void *)p->payload, increment_magnitude));
|
(void *)payload, (void *)p->payload, increment_magnitude));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -344,7 +344,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
#endif /* CHECKSUM_CHECK_UDP */
|
#endif /* CHECKSUM_CHECK_UDP */
|
||||||
if (pbuf_remove_header(p, UDP_HLEN)) {
|
if (pbuf_remove_header(p, UDP_HLEN)) {
|
||||||
/* Can we cope with this failing? Just assert for now */
|
/* Can we cope with this failing? Just assert for now */
|
||||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
LWIP_ASSERT("pbuf_remove_header failed\n", 0);
|
||||||
UDP_STATS_INC(udp.drop);
|
UDP_STATS_INC(udp.drop);
|
||||||
MIB2_STATS_INC(mib2.udpinerrors);
|
MIB2_STATS_INC(mib2.udpinerrors);
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
|
@ -257,7 +257,7 @@ mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t proto
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reveal MPPE header */
|
/* Reveal MPPE header */
|
||||||
pbuf_header(np, (s16_t)MPPE_OVHD);
|
pbuf_add_header(np, MPPE_OVHD);
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
@ -957,7 +957,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
|||||||
#endif /* PPP_PROTOCOLNAME */
|
#endif /* PPP_PROTOCOLNAME */
|
||||||
ppp_warn("Unsupported protocol 0x%x received", protocol);
|
ppp_warn("Unsupported protocol 0x%x received", protocol);
|
||||||
#endif /* PPP_DEBUG */
|
#endif /* PPP_DEBUG */
|
||||||
pbuf_header(pb, (s16_t)sizeof(protocol));
|
pbuf_add_header(pb, sizeof(protocol));
|
||||||
lcp_sprotrej(pcb, (u8_t*)pb->payload, pb->len);
|
lcp_sprotrej(pcb, (u8_t*)pb->payload, pb->len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -662,7 +662,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
|||||||
#endif
|
#endif
|
||||||
if (pbuf_remove_header(pb, sizeof(struct eth_hdr)) != 0) {
|
if (pbuf_remove_header(pb, sizeof(struct eth_hdr)) != 0) {
|
||||||
/* bail out */
|
/* bail out */
|
||||||
PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header failed\n"));
|
PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_remove_header failed\n"));
|
||||||
LINK_STATS_INC(link.lenerr);
|
LINK_STATS_INC(link.lenerr);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
@ -695,7 +695,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
|||||||
|
|
||||||
if (pbuf_remove_header(pb, PPPOE_HEADERLEN) != 0) {
|
if (pbuf_remove_header(pb, PPPOE_HEADERLEN) != 0) {
|
||||||
/* bail out */
|
/* bail out */
|
||||||
PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n"));
|
PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_remove_header PPPOE_HEADERLEN failed\n"));
|
||||||
LINK_STATS_INC(link.lenerr);
|
LINK_STATS_INC(link.lenerr);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
@ -724,7 +724,7 @@ pppoe_output(struct pppoe_softc *sc, struct pbuf *pb)
|
|||||||
err_t res;
|
err_t res;
|
||||||
|
|
||||||
/* make room for Ethernet header - should not fail */
|
/* make room for Ethernet header - should not fail */
|
||||||
if (pbuf_header(pb, (s16_t)(sizeof(struct eth_hdr))) != 0) {
|
if (pbuf_add_header(pb, sizeof(struct eth_hdr)) != 0) {
|
||||||
/* bail out */
|
/* bail out */
|
||||||
PPPDEBUG(LOG_ERR, ("pppoe: %c%c%"U16_F": pppoe_output: could not allocate room for Ethernet header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
PPPDEBUG(LOG_ERR, ("pppoe: %c%c%"U16_F": pppoe_output: could not allocate room for Ethernet header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
||||||
LINK_STATS_INC(link.lenerr);
|
LINK_STATS_INC(link.lenerr);
|
||||||
@ -1043,7 +1043,7 @@ pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest)
|
|||||||
}
|
}
|
||||||
LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len);
|
LWIP_ASSERT("pb->tot_len == pb->len", pb->tot_len == pb->len);
|
||||||
|
|
||||||
pbuf_header(pb, (s16_t)sizeof(struct eth_hdr));
|
pbuf_add_header(pb, sizeof(struct eth_hdr));
|
||||||
ethhdr = (struct eth_hdr *)pb->payload;
|
ethhdr = (struct eth_hdr *)pb->payload;
|
||||||
ethhdr->type = PP_HTONS(ETHTYPE_PPPOEDISC);
|
ethhdr->type = PP_HTONS(ETHTYPE_PPPOEDISC);
|
||||||
MEMCPY(ðhdr->dest.addr, dest, sizeof(ethhdr->dest.addr));
|
MEMCPY(ðhdr->dest.addr, dest, sizeof(ethhdr->dest.addr));
|
||||||
@ -1137,7 +1137,7 @@ pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb)
|
|||||||
len = pb->tot_len;
|
len = pb->tot_len;
|
||||||
|
|
||||||
/* make room for PPPoE header - should not fail */
|
/* make room for PPPoE header - should not fail */
|
||||||
if (pbuf_header(pb, (s16_t)(PPPOE_HEADERLEN)) != 0) {
|
if (pbuf_add_header(pb, PPPOE_HEADERLEN) != 0) {
|
||||||
/* bail out */
|
/* bail out */
|
||||||
PPPDEBUG(LOG_ERR, ("pppoe: %c%c%"U16_F": pppoe_xmit: could not allocate room for PPPoE header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
PPPDEBUG(LOG_ERR, ("pppoe: %c%c%"U16_F": pppoe_xmit: could not allocate room for PPPoE header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
||||||
LINK_STATS_INC(link.lenerr);
|
LINK_STATS_INC(link.lenerr);
|
||||||
|
@ -1108,7 +1108,7 @@ static err_t pppol2tp_xmit(pppol2tp_pcb *l2tp, struct pbuf *pb) {
|
|||||||
u8_t *p;
|
u8_t *p;
|
||||||
|
|
||||||
/* make room for L2TP header - should not fail */
|
/* make room for L2TP header - should not fail */
|
||||||
if (pbuf_header(pb, (s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN) != 0) {
|
if (pbuf_add_header(pb, PPPOL2TP_OUTPUT_DATA_HEADER_LEN) != 0) {
|
||||||
/* bail out */
|
/* bail out */
|
||||||
PPPDEBUG(LOG_ERR, ("pppol2tp: pppol2tp_pcb: could not allocate room for L2TP header\n"));
|
PPPDEBUG(LOG_ERR, ("pppol2tp: pppol2tp_pcb: could not allocate room for L2TP header\n"));
|
||||||
LINK_STATS_INC(link.lenerr);
|
LINK_STATS_INC(link.lenerr);
|
||||||
|
@ -705,7 +705,7 @@ static void pppos_input_callback(void *arg) {
|
|||||||
|
|
||||||
ppp = ((struct pppos_input_header*)pb->payload)->ppp;
|
ppp = ((struct pppos_input_header*)pb->payload)->ppp;
|
||||||
if(pbuf_remove_header(pb, sizeof(struct pppos_input_header))) {
|
if(pbuf_remove_header(pb, sizeof(struct pppos_input_header))) {
|
||||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
LWIP_ASSERT("pbuf_remove_header failed\n", 0);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb)
|
|||||||
hlen -= deltaS + 4;
|
hlen -= deltaS + 4;
|
||||||
if (pbuf_remove_header(np, hlen)){
|
if (pbuf_remove_header(np, hlen)){
|
||||||
/* Can we cope with this failing? Just assert for now */
|
/* Can we cope with this failing? Just assert for now */
|
||||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
LWIP_ASSERT("pbuf_remove_header failed\n", 0);
|
||||||
}
|
}
|
||||||
cp = (u8_t*)np->payload;
|
cp = (u8_t*)np->payload;
|
||||||
*cp++ = (u8_t)(changes | NEW_C);
|
*cp++ = (u8_t)(changes | NEW_C);
|
||||||
@ -418,7 +418,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb)
|
|||||||
hlen -= deltaS + 3;
|
hlen -= deltaS + 3;
|
||||||
if (pbuf_remove_header(np, hlen)) {
|
if (pbuf_remove_header(np, hlen)) {
|
||||||
/* Can we cope with this failing? Just assert for now */
|
/* Can we cope with this failing? Just assert for now */
|
||||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
LWIP_ASSERT("pbuf_remove_header failed\n", 0);
|
||||||
}
|
}
|
||||||
cp = (u8_t*)np->payload;
|
cp = (u8_t*)np->payload;
|
||||||
*cp++ = (u8_t)changes;
|
*cp++ = (u8_t)changes;
|
||||||
@ -621,7 +621,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
|
|||||||
/* Remove the compressed header and prepend the uncompressed header. */
|
/* Remove the compressed header and prepend the uncompressed header. */
|
||||||
if (pbuf_remove_header(n0, vjlen)) {
|
if (pbuf_remove_header(n0, vjlen)) {
|
||||||
/* Can we cope with this failing? Just assert for now */
|
/* Can we cope with this failing? Just assert for now */
|
||||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
LWIP_ASSERT("pbuf_remove_header failed\n", 0);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +644,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
|
|||||||
|
|
||||||
if (pbuf_remove_header(np, cs->cs_hlen)) {
|
if (pbuf_remove_header(np, cs->cs_hlen)) {
|
||||||
/* Can we cope with this failing? Just assert for now */
|
/* Can we cope with this failing? Just assert for now */
|
||||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
LWIP_ASSERT("pbuf_remove_header failed\n", 0);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user