Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
net_pkt.h File Reference

Network packet buffer descriptor API. More...

Go to the source code of this file.

Data Structures

struct  net_pkt
 Network packet. More...
 

Macros

#define NET_PKT_SLAB_DEFINE(name, count)
 Create a net_pkt slab.
 
#define NET_PKT_DATA_POOL_DEFINE(name, count)
 Create a data fragment net_buf pool.
 
#define net_pkt_print_frags(pkt)
 

Functions

struct net_bufnet_pkt_get_reserve_data (struct net_buf_pool *pool, size_t min_len, k_timeout_t timeout)
 Get a data buffer from a given pool.
 
struct net_bufnet_pkt_get_reserve_rx_data (size_t min_len, k_timeout_t timeout)
 Get RX DATA buffer from pool.
 
struct net_bufnet_pkt_get_reserve_tx_data (size_t min_len, k_timeout_t timeout)
 Get TX DATA buffer from pool.
 
struct net_bufnet_pkt_get_frag (struct net_pkt *pkt, size_t min_len, k_timeout_t timeout)
 Get a data fragment that might be from user specific buffer pool or from global DATA pool.
 
void net_pkt_unref (struct net_pkt *pkt)
 Place packet back into the available packets slab.
 
struct net_pktnet_pkt_ref (struct net_pkt *pkt)
 Increase the packet ref count.
 
struct net_bufnet_pkt_frag_ref (struct net_buf *frag)
 Increase the packet fragment ref count.
 
void net_pkt_frag_unref (struct net_buf *frag)
 Decrease the packet fragment ref count.
 
struct net_bufnet_pkt_frag_del (struct net_pkt *pkt, struct net_buf *parent, struct net_buf *frag)
 Delete existing fragment from a packet.
 
void net_pkt_frag_add (struct net_pkt *pkt, struct net_buf *frag)
 Add a fragment to a packet at the end of its fragment list.
 
void net_pkt_frag_insert (struct net_pkt *pkt, struct net_buf *frag)
 Insert a fragment to a packet at the beginning of its fragment list.
 
void net_pkt_compact (struct net_pkt *pkt)
 Compact the fragment list of a packet.
 
void net_pkt_get_info (struct k_mem_slab **rx, struct k_mem_slab **tx, struct net_buf_pool **rx_data, struct net_buf_pool **tx_data)
 Get information about predefined RX, TX and DATA pools.
 
struct net_pktnet_pkt_alloc (k_timeout_t timeout)
 Allocate an initialized net_pkt.
 
struct net_pktnet_pkt_alloc_from_slab (struct k_mem_slab *slab, k_timeout_t timeout)
 Allocate an initialized net_pkt from a specific slab.
 
struct net_pktnet_pkt_rx_alloc (k_timeout_t timeout)
 Allocate an initialized net_pkt for RX.
 
struct net_pktnet_pkt_alloc_on_iface (struct net_if *iface, k_timeout_t timeout)
 Allocate a network packet for a specific network interface.
 
int net_pkt_alloc_buffer (struct net_pkt *pkt, size_t size, enum net_ip_protocol proto, k_timeout_t timeout)
 Allocate buffer for a net_pkt.
 
int net_pkt_alloc_buffer_raw (struct net_pkt *pkt, size_t size, k_timeout_t timeout)
 Allocate buffer for a net_pkt, of specified size, w/o any additional preconditions.
 
struct net_pktnet_pkt_alloc_with_buffer (struct net_if *iface, size_t size, sa_family_t family, enum net_ip_protocol proto, k_timeout_t timeout)
 Allocate a network packet and buffer at once.
 
void net_pkt_append_buffer (struct net_pkt *pkt, struct net_buf *buffer)
 Append a buffer in packet.
 
size_t net_pkt_available_buffer (struct net_pkt *pkt)
 Get available buffer space from a pkt.
 
size_t net_pkt_available_payload_buffer (struct net_pkt *pkt, enum net_ip_protocol proto)
 Get available buffer space for payload from a pkt.
 
void net_pkt_trim_buffer (struct net_pkt *pkt)
 Trim net_pkt buffer.
 
int net_pkt_remove_tail (struct net_pkt *pkt, size_t length)
 Remove length bytes from tail of packet.
 
