Re:TDI filter : ConnectionContext

Hi All,

Please read the original query (if you havn't read it) (attached below)
before this one.

After analyzing the processing done by TCP for ConnectionContext passed by
ClientEventConnect, it is found that TCP maintains the list of handles in a
table passed by a TCP client in EaBuffer at position (EaBuffer->EaName +
EaBuffer->EaNameLength + 1) at the time of creation of Connection Object.
When the TCP client accepts a connection through ClientEventConnect handler
and pass down a *ConnectionContext pointer, TCP verifies the existence of
this pointer in its table.
If the two context pointers are different, TCP fails the accept irp with
status 0xC000023a (Invalid Connection object).

Although as per DDK :

ClientEventConnect()

"ConnectionContext :
Pointer to a caller?supplied variable in which ClientEventConnect returns a
pointer to the client's context area in which it maintains client-determined
state for this connection endpoint. Usually, the specified address is
identical to the value that the client set for the value at EaBuffer when it
originally called ZwCreateFile to open the local connection endpoint. "

Here it is said that USUALLY the two pointers are same,,,that means the two
context pointers can be different also.

Then why TCP fails my AcceptIrp if I don't pass the same value as
EaBuffer->EaValue (passed by upper driver at the time of Connection object
creation).

Is it not documented properly or my understanding is incorrect.

Hope somebody will be able to put some light on this......USUALLY people
here talks about very general stuff about TCP, which is USUALLY very well
documented.

Regards
Vijender

-----Original Message-----
From: Vijender Yadav [mailto:xxxxx@nodeinfotech.com]
Sent: Tuesday, August 24, 2004 2:15 PM
To: Windows System Software Devs Interest List
Subject: TDI filter : ConnectionContext

Hi All,

I am building a TDI filter driver. I have hooked all the event handlers.

My requirement is : When the ClientEventConnect routine is called,
I call the original connect handler and store the ConnectionContext passed
by upper driver in a data-structure.
Then I set the ConnectionContext to that data-structures (allocated from
Non-Paged pool).
I use the same irp passed by upper driver and pass it to TCP after replacing
the completion routine.

The problem I am facing is , tcp fails to accept the connection and call the
hooked accpet-irp-completion routine with status 0xC000023a.

If I don't change the ConnectionContext pointer, the connection is accepted
and accept irp is completed successfully.

As per DDK and my understanding, the (*ConnectionContext) can be set to any
value (used and understood only by my driver). TCP should not be bothered
about the contents.

Please let me know the cause. (Code snippet (ClientEventConnect) is
attached)

////////////////////////////////////////////////////////////////////////////

....
INFO_FORMAT(("Calling User connect event handler 0x%x with context
0x%x.\n",
pFltContext->m_pOrgTdiEventHandler,
pFltContext->m_pOrgTdiEventContext));

status = ((PTDI_IND_CONNECT)pFltContext->m_pOrgTdiEventHandler)(
pFltContext->m_pOrgTdiEventContext,
RemoteAddressLength,
RemoteAddress,
UserDataLength,
UserData,
OptionsLength,
Options,
&pConnContext,
AcceptIrp);
if(STATUS_MORE_PROCESSING_REQUIRED == status && *AcceptIrp)
{
.....
pConnEntry->m_ConnInfo.m_pUserConnectionContext = pConnContext;

pConnContext = (CONNECTION_CONTEXT)pConnEntry;

// Replace user connection context with ours.
*ConnectionContext = pConnContext;
}
......

////////////////////////////////////////////////////////////////////////////

Let me know if any explaination are required.

regards
Vijender