Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
net_buf.h
Go to the documentation of this file.
1
4
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
31
32/* Alignment needed for various parts of the buffer definition */
33#if CONFIG_NET_BUF_ALIGNMENT == 0
34#define __net_buf_align __aligned(sizeof(void *))
35#else
36#define __net_buf_align __aligned(CONFIG_NET_BUF_ALIGNMENT)
37#endif
38
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, \
52 .len = 0, \
53 .size = _size, \
54 .__buf = net_buf_data_##_name, \
55 }
56
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, \
71 .len = 0, \
72 .size = _size, \
73 .__buf = net_buf_data_##_name, \
74 }
75
92
99
102
106 uint8_t *__buf;
107};
108
125#define NET_BUF_SIMPLE(_size) \
126 ((struct net_buf_simple *)(&(struct { \
127 struct net_buf_simple buf; \
128 uint8_t data[_size]; \
129 }) { \
130 .buf.size = _size, \
131 }))
132
142static inline void net_buf_simple_init(struct net_buf_simple *buf,
143 size_t reserve_head)
144{
145 if (!buf->__buf) {
146 buf->__buf = (uint8_t *)buf + sizeof(*buf);
147 }
148
149 buf->data = buf->__buf + reserve_head;
150 buf->len = 0U;
151}
152
163 void *data, size_t size);
164
172static inline void net_buf_simple_reset(struct net_buf_simple *buf)
173{
174 buf->len = 0U;
175 buf->data = buf->__buf;
176}
177
188void net_buf_simple_clone(const struct net_buf_simple *original,
189 struct net_buf_simple *clone);
190
202void *net_buf_simple_add(struct net_buf_simple *buf, size_t len);
203
216void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
217 size_t len);
218
231
243
255
267
279
291
303
315
327
339
351
363
375
386void *net_buf_simple_remove_mem(struct net_buf_simple *buf, size_t len);
387
399
411
423
435
447
459
471
483
495
507
519
531
543
555void *net_buf_simple_push(struct net_buf_simple *buf, size_t len);
556
569void *net_buf_simple_push_mem(struct net_buf_simple *buf, const void *mem,
570 size_t len);
571
582
593
603
614
625
636
647
658
669
680
691
702
713
725void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len);
726
738void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len);
739
751
763
775
787
799
811
823
835
847
859
871
883
895
905static inline uint8_t *net_buf_simple_tail(const struct net_buf_simple *buf)
906{
907 return buf->data + buf->len;
908}
909
919size_t net_buf_simple_headroom(const struct net_buf_simple *buf);
920
930size_t net_buf_simple_tailroom(const struct net_buf_simple *buf);
931
942
956
965static inline void net_buf_simple_save(const struct net_buf_simple *buf,
967{
968 state->offset = (uint16_t)net_buf_simple_headroom(buf);
969 state->len = buf->len;
970}
971
981static inline void net_buf_simple_restore(struct net_buf_simple *buf,
983{
984 buf->data = buf->__buf + state->offset;
985 buf->len = state->len;
986}
987
997#define NET_BUF_EXTERNAL_DATA BIT(0)
998
1006struct net_buf {
1009
1012
1015
1018
1021
1024
1028 union {
1029 /* The ABI of this struct must match net_buf_simple */
1030 struct {
1033
1036
1039
1044 uint8_t *__buf;
1045 };
1046
1048 struct net_buf_simple b;
1050 };
1051
1053 uint8_t user_data[] __net_buf_align;
1054};
1055
1057
1058struct net_buf_data_cb {
1059 uint8_t * __must_check (*alloc)(struct net_buf *buf, size_t *size,
1060 k_timeout_t timeout);
1061 uint8_t * __must_check (*ref)(struct net_buf *buf, uint8_t *data);
1062 void (*unref)(struct net_buf *buf, uint8_t *data);
1063};
1064
1065struct net_buf_data_alloc {
1066 const struct net_buf_data_cb *cb;
1067 void *alloc_data;
1068 size_t max_alloc_size;
1069 size_t alignment;
1070};
1071
1073
1081 struct k_lifo free;
1082
1085
1088
1091
1094
1095#if defined(CONFIG_NET_BUF_POOL_USAGE)
1097 atomic_t avail_count;
1098
1100 const uint16_t pool_size;
1101
1103 uint16_t max_used;
1104
1106 const char *name;
1107#endif /* CONFIG_NET_BUF_POOL_USAGE */
1108
1110 void (*const destroy)(struct net_buf *buf);
1111
1113 const struct net_buf_data_alloc *alloc;
1114
1116 struct net_buf * const __bufs;
1117};
1118
1120#define NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1121 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.avail_count = ATOMIC_INIT(_count),)) \
1122 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.max_used = 0,)) \
1123 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.name = STRINGIFY(_pool),))
1124
1125#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _ud_size, _destroy) \
1126 { \
1127 .free = Z_LIFO_INITIALIZER(_pool.free), \
1128 .lock = { }, \
1129 .buf_count = _count, \
1130 .uninit_count = _count, \
1131 .user_data_size = _ud_size, \
1132 NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1133 .destroy = _destroy, \
1134 .alloc = _alloc, \
1135 .__bufs = (struct net_buf *)_bufs, \
1136 }
1137
1138#define _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size) \
1139 struct _net_buf_##_name { uint8_t b[sizeof(struct net_buf)]; \
1140 uint8_t ud[_ud_size]; } __net_buf_align; \
1141 BUILD_ASSERT(_ud_size <= UINT8_MAX); \
1142 BUILD_ASSERT(offsetof(struct net_buf, user_data) == \
1143 offsetof(struct _net_buf_##_name, ud), "Invalid offset"); \
1144 BUILD_ASSERT(__alignof__(struct net_buf) == \
1145 __alignof__(struct _net_buf_##_name), "Invalid alignment"); \
1146 BUILD_ASSERT(sizeof(struct _net_buf_##_name) == \
1147 ROUND_UP(sizeof(struct net_buf) + _ud_size, __alignof__(struct net_buf)), \
1148 "Size cannot be determined"); \
1149 static struct _net_buf_##_name _net_buf_##_name[_count] __noinit
1150
1151extern const struct net_buf_data_alloc net_buf_heap_alloc;
1153
1181#define NET_BUF_POOL_HEAP_DEFINE(_name, _count, _ud_size, _destroy) \
1182 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1183 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1184 NET_BUF_POOL_INITIALIZER(_name, &net_buf_heap_alloc, \
1185 _net_buf_##_name, _count, _ud_size, \
1186 _destroy)
1187
1189
1190struct net_buf_pool_fixed {
1191 uint8_t *data_pool;
1192};
1193
1194extern const struct net_buf_data_cb net_buf_fixed_cb;
1195
1197
1226#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1227 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1228 static uint8_t __noinit net_buf_data_##_name[_count][_data_size] __net_buf_align; \
1229 static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
1230 .data_pool = (uint8_t *)net_buf_data_##_name, \
1231 }; \
1232 static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
1233 .cb = &net_buf_fixed_cb, \
1234 .alloc_data = (void *)&net_buf_fixed_##_name, \
1235 .max_alloc_size = _data_size, \
1236 }; \
1237 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1238 NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \
1239 _net_buf_##_name, _count, _ud_size, \
1240 _destroy)
1241
1243extern const struct net_buf_data_cb net_buf_var_cb;
1245
1270#define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1271 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1272 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1273 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1274 .cb = &net_buf_var_cb, \
1275 .alloc_data = &net_buf_mem_pool_##_name, \
1276 .max_alloc_size = 0, \
1277 }; \
1278 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1279 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1280 _net_buf_##_name, _count, _ud_size, \
1281 _destroy)
1282
1313#define NET_BUF_POOL_VAR_ALIGN_DEFINE(_name, _count, _data_size, _ud_size, \
1314 _destroy, _align) \
1315 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1316 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1317 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1318 .cb = &net_buf_var_cb, \
1319 .alloc_data = &net_buf_mem_pool_##_name, \
1320 .max_alloc_size = 0, \
1321 .alignment = _align, \
1322 }; \
1323 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1324 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1325 _net_buf_##_name, _count, _ud_size, \
1326 _destroy)
1327
1349#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1350 NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _ud_size, _destroy)
1351
1360
1373int net_buf_id(const struct net_buf *buf);
1374
1375#if defined(CONFIG_NET_BUF_POOL_USAGE) || defined(__DOXYGEN__)
1389static inline size_t net_buf_get_available(struct net_buf_pool *pool)
1390{
1391 return (size_t)atomic_get(&pool->avail_count);
1392}
1393
1403static inline size_t net_buf_get_max_used(struct net_buf_pool *pool)
1404{
1405 return (size_t)pool->max_used;
1406}
1407#endif /* defined(CONFIG_NET_BUF_POOL_USAGE) || defined(__DOXYGEN__) */
1408
1423#if defined(CONFIG_NET_BUF_LOG)
1424struct net_buf * __must_check net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
1425 k_timeout_t timeout,
1426 const char *func,
1427 int line);
1428#define net_buf_alloc_fixed(_pool, _timeout) \
1429 net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1430#else
1431struct net_buf * __must_check net_buf_alloc_fixed(struct net_buf_pool *pool,
1432 k_timeout_t timeout);
1433#endif
1434
1438static inline struct net_buf * __must_check net_buf_alloc(struct net_buf_pool *pool,
1439 k_timeout_t timeout)
1440{
1441 return net_buf_alloc_fixed(pool, timeout);
1442}
1443
1459#if defined(CONFIG_NET_BUF_LOG)
1460struct net_buf * __must_check net_buf_alloc_len_debug(struct net_buf_pool *pool,
1461 size_t size,
1462 k_timeout_t timeout,
1463 const char *func,
1464 int line);
1465#define net_buf_alloc_len(_pool, _size, _timeout) \
1466 net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1467#else
1468struct net_buf * __must_check net_buf_alloc_len(struct net_buf_pool *pool,
1469 size_t size,
1470 k_timeout_t timeout);
1471#endif
1472
1492#if defined(CONFIG_NET_BUF_LOG)
1493struct net_buf * __must_check net_buf_alloc_with_data_debug(struct net_buf_pool *pool,
1494 void *data, size_t size,
1495 k_timeout_t timeout,
1496 const char *func, int line);
1497#define net_buf_alloc_with_data(_pool, _data_, _size, _timeout) \
1498 net_buf_alloc_with_data_debug(_pool, _data_, _size, _timeout, \
1499 __func__, __LINE__)
1500#else
1501struct net_buf * __must_check net_buf_alloc_with_data(struct net_buf_pool *pool,
1502 void *data, size_t size,
1503 k_timeout_t timeout);
1504#endif
1505
1515static inline void net_buf_destroy(struct net_buf *buf)
1516{
1517 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
1518
1519 if (buf->__buf) {
1520 if (!(buf->flags & NET_BUF_EXTERNAL_DATA)) {
1521 pool->alloc->cb->unref(buf, buf->__buf);
1522 }
1523 buf->__buf = NULL;
1524 }
1525
1526 k_lifo_put(&pool->free, buf);
1527}
1528
1536void net_buf_reset(struct net_buf *buf);
1537
1546void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve);
1547
1554void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
1555
1563struct net_buf * __must_check net_buf_slist_get(sys_slist_t *list);
1564
1572#if defined(CONFIG_NET_BUF_LOG)
1573void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
1574#define net_buf_unref(_buf) \
1575 net_buf_unref_debug(_buf, __func__, __LINE__)
1576#else
1577void net_buf_unref(struct net_buf *buf);
1578#endif
1579
1587struct net_buf * __must_check net_buf_ref(struct net_buf *buf);
1588
1602struct net_buf * __must_check net_buf_clone(struct net_buf *buf,
1603 k_timeout_t timeout);
1604
1612static inline void * __must_check net_buf_user_data(const struct net_buf *buf)
1613{
1614 return (void *)buf->user_data;
1615}
1616
1626int net_buf_user_data_copy(struct net_buf *dst, const struct net_buf *src);
1627
1636static inline void net_buf_reserve(struct net_buf *buf, size_t reserve)
1637{
1638 net_buf_simple_reserve(&buf->b, reserve);
1639}
1640
1652static inline void *net_buf_add(struct net_buf *buf, size_t len)
1653{
1654 return net_buf_simple_add(&buf->b, len);
1655}
1656
1669static inline void *net_buf_add_mem(struct net_buf *buf, const void *mem,
1670 size_t len)
1671{
1672 return net_buf_simple_add_mem(&buf->b, mem, len);
1673}
1674
1686static inline uint8_t *net_buf_add_u8(struct net_buf *buf, uint8_t val)
1687{
1688 return net_buf_simple_add_u8(&buf->b, val);
1689}
1690
1701static inline void net_buf_add_le16(struct net_buf *buf, uint16_t val)
1702{
1703 net_buf_simple_add_le16(&buf->b, val);
1704}
1705
1716static inline void net_buf_add_be16(struct net_buf *buf, uint16_t val)
1717{
1718 net_buf_simple_add_be16(&buf->b, val);
1719}
1720
1731static inline void net_buf_add_le24(struct net_buf *buf, uint32_t val)
1732{
1733 net_buf_simple_add_le24(&buf->b, val);
1734}
1735
1746static inline void net_buf_add_be24(struct net_buf *buf, uint32_t val)
1747{
1748 net_buf_simple_add_be24(&buf->b, val);
1749}
1750
1761static inline void net_buf_add_le32(struct net_buf *buf, uint32_t val)
1762{
1763 net_buf_simple_add_le32(&buf->b, val);
1764}
1765
1776static inline void net_buf_add_be32(struct net_buf *buf, uint32_t val)
1777{
1778 net_buf_simple_add_be32(&buf->b, val);
1779}
1780
1791static inline void net_buf_add_le40(struct net_buf *buf, uint64_t val)
1792{
1793 net_buf_simple_add_le40(&buf->b, val);
1794}
1795
1806static inline void net_buf_add_be40(struct net_buf *buf, uint64_t val)
1807{
1808 net_buf_simple_add_be40(&buf->b, val);
1809}
1810
1821static inline void net_buf_add_le48(struct net_buf *buf, uint64_t val)
1822{
1823 net_buf_simple_add_le48(&buf->b, val);
1824}
1825
1836static inline void net_buf_add_be48(struct net_buf *buf, uint64_t val)
1837{
1838 net_buf_simple_add_be48(&buf->b, val);
1839}
1840
1851static inline void net_buf_add_le64(struct net_buf *buf, uint64_t val)
1852{
1853 net_buf_simple_add_le64(&buf->b, val);
1854}
1855
1866static inline void net_buf_add_be64(struct net_buf *buf, uint64_t val)
1867{
1868 net_buf_simple_add_be64(&buf->b, val);
1869}
1870
1881static inline void *net_buf_remove_mem(struct net_buf *buf, size_t len)
1882{
1883 return net_buf_simple_remove_mem(&buf->b, len);
1884}
1885
1896static inline uint8_t net_buf_remove_u8(struct net_buf *buf)
1897{
1898 return net_buf_simple_remove_u8(&buf->b);
1899}
1900
1911static inline uint16_t net_buf_remove_le16(struct net_buf *buf)
1912{
1913 return net_buf_simple_remove_le16(&buf->b);
1914}
1915
1926static inline uint16_t net_buf_remove_be16(struct net_buf *buf)
1927{
1928 return net_buf_simple_remove_be16(&buf->b);
1929}
1930
1941static inline uint32_t net_buf_remove_be24(struct net_buf *buf)
1942{
1943 return net_buf_simple_remove_be24(&buf->b);
1944}
1945
1956static inline uint32_t net_buf_remove_le24(struct net_buf *buf)
1957{
1958 return net_buf_simple_remove_le24(&buf->b);
1959}
1960
1971static inline uint32_t net_buf_remove_le32(struct net_buf *buf)
1972{
1973 return net_buf_simple_remove_le32(&buf->b);
1974}
1975
1986static inline uint32_t net_buf_remove_be32(struct net_buf *buf)
1987{
1988 return net_buf_simple_remove_be32(&buf->b);
1989}
1990
2001static inline uint64_t net_buf_remove_le40(struct net_buf *buf)
2002{
2003 return net_buf_simple_remove_le40(&buf->b);
2004}
2005
2016static inline uint64_t net_buf_remove_be40(struct net_buf *buf)
2017{
2018 return net_buf_simple_remove_be40(&buf->b);
2019}
2020
2031static inline uint64_t net_buf_remove_le48(struct net_buf *buf)
2032{
2033 return net_buf_simple_remove_le48(&buf->b);
2034}
2035
2046static inline uint64_t net_buf_remove_be48(struct net_buf *buf)
2047{
2048 return net_buf_simple_remove_be48(&buf->b);
2049}
2050
2061static inline uint64_t net_buf_remove_le64(struct net_buf *buf)
2062{
2063 return net_buf_simple_remove_le64(&buf->b);
2064}
2065
2076static inline uint64_t net_buf_remove_be64(struct net_buf *buf)
2077{
2078 return net_buf_simple_remove_be64(&buf->b);
2079}
2080
2092static inline void *net_buf_push(struct net_buf *buf, size_t len)
2093{
2094 return net_buf_simple_push(&buf->b, len);
2095}
2096
2109static inline void *net_buf_push_mem(struct net_buf *buf, const void *mem,
2110 size_t len)
2111{
2112 return net_buf_simple_push_mem(&buf->b, mem, len);
2113}
2114
2123static inline void net_buf_push_u8(struct net_buf *buf, uint8_t val)
2124{
2125 net_buf_simple_push_u8(&buf->b, val);
2126}
2127
2137static inline void net_buf_push_le16(struct net_buf *buf, uint16_t val)
2138{
2139 net_buf_simple_push_le16(&buf->b, val);
2140}
2141
2151static inline void net_buf_push_be16(struct net_buf *buf, uint16_t val)
2152{
2153 net_buf_simple_push_be16(&buf->b, val);
2154}
2155
2165static inline void net_buf_push_le24(struct net_buf *buf, uint32_t val)
2166{
2167 net_buf_simple_push_le24(&buf->b, val);
2168}
2169
2179static inline void net_buf_push_be24(struct net_buf *buf, uint32_t val)
2180{
2181 net_buf_simple_push_be24(&buf->b, val);
2182}
2183
2193static inline void net_buf_push_le32(struct net_buf *buf, uint32_t val)
2194{
2195 net_buf_simple_push_le32(&buf->b, val);
2196}
2197
2207static inline void net_buf_push_be32(struct net_buf *buf, uint32_t val)
2208{
2209 net_buf_simple_push_be32(&buf->b, val);
2210}
2211
2221static inline void net_buf_push_le40(struct net_buf *buf, uint64_t val)
2222{
2223 net_buf_simple_push_le40(&buf->b, val);
2224}
2225
2235static inline void net_buf_push_be40(struct net_buf *buf, uint64_t val)
2236{
2237 net_buf_simple_push_be40(&buf->b, val);
2238}
2239
2249static inline void net_buf_push_le48(struct net_buf *buf, uint64_t val)
2250{
2251 net_buf_simple_push_le48(&buf->b, val);
2252}
2253
2263static inline void net_buf_push_be48(struct net_buf *buf, uint64_t val)
2264{
2265 net_buf_simple_push_be48(&buf->b, val);
2266}
2267
2277static inline void net_buf_push_le64(struct net_buf *buf, uint64_t val)
2278{
2279 net_buf_simple_push_le64(&buf->b, val);
2280}
2281
2291static inline void net_buf_push_be64(struct net_buf *buf, uint64_t val)
2292{
2293 net_buf_simple_push_be64(&buf->b, val);
2294}
2295
2307static inline void *net_buf_pull(struct net_buf *buf, size_t len)
2308{
2309 return net_buf_simple_pull(&buf->b, len);
2310}
2311
2323static inline void *net_buf_pull_mem(struct net_buf *buf, size_t len)
2324{
2325 return net_buf_simple_pull_mem(&buf->b, len);
2326}
2327
2338static inline uint8_t net_buf_pull_u8(struct net_buf *buf)
2339{
2340 return net_buf_simple_pull_u8(&buf->b);
2341}
2342
2353static inline uint16_t net_buf_pull_le16(struct net_buf *buf)
2354{
2355 return net_buf_simple_pull_le16(&buf->b);
2356}
2357
2368static inline uint16_t net_buf_pull_be16(struct net_buf *buf)
2369{
2370 return net_buf_simple_pull_be16(&buf->b);
2371}
2372
2383static inline uint32_t net_buf_pull_le24(struct net_buf *buf)
2384{
2385 return net_buf_simple_pull_le24(&buf->b);
2386}
2387
2398static inline uint32_t net_buf_pull_be24(struct net_buf *buf)
2399{
2400 return net_buf_simple_pull_be24(&buf->b);
2401}
2402
2413static inline uint32_t net_buf_pull_le32(struct net_buf *buf)
2414{
2415 return net_buf_simple_pull_le32(&buf->b);
2416}
2417
2428static inline uint32_t net_buf_pull_be32(struct net_buf *buf)
2429{
2430 return net_buf_simple_pull_be32(&buf->b);
2431}
2432
2443static inline uint64_t net_buf_pull_le40(struct net_buf *buf)
2444{
2445 return net_buf_simple_pull_le40(&buf->b);
2446}
2447
2458static inline uint64_t net_buf_pull_be40(struct net_buf *buf)
2459{
2460 return net_buf_simple_pull_be40(&buf->b);
2461}
2462
2473static inline uint64_t net_buf_pull_le48(struct net_buf *buf)
2474{
2475 return net_buf_simple_pull_le48(&buf->b);
2476}
2477
2488static inline uint64_t net_buf_pull_be48(struct net_buf *buf)
2489{
2490 return net_buf_simple_pull_be48(&buf->b);
2491}
2492
2503static inline uint64_t net_buf_pull_le64(struct net_buf *buf)
2504{
2505 return net_buf_simple_pull_le64(&buf->b);
2506}
2507
2518static inline uint64_t net_buf_pull_be64(struct net_buf *buf)
2519{
2520 return net_buf_simple_pull_be64(&buf->b);
2521}
2522
2532static inline size_t net_buf_tailroom(const struct net_buf *buf)
2533{
2534 return net_buf_simple_tailroom(&buf->b);
2535}
2536
2546static inline size_t net_buf_headroom(const struct net_buf *buf)
2547{
2548 return net_buf_simple_headroom(&buf->b);
2549}
2550
2560static inline uint16_t net_buf_max_len(const struct net_buf *buf)
2561{
2562 return net_buf_simple_max_len(&buf->b);
2563}
2564
2574static inline uint8_t *net_buf_tail(const struct net_buf *buf)
2575{
2576 return net_buf_simple_tail(&buf->b);
2577}
2578
2585
2597void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
2598
2613struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
2614
2624#if defined(CONFIG_NET_BUF_LOG)
2625struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
2626 struct net_buf *frag,
2627 const char *func, int line);
2628#define net_buf_frag_del(_parent, _frag) \
2629 net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2630#else
2631struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
2632#endif
2633
2649size_t net_buf_linearize(void *dst, size_t dst_len,
2650 const struct net_buf *src, size_t offset, size_t len);
2651
2666typedef struct net_buf * __must_check (*net_buf_allocator_cb)(k_timeout_t timeout,
2667 void *user_data);
2668
2690size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
2691 const void *value, k_timeout_t timeout,
2692 net_buf_allocator_cb allocate_cb, void *user_data);
2693
2708size_t net_buf_data_match(const struct net_buf *buf, size_t offset, const void *data, size_t len);
2709
2725static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
2726{
2727 while (buf && len--) {
2728 net_buf_pull_u8(buf);
2729 if (!buf->len) {
2730 buf = net_buf_frag_del(NULL, buf);
2731 }
2732 }
2733
2734 return buf;
2735}
2736
2747static inline size_t net_buf_frags_len(const struct net_buf *buf)
2748{
2749 size_t bytes = 0;
2750
2751 while (buf) {
2752 bytes += buf->len;
2753 buf = buf->frags;
2754 }
2755
2756 return bytes;
2757}
2758
2762
2763#ifdef __cplusplus
2764}
2765#endif
2766
2767#endif /* ZEPHYR_INCLUDE_NET_BUF_H_ */
long atomic_t
Definition atomic_types.h:15
atomic_val_t atomic_get(const atomic_t *target)
Atomic get.
#define k_lifo_put(lifo, data)
Add an element to a LIFO queue.
Definition kernel.h:2999
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:142
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:2458
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:1866
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:2031
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:1746
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.
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:2725
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:1652
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:1731
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:2443
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:2518
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:2291
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:2061
static void net_buf_simple_reset(struct net_buf_simple *buf)
Reset buffer.
Definition net_buf.h:172
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 net_buf.h:2235
static struct net_buf * net_buf_alloc(struct net_buf_pool *pool, k_timeout_t timeout)
Definition net_buf.h:1438
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:1776
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:2001
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 net_buf.h:1926
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:2413
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:2428
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:1716
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:1791
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:2560
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:2488
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 net_buf.h:2151
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:1941
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:1806
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:2338
static void net_buf_destroy(struct net_buf *buf)
Destroy buffer from custom destroy callback.
Definition net_buf.h:1515
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.
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:2109
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:2473
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:2249
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:2383
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:1686
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:2179
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:2165
static void net_buf_reserve(struct net_buf *buf, size_t reserve)
Initialize buffer with the given headroom.
Definition net_buf.h:1636
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:2076
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 net_buf.h:2398
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:1836
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:1956
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:2123
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:2092
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:2368
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:2193
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:2503
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:2666
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:1389
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:905
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:2046
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:997
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:1911
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 net_buf.h:2137
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:965
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:2263
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 net_buf.h:1851
static size_t net_buf_headroom(const struct net_buf *buf)
Check buffer headroom.
Definition net_buf.h:2546
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:1986
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:1881
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:1669
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:2277
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:1403
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:1896
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 net_buf.h:1701
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:2016
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:2207
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:1761
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:1971
static size_t net_buf_frags_len(const struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition net_buf.h:2747
static size_t net_buf_tailroom(const struct net_buf *buf)
Check buffer tailroom.
Definition net_buf.h:2532
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:2353
static uint8_t * net_buf_tail(const struct net_buf *buf)
Get the tail pointer for a buffer.
Definition net_buf.h:2574
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:2323
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:981
static void * net_buf_pull(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition net_buf.h:2307
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:2221
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:1821
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:1612
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
#define NULL
Definition iar_missing_defs.h:20
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:2945
Kernel Spin Lock.
Definition spinlock.h:45
Kernel timeout type.
Definition clock.h:65
Network buffer pool representation.
Definition net_buf.h:1079
void(*const destroy)(struct net_buf *buf)
Optional destroy callback when buffer is freed.
Definition net_buf.h:1110
uint16_t uninit_count
Number of uninitialized buffers.
Definition net_buf.h:1090
uint8_t user_data_size
Size of user data allocated to this pool.
Definition net_buf.h:1093
const uint16_t buf_count
Number of buffers in pool.
Definition net_buf.h:1087
const struct net_buf_data_alloc * alloc
Data allocation handlers.
Definition net_buf.h:1113
struct k_lifo free
LIFO to place the buffer into when free.
Definition net_buf.h:1081
struct k_spinlock lock
To prevent concurrent access/modifications.
Definition net_buf.h:1084
Parsing state of a buffer.
Definition net_buf.h:950
uint16_t offset
Offset of the data pointer from the beginning of the storage.
Definition net_buf.h:952
uint16_t len
Length of data.
Definition net_buf.h:954
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:101
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:98
Network buffer representation.
Definition net_buf.h:1006
uint16_t size
Amount of data that this buffer can store.
Definition net_buf.h:1038
struct net_buf * frags
Fragments associated with this buffer.
Definition net_buf.h:1011
uint8_t ref
Reference count.
Definition net_buf.h:1014
uint8_t pool_id
Where the buffer should go when freed up.
Definition net_buf.h:1020
sys_snode_t node
Allow placing the buffer into sys_slist_t.
Definition net_buf.h:1008
uint8_t user_data_size
Size of user data on this buffer.
Definition net_buf.h:1023
uint8_t flags
Bit-field of buffer flags.
Definition net_buf.h:1017
uint8_t * data
Pointer to the start of data in the buffer.
Definition net_buf.h:1032
uint8_t user_data[]
System metadata for this buffer.
Definition net_buf.h:1053
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:1035
Misc utilities.