Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
/* Linux ISDN subsystem, main header
2
 *
3
 * Copyright 1994,95,96 by Fritz Elfert (fritz@isdn4linux.de)
4
 * Copyright 1995,96    by Thinking Objects Software GmbH Wuerzburg
5
 * Copyright 1995,96    by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de)
6
 * Copyright 2000-2002  by Kai Germaschewski (kai@germaschewski.name)
7
 *
8
 * This software may be used and distributed according to the terms
9
 * of the GNU General Public License, incorporated herein by reference.
10
 *
11
 */
12
 
13
#ifndef __ISDN_H__
14
#define __ISDN_H__
15
 
16
#include <linux/ioctl.h>
17
#include <linux/isdn/fsm.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_NR         8
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/io.h>
154
#include <linux/kernel.h>
155
#include <linux/signal.h>
156
#include <linux/slab.h>
157
#include <linux/timer.h>
158
#include <linux/wait.h>
159
#include <linux/tty.h>
160
#include <linux/tty_flip.h>
161
#include <linux/serial_reg.h>
162
#include <linux/fcntl.h>
163
#include <linux/types.h>
164
#include <linux/interrupt.h>
165
#include <linux/ip.h>
166
#include <linux/in.h>
167
#include <linux/netdevice.h>
168
#include <linux/etherdevice.h>
169
#include <linux/skbuff.h>
170
#include <linux/tcp.h>
171
 
172
#define ISDN_TTY_MAJOR    43
173
#define ISDN_TTYAUX_MAJOR 44
174
#define ISDN_MAJOR        45
175
 
176
/* The minor-devicenumbers for Channel 0 and 1 are used as arguments for
177
 * physical Channel-Mapping, so they MUST NOT be changed without changing
178
 * the correspondent code in isdn.c
179
 */
180
 
181
#define ISDN_MINOR_CTRL     64
182
#define ISDN_MINOR_CTRLMAX  (64 + (ISDN_MAX_CHANNELS-1))
183
#define ISDN_MINOR_PPP      128
184
#define ISDN_MINOR_PPPMAX   (128 + (ISDN_MAX_CHANNELS-1))
185
#define ISDN_MINOR_STATUS   255
186
 
187
#ifdef CONFIG_ISDN_PPP
188
 
189
#ifdef CONFIG_ISDN_PPP_VJ
190
#  include <net/slhc_vj.h>
191
#endif
192
 
193
#include <linux/ppp_defs.h>
194
#include <linux/if_ppp.h>
195
#include <linux/if_pppvar.h>
196
 
197
#include <linux/isdn_ppp.h>
198
#endif
199
 
200
#ifdef CONFIG_ISDN_X25
201
#  include <linux/concap.h>
202
#endif
203
 
204
#include <linux/isdnif.h>
205
 
206
#define ISDN_DRVIOCTL_MASK       0x7f  /* Mask for Device-ioctl */
207
 
208
/* Until now unused */
209
#define ISDN_SERVICE_VOICE 1
210
#define ISDN_SERVICE_AB    1<<1 
211
#define ISDN_SERVICE_X21   1<<2
212
#define ISDN_SERVICE_G4    1<<3
213
#define ISDN_SERVICE_BTX   1<<4
214
#define ISDN_SERVICE_DFUE  1<<5
215
#define ISDN_SERVICE_X25   1<<6
216
#define ISDN_SERVICE_TTX   1<<7
217
#define ISDN_SERVICE_MIXED 1<<8
218
#define ISDN_SERVICE_FW    1<<9
219
#define ISDN_SERVICE_GTEL  1<<10
220
#define ISDN_SERVICE_BTXN  1<<11
221
#define ISDN_SERVICE_BTEL  1<<12
222
 
223
/* Macros checking plain usage */
224
#define USG_NONE(x)         ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
225
#define USG_RAW(x)          ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
226
#define USG_MODEM(x)        ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
227
#define USG_VOICE(x)        ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)
228
#define USG_NET(x)          ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
229
#define USG_FAX(x)          ((x & ISDN_USAGE_MASK)==ISDN_USAGE_FAX)
230
#define USG_OUTGOING(x)     ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
231
#define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \
232
                             ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)     )
233
 
234
/* GLOBAL_FLAGS */
235
#define ISDN_GLOBAL_STOPPED 1
236
 
237
/*======================= Start of ISDN-tty stuff ===========================*/
238
 
