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