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
86 #define IP_RECEIVE_BROADCAST 22
88 #define IP_RECVDSTADDR 25
90 #define IP_ADD_IFLIST 29
91 #define IP_DEL_IFLIST 30
92 #define IP_UNICAST_IF 31
94 #define IP_RECVRTHDR 38
96 #define WS_IP_OPTIONS 1
97 #define WS_IP_HDRINCL 2
100 #define WS_IP_MULTICAST_IF 9
101 #define WS_IP_MULTICAST_TTL 10
102 #define WS_IP_MULTICAST_LOOP 11
103 #define WS_IP_ADD_MEMBERSHIP 12
104 #define WS_IP_DROP_MEMBERSHIP 13
105 #define WS_IP_DONTFRAGMENT 14
106 #define WS_IP_ADD_SOURCE_MEMBERSHIP 15
107 #define WS_IP_DROP_SOURCE_MEMBERSHIP 16
108 #define WS_IP_BLOCK_SOURCE 17
109 #define WS_IP_UNBLOCK_SOURCE 18
110 #define WS_IP_PKTINFO 19
111 #define WS_IP_HOPLIMIT 21
112 #define WS_IP_RECEIVE_BROADCAST 22
113 #define WS_IP_RECVIF 24
114 #define WS_IP_RECVDSTADDR 25
115 #define WS_IP_IFLIST 28
116 #define WS_IP_ADD_IFLIST 29
117 #define WS_IP_DEL_IFLIST 30
118 #define WS_IP_UNICAST_IF 31
119 #define WS_IP_RTHDR 32
120 #define WS_IP_RECVRTHDR 38
121 #endif /* USE_WS_PREFIX */
123 typedef struct WS(sockaddr_in6
)
130 } SOCKADDR_IN6
,*PSOCKADDR_IN6
, *LPSOCKADDR_IN6
;
132 typedef struct WS(sockaddr_in6_pair
)
134 PSOCKADDR_IN6 SourceAddress
;
135 PSOCKADDR_IN6 DestinationAddress
;
136 } SOCKADDR_IN6_PAIR
, *PSOCKADDR_IN6_PAIR
;
138 typedef union _SOCKADDR_INET
142 ADDRESS_FAMILY si_family
;
143 } SOCKADDR_INET
, *PSOCKADDR_INET
;
146 * Multicast group information
149 typedef struct WS(ip_mreq
)
151 struct WS(in_addr
) imr_multiaddr
;
152 struct WS(in_addr
) imr_interface
;
153 } WS(IP_MREQ
), *WS(PIP_MREQ
);
155 typedef struct WS(ipv6_mreq
)
157 struct WS(in6_addr
) ipv6mr_multiaddr
;
158 unsigned int ipv6mr_interface
;
159 } WS(IPV6_MREQ
), *WS(PIPV6_MREQ
);
161 typedef struct WS(ip_mreq_source
) {
162 struct WS(in_addr
) imr_multiaddr
;
163 struct WS(in_addr
) imr_sourceaddr
;
164 struct WS(in_addr
) imr_interface
;
165 } WS(IP_MREQ_SOURCE
), *WS(PIP_MREQ_SOURCE
);
167 typedef struct WS(ip_msfilter
) {
168 struct WS(in_addr
) imsf_multiaddr
;
169 struct WS(in_addr
) imsf_interface
;
172 struct WS(in_addr
) imsf_slist
[1];
173 } WS(IP_MSFILTER
), *WS(PIP_MSFILTER
);
175 typedef struct WS(in_pktinfo
) {
178 } IN_PKTINFO
, *PIN_PKTINFO
;
180 typedef struct WS(in6_pktinfo
) {
183 } IN6_PKTINFO
, *PIN6_PKTINFO
;
185 #ifndef USE_WS_PREFIX
186 #define IPV6_OPTIONS 1
187 #define IPV6_HDRINCL 2
188 #define IPV6_UNICAST_HOPS 4
189 #define IPV6_MULTICAST_IF 9
190 #define IPV6_MULTICAST_HOPS 10
191 #define IPV6_MULTICAST_LOOP 11
192 #define IPV6_ADD_MEMBERSHIP 12
193 #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
194 #define IPV6_DROP_MEMBERSHIP 13
195 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
196 #define IPV6_DONTFRAG 14
197 #define IPV6_PKTINFO 19
198 #define IPV6_HOPLIMIT 21
199 #define IPV6_PROTECTION_LEVEL 23
200 #define IPV6_RECVIF 24
201 #define IPV6_RECVDSTADDR 25
202 #define IPV6_CHECKSUM 26
203 #define IPV6_V6ONLY 27
204 #define IPV6_IFLIST 28
205 #define IPV6_ADD_IFLIST 29
206 #define IPV6_DEL_IFLIST 30
207 #define IPV6_UNICAST_IF 31
208 #define IPV6_RTHDR 32
209 #define IPV6_RECVRTHDR 38
210 #define IPV6_TCLASS 39
211 #define IPV6_RECVTCLASS 40
213 #define IPV6_PKTINFO_EX 51
214 #define IPV6_WFP_REDIRECT_RECORDS 60
215 #define IPV6_WFP_REDIRECT_CONTEXT 70
216 #define IPV6_MTU_DISCOVER 71
218 #define IPV6_NRT_INTERFACE 74
219 #define IPV6_RECVERR 75
220 #define IPV6_USER_MTU 76
222 #define WS_IPV6_OPTIONS 1
223 #define WS_IPV6_HDRINCL 2
224 #define WS_IPV6_UNICAST_HOPS 4
225 #define WS_IPV6_MULTICAST_IF 9
226 #define WS_IPV6_MULTICAST_HOPS 10
227 #define WS_IPV6_MULTICAST_LOOP 11
228 #define WS_IPV6_ADD_MEMBERSHIP 12
229 #define WS_IPV6_DROP_MEMBERSHIP 13
230 #define WS_IPV6_LEAVE_GROUP WS_IPV6_DROP_MEMBERSHIP
231 #define WS_IPV6_DONTFRAG 14
232 #define WS_IPV6_PKTINFO 19
233 #define WS_IPV6_HOPLIMIT 21
234 #define WS_IPV6_PROTECTION_LEVEL 23
235 #define WS_IPV6_RECVIF 24
236 #define WS_IPV6_RECVDSTADDR 25
237 #define WS_IPV6_CHECKSUM 26
238 #define WS_IPV6_V6ONLY 27
239 #define WS_IPV6_IFLIST 28
240 #define WS_IPV6_ADD_IFLIST 29
241 #define WS_IPV6_DEL_IFLIST 30
242 #define WS_IPV6_UNICAST_IF 31
243 #define WS_IPV6_RTHDR 32
244 #define WS_IPV6_RECVRTHDR 38
245 #define WS_IPV6_TCLASS 39
246 #define WS_IPV6_RECVTCLASS 40
247 #define WS_IPV6_ECN 50
248 #define WS_IPV6_PKTINFO_EX 51
249 #define WS_IPV6_WFP_REDIRECT_RECORDS 60
250 #define WS_IPV6_WFP_REDIRECT_CONTEXT 70
251 #define WS_IPV6_MTU_DISCOVER 71
252 #define WS_IPV6_MTU 72
253 #define WS_IPV6_NRT_INTERFACE 74
254 #define WS_IPV6_RECVERR 75
255 #define WS_IPV6_USER_MTU 76
256 #endif /* USE_WS_PREFIX */
258 #ifndef USE_WS_PREFIX
259 #define TCP_OFFLOAD_NO_PREFERENCE 0
260 #define TCP_OFFLOAD_NOT_PREFERRED 1
261 #define TCP_OFFLOAD_PREFERRED 2
263 #define WS_TCP_OFFLOAD_NO_PREFERENCE 0
264 #define WS_TCP_OFFLOAD_NOT_PREFERRED 1
265 #define WS_TCP_OFFLOAD_PREFERRED 2
266 #endif /* USE_WS_PREFIX */
268 #ifndef USE_WS_PREFIX
269 /* TCP_NODELAY is defined elsewhere */
270 #define TCP_EXPEDITED_1122 2
271 #define TCP_KEEPALIVE 3
277 #define TCP_NOSYNRETRIES 9
278 #define TCP_TIMESTAMPS 10
279 #define TCP_OFFLOAD_PREFERENCE 11
280 #define TCP_CONGESTION_ALGORITHM 12
281 #define TCP_DELAY_FIN_ACK 13
283 /* WS_TCP_NODELAY is defined elsewhere */
284 #define WS_TCP_EXPEDITED_1122 2
285 #define WS_TCP_KEEPALIVE 3
286 #define WS_TCP_MAXSEG 4
287 #define WS_TCP_MAXRT 5
288 #define WS_TCP_STDURG 6
289 #define WS_TCP_NOURG 7
290 #define WS_TCP_ATMARK 8
291 #define WS_TCP_NOSYNRETRIES 9
292 #define WS_TCP_TIMESTAMPS 10
293 #define WS_TCP_OFFLOAD_PREFERENCE 11
294 #define WS_TCP_CONGESTION_ALGORITHM 12
295 #define WS_TCP_DELAY_FIN_ACK 13
296 #endif /* USE_WS_PREFIX */
298 #ifndef USE_WS_PREFIX
299 #define INET_ADDRSTRLEN 22
300 #define INET6_ADDRSTRLEN 65
301 #define IN6ADDR_ANY_INIT { 0 }
302 #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
304 #define WS_INET_ADDRSTRLEN 22
305 #define WS_INET6_ADDRSTRLEN 65
306 #define WS_IN6ADDR_ANY_INIT { 0 }
307 #define WS_IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
308 #endif /* USE_WS_PREFIX */
310 #define SS_PORT(ssp) (((PSOCKADDR_IN)(ssp))->sin_port)
312 #ifndef USE_WS_PREFIX
313 #define SIO_IDEAL_SEND_BACKLOG_CHANGE _IO ('t', 122)
314 #define SIO_IDEAL_SEND_BACKLOG_QUERY _IOR('t', 123, ULONG)
316 #define WS_SIO_IDEAL_SEND_BACKLOG_CHANGE WS__IO ('t', 122)
317 #define WS_SIO_IDEAL_SEND_BACKLOG_QUERY WS__IOR('t', 123, ULONG)
324 static inline BOOLEAN
WS(IN6_IS_ADDR_LOOPBACK
) ( const IN6_ADDR
*a
)
326 return ((a
->s6_words
[0] == 0) &&
327 (a
->s6_words
[1] == 0) &&
328 (a
->s6_words
[2] == 0) &&
329 (a
->s6_words
[3] == 0) &&
330 (a
->s6_words
[4] == 0) &&
331 (a
->s6_words
[5] == 0) &&
332 (a
->s6_words
[6] == 0) &&
333 (a
->s6_words
[7] == 0x0100));
336 static inline BOOLEAN
WS(IN6_IS_ADDR_MULTICAST
) ( const IN6_ADDR
*a
)
338 return (a
->s6_bytes
[0] == 0xff);
341 static inline BOOLEAN
WS(IN6_IS_ADDR_UNSPECIFIED
) ( const IN6_ADDR
*a
)
343 return ((a
->s6_words
[0] == 0) &&
344 (a
->s6_words
[1] == 0) &&
345 (a
->s6_words
[2] == 0) &&
346 (a
->s6_words
[3] == 0) &&
347 (a
->s6_words
[4] == 0) &&
348 (a
->s6_words
[5] == 0) &&
349 (a
->s6_words
[6] == 0) &&
350 (a
->s6_words
[7] == 0));
353 static inline BOOLEAN
WS(IN6_IS_ADDR_LINKLOCAL
) ( const IN6_ADDR
*a
)
355 return ((a
->s6_bytes
[0] == 0xfe) && ((a
->s6_bytes
[1] & 0xc0) == 0x80));
358 static inline BOOLEAN
WS(IN6_IS_ADDR_SITELOCAL
) ( const IN6_ADDR
*a
)
360 return ((a
->s6_bytes
[0] == 0xfe) && ((a
->s6_bytes
[1] & 0xc0) == 0xc0));
367 #endif /* __WS2IPDEF__ */