Implement support for FIONREAD in WSPIoctl. (hope I did it properly)
[reactos.git] / reactos / include / reactos / drivers / afd / shared.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Ancillary Function Driver
4 * FILE: include/afd/shared.h
5 * PURPOSE: Shared definitions for AFD.SYS and MSAFD.DLL
6 */
7 #ifndef __AFD_SHARED_H
8 #define __AFD_SHARED_H
9
10 #define AFD_MAX_EVENTS 10
11 #define AFD_PACKET_COMMAND_LENGTH 15
12 #define AfdCommand "AfdOpenPacketXX"
13
14 /* Extra definition of WSABUF for AFD so that I don't have to include any
15 * userland winsock headers. */
16 typedef struct _AFD_WSABUF {
17 UINT len;
18 PCHAR buf;
19 } AFD_WSABUF, *PAFD_WSABUF;
20
21 typedef struct _AFD_CREATE_PACKET {
22 DWORD EndpointFlags;
23 DWORD GroupID;
24 DWORD SizeOfTransportName;
25 WCHAR TransportName[1];
26 } AFD_CREATE_PACKET, *PAFD_CREATE_PACKET;
27
28 typedef struct _AFD_INFO {
29 ULONG InformationClass;
30 union {
31 ULONG Ulong;
32 LARGE_INTEGER LargeInteger;
33 } Information;
34 ULONG Padding;
35 } AFD_INFO, *PAFD_INFO;
36
37 typedef struct _AFD_BIND_DATA {
38 ULONG ShareType;
39 TRANSPORT_ADDRESS Address;
40 } AFD_BIND_DATA, *PAFD_BIND_DATA;
41
42 typedef struct _AFD_LISTEN_DATA {
43 BOOLEAN UseSAN;
44 ULONG Backlog;
45 BOOLEAN UseDelayedAcceptance;
46 } AFD_LISTEN_DATA, *PAFD_LISTEN_DATA;
47
48 typedef struct _AFD_HANDLE_ {
49 SOCKET Handle;
50 ULONG Events;
51 NTSTATUS Status;
52 } AFD_HANDLE, *PAFD_HANDLE;
53
54 typedef struct _AFD_POLL_INFO {
55 LARGE_INTEGER Timeout;
56 ULONG HandleCount;
57 ULONG Exclusive;
58 AFD_HANDLE Handles[1];
59 } AFD_POLL_INFO, *PAFD_POLL_INFO;
60
61 typedef struct _AFD_ACCEPT_DATA {
62 ULONG UseSAN;
63 ULONG SequenceNumber;
64 ULONG ListenHandle;
65 } AFD_ACCEPT_DATA, *PAFD_ACCEPT_DATA;
66
67 typedef struct _AFD_RECEIVED_ACCEPT_DATA {
68 ULONG SequenceNumber;
69 TRANSPORT_ADDRESS Address;
70 } AFD_RECEIVED_ACCEPT_DATA, *PAFD_RECEIVED_ACCEPT_DATA;
71
72 typedef struct _AFD_PENDING_ACCEPT_DATA {
73 ULONG SequenceNumber;
74 ULONG SizeOfData;
75 ULONG ReturnSize;
76 } AFD_PENDING_ACCEPT_DATA, *PAFD_PENDING_ACCEPT_DATA;
77
78 typedef struct _AFD_DEFER_ACCEPT_DATA {
79 ULONG SequenceNumber;
80 BOOLEAN RejectConnection;
81 } AFD_DEFER_ACCEPT_DATA, *PAFD_DEFER_ACCEPT_DATA;
82
83 typedef struct _AFD_RECV_INFO {
84 PAFD_WSABUF BufferArray;
85 ULONG BufferCount;
86 ULONG AfdFlags;
87 ULONG TdiFlags;
88 } AFD_RECV_INFO , *PAFD_RECV_INFO ;
89
90 typedef struct _AFD_RECV_INFO_UDP {
91 PAFD_WSABUF BufferArray;
92 ULONG BufferCount;
93 ULONG AfdFlags;
94 ULONG TdiFlags;
95 PVOID Address;
96 PINT AddressLength;
97 } AFD_RECV_INFO_UDP, *PAFD_RECV_INFO_UDP;
98
99 typedef struct _AFD_SEND_INFO {
100 PAFD_WSABUF BufferArray;
101 ULONG BufferCount;
102 ULONG AfdFlags;
103 ULONG TdiFlags;
104 } AFD_SEND_INFO , *PAFD_SEND_INFO ;
105
106 typedef struct _AFD_SEND_INFO_UDP {
107 PAFD_WSABUF BufferArray;
108 ULONG BufferCount;
109 ULONG AfdFlags;
110 ULONG Padding[9];
111 ULONG SizeOfRemoteAddress;
112 PVOID RemoteAddress;
113 } AFD_SEND_INFO_UDP, *PAFD_SEND_INFO_UDP;
114
115 typedef struct _AFD_CONNECT_INFO {
116 BOOLEAN UseSAN;
117 ULONG Root;
118 ULONG Unknown;
119 TRANSPORT_ADDRESS RemoteAddress;
120 } AFD_CONNECT_INFO , *PAFD_CONNECT_INFO ;
121
122 typedef struct _AFD_EVENT_SELECT_INFO {
123 HANDLE EventObject;
124 ULONG Events;
125 } AFD_EVENT_SELECT_INFO, *PAFD_EVENT_SELECT_INFO;
126
127 typedef struct _AFD_ENUM_NETWORK_EVENTS_INFO {
128 HANDLE Event;
129 ULONG PollEvents;
130 NTSTATUS EventStatus[AFD_MAX_EVENTS];
131 } AFD_ENUM_NETWORK_EVENTS_INFO, *PAFD_ENUM_NETWORK_EVENTS_INFO;
132
133 typedef struct _AFD_DISCONNECT_INFO {
134 ULONG DisconnectType;
135 LARGE_INTEGER Timeout;
136 } AFD_DISCONNECT_INFO, *PAFD_DISCONNECT_INFO;
137
138 /* AFD Packet Endpoint Flags */
139 #define AFD_ENDPOINT_CONNECTIONLESS 0x1
140 #define AFD_ENDPOINT_MESSAGE_ORIENTED 0x10
141 #define AFD_ENDPOINT_RAW 0x100
142 #define AFD_ENDPOINT_MULTIPOINT 0x1000
143 #define AFD_ENDPOINT_C_ROOT 0x10000
144 #define AFD_ENDPOINT_D_ROOT 0x100000
145
146 /* AFD Info Flags */
147 #define AFD_INFO_BLOCKING_MODE 0x02L
148 #define AFD_INFO_SENDS_IN_PROGRESS 0x04L
149 #define AFD_INFO_RECEIVE_WINDOW_SIZE 0x06L
150 #define AFD_INFO_SEND_WINDOW_SIZE 0x07L
151 #define AFD_INFO_GROUP_ID_TYPE 0x10L
152 #define AFD_INFO_RECEIVE_CONTENT_SIZE 0x11L
153
154 /* AFD Share Flags */
155 #define AFD_SHARE_UNIQUE 0x0L
156 #define AFD_SHARE_REUSE 0x1L
157 #define AFD_SHARE_WILDCARD 0x2L
158 #define AFD_SHARE_EXCLUSIVE 0x3L
159
160 /* AFD Disconnect Flags */
161 #define AFD_DISCONNECT_SEND 0x01L
162 #define AFD_DISCONNECT_RECV 0x02L
163 #define AFD_DISCONNECT_ABORT 0x04L
164
165 /* AFD Event Flags */
166 #define AFD_EVENT_RECEIVE 0x1L
167 #define AFD_EVENT_OOB_RECEIVE 0x2L
168 #define AFD_EVENT_SEND 0x4L
169 #define AFD_EVENT_DISCONNECT 0x8L
170 #define AFD_EVENT_ABORT 0x10L
171 #define AFD_EVENT_CLOSE 0x20L
172 #define AFD_EVENT_CONNECT 0x40L
173 #define AFD_EVENT_ACCEPT 0x80L
174 #define AFD_EVENT_CONNECT_FAIL 0x100L
175 #define AFD_EVENT_QOS 0x200L
176 #define AFD_EVENT_GROUP_QOS 0x400L
177
178 /* AFD SEND/RECV Flags */
179 #define AFD_SKIP_FIO 0x1L
180 #define AFD_OVERLAPPED 0x2L
181 #define AFD_IMMEDIATE 0x4L
182
183 /* IOCTL Generation */
184 #define FSCTL_AFD_BASE FILE_DEVICE_NETWORK
185 #define _AFD_CONTROL_CODE(Operation,Method) \
186 ((FSCTL_AFD_BASE)<<12 | (Operation<<2) | Method)
187
188 /* AFD Commands */
189 #define AFD_BIND 0
190 #define AFD_CONNECT 1
191 #define AFD_START_LISTEN 2
192 #define AFD_WAIT_FOR_LISTEN 3
193 #define AFD_ACCEPT 4
194 #define AFD_RECV 5
195 #define AFD_RECV_DATAGRAM 6
196 #define AFD_SEND 7
197 #define AFD_SEND_DATAGRAM 8
198 #define AFD_SELECT 9
199 #define AFD_DISCONNECT 10
200 #define AFD_GET_SOCK_NAME 11
201 #define AFD_GET_PEER_NAME 12
202 #define AFD_GET_TDI_HANDLES 13
203 #define AFD_SET_INFO 14
204 #define AFD_GET_CONTEXT 16
205 #define AFD_SET_CONTEXT 17
206 #define AFD_SET_CONNECT_DATA 18
207 #define AFD_SET_CONNECT_OPTIONS 19
208 #define AFD_SET_DISCONNECT_DATA 20
209 #define AFD_SET_DISCONNECT_OPTIONS 21
210 #define AFD_GET_CONNECT_DATA 22
211 #define AFD_GET_CONNECT_OPTIONS 23
212 #define AFD_GET_DISCONNECT_DATA 24
213 #define AFD_GET_DISCONNECT_OPTIONS 25
214 #define AFD_SET_CONNECT_DATA_SIZE 26
215 #define AFD_SET_CONNECT_OPTIONS_SIZE 27
216 #define AFD_SET_DISCONNECT_DATA_SIZE 28
217 #define AFD_SET_DISCONNECT_OPTIONS_SIZE 29
218 #define AFD_GET_INFO 30
219 #define AFD_EVENT_SELECT 33
220 #define AFD_ENUM_NETWORK_EVENTS 34
221 #define AFD_DEFER_ACCEPT 35
222 #define AFD_GET_PENDING_CONNECT_DATA 41
223
224 /* AFD IOCTLs */
225
226 #define IOCTL_AFD_BIND \
227 _AFD_CONTROL_CODE(AFD_BIND, METHOD_NEITHER)
228 #define IOCTL_AFD_CONNECT \
229 _AFD_CONTROL_CODE(AFD_CONNECT, METHOD_NEITHER)
230 #define IOCTL_AFD_START_LISTEN \
231 _AFD_CONTROL_CODE(AFD_START_LISTEN, METHOD_NEITHER)
232 #define IOCTL_AFD_WAIT_FOR_LISTEN \
233 _AFD_CONTROL_CODE(AFD_WAIT_FOR_LISTEN, METHOD_BUFFERED )
234 #define IOCTL_AFD_ACCEPT \
235 _AFD_CONTROL_CODE(AFD_ACCEPT, METHOD_BUFFERED )
236 #define IOCTL_AFD_RECV \
237 _AFD_CONTROL_CODE(AFD_RECV, METHOD_NEITHER)
238 #define IOCTL_AFD_RECV_DATAGRAM \
239 _AFD_CONTROL_CODE(AFD_RECV_DATAGRAM, METHOD_NEITHER)
240 #define IOCTL_AFD_SEND \
241 _AFD_CONTROL_CODE(AFD_SEND, METHOD_NEITHER)
242 #define IOCTL_AFD_SEND_DATAGRAM \
243 _AFD_CONTROL_CODE(AFD_SEND_DATAGRAM, METHOD_NEITHER)
244 #define IOCTL_AFD_SELECT \
245 _AFD_CONTROL_CODE(AFD_SELECT, METHOD_BUFFERED )
246 #define IOCTL_AFD_DISCONNECT \
247 _AFD_CONTROL_CODE(AFD_DISCONNECT, METHOD_NEITHER)
248 #define IOCTL_AFD_GET_SOCK_NAME \
249 _AFD_CONTROL_CODE(AFD_GET_SOCK_NAME, METHOD_NEITHER)
250 #define IOCTL_AFD_GET_PEER_NAME \
251 _AFD_CONTROL_CODE(AFD_GET_PEER_NAME, METHOD_NEITHER)
252 #define IOCTL_AFD_GET_TDI_HANDLES \
253 _AFD_CONTROL_CODE(AFD_GET_TDI_HANDLES, METHOD_NEITHER)
254 #define IOCTL_AFD_SET_INFO \
255 _AFD_CONTROL_CODE(AFD_SET_INFO, METHOD_NEITHER)
256 #define IOCTL_AFD_GET_CONTEXT \
257 _AFD_CONTROL_CODE(AFD_GET_CONTEXT, METHOD_NEITHER)
258 #define IOCTL_AFD_SET_CONTEXT \
259 _AFD_CONTROL_CODE(AFD_SET_CONTEXT, METHOD_NEITHER)
260 #define IOCTL_AFD_SET_CONNECT_DATA \
261 _AFD_CONTROL_CODE(AFD_SET_CONNECT_DATA, METHOD_NEITHER)
262 #define IOCTL_AFD_SET_CONNECT_OPTIONS \
263 _AFD_CONTROL_CODE(AFD_SET_CONNECT_OPTIONS, METHOD_NEITHER)
264 #define IOCTL_AFD_SET_DISCONNECT_DATA \
265 _AFD_CONTROL_CODE(AFD_SET_DISCONNECT_DATA, METHOD_NEITHER)
266 #define IOCTL_AFD_SET_DISCONNECT_OPTIONS \
267 _AFD_CONTROL_CODE(AFD_SET_DISCONNECT_OPTIONS, METHOD_NEITHER)
268 #define IOCTL_AFD_GET_CONNECT_DATA \
269 _AFD_CONTROL_CODE(AFD_GET_CONNECT_DATA, METHOD_NEITHER)
270 #define IOCTL_AFD_GET_CONNECT_OPTIONS \
271 _AFD_CONTROL_CODE(AFD_GET_CONNECT_OPTIONS, METHOD_NEITHER)
272 #define IOCTL_AFD_GET_DISCONNECT_DATA \
273 _AFD_CONTROL_CODE(AFD_GET_DISCONNECT_DATA, METHOD_NEITHER)
274 #define IOCTL_AFD_GET_DISCONNECT_OPTIONS \
275 _AFD_CONTROL_CODE(AFD_GET_DISCONNECT_OPTIONS, METHOD_NEITHER)
276 #define IOCTL_AFD_SET_CONNECT_DATA_SIZE \
277 _AFD_CONTROL_CODE(AFD_SET_CONNECT_DATA_SIZE, METHOD_NEITHER)
278 #define IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE \
279 _AFD_CONTROL_CODE(AFD_SET_CONNECT_OPTIONS_SIZE, METHOD_NEITHER)
280 #define IOCTL_AFD_SET_DISCONNECT_DATA_SIZE \
281 _AFD_CONTROL_CODE(AFD_SET_DISCONNECT_DATA_SIZE, METHOD_NEITHER)
282 #define IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE \
283 _AFD_CONTROL_CODE(AFD_SET_DISCONNECT_OPTIONS_SIZE, METHOD_NEITHER)
284 #define IOCTL_AFD_GET_INFO \
285 _AFD_CONTROL_CODE(AFD_GET_INFO, METHOD_NEITHER)
286 #define IOCTL_AFD_EVENT_SELECT \
287 _AFD_CONTROL_CODE(AFD_EVENT_SELECT, METHOD_NEITHER)
288 #define IOCTL_AFD_DEFER_ACCEPT \
289 _AFD_CONTROL_CODE(AFD_DEFER_ACCEPT, METHOD_NEITHER)
290 #define IOCTL_AFD_GET_PENDING_CONNECT_DATA \
291 _AFD_CONTROL_CODE(AFD_GET_PENDING_CONNECT_DATA, METHOD_NEITHER)
292 #define IOCTL_AFD_ENUM_NETWORK_EVENTS \
293 _AFD_CONTROL_CODE(AFD_ENUM_NETWORK_EVENTS, METHOD_NEITHER)
294
295 typedef struct _AFD_SOCKET_INFORMATION {
296 BOOL CommandChannel;
297 INT AddressFamily;
298 INT SocketType;
299 INT Protocol;
300 PVOID HelperContext;
301 DWORD NotificationEvents;
302 UNICODE_STRING TdiDeviceName;
303 SOCKADDR Name;
304 } AFD_SOCKET_INFORMATION, *PAFD_SOCKET_INFORMATION;
305
306 typedef struct _FILE_REQUEST_BIND {
307 SOCKADDR Name;
308 } FILE_REQUEST_BIND, *PFILE_REQUEST_BIND;
309
310 typedef struct _FILE_REPLY_BIND {
311 INT Status;
312 HANDLE TdiAddressObjectHandle;
313 HANDLE TdiConnectionObjectHandle;
314 } FILE_REPLY_BIND, *PFILE_REPLY_BIND;
315
316 typedef struct _FILE_REQUEST_LISTEN {
317 INT Backlog;
318 } FILE_REQUEST_LISTEN, *PFILE_REQUEST_LISTEN;
319
320 typedef struct _FILE_REPLY_LISTEN {
321 INT Status;
322 } FILE_REPLY_LISTEN, *PFILE_REPLY_LISTEN;
323
324 typedef struct _FILE_REQUEST_SENDTO {
325 LPWSABUF Buffers;
326 DWORD BufferCount;
327 DWORD Flags;
328 SOCKADDR To;
329 INT ToLen;
330 } FILE_REQUEST_SENDTO, *PFILE_REQUEST_SENDTO;
331
332 typedef struct _FILE_REPLY_SENDTO {
333 INT Status;
334 DWORD NumberOfBytesSent;
335 } FILE_REPLY_SENDTO, *PFILE_REPLY_SENDTO;
336
337 typedef struct _FILE_REQUEST_RECVFROM {
338 LPWSABUF Buffers;
339 DWORD BufferCount;
340 LPDWORD Flags;
341 LPSOCKADDR From;
342 LPINT FromLen;
343 } FILE_REQUEST_RECVFROM, *PFILE_REQUEST_RECVFROM;
344
345 typedef struct _FILE_REPLY_RECVFROM {
346 INT Status;
347 DWORD NumberOfBytesRecvd;
348 } FILE_REPLY_RECVFROM, *PFILE_REPLY_RECVFROM;
349
350 typedef struct _FILE_REQUEST_RECV {
351 LPWSABUF Buffers;
352 DWORD BufferCount;
353 LPDWORD Flags;
354 } FILE_REQUEST_RECV, *PFILE_REQUEST_RECV;
355
356 typedef struct _FILE_REPLY_RECV {
357 INT Status;
358 DWORD NumberOfBytesRecvd;
359 } FILE_REPLY_RECV, *PFILE_REPLY_RECV;
360
361
362 typedef struct _FILE_REQUEST_SEND {
363 LPWSABUF Buffers;
364 DWORD BufferCount;
365 DWORD Flags;
366 } FILE_REQUEST_SEND, *PFILE_REQUEST_SEND;
367
368 typedef struct _FILE_REPLY_SEND {
369 INT Status;
370 DWORD NumberOfBytesSent;
371 } FILE_REPLY_SEND, *PFILE_REPLY_SEND;
372
373
374 typedef struct _FILE_REQUEST_ACCEPT {
375 LPSOCKADDR addr;
376 INT addrlen;
377 LPCONDITIONPROC lpfnCondition;
378 DWORD dwCallbackData;
379 } FILE_REQUEST_ACCEPT, *PFILE_REQUEST_ACCEPT;
380
381 typedef struct _FILE_REPLY_ACCEPT {
382 INT Status;
383 INT addrlen;
384 SOCKET Socket;
385 } FILE_REPLY_ACCEPT, *PFILE_REPLY_ACCEPT;
386
387
388 typedef struct _FILE_REQUEST_CONNECT {
389 LPSOCKADDR name;
390 INT namelen;
391 LPWSABUF lpCallerData;
392 LPWSABUF lpCalleeData;
393 LPQOS lpSQOS;
394 LPQOS lpGQOS;
395 } FILE_REQUEST_CONNECT, *PFILE_REQUEST_CONNECT;
396
397 typedef struct _FILE_REPLY_CONNECT {
398 INT Status;
399 } FILE_REPLY_CONNECT, *PFILE_REPLY_CONNECT;
400
401 #endif /*__AFD_SHARED_H */
402
403 /* EOF */