VSF Documented
in.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_NETINET_IN_H__
2#define __VSF_LINUX_NETINET_IN_H__
3
5
6#if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED
7# include "../sys/types.h"
8# include "../sys/socket.h"
9#else
10# include <sys/types.h>
11# include <sys/socket.h>
12#endif
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18// fixme: in_port_t and in_addr_t should be in inttypes.h
21
22enum {
24#define IPPROTO_IP IPPROTO_IP
26#define IPPROTO_ICMP IPPROTO_ICMP
28#define IPPROTO_IGMP IPPROTO_IGMP
30#define IPPROTO_TCP IPPROTO_TCP
32#define IPPROTO_UDP IPPROTO_UDP
34#define IPPROTO_IPV6 IPPROTO_IPV6
36#define IPPROTO_RAW IPPROTO_RAW
37};
38
39#define INADDR_ANY (in_addr_t)0x00000000
40#define INADDR_NONE (in_addr_t)0xFFFFFFFF
41#define INADDR_BROADCAST (in_addr_t)0xFFFFFFFF
42#define INADDR_LOOPBACK (in_addr_t)0x7F000001
43
44#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
45#define IN_CLASSA_NET 0xff000000
46#define IN_CLASSA_NSHIFT 24
47#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
48#define IN_CLASSA_MAX 128
49
50#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
51#define IN_CLASSB_NET 0xffff0000
52#define IN_CLASSB_NSHIFT 16
53#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
54#define IN_CLASSB_MAX 65536
55
56#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000)
57#define IN_CLASSC_NET 0xffffff00
58#define IN_CLASSC_NSHIFT 8
59#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
60
61#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
62#define IN_MULTICAST(a) IN_CLASSD(a)
63#define IN_MULTICAST_NET 0xe0000000
64
65#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
66
67#define IN6_IS_ADDR_MC_NODELOCAL(a) \
68 (IN6_IS_ADDR_MULTICAST(a) \
69 && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
70#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
71 (IN6_IS_ADDR_MULTICAST(a) \
72 && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
73#define IN6_IS_ADDR_MC_SITELOCAL(a) \
74 (IN6_IS_ADDR_MULTICAST(a) \
75 && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
76#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
77 (IN6_IS_ADDR_MULTICAST(a) \
78 && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
79#define IN6_IS_ADDR_MC_GLOBAL(a) \
80 (IN6_IS_ADDR_MULTICAST(a) \
81 && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
82
83#define IN6_IS_ADDR_UNSPECIFIED(a) \
84 (((const uint32_t *) (a))[0] == 0 \
85 && ((const uint32_t *) (a))[1] == 0 \
86 && ((const uint32_t *) (a))[2] == 0 \
87 && ((const uint32_t *) (a))[3] == 0)
88#define IN6_IS_ADDR_LOOPBACK(a) \
89 (((const uint32_t *) (a))[0] == 0 \
90 && ((const uint32_t *) (a))[1] == 0 \
91 && ((const uint32_t *) (a))[2] == 0 \
92 && ((const uint32_t *) (a))[3] == htonl (1))
93#define IN6_IS_ADDR_LINKLOCAL(a) \
94 ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
95 == htonl (0xfe800000))
96#define IN6_IS_ADDR_SITELOCAL(a) \
97 ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
98 == htonl (0xfec00000))
99#define IN6_IS_ADDR_V4MAPPED(a) \
100 ((((const uint32_t *) (a))[0] == 0) \
101 && (((const uint32_t *) (a))[1] == 0) \
102 && (((const uint32_t *) (a))[2] == htonl (0xffff)))
103#define IN6_IS_ADDR_V4COMPAT(a) \
104 ((((const uint32_t *) (a))[0] == 0) \
105 && (((const uint32_t *) (a))[1] == 0) \
106 && (((const uint32_t *) (a))[2] == 0) \
107 && (ntohl (((const uint32_t *) (a))[3]) > 1))
108#define IN6_ARE_ADDR_EQUAL(a,b) \
109 ((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0]) \
110 && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1]) \
111 && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2]) \
112 && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
113
114#define INET_ADDRSTRLEN 16
115struct in_addr {
117};
122#define SIN_ZERO_LEN 8
124};
125
126struct ip_mreq {
129};
130
131#define INET6_ADDRSTRLEN 46
132#define IN6ADDR_ANY_INIT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
133#define IN6ADDR_LOOPBACK_INIT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
134extern const struct in6_addr in6addr_any;
135extern const struct in6_addr in6addr_loopback;
136struct in6_addr {
138};
145};
146
147struct ipv6_mreq {
149 unsigned int ipv6mr_interface;
150};
151
152#if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED
153# include "../arpa/inet.h"
154#else
155# include <arpa/inet.h>
156#endif
157
158#ifdef __cplusplus
159}
160#endif
161#endif
#define IPPROTO_RAW
Definition in.h:36
#define IPPROTO_IPV6
Definition in.h:34
#define IPPROTO_IGMP
Definition in.h:28
const struct in6_addr in6addr_loopback
Definition vsf_linux_socket.c:72
#define SIN_ZERO_LEN
Definition in.h:122
#define IPPROTO_TCP
Definition in.h:30
uint16_t in_port_t
Definition in.h:19
uint32_t in_addr_t
Definition in.h:20
#define IPPROTO_ICMP
Definition in.h:26
#define IPPROTO_UDP
Definition in.h:32
#define IPPROTO_IP
Definition in.h:24
const struct in6_addr in6addr_any
Definition vsf_linux_socket.c:70
uint16_t sa_family_t
Definition socket.h:71
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition in.h:136
uint8_t s6_addr[16]
Definition in.h:137
Definition in.h:115
in_addr_t s_addr
Definition in.h:116
Definition in.h:126
struct in_addr imr_interface
Definition in.h:128
struct in_addr imr_multiaddr
Definition in.h:127
Definition in.h:147
struct in6_addr ipv6mr_multiaddr
Definition in.h:148
unsigned int ipv6mr_interface
Definition in.h:149
Definition in.h:139
in_port_t sin6_port
Definition in.h:141
struct in6_addr sin6_addr
Definition in.h:143
uint32_t sin6_flowinfo
Definition in.h:142
uint32_t sin6_scope_id
Definition in.h:144
sa_family_t sin6_family
Definition in.h:140
Definition in.h:118
struct in_addr sin_addr
Definition in.h:121
char sin_zero[SIN_ZERO_LEN]
Definition in.h:123
sa_family_t sin_family
Definition in.h:119
in_port_t sin_port
Definition in.h:120