Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
net_pkt.h
Go to the documentation of this file.
1
8/*
9 * Copyright (c) 2016 Intel Corporation
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13
14/* Data buffer API - used for all data to/from net */
15
16#ifndef ZEPHYR_INCLUDE_NET_NET_PKT_H_
17#define ZEPHYR_INCLUDE_NET_NET_PKT_H_
18
19#include <zephyr/types.h>
20#include <stdbool.h>
21
22#include <zephyr/net/buf.h>
23
24#if defined(CONFIG_IEEE802154)
26#endif
27#include <zephyr/net/net_core.h>
29#include <zephyr/net/net_ip.h>
30#include <zephyr/net/net_if.h>
32#include <zephyr/net/net_time.h>
34#include <zephyr/net/ptp_time.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
47struct net_context;
48
49/* buffer cursor used in net_pkt */
52 struct net_buf *buf;
55};
56
63struct net_pkt {
69
71 struct k_mem_slab *slab;
72
74 union {
75 struct net_buf *frags;
76 struct net_buf *buffer;
77 };
78
81
84
86 struct net_if *iface;
87
90#if defined(CONFIG_NET_TCP)
92 sys_snode_t next;
93#endif
94#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
95 struct net_if *orig_iface; /* Original network interface */
96#endif
97
98#if defined(CONFIG_NET_PKT_TIMESTAMP) || defined(CONFIG_NET_PKT_TXTIME)
117 struct net_ptp_time timestamp;
118#endif
119
120#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
121 struct {
123 uint32_t create_time;
124
125#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
126 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
132 struct {
133 uint32_t stat[NET_PKT_DETAIL_STATS_COUNT];
134 int count;
135 } detail;
136#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
137 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
138 };
139#endif /* CONFIG_NET_PKT_RXTIME_STATS || CONFIG_NET_PKT_TXTIME_STATS */
140
142 atomic_t atomic_ref;
143
144 /* Filled by layer 2 when network packet is received. */
145 struct net_linkaddr lladdr_src;
146 struct net_linkaddr lladdr_dst;
147 uint16_t ll_proto_type;
148
149#if defined(CONFIG_NET_IP)
150 uint8_t ip_hdr_len; /* pre-filled in order to avoid func call */
151#endif
152
153 uint8_t overwrite : 1; /* Is packet content being overwritten? */
154 uint8_t eof : 1; /* Last packet before EOF */
155 uint8_t ptp_pkt : 1; /* For outgoing packet: is this packet
156 * a L2 PTP packet.
157 * Used only if defined (CONFIG_NET_L2_PTP)
158 */
159 uint8_t forwarding : 1; /* Are we forwarding this pkt
160 * Used only if defined(CONFIG_NET_ROUTE)
161 */
162 uint8_t family : 3; /* Address family, see net_ip.h */
163
164 /* bitfield byte alignment boundary */
165
166#if defined(CONFIG_NET_IPV4_AUTO)
167 uint8_t ipv4_auto_arp_msg : 1; /* Is this pkt IPv4 autoconf ARP
168 * message.
169 * Note: family needs to be
170 * AF_INET.
171 */
172#endif
173#if defined(CONFIG_NET_LLDP)
174 uint8_t lldp_pkt : 1; /* Is this pkt an LLDP message.
175 * Note: family needs to be
176 * AF_UNSPEC.
177 */
178#endif
179 uint8_t ppp_msg : 1; /* This is a PPP message */
180#if defined(CONFIG_NET_TCP)
181 uint8_t tcp_first_msg : 1; /* Is this the first time this pkt is
182 * sent, or is this a resend of a TCP
183 * segment.
184 */
185#endif
186 uint8_t captured : 1; /* Set to 1 if this packet is already being
187 * captured
188 */
189 uint8_t l2_bridged : 1; /* set to 1 if this packet comes from a bridge
190 * and already contains its L2 header to be
191 * preserved. Useful only if
192 * defined(CONFIG_NET_ETHERNET_BRIDGE).
193 */
194 uint8_t l2_processed : 1; /* Set to 1 if this packet has already been
195 * processed by the L2
196 */
197 uint8_t chksum_done : 1; /* Checksum has already been computed for
198 * the packet.
199 */
200#if defined(CONFIG_NET_IP_FRAGMENT)
201 uint8_t ip_reassembled : 1; /* Packet is a reassembled IP packet. */
202#endif
203 /* bitfield byte alignment boundary */
204
205#if defined(CONFIG_NET_IP)
206 union {
207 /* IPv6 hop limit or IPv4 ttl for this network packet.
208 * The value is shared between IPv6 and IPv4.
209 */
210#if defined(CONFIG_NET_IPV6)
211 uint8_t ipv6_hop_limit;
212#endif
213#if defined(CONFIG_NET_IPV4)
214 uint8_t ipv4_ttl;
215#endif
216 };
217
218 union {
219#if defined(CONFIG_NET_IPV4)
220 uint8_t ipv4_opts_len; /* length of IPv4 header options */
221#endif
222#if defined(CONFIG_NET_IPV6)
223 uint16_t ipv6_ext_len; /* length of extension headers */
224#endif
225 };
226
227#if defined(CONFIG_NET_IP_FRAGMENT)
228 union {
229#if defined(CONFIG_NET_IPV4_FRAGMENT)
230 struct {
231 uint16_t flags; /* Fragment offset and M (More Fragment) flag */
232 uint16_t id; /* Fragment ID */
233 } ipv4_fragment;
234#endif /* CONFIG_NET_IPV4_FRAGMENT */
235#if defined(CONFIG_NET_IPV6_FRAGMENT)
236 struct {
237 uint16_t flags; /* Fragment offset and M (More Fragment) flag */
238 uint32_t id; /* Fragment id */
239 uint16_t hdr_start; /* Where starts the fragment header */
240 } ipv6_fragment;
241#endif /* CONFIG_NET_IPV6_FRAGMENT */
242 };
243#endif /* CONFIG_NET_IP_FRAGMENT */
244
245#if defined(CONFIG_NET_IPV6)
246 /* Where is the start of the last header before payload data
247 * in IPv6 packet. This is offset value from start of the IPv6
248 * packet. Note that this value should be updated by who ever
249 * adds IPv6 extension headers to the network packet.
250 */
251 uint16_t ipv6_prev_hdr_start;
252
253 uint8_t ipv6_ext_opt_len; /* IPv6 ND option length */
254 uint8_t ipv6_next_hdr; /* What is the very first next header */
255#endif /* CONFIG_NET_IPV6 */
256
257#if defined(CONFIG_NET_IP_DSCP_ECN)
259 uint8_t ip_dscp : 6;
260
262 uint8_t ip_ecn : 2;
263#endif /* CONFIG_NET_IP_DSCP_ECN */
264#endif /* CONFIG_NET_IP */
265
266#if defined(CONFIG_NET_VLAN)
267 /* VLAN TCI (Tag Control Information). This contains the Priority
268 * Code Point (PCP), Drop Eligible Indicator (DEI) and VLAN
269 * Identifier (VID, called more commonly VLAN tag). This value is
270 * kept in host byte order.
271 */
272 uint16_t vlan_tci;
273#endif /* CONFIG_NET_VLAN */
274
275#if defined(NET_PKT_HAS_CONTROL_BLOCK)
276 /* TODO: Evolve this into a union of orthogonal
277 * control block declarations if further L2
278 * stacks require L2-specific attributes.
279 */
280#if defined(CONFIG_IEEE802154)
281 /* The following structure requires a 4-byte alignment
282 * boundary to avoid padding.
283 */
284 struct net_pkt_cb_ieee802154 cb;
285#endif /* CONFIG_IEEE802154 */
286#endif /* NET_PKT_HAS_CONTROL_BLOCK */
287
291 uint8_t priority;
292
293#if defined(CONFIG_NET_OFFLOAD)
294 /* Remote address of the recived packet. This is only used by
295 * network interfaces with an offloaded TCP/IP stack.
296 */
297 struct sockaddr remote;
298#endif /* CONFIG_NET_OFFLOAD */
299
300 /* @endcond */
301};
302
305/* The interface real ll address */
306static inline struct net_linkaddr *net_pkt_lladdr_if(struct net_pkt *pkt)
307{
308 return net_if_get_link_addr(pkt->iface);
309}
310
311static inline struct net_context *net_pkt_context(struct net_pkt *pkt)
312{
313 return pkt->context;
314}
315
316static inline void net_pkt_set_context(struct net_pkt *pkt,
317 struct net_context *ctx)
318{
319 pkt->context = ctx;
320}
321
322static inline struct net_if *net_pkt_iface(struct net_pkt *pkt)
323{
324 return pkt->iface;
325}
326
327static inline void net_pkt_set_iface(struct net_pkt *pkt, struct net_if *iface)
328{
329 pkt->iface = iface;
330
331 /* If the network interface is set in pkt, then also set the type of
332 * the network address that is stored in pkt. This is done here so
333 * that the address type is properly set and is not forgotten.
334 */
335 if (iface) {
336 uint8_t type = net_if_get_link_addr(iface)->type;
337
338 pkt->lladdr_src.type = type;
339 pkt->lladdr_dst.type = type;
340 }
341}
342
343static inline struct net_if *net_pkt_orig_iface(struct net_pkt *pkt)
344{
345#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
346 return pkt->orig_iface;
347#else
348 return pkt->iface;
349#endif
350}
351
352static inline void net_pkt_set_orig_iface(struct net_pkt *pkt,
353 struct net_if *iface)
354{
355#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
356 pkt->orig_iface = iface;
357#endif
358}
359
360static inline uint8_t net_pkt_family(struct net_pkt *pkt)
361{
362 return pkt->family;
363}
364
365static inline void net_pkt_set_family(struct net_pkt *pkt, uint8_t family)
366{
367 pkt->family = family;
368}
369
370static inline bool net_pkt_is_ptp(struct net_pkt *pkt)
371{
372 return !!(pkt->ptp_pkt);
373}
374
375static inline void net_pkt_set_ptp(struct net_pkt *pkt, bool is_ptp)
376{
377 pkt->ptp_pkt = is_ptp;
378}
379
380static inline bool net_pkt_is_captured(struct net_pkt *pkt)
381{
382 return !!(pkt->captured);
383}
384
385static inline void net_pkt_set_captured(struct net_pkt *pkt, bool is_captured)
386{
387 pkt->captured = is_captured;
388}
389
390static inline bool net_pkt_is_l2_bridged(struct net_pkt *pkt)
391{
392 return IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE) ? !!(pkt->l2_bridged) : 0;
393}
394
395static inline void net_pkt_set_l2_bridged(struct net_pkt *pkt, bool is_l2_bridged)
396{
397 if (IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE)) {
398 pkt->l2_bridged = is_l2_bridged;
399 }
400}
401
402static inline bool net_pkt_is_l2_processed(struct net_pkt *pkt)
403{
404 return !!(pkt->l2_processed);
405}
406
407static inline void net_pkt_set_l2_processed(struct net_pkt *pkt,
408 bool is_l2_processed)
409{
410 pkt->l2_processed = is_l2_processed;
411}
412
413static inline bool net_pkt_is_chksum_done(struct net_pkt *pkt)
414{
415 return !!(pkt->chksum_done);
416}
417
418static inline void net_pkt_set_chksum_done(struct net_pkt *pkt,
419 bool is_chksum_done)
420{
421 pkt->chksum_done = is_chksum_done;
422}
423
424static inline uint8_t net_pkt_ip_hdr_len(struct net_pkt *pkt)
425{
426#if defined(CONFIG_NET_IP)
427 return pkt->ip_hdr_len;
428#else
429 return 0;
430#endif
431}
432
433static inline void net_pkt_set_ip_hdr_len(struct net_pkt *pkt, uint8_t len)
434{
435#if defined(CONFIG_NET_IP)
436 pkt->ip_hdr_len = len;
437#endif
438}
439
440static inline uint8_t net_pkt_ip_dscp(struct net_pkt *pkt)
441{
442#if defined(CONFIG_NET_IP_DSCP_ECN)
443 return pkt->ip_dscp;
444#else
445 return 0;
446#endif
447}
448
449static inline void net_pkt_set_ip_dscp(struct net_pkt *pkt, uint8_t dscp)
450{
451#if defined(CONFIG_NET_IP_DSCP_ECN)
452 pkt->ip_dscp = dscp;
453#endif
454}
455
456static inline uint8_t net_pkt_ip_ecn(struct net_pkt *pkt)
457{
458#if defined(CONFIG_NET_IP_DSCP_ECN)
459 return pkt->ip_ecn;
460#else
461 return 0;
462#endif
463}
464
465static inline void net_pkt_set_ip_ecn(struct net_pkt *pkt, uint8_t ecn)
466{
467#if defined(CONFIG_NET_IP_DSCP_ECN)
468 pkt->ip_ecn = ecn;
469#endif
470}
471
472static inline uint8_t net_pkt_tcp_1st_msg(struct net_pkt *pkt)
473{
474#if defined(CONFIG_NET_TCP)
475 return pkt->tcp_first_msg;
476#else
477 return true;
478#endif
479}
480
481static inline void net_pkt_set_tcp_1st_msg(struct net_pkt *pkt, bool is_1st)
482{
483#if defined(CONFIG_NET_TCP)
484 pkt->tcp_first_msg = is_1st;
485#else
486 ARG_UNUSED(pkt);
487 ARG_UNUSED(is_1st);
488#endif
489}
490
491static inline uint8_t net_pkt_eof(struct net_pkt *pkt)
492{
493 return pkt->eof;
494}
495
496static inline void net_pkt_set_eof(struct net_pkt *pkt, bool eof)
497{
498 pkt->eof = eof;
499}
500
501static inline bool net_pkt_forwarding(struct net_pkt *pkt)
502{
503 return !!(pkt->forwarding);
504}
505
506static inline void net_pkt_set_forwarding(struct net_pkt *pkt, bool forward)
507{
508 pkt->forwarding = forward;
509}
510
511#if defined(CONFIG_NET_IPV4)
512static inline uint8_t net_pkt_ipv4_ttl(struct net_pkt *pkt)
513{
514 return pkt->ipv4_ttl;
515}
516
517static inline void net_pkt_set_ipv4_ttl(struct net_pkt *pkt,
518 uint8_t ttl)
519{
520 pkt->ipv4_ttl = ttl;
521}
522
523static inline uint8_t net_pkt_ipv4_opts_len(struct net_pkt *pkt)
524{
525 return pkt->ipv4_opts_len;
526}
527
528static inline void net_pkt_set_ipv4_opts_len(struct net_pkt *pkt,
529 uint8_t opts_len)
530{
531 pkt->ipv4_opts_len = opts_len;
532}
533#else
534static inline uint8_t net_pkt_ipv4_ttl(struct net_pkt *pkt)
535{
536 ARG_UNUSED(pkt);
537
538 return 0;
539}
540
541static inline void net_pkt_set_ipv4_ttl(struct net_pkt *pkt,
542 uint8_t ttl)
543{
544 ARG_UNUSED(pkt);
545 ARG_UNUSED(ttl);
546}
547
548static inline uint8_t net_pkt_ipv4_opts_len(struct net_pkt *pkt)
549{
550 ARG_UNUSED(pkt);
551 return 0;
552}
553
554static inline void net_pkt_set_ipv4_opts_len(struct net_pkt *pkt,
555 uint8_t opts_len)
556{
557 ARG_UNUSED(pkt);
558 ARG_UNUSED(opts_len);
559}
560#endif
561
562#if defined(CONFIG_NET_IPV6)
563static inline uint8_t net_pkt_ipv6_ext_opt_len(struct net_pkt *pkt)
564{
565 return pkt->ipv6_ext_opt_len;
566}
567
568static inline void net_pkt_set_ipv6_ext_opt_len(struct net_pkt *pkt,
569 uint8_t len)
570{
571 pkt->ipv6_ext_opt_len = len;
572}
573
574static inline uint8_t net_pkt_ipv6_next_hdr(struct net_pkt *pkt)
575{
576 return pkt->ipv6_next_hdr;
577}
578
579static inline void net_pkt_set_ipv6_next_hdr(struct net_pkt *pkt,
580 uint8_t next_hdr)
581{
582 pkt->ipv6_next_hdr = next_hdr;
583}
584
585static inline uint16_t net_pkt_ipv6_ext_len(struct net_pkt *pkt)
586{
587 return pkt->ipv6_ext_len;
588}
589
590static inline void net_pkt_set_ipv6_ext_len(struct net_pkt *pkt, uint16_t len)
591{
592 pkt->ipv6_ext_len = len;
593}
594
595static inline uint16_t net_pkt_ipv6_hdr_prev(struct net_pkt *pkt)
596{
597 return pkt->ipv6_prev_hdr_start;
598}
599
600static inline void net_pkt_set_ipv6_hdr_prev(struct net_pkt *pkt,
601 uint16_t offset)
602{
603 pkt->ipv6_prev_hdr_start = offset;
604}
605
606static inline uint8_t net_pkt_ipv6_hop_limit(struct net_pkt *pkt)
607{
608 return pkt->ipv6_hop_limit;
609}
610
611static inline void net_pkt_set_ipv6_hop_limit(struct net_pkt *pkt,
612 uint8_t hop_limit)
613{
614 pkt->ipv6_hop_limit = hop_limit;
615}
616#else /* CONFIG_NET_IPV6 */
617static inline uint8_t net_pkt_ipv6_ext_opt_len(struct net_pkt *pkt)
618{
619 ARG_UNUSED(pkt);
620
621 return 0;
622}
623
624static inline void net_pkt_set_ipv6_ext_opt_len(struct net_pkt *pkt,
625 uint8_t len)
626{
627 ARG_UNUSED(pkt);
628 ARG_UNUSED(len);
629}
630
631static inline uint8_t net_pkt_ipv6_next_hdr(struct net_pkt *pkt)
632{
633 ARG_UNUSED(pkt);
634
635 return 0;
636}
637
638static inline void net_pkt_set_ipv6_next_hdr(struct net_pkt *pkt,
639 uint8_t next_hdr)
640{
641 ARG_UNUSED(pkt);
642 ARG_UNUSED(next_hdr);
643}
644
645static inline uint16_t net_pkt_ipv6_ext_len(struct net_pkt *pkt)
646{
647 ARG_UNUSED(pkt);
648
649 return 0;
650}
651
652static inline void net_pkt_set_ipv6_ext_len(struct net_pkt *pkt, uint16_t len)
653{
654 ARG_UNUSED(pkt);
655 ARG_UNUSED(len);
656}
657
658static inline uint16_t net_pkt_ipv6_hdr_prev(struct net_pkt *pkt)
659{
660 ARG_UNUSED(pkt);
661
662 return 0;
663}
664
665static inline void net_pkt_set_ipv6_hdr_prev(struct net_pkt *pkt,
666 uint16_t offset)
667{
668 ARG_UNUSED(pkt);
669 ARG_UNUSED(offset);
670}
671
672static inline uint8_t net_pkt_ipv6_hop_limit(struct net_pkt *pkt)
673{
674 ARG_UNUSED(pkt);
675
676 return 0;
677}
678
679static inline void net_pkt_set_ipv6_hop_limit(struct net_pkt *pkt,
680 uint8_t hop_limit)
681{
682 ARG_UNUSED(pkt);
683 ARG_UNUSED(hop_limit);
684}
685#endif /* CONFIG_NET_IPV6 */
686
687static inline uint16_t net_pkt_ip_opts_len(struct net_pkt *pkt)
688{
689#if defined(CONFIG_NET_IPV6)
690 return pkt->ipv6_ext_len;
691#elif defined(CONFIG_NET_IPV4)
692 return pkt->ipv4_opts_len;
693#else
694 ARG_UNUSED(pkt);
695
696 return 0;
697#endif
698}
699
700#if defined(CONFIG_NET_IPV4_FRAGMENT)
701static inline uint16_t net_pkt_ipv4_fragment_offset(struct net_pkt *pkt)
702{
703 return (pkt->ipv4_fragment.flags & NET_IPV4_FRAGH_OFFSET_MASK) * 8;
704}
705
706static inline bool net_pkt_ipv4_fragment_more(struct net_pkt *pkt)
707{
708 return (pkt->ipv4_fragment.flags & NET_IPV4_MORE_FRAG_MASK) != 0;
709}
710
711static inline void net_pkt_set_ipv4_fragment_flags(struct net_pkt *pkt, uint16_t flags)
712{
713 pkt->ipv4_fragment.flags = flags;
714}
715
716static inline uint32_t net_pkt_ipv4_fragment_id(struct net_pkt *pkt)
717{
718 return pkt->ipv4_fragment.id;
719}
720
721static inline void net_pkt_set_ipv4_fragment_id(struct net_pkt *pkt, uint32_t id)
722{
723 pkt->ipv4_fragment.id = id;
724}
725#else /* CONFIG_NET_IPV4_FRAGMENT */
726static inline uint16_t net_pkt_ipv4_fragment_offset(struct net_pkt *pkt)
727{
728 ARG_UNUSED(pkt);
729
730 return 0;
731}
732
733static inline bool net_pkt_ipv4_fragment_more(struct net_pkt *pkt)
734{
735 ARG_UNUSED(pkt);
736
737 return 0;
738}
739
740static inline void net_pkt_set_ipv4_fragment_flags(struct net_pkt *pkt, uint16_t flags)
741{
742 ARG_UNUSED(pkt);
743 ARG_UNUSED(flags);
744}
745
746static inline uint32_t net_pkt_ipv4_fragment_id(struct net_pkt *pkt)
747{
748 ARG_UNUSED(pkt);
749
750 return 0;
751}
752
753static inline void net_pkt_set_ipv4_fragment_id(struct net_pkt *pkt, uint32_t id)
754{
755 ARG_UNUSED(pkt);
756 ARG_UNUSED(id);
757}
758#endif /* CONFIG_NET_IPV4_FRAGMENT */
759
760#if defined(CONFIG_NET_IPV6_FRAGMENT)
761static inline uint16_t net_pkt_ipv6_fragment_start(struct net_pkt *pkt)
762{
763 return pkt->ipv6_fragment.hdr_start;
764}
765
766static inline void net_pkt_set_ipv6_fragment_start(struct net_pkt *pkt,
767 uint16_t start)
768{
769 pkt->ipv6_fragment.hdr_start = start;
770}
771
772static inline uint16_t net_pkt_ipv6_fragment_offset(struct net_pkt *pkt)
773{
774 return pkt->ipv6_fragment.flags & NET_IPV6_FRAGH_OFFSET_MASK;
775}
776static inline bool net_pkt_ipv6_fragment_more(struct net_pkt *pkt)
777{
778 return (pkt->ipv6_fragment.flags & 0x01) != 0;
779}
780
781static inline void net_pkt_set_ipv6_fragment_flags(struct net_pkt *pkt,
783{
784 pkt->ipv6_fragment.flags = flags;
785}
786
787static inline uint32_t net_pkt_ipv6_fragment_id(struct net_pkt *pkt)
788{
789 return pkt->ipv6_fragment.id;
790}
791
792static inline void net_pkt_set_ipv6_fragment_id(struct net_pkt *pkt,
793 uint32_t id)
794{
795 pkt->ipv6_fragment.id = id;
796}
797#else /* CONFIG_NET_IPV6_FRAGMENT */
798static inline uint16_t net_pkt_ipv6_fragment_start(struct net_pkt *pkt)
799{
800 ARG_UNUSED(pkt);
801
802 return 0;
803}
804
805static inline void net_pkt_set_ipv6_fragment_start(struct net_pkt *pkt,
806 uint16_t start)
807{
808 ARG_UNUSED(pkt);
809 ARG_UNUSED(start);
810}
811
812static inline uint16_t net_pkt_ipv6_fragment_offset(struct net_pkt *pkt)
813{
814 ARG_UNUSED(pkt);
815
816 return 0;
817}
818
819static inline bool net_pkt_ipv6_fragment_more(struct net_pkt *pkt)
820{
821 ARG_UNUSED(pkt);
822
823 return 0;
824}
825
826static inline void net_pkt_set_ipv6_fragment_flags(struct net_pkt *pkt,
828{
829 ARG_UNUSED(pkt);
830 ARG_UNUSED(flags);
831}
832
833static inline uint32_t net_pkt_ipv6_fragment_id(struct net_pkt *pkt)
834{
835 ARG_UNUSED(pkt);
836
837 return 0;
838}
839
840static inline void net_pkt_set_ipv6_fragment_id(struct net_pkt *pkt,
841 uint32_t id)
842{
843 ARG_UNUSED(pkt);
844 ARG_UNUSED(id);
845}
846#endif /* CONFIG_NET_IPV6_FRAGMENT */
847
848#if defined(CONFIG_NET_IP_FRAGMENT)
849static inline bool net_pkt_is_ip_reassembled(struct net_pkt *pkt)
850{
851 return !!(pkt->ip_reassembled);
852}
853
854static inline void net_pkt_set_ip_reassembled(struct net_pkt *pkt,
855 bool reassembled)
856{
857 pkt->ip_reassembled = reassembled;
858}
859#else /* CONFIG_NET_IP_FRAGMENT */
860static inline bool net_pkt_is_ip_reassembled(struct net_pkt *pkt)
861{
862 ARG_UNUSED(pkt);
863
864 return false;
865}
866
867static inline void net_pkt_set_ip_reassembled(struct net_pkt *pkt,
868 bool reassembled)
869{
870 ARG_UNUSED(pkt);
871 ARG_UNUSED(reassembled);
872}
873#endif /* CONFIG_NET_IP_FRAGMENT */
874
875static inline uint8_t net_pkt_priority(struct net_pkt *pkt)
876{
877 return pkt->priority;
878}
879
880static inline void net_pkt_set_priority(struct net_pkt *pkt,
881 uint8_t priority)
882{
883 pkt->priority = priority;
884}
885
886#if defined(CONFIG_NET_VLAN)
887static inline uint16_t net_pkt_vlan_tag(struct net_pkt *pkt)
888{
889 return net_eth_vlan_get_vid(pkt->vlan_tci);
890}
891
892static inline void net_pkt_set_vlan_tag(struct net_pkt *pkt, uint16_t tag)
893{
894 pkt->vlan_tci = net_eth_vlan_set_vid(pkt->vlan_tci, tag);
895}
896
897static inline uint8_t net_pkt_vlan_priority(struct net_pkt *pkt)
898{
899 return net_eth_vlan_get_pcp(pkt->vlan_tci);
900}
901
902static inline void net_pkt_set_vlan_priority(struct net_pkt *pkt,
903 uint8_t priority)
904{
905 pkt->vlan_tci = net_eth_vlan_set_pcp(pkt->vlan_tci, priority);
906}
907
908static inline bool net_pkt_vlan_dei(struct net_pkt *pkt)
909{
910 return net_eth_vlan_get_dei(pkt->vlan_tci);
911}
912
913static inline void net_pkt_set_vlan_dei(struct net_pkt *pkt, bool dei)
914{
915 pkt->vlan_tci = net_eth_vlan_set_dei(pkt->vlan_tci, dei);
916}
917
918static inline void net_pkt_set_vlan_tci(struct net_pkt *pkt, uint16_t tci)
919{
920 pkt->vlan_tci = tci;
921}
922
923static inline uint16_t net_pkt_vlan_tci(struct net_pkt *pkt)
924{
925 return pkt->vlan_tci;
926}
927#else
928static inline uint16_t net_pkt_vlan_tag(struct net_pkt *pkt)
929{
930 return NET_VLAN_TAG_UNSPEC;
931}
932
933static inline void net_pkt_set_vlan_tag(struct net_pkt *pkt, uint16_t tag)
934{
935 ARG_UNUSED(pkt);
936 ARG_UNUSED(tag);
937}
938
939static inline uint8_t net_pkt_vlan_priority(struct net_pkt *pkt)
940{
941 ARG_UNUSED(pkt);
942 return 0;
943}
944
945static inline bool net_pkt_vlan_dei(struct net_pkt *pkt)
946{
947 return false;
948}
949
950static inline void net_pkt_set_vlan_dei(struct net_pkt *pkt, bool dei)
951{
952 ARG_UNUSED(pkt);
953 ARG_UNUSED(dei);
954}
955
956static inline uint16_t net_pkt_vlan_tci(struct net_pkt *pkt)
957{
958 return NET_VLAN_TAG_UNSPEC; /* assumes priority is 0 */
959}
960
961static inline void net_pkt_set_vlan_tci(struct net_pkt *pkt, uint16_t tci)
962{
963 ARG_UNUSED(pkt);
964 ARG_UNUSED(tci);
965}
966#endif
967
968#if defined(CONFIG_NET_PKT_TIMESTAMP) || defined(CONFIG_NET_PKT_TXTIME)
969static inline struct net_ptp_time *net_pkt_timestamp(struct net_pkt *pkt)
970{
971 return &pkt->timestamp;
972}
973
974static inline void net_pkt_set_timestamp(struct net_pkt *pkt,
975 struct net_ptp_time *timestamp)
976{
977 pkt->timestamp.second = timestamp->second;
978 pkt->timestamp.nanosecond = timestamp->nanosecond;
979}
980
981static inline net_time_t net_pkt_timestamp_ns(struct net_pkt *pkt)
982{
983 return net_ptp_time_to_ns(&pkt->timestamp);
984}
985
986static inline void net_pkt_set_timestamp_ns(struct net_pkt *pkt, net_time_t timestamp)
987{
988 pkt->timestamp = ns_to_net_ptp_time(timestamp);
989}
990#else
991static inline struct net_ptp_time *net_pkt_timestamp(struct net_pkt *pkt)
992{
993 ARG_UNUSED(pkt);
994
995 return NULL;
996}
997
998static inline void net_pkt_set_timestamp(struct net_pkt *pkt,
999 struct net_ptp_time *timestamp)
1000{
1001 ARG_UNUSED(pkt);
1002 ARG_UNUSED(timestamp);
1003}
1004
1005static inline net_time_t net_pkt_timestamp_ns(struct net_pkt *pkt)
1006{
1007 ARG_UNUSED(pkt);
1008
1009 return 0;
1010}
1011
1012static inline void net_pkt_set_timestamp_ns(struct net_pkt *pkt, net_time_t timestamp)
1013{
1014 ARG_UNUSED(pkt);
1015 ARG_UNUSED(timestamp);
1016}
1017#endif /* CONFIG_NET_PKT_TIMESTAMP || CONFIG_NET_PKT_TXTIME */
1018
1019#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
1020static inline uint32_t net_pkt_create_time(struct net_pkt *pkt)
1021{
1022 return pkt->create_time;
1023}
1024
1025static inline void net_pkt_set_create_time(struct net_pkt *pkt,
1026 uint32_t create_time)
1027{
1028 pkt->create_time = create_time;
1029}
1030#else
1031static inline uint32_t net_pkt_create_time(struct net_pkt *pkt)
1032{
1033 ARG_UNUSED(pkt);
1034
1035 return 0U;
1036}
1037
1038static inline void net_pkt_set_create_time(struct net_pkt *pkt,
1039 uint32_t create_time)
1040{
1041 ARG_UNUSED(pkt);
1042 ARG_UNUSED(create_time);
1043}
1044#endif /* CONFIG_NET_PKT_RXTIME_STATS || CONFIG_NET_PKT_TXTIME_STATS */
1045
1049static inline uint64_t net_pkt_txtime(struct net_pkt *pkt)
1050{
1051#if defined(CONFIG_NET_PKT_TXTIME)
1052 return pkt->timestamp.second * NSEC_PER_SEC + pkt->timestamp.nanosecond;
1053#else
1054 ARG_UNUSED(pkt);
1055
1056 return 0;
1057#endif /* CONFIG_NET_PKT_TXTIME */
1058}
1059
1064static inline void net_pkt_set_txtime(struct net_pkt *pkt, uint64_t txtime)
1065{
1066#if defined(CONFIG_NET_PKT_TXTIME)
1067 pkt->timestamp.second = txtime / NSEC_PER_SEC;
1068 pkt->timestamp.nanosecond = txtime % NSEC_PER_SEC;
1069#else
1070 ARG_UNUSED(pkt);
1071 ARG_UNUSED(txtime);
1072#endif /* CONFIG_NET_PKT_TXTIME */
1073}
1074
1075#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
1076 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
1077static inline uint32_t *net_pkt_stats_tick(struct net_pkt *pkt)
1078{
1079 return pkt->detail.stat;
1080}
1081
1082static inline int net_pkt_stats_tick_count(struct net_pkt *pkt)
1083{
1084 return pkt->detail.count;
1085}
1086
1087static inline void net_pkt_stats_tick_reset(struct net_pkt *pkt)
1088{
1089 memset(&pkt->detail, 0, sizeof(pkt->detail));
1090}
1091
1092static ALWAYS_INLINE void net_pkt_set_stats_tick(struct net_pkt *pkt,
1093 uint32_t tick)
1094{
1095 if (pkt->detail.count >= NET_PKT_DETAIL_STATS_COUNT) {
1096 NET_ERR("Detail stats count overflow (%d >= %d)",
1097 pkt->detail.count, NET_PKT_DETAIL_STATS_COUNT);
1098 return;
1099 }
1100
1101 pkt->detail.stat[pkt->detail.count++] = tick;
1102}
1103
1104#define net_pkt_set_tx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
1105#define net_pkt_set_rx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
1106#else
1107static inline uint32_t *net_pkt_stats_tick(struct net_pkt *pkt)
1108{
1109 ARG_UNUSED(pkt);
1110
1111 return NULL;
1112}
1113
1114static inline int net_pkt_stats_tick_count(struct net_pkt *pkt)
1115{
1116 ARG_UNUSED(pkt);
1117
1118 return 0;
1119}
1120
1121static inline void net_pkt_stats_tick_reset(struct net_pkt *pkt)
1122{
1123 ARG_UNUSED(pkt);
1124}
1125
1126static inline void net_pkt_set_stats_tick(struct net_pkt *pkt, uint32_t tick)
1127{
1128 ARG_UNUSED(pkt);
1129 ARG_UNUSED(tick);
1130}
1131
1132#define net_pkt_set_tx_stats_tick(pkt, tick)
1133#define net_pkt_set_rx_stats_tick(pkt, tick)
1134#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
1135 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
1136
1137static inline size_t net_pkt_get_len(struct net_pkt *pkt)
1138{
1139 return net_buf_frags_len(pkt->frags);
1140}
1141
1142static inline uint8_t *net_pkt_data(struct net_pkt *pkt)
1143{
1144 return pkt->frags->data;
1145}
1146
1147static inline uint8_t *net_pkt_ip_data(struct net_pkt *pkt)
1148{
1149 return pkt->frags->data;
1150}
1151
1152static inline bool net_pkt_is_empty(struct net_pkt *pkt)
1153{
1154 return !pkt->buffer || !net_pkt_data(pkt) || pkt->buffer->len == 0;
1155}
1156
1157static inline struct net_linkaddr *net_pkt_lladdr_src(struct net_pkt *pkt)
1158{
1159 return &pkt->lladdr_src;
1160}
1161
1162static inline struct net_linkaddr *net_pkt_lladdr_dst(struct net_pkt *pkt)
1163{
1164 return &pkt->lladdr_dst;
1165}
1166
1167static inline void net_pkt_lladdr_swap(struct net_pkt *pkt)
1168{
1169 uint8_t *addr = net_pkt_lladdr_src(pkt)->addr;
1170
1171 net_pkt_lladdr_src(pkt)->addr = net_pkt_lladdr_dst(pkt)->addr;
1172 net_pkt_lladdr_dst(pkt)->addr = addr;
1173}
1174
1175static inline void net_pkt_lladdr_clear(struct net_pkt *pkt)
1176{
1177 net_pkt_lladdr_src(pkt)->addr = NULL;
1178 net_pkt_lladdr_src(pkt)->len = 0U;
1179}
1180
1181static inline uint16_t net_pkt_ll_proto_type(struct net_pkt *pkt)
1182{
1183 return pkt->ll_proto_type;
1184}
1185
1186static inline void net_pkt_set_ll_proto_type(struct net_pkt *pkt, uint16_t type)
1187{
1188 pkt->ll_proto_type = type;
1189}
1190
1191#if defined(CONFIG_NET_IPV4_AUTO)
1192static inline bool net_pkt_ipv4_auto(struct net_pkt *pkt)
1193{
1194 return !!(pkt->ipv4_auto_arp_msg);
1195}
1196
1197static inline void net_pkt_set_ipv4_auto(struct net_pkt *pkt,
1198 bool is_auto_arp_msg)
1199{
1200 pkt->ipv4_auto_arp_msg = is_auto_arp_msg;
1201}
1202#else /* CONFIG_NET_IPV4_AUTO */
1203static inline bool net_pkt_ipv4_auto(struct net_pkt *pkt)
1204{
1205 ARG_UNUSED(pkt);
1206
1207 return false;
1208}
1209
1210static inline void net_pkt_set_ipv4_auto(struct net_pkt *pkt,
1211 bool is_auto_arp_msg)
1212{
1213 ARG_UNUSED(pkt);
1214 ARG_UNUSED(is_auto_arp_msg);
1215}
1216#endif /* CONFIG_NET_IPV4_AUTO */
1217
1218#if defined(CONFIG_NET_LLDP)
1219static inline bool net_pkt_is_lldp(struct net_pkt *pkt)
1220{
1221 return !!(pkt->lldp_pkt);
1222}
1223
1224static inline void net_pkt_set_lldp(struct net_pkt *pkt, bool is_lldp)
1225{
1226 pkt->lldp_pkt = is_lldp;
1227}
1228#else
1229static inline bool net_pkt_is_lldp(struct net_pkt *pkt)
1230{
1231 ARG_UNUSED(pkt);
1232
1233 return false;
1234}
1235
1236static inline void net_pkt_set_lldp(struct net_pkt *pkt, bool is_lldp)
1237{
1238 ARG_UNUSED(pkt);
1239 ARG_UNUSED(is_lldp);
1240}
1241#endif /* CONFIG_NET_LLDP */
1242
1243#if defined(CONFIG_NET_L2_PPP)
1244static inline bool net_pkt_is_ppp(struct net_pkt *pkt)
1245{
1246 return !!(pkt->ppp_msg);
1247}
1248
1249static inline void net_pkt_set_ppp(struct net_pkt *pkt,
1250 bool is_ppp_msg)
1251{
1252 pkt->ppp_msg = is_ppp_msg;
1253}
1254#else /* CONFIG_NET_L2_PPP */
1255static inline bool net_pkt_is_ppp(struct net_pkt *pkt)
1256{
1257 ARG_UNUSED(pkt);
1258
1259 return false;
1260}
1261
1262static inline void net_pkt_set_ppp(struct net_pkt *pkt,
1263 bool is_ppp_msg)
1264{
1265 ARG_UNUSED(pkt);
1266 ARG_UNUSED(is_ppp_msg);
1267}
1268#endif /* CONFIG_NET_L2_PPP */
1269
1270#if defined(NET_PKT_HAS_CONTROL_BLOCK)
1271static inline void *net_pkt_cb(struct net_pkt *pkt)
1272{
1273 return &pkt->cb;
1274}
1275#else
1276static inline void *net_pkt_cb(struct net_pkt *pkt)
1277{
1278 ARG_UNUSED(pkt);
1279
1280 return NULL;
1281}
1282#endif
1283
1284#define NET_IPV6_HDR(pkt) ((struct net_ipv6_hdr *)net_pkt_ip_data(pkt))
1285#define NET_IPV4_HDR(pkt) ((struct net_ipv4_hdr *)net_pkt_ip_data(pkt))
1286
1287static inline void net_pkt_set_src_ipv6_addr(struct net_pkt *pkt)
1288{
1290 net_pkt_context(pkt)),
1291 (struct in6_addr *)NET_IPV6_HDR(pkt)->src);
1292}
1293
1294static inline void net_pkt_set_overwrite(struct net_pkt *pkt, bool overwrite)
1295{
1296 pkt->overwrite = overwrite;
1297}
1298
1299static inline bool net_pkt_is_being_overwritten(struct net_pkt *pkt)
1300{
1301 return !!(pkt->overwrite);
1302}
1303
1304#ifdef CONFIG_NET_PKT_FILTER
1305
1306bool net_pkt_filter_send_ok(struct net_pkt *pkt);
1307bool net_pkt_filter_recv_ok(struct net_pkt *pkt);
1308
1309#else
1310
1311static inline bool net_pkt_filter_send_ok(struct net_pkt *pkt)
1312{
1313 ARG_UNUSED(pkt);
1314
1315 return true;
1316}
1317
1318static inline bool net_pkt_filter_recv_ok(struct net_pkt *pkt)
1319{
1320 ARG_UNUSED(pkt);
1321
1322 return true;
1323}
1324
1325#endif /* CONFIG_NET_PKT_FILTER */
1326
1327#if defined(CONFIG_NET_PKT_FILTER) && \
1328 (defined(CONFIG_NET_PKT_FILTER_IPV4_HOOK) || defined(CONFIG_NET_PKT_FILTER_IPV6_HOOK))
1329
1330bool net_pkt_filter_ip_recv_ok(struct net_pkt *pkt);
1331
1332#else
1333
1334static inline bool net_pkt_filter_ip_recv_ok(struct net_pkt *pkt)
1335{
1336 ARG_UNUSED(pkt);
1337
1338 return true;
1339}
1340
1341#endif /* CONFIG_NET_PKT_FILTER_IPV4_HOOK || CONFIG_NET_PKT_FILTER_IPV6_HOOK */
1342
1343#if defined(CONFIG_NET_PKT_FILTER) && defined(CONFIG_NET_PKT_FILTER_LOCAL_IN_HOOK)
1344
1345bool net_pkt_filter_local_in_recv_ok(struct net_pkt *pkt);
1346
1347#else
1348
1349static inline bool net_pkt_filter_local_in_recv_ok(struct net_pkt *pkt)
1350{
1351 ARG_UNUSED(pkt);
1352
1353 return true;
1354}
1355
1356#endif /* CONFIG_NET_PKT_FILTER && CONFIG_NET_PKT_FILTER_LOCAL_IN_HOOK */
1357
1358/* @endcond */
1359
1373#define NET_PKT_SLAB_DEFINE(name, count) \
1374 K_MEM_SLAB_DEFINE(name, sizeof(struct net_pkt), count, 4)
1375
1376/* Backward compatibility macro */
1377#define NET_PKT_TX_SLAB_DEFINE(name, count) NET_PKT_SLAB_DEFINE(name, count)
1378
1392#define NET_PKT_DATA_POOL_DEFINE(name, count) \
1393 NET_BUF_POOL_DEFINE(name, count, CONFIG_NET_BUF_DATA_SIZE, \
1394 0, NULL)
1395
1398#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC) || \
1399 (CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG)
1400#define NET_PKT_DEBUG_ENABLED
1401#endif
1402
1403#if defined(NET_PKT_DEBUG_ENABLED)
1404
1405/* Debug versions of the net_pkt functions that are used when tracking
1406 * buffer usage.
1407 */
1408
1409struct net_buf *net_pkt_get_reserve_data_debug(struct net_buf_pool *pool,
1410 size_t min_len,
1411 k_timeout_t timeout,
1412 const char *caller,
1413 int line);
1414
1415#define net_pkt_get_reserve_data(pool, min_len, timeout) \
1416 net_pkt_get_reserve_data_debug(pool, min_len, timeout, __func__, __LINE__)
1417
1418struct net_buf *net_pkt_get_reserve_rx_data_debug(size_t min_len,
1419 k_timeout_t timeout,
1420 const char *caller,
1421 int line);
1422#define net_pkt_get_reserve_rx_data(min_len, timeout) \
1423 net_pkt_get_reserve_rx_data_debug(min_len, timeout, __func__, __LINE__)
1424
1425struct net_buf *net_pkt_get_reserve_tx_data_debug(size_t min_len,
1426 k_timeout_t timeout,
1427 const char *caller,
1428 int line);
1429#define net_pkt_get_reserve_tx_data(min_len, timeout) \
1430 net_pkt_get_reserve_tx_data_debug(min_len, timeout, __func__, __LINE__)
1431
1432struct net_buf *net_pkt_get_frag_debug(struct net_pkt *pkt, size_t min_len,
1433 k_timeout_t timeout,
1434 const char *caller, int line);
1435#define net_pkt_get_frag(pkt, min_len, timeout) \
1436 net_pkt_get_frag_debug(pkt, min_len, timeout, __func__, __LINE__)
1437
1438void net_pkt_unref_debug(struct net_pkt *pkt, const char *caller, int line);
1439#define net_pkt_unref(pkt) net_pkt_unref_debug(pkt, __func__, __LINE__)
1440
1441struct net_pkt *net_pkt_ref_debug(struct net_pkt *pkt, const char *caller,
1442 int line);
1443#define net_pkt_ref(pkt) net_pkt_ref_debug(pkt, __func__, __LINE__)
1444
1445struct net_buf *net_pkt_frag_ref_debug(struct net_buf *frag,
1446 const char *caller, int line);
1447#define net_pkt_frag_ref(frag) net_pkt_frag_ref_debug(frag, __func__, __LINE__)
1448
1449void net_pkt_frag_unref_debug(struct net_buf *frag,
1450 const char *caller, int line);
1451#define net_pkt_frag_unref(frag) \
1452 net_pkt_frag_unref_debug(frag, __func__, __LINE__)
1453
1454struct net_buf *net_pkt_frag_del_debug(struct net_pkt *pkt,
1455 struct net_buf *parent,
1456 struct net_buf *frag,
1457 const char *caller, int line);
1458#define net_pkt_frag_del(pkt, parent, frag) \
1459 net_pkt_frag_del_debug(pkt, parent, frag, __func__, __LINE__)
1460
1461void net_pkt_frag_add_debug(struct net_pkt *pkt, struct net_buf *frag,
1462 const char *caller, int line);
1463#define net_pkt_frag_add(pkt, frag) \
1464 net_pkt_frag_add_debug(pkt, frag, __func__, __LINE__)
1465
1466void net_pkt_frag_insert_debug(struct net_pkt *pkt, struct net_buf *frag,
1467 const char *caller, int line);
1468#define net_pkt_frag_insert(pkt, frag) \
1469 net_pkt_frag_insert_debug(pkt, frag, __func__, __LINE__)
1470#endif /* CONFIG_NET_DEBUG_NET_PKT_ALLOC ||
1471 * CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
1472 */
1482#if defined(NET_PKT_DEBUG_ENABLED)
1483void net_pkt_print_frags(struct net_pkt *pkt);
1484#else
1485#define net_pkt_print_frags(pkt)
1486#endif
1487
1502#if !defined(NET_PKT_DEBUG_ENABLED)
1503struct net_buf *net_pkt_get_reserve_rx_data(size_t min_len, k_timeout_t timeout);
1504#endif
1505
1520#if !defined(NET_PKT_DEBUG_ENABLED)
1521struct net_buf *net_pkt_get_reserve_tx_data(size_t min_len, k_timeout_t timeout);
1522#endif
1523
1536#if !defined(NET_PKT_DEBUG_ENABLED)
1537struct net_buf *net_pkt_get_frag(struct net_pkt *pkt, size_t min_len,
1538 k_timeout_t timeout);
1539#endif
1540
1550#if !defined(NET_PKT_DEBUG_ENABLED)
1551void net_pkt_unref(struct net_pkt *pkt);
1552#endif
1553
1563#if !defined(NET_PKT_DEBUG_ENABLED)
1564struct net_pkt *net_pkt_ref(struct net_pkt *pkt);
1565#endif
1566
1576#if !defined(NET_PKT_DEBUG_ENABLED)
1577struct net_buf *net_pkt_frag_ref(struct net_buf *frag);
1578#endif
1579
1585#if !defined(NET_PKT_DEBUG_ENABLED)
1586void net_pkt_frag_unref(struct net_buf *frag);
1587#endif
1588
1599#if !defined(NET_PKT_DEBUG_ENABLED)
1601 struct net_buf *parent,
1602 struct net_buf *frag);
1603#endif
1604
1611#if !defined(NET_PKT_DEBUG_ENABLED)
1612void net_pkt_frag_add(struct net_pkt *pkt, struct net_buf *frag);
1613#endif
1614
1621#if !defined(NET_PKT_DEBUG_ENABLED)
1622void net_pkt_frag_insert(struct net_pkt *pkt, struct net_buf *frag);
1623#endif
1624
1631void net_pkt_compact(struct net_pkt *pkt);
1632
1641void net_pkt_get_info(struct k_mem_slab **rx,
1642 struct k_mem_slab **tx,
1643 struct net_buf_pool **rx_data,
1644 struct net_buf_pool **tx_data);
1645
1648#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC)
1652void net_pkt_print(void);
1653
1654typedef void (*net_pkt_allocs_cb_t)(struct net_pkt *pkt,
1655 struct net_buf *buf,
1656 const char *func_alloc,
1657 int line_alloc,
1658 const char *func_free,
1659 int line_free,
1660 bool in_use,
1661 void *user_data);
1662
1663void net_pkt_allocs_foreach(net_pkt_allocs_cb_t cb, void *user_data);
1664
1665const char *net_pkt_slab2str(struct k_mem_slab *slab);
1666const char *net_pkt_pool2str(struct net_buf_pool *pool);
1667
1668#else
1669#define net_pkt_print(...)
1670#endif /* CONFIG_NET_DEBUG_NET_PKT_ALLOC */
1671
1672/* New allocator, and API are defined below.
1673 * This will be simpler when time will come to get rid of former API above.
1674 */
1675#if defined(NET_PKT_DEBUG_ENABLED)
1676
1677struct net_pkt *net_pkt_alloc_debug(k_timeout_t timeout,
1678 const char *caller, int line);
1679#define net_pkt_alloc(_timeout) \
1680 net_pkt_alloc_debug(_timeout, __func__, __LINE__)
1681
1682struct net_pkt *net_pkt_alloc_from_slab_debug(struct k_mem_slab *slab,
1683 k_timeout_t timeout,
1684 const char *caller, int line);
1685#define net_pkt_alloc_from_slab(_slab, _timeout) \
1686 net_pkt_alloc_from_slab_debug(_slab, _timeout, __func__, __LINE__)
1687
1688struct net_pkt *net_pkt_rx_alloc_debug(k_timeout_t timeout,
1689 const char *caller, int line);
1690#define net_pkt_rx_alloc(_timeout) \
1691 net_pkt_rx_alloc_debug(_timeout, __func__, __LINE__)
1692
1693struct net_pkt *net_pkt_alloc_on_iface_debug(struct net_if *iface,
1694 k_timeout_t timeout,
1695 const char *caller,
1696 int line);
1697#define net_pkt_alloc_on_iface(_iface, _timeout) \
1698 net_pkt_alloc_on_iface_debug(_iface, _timeout, __func__, __LINE__)
1699
1700struct net_pkt *net_pkt_rx_alloc_on_iface_debug(struct net_if *iface,
1701 k_timeout_t timeout,
1702 const char *caller,
1703 int line);
1704#define net_pkt_rx_alloc_on_iface(_iface, _timeout) \
1705 net_pkt_rx_alloc_on_iface_debug(_iface, _timeout, \
1706 __func__, __LINE__)
1707
1708int net_pkt_alloc_buffer_debug(struct net_pkt *pkt,
1709 size_t size,
1710 enum net_ip_protocol proto,
1711 k_timeout_t timeout,
1712 const char *caller, int line);
1713#define net_pkt_alloc_buffer(_pkt, _size, _proto, _timeout) \
1714 net_pkt_alloc_buffer_debug(_pkt, _size, _proto, _timeout, \
1715 __func__, __LINE__)
1716
1717int net_pkt_alloc_buffer_raw_debug(struct net_pkt *pkt, size_t size,
1718 k_timeout_t timeout,
1719 const char *caller, int line);
1720#define net_pkt_alloc_buffer_raw(_pkt, _size, _timeout) \
1721 net_pkt_alloc_buffer_raw_debug(_pkt, _size, _timeout, \
1722 __func__, __LINE__)
1723
1724struct net_pkt *net_pkt_alloc_with_buffer_debug(struct net_if *iface,
1725 size_t size,
1726 sa_family_t family,
1727 enum net_ip_protocol proto,
1728 k_timeout_t timeout,
1729 const char *caller,
1730 int line);
1731#define net_pkt_alloc_with_buffer(_iface, _size, _family, \
1732 _proto, _timeout) \
1733 net_pkt_alloc_with_buffer_debug(_iface, _size, _family, \
1734 _proto, _timeout, \
1735 __func__, __LINE__)
1736
1737struct net_pkt *net_pkt_rx_alloc_with_buffer_debug(struct net_if *iface,
1738 size_t size,
1739 sa_family_t family,
1740 enum net_ip_protocol proto,
1741 k_timeout_t timeout,
1742 const char *caller,
1743 int line);
1744#define net_pkt_rx_alloc_with_buffer(_iface, _size, _family, \
1745 _proto, _timeout) \
1746 net_pkt_rx_alloc_with_buffer_debug(_iface, _size, _family, \
1747 _proto, _timeout, \
1748 __func__, __LINE__)
1749#endif /* NET_PKT_DEBUG_ENABLED */
1762#if !defined(NET_PKT_DEBUG_ENABLED)
1764#endif
1765
1780#if !defined(NET_PKT_DEBUG_ENABLED)
1781struct net_pkt *net_pkt_alloc_from_slab(struct k_mem_slab *slab,
1782 k_timeout_t timeout);
1783#endif
1784
1795#if !defined(NET_PKT_DEBUG_ENABLED)
1797#endif
1798
1807#if !defined(NET_PKT_DEBUG_ENABLED)
1809 k_timeout_t timeout);
1810
1811/* Same as above but specifically for RX packet */
1813 k_timeout_t timeout);
1814#endif
1815
1831#if !defined(NET_PKT_DEBUG_ENABLED)
1833 size_t size,
1834 enum net_ip_protocol proto,
1835 k_timeout_t timeout);
1836#endif
1837
1851#if !defined(NET_PKT_DEBUG_ENABLED)
1852int net_pkt_alloc_buffer_raw(struct net_pkt *pkt, size_t size,
1853 k_timeout_t timeout);
1854#endif
1855
1867#if !defined(NET_PKT_DEBUG_ENABLED)
1869 size_t size,
1870 sa_family_t family,
1871 enum net_ip_protocol proto,
1872 k_timeout_t timeout);
1873
1874/* Same as above but specifically for RX packet */
1876 size_t size,
1877 sa_family_t family,
1878 enum net_ip_protocol proto,
1879 k_timeout_t timeout);
1880#endif
1881
1888void net_pkt_append_buffer(struct net_pkt *pkt, struct net_buf *buffer);
1889
1901
1918 enum net_ip_protocol proto);
1919
1929
1944int net_pkt_remove_tail(struct net_pkt *pkt, size_t length);
1945
1954
1961static inline void net_pkt_cursor_backup(struct net_pkt *pkt,
1962 struct net_pkt_cursor *backup)
1963{
1964 backup->buf = pkt->cursor.buf;
1965 backup->pos = pkt->cursor.pos;
1966}
1967
1974static inline void net_pkt_cursor_restore(struct net_pkt *pkt,
1975 struct net_pkt_cursor *backup)
1976{
1977 pkt->cursor.buf = backup->buf;
1978 pkt->cursor.pos = backup->pos;
1979}
1980
1988static inline void *net_pkt_cursor_get_pos(struct net_pkt *pkt)
1989{
1990 return pkt->cursor.pos;
1991}
1992
2013int net_pkt_skip(struct net_pkt *pkt, size_t length);
2014
2029int net_pkt_memset(struct net_pkt *pkt, int byte, size_t length);
2030
2044int net_pkt_copy(struct net_pkt *pkt_dst,
2045 struct net_pkt *pkt_src,
2046 size_t length);
2047
2057struct net_pkt *net_pkt_clone(struct net_pkt *pkt, k_timeout_t timeout);
2058
2068struct net_pkt *net_pkt_rx_clone(struct net_pkt *pkt, k_timeout_t timeout);
2069
2079 k_timeout_t timeout);
2080
2094int net_pkt_read(struct net_pkt *pkt, void *data, size_t length);
2095
2096/* Read uint8_t data data a net_pkt */
2097static inline int net_pkt_read_u8(struct net_pkt *pkt, uint8_t *data)
2098{
2099 return net_pkt_read(pkt, data, 1);
2100}
2101
2114int net_pkt_read_be16(struct net_pkt *pkt, uint16_t *data);
2115
2128int net_pkt_read_le16(struct net_pkt *pkt, uint16_t *data);
2129
2142int net_pkt_read_be32(struct net_pkt *pkt, uint32_t *data);
2143
2157int net_pkt_write(struct net_pkt *pkt, const void *data, size_t length);
2158
2159/* Write uint8_t data into a net_pkt. */
2160static inline int net_pkt_write_u8(struct net_pkt *pkt, uint8_t data)
2161{
2162 return net_pkt_write(pkt, &data, sizeof(uint8_t));
2163}
2164
2165/* Write uint16_t big endian data into a net_pkt. */
2166static inline int net_pkt_write_be16(struct net_pkt *pkt, uint16_t data)
2167{
2168 uint16_t data_be16 = htons(data);
2169
2170 return net_pkt_write(pkt, &data_be16, sizeof(uint16_t));
2171}
2172
2173/* Write uint32_t big endian data into a net_pkt. */
2174static inline int net_pkt_write_be32(struct net_pkt *pkt, uint32_t data)
2175{
2176 uint32_t data_be32 = htonl(data);
2177
2178 return net_pkt_write(pkt, &data_be32, sizeof(uint32_t));
2179}
2180
2181/* Write uint32_t little endian data into a net_pkt. */
2182static inline int net_pkt_write_le32(struct net_pkt *pkt, uint32_t data)
2183{
2184 uint32_t data_le32 = sys_cpu_to_le32(data);
2185
2186 return net_pkt_write(pkt, &data_le32, sizeof(uint32_t));
2187}
2188
2189/* Write uint16_t little endian data into a net_pkt. */
2190static inline int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
2191{
2192 uint16_t data_le16 = sys_cpu_to_le16(data);
2193
2194 return net_pkt_write(pkt, &data_le16, sizeof(uint16_t));
2195}
2196
2205
2218int net_pkt_update_length(struct net_pkt *pkt, size_t length);
2219
2232int net_pkt_pull(struct net_pkt *pkt, size_t length);
2233
2243
2255bool net_pkt_is_contiguous(struct net_pkt *pkt, size_t size);
2256
2266
2268#if !defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2269 void *data;
2270#endif
2271 const size_t size;
2272};
2273
2274#if defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2275#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2276 struct net_pkt_data_access _name = { \
2277 .size = sizeof(_type), \
2278 }
2279
2280#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2281 NET_PKT_DATA_ACCESS_DEFINE(_name, _type)
2282
2283#else
2284#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2285 _type _hdr_##_name; \
2286 struct net_pkt_data_access _name = { \
2287 .data = &_hdr_##_name, \
2288 .size = sizeof(_type), \
2289 }
2290
2291#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2292 struct net_pkt_data_access _name = { \
2293 .data = NULL, \
2294 .size = sizeof(_type), \
2295 }
2296
2297#endif /* CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS */
2298
2312void *net_pkt_get_data(struct net_pkt *pkt,
2313 struct net_pkt_data_access *access);
2314
2329 struct net_pkt_data_access *access);
2330
2335static inline int net_pkt_acknowledge_data(struct net_pkt *pkt,
2336 struct net_pkt_data_access *access)
2337{
2338 return net_pkt_skip(pkt, access->size);
2339}
2340
2345#ifdef __cplusplus
2346}
2347#endif
2348
2349#endif /* ZEPHYR_INCLUDE_NET_NET_PKT_H_ */
long atomic_t
Definition: atomic_types.h:15
#define ALWAYS_INLINE
Definition: common.h:129
VLAN specific definitions.
#define NSEC_PER_SEC
number of nanoseconds per second
Definition: sys_clock.h:107
unsigned short int sa_family_t
Socket address family type.
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
Protocol numbers from IANA/BSD.
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:2471
static struct net_if * net_context_get_iface(struct net_context *context)
Get network interface for this context.
Definition: net_context.h:690
static struct net_linkaddr * net_if_get_link_addr(struct net_if *iface)
Get an network interface's link address.
Definition: net_if.h:991
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:1836
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:2174
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:1485
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.
int net_pkt_alloc_buffer_raw(struct net_pkt *pkt, size_t size, k_timeout_t timeout)
Allocate buffer for a net_pkt, of specified size, w/o any additional preconditions.
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.
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:2166
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:2160
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.
static void * net_pkt_cursor_get_pos(struct net_pkt *pkt)
Returns current position of the cursor.
Definition: net_pkt.h:1988
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:1961
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)
Acknowledge previously contiguous data taken from a network packet Packet needs to be set to overwrit...
Definition: net_pkt.h:2335
static int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
Definition: net_pkt.h:2190
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:1974
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.
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:2182
struct net_buf * net_pkt_get_reserve_rx_data(size_t min_len, k_timeout_t timeout)
Get RX DATA buffer from pool.
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:2097
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)
Get the contiguous buffer space.
int64_t net_time_t
Any occurrence of net_time_t specifies a concept of nanosecond resolution scalar time span,...
Definition: net_time.h:101
static net_time_t net_ptp_time_to_ns(struct net_ptp_time *ts)
Convert a PTP timestamp to a nanosecond precision timestamp, both related to the local network refere...
Definition: ptp_time.h:193
static struct net_ptp_time ns_to_net_ptp_time(net_time_t nsec)
Convert a nanosecond precision timestamp to a PTP timestamp, both related to the local network refere...
Definition: ptp_time.h:214
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:124
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
Unspecified VLAN tag value.
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.
Buffer management.
Network context definitions.
Network core definitions.
Public API for network interface.
IPv6 and IPv4 definitions.
Public API for network link address.
Representation of nanosecond resolution elapsed time and timestamps in the network stack.
flags
Definition: parser.h:96
Public functions for the Precision Time Protocol time specification.
__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)
IPv6 address struct.
Definition: net_ip.h:139
Kernel timeout type.
Definition: sys_clock.h:65
Network buffer pool representation.
Definition: buf.h:976
Network buffer representation.
Definition: buf.h:910
uint8_t * data
Pointer to the start of data in the buffer.
Definition: buf.h:936
uint8_t user_data[]
System metadata for this buffer.
Definition: buf.h:955
uint16_t len
Length of the data behind the data pointer.
Definition: buf.h:939
Note that we do not store the actual source IP address in the context because the address is already ...
Definition: net_context.h:201
Network Interface structure.
Definition: net_if.h:615
Hardware link address structure.
Definition: net_linkaddr.h:67
uint8_t * addr
The array of byte representing the address.
Definition: net_linkaddr.h:69
uint8_t type
What kind of address is this for.
Definition: net_linkaddr.h:75
Definition: net_pkt.h:50
uint8_t * pos
Current position in the data buffer of the net_buf.
Definition: net_pkt.h:54
struct net_buf * buf
Current net_buf pointer by the cursor.
Definition: net_pkt.h:52
Definition: net_pkt.h:2267
const size_t size
Definition: net_pkt.h:2271
void * data
Definition: net_pkt.h:2269
Network packet.
Definition: net_pkt.h:63
struct net_buf * frags
Definition: net_pkt.h:75
struct net_context * context
Network connection context.
Definition: net_pkt.h:83
struct net_pkt_cursor cursor
Internal buffer iterator used for reading/writing.
Definition: net_pkt.h:80
struct net_if * iface
Network interface.
Definition: net_pkt.h:86
intptr_t fifo
The fifo is used by RX/TX threads and by socket layer.
Definition: net_pkt.h:68
struct net_buf * buffer
Definition: net_pkt.h:76
struct k_mem_slab * slab
Slab pointer from where it belongs to.
Definition: net_pkt.h:71
(Generalized) Precision Time Protocol Timestamp format.
Definition: ptp_time.h:109
uint32_t nanosecond
Nanoseconds.
Definition: ptp_time.h:127
uint64_t second
Definition: ptp_time.h:123
Generic sockaddr struct.
Definition: net_ip.h:347
Definition: stat.h:92
#define sys_cpu_to_le32(val)
Convert 32-bit integer from host endianness to little-endian.
Definition: byteorder.h:261
#define sys_cpu_to_le16(val)
Convert 16-bit integer from host endianness to little-endian.
Definition: byteorder.h:257