void net_pkt_cursor_init (struct net_pkt *pkt)
 Initialize net_pkt cursor.
 
static void net_pkt_cursor_backup (struct net_pkt *pkt, struct net_pkt_cursor *backup)
 Backup net_pkt cursor.
 
static void net_pkt_cursor_restore (struct net_pkt *pkt, struct net_pkt_cursor *backup)
 Restore net_pkt cursor from a backup.
 
static void * net_pkt_cursor_get_pos (struct net_pkt *pkt)
 Returns current position of the cursor.
 
int net_pkt_skip (struct net_pkt *pkt, size_t length)
 Skip some data from a net_pkt.
 
int net_pkt_memset (struct net_pkt *pkt, int byte, size_t length)
 Memset some data in a net_pkt.
 
int net_pkt_copy (struct net_pkt *pkt_dst, struct net_pkt *pkt_src, size_t length)
 Copy data from a packet into another one.
 
struct net_pktnet_pkt_clone (struct net_pkt *pkt, k_timeout_t timeout)
 Clone pkt and its buffer.
 
struct net_pktnet_pkt_rx_clone (struct net_pkt *pkt, k_timeout_t timeout)
 Clone pkt and its buffer.
 
struct net_pktnet_pkt_shallow_clone (struct net_pkt *pkt, k_timeout_t timeout)
 Clone pkt and increase the refcount of its buffer.
 
int net_pkt_read (struct net_pkt *pkt, void *data, size_t length)
 Read some data from a net_pkt.
 
static int net_pkt_read_u8 (struct net_pkt *pkt, uint8_t *data)
 Read a byte (uint8_t) from a net_pkt.
 
int net_pkt_read_be16 (struct net_pkt *pkt, uint16_t *data)
 Read uint16_t big endian data from a net_pkt.
 
int net_pkt_read_le16 (struct net_pkt *pkt, uint16_t *data)
 Read uint16_t little endian data from a net_pkt.
 
int net_pkt_read_be32 (struct net_pkt *pkt, uint32_t *data)
 Read uint32_t big endian data from a net_pkt.
 
int net_pkt_write (struct net_pkt *pkt, const void *data, size_t length)
 Write data into a net_pkt.
 
static int net_pkt_write_u8 (struct net_pkt *pkt, uint8_t data)
 Write a byte (uint8_t) data to a net_pkt.
 
static int net_pkt_write_be16 (struct net_pkt *pkt, uint16_t data)
 Write a uint16_t big endian data to a net_pkt.
 
static int net_pkt_write_be32 (struct net_pkt *pkt, uint32_t data)
 Write a uint32_t big endian data to a net_pkt.
 
static int net_pkt_write_le32 (struct net_pkt *pkt, uint32_t data)
 Write a uint32_t little endian data to a net_pkt.
 
static int net_pkt_write_le16 (struct net_pkt *pkt, uint16_t data)
 Write a uint16_t little endian data to a net_pkt.
 
size_t net_pkt_remaining_data (struct net_pkt *pkt)
 Get the amount of data which can be read from current cursor position.
 
int net_pkt_update_length (struct net_pkt *pkt, size_t length)
 Update the overall length of a packet.
 
int net_pkt_pull (struct net_pkt *pkt, size_t length)
 Remove data from the packet at current location.
 
uint16_t net_pkt_get_current_offset (struct net_pkt *pkt)
 Get the actual offset in the packet from its cursor.
 
bool net_pkt_is_contiguous (struct net_pkt *pkt, size_t size)
 Check if a data size could fit contiguously.
 
size_t net_pkt_get_contiguous_len (struct net_pkt *pkt)
 Get the contiguous buffer space.
 
void * net_pkt_get_data (struct net_pkt *pkt, struct net_pkt_data_access *access)
 Get data from a network packet in a contiguous way.
 
int net_pkt_set_data (struct net_pkt *pkt, struct net_pkt_data_access *access)
 Set contiguous data into a network packet.
 
static int net_pkt_acknowledge_data (struct net_pkt *pkt, struct net_pkt_data_access *access)
 Acknowledge previously contiguous data taken from a network packet Packet needs to be set to overwrite mode.
 

Detailed Description

Network packet buffer descriptor API.

Network data is passed between different parts of the stack via net_buf struct.