16#ifndef ZEPHYR_INCLUDE_NET_NET_PKT_H_
17#define ZEPHYR_INCLUDE_NET_NET_PKT_H_
86#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
90#if defined(CONFIG_NET_PKT_TIMESTAMP)
95#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
100#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
101 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
116#if defined(CONFIG_NET_PKT_TXTIME)
128#if defined(CONFIG_NET_TCP)
175#if defined(CONFIG_NET_TCP)
205#if defined(CONFIG_NET_IPV4)
208#if defined(CONFIG_NET_IPV6)
218#if defined(CONFIG_NET_VLAN)
227#if defined(CONFIG_NET_IPV6)
235#if defined(CONFIG_NET_IPV6_FRAGMENT)
245#if defined(CONFIG_IEEE802154)
249 uint8_t ieee802154_ack_fpb : 1;
250 uint8_t ieee802154_frame_secured : 1;
254 uint8_t ieee802154_mac_hdr_rdy : 1;
259#if defined(CONFIG_IEEE802154_2015)
261 uint8_t ieee802154_ack_seb : 1;
282static inline void net_pkt_set_context(
struct net_pkt *pkt,
288static inline struct net_if *net_pkt_iface(
struct net_pkt *pkt)
293static inline void net_pkt_set_iface(
struct net_pkt *pkt,
struct net_if *iface)
307static inline struct net_if *net_pkt_orig_iface(
struct net_pkt *pkt)
309#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
310 return pkt->orig_iface;
316static inline void net_pkt_set_orig_iface(
struct net_pkt *pkt,
319#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
320 pkt->orig_iface = iface;
329static inline void net_pkt_set_family(
struct net_pkt *pkt,
uint8_t family)
331 pkt->family = family;
334static inline bool net_pkt_is_ptp(
struct net_pkt *pkt)
336 return !!(pkt->ptp_pkt);
339static inline void net_pkt_set_ptp(
struct net_pkt *pkt,
bool is_ptp)
341 pkt->ptp_pkt = is_ptp;
344static inline bool net_pkt_is_captured(
struct net_pkt *pkt)
346 return !!(pkt->captured);
349static inline void net_pkt_set_captured(
struct net_pkt *pkt,
bool is_captured)
351 pkt->captured = is_captured;
354static inline bool net_pkt_is_l2_bridged(
struct net_pkt *pkt)
356 return IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE) ? !!(pkt->l2_bridged) : 0;
359static inline void net_pkt_set_l2_bridged(
struct net_pkt *pkt,
bool is_l2_bridged)
362 pkt->l2_bridged = is_l2_bridged;
366static inline bool net_pkt_is_l2_processed(
struct net_pkt *pkt)
368 return !!(pkt->l2_processed);
371static inline void net_pkt_set_l2_processed(
struct net_pkt *pkt,
372 bool is_l2_processed)
374 pkt->l2_processed = is_l2_processed;
379 return pkt->ip_hdr_len;
382static inline void net_pkt_set_ip_hdr_len(
struct net_pkt *pkt,
uint8_t len)
384 pkt->ip_hdr_len = len;
389 return pkt->sent_or_eof;
392static inline void net_pkt_set_sent(
struct net_pkt *pkt,
bool sent)
394 pkt->sent_or_eof = sent;
399 return pkt->pkt_queued;
402static inline void net_pkt_set_queued(
struct net_pkt *pkt,
bool send)
404 pkt->pkt_queued =
send;
409#if defined(CONFIG_NET_TCP)
410 return pkt->tcp_first_msg;
416static inline void net_pkt_set_tcp_1st_msg(
struct net_pkt *pkt,
bool is_1st)
418#if defined(CONFIG_NET_TCP)
419 pkt->tcp_first_msg = is_1st;
426#if defined(CONFIG_NET_SOCKETS)
429 return pkt->sent_or_eof;
432static inline void net_pkt_set_eof(
struct net_pkt *pkt,
bool eof)
434 pkt->sent_or_eof = eof;
438#if defined(CONFIG_NET_ROUTE)
439static inline bool net_pkt_forwarding(
struct net_pkt *pkt)
441 return pkt->forwarding;
444static inline void net_pkt_set_forwarding(
struct net_pkt *pkt,
bool forward)
446 pkt->forwarding = forward;
449static inline bool net_pkt_forwarding(
struct net_pkt *pkt)
455#if defined(CONFIG_NET_IPV4)
458 return pkt->ipv4_ttl;
461static inline void net_pkt_set_ipv4_ttl(
struct net_pkt *pkt,
469 return pkt->ipv4_opts_len;
472static inline void net_pkt_set_ipv4_opts_len(
struct net_pkt *pkt,
475 pkt->ipv4_opts_len = opts_len;
485static inline void net_pkt_set_ipv4_ttl(
struct net_pkt *pkt,
498static inline void net_pkt_set_ipv4_opts_len(
struct net_pkt *pkt,
502 ARG_UNUSED(opts_len);
506#if defined(CONFIG_NET_IPV6)
507static inline uint8_t net_pkt_ipv6_ext_opt_len(
struct net_pkt *pkt)
509 return pkt->ipv6_ext_opt_len;
512static inline void net_pkt_set_ipv6_ext_opt_len(
struct net_pkt *pkt,
515 pkt->ipv6_ext_opt_len = len;
520 return pkt->ipv6_next_hdr;
523static inline void net_pkt_set_ipv6_next_hdr(
struct net_pkt *pkt,
526 pkt->ipv6_next_hdr = next_hdr;
531 return pkt->ipv6_ext_len;
534static inline void net_pkt_set_ipv6_ext_len(
struct net_pkt *pkt,
uint16_t len)
536 pkt->ipv6_ext_len = len;
541 return pkt->ipv6_prev_hdr_start;
544static inline void net_pkt_set_ipv6_hdr_prev(
struct net_pkt *pkt,
547 pkt->ipv6_prev_hdr_start = offset;
552 return pkt->ipv6_hop_limit;
555static inline void net_pkt_set_ipv6_hop_limit(
struct net_pkt *pkt,
558 pkt->ipv6_hop_limit = hop_limit;
561static inline uint8_t net_pkt_ipv6_ext_opt_len(
struct net_pkt *pkt)
568static inline void net_pkt_set_ipv6_ext_opt_len(
struct net_pkt *pkt,
582static inline void net_pkt_set_ipv6_next_hdr(
struct net_pkt *pkt,
586 ARG_UNUSED(next_hdr);
596static inline void net_pkt_set_ipv6_ext_len(
struct net_pkt *pkt,
uint16_t len)
609static inline void net_pkt_set_ipv6_hdr_prev(
struct net_pkt *pkt,
623static inline void net_pkt_set_ipv6_hop_limit(
struct net_pkt *pkt,
627 ARG_UNUSED(hop_limit);
633#if defined(CONFIG_NET_IPV6)
634 return pkt->ipv6_ext_len;
635#elif defined(CONFIG_NET_IPV4)
636 return pkt->ipv4_opts_len;
644#if defined(CONFIG_NET_IPV6_FRAGMENT)
647 return pkt->ipv6_frag_hdr_start;
650static inline void net_pkt_set_ipv6_fragment_start(
struct net_pkt *pkt,
653 pkt->ipv6_frag_hdr_start = start;
656static inline uint16_t net_pkt_ipv6_fragment_offset(
struct net_pkt *pkt)
658 return pkt->ipv6_fragment_flags & NET_IPV6_FRAGH_OFFSET_MASK;
660static inline bool net_pkt_ipv6_fragment_more(
struct net_pkt *pkt)
662 return (pkt->ipv6_fragment_flags & 0x01) != 0;
665static inline void net_pkt_set_ipv6_fragment_flags(
struct net_pkt *pkt,
668 pkt->ipv6_fragment_flags =
flags;
673 return pkt->ipv6_fragment_id;
676static inline void net_pkt_set_ipv6_fragment_id(
struct net_pkt *pkt,
679 pkt->ipv6_fragment_id = id;
689static inline void net_pkt_set_ipv6_fragment_start(
struct net_pkt *pkt,
696static inline uint16_t net_pkt_ipv6_fragment_offset(
struct net_pkt *pkt)
703static inline bool net_pkt_ipv6_fragment_more(
struct net_pkt *pkt)
710static inline void net_pkt_set_ipv6_fragment_flags(
struct net_pkt *pkt,
724static inline void net_pkt_set_ipv6_fragment_id(
struct net_pkt *pkt,
734 return pkt->priority;
737static inline void net_pkt_set_priority(
struct net_pkt *pkt,
740 pkt->priority = priority;
743#if defined(CONFIG_NET_VLAN)
759static inline void net_pkt_set_vlan_priority(
struct net_pkt *pkt,
765static inline bool net_pkt_vlan_dei(
struct net_pkt *pkt)
770static inline void net_pkt_set_vlan_dei(
struct net_pkt *pkt,
bool dei)
775static inline void net_pkt_set_vlan_tci(
struct net_pkt *pkt,
uint16_t tci)
782 return pkt->vlan_tci;
802static inline bool net_pkt_vlan_dei(
struct net_pkt *pkt)
807static inline void net_pkt_set_vlan_dei(
struct net_pkt *pkt,
bool dei)
818static inline void net_pkt_set_vlan_tci(
struct net_pkt *pkt,
uint16_t tci)
825#if defined(CONFIG_NET_PKT_TIMESTAMP)
828 return &pkt->timestamp;
831static inline void net_pkt_set_timestamp(
struct net_pkt *pkt,
834 pkt->timestamp.second = timestamp->
second;
835 pkt->timestamp.nanosecond = timestamp->
nanosecond;
845static inline void net_pkt_set_timestamp(
struct net_pkt *pkt,
849 ARG_UNUSED(timestamp);
853#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
856 return pkt->create_time;
859static inline void net_pkt_set_create_time(
struct net_pkt *pkt,
862 pkt->create_time = create_time;
872static inline void net_pkt_set_create_time(
struct net_pkt *pkt,
876 ARG_UNUSED(create_time);
880#if defined(CONFIG_NET_PKT_TXTIME)
886static inline void net_pkt_set_txtime(
struct net_pkt *pkt,
uint64_t txtime)
888 pkt->txtime = txtime;
898static inline void net_pkt_set_txtime(
struct net_pkt *pkt,
uint64_t txtime)
905#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
906 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
909 return pkt->detail.stat;
912static inline int net_pkt_stats_tick_count(
struct net_pkt *pkt)
914 return pkt->detail.count;
917static inline void net_pkt_stats_tick_reset(
struct net_pkt *pkt)
919 memset(&pkt->detail, 0,
sizeof(pkt->detail));
925 if (pkt->detail.count >= NET_PKT_DETAIL_STATS_COUNT) {
926 NET_ERR(
"Detail stats count overflow (%d >= %d)",
927 pkt->detail.count, NET_PKT_DETAIL_STATS_COUNT);
931 pkt->detail.stat[pkt->detail.count++] = tick;
934#define net_pkt_set_tx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
935#define net_pkt_set_rx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
944static inline int net_pkt_stats_tick_count(
struct net_pkt *pkt)
951static inline void net_pkt_stats_tick_reset(
struct net_pkt *pkt)
956static inline void net_pkt_set_stats_tick(
struct net_pkt *pkt,
uint32_t tick)
962#define net_pkt_set_tx_stats_tick(pkt, tick)
963#define net_pkt_set_rx_stats_tick(pkt, tick)
967static inline size_t net_pkt_get_len(
struct net_pkt *pkt)
982static inline bool net_pkt_is_empty(
struct net_pkt *pkt)
989 return &pkt->lladdr_src;
994 return &pkt->lladdr_dst;
997static inline void net_pkt_lladdr_swap(
struct net_pkt *pkt)
1001 net_pkt_lladdr_src(pkt)->addr = net_pkt_lladdr_dst(pkt)->addr;
1002 net_pkt_lladdr_dst(pkt)->addr =
addr;
1005static inline void net_pkt_lladdr_clear(
struct net_pkt *pkt)
1007 net_pkt_lladdr_src(pkt)->addr = NULL;
1008 net_pkt_lladdr_src(pkt)->len = 0U;
1011#if defined(CONFIG_IEEE802154) || defined(CONFIG_IEEE802154_RAW_MODE)
1012static inline uint8_t net_pkt_ieee802154_rssi(
struct net_pkt *pkt)
1014 return pkt->ieee802154_rssi;
1017static inline void net_pkt_set_ieee802154_rssi(
struct net_pkt *pkt,
1020 pkt->ieee802154_rssi = rssi;
1025 return pkt->ieee802154_lqi;
1028static inline void net_pkt_set_ieee802154_lqi(
struct net_pkt *pkt,
1031 pkt->ieee802154_lqi = lqi;
1034static inline bool net_pkt_ieee802154_arb(
struct net_pkt *pkt)
1036 return pkt->ieee802154_arb;
1039static inline void net_pkt_set_ieee802154_arb(
struct net_pkt *pkt,
bool arb)
1041 pkt->ieee802154_arb = arb;
1044static inline bool net_pkt_ieee802154_ack_fpb(
struct net_pkt *pkt)
1046 return pkt->ieee802154_ack_fpb;
1049static inline void net_pkt_set_ieee802154_ack_fpb(
struct net_pkt *pkt,
1052 pkt->ieee802154_ack_fpb = fpb;
1055static inline bool net_pkt_ieee802154_frame_secured(
struct net_pkt *pkt)
1057 return pkt->ieee802154_frame_secured;
1060static inline void net_pkt_set_ieee802154_frame_secured(
struct net_pkt *pkt,
1063 pkt->ieee802154_frame_secured = secured;
1066static inline bool net_pkt_ieee802154_mac_hdr_rdy(
struct net_pkt *pkt)
1068 return pkt->ieee802154_mac_hdr_rdy;
1071static inline void net_pkt_set_ieee802154_mac_hdr_rdy(
struct net_pkt *pkt,
1074 pkt->ieee802154_mac_hdr_rdy = rdy;
1077#if defined(CONFIG_IEEE802154_2015)
1078static inline bool net_pkt_ieee802154_fv2015(
struct net_pkt *pkt)
1080 return pkt->ieee802154_fv2015;
1083static inline void net_pkt_set_ieee802154_fv2015(
struct net_pkt *pkt,
bool fv2015)
1085 pkt->ieee802154_fv2015 = fv2015;
1088static inline bool net_pkt_ieee802154_ack_seb(
struct net_pkt *pkt)
1090 return pkt->ieee802154_ack_seb;
1093static inline void net_pkt_set_ieee802154_ack_seb(
struct net_pkt *pkt,
bool seb)
1095 pkt->ieee802154_ack_seb = seb;
1100 return pkt->ieee802154_ack_fc;
1103static inline void net_pkt_set_ieee802154_ack_fc(
struct net_pkt *pkt,
1106 pkt->ieee802154_ack_fc = fc;
1109static inline uint8_t net_pkt_ieee802154_ack_keyid(
struct net_pkt *pkt)
1111 return pkt->ieee802154_ack_keyid;
1114static inline void net_pkt_set_ieee802154_ack_keyid(
struct net_pkt *pkt,
1117 pkt->ieee802154_ack_keyid = keyid;
1122#if defined(CONFIG_NET_IPV4_AUTO)
1123static inline bool net_pkt_ipv4_auto(
struct net_pkt *pkt)
1125 return pkt->ipv4_auto_arp_msg;
1128static inline void net_pkt_set_ipv4_auto(
struct net_pkt *pkt,
1129 bool is_auto_arp_msg)
1131 pkt->ipv4_auto_arp_msg = is_auto_arp_msg;
1134static inline bool net_pkt_ipv4_auto(
struct net_pkt *pkt)
1141static inline void net_pkt_set_ipv4_auto(
struct net_pkt *pkt,
1142 bool is_auto_arp_msg)
1145 ARG_UNUSED(is_auto_arp_msg);
1149#if defined(CONFIG_NET_LLDP)
1150static inline bool net_pkt_is_lldp(
struct net_pkt *pkt)
1152 return pkt->lldp_pkt;
1155static inline void net_pkt_set_lldp(
struct net_pkt *pkt,
bool is_lldp)
1157 pkt->lldp_pkt = is_lldp;
1160static inline bool net_pkt_is_lldp(
struct net_pkt *pkt)
1167static inline void net_pkt_set_lldp(
struct net_pkt *pkt,
bool is_lldp)
1170 ARG_UNUSED(is_lldp);
1174#if defined(CONFIG_NET_PPP)
1175static inline bool net_pkt_is_ppp(
struct net_pkt *pkt)
1177 return pkt->ppp_msg;
1180static inline void net_pkt_set_ppp(
struct net_pkt *pkt,
1183 pkt->ppp_msg = is_ppp_msg;
1186static inline bool net_pkt_is_ppp(
struct net_pkt *pkt)
1193static inline void net_pkt_set_ppp(
struct net_pkt *pkt,
1197 ARG_UNUSED(is_ppp_msg);
1201#define NET_IPV6_HDR(pkt) ((struct net_ipv6_hdr *)net_pkt_ip_data(pkt))
1202#define NET_IPV4_HDR(pkt) ((struct net_ipv4_hdr *)net_pkt_ip_data(pkt))
1204static inline void net_pkt_set_src_ipv6_addr(
struct net_pkt *pkt)
1207 net_pkt_context(pkt)),
1208 (
struct in6_addr *)NET_IPV6_HDR(pkt)->src);
1211static inline void net_pkt_set_overwrite(
struct net_pkt *pkt,
bool overwrite)
1213 pkt->overwrite = overwrite;
1216static inline bool net_pkt_is_being_overwritten(
struct net_pkt *pkt)
1218 return pkt->overwrite;
1221#ifdef CONFIG_NET_PKT_FILTER
1223bool net_pkt_filter_send_ok(
struct net_pkt *pkt);
1224bool net_pkt_filter_recv_ok(
struct net_pkt *pkt);
1228static inline bool net_pkt_filter_send_ok(
struct net_pkt *pkt)
1235static inline bool net_pkt_filter_recv_ok(
struct net_pkt *pkt)
1259#define NET_PKT_SLAB_DEFINE(name, count) \
1260 K_MEM_SLAB_DEFINE(name, sizeof(struct net_pkt), count, 4)
1263#define NET_PKT_TX_SLAB_DEFINE(name, count) NET_PKT_SLAB_DEFINE(name, count)
1278#define NET_PKT_DATA_POOL_DEFINE(name, count) \
1279 NET_BUF_POOL_DEFINE(name, count, CONFIG_NET_BUF_DATA_SIZE, \
1284#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC) || \
1285 (CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG)
1286#define NET_PKT_DEBUG_ENABLED
1289#if defined(NET_PKT_DEBUG_ENABLED)
1300#define net_pkt_get_reserve_data(pool, timeout) \
1301 net_pkt_get_reserve_data_debug(pool, timeout, __func__, __LINE__)
1306#define net_pkt_get_reserve_rx_data(timeout) \
1307 net_pkt_get_reserve_rx_data_debug(timeout, __func__, __LINE__)
1312#define net_pkt_get_reserve_tx_data(timeout) \
1313 net_pkt_get_reserve_tx_data_debug(timeout, __func__, __LINE__)
1317 const char *caller,
int line);
1318#define net_pkt_get_frag(pkt, timeout) \
1319 net_pkt_get_frag_debug(pkt, timeout, __func__, __LINE__)
1321void net_pkt_unref_debug(
struct net_pkt *pkt,
const char *caller,
int line);
1322#define net_pkt_unref(pkt) net_pkt_unref_debug(pkt, __func__, __LINE__)
1324struct net_pkt *net_pkt_ref_debug(
struct net_pkt *pkt,
const char *caller,
1326#define net_pkt_ref(pkt) net_pkt_ref_debug(pkt, __func__, __LINE__)
1329 const char *caller,
int line);
1330#define net_pkt_frag_ref(frag) net_pkt_frag_ref_debug(frag, __func__, __LINE__)
1332void net_pkt_frag_unref_debug(
struct net_buf *frag,
1333 const char *caller,
int line);
1334#define net_pkt_frag_unref(frag) \
1335 net_pkt_frag_unref_debug(frag, __func__, __LINE__)
1340 const char *caller,
int line);
1341#define net_pkt_frag_del(pkt, parent, frag) \
1342 net_pkt_frag_del_debug(pkt, parent, frag, __func__, __LINE__)
1344void net_pkt_frag_add_debug(
struct net_pkt *pkt,
struct net_buf *frag,
1345 const char *caller,
int line);
1346#define net_pkt_frag_add(pkt, frag) \
1347 net_pkt_frag_add_debug(pkt, frag, __func__, __LINE__)
1349void net_pkt_frag_insert_debug(
struct net_pkt *pkt,
struct net_buf *frag,
1350 const char *caller,
int line);
1351#define net_pkt_frag_insert(pkt, frag) \
1352 net_pkt_frag_insert_debug(pkt, frag, __func__, __LINE__)
1365#if defined(NET_PKT_DEBUG_ENABLED)
1368#define net_pkt_print_frags(pkt)
1384#if !defined(NET_PKT_DEBUG_ENABLED)
1401#if !defined(NET_PKT_DEBUG_ENABLED)
1416#if !defined(NET_PKT_DEBUG_ENABLED)
1429#if !defined(NET_PKT_DEBUG_ENABLED)
1442#if !defined(NET_PKT_DEBUG_ENABLED)
1455#if !defined(NET_PKT_DEBUG_ENABLED)
1464#if !defined(NET_PKT_DEBUG_ENABLED)
1478#if !defined(NET_PKT_DEBUG_ENABLED)
1490#if !defined(NET_PKT_DEBUG_ENABLED)
1500#if !defined(NET_PKT_DEBUG_ENABLED)
1523 struct k_mem_slab **tx,
1529#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC)
1533void net_pkt_print(
void);
1535typedef void (*net_pkt_allocs_cb_t)(
struct net_pkt *pkt,
1537 const char *func_alloc,
1539 const char *func_free,
1544void net_pkt_allocs_foreach(net_pkt_allocs_cb_t cb,
void *
user_data);
1546const char *net_pkt_slab2str(
struct k_mem_slab *slab);
1547const char *net_pkt_pool2str(
struct net_buf_pool *pool);
1550#define net_pkt_print(...)
1556#if defined(NET_PKT_DEBUG_ENABLED)
1559 const char *caller,
int line);
1560#define net_pkt_alloc(_timeout) \
1561 net_pkt_alloc_debug(_timeout, __func__, __LINE__)
1563struct net_pkt *net_pkt_alloc_from_slab_debug(
struct k_mem_slab *
slab,
1565 const char *caller,
int line);
1566#define net_pkt_alloc_from_slab(_slab, _timeout) \
1567 net_pkt_alloc_from_slab_debug(_slab, _timeout, __func__, __LINE__)
1570 const char *caller,
int line);
1571#define net_pkt_rx_alloc(_timeout) \
1572 net_pkt_rx_alloc_debug(_timeout, __func__, __LINE__)
1578#define net_pkt_alloc_on_iface(_iface, _timeout) \
1579 net_pkt_alloc_on_iface_debug(_iface, _timeout, __func__, __LINE__)
1585#define net_pkt_rx_alloc_on_iface(_iface, _timeout) \
1586 net_pkt_rx_alloc_on_iface_debug(_iface, _timeout, \
1589int net_pkt_alloc_buffer_debug(
struct net_pkt *pkt,
1593 const char *caller,
int line);
1594#define net_pkt_alloc_buffer(_pkt, _size, _proto, _timeout) \
1595 net_pkt_alloc_buffer_debug(_pkt, _size, _proto, _timeout, \
1605#define net_pkt_alloc_with_buffer(_iface, _size, _family, \
1607 net_pkt_alloc_with_buffer_debug(_iface, _size, _family, \
1618#define net_pkt_rx_alloc_with_buffer(_iface, _size, _family, \
1620 net_pkt_rx_alloc_with_buffer_debug(_iface, _size, _family, \
1636#if !defined(NET_PKT_DEBUG_ENABLED)
1654#if !defined(NET_PKT_DEBUG_ENABLED)
1669#if !defined(NET_PKT_DEBUG_ENABLED)
1681#if !defined(NET_PKT_DEBUG_ENABLED)
1705#if !defined(NET_PKT_DEBUG_ENABLED)
1723#if !defined(NET_PKT_DEBUG_ENABLED)
2124#if !defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2130#if defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2131#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2132 struct net_pkt_data_access _name = { \
2133 .size = sizeof(_type), \
2136#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2137 NET_PKT_DATA_ACCESS_DEFINE(_name, _type)
2140#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2141 _type _hdr_##_name; \
2142 struct net_pkt_data_access _name = { \
2143 .data = &_hdr_##_name, \
2144 .size = sizeof(_type), \
2147#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2148 struct net_pkt_data_access _name = { \
2150 .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:177
#define sys_cpu_to_le16(val)
Convert 16-bit integer from host endianness to little-endian.
Definition: byteorder.h:173
#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.
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 ZTEST_BMEM char buffer[8]
Test mailbox enhance capabilities.
Definition: test_mbox_api.c:566
static size_t net_buf_frags_len(struct net_buf *buf)
Calculate amount of bytes stored in fragments.
Definition: buf.h:2465
static struct net_if * net_context_get_iface(struct net_context *context)
Get network interface for this context.
Definition: net_context.h:639
static struct net_linkaddr * net_if_get_link_addr(struct net_if *iface)
Get an network interface's link address.
Definition: net_if.h:725
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:1488
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:2030
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:1368
int net_pkt_update_length(struct net_pkt *pkt, size_t length)
Update the overall length of a packet.
struct net_buf * net_pkt_get_reserve_rx_data(k_timeout_t timeout)
Get RX DATA buffer from pool. Normally you should use net_pkt_get_frag() instead.
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.
bool net_pkt_compact(struct net_pkt *pkt)
Compact the fragment list of a packet.
static int net_pkt_write_be16(struct net_pkt *pkt, uint16_t data)
Definition: net_pkt.h:2022
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:2016
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.
static void * net_pkt_cursor_get_pos(struct net_pkt *pkt)
Returns current position of the cursor.
Definition: net_pkt.h:1844
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:1817
static int net_pkt_acknowledge_data(struct net_pkt *pkt, struct net_pkt_data_access *access)
Definition: net_pkt.h:2191
static int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
Definition: net_pkt.h:2046
struct net_buf * net_pkt_get_reserve_tx_data(k_timeout_t timeout)
Get TX DATA buffer from pool. Normally you should use net_pkt_get_frag() instead.
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:1830
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.
struct net_buf * net_pkt_get_frag(struct net_pkt *pkt, k_timeout_t timeout)
Get a data fragment that might be from user specific buffer pool or from global DATA pool.
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:2038
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:1953
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:101
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
flags
Definition: http_parser.h:131
Network context definitions.
Network core definitions.
Public API for network interface.
IPv6 and IPv4 definitions.
Public API for network link address.
static ssize_t send(int sock, const void *buf, size_t len, int flags)
Definition: socket.h:61
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:982
Network buffer representation.
Definition: buf.h:915
uint8_t * data
Definition: buf.h:943
uint16_t len
Definition: buf.h:946
Definition: net_context.h:201
Network Interface structure.
Definition: net_if.h:478
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:50
struct net_buf * buf
Definition: net_pkt.h:48
Definition: net_pkt.h:2123
const size_t size
Definition: net_pkt.h:2127
void * data
Definition: net_pkt.h:2125
Network packet.
Definition: net_pkt.h:59
struct net_buf * frags
Definition: net_pkt.h:71
struct net_context * context
Definition: net_pkt.h:79
struct net_pkt_cursor cursor
Definition: net_pkt.h:76
struct net_if * iface
Definition: net_pkt.h:82
intptr_t fifo
Definition: net_pkt.h:64
struct net_buf * buffer
Definition: net_pkt.h:72
struct k_mem_slab * slab
Definition: net_pkt.h:67
Precision Time Protocol Timestamp format.
Definition: ptp_time.h:39
uint32_t nanosecond
Definition: ptp_time.h:59
uint64_t second
Definition: ptp_time.h:55
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static const char * tag(void)
Definition: main.c:27
static const intptr_t user_data[5]
Definition: main.c:590