Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
|
Network packet management library . More...
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_buf * | net_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_buf * | net_pkt_get_reserve_rx_data (size_t min_len, k_timeout_t timeout) |
Get RX DATA buffer from pool. | |
struct net_buf * | net_pkt_get_reserve_tx_data (size_t min_len, k_timeout_t timeout) |
Get TX DATA buffer from pool. | |
struct net_buf * | net_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_pkt * | net_pkt_ref (struct net_pkt *pkt) |
Increase the packet ref count. | |
struct net_buf * | net_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_buf * | net_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_pkt * | net_pkt_alloc (k_timeout_t timeout) |
Allocate an initialized net_pkt. | |
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. | |
struct net_pkt * | net_pkt_rx_alloc (k_timeout_t timeout) |
Allocate an initialized net_pkt for RX. | |
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. | |
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_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. | |
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_pkt * | net_pkt_clone (struct net_pkt *pkt, k_timeout_t timeout) |
Clone pkt and its buffer. | |
struct net_pkt * | net_pkt_rx_clone (struct net_pkt *pkt, k_timeout_t timeout) |
Clone pkt and its buffer. | |
struct net_pkt * | net_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. | |
Network packet management library .
#define NET_PKT_DATA_POOL_DEFINE | ( | name, | |
count ) |
#include <zephyr/net/net_pkt.h>
Create a data fragment net_buf pool.
A net_buf pool is used to store actual data for network packets. It must be coupled with a net_pkt slab (NET_PKT_SLAB_DEFINE) used to store the packet meta-information. The macro can be used by an application to define additional custom per-context TX packet pools (see net_context_setup_pools()).
name | Name of the pool. |
count | Number of net_buf in this pool. |
#define net_pkt_print_frags | ( | pkt | ) |
#include <zephyr/net/net_pkt.h>
#define NET_PKT_SLAB_DEFINE | ( | name, | |
count ) |
#include <zephyr/net/net_pkt.h>
Create a net_pkt slab.
A net_pkt slab is used to store meta-information about network packets. It must be coupled with a data fragment pool (NET_PKT_DATA_POOL_DEFINE) used to store the actual packet data. The macro can be used by an application to define additional custom per-context TX packet slabs (see net_context_setup_pools()).
name | Name of the slab. |
count | Number of net_pkt in this slab. |
|
inlinestatic |
#include <zephyr/net/net_pkt.h>
Acknowledge previously contiguous data taken from a network packet Packet needs to be set to overwrite mode.
struct net_pkt * net_pkt_alloc | ( | k_timeout_t | timeout | ) |
#include <zephyr/net/net_pkt.h>
Allocate an initialized net_pkt.
for the time being, 2 pools are used. One for TX and one for RX. This allocator has to be used for TX.
timeout | Maximum time to wait for an allocation. |
int net_pkt_alloc_buffer | ( | struct net_pkt * | pkt, |
size_t | size, | ||
enum net_ip_protocol | proto, | ||
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Allocate buffer for a net_pkt.
: such allocator will take into account space necessary for headers, MTU, and existing buffer (if any). Beware that, due to all these criteria, the allocated size might be smaller/bigger than requested one.
pkt | The network packet requiring buffer to be allocated. |
size | The size of buffer being requested. |
proto | The IP protocol type (can be 0 for none). |
timeout | Maximum time to wait for an allocation. |
int net_pkt_alloc_buffer_raw | ( | struct net_pkt * | pkt, |
size_t | size, | ||
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Allocate buffer for a net_pkt, of specified size, w/o any additional preconditions.
: The actual buffer size may be larger than requested one if fixed size buffers are in use.
pkt | The network packet requiring buffer to be allocated. |
size | The size of buffer being requested. |
timeout | Maximum time to wait for an allocation. |
struct net_pkt * net_pkt_alloc_from_slab | ( | struct k_mem_slab * | slab, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Allocate an initialized net_pkt from a specific slab.
unlike net_pkt_alloc() which uses core slabs, this one will use an external slab (see NET_PKT_SLAB_DEFINE()). Do not use it unless you know what you are doing. Basically, only net_context should be using this, in order to allocate packet and then buffer on its local slab/pool (if any).
slab | The slab to use for allocating the packet |
timeout | Maximum time to wait for an allocation. |
struct net_pkt * net_pkt_alloc_on_iface | ( | struct net_if * | iface, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Allocate a network packet for a specific network interface.
iface | The network interface the packet is supposed to go through. |
timeout | Maximum time to wait for an allocation. |
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 ) |
#include <zephyr/net/net_pkt.h>
Allocate a network packet and buffer at once.
iface | The network interface the packet is supposed to go through. |
size | The size of buffer. |
family | The family to which the packet belongs. |
proto | The IP protocol type (can be 0 for none). |
timeout | Maximum time to wait for an allocation. |
#include <zephyr/net/net_pkt.h>
Append a buffer in packet.
pkt | Network packet where to append the buffer |
buffer | Buffer to append |
#include <zephyr/net/net_pkt.h>
Get available buffer space from a pkt.
pkt | The net_pkt which buffer availability should be evaluated |
size_t net_pkt_available_payload_buffer | ( | struct net_pkt * | pkt, |
enum net_ip_protocol | proto ) |
#include <zephyr/net/net_pkt.h>
Get available buffer space for payload from a pkt.
Unlike net_pkt_available_buffer(), this will take into account the headers space.
pkt | The net_pkt which payload buffer availability should be evaluated |
proto | The IP protocol type (can be 0 for none). |
struct net_pkt * net_pkt_clone | ( | struct net_pkt * | pkt, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Clone pkt and its buffer.
The cloned packet will be allocated on the same pool as the original one.
pkt | Original pkt to be cloned |
timeout | Timeout to wait for free buffer |
void net_pkt_compact | ( | struct net_pkt * | pkt | ) |
#include <zephyr/net/net_pkt.h>
Compact the fragment list of a packet.
After this there is no more any free space in individual fragments.
pkt | Network packet. |
#include <zephyr/net/net_pkt.h>
Copy data from a packet into another one.
Both net_pkt cursors should be properly initialized and, if needed, positioned using net_pkt_skip. The cursors will be updated after the operation.
pkt_dst | Destination network packet. |
pkt_src | Source network packet. |
length | Length of data to be copied. |
|
inlinestatic |
#include <zephyr/net/net_pkt.h>
Backup net_pkt cursor.
|
inlinestatic |
#include <zephyr/net/net_pkt.h>
Returns current position of the cursor.
pkt | The net_pkt whose cursor position is going to be returned |
void net_pkt_cursor_init | ( | struct net_pkt * | pkt | ) |
#include <zephyr/net/net_pkt.h>
Initialize net_pkt cursor.
This will initialize the net_pkt cursor from its buffer.
pkt | The net_pkt whose cursor is going to be initialized |
|
inlinestatic |
#include <zephyr/net/net_pkt.h>
Restore net_pkt cursor from a backup.
#include <zephyr/net/net_pkt.h>
Add a fragment to a packet at the end of its fragment list.
pkt | pkt Network packet where to add the fragment |
frag | Fragment to add |
struct net_buf * net_pkt_frag_del | ( | struct net_pkt * | pkt, |
struct net_buf * | parent, | ||
struct net_buf * | frag ) |
#include <zephyr/net/net_pkt.h>
Delete existing fragment from a packet.
pkt | Network packet from which frag belongs to. |
parent | parent fragment of frag, or NULL if none. |
frag | Fragment to delete. |
#include <zephyr/net/net_pkt.h>
Insert a fragment to a packet at the beginning of its fragment list.
pkt | pkt Network packet where to insert the fragment |
frag | Fragment to insert |
#include <zephyr/net/net_pkt.h>
Increase the packet fragment ref count.
Mark the fragment to be used still.
frag | Network fragment to ref. |
void net_pkt_frag_unref | ( | struct net_buf * | frag | ) |
#include <zephyr/net/net_pkt.h>
Decrease the packet fragment ref count.
frag | Network fragment to unref. |
#include <zephyr/net/net_pkt.h>
Get the contiguous buffer space.
pkt | Network packet |
#include <zephyr/net/net_pkt.h>
Get the actual offset in the packet from its cursor.
pkt | Network packet. |
void * net_pkt_get_data | ( | struct net_pkt * | pkt, |
struct net_pkt_data_access * | access ) |
#include <zephyr/net/net_pkt.h>
Get data from a network packet in a contiguous way.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Unlike other functions, cursor position will not be updated after the operation.
pkt | The network packet from where to get the data. |
access | A pointer to a valid net_pkt_data_access describing the data to get in a contiguous way. |
struct net_buf * net_pkt_get_frag | ( | struct net_pkt * | pkt, |
size_t | min_len, | ||
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Get a data fragment that might be from user specific buffer pool or from global DATA pool.
pkt | Network packet. |
min_len | Minimum length of the requested fragment. |
timeout | Affects the action taken should the net buf pool be empty. If K_NO_WAIT, then return immediately. If K_FOREVER, then wait as long as necessary. Otherwise, wait up to the specified time. |
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 ) |
#include <zephyr/net/net_pkt.h>
Get information about predefined RX, TX and DATA pools.
rx | Pointer to RX pool is returned. |
tx | Pointer to TX pool is returned. |
rx_data | Pointer to RX DATA pool is returned. |
tx_data | Pointer to TX DATA pool is returned. |
struct net_buf * net_pkt_get_reserve_data | ( | struct net_buf_pool * | pool, |
size_t | min_len, | ||
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Get a data buffer from a given pool.
Normally this version is not useful for applications but is mainly used by network fragmentation code.
pool | The net_buf pool to use. |
min_len | Minimum length of the requested fragment. |
timeout | Affects the action taken should the net buf pool be empty. If K_NO_WAIT, then return immediately. If K_FOREVER, then wait as long as necessary. Otherwise, wait up to the specified time. |
struct net_buf * net_pkt_get_reserve_rx_data | ( | size_t | min_len, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Get RX DATA buffer from pool.
Normally you should use net_pkt_get_frag() instead.
Normally this version is not useful for applications but is mainly used by network fragmentation code.
min_len | Minimum length of the requested fragment. |
timeout | Affects the action taken should the net buf pool be empty. If K_NO_WAIT, then return immediately. If K_FOREVER, then wait as long as necessary. Otherwise, wait up to the specified time. |
struct net_buf * net_pkt_get_reserve_tx_data | ( | size_t | min_len, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Get TX DATA buffer from pool.
Normally you should use net_pkt_get_frag() instead.
Normally this version is not useful for applications but is mainly used by network fragmentation code.
min_len | Minimum length of the requested fragment. |
timeout | Affects the action taken should the net buf pool be empty. If K_NO_WAIT, then return immediately. If K_FOREVER, then wait as long as necessary. Otherwise, wait up to the specified time. |
#include <zephyr/net/net_pkt.h>
Check if a data size could fit contiguously.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip.
pkt | Network packet. |
size | The size to check for contiguity |
#include <zephyr/net/net_pkt.h>
Memset some data in a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The net_pkt whose buffer to fill starting at the current cursor position. |
byte | The byte to write in memory |
length | Amount of data to memset with given byte |
#include <zephyr/net/net_pkt.h>
Remove data from the packet at current location.
net_pkt's cursor should be properly initialized and, eventually, properly positioned using net_pkt_skip/read/write. Note that net_pkt's cursor is reset by this function.
pkt | Network packet |
length | Number of bytes to be removed |
#include <zephyr/net/net_pkt.h>
Read some data from a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read some data |
data | The destination buffer where to copy the data |
length | The amount of data to copy |
#include <zephyr/net/net_pkt.h>
Read uint16_t big endian data from a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The destination uint16_t where to copy the data |
#include <zephyr/net/net_pkt.h>
Read uint32_t big endian data from a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The destination uint32_t where to copy the data |
#include <zephyr/net/net_pkt.h>
Read uint16_t little endian data from a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The destination uint16_t where to copy the data |
#include <zephyr/net/net_pkt.h>
Read a byte (uint8_t) from a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The destination uint8_t where to copy the data |
#include <zephyr/net/net_pkt.h>
Increase the packet ref count.
Mark the packet to be used still.
pkt | Network packet to ref. |
#include <zephyr/net/net_pkt.h>
Get the amount of data which can be read from current cursor position.
pkt | Network packet |
#include <zephyr/net/net_pkt.h>
Remove length bytes from tail of packet.
This function does not take packet cursor into account. It is a helper to remove unneeded bytes from tail of packet (like appended CRC). It takes care of buffer deallocation if removed bytes span whole buffer(s).
pkt | Network packet |
length | Number of bytes to be removed |
0 | On success. |
-EINVAL | If packet length is shorter than length. |
struct net_pkt * net_pkt_rx_alloc | ( | k_timeout_t | timeout | ) |
#include <zephyr/net/net_pkt.h>
Allocate an initialized net_pkt for RX.
for the time being, 2 pools are used. One for TX and one for RX. This allocator has to be used for RX.
timeout | Maximum time to wait for an allocation. |
struct net_pkt * net_pkt_rx_clone | ( | struct net_pkt * | pkt, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Clone pkt and its buffer.
The cloned packet will be allocated on the RX packet poll.
pkt | Original pkt to be cloned |
timeout | Timeout to wait for free buffer |
int net_pkt_set_data | ( | struct net_pkt * | pkt, |
struct net_pkt_data_access * | access ) |
#include <zephyr/net/net_pkt.h>
Set contiguous data into a network packet.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet to where the data should be set. |
access | A pointer to a valid net_pkt_data_access describing the data to set. |
struct net_pkt * net_pkt_shallow_clone | ( | struct net_pkt * | pkt, |
k_timeout_t | timeout ) |
#include <zephyr/net/net_pkt.h>
Clone pkt and increase the refcount of its buffer.
pkt | Original pkt to be shallow cloned |
timeout | Timeout to wait for free packet |
#include <zephyr/net/net_pkt.h>
Skip some data from a net_pkt.
net_pkt's cursor should be properly initialized Cursor position will be updated after the operation. Depending on the value of pkt->overwrite bit, this function will affect the buffer length or not. If it's true, it will advance the cursor to the requested length. If it's false, it will do the same but if the cursor was already also at the end of existing data, it will increment the buffer length. So in this case, its behavior is just like net_pkt_write or net_pkt_memset, difference being that it will not affect the buffer content itself (which may be just garbage then).
pkt | The net_pkt whose cursor will be updated to skip given amount of data from the buffer. |
length | Amount of data to skip in the buffer |
void net_pkt_trim_buffer | ( | struct net_pkt * | pkt | ) |
#include <zephyr/net/net_pkt.h>
Trim net_pkt buffer.
This will basically check for unused buffers and deallocate them relevantly
pkt | The net_pkt which buffer will be trimmed |
void net_pkt_unref | ( | struct net_pkt * | pkt | ) |
#include <zephyr/net/net_pkt.h>
Place packet back into the available packets slab.
Releases the packet to other use. This needs to be called by application after it has finished with the packet.
pkt | Network packet to release. |
#include <zephyr/net/net_pkt.h>
Update the overall length of a packet.
Unlike net_pkt_pull() below, this does not take packet cursor into account. It's mainly a helper dedicated for ipv4 and ipv6 input functions. It shrinks the overall length by given parameter.
pkt | Network packet |
length | The new length of the packet |
#include <zephyr/net/net_pkt.h>
Write data into a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet where to write |
data | Data to be written |
length | Length of the data to be written |
#include <zephyr/net/net_pkt.h>
Write a uint16_t big endian data to a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The uint16_t value in host byte order to write |
#include <zephyr/net/net_pkt.h>
Write a uint32_t big endian data to a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The uint32_t value in host byte order to write |
#include <zephyr/net/net_pkt.h>
Write a uint16_t little endian data to a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The uint16_t value in host byte order to write |
#include <zephyr/net/net_pkt.h>
Write a uint32_t little endian data to a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The uint32_t value in host byte order to write |
#include <zephyr/net/net_pkt.h>
Write a byte (uint8_t) data to a net_pkt.
net_pkt's cursor should be properly initialized and, if needed, positioned using net_pkt_skip. Cursor position will be updated after the operation.
pkt | The network packet from where to read |
data | The uint8_t value to write |