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 * 15 * This program is free software; you can redistribute it and/or 16 * modify it under the terms of the GNU General Public License 17 * as published by the Free Software Foundation; either version 18 * 2 of the License, or (at your option) any later version. 19 */ 20 #ifndef_DEV_H 21 #define_DEV_H 22
23 #include <linux/if.h>
24 #include <linux/if_ether.h>
25
26
27 /* for future expansion when we will have different priorities. */ 28 #defineDEV_NUMBUFFS 3
29 #defineMAX_ADDR_LEN 7
30 #defineMAX_HEADER 18
31
32 #defineIS_MYADDR 1 /* address is (one of) our own */ 33 #define IS_LOOPBACK 2 /* address is for LOOPBACK */ 34 #defineIS_BROADCAST 3 /* address is a valid broadcast */ 35 #define IS_INVBCAST 4 /* Wrong netmask bcast not for us */ 36
37 /* 38 * The DEVICE structure. 39 * Actually, this whole structure is a big mistake. It mixes I/O 40 * data with strictly "high-level" data, and it has to know about 41 * almost every data structure used in the INET module. We will 42 * gradually phase out this structure, and replace it with the 43 * more general (but stolen :-) BSD "ifnet" structure. -FvK 44 */ 45 structdevice{ 46
47 /* 48 * This is the first field of the "visible" part of this structure 49 * (i.e. as seen by users in the "Space.c" file). It is the name 50 * the interface. 51 */ 52 char *name;
53
54 /* I/O specific fields. These will be moved to DDI soon. */ 55 unsignedlongrmem_end; /* shmem "recv" end */ 56 unsignedlongrmem_start; /* shmem "recv" start */ 57 unsignedlongmem_end; /* sahared mem end */ 58 unsignedlongmem_start; /* shared mem start */ 59 unsignedshortbase_addr; /* device I/O address */ 60 unsignedcharirq; /* device IRQ number */ 61
62 /* Low-level status flags. */ 63 volatileunsignedcharstart, /* start an operation */ 64 tbusy, /* transmitter busy */ 65 interrupt; /* interrupt arrived */ 66
67 /* 68 * Another mistake. 69 * This points to the next device in the "dev" chain. It will 70 * be moved to the "invisible" part of the structure as soon as 71 * it has been cleaned up. -FvK 72 */ 73 structdevice *next;
74
75 /* The device initialization function. Called only once. */ 76 int (*init)(structdevice *dev);
77
78 /* Some hardware also needs these fields, but they are not part of the 79 usual set specified in Space.c. */ 80 unsignedcharif_port; /* Selectable AUI, TP,..*/ 81 unsignedchardma; /* DMA channel */ 82
83 structenet_statistics* (*get_stats)(structdevice *dev);
84
85 /* 86 * This marks the end of the "visible" part of the structure. All 87 * fields hereafter are internal to the system, and may change at 88 * will (read: may be cleaned up at will). 89 */ 90
91 /* These may be needed for future network-power-down code. */ 92 unsignedlongtrans_start; /* Time (in jiffies) of last Tx */ 93 unsignedlonglast_rx; /* Time of last Rx */ 94
95 unsignedshortflags; /* interface flags (a la BSD) */ 96 unsignedshortfamily; /* address family ID (AF_INET) */ 97 unsignedshortmetric; /* routing metric (not used) */ 98 unsignedshortmtu; /* interface MTU value */ 99 unsignedshorttype; /* interface hardware type */ 100 unsignedshorthard_header_len; /* hardware hdr length */ 101 void *priv; /* pointer to private data */ 102
103 /* Interface address info. */ 104 unsignedcharbroadcast[MAX_ADDR_LEN]; /* hw bcast add */ 105 unsignedchardev_addr[MAX_ADDR_LEN]; /* hw address */ 106 unsignedcharaddr_len; /* harfware address length */ 107 unsignedlongpa_addr; /* protocol address */ 108 unsignedlongpa_brdaddr; /* protocol broadcast addr */ 109 unsignedlongpa_dstaddr; /* protocol P-P other side addr */ 110 unsignedlongpa_mask; /* protocol netmask */ 111 unsignedshortpa_alen; /* protocol address length */ 112
113 /* Pointer to the interface buffers. */ 114 structsk_buff *volatilebuffs[DEV_NUMBUFFS];
115
116 /* Pointers to interface service routines. */ 117 int (*open)(structdevice *dev);
118 int (*stop)(structdevice *dev);
119 int (*hard_start_xmit) (structsk_buff *skb,
120 structdevice *dev);
121 int (*hard_header) (unsignedchar *buff,
122 structdevice *dev,
123 unsignedshorttype,
124 unsignedlongdaddr,
125 unsignedlongsaddr,
126 unsignedlen);
127 void (*add_arp) (unsignedlongaddr,
128 structsk_buff *skb,
129 structdevice *dev);
130 void (*queue_xmit)(structsk_buff *skb,
131 structdevice *dev, intpri);
132 int (*rebuild_header)(void *eth, structdevice *dev);
133 unsignedshort (*type_trans) (structsk_buff *skb,
134 structdevice *dev);
135 #defineHAVE_MULTICAST 136 void (*set_multicast_list)(structdevice *dev,
137 intnum_addrs, void *addrs);
138 #defineHAVE_SET_MAC_ADDR 139 int (*set_mac_address)(structdevice *dev, void *addr);
140 };
141
142
143 structpacket_type{ 144 unsignedshorttype; /* This is really NET16(ether_type) other 145 * devices will have to translate 146 * appropriately. 147 */ 148 unsignedshortcopy:1;
149 int (*func) (structsk_buff *, structdevice *,
150 structpacket_type *);
151 void *data;
152 structpacket_type *next;
153 };
154
155
156 /* Used by dev_rint */ 157 #defineIN_SKBUFF 1
158 #define DEV_QUEUE_MAGIC 0x17432895
159
160
161 externstructdevice *dev_base;
162 externstructpacket_type *ptype_base;
163
164
165 externintip_addr_match(unsignedlongaddr1, unsignedlongaddr2);
166 externint chk_addr(unsignedlongaddr);
167 externstructdevice *dev_check(unsignedlongdaddr);
168 externunsignedlong my_addr(void);
169
170 externvoiddev_add_pack(structpacket_type *pt);
171 externvoiddev_remove_pack(structpacket_type *pt);
172 externstructdevice *dev_get(char *name);
173 externintdev_open(structdevice *dev);
174 externintdev_close(structdevice *dev);
175 externvoiddev_queue_xmit(structsk_buff *skb, structdevice *dev,
176 intpri);
177 #defineHAVE_NETIF_RX 1
178 externvoidnetif_rx(structsk_buff *skb);
179 /* The old interface to netif_rx(). */ 180 externintdev_rint(unsignedchar *buff, longlen, intflags,
181 structdevice * dev);
182 externvoiddev_transmit(void);
183 externintin_inet_bh(void);
184 externvoidinet_bh(void *tmp);
185 externvoiddev_tint(structdevice *dev);
186 externintdev_get_info(char *buffer);
187 externintdev_ioctl(unsignedintcmd, void *);
188
189 externvoiddev_init(void);
190
191 #endif/* _DEV_H */