Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
51/* buffer cursor used in net_pkt */
52struct net_pkt_cursor {
54 struct net_buf *buf;
56 uint8_t *pos;
57};
58
67struct net_pkt {
73
75 struct k_mem_slab *slab;
76
78 union {
79 struct net_buf *frags;
80 struct net_buf *buffer;
81 };
82
84 struct net_pkt_cursor cursor;
85
88
90 struct net_if *iface;
91
94#if defined(CONFIG_NET_TCP)
96 sys_snode_t next;
97#endif
98#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
99 struct net_if *orig_iface; /* Original network interface */
100#endif
101
102#if defined(CONFIG_NET_PKT_TIMESTAMP) || defined(CONFIG_NET_PKT_TXTIME)
121 struct net_ptp_time timestamp;
122#endif
123
124#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
125 struct {
127 uint32_t create_time;
128
129#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
130 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
136 struct {
137 uint32_t stat[NET_PKT_DETAIL_STATS_COUNT];
138 int count;
139 } detail;
140#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
141 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
142 };
143#endif /* CONFIG_NET_PKT_RXTIME_STATS || CONFIG_NET_PKT_TXTIME_STATS */
144
146 atomic_t atomic_ref;
147
148 /* Filled by layer 2 when network packet is received. */
149 struct net_linkaddr lladdr_src;
150 struct net_linkaddr lladdr_dst;
151 uint16_t ll_proto_type;
152
153#if defined(CONFIG_NET_IP)
154 uint8_t ip_hdr_len; /* pre-filled in order to avoid func call */
155#endif
156
157 uint8_t overwrite : 1; /* Is packet content being overwritten? */
158 uint8_t eof : 1; /* Last packet before EOF */
159 uint8_t ptp_pkt : 1; /* For outgoing packet: is this packet
160 * a L2 PTP packet.
161 * Used only if defined (CONFIG_NET_L2_PTP)
162 */
163 uint8_t forwarding : 1; /* Are we forwarding this pkt
164 * Used only if defined(CONFIG_NET_ROUTE)
165 */
166 uint8_t family : 3; /* Address family, see net_ip.h */
167
168 /* bitfield byte alignment boundary */
169
170#if defined(CONFIG_NET_IPV4_ACD)
171 uint8_t ipv4_acd_arp_msg : 1; /* Is this pkt IPv4 conflict detection ARP
172 * message.
173 * Note: family needs to be
174 * AF_INET.
175 */
176#endif
177#if defined(CONFIG_NET_LLDP)
178 uint8_t lldp_pkt : 1; /* Is this pkt an LLDP message.
179 * Note: family needs to be
180 * AF_UNSPEC.
181 */
182#endif
183 uint8_t ppp_msg : 1; /* This is a PPP message */
184 uint8_t captured : 1; /* Set to 1 if this packet is already being
185 * captured
186 */
187 uint8_t l2_bridged : 1; /* set to 1 if this packet comes from a bridge
188 * and already contains its L2 header to be
189 * preserved. Useful only if
190 * defined(CONFIG_NET_ETHERNET_BRIDGE).
191 */
192 uint8_t l2_processed : 1; /* Set to 1 if this packet has already been
193 * processed by the L2
194 */
195 uint8_t chksum_done : 1; /* Checksum has already been computed for
196 * the packet.
197 */
198#if defined(CONFIG_NET_IP_FRAGMENT)
199 uint8_t ip_reassembled : 1; /* Packet is a reassembled IP packet. */
200#endif
201#if defined(CONFIG_NET_PKT_TIMESTAMP)
202 uint8_t tx_timestamping : 1;
203 uint8_t rx_timestamping : 1;
204#endif
205 /* bitfield byte alignment boundary */
206
207#if defined(CONFIG_NET_IP)
208 union {
209 /* IPv6 hop limit or IPv4 ttl for this network packet.
210 * The value is shared between IPv6 and IPv4.
211 */
212#if defined(CONFIG_NET_IPV6)
213 uint8_t ipv6_hop_limit;
214#endif
215#if defined(CONFIG_NET_IPV4)
216 uint8_t ipv4_ttl;
217#endif
218 };
219
220 union {
221#if defined(CONFIG_NET_IPV4)
222 uint8_t ipv4_opts_len; /* length of IPv4 header options */
223#endif
224#if defined(CONFIG_NET_IPV6)
225 uint16_t ipv6_ext_len; /* length of extension headers */
226#endif
227 };
228
229#if defined(CONFIG_NET_IP_FRAGMENT)
230 union {
231#if defined(CONFIG_NET_IPV4_FRAGMENT)
232 struct {
233 uint16_t flags; /* Fragment offset and M (More Fragment) flag */
234 uint16_t id; /* Fragment ID */
235 } ipv4_fragment;
236#endif /* CONFIG_NET_IPV4_FRAGMENT */
237#if defined(CONFIG_NET_IPV6_FRAGMENT)
238 struct {
239 uint16_t flags; /* Fragment offset and M (More Fragment) flag */
240 uint32_t id; /* Fragment id */
241 uint16_t hdr_start; /* Where starts the fragment header */
242 } ipv6_fragment;
243#endif /* CONFIG_NET_IPV6_FRAGMENT */
244 };
245#endif /* CONFIG_NET_IP_FRAGMENT */
246
247#if defined(CONFIG_NET_IPV6)
248 /* Where is the start of the last header before payload data
249 * in IPv6 packet. This is offset value from start of the IPv6
250 * packet. Note that this value should be updated by who ever
251 * adds IPv6 extension headers to the network packet.
252 */
253 uint16_t ipv6_prev_hdr_start;
254
255 uint8_t ipv6_ext_opt_len; /* IPv6 ND option length */
256 uint8_t ipv6_next_hdr; /* What is the very first next header */
257#endif /* CONFIG_NET_IPV6 */
258
259#if defined(CONFIG_NET_IP_DSCP_ECN)
261 uint8_t ip_dscp : 6;
262
264 uint8_t ip_ecn : 2;
265#endif /* CONFIG_NET_IP_DSCP_ECN */
266#endif /* CONFIG_NET_IP */
267
268#if defined(CONFIG_NET_VLAN)
269 /* VLAN TCI (Tag Control Information). This contains the Priority
270 * Code Point (PCP), Drop Eligible Indicator (DEI) and VLAN
271 * Identifier (VID, called more commonly VLAN tag). This value is
272 * kept in host byte order.
273 */
274 uint16_t vlan_tci;
275#endif /* CONFIG_NET_VLAN */
276
277#if defined(NET_PKT_HAS_CONTROL_BLOCK)
278 /* TODO: Evolve this into a union of orthogonal
279 * control block declarations if further L2
280 * stacks require L2-specific attributes.
281 */
282#if defined(CONFIG_IEEE802154)
283 /* The following structure requires a 4-byte alignment
284 * boundary to avoid padding.
285 */
286 struct net_pkt_cb_ieee802154 cb;
287#endif /* CONFIG_IEEE802154 */
288#endif /* NET_PKT_HAS_CONTROL_BLOCK */
289
293 uint8_t priority;
294
295#if defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_L2_IPIP)
296 /* Remote address of the recived packet. This is only used by
297 * network interfaces with an offloaded TCP/IP stack, or if we
298 * have network tunneling in use.
299 */
300 union {
301 struct sockaddr remote;
302
303 /* This will make sure that there is enough storage to store
304 * the address struct. The access to value is via remote
305 * address.
306 */
307 struct sockaddr_storage remote_storage;
308 };
309#endif /* CONFIG_NET_OFFLOAD */
310
311#if defined(CONFIG_NET_CAPTURE_COOKED_MODE)
312 /* Tell the capture api that this is a captured packet */
313 uint8_t cooked_mode_pkt : 1;
314#endif /* CONFIG_NET_CAPTURE_COOKED_MODE */
315
316 /* @endcond */
317};
318
321/* The interface real ll address */
322static inline struct net_linkaddr *net_pkt_lladdr_if(struct net_pkt *pkt)
323{
324 return net_if_get_link_addr(pkt->iface);
325}
326
327static inline struct net_context *net_pkt_context(struct net_pkt *pkt)
328{
329 return pkt->context;
330}
331
332static inline void net_pkt_set_context(struct net_pkt *pkt,
333 struct net_context *ctx)
334{
335 pkt->context = ctx;
336}
337
338static inline struct net_if *net_pkt_iface(struct net_pkt *pkt)
339{
340 return pkt->iface;
341}
342
343static inline void net_pkt_set_iface(struct net_pkt *pkt, struct net_if *iface)
344{
345 pkt->iface = iface;
346
347 /* If the network interface is set in pkt, then also set the type of
348 * the network address that is stored in pkt. This is done here so
349 * that the address type is properly set and is not forgotten.
350 */
351 if (iface) {
352 uint8_t type = net_if_get_link_addr(iface)->type;
353
354 pkt->lladdr_src.type = type;
355 pkt->lladdr_dst.type = type;
356 }
357}
358
359static inline struct net_if *net_pkt_orig_iface(struct net_pkt *pkt)
360{
361#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
362 return pkt->orig_iface;
363#else
364 return pkt->iface;
365#endif
366}
367
368static inline void net_pkt_set_orig_iface(struct net_pkt *pkt,
369 struct net_if *iface)
370{
371#if defined(CONFIG_NET_ROUTING) || defined(CONFIG_NET_ETHERNET_BRIDGE)
372 pkt->orig_iface = iface;
373#endif
374}
375
376static inline uint8_t net_pkt_family(struct net_pkt *pkt)
377{
378 return pkt->family;
379}
380
381static inline void net_pkt_set_family(struct net_pkt *pkt, uint8_t family)
382{
383 pkt->family = family;
384}
385
386static inline bool net_pkt_is_ptp(struct net_pkt *pkt)
387{
388 return !!(pkt->ptp_pkt);
389}
390
391static inline void net_pkt_set_ptp(struct net_pkt *pkt, bool is_ptp)
392{
393 pkt->ptp_pkt = is_ptp;
394}
395
396static inline bool net_pkt_is_tx_timestamping(struct net_pkt *pkt)
397{
398#if defined(CONFIG_NET_PKT_TIMESTAMP)
399 return !!(pkt->tx_timestamping);
400#else
401 return false;
402#endif
403}
404
405static inline void net_pkt_set_tx_timestamping(struct net_pkt *pkt, bool is_timestamping)
406{
407#if defined(CONFIG_NET_PKT_TIMESTAMP)
408 pkt->tx_timestamping = is_timestamping;
409#endif
410}
411
412static inline bool net_pkt_is_rx_timestamping(struct net_pkt *pkt)
413{
414#if defined(CONFIG_NET_PKT_TIMESTAMP)
415 return !!(pkt->rx_timestamping);
416#else
417 return false;
418#endif
419}
420
421static inline void net_pkt_set_rx_timestamping(struct net_pkt *pkt, bool is_timestamping)
422{
423#if defined(CONFIG_NET_PKT_TIMESTAMP)
424 pkt->rx_timestamping = is_timestamping;
425#endif
426}
427
428static inline bool net_pkt_is_captured(struct net_pkt *pkt)
429{
430 return !!(pkt->captured);
431}
432
433static inline void net_pkt_set_captured(struct net_pkt *pkt, bool is_captured)
434{
435 pkt->captured = is_captured;
436}
437
438static inline bool net_pkt_is_l2_bridged(struct net_pkt *pkt)
439{
440 return IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE) ? !!(pkt->l2_bridged) : 0;
441}
442
443static inline void net_pkt_set_l2_bridged(struct net_pkt *pkt, bool is_l2_bridged)
444{
445 if (IS_ENABLED(CONFIG_NET_ETHERNET_BRIDGE)) {
446 pkt->l2_bridged = is_l2_bridged;
447 }
448}
449
450static inline bool net_pkt_is_l2_processed(struct net_pkt *pkt)
451{
452 return !!(pkt->l2_processed);
453}
454
455static inline void net_pkt_set_l2_processed(struct net_pkt *pkt,
456 bool is_l2_processed)
457{
458 pkt->l2_processed = is_l2_processed;
459}
460
461static inline bool net_pkt_is_chksum_done(struct net_pkt *pkt)
462{
463 return !!(pkt->chksum_done);
464}
465
466static inline void net_pkt_set_chksum_done(struct net_pkt *pkt,
467 bool is_chksum_done)
468{
469 pkt->chksum_done = is_chksum_done;
470}
471
472static inline uint8_t net_pkt_ip_hdr_len(struct net_pkt *pkt)
473{
474#if defined(CONFIG_NET_IP)
475 return pkt->ip_hdr_len;
476#else
477 return 0;
478#endif
479}
480
481static inline void net_pkt_set_ip_hdr_len(struct net_pkt *pkt, uint8_t len)
482{
483#if defined(CONFIG_NET_IP)
484 pkt->ip_hdr_len = len;
485#endif
486}
487
488static inline uint8_t net_pkt_ip_dscp(struct net_pkt *pkt)
489{
490#if defined(CONFIG_NET_IP_DSCP_ECN)
491 return pkt->ip_dscp;
492#else
493 return 0;
494#endif
495}
496
497static inline void net_pkt_set_ip_dscp(struct net_pkt *pkt, uint8_t dscp)
498{
499#if defined(CONFIG_NET_IP_DSCP_ECN)
500 pkt->ip_dscp = dscp;
501#endif
502}
503
504static inline uint8_t net_pkt_ip_ecn(struct net_pkt *pkt)
505{
506#if defined(CONFIG_NET_IP_DSCP_ECN)
507 return pkt->ip_ecn;
508#else
509 return 0;
510#endif
511}
512
513static inline void net_pkt_set_ip_ecn(struct net_pkt *pkt, uint8_t ecn)
514{
515#if defined(CONFIG_NET_IP_DSCP_ECN)
516 pkt->ip_ecn = ecn;
517#endif
518}
519
520static inline uint8_t net_pkt_eof(struct net_pkt *pkt)
521{
522 return pkt->eof;
523}
524
525static inline void net_pkt_set_eof(struct net_pkt *pkt, bool eof)
526{
527 pkt->eof = eof;
528}
529
530static inline bool net_pkt_forwarding(struct net_pkt *pkt)
531{
532 return !!(pkt->forwarding);
533}
534
535static inline void net_pkt_set_forwarding(struct net_pkt *pkt, bool forward)
536{
537 pkt->forwarding = forward;
538}
539
540#if defined(CONFIG_NET_IPV4)
541static inline uint8_t net_pkt_ipv4_ttl(struct net_pkt *pkt)
542{
543 return pkt->ipv4_ttl;
544}
545
546static inline void net_pkt_set_ipv4_ttl(struct net_pkt *pkt,
547 uint8_t ttl)
548{
549 pkt->ipv4_ttl = ttl;
550}
551
552static inline uint8_t net_pkt_ipv4_opts_len(struct net_pkt *pkt)
553{
554 return pkt->ipv4_opts_len;
555}
556
557static inline void net_pkt_set_ipv4_opts_len(struct net_pkt *pkt,
558 uint8_t opts_len)
559{
560 pkt->ipv4_opts_len = opts_len;
561}
562#else
563static inline uint8_t net_pkt_ipv4_ttl(struct net_pkt *pkt)
564{
565 ARG_UNUSED(pkt);
566
567 return 0;
568}
569
570static inline void net_pkt_set_ipv4_ttl(struct net_pkt *pkt,
571 uint8_t ttl)
572{
573 ARG_UNUSED(pkt);
574 ARG_UNUSED(ttl);
575}
576
577static inline uint8_t net_pkt_ipv4_opts_len(struct net_pkt *pkt)
578{
579 ARG_UNUSED(pkt);
580 return 0;
581}
582
583static inline void net_pkt_set_ipv4_opts_len(struct net_pkt *pkt,
584 uint8_t opts_len)
585{
586 ARG_UNUSED(pkt);
587 ARG_UNUSED(opts_len);
588}
589#endif
590
591#if defined(CONFIG_NET_IPV6)
592static inline uint8_t net_pkt_ipv6_ext_opt_len(struct net_pkt *pkt)
593{
594 return pkt->ipv6_ext_opt_len;
595}
596
597static inline void net_pkt_set_ipv6_ext_opt_len(struct net_pkt *pkt,
598 uint8_t len)
599{
600 pkt->ipv6_ext_opt_len = len;
601}
602
603static inline uint8_t net_pkt_ipv6_next_hdr(struct net_pkt *pkt)
604{
605 return pkt->ipv6_next_hdr;
606}
607
608static inline void net_pkt_set_ipv6_next_hdr(struct net_pkt *pkt,
609 uint8_t next_hdr)
610{
611 pkt->ipv6_next_hdr = next_hdr;
612}
613
614static inline uint16_t net_pkt_ipv6_ext_len(struct net_pkt *pkt)
615{
616 return pkt->ipv6_ext_len;
617}
618
619static inline void net_pkt_set_ipv6_ext_len(struct net_pkt *pkt, uint16_t len)
620{
621 pkt->ipv6_ext_len = len;
622}
623
624static inline uint16_t net_pkt_ipv6_hdr_prev(struct net_pkt *pkt)
625{
626 return pkt->ipv6_prev_hdr_start;
627}
628
629static inline void net_pkt_set_ipv6_hdr_prev(struct net_pkt *pkt,
630 uint16_t offset)
631{
632 pkt->ipv6_prev_hdr_start = offset;
633}
634
635static inline uint8_t net_pkt_ipv6_hop_limit(struct net_pkt *pkt)
636{
637 return pkt->ipv6_hop_limit;
638}
639
640static inline void net_pkt_set_ipv6_hop_limit(struct net_pkt *pkt,
641 uint8_t hop_limit)
642{
643 pkt->ipv6_hop_limit = hop_limit;
644}
645#else /* CONFIG_NET_IPV6 */
646static inline uint8_t net_pkt_ipv6_ext_opt_len(struct net_pkt *pkt)
647{
648 ARG_UNUSED(pkt);
649
650 return 0;
651}
652
653static inline void net_pkt_set_ipv6_ext_opt_len(struct net_pkt *pkt,
654 uint8_t len)
655{
656 ARG_UNUSED(pkt);
657 ARG_UNUSED(len);
658}
659
660static inline uint8_t net_pkt_ipv6_next_hdr(struct net_pkt *pkt)
661{
662 ARG_UNUSED(pkt);
663
664 return 0;
665}
666
667static inline void net_pkt_set_ipv6_next_hdr(struct net_pkt *pkt,
668 uint8_t next_hdr)
669{
670 ARG_UNUSED(pkt);
671 ARG_UNUSED(next_hdr);
672}
673
674static inline uint16_t net_pkt_ipv6_ext_len(struct net_pkt *pkt)
675{
676 ARG_UNUSED(pkt);
677
678 return 0;
679}
680
681static inline void net_pkt_set_ipv6_ext_len(struct net_pkt *pkt, uint16_t len)
682{
683 ARG_UNUSED(pkt);
684 ARG_UNUSED(len);
685}
686
687static inline uint16_t net_pkt_ipv6_hdr_prev(struct net_pkt *pkt)
688{
689 ARG_UNUSED(pkt);
690
691 return 0;
692}
693
694static inline void net_pkt_set_ipv6_hdr_prev(struct net_pkt *pkt,
695 uint16_t offset)
696{
697 ARG_UNUSED(pkt);
698 ARG_UNUSED(offset);
699}
700
701static inline uint8_t net_pkt_ipv6_hop_limit(struct net_pkt *pkt)
702{
703 ARG_UNUSED(pkt);
704
705 return 0;
706}
707
708static inline void net_pkt_set_ipv6_hop_limit(struct net_pkt *pkt,
709 uint8_t hop_limit)
710{
711 ARG_UNUSED(pkt);
712 ARG_UNUSED(hop_limit);
713}
714#endif /* CONFIG_NET_IPV6 */
715
716static inline uint16_t net_pkt_ip_opts_len(struct net_pkt *pkt)
717{
718#if defined(CONFIG_NET_IPV6)
719 return pkt->ipv6_ext_len;
720#elif defined(CONFIG_NET_IPV4)
721 return pkt->ipv4_opts_len;
722#else
723 ARG_UNUSED(pkt);
724
725 return 0;
726#endif
727}
728
729#if defined(CONFIG_NET_IPV4_FRAGMENT)
730static inline uint16_t net_pkt_ipv4_fragment_offset(struct net_pkt *pkt)
731{
732 return (pkt->ipv4_fragment.flags & NET_IPV4_FRAGH_OFFSET_MASK) * 8;
733}
734
735static inline bool net_pkt_ipv4_fragment_more(struct net_pkt *pkt)
736{
737 return (pkt->ipv4_fragment.flags & NET_IPV4_MORE_FRAG_MASK) != 0;
738}
739
740static inline void net_pkt_set_ipv4_fragment_flags(struct net_pkt *pkt, uint16_t flags)
741{
742 pkt->ipv4_fragment.flags = flags;
743}
744
745static inline uint32_t net_pkt_ipv4_fragment_id(struct net_pkt *pkt)
746{
747 return pkt->ipv4_fragment.id;
748}
749
750static inline void net_pkt_set_ipv4_fragment_id(struct net_pkt *pkt, uint32_t id)
751{
752 pkt->ipv4_fragment.id = id;
753}
754#else /* CONFIG_NET_IPV4_FRAGMENT */
755static inline uint16_t net_pkt_ipv4_fragment_offset(struct net_pkt *pkt)
756{
757 ARG_UNUSED(pkt);
758
759 return 0;
760}
761
762static inline bool net_pkt_ipv4_fragment_more(struct net_pkt *pkt)
763{
764 ARG_UNUSED(pkt);
765
766 return 0;
767}
768
769static inline void net_pkt_set_ipv4_fragment_flags(struct net_pkt *pkt, uint16_t flags)
770{
771 ARG_UNUSED(pkt);
772 ARG_UNUSED(flags);
773}
774
775static inline uint32_t net_pkt_ipv4_fragment_id(struct net_pkt *pkt)
776{
777 ARG_UNUSED(pkt);
778
779 return 0;
780}
781
782static inline void net_pkt_set_ipv4_fragment_id(struct net_pkt *pkt, uint32_t id)
783{
784 ARG_UNUSED(pkt);
785 ARG_UNUSED(id);
786}
787#endif /* CONFIG_NET_IPV4_FRAGMENT */
788
789#if defined(CONFIG_NET_IPV6_FRAGMENT)
790static inline uint16_t net_pkt_ipv6_fragment_start(struct net_pkt *pkt)
791{
792 return pkt->ipv6_fragment.hdr_start;
793}
794
795static inline void net_pkt_set_ipv6_fragment_start(struct net_pkt *pkt,
796 uint16_t start)
797{
798 pkt->ipv6_fragment.hdr_start = start;
799}
800
801static inline uint16_t net_pkt_ipv6_fragment_offset(struct net_pkt *pkt)
802{
803 return pkt->ipv6_fragment.flags & NET_IPV6_FRAGH_OFFSET_MASK;
804}
805static inline bool net_pkt_ipv6_fragment_more(struct net_pkt *pkt)
806{
807 return (pkt->ipv6_fragment.flags & 0x01) != 0;
808}
809
810static inline void net_pkt_set_ipv6_fragment_flags(struct net_pkt *pkt,
812{
813 pkt->ipv6_fragment.flags = flags;
814}
815
816static inline uint32_t net_pkt_ipv6_fragment_id(struct net_pkt *pkt)
817{
818 return pkt->ipv6_fragment.id;
819}
820
821static inline void net_pkt_set_ipv6_fragment_id(struct net_pkt *pkt,
822 uint32_t id)
823{
824 pkt->ipv6_fragment.id = id;
825}
826#else /* CONFIG_NET_IPV6_FRAGMENT */
827static inline uint16_t net_pkt_ipv6_fragment_start(struct net_pkt *pkt)
828{
829 ARG_UNUSED(pkt);
830
831 return 0;
832}
833
834static inline void net_pkt_set_ipv6_fragment_start(struct net_pkt *pkt,
835 uint16_t start)
836{
837 ARG_UNUSED(pkt);
838 ARG_UNUSED(start);
839}
840
841static inline uint16_t net_pkt_ipv6_fragment_offset(struct net_pkt *pkt)
842{
843 ARG_UNUSED(pkt);
844
845 return 0;
846}
847
848static inline bool net_pkt_ipv6_fragment_more(struct net_pkt *pkt)
849{
850 ARG_UNUSED(pkt);
851
852 return 0;
853}
854
855static inline void net_pkt_set_ipv6_fragment_flags(struct net_pkt *pkt,
857{
858 ARG_UNUSED(pkt);
859 ARG_UNUSED(flags);
860}
861
862static inline uint32_t net_pkt_ipv6_fragment_id(struct net_pkt *pkt)
863{
864 ARG_UNUSED(pkt);
865
866 return 0;
867}
868
869static inline void net_pkt_set_ipv6_fragment_id(struct net_pkt *pkt,
870 uint32_t id)
871{
872 ARG_UNUSED(pkt);
873 ARG_UNUSED(id);
874}
875#endif /* CONFIG_NET_IPV6_FRAGMENT */
876
877#if defined(CONFIG_NET_IP_FRAGMENT)
878static inline bool net_pkt_is_ip_reassembled(struct net_pkt *pkt)
879{
880 return !!(pkt->ip_reassembled);
881}
882
883static inline void net_pkt_set_ip_reassembled(struct net_pkt *pkt,
884 bool reassembled)
885{
886 pkt->ip_reassembled = reassembled;
887}
888#else /* CONFIG_NET_IP_FRAGMENT */
889static inline bool net_pkt_is_ip_reassembled(struct net_pkt *pkt)
890{
891 ARG_UNUSED(pkt);
892
893 return false;
894}
895
896static inline void net_pkt_set_ip_reassembled(struct net_pkt *pkt,
897 bool reassembled)
898{
899 ARG_UNUSED(pkt);
900 ARG_UNUSED(reassembled);
901}
902#endif /* CONFIG_NET_IP_FRAGMENT */
903
904static inline uint8_t net_pkt_priority(struct net_pkt *pkt)
905{
906 return pkt->priority;
907}
908
909static inline void net_pkt_set_priority(struct net_pkt *pkt,
910 uint8_t priority)
911{
912 pkt->priority = priority;
913}
914
915#if defined(CONFIG_NET_CAPTURE_COOKED_MODE)
916static inline bool net_pkt_is_cooked_mode(struct net_pkt *pkt)
917{
918 return pkt->cooked_mode_pkt;
919}
920
921static inline void net_pkt_set_cooked_mode(struct net_pkt *pkt, bool value)
922{
923 pkt->cooked_mode_pkt = value;
924}
925#else
926static inline bool net_pkt_is_cooked_mode(struct net_pkt *pkt)
927{
928 ARG_UNUSED(pkt);
929
930 return false;
931}
932
933static inline void net_pkt_set_cooked_mode(struct net_pkt *pkt, bool value)
934{
935 ARG_UNUSED(pkt);
936 ARG_UNUSED(value);
937}
938#endif /* CONFIG_NET_CAPTURE_COOKED_MODE */
939
940#if defined(CONFIG_NET_VLAN)
941static inline uint16_t net_pkt_vlan_tag(struct net_pkt *pkt)
942{
943 return net_eth_vlan_get_vid(pkt->vlan_tci);
944}
945
946static inline void net_pkt_set_vlan_tag(struct net_pkt *pkt, uint16_t tag)
947{
948 pkt->vlan_tci = net_eth_vlan_set_vid(pkt->vlan_tci, tag);
949}
950
951static inline uint8_t net_pkt_vlan_priority(struct net_pkt *pkt)
952{
953 return net_eth_vlan_get_pcp(pkt->vlan_tci);
954}
955
956static inline void net_pkt_set_vlan_priority(struct net_pkt *pkt,
957 uint8_t priority)
958{
959 pkt->vlan_tci = net_eth_vlan_set_pcp(pkt->vlan_tci, priority);
960}
961
962static inline bool net_pkt_vlan_dei(struct net_pkt *pkt)
963{
964 return net_eth_vlan_get_dei(pkt->vlan_tci);
965}
966
967static inline void net_pkt_set_vlan_dei(struct net_pkt *pkt, bool dei)
968{
969 pkt->vlan_tci = net_eth_vlan_set_dei(pkt->vlan_tci, dei);
970}
971
972static inline void net_pkt_set_vlan_tci(struct net_pkt *pkt, uint16_t tci)
973{
974 pkt->vlan_tci = tci;
975}
976
977static inline uint16_t net_pkt_vlan_tci(struct net_pkt *pkt)
978{
979 return pkt->vlan_tci;
980}
981#else
982static inline uint16_t net_pkt_vlan_tag(struct net_pkt *pkt)
983{
984 return NET_VLAN_TAG_UNSPEC;
985}
986
987static inline void net_pkt_set_vlan_tag(struct net_pkt *pkt, uint16_t tag)
988{
989 ARG_UNUSED(pkt);
990 ARG_UNUSED(tag);
991}
992
993static inline uint8_t net_pkt_vlan_priority(struct net_pkt *pkt)
994{
995 ARG_UNUSED(pkt);
996 return 0;
997}
998
999static inline bool net_pkt_vlan_dei(struct net_pkt *pkt)
1000{
1001 return false;
1002}
1003
1004static inline void net_pkt_set_vlan_dei(struct net_pkt *pkt, bool dei)
1005{
1006 ARG_UNUSED(pkt);
1007 ARG_UNUSED(dei);
1008}
1009
1010static inline uint16_t net_pkt_vlan_tci(struct net_pkt *pkt)
1011{
1012 return NET_VLAN_TAG_UNSPEC; /* assumes priority is 0 */
1013}
1014
1015static inline void net_pkt_set_vlan_tci(struct net_pkt *pkt, uint16_t tci)
1016{
1017 ARG_UNUSED(pkt);
1018 ARG_UNUSED(tci);
1019}
1020#endif
1021
1022#if defined(CONFIG_NET_PKT_TIMESTAMP) || defined(CONFIG_NET_PKT_TXTIME)
1023static inline struct net_ptp_time *net_pkt_timestamp(struct net_pkt *pkt)
1024{
1025 return &pkt->timestamp;
1026}
1027
1028static inline void net_pkt_set_timestamp(struct net_pkt *pkt,
1029 struct net_ptp_time *timestamp)
1030{
1031 pkt->timestamp.second = timestamp->second;
1032 pkt->timestamp.nanosecond = timestamp->nanosecond;
1033}
1034
1035static inline net_time_t net_pkt_timestamp_ns(struct net_pkt *pkt)
1036{
1037 return net_ptp_time_to_ns(&pkt->timestamp);
1038}
1039
1040static inline void net_pkt_set_timestamp_ns(struct net_pkt *pkt, net_time_t timestamp)
1041{
1042 pkt->timestamp = ns_to_net_ptp_time(timestamp);
1043}
1044#else
1045static inline struct net_ptp_time *net_pkt_timestamp(struct net_pkt *pkt)
1046{
1047 ARG_UNUSED(pkt);
1048
1049 return NULL;
1050}
1051
1052static inline void net_pkt_set_timestamp(struct net_pkt *pkt,
1053 struct net_ptp_time *timestamp)
1054{
1055 ARG_UNUSED(pkt);
1056 ARG_UNUSED(timestamp);
1057}
1058
1059static inline net_time_t net_pkt_timestamp_ns(struct net_pkt *pkt)
1060{
1061 ARG_UNUSED(pkt);
1062
1063 return 0;
1064}
1065
1066static inline void net_pkt_set_timestamp_ns(struct net_pkt *pkt, net_time_t timestamp)
1067{
1068 ARG_UNUSED(pkt);
1069 ARG_UNUSED(timestamp);
1070}
1071#endif /* CONFIG_NET_PKT_TIMESTAMP || CONFIG_NET_PKT_TXTIME */
1072
1073#if defined(CONFIG_NET_PKT_RXTIME_STATS) || defined(CONFIG_NET_PKT_TXTIME_STATS)
1074static inline uint32_t net_pkt_create_time(struct net_pkt *pkt)
1075{
1076 return pkt->create_time;
1077}
1078
1079static inline void net_pkt_set_create_time(struct net_pkt *pkt,
1080 uint32_t create_time)
1081{
1082 pkt->create_time = create_time;
1083}
1084#else
1085static inline uint32_t net_pkt_create_time(struct net_pkt *pkt)
1086{
1087 ARG_UNUSED(pkt);
1088
1089 return 0U;
1090}
1091
1092static inline void net_pkt_set_create_time(struct net_pkt *pkt,
1093 uint32_t create_time)
1094{
1095 ARG_UNUSED(pkt);
1096 ARG_UNUSED(create_time);
1097}
1098#endif /* CONFIG_NET_PKT_RXTIME_STATS || CONFIG_NET_PKT_TXTIME_STATS */
1099
1103static inline uint64_t net_pkt_txtime(struct net_pkt *pkt)
1104{
1105#if defined(CONFIG_NET_PKT_TXTIME)
1106 return pkt->timestamp.second * NSEC_PER_SEC + pkt->timestamp.nanosecond;
1107#else
1108 ARG_UNUSED(pkt);
1109
1110 return 0;
1111#endif /* CONFIG_NET_PKT_TXTIME */
1112}
1113
1118static inline void net_pkt_set_txtime(struct net_pkt *pkt, uint64_t txtime)
1119{
1120#if defined(CONFIG_NET_PKT_TXTIME)
1121 pkt->timestamp.second = txtime / NSEC_PER_SEC;
1122 pkt->timestamp.nanosecond = txtime % NSEC_PER_SEC;
1123#else
1124 ARG_UNUSED(pkt);
1125 ARG_UNUSED(txtime);
1126#endif /* CONFIG_NET_PKT_TXTIME */
1127}
1128
1129#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) || \
1130 defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
1131static inline uint32_t *net_pkt_stats_tick(struct net_pkt *pkt)
1132{
1133 return pkt->detail.stat;
1134}
1135
1136static inline int net_pkt_stats_tick_count(struct net_pkt *pkt)
1137{
1138 return pkt->detail.count;
1139}
1140
1141static inline void net_pkt_stats_tick_reset(struct net_pkt *pkt)
1142{
1143 memset(&pkt->detail, 0, sizeof(pkt->detail));
1144}
1145
1146static ALWAYS_INLINE void net_pkt_set_stats_tick(struct net_pkt *pkt,
1147 uint32_t tick)
1148{
1149 if (pkt->detail.count >= NET_PKT_DETAIL_STATS_COUNT) {
1150 NET_ERR("Detail stats count overflow (%d >= %d)",
1151 pkt->detail.count, NET_PKT_DETAIL_STATS_COUNT);
1152 return;
1153 }
1154
1155 pkt->detail.stat[pkt->detail.count++] = tick;
1156}
1157
1158#define net_pkt_set_tx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
1159#define net_pkt_set_rx_stats_tick(pkt, tick) net_pkt_set_stats_tick(pkt, tick)
1160#else
1161static inline uint32_t *net_pkt_stats_tick(struct net_pkt *pkt)
1162{
1163 ARG_UNUSED(pkt);
1164
1165 return NULL;
1166}
1167
1168static inline int net_pkt_stats_tick_count(struct net_pkt *pkt)
1169{
1170 ARG_UNUSED(pkt);
1171
1172 return 0;
1173}
1174
1175static inline void net_pkt_stats_tick_reset(struct net_pkt *pkt)
1176{
1177 ARG_UNUSED(pkt);
1178}
1179
1180static inline void net_pkt_set_stats_tick(struct net_pkt *pkt, uint32_t tick)
1181{
1182 ARG_UNUSED(pkt);
1183 ARG_UNUSED(tick);
1184}
1185
1186#define net_pkt_set_tx_stats_tick(pkt, tick)
1187#define net_pkt_set_rx_stats_tick(pkt, tick)
1188#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
1189 CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
1190
1191static inline size_t net_pkt_get_len(struct net_pkt *pkt)
1192{
1193 return net_buf_frags_len(pkt->frags);
1194}
1195
1196static inline uint8_t *net_pkt_data(struct net_pkt *pkt)
1197{
1198 return pkt->frags->data;
1199}
1200
1201static inline uint8_t *net_pkt_ip_data(struct net_pkt *pkt)
1202{
1203 return pkt->frags->data;
1204}
1205
1206static inline bool net_pkt_is_empty(struct net_pkt *pkt)
1207{
1208 return !pkt->buffer || !net_pkt_data(pkt) || pkt->buffer->len == 0;
1209}
1210
1211static inline struct net_linkaddr *net_pkt_lladdr_src(struct net_pkt *pkt)
1212{
1213 return &pkt->lladdr_src;
1214}
1215
1216static inline struct net_linkaddr *net_pkt_lladdr_dst(struct net_pkt *pkt)
1217{
1218 return &pkt->lladdr_dst;
1219}
1220
1221static inline void net_pkt_lladdr_swap(struct net_pkt *pkt)
1222{
1223 uint8_t *addr = net_pkt_lladdr_src(pkt)->addr;
1224
1225 net_pkt_lladdr_src(pkt)->addr = net_pkt_lladdr_dst(pkt)->addr;
1226 net_pkt_lladdr_dst(pkt)->addr = addr;
1227}
1228
1229static inline void net_pkt_lladdr_clear(struct net_pkt *pkt)
1230{
1231 net_pkt_lladdr_src(pkt)->addr = NULL;
1232 net_pkt_lladdr_src(pkt)->len = 0U;
1233}
1234
1235static inline uint16_t net_pkt_ll_proto_type(struct net_pkt *pkt)
1236{
1237 return pkt->ll_proto_type;
1238}
1239
1240static inline void net_pkt_set_ll_proto_type(struct net_pkt *pkt, uint16_t type)
1241{
1242 pkt->ll_proto_type = type;
1243}
1244
1245#if defined(CONFIG_NET_IPV4_ACD)
1246static inline bool net_pkt_ipv4_acd(struct net_pkt *pkt)
1247{
1248 return !!(pkt->ipv4_acd_arp_msg);
1249}
1250
1251static inline void net_pkt_set_ipv4_acd(struct net_pkt *pkt,
1252 bool is_acd_arp_msg)
1253{
1254 pkt->ipv4_acd_arp_msg = is_acd_arp_msg;
1255}
1256#else /* CONFIG_NET_IPV4_ACD */
1257static inline bool net_pkt_ipv4_acd(struct net_pkt *pkt)
1258{
1259 ARG_UNUSED(pkt);
1260
1261 return false;
1262}
1263
1264static inline void net_pkt_set_ipv4_acd(struct net_pkt *pkt,
1265 bool is_acd_arp_msg)
1266{
1267 ARG_UNUSED(pkt);
1268 ARG_UNUSED(is_acd_arp_msg);
1269}
1270#endif /* CONFIG_NET_IPV4_ACD */
1271
1272#if defined(CONFIG_NET_LLDP)
1273static inline bool net_pkt_is_lldp(struct net_pkt *pkt)
1274{
1275 return !!(pkt->lldp_pkt);
1276}
1277
1278static inline void net_pkt_set_lldp(struct net_pkt *pkt, bool is_lldp)
1279{
1280 pkt->lldp_pkt = is_lldp;
1281}
1282#else
1283static inline bool net_pkt_is_lldp(struct net_pkt *pkt)
1284{
1285 ARG_UNUSED(pkt);
1286
1287 return false;
1288}
1289
1290static inline void net_pkt_set_lldp(struct net_pkt *pkt, bool is_lldp)
1291{
1292 ARG_UNUSED(pkt);
1293 ARG_UNUSED(is_lldp);
1294}
1295#endif /* CONFIG_NET_LLDP */
1296
1297#if defined(CONFIG_NET_L2_PPP)
1298static inline bool net_pkt_is_ppp(struct net_pkt *pkt)
1299{
1300 return !!(pkt->ppp_msg);
1301}
1302
1303static inline void net_pkt_set_ppp(struct net_pkt *pkt,
1304 bool is_ppp_msg)
1305{
1306 pkt->ppp_msg = is_ppp_msg;
1307}
1308#else /* CONFIG_NET_L2_PPP */
1309static inline bool net_pkt_is_ppp(struct net_pkt *pkt)
1310{
1311 ARG_UNUSED(pkt);
1312
1313 return false;
1314}
1315
1316static inline void net_pkt_set_ppp(struct net_pkt *pkt,
1317 bool is_ppp_msg)
1318{
1319 ARG_UNUSED(pkt);
1320 ARG_UNUSED(is_ppp_msg);
1321}
1322#endif /* CONFIG_NET_L2_PPP */
1323
1324#if defined(NET_PKT_HAS_CONTROL_BLOCK)
1325static inline void *net_pkt_cb(struct net_pkt *pkt)
1326{
1327 return &pkt->cb;
1328}
1329#else
1330static inline void *net_pkt_cb(struct net_pkt *pkt)
1331{
1332 ARG_UNUSED(pkt);
1333
1334 return NULL;
1335}
1336#endif
1337
1338#define NET_IPV6_HDR(pkt) ((struct net_ipv6_hdr *)net_pkt_ip_data(pkt))
1339#define NET_IPV4_HDR(pkt) ((struct net_ipv4_hdr *)net_pkt_ip_data(pkt))
1340
1341static inline void net_pkt_set_src_ipv6_addr(struct net_pkt *pkt)
1342{
1344 net_pkt_context(pkt)),
1345 (struct in6_addr *)NET_IPV6_HDR(pkt)->src);
1346}
1347
1348static inline void net_pkt_set_overwrite(struct net_pkt *pkt, bool overwrite)
1349{
1350 pkt->overwrite = overwrite;
1351}
1352
1353static inline bool net_pkt_is_being_overwritten(struct net_pkt *pkt)
1354{
1355 return !!(pkt->overwrite);
1356}
1357
1358#ifdef CONFIG_NET_PKT_FILTER
1359
1360bool net_pkt_filter_send_ok(struct net_pkt *pkt);
1361bool net_pkt_filter_recv_ok(struct net_pkt *pkt);
1362
1363#else
1364
1365static inline bool net_pkt_filter_send_ok(struct net_pkt *pkt)
1366{
1367 ARG_UNUSED(pkt);
1368
1369 return true;
1370}
1371
1372static inline bool net_pkt_filter_recv_ok(struct net_pkt *pkt)
1373{
1374 ARG_UNUSED(pkt);
1375
1376 return true;
1377}
1378
1379#endif /* CONFIG_NET_PKT_FILTER */
1380
1381#if defined(CONFIG_NET_PKT_FILTER) && \
1382 (defined(CONFIG_NET_PKT_FILTER_IPV4_HOOK) || defined(CONFIG_NET_PKT_FILTER_IPV6_HOOK))
1383
1384bool net_pkt_filter_ip_recv_ok(struct net_pkt *pkt);
1385
1386#else
1387
1388static inline bool net_pkt_filter_ip_recv_ok(struct net_pkt *pkt)
1389{
1390 ARG_UNUSED(pkt);
1391
1392 return true;
1393}
1394
1395#endif /* CONFIG_NET_PKT_FILTER_IPV4_HOOK || CONFIG_NET_PKT_FILTER_IPV6_HOOK */
1396
1397#if defined(CONFIG_NET_PKT_FILTER) && defined(CONFIG_NET_PKT_FILTER_LOCAL_IN_HOOK)
1398
1399bool net_pkt_filter_local_in_recv_ok(struct net_pkt *pkt);
1400
1401#else
1402
1403static inline bool net_pkt_filter_local_in_recv_ok(struct net_pkt *pkt)
1404{
1405 ARG_UNUSED(pkt);
1406
1407 return true;
1408}
1409
1410#endif /* CONFIG_NET_PKT_FILTER && CONFIG_NET_PKT_FILTER_LOCAL_IN_HOOK */
1411
1412#if defined(CONFIG_NET_OFFLOAD) || defined(CONFIG_NET_L2_IPIP)
1413static inline struct sockaddr *net_pkt_remote_address(struct net_pkt *pkt)
1414{
1415 return &pkt->remote;
1416}
1417
1418static inline void net_pkt_set_remote_address(struct net_pkt *pkt,
1419 struct sockaddr *address,
1420 socklen_t len)
1421{
1422 memcpy(&pkt->remote, address, len);
1423}
1424#endif /* CONFIG_NET_OFFLOAD || CONFIG_NET_L2_IPIP */
1425
1426/* @endcond */
1427
1441#define NET_PKT_SLAB_DEFINE(name, count) \
1442 K_MEM_SLAB_DEFINE(name, sizeof(struct net_pkt), count, 4)
1443
1446/* Backward compatibility macro */
1447#define NET_PKT_TX_SLAB_DEFINE(name, count) NET_PKT_SLAB_DEFINE(name, count)
1448
1464#define NET_PKT_DATA_POOL_DEFINE(name, count) \
1465 NET_BUF_POOL_DEFINE(name, count, CONFIG_NET_BUF_DATA_SIZE, \
1466 0, NULL)
1467
1470#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC) || \
1471 (CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG)
1472#define NET_PKT_DEBUG_ENABLED
1473#endif
1474
1475#if defined(NET_PKT_DEBUG_ENABLED)
1476
1477/* Debug versions of the net_pkt functions that are used when tracking
1478 * buffer usage.
1479 */
1480
1481struct net_buf *net_pkt_get_reserve_data_debug(struct net_buf_pool *pool,
1482 size_t min_len,
1483 k_timeout_t timeout,
1484 const char *caller,
1485 int line);
1486
1487#define net_pkt_get_reserve_data(pool, min_len, timeout) \
1488 net_pkt_get_reserve_data_debug(pool, min_len, timeout, __func__, __LINE__)
1489
1490struct net_buf *net_pkt_get_reserve_rx_data_debug(size_t min_len,
1491 k_timeout_t timeout,
1492 const char *caller,
1493 int line);
1494#define net_pkt_get_reserve_rx_data(min_len, timeout) \
1495 net_pkt_get_reserve_rx_data_debug(min_len, timeout, __func__, __LINE__)
1496
1497struct net_buf *net_pkt_get_reserve_tx_data_debug(size_t min_len,
1498 k_timeout_t timeout,
1499 const char *caller,
1500 int line);
1501#define net_pkt_get_reserve_tx_data(min_len, timeout) \
1502 net_pkt_get_reserve_tx_data_debug(min_len, timeout, __func__, __LINE__)
1503
1504struct net_buf *net_pkt_get_frag_debug(struct net_pkt *pkt, size_t min_len,
1505 k_timeout_t timeout,
1506 const char *caller, int line);
1507#define net_pkt_get_frag(pkt, min_len, timeout) \
1508 net_pkt_get_frag_debug(pkt, min_len, timeout, __func__, __LINE__)
1509
1510void net_pkt_unref_debug(struct net_pkt *pkt, const char *caller, int line);
1511#define net_pkt_unref(pkt) net_pkt_unref_debug(pkt, __func__, __LINE__)
1512
1513struct net_pkt *net_pkt_ref_debug(struct net_pkt *pkt, const char *caller,
1514 int line);
1515#define net_pkt_ref(pkt) net_pkt_ref_debug(pkt, __func__, __LINE__)
1516
1517struct net_buf *net_pkt_frag_ref_debug(struct net_buf *frag,
1518 const char *caller, int line);
1519#define net_pkt_frag_ref(frag) net_pkt_frag_ref_debug(frag, __func__, __LINE__)
1520
1521void net_pkt_frag_unref_debug(struct net_buf *frag,
1522 const char *caller, int line);
1523#define net_pkt_frag_unref(frag) \
1524 net_pkt_frag_unref_debug(frag, __func__, __LINE__)
1525
1526struct net_buf *net_pkt_frag_del_debug(struct net_pkt *pkt,
1527 struct net_buf *parent,
1528 struct net_buf *frag,
1529 const char *caller, int line);
1530#define net_pkt_frag_del(pkt, parent, frag) \
1531 net_pkt_frag_del_debug(pkt, parent, frag, __func__, __LINE__)
1532
1533void net_pkt_frag_add_debug(struct net_pkt *pkt, struct net_buf *frag,
1534 const char *caller, int line);
1535#define net_pkt_frag_add(pkt, frag) \
1536 net_pkt_frag_add_debug(pkt, frag, __func__, __LINE__)
1537
1538void net_pkt_frag_insert_debug(struct net_pkt *pkt, struct net_buf *frag,
1539 const char *caller, int line);
1540#define net_pkt_frag_insert(pkt, frag) \
1541 net_pkt_frag_insert_debug(pkt, frag, __func__, __LINE__)
1542#endif /* CONFIG_NET_DEBUG_NET_PKT_ALLOC ||
1543 * CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
1544 */
1554#if defined(NET_PKT_DEBUG_ENABLED)
1555void net_pkt_print_frags(struct net_pkt *pkt);
1556#else
1557#define net_pkt_print_frags(pkt)
1558#endif
1559
1574#if !defined(NET_PKT_DEBUG_ENABLED)
1576 size_t min_len, k_timeout_t timeout);
1577#endif
1578
1593#if !defined(NET_PKT_DEBUG_ENABLED)
1594struct net_buf *net_pkt_get_reserve_rx_data(size_t min_len, k_timeout_t timeout);
1595#endif
1596
1611#if !defined(NET_PKT_DEBUG_ENABLED)
1612struct net_buf *net_pkt_get_reserve_tx_data(size_t min_len, k_timeout_t timeout);
1613#endif
1614
1627#if !defined(NET_PKT_DEBUG_ENABLED)
1628struct net_buf *net_pkt_get_frag(struct net_pkt *pkt, size_t min_len,
1629 k_timeout_t timeout);
1630#endif
1631
1641#if !defined(NET_PKT_DEBUG_ENABLED)
1642void net_pkt_unref(struct net_pkt *pkt);
1643#endif
1644
1654#if !defined(NET_PKT_DEBUG_ENABLED)
1655struct net_pkt *net_pkt_ref(struct net_pkt *pkt);
1656#endif
1657
1667#if !defined(NET_PKT_DEBUG_ENABLED)
1668struct net_buf *net_pkt_frag_ref(struct net_buf *frag);
1669#endif
1670
1676#if !defined(NET_PKT_DEBUG_ENABLED)
1677void net_pkt_frag_unref(struct net_buf *frag);
1678#endif
1679
1690#if !defined(NET_PKT_DEBUG_ENABLED)
1692 struct net_buf *parent,
1693 struct net_buf *frag);
1694#endif
1695
1702#if !defined(NET_PKT_DEBUG_ENABLED)
1703void net_pkt_frag_add(struct net_pkt *pkt, struct net_buf *frag);
1704#endif
1705
1712#if !defined(NET_PKT_DEBUG_ENABLED)
1713void net_pkt_frag_insert(struct net_pkt *pkt, struct net_buf *frag);
1714#endif
1715
1722void net_pkt_compact(struct net_pkt *pkt);
1723
1732void net_pkt_get_info(struct k_mem_slab **rx,
1733 struct k_mem_slab **tx,
1734 struct net_buf_pool **rx_data,
1735 struct net_buf_pool **tx_data);
1736
1739#if defined(CONFIG_NET_DEBUG_NET_PKT_ALLOC)
1743void net_pkt_print(void);
1744
1745typedef void (*net_pkt_allocs_cb_t)(struct net_pkt *pkt,
1746 struct net_buf *buf,
1747 const char *func_alloc,
1748 int line_alloc,
1749 const char *func_free,
1750 int line_free,
1751 bool in_use,
1752 void *user_data);
1753
1754void net_pkt_allocs_foreach(net_pkt_allocs_cb_t cb, void *user_data);
1755
1756const char *net_pkt_slab2str(struct k_mem_slab *slab);
1757const char *net_pkt_pool2str(struct net_buf_pool *pool);
1758
1759#else
1760#define net_pkt_print(...)
1761#endif /* CONFIG_NET_DEBUG_NET_PKT_ALLOC */
1762
1763/* New allocator, and API are defined below.
1764 * This will be simpler when time will come to get rid of former API above.
1765 */
1766#if defined(NET_PKT_DEBUG_ENABLED)
1767
1768struct net_pkt *net_pkt_alloc_debug(k_timeout_t timeout,
1769 const char *caller, int line);
1770#define net_pkt_alloc(_timeout) \
1771 net_pkt_alloc_debug(_timeout, __func__, __LINE__)
1772
1773struct net_pkt *net_pkt_alloc_from_slab_debug(struct k_mem_slab *slab,
1774 k_timeout_t timeout,
1775 const char *caller, int line);
1776#define net_pkt_alloc_from_slab(_slab, _timeout) \
1777 net_pkt_alloc_from_slab_debug(_slab, _timeout, __func__, __LINE__)
1778
1779struct net_pkt *net_pkt_rx_alloc_debug(k_timeout_t timeout,
1780 const char *caller, int line);
1781#define net_pkt_rx_alloc(_timeout) \
1782 net_pkt_rx_alloc_debug(_timeout, __func__, __LINE__)
1783
1784struct net_pkt *net_pkt_alloc_on_iface_debug(struct net_if *iface,
1785 k_timeout_t timeout,
1786 const char *caller,
1787 int line);
1788#define net_pkt_alloc_on_iface(_iface, _timeout) \
1789 net_pkt_alloc_on_iface_debug(_iface, _timeout, __func__, __LINE__)
1790
1791struct net_pkt *net_pkt_rx_alloc_on_iface_debug(struct net_if *iface,
1792 k_timeout_t timeout,
1793 const char *caller,
1794 int line);
1795#define net_pkt_rx_alloc_on_iface(_iface, _timeout) \
1796 net_pkt_rx_alloc_on_iface_debug(_iface, _timeout, \
1797 __func__, __LINE__)
1798
1799int net_pkt_alloc_buffer_debug(struct net_pkt *pkt,
1800 size_t size,
1801 enum net_ip_protocol proto,
1802 k_timeout_t timeout,
1803 const char *caller, int line);
1804#define net_pkt_alloc_buffer(_pkt, _size, _proto, _timeout) \
1805 net_pkt_alloc_buffer_debug(_pkt, _size, _proto, _timeout, \
1806 __func__, __LINE__)
1807
1808int net_pkt_alloc_buffer_raw_debug(struct net_pkt *pkt, size_t size,
1809 k_timeout_t timeout,
1810 const char *caller, int line);
1811#define net_pkt_alloc_buffer_raw(_pkt, _size, _timeout) \
1812 net_pkt_alloc_buffer_raw_debug(_pkt, _size, _timeout, \
1813 __func__, __LINE__)
1814
1815struct net_pkt *net_pkt_alloc_with_buffer_debug(struct net_if *iface,
1816 size_t size,
1817 sa_family_t family,
1818 enum net_ip_protocol proto,
1819 k_timeout_t timeout,
1820 const char *caller,
1821 int line);
1822#define net_pkt_alloc_with_buffer(_iface, _size, _family, \
1823 _proto, _timeout) \
1824 net_pkt_alloc_with_buffer_debug(_iface, _size, _family, \
1825 _proto, _timeout, \
1826 __func__, __LINE__)
1827
1828struct net_pkt *net_pkt_rx_alloc_with_buffer_debug(struct net_if *iface,
1829 size_t size,
1830 sa_family_t family,
1831 enum net_ip_protocol proto,
1832 k_timeout_t timeout,
1833 const char *caller,
1834 int line);
1835#define net_pkt_rx_alloc_with_buffer(_iface, _size, _family, \
1836 _proto, _timeout) \
1837 net_pkt_rx_alloc_with_buffer_debug(_iface, _size, _family, \
1838 _proto, _timeout, \
1839 __func__, __LINE__)
1840#endif /* NET_PKT_DEBUG_ENABLED */
1853#if !defined(NET_PKT_DEBUG_ENABLED)
1855#endif
1856
1871#if !defined(NET_PKT_DEBUG_ENABLED)
1872struct net_pkt *net_pkt_alloc_from_slab(struct k_mem_slab *slab,
1873 k_timeout_t timeout);
1874#endif
1875
1886#if !defined(NET_PKT_DEBUG_ENABLED)
1888#endif
1889
1898#if !defined(NET_PKT_DEBUG_ENABLED)
1900 k_timeout_t timeout);
1901
1904/* Same as above but specifically for RX packet */
1905struct net_pkt *net_pkt_rx_alloc_on_iface(struct net_if *iface,
1906 k_timeout_t timeout);
1909#endif
1910
1926#if !defined(NET_PKT_DEBUG_ENABLED)
1928 size_t size,
1929 enum net_ip_protocol proto,
1930 k_timeout_t timeout);
1931#endif
1932
1946#if !defined(NET_PKT_DEBUG_ENABLED)
1947int net_pkt_alloc_buffer_raw(struct net_pkt *pkt, size_t size,
1948 k_timeout_t timeout);
1949#endif
1950
1962#if !defined(NET_PKT_DEBUG_ENABLED)
1964 size_t size,
1965 sa_family_t family,
1966 enum net_ip_protocol proto,
1967 k_timeout_t timeout);
1968
1971/* Same as above but specifically for RX packet */
1972struct net_pkt *net_pkt_rx_alloc_with_buffer(struct net_if *iface,
1973 size_t size,
1974 sa_family_t family,
1975 enum net_ip_protocol proto,
1976 k_timeout_t timeout);
1977
1980#endif
1981
1988void net_pkt_append_buffer(struct net_pkt *pkt, struct net_buf *buffer);
1989
2001
2018 enum net_ip_protocol proto);
2019
2029
2044int net_pkt_remove_tail(struct net_pkt *pkt, size_t length);
2045
2054
2061static inline void net_pkt_cursor_backup(struct net_pkt *pkt,
2062 struct net_pkt_cursor *backup)
2063{
2064 backup->buf = pkt->cursor.buf;
2065 backup->pos = pkt->cursor.pos;
2066}
2067
2074static inline void net_pkt_cursor_restore(struct net_pkt *pkt,
2075 struct net_pkt_cursor *backup)
2076{
2077 pkt->cursor.buf = backup->buf;
2078 pkt->cursor.pos = backup->pos;
2079}
2080
2088static inline void *net_pkt_cursor_get_pos(struct net_pkt *pkt)
2089{
2090 return pkt->cursor.pos;
2091}
2092
2113int net_pkt_skip(struct net_pkt *pkt, size_t length);
2114
2129int net_pkt_memset(struct net_pkt *pkt, int byte, size_t length);
2130
2144int net_pkt_copy(struct net_pkt *pkt_dst,
2145 struct net_pkt *pkt_src,
2146 size_t length);
2147
2157struct net_pkt *net_pkt_clone(struct net_pkt *pkt, k_timeout_t timeout);
2158
2168struct net_pkt *net_pkt_rx_clone(struct net_pkt *pkt, k_timeout_t timeout);
2169
2179 k_timeout_t timeout);
2180
2194int net_pkt_read(struct net_pkt *pkt, void *data, size_t length);
2195
2208static inline int net_pkt_read_u8(struct net_pkt *pkt, uint8_t *data)
2209{
2210 return net_pkt_read(pkt, data, 1);
2211}
2212
2225int net_pkt_read_be16(struct net_pkt *pkt, uint16_t *data);
2226
2239int net_pkt_read_le16(struct net_pkt *pkt, uint16_t *data);
2240
2253int net_pkt_read_be32(struct net_pkt *pkt, uint32_t *data);
2254
2268int net_pkt_write(struct net_pkt *pkt, const void *data, size_t length);
2269
2282static inline int net_pkt_write_u8(struct net_pkt *pkt, uint8_t data)
2283{
2284 return net_pkt_write(pkt, &data, sizeof(uint8_t));
2285}
2286
2299static inline int net_pkt_write_be16(struct net_pkt *pkt, uint16_t data)
2300{
2301 uint16_t data_be16 = htons(data);
2302
2303 return net_pkt_write(pkt, &data_be16, sizeof(uint16_t));
2304}
2305
2318static inline int net_pkt_write_be32(struct net_pkt *pkt, uint32_t data)
2319{
2320 uint32_t data_be32 = htonl(data);
2321
2322 return net_pkt_write(pkt, &data_be32, sizeof(uint32_t));
2323}
2324
2337static inline int net_pkt_write_le32(struct net_pkt *pkt, uint32_t data)
2338{
2339 uint32_t data_le32 = sys_cpu_to_le32(data);
2340
2341 return net_pkt_write(pkt, &data_le32, sizeof(uint32_t));
2342}
2343
2356static inline int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
2357{
2358 uint16_t data_le16 = sys_cpu_to_le16(data);
2359
2360 return net_pkt_write(pkt, &data_le16, sizeof(uint16_t));
2361}
2362
2371
2384int net_pkt_update_length(struct net_pkt *pkt, size_t length);
2385
2398int net_pkt_pull(struct net_pkt *pkt, size_t length);
2399
2409
2421bool net_pkt_is_contiguous(struct net_pkt *pkt, size_t size);
2422
2432
2435struct net_pkt_data_access {
2436#if !defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2437 void *data;
2438#endif
2439 const size_t size;
2440};
2441
2442#if defined(CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS)
2443#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2444 struct net_pkt_data_access _name = { \
2445 .size = sizeof(_type), \
2446 }
2447
2448#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2449 NET_PKT_DATA_ACCESS_DEFINE(_name, _type)
2450
2451#else
2452#define NET_PKT_DATA_ACCESS_DEFINE(_name, _type) \
2453 _type _hdr_##_name; \
2454 struct net_pkt_data_access _name = { \
2455 .data = &_hdr_##_name, \
2456 .size = sizeof(_type), \
2457 }
2458
2459#define NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(_name, _type) \
2460 struct net_pkt_data_access _name = { \
2461 .data = NULL, \
2462 .size = sizeof(_type), \
2463 }
2464
2465#endif /* CONFIG_NET_HEADERS_ALWAYS_CONTIGUOUS */
2466
2482void *net_pkt_get_data(struct net_pkt *pkt,
2483 struct net_pkt_data_access *access);
2484
2499 struct net_pkt_data_access *access);
2500
2505static inline int net_pkt_acknowledge_data(struct net_pkt *pkt,
2506 struct net_pkt_data_access *access)
2507{
2508 return net_pkt_skip(pkt, access->size);
2509}
2510
2515#ifdef __cplusplus
2516}
2517#endif
2518
2519#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
size_t socklen_t
Length of a socket address.
Definition: net_ip.h:168
#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:2717
static struct net_if * net_context_get_iface(struct net_context *context)
Get network interface for this context.
Definition: net_context.h:709
static struct net_linkaddr * net_if_get_link_addr(struct net_if *iface)
Get an network interface's link address.
Definition: net_if.h:1075
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:2006
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)
Write a uint32_t big endian data to a net_pkt.
Definition: net_pkt.h:2318
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:1557
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_clone(struct net_pkt *pkt, k_timeout_t timeout)
Clone pkt and its buffer.
struct net_buf * net_pkt_get_reserve_data(struct net_buf_pool *pool, size_t min_len, k_timeout_t timeout)
Get a data buffer from a given pool.
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)
Write a uint16_t big endian data to a net_pkt.
Definition: net_pkt.h:2299
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)
Write a byte (uint8_t) data to a net_pkt.
Definition: net_pkt.h:2282
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.
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:2088
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:2061
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:2505
static int net_pkt_write_le16(struct net_pkt *pkt, uint16_t data)
Write a uint16_t little endian data to a net_pkt.
Definition: net_pkt.h:2356
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:2074
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)
Write a uint32_t little endian data to a net_pkt.
Definition: net_pkt.h:2337
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)
Read a byte (uint8_t) from a net_pkt.
Definition: net_pkt.h:2208
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:208
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:229
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)
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, 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:1076
Network buffer representation.
Definition: buf.h:1004
uint8_t * data
Pointer to the start of data in the buffer.
Definition: buf.h:1030
uint8_t user_data[]
System metadata for this buffer.
Definition: buf.h:1051
uint16_t len
Length of the data behind the data pointer.
Definition: buf.h:1033
Note that we do not store the actual source IP address in the context because the address is already ...
Definition: net_context.h:205
Network Interface structure.
Definition: net_if.h:678
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
Network packet.
Definition: net_pkt.h:67
struct net_buf * frags
buffer fragment
Definition: net_pkt.h:79
struct net_context * context
Network connection context.
Definition: net_pkt.h:87
struct net_pkt_cursor cursor
Internal buffer iterator used for reading/writing.
Definition: net_pkt.h:84
struct net_if * iface
Network interface.
Definition: net_pkt.h:90
intptr_t fifo
The fifo is used by RX/TX threads and by socket layer.
Definition: net_pkt.h:72
struct net_buf * buffer
alias to a buffer fragment
Definition: net_pkt.h:80
struct k_mem_slab * slab
Slab pointer from where it belongs to.
Definition: net_pkt.h:75
(Generalized) Precision Time Protocol Timestamp format.
Definition: ptp_time.h:109
uint32_t nanosecond
Nanoseconds.
Definition: ptp_time.h:132
uint64_t second
Second value.
Definition: ptp_time.h:128
Generic sockaddr struct.
Definition: net_ip.h:385
Definition: stat.h:92
#define sys_cpu_to_le32(val)
Convert 32-bit integer from host endianness to little-endian.
Definition: byteorder.h:270
#define sys_cpu_to_le16(val)
Convert 16-bit integer from host endianness to little-endian.
Definition: byteorder.h:266