HP-UX IPv6 Porting Guide (September 2004)

Table Of Contents
Identifying Local Interface Names and Indexes
Name-to-Index
Chapter 1252
On HP-UX implementations, when the system configures an interface, the kernel assigns a
unique positive integer value (called the interface index) to that interface. These small
positive integers start at one. Interface numbering is not necessarily contiguous.
This API defines:
two functions that map between an interface name and index:
if_nametoindex()
if_indextoname()
a function that returns all interface names and indexes:
if_nameindex()
a function to return the dynamic memory allocated by the previous function:
if_freenameindex()
Name-to-Index
The first function maps an interface name into its corresponding index.
Header Files
#include <net/if.h>
Syntax
unsigned int if_nametoindex(const char *ifname);
If the specified interface name does not exist, the function returns a value of zero, and sets
errno to ENXIO. If a system error occurred (such as running out of memory), the function
returns a value of zero and sets errno to the proper value (such as ENOMEM).