Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

TDI Server send not working

Hi
I have established TCP/IP path between TDI client and TDI server.
But my TDI server is not able to send anything.

My code follows.
NTSTATUS
Send(PDEVICE_OBJECT pTcpDevObj, PFILE_OBJECT pConnFileObj, PVOID Data, ULONG Length, PSIZE_T total)
{
       NTSTATUS status = STATUS_TIMEOUT;
       PIRP pIrp;
       IO_STATUS_BLOCK IoStatus = {0};
       KEVENT SendEvent;
       PMDL       pMdl;
       *total = 0; //To use for received data count
       KeInitializeEvent(&SendEvent, NotificationEvent, FALSE);
       // build an IRP to connect to a remote host
       pIrp =
       TdiBuildInternalDeviceControlIrp( TDI_SEND,
                                       pTcpDevObj,   // TDI driver's device object.
                                       pConnFileObj, // Connection (endpoint) file object.
                                       &SendEvent,       // Event to be signalled when Irp completes.
                                       &IoStatus     // I/O status block.
                                      );

       ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
       pMdl = IoAllocateMdl((PCHAR)Data, Length, FALSE, FALSE, pIrp);
       if(NULL==pMdl)
        {
               DbgPrint("Could not get an MDL for TDI_SEND");
               return(STATUS_INSUFFICIENT_RESOURCES);
        }

        __try
        {
                MmProbeAndLockPages( pMdl,                     // (Try to) fix buffer.
                           KernelMode,
                               IoModifyAccess
                               );
       }
       __except(EXCEPTION_EXECUTE_HANDLER)
       {
                DbgPrint("Exception calling MmProbeAndLockPages");
                IoFreeMdl(pMdl);
                pMdl = NULL;
                return STATUS_UNSUCCESSFUL;
        }

       TdiBuildSend( pIrp,
                 pTcpDevObj,                         // TDI driver's device object.
                 pConnFileObj,                       // Connection (endpoint) file object.
                 NULL,                               // I/O completion routine.
                 NULL,                               // Context for I/O completion routine.
                 pMdl,                               // MDL address.
                 0, //TDI_SEND_NON_BLOCKING                                // Flags.  0 => send as normal TSDU.
                 Length                      // Length of buffer mapped by MDL.
                );

        ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL );
        IoSetCompletionRoutine( pIrp, TDICompletionRoutine, &SendEvent, TRUE, TRUE, TRUE);

        ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
        status = IoCallDriver(pTcpDevObj, pIrp);
       if (STATUS_PENDING==status)
       {
               DbgPrint("Waiting on IRP (send)...");
               status = KeWaitForSingleObject(&SendEvent, Executive, KernelMode, FALSE, 0);
        }
       if(status != STATUS_SUCCESS) {
               DbgPrint("Send....fails");
               return status;
       } else
       {
               DbgPrint("n Total sent : %dn",IoStatus.Information);
               *total = IoStatus.Information;
               return IoStatus.Status;
       }
}

With thanks in advance,
Barun

0 Kudos
Message 1 of 4
(8,214 Views)
Barun,

Can you tell us what hardware you're using?  Thanks!

Chad B. » National Instruments » ni.com
0 Kudos
Message 2 of 4
(8,201 Views)
Hi
My OS is Windows XP, which runs over AMD Athlon processor, 512MB Ram, 80GB harddisk.

0 Kudos
Message 3 of 4
(8,197 Views)
I have VIA PCI 10/100Mb Fast Ethernet Adapter and USB-2.0.
0 Kudos
Message 4 of 4
(8,196 Views)