if_nametoindex if_indextoname if_nameindex if_freenameindex - provide mappings between interface names and indexes
The
if_indextoname ();
function maps the interface index specified in
Fa ifindex
to it corresponding name, which is copied into the
buffer pointed to by
Fa ifname ,
which must be of at least
IFNAMSIZ
bytes.
This pointer is also the return value of the function.
If there is no interface corresponding to the specified
index,
NULL
is returned.
The
if_nameindex ();
function returns an array of
Vt if_nameindex
structures, one structure per interface, as
defined in the include file
In net/if.h .
The
Vt if_nameindex
structure contains at least the following entries:
unsigned int if_index; /* 1, 2, ... */ char *if_name; /* null terminated name: "le0", ... */
The end of the array of structures is indicated by a structure with an if_index of 0 and an if_name of NULL A NULL pointer is returned upon an error.
The
if_freenameindex ();
function frees the dynamic memory that was
allocated by
if_nameindex (.);
Upon successful completion,
if_indextoname ();
returns
Fa ifname .
If the interface is not found, a
NULL
pointer is returned and
errno
is set to
Er ENXIO .
A
NULL
pointer is also returned if an error
occurs while retrieving the list of interfaces via
getifaddrs(3).
The
if_nameindex ();
returns a
NULL
pointer if an error
occurs while retrieving the list of interfaces via
getifaddrs(3),
or if sufficient memory cannot be allocated.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |