Tech Support > Microsoft Windows > Drivers > TDI listen hangs. How to know, why?
TDI listen hangs. How to know, why?
Posted by Sergei V on October 7th, 2007


Hello,
I try to make my TCP TDI client to listen for connection
(that is I try to bring the server side of the connection up).

This is, I hope, 5 steps process:
1) Open transport address. (I use 0.0.0.0:5000)
2) Open connection endpoint
3) Associate transport with the connection
4) Hook some event grabbers (I have set event handlers
for TDI_EVENT_CONNECT and TDI_EVENT_RECEIVE)
5) Listen...

The first 4 steps of the 5 succeed, but the last TDI_LISTEN CallDriver
return STATUS_PENDING which never ends. (below please find a code fragment).

I expected that TDI listen request must never hang, because this is (i hope)
a
transport service "mode" setting only. What could be the reason for it to
hang?
How to make the server listen?

Please help.
(probably somebody could post few lines of sample code)

Thanks,
Sergei.

//-----------------------------------------------------------
//------------------------------------------------------------
//
// Tdi_Listen
//
NTSTATUS Tdi_Listen(PFILE_OBJECT pConnection)
{
NTSTATUS NtStatus = STATUS_INSUFFICIENT_RESOURCES;
PIRP pIrp;
PDEVICE_OBJECT pTdiDevice;
TDI_COMPLETION_CONTEXT TdiCompletionContext;
TDI_CONNECTION_INFORMATION ConnectionInfo_ret;
TDI_CONNECTION_INFORMATION ConnectionInfo = {0};
IO_STATUS_BLOCK IoStatusBlock = {0};
ULONG User_D = 0x40404040; // a "don't care" value

// PAGED_CODE();

KeInitializeEvent(&TdiCompletionContext.kCompleteE vent,
NotificationEvent, FALSE);
//
// TDI Device Object to send requests to the TDI Driver.
//
pTdiDevice = IoGetRelatedDeviceObject(pConnection);

//
// Build the IRP.
//
pIrp = TdiBuildInternalDeviceControlIrp(TDI_LISTEN,
pTdiDevice,
pConnection,
&TdiCompletionContext.kCompleteEvent,
&IoStatusBlock);
if(pIrp)
{
//
// Add the correct parameters into the IRP.
//
ConnectionInfo.UserData = &User_D;
ConnectionInfo.UserDataLength = sizeof(ULONG);
ConnectionInfo.Options = NULL;
ConnectionInfo.OptionsLength = 0;
ConnectionInfo.RemoteAddress = NULL;
ConnectionInfo.RemoteAddressLength = 0;
TdiBuildListen(pIrp, pTdiDevice,
pConnection, NULL, NULL,
0, // Flags,
&ConnectionInfo,
&ConnectionInfo_ret); // PTDI_CONNECTION_INFORMATION
NtStatus = IoCallDriver(pTdiDevice, pIrp);

//
// If TDI_LISTEN will not hang I'll have BSOD(CC01).
//
if(NtStatus == STATUS_PENDING)
{
KeWaitForSingleObject(&TdiCompletionContext.kCompl eteEvent,
Executive, KernelMode, FALSE, NULL);
NtStatus = IoStatusBlock.Status;

KeBugCheckEx(0xDEADCC01, 0, 0, 0, NtStatus);
}else{
KeBugCheckEx(0xDEADCC02, 0, 0, 0, NtStatus);
}
}
return NtStatus;
} // Tdi_Listen


Posted by Sergei V on October 7th, 2007


(this all was about WinXP DDK 3790.1830)


Posted by Sergei V on October 7th, 2007


Oops, seems I'm not alone with my question
and Maxim S. Shatskih once upon a time posted an answer:
http://www.techreplies.com/drivers-4...listen-331721/

However, still I cannot connect:
I try :
telnet 192.168.5.100 5000
(an IP address of my NIC - a single NIC in my PC)

telnet reports "could not open connection"
and TDI_LISTEN callback, nor
TdiEventConnect hook
never get control.



Posted by SergeV on October 12th, 2007


There were few my bugs (ex: byte order in network addresses)
and a misunderstanding how to properly preallocate and re-use of IRPs.

Bugs corrected.
IRP pre-allocation and re-use I replaced with WorkItem creation for IRP
full allocation.
Works. (Probably there is a better solution for hadling reconnects).

Thank you.
Sometimes silece is a best answer. :-)



Similar Posts