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 #if (_WIN32_WINNT >= 0x0600)
    612 #define NS_BTH (16)
    613 #endif
    614 
    615 #define NS_NBP (20)
    616 
    617 #define NS_MS (30)
    618 #define NS_STDA (31)
    619 #define NS_NTDS (32)
    620 
    621 #if (_WIN32_WINNT >= 0x0600)
    622 #define NS_EMAIL (37)
    623 #define NS_PNRPNAME (38)
    624 #define NS_PNRPCLOUD (39)
    625 #endif
    626 
    627 #define NS_X500 (40)
    628 #define NS_NIS (41)
    629 #define NS_NISPLUS (42)
    630 
    631 #define NS_WRQ (50)
    632 
    633 #define NS_NETDES (60)
    634 
    635 #define RES_UNUSED_1 (0x00000001)
    636 #define RES_FLUSH_CACHE (0x00000002)
    637 #ifndef RES_SERVICE
    638 #define RES_SERVICE (0x00000004)
    639 #endif
    640 
    641 #define SERVICE_TYPE_VALUE_IPXPORTA "IpxSocket"
    642 #define SERVICE_TYPE_VALUE_IPXPORTW L"IpxSocket"
    643 #define SERVICE_TYPE_VALUE_SAPIDA "SapId"
    644 #define SERVICE_TYPE_VALUE_SAPIDW L"SapId"
    645 
    646 #define SERVICE_TYPE_VALUE_TCPPORTA "TcpPort"
    647 #define SERVICE_TYPE_VALUE_TCPPORTW L"TcpPort"
    648 
    649 #define SERVICE_TYPE_VALUE_UDPPORTA "UdpPort"
    650 #define SERVICE_TYPE_VALUE_UDPPORTW L"UdpPort"
    651 
    652 #define SERVICE_TYPE_VALUE_OBJECTIDA "ObjectId"
    653 #define SERVICE_TYPE_VALUE_OBJECTIDW L"ObjectId"
    654 
    655 #define SERVICE_TYPE_VALUE_SAPID __MINGW_NAME_AW(SERVICE_TYPE_VALUE_SAPID)
    656 #define SERVICE_TYPE_VALUE_TCPPORT __MINGW_NAME_AW(SERVICE_TYPE_VALUE_TCPPORT)
    657 #define SERVICE_TYPE_VALUE_UDPPORT __MINGW_NAME_AW(SERVICE_TYPE_VALUE_UDPPORT)
    658 #define SERVICE_TYPE_VALUE_OBJECTID __MINGW_NAME_AW(SERVICE_TYPE_VALUE_OBJECTID)
    659 
    660 #ifndef __CSADDR_DEFINED__
    661 #define __CSADDR_DEFINED__
    662 
    663   typedef struct _SOCKET_ADDRESS {
    664     LPSOCKADDR lpSockaddr;
    665     INT iSockaddrLength;
    666   } SOCKET_ADDRESS,*PSOCKET_ADDRESS,*LPSOCKET_ADDRESS;
    667 
    668   typedef struct _CSADDR_INFO {
    669     SOCKET_ADDRESS LocalAddr;
    670     SOCKET_ADDRESS RemoteAddr;
    671     INT iSocketType;
    672     INT iProtocol;
    673   } CSADDR_INFO,*PCSADDR_INFO,*LPCSADDR_INFO;
    674 #endif /* __CSADDR_DEFINED__ */
    675 
    676   typedef struct _SOCKET_ADDRESS_LIST {
    677     INT iAddressCount;
    678     SOCKET_ADDRESS Address[1];
    679   } SOCKET_ADDRESS_LIST,*PSOCKET_ADDRESS_LIST,*LPSOCKET_ADDRESS_LIST;
    680 
    681   typedef struct _AFPROTOCOLS {
    682     INT iAddressFamily;
    683     INT iProtocol;
    684   } AFPROTOCOLS,*PAFPROTOCOLS,*LPAFPROTOCOLS;
    685 
    686   typedef enum _WSAEcomparator {
    687     COMP_EQUAL = 0,
    688     COMP_NOTLESS
    689   } WSAECOMPARATOR,*PWSAECOMPARATOR,*LPWSAECOMPARATOR;
    690 
    691   typedef struct _WSAVersion {
    692     DWORD dwVersion;
    693     WSAECOMPARATOR ecHow;
    694   } WSAVERSION,*PWSAVERSION,*LPWSAVERSION;
    695 
    696   typedef struct _WSAQuerySetA {
    697     DWORD dwSize;
    698     LPSTR lpszServiceInstanceName;
    699     LPGUID lpServiceClassId;
    700     LPWSAVERSION lpVersion;
    701     LPSTR lpszComment;
    702     DWORD dwNameSpace;
    703     LPGUID lpNSProviderId;
    704     LPSTR lpszContext;
    705     DWORD dwNumberOfProtocols;
    706     LPAFPROTOCOLS lpafpProtocols;
    707     LPSTR lpszQueryString;
    708     DWORD dwNumberOfCsAddrs;
    709     LPCSADDR_INFO lpcsaBuffer;
    710     DWORD dwOutputFlags;
    711     LPBLOB lpBlob;
    712   } WSAQUERYSETA,*PWSAQUERYSETA,*LPWSAQUERYSETA;
    713 
    714   typedef struct _WSAQuerySetW {
    715     DWORD dwSize;
    716     LPWSTR lpszServiceInstanceName;
    717     LPGUID lpServiceClassId;
    718     LPWSAVERSION lpVersion;
    719     LPWSTR lpszComment;
    720     DWORD dwNameSpace;
    721     LPGUID lpNSProviderId;
    722     LPWSTR lpszContext;
    723     DWORD dwNumberOfProtocols;
    724     LPAFPROTOCOLS lpafpProtocols;
    725     LPWSTR lpszQueryString;
    726     DWORD dwNumberOfCsAddrs;
    727     LPCSADDR_INFO lpcsaBuffer;
    728     DWORD dwOutputFlags;
    729     LPBLOB lpBlob;
    730   } WSAQUERYSETW,*PWSAQUERYSETW,*LPWSAQUERYSETW;
    731 
    732   __MINGW_TYPEDEF_AW(WSAQUERYSET)
    733   __MINGW_TYPEDEF_AW(PWSAQUERYSET)
    734   __MINGW_TYPEDEF_AW(LPWSAQUERYSET)
    735 
    736 #define LUP_DEEP 0x0001
    737 #define LUP_CONTAINERS 0x0002
    738 #define LUP_NOCONTAINERS 0x0004
    739 #define LUP_NEAREST 0x0008
    740 #define LUP_RETURN_NAME 0x0010
    741 #define LUP_RETURN_TYPE 0x0020
    742 #define LUP_RETURN_VERSION 0x0040
    743 #define LUP_RETURN_COMMENT 0x0080
    744 #define LUP_RETURN_ADDR 0x0100
    745 #define LUP_RETURN_BLOB 0x0200
    746 #define LUP_RETURN_ALIASES 0x0400
    747 #define LUP_RETURN_QUERY_STRING 0x0800
    748 #define LUP_RETURN_ALL 0x0FF0
    749 #define LUP_RES_SERVICE 0x8000
    750 
    751 #define LUP_FLUSHCACHE 0x1000
    752 #define LUP_FLUSHPREVIOUS 0x2000
    753 
    754 #define LUP_NON_AUTHORITATIVE 0x4000
    755 #define LUP_SECURE 0x8000
    756 #define LUP_RETURN_PREFERRED_NAMES 0x10000
    757 
    758 #define LUP_ADDRCONFIG 0x100000
    759 #define LUP_DUAL_ADDR 0x200000
    760 #define LUP_FILESERVER 0x400000
    761 
    762 #define LUP_RES_RESERVICE 0x8000 /* FIXME: not in PSDK anymore?? */
    763 
    764 #define RESULT_IS_ALIAS 0x0001
    765 #define RESULT_IS_ADDED 0x0010
    766 #define RESULT_IS_CHANGED 0x0020
    767 #define RESULT_IS_DELETED 0x0040
    768 
    769   typedef enum _WSAESETSERVICEOP {
    770     RNRSERVICE_REGISTER = 0,
    771     RNRSERVICE_DEREGISTER,
    772     RNRSERVICE_DELETE
    773   } WSAESETSERVICEOP,*PWSAESETSERVICEOP,*LPWSAESETSERVICEOP;
    774 
    775   typedef struct _WSANSClassInfoA {
    776     LPSTR lpszName;
    777     DWORD dwNameSpace;
    778     DWORD dwValueType;
    779     DWORD dwValueSize;
    780     LPVOID lpValue;
    781   } WSANSCLASSINFOA,*PWSANSCLASSINFOA,*LPWSANSCLASSINFOA;
    782 
    783   typedef struct _WSANSClassInfoW {
    784     LPWSTR lpszName;
    785     DWORD dwNameSpace;
    786     DWORD dwValueType;
    787     DWORD dwValueSize;
    788     LPVOID lpValue;
    789   } WSANSCLASSINFOW,*PWSANSCLASSINFOW,*LPWSANSCLASSINFOW;
    790 
    791   __MINGW_TYPEDEF_AW(WSANSCLASSINFO)
    792   __MINGW_TYPEDEF_AW(PWSANSCLASSINFO)
    793   __MINGW_TYPEDEF_AW(LPWSANSCLASSINFO)
    794 
    795   typedef struct _WSAServiceClassInfoA {
    796     LPGUID lpServiceClassId;
    797     LPSTR lpszServiceClassName;
    798     DWORD dwCount;
    799     LPWSANSCLASSINFOA lpClassInfos;
    800   } WSASERVICECLASSINFOA,*PWSASERVICECLASSINFOA,*LPWSASERVICECLASSINFOA;
    801 
    802   typedef struct _WSAServiceClassInfoW {
    803     LPGUID lpServiceClassId;
    804     LPWSTR lpszServiceClassName;
    805     DWORD dwCount;
    806     LPWSANSCLASSINFOW lpClassInfos;
    807   } WSASERVICECLASSINFOW,*PWSASERVICECLASSINFOW,*LPWSASERVICECLASSINFOW;
    808 
    809   __MINGW_TYPEDEF_AW(WSASERVICECLASSINFO)
    810   __MINGW_TYPEDEF_AW(PWSASERVICECLASSINFO)
    811   __MINGW_TYPEDEF_AW(LPWSASERVICECLASSINFO)
    812 
    813   typedef struct _WSANAMESPACE_INFOA {
    814     GUID NSProviderId;
    815     DWORD dwNameSpace;
    816     WINBOOL fActive;
    817     DWORD dwVersion;
    818     LPSTR lpszIdentifier;
    819   } WSANAMESPACE_INFOA,*PWSANAMESPACE_INFOA,*LPWSANAMESPACE_INFOA;
    820 
    821   typedef struct _WSANAMESPACE_INFOW {
    822     GUID NSProviderId;
    823     DWORD dwNameSpace;
    824     WINBOOL fActive;
    825     DWORD dwVersion;
    826     LPWSTR lpszIdentifier;
    827   } WSANAMESPACE_INFOW,*PWSANAMESPACE_INFOW,*LPWSANAMESPACE_INFOW;
    828 
    829   __MINGW_TYPEDEF_AW(WSANAMESPACE_INFO)
    830   __MINGW_TYPEDEF_AW(PWSANAMESPACE_INFO)
    831   __MINGW_TYPEDEF_AW(LPWSANAMESPACE_INFO)
    832 
    833 /* FIXME: WSAMSG originally lived in mswsock.h,
    834  * newer SDKs moved it into a new ws2def.h. for
    835  * now we keep it here. */
    836   typedef struct _WSAMSG {
    837     LPSOCKADDR name;
    838     INT namelen;
    839     LPWSABUF lpBuffers;
    840     DWORD dwBufferCount;
    841     WSABUF Control;
    842     DWORD dwFlags;
    843   } WSAMSG,*PWSAMSG,*LPWSAMSG;
    844 
    845 #if INCL_WINSOCK_API_TYPEDEFS
    846 #define LPFN_WSADUPLICATESOCKET __MINGW_NAME_AW(LPFN_WSADUPLICATESOCKET)
    847 #define LPFN_WSAENUMPROTOCOLS __MINGW_NAME_AW(LPFN_WSAENUMPROTOCOLS)
    848 #define LPFN_WSASOCKET __MINGW_NAME_AW(LPFN_WSASOCKET)
    849 #define LPFN_WSAADDRESSTOSTRING __MINGW_NAME_AW(LPFN_WSAADDRESSTOSTRING)
    850 #define LPFN_WSASTRINGTOADDRESS __MINGW_NAME_AW(LPFN_WSASTRINGTOADDRESS)
    851 #define LPFN_WSALOOKUPSERVICEBEGIN __MINGW_NAME_AW(LPFN_WSALOOKUPSERVICEBEGIN)
    852 #define LPFN_WSALOOKUPSERVICENEXT __MINGW_NAME_AW(LPFN_WSALOOKUPSERVICENEXT)
    853 #define LPFN_WSAINSTALLSERVICECLASS __MINGW_NAME_AW(LPFN_WSAINSTALLSERVICECLASS)
    854 #define LPFN_WSAGETSERVICECLASSINFO __MINGW_NAME_AW(LPFN_WSAGETSERVICECLASSINFO)
    855 #define LPFN_WSAENUMNAMESPACEPROVIDERS __MINGW_NAME_AW(LPFN_WSAENUMNAMESPACEPROVIDERS)
    856 #define LPFN_WSAGETSERVICECLASSNAMEBYCLASSID __MINGW_NAME_AW(LPFN_WSAGETSERVICECLASSNAMEBYCLASSID)
    857 #define LPFN_WSASETSERVICE __MINGW_NAME_AW(LPFN_WSASETSERVICE)
    858 
    859   typedef SOCKET (WSAAPI *LPFN_ACCEPT)(SOCKET s,struct sockaddr *addr,int *addrlen);
    860   typedef int (WSAAPI *LPFN_BIND)(SOCKET s,const struct sockaddr *name,int namelen);
    861   typedef int (WSAAPI *LPFN_CLOSESOCKET)(SOCKET s);
    862   typedef int (WSAAPI *LPFN_CONNECT)(SOCKET s,const struct sockaddr *name,int namelen);
    863   typedef int (WSAAPI *LPFN_IOCTLSOCKET)(SOCKET s,__LONG32 cmd,u_long *argp);
    864   typedef int (WSAAPI *LPFN_GETPEERNAME)(SOCKET s,struct sockaddr *name,int *namelen);
    865   typedef int (WSAAPI *LPFN_GETSOCKNAME)(SOCKET s,struct sockaddr *name,int *namelen);
    866   typedef int (WSAAPI *LPFN_GETSOCKOPT)(SOCKET s,int level,int optname,char *optval,int *optlen);
    867   typedef u_long (WSAAPI *LPFN_HTONL)(u_long hostlong);
    868   typedef u_short (WSAAPI *LPFN_HTONS)(u_short hostshort);
    869   typedef unsigned __LONG32 (WSAAPI *LPFN_INET_ADDR)(const char *cp);
    870   typedef char *(WSAAPI *LPFN_INET_NTOA)(struct in_addr in);
    871   typedef int (WSAAPI *LPFN_LISTEN)(SOCKET s,int backlog);
    872   typedef u_long (WSAAPI *LPFN_NTOHL)(u_long netlong);
    873   typedef u_short (WSAAPI *LPFN_NTOHS)(u_short netshort);
    874   typedef int (WSAAPI *LPFN_RECV)(SOCKET s,char *buf,int len,int flags);
    875   typedef int (WSAAPI *LPFN_RECVFROM)(SOCKET s,char *buf,int len,int flags,struct sockaddr *from,int *fromlen);
    876   typedef int (WSAAPI *LPFN_SELECT)(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
    877   typedef int (WSAAPI *LPFN_SEND)(SOCKET s,const char *buf,int len,int flags);
    878   typedef int (WSAAPI *LPFN_SENDTO)(SOCKET s,const char *buf,int len,int flags,const struct sockaddr *to,int tolen);
    879   typedef int (WSAAPI *LPFN_SETSOCKOPT)(SOCKET s,int level,int optname,const char *optval,int optlen);
    880   typedef int (WSAAPI *LPFN_SHUTDOWN)(SOCKET s,int how);
    881   typedef SOCKET (WSAAPI *LPFN_SOCKET)(int af,int type,int protocol);
    882   typedef struct hostent *(WSAAPI *LPFN_GETHOSTBYADDR)(const char *addr,int len,int type);
    883   typedef struct hostent *(WSAAPI *LPFN_GETHOSTBYNAME)(const char *name);
    884   typedef int (WSAAPI *LPFN_GETHOSTNAME)(char *name,int namelen);
    885   typedef struct servent *(WSAAPI *LPFN_GETSERVBYPORT)(int port,const char *proto);
    886   typedef struct servent *(WSAAPI *LPFN_GETSERVBYNAME)(const char *name,const char *proto);
    887   typedef struct protoent *(WSAAPI *LPFN_GETPROTOBYNUMBER)(int number);
    888   typedef struct protoent *(WSAAPI *LPFN_GETPROTOBYNAME)(const char *name);
    889   typedef int (WSAAPI *LPFN_WSASTARTUP)(WORD wVersionRequested,LPWSADATA lpWSAData);
    890   typedef int (WSAAPI *LPFN_WSACLEANUP)(void);
    891   typedef void (WSAAPI *LPFN_WSASETLASTERROR)(int iError);
    892   typedef int (WSAAPI *LPFN_WSAGETLASTERROR)(void);
    893   typedef WINBOOL (WSAAPI *LPFN_WSAISBLOCKING)(void);
    894   typedef int (WSAAPI *LPFN_WSAUNHOOKBLOCKINGHOOK)(void);
    895   typedef FARPROC (WSAAPI *LPFN_WSASETBLOCKINGHOOK)(FARPROC lpBlockFunc);
    896   typedef int (WSAAPI *LPFN_WSACANCELBLOCKINGCALL)(void);
    897   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETSERVBYNAME)(HWND hWnd,u_int wMsg,const char *name,const char *proto,char *buf,int buflen);
    898   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETSERVBYPORT)(HWND hWnd,u_int wMsg,int port,const char *proto,char *buf,int buflen);
    899   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETPROTOBYNAME)(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
    900   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETPROTOBYNUMBER)(HWND hWnd,u_int wMsg,int number,char *buf,int buflen);
    901   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETHOSTBYNAME)(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
    902   typedef HANDLE (WSAAPI *LPFN_WSAASYNCGETHOSTBYADDR)(HWND hWnd,u_int wMsg,const char *addr,int len,int type,char *buf,int buflen);
    903   typedef int (WSAAPI *LPFN_WSACANCELASYNCREQUEST)(HANDLE hAsyncTaskHandle);
    904   typedef int (WSAAPI *LPFN_WSAASYNCSELECT)(SOCKET s,HWND hWnd,u_int wMsg,__LONG32 lEvent);
    905   typedef SOCKET (WSAAPI *LPFN_WSAACCEPT)(SOCKET s,struct sockaddr *addr,LPINT addrlen,LPCONDITIONPROC lpfnCondition,DWORD_PTR dwCallbackData);
    906   typedef WINBOOL (WSAAPI *LPFN_WSACLOSEEVENT)(WSAEVENT hEvent);
    907   typedef int (WSAAPI *LPFN_WSACONNECT)(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS);
    908   typedef WSAEVENT (WSAAPI *LPFN_WSACREATEEVENT)(void);
    909   typedef int (WSAAPI *LPFN_WSADUPLICATESOCKETA)(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOA lpProtocolInfo);
    910   typedef int (WSAAPI *LPFN_WSADUPLICATESOCKETW)(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOW lpProtocolInfo);
    911   typedef int (WSAAPI *LPFN_WSAENUMNETWORKEVENTS)(SOCKET s,WSAEVENT hEventObject,LPWSANETWORKEVENTS lpNetworkEvents);
    912   typedef int (WSAAPI *LPFN_WSAENUMPROTOCOLSA)(LPINT lpiProtocols,LPWSAPROTOCOL_INFOA lpProtocolBuffer,LPDWORD lpdwBufferLength);
    913   typedef int (WSAAPI *LPFN_WSAENUMPROTOCOLSW)(LPINT lpiProtocols,LPWSAPROTOCOL_INFOW lpProtocolBuffer,LPDWORD lpdwBufferLength);
    914   typedef int (WSAAPI *LPFN_WSAEVENTSELECT)(SOCKET s,WSAEVENT hEventObject,__LONG32 lNetworkEvents);
    915   typedef WINBOOL (WSAAPI *LPFN_WSAGETOVERLAPPEDRESULT)(SOCKET s,LPWSAOVERLAPPED lpOverlapped,LPDWORD lpcbTransfer,WINBOOL fWait,LPDWORD lpdwFlags);
    916   typedef WINBOOL (WSAAPI *LPFN_WSAGETQOSBYNAME)(SOCKET s,LPWSABUF lpQOSName,LPQOS lpQOS);
    917   typedef int (WSAAPI *LPFN_WSAHTONL)(SOCKET s,u_long hostlong,u_long *lpnetlong);
    918   typedef int (WSAAPI *LPFN_WSAHTONS)(SOCKET s,u_short hostshort,u_short *lpnetshort);
    919   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);
    920   typedef SOCKET (WSAAPI *LPFN_WSAJOINLEAF)(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS,DWORD dwFlags);
    921   typedef int (WSAAPI *LPFN_WSANTOHL)(SOCKET s,u_long netlong,u_long *lphostlong);
    922   typedef int (WSAAPI *LPFN_WSANTOHS)(SOCKET s,u_short netshort,u_short *lphostshort);
    923   typedef int (WSAAPI *LPFN_WSARECV)(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    924   typedef int (WSAAPI *LPFN_WSARECVDISCONNECT)(SOCKET s,LPWSABUF lpInboundDisconnectData);
    925   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);
    926   typedef WINBOOL (WSAAPI *LPFN_WSARESETEVENT)(WSAEVENT hEvent);
    927   typedef int (WSAAPI *LPFN_WSASEND)(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesSent,DWORD dwFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    928   typedef int (WSAAPI *LPFN_WSASENDDISCONNECT)(SOCKET s,LPWSABUF lpOutboundDisconnectData);
    929   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);
    930   typedef WINBOOL (WSAAPI *LPFN_WSASETEVENT)(WSAEVENT hEvent);
    931   typedef SOCKET (WSAAPI *LPFN_WSASOCKETA)(int af,int type,int protocol,LPWSAPROTOCOL_INFOA lpProtocolInfo,GROUP g,DWORD dwFlags);
    932   typedef SOCKET (WSAAPI *LPFN_WSASOCKETW)(int af,int type,int protocol,LPWSAPROTOCOL_INFOW lpProtocolInfo,GROUP g,DWORD dwFlags);
    933   typedef DWORD (WSAAPI *LPFN_WSAWAITFORMULTIPLEEVENTS)(DWORD cEvents,const WSAEVENT *lphEvents,WINBOOL fWaitAll,DWORD dwTimeout,WINBOOL fAlertable);
    934   typedef INT (WSAAPI *LPFN_WSAADDRESSTOSTRINGA)(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
    935   typedef INT (WSAAPI *LPFN_WSAADDRESSTOSTRINGW)(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPWSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
    936   typedef INT (WSAAPI *LPFN_WSASTRINGTOADDRESSA)(LPSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
    937   typedef INT (WSAAPI *LPFN_WSASTRINGTOADDRESSW)(LPWSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
    938   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICEBEGINA)(LPWSAQUERYSETA lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
    939   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICEBEGINW)(LPWSAQUERYSETW lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
    940   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICENEXTA)(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETA lpqsResults);
    941   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICENEXTW)(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETW lpqsResults);
    942   typedef INT (WSAAPI *LPFN_WSANSPIOCTL)(HANDLE hLookup,DWORD dwControlCode,LPVOID lpvInBuffer,DWORD cbInBuffer,LPVOID lpvOutBuffer,DWORD cbOutBuffer,LPDWORD lpcbBytesReturned,LPWSACOMPLETION lpCompletion);
    943   typedef INT (WSAAPI *LPFN_WSALOOKUPSERVICEEND)(HANDLE hLookup);
    944   typedef INT (WSAAPI *LPFN_WSAINSTALLSERVICECLASSA)(LPWSASERVICECLASSINFOA lpServiceClassInfo);
    945   typedef INT (WSAAPI *LPFN_WSAINSTALLSERVICECLASSW)(LPWSASERVICECLASSINFOW lpServiceClassInfo);
    946   typedef INT (WSAAPI *LPFN_WSAREMOVESERVICECLASS)(LPGUID lpServiceClassId);
    947   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSINFOA)(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOA lpServiceClassInfo);
    948   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSINFOW)(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOW lpServiceClassInfo);
    949   typedef INT (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSA)(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOA lpnspBuffer);
    950   typedef INT (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSW)(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOW lpnspBuffer);
    951   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA)(LPGUID lpServiceClassId,LPSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
    952   typedef INT (WSAAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW)(LPGUID lpServiceClassId,LPWSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
    953   typedef INT (WSAAPI *LPFN_WSASETSERVICEA)(LPWSAQUERYSETA lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
    954   typedef INT (WSAAPI *LPFN_WSASETSERVICEW)(LPWSAQUERYSETW lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
    955   typedef INT (WSAAPI *LPFN_WSAPROVIDERCONFIGCHANGE)(LPHANDLE lpNotificationHandle,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
    956 #endif
    957 
    958 #define WSADuplicateSocket __MINGW_NAME_AW(WSADuplicateSocket)
    959 #define WSAEnumProtocols __MINGW_NAME_AW(WSAEnumProtocols)
    960 #define WSAAddressToString __MINGW_NAME_AW(WSAAddressToString)
    961 #define WSASocket __MINGW_NAME_AW(WSASocket)
    962 #define WSAStringToAddress __MINGW_NAME_AW(WSAStringToAddress)
    963 #define WSALookupServiceBegin __MINGW_NAME_AW(WSALookupServiceBegin)
    964 #define WSALookupServiceNext __MINGW_NAME_AW(WSALookupServiceNext)
    965 #define WSAInstallServiceClass __MINGW_NAME_AW(WSAInstallServiceClass)
    966 #define WSAGetServiceClassInfo __MINGW_NAME_AW(WSAGetServiceClassInfo)
    967 #define WSAEnumNameSpaceProviders __MINGW_NAME_AW(WSAEnumNameSpaceProviders)
    968 #define WSAGetServiceClassNameByClassId __MINGW_NAME_AW(WSAGetServiceClassNameByClassId)
    969 #define WSASetService __MINGW_NAME_AW(WSASetService)
    970 
    971 #ifndef __WINSOCK_WS1_SHARED
    972 /* these 46 functions have the same prototypes as in winsock2 */
    973   WINSOCK_API_LINKAGE SOCKET WSAAPI accept(SOCKET s,struct sockaddr *addr,int *addrlen);
    974   WINSOCK_API_LINKAGE int WSAAPI bind(SOCKET s,const struct sockaddr *name,int namelen);
    975   WINSOCK_API_LINKAGE int WSAAPI closesocket(SOCKET s);
    976   WINSOCK_API_LINKAGE int WSAAPI connect(SOCKET s,const struct sockaddr *name,int namelen);
    977   WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
    978   WINSOCK_API_LINKAGE int WSAAPI getpeername(SOCKET s,struct sockaddr *name,int *namelen);
    979   WINSOCK_API_LINKAGE int WSAAPI getsockname(SOCKET s,struct sockaddr *name,int *namelen);
    980   WINSOCK_API_LINKAGE int WSAAPI getsockopt(SOCKET s,int level,int optname,char *optval,int *optlen);
    981 #ifndef __INSIDE_CYGWIN__
    982   WINSOCK_API_LINKAGE u_long WSAAPI htonl(u_long hostlong);
    983   WINSOCK_API_LINKAGE u_short WSAAPI htons(u_short hostshort);
    984 #endif /* !__INSIDE_CYGWIN__ */
    985   WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);
    986   WINSOCK_API_LINKAGE char *WSAAPI inet_ntoa(struct in_addr in);
    987   WINSOCK_API_LINKAGE int WSAAPI listen(SOCKET s,int backlog);
    988 #ifndef __INSIDE_CYGWIN__
    989   WINSOCK_API_LINKAGE u_long WSAAPI ntohl(u_long netlong);
    990   WINSOCK_API_LINKAGE u_short WSAAPI ntohs(u_short netshort);
    991 #endif /* !__INSIDE_CYGWIN__ */
    992   WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags);
    993   WINSOCK_API_LINKAGE int WSAAPI recvfrom(SOCKET s,char *buf,int len,int flags,struct sockaddr *from,int *fromlen);
    994 #ifndef __INSIDE_CYGWIN__
    995   WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
    996 #endif /* !__INSIDE_CYGWIN__ */
    997   WINSOCK_API_LINKAGE int WSAAPI send(SOCKET s,const char *buf,int len,int flags);
    998   WINSOCK_API_LINKAGE int WSAAPI sendto(SOCKET s,const char *buf,int len,int flags,const struct sockaddr *to,int tolen);
    999   WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int optname,const char *optval,int optlen);
   1000   WINSOCK_API_LINKAGE int WSAAPI shutdown(SOCKET s,int how);
   1001   WINSOCK_API_LINKAGE SOCKET WSAAPI socket(int af,int type,int protocol);
   1002   WINSOCK_API_LINKAGE struct hostent *WSAAPI gethostbyaddr(const char *addr,int len,int type);
   1003   WINSOCK_API_LINKAGE struct hostent *WSAAPI gethostbyname(const char *name);
   1004   WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen);
   1005   WINSOCK_API_LINKAGE struct servent *WSAAPI getservbyport(int port,const char *proto);
   1006   WINSOCK_API_LINKAGE struct servent *WSAAPI getservbyname(const char *name,const char *proto);
   1007   WINSOCK_API_LINKAGE struct protoent *WSAAPI getprotobynumber(int number);
   1008   WINSOCK_API_LINKAGE struct protoent *WSAAPI getprotobyname(const char *name);
   1009   WINSOCK_API_LINKAGE int WSAAPI WSAStartup(WORD wVersionRequested,LPWSADATA lpWSAData);
   1010   WINSOCK_API_LINKAGE int WSAAPI WSACleanup(void);
   1011   WINSOCK_API_LINKAGE void WSAAPI WSASetLastError(int iError);
   1012   WINSOCK_API_LINKAGE int WSAAPI WSAGetLastError(void);
   1013   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAIsBlocking(void);
   1014   WINSOCK_API_LINKAGE int WSAAPI WSAUnhookBlockingHook(void);
   1015   WINSOCK_API_LINKAGE FARPROC WSAAPI WSASetBlockingHook(FARPROC lpBlockFunc);
   1016   WINSOCK_API_LINKAGE int WSAAPI WSACancelBlockingCall(void);
   1017   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetServByName(HWND hWnd,u_int wMsg,const char *name,const char *proto,char *buf,int buflen);
   1018   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetServByPort(HWND hWnd,u_int wMsg,int port,const char *proto,char *buf,int buflen);
   1019   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetProtoByName(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
   1020   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetProtoByNumber(HWND hWnd,u_int wMsg,int number,char *buf,int buflen);
   1021   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetHostByName(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
   1022   WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetHostByAddr(HWND hWnd,u_int wMsg,const char *addr,int len,int type,char *buf,int buflen);
   1023   WINSOCK_API_LINKAGE int WSAAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
   1024   WINSOCK_API_LINKAGE int WSAAPI WSAAsyncSelect(SOCKET s,HWND hWnd,u_int wMsg,__LONG32 lEvent);
   1025 #endif /* __WINSOCK_WS1_SHARED */
   1026   WINSOCK_API_LINKAGE SOCKET WSAAPI WSAAccept(SOCKET s,struct sockaddr *addr,LPINT addrlen,LPCONDITIONPROC lpfnCondition,DWORD_PTR dwCallbackData);
   1027   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSACloseEvent(WSAEVENT hEvent);
   1028   WINSOCK_API_LINKAGE int WSAAPI WSAConnect(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS);
   1029   WINSOCK_API_LINKAGE WSAEVENT WSAAPI WSACreateEvent(void);
   1030   WINSOCK_API_LINKAGE int WSAAPI WSADuplicateSocketA(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOA lpProtocolInfo);
   1031   WINSOCK_API_LINKAGE int WSAAPI WSADuplicateSocketW(SOCKET s,DWORD dwProcessId,LPWSAPROTOCOL_INFOW lpProtocolInfo);
   1032   WINSOCK_API_LINKAGE int WSAAPI WSAEnumNetworkEvents(SOCKET s,WSAEVENT hEventObject,LPWSANETWORKEVENTS lpNetworkEvents);
   1033   WINSOCK_API_LINKAGE int WSAAPI WSAEnumProtocolsA(LPINT lpiProtocols,LPWSAPROTOCOL_INFOA lpProtocolBuffer,LPDWORD lpdwBufferLength);
   1034   WINSOCK_API_LINKAGE int WSAAPI WSAEnumProtocolsW(LPINT lpiProtocols,LPWSAPROTOCOL_INFOW lpProtocolBuffer,LPDWORD lpdwBufferLength);
   1035   WINSOCK_API_LINKAGE int WSAAPI WSAEventSelect(SOCKET s,WSAEVENT hEventObject,__LONG32 lNetworkEvents);
   1036   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAGetOverlappedResult(SOCKET s,LPWSAOVERLAPPED lpOverlapped,LPDWORD lpcbTransfer,WINBOOL fWait,LPDWORD lpdwFlags);
   1037   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAGetQOSByName(SOCKET s,LPWSABUF lpQOSName,LPQOS lpQOS);
   1038   WINSOCK_API_LINKAGE int WSAAPI WSAHtonl(SOCKET s,u_long hostlong,u_long *lpnetlong);
   1039   WINSOCK_API_LINKAGE int WSAAPI WSAHtons(SOCKET s,u_short hostshort,u_short *lpnetshort);
   1040   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);
   1041   WINSOCK_API_LINKAGE SOCKET WSAAPI WSAJoinLeaf(SOCKET s,const struct sockaddr *name,int namelen,LPWSABUF lpCallerData,LPWSABUF lpCalleeData,LPQOS lpSQOS,LPQOS lpGQOS,DWORD dwFlags);
   1042   WINSOCK_API_LINKAGE int WSAAPI WSANtohl(SOCKET s,u_long netlong,u_long *lphostlong);
   1043   WINSOCK_API_LINKAGE int WSAAPI WSANtohs(SOCKET s,u_short netshort,u_short *lphostshort);
   1044   WINSOCK_API_LINKAGE int WSAAPI WSARecv(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1045   WINSOCK_API_LINKAGE int WSAAPI WSARecvDisconnect(SOCKET s,LPWSABUF lpInboundDisconnectData);
   1046   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);
   1047   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAResetEvent(WSAEVENT hEvent);
   1048   WINSOCK_API_LINKAGE int WSAAPI WSASend(SOCKET s,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesSent,DWORD dwFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1049   WINSOCK_API_LINKAGE int WSAAPI WSASendDisconnect(SOCKET s,LPWSABUF lpOutboundDisconnectData);
   1050   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);
   1051   WINSOCK_API_LINKAGE WINBOOL WSAAPI WSASetEvent(WSAEVENT hEvent);
   1052   WINSOCK_API_LINKAGE SOCKET WSAAPI WSASocketA(int af,int type,int protocol,LPWSAPROTOCOL_INFOA lpProtocolInfo,GROUP g,DWORD dwFlags);
   1053   WINSOCK_API_LINKAGE SOCKET WSAAPI WSASocketW(int af,int type,int protocol,LPWSAPROTOCOL_INFOW lpProtocolInfo,GROUP g,DWORD dwFlags);
   1054   WINSOCK_API_LINKAGE DWORD WSAAPI WSAWaitForMultipleEvents(DWORD cEvents,const WSAEVENT *lphEvents,WINBOOL fWaitAll,DWORD dwTimeout,WINBOOL fAlertable);
   1055   WINSOCK_API_LINKAGE INT WSAAPI WSAAddressToStringA(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
   1056   WINSOCK_API_LINKAGE INT WSAAPI WSAAddressToStringW(LPSOCKADDR lpsaAddress,DWORD dwAddressLength,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPWSTR lpszAddressString,LPDWORD lpdwAddressStringLength);
   1057   WINSOCK_API_LINKAGE INT WSAAPI WSAStringToAddressA(LPSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOA lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
   1058   WINSOCK_API_LINKAGE INT WSAAPI WSAStringToAddressW(LPWSTR AddressString,INT AddressFamily,LPWSAPROTOCOL_INFOW lpProtocolInfo,LPSOCKADDR lpAddress,LPINT lpAddressLength);
   1059   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceBeginA(LPWSAQUERYSETA lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
   1060   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions,DWORD dwControlFlags,LPHANDLE lphLookup);
   1061   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceNextA(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETA lpqsResults);
   1062   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceNextW(HANDLE hLookup,DWORD dwControlFlags,LPDWORD lpdwBufferLength,LPWSAQUERYSETW lpqsResults);
   1063   WINSOCK_API_LINKAGE INT WSAAPI WSANSPIoctl(HANDLE hLookup,DWORD dwControlCode,LPVOID lpvInBuffer,DWORD cbInBuffer,LPVOID lpvOutBuffer,DWORD cbOutBuffer,LPDWORD lpcbBytesReturned,LPWSACOMPLETION lpCompletion);
   1064   WINSOCK_API_LINKAGE INT WSAAPI WSALookupServiceEnd(HANDLE hLookup);
   1065   WINSOCK_API_LINKAGE INT WSAAPI WSAInstallServiceClassA(LPWSASERVICECLASSINFOA lpServiceClassInfo);
   1066   WINSOCK_API_LINKAGE INT WSAAPI WSAInstallServiceClassW(LPWSASERVICECLASSINFOW lpServiceClassInfo);
   1067   WINSOCK_API_LINKAGE INT WSAAPI WSARemoveServiceClass(LPGUID lpServiceClassId);
   1068   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassInfoA(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOA lpServiceClassInfo);
   1069   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassInfoW(LPGUID lpProviderId,LPGUID lpServiceClassId,LPDWORD lpdwBufSize,LPWSASERVICECLASSINFOW lpServiceClassInfo);
   1070   WINSOCK_API_LINKAGE INT WSAAPI WSAEnumNameSpaceProvidersA(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOA lpnspBuffer);
   1071   WINSOCK_API_LINKAGE INT WSAAPI WSAEnumNameSpaceProvidersW(LPDWORD lpdwBufferLength,LPWSANAMESPACE_INFOW lpnspBuffer);
   1072   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassNameByClassIdA(LPGUID lpServiceClassId,LPSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
   1073   WINSOCK_API_LINKAGE INT WSAAPI WSAGetServiceClassNameByClassIdW(LPGUID lpServiceClassId,LPWSTR lpszServiceClassName,LPDWORD lpdwBufferLength);
   1074   WINSOCK_API_LINKAGE INT WSAAPI WSASetServiceA(LPWSAQUERYSETA lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
   1075   WINSOCK_API_LINKAGE INT WSAAPI WSASetServiceW(LPWSAQUERYSETW lpqsRegInfo,WSAESETSERVICEOP essoperation,DWORD dwControlFlags);
   1076   WINSOCK_API_LINKAGE INT WSAAPI WSAProviderConfigChange(LPHANDLE lpNotificationHandle,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
   1077 
   1078 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
   1079 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
   1080 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
   1081 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
   1082 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
   1083 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
   1084 
   1085 #if (_WIN32_WINNT >= 0x0600)
   1086 typedef struct _WSANAMESPACE_INFOEXA {
   1087   GUID NSProviderId;
   1088   DWORD dwNameSpace;
   1089   WINBOOL fActive;
   1090   DWORD dwVersion;
   1091   LPSTR lpszIdentifier;
   1092   BLOB ProviderSpecific;
   1093 } WSANAMESPACE_INFOEXA, *PWSANAMESPACE_INFOEXA, *LPWSANAMESPACE_INFOEXA;
   1094 
   1095 typedef struct _WSANAMESPACE_INFOEXW {
   1096   GUID NSProviderId;
   1097   DWORD dwNameSpace;
   1098   WINBOOL fActive;
   1099   DWORD dwVersion;
   1100   LPWSTR lpszIdentifier;
   1101   BLOB ProviderSpecific;
   1102 } WSANAMESPACE_INFOEXW, *PWSANAMESPACE_INFOEXW, *LPWSANAMESPACE_INFOEXW;
   1103 
   1104 __MINGW_TYPEDEF_AW(WSANAMESPACE_INFOEX)
   1105 __MINGW_TYPEDEF_AW(PWSANAMESPACE_INFOEX)
   1106 __MINGW_TYPEDEF_AW(LPWSANAMESPACE_INFOEX)
   1107 
   1108 typedef struct _WSAQUERYSET2A {
   1109   DWORD         dwSize;
   1110   LPSTR         lpszServiceInstanceName;
   1111   LPWSAVERSION  lpVersion;
   1112   LPSTR         lpszComment;
   1113   DWORD         dwNameSpace;
   1114   LPGUID        lpNSProviderId;
   1115   LPSTR         lpszContext;
   1116   DWORD         dwNumberOfProtocols;
   1117   LPAFPROTOCOLS lpafpProtocols;
   1118   LPSTR         lpszQueryString;
   1119   DWORD         dwNumberOfCsAddrs;
   1120   LPCSADDR_INFO lpcsaBuffer;
   1121   DWORD         dwOutputFlags;
   1122   LPBLOB        lpBlob;
   1123 } WSAQUERYSET2A, *PWSAQUERYSET2A, *LPWSAQUERYSET2A;
   1124 
   1125 typedef struct _WSAQUERYSET2W {
   1126   DWORD         dwSize;
   1127   LPWSTR        lpszServiceInstanceName;
   1128   LPWSAVERSION  lpVersion;
   1129   LPWSTR        lpszComment;
   1130   DWORD         dwNameSpace;
   1131   LPGUID        lpNSProviderId;
   1132   LPTSTR        lpszContext;
   1133   DWORD         dwNumberOfProtocols;
   1134   LPAFPROTOCOLS lpafpProtocols;
   1135   LPWSTR        lpszQueryString;
   1136   DWORD         dwNumberOfCsAddrs;
   1137   LPCSADDR_INFO lpcsaBuffer;
   1138   DWORD         dwOutputFlags;
   1139   LPBLOB        lpBlob;
   1140 } WSAQUERYSET2W, *PWSAQUERYSET2W, *LPWSAQUERYSET2W;
   1141 
   1142 #define POLLRDNORM 0x0100
   1143 #define POLLRDBAND 0x0200
   1144 #define POLLIN    (POLLRDNORM | POLLRDBAND)
   1145 #define POLLPRI    0x0400
   1146 
   1147 #define POLLWRNORM 0x0010
   1148 #define POLLOUT   (POLLWRNORM)
   1149 #define POLLWRBAND 0x0020
   1150 
   1151 #define POLLERR    0x0001
   1152 #define POLLHUP    0x0002
   1153 #define POLLNVAL   0x0004
   1154 
   1155 typedef struct pollfd {
   1156   SOCKET fd;
   1157   short  events;
   1158   short  revents;
   1159 } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
   1160 
   1161 WINSOCK_API_LINKAGE WINBOOL PASCAL WSAConnectByList(
   1162   SOCKET s,
   1163   PSOCKET_ADDRESS_LIST SocketAddressList,
   1164   LPDWORD LocalAddressLength,
   1165   LPSOCKADDR LocalAddress,
   1166   LPDWORD RemoteAddressLength,
   1167   LPSOCKADDR RemoteAddress,
   1168   const PTIMEVAL timeout,
   1169   LPWSAOVERLAPPED Reserved
   1170 );
   1171 
   1172 WINSOCK_API_LINKAGE WINBOOL PASCAL WSAConnectByNameA(
   1173   SOCKET s,
   1174   LPSTR nodename,
   1175   LPSTR servicename,
   1176   LPDWORD LocalAddressLength,
   1177   LPSOCKADDR LocalAddress,
   1178   LPDWORD RemoteAddressLength,
   1179   LPSOCKADDR RemoteAddress,
   1180   const PTIMEVAL timeout,
   1181   LPWSAOVERLAPPED Reserved
   1182 );
   1183 
   1184 WINSOCK_API_LINKAGE WINBOOL PASCAL WSAConnectByNameW(
   1185   SOCKET s,
   1186   LPWSTR nodename,
   1187   LPWSTR servicename,
   1188   LPDWORD LocalAddressLength,
   1189   LPSOCKADDR LocalAddress,
   1190   LPDWORD RemoteAddressLength,
   1191   LPSOCKADDR RemoteAddress,
   1192   const PTIMEVAL timeout,
   1193   LPWSAOVERLAPPED Reserved
   1194 );
   1195 #define WSAConnectByName __MINGW_NAME_AW(WSAConnectByName)
   1196 
   1197 INT WSAAPI WSAEnumNameSpaceProvidersExA(
   1198   LPDWORD lpdwBufferLength,
   1199   LPWSANAMESPACE_INFOEXA lpnspBuffer
   1200 );
   1201 
   1202 INT WSAAPI WSAEnumNameSpaceProvidersExW(
   1203   LPDWORD lpdwBufferLength,
   1204   LPWSANAMESPACE_INFOEXW lpnspBuffer
   1205 );
   1206 #define WSAEnumNameSpaceProvidersEx __MINGW_NAME_AW(WSAEnumNameSpaceProvidersEx)
   1207 
   1208 int WSAAPI WSAPoll(
   1209   WSAPOLLFD fdarray[],
   1210   ULONG nfds,
   1211   INT timeout
   1212 );
   1213 
   1214 int WSAAPI WSASendMsg(
   1215   SOCKET s,
   1216   LPWSAMSG lpMsg,
   1217   DWORD dwFlags,
   1218   LPDWORD lpNumberOfBytesSent,
   1219   LPWSAOVERLAPPED lpOverlapped,
   1220   LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
   1221 );
   1222 #endif /*(_WIN32_WINNT >= 0x0600)*/
   1223 
   1224 #ifdef __cplusplus
   1225 }
   1226 #endif
   1227 
   1228 #ifdef _NEED_POPPACK
   1229 #include <poppack.h>
   1230 #endif
   1231 
   1232 #ifdef IPV6STRICT
   1233 #include <wsipv6ok.h>
   1234 #endif
   1235 
   1236 #ifdef __LP64__
   1237 #pragma pop_macro("u_long")
   1238 #endif
   1239 
   1240 #endif /* _WINSOCK2API_ */
   1241