HPlogo HP-UX IPv6 Porting Guide: HP-UX 11i v2 September 2004 > Chapter 12  Identifying Local Interface Names and Indexes

Returning All Interface Names and Indexes

» 

Technical documentation

Complete book in PDF

 » Table of Contents

The if_nameindex structure holds the information about a single interface. The definition of the structure is in the <net/if.h> header file.

struct if_nameindex {
unsigned int if_index; /* 1, 2, ... */
char *if_name; /* null terminated name: "le0", .. */
};

The final function returns an array of if_nameindex structures, returning one structure per interface.

struct if_nameindex  *if_nameindex(void);

The if_nameindex function signals the end of the array of structures by returning a structure with a zero if_index value and a NULL if_name value. If an error occurred, the function returns a NULL pointer, and sets errno to the appropriate value.

The if_nameindex() function acquires memory dynamically for the array of if_nameindex structures and for if_name’s interface names. The if_freenameindex() function frees that memory.

© 2004 Hewlett-Packard Development Company, L.P.