Finding static IP address for an interface

Within my Ndis 6 MUX driver on Win7 I need to find the static IP address (i.e. created by Ipv4 property page) for an interface. Using GetUnicastIpAddressTable() I get a list in numeric order of all IP addresses even the ones that are created by usermode applications. Is there some way to get the static IP address?

Larry C

Even the IPv4 property page can specify multiple static IPv4 addresses.

What would you do in that case (assuming you could fetch the
information…)?

I think that you may have to devise a way to live with the list you have
fetched.

Thomas F. Divine


From:
Sent: Wednesday, May 12, 2010 4:13 PM
To: “Windows System Software Devs Interest List”
Subject: [ntdev] Finding static IP address for an interface

> Within my Ndis 6 MUX driver on Win7 I need to find the static IP address
> (i.e. created by Ipv4 property page) for an interface. Using
> GetUnicastIpAddressTable() I get a list in numeric order of all IP
> addresses even the ones that are created by usermode applications. Is
> there some way to get the static IP address?
>
> Larry C
>
> —
> 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

We do have certain rules as to not deleting the first created IP address from the IPv4 property page, but others could be added. In NDIS 5, XP/s2003, the OID_GEN_NETWORK_LAYER_ADDRESSES passed in the IP addresses in order of creation so we used the first one. OID_GEN_NETWORK_LAYER_ADDRESSES is scambled on Vista/s2008/Win7 and is useless for trying to get the IPs, that’s why I use GetUnicastIpAddressTable().

I have found that \REGISTRY\MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"mux GUID" does have a list at ‘IPAddess’ that contains just the static IP addresses in creation order, but no temperary IPs. I now have a combination of the two to get all IPs.

I was hoping that the IP Helper Functions had an api to use instead of hitting the registry.

Larry C

Larry,

I thought that MIB_IPADDRROW::wType distinguished just what you want to
know.

MIB_IPADDR_DYNAMIC -> DHCP
MIB_IPADDR_TRANSIENT -> Added by somebody

So (0 == (wType & (MIB_IPADDR_DYNAMIC|MIB_IPADDR_TRANSIENT))) might be what
you are looking for. And MIB_IPADDR_PRIMARY would be ‘the first’ static IP
address.

Of course you have to digest GetIpAddrTable() and do the lifting to
correlate to your IfIndex.

And how is the OID_GEN_NETWORK_LAYER_ADDRESSES scrambled on NT6? I don’t
recall seeing that (but then again, I have not looked specifically). Is
your MP edge NT6 or NT5?

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@honeywell.com
Sent: Wednesday, May 12, 2010 5:08 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Finding static IP address for an interface

We do have certain rules as to not deleting the first created IP address
from the IPv4 property page, but others could be added. In NDIS 5, XP/s2003,
the OID_GEN_NETWORK_LAYER_ADDRESSES passed in the IP addresses in order of
creation so we used the first one. OID_GEN_NETWORK_LAYER_ADDRESSES is
scambled on Vista/s2008/Win7 and is useless for trying to get the IPs,
that’s why I use GetUnicastIpAddressTable().

I have found that
\REGISTRY\MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfa
ces"mux GUID" does have a list at ‘IPAddess’ that contains just the static
IP addresses in creation order, but no temperary IPs. I now have a
combination of the two to get all IPs.

I was hoping that the IP Helper Functions had an api to use instead of
hitting the registry.

Larry C


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

David,

Isn’t GetIpAddrTable() a usermode api? I need this in my driver, currently I use GetUnicastIpAddressTable() and there is no ‘wType’ in MIB_UNICASTIPADDRESS_ROW.

When there are more than one IP address on an interface the NETWORK_ADDRESS structures overlap within the list making them un-usable.

The MP is Ndis 6.

Larry C

On Vista and later there is a kernel version of the IP Helper API. Almost
identical API.

Search for “IP Helper” in the WDK Help.

Thomas F. Divine


From:
Sent: Monday, May 17, 2010 12:21 PM
To: “Windows System Software Devs Interest List”
Subject: RE:[ntdev] Finding static IP address for an interface

> David,
>
> Isn’t GetIpAddrTable() a usermode api? I need this in my driver, currently
> I use GetUnicastIpAddressTable() and there is no ‘wType’ in
> MIB_UNICASTIPADDRESS_ROW.
>
> When there are more than one IP address on an interface the
> NETWORK_ADDRESS structures overlap within the list making them un-usable.
>
> The MP is Ndis 6.
>
> Larry C
>
>
>
> —
> 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

Larry,

Any chance that MIB_UNICASTADDRESS_ROW::SuffixOrigin can be used in lieu of
wType?

Thanks for the tip on what to look for on OID_GEN_NETWORK_LAYER_ADDRESSES.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@honeywell.com
Sent: Monday, May 17, 2010 12:22 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Finding static IP address for an interface

David,

Isn’t GetIpAddrTable() a usermode api? I need this in my driver, currently I
use GetUnicastIpAddressTable() and there is no ‘wType’ in
MIB_UNICASTIPADDRESS_ROW.

When there are more than one IP address on an interface the NETWORK_ADDRESS
structures overlap within the list making them un-usable.

The MP is Ndis 6.

Larry C


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

Thomas,

The only api in the kernel IP Helper functions that returns similar information is the GetUnicastIpAddressTable() function and there is no wType.

Larry C

David,

That provides some of the information I need but not all. I need to know which IP addresses are static. I do not want to use a temporary IP for the packets that my driver sends out. The temporary IP addresses are usually ‘floating IP addresses’ between two redundant nodes. If the driver uses a temporary IP that floats to another node the IP will be flagged as duplicate on the node that tries to add the IP.

Larry C

I see that IP_ADAPTER_UNICAST_ADDRESS::Flags bit
IP_ADAPTER_ADDRESS_TRANSIENT is possibly what you want to know. I don’t see
a way to get that out of the KMode IPHLP/NETIO either. What a PITA!

Sorry I was no help.

Regards,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@honeywell.com
Sent: Monday, May 17, 2010 2:26 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Finding static IP address for an interface

David,

That provides some of the information I need but not all. I need to know
which IP addresses are static. I do not want to use a temporary IP for the
packets that my driver sends out. The temporary IP addresses are usually
‘floating IP addresses’ between two redundant nodes. If the driver uses a
temporary IP that floats to another node the IP will be flagged as duplicate
on the node that tries to add the IP.

Larry C


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

Thanks for trying.

Larry C