pub unsafe extern "C" fn gnrc_pktbuf_merge(
pkt: *mut gnrc_pktsnip_t,
) -> c_int
Expand description
@brief Merge pktsnip chain to single pktsnip.
Specifically it calls @ref gnrc_pktbuf_realloc_data() on @p pkt, then copies the data of all following packet snips into that reallocated space, and removes the packet snip the data was copied from afterwards.
§Example
§Input
buffer
+---------------------------+ +------+
| size = 8 | data +-------->| |
| type = NETTYPE_IPV6 |------------+ +------+
+---------------------------+ . .
| next . .
v . .
+---------------------------+ +------+
| size = 40 | data +----------->| |
| type = NETTYPE_UDP |---------+ +------+
+---------------------------+ . .
| next . .
v
+---------------------------+ +------+
| size = 14 | data +-------------->| |
| type = NETTYPE_UNDEF |------+ +------+
+---------------------------+ . .
§Output
buffer
+---------------------------+ +------+
| size = 62 | data +-------->| |
| type = NETTYPE_IPV6 |------------+ | |
+---------------------------+ | |
| |
| |
| |
+------+
. .
@warning @p pkt needs to write protected before calling this function. @note Packets in receive order need to call @ref gnrc_pktbuf_reverse_snips() first to get the data in the correct order.
@param[in,out] pkt The snip to merge.
@return 0, on success @return ENOMEM, if no space is left in the packet buffer.