if_indextoname() — Map a network interface index to its corresponding name

Standards

Standards / Extensions C or C++ Dependencies

RFC2553
Single UNIX Specification, Version 3

both z/OS V1R4

Format

#define _OPEN_SYS_SOCK_IPV6
#include <net/if.h>

char *if_indextoname(unsigned int ifindex, char *ifname);
SUSV3:
#define _POSIX_C_SOURCE 200112L
#include <net/if.h>

char *if_indextoname(unsigned int ifindex, char *ifname);

General description

The if_indextoname() function maps an interface index to its corresponding interface name. When this function is called, ifname must point to a buffer of at least IF_NAMESIZE bytes into which the interface name corresponding to interface index ifindex is returned. Otherwise, the function shall return a NULL pointer and set errno to indicate the error.

Returned value

Error Code
Description
EINVAL
The ifindex parameter was zero, or the ifname parameter was NULL, or both.
ENOMEM
Insufficient storage is available to obtain the information for the interface name.
ENXIO
The ifindex does not yield an interface name.