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 #defineDEV_NUMBUFFS 3
33 #defineMAX_ADDR_LEN 7
34 #ifndefCONFIG_AX25 35 #ifndefCONFIG_TR 36 #defineMAX_HEADER 32 /* We really need about 18 worst case .. so 32 is aligned */ 37 #else 38 #defineMAX_HEADER 48 /* Token Ring header needs 40 bytes ... 48 is aligned */ 39 #endif 40 #else 41 #defineMAX_HEADER 96 /* AX.25 + NetROM */ 42 #endif 43
44 #defineIS_MYADDR 1 /* address is (one of) our own */ 45 #define IS_LOOPBACK 2 /* address is for LOOPBACK */ 46 #defineIS_BROADCAST 3 /* address is a valid broadcast */ 47 #define IS_INVBCAST 4 /* Wrong netmask bcast not for us (unused)*/ 48 #defineIS_MULTICAST 5 /* Multicast IP address */ 49
50 /* 51 * We tag these structures with multicasts. 52 */ 53
54 structdev_mc_list 55 { 56 structdev_mc_list *next;
57 chardmi_addr[MAX_ADDR_LEN];
58 unsignedshortdmi_addrlen;
59 unsignedshortdmi_users;
60 };
61
62 /* 63 * The DEVICE structure. 64 * Actually, this whole structure is a big mistake. It mixes I/O 65 * data with strictly "high-level" data, and it has to know about 66 * almost every data structure used in the INET module. 67 */ 68 structdevice 69 { 70
71 /* 72 * This is the first field of the "visible" part of this structure 73 * (i.e. as seen by users in the "Space.c" file). It is the name 74 * the interface. 75 */ 76 char *name;
77
78 /* I/O specific fields - FIXME: Merge these and struct ifmap into one */ 79 unsignedlongrmem_end; /* shmem "recv" end */ 80 unsignedlongrmem_start; /* shmem "recv" start */ 81 unsignedlongmem_end; /* shared mem end */ 82 unsignedlongmem_start; /* shared mem start */ 83 unsignedlongbase_addr; /* device I/O address */ 84 unsignedcharirq; /* device IRQ number */ 85
86 /* Low-level status flags. */ 87 volatileunsignedcharstart, /* start an operation */ 88 interrupt; /* interrupt arrived */ 89 unsignedlongtbusy; /* transmitter busy must be long for bitops */ 90
91 structdevice *next;
92
93 /* The device initialization function. Called only once. */ 94 int (*init)(structdevice *dev);
95
96 /* Some hardware also needs these fields, but they are not part of the 97 usual set specified in Space.c. */ 98 unsignedcharif_port; /* Selectable AUI, TP,..*/ 99 unsignedchardma; /* DMA channel */ 100
101 structenet_statistics* (*get_stats)(structdevice *dev);
102
103 /* 104 * This marks the end of the "visible" part of the structure. All 105 * fields hereafter are internal to the system, and may change at 106 * will (read: may be cleaned up at will). 107 */ 108
109 /* These may be needed for future network-power-down code. */ 110 unsignedlongtrans_start; /* Time (in jiffies) of last Tx */ 111 unsignedlonglast_rx; /* Time of last Rx */ 112
113 unsignedshortflags; /* interface flags (a la BSD) */ 114 unsignedshortfamily; /* address family ID (AF_INET) */ 115 unsignedshortmetric; /* routing metric (not used) */ 116 unsignedshortmtu; /* interface MTU value */ 117 unsignedshorttype; /* interface hardware type */ 118 unsignedshorthard_header_len; /* hardware hdr length */ 119 void *priv; /* pointer to private data */ 120
121 /* Interface address info. */ 122 unsignedcharbroadcast[MAX_ADDR_LEN]; /* hw bcast add */ 123 unsignedcharpad; /* make dev_addr aligned to 8 bytes */ 124 unsignedchardev_addr[MAX_ADDR_LEN]; /* hw address */ 125 unsignedcharaddr_len; /* hardware address length */ 126 unsignedlongpa_addr; /* protocol address */ 127 unsignedlongpa_brdaddr; /* protocol broadcast addr */ 128 unsignedlongpa_dstaddr; /* protocol P-P other side addr */ 129 unsignedlongpa_mask; /* protocol netmask */ 130 unsignedshortpa_alen; /* protocol address length */ 131
132 structdev_mc_list *mc_list; /* Multicast mac addresses */ 133 intmc_count; /* Number of installed mcasts */ 134
135 structip_mc_list *ip_mc_list; /* IP multicast filter chain */ 136
137 /* For load balancing driver pair support */ 138
139 unsignedlong pkt_queue; /* Packets queued */ 140 structdevice *slave; /* Slave device */ 141
142
143 /* Pointer to the interface buffers. */ 144 structsk_buff_headbuffs[DEV_NUMBUFFS];
145
146 /* Pointers to interface service routines. */ 147 int (*open)(structdevice *dev);
148 int (*stop)(structdevice *dev);
149 int (*hard_start_xmit) (structsk_buff *skb,
150 structdevice *dev);
151 int (*hard_header) (structsk_buff *skb,
152 structdevice *dev,
153 unsignedshorttype,
154 void *daddr,
155 void *saddr,
156 unsignedlen);
157 int (*rebuild_header)(void *eth, structdevice *dev,
158 unsignedlongraddr, structsk_buff *skb);
159 #defineHAVE_MULTICAST 160 void (*set_multicast_list)(structdevice *dev,
161 intnum_addrs, void *addrs);
162 #defineHAVE_SET_MAC_ADDR 163 int (*set_mac_address)(structdevice *dev, void *addr);
164 #define HAVE_PRIVATE_IOCTL
165 int (*do_ioctl)(structdevice *dev, structifreq *ifr, intcmd);
166 #define HAVE_SET_CONFIG
167 int (*set_config)(structdevice *dev, structifmap *map);
168 void (*header_cache)(structdevice *dev, structsock *sk, unsignedlongsaddr, unsignedlongdaddr);
169 };
170
171
172 structpacket_type{ 173 unsignedshorttype; /* This is really htons(ether_type). */ 174 structdevice * dev;
175 int (*func) (structsk_buff *, structdevice *,
176 structpacket_type *);
177 void *data;
178 structpacket_type *next;
179 };
180
181
182 #ifdef__KERNEL__ 183
184 #include <linux/notifier.h>
185
186 /* Used by dev_rint */ 187 #defineIN_SKBUFF 1
188
189 externvolatilecharin_bh;
190
191 externstructdeviceloopback_dev;
192 externstructdevice *dev_base;
193 externstructpacket_type *ptype_base[16];
194
195
196 externint ip_addr_match(unsignedlong addr1, unsignedlong addr2);
197 externintip_chk_addr(unsignedlongaddr);
198 externstructdevice *ip_dev_check(unsignedlongdaddr);
199 externunsignedlongip_my_addr(void);
200 externunsignedlongip_get_mask(unsignedlongaddr);
201 externstructdevice *ip_dev_find(unsignedlongaddr);
202
203 externvoiddev_add_pack(structpacket_type *pt);
204 externvoiddev_remove_pack(structpacket_type *pt);
205 externstructdevice *dev_get(constchar *name);
206 externintdev_open(structdevice *dev);
207 externintdev_close(structdevice *dev);
208 externvoiddev_queue_xmit(structsk_buff *skb, structdevice *dev,
209 intpri);
210 #define HAVE_NETIF_RX 1
211 externvoidnetif_rx(structsk_buff *skb);
212 /* The old interface to netif_rx(). */ 213 externintdev_rint(unsignedchar *buff, longlen, intflags,
214 structdevice * dev);
215 externvoiddev_transmit(void);
216 externintin_net_bh(void);
217 externvoidnet_bh(void *tmp);
218 externvoiddev_tint(structdevice *dev);
219 externintdev_get_info(char *buffer, char **start, off_toffset, intlength, intdummy);
220 externintdev_ioctl(unsignedintcmd, void *);
221
222 externvoiddev_init(void);
223
224 /* Locking protection for page faults during outputs to devices unloaded during the fault */ 225
226 externintdev_lockct;
227
228 /* 229 * These two dont currently need to be interrupt safe 230 * but they may do soon. Do it properly anyway. 231 */ 232
233 extern__inline__voiddev_lock_list(void)
/* */ 234 { 235 unsignedlongflags;
236 save_flags(flags);
237 cli();
238 dev_lockct++;
239 restore_flags(flags);
240 } 241
242 extern__inline__voiddev_unlock_list(void)
/* */ 243 { 244 unsignedlongflags;
245 save_flags(flags);
246 cli();
247 dev_lockct--;
248 restore_flags(flags);
249 } 250
251 /* 252 * This almost never occurs, isnt in performance critical paths 253 * and we can thus be relaxed about it 254 */ 255
256 extern__inline__voiddev_lock_wait(void)
/* */ 257 { 258 while(dev_lockct)
259 schedule();
260 } 261
262
263 /* These functions live elsewhere (drivers/net/net_init.c, but related) */ 264
265 externvoidether_setup(structdevice *dev);
266 externvoidtr_setup(structdevice *dev);
267 externintether_config(structdevice *dev, structifmap *map);
268 /* Support for loadable net-drivers */ 269 externintregister_netdev(structdevice *dev);
270 externvoidunregister_netdev(structdevice *dev);
271 externintregister_netdevice_notifier(structnotifier_block *nb);
272 externintunregister_netdevice_notifier(structnotifier_block *nb);
273 /* Functions used for multicast support */ 274 externvoiddev_mc_upload(structdevice *dev);
275 externvoiddev_mc_delete(structdevice *dev, void *addr, intalen, intall);
276 externvoiddev_mc_add(structdevice *dev, void *addr, intalen, intnewonly);
277 externvoiddev_mc_discard(structdevice *dev);
278 /* This is the wrong place but it'll do for the moment */ 279 externvoidip_mc_allhost(structdevice *dev);
280 #endif/* __KERNEL__ */ 281
282 #endif/* _LINUX_DEV_H */