TCP/IP Programming Manual
index = if_nametoindex(ifname);
INT(32) index;
STRING .EXT ifname;
index
return value; upon successful completion, if_nametoindex returns the interface index
corresponding to the interface name specified in ifname. Otherwise, this function returns 0
(zero).
ifname
input value; points to a buffer that holds 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.
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_nametoindex function is one of four functions used to manage interface indexes.
Example
if_index = if_nametoindex(&subnetname);
if (if_index <= 0){
perror("Interface name not found");
exit(1);
}
inet_addr
The inet_addr function converts an address format from dotted-decimal format to binary format.
This call is for INET operations. For protocol-independent applications, see inet_pton (page 139).
C Synopsis
#include <netdb.h>
l_addr = inet_addr (addr_ptr);
unsigned long l_addr;
char *addr_ptr;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
l_addr := inet_addr (addr_ptr);
INT(32) l_addr ;
STRING .EXT addr_ptr;
l_addr
return value; the Internet address in binary format. This value is the return value. This address
can be copied directly into the structure sockaddr_in.
addr_ptr
input value; points to an Internet address in dotted-decimal format.
134 Library Routines