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

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