Open System Services Library Calls Reference Manual (G06.27+, H06.04+)

if_nametoindex(3) OSS Library Calls Reference Manual
NAME
if_nametoindex - Maps an interface name to its corresponding index
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
H-series OSS processes: /G/system/zdllnnn/zinetdll
SYNOPSIS
#include <netdb.h>
unsigned int if_nametoindex(
const char *ifname);
PARAMETERS
ifname Species the name of the interface (subnet) to be mapped to an index number.
The name specied cannot be larger than IFNAMSIZ,asdened in the if.h
header le.
DESCRIPTION
When an interface (subnet) is created, it is assigned a unique number called an interface index.
The interface index identies the interface used to send or receive multicast datagrams.
Interface index numbers start with 1.
The if_nametoindex() function is one of four functions used to manage interface indexes.
EXAMPLES
.
.
.
if_index = if_nametoindex(&subnetname);
if (if_index <= 0){
perror("Interface name not found");
exit(1);
}
.
.
.
RETURN VALUES
Upon successful completion, if_nametoindex() returns the interface index corresponding to the
specied interface name. Otherwise, this function returns 0 (zero).
ERRORS
If any of these conditions occurs, the function sets errno to the corresponding value:
[EINVAL] A value specied for a parameter is not recognized or inapplicable.
[ENOMEM] Either no memory is available to complete the request or a system error
occurred.
[ENXIO] There is no interface corresponding to the index specied by the index parame-
ter.
412 Hewlett-Packard Company 527187-004