MSDN Documentation

IP_ADAPTER_ADDRESSES Structure

The IP_ADAPTER_ADDRESSES structure contains information about an adapter on the local computer. It is used with the GetAdaptersAddresses function to retrieve comprehensive details about network interfaces.

Header

#include <iphlpapi.h>

Library

Iphlpapi.lib

Syntax

typedef struct _IP_ADAPTER_ADDRESSES {
    ULONG                 Length;
    DWORD                 IfIndex;
    struct _IP_ADAPTER_ADDRESSES *Next;
    PWCHAR                AdapterName;
    PWCHAR                Description;
    UINT                  PhysicalAddressLength;
    BYTE                  PhysicalAddress[8];
    UINT                  Flags;
    DWORD                 Mtu;
    DWORD                 IfType;
    IF_OPER_STATUS        OperStatus;
    DWORD                 Ipv6IfIndex;
    DWORD                 ZoneIndices[16];
    PIP_ADAPTER_PREFIX    FirstPrefix;
    // ... (additional members omitted for brevity)
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;

Members

MemberTypeDescription
LengthULONGSize of the structure, in bytes.
IfIndexDWORDInterface index used to identify the adapter.
Nextstruct _IP_ADAPTER_ADDRESSES*Pointer to the next adapter in the list.
AdapterNamePWCHARNetwork adapter name (e.g., Ethernet0).
DescriptionPWCHARHuman‑readable description of the adapter.
PhysicalAddressLengthUINTLength, in bytes, of the physical address.
PhysicalAddressBYTE[8]MAC address of the adapter.
FlagsUINTAdapter flags (e.g., IP_ADAPTER_IPV4_ENABLED).
MtuDWORDMaximum Transmission Unit size.
IfTypeDWORDNetwork interface type (e.g., IF_TYPE_ETHERNET_CSMACD).
OperStatusIF_OPER_STATUSOperational status of the interface.
Ipv6IfIndexDWORDIPv6 interface index.
ZoneIndicesDWORD[16]Per‑zone IPv6 interface indices.
FirstPrefixPIP_ADAPTER_PREFIXPointer to the list of IPv4/IPv6 prefixes.

Example

The following C example retrieves all adapters and prints basic information.

#include <stdio.h>
#include <windows.h>
#include <iphlpapi.h>
#pragma comment(lib, "iphlpapi.lib")

int main() {
    ULONG outBufLen = 15000;
    PIP_ADAPTER_ADDRESSES pAddresses = NULL;
    DWORD dwRetVal = 0;

    pAddresses = (IP_ADAPTER_ADDRESSES *) malloc(outBufLen);
    if (pAddresses == NULL) {
        printf("Memory allocation failed.\n");
        return 1;
    }

    dwRetVal = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX,
                                    NULL, pAddresses, &outBufLen);

    if (dwRetVal == NO_ERROR) {
        PIP_ADAPTER_ADDRESSES pCurr = pAddresses;
        while (pCurr) {
            printf("\nAdapter Name: %ws\n", pCurr->AdapterName);
            printf("Description : %ws\n", pCurr->Description);
            printf("IfIndex     : %u\n", pCurr->IfIndex);
            printf("OperStatus  : %u\n", pCurr->OperStatus);
            pCurr = pCurr->Next;
        }
    } else {
        printf("GetAdaptersAddresses failed with error: %u\n", dwRetVal);
    }

    if (pAddresses) free(pAddresses);
    return 0;
}

Related Functions