Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

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
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zinetdll |
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yinetdll |
SYNOPSIS
#include <netdb.h>
unsigned int if_nametoindex(
const char *ifname);
PARAMETERS
ifname Specifies the name of the interface (subnet) to be mapped to an index number.
The name specified cannot be larger than IFNAMSIZ, as defined in the if.h
header file.
DESCRIPTION
When an interface (subnet) is created, it is assigned a unique number called an interface index.
The interface index identifies 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
specified 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 specified 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 specified by the ifindex parame-
ter.
412 Hewlett-Packard Company 527187-017