posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
in.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
16#ifndef ZEPHYR_INCLUDE_POSIX_NETINET_IN_H_
17#define ZEPHYR_INCLUDE_POSIX_NETINET_IN_H_
18
19#include <stdint.h>
20
21#include <zephyr/net/net_ip.h>
22#include <zephyr/net/socket.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#if !defined(_SA_FAMILY_T_DECLARED) && !defined(__sa_family_t_defined)
29typedef net_sa_family_t sa_family_t;
30#define _SA_FAMILY_T_DECLARED
31#define __sa_family_t_defined
32#endif
33
34#if !(defined(_IN_PORT_T_DECLARED) || defined(__in_port_t_defined)) || defined(__DOXYGEN__)
36typedef uint16_t in_port_t;
37#define _IN_PORT_T_DECLARED
38#define __in_port_t_defined
39#endif
40
41#if !(defined(_IN_ADDR_T_DECLARED) || defined(__in_addr_t_defined)) || defined(__DOXYGEN__)
43typedef uint32_t in_addr_t;
44#define _IN_ADDR_T_DECLARED
45#define __in_addr_t_defined
46#endif
47
48#if !(defined(_IN_ADDR_DECLARED) || defined(__in_addr_defined)) || defined(__DOXYGEN__)
50struct in_addr {
51 in_addr_t s_addr;
52};
53#define _IN_ADDR_DECLARED
54#define __in_addr_defined
55#endif
56
57#if !(defined(_SOCKADDR_IN_DECLARED) || defined(__sockaddr_in_defined)) || defined(__DOXYGEN__)
64#define _SOCKADDR_IN_DECLARED
65#define __sockaddr_in_defined
66#endif
67
68#if !(defined(_IN6_ADDR_DECLARED) || defined(__in6_addr_defined)) || defined(__DOXYGEN__)
70struct in6_addr {
71 uint8_t s6_addr[16];
72};
73#define _IN6_ADDR_DECLARED
74#define __in6_addr_defined
75#endif
76
77#if !(defined(_SOCKADDR_IN6_DECLARED) || defined(__sockaddr_in6_defined)) || defined(__DOXYGEN__)
80 sa_family_t sin6_family;
83 uint32_t sin6_scope_id;
84 /* slightly out of order w.r.t. spec (zephyr assumes consistent family, port, addr offsets) */
85 uint32_t sin6_flowinfo;
86};
87#define _SOCKADDR_IN6_DECLARED
88#define __sockaddr_in6_defined
89#endif
90
92extern const struct in6_addr in6addr_any;
94extern const struct in6_addr in6addr_loopback;
95
97#define IN6ADDR_ANY_INIT { { 0 } }
99#define IN6ADDR_LOOPBACK_INIT { { 0, 0, 0, 0, 0, 0, 0, 0, \
100 0, 0, 0, 0, 0, 0, 0, 1 } }
101
102#if !(defined(_IPV6_MREQ_DECLARED) || defined(__ipv6_mreq_defined)) || defined(__DOXYGEN__)
104struct ipv6_mreq {
106 unsigned int ipv6mr_interface;
107};
108#define _IPV6_MREQ_DECLARED
109#define __ipv6_mreq_defined
110#endif
111
112/* Protocols (IPPROTO_*). */
113#define IPPROTO_IP NET_IPPROTO_IP
114#define IPPROTO_IPV6 NET_IPPROTO_IPV6
115#define IPPROTO_ICMP NET_IPPROTO_ICMP
116#define IPPROTO_RAW NET_IPPROTO_RAW
117#define IPPROTO_TCP NET_IPPROTO_TCP
118#define IPPROTO_UDP NET_IPPROTO_UDP
121#define INADDR_ANY ((in_addr_t)NET_INADDR_ANY)
123#define INADDR_BROADCAST ((in_addr_t)NET_INADDR_BROADCAST)
124
126#define INET_ADDRSTRLEN NET_INET_ADDRSTRLEN
127
129#define htonl(x) net_htonl(x)
131#define htons(x) net_htons(x)
133#define ntohl(x) net_ntohl(x)
135#define ntohs(x) net_ntohs(x)
136
138#define INET6_ADDRSTRLEN NET_INET6_ADDRSTRLEN
139
140/* IPv6-level socket options (IPPROTO_IPV6). */
142#define IPV6_JOIN_GROUP ZSOCK_IPV6_JOIN_GROUP
144#define IPV6_LEAVE_GROUP ZSOCK_IPV6_LEAVE_GROUP
146#define IPV6_MULTICAST_HOPS ZSOCK_IPV6_MULTICAST_HOPS
148#define IPV6_MULTICAST_IF ZSOCK_IPV6_MULTICAST_IF
150#define IPV6_MULTICAST_LOOP ZSOCK_IPV6_MULTICAST_LOOP
152#define IPV6_UNICAST_HOPS ZSOCK_IPV6_UNICAST_HOPS
154#define IPV6_V6ONLY ZSOCK_IPV6_V6ONLY
155
156/* IPv6 address tests. Each takes a pointer to a struct in6_addr and evaluates non-zero on match. */
158#define IN6_IS_ADDR_UNSPECIFIED(addr) ZSOCK_IN6_IS_ADDR_UNSPECIFIED(addr)
160#define IN6_IS_ADDR_LOOPBACK(addr) ZSOCK_IN6_IS_ADDR_LOOPBACK(addr)
162#define IN6_IS_ADDR_MULTICAST(addr) ZSOCK_IN6_IS_ADDR_MULTICAST(addr)
164#define IN6_IS_ADDR_LINKLOCAL(addr) ZSOCK_IN6_IS_ADDR_LINKLOCAL(addr)
166#define IN6_IS_ADDR_SITELOCAL(addr) ZSOCK_IN6_IS_ADDR_SITELOCAL(addr)
168#define IN6_IS_ADDR_V4MAPPED(addr) ZSOCK_IN6_IS_ADDR_V4MAPPED(addr)
170#define IN6_IS_ADDR_MC_NODELOCAL(addr) ZSOCK_IN6_IS_ADDR_MC_NODELOCAL(addr)
172#define IN6_IS_ADDR_MC_LINKLOCAL(addr) ZSOCK_IN6_IS_ADDR_MC_LINKLOCAL(addr)
174#define IN6_IS_ADDR_MC_SITELOCAL(addr) ZSOCK_IN6_IS_ADDR_MC_SITELOCAL(addr)
176#define IN6_IS_ADDR_MC_ORGLOCAL(addr) ZSOCK_IN6_IS_ADDR_MC_ORGLOCAL(addr)
178#define IN6_IS_ADDR_MC_GLOBAL(addr) ZSOCK_IN6_IS_ADDR_MC_GLOBAL(addr)
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif /* ZEPHYR_INCLUDE_POSIX_NETINET_IN_H_ */
const struct in6_addr in6addr_loopback
IPv6 loopback address.
uint16_t in_port_t
Unsigned 16-bit Internet port number.
Definition in.h:36
uint32_t in_addr_t
Unsigned 32-bit IPv4 address.
Definition in.h:43
const struct in6_addr in6addr_any
IPv6 wildcard address.
IPv6 address.
Definition in.h:70
uint8_t s6_addr[16]
IPv6 address bytes in network byte order.
Definition in.h:71
IPv4 address.
Definition inet.h:47
in_addr_t s_addr
IPv4 address in network byte order.
Definition inet.h:48
IPv6 multicast group request.
Definition in.h:104
struct in6_addr ipv6mr_multiaddr
Multicast address.
Definition in.h:105
unsigned int ipv6mr_interface
Interface index.
Definition in.h:106
Socket address for IPv6.
Definition in.h:79
in_port_t sin6_port
Port number in network byte order.
Definition in.h:81
struct in6_addr sin6_addr
IPv6 address.
Definition in.h:82
uint32_t sin6_flowinfo
IPv6 flow information.
Definition in.h:85
uint32_t sin6_scope_id
Scope identifier.
Definition in.h:83
sa_family_t sin6_family
Address family; AF_INET6.
Definition in.h:80
Socket address for IPv4.
Definition in.h:59
struct in_addr sin_addr
IPv4 address.
Definition in.h:62
sa_family_t sin_family
Address family; AF_INET.
Definition in.h:60
in_port_t sin_port
Port number in network byte order.
Definition in.h:61