Returns an array of all interface names and indexes.
Format
#include <if.h>
struct if_nameindex *if_nameindex ( void );
1 – Description
This function dynamically allocates memory for an array of
if_nameindex structures, one structure for each interface. A
structure with an if_index value of 0 and a NULL if_name value
indicates the end of the array.
The following if_nameindex structure must also be defined
by including the IF.H header file prior to the call to if_
nameindex():
struct if_nameindex {
unsigned int if_index;
char *if_name;
};
To free the memory allocated by this function, use the if_
freenameindex() function. If an error occurs, the function
returns a NULL pointer and sets errno to an appropriate value.
2 – Return Values
NULL Indicates an error; errno is set to an
appropriate value.