MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pbuf_remove_header

Function pbuf_remove_header

components/net/lwip/lwip-2.1.2/src/core/pbuf.c:581–613  ·  view source on GitHub ↗

* Adjusts the payload pointer to hide headers in the payload. * * Adjusts the ->payload pointer so that space for a header * disappears in the pbuf payload. * * The ->payload, ->tot_len and ->len fields are adjusted. * * @param p pbuf to change the header size. * @param header_size_decrement Number of bytes to decrement header size which * decreases the size of the pbuf. *

Source from the content-addressed store, hash-verified

579 *
580 */
581u8_t
582pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
583{
584 void *payload;
585 u16_t increment_magnitude;
586
587 LWIP_ASSERT("p != NULL", p != NULL);
588 if ((p == NULL) || (header_size_decrement > 0xFFFF)) {
589 return 1;
590 }
591 if (header_size_decrement == 0) {
592 return 0;
593 }
594
595 increment_magnitude = (u16_t)header_size_decrement;
596 /* Check that we aren't going to move off the end of the pbuf */
597 LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;);
598
599 /* remember current payload pointer */
600 payload = p->payload;
601 LWIP_UNUSED_ARG(payload); /* only used in LWIP_DEBUGF below */
602
603 /* increase payload pointer (guarded by length check above) */
604 p->payload = (u8_t *)p->payload + header_size_decrement;
605 /* modify pbuf length fields */
606 p->len = (u16_t)(p->len - increment_magnitude);
607 p->tot_len = (u16_t)(p->tot_len - increment_magnitude);
608
609 LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_remove_header: old %p new %p (%"U16_F")\n",
610 (void *)payload, (void *)p->payload, increment_magnitude));
611
612 return 0;
613}
614
615static u8_t
616pbuf_header_impl(struct pbuf *p, s16_t header_size_increment, u8_t force)

Callers 15

pbuf_header_implFunction · 0.85
pbuf_free_headerFunction · 0.85
raw_sendto_if_srcFunction · 0.85
udp_inputFunction · 0.85
tcp_in.cFile · 0.85
tcp_receiveFunction · 0.85
mld6_sendFunction · 0.85
ip6_reassFunction · 0.85
ip6.cFile · 0.85
ip4_reassFunction · 0.85
ip4.cFile · 0.85
icmp_inputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected