ReactOS 0.4.16-dev-297-gc569aee
dispatch.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DISCONNECT_TYPE
 

Typedefs

typedef struct _DISCONNECT_TYPE DISCONNECT_TYPE
 
typedef struct _DISCONNECT_TYPEPDISCONNECT_TYPE
 

Functions

NTSTATUS DispTdiAccept (PIRP Irp)
 
NTSTATUS DispTdiAssociateAddress (PIRP Irp)
 
NTSTATUS DispTdiConnect (PIRP Irp)
 
NTSTATUS DispTdiDisassociateAddress (PIRP Irp)
 
NTSTATUS DispTdiDisconnect (PIRP Irp)
 
NTSTATUS DispTdiListen (PIRP Irp)
 
NTSTATUS DispTdiQueryInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DispTdiReceive (PIRP Irp)
 
NTSTATUS DispTdiReceiveDatagram (PIRP Irp)
 
NTSTATUS DispTdiSend (PIRP Irp)
 
NTSTATUS DispTdiSendDatagram (PIRP Irp)
 
NTSTATUS DispTdiSetEventHandler (PIRP Irp)
 
NTSTATUS DispTdiSetInformation (PIRP Irp)
 
NTSTATUS DispTdiQueryInformationEx (PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS DispTdiSetInformationEx (PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS DispTdiSetIPAddress (PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS DispTdiDeleteIPAddress (PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS DispTdiQueryIpHwAddress (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
VOID DispDoDisconnect (PVOID Data)
 
NTSTATUS IRPFinish (PIRP Irp, NTSTATUS Status)
 

Typedef Documentation

◆ DISCONNECT_TYPE

◆ PDISCONNECT_TYPE

Function Documentation

◆ DispDoDisconnect()

VOID DispDoDisconnect ( PVOID  Data)

◆ DispTdiAccept()

NTSTATUS DispTdiAccept ( PIRP  Irp)

Definition at line 254 of file dispatch.c.

263{
264 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
265
267}
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define DEBUG_IRP
Definition: debug.h:19
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45

Referenced by TiDispatchInternal().

◆ DispTdiAssociateAddress()

NTSTATUS DispTdiAssociateAddress ( PIRP  Irp)

Definition at line 270 of file dispatch.c.

279{
281 PTRANSPORT_CONTEXT TranContext;
283 PCONNECTION_ENDPOINT Connection, LastConnection;
285 PADDRESS_FILE AddrFile = NULL;
287
288 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
289
291
292 /* Get associated connection endpoint file object. Quit if none exists */
293
294 TranContext = IrpSp->FileObject->FsContext;
295 if (!TranContext) {
296 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
298 }
299
300 Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
301 if (!Connection) {
302 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
304 }
305
307
309 Parameters->AddressHandle,
310 0,
313 (PVOID*)&FileObject,
314 NULL);
315 if (!NT_SUCCESS(Status)) {
316 TI_DbgPrint(MID_TRACE, ("Bad address file object handle (0x%X): %x.\n",
317 Parameters->AddressHandle, Status));
319 }
320
321 LockObject(Connection);
322
323 if (Connection->AddressFile) {
325 UnlockObject(Connection);
326 TI_DbgPrint(MID_TRACE, ("An address file is already associated.\n"));
328 }
329
330 if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
332 UnlockObject(Connection);
333 TI_DbgPrint(MID_TRACE, ("Bad address file object. Magic (0x%X).\n",
334 FileObject->FsContext2));
336 }
337
338 /* Get associated address file object. Quit if none exists */
339
340 TranContext = FileObject->FsContext;
341 if (!TranContext) {
343 UnlockObject(Connection);
344 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
346 }
347
348 AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
349 if (!AddrFile) {
350 UnlockObject(Connection);
352 TI_DbgPrint(MID_TRACE, ("No address file object.\n"));
354 }
355
356 LockObject(AddrFile);
357
358 ReferenceObject(AddrFile);
359 Connection->AddressFile = AddrFile;
360
361 /* Add connection endpoint to the address file */
362 ReferenceObject(Connection);
363 if (AddrFile->Connection == NULL)
364 AddrFile->Connection = Connection;
365 else
366 {
367 LastConnection = AddrFile->Connection;
368 while (LastConnection->Next != NULL)
369 LastConnection = LastConnection->Next;
370 LastConnection->Next = Connection;
371 }
372
374
375 UnlockObject(AddrFile);
376 UnlockObject(Connection);
377
378 return STATUS_SUCCESS;
379}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
#define MID_TRACE
Definition: debug.h:15
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
Status
Definition: gdiplustypes.h:25
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
if(dx< 0)
Definition: linetemp.h:194
#define KernelMode
Definition: asm.h:34
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _CONNECTION_ENDPOINT * Connection
Definition: titypes.h:131
PADDRESS_FILE AddressFile
Definition: titypes.h:247
struct _CONNECTION_ENDPOINT * Next
Definition: titypes.h:269
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
union _IO_STACK_LOCATION::@1579 Parameters
HANDLE AddressHandle
Definition: titypes.h:291
union _TRANSPORT_CONTEXT::@1032 Handle
CONNECTION_CONTEXT ConnectionContext
Definition: titypes.h:292
#define TDI_TRANSPORT_ADDRESS_FILE
Definition: tdikrnl.h:65
struct _TDI_REQUEST_KERNEL_ASSOCIATE * PTDI_REQUEST_KERNEL_ASSOCIATE
#define UnlockObject(Object)
Definition: titypes.h:44
#define ReferenceObject(Object)
Definition: titypes.h:14
#define LockObject(Object)
Definition: titypes.h:34
struct _CONNECTION_ENDPOINT * PCONNECTION_ENDPOINT
struct _ADDRESS_FILE * PADDRESS_FILE
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by TiDispatchInternal().

◆ DispTdiConnect()

NTSTATUS DispTdiConnect ( PIRP  Irp)

Definition at line 382 of file dispatch.c.

391{
392 PCONNECTION_ENDPOINT Connection;
394 PTRANSPORT_CONTEXT TranContext;
397
398 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
399
401
403
404 /* Get associated connection endpoint file object. Quit if none exists */
405
406 TranContext = IrpSp->FileObject->FsContext;
407 if (!TranContext) {
408 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
410 goto done;
411 }
412
413 Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
414 if (!Connection) {
415 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
417 goto done;
418 }
419
421
423 Irp,
425
426 if (NT_SUCCESS(Status)) {
428 TranContext->Handle.ConnectionContext,
429 Parameters->RequestConnectionInformation,
430 Parameters->ReturnConnectionInformation,
432 Irp );
433 }
434
435done:
436 if (Status != STATUS_PENDING) {
438 }
439
440 TI_DbgPrint(MAX_TRACE, ("TCP Connect returned %08x\n", Status));
441
442 return STATUS_PENDING;
443}
#define MAX_TRACE
Definition: debug.h:16
#define STATUS_PENDING
Definition: d3dkmdt.h:43
NTSTATUS DispPrepareIrpForCancel(PTRANSPORT_CONTEXT Context, PIRP Irp, PDRIVER_CANCEL CancelRoutine)
Definition: dispatch.c:41
VOID NTAPI DispCancelRequest(PDEVICE_OBJECT Device, PIRP Irp)
Definition: dispatch.c:118
VOID DispDataRequestComplete(PVOID Context, NTSTATUS Status, ULONG Count)
Definition: dispatch.c:87
NTSTATUS TCPConnect(PCONNECTION_ENDPOINT Connection, PTDI_CONNECTION_INFORMATION ConnInfo, PTDI_CONNECTION_INFORMATION ReturnInfo, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:302
IoMarkIrpPending(Irp)
struct _TDI_REQUEST_KERNEL * PTDI_REQUEST_KERNEL

Referenced by TiDispatchInternal().

◆ DispTdiDeleteIPAddress()

NTSTATUS DispTdiDeleteIPAddress ( PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 1609 of file dispatch.c.

1609 {
1611 PUSHORT NteIndex = Irp->AssociatedIrp.SystemBuffer;
1612 IF_LIST_ITER(IF);
1613
1614 ForEachInterface(IF) {
1615 if( IF->Index == *NteIndex ) {
1617 IF->Unicast.Type = IP_ADDRESS_V4;
1618 IF->Unicast.Address.IPv4Address = 0;
1619
1620 IF->Netmask.Type = IP_ADDRESS_V4;
1621 IF->Netmask.Address.IPv4Address = 0;
1622
1623 IF->Broadcast.Type = IP_ADDRESS_V4;
1624 IF->Broadcast.Address.IPv4Address = 0;
1625
1627 }
1628 } EndFor(IF);
1629
1630 Irp->IoStatus.Status = Status;
1631 return Status;
1632}
#define IP_ADDRESS_V4
Definition: ip.h:32
VOID IPRemoveInterfaceRoute(PIP_INTERFACE IF)
Definition: ip.c:331
#define ForEachInterface(n)
Definition: tilists.h:9
#define EndFor(n)
Definition: tilists.h:20
#define IF_LIST_ITER(n)
Definition: tilists.h:5
uint16_t * PUSHORT
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by TiDispatch().

◆ DispTdiDisassociateAddress()

NTSTATUS DispTdiDisassociateAddress ( PIRP  Irp)

Definition at line 446 of file dispatch.c.

455{
456 PCONNECTION_ENDPOINT Connection;
457 PTRANSPORT_CONTEXT TranContext;
459
460 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
461
463
464 /* Get associated connection endpoint file object. Quit if none exists */
465
466 TranContext = IrpSp->FileObject->FsContext;
467 if (!TranContext) {
468 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
470 }
471
472 Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
473 if (!Connection) {
474 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
476 }
477
478 /* NO-OP because we need the address to deallocate the port when the connection closes */
479
480 return STATUS_SUCCESS;
481}

Referenced by TiDispatchInternal().

◆ DispTdiDisconnect()

NTSTATUS DispTdiDisconnect ( PIRP  Irp)

Definition at line 484 of file dispatch.c.

493{
496 PCONNECTION_ENDPOINT Connection;
497 PTRANSPORT_CONTEXT TranContext;
499
500 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
501
504
506
507 /* Get associated connection endpoint file object. Quit if none exists */
508
509 TranContext = IrpSp->FileObject->FsContext;
510 if (!TranContext) {
511 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
513 goto done;
514 }
515
516 Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
517 if (!Connection) {
518 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
520 goto done;
521 }
522
524 (TranContext->Handle.ConnectionContext,
525 Irp,
527
528 if (NT_SUCCESS(Status))
529 {
531 DisReq->RequestFlags,
532 DisReq->RequestSpecific,
536 Irp);
537 }
538
539done:
540 if (Status != STATUS_PENDING) {
542 }
543
544 TI_DbgPrint(MAX_TRACE, ("TCP Disconnect returned %08x\n", Status));
545
546 return STATUS_PENDING;
547}
NTSTATUS TCPDisconnect(PCONNECTION_ENDPOINT Connection, UINT Flags, PLARGE_INTEGER Timeout, PTDI_CONNECTION_INFORMATION ConnInfo, PTDI_CONNECTION_INFORMATION ReturnInfo, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:427
PVOID RequestSpecific
Definition: tdikrnl.h:43
PTDI_CONNECTION_INFORMATION RequestConnectionInformation
Definition: tdikrnl.h:41
PTDI_CONNECTION_INFORMATION ReturnConnectionInformation
Definition: tdikrnl.h:42
ULONG RequestFlags
Definition: tdikrnl.h:40
TDI_REQUEST_KERNEL * PTDI_REQUEST_KERNEL_DISCONNECT
Definition: tdikrnl.h:94
DRIVER_CANCEL * PDRIVER_CANCEL
Definition: iotypes.h:2759

Referenced by TiDispatchInternal().

◆ DispTdiListen()

NTSTATUS DispTdiListen ( PIRP  Irp)

Definition at line 550 of file dispatch.c.

559{
560 PCONNECTION_ENDPOINT Connection;
562 PTRANSPORT_CONTEXT TranContext;
565
566 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
567
569
571
572 /* Get associated connection endpoint file object. Quit if none exists */
573
574 TranContext = IrpSp->FileObject->FsContext;
575 if (TranContext == NULL)
576 {
577 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
579 goto done;
580 }
581
582 Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
583 if (Connection == NULL)
584 {
585 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
587 goto done;
588 }
589
591
593 (TranContext->Handle.ConnectionContext,
594 Irp,
596
597 LockObject(Connection);
598
599 if (Connection->AddressFile == NULL)
600 {
601 TI_DbgPrint(MID_TRACE, ("No associated address file\n"));
602 UnlockObject(Connection);
604 goto done;
605 }
606
607 LockObject(Connection->AddressFile);
608
609 /* Listening will require us to create a listening socket and store it in
610 * the address file. It will be signalled, and attempt to complete an irp
611 * when a new connection arrives. */
612 /* The important thing to note here is that the irp we'll complete belongs
613 * to the socket to be accepted onto, not the listener */
614 if( NT_SUCCESS(Status) && !Connection->AddressFile->Listener ) {
615 Connection->AddressFile->Listener =
617
618 if( !Connection->AddressFile->Listener )
620
621 if( NT_SUCCESS(Status) ) {
622 ReferenceObject(Connection->AddressFile);
623 Connection->AddressFile->Listener->AddressFile =
624 Connection->AddressFile;
625
626 Status = TCPSocket( Connection->AddressFile->Listener,
627 Connection->AddressFile->Family,
629 Connection->AddressFile->Protocol );
630 }
631
632 if( NT_SUCCESS(Status) ) {
634 Status = TCPListen( Connection->AddressFile->Listener, 1024 );
635 /* BACKLOG */
636 }
637 }
638
639 if( NT_SUCCESS(Status) ) {
642 Connection->AddressFile->Listener,
643 Connection,
645 Irp );
646 }
647
648 UnlockObject(Connection->AddressFile);
649 UnlockObject(Connection);
650
651done:
652 if (Status != STATUS_PENDING) {
654 }
655
656 TI_DbgPrint(MID_TRACE,("Leaving %x\n", Status));
657
658 return STATUS_PENDING;
659}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define SOCK_STREAM
Definition: tcpip.h:118
VOID NTAPI DispCancelListenRequest(PDEVICE_OBJECT Device, PIRP Irp)
Definition: dispatch.c:209
NTSTATUS TCPSocket(PCONNECTION_ENDPOINT Connection, UINT Family, UINT Type, UINT Proto)
Definition: tcp.c:153
NTSTATUS TCPListen(PCONNECTION_ENDPOINT Connection, UINT Backlog)
Definition: accept.c:47
NTSTATUS TCPAccept(PTDI_REQUEST Request, PCONNECTION_ENDPOINT Listener, PCONNECTION_ENDPOINT Connection, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: accept.c:139
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint(PVOID ClientContext)
Definition: tcp.c:107
USHORT Family
Definition: titypes.h:118
USHORT Protocol
Definition: titypes.h:119
struct _CONNECTION_ENDPOINT * Listener
Definition: titypes.h:133

Referenced by TiDispatchInternal().

◆ DispTdiQueryInformation()

NTSTATUS DispTdiQueryInformation ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 662 of file dispatch.c.

673{
675 PTRANSPORT_CONTEXT TranContext;
677
678 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
679
682
683 TranContext = IrpSp->FileObject->FsContext;
684 if (!TranContext) {
685 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
687 }
688
689 switch (Parameters->QueryType)
690 {
692 {
693 PTDI_ADDRESS_INFO AddressInfo;
694 PADDRESS_FILE AddrFile;
696 PCONNECTION_ENDPOINT Endpoint = NULL;
697
698
699 if (MmGetMdlByteCount(Irp->MdlAddress) <
700 (FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
701 sizeof(TDI_ADDRESS_IP))) {
702 TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
704 }
705
706 AddressInfo = (PTDI_ADDRESS_INFO)MmGetSystemAddressForMdl(Irp->MdlAddress);
707 Address = (PTA_IP_ADDRESS)&AddressInfo->Address;
708
709 switch ((ULONG_PTR)IrpSp->FileObject->FsContext2) {
711 AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
712 if (AddrFile == NULL)
713 {
714 TI_DbgPrint(MIN_TRACE, ("FIXME: No address file object.\n"));
715 ASSERT(AddrFile != NULL);
717 }
718
719 Address->TAAddressCount = 1;
720 Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
721 Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
722 Address->Address[0].Address[0].sin_port = AddrFile->Port;
723 Address->Address[0].Address[0].in_addr = AddrFile->Address.Address.IPv4Address;
725 &Address->Address[0].Address[0].sin_zero,
726 sizeof(Address->Address[0].Address[0].sin_zero));
727 return STATUS_SUCCESS;
728
730 Endpoint =
732 if (Endpoint == NULL || Endpoint->AddressFile == NULL)
733 {
734 TI_DbgPrint(MIN_TRACE, ("FIXME: No connection endpoint file object.\n"));
735 ASSERT(Endpoint != NULL && Endpoint->AddressFile != NULL);
737 }
738
739 Address->TAAddressCount = 1;
740 Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
741 Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
742 Address->Address[0].Address[0].sin_port = Endpoint->AddressFile->Port;
743 Address->Address[0].Address[0].in_addr = Endpoint->AddressFile->Address.Address.IPv4Address;
745 &Address->Address[0].Address[0].sin_zero,
746 sizeof(Address->Address[0].Address[0].sin_zero));
747 return STATUS_SUCCESS;
748
749 default:
750 TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
752 }
753 }
754
756 {
757 PTDI_CONNECTION_INFO ConnectionInfo;
758 //PCONNECTION_ENDPOINT Endpoint;
759
760 if (MmGetMdlByteCount(Irp->MdlAddress) < sizeof(*ConnectionInfo)) {
761 TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
763 }
764
765 ConnectionInfo = (PTDI_CONNECTION_INFO)
766 MmGetSystemAddressForMdl(Irp->MdlAddress);
767
768 switch ((ULONG_PTR)IrpSp->FileObject->FsContext2) {
770 //Endpoint = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
771 RtlZeroMemory(ConnectionInfo, sizeof(*ConnectionInfo));
772 return STATUS_SUCCESS;
773
774 default:
775 TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
777 }
778 }
779
781 {
782 PTDI_MAX_DATAGRAM_INFO MaxDatagramInfo;
783
784 if (MmGetMdlByteCount(Irp->MdlAddress) < sizeof(*MaxDatagramInfo)) {
785 TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
787 }
788
789 MaxDatagramInfo = (PTDI_MAX_DATAGRAM_INFO)
790 MmGetSystemAddressForMdl(Irp->MdlAddress);
791
792 MaxDatagramInfo->MaxDatagramSize = 0xFFFF;
793
794 return STATUS_SUCCESS;
795 }
796 }
797
799}
#define MIN_TRACE
Definition: debug.h:14
switch(r->id)
Definition: btrfs.c:3046
#define ASSERT(a)
Definition: mode.c:44
static WCHAR Address[46]
Definition: ping.c:68
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
union IP_ADDRESS::@1014 Address
IPv4_RAW_ADDRESS IPv4Address
Definition: ip.h:26
USHORT Port
Definition: titypes.h:120
IP_ADDRESS Address
Definition: titypes.h:117
TRANSPORT_ADDRESS Address
Definition: tdi.h:388
ULONG MaxDatagramSize
Definition: tdi.h:230
#define TDI_QUERY_MAX_DATAGRAM_INFO
Definition: tdi.h:187
#define TDI_QUERY_CONNECTION_INFO
Definition: tdi.h:182
struct _TA_ADDRESS_IP * PTA_IP_ADDRESS
struct _TDI_CONNECTION_INFO * PTDI_CONNECTION_INFO
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
struct _TDI_ADDRESS_INFO * PTDI_ADDRESS_INFO
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
#define TDI_QUERY_ADDRESS_INFO
Definition: tdi.h:181
struct _TDI_MAX_DATAGRAM_INFO * PTDI_MAX_DATAGRAM_INFO
struct _TDI_REQUEST_KERNEL_QUERY_INFO * PTDI_REQUEST_KERNEL_QUERY_INFORMATION
#define TDI_CONNECTION_FILE
Definition: tdikrnl.h:66
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MmGetMdlByteCount(_Mdl)
#define MmGetSystemAddressForMdl(Mdl)

Referenced by TiDispatchInternal().

◆ DispTdiQueryInformationEx()

NTSTATUS DispTdiQueryInformationEx ( PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 1319 of file dispatch.c.

1330{
1332 PTRANSPORT_CONTEXT TranContext;
1333 PTI_QUERY_CONTEXT QueryContext;
1336 UINT Size;
1339 BOOLEAN InputMdlLocked = FALSE;
1340 BOOLEAN OutputMdlLocked = FALSE;
1341 PMDL InputMdl = NULL;
1342 PMDL OutputMdl = NULL;
1344
1345 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
1346
1347 TranContext = (PTRANSPORT_CONTEXT)IrpSp->FileObject->FsContext;
1348
1349 switch ((ULONG_PTR)IrpSp->FileObject->FsContext2) {
1351 Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
1352 break;
1353
1355 Request.Handle.ConnectionContext = TranContext->Handle.ConnectionContext;
1356 break;
1357
1359 Request.Handle.ControlChannel = TranContext->Handle.ControlChannel;
1360 break;
1361
1362 default:
1363 TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
1365 }
1366
1368 OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
1369
1370 /* Validate parameters */
1372 (OutputBufferLength != 0)) {
1373
1375 IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
1376 OutputBuffer = Irp->UserBuffer;
1377
1379 if (QueryContext) {
1380 _SEH2_TRY {
1381 InputMdl = IoAllocateMdl(InputBuffer,
1383 FALSE, TRUE, NULL);
1384
1385 OutputMdl = IoAllocateMdl(OutputBuffer,
1387
1388 if (InputMdl && OutputMdl) {
1389
1390 MmProbeAndLockPages(InputMdl, Irp->RequestorMode,
1392
1393 InputMdlLocked = TRUE;
1394
1395 MmProbeAndLockPages(OutputMdl, Irp->RequestorMode,
1397
1398 OutputMdlLocked = TRUE;
1399
1400 RtlCopyMemory(&QueryContext->QueryInfo,
1402 } else
1406 } _SEH2_END;
1407
1408 if (NT_SUCCESS(Status)) {
1409 Size = MmGetMdlByteCount(OutputMdl);
1410
1411 QueryContext->Irp = Irp;
1412 QueryContext->InputMdl = InputMdl;
1413 QueryContext->OutputMdl = OutputMdl;
1414
1415 Request.RequestNotifyObject = DispTdiQueryInformationExComplete;
1416 Request.RequestContext = QueryContext;
1418 &QueryContext->QueryInfo.ID, OutputMdl,
1419 &Size, &QueryContext->QueryInfo.Context);
1421
1422 TI_DbgPrint(MAX_TRACE, ("Leaving. Status = (0x%X)\n", Status));
1423
1424 return Status;
1425 }
1426
1427 /* An error occurred if we get here */
1428
1429 if (InputMdl) {
1430 if (InputMdlLocked)
1431 MmUnlockPages(InputMdl);
1432 IoFreeMdl(InputMdl);
1433 }
1434
1435 if (OutputMdl) {
1436 if (OutputMdlLocked)
1437 MmUnlockPages(OutputMdl);
1438 IoFreeMdl(OutputMdl);
1439 }
1440
1441 ExFreePoolWithTag(QueryContext, QUERY_CONTEXT_TAG);
1442 } else
1444 } else if( InputBufferLength ==
1446 /* Handle the case where the user is probing the buffer for length */
1447 TI_DbgPrint(MAX_TRACE, ("InputBufferLength %d OutputBufferLength %d\n",
1450 IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
1451
1452 Size = 0;
1453
1455 if (!QueryContext) return STATUS_INSUFFICIENT_RESOURCES;
1456
1457 _SEH2_TRY {
1458 InputMdl = IoAllocateMdl(InputBuffer,
1460 FALSE, TRUE, NULL);
1461
1462 MmProbeAndLockPages(InputMdl, Irp->RequestorMode,
1464
1465 InputMdlLocked = TRUE;
1468 TI_DbgPrint(MAX_TRACE, ("Failed to acquire client buffer\n"));
1470 } _SEH2_END;
1471
1472 if( !NT_SUCCESS(Status) || !InputMdl ) {
1473 if( InputMdl ) IoFreeMdl( InputMdl );
1474 ExFreePoolWithTag(QueryContext, QUERY_CONTEXT_TAG);
1475 return Status;
1476 }
1477
1478 RtlCopyMemory(&QueryContext->QueryInfo,
1480
1481 QueryContext->Irp = Irp;
1482 QueryContext->InputMdl = InputMdl;
1483 QueryContext->OutputMdl = NULL;
1484
1485 Request.RequestNotifyObject = DispTdiQueryInformationExComplete;
1486 Request.RequestContext = QueryContext;
1488 &QueryContext->QueryInfo.ID,
1489 NULL,
1490 &Size,
1491 &QueryContext->QueryInfo.Context);
1493 TI_DbgPrint(MAX_TRACE, ("Leaving. Status = (0x%X)\n", Status));
1495
1496 TI_DbgPrint(MIN_TRACE, ("Leaving. Status = (0x%X)\n", Status));
1497
1498 return Status;
1499}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define QUERY_CONTEXT_TAG
Definition: tags.h:17
VOID DispTdiQueryInformationExComplete(PVOID Context, ULONG Status, UINT ByteCount)
Definition: dispatch.c:1282
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
TDI_STATUS InfoTdiQueryInformationEx(PTDI_REQUEST Request, TDIObjectID *ID, PNDIS_BUFFER Buffer, PUINT BufferSize, PVOID Context)
Definition: info.c:215
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
unsigned int UINT
Definition: ndis.h:50
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
struct _IO_STACK_LOCATION::@1579::@1580 DeviceIoControl
ULONG_PTR Context[CONTEXT_SIZE/sizeof(ULONG_PTR)]
Definition: tdiinfo.h:84
TCP_REQUEST_QUERY_INFORMATION_EX QueryInfo
Definition: titypes.h:303
HANDLE ControlChannel
Definition: titypes.h:293
struct _TCP_REQUEST_QUERY_INFORMATION_EX * PTCP_REQUEST_QUERY_INFORMATION_EX
#define TDI_CONTROL_CHANNEL_FILE
Definition: tdikrnl.h:67
struct _TRANSPORT_CONTEXT * PTRANSPORT_CONTEXT
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
@ IoWriteAccess
Definition: ketypes.h:864
@ IoModifyAccess
Definition: ketypes.h:865

Referenced by TiDispatch().

◆ DispTdiQueryIpHwAddress()

NTSTATUS DispTdiQueryIpHwAddress ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 1681 of file dispatch.c.

1681 {
1683 PULONG IPs;
1684 IP_ADDRESS Remote, Local;
1688
1689 Irp->IoStatus.Information = 0;
1690
1691 if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < 2 * sizeof(ULONG) ||
1692 IrpSp->Parameters.DeviceIoControl.OutputBufferLength == 0) {
1694 goto Exit;
1695 }
1696
1697 IPs = (PULONG)Irp->AssociatedIrp.SystemBuffer;
1698 AddrInitIPv4(&Remote, IPs[0]);
1699 AddrInitIPv4(&Local, IPs[1]);
1700
1701 if (AddrIsUnspecified(&Remote)) {
1703 goto Exit;
1704 }
1705
1706 Interface = AddrLocateInterface(&Remote);
1707 if (Interface) {
1709
1710 if (Interface->AddressLength > IrpSp->Parameters.DeviceIoControl.OutputBufferLength) {
1712 goto Exit;
1713 }
1714
1715 OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
1716 RtlCopyMemory(OutputBuffer, Interface->Address, Interface->AddressLength);
1717 Irp->IoStatus.Information = Interface->AddressLength;
1719 goto Exit;
1720 }
1721
1722 if (AddrIsUnspecified(&Local)) {
1723 NCE = RouteGetRouteToDestination(&Remote);
1724 if (NCE == NULL) {
1726 goto Exit;
1727 }
1728
1729 Interface = NCE->Interface;
1730 }
1731 else {
1733 if (Interface == NULL) {
1735 if (Interface == NULL) {
1737 goto Exit;
1738 }
1739 }
1740 }
1741
1743 if (WorkItem == NULL) {
1745 goto Exit;
1746 }
1747
1749 if (WorkItem->WorkItem == NULL) {
1752 goto Exit;
1753 }
1754
1755 WorkItem->Irp = Irp;
1756 WorkItem->IrpSp = IrpSp;
1758 WorkItem->RemoteIP = IPs[0];
1759 KeQuerySystemTime(&WorkItem->StartTime);
1760
1761 NCE = NBLocateNeighbor(&Remote, Interface);
1762 if (NCE != NULL) {
1763 if (NCE->LinkAddressLength > IrpSp->Parameters.DeviceIoControl.OutputBufferLength) {
1764 IoFreeWorkItem(WorkItem->WorkItem);
1767 goto Exit;
1768 }
1769
1770 if (!(NCE->State & NUD_INCOMPLETE)) {
1772 if (LinkAddress == NULL) {
1773 IoFreeWorkItem(WorkItem->WorkItem);
1776 goto Exit;
1777 }
1778 memset(LinkAddress, 0xff, NCE->LinkAddressLength);
1779 NBUpdateNeighbor(NCE, LinkAddress, NUD_INCOMPLETE);
1781 }
1782 }
1783
1784 if (!ARPTransmit(&Remote, NULL, Interface)) {
1785 IoFreeWorkItem(WorkItem->WorkItem);
1788 goto Exit;
1789 }
1790
1791 if (Irp->Flags & IRP_SYNCHRONOUS_API) {
1793 Status = Irp->IoStatus.Status;
1794 } else {
1798 }
1799
1800Exit:
1801 return Status;
1802}
#define AddrInitIPv4(IPAddress, RawAddress)
Definition: address.h:16
PIP_INTERFACE AddrLocateInterface(PIP_ADDRESS MatchAddress)
Definition: interface.c:89
BOOLEAN AddrIsUnspecified(PIP_ADDRESS Address)
Definition: address.c:113
BOOLEAN ARPTransmit(PIP_ADDRESS Address, PVOID LinkAddress, PIP_INTERFACE Interface)
Definition: arp.c:111
PNEIGHBOR_CACHE_ENTRY RouteGetRouteToDestination(PIP_ADDRESS Destination)
Definition: router.c:300
VOID NTAPI WaitForHwAddress(PDEVICE_OBJECT DeviceObject, PVOID Context)
Definition: dispatch.c:1635
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
@ Remote
Definition: scrrun.idl:92
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(PIP_ADDRESS Address, PIP_INTERFACE Interface)
Definition: neighbor.c:417
#define NUD_INCOMPLETE
Definition: neighbor.h:41
VOID NBUpdateNeighbor(PNEIGHBOR_CACHE_ENTRY NCE, PVOID LinkAddress, UCHAR State)
Definition: neighbor.c:346
PIP_INTERFACE GetDefaultInterface(VOID)
Definition: interface.c:156
#define STATUS_NETWORK_UNREACHABLE
Definition: ntstatus.h:704
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define memset(x, y, z)
Definition: compat.h:39
static void Exit(void)
Definition: sock.c:1330
Definition: ip.h:23
Definition: neighbor.h:28
PIP_INTERFACE Interface
Definition: neighbor.h:33
UCHAR State
Definition: neighbor.h:30
UINT LinkAddressLength
Definition: neighbor.h:34
PINTERFACE Interface
Definition: iotypes.h:3248
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
@ DelayedWorkQueue
Definition: extypes.h:190
#define IRP_SYNCHRONOUS_API

Referenced by TiDispatch().

◆ DispTdiReceive()

NTSTATUS DispTdiReceive ( PIRP  Irp)

Definition at line 802 of file dispatch.c.

811{
813 PTDI_REQUEST_KERNEL_RECEIVE ReceiveInfo;
814 PTRANSPORT_CONTEXT TranContext;
816 ULONG BytesReceived = 0;
817
818 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
819
822
824
825 TranContext = IrpSp->FileObject->FsContext;
826 if (TranContext == NULL)
827 {
828 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
830 goto done;
831 }
832
833 if (TranContext->Handle.ConnectionContext == NULL)
834 {
835 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
837 goto done;
838 }
839
840 /* Initialize a receive request */
842 (TranContext->Handle.ConnectionContext,
843 Irp,
845
846 TI_DbgPrint(MID_TRACE,("TCPIP<<< Got an MDL: %x\n", Irp->MdlAddress));
847 if (NT_SUCCESS(Status))
848 {
850 TranContext->Handle.ConnectionContext,
851 (PNDIS_BUFFER)Irp->MdlAddress,
852 ReceiveInfo->ReceiveLength,
853 &BytesReceived,
854 ReceiveInfo->ReceiveFlags,
856 Irp);
857 }
858
859done:
860 if (Status != STATUS_PENDING) {
861 DispDataRequestComplete(Irp, Status, BytesReceived);
862 }
863
864 TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
865
866 return STATUS_PENDING;
867}
NTSTATUS TCPReceiveData(PCONNECTION_ENDPOINT Connection, PNDIS_BUFFER Buffer, ULONG ReceiveLength, PULONG BytesReceived, ULONG ReceiveFlags, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:529
MDL * PNDIS_BUFFER
Definition: ndis.h:343
struct _TDI_REQUEST_KERNEL_RECEIVE * PTDI_REQUEST_KERNEL_RECEIVE

Referenced by TiDispatchInternal().

◆ DispTdiReceiveDatagram()

NTSTATUS DispTdiReceiveDatagram ( PIRP  Irp)

Definition at line 870 of file dispatch.c.

879{
882 PTRANSPORT_CONTEXT TranContext;
885 ULONG BytesReceived = 0;
886
887 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
888
891
893
894 TranContext = IrpSp->FileObject->FsContext;
895 if (TranContext == NULL)
896 {
897 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
899 goto done;
900 }
901
902 /* Initialize a receive request */
903 Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
904 Request.RequestNotifyObject = DispDataRequestComplete;
905 Request.RequestContext = Irp;
906
908 IrpSp->FileObject->FsContext,
909 Irp,
911
912 if (NT_SUCCESS(Status))
913 {
914 PVOID DataBuffer;
916
917 NdisQueryBuffer( (PNDIS_BUFFER)Irp->MdlAddress,
918 &DataBuffer,
919 &BufferSize );
920
922 Request.Handle.AddressHandle,
924 DataBuffer,
925 DgramInfo->ReceiveLength,
926 DgramInfo->ReceiveFlags,
927 DgramInfo->ReturnDatagramInformation,
928 &BytesReceived,
930 Irp,
931 Irp);
932 }
933
934done:
935 if (Status != STATUS_PENDING) {
936 DispDataRequestComplete(Irp, Status, BytesReceived);
937 }
938
939 TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
940
941 return STATUS_PENDING;
942}
NTSTATUS DGReceiveDatagram(PADDRESS_FILE AddrFile, PTDI_CONNECTION_INFORMATION ConnInfo, PCHAR Buffer, ULONG ReceiveLength, ULONG ReceiveFlags, PTDI_CONNECTION_INFORMATION ReturnInfo, PULONG BytesReceived, PDATAGRAM_COMPLETION_ROUTINE Complete, PVOID Context, PIRP Irp)
Definition: datagram.c:226
#define BufferSize
Definition: mmc.h:75
#define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length)
Definition: ndis.h:3029
PTDI_CONNECTION_INFORMATION ReceiveDatagramInformation
Definition: tdikrnl.h:109
PTDI_CONNECTION_INFORMATION ReturnDatagramInformation
Definition: tdikrnl.h:110
struct _TDI_REQUEST_KERNEL_RECEIVEDG * PTDI_REQUEST_KERNEL_RECEIVEDG
DATAGRAM_COMPLETION_ROUTINE PDATAGRAM_COMPLETION_ROUTINE
Definition: titypes.h:74
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by TiDispatchInternal().

◆ DispTdiSend()

NTSTATUS DispTdiSend ( PIRP  Irp)

Definition at line 945 of file dispatch.c.

954{
957 PTRANSPORT_CONTEXT TranContext;
959 ULONG BytesSent = 0;
960
961 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
962
965
967
968 TranContext = IrpSp->FileObject->FsContext;
969 if (TranContext == NULL)
970 {
971 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
973 goto done;
974 }
975
976 if (TranContext->Handle.ConnectionContext == NULL)
977 {
978 TI_DbgPrint(MID_TRACE, ("No connection endpoint file object.\n"));
980 goto done;
981 }
982
984 IrpSp->FileObject->FsContext,
985 Irp,
987
988 TI_DbgPrint(MID_TRACE,("TCPIP<<< Got an MDL: %x\n", Irp->MdlAddress));
989 if (NT_SUCCESS(Status))
990 {
991 PVOID Data;
992 UINT Len;
993
994 NdisQueryBuffer( Irp->MdlAddress, &Data, &Len );
995
996 TI_DbgPrint(MID_TRACE,("About to TCPSendData\n"));
998 TranContext->Handle.ConnectionContext,
999 Data,
1000 SendInfo->SendLength,
1001 &BytesSent,
1002 SendInfo->SendFlags,
1004 Irp);
1005 }
1006
1007done:
1008 if (Status != STATUS_PENDING) {
1009 DispDataRequestComplete(Irp, Status, BytesSent);
1010 }
1011
1012 TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
1013
1014 return STATUS_PENDING;
1015}
#define Len
Definition: deflate.h:82
NTSTATUS TCPSendData(PCONNECTION_ENDPOINT Connection, PCHAR Buffer, ULONG DataSize, PULONG DataUsed, ULONG Flags, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:580
struct _TDI_REQUEST_KERNEL_SEND * PTDI_REQUEST_KERNEL_SEND

Referenced by TiDispatchInternal().

◆ DispTdiSendDatagram()

NTSTATUS DispTdiSendDatagram ( PIRP  Irp)

Definition at line 1018 of file dispatch.c.

1027{
1031 PTRANSPORT_CONTEXT TranContext;
1033
1034 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
1035
1038
1040
1041 TranContext = IrpSp->FileObject->FsContext;
1042 if (TranContext == NULL)
1043 {
1044 TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
1046 goto done;
1047 }
1048
1049 /* Initialize a send request */
1050 Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
1051 Request.RequestNotifyObject = DispDataRequestComplete;
1052 Request.RequestContext = Irp;
1053
1055 IrpSp->FileObject->FsContext,
1056 Irp,
1058
1059 if (NT_SUCCESS(Status)) {
1060 PVOID DataBuffer;
1062
1063 TI_DbgPrint(MID_TRACE,("About to query buffer %x\n", Irp->MdlAddress));
1064
1065 NdisQueryBuffer( (PNDIS_BUFFER)Irp->MdlAddress,
1066 &DataBuffer,
1067 &BufferSize );
1068
1069 /* FIXME: DgramInfo->SendDatagramInformation->RemoteAddress
1070 must be of type PTDI_ADDRESS_IP */
1072 ("About to call send routine %x\n",
1073 (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send)));
1074
1075 if( (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send != NULL) )
1076 {
1077 ULONG DataUsed = 0;
1078 Status = (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send)(
1079 Request.Handle.AddressHandle,
1080 DgramInfo->SendDatagramInformation,
1081 DataBuffer,
1082 BufferSize,
1083 &DataUsed);
1084 Irp->IoStatus.Information = DataUsed;
1085 }
1086 else {
1088 ASSERT(FALSE);
1089 }
1090 }
1091
1092done:
1093 if (Status != STATUS_PENDING) {
1094 DispDataRequestComplete(Irp, Status, Irp->IoStatus.Information);
1095 }
1096
1097 TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
1098
1099 return STATUS_PENDING;
1100}
struct _TDI_REQUEST_KERNEL_SENDDG * PTDI_REQUEST_KERNEL_SENDDG

Referenced by TiDispatchInternal().

◆ DispTdiSetEventHandler()

NTSTATUS DispTdiSetEventHandler ( PIRP  Irp)

Definition at line 1103 of file dispatch.c.

1111{
1113 PTRANSPORT_CONTEXT TranContext;
1115 PADDRESS_FILE AddrFile;
1117
1118 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
1119
1121
1122 /* Get associated address file object. Quit if none exists */
1123
1124 TranContext = IrpSp->FileObject->FsContext;
1125 if (!TranContext) {
1126 TI_DbgPrint(MIN_TRACE, ("Bad transport context.\n"));
1128 }
1129
1130 AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
1131 if (!AddrFile) {
1132 TI_DbgPrint(MIN_TRACE, ("No address file object.\n"));
1134 }
1135
1138
1139 LockObject(AddrFile);
1140
1141 /* Set the event handler. if an event handler is associated with
1142 a specific event, it's flag (RegisteredXxxHandler) is TRUE.
1143 If an event handler is not used it's flag is FALSE */
1144 switch (Parameters->EventType) {
1145 case TDI_EVENT_CONNECT:
1146 if (!Parameters->EventHandler) {
1147 AddrFile->ConnectHandlerContext = NULL;
1148 AddrFile->RegisteredConnectHandler = FALSE;
1149 } else {
1150 AddrFile->ConnectHandler =
1151 (PTDI_IND_CONNECT)Parameters->EventHandler;
1152 AddrFile->ConnectHandlerContext = Parameters->EventContext;
1153 AddrFile->RegisteredConnectHandler = TRUE;
1154 }
1155 break;
1156
1158 if (!Parameters->EventHandler) {
1159 AddrFile->DisconnectHandlerContext = NULL;
1161 } else {
1162 AddrFile->DisconnectHandler =
1163 (PTDI_IND_DISCONNECT)Parameters->EventHandler;
1164 AddrFile->DisconnectHandlerContext = Parameters->EventContext;
1166 }
1167 break;
1168
1169 case TDI_EVENT_ERROR:
1170 if (Parameters->EventHandler == NULL) {
1171 AddrFile->ErrorHandlerContext = NULL;
1172 AddrFile->RegisteredErrorHandler = FALSE;
1173 } else {
1174 AddrFile->ErrorHandler =
1175 (PTDI_IND_ERROR)Parameters->EventHandler;
1176 AddrFile->ErrorHandlerContext = Parameters->EventContext;
1177 AddrFile->RegisteredErrorHandler = TRUE;
1178 }
1179 break;
1180
1181 case TDI_EVENT_RECEIVE:
1182 if (Parameters->EventHandler == NULL) {
1183 AddrFile->ReceiveHandlerContext = NULL;
1184 AddrFile->RegisteredReceiveHandler = FALSE;
1185 } else {
1186 AddrFile->ReceiveHandler =
1187 (PTDI_IND_RECEIVE)Parameters->EventHandler;
1188 AddrFile->ReceiveHandlerContext = Parameters->EventContext;
1189 AddrFile->RegisteredReceiveHandler = TRUE;
1190 }
1191 break;
1192
1194 if (Parameters->EventHandler == NULL) {
1197 } else {
1198 AddrFile->ReceiveDatagramHandler =
1200 AddrFile->ReceiveDatagramHandlerContext = Parameters->EventContext;
1202 }
1203 break;
1204
1206 if (Parameters->EventHandler == NULL) {
1209 } else {
1210 AddrFile->ExpeditedReceiveHandler =
1212 AddrFile->ExpeditedReceiveHandlerContext = Parameters->EventContext;
1214 }
1215 break;
1216
1218 if (Parameters->EventHandler == NULL) {
1221 } else {
1222 AddrFile->ChainedReceiveHandler =
1223 (PTDI_IND_CHAINED_RECEIVE)Parameters->EventHandler;
1224 AddrFile->ChainedReceiveHandlerContext = Parameters->EventContext;
1226 }
1227 break;
1228
1230 if (Parameters->EventHandler == NULL) {
1233 } else {
1236 AddrFile->ChainedReceiveDatagramHandlerContext = Parameters->EventContext;
1238 }
1239 break;
1240
1242 if (Parameters->EventHandler == NULL) {
1245 } else {
1248 AddrFile->ChainedReceiveExpeditedHandlerContext = Parameters->EventContext;
1250 }
1251 break;
1252
1253 default:
1254 TI_DbgPrint(MIN_TRACE, ("Unknown event type (0x%X).\n",
1255 Parameters->EventType));
1256
1258 }
1259
1260 UnlockObject(AddrFile);
1261
1262 return Status;
1263}
BOOLEAN RegisteredReceiveDatagramHandler
Definition: titypes.h:163
BOOLEAN RegisteredConnectHandler
Definition: titypes.h:146
PTDI_IND_CHAINED_RECEIVE ChainedReceiveHandler
Definition: titypes.h:169
PVOID ChainedReceiveHandlerContext
Definition: titypes.h:170
BOOLEAN RegisteredChainedReceiveExpeditedHandler
Definition: titypes.h:179
PTDI_IND_DISCONNECT DisconnectHandler
Definition: titypes.h:148
PVOID ConnectHandlerContext
Definition: titypes.h:145
PTDI_IND_CHAINED_RECEIVE_DATAGRAM ChainedReceiveDatagramHandler
Definition: titypes.h:173
PVOID DisconnectHandlerContext
Definition: titypes.h:149
PTDI_IND_ERROR ErrorHandler
Definition: titypes.h:152
PVOID ReceiveHandlerContext
Definition: titypes.h:158
PVOID ExpeditedReceiveHandlerContext
Definition: titypes.h:166
BOOLEAN RegisteredErrorHandler
Definition: titypes.h:155
PTDI_IND_CONNECT ConnectHandler
Definition: titypes.h:144
BOOLEAN RegisteredChainedReceiveHandler
Definition: titypes.h:171
BOOLEAN RegisteredReceiveHandler
Definition: titypes.h:159
PVOID ChainedReceiveDatagramHandlerContext
Definition: titypes.h:174
PVOID ReceiveDatagramHandlerContext
Definition: titypes.h:162
BOOLEAN RegisteredDisconnectHandler
Definition: titypes.h:150
PTDI_IND_RECEIVE_DATAGRAM ReceiveDatagramHandler
Definition: titypes.h:161
PTDI_IND_RECEIVE ReceiveHandler
Definition: titypes.h:157
PVOID ErrorHandlerContext
Definition: titypes.h:153
BOOLEAN RegisteredExpeditedReceiveHandler
Definition: titypes.h:167
PTDI_IND_CHAINED_RECEIVE_EXPEDITED ChainedReceiveExpeditedHandler
Definition: titypes.h:177
BOOLEAN RegisteredChainedReceiveDatagramHandler
Definition: titypes.h:175
PTDI_IND_RECEIVE_EXPEDITED ExpeditedReceiveHandler
Definition: titypes.h:165
PVOID ChainedReceiveExpeditedHandlerContext
Definition: titypes.h:178
#define TDI_EVENT_ERROR
Definition: tdikrnl.h:148
NTSTATUS(NTAPI * PTDI_IND_RECEIVE_EXPEDITED)(_In_opt_ PVOID TdiEventContext, _In_opt_ CONNECTION_CONTEXT ConnectionContext, _In_ ULONG ReceiveFlags, _In_ ULONG BytesIndicated, _In_ ULONG BytesAvailable, _Out_ ULONG *BytesTaken, _In_ PVOID Tsdu, _Out_opt_ PIRP *IoRequestPacket)
Definition: tdikrnl.h:278
#define TDI_EVENT_CHAINED_RECEIVE_EXPEDITED
Definition: tdikrnl.h:155
#define TDI_EVENT_RECEIVE_EXPEDITED
Definition: tdikrnl.h:151
#define TDI_EVENT_CHAINED_RECEIVE
Definition: tdikrnl.h:153
#define TDI_EVENT_CONNECT
Definition: tdikrnl.h:146
NTSTATUS(NTAPI * PTDI_IND_CHAINED_RECEIVE_DATAGRAM)(_In_opt_ PVOID TdiEventContext, _In_ LONG SourceAddressLength, _In_reads_bytes_(SourceAddressLength) PVOID SourceAddress, _In_ LONG OptionsLength, _In_reads_bytes_opt_(OptionsLength) PVOID Options, _In_ ULONG ReceiveDatagramFlags, _In_ ULONG ReceiveDatagramLength, _In_ ULONG StartingOffset, _In_ PMDL Tsdu, _In_ PVOID TsduDescriptor)
Definition: tdikrnl.h:324
NTSTATUS(NTAPI * PTDI_IND_CHAINED_RECEIVE)(_In_opt_ PVOID TdiEventContext, _In_opt_ CONNECTION_CONTEXT ConnectionContext, _In_ ULONG ReceiveFlags, _In_ ULONG ReceiveLength, _In_ ULONG StartingOffset, _In_ PMDL Tsdu, _In_ PVOID TsduDescriptor)
Definition: tdikrnl.h:302
NTSTATUS(NTAPI * PTDI_IND_ERROR)(_In_opt_ PVOID TdiEventContext, _In_ NTSTATUS Status)
Definition: tdikrnl.h:207
struct _TDI_REQUEST_KERNEL_SET_EVENT * PTDI_REQUEST_KERNEL_SET_EVENT
#define TDI_EVENT_CHAINED_RECEIVE_DATAGRAM
Definition: tdikrnl.h:154
NTSTATUS(NTAPI * PTDI_IND_CHAINED_RECEIVE_EXPEDITED)(_In_opt_ PVOID TdiEventContext, _In_opt_ CONNECTION_CONTEXT ConnectionContext, _In_ ULONG ReceiveFlags, _In_ ULONG ReceiveLength, _In_ ULONG StartingOffset, _In_ PMDL Tsdu, _In_ PVOID TsduDescriptor)
Definition: tdikrnl.h:352
#define TDI_EVENT_DISCONNECT
Definition: tdikrnl.h:147
NTSTATUS(NTAPI * PTDI_IND_RECEIVE_DATAGRAM)(_In_opt_ PVOID TdiEventContext, _In_ LONG SourceAddressLength, _In_reads_bytes_(SourceAddressLength) PVOID SourceAddress, _In_ LONG OptionsLength, _In_reads_bytes_opt_(OptionsLength) PVOID Options, _In_ ULONG ReceiveDatagramFlags, _In_ ULONG BytesIndicated, _In_ ULONG BytesAvailable, _Out_ ULONG *BytesTaken, _In_ PVOID Tsdu, _Out_opt_ PIRP *IoRequestPacket)
Definition: tdikrnl.h:249
NTSTATUS(NTAPI * PTDI_IND_RECEIVE)(_In_opt_ PVOID TdiEventContext, _In_opt_ CONNECTION_CONTEXT ConnectionContext, _In_ ULONG ReceiveFlags, _In_ ULONG BytesIndicated, _In_ ULONG BytesAvailable, _Out_ ULONG *BytesTaken, _In_ PVOID Tsdu, _Out_opt_ PIRP *IoRequestPacket)
Definition: tdikrnl.h:225
NTSTATUS(NTAPI * PTDI_IND_CONNECT)(_In_opt_ PVOID TdiEventContext, _In_ LONG RemoteAddressLength, _In_reads_bytes_(RemoteAddressLength) PVOID RemoteAddress, _In_ LONG UserDataLength, _In_reads_bytes_opt_(UserDataLength) PVOID UserData, _In_ LONG OptionsLength, _In_reads_bytes_opt_(OptionsLength) PVOID Options, _Out_ CONNECTION_CONTEXT *ConnectionContext, _Out_ PIRP *AcceptIrp)
Definition: tdikrnl.h:159
#define TDI_EVENT_RECEIVE
Definition: tdikrnl.h:149
#define TDI_EVENT_RECEIVE_DATAGRAM
Definition: tdikrnl.h:150
NTSTATUS(NTAPI * PTDI_IND_DISCONNECT)(_In_opt_ PVOID TdiEventContext, _In_opt_ CONNECTION_CONTEXT ConnectionContext, _In_ LONG DisconnectDataLength, _In_reads_bytes_opt_(DisconnectDataLength) PVOID DisconnectData, _In_ LONG DisconnectInformationLength, _In_reads_bytes_opt_(DisconnectInformationLength) PVOID DisconnectInformation, _In_ ULONG DisconnectFlags)
Definition: tdikrnl.h:185

Referenced by TiDispatchInternal().

◆ DispTdiSetInformation()

NTSTATUS DispTdiSetInformation ( PIRP  Irp)

Definition at line 1266 of file dispatch.c.

1275{
1276 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
1277
1279}

Referenced by TiDispatchInternal().

◆ DispTdiSetInformationEx()

NTSTATUS DispTdiSetInformationEx ( PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 1502 of file dispatch.c.

1513{
1514 PTRANSPORT_CONTEXT TranContext;
1518
1519 TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
1520
1521 TranContext = (PTRANSPORT_CONTEXT)IrpSp->FileObject->FsContext;
1522 Info = (PTCP_REQUEST_SET_INFORMATION_EX)Irp->AssociatedIrp.SystemBuffer;
1523
1524 switch ((ULONG_PTR)IrpSp->FileObject->FsContext2) {
1526 Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
1527 break;
1528
1530 Request.Handle.ConnectionContext = TranContext->Handle.ConnectionContext;
1531 break;
1532
1534 Request.Handle.ControlChannel = TranContext->Handle.ControlChannel;
1535 break;
1536
1537 default:
1538 Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
1539 Irp->IoStatus.Information = 0;
1540
1541 TI_DbgPrint(DEBUG_IRP, ("Completing IRP at (0x%X).\n", Irp));
1542
1543 return Irp->IoStatus.Status;
1544 }
1545
1546 Request.RequestNotifyObject = NULL;
1547 Request.RequestContext = NULL;
1548
1550 &Info->Buffer, Info->BufferSize);
1551
1552 return Status;
1553}
TDI_STATUS InfoTdiSetInformationEx(PTDI_REQUEST Request, TDIObjectID *ID, PVOID Buffer, UINT BufferSize)
Definition: info.c:383
LONG TDI_STATUS
Definition: tdi.h:36
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by TiDispatch().

◆ DispTdiSetIPAddress()

NTSTATUS DispTdiSetIPAddress ( PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 1561 of file dispatch.c.

1561 {
1563 PIP_SET_ADDRESS IpAddrChange =
1564 (PIP_SET_ADDRESS)Irp->AssociatedIrp.SystemBuffer;
1565 IF_LIST_ITER(IF);
1566
1567 TI_DbgPrint(MID_TRACE,("Setting IP Address for adapter %d\n",
1568 IpAddrChange->NteIndex));
1569
1570 ForEachInterface(IF) {
1571 TI_DbgPrint(MID_TRACE,("Looking at adapter %d\n", IF->Index));
1572
1573 if( IF->Unicast.Address.IPv4Address == IpAddrChange->Address ) {
1575 break;
1576 }
1577 if( IF->Index == IpAddrChange->NteIndex ) {
1579
1580 IF->Unicast.Type = IP_ADDRESS_V4;
1581 IF->Unicast.Address.IPv4Address = IpAddrChange->Address;
1582
1583 IF->Netmask.Type = IP_ADDRESS_V4;
1584 IF->Netmask.Address.IPv4Address = IpAddrChange->Netmask;
1585
1586 IF->Broadcast.Type = IP_ADDRESS_V4;
1587 IF->Broadcast.Address.IPv4Address =
1588 IF->Unicast.Address.IPv4Address |
1589 ~IF->Netmask.Address.IPv4Address;
1590
1591 TI_DbgPrint(MID_TRACE,("New Unicast Address: %x\n",
1592 IF->Unicast.Address.IPv4Address));
1593 TI_DbgPrint(MID_TRACE,("New Netmask : %x\n",
1594 IF->Netmask.Address.IPv4Address));
1595
1596 IPAddInterfaceRoute( IF );
1597
1598 IpAddrChange->Address = IF->Index;
1600 Irp->IoStatus.Information = IF->Index;
1601 break;
1602 }
1603 } EndFor(IF);
1604
1605 Irp->IoStatus.Status = Status;
1606 return Status;
1607}
VOID IPAddInterfaceRoute(PIP_INTERFACE IF)
Definition: ip.c:262
struct _IP_SET_ADDRESS * PIP_SET_ADDRESS
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define STATUS_DUPLICATE_OBJECTID
Definition: ntstatus.h:686
ULONG NteIndex
Definition: ip.h:174
IPv4_RAW_ADDRESS Address
Definition: ip.h:175
IPv4_RAW_ADDRESS Netmask
Definition: ip.h:176

Referenced by TiDispatch().

◆ IRPFinish()

NTSTATUS IRPFinish ( PIRP  Irp,
NTSTATUS  Status 
)

Definition at line 26 of file dispatch.c.

26 {
28
29 if (Status != STATUS_PENDING) {
30 Irp->IoStatus.Status = Status;
34
36 }
37
38 return Status;
39}
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
UCHAR KIRQL
Definition: env_spec_w32.h:591
IoSetCancelRoutine(Irp, CancelRoutine)
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by DispCancelListenRequest(), DispCancelRequest(), DispDataRequestComplete(), TiDispatch(), TiDispatchInternal(), TiDispatchOpenClose(), and WaitForHwAddress().