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. 5 * 6 * Author: Nenad Corbic <ncorbic@sangoma.com> 7 * Gideon Hack 8 * Additions: Arnaldo Melo 9 * 10 * Copyright: (c) 1995-2000 Sangoma Technologies Inc. 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 15 * 2 of the License, or (at your option) any later version. 16 * ============================================================================ 17 * Jul 21, 2000 Nenad Corbic Added WAN_FT1_READY State 18 * Feb 24, 2000 Nenad Corbic Added support for socket based x25api 19 * Jan 28, 2000 Nenad Corbic Added support for the ASYNC protocol. 20 * Oct 04, 1999 Nenad Corbic Updated for 2.1.0 release 21 * Jun 02, 1999 Gideon Hack Added support for the S514 adapter. 22 * May 23, 1999 Arnaldo Melo Added local_addr to wanif_conf_t 23 * WAN_DISCONNECTING state added 24 * Jul 20, 1998 David Fong Added Inverse ARP options to 'wanif_conf_t' 25 * Jun 12, 1998 David Fong Added Cisco HDLC support. 26 * Dec 16, 1997 Jaspreet Singh Moved 'enable_IPX' and 'network_number' to 27 * 'wanif_conf_t' 28 * Dec 05, 1997 Jaspreet Singh Added 'pap', 'chap' to 'wanif_conf_t' 29 * Added 'authenticator' to 'wan_ppp_conf_t' 30 * Nov 06, 1997 Jaspreet Singh Changed Router Driver version to 1.1 from 1.0 31 * Oct 20, 1997 Jaspreet Singh Added 'cir','bc','be' and 'mc' to 'wanif_conf_t' 32 * Added 'enable_IPX' and 'network_number' to 33 * 'wan_device_t'. Also added defines for 34 * UDP PACKET TYPE, Interrupt test, critical values 35 * for RACE conditions. 36 * Oct 05, 1997 Jaspreet Singh Added 'dlci_num' and 'dlci[100]' to 37 * 'wan_fr_conf_t' to configure a list of dlci(s) 38 * for a NODE 39 * Jul 07, 1997 Jaspreet Singh Added 'ttl' to 'wandev_conf_t' & 'wan_device_t' 40 * May 29, 1997 Jaspreet Singh Added 'tx_int_enabled' to 'wan_device_t' 41 * May 21, 1997 Jaspreet Singh Added 'udp_port' to 'wan_device_t' 42 * Apr 25, 1997 Farhan Thawar Added 'udp_port' to 'wandev_conf_t' 43 * Jan 16, 1997 Gene Kozin router_devlist made public 44 * Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h). 45 *****************************************************************************/ 46 #include <linux/version.h> 47 48 #ifndef KERNEL_VERSION 49 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 50 #endif 51 52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) 53 #define LINUX_2_4 54 #define netdevice_t struct net_device 55 #include <linux/spinlock.h> /* Support for SMP Locking */ 56 57 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) 58 #define LINUX_2_1 59 #define netdevice_t struct device 60 #include <asm/spinlock.h> /* Support for SMP Locking */ 61 62 #else 63 #define LINUX_2_0 64 #define netdevice_t struct device 65 #define spinlock_t int 66 #endif 67 68 #ifndef _ROUTER_H 69 #define _ROUTER_H 70 71 #define ROUTER_NAME "wanrouter" /* in case we ever change it */ 72 #define ROUTER_VERSION 1 /* version number */ 73 #define ROUTER_RELEASE 1 /* release (minor version) number */ 74 #define ROUTER_IOCTL 'W' /* for IOCTL calls */ 75 #define ROUTER_MAGIC 0x524D4157L /* signature: 'WANR' reversed */ 76 77 /* IOCTL codes for /proc/router/<device> entries (up to 255) */ 78 enum router_ioctls 79 { 80 ROUTER_SETUP = ROUTER_IOCTL<<8, /* configure device */ 81 ROUTER_DOWN, /* shut down device */ 82 ROUTER_STAT, /* get device status */ 83 ROUTER_IFNEW, /* add interface */ 84 ROUTER_IFDEL, /* delete interface */ 85 ROUTER_IFSTAT, /* get interface status */ 86 ROUTER_USER = (ROUTER_IOCTL<<8)+16, /* driver-specific calls */ 87 ROUTER_USER_MAX = (ROUTER_IOCTL<<8)+31 88 }; 89 90 /* identifiers for displaying proc file data for dual port adapters */ 91 #define PROC_DATA_PORT_0 0x8000 /* the data is for port 0 */ 92 #define PROC_DATA_PORT_1 0x8001 /* the data is for port 1 */ 93 94 /* NLPID for packet encapsulation (ISO/IEC TR 9577) */ 95 #define NLPID_IP 0xCC /* Internet Protocol Datagram */ 96 #define NLPID_SNAP 0x80 /* IEEE Subnetwork Access Protocol */ 97 #define NLPID_CLNP 0x81 /* ISO/IEC 8473 */ 98 #define NLPID_ESIS 0x82 /* ISO/IEC 9542 */ 99 #define NLPID_ISIS 0x83 /* ISO/IEC ISIS */ 100 #define NLPID_Q933 0x08 /* CCITT Q.933 */ 101 102 /* Miscellaneous */ 103 #define WAN_IFNAME_SZ 15 /* max length of the interface name */ 104 #define WAN_DRVNAME_SZ 15 /* max length of the link driver name */ 105 #define WAN_ADDRESS_SZ 31 /* max length of the WAN media address */ 106 #define USED_BY_FIELD 8 /* max length of the used by field */ 107 108 /* Defines for UDP PACKET TYPE */ 109 #define UDP_PTPIPE_TYPE 0x01 110 #define UDP_FPIPE_TYPE 0x02 111 #define UDP_CPIPE_TYPE 0x03 112 #define UDP_DRVSTATS_TYPE 0x04 113 #define UDP_INVALID_TYPE 0x05 114 115 /* Command return code */ 116 #define CMD_OK 0 /* normal firmware return code */ 117 #define CMD_TIMEOUT 0xFF /* firmware command timed out */ 118 119 /* UDP Packet Management */ 120 #define UDP_PKT_FRM_STACK 0x00 121 #define UDP_PKT_FRM_NETWORK 0x01 122 123 /* Maximum interrupt test counter */ 124 #define MAX_INTR_TEST_COUNTER 100 125 126 /* Critical Values for RACE conditions*/ 127 #define CRITICAL_IN_ISR 0xA1 128 #define CRITICAL_INTR_HANDLED 0xB1 129 130 /****** Data Types **********************************************************/ 131 132 /*---------------------------------------------------------------------------- 133 * X.25-specific link-level configuration. 134 */ 135 typedef struct wan_x25_conf 136 { 137 unsigned lo_pvc; /* lowest permanent circuit number */ 138 unsigned hi_pvc; /* highest permanent circuit number */ 139 unsigned lo_svc; /* lowest switched circuit number */ 140 unsigned hi_svc; /* highest switched circuit number */ 141 unsigned hdlc_window; /* HDLC window size (1..7) */ 142 unsigned pkt_window; /* X.25 packet window size (1..7) */ 143 unsigned t1; /* HDLC timer T1, sec (1..30) */ 144 unsigned t2; /* HDLC timer T2, sec (0..29) */ 145 unsigned t4; /* HDLC supervisory frame timer = T4 * T1 */ 146 unsigned n2; /* HDLC retransmission limit (1..30) */ 147 unsigned t10_t20; /* X.25 RESTART timeout, sec (1..255) */ 148 unsigned t11_t21; /* X.25 CALL timeout, sec (1..255) */ 149 unsigned t12_t22; /* X.25 RESET timeout, sec (1..255) */ 150 unsigned t13_t23; /* X.25 CLEAR timeout, sec (1..255) */ 151 unsigned t16_t26; /* X.25 INTERRUPT timeout, sec (1..255) */ 152 unsigned t28; /* X.25 REGISTRATION timeout, sec (1..255) */ 153 unsigned r10_r20; /* RESTART retransmission limit (0..250) */ 154 unsigned r12_r22; /* RESET retransmission limit (0..250) */ 155 unsigned r13_r23; /* CLEAR retransmission limit (0..250) */ 156 unsigned ccitt_compat; /* compatibility mode: 1988/1984/1980 */ 157 unsigned x25_conf_opt; /* User defined x25 config optoins */ 158 unsigned char LAPB_hdlc_only; /* Run in HDLC only mode */ 159 unsigned char logging; /* Control connection logging */ 160 unsigned char oob_on_modem; /* Whether to send modem status to the user app */ 161 } wan_x25_conf_t; 162 163 /*---------------------------------------------------------------------------- 164 * Frame relay specific link-level configuration. 165 */ 166 typedef struct wan_fr_conf 167 { 168 unsigned signalling; /* local in-channel signalling type */ 169 unsigned t391; /* link integrity verification timer */ 170 unsigned t392; /* polling verification timer */ 171 unsigned n391; /* full status polling cycle counter */ 172 unsigned n392; /* error threshold counter */ 173 unsigned n393; /* monitored events counter */ 174 unsigned dlci_num; /* number of DLCs (access node) */ 175 unsigned dlci[100]; /* List of all DLCIs */ 176 } wan_fr_conf_t; 177 178 /*---------------------------------------------------------------------------- 179 * PPP-specific link-level configuration. 180 */ 181 typedef struct wan_ppp_conf 182 { 183 unsigned restart_tmr; /* restart timer */ 184 unsigned auth_rsrt_tmr; /* authentication timer */ 185 unsigned auth_wait_tmr; /* authentication timer */ 186 unsigned mdm_fail_tmr; /* modem failure timer */ 187 unsigned dtr_drop_tmr; /* DTR drop timer */ 188 unsigned connect_tmout; /* connection timeout */ 189 unsigned conf_retry; /* max. retry */ 190 unsigned term_retry; /* max. retry */ 191 unsigned fail_retry; /* max. retry */ 192 unsigned auth_retry; /* max. retry */ 193 unsigned auth_options; /* authentication opt. */ 194 unsigned ip_options; /* IP options */ 195 char authenticator; /* AUTHENTICATOR or not */ 196 char ip_mode; /* Static/Host/Peer */ 197 } wan_ppp_conf_t; 198 199 /*---------------------------------------------------------------------------- 200 * CHDLC-specific link-level configuration. 201 */ 202 typedef struct wan_chdlc_conf 203 { 204 unsigned char ignore_dcd; /* Protocol options: */ 205 unsigned char ignore_cts; /* Ignore these to determine */ 206 unsigned char ignore_keepalive; /* link status (Yes or No) */ 207 unsigned char hdlc_streaming; /* hdlc_streaming mode (Y/N) */ 208 unsigned char receive_only; /* no transmit buffering (Y/N) */ 209 unsigned keepalive_tx_tmr; /* transmit keepalive timer */ 210 unsigned keepalive_rx_tmr; /* receive keepalive timer */ 211 unsigned keepalive_err_margin; /* keepalive_error_tolerance */ 212 unsigned slarp_timer; /* SLARP request timer */ 213 } wan_chdlc_conf_t; 214 215 216 /*---------------------------------------------------------------------------- 217 * WAN device configuration. Passed to ROUTER_SETUP IOCTL. 218 */ 219 typedef struct wandev_conf 220 { 221 unsigned magic; /* magic number (for verification) */ 222 unsigned config_id; /* configuration structure identifier */ 223 /****** hardware configuration ******/ 224 unsigned ioport; /* adapter I/O port base */ 225 unsigned long maddr; /* dual-port memory address */ 226 unsigned msize; /* dual-port memory size */ 227 int irq; /* interrupt request level */ 228 int dma; /* DMA request level */ 229 char S514_CPU_no[1]; /* S514 PCI adapter CPU number ('A' or 'B') */ 230 unsigned PCI_slot_no; /* S514 PCI adapter slot number */ 231 char auto_pci_cfg; /* S515 PCI automatic slot detection */ 232 char comm_port; /* Communication Port (PRI=0, SEC=1) */ 233 unsigned bps; /* data transfer rate */ 234 unsigned mtu; /* maximum transmit unit size */ 235 unsigned udp_port; /* UDP port for management */ 236 unsigned char ttl; /* Time To Live for UDP security */ 237 unsigned char ft1; /* FT1 Configurator Option */ 238 char interface; /* RS-232/V.35, etc. */ 239 char clocking; /* external/internal */ 240 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */ 241 char station; /* DTE/DCE, primary/secondary, etc. */ 242 char connection; /* permanent/switched/on-demand */ 243 char read_mode; /* read mode: Polling or interrupt */ 244 char receive_only; /* disable tx buffers */ 245 char tty; /* Create a fake tty device */ 246 unsigned tty_major; /* Major number for wanpipe tty device */ 247 unsigned tty_minor; /* Minor number for wanpipe tty device */ 248 unsigned tty_mode; /* TTY operation mode SYNC or ASYNC */ 249 char backup; /* Backup Mode */ 250 unsigned hw_opt[4]; /* other hardware options */ 251 unsigned reserved[4]; 252 /****** arbitrary data ***************/ 253 unsigned data_size; /* data buffer size */ 254 void* data; /* data buffer, e.g. firmware */ 255 union /****** protocol-specific ************/ 256 { 257 wan_x25_conf_t x25; /* X.25 configuration */ 258 wan_ppp_conf_t ppp; /* PPP configuration */ 259 wan_fr_conf_t fr; /* frame relay configuration */ 260 wan_chdlc_conf_t chdlc; /* Cisco HDLC configuration */ 261 } u; 262 } wandev_conf_t; 263 264 /* 'config_id' definitions */ 265 #define WANCONFIG_X25 101 /* X.25 link */ 266 #define WANCONFIG_FR 102 /* frame relay link */ 267 #define WANCONFIG_PPP 103 /* synchronous PPP link */ 268 #define WANCONFIG_CHDLC 104 /* Cisco HDLC Link */ 269 #define WANCONFIG_BSC 105 /* BiSync Streaming */ 270 #define WANCONFIG_HDLC 106 /* HDLC Support */ 271 #define WANCONFIG_MPPP 107 /* Multi Port PPP over RAW CHDLC */ 272 273 /* 274 * Configuration options defines. 275 */ 276 /* general options */ 277 #define WANOPT_OFF 0 278 #define WANOPT_ON 1 279 #define WANOPT_NO 0 280 #define WANOPT_YES 1 281 282 /* intercace options */ 283 #define WANOPT_RS232 0 284 #define WANOPT_V35 1 285 286 /* data encoding options */ 287 #define WANOPT_NRZ 0 288 #define WANOPT_NRZI 1 289 #define WANOPT_FM0 2 290 #define WANOPT_FM1 3 291 292 /* link type options */ 293 #define WANOPT_POINTTOPOINT 0 /* RTS always active */ 294 #define WANOPT_MULTIDROP 1 /* RTS is active when transmitting */ 295 296 /* clocking options */ 297 #define WANOPT_EXTERNAL 0 298 #define WANOPT_INTERNAL 1 299 300 /* station options */ 301 #define WANOPT_DTE 0 302 #define WANOPT_DCE 1 303 #define WANOPT_CPE 0 304 #define WANOPT_NODE 1 305 #define WANOPT_SECONDARY 0 306 #define WANOPT_PRIMARY 1 307 308 /* connection options */ 309 #define WANOPT_PERMANENT 0 /* DTR always active */ 310 #define WANOPT_SWITCHED 1 /* use DTR to setup link (dial-up) */ 311 #define WANOPT_ONDEMAND 2 /* activate DTR only before sending */ 312 313 /* frame relay in-channel signalling */ 314 #define WANOPT_FR_ANSI 1 /* ANSI T1.617 Annex D */ 315 #define WANOPT_FR_Q933 2 /* ITU Q.933A */ 316 #define WANOPT_FR_LMI 3 /* LMI */ 317 318 /* PPP IP Mode Options */ 319 #define WANOPT_PPP_STATIC 0 320 #define WANOPT_PPP_HOST 1 321 #define WANOPT_PPP_PEER 2 322 323 /* ASY Mode Options */ 324 #define WANOPT_ONE 1 325 #define WANOPT_TWO 2 326 #define WANOPT_ONE_AND_HALF 3 327 328 #define WANOPT_NONE 0 329 #define WANOPT_ODD 1 330 #define WANOPT_EVEN 2 331 332 /* CHDLC Protocol Options */ 333 /* DF Commmented out for now. 334 335 #define WANOPT_CHDLC_NO_DCD IGNORE_DCD_FOR_LINK_STAT 336 #define WANOPT_CHDLC_NO_CTS IGNORE_CTS_FOR_LINK_STAT 337 #define WANOPT_CHDLC_NO_KEEPALIVE IGNORE_KPALV_FOR_LINK_STAT 338 */ 339 340 /* Port options */ 341 #define WANOPT_PRI 0 342 #define WANOPT_SEC 1 343 /* read mode */ 344 #define WANOPT_INTR 0 345 #define WANOPT_POLL 1 346 347 348 #define WANOPT_TTY_SYNC 0 349 #define WANOPT_TTY_ASYNC 1 350 /*---------------------------------------------------------------------------- 351 * WAN Link Status Info (for ROUTER_STAT IOCTL). 352 */ 353 typedef struct wandev_stat 354 { 355 unsigned state; /* link state */ 356 unsigned ndev; /* number of configured interfaces */ 357 358 /* link/interface configuration */ 359 unsigned connection; /* permanent/switched/on-demand */ 360 unsigned media_type; /* Frame relay/PPP/X.25/SDLC, etc. */ 361 unsigned mtu; /* max. transmit unit for this device */ 362 363 /* physical level statistics */ 364 unsigned modem_status; /* modem status */ 365 unsigned rx_frames; /* received frames count */ 366 unsigned rx_overruns; /* receiver overrun error count */ 367 unsigned rx_crc_err; /* receive CRC error count */ 368 unsigned rx_aborts; /* received aborted frames count */ 369 unsigned rx_bad_length; /* unexpetedly long/short frames count */ 370 unsigned rx_dropped; /* frames discarded at device level */ 371 unsigned tx_frames; /* transmitted frames count */ 372 unsigned tx_underruns; /* aborted transmissions (underruns) count */ 373 unsigned tx_timeouts; /* transmission timeouts */ 374 unsigned tx_rejects; /* other transmit errors */ 375 376 /* media level statistics */ 377 unsigned rx_bad_format; /* frames with invalid format */ 378 unsigned rx_bad_addr; /* frames with invalid media address */ 379 unsigned tx_retries; /* frames re-transmitted */ 380 unsigned reserved[16]; /* reserved for future use */ 381 } wandev_stat_t; 382 383 /* 'state' defines */ 384 enum wan_states 385 { 386 WAN_UNCONFIGURED, /* link/channel is not configured */ 387 WAN_DISCONNECTED, /* link/channel is disconnected */ 388 WAN_CONNECTING, /* connection is in progress */ 389 WAN_CONNECTED, /* link/channel is operational */ 390 WAN_LIMIT, /* for verification only */ 391 WAN_DUALPORT, /* for Dual Port cards */ 392 WAN_DISCONNECTING, 393 WAN_FT1_READY /* FT1 Configurator Ready */ 394 }; 395 396 enum { 397 WAN_LOCAL_IP, 398 WAN_POINTOPOINT_IP, 399 WAN_NETMASK_IP, 400 WAN_BROADCAST_IP 401 }; 402 403 /* 'modem_status' masks */ 404 #define WAN_MODEM_CTS 0x0001 /* CTS line active */ 405 #define WAN_MODEM_DCD 0x0002 /* DCD line active */ 406 #define WAN_MODEM_DTR 0x0010 /* DTR line active */ 407 #define WAN_MODEM_RTS 0x0020 /* RTS line active */ 408 409 /*---------------------------------------------------------------------------- 410 * WAN interface (logical channel) configuration (for ROUTER_IFNEW IOCTL). 411 */ 412 typedef struct wanif_conf 413 { 414 unsigned magic; /* magic number */ 415 unsigned config_id; /* configuration identifier */ 416 char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */ 417 char addr[WAN_ADDRESS_SZ+1]; /* media address, ASCIIZ */ 418 char usedby[USED_BY_FIELD]; /* used by API or WANPIPE */ 419 unsigned idle_timeout; /* sec, before disconnecting */ 420 unsigned hold_timeout; /* sec, before re-connecting */ 421 unsigned cir; /* Committed Information Rate fwd,bwd*/ 422 unsigned bc; /* Committed Burst Size fwd, bwd */ 423 unsigned be; /* Excess Burst Size fwd, bwd */ 424 unsigned char enable_IPX; /* Enable or Disable IPX */ 425 unsigned char inarp; /* Send Inverse ARP requests Y/N */ 426 unsigned inarp_interval; /* sec, between InARP requests */ 427 unsigned long network_number; /* Network Number for IPX */ 428 char mc; /* Multicast on or off */ 429 char local_addr[WAN_ADDRESS_SZ+1];/* local media address, ASCIIZ */ 430 unsigned char port; /* board port */ 431 unsigned char protocol; /* prococol used in this channel (TCPOX25 or X25) */ 432 char pap; /* PAP enabled or disabled */ 433 char chap; /* CHAP enabled or disabled */ 434 unsigned char userid[511]; /* List of User Id */ 435 unsigned char passwd[511]; /* List of passwords */ 436 unsigned char sysname[31]; /* Name of the system */ 437 unsigned char ignore_dcd; /* Protocol options: */ 438 unsigned char ignore_cts; /* Ignore these to determine */ 439 unsigned char ignore_keepalive; /* link status (Yes or No) */ 440 unsigned char hdlc_streaming; /* Hdlc streaming mode (Y/N) */ 441 unsigned keepalive_tx_tmr; /* transmit keepalive timer */ 442 unsigned keepalive_rx_tmr; /* receive keepalive timer */ 443 unsigned keepalive_err_margin; /* keepalive_error_tolerance */ 444 unsigned slarp_timer; /* SLARP request timer */ 445 unsigned char ttl; /* Time To Live for UDP security */ 446 char interface; /* RS-232/V.35, etc. */ 447 char clocking; /* external/internal */ 448 unsigned bps; /* data transfer rate */ 449 unsigned mtu; /* maximum transmit unit size */ 450 unsigned char if_down; /* brind down interface when disconnected */ 451 unsigned char gateway; /* Is this interface a gateway */ 452 unsigned char true_if_encoding; /* Set the dev->type to true board protocol */ 453 454 unsigned char asy_data_trans; /* async API options */ 455 unsigned char rts_hs_for_receive; /* async Protocol options */ 456 unsigned char xon_xoff_hs_for_receive; 457 unsigned char xon_xoff_hs_for_transmit; 458 unsigned char dcd_hs_for_transmit; 459 unsigned char cts_hs_for_transmit; 460 unsigned char async_mode; 461 unsigned tx_bits_per_char; 462 unsigned rx_bits_per_char; 463 unsigned stop_bits; 464 unsigned char parity; 465 unsigned break_timer; 466 unsigned inter_char_timer; 467 unsigned rx_complete_length; 468 unsigned xon_char; 469 unsigned xoff_char; 470 unsigned char receive_only; /* no transmit buffering (Y/N) */ 471 } wanif_conf_t; 472 473 #ifdef __KERNEL__ 474 /****** Kernel Interface ****************************************************/ 475 476 #include <linux/fs.h> /* support for device drivers */ 477 #include <linux/proc_fs.h> /* proc filesystem pragmatics */ 478 #include <linux/netdevice.h> /* support for network drivers */ 479 /*---------------------------------------------------------------------------- 480 * WAN device data space. 481 */ 482 typedef struct wan_device 483 { 484 unsigned magic; /* magic number */ 485 char* name; /* -> WAN device name (ASCIIZ) */ 486 void* private; /* -> driver private data */ 487 unsigned config_id; /* Configuration ID */ 488 /****** hardware configuration ******/ 489 unsigned ioport; /* adapter I/O port base #1 */ 490 char S514_cpu_no[1]; /* PCI CPU Number */ 491 unsigned char S514_slot_no; /* PCI Slot Number */ 492 unsigned long maddr; /* dual-port memory address */ 493 unsigned msize; /* dual-port memory size */ 494 int irq; /* interrupt request level */ 495 int dma; /* DMA request level */ 496 unsigned bps; /* data transfer rate */ 497 unsigned mtu; /* max physical transmit unit size */ 498 unsigned udp_port; /* UDP port for management */ 499 unsigned char ttl; /* Time To Live for UDP security */ 500 unsigned enable_tx_int; /* Transmit Interrupt enabled or not */ 501 char interface; /* RS-232/V.35, etc. */ 502 char clocking; /* external/internal */ 503 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */ 504 char station; /* DTE/DCE, primary/secondary, etc. */ 505 char connection; /* permanent/switched/on-demand */ 506 char signalling; /* Signalling RS232 or V35 */ 507 char read_mode; /* read mode: Polling or interrupt */ 508 char new_if_cnt; /* Number of interfaces per wanpipe */ 509 char del_if_cnt; /* Number of times del_if() gets called */ 510 unsigned char piggyback; /* Piggibacking a port */ 511 unsigned hw_opt[4]; /* other hardware options */ 512 /****** status and statistics *******/ 513 char state; /* device state */ 514 char api_status; /* device api status */ 515 #if defined(LINUX_2_1) || defined(LINUX_2_4) 516 struct net_device_stats stats; /* interface statistics */ 517 #else 518 struct enet_statistics stats; /* interface statistics */ 519 #endif 520 unsigned reserved[16]; /* reserved for future use */ 521 unsigned long critical; /* critical section flag */ 522 spinlock_t lock; /* Support for SMP Locking */ 523 524 /****** device management methods ***/ 525 int (*setup) (struct wan_device *wandev, wandev_conf_t *conf); 526 int (*shutdown) (struct wan_device *wandev); 527 int (*update) (struct wan_device *wandev); 528 int (*ioctl) (struct wan_device *wandev, unsigned cmd, 529 unsigned long arg); 530 int (*new_if) (struct wan_device *wandev, netdevice_t *dev, 531 wanif_conf_t *conf); 532 int (*del_if) (struct wan_device *wandev, netdevice_t *dev); 533 /****** maintained by the router ****/ 534 struct wan_device* next; /* -> next device */ 535 netdevice_t* dev; /* list of network interfaces */ 536 unsigned ndev; /* number of interfaces */ 537 #ifdef LINUX_2_4 538 struct proc_dir_entry *dent; /* proc filesystem entry */ 539 #else 540 struct proc_dir_entry dent; /* proc filesystem entry */ 541 #endif 542 } wan_device_t; 543 544 /* Public functions available for device drivers */ 545 extern int register_wan_device(wan_device_t *wandev); 546 extern int unregister_wan_device(char *name); 547 unsigned short wanrouter_type_trans(struct sk_buff *skb, netdevice_t *dev); 548 int wanrouter_encapsulate(struct sk_buff *skb, netdevice_t *dev,unsigned short type); 549 550 /* Proc interface functions. These must not be called by the drivers! */ 551 extern int wanrouter_proc_init(void); 552 extern void wanrouter_proc_cleanup(void); 553 extern int wanrouter_proc_add(wan_device_t *wandev); 554 extern int wanrouter_proc_delete(wan_device_t *wandev); 555 extern int wanrouter_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); 556 557 extern void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags); 558 extern void unlock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags); 559 560 561 562 /* Public Data */ 563 extern wan_device_t *router_devlist; /* list of registered devices */ 564 565 #endif /* __KERNEL__ */ 566 #endif /* _ROUTER_H */ 567