#include <net/if.h> struct if_nameindex *if_nameindex(void);Service Program Name: QSOSRV2
The if_nameindex() function returns an array of if_nameindex structures, one structure per interface. The end of the array of structures is indicated by a structure with an if_index of 0 and an if_name of NULL.
None.
No authorization is required.
if_nameindex() returns a pointer to an array of if_nameindex structures. Possible values are:
The structure struct if_nameindex is defined in <net/if.h>.
struct if_nameindex { unsigned int if_index; /* 1, 2, ... */ char *if_name; /* null terminated line name */ };
When if_nameindex() fails, errno can be set to one of the following:
See Code disclaimer information for information pertaining to code examples.
The following example shows how if_nameindex() is used:
#include <net/if.h> #include <sys/types.h> #include <errno.h> void main() { struct if_nameindex *interfaceArray = NULL; interfaceArray = if_nameindex(void); /* retrieve the current interfaces */ if (interfaceArray != NULL) { ... if_freenameindex(interfaceArray); /* free the dynamic memory */ interfaceArray = NULL; /* prevent use after free */ } else { printf("if_nameindex() failed with errno = %d %s \n", errno,strerror(errno)); return; } ... }
Top | UNIX-Type APIs | APIs by category |