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

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