Loading...
Searching...
No Matches
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
34extern "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))
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)
207typedef uint16_t in_port_t;
208typedef uint32_t in_addr_t;
216
220struct in6_addr {
221 uint8_t s6_addr[16];
222};
223
233
248
256
260extern const struct in6_addr in6addr_any;
261
265extern const struct in6_addr in6addr_loopback;
266
267#ifdef __cplusplus
268}
269#endif
270
274#endif /* NETINET_IN_H */
System-internal byte operations.
unsigned short sa_family_t
address family type
Definition socket.h:121
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 in_addr_t
IPv4 address type.
Definition in.h:208
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:220
uint8_t s6_addr[16]
unsigned 8-bit integer array
Definition in.h:221
IPv4 address structure type.
Definition in.h:213
in_addr_t s_addr
an IPv4 address
Definition in.h:214
IPv6 multicast request.
Definition in.h:252
struct in6_addr ipv6mr_multiaddr
an IPv6 multicast address
Definition in.h:253
unsigned ipv6mr_interface
interface index, leave 0 for default
Definition in.h:254
IPv6 socket address type.
Definition in.h:238
in_port_t sin6_port
Port number.
Definition in.h:243
struct in6_addr sin6_addr
IPv6 address.
Definition in.h:245
uint32_t sin6_flowinfo
IPv6 traffic class and flow information.
Definition in.h:244
uint32_t sin6_scope_id
Set of interfaces for a scope.
Definition in.h:246
sa_family_t sin6_family
Protocol family, always AF_INET6.
Definition in.h:242
IPv4 socket address type.
Definition in.h:228
struct in_addr sin_addr
IPv4 address.
Definition in.h:231
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