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 unsignedchardev_addr[MAX_ADDR_LEN]; /* hw address */ 120 unsignedcharaddr_len; /* hardware address length */ 121 unsignedlongpa_addr; /* protocol address */ 122 unsignedlongpa_brdaddr; /* protocol broadcast addr */ 123 unsignedlongpa_dstaddr; /* protocol P-P other side addr */ 124 unsignedlongpa_mask; /* protocol netmask */ 125 unsignedshortpa_alen; /* protocol address length */ 126
127 structdev_mc_list *mc_list; /* Multicast mac addresses */ 128 intmc_count; /* Number of installed mcasts */ 129
130 structip_mc_list *ip_mc_list; /* IP multicast filter chain */ 131
132 /* For load balancing driver pair support */ 133
134 unsignedlong pkt_queue; /* Packets queued */ 135 structdevice *slave; /* Slave device */ 136
137
138 /* Pointer to the interface buffers. */ 139 structsk_buff_headbuffs[DEV_NUMBUFFS];
140
141 /* Pointers to interface service routines. */ 142 int (*open)(structdevice *dev);
143 int (*stop)(structdevice *dev);
144 int (*hard_start_xmit) (structsk_buff *skb,
145 structdevice *dev);
146 int (*hard_header) (structsk_buff *skb,
147 structdevice *dev,
148 unsignedshorttype,
149 void *daddr,
150 void *saddr,
151 unsignedlen);
152 int (*rebuild_header)(void *eth, structdevice *dev,
153 unsignedlongraddr, structsk_buff *skb);
154 #defineHAVE_MULTICAST 155 void (*set_multicast_list)(structdevice *dev,
156 intnum_addrs, void *addrs);
157 #defineHAVE_SET_MAC_ADDR 158 int (*set_mac_address)(structdevice *dev, void *addr);
159 #define HAVE_PRIVATE_IOCTL
160 int (*do_ioctl)(structdevice *dev, structifreq *ifr, intcmd);
161 #define HAVE_SET_CONFIG
162 int (*set_config)(structdevice *dev, structifmap *map);
163 void (*header_cache)(structdevice *dev, structsock *sk, unsignedlongsaddr, unsignedlongdaddr);
164 };
165
166
167 structpacket_type{ 168 unsignedshorttype; /* This is really htons(ether_type). */ 169 structdevice * dev;
170 int (*func) (structsk_buff *, structdevice *,
171 structpacket_type *);
172 void *data;
173 structpacket_type *next;
174 };
175
176
177 #ifdef__KERNEL__ 178
179 #include <linux/notifier.h>
180
181 /* Used by dev_rint */ 182 #defineIN_SKBUFF 1
183
184 externvolatilecharin_bh;
185
186 externstructdeviceloopback_dev;
187 externstructdevice *dev_base;
188 externstructpacket_type *ptype_base[16];
189
190
191 externint ip_addr_match(unsignedlong addr1, unsignedlong addr2);
192 externintip_chk_addr(unsignedlongaddr);
193 externstructdevice *ip_dev_check(unsignedlongdaddr);
194 externunsignedlongip_my_addr(void);
195 externunsignedlongip_get_mask(unsignedlongaddr);
196
197 externvoiddev_add_pack(structpacket_type *pt);
198 externvoiddev_remove_pack(structpacket_type *pt);
199 externstructdevice *dev_get(constchar *name);
200 externintdev_open(structdevice *dev);
201 externintdev_close(structdevice *dev);
202 externvoiddev_queue_xmit(structsk_buff *skb, structdevice *dev,
203 intpri);
204 #define HAVE_NETIF_RX 1
205 externvoidnetif_rx(structsk_buff *skb);
206 /* The old interface to netif_rx(). */ 207 externintdev_rint(unsignedchar *buff, longlen, intflags,
208 structdevice * dev);
209 externvoiddev_transmit(void);
210 externintin_net_bh(void);
211 externvoidnet_bh(void *tmp);
212 externvoiddev_tint(structdevice *dev);
213 externintdev_get_info(char *buffer, char **start, off_toffset, intlength, intdummy);
214 externintdev_ioctl(unsignedintcmd, void *);
215
216 externvoiddev_init(void);
217
218 /* Locking protection for page faults during outputs to devices unloaded during the fault */ 219
220 externintdev_lockct;
221
222 /* 223 * These two dont currently need to be interrupt safe 224 * but they may do soon. Do it properly anyway. 225 */ 226
227 extern__inline__void dev_lock_list(void)
/* */ 228 { 229 unsignedlongflags;
230 save_flags(flags);
231 cli();
232 dev_lockct++;
233 restore_flags(flags);
234 } 235
236 extern__inline__void dev_unlock_list(void)
/* */ 237 { 238 unsignedlongflags;
239 save_flags(flags);
240 cli();
241 dev_lockct--;
242 restore_flags(flags);
243 } 244
245 /* 246 * This almost never occurs, isnt in performance critical paths 247 * and we can thus be relaxed about it 248 */ 249
250 extern__inline__void dev_lock_wait(void)
/* */ 251 { 252 while(dev_lockct)
253 schedule();
254 } 255
256
257 /* These functions live elsewhere (drivers/net/net_init.c, but related) */ 258
259 externvoidether_setup(structdevice *dev);
260 externvoidtr_setup(structdevice *dev);
261 externintether_config(structdevice *dev, structifmap *map);
262 /* Support for loadable net-drivers */ 263 externintregister_netdev(structdevice *dev);
264 externvoidunregister_netdev(structdevice *dev);
265 externintregister_netdevice_notifier(structnotifier_block *nb);
266 externintunregister_netdevice_notifier(structnotifier_block *nb);
267 /* Functions used for multicast support */ 268 externvoiddev_mc_upload(structdevice *dev);
269 externvoiddev_mc_delete(structdevice *dev, void *addr, intalen, intall);
270 externvoiddev_mc_add(structdevice *dev, void *addr, intalen, intnewonly);
271 externvoiddev_mc_discard(structdevice *dev);
272 /* This is the wrong place but it'll do for the moment */ 273 externvoidip_mc_allhost(structdevice *dev);
274 #endif/* __KERNEL__ */ 275
276 #endif/* _LINUX_DEV_H */