Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 
      7 #ifndef _WINSOCK2API_
      8 #define _WINSOCK2API_
      9 
     10 #include <_mingw_unicode.h>
     11 
     12 #ifndef _WINSOCKAPI_
     13 #define _WINSOCKAPI_
     14 #else
     15 #warning Please include winsock2.h before windows.h
     16 #endif
     17 
     18 #ifndef INCL_WINSOCK_API_TYPEDEFS
     19 #define INCL_WINSOCK_API_TYPEDEFS 0
     20 #endif
     21 
     22 #ifndef _INC_WINDOWS
     23 #include <windows.h>
     24 #endif
     25 
     26 #ifndef MAKEWORD
     27 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
     28 #endif
     29 
     30 #ifndef WINSOCK_VERSION
     31 #define WINSOCK_VERSION MAKEWORD(2,2)
     32 #endif
     33 
     34 #ifndef WINSOCK_API_LINKAGE
     35 #ifdef  DECLSPEC_IMPORT
     36 #define WINSOCK_API_LINKAGE	DECLSPEC_IMPORT
     37 #else
     38 #define WINSOCK_API_LINKAGE
     39 #endif
     40 #endif /* WINSOCK_API_LINKAGE */
     41 #define WSAAPI			WINAPI
     42 
     43 /* undefine macros from winsock.h */
     44 #include <psdk_inc/_ws1_undef.h>
     45 
     46 #ifdef __LP64__
     47 #pragma push_macro("u_long")
     48 #undef u_long
     49 #define u_long __ms_u_long
     50 #endif
     51 
     52 #include <_timeval.h>
     53 #include <_bsd_types.h>
     54 #include <inaddr.h>
     55 #include <psdk_inc/_socket_types.h>
     56 #include <psdk_inc/_fd_types.h>
     57 #include <psdk_inc/_ip_types.h>
     58 #include <psdk_inc/_wsadata.h>
     59 #include <ws2def.h> /* FIXME: include order */
     60 
     61 #ifdef __cplusplus
     62 extern "C" {
     63 #endif
     64 
     65 #define IOCPARM_MASK 0x7f
     66 #define IOC_VOID 0x20000000
     67 #define IOC_OUT 0x40000000
     68 #define IOC_IN 0x80000000
     69 #define IOC_INOUT (IOC_IN|IOC_OUT)
     70 
     71 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
     72 #define _IOR(x,y,t) (IOC_OUT|(((__LONG32)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
     73 #define _IOW(x,y,t) (IOC_IN|(((__LONG32)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
     74 
     75 #define FIONREAD _IOR('f',127,u_long)
     76 #define FIONBIO _IOW('f',126,u_long)
     77 #define FIOASYNC _IOW('f',125,u_long)
     78 
     79 #define SIOCSHIWAT _IOW('s',0,u_long)
     80 #define SIOCGHIWAT _IOR('s',1,u_long)
     81 #define SIOCSLOWAT _IOW('s',2,u_long)
     82 #define SIOCGLOWAT _IOR('s',3,u_long)
     83 #define SIOCATMARK _IOR('s',7,u_long)
     84 
     85 #define IPPROTO_IP 0
     86 #define IPPROTO_HOPOPTS 0
     87 #define IPPROTO_ICMP 1
     88 #define IPPROTO_IGMP 2
     89 #define IPPROTO_GGP 3
     90 #define IPPROTO_IPV4 4
     91 #define IPPROTO_TCP 6
     92 #define IPPROTO_PUP 12
     93 #define IPPROTO_UDP 17
     94 #define IPPROTO_IDP 22
     95 #define IPPROTO_IPV6 41
     96 #define IPPROTO_ROUTING 43
     97 #define IPPROTO_FRAGMENT 44
     98 #define IPPROTO_ESP 50
     99 #define IPPROTO_AH 51
    100 #define IPPROTO_ICMPV6 58
    101 #define IPPROTO_NONE 59
    102 #define IPPROTO_DSTOPTS 60
    103 #define IPPROTO_ND 77
    104 #define IPPROTO_ICLFXBM 78
    105 
    106 #define IPPROTO_RAW 255
    107 #define IPPROTO_MAX 256
    108 
    109 #define IPPORT_ECHO 7
    110 #define IPPORT_DISCARD 9
    111 #define IPPORT_SYSTAT 11
    112 #define IPPORT_DAYTIME 13
    113 #define IPPORT_NETSTAT 15
    114 #define IPPORT_FTP 21
    115 #define IPPORT_TELNET 23
    116 #define IPPORT_SMTP 25
    117 #define IPPORT_TIMESERVER 37
    118 #define IPPORT_NAMESERVER 42
    119 #define IPPORT_WHOIS 43
    120 #define IPPORT_MTP 57
    121 
    122 #define IPPORT_TFTP 69
    123 #define IPPORT_RJE 77
    124 #define IPPORT_FINGER 79
    125 #define IPPORT_TTYLINK 87
    126 #define IPPORT_SUPDUP 95
    127 
    128 #define IPPORT_EXECSERVER 512
    129 #define IPPORT_LOGINSERVER 513
    130 #define IPPORT_CMDSERVER 514
    131 #define IPPORT_EFSSERVER 520
    132 
    133 #define IPPORT_BIFFUDP 512
    134 #define IPPORT_WHOSERVER 513
    135 #define IPPORT_ROUTESERVER 520
    136 
    137 #define IPPORT_RESERVED 1024
    138 
    139 #define IMPLINK_IP 155
    140 #define IMPLINK_LOWEXPER 156
    141 #define IMPLINK_HIGHEXPER 158
    142 
    143 
    144 #define IN_CLASSA(i) (((__LONG32)(i) & 0x80000000)==0)
    145 #define IN_CLASSA_NET 0xff000000
    146 #define IN_CLASSA_NSHIFT 24
    147 #define IN_CLASSA_HOST 0x00ffffff
    148 #define IN_CLASSA_MAX 128
    149 
    150 #define IN_CLASSB(i) (((__LONG32)(i) & 0xc0000000)==0x80000000)
    151 #define IN_CLASSB_NET 0xffff0000
    152 #define IN_CLASSB_NSHIFT 16
    153 #define IN_CLASSB_HOST 0x0000ffff
    154 #define IN_CLASSB_MAX 65536
    155 
    156 #define IN_CLASSC(i) (((__LONG32)(i) & 0xe0000000)==0xc0000000)
    157 #define IN_CLASSC_NET 0xffffff00
    158 #define IN_CLASSC_NSHIFT 8
    159 #define IN_CLASSC_HOST 0x000000ff
    160 
    161 #define IN_CLASSD(i) (((__LONG32)(i) & 0xf0000000)==0xe0000000)
    162 #define IN_CLASSD_NET 0xf0000000
    163 #define IN_CLASSD_NSHIFT 28
    164 #define IN_CLASSD_HOST 0x0fffffff
    165 #define IN_MULTICAST(i) IN_CLASSD(i)
    166 
    167 #define INADDR_ANY (u_long)0x00000000
    168 #define INADDR_LOOPBACK 0x7f000001
    169 #define INADDR_BROADCAST (u_long)0xffffffff
    170 #define INADDR_NONE 0xffffffff
    171 
    172 #define ADDR_ANY INADDR_ANY
    173 
    174 #define FROM_PROTOCOL_INFO (-1)
    175 
    176 #define SOCK_STREAM 1
    177 #define SOCK_DGRAM 2
    178 #define SOCK_RAW 3
    179 #define SOCK_RDM 4
    180 #define SOCK_SEQPACKET 5
    181 
    182 #define SO_DEBUG 0x0001
    183 #define SO_ACCEPTCONN 0x0002
    184 #define SO_REUSEADDR 0x0004
    185 #define SO_KEEPALIVE 0x0008
    186 #define SO_DONTROUTE 0x0010
    187 #define SO_BROADCAST 0x0020
    188 #define SO_USELOOPBACK 0x0040
    189 #define SO_LINGER 0x0080
    190 #define SO_OOBINLINE 0x0100
    191 
    192 #define SO_DONTLINGER (int)(~SO_LINGER)
    193 #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
    194 
    195 #define SO_SNDBUF 0x1001
    196 #define SO_RCVBUF 0x1002
    197 #define SO_SNDLOWAT 0x1003
    198 #define SO_RCVLOWAT 0x1004
    199 #define SO_SNDTIMEO 0x1005
    200 #define SO_RCVTIMEO 0x1006
    201 #define SO_ERROR 0x1007
    202 #define SO_TYPE 0x1008
    203 
    204 #define SO_GROUP_ID 0x2001
    205 #define SO_GROUP_PRIORITY 0x2002
    206 #define SO_MAX_MSG_SIZE 0x2003
    207 #define SO_PROTOCOL_INFOA 0x2004
    208 #define SO_PROTOCOL_INFOW 0x2005
    209 
    210 #define SO_PROTOCOL_INFO __MINGW_NAME_AW(SO_PROTOCOL_INFO)
    211 
    212 #define PVD_CONFIG 0x3001
    213 #define SO_CONDITIONAL_ACCEPT 0x3002
    214 
    215 #define TCP_NODELAY 0x0001
    216 
    217 #define AF_UNSPEC 0
    218 
    219 #define AF_UNIX 1
    220 #define AF_INET 2
    221 #define AF_IMPLINK 3
    222 #define AF_PUP 4
    223 #define AF_CHAOS 5
    224 #define AF_NS 6
    225 #define AF_IPX AF_NS
    226 #define AF_ISO 7
    227 #define AF_OSI AF_ISO
    228 #define AF_ECMA 8
    229 #define AF_DATAKIT 9
    230 #define AF_CCITT 10
    231 #define AF_SNA 11
    232 #define AF_DECnet 12
    233 #define AF_DLI 13
    234 #define AF_LAT 14
    235 #define AF_HYLINK 15
    236 #define AF_APPLETALK 16
    237 #define AF_NETBIOS 17
    238 #define AF_VOICEVIEW 18
    239 #define AF_FIREFOX 19
    240 #define AF_UNKNOWN1 20
    241 #define AF_BAN 21
    242 #define AF_ATM 22
    243 #define AF_INET6 23
    244 #define AF_CLUSTER 24
    245 #define AF_12844 25
    246 #define AF_IRDA 26
    247 #define AF_NETDES 28
    248 #define AF_TCNPROCESS 29
    249 #define AF_TCNMESSAGE 30
    250 #define AF_ICLFXBM 31
    251 #define AF_BTH 32
    252 #define AF_MAX 33
    253 
    254 #define _SS_MAXSIZE 128
    255 #define _SS_ALIGNSIZE (8)
    256 
    257 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (short))
    258 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (short) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
    259 
    260   struct sockaddr_storage {
    261     short ss_family;
    262     char __ss_pad1[_SS_PAD1SIZE];
    263 
    264     __MINGW_EXTENSION __int64 __ss_align;
    265     char __ss_pad2[_SS_PAD2SIZE];
    266   };
    267 
    268 #define PF_UNSPEC AF_UNSPEC
    269 #define PF_UNIX AF_UNIX
    270 #define PF_INET AF_INET
    271 #define PF_IMPLINK AF_IMPLINK
    272 #define PF_PUP AF_PUP
    273 #define PF_CHAOS AF_CHAOS
    274 #define PF_NS AF_NS
    275 #define PF_IPX AF_IPX
    276 #define PF_ISO AF_ISO
    277 #define PF_OSI AF_OSI
    278 #define PF_ECMA AF_ECMA
    279 #define PF_DATAKIT AF_DATAKIT
    280 #define PF_CCITT AF_CCITT
    281 #define PF_SNA AF_SNA
    282 #define PF_DECnet AF_DECnet
    283 #define PF_DLI AF_DLI
    284 #define PF_LAT AF_LAT
    285 #define PF_HYLINK AF_HYLINK
    286 #define PF_APPLETALK AF_APPLETALK
    287 #define PF_VOICEVIEW AF_VOICEVIEW
    288 #define PF_FIREFOX AF_FIREFOX
    289 #define PF_UNKNOWN1 AF_UNKNOWN1
    290 #define PF_BAN AF_BAN
    291 #define PF_ATM AF_ATM
    292 #define PF_INET6 AF_INET6
    293 #define PF_BTH AF_BTH
    294 
    295 #define PF_MAX AF_MAX
    296 
    297 #define SOL_SOCKET 0xffff
    298 
    299 #define SOMAXCONN 0x7fffffff
    300 
    301 #define MSG_OOB 0x1
    302 #define MSG_PEEK 0x2
    303 #define MSG_DONTROUTE 0x4
    304 #define MSG_WAITALL 0x8
    305 
    306 #define MSG_PARTIAL 0x8000
    307 
    308 #define MSG_INTERRUPT 0x10
    309 
    310 #define MSG_MAXIOVLEN 16
    311 
    312 #define MAXGETHOSTSTRUCT 1024
    313 
    314 #define FD_READ_BIT 0
    315 #define FD_READ (1 << FD_READ_BIT)
    316 
    317 #define FD_WRITE_BIT 1
    318 #define FD_WRITE (1 << FD_WRITE_BIT)
    319 
    320 #define FD_OOB_BIT 2
    321 #define FD_OOB (1 << FD_OOB_BIT)
    322 
    323 #define FD_ACCEPT_BIT 3
    324 #define FD_ACCEPT (1 << FD_ACCEPT_BIT)
    325 
    326 #define FD_CONNECT_BIT 4
    327 #define FD_CONNECT (1 << FD_CONNECT_BIT)
    328 
    329 #define FD_CLOSE_BIT 5
    330 #define FD_CLOSE (1 << FD_CLOSE_BIT)
    331 
    332 #define FD_QOS_BIT 6
    333 #define FD_QOS (1 << FD_QOS_BIT)
    334 
    335 #define FD_GROUP_QOS_BIT 7
    336 #define FD_GROUP_QOS (1 << FD_GROUP_QOS_BIT)
    337 
    338 #define FD_ROUTING_INTERFACE_CHANGE_BIT 8
    339 #define FD_ROUTING_INTERFACE_CHANGE (1 << FD_ROUTING_INTERFACE_CHANGE_BIT)
    340 
    341 #define FD_ADDRESS_LIST_CHANGE_BIT 9
    342 #define FD_ADDRESS_LIST_CHANGE (1 << FD_ADDRESS_LIST_CHANGE_BIT)
    343 
    344 #define FD_MAX_EVENTS 10
    345 #define FD_ALL_EVENTS ((1 << FD_MAX_EVENTS) - 1)
    346 
    347 #include <psdk_inc/_wsa_errnos.h>
    348 
    349 #define WSAEVENT HANDLE
    350 #define LPWSAEVENT LPHANDLE
    351 #define WSAOVERLAPPED OVERLAPPED
    352 
    353   typedef struct _OVERLAPPED *LPWSAOVERLAPPED;
    354 
    355 #define WSA_IO_PENDING (ERROR_IO_PENDING)
    356 #define WSA_IO_INCOMPLETE (ERROR_IO_INCOMPLETE)
    357 #define WSA_INVALID_HANDLE (ERROR_INVALID_HANDLE)
    358 #define WSA_INVALID_PARAMETER (ERROR_INVALID_PARAMETER)
    359 #define WSA_NOT_ENOUGH_MEMORY (ERROR_NOT_ENOUGH_MEMORY)
    360 #define WSA_OPERATION_ABORTED (ERROR_OPERATION_ABORTED)
    361 
    362 #define WSA_INVALID_EVENT ((WSAEVENT)NULL)
    363 #define WSA_MAXIMUM_WAIT_EVENTS (MAXIMUM_WAIT_OBJECTS)
    364 #define WSA_WAIT_FAILED (WAIT_FAILED)
    365 #define WSA_WAIT_EVENT_0 (WAIT_OBJECT_0)
    366 #define WSA_WAIT_IO_COMPLETION (WAIT_IO_COMPLETION)
    367 #define WSA_WAIT_TIMEOUT (WAIT_TIMEOUT)
    368 #define WSA_INFINITE (INFINITE)
    369 
    370   typedef struct _WSABUF {
    371     u_long len;
    372     char *buf;
    373   } WSABUF,*LPWSABUF;
    374 
    375 #include <qos.h>
    376 
    377   typedef struct _QualityOfService {
    378     FLOWSPEC SendingFlowspec;
    379     FLOWSPEC ReceivingFlowspec;
    380     WSABUF ProviderSpecific;
    381   } QOS,*LPQOS;
    382 
    383 #define CF_ACCEPT 0x0000
    384 #define CF_REJECT 0x0001
    385 #define CF_DEFER 0x0002
    386 
    387 #define SD_RECEIVE 0x00
    388 #define SD_SEND 0x01
    389 #define SD_BOTH 0x02
    390 
    391 typedef unsigned int GROUP;
    392 
    393 #define SG_UNCONSTRAINED_GROUP 0x01
    394 #define SG_CONSTRAINED_GROUP 0x02
    395 
    396   typedef struct _WSANETWORKEVENTS {
    397     __LONG32 lNetworkEvents;
    398     int iErrorCode[FD_MAX_EVENTS];
    399   } WSANETWORKEVENTS,*LPWSANETWORKEVENTS;
    400 
    401 #ifndef GUID_DEFINED
    402 #include <guiddef.h>
    403 #endif
    404 
    405 #define MAX_PROTOCOL_CHAIN 7
    406 
    407 #define BASE_PROTOCOL 1
    408 #define LAYERED_PROTOCOL 0
    409 
    410   typedef struct _WSAPROTOCOLCHAIN {
    411     int ChainLen;
    412 
    413     DWORD ChainEntries[MAX_PROTOCOL_CHAIN];
    414   } WSAPROTOCOLCHAIN,*LPWSAPROTOCOLCHAIN;
    415 
    416 #define WSAPROTOCOL_LEN 255
    417 
    418   typedef struct _WSAPROTOCOL_INFOA {
    419     DWORD dwServiceFlags1;
    420     DWORD dwServiceFlags2;
    421     DWORD dwServiceFlags3;
    422     DWORD dwServiceFlags4;
    423     DWORD dwProviderFlags;
    424     GUID ProviderId;
    425     DWORD dwCatalogEntryId;
    426     WSAPROTOCOLCHAIN ProtocolChain;
    427     int iVersion;
    428     int iAddressFamily;
    429     int iMaxSockAddr;
    430     int iMinSockAddr;
    431     int iSocketType;
    432     int iProtocol;
    433     int iProtocolMaxOffset;
    434     int iNetworkByteOrder;
    435     int iSecurityScheme;
    436     DWORD dwMessageSize;
    437     DWORD dwProviderReserved;
    438     CHAR szProtocol[WSAPROTOCOL_LEN+1];
    439   } WSAPROTOCOL_INFOA,*LPWSAPROTOCOL_INFOA;
    440 
    441   typedef struct _WSAPROTOCOL_INFOW {
    442     DWORD dwServiceFlags1;
    443     DWORD dwServiceFlags2;
    444     DWORD dwServiceFlags3;
    445     DWORD dwServiceFlags4;
    446     DWORD dwProviderFlags;
    447     GUID ProviderId;
    448     DWORD dwCatalogEntryId;
    449     WSAPROTOCOLCHAIN ProtocolChain;
    450     int iVersion;
    451     int iAddressFamily;
    452     int iMaxSockAddr;
    453     int iMinSockAddr;
    454     int iSocketType;
    455     int iProtocol;
    456     int iProtocolMaxOffset;
    457     int iNetworkByteOrder;
    458     int iSecurityScheme;
    459     DWORD dwMessageSize;
    460     DWORD dwProviderReserved;
    461     WCHAR szProtocol[WSAPROTOCOL_LEN+1];
    462   } WSAPROTOCOL_INFOW,*LPWSAPROTOCOL_INFOW;
    463 
    464   __MINGW_TYPEDEF_AW(WSAPROTOCOL_INFO)
    465   __MINGW_TYPEDEF_AW(LPWSAPROTOCOL_INFO)
    466 
    467 #define PFL_MULTIPLE_PROTO_ENTRIES 0x00000001
    468 #define PFL_RECOMMENDED_PROTO_ENTRY 0x00000002
    469 #define PFL_HIDDEN 0x00000004
    470 #define PFL_MATCHES_PROTOCOL_ZERO 0x00000008
    471 
    472 #define XP1_CONNECTIONLESS 0x00000001
    473 #define XP1_GUARANTEED_DELIVERY 0x00000002
    474 #define XP1_GUARANTEED_ORDER 0x00000004
    475 #define XP1_MESSAGE_ORIENTED 0x00000008
    476 #define XP1_PSEUDO_STREAM 0x00000010
    477 #define XP1_GRACEFUL_CLOSE 0x00000020
    478 #define XP1_EXPEDITED_DATA 0x00000040
    479 #define XP1_CONNECT_DATA 0x00000080
    480 #define XP1_DISCONNECT_DATA 0x00000100
    481 #define XP1_SUPPORT_BROADCAST 0x00000200
    482 #define XP1_SUPPORT_MULTIPOINT 0x00000400
    483 #define XP1_MULTIPOINT_CONTROL_PLANE 0x00000800
    484 #define XP1_MULTIPOINT_DATA_PLANE 0x00001000
    485 #define XP1_QOS_SUPPORTED 0x00002000
    486 #define XP1_INTERRUPT 0x00004000
    487 #define XP1_UNI_SEND 0x00008000
    488 #define XP1_UNI_RECV 0x00010000
    489 #define XP1_IFS_HANDLES 0x00020000
    490 #define XP1_PARTIAL_MESSAGE 0x00040000
    491 
    492 #define BIGENDIAN 0x0000
    493 #define LITTLEENDIAN 0x0001
    494 
    495 #define SECURITY_PROTOCOL_NONE 0x0000
    496 
    497 #define JL_SENDER_ONLY 0x01
    498 #define JL_RECEIVER_ONLY 0x02
    499 #define JL_BOTH 0x04
    500 
    501 #define WSA_FLAG_OVERLAPPED 0x01
    502 #define WSA_FLAG_MULTIPOINT_C_ROOT 0x02
    503 #define WSA_FLAG_MULTIPOINT_C_LEAF 0x04
    504 #define WSA_FLAG_MULTIPOINT_D_ROOT 0x08
    505 #define WSA_FLAG_MULTIPOINT_D_LEAF 0x10
    506 
    507 #define IOC_UNIX 0x00000000
    508 #define IOC_WS2 0x08000000
    509 #define IOC_PROTOCOL 0x10000000
    510 #define IOC_VENDOR 0x18000000
    511 
    512 #define _WSAIO(x,y) (IOC_VOID|(x)|(y))
    513 #define _WSAIOR(x,y) (IOC_OUT|(x)|(y))
    514 #define _WSAIOW(x,y) (IOC_IN|(x)|(y))
    515 #define _WSAIORW(x,y) (IOC_INOUT|(x)|(y))
    516 
    517 #define SIO_ASSOCIATE_HANDLE _WSAIOW(IOC_WS2,1)
    518 #define SIO_ENABLE_CIRCULAR_QUEUEING _WSAIO(IOC_WS2,2)
    519 #define SIO_FIND_ROUTE _WSAIOR(IOC_WS2,3)
    520 #define SIO_FLUSH _WSAIO(IOC_WS2,4)
    521 #define SIO_GET_BROADCAST_ADDRESS _WSAIOR(IOC_WS2,5)
    522 #define SIO_GET_EXTENSION_FUNCTION_POINTER _WSAIORW(IOC_WS2,6)
    523 #define SIO_GET_QOS _WSAIORW(IOC_WS2,7)
    524 #define SIO_GET_GROUP_QOS _WSAIORW(IOC_WS2,8)
    525 #define SIO_MULTIPOINT_LOOPBACK _WSAIOW(IOC_WS2,9)
    526 #define SIO_MULTICAST_SCOPE _WSAIOW(IOC_WS2,10)
    527 #define SIO_SET_QOS _WSAIOW(IOC_WS2,11)
    528 #define SIO_SET_GROUP_QOS _WSAIOW(IOC_WS2,12)
    529 #define SIO_TRANSLATE_HANDLE _WSAIORW(IOC_WS2,13)
    530 #define SIO_ROUTING_INTERFACE_QUERY _WSAIORW(IOC_WS2,20)
    531 #define SIO_ROUTING_INTERFACE_CHANGE _WSAIOW(IOC_WS2,21)
    532 #define SIO_ADDRESS_LIST_QUERY _WSAIOR(IOC_WS2,22)
    533 #define SIO_ADDRESS_LIST_CHANGE _WSAIO(IOC_WS2,23)
    534 #define SIO_QUERY_TARGET_PNP_HANDLE _WSAIOR(IOC_WS2,24)
    535 #define SIO_ADDRESS_LIST_SORT _WSAIORW(IOC_WS2,25)
    536 #if (_WIN32_WINNT >= 0x0600)
    537 #define SIO_RESERVED_1 _WSAIOW(IOC_WS2,26)
    538 #define SIO_RESERVED_2 _WSAIOW(IOC_WS2,33)
    539 #endif /* _WIN32_WINNT >= 0x0600 */
    540 
    541   typedef int (CALLBACK *LPCONDITIONPROC)(LPWSABUF lpCallerId,LPWSABUF lpCallerData,LPQOS lpSQOS,LPQOS lpGQOS,LPWSABUF lpCalleeId,LPWSABUF lpCalleeData,GROUP *g,DWORD_PTR dwCallbackData);
    542   typedef void (CALLBACK *LPWSAOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwError,DWORD cbTransferred,LPWSAOVERLAPPED lpOverlapped,DWORD dwFlags);
    543 
    544 #define SIO_NSP_NOTIFY_CHANGE _WSAIOW(IOC_WS2,25)
    545 
    546   typedef enum _WSACOMPLETIONTYPE {
    547     NSP_NOTIFY_IMMEDIATELY = 0,
    548     NSP_NOTIFY_HWND,
    549     NSP_NOTIFY_EVENT,
    550     NSP_NOTIFY_PORT,
    551     NSP_NOTIFY_APC
    552   } WSACOMPLETIONTYPE,*PWSACOMPLETIONTYPE,*LPWSACOMPLETIONTYPE;
    553 
    554   typedef struct _WSACOMPLETION {
    555     WSACOMPLETIONTYPE Type;
    556     union {
    557       struct {
    558 	HWND hWnd;
    559 	UINT uMsg;
    560 	WPARAM context;
    561       } WindowMessage;
    562       struct {
    563 	LPWSAOVERLAPPED lpOverlapped;
    564       } Event;
    565       struct {
    566 	LPWSAOVERLAPPED lpOverlapped;
    567 	LPWSAOVERLAPPED_COMPLETION_ROUTINE lpfnCompletionProc;
    568       } Apc;
    569       struct {
    570 	LPWSAOVERLAPPED lpOverlapped;
    571 	HANDLE hPort;
    572 	ULONG_PTR Key;
    573       } Port;
    574     } Parameters;
    575   } WSACOMPLETION,*PWSACOMPLETION,*LPWSACOMPLETION;
    576 
    577 #define TH_NETDEV 0x00000001
    578 #define TH_TAPI 0x00000002
    579 
    580   typedef struct sockaddr_storage SOCKADDR_STORAGE;
    581   typedef struct sockaddr_storage *PSOCKADDR_STORAGE;
    582   typedef struct sockaddr_storage *LPSOCKADDR_STORAGE;
    583   typedef u_short ADDRESS_FAMILY;
    584 
    585 #ifndef _tagBLOB_DEFINED
    586 #define _tagBLOB_DEFINED
    587 #define _BLOB_DEFINED
    588 #define _LPBLOB_DEFINED
    589   typedef struct _BLOB {
    590     ULONG cbSize;
    591     BYTE *pBlobData;
    592   } BLOB,*LPBLOB;
    593 #endif /* _tagBLOB_DEFINED */
    594 
    595 #define SERVICE_MULTIPLE (0x00000001)
    596 
    597 #define NS_ALL (0)
    598 
    599 #define NS_SAP (1)
    600 #define NS_NDS (2)
    601 #define NS_PEER_BROWSE (3)
    602 #define NS_SLP (5)
    603 #define NS_DHCP (6)
    604 
    605 #define NS_TCPIP_LOCAL (10)
    606 #define NS_TCPIP_HOSTS (11)
    607 #define NS_DNS (12)
    608 #define NS_NETBT (13)
    609 #define NS_WINS (14)
    610 #define NS_NLA (15)
    611 
    612 #define NS_NBP (20)
    613 
    614 #define NS_MS (30)
    615 #define NS_STDA (31)
    616 #define NS_NTDS (32)
    617 
    618 #define NS_X500 (40)
    619 #define NS_NIS (41)
    620 #define NS_NISPLUS (42)
    621 
    622 #define NS_WRQ (50)
    623 
    624 #define NS_NETDES (60)
    625 
    626 #define RES_UNUSED_1 (0x00000001)
    627 #define RES_FLUSH_CACHE (0x00000002)
    628 #ifndef RES_SERVICE
    629 #define RES_SERVICE (0x00000004)
    630 #endif
    631 
    632 #define SERVICE_TYPE_VALUE_IPXPORTA "IpxSocket"
    633 #define SERVICE_TYPE_VALUE_IPXPORTW L"IpxSocket"
    634 #define SERVICE_TYPE_VALUE_SAPIDA "SapId"
    635 #define SERVICE_TYPE_VALUE_SAPIDW L"SapId"
    636 
    637 #define SERVICE_TYPE_VALUE_TCPPORTA "TcpPort"
    638 #define SERVICE_TYPE_VALUE_TCPPORTW L"TcpPort"
    639 
    640 #define SERVICE_TYPE_VALUE_UDPPORTA "UdpPort"
    641 #define SERVICE_TYPE_VALUE_UDPPORTW L"UdpPort"
    642 
    643 #define SERVICE_TYPE_VALUE_OBJECTIDA "ObjectId"
    644 #define SERVICE_TYPE_VALUE_OBJECTIDW L"ObjectId"
    645 
    646 #define SERVICE_TYPE_VALUE_SAPID __MINGW_NAME_AW(SERVICE_TYPE_VALUE_SAPID)
    647 #define SERVICE_TYPE_VALUE_TCPPORT __MINGW_NAME_AW(SERVICE_TYPE_VALUE_TCPPORT)
    648 #define SERVICE_TYPE_VALUE_UDPPORT __MINGW_NAME_AW(SERVICE_TYPE_VALUE_UDPPORT)
    649 #define SERVICE_TYPE_VALUE_OBJECTID __MINGW_NAME_AW(SERVICE_TYPE_VALUE_OBJECTID)
    650 
    651 #ifndef __CSADDR_DEFINED__
    652 #define __CSADDR_DEFINED__
    653 
    654   typedef struct _SOCKET_ADDRESS {
    655     LPSOCKADDR lpSockaddr;
    656     INT iSockaddrLength;
    657   } SOCKET_ADDRESS,*PSOCKET_ADDRESS,*LPSOCKET_ADDRESS;
    658 
    659   typedef struct _CSADDR_INFO {
    660     SOCKET_ADDRESS LocalAddr;
    661     SOCKET_ADDRESS RemoteAddr;
    662     INT iSocketType;
    663     INT iProtocol;
    664   } CSADDR_INFO,*PCSADDR_INFO,*LPCSADDR_INFO;
    665 #endif /* __CSADDR_DEFINED__ */
    666 
    667   typedef struct _SOCKET_ADDRESS_LIST {
    668     INT iAddressCount;
    669     SOCKET_ADDRESS Address[1];
    670   } SOCKET_ADDRESS_LIST,*PSOCKET_ADDRESS_LIST,*LPSOCKET_ADDRESS_LIST;
    671 
    672   typedef struct _AFPROTOCOLS {
    673     INT iAddressFamily;
    674     INT iProtocol;
    675   } AFPROTOCOLS,*PAFPROTOCOLS,*LPAFPROTOCOLS;
    676 
    677   typedef enum _WSAEcomparator {
    678     COMP_EQUAL = 0,
    679     COMP_NOTLESS
    680   } WSAECOMPARATOR,*PWSAECOMPARATOR,*LPWSAECOMPARATOR;
    681 
    682   typedef struct _WSAVersion {
    683     DWORD dwVersion;
    684     WSAECOMPARATOR ecHow;
    685   } WSAVERSION,*PWSAVERSION,*LPWSAVERSION;
    686 
    687   typedef struct _WSAQuerySetA {
    688     DWORD dwSize;
    689     LPSTR lpszServiceInstanceName;
    690     LPGUID lpServiceClassId;
    691     LPWSAVERSION lpVersion;
    692     LPSTR lpszComment;
    693     DWORD dwNameSpace;
    694     LPGUID lpNSProviderId;
    695     LPSTR lpszContext;
    696     DWORD dwNumberOfProtocols;
    697     LPAFPROTOCOLS lpafpProtocols;
    698     LPSTR lpszQueryString;
    699     DWORD dwNumberOfCsAddrs;
    700     LPCSADDR_INFO lpcsaBuffer;
    701     DWORD dwOutputFlags;
    702     LPBLOB lpBlob;
    703   } WSAQUERYSETA,*PWSAQUERYSETA,*LPWSAQUERYSETA;
    704 
    705   typedef struct _WSAQuerySetW {
    706     DWORD dwSize;
    707     LPWSTR lpszServiceInstanceName;
    708     LPGUID lpServiceClassId;
    709     LPWSAVERSION lpVersion;
    710     LPWSTR lpszComment;
    711     DWORD dwNameSpace;
    712     LPGUID lpNSProviderId;
    713     LPWSTR lpszContext;
    714     DWORD dwNumberOfProtocols;
    715     LPAFPROTOCOLS lpafpProtocols;
    716     LPWSTR lpszQueryString;
    717     DWORD dwNumberOfCsAddrs;
    718     LPCSADDR_INFO lpcsaBuffer;
    719     DWORD dwOutputFlags;
    720     LPBLOB lpBlob;
    721   } WSAQUERYSETW,*PWSAQUERYSETW,*LPWSAQUERYSETW;
    722 
    723   __MINGW_TYPEDEF_AW(WSAQUERYSET)
    724   __MINGW_TYPEDEF_AW(PWSAQUERYSET)
    725   __MINGW_TYPEDEF_AW(LPWSAQUERYSET)
    726 
    727 #define LUP_DEEP 0x0001
    728 #define LUP_CONTAINERS 0x0002
    729 #define LUP_NOCONTAINERS 0x0004
    730 #define LUP_NEAREST 0x0008
    731 #define LUP_RETURN_NAME 0x0010
    732 #define LUP_RETURN_TYPE 0x0020
    733 #define LUP_RETURN_VERSION 0x0040
    734 #define LUP_RETURN_COMMENT 0x0080
    735 #define LUP_RETURN_ADDR 0x0100
    736 #define LUP_RETURN_BLOB 0x0200
    737 #define LUP_RETURN_ALIASES 0x0400
    738 #define LUP_RETURN_QUERY_STRING 0x0800
    739 #define LUP_RETURN_ALL 0x0FF0
    740 #define LUP_RES_SERVICE 0x8000
    741 
    742 #define LUP_FLUSHCACHE 0x1000
    743 #define LUP_FLUSHPREVIOUS 0x2000
    744 
    745 #define LUP_NON_AUTHORITATIVE 0x4000
    746 #define LUP_SECURE 0x8000
    747 #define LUP_RETURN_PREFERRED_NAMES 0x10000
    748 
    749 #define LUP_ADDRCONFIG 0x100000
    750 #define LUP_DUAL_ADDR 0x200000
    751 #define LUP_FILESERVER 0x400000
    752 
    753 #define LUP_RES_RESERVICE 0x8000 /* FIXME: not in PSDK anymore?? */
    754 
    755 #define RESULT_IS_ALIAS 0x0001
    756 #define RESULT_IS_ADDED 0x0010
    757 #define RESULT_IS_CHANGED 0x0020
    758 #define RESULT_IS_DELETED 0x0040
    759 
    760   typedef enum _WSAESETSERVICEOP {
    761     RNRSERVICE_REGISTER = 0,
    762     RNRSERVICE_DEREGISTER,
    763     RNRSERVICE_DELETE
    764   } WSAESETSERVICEOP,*PWSAESETSERVICEOP,*LPWSAESETSERVICEOP;
    765 
    766   typedef struct _WSANSClassInfoA {
    767     LPSTR lpszName;
    768     DWORD dwNameSpace;
    769     DWORD dwValueType;
    770     DWORD dwValueSize;
    771     LPVOID lpValue;
    772   } WSANSCLASSINFOA,*PWSANSCLASSINFOA,*LPWSANSCLASSINFOA;
    773 
    774   typedef struct _WSANSClassInfoW {
    775     LPWSTR lpszName;
    776     DWORD dwNameSpace;
    777     DWORD dwValueType;
    778     DWORD dwValueSize;
    779     LPVOID lpValue;
    780   } WSANSCLASSINFOW,*PWSANSCLASSINFOW,*LPWSANSCLASSINFOW;
    781 
    782   __MINGW_TYPEDEF_AW(WSANSCLASSINFO)
    783   __MINGW_TYPEDEF_AW(PWSANSCLASSINFO)
    784   __MINGW_TYPEDEF_AW(LPWSANSCLASSINFO)
    785 
    786   typedef struct _WSAServiceClassInfoA {
    787     LPGUID lpServiceClassId;
    788     LPSTR lpszServiceClassName;
    789     DWORD dwCount;
    790     LPWSANSCLASSINFOA lpClassInfos;
    791   } WSASERVICECLASSINFOA,*PWSASERVICECLASSINFOA,*LPWSASERVICECLASSINFOA;
    792 
    793   typedef struct _WSAServiceClassInfoW {
    794     LPGUID lpServiceClassId;
    795     LPWSTR lpszServiceClassName;
    796     DWORD dwCount;
    797     LPWSANSCLASSINFOW lpClassInfos;
    798   } WSASERVICECLASSINFOW,*PWSASERVICECLASSINFOW,*LPWSASERVICECLASSINFOW;
    799 
    800   __MINGW_TYPEDEF_AW(WSASERVICECLASSINFO)
    801   __MINGW_TYPEDEF_AW(PWSASERVICECLASSINFO)
    802   __MINGW_TYPEDEF_AW(LPWSASERVICECLASSINFO)
    803 
    804   typedef struct _WSANAMESPACE_INFOA {
    805     GUID NSProviderId;
    806     DWORD dwNameSpace;
    807     WINBOOL fActive;
    808     DWORD dwVersion;
    809     LPSTR lpszIdentifier;
    810   } WSANAMESPACE_INFOA,*PWSANAMESPACE_INFOA,*LPWSANAMESPACE_INFOA;
    811 
    812   typedef struct _WSANAMESPACE_INFOW {
    813     GUID NSProviderId;
    814     DWORD dwNameSpace;
    815     WINBOOL fActive;
    816     DWORD dwVersion;
    817     LPWSTR lpszIdentifier;
    818   } WSANAMESPACE_INFOW,*PWSANAMESPACE_INFOW,*LPWSANAMESPACE_INFOW;
    819 
    820   __MINGW_TYPEDEF_AW(WSANAMESPACE_INFO)
    821   __MINGW_TYPEDEF_AW(PWSANAMESPACE_INFO)
    822   __MINGW_TYPEDEF_AW(LPWSANAMESPACE_INFO)
    823 
    824 /* FIXME: WSAMSG originally lived in mswsock.h,
    825  * newer SDKs moved it into a new ws2def.h. for
    826  * now we keep it here. */
    827   typedef struct _WSAMSG {
    828     LPSOCKADDR name;
    829     INT namelen;
    830     LPWSABUF lpBuffers;
    831     DWORD dwBufferCount;
    832     WSABUF Control;
    833     DWORD dwFlags;
    834   } WSAMSG,*PWSAMSG,*LPWSAMSG;
    835 
    836 #if INCL_WINSOCK_API_TYPEDEFS
    837 #define LPFN_WSADUPLICATESOCKET __MINGW_NAME_AW(LPFN_WSADUPLICATESOCKET)
    838 #define LPFN_WSAENUMPROTOCOLS __MINGW_NAME_AW(LPFN_WSAENUMPROTOCOLS)
    839 #define LPFN_WSASOCKET __MINGW_NAME_AW(LPFN_WSASOCKET)
    840 #define LPFN_WSAADDRESSTOSTRING __MINGW_NAME_AW(LPFN_WSAADDRESSTOSTRING)
    841 #define LPFN_WSASTRINGTOADDRESS __MINGW_NAME_AW(LPFN_WSASTRINGTOADDRESS)
    842 #define LPFN_WSALOOKUPSERVICEBEGIN __MINGW_NAME_AW(LPFN_WSALOOKUPSERVICEBEGIN)
    843 #define LPFN_WSALOOKUPSERVICENEXT __MINGW_NAME_AW(LPFN_WSALOOKUPSERVICENEXT)
    844 #define LPFN_WSAINSTALLSERVICECLASS __MINGW_NAME_AW(LPFN_WSAINSTALLSERVICECLASS)
    845 #define LPFN_WSAGETSERVICECLASSINFO __MINGW_NAME_AW(LPFN_WSAGETSERVICECLASSINFO)
    846 #define LPFN_WSAENUMNAMESPACEPROVIDERS __MINGW_NAME_AW(LPFN_WSAENUMNAMESPACEPROVIDERS)
    847 #define LPFN_WSAGETSERVICECLASSNAMEBYCLASSID __MINGW_NAME_AW(LPFN_WSAGETSERVICECLASSNAMEBYCLASSID)
    848 #define LPFN_WSASETSERVICE __MINGW_NAME_AW(LPFN_WSASETSERVICE)
    849 
    850   typedef SOCKET (WSAAPI *LPFN_ACCEPT)(SOCKET s,struct sockaddr *addr,int *addrlen);
    851   typedef int (WSAAPI *LPFN_BIND)(SOCKET s,const struct sockaddr *name,int namelen);
    852   typedef int (WSAAPI *LPFN_CLOSESOCKET)(SOCKET s);
    853   typedef int (WSAAPI *LPFN_CONNECT)(SOCKET s,const struct sockaddr *name,int namelen);
    854   typedef int (WSAAPI *LPFN_IOCTLSOCKET)(SOCKET s,__LONG32 cmd,u_long *argp);
    855   typedef int (WSAAPI *LPFN_GETPEERNAME)(SOCKET s,struct sockaddr *name,int *namelen);
    856   typedef int (WSAAPI *LPFN_GETSOCKNAME)(SOCKET s,struct sockaddr *name,int *namelen);
    857   typedef int (WSAAPI *LPFN_GETSOCKOPT)(SOCKET s,int level,int optname,char *optval,int *optlen);
    858   typedef u_long (WSAAPI *LPFN_HTONL)(u_long hostlong);
    859   typedef u_short (WSAAPI *LPFN_HTONS)(u_short hostshort);
    860   typedef unsigned __LONG32 (WSAAPI *LPFN_INET_ADDR)(const char *cp);
    861   typedef char *(WSAAPI *LPFN_INET_NTOA)(struct in_addr in);
    862   typedef int (WSAAPI *LPFN_LISTEN)(SOCKET s,int backlog);
    863   typedef u_long (WSAAPI *LPFN_NTOHL)(u_long netlong);
    864   typedef u_short (WSAAPI *LPFN_NTOHS)(u_short netshort);
    865   typedef int (WSAAPI *LPFN_RECV)(SOCKET s,char *buf,int len,int flags);
    866   typedef int (WSAAPI *LPFN_RECVFROM)(SOCKET s,char *buf,int len,int flags,struct sockaddr *from,int *fromlen);
    867   typedef int (WSAAPI *LPFN_SELECT)(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
    868   typedef int (WSAAPI *LPFN_SEND)(SOCKET s,const char *buf,int len,int flags);
    869   typedef int (WSAAPI *LPFN_SENDTO)(SOCKET s,const char *buf,int len,int flags,const struct sockaddr *to,int tolen);
    870   typedef int (WSAAPI *LPFN_SETSOCKOPT)(SOCKET s,int level,int optname,const char *optval,int optlen);
    871   typedef int (WSAAPI *LPFN_SHUTDOWN)(SOCKET s,int how);
    872   typedef SOCKET (WSAAPI *LPFN_SOCKET)(int af,int type,int protocol);
    873   typedef struct hostent *(WSAAPI *LPFN_GETHOSTBYADDR)(const char *addr,int len,int type);
    874   typedef struct hostent *(WSAAPI *LPFN_GETHOSTBYNAME)(const char *name);
    875   typedef int (WSAAPI *LPFN_GETHOSTNAME)(char *name,int namelen);
    876   typedef struct servent *(WSAAPI *LPFN_GETSERVBYPORT)(int port,const char *proto);
    877   typedef struct servent *(WSAAPI *LPFN_GETSERVBYNAME)(const char *name,const char *proto);
    878   typedef struct protoent *(WSAAPI *LPFN_GETPROTOBYNUMBER)(int number);
    879   typedef struct protoent *(WSAAPI *LPFN_GETPROTOBYNAME)(const char *name);
    880   typedef int (WSAAPI *LPFN_WSASTARTUP)(WORD wVersionRequested,LPWSADATA lpWSAData);
    881   typedef int (WSAAPI *LPFN_WSACLEANUP)(void);
    882   typedef void (WSAAPI *LPFN_WSASETLASTERROR)(int iError);
    883   typedef int (WSAAPI *LPFN_WSAGETLASTERROR)(void);
    884   typedef WINBOOL (WSAAPI *LPFN_WSAISBLOCKING)(void);
    885   typedef int (WSAAPI *LPFN_WSAUNHOOKBLOCKINGHOOK)(void);
    886   typedef FARPROC (WSAAPI *LPFN_WSASETBLOCKINGHOOK)(FARPROC lpBlockFunc);
    887   typedef int (WSAAPI *LPFN_WSACANCELBLOCKINGCALL)(void);
    888   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETSERVBYNAME)(HWND hWnd,u_int wMsg,const char *name,const char *proto,char *buf,int buflen);
    889   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETSERVBYPORT)(HWND hWnd,u_int wMsg,int port,const char *proto,char *buf,int buflen);
    890   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETPROTOBYNAME)(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
    891   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETPROTOBYNUMBER)(HWND hWnd,u_int wMsg,int number,char *buf,int buflen);
    892   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETHOSTBYNAME)(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
    893   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETHOSTBYADDR)(HWND hWnd,u_int wMsg,const char *addr,int len,int type,char *buf,int buflen);
    894   typedef int (WSAAPI *LPFN_WSACANCELASYNCREQUEST)(HANDLE hAsyncTaskHandle);
    895   typedef int (WSAAPI *LPFN_WSAASYNCSELECT)(SOCKET s,HWND hWnd,u_int wMsg,__LONG32 lEvent);
    896   typedef SOCKET (WSAAPI *LPFN_WSAACCEPT)(SOCKET s,struct sockaddr *addr,LPINT addrlen,LPCONDITIONPROC lpfnCondition,DWORD_PTR dwCallbackData);
    897   typedef WINBOOL (WSAAPI *LPFN_WSACLOSEEVENT)(WSAEVENT hEvent);
    898   typedef int (WSAAPI *LPFN_WSACONNECT)(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS);
    899   typedef WSAEVENT (WSAAPI *LPFN_WSACREATEEVENT)(void);
    900   typedef int (WSAAPI *LPFN_WSADUPLICATESOCKETA)(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOA lpProtocolInfo);
    901   typedef int (WSAAPI *LPFN_WSADUPLICATESOCKETW)(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOW lpProtocolInfo);
    902   typedef int (WSAAPI *LPFN_WSAENUMNETWORKEVENTS)(SOCKET s,WSAEVENT hEventObject,LPWSANETWORKEVENTS lpNetworkEvents);
    903   typedef int (WSAAPI *LPFN_WSAENUMPROTOCOLSA)(LPINT lpiProtocols,LPWSAPROTOCOL_INFOA lpProtocolBuffer,LPDWORD lpdwBufferLength);
    904   typedef int (WSAAPI *LPFN_WSAENUMPROTOCOLSW)(LPINT lpiProtocols,LPWSAPROTOCOL_INFOW lpProtocolBuffer,LPDWORD lpdwBufferLength);
    905   typedef int (WSAAPI *LPFN_WSAEVENTSELECT)(SOCKET s,WSAEVENT hEventObject,__LONG32 lNetworkEvents);
    906   typedef WINBOOL (WSAAPI *LPFN_WSAGETOVERLAPPEDRESULT)(SOCKET s,LPWSAOVERLAPPED lpOverlapped,LPDWORD lpcbTransfer,WINBOOL fWait,LPDWORD lpdwFlags);
    907   typedef WINBOOL (WSAAPI *LPFN_WSAGETQOSBYNAME)(SOCKET s,LPWSABUF lpQOSName,LPQOS lpQOS);
    908   typedef int (WSAAPI *LPFN_WSAHTONL)(SOCKET s,u_long hostlong,u_long *lpnetlong);
    909   typedef int (WSAAPI *LPFN_WSAHTONS)(SOCKET s,u_short hostshort,u_short *lpnetshort);
    910   typedef int (WSAAPI *LPFN_WSAIOCTL)(SOCKET s,DWORD dwIoControlCode,LPVOID lpvInBuffer,DWORD cbInBuffer,LPVOID lpvOutBuffer,DWORD cbOutBuffer,LPDWORD lpcbBytesReturned,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    911   typedef SOCKET (WSAAPI *LPFN_WSAJOINLEAF)(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS,DWORD dwFlags);
    912   typedef int (WSAAPI *LPFN_WSANTOHL)(SOCKET s,u_long netlong,u_long *lphostlong);
    913   typedef int (WSAAPI *LPFN_WSANTOHS)(SOCKET s,u_short netshort,u_short *lphostshort);
    914   typedef int (WSAAPI *LPFN_WSARECV)(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    915   typedef int (WSAAPI *LPFN_WSARECVDISCONNECT)(SOCKET s,LPWSABUF lpInboundDisconnectData);
    916   typedef int (WSAAPI *LPFN_WSARECVFROM)(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,struct sockaddr *lpFrom,LPINT lpFromlen,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    917   typedef WINBOOL (WSAAPI *LPFN_WSARESETEVENT)(WSAEVENT hEvent);
    918   typedef int (WSAAPI *LPFN_WSASEND)(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesSent,DWORD dwFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    919   typedef int (WSAAPI *LPFN_WSASENDDISCONNECT)(SOCKET s,LPWSABUF lpOutboundDisconnectData);
    920   typedef int (WSAAPI *LPFN_WSASENDTO)(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesSent,DWORD dwFlags,const struct sockaddr *lpTo,int iTolen,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    921   typedef WINBOOL (WSAAPI *LPFN_WSASETEVENT)(WSAEVENT hEvent);
    922   typedef SOCKET (WSAAPI *LPFN_WSASOCKETA)(int af,int type,int protocol,LPWSAPROTOCOL_INFOA lpProtocolInfo,GROUP g,DWORD dwFlags);
    923   typedef SOCKET (WSAAPI *LPFN_WSASOCKETW)(int af,int type,int protocol,LPWSAPROTOCOL_INFOW lpProtocolInfo,GROUP g,DWORD dwFlags);
    924   typedef DWORD (WSAAPI *LPFN_WSAWAITFORMULTIPLEEVENTS)(DWORD cEvents,const WSAEVENT *lphEvents,WINBOOL fWaitAll,DWORD dwTimeout,WINBOOL fAlertable);
    925   typedef INT (WSAAPI *LPFN_WSAADDRESSTOSTRINGA)(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
    926   typedef INT (WSAAPI *LPFN_WSAADDRESSTOSTRINGW)(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPWSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
    927   typedef INT (WSAAPI *LPFN_WSASTRINGTOADDRESSA)(LPSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
    928   typedef INT (WSAAPI *LPFN_WSASTRINGTOADDRESSW)(LPWSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
    929   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICEBEGINA)(LPWSAQUERYSETA lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
    930   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICEBEGINW)(LPWSAQUERYSETW lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
    931   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICENEXTA)(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETA lpqsResults);
    932   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICENEXTW)(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETW lpqsResults);
    933   typedef INT (WSAAPI *LPFN_WSANSPIOCTL)(HANDLE hLookup,DWORD dwControlCode,LPVOID lpvInBuffer,DWORD cbInBuffer,LPVOID lpvOutBuffer,DWORD cbOutBuffer,LPDWORD lpcbBytesReturned,LPWSACOMPLETION lpCompletion);
    934   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICEEND)(HANDLE hLookup);
    935   typedef INT (WSAAPI *LPFN_WSAINSTALLSERVICECLASSA)(LPWSASERVICECLASSINFOA lpServiceClassInfo);
    936   typedef INT (WSAAPI *LPFN_WSAINSTALLSERVICECLASSW)(LPWSASERVICECLASSINFOW lpServiceClassInfo);
    937   typedef INT (WSAAPI *LPFN_WSAREMOVESERVICECLASS)(LPGUID lpServiceClassId);
    938   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSINFOA)(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOA lpServiceClassInfo);
    939   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSINFOW)(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOW lpServiceClassInfo);
    940   typedef INT (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSA)(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOA lpnspBuffer);
    941   typedef INT (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSW)(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOW lpnspBuffer);
    942   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA)(LPGUID lpServiceClassId,LPSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
    943   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW)(LPGUID lpServiceClassId,LPWSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
    944   typedef INT (WSAAPI *LPFN_WSASETSERVICEA)(LPWSAQUERYSETA lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
    945   typedef INT (WSAAPI *LPFN_WSASETSERVICEW)(LPWSAQUERYSETW lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
    946   typedef INT (WSAAPI *LPFN_WSAPROVIDERCONFIGCHANGE)(LPHANDLE lpNotificationHandle,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    947 #endif
    948 
    949 #define WSADuplicateSocket __MINGW_NAME_AW(WSADuplicateSocket)
    950 #define WSAEnumProtocols __MINGW_NAME_AW(WSAEnumProtocols)
    951 #define WSAAddressToString __MINGW_NAME_AW(WSAAddressToString)
    952 #define WSASocket __MINGW_NAME_AW(WSASocket)
    953 #define WSAStringToAddress __MINGW_NAME_AW(WSAStringToAddress)
    954 #define WSALookupServiceBegin __MINGW_NAME_AW(WSALookupServiceBegin)
    955 #define WSALookupServiceNext __MINGW_NAME_AW(WSALookupServiceNext)
    956 #define WSAInstallServiceClass __MINGW_NAME_AW(WSAInstallServiceClass)
    957 #define WSAGetServiceClassInfo __MINGW_NAME_AW(WSAGetServiceClassInfo)
    958 #define WSAEnumNameSpaceProviders __MINGW_NAME_AW(WSAEnumNameSpaceProviders)
    959 #define WSAGetServiceClassNameByClassId __MINGW_NAME_AW(WSAGetServiceClassNameByClassId)
    960 #define WSASetService __MINGW_NAME_AW(WSASetService)
    961 
    962 #ifndef __WINSOCK_WS1_SHARED
    963 /* these 46 functions have the same prototypes as in winsock2 */
    964   WINSOCK_API_LINKAGE SOCKET WSAAPI accept(SOCKET s,struct sockaddr *addr,int *addrlen);
    965   WINSOCK_API_LINKAGE int WSAAPI bind(SOCKET s,const struct sockaddr *name,int namelen);
    966   WINSOCK_API_LINKAGE int WSAAPI closesocket(SOCKET s);
    967   WINSOCK_API_LINKAGE int WSAAPI connect(SOCKET s,const struct sockaddr *name,int namelen);
    968   WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
    969   WINSOCK_API_LINKAGE int WSAAPI getpeername(SOCKET s,struct sockaddr *name,int *namelen);
    970   WINSOCK_API_LINKAGE int WSAAPI getsockname(SOCKET s,struct sockaddr *name,int *namelen);
    971   WINSOCK_API_LINKAGE int WSAAPI getsockopt(SOCKET s,int level,int optname,char *optval,int *optlen);
    972 #ifndef __INSIDE_CYGWIN__
    973   WINSOCK_API_LINKAGE u_long WSAAPI htonl(u_long hostlong);
    974   WINSOCK_API_LINKAGE u_short WSAAPI htons(u_short hostshort);
    975 #endif /* !__INSIDE_CYGWIN__ */
    976   WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);
    977   WINSOCK_API_LINKAGE char *WSAAPI inet_ntoa(struct in_addr in);
    978   WINSOCK_API_LINKAGE int WSAAPI listen(SOCKET s,int backlog);
    979 #ifndef __INSIDE_CYGWIN__
    980   WINSOCK_API_LINKAGE u_long WSAAPI ntohl(u_long netlong);
    981   WINSOCK_API_LINKAGE u_short WSAAPI ntohs(u_short netshort);
    982 #endif /* !__INSIDE_CYGWIN__ */
    983   WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags);
    984   WINSOCK_API_LINKAGE int WSAAPI recvfrom(SOCKET s,char *buf,int len,int flags,struct sockaddr *from,int *fromlen);
    985 #ifndef __INSIDE_CYGWIN__
    986   WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
    987 #endif /* !__INSIDE_CYGWIN__ */
    988   WINSOCK_API_LINKAGE int WSAAPI send(SOCKET s,const char *buf,int len,int flags);
    989   WINSOCK_API_LINKAGE int WSAAPI sendto(SOCKET s,const char *buf,int len,int flags,const struct sockaddr *to,int tolen);
    990   WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int optname,const char *optval,int optlen);
    991   WINSOCK_API_LINKAGE int WSAAPI shutdown(SOCKET s,int how);
    992   WINSOCK_API_LINKAGE SOCKET WSAAPI socket(int af,int type,int protocol);
    993   WINSOCK_API_LINKAGE struct hostent *WSAAPI gethostbyaddr(const char *addr,int len,int type);
    994   WINSOCK_API_LINKAGE struct hostent *WSAAPI gethostbyname(const char *name);
    995   WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen);
    996   WINSOCK_API_LINKAGE struct servent *WSAAPI getservbyport(int port,const char *proto);
    997   WINSOCK_API_LINKAGE struct servent *WSAAPI getservbyname(const char *name,const char *proto);
    998   WINSOCK_API_LINKAGE struct protoent *WSAAPI getprotobynumber(int number);
    999   WINSOCK_API_LINKAGE struct protoent *WSAAPI getprotobyname(const char *name);
   1000   WINSOCK_API_LINKAGE int WSAAPI WSAStartup(WORD wVersionRequested,LPWSADATA lpWSAData);
   1001   WINSOCK_API_LINKAGE int WSAAPI WSACleanup(void);
   1002   WINSOCK_API_LINKAGE void WSAAPI WSASetLastError(int iError);
   1003   WINSOCK_API_LINKAGE int WSAAPI WSAGetLastError(void);
   1004   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAIsBlocking(void);
   1005   WINSOCK_API_LINKAGE int WSAAPI WSAUnhookBlockingHook(void);
   1006   WINSOCK_API_LINKAGE FARPROC WSAAPI WSASetBlockingHook(FARPROC lpBlockFunc);
   1007   WINSOCK_API_LINKAGE int WSAAPI WSACancelBlockingCall(void);
   1008   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetServByName(HWND hWnd,u_int wMsg,const char *name,const char *proto,char *buf,int buflen);
   1009   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetServByPort(HWND hWnd,u_int wMsg,int port,const char *proto,char *buf,int buflen);
   1010   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetProtoByName(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
   1011   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetProtoByNumber(HWND hWnd,u_int wMsg,int number,char *buf,int buflen);
   1012   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetHostByName(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
   1013   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetHostByAddr(HWND hWnd,u_int wMsg,const char *addr,int len,int type,char *buf,int buflen);
   1014   WINSOCK_API_LINKAGE int WSAAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
   1015   WINSOCK_API_LINKAGE int WSAAPI WSAAsyncSelect(SOCKET s,HWND hWnd,u_int wMsg,__LONG32 lEvent);
   1016 #endif /* __WINSOCK_WS1_SHARED */
   1017   WINSOCK_API_LINKAGE SOCKET WSAAPI WSAAccept(SOCKET s,struct sockaddr *addr,LPINT addrlen,LPCONDITIONPROC lpfnCondition,DWORD_PTR dwCallbackData);
   1018   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSACloseEvent(WSAEVENT hEvent);
   1019   WINSOCK_API_LINKAGE int WSAAPI WSAConnect(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS);
   1020   WINSOCK_API_LINKAGE WSAEVENT WSAAPI WSACreateEvent(void);
   1021   WINSOCK_API_LINKAGE int WSAAPI WSADuplicateSocketA(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOA lpProtocolInfo);
   1022   WINSOCK_API_LINKAGE int WSAAPI WSADuplicateSocketW(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOW lpProtocolInfo);
   1023   WINSOCK_API_LINKAGE int WSAAPI WSAEnumNetworkEvents(SOCKET s,WSAEVENT hEventObject,LPWSANETWORKEVENTS lpNetworkEvents);
   1024   WINSOCK_API_LINKAGE int WSAAPI WSAEnumProtocolsA(LPINT lpiProtocols,LPWSAPROTOCOL_INFOA lpProtocolBuffer,LPDWORD lpdwBufferLength);
   1025   WINSOCK_API_LINKAGE int WSAAPI WSAEnumProtocolsW(LPINT lpiProtocols,LPWSAPROTOCOL_INFOW lpProtocolBuffer,LPDWORD lpdwBufferLength);
   1026   WINSOCK_API_LINKAGE int WSAAPI WSAEventSelect(SOCKET s,WSAEVENT hEventObject,__LONG32 lNetworkEvents);
   1027   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAGetOverlappedResult(SOCKET s,LPWSAOVERLAPPED lpOverlapped,LPDWORD lpcbTransfer,WINBOOL fWait,LPDWORD lpdwFlags);
   1028   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAGetQOSByName(SOCKET s,LPWSABUF lpQOSName,LPQOS lpQOS);
   1029   WINSOCK_API_LINKAGE int WSAAPI WSAHtonl(SOCKET s,u_long hostlong,u_long *lpnetlong);
   1030   WINSOCK_API_LINKAGE int WSAAPI WSAHtons(SOCKET s,u_short hostshort,u_short *lpnetshort);
   1031   WINSOCK_API_LINKAGE int WSAAPI WSAIoctl(SOCKET s,DWORD dwIoControlCode,LPVOID lpvInBuffer,DWORD cbInBuffer,LPVOID lpvOutBuffer,DWORD cbOutBuffer,LPDWORD lpcbBytesReturned,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1032   WINSOCK_API_LINKAGE SOCKET WSAAPI WSAJoinLeaf(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS,DWORD dwFlags);
   1033   WINSOCK_API_LINKAGE int WSAAPI WSANtohl(SOCKET s,u_long netlong,u_long *lphostlong);
   1034   WINSOCK_API_LINKAGE int WSAAPI WSANtohs(SOCKET s,u_short netshort,u_short *lphostshort);
   1035   WINSOCK_API_LINKAGE int WSAAPI WSARecv(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1036   WINSOCK_API_LINKAGE int WSAAPI WSARecvDisconnect(SOCKET s,LPWSABUF lpInboundDisconnectData);
   1037   WINSOCK_API_LINKAGE int WSAAPI WSARecvFrom(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,struct sockaddr *lpFrom,LPINT lpFromlen,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1038   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAResetEvent(WSAEVENT hEvent);
   1039   WINSOCK_API_LINKAGE int WSAAPI WSASend(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesSent,DWORD dwFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1040   WINSOCK_API_LINKAGE int WSAAPI WSASendDisconnect(SOCKET s,LPWSABUF lpOutboundDisconnectData);
   1041   WINSOCK_API_LINKAGE int WSAAPI WSASendTo(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesSent,DWORD dwFlags,const struct sockaddr *lpTo,int iTolen,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1042   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSASetEvent(WSAEVENT hEvent);
   1043   WINSOCK_API_LINKAGE SOCKET WSAAPI WSASocketA(int af,int type,int protocol,LPWSAPROTOCOL_INFOA lpProtocolInfo,GROUP g,DWORD dwFlags);
   1044   WINSOCK_API_LINKAGE SOCKET WSAAPI WSASocketW(int af,int type,int protocol,LPWSAPROTOCOL_INFOW lpProtocolInfo,GROUP g,DWORD dwFlags);
   1045   WINSOCK_API_LINKAGE DWORD WSAAPI WSAWaitForMultipleEvents(DWORD cEvents,const WSAEVENT *lphEvents,WINBOOL fWaitAll,DWORD dwTimeout,WINBOOL fAlertable);
   1046   WINSOCK_API_LINKAGE INT WSAAPI WSAAddressToStringA(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
   1047   WINSOCK_API_LINKAGE INT WSAAPI WSAAddressToStringW(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPWSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
   1048   WINSOCK_API_LINKAGE INT WSAAPI WSAStringToAddressA(LPSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
   1049   WINSOCK_API_LINKAGE INT WSAAPI WSAStringToAddressW(LPWSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
   1050   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceBeginA(LPWSAQUERYSETA lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
   1051   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
   1052   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceNextA(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETA lpqsResults);
   1053   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceNextW(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETW lpqsResults);
   1054   WINSOCK_API_LINKAGE INT WSAAPI WSANSPIoctl(HANDLE hLookup,DWORD dwControlCode,LPVOID lpvInBuffer,DWORD cbInBuffer,LPVOID lpvOutBuffer,DWORD cbOutBuffer,LPDWORD lpcbBytesReturned,LPWSACOMPLETION lpCompletion);
   1055   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceEnd(HANDLE hLookup);
   1056   WINSOCK_API_LINKAGE INT WSAAPI WSAInstallServiceClassA(LPWSASERVICECLASSINFOA lpServiceClassInfo);
   1057   WINSOCK_API_LINKAGE INT WSAAPI WSAInstallServiceClassW(LPWSASERVICECLASSINFOW lpServiceClassInfo);
   1058   WINSOCK_API_LINKAGE INT WSAAPI WSARemoveServiceClass(LPGUID lpServiceClassId);
   1059   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassInfoA(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOA lpServiceClassInfo);
   1060   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassInfoW(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOW lpServiceClassInfo);
   1061   WINSOCK_API_LINKAGE INT WSAAPI WSAEnumNameSpaceProvidersA(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOA lpnspBuffer);
   1062   WINSOCK_API_LINKAGE INT WSAAPI WSAEnumNameSpaceProvidersW(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOW lpnspBuffer);
   1063   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassNameByClassIdA(LPGUID lpServiceClassId,LPSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
   1064   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassNameByClassIdW(LPGUID lpServiceClassId,LPWSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
   1065   WINSOCK_API_LINKAGE INT WSAAPI WSASetServiceA(LPWSAQUERYSETA lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
   1066   WINSOCK_API_LINKAGE INT WSAAPI WSASetServiceW(LPWSAQUERYSETW lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
   1067   WINSOCK_API_LINKAGE INT WSAAPI WSAProviderConfigChange(LPHANDLE lpNotificationHandle,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1068 
   1069 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
   1070 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
   1071 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
   1072 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
   1073 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
   1074 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
   1075 
   1076 #if (_WIN32_WINNT >= 0x0600)
   1077 typedef struct _WSANAMESPACE_INFOEXA {
   1078   GUID NSProviderId;
   1079   DWORD dwNameSpace;
   1080   WINBOOL fActive;
   1081   DWORD dwVersion;
   1082   LPSTR lpszIdentifier;
   1083   BLOB ProviderSpecific;
   1084 } WSANAMESPACE_INFOEXA, *PWSANAMESPACE_INFOEXA, *LPWSANAMESPACE_INFOEXA;
   1085 
   1086 typedef struct _WSANAMESPACE_INFOEXW {
   1087   GUID NSProviderId;
   1088   DWORD dwNameSpace;
   1089   WINBOOL fActive;
   1090   DWORD dwVersion;
   1091   LPWSTR lpszIdentifier;
   1092   BLOB ProviderSpecific;
   1093 } WSANAMESPACE_INFOEXW, *PWSANAMESPACE_INFOEXW, *LPWSANAMESPACE_INFOEXW;
   1094 
   1095 __MINGW_TYPEDEF_AW(WSANAMESPACE_INFOEX)
   1096 __MINGW_TYPEDEF_AW(PWSANAMESPACE_INFOEX)
   1097 __MINGW_TYPEDEF_AW(LPWSANAMESPACE_INFOEX)
   1098 
   1099 typedef struct _WSAQUERYSET2A {
   1100   DWORD         dwSize;
   1101   LPSTR         lpszServiceInstanceName;
   1102   LPWSAVERSION  lpVersion;
   1103   LPSTR         lpszComment;
   1104   DWORD         dwNameSpace;
   1105   LPGUID        lpNSProviderId;
   1106   LPSTR         lpszContext;
   1107   DWORD         dwNumberOfProtocols;
   1108   LPAFPROTOCOLS lpafpProtocols;
   1109   LPSTR         lpszQueryString;
   1110   DWORD         dwNumberOfCsAddrs;
   1111   LPCSADDR_INFO lpcsaBuffer;
   1112   DWORD         dwOutputFlags;
   1113   LPBLOB        lpBlob;
   1114 } WSAQUERYSET2A, *PWSAQUERYSET2A, *LPWSAQUERYSET2A;
   1115 
   1116 typedef struct _WSAQUERYSET2W {
   1117   DWORD         dwSize;
   1118   LPWSTR        lpszServiceInstanceName;
   1119   LPWSAVERSION  lpVersion;
   1120   LPWSTR        lpszComment;
   1121   DWORD         dwNameSpace;
   1122   LPGUID        lpNSProviderId;
   1123   LPTSTR        lpszContext;
   1124   DWORD         dwNumberOfProtocols;
   1125   LPAFPROTOCOLS lpafpProtocols;
   1126   LPWSTR        lpszQueryString;
   1127   DWORD         dwNumberOfCsAddrs;
   1128   LPCSADDR_INFO lpcsaBuffer;
   1129   DWORD         dwOutputFlags;
   1130   LPBLOB        lpBlob;
   1131 } WSAQUERYSET2W, *PWSAQUERYSET2W, *LPWSAQUERYSET2W;
   1132 
   1133 #define POLLRDNORM 0x0100
   1134 #define POLLRDBAND 0x0200
   1135 #define POLLIN    (POLLRDNORM | POLLRDBAND)
   1136 #define POLLPRI    0x0400
   1137 
   1138 #define POLLWRNORM 0x0010
   1139 #define POLLOUT   (POLLWRNORM)
   1140 #define POLLWRBAND 0x0020
   1141 
   1142 #define POLLERR    0x0001
   1143 #define POLLHUP    0x0002
   1144 #define POLLNVAL   0x0004
   1145 
   1146 typedef struct pollfd {
   1147   SOCKET fd;
   1148   short  events;
   1149   short  revents;
   1150 } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
   1151 
   1152 WINSOCK_API_LINKAGE WINBOOL PASCAL WSAConnectByList(
   1153   SOCKET s,
   1154   PSOCKET_ADDRESS_LIST SocketAddressList,
   1155   LPDWORD LocalAddressLength,
   1156   LPSOCKADDR LocalAddress,
   1157   LPDWORD RemoteAddressLength,
   1158   LPSOCKADDR RemoteAddress,
   1159   const PTIMEVAL timeout,
   1160   LPWSAOVERLAPPED Reserved
   1161 );
   1162 
   1163 WINSOCK_API_LINKAGE WINBOOL PASCAL WSAConnectByNameA(
   1164   SOCKET s,
   1165   LPSTR nodename,
   1166   LPSTR servicename,
   1167   LPDWORD LocalAddressLength,
   1168   LPSOCKADDR LocalAddress,
   1169   LPDWORD RemoteAddressLength,
   1170   LPSOCKADDR RemoteAddress,
   1171   const PTIMEVAL timeout,
   1172   LPWSAOVERLAPPED Reserved
   1173 );
   1174 
   1175 WINSOCK_API_LINKAGE WINBOOL PASCAL WSAConnectByNameW(
   1176   SOCKET s,
   1177   LPWSTR nodename,
   1178   LPWSTR servicename,
   1179   LPDWORD LocalAddressLength,
   1180   LPSOCKADDR LocalAddress,
   1181   LPDWORD RemoteAddressLength,
   1182   LPSOCKADDR RemoteAddress,
   1183   const PTIMEVAL timeout,
   1184   LPWSAOVERLAPPED Reserved
   1185 );
   1186 #define WSAConnectByName __MINGW_NAME_AW(WSAConnectByName)
   1187 
   1188 INT WSAAPI WSAEnumNameSpaceProvidersExA(
   1189   LPDWORD lpdwBufferLength,
   1190   LPWSANAMESPACE_INFOEXA lpnspBuffer
   1191 );
   1192 
   1193 INT WSAAPI WSAEnumNameSpaceProvidersExW(
   1194   LPDWORD lpdwBufferLength,
   1195   LPWSANAMESPACE_INFOEXW lpnspBuffer
   1196 );
   1197 #define WSAEnumNameSpaceProvidersEx __MINGW_NAME_AW(WSAEnumNameSpaceProvidersEx)
   1198 
   1199 int WSAAPI WSAPoll(
   1200   WSAPOLLFD fdarray[],
   1201   ULONG nfds,
   1202   INT timeout
   1203 );
   1204 
   1205 int WSAAPI WSASendMsg(
   1206   SOCKET s,
   1207   LPWSAMSG lpMsg,
   1208   DWORD dwFlags,
   1209   LPDWORD lpNumberOfBytesSent,
   1210   LPWSAOVERLAPPED lpOverlapped,
   1211   LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
   1212 );
   1213 #endif /*(_WIN32_WINNT >= 0x0600)*/
   1214 
   1215 #ifdef __cplusplus
   1216 }
   1217 #endif
   1218 
   1219 #ifdef _NEED_POPPACK
   1220 #include <poppack.h>
   1221 #endif
   1222 
   1223 #ifdef IPV6STRICT
   1224 #include <wsipv6ok.h>
   1225 #endif
   1226 
   1227 #ifdef __LP64__
   1228 #pragma pop_macro("u_long")
   1229 #endif
   1230 
   1231 #endif /* _WINSOCK2API_ */
   1232