root/include/linux/netdevice.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  *              Definitions for the Interfaces handler.
   7  *
   8  * Version:     @(#)dev.h       1.0.10  08/12/93
   9  *
  10  * Authors:     Ross Biro, <bir7@leland.Stanford.Edu>
  11  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12  *              Corey Minyard <wf-rch!minyard@relay.EU.net>
  13  *              Donald J. Becker, <becker@super.org>
  14  *              Alan Cox, <A.Cox@swansea.ac.uk>
  15  *
  16  *              This program is free software; you can redistribute it and/or
  17  *              modify it under the terms of the GNU General Public License
  18  *              as published by the Free Software Foundation; either version
  19  *              2 of the License, or (at your option) any later version.
  20  *
  21  *              Moved to /usr/include/linux for NET3
  22  */
  23 #ifndef _LINUX_NETDEVICE_H
  24 #define _LINUX_NETDEVICE_H
  25 
  26 #include <linux/if.h>
  27 #include <linux/if_ether.h>
  28 #include <linux/skbuff.h>
  29 
  30 /* for future expansion when we will have different priorities. */
  31 #define DEV_NUMBUFFS    3
  32 #define MAX_ADDR_LEN    7
  33 #define MAX_HEADER      18
  34 
  35 #define IS_MYADDR       1               /* address is (one of) our own  */
  36 #define IS_LOOPBACK     2               /* address is for LOOPBACK      */
  37 #define IS_BROADCAST    3               /* address is a valid broadcast */
  38 #define IS_INVBCAST     4               /* Wrong netmask bcast not for us (unused)*/
  39 
  40 /*
  41  * The DEVICE structure.
  42  * Actually, this whole structure is a big mistake.  It mixes I/O
  43  * data with strictly "high-level" data, and it has to know about
  44  * almost every data structure used in the INET module.  
  45  */
  46 struct device 
  47 {
  48 
  49   /*
  50    * This is the first field of the "visible" part of this structure
  51    * (i.e. as seen by users in the "Space.c" file).  It is the name
  52    * the interface.
  53    */
  54   char                    *name;
  55 
  56   /* I/O specific fields.  */
  57   unsigned long           rmem_end;             /* shmem "recv" end     */
  58   unsigned long           rmem_start;           /* shmem "recv" start   */
  59   unsigned long           mem_end;              /* sahared mem end      */
  60   unsigned long           mem_start;            /* shared mem start     */
  61   unsigned short          base_addr;            /* device I/O address   */
  62   unsigned char           irq;                  /* device IRQ number    */
  63 
  64   /* Low-level status flags. */
  65   volatile unsigned char  start,                /* start an operation   */
  66                           tbusy,                /* transmitter busy     */
  67                           interrupt;            /* interrupt arrived    */
  68 
  69   struct device           *next;
  70 
  71   /* The device initialization function. Called only once. */
  72   int                     (*init)(struct device *dev);
  73 
  74   /* Some hardware also needs these fields, but they are not part of the
  75      usual set specified in Space.c. */
  76   unsigned char           if_port;              /* Selectable AUI, TP,..*/
  77   unsigned char           dma;                  /* DMA channel          */
  78 
  79   struct enet_statistics* (*get_stats)(struct device *dev);
  80 
  81   /*
  82    * This marks the end of the "visible" part of the structure. All
  83    * fields hereafter are internal to the system, and may change at
  84    * will (read: may be cleaned up at will).
  85    */
  86 
  87   /* These may be needed for future network-power-down code. */
  88   unsigned long           trans_start;  /* Time (in jiffies) of last Tx */
  89   unsigned long           last_rx;      /* Time of last Rx              */
  90 
  91   unsigned short          flags;        /* interface flags (a la BSD)   */
  92   unsigned short          family;       /* address family ID (AF_INET)  */
  93   unsigned short          metric;       /* routing metric (not used)    */
  94   unsigned short          mtu;          /* interface MTU value          */
  95   unsigned short          type;         /* interface hardware type      */
  96   unsigned short          hard_header_len;      /* hardware hdr length  */
  97   void                    *priv;        /* pointer to private data      */
  98 
  99   /* Interface address info. */
 100   unsigned char           broadcast[MAX_ADDR_LEN];      /* hw bcast add */
 101   unsigned char           dev_addr[MAX_ADDR_LEN];       /* hw address   */
 102   unsigned char           addr_len;     /* harfware address length      */
 103   unsigned long           pa_addr;      /* protocol address             */
 104   unsigned long           pa_brdaddr;   /* protocol broadcast addr      */
 105   unsigned long           pa_dstaddr;   /* protocol P-P other side addr */
 106   unsigned long           pa_mask;      /* protocol netmask             */
 107   unsigned short          pa_alen;      /* protocol address length      */
 108 
 109   /* Pointer to the interface buffers. */
 110   struct sk_buff_head     buffs[DEV_NUMBUFFS];
 111 
 112   /* Pointers to interface service routines. */
 113   int                     (*open)(struct device *dev);
 114   int                     (*stop)(struct device *dev);
 115   int                     (*hard_start_xmit) (struct sk_buff *skb,
 116                                               struct device *dev);
 117   int                     (*hard_header) (unsigned char *buff,
 118                                           struct device *dev,
 119                                           unsigned short type,
 120                                           void *daddr,
 121                                           void *saddr,
 122                                           unsigned len,
 123                                           struct sk_buff *skb);
 124   int                     (*rebuild_header)(void *eth, struct device *dev,
 125                                 unsigned long raddr, struct sk_buff *skb);
 126   unsigned short          (*type_trans) (struct sk_buff *skb,
 127                                          struct device *dev);
 128 #define HAVE_MULTICAST                   
 129   void                    (*set_multicast_list)(struct device *dev,
 130                                          int num_addrs, void *addrs);
 131 #define HAVE_SET_MAC_ADDR                
 132   int                     (*set_mac_address)(struct device *dev, void *addr);
 133 #define HAVE_PRIVATE_IOCTL
 134   int                     (*do_ioctl)(struct device *dev, struct ifreq *ifr);
 135 };
 136 
 137 
 138 struct packet_type {
 139   unsigned short        type;   /* This is really htons(ether_type). */
 140   unsigned short        copy:1;
 141   int                   (*func) (struct sk_buff *, struct device *,
 142                                  struct packet_type *);
 143   void                  *data;
 144   struct packet_type    *next;
 145 };
 146 
 147 
 148 #ifdef __KERNEL__
 149 
 150 /* Used by dev_rint */
 151 #define IN_SKBUFF       1
 152 
 153 extern volatile char in_bh;
 154 
 155 extern struct device    *dev_base;
 156 extern struct packet_type *ptype_base;
 157 
 158 
 159 extern int              ip_addr_match(unsigned long addr1, unsigned long addr2);
 160 extern int              ip_chk_addr(unsigned long addr);
 161 extern struct device    *ip_dev_check(unsigned long daddr);
 162 extern unsigned long    ip_my_addr(void);
 163 extern unsigned long    ip_get_mask(unsigned long addr);
 164 
 165 extern void             dev_add_pack(struct packet_type *pt);
 166 extern void             dev_remove_pack(struct packet_type *pt);
 167 extern struct device    *dev_get(char *name);
 168 extern int              dev_open(struct device *dev);
 169 extern int              dev_close(struct device *dev);
 170 extern void             dev_queue_xmit(struct sk_buff *skb, struct device *dev,
 171                                        int pri);
 172 #define HAVE_NETIF_RX 1
 173 extern void             netif_rx(struct sk_buff *skb);
 174 /* The old interface to netif_rx(). */
 175 extern int              dev_rint(unsigned char *buff, long len, int flags,
 176                                  struct device * dev);
 177 extern void             dev_transmit(void);
 178 extern int              in_inet_bh(void);
 179 extern void             inet_bh(void *tmp);
 180 extern void             dev_tint(struct device *dev);
 181 extern int              dev_get_info(char *buffer, char **start, off_t offset, int length);
 182 extern int              dev_ioctl(unsigned int cmd, void *);
 183 
 184 extern void             dev_init(void);
 185 
 186 /* This function lives elsewhere (drivers/net/net_init.c but is related) */
 187 
 188 extern void             ether_setup(struct device *dev);
 189 
 190 #endif /* __KERNEL__ */
 191 
 192 #endif  /* _LINUX_DEV_H */

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