if.h

Go to the documentation of this file.
00001 /**
00002 *
00003 
00004  * INET         An implementation of the TCP/IP protocol suite for the LINUX
00005  *              operating system.  INET is implemented using the  BSD Socket
00006  *              interface as the means of communication with the user level.
00007  *
00008  *              Global definitions for the INET interface module.
00009  *
00010  * Version:     @(#)if.h        1.0.2   04/18/93
00011  *
00012  * Authors:     Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
00013  *              Ross Biro, <bir7@leland.Stanford.Edu>
00014  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
00015  *
00016  *              This program is free software; you can redistribute it and/or
00017  *              modify it under the terms of the GNU General Public License
00018  *              as published by the Free Software Foundation; either version
00019  *              2 of the License, or (at your option) any later version.
00020 
00021 
00022 */
00023 #ifndef _LINUX_IF_H
00024 #define _LINUX_IF_H
00025 
00026 #include <linux/types.h>                ///< for "caddr_t" et al                
00027 #include <linux/socket.h>               ///< for "struct sockaddr" et al        
00028 
00029 
00030 /// Structure defining a queue for a network interface. 
00031 struct ifnet {
00032   char          *if_name;               ///< name, e.g. ``en'' or ``lo''        
00033   short         if_unit;                ///< sub-unit for device driver 
00034   short         if_mtu;                 ///< maximum transmission unit  
00035   short         if_flags;               ///< up/down, broadcast, etc.   
00036   short         if_timer;               ///< time 'til if_watchdog called       
00037   int           if_metric;              ///< routing metric (not used)  
00038   struct        ifaddr *if_addrlist;    ///< linked list of addrs per if        
00039   struct        ifqueue {
00040 #ifdef not_yet_in_linux
00041         struct mbuf     *ifq_head;
00042         struct mbuf     *ifq_tail;
00043         int             ifq_len;
00044         int             ifq_maxlen;
00045         int             ifq_drops;
00046 #endif
00047   } if_snd;                             ///< output queue                       
00048 
00049   /// Procedure handles. 
00050   int           (*if_init)();           ///< init routine                       
00051   int           (*if_output)();         ///< output routine             
00052   int           (*if_ioctl)();          ///< ioctl routine              
00053   int           (*if_reset)();          ///< bus reset routine          
00054   int           (*if_watchdog)();       ///< timer routine              
00055 
00056   /// Generic interface statistics. 
00057   int           if_ipackets;            ///< packets recv'd on interface        
00058   int           if_ierrors;             ///< input errors on interface  
00059   int           if_opackets;            ///< packets sent on interface  
00060   int           if_oerrors;             ///< output errors on interface 
00061   int           if_collisions;          ///< collisions on CSMA i'faces 
00062 
00063   /// Linked list: pointer to next interface. 
00064   struct ifnet  *if_next;
00065 };
00066 
00067 /// Standard interface flags. 
00068 #define IFF_UP          0x1             ///< interface is up            
00069 #define IFF_BROADCAST   0x2             ///< broadcast address valid    
00070 #define IFF_DEBUG       0x4             ///< turn on debugging          
00071 #define IFF_LOOPBACK    0x8             ///< is a loopback net          
00072 #define IFF_POINTOPOINT 0x10            ///< interface is has p-p link  
00073 #define IFF_NOTRAILERS  0x20            ///< avoid use of trailers      
00074 #define IFF_RUNNING     0x40            ///< resources allocated                
00075 #define IFF_NOARP       0x80            ///< no ARP protocol            
00076 
00077 /// These are not yet used: 
00078 #define IFF_PROMISC     0x100           ///< recve all packets          
00079 #define IFF_ALLMULTI    0x200           ///< recve all multicast packets        
00080 
00081 
00082 /**
00083 *
00084 
00085  * The ifaddr structure contains information about one address
00086  * of an interface.  They are maintained by the different address
00087  * families, are allocated and attached when an address is set,
00088  * and are linked together so all addresses for an interface can
00089  * be located.
00090 
00091 
00092 */
00093 struct ifaddr {
00094   struct sockaddr       ifa_addr;       ///< address of interface               
00095   union {
00096         struct sockaddr ifu_broadaddr;
00097         struct sockaddr ifu_dstaddr;
00098   } ifa_ifu;
00099   struct iface          *ifa_ifp;       ///< back-pointer to interface  
00100   struct ifaddr         *ifa_next;      ///< next address for interface 
00101 };
00102 #define ifa_broadaddr   ifa_ifu.ifu_broadaddr   ///< broadcast address  
00103 #define ifa_dstaddr     ifa_ifu.ifu_dstaddr     ///< other end of link  
00104 
00105 /**
00106 *
00107 
00108  * Interface request structure used for socket
00109  * ioctl's.  All interface ioctl's must have parameter
00110  * definitions which begin with ifr_name.  The
00111  * remainder may be interface specific.
00112 
00113 
00114 */
00115 struct ifreq {
00116 #define IFHWADDRLEN     6
00117 #define IFNAMSIZ        16
00118         union
00119         {
00120                 char    ifrn_name[IFNAMSIZ];            ///< if name, e.g. "en0" 
00121                 char    ifrn_hwaddr[IFHWADDRLEN];
00122         } ifr_ifrn;
00123         
00124         union {
00125                 struct  sockaddr ifru_addr;
00126                 struct  sockaddr ifru_dstaddr;
00127                 struct  sockaddr ifru_broadaddr;
00128                 struct  sockaddr ifru_netmask;
00129                 short   ifru_flags;
00130                 int     ifru_metric;
00131                 int     ifru_mtu;
00132                 caddr_t ifru_data;
00133         } ifr_ifru;
00134 };
00135 
00136 #define ifr_name        ifr_ifrn.ifrn_name      ///< interface name     
00137 #define ifr_hwaddr      ifr_ifrn.ifrn_hwaddr    ///< interface hardware   
00138 #define ifr_addr        ifr_ifru.ifru_addr      ///< address            
00139 #define ifr_dstaddr     ifr_ifru.ifru_dstaddr   ///< other end of p-p lnk       
00140 #define ifr_broadaddr   ifr_ifru.ifru_broadaddr ///< broadcast address  
00141 #define ifr_netmask     ifr_ifru.ifru_netmask   ///< interface net mask 
00142 #define ifr_flags       ifr_ifru.ifru_flags     ///< flags              
00143 #define ifr_metric      ifr_ifru.ifru_metric    ///< metric             
00144 #define ifr_mtu         ifr_ifru.ifru_mtu       ///< mtu                        
00145 #define ifr_data        ifr_ifru.ifru_data      ///< for use by interface       
00146 
00147 /**
00148 *
00149 
00150  * Structure used in SIOCGIFCONF request.
00151  * Used to retrieve interface configuration
00152  * for machine (useful for programs which
00153  * must know all networks accessible).
00154 
00155 
00156 */
00157 struct ifconf {
00158         int     ifc_len;                        ///< size of buffer     
00159         union {
00160                 caddr_t ifcu_buf;
00161                 struct  ifreq *ifcu_req;
00162         } ifc_ifcu;
00163 };
00164 #define ifc_buf ifc_ifcu.ifcu_buf               ///< buffer address     
00165 #define ifc_req ifc_ifcu.ifcu_req               ///< array of structures        
00166 
00167 
00168 /// BSD UNIX expects to find these here, so here we go: 
00169 #include <linux/if_arp.h>
00170 #include <linux/route.h>
00171 
00172 #endif // _NET_IF_H 

Generated on Mon May 1 21:47:00 2006 for KernelAPI by  doxygen 1.4.6-5