OSDN Git Service

_USE_32BIT_TIME_T resolution and prepare for release.
[mingw/mingw-org-wsl.git] / include / mswsock.h
1 /**
2  * @file mswsock.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _MSWSOCK_H
25 #define _MSWSOCK_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 /*
30  * MS-specific extensions to Windows Sockets, exported from mswsock.dll.
31  * These functions are N/A on Windows9x.
32  */
33          
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #define SO_CONNDATA     0x7000
39 #define SO_CONNOPT      0x7001
40 #define SO_DISCDATA     0x7002
41 #define SO_DISCOPT      0x7003
42 #define SO_CONNDATALEN  0x7004
43 #define SO_CONNOPTLEN   0x7005
44 #define SO_DISCDATALEN  0x7006
45 #define SO_DISCOPTLEN   0x7007
46 #define SO_OPENTYPE     0x7008
47 #define SO_SYNCHRONOUS_ALERT    0x10
48 #define SO_SYNCHRONOUS_NONALERT 0x20
49 #define SO_MAXDG        0x7009
50 #define SO_MAXPATHDG    0x700A
51 #define SO_UPDATE_ACCEPT_CONTEXT        0x700B
52 #define SO_CONNECT_TIME 0x700C
53 #define TCP_BSDURGENT   0x7000
54
55 #define TF_DISCONNECT   1
56 #define TF_REUSE_SOCKET 2
57 #define TF_WRITE_BEHIND 4
58 #define TF_USE_DEFAULT_WORKER   0
59 #define TF_USE_SYSTEM_THREAD    16
60 #define TF_USE_KERNEL_APC   32
61
62 typedef struct _TRANSMIT_FILE_BUFFERS {
63         PVOID Head;
64         DWORD HeadLength;
65         PVOID Tail;
66         DWORD TailLength;
67 } TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
68
69 int PASCAL WSARecvEx(SOCKET,char*,int,int*);
70 BOOL PASCAL TransmitFile(SOCKET,HANDLE,DWORD,DWORD,LPOVERLAPPED,LPTRANSMIT_FILE_BUFFERS,DWORD);
71 BOOL PASCAL AcceptEx(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED);
72 VOID PASCAL GetAcceptExSockaddrs(PVOID,DWORD,DWORD,DWORD,struct sockaddr**, LPINT, struct sockaddr**, LPINT);
73
74 #ifdef _WINSOCK2_H /* These require the winsock2 interface.  */
75
76 #define TP_ELEMENT_FILE         1
77 #define TP_ELEMENT_MEMORY       2
78 #define TP_ELEMENT_EOP          4
79
80 typedef struct _TRANSMIT_PACKETS_ELEMENT { 
81         ULONG dwElFlags;
82         ULONG cLength;
83         _ANONYMOUS_UNION
84         union {
85                 struct {
86                         LARGE_INTEGER   nFileOffset;
87                         HANDLE          hFile;
88                 };
89                 PVOID   pBuffer;
90         };
91 } TRANSMIT_PACKETS_ELEMENT; 
92
93 typedef struct _WSAMSG {
94         LPSOCKADDR      name;
95         INT             namelen;
96         LPWSABUF        lpBuffers;
97         DWORD           dwBufferCount;
98         WSABUF          Control;
99         DWORD           dwFlags;
100 } WSAMSG, *PWSAMSG, *LPWSAMSG;
101
102
103 /* According to MSDN docs, the WSAMSG.Control buffer starts with a
104    cmsghdr header of the following form.  See also RFC 2292. */
105
106 typedef struct wsacmsghdr {
107         UINT    cmsg_len;
108         INT     cmsg_level;
109         INT     cmsg_type;
110         /* followed by UCHAR cmsg_data[]; */
111 } WSACMSGHDR;
112
113 /* TODO: Standard Posix.1g macros as per RFC 2292, with WSA_uglification. */
114 #if 0
115 #define WSA_CMSG_FIRSTHDR(mhdr)
116 #define WSA_CMSG_NXTHDR(mhdr, cmsg)
117 #define WSA_CMSG_SPACE(length)
118 #define WSA_CMSG_LEN(length)
119 #endif
120
121 BOOL PASCAL DisconnectEx(SOCKET,LPOVERLAPPED,DWORD,DWORD);
122 int PASCAL WSARecvMsg(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE);
123
124 #endif /* _WINSOCK2_H */
125
126 #ifdef __cplusplus
127 }
128 #endif
129 #endif  /*  _MSWSOCK_H */
130