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#include <linux/mutex.h>
171
172#define ISDN_TTY_MAJOR 43
173#define ISDN_TTYAUX_MAJOR 44
174#define ISDN_MAJOR 45
175
176
177
178
179
180
181#define ISDN_MINOR_B 0
182#define ISDN_MINOR_BMAX (ISDN_MAX_CHANNELS-1)
183#define ISDN_MINOR_CTRL 64
184#define ISDN_MINOR_CTRLMAX (64 + (ISDN_MAX_CHANNELS-1))
185#define ISDN_MINOR_PPP 128
186#define ISDN_MINOR_PPPMAX (128 + (ISDN_MAX_CHANNELS-1))
187#define ISDN_MINOR_STATUS 255
188
189#ifdef CONFIG_ISDN_PPP
190
191#ifdef CONFIG_ISDN_PPP_VJ
192# include <net/slhc_vj.h>
193#endif
194
195#include <linux/ppp_defs.h>
196#include <linux/if_ppp.h>
197
198#include <linux/isdn_ppp.h>
199#endif
200
201#ifdef CONFIG_ISDN_X25
202# include <linux/concap.h>
203#endif
204
205#include <linux/isdnif.h>
206
207#define ISDN_DRVIOCTL_MASK 0x7f
208
209
210#define ISDN_SERVICE_VOICE 1
211#define ISDN_SERVICE_AB 1<<1
212#define ISDN_SERVICE_X21 1<<2
213#define ISDN_SERVICE_G4 1<<3
214#define ISDN_SERVICE_BTX 1<<4
215#define ISDN_SERVICE_DFUE 1<<5
216#define ISDN_SERVICE_X25 1<<6
217#define ISDN_SERVICE_TTX 1<<7
218#define ISDN_SERVICE_MIXED 1<<8
219#define ISDN_SERVICE_FW 1<<9
220#define ISDN_SERVICE_GTEL 1<<10
221#define ISDN_SERVICE_BTXN 1<<11
222#define ISDN_SERVICE_BTEL 1<<12
223
224
225#define USG_NONE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
226#define USG_RAW(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
227#define USG_MODEM(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
228#define USG_VOICE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)
229#define USG_NET(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
230#define USG_FAX(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_FAX)
231#define USG_OUTGOING(x) ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
232#define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \
233 ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE) )
234
235
236#define ISDN_TIMER_RES 4
237#define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5)
238#define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES)
239#define ISDN_TIMER_RINGING 5
240#define ISDN_TIMER_KEEPINT 10
241#define ISDN_TIMER_MODEMREAD 1
242#define ISDN_TIMER_MODEMPLUS 2
243#define ISDN_TIMER_MODEMRING 4
244#define ISDN_TIMER_MODEMXMIT 8
245#define ISDN_TIMER_NETDIAL 16
246#define ISDN_TIMER_NETHANGUP 32
247#define ISDN_TIMER_CARRIER 256
248#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
249 ISDN_TIMER_MODEMXMIT)
250#define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
251 ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER)
252
253
254#define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
255#define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
256#define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
257
258
259#define ISDN_GLOBAL_STOPPED 1
260
261
262
263
264#define ISDN_NET_CONNECTED 0x01
265#define ISDN_NET_SECURE 0x02
266#define ISDN_NET_CALLBACK 0x04
267#define ISDN_NET_CBHUP 0x08
268#define ISDN_NET_CBOUT 0x10
269
270#define ISDN_NET_MAGIC 0x49344C02
271
272
273typedef struct {
274 void *next;
275 char num[ISDN_MSNLEN];
276} isdn_net_phone;
277
278
279
280
281
282
283
284
285
286
287
288typedef struct isdn_net_local_s {
289 ulong magic;
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 pppbind;
357 int dialtimeout;
358 int dialwait;
359 ulong dialstarted;
360 ulong dialwait_timer;
361 int huptimeout;
362#ifdef CONFIG_ISDN_X25
363 struct concap_device_ops *dops;
364#endif
365
366 ulong cisco_myseq;
367 ulong cisco_mineseen;
368 ulong cisco_yourseq;
369 int cisco_keepalive_period;
370 ulong cisco_last_slarp_in;
371 char cisco_line_state;
372 char cisco_debserint;
373 struct timer_list cisco_timer;
374 struct work_struct tqueue;
375} isdn_net_local;
376
377
378typedef struct isdn_net_dev_s {
379 isdn_net_local *local;
380 isdn_net_local *queue;
381
382
383 spinlock_t queue_lock;
384 void *next;
385 struct net_device *dev;
386#ifdef CONFIG_ISDN_PPP
387 ippp_bundle * pb;
388
389#endif
390#ifdef CONFIG_ISDN_X25
391 struct concap_proto *cprot;
392#endif
393
394} isdn_net_dev;
395
396
397
398
399
400#define ISDN_ASYNC_MAGIC 0x49344C01
401#define ISDN_ASYNC_INITIALIZED 0x80000000
402#define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000
403#define ISDN_ASYNC_NORMAL_ACTIVE 0x20000000
404#define ISDN_ASYNC_CLOSING 0x08000000
405#define ISDN_ASYNC_CTS_FLOW 0x04000000
406#define ISDN_ASYNC_CHECK_CD 0x02000000
407#define ISDN_ASYNC_HUP_NOTIFY 0x0001
408#define ISDN_ASYNC_SESSION_LOCKOUT 0x0100
409#define ISDN_ASYNC_PGRP_LOCKOUT 0x0200
410#define ISDN_ASYNC_CALLOUT_NOHUP 0x0400
411#define ISDN_ASYNC_SPLIT_TERMIOS 0x0008
412#define ISDN_SERIAL_XMIT_SIZE 1024
413#define ISDN_SERIAL_XMIT_MAX 4000
414#define ISDN_SERIAL_TYPE_NORMAL 1
415#define ISDN_SERIAL_TYPE_CALLOUT 2
416
417#ifdef CONFIG_ISDN_AUDIO
418
419
420
421
422
423typedef struct _isdn_audio_data {
424 unsigned short dle_count;
425 unsigned char lock;
426} isdn_audio_data_t;
427
428#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_data_t *)&skb->cb[0])->dle_count)
429#define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_data_t *)&skb->cb[0])->lock)
430#endif
431
432
433typedef struct atemu {
434 u_char profile[ISDN_MODEM_NUMREG];
435 u_char mdmreg[ISDN_MODEM_NUMREG];
436 char pmsn[ISDN_MSNLEN];
437 char msn[ISDN_MSNLEN];
438 char plmsn[ISDN_LMSNLEN];
439 char lmsn[ISDN_LMSNLEN];
440 char cpn[ISDN_MSNLEN];
441 char connmsg[ISDN_CMSGLEN];
442#ifdef CONFIG_ISDN_AUDIO
443 u_char vpar[10];
444 int lastDLE;
445#endif
446 int mdmcmdl;
447 int pluscount;
448 u_long lastplus;
449 int carrierwait;
450 char mdmcmd[255];
451 unsigned int charge;
452} atemu;
453
454
455typedef struct modem_info {
456 int magic;
457 struct module *owner;
458 int flags;
459 int x_char;
460 int mcr;
461 int msr;
462 int lsr;
463 int line;
464 int count;
465 int blocked_open;
466 long session;
467 long pgrp;
468 int online;
469
470 int dialing;
471 int rcvsched;
472 int isdn_driver;
473 int isdn_channel;
474 int drv_index;
475 int ncarrier;
476 unsigned char last_cause[8];
477 unsigned char last_num[ISDN_MSNLEN];
478
479 unsigned char last_l2;
480 unsigned char last_si;
481 unsigned char last_lhup;
482 unsigned char last_dir;
483 struct timer_list nc_timer;
484 int send_outstanding;
485 int xmit_size;
486 int xmit_count;
487 unsigned char *xmit_buf;
488 struct sk_buff_head xmit_queue;
489 atomic_t xmit_lock;
490#ifdef CONFIG_ISDN_AUDIO
491 int vonline;
492
493
494
495 struct sk_buff_head dtmf_queue;
496 void *adpcms;
497 void *adpcmr;
498 void *dtmf_state;
499 void *silence_state;
500#endif
501#ifdef CONFIG_ISDN_TTY_FAX
502 struct T30_s *fax;
503 int faxonline;
504#endif
505 struct tty_struct *tty;
506 atemu emu;
507 struct ktermios normal_termios;
508 struct ktermios callout_termios;
509 wait_queue_head_t open_wait, close_wait;
510 struct semaphore write_sem;
511 spinlock_t readlock;
512} modem_info;
513
514#define ISDN_MODEM_WINSIZE 8
515
516
517typedef struct _isdn_modem {
518 int refcount;
519 struct tty_driver *tty_modem;
520 struct tty_struct *modem_table[ISDN_MAX_CHANNELS];
521 struct ktermios *modem_termios[ISDN_MAX_CHANNELS];
522 struct ktermios *modem_termios_locked[ISDN_MAX_CHANNELS];
523 modem_info info[ISDN_MAX_CHANNELS];
524} isdn_modem_t;
525
526
527
528
529#define V110_BUFSIZE 1024
530
531typedef struct {
532 int nbytes;
533 int nbits;
534 unsigned char key;
535 int decodelen;
536 int SyncInit;
537 unsigned char *OnlineFrame;
538 unsigned char *OfflineFrame;
539 int framelen;
540 int skbuser;
541 int skbidle;
542 int introducer;
543 int dbit;
544 unsigned char b;
545 int skbres;
546 int maxsize;
547 unsigned char *encodebuf;
548 unsigned char decodebuf[V110_BUFSIZE];
549} isdn_v110_stream;
550
551
552
553
554
555typedef struct {
556 char *next;
557 char *private;
558} infostruct;
559
560#define DRV_FLAG_RUNNING 1
561#define DRV_FLAG_REJBUS 2
562#define DRV_FLAG_LOADED 4
563
564
565typedef struct _isdn_driver {
566 ulong online;
567 ulong flags;
568 int locks;
569 int channels;
570 wait_queue_head_t st_waitq;
571 int maxbufsize;
572 unsigned long pktcount;
573 int stavail;
574 isdn_if *interface;
575 int *rcverr;
576 int *rcvcount;
577#ifdef CONFIG_ISDN_AUDIO
578 unsigned long DLEflag;
579#endif
580 struct sk_buff_head *rpqueue;
581 wait_queue_head_t *rcv_waitq;
582 wait_queue_head_t *snd_waitq;
583 char msn2eaz[10][ISDN_MSNLEN];
584} isdn_driver_t;
585
586
587typedef struct isdn_devt {
588 struct module *owner;
589 spinlock_t lock;
590 unsigned short flags;
591 int drivers;
592 int channels;
593 int net_verbose;
594 int modempoll;
595 spinlock_t timerlock;
596 int tflags;
597
598 int global_flags;
599 infostruct *infochain;
600 wait_queue_head_t info_waitq;
601 struct timer_list timer;
602 int chanmap[ISDN_MAX_CHANNELS];
603 int drvmap[ISDN_MAX_CHANNELS];
604 int usage[ISDN_MAX_CHANNELS];
605 char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
606
607 int m_idx[ISDN_MAX_CHANNELS];
608 isdn_driver_t *drv[ISDN_MAX_DRIVERS];
609 isdn_net_dev *netdev;
610 char drvid[ISDN_MAX_DRIVERS][20];
611 struct task_struct *profd;
612 isdn_modem_t mdm;
613 isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS];
614 isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS];
615 ulong ibytes[ISDN_MAX_CHANNELS];
616 ulong obytes[ISDN_MAX_CHANNELS];
617 int v110emu[ISDN_MAX_CHANNELS];
618 atomic_t v110use[ISDN_MAX_CHANNELS];
619 isdn_v110_stream *v110[ISDN_MAX_CHANNELS];
620 struct mutex mtx;
621 unsigned long global_features;
622} isdn_dev;
623
624extern isdn_dev *dev;
625
626
627#endif
628
629#endif
630