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