Lines Matching full:buf

14 #include <zephyr/net/buf.h>
66 static void buf_destroy(struct net_buf *buf);
67 static void fixed_destroy(struct net_buf *buf);
68 static void var_destroy(struct net_buf *buf);
74 static void buf_destroy(struct net_buf *buf) in buf_destroy() argument
76 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id); in buf_destroy()
80 net_buf_destroy(buf); in buf_destroy()
83 static void fixed_destroy(struct net_buf *buf) in fixed_destroy() argument
85 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id); in fixed_destroy()
89 net_buf_destroy(buf); in fixed_destroy()
92 static void var_destroy(struct net_buf *buf) in var_destroy() argument
94 struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id); in var_destroy()
98 net_buf_destroy(buf); in var_destroy()
108 struct net_buf *buf; in ZTEST() local
112 buf = net_buf_alloc_len(&bufs_pool, 74, K_NO_WAIT); in ZTEST()
113 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
114 bufs[i] = buf; in ZTEST()
155 struct net_buf *buf; in test_3_thread() local
159 buf = net_buf_get(fifo, TEST_TIMEOUT); in test_3_thread()
160 zassert_not_null(buf, "Unable to get buffer"); in test_3_thread()
163 net_buf_unref(buf); in test_3_thread()
210 struct net_buf *buf, *frag; in ZTEST() local
215 /* Create a buf that does not have any data to store, it just in ZTEST()
218 buf = net_buf_alloc_len(&bufs_pool, 0, K_FOREVER); in ZTEST()
220 zassert_equal(buf->size, 0, "Invalid buffer size"); in ZTEST()
225 net_buf_frag_add(buf, frag); in ZTEST()
231 net_buf_frag_insert(buf, frag); in ZTEST()
234 frag = buf->frags; in ZTEST()
246 frag = buf->frags; in ZTEST()
261 frag = buf->frags; in ZTEST()
272 while (buf->frags) { in ZTEST()
273 struct net_buf *frag2 = buf->frags; in ZTEST()
275 net_buf_frag_del(buf, frag2); in ZTEST()
285 * by freeing the top buf. in ZTEST()
288 net_buf_frag_add(buf, in ZTEST()
298 net_buf_frag_insert(buf->frags->frags, frag); in ZTEST()
301 frag = buf->frags; in ZTEST()
311 net_buf_unref(buf); in ZTEST()
320 struct net_buf *buf, *frag; in ZTEST() local
327 buf = net_buf_alloc_len(&bufs_pool, 0, K_FOREVER); in ZTEST()
349 net_buf_frag_add(buf, frag); in ZTEST()
350 net_buf_unref(buf); in ZTEST()
358 struct net_buf *buf; in ZTEST() local
366 buf = net_buf_alloc_len(&bufs_pool, 0, K_FOREVER); in ZTEST()
380 net_buf_frag_add(buf, frags[i]); in ZTEST()
388 net_buf_frag_insert(buf, frags[i]); in ZTEST()
402 net_buf_unref(buf); in ZTEST()
410 struct net_buf *buf, *clone; in ZTEST() local
414 buf = net_buf_alloc_len(&bufs_pool, 74, K_NO_WAIT); in ZTEST()
415 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
417 clone = net_buf_clone(buf, K_NO_WAIT); in ZTEST()
419 zassert_equal(buf->data, clone->data, "Incorrect clone data pointer"); in ZTEST()
421 net_buf_unref(buf); in ZTEST()
429 struct net_buf *buf; in ZTEST() local
433 buf = net_buf_alloc_len(&fixed_pool, 20, K_NO_WAIT); in ZTEST()
434 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
436 net_buf_unref(buf); in ZTEST()
466 struct net_buf *buf; in ZTEST() local
481 buf = net_buf_alloc_len(&fixed_pool, 16, K_FOREVER); in ZTEST()
482 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
485 net_buf_add_mem(buf, &le16, sizeof(le16)); in ZTEST()
486 net_buf_add_mem(buf, &be16, sizeof(be16)); in ZTEST()
488 u16 = net_buf_pull_le16(buf); in ZTEST()
489 zassert_equal(u16, net_buf_pull_be16(buf), in ZTEST()
492 net_buf_reset(buf); in ZTEST()
494 net_buf_add_le16(buf, u16); in ZTEST()
495 net_buf_add_be16(buf, u16); in ZTEST()
497 zassert_mem_equal(le16, net_buf_pull_mem(buf, sizeof(le16)), in ZTEST()
499 zassert_mem_equal(be16, net_buf_pull_mem(buf, sizeof(be16)), in ZTEST()
502 net_buf_reset(buf); in ZTEST()
504 net_buf_add_mem(buf, &le24, sizeof(le24)); in ZTEST()
505 net_buf_add_mem(buf, &be24, sizeof(be24)); in ZTEST()
507 u32 = net_buf_pull_le24(buf); in ZTEST()
508 zassert_equal(u32, net_buf_pull_be24(buf), in ZTEST()
511 net_buf_reset(buf); in ZTEST()
513 net_buf_add_le24(buf, u32); in ZTEST()
514 net_buf_add_be24(buf, u32); in ZTEST()
516 zassert_mem_equal(le24, net_buf_pull_mem(buf, sizeof(le24)), in ZTEST()
518 zassert_mem_equal(be24, net_buf_pull_mem(buf, sizeof(be24)), in ZTEST()
521 net_buf_reset(buf); in ZTEST()
523 net_buf_add_mem(buf, &le32, sizeof(le32)); in ZTEST()
524 net_buf_add_mem(buf, &be32, sizeof(be32)); in ZTEST()
526 u32 = net_buf_pull_le32(buf); in ZTEST()
527 zassert_equal(u32, net_buf_pull_be32(buf), in ZTEST()
530 net_buf_reset(buf); in ZTEST()
532 net_buf_add_le32(buf, u32); in ZTEST()
533 net_buf_add_be32(buf, u32); in ZTEST()
535 zassert_mem_equal(le32, net_buf_pull_mem(buf, sizeof(le32)), in ZTEST()
537 zassert_mem_equal(be32, net_buf_pull_mem(buf, sizeof(be32)), in ZTEST()
540 net_buf_reset(buf); in ZTEST()
542 net_buf_add_mem(buf, &le48, sizeof(le48)); in ZTEST()
543 net_buf_add_mem(buf, &be48, sizeof(be48)); in ZTEST()
545 u64 = net_buf_pull_le48(buf); in ZTEST()
546 zassert_equal(u64, net_buf_pull_be48(buf), in ZTEST()
549 net_buf_reset(buf); in ZTEST()
551 net_buf_add_le48(buf, u64); in ZTEST()
552 net_buf_add_be48(buf, u64); in ZTEST()
554 zassert_mem_equal(le48, net_buf_pull_mem(buf, sizeof(le48)), in ZTEST()
556 zassert_mem_equal(be48, net_buf_pull_mem(buf, sizeof(be48)), in ZTEST()
559 net_buf_reset(buf); in ZTEST()
561 net_buf_add_mem(buf, &le64, sizeof(le64)); in ZTEST()
562 net_buf_add_mem(buf, &be64, sizeof(be64)); in ZTEST()
564 u64 = net_buf_pull_le64(buf); in ZTEST()
565 zassert_equal(u64, net_buf_pull_be64(buf), in ZTEST()
568 net_buf_reset(buf); in ZTEST()
570 net_buf_add_le64(buf, u64); in ZTEST()
571 net_buf_add_be64(buf, u64); in ZTEST()
573 zassert_mem_equal(le64, net_buf_pull_mem(buf, sizeof(le64)), in ZTEST()
575 zassert_mem_equal(be64, net_buf_pull_mem(buf, sizeof(be64)), in ZTEST()
579 net_buf_reset(buf); in ZTEST()
580 net_buf_reserve(buf, 16); in ZTEST()
582 net_buf_push_mem(buf, &le16, sizeof(le16)); in ZTEST()
583 net_buf_push_mem(buf, &be16, sizeof(be16)); in ZTEST()
585 u16 = net_buf_remove_le16(buf); in ZTEST()
586 zassert_equal(u16, net_buf_remove_be16(buf), in ZTEST()
589 net_buf_reset(buf); in ZTEST()
590 net_buf_reserve(buf, 16); in ZTEST()
592 net_buf_push_le16(buf, u16); in ZTEST()
593 net_buf_push_be16(buf, u16); in ZTEST()
595 zassert_mem_equal(le16, net_buf_remove_mem(buf, sizeof(le16)), in ZTEST()
597 zassert_mem_equal(be16, net_buf_remove_mem(buf, sizeof(be16)), in ZTEST()
600 net_buf_reset(buf); in ZTEST()
601 net_buf_reserve(buf, 16); in ZTEST()
603 net_buf_push_mem(buf, &le24, sizeof(le24)); in ZTEST()
604 net_buf_push_mem(buf, &be24, sizeof(be24)); in ZTEST()
606 u32 = net_buf_remove_le24(buf); in ZTEST()
607 zassert_equal(u32, net_buf_remove_be24(buf), in ZTEST()
610 net_buf_reset(buf); in ZTEST()
611 net_buf_reserve(buf, 16); in ZTEST()
613 net_buf_push_le24(buf, u32); in ZTEST()
614 net_buf_push_be24(buf, u32); in ZTEST()
616 zassert_mem_equal(le24, net_buf_remove_mem(buf, sizeof(le24)), in ZTEST()
618 zassert_mem_equal(be24, net_buf_remove_mem(buf, sizeof(be24)), in ZTEST()
621 net_buf_reset(buf); in ZTEST()
622 net_buf_reserve(buf, 16); in ZTEST()
624 net_buf_push_mem(buf, &le32, sizeof(le32)); in ZTEST()
625 net_buf_push_mem(buf, &be32, sizeof(be32)); in ZTEST()
627 u32 = net_buf_remove_le32(buf); in ZTEST()
628 zassert_equal(u32, net_buf_remove_be32(buf), in ZTEST()
631 net_buf_reset(buf); in ZTEST()
632 net_buf_reserve(buf, 16); in ZTEST()
634 net_buf_push_le32(buf, u32); in ZTEST()
635 net_buf_push_be32(buf, u32); in ZTEST()
637 zassert_mem_equal(le32, net_buf_remove_mem(buf, sizeof(le32)), in ZTEST()
639 zassert_mem_equal(be32, net_buf_remove_mem(buf, sizeof(be32)), in ZTEST()
642 net_buf_reset(buf); in ZTEST()
643 net_buf_reserve(buf, 16); in ZTEST()
645 net_buf_push_mem(buf, &le48, sizeof(le48)); in ZTEST()
646 net_buf_push_mem(buf, &be48, sizeof(be48)); in ZTEST()
648 u64 = net_buf_remove_le48(buf); in ZTEST()
649 zassert_equal(u64, net_buf_remove_be48(buf), in ZTEST()
652 net_buf_reset(buf); in ZTEST()
653 net_buf_reserve(buf, 16); in ZTEST()
655 net_buf_push_le48(buf, u64); in ZTEST()
656 net_buf_push_be48(buf, u64); in ZTEST()
658 zassert_mem_equal(le48, net_buf_remove_mem(buf, sizeof(le48)), in ZTEST()
660 zassert_mem_equal(be48, net_buf_remove_mem(buf, sizeof(be48)), in ZTEST()
663 net_buf_reset(buf); in ZTEST()
664 net_buf_reserve(buf, 16); in ZTEST()
666 net_buf_push_mem(buf, &le64, sizeof(le64)); in ZTEST()
667 net_buf_push_mem(buf, &be64, sizeof(be64)); in ZTEST()
669 u64 = net_buf_remove_le64(buf); in ZTEST()
670 zassert_equal(u64, net_buf_remove_be64(buf), in ZTEST()
673 net_buf_reset(buf); in ZTEST()
674 net_buf_reserve(buf, 16); in ZTEST()
676 net_buf_push_le64(buf, u64); in ZTEST()
677 net_buf_push_be64(buf, u64); in ZTEST()
679 zassert_mem_equal(le64, net_buf_remove_mem(buf, sizeof(le64)), in ZTEST()
681 zassert_mem_equal(be64, net_buf_remove_mem(buf, sizeof(be64)), in ZTEST()
684 net_buf_unref(buf); in ZTEST()
689 struct net_buf *buf; in ZTEST() local
692 buf = net_buf_alloc(&fixed_pool, K_NO_WAIT); in ZTEST()
693 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
697 zassert_equal(USER_DATA_FIXED, buf->user_data_size, in ZTEST()
700 net_buf_unref(buf); in ZTEST()
703 buf = net_buf_alloc_len(&bufs_pool, 20, K_NO_WAIT); in ZTEST()
704 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
708 zassert_equal(USER_DATA_HEAP, buf->user_data_size, in ZTEST()
711 net_buf_unref(buf); in ZTEST()
714 buf = net_buf_alloc_len(&var_pool, 20, K_NO_WAIT); in ZTEST()
715 zassert_not_null(buf, "Failed to get buffer"); in ZTEST()
719 zassert_equal(USER_DATA_VAR, buf->user_data_size, in ZTEST()
722 net_buf_unref(buf); in ZTEST()