Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
buf.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2015 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10#ifndef ZEPHYR_INCLUDE_NET_BUF_H_
11#define ZEPHYR_INCLUDE_NET_BUF_H_
12
13#include <stddef.h>
14#include <zephyr/types.h>
15#include <zephyr/sys/util.h>
16#include <zephyr/kernel.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
30/* Alignment needed for various parts of the buffer definition */
31#if CONFIG_NET_BUF_ALIGNMENT == 0
32#define __net_buf_align __aligned(sizeof(void *))
33#else
34#define __net_buf_align __aligned(CONFIG_NET_BUF_ALIGNMENT)
35#endif
36
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, \
50 .len = 0, \
51 .size = _size, \
52 .__buf = net_buf_data_##_name, \
53 }
54
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, \
69 .len = 0, \
70 .size = _size, \
71 .__buf = net_buf_data_##_name, \
72 }
73
90
97
100
104 uint8_t *__buf;
105};
106
123#define NET_BUF_SIMPLE(_size) \
124 ((struct net_buf_simple *)(&(struct { \
125 struct net_buf_simple buf; \
126 uint8_t data[_size]; \
127 }) { \
128 .buf.size = _size, \
129 }))
130
140static inline void net_buf_simple_init(struct net_buf_simple *buf,
141 size_t reserve_head)
142{
143 if (!buf->__buf) {
144 buf->__buf = (uint8_t *)buf + sizeof(*buf);
145 }
146
147 buf->data = buf->__buf + reserve_head;
148 buf->len = 0U;
149}
150
161 void *data, size_t size);
162
170static inline void net_buf_simple_reset(struct net_buf_simple *buf)
171{
172 buf->len = 0U;
173 buf->data = buf->__buf;
174}
175
186void net_buf_simple_clone(const struct net_buf_simple *original,
187 struct net_buf_simple *clone);
188
200void *net_buf_simple_add(struct net_buf_simple *buf, size_t len);
201
214void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
215 size_t len);
216
229
241
253
265
277
289
301
313
325
337
349
361
373
384void *net_buf_simple_remove_mem(struct net_buf_simple *buf, size_t len);
385
397
409
421
433
445
457
469
481
493
505
517
529
541
553void *net_buf_simple_push(struct net_buf_simple *buf, size_t len);
554
567void *net_buf_simple_push_mem(struct net_buf_simple *buf, const void *mem,
568 size_t len);
569
580
591
601
612
623
634
645
656
667
678
689
700
711
723void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len);
724
736void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len);
737
749
761
773
785
797
809
821
833
845
857
869
881
893
903static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf)
904{
905 return buf->data + buf->len;
906}
907
918
929
940
953};
954
963static inline void net_buf_simple_save(struct net_buf_simple *buf,
965{
966 state->offset = net_buf_simple_headroom(buf);
967 state->len = buf->len;
968}
969
979static inline void net_buf_simple_restore(struct net_buf_simple *buf,
981{
982 buf->data = buf->__buf + state->offset;
983 buf->len = state->len;
984}
985
995#define NET_BUF_EXTERNAL_DATA BIT(0)
996
1004struct net_buf {
1007
1010
1013
1016
1019
1020 /* Size of user data on this buffer */
1022
1023 /* Union for convenience access to the net_buf_simple members, also
1024 * preserving the old API.
1025 */
1026 union {
1027 /* The ABI of this struct must match net_buf_simple */
1028 struct {
1031
1034
1037
1042 uint8_t *__buf;
1043 };
1044
1046 };
1047
1049 uint8_t user_data[] __net_buf_align;
1050};
1051
1053 uint8_t * __must_check (*alloc)(struct net_buf *buf, size_t *size,
1054 k_timeout_t timeout);
1055 uint8_t * __must_check (*ref)(struct net_buf *buf, uint8_t *data);
1056 void (*unref)(struct net_buf *buf, uint8_t *data);
1057};
1058
1060 const struct net_buf_data_cb *cb;
1063};
1064
1072 struct k_lifo free;
1073
1074 /* to prevent concurrent access/modifications */
1076
1079
1082
1083 /* Size of user data allocated to this pool */
1085
1086#if defined(CONFIG_NET_BUF_POOL_USAGE)
1088 atomic_t avail_count;
1089
1091 const uint16_t pool_size;
1092
1094 const char *name;
1095#endif /* CONFIG_NET_BUF_POOL_USAGE */
1096
1098 void (*const destroy)(struct net_buf *buf);
1099
1102
1104 struct net_buf * const __bufs;
1105};
1106
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),))
1111
1112#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _ud_size, _destroy) \
1113 { \
1114 .free = Z_LIFO_INITIALIZER(_pool.free), \
1115 .lock = { }, \
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, \
1121 .alloc = _alloc, \
1122 .__bufs = (struct net_buf *)_bufs, \
1123 }
1124
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
1137
1138extern const struct net_buf_data_alloc net_buf_heap_alloc;
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, \
1173 _destroy)
1174
1177};
1178
1180extern const struct net_buf_data_cb net_buf_fixed_cb;
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, \
1216 }; \
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, \
1221 }; \
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, \
1225 _destroy)
1226
1228extern const struct net_buf_data_cb net_buf_var_cb;
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, \
1262 }; \
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, \
1266 _destroy)
1267
1289#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1290 NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _ud_size, _destroy)
1291
1300
1313int net_buf_id(struct net_buf *buf);
1314
1329#if defined(CONFIG_NET_BUF_LOG)
1330struct net_buf * __must_check net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
1331 k_timeout_t timeout,
1332 const char *func,
1333 int line);
1334#define net_buf_alloc_fixed(_pool, _timeout) \
1335 net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1336#else
1337struct net_buf * __must_check net_buf_alloc_fixed(struct net_buf_pool *pool,
1338 k_timeout_t timeout);
1339#endif
1340
1344static inline struct net_buf * __must_check net_buf_alloc(struct net_buf_pool *pool,
1345 k_timeout_t timeout)
1346{
1347 return net_buf_alloc_fixed(pool, timeout);
1348}
1349
1365#if defined(CONFIG_NET_BUF_LOG)
1366struct net_buf * __must_check net_buf_alloc_len_debug(struct net_buf_pool *pool,
1367 size_t size,
1368 k_timeout_t timeout,
1369 const char *func,
1370 int line);
1371#define net_buf_alloc_len(_pool, _size, _timeout) \
1372 net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1373#else
1374struct net_buf * __must_check net_buf_alloc_len(struct net_buf_pool *pool,
1375 size_t size,
1376 k_timeout_t timeout);
1377#endif
1378
1398#if defined(CONFIG_NET_BUF_LOG)
1399struct net_buf * __must_check net_buf_alloc_with_data_debug(struct net_buf_pool *pool,
1400 void *data, size_t size,
1401 k_timeout_t timeout,
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, \
1405 __func__, __LINE__)
1406#else
1407struct net_buf * __must_check net_buf_alloc_with_data(struct net_buf_pool *pool,
1408 void *data, size_t size,
1409 k_timeout_t timeout);
1410#endif
1411
1425#if defined(CONFIG_NET_BUF_LOG)
1426struct net_buf * __must_check net_buf_get_debug(struct k_fifo *fifo,
1427 k_timeout_t timeout,
1428 const char *func, int line);
1429#define net_buf_get(_fifo, _timeout) \
1430 net_buf_get_debug(_fifo, _timeout, __func__, __LINE__)
1431#else
1432struct net_buf * __must_check net_buf_get(struct k_fifo *fifo,
1433 k_timeout_t timeout);
1434#endif
1435
1445static inline void net_buf_destroy(struct net_buf *buf)
1446{
1447 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
1448
1449 if (buf->__buf) {
1450 if (!(buf->flags & NET_BUF_EXTERNAL_DATA)) {
1451 pool->alloc->cb->unref(buf, buf->__buf);
1452 }
1453 buf->__buf = NULL;
1454 }
1455
1456 k_lifo_put(&pool->free, buf);
1457}
1458
1466void net_buf_reset(struct net_buf *buf);
1467
1476void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve);
1477
1487void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
1488
1499struct net_buf * __must_check net_buf_slist_get(sys_slist_t *list);
1500
1510void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
1511
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__)
1523#else
1524void net_buf_unref(struct net_buf *buf);
1525#endif
1526
1534struct net_buf * __must_check net_buf_ref(struct net_buf *buf);
1535
1549struct net_buf * __must_check net_buf_clone(struct net_buf *buf,
1550 k_timeout_t timeout);
1551
1559static inline void * __must_check net_buf_user_data(const struct net_buf *buf)
1560{
1561 return (void *)buf->user_data;
1562}
1563
1573int net_buf_user_data_copy(struct net_buf *dst, const struct net_buf *src);
1574
1583static inline void net_buf_reserve(struct net_buf *buf, size_t reserve)
1584{
1585 net_buf_simple_reserve(&buf->b, reserve);
1586}
1587
1599static inline void *net_buf_add(struct net_buf *buf, size_t len)
1600{
1601 return net_buf_simple_add(&buf->b, len);
1602}
1603
1616static inline void *net_buf_add_mem(struct net_buf *buf, const void *mem,
1617 size_t len)
1618{
1619 return net_buf_simple_add_mem(&buf->b, mem, len);
1620}
1621
1633static inline uint8_t *net_buf_add_u8(struct net_buf *buf, uint8_t val)
1634{
1635 return net_buf_simple_add_u8(&buf->b, val);
1636}
1637
1648static inline void net_buf_add_le16(struct net_buf *buf, uint16_t val)
1649{
1650 net_buf_simple_add_le16(&buf->b, val);
1651}
1652
1663static inline void net_buf_add_be16(struct net_buf *buf, uint16_t val)
1664{
1665 net_buf_simple_add_be16(&buf->b, val);
1666}
1667
1678static inline void net_buf_add_le24(struct net_buf *buf, uint32_t val)
1679{
1680 net_buf_simple_add_le24(&buf->b, val);
1681}
1682
1693static inline void net_buf_add_be24(struct net_buf *buf, uint32_t val)
1694{
1695 net_buf_simple_add_be24(&buf->b, val);
1696}
1697
1708static inline void net_buf_add_le32(struct net_buf *buf, uint32_t val)
1709{
1710 net_buf_simple_add_le32(&buf->b, val);
1711}
1712
1723static inline void net_buf_add_be32(struct net_buf *buf, uint32_t val)
1724{
1725 net_buf_simple_add_be32(&buf->b, val);
1726}
1727
1738static inline void net_buf_add_le40(struct net_buf *buf, uint64_t val)
1739{
1740 net_buf_simple_add_le40(&buf->b, val);
1741}
1742
1753static inline void net_buf_add_be40(struct net_buf *buf, uint64_t val)
1754{
1755 net_buf_simple_add_be40(&buf->b, val);
1756}
1757
1768static inline void net_buf_add_le48(struct net_buf *buf, uint64_t val)
1769{
1770 net_buf_simple_add_le48(&buf->b, val);
1771}
1772
1783static inline void net_buf_add_be48(struct net_buf *buf, uint64_t val)
1784{
1785 net_buf_simple_add_be48(&buf->b, val);
1786}
1787
1798static inline void net_buf_add_le64(struct net_buf *buf, uint64_t val)
1799{
1800 net_buf_simple_add_le64(&buf->b, val);
1801}
1802
1813static inline void net_buf_add_be64(struct net_buf *buf, uint64_t val)
1814{
1815 net_buf_simple_add_be64(&buf->b, val);
1816}
1817
1828static inline void *net_buf_remove_mem(struct net_buf *buf, size_t len)
1829{
1830 return net_buf_simple_remove_mem(&buf->b, len);
1831}
1832
1843static inline uint8_t net_buf_remove_u8(struct net_buf *buf)
1844{
1845 return net_buf_simple_remove_u8(&buf->b);
1846}
1847
1858static inline uint16_t net_buf_remove_le16(struct net_buf *buf)
1859{
1860 return net_buf_simple_remove_le16(&buf->b);
1861}
1862
1873static inline uint16_t net_buf_remove_be16(struct net_buf *buf)
1874{
1875 return net_buf_simple_remove_be16(&buf->b);
1876}
1877
1888static inline uint32_t net_buf_remove_be24(struct net_buf *buf)
1889{
1890 return net_buf_simple_remove_be24(&buf->b);
1891}
1892
1903static inline uint32_t net_buf_remove_le24(struct net_buf *buf)
1904{
1905 return net_buf_simple_remove_le24(&buf->b);
1906}
1907
1918static inline uint32_t net_buf_remove_le32(struct net_buf *buf)
1919{
1920 return net_buf_simple_remove_le32(&buf->b);
1921}
1922
1933static inline uint32_t net_buf_remove_be32(struct net_buf *buf)
1934{
1935 return net_buf_simple_remove_be32(&buf->b);
1936}
1937
1948static inline uint64_t net_buf_remove_le40(struct net_buf *buf)
1949{
1950 return net_buf_simple_remove_le40(&buf->b);
1951}
1952
1963static inline uint64_t net_buf_remove_be40(struct net_buf *buf)
1964{
1965 return net_buf_simple_remove_be40(&buf->b);
1966}
1967
1978static inline uint64_t net_buf_remove_le48(struct net_buf *buf)
1979{
1980 return net_buf_simple_remove_le48(&buf->b);
1981}
1982
1993static inline uint64_t net_buf_remove_be48(struct net_buf *buf)
1994{
1995 return net_buf_simple_remove_be48(&buf->b);
1996}
1997
2008static inline uint64_t net_buf_remove_le64(struct net_buf *buf)
2009{
2010 return net_buf_simple_remove_le64(&buf->b);
2011}
2012
2023static inline uint64_t net_buf_remove_be64(struct net_buf *buf)
2024{
2025 return net_buf_simple_remove_be64(&buf->b);
2026}
2027
2039static inline void *net_buf_push(struct net_buf *buf, size_t len)
2040{
2041 return net_buf_simple_push(&buf->b, len);
2042}
2043
2056static inline void *net_buf_push_mem(struct net_buf *buf, const void *mem,
2057 size_t len)
2058{
2059 return net_buf_simple_push_mem(&buf->b, mem, len);
2060}
2061
2070static inline void net_buf_push_u8(struct net_buf *buf, uint8_t val)
2071{
2072 net_buf_simple_push_u8(&buf->b, val);
2073}
2074
2084static inline void net_buf_push_le16(struct net_buf *buf, uint16_t val)
2085{
2086 net_buf_simple_push_le16(&buf->b, val);
2087}
2088
2098static inline void net_buf_push_be16(struct net_buf *buf, uint16_t val)
2099{
2100 net_buf_simple_push_be16(&buf->b, val);
2101}
2102
2112static inline void net_buf_push_le24(struct net_buf *buf, uint32_t val)
2113{
2114 net_buf_simple_push_le24(&buf->b, val);
2115}
2116
2126static inline void net_buf_push_be24(struct net_buf *buf, uint32_t val)
2127{
2128 net_buf_simple_push_be24(&buf->b, val);
2129}
2130
2140static inline void net_buf_push_le32(struct net_buf *buf, uint32_t val)
2141{
2142 net_buf_simple_push_le32(&buf->b, val);
2143}
2144
2154static inline void net_buf_push_be32(struct net_buf *buf, uint32_t val)
2155{
2156 net_buf_simple_push_be32(&buf->b, val);
2157}
2158
2168static inline void net_buf_push_le40(struct net_buf *buf, uint64_t val)
2169{
2170 net_buf_simple_push_le40(&buf->b, val);
2171}
2172
2182static inline void net_buf_push_be40(struct net_buf *buf, uint64_t val)
2183{
2184 net_buf_simple_push_be40(&buf->b, val);
2185}
2186
2196static inline void net_buf_push_le48(struct net_buf *buf, uint64_t val)
2197{
2198 net_buf_simple_push_le48(&buf->b, val);
2199}
2200
2210static inline void net_buf_push_be48(struct net_buf *buf, uint64_t val)
2211{
2212 net_buf_simple_push_be48(&buf->b, val);
2213}
2214
2224static inline void net_buf_push_le64(struct net_buf *buf, uint64_t val)
2225{
2226 net_buf_simple_push_le64(&buf->b, val);
2227}
2228
2238static inline void net_buf_push_be64(struct net_buf *buf, uint64_t val)
2239{
2240 net_buf_simple_push_be64(&buf->b, val);
2241}
2242
2254static inline void *net_buf_pull(struct net_buf *buf, size_t len)
2255{
2256 return net_buf_simple_pull(&buf->b, len);
2257}
2258
2270static inline void *net_buf_pull_mem(struct net_buf *buf, size_t len)
2271{
2272 return net_buf_simple_pull_mem(&buf->b, len);
2273}
2274
2285static inline uint8_t net_buf_pull_u8(struct net_buf *buf)
2286{
2287 return net_buf_simple_pull_u8(&buf->b);
2288}
2289
2300static inline uint16_t net_buf_pull_le16(struct net_buf *buf)
2301{
2302 return net_buf_simple_pull_le16(&buf->b);
2303}
2304
2315static inline uint16_t net_buf_pull_be16(struct net_buf *buf)
2316{
2317 return net_buf_simple_pull_be16(&buf->b);
2318}
2319
2330static inline uint32_t net_buf_pull_le24(struct net_buf *buf)
2331{
2332 return net_buf_simple_pull_le24(&buf->b);
2333}
2334
2345static inline uint32_t net_buf_pull_be24(struct net_buf *buf)
2346{
2347 return net_buf_simple_pull_be24(&buf->b);
2348}
2349
2360static inline uint32_t net_buf_pull_le32(struct net_buf *buf)
2361{
2362 return net_buf_simple_pull_le32(&buf->b);
2363}
2364
2375static inline uint32_t net_buf_pull_be32(struct net_buf *buf)
2376{
2377 return net_buf_simple_pull_be32(&buf->b);
2378}
2379
2390static inline uint64_t net_buf_pull_le40(struct net_buf *buf)
2391{
2392 return net_buf_simple_pull_le40(&buf->b);
2393}
2394
2405static inline uint64_t net_buf_pull_be40(struct net_buf *buf)
2406{
2407 return net_buf_simple_pull_be40(&buf->b);
2408}
2409
2420static inline uint64_t net_buf_pull_le48(struct net_buf *buf)
2421{
2422 return net_buf_simple_pull_le48(&buf->b);
2423}
2424
2435static inline uint64_t net_buf_pull_be48(struct net_buf *buf)
2436{
2437 return net_buf_simple_pull_be48(&buf->b);
2438}
2439
2450static inline uint64_t net_buf_pull_le64(struct net_buf *buf)
2451{
2452 return net_buf_simple_pull_le64(&buf->b);
2453}
2454
2465static inline uint64_t net_buf_pull_be64(struct net_buf *buf)
2466{
2467 return net_buf_simple_pull_be64(&buf->b);
2468}
2469
2479static inline size_t net_buf_tailroom(struct net_buf *buf)
2480{
2481 return net_buf_simple_tailroom(&buf->b);
2482}
2483
2493static inline size_t net_buf_headroom(struct net_buf *buf)
2494{
2495 return net_buf_simple_headroom(&buf->b);
2496}
2497
2507static inline uint16_t net_buf_max_len(struct net_buf *buf)
2508{
2509 return net_buf_simple_max_len(&buf->b);
2510}
2511
2521static inline uint8_t *net_buf_tail(struct net_buf *buf)
2522{
2523 return net_buf_simple_tail(&buf->b);
2524}
2525
2532
2544void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
2545
2560struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
2561
2571#if defined(CONFIG_NET_BUF_LOG)
2572struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
2573 struct net_buf *frag,
2574 const char *func, int line);
2575#define net_buf_frag_del(_parent, _frag) \
2576 net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2577#else
2578struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
2579#endif
2580
2596size_t net_buf_linearize(void *dst, size_t dst_len,
2597 struct net_buf *src, size_t offset, size_t len);
2598
2613typedef struct net_buf * __must_check (*net_buf_allocator_cb)(k_timeout_t timeout,
2614 void *user_data);
2615
2637size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
2638 const void *value, k_timeout_t timeout,
2639 net_buf_allocator_cb allocate_cb, void *user_data);
2640
2655size_t net_buf_data_match(const struct net_buf *buf, size_t offset, const void *data, size_t len);
2656
2672static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
2673{
2674 while (buf && len--) {
2675 net_buf_pull_u8(buf);
2676 if (!buf->len) {
2677 buf = net_buf_frag_del(NULL, buf);
2678 }
2679 }
2680
2681 return buf;
2682}
2683
2694static inline size_t net_buf_frags_len(struct net_buf *buf)
2695{
2696 size_t bytes = 0;
2697
2698 while (buf) {
2699 bytes += buf->len;
2700 buf = buf->frags;
2701 }
2702
2703 return bytes;
2704}
2705
2710#ifdef __cplusplus
2711}
2712#endif
2713
2714#endif /* ZEPHYR_INCLUDE_NET_BUF_H_ */
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
Public kernel APIs.
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
Definition: buf.h:1059
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
Definition: buf.h:1052
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
Definition: buf.h:1175
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
Misc utilities.