Zephyr Project API 3.7.0
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(const struct net_buf_simple *buf)
904{
905 return buf->data + buf->len;
906}
907
917size_t net_buf_simple_headroom(const struct net_buf_simple *buf);
918
928size_t net_buf_simple_tailroom(const struct net_buf_simple *buf);
929
940
954
963static inline void net_buf_simple_save(const struct net_buf_simple *buf,
965{
966 state->offset = (uint16_t)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
1022
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 struct net_buf_simple b;
1048 };
1049
1051 uint8_t user_data[] __net_buf_align;
1052};
1053
1056struct net_buf_data_cb {
1057 uint8_t * __must_check (*alloc)(struct net_buf *buf, size_t *size,
1059 uint8_t * __must_check (*ref)(struct net_buf *buf, uint8_t *data);
1060 void (*unref)(struct net_buf *buf, uint8_t *data);
1061};
1062
1063struct net_buf_data_alloc {
1064 const struct net_buf_data_cb *cb;
1065 void *alloc_data;
1066 size_t max_alloc_size;
1067};
1068
1078 struct k_lifo free;
1079
1082
1085
1088
1091
1092#if defined(CONFIG_NET_BUF_POOL_USAGE)
1094 atomic_t avail_count;
1095
1097 const uint16_t pool_size;
1098
1100 const char *name;
1101#endif /* CONFIG_NET_BUF_POOL_USAGE */
1102
1104 void (*const destroy)(struct net_buf *buf);
1105
1107 const struct net_buf_data_alloc *alloc;
1108
1110 struct net_buf * const __bufs;
1111};
1112
1114#define NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1115 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.avail_count = ATOMIC_INIT(_count),)) \
1116 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.name = STRINGIFY(_pool),))
1117
1118#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _ud_size, _destroy) \
1119 { \
1120 .free = Z_LIFO_INITIALIZER(_pool.free), \
1121 .lock = { }, \
1122 .buf_count = _count, \
1123 .uninit_count = _count, \
1124 .user_data_size = _ud_size, \
1125 NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1126 .destroy = _destroy, \
1127 .alloc = _alloc, \
1128 .__bufs = (struct net_buf *)_bufs, \
1129 }
1130
1131#define _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size) \
1132 struct _net_buf_##_name { uint8_t b[sizeof(struct net_buf)]; \
1133 uint8_t ud[_ud_size]; } __net_buf_align; \
1134 BUILD_ASSERT(_ud_size <= UINT8_MAX); \
1135 BUILD_ASSERT(offsetof(struct net_buf, user_data) == \
1136 offsetof(struct _net_buf_##_name, ud), "Invalid offset"); \
1137 BUILD_ASSERT(__alignof__(struct net_buf) == \
1138 __alignof__(struct _net_buf_##_name), "Invalid alignment"); \
1139 BUILD_ASSERT(sizeof(struct _net_buf_##_name) == \
1140 ROUND_UP(sizeof(struct net_buf) + _ud_size, __alignof__(struct net_buf)), \
1141 "Size cannot be determined"); \
1142 static struct _net_buf_##_name _net_buf_##_name[_count] __noinit
1143
1144extern const struct net_buf_data_alloc net_buf_heap_alloc;
1174#define NET_BUF_POOL_HEAP_DEFINE(_name, _count, _ud_size, _destroy) \
1175 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1176 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1177 NET_BUF_POOL_INITIALIZER(_name, &net_buf_heap_alloc, \
1178 _net_buf_##_name, _count, _ud_size, \
1179 _destroy)
1180
1183struct net_buf_pool_fixed {
1184 uint8_t *data_pool;
1185};
1186
1187extern const struct net_buf_data_cb net_buf_fixed_cb;
1188
1219#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1220 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1221 static uint8_t __noinit net_buf_data_##_name[_count][_data_size] __net_buf_align; \
1222 static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
1223 .data_pool = (uint8_t *)net_buf_data_##_name, \
1224 }; \
1225 static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
1226 .cb = &net_buf_fixed_cb, \
1227 .alloc_data = (void *)&net_buf_fixed_##_name, \
1228 .max_alloc_size = _data_size, \
1229 }; \
1230 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1231 NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \
1232 _net_buf_##_name, _count, _ud_size, \
1233 _destroy)
1234
1236extern const struct net_buf_data_cb net_buf_var_cb;
1263#define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1264 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1265 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1266 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1267 .cb = &net_buf_var_cb, \
1268 .alloc_data = &net_buf_mem_pool_##_name, \
1269 .max_alloc_size = 0, \
1270 }; \
1271 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1272 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1273 _net_buf_##_name, _count, _ud_size, \
1274 _destroy)
1275
1297#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1298 NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _ud_size, _destroy)
1299
1308
1321int net_buf_id(const struct net_buf *buf);
1322
1342#if defined(CONFIG_NET_BUF_LOG)
1343struct net_buf * __must_check net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
1345 const char *func,
1346 int line);
1347#define net_buf_alloc_fixed(_pool, _timeout) \
1348 net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1349#else
1350struct net_buf * __must_check net_buf_alloc_fixed(struct net_buf_pool *pool,
1352#endif
1353
1357static inline struct net_buf * __must_check net_buf_alloc(struct net_buf_pool *pool,
1359{
1360 return net_buf_alloc_fixed(pool, timeout);
1361}
1362
1383#if defined(CONFIG_NET_BUF_LOG)
1384struct net_buf * __must_check net_buf_alloc_len_debug(struct net_buf_pool *pool,
1385 size_t size,
1387 const char *func,
1388 int line);
1389#define net_buf_alloc_len(_pool, _size, _timeout) \
1390 net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1391#else
1392struct net_buf * __must_check net_buf_alloc_len(struct net_buf_pool *pool,
1393 size_t size,
1395#endif
1396
1421#if defined(CONFIG_NET_BUF_LOG)
1422struct net_buf * __must_check net_buf_alloc_with_data_debug(struct net_buf_pool *pool,
1423 void *data, size_t size,
1425 const char *func, int line);
1426#define net_buf_alloc_with_data(_pool, _data_, _size, _timeout) \
1427 net_buf_alloc_with_data_debug(_pool, _data_, _size, _timeout, \
1428 __func__, __LINE__)
1429#else
1430struct net_buf * __must_check net_buf_alloc_with_data(struct net_buf_pool *pool,
1431 void *data, size_t size,
1433#endif
1434
1448#if defined(CONFIG_NET_BUF_LOG)
1449struct net_buf * __must_check net_buf_get_debug(struct k_fifo *fifo,
1451 const char *func, int line);
1452#define net_buf_get(_fifo, _timeout) \
1453 net_buf_get_debug(_fifo, _timeout, __func__, __LINE__)
1454#else
1455struct net_buf * __must_check net_buf_get(struct k_fifo *fifo,
1457#endif
1458
1468static inline void net_buf_destroy(struct net_buf *buf)
1469{
1470 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
1471
1472 if (buf->__buf) {
1473 if (!(buf->flags & NET_BUF_EXTERNAL_DATA)) {
1474 pool->alloc->cb->unref(buf, buf->__buf);
1475 }
1476 buf->__buf = NULL;
1477 }
1478
1479 k_lifo_put(&pool->free, buf);
1480}
1481
1489void net_buf_reset(struct net_buf *buf);
1490
1499void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve);
1500
1510void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
1511
1522struct net_buf * __must_check net_buf_slist_get(sys_slist_t *list);
1523
1533void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
1534
1542#if defined(CONFIG_NET_BUF_LOG)
1543void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
1544#define net_buf_unref(_buf) \
1545 net_buf_unref_debug(_buf, __func__, __LINE__)
1546#else
1547void net_buf_unref(struct net_buf *buf);
1548#endif
1549
1557struct net_buf * __must_check net_buf_ref(struct net_buf *buf);
1558
1572struct net_buf * __must_check net_buf_clone(struct net_buf *buf,
1574
1582static inline void * __must_check net_buf_user_data(const struct net_buf *buf)
1583{
1584 return (void *)buf->user_data;
1585}
1586
1596int net_buf_user_data_copy(struct net_buf *dst, const struct net_buf *src);
1597
1606static inline void net_buf_reserve(struct net_buf *buf, size_t reserve)
1607{
1608 net_buf_simple_reserve(&buf->b, reserve);
1609}
1610
1622static inline void *net_buf_add(struct net_buf *buf, size_t len)
1623{
1624 return net_buf_simple_add(&buf->b, len);
1625}
1626
1639static inline void *net_buf_add_mem(struct net_buf *buf, const void *mem,
1640 size_t len)
1641{
1642 return net_buf_simple_add_mem(&buf->b, mem, len);
1643}
1644
1656static inline uint8_t *net_buf_add_u8(struct net_buf *buf, uint8_t val)
1657{
1658 return net_buf_simple_add_u8(&buf->b, val);
1659}
1660
1671static inline void net_buf_add_le16(struct net_buf *buf, uint16_t val)
1672{
1673 net_buf_simple_add_le16(&buf->b, val);
1674}
1675
1686static inline void net_buf_add_be16(struct net_buf *buf, uint16_t val)
1687{
1688 net_buf_simple_add_be16(&buf->b, val);
1689}
1690
1701static inline void net_buf_add_le24(struct net_buf *buf, uint32_t val)
1702{
1703 net_buf_simple_add_le24(&buf->b, val);
1704}
1705
1716static inline void net_buf_add_be24(struct net_buf *buf, uint32_t val)
1717{
1718 net_buf_simple_add_be24(&buf->b, val);
1719}
1720
1731static inline void net_buf_add_le32(struct net_buf *buf, uint32_t val)
1732{
1733 net_buf_simple_add_le32(&buf->b, val);
1734}
1735
1746static inline void net_buf_add_be32(struct net_buf *buf, uint32_t val)
1747{
1748 net_buf_simple_add_be32(&buf->b, val);
1749}
1750
1761static inline void net_buf_add_le40(struct net_buf *buf, uint64_t val)
1762{
1763 net_buf_simple_add_le40(&buf->b, val);
1764}
1765
1776static inline void net_buf_add_be40(struct net_buf *buf, uint64_t val)
1777{
1778 net_buf_simple_add_be40(&buf->b, val);
1779}
1780
1791static inline void net_buf_add_le48(struct net_buf *buf, uint64_t val)
1792{
1793 net_buf_simple_add_le48(&buf->b, val);
1794}
1795
1806static inline void net_buf_add_be48(struct net_buf *buf, uint64_t val)
1807{
1808 net_buf_simple_add_be48(&buf->b, val);
1809}
1810
1821static inline void net_buf_add_le64(struct net_buf *buf, uint64_t val)
1822{
1823 net_buf_simple_add_le64(&buf->b, val);
1824}
1825
1836static inline void net_buf_add_be64(struct net_buf *buf, uint64_t val)
1837{
1838 net_buf_simple_add_be64(&buf->b, val);
1839}
1840
1851static inline void *net_buf_remove_mem(struct net_buf *buf, size_t len)
1852{
1853 return net_buf_simple_remove_mem(&buf->b, len);
1854}
1855
1866static inline uint8_t net_buf_remove_u8(struct net_buf *buf)
1867{
1868 return net_buf_simple_remove_u8(&buf->b);
1869}
1870
1881static inline uint16_t net_buf_remove_le16(struct net_buf *buf)
1882{
1883 return net_buf_simple_remove_le16(&buf->b);
1884}
1885
1896static inline uint16_t net_buf_remove_be16(struct net_buf *buf)
1897{
1898 return net_buf_simple_remove_be16(&buf->b);
1899}
1900
1911static inline uint32_t net_buf_remove_be24(struct net_buf *buf)
1912{
1913 return net_buf_simple_remove_be24(&buf->b);
1914}
1915
1926static inline uint32_t net_buf_remove_le24(struct net_buf *buf)
1927{
1928 return net_buf_simple_remove_le24(&buf->b);
1929}
1930
1941static inline uint32_t net_buf_remove_le32(struct net_buf *buf)
1942{
1943 return net_buf_simple_remove_le32(&buf->b);
1944}
1945
1956static inline uint32_t net_buf_remove_be32(struct net_buf *buf)
1957{
1958 return net_buf_simple_remove_be32(&buf->b);
1959}
1960
1971static inline uint64_t net_buf_remove_le40(struct net_buf *buf)
1972{
1973 return net_buf_simple_remove_le40(&buf->b);
1974}
1975
1986static inline uint64_t net_buf_remove_be40(struct net_buf *buf)
1987{
1988 return net_buf_simple_remove_be40(&buf->b);
1989}
1990
2001static inline uint64_t net_buf_remove_le48(struct net_buf *buf)
2002{
2003 return net_buf_simple_remove_le48(&buf->b);
2004}
2005
2016static inline uint64_t net_buf_remove_be48(struct net_buf *buf)
2017{
2018 return net_buf_simple_remove_be48(&buf->b);
2019}
2020
2031static inline uint64_t net_buf_remove_le64(struct net_buf *buf)
2032{
2033 return net_buf_simple_remove_le64(&buf->b);
2034}
2035
2046static inline uint64_t net_buf_remove_be64(struct net_buf *buf)
2047{
2048 return net_buf_simple_remove_be64(&buf->b);
2049}
2050
2062static inline void *net_buf_push(struct net_buf *buf, size_t len)
2063{
2064 return net_buf_simple_push(&buf->b, len);
2065}
2066
2079static inline void *net_buf_push_mem(struct net_buf *buf, const void *mem,
2080 size_t len)
2081{
2082 return net_buf_simple_push_mem(&buf->b, mem, len);
2083}
2084
2093static inline void net_buf_push_u8(struct net_buf *buf, uint8_t val)
2094{
2095 net_buf_simple_push_u8(&buf->b, val);
2096}
2097
2107static inline void net_buf_push_le16(struct net_buf *buf, uint16_t val)
2108{
2109 net_buf_simple_push_le16(&buf->b, val);
2110}
2111
2121static inline void net_buf_push_be16(struct net_buf *buf, uint16_t val)
2122{
2123 net_buf_simple_push_be16(&buf->b, val);
2124}
2125
2135static inline void net_buf_push_le24(struct net_buf *buf, uint32_t val)
2136{
2137 net_buf_simple_push_le24(&buf->b, val);
2138}
2139
2149static inline void net_buf_push_be24(struct net_buf *buf, uint32_t val)
2150{
2151 net_buf_simple_push_be24(&buf->b, val);
2152}
2153
2163static inline void net_buf_push_le32(struct net_buf *buf, uint32_t val)
2164{
2165 net_buf_simple_push_le32(&buf->b, val);
2166}
2167
2177static inline void net_buf_push_be32(struct net_buf *buf, uint32_t val)
2178{
2179 net_buf_simple_push_be32(&buf->b, val);
2180}
2181
2191static inline void net_buf_push_le40(struct net_buf *buf, uint64_t val)
2192{
2193 net_buf_simple_push_le40(&buf->b, val);
2194}
2195
2205static inline void net_buf_push_be40(struct net_buf *buf, uint64_t val)
2206{
2207 net_buf_simple_push_be40(&buf->b, val);
2208}
2209
2219static inline void net_buf_push_le48(struct net_buf *buf, uint64_t val)
2220{
2221 net_buf_simple_push_le48(&buf->b, val);
2222}
2223
2233static inline void net_buf_push_be48(struct net_buf *buf, uint64_t val)
2234{
2235 net_buf_simple_push_be48(&buf->b, val);
2236}
2237
2247static inline void net_buf_push_le64(struct net_buf *buf, uint64_t val)
2248{
2249 net_buf_simple_push_le64(&buf->b, val);
2250}
2251
2261static inline void net_buf_push_be64(struct net_buf *buf, uint64_t val)
2262{
2263 net_buf_simple_push_be64(&buf->b, val);
2264}
2265
2277static inline void *net_buf_pull(struct net_buf *buf, size_t len)
2278{
2279 return net_buf_simple_pull(&buf->b, len);
2280}
2281
2293static inline void *net_buf_pull_mem(struct net_buf *buf, size_t len)
2294{
2295 return net_buf_simple_pull_mem(&buf->b, len);
2296}
2297
2308static inline uint8_t net_buf_pull_u8(struct net_buf *buf)
2309{
2310 return net_buf_simple_pull_u8(&buf->b);
2311}
2312
2323static inline uint16_t net_buf_pull_le16(struct net_buf *buf)
2324{
2325 return net_buf_simple_pull_le16(&buf->b);
2326}
2327
2338static inline uint16_t net_buf_pull_be16(struct net_buf *buf)
2339{
2340 return net_buf_simple_pull_be16(&buf->b);
2341}
2342
2353static inline uint32_t net_buf_pull_le24(struct net_buf *buf)
2354{
2355 return net_buf_simple_pull_le24(&buf->b);
2356}
2357
2368static inline uint32_t net_buf_pull_be24(struct net_buf *buf)
2369{
2370 return net_buf_simple_pull_be24(&buf->b);
2371}
2372
2383static inline uint32_t net_buf_pull_le32(struct net_buf *buf)
2384{
2385 return net_buf_simple_pull_le32(&buf->b);
2386}
2387
2398static inline uint32_t net_buf_pull_be32(struct net_buf *buf)
2399{
2400 return net_buf_simple_pull_be32(&buf->b);
2401}
2402
2413static inline uint64_t net_buf_pull_le40(struct net_buf *buf)
2414{
2415 return net_buf_simple_pull_le40(&buf->b);
2416}
2417
2428static inline uint64_t net_buf_pull_be40(struct net_buf *buf)
2429{
2430 return net_buf_simple_pull_be40(&buf->b);
2431}
2432
2443static inline uint64_t net_buf_pull_le48(struct net_buf *buf)
2444{
2445 return net_buf_simple_pull_le48(&buf->b);
2446}
2447
2458static inline uint64_t net_buf_pull_be48(struct net_buf *buf)
2459{
2460 return net_buf_simple_pull_be48(&buf->b);
2461}
2462
2473static inline uint64_t net_buf_pull_le64(struct net_buf *buf)
2474{
2475 return net_buf_simple_pull_le64(&buf->b);
2476}
2477
2488static inline uint64_t net_buf_pull_be64(struct net_buf *buf)
2489{
2490 return net_buf_simple_pull_be64(&buf->b);
2491}
2492
2502static inline size_t net_buf_tailroom(const struct net_buf *buf)
2503{
2504 return net_buf_simple_tailroom(&buf->b);
2505}
2506
2516static inline size_t net_buf_headroom(const struct net_buf *buf)
2517{
2518 return net_buf_simple_headroom(&buf->b);
2519}
2520
2530static inline uint16_t net_buf_max_len(const struct net_buf *buf)
2531{
2532 return net_buf_simple_max_len(&buf->b);
2533}
2534
2544static inline uint8_t *net_buf_tail(const struct net_buf *buf)
2545{
2546 return net_buf_simple_tail(&buf->b);
2547}
2548
2555
2567void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
2568
2583struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
2584
2594#if defined(CONFIG_NET_BUF_LOG)
2595struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
2596 struct net_buf *frag,
2597 const char *func, int line);
2598#define net_buf_frag_del(_parent, _frag) \
2599 net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2600#else
2601struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
2602#endif
2603
2619size_t net_buf_linearize(void *dst, size_t dst_len,
2620 const struct net_buf *src, size_t offset, size_t len);
2621
2636typedef struct net_buf * __must_check (*net_buf_allocator_cb)(k_timeout_t timeout,
2637 void *user_data);
2638
2660size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
2661 const void *value, k_timeout_t timeout,
2662 net_buf_allocator_cb allocate_cb, void *user_data);
2663
2678size_t net_buf_data_match(const struct net_buf *buf, size_t offset, const void *data, size_t len);
2679
2695static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
2696{
2697 while (buf && len--) {
2698 net_buf_pull_u8(buf);
2699 if (!buf->len) {
2700 buf = net_buf_frag_del(NULL, buf);
2701 }
2702 }
2703
2704 return buf;
2705}
2706
2717static inline size_t net_buf_frags_len(const struct net_buf *buf)
2718{
2719 size_t bytes = 0;
2720
2721 while (buf) {
2722 bytes += buf->len;
2723 buf = buf->frags;
2724 }
2725
2726 return bytes;
2727}
2728
2733#ifdef __cplusplus
2734}
2735#endif
2736
2737#endif /* ZEPHYR_INCLUDE_NET_BUF_H_ */
long atomic_t
Definition atomic_types.h:15
ZTEST_BMEM int timeout
Definition main.c:31
struct k_fifo fifo
Definition errno.c:44
#define k_lifo_put(lifo, data)
Add an element to a LIFO queue.
Definition kernel.h:2684
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:2428
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:1836
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:2001
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:1716
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.
size_t net_buf_simple_tailroom(const struct net_buf_simple *buf)
Check buffer tailroom.
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:2636
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:2695
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:1622
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:1701
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:2413
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:2488
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:2261
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:2031
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:2205
static struct net_buf * net_buf_alloc(struct net_buf_pool *pool, k_timeout_t timeout)
Definition buf.h:1357
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:1746
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:1971
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:1896
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:2383
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:2398
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 buf.h:1686
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:1761
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 buf.h:2530
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:2458
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:2121
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:1911
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:1776
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:2308
static void net_buf_destroy(struct net_buf *buf)
Destroy buffer from custom destroy callback.
Definition buf.h:1468
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.
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:2079
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:2443
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:2219
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:2353
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:1656
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:2149
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:2135
static void net_buf_reserve(struct net_buf *buf, size_t reserve)
Initialize buffer with the given headroom.
Definition buf.h:1606
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:2046
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 uint32_t net_buf_pull_be24(struct net_buf *buf)
Remove and convert 24 bits from the beginning of the buffer.
Definition buf.h:2368
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:1806
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:1926
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:2093
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:2062
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:2338
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:2163
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:2473
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.
static uint8_t * net_buf_simple_tail(const struct net_buf_simple *buf)
Get the tail pointer for a buffer.
Definition buf.h:903
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:2016
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:1881
size_t net_buf_simple_headroom(const struct net_buf_simple *buf)
Check buffer headroom.
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:2107
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 buf.h:963
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:2233
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
uint16_t net_buf_simple_max_len(const struct net_buf_simple *buf)
Check maximum net_buf_simple::len value.
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:1821
static size_t net_buf_headroom(const struct net_buf *buf)
Check buffer headroom.
Definition buf.h:2516
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:1956
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 buf.h:1851
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:1639
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:2247
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.
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:1866
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:1671
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:1986
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:2177
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:1731
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:1941
static size_t net_buf_frags_len(const struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition buf.h:2717
static size_t net_buf_tailroom(const struct net_buf *buf)
Check buffer tailroom.
Definition buf.h:2502
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:2323
static uint8_t * net_buf_tail(const struct net_buf *buf)
Get the tail pointer for a buffer.
Definition buf.h:2544
static void * net_buf_pull_mem(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition buf.h:2293
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:2277
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:2191
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:1791
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:1582
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: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:2391
Definition kernel.h:2630
Kernel Spin Lock.
Definition spinlock.h:45
Kernel timeout type.
Definition sys_clock.h:65
Network buffer pool representation.
Definition buf.h:1076
void(*const destroy)(struct net_buf *buf)
Optional destroy callback when buffer is freed.
Definition buf.h:1104
uint16_t uninit_count
Number of uninitialized buffers.
Definition buf.h:1087
uint8_t user_data_size
Size of user data allocated to this pool.
Definition buf.h:1090
const uint16_t buf_count
Number of buffers in pool.
Definition buf.h:1084
const struct net_buf_data_alloc * alloc
Data allocation handlers.
Definition buf.h:1107
struct k_lifo free
LIFO to place the buffer into when free.
Definition buf.h:1078
struct k_spinlock lock
To prevent concurrent access/modifications.
Definition buf.h:1081
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
Size of user data on this buffer.
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:1051
uint16_t len
Length of the data behind the data pointer.
Definition buf.h:1033
static fdata_t data[2]
Definition test_fifo_contexts.c:15
static void func(void *arg1, void *arg2, void *arg3)
Definition main.c:26
static const intptr_t user_data[5]
Definition main.c:588
Misc utilities.