source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/winsock.h@ 1181

Last change on this file since 1181 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 11.9 KB
RevLine 
[1166]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#ifndef _WINSOCKAPI_
7#define _WINSOCKAPI_
8
9#ifndef _INC_WINDOWS
10#include <windows.h>
11#endif
12
13/* define WINSOCK_API_LINKAGE and WSAAPI for less
14 * diff output between winsock.h and winsock2.h, but
15 * remember to undefine them at the end of file */
16#ifndef WINSOCK_API_LINKAGE
17#define UNDEF_WINSOCK_API_LINKAGE
18#ifdef DECLSPEC_IMPORT
19#define WINSOCK_API_LINKAGE DECLSPEC_IMPORT
20#else
21#define WINSOCK_API_LINKAGE
22#endif
23#endif /* WINSOCK_API_LINKAGE */
24#define WSAAPI WINAPI
25
26#ifdef __LP64__
27#pragma push_macro("u_long")
28#undef u_long
29#define u_long __ms_u_long
30#endif
31
32#include <_timeval.h>
33#include <_bsd_types.h>
34#include <inaddr.h>
35#include <psdk_inc/_socket_types.h>
36#include <psdk_inc/_fd_types.h>
37#include <psdk_inc/_ip_types.h>
38#include <psdk_inc/_ip_mreq1.h>
39#include <psdk_inc/_wsadata.h>
40#include <psdk_inc/_xmitfile.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#define IOCPARM_MASK 0x7f
47#define IOC_VOID 0x20000000
48#define IOC_OUT 0x40000000
49#define IOC_IN 0x80000000
50#define IOC_INOUT (IOC_IN|IOC_OUT)
51
52#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
53#define _IOR(x,y,t) (IOC_OUT|(((__LONG32)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
54#define _IOW(x,y,t) (IOC_IN|(((__LONG32)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
55
56#define FIONREAD _IOR('f',127,u_long)
57#define FIONBIO _IOW('f',126,u_long)
58#define FIOASYNC _IOW('f',125,u_long)
59
60#define SIOCSHIWAT _IOW('s',0,u_long)
61#define SIOCGHIWAT _IOR('s',1,u_long)
62#define SIOCSLOWAT _IOW('s',2,u_long)
63#define SIOCGLOWAT _IOR('s',3,u_long)
64#define SIOCATMARK _IOR('s',7,u_long)
65
66#define IPPROTO_IP 0
67#define IPPROTO_ICMP 1
68#define IPPROTO_IGMP 2
69#define IPPROTO_GGP 3
70#define IPPROTO_TCP 6
71#define IPPROTO_PUP 12
72#define IPPROTO_UDP 17
73#define IPPROTO_IDP 22
74#define IPPROTO_ND 77
75
76#define IPPROTO_RAW 255
77#define IPPROTO_MAX 256
78
79#define IPPORT_ECHO 7
80#define IPPORT_DISCARD 9
81#define IPPORT_SYSTAT 11
82#define IPPORT_DAYTIME 13
83#define IPPORT_NETSTAT 15
84#define IPPORT_FTP 21
85#define IPPORT_TELNET 23
86#define IPPORT_SMTP 25
87#define IPPORT_TIMESERVER 37
88#define IPPORT_NAMESERVER 42
89#define IPPORT_WHOIS 43
90#define IPPORT_MTP 57
91
92#define IPPORT_TFTP 69
93#define IPPORT_RJE 77
94#define IPPORT_FINGER 79
95#define IPPORT_TTYLINK 87
96#define IPPORT_SUPDUP 95
97
98#define IPPORT_EXECSERVER 512
99#define IPPORT_LOGINSERVER 513
100#define IPPORT_CMDSERVER 514
101#define IPPORT_EFSSERVER 520
102
103#define IPPORT_BIFFUDP 512
104#define IPPORT_WHOSERVER 513
105#define IPPORT_ROUTESERVER 520
106
107#define IPPORT_RESERVED 1024
108
109#define IMPLINK_IP 155
110#define IMPLINK_LOWEXPER 156
111#define IMPLINK_HIGHEXPER 158
112
113
114#define IN_CLASSA(i) (((__LONG32)(i) & 0x80000000)==0)
115#define IN_CLASSA_NET 0xff000000
116#define IN_CLASSA_NSHIFT 24
117#define IN_CLASSA_HOST 0x00ffffff
118#define IN_CLASSA_MAX 128
119
120#define IN_CLASSB(i) (((__LONG32)(i) & 0xc0000000)==0x80000000)
121#define IN_CLASSB_NET 0xffff0000
122#define IN_CLASSB_NSHIFT 16
123#define IN_CLASSB_HOST 0x0000ffff
124#define IN_CLASSB_MAX 65536
125
126#define IN_CLASSC(i) (((__LONG32)(i) & 0xe0000000)==0xc0000000)
127#define IN_CLASSC_NET 0xffffff00
128#define IN_CLASSC_NSHIFT 8
129#define IN_CLASSC_HOST 0x000000ff
130
131#define INADDR_ANY (u_long)0x00000000
132#define INADDR_LOOPBACK 0x7f000001
133#define INADDR_BROADCAST (u_long)0xffffffff
134#define INADDR_NONE 0xffffffff
135
136
137#define IP_OPTIONS 1
138#define IP_MULTICAST_IF 2
139#define IP_MULTICAST_TTL 3
140#define IP_MULTICAST_LOOP 4
141#define IP_ADD_MEMBERSHIP 5
142#define IP_DROP_MEMBERSHIP 6
143#define IP_TTL 7
144#define IP_TOS 8
145#define IP_DONTFRAGMENT 9
146
147#define IP_DEFAULT_MULTICAST_TTL 1
148#define IP_DEFAULT_MULTICAST_LOOP 1
149#define IP_MAX_MEMBERSHIPS 20
150
151#define SOCK_STREAM 1
152#define SOCK_DGRAM 2
153#define SOCK_RAW 3
154#define SOCK_RDM 4
155#define SOCK_SEQPACKET 5
156
157#define SO_DEBUG 0x0001
158#define SO_ACCEPTCONN 0x0002
159#define SO_REUSEADDR 0x0004
160#define SO_KEEPALIVE 0x0008
161#define SO_DONTROUTE 0x0010
162#define SO_BROADCAST 0x0020
163#define SO_USELOOPBACK 0x0040
164#define SO_LINGER 0x0080
165#define SO_OOBINLINE 0x0100
166
167#define SO_DONTLINGER (u_int)(~SO_LINGER)
168
169#define SO_SNDBUF 0x1001
170#define SO_RCVBUF 0x1002
171#define SO_SNDLOWAT 0x1003
172#define SO_RCVLOWAT 0x1004
173#define SO_SNDTIMEO 0x1005
174#define SO_RCVTIMEO 0x1006
175#define SO_ERROR 0x1007
176#define SO_TYPE 0x1008
177
178#define SO_CONNDATA 0x7000
179#define SO_CONNOPT 0x7001
180#define SO_DISCDATA 0x7002
181#define SO_DISCOPT 0x7003
182#define SO_CONNDATALEN 0x7004
183#define SO_CONNOPTLEN 0x7005
184#define SO_DISCDATALEN 0x7006
185#define SO_DISCOPTLEN 0x7007
186
187#define SO_OPENTYPE 0x7008
188
189#define SO_SYNCHRONOUS_ALERT 0x10
190#define SO_SYNCHRONOUS_NONALERT 0x20
191
192#define SO_MAXDG 0x7009
193#define SO_MAXPATHDG 0x700A
194#define SO_UPDATE_ACCEPT_CONTEXT 0x700B
195#define SO_CONNECT_TIME 0x700C
196
197#define TCP_NODELAY 0x0001
198#define TCP_BSDURGENT 0x7000
199
200#define AF_UNSPEC 0
201#define AF_UNIX 1
202#define AF_INET 2
203#define AF_IMPLINK 3
204#define AF_PUP 4
205#define AF_CHAOS 5
206#define AF_IPX 6
207#define AF_NS 6
208#define AF_ISO 7
209#define AF_OSI AF_ISO
210#define AF_ECMA 8
211#define AF_DATAKIT 9
212#define AF_CCITT 10
213#define AF_SNA 11
214#define AF_DECnet 12
215#define AF_DLI 13
216#define AF_LAT 14
217#define AF_HYLINK 15
218#define AF_APPLETALK 16
219#define AF_NETBIOS 17
220#define AF_VOICEVIEW 18
221#define AF_FIREFOX 19
222#define AF_UNKNOWN1 20
223#define AF_BAN 21
224
225#define AF_MAX 22
226
227#define PF_UNSPEC AF_UNSPEC
228#define PF_UNIX AF_UNIX
229#define PF_INET AF_INET
230#define PF_IMPLINK AF_IMPLINK
231#define PF_PUP AF_PUP
232#define PF_CHAOS AF_CHAOS
233#define PF_NS AF_NS
234#define PF_IPX AF_IPX
235#define PF_ISO AF_ISO
236#define PF_OSI AF_OSI
237#define PF_ECMA AF_ECMA
238#define PF_DATAKIT AF_DATAKIT
239#define PF_CCITT AF_CCITT
240#define PF_SNA AF_SNA
241#define PF_DECnet AF_DECnet
242#define PF_DLI AF_DLI
243#define PF_LAT AF_LAT
244#define PF_HYLINK AF_HYLINK
245#define PF_APPLETALK AF_APPLETALK
246#define PF_VOICEVIEW AF_VOICEVIEW
247#define PF_FIREFOX AF_FIREFOX
248#define PF_UNKNOWN1 AF_UNKNOWN1
249#define PF_BAN AF_BAN
250
251#define PF_MAX AF_MAX
252
253#define SOL_SOCKET 0xffff
254
255#define SOMAXCONN 5
256
257#define MSG_OOB 0x1
258#define MSG_PEEK 0x2
259#define MSG_DONTROUTE 0x4
260
261#define MSG_MAXIOVLEN 16
262
263#define MSG_PARTIAL 0x8000
264
265#define MAXGETHOSTSTRUCT 1024
266
267#define FD_READ 0x01
268#define FD_WRITE 0x02
269#define FD_OOB 0x04
270#define FD_ACCEPT 0x08
271#define FD_CONNECT 0x10
272#define FD_CLOSE 0x20
273
274#include <psdk_inc/_wsa_errnos.h>
275
276/* these 46 functions have the same prototypes as in winsock2 */
277 WINSOCK_API_LINKAGE SOCKET WSAAPI accept(SOCKET s,struct sockaddr *addr,int *addrlen);
278 WINSOCK_API_LINKAGE int WSAAPI bind(SOCKET s,const struct sockaddr *name,int namelen);
279 WINSOCK_API_LINKAGE int WSAAPI closesocket(SOCKET s);
280 WINSOCK_API_LINKAGE int WSAAPI connect(SOCKET s,const struct sockaddr *name,int namelen);
281 WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
282 WINSOCK_API_LINKAGE int WSAAPI getpeername(SOCKET s,struct sockaddr *name,int *namelen);
283 WINSOCK_API_LINKAGE int WSAAPI getsockname(SOCKET s,struct sockaddr *name,int *namelen);
284 WINSOCK_API_LINKAGE int WSAAPI getsockopt(SOCKET s,int level,int optname,char *optval,int *optlen);
285#ifndef __INSIDE_CYGWIN__
286 WINSOCK_API_LINKAGE u_long WSAAPI htonl(u_long hostlong);
287 WINSOCK_API_LINKAGE u_short WSAAPI htons(u_short hostshort);
288#endif /* !__INSIDE_CYGWIN__ */
289 WINSOCK_API_LINKAGE unsigned __LONG32 WSAAPI inet_addr(const char *cp);
290 WINSOCK_API_LINKAGE char *WSAAPI inet_ntoa(struct in_addr in);
291 WINSOCK_API_LINKAGE int WSAAPI listen(SOCKET s,int backlog);
292#ifndef __INSIDE_CYGWIN__
293 WINSOCK_API_LINKAGE u_long WSAAPI ntohl(u_long netlong);
294 WINSOCK_API_LINKAGE u_short WSAAPI ntohs(u_short netshort);
295#endif /* !__INSIDE_CYGWIN__ */
296 WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags);
297 WINSOCK_API_LINKAGE int WSAAPI recvfrom(SOCKET s,char *buf,int len,int flags,struct sockaddr *from,int *fromlen);
298#ifndef __INSIDE_CYGWIN__
299 WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
300#endif /* !__INSIDE_CYGWIN__ */
301 WINSOCK_API_LINKAGE int WSAAPI send(SOCKET s,const char *buf,int len,int flags);
302 WINSOCK_API_LINKAGE int WSAAPI sendto(SOCKET s,const char *buf,int len,int flags,const struct sockaddr *to,int tolen);
303 WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int optname,const char *optval,int optlen);
304 WINSOCK_API_LINKAGE int WSAAPI shutdown(SOCKET s,int how);
305 WINSOCK_API_LINKAGE SOCKET WSAAPI socket(int af,int type,int protocol);
306 WINSOCK_API_LINKAGE struct hostent *WSAAPI gethostbyaddr(const char *addr,int len,int type);
307 WINSOCK_API_LINKAGE struct hostent *WSAAPI gethostbyname(const char *name);
308#ifndef __INSIDE_CYGWIN__
309 WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen);
310#endif /* !__INSIDE_CYGWIN__ */
311 WINSOCK_API_LINKAGE struct servent *WSAAPI getservbyport(int port,const char *proto);
312 WINSOCK_API_LINKAGE struct servent *WSAAPI getservbyname(const char *name,const char *proto);
313 WINSOCK_API_LINKAGE struct protoent *WSAAPI getprotobynumber(int number);
314 WINSOCK_API_LINKAGE struct protoent *WSAAPI getprotobyname(const char *name);
315 WINSOCK_API_LINKAGE int WSAAPI WSAStartup(WORD wVersionRequested,LPWSADATA lpWSAData);
316 WINSOCK_API_LINKAGE int WSAAPI WSACleanup(void);
317 WINSOCK_API_LINKAGE void WSAAPI WSASetLastError(int iError);
318 WINSOCK_API_LINKAGE int WSAAPI WSAGetLastError(void);
319 WINSOCK_API_LINKAGE WINBOOL WSAAPI WSAIsBlocking(void);
320 WINSOCK_API_LINKAGE int WSAAPI WSAUnhookBlockingHook(void);
321 WINSOCK_API_LINKAGE FARPROC WSAAPI WSASetBlockingHook(FARPROC lpBlockFunc);
322 WINSOCK_API_LINKAGE int WSAAPI WSACancelBlockingCall(void);
323 WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetServByName(HWND hWnd,u_int wMsg,const char *name,const char *proto,char *buf,int buflen);
324 WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetServByPort(HWND hWnd,u_int wMsg,int port,const char *proto,char *buf,int buflen);
325 WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetProtoByName(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
326 WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetProtoByNumber(HWND hWnd,u_int wMsg,int number,char *buf,int buflen);
327 WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetHostByName(HWND hWnd,u_int wMsg,const char *name,char *buf,int buflen);
328 WINSOCK_API_LINKAGE HANDLE WSAAPI WSAAsyncGetHostByAddr(HWND hWnd,u_int wMsg,const char *addr,int len,int type,char *buf,int buflen);
329 WINSOCK_API_LINKAGE int WSAAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
330 WINSOCK_API_LINKAGE int WSAAPI WSAAsyncSelect(SOCKET s,HWND hWnd,u_int wMsg,__LONG32 lEvent);
331#define __WINSOCK_WS1_SHARED /* avoid redefinitions in winsock2.h */
332
333/* these four functions are in mswsock.h in the new api */
334 int WINAPI WSARecvEx(SOCKET s,char *buf,int len,int *flags);
335
336#define TF_DISCONNECT 0x01
337#define TF_REUSE_SOCKET 0x02
338#define TF_WRITE_BEHIND 0x04
339
340 WINBOOL WINAPI TransmitFile(SOCKET hSocket,HANDLE hFile,DWORD nNumberOfBytesToWrite,DWORD nNumberOfBytesPerSend,LPOVERLAPPED lpOverlapped,LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,DWORD dwReserved);
341 WINBOOL WINAPI AcceptEx(SOCKET sListenSocket,SOCKET sAcceptSocket,PVOID lpOutputBuffer,DWORD dwReceiveDataLength,DWORD dwLocalAddressLength,DWORD dwRemoteAddressLength,LPDWORD lpdwBytesReceived,LPOVERLAPPED lpOverlapped);
342 VOID WINAPI GetAcceptExSockaddrs(PVOID lpOutputBuffer,DWORD dwReceiveDataLength,DWORD dwLocalAddressLength,DWORD dwRemoteAddressLength,struct sockaddr **LocalSockaddr,LPINT LocalSockaddrLength,struct sockaddr **RemoteSockaddr,LPINT RemoteSockaddrLength);
343#define __MSWSOCK_WS1_SHARED /* avoid redefinitions in mswsock.h */
344
345#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
346#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
347#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
348#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
349#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
350#define WSAGETSELECTERROR(lParam) HIWORD(lParam)
351
352#ifdef __cplusplus
353}
354#endif
355
356#ifdef UNDEF_WINSOCK_API_LINKAGE
357#undef WINSOCK_API_LINKAGE
358#undef UNDEF_WINSOCK_API_LINKAGE
359#endif
360
361#undef WSAAPI
362
363#ifdef IPV6STRICT
364#error WINSOCK2 required.
365#endif
366
367#ifdef __LP64__
368#pragma pop_macro("u_long")
369#endif
370
371#endif /* _WINSOCKAPI_ */
Note: See TracBrowser for help on using the repository browser.