xref: /reactos/sdk/include/psdk/mswsock.h (revision d6eebaa4)
1 /*
2  * mswsock.h
3  * MS-specific extensions to Windows Sockets, exported from mswsock.dll.
4  * These functions are N/A on Windows9x.
5  *
6  * This file is part of a free library for the Win32 API.
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
12 #pragma once
13 
14 #define _MSWSOCK_
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <mswsockdef.h>
21 
22 #define SO_CONNDATA               0x7000
23 #define SO_CONNOPT                0x7001
24 #define SO_DISCDATA               0x7002
25 #define SO_DISCOPT                0x7003
26 #define SO_CONNDATALEN            0x7004
27 #define SO_CONNOPTLEN             0x7005
28 #define SO_DISCDATALEN            0x7006
29 #define SO_DISCOPTLEN             0x7007
30 #define SO_OPENTYPE               0x7008
31 #define SO_SYNCHRONOUS_ALERT      0x10
32 #define SO_SYNCHRONOUS_NONALERT   0x20
33 #define SO_MAXDG                  0x7009
34 #define SO_MAXPATHDG              0x700A
35 #define SO_UPDATE_ACCEPT_CONTEXT  0x700B
36 #define SO_CONNECT_TIME           0x700C
37 #if(_WIN32_WINNT >= 0x0501)
38 #define SO_UPDATE_CONNECT_CONTEXT 0x7010
39 #endif
40 
41 #define TCP_BSDURGENT            0x7000
42 
43 #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
44 
45 #if((_WIN32_WINNT < 0x0600) && (_WIN32_WINNT >= 0x0501))
46 #define SIO_SOCKET_CLOSE_NOTIFY _WSAIOW(IOC_VENDOR,13)
47 #endif
48 
49 #define SIO_UDP_NETRESET _WSAIOW(IOC_VENDOR,15)
50 
51 #define TF_DISCONNECT            1
52 #define TF_REUSE_SOCKET          2
53 #define TF_WRITE_BEHIND          4
54 
55 #define TF_USE_DEFAULT_WORKER    0
56 #define TF_USE_SYSTEM_THREAD     16
57 #define TF_USE_KERNEL_APC        32
58 
59 #if(_WIN32_WINNT >= 0x0501)
60 #define TP_ELEMENT_MEMORY        1
61 #define TP_ELEMENT_FILE          2
62 #define TP_ELEMENT_EOP           4
63 #endif
64 
65 #define TP_DISCONNECT            TF_DISCONNECT
66 #define TP_REUSE_SOCKET          TF_REUSE_SOCKET
67 #define TP_USE_DEFAULT_WORKER    TF_USE_DEFAULT_WORKER
68 #define TP_USE_SYSTEM_THREAD     TF_USE_SYSTEM_THREAD
69 #define TP_USE_KERNEL_APC        TF_USE_KERNEL_APC
70 
71 #define WSAID_TRANSMITFILE \
72   {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
73 
74 #define WSAID_ACCEPTEX \
75   {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
76 
77 #define WSAID_GETACCEPTEXSOCKADDRS \
78   {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
79 
80 typedef struct _TRANSMIT_FILE_BUFFERS {
81   LPVOID Head;
82   DWORD HeadLength;
83   LPVOID Tail;
84   DWORD TailLength;
85 } TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, FAR *LPTRANSMIT_FILE_BUFFERS;
86 
87 typedef BOOL
88 (PASCAL FAR *LPFN_TRANSMITFILE)(
89   _In_ SOCKET hSocket,
90   _In_ HANDLE hFile,
91   _In_ DWORD nNumberOfBytesToWrite,
92   _In_ DWORD nNumberOfBytesPerSend,
93   _Inout_opt_ LPOVERLAPPED lpOverlapped,
94   _In_opt_ LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
95   _In_ DWORD dwReserved);
96 
97 typedef BOOL
98 (PASCAL FAR *LPFN_ACCEPTEX)(
99   _In_ SOCKET sListenSocket,
100   _In_ SOCKET sAcceptSocket,
101   _Out_writes_bytes_(dwReceiveDataLength + dwLocalAddressLength + dwRemoteAddressLength) PVOID lpOutputBuffer,
102   _In_ DWORD dwReceiveDataLength,
103   _In_ DWORD dwLocalAddressLength,
104   _In_ DWORD dwRemoteAddressLength,
105   _Out_ LPDWORD lpdwBytesReceived,
106   _Inout_ LPOVERLAPPED lpOverlapped);
107 
108 typedef VOID
109 (PASCAL FAR *LPFN_GETACCEPTEXSOCKADDRS)(
110   _In_reads_bytes_(dwReceiveDataLength + dwLocalAddressLength + dwRemoteAddressLength) PVOID lpOutputBuffer,
111   _In_ DWORD dwReceiveDataLength,
112   _In_ DWORD dwLocalAddressLength,
113   _In_ DWORD dwRemoteAddressLength,
114   _Outptr_result_bytebuffer_(*LocalSockaddrLength) struct sockaddr **LocalSockaddr,
115   _Out_ LPINT LocalSockaddrLength,
116   _Outptr_result_bytebuffer_(*RemoteSockaddrLength) struct sockaddr **RemoteSockaddr,
117   _Out_ LPINT RemoteSockaddrLength);
118 
119 #if(_WIN32_WINNT >= 0x0501)
120 
121 typedef struct _TRANSMIT_PACKETS_ELEMENT {
122   ULONG dwElFlags;
123   ULONG cLength;
124   union {
125     struct {
126       LARGE_INTEGER nFileOffset;
127       HANDLE hFile;
128     };
129     PVOID pBuffer;
130   };
131 } TRANSMIT_PACKETS_ELEMENT, *PTRANSMIT_PACKETS_ELEMENT, FAR *LPTRANSMIT_PACKETS_ELEMENT;
132 
133 typedef BOOL
134 (PASCAL FAR *LPFN_TRANSMITPACKETS)(
135   _In_ SOCKET hSocket,
136   _In_opt_ LPTRANSMIT_PACKETS_ELEMENT lpPacketArray,
137   _In_ DWORD nElementCount,
138   _In_ DWORD nSendSize,
139   _Inout_opt_ LPOVERLAPPED lpOverlapped,
140   _In_ DWORD dwFlags);
141 
142 #define WSAID_TRANSMITPACKETS \
143   {0xd9689da0,0x1f90,0x11d3,{0x99,0x71,0x00,0xc0,0x4f,0x68,0xc8,0x76}}
144 
145 typedef BOOL
146 (PASCAL FAR *LPFN_CONNECTEX)(
147   _In_ SOCKET s,
148   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
149   _In_ int namelen,
150   _In_reads_bytes_opt_(dwSendDataLength) PVOID lpSendBuffer,
151   _In_ DWORD dwSendDataLength,
152   _Out_ LPDWORD lpdwBytesSent,
153   _Inout_ LPOVERLAPPED lpOverlapped);
154 
155 #define WSAID_CONNECTEX \
156   {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
157 
158 typedef BOOL
159 (PASCAL FAR *LPFN_DISCONNECTEX)(
160   _In_ SOCKET s,
161   _Inout_opt_ LPOVERLAPPED lpOverlapped,
162   _In_ DWORD dwFlags,
163   _In_ DWORD dwReserved);
164 
165 #define WSAID_DISCONNECTEX \
166   {0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
167 
168 #define DE_REUSE_SOCKET TF_REUSE_SOCKET
169 
170 #define NLA_NAMESPACE_GUID \
171   {0x6642243a,0x3ba8,0x4aa6,{0xba,0xa5,0x2e,0xb,0xd7,0x1f,0xdd,0x83}}
172 
173 #define NLA_SERVICE_CLASS_GUID \
174   {0x37e515,0xb5c9,0x4a43,{0xba,0xda,0x8b,0x48,0xa8,0x7a,0xd2,0x39}}
175 
176 #define NLA_ALLUSERS_NETWORK     0x00000001
177 #define NLA_FRIENDLY_NAME        0x00000002
178 
179 typedef enum _NLA_BLOB_DATA_TYPE {
180   NLA_RAW_DATA = 0,
181   NLA_INTERFACE = 1,
182   NLA_802_1X_LOCATION = 2,
183   NLA_CONNECTIVITY = 3,
184   NLA_ICS = 4,
185 } NLA_BLOB_DATA_TYPE, *PNLA_BLOB_DATA_TYPE;
186 
187 typedef enum _NLA_CONNECTIVITY_TYPE {
188   NLA_NETWORK_AD_HOC = 0,
189   NLA_NETWORK_MANAGED = 1,
190   NLA_NETWORK_UNMANAGED = 2,
191   NLA_NETWORK_UNKNOWN = 3,
192 } NLA_CONNECTIVITY_TYPE, *PNLA_CONNECTIVITY_TYPE;
193 
194 typedef enum _NLA_INTERNET {
195   NLA_INTERNET_UNKNOWN = 0,
196   NLA_INTERNET_NO = 1,
197   NLA_INTERNET_YES = 2,
198 } NLA_INTERNET, *PNLA_INTERNET;
199 
200 typedef struct _NLA_BLOB {
201   struct {
202     NLA_BLOB_DATA_TYPE type;
203     DWORD dwSize;
204     DWORD nextOffset;
205   } header;
206   union {
207     CHAR rawData[1];
208     struct {
209       DWORD dwType;
210       DWORD dwSpeed;
211       CHAR adapterName[1];
212     } interfaceData;
213     struct {
214       CHAR information[1];
215     } locationData;
216     struct {
217       NLA_CONNECTIVITY_TYPE type;
218       NLA_INTERNET internet;
219     } connectivity;
220     struct {
221       struct {
222         DWORD speed;
223         DWORD type;
224         DWORD state;
225         WCHAR machineName[256];
226         WCHAR sharedAdapterName[256];
227       } remote;
228     } ICS;
229   } data;
230 } NLA_BLOB, *PNLA_BLOB, * FAR LPNLA_BLOB;
231 
232 typedef INT
233 (PASCAL FAR *LPFN_WSARECVMSG)(
234   _In_ SOCKET s,
235   _Inout_ LPWSAMSG lpMsg,
236   _Out_opt_ LPDWORD lpdwNumberOfBytesRecvd,
237   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
238   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
239 
240 #define WSAID_WSARECVMSG \
241   {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
242 
243 #endif /* (_WIN32_WINNT >= 0x0501) */
244 
245 #if(_WIN32_WINNT >= 0x0600)
246 
247 #define SIO_BSP_HANDLE          _WSAIOR(IOC_WS2,27)
248 #define SIO_BSP_HANDLE_SELECT   _WSAIOR(IOC_WS2,28)
249 #define SIO_BSP_HANDLE_POLL     _WSAIOR(IOC_WS2,29)
250 
251 #define SIO_BASE_HANDLE         _WSAIOR(IOC_WS2,34)
252 
253 #define SIO_EXT_SELECT          _WSAIORW(IOC_WS2,30)
254 #define SIO_EXT_POLL            _WSAIORW(IOC_WS2,31)
255 #define SIO_EXT_SENDMSG         _WSAIORW(IOC_WS2,32)
256 
257 typedef struct {
258   int result;
259   ULONG fds;
260   INT timeout;
261   WSAPOLLFD fdArray[0];
262 } WSAPOLLDATA, *LPWSAPOLLDATA;
263 
264 typedef struct {
265   LPWSAMSG lpMsg;
266   DWORD dwFlags;
267   LPDWORD lpNumberOfBytesSent;
268   LPWSAOVERLAPPED lpOverlapped;
269   LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine;
270 } WSASENDMSG, *LPWSASENDMSG;
271 
272 typedef INT
273 (PASCAL FAR *LPFN_WSASENDMSG)(
274   _In_ SOCKET s,
275   _In_ LPWSAMSG lpMsg,
276   _In_ DWORD dwFlags,
277   _Out_opt_ LPDWORD lpNumberOfBytesSent,
278   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
279   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
280 
281 #define WSAID_WSASENDMSG \
282   {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}}
283 
284 typedef INT
285 (WSAAPI *LPFN_WSAPOLL)(
286   _Inout_ LPWSAPOLLFD fdarray,
287   _In_ ULONG nfds,
288   _In_ INT timeout);
289 
290 #define WSAID_WSAPOLL \
291   {0x18C76F85,0xDC66,0x4964,{0x97,0x2E,0x23,0xC2,0x72,0x38,0x31,0x2B}}
292 
293 #endif /* (_WIN32_WINNT >= 0x0600) */
294 
295 #if(_WIN32_WINNT < 0x0600)
296 int
297 PASCAL
298 FAR
299 WSARecvEx(
300   _In_ SOCKET s,
301   _Out_writes_bytes_to_(len, return) char FAR *buf,
302   _In_ int len,
303   _Inout_ int FAR *flags);
304 #else
305 INT
306 PASCAL
307 FAR
308 WSARecvEx(
309   _In_ SOCKET s,
310   _Out_writes_bytes_to_(len, return) CHAR FAR *buf,
311   _In_ INT len,
312   _Inout_ INT FAR *flags);
313 #endif /* (_WIN32_WINNT < 0x0600) */
314 
315 BOOL
316 PASCAL
317 FAR
318 TransmitFile(
319   _In_ SOCKET hSocket,
320   _In_ HANDLE hFile,
321   _In_ DWORD nNumberOfBytesToWrite,
322   _In_ DWORD nNumberOfBytesPerSend,
323   _Inout_opt_ LPOVERLAPPED lpOverlapped,
324   _In_opt_ LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
325   _In_ DWORD dwReserved);
326 
327 BOOL
328 PASCAL
329 FAR
330 AcceptEx(
331   _In_ SOCKET sListenSocket,
332   _In_ SOCKET sAcceptSocket,
333   _Out_writes_bytes_(dwReceiveDataLength + dwLocalAddressLength + dwRemoteAddressLength) PVOID lpOutputBuffer,
334   _In_ DWORD dwReceiveDataLength,
335   _In_ DWORD dwLocalAddressLength,
336   _In_ DWORD dwRemoteAddressLength,
337   _Out_ LPDWORD lpdwBytesReceived,
338   _Inout_ LPOVERLAPPED lpOverlapped);
339 
340 VOID
341 PASCAL
342 FAR
343 GetAcceptExSockaddrs(
344   _In_reads_bytes_(dwReceiveDataLength + dwLocalAddressLength + dwRemoteAddressLength) PVOID lpOutputBuffer,
345   _In_ DWORD dwReceiveDataLength,
346   _In_ DWORD dwLocalAddressLength,
347   _In_ DWORD dwRemoteAddressLength,
348   _Outptr_result_bytebuffer_(*LocalSockaddrLength) struct sockaddr **LocalSockaddr,
349   _Out_ LPINT LocalSockaddrLength,
350   _Outptr_result_bytebuffer_(*RemoteSockaddrLength) struct sockaddr **RemoteSockaddr,
351   _Out_ LPINT RemoteSockaddrLength);
352 
353 #ifdef __cplusplus
354 }
355 #endif
356