1 // Copyright © 2015-2017 winapi-rs developers
2 // Licensed under the Apache License, Version 2.0
3 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
4 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
5 // All files in the project carrying such notice may not be copied, modified, or distributed
6 // except according to those terms.
7 //! Core definitions for the Winsock2 specification
8 use ctypes::{__int64, c_char, c_int, c_long, c_short, c_void};
9 use shared::basetsd::SIZE_T;
10 use shared::guiddef::LPGUID;
11 use shared::inaddr::IN_ADDR;
12 use shared::minwindef::{DWORD, INT, UCHAR, ULONG, USHORT};
13 use um::winnt::{CHAR, HANDLE, LONG, PROCESSOR_NUMBER, PWSTR};
14 use vc::vcruntime::size_t;
15 pub type ADDRESS_FAMILY = USHORT;
16 pub const AF_UNSPEC: c_int = 0;
17 pub const AF_UNIX: c_int = 1;
18 pub const AF_INET: c_int = 2;
19 pub const AF_IMPLINK: c_int = 3;
20 pub const AF_PUP: c_int = 4;
21 pub const AF_CHAOS: c_int = 5;
22 pub const AF_NS: c_int = 6;
23 pub const AF_IPX: c_int = AF_NS;
24 pub const AF_ISO: c_int = 7;
25 pub const AF_OSI: c_int = AF_ISO;
26 pub const AF_ECMA: c_int = 8;
27 pub const AF_DATAKIT: c_int = 9;
28 pub const AF_CCITT: c_int = 10;
29 pub const AF_SNA: c_int = 11;
30 pub const AF_DECnet: c_int = 12;
31 pub const AF_DLI: c_int = 13;
32 pub const AF_LAT: c_int = 14;
33 pub const AF_HYLINK: c_int = 15;
34 pub const AF_APPLETALK: c_int = 16;
35 pub const AF_NETBIOS: c_int = 17;
36 pub const AF_VOICEVIEW: c_int = 18;
37 pub const AF_FIREFOX: c_int = 19;
38 pub const AF_UNKNOWN1: c_int = 20;
39 pub const AF_BAN: c_int = 21;
40 pub const AF_ATM: c_int = 22;
41 pub const AF_INET6: c_int = 23;
42 pub const AF_CLUSTER: c_int = 24;
43 pub const AF_12844: c_int = 25;
44 pub const AF_IRDA: c_int = 26;
45 pub const AF_NETDES: c_int = 28;
46 pub const AF_TCNPROCESS: c_int = 29;
47 pub const AF_TCNMESSAGE: c_int = 30;
48 pub const AF_ICLFXBM: c_int = 31;
49 pub const AF_BTH: c_int = 32;
50 pub const AF_LINK: c_int = 33;
51 pub const AF_HYPERV: c_int = 34;
52 pub const AF_MAX: c_int = 35;
53 pub const SOCK_STREAM: c_int = 1;
54 pub const SOCK_DGRAM: c_int = 2;
55 pub const SOCK_RAW: c_int = 3;
56 pub const SOCK_RDM: c_int = 4;
57 pub const SOCK_SEQPACKET: c_int = 5;
58 pub const SOL_SOCKET: c_int = 0xffff;
59 pub const SO_DEBUG: c_int = 0x0001;
60 pub const SO_ACCEPTCONN: c_int = 0x0002;
61 pub const SO_REUSEADDR: c_int = 0x0004;
62 pub const SO_KEEPALIVE: c_int = 0x0008;
63 pub const SO_DONTROUTE: c_int = 0x0010;
64 pub const SO_BROADCAST: c_int = 0x0020;
65 pub const SO_USELOOPBACK: c_int = 0x0040;
66 pub const SO_LINGER: c_int = 0x0080;
67 pub const SO_OOBINLINE: c_int = 0x0100;
68 pub const SO_DONTLINGER: c_int = !SO_LINGER;
69 pub const SO_EXCLUSIVEADDRUSE: c_int = !SO_REUSEADDR;
70 pub const SO_SNDBUF: c_int = 0x1001;
71 pub const SO_RCVBUF: c_int = 0x1002;
72 pub const SO_SNDLOWAT: c_int = 0x1003;
73 pub const SO_RCVLOWAT: c_int = 0x1004;
74 pub const SO_SNDTIMEO: c_int = 0x1005;
75 pub const SO_RCVTIMEO: c_int = 0x1006;
76 pub const SO_ERROR: c_int = 0x1007;
77 pub const SO_TYPE: c_int = 0x1008;
78 pub const SO_BSP_STATE: c_int = 0x1009;
79 pub const SO_GROUP_ID: c_int = 0x2001;
80 pub const SO_GROUP_PRIORITY: c_int = 0x2002;
81 pub const SO_MAX_MSG_SIZE: c_int = 0x2003;
82 pub const SO_CONDITIONAL_ACCEPT: c_int = 0x3002;
83 pub const SO_PAUSE_ACCEPT: c_int = 0x3003;
84 pub const SO_COMPARTMENT_ID: c_int = 0x3004;
85 pub const SO_RANDOMIZE_PORT: c_int = 0x3005;
86 pub const SO_PORT_SCALABILITY: c_int = 0x3006;
87 pub const SO_REUSE_UNICASTPORT: c_int = 0x3007;
88 pub const SO_REUSE_MULTICASTPORT: c_int = 0x3008;
89 pub const WSK_SO_BASE: c_int = 0x4000;
90 pub const TCP_NODELAY: c_int = 0x0001;
91 STRUCT!{struct SOCKADDR {
92     sa_family: ADDRESS_FAMILY,
93     sa_data: [CHAR; 14],
94 }}
95 pub type PSOCKADDR = *mut SOCKADDR;
96 pub type LPSOCKADDR = *mut SOCKADDR;
97 STRUCT!{struct SOCKET_ADDRESS {
98     lpSockaddr: LPSOCKADDR,
99     iSockaddrLength: INT,
100 }}
101 pub type PSOCKET_ADDRESS = *mut SOCKET_ADDRESS;
102 pub type LPSOCKET_ADDRESS = *mut SOCKET_ADDRESS;
103 STRUCT!{struct SOCKET_ADDRESS_LIST {
104     iAddressCount: INT,
105     Address: [SOCKET_ADDRESS; 1],
106 }}
107 pub type PSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST;
108 pub type LPSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST;
109 STRUCT!{struct CSADDR_INFO {
110     LocalAddr: SOCKET_ADDRESS,
111     RemoteAddr: SOCKET_ADDRESS,
112     iSocketType: INT,
113     iProtocol: INT,
114 }}
115 pub type PCSADDR_INFO = *mut CSADDR_INFO;
116 pub type LPCSADDR_INFO = *mut CSADDR_INFO;
117 STRUCT!{struct SOCKADDR_STORAGE_LH {
118     ss_family: ADDRESS_FAMILY,
119     __ss_pad1: [CHAR; 6],
120     __ss_align: __int64,
121     __ss_pad2: [CHAR; 112],
122 }}
123 pub type PSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH;
124 pub type LPSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH;
125 STRUCT!{struct SOCKADDR_STORAGE_XP {
126     ss_family: c_short,
127     __ss_pad1: [CHAR; 6],
128     __ss_align: __int64,
129     __ss_pad2: [CHAR; 112],
130 }}
131 pub type PSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP;
132 pub type LPSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP;
133 pub type SOCKADDR_STORAGE = SOCKADDR_STORAGE_LH;
134 pub type PSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE;
135 pub type LPSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE;
136 STRUCT!{struct SOCKET_PROCESSOR_AFFINITY {
137     Processor: PROCESSOR_NUMBER,
138     NumaNodeId: USHORT,
139     Reserved: USHORT,
140 }}
141 pub type PSOCKET_PROCESSOR_AFFINITY = *mut SOCKET_PROCESSOR_AFFINITY;
142 pub const IOC_UNIX: DWORD = 0x00000000;
143 pub const IOC_WS2: DWORD = 0x08000000;
144 pub const IOC_PROTOCOL: DWORD = 0x10000000;
145 pub const IOC_VENDOR: DWORD = 0x18000000;
146 pub const IOC_WSK: DWORD = IOC_WS2 | 0x07000000;
147 macro_rules! _WSAIO { ($x:expr, $y:expr) => { IOC_VOID | $x | $y } }
148 macro_rules! _WSAIOR { ($x:expr, $y:expr) => { IOC_OUT | $x | $y } }
149 macro_rules! _WSAIOW { ($x:expr, $y:expr) => { IOC_IN | $x | $y } }
150 macro_rules! _WSAIORW { ($x:expr, $y:expr) => { IOC_INOUT | $x | $y } }
151 pub const SIO_ASSOCIATE_HANDLE: DWORD = _WSAIOW!(IOC_WS2, 1);
152 pub const SIO_ENABLE_CIRCULAR_QUEUEING: DWORD = _WSAIO!(IOC_WS2, 2);
153 pub const SIO_FIND_ROUTE: DWORD = _WSAIOR!(IOC_WS2, 3);
154 pub const SIO_FLUSH: DWORD = _WSAIO!(IOC_WS2, 4);
155 pub const SIO_GET_BROADCAST_ADDRESS: DWORD = _WSAIOR!(IOC_WS2, 5);
156 pub const SIO_GET_EXTENSION_FUNCTION_POINTER: DWORD = _WSAIORW!(IOC_WS2, 6);
157 pub const SIO_GET_QOS: DWORD = _WSAIORW!(IOC_WS2, 7);
158 pub const SIO_GET_GROUP_QOS: DWORD = _WSAIORW!(IOC_WS2, 8);
159 pub const SIO_MULTIPOINT_LOOPBACK: DWORD = _WSAIOW!(IOC_WS2, 9);
160 pub const SIO_MULTICAST_SCOPE: DWORD = _WSAIOW!(IOC_WS2, 10);
161 pub const SIO_SET_QOS: DWORD = _WSAIOW!(IOC_WS2, 11);
162 pub const SIO_SET_GROUP_QOS: DWORD = _WSAIOW!(IOC_WS2, 12);
163 pub const SIO_TRANSLATE_HANDLE: DWORD = _WSAIORW!(IOC_WS2, 13);
164 pub const SIO_ROUTING_INTERFACE_QUERY: DWORD = _WSAIORW!(IOC_WS2, 20);
165 pub const SIO_ROUTING_INTERFACE_CHANGE: DWORD = _WSAIOW!(IOC_WS2, 21);
166 pub const SIO_ADDRESS_LIST_QUERY: DWORD = _WSAIOR!(IOC_WS2, 22);
167 pub const SIO_ADDRESS_LIST_CHANGE: DWORD = _WSAIO!(IOC_WS2, 23);
168 pub const SIO_QUERY_TARGET_PNP_HANDLE: DWORD = _WSAIOR!(IOC_WS2, 24);
169 pub const SIO_QUERY_RSS_PROCESSOR_INFO: DWORD = _WSAIOR!(IOC_WS2, 37);
170 pub const SIO_ADDRESS_LIST_SORT: DWORD = _WSAIORW!(IOC_WS2, 25);
171 pub const SIO_RESERVED_1: DWORD = _WSAIOW!(IOC_WS2, 26);
172 pub const SIO_RESERVED_2: DWORD = _WSAIOW!(IOC_WS2, 33);
173 pub const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER: DWORD = _WSAIORW!(IOC_WS2, 36);
174 pub const IPPROTO_IP: c_int = 0;
175 ENUM!{enum IPPROTO {
176     IPPROTO_HOPOPTS = 0, // IPv6 Hop-by-Hop options
177     IPPROTO_ICMP = 1,
178     IPPROTO_IGMP = 2,
179     IPPROTO_GGP = 3,
180     IPPROTO_IPV4 = 4,
181     IPPROTO_ST = 5,
182     IPPROTO_TCP = 6,
183     IPPROTO_CBT = 7,
184     IPPROTO_EGP = 8,
185     IPPROTO_IGP = 9,
186     IPPROTO_PUP = 12,
187     IPPROTO_UDP = 17,
188     IPPROTO_IDP = 22,
189     IPPROTO_RDP = 27,
190     IPPROTO_IPV6 = 41, // IPv6 header
191     IPPROTO_ROUTING = 43, // IPv6 Routing header
192     IPPROTO_FRAGMENT = 44, // IPv6 fragmentation header
193     IPPROTO_ESP = 50, // encapsulating security payload
194     IPPROTO_AH = 51, // authentication header
195     IPPROTO_ICMPV6 = 58, // ICMPv6
196     IPPROTO_NONE = 59, // IPv6 no next header
197     IPPROTO_DSTOPTS = 60, // IPv6 Destination options
198     IPPROTO_ND = 77,
199     IPPROTO_ICLFXBM = 78,
200     IPPROTO_PIM = 103,
201     IPPROTO_PGM = 113,
202     IPPROTO_L2TP = 115,
203     IPPROTO_SCTP = 132,
204     IPPROTO_RAW = 255,
205     IPPROTO_MAX = 256,
206     IPPROTO_RESERVED_RAW = 257,
207     IPPROTO_RESERVED_IPSEC = 258,
208     IPPROTO_RESERVED_IPSECOFFLOAD = 259,
209     IPPROTO_RESERVED_WNV = 260,
210     IPPROTO_RESERVED_MAX = 261,
211 }}
212 pub type PIPPROTO = *mut IPPROTO;
213 pub const IPPORT_TCPMUX: USHORT = 1;
214 pub const IPPORT_ECHO: USHORT = 7;
215 pub const IPPORT_DISCARD: USHORT = 9;
216 pub const IPPORT_SYSTAT: USHORT = 11;
217 pub const IPPORT_DAYTIME: USHORT = 13;
218 pub const IPPORT_NETSTAT: USHORT = 15;
219 pub const IPPORT_QOTD: USHORT = 17;
220 pub const IPPORT_MSP: USHORT = 18;
221 pub const IPPORT_CHARGEN: USHORT = 19;
222 pub const IPPORT_FTP_DATA: USHORT = 20;
223 pub const IPPORT_FTP: USHORT = 21;
224 pub const IPPORT_TELNET: USHORT = 23;
225 pub const IPPORT_SMTP: USHORT = 25;
226 pub const IPPORT_TIMESERVER: USHORT = 37;
227 pub const IPPORT_NAMESERVER: USHORT = 42;
228 pub const IPPORT_WHOIS: USHORT = 43;
229 pub const IPPORT_MTP: USHORT = 57;
230 pub const IPPORT_TFTP: USHORT = 69;
231 pub const IPPORT_RJE: USHORT = 77;
232 pub const IPPORT_FINGER: USHORT = 79;
233 pub const IPPORT_TTYLINK: USHORT = 87;
234 pub const IPPORT_SUPDUP: USHORT = 95;
235 pub const IPPORT_POP3: USHORT = 110;
236 pub const IPPORT_NTP: USHORT = 123;
237 pub const IPPORT_EPMAP: USHORT = 135;
238 pub const IPPORT_NETBIOS_NS: USHORT = 137;
239 pub const IPPORT_NETBIOS_DGM: USHORT = 138;
240 pub const IPPORT_NETBIOS_SSN: USHORT = 139;
241 pub const IPPORT_IMAP: USHORT = 143;
242 pub const IPPORT_SNMP: USHORT = 161;
243 pub const IPPORT_SNMP_TRAP: USHORT = 162;
244 pub const IPPORT_IMAP3: USHORT = 220;
245 pub const IPPORT_LDAP: USHORT = 389;
246 pub const IPPORT_HTTPS: USHORT = 443;
247 pub const IPPORT_MICROSOFT_DS: USHORT = 445;
248 pub const IPPORT_EXECSERVER: USHORT = 512;
249 pub const IPPORT_LOGINSERVER: USHORT = 513;
250 pub const IPPORT_CMDSERVER: USHORT = 514;
251 pub const IPPORT_EFSSERVER: USHORT = 520;
252 pub const IPPORT_BIFFUDP: USHORT = 512;
253 pub const IPPORT_WHOSERVER: USHORT = 513;
254 pub const IPPORT_ROUTESERVER: USHORT = 520;
255 pub const IPPORT_RESERVED: USHORT = 1024;
256 pub const IPPORT_REGISTERED_MIN: USHORT = IPPORT_RESERVED;
257 pub const IPPORT_REGISTERED_MAX: USHORT = 0xbfff;
258 pub const IPPORT_DYNAMIC_MIN: USHORT = 0xc000;
259 pub const IPPORT_DYNAMIC_MAX: USHORT = 0xffff;
260 #[inline]
IN_CLASSA(i: LONG) -> bool261 pub fn IN_CLASSA(i: LONG) -> bool {
262     (i & 0x80000000) == 0
263 }
264 pub const IN_CLASSA_NET: LONG = 0xff000000;
265 pub const IN_CLASSA_NSHIFT: LONG = 24;
266 pub const IN_CLASSA_HOST: LONG = 0x00ffffff;
267 pub const IN_CLASSA_MAX: LONG = 128;
268 #[inline]
IN_CLASSB(i: LONG) -> bool269 pub fn IN_CLASSB(i: LONG) -> bool {
270     (i as u32 & 0xc0000000) == 0x80000000
271 }
272 pub const IN_CLASSB_NET: LONG = 0xffff0000;
273 pub const IN_CLASSB_NSHIFT: LONG = 16;
274 pub const IN_CLASSB_HOST: LONG = 0x0000ffff;
275 pub const IN_CLASSB_MAX: LONG = 65536;
276 #[inline]
IN_CLASSC(i: LONG) -> bool277 pub fn IN_CLASSC(i: LONG) -> bool {
278     (i as u32 & 0xe0000000) == 0xc0000000
279 }
280 pub const IN_CLASSC_NET: LONG = 0xffffff00;
281 pub const IN_CLASSC_NSHIFT: LONG = 8;
282 pub const IN_CLASSC_HOST: LONG = 0x000000ff;
283 #[inline]
IN_CLASSD(i: c_long) -> bool284 pub fn IN_CLASSD(i: c_long) -> bool {
285     (i as u32 & 0xf0000000) == 0xe0000000
286 }
287 pub const IN_CLASSD_NET: LONG = 0xf0000000;
288 pub const IN_CLASSD_NSHIFT: LONG = 28;
289 pub const IN_CLASSD_HOST: LONG = 0x0fffffff;
290 #[inline]
IN_MULTICAST(i: c_long) -> bool291 pub fn IN_MULTICAST(i: c_long) -> bool {
292     IN_CLASSD(i)
293 }
294 pub const INADDR_ANY: ULONG = 0x00000000;
295 pub const INADDR_LOOPBACK: ULONG = 0x7f000001;
296 pub const INADDR_BROADCAST: ULONG = 0xffffffff;
297 pub const INADDR_NONE: ULONG = 0xffffffff;
298 ENUM!{enum SCOPE_LEVEL {
299     ScopeLevelInterface = 1,
300     ScopeLevelLink = 2,
301     ScopeLevelSubnet = 3,
302     ScopeLevelAdmin = 4,
303     ScopeLevelSite = 5,
304     ScopeLevelOrganization = 8,
305     ScopeLevelGlobal = 14,
306     ScopeLevelCount = 16,
307 }}
308 STRUCT!{struct SCOPE_ID_u_s {
309     bitfield: ULONG,
310 }}
311 BITFIELD!{SCOPE_ID_u_s bitfield: ULONG [
312     Zone set_Zone[0..28],
313     Level set_Level[28..32],
314 ]}
315 UNION!{union SCOPE_ID_u {
316     [u32; 1],
317     s s_mut: SCOPE_ID_u_s,
318     Value Value_mut: ULONG,
319 }}
320 STRUCT!{struct SCOPE_ID {
321     u: SCOPE_ID_u,
322 }}
323 pub type PSCOPE_ID = *mut SCOPE_ID;
324 STRUCT!{struct SOCKADDR_IN {
325     sin_family: ADDRESS_FAMILY,
326     sin_port: USHORT,
327     sin_addr: IN_ADDR,
328     sin_zero: [CHAR; 8],
329 }}
330 pub type PSOCKADDR_IN = *mut SOCKADDR_IN;
331 STRUCT!{struct SOCKADDR_DL {
332     sdl_family: ADDRESS_FAMILY,
333     sdl_data: [UCHAR; 8],
334     sdl_zero: [UCHAR; 4],
335 }}
336 pub type PSOCKADDR_DL = *mut SOCKADDR_DL;
337 pub const IOCPARM_MASK: DWORD = 0x7f;
338 pub const IOC_VOID: DWORD = 0x20000000;
339 pub const IOC_OUT: DWORD = 0x40000000;
340 pub const IOC_IN: DWORD = 0x80000000;
341 pub const IOC_INOUT: DWORD = IOC_IN | IOC_OUT;
342 STRUCT!{struct WSABUF {
343     len: ULONG,
344     buf: *mut CHAR,
345 }}
346 pub type LPWSABUF = *mut WSABUF;
347 STRUCT!{struct WSAMSG {
348     name: LPSOCKADDR,
349     namelen: INT,
350     lpBuffers: LPWSABUF,
351     dwBufferCount: ULONG,
352     Control: WSABUF,
353     dwFlags: ULONG,
354 }}
355 pub type PWSAMSG = *mut WSAMSG;
356 pub type LPWSAMSG = *mut WSAMSG;
357 STRUCT!{struct WSACMSGHDR {
358     cmsg_len: SIZE_T,
359     cmsg_level: INT,
360     cmsg_type: INT,
361 }}
362 pub type PWSACMSGHDR = *mut WSACMSGHDR;
363 pub type LPWSACMSGHDR = *mut WSACMSGHDR;
364 pub type CMSGHDR = WSACMSGHDR;
365 pub type PCMSGHDR = *mut WSACMSGHDR;
366 pub const MSG_TRUNC: ULONG = 0x0100;
367 pub const MSG_CTRUNC: ULONG = 0x0200;
368 pub const MSG_BCAST: ULONG = 0x0400;
369 pub const MSG_MCAST: ULONG = 0x0800;
370 pub const AI_PASSIVE: c_int = 0x00000001;
371 pub const AI_CANONNAME: c_int = 0x00000002;
372 pub const AI_NUMERICHOST: c_int = 0x00000004;
373 pub const AI_NUMERICSERV: c_int = 0x00000008;
374 pub const AI_DNS_ONLY: c_int = 0x00000010;
375 pub const AI_ALL: c_int = 0x00000100;
376 pub const AI_ADDRCONFIG: c_int = 0x00000400;
377 pub const AI_V4MAPPED: c_int = 0x00000800;
378 pub const AI_NON_AUTHORITATIVE: c_int = 0x00004000;
379 pub const AI_SECURE: c_int = 0x00008000;
380 pub const AI_RETURN_PREFERRED_NAMES: c_int = 0x00010000;
381 pub const AI_FQDN: c_int = 0x00020000;
382 pub const AI_FILESERVER: c_int = 0x00040000;
383 pub const AI_DISABLE_IDN_ENCODING: c_int = 0x00080000;
384 pub const AI_EXTENDED: c_int = 0x80000000;
385 pub const AI_RESOLUTION_HANDLE: c_int = 0x40000000;
386 STRUCT!{struct ADDRINFOA {
387     ai_flags: c_int,
388     ai_family: c_int,
389     ai_socktype: c_int,
390     ai_protocol: c_int,
391     ai_addrlen: size_t,
392     ai_canonname: *mut c_char,
393     ai_addr: *mut SOCKADDR,
394     ai_next: *mut ADDRINFOA,
395 }}
396 pub type PADDRINFOA = *mut ADDRINFOA;
397 STRUCT!{struct ADDRINFOW {
398     ai_flags: c_int,
399     ai_family: c_int,
400     ai_socktype: c_int,
401     ai_protocol: c_int,
402     ai_addrlen: size_t,
403     ai_canonname: PWSTR,
404     ai_addr: *mut SOCKADDR,
405     ai_next: *mut ADDRINFOW,
406 }}
407 pub type PADDRINFOW = *mut ADDRINFOW;
408 STRUCT!{struct ADDRINFOEXA {
409     ai_flags: c_int,
410     ai_family: c_int,
411     ai_socktype: c_int,
412     ai_protocol: c_int,
413     ai_addrlen: size_t,
414     ai_canonname: *mut c_char,
415     ai_addr: *mut SOCKADDR,
416     ai_blob: *mut c_void,
417     ai_bloblen: size_t,
418     ai_provider: LPGUID,
419     ai_next: *mut ADDRINFOEXA,
420 }}
421 pub type PADDRINFOEXA = *mut ADDRINFOEXA;
422 pub type LPADDRINFOEXA = *mut ADDRINFOEXA;
423 STRUCT!{struct ADDRINFOEXW {
424     ai_flags: c_int,
425     ai_family: c_int,
426     ai_socktype: c_int,
427     ai_protocol: c_int,
428     ai_addrlen: size_t,
429     ai_canonname: PWSTR,
430     ai_addr: *mut SOCKADDR,
431     ai_blob: *mut c_void,
432     ai_bloblen: size_t,
433     ai_provider: LPGUID,
434     ai_next: *mut ADDRINFOEXW,
435 }}
436 pub type PADDRINFOEXW = *mut ADDRINFOEXW;
437 pub type LPADDRINFOEXW = *mut ADDRINFOEXW;
438 pub const ADDRINFOEX_VERSION_2: c_int = 2;
439 pub const ADDRINFOEX_VERSION_3: c_int = 3;
440 pub const ADDRINFOEX_VERSION_4: c_int = 4;
441 STRUCT!{struct ADDRINFOEX2A {
442     ai_flags: c_int,
443     ai_family: c_int,
444     ai_socktype: c_int,
445     ai_protocol: c_int,
446     ai_addrlen: size_t,
447     ai_canonname: *mut c_char,
448     ai_addr: *mut SOCKADDR,
449     ai_blob: *mut c_void,
450     ai_bloblen: size_t,
451     ai_provider: LPGUID,
452     ai_next: *mut ADDRINFOEX2W,
453     ai_version: c_int,
454     ai_fqdn: *mut c_char,
455 }}
456 pub type PADDRINFOEX2A = *mut ADDRINFOEX2A;
457 pub type LPADDRINFOEX2A = *mut ADDRINFOEX2A;
458 STRUCT!{struct ADDRINFOEX2W {
459     ai_flags: c_int,
460     ai_family: c_int,
461     ai_socktype: c_int,
462     ai_protocol: c_int,
463     ai_addrlen: size_t,
464     ai_canonname: PWSTR,
465     ai_addr: *mut SOCKADDR,
466     ai_blob: *mut c_void,
467     ai_bloblen: size_t,
468     ai_provider: LPGUID,
469     ai_next: *mut ADDRINFOEX2W,
470     ai_version: c_int,
471     ai_fqdn: PWSTR,
472 }}
473 pub type PADDRINFOEX2W = *mut ADDRINFOEX2W;
474 pub type LPADDRINFOEX2W = *mut ADDRINFOEX2W;
475 STRUCT!{struct ADDRINFOEX3A {
476     ai_flags: c_int,
477     ai_family: c_int,
478     ai_socktype: c_int,
479     ai_protocol: c_int,
480     ai_addrlen: size_t,
481     ai_canonname: *mut c_char,
482     ai_addr: *mut SOCKADDR,
483     ai_blob: *mut c_void,
484     ai_bloblen: size_t,
485     ai_provider: LPGUID,
486     ai_next: *mut ADDRINFOEX3W,
487     ai_version: c_int,
488     ai_fqdn: *mut c_char,
489     ai_interfaceindex: c_int,
490 }}
491 pub type PADDRINFOEX3A = *mut ADDRINFOEX3A;
492 pub type LPADDRINFOEX3A = *mut ADDRINFOEX3A;
493 STRUCT!{struct ADDRINFOEX3W {
494     ai_flags: c_int,
495     ai_family: c_int,
496     ai_socktype: c_int,
497     ai_protocol: c_int,
498     ai_addrlen: size_t,
499     ai_canonname: PWSTR,
500     ai_addr: *mut SOCKADDR,
501     ai_blob: *mut c_void,
502     ai_bloblen: size_t,
503     ai_provider: LPGUID,
504     ai_next: *mut ADDRINFOEX3W,
505     ai_version: c_int,
506     ai_fqdn: PWSTR,
507     ai_interfaceindex: c_int,
508 }}
509 pub type PADDRINFOEX3W = *mut ADDRINFOEX3W;
510 pub type LPADDRINFOEX3W = *mut ADDRINFOEX3W;
511 STRUCT!{struct ADDRINFOEX4 {
512     ai_flags: c_int,
513     ai_family: c_int,
514     ai_socktype: c_int,
515     ai_protocol: c_int,
516     ai_addrlen: size_t,
517     ai_canonname: PWSTR,
518     ai_addr: *mut SOCKADDR,
519     ai_blob: *mut c_void,
520     ai_bloblen: size_t,
521     ai_provider: LPGUID,
522     ai_next: *mut ADDRINFOEX4,
523     ai_version: c_int,
524     ai_fqdn: PWSTR,
525     ai_interfaceindex: c_int,
526     ai_resolutionhandle: HANDLE,
527 }}
528 pub type PADDRINFOEX4 = *mut ADDRINFOEX4;
529 pub type LPADDRINFOEX4 = *mut ADDRINFOEX4;
530 pub const NS_ALL: DWORD = 0;
531 pub const NS_SAP: DWORD = 1;
532 pub const NS_NDS: DWORD = 2;
533 pub const NS_PEER_BROWSE: DWORD = 3;
534 pub const NS_SLP: DWORD = 5;
535 pub const NS_DHCP: DWORD = 6;
536 pub const NS_TCPIP_LOCAL: DWORD = 10;
537 pub const NS_TCPIP_HOSTS: DWORD = 11;
538 pub const NS_DNS: DWORD = 12;
539 pub const NS_NETBT: DWORD = 13;
540 pub const NS_WINS: DWORD = 14;
541 pub const NS_NLA: DWORD = 15;
542 pub const NS_BTH: DWORD = 16;
543 pub const NS_NBP: DWORD = 20;
544 pub const NS_MS: DWORD = 30;
545 pub const NS_STDA: DWORD = 31;
546 pub const NS_NTDS: DWORD = 32;
547 pub const NS_EMAIL: DWORD = 37;
548 pub const NS_PNRPNAME: DWORD = 38;
549 pub const NS_PNRPCLOUD: DWORD = 39;
550 pub const NS_X500: DWORD = 40;
551 pub const NS_NIS: DWORD = 41;
552 pub const NS_NISPLUS: DWORD = 42;
553 pub const NS_WRQ: DWORD = 50;
554 pub const NS_NETDES: DWORD = 60;
555 pub const NI_NOFQDN: c_int = 0x01;
556 pub const NI_NUMERICHOST: c_int = 0x02;
557 pub const NI_NAMEREQD: c_int = 0x04;
558 pub const NI_NUMERICSERV: c_int = 0x08;
559 pub const NI_DGRAM: c_int = 0x10;
560 pub const NI_MAXHOST: c_int = 1025;
561 pub const NI_MAXSERV: c_int = 32;
562