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