NAME
iiffnnaammeettooiinnddeexx, iiffiinnddeexxttoonnaammee, iiffnnaammeeiinnddeexx, iiffffrreeeennaammeeiinnddeexx - convert
interface index to name, and vice versa LLIIBBRRAARRYYStandard C Library (libc, -lc)
SYNOPSIS
##iinncclluuddee <
> ##iinncclluuddee <
> ##iinncclluuddee <
unsigned int iiffnnaammeettooiinnddeexx(const char *ifname); char * iiffiinnddeexxttoonnaammee(unsigned int ifindex, char *ifname); struct ifnameindex * iiffnnaammeeiinnddeexx(void); void iiffffrreeeennaammeeiinnddeexx(struct ifnameindex *ptr);> DESCRIPTION
The functions map interface index to readable interface name (such as ``lo0''), and vice versa. iiffnnaammeettooiinnddeexx() converts readable interface name to interface index If the specified interface does not exist, 0 will be returned. iiffiinnddeexxttoonnaammee() converts interface index to readable interface name.The ifname argument must point to a buffer of at least IFNAMESIZE bytes
into which the interface name corresponding to the specified index isreturned. (IFNAMESIZE is also defined in
includes a terminating null byte at the end of the interface name.) Thisand its value pointer is also the return value of the function. If there is no inter-
face corresponding to the specified index, NULL is returned. iiffnnaammeeiinnddeexx() returns an array of ifnameindex structures. ifnametoindex is also defined in, and is as follows: struct ifnameindex { unsigned int ifindex; /* 1, 2, ... */ char *ifname; /* null terminated name: "le0", ... */ }; The end of the array of structures is indicated by a structure with an ifindex of 0 and an ifname of NULL. The function returns a NULL pointer upon an error. The memory used for this array of structures along with the interface names pointed to by the ifname members is obtained dynamically. This memory is freed by the iiffffrreeeennaammeeiinnddeexx() function. iiffffrreeeennaammeeiinnddeexx() takes a pointer that was returned by iiffnnaammeeiinnddeexx() as argument (ptr), and it reclaims the region allocated. DIAGNOSTICS iiffnnaammeettooiinnddeexx() returns 0 on error, positive integer on success. iiffiinnddeexxttoonnaammee() and iiffnnaammeeiinnddeexx() return NULL on errors. SEE ALSO
R. Gilligan, S. Thomson, J. Bound, and W. Stevens, ``Basic Socket Inter-
face Extensions for IPv6,'' RFC2553, March 1999. HISTORY The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. STANDARDS These functions are defined in ``Basic Socket Interface Extensions for IPv6'' (RFC2533). BSD May 21, 1998 BSD