added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / include / linux / isdn.h
1 /* $Id: isdn.h,v 1.1.1.1 2005/04/11 02:51:02 jack Exp $
2  *
3  * Main header for the Linux ISDN subsystem (linklevel).
4  *
5  * Copyright 1994,95,96 by Fritz Elfert (fritz@isdn4linux.de)
6  * Copyright 1995,96    by Thinking Objects Software GmbH Wuerzburg
7  * Copyright 1995,96    by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de)
8  * 
9  * This software may be used and distributed according to the terms
10  * of the GNU General Public License, incorporated herein by reference.
11  *
12  */
13
14 #ifndef __ISDN_H__
15 #define __ISDN_H__
16
17 #include <linux/ioctl.h>
18
19 #ifdef CONFIG_COBALT_MICRO_SERVER
20 /* Save memory */
21 #define ISDN_MAX_DRIVERS    2
22 #define ISDN_MAX_CHANNELS   8
23 #else
24 #define ISDN_MAX_DRIVERS    32
25 #define ISDN_MAX_CHANNELS   64
26 #endif
27
28 /* New ioctl-codes */
29 #define IIOCNETAIF  _IO('I',1)
30 #define IIOCNETDIF  _IO('I',2)
31 #define IIOCNETSCF  _IO('I',3)
32 #define IIOCNETGCF  _IO('I',4)
33 #define IIOCNETANM  _IO('I',5)
34 #define IIOCNETDNM  _IO('I',6)
35 #define IIOCNETGNM  _IO('I',7)
36 #define IIOCGETSET  _IO('I',8) /* no longer supported */
37 #define IIOCSETSET  _IO('I',9) /* no longer supported */
38 #define IIOCSETVER  _IO('I',10)
39 #define IIOCNETHUP  _IO('I',11)
40 #define IIOCSETGST  _IO('I',12)
41 #define IIOCSETBRJ  _IO('I',13)
42 #define IIOCSIGPRF  _IO('I',14)
43 #define IIOCGETPRF  _IO('I',15)
44 #define IIOCSETPRF  _IO('I',16)
45 #define IIOCGETMAP  _IO('I',17)
46 #define IIOCSETMAP  _IO('I',18)
47 #define IIOCNETASL  _IO('I',19)
48 #define IIOCNETDIL  _IO('I',20)
49 #define IIOCGETCPS  _IO('I',21)
50 #define IIOCGETDVR  _IO('I',22)
51 #define IIOCNETLCR  _IO('I',23) /* dwabc ioctl for LCR from isdnlog */
52 #define IIOCNETDWRSET  _IO('I',24) /* dwabc ioctl to reset abc-values to default on a net-interface */
53
54 #define IIOCNETALN  _IO('I',32)
55 #define IIOCNETDLN  _IO('I',33)
56
57 #define IIOCNETGPN  _IO('I',34)
58
59 #define IIOCDBGVAR  _IO('I',127)
60
61 #define IIOCDRVCTL  _IO('I',128)
62
63 /* cisco hdlck device private ioctls */
64 #define SIOCGKEEPPERIOD (SIOCDEVPRIVATE + 0)
65 #define SIOCSKEEPPERIOD (SIOCDEVPRIVATE + 1)
66 #define SIOCGDEBSERINT  (SIOCDEVPRIVATE + 2)
67 #define SIOCSDEBSERINT  (SIOCDEVPRIVATE + 3)
68
69 /* Packet encapsulations for net-interfaces */
70 #define ISDN_NET_ENCAP_ETHER      0
71 #define ISDN_NET_ENCAP_RAWIP      1
72 #define ISDN_NET_ENCAP_IPTYP      2
73 #define ISDN_NET_ENCAP_CISCOHDLC  3 /* Without SLARP and keepalive */
74 #define ISDN_NET_ENCAP_SYNCPPP    4
75 #define ISDN_NET_ENCAP_UIHDLC     5
76 #define ISDN_NET_ENCAP_CISCOHDLCK 6 /* With SLARP and keepalive    */
77 #define ISDN_NET_ENCAP_X25IFACE   7 /* Documentation/networking/x25-iface.txt*/
78 #define ISDN_NET_ENCAP_MAX_ENCAP  ISDN_NET_ENCAP_X25IFACE
79
80 /* Facility which currently uses an ISDN-channel */
81 #define ISDN_USAGE_NONE       0
82 #define ISDN_USAGE_RAW        1
83 #define ISDN_USAGE_MODEM      2
84 #define ISDN_USAGE_NET        3
85 #define ISDN_USAGE_VOICE      4
86 #define ISDN_USAGE_FAX        5
87 #define ISDN_USAGE_MASK       7 /* Mask to get plain usage */
88 #define ISDN_USAGE_DISABLED  32 /* This bit is set, if channel is disabled */
89 #define ISDN_USAGE_EXCLUSIVE 64 /* This bit is set, if channel is exclusive */
90 #define ISDN_USAGE_OUTGOING 128 /* This bit is set, if channel is outgoing  */
91
92 #define ISDN_MODEM_NUMREG    24        /* Number of Modem-Registers        */
93 #define ISDN_LMSNLEN         255 /* Length of tty's Listen-MSN string */
94 #define ISDN_CMSGLEN         50  /* Length of CONNECT-Message to add for Modem */
95
96 #define ISDN_MSNLEN          32
97 #define NET_DV 0x06  /* Data version for isdn_net_ioctl_cfg   */
98 #define TTY_DV 0x06  /* Data version for iprofd etc.          */
99
100 #define INF_DV 0x01  /* Data version for /dev/isdninfo        */
101
102 typedef struct {
103   char drvid[25];
104   unsigned long arg;
105 } isdn_ioctl_struct;
106
107 typedef struct {
108   char name[10];
109   char phone[ISDN_MSNLEN];
110   int  outgoing;
111 } isdn_net_ioctl_phone;
112
113 typedef struct {
114   char name[10];     /* Name of interface                     */
115   char master[10];   /* Name of Master for Bundling           */
116   char slave[10];    /* Name of Slave for Bundling            */
117   char eaz[256];     /* EAZ/MSN                               */
118   char drvid[25];    /* DriverId for Bindings                 */
119   int  onhtime;      /* Hangup-Timeout                        */
120   int  charge;       /* Charge-Units                          */
121   int  l2_proto;     /* Layer-2 protocol                      */
122   int  l3_proto;     /* Layer-3 protocol                      */
123   int  p_encap;      /* Encapsulation                         */
124   int  exclusive;    /* Channel, if bound exclusive           */
125   int  dialmax;      /* Dial Retry-Counter                    */
126   int  slavedelay;   /* Delay until slave starts up           */
127   int  cbdelay;      /* Delay before Callback                 */
128   int  chargehup;    /* Flag: Charge-Hangup                   */
129   int  ihup;         /* Flag: Hangup-Timeout on incoming line */
130   int  secure;       /* Flag: Secure                          */
131   int  callback;     /* Flag: Callback                        */
132   int  cbhup;        /* Flag: Reject Call before Callback     */
133   int  pppbind;      /* ippp device for bindings              */
134   int  chargeint;    /* Use fixed charge interval length      */
135   int  triggercps;   /* BogoCPS needed for triggering slave   */
136   int  dialtimeout;  /* Dial-Timeout                          */
137   int  dialwait;     /* Time to wait after failed dial        */
138   int  dialmode;     /* Flag: off / on / auto                 */
139 } isdn_net_ioctl_cfg;
140
141 #define ISDN_NET_DIALMODE_MASK  0xC0    /* bits for status                */
142 #define ISDN_NET_DM_OFF         0x00    /* this interface is stopped      */
143 #define ISDN_NET_DM_MANUAL      0x40    /* this interface is on (manual)  */
144 #define ISDN_NET_DM_AUTO        0x80    /* this interface is autodial     */
145 #define ISDN_NET_DIALMODE(x) ((&(x))->flags & ISDN_NET_DIALMODE_MASK)
146
147 #ifdef __KERNEL__
148
149 #include <linux/config.h>
150 #include <linux/errno.h>
151 #include <linux/fs.h>
152 #include <linux/major.h>
153 #include <asm/segment.h>
154 #include <asm/io.h>
155 #include <linux/kernel.h>
156 #include <linux/signal.h>
157 #include <linux/slab.h>
158 #include <linux/timer.h>
159 #include <linux/wait.h>
160 #include <linux/tty.h>
161 #include <linux/tty_flip.h>
162 #include <linux/serial_reg.h>
163 #include <linux/fcntl.h>
164 #include <linux/types.h>
165 #include <linux/interrupt.h>
166 #include <linux/ip.h>
167 #include <linux/in.h>
168 #include <linux/netdevice.h>
169 #include <linux/etherdevice.h>
170 #include <linux/skbuff.h>
171 #include <linux/tcp.h>
172
173 #define ISDN_TTY_MAJOR    43
174 #define ISDN_TTYAUX_MAJOR 44
175 #define ISDN_MAJOR        45
176
177 /* The minor-devicenumbers for Channel 0 and 1 are used as arguments for
178  * physical Channel-Mapping, so they MUST NOT be changed without changing
179  * the correspondent code in isdn.c
180  */
181
182 #define ISDN_MINOR_B        0
183 #define ISDN_MINOR_BMAX     (ISDN_MAX_CHANNELS-1)
184 #define ISDN_MINOR_CTRL     64
185 #define ISDN_MINOR_CTRLMAX  (64 + (ISDN_MAX_CHANNELS-1))
186 #define ISDN_MINOR_PPP      128
187 #define ISDN_MINOR_PPPMAX   (128 + (ISDN_MAX_CHANNELS-1))
188 #define ISDN_MINOR_STATUS   255
189
190 #ifdef CONFIG_ISDN_PPP
191
192 #ifdef CONFIG_ISDN_PPP_VJ
193 #  include <net/slhc_vj.h>
194 #endif
195
196 #include <linux/ppp_defs.h>
197 #include <linux/if_ppp.h>
198 #include <linux/if_pppvar.h>
199
200 #include <linux/isdn_ppp.h>
201 #endif
202
203 #ifdef CONFIG_ISDN_X25
204 #  include <linux/concap.h>
205 #endif
206
207 #ifdef CONFIG_DEVFS_FS
208 #  include <linux/devfs_fs_kernel.h>
209 #endif
210
211 #include <linux/isdnif.h>
212
213 #define ISDN_DRVIOCTL_MASK       0x7f  /* Mask for Device-ioctl */
214
215 /* Until now unused */
216 #define ISDN_SERVICE_VOICE 1
217 #define ISDN_SERVICE_AB    1<<1 
218 #define ISDN_SERVICE_X21   1<<2
219 #define ISDN_SERVICE_G4    1<<3
220 #define ISDN_SERVICE_BTX   1<<4
221 #define ISDN_SERVICE_DFUE  1<<5
222 #define ISDN_SERVICE_X25   1<<6
223 #define ISDN_SERVICE_TTX   1<<7
224 #define ISDN_SERVICE_MIXED 1<<8
225 #define ISDN_SERVICE_FW    1<<9
226 #define ISDN_SERVICE_GTEL  1<<10
227 #define ISDN_SERVICE_BTXN  1<<11
228 #define ISDN_SERVICE_BTEL  1<<12
229
230 /* Macros checking plain usage */
231 #define USG_NONE(x)         ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
232 #define USG_RAW(x)          ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
233 #define USG_MODEM(x)        ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
234 #define USG_VOICE(x)        ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)
235 #define USG_NET(x)          ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
236 #define USG_FAX(x)          ((x & ISDN_USAGE_MASK)==ISDN_USAGE_FAX)
237 #define USG_OUTGOING(x)     ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
238 #define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \
239                              ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)     )
240
241 /* Timer-delays and scheduling-flags */
242 #define ISDN_TIMER_RES         4                         /* Main Timer-Resolution   */
243 #define ISDN_TIMER_02SEC       (HZ/ISDN_TIMER_RES/5)     /* Slow-Timer1 .2 sec      */
244 #define ISDN_TIMER_1SEC        (HZ/ISDN_TIMER_RES)       /* Slow-Timer2 1 sec       */
245 #define ISDN_TIMER_RINGING     5 /* tty RINGs = ISDN_TIMER_1SEC * this factor       */
246 #define ISDN_TIMER_KEEPINT    10 /* Cisco-Keepalive = ISDN_TIMER_1SEC * this factor */
247 #define ISDN_TIMER_MODEMREAD   1
248 #define ISDN_TIMER_MODEMPLUS   2
249 #define ISDN_TIMER_MODEMRING   4
250 #define ISDN_TIMER_MODEMXMIT   8
251 #define ISDN_TIMER_NETDIAL    16 
252 #define ISDN_TIMER_NETHANGUP  32
253 #define ISDN_TIMER_CARRIER   256 /* Wait for Carrier */
254 #define ISDN_TIMER_FAST      (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
255                               ISDN_TIMER_MODEMXMIT)
256 #define ISDN_TIMER_SLOW      (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
257                               ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER)
258
259 /* Timeout-Values for isdn_net_dial() */
260 #define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
261 #define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
262 #define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
263
264 /* GLOBAL_FLAGS */
265 #define ISDN_GLOBAL_STOPPED 1
266
267 /*=================== Start of ip-over-ISDN stuff =========================*/
268
269 /* Feature- and status-flags for a net-interface */
270 #define ISDN_NET_CONNECTED  0x01       /* Bound to ISDN-Channel             */
271 #define ISDN_NET_SECURE     0x02       /* Accept calls from phonelist only  */
272 #define ISDN_NET_CALLBACK   0x04       /* activate callback                 */
273 #define ISDN_NET_CBHUP      0x08       /* hangup before callback            */
274 #define ISDN_NET_CBOUT      0x10       /* remote machine does callback      */
275
276 #define ISDN_NET_MAGIC      0x49344C02 /* for paranoia-checking             */
277
278 /* Phone-list-element */
279 typedef struct {
280   void *next;
281   char num[ISDN_MSNLEN];
282 } isdn_net_phone;
283
284 /*
285    Principles when extending structures for generic encapsulation protocol
286    ("concap") support:
287    - Stuff which is hardware specific (here i4l-specific) goes in 
288      the netdev -> local structure (here: isdn_net_local)
289    - Stuff which is encapsulation protocol specific goes in the structure
290      which holds the linux device structure (here: isdn_net_device)
291 */
292
293 /* Local interface-data */
294 typedef struct isdn_net_local_s {
295   ulong                  magic;
296   char                   name[10];     /* Name of device                   */
297   struct net_device_stats stats;       /* Ethernet Statistics              */
298   int                    isdn_device;  /* Index to isdn-device             */
299   int                    isdn_channel; /* Index to isdn-channel            */
300   int                    ppp_slot;     /* PPPD device slot number          */
301   int                    pre_device;   /* Preselected isdn-device          */
302   int                    pre_channel;  /* Preselected isdn-channel         */
303   int                    exclusive;    /* If non-zero idx to reserved chan.*/
304   int                    flags;        /* Connection-flags                 */
305   int                    dialretry;    /* Counter for Dialout-retries      */
306   int                    dialmax;      /* Max. Number of Dial-retries      */
307   int                    cbdelay;      /* Delay before Callback starts     */
308   int                    dtimer;       /* Timeout-counter for dialing      */
309   char                   msn[ISDN_MSNLEN]; /* MSNs/EAZs for this interface */
310   u_char                 cbhup;        /* Flag: Reject Call before Callback*/
311   u_char                 dialstate;    /* State for dialing                */
312   u_char                 p_encap;      /* Packet encapsulation             */
313                                        /*   0 = Ethernet over ISDN         */
314                                        /*   1 = RAW-IP                     */
315                                        /*   2 = IP with type field         */
316   u_char                 l2_proto;     /* Layer-2-protocol                 */
317                                        /* See ISDN_PROTO_L2..-constants in */
318                                        /* isdnif.h                         */
319                                        /*   0 = X75/LAPB with I-Frames     */
320                                        /*   1 = X75/LAPB with UI-Frames    */
321                                        /*   2 = X75/LAPB with BUI-Frames   */
322                                        /*   3 = HDLC                       */
323   u_char                 l3_proto;     /* Layer-3-protocol                 */
324                                        /* See ISDN_PROTO_L3..-constants in */
325                                        /* isdnif.h                         */
326                                        /*   0 = Transparent                */
327   int                    huptimer;     /* Timeout-counter for auto-hangup  */
328   int                    charge;       /* Counter for charging units       */
329   ulong                  chargetime;   /* Timer for Charging info          */
330   int                    hupflags;     /* Flags for charge-unit-hangup:    */
331                                        /* bit0: chargeint is invalid       */
332                                        /* bit1: Getting charge-interval    */
333                                        /* bit2: Do charge-unit-hangup      */
334                                        /* bit3: Do hangup even on incoming */
335   int                    outgoing;     /* Flag: outgoing call              */
336   int                    onhtime;      /* Time to keep link up             */
337   int                    chargeint;    /* Interval between charge-infos    */
338   int                    onum;         /* Flag: at least 1 outgoing number */
339   int                    cps;          /* current speed of this interface  */
340   int                    transcount;   /* byte-counter for cps-calculation */
341   int                    sqfull;       /* Flag: netdev-queue overloaded    */
342   ulong                  sqfull_stamp; /* Start-Time of overload           */
343   ulong                  slavedelay;   /* Dynamic bundling delaytime       */
344   int                    triggercps;   /* BogoCPS needed for trigger slave */
345   isdn_net_phone         *phone[2];    /* List of remote-phonenumbers      */
346                                        /* phone[0] = Incoming Numbers      */
347                                        /* phone[1] = Outgoing Numbers      */
348   isdn_net_phone         *dial;        /* Pointer to dialed number         */
349   struct net_device      *master;      /* Ptr to Master device for slaves  */
350   struct net_device      *slave;       /* Ptr to Slave device for masters  */
351   struct isdn_net_local_s *next;       /* Ptr to next link in bundle       */
352   struct isdn_net_local_s *last;       /* Ptr to last link in bundle       */
353   struct isdn_net_dev_s  *netdev;      /* Ptr to netdev                    */
354   struct sk_buff_head    super_tx_queue; /* List of supervisory frames to  */
355                                        /* be transmitted asap              */
356   atomic_t frame_cnt;                  /* number of frames currently       */
357                                        /* queued in HL driver              */    
358                                        /* Ptr to orig. hard_header_cache   */
359   spinlock_t             xmit_lock;    /* used to protect the xmit path of */
360                                        /* a particular channel (including  */
361                                        /* the frame_cnt                    */
362
363   int                    (*org_hhc)(
364                                     struct neighbour *neigh,
365                                     struct hh_cache *hh);
366                                        /* Ptr to orig. header_cache_update */
367   void                   (*org_hcu)(struct hh_cache *,
368                                     struct net_device *,
369                                     unsigned char *);
370   int  pppbind;                        /* ippp device for bindings         */
371   int                                   dialtimeout;    /* How long shall we try on dialing? (jiffies) */
372   int                                   dialwait;               /* How long shall we wait after failed attempt? (jiffies) */
373   ulong                                 dialstarted;    /* jiffies of first dialing-attempt */
374   ulong                                 dialwait_timer; /* jiffies of earliest next dialing-attempt */
375   int                                   huptimeout;             /* How long will the connection be up? (seconds) */
376 #ifdef CONFIG_ISDN_X25
377   struct concap_device_ops *dops;      /* callbacks used by encapsulator   */
378 #endif
379   /* use an own struct for that in later versions */
380   ulong cisco_myseq;                   /* Local keepalive seq. for Cisco   */
381   ulong cisco_mineseen;                /* returned keepalive seq. from remote */
382   ulong cisco_yourseq;                 /* Remote keepalive seq. for Cisco  */
383   int cisco_keepalive_period;           /* keepalive period */
384   ulong cisco_last_slarp_in;            /* jiffie of last keepalive packet we received */
385   char cisco_line_state;                /* state of line according to keepalive packets */
386   char cisco_debserint;                 /* debugging flag of cisco hdlc with slarp */
387   struct timer_list cisco_timer;
388   struct tq_struct tqueue;
389 } isdn_net_local;
390
391 /* the interface itself */
392 typedef struct isdn_net_dev_s {
393   isdn_net_local *local;
394   isdn_net_local *queue;               /* circular list of all bundled
395                                           channels, which are currently
396                                           online                           */
397   spinlock_t queue_lock;               /* lock to protect queue            */
398   void *next;                          /* Pointer to next isdn-interface   */
399   struct net_device dev;               /* interface to upper levels        */
400 #ifdef CONFIG_ISDN_PPP
401   ippp_bundle * pb;             /* pointer to the common bundle structure
402                                  * with the per-bundle data */
403 #endif
404 #ifdef CONFIG_ISDN_X25
405   struct concap_proto  *cprot; /* connection oriented encapsulation protocol */
406 #endif
407
408 } isdn_net_dev;
409
410 /*===================== End of ip-over-ISDN stuff ===========================*/
411
412 /*======================= Start of ISDN-tty stuff ===========================*/
413
414 #define ISDN_ASYNC_MAGIC          0x49344C01 /* for paranoia-checking        */
415 #define ISDN_ASYNC_INITIALIZED    0x80000000 /* port was initialized         */
416 #define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000 /* Call out device active       */
417 #define ISDN_ASYNC_NORMAL_ACTIVE  0x20000000 /* Normal device active         */
418 #define ISDN_ASYNC_CLOSING        0x08000000 /* Serial port is closing       */
419 #define ISDN_ASYNC_CTS_FLOW       0x04000000 /* Do CTS flow control          */
420 #define ISDN_ASYNC_CHECK_CD       0x02000000 /* i.e., CLOCAL                 */
421 #define ISDN_ASYNC_HUP_NOTIFY         0x0001 /* Notify tty on hangups/closes */
422 #define ISDN_ASYNC_SESSION_LOCKOUT    0x0100 /* Lock cua opens on session    */
423 #define ISDN_ASYNC_PGRP_LOCKOUT       0x0200 /* Lock cua opens on pgrp       */
424 #define ISDN_ASYNC_CALLOUT_NOHUP      0x0400 /* No hangup for cui            */
425 #define ISDN_ASYNC_SPLIT_TERMIOS      0x0008 /* Sep. termios for dialin/out  */
426 #define ISDN_SERIAL_XMIT_SIZE           1024 /* Default bufsize for write    */
427 #define ISDN_SERIAL_XMIT_MAX            4000 /* Maximum bufsize for write    */
428 #define ISDN_SERIAL_TYPE_NORMAL            1
429 #define ISDN_SERIAL_TYPE_CALLOUT           2
430
431 #ifdef CONFIG_ISDN_AUDIO
432 /* For using sk_buffs with audio we need some private variables
433  * within each sk_buff. For this purpose, we declare a struct here,
434  * and put it always at skb->head. A few macros help accessing the
435  * variables. Of course, we need to check skb_headroom prior to
436  * any access.
437  */
438 typedef struct isdn_audio_skb {
439   unsigned short dle_count;
440   unsigned char  lock;
441 } isdn_audio_skb;
442
443 #define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_skb*)skb->head)->dle_count)
444 #define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_skb*)skb->head)->lock)
445 #endif
446
447 /* Private data of AT-command-interpreter */
448 typedef struct atemu {
449         u_char       profile[ISDN_MODEM_NUMREG]; /* Modem-Regs. Profile 0              */
450         u_char       mdmreg[ISDN_MODEM_NUMREG];  /* Modem-Registers                    */
451         char         pmsn[ISDN_MSNLEN];          /* EAZ/MSNs Profile 0                 */
452         char         msn[ISDN_MSNLEN];           /* EAZ/MSN                            */
453         char         plmsn[ISDN_LMSNLEN];        /* Listening MSNs Profile 0           */
454         char         lmsn[ISDN_LMSNLEN];         /* Listening MSNs                     */
455         char         cpn[ISDN_MSNLEN];           /* CalledPartyNumber on incoming call */
456         char         connmsg[ISDN_CMSGLEN];      /* CONNECT-Msg from HL-Driver         */
457 #ifdef CONFIG_ISDN_AUDIO
458         u_char       vpar[10];                   /* Voice-parameters                   */
459         int          lastDLE;                    /* Flag for voice-coding: DLE seen    */
460 #endif
461         int          mdmcmdl;                    /* Length of Modem-Commandbuffer      */
462         int          pluscount;                  /* Counter for +++ sequence           */
463         int          lastplus;                   /* Timestamp of last +                */
464         int          carrierwait;                /* Seconds of carrier waiting         */
465         char         mdmcmd[255];                /* Modem-Commandbuffer                */
466         unsigned int charge;                     /* Charge units of current connection */
467 } atemu;
468
469 /* Private data (similar to async_struct in <linux/serial.h>) */
470 typedef struct modem_info {
471   int                   magic;
472   int                   flags;           /* defined in tty.h               */
473   int                   x_char;          /* xon/xoff character             */
474   int                   mcr;             /* Modem control register         */
475   int                   msr;             /* Modem status register          */
476   int                   lsr;             /* Line status register           */
477   int                   line;
478   int                   count;           /* # of fd on device              */
479   int                   blocked_open;    /* # of blocked opens             */
480   long                  session;         /* Session of opening process     */
481   long                  pgrp;            /* pgrp of opening process        */
482   int                   online;          /* 1 = B-Channel is up, drop data */
483                                          /* 2 = B-Channel is up, deliver d.*/
484   int                   dialing;         /* Dial in progress or ATA        */
485   int                   rcvsched;        /* Receive needs schedule         */
486   int                   isdn_driver;     /* Index to isdn-driver           */
487   int                   isdn_channel;    /* Index to isdn-channel          */
488   int                   drv_index;       /* Index to dev->usage            */
489   int                   ncarrier;        /* Flag: schedule NO CARRIER      */
490   unsigned char         last_cause[8];   /* Last cause message             */
491   unsigned char         last_num[ISDN_MSNLEN];
492                                          /* Last phone-number              */
493   unsigned char         last_l2;         /* Last layer-2 protocol          */
494   unsigned char         last_si;         /* Last service                   */
495   unsigned char         last_lhup;       /* Last hangup local?             */
496   unsigned char         last_dir;        /* Last direction (in or out)     */
497   struct timer_list     nc_timer;        /* Timer for delayed NO CARRIER   */
498   int                   send_outstanding;/* # of outstanding send-requests */
499   int                   xmit_size;       /* max. # of chars in xmit_buf    */
500   int                   xmit_count;      /* # of chars in xmit_buf         */
501   unsigned char         *xmit_buf;       /* transmit buffer                */
502   struct sk_buff_head   xmit_queue;      /* transmit queue                 */
503   atomic_t              xmit_lock;       /* Semaphore for isdn_tty_write   */
504 #ifdef CONFIG_ISDN_AUDIO
505   int                   vonline;         /* Voice-channel status           */
506                                          /* Bit 0 = recording              */
507                                          /* Bit 1 = playback               */
508                                          /* Bit 2 = playback, DLE-ETX seen */
509   struct sk_buff_head   dtmf_queue;      /* queue for dtmf results         */
510   void                  *adpcms;         /* state for adpcm decompression  */
511   void                  *adpcmr;         /* state for adpcm compression    */
512   void                  *dtmf_state;     /* state for dtmf decoder         */
513   void                  *silence_state;  /* state for silence detection    */
514 #endif
515 #ifdef CONFIG_ISDN_TTY_FAX
516   struct T30_s          *fax;            /* T30 Fax Group 3 data/interface */
517   int                   faxonline;       /* Fax-channel status             */
518 #endif
519   struct tty_struct     *tty;            /* Pointer to corresponding tty   */
520   atemu                 emu;             /* AT-emulator data               */
521   struct termios        normal_termios;  /* For saving termios structs     */
522   struct termios        callout_termios;
523   wait_queue_head_t     open_wait, close_wait;
524   struct semaphore      write_sem;
525 } modem_info;
526
527 #define ISDN_MODEM_WINSIZE 8
528
529 /* Description of one ISDN-tty */
530 typedef struct {
531   int                refcount;                     /* Number of opens        */
532   struct tty_driver  tty_modem;                    /* tty-device             */
533   struct tty_driver  cua_modem;                    /* cua-device             */
534   struct tty_struct  *modem_table[ISDN_MAX_CHANNELS]; /* ?? copied from Orig */
535   struct termios     *modem_termios[ISDN_MAX_CHANNELS];
536   struct termios     *modem_termios_locked[ISDN_MAX_CHANNELS];
537   modem_info         info[ISDN_MAX_CHANNELS];      /* Private data           */
538 } modem;
539
540 /*======================= End of ISDN-tty stuff ============================*/
541
542 /*======================== Start of V.110 stuff ============================*/
543 #define V110_BUFSIZE 1024
544
545 typedef struct {
546         int nbytes;                    /* 1 Matrixbyte -> nbytes in stream     */
547         int nbits;                     /* Number of used bits in streambyte    */
548         unsigned char key;             /* Bitmask in stream eg. 11 (nbits=2)   */
549         int decodelen;                 /* Amount of data in decodebuf          */
550         int SyncInit;                  /* Number of sync frames to send        */
551         unsigned char *OnlineFrame;    /* Precalculated V110 idle frame        */
552         unsigned char *OfflineFrame;   /* Precalculated V110 sync Frame        */
553         int framelen;                  /* Length of frames                     */
554         int skbuser;                   /* Number of unacked userdata skbs      */
555         int skbidle;                   /* Number of unacked idle/sync skbs     */
556         int introducer;                /* Local vars for decoder               */
557         int dbit;
558         unsigned char b;
559         int skbres;                    /* space to reserve in outgoing skb     */
560         int maxsize;                   /* maxbufsize of lowlevel driver        */
561         unsigned char *encodebuf;      /* temporary buffer for encoding        */
562         unsigned char decodebuf[V110_BUFSIZE]; /* incomplete V110 matrices     */
563 } isdn_v110_stream;
564
565 /*========================= End of V.110 stuff =============================*/
566
567 /*======================= Start of general stuff ===========================*/
568
569 typedef struct {
570         char *next;
571         char *private;
572 } infostruct;
573
574 #define DRV_FLAG_RUNNING 1
575 #define DRV_FLAG_REJBUS  2
576 #define DRV_FLAG_LOADED  4
577
578 /* Description of hardware-level-driver */
579 typedef struct {
580         ulong               online;           /* Channel-Online flags             */
581         ulong               flags;            /* Misc driver Flags                */
582         int                 locks;            /* Number of locks for this driver  */
583         int                 channels;         /* Number of channels               */
584         wait_queue_head_t   st_waitq;         /* Wait-Queue for status-read's     */
585         int                 maxbufsize;       /* Maximum Buffersize supported     */
586         unsigned long       pktcount;         /* Until now: unused                */
587         int                 stavail;          /* Chars avail on Status-device     */
588         isdn_if            *interface;        /* Interface to driver              */
589         int                *rcverr;           /* Error-counters for B-Ch.-receive */
590         int                *rcvcount;         /* Byte-counters for B-Ch.-receive  */
591 #ifdef CONFIG_ISDN_AUDIO
592         unsigned long      DLEflag;           /* Flags: Insert DLE at next read   */
593 #endif
594         struct sk_buff_head *rpqueue;         /* Pointers to start of Rcv-Queue   */
595         wait_queue_head_t  *rcv_waitq;       /* Wait-Queues for B-Channel-Reads  */
596         wait_queue_head_t  *snd_waitq;       /* Wait-Queue for B-Channel-Send's  */
597         char               msn2eaz[10][ISDN_MSNLEN];  /* Mapping-Table MSN->EAZ   */
598 } driver;
599
600 /* Main driver-data */
601 typedef struct isdn_devt {
602         unsigned short    flags;                       /* Bitmapped Flags:           */
603         /*                            */
604         int               drivers;                     /* Current number of drivers  */
605         int               channels;                    /* Current number of channels */
606         int               net_verbose;               /* Verbose-Flag               */
607         int               modempoll;                   /* Flag: tty-read active      */
608         int               tflags;                    /* Timer-Flags:               */
609         /*  see ISDN_TIMER_..defines  */
610         int               global_flags;
611         infostruct        *infochain;                /* List of open info-devs.    */
612         wait_queue_head_t info_waitq;               /* Wait-Queue for isdninfo    */
613         struct timer_list timer;                       /* Misc.-function Timer       */
614         int               chanmap[ISDN_MAX_CHANNELS];/* Map minor->device-channel  */
615         int               drvmap[ISDN_MAX_CHANNELS]; /* Map minor->driver-index    */
616         int               usage[ISDN_MAX_CHANNELS];  /* Used by tty/ip/voice       */
617         char              num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
618         /* Remote number of active ch.*/
619         int               m_idx[ISDN_MAX_CHANNELS];  /* Index for mdm....          */
620         driver            *drv[ISDN_MAX_DRIVERS];    /* Array of drivers           */
621         isdn_net_dev      *netdev;                     /* Linked list of net-if's    */
622         char              drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID                 */
623         struct task_struct *profd;                   /* For iprofd                 */
624         modem             mdm;                 /* tty-driver-data            */
625         isdn_net_dev      *rx_netdev[ISDN_MAX_CHANNELS]; /* rx netdev-pointers     */
626         isdn_net_dev      *st_netdev[ISDN_MAX_CHANNELS]; /* stat netdev-pointers   */
627         ulong             ibytes[ISDN_MAX_CHANNELS]; /* Statistics incoming bytes  */
628         ulong             obytes[ISDN_MAX_CHANNELS]; /* Statistics outgoing bytes  */
629         int               v110emu[ISDN_MAX_CHANNELS];/* V.110 emulator-mode 0=none */
630         atomic_t          v110use[ISDN_MAX_CHANNELS];/* Usage-Semaphore for stream */
631         isdn_v110_stream  *v110[ISDN_MAX_CHANNELS];  /* V.110 private data         */
632         struct semaphore  sem;                       /* serialize list access*/
633         unsigned long     global_features;
634 #ifdef CONFIG_DEVFS_FS
635         devfs_handle_t devfs_handle_isdninfo;
636         devfs_handle_t devfs_handle_isdnctrl;
637         devfs_handle_t devfs_handle_isdnX[ISDN_MAX_CHANNELS];
638         devfs_handle_t devfs_handle_isdnctrlX[ISDN_MAX_CHANNELS];
639 #ifdef CONFIG_ISDN_PPP
640         devfs_handle_t devfs_handle_ipppX[ISDN_MAX_CHANNELS];
641 #endif
642 #endif /* CONFIG_DEVFS_FS */
643 } isdn_dev;
644
645 extern isdn_dev *dev;
646
647
648 #endif /* __KERNEL__ */
649
650 #endif /* __ISDN_H__ */