Zephyr Project API 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
317};
318
320
321/* Alignment for headers and data. These are arch specific but define
322 * them here atm if not found already.
323 */
324#if !defined(NET_ALIGN_H)
325#define NET_ALIGN_H(x) ROUND_UP(x, __alignof__(struct net_cmsghdr))
326#endif
327#if !defined(NET_ALIGN_D)
328#define NET_ALIGN_D(x) ROUND_UP(x, __alignof__(z_max_align_t))
329#endif
330
332
333#if !defined(NET_CMSG_FIRSTHDR)
339#define NET_CMSG_FIRSTHDR(msghdr) \
340 ((msghdr)->msg_controllen >= sizeof(struct net_cmsghdr) ? \
341 (struct net_cmsghdr *)((msghdr)->msg_control) : NULL)
342#endif
343
344#if !defined(NET_CMSG_NXTHDR)
349#define NET_CMSG_NXTHDR(msghdr, cmsg) \
350 (((cmsg) == NULL) ? NET_CMSG_FIRSTHDR(msghdr) : \
351 (((uint8_t *)(cmsg) + NET_ALIGN_H((cmsg)->cmsg_len) + \
352 NET_ALIGN_D(sizeof(struct net_cmsghdr)) > \
353 (uint8_t *)((msghdr)->msg_control) + (msghdr)->msg_controllen) ? \
354 NULL : \
355 (struct net_cmsghdr *)((uint8_t *)(cmsg) + \
356 NET_ALIGN_H((cmsg)->cmsg_len))))
357#endif
358
359#if !defined(NET_CMSG_DATA)
367#define NET_CMSG_DATA(cmsg) ((uint8_t *)(cmsg) + NET_ALIGN_D(sizeof(struct net_cmsghdr)))
368#endif
369
370#if !defined(NET_CMSG_SPACE)
375#define NET_CMSG_SPACE(length) (NET_ALIGN_D(sizeof(struct net_cmsghdr)) + NET_ALIGN_H(length))
376#endif
377
378#if !defined(NET_CMSG_LEN)
384#define NET_CMSG_LEN(length) (NET_ALIGN_D(sizeof(struct net_cmsghdr)) + length)
385#endif
386
388
389/* Packet types. */
390#define NET_PACKET_HOST 0 /* To us */
391#define NET_PACKET_BROADCAST 1 /* To all */
392#define NET_PACKET_MULTICAST 2 /* To group */
393#define NET_PACKET_OTHERHOST 3 /* To someone else */
394#define NET_PACKET_OUTGOING 4 /* Originated by us */
395#define NET_PACKET_LOOPBACK 5
396#define NET_PACKET_FASTROUTE 6
397
398/* ARP protocol HARDWARE identifiers. */
399#define NET_ARPHRD_ETHER 1
400#define NET_ARPHRD_PPP 512
401
402/* Note: These macros are defined in a specific order.
403 * The largest sockaddr size is the last one.
404 */
405#if defined(CONFIG_NET_IPV4)
406#undef NET_SOCKADDR_MAX_SIZE
407#undef NET_SOCKADDR_PTR_MAX_SIZE
408#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in))
409#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in_ptr))
410#endif
411
412#if defined(CONFIG_NET_SOCKETS_PACKET)
413#undef NET_SOCKADDR_MAX_SIZE
414#undef NET_SOCKADDR_PTR_MAX_SIZE
415#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_ll))
416#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_ll_ptr))
417#endif
418
419#if defined(CONFIG_NET_IPV6)
420#undef NET_SOCKADDR_MAX_SIZE
421#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in6))
422#if !defined(CONFIG_NET_SOCKETS_PACKET)
423#undef NET_SOCKADDR_PTR_MAX_SIZE
424#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in6_ptr))
425#endif
426#endif
427
428#if defined(CONFIG_NET_NATIVE_OFFLOADED_SOCKETS)
429#define UNIX_PATH_MAX 108
430#undef NET_SOCKADDR_MAX_SIZE
431/* Define NET_SOCKADDR_MAX_SIZE to be struct of net_sa_family_t + char[UNIX_PATH_MAX] */
432#define NET_SOCKADDR_MAX_SIZE (UNIX_PATH_MAX+sizeof(net_sa_family_t))
433#if !defined(CONFIG_NET_SOCKETS_PACKET)
434#undef NET_SOCKADDR_PTR_MAX_SIZE
435#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_un_ptr))
436#endif
437#endif
438
439#if !defined(CONFIG_NET_IPV4)
440#if !defined(CONFIG_NET_IPV6)
441#if !defined(CONFIG_NET_SOCKETS_PACKET)
442#if !defined(CONFIG_NET_NATIVE_OFFLOADED_SOCKETS)
443#define NET_SOCKADDR_MAX_SIZE (sizeof(struct net_sockaddr_in6))
444#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct net_sockaddr_in6_ptr))
445#endif
446#endif
447#endif
448#endif
449
451
452#define SOCKADDR_ALIGN (4)
453
458 char data[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
460} __aligned(SOCKADDR_ALIGN);
461
463
464struct net_sockaddr_ptr {
465 net_sa_family_t family;
466 char data[NET_SOCKADDR_PTR_MAX_SIZE - sizeof(net_sa_family_t)];
467} __aligned(SOCKADDR_ALIGN);
468
469/* Same as sockaddr in our case */
470struct net_sockaddr_storage {
471 net_sa_family_t ss_family;
472 char data[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
473} __aligned(SOCKADDR_ALIGN);
474
475/* Socket address struct for UNIX domain sockets */
476struct net_sockaddr_un {
477 net_sa_family_t sun_family; /* NET_AF_UNIX */
478 char sun_path[NET_SOCKADDR_MAX_SIZE - sizeof(net_sa_family_t)];
479};
480
481struct net_addr {
482 net_sa_family_t family;
483 union {
484#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
485 struct net_in6_addr net_in6_addr;
486 struct net_in_addr net_in_addr;
487#else
488 struct net_in6_addr in6_addr;
489 struct net_in_addr in_addr;
490#endif
491 };
492};
493
495extern const struct net_in6_addr net_in6addr_any;
496
498extern const struct net_in6_addr net_in6addr_loopback;
499
501
503#define NET_IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, \
504 0, 0, 0, 0, 0, 0, 0, 0 } } }
505
507#define NET_IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, \
508 0, 0, 0, 0, 0, 0, 0, 1 } } }
509
511#define NET_INADDR_ANY 0
512
514#define NET_INADDR_BROADCAST 0xffffffff
515
517#define NET_INADDR_ANY_INIT { { { NET_INADDR_ANY } } }
518
520#define NET_INADDR_LOOPBACK_INIT { { { 127, 0, 0, 1 } } }
521
523#define NET_INET_ADDRSTRLEN 16
524
528#define NET_INET6_ADDRSTRLEN 46
529
531
532/* These are for internal usage of the stack */
533#define NET_IPV6_ADDR_LEN sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxx.xxx.xxx.xxx")
534#define NET_IPV4_ADDR_LEN sizeof("xxx.xxx.xxx.xxx")
535
537
543#if defined(CONFIG_NET_NATIVE_IPV6)
544 NET_IPV6_MTU = CONFIG_NET_IPV6_MTU,
545#else
547#endif
548
552#if defined(CONFIG_NET_NATIVE_IPV4)
553 NET_IPV4_MTU = CONFIG_NET_IPV4_MTU,
554#else
556#endif
557};
558
570
571#define NET_MAX_PRIORITIES 8
572
581
589
603
605
606struct net_ipv6_hdr {
607 uint8_t vtc;
608 uint8_t tcflow;
609 uint16_t flow;
610 uint16_t len;
611 uint8_t nexthdr;
612 uint8_t hop_limit;
615} __packed;
616
617struct net_ipv6_frag_hdr {
618 uint8_t nexthdr;
619 uint8_t reserved;
620 uint16_t offset;
621 uint32_t id;
622} __packed;
623
624struct net_ipv4_hdr {
625 uint8_t vhl;
626 uint8_t tos;
627 uint16_t len;
628 uint8_t id[2];
629 uint8_t offset[2];
630 uint8_t ttl;
631 uint8_t proto;
632 uint16_t chksum;
635} __packed;
636
637struct net_icmp_hdr {
638 uint8_t type;
639 uint8_t code;
640 uint16_t chksum;
641} __packed;
642
643struct net_udp_hdr {
644 uint16_t src_port;
645 uint16_t dst_port;
646 uint16_t len;
647 uint16_t chksum;
648} __packed;
649
655struct net_udp_opt_mrds {
657 uint16_t size;
659 uint8_t segs;
660};
661
666struct net_udp_opt_time {
668 uint32_t tsval;
670 uint32_t tsecr;
671};
672
673struct net_tcp_hdr {
674 uint16_t src_port;
675 uint16_t dst_port;
676 uint8_t seq[4];
677 uint8_t ack[4];
678 uint8_t offset;
680 uint8_t wnd[2];
681 uint16_t chksum;
682 uint8_t urg[2];
683 uint8_t optdata[0];
684} __packed;
685
686static inline const char *net_addr_type2str(enum net_addr_type type)
687{
688 switch (type) {
690 return "AUTO";
691 case NET_ADDR_DHCP:
692 return "DHCP";
693 case NET_ADDR_MANUAL:
694 return "MANUAL";
696 return "OVERRIDE";
697 case NET_ADDR_ANY:
698 default:
699 break;
700 }
701
702 return "<unknown>";
703}
704
705/* IPv6 extension headers types */
706#define NET_IPV6_NEXTHDR_HBHO 0
707#define NET_IPV6_NEXTHDR_DESTO 60
708#define NET_IPV6_NEXTHDR_ROUTING 43
709#define NET_IPV6_NEXTHDR_FRAG 44
710#define NET_IPV6_NEXTHDR_NONE 59
711
716union net_ip_header {
717 struct net_ipv4_hdr *ipv4;
718 struct net_ipv6_hdr *ipv6;
719};
720
721union net_proto_header {
722 struct net_udp_hdr *udp;
723 struct net_tcp_hdr *tcp;
724};
725
726#define NET_UDPH_LEN 8 /* Size of UDP header */
727#define NET_TCPH_LEN 20 /* Size of TCP header */
728#define NET_ICMPH_LEN 4 /* Size of ICMP header */
729
730#define NET_IPV6H_LEN 40 /* Size of IPv6 header */
731#define NET_ICMPV6H_LEN NET_ICMPH_LEN /* Size of ICMPv6 header */
732#define NET_IPV6UDPH_LEN (NET_UDPH_LEN + NET_IPV6H_LEN) /* IPv6 + UDP */
733#define NET_IPV6TCPH_LEN (NET_TCPH_LEN + NET_IPV6H_LEN) /* IPv6 + TCP */
734#define NET_IPV6ICMPH_LEN (NET_IPV6H_LEN + NET_ICMPH_LEN) /* ICMPv6 + IPv6 */
735#define NET_IPV6_FRAGH_LEN 8
736
737#define NET_IPV4H_LEN 20 /* Size of IPv4 header */
738#define NET_ICMPV4H_LEN NET_ICMPH_LEN /* Size of ICMPv4 header */
739#define NET_IPV4UDPH_LEN (NET_UDPH_LEN + NET_IPV4H_LEN) /* IPv4 + UDP */
740#define NET_IPV4TCPH_LEN (NET_TCPH_LEN + NET_IPV4H_LEN) /* IPv4 + TCP */
741#define NET_IPV4ICMPH_LEN (NET_IPV4H_LEN + NET_ICMPH_LEN) /* ICMPv4 + IPv4 */
742
743#define NET_IPV6H_LENGTH_OFFSET 0x04 /* Offset of the Length field in the IPv6 header */
744
745#define NET_IPV6_FRAGH_OFFSET_MASK 0xfff8 /* Mask for the 13-bit Fragment Offset field */
746#define NET_IPV4_FRAGH_OFFSET_MASK 0x1fff /* Mask for the 13-bit Fragment Offset field */
747#define NET_IPV4_MORE_FRAG_MASK 0x2000 /* Mask for the 1-bit More Fragments field */
748#define NET_IPV4_DO_NOT_FRAG_MASK 0x4000 /* Mask for the 1-bit Do Not Fragment field */
749
751#if defined(CONFIG_NET_INTERFACE_NAME)
752#define NET_IFNAMSIZ CONFIG_NET_INTERFACE_NAME_LEN
753#else
754#if defined(Z_DEVICE_MAX_NAME_LEN)
755#define NET_IFNAMSIZ Z_DEVICE_MAX_NAME_LEN
756#else
757#define NET_IFNAMSIZ 1
758#endif /* Z_DEVICE_MAX_NAME_LEN */
759#endif /* CONFIG_NET_INTERFACE_NAME */
760
762
767
769struct net_ifreq {
770 char ifr_name[NET_IFNAMSIZ];
771};
772
773
785
794
802
813
822 unsigned int ipi6_ifindex;
823};
824
826static inline bool net_ipv6_is_addr_loopback_raw(const uint8_t *addr)
827{
828 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
829 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
830 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
831 net_ntohl(UNALIGNED_GET((uint32_t *)addr + 3)) == 1;
832}
834
842static inline bool net_ipv6_is_addr_loopback(const struct net_in6_addr *addr)
843{
844 return net_ipv6_is_addr_loopback_raw(addr->s6_addr);
845}
846
848static inline bool net_ipv6_is_addr_mcast_raw(const uint8_t *addr)
849{
850 return addr[0] == 0xff;
851}
853
861static inline bool net_ipv6_is_addr_mcast(const struct net_in6_addr *addr)
862{
863 return net_ipv6_is_addr_mcast_raw(addr->s6_addr);
864}
865
866struct net_if;
867struct net_if_config;
868
870extern struct net_if_addr *net_if_ipv6_addr_lookup_raw(const uint8_t *addr,
871 struct net_if **ret);
872
873static inline bool net_ipv6_is_my_addr_raw(const uint8_t *addr)
874{
875 return net_if_ipv6_addr_lookup_raw(addr, NULL) != NULL;
876}
878
879extern struct net_if_addr *net_if_ipv6_addr_lookup(const struct net_in6_addr *addr,
880 struct net_if **iface);
881
889static inline bool net_ipv6_is_my_addr(struct net_in6_addr *addr)
890{
891 return net_if_ipv6_addr_lookup(addr, NULL) != NULL;
892}
893
895 const struct net_in6_addr *addr, struct net_if **iface);
896
905static inline bool net_ipv6_is_my_maddr(struct net_in6_addr *maddr)
906{
907 return net_if_ipv6_maddr_lookup(maddr, NULL) != NULL;
908}
909
919static inline bool net_ipv6_is_prefix(const uint8_t *addr1,
920 const uint8_t *addr2,
921 uint8_t length)
922{
923 uint8_t bits = 128 - length;
924 uint8_t bytes = length / 8U;
925 uint8_t remain = bits % 8;
926 uint8_t mask;
927
928 if (length > 128) {
929 return false;
930 }
931
932 if (memcmp(addr1, addr2, bytes)) {
933 return false;
934 }
935
936 if (!remain) {
937 /* No remaining bits, the prefixes are the same as first
938 * bytes are the same.
939 */
940 return true;
941 }
942
943 /* Create a mask that has remaining most significant bits set */
944 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
945
946 return (addr1[bytes] & mask) == (addr2[bytes] & mask);
947}
948
949
957static inline void net_ipv6_addr_prefix_mask(const uint8_t *inaddr,
958 uint8_t *outaddr,
959 uint8_t prefix_len)
960{
961 uint8_t bits = 128 - prefix_len;
962 uint8_t bytes = prefix_len / 8U;
963 uint8_t remain = bits % 8;
964 uint8_t mask;
965
966 memset(outaddr, 0, 16U);
967 memcpy(outaddr, inaddr, bytes);
968
969 if (!remain) {
970 /* No remaining bits, the prefixes are the same as first
971 * bytes are the same.
972 */
973 return;
974 }
975
976 /* Create a mask that has remaining most significant bits set */
977 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
978 outaddr[bytes] = inaddr[bytes] & mask;
979}
980
982static inline bool net_ipv4_is_addr_loopback_raw(const uint8_t *addr)
983{
984 return addr[0] == 127U;
985}
987
995static inline bool net_ipv4_is_addr_loopback(const struct net_in_addr *addr)
996{
997 return net_ipv4_is_addr_loopback_raw(addr->s4_addr);
998}
999
1001static inline bool net_ipv4_is_addr_unspecified_raw(const uint8_t *addr)
1002{
1003 return UNALIGNED_GET((uint32_t *)addr) == 0;
1004}
1006
1014static inline bool net_ipv4_is_addr_unspecified(const struct net_in_addr *addr)
1015{
1016 return net_ipv4_is_addr_unspecified_raw(addr->s4_addr);
1017}
1018
1020static inline bool net_ipv4_is_addr_mcast_raw(const uint8_t *addr)
1021{
1022 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xF0000000) == 0xE0000000;
1023}
1025
1033static inline bool net_ipv4_is_addr_mcast(const struct net_in_addr *addr)
1034{
1035 return net_ipv4_is_addr_mcast_raw(addr->s4_addr);
1036}
1037
1039static inline bool net_ipv4_is_ll_addr_raw(const uint8_t *addr)
1040{
1041 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xFFFF0000) == 0xA9FE0000;
1042}
1044
1052static inline bool net_ipv4_is_ll_addr(const struct net_in_addr *addr)
1053{
1054 return net_ipv4_is_ll_addr_raw(addr->s4_addr);
1055}
1056
1066static inline bool net_ipv4_is_private_addr(const struct net_in_addr *addr)
1067{
1068 uint32_t masked_24, masked_16, masked_12, masked_10, masked_8;
1069
1070 masked_24 = net_ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xFFFFFF00;
1071 masked_16 = masked_24 & 0xFFFF0000;
1072 masked_12 = masked_24 & 0xFFF00000;
1073 masked_10 = masked_24 & 0xFFC00000;
1074 masked_8 = masked_24 & 0xFF000000;
1075
1076 return masked_8 == 0x0A000000 || /* 10.0.0.0/8 */
1077 masked_10 == 0x64400000 || /* 100.64.0.0/10 */
1078 masked_12 == 0xAC100000 || /* 172.16.0.0/12 */
1079 masked_16 == 0xC0A80000 || /* 192.168.0.0/16 */
1080 masked_24 == 0xC0000200 || /* 192.0.2.0/24 */
1081 masked_24 == 0xC0336400 || /* 192.51.100.0/24 */
1082 masked_24 == 0xCB007100; /* 203.0.113.0/24 */
1083}
1084
1093#define net_ipaddr_copy(dest, src) \
1094 UNALIGNED_PUT(UNALIGNED_GET(src), dest)
1095
1102static inline void net_ipv4_addr_copy_raw(uint8_t *dest,
1103 const uint8_t *src)
1104{
1105 net_ipaddr_copy((struct net_in_addr *)dest, (const struct net_in_addr *)src);
1106}
1107
1114static inline void net_ipv6_addr_copy_raw(uint8_t *dest,
1115 const uint8_t *src)
1116{
1117 memcpy(dest, src, sizeof(struct net_in6_addr));
1118}
1119
1128static inline bool net_ipv4_addr_cmp_raw(const uint8_t *addr1,
1129 const uint8_t *addr2)
1130{
1131 return UNALIGNED_GET((uint32_t *)addr1) == UNALIGNED_GET((uint32_t *)addr2);
1132}
1133
1142static inline bool net_ipv4_addr_cmp(const struct net_in_addr *addr1,
1143 const struct net_in_addr *addr2)
1144{
1145 return net_ipv4_addr_cmp_raw(addr1->s4_addr, addr2->s4_addr);
1146}
1147
1156static inline bool net_ipv6_addr_cmp(const struct net_in6_addr *addr1,
1157 const struct net_in6_addr *addr2)
1158{
1159 return !memcmp(addr1, addr2, sizeof(struct net_in6_addr));
1160}
1161
1170static inline bool net_ipv6_addr_cmp_raw(const uint8_t *addr1,
1171 const uint8_t *addr2)
1172{
1173 return net_ipv6_addr_cmp((const struct net_in6_addr *)addr1,
1174 (const struct net_in6_addr *)addr2);
1175}
1176
1178static inline bool net_ipv6_is_ll_addr_raw(const uint8_t *addr)
1179{
1180 return UNALIGNED_GET((uint16_t *)addr) == net_htons(0xFE80);
1181}
1183
1191static inline bool net_ipv6_is_ll_addr(const struct net_in6_addr *addr)
1192{
1193 return net_ipv6_is_ll_addr_raw(addr->s6_addr);
1194}
1195
1203static inline bool net_ipv6_is_sl_addr(const struct net_in6_addr *addr)
1204{
1205 return UNALIGNED_GET(&addr->s6_addr16[0]) == net_htons(0xFEC0);
1206}
1207
1208
1216static inline bool net_ipv6_is_ula_addr(const struct net_in6_addr *addr)
1217{
1218 return addr->s6_addr[0] == 0xFD;
1219}
1220
1228static inline bool net_ipv6_is_global_addr(const struct net_in6_addr *addr)
1229{
1230 return (addr->s6_addr[0] & 0xE0) == 0x20;
1231}
1232
1242static inline bool net_ipv6_is_private_addr(const struct net_in6_addr *addr)
1243{
1244 uint32_t masked_32, masked_7;
1245
1246 masked_32 = net_ntohl(UNALIGNED_GET(&addr->s6_addr32[0]));
1247 masked_7 = masked_32 & 0xfc000000;
1248
1249 return masked_32 == 0x20010db8 || /* 2001:db8::/32 */
1250 masked_7 == 0xfc000000; /* fc00::/7 */
1251}
1252
1259
1266
1273
1274struct net_if;
1275extern bool net_if_ipv4_addr_mask_cmp(struct net_if *iface,
1276 const struct net_in_addr *addr);
1277
1287static inline bool net_ipv4_addr_mask_cmp(struct net_if *iface,
1288 const struct net_in_addr *addr)
1289{
1290 return net_if_ipv4_addr_mask_cmp(iface, addr);
1291}
1292
1294extern bool net_if_ipv4_is_addr_bcast_raw(struct net_if *iface,
1295 const uint8_t *addr);
1296
1297#if defined(CONFIG_NET_NATIVE_IPV4)
1298static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1299 const uint8_t *addr)
1300{
1301 if (net_ipv4_addr_cmp_raw(addr, net_ipv4_broadcast_address()->s4_addr)) {
1302 return true;
1303 }
1304
1305 return net_if_ipv4_is_addr_bcast_raw(iface, addr);
1306}
1307#else
1308static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1309 const uint8_t *addr)
1310{
1311 ARG_UNUSED(iface);
1312 ARG_UNUSED(addr);
1313
1314 return false;
1315}
1316#endif
1318
1319extern bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
1320 const struct net_in_addr *addr);
1321
1330#if defined(CONFIG_NET_NATIVE_IPV4)
1331static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1332 const struct net_in_addr *addr)
1333{
1335 return true;
1336 }
1337
1338 return net_if_ipv4_is_addr_bcast(iface, addr);
1339}
1340#else
1341static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1342 const struct net_in_addr *addr)
1343{
1344 ARG_UNUSED(iface);
1345 ARG_UNUSED(addr);
1346
1347 return false;
1348}
1349#endif
1350
1352extern struct net_if_addr *net_if_ipv4_addr_lookup_raw(const uint8_t *addr,
1353 struct net_if **ret);
1354
1355static inline bool net_ipv4_is_my_addr_raw(const uint8_t *addr)
1356{
1357 bool ret;
1358
1359 ret = net_if_ipv4_addr_lookup_raw(addr, NULL) != NULL;
1360 if (!ret) {
1361 ret = net_ipv4_is_addr_bcast_raw(NULL, addr);
1362 }
1363
1364 return ret;
1365}
1367
1368extern struct net_if_addr *net_if_ipv4_addr_lookup(const struct net_in_addr *addr,
1369 struct net_if **iface);
1370
1380static inline bool net_ipv4_is_my_addr(const struct net_in_addr *addr)
1381{
1382 bool ret;
1383
1384 ret = net_if_ipv4_addr_lookup(addr, NULL) != NULL;
1385 if (!ret) {
1386 ret = net_ipv4_is_addr_bcast(NULL, addr);
1387 }
1388
1389 return ret;
1390}
1391
1393static inline bool net_ipv6_is_addr_unspecified_raw(const uint8_t *addr)
1394{
1395 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
1396 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
1397 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
1398 UNALIGNED_GET((uint32_t *)addr + 3) == 0;
1399}
1401
1409static inline bool net_ipv6_is_addr_unspecified(const struct net_in6_addr *addr)
1410{
1411 return net_ipv6_is_addr_unspecified_raw(addr->s6_addr);
1412}
1413
1415static inline bool net_ipv6_is_addr_solicited_node_raw(const uint8_t *addr)
1416{
1417 return UNALIGNED_GET((uint32_t *)addr) == net_htonl(0xff020000) &&
1418 UNALIGNED_GET((uint32_t *)addr + 1) == 0x00000000 &&
1419 UNALIGNED_GET((uint32_t *)addr + 2) == net_htonl(0x00000001) &&
1420 ((UNALIGNED_GET((uint32_t *)addr + 3) & net_htonl(0xff000000)) ==
1421 net_htonl(0xff000000));
1422}
1424
1433static inline bool net_ipv6_is_addr_solicited_node(const struct net_in6_addr *addr)
1434{
1435 return net_ipv6_is_addr_solicited_node_raw(addr->s6_addr);
1436}
1437
1439static inline bool net_ipv6_is_addr_mcast_scope_raw(const uint8_t *addr,
1440 int scope)
1441{
1442 return (addr[0] == 0xff) && ((addr[1] & 0xF) == scope);
1443}
1445
1447static inline int net_ipv6_get_addr_mcast_scope_raw(const uint8_t *addr)
1448{
1449 if (addr[0] == 0xff) {
1450 return (addr[1] & 0xF);
1451 }
1452
1453 return -1;
1454}
1456
1467static inline bool net_ipv6_is_addr_mcast_scope(const struct net_in6_addr *addr,
1468 int scope)
1469{
1470 return net_ipv6_is_addr_mcast_scope_raw(addr->s6_addr, scope);
1471}
1472
1482static inline bool net_ipv6_is_same_mcast_scope(const struct net_in6_addr *addr_1,
1483 const struct net_in6_addr *addr_2)
1484{
1485 return (addr_1->s6_addr[0] == 0xff) && (addr_2->s6_addr[0] == 0xff) &&
1486 (addr_1->s6_addr[1] == addr_2->s6_addr[1]);
1487}
1488
1496static inline int net_ipv6_get_addr_mcast_scope(const struct net_in6_addr *addr)
1497{
1498 return net_ipv6_get_addr_mcast_scope_raw(addr->s6_addr);
1499}
1500
1502static inline bool net_ipv6_is_addr_mcast_iface_raw(const uint8_t *addr)
1503{
1504 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x01);
1505}
1506
1507static inline bool net_ipv6_is_addr_mcast_link_raw(const uint8_t *addr)
1508{
1509 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x02);
1510}
1511
1512static inline bool net_ipv6_is_addr_mcast_mesh_raw(const uint8_t *addr)
1513{
1514 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x03);
1515}
1516
1517static inline bool net_ipv6_is_addr_mcast_site_raw(const uint8_t *addr)
1518{
1519 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x05);
1520}
1521
1522static inline bool net_ipv6_is_addr_mcast_org_raw(const uint8_t *addr)
1523{
1524 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x08);
1525}
1527
1535static inline bool net_ipv6_is_addr_mcast_global(const struct net_in6_addr *addr)
1536{
1537 return net_ipv6_is_addr_mcast_scope(addr, 0x0e);
1538}
1539
1549static inline bool net_ipv6_is_addr_mcast_iface(const struct net_in6_addr *addr)
1550{
1551 return net_ipv6_is_addr_mcast_scope(addr, 0x01);
1552}
1553
1563static inline bool net_ipv6_is_addr_mcast_link(const struct net_in6_addr *addr)
1564{
1565 return net_ipv6_is_addr_mcast_scope(addr, 0x02);
1566}
1567
1577static inline bool net_ipv6_is_addr_mcast_mesh(const struct net_in6_addr *addr)
1578{
1579 return net_ipv6_is_addr_mcast_scope(addr, 0x03);
1580}
1581
1591static inline bool net_ipv6_is_addr_mcast_site(const struct net_in6_addr *addr)
1592{
1593 return net_ipv6_is_addr_mcast_scope(addr, 0x05);
1594}
1595
1605static inline bool net_ipv6_is_addr_mcast_org(const struct net_in6_addr *addr)
1606{
1607 return net_ipv6_is_addr_mcast_scope(addr, 0x08);
1608}
1609
1611static inline bool net_ipv6_is_addr_mcast_group_raw(const uint8_t *addr,
1612 const uint8_t *group)
1613{
1614 return UNALIGNED_GET((uint16_t *)addr + 1) == UNALIGNED_GET((uint16_t *)group + 1) &&
1615 UNALIGNED_GET((uint32_t *)addr + 1) == UNALIGNED_GET((uint32_t *)group + 1) &&
1616 UNALIGNED_GET((uint32_t *)addr + 2) == UNALIGNED_GET((uint32_t *)group + 2) &&
1617 UNALIGNED_GET((uint32_t *)addr + 3) == UNALIGNED_GET((uint32_t *)group + 3);
1618}
1620
1631static inline bool net_ipv6_is_addr_mcast_group(const struct net_in6_addr *addr,
1632 const struct net_in6_addr *group)
1633{
1634 return net_ipv6_is_addr_mcast_group_raw(addr->s6_addr, group->s6_addr);
1635}
1636
1638static inline bool net_ipv6_is_addr_mcast_all_nodes_group_raw(const uint8_t *addr)
1639{
1640 static const uint8_t all_nodes_mcast_group[NET_IPV6_ADDR_SIZE] = {
1641 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1642 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1643 };
1644
1645 return net_ipv6_is_addr_mcast_group_raw(addr, all_nodes_mcast_group);
1646}
1648
1657static inline bool
1659{
1660 return net_ipv6_is_addr_mcast_all_nodes_group_raw(addr->s6_addr);
1661}
1662
1672static inline bool
1678
1680static inline bool net_ipv6_is_addr_mcast_link_all_nodes_raw(const uint8_t *addr)
1681{
1682 return net_ipv6_is_addr_mcast_link_raw(addr) &&
1683 net_ipv6_is_addr_mcast_all_nodes_group_raw(addr);
1684}
1686
1696static inline bool
1702
1710static inline
1712 struct net_in6_addr *dst)
1713{
1714 dst->s6_addr[0] = 0xFF;
1715 dst->s6_addr[1] = 0x02;
1716 UNALIGNED_PUT(0, &dst->s6_addr16[1]);
1717 UNALIGNED_PUT(0, &dst->s6_addr16[2]);
1718 UNALIGNED_PUT(0, &dst->s6_addr16[3]);
1719 UNALIGNED_PUT(0, &dst->s6_addr16[4]);
1720 dst->s6_addr[10] = 0U;
1721 dst->s6_addr[11] = 0x01;
1722 dst->s6_addr[12] = 0xFF;
1723 dst->s6_addr[13] = src->s6_addr[13];
1724 UNALIGNED_PUT(UNALIGNED_GET(&src->s6_addr16[7]), &dst->s6_addr16[7]);
1725}
1726
1739static inline void net_ipv6_addr_create(struct net_in6_addr *addr,
1740 uint16_t addr0, uint16_t addr1,
1741 uint16_t addr2, uint16_t addr3,
1742 uint16_t addr4, uint16_t addr5,
1743 uint16_t addr6, uint16_t addr7)
1744{
1745 UNALIGNED_PUT(net_htons(addr0), &addr->s6_addr16[0]);
1746 UNALIGNED_PUT(net_htons(addr1), &addr->s6_addr16[1]);
1747 UNALIGNED_PUT(net_htons(addr2), &addr->s6_addr16[2]);
1748 UNALIGNED_PUT(net_htons(addr3), &addr->s6_addr16[3]);
1749 UNALIGNED_PUT(net_htons(addr4), &addr->s6_addr16[4]);
1750 UNALIGNED_PUT(net_htons(addr5), &addr->s6_addr16[5]);
1751 UNALIGNED_PUT(net_htons(addr6), &addr->s6_addr16[6]);
1752 UNALIGNED_PUT(net_htons(addr7), &addr->s6_addr16[7]);
1753}
1754
1761{
1762 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001);
1763}
1764
1771{
1772 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002);
1773}
1774
1781static inline void net_ipv6_addr_create_v4_mapped(const struct net_in_addr *addr4,
1782 struct net_in6_addr *addr6)
1783{
1784 net_ipv6_addr_create(addr6, 0, 0, 0, 0, 0, 0xffff,
1785 net_ntohs(addr4->s4_addr16[0]),
1786 net_ntohs(addr4->s4_addr16[1]));
1787}
1788
1797static inline bool net_ipv6_addr_is_v4_mapped(const struct net_in6_addr *addr)
1798{
1799 if (UNALIGNED_GET(&addr->s6_addr32[0]) == 0 &&
1800 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 &&
1801 UNALIGNED_GET(&addr->s6_addr16[5]) == 0xffff) {
1802 return true;
1803 }
1804
1805 return false;
1806}
1807
1816static inline void net_ipv6_addr_get_v4_mapped(const struct net_in6_addr *addr6,
1817 struct net_in_addr *addr4)
1818{
1819 addr4->s_addr = UNALIGNED_GET(&addr6->s6_addr32[3]);
1820}
1821
1841 const struct net_in6_addr *prefix,
1842 uint8_t *network_id, size_t network_id_len,
1843 uint8_t dad_counter,
1844 struct net_in6_addr *addr,
1845 struct net_linkaddr *lladdr);
1846
1853static inline void net_ipv6_addr_create_iid(struct net_in6_addr *addr,
1854 struct net_linkaddr *lladdr)
1855{
1856 (void)net_ipv6_addr_generate_iid(NULL, NULL, NULL, 0, 0, addr, lladdr);
1857}
1858
1860static inline bool net_ipv6_addr_based_on_ll_raw(const uint8_t *addr,
1861 const struct net_linkaddr *lladdr)
1862{
1863 if (addr == NULL || lladdr == NULL) {
1864 return false;
1865 }
1866
1867 switch (lladdr->len) {
1868 case 2:
1869 if (!memcmp(&addr[14], lladdr->addr, lladdr->len) &&
1870 addr[8] == 0U &&
1871 addr[9] == 0U &&
1872 addr[10] == 0U &&
1873 addr[11] == 0xff &&
1874 addr[12] == 0xfe) {
1875 return true;
1876 }
1877
1878 break;
1879 case 6:
1880 if (lladdr->type == NET_LINK_ETHERNET) {
1881 if (!memcmp(&addr[9], &lladdr->addr[1], 2) &&
1882 !memcmp(&addr[13], &lladdr->addr[3], 3) &&
1883 addr[11] == 0xff &&
1884 addr[12] == 0xfe &&
1885 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1886 return true;
1887 }
1888 }
1889
1890 break;
1891 case 8:
1892 if (sizeof(lladdr->addr) < 8) {
1893 return false;
1894 }
1895
1896 if (!memcmp(&addr[9], &lladdr->addr[1],
1897 lladdr->len - 1) &&
1898 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1899 return true;
1900 }
1901
1902 break;
1903 default:
1904 return false;
1905 }
1906
1907 return false;
1908}
1910
1916static inline bool net_ipv6_addr_based_on_ll(const struct net_in6_addr *addr,
1917 const struct net_linkaddr *lladdr)
1918{
1919 if (addr == NULL || lladdr == NULL) {
1920 return false;
1921 }
1922
1923 return net_ipv6_addr_based_on_ll_raw(addr->s6_addr, lladdr);
1924}
1925
1934static ALWAYS_INLINE struct net_sockaddr *net_sad(const struct net_sockaddr_storage *addr)
1935{
1936 return (struct net_sockaddr *)addr;
1937}
1938
1947static ALWAYS_INLINE struct net_sockaddr_storage *net_sas(const struct net_sockaddr *addr)
1948{
1949 return (struct net_sockaddr_storage *)addr;
1950}
1951
1960static ALWAYS_INLINE struct net_sockaddr_in6 *net_sin6(const struct net_sockaddr *addr)
1961{
1962 return (struct net_sockaddr_in6 *)addr;
1963}
1964
1973static ALWAYS_INLINE struct net_sockaddr_in *net_sin(const struct net_sockaddr *addr)
1974{
1975 return (struct net_sockaddr_in *)addr;
1976}
1977
1986static ALWAYS_INLINE
1987struct net_sockaddr_in6_ptr *net_sin6_ptr(const struct net_sockaddr_ptr *addr)
1988{
1989 return (struct net_sockaddr_in6_ptr *)addr;
1990}
1991
2000static ALWAYS_INLINE
2001struct net_sockaddr_in_ptr *net_sin_ptr(const struct net_sockaddr_ptr *addr)
2002{
2003 return (struct net_sockaddr_in_ptr *)addr;
2004}
2005
2014static ALWAYS_INLINE
2015struct net_sockaddr_ll_ptr *net_sll_ptr(const struct net_sockaddr_ptr *addr)
2016{
2017 return (struct net_sockaddr_ll_ptr *)addr;
2018}
2019
2028static ALWAYS_INLINE
2029struct net_sockaddr_can_ptr *net_can_ptr(const struct net_sockaddr_ptr *addr)
2030{
2031 return (struct net_sockaddr_can_ptr *)addr;
2032}
2033
2047__syscall int net_addr_pton(net_sa_family_t family, const char *src, void *dst);
2048
2060__syscall char *net_addr_ntop(net_sa_family_t family, const void *src,
2061 char *dst, size_t size);
2062
2074 struct net_sockaddr *mask);
2075
2087 uint8_t *mask_len);
2088
2110bool net_ipaddr_parse(const char *str, size_t str_len,
2111 struct net_sockaddr *addr);
2112
2140const char *net_ipaddr_parse_mask(const char *str, size_t str_len,
2141 struct net_sockaddr *addr, uint8_t *mask_len);
2142
2152int net_port_set_default(struct net_sockaddr *addr, uint16_t default_port);
2153
2162int net_port_set(struct net_sockaddr *addr, uint16_t port);
2163
2172int net_port_get(struct net_sockaddr *addr, uint16_t *port);
2173
2185static inline int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
2186{
2187 return (int32_t)(seq1 - seq2);
2188}
2189
2200static inline bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
2201{
2202 return net_tcp_seq_cmp(seq1, seq2) > 0;
2203}
2204
2216int net_bytes_from_str(uint8_t *buf, int buf_len, const char *src);
2217
2227
2237
2246static inline enum net_priority net_vlan2priority(uint8_t priority)
2247{
2248 /* Map according to IEEE 802.1Q */
2249 static const uint8_t vlan2priority[] = {
2258 };
2259
2260 if (priority >= ARRAY_SIZE(vlan2priority)) {
2261 /* Use Best Effort as the default priority */
2262 return NET_PRIORITY_BE;
2263 }
2264
2265 return (enum net_priority)vlan2priority[priority];
2266}
2267
2275static inline uint8_t net_priority2vlan(enum net_priority priority)
2276{
2277 /* The conversion works both ways */
2278 return (uint8_t)net_vlan2priority(priority);
2279}
2280
2290
2298static inline size_t net_family2size(net_sa_family_t family)
2299{
2300 switch (family) {
2301 case NET_AF_INET:
2302 return sizeof(struct net_sockaddr_in);
2303 case NET_AF_INET6:
2304 return sizeof(struct net_sockaddr_in6);
2305 case NET_AF_PACKET:
2306 return sizeof(struct net_sockaddr_ll);
2307 case NET_AF_UNIX:
2308 return sizeof(struct net_sockaddr_un);
2309 case NET_AF_CAN:
2310 return sizeof(struct net_sockaddr_can);
2311 case NET_AF_NET_MGMT:
2312 return sizeof(struct net_sockaddr_nm);
2313 default:
2314 return 0;
2315 }
2316}
2317
2328#if defined(CONFIG_NET_IPV6_PE)
2329int net_ipv6_pe_add_filter(struct net_in6_addr *addr, bool is_denylist);
2330#else
2331static inline int net_ipv6_pe_add_filter(struct net_in6_addr *addr,
2332 bool is_denylist)
2333{
2334 ARG_UNUSED(addr);
2335 ARG_UNUSED(is_denylist);
2336
2337 return -ENOTSUP;
2338}
2339#endif /* CONFIG_NET_IPV6_PE */
2340
2348#if defined(CONFIG_NET_IPV6_PE)
2349int net_ipv6_pe_del_filter(struct net_in6_addr *addr);
2350#else
2351static inline int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
2352{
2353 ARG_UNUSED(addr);
2354
2355 return -ENOTSUP;
2356}
2357#endif /* CONFIG_NET_IPV6_PE */
2358
2359#ifdef __cplusplus
2360}
2361#endif
2362
2363#include <zephyr/syscalls/net_ip.h>
2364
2365#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
2366#define ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2367#include <zephyr/net/net_compat.h>
2368#undef ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2369#endif /* CONFIG_NET_NAMESPACE_COMPAT_MODE */
2370
2374
2375#endif /* ZEPHYR_INCLUDE_NET_NET_IP_H_ */
#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:1216
int net_port_get(struct net_sockaddr *addr, uint16_t *port)
Get the port in the sockaddr structure.
static size_t net_family2size(net_sa_family_t family)
Return network address size for a given family.
Definition net_ip.h:2298
#define NET_IPV4_ADDR_SIZE
Binary size of the IPv4 address.
Definition net_ip.h:166
static ALWAYS_INLINE struct net_sockaddr * net_sad(const struct net_sockaddr_storage *addr)
Get net_sockaddr from net_sockaddr_storage.
Definition net_ip.h:1934
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:2246
static int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
Compare TCP sequence numbers.
Definition net_ip.h:2185
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:905
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:1142
#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:1797
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:1409
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:1577
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:1781
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:1033
net_addr_state
What is the current state of the network address.
Definition net_ip.h:583
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:1128
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:1242
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:1014
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:861
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:1549
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:1114
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:1287
const char * net_family2str(net_sa_family_t family)
Return network address family value as a string.
static ALWAYS_INLINE struct net_sockaddr_in6 * net_sin6(const struct net_sockaddr *addr)
Get net_sockaddr_in6 from net_sockaddr.
Definition net_ip.h:1960
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:957
#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.
#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 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:1380
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:995
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:1052
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:1156
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:1760
static ALWAYS_INLINE 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:2001
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:1816
#define net_ipaddr_copy(dest, src)
Copy an IPv4 or IPv6 address.
Definition net_ip.h:1093
int net_port_set(struct net_sockaddr *addr, uint16_t port)
Set the port in the sockaddr structure.
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:1916
net_ip_mtu
IP Maximum Transfer Unit.
Definition net_ip.h:539
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:1496
static ALWAYS_INLINE struct net_sockaddr_storage * net_sas(const struct net_sockaddr *addr)
Get net_sockaddr_storage from net_sockaddr.
Definition net_ip.h:1947
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:1853
static ALWAYS_INLINE 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:2015
#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:2275
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:1591
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:1467
#define SOCKADDR_ALIGN
Definition net_ip.h:452
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:889
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:919
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:842
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:1605
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:2331
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:1631
static bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
Check that one TCP sequence number is greater.
Definition net_ip.h:2200
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:1433
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:1739
static ALWAYS_INLINE 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:2029
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:1228
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:1697
const struct net_in_addr * net_ipv4_unspecified_address(void)
Return pointer to any (all bits zeros) IPv4 address.
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:1658
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:1482
static int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
Delete IPv6 prefix from privacy extension filter list.
Definition net_ip.h:2351
#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:1191
static ALWAYS_INLINE 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:1987
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:1066
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:1711
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:1563
#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:1770
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:560
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:1673
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:1203
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:1102
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:1535
static ALWAYS_INLINE struct net_sockaddr_in * net_sin(const struct net_sockaddr *addr)
Get net_sockaddr_in from net_sockaddr.
Definition net_ip.h:1973
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:1170
net_addr_type
How the network address is assigned to network interface.
Definition net_ip.h:591
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:1341
@ NET_ADDR_ANY_STATE
Default (invalid) address type.
Definition net_ip.h:584
@ NET_ADDR_TENTATIVE
Tentative address.
Definition net_ip.h:585
@ NET_ADDR_DEPRECATED
Deprecated address.
Definition net_ip.h:587
@ NET_ADDR_PREFERRED
Preferred address.
Definition net_ip.h:586
@ 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:555
@ NET_IPV6_MTU
IPv6 MTU length.
Definition net_ip.h:546
@ 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:568
@ NET_PRIORITY_IC
Internetwork control.
Definition net_ip.h:567
@ NET_PRIORITY_CA
Critical applications.
Definition net_ip.h:564
@ NET_PRIORITY_VO
Voice, < 10 ms latency and jitter.
Definition net_ip.h:566
@ NET_PRIORITY_VI
Video, < 100 ms latency and jitter.
Definition net_ip.h:565
@ NET_PRIORITY_BE
Best effort (default).
Definition net_ip.h:562
@ NET_PRIORITY_EE
Excellent effort.
Definition net_ip.h:563
@ NET_PRIORITY_BK
Background (lowest).
Definition net_ip.h:561
@ 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:593
@ NET_ADDR_OVERRIDABLE
Manually set address which is overridable by DHCP.
Definition net_ip.h:601
@ NET_ADDR_DHCP
Address is from DHCP.
Definition net_ip.h:597
@ NET_ADDR_MANUAL
Manually set address.
Definition net_ip.h:599
@ NET_ADDR_AUTOCONF
Auto configured address.
Definition net_ip.h:595
@ 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:115
#define NULL
Definition iar_missing_defs.h:20
#define in_addr
Definition in.h:20
#define in6_addr
Definition in.h:21
#define ALWAYS_INLINE
Definition common.h:161
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:595
Network Interface multicast IP addresses.
Definition net_if.h:161
Network Interface structure.
Definition net_if.h:744
Interface description structure.
Definition net_ip.h:769
char ifr_name[NET_IFNAMSIZ]
Network interface name.
Definition net_ip.h:770
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:820
unsigned int ipi6_ifindex
Receive interface index.
Definition net_ip.h:822
struct net_in6_addr ipi6_addr
Destination IPv6 address.
Definition net_ip.h:821
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:780
unsigned int ipi_ifindex
Network interface index.
Definition net_ip.h:781
struct net_in_addr ipi_addr
Header Destination address.
Definition net_ip.h:783
struct net_in_addr ipi_spec_dst
Local address.
Definition net_ip.h:782
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:798
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:799
struct net_in_addr imr_interface
IP address of local interface.
Definition net_ip.h:800
Struct used when joining or leaving a IPv4 multicast group.
Definition net_ip.h:789
int imr_ifindex
Network interface index.
Definition net_ip.h:792
struct net_in_addr imr_address
IP address of local interface.
Definition net_ip.h:791
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:790
Struct used when joining or leaving a IPv6 multicast group.
Definition net_ip.h:806
struct net_in6_addr ipv6mr_multiaddr
IPv6 multicast address of group.
Definition net_ip.h:808
int ipv6mr_ifindex
Network interface index of the local IPv6 address.
Definition net_ip.h:811
Linger option struct for the SO_LINGER socket option.
Definition net_ip.h:314
int l_onoff
Whether the linger behaviour is enabled.
Definition net_ip.h:315
int l_linger
Linger time in seconds.
Definition net_ip.h:316
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:455
net_sa_family_t sa_family
Address family.
Definition net_ip.h:456
IPv6/IPv4 network connection tuple.
Definition net_ip.h:574
struct net_addr * remote_addr
IPv6/IPv4 remote address.
Definition net_ip.h:575
uint16_t local_port
UDP/TCP local port.
Definition net_ip.h:578
enum net_ip_protocol ip_proto
IP protocol.
Definition net_ip.h:579
uint16_t remote_port
UDP/TCP remote port.
Definition net_ip.h:577
struct net_addr * local_addr
IPv6/IPv4 local address.
Definition net_ip.h:576
Byte order helpers.
Misc utilities.
Macros to abstract toolchain specific capabilities.