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 #define IS_MULTICAST    5               /* Multicast IP address */
  41 
  42 /*
  43  *      We tag these structures with multicasts.
  44  */
  45  
  46 struct dev_mc_list
  47 {       
  48         struct dev_mc_list *next;
  49         char dmi_addr[MAX_ADDR_LEN];
  50         unsigned short dmi_addrlen;
  51         unsigned short dmi_users;
  52 };
  53 
  54 /*
  55  * The DEVICE structure.
  56  * Actually, this whole structure is a big mistake.  It mixes I/O
  57  * data with strictly "high-level" data, and it has to know about
  58  * almost every data structure used in the INET module.  
  59  */
  60 struct device 
  61 {
  62 
  63   /*
  64    * This is the first field of the "visible" part of this structure
  65    * (i.e. as seen by users in the "Space.c" file).  It is the name
  66    * the interface.
  67    */
  68   char                    *name;
  69 
  70   /* I/O specific fields - FIXME: Merge these and struct ifmap into one */
  71   unsigned long           rmem_end;             /* shmem "recv" end     */
  72   unsigned long           rmem_start;           /* shmem "recv" start   */
  73   unsigned long           mem_end;              /* sahared mem end      */
  74   unsigned long           mem_start;            /* shared mem start     */
  75   unsigned long           base_addr;            /* device I/O address   */
  76   unsigned char           irq;                  /* device IRQ number    */
  77 
  78   /* Low-level status flags. */
  79   volatile unsigned char  start,                /* start an operation   */
  80                           tbusy,                /* transmitter busy     */
  81                           interrupt;            /* interrupt arrived    */
  82 
  83   struct device           *next;
  84 
  85   /* The device initialization function. Called only once. */
  86   int                     (*init)(struct device *dev);
  87 
  88   /* Some hardware also needs these fields, but they are not part of the
  89      usual set specified in Space.c. */
  90   unsigned char           if_port;              /* Selectable AUI, TP,..*/
  91   unsigned char           dma;                  /* DMA channel          */
  92 
  93   struct enet_statistics* (*get_stats)(struct device *dev);
  94 
  95   /*
  96    * This marks the end of the "visible" part of the structure. All
  97    * fields hereafter are internal to the system, and may change at
  98    * will (read: may be cleaned up at will).
  99    */
 100 
 101   /* These may be needed for future network-power-down code. */
 102   unsigned long           trans_start;  /* Time (in jiffies) of last Tx */
 103   unsigned long           last_rx;      /* Time of last Rx              */
 104 
 105   unsigned short          flags;        /* interface flags (a la BSD)   */
 106   unsigned short          family;       /* address family ID (AF_INET)  */
 107   unsigned short          metric;       /* routing metric (not used)    */
 108   unsigned short          mtu;          /* interface MTU value          */
 109   unsigned short          type;         /* interface hardware type      */
 110   unsigned short          hard_header_len;      /* hardware hdr length  */
 111   void                    *priv;        /* pointer to private data      */
 112 
 113   /* Interface address info. */
 114   unsigned char           broadcast[MAX_ADDR_LEN];      /* hw bcast add */
 115   unsigned char           dev_addr[MAX_ADDR_LEN];       /* hw address   */
 116   unsigned char           addr_len;     /* hardware address length      */
 117   unsigned long           pa_addr;      /* protocol address             */
 118   unsigned long           pa_brdaddr;   /* protocol broadcast addr      */
 119   unsigned long           pa_dstaddr;   /* protocol P-P other side addr */
 120   unsigned long           pa_mask;      /* protocol netmask             */
 121   unsigned short          pa_alen;      /* protocol address length      */
 122 
 123   struct dev_mc_list     *mc_list;      /* Multicast mac addresses      */
 124   int                    mc_count;      /* Number of installed mcasts   */
 125   
 126   struct ip_mc_list      *ip_mc_list;   /* IP multicast filter chain    */
 127     
 128   /* For load balancing driver pair support */
 129   
 130   unsigned long            pkt_queue;   /* Packets queued */
 131   struct device           *slave;       /* Slave device */
 132   
 133 
 134   /* Pointer to the interface buffers. */
 135   struct sk_buff_head     buffs[DEV_NUMBUFFS];
 136 
 137   /* Pointers to interface service routines. */
 138   int                     (*open)(struct device *dev);
 139   int                     (*stop)(struct device *dev);
 140   int                     (*hard_start_xmit) (struct sk_buff *skb,
 141                                               struct device *dev);
 142   int                     (*hard_header) (unsigned char *buff,
 143                                           struct device *dev,
 144                                           unsigned short type,
 145                                           void *daddr,
 146                                           void *saddr,
 147                                           unsigned len,
 148                                           struct sk_buff *skb);
 149   int                     (*rebuild_header)(void *eth, struct device *dev,
 150                                 unsigned long raddr, struct sk_buff *skb);
 151   unsigned short          (*type_trans) (struct sk_buff *skb,
 152                                          struct device *dev);
 153 #define HAVE_MULTICAST                   
 154   void                    (*set_multicast_list)(struct device *dev,
 155                                          int num_addrs, void *addrs);
 156 #define HAVE_SET_MAC_ADDR                
 157   int                     (*set_mac_address)(struct device *dev, void *addr);
 158 #define HAVE_PRIVATE_IOCTL
 159   int                     (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd);
 160 #define HAVE_SET_CONFIG
 161   int                     (*set_config)(struct device *dev, struct ifmap *map);
 162   
 163 };
 164 
 165 
 166 struct packet_type {
 167   unsigned short        type;   /* This is really htons(ether_type). */
 168   struct device *       dev;
 169   int                   (*func) (struct sk_buff *, struct device *,
 170                                  struct packet_type *);
 171   void                  *data;
 172   struct packet_type    *next;
 173 };
 174 
 175 
 176 #ifdef __KERNEL__
 177 
 178 #include <linux/notifier.h>
 179 
 180 /* Used by dev_rint */
 181 #define IN_SKBUFF       1
 182 
 183 extern volatile char in_bh;
 184 
 185 extern struct device    loopback_dev;
 186 extern struct device    *dev_base;
 187 extern struct packet_type *ptype_base;
 188 
 189 
 190 extern int              ip_addr_match(unsigned long addr1, unsigned long addr2);
 191 extern int              ip_chk_addr(unsigned long addr);
 192 extern struct device    *ip_dev_check(unsigned long daddr);
 193 extern unsigned long    ip_my_addr(void);
 194 extern unsigned long    ip_get_mask(unsigned long addr);
 195 
 196 extern void             dev_add_pack(struct packet_type *pt);
 197 extern void             dev_remove_pack(struct packet_type *pt);
 198 extern struct device    *dev_get(char *name);
 199 extern int              dev_open(struct device *dev);
 200 extern int              dev_close(struct device *dev);
 201 extern void             dev_queue_xmit(struct sk_buff *skb, struct device *dev,
 202                                        int pri);
 203 #define HAVE_NETIF_RX 1
 204 extern void             netif_rx(struct sk_buff *skb);
 205 /* The old interface to netif_rx(). */
 206 extern int              dev_rint(unsigned char *buff, long len, int flags,
 207                                  struct device * dev);
 208 extern void             dev_transmit(void);
 209 extern int              in_net_bh(void);
 210 extern void             net_bh(void *tmp);
 211 extern void             dev_tint(struct device *dev);
 212 extern int              dev_get_info(char *buffer, char **start, off_t offset, int length);
 213 extern int              dev_ioctl(unsigned int cmd, void *);
 214 
 215 extern void             dev_init(void);
 216 
 217 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
 218 
 219 extern void             ether_setup(struct device *dev);
 220 extern int              ether_config(struct device *dev, struct ifmap *map);
 221 /* Support for loadable net-drivers */
 222 extern int              register_netdev(struct device *dev);
 223 extern void             unregister_netdev(struct device *dev);
 224 extern int              register_netdevice_notifier(struct notifier_block *nb);
 225 extern int              unregister_netdevice_notifier(struct notifier_block *nb);
 226 /* Functions used for multicast support */
 227 extern void             dev_mc_upload(struct device *dev);
 228 extern void             dev_mc_delete(struct device *dev, void *addr, int alen, int all);
 229 extern void             dev_mc_add(struct device *dev, void *addr, int alen, int newonly);
 230 extern void             dev_mc_discard(struct device *dev);
 231 /* This is the wrong place but it'll do for the moment */
 232 extern void             ip_mc_allhost(struct device *dev);
 233 #endif /* __KERNEL__ */
 234 
 235 #endif  /* _LINUX_DEV_H */

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