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