p The .Fn if_indextoname function maps the interface index specified in .Ar ifindex to it corresponding name, which is copied into the buffer pointed to by .Ar 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.
p The .Fn if_nameindex function returns an array of .Nm if_nameindex structures, one structure per interface, as defined in the include file n net/if.h . The .Nm if_nameindex structure contains at least the following entries: d -literal unsigned int if_index; /* 1, 2, ... */ char *if_name; /* null terminated name: "le0", ... */ .Ed
p The end of the array of structures is indicated by a structure with an .Nm if_index of 0 and an .Nm if_name of NULL. A NULL pointer is returned upon an error.
p The .Fn if_freenameindex function frees the dynamic memory that was allocated by .Fn if_nameindex . .Sh RETURN VALUES Upon successful completion, .Fn if_nametoindex returns the index number of the interface. If the interface is not found, a value of 0 is returned and .Va errno is set to .Er ENXIO . A value of 0 is also returned if an error occurs while retrieving the list of interfaces via .Xr getifaddrs 3 .
p Upon successful completion, .Fn if_indextoname returns .Ar ifname . If the interface is not found, a NULL pointer is returned and .Va errno is set to .Er ENXIO . A NULL pointer is also returned if an error occurs while retrieving the list of interfaces via .Xr getifaddrs 3 .
p The .Fn if_nameindex returns a NULL pointer if an error occurs while retrieving the list of interfaces via .Xr getifaddrs 3 , or if sufficient memory cannot be allocated. .Sh SEE ALSO .Xr getifaddrs 3 , .Xr networking 4 .Sh STANDARDS The .Fn if_nametoindex , .Fn if_indextoname , .Fn if_nameindex , and .Fn if_freenameindex functions conform to .St -p1003.1-2001 , .St -xns5.2 , and RFC 3493. .Sh HISTORY The implementation first appeared in sx .