root/include/linux/if.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
   3  *              operating system.  INET is implemented using the  BSD Socket
   4  *              interface as the means of communication with the user level.
   5  *
   6  *              Global definitions for the INET interface module.
   7  *
   8  * Version:     @(#)if.h        1.0.2   04/18/93
   9  *
  10  * Authors:     Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
  11  *              Ross Biro, <bir7@leland.Stanford.Edu>
  12  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  13  *
  14  *              This program is free software; you can redistribute it and/or
  15  *              modify it under the terms of the GNU General Public License
  16  *              as published by the Free Software Foundation; either version
  17  *              2 of the License, or (at your option) any later version.
  18  */
  19 #ifndef _LINUX_IF_H
  20 #define _LINUX_IF_H
  21 
  22 #include <linux/types.h>                /* for "caddr_t" et al          */
  23 #include <linux/socket.h>               /* for "struct sockaddr" et al  */
  24 
  25 
  26 /* Structure defining a queue for a network interface. */
  27 struct ifnet {
  28   char          *if_name;               /* name, e.g. ``en'' or ``lo''  */
  29   short         if_unit;                /* sub-unit for device driver   */
  30   short         if_mtu;                 /* maximum transmission unit    */
  31   short         if_flags;               /* up/down, broadcast, etc.     */
  32   short         if_timer;               /* time 'til if_watchdog called */
  33   int           if_metric;              /* routing metric (not used)    */
  34   struct        ifaddr *if_addrlist;    /* linked list of addrs per if  */
  35   struct        ifqueue {
  36 #ifdef not_yet_in_linux
  37         struct mbuf     *ifq_head;
  38         struct mbuf     *ifq_tail;
  39         int             ifq_len;
  40         int             ifq_maxlen;
  41         int             ifq_drops;
  42 #endif
  43   } if_snd;                             /* output queue                 */
  44 
  45   /* Procedure handles. */
  46   int           (*if_init)();           /* init routine                 */
  47   int           (*if_output)();         /* output routine               */
  48   int           (*if_ioctl)();          /* ioctl routine                */
  49   int           (*if_reset)();          /* bus reset routine            */
  50   int           (*if_watchdog)();       /* timer routine                */
  51 
  52   /* Generic interface statistics. */
  53   int           if_ipackets;            /* packets recv'd on interface  */
  54   int           if_ierrors;             /* input errors on interface    */
  55   int           if_opackets;            /* packets sent on interface    */
  56   int           if_oerrors;             /* output errors on interface   */
  57   int           if_collisions;          /* collisions on CSMA i'faces   */
  58 
  59   /* Linked list: pointer to next interface. */
  60   struct ifnet  *if_next;
  61 };
  62 
  63 /* Standard interface flags. */
  64 #define IFF_UP          0x1             /* interface is up              */
  65 #define IFF_BROADCAST   0x2             /* broadcast address valid      */
  66 #define IFF_DEBUG       0x4             /* turn on debugging            */
  67 #define IFF_LOOPBACK    0x8             /* is a loopback net            */
  68 #define IFF_POINTOPOINT 0x10            /* interface is has p-p link    */
  69 #define IFF_NOTRAILERS  0x20            /* avoid use of trailers        */
  70 #define IFF_RUNNING     0x40            /* resources allocated          */
  71 #define IFF_NOARP       0x80            /* no ARP protocol              */
  72 
  73 /* These are not yet used: */
  74 #define IFF_PROMISC     0x100           /* recve all packets            */
  75 #define IFF_ALLMULTI    0x200           /* recve all multicast packets  */
  76 
  77 
  78 /*
  79  * The ifaddr structure contains information about one address
  80  * of an interface.  They are maintained by the different address
  81  * families, are allocated and attached when an address is set,
  82  * and are linked together so all addresses for an interface can
  83  * be located.
  84  */
  85 struct ifaddr {
  86   struct sockaddr       ifa_addr;       /* address of interface         */
  87   union {
  88         struct sockaddr ifu_broadaddr;
  89         struct sockaddr ifu_dstaddr;
  90   } ifa_ifu;
  91   struct iface          *ifa_ifp;       /* back-pointer to interface    */
  92   struct ifaddr         *ifa_next;      /* next address for interface   */
  93 };
  94 #define ifa_broadaddr   ifa_ifu.ifu_broadaddr   /* broadcast address    */
  95 #define ifa_dstaddr     ifa_ifu.ifu_dstaddr     /* other end of link    */
  96 
  97 /*
  98  * Interface request structure used for socket
  99  * ioctl's.  All interface ioctl's must have parameter
 100  * definitions which begin with ifr_name.  The
 101  * remainder may be interface specific.
 102  */
 103 struct ifreq {
 104 #define IFHWADDRLEN     6
 105 #define IFNAMSIZ        16
 106         union
 107         {
 108                 char    ifrn_name[IFNAMSIZ];            /* if name, e.g. "en0" */
 109                 char    ifrn_hwaddr[IFHWADDRLEN];
 110         } ifr_ifrn;
 111         
 112         union {
 113                 struct  sockaddr ifru_addr;
 114                 struct  sockaddr ifru_dstaddr;
 115                 struct  sockaddr ifru_broadaddr;
 116                 struct  sockaddr ifru_netmask;
 117                 short   ifru_flags;
 118                 int     ifru_metric;
 119                 int     ifru_mtu;
 120                 caddr_t ifru_data;
 121         } ifr_ifru;
 122 };
 123 
 124 #define ifr_name        ifr_ifrn.ifrn_name      /* interface name       */
 125 #define ifr_hwaddr      ifr_ifrn.ifrn_hwaddr    /* interface hardware   */
 126 #define ifr_addr        ifr_ifru.ifru_addr      /* address              */
 127 #define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-p lnk */
 128 #define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address    */
 129 #define ifr_netmask     ifr_ifru.ifru_netmask   /* interface net mask   */
 130 #define ifr_flags       ifr_ifru.ifru_flags     /* flags                */
 131 #define ifr_metric      ifr_ifru.ifru_metric    /* metric               */
 132 #define ifr_mtu         ifr_ifru.ifru_mtu       /* mtu                  */
 133 #define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
 134 
 135 /*
 136  * Structure used in SIOCGIFCONF request.
 137  * Used to retrieve interface configuration
 138  * for machine (useful for programs which
 139  * must know all networks accessible).
 140  */
 141 struct ifconf {
 142         int     ifc_len;                        /* size of buffer       */
 143         union {
 144                 caddr_t ifcu_buf;
 145                 struct  ifreq *ifcu_req;
 146         } ifc_ifcu;
 147 };
 148 #define ifc_buf ifc_ifcu.ifcu_buf               /* buffer address       */
 149 #define ifc_req ifc_ifcu.ifcu_req               /* array of structures  */
 150 
 151 
 152 /* BSD UNIX expects to find these here, so here we go: */
 153 #include <linux/if_arp.h>
 154 #include <linux/route.h>
 155 
 156 #endif /* _NET_IF_H */

/* [previous][next][first][last][top][bottom][index][help] */