Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Network packet buffer descriptor API. More...
#include <zephyr/types.h>
#include <stdbool.h>
#include <net/buf.h>
#include <net/net_core.h>
#include <net/net_linkaddr.h>
#include <net/net_ip.h>
#include <net/net_if.h>
#include <net/net_context.h>
#include <net/ethernet_vlan.h>
#include <net/ptp_time.h>
Go to the source code of this file.
Data Structures | |
struct | net_pkt_cursor |
struct | net_pkt |
Network packet. More... | |
struct | net_pkt_data_access |
Macros | |
#define | NET_PKT_SLAB_DEFINE(name, count) K_MEM_SLAB_DEFINE(name, sizeof(struct net_pkt), count, 4) |
Create a net_pkt slab. More... | |
#define | NET_PKT_TX_SLAB_DEFINE(name, count) NET_PKT_SLAB_DEFINE(name, count) |
#define | NET_PKT_DATA_POOL_DEFINE(name, count) |
Create a data fragment net_buf pool. More... | |
#define | net_pkt_print_frags(pkt) |
Print fragment list and the fragment sizes. More... | |
#define | NET_PKT_DATA_ACCESS_DEFINE(_name, _type) |
#define | NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) |
Functions | |
struct net_buf * | net_pkt_get_reserve_rx_data (k_timeout_t timeout) |
Get RX DATA buffer from pool. Normally you should use net_pkt_get_frag() instead. More... | |
struct net_buf * | net_pkt_get_reserve_tx_data (k_timeout_t timeout) |
Get TX DATA buffer from pool. Normally you should use net_pkt_get_frag() instead. More... | |
struct net_buf * | net_pkt_get_frag (struct net_pkt *pkt, k_timeout_t timeout) |
Get a data fragment that might be from user specific buffer pool or from global DATA pool. More... | |
void | net_pkt_unref (struct net_pkt *pkt) |
Place packet back into the available packets slab. More... | |
struct net_pkt * | net_pkt_ref (struct net_pkt *pkt) |
Increase the packet ref count. More... | |
struct net_buf * | net_pkt_frag_ref (struct net_buf *frag) |
Increase the packet fragment ref count. More... | |
void | net_pkt_frag_unref (struct net_buf *frag) |
Decrease the packet fragment ref count. More... | |
struct net_buf * | net_pkt_frag_del (struct net_pkt *pkt, struct net_buf *parent, struct net_buf *frag) |
Delete existing fragment from a packet. More... | |
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. More... | |
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. More... | |
bool | net_pkt_compact (struct net_pkt *pkt) |
Compact the fragment list of a packet. More... | |
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. More... | |
struct net_pkt * | net_pkt_alloc (k_timeout_t timeout) |
Allocate an initialized net_pkt. More... | |
struct net_pkt * | net_pkt_alloc_from_slab (struct k_mem_slab *slab, k_timeout_t timeout) |
Allocate an initialized net_pkt from a specific slab. More... | |
struct net_pkt * | net_pkt_rx_alloc (k_timeout_t timeout) |
Allocate an initialized net_pkt for RX. More... | |
struct net_pkt * | net_pkt_alloc_on_iface (struct net_if *iface, k_timeout_t timeout) |
Allocate a network packet for a specific network interface. More... | |
struct net_pkt * | net_pkt_rx_alloc_on_iface (struct net_if *iface, k_timeout_t timeout) |
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. More... | |
struct net_pkt * | net_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. More... | |
struct net_pkt * | net_pkt_rx_alloc_with_buffer (struct net_if *iface, size_t size, sa_family_t family, enum net_ip_protocol proto, k_timeout_t timeout) |
void | net_pkt_append_buffer (struct net_pkt *pkt, struct net_buf *buffer) |
Append a buffer in packet. More... | |
size_t | net_pkt_available_buffer (struct net_pkt *pkt) |
Get available buffer space from a pkt. More... | |
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. More... | |
void | net_pkt_trim_buffer (struct net_pkt *pkt) |
Trim net_pkt buffer. More... | |
int | net_pkt_remove_tail (struct net_pkt *pkt, size_t length) |
Remove length bytes from tail of packet. More... | |
void | net_pkt_cursor_init (struct net_pkt *pkt) |
Initialize net_pkt cursor. More... | |
static void | net_pkt_cursor_backup (struct net_pkt *pkt, struct net_pkt_cursor *backup) |
Backup net_pkt cursor. More... | |
static void | net_pkt_cursor_restore (struct net_pkt *pkt, struct net_pkt_cursor *backup) |
Restore net_pkt cursor from a backup. More... | |
static void * | net_pkt_cursor_get_pos (struct net_pkt *pkt) |
Returns current position of the cursor. More... | |
int | net_pkt_skip (struct net_pkt *pkt, size_t length) |
Skip some data from a net_pkt. More... | |
int | net_pkt_memset (struct net_pkt *pkt, int byte, size_t length) |
Memset some data in a net_pkt. More... | |
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. More... | |
struct net_pkt * | net_pkt_clone (struct net_pkt *pkt, k_timeout_t timeout) |
Clone pkt and its buffer. More... | |
struct net_pkt * | net_pkt_shallow_clone (struct net_pkt *pkt, k_timeout_t timeout) |
Clone pkt and increase the refcount of its buffer. More... | |
int | net_pkt_read (struct net_pkt *pkt, void *data, size_t length) |
Read some data from a net_pkt. More... | |
static int | net_pkt_read_u8 (struct net_pkt *pkt, uint8_t *data) |
int | net_pkt_read_be16 (struct net_pkt *pkt, uint16_t *data) |
Read uint16_t big endian data from a net_pkt. More... | |
int | net_pkt_read_le16 (struct net_pkt *pkt, uint16_t *data) |
Read uint16_t little endian data from a net_pkt. More... | |
int | net_pkt_read_be32 (struct net_pkt *pkt, uint32_t *data) |
Read uint32_t big endian data from a net_pkt. More... | |
int | net_pkt_write (struct net_pkt *pkt, const void *data, size_t length) |
Write data into a net_pkt. More... | |
static int | net_pkt_write_u8 (struct net_pkt *pkt, uint8_t data) |
static int | net_pkt_write_be16 (struct net_pkt *pkt, uint16_t data) |
static int | net_pkt_write_be32 (struct net_pkt *pkt, uint32_t data) |
static int | net_pkt_write_le32 (struct net_pkt *pkt, uint32_t data) |
static int | net_pkt_write_le16 (struct net_pkt *pkt, uint16_t data) |
size_t | net_pkt_remaining_data (struct net_pkt *pkt) |
Get the amount of data which can be read from current cursor position. More... | |
int | net_pkt_update_length (struct net_pkt *pkt, size_t length) |
Update the overall length of a packet. More... | |
int | net_pkt_pull (struct net_pkt *pkt, size_t length) |
Remove data from the packet at current location. More... | |
uint16_t | net_pkt_get_current_offset (struct net_pkt *pkt) |
Get the actual offset in the packet from its cursor. More... | |
bool | net_pkt_is_contiguous (struct net_pkt *pkt, size_t size) |
Check if a data size could fit contiguously. More... | |
size_t | net_pkt_get_contiguous_len (struct net_pkt *pkt) |
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. More... | |
int | net_pkt_set_data (struct net_pkt *pkt, struct net_pkt_data_access *access) |
Set contiguous data into a network packet. More... | |
static int | net_pkt_acknowledge_data (struct net_pkt *pkt, struct net_pkt_data_access *access) |
Network packet buffer descriptor API.
Network data is passed between different parts of the stack via net_buf struct.