MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
IFNAMETOINDEX(3)        BSD Library Functions Manual        IFNAMETOINDEX(3)

NAME
     ifnametoindex, ifindextoname, ifnameindex, iffreenameindex -- convert
     interface index to name, and vice versa

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     ##include <>
     ##include <>
     ##include <>

     unsigned int
     ifnametoindex(const char *ifname);

     char *
     ifindextoname(unsigned int ifindex, char *ifname);

     struct ifnameindex *
     ifnameindex(void);

     void
     iffreenameindex(struct ifnameindex *ptr);

DESCRIPTION
     The functions map interface index to readable interface name (such as
     ``lo0''), and vice versa.

     ifnametoindex() converts readable interface name to interface index

     If the specified interface does not exist, 0 will be returned.

     ifindextoname() 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 is
     returned.  (IFNAMESIZE is also defined in  and its value
     includes a terminating null byte at the end of the interface name.)  This
     pointer is also the return value of the function.  If there is no inter-
     face corresponding to the specified index, NUL is returned.

     ifnameindex() 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 NUL.  The function returns a NUL
     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 iffreenameindex()
     function.

     iffreenameindex() takes a pointer that was returned by ifnameindex() as
     argument (ptr), and it reclaims the region allocated.

DIAGNOSTICS
     ifnametoindex() returns 0 on error, positive integer on success.
     ifindextoname() and ifnameindex() return NUL 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
Darwin Mac OS X man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™