10#ifndef ZEPHYR_INCLUDE_NET_BUF_H_
11#define ZEPHYR_INCLUDE_NET_BUF_H_
31#if CONFIG_NET_BUF_ALIGNMENT == 0
32#define __net_buf_align __aligned(sizeof(void *))
34#define __net_buf_align __aligned(CONFIG_NET_BUF_ALIGNMENT)
46#define NET_BUF_SIMPLE_DEFINE(_name, _size) \
47 uint8_t net_buf_data_##_name[_size]; \
48 struct net_buf_simple _name = { \
49 .data = net_buf_data_##_name, \
52 .__buf = net_buf_data_##_name, \
65#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \
66 static __noinit uint8_t net_buf_data_##_name[_size]; \
67 static struct net_buf_simple _name = { \
68 .data = net_buf_data_##_name, \
71 .__buf = net_buf_data_##_name, \
123#define NET_BUF_SIMPLE(_size) \
124 ((struct net_buf_simple *)(&(struct { \
125 struct net_buf_simple buf; \
126 uint8_t data[_size]; \
144 buf->__buf = (
uint8_t *)buf +
sizeof(*buf);
147 buf->
data = buf->__buf + reserve_head;
161 void *data,
size_t size);
173 buf->
data = buf->__buf;
995#define NET_BUF_EXTERNAL_DATA BIT(0)
1086#if defined(CONFIG_NET_BUF_POOL_USAGE)
1104 struct net_buf *
const __bufs;
1108#define NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1109 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.avail_count = ATOMIC_INIT(_count),)) \
1110 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.name = STRINGIFY(_pool),))
1112#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _ud_size, _destroy) \
1114 .free = Z_LIFO_INITIALIZER(_pool.free), \
1116 .buf_count = _count, \
1117 .uninit_count = _count, \
1118 .user_data_size = _ud_size, \
1119 NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1120 .destroy = _destroy, \
1122 .__bufs = (struct net_buf *)_bufs, \
1125#define _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size) \
1126 struct _net_buf_##_name { uint8_t b[sizeof(struct net_buf)]; \
1127 uint8_t ud[_ud_size]; } __net_buf_align; \
1128 BUILD_ASSERT(_ud_size <= UINT8_MAX); \
1129 BUILD_ASSERT(offsetof(struct net_buf, user_data) == \
1130 offsetof(struct _net_buf_##_name, ud), "Invalid offset"); \
1131 BUILD_ASSERT(__alignof__(struct net_buf) == \
1132 __alignof__(struct _net_buf_##_name), "Invalid alignment"); \
1133 BUILD_ASSERT(sizeof(struct _net_buf_##_name) == \
1134 ROUND_UP(sizeof(struct net_buf) + _ud_size, __alignof__(struct net_buf)), \
1135 "Size cannot be determined"); \
1136 static struct _net_buf_##_name _net_buf_##_name[_count] __noinit
1168#define NET_BUF_POOL_HEAP_DEFINE(_name, _count, _ud_size, _destroy) \
1169 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1170 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1171 NET_BUF_POOL_INITIALIZER(_name, &net_buf_heap_alloc, \
1172 _net_buf_##_name, _count, _ud_size, \
1211#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1212 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1213 static uint8_t __noinit net_buf_data_##_name[_count][_data_size] __net_buf_align; \
1214 static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
1215 .data_pool = (uint8_t *)net_buf_data_##_name, \
1217 static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
1218 .cb = &net_buf_fixed_cb, \
1219 .alloc_data = (void *)&net_buf_fixed_##_name, \
1220 .max_alloc_size = _data_size, \
1222 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1223 NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \
1224 _net_buf_##_name, _count, _ud_size, \
1255#define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1256 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1257 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1258 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1259 .cb = &net_buf_var_cb, \
1260 .alloc_data = &net_buf_mem_pool_##_name, \
1261 .max_alloc_size = 0, \
1263 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1264 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1265 _net_buf_##_name, _count, _ud_size, \
1289#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1290 NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _ud_size, _destroy)
1329#if defined(CONFIG_NET_BUF_LOG)
1334#define net_buf_alloc_fixed(_pool, _timeout) \
1335 net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1365#if defined(CONFIG_NET_BUF_LOG)
1371#define net_buf_alloc_len(_pool, _size, _timeout) \
1372 net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1398#if defined(CONFIG_NET_BUF_LOG)
1402 const char *func,
int line);
1403#define net_buf_alloc_with_data(_pool, _data_, _size, _timeout) \
1404 net_buf_alloc_with_data_debug(_pool, _data_, _size, _timeout, \
1425#if defined(CONFIG_NET_BUF_LOG)
1426struct net_buf * __must_check net_buf_get_debug(
struct k_fifo *fifo,
1428 const char *func,
int line);
1429#define net_buf_get(_fifo, _timeout) \
1430 net_buf_get_debug(_fifo, _timeout, __func__, __LINE__)
1519#if defined(CONFIG_NET_BUF_LOG)
1520void net_buf_unref_debug(
struct net_buf *buf,
const char *func,
int line);
1521#define net_buf_unref(_buf) \
1522 net_buf_unref_debug(_buf, __func__, __LINE__)
2571#if defined(CONFIG_NET_BUF_LOG)
2574 const char *func,
int line);
2575#define net_buf_frag_del(_parent, _frag) \
2576 net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2597 struct net_buf *src,
size_t offset,
size_t len);
2674 while (buf &&
len--) {
long atomic_t
Definition: atomic_types.h:15
#define k_lifo_put(lifo, data)
Add an element to a LIFO queue.
Definition: kernel.h:2669
struct net_buf * net_buf_get(struct k_fifo *fifo, k_timeout_t timeout)
Get a buffer from a FIFO.
void net_buf_simple_clone(const struct net_buf_simple *original, struct net_buf_simple *clone)
Clone buffer state, using the same data buffer.
static void net_buf_simple_init(struct net_buf_simple *buf, size_t reserve_head)
Initialize a net_buf_simple object.
Definition: buf.h:140
struct net_buf * net_buf_frag_last(struct net_buf *frags)
Find the last fragment in the fragment list.
static uint64_t net_buf_pull_be40(struct net_buf *buf)
Remove and convert 40 bits from the beginning of the buffer.
Definition: buf.h:2405
static void net_buf_add_be64(struct net_buf *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
Definition: buf.h:1813
static size_t net_buf_headroom(struct net_buf *buf)
Check buffer headroom.
Definition: buf.h:2493
uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
Remove a 8-bit value from the beginning of the buffer.
uint16_t net_buf_simple_remove_le16(struct net_buf_simple *buf)
Remove and convert 16 bits from the end of the buffer.
static uint64_t net_buf_remove_le48(struct net_buf *buf)
Remove and convert 48 bits from the end of the buffer.
Definition: buf.h:1978
struct net_buf * net_buf_frag_add(struct net_buf *head, struct net_buf *frag)
Add a new fragment to the end of a chain of bufs.
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
Initialize buffer with the given headroom.
void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val)
Push 8-bit value to the beginning of the buffer.
static void net_buf_add_be24(struct net_buf *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
Definition: buf.h:1693
struct net_buf * net_buf_alloc_len(struct net_buf_pool *pool, size_t size, k_timeout_t timeout)
Allocate a new variable length buffer from a pool.
void net_buf_reset(struct net_buf *buf)
Reset buffer.
struct net_buf_pool * net_buf_pool_get(int id)
Looks up a pool based on its ID.
void * net_buf_simple_add(struct net_buf_simple *buf, size_t len)
Prepare data to be added at the end of the buffer.
uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
Remove and convert 48 bits from the beginning of the buffer.
uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
Remove and convert 32 bits from the beginning of the buffer.
void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
struct net_buf * net_buf_slist_get(sys_slist_t *list)
Get a buffer from a list.
struct net_buf * net_buf_ref(struct net_buf *buf)
Increment the reference count of a buffer.
uint64_t net_buf_simple_remove_le40(struct net_buf_simple *buf)
Remove and convert 40 bits from the end of the buffer.
struct net_buf *(* net_buf_allocator_cb)(k_timeout_t timeout, void *user_data)
Network buffer allocator callback.
Definition: buf.h:2613
static struct net_buf * net_buf_skip(struct net_buf *buf, size_t len)
Skip N number of bytes in a net_buf.
Definition: buf.h:2672
static void * net_buf_add(struct net_buf *buf, size_t len)
Prepare data to be added at the end of the buffer.
Definition: buf.h:1599
static void net_buf_add_le24(struct net_buf *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
Definition: buf.h:1678
static uint64_t net_buf_pull_le40(struct net_buf *buf)
Remove and convert 40 bits from the beginning of the buffer.
Definition: buf.h:2390
uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
Remove and convert 32 bits from the beginning of the buffer.
void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
static uint64_t net_buf_pull_be64(struct net_buf *buf)
Remove and convert 64 bits from the beginning of the buffer.
Definition: buf.h:2465
static void net_buf_push_be64(struct net_buf *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
Definition: buf.h:2238
static uint64_t net_buf_remove_le64(struct net_buf *buf)
Remove and convert 64 bits from the end of the buffer.
Definition: buf.h:2008
static void net_buf_simple_reset(struct net_buf_simple *buf)
Reset buffer.
Definition: buf.h:170
uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
Remove and convert 24 bits from the beginning of the buffer.
uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
Remove and convert 24 bits from the beginning of the buffer.
int net_buf_user_data_copy(struct net_buf *dst, const struct net_buf *src)
Copy user data from one to another buffer.
uint32_t net_buf_simple_remove_le24(struct net_buf_simple *buf)
Remove and convert 24 bits from the end of the buffer.
void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
static void net_buf_push_be40(struct net_buf *buf, uint64_t val)
Push 40-bit value to the beginning of the buffer.
Definition: buf.h:2182
static struct net_buf * net_buf_alloc(struct net_buf_pool *pool, k_timeout_t timeout)
Definition: buf.h:1344
static void net_buf_add_be32(struct net_buf *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
Definition: buf.h:1723
uint64_t net_buf_simple_remove_le64(struct net_buf_simple *buf)
Remove and convert 64 bits from the end of the buffer.
static uint64_t net_buf_remove_le40(struct net_buf *buf)
Remove and convert 40 bits from the end of the buffer.
Definition: buf.h:1948
size_t net_buf_simple_tailroom(struct net_buf_simple *buf)
Check buffer tailroom.
static void net_buf_simple_save(struct net_buf_simple *buf, struct net_buf_simple_state *state)
Save the parsing state of a buffer.
Definition: buf.h:963
void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
static uint16_t net_buf_remove_be16(struct net_buf *buf)
Remove and convert 16 bits from the end of the buffer.
Definition: buf.h:1873
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
static uint32_t net_buf_pull_le32(struct net_buf *buf)
Remove and convert 32 bits from the beginning of the buffer.
Definition: buf.h:2360
static uint32_t net_buf_pull_be32(struct net_buf *buf)
Remove and convert 32 bits from the beginning of the buffer.
Definition: buf.h:2375
struct net_buf * net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
Delete existing fragment from a chain of bufs.
uint64_t net_buf_simple_remove_be64(struct net_buf_simple *buf)
Remove and convert 64 bits from the end of the buffer.
static size_t net_buf_tailroom(struct net_buf *buf)
Check buffer tailroom.
Definition: buf.h:2479
static void net_buf_add_be16(struct net_buf *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
Definition: buf.h:1663
static void net_buf_add_le40(struct net_buf *buf, uint64_t val)
Add 40-bit value at the end of the buffer.
Definition: buf.h:1738
size_t net_buf_append_bytes(struct net_buf *buf, size_t len, const void *value, k_timeout_t timeout, net_buf_allocator_cb allocate_cb, void *user_data)
Append data to a list of net_buf.
void * net_buf_simple_push(struct net_buf_simple *buf, size_t len)
Prepare data to be added to the start of the buffer.
void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
void net_buf_simple_add_le40(struct net_buf_simple *buf, uint64_t val)
Add 40-bit value at the end of the buffer.
struct net_buf * net_buf_alloc_fixed(struct net_buf_pool *pool, k_timeout_t timeout)
Allocate a new fixed buffer from a pool.
static uint64_t net_buf_pull_be48(struct net_buf *buf)
Remove and convert 48 bits from the beginning of the buffer.
Definition: buf.h:2435
void net_buf_simple_add_be40(struct net_buf_simple *buf, uint64_t val)
Add 40-bit value at the end of the buffer.
uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
Remove and convert 48 bits from the beginning of the buffer.
void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
Put a buffer into a list.
static void net_buf_push_be16(struct net_buf *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
Definition: buf.h:2098
static uint32_t net_buf_remove_be24(struct net_buf *buf)
Remove and convert 24 bits from the end of the buffer.
Definition: buf.h:1888
static void net_buf_add_be40(struct net_buf *buf, uint64_t val)
Add 40-bit value at the end of the buffer.
Definition: buf.h:1753
static uint8_t net_buf_pull_u8(struct net_buf *buf)
Remove a 8-bit value from the beginning of the buffer.
Definition: buf.h:2285
static void net_buf_destroy(struct net_buf *buf)
Destroy buffer from custom destroy callback.
Definition: buf.h:1445
void net_buf_simple_push_le40(struct net_buf_simple *buf, uint64_t val)
Push 40-bit value to the beginning of the buffer.
void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
uint16_t net_buf_simple_max_len(struct net_buf_simple *buf)
Check maximum net_buf_simple::len value.
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
Remove and convert 64 bits from the beginning of the buffer.
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf)
Put a buffer to the end of a FIFO.
static void * net_buf_push_mem(struct net_buf *buf, const void *mem, size_t len)
Copies the given number of bytes to the start of the buffer.
Definition: buf.h:2056
static uint64_t net_buf_pull_le48(struct net_buf *buf)
Remove and convert 48 bits from the beginning of the buffer.
Definition: buf.h:2420
void net_buf_simple_init_with_data(struct net_buf_simple *buf, void *data, size_t size)
Initialize a net_buf_simple object with data.
void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
void * net_buf_simple_remove_mem(struct net_buf_simple *buf, size_t len)
Remove data from the end of the buffer.
static void net_buf_push_le48(struct net_buf *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
Definition: buf.h:2196
static uint32_t net_buf_pull_le24(struct net_buf *buf)
Remove and convert 24 bits from the beginning of the buffer.
Definition: buf.h:2330
void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
static uint8_t * net_buf_add_u8(struct net_buf *buf, uint8_t val)
Add (8-bit) byte at the end of the buffer.
Definition: buf.h:1633
static void net_buf_push_be24(struct net_buf *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
Definition: buf.h:2126
static void net_buf_push_le24(struct net_buf *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
Definition: buf.h:2112
static void net_buf_reserve(struct net_buf *buf, size_t reserve)
Initialize buffer with the given headroom.
Definition: buf.h:1583
static uint64_t net_buf_remove_be64(struct net_buf *buf)
Remove and convert 64 bits from the end of the buffer.
Definition: buf.h:2023
struct net_buf * net_buf_alloc_with_data(struct net_buf_pool *pool, void *data, size_t size, k_timeout_t timeout)
Allocate a new buffer from a pool but with external data pointer.
static uint8_t * net_buf_simple_tail(struct net_buf_simple *buf)
Get the tail pointer for a buffer.
Definition: buf.h:903
static uint32_t net_buf_pull_be24(struct net_buf *buf)
Remove and convert 24 bits from the beginning of the buffer.
Definition: buf.h:2345
void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
static void net_buf_add_be48(struct net_buf *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
Definition: buf.h:1783
uint8_t * net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val)
Add (8-bit) byte at the end of the buffer.
static uint32_t net_buf_remove_le24(struct net_buf *buf)
Remove and convert 24 bits from the end of the buffer.
Definition: buf.h:1903
static void net_buf_push_u8(struct net_buf *buf, uint8_t val)
Push 8-bit value to the beginning of the buffer.
Definition: buf.h:2070
void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
uint16_t net_buf_simple_remove_be16(struct net_buf_simple *buf)
Remove and convert 16 bits from the end of the buffer.
static void * net_buf_push(struct net_buf *buf, size_t len)
Prepare data to be added at the start of the buffer.
Definition: buf.h:2039
static uint16_t net_buf_pull_be16(struct net_buf *buf)
Remove and convert 16 bits from the beginning of the buffer.
Definition: buf.h:2315
static void net_buf_push_le32(struct net_buf *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
Definition: buf.h:2140
static uint64_t net_buf_pull_le64(struct net_buf *buf)
Remove and convert 64 bits from the beginning of the buffer.
Definition: buf.h:2450
uint64_t net_buf_simple_remove_be40(struct net_buf_simple *buf)
Remove and convert 40 bits from the end of the buffer.
uint32_t net_buf_simple_remove_be24(struct net_buf_simple *buf)
Remove and convert 24 bits from the end of the buffer.
void * net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
Remove data from the beginning of the buffer.
uint32_t net_buf_simple_remove_le32(struct net_buf_simple *buf)
Remove and convert 32 bits from the end of the buffer.
void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
uint64_t net_buf_simple_pull_be40(struct net_buf_simple *buf)
Remove and convert 40 bits from the beginning of the buffer.
void * net_buf_simple_push_mem(struct net_buf_simple *buf, const void *mem, size_t len)
Copy given number of bytes from memory to the start of the buffer.
static uint64_t net_buf_remove_be48(struct net_buf *buf)
Remove and convert 48 bits from the end of the buffer.
Definition: buf.h:1993
static uint16_t net_buf_max_len(struct net_buf *buf)
Check maximum net_buf::len value.
Definition: buf.h:2507
void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
#define NET_BUF_EXTERNAL_DATA
Flag indicating that the buffer's associated data pointer, points to externally allocated memory.
Definition: buf.h:995
static uint16_t net_buf_remove_le16(struct net_buf *buf)
Remove and convert 16 bits from the end of the buffer.
Definition: buf.h:1858
static void net_buf_push_le16(struct net_buf *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
Definition: buf.h:2084
uint64_t net_buf_simple_remove_be48(struct net_buf_simple *buf)
Remove and convert 48 bits from the end of the buffer.
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
void net_buf_unref(struct net_buf *buf)
Decrements the reference count of a buffer.
static void net_buf_push_be48(struct net_buf *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
Definition: buf.h:2210
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag)
Insert a new fragment to a chain of bufs.
uint64_t net_buf_simple_remove_le48(struct net_buf_simple *buf)
Remove and convert 48 bits from the end of the buffer.
void * net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, size_t len)
Copy given number of bytes from memory to the end of the buffer.
static void net_buf_add_le64(struct net_buf *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
Definition: buf.h:1798
static uint8_t * net_buf_tail(struct net_buf *buf)
Get the tail pointer for a buffer.
Definition: buf.h:2521
static uint32_t net_buf_remove_be32(struct net_buf *buf)
Remove and convert 32 bits from the end of the buffer.
Definition: buf.h:1933
static void * net_buf_remove_mem(struct net_buf *buf, size_t len)
Remove data from the end of the buffer.
Definition: buf.h:1828
static void * net_buf_add_mem(struct net_buf *buf, const void *mem, size_t len)
Copies the given number of bytes to the end of the buffer.
Definition: buf.h:1616
size_t net_buf_simple_headroom(struct net_buf_simple *buf)
Check buffer headroom.
uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf)
Remove and convert 64 bits from the beginning of the buffer.
void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
static void net_buf_push_le64(struct net_buf *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
Definition: buf.h:2224
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
Remove and convert 16 bits from the beginning of the buffer.
void net_buf_simple_push_be40(struct net_buf_simple *buf, uint64_t val)
Push 40-bit value to the beginning of the buffer.
uint64_t net_buf_simple_pull_le40(struct net_buf_simple *buf)
Remove and convert 40 bits from the beginning of the buffer.
int net_buf_id(struct net_buf *buf)
Get a zero-based index for a buffer.
static uint8_t net_buf_remove_u8(struct net_buf *buf)
Remove a 8-bit value from the end of the buffer.
Definition: buf.h:1843
void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
static void net_buf_add_le16(struct net_buf *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
Definition: buf.h:1648
static uint64_t net_buf_remove_be40(struct net_buf *buf)
Remove and convert 40 bits from the end of the buffer.
Definition: buf.h:1963
uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
Remove and convert 16 bits from the beginning of the buffer.
static void net_buf_push_be32(struct net_buf *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
Definition: buf.h:2154
static void net_buf_add_le32(struct net_buf *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
Definition: buf.h:1708
uint32_t net_buf_simple_remove_be32(struct net_buf_simple *buf)
Remove and convert 32 bits from the end of the buffer.
static uint32_t net_buf_remove_le32(struct net_buf *buf)
Remove and convert 32 bits from the end of the buffer.
Definition: buf.h:1918
static size_t net_buf_frags_len(struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition: buf.h:2694
static uint16_t net_buf_pull_le16(struct net_buf *buf)
Remove and convert 16 bits from the beginning of the buffer.
Definition: buf.h:2300
static void * net_buf_pull_mem(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition: buf.h:2270
static void net_buf_simple_restore(struct net_buf_simple *buf, struct net_buf_simple_state *state)
Restore the parsing state of a buffer.
Definition: buf.h:979
static void * net_buf_pull(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition: buf.h:2254
size_t net_buf_data_match(const struct net_buf *buf, size_t offset, const void *data, size_t len)
Match data with a net_buf's content.
static void net_buf_push_le40(struct net_buf *buf, uint64_t val)
Push 40-bit value to the beginning of the buffer.
Definition: buf.h:2168
static void net_buf_add_le48(struct net_buf *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
Definition: buf.h:1768
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
static void * net_buf_user_data(const struct net_buf *buf)
Get a pointer to the user data of a buffer.
Definition: buf.h:1559
struct net_buf * net_buf_clone(struct net_buf *buf, k_timeout_t timeout)
Clone buffer.
uint8_t net_buf_simple_remove_u8(struct net_buf_simple *buf)
Remove a 8-bit value from the end of the buffer.
void * net_buf_simple_pull(struct net_buf_simple *buf, size_t len)
Remove data from the beginning of the buffer.
size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src, size_t offset, size_t len)
Copy bytes from net_buf chain starting at offset to linear buffer.
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
struct _slist sys_slist_t
Single-linked list structure.
Definition: slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
state
Definition: parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Definition: kernel.h:2376
Definition: kernel.h:2615
Kernel Spin Lock.
Definition: spinlock.h:45
Kernel timeout type.
Definition: sys_clock.h:65
const struct net_buf_data_cb * cb
Definition: buf.h:1060
size_t max_alloc_size
Definition: buf.h:1062
void * alloc_data
Definition: buf.h:1061
uint8_t *(* ref)(struct net_buf *buf, uint8_t *data)
Definition: buf.h:1055
uint8_t *(* alloc)(struct net_buf *buf, size_t *size, k_timeout_t timeout)
Definition: buf.h:1053
void(* unref)(struct net_buf *buf, uint8_t *data)
Definition: buf.h:1056
uint8_t * data_pool
Definition: buf.h:1176
Network buffer pool representation.
Definition: buf.h:1070
void(*const destroy)(struct net_buf *buf)
Optional destroy callback when buffer is freed.
Definition: buf.h:1098
uint16_t uninit_count
Number of uninitialized buffers.
Definition: buf.h:1081
uint8_t user_data_size
Definition: buf.h:1084
const uint16_t buf_count
Number of buffers in pool.
Definition: buf.h:1078
const struct net_buf_data_alloc * alloc
Data allocation handlers.
Definition: buf.h:1101
struct k_lifo free
LIFO to place the buffer into when free.
Definition: buf.h:1072
struct k_spinlock lock
Definition: buf.h:1075
Parsing state of a buffer.
Definition: buf.h:948
uint16_t offset
Offset of the data pointer from the beginning of the storage.
Definition: buf.h:950
uint16_t len
Length of data.
Definition: buf.h:952
Simple network buffer representation.
Definition: buf.h:87
uint8_t * data
Pointer to the start of data in the buffer.
Definition: buf.h:89
uint16_t size
Amount of data that net_buf_simple::__buf can store.
Definition: buf.h:99
uint16_t len
Length of the data behind the data pointer.
Definition: buf.h:96
Network buffer representation.
Definition: buf.h:1004
uint16_t size
Amount of data that this buffer can store.
Definition: buf.h:1036
struct net_buf * frags
Fragments associated with this buffer.
Definition: buf.h:1009
uint8_t ref
Reference count.
Definition: buf.h:1012
uint8_t pool_id
Where the buffer should go when freed up.
Definition: buf.h:1018
sys_snode_t node
Allow placing the buffer into sys_slist_t.
Definition: buf.h:1006
uint8_t user_data_size
Definition: buf.h:1021
uint8_t flags
Bit-field of buffer flags.
Definition: buf.h:1015
uint8_t * data
Pointer to the start of data in the buffer.
Definition: buf.h:1030
uint8_t user_data[]
System metadata for this buffer.
Definition: buf.h:1049
struct net_buf_simple b
Definition: buf.h:1045
uint16_t len
Length of the data behind the data pointer.
Definition: buf.h:1033