Back to index

glibc  2.9
Classes | Defines | Enumerations | Functions
if.h File Reference
#include <features.h>
#include <sys/types.h>
#include <sys/socket.h>

Go to the source code of this file.

Classes

struct  ifaddr
struct  ifreq
struct  oifreq
struct  ifconf
struct  if_nameindex
union  ifaddr.ifa_ifu
union  ifreq.ifr_ifrn
union  ifreq.ifr_ifru
union  oifreq.ifr_ifru
union  ifconf.ifc_ifcu

Defines

#define IFF_UP   IFF_UP
#define IFF_BROADCAST   IFF_BROADCAST
#define IFF_DEBUG   IFF_DEBUG
#define IFF_LOOPBACK   IFF_LOOPBACK
#define IFF_POINTOPOINT   IFF_POINTOPOINT
#define IFF_NOTRAILERS   IFF_NOTRAILERS
#define IFF_RUNNING   IFF_RUNNING
#define IFF_NOARP   IFF_NOARP
#define IFF_PROMISC   IFF_PROMISC
#define IFF_ALLMULTI   IFF_ALLMULTI
#define IFF_OACTIVE   IFF_OACTIVE
#define IFF_SIMPLEX   IFF_SIMPLEX
#define IFF_DO_HW_LOOPBACK   IFF_DO_HW_LOOPBACK
#define IFF_ALLCAST   IFF_ALLCAST
#define IFF_BRIDGE   IFF_BRIDGE
#define IFF_NOECHO   IFF_NOECHO
#define ifa_broadaddr   ifa_ifu.ifu_broadaddr /* broadcast address */
#define ifa_dstaddr   ifa_ifu.ifu_dstaddr /* other end of link */
#define IFHWADDRLEN   6
#define IFNAMSIZ   16
#define ifr_name   ifr_ifrn.ifrn_name /* interface name */
#define ifr_hwaddr   ifr_ifru.ifru_hwaddr /* MAC address */
#define ifr_addr   ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr   ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
#define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_netmask   ifr_ifru.ifru_netmask /* interface net mask */
#define ifr_flags   ifr_ifru.ifru_flags /* flags */
#define ifr_metric   ifr_ifru.ifru_ivalue /* metric */
#define ifr_mtu   ifr_ifru.ifru_mtu /* mtu */
#define ifr_slave   ifr_ifru.ifru_slave /* slave device */
#define ifr_data   ifr_ifru.ifru_data /* for use by interface */
#define ifr_ifindex   ifr_ifru.ifru_ivalue /* interface index */
#define ifr_bandwidth   ifr_ifru.ifru_ivalue /* link bandwidth */
#define ifr_baudrate   ifr_ifru.ifru_ivalue /* link bandwidth */
#define ifr_qlen   ifr_ifru.ifru_ivalue /* queue length */
#define ifr_site6   ifr_ifru.ifru_site6 /* IPv6 site index */
#define ifc_buf   ifc_ifcu.ifcu_buf /* Buffer address. */
#define ifc_req   ifc_ifcu.ifcu_req /* Array of structures. */

Enumerations

enum  {
  IFF_UP = 0x1, IFF_UP = 0x1, IFF_BROADCAST = 0x2, IFF_BROADCAST = 0x2,
  IFF_DEBUG = 0x4, IFF_DEBUG = 0x4, IFF_LOOPBACK = 0x8, IFF_LOOPBACK = 0x8,
  IFF_POINTOPOINT = 0x10, IFF_POINTOPOINT = 0x10, IFF_NOTRAILERS = 0x20, IFF_NOTRAILERS = 0x20,
  IFF_RUNNING = 0x40, IFF_RUNNING = 0x40, IFF_NOARP = 0x80, IFF_NOARP = 0x80,
  IFF_PROMISC = 0x100, IFF_PROMISC = 0x100, IFF_ALLMULTI = 0x200, IFF_ALLMULTI = 0x200,
  IFF_OACTIVE = 0x400, IFF_OACTIVE = 0x400, IFF_SIMPLEX = 0x800, IFF_SIMPLEX = 0x800,
  IFF_DO_HW_LOOPBACK = 0x10000, IFF_DO_HW_LOOPBACK = 0x10000, IFF_ALLCAST = 0x20000, IFF_ALLCAST = 0x20000,
  IFF_BRIDGE = 0x40000, IFF_BRIDGE = 0x40000, IFF_NOECHO = IFF_SIMPLEX, IFF_NOECHO = IFF_SIMPLEX
}

