Zephyr API Documentation 4.3.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
86
93
100#define net_ntohs(x) sys_be16_to_cpu(x)
101
108#define net_ntohl(x) sys_be32_to_cpu(x)
109
116#define net_ntohll(x) sys_be64_to_cpu(x)
117
124#define net_htons(x) sys_cpu_to_be16(x)
125
132#define net_htonl(x) sys_cpu_to_be32(x)
133
140#define net_htonll(x) sys_cpu_to_be64(x)
141
144 union {
148 };
149};
150
152#define NET_IPV6_ADDR_SIZE 16
153
163
165#define NET_IPV4_ADDR_SIZE 4
166
168typedef unsigned short int net_sa_family_t;
169
172
173/*
174 * Note that the sin_port and sin6_port are in network byte order
175 * in various net_sockaddr* structs.
176 */
177
185
192
203
209
243
245
247struct net_sockaddr_in6_ptr {
248 net_sa_family_t sin6_family;
249 uint16_t sin6_port;
250 struct net_in6_addr *sin6_addr;
251 uint8_t sin6_scope_id;
252};
253
255struct net_sockaddr_in_ptr {
256 net_sa_family_t sin_family;
257 uint16_t sin_port;
258 struct net_in_addr *sin_addr;
259};
260
262struct net_sockaddr_ll_ptr {
263 net_sa_family_t sll_family;
264 uint16_t sll_protocol;
265 int sll_ifindex;
266 uint16_t sll_hatype;
267 uint8_t sll_pkttype;
268 uint8_t sll_halen;
269 uint8_t *sll_addr;
270};
271
273struct net_sockaddr_un_ptr {
274 net_sa_family_t sun_family;
275 char *sun_path;
276};
277
278struct net_sockaddr_can_ptr {
279 net_sa_family_t can_family;
280 int can_ifindex;
281};
282
284
285#if !defined(HAVE_IOVEC)
287struct net_iovec {
288 void *iov_base;
289 size_t iov_len;
290};
291#endif
292
303
311
313
314/* Alignment for headers and data. These are arch specific but define
315 * them here atm if not found already.
316 */
317#if !defined(NET_ALIGN_H)
318#define NET_ALIGN_H(x) ROUND_UP(x, __alignof__(struct net_cmsghdr))
319#endif
320#if !defined(NET_ALIGN_D)
321#define NET_ALIGN_D(x) ROUND_UP(x, __alignof__(z_max_align_t))
322#endif
323
325
326#if !defined(NET_CMSG_FIRSTHDR)
332#define NET_CMSG_FIRSTHDR(msghdr) \
333 ((msghdr)->msg_controllen >= sizeof(struct net_cmsghdr) ? \
334 (struct net_cmsghdr *)((msghdr)->msg_control) : NULL)
335#endif
336
337#if !defined(NET_CMSG_NXTHDR)
342#define NET_CMSG_NXTHDR(msghdr, cmsg) \
343 (((cmsg) == NULL) ? NET_CMSG_FIRSTHDR(msghdr) : \
344 (((uint8_t *)(cmsg) + NET_ALIGN_H((cmsg)->cmsg_len) + \
345 NET_ALIGN_D(sizeof(struct net_cmsghdr)) > \
346 (uint8_t *)((msghdr)->msg_control) + (msghdr)->msg_controllen) ? \
347 NULL : \
348 (struct net_cmsghdr *)((uint8_t *)(cmsg) + \
349 NET_ALIGN_H((cmsg)->cmsg_len))))
350#endif
351
352#if !defined(NET_CMSG_DATA)
360#define NET_CMSG_DATA(cmsg) ((uint8_t *)(cmsg) + NET_ALIGN_D(sizeof(struct net_cmsghdr)))
361#endif
362
363#if !defined(NET_CMSG_SPACE)
368#define NET_CMSG_SPACE(length) (NET_ALIGN_D(sizeof(struct net_cmsghdr)) + NET_ALIGN_H(length))
369#endif
370
371#if !defined(NET_CMSG_LEN)
377#define NET_CMSG_LEN(length) (NET_ALIGN_D(sizeof(struct net_cmsghdr)) + length)
378#endif
379
381
382/* Packet types. */
383#define NET_PACKET_HOST 0 /* To us */
384#define NET_PACKET_BROADCAST 1 /* To all */
385#define NET_PACKET_MULTICAST 2 /* To group */
386#define NET_PACKET_OTHERHOST 3 /* To someone else */
387#define NET_PACKET_OUTGOING 4 /* Originated by us */
388#define NET_PACKET_LOOPBACK 5
389#define NET_PACKET_FASTROUTE 6
390
391/* ARP protocol HARDWARE identifiers. */
392#define NET_ARPHRD_ETHER 1
393#define NET_ARPHRD_PPP 512
394
395/* Note: These macros are defined in a specific order.
396 * The largest sockaddr size is the last one.
397 */
398#if defined(CONFIG_NET_IPV4)
399#undef NET_SOCKADDR_MAX_SIZE
400#undef NET_SOCKADDR_PTR_MAX_SIZE
401#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in))
402#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in_ptr))
403#endif
404
405#if defined(CONFIG_NET_SOCKETS_PACKET)
406#undef NET_SOCKADDR_MAX_SIZE
407#undef NET_SOCKADDR_PTR_MAX_SIZE
408#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_ll))
409#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_ll_ptr))
410#endif
411
412#if defined(CONFIG_NET_IPV6)
413#undef NET_SOCKADDR_MAX_SIZE
414#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in6))
415#if !defined(CONFIG_NET_SOCKETS_PACKET)
416#undef NET_SOCKADDR_PTR_MAX_SIZE
417#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in6_ptr))
418#endif
419#endif
420
421#if defined(CONFIG_NET_NATIVE_OFFLOADED_SOCKETS)
422#define UNIX_PATH_MAX 108
423#undef NET_SOCKADDR_MAX_SIZE
424/* Define NET_SOCKADDR_MAX_SIZE to be struct of net_sa_family_t + char[UNIX_PATH_MAX] */
425#define NET_SOCKADDR_MAX_SIZE (UNIX_PATH_MAX+sizeof(net_sa_family_t))
426#if !defined(CONFIG_NET_SOCKETS_PACKET)
427#undef NET_SOCKADDR_PTR_MAX_SIZE
428#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_un_ptr))
429#endif
430#endif
431
432#if !defined(CONFIG_NET_IPV4)
433#if !defined(CONFIG_NET_IPV6)
434#if !defined(CONFIG_NET_SOCKETS_PACKET)
435#if !defined(CONFIG_NET_NATIVE_OFFLOADED_SOCKETS)
436#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in6))
437#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in6_ptr))
438#endif
439#endif
440#endif
441#endif
442
444
445#define SOCKADDR_ALIGN (4)
446
451 char data[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
453} __aligned(SOCKADDR_ALIGN);
454
456
457struct net_sockaddr_ptr {
458 net_sa_family_t family;
459 char data[NET_SOCKADDR_PTR_MAX_SIZE - sizeof(net_sa_family_t)];
460} __aligned(SOCKADDR_ALIGN);
461
462/* Same as sockaddr in our case */
463struct net_sockaddr_storage {
464 net_sa_family_t ss_family;
465 char data[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
466} __aligned(SOCKADDR_ALIGN);
467
468/* Socket address struct for UNIX domain sockets */
469struct net_sockaddr_un {
470 net_sa_family_t sun_family; /* NET_AF_UNIX */
471 char sun_path[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
472};
473
474struct net_addr {
475 net_sa_family_t family;
476 union {
477#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
478 struct net_in6_addr net_in6_addr;
479 struct net_in_addr net_in_addr;
480#else
481 struct net_in6_addr in6_addr;
482 struct net_in_addr in_addr;
483#endif
484 };
485};
486
488extern const struct net_in6_addr net_in6addr_any;
489
491extern const struct net_in6_addr net_in6addr_loopback;
492
494
496#define NET_IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, \
497 0, 0, 0, 0, 0, 0, 0, 0 } } }
498
500#define NET_IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, \
501 0, 0, 0, 0, 0, 0, 0, 1 } } }
502
504#define NET_INADDR_ANY 0
505
507#define NET_INADDR_BROADCAST 0xffffffff
508
510#define NET_INADDR_ANY_INIT { { { NET_INADDR_ANY } } }
511
513#define NET_INADDR_LOOPBACK_INIT { { { 127, 0, 0, 1 } } }
514
516#define NET_INET_ADDRSTRLEN 16
517
521#define NET_INET6_ADDRSTRLEN 46
522
524
525/* These are for internal usage of the stack */
526#define NET_IPV6_ADDR_LEN sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxx.xxx.xxx.xxx")
527#define NET_IPV4_ADDR_LEN sizeof("xxx.xxx.xxx.xxx")
528
530
536#if defined(CONFIG_NET_NATIVE_IPV6)
537 NET_IPV6_MTU = CONFIG_NET_IPV6_MTU,
538#else
540#endif
541
545#if defined(CONFIG_NET_NATIVE_IPV4)
546 NET_IPV4_MTU = CONFIG_NET_IPV4_MTU,
547#else
549#endif
550};
551
563
564#define NET_MAX_PRIORITIES 8
565
574
582
596
598
599struct net_ipv6_hdr {
600 uint8_t vtc;
601 uint8_t tcflow;
602 uint16_t flow;
603 uint16_t len;
604 uint8_t nexthdr;
605 uint8_t hop_limit;
608} __packed;
609
610struct net_ipv6_frag_hdr {
611 uint8_t nexthdr;
612 uint8_t reserved;
613 uint16_t offset;
614 uint32_t id;
615} __packed;
616
617struct net_ipv4_hdr {
618 uint8_t vhl;
619 uint8_t tos;
620 uint16_t len;
621 uint8_t id[2];
622 uint8_t offset[2];
623 uint8_t ttl;
624 uint8_t proto;
625 uint16_t chksum;
628} __packed;
629
630struct net_icmp_hdr {
631 uint8_t type;
632 uint8_t code;
633 uint16_t chksum;
634} __packed;
635
636struct net_udp_hdr {
637 uint16_t src_port;
638 uint16_t dst_port;
639 uint16_t len;
640 uint16_t chksum;
641} __packed;
642
643struct net_tcp_hdr {
644 uint16_t src_port;
645 uint16_t dst_port;
646 uint8_t seq[4];
647 uint8_t ack[4];
648 uint8_t offset;
650 uint8_t wnd[2];
651 uint16_t chksum;
652 uint8_t urg[2];
653 uint8_t optdata[0];
654} __packed;
655
656static inline const char *net_addr_type2str(enum net_addr_type type)
657{
658 switch (type) {
660 return "AUTO";
661 case NET_ADDR_DHCP:
662 return "DHCP";
663 case NET_ADDR_MANUAL:
664 return "MANUAL";
666 return "OVERRIDE";
667 case NET_ADDR_ANY:
668 default:
669 break;
670 }
671
672 return "<unknown>";
673}
674
675/* IPv6 extension headers types */
676#define NET_IPV6_NEXTHDR_HBHO 0
677#define NET_IPV6_NEXTHDR_DESTO 60
678#define NET_IPV6_NEXTHDR_ROUTING 43
679#define NET_IPV6_NEXTHDR_FRAG 44
680#define NET_IPV6_NEXTHDR_NONE 59
681
686union net_ip_header {
687 struct net_ipv4_hdr *ipv4;
688 struct net_ipv6_hdr *ipv6;
689};
690
691union net_proto_header {
692 struct net_udp_hdr *udp;
693 struct net_tcp_hdr *tcp;
694};
695
696#define NET_UDPH_LEN 8 /* Size of UDP header */
697#define NET_TCPH_LEN 20 /* Size of TCP header */
698#define NET_ICMPH_LEN 4 /* Size of ICMP header */
699
700#define NET_IPV6H_LEN 40 /* Size of IPv6 header */
701#define NET_ICMPV6H_LEN NET_ICMPH_LEN /* Size of ICMPv6 header */
702#define NET_IPV6UDPH_LEN (NET_UDPH_LEN + NET_IPV6H_LEN) /* IPv6 + UDP */
703#define NET_IPV6TCPH_LEN (NET_TCPH_LEN + NET_IPV6H_LEN) /* IPv6 + TCP */
704#define NET_IPV6ICMPH_LEN (NET_IPV6H_LEN + NET_ICMPH_LEN) /* ICMPv6 + IPv6 */
705#define NET_IPV6_FRAGH_LEN 8
706
707#define NET_IPV4H_LEN 20 /* Size of IPv4 header */
708#define NET_ICMPV4H_LEN NET_ICMPH_LEN /* Size of ICMPv4 header */
709#define NET_IPV4UDPH_LEN (NET_UDPH_LEN + NET_IPV4H_LEN) /* IPv4 + UDP */
710#define NET_IPV4TCPH_LEN (NET_TCPH_LEN + NET_IPV4H_LEN) /* IPv4 + TCP */
711#define NET_IPV4ICMPH_LEN (NET_IPV4H_LEN + NET_ICMPH_LEN) /* ICMPv4 + IPv4 */
712
713#define NET_IPV6H_LENGTH_OFFSET 0x04 /* Offset of the Length field in the IPv6 header */
714
715#define NET_IPV6_FRAGH_OFFSET_MASK 0xfff8 /* Mask for the 13-bit Fragment Offset field */
716#define NET_IPV4_FRAGH_OFFSET_MASK 0x1fff /* Mask for the 13-bit Fragment Offset field */
717#define NET_IPV4_MORE_FRAG_MASK 0x2000 /* Mask for the 1-bit More Fragments field */
718#define NET_IPV4_DO_NOT_FRAG_MASK 0x4000 /* Mask for the 1-bit Do Not Fragment field */
719
721#if defined(CONFIG_NET_INTERFACE_NAME)
722#define NET_IFNAMSIZ CONFIG_NET_INTERFACE_NAME_LEN
723#else
724#if defined(Z_DEVICE_MAX_NAME_LEN)
725#define NET_IFNAMSIZ Z_DEVICE_MAX_NAME_LEN
726#else
727#define NET_IFNAMSIZ 1
728#endif /* Z_DEVICE_MAX_NAME_LEN */
729#endif /* CONFIG_NET_INTERFACE_NAME */
730
732
737
739struct net_ifreq {
740 char ifr_name[NET_IFNAMSIZ];
741};
742
743
755
764
772
783
792 unsigned int ipi6_ifindex;
793};
794
796static inline bool net_ipv6_is_addr_loopback_raw(const uint8_t *addr)
797{
798 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
799 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
800 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
801 net_ntohl(UNALIGNED_GET((uint32_t *)addr + 3)) == 1;
802}
804
812static inline bool net_ipv6_is_addr_loopback(const struct net_in6_addr *addr)
813{
814 return net_ipv6_is_addr_loopback_raw(addr->s6_addr);
815}
816
818static inline bool net_ipv6_is_addr_mcast_raw(const uint8_t *addr)
819{
820 return addr[0] == 0xff;
821}
823
831static inline bool net_ipv6_is_addr_mcast(const struct net_in6_addr *addr)
832{
833 return net_ipv6_is_addr_mcast_raw(addr->s6_addr);
834}
835
836struct net_if;
837struct net_if_config;
838
840extern struct net_if_addr *net_if_ipv6_addr_lookup_raw(const uint8_t *addr,
841 struct net_if **ret);
842
843static inline bool net_ipv6_is_my_addr_raw(const uint8_t *addr)
844{
845 return net_if_ipv6_addr_lookup_raw(addr, NULL) != NULL;
846}
848
849extern struct net_if_addr *net_if_ipv6_addr_lookup(const struct net_in6_addr *addr,
850 struct net_if **iface);
851
859static inline bool net_ipv6_is_my_addr(struct net_in6_addr *addr)
860{
861 return net_if_ipv6_addr_lookup(addr, NULL) != NULL;
862}
863
865 const struct net_in6_addr *addr, struct net_if **iface);
866
875static inline bool net_ipv6_is_my_maddr(struct net_in6_addr *maddr)
876{
877 return net_if_ipv6_maddr_lookup(maddr, NULL) != NULL;
878}
879
889static inline bool net_ipv6_is_prefix(const uint8_t *addr1,
890 const uint8_t *addr2,
891 uint8_t length)
892{
893 uint8_t bits = 128 - length;
894 uint8_t bytes = length / 8U;
895 uint8_t remain = bits % 8;
896 uint8_t mask;
897
898 if (length > 128) {
899 return false;
900 }
901
902 if (memcmp(addr1, addr2, bytes)) {
903 return false;
904 }
905
906 if (!remain) {
907 /* No remaining bits, the prefixes are the same as first
908 * bytes are the same.
909 */
910 return true;
911 }
912
913 /* Create a mask that has remaining most significant bits set */
914 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
915
916 return (addr1[bytes] & mask) == (addr2[bytes] & mask);
917}
918
919
927static inline void net_ipv6_addr_prefix_mask(const uint8_t *inaddr,
928 uint8_t *outaddr,
929 uint8_t prefix_len)
930{
931 uint8_t bits = 128 - prefix_len;
932 uint8_t bytes = prefix_len / 8U;
933 uint8_t remain = bits % 8;
934 uint8_t mask;
935
936 memset(outaddr, 0, 16U);
937 memcpy(outaddr, inaddr, bytes);
938
939 if (!remain) {
940 /* No remaining bits, the prefixes are the same as first
941 * bytes are the same.
942 */
943 return;
944 }
945
946 /* Create a mask that has remaining most significant bits set */
947 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
948 outaddr[bytes] = inaddr[bytes] & mask;
949}
950
952static inline bool net_ipv4_is_addr_loopback_raw(const uint8_t *addr)
953{
954 return addr[0] == 127U;
955}
957
965static inline bool net_ipv4_is_addr_loopback(const struct net_in_addr *addr)
966{
967 return net_ipv4_is_addr_loopback_raw(addr->s4_addr);
968}
969
971static inline bool net_ipv4_is_addr_unspecified_raw(const uint8_t *addr)
972{
973 return UNALIGNED_GET((uint32_t *)addr) == 0;
974}
976
984static inline bool net_ipv4_is_addr_unspecified(const struct net_in_addr *addr)
985{
986 return net_ipv4_is_addr_unspecified_raw(addr->s4_addr);
987}
988
990static inline bool net_ipv4_is_addr_mcast_raw(const uint8_t *addr)
991{
992 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xF0000000) == 0xE0000000;
993}
995
1003static inline bool net_ipv4_is_addr_mcast(const struct net_in_addr *addr)
1004{
1005 return net_ipv4_is_addr_mcast_raw(addr->s4_addr);
1006}
1007
1009static inline bool net_ipv4_is_ll_addr_raw(const uint8_t *addr)
1010{
1011 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xFFFF0000) == 0xA9FE0000;
1012}
1014
1022static inline bool net_ipv4_is_ll_addr(const struct net_in_addr *addr)
1023{
1024 return net_ipv4_is_ll_addr_raw(addr->s4_addr);
1025}
1026
1036static inline bool net_ipv4_is_private_addr(const struct net_in_addr *addr)
1037{
1038 uint32_t masked_24, masked_16, masked_12, masked_10, masked_8;
1039
1040 masked_24 = net_ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xFFFFFF00;
1041 masked_16 = masked_24 & 0xFFFF0000;
1042 masked_12 = masked_24 & 0xFFF00000;
1043 masked_10 = masked_24 & 0xFFC00000;
1044 masked_8 = masked_24 & 0xFF000000;
1045
1046 return masked_8 == 0x0A000000 || /* 10.0.0.0/8 */
1047 masked_10 == 0x64400000 || /* 100.64.0.0/10 */
1048 masked_12 == 0xAC100000 || /* 172.16.0.0/12 */
1049 masked_16 == 0xC0A80000 || /* 192.168.0.0/16 */
1050 masked_24 == 0xC0000200 || /* 192.0.2.0/24 */
1051 masked_24 == 0xC0336400 || /* 192.51.100.0/24 */
1052 masked_24 == 0xCB007100; /* 203.0.113.0/24 */
1053}
1054
1063#define net_ipaddr_copy(dest, src) \
1064 UNALIGNED_PUT(UNALIGNED_GET(src), dest)
1065
1072static inline void net_ipv4_addr_copy_raw(uint8_t *dest,
1073 const uint8_t *src)
1074{
1075 net_ipaddr_copy((struct net_in_addr *)dest, (const struct net_in_addr *)src);
1076}
1077
1084static inline void net_ipv6_addr_copy_raw(uint8_t *dest,
1085 const uint8_t *src)
1086{
1087 memcpy(dest, src, sizeof(struct net_in6_addr));
1088}
1089
1098static inline bool net_ipv4_addr_cmp_raw(const uint8_t *addr1,
1099 const uint8_t *addr2)
1100{
1101 return UNALIGNED_GET((uint32_t *)addr1) == UNALIGNED_GET((uint32_t *)addr2);
1102}
1103
1112static inline bool net_ipv4_addr_cmp(const struct net_in_addr *addr1,
1113 const struct net_in_addr *addr2)
1114{
1115 return net_ipv4_addr_cmp_raw(addr1->s4_addr, addr2->s4_addr);
1116}
1117
1126static inline bool net_ipv6_addr_cmp(const struct net_in6_addr *addr1,
1127 const struct net_in6_addr *addr2)
1128{
1129 return !memcmp(addr1, addr2, sizeof(struct net_in6_addr));
1130}
1131
1140static inline bool net_ipv6_addr_cmp_raw(const uint8_t *addr1,
1141 const uint8_t *addr2)
1142{
1143 return net_ipv6_addr_cmp((const struct net_in6_addr *)addr1,
1144 (const struct net_in6_addr *)addr2);
1145}
1146
1148static inline bool net_ipv6_is_ll_addr_raw(const uint8_t *addr)
1149{
1150 return UNALIGNED_GET((uint16_t *)addr) == net_htons(0xFE80);
1151}
1153
1161static inline bool net_ipv6_is_ll_addr(const struct net_in6_addr *addr)
1162{
1163 return net_ipv6_is_ll_addr_raw(addr->s6_addr);
1164}
1165
1173static inline bool net_ipv6_is_sl_addr(const struct net_in6_addr *addr)
1174{
1175 return UNALIGNED_GET(&addr->s6_addr16[0]) == net_htons(0xFEC0);
1176}
1177
1178
1186static inline bool net_ipv6_is_ula_addr(const struct net_in6_addr *addr)
1187{
1188 return addr->s6_addr[0] == 0xFD;
1189}
1190
1198static inline bool net_ipv6_is_global_addr(const struct net_in6_addr *addr)
1199{
1200 return (addr->s6_addr[0] & 0xE0) == 0x20;
1201}
1202
1212static inline bool net_ipv6_is_private_addr(const struct net_in6_addr *addr)
1213{
1214 uint32_t masked_32, masked_7;
1215
1216 masked_32 = net_ntohl(UNALIGNED_GET(&addr->s6_addr32[0]));
1217 masked_7 = masked_32 & 0xfc000000;
1218
1219 return masked_32 == 0x20010db8 || /* 2001:db8::/32 */
1220 masked_7 == 0xfc000000; /* fc00::/7 */
1221}
1222
1229
1236
1243
1244struct net_if;
1245extern bool net_if_ipv4_addr_mask_cmp(struct net_if *iface,
1246 const struct net_in_addr *addr);
1247
1257static inline bool net_ipv4_addr_mask_cmp(struct net_if *iface,
1258 const struct net_in_addr *addr)
1259{
1260 return net_if_ipv4_addr_mask_cmp(iface, addr);
1261}
1262
1264extern bool net_if_ipv4_is_addr_bcast_raw(struct net_if *iface,
1265 const uint8_t *addr);
1266
1267#if defined(CONFIG_NET_NATIVE_IPV4)
1268static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1269 const uint8_t *addr)
1270{
1271 if (net_ipv4_addr_cmp_raw(addr, net_ipv4_broadcast_address()->s4_addr)) {
1272 return true;
1273 }
1274
1275 return net_if_ipv4_is_addr_bcast_raw(iface, addr);
1276}
1277#else
1278static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1279 const uint8_t *addr)
1280{
1281 ARG_UNUSED(iface);
1282 ARG_UNUSED(addr);
1283
1284 return false;
1285}
1286#endif
1288
1289extern bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
1290 const struct net_in_addr *addr);
1291
1300#if defined(CONFIG_NET_NATIVE_IPV4)
1301static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1302 const struct net_in_addr *addr)
1303{
1305 return true;
1306 }
1307
1308 return net_if_ipv4_is_addr_bcast(iface, addr);
1309}
1310#else
1311static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1312 const struct net_in_addr *addr)
1313{
1314 ARG_UNUSED(iface);
1315 ARG_UNUSED(addr);
1316
1317 return false;
1318}
1319#endif
1320
1322extern struct net_if_addr *net_if_ipv4_addr_lookup_raw(const uint8_t *addr,
1323 struct net_if **ret);
1324
1325static inline bool net_ipv4_is_my_addr_raw(const uint8_t *addr)
1326{
1327 bool ret;
1328
1329 ret = net_if_ipv4_addr_lookup_raw(addr, NULL) != NULL;
1330 if (!ret) {
1331 ret = net_ipv4_is_addr_bcast_raw(NULL, addr);
1332 }
1333
1334 return ret;
1335}
1337
1338extern struct net_if_addr *net_if_ipv4_addr_lookup(const struct net_in_addr *addr,
1339 struct net_if **iface);
1340
1350static inline bool net_ipv4_is_my_addr(const struct net_in_addr *addr)
1351{
1352 bool ret;
1353
1354 ret = net_if_ipv4_addr_lookup(addr, NULL) != NULL;
1355 if (!ret) {
1356 ret = net_ipv4_is_addr_bcast(NULL, addr);
1357 }
1358
1359 return ret;
1360}
1361
1363static inline bool net_ipv6_is_addr_unspecified_raw(const uint8_t *addr)
1364{
1365 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
1366 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
1367 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
1368 UNALIGNED_GET((uint32_t *)addr + 3) == 0;
1369}
1371
1379static inline bool net_ipv6_is_addr_unspecified(const struct net_in6_addr *addr)
1380{
1381 return net_ipv6_is_addr_unspecified_raw(addr->s6_addr);
1382}
1383
1385static inline bool net_ipv6_is_addr_solicited_node_raw(const uint8_t *addr)
1386{
1387 return UNALIGNED_GET((uint32_t *)addr) == net_htonl(0xff020000) &&
1388 UNALIGNED_GET((uint32_t *)addr + 1) == 0x00000000 &&
1389 UNALIGNED_GET((uint32_t *)addr + 2) == net_htonl(0x00000001) &&
1390 ((UNALIGNED_GET((uint32_t *)addr + 3) & net_htonl(0xff000000)) ==
1391 net_htonl(0xff000000));
1392}
1394
1403static inline bool net_ipv6_is_addr_solicited_node(const struct net_in6_addr *addr)
1404{
1405 return net_ipv6_is_addr_solicited_node_raw(addr->s6_addr);
1406}
1407
1409static inline bool net_ipv6_is_addr_mcast_scope_raw(const uint8_t *addr,
1410 int scope)
1411{
1412 return (addr[0] == 0xff) && ((addr[1] & 0xF) == scope);
1413}
1415
1417static inline int net_ipv6_get_addr_mcast_scope_raw(const uint8_t *addr)
1418{
1419 if (addr[0] == 0xff) {
1420 return (addr[1] & 0xF);
1421 }
1422
1423 return -1;
1424}
1426
1437static inline bool net_ipv6_is_addr_mcast_scope(const struct net_in6_addr *addr,
1438 int scope)
1439{
1440 return net_ipv6_is_addr_mcast_scope_raw(addr->s6_addr, scope);
1441}
1442
1452static inline bool net_ipv6_is_same_mcast_scope(const struct net_in6_addr *addr_1,
1453 const struct net_in6_addr *addr_2)
1454{
1455 return (addr_1->s6_addr[0] == 0xff) && (addr_2->s6_addr[0] == 0xff) &&
1456 (addr_1->s6_addr[1] == addr_2->s6_addr[1]);
1457}
1458
1466static inline int net_ipv6_get_addr_mcast_scope(const struct net_in6_addr *addr)
1467{
1468 return net_ipv6_get_addr_mcast_scope_raw(addr->s6_addr);
1469}
1470
1472static inline bool net_ipv6_is_addr_mcast_iface_raw(const uint8_t *addr)
1473{
1474 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x01);
1475}
1476
1477static inline bool net_ipv6_is_addr_mcast_link_raw(const uint8_t *addr)
1478{
1479 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x02);
1480}
1481
1482static inline bool net_ipv6_is_addr_mcast_mesh_raw(const uint8_t *addr)
1483{
1484 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x03);
1485}
1486
1487static inline bool net_ipv6_is_addr_mcast_site_raw(const uint8_t *addr)
1488{
1489 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x05);
1490}
1491
1492static inline bool net_ipv6_is_addr_mcast_org_raw(const uint8_t *addr)
1493{
1494 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x08);
1495}
1497
1505static inline bool net_ipv6_is_addr_mcast_global(const struct net_in6_addr *addr)
1506{
1507 return net_ipv6_is_addr_mcast_scope(addr, 0x0e);
1508}
1509
1519static inline bool net_ipv6_is_addr_mcast_iface(const struct net_in6_addr *addr)
1520{
1521 return net_ipv6_is_addr_mcast_scope(addr, 0x01);
1522}
1523
1533static inline bool net_ipv6_is_addr_mcast_link(const struct net_in6_addr *addr)
1534{
1535 return net_ipv6_is_addr_mcast_scope(addr, 0x02);
1536}
1537
1547static inline bool net_ipv6_is_addr_mcast_mesh(const struct net_in6_addr *addr)
1548{
1549 return net_ipv6_is_addr_mcast_scope(addr, 0x03);
1550}
1551
1561static inline bool net_ipv6_is_addr_mcast_site(const struct net_in6_addr *addr)
1562{
1563 return net_ipv6_is_addr_mcast_scope(addr, 0x05);
1564}
1565
1575static inline bool net_ipv6_is_addr_mcast_org(const struct net_in6_addr *addr)
1576{
1577 return net_ipv6_is_addr_mcast_scope(addr, 0x08);
1578}
1579
1581static inline bool net_ipv6_is_addr_mcast_group_raw(const uint8_t *addr,
1582 const uint8_t *group)
1583{
1584 return UNALIGNED_GET((uint16_t *)addr + 1) == UNALIGNED_GET((uint16_t *)group + 1) &&
1585 UNALIGNED_GET((uint32_t *)addr + 1) == UNALIGNED_GET((uint32_t *)group + 1) &&
1586 UNALIGNED_GET((uint32_t *)addr + 2) == UNALIGNED_GET((uint32_t *)group + 2) &&
1587 UNALIGNED_GET((uint32_t *)addr + 3) == UNALIGNED_GET((uint32_t *)group + 3);
1588}
1590
1601static inline bool net_ipv6_is_addr_mcast_group(const struct net_in6_addr *addr,
1602 const struct net_in6_addr *group)
1603{
1604 return net_ipv6_is_addr_mcast_group_raw(addr->s6_addr, group->s6_addr);
1605}
1606
1608static inline bool net_ipv6_is_addr_mcast_all_nodes_group_raw(const uint8_t *addr)
1609{
1610 static const uint8_t all_nodes_mcast_group[NET_IPV6_ADDR_SIZE] = {
1611 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1612 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1613 };
1614
1615 return net_ipv6_is_addr_mcast_group_raw(addr, all_nodes_mcast_group);
1616}
1618
1627static inline bool
1629{
1630 return net_ipv6_is_addr_mcast_all_nodes_group_raw(addr->s6_addr);
1631}
1632
1642static inline bool
1648
1650static inline bool net_ipv6_is_addr_mcast_link_all_nodes_raw(const uint8_t *addr)
1651{
1652 return net_ipv6_is_addr_mcast_link_raw(addr) &&
1653 net_ipv6_is_addr_mcast_all_nodes_group_raw(addr);
1654}
1656
1666static inline bool
1672
1680static inline
1682 struct net_in6_addr *dst)
1683{
1684 dst->s6_addr[0] = 0xFF;
1685 dst->s6_addr[1] = 0x02;
1686 UNALIGNED_PUT(0, &dst->s6_addr16[1]);
1687 UNALIGNED_PUT(0, &dst->s6_addr16[2]);
1688 UNALIGNED_PUT(0, &dst->s6_addr16[3]);
1689 UNALIGNED_PUT(0, &dst->s6_addr16[4]);
1690 dst->s6_addr[10] = 0U;
1691 dst->s6_addr[11] = 0x01;
1692 dst->s6_addr[12] = 0xFF;
1693 dst->s6_addr[13] = src->s6_addr[13];
1694 UNALIGNED_PUT(UNALIGNED_GET(&src->s6_addr16[7]), &dst->s6_addr16[7]);
1695}
1696
1709static inline void net_ipv6_addr_create(struct net_in6_addr *addr,
1710 uint16_t addr0, uint16_t addr1,
1711 uint16_t addr2, uint16_t addr3,
1712 uint16_t addr4, uint16_t addr5,
1713 uint16_t addr6, uint16_t addr7)
1714{
1715 UNALIGNED_PUT(net_htons(addr0), &addr->s6_addr16[0]);
1716 UNALIGNED_PUT(net_htons(addr1), &addr->s6_addr16[1]);
1717 UNALIGNED_PUT(net_htons(addr2), &addr->s6_addr16[2]);
1718 UNALIGNED_PUT(net_htons(addr3), &addr->s6_addr16[3]);
1719 UNALIGNED_PUT(net_htons(addr4), &addr->s6_addr16[4]);
1720 UNALIGNED_PUT(net_htons(addr5), &addr->s6_addr16[5]);
1721 UNALIGNED_PUT(net_htons(addr6), &addr->s6_addr16[6]);
1722 UNALIGNED_PUT(net_htons(addr7), &addr->s6_addr16[7]);
1723}
1724
1731{
1732 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001);
1733}
1734
1741{
1742 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002);
1743}
1744
1751static inline void net_ipv6_addr_create_v4_mapped(const struct net_in_addr *addr4,
1752 struct net_in6_addr *addr6)
1753{
1754 net_ipv6_addr_create(addr6, 0, 0, 0, 0, 0, 0xffff,
1755 net_ntohs(addr4->s4_addr16[0]),
1756 net_ntohs(addr4->s4_addr16[1]));
1757}
1758
1767static inline bool net_ipv6_addr_is_v4_mapped(const struct net_in6_addr *addr)
1768{
1769 if (UNALIGNED_GET(&addr->s6_addr32[0]) == 0 &&
1770 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 &&
1771 UNALIGNED_GET(&addr->s6_addr16[5]) == 0xffff) {
1772 return true;
1773 }
1774
1775 return false;
1776}
1777
1786static inline void net_ipv6_addr_get_v4_mapped(const struct net_in6_addr *addr6,
1787 struct net_in_addr *addr4)
1788{
1789 addr4->s_addr = UNALIGNED_GET(&addr6->s6_addr32[3]);
1790}
1791
1811 const struct net_in6_addr *prefix,
1812 uint8_t *network_id, size_t network_id_len,
1813 uint8_t dad_counter,
1814 struct net_in6_addr *addr,
1815 struct net_linkaddr *lladdr);
1816
1823static inline void net_ipv6_addr_create_iid(struct net_in6_addr *addr,
1824 struct net_linkaddr *lladdr)
1825{
1826 (void)net_ipv6_addr_generate_iid(NULL, NULL, NULL, 0, 0, addr, lladdr);
1827}
1828
1830static inline bool net_ipv6_addr_based_on_ll_raw(const uint8_t *addr,
1831 const struct net_linkaddr *lladdr)
1832{
1833 if (addr == NULL || lladdr == NULL) {
1834 return false;
1835 }
1836
1837 switch (lladdr->len) {
1838 case 2:
1839 if (!memcmp(&addr[14], lladdr->addr, lladdr->len) &&
1840 addr[8] == 0U &&
1841 addr[9] == 0U &&
1842 addr[10] == 0U &&
1843 addr[11] == 0xff &&
1844 addr[12] == 0xfe) {
1845 return true;
1846 }
1847
1848 break;
1849 case 6:
1850 if (lladdr->type == NET_LINK_ETHERNET) {
1851 if (!memcmp(&addr[9], &lladdr->addr[1], 2) &&
1852 !memcmp(&addr[13], &lladdr->addr[3], 3) &&
1853 addr[11] == 0xff &&
1854 addr[12] == 0xfe &&
1855 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1856 return true;
1857 }
1858 }
1859
1860 break;
1861 case 8:
1862 if (sizeof(lladdr->addr) < 8) {
1863 return false;
1864 }
1865
1866 if (!memcmp(&addr[9], &lladdr->addr[1],
1867 lladdr->len - 1) &&
1868 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1869 return true;
1870 }
1871
1872 break;
1873 default:
1874 return false;
1875 }
1876
1877 return false;
1878}
1880
1886static inline bool net_ipv6_addr_based_on_ll(const struct net_in6_addr *addr,
1887 const struct net_linkaddr *lladdr)
1888{
1889 if (addr == NULL || lladdr == NULL) {
1890 return false;
1891 }
1892
1893 return net_ipv6_addr_based_on_ll_raw(addr->s6_addr, lladdr);
1894}
1895
1904static inline struct net_sockaddr *net_sad(const struct net_sockaddr_storage *addr)
1905{
1906 return (struct net_sockaddr *)addr;
1907}
1908
1917static inline struct net_sockaddr_in6 *net_sin6(const struct net_sockaddr *addr)
1918{
1919 return (struct net_sockaddr_in6 *)addr;
1920}
1921
1930static inline struct net_sockaddr_in *net_sin(const struct net_sockaddr *addr)
1931{
1932 return (struct net_sockaddr_in *)addr;
1933}
1934
1943static inline
1944struct net_sockaddr_in6_ptr *net_sin6_ptr(const struct net_sockaddr_ptr *addr)
1945{
1946 return (struct net_sockaddr_in6_ptr *)addr;
1947}
1948
1957static inline
1958struct net_sockaddr_in_ptr *net_sin_ptr(const struct net_sockaddr_ptr *addr)
1959{
1960 return (struct net_sockaddr_in_ptr *)addr;
1961}
1962
1971static inline
1972struct net_sockaddr_ll_ptr *net_sll_ptr(const struct net_sockaddr_ptr *addr)
1973{
1974 return (struct net_sockaddr_ll_ptr *)addr;
1975}
1976
1985static inline
1986struct net_sockaddr_can_ptr *net_can_ptr(const struct net_sockaddr_ptr *addr)
1987{
1988 return (struct net_sockaddr_can_ptr *)addr;
1989}
1990
2004__syscall int net_addr_pton(net_sa_family_t family, const char *src, void *dst);
2005
2017__syscall char *net_addr_ntop(net_sa_family_t family, const void *src,
2018 char *dst, size_t size);
2019
2031 struct net_sockaddr *mask);
2032
2044 uint8_t *mask_len);
2045
2067bool net_ipaddr_parse(const char *str, size_t str_len,
2068 struct net_sockaddr *addr);
2069
2097const char *net_ipaddr_parse_mask(const char *str, size_t str_len,
2098 struct net_sockaddr *addr, uint8_t *mask_len);
2099
2109int net_port_set_default(struct net_sockaddr *addr, uint16_t default_port);
2110
2122static inline int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
2123{
2124 return (int32_t)(seq1 - seq2);
2125}
2126
2137static inline bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
2138{
2139 return net_tcp_seq_cmp(seq1, seq2) > 0;
2140}
2141
2153int net_bytes_from_str(uint8_t *buf, int buf_len, const char *src);
2154
2164
2174
2183static inline enum net_priority net_vlan2priority(uint8_t priority)
2184{
2185 /* Map according to IEEE 802.1Q */
2186 static const uint8_t vlan2priority[] = {
2195 };
2196
2197 if (priority >= ARRAY_SIZE(vlan2priority)) {
2198 /* Use Best Effort as the default priority */
2199 return NET_PRIORITY_BE;
2200 }
2201
2202 return (enum net_priority)vlan2priority[priority];
2203}
2204
2212static inline uint8_t net_priority2vlan(enum net_priority priority)
2213{
2214 /* The conversion works both ways */
2215 return (uint8_t)net_vlan2priority(priority);
2216}
2217
2227
2235static inline size_t net_family2size(net_sa_family_t family)
2236{
2237 switch (family) {
2238 case NET_AF_INET:
2239 return sizeof(struct net_sockaddr_in);
2240 case NET_AF_INET6:
2241 return sizeof(struct net_sockaddr_in6);
2242 case NET_AF_PACKET:
2243 return sizeof(struct net_sockaddr_ll);
2244 case NET_AF_UNIX:
2245 return sizeof(struct net_sockaddr_un);
2246 case NET_AF_CAN:
2247 return sizeof(struct net_sockaddr_can);
2248 case NET_AF_NET_MGMT:
2249 return sizeof(struct net_sockaddr_nm);
2250 default:
2251 return 0;
2252 }
2253}
2254
2265#if defined(CONFIG_NET_IPV6_PE)
2266int net_ipv6_pe_add_filter(struct net_in6_addr *addr, bool is_denylist);
2267#else
2268static inline int net_ipv6_pe_add_filter(struct net_in6_addr *addr,
2269 bool is_denylist)
2270{
2271 ARG_UNUSED(addr);
2272 ARG_UNUSED(is_denylist);
2273
2274 return -ENOTSUP;
2275}
2276#endif /* CONFIG_NET_IPV6_PE */
2277
2285#if defined(CONFIG_NET_IPV6_PE)
2286int net_ipv6_pe_del_filter(struct net_in6_addr *addr);
2287#else
2288static inline int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
2289{
2290 ARG_UNUSED(addr);
2291
2292 return -ENOTSUP;
2293}
2294#endif /* CONFIG_NET_IPV6_PE */
2295
2296#ifdef __cplusplus
2297}
2298#endif
2299
2300#include <zephyr/syscalls/net_ip.h>
2301
2302#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
2303#define ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2304#include <zephyr/net/net_compat.h>
2305#undef ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2306#endif /* CONFIG_NET_NAMESPACE_COMPAT_MODE */
2307
2311
2312#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:1986
#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:1186
static size_t net_family2size(net_sa_family_t family)
Return network address size for a given family.
Definition net_ip.h:2235
#define NET_IPV4_ADDR_SIZE
Binary size of the IPv4 address.
Definition net_ip.h:165
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:2183
static int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
Compare TCP sequence numbers.
Definition net_ip.h:2122
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:875
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:152
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:1112
#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:1767
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:1379
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:1547
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:1751
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:1003
net_addr_state
What is the current state of the network address.
Definition net_ip.h:576
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:1098
uint32_t net_socklen_t
Length of a socket address.
Definition net_ip.h:171
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:1212
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:984
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:831
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:1519
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:100
static void net_ipv6_addr_copy_raw(uint8_t *dest, const uint8_t *src)
Copy an IPv6 address raw buffer.
Definition net_ip.h:1084
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:1257
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:927
#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:1904
#define net_htonl(x)
Convert 32-bit value from host to network byte order.
Definition net_ip.h:132
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:1917
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:1958
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:1350
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:965
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:1022
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:1126
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:1730
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:1786
#define net_ipaddr_copy(dest, src)
Copy an IPv4 or IPv6 address.
Definition net_ip.h:1063
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:1886
net_ip_mtu
IP Maximum Transfer Unit.
Definition net_ip.h:532
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:1466
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:1823
static struct net_sockaddr_in * net_sin(const struct net_sockaddr *addr)
Get net_sockaddr_in from net_sockaddr.
Definition net_ip.h:1930
#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:168
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:2212
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:1561
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:1437
#define SOCKADDR_ALIGN
Definition net_ip.h:445
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:859
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:889
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:812
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:1575
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:2268
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:1601
static bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
Check that one TCP sequence number is greater.
Definition net_ip.h:2137
net_sock_type
Socket type.
Definition net_ip.h:88
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:1403
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:1709
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:1198
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:1972
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:1667
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:1944
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:1628
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:1452
static int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
Delete IPv6 prefix from privacy extension filter list.
Definition net_ip.h:2288
#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:1161
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:1036
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:1681
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:1533
#define net_ntohl(x)
Convert 32-bit value from network to host byte order.
Definition net_ip.h:108
#define net_htons(x)
Convert 16-bit value from host to network byte order.
Definition net_ip.h:124
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:1740
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:553
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:1643
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:1173
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:1072
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:1505
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:1140
net_addr_type
How the network address is assigned to network interface.
Definition net_ip.h:584
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:1311
@ NET_ADDR_ANY_STATE
Default (invalid) address type.
Definition net_ip.h:577
@ NET_ADDR_TENTATIVE
Tentative address.
Definition net_ip.h:578
@ NET_ADDR_DEPRECATED
Deprecated address.
Definition net_ip.h:580
@ NET_ADDR_PREFERRED
Preferred address.
Definition net_ip.h:579
@ 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_DTLS_1_0
DTLS 1.0 protocol.
Definition net_ip.h:83
@ NET_IPV4_MTU
IPv4 MTU length.
Definition net_ip.h:548
@ NET_IPV6_MTU
IPv6 MTU length.
Definition net_ip.h:539
@ NET_SOCK_STREAM
Stream socket type.
Definition net_ip.h:89
@ NET_SOCK_RAW
RAW socket type.
Definition net_ip.h:91
@ NET_SOCK_DGRAM
Datagram socket type.
Definition net_ip.h:90
@ NET_PRIORITY_NC
Network control (highest).
Definition net_ip.h:561
@ NET_PRIORITY_IC
Internetwork control.
Definition net_ip.h:560
@ NET_PRIORITY_CA
Critical applications.
Definition net_ip.h:557
@ NET_PRIORITY_VO
Voice, < 10 ms latency and jitter.
Definition net_ip.h:559
@ NET_PRIORITY_VI
Video, < 100 ms latency and jitter.
Definition net_ip.h:558
@ NET_PRIORITY_BE
Best effort (default).
Definition net_ip.h:555
@ NET_PRIORITY_EE
Excellent effort.
Definition net_ip.h:556
@ NET_PRIORITY_BK
Background (lowest).
Definition net_ip.h:554
@ 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:586
@ NET_ADDR_OVERRIDABLE
Manually set address which is overridable by DHCP.
Definition net_ip.h:594
@ NET_ADDR_DHCP
Address is from DHCP.
Definition net_ip.h:590
@ NET_ADDR_MANUAL
Manually set address.
Definition net_ip.h:592
@ NET_ADDR_AUTOCONF
Auto configured address.
Definition net_ip.h:588
@ NET_LINK_ETHERNET
Ethernet link address.
Definition net_linkaddr.h:55
#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:305
net_socklen_t cmsg_len
Number of bytes, including header.
Definition net_ip.h:306
int cmsg_level
Originating protocol.
Definition net_ip.h:307
int cmsg_type
Protocol-specific type.
Definition net_ip.h:308
z_max_align_t cmsg_data[]
Flexible array member to force alignment of net_cmsghdr.
Definition net_ip.h:309
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:739
char ifr_name[NET_IFNAMSIZ]
Network interface name.
Definition net_ip.h:740
IPv6 address struct.
Definition net_ip.h:143
uint16_t s6_addr16[8]
In big endian.
Definition net_ip.h:146
uint32_t s6_addr32[4]
In big endian.
Definition net_ip.h:147
uint8_t s6_addr[16]
IPv6 address buffer.
Definition net_ip.h:145
Incoming IPv6 packet information.
Definition net_ip.h:790
unsigned int ipi6_ifindex
Receive interface index.
Definition net_ip.h:792
struct net_in6_addr ipi6_addr
Destination IPv6 address.
Definition net_ip.h:791
IPv4 address struct.
Definition net_ip.h:155
uint16_t s4_addr16[2]
In big endian.
Definition net_ip.h:158
uint32_t s4_addr32[1]
In big endian.
Definition net_ip.h:159
uint32_t s_addr
In big endian, for POSIX compatibility.
Definition net_ip.h:160
uint8_t s4_addr[4]
IPv4 address buffer.
Definition net_ip.h:157
Incoming IPv4 packet information.
Definition net_ip.h:750
unsigned int ipi_ifindex
Network interface index.
Definition net_ip.h:751
struct net_in_addr ipi_addr
Header Destination address.
Definition net_ip.h:753
struct net_in_addr ipi_spec_dst
Local address.
Definition net_ip.h:752
IO vector array element.
Definition net_ip.h:287
void * iov_base
Pointer to data.
Definition net_ip.h:288
size_t iov_len
Length of the data.
Definition net_ip.h:289
Struct used when setting a IPv4 multicast network interface.
Definition net_ip.h:768
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:769
struct net_in_addr imr_interface
IP address of local interface.
Definition net_ip.h:770
Struct used when joining or leaving a IPv4 multicast group.
Definition net_ip.h:759
int imr_ifindex
Network interface index.
Definition net_ip.h:762
struct net_in_addr imr_address
IP address of local interface.
Definition net_ip.h:761
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:760
Struct used when joining or leaving a IPv6 multicast group.
Definition net_ip.h:776
struct net_in6_addr ipv6mr_multiaddr
IPv6 multicast address of group.
Definition net_ip.h:778
int ipv6mr_ifindex
Network interface index of the local IPv6 address.
Definition net_ip.h:781
Hardware link address structure.
Definition net_linkaddr.h:72
uint8_t addr[6]
The array of bytes representing the address.
Definition net_linkaddr.h:80
uint8_t type
What kind of address is this for.
Definition net_linkaddr.h:74
uint8_t len
The real length of the ll address.
Definition net_linkaddr.h:77
Message struct.
Definition net_ip.h:294
int msg_flags
Flags on received message.
Definition net_ip.h:301
struct net_iovec * msg_iov
Scatter/gather array.
Definition net_ip.h:297
net_socklen_t msg_namelen
Size of socket address.
Definition net_ip.h:296
size_t msg_controllen
Ancillary data buffer len.
Definition net_ip.h:300
void * msg_control
Ancillary data.
Definition net_ip.h:299
void * msg_name
Optional socket address, big endian.
Definition net_ip.h:295
size_t msg_iovlen
Number of elements in msg_iov.
Definition net_ip.h:298
struct net_sockaddr_can - The net_sockaddr structure for CAN sockets.
Definition net_ip.h:205
int can_ifindex
SocketCAN network interface index.
Definition net_ip.h:207
net_sa_family_t can_family
Address family.
Definition net_ip.h:206
Socket address struct for IPv6.
Definition net_ip.h:179
struct net_in6_addr sin6_addr
IPv6 address.
Definition net_ip.h:182
net_sa_family_t sin6_family
NET_AF_INET6.
Definition net_ip.h:180
uint8_t sin6_scope_id
Interfaces for a scope.
Definition net_ip.h:183
uint16_t sin6_port
Port number.
Definition net_ip.h:181
Socket address struct for IPv4.
Definition net_ip.h:187
uint16_t sin_port
Port number.
Definition net_ip.h:189
struct net_in_addr sin_addr
IPv4 address.
Definition net_ip.h:190
net_sa_family_t sin_family
NET_AF_INET.
Definition net_ip.h:188
Socket address struct for packet socket.
Definition net_ip.h:194
uint8_t sll_pkttype
Packet type.
Definition net_ip.h:199
int sll_ifindex
Interface number.
Definition net_ip.h:197
net_sa_family_t sll_family
Always NET_AF_PACKET.
Definition net_ip.h:195
uint16_t sll_hatype
ARP hardware type.
Definition net_ip.h:198
uint8_t sll_halen
Length of address.
Definition net_ip.h:200
uint16_t sll_protocol
Physical-layer protocol.
Definition net_ip.h:196
uint8_t sll_addr[8]
Physical-layer address, big endian.
Definition net_ip.h:201
struct net_sockaddr_nm - The net_sockaddr structure for NET_MGMT sockets
Definition net_ip.h:228
uint64_t nm_mask
net_mgmt mask
Definition net_ip.h:241
int nm_ifindex
Network interface related to this address.
Definition net_ip.h:233
uintptr_t nm_pid
Thread id or similar that is used to separate the different sockets.
Definition net_ip.h:238
net_sa_family_t nm_family
AF_NET_MGMT address family.
Definition net_ip.h:230
Generic sockaddr struct.
Definition net_ip.h:448
net_sa_family_t sa_family
Address family.
Definition net_ip.h:449
IPv6/IPv4 network connection tuple.
Definition net_ip.h:567
struct net_addr * remote_addr
IPv6/IPv4 remote address.
Definition net_ip.h:568
uint16_t local_port
UDP/TCP local port.
Definition net_ip.h:571
enum net_ip_protocol ip_proto
IP protocol.
Definition net_ip.h:572
uint16_t remote_port
UDP/TCP remote port.
Definition net_ip.h:570
struct net_addr * local_addr
IPv6/IPv4 local address.
Definition net_ip.h:569
Byte order helpers.
Misc utilities.
Macros to abstract toolchain specific capabilities.