1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __ISDN_H__
15#define __ISDN_H__
16
17#include <linux/ioctl.h>
18#include <linux/tty.h>
19
20#define ISDN_MAX_DRIVERS 32
21#define ISDN_MAX_CHANNELS 64
22
23
24#define IIOCNETAIF _IO('I',1)
25#define IIOCNETDIF _IO('I',2)
26#define IIOCNETSCF _IO('I',3)
27#define IIOCNETGCF _IO('I',4)
28#define IIOCNETANM _IO('I',5)
29#define IIOCNETDNM _IO('I',6)
30#define IIOCNETGNM _IO('I',7)
31#define IIOCGETSET _IO('I',8)
32#define IIOCSETSET _IO('I',9)
33#define IIOCSETVER _IO('I',10)
34#define IIOCNETHUP _IO('I',11)
35#define IIOCSETGST _IO('I',12)
36#define IIOCSETBRJ _IO('I',13)
37#define IIOCSIGPRF _IO('I',14)
38#define IIOCGETPRF _IO('I',15)
39#define IIOCSETPRF _IO('I',16)
40#define IIOCGETMAP _IO('I',17)
41#define IIOCSETMAP _IO('I',18)
42#define IIOCNETASL _IO('I',19)
43#define IIOCNETDIL _IO('I',20)
44#define IIOCGETCPS _IO('I',21)
45#define IIOCGETDVR _IO('I',22)
46#define IIOCNETLCR _IO('I',23)
47#define IIOCNETDWRSET _IO('I',24)
48
49#define IIOCNETALN _IO('I',32)
50#define IIOCNETDLN _IO('I',33)
51
52#define IIOCNETGPN _IO('I',34)
53
54#define IIOCDBGVAR _IO('I',127)
55
56#define IIOCDRVCTL _IO('I',128)
57
58
59#define SIOCGKEEPPERIOD (SIOCDEVPRIVATE + 0)
60#define SIOCSKEEPPERIOD (SIOCDEVPRIVATE + 1)
61#define SIOCGDEBSERINT (SIOCDEVPRIVATE + 2)
62#define SIOCSDEBSERINT (SIOCDEVPRIVATE + 3)
63
64
65#define ISDN_NET_ENCAP_ETHER 0
66#define ISDN_NET_ENCAP_RAWIP 1
67#define ISDN_NET_ENCAP_IPTYP 2
68#define ISDN_NET_ENCAP_CISCOHDLC 3
69#define ISDN_NET_ENCAP_SYNCPPP 4
70#define ISDN_NET_ENCAP_UIHDLC 5
71#define ISDN_NET_ENCAP_CISCOHDLCK 6
72#define ISDN_NET_ENCAP_X25IFACE 7
73#define ISDN_NET_ENCAP_MAX_ENCAP ISDN_NET_ENCAP_X25IFACE
74
75
76#define ISDN_USAGE_NONE 0
77#define ISDN_USAGE_RAW 1
78#define ISDN_USAGE_MODEM 2
79#define ISDN_USAGE_NET 3
80#define ISDN_USAGE_VOICE 4
81#define ISDN_USAGE_FAX 5
82#define ISDN_USAGE_MASK 7
83#define ISDN_USAGE_DISABLED 32
84#define ISDN_USAGE_EXCLUSIVE 64
85#define ISDN_USAGE_OUTGOING 128
86
87#define ISDN_MODEM_NUMREG 24
88#define ISDN_LMSNLEN 255
89#define ISDN_CMSGLEN 50
90
91#define ISDN_MSNLEN 32
92#define NET_DV 0x06
93#define TTY_DV 0x06
94
95#define INF_DV 0x01
96
97typedef struct {
98 char drvid[25];
99 unsigned long arg;
100} isdn_ioctl_struct;
101
102typedef struct {
103 char name[10];
104 char phone[ISDN_MSNLEN];
105 int outgoing;
106} isdn_net_ioctl_phone;
107
108typedef struct {
109 char name[10];
110 char master[10];
111 char slave[10];
112 char eaz[256];
113 char drvid[25];
114 int onhtime;
115 int charge;
116 int l2_proto;
117 int l3_proto;
118 int p_encap;
119 int exclusive;
120 int dialmax;
121 int slavedelay;
122 int cbdelay;
123 int chargehup;
124 int ihup;
125 int secure;
126 int callback;
127 int cbhup;
128 int pppbind;
129 int chargeint;
130 int triggercps;
131 int dialtimeout;
132 int dialwait;
133 int dialmode;
134} isdn_net_ioctl_cfg;
135
136#define ISDN_NET_DIALMODE_MASK 0xC0
137#define ISDN_NET_DM_OFF 0x00
138#define ISDN_NET_DM_MANUAL 0x40
139#define ISDN_NET_DM_AUTO 0x80
140#define ISDN_NET_DIALMODE(x) ((&(x))->flags & ISDN_NET_DIALMODE_MASK)
141
142#ifdef __KERNEL__
143
144#include <linux/errno.h>
145#include <linux/fs.h>
146#include <linux/major.h>
147#include <asm/io.h>
148#include <linux/kernel.h>
149#include <linux/signal.h>
150#include <linux/slab.h>
151#include <linux/timer.h>
152#include <linux/wait.h>
153#include <linux/tty.h>
154#include <linux/tty_flip.h>
155#include <linux/serial_reg.h>
156#include <linux/fcntl.h>
157#include <linux/types.h>
158#include <linux/interrupt.h>
159#include <linux/ip.h>
160#include <linux/in.h>
161#include <linux/netdevice.h>
162#include <linux/etherdevice.h>
163#include <linux/skbuff.h>
164#include <linux/tcp.h>
165#include <linux/mutex.h>
166
167#define ISDN_TTY_MAJOR 43
168#define ISDN_TTYAUX_MAJOR 44
169#define ISDN_MAJOR 45
170
171
172
173
174
175
176#define ISDN_MINOR_B 0
177#define ISDN_MINOR_BMAX (ISDN_MAX_CHANNELS-1)
178#define ISDN_MINOR_CTRL 64
179#define ISDN_MINOR_CTRLMAX (64 + (ISDN_MAX_CHANNELS-1))
180#define ISDN_MINOR_PPP 128
181#define ISDN_MINOR_PPPMAX (128 + (ISDN_MAX_CHANNELS-1))
182#define ISDN_MINOR_STATUS 255
183
184#ifdef CONFIG_ISDN_PPP
185
186#ifdef CONFIG_ISDN_PPP_VJ
187# include <net/slhc_vj.h>
188#endif
189
190#include <linux/ppp_defs.h>
191#include <linux/ppp-ioctl.h>
192
193#include <linux/isdn_ppp.h>
194#endif
195
196#ifdef CONFIG_ISDN_X25
197# include <linux/concap.h>
198#endif
199
200#include <linux/isdnif.h>
201
202#define ISDN_DRVIOCTL_MASK 0x7f
203
204
205#define ISDN_SERVICE_VOICE 1
206#define ISDN_SERVICE_AB 1<<1
207#define ISDN_SERVICE_X21 1<<2
208#define ISDN_SERVICE_G4 1<<3
209#define ISDN_SERVICE_BTX 1<<4
210#define ISDN_SERVICE_DFUE 1<<5
211#define ISDN_SERVICE_X25 1<<6
212#define ISDN_SERVICE_TTX 1<<7
213#define ISDN_SERVICE_MIXED 1<<8
214#define ISDN_SERVICE_FW 1<<9
215#define ISDN_SERVICE_GTEL 1<<10
216#define ISDN_SERVICE_BTXN 1<<11
217#define ISDN_SERVICE_BTEL 1<<12
218
219
220#define USG_NONE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
221#define USG_RAW(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
222#define USG_MODEM(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
223#define USG_VOICE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)
224#define USG_NET(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
225#define USG_FAX(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_FAX)
226#define USG_OUTGOING(x) ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
227#define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \
228 ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE) )
229
230
231#define ISDN_TIMER_RES 4
232#define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5)
233#define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES)
234#define ISDN_TIMER_RINGING 5
235#define ISDN_TIMER_KEEPINT 10
236#define ISDN_TIMER_MODEMREAD 1
237#define ISDN_TIMER_MODEMPLUS 2
238#define ISDN_TIMER_MODEMRING 4
239#define ISDN_TIMER_MODEMXMIT 8
240#define ISDN_TIMER_NETDIAL 16
241#define ISDN_TIMER_NETHANGUP 32
242#define ISDN_TIMER_CARRIER 256
243#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
244 ISDN_TIMER_MODEMXMIT)
245#define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
246 ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER)
247
248
249#define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
250#define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
251#define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
252
253
254#define ISDN_GLOBAL_STOPPED 1
255
256
257
258
259#define ISDN_NET_CONNECTED 0x01
260#define ISDN_NET_SECURE 0x02
261#define ISDN_NET_CALLBACK 0x04
262#define ISDN_NET_CBHUP 0x08
263#define ISDN_NET_CBOUT 0x10
264
265#define ISDN_NET_MAGIC 0x49344C02
266
267
268typedef struct {
269 void *next;
270 char num[ISDN_MSNLEN];
271} isdn_net_phone;
272
273
274
275
276
277
278
279
280
281
282
283typedef struct isdn_net_local_s {
284 ulong magic;
285 struct net_device_stats stats;
286 int isdn_device;
287 int isdn_channel;
288 int ppp_slot;
289 int pre_device;
290 int pre_channel;
291 int exclusive;
292 int flags;
293 int dialretry;
294 int dialmax;
295 int cbdelay;
296 int dtimer;
297 char msn[ISDN_MSNLEN];
298 u_char cbhup;
299 u_char dialstate;
300 u_char p_encap;
301
302
303
304 u_char l2_proto;
305
306
307
308
309
310
311 u_char l3_proto;
312
313
314
315 int huptimer;
316 int charge;
317 ulong chargetime;
318 int hupflags;
319
320
321
322
323 int outgoing;
324 int onhtime;
325 int chargeint;
326 int onum;
327 int cps;
328 int transcount;
329 int sqfull;
330 ulong sqfull_stamp;
331 ulong slavedelay;
332 int triggercps;
333 isdn_net_phone *phone[2];
334
335
336 isdn_net_phone *dial;
337 struct net_device *master;
338 struct net_device *slave;
339 struct isdn_net_local_s *next;
340 struct isdn_net_local_s *last;
341 struct isdn_net_dev_s *netdev;
342 struct sk_buff_head super_tx_queue;
343
344 atomic_t frame_cnt;
345
346
347 spinlock_t xmit_lock;
348
349
350
351 int pppbind;
352 int dialtimeout;
353 int dialwait;
354 ulong dialstarted;
355 ulong dialwait_timer;
356 int huptimeout;
357#ifdef CONFIG_ISDN_X25
358 struct concap_device_ops *dops;
359#endif
360
361 ulong cisco_myseq;
362 ulong cisco_mineseen;
363 ulong cisco_yourseq;
364 int cisco_keepalive_period;
365 ulong cisco_last_slarp_in;
366 char cisco_line_state;
367 char cisco_debserint;
368 struct timer_list cisco_timer;
369 struct work_struct tqueue;
370} isdn_net_local;
371
372
373typedef struct isdn_net_dev_s {
374 isdn_net_local *local;
375 isdn_net_local *queue;
376
377
378 spinlock_t queue_lock;
379 void *next;
380 struct net_device *dev;
381#ifdef CONFIG_ISDN_PPP
382 ippp_bundle * pb;
383
384#endif
385#ifdef CONFIG_ISDN_X25
386 struct concap_proto *cprot;
387#endif
388
389} isdn_net_dev;
390
391
392
393
394
395#define ISDN_ASYNC_MAGIC 0x49344C01
396#define ISDN_SERIAL_XMIT_SIZE 1024
397#define ISDN_SERIAL_XMIT_MAX 4000
398
399#ifdef CONFIG_ISDN_AUDIO
400
401
402
403
404
405typedef struct _isdn_audio_data {
406 unsigned short dle_count;
407 unsigned char lock;
408} isdn_audio_data_t;
409
410#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_data_t *)&skb->cb[0])->dle_count)
411#define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_data_t *)&skb->cb[0])->lock)
412#endif
413
414
415typedef struct atemu {
416 u_char profile[ISDN_MODEM_NUMREG];
417 u_char mdmreg[ISDN_MODEM_NUMREG];
418 char pmsn[ISDN_MSNLEN];
419 char msn[ISDN_MSNLEN];
420 char plmsn[ISDN_LMSNLEN];
421 char lmsn[ISDN_LMSNLEN];
422 char cpn[ISDN_MSNLEN];
423 char connmsg[ISDN_CMSGLEN];
424#ifdef CONFIG_ISDN_AUDIO
425 u_char vpar[10];
426 int lastDLE;
427#endif
428 int mdmcmdl;
429 int pluscount;
430 u_long lastplus;
431 int carrierwait;
432 char mdmcmd[255];
433 unsigned int charge;
434} atemu;
435
436
437typedef struct modem_info {
438 int magic;
439 struct tty_port port;
440 int x_char;
441 int mcr;
442 int msr;
443 int lsr;
444 int line;
445 int online;
446
447 int dialing;
448 int rcvsched;
449 int isdn_driver;
450 int isdn_channel;
451 int drv_index;
452 int ncarrier;
453 unsigned char last_cause[8];
454 unsigned char last_num[ISDN_MSNLEN];
455
456 unsigned char last_l2;
457 unsigned char last_si;
458 unsigned char last_lhup;
459 unsigned char last_dir;
460 struct timer_list nc_timer;
461 int send_outstanding;
462 int xmit_size;
463 int xmit_count;
464 struct sk_buff_head xmit_queue;
465 atomic_t xmit_lock;
466#ifdef CONFIG_ISDN_AUDIO
467 int vonline;
468
469
470
471 struct sk_buff_head dtmf_queue;
472 void *adpcms;
473 void *adpcmr;
474 void *dtmf_state;
475 void *silence_state;
476#endif
477#ifdef CONFIG_ISDN_TTY_FAX
478 struct T30_s *fax;
479 int faxonline;
480#endif
481 atemu emu;
482 spinlock_t readlock;
483} modem_info;
484
485#define ISDN_MODEM_WINSIZE 8
486
487
488typedef struct _isdn_modem {
489 int refcount;
490 struct tty_driver *tty_modem;
491 struct tty_struct *modem_table[ISDN_MAX_CHANNELS];
492 struct ktermios *modem_termios[ISDN_MAX_CHANNELS];
493 struct ktermios *modem_termios_locked[ISDN_MAX_CHANNELS];
494 modem_info info[ISDN_MAX_CHANNELS];
495} isdn_modem_t;
496
497
498
499
500#define V110_BUFSIZE 1024
501
502typedef struct {
503 int nbytes;
504 int nbits;
505 unsigned char key;
506 int decodelen;
507 int SyncInit;
508 unsigned char *OnlineFrame;
509 unsigned char *OfflineFrame;
510 int framelen;
511 int skbuser;
512 int skbidle;
513 int introducer;
514 int dbit;
515 unsigned char b;
516 int skbres;
517 int maxsize;
518 unsigned char *encodebuf;
519 unsigned char decodebuf[V110_BUFSIZE];
520} isdn_v110_stream;
521
522
523
524
525
526typedef struct {
527 char *next;
528 char *private;
529} infostruct;
530
531#define DRV_FLAG_RUNNING 1
532#define DRV_FLAG_REJBUS 2
533#define DRV_FLAG_LOADED 4
534
535
536typedef struct _isdn_driver {
537 ulong online;
538 ulong flags;
539 int locks;
540 int channels;
541 wait_queue_head_t st_waitq;
542 int maxbufsize;
543 unsigned long pktcount;
544 int stavail;
545 isdn_if *interface;
546 int *rcverr;
547 int *rcvcount;
548#ifdef CONFIG_ISDN_AUDIO
549 unsigned long DLEflag;
550#endif
551 struct sk_buff_head *rpqueue;
552 wait_queue_head_t *rcv_waitq;
553 wait_queue_head_t *snd_waitq;
554 char msn2eaz[10][ISDN_MSNLEN];
555} isdn_driver_t;
556
557
558typedef struct isdn_devt {
559 struct module *owner;
560 spinlock_t lock;
561 unsigned short flags;
562 int drivers;
563 int channels;
564 int net_verbose;
565 int modempoll;
566 spinlock_t timerlock;
567 int tflags;
568
569 int global_flags;
570 infostruct *infochain;
571 wait_queue_head_t info_waitq;
572 struct timer_list timer;
573 int chanmap[ISDN_MAX_CHANNELS];
574 int drvmap[ISDN_MAX_CHANNELS];
575 int usage[ISDN_MAX_CHANNELS];
576 char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
577
578 int m_idx[ISDN_MAX_CHANNELS];
579 isdn_driver_t *drv[ISDN_MAX_DRIVERS];
580 isdn_net_dev *netdev;
581 char drvid[ISDN_MAX_DRIVERS][20];
582 struct task_struct *profd;
583 isdn_modem_t mdm;
584 isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS];
585 isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS];
586 ulong ibytes[ISDN_MAX_CHANNELS];
587 ulong obytes[ISDN_MAX_CHANNELS];
588 int v110emu[ISDN_MAX_CHANNELS];
589 atomic_t v110use[ISDN_MAX_CHANNELS];
590 isdn_v110_stream *v110[ISDN_MAX_CHANNELS];
591 struct mutex mtx;
592 unsigned long global_features;
593} isdn_dev;
594
595extern isdn_dev *dev;
596
597
598#endif
599
600#endif
601