2 * Copyright (C) 2009 Robert Shearman
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.
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.
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
30 typedef struct WS(sockaddr_in6_old
)
36 } SOCKADDR_IN6_OLD
,*PSOCKADDR_IN6_OLD
, *LPSOCKADDR_IN6_OLD
;
38 typedef union sockaddr_gen
40 struct WS(sockaddr
) Address
;
41 struct WS(sockaddr_in
) AddressIn
;
42 struct WS(sockaddr_in6_old
) AddressIn6
;
45 /* Structure to keep interface specific information */
46 typedef struct _INTERFACE_INFO
48 ULONG iiFlags
; /* Interface flags */
49 WS(sockaddr_gen
) iiAddress
; /* Interface address */
50 WS(sockaddr_gen
) iiBroadcastAddress
; /* Broadcast address */
51 WS(sockaddr_gen
) iiNetmask
; /* Network mask */
52 } INTERFACE_INFO
, * LPINTERFACE_INFO
;
54 /* Possible flags for the iiFlags - bitmask */
56 #define IFF_UP 0x00000001 /* Interface is up */
57 #define IFF_BROADCAST 0x00000002 /* Broadcast is supported */
58 #define IFF_LOOPBACK 0x00000004 /* this is loopback interface */
59 #define IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
60 #define IFF_MULTICAST 0x00000010 /* multicast is supported */
62 #define WS_IFF_UP 0x00000001 /* Interface is up */
63 #define WS_IFF_BROADCAST 0x00000002 /* Broadcast is supported */
64 #define WS_IFF_LOOPBACK 0x00000004 /* this is loopback interface */
65 #define WS_IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
66 #define WS_IFF_MULTICAST 0x00000010 /* multicast is supported */
67 #endif /* USE_WS_PREFIX */
74 #define IP_MULTICAST_IF 9
75 #define IP_MULTICAST_TTL 10
76 #define IP_MULTICAST_LOOP 11
77 #define IP_ADD_MEMBERSHIP 12
78 #define IP_DROP_MEMBERSHIP 13
79 #define IP_DONTFRAGMENT 14
80 #define IP_ADD_SOURCE_MEMBERSHIP 15
81 #define IP_DROP_SOURCE_MEMBERSHIP 16
82 #define IP_BLOCK_SOURCE 17
83 #define IP_UNBLOCK_SOURCE 18
85 #define IP_HOPLIMIT 21
87 #define IP_RECEIVE_BROADCAST 22
89 #define IP_RECVDSTADDR 25
91 #define IP_ADD_IFLIST 29
92 #define IP_DEL_IFLIST 30
93 #define IP_UNICAST_IF 31
95 #define IP_GET_IFLIST 33
96 #define IP_RECVRTHDR 38
98 #define IP_RECVTCLASS 40
100 #define IP_ORIGINAL_ARRIVAL_IF 47
102 #define IP_PKTINFO_EX 51
103 #define IP_WFP_REDIRECT_RECORDS 60
104 #define IP_WFP_REDIRECT_CONTEXT 70
105 #define IP_MTU_DISCOVER 71
107 #define IP_NRT_INTERFACE 74
108 #define IP_RECVERR 75
109 #define IP_USER_MTU 76
111 #define WS_IP_OPTIONS 1
112 #define WS_IP_HDRINCL 2
115 #define WS_IP_MULTICAST_IF 9
116 #define WS_IP_MULTICAST_TTL 10
117 #define WS_IP_MULTICAST_LOOP 11
118 #define WS_IP_ADD_MEMBERSHIP 12
119 #define WS_IP_DROP_MEMBERSHIP 13
120 #define WS_IP_DONTFRAGMENT 14
121 #define WS_IP_ADD_SOURCE_MEMBERSHIP 15
122 #define WS_IP_DROP_SOURCE_MEMBERSHIP 16
123 #define WS_IP_BLOCK_SOURCE 17
124 #define WS_IP_UNBLOCK_SOURCE 18
125 #define WS_IP_PKTINFO 19
126 #define WS_IP_HOPLIMIT 21
127 #define WS_IP_RECVTTL 21
128 #define WS_IP_RECEIVE_BROADCAST 22
129 #define WS_IP_RECVIF 24
130 #define WS_IP_RECVDSTADDR 25
131 #define WS_IP_IFLIST 28
132 #define WS_IP_ADD_IFLIST 29
133 #define WS_IP_DEL_IFLIST 30
134 #define WS_IP_UNICAST_IF 31
135 #define WS_IP_RTHDR 32
136 #define WS_IP_GET_IFLIST 33
137 #define WS_IP_RECVRTHDR 38
138 #define WS_IP_TCLASS 39
139 #define WS_IP_RECVTCLASS 40
140 #define WS_IP_RECVTOS 40
141 #define WS_IP_ORIGINAL_ARRIVAL_IF 47
143 #define WS_IP_PKTINFO_EX 51
144 #define WS_IP_WFP_REDIRECT_RECORDS 60
145 #define WS_IP_WFP_REDIRECT_CONTEXT 70
146 #define WS_IP_MTU_DISCOVER 71
148 #define WS_IP_NRT_INTERFACE 74
149 #define WS_IP_RECVERR 75
150 #define WS_IP_USER_MTU 76
151 #endif /* USE_WS_PREFIX */
153 typedef struct WS(sockaddr_in6
)
160 } SOCKADDR_IN6
,*PSOCKADDR_IN6
, *LPSOCKADDR_IN6
;
162 typedef struct WS(sockaddr_in6_pair
)
164 PSOCKADDR_IN6 SourceAddress
;
165 PSOCKADDR_IN6 DestinationAddress
;
166 } SOCKADDR_IN6_PAIR
, *PSOCKADDR_IN6_PAIR
;
168 typedef union _SOCKADDR_INET
172 ADDRESS_FAMILY si_family
;
173 } SOCKADDR_INET
, *PSOCKADDR_INET
;
176 * Multicast group information
179 typedef struct WS(ip_mreq
)
181 struct WS(in_addr
) imr_multiaddr
;
182 struct WS(in_addr
) imr_interface
;
183 } WS(IP_MREQ
), *WS(PIP_MREQ
);
185 typedef struct WS(ipv6_mreq
)
187 struct WS(in6_addr
) ipv6mr_multiaddr
;
188 unsigned int ipv6mr_interface
;
189 } WS(IPV6_MREQ
), *WS(PIPV6_MREQ
);
191 typedef struct WS(ip_mreq_source
) {
192 struct WS(in_addr
) imr_multiaddr
;
193 struct WS(in_addr
) imr_sourceaddr
;
194 struct WS(in_addr
) imr_interface
;
195 } WS(IP_MREQ_SOURCE
), *WS(PIP_MREQ_SOURCE
);
197 typedef struct WS(ip_msfilter
) {
198 struct WS(in_addr
) imsf_multiaddr
;
199 struct WS(in_addr
) imsf_interface
;
202 struct WS(in_addr
) imsf_slist
[1];
203 } WS(IP_MSFILTER
), *WS(PIP_MSFILTER
);
205 typedef struct WS(in_pktinfo
) {
208 } IN_PKTINFO
, *PIN_PKTINFO
;
210 typedef struct WS(in6_pktinfo
) {
213 } IN6_PKTINFO
, *PIN6_PKTINFO
;
215 #ifndef USE_WS_PREFIX
216 #define IPV6_OPTIONS 1
217 #define IPV6_HOPOPTS 1
218 #define IPV6_HDRINCL 2
219 #define IPV6_UNICAST_HOPS 4
220 #define IPV6_MULTICAST_IF 9
221 #define IPV6_MULTICAST_HOPS 10
222 #define IPV6_MULTICAST_LOOP 11
223 #define IPV6_ADD_MEMBERSHIP 12
224 #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
225 #define IPV6_DROP_MEMBERSHIP 13
226 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
227 #define IPV6_DONTFRAG 14
228 #define IPV6_PKTINFO 19
229 #define IPV6_HOPLIMIT 21
230 #define IPV6_PROTECTION_LEVEL 23
231 #define IPV6_RECVIF 24
232 #define IPV6_RECVDSTADDR 25
233 #define IPV6_CHECKSUM 26
234 #define IPV6_V6ONLY 27
235 #define IPV6_IFLIST 28
236 #define IPV6_ADD_IFLIST 29
237 #define IPV6_DEL_IFLIST 30
238 #define IPV6_UNICAST_IF 31
239 #define IPV6_RTHDR 32
240 #define IPV6_GET_IFLIST 33
241 #define IPV6_RECVRTHDR 38
242 #define IPV6_TCLASS 39
243 #define IPV6_RECVTCLASS 40
245 #define IPV6_PKTINFO_EX 51
246 #define IPV6_WFP_REDIRECT_RECORDS 60
247 #define IPV6_WFP_REDIRECT_CONTEXT 70
248 #define IPV6_MTU_DISCOVER 71
250 #define IPV6_NRT_INTERFACE 74
251 #define IPV6_RECVERR 75
252 #define IPV6_USER_MTU 76
254 #define WS_IPV6_OPTIONS 1
255 #define WS_IPV6_HOPOPTS 1
256 #define WS_IPV6_HDRINCL 2
257 #define WS_IPV6_UNICAST_HOPS 4
258 #define WS_IPV6_MULTICAST_IF 9
259 #define WS_IPV6_MULTICAST_HOPS 10
260 #define WS_IPV6_MULTICAST_LOOP 11
261 #define WS_IPV6_ADD_MEMBERSHIP 12
262 #define WS_IPV6_DROP_MEMBERSHIP 13
263 #define WS_IPV6_LEAVE_GROUP WS_IPV6_DROP_MEMBERSHIP
264 #define WS_IPV6_DONTFRAG 14
265 #define WS_IPV6_PKTINFO 19
266 #define WS_IPV6_HOPLIMIT 21
267 #define WS_IPV6_PROTECTION_LEVEL 23
268 #define WS_IPV6_RECVIF 24
269 #define WS_IPV6_RECVDSTADDR 25
270 #define WS_IPV6_CHECKSUM 26
271 #define WS_IPV6_V6ONLY 27
272 #define WS_IPV6_IFLIST 28
273 #define WS_IPV6_ADD_IFLIST 29
274 #define WS_IPV6_DEL_IFLIST 30
275 #define WS_IPV6_UNICAST_IF 31
276 #define WS_IPV6_RTHDR 32
277 #define WS_IPV6_GET_IFLIST 33
278 #define WS_IPV6_RECVRTHDR 38
279 #define WS_IPV6_TCLASS 39
280 #define WS_IPV6_RECVTCLASS 40
281 #define WS_IPV6_ECN 50
282 #define WS_IPV6_PKTINFO_EX 51
283 #define WS_IPV6_WFP_REDIRECT_RECORDS 60
284 #define WS_IPV6_WFP_REDIRECT_CONTEXT 70
285 #define WS_IPV6_MTU_DISCOVER 71
286 #define WS_IPV6_MTU 72
287 #define WS_IPV6_NRT_INTERFACE 74
288 #define WS_IPV6_RECVERR 75
289 #define WS_IPV6_USER_MTU 76
290 #endif /* USE_WS_PREFIX */
292 #ifndef USE_WS_PREFIX
293 #define TCP_OFFLOAD_NO_PREFERENCE 0
294 #define TCP_OFFLOAD_NOT_PREFERRED 1
295 #define TCP_OFFLOAD_PREFERRED 2
297 #define WS_TCP_OFFLOAD_NO_PREFERENCE 0
298 #define WS_TCP_OFFLOAD_NOT_PREFERRED 1
299 #define WS_TCP_OFFLOAD_PREFERRED 2
300 #endif /* USE_WS_PREFIX */
302 #ifndef USE_WS_PREFIX
303 /* TCP_NODELAY is defined elsewhere */
304 #define TCP_EXPEDITED_1122 2
305 #define TCP_KEEPALIVE 3
311 #define TCP_NOSYNRETRIES 9
312 #define TCP_TIMESTAMPS 10
313 #define TCP_OFFLOAD_PREFERENCE 11
314 #define TCP_CONGESTION_ALGORITHM 12
315 #define TCP_DELAY_FIN_ACK 13
316 #define TCP_KEEPCNT 16
317 #define TCP_KEEPINTVL 17
319 /* WS_TCP_NODELAY is defined elsewhere */
320 #define WS_TCP_EXPEDITED_1122 2
321 #define WS_TCP_KEEPALIVE 3
322 #define WS_TCP_MAXSEG 4
323 #define WS_TCP_MAXRT 5
324 #define WS_TCP_STDURG 6
325 #define WS_TCP_NOURG 7
326 #define WS_TCP_ATMARK 8
327 #define WS_TCP_NOSYNRETRIES 9
328 #define WS_TCP_TIMESTAMPS 10
329 #define WS_TCP_OFFLOAD_PREFERENCE 11
330 #define WS_TCP_CONGESTION_ALGORITHM 12
331 #define WS_TCP_DELAY_FIN_ACK 13
332 #define WS_TCP_KEEPCNT 16
333 #define WS_TCP_KEEPINTVL 17
334 #endif /* USE_WS_PREFIX */
336 #define PROTECTION_LEVEL_UNRESTRICTED 10
337 #define PROTECTION_LEVEL_EDGERESTRICTED 20
338 #define PROTECTION_LEVEL_RESTRICTED 30
339 #define PROTECTION_LEVEL_DEFAULT ((UINT)-1)
341 #ifndef USE_WS_PREFIX
342 #define INET_ADDRSTRLEN 22
343 #define INET6_ADDRSTRLEN 65
344 #define IN6ADDR_6BONETESTPREFIX_INIT { 0x3f,0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
345 #define IN6ADDR_6TO4PREFIX_INIT { 0x20,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
346 #define IN6ADDR_ALLMLDV2ROUTERSONLINK_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 }
347 #define IN6ADDR_ALLNODESONLINK_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
348 #define IN6ADDR_ALLNODESONNODE_INIT { 0xff,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
349 #define IN6ADDR_ALLROUTERSONLINK_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 }
350 #define IN6ADDR_ANY_INIT { 0 }
351 #define IN6ADDR_LINKLOCALPREFIX_INIT { 0xfe,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
352 #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
353 #define IN6ADDR_MULTICASTPREFIX_INIT { 0xff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
354 #define IN6ADDR_SITELOCALPREFIX_INIT { 0xfe,0xc0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
355 #define IN6ADDR_SOLICITEDNODEMULTICASTPREFIX_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0x01,0xff,0,0,0 }
356 #define IN6ADDR_TEREDOINITIALLINKLOCALADDRESS_INIT { 0xfe,0x80,0,0,0,0,0,0,0,0,0xff,0xff,0xff,0xff,0xff,0xfe }
357 #define IN6ADDR_TEREDOPREFIX_INIT { 0x20,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
358 #define IN6ADDR_TEREDOPREFIX_INIT_OLD { 0x3f,0xfe,0x83,0x1f,0,0,0,0,0,0,0,0,0,0,0,0 }
359 #define IN6ADDR_ULAPREFIX_INIT { 0xfc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
360 #define IN6ADDR_V4MAPPEDPREFIX_INIT { 0,0,0,0,0,0,0,0,0,0,0xff,0xff,0,0,0,0 }
362 #define WS_INET_ADDRSTRLEN 22
363 #define WS_INET6_ADDRSTRLEN 65
364 #define WS_IN6ADDR_6BONETESTPREFIX_INIT { 0x3f,0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
365 #define WS_IN6ADDR_6TO4PREFIX_INIT { 0x20,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
366 #define WS_IN6ADDR_ALLMLDV2ROUTERSONLINK_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 }
367 #define WS_IN6ADDR_ALLNODESONLINK_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
368 #define WS_IN6ADDR_ALLNODESONNODE_INIT { 0xff,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
369 #define WS_IN6ADDR_ALLROUTERSONLINK_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 }
370 #define WS_IN6ADDR_ANY_INIT { 0 }
371 #define WS_IN6ADDR_LINKLOCALPREFIX_INIT { 0xfe,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
372 #define WS_IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
373 #define WS_IN6ADDR_MULTICASTPREFIX_INIT { 0xff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
374 #define WS_IN6ADDR_SITELOCALPREFIX_INIT { 0xfe,0xc0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
375 #define WS_IN6ADDR_SOLICITEDNODEMULTICASTPREFIX_INIT { 0xff,2,0,0,0,0,0,0,0,0,0,0x01,0xff,0,0,0 }
376 #define WS_IN6ADDR_TEREDOINITIALLINKLOCALADDRESS_INIT { 0xfe,0x80,0,0,0,0,0,0,0,0,0xff,0xff,0xff,0xff,0xff,0xfe }
377 #define WS_IN6ADDR_TEREDOPREFIX_INIT { 0x20,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
378 #define WS_IN6ADDR_TEREDOPREFIX_INIT_OLD { 0x3f,0xfe,0x83,0x1f,0,0,0,0,0,0,0,0,0,0,0,0 }
379 #define WS_IN6ADDR_ULAPREFIX_INIT { 0xfc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
380 #define WS_IN6ADDR_V4MAPPEDPREFIX_INIT { 0,0,0,0,0,0,0,0,0,0,0xff,0xff,0,0,0,0 }
381 #endif /* USE_WS_PREFIX */
383 #define SS_PORT(ssp) (((PSOCKADDR_IN)(ssp))->sin_port)
385 #ifndef USE_WS_PREFIX
386 #define SIO_IDEAL_SEND_BACKLOG_CHANGE _IO ('t', 122)
387 #define SIO_IDEAL_SEND_BACKLOG_QUERY _IOR('t', 123, ULONG)
389 #define WS_SIO_IDEAL_SEND_BACKLOG_CHANGE WS__IO ('t', 122)
390 #define WS_SIO_IDEAL_SEND_BACKLOG_QUERY WS__IOR('t', 123, ULONG)
393 #ifndef USE_WS_PREFIX
394 extern const IN_ADDR in4addr_alligmpv3routersonlink
;
395 extern const IN_ADDR in4addr_allnodesonlink
;
396 extern const IN_ADDR in4addr_allroutersonlink
;
397 extern const IN_ADDR in4addr_allteredohostsonlink
;
398 extern const IN_ADDR in4addr_any
;
399 extern const IN_ADDR in4addr_broadcast
;
400 extern const IN_ADDR in4addr_linklocalprefix
;
401 extern const IN_ADDR in4addr_loopback
;
402 extern const IN_ADDR in4addr_multicastprefix
;
403 extern const IN6_ADDR in6addr_6to4prefix
;
404 extern const IN6_ADDR in6addr_allmldv2routersonlink
;
405 extern const IN6_ADDR in6addr_allnodesonlink
;
406 extern const IN6_ADDR in6addr_allnodesonnode
;
407 extern const IN6_ADDR in6addr_allroutersonlink
;
408 extern const IN6_ADDR in6addr_any
;
409 extern const IN6_ADDR in6addr_linklocalprefix
;
410 extern const IN6_ADDR in6addr_loopback
;
411 extern const IN6_ADDR in6addr_multicastprefix
;
412 extern const IN6_ADDR in6addr_solicitednodemulticastprefix
;
413 extern const IN6_ADDR in6addr_teredoinitiallinklocaladdress
;
414 extern const IN6_ADDR in6addr_teredoprefix
;
415 extern const IN6_ADDR in6addr_teredoprefix_old
;
416 extern const IN6_ADDR in6addr_v4mappedprefix
;
423 static inline BOOLEAN
WS(IN6_IS_ADDR_LOOPBACK
) ( const IN6_ADDR
*a
)
425 return ((a
->s6_words
[0] == 0) &&
426 (a
->s6_words
[1] == 0) &&
427 (a
->s6_words
[2] == 0) &&
428 (a
->s6_words
[3] == 0) &&
429 (a
->s6_words
[4] == 0) &&
430 (a
->s6_words
[5] == 0) &&
431 (a
->s6_words
[6] == 0) &&
432 (a
->s6_words
[7] == 0x0100));
435 static inline BOOLEAN
WS(IN6_IS_ADDR_MULTICAST
) ( const IN6_ADDR
*a
)
437 return (a
->s6_bytes
[0] == 0xff);
440 static inline BOOLEAN
WS(IN6_IS_ADDR_UNSPECIFIED
) ( const IN6_ADDR
*a
)
442 return ((a
->s6_words
[0] == 0) &&
443 (a
->s6_words
[1] == 0) &&
444 (a
->s6_words
[2] == 0) &&
445 (a
->s6_words
[3] == 0) &&
446 (a
->s6_words
[4] == 0) &&
447 (a
->s6_words
[5] == 0) &&
448 (a
->s6_words
[6] == 0) &&
449 (a
->s6_words
[7] == 0));
452 static inline BOOLEAN
WS(IN6_IS_ADDR_LINKLOCAL
) ( const IN6_ADDR
*a
)
454 return ((a
->s6_bytes
[0] == 0xfe) && ((a
->s6_bytes
[1] & 0xc0) == 0x80));
457 static inline BOOLEAN
WS(IN6_IS_ADDR_SITELOCAL
) ( const IN6_ADDR
*a
)
459 return ((a
->s6_bytes
[0] == 0xfe) && ((a
->s6_bytes
[1] & 0xc0) == 0xc0));
466 #endif /* __WS2IPDEF__ */