MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Sockets Library Functions                 ifnametoindex(3SOCKET)



NAME
     ifnametoindex,        ifindextoname,         ifnameindex,
     iffreenameindex - routines to map Internet Protocol network
     interface names and interface indexes

SYNOPSIS
     cc [ flag... ] file... -lsocket [ library... ]
     #include 

     unsigned int ifnametoindex(const char *ifname);


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


     struct ifnameindex *ifnameindex(void)


     void iffreenameindex(struct ifnameindex *ptr);


PARAMETERS
     ifname     interface name


     ifindex    interface index


     ptr        pointer returned by ifnameindex()


DESCRIPTION
     This API defines two functions that map between an  Internet
     Protocol  network interface name and index, a third function
     that returns all the interface  names  and  indexes,  and  a
     fourth  function  to  return the dynamic memory allocated by
     the previous function.


     Network interfaces are normally known by names such as eri0,
     sl1, ppp2, and the like. The ifname argument must point to a
     buffer of at least IFNAMESIZE bytes into which  the  inter-
     face  name corresponding to the specified index is returned.
     IFNAMESIZE is defined in  and its value  includes
     a terminating null byte at the end of the interface name.

     ifnametoindex()      The ifnametoindex() function  returns
                           the  interface  index corresponding to
                           the interface name pointed to  by  the
                           ifname   pointer.   If  the  specified
                           interface name  does  not  exist,  the
                           return value is 0, and errno is set to



SunOS 5.11          Last change: 28 Jan 2009                    1






Sockets Library Functions                 ifnametoindex(3SOCKET)



                           ENXIO. If there was  a  system  error,
                           such  as  running  out  of memory, the
                           return value is 0 and errno is set  to
                           the proper value, for example, ENOMEM.


     ifindextoname()      The ifindextoname() function maps  an
                           interface index into its corresponding
                           name. This pointer is also the  return
                           value  of the function. If there is no
                           interface corresponding to the  speci-
                           fied  index,  NUL  is  returned,  and
                           errno is set to ENXIO, if there was  a
                           system  error,  such as running out of
                           memory, ifindextoname() returns  NUL
                           and  errno  would be set to the proper
                           value, for example, ENOMEM.


     ifnameindex()        The ifnameindex() function returns an
                           array  of ifnameindex structures, one
                           structure    per    interface.     The
                           ifnameindex   structure   holds   the
                           information about a  single  interface
                           and  is  defined  when  the 
                           header is included:

                             struct ifnameindex
                                unsigned int   ifindex; /* 1, 2, ... */
                                char          *ifname;  /* "net0", ... */
                             };

                           While  any  IPMP  IP  interfaces   are
                           returned by ifnameindex(), the under-
                           lying IP interfaces that comprise each
                           IPMP group are not returned.

                           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 null pointer
                           upon an error and sets  errno  to  the
                           appropriate value. The memory used for
                           this array of  structures  along  with
                           the  interface names pointed to by the
                           ifname members  is  obtained  dynami-
                           cally.  This  memory  is  freed by the
                           iffreenameindex() function.


     iffreenameindex()    The iffreenameindex() function  frees
                           the  dynamic memory that was allocated



SunOS 5.11          Last change: 28 Jan 2009                    2






Sockets Library Functions                 ifnametoindex(3SOCKET)



                           by  ifnameindex().  The  argument  to
                           this  function  must be a pointer that
                           was returned by ifnameindex().


ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Availability                 SUNWcsl (32-bit)            
                                  SUNWcslx (64-bit)           
    
     MT-Level                     MT-Safe                     
    


SEE ALSO
     ifconfig(1M), ifnametoindex(3XNET), attributes(5), if(7P)
































SunOS 5.11          Last change: 28 Jan 2009                    3



OpenSolaris man pages main menu

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