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

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