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
19#ifdef CONFIG_COBALT_MICRO_SERVER
20
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
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)
37#define IIOCSETSET _IO('I',9)
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)
52#define IIOCNETDWRSET _IO('I',24)
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
64#define SIOCGKEEPPERIOD (SIOCDEVPRIVATE + 0)
65#define SIOCSKEEPPERIOD (SIOCDEVPRIVATE + 1)
66#define SIOCGDEBSERINT (SIOCDEVPRIVATE + 2)
67#define SIOCSDEBSERINT (SIOCDEVPRIVATE + 3)
68
69
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
74#define ISDN_NET_ENCAP_SYNCPPP 4
75#define ISDN_NET_ENCAP_UIHDLC 5
76#define ISDN_NET_ENCAP_CISCOHDLCK 6
77#define ISDN_NET_ENCAP_X25IFACE 7
78#define ISDN_NET_ENCAP_MAX_ENCAP ISDN_NET_ENCAP_X25IFACE
79
80
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
88#define ISDN_USAGE_DISABLED 32
89#define ISDN_USAGE_EXCLUSIVE 64
90#define ISDN_USAGE_OUTGOING 128
91
92#define ISDN_MODEM_NUMREG 24
93#define ISDN_LMSNLEN 255
94#define ISDN_CMSGLEN 50
95
96#define ISDN_MSNLEN 32
97#define NET_DV 0x06
98#define TTY_DV 0x06
99
100#define INF_DV 0x01
101
102typedef struct {
103 char drvid[25];
104 unsigned long arg;
105} isdn_ioctl_struct;
106
107typedef struct {
108 char name[10];
109 char phone[ISDN_MSNLEN];
110 int outgoing;
111} isdn_net_ioctl_phone;
112
113typedef struct {
114 char name[10];
115 char master[10];
116 char slave[10];
117 char eaz[256];
118 char drvid[25];
119 int onhtime;
120 int charge;
121 int l2_proto;
122 int l3_proto;
123 int p_encap;
124 int exclusive;
125 int dialmax;
126 int slavedelay;
127 int cbdelay;
128 int chargehup;
129 int ihup;
130 int secure;
131 int callback;
132 int cbhup;
133 int pppbind;
134 int chargeint;
135 int triggercps;
136 int dialtimeout;
137 int dialwait;
138 int dialmode;
139} isdn_net_ioctl_cfg;
140
141#define ISDN_NET_DIALMODE_MASK 0xC0
142#define ISDN_NET_DM_OFF 0x00
143#define ISDN_NET_DM_MANUAL 0x40
144#define ISDN_NET_DM_AUTO 0x80
145#define ISDN_NET_DIALMODE(x) ((&(x))->flags & ISDN_NET_DIALMODE_MASK)
146
147#ifdef __KERNEL__
148
149#include <linux/errno.h>
150#include <linux/fs.h>
151#include <linux/major.h>
152#include <asm/io.h>
153#include <linux/kernel.h>
154#include <linux/signal.h>
155#include <linux/slab.h>
156#include <linux/timer.h>
157#include <linux/wait.h>
158#include <linux/tty.h>
159#include <linux/tty_flip.h>
160#include <linux/serial_reg.h>
161#include <linux/fcntl.h>
162#include <linux/types.h>
163#include <linux/interrupt.h>
164#include <linux/ip.h>
165#include <linux/in.h>
166#include <linux/netdevice.h>
167#include <linux/etherdevice.h>
168#include <linux/skbuff.h>
169#include <linux/tcp.h>
170
171#define ISDN_TTY_MAJOR 43
172#define ISDN_TTYAUX_MAJOR 44
173#define ISDN_MAJOR 45
174
175
176
177
178
179
180#define ISDN_MINOR_B 0
181#define ISDN_MINOR_BMAX (ISDN_MAX_CHANNELS-1)
182#define ISDN_MINOR_CTRL 64
183#define ISDN_MINOR_CTRLMAX (64 + (ISDN_MAX_CHANNELS-1))
184#define ISDN_MINOR_PPP 128
185#define ISDN_MINOR_PPPMAX (128 + (ISDN_MAX_CHANNELS-1))
186#define ISDN_MINOR_STATUS 255
187
188#ifdef CONFIG_ISDN_PPP
189
190#ifdef CONFIG_ISDN_PPP_VJ
191# include <net/slhc_vj.h>
192#endif
193
194#include <linux/ppp_defs.h>
195#include <linux/if_ppp.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
207
208
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
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
235#define ISDN_TIMER_RES 4
236#define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5)
237#define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES)
238#define ISDN_TIMER_RINGING 5
239#define ISDN_TIMER_KEEPINT 10
240#define ISDN_TIMER_MODEMREAD 1
241#define ISDN_TIMER_MODEMPLUS 2
242#define ISDN_TIMER_MODEMRING 4
243#define ISDN_TIMER_MODEMXMIT 8
244#define ISDN_TIMER_NETDIAL 16
245#define ISDN_TIMER_NETHANGUP 32
246#define ISDN_TIMER_CARRIER 256
247#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
248 ISDN_TIMER_MODEMXMIT)
249#define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
250 ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER)
251
252
253#define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
254#define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
255#define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
256
257
258#define ISDN_GLOBAL_STOPPED 1
259
260
261
262
263#define ISDN_NET_CONNECTED 0x01
264#define ISDN_NET_SECURE 0x02
265#define ISDN_NET_CALLBACK 0x04
266#define ISDN_NET_CBHUP 0x08
267#define ISDN_NET_CBOUT 0x10
268
269#define ISDN_NET_MAGIC 0x49344C02
270
271
272typedef struct {
273 void *next;
274 char num[ISDN_MSNLEN];
275} isdn_net_phone;
276
277
278
279
280
281
282
283
284
285
286
287typedef struct isdn_net_local_s {
288 ulong magic;
289 char name[10];
290 struct net_device_stats stats;
291 int isdn_device;
292 int isdn_channel;
293 int ppp_slot;
294 int pre_device;
295 int pre_channel;
296 int exclusive;
297 int flags;
298 int dialretry;
299 int dialmax;
300 int cbdelay;
301 int dtimer;
302 char msn[ISDN_MSNLEN];
303 u_char cbhup;
304 u_char dialstate;
305 u_char p_encap;
306
307
308
309 u_char l2_proto;
310
311
312
313
314
315
316 u_char l3_proto;
317
318
319
320 int huptimer;
321 int charge;
322 ulong chargetime;
323 int hupflags;
324
325
326
327
328 int outgoing;
329 int onhtime;
330 int chargeint;
331 int onum;
332 int cps;
333 int transcount;
334 int sqfull;
335 ulong sqfull_stamp;
336 ulong slavedelay;
337 int triggercps;
338 isdn_net_phone *phone[2];
339
340
341 isdn_net_phone *dial;
342 struct net_device *master;
343 struct net_device *slave;
344 struct isdn_net_local_s *next;
345 struct isdn_net_local_s *last;
346 struct isdn_net_dev_s *netdev;
347 struct sk_buff_head super_tx_queue;
348
349 atomic_t frame_cnt;
350
351
352 spinlock_t xmit_lock;
353
354
355
356 int (*org_hhc)(
357 struct neighbour *neigh,
358 struct hh_cache *hh);
359
360 void (*org_hcu)(struct hh_cache *,
361 struct net_device *,
362 unsigned char *);
363 int pppbind;
364 int dialtimeout;
365 int dialwait;
366 ulong dialstarted;
367 ulong dialwait_timer;
368 int huptimeout;
369#ifdef CONFIG_ISDN_X25
370 struct concap_device_ops *dops;
371#endif
372
373 ulong cisco_myseq;
374 ulong cisco_mineseen;
375 ulong cisco_yourseq;
376 int cisco_keepalive_period;
377 ulong cisco_last_slarp_in;
378 char cisco_line_state;
379 char cisco_debserint;
380 struct timer_list cisco_timer;
381 struct work_struct tqueue;
382} isdn_net_local;
383
384
385typedef struct isdn_net_dev_s {
386 isdn_net_local *local;
387 isdn_net_local *queue;
388
389
390 spinlock_t queue_lock;
391 void *next;
392 struct net_device dev;
393#ifdef CONFIG_ISDN_PPP
394 ippp_bundle * pb;
395
396#endif
397#ifdef CONFIG_ISDN_X25
398 struct concap_proto *cprot;
399#endif
400
401} isdn_net_dev;
402
403
404
405
406
407#define ISDN_ASYNC_MAGIC 0x49344C01
408#define ISDN_ASYNC_INITIALIZED 0x80000000
409#define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000
410#define ISDN_ASYNC_NORMAL_ACTIVE 0x20000000
411#define ISDN_ASYNC_CLOSING 0x08000000
412#define ISDN_ASYNC_CTS_FLOW 0x04000000
413#define ISDN_ASYNC_CHECK_CD 0x02000000
414#define ISDN_ASYNC_HUP_NOTIFY 0x0001
415#define ISDN_ASYNC_SESSION_LOCKOUT 0x0100
416#define ISDN_ASYNC_PGRP_LOCKOUT 0x0200
417#define ISDN_ASYNC_CALLOUT_NOHUP 0x0400
418#define ISDN_ASYNC_SPLIT_TERMIOS 0x0008
419#define ISDN_SERIAL_XMIT_SIZE 1024
420#define ISDN_SERIAL_XMIT_MAX 4000
421#define ISDN_SERIAL_TYPE_NORMAL 1
422#define ISDN_SERIAL_TYPE_CALLOUT 2
423
424#ifdef CONFIG_ISDN_AUDIO
425
426
427
428
429
430typedef struct _isdn_audio_data {
431 unsigned short dle_count;
432 unsigned char lock;
433} isdn_audio_data_t;
434
435#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_data_t *)&skb->cb[0])->dle_count)
436#define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_data_t *)&skb->cb[0])->lock)
437#endif
438
439
440typedef struct atemu {
441 u_char profile[ISDN_MODEM_NUMREG];
442 u_char mdmreg[ISDN_MODEM_NUMREG];
443 char pmsn[ISDN_MSNLEN];
444 char msn[ISDN_MSNLEN];
445 char plmsn[ISDN_LMSNLEN];
446 char lmsn[ISDN_LMSNLEN];
447 char cpn[ISDN_MSNLEN];
448 char connmsg[ISDN_CMSGLEN];
449#ifdef CONFIG_ISDN_AUDIO
450 u_char vpar[10];
451 int lastDLE;
452#endif
453 int mdmcmdl;
454 int pluscount;
455 u_long lastplus;
456 int carrierwait;
457 char mdmcmd[255];
458 unsigned int charge;
459} atemu;
460
461
462typedef struct modem_info {
463 int magic;
464 struct module *owner;
465 int flags;
466 int x_char;
467 int mcr;
468 int msr;
469 int lsr;
470 int line;
471 int count;
472 int blocked_open;
473 long session;
474 long pgrp;
475 int online;
476
477 int dialing;
478 int rcvsched;
479 int isdn_driver;
480 int isdn_channel;
481 int drv_index;
482 int ncarrier;
483 unsigned char last_cause[8];
484 unsigned char last_num[ISDN_MSNLEN];
485
486 unsigned char last_l2;
487 unsigned char last_si;
488 unsigned char last_lhup;
489 unsigned char last_dir;
490 struct timer_list nc_timer;
491 int send_outstanding;
492 int xmit_size;
493 int xmit_count;
494 unsigned char *xmit_buf;
495 struct sk_buff_head xmit_queue;
496 atomic_t xmit_lock;
497#ifdef CONFIG_ISDN_AUDIO
498 int vonline;
499
500
501
502 struct sk_buff_head dtmf_queue;
503 void *adpcms;
504 void *adpcmr;
505 void *dtmf_state;
506 void *silence_state;
507#endif
508#ifdef CONFIG_ISDN_TTY_FAX
509 struct T30_s *fax;
510 int faxonline;
511#endif
512 struct tty_struct *tty;
513 atemu emu;
514 struct termios normal_termios;
515 struct termios callout_termios;
516 wait_queue_head_t open_wait, close_wait;
517 struct semaphore write_sem;
518 spinlock_t readlock;
519} modem_info;
520
521#define ISDN_MODEM_WINSIZE 8
522
523
524typedef struct _isdn_modem {
525 int refcount;
526 struct tty_driver *tty_modem;
527 struct tty_struct *modem_table[ISDN_MAX_CHANNELS];
528 struct termios *modem_termios[ISDN_MAX_CHANNELS];
529 struct termios *modem_termios_locked[ISDN_MAX_CHANNELS];
530 modem_info info[ISDN_MAX_CHANNELS];
531} isdn_modem_t;
532
533
534
535
536#define V110_BUFSIZE 1024
537
538typedef struct {
539 int nbytes;
540 int nbits;
541 unsigned char key;
542 int decodelen;
543 int SyncInit;
544 unsigned char *OnlineFrame;
545 unsigned char *OfflineFrame;
546 int framelen;
547 int skbuser;
548 int skbidle;
549 int introducer;
550 int dbit;
551 unsigned char b;
552 int skbres;
553 int maxsize;
554 unsigned char *encodebuf;
555 unsigned char decodebuf[V110_BUFSIZE];
556} isdn_v110_stream;
557
558
559
560
561
562typedef struct {
563 char *next;
564 char *private;
565} infostruct;
566
567#define DRV_FLAG_RUNNING 1
568#define DRV_FLAG_REJBUS 2
569#define DRV_FLAG_LOADED 4
570
571
572typedef struct _isdn_driver {
573 ulong online;
574 ulong flags;
575 int locks;
576 int channels;
577 wait_queue_head_t st_waitq;
578 int maxbufsize;
579 unsigned long pktcount;
580 int stavail;
581 isdn_if *interface;
582 int *rcverr;
583 int *rcvcount;
584#ifdef CONFIG_ISDN_AUDIO
585 unsigned long DLEflag;
586#endif
587 struct sk_buff_head *rpqueue;
588 wait_queue_head_t *rcv_waitq;
589 wait_queue_head_t *snd_waitq;
590 char msn2eaz[10][ISDN_MSNLEN];
591} isdn_driver_t;
592
593
594typedef struct isdn_devt {
595 struct module *owner;
596 spinlock_t lock;
597 unsigned short flags;
598 int drivers;
599 int channels;
600 int net_verbose;
601 int modempoll;
602 spinlock_t timerlock;
603 int tflags;
604
605 int global_flags;
606 infostruct *infochain;
607 wait_queue_head_t info_waitq;
608 struct timer_list timer;
609 int chanmap[ISDN_MAX_CHANNELS];
610 int drvmap[ISDN_MAX_CHANNELS];
611 int usage[ISDN_MAX_CHANNELS];
612 char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
613
614 int m_idx[ISDN_MAX_CHANNELS];
615 isdn_driver_t *drv[ISDN_MAX_DRIVERS];
616 isdn_net_dev *netdev;
617 char drvid[ISDN_MAX_DRIVERS][20];
618 struct task_struct *profd;
619 isdn_modem_t mdm;
620 isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS];
621 isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS];
622 ulong ibytes[ISDN_MAX_CHANNELS];
623 ulong obytes[ISDN_MAX_CHANNELS];
624 int v110emu[ISDN_MAX_CHANNELS];
625 atomic_t v110use[ISDN_MAX_CHANNELS];
626 isdn_v110_stream *v110[ISDN_MAX_CHANNELS];
627 struct semaphore sem;
628 unsigned long global_features;
629} isdn_dev;
630
631extern isdn_dev *dev;
632
633
634#endif
635
636#endif
637