1 |
1633 |
jcastillo |
/*
|
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.11 07/31/96
|
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 |
|
|
* Lawrence V. Stefani, <stefani@lkg.dec.com>
|
17 |
|
|
*
|
18 |
|
|
* This program is free software; you can redistribute it and/or
|
19 |
|
|
* modify it under the terms of the GNU General Public License
|
20 |
|
|
* as published by the Free Software Foundation; either version
|
21 |
|
|
* 2 of the License, or (at your option) any later version.
|
22 |
|
|
*
|
23 |
|
|
* Moved to /usr/include/linux for NET3
|
24 |
|
|
* Added extern for fddi_setup()
|
25 |
|
|
*/
|
26 |
|
|
#ifndef _LINUX_NETDEVICE_H
|
27 |
|
|
#define _LINUX_NETDEVICE_H
|
28 |
|
|
|
29 |
|
|
#include <linux/config.h>
|
30 |
|
|
#include <linux/if.h>
|
31 |
|
|
#include <linux/if_ether.h>
|
32 |
|
|
|
33 |
|
|
/* for future expansion when we will have different priorities. */
|
34 |
|
|
#define DEV_NUMBUFFS 3
|
35 |
|
|
#define MAX_ADDR_LEN 7
|
36 |
|
|
#ifndef CONFIG_AX25
|
37 |
|
|
#ifndef CONFIG_AX25_MODULE
|
38 |
|
|
#ifndef CONFIG_TR
|
39 |
|
|
#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE)
|
40 |
|
|
#define MAX_HEADER 32 /* We really need about 18 worst case .. so 32 is aligned */
|
41 |
|
|
#else
|
42 |
|
|
#define MAX_HEADER 80 /* We need to allow for having tunnel headers */
|
43 |
|
|
#endif /* IPIP */
|
44 |
|
|
#else
|
45 |
|
|
#define MAX_HEADER 48 /* Token Ring header needs 40 bytes ... 48 is aligned */
|
46 |
|
|
#endif /* TR */
|
47 |
|
|
#else
|
48 |
|
|
#define MAX_HEADER 96 /* AX.25 + NET/ROM module*/
|
49 |
|
|
#endif /* AX.25 module */
|
50 |
|
|
#else
|
51 |
|
|
#define MAX_HEADER 96 /* AX.25 + NET/ROM */
|
52 |
|
|
#endif /* AX.25 */
|
53 |
|
|
|
54 |
|
|
#define IS_MYADDR 1 /* address is (one of) our own */
|
55 |
|
|
#define IS_LOOPBACK 2 /* address is for LOOPBACK */
|
56 |
|
|
#define IS_BROADCAST 3 /* address is a valid broadcast */
|
57 |
|
|
#define IS_INVBCAST 4 /* Wrong netmask bcast not for us (unused)*/
|
58 |
|
|
#define IS_MULTICAST 5 /* Multicast IP address */
|
59 |
|
|
|
60 |
|
|
#ifdef __KERNEL__
|
61 |
|
|
|
62 |
|
|
#include <linux/skbuff.h>
|
63 |
|
|
|
64 |
|
|
/*
|
65 |
|
|
* We tag multicasts with these structures.
|
66 |
|
|
*/
|
67 |
|
|
|
68 |
|
|
struct dev_mc_list
|
69 |
|
|
{
|
70 |
|
|
struct dev_mc_list *next;
|
71 |
|
|
char dmi_addr[MAX_ADDR_LEN];
|
72 |
|
|
unsigned short dmi_addrlen;
|
73 |
|
|
unsigned short dmi_users;
|
74 |
|
|
};
|
75 |
|
|
|
76 |
|
|
struct hh_cache
|
77 |
|
|
{
|
78 |
|
|
struct hh_cache *hh_next;
|
79 |
|
|
void *hh_arp; /* Opaque pointer, used by
|
80 |
|
|
* any address resolution module,
|
81 |
|
|
* not only ARP.
|
82 |
|
|
*/
|
83 |
|
|
int hh_refcnt; /* number of users */
|
84 |
|
|
unsigned short hh_type; /* protocol identifier, f.e ETH_P_IP */
|
85 |
|
|
char hh_uptodate; /* hh_data is valid */
|
86 |
|
|
char hh_data[16]; /* cached hardware header */
|
87 |
|
|
};
|
88 |
|
|
|
89 |
|
|
/*
|
90 |
|
|
* The DEVICE structure.
|
91 |
|
|
* Actually, this whole structure is a big mistake. It mixes I/O
|
92 |
|
|
* data with strictly "high-level" data, and it has to know about
|
93 |
|
|
* almost every data structure used in the INET module.
|
94 |
|
|
*/
|
95 |
|
|
struct device
|
96 |
|
|
{
|
97 |
|
|
|
98 |
|
|
/*
|
99 |
|
|
* This is the first field of the "visible" part of this structure
|
100 |
|
|
* (i.e. as seen by users in the "Space.c" file). It is the name
|
101 |
|
|
* the interface.
|
102 |
|
|
*/
|
103 |
|
|
char *name;
|
104 |
|
|
|
105 |
|
|
/* I/O specific fields - FIXME: Merge these and struct ifmap into one */
|
106 |
|
|
unsigned long rmem_end; /* shmem "recv" end */
|
107 |
|
|
unsigned long rmem_start; /* shmem "recv" start */
|
108 |
|
|
unsigned long mem_end; /* shared mem end */
|
109 |
|
|
unsigned long mem_start; /* shared mem start */
|
110 |
|
|
unsigned long base_addr; /* device I/O address */
|
111 |
|
|
unsigned char irq; /* device IRQ number */
|
112 |
|
|
|
113 |
|
|
/* Low-level status flags. */
|
114 |
|
|
volatile unsigned char start, /* start an operation */
|
115 |
|
|
interrupt; /* interrupt arrived */
|
116 |
|
|
unsigned long tbusy; /* transmitter busy must be long for bitops */
|
117 |
|
|
|
118 |
|
|
struct device *next;
|
119 |
|
|
|
120 |
|
|
/* The device initialization function. Called only once. */
|
121 |
|
|
int (*init)(struct device *dev);
|
122 |
|
|
|
123 |
|
|
/* Some hardware also needs these fields, but they are not part of the
|
124 |
|
|
usual set specified in Space.c. */
|
125 |
|
|
unsigned char if_port; /* Selectable AUI, TP,..*/
|
126 |
|
|
unsigned char dma; /* DMA channel */
|
127 |
|
|
|
128 |
|
|
struct enet_statistics* (*get_stats)(struct device *dev);
|
129 |
|
|
|
130 |
|
|
/*
|
131 |
|
|
* This marks the end of the "visible" part of the structure. All
|
132 |
|
|
* fields hereafter are internal to the system, and may change at
|
133 |
|
|
* will (read: may be cleaned up at will).
|
134 |
|
|
*/
|
135 |
|
|
|
136 |
|
|
/* These may be needed for future network-power-down code. */
|
137 |
|
|
unsigned long trans_start; /* Time (in jiffies) of last Tx */
|
138 |
|
|
unsigned long last_rx; /* Time of last Rx */
|
139 |
|
|
|
140 |
|
|
unsigned short flags; /* interface flags (a la BSD) */
|
141 |
|
|
unsigned short family; /* address family ID (AF_INET) */
|
142 |
|
|
unsigned short metric; /* routing metric (not used) */
|
143 |
|
|
unsigned short mtu; /* interface MTU value */
|
144 |
|
|
unsigned short type; /* interface hardware type */
|
145 |
|
|
unsigned short hard_header_len; /* hardware hdr length */
|
146 |
|
|
void *priv; /* pointer to private data */
|
147 |
|
|
|
148 |
|
|
/* Interface address info. */
|
149 |
|
|
unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
|
150 |
|
|
unsigned char pad; /* make dev_addr aligned to 8 bytes */
|
151 |
|
|
unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */
|
152 |
|
|
unsigned char addr_len; /* hardware address length */
|
153 |
|
|
unsigned long pa_addr; /* protocol address */
|
154 |
|
|
unsigned long pa_brdaddr; /* protocol broadcast addr */
|
155 |
|
|
unsigned long pa_dstaddr; /* protocol P-P other side addr */
|
156 |
|
|
unsigned long pa_mask; /* protocol netmask */
|
157 |
|
|
unsigned short pa_alen; /* protocol address length */
|
158 |
|
|
|
159 |
|
|
struct dev_mc_list *mc_list; /* Multicast mac addresses */
|
160 |
|
|
int mc_count; /* Number of installed mcasts */
|
161 |
|
|
|
162 |
|
|
struct ip_mc_list *ip_mc_list; /* IP multicast filter chain */
|
163 |
|
|
__u32 tx_queue_len; /* Max frames per queue allowed */
|
164 |
|
|
|
165 |
|
|
/* For load balancing driver pair support */
|
166 |
|
|
|
167 |
|
|
unsigned long pkt_queue; /* Packets queued */
|
168 |
|
|
struct device *slave; /* Slave device */
|
169 |
|
|
struct net_alias_info *alias_info; /* main dev alias info */
|
170 |
|
|
struct net_alias *my_alias; /* alias devs */
|
171 |
|
|
|
172 |
|
|
/* Pointer to the interface buffers. */
|
173 |
|
|
struct sk_buff_head buffs[DEV_NUMBUFFS];
|
174 |
|
|
|
175 |
|
|
/* Pointers to interface service routines. */
|
176 |
|
|
int (*open)(struct device *dev);
|
177 |
|
|
int (*stop)(struct device *dev);
|
178 |
|
|
int (*hard_start_xmit) (struct sk_buff *skb,
|
179 |
|
|
struct device *dev);
|
180 |
|
|
int (*hard_header) (struct sk_buff *skb,
|
181 |
|
|
struct device *dev,
|
182 |
|
|
unsigned short type,
|
183 |
|
|
void *daddr,
|
184 |
|
|
void *saddr,
|
185 |
|
|
unsigned len);
|
186 |
|
|
int (*rebuild_header)(void *eth, struct device *dev,
|
187 |
|
|
unsigned long raddr, struct sk_buff *skb);
|
188 |
|
|
#define HAVE_MULTICAST
|
189 |
|
|
void (*set_multicast_list)(struct device *dev);
|
190 |
|
|
#define HAVE_SET_MAC_ADDR
|
191 |
|
|
int (*set_mac_address)(struct device *dev, void *addr);
|
192 |
|
|
#define HAVE_PRIVATE_IOCTL
|
193 |
|
|
int (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd);
|
194 |
|
|
#define HAVE_SET_CONFIG
|
195 |
|
|
int (*set_config)(struct device *dev, struct ifmap *map);
|
196 |
|
|
#define HAVE_HEADER_CACHE
|
197 |
|
|
void (*header_cache_bind)(struct hh_cache **hhp, struct device *dev, unsigned short htype, __u32 daddr);
|
198 |
|
|
void (*header_cache_update)(struct hh_cache *hh, struct device *dev, unsigned char * haddr);
|
199 |
|
|
#define HAVE_CHANGE_MTU
|
200 |
|
|
int (*change_mtu)(struct device *dev, int new_mtu);
|
201 |
|
|
|
202 |
|
|
struct iw_statistics* (*get_wireless_stats)(struct device *dev);
|
203 |
|
|
};
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
struct packet_type {
|
207 |
|
|
unsigned short type; /* This is really htons(ether_type). */
|
208 |
|
|
struct device * dev;
|
209 |
|
|
int (*func) (struct sk_buff *, struct device *,
|
210 |
|
|
struct packet_type *);
|
211 |
|
|
void *data;
|
212 |
|
|
struct packet_type *next;
|
213 |
|
|
};
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
#include <linux/interrupt.h>
|
217 |
|
|
#include <linux/notifier.h>
|
218 |
|
|
|
219 |
|
|
/* Used by dev_rint */
|
220 |
|
|
#define IN_SKBUFF 1
|
221 |
|
|
|
222 |
|
|
extern volatile unsigned long in_bh;
|
223 |
|
|
|
224 |
|
|
extern struct device loopback_dev;
|
225 |
|
|
extern struct device *dev_base;
|
226 |
|
|
extern struct packet_type *ptype_base[16];
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
extern int ip_addr_match(unsigned long addr1, unsigned long addr2);
|
230 |
|
|
extern int ip_chk_addr(unsigned long addr);
|
231 |
|
|
extern struct device *ip_dev_bynet(unsigned long daddr, unsigned long mask);
|
232 |
|
|
extern unsigned long ip_my_addr(void);
|
233 |
|
|
extern unsigned long ip_get_mask(unsigned long addr);
|
234 |
|
|
extern struct device *ip_dev_find(unsigned long addr);
|
235 |
|
|
extern struct device *dev_getbytype(unsigned short type);
|
236 |
|
|
|
237 |
|
|
extern void dev_add_pack(struct packet_type *pt);
|
238 |
|
|
extern void dev_remove_pack(struct packet_type *pt);
|
239 |
|
|
extern struct device *dev_get(const char *name);
|
240 |
|
|
extern int dev_open(struct device *dev);
|
241 |
|
|
extern int dev_close(struct device *dev);
|
242 |
|
|
extern void dev_queue_xmit(struct sk_buff *skb, struct device *dev,
|
243 |
|
|
int pri);
|
244 |
|
|
|
245 |
|
|
#define HAVE_NETIF_RX 1
|
246 |
|
|
extern void netif_rx(struct sk_buff *skb);
|
247 |
|
|
extern void net_bh(void);
|
248 |
|
|
extern void dev_tint(struct device *dev);
|
249 |
|
|
extern int dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy);
|
250 |
|
|
extern int dev_ioctl(unsigned int cmd, void *);
|
251 |
|
|
|
252 |
|
|
extern void dev_init(void);
|
253 |
|
|
|
254 |
|
|
/* Locking protection for page faults during outputs to devices unloaded during the fault */
|
255 |
|
|
|
256 |
|
|
extern int dev_lockct;
|
257 |
|
|
|
258 |
|
|
/*
|
259 |
|
|
* These two don't currently need to be interrupt-safe
|
260 |
|
|
* but they may do soon. Do it properly anyway.
|
261 |
|
|
*/
|
262 |
|
|
|
263 |
|
|
extern __inline__ void dev_lock_list(void)
|
264 |
|
|
{
|
265 |
|
|
unsigned long flags;
|
266 |
|
|
save_flags(flags);
|
267 |
|
|
cli();
|
268 |
|
|
dev_lockct++;
|
269 |
|
|
restore_flags(flags);
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
extern __inline__ void dev_unlock_list(void)
|
273 |
|
|
{
|
274 |
|
|
unsigned long flags;
|
275 |
|
|
save_flags(flags);
|
276 |
|
|
cli();
|
277 |
|
|
dev_lockct--;
|
278 |
|
|
restore_flags(flags);
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
/*
|
282 |
|
|
* This almost never occurs, isn't in performance critical paths
|
283 |
|
|
* and we can thus be relaxed about it
|
284 |
|
|
*/
|
285 |
|
|
|
286 |
|
|
extern __inline__ void dev_lock_wait(void)
|
287 |
|
|
{
|
288 |
|
|
while(dev_lockct)
|
289 |
|
|
schedule();
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
/* These functions live elsewhere (drivers/net/net_init.c, but related) */
|
294 |
|
|
|
295 |
|
|
extern void ether_setup(struct device *dev);
|
296 |
|
|
extern void tr_setup(struct device *dev);
|
297 |
|
|
extern void fddi_setup(struct device *dev);
|
298 |
|
|
extern int ether_config(struct device *dev, struct ifmap *map);
|
299 |
|
|
/* Support for loadable net-drivers */
|
300 |
|
|
extern int register_netdev(struct device *dev);
|
301 |
|
|
extern void unregister_netdev(struct device *dev);
|
302 |
|
|
extern int register_netdevice_notifier(struct notifier_block *nb);
|
303 |
|
|
extern int unregister_netdevice_notifier(struct notifier_block *nb);
|
304 |
|
|
/* Functions used for multicast support */
|
305 |
|
|
extern void dev_mc_upload(struct device *dev);
|
306 |
|
|
extern void dev_mc_delete(struct device *dev, void *addr, int alen, int all);
|
307 |
|
|
extern void dev_mc_add(struct device *dev, void *addr, int alen, int newonly);
|
308 |
|
|
extern void dev_mc_discard(struct device *dev);
|
309 |
|
|
/* This is the wrong place but it'll do for the moment */
|
310 |
|
|
extern void ip_mc_allhost(struct device *dev);
|
311 |
|
|
#endif /* __KERNEL__ */
|
312 |
|
|
|
313 |
|
|
#endif /* _LINUX_DEV_H */
|