239
#define ISDN_ASYNC_MAGIC          0x49344C01 /* for paranoia-checking        */
240
#define ISDN_ASYNC_INITIALIZED    0x80000000 /* port was initialized         */
241
#define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000 /* Call out device active       */
242
#define ISDN_ASYNC_NORMAL_ACTIVE  0x20000000 /* Normal device active         */
243
#define ISDN_ASYNC_CLOSING        0x08000000 /* Serial port is closing       */
244
#define ISDN_ASYNC_CTS_FLOW       0x04000000 /* Do CTS flow control          */
245
#define ISDN_ASYNC_CHECK_CD       0x02000000 /* i.e., CLOCAL                 */
246
#define ISDN_ASYNC_HUP_NOTIFY         0x0001 /* Notify tty on hangups/closes */
247
#define ISDN_ASYNC_SESSION_LOCKOUT    0x0100 /* Lock cua opens on session    */
248
#define ISDN_ASYNC_PGRP_LOCKOUT       0x0200 /* Lock cua opens on pgrp       */
249
#define ISDN_ASYNC_CALLOUT_NOHUP      0x0400 /* No hangup for cui            */
250
#define ISDN_ASYNC_SPLIT_TERMIOS      0x0008 /* Sep. termios for dialin/out  */
251
#define ISDN_SERIAL_XMIT_SIZE           1024 /* Default bufsize for write    */
252
#define ISDN_SERIAL_XMIT_MAX            4000 /* Maximum bufsize for write    */
253
 
254
#ifdef CONFIG_ISDN_AUDIO
255
/* For using sk_buffs with audio we need some private variables
256
 * within each sk_buff. For this purpose, we declare a struct here,
257
 * and put it always at skb->head. A few macros help accessing the
258
 * variables. Of course, we need to check skb_headroom prior to
259
 * any access.
260
 */
261
typedef struct _isdnaudio_header {
262
  unsigned short dle_count;
263
  unsigned char  lock;
264
} isdnaudio_header;
265
 
266
#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdnaudio_header*)skb->head)->dle_count)
267
#define ISDN_AUDIO_SKB_LOCK(skb) (((isdnaudio_header*)skb->head)->lock)
268
#endif
269
 
270
/* Private data of AT-command-interpreter */
271
typedef struct atemu {
272
        u_char       profile[ISDN_MODEM_NUMREG]; /* Modem-Regs. Profile 0              */
273
        u_char       mdmreg[ISDN_MODEM_NUMREG];  /* Modem-Registers                    */
274
        char         pmsn[ISDN_MSNLEN];          /* EAZ/MSNs Profile 0                 */
275
        char         msn[ISDN_MSNLEN];           /* EAZ/MSN                            */
276
        char         plmsn[ISDN_LMSNLEN];        /* Listening MSNs Profile 0           */
277
        char         lmsn[ISDN_LMSNLEN];         /* Listening MSNs                     */
278
        char         cpn[ISDN_MSNLEN];           /* CalledPartyNumber on incoming call */
279
        char         connmsg[ISDN_CMSGLEN];      /* CONNECT-Msg from HL-Driver         */
280
#ifdef CONFIG_ISDN_AUDIO
281
        u_char       vpar[10];                   /* Voice-parameters                   */
282
        int          lastDLE;                    /* Flag for voice-coding: DLE seen    */
283
#endif
284
        int          mdmcmdl;                    /* Length of Modem-Commandbuffer      */
285
        int          pluscount;                  /* Counter for +++ sequence           */
286
        unsigned long lastplus;                  /* Timestamp of last +                */
287
        char         mdmcmd[255];                /* Modem-Commandbuffer                */
288
        unsigned int charge;                     /* Charge units of current connection */
289
} atemu;
290
 
