16#ifndef ZEPHYR_INCLUDE_NET_NET_PKT_H_
17#define ZEPHYR_INCLUDE_NET_NET_PKT_H_
44struct canbus_net_isotp_tx_ctx;
45struct canbus_net_isotp_rx_ctx;
89#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
93#if defined(CONFIG_NET_PKT_TIMESTAMP)
98#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
103#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
104 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
119#if defined(CONFIG_NET_PKT_TXTIME)
131#if defined(CONFIG_NET_TCP)
178#if defined(CONFIG_NET_TCP)
204#if defined(CONFIG_NET_IPV4)
207#if defined(CONFIG_NET_IPV6)
217#if defined(CONFIG_NET_VLAN)
226#if defined(CONFIG_NET_IPV6)
234#if defined(CONFIG_NET_IPV6_FRAGMENT)
244#if defined(CONFIG_IEEE802154)
248 uint8_t ieee802154_ack_fpb : 1;
249 uint8_t ieee802154_frame_secured : 1;
253 uint8_t ieee802154_mac_hdr_rdy : 1;
258#if defined(CONFIG_IEEE802154_2015)
260 uint8_t ieee802154_ack_seb : 1;
265#if defined(CONFIG_NET_L2_CANBUS)
267 struct canbus_isotp_tx_ctx *canbus_tx_ctx;
268 struct canbus_isotp_rx_ctx *canbus_rx_ctx;
287static inline void net_pkt_set_context(
struct net_pkt *pkt,
293static inline struct net_if *net_pkt_iface(
struct net_pkt *pkt)
298static inline void net_pkt_set_iface(
struct net_pkt *pkt,
struct net_if *iface)
312static inline struct net_if *net_pkt_orig_iface(
struct net_pkt *pkt)
314#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
315 return pkt->orig_iface;
321static inline void net_pkt_set_orig_iface(
struct net_pkt *pkt,
324#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
325 pkt->orig_iface = iface;
334static inline void net_pkt_set_family(
struct net_pkt *pkt,
uint8_t family)
336 pkt->family = family;
339static inline bool net_pkt_is_ptp(
struct net_pkt *pkt)
341 return !!(pkt->ptp_pkt);
344static inline void net_pkt_set_ptp(
struct net_pkt *pkt,
bool is_ptp)
346 pkt->ptp_pkt = is_ptp;
349static inline bool net_pkt_is_captured(
struct net_pkt *pkt)
351 return !!(pkt->captured);
354static inline void net_pkt_set_captured(
struct net_pkt *pkt,
bool is_captured)
356 pkt->captured = is_captured;
359static inline bool net_pkt_is_l2_bridged(
struct net_pkt *pkt)
361 return IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE) ? !!(pkt->l2_bridged) : 0;
364static inline void net_pkt_set_l2_bridged(
struct net_pkt *pkt,
bool is_l2_bridged)
367 pkt->l2_bridged = is_l2_bridged;
373 return pkt->ip_hdr_len;
376static inline void net_pkt_set_ip_hdr_len(
struct net_pkt *pkt,
uint8_t len)
378 pkt->ip_hdr_len = len;
383 return pkt->sent_or_eof;
386static inline void net_pkt_set_sent(
struct net_pkt *pkt,
bool sent)
388 pkt->sent_or_eof = sent;
393 return pkt->pkt_queued;
396static inline void net_pkt_set_queued(
struct net_pkt *pkt,
bool send)
398 pkt->pkt_queued =
send;
403#if defined(CONFIG_NET_TCP)
404 return pkt->tcp_first_msg;
410static inline void net_pkt_set_tcp_1st_msg(
struct net_pkt *pkt,
bool is_1st)
412#if defined(CONFIG_NET_TCP)
413 pkt->tcp_first_msg = is_1st;
420#if defined(CONFIG_NET_SOCKETS)
423 return pkt->sent_or_eof;
426static inline void net_pkt_set_eof(
struct net_pkt *pkt,
bool eof)
428 pkt->sent_or_eof = eof;
432#if defined(CONFIG_NET_ROUTE)
433static inline bool net_pkt_forwarding(
struct net_pkt *pkt)
435 return pkt->forwarding;
438static inline void net_pkt_set_forwarding(
struct net_pkt *pkt,
bool forward)
440 pkt->forwarding = forward;
443static inline bool net_pkt_forwarding(
struct net_pkt *pkt)
449#if defined(CONFIG_NET_IPV4)
452 return pkt->ipv4_ttl;
455static inline void net_pkt_set_ipv4_ttl(
struct net_pkt *pkt,
463 return pkt->ipv4_opts_len;
466static inline void net_pkt_set_ipv4_opts_len(
struct net_pkt *pkt,
469 pkt->ipv4_opts_len = opts_len;
479static inline void net_pkt_set_ipv4_ttl(
struct net_pkt *pkt,
492static inline void net_pkt_set_ipv4_opts_len(
struct net_pkt *pkt,
496 ARG_UNUSED(opts_len);
500#if defined(CONFIG_NET_IPV6)
501static inline uint8_t net_pkt_ipv6_ext_opt_len(
struct net_pkt *pkt)
503 return pkt->ipv6_ext_opt_len;
506static inline void net_pkt_set_ipv6_ext_opt_len(
struct net_pkt *pkt,
509 pkt->ipv6_ext_opt_len = len;
514 return pkt->ipv6_next_hdr;
517static inline void net_pkt_set_ipv6_next_hdr(
struct net_pkt *pkt,
520 pkt->ipv6_next_hdr = next_hdr;
525 return pkt->ipv6_ext_len;
528static inline void net_pkt_set_ipv6_ext_len(
struct net_pkt *pkt,
uint16_t len)
530 pkt->ipv6_ext_len = len;
535 return pkt->ipv6_prev_hdr_start;
538static inline void net_pkt_set_ipv6_hdr_prev(
struct net_pkt *pkt,
541 pkt->ipv6_prev_hdr_start = offset;
546 return pkt->ipv6_hop_limit;
549static inline void net_pkt_set_ipv6_hop_limit(
struct net_pkt *pkt,
552 pkt->ipv6_hop_limit = hop_limit;
555static inline uint8_t net_pkt_ipv6_ext_opt_len(
struct net_pkt *pkt)
562static inline void net_pkt_set_ipv6_ext_opt_len(
struct net_pkt *pkt,
576static inline void net_pkt_set_ipv6_next_hdr(
struct net_pkt *pkt,
580 ARG_UNUSED(next_hdr);
590static inline void net_pkt_set_ipv6_ext_len(
struct net_pkt *pkt,
uint16_t len)
603static inline void net_pkt_set_ipv6_hdr_prev(
struct net_pkt *pkt,
617static inline void net_pkt_set_ipv6_hop_limit(
struct net_pkt *pkt,
621 ARG_UNUSED(hop_limit);
627#if defined(CONFIG_NET_IPV6)
628 return pkt->ipv6_ext_len;
629#elif defined(CONFIG_NET_IPV4)
630 return pkt->ipv4_opts_len;
638#if defined(CONFIG_NET_IPV6_FRAGMENT)
641 return pkt->ipv6_frag_hdr_start;
644static inline void net_pkt_set_ipv6_fragment_start(
struct net_pkt *pkt,
647 pkt->ipv6_frag_hdr_start = start;
650static inline uint16_t net_pkt_ipv6_fragment_offset(
struct net_pkt *pkt)
652 return pkt->ipv6_fragment_flags & NET_IPV6_FRAGH_OFFSET_MASK;
654static inline bool net_pkt_ipv6_fragment_more(
struct net_pkt *pkt)
656 return (pkt->ipv6_fragment_flags & 0x01) != 0;
659static inline void net_pkt_set_ipv6_fragment_flags(
struct net_pkt *pkt,
662 pkt->ipv6_fragment_flags =
flags;
667 return pkt->ipv6_fragment_id;
670static inline void net_pkt_set_ipv6_fragment_id(
struct net_pkt *pkt,
673 pkt->ipv6_fragment_id = id;
683static inline void net_pkt_set_ipv6_fragment_start(
struct net_pkt *pkt,
690static inline uint16_t net_pkt_ipv6_fragment_offset(
struct net_pkt *pkt)
697static inline bool net_pkt_ipv6_fragment_more(
struct net_pkt *pkt)
704static inline void net_pkt_set_ipv6_fragment_flags(
struct net_pkt *pkt,
718static inline void net_pkt_set_ipv6_fragment_id(
struct net_pkt *pkt,
728 return pkt->priority;
731static inline void net_pkt_set_priority(
struct net_pkt *pkt,
734 pkt->priority = priority;
737#if defined(CONFIG_NET_VLAN)
753static inline void net_pkt_set_vlan_priority(
struct net_pkt *pkt,
759static inline bool net_pkt_vlan_dei(
struct net_pkt *pkt)
764static inline void net_pkt_set_vlan_dei(
struct net_pkt *pkt,
bool dei)
769static inline void net_pkt_set_vlan_tci(
struct net_pkt *pkt,
uint16_t tci)
776 return pkt->vlan_tci;
796static inline bool net_pkt_vlan_dei(
struct net_pkt *pkt)
801static inline void net_pkt_set_vlan_dei(
struct net_pkt *pkt,
bool dei)
812static inline void net_pkt_set_vlan_tci(
struct net_pkt *pkt,
uint16_t tci)
819#if defined(CONFIG_NET_PKT_TIMESTAMP)
822 return &pkt->timestamp;
825static inline void net_pkt_set_timestamp(
struct net_pkt *pkt,
828 pkt->timestamp.second = timestamp->
second;
829 pkt->timestamp.nanosecond = timestamp->
nanosecond;
839static inline void net_pkt_set_timestamp(
struct net_pkt *pkt,
843 ARG_UNUSED(timestamp);
847#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
850 return pkt->create_time;
853static inline void net_pkt_set_create_time(
struct net_pkt *pkt,
856 pkt->create_time = create_time;
866static inline void net_pkt_set_create_time(
struct net_pkt *pkt,
870 ARG_UNUSED(create_time);
874#if defined(CONFIG_NET_PKT_TXTIME)
880static inline void net_pkt_set_txtime(
struct net_pkt *pkt,
uint64_t txtime)
882 pkt->txtime = txtime;
892static inline void net_pkt_set_txtime(
struct net_pkt *pkt,
uint64_t txtime)
899#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
900 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
903 return pkt->detail.stat;
906static inline int net_pkt_stats_tick_count(
struct net_pkt *pkt)
908 return pkt->detail.count;
911static inline void net_pkt_stats_tick_reset(
struct net_pkt *pkt)
913 memset(&pkt->detail, 0,
sizeof(pkt->detail));
919 if (pkt->detail.count >= NET_PKT_DETAIL_STATS_COUNT) {
920 NET_ERR(
"Detail stats count overflow (%d >= %d)",
921 pkt->detail.count, NET_PKT_DETAIL_STATS_COUNT);
925 pkt->detail.stat[pkt->detail.count++] = tick;
928#define net_pkt_set_tx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
929#define net_pkt_set_rx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
938static inline int net_pkt_stats_tick_count(
struct net_pkt *pkt)
945static inline void net_pkt_stats_tick_reset(
struct net_pkt *pkt)
950static inline void net_pkt_set_stats_tick(
struct net_pkt *pkt,
uint32_t tick)
956#define net_pkt_set_tx_stats_tick(pkt, tick)
957#define net_pkt_set_rx_stats_tick(pkt, tick)
961static inline size_t net_pkt_get_len(
struct net_pkt *pkt)
976static inline bool net_pkt_is_empty(
struct net_pkt *pkt)
983 return &pkt->lladdr_src;
988 return &pkt->lladdr_dst;
991static inline void net_pkt_lladdr_swap(
struct net_pkt *pkt)
995 net_pkt_lladdr_src(pkt)->addr = net_pkt_lladdr_dst(pkt)->addr;
996 net_pkt_lladdr_dst(pkt)->addr =
addr;
999static inline void net_pkt_lladdr_clear(
struct net_pkt *pkt)
1001 net_pkt_lladdr_src(pkt)->addr = NULL;
1002 net_pkt_lladdr_src(pkt)->len = 0U;
1005#if defined(CONFIG_IEEE802154) || defined(CONFIG_IEEE802154_RAW_MODE)
1006static inline uint8_t net_pkt_ieee802154_rssi(
struct net_pkt *pkt)
1008 return pkt->ieee802154_rssi;
1011static inline void net_pkt_set_ieee802154_rssi(
struct net_pkt *pkt,
1014 pkt->ieee802154_rssi = rssi;
1019 return pkt->ieee802154_lqi;
1022static inline void net_pkt_set_ieee802154_lqi(
struct net_pkt *pkt,
1025 pkt->ieee802154_lqi = lqi;
1028static inline bool net_pkt_ieee802154_arb(
struct net_pkt *pkt)
1030 return pkt->ieee802154_arb;
1033static inline void net_pkt_set_ieee802154_arb(
struct net_pkt *pkt,
bool arb)
1035 pkt->ieee802154_arb = arb;
1038static inline bool net_pkt_ieee802154_ack_fpb(
struct net_pkt *pkt)
1040 return pkt->ieee802154_ack_fpb;
1043static inline void net_pkt_set_ieee802154_ack_fpb(
struct net_pkt *pkt,
1046 pkt->ieee802154_ack_fpb = fpb;
1049static inline bool net_pkt_ieee802154_frame_secured(
struct net_pkt *pkt)
1051 return pkt->ieee802154_frame_secured;
1054static inline void net_pkt_set_ieee802154_frame_secured(
struct net_pkt *pkt,
1057 pkt->ieee802154_frame_secured = secured;
1060static inline bool net_pkt_ieee802154_mac_hdr_rdy(
struct net_pkt *pkt)
1062 return pkt->ieee802154_mac_hdr_rdy;
1065static inline void net_pkt_set_ieee802154_mac_hdr_rdy(
struct net_pkt *pkt,
1068 pkt->ieee802154_mac_hdr_rdy = rdy;
1071#if defined(CONFIG_IEEE802154_2015)
1072static inline bool net_pkt_ieee802154_fv2015(
struct net_pkt *pkt)
1074 return pkt->ieee802154_fv2015;
1077static inline void net_pkt_set_ieee802154_fv2015(
struct net_pkt *pkt,
bool fv2015)
1079 pkt->ieee802154_fv2015 = fv2015;
1082static inline bool net_pkt_ieee802154_ack_seb(
struct net_pkt *pkt)
1084 return pkt->ieee802154_ack_seb;
1087static inline void net_pkt_set_ieee802154_ack_seb(
struct net_pkt *pkt,
bool seb)
1089 pkt->ieee802154_ack_seb = seb;
1094 return pkt->ieee802154_ack_fc;
1097static inline void net_pkt_set_ieee802154_ack_fc(
struct net_pkt *pkt,
1100 pkt->ieee802154_ack_fc = fc;
1103static inline uint8_t net_pkt_ieee802154_ack_keyid(
struct net_pkt *pkt)
1105 return pkt->ieee802154_ack_keyid;
1108static inline void net_pkt_set_ieee802154_ack_keyid(
struct net_pkt *pkt,
1111 pkt->ieee802154_ack_keyid = keyid;
1116#if defined(CONFIG_NET_IPV4_AUTO)
1117static inline bool net_pkt_ipv4_auto(
struct net_pkt *pkt)
1119 return pkt->ipv4_auto_arp_msg;
1122static inline void net_pkt_set_ipv4_auto(
struct net_pkt *pkt,
1123 bool is_auto_arp_msg)
1125 pkt->ipv4_auto_arp_msg = is_auto_arp_msg;
1128static inline bool net_pkt_ipv4_auto(
struct net_pkt *pkt)
1135static inline void net_pkt_set_ipv4_auto(
struct net_pkt *pkt,
1136 bool is_auto_arp_msg)
1139 ARG_UNUSED(is_auto_arp_msg);
1143#if defined(CONFIG_NET_LLDP)
1144static inline bool net_pkt_is_lldp(
struct net_pkt *pkt)
1146 return pkt->lldp_pkt;
1149static inline void net_pkt_set_lldp(
struct net_pkt *pkt,
bool is_lldp)
1151 pkt->lldp_pkt = is_lldp;
1154static inline bool net_pkt_is_lldp(
struct net_pkt *pkt)
1161static inline void net_pkt_set_lldp(
struct net_pkt *pkt,
bool is_lldp)
1164 ARG_UNUSED(is_lldp);
1168#if defined(CONFIG_NET_PPP)
1169static inline bool net_pkt_is_ppp(
struct net_pkt *pkt)
1171 return pkt->ppp_msg;
1174static inline void net_pkt_set_ppp(
struct net_pkt *pkt,
1177 pkt->ppp_msg = is_ppp_msg;
1180static inline bool net_pkt_is_ppp(
struct net_pkt *pkt)
1187static inline void net_pkt_set_ppp(
struct net_pkt *pkt,
1191 ARG_UNUSED(is_ppp_msg);
1195#define NET_IPV6_HDR(pkt) ((struct net_ipv6_hdr *)net_pkt_ip_data(pkt))
1196#define NET_IPV4_HDR(pkt) ((struct net_ipv4_hdr *)net_pkt_ip_data(pkt))
1198static inline void net_pkt_set_src_ipv6_addr(
struct net_pkt *pkt)
1201 net_pkt_context(pkt)),
1202 (
struct in6_addr *)NET_IPV6_HDR(pkt)->src);
1205static inline void net_pkt_set_overwrite(
struct net_pkt *pkt,
bool overwrite)
1207 pkt->overwrite = overwrite;
1210static inline bool net_pkt_is_being_overwritten(
struct net_pkt *pkt)
1212 return pkt->overwrite;
1215#ifdef CONFIG_NET_PKT_FILTER
1217bool net_pkt_filter_send_ok(
struct net_pkt *pkt);
1218bool net_pkt_filter_recv_ok(
struct net_pkt *pkt);
1222static inline bool net_pkt_filter_send_ok(
struct net_pkt *pkt)
1229static inline bool net_pkt_filter_recv_ok(
struct net_pkt *pkt)
1253#define NET_PKT_SLAB_DEFINE(name, count) \
1254 K_MEM_SLAB_DEFINE(name, sizeof(struct net_pkt), count, 4)
1257#define NET_PKT_TX_SLAB_DEFINE(name, count) NET_PKT_SLAB_DEFINE(name, count)
1272#define NET_PKT_DATA_POOL_DEFINE(name, count) \
1273 NET_BUF_POOL_DEFINE(name, count, CONFIG_NET_BUF_DATA_SIZE, \
1278#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC) || \
1279 (CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG)
1280#define NET_PKT_DEBUG_ENABLED
1283#if defined(NET_PKT_DEBUG_ENABLED)
1294#define net_pkt_get_reserve_data(pool, timeout) \
1295 net_pkt_get_reserve_data_debug(pool, timeout, __func__, __LINE__)
1300#define net_pkt_get_reserve_rx_data(timeout) \
1301 net_pkt_get_reserve_rx_data_debug(timeout, __func__, __LINE__)
1306#define net_pkt_get_reserve_tx_data(timeout) \
1307 net_pkt_get_reserve_tx_data_debug(timeout, __func__, __LINE__)
1311 const char *caller,
int line);
1312#define net_pkt_get_frag(pkt, timeout) \
1313 net_pkt_get_frag_debug(pkt, timeout, __func__, __LINE__)
1315void net_pkt_unref_debug(
struct net_pkt *pkt,
const char *caller,
int line);
1316#define net_pkt_unref(pkt) net_pkt_unref_debug(pkt, __func__, __LINE__)
1318struct net_pkt *net_pkt_ref_debug(
struct net_pkt *pkt,
const char *caller,
1320#define net_pkt_ref(pkt) net_pkt_ref_debug(pkt, __func__, __LINE__)
1323 const char *caller,
int line);
1324#define net_pkt_frag_ref(frag) net_pkt_frag_ref_debug(frag, __func__, __LINE__)
1326void net_pkt_frag_unref_debug(
struct net_buf *frag,
1327 const char *caller,
int line);
1328#define net_pkt_frag_unref(frag) \
1329 net_pkt_frag_unref_debug(frag, __func__, __LINE__)
1334 const char *caller,
int line);
1335#define net_pkt_frag_del(pkt, parent, frag) \
1336 net_pkt_frag_del_debug(pkt, parent, frag, __func__, __LINE__)
1338void net_pkt_frag_add_debug(
struct net_pkt *pkt,
struct net_buf *frag,
1339 const char *caller,
int line);
1340#define net_pkt_frag_add(pkt, frag) \
1341 net_pkt_frag_add_debug(pkt, frag, __func__, __LINE__)
1343void net_pkt_frag_insert_debug(
struct net_pkt *pkt,
struct net_buf *frag,
1344 const char *caller,
int line);
1345#define net_pkt_frag_insert(pkt, frag) \
1346 net_pkt_frag_insert_debug(pkt, frag, __func__, __LINE__)
1359#if defined(NET_PKT_DEBUG_ENABLED)
1362#define net_pkt_print_frags(pkt)
1378#if !defined(NET_PKT_DEBUG_ENABLED)
1395#if !defined(NET_PKT_DEBUG_ENABLED)
1410#if !defined(NET_PKT_DEBUG_ENABLED)
1423#if !defined(NET_PKT_DEBUG_ENABLED)
1436#if !defined(NET_PKT_DEBUG_ENABLED)
1449#if !defined(NET_PKT_DEBUG_ENABLED)
1458#if !defined(NET_PKT_DEBUG_ENABLED)
1472#if !defined(NET_PKT_DEBUG_ENABLED)
1484#if !defined(NET_PKT_DEBUG_ENABLED)
1494#if !defined(NET_PKT_DEBUG_ENABLED)
1517 struct k_mem_slab **tx,
1523#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC)
1527void net_pkt_print(
void);
1529typedef void (*net_pkt_allocs_cb_t)(
struct net_pkt *pkt,
1531 const char *func_alloc,
1533 const char *func_free,
1538void net_pkt_allocs_foreach(net_pkt_allocs_cb_t cb,
void *
user_data);
1540const char *net_pkt_slab2str(
struct k_mem_slab *slab);
1541const char *net_pkt_pool2str(
struct net_buf_pool *pool);
1544#define net_pkt_print(...)
1550#if defined(NET_PKT_DEBUG_ENABLED)
1553 const char *caller,
int line);
1554#define net_pkt_alloc(_timeout) \
1555 net_pkt_alloc_debug(_timeout, __func__, __LINE__)
1557struct net_pkt *net_pkt_alloc_from_slab_debug(
struct k_mem_slab *
slab,
1559 const char *caller,
int line);
1560#define net_pkt_alloc_from_slab(_slab, _timeout) \
1561 net_pkt_alloc_from_slab_debug(_slab, _timeout, __func__, __LINE__)
1564 const char *caller,
int line);
1565#define net_pkt_rx_alloc(_timeout) \
1566 net_pkt_rx_alloc_debug(_timeout, __func__, __LINE__)
1572#define net_pkt_alloc_on_iface(_iface, _timeout) \
1573 net_pkt_alloc_on_iface_debug(_iface, _timeout, __func__, __LINE__)
1579#define net_pkt_rx_alloc_on_iface(_iface, _timeout) \
1580 net_pkt_rx_alloc_on_iface_debug(_iface, _timeout, \
1583int net_pkt_alloc_buffer_debug(
struct net_pkt *pkt,
1587 const char *caller,
int line);
1588#define net_pkt_alloc_buffer(_pkt, _size, _proto, _timeout) \
1589 net_pkt_alloc_buffer_debug(_pkt, _size, _proto, _timeout, \
1599#define net_pkt_alloc_with_buffer(_iface, _size, _family, \
1601 net_pkt_alloc_with_buffer_debug(_iface, _size, _family, \
1612#define net_pkt_rx_alloc_with_buffer(_iface, _size, _family, \
1614 net_pkt_rx_alloc_with_buffer_debug(_iface, _size, _family, \
1630#if !defined(NET_PKT_DEBUG_ENABLED)
1648#if !defined(NET_PKT_DEBUG_ENABLED)
1663#if !defined(NET_PKT_DEBUG_ENABLED)
1675#if !defined(NET_PKT_DEBUG_ENABLED)
1699#if !defined(NET_PKT_DEBUG_ENABLED)
1717#if !defined(NET_PKT_DEBUG_ENABLED)
2106#if !defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2112#if defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2113#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2114 struct net_pkt_data_access _name = { \
2115 .size = sizeof(_type), \
2118#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2119 NET_PKT_DATA_ACCESS_DEFINE(_name, _type)
2122#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2123 _type _hdr_##_name; \
2124 struct net_pkt_data_access _name = { \
2125 .data = &_hdr_##_name, \
2126 .size = sizeof(_type), \
2129#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2130 struct net_pkt_data_access _name = { \
2132 .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:633
static struct net_linkaddr * net_if_get_link_addr(struct net_if *iface)
Get an network interface's link address.
Definition: net_if.h:680
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:1428
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:2012
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:1362
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)
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:2004
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:1998
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:1838
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:1811
static int net_pkt_acknowledge_data(struct net_pkt *pkt, struct net_pkt_data_access *access)
Definition: net_pkt.h:2173
static int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
Definition: net_pkt.h:2028
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:1824
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.
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:2020
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:1935
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:60
__INTPTR_TYPE__ intptr_t
Definition: stdint.h:74
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
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:468
Hardware link address structure.
Definition: net_linkaddr.h:69
uint8_t * addr
Definition: net_linkaddr.h:71
uint8_t type
Definition: net_linkaddr.h:77
uint8_t * pos
Definition: net_pkt.h:53
struct net_buf * buf
Definition: net_pkt.h:51
Definition: net_pkt.h:2105
const size_t size
Definition: net_pkt.h:2109
void * data
Definition: net_pkt.h:2107
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: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