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.