if_nametoindex() — Map a network interface name to its corresponding index
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
RFC2553 |
both | z/OS® V1R4 |
Format
#define _OPEN_SYS_SOCK_IPV6
#include <net/if.h>
unsigned int if_nametoindex(const char *ifname);
SUSV3:
#define _POSIX_C_SOURCE 200112L
#include <net/if.h>
unsigned int if_nametoindex(const char *ifname);
General description
The if_nametoindex() function returns the interface index corresponding to the interface name ifname.
Returned value
When successful, if_nametoindex() returns the interface index corresponding to the interface name ifname. Upon failure, if_nametoindex() returns zero and sets errno to one of the following:
- Error Code
- Description
- EINVAL
- Non-valid parameter was specified. The ifname parameter was NULL.
- ENOMEM
- Insufficient storage is available to obtain the information for the interface name.
- ENXIO
- The specified interface name provided in the ifname parameter does not exist.