The friendly Operating System for the Internet of Things
in.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013-15 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
23 #ifndef _NETINET_IN_H
24 #define _NETINET_IN_H
25 
26 #include <inttypes.h>
27 #include <sys/socket.h>
28 
29 #include "net/protnum.h"
30 #include "net/ipv6/addr.h"
31 #include "sys/bytes.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define INET_ADDRSTRLEN (16)
38 #define INET6_ADDRSTRLEN (46)
43 #define INADDR_ANY ((in_addr_t)0x00000000)
44 
48 #define INADDR_BROADCAST ((in_addr_t)0xffffffff)
49 
53 #define IN6ADDR_ANY_INIT IPV6_ADDR_UNSPECIFIED
54 
58 #define IN6ADDR_LOOPBACK_INIT IPV6_ADDR_LOOPBACK
59 
72 #define IN6_IS_ADDR_UNSPECIFIED(addr) ((int)(ipv6_addr_is_unspecified((const ipv6_addr_t *)(addr))))
73 
82 #define IN6_IS_ADDR_LOOPBACK(addr) ((int)(ipv6_addr_is_loopback((const ipv6_addr_t *)(addr))))
83 
92 #define IN6_IS_ADDR_MULTICAST(addr) ((int)(ipv6_addr_is_multicast((const ipv6_addr_t *)(addr))))
93 
102 #define IN6_IS_ADDR_LINKLOCAL(addr) ((int)(ipv6_addr_is_link_local((const ipv6_addr_t *)addr)))
103 
112 #define IN6_IS_ADDR_SITELOCAL(addr) ((int)(ipv6_addr_is_site_local((const ipv6_addr_t *)addr)))
113 
122 #define IN6_IS_ADDR_V4MAPPED(addr) ((int)(ipv6_addr_is_ipv4_mapped((const ipv6_addr_t *)addr)))
123 
132 #define IN6_IS_ADDR_V4COMPAT(addr) ((int)(ipv6_addr_is_ipv4_compat((const ipv6_addr_t *)addr)))
133 
142 #define IN6_IS_ADDR_MC_NODELOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
143  (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_IF_LOCAL))
144 
153 #define IN6_IS_ADDR_MC_LINKLOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
154  (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_LINK_LOCAL))
155 
164 #define IN6_IS_ADDR_MC_SITELOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
165  (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_SITE_LOCAL))
166 
175 #define IN6_IS_ADDR_MC_ORGLOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
176  (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_ORG_LOCAL))
177 
186 #define IN6_IS_ADDR_MC_GLOBAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
187  (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_GLOBAL))
188 
194 #define IPPROTO_IP (PROTNUM_IPV4)
195 #define IPPROTO_IPV6 (PROTNUM_IPV6)
196 #define IPPROTO_ICMP (PROTNUM_ICMP)
197 #define IPPROTO_ICMPV6 (PROTNUM_ICMPV6)
198 #define IPPROTO_RAW (PROTNUM_RESERVED)
199 #define IPPROTO_TCP (PROTNUM_TCP)
200 #define IPPROTO_UDP (PROTNUM_UDP)
207 typedef uint16_t in_port_t;
208 typedef uint32_t in_addr_t;
213 struct in_addr {
215 };
216 
220 struct in6_addr {
221  uint8_t s6_addr[16];
222 };
223 
228 struct sockaddr_in {
231  struct in_addr sin_addr;
232 };
233 
238 struct sockaddr_in6 {
244  uint32_t sin6_flowinfo;
246  uint32_t sin6_scope_id;
247 };
248 
252 struct ipv6_mreq {
254  unsigned ipv6mr_interface;
255 };
256 
260 extern const struct in6_addr in6addr_any;
261 
265 extern const struct in6_addr in6addr_loopback;
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 
274 #endif /* _NETINET_IN_H */
uint8_t s6_addr[16]
unsigned 8-bit integer array
Definition: in.h:221
struct in6_addr ipv6mr_multiaddr
an IPv6 multicast address
Definition: in.h:253
Protocol number definitions.
Definitions for IPv6 addresses.
const struct in6_addr in6addr_loopback
IPv6 socket address for the loopback address.
uint16_t in_port_t
Internet port type.
Definition: in.h:207
uint32_t sin6_flowinfo
IPv6 traffic class and flow information.
Definition: in.h:244
IPv4 socket address type.
Definition: in.h:228
sa_family_t sin_family
Protocol family, always AF_INET.
Definition: in.h:229
in_port_t sin_port
Port number.
Definition: in.h:230
uint32_t sin6_scope_id
Set of interfaces for a scope.
Definition: in.h:246
in_addr_t s_addr
an IPv4 address
Definition: in.h:214
IPv6 address structure type.
Definition: in.h:220
unsigned short sa_family_t
address family type
Definition: socket.h:120
unsigned ipv6mr_interface
interface index, leave 0 for default
Definition: in.h:254
IPv4 address structure type.
Definition: in.h:213
uint32_t in_addr_t
IPv4 address type.
Definition: in.h:208
Adds include for missing inttype definitions.
struct in_addr sin_addr
IPv4 address.
Definition: in.h:231
IPv6 multicast request.
Definition: in.h:252
System-internal byte operations.
const struct in6_addr in6addr_any
IPv6 socket address for the wildcard address.
IPv6 socket address type.
Definition: in.h:238
sa_family_t sin6_family
Protocol family, always AF_INET6.
Definition: in.h:242
Main socket header.
in_port_t sin6_port
Port number.
Definition: in.h:243
struct in6_addr sin6_addr
IPv6 address.
Definition: in.h:245