Each network interface has a name. This usually consists of a few
letters that relate to the type of interface, which may be followed by a
number if there is more than one interface of that type. Examples
might be lo
(the loopback interface) and eth0
(the first
Ethernet interface).
Although such names are convenient for humans, it would be clumsy to have to use them whenever a program needs to refer to an interface. In such situations an interface is referred to by its index, which is an arbitrarily-assigned small positive integer.
The following functions, constants and data types are declared in the header file `net/if.h'.
ifname
, which
must be at least IFNAMSIZ
bytes in length. If the index was
invalid, the function's return value is a null pointer, otherwise it is
ifname
.
unsigned int if_index;
char *if_name
if_nameindex
structures, one
for every interface that is present. The end of the list is indicated
by a structure with an interface of 0 and a null name pointer. If an
error occurs, this function returns a null pointer.
The returned structure must be freed with if_freenameindex
after
use.
if_nameindex
.
Go to the first, previous, next, last section, table of contents.