TCP/IP Programming Manual
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
name^ptr = if_indextoname(ifindex, char *ifname);
INT(32) name^ptr;
INT(32) ifindex;
STRING .EXT ifname;
name^ptr
return value; a pointer to the interface name string. If there is no interface corresponding to
the specified index, NULL is returned, and error is as described in Errors (page 132).
ifindex
input value; specifies the index to be mapped to an interface name.
ifname
input value; specifies the buffer to receive the mapped name. The buffer must be at least
IF_NAMESIZE bytes long; IF_NAMESIZE is defined in the header file in.h.
Errors
Upon successful completion, this function returns a pointer to the character string buffer containing
the mapped name. Otherwise, this function returns NULL and errno is set to indicate the following
errors.
An invalid argument was specified.EINVAL
Either no memory is available to complete the request or a system error occurred.ENOMEM
No interface corresponds to the index specified by the ifindex parameter.ENXIO
Usage Guidelines
When an interface (subnet) is created, that interface 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_indextoname function is one of four functions used to manage interface indexes.
Examples
cp = if_indextoname(if_index, sn);
if (cp==NULL){
perror("No interface name matching interface index");
exit(1);
}
if_nameindex
The if_nameindex function gets all interface names and indexes. This function returns a pointer
to an array of if_nameindex structures. See if_nameindex (page 132) for a definition of the
if_nameindex structure. (This function is supported for NonStop TCP/IPv6 only.)
NOTE: The C synopsis is given in ANSI C format rather than the pre-ANSI C formats of the other
library routines because the only NonStop servers you can use these routines on all support ANSI
C. (ANSI C format defines the function and the arguments in the same line rather than using an
assign statement and defining the arguments underneath.)
C Synopsis
132 Library Routines