Loading...
Searching...
No Matches
in.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2013-2015 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
12
22
23#include <inttypes.h>
24#include <sys/socket.h>
25
26#include "net/protnum.h"
27#include "net/ipv6/addr.h"
28#include "sys/bytes.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#define INET_ADDRSTRLEN (16)
35#define INET6_ADDRSTRLEN (46)
36
40#define INADDR_ANY ((in_addr_t)0x00000000)
41
45#define INADDR_BROADCAST ((in_addr_t)0xffffffff)
46
50#define IN6ADDR_ANY_INIT IPV6_ADDR_UNSPECIFIED
51
55#define IN6ADDR_LOOPBACK_INIT IPV6_ADDR_LOOPBACK
56
69#define IN6_IS_ADDR_UNSPECIFIED(addr) ((int)(ipv6_addr_is_unspecified((const ipv6_addr_t *)(addr))))
70
79#define IN6_IS_ADDR_LOOPBACK(addr) ((int)(ipv6_addr_is_loopback((const ipv6_addr_t *)(addr))))
80
89#define IN6_IS_ADDR_MULTICAST(addr) ((int)(ipv6_addr_is_multicast((const ipv6_addr_t *)(addr))))
90
99#define IN6_IS_ADDR_LINKLOCAL(addr) ((int)(ipv6_addr_is_link_local((const ipv6_addr_t *)addr)))
100
109#define IN6_IS_ADDR_SITELOCAL(addr) ((int)(ipv6_addr_is_site_local((const ipv6_addr_t *)addr)))
110
119#define IN6_IS_ADDR_V4MAPPED(addr) ((int)(ipv6_addr_is_ipv4_mapped((const ipv6_addr_t *)addr)))
120
129#define IN6_IS_ADDR_V4COMPAT(addr) ((int)(ipv6_addr_is_ipv4_compat((const ipv6_addr_t *)addr)))
130
139#define IN6_IS_ADDR_MC_NODELOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
140 (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_IF_LOCAL))
141
150#define IN6_IS_ADDR_MC_LINKLOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
151 (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_LINK_LOCAL))
152
161#define IN6_IS_ADDR_MC_SITELOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
162 (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_SITE_LOCAL))
163
172#define IN6_IS_ADDR_MC_ORGLOCAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
173 (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_ORG_LOCAL))
174
183#define IN6_IS_ADDR_MC_GLOBAL(addr) (IN6_IS_ADDR_MULTICAST(addr) && \
184 (int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_GLOBAL))
185
186
191#define IPPROTO_IP (PROTNUM_IPV4)
192#define IPPROTO_IPV6 (PROTNUM_IPV6)
193#define IPPROTO_ICMP (PROTNUM_ICMP)
194#define IPPROTO_ICMPV6 (PROTNUM_ICMPV6)
195#define IPPROTO_RAW (PROTNUM_RESERVED)
196#define IPPROTO_TCP (PROTNUM_TCP)
197#define IPPROTO_UDP (PROTNUM_UDP)
199
203
204typedef uint16_t in_port_t;
205typedef uint32_t in_addr_t;
206
213
217struct in6_addr {
218 uint8_t s6_addr[16];
219};
220
230
245
253
257extern const struct in6_addr in6addr_any;
258
262extern const struct in6_addr in6addr_loopback;
263
264#ifdef __cplusplus
265}
266#endif
267
System-internal byte operations.
unsigned short sa_family_t
address family type
Definition socket.h:118
const struct in6_addr in6addr_loopback
IPv6 socket address for the loopback address.
uint16_t in_port_t
Internet port type.
Definition in.h:204
uint32_t in_addr_t
IPv4 address type.
Definition in.h:205
const struct in6_addr in6addr_any
IPv6 socket address for the wildcard address.
Adds include for missing inttype definitions.
Definitions for IPv6 addresses.
Protocol number definitions.
Main socket header.
IPv6 address structure type.
Definition in.h:217
uint8_t s6_addr[16]
unsigned 8-bit integer array
Definition in.h:218
IPv4 address structure type.
Definition in.h:210
in_addr_t s_addr
an IPv4 address
Definition in.h:211
IPv6 multicast request.
Definition in.h:249
struct in6_addr ipv6mr_multiaddr
an IPv6 multicast address
Definition in.h:250
unsigned ipv6mr_interface
interface index, leave 0 for default
Definition in.h:251
IPv6 socket address type.
Definition in.h:235
in_port_t sin6_port
Port number.
Definition in.h:240
struct in6_addr sin6_addr
IPv6 address.
Definition in.h:242
uint32_t sin6_flowinfo
IPv6 traffic class and flow information.
Definition in.h:241
uint32_t sin6_scope_id
Set of interfaces for a scope.
Definition in.h:243
sa_family_t sin6_family
Protocol family, always AF_INET6.
Definition in.h:239
IPv4 socket address type.
Definition in.h:225
struct in_addr sin_addr
IPv4 address.
Definition in.h:228
sa_family_t sin_family
Protocol family, always AF_INET.
Definition in.h:226
in_port_t sin_port
Port number.
Definition in.h:227