Functions

__BEGIN_DECLS unsigned int if_nametoindex (__const char *__ifname) __THROW
char * if_indextoname (unsigned int __ifindex, char *__ifname) __THROW
struct if_nameindexif_nameindex (void) __THROW
void if_freenameindex (struct if_nameindex *__ptr) __THROW

Class Documentation

struct ifreq

Definition at line 96 of file if.h.

Class Members
union ifreq ifr_ifrn
union ifreq ifr_ifru
struct oifreq

Definition at line 122 of file if.h.

Class Members
union oifreq ifr_ifru
char ifr_name
unsigned char reserved
struct ifconf

Definition at line 161 of file if.h.

Class Members
union ifconf ifc_ifcu
int ifc_len
struct if_nameindex

Definition at line 182 of file if.h.

Class Members
unsigned int if_index
char * if_name
union ifaddr.ifa_ifu

Definition at line 75 of file if.h.

union ifreq.ifr_ifrn

Definition at line 100 of file if.h.

Class Members
char ifrn_name
union ifreq.ifr_ifru

Definition at line 105 of file if.h.

Class Members
__caddr_t ifru_data
short int ifru_flags
int ifru_ivalue
unsigned int ifru_mtu
unsigned short int ifru_site6
char ifru_slave
union oifreq.ifr_ifru

Definition at line 125 of file if.h.

Class Members
caddr_t ifru_data
int ifru_flags
int ifru_metric
unsigned int ifru_mtu
union ifconf.ifc_ifcu

Definition at line 164 of file if.h.

Class Members
__caddr_t ifcu_buf
struct ifreq * ifcu_req

Define Documentation

#define ifa_broadaddr   ifa_ifu.ifu_broadaddr /* broadcast address */

Definition at line 89 of file if.h.

#define ifa_dstaddr   ifa_ifu.ifu_dstaddr /* other end of link */

Definition at line 90 of file if.h.

#define ifc_buf   ifc_ifcu.ifcu_buf /* Buffer address. */

Definition at line 170 of file if.h.

#define ifc_req   ifc_ifcu.ifcu_req /* Array of structures. */

Definition at line 171 of file if.h.

#define IFF_ALLCAST   IFF_ALLCAST

Definition at line 60 of file if.h.

#define IFF_ALLMULTI   IFF_ALLMULTI

Definition at line 51 of file if.h.

#define IFF_BRIDGE   IFF_BRIDGE

Definition at line 62 of file if.h.

Definition at line 33 of file if.h.

#define IFF_DEBUG   IFF_DEBUG

Definition at line 35 of file if.h.

Definition at line 58 of file if.h.

#define IFF_LOOPBACK   IFF_LOOPBACK

Definition at line 37 of file if.h.

#define IFF_NOARP   IFF_NOARP

Definition at line 45 of file if.h.

#define IFF_NOECHO   IFF_NOECHO

Definition at line 64 of file if.h.

Definition at line 41 of file if.h.

#define IFF_OACTIVE   IFF_OACTIVE

Definition at line 54 of file if.h.

Definition at line 39 of file if.h.

#define IFF_PROMISC   IFF_PROMISC

Definition at line 47 of file if.h.

#define IFF_RUNNING   IFF_RUNNING

Definition at line 43 of file if.h.

#define IFF_SIMPLEX   IFF_SIMPLEX

Definition at line 56 of file if.h.

#define IFF_UP   IFF_UP

Definition at line 31 of file if.h.

#define IFHWADDRLEN   6

Definition at line 98 of file if.h.

#define IFNAMSIZ   16

Definition at line 99 of file if.h.

#define ifr_addr   ifr_ifru.ifru_addr /* address */

Definition at line 141 of file if.h.

