From: vitaly.vatnikov@compuware.com Sent: Sunday, June 17, 2001 9:00 PM To: NT Developers Interest List Subject: [ntdev] Re: Build Connection in ClientEventConnect in TDI Client I haven't looked thoroughly but your problem could be in the way you deal with the accept IRP. Try to build the IRP using TdiBuildAccept and pass the pointer to the irp to AcceptIrp output parameter, ie do NOT submit it to TDI using your TdiCall(). The transport driver will process this irp as "accept" when your return STATUS_MORE_PROCESSING_REQUIRED. Something like: TdiBuildAccept(pGlobalIrp,...); IoSetNextIrpStackLocation(pGlobalIrp) *AcceptIrp = pGlobalIrp; return STATUS_MORE_PROCESSING_REQUIRED; Good luck, - Vitaly On 06/15/01, "ivailo.todorov@atia.com" wrote: > Hi > > I have build two NT kernel-mode TDI Client Drivers; one acts as "server" > and another acts as "client". > > In "server", I register ClientEventConnect routine to receive connection > request. I preallocate IRP (TdiBuildAccept), in ClientEventConnect I > return this IRP, for TDI will use this IRP to accept the connection > request. In the IRP I set the "client"'s IP address and port. > > The "server" do receive the connection request, but after > ClientEventConnect return, the "client" report that the remote refused > the connection. > > > NTSTATUS > ClientEventConnect ( > IN PVOID TdiEventContext, > IN LONG RemoteAddressLength, > IN PVOID RemoteAddress, > IN LONG UserDataLength, > IN PVOID UserData, > IN LONG OptionsLength, > IN PVOID Options, > OUT CONNECTION_CONTEXT *ConnectionContext, > OUT PIRP *AcceptIrp > ) > { > NTSTATUS ntStatus = STATUS_UNSUCCESSFUL; > CONNECTION_CONTEXT connectContext; > PDEVICE_OBJECT deviceObject; > > IO_STATUS_BLOCK IoStatusBlock; > PTDI_CONNECTION_INFORMATION pConnectInfo = NULL; > TDI_CONNECTION_INFORMATION connectInfo; > > > KdPrint(( "Server: ClientEventConnect: Start! \n" )); > KdPrint(( "Server: remoteAddressLength = %u \n", RemoteAddressLength )); > > > connectContext = ExAllocatePool( NonPagedPool, sizeof( > TdiConnectionContext ) ); > > RtlCopyMemory ( connectContext, // copy transport name > TdiConnectionContext, > sizeof ( TdiConnectionContext ) ); > > ConnectionContext = &connectContext; > > AcceptIrp = &pGlobalIrp; > > > > pConnectInfo = (PTDI_CONNECTION_INFORMATION)ExAllocatePool ( // allocate > buffer > NonPagedPool, > sizeof ( TDI_CONNECTION_INFORMATION ) + > RemoteAddressLength ); > > if ( pConnectInfo ) // validate > pointer > { > RtlZeroMemory ( pConnectInfo, // clear > buffer > sizeof ( TDI_CONNECTION_INFORMATION ) + > RemoteAddressLength ); > > pConnectInfo->RemoteAddressLength = RemoteAddressLength; > > // pConnectInfo->RemoteAddress = (PUCHAR)pConnectInfo + sizeof ( > TDI_CONNECTION_INFORMATION ); > > pConnectInfo->RemoteAddress = (PTA_IP_ADDRESS)RemoteAddress; > > > connectInfo.RemoteAddressLength = RemoteAddressLength; > connectInfo.RemoteAddress = RemoteAddress; > > deviceObject = IoGetRelatedDeviceObject( connectObject ); > > > TdiBuildAccept( > pGlobalIrp, > deviceObject, > connectObject, > NULL, > NULL, > &connectInfo, > NULL //pReturnConnectInfo > ); > > > ntStatus = TdiCall( pGlobalIrp, deviceObject, &IoStatusBlock ); > > > > if ( pConnectInfo ) > ExFreePool( pConnectInfo ); > } > > if ( NT_SUCCESS( ntStatus ) ) > ntStatus = STATUS_MORE_PROCESSING_REQUIRED; > else > ntStatus = STATUS_CONNECTION_REFUSED; > > > KdPrint(( "TdiClient: ClientEventConnect: exit Status = 0x%X \n", ntStatus > )); > > return ( ntStatus ); > } > > > NTSTATUS > ClientEventConnect ( > IN PVOID TdiEventContext, > IN LONG RemoteAddressLength, > IN PVOID RemoteAddress, > IN LONG UserDataLength, > IN PVOID UserData, > IN LONG OptionsLength, > IN PVOID Options, > OUT CONNECTION_CONTEXT *ConnectionContext, > OUT PIRP *AcceptIrp > ) > { > NTSTATUS ntStatus = STATUS_UNSUCCESSFUL; > // WORK_QUEUE_ITEM WorkItem; > // CONNECT_INFO ConnectInfo; > CONNECTION_CONTEXT connectContext; > PDEVICE_OBJECT deviceObject; > > IO_STATUS_BLOCK IoStatusBlock; > PTDI_CONNECTION_INFORMATION pConnectInfo = NULL; > TDI_CONNECTION_INFORMATION connectInfo; > > > KdPrint(( "Server: ClientEventConnect: Start! \n" )); > KdPrint(( "Server: remoteAddressLength = %u \n", RemoteAddressLength )); > > > connectContext = ExAllocatePool( NonPagedPool, sizeof( > TdiConnectionContext ) ); > > RtlCopyMemory ( connectContext, // copy transport name > TdiConnectionContext, > sizeof ( TdiConnectionContext ) ); > > ConnectionContext = &connectContext; > > AcceptIrp = &pGlobalIrp; > > > > pConnectInfo = (PTDI_CONNECTION_INFORMATION)ExAllocatePool ( // allocate > buffer > NonPagedPool, > sizeof ( TDI_CONNECTION_INFORMATION ) + > RemoteAddressLength ); > > if ( pConnectInfo ) // validate > pointer > { > RtlZeroMemory ( pConnectInfo, // clear > buffer > sizeof ( TDI_CONNECTION_INFORMATION ) + > RemoteAddressLength ); > > pConnectInfo->RemoteAddressLength = RemoteAddressLength; > > // pConnectInfo->RemoteAddress = (PUCHAR)pConnectInfo + sizeof ( > TDI_CONNECTION_INFORMATION ); > > pConnectInfo->RemoteAddress = (PTA_IP_ADDRESS)RemoteAddress; > > > connectInfo.RemoteAddressLength = RemoteAddressLength; > connectInfo.RemoteAddress = RemoteAddress; > > // > // Get deviceObject from connectObject > // > deviceObject = IoGetRelatedDeviceObject( connectObject ); > > > TdiBuildAccept( > pGlobalIrp, > deviceObject, > connectObject, > NULL, > NULL, > &connectInfo, > NULL //pReturnConnectInfo > ); > > > ntStatus = TdiCall( pGlobalIrp, deviceObject, &IoStatusBlock ); > > > > if ( pConnectInfo ) > ExFreePool( pConnectInfo ); > } > > if ( NT_SUCCESS( ntStatus ) ) > ntStatus = STATUS_MORE_PROCESSING_REQUIRED; > else > ntStatus = STATUS_CONNECTION_REFUSED; > > > KdPrint(( "TdiClient: ClientEventConnect: exit Status = 0x%X \n", ntStatus > )); > > return ( STATUS_INSUFFICIENT_RESOURCES ); > } > > > > Please, send my sample! > Any suggestions are appreciated. > > Best Regards, > Ivaylo Todorov > > > --- > You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com > To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com --- You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com