Hello,
I have to write TDI driver to serve TCP connection from ring-0.
And after careful reading MSDN, DDK and this mail list still could not
understand some very simple things.
My way of connection establishment.
- Open transport using address 0L:wPort.
- Open connection end-point.
- Associate address from p.1 with connection end-point from p.2
3X. Optional Open transport using address 192.168.1.9:wPort. Local
address of server. - Setup ClientConnectEvent function
- Wait for connection.
- Receive connection request in
ClientConnectEvent(…)
{
…
a) IoAllocateIrp
b) build TDI_CONNECTION_INFORMATION AcceptRequestInfo using Ip and
Port of remote node requesting connection
c) TdiBuildAccept(
Irp/*from 6a*/,
DevObj/*from 1*/,
TdiAcceptCompeteFunction/* IoCompetionProc*/,
AcceptRequestInfo/*from 6b*/,
NULL)
d) IoSetNextIrpStackLocation(pIrp)
e) filling up parameters of ClientConnectEvent
- ConnectionContext with eaBuffer from p.1
- Irp from 6a, 6c
g) return STATUS_MORE_PROCESSING_REQUIRED
}
TdiAcceptComplete(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
{
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
If I exec step 3x then step 6 repeats three times.
In TdiAcceptComplete I have IoStatusBlock.Status :
STATUS_CONNECTION_INVALID=0xC000023AL. Of course remote node cannot
establish link with server.
So, questions:
- What I’m doing wrong?
- Where should I get new(if any)FileObject to be used later with
TDI_SEND? - How to modify algorithm to have few established connections?
- How to serve disconnect gracefully?
–
Best regards,
Sergey mailto:kipnis@wp.pl