#define ifr_bandwidth   ifr_ifru.ifru_ivalue /* link bandwidth */

Definition at line 151 of file if.h.

#define ifr_baudrate   ifr_ifru.ifru_ivalue /* link bandwidth */

Definition at line 152 of file if.h.

#define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */

Definition at line 143 of file if.h.

#define ifr_data   ifr_ifru.ifru_data /* for use by interface */

Definition at line 149 of file if.h.

#define ifr_dstaddr   ifr_ifru.ifru_dstaddr /* other end of p-p lnk */

Definition at line 142 of file if.h.

#define ifr_flags   ifr_ifru.ifru_flags /* flags */

Definition at line 145 of file if.h.

#define ifr_hwaddr   ifr_ifru.ifru_hwaddr /* MAC address */

Definition at line 140 of file if.h.

#define ifr_ifindex   ifr_ifru.ifru_ivalue /* interface index */

Definition at line 150 of file if.h.

#define ifr_metric   ifr_ifru.ifru_ivalue /* metric */

Definition at line 146 of file if.h.

#define ifr_mtu   ifr_ifru.ifru_mtu /* mtu */

Definition at line 147 of file if.h.

#define ifr_name   ifr_ifrn.ifrn_name /* interface name */

Definition at line 139 of file if.h.

#define ifr_netmask   ifr_ifru.ifru_netmask /* interface net mask */

Definition at line 144 of file if.h.

#define ifr_qlen   ifr_ifru.ifru_ivalue /* queue length */

Definition at line 153 of file if.h.

#define ifr_site6   ifr_ifru.ifru_site6 /* IPv6 site index */

Definition at line 154 of file if.h.

#define ifr_slave   ifr_ifru.ifru_slave /* slave device */

Definition at line 148 of file if.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
IFF_UP 
IFF_UP 
IFF_BROADCAST 
IFF_BROADCAST 
IFF_DEBUG 
IFF_DEBUG 
IFF_LOOPBACK 
IFF_LOOPBACK 
IFF_POINTOPOINT 
IFF_POINTOPOINT 
IFF_NOTRAILERS 
IFF_NOTRAILERS 
IFF_RUNNING 
IFF_RUNNING 
IFF_NOARP 
IFF_NOARP 
IFF_PROMISC 
IFF_PROMISC 
IFF_ALLMULTI 
IFF_ALLMULTI 
IFF_OACTIVE 
IFF_OACTIVE 
IFF_SIMPLEX 
IFF_SIMPLEX 
IFF_DO_HW_LOOPBACK 
IFF_DO_HW_LOOPBACK 
IFF_ALLCAST 
IFF_ALLCAST 
IFF_BRIDGE 
IFF_BRIDGE 
IFF_NOECHO 
IFF_NOECHO 

Definition at line 28 of file if.h.

  {
    IFF_UP = 0x1,           /* Interface is up.  */
#define IFF_UP       IFF_UP
    IFF_BROADCAST = 0x2,    /* Broadcast address valid.  */
#define IFF_BROADCAST       IFF_BROADCAST
    IFF_DEBUG = 0x4,        /* Turn on debugging.  */
#define IFF_DEBUG    IFF_DEBUG
    IFF_LOOPBACK = 0x8,            /* Is a loopback net.  */
#define IFF_LOOPBACK IFF_LOOPBACK
    IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link.  */
#define IFF_POINTOPOINT     IFF_POINTOPOINT
    IFF_NOTRAILERS = 0x20,  /* Avoid use of trailers.  */
#define IFF_NOTRAILERS      IFF_NOTRAILERS
    IFF_RUNNING = 0x40,            /* Resources allocated.  */
#define IFF_RUNNING  IFF_RUNNING
    IFF_NOARP = 0x80,              /* No address resolution protocol.  */
#define IFF_NOARP    IFF_NOARP
    IFF_PROMISC = 0x100,    /* Receive all packets.  */
#define IFF_PROMISC  IFF_PROMISC

    /* Not supported */
    IFF_ALLMULTI = 0x200,   /* Receive all multicast packets.  */
#define IFF_ALLMULTI IFF_ALLMULTI

    IFF_OACTIVE = 0x400,    /* Transmission in progress.  */
#define IFF_OACTIVE  IFF_OACTIVE
    IFF_SIMPLEX = 0x800,    /* Cannot hear own transmissions.  */
#define IFF_SIMPLEX  IFF_SIMPLEX
    IFF_DO_HW_LOOPBACK = 0x10000, /* Force loopback through hardware.  */
#define IFF_DO_HW_LOOPBACK  IFF_DO_HW_LOOPBACK
    IFF_ALLCAST = 0x20000,  /* Global broadcast.  */
#define IFF_ALLCAST  IFF_ALLCAST
    IFF_BRIDGE = 0x40000,   /* Receive all bridge packets.  */
#define IFF_BRIDGE   IFF_BRIDGE
    IFF_NOECHO = IFF_SIMPLEX,      /* Reeives echo packets.  */
#define IFF_NOECHO   IFF_NOECHO
  };