291
/* Private data (similar to async_struct in <linux/serial.h>) */
292
typedef struct modem_info {
293
  int                   magic;
294
  struct module         *owner;
295
  int                   flags;           /* defined in tty.h               */
296
  int                   x_char;          /* xon/xoff character             */
297
  int                   mcr;             /* Modem control register         */
298
  int                   msr;             /* Modem status register          */
299
  int                   lsr;             /* Line status register           */
300
  int                   line;
301
  int                   count;           /* # of fd on device              */
302
  int                   blocked_open;    /* # of blocked opens             */
303
  int                   online;          /* 1 = B-Channel is up, drop data */
304
                                         /* 2 = B-Channel is up, deliver d.*/
305
  int                   dialing;         /* Dial in progress or ATA        */
306
  int                   rcvsched;        /* Receive needs schedule         */
307
  struct isdn_slot     *isdn_slot;       /* Ptr to isdn-driver/channel     */
308
  struct sk_buff_head   rpqueue;         /* Queue of recv'd packets        */
309
  int                   rcvcount;        /* Byte-counters for B rx         */
310
  int                   ncarrier;        /* Flag: schedule NO CARRIER      */
311
  unsigned char         last_cause[8];   /* Last cause message             */
312
  unsigned char         last_num[ISDN_MSNLEN];
313
                                         /* Last phone-number              */
314
  unsigned char         last_l2;         /* Last layer-2 protocol          */
315
  unsigned char         last_si;         /* Last service                   */
316
  unsigned char         last_lhup;       /* Last hangup local?             */
317
  unsigned char         last_dir;        /* Last direction (in or out)     */
318
  struct timer_list     nc_timer;        /* Timer for delayed NO CARRIER   */
319
  int                   send_outstanding;/* # of outstanding send-requests */
320
  int                   xmit_size;       /* max. # of chars in xmit_buf    */
321
  int                   xmit_count;      /* # of chars in xmit_buf         */
322
  unsigned char         *xmit_buf;       /* transmit buffer                */
323
  struct sk_buff_head   xmit_queue;      /* transmit queue                 */
324
  atomic_t              xmit_lock;       /* Semaphore for isdn_tty_write   */
325
#ifdef CONFIG_ISDN_AUDIO
326
  unsigned long         DLEflag;         /* Insert DLE at next read     */
327
  int                   vonline;         /* Voice-channel status           */
328
                                         /* Bit 0 = recording              */
329
                                         /* Bit 1 = playback               */
330
                                         /* Bit 2 = playback, DLE-ETX seen */
331
  struct sk_buff_head   dtmf_queue;      /* queue for dtmf results         */
332
  void                  *adpcms;         /* state for adpcm decompression  */
333
  void                  *adpcmr;         /* state for adpcm compression    */
334
  void                  *dtmf_state;     /* state for dtmf decoder         */
335
  void                  *silence_state;  /* state for silence detection    */
336
#endif
337
#ifdef CONFIG_ISDN_TTY_FAX
338
  struct T30_s          *fax;            /* T30 Fax Group 3 data/interface */
339
  int                   faxonline;       /* Fax-channel status             */
340
#endif
341
  struct tty_struct     *tty;            /* Pointer to corresponding tty   */
342
  atemu                 emu;             /* AT-emulator data               */
343
  struct timer_list     escape_timer;    /* to recognize +++ escape        */
344
  struct timer_list     ring_timer;      /* for writing 'RING' responses   */
345
  struct timer_list     connect_timer;   /* waiting for CONNECT            */
346
  struct timer_list     read_timer;      /* read incoming data             */
347
  wait_queue_head_t     open_wait, close_wait;
348
  struct semaphore      write_sem;
349
} modem_info;
350
 
351
#define ISDN_MODEM_WINSIZE 8
352
 
353
/*======================= End of ISDN-tty stuff ============================*/
354
 
355
/*======================== Start of V.110 stuff ============================*/
356
#define V110_BUFSIZE 1024
357
 
358
typedef struct {
359
        int nbytes;                    /* 1 Matrixbyte -> nbytes in stream     */
360
        int nbits;                     /* Number of used bits in streambyte    */
361
        unsigned char key;             /* Bitmask in stream eg. 11 (nbits=2)   */
362
        int decodelen;                 /* Amount of data in decodebuf          */
363
        int SyncInit;                  /* Number of sync frames to send        */
364
        unsigned char *OnlineFrame;    /* Precalculated V110 idle frame        */
365
        unsigned char *OfflineFrame;   /* Precalculated V110 sync Frame        */
366
        int framelen;                  /* Length of frames                     */
367
        int skbuser;                   /* Number of unacked userdata skbs      */
368
        int skbidle;                   /* Number of unacked idle/sync skbs     */
369
        int introducer;                /* Local vars for decoder               */
370
        int dbit;
371
        unsigned char b;
372
        int skbres;                    /* space to reserve in outgoing skb     */
373
        int maxsize;                   /* maxbufsize of lowlevel driver        */
374
        unsigned char *encodebuf;      /* temporary buffer for encoding        */
375
        unsigned char decodebuf[V110_BUFSIZE]; /* incomplete V110 matrices     */
376
} isdn_v110_stream;
377
 
378
/*========================= End of V.110 stuff =============================*/
379
 
380
/*======================= Start of general stuff ===========================*/
381
 
382
typedef struct {
383
        char *next;
384
        char *private;
385
} infostruct;
386
 
387
/* Main driver-data */
388
typedef struct _isdn_dev_t {
389
        unsigned short          flags;          /* Bitmapped Flags:           */
390
        int                     channels;       /* Current number of channels */
391
        int                     net_verbose;    /* Verbose-Flag               */
392
        int                     modempoll;      /* Flag: tty-read active      */
393
        int                     tflags;         /* Timer-Flags:               */
394
                                                /*  see ISDN_TIMER_..defines  */
395
        int                     global_flags;
396
        infostruct              *infochain;     /* List of open info-devs.    */
397
        wait_queue_head_t       info_waitq;     /* Wait-Queue for isdninfo    */
398
        struct task_struct      *profd;         /* For iprofd                 */
399
        struct semaphore        sem;            /* serialize list access*/
400
        unsigned long           global_features;
401
} isdn_dev_t;
402
 
403
extern isdn_dev_t       *get_isdn_dev(void);
404
 
405
#endif /* __KERNEL__ */
406
 
407
#endif /* __ISDN_H__ */