1 | /*
|
---|
2 | * Copyright (C) 2009 Robert Shearman
|
---|
3 | *
|
---|
4 | * This library is free software; you can redistribute it and/or
|
---|
5 | * modify it under the terms of the GNU Lesser General Public
|
---|
6 | * License as published by the Free Software Foundation; either
|
---|
7 | * version 2.1 of the License, or (at your option) any later version.
|
---|
8 | *
|
---|
9 | * This library is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
12 | * Lesser General Public License for more details.
|
---|
13 | *
|
---|
14 | * You should have received a copy of the GNU Lesser General Public
|
---|
15 | * License along with this library; if not, write to the Free Software
|
---|
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | /*
|
---|
20 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
21 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
22 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
23 | * a choice of LGPL license versions is made available with the language indicating
|
---|
24 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
25 | * of the LGPL is applied is otherwise unspecified.
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef __WS2IPDEF__
|
---|
29 | #define __WS2IPDEF__
|
---|
30 |
|
---|
31 | #include <in6addr.h>
|
---|
32 |
|
---|
33 | #ifdef USE_WS_PREFIX
|
---|
34 | #define WS(x) WS_##x
|
---|
35 | #else
|
---|
36 | #define WS(x) x
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | typedef struct WS(sockaddr_in6_old)
|
---|
40 | {
|
---|
41 | SHORT sin6_family;
|
---|
42 | USHORT sin6_port;
|
---|
43 | ULONG sin6_flowinfo;
|
---|
44 | IN6_ADDR sin6_addr;
|
---|
45 | } SOCKADDR_IN6_OLD,*PSOCKADDR_IN6_OLD, *LPSOCKADDR_IN6_OLD;
|
---|
46 |
|
---|
47 | typedef union sockaddr_gen
|
---|
48 | {
|
---|
49 | struct WS(sockaddr) Address;
|
---|
50 | struct WS(sockaddr_in) AddressIn;
|
---|
51 | struct WS(sockaddr_in6_old) AddressIn6;
|
---|
52 | } WS(sockaddr_gen);
|
---|
53 |
|
---|
54 | /* Structure to keep interface specific information */
|
---|
55 | typedef struct _INTERFACE_INFO
|
---|
56 | {
|
---|
57 | ULONG iiFlags; /* Interface flags */
|
---|
58 | WS(sockaddr_gen) iiAddress; /* Interface address */
|
---|
59 | WS(sockaddr_gen) iiBroadcastAddress; /* Broadcast address */
|
---|
60 | WS(sockaddr_gen) iiNetmask; /* Network mask */
|
---|
61 | } INTERFACE_INFO, * LPINTERFACE_INFO;
|
---|
62 |
|
---|
63 | /* Possible flags for the iiFlags - bitmask */
|
---|
64 | #ifndef USE_WS_PREFIX
|
---|
65 | #define IFF_UP 0x00000001 /* Interface is up */
|
---|
66 | #define IFF_BROADCAST 0x00000002 /* Broadcast is supported */
|
---|
67 | #define IFF_LOOPBACK 0x00000004 /* this is loopback interface */
|
---|
68 | #define IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
|
---|
69 | #define IFF_MULTICAST 0x00000010 /* multicast is supported */
|
---|
70 | #else
|
---|
71 | #define WS_IFF_UP 0x00000001 /* Interface is up */
|
---|
72 | #define WS_IFF_BROADCAST 0x00000002 /* Broadcast is supported */
|
---|
73 | #define WS_IFF_LOOPBACK 0x00000004 /* this is loopback interface */
|
---|
74 | #define WS_IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
|
---|
75 | #define WS_IFF_MULTICAST 0x00000010 /* multicast is supported */
|
---|
76 | #endif /* USE_WS_PREFIX */
|
---|
77 |
|
---|
78 | #ifndef USE_WS_PREFIX
|
---|
79 | #define IP_OPTIONS 1
|
---|
80 | #define IP_HDRINCL 2
|
---|
81 | #define IP_TOS 3
|
---|
82 | #define IP_TTL 4
|
---|
83 | #define IP_MULTICAST_IF 9
|
---|
84 | #define IP_MULTICAST_TTL 10
|
---|
85 | #define IP_MULTICAST_LOOP 11
|
---|
86 | #define IP_ADD_MEMBERSHIP 12
|
---|
87 | #define IP_DROP_MEMBERSHIP 13
|
---|
88 | #define IP_DONTFRAGMENT 14
|
---|
89 | #define IP_ADD_SOURCE_MEMBERSHIP 15
|
---|
90 | #define IP_DROP_SOURCE_MEMBERSHIP 16
|
---|
91 | #define IP_BLOCK_SOURCE 17
|
---|
92 | #define IP_UNBLOCK_SOURCE 18
|
---|
93 | #define IP_PKTINFO 19
|
---|
94 | #define IP_HOPLIMIT 21
|
---|
95 | #define IP_RECEIVE_BROADCAST 22
|
---|
96 | #define IP_RECVIF 24
|
---|
97 | #define IP_RECVDSTADDR 25
|
---|
98 | #define IP_IFLIST 28
|
---|
99 | #define IP_ADD_IFLIST 29
|
---|
100 | #define IP_DEL_IFLIST 30
|
---|
101 | #define IP_UNICAST_IF 31
|
---|
102 | #define IP_RTHDR 32
|
---|
103 | #define IP_RECVRTHDR 38
|
---|
104 | #else
|
---|
105 | #define WS_IP_OPTIONS 1
|
---|
106 | #define WS_IP_HDRINCL 2
|
---|
107 | #define WS_IP_TOS 3
|
---|
108 | #define WS_IP_TTL 4
|
---|
109 | #define WS_IP_MULTICAST_IF 9
|
---|
110 | #define WS_IP_MULTICAST_TTL 10
|
---|
111 | #define WS_IP_MULTICAST_LOOP 11
|
---|
112 | #define WS_IP_ADD_MEMBERSHIP 12
|
---|
113 | #define WS_IP_DROP_MEMBERSHIP 13
|
---|
114 | #define WS_IP_DONTFRAGMENT 14
|
---|
115 | #define WS_IP_ADD_SOURCE_MEMBERSHIP 15
|
---|
116 | #define WS_IP_DROP_SOURCE_MEMBERSHIP 16
|
---|
117 | #define WS_IP_BLOCK_SOURCE 17
|
---|
118 | #define WS_IP_UNBLOCK_SOURCE 18
|
---|
119 | #define WS_IP_PKTINFO 19
|
---|
120 | #define WS_IP_HOPLIMIT 21
|
---|
121 | #define WS_IP_RECEIVE_BROADCAST 22
|
---|
122 | #define WS_IP_RECVIF 24
|
---|
123 | #define WS_IP_RECVDSTADDR 25
|
---|
124 | #define WS_IP_IFLIST 28
|
---|
125 | #define WS_IP_ADD_IFLIST 29
|
---|
126 | #define WS_IP_DEL_IFLIST 30
|
---|
127 | #define WS_IP_UNICAST_IF 31
|
---|
128 | #define WS_IP_RTHDR 32
|
---|
129 | #define WS_IP_RECVRTHDR 38
|
---|
130 | #endif /* USE_WS_PREFIX */
|
---|
131 |
|
---|
132 | typedef struct WS(sockaddr_in6)
|
---|
133 | {
|
---|
134 | SHORT sin6_family;
|
---|
135 | USHORT sin6_port;
|
---|
136 | ULONG sin6_flowinfo;
|
---|
137 | IN6_ADDR sin6_addr;
|
---|
138 | ULONG sin6_scope_id;
|
---|
139 | } SOCKADDR_IN6,*PSOCKADDR_IN6, *LPSOCKADDR_IN6;
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * Multicast group information
|
---|
143 | */
|
---|
144 |
|
---|
145 | struct WS(ip_mreq)
|
---|
146 | {
|
---|
147 | struct WS(in_addr) imr_multiaddr;
|
---|
148 | struct WS(in_addr) imr_interface;
|
---|
149 | } WS(IP_MREQ), *WS(PIP_MREQ);
|
---|
150 |
|
---|
151 | struct WS(ip_mreq_source) {
|
---|
152 | struct WS(in_addr) imr_multiaddr;
|
---|
153 | struct WS(in_addr) imr_sourceaddr;
|
---|
154 | struct WS(in_addr) imr_interface;
|
---|
155 | } WS(IP_MREQ_SOURCE), *WS(PIP_MREQ_SOURCE);
|
---|
156 |
|
---|
157 | struct WS(ip_msfilter) {
|
---|
158 | struct WS(in_addr) imsf_multiaddr;
|
---|
159 | struct WS(in_addr) imsf_interface;
|
---|
160 | ULONG imsf_fmode;
|
---|
161 | ULONG imsf_numsrc;
|
---|
162 | struct WS(in_addr) imsf_slist[1];
|
---|
163 | } WS(IP_MSFILTER), *WS(PIP_MSFILTER);
|
---|
164 |
|
---|
165 | #ifndef USE_WS_PREFIX
|
---|
166 | #define IPV6_OPTIONS 1
|
---|
167 | #define IPV6_HDRINCL 2
|
---|
168 | #define IPV6_UNICAST_HOPS 4
|
---|
169 | #define IPV6_MULTICAST_IF 9
|
---|
170 | #define IPV6_MULTICAST_HOPS 10
|
---|
171 | #define IPV6_MULTICAST_LOOP 11
|
---|
172 | #define IPV6_ADD_MEMBERSHIP 12
|
---|
173 | #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
|
---|
174 | #define IPV6_DROP_MEMBERSHIP 13
|
---|
175 | #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
|
---|
176 | #define IPV6_DONTFRAG 14
|
---|
177 | #define IPV6_PKTINFO 19
|
---|
178 | #define IPV6_HOPLIMIT 21
|
---|
179 | #define IPV6_PROTECTION_LEVEL 23
|
---|
180 | #define IPV6_RECVIF 24
|
---|
181 | #define IPV6_RECVDSTADDR 25
|
---|
182 | #define IPV6_CHECKSUM 26
|
---|
183 | #define IPV6_V6ONLY 27
|
---|
184 | #define IPV6_IFLIST 28
|
---|
185 | #define IPV6_ADD_IFLIST 29
|
---|
186 | #define IPV6_DEL_IFLIST 30
|
---|
187 | #define IPV6_UNICAST_IF 31
|
---|
188 | #define IPV6_RTHDR 32
|
---|
189 | #define IPV6_RECVRTHDR 38
|
---|
190 | #else
|
---|
191 | #define WS_IPV6_OPTIONS 1
|
---|
192 | #define WS_IPV6_HDRINCL 2
|
---|
193 | #define WS_IPV6_UNICAST_HOPS 4
|
---|
194 | #define WS_IPV6_MULTICAST_IF 9
|
---|
195 | #define WS_IPV6_MULTICAST_HOPS 10
|
---|
196 | #define WS_IPV6_MULTICAST_LOOP 11
|
---|
197 | #define WS_IPV6_ADD_MEMBERSHIP 12
|
---|
198 | #define WS_IPV6_DROP_MEMBERSHIP 13
|
---|
199 | #define WS_IPV6_LEAVE_GROUP WS_IPV6_DROP_MEMBERSHIP
|
---|
200 | #define WS_IPV6_DONTFRAG 14
|
---|
201 | #define WS_IPV6_PKTINFO 19
|
---|
202 | #define WS_IPV6_HOPLIMIT 21
|
---|
203 | #define WS_IPV6_PROTECTION_LEVEL 23
|
---|
204 | #define WS_IPV6_RECVIF 24
|
---|
205 | #define WS_IPV6_RECVDSTADDR 25
|
---|
206 | #define WS_IPV6_CHECKSUM 26
|
---|
207 | #define WS_IPV6_V6ONLY 27
|
---|
208 | #define WS_IPV6_IFLIST 28
|
---|
209 | #define WS_IPV6_ADD_IFLIST 29
|
---|
210 | #define WS_IPV6_DEL_IFLIST 30
|
---|
211 | #define WS_IPV6_UNICAST_IF 31
|
---|
212 | #define WS_IPV6_RTHDR 32
|
---|
213 | #define WS_IPV6_RECVRTHDR 38
|
---|
214 | #endif /* USE_WS_PREFIX */
|
---|
215 |
|
---|
216 | #ifndef USE_WS_PREFIX
|
---|
217 | #define TCP_OFFLOAD_NO_PREFERENCE 0
|
---|
218 | #define TCP_OFFLOAD_NOT_PREFERRED 1
|
---|
219 | #define TCP_OFFLOAD_PREFERRED 2
|
---|
220 | #else
|
---|
221 | #define WS_TCP_OFFLOAD_NO_PREFERENCE 0
|
---|
222 | #define WS_TCP_OFFLOAD_NOT_PREFERRED 1
|
---|
223 | #define WS_TCP_OFFLOAD_PREFERRED 2
|
---|
224 | #endif /* USE_WS_PREFIX */
|
---|
225 |
|
---|
226 | #ifndef USE_WS_PREFIX
|
---|
227 | /* TCP_NODELAY is defined elsewhere */
|
---|
228 | #define TCP_EXPEDITED_1122 2
|
---|
229 | #define TCP_KEEPALIVE 3
|
---|
230 | #define TCP_MAXSEG 4
|
---|
231 | #define TCP_MAXRT 5
|
---|
232 | #define TCP_STDURG 6
|
---|
233 | #define TCP_NOURG 7
|
---|
234 | #define TCP_ATMARK 8
|
---|
235 | #define TCP_NOSYNRETRIES 9
|
---|
236 | #define TCP_TIMESTAMPS 10
|
---|
237 | #define TCP_OFFLOAD_PREFERENCE 11
|
---|
238 | #define TCP_CONGESTION_ALGORITHM 12
|
---|
239 | #define TCP_DELAY_FIN_ACK 13
|
---|
240 | #else
|
---|
241 | /* WS_TCP_NODELAY is defined elsewhere */
|
---|
242 | #define WS_TCP_EXPEDITED_1122 2
|
---|
243 | #define WS_TCP_KEEPALIVE 3
|
---|
244 | #define WS_TCP_MAXSEG 4
|
---|
245 | #define WS_TCP_MAXRT 5
|
---|
246 | #define WS_TCP_STDURG 6
|
---|
247 | #define WS_TCP_NOURG 7
|
---|
248 | #define WS_TCP_ATMARK 8
|
---|
249 | #define WS_TCP_NOSYNRETRIES 9
|
---|
250 | #define WS_TCP_TIMESTAMPS 10
|
---|
251 | #define WS_TCP_OFFLOAD_PREFERENCE 11
|
---|
252 | #define WS_TCP_CONGESTION_ALGORITHM 12
|
---|
253 | #define WS_TCP_DELAY_FIN_ACK 13
|
---|
254 | #endif /* USE_WS_PREFIX */
|
---|
255 |
|
---|
256 | #ifndef USE_WS_PREFIX
|
---|
257 | #define INET_ADDRSTRLEN 22
|
---|
258 | #define INET6_ADDRSTRLEN 65
|
---|
259 | #define IN6ADDR_ANY_INIT { 0 }
|
---|
260 | #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
|
---|
261 | #else
|
---|
262 | #define WS_INET_ADDRSTRLEN 22
|
---|
263 | #define WS_INET6_ADDRSTRLEN 65
|
---|
264 | #define WS_IN6ADDR_ANY_INIT { 0 }
|
---|
265 | #define WS_IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
|
---|
266 | #endif /* USE_WS_PREFIX */
|
---|
267 |
|
---|
268 | static inline BOOL WS(IN6_IS_ADDR_LOOPBACK) ( const IN6_ADDR *a )
|
---|
269 | {
|
---|
270 | return (BOOL)((a->s6_words[0] == 0) &&
|
---|
271 | (a->s6_words[1] == 0) &&
|
---|
272 | (a->s6_words[2] == 0) &&
|
---|
273 | (a->s6_words[3] == 0) &&
|
---|
274 | (a->s6_words[4] == 0) &&
|
---|
275 | (a->s6_words[5] == 0) &&
|
---|
276 | (a->s6_words[6] == 0) &&
|
---|
277 | (a->s6_words[7] == 0x0100));
|
---|
278 | }
|
---|
279 |
|
---|
280 | #endif /* __WS2IPDEF__ */
|
---|