Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
net_ip.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2016 Intel Corporation
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12
13#ifndef ZEPHYR_INCLUDE_NET_NET_IP_H_
14#define ZEPHYR_INCLUDE_NET_NET_IP_H_
15
24
25#include <string.h>
26#include <zephyr/types.h>
27#include <stdbool.h>
28#include <zephyr/sys/util.h>
30#include <zephyr/toolchain.h>
31
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
39/* Specifying VLAN tag here in order to avoid circular dependencies */
40#define NET_VLAN_TAG_UNSPEC 0x0fff
42
43/* Protocol families. */
44#define NET_PF_UNSPEC 0
45#define NET_PF_INET 1
46#define NET_PF_INET6 2
47#define NET_PF_PACKET 3
48#define NET_PF_CAN 4
49#define NET_PF_NET_MGMT 5
50#define NET_PF_LOCAL 6
51#define NET_PF_UNIX NET_PF_LOCAL
52
53/* Address families. */
54#define NET_AF_UNSPEC NET_PF_UNSPEC
55#define NET_AF_INET NET_PF_INET
56#define NET_AF_INET6 NET_PF_INET6
57#define NET_AF_PACKET NET_PF_PACKET
58#define NET_AF_CAN NET_PF_CAN
59#define NET_AF_NET_MGMT NET_PF_NET_MGMT
60#define NET_AF_LOCAL NET_PF_LOCAL
61#define NET_AF_UNIX NET_PF_UNIX
62
76
87
94
101#define net_ntohs(x) sys_be16_to_cpu(x)
102
109#define net_ntohl(x) sys_be32_to_cpu(x)
110
117#define net_ntohll(x) sys_be64_to_cpu(x)
118
125#define net_htons(x) sys_cpu_to_be16(x)
126
133#define net_htonl(x) sys_cpu_to_be32(x)
134
141#define net_htonll(x) sys_cpu_to_be64(x)
142
145 union {
149 };
150};
151
153#define NET_IPV6_ADDR_SIZE 16
154
164
166#define NET_IPV4_ADDR_SIZE 4
167
169typedef unsigned short int net_sa_family_t;
170
173
174/*
175 * Note that the sin_port and sin6_port are in network byte order
176 * in various net_sockaddr* structs.
177 */
178
186
193
204
210
244
246
248struct net_sockaddr_in6_ptr {
249 net_sa_family_t sin6_family;
250 uint16_t sin6_port;
251 struct net_in6_addr *sin6_addr;
252 uint8_t sin6_scope_id;
253};
254
256struct net_sockaddr_in_ptr {
257 net_sa_family_t sin_family;
258 uint16_t sin_port;
259 struct net_in_addr *sin_addr;
260};
261
263struct net_sockaddr_ll_ptr {
264 net_sa_family_t sll_family;
265 uint16_t sll_protocol;
266 int sll_ifindex;
267 uint16_t sll_hatype;
268 uint8_t sll_pkttype;
269 uint8_t sll_halen;
270 uint8_t *sll_addr;
271};
272
274struct net_sockaddr_un_ptr {
275 net_sa_family_t sun_family;
276 char *sun_path;
277};
278
279struct net_sockaddr_can_ptr {
280 net_sa_family_t can_family;
281 int can_ifindex;
282};
283
285
286#if !defined(HAVE_IOVEC)
288struct net_iovec {
289 void *iov_base;
290 size_t iov_len;
291};
292#endif
293
304
312
314
315/* Alignment for headers and data. These are arch specific but define
316 * them here atm if not found already.
317 */
318#if !defined(NET_ALIGN_H)
319#define NET_ALIGN_H(x) ROUND_UP(x, __alignof__(struct net_cmsghdr))
320#endif
321#if !defined(NET_ALIGN_D)
322#define NET_ALIGN_D(x) ROUND_UP(x, __alignof__(z_max_align_t))
323#endif
324
326
327#if !defined(NET_CMSG_FIRSTHDR)
333#define NET_CMSG_FIRSTHDR(msghdr) \
334 ((msghdr)->msg_controllen >= sizeof(struct net_cmsghdr) ? \
335 (struct net_cmsghdr *)((msghdr)->msg_control) : NULL)
336#endif
337
338#if !defined(NET_CMSG_NXTHDR)
343#define NET_CMSG_NXTHDR(msghdr, cmsg) \
344 (((cmsg) == NULL) ? NET_CMSG_FIRSTHDR(msghdr) : \
345 (((uint8_t *)(cmsg) + NET_ALIGN_H((cmsg)->cmsg_len) + \
346 NET_ALIGN_D(sizeof(struct net_cmsghdr)) > \
347 (uint8_t *)((msghdr)->msg_control) + (msghdr)->msg_controllen) ? \
348 NULL : \
349 (struct net_cmsghdr *)((uint8_t *)(cmsg) + \
350 NET_ALIGN_H((cmsg)->cmsg_len))))
351#endif
352
353#if !defined(NET_CMSG_DATA)
361#define NET_CMSG_DATA(cmsg) ((uint8_t *)(cmsg) + NET_ALIGN_D(sizeof(struct net_cmsghdr)))
362#endif
363
364#if !defined(NET_CMSG_SPACE)
369#define NET_CMSG_SPACE(length) (NET_ALIGN_D(sizeof(struct net_cmsghdr)) + NET_ALIGN_H(length))
370#endif
371
372#if !defined(NET_CMSG_LEN)
378#define NET_CMSG_LEN(length) (NET_ALIGN_D(sizeof(struct net_cmsghdr)) + length)
379#endif
380
382
383/* Packet types. */
384#define NET_PACKET_HOST 0 /* To us */
385#define NET_PACKET_BROADCAST 1 /* To all */
386#define NET_PACKET_MULTICAST 2 /* To group */
387#define NET_PACKET_OTHERHOST 3 /* To someone else */
388#define NET_PACKET_OUTGOING 4 /* Originated by us */
389#define NET_PACKET_LOOPBACK 5
390#define NET_PACKET_FASTROUTE 6
391
392/* ARP protocol HARDWARE identifiers. */
393#define NET_ARPHRD_ETHER 1
394#define NET_ARPHRD_PPP 512
395
396/* Note: These macros are defined in a specific order.
397 * The largest sockaddr size is the last one.
398 */
399#if defined(CONFIG_NET_IPV4)
400#undef NET_SOCKADDR_MAX_SIZE
401#undef NET_SOCKADDR_PTR_MAX_SIZE
402#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in))
403#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in_ptr))
404#endif
405
406#if defined(CONFIG_NET_SOCKETS_PACKET)
407#undef NET_SOCKADDR_MAX_SIZE
408#undef NET_SOCKADDR_PTR_MAX_SIZE
409#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_ll))
410#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_ll_ptr))
411#endif
412
413#if defined(CONFIG_NET_IPV6)
414#undef NET_SOCKADDR_MAX_SIZE
415#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in6))
416#if !defined(CONFIG_NET_SOCKETS_PACKET)
417#undef NET_SOCKADDR_PTR_MAX_SIZE
418#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in6_ptr))
419#endif
420#endif
421
422#if defined(CONFIG_NET_NATIVE_OFFLOADED_SOCKETS)
423#define UNIX_PATH_MAX 108
424#undef NET_SOCKADDR_MAX_SIZE
425/* Define NET_SOCKADDR_MAX_SIZE to be struct of net_sa_family_t + char[UNIX_PATH_MAX] */
426#define NET_SOCKADDR_MAX_SIZE (UNIX_PATH_MAX+sizeof(net_sa_family_t))
427#if !defined(CONFIG_NET_SOCKETS_PACKET)
428#undef NET_SOCKADDR_PTR_MAX_SIZE
429#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_un_ptr))
430#endif
431#endif
432
433#if !defined(CONFIG_NET_IPV4)
434#if !defined(CONFIG_NET_IPV6)
435#if !defined(CONFIG_NET_SOCKETS_PACKET)
436#if !defined(CONFIG_NET_NATIVE_OFFLOADED_SOCKETS)
437#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in6))
438#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in6_ptr))
439#endif
440#endif
441#endif
442#endif
443
445
446#define SOCKADDR_ALIGN (4)
447
452 char data[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
454} __aligned(SOCKADDR_ALIGN);
455
457
458struct net_sockaddr_ptr {
459 net_sa_family_t family;
460 char data[NET_SOCKADDR_PTR_MAX_SIZE - sizeof(net_sa_family_t)];
461} __aligned(SOCKADDR_ALIGN);
462
463/* Same as sockaddr in our case */
464struct net_sockaddr_storage {
465 net_sa_family_t ss_family;
466 char data[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
467} __aligned(SOCKADDR_ALIGN);
468
469/* Socket address struct for UNIX domain sockets */
470struct net_sockaddr_un {
471 net_sa_family_t sun_family; /* NET_AF_UNIX */
472 char sun_path[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
473};
474
475struct net_addr {
476 net_sa_family_t family;
477 union {
478#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
479 struct net_in6_addr net_in6_addr;
480 struct net_in_addr net_in_addr;
481#else
482 struct net_in6_addr in6_addr;
483 struct net_in_addr in_addr;
484#endif
485 };
486};
487
489extern const struct net_in6_addr net_in6addr_any;
490
492extern const struct net_in6_addr net_in6addr_loopback;
493
495
497#define NET_IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, \
498 0, 0, 0, 0, 0, 0, 0, 0 } } }
499
501#define NET_IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, \
502 0, 0, 0, 0, 0, 0, 0, 1 } } }
503
505#define NET_INADDR_ANY 0
506
508#define NET_INADDR_BROADCAST 0xffffffff
509
511#define NET_INADDR_ANY_INIT { { { NET_INADDR_ANY } } }
512
514#define NET_INADDR_LOOPBACK_INIT { { { 127, 0, 0, 1 } } }
515
517#define NET_INET_ADDRSTRLEN 16
518
522#define NET_INET6_ADDRSTRLEN 46
523
525
526/* These are for internal usage of the stack */
527#define NET_IPV6_ADDR_LEN sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxx.xxx.xxx.xxx")
528#define NET_IPV4_ADDR_LEN sizeof("xxx.xxx.xxx.xxx")
529
531
537#if defined(CONFIG_NET_NATIVE_IPV6)
538 NET_IPV6_MTU = CONFIG_NET_IPV6_MTU,
539#else
541#endif
542
546#if defined(CONFIG_NET_NATIVE_IPV4)
547 NET_IPV4_MTU = CONFIG_NET_IPV4_MTU,
548#else
550#endif
551};
552
564
565#define NET_MAX_PRIORITIES 8
566
575
583
597
599
600struct net_ipv6_hdr {
601 uint8_t vtc;
602 uint8_t tcflow;
603 uint16_t flow;
604 uint16_t len;
605 uint8_t nexthdr;
606 uint8_t hop_limit;
609} __packed;
610
611struct net_ipv6_frag_hdr {
612 uint8_t nexthdr;
613 uint8_t reserved;
614 uint16_t offset;
615 uint32_t id;
616} __packed;
617
618struct net_ipv4_hdr {
619 uint8_t vhl;
620 uint8_t tos;
621 uint16_t len;
622 uint8_t id[2];
623 uint8_t offset[2];
624 uint8_t ttl;
625 uint8_t proto;
626 uint16_t chksum;
629} __packed;
630
631struct net_icmp_hdr {
632 uint8_t type;
633 uint8_t code;
634 uint16_t chksum;
635} __packed;
636
637struct net_udp_hdr {
638 uint16_t src_port;
639 uint16_t dst_port;
640 uint16_t len;
641 uint16_t chksum;
642} __packed;
643
644struct net_tcp_hdr {
645 uint16_t src_port;
646 uint16_t dst_port;
647 uint8_t seq[4];
648 uint8_t ack[4];
649 uint8_t offset;
651 uint8_t wnd[2];
652 uint16_t chksum;
653 uint8_t urg[2];
654 uint8_t optdata[0];
655} __packed;
656
657static inline const char *net_addr_type2str(enum net_addr_type type)
658{
659 switch (type) {
661 return "AUTO";
662 case NET_ADDR_DHCP:
663 return "DHCP";
664 case NET_ADDR_MANUAL:
665 return "MANUAL";
667 return "OVERRIDE";
668 case NET_ADDR_ANY:
669 default:
670 break;
671 }
672
673 return "<unknown>";
674}
675
676/* IPv6 extension headers types */
677#define NET_IPV6_NEXTHDR_HBHO 0
678#define NET_IPV6_NEXTHDR_DESTO 60
679#define NET_IPV6_NEXTHDR_ROUTING 43
680#define NET_IPV6_NEXTHDR_FRAG 44
681#define NET_IPV6_NEXTHDR_NONE 59
682
687union net_ip_header {
688 struct net_ipv4_hdr *ipv4;
689 struct net_ipv6_hdr *ipv6;
690};
691
692union net_proto_header {
693 struct net_udp_hdr *udp;
694 struct net_tcp_hdr *tcp;
695};
696
697#define NET_UDPH_LEN 8 /* Size of UDP header */
698#define NET_TCPH_LEN 20 /* Size of TCP header */
699#define NET_ICMPH_LEN 4 /* Size of ICMP header */
700
701#define NET_IPV6H_LEN 40 /* Size of IPv6 header */
702#define NET_ICMPV6H_LEN NET_ICMPH_LEN /* Size of ICMPv6 header */
703#define NET_IPV6UDPH_LEN (NET_UDPH_LEN + NET_IPV6H_LEN) /* IPv6 + UDP */
704#define NET_IPV6TCPH_LEN (NET_TCPH_LEN + NET_IPV6H_LEN) /* IPv6 + TCP */
705#define NET_IPV6ICMPH_LEN (NET_IPV6H_LEN + NET_ICMPH_LEN) /* ICMPv6 + IPv6 */
706#define NET_IPV6_FRAGH_LEN 8
707
708#define NET_IPV4H_LEN 20 /* Size of IPv4 header */
709#define NET_ICMPV4H_LEN NET_ICMPH_LEN /* Size of ICMPv4 header */
710#define NET_IPV4UDPH_LEN (NET_UDPH_LEN + NET_IPV4H_LEN) /* IPv4 + UDP */
711#define NET_IPV4TCPH_LEN (NET_TCPH_LEN + NET_IPV4H_LEN) /* IPv4 + TCP */
712#define NET_IPV4ICMPH_LEN (NET_IPV4H_LEN + NET_ICMPH_LEN) /* ICMPv4 + IPv4 */
713
714#define NET_IPV6H_LENGTH_OFFSET 0x04 /* Offset of the Length field in the IPv6 header */
715
716#define NET_IPV6_FRAGH_OFFSET_MASK 0xfff8 /* Mask for the 13-bit Fragment Offset field */
717#define NET_IPV4_FRAGH_OFFSET_MASK 0x1fff /* Mask for the 13-bit Fragment Offset field */
718#define NET_IPV4_MORE_FRAG_MASK 0x2000 /* Mask for the 1-bit More Fragments field */
719#define NET_IPV4_DO_NOT_FRAG_MASK 0x4000 /* Mask for the 1-bit Do Not Fragment field */
720
722#if defined(CONFIG_NET_INTERFACE_NAME)
723#define NET_IFNAMSIZ CONFIG_NET_INTERFACE_NAME_LEN
724#else
725#if defined(Z_DEVICE_MAX_NAME_LEN)
726#define NET_IFNAMSIZ Z_DEVICE_MAX_NAME_LEN
727#else
728#define NET_IFNAMSIZ 1
729#endif /* Z_DEVICE_MAX_NAME_LEN */
730#endif /* CONFIG_NET_INTERFACE_NAME */
731
733
738
740struct net_ifreq {
741 char ifr_name[NET_IFNAMSIZ];
742};
743
744
756
765
773
784
793 unsigned int ipi6_ifindex;
794};
795
797static inline bool net_ipv6_is_addr_loopback_raw(const uint8_t *addr)
798{
799 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
800 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
801 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
802 net_ntohl(UNALIGNED_GET((uint32_t *)addr + 3)) == 1;
803}
805
813static inline bool net_ipv6_is_addr_loopback(const struct net_in6_addr *addr)
814{
815 return net_ipv6_is_addr_loopback_raw(addr->s6_addr);
816}
817
819static inline bool net_ipv6_is_addr_mcast_raw(const uint8_t *addr)
820{
821 return addr[0] == 0xff;
822}
824
832static inline bool net_ipv6_is_addr_mcast(const struct net_in6_addr *addr)
833{
834 return net_ipv6_is_addr_mcast_raw(addr->s6_addr);
835}
836
837struct net_if;
838struct net_if_config;
839
841extern struct net_if_addr *net_if_ipv6_addr_lookup_raw(const uint8_t *addr,
842 struct net_if **ret);
843
844static inline bool net_ipv6_is_my_addr_raw(const uint8_t *addr)
845{
846 return net_if_ipv6_addr_lookup_raw(addr, NULL) != NULL;
847}
849
850extern struct net_if_addr *net_if_ipv6_addr_lookup(const struct net_in6_addr *addr,
851 struct net_if **iface);
852
860static inline bool net_ipv6_is_my_addr(struct net_in6_addr *addr)
861{
862 return net_if_ipv6_addr_lookup(addr, NULL) != NULL;
863}
864
866 const struct net_in6_addr *addr, struct net_if **iface);
867
876static inline bool net_ipv6_is_my_maddr(struct net_in6_addr *maddr)
877{
878 return net_if_ipv6_maddr_lookup(maddr, NULL) != NULL;
879}
880
890static inline bool net_ipv6_is_prefix(const uint8_t *addr1,
891 const uint8_t *addr2,
892 uint8_t length)
893{
894 uint8_t bits = 128 - length;
895 uint8_t bytes = length / 8U;
896 uint8_t remain = bits % 8;
897 uint8_t mask;
898
899 if (length > 128) {
900 return false;
901 }
902
903 if (memcmp(addr1, addr2, bytes)) {
904 return false;
905 }
906
907 if (!remain) {
908 /* No remaining bits, the prefixes are the same as first
909 * bytes are the same.
910 */
911 return true;
912 }
913
914 /* Create a mask that has remaining most significant bits set */
915 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
916
917 return (addr1[bytes] & mask) == (addr2[bytes] & mask);
918}
919
920
928static inline void net_ipv6_addr_prefix_mask(const uint8_t *inaddr,
929 uint8_t *outaddr,
930 uint8_t prefix_len)
931{
932 uint8_t bits = 128 - prefix_len;
933 uint8_t bytes = prefix_len / 8U;
934 uint8_t remain = bits % 8;
935 uint8_t mask;
936
937 memset(outaddr, 0, 16U);
938 memcpy(outaddr, inaddr, bytes);
939
940 if (!remain) {
941 /* No remaining bits, the prefixes are the same as first
942 * bytes are the same.
943 */
944 return;
945 }
946
947 /* Create a mask that has remaining most significant bits set */
948 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
949 outaddr[bytes] = inaddr[bytes] & mask;
950}
951
953static inline bool net_ipv4_is_addr_loopback_raw(const uint8_t *addr)
954{
955 return addr[0] == 127U;
956}
958
966static inline bool net_ipv4_is_addr_loopback(const struct net_in_addr *addr)
967{
968 return net_ipv4_is_addr_loopback_raw(addr->s4_addr);
969}
970
972static inline bool net_ipv4_is_addr_unspecified_raw(const uint8_t *addr)
973{
974 return UNALIGNED_GET((uint32_t *)addr) == 0;
975}
977
985static inline bool net_ipv4_is_addr_unspecified(const struct net_in_addr *addr)
986{
987 return net_ipv4_is_addr_unspecified_raw(addr->s4_addr);
988}
989
991static inline bool net_ipv4_is_addr_mcast_raw(const uint8_t *addr)
992{
993 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xF0000000) == 0xE0000000;
994}
996
1004static inline bool net_ipv4_is_addr_mcast(const struct net_in_addr *addr)
1005{
1006 return net_ipv4_is_addr_mcast_raw(addr->s4_addr);
1007}
1008
1010static inline bool net_ipv4_is_ll_addr_raw(const uint8_t *addr)
1011{
1012 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xFFFF0000) == 0xA9FE0000;
1013}
1015
1023static inline bool net_ipv4_is_ll_addr(const struct net_in_addr *addr)
1024{
1025 return net_ipv4_is_ll_addr_raw(addr->s4_addr);
1026}
1027
1037static inline bool net_ipv4_is_private_addr(const struct net_in_addr *addr)
1038{
1039 uint32_t masked_24, masked_16, masked_12, masked_10, masked_8;
1040
1041 masked_24 = net_ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xFFFFFF00;
1042 masked_16 = masked_24 & 0xFFFF0000;
1043 masked_12 = masked_24 & 0xFFF00000;
1044 masked_10 = masked_24 & 0xFFC00000;
1045 masked_8 = masked_24 & 0xFF000000;
1046
1047 return masked_8 == 0x0A000000 || /* 10.0.0.0/8 */
1048 masked_10 == 0x64400000 || /* 100.64.0.0/10 */
1049 masked_12 == 0xAC100000 || /* 172.16.0.0/12 */
1050 masked_16 == 0xC0A80000 || /* 192.168.0.0/16 */
1051 masked_24 == 0xC0000200 || /* 192.0.2.0/24 */
1052 masked_24 == 0xC0336400 || /* 192.51.100.0/24 */
1053 masked_24 == 0xCB007100; /* 203.0.113.0/24 */
1054}
1055
1064#define net_ipaddr_copy(dest, src) \
1065 UNALIGNED_PUT(UNALIGNED_GET(src), dest)
1066
1073static inline void net_ipv4_addr_copy_raw(uint8_t *dest,
1074 const uint8_t *src)
1075{
1076 net_ipaddr_copy((struct net_in_addr *)dest, (const struct net_in_addr *)src);
1077}
1078
1085static inline void net_ipv6_addr_copy_raw(uint8_t *dest,
1086 const uint8_t *src)
1087{
1088 memcpy(dest, src, sizeof(struct net_in6_addr));
1089}
1090
1099static inline bool net_ipv4_addr_cmp_raw(const uint8_t *addr1,
1100 const uint8_t *addr2)
1101{
1102 return UNALIGNED_GET((uint32_t *)addr1) == UNALIGNED_GET((uint32_t *)addr2);
1103}
1104
1113static inline bool net_ipv4_addr_cmp(const struct net_in_addr *addr1,
1114 const struct net_in_addr *addr2)
1115{
1116 return net_ipv4_addr_cmp_raw(addr1->s4_addr, addr2->s4_addr);
1117}
1118
1127static inline bool net_ipv6_addr_cmp(const struct net_in6_addr *addr1,
1128 const struct net_in6_addr *addr2)
1129{
1130 return !memcmp(addr1, addr2, sizeof(struct net_in6_addr));
1131}
1132
1141static inline bool net_ipv6_addr_cmp_raw(const uint8_t *addr1,
1142 const uint8_t *addr2)
1143{
1144 return net_ipv6_addr_cmp((const struct net_in6_addr *)addr1,
1145 (const struct net_in6_addr *)addr2);
1146}
1147
1149static inline bool net_ipv6_is_ll_addr_raw(const uint8_t *addr)
1150{
1151 return UNALIGNED_GET((uint16_t *)addr) == net_htons(0xFE80);
1152}
1154
1162static inline bool net_ipv6_is_ll_addr(const struct net_in6_addr *addr)
1163{
1164 return net_ipv6_is_ll_addr_raw(addr->s6_addr);
1165}
1166
1174static inline bool net_ipv6_is_sl_addr(const struct net_in6_addr *addr)
1175{
1176 return UNALIGNED_GET(&addr->s6_addr16[0]) == net_htons(0xFEC0);
1177}
1178
1179
1187static inline bool net_ipv6_is_ula_addr(const struct net_in6_addr *addr)
1188{
1189 return addr->s6_addr[0] == 0xFD;
1190}
1191
1199static inline bool net_ipv6_is_global_addr(const struct net_in6_addr *addr)
1200{
1201 return (addr->s6_addr[0] & 0xE0) == 0x20;
1202}
1203
1213static inline bool net_ipv6_is_private_addr(const struct net_in6_addr *addr)
1214{
1215 uint32_t masked_32, masked_7;
1216
1217 masked_32 = net_ntohl(UNALIGNED_GET(&addr->s6_addr32[0]));
1218 masked_7 = masked_32 & 0xfc000000;
1219
1220 return masked_32 == 0x20010db8 || /* 2001:db8::/32 */
1221 masked_7 == 0xfc000000; /* fc00::/7 */
1222}
1223
1230
1237
1244
1245struct net_if;
1246extern bool net_if_ipv4_addr_mask_cmp(struct net_if *iface,
1247 const struct net_in_addr *addr);
1248
1258static inline bool net_ipv4_addr_mask_cmp(struct net_if *iface,
1259 const struct net_in_addr *addr)
1260{
1261 return net_if_ipv4_addr_mask_cmp(iface, addr);
1262}
1263
1265extern bool net_if_ipv4_is_addr_bcast_raw(struct net_if *iface,
1266 const uint8_t *addr);
1267
1268#if defined(CONFIG_NET_NATIVE_IPV4)
1269static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1270 const uint8_t *addr)
1271{
1272 if (net_ipv4_addr_cmp_raw(addr, net_ipv4_broadcast_address()->s4_addr)) {
1273 return true;
1274 }
1275
1276 return net_if_ipv4_is_addr_bcast_raw(iface, addr);
1277}
1278#else
1279static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1280 const uint8_t *addr)
1281{
1282 ARG_UNUSED(iface);
1283 ARG_UNUSED(addr);
1284
1285 return false;
1286}
1287#endif
1289
1290extern bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
1291 const struct net_in_addr *addr);
1292
1301#if defined(CONFIG_NET_NATIVE_IPV4)
1302static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1303 const struct net_in_addr *addr)
1304{
1306 return true;
1307 }
1308
1309 return net_if_ipv4_is_addr_bcast(iface, addr);
1310}
1311#else
1312static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1313 const struct net_in_addr *addr)
1314{
1315 ARG_UNUSED(iface);
1316 ARG_UNUSED(addr);
1317
1318 return false;
1319}
1320#endif
1321
1323extern struct net_if_addr *net_if_ipv4_addr_lookup_raw(const uint8_t *addr,
1324 struct net_if **ret);
1325
1326static inline bool net_ipv4_is_my_addr_raw(const uint8_t *addr)
1327{
1328 bool ret;
1329
1330 ret = net_if_ipv4_addr_lookup_raw(addr, NULL) != NULL;
1331 if (!ret) {
1332 ret = net_ipv4_is_addr_bcast_raw(NULL, addr);
1333 }
1334
1335 return ret;
1336}
1338
1339extern struct net_if_addr *net_if_ipv4_addr_lookup(const struct net_in_addr *addr,
1340 struct net_if **iface);
1341
1351static inline bool net_ipv4_is_my_addr(const struct net_in_addr *addr)
1352{
1353 bool ret;
1354
1355 ret = net_if_ipv4_addr_lookup(addr, NULL) != NULL;
1356 if (!ret) {
1357 ret = net_ipv4_is_addr_bcast(NULL, addr);
1358 }
1359
1360 return ret;
1361}
1362
1364static inline bool net_ipv6_is_addr_unspecified_raw(const uint8_t *addr)
1365{
1366 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
1367 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
1368 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
1369 UNALIGNED_GET((uint32_t *)addr + 3) == 0;
1370}
1372
1380static inline bool net_ipv6_is_addr_unspecified(const struct net_in6_addr *addr)
1381{
1382 return net_ipv6_is_addr_unspecified_raw(addr->s6_addr);
1383}
1384
1386static inline bool net_ipv6_is_addr_solicited_node_raw(const uint8_t *addr)
1387{
1388 return UNALIGNED_GET((uint32_t *)addr) == net_htonl(0xff020000) &&
1389 UNALIGNED_GET((uint32_t *)addr + 1) == 0x00000000 &&
1390 UNALIGNED_GET((uint32_t *)addr + 2) == net_htonl(0x00000001) &&
1391 ((UNALIGNED_GET((uint32_t *)addr + 3) & net_htonl(0xff000000)) ==
1392 net_htonl(0xff000000));
1393}
1395
1404static inline bool net_ipv6_is_addr_solicited_node(const struct net_in6_addr *addr)
1405{
1406 return net_ipv6_is_addr_solicited_node_raw(addr->s6_addr);
1407}
1408
1410static inline bool net_ipv6_is_addr_mcast_scope_raw(const uint8_t *addr,
1411 int scope)
1412{
1413 return (addr[0] == 0xff) && ((addr[1] & 0xF) == scope);
1414}
1416
1418static inline int net_ipv6_get_addr_mcast_scope_raw(const uint8_t *addr)
1419{
1420 if (addr[0] == 0xff) {
1421 return (addr[1] & 0xF);
1422 }
1423
1424 return -1;
1425}
1427
1438static inline bool net_ipv6_is_addr_mcast_scope(const struct net_in6_addr *addr,
1439 int scope)
1440{
1441 return net_ipv6_is_addr_mcast_scope_raw(addr->s6_addr, scope);
1442}
1443
1453static inline bool net_ipv6_is_same_mcast_scope(const struct net_in6_addr *addr_1,
1454 const struct net_in6_addr *addr_2)
1455{
1456 return (addr_1->s6_addr[0] == 0xff) && (addr_2->s6_addr[0] == 0xff) &&
1457 (addr_1->s6_addr[1] == addr_2->s6_addr[1]);
1458}
1459
1467static inline int net_ipv6_get_addr_mcast_scope(const struct net_in6_addr *addr)
1468{
1469 return net_ipv6_get_addr_mcast_scope_raw(addr->s6_addr);
1470}
1471
1473static inline bool net_ipv6_is_addr_mcast_iface_raw(const uint8_t *addr)
1474{
1475 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x01);
1476}
1477
1478static inline bool net_ipv6_is_addr_mcast_link_raw(const uint8_t *addr)
1479{
1480 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x02);
1481}
1482
1483static inline bool net_ipv6_is_addr_mcast_mesh_raw(const uint8_t *addr)
1484{
1485 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x03);
1486}
1487
1488static inline bool net_ipv6_is_addr_mcast_site_raw(const uint8_t *addr)
1489{
1490 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x05);
1491}
1492
1493static inline bool net_ipv6_is_addr_mcast_org_raw(const uint8_t *addr)
1494{
1495 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x08);
1496}
1498
1506static inline bool net_ipv6_is_addr_mcast_global(const struct net_in6_addr *addr)
1507{
1508 return net_ipv6_is_addr_mcast_scope(addr, 0x0e);
1509}
1510
1520static inline bool net_ipv6_is_addr_mcast_iface(const struct net_in6_addr *addr)
1521{
1522 return net_ipv6_is_addr_mcast_scope(addr, 0x01);
1523}
1524
1534static inline bool net_ipv6_is_addr_mcast_link(const struct net_in6_addr *addr)
1535{
1536 return net_ipv6_is_addr_mcast_scope(addr, 0x02);
1537}
1538
1548static inline bool net_ipv6_is_addr_mcast_mesh(const struct net_in6_addr *addr)
1549{
1550 return net_ipv6_is_addr_mcast_scope(addr, 0x03);
1551}
1552
1562static inline bool net_ipv6_is_addr_mcast_site(const struct net_in6_addr *addr)
1563{
1564 return net_ipv6_is_addr_mcast_scope(addr, 0x05);
1565}
1566
1576static inline bool net_ipv6_is_addr_mcast_org(const struct net_in6_addr *addr)
1577{
1578 return net_ipv6_is_addr_mcast_scope(addr, 0x08);
1579}
1580
1582static inline bool net_ipv6_is_addr_mcast_group_raw(const uint8_t *addr,
1583 const uint8_t *group)
1584{
1585 return UNALIGNED_GET((uint16_t *)addr + 1) == UNALIGNED_GET((uint16_t *)group + 1) &&
1586 UNALIGNED_GET((uint32_t *)addr + 1) == UNALIGNED_GET((uint32_t *)group + 1) &&
1587 UNALIGNED_GET((uint32_t *)addr + 2) == UNALIGNED_GET((uint32_t *)group + 2) &&
1588 UNALIGNED_GET((uint32_t *)addr + 3) == UNALIGNED_GET((uint32_t *)group + 3);
1589}
1591
1602static inline bool net_ipv6_is_addr_mcast_group(const struct net_in6_addr *addr,
1603 const struct net_in6_addr *group)
1604{
1605 return net_ipv6_is_addr_mcast_group_raw(addr->s6_addr, group->s6_addr);
1606}
1607
1609static inline bool net_ipv6_is_addr_mcast_all_nodes_group_raw(const uint8_t *addr)
1610{
1611 static const uint8_t all_nodes_mcast_group[NET_IPV6_ADDR_SIZE] = {
1612 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1613 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1614 };
1615
1616 return net_ipv6_is_addr_mcast_group_raw(addr, all_nodes_mcast_group);
1617}
1619
1628static inline bool
1630{
1631 return net_ipv6_is_addr_mcast_all_nodes_group_raw(addr->s6_addr);
1632}
1633
1643static inline bool
1649
1651static inline bool net_ipv6_is_addr_mcast_link_all_nodes_raw(const uint8_t *addr)
1652{
1653 return net_ipv6_is_addr_mcast_link_raw(addr) &&
1654 net_ipv6_is_addr_mcast_all_nodes_group_raw(addr);
1655}
1657
1667static inline bool
1673
1681static inline
1683 struct net_in6_addr *dst)
1684{
1685 dst->s6_addr[0] = 0xFF;
1686 dst->s6_addr[1] = 0x02;
1687 UNALIGNED_PUT(0, &dst->s6_addr16[1]);
1688 UNALIGNED_PUT(0, &dst->s6_addr16[2]);
1689 UNALIGNED_PUT(0, &dst->s6_addr16[3]);
1690 UNALIGNED_PUT(0, &dst->s6_addr16[4]);
1691 dst->s6_addr[10] = 0U;
1692 dst->s6_addr[11] = 0x01;
1693 dst->s6_addr[12] = 0xFF;
1694 dst->s6_addr[13] = src->s6_addr[13];
1695 UNALIGNED_PUT(UNALIGNED_GET(&src->s6_addr16[7]), &dst->s6_addr16[7]);
1696}
1697
1710static inline void net_ipv6_addr_create(struct net_in6_addr *addr,
1711 uint16_t addr0, uint16_t addr1,
1712 uint16_t addr2, uint16_t addr3,
1713 uint16_t addr4, uint16_t addr5,
1714 uint16_t addr6, uint16_t addr7)
1715{
1716 UNALIGNED_PUT(net_htons(addr0), &addr->s6_addr16[0]);
1717 UNALIGNED_PUT(net_htons(addr1), &addr->s6_addr16[1]);
1718 UNALIGNED_PUT(net_htons(addr2), &addr->s6_addr16[2]);
1719 UNALIGNED_PUT(net_htons(addr3), &addr->s6_addr16[3]);
1720 UNALIGNED_PUT(net_htons(addr4), &addr->s6_addr16[4]);
1721 UNALIGNED_PUT(net_htons(addr5), &addr->s6_addr16[5]);
1722 UNALIGNED_PUT(net_htons(addr6), &addr->s6_addr16[6]);
1723 UNALIGNED_PUT(net_htons(addr7), &addr->s6_addr16[7]);
1724}
1725
1732{
1733 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001);
1734}
1735
1742{
1743 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002);
1744}
1745
1752static inline void net_ipv6_addr_create_v4_mapped(const struct net_in_addr *addr4,
1753 struct net_in6_addr *addr6)
1754{
1755 net_ipv6_addr_create(addr6, 0, 0, 0, 0, 0, 0xffff,
1756 net_ntohs(addr4->s4_addr16[0]),
1757 net_ntohs(addr4->s4_addr16[1]));
1758}
1759
1768static inline bool net_ipv6_addr_is_v4_mapped(const struct net_in6_addr *addr)
1769{
1770 if (UNALIGNED_GET(&addr->s6_addr32[0]) == 0 &&
1771 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 &&
1772 UNALIGNED_GET(&addr->s6_addr16[5]) == 0xffff) {
1773 return true;
1774 }
1775
1776 return false;
1777}
1778
1787static inline void net_ipv6_addr_get_v4_mapped(const struct net_in6_addr *addr6,
1788 struct net_in_addr *addr4)
1789{
1790 addr4->s_addr = UNALIGNED_GET(&addr6->s6_addr32[3]);
1791}
1792
1812 const struct net_in6_addr *prefix,
1813 uint8_t *network_id, size_t network_id_len,
1814 uint8_t dad_counter,
1815 struct net_in6_addr *addr,
1816 struct net_linkaddr *lladdr);
1817
1824static inline void net_ipv6_addr_create_iid(struct net_in6_addr *addr,
1825 struct net_linkaddr *lladdr)
1826{
1827 (void)net_ipv6_addr_generate_iid(NULL, NULL, NULL, 0, 0, addr, lladdr);
1828}
1829
1831static inline bool net_ipv6_addr_based_on_ll_raw(const uint8_t *addr,
1832 const struct net_linkaddr *lladdr)
1833{
1834 if (addr == NULL || lladdr == NULL) {
1835 return false;
1836 }
1837
1838 switch (lladdr->len) {
1839 case 2:
1840 if (!memcmp(&addr[14], lladdr->addr, lladdr->len) &&
1841 addr[8] == 0U &&
1842 addr[9] == 0U &&
1843 addr[10] == 0U &&
1844 addr[11] == 0xff &&
1845 addr[12] == 0xfe) {
1846 return true;
1847 }
1848
1849 break;
1850 case 6:
1851 if (lladdr->type == NET_LINK_ETHERNET) {
1852 if (!memcmp(&addr[9], &lladdr->addr[1], 2) &&
1853 !memcmp(&addr[13], &lladdr->addr[3], 3) &&
1854 addr[11] == 0xff &&
1855 addr[12] == 0xfe &&
1856 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1857 return true;
1858 }
1859 }
1860
1861 break;
1862 case 8:
1863 if (sizeof(lladdr->addr) < 8) {
1864 return false;
1865 }
1866
1867 if (!memcmp(&addr[9], &lladdr->addr[1],
1868 lladdr->len - 1) &&
1869 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1870 return true;
1871 }
1872
1873 break;
1874 default:
1875 return false;
1876 }
1877
1878 return false;
1879}
1881
1887static inline bool net_ipv6_addr_based_on_ll(const struct net_in6_addr *addr,
1888 const struct net_linkaddr *lladdr)
1889{
1890 if (addr == NULL || lladdr == NULL) {
1891 return false;
1892 }
1893
1894 return net_ipv6_addr_based_on_ll_raw(addr->s6_addr, lladdr);
1895}
1896
1905static inline struct net_sockaddr *net_sad(const struct net_sockaddr_storage *addr)
1906{
1907 return (struct net_sockaddr *)addr;
1908}
1909
1918static inline struct net_sockaddr_storage *net_sas(const struct net_sockaddr *addr)
1919{
1920 return (struct net_sockaddr_storage *)addr;
1921}
1922
1931static inline struct net_sockaddr_in6 *net_sin6(const struct net_sockaddr *addr)
1932{
1933 return (struct net_sockaddr_in6 *)addr;
1934}
1935
1944static inline struct net_sockaddr_in *net_sin(const struct net_sockaddr *addr)
1945{
1946 return (struct net_sockaddr_in *)addr;
1947}
1948
1957static inline
1958struct net_sockaddr_in6_ptr *net_sin6_ptr(const struct net_sockaddr_ptr *addr)
1959{
1960 return (struct net_sockaddr_in6_ptr *)addr;
1961}
1962
1971static inline
1972struct net_sockaddr_in_ptr *net_sin_ptr(const struct net_sockaddr_ptr *addr)
1973{
1974 return (struct net_sockaddr_in_ptr *)addr;
1975}
1976
1985static inline
1986struct net_sockaddr_ll_ptr *net_sll_ptr(const struct net_sockaddr_ptr *addr)
1987{
1988 return (struct net_sockaddr_ll_ptr *)addr;
1989}
1990
1999static inline
2000struct net_sockaddr_can_ptr *net_can_ptr(const struct net_sockaddr_ptr *addr)
2001{
2002 return (struct net_sockaddr_can_ptr *)addr;
2003}
2004
2018__syscall int net_addr_pton(net_sa_family_t family, const char *src, void *dst);
2019
2031__syscall char *net_addr_ntop(net_sa_family_t family, const void *src,
2032 char *dst, size_t size);
2033
2045 struct net_sockaddr *mask);
2046
2058 uint8_t *mask_len);
2059
2081bool net_ipaddr_parse(const char *str, size_t str_len,
2082 struct net_sockaddr *addr);
2083
2111const char *net_ipaddr_parse_mask(const char *str, size_t str_len,
2112 struct net_sockaddr *addr, uint8_t *mask_len);
2113
2123int net_port_set_default(struct net_sockaddr *addr, uint16_t default_port);
2124
2136static inline int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
2137{
2138 return (int32_t)(seq1 - seq2);
2139}
2140
2151static inline bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
2152{
2153 return net_tcp_seq_cmp(seq1, seq2) > 0;
2154}
2155
2167int net_bytes_from_str(uint8_t *buf, int buf_len, const char *src);
2168
2178
2188
2197static inline enum net_priority net_vlan2priority(uint8_t priority)
2198{
2199 /* Map according to IEEE 802.1Q */
2200 static const uint8_t vlan2priority[] = {
2209 };
2210
2211 if (priority >= ARRAY_SIZE(vlan2priority)) {
2212 /* Use Best Effort as the default priority */
2213 return NET_PRIORITY_BE;
2214 }
2215
2216 return (enum net_priority)vlan2priority[priority];
2217}
2218
2226static inline uint8_t net_priority2vlan(enum net_priority priority)
2227{
2228 /* The conversion works both ways */
2229 return (uint8_t)net_vlan2priority(priority);
2230}
2231
2241
2249static inline size_t net_family2size(net_sa_family_t family)
2250{
2251 switch (family) {
2252 case NET_AF_INET:
2253 return sizeof(struct net_sockaddr_in);
2254 case NET_AF_INET6:
2255 return sizeof(struct net_sockaddr_in6);
2256 case NET_AF_PACKET:
2257 return sizeof(struct net_sockaddr_ll);
2258 case NET_AF_UNIX:
2259 return sizeof(struct net_sockaddr_un);
2260 case NET_AF_CAN:
2261 return sizeof(struct net_sockaddr_can);
2262 case NET_AF_NET_MGMT:
2263 return sizeof(struct net_sockaddr_nm);
2264 default:
2265 return 0;
2266 }
2267}
2268
2279#if defined(CONFIG_NET_IPV6_PE)
2280int net_ipv6_pe_add_filter(struct net_in6_addr *addr, bool is_denylist);
2281#else
2282static inline int net_ipv6_pe_add_filter(struct net_in6_addr *addr,
2283 bool is_denylist)
2284{
2285 ARG_UNUSED(addr);
2286 ARG_UNUSED(is_denylist);
2287
2288 return -ENOTSUP;
2289}
2290#endif /* CONFIG_NET_IPV6_PE */
2291
2299#if defined(CONFIG_NET_IPV6_PE)
2300int net_ipv6_pe_del_filter(struct net_in6_addr *addr);
2301#else
2302static inline int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
2303{
2304 ARG_UNUSED(addr);
2305
2306 return -ENOTSUP;
2307}
2308#endif /* CONFIG_NET_IPV6_PE */
2309
2310#ifdef __cplusplus
2311}
2312#endif
2313
2314#include <zephyr/syscalls/net_ip.h>
2315
2316#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
2317#define ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2318#include <zephyr/net/net_compat.h>
2319#undef ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2320#endif /* CONFIG_NET_NAMESPACE_COMPAT_MODE */
2321
2325
2326#endif /* ZEPHYR_INCLUDE_NET_NET_IP_H_ */
static struct net_sockaddr_can_ptr * net_can_ptr(const struct net_sockaddr_ptr *addr)
Get net_sockaddr_can_ptr from net_sockaddr_ptr.
Definition net_ip.h:2000
#define NET_AF_PACKET
Packet family.
Definition net_ip.h:57
static bool net_ipv6_is_ula_addr(const struct net_in6_addr *addr)
Check if the given IPv6 address is a unique local address.
Definition net_ip.h:1187
static size_t net_family2size(net_sa_family_t family)
Return network address size for a given family.
Definition net_ip.h:2249
#define NET_IPV4_ADDR_SIZE
Binary size of the IPv4 address.
Definition net_ip.h:166
static enum net_priority net_vlan2priority(uint8_t priority)
Convert network packet VLAN priority to network packet priority so we can place the packet into corre...
Definition net_ip.h:2197
static int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
Compare TCP sequence numbers.
Definition net_ip.h:2136
static bool net_ipv6_is_my_maddr(struct net_in6_addr *maddr)
Check if IPv6 multicast address is found in one of the network interfaces.
Definition net_ip.h:876
const struct net_in_addr * net_ipv4_broadcast_address(void)
Return pointer to broadcast (all bits ones) IPv4 address.
#define NET_AF_CAN
Controller Area Network.
Definition net_ip.h:58
#define NET_IPV6_ADDR_SIZE
Binary size of the IPv6 address.
Definition net_ip.h:153
static bool net_ipv4_addr_cmp(const struct net_in_addr *addr1, const struct net_in_addr *addr2)
Compare two IPv4 addresses.
Definition net_ip.h:1113
#define NET_AF_NET_MGMT
Network management info.
Definition net_ip.h:59
static bool net_ipv6_addr_is_v4_mapped(const struct net_in6_addr *addr)
Is the IPv6 address an IPv4 mapped one.
Definition net_ip.h:1768
static bool net_ipv6_is_addr_unspecified(const struct net_in6_addr *addr)
Check if the IPv6 address is unspecified (all bits zero).
Definition net_ip.h:1380
static bool net_ipv6_is_addr_mcast_mesh(const struct net_in6_addr *addr)
Check if the IPv6 address is a mesh-local scope multicast address (FFx3::).
Definition net_ip.h:1548
static void net_ipv6_addr_create_v4_mapped(const struct net_in_addr *addr4, struct net_in6_addr *addr6)
Create IPv4 mapped IPv6 address.
Definition net_ip.h:1752
static bool net_ipv4_is_addr_mcast(const struct net_in_addr *addr)
Check if the IPv4 address is a multicast address.
Definition net_ip.h:1004
net_addr_state
What is the current state of the network address.
Definition net_ip.h:577
static bool net_ipv4_addr_cmp_raw(const uint8_t *addr1, const uint8_t *addr2)
Compare two raw IPv4 address buffers.
Definition net_ip.h:1099
uint32_t net_socklen_t
Length of a socket address.
Definition net_ip.h:172
static bool net_ipv6_is_private_addr(const struct net_in6_addr *addr)
Check if the given IPv6 address is from a private/local address range.
Definition net_ip.h:1213
static bool net_ipv4_is_addr_unspecified(const struct net_in_addr *addr)
Check if the IPv4 address is unspecified (all bits zero).
Definition net_ip.h:985
static bool net_ipv6_is_addr_mcast(const struct net_in6_addr *addr)
Check if the IPv6 address is a multicast address.
Definition net_ip.h:832
struct net_if_addr * net_if_ipv6_addr_lookup(const struct net_in6_addr *addr, struct net_if **iface)
static bool net_ipv6_is_addr_mcast_iface(const struct net_in6_addr *addr)
Check if the IPv6 address is a interface scope multicast address (FFx1::).
Definition net_ip.h:1520
bool net_if_ipv4_is_addr_bcast(struct net_if *iface, const struct net_in_addr *addr)
int net_port_set_default(struct net_sockaddr *addr, uint16_t default_port)
Set the default port in the sockaddr structure.
#define net_ntohs(x)
Convert 16-bit value from network to host byte order.
Definition net_ip.h:101
static void net_ipv6_addr_copy_raw(uint8_t *dest, const uint8_t *src)
Copy an IPv6 address raw buffer.
Definition net_ip.h:1085
static bool net_ipv4_addr_mask_cmp(struct net_if *iface, const struct net_in_addr *addr)
Check if the given address belongs to same subnet that has been configured for the interface.
Definition net_ip.h:1258
const char * net_family2str(net_sa_family_t family)
Return network address family value as a string.
static void net_ipv6_addr_prefix_mask(const uint8_t *inaddr, uint8_t *outaddr, uint8_t prefix_len)
Get the IPv6 network address via the unicast address and the prefix mask.
Definition net_ip.h:928
#define NET_AF_INET6
IP protocol family version 6.
Definition net_ip.h:56
struct net_if_addr * net_if_ipv4_addr_lookup(const struct net_in_addr *addr, struct net_if **iface)
int net_ipv6_addr_generate_iid(struct net_if *iface, const struct net_in6_addr *prefix, uint8_t *network_id, size_t network_id_len, uint8_t dad_counter, struct net_in6_addr *addr, struct net_linkaddr *lladdr)
Generate IPv6 address using a prefix and interface identifier.
static struct net_sockaddr * net_sad(const struct net_sockaddr_storage *addr)
Get net_sockaddr from net_sockaddr_storage.
Definition net_ip.h:1905
#define net_htonl(x)
Convert 32-bit value from host to network byte order.
Definition net_ip.h:133
const char * net_ipaddr_parse_mask(const char *str, size_t str_len, struct net_sockaddr *addr, uint8_t *mask_len)
Parse a string that contains either IPv4 or IPv6 address and optional mask len, and store the informa...
static struct net_sockaddr_in6 * net_sin6(const struct net_sockaddr *addr)
Get net_sockaddr_in6 from net_sockaddr.
Definition net_ip.h:1931
static struct net_sockaddr_in_ptr * net_sin_ptr(const struct net_sockaddr_ptr *addr)
Get net_sockaddr_in_ptr from sockaddr_ptr.
Definition net_ip.h:1972
static bool net_ipv4_is_my_addr(const struct net_in_addr *addr)
Check if the IPv4 address is assigned to any network interface in the system.
Definition net_ip.h:1351
static bool net_ipv4_is_addr_loopback(const struct net_in_addr *addr)
Check if the IPv4 address is a loopback address (127.0.0.0/8).
Definition net_ip.h:966
int net_addr_pton(net_sa_family_t family, const char *src, void *dst)
Convert a string to IP address.
int net_mask_len_to_netmask(net_sa_family_t family, uint8_t mask_len, struct net_sockaddr *mask)
Create netmask from mask length.
static bool net_ipv4_is_ll_addr(const struct net_in_addr *addr)
Check if the given IPv4 address is a link local address.
Definition net_ip.h:1023
static bool net_ipv6_addr_cmp(const struct net_in6_addr *addr1, const struct net_in6_addr *addr2)
Compare two IPv6 addresses.
Definition net_ip.h:1127
static void net_ipv6_addr_create_ll_allnodes_mcast(struct net_in6_addr *addr)
Create link local allnodes multicast IPv6 address.
Definition net_ip.h:1731
net_ip_protocol_secure
Protocol numbers for TLS protocols.
Definition net_ip.h:78
static void net_ipv6_addr_get_v4_mapped(const struct net_in6_addr *addr6, struct net_in_addr *addr4)
Get the IPv4 address from an IPv4 mapped IPv6 address.
Definition net_ip.h:1787
#define net_ipaddr_copy(dest, src)
Copy an IPv4 or IPv6 address.
Definition net_ip.h:1064
static bool net_ipv6_addr_based_on_ll(const struct net_in6_addr *addr, const struct net_linkaddr *lladdr)
Check if given address is based on link layer address.
Definition net_ip.h:1887
net_ip_mtu
IP Maximum Transfer Unit.
Definition net_ip.h:533
int net_rx_priority2tc(enum net_priority prio)
Convert Rx network packet priority to traffic class so we can place the packet into correct Rx queue.
static int net_ipv6_get_addr_mcast_scope(const struct net_in6_addr *addr)
Returns the scope of the given IPv6 address.
Definition net_ip.h:1467
int net_netmask_to_mask_len(net_sa_family_t family, struct net_sockaddr *mask, uint8_t *mask_len)
Create mask length from netmask.
static void net_ipv6_addr_create_iid(struct net_in6_addr *addr, struct net_linkaddr *lladdr)
Create IPv6 address interface identifier.
Definition net_ip.h:1824
static struct net_sockaddr_in * net_sin(const struct net_sockaddr *addr)
Get net_sockaddr_in from net_sockaddr.
Definition net_ip.h:1944
#define NET_AF_UNIX
Inter-process communication.
Definition net_ip.h:61
unsigned short int net_sa_family_t
Socket address family type.
Definition net_ip.h:169
int net_bytes_from_str(uint8_t *buf, int buf_len, const char *src)
Convert a string of hex values to array of bytes.
static uint8_t net_priority2vlan(enum net_priority priority)
Convert network packet priority to network packet VLAN priority.
Definition net_ip.h:2226
static bool net_ipv6_is_addr_mcast_site(const struct net_in6_addr *addr)
Check if the IPv6 address is a site scope multicast address (FFx5::).
Definition net_ip.h:1562
bool net_ipaddr_parse(const char *str, size_t str_len, struct net_sockaddr *addr)
Parse a string that contains either IPv4 or IPv6 address and optional port, and store the information...
bool net_if_ipv4_addr_mask_cmp(struct net_if *iface, const struct net_in_addr *addr)
static bool net_ipv6_is_addr_mcast_scope(const struct net_in6_addr *addr, int scope)
Check if the IPv6 address is a given scope multicast address (FFyx::).
Definition net_ip.h:1438
#define SOCKADDR_ALIGN
Definition net_ip.h:446
static bool net_ipv6_is_my_addr(struct net_in6_addr *addr)
Check if IPv6 address is found in one of the network interfaces.
Definition net_ip.h:860
static bool net_ipv6_is_prefix(const uint8_t *addr1, const uint8_t *addr2, uint8_t length)
Check if two IPv6 addresses are same when compared after prefix mask.
Definition net_ip.h:890
static bool net_ipv6_is_addr_loopback(const struct net_in6_addr *addr)
Check if the IPv6 address is a loopback address (::1).
Definition net_ip.h:813
static struct net_sockaddr_storage * net_sas(const struct net_sockaddr *addr)
Get net_sockaddr_storage from net_sockaddr.
Definition net_ip.h:1918
static bool net_ipv6_is_addr_mcast_org(const struct net_in6_addr *addr)
Check if the IPv6 address is an organization scope multicast address (FFx8::).
Definition net_ip.h:1576
static int net_ipv6_pe_add_filter(struct net_in6_addr *addr, bool is_denylist)
Add IPv6 prefix as a privacy extension filter.
Definition net_ip.h:2282
static bool net_ipv6_is_addr_mcast_group(const struct net_in6_addr *addr, const struct net_in6_addr *group)
Check if the IPv6 address belongs to certain multicast group.
Definition net_ip.h:1602
static bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
Check that one TCP sequence number is greater.
Definition net_ip.h:2151
net_sock_type
Socket type.
Definition net_ip.h:89
static bool net_ipv6_is_addr_solicited_node(const struct net_in6_addr *addr)
Check if the IPv6 address is solicited node multicast address FF02:0:0:0:0:1:FFXX:XXXX defined in RFC...
Definition net_ip.h:1404
static void net_ipv6_addr_create(struct net_in6_addr *addr, uint16_t addr0, uint16_t addr1, uint16_t addr2, uint16_t addr3, uint16_t addr4, uint16_t addr5, uint16_t addr6, uint16_t addr7)
Construct an IPv6 address from eight 16-bit words.
Definition net_ip.h:1710
static bool net_ipv6_is_global_addr(const struct net_in6_addr *addr)
Check if the given IPv6 address is a global address.
Definition net_ip.h:1199
static struct net_sockaddr_ll_ptr * net_sll_ptr(const struct net_sockaddr_ptr *addr)
Get net_sockaddr_ll_ptr from sockaddr_ptr.
Definition net_ip.h:1986
static bool net_ipv6_is_addr_mcast_link_all_nodes(const struct net_in6_addr *addr)
Check if the IPv6 address is a link local scope all nodes multicast address (FF02::1).
Definition net_ip.h:1668
const struct net_in_addr * net_ipv4_unspecified_address(void)
Return pointer to any (all bits zeros) IPv4 address.
static struct net_sockaddr_in6_ptr * net_sin6_ptr(const struct net_sockaddr_ptr *addr)
Get net_sockaddr_in6_ptr from net_sockaddr_ptr.
Definition net_ip.h:1958
static bool net_ipv6_is_addr_mcast_all_nodes_group(const struct net_in6_addr *addr)
Check if the IPv6 address belongs to the all nodes multicast group.
Definition net_ip.h:1629
static bool net_ipv6_is_same_mcast_scope(const struct net_in6_addr *addr_1, const struct net_in6_addr *addr_2)
Check if the IPv6 addresses have the same multicast scope (FFyx::).
Definition net_ip.h:1453
static int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
Delete IPv6 prefix from privacy extension filter list.
Definition net_ip.h:2302
#define NET_AF_INET
IP protocol family version 4.
Definition net_ip.h:55
static bool net_ipv6_is_ll_addr(const struct net_in6_addr *addr)
Check if the given IPv6 address is a link local address.
Definition net_ip.h:1162
struct net_if_mcast_addr * net_if_ipv6_maddr_lookup(const struct net_in6_addr *addr, struct net_if **iface)
static bool net_ipv4_is_private_addr(const struct net_in_addr *addr)
Check if the given IPv4 address is from a private address range.
Definition net_ip.h:1037
static void net_ipv6_addr_create_solicited_node(const struct net_in6_addr *src, struct net_in6_addr *dst)
Create solicited node IPv6 multicast address FF02:0:0:0:0:1:FFXX:XXXX defined in RFC 3513.
Definition net_ip.h:1682
static bool net_ipv6_is_addr_mcast_link(const struct net_in6_addr *addr)
Check if the IPv6 address is a link local scope multicast address (FFx2::).
Definition net_ip.h:1534
#define net_ntohl(x)
Convert 32-bit value from network to host byte order.
Definition net_ip.h:109
#define net_htons(x)
Convert 16-bit value from host to network byte order.
Definition net_ip.h:125
static void net_ipv6_addr_create_ll_allrouters_mcast(struct net_in6_addr *addr)
Create link local allrouters multicast IPv6 address.
Definition net_ip.h:1741
int net_tx_priority2tc(enum net_priority prio)
Convert Tx network packet priority to traffic class so we can place the packet into correct Tx queue.
net_priority
Network packet priority settings described in IEEE 802.1Q Annex I.1.
Definition net_ip.h:554
static bool net_ipv6_is_addr_mcast_iface_all_nodes(const struct net_in6_addr *addr)
Check if the IPv6 address is a interface scope all nodes multicast address (FF01::1).
Definition net_ip.h:1644
static bool net_ipv6_is_sl_addr(const struct net_in6_addr *addr)
Check if the given IPv6 address is a site local address.
Definition net_ip.h:1174
net_ip_protocol
Protocol numbers from IANA/BSD.
Definition net_ip.h:64
const struct net_in6_addr * net_ipv6_unspecified_address(void)
Return pointer to any (all bits zeros) IPv6 address.
static void net_ipv4_addr_copy_raw(uint8_t *dest, const uint8_t *src)
Copy an IPv4 address raw buffer.
Definition net_ip.h:1073
static bool net_ipv6_is_addr_mcast_global(const struct net_in6_addr *addr)
Check if the IPv6 address is a global multicast address (FFxE::/16).
Definition net_ip.h:1506
char * net_addr_ntop(net_sa_family_t family, const void *src, char *dst, size_t size)
Convert IP address to string form.
static bool net_ipv6_addr_cmp_raw(const uint8_t *addr1, const uint8_t *addr2)
Compare two raw IPv6 address buffers.
Definition net_ip.h:1141
net_addr_type
How the network address is assigned to network interface.
Definition net_ip.h:585
static bool net_ipv4_is_addr_bcast(struct net_if *iface, const struct net_in_addr *addr)
Check if the given IPv4 address is a broadcast address.
Definition net_ip.h:1312
@ NET_ADDR_ANY_STATE
Default (invalid) address type.
Definition net_ip.h:578
@ NET_ADDR_TENTATIVE
Tentative address.
Definition net_ip.h:579
@ NET_ADDR_DEPRECATED
Deprecated address.
Definition net_ip.h:581
@ NET_ADDR_PREFERRED
Preferred address.
Definition net_ip.h:580
@ NET_IPPROTO_TLS_1_2
TLS 1.2 protocol.
Definition net_ip.h:81
@ NET_IPPROTO_TLS_1_1
TLS 1.1 protocol.
Definition net_ip.h:80
@ NET_IPPROTO_TLS_1_0
TLS 1.0 protocol.
Definition net_ip.h:79
@ NET_IPPROTO_DTLS_1_2
DTLS 1.2 protocol.
Definition net_ip.h:84
@ NET_IPPROTO_TLS_1_3
TLS 1.3 protocol.
Definition net_ip.h:82
@ NET_IPPROTO_QUIC
QUIC protocol.
Definition net_ip.h:85
@ NET_IPPROTO_DTLS_1_0
DTLS 1.0 protocol.
Definition net_ip.h:83
@ NET_IPV4_MTU
IPv4 MTU length.
Definition net_ip.h:549
@ NET_IPV6_MTU
IPv6 MTU length.
Definition net_ip.h:540
@ NET_SOCK_STREAM
Stream socket type.
Definition net_ip.h:90
@ NET_SOCK_RAW
RAW socket type.
Definition net_ip.h:92
@ NET_SOCK_DGRAM
Datagram socket type.
Definition net_ip.h:91
@ NET_PRIORITY_NC
Network control (highest).
Definition net_ip.h:562
@ NET_PRIORITY_IC
Internetwork control.
Definition net_ip.h:561
@ NET_PRIORITY_CA
Critical applications.
Definition net_ip.h:558
@ NET_PRIORITY_VO
Voice, < 10 ms latency and jitter.
Definition net_ip.h:560
@ NET_PRIORITY_VI
Video, < 100 ms latency and jitter.
Definition net_ip.h:559
@ NET_PRIORITY_BE
Best effort (default).
Definition net_ip.h:556
@ NET_PRIORITY_EE
Excellent effort.
Definition net_ip.h:557
@ NET_PRIORITY_BK
Background (lowest).
Definition net_ip.h:555
@ NET_IPPROTO_TCP
TCP protocol.
Definition net_ip.h:70
@ NET_IPPROTO_ICMP
ICMP protocol.
Definition net_ip.h:66
@ NET_IPPROTO_ICMPV6
ICMPv6 protocol.
Definition net_ip.h:73
@ NET_IPPROTO_UDP
UDP protocol.
Definition net_ip.h:71
@ NET_IPPROTO_IP
IP protocol (pseudo-val for setsockopt().
Definition net_ip.h:65
@ NET_IPPROTO_RAW
RAW IP packets.
Definition net_ip.h:74
@ NET_IPPROTO_IGMP
IGMP protocol.
Definition net_ip.h:67
@ NET_IPPROTO_IPV6
IPv6 protocol.
Definition net_ip.h:72
@ NET_IPPROTO_IPIP
IPIP tunnels.
Definition net_ip.h:69
@ NET_IPPROTO_ETH_P_ALL
Every packet.
Definition net_ip.h:68
@ NET_ADDR_ANY
Default value.
Definition net_ip.h:587
@ NET_ADDR_OVERRIDABLE
Manually set address which is overridable by DHCP.
Definition net_ip.h:595
@ NET_ADDR_DHCP
Address is from DHCP.
Definition net_ip.h:591
@ NET_ADDR_MANUAL
Manually set address.
Definition net_ip.h:593
@ NET_ADDR_AUTOCONF
Auto configured address.
Definition net_ip.h:589
@ NET_LINK_ETHERNET
Ethernet link address.
Definition net_linkaddr.h:66
#define ARRAY_SIZE(array)
Number of elements in the given array.
Definition util.h:118
#define ENOTSUP
Unsupported value.
Definition errno.h:114
#define NULL
Definition iar_missing_defs.h:20
#define in_addr
Definition in.h:20
#define in6_addr
Definition in.h:21
Network namespace compatibility mode header.
Public API for network link address.
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
void * memset(void *buf, int c, size_t n)
int memcmp(const void *m1, const void *m2, size_t n)
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
Group structure.
Definition grp.h:18
Control message ancillary data.
Definition net_ip.h:306
net_socklen_t cmsg_len
Number of bytes, including header.
Definition net_ip.h:307
int cmsg_level
Originating protocol.
Definition net_ip.h:308
int cmsg_type
Protocol-specific type.
Definition net_ip.h:309
z_max_align_t cmsg_data[]
Flexible array member to force alignment of net_cmsghdr.
Definition net_ip.h:310
Network Interface unicast IP addresses.
Definition net_if.h:56
IP and other configuration related data for network interface.
Definition net_if.h:591
Network Interface multicast IP addresses.
Definition net_if.h:161
Network Interface structure.
Definition net_if.h:731
Interface description structure.
Definition net_ip.h:740
char ifr_name[NET_IFNAMSIZ]
Network interface name.
Definition net_ip.h:741
IPv6 address struct.
Definition net_ip.h:144
uint16_t s6_addr16[8]
In big endian.
Definition net_ip.h:147
uint32_t s6_addr32[4]
In big endian.
Definition net_ip.h:148
uint8_t s6_addr[16]
IPv6 address buffer.
Definition net_ip.h:146
Incoming IPv6 packet information.
Definition net_ip.h:791
unsigned int ipi6_ifindex
Receive interface index.
Definition net_ip.h:793
struct net_in6_addr ipi6_addr
Destination IPv6 address.
Definition net_ip.h:792
IPv4 address struct.
Definition net_ip.h:156
uint16_t s4_addr16[2]
In big endian.
Definition net_ip.h:159
uint32_t s4_addr32[1]
In big endian.
Definition net_ip.h:160
uint32_t s_addr
In big endian, for POSIX compatibility.
Definition net_ip.h:161
uint8_t s4_addr[4]
IPv4 address buffer.
Definition net_ip.h:158
Incoming IPv4 packet information.
Definition net_ip.h:751
unsigned int ipi_ifindex
Network interface index.
Definition net_ip.h:752
struct net_in_addr ipi_addr
Header Destination address.
Definition net_ip.h:754
struct net_in_addr ipi_spec_dst
Local address.
Definition net_ip.h:753
IO vector array element.
Definition net_ip.h:288
void * iov_base
Pointer to data.
Definition net_ip.h:289
size_t iov_len
Length of the data.
Definition net_ip.h:290
Struct used when setting a IPv4 multicast network interface.
Definition net_ip.h:769
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:770
struct net_in_addr imr_interface
IP address of local interface.
Definition net_ip.h:771
Struct used when joining or leaving a IPv4 multicast group.
Definition net_ip.h:760
int imr_ifindex
Network interface index.
Definition net_ip.h:763
struct net_in_addr imr_address
IP address of local interface.
Definition net_ip.h:762
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:761
Struct used when joining or leaving a IPv6 multicast group.
Definition net_ip.h:777
struct net_in6_addr ipv6mr_multiaddr
IPv6 multicast address of group.
Definition net_ip.h:779
int ipv6mr_ifindex
Network interface index of the local IPv6 address.
Definition net_ip.h:782
Hardware link address structure.
Definition net_linkaddr.h:83
uint8_t addr[6]
The array of bytes representing the address.
Definition net_linkaddr.h:91
uint8_t type
What kind of address is this for.
Definition net_linkaddr.h:85
uint8_t len
The real length of the ll address.
Definition net_linkaddr.h:88
Message struct.
Definition net_ip.h:295
int msg_flags
Flags on received message.
Definition net_ip.h:302
struct net_iovec * msg_iov
Scatter/gather array.
Definition net_ip.h:298
net_socklen_t msg_namelen
Size of socket address.
Definition net_ip.h:297
size_t msg_controllen
Ancillary data buffer len.
Definition net_ip.h:301
void * msg_control
Ancillary data.
Definition net_ip.h:300
void * msg_name
Optional socket address, big endian.
Definition net_ip.h:296
size_t msg_iovlen
Number of elements in msg_iov.
Definition net_ip.h:299
struct net_sockaddr_can - The net_sockaddr structure for CAN sockets.
Definition net_ip.h:206
int can_ifindex
SocketCAN network interface index.
Definition net_ip.h:208
net_sa_family_t can_family
Address family.
Definition net_ip.h:207
Socket address struct for IPv6.
Definition net_ip.h:180
struct net_in6_addr sin6_addr
IPv6 address.
Definition net_ip.h:183
net_sa_family_t sin6_family
NET_AF_INET6.
Definition net_ip.h:181
uint8_t sin6_scope_id
Interfaces for a scope.
Definition net_ip.h:184
uint16_t sin6_port
Port number.
Definition net_ip.h:182
Socket address struct for IPv4.
Definition net_ip.h:188
uint16_t sin_port
Port number.
Definition net_ip.h:190
struct net_in_addr sin_addr
IPv4 address.
Definition net_ip.h:191
net_sa_family_t sin_family
NET_AF_INET.
Definition net_ip.h:189
Socket address struct for packet socket.
Definition net_ip.h:195
uint8_t sll_pkttype
Packet type.
Definition net_ip.h:200
int sll_ifindex
Interface number.
Definition net_ip.h:198
net_sa_family_t sll_family
Always NET_AF_PACKET.
Definition net_ip.h:196
uint16_t sll_hatype
ARP hardware type.
Definition net_ip.h:199
uint8_t sll_halen
Length of address.
Definition net_ip.h:201
uint16_t sll_protocol
Physical-layer protocol.
Definition net_ip.h:197
uint8_t sll_addr[8]
Physical-layer address, big endian.
Definition net_ip.h:202
struct net_sockaddr_nm - The net_sockaddr structure for NET_MGMT sockets
Definition net_ip.h:229
uint64_t nm_mask
net_mgmt mask
Definition net_ip.h:242
int nm_ifindex
Network interface related to this address.
Definition net_ip.h:234
uintptr_t nm_pid
Thread id or similar that is used to separate the different sockets.
Definition net_ip.h:239
net_sa_family_t nm_family
AF_NET_MGMT address family.
Definition net_ip.h:231
Generic sockaddr struct.
Definition net_ip.h:449
net_sa_family_t sa_family
Address family.
Definition net_ip.h:450
IPv6/IPv4 network connection tuple.
Definition net_ip.h:568
struct net_addr * remote_addr
IPv6/IPv4 remote address.
Definition net_ip.h:569
uint16_t local_port
UDP/TCP local port.
Definition net_ip.h:572
enum net_ip_protocol ip_proto
IP protocol.
Definition net_ip.h:573
uint16_t remote_port
UDP/TCP remote port.
Definition net_ip.h:571
struct net_addr * local_addr
IPv6/IPv4 local address.
Definition net_ip.h:570
Byte order helpers.
Misc utilities.
Macros to abstract toolchain specific capabilities.