1/* $Id: isdnloop.h,v 1.1.1.1 2008/10/15 03:26:34 james26_jang Exp $
2 *
3 * Loopback lowlevel module for testing of linklevel.
4 *
5 * Copyright 1997 by Fritz Elfert (fritz@isdn4linux.de)
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#ifndef isdnloop_h
13#define isdnloop_h
14
15#define ISDNLOOP_IOCTL_DEBUGVAR  0
16#define ISDNLOOP_IOCTL_ADDCARD   1
17#define ISDNLOOP_IOCTL_LEASEDCFG 2
18#define ISDNLOOP_IOCTL_STARTUP   3
19
20/* Struct for adding new cards */
21typedef struct isdnloop_cdef {
22	char id1[10];
23} isdnloop_cdef;
24
25/* Struct for configuring cards */
26typedef struct isdnloop_sdef {
27	int ptype;
28	char num[3][20];
29} isdnloop_sdef;
30
31#if defined(__KERNEL__) || defined(__DEBUGVAR__)
32
33#ifdef __KERNEL__
34/* Kernel includes */
35
36#include <linux/version.h>
37#include <linux/errno.h>
38#include <linux/fs.h>
39#include <linux/major.h>
40#include <asm/segment.h>
41#include <asm/io.h>
42#include <linux/kernel.h>
43#include <linux/signal.h>
44#include <linux/slab.h>
45#include <linux/mm.h>
46#include <linux/mman.h>
47#include <linux/ioport.h>
48#include <linux/timer.h>
49#include <linux/wait.h>
50#include <linux/isdnif.h>
51
52#endif                          /* __KERNEL__ */
53
54#define ISDNLOOP_FLAGS_B1ACTIVE 1	/* B-Channel-1 is open           */
55#define ISDNLOOP_FLAGS_B2ACTIVE 2	/* B-Channel-2 is open           */
56#define ISDNLOOP_FLAGS_RUNNING  4	/* Cards driver activated        */
57#define ISDNLOOP_FLAGS_RBTIMER  8	/* scheduling of B-Channel-poll  */
58#define ISDNLOOP_TIMER_BCREAD 1 /* B-Channel poll-cycle          */
59#define ISDNLOOP_TIMER_DCREAD (HZ/2)	/* D-Channel poll-cycle          */
60#define ISDNLOOP_TIMER_ALERTWAIT (10*HZ)	/* Alert timeout                 */
61#define ISDNLOOP_MAX_SQUEUE 65536	/* Max. outstanding send-data    */
62#define ISDNLOOP_BCH 2          /* channels per card             */
63
64/*
65 * Per card driver data
66 */
67typedef struct isdnloop_card {
68	struct isdnloop_card *next;	/* Pointer to next device struct    */
69	struct isdnloop_card
70	*rcard[ISDNLOOP_BCH];   /* Pointer to 'remote' card         */
71	int rch[ISDNLOOP_BCH];  /* 'remote' channel                 */
72	int myid;               /* Driver-Nr. assigned by linklevel */
73	int leased;             /* Flag: This Adapter is connected  */
74	/*       to a leased line           */
75	int sil[ISDNLOOP_BCH];  /* SI's to listen for               */
76	char eazlist[ISDNLOOP_BCH][11];
77	/* EAZ's to listen for              */
78	char s0num[3][20];      /* 1TR6 base-number or MSN's        */
79	unsigned short flags;   /* Statusflags                      */
80	int ptype;              /* Protocol type (1TR6 or Euro)     */
81	struct timer_list st_timer;	/* Timer for Status-Polls           */
82	struct timer_list rb_timer;	/* Timer for B-Channel-Polls        */
83	struct timer_list
84	 c_timer[ISDNLOOP_BCH]; /* Timer for Alerting               */
85	int l2_proto[ISDNLOOP_BCH];	/* Current layer-2-protocol         */
86	isdn_if interface;      /* Interface to upper layer         */
87	int iptr;               /* Index to imsg-buffer             */
88	char imsg[60];          /* Internal buf for status-parsing  */
89	int optr;               /* Index to omsg-buffer             */
90	char omsg[60];          /* Internal buf for cmd-parsing     */
91	char msg_buf[2048];     /* Buffer for status-messages       */
92	char *msg_buf_write;    /* Writepointer for statusbuffer    */
93	char *msg_buf_read;     /* Readpointer for statusbuffer     */
94	char *msg_buf_end;      /* Pointer to end of statusbuffer   */
95	int sndcount[ISDNLOOP_BCH];	/* Byte-counters for B-Ch.-send     */
96	struct sk_buff_head
97	 bqueue[ISDNLOOP_BCH];  /* B-Channel queues                 */
98	struct sk_buff_head dqueue;	/* D-Channel queue                  */
99} isdnloop_card;
100
101/*
102 * Main driver data
103 */
104#ifdef __KERNEL__
105static isdnloop_card *cards = (isdnloop_card *) 0;
106#endif                          /* __KERNEL__ */
107
108/* Utility-Macros */
109
110#define CID (card->interface.id)
111
112#endif                          /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
113#endif                          /* isdnloop_h */
114