10#ifndef ZEPHYR_INCLUDE_NET_BUF_H_
11#define ZEPHYR_INCLUDE_NET_BUF_H_
33#if CONFIG_NET_BUF_ALIGNMENT == 0
34#define __net_buf_align __aligned(sizeof(void *))
36#define __net_buf_align __aligned(CONFIG_NET_BUF_ALIGNMENT)
48#define NET_BUF_SIMPLE_DEFINE(_name, _size) \
49 uint8_t net_buf_data_##_name[_size]; \
50 struct net_buf_simple _name = { \
51 .data = net_buf_data_##_name, \
54 .__buf = net_buf_data_##_name, \
67#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \
68 static __noinit uint8_t net_buf_data_##_name[_size]; \
69 static struct net_buf_simple _name = { \
70 .data = net_buf_data_##_name, \
73 .__buf = net_buf_data_##_name, \
126#define NET_BUF_SIMPLE(_size) \
127 ((struct net_buf_simple *)(&(struct { \
128 struct net_buf_simple buf; \
129 uint8_t data[_size]; \
147 buf->__buf = (
uint8_t *)buf +
sizeof(*buf);
150 buf->
data = buf->__buf + reserve_head;
164 void *data,
size_t size);
176 buf->
data = buf->__buf;
922 return buf->
data - buf->__buf;
979 if (buf ==
NULL || buf->__buf ==
NULL || buf->
data < buf->__buf) {
984 if (headroom > buf->
size) {
988 return (
size_t)buf->
len <= (size_t)(buf->
size - headroom);
1045#define NET_BUF_EXTERNAL_DATA BIT(0)
1097#if defined(CONFIG_BIG_ENDIAN)
1104#if (__SIZEOF_LONG__ == 8)
1169struct net_buf_data_cb {
1170 uint8_t * __must_check (*alloc)(
struct net_buf *buf,
size_t *size,
1176struct net_buf_data_alloc {
1177 const struct net_buf_data_cb *cb;
1179 size_t max_alloc_size;
1206#if defined(CONFIG_NET_BUF_POOL_USAGE)
1227 struct net_buf *
const __bufs;
1231#define NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1232 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.avail_count = ATOMIC_INIT(_count),)) \
1233 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.max_used = 0,)) \
1234 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.name = STRINGIFY(_pool),))
1236#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _ud_size, _destroy) \
1238 .free = Z_LIFO_INITIALIZER(_pool.free), \
1240 .buf_count = _count, \
1241 .uninit_count = _count, \
1242 .user_data_size = _ud_size, \
1243 NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1244 .destroy = _destroy, \
1246 .__bufs = (struct net_buf *)_bufs, \
1249#define _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size) \
1250 struct _net_buf_##_name { uint8_t b[sizeof(struct net_buf)]; \
1251 uint8_t ud[_ud_size]; } __net_buf_align; \
1252 BUILD_ASSERT(_ud_size <= UINT8_MAX); \
1253 BUILD_ASSERT(offsetof(struct net_buf, user_data) == \
1254 offsetof(struct _net_buf_##_name, ud), "Invalid offset"); \
1255 BUILD_ASSERT(__alignof__(struct net_buf) == \
1256 __alignof__(struct _net_buf_##_name), "Invalid alignment"); \
1257 BUILD_ASSERT(sizeof(struct _net_buf_##_name) == \
1258 ROUND_UP(sizeof(struct net_buf) + _ud_size, __alignof__(struct net_buf)), \
1259 "Size cannot be determined"); \
1260 static struct _net_buf_##_name _net_buf_##_name[_count] __noinit
1262extern const struct net_buf_data_alloc net_buf_heap_alloc;
1292#define NET_BUF_POOL_HEAP_DEFINE(_name, _count, _ud_size, _destroy) \
1293 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1294 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1295 NET_BUF_POOL_INITIALIZER(_name, &net_buf_heap_alloc, \
1296 _net_buf_##_name, _count, _ud_size, \
1301struct net_buf_pool_fixed {
1305extern const struct net_buf_data_cb net_buf_fixed_cb;
1337#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1338 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1339 static uint8_t __noinit net_buf_data_##_name[_count][_data_size] __net_buf_align; \
1340 static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
1341 .data_pool = (uint8_t *)net_buf_data_##_name, \
1343 static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
1344 .cb = &net_buf_fixed_cb, \
1345 .alloc_data = (void *)&net_buf_fixed_##_name, \
1346 .max_alloc_size = _data_size, \
1348 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1349 NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \
1350 _net_buf_##_name, _count, _ud_size, \
1354extern const struct net_buf_data_cb net_buf_var_cb;
1381#define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1382 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1383 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1384 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1385 .cb = &net_buf_var_cb, \
1386 .alloc_data = &net_buf_mem_pool_##_name, \
1387 .max_alloc_size = 0, \
1389 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1390 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1391 _net_buf_##_name, _count, _ud_size, \
1424#define NET_BUF_POOL_VAR_ALIGN_DEFINE(_name, _count, _data_size, _ud_size, \
1426 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1427 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1428 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1429 .cb = &net_buf_var_cb, \
1430 .alloc_data = &net_buf_mem_pool_##_name, \
1431 .max_alloc_size = 0, \
1432 .alignment = _align, \
1434 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1435 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1436 _net_buf_##_name, _count, _ud_size, \
1460#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1461 NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _ud_size, _destroy)
1486#if defined(CONFIG_NET_BUF_POOL_USAGE) || defined(__DOXYGEN__)
1502 return (
size_t)
atomic_get(&pool->avail_count);
1516 return (
size_t)pool->max_used;
1534#if defined(CONFIG_NET_BUF_LOG)
1539#define net_buf_alloc_fixed(_pool, _timeout) \
1540 net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1570#if defined(CONFIG_NET_BUF_LOG)
1576#define net_buf_alloc_len(_pool, _size, _timeout) \
1577 net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1603#if defined(CONFIG_NET_BUF_LOG)
1607 const char *func,
int line);
1608#define net_buf_alloc_with_data(_pool, _data_, _size, _timeout) \
1609 net_buf_alloc_with_data_debug(_pool, _data_, _size, _timeout, \
1632 pool->
alloc->cb->unref(buf, buf->__buf);
1683#if defined(CONFIG_NET_BUF_LOG)
1684void net_buf_unref_debug(
struct net_buf *buf,
const char *func,
int line);
1685#define net_buf_unref(_buf) \
1686 net_buf_unref_debug(_buf, __func__, __LINE__)
2793#if defined(CONFIG_NET_BUF_LOG)
2796 const char *func,
int line);
2797#define net_buf_frag_del(_parent, _frag) \
2798 net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2819 const struct net_buf *src,
size_t offset,
size_t len);
2896 while (buf &&
len--) {
long atomic_t
Atomic integer variable.
Definition atomic_types.h:31
atomic_val_t atomic_get(const atomic_t *target)
Atomic get.
atomic_ptr_val_t atomic_ptr_clear(atomic_ptr_t *target)
Atomic clear of a pointer value.
void * atomic_ptr_t
Atomic pointer variable.
Definition atomic_types.h:46
#define k_lifo_put(lifo, data)
Add an element to a LIFO queue.
Definition kernel.h:3269
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 net_buf.h:143
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 net_buf.h:2602
static void net_buf_add_be64(struct net_buf *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
Definition net_buf.h:2010
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 net_buf.h:2175
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 net_buf.h:1890
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.
static struct net_buf * net_buf_skip(struct net_buf *buf, size_t len)
Skip N number of bytes in a net_buf.
Definition net_buf.h:2894
static void * net_buf_add(struct net_buf *buf, size_t len)
Prepare data to be added at the end of the buffer.
Definition net_buf.h:1796
static void net_buf_add_le24(struct net_buf *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
Definition net_buf.h:1875
static uint64_t net_buf_pull_le40(struct net_buf *buf)
Remove and convert 40 bits from the beginning of the buffer.
Definition net_buf.h:2587
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 net_buf.h:2662
static void net_buf_push_be64(struct net_buf *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
Definition net_buf.h:2435
static uint64_t net_buf_remove_le64(struct net_buf *buf)
Remove and convert 64 bits from the end of the buffer.
Definition net_buf.h:2205
static void net_buf_simple_reset(struct net_buf_simple *buf)
Reset buffer.
Definition net_buf.h:173
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.
static struct net_buf * net_buf_take(struct net_buf **orig)
Move a buffer pointer, setting the orig to NULL.
Definition net_buf.h:1711
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 net_buf.h:2379
static struct net_buf * net_buf_alloc(struct net_buf_pool *pool, k_timeout_t timeout)
Definition net_buf.h:1549
static void net_buf_add_be32(struct net_buf *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
Definition net_buf.h:1920
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 net_buf.h:2145
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 bool net_buf_simple_is_valid(const struct net_buf_simple *buf)
Check that a buffer's length and pointers are self-consistent.
Definition net_buf.h:975
static uint16_t net_buf_remove_be16(struct net_buf *buf)
Remove and convert 16 bits from the end of the buffer.
Definition net_buf.h:2070
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 net_buf.h:2557
static uint32_t net_buf_pull_be32(struct net_buf *buf)
Remove and convert 32 bits from the beginning of the buffer.
Definition net_buf.h:2572
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 void net_buf_add_be16(struct net_buf *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
Definition net_buf.h:1860
static void net_buf_add_le40(struct net_buf *buf, uint64_t val)
Add 40-bit value at the end of the buffer.
Definition net_buf.h:1935
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.
static uint16_t net_buf_max_len(const struct net_buf *buf)
Check maximum net_buf::len value.
Definition net_buf.h:2709
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 net_buf.h:2632
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.
static void net_buf_drop(struct net_buf **orig)
Drop a buffer reference and clear the pointer.
Definition net_buf.h:1724
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 net_buf.h:2295
static uint32_t net_buf_remove_be24(struct net_buf *buf)
Remove and convert 24 bits from the end of the buffer.
Definition net_buf.h:2085
static void net_buf_add_be40(struct net_buf *buf, uint64_t val)
Add 40-bit value at the end of the buffer.
Definition net_buf.h:1950
static uint8_t net_buf_pull_u8(struct net_buf *buf)
Remove a 8-bit value from the beginning of the buffer.
Definition net_buf.h:2482
static void net_buf_destroy(struct net_buf *buf)
Destroy buffer from custom destroy callback.
Definition net_buf.h:1626
static size_t net_buf_simple_tailroom(const struct net_buf_simple *buf)
Check buffer tailroom.
Definition net_buf.h:934
void net_buf_simple_push_le40(struct net_buf_simple *buf, uint64_t val)
Push 40-bit value to the beginning of the buffer.
static uint16_t net_buf_simple_max_len(const struct net_buf_simple *buf)
Check maximum net_buf_simple::len value.
Definition net_buf.h:953
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.
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
Remove and convert 64 bits from the beginning of the buffer.
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 net_buf.h:2253
static uint64_t net_buf_pull_le48(struct net_buf *buf)
Remove and convert 48 bits from the beginning of the buffer.
Definition net_buf.h:2617
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 net_buf.h:2393
static uint32_t net_buf_pull_le24(struct net_buf *buf)
Remove and convert 24 bits from the beginning of the buffer.
Definition net_buf.h:2527
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 net_buf.h:1830
static void net_buf_push_be24(struct net_buf *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
Definition net_buf.h:2323
static void net_buf_push_le24(struct net_buf *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
Definition net_buf.h:2309
static void net_buf_reserve(struct net_buf *buf, size_t reserve)
Initialize buffer with the given headroom.
Definition net_buf.h:1780
static uint64_t net_buf_remove_be64(struct net_buf *buf)
Remove and convert 64 bits from the end of the buffer.
Definition net_buf.h:2220
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 bool net_buf_is_valid(const struct net_buf *buf)
Check that a buffer's length and pointers are self-consistent.
Definition net_buf.h:2729
static uint32_t net_buf_pull_be24(struct net_buf *buf)
Remove and convert 24 bits from the beginning of the buffer.
Definition net_buf.h:2542
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 net_buf.h:1980
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 net_buf.h:2100
static void net_buf_push_u8(struct net_buf *buf, uint8_t val)
Push 8-bit value to the beginning of the buffer.
Definition net_buf.h:2267
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 net_buf.h:2236
static uint16_t net_buf_pull_be16(struct net_buf *buf)
Remove and convert 16 bits from the beginning of the buffer.
Definition net_buf.h:2512
static void net_buf_push_le32(struct net_buf *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
Definition net_buf.h:2337
static uint64_t net_buf_pull_le64(struct net_buf *buf)
Remove and convert 64 bits from the beginning of the buffer.
Definition net_buf.h:2647
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.
struct net_buf *(* net_buf_allocator_cb)(k_timeout_t timeout, void *user_data)
Network buffer allocator callback.
Definition net_buf.h:2835
void * net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
Remove data from the beginning of the buffer.
static size_t net_buf_get_available(struct net_buf_pool *pool)
Get the number of buffers currently available to claim from a pool.
Definition net_buf.h:1500
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.
static uint8_t * net_buf_simple_tail(const struct net_buf_simple *buf)
Get the tail pointer for a buffer.
Definition net_buf.h:906
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 net_buf.h:2190
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 net_buf.h:1045
static uint16_t net_buf_remove_le16(struct net_buf *buf)
Remove and convert 16 bits from the end of the buffer.
Definition net_buf.h:2055
static void net_buf_push_le16(struct net_buf *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
Definition net_buf.h:2281
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_simple_save(const struct net_buf_simple *buf, struct net_buf_simple_state *state)
Save the parsing state of a buffer.
Definition net_buf.h:1013
static void net_buf_push_be48(struct net_buf *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
Definition net_buf.h:2407
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 net_buf.h:1995
static size_t net_buf_headroom(const struct net_buf *buf)
Check buffer headroom.
Definition net_buf.h:2690
static uint32_t net_buf_remove_be32(struct net_buf *buf)
Remove and convert 32 bits from the end of the buffer.
Definition net_buf.h:2130
int net_buf_id(const struct net_buf *buf)
Get a zero-based index for a buffer.
static void * net_buf_remove_mem(struct net_buf *buf, size_t len)
Remove data from the end of the buffer.
Definition net_buf.h:2025
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 net_buf.h:1813
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 net_buf.h:2421
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
Remove and convert 16 bits from the beginning of the buffer.
static size_t net_buf_get_max_used(struct net_buf_pool *pool)
Get the maximum number of buffers simultaneously claimed from a pool.
Definition net_buf.h:1514
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.
static uint8_t net_buf_remove_u8(struct net_buf *buf)
Remove a 8-bit value from the end of the buffer.
Definition net_buf.h:2040
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 size_t net_buf_simple_headroom(const struct net_buf_simple *buf)
Check buffer headroom.
Definition net_buf.h:920
static void net_buf_add_le16(struct net_buf *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
Definition net_buf.h:1845
static uint64_t net_buf_remove_be40(struct net_buf *buf)
Remove and convert 40 bits from the end of the buffer.
Definition net_buf.h:2160
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 net_buf.h:2351
static void net_buf_add_le32(struct net_buf *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
Definition net_buf.h:1905
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 net_buf.h:2115
static size_t net_buf_frags_len(const struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition net_buf.h:2916
static size_t net_buf_tailroom(const struct net_buf *buf)
Check buffer tailroom.
Definition net_buf.h:2676
static uint16_t net_buf_pull_le16(struct net_buf *buf)
Remove and convert 16 bits from the beginning of the buffer.
Definition net_buf.h:2497
static uint8_t * net_buf_tail(const struct net_buf *buf)
Get the tail pointer for a buffer.
Definition net_buf.h:2743
static void * net_buf_pull_mem(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition net_buf.h:2467
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 net_buf.h:1029
static void * net_buf_pull(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition net_buf.h:2451
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 net_buf.h:2365
static void net_buf_add_le48(struct net_buf *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
Definition net_buf.h:1965
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 net_buf.h:1756
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.
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
size_t net_buf_linearize(void *dst, size_t dst_len, const struct net_buf *src, size_t offset, size_t len)
Copy bytes from net_buf chain starting at offset to linear buffer.
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:54
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
#define NULL
Definition iar_missing_defs.h:20
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
Kernel LIFO structure.
Definition kernel.h:3211
Kernel Spin Lock.
Definition spinlock.h:45
Kernel timeout type.
Definition clock.h:65
Network buffer pool representation.
Definition net_buf.h:1190
void(*const destroy)(struct net_buf *buf)
Optional destroy callback when buffer is freed.
Definition net_buf.h:1221
uint16_t uninit_count
Number of uninitialized buffers.
Definition net_buf.h:1201
uint8_t user_data_size
Size of user data allocated to this pool.
Definition net_buf.h:1204
const uint16_t buf_count
Number of buffers in pool.
Definition net_buf.h:1198
const struct net_buf_data_alloc * alloc
Data allocation handlers.
Definition net_buf.h:1224
struct k_lifo free
LIFO to place the buffer into when free.
Definition net_buf.h:1192
struct k_spinlock lock
To prevent concurrent access/modifications.
Definition net_buf.h:1195
Parsing state of a buffer.
Definition net_buf.h:998
uint16_t offset
Offset of the data pointer from the beginning of the storage.
Definition net_buf.h:1000
uint16_t len
Length of data.
Definition net_buf.h:1002
Simple network buffer representation.
Definition net_buf.h:89
uint8_t * data
Pointer to the start of data in the buffer.
Definition net_buf.h:91
uint16_t size
Amount of data that net_buf_simple::__buf can store.
Definition net_buf.h:102
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:99
Network buffer representation.
Definition net_buf.h:1054
uint16_t size
Amount of data that this buffer can store.
Definition net_buf.h:1149
struct net_buf * frags
Fragments associated with this buffer.
Definition net_buf.h:1059
uint8_t ref
Reference count.
Definition net_buf.h:1122
uint8_t pool_id
Where the buffer should go when freed up.
Definition net_buf.h:1128
sys_snode_t node
Allow placing the buffer into sys_slist_t.
Definition net_buf.h:1056
uint8_t user_data_size
Size of user data on this buffer.
Definition net_buf.h:1131
uint8_t flags
Bit-field of buffer flags.
Definition net_buf.h:1125
uint8_t * data
Pointer to the start of data in the buffer.
Definition net_buf.h:1143
uint8_t user_data[]
System metadata for this buffer.
Definition net_buf.h:1164
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:1146
Iterable sections helpers.