However :), sometimes if you query source IP for UDP it works, sometime it
does not. Which means (for me, at least), this approach does not work in
general, as there is no 100% garantee you will get real results.
Querying an Address Object for the local address info and receiving 0.0.0.0
is still a correct result. It (INADDR_ANY) means that the transport will
choose a source IP address based on the outbound interface. The Address
Object is thus NOT bound to a local IP address (but likely is bound to a
specific Port in the case of UDP).
Unless one needs to perform some filtering operation on a ‘send’ which is
dependent on the interface, this is not typically an issue. If it is
really necessary to know what IP address is going to get selected then
lookup the best (outbound) interface based on the destination address
information in the TDI_SEND_DATAGRRAM request. The driver will need to have
a copy of the route table and other information to do so, of course. (Or
reverse engineer the IOCTLs from IPHLPAPI.DLL to TCPIP.SYS).
If you search back on this list you will find a (multiple?) discussions
regarding the querying of the local address/port information of a TDI
Connection File Object triggered from the Completion Routine of the
TDI_CONNECT (or TDI_ACCEPT) IRP. If you do not care about ‘inbound’
connections then you can ignore the Connect Event callback on the AO,
otherwise, you need to watch and filter any IRP passed back as an
‘acceptance’ of an inbound connection too.
On NT5 (2K3/XP/2K) the TCPIP.SYS Transport would complete a
TDI_QUERY_ADDRESS_INFO request synchronously and many TDI filters
incorrectly assumed this to always be the case. In NT6 (and in NT5 with
some *other* TDI filters) IoCallDriver() will return STATUS_PENDING. Be
sure to handle the asynchronous case correctly by having a non-threaded IRP
with a Completion Routine to handle the cleanup of the IRP and continuation
of the processing after the address has been queried. Assuming that
IoCallDriver() will return with STATUS_SUCCESS will result in an error.
Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Volodymyr M.
Shcherbyna
Sent: Wednesday, April 22, 2009 6:49 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI and Vista Problem
Hello,
could you please tell me how should i query the address after connection
has been initiated.
i am just clueless how to proceed!!
as in my previous post,
i was trying to set up a completion routine in the OpenConnection request.
when my completion routine gets called i was trying to query the address
with
TdiBuildQueryInformation(evt->qirp, dx->dev_lower, irps->FileObject,
crQueryAddressInfo, evt, TDI_QUERY_ADDRESS_INFO, mdl);
this fails and gives me
STATUS_ADDRESS_NOT_ASSOCIATED
If you take a typical sequence of events being taken before connection is
established, the following actions happen:
- Address Object A.O. is created via IRP_MJ_CREATE
- Connection Object (C.O.) is created via IRP_MJ_CREATE
- C.O. is associated with A.O. via IRP_MJ_INTERNAL_DEVICE_CONTROL with
TDI_ASSOCIATE_ADDRESS
- When C.O. and A.O. are associated, and connection is about to be made,
the TDI_CONNECT is issued
So, it seems like you were trying to get source IP before step 3 finished,
which is wrong. You may request source IP after TDI_CONNECT finished, i.e.,
for example, after completion routine of TDI_CONNECT IRP is called and
before TDI_DISCONNECT is issued for a particular C.O.
secondly you mentioned TDI is a wrong level for this. should i consider
using WFP if i want UDP support too?
My idea here is that, well, UDP stateless protocol, and usually TDI does not
have local address initialized for UDP A.O. (in TDI, the UDP are represented
as A.O.), just because this is not efficient: because one A.O. may be used
to send dg to multiple destinations, and source IP + Port pair might be
different, so, usually UDP source IP + Port is being picked up at NDIS layer
which is lower than TDI.
However :), sometimes if you query source IP for UDP it works, sometime it
does not. Which means (for me, at least), this approach does not work in
general, as there is no 100% garantee you will get real results.
–
Volodymyr M. Shcherbyna, blog: http://www.shcherbyna.com/
(This posting is provided “AS IS” with no warranties, and confers no
rights)
wrote in message news:xxxxx@ntdev…
> hello Volodymyr,
>
> thanks for your input,
> could you please tell me how should i query the address after connection
> has been initiated.
>
> i am just clueless how to proceed!!
> as in my previous post,
> i was trying to set up a completion routine in the OpenConnection request.
> when my completion routine gets called i was trying to query the address
> with
>
> TdiBuildQueryInformation(evt->qirp, dx->dev_lower, irps->FileObject,
> crQueryAddressInfo, evt, TDI_QUERY_ADDRESS_INFO, mdl);
>
> this fails and gives me
> STATUS_ADDRESS_NOT_ASSOCIATED
>
> how do i associate a address with Open connection request. it needs
> HANDLE in
> TdiBuildAssociateAddress
>
> or i am doing it completely wrong.
>
> could you please some lights as i am really new to TDI?
>
> secondly you mentioned TDI is a wrong level for this. should i consider
> using WFP if i want UDP support too?
>
>
> regards
> deep
>
>
>
>
>
>
>
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer