if_nametoindex man page on SmartOS

Man page or keyword search:  
man Server   16655 pages
apropos Keyword Search (all sections)
Output format
SmartOS logo
[printable version]


       if_nametoindex,	if_indextoname,	 if_nameindex, if_freenameindex - rou‐
       tines to map Internet Protocol network interface	 names	and  interface

       cc [ flag... ] file... -lsocket [ library... ]
       #include <net/if.h>

       unsigned int if_nametoindex(const char *ifname);

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

       struct if_nameindex *if_nameindex(void)

       void if_freenameindex(struct if_nameindex *ptr);

		  interface name

		  interface index

		  pointer returned by if_nameindex()

       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
       IF_NAMESIZE bytes into which the interface name	corresponding  to  the
       specified  index	 is returned. IF_NAMESIZE is defined in <net/if.h> and
       its value includes a terminating null byte at the end of the  interface

			     The  if_nametoindex() function returns the inter‐
			     face index corresponding to  the  interface  name
			     pointed  to  by the ifname pointer. If the speci‐
			     fied interface name does not  exist,  the	return
			     value  is	0, and errno is set to ENXIO. If there
			     was a system error, such as running out  of  mem‐
			     ory,  the	return	value is 0 and errno is set to
			     the proper value, for example, ENOMEM.

			     The if_indextoname() 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, NULL is returned, and errno is set to
			     ENXIO,  if there was a system error, such as run‐
			     ning out of memory, if_indextoname() returns NULL
			     and  errno	 would be set to the proper value, for
			     example, ENOMEM.

			     The if_nameindex() function returns an  array  of
			     if_nameindex structures, one structure per inter‐
			     face. The if_nameindex structure holds the infor‐
			     mation  about  a  single interface and is defined
			     when the <net/if.h> header is included:

			       struct if_nameindex
				  unsigned int	 if_index; /* 1, 2, ... */
				  char		*if_name;  /* "net0", ... */

			     While any IPMP  IP	 interfaces  are  returned  by
			     if_nameindex(), the underlying IP interfaces that
			     comprise each IPMP group are not returned.

			     The end of the array of structures	 is  indicated
			     by	 a  structure  with  an	 if_index  of 0 and an
			     if_name of NULL.  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	if_name	 members  is  obtained
			     dynamically.   This   memory   is	freed  by  the
			     if_freenameindex() function.

			     The if_freenameindex() function frees the dynamic
			     memory  that was allocated by if_nameindex(). The
			     argument to this function must be a pointer  that
			     was returned by if_nameindex().

       See attributes(5) for descriptions of the following attributes:

       │MT-Level       │ MT-Safe	 │

       ifconfig(1M), if_nametoindex(3XNET), attributes(5), if(7P)

				 Jan 28, 2009	       IF_NAMETOINDEX(3SOCKET)

List of man pages available for SmartOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net