1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #ifndef isdn_h
41 #define isdn_h
42
43 #include <linux/ioctl.h>
44
45 #define ISDN_TTY_MAJOR 43
46 #define ISDN_TTYAUX_MAJOR 44
47 #define ISDN_MAJOR 45
48
49
50
51
52
53
54 #define ISDN_MAX_DRIVERS 32
55 #define ISDN_MAX_CHANNELS 64
56 #define ISDN_MINOR_B 0
57 #define ISDN_MINOR_BMAX (ISDN_MAX_CHANNELS-1)
58 #define ISDN_MINOR_CTRL ISDN_MAX_CHANNELS
59 #define ISDN_MINOR_CTRLMAX (2*ISDN_MAX_CHANNELS-1)
60 #define ISDN_MINOR_PPP (2*ISDN_MAX_CHANNELS)
61 #define ISDN_MINOR_PPPMAX (3*ISDN_MAX_CHANNELS-1)
62 #define ISDN_MINOR_STATUS 255
63
64
65 #define IIOCNETAIF _IO('I',1)
66 #define IIOCNETDIF _IO('I',2)
67 #define IIOCNETSCF _IO('I',3)
68 #define IIOCNETGCF _IO('I',4)
69 #define IIOCNETANM _IO('I',5)
70 #define IIOCNETDNM _IO('I',6)
71 #define IIOCNETGNM _IO('I',7)
72 #define IIOCGETSET _IO('I',8)
73 #define IIOCSETSET _IO('I',9)
74 #define IIOCSETVER _IO('I',10)
75 #define IIOCNETHUP _IO('I',11)
76 #define IIOCSETGST _IO('I',12)
77 #define IIOCSETBRJ _IO('I',13)
78 #define IIOCSIGPRF _IO('I',14)
79 #define IIOCGETPRF _IO('I',15)
80 #define IIOCSETPRF _IO('I',16)
81 #define IIOCGETMAP _IO('I',17)
82 #define IIOCSETMAP _IO('I',18)
83 #define IIOCNETASL _IO('I',19)
84 #define IIOCNETDIL _IO('I',20)
85 #define IIOCGETCPS _IO('I',21)
86
87 #define IIOCNETALN _IO('I',32)
88 #define IIOCNETDLN _IO('I',33)
89
90 #define IIOCDBGVAR _IO('I',127)
91
92 #define IIOCDRVCTL _IO('I',128)
93
94
95 #define ISDN_NET_ENCAP_ETHER 0
96 #define ISDN_NET_ENCAP_RAWIP 1
97 #define ISDN_NET_ENCAP_IPTYP 2
98 #define ISDN_NET_ENCAP_CISCOHDLC 3
99 #define ISDN_NET_ENCAP_SYNCPPP 4
100 #define ISDN_NET_ENCAP_UIHDLC 5
101
102
103 #define ISDN_USAGE_NONE 0
104 #define ISDN_USAGE_RAW 1
105 #define ISDN_USAGE_MODEM 2
106 #define ISDN_USAGE_NET 3
107 #define ISDN_USAGE_VOICE 4
108 #define ISDN_USAGE_FAX 5
109 #define ISDN_USAGE_MASK 7
110 #define ISDN_USAGE_EXCLUSIVE 64
111 #define ISDN_USAGE_OUTGOING 128
112
113 #define ISDN_MODEM_ANZREG 20
114 #define ISDN_MSNLEN 20
115
116 typedef struct {
117 char drvid[25];
118 unsigned long arg;
119 } isdn_ioctl_struct;
120
121 typedef struct {
122 unsigned long isdndev;
123 unsigned long atmodem[ISDN_MAX_CHANNELS];
124 unsigned long info[ISDN_MAX_CHANNELS];
125 } debugvar_addr;
126
127 typedef struct {
128 char name[10];
129 char phone[20];
130 int outgoing;
131 } isdn_net_ioctl_phone;
132
133 typedef struct {
134 char name[10];
135 char master[10];
136 char slave[10];
137 char eaz[256];
138 char drvid[25];
139 int onhtime;
140 int charge;
141 int l2_proto;
142 int l3_proto;
143 int p_encap;
144 int exclusive;
145 int dialmax;
146 int slavedelay;
147 int cbdelay;
148 int chargehup;
149 int ihup;
150 int secure;
151 int callback;
152 int cbhup;
153 } isdn_net_ioctl_cfg;
154
155 #ifdef __KERNEL__
156
157 #ifndef STANDALONE
158 #include <linux/config.h>
159 #endif
160 #include <linux/errno.h>
161 #include <linux/fs.h>
162 #include <linux/major.h>
163 #include <asm/segment.h>
164 #include <asm/io.h>
165 #include <linux/kernel.h>
166 #include <linux/signal.h>
167 #include <linux/malloc.h>
168 #include <linux/mm.h>
169 #include <linux/timer.h>
170 #include <linux/wait.h>
171 #include <linux/tty.h>
172 #include <linux/tty_flip.h>
173 #include <linux/serial_reg.h>
174 #include <linux/fcntl.h>
175 #include <linux/types.h>
176 #include <linux/interrupt.h>
177 #include <linux/ip.h>
178 #include <linux/in.h>
179 #include <linux/netdevice.h>
180 #include <linux/etherdevice.h>
181 #include <linux/skbuff.h>
182 #include <linux/tcp.h>
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/if_ppp.h>
192 #include <linux/if_pppvar.h>
193
194 #include <linux/isdn_ppp.h>
195 #endif
196
197 #include <linux/isdnif.h>
198
199 #define ISDN_DRVIOCTL_MASK 0x7f
200
201
202 #define ISDN_SERVICE_VOICE 1
203 #define ISDN_SERVICE_AB 1<<1
204 #define ISDN_SERVICE_X21 1<<2
205 #define ISDN_SERVICE_G4 1<<3
206 #define ISDN_SERVICE_BTX 1<<4
207 #define ISDN_SERVICE_DFUE 1<<5
208 #define ISDN_SERVICE_X25 1<<6
209 #define ISDN_SERVICE_TTX 1<<7
210 #define ISDN_SERVICE_MIXED 1<<8
211 #define ISDN_SERVICE_FW 1<<9
212 #define ISDN_SERVICE_GTEL 1<<10
213 #define ISDN_SERVICE_BTXN 1<<11
214 #define ISDN_SERVICE_BTEL 1<<12
215
216
217 #define USG_NONE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
218 #define USG_RAW(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
219 #define USG_MODEM(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
220 #define USG_NET(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
221 #define USG_OUTGOING(x) ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
222
223
224 #define ISDN_TIMER_RES 3
225 #define ISDN_TIMER_02SEC (HZ/(ISDN_TIMER_RES+1)/5)
226 #define ISDN_TIMER_1SEC (HZ/(ISDN_TIMER_RES+1))
227 #define ISDN_TIMER_MODEMREAD 1
228 #define ISDN_TIMER_MODEMPLUS 2
229 #define ISDN_TIMER_MODEMRING 4
230 #define ISDN_TIMER_MODEMXMIT 8
231 #define ISDN_TIMER_NETDIAL 16
232 #define ISDN_TIMER_NETHANGUP 32
233 #define ISDN_TIMER_IPPP 64
234 #define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
235 ISDN_TIMER_MODEMXMIT)
236 #define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
237 ISDN_TIMER_NETDIAL)
238
239
240 #define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
241 #define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
242
243
244 #define ISDN_GLOBAL_STOPPED 1
245
246
247
248
249 #define ISDN_NET_CONNECTED 0x01
250 #define ISDN_NET_SECURE 0x02
251 #define ISDN_NET_CALLBACK 0x04
252 #define ISDN_NET_CBHUP 0x08
253 #define ISDN_NET_CBOUT 0x10
254 #if 0
255
256 #define ISDN_NET_CLONE 0x08
257 #define ISDN_NET_TMP 0x10
258 #define ISDN_NET_DYNAMIC 0x20
259 #endif
260 #define ISDN_NET_MAGIC 0x49344C02
261
262
263 typedef struct {
264 void *next;
265 char num[20];
266 } isdn_net_phone;
267
268
269 typedef struct isdn_net_local_s {
270 ulong magic;
271 char name[10];
272 struct enet_statistics stats;
273 int isdn_device;
274 int isdn_channel;
275 int ppp_minor;
276 int pre_device;
277 int pre_channel;
278 int exclusive;
279 int flags;
280 int dialretry;
281 int dialmax;
282 int cbdelay;
283 int dtimer;
284 char msn[ISDN_MSNLEN];
285 u_char cbhup;
286 u_char dialstate;
287 u_char p_encap;
288
289
290
291 u_char l2_proto;
292
293
294
295
296
297
298 u_char l3_proto;
299
300
301
302 int huptimer;
303 int charge;
304 int chargetime;
305 int hupflags;
306
307
308
309 int outgoing;
310 int onhtime;
311 int chargeint;
312 int onum;
313 int cps;
314 int transcount;
315 int sqfull;
316 ulong sqfull_stamp;
317 ulong slavedelay;
318 struct device *srobin;
319 isdn_net_phone *phone[2];
320
321
322 isdn_net_phone *dial;
323 struct device *master;
324 struct device *slave;
325 struct isdn_net_local_s *next;
326 struct isdn_net_local_s *last;
327 struct isdn_net_dev_s *netdev;
328 struct sk_buff *first_skb;
329 struct sk_buff *sav_skb;
330
331 void (*org_hcb)(struct hh_cache **, struct device *,
332 unsigned short, __u32);
333
334 void (*org_hcu)(struct hh_cache *, struct device *,
335 unsigned char *);
336 } isdn_net_local;
337
338 #ifdef CONFIG_ISDN_PPP
339 struct ippp_bundle {
340 int mp_mrru;
341 struct mpqueue *last;
342 int min;
343 long next_num;
344 struct sqqueue *sq;
345 int modify:1;
346 int bundled:1;
347 };
348 #endif
349
350
351 typedef struct isdn_net_dev_s {
352 isdn_net_local local;
353 isdn_net_local *queue;
354 void *next;
355 struct device dev;
356 #ifdef CONFIG_ISDN_PPP
357 struct mpqueue *mp_last;
358 struct ippp_bundle ib;
359 #endif
360 } isdn_net_dev;
361
362
363
364
365
366 #define ISDN_ASYNC_MAGIC 0x49344C01
367 #define ISDN_ASYNC_INITIALIZED 0x80000000
368 #define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000
369 #define ISDN_ASYNC_NORMAL_ACTIVE 0x20000000
370 #define ISDN_ASYNC_CLOSING 0x08000000
371 #define ISDN_ASYNC_CTS_FLOW 0x04000000
372 #define ISDN_ASYNC_CHECK_CD 0x02000000
373 #define ISDN_ASYNC_HUP_NOTIFY 0x0001
374 #define ISDN_ASYNC_SESSION_LOCKOUT 0x0100
375 #define ISDN_ASYNC_PGRP_LOCKOUT 0x0200
376 #define ISDN_ASYNC_CALLOUT_NOHUP 0x0400
377 #define ISDN_ASYNC_SPLIT_TERMIOS 0x0008
378 #define ISDN_PORT_16550A 4
379 #define ISDN_SERIAL_XMIT_SIZE 4000
380 #define ISDN_SERIAL_TYPE_NORMAL 1
381 #define ISDN_SERIAL_TYPE_CALLOUT 2
382
383
384 typedef struct {
385 int magic;
386 int flags;
387 int type;
388 struct tty_struct *tty;
389 int x_char;
390 int close_delay;
391 int MCR;
392 int line;
393 int count;
394 int blocked_open;
395 long session;
396 long pgrp;
397 int isdn_driver;
398 int isdn_channel;
399 int drv_index;
400 #if FUTURE
401 int send_outstanding;
402 #endif
403 int xmit_size;
404 int xmit_count;
405 u_char *xmit_buf;
406 struct termios normal_termios;
407 struct termios callout_termios;
408 struct wait_queue *open_wait;
409 struct wait_queue *close_wait;
410 } modem_info;
411
412 #define ISDN_MODEM_WINSIZE 8
413
414
415 typedef struct {
416 u_char profile[ISDN_MODEM_ANZREG];
417 u_char mdmreg[ISDN_MODEM_ANZREG];
418 char pmsn[ISDN_MSNLEN];
419 char msn[ISDN_MSNLEN];
420 int mdmcmdl;
421 int pluscount;
422 int lastplus;
423 char mdmcmd[255];
424 } atemu;
425
426
427 typedef struct {
428 int msr[ISDN_MAX_CHANNELS];
429 int mlr[ISDN_MAX_CHANNELS];
430 int refcount;
431 int online[ISDN_MAX_CHANNELS];
432 int dialing[ISDN_MAX_CHANNELS];
433 int rcvsched[ISDN_MAX_CHANNELS];
434 int ncarrier[ISDN_MAX_CHANNELS];
435 struct tty_driver tty_modem;
436 struct tty_driver cua_modem;
437 struct tty_struct *modem_table[ISDN_MAX_CHANNELS];
438 struct termios *modem_termios[ISDN_MAX_CHANNELS];
439 struct termios *modem_termios_locked[ISDN_MAX_CHANNELS];
440 atemu atmodem[ISDN_MAX_CHANNELS];
441 modem_info info[ISDN_MAX_CHANNELS];
442 } modem;
443
444
445
446
447
448
449 #define NUM_RCV_BUFFS 64
450 #define PPP_HARD_HDR_LEN 4
451
452 #define IPPP_OPEN 0x1
453 #define IPPP_CONNECT 0x2
454 #define IPPP_CLOSEWAIT 0x4
455 #define IPPP_NOBLOCK 0x8
456
457 #ifdef CONFIG_ISDN_PPP
458
459 struct sqqueue {
460 struct sqqueue *next;
461 int sqno_start;
462 int sqno_end;
463 struct sk_buff *skb;
464 long timer;
465 };
466
467 struct mpqueue {
468 struct mpqueue *next;
469 struct mpqueue *last;
470 int sqno;
471 struct sk_buff *skb;
472 int BEbyte;
473 unsigned long time;
474 };
475
476 struct ippp_buf_queue {
477 struct ippp_buf_queue *next;
478 struct ippp_buf_queue *last;
479 char *buf;
480 int len;
481 };
482
483 struct ippp_struct {
484 struct ippp_struct *next_link;
485 int state;
486 struct ippp_buf_queue rq[NUM_RCV_BUFFS];
487 struct ippp_buf_queue *first;
488 struct ippp_buf_queue *last;
489 struct wait_queue *wq;
490 struct wait_queue *wq1;
491 struct task_struct *tk;
492 unsigned int mpppcfg;
493 unsigned int pppcfg;
494 unsigned int mru;
495 unsigned int mpmru;
496 unsigned int mpmtu;
497 unsigned int maxcid;
498 isdn_net_local *lp;
499 int unit;
500 long last_link_seqno;
501 long mp_seqno;
502 long range;
503 #ifdef CONFIG_ISDN_PPP_VJ
504 unsigned char *cbuf;
505 struct slcompress *slcomp;
506 #endif
507 };
508
509 #endif
510
511
512
513
514
515
516 typedef struct pqueue {
517 char *next;
518 short length;
519 short size;
520 u_char *rptr;
521 u_char buffer[1];
522 } pqueue;
523
524 typedef struct {
525 char *next;
526 char *private;
527 } infostruct;
528
529
530 typedef struct {
531 ulong flags;
532 int channels;
533 int reject_bus;
534 struct wait_queue *st_waitq;
535 int maxbufsize;
536 unsigned long pktcount;
537 int running;
538 int loaded;
539 int stavail;
540 isdn_if *interface;
541 int *rcverr;
542 int *rcvcount;
543 pqueue **rpqueue;
544 struct wait_queue **rcv_waitq;
545 struct wait_queue **snd_waitq;
546 char msn2eaz[10][ISDN_MSNLEN];
547 } driver;
548
549
550 typedef struct isdn_devt {
551 unsigned short flags;
552
553 int drivers;
554 int channels;
555 int net_verbose;
556 int modempoll;
557 int tflags;
558
559 int global_flags;
560 infostruct *infochain;
561 struct wait_queue *info_waitq;
562 struct timer_list timer;
563 int chanmap[ISDN_MAX_CHANNELS];
564 int drvmap[ISDN_MAX_CHANNELS];
565 int usage[ISDN_MAX_CHANNELS];
566 char num[ISDN_MAX_CHANNELS][20];
567 int m_idx[ISDN_MAX_CHANNELS];
568 driver *drv[ISDN_MAX_DRIVERS];
569 isdn_net_dev *netdev;
570 char drvid[ISDN_MAX_DRIVERS][20];
571 struct task_struct *profd;
572 modem mdm;
573 isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS];
574 isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS];
575 ulong ibytes[ISDN_MAX_CHANNELS];
576 ulong obytes[ISDN_MAX_CHANNELS];
577 } isdn_dev;
578
579 extern isdn_dev *dev;
580
581
582 #define MIN(a,b) ((a<b)?a:b)
583 #define MAX(a,b) ((a>b)?a:b)
584
585 #endif
586 #endif