Zephyr Project API 4.3.2
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
1044 union {
1046 atomic_t ref_word;
1048 struct {
1049#if defined(CONFIG_BIG_ENDIAN)
1050 /* atomic_t is typedef'd as long (BUILD_ASSERTed in
1051 * lib/net_buf/buf.c); on a 64-bit big-endian build
1052 * the byte struct needs 4 bytes of padding so that
1053 * `ref` lands on the least-significant byte of
1054 * ref_word.
1055 */
1056#if (__SIZEOF_LONG__ == 8)
1058 uint8_t _ref_word_pad[4];
1060#endif
1063
1066
1068 uint8_t flags;
1069
1071 uint8_t ref;
1072#else
1075
1078
1081
1084#endif
1085 };
1086 };
1087
1091 union {
1092 /* The ABI of this struct must match net_buf_simple */
1093 struct {
1096
1099
1102
1107 uint8_t *__buf;
1108 };
1109
1111 struct net_buf_simple b;
1113 };
1114
1116 uint8_t user_data[] __net_buf_align;
1117};
1118
1120
1121struct net_buf_data_cb {
1122 uint8_t * __must_check (*alloc)(struct net_buf *buf, size_t *size,
1123 k_timeout_t timeout);
1124 uint8_t * __must_check (*ref)(struct net_buf *buf, uint8_t *data);
1125 void (*unref)(struct net_buf *buf, uint8_t *data);
1126};
1127
1128struct net_buf_data_alloc {
1129 const struct net_buf_data_cb *cb;
1130 void *alloc_data;
1131 size_t max_alloc_size;
1132 size_t alignment;
1133};
1134
1136
1144 struct k_lifo free;
1145
1148
1151
1154
1157
1158#if defined(CONFIG_NET_BUF_POOL_USAGE)
1160 atomic_t avail_count;
1161
1163 const uint16_t pool_size;
1164
1166 uint16_t max_used;
1167
1169 const char *name;
1170#endif /* CONFIG_NET_BUF_POOL_USAGE */
1171
1173 void (*const destroy)(struct net_buf *buf);
1174
1176 const struct net_buf_data_alloc *alloc;
1177
1179 struct net_buf * const __bufs;
1180};
1181
1183#define NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1184 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.avail_count = ATOMIC_INIT(_count),)) \
1185 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.max_used = 0,)) \
1186 IF_ENABLED(CONFIG_NET_BUF_POOL_USAGE, (.name = STRINGIFY(_pool),))
1187
1188#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _ud_size, _destroy) \
1189 { \
1190 .free = Z_LIFO_INITIALIZER(_pool.free), \
1191 .lock = { }, \
1192 .buf_count = _count, \
1193 .uninit_count = _count, \
1194 .user_data_size = _ud_size, \
1195 NET_BUF_POOL_USAGE_INIT(_pool, _count) \
1196 .destroy = _destroy, \
1197 .alloc = _alloc, \
1198 .__bufs = (struct net_buf *)_bufs, \
1199 }
1200
1201#define _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size) \
1202 struct _net_buf_##_name { uint8_t b[sizeof(struct net_buf)]; \
1203 uint8_t ud[_ud_size]; } __net_buf_align; \
1204 BUILD_ASSERT(_ud_size <= UINT8_MAX); \
1205 BUILD_ASSERT(offsetof(struct net_buf, user_data) == \
1206 offsetof(struct _net_buf_##_name, ud), "Invalid offset"); \
1207 BUILD_ASSERT(__alignof__(struct net_buf) == \
1208 __alignof__(struct _net_buf_##_name), "Invalid alignment"); \
1209 BUILD_ASSERT(sizeof(struct _net_buf_##_name) == \
1210 ROUND_UP(sizeof(struct net_buf) + _ud_size, __alignof__(struct net_buf)), \
1211 "Size cannot be determined"); \
1212 static struct _net_buf_##_name _net_buf_##_name[_count] __noinit
1213
1214extern const struct net_buf_data_alloc net_buf_heap_alloc;
1216
1244#define NET_BUF_POOL_HEAP_DEFINE(_name, _count, _ud_size, _destroy) \
1245 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1246 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1247 NET_BUF_POOL_INITIALIZER(_name, &net_buf_heap_alloc, \
1248 _net_buf_##_name, _count, _ud_size, \
1249 _destroy)
1250
1252
1253struct net_buf_pool_fixed {
1254 uint8_t *data_pool;
1255};
1256
1257extern const struct net_buf_data_cb net_buf_fixed_cb;
1258
1260
1289#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1290 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1291 static uint8_t __noinit net_buf_data_##_name[_count][_data_size] __net_buf_align; \
1292 static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
1293 .data_pool = (uint8_t *)net_buf_data_##_name, \
1294 }; \
1295 static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
1296 .cb = &net_buf_fixed_cb, \
1297 .alloc_data = (void *)&net_buf_fixed_##_name, \
1298 .max_alloc_size = _data_size, \
1299 }; \
1300 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1301 NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \
1302 _net_buf_##_name, _count, _ud_size, \
1303 _destroy)
1304
1306extern const struct net_buf_data_cb net_buf_var_cb;
1308
1333#define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _ud_size, _destroy) \
1334 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1335 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1336 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1337 .cb = &net_buf_var_cb, \
1338 .alloc_data = &net_buf_mem_pool_##_name, \
1339 .max_alloc_size = 0, \
1340 }; \
1341 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1342 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1343 _net_buf_##_name, _count, _ud_size, \
1344 _destroy)
1345
1376#define NET_BUF_POOL_VAR_ALIGN_DEFINE(_name, _count, _data_size, _ud_size, \
1377 _destroy, _align) \
1378 _NET_BUF_ARRAY_DEFINE(_name, _count, _ud_size); \
1379 K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1380 static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1381 .cb = &net_buf_var_cb, \
1382 .alloc_data = &net_buf_mem_pool_##_name, \
1383 .max_alloc_size = 0, \
1384 .alignment = _align, \
1385 }; \
1386 static STRUCT_SECTION_ITERABLE(net_buf_pool, _name) = \
1387 NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1388 _net_buf_##_name, _count, _ud_size, \
1389 _destroy)
1390
1412#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1413 NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _ud_size, _destroy)
1414
1423
1436int net_buf_id(const struct net_buf *buf);
1437
1452#if defined(CONFIG_NET_BUF_LOG)
1453struct net_buf * __must_check net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
1454 k_timeout_t timeout,
1455 const char *func,
1456 int line);
1457#define net_buf_alloc_fixed(_pool, _timeout) \
1458 net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1459#else
1460struct net_buf * __must_check net_buf_alloc_fixed(struct net_buf_pool *pool,
1461 k_timeout_t timeout);
1462#endif
1463
1467static inline struct net_buf * __must_check net_buf_alloc(struct net_buf_pool *pool,
1468 k_timeout_t timeout)
1469{
1470 return net_buf_alloc_fixed(pool, timeout);
1471}
1472
1488#if defined(CONFIG_NET_BUF_LOG)
1489struct net_buf * __must_check net_buf_alloc_len_debug(struct net_buf_pool *pool,
1490 size_t size,
1491 k_timeout_t timeout,
1492 const char *func,
1493 int line);
1494#define net_buf_alloc_len(_pool, _size, _timeout) \
1495 net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1496#else
1497struct net_buf * __must_check net_buf_alloc_len(struct net_buf_pool *pool,
1498 size_t size,
1499 k_timeout_t timeout);
1500#endif
1501
1521#if defined(CONFIG_NET_BUF_LOG)
1522struct net_buf * __must_check net_buf_alloc_with_data_debug(struct net_buf_pool *pool,
1523 void *data, size_t size,
1524 k_timeout_t timeout,
1525 const char *func, int line);
1526#define net_buf_alloc_with_data(_pool, _data_, _size, _timeout) \
1527 net_buf_alloc_with_data_debug(_pool, _data_, _size, _timeout, \
1528 __func__, __LINE__)
1529#else
1530struct net_buf * __must_check net_buf_alloc_with_data(struct net_buf_pool *pool,
1531 void *data, size_t size,
1532 k_timeout_t timeout);
1533#endif
1534
1544static inline void net_buf_destroy(struct net_buf *buf)
1545{
1546 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
1547
1548 if (buf->__buf) {
1549 if (!(buf->flags & NET_BUF_EXTERNAL_DATA)) {
1550 pool->alloc->cb->unref(buf, buf->__buf);
1551 }
1552 buf->__buf = NULL;
1553 }
1554
1555 k_lifo_put(&pool->free, buf);
1556}
1557
1565void net_buf_reset(struct net_buf *buf);
1566
1575void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve);
1576
1583void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
1584
1592struct net_buf * __must_check net_buf_slist_get(sys_slist_t *list);
1593
1601#if defined(CONFIG_NET_BUF_LOG)
1602void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
1603#define net_buf_unref(_buf) \
1604 net_buf_unref_debug(_buf, __func__, __LINE__)
1605#else
1606void net_buf_unref(struct net_buf *buf);
1607#endif
1608
1616struct net_buf * __must_check net_buf_ref(struct net_buf *buf);
1617
1631struct net_buf * __must_check net_buf_clone(struct net_buf *buf,
1632 k_timeout_t timeout);
1633
1641static inline void * __must_check net_buf_user_data(const struct net_buf *buf)
1642{
1643 return (void *)buf->user_data;
1644}
1645
1655int net_buf_user_data_copy(struct net_buf *dst, const struct net_buf *src);
1656
1665static inline void net_buf_reserve(struct net_buf *buf, size_t reserve)
1666{
1667 net_buf_simple_reserve(&buf->b, reserve);
1668}
1669
1681static inline void *net_buf_add(struct net_buf *buf, size_t len)
1682{
1683 return net_buf_simple_add(&buf->b, len);
1684}
1685
1698static inline void *net_buf_add_mem(struct net_buf *buf, const void *mem,
1699 size_t len)
1700{
1701 return net_buf_simple_add_mem(&buf->b, mem, len);
1702}
1703
1715static inline uint8_t *net_buf_add_u8(struct net_buf *buf, uint8_t val)
1716{
1717 return net_buf_simple_add_u8(&buf->b, val);
1718}
1719
1730static inline void net_buf_add_le16(struct net_buf *buf, uint16_t val)
1731{
1732 net_buf_simple_add_le16(&buf->b, val);
1733}
1734
1745static inline void net_buf_add_be16(struct net_buf *buf, uint16_t val)
1746{
1747 net_buf_simple_add_be16(&buf->b, val);
1748}
1749
1760static inline void net_buf_add_le24(struct net_buf *buf, uint32_t val)
1761{
1762 net_buf_simple_add_le24(&buf->b, val);
1763}
1764
1775static inline void net_buf_add_be24(struct net_buf *buf, uint32_t val)
1776{
1777 net_buf_simple_add_be24(&buf->b, val);
1778}
1779
1790static inline void net_buf_add_le32(struct net_buf *buf, uint32_t val)
1791{
1792 net_buf_simple_add_le32(&buf->b, val);
1793}
1794
1805static inline void net_buf_add_be32(struct net_buf *buf, uint32_t val)
1806{
1807 net_buf_simple_add_be32(&buf->b, val);
1808}
1809
1820static inline void net_buf_add_le40(struct net_buf *buf, uint64_t val)
1821{
1822 net_buf_simple_add_le40(&buf->b, val);
1823}
1824
1835static inline void net_buf_add_be40(struct net_buf *buf, uint64_t val)
1836{
1837 net_buf_simple_add_be40(&buf->b, val);
1838}
1839
1850static inline void net_buf_add_le48(struct net_buf *buf, uint64_t val)
1851{
1852 net_buf_simple_add_le48(&buf->b, val);
1853}
1854
1865static inline void net_buf_add_be48(struct net_buf *buf, uint64_t val)
1866{
1867 net_buf_simple_add_be48(&buf->b, val);
1868}
1869
1880static inline void net_buf_add_le64(struct net_buf *buf, uint64_t val)
1881{
1882 net_buf_simple_add_le64(&buf->b, val);
1883}
1884
1895static inline void net_buf_add_be64(struct net_buf *buf, uint64_t val)
1896{
1897 net_buf_simple_add_be64(&buf->b, val);
1898}
1899
1910static inline void *net_buf_remove_mem(struct net_buf *buf, size_t len)
1911{
1912 return net_buf_simple_remove_mem(&buf->b, len);
1913}
1914
1925static inline uint8_t net_buf_remove_u8(struct net_buf *buf)
1926{
1927 return net_buf_simple_remove_u8(&buf->b);
1928}
1929
1940static inline uint16_t net_buf_remove_le16(struct net_buf *buf)
1941{
1942 return net_buf_simple_remove_le16(&buf->b);
1943}
1944
1955static inline uint16_t net_buf_remove_be16(struct net_buf *buf)
1956{
1957 return net_buf_simple_remove_be16(&buf->b);
1958}
1959
1970static inline uint32_t net_buf_remove_be24(struct net_buf *buf)
1971{
1972 return net_buf_simple_remove_be24(&buf->b);
1973}
1974
1985static inline uint32_t net_buf_remove_le24(struct net_buf *buf)
1986{
1987 return net_buf_simple_remove_le24(&buf->b);
1988}
1989
2000static inline uint32_t net_buf_remove_le32(struct net_buf *buf)
2001{
2002 return net_buf_simple_remove_le32(&buf->b);
2003}
2004
2015static inline uint32_t net_buf_remove_be32(struct net_buf *buf)
2016{
2017 return net_buf_simple_remove_be32(&buf->b);
2018}
2019
2030static inline uint64_t net_buf_remove_le40(struct net_buf *buf)
2031{
2032 return net_buf_simple_remove_le40(&buf->b);
2033}
2034
2045static inline uint64_t net_buf_remove_be40(struct net_buf *buf)
2046{
2047 return net_buf_simple_remove_be40(&buf->b);
2048}
2049
2060static inline uint64_t net_buf_remove_le48(struct net_buf *buf)
2061{
2062 return net_buf_simple_remove_le48(&buf->b);
2063}
2064
2075static inline uint64_t net_buf_remove_be48(struct net_buf *buf)
2076{
2077 return net_buf_simple_remove_be48(&buf->b);
2078}
2079
2090static inline uint64_t net_buf_remove_le64(struct net_buf *buf)
2091{
2092 return net_buf_simple_remove_le64(&buf->b);
2093}
2094
2105static inline uint64_t net_buf_remove_be64(struct net_buf *buf)
2106{
2107 return net_buf_simple_remove_be64(&buf->b);
2108}
2109
2121static inline void *net_buf_push(struct net_buf *buf, size_t len)
2122{
2123 return net_buf_simple_push(&buf->b, len);
2124}
2125
2138static inline void *net_buf_push_mem(struct net_buf *buf, const void *mem,
2139 size_t len)
2140{
2141 return net_buf_simple_push_mem(&buf->b, mem, len);
2142}
2143
2152static inline void net_buf_push_u8(struct net_buf *buf, uint8_t val)
2153{
2154 net_buf_simple_push_u8(&buf->b, val);
2155}
2156
2166static inline void net_buf_push_le16(struct net_buf *buf, uint16_t val)
2167{
2168 net_buf_simple_push_le16(&buf->b, val);
2169}
2170
2180static inline void net_buf_push_be16(struct net_buf *buf, uint16_t val)
2181{
2182 net_buf_simple_push_be16(&buf->b, val);
2183}
2184
2194static inline void net_buf_push_le24(struct net_buf *buf, uint32_t val)
2195{
2196 net_buf_simple_push_le24(&buf->b, val);
2197}
2198
2208static inline void net_buf_push_be24(struct net_buf *buf, uint32_t val)
2209{
2210 net_buf_simple_push_be24(&buf->b, val);
2211}
2212
2222static inline void net_buf_push_le32(struct net_buf *buf, uint32_t val)
2223{
2224 net_buf_simple_push_le32(&buf->b, val);
2225}
2226
2236static inline void net_buf_push_be32(struct net_buf *buf, uint32_t val)
2237{
2238 net_buf_simple_push_be32(&buf->b, val);
2239}
2240
2250static inline void net_buf_push_le40(struct net_buf *buf, uint64_t val)
2251{
2252 net_buf_simple_push_le40(&buf->b, val);
2253}
2254
2264static inline void net_buf_push_be40(struct net_buf *buf, uint64_t val)
2265{
2266 net_buf_simple_push_be40(&buf->b, val);
2267}
2268
2278static inline void net_buf_push_le48(struct net_buf *buf, uint64_t val)
2279{
2280 net_buf_simple_push_le48(&buf->b, val);
2281}
2282
2292static inline void net_buf_push_be48(struct net_buf *buf, uint64_t val)
2293{
2294 net_buf_simple_push_be48(&buf->b, val);
2295}
2296
2306static inline void net_buf_push_le64(struct net_buf *buf, uint64_t val)
2307{
2308 net_buf_simple_push_le64(&buf->b, val);
2309}
2310
2320static inline void net_buf_push_be64(struct net_buf *buf, uint64_t val)
2321{
2322 net_buf_simple_push_be64(&buf->b, val);
2323}
2324
2336static inline void *net_buf_pull(struct net_buf *buf, size_t len)
2337{
2338 return net_buf_simple_pull(&buf->b, len);
2339}
2340
2352static inline void *net_buf_pull_mem(struct net_buf *buf, size_t len)
2353{
2354 return net_buf_simple_pull_mem(&buf->b, len);
2355}
2356
2367static inline uint8_t net_buf_pull_u8(struct net_buf *buf)
2368{
2369 return net_buf_simple_pull_u8(&buf->b);
2370}
2371
2382static inline uint16_t net_buf_pull_le16(struct net_buf *buf)
2383{
2384 return net_buf_simple_pull_le16(&buf->b);
2385}
2386
2397static inline uint16_t net_buf_pull_be16(struct net_buf *buf)
2398{
2399 return net_buf_simple_pull_be16(&buf->b);
2400}
2401
2412static inline uint32_t net_buf_pull_le24(struct net_buf *buf)
2413{
2414 return net_buf_simple_pull_le24(&buf->b);
2415}
2416
2427static inline uint32_t net_buf_pull_be24(struct net_buf *buf)
2428{
2429 return net_buf_simple_pull_be24(&buf->b);
2430}
2431
2442static inline uint32_t net_buf_pull_le32(struct net_buf *buf)
2443{
2444 return net_buf_simple_pull_le32(&buf->b);
2445}
2446
2457static inline uint32_t net_buf_pull_be32(struct net_buf *buf)
2458{
2459 return net_buf_simple_pull_be32(&buf->b);
2460}
2461
2472static inline uint64_t net_buf_pull_le40(struct net_buf *buf)
2473{
2474 return net_buf_simple_pull_le40(&buf->b);
2475}
2476
2487static inline uint64_t net_buf_pull_be40(struct net_buf *buf)
2488{
2489 return net_buf_simple_pull_be40(&buf->b);
2490}
2491
2502static inline uint64_t net_buf_pull_le48(struct net_buf *buf)
2503{
2504 return net_buf_simple_pull_le48(&buf->b);
2505}
2506
2517static inline uint64_t net_buf_pull_be48(struct net_buf *buf)
2518{
2519 return net_buf_simple_pull_be48(&buf->b);
2520}
2521
2532static inline uint64_t net_buf_pull_le64(struct net_buf *buf)
2533{
2534 return net_buf_simple_pull_le64(&buf->b);
2535}
2536
2547static inline uint64_t net_buf_pull_be64(struct net_buf *buf)
2548{
2549 return net_buf_simple_pull_be64(&buf->b);
2550}
2551
2561static inline size_t net_buf_tailroom(const struct net_buf *buf)
2562{
2563 return net_buf_simple_tailroom(&buf->b);
2564}
2565
2575static inline size_t net_buf_headroom(const struct net_buf *buf)
2576{
2577 return net_buf_simple_headroom(&buf->b);
2578}
2579
2589static inline uint16_t net_buf_max_len(const struct net_buf *buf)
2590{
2591 return net_buf_simple_max_len(&buf->b);
2592}
2593
2603static inline uint8_t *net_buf_tail(const struct net_buf *buf)
2604{
2605 return net_buf_simple_tail(&buf->b);
2606}
2607
2614
2626void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
2627
2642struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
2643
2653#if defined(CONFIG_NET_BUF_LOG)
2654struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
2655 struct net_buf *frag,
2656 const char *func, int line);
2657#define net_buf_frag_del(_parent, _frag) \
2658 net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2659#else
2660struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
2661#endif
2662
2678size_t net_buf_linearize(void *dst, size_t dst_len,
2679 const struct net_buf *src, size_t offset, size_t len);
2680
2695typedef struct net_buf * __must_check (*net_buf_allocator_cb)(k_timeout_t timeout,
2696 void *user_data);
2697
2719size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
2720 const void *value, k_timeout_t timeout,
2721 net_buf_allocator_cb allocate_cb, void *user_data);
2722
2737size_t net_buf_data_match(const struct net_buf *buf, size_t offset, const void *data, size_t len);
2738
2754static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
2755{
2756 while (buf && len--) {
2757 net_buf_pull_u8(buf);
2758 if (!buf->len) {
2759 buf = net_buf_frag_del(NULL, buf);
2760 }
2761 }
2762
2763 return buf;
2764}
2765
2776static inline size_t net_buf_frags_len(const struct net_buf *buf)
2777{
2778 size_t bytes = 0;
2779
2780 while (buf) {
2781 bytes += buf->len;
2782 buf = buf->frags;
2783 }
2784
2785 return bytes;
2786}
2787
2791
2792#ifdef __cplusplus
2793}
2794#endif
2795
2796#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:2997
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:2487
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:1895
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:2060
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:1775
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:2754
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:1681
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:1760
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:2472
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:2547
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:2320
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:2090
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:2264
static struct net_buf * net_buf_alloc(struct net_buf_pool *pool, k_timeout_t timeout)
Definition net_buf.h:1467
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:1805
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:2030
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:1955
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:2442
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:2457
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:1745
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:1820
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:2589
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:2517
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:2180
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:1970
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:1835
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:2367
static void net_buf_destroy(struct net_buf *buf)
Destroy buffer from custom destroy callback.
Definition net_buf.h:1544
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:2138
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:2502
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:2278
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:2412
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:1715
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:2208
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:2194
static void net_buf_reserve(struct net_buf *buf, size_t reserve)
Initialize buffer with the given headroom.
Definition net_buf.h:1665
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:2105
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:2427
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:1865
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:1985
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:2152
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:2121
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:2397
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:2222
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:2532
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:2695
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 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:2075
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:1940
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:2166
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:2292
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:1880
static size_t net_buf_headroom(const struct net_buf *buf)
Check buffer headroom.
Definition net_buf.h:2575
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:2015
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:1910
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:1698
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:2306
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 net_buf.h:1925
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:1730
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:2045
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:2236
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:1790
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:2000
static size_t net_buf_frags_len(const struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition net_buf.h:2776
static size_t net_buf_tailroom(const struct net_buf *buf)
Check buffer tailroom.
Definition net_buf.h:2561
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:2382
static uint8_t * net_buf_tail(const struct net_buf *buf)
Get the tail pointer for a buffer.
Definition net_buf.h:2603
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:2352
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:2336
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:2250
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:1850
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:1641
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:2944
Kernel Spin Lock.
Definition spinlock.h:45
Kernel timeout type.
Definition clock.h:65
Network buffer pool representation.
Definition net_buf.h:1142
void(*const destroy)(struct net_buf *buf)
Optional destroy callback when buffer is freed.
Definition net_buf.h:1173
uint16_t uninit_count
Number of uninitialized buffers.
Definition net_buf.h:1153
uint8_t user_data_size
Size of user data allocated to this pool.
Definition net_buf.h:1156
const uint16_t buf_count
Number of buffers in pool.
Definition net_buf.h:1150
const struct net_buf_data_alloc * alloc
Data allocation handlers.
Definition net_buf.h:1176
struct k_lifo free
LIFO to place the buffer into when free.
Definition net_buf.h:1144
struct k_spinlock lock
To prevent concurrent access/modifications.
Definition net_buf.h:1147
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:1101
struct net_buf * frags
Fragments associated with this buffer.
Definition net_buf.h:1011
uint8_t ref
Reference count.
Definition net_buf.h:1074
uint8_t pool_id
Where the buffer should go when freed up.
Definition net_buf.h:1080
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:1083
uint8_t flags
Bit-field of buffer flags.
Definition net_buf.h:1077
uint8_t * data
Pointer to the start of data in the buffer.
Definition net_buf.h:1095
uint8_t user_data[]
System metadata for this buffer.
Definition net_buf.h:1116
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:1098
Misc utilities.