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