xref: /reactos/sdk/include/ddk/wsk.h (revision c2c66aff)
1 /*
2  * wsk.h
3  *
4  * Windows Sockets Kernel-Mode Interface
5  *
6  * This file is part of the ReactOS DDK package.
7  *
8  * Contributors:
9  *   Timo Kreuzer (timo.kreuzer@reactos.org)
10  *
11  * THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  * This source code is offered for use in the public domain. You may
14  * use, modify or distribute it freely.
15  *
16  * This code is distributed in the hope that it will be useful but
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  * DISCLAIMED. This includes but is not limited to warranties of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  */
22 #pragma once
23 #define _WSK_
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <netioddk.h>
30 #include <ws2def.h>
31 #include <mswsockdef.h>
32 
33 extern CONST NPIID NPI_WSK_INTERFACE_ID;
34 
35 #define WSKAPI NTAPI
36 
37 #define MAKE_WSK_VERSION(Mj, Mn) ((USHORT)((Mj) << 8) | (USHORT)((Mn) & 0xff))
38 #define WSK_MAJOR_VERSION(V) ((UCHAR)((V) >> 8))
39 #define WSK_MINOR_VERSION(V) ((UCHAR)(V))
40 #define WSK_FLAG_AT_DISPATCH_LEVEL 0x00000008
41 #define WSK_FLAG_RELEASE_ASAP 0x00000002
42 #define WSK_FLAG_ENTIRE_MESSAGE 0x00000004
43 #define WSK_FLAG_ABORTIVE 0x00000001
44 #define WSK_FLAG_BASIC_SOCKET 0x00000000
45 #define WSK_FLAG_LISTEN_SOCKET 0x00000001
46 #define WSK_FLAG_CONNECTION_SOCKET 0x00000002
47 #define WSK_FLAG_DATAGRAM_SOCKET 0x00000004
48 #define WSK_TRANSPORT_LIST_QUERY 2
49 #define WSK_TRANSPORT_LIST_CHANGE 3
50 #define WSK_CACHE_SD 4
51 #define WSK_RELEASE_SD 5
52 #define WSK_TDI_DEVICENAME_MAPPING 6
53 #define WSK_SET_STATIC_EVENT_CALLBACKS 7
54 #define WSK_TDI_BEHAVIOR 8
55 #define WSK_TDI_BEHAVIOR_BYPASS_TDI 0x00000001
56 #define SO_WSK_SECURITY (WSK_SO_BASE+1)
57 #define SO_WSK_EVENT_CALLBACK (WSK_SO_BASE+2)
58 #define WSK_EVENT_RECEIVE_FROM 0x00000100
59 #define WSK_EVENT_ACCEPT 0x00000200
60 #define WSK_EVENT_SEND_BACKLOG 0x00000010
61 #define WSK_EVENT_RECEIVE 0x00000040
62 #define WSK_EVENT_DISCONNECT 0x00000080
63 #define WSK_EVENT_DISABLE 0x80000000
64 #define SIO_WSK_SET_REMOTE_ADDRESS _WSAIOW(IOC_WSK,0x1)
65 #define SIO_WSK_REGISTER_EXTENSION _WSAIORW(IOC_WSK,0x2)
66 #define SIO_WSK_QUERY_IDEAL_SEND_BACKLOG _WSAIOR(IOC_WSK,0x3)
67 #define SIO_WSK_QUERY_RECEIVE_BACKLOG _WSAIOR(IOC_WSK,0x4)
68 #define SIO_WSK_QUERY_INSPECT_ID _WSAIOR(IOC_WSK,0x5)
69 #define SIO_WSK_SET_SENDTO_ADDRESS _WSAIOW(IOC_WSK,0x6)
70 #define WSK_FLAG_NODELAY 0x00000002
71 #define WSK_FLAG_WAITALL 0x00000002
72 #define WSK_FLAG_DRAIN 0x00000004
73 #define WSK_NO_WAIT 0
74 #define WSK_INFINITE_WAIT 0xffffffff
75 
76 typedef enum
77 {
78     WskInspectReject,
79     WskInspectAccept,
80     WskInspectPend,
81     WskInspectMax
82 } WSK_INSPECT_ACTION, *PWSK_INSPECT_ACTION;
83 
84 typedef enum
85 {
86     WskSetOption,
87     WskGetOption,
88     WskIoctl,
89     WskControlMax
90 } WSK_CONTROL_SOCKET_TYPE, *PWSK_CONTROL_SOCKET_TYPE;
91 
92 typedef PVOID PWSK_CLIENT;
93 
94 typedef struct _WSK_SOCKET
95 {
96     const VOID *Dispatch;
97 } WSK_SOCKET, *PWSK_SOCKET;
98 
99 typedef struct _WSK_BUF
100 {
101     PMDL Mdl;
102     ULONG Offset;
103     SIZE_T Length;
104 } WSK_BUF, *PWSK_BUF;
105 
106 typedef struct _WSK_INSPECT_ID
107 {
108     ULONG_PTR Key;
109     ULONG SerialNumber;
110 } WSK_INSPECT_ID, *PWSK_INSPECT_ID;
111 
112 typedef struct _WSK_DATAGRAM_INDICATION
113 {
114     struct _WSK_DATAGRAM_INDICATION *Next;
115     WSK_BUF Buffer;
116     _Field_size_bytes_(ControlInfoLength) PCMSGHDR ControlInfo;
117     ULONG ControlInfoLength;
118     PSOCKADDR RemoteAddress;
119 } WSK_DATAGRAM_INDICATION, *PWSK_DATAGRAM_INDICATION;
120 
121 typedef
122 _Must_inspect_result_
123 NTSTATUS
124 (WSKAPI * PFN_WSK_RECEIVE_FROM_EVENT)(
125     _In_opt_ PVOID SocketContext,
126     _In_ ULONG Flags,
127     _In_opt_ PWSK_DATAGRAM_INDICATION DataIndication);
128 
129 typedef struct _WSK_DATA_INDICATION
130 {
131     struct _WSK_DATA_INDICATION *Next;
132     WSK_BUF Buffer;
133 } WSK_DATA_INDICATION, *PWSK_DATA_INDICATION;
134 
135 typedef
136 _Must_inspect_result_
137 NTSTATUS
138 (WSKAPI * PFN_WSK_RECEIVE_EVENT)(
139     _In_opt_ PVOID SocketContext,
140     _In_ ULONG Flags,
141     _In_opt_ PWSK_DATA_INDICATION DataIndication,
142     _In_ SIZE_T BytesIndicated,
143     _Inout_ SIZE_T *BytesAccepted);
144 
145 typedef
146 NTSTATUS
147 (WSKAPI * PFN_WSK_DISCONNECT_EVENT)(
148     _In_opt_ PVOID SocketContext,
149     _In_ ULONG Flags);
150 
151 typedef
152 NTSTATUS
153 (WSKAPI * PFN_WSK_SEND_BACKLOG_EVENT)(
154     _In_opt_ PVOID SocketContext,
155     _In_ SIZE_T IdealBacklogSize);
156 
157 typedef struct _WSK_CLIENT_CONNECTION_DISPATCH
158 {
159     PFN_WSK_RECEIVE_EVENT WskReceiveEvent;
160     PFN_WSK_DISCONNECT_EVENT WskDisconnectEvent;
161     PFN_WSK_SEND_BACKLOG_EVENT WskSendBacklogEvent;
162 } WSK_CLIENT_CONNECTION_DISPATCH, *PWSK_CLIENT_CONNECTION_DISPATCH;
163 
164 typedef
165 _Must_inspect_result_
166 _At_(AcceptSocket, __drv_aliasesMem)
167 NTSTATUS
168 (WSKAPI * PFN_WSK_ACCEPT_EVENT)(
169     _In_opt_ PVOID SocketContext,
170     _In_ ULONG Flags,
171     _In_ PSOCKADDR LocalAddress,
172     _In_ PSOCKADDR RemoteAddress,
173     _In_opt_ PWSK_SOCKET AcceptSocket,
174     _Outptr_result_maybenull_ PVOID *AcceptSocketContext,
175     _Outptr_result_maybenull_ const WSK_CLIENT_CONNECTION_DISPATCH **AcceptSocketDispatch);
176 
177 typedef
178 _At_(Irp->IoStatus.Information, __drv_allocatesMem(Mem))
179 NTSTATUS
180 (WSKAPI * PFN_WSK_SOCKET_CONNECT)(
181     _In_ PWSK_CLIENT Client,
182     _In_ USHORT SocketType,
183     _In_ ULONG Protocol,
184     _In_ PSOCKADDR LocalAddress,
185     _In_ PSOCKADDR RemoteAddress,
186     _Reserved_ ULONG Flags,
187     _In_opt_ PVOID SocketContext,
188     _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH *Dispatch,
189     _In_opt_ PEPROCESS OwningProcess,
190     _In_opt_ PETHREAD OwningThread,
191     _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
192     _Inout_ PIRP Irp);
193 
194 typedef
195 NTSTATUS
196 (WSKAPI * PFN_WSK_CONTROL_SOCKET)(
197     _In_ PWSK_SOCKET Socket,
198     _In_ WSK_CONTROL_SOCKET_TYPE RequestType,
199     _In_ ULONG ControlCode,
200     _In_ ULONG Level,
201     _In_ SIZE_T InputSize,
202     _In_reads_bytes_opt_(InputSize) PVOID InputBuffer,
203     _In_ SIZE_T OutputSize,
204     _Out_writes_bytes_opt_(OutputSize) PVOID  OutputBuffer,
205     _Out_opt_ SIZE_T *OutputSizeReturned,
206     _Inout_opt_ PIRP Irp);
207 
208 typedef
209 _At_(Socket, __drv_freesMem(Mem))
210 NTSTATUS
211 (WSKAPI * PFN_WSK_CLOSE_SOCKET)(
212     _In_ PWSK_SOCKET Socket,
213     _Inout_ PIRP Irp);
214 
215 typedef struct _WSK_PROVIDER_BASIC_DISPATCH
216 {
217     PFN_WSK_CONTROL_SOCKET WskControlSocket;
218     PFN_WSK_CLOSE_SOCKET WskCloseSocket;
219 } WSK_PROVIDER_BASIC_DISPATCH, *PWSK_PROVIDER_BASIC_DISPATCH;
220 
221 typedef
222 NTSTATUS
223 (WSKAPI * PFN_WSK_BIND) (
224     _In_ PWSK_SOCKET Socket,
225     _In_ PSOCKADDR LocalAddress,
226     _Reserved_ ULONG Flags,
227     _Inout_ PIRP Irp);
228 
229 typedef
230 _At_(Irp->IoStatus.Information, __drv_allocatesMem(Mem))
231 NTSTATUS
232 (WSKAPI * PFN_WSK_ACCEPT)(
233     _In_ PWSK_SOCKET ListenSocket,
234     _Reserved_ ULONG Flags,
235     _In_opt_ PVOID AcceptSocketContext,
236     _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH *AcceptSocketDispatch,
237     _Out_opt_ PSOCKADDR LocalAddress,
238     _Out_opt_ PSOCKADDR RemoteAddress,
239     _Inout_ PIRP Irp);
240 
241 typedef
242 NTSTATUS
243 (WSKAPI * PFN_WSK_INSPECT_COMPLETE)(
244     _In_ PWSK_SOCKET ListenSocket,
245     _In_ PWSK_INSPECT_ID InspectID,
246     _In_ WSK_INSPECT_ACTION Action,
247     _Inout_ PIRP Irp);
248 
249 typedef
250 NTSTATUS
251 (WSKAPI * PFN_WSK_GET_LOCAL_ADDRESS)(
252     _In_ PWSK_SOCKET Socket,
253     _Out_ PSOCKADDR LocalAddress,
254     _Inout_ PIRP Irp);
255 
256 typedef struct _WSK_PROVIDER_LISTEN_DISPATCH
257 {
258 #ifdef __cplusplus
259     WSK_PROVIDER_BASIC_DISPATCH Basic;
260 #else
261     WSK_PROVIDER_BASIC_DISPATCH;
262 #endif
263     PFN_WSK_BIND WskBind;
264     PFN_WSK_ACCEPT WskAccept;
265     PFN_WSK_INSPECT_COMPLETE WskInspectComplete;
266     PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;
267 } WSK_PROVIDER_LISTEN_DISPATCH, *PWSK_PROVIDER_LISTEN_DISPATCH;
268 
269 #if (NTDDI_VERSION >= NTDDI_WIN8)
270 typedef struct _WSK_BUF_LIST {
271     struct _WSK_BUF_LIST *Next;
272     WSK_BUF Buffer;
273 } WSK_BUF_LIST, *PWSK_BUF_LIST;
274 
275 typedef
276 NTSTATUS
277 (WSKAPI * PFN_WSK_SEND_MESSAGES)(
278     _In_ PWSK_SOCKET Socket,
279     _In_ PWSK_BUF_LIST BufferList,
280     _Reserved_ ULONG Flags,
281     _In_opt_ PSOCKADDR RemoteAddress,
282     _In_ ULONG ControlInfoLength,
283     _In_reads_bytes_opt_(ControlInfoLength) PCMSGHDR ControlInfo,
284     _Inout_ PIRP Irp);
285 #endif /* (NTDDI_VERSION >= NTDDI_WIN8) */
286 
287 typedef struct _WSK_PROVIDER_DATAGRAM_DISPATCH
288 {
289 #ifdef __cplusplus
290     WSK_PROVIDER_BASIC_DISPATCH Basic;
291 #else
292     WSK_PROVIDER_BASIC_DISPATCH;
293 #endif
294     PFN_WSK_BIND WskBind;
295     PFN_WSK_SEND_TO WskSendTo;
296     PFN_WSK_RECEIVE_FROM WskReceiveFrom;
297     PFN_WSK_RELEASE_DATAGRAM_INDICATION_LIST WskRelease;
298     PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;
299 #if (NTDDI_VERSION >= NTDDI_WIN8)
300     PFN_WSK_SEND_MESSAGES WskSendMessages;
301 #endif
302 } WSK_PROVIDER_DATAGRAM_DISPATCH, *PWSK_PROVIDER_DATAGRAM_DISPATCH;
303 
304 typedef
305 NTSTATUS
306 (WSKAPI * PFN_WSK_CONNECT) (
307     _In_ PWSK_SOCKET Socket,
308     _In_ PSOCKADDR RemoteAddress,
309     _Reserved_ ULONG Flags,
310     _Inout_ PIRP Irp);
311 
312 typedef
313 NTSTATUS
314 (WSKAPI * PFN_WSK_GET_REMOTE_ADDRESS)(
315     _In_ PWSK_SOCKET Socket,
316     _Out_ PSOCKADDR RemoteAddress,
317     _Inout_ PIRP Irp);
318 
319 typedef
320 NTSTATUS
321 (WSKAPI * PFN_WSK_SEND)(
322     _In_ PWSK_SOCKET Socket,
323     _In_ PWSK_BUF Buffer,
324     _In_ ULONG Flags,
325     _Inout_ PIRP Irp);
326 
327 typedef
328 NTSTATUS
329 (WSKAPI * PFN_WSK_RECEIVE)(
330     _In_ PWSK_SOCKET Socket,
331     _In_ PWSK_BUF Buffer,
332     _In_ ULONG Flags,
333     _Inout_ PIRP Irp);
334 
335 typedef
336 NTSTATUS
337 (WSKAPI * PFN_WSK_DISCONNECT)(
338     _In_ PWSK_SOCKET Socket,
339     _In_opt_ PWSK_BUF Buffer,
340     _In_ ULONG Flags,
341     _Inout_ PIRP Irp);
342 
343 typedef
344 NTSTATUS
345 (WSKAPI * PFN_WSK_RELEASE_DATA_INDICATION_LIST)(
346     _In_ PWSK_SOCKET Socket,
347     _In_ PWSK_DATA_INDICATION DataIndication);
348 
349 typedef struct _WSK_PROVIDER_CONNECTION_DISPATCH
350 {
351 #ifdef __cplusplus
352     WSK_PROVIDER_BASIC_DISPATCH Basic;
353 #else
354     WSK_PROVIDER_BASIC_DISPATCH;
355 #endif
356     PFN_WSK_BIND WskBind;
357     PFN_WSK_CONNECT WskConnect;
358     PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;
359     PFN_WSK_GET_REMOTE_ADDRESS WskGetRemoteAddress;
360     PFN_WSK_SEND WskSend;
361     PFN_WSK_RECEIVE WskReceive;
362     PFN_WSK_DISCONNECT WskDisconnect;
363     PFN_WSK_RELEASE_DATA_INDICATION_LIST WskRelease;
364 } WSK_PROVIDER_CONNECTION_DISPATCH, *PWSK_PROVIDER_CONNECTION_DISPATCH;
365 
366 typedef
367 _Must_inspect_result_
368 WSK_INSPECT_ACTION
369 (WSKAPI * PFN_WSK_INSPECT_EVENT)(
370     _In_opt_ PVOID SocketContext,
371     _In_ PSOCKADDR LocalAddress,
372     _In_ PSOCKADDR RemoteAddress,
373     _In_opt_ PWSK_INSPECT_ID InspectID);
374 
375 typedef
376 NTSTATUS
377 (WSKAPI * PFN_WSK_ABORT_EVENT) (
378     _In_opt_ PVOID SocketContext,
379     _In_ PWSK_INSPECT_ID InspectID);
380 
381 typedef
382 _At_(Irp->IoStatus.Information, __drv_allocatesMem(Mem))
383 NTSTATUS
384 (WSKAPI * PFN_WSK_SOCKET)(
385     _In_ PWSK_CLIENT Client,
386     _In_ ADDRESS_FAMILY AddressFamily,
387     _In_ USHORT SocketType,
388     _In_ ULONG Protocol,
389     _In_ ULONG Flags,
390     _In_opt_ PVOID SocketContext,
391     _In_opt_ const VOID *Dispatch,
392     _In_opt_ PEPROCESS OwningProcess,
393     _In_opt_ PETHREAD OwningThread,
394     _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
395     _Inout_ PIRP Irp);
396 
397 typedef struct _WSK_TDI_MAP
398 {
399     USHORT SocketType;
400     ADDRESS_FAMILY AddressFamily;
401     ULONG Protocol;
402     PCWSTR TdiDeviceName;
403 } WSK_TDI_MAP, *PWSK_TDI_MAP;
404 
405 typedef struct _WSK_TDI_MAP_INFO
406 {
407     const ULONG ElementCount;
408     _Field_size_(ElementCount) const WSK_TDI_MAP *Map;
409 } WSK_TDI_MAP_INFO, *PWSK_TDI_MAP_INFO;
410 
411 typedef
412 NTSTATUS
413 (WSKAPI * PFN_WSK_CONTROL_CLIENT)(
414     _In_ PWSK_CLIENT Client,
415     _In_ ULONG ControlCode,
416     _In_ SIZE_T InputSize,
417     _In_reads_bytes_opt_(InputSize) PVOID InputBuffer,
418     _In_ SIZE_T OutputSize,
419     _Out_writes_bytes_opt_(OutputSize) PVOID OutputBuffer,
420     _Out_opt_ SIZE_T *OutputSizeReturned,
421     _Inout_opt_ PIRP Irp);
422 
423 #if (NTDDI_VERSION >= NTDDI_WIN7)
424 
425 typedef
426 _At_(*Result, __drv_allocatesMem(Mem))
427 NTSTATUS
428 (WSKAPI * PFN_WSK_GET_ADDRESS_INFO)(
429     _In_ PWSK_CLIENT Client,
430     _In_opt_ PUNICODE_STRING NodeName,
431     _In_opt_ PUNICODE_STRING ServiceName,
432     _In_opt_ ULONG NameSpace,
433     _In_opt_ GUID *Provider,
434     _In_opt_ PADDRINFOEXW Hints,
435     _Outptr_ PADDRINFOEXW *Result,
436     _In_opt_ PEPROCESS OwningProcess,
437     _In_opt_ PETHREAD OwningThread,
438     _Inout_ PIRP Irp);
439 
440 typedef
441 NTSTATUS
442 (WSKAPI * PFN_WSK_GET_NAME_INFO)(
443     _In_ PWSK_CLIENT Client,
444     _In_ PSOCKADDR SockAddr,
445     _In_ ULONG SockAddrLength,
446     _Out_opt_ PUNICODE_STRING NodeName,
447     _Out_opt_ PUNICODE_STRING ServiceName,
448     _In_ ULONG Flags,
449     _In_opt_ PEPROCESS OwningProcess,
450     _In_opt_ PETHREAD OwningThread,
451     _Inout_ PIRP Irp);
452 
453 typedef
454 _At_(AddrInfo, __drv_freesMem(Mem))
455 VOID
456 (WSKAPI * PFN_WSK_FREE_ADDRESS_INFO)(
457     _In_ PWSK_CLIENT Client,
458     _In_ PADDRINFOEXW AddrInfo);
459 
460 #endif /* if (NTDDI_VERSION >= NTDDI_WIN7) */
461 
462 typedef struct _WSK_EVENT_CALLBACK_CONTROL
463 {
464     PNPIID NpiId;
465     ULONG  EventMask;
466 } WSK_EVENT_CALLBACK_CONTROL, *PWSK_EVENT_CALLBACK_CONTROL;
467 
468 typedef struct _WSK_EXTENSION_CONTROL_IN
469 {
470     PNPIID NpiId;
471     PVOID ClientContext;
472     const VOID* ClientDispatch;
473 } WSK_EXTENSION_CONTROL_IN, *PWSK_EXTENSION_CONTROL_IN;
474 
475 typedef struct _WSK_EXTENSION_CONTROL_OUT
476 {
477     PVOID ProviderContext;
478     const VOID* ProviderDispatch;
479 } WSK_EXTENSION_CONTROL_OUT, *PWSK_EXTENSION_CONTROL_OUT;
480 
481 typedef
482 NTSTATUS
483 (WSKAPI * PFN_WSK_SEND_TO)(
484     _In_ PWSK_SOCKET Socket,
485     _In_ PWSK_BUF Buffer,
486     _Reserved_ ULONG Flags,
487     _In_opt_ PSOCKADDR RemoteAddress,
488     _In_ ULONG ControlInfoLength,
489     _In_reads_bytes_opt_(ControlInfoLength) PCMSGHDR ControlInfo,
490     _Inout_ PIRP Irp);
491 
492 typedef
493 NTSTATUS
494 (WSKAPI * PFN_WSK_RECEIVE_FROM)(
495     _In_ PWSK_SOCKET Socket,
496     _In_ PWSK_BUF Buffer,
497     _Reserved_ ULONG Flags,
498     _Out_opt_ PSOCKADDR RemoteAddress,
499     _Inout_ PULONG ControlLength,
500     _Out_writes_bytes_opt_(*ControlLength) PCMSGHDR ControlInfo,
501     _Out_opt_ PULONG ControlFlags,
502     _Inout_ PIRP Irp);
503 
504 typedef
505 NTSTATUS
506 (WSKAPI * PFN_WSK_RELEASE_DATAGRAM_INDICATION_LIST)(
507     _In_ PWSK_SOCKET Socket,
508     _In_ PWSK_DATAGRAM_INDICATION DatagramIndication);
509 
510 typedef
511 NTSTATUS
512 (WSKAPI * PFN_WSK_CLIENT_EVENT)(
513     _In_opt_ PVOID ClientContext,
514     _In_ ULONG EventType,
515     _In_reads_bytes_opt_(InformationLength) PVOID Information,
516     _In_ SIZE_T InformationLength);
517 
518 typedef struct _WSK_CLIENT_DISPATCH
519 {
520     USHORT Version;
521     USHORT Reserved;
522     PFN_WSK_CLIENT_EVENT WskClientEvent;
523 } WSK_CLIENT_DISPATCH, *PWSK_CLIENT_DISPATCH;
524 
525 typedef struct _WSK_CLIENT_LISTEN_DISPATCH
526 {
527     PFN_WSK_ACCEPT_EVENT WskAcceptEvent;
528     PFN_WSK_INSPECT_EVENT WskInspectEvent;
529     PFN_WSK_ABORT_EVENT WskAbortEvent;
530 } WSK_CLIENT_LISTEN_DISPATCH, *PWSK_CLIENT_LISTEN_DISPATCH;
531 
532 typedef struct _WSK_CLIENT_DATAGRAM_DISPATCH
533 {
534     PFN_WSK_RECEIVE_FROM_EVENT WskReceiveFromEvent;
535 } WSK_CLIENT_DATAGRAM_DISPATCH, *PWSK_CLIENT_DATAGRAM_DISPATCH;
536 
537 typedef struct _WSK_PROVIDER_DISPATCH
538 {
539     USHORT Version;
540     USHORT Reserved;
541     PFN_WSK_SOCKET WskSocket;
542     PFN_WSK_SOCKET_CONNECT WskSocketConnect;
543     PFN_WSK_CONTROL_CLIENT WskControlClient;
544 #if (NTDDI_VERSION >= NTDDI_WIN7)
545     PFN_WSK_GET_ADDRESS_INFO WskGetAddressInfo;
546     PFN_WSK_FREE_ADDRESS_INFO WskFreeAddressInfo;
547     PFN_WSK_GET_NAME_INFO WskGetNameInfo;
548 #endif
549 } WSK_PROVIDER_DISPATCH, *PWSK_PROVIDER_DISPATCH;
550 
551 
552 typedef struct _WSK_CLIENT_NPI
553 {
554     PVOID ClientContext;
555     const WSK_CLIENT_DISPATCH *Dispatch;
556 } WSK_CLIENT_NPI, *PWSK_CLIENT_NPI;
557 
558 typedef struct _WSK_PROVIDER_NPI
559 {
560     PWSK_CLIENT Client;
561     const WSK_PROVIDER_DISPATCH *Dispatch;
562 } WSK_PROVIDER_NPI, *PWSK_PROVIDER_NPI;
563 
564 typedef struct _WSK_REGISTRATION
565 {
566     ULONGLONG ReservedRegistrationState;
567     PVOID ReservedRegistrationContext;
568     KSPIN_LOCK ReservedRegistrationLock;
569 } WSK_REGISTRATION, *PWSK_REGISTRATION;
570 
571 typedef struct _WSK_PROVIDER_CHARACTERISTICS
572 {
573     USHORT HighestVersion;
574     USHORT LowestVersion;
575 } WSK_PROVIDER_CHARACTERISTICS, *PWSK_PROVIDER_CHARACTERISTICS;
576 
577 typedef struct _WSK_TRANSPORT
578 {
579     USHORT Version;
580     USHORT SocketType;
581     ULONG Protocol;
582     ADDRESS_FAMILY AddressFamily;
583     GUID ProviderId;
584 } WSK_TRANSPORT, *PWSK_TRANSPORT;
585 
586 _Must_inspect_result_
587 NTSTATUS
588 WskRegister(
589     _In_ PWSK_CLIENT_NPI WskClientNpi,
590     _Out_ PWSK_REGISTRATION WskRegistration);
591 
592 _Must_inspect_result_
593 NTSTATUS
594 WskCaptureProviderNPI(
595     _In_ PWSK_REGISTRATION WskRegistration,
596     _In_ ULONG WaitTimeout,
597     _Out_ PWSK_PROVIDER_NPI WskProviderNpi);
598 
599 VOID
600 WskReleaseProviderNPI(
601     _In_ PWSK_REGISTRATION WskRegistration);
602 
603 _Must_inspect_result_
604 NTSTATUS
605 WskQueryProviderCharacteristics(
606     _In_ PWSK_REGISTRATION WskRegistration,
607     _Out_ PWSK_PROVIDER_CHARACTERISTICS WskProviderCharacteristics);
608 
609 VOID
610 WskDeregister(
611     _In_ PWSK_REGISTRATION WskRegistration);
612 
613 #ifdef __cplusplus
614 }
615 #endif
616 
617 
618