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