Lines Matching full:buf

17 #include <zephyr/net/buf.h>
32 void net_buf_simple_init_with_data(struct net_buf_simple *buf, in net_buf_simple_init_with_data() argument
35 buf->__buf = data; in net_buf_simple_init_with_data()
36 buf->data = data; in net_buf_simple_init_with_data()
37 buf->size = size; in net_buf_simple_init_with_data()
38 buf->len = size; in net_buf_simple_init_with_data()
41 void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve) in net_buf_simple_reserve() argument
43 __ASSERT_NO_MSG(buf); in net_buf_simple_reserve()
44 __ASSERT_NO_MSG(buf->len == 0U); in net_buf_simple_reserve()
45 NET_BUF_SIMPLE_DBG("buf %p reserve %zu", buf, reserve); in net_buf_simple_reserve()
47 buf->data = buf->__buf + reserve; in net_buf_simple_reserve()
56 void *net_buf_simple_add(struct net_buf_simple *buf, size_t len) in net_buf_simple_add() argument
58 uint8_t *tail = net_buf_simple_tail(buf); in net_buf_simple_add()
60 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_add()
62 __ASSERT_NO_MSG(net_buf_simple_tailroom(buf) >= len); in net_buf_simple_add()
64 buf->len += len; in net_buf_simple_add()
68 void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, in net_buf_simple_add_mem() argument
71 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_add_mem()
73 return memcpy(net_buf_simple_add(buf, len), mem, len); in net_buf_simple_add_mem()
76 uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val) in net_buf_simple_add_u8() argument
80 NET_BUF_SIMPLE_DBG("buf %p val 0x%02x", buf, val); in net_buf_simple_add_u8()
82 u8 = net_buf_simple_add(buf, 1); in net_buf_simple_add_u8()
88 void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val) in net_buf_simple_add_le16() argument
90 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_add_le16()
92 sys_put_le16(val, net_buf_simple_add(buf, sizeof(val))); in net_buf_simple_add_le16()
95 void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val) in net_buf_simple_add_be16() argument
97 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_add_be16()
99 sys_put_be16(val, net_buf_simple_add(buf, sizeof(val))); in net_buf_simple_add_be16()
102 void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_add_le24() argument
104 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_add_le24()
106 sys_put_le24(val, net_buf_simple_add(buf, 3)); in net_buf_simple_add_le24()
109 void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_add_be24() argument
111 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_add_be24()
113 sys_put_be24(val, net_buf_simple_add(buf, 3)); in net_buf_simple_add_be24()
116 void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_add_le32() argument
118 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_add_le32()
120 sys_put_le32(val, net_buf_simple_add(buf, sizeof(val))); in net_buf_simple_add_le32()
123 void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_add_be32() argument
125 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_add_be32()
127 sys_put_be32(val, net_buf_simple_add(buf, sizeof(val))); in net_buf_simple_add_be32()
130 void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_add_le48() argument
132 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_add_le48()
134 sys_put_le48(val, net_buf_simple_add(buf, 6)); in net_buf_simple_add_le48()
137 void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_add_be48() argument
139 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_add_be48()
141 sys_put_be48(val, net_buf_simple_add(buf, 6)); in net_buf_simple_add_be48()
144 void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_add_le64() argument
146 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_add_le64()
148 sys_put_le64(val, net_buf_simple_add(buf, sizeof(val))); in net_buf_simple_add_le64()
151 void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_add_be64() argument
153 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_add_be64()
155 sys_put_be64(val, net_buf_simple_add(buf, sizeof(val))); in net_buf_simple_add_be64()
158 void *net_buf_simple_remove_mem(struct net_buf_simple *buf, size_t len) in net_buf_simple_remove_mem() argument
160 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_remove_mem()
162 __ASSERT_NO_MSG(buf->len >= len); in net_buf_simple_remove_mem()
164 buf->len -= len; in net_buf_simple_remove_mem()
165 return buf->data + buf->len; in net_buf_simple_remove_mem()
168 uint8_t net_buf_simple_remove_u8(struct net_buf_simple *buf) in net_buf_simple_remove_u8() argument
173 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_u8()
179 uint16_t net_buf_simple_remove_le16(struct net_buf_simple *buf) in net_buf_simple_remove_le16() argument
184 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_le16()
190 uint16_t net_buf_simple_remove_be16(struct net_buf_simple *buf) in net_buf_simple_remove_be16() argument
195 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_be16()
201 uint32_t net_buf_simple_remove_le24(struct net_buf_simple *buf) in net_buf_simple_remove_le24() argument
208 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_le24()
214 uint32_t net_buf_simple_remove_be24(struct net_buf_simple *buf) in net_buf_simple_remove_be24() argument
221 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_be24()
227 uint32_t net_buf_simple_remove_le32(struct net_buf_simple *buf) in net_buf_simple_remove_le32() argument
232 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_le32()
238 uint32_t net_buf_simple_remove_be32(struct net_buf_simple *buf) in net_buf_simple_remove_be32() argument
243 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_be32()
249 uint64_t net_buf_simple_remove_le48(struct net_buf_simple *buf) in net_buf_simple_remove_le48() argument
256 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_le48()
262 uint64_t net_buf_simple_remove_be48(struct net_buf_simple *buf) in net_buf_simple_remove_be48() argument
269 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_be48()
275 uint64_t net_buf_simple_remove_le64(struct net_buf_simple *buf) in net_buf_simple_remove_le64() argument
280 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_le64()
286 uint64_t net_buf_simple_remove_be64(struct net_buf_simple *buf) in net_buf_simple_remove_be64() argument
291 ptr = net_buf_simple_remove_mem(buf, sizeof(val)); in net_buf_simple_remove_be64()
297 void *net_buf_simple_push(struct net_buf_simple *buf, size_t len) in net_buf_simple_push() argument
299 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_push()
301 __ASSERT_NO_MSG(net_buf_simple_headroom(buf) >= len); in net_buf_simple_push()
303 buf->data -= len; in net_buf_simple_push()
304 buf->len += len; in net_buf_simple_push()
305 return buf->data; in net_buf_simple_push()
308 void *net_buf_simple_push_mem(struct net_buf_simple *buf, const void *mem, in net_buf_simple_push_mem() argument
311 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_push_mem()
313 return memcpy(net_buf_simple_push(buf, len), mem, len); in net_buf_simple_push_mem()
316 void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val) in net_buf_simple_push_le16() argument
318 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_push_le16()
320 sys_put_le16(val, net_buf_simple_push(buf, sizeof(val))); in net_buf_simple_push_le16()
323 void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val) in net_buf_simple_push_be16() argument
325 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_push_be16()
327 sys_put_be16(val, net_buf_simple_push(buf, sizeof(val))); in net_buf_simple_push_be16()
330 void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val) in net_buf_simple_push_u8() argument
332 uint8_t *data = net_buf_simple_push(buf, 1); in net_buf_simple_push_u8()
337 void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_push_le24() argument
339 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_push_le24()
341 sys_put_le24(val, net_buf_simple_push(buf, 3)); in net_buf_simple_push_le24()
344 void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_push_be24() argument
346 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_push_be24()
348 sys_put_be24(val, net_buf_simple_push(buf, 3)); in net_buf_simple_push_be24()
351 void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_push_le32() argument
353 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_push_le32()
355 sys_put_le32(val, net_buf_simple_push(buf, sizeof(val))); in net_buf_simple_push_le32()
358 void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val) in net_buf_simple_push_be32() argument
360 NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); in net_buf_simple_push_be32()
362 sys_put_be32(val, net_buf_simple_push(buf, sizeof(val))); in net_buf_simple_push_be32()
365 void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_push_le48() argument
367 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_push_le48()
369 sys_put_le48(val, net_buf_simple_push(buf, 6)); in net_buf_simple_push_le48()
372 void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_push_be48() argument
374 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_push_be48()
376 sys_put_be48(val, net_buf_simple_push(buf, 6)); in net_buf_simple_push_be48()
379 void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_push_le64() argument
381 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_push_le64()
383 sys_put_le64(val, net_buf_simple_push(buf, sizeof(val))); in net_buf_simple_push_le64()
386 void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val) in net_buf_simple_push_be64() argument
388 NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); in net_buf_simple_push_be64()
390 sys_put_be64(val, net_buf_simple_push(buf, sizeof(val))); in net_buf_simple_push_be64()
393 void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len) in net_buf_simple_pull() argument
395 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_pull()
397 __ASSERT_NO_MSG(buf->len >= len); in net_buf_simple_pull()
399 buf->len -= len; in net_buf_simple_pull()
400 return buf->data += len; in net_buf_simple_pull()
403 void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len) in net_buf_simple_pull_mem() argument
405 void *data = buf->data; in net_buf_simple_pull_mem()
407 NET_BUF_SIMPLE_DBG("buf %p len %zu", buf, len); in net_buf_simple_pull_mem()
409 __ASSERT_NO_MSG(buf->len >= len); in net_buf_simple_pull_mem()
411 buf->len -= len; in net_buf_simple_pull_mem()
412 buf->data += len; in net_buf_simple_pull_mem()
417 uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf) in net_buf_simple_pull_u8() argument
421 val = buf->data[0]; in net_buf_simple_pull_u8()
422 net_buf_simple_pull(buf, 1); in net_buf_simple_pull_u8()
427 uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf) in net_buf_simple_pull_le16() argument
431 val = UNALIGNED_GET((uint16_t *)buf->data); in net_buf_simple_pull_le16()
432 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_le16()
437 uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf) in net_buf_simple_pull_be16() argument
441 val = UNALIGNED_GET((uint16_t *)buf->data); in net_buf_simple_pull_be16()
442 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_be16()
447 uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf) in net_buf_simple_pull_le24() argument
453 val = UNALIGNED_GET((struct uint24 *)buf->data); in net_buf_simple_pull_le24()
454 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_le24()
459 uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf) in net_buf_simple_pull_be24() argument
465 val = UNALIGNED_GET((struct uint24 *)buf->data); in net_buf_simple_pull_be24()
466 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_be24()
471 uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf) in net_buf_simple_pull_le32() argument
475 val = UNALIGNED_GET((uint32_t *)buf->data); in net_buf_simple_pull_le32()
476 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_le32()
481 uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf) in net_buf_simple_pull_be32() argument
485 val = UNALIGNED_GET((uint32_t *)buf->data); in net_buf_simple_pull_be32()
486 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_be32()
491 uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf) in net_buf_simple_pull_le48() argument
497 val = UNALIGNED_GET((struct uint48 *)buf->data); in net_buf_simple_pull_le48()
498 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_le48()
503 uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf) in net_buf_simple_pull_be48() argument
509 val = UNALIGNED_GET((struct uint48 *)buf->data); in net_buf_simple_pull_be48()
510 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_be48()
515 uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf) in net_buf_simple_pull_le64() argument
519 val = UNALIGNED_GET((uint64_t *)buf->data); in net_buf_simple_pull_le64()
520 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_le64()
525 uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf) in net_buf_simple_pull_be64() argument
529 val = UNALIGNED_GET((uint64_t *)buf->data); in net_buf_simple_pull_be64()
530 net_buf_simple_pull(buf, sizeof(val)); in net_buf_simple_pull_be64()
535 size_t net_buf_simple_headroom(struct net_buf_simple *buf) in net_buf_simple_headroom() argument
537 return buf->data - buf->__buf; in net_buf_simple_headroom()
540 size_t net_buf_simple_tailroom(struct net_buf_simple *buf) in net_buf_simple_tailroom() argument
542 return buf->size - net_buf_simple_headroom(buf) - buf->len; in net_buf_simple_tailroom()
545 uint16_t net_buf_simple_max_len(struct net_buf_simple *buf) in net_buf_simple_max_len() argument
547 return buf->size - net_buf_simple_headroom(buf); in net_buf_simple_max_len()