4 * TDI kernel mode definitions
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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.
27 #pragma GCC system_header
37 #define TDIKRNLAPI DECLSPEC_EXPORT
39 #define TDIKRNLAPI DECLSPEC_IMPORT
43 typedef struct _TDI_REQUEST_KERNEL
{
45 PTDI_CONNECTION_INFORMATION RequestConnectionInformation
;
46 PTDI_CONNECTION_INFORMATION ReturnConnectionInformation
;
47 PVOID RequestSpecific
;
48 } TDI_REQUEST_KERNEL
, *PTDI_REQUEST_KERNEL
;
51 #define TDI_ASSOCIATE_ADDRESS 0x01
52 #define TDI_DISASSOCIATE_ADDRESS 0x02
53 #define TDI_CONNECT 0x03
54 #define TDI_LISTEN 0x04
55 #define TDI_ACCEPT 0x05
56 #define TDI_DISCONNECT 0x06
58 #define TDI_RECEIVE 0x08
59 #define TDI_SEND_DATAGRAM 0x09
60 #define TDI_RECEIVE_DATAGRAM 0x0A
61 #define TDI_SET_EVENT_HANDLER 0x0B
62 #define TDI_QUERY_INFORMATION 0x0C
63 #define TDI_SET_INFORMATION 0x0D
64 #define TDI_ACTION 0x0E
66 #define TDI_DIRECT_SEND 0x27
67 #define TDI_DIRECT_SEND_DATAGRAM 0x29
69 #define TDI_TRANSPORT_ADDRESS_FILE 1
70 #define TDI_CONNECTION_FILE 2
71 #define TDI_CONTROL_CHANNEL_FILE 3
73 /* Internal TDI IOCTLS */
74 #define IOCTL_TDI_QUERY_DIRECT_SEND_HANDLER _TDI_CONTROL_CODE(0x80, METHOD_NEITHER)
75 #define IOCTL_TDI_QUERY_DIRECT_SENDDG_HANDLER _TDI_CONTROL_CODE(0x81, METHOD_NEITHER)
77 /* TdiAssociateAddress */
78 typedef struct _TDI_REQUEST_KERNEL_ASSOCIATE
{
80 } TDI_REQUEST_KERNEL_ASSOCIATE
, *PTDI_REQUEST_KERNEL_ASSOCIATE
;
82 /* TdiDisassociateAddress */
83 typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_DISASSOCIATE
,
84 *PTDI_REQUEST_KERNEL_DISASSOCIATE
;
87 typedef struct _TDI_REQUEST_KERNEL_ACCEPT
{
88 PTDI_CONNECTION_INFORMATION RequestConnectionInformation
;
89 PTDI_CONNECTION_INFORMATION ReturnConnectionInformation
;
90 } TDI_REQUEST_KERNEL_ACCEPT
, *PTDI_REQUEST_KERNEL_ACCEPT
;
93 typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_CONNECT
,
94 *PTDI_REQUEST_KERNEL_CONNECT
;
97 typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_DISCONNECT
,
98 *PTDI_REQUEST_KERNEL_DISCONNECT
;
101 typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_LISTEN
,
102 *PTDI_REQUEST_KERNEL_LISTEN
;
105 typedef struct _TDI_REQUEST_KERNEL_RECEIVE
{
108 } TDI_REQUEST_KERNEL_RECEIVE
, *PTDI_REQUEST_KERNEL_RECEIVE
;
110 /* TdiReceiveDatagram */
111 typedef struct _TDI_REQUEST_KERNEL_RECEIVEDG
{
113 PTDI_CONNECTION_INFORMATION ReceiveDatagramInformation
;
114 PTDI_CONNECTION_INFORMATION ReturnDatagramInformation
;
116 } TDI_REQUEST_KERNEL_RECEIVEDG
, *PTDI_REQUEST_KERNEL_RECEIVEDG
;
119 typedef struct _TDI_REQUEST_KERNEL_SEND
{
122 } TDI_REQUEST_KERNEL_SEND
, *PTDI_REQUEST_KERNEL_SEND
;
124 /* TdiSendDatagram */
125 typedef struct _TDI_REQUEST_KERNEL_SENDDG
{
127 PTDI_CONNECTION_INFORMATION SendDatagramInformation
;
128 } TDI_REQUEST_KERNEL_SENDDG
, *PTDI_REQUEST_KERNEL_SENDDG
;
130 /* TdiSetEventHandler */
131 typedef struct _TDI_REQUEST_KERNEL_SET_EVENT
{
135 } TDI_REQUEST_KERNEL_SET_EVENT
, *PTDI_REQUEST_KERNEL_SET_EVENT
;
137 /* TdiQueryInformation */
138 typedef struct _TDI_REQUEST_KERNEL_QUERY_INFO
{
140 PTDI_CONNECTION_INFORMATION RequestConnectionInformation
;
141 } TDI_REQUEST_KERNEL_QUERY_INFORMATION
, *PTDI_REQUEST_KERNEL_QUERY_INFORMATION
;
143 /* TdiSetInformation */
144 typedef struct _TDI_REQUEST_KERNEL_SET_INFO
{
146 PTDI_CONNECTION_INFORMATION RequestConnectionInformation
;
147 } TDI_REQUEST_KERNEL_SET_INFORMATION
, *PTDI_REQUEST_KERNEL_SET_INFORMATION
;
151 #define TDI_EVENT_CONNECT 0
152 #define TDI_EVENT_DISCONNECT 1
153 #define TDI_EVENT_ERROR 2
154 #define TDI_EVENT_RECEIVE 3
155 #define TDI_EVENT_RECEIVE_DATAGRAM 4
156 #define TDI_EVENT_RECEIVE_EXPEDITED 5
157 #define TDI_EVENT_SEND_POSSIBLE 6
158 #define TDI_EVENT_CHAINED_RECEIVE 7
159 #define TDI_EVENT_CHAINED_RECEIVE_DATAGRAM 8
160 #define TDI_EVENT_CHAINED_RECEIVE_EXPEDITED 9
161 #define TDI_EVENT_ERROR_EX 10
163 typedef NTSTATUS DDKAPI
165 IN PVOID TdiEventContext
,
166 IN LONG RemoteAddressLength
,
167 IN PVOID RemoteAddress
,
168 IN LONG UserDataLength
,
170 IN LONG OptionsLength
,
172 OUT CONNECTION_CONTEXT
*ConnectionContext
,
173 OUT PIRP
*AcceptIrp
);
178 TdiDefaultConnectHandler(
179 IN PVOID TdiEventContext
,
180 IN LONG RemoteAddressLength
,
181 IN PVOID RemoteAddress
,
182 IN LONG UserDataLength
,
184 IN LONG OptionsLength
,
186 OUT CONNECTION_CONTEXT
*ConnectionContext
,
187 OUT PIRP
*AcceptIrp
);
189 typedef NTSTATUS DDKAPI
190 (*PTDI_IND_DISCONNECT
)(
191 IN PVOID TdiEventContext
,
192 IN CONNECTION_CONTEXT ConnectionContext
,
193 IN LONG DisconnectDataLength
,
194 IN PVOID DisconnectData
,
195 IN LONG DisconnectInformationLength
,
196 IN PVOID DisconnectInformation
,
197 IN ULONG DisconnectFlags
);
202 TdiDefaultDisconnectHandler(
203 IN PVOID TdiEventContext
,
204 IN CONNECTION_CONTEXT ConnectionContext
,
205 IN LONG DisconnectDataLength
,
206 IN PVOID DisconnectData
,
207 IN LONG DisconnectInformationLength
,
208 IN PVOID DisconnectInformation
,
209 IN ULONG DisconnectFlags
);
211 typedef NTSTATUS DDKAPI
213 IN PVOID TdiEventContext
,
216 typedef NTSTATUS DDKAPI
217 (*PTDI_IND_ERROR_EX
)(
218 IN PVOID TdiEventContext
,
225 TdiDefaultErrorHandler(
226 IN PVOID TdiEventContext
,
229 typedef NTSTATUS DDKAPI
231 IN PVOID TdiEventContext
,
232 IN CONNECTION_CONTEXT ConnectionContext
,
233 IN ULONG ReceiveFlags
,
234 IN ULONG BytesIndicated
,
235 IN ULONG BytesAvailable
,
236 OUT ULONG
*BytesTaken
,
238 OUT PIRP
*IoRequestPacket
);
243 TdiDefaultReceiveHandler(
244 IN PVOID TdiEventContext
,
245 IN CONNECTION_CONTEXT ConnectionContext
,
246 IN ULONG ReceiveFlags
,
247 IN ULONG BytesIndicated
,
248 IN ULONG BytesAvailable
,
249 OUT ULONG
*BytesTaken
,
251 OUT PIRP
*IoRequestPacket
);
253 typedef NTSTATUS DDKAPI
254 (*PTDI_IND_RECEIVE_DATAGRAM
)(
255 IN PVOID TdiEventContext
,
256 IN LONG SourceAddressLength
,
257 IN PVOID SourceAddress
,
258 IN LONG OptionsLength
,
260 IN ULONG ReceiveDatagramFlags
,
261 IN ULONG BytesIndicated
,
262 IN ULONG BytesAvailable
,
263 OUT ULONG
*BytesTaken
,
265 OUT PIRP
*IoRequestPacket
);
269 TdiDefaultRcvDatagramHandler(
270 IN PVOID TdiEventContext
,
271 IN LONG SourceAddressLength
,
272 IN PVOID SourceAddress
,
273 IN LONG OptionsLength
,
275 IN ULONG ReceiveDatagramFlags
,
276 IN ULONG BytesIndicated
,
277 IN ULONG BytesAvailable
,
278 OUT ULONG
*BytesTaken
,
280 OUT PIRP
*IoRequestPacket
);
282 typedef NTSTATUS DDKAPI
283 (*PTDI_IND_RECEIVE_EXPEDITED
)(
284 IN PVOID TdiEventContext
,
285 IN CONNECTION_CONTEXT ConnectionContext
,
286 IN ULONG ReceiveFlags
,
287 IN ULONG BytesIndicated
,
288 IN ULONG BytesAvailable
,
289 OUT ULONG
*BytesTaken
,
291 OUT PIRP
*IoRequestPacket
);
296 TdiDefaultRcvExpeditedHandler(
297 IN PVOID TdiEventContext
,
298 IN CONNECTION_CONTEXT ConnectionContext
,
299 IN ULONG ReceiveFlags
,
300 IN ULONG BytesIndicated
,
301 IN ULONG BytesAvailable
,
302 OUT ULONG
*BytesTaken
,
304 OUT PIRP
*IoRequestPacket
);
306 typedef NTSTATUS DDKAPI
307 (*PTDI_IND_CHAINED_RECEIVE
)(
308 IN PVOID TdiEventContext
,
309 IN CONNECTION_CONTEXT ConnectionContext
,
310 IN ULONG ReceiveFlags
,
311 IN ULONG ReceiveLength
,
312 IN ULONG StartingOffset
,
314 IN PVOID TsduDescriptor
);
319 TdiDefaultChainedReceiveHandler(
320 IN PVOID TdiEventContext
,
321 IN CONNECTION_CONTEXT ConnectionContext
,
322 IN ULONG ReceiveFlags
,
323 IN ULONG ReceiveLength
,
324 IN ULONG StartingOffset
,
326 IN PVOID TsduDescriptor
);
328 typedef NTSTATUS DDKAPI
329 (*PTDI_IND_CHAINED_RECEIVE_DATAGRAM
)(
330 IN PVOID TdiEventContext
,
331 IN LONG SourceAddressLength
,
332 IN PVOID SourceAddress
,
333 IN LONG OptionsLength
,
335 IN ULONG ReceiveDatagramFlags
,
336 IN ULONG ReceiveDatagramLength
,
337 IN ULONG StartingOffset
,
339 IN PVOID TsduDescriptor
);
344 TdiDefaultChainedRcvDatagramHandler(
345 IN PVOID TdiEventContext
,
346 IN LONG SourceAddressLength
,
347 IN PVOID SourceAddress
,
348 IN LONG OptionsLength
,
350 IN ULONG ReceiveDatagramFlags
,
351 IN ULONG ReceiveDatagramLength
,
352 IN ULONG StartingOffset
,
354 IN PVOID TsduDescriptor
);
356 typedef NTSTATUS DDKAPI
357 (*PTDI_IND_CHAINED_RECEIVE_EXPEDITED
)(
358 IN PVOID TdiEventContext
,
359 IN CONNECTION_CONTEXT ConnectionContext
,
360 IN ULONG ReceiveFlags
,
361 IN ULONG ReceiveLength
,
362 IN ULONG StartingOffset
,
364 IN PVOID TsduDescriptor
);
369 TdiDefaultChainedRcvExpeditedHandler(
370 IN PVOID TdiEventContext
,
371 IN CONNECTION_CONTEXT ConnectionContext
,
372 IN ULONG ReceiveFlags
,
373 IN ULONG ReceiveLength
,
374 IN ULONG StartingOffset
,
376 IN PVOID TsduDescriptor
);
378 typedef NTSTATUS DDKAPI
379 (*PTDI_IND_SEND_POSSIBLE
)(
380 IN PVOID TdiEventContext
,
381 IN PVOID ConnectionContext
,
382 IN ULONG BytesAvailable
);
387 TdiDefaultSendPossibleHandler(
388 IN PVOID TdiEventContext
,
389 IN PVOID ConnectionContext
,
390 IN ULONG BytesAvailable
);
394 /* Macros and functions to build IRPs */
396 #define TdiBuildBaseIrp( \
397 bIrp, bDevObj, bFileObj, bCompRoutine, bContxt, bIrpSp, bMinor) \
399 bIrpSp->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; \
400 bIrpSp->MinorFunction = (bMinor); \
401 bIrpSp->DeviceObject = (bDevObj); \
402 bIrpSp->FileObject = (bFileObj); \
404 IoSetCompletionRoutine(bIrp, bCompRoutine, bContxt, TRUE, TRUE, TRUE) \
406 IoSetCompletionRoutine(bIrp, NULL, NULL, FALSE, FALSE, FALSE); \
413 * IN PDEVICE_OBJECT DevObj,
414 * IN PFILE_OBJECT FileObj,
415 * IN PVOID CompRoutine,
417 * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
418 * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo);
420 #define TdiBuildAccept( \
421 Irp, DevObj, FileObj, CompRoutine, Contxt, \
422 RequestConnectionInfo, ReturnConnectionInfo) \
424 PTDI_REQUEST_KERNEL_ACCEPT _Request; \
425 PIO_STACK_LOCATION _IrpSp; \
427 _IrpSp = IoGetNextIrpStackLocation(Irp); \
429 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
430 Contxt, _IrpSp, TDI_ACCEPT); \
432 _Request = (PTDI_REQUEST_KERNEL_ACCEPT)&_IrpSp->Parameters; \
433 _Request->RequestConnectionInformation = (RequestConnectionInfo); \
434 _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \
441 * IN PDEVICE_OBJECT DevObj,
442 * IN PFILE_OBJECT FileObj,
443 * IN PVOID CompRoutine,
447 #define TdiBuildAction( \
448 Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr) \
450 PIO_STACK_LOCATION _IrpSp; \
452 _IrpSp = IoGetNextIrpStackLocation(Irp); \
454 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
455 Contxt, _IrpSp, TDI_ACTION); \
457 (Irp)->MdlAddress = (MdlAddr); \
462 * TdiBuildAssociateAddress(
464 * IN PDEVICE_OBJECT DevObj,
465 * IN PFILE_OBJECT FileObj,
466 * IN PVOID CompRoutine,
468 * IN HANDLE AddrHandle);
470 #define TdiBuildAssociateAddress( \
471 Irp, DevObj, FileObj, CompRoutine, Contxt, AddrHandle) \
473 PTDI_REQUEST_KERNEL_ASSOCIATE _Request; \
474 PIO_STACK_LOCATION _IrpSp; \
476 _IrpSp = IoGetNextIrpStackLocation(Irp); \
478 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
479 Contxt, _IrpSp, TDI_ASSOCIATE_ADDRESS); \
481 _Request = (PTDI_REQUEST_KERNEL_ASSOCIATE)&_IrpSp->Parameters; \
482 _Request->AddressHandle = (HANDLE)(AddrHandle); \
489 * IN PDEVICE_OBJECT DevObj,
490 * IN PFILE_OBJECT FileObj,
491 * IN PVOID CompRoutine,
493 * IN PLARGE_INTEGER Time,
494 * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
495 * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo);
497 #define TdiBuildConnect( \
498 Irp, DevObj, FileObj, CompRoutine, Contxt, \
499 Time, RequestConnectionInfo, ReturnConnectionInfo) \
501 PTDI_REQUEST_KERNEL _Request; \
502 PIO_STACK_LOCATION _IrpSp; \
504 _IrpSp = IoGetNextIrpStackLocation(Irp); \
506 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
507 Contxt, _IrpSp, TDI_CONNECT); \
509 _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters; \
510 _Request->RequestConnectionInformation = (RequestConnectionInfo); \
511 _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \
512 _Request->RequestSpecific = (PVOID)(Time); \
517 * TdiBuildDisassociateAddress(
519 * IN PDEVICE_OBJECT DevObj,
520 * IN PFILE_OBJECT FileObj,
521 * IN PVOID CompRoutine,
524 #define TdiBuildDisassociateAddress( \
525 Irp, DevObj, FileObj, CompRoutine, Contxt) \
527 PIO_STACK_LOCATION _IrpSp; \
529 _IrpSp = IoGetNextIrpStackLocation(Irp); \
531 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
532 Contxt, _IrpSp, TDI_DISASSOCIATE_ADDRESS); \
537 * TdiBuildDisconnect(
539 * IN PDEVICE_OBJECT DevObj,
540 * IN PFILE_OBJECT FileObj,
541 * IN PVOID CompRoutine,
543 * IN PLARGE_INTEGER Time,
545 * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
546 * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo);
548 #define TdiBuildDisconnect( \
549 Irp, DevObj, FileObj, CompRoutine, Contxt, Time, \
550 Flags, RequestConnectionInfo, ReturnConnectionInfo) \
552 PTDI_REQUEST_KERNEL _Request; \
553 PIO_STACK_LOCATION _IrpSp; \
555 _IrpSp = IoGetNextIrpStackLocation(Irp); \
557 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
558 Contxt, _IrpSp, TDI_DISCONNECT); \
560 _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters; \
561 _Request->RequestConnectionInformation = (RequestConnectionInfo); \
562 _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \
563 _Request->RequestSpecific = (PVOID)(Time); \
564 _Request->RequestFlags = (Flags); \
569 * TdiBuildInternalDeviceControlIrp(
570 * IN CCHAR IrpSubFunction,
571 * IN PDEVICE_OBJECT DeviceObject,
572 * IN PFILE_OBJECT FileObject,
574 * IN PIO_STATUS_BLOCK IoStatusBlock);
576 #define TdiBuildInternalDeviceControlIrp( \
577 IrpSubFunction, DeviceObject, \
578 FileObject, Event, IoStatusBlock) \
579 IoBuildDeviceIoControlRequest( \
580 IrpSubFunction, DeviceObject, \
582 TRUE, Event, IoStatusBlock)
588 * IN PDEVICE_OBJECT DevObj,
589 * IN PFILE_OBJECT FileObj,
590 * IN PVOID CompRoutine,
593 * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
594 * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo);
596 #define TdiBuildListen( \
597 Irp, DevObj, FileObj, CompRoutine, Contxt, \
598 Flags, RequestConnectionInfo, ReturnConnectionInfo) \
600 PTDI_REQUEST_KERNEL _Request; \
601 PIO_STACK_LOCATION _IrpSp; \
603 _IrpSp = IoGetNextIrpStackLocation(Irp); \
605 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
606 Contxt, _IrpSp, TDI_LISTEN); \
608 _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters; \
609 _Request->RequestConnectionInformation = (RequestConnectionInfo); \
610 _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \
611 _Request->RequestFlags = (Flags); \
617 TdiBuildNetbiosAddress(
618 IN PUCHAR NetbiosName
,
619 IN BOOLEAN IsGroupName
,
620 IN OUT PTA_NETBIOS_ADDRESS NetworkName
);
625 TdiBuildNetbiosAddressEa(
627 IN BOOLEAN IsGroupName
,
628 IN PUCHAR NetbiosName
);
632 * TdiBuildQueryInformation(
634 * IN PDEVICE_OBJECT DevObj,
635 * IN PFILE_OBJECT FileObj,
636 * IN PVOID CompRoutine,
641 #define TdiBuildQueryInformation( \
642 Irp, DevObj, FileObj, CompRoutine, Contxt, QType, MdlAddr) \
644 PTDI_REQUEST_KERNEL_QUERY_INFORMATION _Request; \
645 PIO_STACK_LOCATION _IrpSp; \
647 _IrpSp = IoGetNextIrpStackLocation(Irp); \
649 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
650 Contxt, _IrpSp, TDI_QUERY_INFORMATION); \
652 _Request = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&_IrpSp->Parameters; \
653 _Request->RequestConnectionInformation = NULL; \
654 _Request->QueryType = (ULONG)(QType); \
655 (Irp)->MdlAddress = (MdlAddr); \
662 * IN PDEVICE_OBJECT DevObj,
663 * IN PFILE_OBJECT FileObj,
664 * IN PVOID CompRoutine,
668 * IN ULONG ReceiveLen);
670 #define TdiBuildReceive( \
671 Irp, DevObj, FileObj, CompRoutine, Contxt, \
672 MdlAddr, InFlags, ReceiveLen) \
674 PTDI_REQUEST_KERNEL_RECEIVE _Request; \
675 PIO_STACK_LOCATION _IrpSp; \
677 _IrpSp = IoGetNextIrpStackLocation(Irp); \
679 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
680 Contxt, _IrpSp, TDI_RECEIVE); \
682 _Request = (PTDI_REQUEST_KERNEL_RECEIVE)&_IrpSp->Parameters; \
683 _Request->ReceiveFlags = (InFlags); \
684 _Request->ReceiveLength = (ReceiveLen); \
685 (Irp)->MdlAddress = (MdlAddr); \
690 * TdiBuildReceiveDatagram(
692 * IN PDEVICE_OBJECT DevObj,
693 * IN PFILE_OBJECT FileObj,
694 * IN PVOID CompRoutine,
697 * IN ULONG ReceiveLen,
698 * IN PTDI_CONNECTION_INFORMATION ReceiveDatagramInfo,
699 * OUT PTDI_CONNECTION_INFORMATION ReturnInfo,
702 #define TdiBuildReceiveDatagram( \
703 Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, \
704 ReceiveLen, ReceiveDatagramInfo, ReturnInfo, InFlags) \
706 PTDI_REQUEST_KERNEL_RECEIVEDG _Request; \
707 PIO_STACK_LOCATION _IrpSp; \
709 _IrpSp = IoGetNextIrpStackLocation(Irp); \
711 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
712 Contxt, _IrpSp, TDI_RECEIVE_DATAGRAM); \
714 _Request = (PTDI_REQUEST_KERNEL_RECEIVEDG)&_IrpSp->Parameters; \
715 _Request->ReceiveDatagramInformation = (ReceiveDatagramInfo); \
716 _Request->ReturnDatagramInformation = (ReturnInfo); \
717 _Request->ReceiveLength = (ReceiveLen); \
718 _Request->ReceiveFlags = (InFlags); \
719 (Irp)->MdlAddress = (MdlAddr); \
726 * IN PDEVICE_OBJECT DevObj,
727 * IN PFILE_OBJECT FileObj,
728 * IN PVOID CompRoutine,
734 #define TdiBuildSend( \
735 Irp, DevObj, FileObj, CompRoutine, Contxt, \
736 MdlAddr, InFlags, SendLen) \
738 PTDI_REQUEST_KERNEL_SEND _Request; \
739 PIO_STACK_LOCATION _IrpSp; \
741 _IrpSp = IoGetNextIrpStackLocation(Irp); \
743 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
744 Contxt, _IrpSp, TDI_SEND); \
746 _Request = (PTDI_REQUEST_KERNEL_SEND)&_IrpSp->Parameters; \
747 _Request->SendFlags = (InFlags); \
748 _Request->SendLength = (SendLen); \
749 (Irp)->MdlAddress = (MdlAddr); \
754 * TdiBuildSendDatagram(
756 * IN PDEVICE_OBJECT DevObj,
757 * IN PFILE_OBJECT FileObj,
758 * IN PVOID CompRoutine,
762 * IN PTDI_CONNECTION_INFORMATION SendDatagramInfo);
764 #define TdiBuildSendDatagram( \
765 Irp, DevObj, FileObj, CompRoutine, Contxt, \
766 MdlAddr, SendLen, SendDatagramInfo) \
768 PTDI_REQUEST_KERNEL_SENDDG _Request; \
769 PIO_STACK_LOCATION _IrpSp; \
771 _IrpSp = IoGetNextIrpStackLocation(Irp); \
773 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
774 Contxt, _IrpSp, TDI_SEND_DATAGRAM); \
776 _Request = (PTDI_REQUEST_KERNEL_SENDDG)&_IrpSp->Parameters; \
777 _Request->SendDatagramInformation = (SendDatagramInfo); \
778 _Request->SendLength = (SendLen); \
779 (Irp)->MdlAddress = (MdlAddr); \
784 * TdiBuildSetEventHandler(
786 * IN PDEVICE_OBJECT DevObj,
787 * IN PFILE_OBJECT FileObj,
788 * IN PVOID CompRoutine,
790 * IN INT InEventType,
791 * IN PVOID InEventHandler,
792 * IN PVOID InEventContext);
794 #define TdiBuildSetEventHandler( \
795 Irp, DevObj, FileObj, CompRoutine, Contxt, \
796 InEventType, InEventHandler, InEventContext) \
798 PTDI_REQUEST_KERNEL_SET_EVENT _Request; \
799 PIO_STACK_LOCATION _IrpSp; \
801 _IrpSp = IoGetNextIrpStackLocation(Irp); \
803 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
804 Contxt, _IrpSp, TDI_SET_EVENT_HANDLER); \
806 _Request = (PTDI_REQUEST_KERNEL_SET_EVENT)&_IrpSp->Parameters; \
807 _Request->EventType = (InEventType); \
808 _Request->EventHandler = (PVOID)(InEventHandler); \
809 _Request->EventContext = (PVOID)(InEventContext); \
814 * TdiBuildSetInformation(
816 * IN PDEVICE_OBJECT DevObj,
817 * IN PFILE_OBJECT FileObj,
818 * IN PVOID CompRoutine,
823 #define TdiBuildSetInformation( \
824 Irp, DevObj, FileObj, CompRoutine, Contxt, SType, MdlAddr) \
826 PTDI_REQUEST_KERNEL_SET_INFORMATION _Request; \
827 PIO_STACK_LOCATION _IrpSp; \
829 _IrpSp = IoGetNextIrpStackLocation(Irp); \
831 TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \
832 Contxt, _IrpSp, TDI_SET_INFORMATION); \
834 _Request = (PTDI_REQUEST_KERNEL_SET_INFORMATION)&_IrpSp->Parameters; \
835 _Request->RequestConnectionInformation = NULL; \
836 _Request->SetType = (ULONG)(SType); \
837 (Irp)->MdlAddress = (MdlAddr); \
840 /* TDI20_CLIENT_INTERFACE_INFO.TdiVersion constants */
841 #define TDI_CURRENT_MAJOR_VERSION 2
842 #define TDI_CURRENT_MINOR_VERSION 0
844 #define TDI_CURRENT_VERSION ((TDI_CURRENT_MINOR_VERSION) << 8 \
845 | (TDI_CURRENT_MAJOR_VERSION))
847 #define TDI_VERSION_ONE 0x0001
849 typedef enum _TDI_PNP_OPCODE
{
854 TDI_PNP_OP_PROVIDERREADY
,
856 TDI_PNP_OP_ADD_IGNORE_BINDING
,
857 TDI_PNP_OP_DELETE_IGNORE_BINDING
,
861 /* TDI_PNP_CONTEXT.ContextType */
862 #define TDI_PNP_CONTEXT_TYPE_IF_NAME 0x1
863 #define TDI_PNP_CONTEXT_TYPE_IF_ADDR 0x2
864 #define TDI_PNP_CONTEXT_TYPE_PDO 0x3
865 #define TDI_PNP_CONTEXT_TYPE_FIRST_OR_LAST_IF 0x4
867 typedef struct _TDI_PNP_CONTEXT
{
870 UCHAR ContextData
[1];
871 } TDI_PNP_CONTEXT
, *PTDI_PNP_CONTEXT
;
874 (*TDI_ADD_ADDRESS_HANDLER
)(
875 IN PTA_ADDRESS Address
);
878 (*TDI_ADD_ADDRESS_HANDLER_V2
)(
879 IN PTA_ADDRESS Address
,
880 IN PUNICODE_STRING DeviceName
,
881 IN PTDI_PNP_CONTEXT Context
);
884 (*TDI_BINDING_HANDLER
)(
885 IN TDI_PNP_OPCODE PnPOpcode
,
886 IN PUNICODE_STRING DeviceName
,
887 IN PWSTR MultiSZBindList
);
891 IN PUNICODE_STRING DeviceName
);
894 (*TDI_DEL_ADDRESS_HANDLER
)(
895 IN PTA_ADDRESS Address
);
898 (*TDI_DEL_ADDRESS_HANDLER_V2
)(
899 IN PTA_ADDRESS Address
,
900 IN PUNICODE_STRING DeviceName
,
901 IN PTDI_PNP_CONTEXT Context
);
903 typedef NTSTATUS DDKAPI
904 (*TDI_PNP_POWER_HANDLER
)(
905 IN PUNICODE_STRING DeviceName
,
906 IN PNET_PNP_EVENT PowerEvent
,
907 IN PTDI_PNP_CONTEXT Context1
,
908 IN PTDI_PNP_CONTEXT Context2
);
911 (*TDI_UNBIND_HANDLER
)(
912 IN PUNICODE_STRING DeviceName
);
915 (*ProviderPnPPowerComplete
)(
916 IN PNET_PNP_EVENT NetEvent
,
917 IN NTSTATUS ProviderStatus
);
919 typedef struct _TDI20_CLIENT_INTERFACE_INFO
{
920 _ANONYMOUS_UNION
union {
921 _ANONYMOUS_STRUCT
struct {
922 UCHAR MajorTdiVersion
;
923 UCHAR MinorTdiVersion
;
928 PUNICODE_STRING ClientName
;
929 TDI_PNP_POWER_HANDLER PnPPowerHandler
;
930 _ANONYMOUS_UNION
union {
931 TDI_BINDING_HANDLER BindingHandler
;
932 _ANONYMOUS_STRUCT
struct {
933 TDI_BIND_HANDLER BindHandler
;
934 TDI_UNBIND_HANDLER UnBindHandler
;
937 _ANONYMOUS_UNION
union {
938 _ANONYMOUS_STRUCT
struct {
939 TDI_ADD_ADDRESS_HANDLER_V2 AddAddressHandlerV2
;
940 TDI_DEL_ADDRESS_HANDLER_V2 DelAddressHandlerV2
;
942 _ANONYMOUS_STRUCT
struct {
943 TDI_ADD_ADDRESS_HANDLER AddAddressHandler
;
944 TDI_DEL_ADDRESS_HANDLER DelAddressHandler
;
947 } TDI20_CLIENT_INTERFACE_INFO
, *PTDI20_CLIENT_INTERFACE_INFO
;
949 typedef TDI20_CLIENT_INTERFACE_INFO TDI_CLIENT_INTERFACE_INFO
;
950 typedef TDI_CLIENT_INTERFACE_INFO
*PTDI_CLIENT_INTERFACE_INFO
;
957 * TdiCompleteRequest(
959 * IN NTSTATUS Status);
961 #define TdiCompleteRequest(Irp, Status) \
963 (Irp)->IoStatus.Status = (Status); \
964 IoCompleteRequest((Irp), IO_NETWORK_INCREMENT); \
971 IN PVOID SourceBuffer
,
972 IN ULONG SourceOffset
,
973 IN ULONG SourceBytesToCopy
,
974 IN PMDL DestinationMdlChain
,
975 IN ULONG DestinationOffset
,
976 IN PULONG BytesCopied
);
980 * TdiCopyLookaheadData(
981 * IN PVOID Destination,
984 * IN ULONG ReceiveFlags);
986 #define TdiCopyLookaheadData(Destination, Source, Length, ReceiveFlags) \
987 RtlCopyMemory(Destination, Source, Length)
992 TdiCopyMdlChainToMdlChain (
993 IN PMDL SourceMdlChain
,
994 IN ULONG SourceOffset
,
995 IN PMDL DestinationMdlChain
,
996 IN ULONG DestinationOffset
,
997 OUT PULONG BytesCopied
);
1003 IN PMDL SourceMdlChain
,
1004 IN ULONG SourceOffset
,
1005 IN PVOID DestinationBuffer
,
1006 IN ULONG DestinationOffset
,
1007 IN ULONG DestinationBufferSize
,
1008 OUT PULONG BytesCopied
);
1013 TdiDeregisterAddressChangeHandler(
1014 IN HANDLE BindingHandle
);
1019 TdiDeregisterDeviceObject(
1020 IN HANDLE DevRegistrationHandle
);
1025 TdiDeregisterNetAddress(
1026 IN HANDLE AddrRegistrationHandle
);
1031 TdiDeregisterPnPHandlers(
1032 IN HANDLE BindingHandle
);
1037 TdiDeregisterProvider(
1038 IN HANDLE ProviderHandle
);
1043 TdiEnumerateAddresses(
1044 IN HANDLE BindingHandle
);
1062 IN PDEVICE_OBJECT DeviceObject
,
1064 IN PIO_STACK_LOCATION IrpSp
);
1069 TdiMatchPdoWithChainedReceiveContext(
1070 IN PVOID TsduDescriptor
,
1076 TdiPnPPowerComplete(
1077 IN HANDLE BindingHandle
,
1078 IN PNET_PNP_EVENT PowerEvent
,
1079 IN NTSTATUS Status
);
1085 IN PUNICODE_STRING DeviceName
,
1086 IN PNET_PNP_EVENT PowerEvent
,
1087 IN PTDI_PNP_CONTEXT Context1
,
1088 IN PTDI_PNP_CONTEXT Context2
,
1089 IN ProviderPnPPowerComplete ProtocolCompletionHandler
);
1095 IN HANDLE ProviderHandle
);
1100 TdiRegisterAddressChangeHandler(
1101 IN TDI_ADD_ADDRESS_HANDLER AddHandler
,
1102 IN TDI_DEL_ADDRESS_HANDLER DeleteHandler
,
1103 OUT HANDLE
*BindingHandle
);
1108 TdiRegisterDeviceObject(
1109 IN PUNICODE_STRING DeviceName
,
1110 OUT HANDLE
*DevRegistrationHandle
);
1115 TdiRegisterNetAddress(
1116 IN PTA_ADDRESS Address
,
1117 IN PUNICODE_STRING DeviceName
,
1118 IN PTDI_PNP_CONTEXT Context
,
1119 OUT HANDLE
*AddrRegistrationHandle
);
1124 TdiRegisterNotificationHandler(
1125 IN TDI_BIND_HANDLER BindHandler
,
1126 IN TDI_UNBIND_HANDLER UnbindHandler
,
1127 OUT HANDLE
*BindingHandle
);
1132 TdiRegisterPnPHandlers(
1133 IN PTDI_CLIENT_INTERFACE_INFO ClientInterfaceInfo
,
1134 IN ULONG InterfaceInfoSize
,
1135 OUT HANDLE
*BindingHandle
);
1140 TdiRegisterProvider(
1141 IN PUNICODE_STRING ProviderName
,
1142 OUT HANDLE
*ProviderHandle
);
1147 TdiReturnChainedReceives(
1148 IN PVOID
*TsduDescriptors
,
1149 IN ULONG NumberOfTsdus
);
1161 #endif /* __TDIKRNL_H */