16#ifndef ZEPHYR_INCLUDE_NET_NET_PKT_H_
17#define ZEPHYR_INCLUDE_NET_NET_PKT_H_
24#if defined(CONFIG_IEEE802154)
89#if defined(CONFIG_NET_TCP)
93#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
97#if defined(CONFIG_NET_PKT_TIMESTAMP)
102#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
107#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
108 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
123#if defined(CONFIG_NET_PKT_TXTIME)
136#if defined(CONFIG_NET_IP)
162#if defined(CONFIG_NET_IPV4_AUTO)
169#if defined(CONFIG_NET_LLDP)
176#if defined(CONFIG_NET_TCP)
196#if defined(CONFIG_NET_IP)
201#if defined(CONFIG_NET_IPV6)
204#if defined(CONFIG_NET_IPV4)
210#if defined(CONFIG_NET_IPV4)
213#if defined(CONFIG_NET_IPV6)
218#if defined(CONFIG_NET_IPV4_FRAGMENT) || defined(CONFIG_NET_IPV6_FRAGMENT)
220#if defined(CONFIG_NET_IPV4_FRAGMENT)
226#if defined(CONFIG_NET_IPV6_FRAGMENT)
236#if defined(CONFIG_NET_IPV6)
248#if defined(CONFIG_NET_IP_DSCP_ECN)
257#if defined(CONFIG_NET_VLAN)
266#if defined(NET_PKT_HAS_CONTROL_BLOCK)
271#if defined(CONFIG_IEEE802154)
275 struct net_pkt_cb_ieee802154 cb;
300static inline void net_pkt_set_context(
struct net_pkt *pkt,
306static inline struct net_if *net_pkt_iface(
struct net_pkt *pkt)
311static inline void net_pkt_set_iface(
struct net_pkt *pkt,
struct net_if *iface)
325static inline struct net_if *net_pkt_orig_iface(
struct net_pkt *pkt)
327#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
328 return pkt->orig_iface;
334static inline void net_pkt_set_orig_iface(
struct net_pkt *pkt,
337#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
338 pkt->orig_iface = iface;
347static inline void net_pkt_set_family(
struct net_pkt *pkt,
uint8_t family)
349 pkt->family = family;
352static inline bool net_pkt_is_ptp(
struct net_pkt *pkt)
354 return !!(pkt->ptp_pkt);
357static inline void net_pkt_set_ptp(
struct net_pkt *pkt,
bool is_ptp)
359 pkt->ptp_pkt = is_ptp;
362static inline bool net_pkt_is_captured(
struct net_pkt *pkt)
364 return !!(pkt->captured);
367static inline void net_pkt_set_captured(
struct net_pkt *pkt,
bool is_captured)
369 pkt->captured = is_captured;
372static inline bool net_pkt_is_l2_bridged(
struct net_pkt *pkt)
374 return IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE) ? !!(pkt->l2_bridged) : 0;
377static inline void net_pkt_set_l2_bridged(
struct net_pkt *pkt,
bool is_l2_bridged)
380 pkt->l2_bridged = is_l2_bridged;
384static inline bool net_pkt_is_l2_processed(
struct net_pkt *pkt)
386 return !!(pkt->l2_processed);
389static inline void net_pkt_set_l2_processed(
struct net_pkt *pkt,
390 bool is_l2_processed)
392 pkt->l2_processed = is_l2_processed;
397#if defined(CONFIG_NET_IP)
398 return pkt->ip_hdr_len;
404static inline void net_pkt_set_ip_hdr_len(
struct net_pkt *pkt,
uint8_t len)
406#if defined(CONFIG_NET_IP)
407 pkt->ip_hdr_len = len;
413#if defined(CONFIG_NET_IP_DSCP_ECN)
420static inline void net_pkt_set_ip_dscp(
struct net_pkt *pkt,
uint8_t dscp)
422#if defined(CONFIG_NET_IP_DSCP_ECN)
429#if defined(CONFIG_NET_IP_DSCP_ECN)
436static inline void net_pkt_set_ip_ecn(
struct net_pkt *pkt,
uint8_t ecn)
438#if defined(CONFIG_NET_IP_DSCP_ECN)
445 return pkt->sent_or_eof;
448static inline void net_pkt_set_sent(
struct net_pkt *pkt,
bool sent)
450 pkt->sent_or_eof = sent;
455 return pkt->pkt_queued;
458static inline void net_pkt_set_queued(
struct net_pkt *pkt,
bool send)
460 pkt->pkt_queued =
send;
465#if defined(CONFIG_NET_TCP)
466 return pkt->tcp_first_msg;
472static inline void net_pkt_set_tcp_1st_msg(
struct net_pkt *pkt,
bool is_1st)
474#if defined(CONFIG_NET_TCP)
475 pkt->tcp_first_msg = is_1st;
482#if defined(CONFIG_NET_SOCKETS)
485 return pkt->sent_or_eof;
488static inline void net_pkt_set_eof(
struct net_pkt *pkt,
bool eof)
490 pkt->sent_or_eof = eof;
494#if defined(CONFIG_NET_ROUTE)
495static inline bool net_pkt_forwarding(
struct net_pkt *pkt)
497 return pkt->forwarding;
500static inline void net_pkt_set_forwarding(
struct net_pkt *pkt,
bool forward)
502 pkt->forwarding = forward;
505static inline bool net_pkt_forwarding(
struct net_pkt *pkt)
511#if defined(CONFIG_NET_IPV4)
514 return pkt->ipv4_ttl;
517static inline void net_pkt_set_ipv4_ttl(
struct net_pkt *pkt,
525 return pkt->ipv4_opts_len;
528static inline void net_pkt_set_ipv4_opts_len(
struct net_pkt *pkt,
531 pkt->ipv4_opts_len = opts_len;
541static inline void net_pkt_set_ipv4_ttl(
struct net_pkt *pkt,
554static inline void net_pkt_set_ipv4_opts_len(
struct net_pkt *pkt,
558 ARG_UNUSED(opts_len);
562#if defined(CONFIG_NET_IPV6)
563static inline uint8_t net_pkt_ipv6_ext_opt_len(
struct net_pkt *pkt)
565 return pkt->ipv6_ext_opt_len;
568static inline void net_pkt_set_ipv6_ext_opt_len(
struct net_pkt *pkt,
571 pkt->ipv6_ext_opt_len = len;
576 return pkt->ipv6_next_hdr;
579static inline void net_pkt_set_ipv6_next_hdr(
struct net_pkt *pkt,
582 pkt->ipv6_next_hdr = next_hdr;
587 return pkt->ipv6_ext_len;
590static inline void net_pkt_set_ipv6_ext_len(
struct net_pkt *pkt,
uint16_t len)
592 pkt->ipv6_ext_len = len;
597 return pkt->ipv6_prev_hdr_start;
600static inline void net_pkt_set_ipv6_hdr_prev(
struct net_pkt *pkt,
603 pkt->ipv6_prev_hdr_start = offset;
608 return pkt->ipv6_hop_limit;
611static inline void net_pkt_set_ipv6_hop_limit(
struct net_pkt *pkt,
614 pkt->ipv6_hop_limit = hop_limit;
617static inline uint8_t net_pkt_ipv6_ext_opt_len(
struct net_pkt *pkt)
624static inline void net_pkt_set_ipv6_ext_opt_len(
struct net_pkt *pkt,
638static inline void net_pkt_set_ipv6_next_hdr(
struct net_pkt *pkt,
642 ARG_UNUSED(next_hdr);
652static inline void net_pkt_set_ipv6_ext_len(
struct net_pkt *pkt,
uint16_t len)
665static inline void net_pkt_set_ipv6_hdr_prev(
struct net_pkt *pkt,
679static inline void net_pkt_set_ipv6_hop_limit(
struct net_pkt *pkt,
683 ARG_UNUSED(hop_limit);
689#if defined(CONFIG_NET_IPV6)
690 return pkt->ipv6_ext_len;
691#elif defined(CONFIG_NET_IPV4)
692 return pkt->ipv4_opts_len;
700#if defined(CONFIG_NET_IPV4_FRAGMENT)
701static inline uint16_t net_pkt_ipv4_fragment_offset(
struct net_pkt *pkt)
703 return (pkt->ipv4_fragment.flags & NET_IPV4_FRAGH_OFFSET_MASK) * 8;
706static inline bool net_pkt_ipv4_fragment_more(
struct net_pkt *pkt)
708 return (pkt->ipv4_fragment.flags & NET_IPV4_MORE_FRAG_MASK) != 0;
713 pkt->ipv4_fragment.flags =
flags;
718 return pkt->ipv4_fragment.id;
721static inline void net_pkt_set_ipv4_fragment_id(
struct net_pkt *pkt,
uint32_t id)
723 pkt->ipv4_fragment.id = id;
726static inline uint16_t net_pkt_ipv4_fragment_offset(
struct net_pkt *pkt)
733static inline bool net_pkt_ipv4_fragment_more(
struct net_pkt *pkt)
753static inline void net_pkt_set_ipv4_fragment_id(
struct net_pkt *pkt,
uint32_t id)
760#if defined(CONFIG_NET_IPV6_FRAGMENT)
763 return pkt->ipv6_fragment.hdr_start;
766static inline void net_pkt_set_ipv6_fragment_start(
struct net_pkt *pkt,
769 pkt->ipv6_fragment.hdr_start = start;
772static inline uint16_t net_pkt_ipv6_fragment_offset(
struct net_pkt *pkt)
774 return pkt->ipv6_fragment.flags & NET_IPV6_FRAGH_OFFSET_MASK;
776static inline bool net_pkt_ipv6_fragment_more(
struct net_pkt *pkt)
778 return (pkt->ipv6_fragment.flags & 0x01) != 0;
781static inline void net_pkt_set_ipv6_fragment_flags(
struct net_pkt *pkt,
784 pkt->ipv6_fragment.flags =
flags;
789 return pkt->ipv6_fragment.id;
792static inline void net_pkt_set_ipv6_fragment_id(
struct net_pkt *pkt,
795 pkt->ipv6_fragment.id = id;
805static inline void net_pkt_set_ipv6_fragment_start(
struct net_pkt *pkt,
812static inline uint16_t net_pkt_ipv6_fragment_offset(
struct net_pkt *pkt)
819static inline bool net_pkt_ipv6_fragment_more(
struct net_pkt *pkt)
826static inline void net_pkt_set_ipv6_fragment_flags(
struct net_pkt *pkt,
840static inline void net_pkt_set_ipv6_fragment_id(
struct net_pkt *pkt,
850 return pkt->priority;
853static inline void net_pkt_set_priority(
struct net_pkt *pkt,
856 pkt->priority = priority;
859#if defined(CONFIG_NET_VLAN)
875static inline void net_pkt_set_vlan_priority(
struct net_pkt *pkt,
881static inline bool net_pkt_vlan_dei(
struct net_pkt *pkt)
886static inline void net_pkt_set_vlan_dei(
struct net_pkt *pkt,
bool dei)
891static inline void net_pkt_set_vlan_tci(
struct net_pkt *pkt,
uint16_t tci)
898 return pkt->vlan_tci;
918static inline bool net_pkt_vlan_dei(
struct net_pkt *pkt)
923static inline void net_pkt_set_vlan_dei(
struct net_pkt *pkt,
bool dei)
934static inline void net_pkt_set_vlan_tci(
struct net_pkt *pkt,
uint16_t tci)
941#if defined(CONFIG_NET_PKT_TIMESTAMP)
944 return &pkt->timestamp;
947static inline void net_pkt_set_timestamp(
struct net_pkt *pkt,
950 pkt->timestamp.second = timestamp->
second;
951 pkt->timestamp.nanosecond = timestamp->
nanosecond;
961static inline void net_pkt_set_timestamp(
struct net_pkt *pkt,
965 ARG_UNUSED(timestamp);
969#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
972 return pkt->create_time;
975static inline void net_pkt_set_create_time(
struct net_pkt *pkt,
978 pkt->create_time = create_time;
988static inline void net_pkt_set_create_time(
struct net_pkt *pkt,
992 ARG_UNUSED(create_time);
996#if defined(CONFIG_NET_PKT_TXTIME)
1002static inline void net_pkt_set_txtime(
struct net_pkt *pkt,
uint64_t txtime)
1004 pkt->txtime = txtime;
1014static inline void net_pkt_set_txtime(
struct net_pkt *pkt,
uint64_t txtime)
1021#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
1022 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
1025 return pkt->detail.stat;
1028static inline int net_pkt_stats_tick_count(
struct net_pkt *pkt)
1030 return pkt->detail.count;
1033static inline void net_pkt_stats_tick_reset(
struct net_pkt *pkt)
1035 memset(&pkt->detail, 0,
sizeof(pkt->detail));
1041 if (pkt->detail.count >= NET_PKT_DETAIL_STATS_COUNT) {
1042 NET_ERR(
"Detail stats count overflow (%d >= %d)",
1043 pkt->detail.count, NET_PKT_DETAIL_STATS_COUNT);
1047 pkt->detail.stat[pkt->detail.count++] = tick;
1050#define net_pkt_set_tx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
1051#define net_pkt_set_rx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
1060static inline int net_pkt_stats_tick_count(
struct net_pkt *pkt)
1067static inline void net_pkt_stats_tick_reset(
struct net_pkt *pkt)
1072static inline void net_pkt_set_stats_tick(
struct net_pkt *pkt,
uint32_t tick)
1078#define net_pkt_set_tx_stats_tick(pkt, tick)
1079#define net_pkt_set_rx_stats_tick(pkt, tick)
1083static inline size_t net_pkt_get_len(
struct net_pkt *pkt)
1098static inline bool net_pkt_is_empty(
struct net_pkt *pkt)
1105 return &pkt->lladdr_src;
1110 return &pkt->lladdr_dst;
1113static inline void net_pkt_lladdr_swap(
struct net_pkt *pkt)
1117 net_pkt_lladdr_src(pkt)->addr = net_pkt_lladdr_dst(pkt)->addr;
1118 net_pkt_lladdr_dst(pkt)->addr =
addr;
1121static inline void net_pkt_lladdr_clear(
struct net_pkt *pkt)
1123 net_pkt_lladdr_src(pkt)->addr = NULL;
1124 net_pkt_lladdr_src(pkt)->len = 0U;
1129 return pkt->ll_proto_type;
1134 pkt->ll_proto_type =
type;
1137#if defined(CONFIG_NET_IPV4_AUTO)
1138static inline bool net_pkt_ipv4_auto(
struct net_pkt *pkt)
1140 return pkt->ipv4_auto_arp_msg;
1143static inline void net_pkt_set_ipv4_auto(
struct net_pkt *pkt,
1144 bool is_auto_arp_msg)
1146 pkt->ipv4_auto_arp_msg = is_auto_arp_msg;
1149static inline bool net_pkt_ipv4_auto(
struct net_pkt *pkt)
1156static inline void net_pkt_set_ipv4_auto(
struct net_pkt *pkt,
1157 bool is_auto_arp_msg)
1160 ARG_UNUSED(is_auto_arp_msg);
1164#if defined(CONFIG_NET_LLDP)
1165static inline bool net_pkt_is_lldp(
struct net_pkt *pkt)
1167 return pkt->lldp_pkt;
1170static inline void net_pkt_set_lldp(
struct net_pkt *pkt,
bool is_lldp)
1172 pkt->lldp_pkt = is_lldp;
1175static inline bool net_pkt_is_lldp(
struct net_pkt *pkt)
1182static inline void net_pkt_set_lldp(
struct net_pkt *pkt,
bool is_lldp)
1185 ARG_UNUSED(is_lldp);
1189#if defined(CONFIG_NET_L2_PPP)
1190static inline bool net_pkt_is_ppp(
struct net_pkt *pkt)
1192 return pkt->ppp_msg;
1195static inline void net_pkt_set_ppp(
struct net_pkt *pkt,
1198 pkt->ppp_msg = is_ppp_msg;
1201static inline bool net_pkt_is_ppp(
struct net_pkt *pkt)
1208static inline void net_pkt_set_ppp(
struct net_pkt *pkt,
1212 ARG_UNUSED(is_ppp_msg);
1216#if defined(NET_PKT_HAS_CONTROL_BLOCK)
1217static inline void *net_pkt_cb(
struct net_pkt *pkt)
1222static inline void *net_pkt_cb(
struct net_pkt *pkt)
1230#define NET_IPV6_HDR(pkt) ((struct net_ipv6_hdr *)net_pkt_ip_data(pkt))
1231#define NET_IPV4_HDR(pkt) ((struct net_ipv4_hdr *)net_pkt_ip_data(pkt))
1233static inline void net_pkt_set_src_ipv6_addr(
struct net_pkt *pkt)
1236 net_pkt_context(pkt)),
1237 (
struct in6_addr *)NET_IPV6_HDR(pkt)->src);
1240static inline void net_pkt_set_overwrite(
struct net_pkt *pkt,
bool overwrite)
1242 pkt->overwrite = overwrite;
1245static inline bool net_pkt_is_being_overwritten(
struct net_pkt *pkt)
1247 return pkt->overwrite;
1250#ifdef CONFIG_NET_PKT_FILTER
1252bool net_pkt_filter_send_ok(
struct net_pkt *pkt);
1253bool net_pkt_filter_recv_ok(
struct net_pkt *pkt);
1257static inline bool net_pkt_filter_send_ok(
struct net_pkt *pkt)
1264static inline bool net_pkt_filter_recv_ok(
struct net_pkt *pkt)
1288#define NET_PKT_SLAB_DEFINE(name, count) \
1289 K_MEM_SLAB_DEFINE(name, sizeof(struct net_pkt), count, 4)
1292#define NET_PKT_TX_SLAB_DEFINE(name, count) NET_PKT_SLAB_DEFINE(name, count)
1307#define NET_PKT_DATA_POOL_DEFINE(name, count) \
1308 NET_BUF_POOL_DEFINE(name, count, CONFIG_NET_BUF_DATA_SIZE, \
1313#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC) || \
1314 (CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG)
1315#define NET_PKT_DEBUG_ENABLED
1318#if defined(NET_PKT_DEBUG_ENABLED)
1330#define net_pkt_get_reserve_data(pool, min_len, timeout) \
1331 net_pkt_get_reserve_data_debug(pool, min_len, timeout, __func__, __LINE__)
1333struct net_buf *net_pkt_get_reserve_rx_data_debug(
size_t min_len,
1337#define net_pkt_get_reserve_rx_data(min_len, timeout) \
1338 net_pkt_get_reserve_rx_data_debug(min_len, timeout, __func__, __LINE__)
1340struct net_buf *net_pkt_get_reserve_tx_data_debug(
size_t min_len,
1344#define net_pkt_get_reserve_tx_data(min_len, timeout) \
1345 net_pkt_get_reserve_tx_data_debug(min_len, timeout, __func__, __LINE__)
1347struct net_buf *net_pkt_get_frag_debug(
struct net_pkt *pkt,
size_t min_len,
1349 const char *caller,
int line);
1350#define net_pkt_get_frag(pkt, min_len, timeout) \
1351 net_pkt_get_frag_debug(pkt, min_len, timeout, __func__, __LINE__)
1353void net_pkt_unref_debug(
struct net_pkt *pkt,
const char *caller,
int line);
1354#define net_pkt_unref(pkt) net_pkt_unref_debug(pkt, __func__, __LINE__)
1356struct net_pkt *net_pkt_ref_debug(
struct net_pkt *pkt,
const char *caller,
1358#define net_pkt_ref(pkt) net_pkt_ref_debug(pkt, __func__, __LINE__)
1361 const char *caller,
int line);
1362#define net_pkt_frag_ref(frag) net_pkt_frag_ref_debug(frag, __func__, __LINE__)
1364void net_pkt_frag_unref_debug(
struct net_buf *frag,
1365 const char *caller,
int line);
1366#define net_pkt_frag_unref(frag) \
1367 net_pkt_frag_unref_debug(frag, __func__, __LINE__)
1372 const char *caller,
int line);
1373#define net_pkt_frag_del(pkt, parent, frag) \
1374 net_pkt_frag_del_debug(pkt, parent, frag, __func__, __LINE__)
1376void net_pkt_frag_add_debug(
struct net_pkt *pkt,
struct net_buf *frag,
1377 const char *caller,
int line);
1378#define net_pkt_frag_add(pkt, frag) \
1379 net_pkt_frag_add_debug(pkt, frag, __func__, __LINE__)
1381void net_pkt_frag_insert_debug(
struct net_pkt *pkt,
struct net_buf *frag,
1382 const char *caller,
int line);
1383#define net_pkt_frag_insert(pkt, frag) \
1384 net_pkt_frag_insert_debug(pkt, frag, __func__, __LINE__)
1397#if defined(NET_PKT_DEBUG_ENABLED)
1400#define net_pkt_print_frags(pkt)
1417#if !defined(NET_PKT_DEBUG_ENABLED)
1435#if !defined(NET_PKT_DEBUG_ENABLED)
1451#if !defined(NET_PKT_DEBUG_ENABLED)
1465#if !defined(NET_PKT_DEBUG_ENABLED)
1478#if !defined(NET_PKT_DEBUG_ENABLED)
1491#if !defined(NET_PKT_DEBUG_ENABLED)
1500#if !defined(NET_PKT_DEBUG_ENABLED)
1514#if !defined(NET_PKT_DEBUG_ENABLED)
1526#if !defined(NET_PKT_DEBUG_ENABLED)
1536#if !defined(NET_PKT_DEBUG_ENABLED)
1557 struct k_mem_slab **tx,
1563#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC)
1567void net_pkt_print(
void);
1569typedef void (*net_pkt_allocs_cb_t)(
struct net_pkt *pkt,
1571 const char *func_alloc,
1573 const char *func_free,
1578void net_pkt_allocs_foreach(net_pkt_allocs_cb_t cb,
void *
user_data);
1580const char *net_pkt_slab2str(
struct k_mem_slab *slab);
1581const char *net_pkt_pool2str(
struct net_buf_pool *pool);
1584#define net_pkt_print(...)
1590#if defined(NET_PKT_DEBUG_ENABLED)
1593 const char *caller,
int line);
1594#define net_pkt_alloc(_timeout) \
1595 net_pkt_alloc_debug(_timeout, __func__, __LINE__)
1597struct net_pkt *net_pkt_alloc_from_slab_debug(
struct k_mem_slab *
slab,
1599 const char *caller,
int line);
1600#define net_pkt_alloc_from_slab(_slab, _timeout) \
1601 net_pkt_alloc_from_slab_debug(_slab, _timeout, __func__, __LINE__)
1604 const char *caller,
int line);
1605#define net_pkt_rx_alloc(_timeout) \
1606 net_pkt_rx_alloc_debug(_timeout, __func__, __LINE__)
1612#define net_pkt_alloc_on_iface(_iface, _timeout) \
1613 net_pkt_alloc_on_iface_debug(_iface, _timeout, __func__, __LINE__)
1619#define net_pkt_rx_alloc_on_iface(_iface, _timeout) \
1620 net_pkt_rx_alloc_on_iface_debug(_iface, _timeout, \
1623int net_pkt_alloc_buffer_debug(
struct net_pkt *pkt,
1627 const char *caller,
int line);
1628#define net_pkt_alloc_buffer(_pkt, _size, _proto, _timeout) \
1629 net_pkt_alloc_buffer_debug(_pkt, _size, _proto, _timeout, \
1639#define net_pkt_alloc_with_buffer(_iface, _size, _family, \
1641 net_pkt_alloc_with_buffer_debug(_iface, _size, _family, \
1652#define net_pkt_rx_alloc_with_buffer(_iface, _size, _family, \
1654 net_pkt_rx_alloc_with_buffer_debug(_iface, _size, _family, \
1670#if !defined(NET_PKT_DEBUG_ENABLED)
1688#if !defined(NET_PKT_DEBUG_ENABLED)
1703#if !defined(NET_PKT_DEBUG_ENABLED)
1715#if !defined(NET_PKT_DEBUG_ENABLED)
1739#if !defined(NET_PKT_DEBUG_ENABLED)
1757#if !defined(NET_PKT_DEBUG_ENABLED)
2158#if !defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2164#if defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2165#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2166 struct net_pkt_data_access _name = { \
2167 .size = sizeof(_type), \
2170#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2171 NET_PKT_DATA_ACCESS_DEFINE(_name, _type)
2174#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2175 _type _hdr_##_name; \
2176 struct net_pkt_data_access _name = { \
2177 .data = &_hdr_##_name, \
2178 .size = sizeof(_type), \
2181#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2182 struct net_pkt_data_access _name = { \
2184 .size = sizeof(_type), \
long atomic_t
Definition: atomic.h:22
#define sys_cpu_to_le32(val)
Convert 32-bit integer from host endianness to little-endian.
Definition: byteorder.h:198
#define sys_cpu_to_le16(val)
Convert 16-bit integer from host endianness to little-endian.
Definition: byteorder.h:194
#define ALWAYS_INLINE
Definition: common.h:124
ZTEST_BMEM int timeout
Definition: main.c:31
ZTEST_BMEM int count
Definition: main.c:33
VLAN specific definitions.
static ssize_t send(int sock, const void *buf, size_t len, int flags)
Definition: socket.h:738
unsigned short int sa_family_t
Definition: net_ip.h:164
#define htons(x)
Convert 16-bit value from host to network byte order.
Definition: net_ip.h:120
#define htonl(x)
Convert 32-bit value from host to network byte order.
Definition: net_ip.h:128
net_ip_protocol
Definition: net_ip.h:62
static size_t net_buf_frags_len(struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition: buf.h:2453
static struct net_if * net_context_get_iface(struct net_context *context)
Get network interface for this context.
Definition: net_context.h:643
static struct net_linkaddr * net_if_get_link_addr(struct net_if *iface)
Get an network interface's link address.
Definition: net_if.h:807
static const struct in6_addr * net_if_ipv6_select_src_addr(struct net_if *iface, const struct in6_addr *dst)
Get a IPv6 source address that should be used when sending network data to destination.
Definition: net_if.h:1574
void net_pkt_frag_add(struct net_pkt *pkt, struct net_buf *frag)
Add a fragment to a packet at the end of its fragment list.
static int net_pkt_write_be32(struct net_pkt *pkt, uint32_t data)
Definition: net_pkt.h:2064
void net_pkt_cursor_init(struct net_pkt *pkt)
Initialize net_pkt cursor.
int net_pkt_skip(struct net_pkt *pkt, size_t length)
Skip some data from a net_pkt.
struct net_pkt * net_pkt_shallow_clone(struct net_pkt *pkt, k_timeout_t timeout)
Clone pkt and increase the refcount of its buffer.
void net_pkt_append_buffer(struct net_pkt *pkt, struct net_buf *buffer)
Append a buffer in packet.
#define net_pkt_print_frags(pkt)
Print fragment list and the fragment sizes.
Definition: net_pkt.h:1400
int net_pkt_update_length(struct net_pkt *pkt, size_t length)
Update the overall length of a packet.
int net_pkt_pull(struct net_pkt *pkt, size_t length)
Remove data from the packet at current location.
int net_pkt_copy(struct net_pkt *pkt_dst, struct net_pkt *pkt_src, size_t length)
Copy data from a packet into another one.
struct net_pkt * net_pkt_rx_alloc(k_timeout_t timeout)
Allocate an initialized net_pkt for RX.
struct net_pkt * net_pkt_ref(struct net_pkt *pkt)
Increase the packet ref count.
int net_pkt_read_be16(struct net_pkt *pkt, uint16_t *data)
Read uint16_t big endian data from a net_pkt.
struct net_pkt * net_pkt_alloc_with_buffer(struct net_if *iface, size_t size, sa_family_t family, enum net_ip_protocol proto, k_timeout_t timeout)
Allocate a network packet and buffer at once.
void net_pkt_frag_unref(struct net_buf *frag)
Decrease the packet fragment ref count.
struct net_pkt * net_pkt_rx_alloc_with_buffer(struct net_if *iface, size_t size, sa_family_t family, enum net_ip_protocol proto, k_timeout_t timeout)
struct net_pkt * net_pkt_rx_clone(struct net_pkt *pkt, k_timeout_t timeout)
Clone pkt and its buffer. The cloned packet will be allocated on the RX packet poll.
void net_pkt_trim_buffer(struct net_pkt *pkt)
Trim net_pkt buffer.
struct net_pkt * net_pkt_alloc_on_iface(struct net_if *iface, k_timeout_t timeout)
Allocate a network packet for a specific network interface.
void net_pkt_get_info(struct k_mem_slab **rx, struct k_mem_slab **tx, struct net_buf_pool **rx_data, struct net_buf_pool **tx_data)
Get information about predefined RX, TX and DATA pools.
void net_pkt_unref(struct net_pkt *pkt)
Place packet back into the available packets slab.
static int net_pkt_write_be16(struct net_pkt *pkt, uint16_t data)
Definition: net_pkt.h:2056
struct net_pkt * net_pkt_alloc(k_timeout_t timeout)
Allocate an initialized net_pkt.
int net_pkt_read(struct net_pkt *pkt, void *data, size_t length)
Read some data from a net_pkt.
struct net_buf * net_pkt_frag_del(struct net_pkt *pkt, struct net_buf *parent, struct net_buf *frag)
Delete existing fragment from a packet.
int net_pkt_set_data(struct net_pkt *pkt, struct net_pkt_data_access *access)
Set contiguous data into a network packet.
void * net_pkt_get_data(struct net_pkt *pkt, struct net_pkt_data_access *access)
Get data from a network packet in a contiguous way.
static int net_pkt_write_u8(struct net_pkt *pkt, uint8_t data)
Definition: net_pkt.h:2050
size_t net_pkt_available_payload_buffer(struct net_pkt *pkt, enum net_ip_protocol proto)
Get available buffer space for payload from a pkt.
int net_pkt_read_le16(struct net_pkt *pkt, uint16_t *data)
Read uint16_t little endian data from a net_pkt.
int net_pkt_read_be32(struct net_pkt *pkt, uint32_t *data)
Read uint32_t big endian data from a net_pkt.
struct net_pkt * net_pkt_rx_alloc_on_iface(struct net_if *iface, k_timeout_t timeout)
int net_pkt_remove_tail(struct net_pkt *pkt, size_t length)
Remove length bytes from tail of packet.
struct net_buf * net_pkt_get_reserve_tx_data(size_t min_len, k_timeout_t timeout)
Get TX DATA buffer from pool. Normally you should use net_pkt_get_frag() instead.
static void * net_pkt_cursor_get_pos(struct net_pkt *pkt)
Returns current position of the cursor.
Definition: net_pkt.h:1878
void net_pkt_frag_insert(struct net_pkt *pkt, struct net_buf *frag)
Insert a fragment to a packet at the beginning of its fragment list.
int net_pkt_memset(struct net_pkt *pkt, int byte, size_t length)
Memset some data in a net_pkt.
static void net_pkt_cursor_backup(struct net_pkt *pkt, struct net_pkt_cursor *backup)
Backup net_pkt cursor.
Definition: net_pkt.h:1851
void net_pkt_compact(struct net_pkt *pkt)
Compact the fragment list of a packet.
static int net_pkt_acknowledge_data(struct net_pkt *pkt, struct net_pkt_data_access *access)
Definition: net_pkt.h:2225
static int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
Definition: net_pkt.h:2080
static void net_pkt_cursor_restore(struct net_pkt *pkt, struct net_pkt_cursor *backup)
Restore net_pkt cursor from a backup.
Definition: net_pkt.h:1864
uint16_t net_pkt_get_current_offset(struct net_pkt *pkt)
Get the actual offset in the packet from its cursor.
size_t net_pkt_remaining_data(struct net_pkt *pkt)
Get the amount of data which can be read from current cursor position.
int net_pkt_alloc_buffer(struct net_pkt *pkt, size_t size, enum net_ip_protocol proto, k_timeout_t timeout)
Allocate buffer for a net_pkt.
int net_pkt_write(struct net_pkt *pkt, const void *data, size_t length)
Write data into a net_pkt.
struct net_buf * net_pkt_frag_ref(struct net_buf *frag)
Increase the packet fragment ref count.
size_t net_pkt_available_buffer(struct net_pkt *pkt)
Get available buffer space from a pkt.
struct net_pkt * net_pkt_clone(struct net_pkt *pkt, k_timeout_t timeout)
Clone pkt and its buffer. The cloned packet will be allocated on the same pool as the original one.
struct net_pkt * net_pkt_alloc_from_slab(struct k_mem_slab *slab, k_timeout_t timeout)
Allocate an initialized net_pkt from a specific slab.
static int net_pkt_write_le32(struct net_pkt *pkt, uint32_t data)
Definition: net_pkt.h:2072
struct net_buf * net_pkt_get_reserve_rx_data(size_t min_len, k_timeout_t timeout)
Get RX DATA buffer from pool. Normally you should use net_pkt_get_frag() instead.
bool net_pkt_is_contiguous(struct net_pkt *pkt, size_t size)
Check if a data size could fit contiguously.
static int net_pkt_read_u8(struct net_pkt *pkt, uint8_t *data)
Definition: net_pkt.h:1987
struct net_buf * net_pkt_get_frag(struct net_pkt *pkt, size_t min_len, k_timeout_t timeout)
Get a data fragment that might be from user specific buffer pool or from global DATA pool.
size_t net_pkt_get_contiguous_len(struct net_pkt *pkt)
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:121
static uint16_t net_eth_vlan_set_vid(uint16_t tci, uint16_t vid)
Set VLAN identifier to TCI.
Definition: ethernet_vlan.h:76
static uint8_t net_eth_vlan_get_dei(uint16_t tci)
Get Drop Eligible Indicator from TCI.
Definition: ethernet_vlan.h:51
#define NET_VLAN_TAG_UNSPEC
Definition: ethernet_vlan.h:30
static uint16_t net_eth_vlan_set_dei(uint16_t tci, bool dei)
Set Drop Eligible Indicator to TCI.
Definition: ethernet_vlan.h:89
static uint16_t net_eth_vlan_get_vid(uint16_t tci)
Get VLAN identifier from TCI.
Definition: ethernet_vlan.h:39
static uint16_t net_eth_vlan_set_pcp(uint16_t tci, uint8_t pcp)
Set Priority Code Point to TCI.
Definition: ethernet_vlan.h:102
static uint8_t net_eth_vlan_get_pcp(uint16_t tci)
Get Priority Code Point from TCI.
Definition: ethernet_vlan.h:63
Packet data common to all IEEE 802.15.4 L2 layers.
Network context definitions.
Network core definitions.
Public API for network interface.
IPv6 and IPv4 definitions.
Public API for network link address.
flags
Definition: parser.h:96
Public functions for the Precision Time Protocol time specification.
struct _snode sys_snode_t
Definition: slist.h:33
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INTPTR_TYPE__ intptr_t
Definition: stdint.h:104
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
void * memset(void *buf, int c, size_t n)
Kernel timeout type.
Definition: sys_clock.h:65
Network buffer pool representation.
Definition: buf.h:970
Network buffer representation.
Definition: buf.h:905
uint8_t * data
Definition: buf.h:931
uint16_t len
Definition: buf.h:934
Definition: net_context.h:201
Network Interface structure.
Definition: net_if.h:510
Hardware link address structure.
Definition: net_linkaddr.h:67
uint8_t * addr
Definition: net_linkaddr.h:69
uint8_t type
Definition: net_linkaddr.h:75
uint8_t * pos
Definition: net_pkt.h:53
struct net_buf * buf
Definition: net_pkt.h:51
Definition: net_pkt.h:2157
const size_t size
Definition: net_pkt.h:2161
void * data
Definition: net_pkt.h:2159
Network packet.
Definition: net_pkt.h:62
struct net_buf * frags
Definition: net_pkt.h:74
struct net_context * context
Definition: net_pkt.h:82
struct net_pkt_cursor cursor
Definition: net_pkt.h:79
struct net_if * iface
Definition: net_pkt.h:85
intptr_t fifo
Definition: net_pkt.h:67
struct net_buf * buffer
Definition: net_pkt.h:75
struct k_mem_slab * slab
Definition: net_pkt.h:70
Precision Time Protocol Timestamp format.
Definition: ptp_time.h:39
uint32_t nanosecond
Definition: ptp_time.h:57
uint64_t second
Definition: ptp_time.h:53
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static ZTEST_BMEM char buffer[8]
Definition: test_mbox_api.c:551
static const char * tag(void)
Definition: main.c:27
static const intptr_t user_data[5]
Definition: main.c:588