• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1143
  • Last Modified:

IOCTL fo IPv6 address for local interface

I am getting the local interface IP address using following code:

IPAddrEntry *ipaddrentry;
TCP_REQUEST_QUERY_INFORMATION_EX req;

req.ID.toi_entity.tei_entity = GENERIC_ENTITY;
req.ID.toi_entity.tei_instance = 0;
req.ID.toi_class = INFO_CLASS_GENERIC;
req.ID.toi_type = INFO_TYPE_PROVIDER;
req.ID.toi_id = IP_MIB_ADDRTABLE_ENTRY_ID;



if( !DeviceIoControl( TCPDriverHandle, // Handle to TCP driver
IOCTL_TCP_QUERY_INFORMATION_EX, // Cmd code
&req, // Pointer to input buffer
sizeof(req), // Size of ipt buffer
ipaddrentry, // Ptr to output buffer
bufferLen, // Size of output buffer
&arrayLen, // Actual size of array
NULL ) )

This code only fetches the IPv4 address.

I am looking for a way to determine:

Whether IPv6 is enabled on that interface
and if so, then get the IPv6 address in the similar way.
0
devkathuria
Asked:
devkathuria
1 Solution
 
jkrCommented:
You'd just use the IP Helper API (http://msdn2.microsoft.com/en-us/library/aa366073.aspx) for that purpose and 'GetAdaptersAddresses()' (http://msdn2.microsoft.com/en-us/library/aa365915.aspx) in particular, e.g.

IP_ADAPTER_ADDRESSES iaa;
ULONG ulSize;

ULONG ulRes = GetAdaptersAddresses(AF_INET6,0,&iaa,&ulSize);

If IPv6 is not enabled, you'll get an error indicating that.

See also http://msdn2.microsoft.com/en-us/library/aa365819.aspx ("Complete IP Helper Application Source Code")
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now