Function Documentation

void if_freenameindex ( struct if_nameindex __ptr)

Here is the caller graph for this function:

char* if_indextoname ( unsigned int  __ifindex,
char *  __ifname 
)

Definition at line 157 of file if_index.c.

{
  struct ifreq ifr;
  int fd = __opensock ();

  if (fd < 0)
    return NULL;

  ifr.ifr_ifindex = ifindex;
  if (__ioctl (fd, SIOCGIFNAME, &ifr) < 0)
    {
      int saved_errno = errno;
      __close (fd);
      if (saved_errno == EINVAL || saved_errno == ENOTTY)
        __set_errno (ENOSYS);
      else if (saved_errno == ENODEV)
       __set_errno (ENXIO);
      return NULL;
    }
  __close (fd);
  return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
}

Here is the caller graph for this function:

struct if_nameindex* if_nameindex ( void  ) [read]

Definition at line 72 of file if_index.c.

{
  error_t err = 0;
  char data[2048];
  file_t server;
  int fd = __opensock ();
  struct ifconf ifc;
  unsigned int nifs, i;
  struct if_nameindex *idx = NULL;

  ifc.ifc_buf = data;

  if (fd < 0)
    return NULL;

  server = _hurd_socket_server (PF_INET, 0);
  if (server == MACH_PORT_NULL)
    nifs = 0;
  else
    {
      size_t len = sizeof data;
      err = __pfinet_siocgifconf (server, -1, &ifc.ifc_buf, &len);
      if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED)
       {
         /* On the first use of the socket server during the operation,
            allow for the old server port dying.  */
         server = _hurd_socket_server (PF_INET, 1);
         if (server == MACH_PORT_NULL)
           goto out;
         err = __pfinet_siocgifconf (server, -1, &ifc.ifc_buf, &len);
       }
      if (err)
       goto out;

      ifc.ifc_len = len;
      nifs = len / sizeof (struct ifreq);
    }

  idx = malloc ((nifs + 1) * sizeof (struct if_nameindex));
  if (idx == NULL)
    {
      err = ENOBUFS;
      goto out;
    }

  for (i = 0; i < nifs; ++i)
    {
      struct ifreq *ifr = &ifc.ifc_req[i];
      idx[i].if_name = __strdup (ifr->ifr_name);
      if (idx[i].if_name == NULL
          || __ioctl (fd, SIOCGIFINDEX, ifr) < 0)
        {
          unsigned int j;
          err = errno;

          for (j =  0; j < i; ++j)
            free (idx[j].if_name);
          free (idx);
         idx = NULL;

          if (err == EINVAL)
            err = ENOSYS;
          else if (err == ENOMEM)
            err = ENOBUFS;
          goto out;
        }
      idx[i].if_index = ifr->ifr_ifindex;
    }

  idx[i].if_index = 0;
  idx[i].if_name = NULL;

 out:
  __close (fd);
  if (data != ifc.ifc_buf)
    __vm_deallocate (__mach_task_self (), (vm_address_t) ifc.ifc_buf,
                   ifc.ifc_len);
  __set_errno (err);
  return idx;
}

Here is the caller graph for this function:

__BEGIN_DECLS unsigned int if_nametoindex ( __const char *  __ifname)