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 #defineDEV_NUMBUFFS 3
32 #defineMAX_ADDR_LEN 7
33 #defineMAX_HEADER 18
34
35 #defineIS_MYADDR 1 /* address is (one of) our own */ 36 #define IS_LOOPBACK 2 /* address is for LOOPBACK */ 37 #defineIS_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 structdevice 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 unsignedlongrmem_end; /* shmem "recv" end */ 58 unsignedlongrmem_start; /* shmem "recv" start */ 59 unsignedlongmem_end; /* sahared mem end */ 60 unsignedlongmem_start; /* shared mem start */ 61 unsignedshortbase_addr; /* device I/O address */ 62 unsignedcharirq; /* device IRQ number */ 63
64 /* Low-level status flags. */ 65 volatileunsignedcharstart, /* start an operation */ 66 tbusy, /* transmitter busy */ 67 interrupt; /* interrupt arrived */ 68
69 structdevice *next;
70
71 /* The device initialization function. Called only once. */ 72 int (*init)(structdevice *dev);
73
74 /* Some hardware also needs these fields, but they are not part of the 75 usual set specified in Space.c. */ 76 unsignedcharif_port; /* Selectable AUI, TP,..*/ 77 unsignedchardma; /* DMA channel */ 78
79 structenet_statistics* (*get_stats)(structdevice *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 unsignedlongtrans_start; /* Time (in jiffies) of last Tx */ 89 unsignedlonglast_rx; /* Time of last Rx */ 90
91 unsignedshortflags; /* interface flags (a la BSD) */ 92 unsignedshortfamily; /* address family ID (AF_INET) */ 93 unsignedshortmetric; /* routing metric (not used) */ 94 unsignedshortmtu; /* interface MTU value */ 95 unsignedshorttype; /* interface hardware type */ 96 unsignedshorthard_header_len; /* hardware hdr length */ 97 void *priv; /* pointer to private data */ 98
99 /* Interface address info. */ 100 unsignedcharbroadcast[MAX_ADDR_LEN]; /* hw bcast add */ 101 unsignedchardev_addr[MAX_ADDR_LEN]; /* hw address */ 102 unsignedcharaddr_len; /* harfware address length */ 103 unsignedlongpa_addr; /* protocol address */ 104 unsignedlongpa_brdaddr; /* protocol broadcast addr */ 105 unsignedlongpa_dstaddr; /* protocol P-P other side addr */ 106 unsignedlongpa_mask; /* protocol netmask */ 107 unsignedshortpa_alen; /* protocol address length */ 108
109 /* Pointer to the interface buffers. */ 110 structsk_buff_headbuffs[DEV_NUMBUFFS];
111
112 /* Pointers to interface service routines. */ 113 int (*open)(structdevice *dev);
114 int (*stop)(structdevice *dev);
115 int (*hard_start_xmit) (structsk_buff *skb,
116 structdevice *dev);
117 int (*hard_header) (unsignedchar *buff,
118 structdevice *dev,
119 unsignedshorttype,
120 void *daddr,
121 void *saddr,
122 unsignedlen,
123 structsk_buff *skb);
124 int (*rebuild_header)(void *eth, structdevice *dev,
125 unsignedlongraddr, structsk_buff *skb);
126 unsignedshort (*type_trans) (structsk_buff *skb,
127 structdevice *dev);
128 #defineHAVE_MULTICAST 129 void (*set_multicast_list)(structdevice *dev,
130 intnum_addrs, void *addrs);
131 #defineHAVE_SET_MAC_ADDR 132 int (*set_mac_address)(structdevice *dev, void *addr);
133 #define HAVE_PRIVATE_IOCTL
134 int (*do_ioctl)(structdevice *dev, structifreq *ifr);
135 };
136
137
138 structpacket_type{ 139 unsignedshorttype; /* This is really htons(ether_type). */ 140 unsignedshortcopy:1;
141 int (*func) (structsk_buff *, structdevice *,
142 structpacket_type *);
143 void *data;
144 structpacket_type *next;
145 };
146
147
148 #ifdef__KERNEL__ 149
150 /* Used by dev_rint */ 151 #defineIN_SKBUFF 1
152
153 externvolatilecharin_bh;
154
155 externstructdevice *dev_base;
156 externstructpacket_type *ptype_base;
157
158
159 externintip_addr_match(unsignedlongaddr1, unsignedlongaddr2);
160 externintip_chk_addr(unsignedlongaddr);
161 externstructdevice *ip_dev_check(unsignedlongdaddr);
162 externunsignedlongip_my_addr(void);
163 externunsignedlongip_get_mask(unsignedlongaddr);
164
165 externvoiddev_add_pack(structpacket_type *pt);
166 externvoiddev_remove_pack(structpacket_type *pt);
167 externstructdevice *dev_get(char *name);
168 externintdev_open(structdevice *dev);
169 externintdev_close(structdevice *dev);
170 externvoiddev_queue_xmit(structsk_buff *skb, structdevice *dev,
171 intpri);
172 #defineHAVE_NETIF_RX 1
173 externvoidnetif_rx(structsk_buff *skb);
174 /* The old interface to netif_rx(). */ 175 externintdev_rint(unsignedchar *buff, longlen, intflags,
176 structdevice * dev);
177 externvoiddev_transmit(void);
178 externintin_inet_bh(void);
179 externvoidinet_bh(void *tmp);
180 externvoiddev_tint(structdevice *dev);
181 externintdev_get_info(char *buffer, char **start, off_toffset, intlength);
182 externintdev_ioctl(unsignedintcmd, void *);
183
184 externvoiddev_init(void);
185
186 /* This function lives elsewhere (drivers/net/net_init.c but is related) */ 187
188 externvoidether_setup(structdevice *dev);
189
190 #endif/* __KERNEL__ */ 191
192 #endif/* _LINUX_DEV_H */