#include <net/if.h> char *if_indextoname(unsigned int ifindex, char *ifname);Service Program Name: QSOSRV2
The if_indextoname() function places the name of the interface with index ifindex into the buffer pointed at by ifname. When this function is called, ifname must point to a buffer of at least IFNAMSIZ bytes.
No authorization is required.
if_indextoname() returns a pointer to a null terminated string containing the interface (line description) name. Possible values are:
When if_indextoname() fails, errno can be set to one of the following:
The interface (line description) name stored at ifname will be returned in the default coded character set identifier (CCSID) currently in effect for the job. If this is not a single byte CCSID, then storage greater than IFNAMSIZ (16) bytes may be needed. 22 bytes is large enough for all CCSIDs.
It is important to note that the term "Interface" refers to the name on a line description (i.e. a physical interface) for this API. Other parts of the operating system, when refering to "Interface," mean an IP address.
See Code disclaimer information for information pertaining to code examples.
The following example shows how if_indextoname() is used:
#include <net/if.h> #include <sys/types.h> #include <errno.h> ref void main() { char interfaceName[IFNAMSIZ]; char *interface = if_indextoname(1, &interfaceName); /* retrieve the name of interface 1 */ if (interface == NULL) { printf("if_indextoname() failed with errno = %d %s \n", errno,strerror(errno)); return; } ... }
Top | UNIX-Type APIs | APIs by category |