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