locked
How to retrieve the IPv6 configration is DHCP or not? And DNS is automatice or manual? RRS feed

  • Question

  • Is there anybody can help me?

    I find the API GetAdaptersAddresses() can retrieves the addresses associated with the adapters on the local computer.

    But I don't find any parameter indicates the ip configration is DHCP.

    I wanna know :

    How to retrieve which item is checked in “Obtain an IPv6 address automatically” and “Use the following IPv6 address”?

    And how to retrieve which item is checked in “Obtain DNS server address automatically” and “Use the following DNS server addresses”?



     

    • Moved by Helen Zhao Monday, July 16, 2012 4:10 AM (From:Visual C++ MFC and ATL)
    Monday, July 9, 2012 2:57 PM

All replies

  • On 7/9/2012 10:57 AM, Weason Lin wrote:

    I find the API GetAdaptersAddresses() can retrieves the addresses associated with the adapters on the local computer.

    But I don't find any parameter indicates the ip configration is DHCP.

    See GetAdaptersInfo, in particular IP_ADAPTER_INFO::DhcpEnabled.


    Igor Tandetnik

    Monday, July 9, 2012 4:32 PM
  • Thanks for your answer, but GetAdapersInfo only can retrieve the IPv4 settings, I wanna know the settings of IPv6.

    Is there any other method?



    Weason Lin Best Regards.

    Tuesday, July 10, 2012 2:43 AM
  • Weason Lin wrote:

    Thanks for your answer, but GetAdapersInfo only can retrieve the IPv4  settings, I wanna know the settings of IPv6.

    Right. GetAdapersInfo is deprecated in favor of GetAdaptersAddresses,  which does support IPv6.


    Igor Tandetnik

    • Proposed as answer by Helen Zhao Monday, July 16, 2012 2:34 AM
    Tuesday, July 10, 2012 3:52 AM
  • So, I can't get what I want by GetAdapersInfo.

    Do you know any other API can retrieve the settings?


    Weason Lin Best Regards.

    Tuesday, July 10, 2012 11:42 AM
  • Weason Lin wrote:

    So, I can't get what I want by GetAdapersInfo.

    Do you know any other API can retrieve the settings?

    Which part of "GetAdaptersAddresses" did you find unclear?


    Igor Tandetnik

    Tuesday, July 10, 2012 11:47 AM
  • Which parameter indicates “Obtain an IPv6 address automatically” is checked?

    Which parameter indicates “Obtain DNS server address automatically” is checked?


    Weason Lin Best Regards.

    Tuesday, July 10, 2012 4:30 PM
  • On 7/10/2012 12:30 PM, Weason Lin wrote:

    Which parameter indicates “Obtain an IPv6 address automatically” is checked?

    Which parameter indicates “Obtain DNS server address automatically” is checked?

    IP_ADAPTER_DHCP_ENABLED and IP_ADAPTER_DDNS_ENABLED flags in IP_ADAPTER_ADDRESSES::Flags, I would imagine.


    Igor Tandetnik

    Tuesday, July 10, 2012 5:39 PM
  • I do these bellow, even the “Obtain an IPv6 address automatically” and “Obtain DNS server address automatically”  are selected, the IP_ADAPTER_ADDRESSES::Flags 
    parameter don't include IP_ADAPTER_DHCP_ENABLED and IP_ADAPTER_DDNS_ENABLED. 
    Is there anything wrong?

    Step1. Set the parameter of GetAdaptersAddresses as bellow:
                        Family: AF_INET6, 
                        Flags: GAA_FLAG_INCLUDE_GATEWAYS | GAA_FLAG_INCLUDE_PREFIX, 
                        SizePointer : 15000, 
                        AdapterAddresses: pAddresses,
    Step2. If the GetAdaptersAddresses returns NO_ERROR, use pAddresses->AdapterName to find the specified adapter.

    Weason Lin Best Regards.

    Wednesday, July 11, 2012 2:40 AM
  • #define ADAPTER_ADDRESSES_SIZE 15000
    #define     MAX_TRIS 3
    #define MAALOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
    #define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
             PIP_ADAPTER_ADDRESSES pAddresses = NULL;
             PIP_ADAPTER_UNICAST_ADDRESS pUnicaseAddress = NULL;
             PIP_ADAPTER_GATEWAY_ADDRESS pGatewayAddress = NULL;
             PIP_ADAPTER_DNS_SERVER_ADDRESS pDNSAddress = NULL;
             ULONG ulAddressSize = ADAPTER_ADDRESSES_SIZE;
             ULONG ulRetVal = 0;
             int i = 0;
             do 
             {
                       pAddresses = (IP_ADAPTER_ADDRESSES*)MAALOC(ulAddressSize);
                       if (NULL == pAddresses)
                       {
                                return;
                       }
                       ulRetVal = GetAdaptersAddresses(AF_INET6, GAA_FLAG_INCLUDE_GATEWAYS | GAA_FLAG_INCLUDE_PREFIX, NULL, pAddresses, &ulAddressSize);
                       if (ERROR_BUFFER_OVERFLOW == ulRetVal)
                       {
                                FREE(pAddresses);
                                pAddresses = NULL;
                       }
                       else
                       {
                                break;
                       }
                       i++;
             } while ((ERROR_BUFFER_OVERFLOW == ulRetVal) && (i < MAX_TRIS));
    
             if (NO_ERROR == ulRetVal)
             {
                       while (pAddresses)
                       {
                                CString strAdapterGuid(pAddresses->AdapterName);
                                if (strGuid.CompareNoCase(strAdapterGuid))
                                {
                                         pAddresses  = pAddresses->Next;
                                         continue;
                                }
                                //get ipv6 address
                                pUnicaseAddress = pAddresses->FirstUnicastAddress;
                                //get first DNS
                                pDNSAddress = pAddresses->FirstDnsServerAddress;
                       }
             }



    Weason Lin Best Regards.

    Wednesday, July 11, 2012 2:45 AM
  • Hi Weason Lin,

    According to your description, I'd like to move this thread to "Windows Desktop Winsock Kernel (WSK) Forum" for more efficient responses.

    Thanks for your understanding.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 16, 2012 4:10 AM