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