xref: /reactos/sdk/include/ddk/wsk.h (revision 490fbfb2)
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
288 NTSTATUS
289 (WSKAPI * PFN_WSK_CONNECT) (
290     _In_ PWSK_SOCKET Socket,
291     _In_ PSOCKADDR RemoteAddress,
292     _Reserved_ ULONG Flags,
293     _Inout_ PIRP Irp);
294 
295 typedef
296 NTSTATUS
297 (WSKAPI * PFN_WSK_GET_REMOTE_ADDRESS)(
298     _In_ PWSK_SOCKET Socket,
299     _Out_ PSOCKADDR RemoteAddress,
300     _Inout_ PIRP Irp);
301 
302 typedef
303 NTSTATUS
304 (WSKAPI * PFN_WSK_SEND)(
305     _In_ PWSK_SOCKET Socket,
306     _In_ PWSK_BUF Buffer,
307     _In_ ULONG Flags,
308     _Inout_ PIRP Irp);
309 
310 typedef
311 NTSTATUS
312 (WSKAPI * PFN_WSK_RECEIVE)(
313     _In_ PWSK_SOCKET Socket,
314     _In_ PWSK_BUF Buffer,
315     _In_ ULONG Flags,
316     _Inout_ PIRP Irp);
317 
318 typedef
319 NTSTATUS
320 (WSKAPI * PFN_WSK_DISCONNECT)(
321     _In_ PWSK_SOCKET Socket,
322     _In_opt_ PWSK_BUF Buffer,
323     _In_ ULONG Flags,
324     _Inout_ PIRP Irp);
325 
326 typedef
327 NTSTATUS
328 (WSKAPI * PFN_WSK_RELEASE_DATA_INDICATION_LIST)(
329     _In_ PWSK_SOCKET Socket,
330     _In_ PWSK_DATA_INDICATION DataIndication);
331 
332 typedef struct _WSK_PROVIDER_CONNECTION_DISPATCH
333 {
334 #ifdef __cplusplus
335     WSK_PROVIDER_BASIC_DISPATCH Basic;
336 #else
337     WSK_PROVIDER_BASIC_DISPATCH;
338 #endif
339     PFN_WSK_BIND WskBind;
340     PFN_WSK_CONNECT WskConnect;
341     PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;
342     PFN_WSK_GET_REMOTE_ADDRESS WskGetRemoteAddress;
343     PFN_WSK_SEND WskSend;
344     PFN_WSK_RECEIVE WskReceive;
345     PFN_WSK_DISCONNECT WskDisconnect;
346     PFN_WSK_RELEASE_DATA_INDICATION_LIST WskRelease;
347 } WSK_PROVIDER_CONNECTION_DISPATCH, *PWSK_PROVIDER_CONNECTION_DISPATCH;
348 
349 typedef
350 _Must_inspect_result_
351 WSK_INSPECT_ACTION
352 (WSKAPI * PFN_WSK_INSPECT_EVENT)(
353     _In_opt_ PVOID SocketContext,
354     _In_ PSOCKADDR LocalAddress,
355     _In_ PSOCKADDR RemoteAddress,
356     _In_opt_ PWSK_INSPECT_ID InspectID);
357 
358 typedef
359 NTSTATUS
360 (WSKAPI * PFN_WSK_ABORT_EVENT) (
361     _In_opt_ PVOID SocketContext,
362     _In_ PWSK_INSPECT_ID InspectID);
363 
364 typedef
365 _At_(Irp->IoStatus.Information, __drv_allocatesMem(Mem))
366 NTSTATUS
367 (WSKAPI * PFN_WSK_SOCKET)(
368     _In_ PWSK_CLIENT Client,
369     _In_ ADDRESS_FAMILY AddressFamily,
370     _In_ USHORT SocketType,
371     _In_ ULONG Protocol,
372     _In_ ULONG Flags,
373     _In_opt_ PVOID SocketContext,
374     _In_opt_ const VOID *Dispatch,
375     _In_opt_ PEPROCESS OwningProcess,
376     _In_opt_ PETHREAD OwningThread,
377     _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
378     _Inout_ PIRP Irp);
379 
380 typedef struct _WSK_TDI_MAP
381 {
382     USHORT SocketType;
383     ADDRESS_FAMILY AddressFamily;
384     ULONG Protocol;
385     PCWSTR TdiDeviceName;
386 } WSK_TDI_MAP, *PWSK_TDI_MAP;
387 
388 typedef struct _WSK_TDI_MAP_INFO
389 {
390     const ULONG ElementCount;
391     _Field_size_(ElementCount) const WSK_TDI_MAP *Map;
392 } WSK_TDI_MAP_INFO, *PWSK_TDI_MAP_INFO;
393 
394 typedef
395 NTSTATUS
396 (WSKAPI * PFN_WSK_CONTROL_CLIENT)(
397     _In_ PWSK_CLIENT Client,
398     _In_ ULONG ControlCode,
399     _In_ SIZE_T InputSize,
400     _In_reads_bytes_opt_(InputSize) PVOID InputBuffer,
401     _In_ SIZE_T OutputSize,
402     _Out_writes_bytes_opt_(OutputSize) PVOID OutputBuffer,
403     _Out_opt_ SIZE_T *OutputSizeReturned,
404     _Inout_opt_ PIRP Irp);
405 
406 #if (NTDDI_VERSION >= NTDDI_WIN7)
407 
408 typedef
409 _At_(*Result, __drv_allocatesMem(Mem))
410 NTSTATUS
411 (WSKAPI * PFN_WSK_GET_ADDRESS_INFO)(
412     _In_ PWSK_CLIENT Client,
413     _In_opt_ PUNICODE_STRING NodeName,
414     _In_opt_ PUNICODE_STRING ServiceName,
415     _In_opt_ ULONG NameSpace,
416     _In_opt_ GUID *Provider,
417     _In_opt_ PADDRINFOEXW Hints,
418     _Outptr_ PADDRINFOEXW *Result,
419     _In_opt_ PEPROCESS OwningProcess,
420     _In_opt_ PETHREAD OwningThread,
421     _Inout_ PIRP Irp);
422 
423 typedef
424 NTSTATUS
425 (WSKAPI * PFN_WSK_GET_NAME_INFO)(
426     _In_ PWSK_CLIENT Client,
427     _In_ PSOCKADDR SockAddr,
428     _In_ ULONG SockAddrLength,
429     _Out_opt_ PUNICODE_STRING NodeName,
430     _Out_opt_ PUNICODE_STRING ServiceName,
431     _In_ ULONG Flags,
432     _In_opt_ PEPROCESS OwningProcess,
433     _In_opt_ PETHREAD OwningThread,
434     _Inout_ PIRP Irp);
435 
436 typedef
437 _At_(AddrInfo, __drv_freesMem(Mem))
438 VOID
439 (WSKAPI * PFN_WSK_FREE_ADDRESS_INFO)(
440     _In_ PWSK_CLIENT Client,
441     _In_ PADDRINFOEXW AddrInfo);
442 
443 #endif /* if (NTDDI_VERSION >= NTDDI_WIN7) */
444 
445 typedef struct _WSK_EVENT_CALLBACK_CONTROL
446 {
447     PNPIID NpiId;
448     ULONG  EventMask;
449 } WSK_EVENT_CALLBACK_CONTROL, *PWSK_EVENT_CALLBACK_CONTROL;
450 
451 typedef struct _WSK_EXTENSION_CONTROL_IN
452 {
453     PNPIID NpiId;
454     PVOID ClientContext;
455     const VOID* ClientDispatch;
456 } WSK_EXTENSION_CONTROL_IN, *PWSK_EXTENSION_CONTROL_IN;
457 
458 typedef struct _WSK_EXTENSION_CONTROL_OUT
459 {
460     PVOID ProviderContext;
461     const VOID* ProviderDispatch;
462 } WSK_EXTENSION_CONTROL_OUT, *PWSK_EXTENSION_CONTROL_OUT;
463 
464 typedef
465 NTSTATUS
466 (WSKAPI * PFN_WSK_SEND_TO)(
467     _In_ PWSK_SOCKET Socket,
468     _In_ PWSK_BUF Buffer,
469     _Reserved_ ULONG Flags,
470     _In_opt_ PSOCKADDR RemoteAddress,
471     _In_ ULONG ControlInfoLength,
472     _In_reads_bytes_opt_(ControlInfoLength) PCMSGHDR ControlInfo,
473     _Inout_ PIRP Irp);
474 
475 typedef
476 NTSTATUS
477 (WSKAPI * PFN_WSK_RECEIVE_FROM)(
478     _In_ PWSK_SOCKET Socket,
479     _In_ PWSK_BUF Buffer,
480     _Reserved_ ULONG Flags,
481     _Out_opt_ PSOCKADDR RemoteAddress,
482     _Inout_ PULONG ControlLength,
483     _Out_writes_bytes_opt_(*ControlLength) PCMSGHDR ControlInfo,
484     _Out_opt_ PULONG ControlFlags,
485     _Inout_ PIRP Irp);
486 
487 typedef
488 NTSTATUS
489 (WSKAPI * PFN_WSK_RELEASE_DATAGRAM_INDICATION_LIST)(
490     _In_ PWSK_SOCKET Socket,
491     _In_ PWSK_DATAGRAM_INDICATION DatagramIndication);
492 
493 typedef struct _WSK_PROVIDER_DATAGRAM_DISPATCH
494 {
495 #ifdef __cplusplus
496     WSK_PROVIDER_BASIC_DISPATCH Basic;
497 #else
498     WSK_PROVIDER_BASIC_DISPATCH;
499 #endif
500     PFN_WSK_BIND WskBind;
501     PFN_WSK_SEND_TO WskSendTo;
502     PFN_WSK_RECEIVE_FROM WskReceiveFrom;
503     PFN_WSK_RELEASE_DATAGRAM_INDICATION_LIST WskRelease;
504     PFN_WSK_GET_LOCAL_ADDRESS WskGetLocalAddress;
505 #if (NTDDI_VERSION >= NTDDI_WIN8)
506     PFN_WSK_SEND_MESSAGES WskSendMessages;
507 #endif
508 } WSK_PROVIDER_DATAGRAM_DISPATCH, *PWSK_PROVIDER_DATAGRAM_DISPATCH;
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 WSKAPI
589 WskRegister(
590     _In_ PWSK_CLIENT_NPI WskClientNpi,
591     _Out_ PWSK_REGISTRATION WskRegistration);
592 
593 _Must_inspect_result_
594 NTSTATUS
595 WSKAPI
596 WskCaptureProviderNPI(
597     _In_ PWSK_REGISTRATION WskRegistration,
598     _In_ ULONG WaitTimeout,
599     _Out_ PWSK_PROVIDER_NPI WskProviderNpi);
600 
601 VOID
602 WSKAPI
603 WskReleaseProviderNPI(
604     _In_ PWSK_REGISTRATION WskRegistration);
605 
606 _Must_inspect_result_
607 NTSTATUS
608 WSKAPI
609 WskQueryProviderCharacteristics(
610     _In_ PWSK_REGISTRATION WskRegistration,
611     _Out_ PWSK_PROVIDER_CHARACTERISTICS WskProviderCharacteristics);
612 
613 VOID
614 WSKAPI
615 WskDeregister(
616     _In_ PWSK_REGISTRATION WskRegistration);
617 
618 #ifdef __cplusplus
619 }
620 #endif
621 
622 
623