Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
net_ip.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2016 Intel Corporation
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12
13#ifndef ZEPHYR_INCLUDE_NET_NET_IP_H_
14#define ZEPHYR_INCLUDE_NET_NET_IP_H_
15
24
25#include <string.h>
26#include <zephyr/types.h>
27#include <stdbool.h>
28#include <zephyr/sys/util.h>
30#include <zephyr/toolchain.h>
31
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
39/* Specifying VLAN tag here in order to avoid circular dependencies */
40#define NET_VLAN_TAG_UNSPEC 0x0fff
42
43/* Protocol families. */
44#define NET_PF_UNSPEC 0
45#define NET_PF_INET 1
46#define NET_PF_INET6 2
47#define NET_PF_PACKET 3
48#define NET_PF_CAN 4
49#define NET_PF_NET_MGMT 5
50#define NET_PF_LOCAL 6
51#define NET_PF_UNIX NET_PF_LOCAL
52
53/* Address families. */
54#define NET_AF_UNSPEC NET_PF_UNSPEC
55#define NET_AF_INET NET_PF_INET
56#define NET_AF_INET6 NET_PF_INET6
57#define NET_AF_PACKET NET_PF_PACKET
58#define NET_AF_CAN NET_PF_CAN
59#define NET_AF_NET_MGMT NET_PF_NET_MGMT
60#define NET_AF_LOCAL NET_PF_LOCAL
61#define NET_AF_UNIX NET_PF_UNIX
62
76
87
94
101#define net_ntohs(x) sys_be16_to_cpu(x)
102
109#define net_ntohl(x) sys_be32_to_cpu(x)
110
117#define net_ntohll(x) sys_be64_to_cpu(x)
118
125#define net_htons(x) sys_cpu_to_be16(x)
126
133#define net_htonl(x) sys_cpu_to_be32(x)
134
141#define net_htonll(x) sys_cpu_to_be64(x)
142
145 union {
149 };
150};
151
153#define NET_IPV6_ADDR_SIZE 16
154
164
166#define NET_IPV4_ADDR_SIZE 4
167
169typedef unsigned short int net_sa_family_t;
170
173
174/*
175 * Note that the sin_port and sin6_port are in network byte order
176 * in various net_sockaddr* structs.
177 */
178
186
193
204
210
244
246
248struct net_sockaddr_in6_ptr {
249 net_sa_family_t sin6_family;
250 uint16_t sin6_port;
251 struct net_in6_addr *sin6_addr;
252 uint8_t sin6_scope_id;
253};
254
256struct net_sockaddr_in_ptr {
257 net_sa_family_t sin_family;
258 uint16_t sin_port;
259 struct net_in_addr *sin_addr;
260};
261
263struct net_sockaddr_ll_ptr {
264 net_sa_family_t sll_family;
265 uint16_t sll_protocol;
266 int sll_ifindex;
267 uint16_t sll_hatype;
268 uint8_t sll_pkttype;
269 uint8_t sll_halen;
270 uint8_t *sll_addr;
271};
272
274struct net_sockaddr_un_ptr {
275 net_sa_family_t sun_family;
276 char *sun_path;
277};
278
279struct net_sockaddr_can_ptr {
280 net_sa_family_t can_family;
281 int can_ifindex;
282};
283
285
286#if !defined(HAVE_IOVEC)
288struct net_iovec {
289 void *iov_base;
290 size_t iov_len;
291};
292#endif
293
304
312
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
650struct net_tcp_hdr {
651 uint16_t src_port;
652 uint16_t dst_port;
653 uint8_t seq[4];
654 uint8_t ack[4];
655 uint8_t offset;
657 uint8_t wnd[2];
658 uint16_t chksum;
659 uint8_t urg[2];
660 uint8_t optdata[0];
661} __packed;
662
663static inline const char *net_addr_type2str(enum net_addr_type type)
664{
665 switch (type) {
667 return "AUTO";
668 case NET_ADDR_DHCP:
669 return "DHCP";
670 case NET_ADDR_MANUAL:
671 return "MANUAL";
673 return "OVERRIDE";
674 case NET_ADDR_ANY:
675 default:
676 break;
677 }
678
679 return "<unknown>";
680}
681
682/* IPv6 extension headers types */
683#define NET_IPV6_NEXTHDR_HBHO 0
684#define NET_IPV6_NEXTHDR_DESTO 60
685#define NET_IPV6_NEXTHDR_ROUTING 43
686#define NET_IPV6_NEXTHDR_FRAG 44
687#define NET_IPV6_NEXTHDR_NONE 59
688
693union net_ip_header {
694 struct net_ipv4_hdr *ipv4;
695 struct net_ipv6_hdr *ipv6;
696};
697
698union net_proto_header {
699 struct net_udp_hdr *udp;
700 struct net_tcp_hdr *tcp;
701};
702
703#define NET_UDPH_LEN 8 /* Size of UDP header */
704#define NET_TCPH_LEN 20 /* Size of TCP header */
705#define NET_ICMPH_LEN 4 /* Size of ICMP header */
706
707#define NET_IPV6H_LEN 40 /* Size of IPv6 header */
708#define NET_ICMPV6H_LEN NET_ICMPH_LEN /* Size of ICMPv6 header */
709#define NET_IPV6UDPH_LEN (NET_UDPH_LEN + NET_IPV6H_LEN) /* IPv6 + UDP */
710#define NET_IPV6TCPH_LEN (NET_TCPH_LEN + NET_IPV6H_LEN) /* IPv6 + TCP */
711#define NET_IPV6ICMPH_LEN (NET_IPV6H_LEN + NET_ICMPH_LEN) /* ICMPv6 + IPv6 */
712#define NET_IPV6_FRAGH_LEN 8
713
714#define NET_IPV4H_LEN 20 /* Size of IPv4 header */
715#define NET_ICMPV4H_LEN NET_ICMPH_LEN /* Size of ICMPv4 header */
716#define NET_IPV4UDPH_LEN (NET_UDPH_LEN + NET_IPV4H_LEN) /* IPv4 + UDP */
717#define NET_IPV4TCPH_LEN (NET_TCPH_LEN + NET_IPV4H_LEN) /* IPv4 + TCP */
718#define NET_IPV4ICMPH_LEN (NET_IPV4H_LEN + NET_ICMPH_LEN) /* ICMPv4 + IPv4 */
719
720#define NET_IPV6H_LENGTH_OFFSET 0x04 /* Offset of the Length field in the IPv6 header */
721
722#define NET_IPV6_FRAGH_OFFSET_MASK 0xfff8 /* Mask for the 13-bit Fragment Offset field */
723#define NET_IPV4_FRAGH_OFFSET_MASK 0x1fff /* Mask for the 13-bit Fragment Offset field */
724#define NET_IPV4_MORE_FRAG_MASK 0x2000 /* Mask for the 1-bit More Fragments field */
725#define NET_IPV4_DO_NOT_FRAG_MASK 0x4000 /* Mask for the 1-bit Do Not Fragment field */
726
728#if defined(CONFIG_NET_INTERFACE_NAME)
729#define NET_IFNAMSIZ CONFIG_NET_INTERFACE_NAME_LEN
730#else
731#if defined(Z_DEVICE_MAX_NAME_LEN)
732#define NET_IFNAMSIZ Z_DEVICE_MAX_NAME_LEN
733#else
734#define NET_IFNAMSIZ 1
735#endif /* Z_DEVICE_MAX_NAME_LEN */
736#endif /* CONFIG_NET_INTERFACE_NAME */
737
739
744
746struct net_ifreq {
747 char ifr_name[NET_IFNAMSIZ];
748};
749
750
762
771
779
790
799 unsigned int ipi6_ifindex;
800};
801
803static inline bool net_ipv6_is_addr_loopback_raw(const uint8_t *addr)
804{
805 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
806 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
807 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
808 net_ntohl(UNALIGNED_GET((uint32_t *)addr + 3)) == 1;
809}
811
819static inline bool net_ipv6_is_addr_loopback(const struct net_in6_addr *addr)
820{
821 return net_ipv6_is_addr_loopback_raw(addr->s6_addr);
822}
823
825static inline bool net_ipv6_is_addr_mcast_raw(const uint8_t *addr)
826{
827 return addr[0] == 0xff;
828}
830
838static inline bool net_ipv6_is_addr_mcast(const struct net_in6_addr *addr)
839{
840 return net_ipv6_is_addr_mcast_raw(addr->s6_addr);
841}
842
843struct net_if;
844struct net_if_config;
845
847extern struct net_if_addr *net_if_ipv6_addr_lookup_raw(const uint8_t *addr,
848 struct net_if **ret);
849
850static inline bool net_ipv6_is_my_addr_raw(const uint8_t *addr)
851{
852 return net_if_ipv6_addr_lookup_raw(addr, NULL) != NULL;
853}
855
856extern struct net_if_addr *net_if_ipv6_addr_lookup(const struct net_in6_addr *addr,
857 struct net_if **iface);
858
866static inline bool net_ipv6_is_my_addr(struct net_in6_addr *addr)
867{
868 return net_if_ipv6_addr_lookup(addr, NULL) != NULL;
869}
870
872 const struct net_in6_addr *addr, struct net_if **iface);
873
882static inline bool net_ipv6_is_my_maddr(struct net_in6_addr *maddr)
883{
884 return net_if_ipv6_maddr_lookup(maddr, NULL) != NULL;
885}
886
896static inline bool net_ipv6_is_prefix(const uint8_t *addr1,
897 const uint8_t *addr2,
898 uint8_t length)
899{
900 uint8_t bits = 128 - length;
901 uint8_t bytes = length / 8U;
902 uint8_t remain = bits % 8;
903 uint8_t mask;
904
905 if (length > 128) {
906 return false;
907 }
908
909 if (memcmp(addr1, addr2, bytes)) {
910 return false;
911 }
912
913 if (!remain) {
914 /* No remaining bits, the prefixes are the same as first
915 * bytes are the same.
916 */
917 return true;
918 }
919
920 /* Create a mask that has remaining most significant bits set */
921 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
922
923 return (addr1[bytes] & mask) == (addr2[bytes] & mask);
924}
925
926
934static inline void net_ipv6_addr_prefix_mask(const uint8_t *inaddr,
935 uint8_t *outaddr,
936 uint8_t prefix_len)
937{
938 uint8_t bits = 128 - prefix_len;
939 uint8_t bytes = prefix_len / 8U;
940 uint8_t remain = bits % 8;
941 uint8_t mask;
942
943 memset(outaddr, 0, 16U);
944 memcpy(outaddr, inaddr, bytes);
945
946 if (!remain) {
947 /* No remaining bits, the prefixes are the same as first
948 * bytes are the same.
949 */
950 return;
951 }
952
953 /* Create a mask that has remaining most significant bits set */
954 mask = (uint8_t)((0xff << (8 - remain)) ^ 0xff) << remain;
955 outaddr[bytes] = inaddr[bytes] & mask;
956}
957
959static inline bool net_ipv4_is_addr_loopback_raw(const uint8_t *addr)
960{
961 return addr[0] == 127U;
962}
964
972static inline bool net_ipv4_is_addr_loopback(const struct net_in_addr *addr)
973{
974 return net_ipv4_is_addr_loopback_raw(addr->s4_addr);
975}
976
978static inline bool net_ipv4_is_addr_unspecified_raw(const uint8_t *addr)
979{
980 return UNALIGNED_GET((uint32_t *)addr) == 0;
981}
983
991static inline bool net_ipv4_is_addr_unspecified(const struct net_in_addr *addr)
992{
993 return net_ipv4_is_addr_unspecified_raw(addr->s4_addr);
994}
995
997static inline bool net_ipv4_is_addr_mcast_raw(const uint8_t *addr)
998{
999 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xF0000000) == 0xE0000000;
1000}
1002
1010static inline bool net_ipv4_is_addr_mcast(const struct net_in_addr *addr)
1011{
1012 return net_ipv4_is_addr_mcast_raw(addr->s4_addr);
1013}
1014
1016static inline bool net_ipv4_is_ll_addr_raw(const uint8_t *addr)
1017{
1018 return (net_ntohl(UNALIGNED_GET((uint32_t *)addr)) & 0xFFFF0000) == 0xA9FE0000;
1019}
1021
1029static inline bool net_ipv4_is_ll_addr(const struct net_in_addr *addr)
1030{
1031 return net_ipv4_is_ll_addr_raw(addr->s4_addr);
1032}
1033
1043static inline bool net_ipv4_is_private_addr(const struct net_in_addr *addr)
1044{
1045 uint32_t masked_24, masked_16, masked_12, masked_10, masked_8;
1046
1047 masked_24 = net_ntohl(UNALIGNED_GET(&addr->s_addr)) & 0xFFFFFF00;
1048 masked_16 = masked_24 & 0xFFFF0000;
1049 masked_12 = masked_24 & 0xFFF00000;
1050 masked_10 = masked_24 & 0xFFC00000;
1051 masked_8 = masked_24 & 0xFF000000;
1052
1053 return masked_8 == 0x0A000000 || /* 10.0.0.0/8 */
1054 masked_10 == 0x64400000 || /* 100.64.0.0/10 */
1055 masked_12 == 0xAC100000 || /* 172.16.0.0/12 */
1056 masked_16 == 0xC0A80000 || /* 192.168.0.0/16 */
1057 masked_24 == 0xC0000200 || /* 192.0.2.0/24 */
1058 masked_24 == 0xC0336400 || /* 192.51.100.0/24 */
1059 masked_24 == 0xCB007100; /* 203.0.113.0/24 */
1060}
1061
1070#define net_ipaddr_copy(dest, src) \
1071 UNALIGNED_PUT(UNALIGNED_GET(src), dest)
1072
1079static inline void net_ipv4_addr_copy_raw(uint8_t *dest,
1080 const uint8_t *src)
1081{
1082 net_ipaddr_copy((struct net_in_addr *)dest, (const struct net_in_addr *)src);
1083}
1084
1091static inline void net_ipv6_addr_copy_raw(uint8_t *dest,
1092 const uint8_t *src)
1093{
1094 memcpy(dest, src, sizeof(struct net_in6_addr));
1095}
1096
1105static inline bool net_ipv4_addr_cmp_raw(const uint8_t *addr1,
1106 const uint8_t *addr2)
1107{
1108 return UNALIGNED_GET((uint32_t *)addr1) == UNALIGNED_GET((uint32_t *)addr2);
1109}
1110
1119static inline bool net_ipv4_addr_cmp(const struct net_in_addr *addr1,
1120 const struct net_in_addr *addr2)
1121{
1122 return net_ipv4_addr_cmp_raw(addr1->s4_addr, addr2->s4_addr);
1123}
1124
1133static inline bool net_ipv6_addr_cmp(const struct net_in6_addr *addr1,
1134 const struct net_in6_addr *addr2)
1135{
1136 return !memcmp(addr1, addr2, sizeof(struct net_in6_addr));
1137}
1138
1147static inline bool net_ipv6_addr_cmp_raw(const uint8_t *addr1,
1148 const uint8_t *addr2)
1149{
1150 return net_ipv6_addr_cmp((const struct net_in6_addr *)addr1,
1151 (const struct net_in6_addr *)addr2);
1152}
1153
1155static inline bool net_ipv6_is_ll_addr_raw(const uint8_t *addr)
1156{
1157 return UNALIGNED_GET((uint16_t *)addr) == net_htons(0xFE80);
1158}
1160
1168static inline bool net_ipv6_is_ll_addr(const struct net_in6_addr *addr)
1169{
1170 return net_ipv6_is_ll_addr_raw(addr->s6_addr);
1171}
1172
1180static inline bool net_ipv6_is_sl_addr(const struct net_in6_addr *addr)
1181{
1182 return UNALIGNED_GET(&addr->s6_addr16[0]) == net_htons(0xFEC0);
1183}
1184
1185
1193static inline bool net_ipv6_is_ula_addr(const struct net_in6_addr *addr)
1194{
1195 return addr->s6_addr[0] == 0xFD;
1196}
1197
1205static inline bool net_ipv6_is_global_addr(const struct net_in6_addr *addr)
1206{
1207 return (addr->s6_addr[0] & 0xE0) == 0x20;
1208}
1209
1219static inline bool net_ipv6_is_private_addr(const struct net_in6_addr *addr)
1220{
1221 uint32_t masked_32, masked_7;
1222
1223 masked_32 = net_ntohl(UNALIGNED_GET(&addr->s6_addr32[0]));
1224 masked_7 = masked_32 & 0xfc000000;
1225
1226 return masked_32 == 0x20010db8 || /* 2001:db8::/32 */
1227 masked_7 == 0xfc000000; /* fc00::/7 */
1228}
1229
1236
1243
1250
1251struct net_if;
1252extern bool net_if_ipv4_addr_mask_cmp(struct net_if *iface,
1253 const struct net_in_addr *addr);
1254
1264static inline bool net_ipv4_addr_mask_cmp(struct net_if *iface,
1265 const struct net_in_addr *addr)
1266{
1267 return net_if_ipv4_addr_mask_cmp(iface, addr);
1268}
1269
1271extern bool net_if_ipv4_is_addr_bcast_raw(struct net_if *iface,
1272 const uint8_t *addr);
1273
1274#if defined(CONFIG_NET_NATIVE_IPV4)
1275static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1276 const uint8_t *addr)
1277{
1278 if (net_ipv4_addr_cmp_raw(addr, net_ipv4_broadcast_address()->s4_addr)) {
1279 return true;
1280 }
1281
1282 return net_if_ipv4_is_addr_bcast_raw(iface, addr);
1283}
1284#else
1285static inline bool net_ipv4_is_addr_bcast_raw(struct net_if *iface,
1286 const uint8_t *addr)
1287{
1288 ARG_UNUSED(iface);
1289 ARG_UNUSED(addr);
1290
1291 return false;
1292}
1293#endif
1295
1296extern bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
1297 const struct net_in_addr *addr);
1298
1307#if defined(CONFIG_NET_NATIVE_IPV4)
1308static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1309 const struct net_in_addr *addr)
1310{
1312 return true;
1313 }
1314
1315 return net_if_ipv4_is_addr_bcast(iface, addr);
1316}
1317#else
1318static inline bool net_ipv4_is_addr_bcast(struct net_if *iface,
1319 const struct net_in_addr *addr)
1320{
1321 ARG_UNUSED(iface);
1322 ARG_UNUSED(addr);
1323
1324 return false;
1325}
1326#endif
1327
1329extern struct net_if_addr *net_if_ipv4_addr_lookup_raw(const uint8_t *addr,
1330 struct net_if **ret);
1331
1332static inline bool net_ipv4_is_my_addr_raw(const uint8_t *addr)
1333{
1334 bool ret;
1335
1336 ret = net_if_ipv4_addr_lookup_raw(addr, NULL) != NULL;
1337 if (!ret) {
1338 ret = net_ipv4_is_addr_bcast_raw(NULL, addr);
1339 }
1340
1341 return ret;
1342}
1344
1345extern struct net_if_addr *net_if_ipv4_addr_lookup(const struct net_in_addr *addr,
1346 struct net_if **iface);
1347
1357static inline bool net_ipv4_is_my_addr(const struct net_in_addr *addr)
1358{
1359 bool ret;
1360
1361 ret = net_if_ipv4_addr_lookup(addr, NULL) != NULL;
1362 if (!ret) {
1363 ret = net_ipv4_is_addr_bcast(NULL, addr);
1364 }
1365
1366 return ret;
1367}
1368
1370static inline bool net_ipv6_is_addr_unspecified_raw(const uint8_t *addr)
1371{
1372 return UNALIGNED_GET((uint32_t *)addr) == 0 &&
1373 UNALIGNED_GET((uint32_t *)addr + 1) == 0 &&
1374 UNALIGNED_GET((uint32_t *)addr + 2) == 0 &&
1375 UNALIGNED_GET((uint32_t *)addr + 3) == 0;
1376}
1378
1386static inline bool net_ipv6_is_addr_unspecified(const struct net_in6_addr *addr)
1387{
1388 return net_ipv6_is_addr_unspecified_raw(addr->s6_addr);
1389}
1390
1392static inline bool net_ipv6_is_addr_solicited_node_raw(const uint8_t *addr)
1393{
1394 return UNALIGNED_GET((uint32_t *)addr) == net_htonl(0xff020000) &&
1395 UNALIGNED_GET((uint32_t *)addr + 1) == 0x00000000 &&
1396 UNALIGNED_GET((uint32_t *)addr + 2) == net_htonl(0x00000001) &&
1397 ((UNALIGNED_GET((uint32_t *)addr + 3) & net_htonl(0xff000000)) ==
1398 net_htonl(0xff000000));
1399}
1401
1410static inline bool net_ipv6_is_addr_solicited_node(const struct net_in6_addr *addr)
1411{
1412 return net_ipv6_is_addr_solicited_node_raw(addr->s6_addr);
1413}
1414
1416static inline bool net_ipv6_is_addr_mcast_scope_raw(const uint8_t *addr,
1417 int scope)
1418{
1419 return (addr[0] == 0xff) && ((addr[1] & 0xF) == scope);
1420}
1422
1424static inline int net_ipv6_get_addr_mcast_scope_raw(const uint8_t *addr)
1425{
1426 if (addr[0] == 0xff) {
1427 return (addr[1] & 0xF);
1428 }
1429
1430 return -1;
1431}
1433
1444static inline bool net_ipv6_is_addr_mcast_scope(const struct net_in6_addr *addr,
1445 int scope)
1446{
1447 return net_ipv6_is_addr_mcast_scope_raw(addr->s6_addr, scope);
1448}
1449
1459static inline bool net_ipv6_is_same_mcast_scope(const struct net_in6_addr *addr_1,
1460 const struct net_in6_addr *addr_2)
1461{
1462 return (addr_1->s6_addr[0] == 0xff) && (addr_2->s6_addr[0] == 0xff) &&
1463 (addr_1->s6_addr[1] == addr_2->s6_addr[1]);
1464}
1465
1473static inline int net_ipv6_get_addr_mcast_scope(const struct net_in6_addr *addr)
1474{
1475 return net_ipv6_get_addr_mcast_scope_raw(addr->s6_addr);
1476}
1477
1479static inline bool net_ipv6_is_addr_mcast_iface_raw(const uint8_t *addr)
1480{
1481 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x01);
1482}
1483
1484static inline bool net_ipv6_is_addr_mcast_link_raw(const uint8_t *addr)
1485{
1486 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x02);
1487}
1488
1489static inline bool net_ipv6_is_addr_mcast_mesh_raw(const uint8_t *addr)
1490{
1491 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x03);
1492}
1493
1494static inline bool net_ipv6_is_addr_mcast_site_raw(const uint8_t *addr)
1495{
1496 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x05);
1497}
1498
1499static inline bool net_ipv6_is_addr_mcast_org_raw(const uint8_t *addr)
1500{
1501 return net_ipv6_is_addr_mcast_scope_raw(addr, 0x08);
1502}
1504
1512static inline bool net_ipv6_is_addr_mcast_global(const struct net_in6_addr *addr)
1513{
1514 return net_ipv6_is_addr_mcast_scope(addr, 0x0e);
1515}
1516
1526static inline bool net_ipv6_is_addr_mcast_iface(const struct net_in6_addr *addr)
1527{
1528 return net_ipv6_is_addr_mcast_scope(addr, 0x01);
1529}
1530
1540static inline bool net_ipv6_is_addr_mcast_link(const struct net_in6_addr *addr)
1541{
1542 return net_ipv6_is_addr_mcast_scope(addr, 0x02);
1543}
1544
1554static inline bool net_ipv6_is_addr_mcast_mesh(const struct net_in6_addr *addr)
1555{
1556 return net_ipv6_is_addr_mcast_scope(addr, 0x03);
1557}
1558
1568static inline bool net_ipv6_is_addr_mcast_site(const struct net_in6_addr *addr)
1569{
1570 return net_ipv6_is_addr_mcast_scope(addr, 0x05);
1571}
1572
1582static inline bool net_ipv6_is_addr_mcast_org(const struct net_in6_addr *addr)
1583{
1584 return net_ipv6_is_addr_mcast_scope(addr, 0x08);
1585}
1586
1588static inline bool net_ipv6_is_addr_mcast_group_raw(const uint8_t *addr,
1589 const uint8_t *group)
1590{
1591 return UNALIGNED_GET((uint16_t *)addr + 1) == UNALIGNED_GET((uint16_t *)group + 1) &&
1592 UNALIGNED_GET((uint32_t *)addr + 1) == UNALIGNED_GET((uint32_t *)group + 1) &&
1593 UNALIGNED_GET((uint32_t *)addr + 2) == UNALIGNED_GET((uint32_t *)group + 2) &&
1594 UNALIGNED_GET((uint32_t *)addr + 3) == UNALIGNED_GET((uint32_t *)group + 3);
1595}
1597
1608static inline bool net_ipv6_is_addr_mcast_group(const struct net_in6_addr *addr,
1609 const struct net_in6_addr *group)
1610{
1611 return net_ipv6_is_addr_mcast_group_raw(addr->s6_addr, group->s6_addr);
1612}
1613
1615static inline bool net_ipv6_is_addr_mcast_all_nodes_group_raw(const uint8_t *addr)
1616{
1617 static const uint8_t all_nodes_mcast_group[NET_IPV6_ADDR_SIZE] = {
1618 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1619 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1620 };
1621
1622 return net_ipv6_is_addr_mcast_group_raw(addr, all_nodes_mcast_group);
1623}
1625
1634static inline bool
1636{
1637 return net_ipv6_is_addr_mcast_all_nodes_group_raw(addr->s6_addr);
1638}
1639
1649static inline bool
1655
1657static inline bool net_ipv6_is_addr_mcast_link_all_nodes_raw(const uint8_t *addr)
1658{
1659 return net_ipv6_is_addr_mcast_link_raw(addr) &&
1660 net_ipv6_is_addr_mcast_all_nodes_group_raw(addr);
1661}
1663
1673static inline bool
1679
1687static inline
1689 struct net_in6_addr *dst)
1690{
1691 dst->s6_addr[0] = 0xFF;
1692 dst->s6_addr[1] = 0x02;
1693 UNALIGNED_PUT(0, &dst->s6_addr16[1]);
1694 UNALIGNED_PUT(0, &dst->s6_addr16[2]);
1695 UNALIGNED_PUT(0, &dst->s6_addr16[3]);
1696 UNALIGNED_PUT(0, &dst->s6_addr16[4]);
1697 dst->s6_addr[10] = 0U;
1698 dst->s6_addr[11] = 0x01;
1699 dst->s6_addr[12] = 0xFF;
1700 dst->s6_addr[13] = src->s6_addr[13];
1701 UNALIGNED_PUT(UNALIGNED_GET(&src->s6_addr16[7]), &dst->s6_addr16[7]);
1702}
1703
1716static inline void net_ipv6_addr_create(struct net_in6_addr *addr,
1717 uint16_t addr0, uint16_t addr1,
1718 uint16_t addr2, uint16_t addr3,
1719 uint16_t addr4, uint16_t addr5,
1720 uint16_t addr6, uint16_t addr7)
1721{
1722 UNALIGNED_PUT(net_htons(addr0), &addr->s6_addr16[0]);
1723 UNALIGNED_PUT(net_htons(addr1), &addr->s6_addr16[1]);
1724 UNALIGNED_PUT(net_htons(addr2), &addr->s6_addr16[2]);
1725 UNALIGNED_PUT(net_htons(addr3), &addr->s6_addr16[3]);
1726 UNALIGNED_PUT(net_htons(addr4), &addr->s6_addr16[4]);
1727 UNALIGNED_PUT(net_htons(addr5), &addr->s6_addr16[5]);
1728 UNALIGNED_PUT(net_htons(addr6), &addr->s6_addr16[6]);
1729 UNALIGNED_PUT(net_htons(addr7), &addr->s6_addr16[7]);
1730}
1731
1738{
1739 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001);
1740}
1741
1748{
1749 net_ipv6_addr_create(addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002);
1750}
1751
1758static inline void net_ipv6_addr_create_v4_mapped(const struct net_in_addr *addr4,
1759 struct net_in6_addr *addr6)
1760{
1761 net_ipv6_addr_create(addr6, 0, 0, 0, 0, 0, 0xffff,
1762 net_ntohs(addr4->s4_addr16[0]),
1763 net_ntohs(addr4->s4_addr16[1]));
1764}
1765
1774static inline bool net_ipv6_addr_is_v4_mapped(const struct net_in6_addr *addr)
1775{
1776 if (UNALIGNED_GET(&addr->s6_addr32[0]) == 0 &&
1777 UNALIGNED_GET(&addr->s6_addr32[1]) == 0 &&
1778 UNALIGNED_GET(&addr->s6_addr16[5]) == 0xffff) {
1779 return true;
1780 }
1781
1782 return false;
1783}
1784
1793static inline void net_ipv6_addr_get_v4_mapped(const struct net_in6_addr *addr6,
1794 struct net_in_addr *addr4)
1795{
1796 addr4->s_addr = UNALIGNED_GET(&addr6->s6_addr32[3]);
1797}
1798
1818 const struct net_in6_addr *prefix,
1819 uint8_t *network_id, size_t network_id_len,
1820 uint8_t dad_counter,
1821 struct net_in6_addr *addr,
1822 struct net_linkaddr *lladdr);
1823
1830static inline void net_ipv6_addr_create_iid(struct net_in6_addr *addr,
1831 struct net_linkaddr *lladdr)
1832{
1833 (void)net_ipv6_addr_generate_iid(NULL, NULL, NULL, 0, 0, addr, lladdr);
1834}
1835
1837static inline bool net_ipv6_addr_based_on_ll_raw(const uint8_t *addr,
1838 const struct net_linkaddr *lladdr)
1839{
1840 if (addr == NULL || lladdr == NULL) {
1841 return false;
1842 }
1843
1844 switch (lladdr->len) {
1845 case 2:
1846 if (!memcmp(&addr[14], lladdr->addr, lladdr->len) &&
1847 addr[8] == 0U &&
1848 addr[9] == 0U &&
1849 addr[10] == 0U &&
1850 addr[11] == 0xff &&
1851 addr[12] == 0xfe) {
1852 return true;
1853 }
1854
1855 break;
1856 case 6:
1857 if (lladdr->type == NET_LINK_ETHERNET) {
1858 if (!memcmp(&addr[9], &lladdr->addr[1], 2) &&
1859 !memcmp(&addr[13], &lladdr->addr[3], 3) &&
1860 addr[11] == 0xff &&
1861 addr[12] == 0xfe &&
1862 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1863 return true;
1864 }
1865 }
1866
1867 break;
1868 case 8:
1869 if (sizeof(lladdr->addr) < 8) {
1870 return false;
1871 }
1872
1873 if (!memcmp(&addr[9], &lladdr->addr[1],
1874 lladdr->len - 1) &&
1875 (addr[8] ^ 0x02) == lladdr->addr[0]) {
1876 return true;
1877 }
1878
1879 break;
1880 default:
1881 return false;
1882 }
1883
1884 return false;
1885}
1887
1893static inline bool net_ipv6_addr_based_on_ll(const struct net_in6_addr *addr,
1894 const struct net_linkaddr *lladdr)
1895{
1896 if (addr == NULL || lladdr == NULL) {
1897 return false;
1898 }
1899
1900 return net_ipv6_addr_based_on_ll_raw(addr->s6_addr, lladdr);
1901}
1902
1911static inline struct net_sockaddr *net_sad(const struct net_sockaddr_storage *addr)
1912{
1913 return (struct net_sockaddr *)addr;
1914}
1915
1924static inline struct net_sockaddr_storage *net_sas(const struct net_sockaddr *addr)
1925{
1926 return (struct net_sockaddr_storage *)addr;
1927}
1928
1937static inline struct net_sockaddr_in6 *net_sin6(const struct net_sockaddr *addr)
1938{
1939 return (struct net_sockaddr_in6 *)addr;
1940}
1941
1950static inline struct net_sockaddr_in *net_sin(const struct net_sockaddr *addr)
1951{
1952 return (struct net_sockaddr_in *)addr;
1953}
1954
1963static inline
1964struct net_sockaddr_in6_ptr *net_sin6_ptr(const struct net_sockaddr_ptr *addr)
1965{
1966 return (struct net_sockaddr_in6_ptr *)addr;
1967}
1968
1977static inline
1978struct net_sockaddr_in_ptr *net_sin_ptr(const struct net_sockaddr_ptr *addr)
1979{
1980 return (struct net_sockaddr_in_ptr *)addr;
1981}
1982
1991static inline
1992struct net_sockaddr_ll_ptr *net_sll_ptr(const struct net_sockaddr_ptr *addr)
1993{
1994 return (struct net_sockaddr_ll_ptr *)addr;
1995}
1996
2005static inline
2006struct net_sockaddr_can_ptr *net_can_ptr(const struct net_sockaddr_ptr *addr)
2007{
2008 return (struct net_sockaddr_can_ptr *)addr;
2009}
2010
2024__syscall int net_addr_pton(net_sa_family_t family, const char *src, void *dst);
2025
2037__syscall char *net_addr_ntop(net_sa_family_t family, const void *src,
2038 char *dst, size_t size);
2039
2051 struct net_sockaddr *mask);
2052
2064 uint8_t *mask_len);
2065
2087bool net_ipaddr_parse(const char *str, size_t str_len,
2088 struct net_sockaddr *addr);
2089
2117const char *net_ipaddr_parse_mask(const char *str, size_t str_len,
2118 struct net_sockaddr *addr, uint8_t *mask_len);
2119
2129int net_port_set_default(struct net_sockaddr *addr, uint16_t default_port);
2130
2139int net_port_set(struct net_sockaddr *addr, uint16_t port);
2140
2149int net_port_get(struct net_sockaddr *addr, uint16_t *port);
2150
2162static inline int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
2163{
2164 return (int32_t)(seq1 - seq2);
2165}
2166
2177static inline bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
2178{
2179 return net_tcp_seq_cmp(seq1, seq2) > 0;
2180}
2181
2193int net_bytes_from_str(uint8_t *buf, int buf_len, const char *src);
2194
2204
2214
2223static inline enum net_priority net_vlan2priority(uint8_t priority)
2224{
2225 /* Map according to IEEE 802.1Q */
2226 static const uint8_t vlan2priority[] = {
2235 };
2236
2237 if (priority >= ARRAY_SIZE(vlan2priority)) {
2238 /* Use Best Effort as the default priority */
2239 return NET_PRIORITY_BE;
2240 }
2241
2242 return (enum net_priority)vlan2priority[priority];
2243}
2244
2252static inline uint8_t net_priority2vlan(enum net_priority priority)
2253{
2254 /* The conversion works both ways */
2255 return (uint8_t)net_vlan2priority(priority);
2256}
2257
2267
2275static inline size_t net_family2size(net_sa_family_t family)
2276{
2277 switch (family) {
2278 case NET_AF_INET:
2279 return sizeof(struct net_sockaddr_in);
2280 case NET_AF_INET6:
2281 return sizeof(struct net_sockaddr_in6);
2282 case NET_AF_PACKET:
2283 return sizeof(struct net_sockaddr_ll);
2284 case NET_AF_UNIX:
2285 return sizeof(struct net_sockaddr_un);
2286 case NET_AF_CAN:
2287 return sizeof(struct net_sockaddr_can);
2288 case NET_AF_NET_MGMT:
2289 return sizeof(struct net_sockaddr_nm);
2290 default:
2291 return 0;
2292 }
2293}
2294
2305#if defined(CONFIG_NET_IPV6_PE)
2306int net_ipv6_pe_add_filter(struct net_in6_addr *addr, bool is_denylist);
2307#else
2308static inline int net_ipv6_pe_add_filter(struct net_in6_addr *addr,
2309 bool is_denylist)
2310{
2311 ARG_UNUSED(addr);
2312 ARG_UNUSED(is_denylist);
2313
2314 return -ENOTSUP;
2315}
2316#endif /* CONFIG_NET_IPV6_PE */
2317
2325#if defined(CONFIG_NET_IPV6_PE)
2326int net_ipv6_pe_del_filter(struct net_in6_addr *addr);
2327#else
2328static inline int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
2329{
2330 ARG_UNUSED(addr);
2331
2332 return -ENOTSUP;
2333}
2334#endif /* CONFIG_NET_IPV6_PE */
2335
2336#ifdef __cplusplus
2337}
2338#endif
2339
2340#include <zephyr/syscalls/net_ip.h>
2341
2342#if defined(CONFIG_NET_NAMESPACE_COMPAT_MODE)
2343#define ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2344#include <zephyr/net/net_compat.h>
2345#undef ZEPHYR_INCLUDE_NET_COMPAT_MODE_SYMBOLS
2346#endif /* CONFIG_NET_NAMESPACE_COMPAT_MODE */
2347
2351
2352#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:2006
#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:1193
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:2275
#define NET_IPV4_ADDR_SIZE
Binary size of the IPv4 address.
Definition net_ip.h:166
static enum net_priority net_vlan2priority(uint8_t priority)
Convert network packet VLAN priority to network packet priority so we can place the packet into corre...
Definition net_ip.h:2223
static int32_t net_tcp_seq_cmp(uint32_t seq1, uint32_t seq2)
Compare TCP sequence numbers.
Definition net_ip.h:2162
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:882
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:1119
#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:1774
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:1386
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:1554
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:1758
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:1010
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:1105
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:1219
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:991
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:838
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:1526
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:1091
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:1264
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:934
#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:1911
#define net_htonl(x)
Convert 32-bit value from host to network byte order.
Definition net_ip.h:133
const char * net_ipaddr_parse_mask(const char *str, size_t str_len, struct net_sockaddr *addr, uint8_t *mask_len)
Parse a string that contains either IPv4 or IPv6 address and optional mask len, and store the informa...
static struct net_sockaddr_in6 * net_sin6(const struct net_sockaddr *addr)
Get net_sockaddr_in6 from net_sockaddr.
Definition net_ip.h:1937
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:1978
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:1357
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:972
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:1029
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:1133
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:1737
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:1793
#define net_ipaddr_copy(dest, src)
Copy an IPv4 or IPv6 address.
Definition net_ip.h:1070
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:1893
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:1473
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:1830
static struct net_sockaddr_in * net_sin(const struct net_sockaddr *addr)
Get net_sockaddr_in from net_sockaddr.
Definition net_ip.h:1950
#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:2252
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:1568
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:1444
#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:866
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:896
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:819
static struct net_sockaddr_storage * net_sas(const struct net_sockaddr *addr)
Get net_sockaddr_storage from net_sockaddr.
Definition net_ip.h:1924
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:1582
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:2308
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:1608
static bool net_tcp_seq_greater(uint32_t seq1, uint32_t seq2)
Check that one TCP sequence number is greater.
Definition net_ip.h:2177
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:1410
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:1716
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:1205
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:1992
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:1674
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:1964
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:1635
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:1459
static int net_ipv6_pe_del_filter(struct net_in6_addr *addr)
Delete IPv6 prefix from privacy extension filter list.
Definition net_ip.h:2328
#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:1168
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:1043
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:1688
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:1540
#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:1747
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:1650
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:1180
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:1079
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:1512
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:1147
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:1318
@ 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:114
#define in_addr
Definition in.h:20
#define in6_addr
Definition in.h:21
Network namespace compatibility mode header.
Public API for network link address.
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
void * memset(void *buf, int c, size_t n)
int memcmp(const void *m1, const void *m2, size_t n)
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
Group structure.
Definition grp.h:18
Control message ancillary data.
Definition net_ip.h:306
net_socklen_t cmsg_len
Number of bytes, including header.
Definition net_ip.h:307
int cmsg_level
Originating protocol.
Definition net_ip.h:308
int cmsg_type
Protocol-specific type.
Definition net_ip.h:309
z_max_align_t cmsg_data[]
Flexible array member to force alignment of net_cmsghdr.
Definition net_ip.h:310
Network Interface unicast IP addresses.
Definition net_if.h:56
IP and other configuration related data for network interface.
Definition net_if.h:584
Network Interface multicast IP addresses.
Definition net_if.h:161
Network Interface structure.
Definition net_if.h:733
Interface description structure.
Definition net_ip.h:746
char ifr_name[NET_IFNAMSIZ]
Network interface name.
Definition net_ip.h:747
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:797
unsigned int ipi6_ifindex
Receive interface index.
Definition net_ip.h:799
struct net_in6_addr ipi6_addr
Destination IPv6 address.
Definition net_ip.h:798
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:757
unsigned int ipi_ifindex
Network interface index.
Definition net_ip.h:758
struct net_in_addr ipi_addr
Header Destination address.
Definition net_ip.h:760
struct net_in_addr ipi_spec_dst
Local address.
Definition net_ip.h:759
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:775
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:776
struct net_in_addr imr_interface
IP address of local interface.
Definition net_ip.h:777
Struct used when joining or leaving a IPv4 multicast group.
Definition net_ip.h:766
int imr_ifindex
Network interface index.
Definition net_ip.h:769
struct net_in_addr imr_address
IP address of local interface.
Definition net_ip.h:768
struct net_in_addr imr_multiaddr
IP multicast group address.
Definition net_ip.h:767
Struct used when joining or leaving a IPv6 multicast group.
Definition net_ip.h:783
struct net_in6_addr ipv6mr_multiaddr
IPv6 multicast address of group.
Definition net_ip.h:785
int ipv6mr_ifindex
Network interface index of the local IPv6 address.
Definition net_ip.h:788
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.