Zephyr Project
A Scalable Open Source RTOS for IoT Embedded Devices
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 <sys/util.h>
16 #include <zephyr.h>
17 
18 #ifndef CONFIG_NET_BUF_USER_DATA_SIZE
19 #define CONFIG_NET_BUF_USER_DATA_SIZE 0
20 #endif
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
33 /* Alignment needed for various parts of the buffer definition */
34 #define __net_buf_align __aligned(sizeof(void *))
35 
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 
140 static 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 
170 static inline void net_buf_simple_reset(struct net_buf_simple *buf)
171 {
172  buf->len = 0U;
173  buf->data = buf->__buf;
174 }
175 
186 void net_buf_simple_clone(const struct net_buf_simple *original,
187  struct net_buf_simple *clone);
188 
200 void *net_buf_simple_add(struct net_buf_simple *buf, size_t len);
201 
214 void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
215  size_t len);
216 
229 
240 void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val);
241 
252 void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val);
253 
264 void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val);
265 
276 void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val);
277 
288 void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val);
289 
300 void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val);
301 
312 void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val);
313 
324 void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val);
325 
336 void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val);
337 
348 void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val);
349 
360 void *net_buf_simple_remove_mem(struct net_buf_simple *buf, size_t len);
361 
373 
385 
397 
409 
421 
433 
445 
457 
469 
481 
493 
505 void *net_buf_simple_push(struct net_buf_simple *buf, size_t len);
506 
519 void *net_buf_simple_push_mem(struct net_buf_simple *buf, const void *mem,
520  size_t len);
521 
531 void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val);
532 
542 void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val);
543 
552 void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val);
553 
563 void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val);
564 
574 void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val);
575 
585 void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val);
586 
596 void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val);
597 
607 void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val);
608 
618 void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val);
619 
629 void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val);
630 
640 void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val);
641 
653 void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len);
654 
666 void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len);
667 
679 
691 
703 
715 
727 
739 
751 
763 
775 
787 
799 
809 static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf)
810 {
811  return buf->data + buf->len;
812 }
813 
823 size_t net_buf_simple_headroom(struct net_buf_simple *buf);
824 
834 size_t net_buf_simple_tailroom(struct net_buf_simple *buf);
835 
846 
859 };
860 
869 static inline void net_buf_simple_save(struct net_buf_simple *buf,
870  struct net_buf_simple_state *state)
871 {
872  state->offset = net_buf_simple_headroom(buf);
873  state->len = buf->len;
874 }
875 
885 static inline void net_buf_simple_restore(struct net_buf_simple *buf,
886  struct net_buf_simple_state *state)
887 {
888  buf->data = buf->__buf + state->offset;
889  buf->len = state->len;
890 }
891 
900 #define NET_BUF_FRAGS BIT(0)
901 
910 #define NET_BUF_EXTERNAL_DATA BIT(1)
911 
919 struct net_buf {
920  union {
923 
925  struct net_buf *frags;
926  };
927 
930 
933 
936 
937  /* Union for convenience access to the net_buf_simple members, also
938  * preserving the old API.
939  */
940  union {
941  /* The ABI of this struct must match net_buf_simple */
942  struct {
945 
948 
951 
956  uint8_t *__buf;
957  };
958 
960  };
961 
964 };
965 
967  uint8_t * (*alloc)(struct net_buf *buf, size_t *size,
969  uint8_t * (*ref)(struct net_buf *buf, uint8_t *data);
970  void (*unref)(struct net_buf *buf, uint8_t *data);
971 };
972 
974  const struct net_buf_data_cb *cb;
975  void *alloc_data;
976 };
977 
983 struct net_buf_pool {
985  struct k_lifo free;
986 
989 
992 
993 #if defined(CONFIG_NET_BUF_POOL_USAGE)
994 
995  atomic_t avail_count;
996 
998  const uint16_t pool_size;
999 
1001  const char *name;
1002 #endif /* CONFIG_NET_BUF_POOL_USAGE */
1003 
1005  void (*const destroy)(struct net_buf *buf);
1006 
1008  const struct net_buf_data_alloc *alloc;
1009 
1011  struct net_buf * const __bufs;
1012 };
1013 
1015 #if defined(CONFIG_NET_BUF_POOL_USAGE)
1016 #define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
1017  { \
1018  .free = Z_LIFO_INITIALIZER(_pool.free), \
1019  .buf_count = _count, \
1020  .uninit_count = _count, \
1021  .avail_count = ATOMIC_INIT(_count), \
1022  .name = STRINGIFY(_pool), \
1023  .destroy = _destroy, \
1024  .alloc = _alloc, \
1025  .__bufs = _bufs, \
1026  }
1027 #else
1028 #define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
1029  { \
1030  .free = Z_LIFO_INITIALIZER(_pool.free), \
1031  .buf_count = _count, \
1032  .uninit_count = _count, \
1033  .destroy = _destroy, \
1034  .alloc = _alloc, \
1035  .__bufs = _bufs, \
1036  }
1037 #endif /* CONFIG_NET_BUF_POOL_USAGE */
1038 
1039 extern const struct net_buf_data_alloc net_buf_heap_alloc;
1068 #define NET_BUF_POOL_HEAP_DEFINE(_name, _count, _destroy) \
1069  static struct net_buf net_buf_##_name[_count] __noinit; \
1070  static struct net_buf_pool _name __net_buf_align \
1071  __in_section(_net_buf_pool, static, _name) = \
1072  NET_BUF_POOL_INITIALIZER(_name, &net_buf_heap_alloc, \
1073  net_buf_##_name, _count, _destroy)
1074 
1076  size_t data_size;
1078 };
1079 
1081 extern const struct net_buf_data_cb net_buf_fixed_cb;
1111 #define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _destroy) \
1112  static struct net_buf net_buf_##_name[_count] __noinit; \
1113  static uint8_t __noinit net_buf_data_##_name[_count][_data_size]; \
1114  static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
1115  .data_size = _data_size, \
1116  .data_pool = (uint8_t *)net_buf_data_##_name, \
1117  }; \
1118  static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = {\
1119  .cb = &net_buf_fixed_cb, \
1120  .alloc_data = (void *)&net_buf_fixed_##_name, \
1121  }; \
1122  static struct net_buf_pool _name __net_buf_align \
1123  __in_section(_net_buf_pool, static, _name) = \
1124  NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \
1125  net_buf_##_name, _count, _destroy)
1126 
1128 extern const struct net_buf_data_cb net_buf_var_cb;
1154 #define NET_BUF_POOL_VAR_DEFINE(_name, _count, _data_size, _destroy) \
1155  static struct net_buf _net_buf_##_name[_count] __noinit; \
1156  K_HEAP_DEFINE(net_buf_mem_pool_##_name, _data_size); \
1157  static const struct net_buf_data_alloc net_buf_data_alloc_##_name = { \
1158  .cb = &net_buf_var_cb, \
1159  .alloc_data = &net_buf_mem_pool_##_name, \
1160  }; \
1161  static struct net_buf_pool _name __net_buf_align \
1162  __in_section(_net_buf_pool, static, _name) = \
1163  NET_BUF_POOL_INITIALIZER(_name, &net_buf_data_alloc_##_name, \
1164  _net_buf_##_name, _count, _destroy)
1165 
1187 #define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \
1188  BUILD_ASSERT(_ud_size <= CONFIG_NET_BUF_USER_DATA_SIZE); \
1189  NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _destroy)
1190 
1198 struct net_buf_pool *net_buf_pool_get(int id);
1199 
1212 int net_buf_id(struct net_buf *buf);
1213 
1228 #if defined(CONFIG_NET_BUF_LOG)
1229 struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
1230  k_timeout_t timeout, const char *func,
1231  int line);
1232 #define net_buf_alloc_fixed(_pool, _timeout) \
1233  net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
1234 #else
1235 struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool,
1237 #endif
1238 
1242 static inline struct net_buf *net_buf_alloc(struct net_buf_pool *pool,
1244 {
1245  return net_buf_alloc_fixed(pool, timeout);
1246 }
1247 
1263 #if defined(CONFIG_NET_BUF_LOG)
1264 struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size,
1265  k_timeout_t timeout, const char *func,
1266  int line);
1267 #define net_buf_alloc_len(_pool, _size, _timeout) \
1268  net_buf_alloc_len_debug(_pool, _size, _timeout, __func__, __LINE__)
1269 #else
1270 struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
1272 #endif
1273 
1293 #if defined(CONFIG_NET_BUF_LOG)
1294 struct net_buf *net_buf_alloc_with_data_debug(struct net_buf_pool *pool,
1295  void *data, size_t size,
1297  const char *func, int line);
1298 #define net_buf_alloc_with_data(_pool, _data_, _size, _timeout) \
1299  net_buf_alloc_with_data_debug(_pool, _data_, _size, _timeout, \
1300  __func__, __LINE__)
1301 #else
1302 struct net_buf *net_buf_alloc_with_data(struct net_buf_pool *pool,
1303  void *data, size_t size,
1305 #endif
1306 
1320 #if defined(CONFIG_NET_BUF_LOG)
1321 struct net_buf *net_buf_get_debug(struct k_fifo *fifo, k_timeout_t timeout,
1322  const char *func, int line);
1323 #define net_buf_get(_fifo, _timeout) \
1324  net_buf_get_debug(_fifo, _timeout, __func__, __LINE__)
1325 #else
1326 struct net_buf *net_buf_get(struct k_fifo *fifo, k_timeout_t timeout);
1327 #endif
1328 
1338 static inline void net_buf_destroy(struct net_buf *buf)
1339 {
1340  struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
1341 
1342  k_lifo_put(&pool->free, buf);
1343 }
1344 
1352 void net_buf_reset(struct net_buf *buf);
1353 
1362 void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve);
1363 
1373 void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
1374 
1386 struct net_buf *net_buf_slist_get(sys_slist_t *list);
1387 
1397 void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
1398 
1406 #if defined(CONFIG_NET_BUF_LOG)
1407 void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
1408 #define net_buf_unref(_buf) \
1409  net_buf_unref_debug(_buf, __func__, __LINE__)
1410 #else
1411 void net_buf_unref(struct net_buf *buf);
1412 #endif
1413 
1421 struct net_buf *net_buf_ref(struct net_buf *buf);
1422 
1436 struct net_buf *net_buf_clone(struct net_buf *buf, k_timeout_t timeout);
1437 
1445 static inline void *net_buf_user_data(const struct net_buf *buf)
1446 {
1447  return (void *)buf->user_data;
1448 }
1449 
1458 static inline void net_buf_reserve(struct net_buf *buf, size_t reserve)
1459 {
1460  net_buf_simple_reserve(&buf->b, reserve);
1461 }
1462 
1474 static inline void *net_buf_add(struct net_buf *buf, size_t len)
1475 {
1476  return net_buf_simple_add(&buf->b, len);
1477 }
1478 
1491 static inline void *net_buf_add_mem(struct net_buf *buf, const void *mem,
1492  size_t len)
1493 {
1494  return net_buf_simple_add_mem(&buf->b, mem, len);
1495 }
1496 
1508 static inline uint8_t *net_buf_add_u8(struct net_buf *buf, uint8_t val)
1509 {
1510  return net_buf_simple_add_u8(&buf->b, val);
1511 }
1512 
1523 static inline void net_buf_add_le16(struct net_buf *buf, uint16_t val)
1524 {
1525  net_buf_simple_add_le16(&buf->b, val);
1526 }
1527 
1538 static inline void net_buf_add_be16(struct net_buf *buf, uint16_t val)
1539 {
1540  net_buf_simple_add_be16(&buf->b, val);
1541 }
1542 
1553 static inline void net_buf_add_le24(struct net_buf *buf, uint32_t val)
1554 {
1555  net_buf_simple_add_le24(&buf->b, val);
1556 }
1557 
1568 static inline void net_buf_add_be24(struct net_buf *buf, uint32_t val)
1569 {
1570  net_buf_simple_add_be24(&buf->b, val);
1571 }
1572 
1583 static inline void net_buf_add_le32(struct net_buf *buf, uint32_t val)
1584 {
1585  net_buf_simple_add_le32(&buf->b, val);
1586 }
1587 
1598 static inline void net_buf_add_be32(struct net_buf *buf, uint32_t val)
1599 {
1600  net_buf_simple_add_be32(&buf->b, val);
1601 }
1602 
1613 static inline void net_buf_add_le48(struct net_buf *buf, uint64_t val)
1614 {
1615  net_buf_simple_add_le48(&buf->b, val);
1616 }
1617 
1628 static inline void net_buf_add_be48(struct net_buf *buf, uint64_t val)
1629 {
1630  net_buf_simple_add_be48(&buf->b, val);
1631 }
1632 
1643 static inline void net_buf_add_le64(struct net_buf *buf, uint64_t val)
1644 {
1645  net_buf_simple_add_le64(&buf->b, val);
1646 }
1647 
1658 static inline void net_buf_add_be64(struct net_buf *buf, uint64_t val)
1659 {
1660  net_buf_simple_add_be64(&buf->b, val);
1661 }
1662 
1673 static inline void *net_buf_remove_mem(struct net_buf *buf, size_t len)
1674 {
1675  return net_buf_simple_remove_mem(&buf->b, len);
1676 }
1677 
1688 static inline uint8_t net_buf_remove_u8(struct net_buf *buf)
1689 {
1690  return net_buf_simple_remove_u8(&buf->b);
1691 }
1692 
1703 static inline uint16_t net_buf_remove_le16(struct net_buf *buf)
1704 {
1705  return net_buf_simple_remove_le16(&buf->b);
1706 }
1707 
1718 static inline uint16_t net_buf_remove_be16(struct net_buf *buf)
1719 {
1720  return net_buf_simple_remove_be16(&buf->b);
1721 }
1722 
1733 static inline uint32_t net_buf_remove_be24(struct net_buf *buf)
1734 {
1735  return net_buf_simple_remove_be24(&buf->b);
1736 }
1737 
1748 static inline uint32_t net_buf_remove_le24(struct net_buf *buf)
1749 {
1750  return net_buf_simple_remove_le24(&buf->b);
1751 }
1752 
1763 static inline uint32_t net_buf_remove_le32(struct net_buf *buf)
1764 {
1765  return net_buf_simple_remove_le32(&buf->b);
1766 }
1767 
1778 static inline uint32_t net_buf_remove_be32(struct net_buf *buf)
1779 {
1780  return net_buf_simple_remove_be32(&buf->b);
1781 }
1782 
1793 static inline uint64_t net_buf_remove_le48(struct net_buf *buf)
1794 {
1795  return net_buf_simple_remove_le48(&buf->b);
1796 }
1797 
1808 static inline uint64_t net_buf_remove_be48(struct net_buf *buf)
1809 {
1810  return net_buf_simple_remove_be48(&buf->b);
1811 }
1812 
1823 static inline uint64_t net_buf_remove_le64(struct net_buf *buf)
1824 {
1825  return net_buf_simple_remove_le64(&buf->b);
1826 }
1827 
1838 static inline uint64_t net_buf_remove_be64(struct net_buf *buf)
1839 {
1840  return net_buf_simple_remove_be64(&buf->b);
1841 }
1842 
1854 static inline void *net_buf_push(struct net_buf *buf, size_t len)
1855 {
1856  return net_buf_simple_push(&buf->b, len);
1857 }
1858 
1871 static inline void *net_buf_push_mem(struct net_buf *buf, const void *mem,
1872  size_t len)
1873 {
1874  return net_buf_simple_push_mem(&buf->b, mem, len);
1875 }
1876 
1885 static inline void net_buf_push_u8(struct net_buf *buf, uint8_t val)
1886 {
1887  net_buf_simple_push_u8(&buf->b, val);
1888 }
1889 
1899 static inline void net_buf_push_le16(struct net_buf *buf, uint16_t val)
1900 {
1901  net_buf_simple_push_le16(&buf->b, val);
1902 }
1903 
1913 static inline void net_buf_push_be16(struct net_buf *buf, uint16_t val)
1914 {
1915  net_buf_simple_push_be16(&buf->b, val);
1916 }
1917 
1927 static inline void net_buf_push_le24(struct net_buf *buf, uint32_t val)
1928 {
1929  net_buf_simple_push_le24(&buf->b, val);
1930 }
1931 
1941 static inline void net_buf_push_be24(struct net_buf *buf, uint32_t val)
1942 {
1943  net_buf_simple_push_be24(&buf->b, val);
1944 }
1945 
1955 static inline void net_buf_push_le32(struct net_buf *buf, uint32_t val)
1956 {
1957  net_buf_simple_push_le32(&buf->b, val);
1958 }
1959 
1969 static inline void net_buf_push_be32(struct net_buf *buf, uint32_t val)
1970 {
1971  net_buf_simple_push_be32(&buf->b, val);
1972 }
1973 
1983 static inline void net_buf_push_le48(struct net_buf *buf, uint64_t val)
1984 {
1985  net_buf_simple_push_le48(&buf->b, val);
1986 }
1987 
1997 static inline void net_buf_push_be48(struct net_buf *buf, uint64_t val)
1998 {
1999  net_buf_simple_push_be48(&buf->b, val);
2000 }
2001 
2011 static inline void net_buf_push_le64(struct net_buf *buf, uint64_t val)
2012 {
2013  net_buf_simple_push_le64(&buf->b, val);
2014 }
2015 
2025 static inline void net_buf_push_be64(struct net_buf *buf, uint64_t val)
2026 {
2027  net_buf_simple_push_be64(&buf->b, val);
2028 }
2029 
2041 static inline void *net_buf_pull(struct net_buf *buf, size_t len)
2042 {
2043  return net_buf_simple_pull(&buf->b, len);
2044 }
2045 
2057 static inline void *net_buf_pull_mem(struct net_buf *buf, size_t len)
2058 {
2059  return net_buf_simple_pull_mem(&buf->b, len);
2060 }
2061 
2072 static inline uint8_t net_buf_pull_u8(struct net_buf *buf)
2073 {
2074  return net_buf_simple_pull_u8(&buf->b);
2075 }
2076 
2087 static inline uint16_t net_buf_pull_le16(struct net_buf *buf)
2088 {
2089  return net_buf_simple_pull_le16(&buf->b);
2090 }
2091 
2102 static inline uint16_t net_buf_pull_be16(struct net_buf *buf)
2103 {
2104  return net_buf_simple_pull_be16(&buf->b);
2105 }
2106 
2117 static inline uint32_t net_buf_pull_le24(struct net_buf *buf)
2118 {
2119  return net_buf_simple_pull_le24(&buf->b);
2120 }
2121 
2132 static inline uint32_t net_buf_pull_be24(struct net_buf *buf)
2133 {
2134  return net_buf_simple_pull_be24(&buf->b);
2135 }
2136 
2147 static inline uint32_t net_buf_pull_le32(struct net_buf *buf)
2148 {
2149  return net_buf_simple_pull_le32(&buf->b);
2150 }
2151 
2162 static inline uint32_t net_buf_pull_be32(struct net_buf *buf)
2163 {
2164  return net_buf_simple_pull_be32(&buf->b);
2165 }
2166 
2177 static inline uint64_t net_buf_pull_le48(struct net_buf *buf)
2178 {
2179  return net_buf_simple_pull_le48(&buf->b);
2180 }
2181 
2192 static inline uint64_t net_buf_pull_be48(struct net_buf *buf)
2193 {
2194  return net_buf_simple_pull_be48(&buf->b);
2195 }
2196 
2207 static inline uint64_t net_buf_pull_le64(struct net_buf *buf)
2208 {
2209  return net_buf_simple_pull_le64(&buf->b);
2210 }
2211 
2222 static inline uint64_t net_buf_pull_be64(struct net_buf *buf)
2223 {
2224  return net_buf_simple_pull_be64(&buf->b);
2225 }
2226 
2236 static inline size_t net_buf_tailroom(struct net_buf *buf)
2237 {
2238  return net_buf_simple_tailroom(&buf->b);
2239 }
2240 
2250 static inline size_t net_buf_headroom(struct net_buf *buf)
2251 {
2252  return net_buf_simple_headroom(&buf->b);
2253 }
2254 
2264 static inline uint16_t net_buf_max_len(struct net_buf *buf)
2265 {
2266  return net_buf_simple_max_len(&buf->b);
2267 }
2268 
2278 static inline uint8_t *net_buf_tail(struct net_buf *buf)
2279 {
2280  return net_buf_simple_tail(&buf->b);
2281 }
2282 
2288 struct net_buf *net_buf_frag_last(struct net_buf *frags);
2289 
2301 void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
2302 
2317 struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
2318 
2328 #if defined(CONFIG_NET_BUF_LOG)
2329 struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
2330  struct net_buf *frag,
2331  const char *func, int line);
2332 #define net_buf_frag_del(_parent, _frag) \
2333  net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
2334 #else
2335 struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
2336 #endif
2337 
2353 size_t net_buf_linearize(void *dst, size_t dst_len,
2354  struct net_buf *src, size_t offset, size_t len);
2355 
2370 typedef struct net_buf *(*net_buf_allocator_cb)(k_timeout_t timeout,
2371  void *user_data);
2372 
2394 size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
2395  const void *value, k_timeout_t timeout,
2396  net_buf_allocator_cb allocate_cb, void *user_data);
2397 
2413 static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
2414 {
2415  while (buf && len--) {
2416  net_buf_pull_u8(buf);
2417  if (!buf->len) {
2418  buf = net_buf_frag_del(NULL, buf);
2419  }
2420  }
2421 
2422  return buf;
2423 }
2424 
2435 static inline size_t net_buf_frags_len(struct net_buf *buf)
2436 {
2437  size_t bytes = 0;
2438 
2439  while (buf) {
2440  bytes += buf->len;
2441  buf = buf->frags;
2442  }
2443 
2444  return bytes;
2445 }
2446 
2451 #ifdef __cplusplus
2452 }
2453 #endif
2454 
2455 #endif /* ZEPHYR_INCLUDE_NET_BUF_H_ */
net_buf_simple_remove_mem
void * net_buf_simple_remove_mem(struct net_buf_simple *buf, size_t len)
Remove data from the end of the buffer.
net_buf_add_le48
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:1613
net_buf
Network buffer representation.
Definition: buf.h:919
net_buf_push_le32
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:1955
net_buf_simple::size
uint16_t size
Definition: buf.h:99
net_buf_tail
static uint8_t * net_buf_tail(struct net_buf *buf)
Get the tail pointer for a buffer.
Definition: buf.h:2278
net_buf_remove_le64
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:1823
sys_snode_t
struct _snode sys_snode_t
Definition: slist.h:33
net_buf_simple_remove_be16
uint16_t net_buf_simple_remove_be16(struct net_buf_simple *buf)
Remove and convert 16 bits from the end of the buffer.
net_buf_pool::buf_count
const uint16_t buf_count
Definition: buf.h:988
net_buf::size
uint16_t size
Definition: buf.h:950
net_buf_destroy
static void net_buf_destroy(struct net_buf *buf)
Destroy buffer from custom destroy callback.
Definition: buf.h:1338
net_buf_simple_pull_le24
uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
Remove and convert 24 bits from the beginning of the buffer.
net_buf_simple_remove_be64
uint64_t net_buf_simple_remove_be64(struct net_buf_simple *buf)
Remove and convert 64 bits from the end of the buffer.
net_buf_pool_fixed::data_size
size_t data_size
Definition: buf.h:1076
net_buf_simple_add_le48
void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
net_buf_simple_state
Parsing state of a buffer.
Definition: buf.h:854
net_buf_simple_add_be64
void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
net_buf_simple::data
uint8_t * data
Definition: buf.h:89
net_buf::flags
uint8_t flags
Definition: buf.h:932
net_buf_add_be16
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:1538
net_buf_remove_be48
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:1808
net_buf_simple_pull_mem
void * net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
Remove data from the beginning of the buffer.
net_buf_data_alloc::alloc_data
void * alloc_data
Definition: buf.h:975
net_buf_simple_push_le48
void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
net_buf_simple_init
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
net_buf::frags
struct net_buf * frags
Definition: buf.h:925
net_buf_push_be48
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:1997
net_buf_simple_save
static void net_buf_simple_save(struct net_buf_simple *buf, struct net_buf_simple_state *state)
Save the parsing state of a buffer.
Definition: buf.h:869
net_buf_remove_be64
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:1838
net_buf_simple_clone
void net_buf_simple_clone(const struct net_buf_simple *original, struct net_buf_simple *clone)
net_buf_simple_push_be32
void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
net_buf_simple_add_le32
void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
net_buf_simple::len
uint16_t len
Definition: buf.h:96
net_buf_push_mem
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:1871
net_buf_unref
void net_buf_unref(struct net_buf *buf)
Decrements the reference count of a buffer.
net_buf_add_le32
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:1583
net_buf_frag_add
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.
net_buf_simple_pull_be64
uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf)
Remove and convert 64 bits from the beginning of the buffer.
net_buf_push_u8
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:1885
net_buf_pull_be64
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:2222
net_buf_simple_pull_be16
uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
Remove and convert 16 bits from the beginning of the buffer.
net_buf::data
uint8_t * data
Definition: buf.h:944
net_buf_simple_add_u8
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.
net_buf_frags_len
static size_t net_buf_frags_len(struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition: buf.h:2435
net_buf_user_data
static void * net_buf_user_data(const struct net_buf *buf)
Get a pointer to the user data of a buffer.
Definition: buf.h:1445
net_buf_simple_state::offset
uint16_t offset
Definition: buf.h:856
net_buf_pool::destroy
void(*const destroy)(struct net_buf *buf)
Definition: buf.h:1005
net_buf_pool::free
struct k_lifo free
Definition: buf.h:985
net_buf_simple_add_le24
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
net_buf_pull_le32
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:2147
net_buf_pull_mem
static void * net_buf_pull_mem(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition: buf.h:2057
net_buf_simple_init_with_data
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.
net_buf_put
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf)
Put a buffer to the end of a FIFO.
net_buf::ref
uint8_t ref
Definition: buf.h:929
net_buf_data_cb
Definition: buf.h:966
net_buf_data_alloc
Definition: buf.h:973
net_buf_remove_u8
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:1688
uint8_t
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
net_buf_remove_le16
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:1703
net_buf::pool_id
uint8_t pool_id
Definition: buf.h:935
net_buf_simple_add_be48
void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val)
Add 48-bit value at the end of the buffer.
net_buf_add_le24
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:1553
net_buf_remove_le48
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:1793
timeout
ZTEST_BMEM int timeout
Definition: main.c:31
net_buf_remove_mem
static void * net_buf_remove_mem(struct net_buf *buf, size_t len)
Remove data from the end of the buffer.
Definition: buf.h:1673
net_buf_simple_reset
static void net_buf_simple_reset(struct net_buf_simple *buf)
Reset buffer.
Definition: buf.h:170
net_buf_simple_push_be16
void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
net_buf_simple_remove_be32
uint32_t net_buf_simple_remove_be32(struct net_buf_simple *buf)
Remove and convert 32 bits from the end of the buffer.
net_buf_simple_tailroom
size_t net_buf_simple_tailroom(struct net_buf_simple *buf)
Check buffer tailroom.
net_buf_add_be48
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:1628
net_buf_simple_remove_u8
uint8_t net_buf_simple_remove_u8(struct net_buf_simple *buf)
Remove a 8-bit value from the end of the buffer.
types.h
net_buf_push
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:1854
net_buf_tailroom
static size_t net_buf_tailroom(struct net_buf *buf)
Check buffer tailroom.
Definition: buf.h:2236
net_buf_frag_last
struct net_buf * net_buf_frag_last(struct net_buf *frags)
Find the last fragment in the fragment list.
k_fifo
Definition: kernel.h:1984
net_buf_push_be64
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:2025
net_buf_push_be24
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:1941
net_buf_reserve
static void net_buf_reserve(struct net_buf *buf, size_t reserve)
Initialize buffer with the given headroom.
Definition: buf.h:1458
net_buf_pull_le48
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:2177
net_buf_pull_le64
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:2207
CONFIG_NET_BUF_USER_DATA_SIZE
#define CONFIG_NET_BUF_USER_DATA_SIZE
Definition: buf.h:19
net_buf_simple_remove_le16
uint16_t net_buf_simple_remove_le16(struct net_buf_simple *buf)
Remove and convert 16 bits from the end of the buffer.
net_buf_pool
Network buffer pool representation.
Definition: buf.h:983
uint64_t
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
net_buf_push_be16
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:1913
net_buf_push_le48
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:1983
net_buf_slist_put
void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
Put a buffer into a list.
net_buf_simple_push_be48
void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val)
Push 48-bit value to the beginning of the buffer.
net_buf_push_le16
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:1899
net_buf_push_be32
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:1969
net_buf_simple_state::len
uint16_t len
Definition: buf.h:858
net_buf_simple_push_le64
void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
uint32_t
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
net_buf_simple_pull_u8
uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
Remove a 8-bit value from the beginning of the buffer.
net_buf_reset
void net_buf_reset(struct net_buf *buf)
Reset buffer.
net_buf_linearize
size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src, size_t offset, size_t len)
Copy bytes from net_buf chain starting at offset to linear buffer.
net_buf_add_mem
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:1491
net_buf_simple_push_le16
void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val)
Push 16-bit value to the beginning of the buffer.
net_buf_skip
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:2413
net_buf_simple_remove_be24
uint32_t net_buf_simple_remove_be24(struct net_buf_simple *buf)
Remove and convert 24 bits from the end of the buffer.
net_buf_pull
static void * net_buf_pull(struct net_buf *buf, size_t len)
Remove data from the beginning of the buffer.
Definition: buf.h:2041
net_buf_add_le16
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:1523
net_buf_data_cb::unref
void(* unref)(struct net_buf *buf, uint8_t *data)
Definition: buf.h:970
state
state
Definition: http_parser_state.h:30
net_buf_simple_remove_le64
uint64_t net_buf_simple_remove_le64(struct net_buf_simple *buf)
Remove and convert 64 bits from the end of the buffer.
net_buf_alloc_with_data
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.
net_buf_simple_add_mem
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.
net_buf_allocator_cb
struct net_buf *(* net_buf_allocator_cb)(k_timeout_t timeout, void *user_data)
Network buffer allocator callback.
Definition: buf.h:2370
k_timeout_t
Kernel timeout type.
Definition: sys_clock.h:65
net_buf_pull_be24
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:2132
net_buf_append_bytes
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.
net_buf_add_be24
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:1568
net_buf_max_len
static uint16_t net_buf_max_len(struct net_buf *buf)
Check maximum net_buf::len value.
Definition: buf.h:2264
net_buf_simple_reserve
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
Initialize buffer with the given headroom.
net_buf_pool::alloc
const struct net_buf_data_alloc * alloc
Definition: buf.h:1008
net_buf_simple_max_len
uint16_t net_buf_simple_max_len(struct net_buf_simple *buf)
Check maximum net_buf_simple::len value.
net_buf_remove_be32
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:1778
net_buf_simple_remove_le32
uint32_t net_buf_simple_remove_le32(struct net_buf_simple *buf)
Remove and convert 32 bits from the end of the buffer.
net_buf_simple_pull_be48
uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
Remove and convert 48 bits from the beginning of the buffer.
net_buf_simple_pull
void * net_buf_simple_pull(struct net_buf_simple *buf, size_t len)
Remove data from the beginning of the buffer.
net_buf_simple_push_be24
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
net_buf::node
sys_snode_t node
Definition: buf.h:922
net_buf_simple_add_be32
void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val)
Add 32-bit value at the end of the buffer.
net_buf_simple_pull_be24
uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
Remove and convert 24 bits from the beginning of the buffer.
net_buf_alloc_fixed
struct net_buf * net_buf_alloc_fixed(struct net_buf_pool *pool, k_timeout_t timeout)
Allocate a new fixed buffer from a pool.
net_buf_simple_pull_le64
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
Remove and convert 64 bits from the beginning of the buffer.
net_buf_frag_del
struct net_buf * net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
Delete existing fragment from a chain of bufs.
net_buf_simple_add_be24
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val)
Add 24-bit value at the end of the buffer.
net_buf_simple_push_be64
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val)
Push 64-bit value to the beginning of the buffer.
uint16_t
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
net_buf_ref
struct net_buf * net_buf_ref(struct net_buf *buf)
Increment the reference count of a buffer.
net_buf_simple_add_le64
void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val)
Add 64-bit value at the end of the buffer.
net_buf_pool::uninit_count
uint16_t uninit_count
Definition: buf.h:991
net_buf_frag_insert
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag)
Insert a new fragment to a chain of bufs.
net_buf_pull_u8
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:2072
net_buf::user_data
uint8_t user_data[0]
Definition: buf.h:963
net_buf_simple
Simple network buffer representation.
Definition: buf.h:87
net_buf_slist_get
struct net_buf * net_buf_slist_get(sys_slist_t *list)
Get a buffer from a list.
net_buf_simple_remove_le24
uint32_t net_buf_simple_remove_le24(struct net_buf_simple *buf)
Remove and convert 24 bits from the end of the buffer.
net_buf_data_alloc::cb
const struct net_buf_data_cb * cb
Definition: buf.h:974
net_buf_id
int net_buf_id(struct net_buf *buf)
Get a zero-based index for a buffer.
net_buf_headroom
static size_t net_buf_headroom(struct net_buf *buf)
Check buffer headroom.
Definition: buf.h:2250
k_lifo
Definition: kernel.h:2228
net_buf::b
struct net_buf_simple b
Definition: buf.h:959
net_buf_alloc
static struct net_buf * net_buf_alloc(struct net_buf_pool *pool, k_timeout_t timeout)
Definition: buf.h:1242
k_lifo_put
#define k_lifo_put(lifo, data)
Add an element to a LIFO queue.
Definition: kernel.h:2281
net_buf_simple_add_be16
void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
net_buf_add_u8
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:1508
net_buf_simple_headroom
size_t net_buf_simple_headroom(struct net_buf_simple *buf)
Check buffer headroom.
net_buf_remove_le32
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:1763
net_buf_simple_tail
static uint8_t * net_buf_simple_tail(struct net_buf_simple *buf)
Get the tail pointer for a buffer.
Definition: buf.h:809
data
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
net_buf_add
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:1474
net_buf_pool_fixed::data_pool
uint8_t * data_pool
Definition: buf.h:1077
net_buf_add_be64
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:1658
net_buf_simple_push
void * net_buf_simple_push(struct net_buf_simple *buf, size_t len)
Prepare data to be added to the start of the buffer.
net_buf_simple_pull_le48
uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
Remove and convert 48 bits from the beginning of the buffer.
net_buf_pull_le16
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:2087
net_buf_pool_fixed
Definition: buf.h:1075
net_buf_simple_add
void * net_buf_simple_add(struct net_buf_simple *buf, size_t len)
Prepare data to be added at the end of the buffer.
net_buf_remove_be16
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:1718
net_buf::len
uint16_t len
Definition: buf.h:947
net_buf_pull_be48
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:2192
net_buf_clone
struct net_buf * net_buf_clone(struct net_buf *buf, k_timeout_t timeout)
Clone buffer.
net_buf_pool_get
struct net_buf_pool * net_buf_pool_get(int id)
Looks up a pool based on its ID.
net_buf_pull_le24
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:2117
net_buf_push_le24
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:1927
net_buf_simple_push_le24
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val)
Push 24-bit value to the beginning of the buffer.
fifo
struct k_fifo fifo
Definition: errno.c:43
user_data
static const intptr_t user_data[5]
Definition: main.c:590
sys_slist_t
struct _slist sys_slist_t
Definition: slist.h:40
net_buf_remove_be24
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:1733
net_buf_simple_push_u8
void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val)
Push 8-bit value to the beginning of the buffer.
net_buf_remove_le24
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:1748
net_buf_pull_be16
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:2102
net_buf_get
struct net_buf * net_buf_get(struct k_fifo *fifo, k_timeout_t timeout)
Get a buffer from a FIFO.
net_buf_simple_add_le16
void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val)
Add 16-bit value at the end of the buffer.
net_buf_simple_pull_le32
uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
Remove and convert 32 bits from the beginning of the buffer.
util.h
Misc utilities.
net_buf_add_be32
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:1598
net_buf_simple_push_le32
void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val)
Push 32-bit value to the beginning of the buffer.
atomic_t
int atomic_t
Definition: atomic.h:21
net_buf_simple_remove_le48
uint64_t net_buf_simple_remove_le48(struct net_buf_simple *buf)
Remove and convert 48 bits from the end of the buffer.
net_buf_pull_be32
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:2162
net_buf_simple_restore
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:885
net_buf_simple_pull_le16
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
Remove and convert 16 bits from the beginning of the buffer.
net_buf_simple_push_mem
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.
net_buf_alloc_len
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.
net_buf_add_le64
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:1643
net_buf_simple_pull_be32
uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
Remove and convert 32 bits from the beginning of the buffer.
net_buf_push_le64
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:2011
net_buf_simple_remove_be48
uint64_t net_buf_simple_remove_be48(struct net_buf_simple *buf)
Remove and convert 48 bits from the end of the buffer.