Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

if_nameindex() - list of interface names with the associated interface indexes

&pagelevel(3)&pagelevel

#include <net.if.h>

struct * if_nameindex if_nameindex(void);


Description

The function if_nameindex() generates an array consisting of the interface names and the associated interface index.

For each interface present, an if_nameindex structure is created.
The if_nameindex structure is declared in b<net.if.h> as follows:

struct if_nameindex {
   unsigned int       if_index;       /*1, 2, .....*/
   char *             if_name;        /* name terminated with null byte*/
};

Return value

An array with structures of type if_nameindex is returned as the result. The end of the array is indicated by the fact that the last if_nameindex structure contains the values 0 for if_index and NULL for if_name.

If an error occurs then a NULL pointer is returned and errno is set accordingly

Errors indicated by errno

EINVAL

No interface information is available

Note

The storage required for the array is requested dynamically and must be released again using the function if_freenameindex().