Import 2.1.42pre1
[davej-history.git] / include / linux / wanrouter.h
blob444608afbcfb9b11d5ade17ca7a99438106d111b
1 /*****************************************************************************
2 * wanrouter.h Definitions for the WAN Multiprotocol Router Module.
3 * This module provides API and common services for WAN Link
4 * Drivers and is completely hardware-independent.
6 * Author: Gene Kozin <genek@compuserve.com>
8 * Copyright: (c) 1995-1997 Sangoma Technologies Inc.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 * ============================================================================
15 * Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h).
16 *****************************************************************************/
17 #ifndef _ROUTER_H
18 #define _ROUTER_H
20 #define ROUTER_NAME "wanrouter" /* in case we ever change it */
21 #define ROUTER_VERSION 1 /* version number */
22 #define ROUTER_RELEASE 0 /* release (minor version) number */
23 #define ROUTER_IOCTL 'W' /* for IOCTL calls */
24 #define ROUTER_MAGIC 0x524D4157L /* signature: 'WANR' reversed */
26 /* IOCTL codes for /proc/router/<device> entries (up to 255) */
27 enum router_ioctls
29 ROUTER_SETUP = ROUTER_IOCTL<<8, /* configure device */
30 ROUTER_DOWN, /* shut down device */
31 ROUTER_STAT, /* get device status */
32 ROUTER_IFNEW, /* add interface */
33 ROUTER_IFDEL, /* delete interface */
34 ROUTER_IFSTAT, /* get interface status */
35 ROUTER_USER = (ROUTER_IOCTL<<8)+16, /* driver-specific calls */
36 ROUTER_USER_MAX = (ROUTER_IOCTL<<8)+31
39 /* NLPID for packet encapsulation (ISO/IEC TR 9577) */
40 #define NLPID_IP 0xCC /* Internet Protocol Datagram */
41 #define NLPID_SNAP 0x80 /* IEEE Subnetwork Access Protocol */
42 #define NLPID_CLNP 0x81 /* ISO/IEC 8473 */
43 #define NLPID_ESIS 0x82 /* ISO/IEC 9542 */
44 #define NLPID_ISIS 0x83 /* ISO/IEC ISIS */
45 #define NLPID_Q933 0x08 /* CCITT Q.933 */
47 /* Miscellaneous */
48 #define WAN_IFNAME_SZ 15 /* max length of the interface name */
49 #define WAN_DRVNAME_SZ 15 /* max length of the link driver name */
50 #define WAN_ADDRESS_SZ 31 /* max length of the WAN media address */
52 /****** Data Types **********************************************************/
54 /*----------------------------------------------------------------------------
55 * X.25-specific link-level configuration.
57 typedef struct wan_x25_conf
59 unsigned lo_pvc; /* lowest permanent circuit number */
60 unsigned hi_pvc; /* highest permanent circuit number */
61 unsigned lo_svc; /* lowest switched circuit number */
62 unsigned hi_svc; /* highest switched circuit number */
63 unsigned hdlc_window; /* HDLC window size (1..7) */
64 unsigned pkt_window; /* X.25 packet window size (1..7) */
65 unsigned t1; /* HDLC timer T1, sec (1..30) */
66 unsigned t2; /* HDLC timer T2, sec (0..29) */
67 unsigned t4; /* HDLC supervisory frame timer = T4 * T1 */
68 unsigned n2; /* HDLC retransmission limit (1..30) */
69 unsigned t10_t20; /* X.25 RESTART timeout, sec (1..255) */
70 unsigned t11_t21; /* X.25 CALL timeout, sec (1..255) */
71 unsigned t12_t22; /* X.25 RESET timeout, sec (1..255) */
72 unsigned t13_t23; /* X.25 CLEAR timeout, sec (1..255) */
73 unsigned t16_t26; /* X.25 INTERRUPT timeout, sec (1..255) */
74 unsigned t28; /* X.25 REGISTRATION timeout, sec (1..255) */
75 unsigned r10_r20; /* RESTART retransmission limit (0..250) */
76 unsigned r12_r22; /* RESET retransmission limit (0..250) */
77 unsigned r13_r23; /* CLEAR retransmission limit (0..250) */
78 unsigned ccitt_compat; /* compatibility mode: 1988/1984/1980 */
79 } wan_x25_conf_t;
81 /*----------------------------------------------------------------------------
82 * Frame relay specific link-level configuration.
84 typedef struct wan_fr_conf
86 unsigned cir; /* committed information rate */
87 unsigned signalling; /* local in-channel signalling type */
88 unsigned t391; /* link integrity verification timer */
89 unsigned t392; /* polling verification timer */
90 unsigned n391; /* full status polling cycle counter */
91 unsigned n392; /* error threshold counter */
92 unsigned n393; /* monitored events counter */
93 unsigned dlci; /* first DLC number (access node) */
94 unsigned dlci_num; /* number of DLCs (access node) */
95 } wan_fr_conf_t;
97 /*----------------------------------------------------------------------------
98 * PPP-specific link-level configuration.
100 typedef struct wan_ppp_conf
102 unsigned restart_tmr; /* restart timer */
103 unsigned auth_rsrt_tmr; /* authentication timer */
104 unsigned auth_wait_tmr; /* authentication timer */
105 unsigned mdm_fail_tmr; /* modem failure timer */
106 unsigned dtr_drop_tmr; /* DTR drop timer */
107 unsigned connect_tmout; /* connection timeout */
108 unsigned conf_retry; /* max. retry */
109 unsigned term_retry; /* max. retry */
110 unsigned fail_retry; /* max. retry */
111 unsigned auth_retry; /* max. retry */
112 unsigned auth_options; /* authentication opt. */
113 unsigned ip_options; /* IP options */
114 } wan_ppp_conf_t;
116 /*----------------------------------------------------------------------------
117 * WAN device configuration. Passed to ROUTER_SETUP IOCTL.
119 typedef struct wandev_conf
121 unsigned magic; /* magic number (for verification) */
122 unsigned config_id; /* configuration structure identifier */
123 /****** hardware configuration ******/
124 unsigned ioport; /* adapter I/O port base */
125 unsigned long maddr; /* dual-port memory address */
126 unsigned msize; /* dual-port memory size */
127 int irq; /* interrupt request level */
128 int dma; /* DMA request level */
129 unsigned bps; /* data transfer rate */
130 unsigned mtu; /* maximum transmit unit size */
131 char interface; /* RS-232/V.35, etc. */
132 char clocking; /* external/internal */
133 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
134 char station; /* DTE/DCE, primary/secondary, etc. */
135 char connection; /* permanent/switched/on-demand */
136 unsigned hw_opt[4]; /* other hardware options */
137 unsigned reserved[4];
138 /****** arbitrary data ***************/
139 unsigned data_size; /* data buffer size */
140 void* data; /* data buffer, e.g. firmware */
141 union /****** protocol-specific ************/
143 wan_x25_conf_t x25; /* X.25 configuration */
144 wan_ppp_conf_t ppp; /* PPP configuration */
145 wan_fr_conf_t fr; /* frame relay configuration */
146 } u;
147 } wandev_conf_t;
149 /* 'config_id' definitions */
150 #define WANCONFIG_X25 101 /* X.25 link */
151 #define WANCONFIG_FR 102 /* frame relay link */
152 #define WANCONFIG_PPP 103 /* synchronous PPP link */
155 * Configuration options defines.
157 /* general options */
158 #define WANOPT_OFF 0
159 #define WANOPT_ON 1
160 #define WANOPT_NO 0
161 #define WANOPT_YES 1
163 /* intercace options */
164 #define WANOPT_RS232 0
165 #define WANOPT_V35 1
167 /* data encoding options */
168 #define WANOPT_NRZ 0
169 #define WANOPT_NRZI 1
170 #define WANOPT_FM0 2
171 #define WANOPT_FM1 3
173 /* link type options */
174 #define WANOPT_POINTTOPOINT 0 /* RTS always active */
175 #define WANOPT_MULTIDROP 1 /* RTS is active when transmitting */
177 /* clocking options */
178 #define WANOPT_EXTERNAL 0
179 #define WANOPT_INTERNAL 1
181 /* station options */
182 #define WANOPT_DTE 0
183 #define WANOPT_DCE 1
184 #define WANOPT_CPE 0
185 #define WANOPT_NODE 1
186 #define WANOPT_SECONDARY 0
187 #define WANOPT_PRIMARY 1
189 /* connection options */
190 #define WANOPT_PERMANENT 0 /* DTR always active */
191 #define WANOPT_SWITCHED 1 /* use DTR to setup link (dial-up) */
192 #define WANOPT_ONDEMAND 2 /* activate DTR only before sending */
194 /* frame relay in-channel signalling */
195 #define WANOPT_FR_ANSI 0 /* ANSI T1.617 Annex D */
196 #define WANOPT_FR_Q933 1 /* ITU Q.933A */
197 #define WANOPT_FR_LMI 2 /* LMI */
199 /*----------------------------------------------------------------------------
200 * WAN Link Status Info (for ROUTER_STAT IOCTL).
202 typedef struct wandev_stat
204 unsigned state; /* link state */
205 unsigned ndev; /* number of configured interfaces */
207 /* link/interface configuration */
208 unsigned connection; /* permanent/switched/on-demand */
209 unsigned media_type; /* Frame relay/PPP/X.25/SDLC, etc. */
210 unsigned mtu; /* max. transmit unit for this device */
212 /* physical level statistics */
213 unsigned modem_status; /* modem status */
214 unsigned rx_frames; /* received frames count */
215 unsigned rx_overruns; /* receiver overrun error count */
216 unsigned rx_crc_err; /* receive CRC error count */
217 unsigned rx_aborts; /* received aborted frames count */
218 unsigned rx_bad_length; /* unexpetedly long/short frames count */
219 unsigned rx_dropped; /* frames discarded at device level */
220 unsigned tx_frames; /* transmitted frames count */
221 unsigned tx_underruns; /* aborted transmissions (underruns) count */
222 unsigned tx_timeouts; /* transmission timeouts */
223 unsigned tx_rejects; /* other transmit errors */
225 /* media level statistics */
226 unsigned rx_bad_format; /* frames with invalid format */
227 unsigned rx_bad_addr; /* frames with invalid media address */
228 unsigned tx_retries; /* frames re-transmitted */
229 unsigned reserved[16]; /* reserved for future use */
230 } wandev_stat_t;
232 /* 'state' defines */
233 enum wan_states
235 WAN_UNCONFIGURED, /* link/channel is not configured */
236 WAN_DISCONNECTED, /* link/channel is disconnected */
237 WAN_CONNECTING, /* connection is in progress */
238 WAN_CONNECTED, /* link/channel is operational */
239 WAN_LIMIT /* for verification only */
242 /* 'modem_status' masks */
243 #define WAN_MODEM_CTS 0x0001 /* CTS line active */
244 #define WAN_MODEM_DCD 0x0002 /* DCD line active */
245 #define WAN_MODEM_DTR 0x0010 /* DTR line active */
246 #define WAN_MODEM_RTS 0x0020 /* RTS line active */
248 /*----------------------------------------------------------------------------
249 * WAN interface (logical channel) configuration (for ROUTER_IFNEW IOCTL).
251 typedef struct wanif_conf
253 unsigned magic; /* magic number */
254 unsigned config_id; /* configuration identifier */
255 char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */
256 char addr[WAN_ADDRESS_SZ+1]; /* media address, ASCIIZ */
257 unsigned idle_timeout; /* sec, before disconnecting */
258 unsigned hold_timeout; /* sec, before re-connecting */
259 int reserved[8]; /* reserved for future extensions */
260 } wanif_conf_t;
262 #ifdef __KERNEL__
263 /****** Kernel Interface ****************************************************/
265 #include <linux/fs.h> /* support for device drivers */
266 #include <linux/proc_fs.h> /* proc filesystem pragmatics */
267 #include <linux/inet.h> /* in_aton(), in_ntoa() prototypes */
268 #include <linux/netdevice.h> /* support for network drivers */
270 /*----------------------------------------------------------------------------
271 * WAN device data space.
273 typedef struct wan_device
275 unsigned magic; /* magic number */
276 char* name; /* -> WAN device name (ASCIIZ) */
277 void* private; /* -> driver private data */
278 /****** hardware configuration ******/
279 unsigned ioport; /* adapter I/O port base #1 */
280 unsigned long maddr; /* dual-port memory address */
281 unsigned msize; /* dual-port memory size */
282 int irq; /* interrupt request level */
283 int dma; /* DMA request level */
284 unsigned bps; /* data transfer rate */
285 unsigned mtu; /* max physical transmit unit size */
286 char interface; /* RS-232/V.35, etc. */
287 char clocking; /* external/internal */
288 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
289 char station; /* DTE/DCE, primary/secondary, etc. */
290 char connection; /* permanent/switched/on-demand */
291 unsigned hw_opt[4]; /* other hardware options */
292 /****** status and statistics *******/
293 char state; /* device state */
294 unsigned modem_status; /* modem status */
295 struct enet_statistics stats; /* interface statistics */
296 unsigned reserved[16]; /* reserved for future use */
297 unsigned critical; /* critical section flag */
298 /****** device management methods ***/
299 int (*setup) (struct wan_device* wandev, wandev_conf_t* conf);
300 int (*shutdown) (struct wan_device* wandev);
301 int (*update) (struct wan_device* wandev);
302 int (*ioctl) (struct wan_device* wandev, unsigned cmd,
303 unsigned long arg);
304 int (*new_if) (struct wan_device* wandev, struct device* dev,
305 wanif_conf_t* conf);
306 int (*del_if) (struct wan_device* wandev, struct device* dev);
307 /****** maintained by the router ****/
308 struct wan_device* next; /* -> next device */
309 struct device* dev; /* list of network interfaces */
310 unsigned ndev; /* number of interfaces */
311 struct proc_dir_entry dent; /* proc filesystem entry */
312 } wan_device_t;
314 /* Init Point */
315 extern void wanrouter_init(void);
317 /* Public functions available for device drivers */
318 extern int register_wan_device (wan_device_t* wandev);
319 extern int unregister_wan_device (char* name);
320 unsigned short wanrouter_type_trans (struct sk_buff* skb, struct device* dev);
321 int wanrouter_encapsulate (struct sk_buff* skb, struct device* dev);
323 /* Proc interface functions. These must not be called by the drivers! */
324 extern int wanrouter_proc_init (void);
325 extern void wanrouter_proc_cleanup (void);
326 extern int wanrouter_proc_add (wan_device_t* wandev);
327 extern int wanrouter_proc_delete (wan_device_t* wandev);
328 extern int wanrouter_ioctl(struct inode* inode, struct file* file,
329 unsigned int cmd, unsigned long arg);
331 #endif /* __KERNEL__ */
332 #endif /* _ROUTER_H */