Jump to main content

##

# TCPIP_STACK_NetIPv6AddressGet Function

## C

    IPV6_ADDR_HANDLE TCPIP_STACK_NetIPv6AddressGet(
        TCPIP_NET_HANDLE netH,
        IPV6_ADDR_TYPE addType,
        IPV6_ADDR_STRUCT* pAddStruct,
        IPV6_ADDR_HANDLE addHandle
    );

## Description

This function allows the listing of the IPv6 addresses associated with an interface.

## Preconditions

The TCPIP_STACK_Initialize() function must have been called before calling this function. The network interface should be up and running.

## Parameters

Parameters | Description
--- | ---
netH | Interface handle to set the address of.
addType | Type of address to request. IPV6_ADDR_TYPE_UNICAST and IPV6_ADDR_TYPE_MULTICAST supported for now.
pAddStruct | Structure provided by the user that will be filled with corresponding IPV6_ADDR_STRUCT data.
addHandle | An address handle that allows iteration across multiple IPv6 addresses. On the first call, it has to be 0; It will begin the listing of the IPv6 addresses. On subsequent calls, it has to be a handle previously returned by a call to this function.

## Returns

- Non-NULL IPV6_ADDR_HANDLE - If a valid IPv6 address was found and the pAddStruct structure was filled with data.
- 0 - If no such interface or interface is not enabled.

## Remarks

None.

## Example

    IPV6_ADDR_STRUCT currAddr;
    IPV6_ADDR_HANDLE currHandle;
    TCPIP_NET_HANDLE hNet = TCPIP_STACK_NetHandleGet("PIC32INT");
    char    ipv6AddBuff[44];

    currHandle = 0;
    do
    {
        currHandle = TCPIP_STACK_NetIPv6AddressGet(netH, IPV6_ADDR_TYPE_UNICAST, &currAddr, currHandle);
        if(currHandle)
        {   // have a valid address; display it
            TCPIP_HELPER_IPv6AddressToString(&currAddr.address, ipv6AddBuff, sizeof(ipv6AddBuff));
        }
    }while(currHandle != 0);