aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/isdn/i4l
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r--drivers/isdn/i4l/isdn_audio.c126
-rw-r--r--drivers/isdn/i4l/isdn_bsdcomp.c375
-rw-r--r--drivers/isdn/i4l/isdn_common.c1511
-rw-r--r--drivers/isdn/i4l/isdn_common.h18
-rw-r--r--drivers/isdn/i4l/isdn_concap.c36
-rw-r--r--drivers/isdn/i4l/isdn_concap.h4
-rw-r--r--drivers/isdn/i4l/isdn_net.c1501
-rw-r--r--drivers/isdn/i4l/isdn_net.h11
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c1446
-rw-r--r--drivers/isdn/i4l/isdn_ppp.h2
-rw-r--r--drivers/isdn/i4l/isdn_tty.c2917
-rw-r--r--drivers/isdn/i4l/isdn_tty.h10
-rw-r--r--drivers/isdn/i4l/isdn_ttyfax.c1092
-rw-r--r--drivers/isdn/i4l/isdn_ttyfax.h1
-rw-r--r--drivers/isdn/i4l/isdn_v110.c294
-rw-r--r--drivers/isdn/i4l/isdn_v110.h8
-rw-r--r--drivers/isdn/i4l/isdn_x25iface.c226
-rw-r--r--drivers/isdn/i4l/isdn_x25iface.h16
-rw-r--r--drivers/isdn/i4l/isdnhdlc.c54
19 files changed, 4884 insertions, 4764 deletions
diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c
index 78ce4221471..d5013935ac6 100644
--- a/drivers/isdn/i4l/isdn_audio.c
+++ b/drivers/isdn/i4l/isdn_audio.c
@@ -204,9 +204,9 @@ isdn_audio_tlookup(const u_char *table, u_char *buff, unsigned long n)
204 "xlatb\n\t" 204 "xlatb\n\t"
205 "stosb\n\t" 205 "stosb\n\t"
206 "loop 1b\n\t" 206 "loop 1b\n\t"
207 : "=&b"(d0), "=&c"(d1), "=&D"(d2), "=&S"(d3) 207 : "=&b"(d0), "=&c"(d1), "=&D"(d2), "=&S"(d3)
208 : "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff) 208 : "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff)
209 : "memory", "ax"); 209 : "memory", "ax");
210#else 210#else
211 while (n--) 211 while (n--)
212 *buff = table[*(unsigned char *)buff], buff++; 212 *buff = table[*(unsigned char *)buff], buff++;
@@ -242,27 +242,27 @@ static unsigned char
242isdn_audio_linear2ulaw(int sample) 242isdn_audio_linear2ulaw(int sample)
243{ 243{
244 static int exp_lut[256] = 244 static int exp_lut[256] =
245 { 245 {
246 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 246 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
247 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 247 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
248 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 248 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
249 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 249 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
250 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 250 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
251 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 251 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
252 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 252 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
253 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 253 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
254 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 254 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
255 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 255 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
256 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 256 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
257 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 257 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
258 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 258 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
259 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 259 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
260 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 260 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
261 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 261 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
262 }; 262 };
263 int sign, 263 int sign,
264 exponent, 264 exponent,
265 mantissa; 265 mantissa;
266 unsigned char ulawbyte; 266 unsigned char ulawbyte;
267 267
268 /* Get the sample into sign-magnitude. */ 268 /* Get the sample into sign-magnitude. */
@@ -299,7 +299,7 @@ static int bitmask[9] =
299}; 299};
300 300
301static int 301static int
302isdn_audio_get_bits(adpcm_state *s, unsigned char **in, int *len) 302isdn_audio_get_bits(adpcm_state * s, unsigned char **in, int *len)
303{ 303{
304 while (s->nleft < s->nbits) { 304 while (s->nleft < s->nbits) {
305 int d = *((*in)++); 305 int d = *((*in)++);
@@ -312,7 +312,7 @@ isdn_audio_get_bits(adpcm_state *s, unsigned char **in, int *len)
312} 312}
313 313
314static void 314static void
315isdn_audio_put_bits(int data, int nbits, adpcm_state *s, 315isdn_audio_put_bits(int data, int nbits, adpcm_state * s,
316 unsigned char **out, int *len) 316 unsigned char **out, int *len)
317{ 317{
318 s->word = (s->word << nbits) | (data & bitmask[nbits]); 318 s->word = (s->word << nbits) | (data & bitmask[nbits]);
@@ -326,7 +326,7 @@ isdn_audio_put_bits(int data, int nbits, adpcm_state *s,
326} 326}
327 327
328adpcm_state * 328adpcm_state *
329isdn_audio_adpcm_init(adpcm_state *s, int nbits) 329isdn_audio_adpcm_init(adpcm_state * s, int nbits)
330{ 330{
331 if (!s) 331 if (!s)
332 s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC); 332 s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC);
@@ -341,7 +341,7 @@ isdn_audio_adpcm_init(adpcm_state *s, int nbits)
341} 341}
342 342
343dtmf_state * 343dtmf_state *
344isdn_audio_dtmf_init(dtmf_state *s) 344isdn_audio_dtmf_init(dtmf_state * s)
345{ 345{
346 if (!s) 346 if (!s)
347 s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC); 347 s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC);
@@ -358,7 +358,7 @@ isdn_audio_dtmf_init(dtmf_state *s)
358 */ 358 */
359 359
360int 360int
361isdn_audio_adpcm2xlaw(adpcm_state *s, int fmt, unsigned char *in, 361isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in,
362 unsigned char *out, int len) 362 unsigned char *out, int len)
363{ 363{
364 int a = s->a; 364 int a = s->a;
@@ -379,7 +379,7 @@ isdn_audio_adpcm2xlaw(adpcm_state *s, int fmt, unsigned char *in,
379 a++; 379 a++;
380 if (fmt) 380 if (fmt)
381 *out++ = isdn_audio_ulaw_to_alaw[ 381 *out++ = isdn_audio_ulaw_to_alaw[
382 isdn_audio_linear2ulaw(a << 2)]; 382 isdn_audio_linear2ulaw(a << 2)];
383 else 383 else
384 *out++ = isdn_audio_linear2ulaw(a << 2); 384 *out++ = isdn_audio_linear2ulaw(a << 2);
385 olen++; 385 olen++;
@@ -393,7 +393,7 @@ isdn_audio_adpcm2xlaw(adpcm_state *s, int fmt, unsigned char *in,
393} 393}
394 394
395int 395int
396isdn_audio_xlaw2adpcm(adpcm_state *s, int fmt, unsigned char *in, 396isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in,
397 unsigned char *out, int len) 397 unsigned char *out, int len)
398{ 398{
399 int a = s->a; 399 int a = s->a;
@@ -403,9 +403,9 @@ isdn_audio_xlaw2adpcm(adpcm_state *s, int fmt, unsigned char *in,
403 403
404 while (len--) { 404 while (len--) {
405 int e = 0, 405 int e = 0,
406 nmax = 1 << (nbits - 1); 406 nmax = 1 << (nbits - 1);
407 int sign, 407 int sign,
408 delta; 408 delta;
409 409
410 if (fmt) 410 if (fmt)
411 delta = (isdn_audio_alaw_to_s16[*in++] >> 2) - a; 411 delta = (isdn_audio_alaw_to_s16[*in++] >> 2) - a;
@@ -439,26 +439,26 @@ isdn_audio_xlaw2adpcm(adpcm_state *s, int fmt, unsigned char *in,
439 439
440/* 440/*
441 * Goertzel algorithm. 441 * Goertzel algorithm.
442 * See http://ptolemy.eecs.berkeley.edu/papers/96/dtmf_ict/ 442 * See http://ptolemy.eecs.berkeley.edu/papers/96/dtmf_ict/
443 * for more info. 443 * for more info.
444 * Result is stored into an sk_buff and queued up for later 444 * Result is stored into an sk_buff and queued up for later
445 * evaluation. 445 * evaluation.
446 */ 446 */
447static void 447static void
448isdn_audio_goertzel(int *sample, modem_info *info) 448isdn_audio_goertzel(int *sample, modem_info * info)
449{ 449{
450 int sk, 450 int sk,
451 sk1, 451 sk1,
452 sk2; 452 sk2;
453 int k, 453 int k,
454 n; 454 n;
455 struct sk_buff *skb; 455 struct sk_buff *skb;
456 int *result; 456 int *result;
457 457
458 skb = dev_alloc_skb(sizeof(int) * NCOEFF); 458 skb = dev_alloc_skb(sizeof(int) * NCOEFF);
459 if (!skb) { 459 if (!skb) {
460 printk(KERN_WARNING 460 printk(KERN_WARNING
461 "isdn_audio: Could not alloc DTMF result for ttyI%d\n", 461 "isdn_audio: Could not alloc DTMF result for ttyI%d\n",
462 info->line); 462 info->line);
463 return; 463 return;
464 } 464 }
@@ -483,16 +483,16 @@ isdn_audio_goertzel(int *sample, modem_info *info)
483 printk(KERN_DEBUG 483 printk(KERN_DEBUG
484 "isdn_audio: dtmf goertzel overflow, sk2=%d\n", sk2); 484 "isdn_audio: dtmf goertzel overflow, sk2=%d\n", sk2);
485 result[k] = 485 result[k] =
486 ((sk * sk) >> AMP_BITS) - 486 ((sk * sk) >> AMP_BITS) -
487 ((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) + 487 ((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) +
488 ((sk2 * sk2) >> AMP_BITS); 488 ((sk2 * sk2) >> AMP_BITS);
489 } 489 }
490 skb_queue_tail(&info->dtmf_queue, skb); 490 skb_queue_tail(&info->dtmf_queue, skb);
491 isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); 491 isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1);
492} 492}
493 493
494void 494void
495isdn_audio_eval_dtmf(modem_info *info) 495isdn_audio_eval_dtmf(modem_info * info)
496{ 496{
497 struct sk_buff *skb; 497 struct sk_buff *skb;
498 int *result; 498 int *result;
@@ -590,7 +590,7 @@ isdn_audio_eval_dtmf(modem_info *info)
590 * fmt = audio data format (0 = ulaw, 1 = alaw) 590 * fmt = audio data format (0 = ulaw, 1 = alaw)
591 */ 591 */
592void 592void
593isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt) 593isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt)
594{ 594{
595 dtmf_state *s = info->dtmf_state; 595 dtmf_state *s = info->dtmf_state;
596 int i; 596 int i;
@@ -605,10 +605,10 @@ isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt)
605 for (i = 0; i < c; i++) { 605 for (i = 0; i < c; i++) {
606 if (fmt) 606 if (fmt)
607 s->buf[s->idx++] = 607 s->buf[s->idx++] =
608 isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS); 608 isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS);
609 else 609 else
610 s->buf[s->idx++] = 610 s->buf[s->idx++] =
611 isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS); 611 isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS);
612 } 612 }
613 if (s->idx == DTMF_NPOINTS) { 613 if (s->idx == DTMF_NPOINTS) {
614 isdn_audio_goertzel(s->buf, info); 614 isdn_audio_goertzel(s->buf, info);
@@ -619,7 +619,7 @@ isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt)
619} 619}
620 620
621silence_state * 621silence_state *
622isdn_audio_silence_init(silence_state *s) 622isdn_audio_silence_init(silence_state * s)
623{ 623{
624 if (!s) 624 if (!s)
625 s = kmalloc(sizeof(silence_state), GFP_ATOMIC); 625 s = kmalloc(sizeof(silence_state), GFP_ATOMIC);
@@ -631,7 +631,7 @@ isdn_audio_silence_init(silence_state *s)
631} 631}
632 632
633void 633void
634isdn_audio_calc_silence(modem_info *info, unsigned char *buf, int len, int fmt) 634isdn_audio_calc_silence(modem_info * info, unsigned char *buf, int len, int fmt)
635{ 635{
636 silence_state *s = info->silence_state; 636 silence_state *s = info->silence_state;
637 int i; 637 int i;
@@ -641,24 +641,24 @@ isdn_audio_calc_silence(modem_info *info, unsigned char *buf, int len, int fmt)
641 641
642 for (i = 0; i < len; i++) { 642 for (i = 0; i < len; i++) {
643 if (fmt) 643 if (fmt)
644 c = isdn_audio_alaw_to_ulaw[*buf++]; 644 c = isdn_audio_alaw_to_ulaw[*buf++];
645 else 645 else
646 c = *buf++; 646 c = *buf++;
647 647
648 if (c > 0) c -= 128; 648 if (c > 0) c -= 128;
649 c = abs(c); 649 c = abs(c);
650 650
651 if (c > (info->emu.vpar[1] * 4)) { 651 if (c > (info->emu.vpar[1] * 4)) {
652 s->idx = 0; 652 s->idx = 0;
653 s->state = 1; 653 s->state = 1;
654 } else { 654 } else {
655 if (s->idx < 210000) s->idx++; 655 if (s->idx < 210000) s->idx++;
656 } 656 }
657 } 657 }
658} 658}
659 659
660void 660void
661isdn_audio_put_dle_code(modem_info *info, u_char code) 661isdn_audio_put_dle_code(modem_info * info, u_char code)
662{ 662{
663 struct sk_buff *skb; 663 struct sk_buff *skb;
664 int di; 664 int di;
@@ -668,7 +668,7 @@ isdn_audio_put_dle_code(modem_info *info, u_char code)
668 skb = dev_alloc_skb(2); 668 skb = dev_alloc_skb(2);
669 if (!skb) { 669 if (!skb) {
670 printk(KERN_WARNING 670 printk(KERN_WARNING
671 "isdn_audio: Could not alloc skb for ttyI%d\n", 671 "isdn_audio: Could not alloc skb for ttyI%d\n",
672 info->line); 672 info->line);
673 return; 673 return;
674 } 674 }
@@ -688,24 +688,24 @@ isdn_audio_put_dle_code(modem_info *info, u_char code)
688} 688}
689 689
690void 690void
691isdn_audio_eval_silence(modem_info *info) 691isdn_audio_eval_silence(modem_info * info)
692{ 692{
693 silence_state *s = info->silence_state; 693 silence_state *s = info->silence_state;
694 char what; 694 char what;
695 695
696 what = ' '; 696 what = ' ';
697 697
698 if (s->idx > (info->emu.vpar[2] * 800)) { 698 if (s->idx > (info->emu.vpar[2] * 800)) {
699 s->idx = 0; 699 s->idx = 0;
700 if (!s->state) { /* silence from beginning of rec */ 700 if (!s->state) { /* silence from beginning of rec */
701 what = 's'; 701 what = 's';
702 } else { 702 } else {
703 what = 'q'; 703 what = 'q';
704 } 704 }
705 } 705 }
706 if ((what == 's') || (what == 'q')) { 706 if ((what == 's') || (what == 'q')) {
707 printk(KERN_DEBUG "ttyI%d: %s\n", info->line, 707 printk(KERN_DEBUG "ttyI%d: %s\n", info->line,
708 (what == 's') ? "silence" : "quiet"); 708 (what=='s') ? "silence":"quiet");
709 isdn_audio_put_dle_code(info, what); 709 isdn_audio_put_dle_code(info, what);
710 } 710 }
711} 711}
diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
index 8837ac5a492..aa0b6a6f5ef 100644
--- a/drivers/isdn/i4l/isdn_bsdcomp.c
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9/* 9/*
10 * Update: The Berkeley copyright was changed, and the change 10 * Update: The Berkeley copyright was changed, and the change
11 * is retroactive to all "true" BSD software (ie everything 11 * is retroactive to all "true" BSD software (ie everything
12 * from UCB as opposed to other peoples code that just carried 12 * from UCB as opposed to other peoples code that just carried
13 * the same license). The new copyright doesn't clash with the 13 * the same license). The new copyright doesn't clash with the
@@ -69,6 +69,7 @@
69#include <linux/signal.h> /* used in new tty drivers */ 69#include <linux/signal.h> /* used in new tty drivers */
70#include <linux/bitops.h> 70#include <linux/bitops.h>
71 71
72#include <asm/system.h>
72#include <asm/byteorder.h> 73#include <asm/byteorder.h>
73#include <asm/types.h> 74#include <asm/types.h>
74 75
@@ -120,7 +121,7 @@ struct bsd_db {
120 unsigned char maxbits; /* maximum bits/code */ 121 unsigned char maxbits; /* maximum bits/code */
121 unsigned char debug; /* non-zero if debug desired */ 122 unsigned char debug; /* non-zero if debug desired */
122 unsigned char unit; /* ppp unit number */ 123 unsigned char unit; /* ppp unit number */
123 u16 seqno; /* sequence # of next packet */ 124 u16 seqno; /* sequence # of next packet */
124 unsigned int mru; /* size of receive (decompress) bufr */ 125 unsigned int mru; /* size of receive (decompress) bufr */
125 unsigned int maxmaxcode; /* largest valid code */ 126 unsigned int maxmaxcode; /* largest valid code */
126 unsigned int max_ent; /* largest code in use */ 127 unsigned int max_ent; /* largest code in use */
@@ -156,16 +157,16 @@ struct bsd_db {
156#define MAXCODE(b) ((1 << (b)) - 1) 157#define MAXCODE(b) ((1 << (b)) - 1)
157#define BADCODEM1 MAXCODE(MAX_BSD_BITS) 158#define BADCODEM1 MAXCODE(MAX_BSD_BITS)
158 159
159#define BSD_HASH(prefix, suffix, hshift) ((((unsigned long)(suffix)) << (hshift)) \ 160#define BSD_HASH(prefix,suffix,hshift) ((((unsigned long)(suffix))<<(hshift)) \
160 ^ (unsigned long)(prefix)) 161 ^ (unsigned long)(prefix))
161#define BSD_KEY(prefix, suffix) ((((unsigned long)(suffix)) << 16) \ 162#define BSD_KEY(prefix,suffix) ((((unsigned long)(suffix)) << 16) \
162 + (unsigned long)(prefix)) 163 + (unsigned long)(prefix))
163 164
164#define CHECK_GAP 10000 /* Ratio check interval */ 165#define CHECK_GAP 10000 /* Ratio check interval */
165 166
166#define RATIO_SCALE_LOG 8 167#define RATIO_SCALE_LOG 8
167#define RATIO_SCALE (1 << RATIO_SCALE_LOG) 168#define RATIO_SCALE (1<<RATIO_SCALE_LOG)
168#define RATIO_MAX (0x7fffffff >> RATIO_SCALE_LOG) 169#define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG)
169 170
170/* 171/*
171 * clear the dictionary 172 * clear the dictionary
@@ -174,7 +175,7 @@ struct bsd_db {
174static void bsd_clear(struct bsd_db *db) 175static void bsd_clear(struct bsd_db *db)
175{ 176{
176 db->clear_count++; 177 db->clear_count++;
177 db->max_ent = FIRST - 1; 178 db->max_ent = FIRST-1;
178 db->n_bits = BSD_INIT_BITS; 179 db->n_bits = BSD_INIT_BITS;
179 db->bytes_out = 0; 180 db->bytes_out = 0;
180 db->in_count = 0; 181 db->in_count = 0;
@@ -196,56 +197,56 @@ static void bsd_clear(struct bsd_db *db)
196 * the absence of CLEAR codes (while packets are incompressible), they 197 * the absence of CLEAR codes (while packets are incompressible), they
197 * must compute the same ratio. 198 * must compute the same ratio.
198 */ 199 */
199static int bsd_check(struct bsd_db *db) /* 1=output CLEAR */ 200static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */
200{ 201{
201 unsigned int new_ratio; 202 unsigned int new_ratio;
202 203
203 if (db->in_count >= db->checkpoint) 204 if (db->in_count >= db->checkpoint)
204 { 205 {
205 /* age the ratio by limiting the size of the counts */ 206 /* age the ratio by limiting the size of the counts */
206 if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) 207 if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX)
207 { 208 {
208 db->in_count -= (db->in_count >> 2); 209 db->in_count -= (db->in_count >> 2);
209 db->bytes_out -= (db->bytes_out >> 2); 210 db->bytes_out -= (db->bytes_out >> 2);
210 } 211 }
211 212
212 db->checkpoint = db->in_count + CHECK_GAP; 213 db->checkpoint = db->in_count + CHECK_GAP;
213 214
214 if (db->max_ent >= db->maxmaxcode) 215 if (db->max_ent >= db->maxmaxcode)
215 { 216 {
216 /* Reset the dictionary only if the ratio is worse, 217 /* Reset the dictionary only if the ratio is worse,
217 * or if it looks as if it has been poisoned 218 * or if it looks as if it has been poisoned
218 * by incompressible data. 219 * by incompressible data.
219 * 220 *
220 * This does not overflow, because 221 * This does not overflow, because
221 * db->in_count <= RATIO_MAX. 222 * db->in_count <= RATIO_MAX.
222 */ 223 */
223 224
224 new_ratio = db->in_count << RATIO_SCALE_LOG; 225 new_ratio = db->in_count << RATIO_SCALE_LOG;
225 if (db->bytes_out != 0) 226 if (db->bytes_out != 0)
226 { 227 {
227 new_ratio /= db->bytes_out; 228 new_ratio /= db->bytes_out;
228 } 229 }
229 230
230 if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) 231 if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE)
231 { 232 {
232 bsd_clear(db); 233 bsd_clear (db);
233 return 1; 234 return 1;
234 } 235 }
235 db->ratio = new_ratio; 236 db->ratio = new_ratio;
236 } 237 }
237 } 238 }
238 return 0; 239 return 0;
239} 240}
240 241
241/* 242/*
242 * Return statistics. 243 * Return statistics.
243 */ 244 */
244 245
245static void bsd_stats(void *state, struct compstat *stats) 246static void bsd_stats (void *state, struct compstat *stats)
246{ 247{
247 struct bsd_db *db = (struct bsd_db *) state; 248 struct bsd_db *db = (struct bsd_db *) state;
248 249
249 stats->unc_bytes = db->uncomp_bytes; 250 stats->unc_bytes = db->uncomp_bytes;
250 stats->unc_packets = db->uncomp_count; 251 stats->unc_packets = db->uncomp_count;
251 stats->comp_bytes = db->comp_bytes; 252 stats->comp_bytes = db->comp_bytes;
@@ -259,9 +260,9 @@ static void bsd_stats(void *state, struct compstat *stats)
259/* 260/*
260 * Reset state, as on a CCP ResetReq. 261 * Reset state, as on a CCP ResetReq.
261 */ 262 */
262static void bsd_reset(void *state, unsigned char code, unsigned char id, 263static void bsd_reset (void *state,unsigned char code, unsigned char id,
263 unsigned char *data, unsigned len, 264 unsigned char *data, unsigned len,
264 struct isdn_ppp_resetparams *rsparm) 265 struct isdn_ppp_resetparams *rsparm)
265{ 266{
266 struct bsd_db *db = (struct bsd_db *) state; 267 struct bsd_db *db = (struct bsd_db *) state;
267 268
@@ -273,7 +274,7 @@ static void bsd_reset(void *state, unsigned char code, unsigned char id,
273/* 274/*
274 * Release the compression structure 275 * Release the compression structure
275 */ 276 */
276static void bsd_free(void *state) 277static void bsd_free (void *state)
277{ 278{
278 struct bsd_db *db = (struct bsd_db *) state; 279 struct bsd_db *db = (struct bsd_db *) state;
279 280
@@ -301,7 +302,7 @@ static void bsd_free(void *state)
301/* 302/*
302 * Allocate space for a (de) compressor. 303 * Allocate space for a (de) compressor.
303 */ 304 */
304static void *bsd_alloc(struct isdn_ppp_comp_data *data) 305static void *bsd_alloc (struct isdn_ppp_comp_data *data)
305{ 306{
306 int bits; 307 int bits;
307 unsigned int hsize, hshift, maxmaxcode; 308 unsigned int hsize, hshift, maxmaxcode;
@@ -309,27 +310,27 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
309 int decomp; 310 int decomp;
310 311
311 static unsigned int htab[][2] = { 312 static unsigned int htab[][2] = {
312 { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , 313 { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } ,
313 { 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 } 314 { 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 }
314 }; 315 };
315 316
316 if (data->optlen != 1 || data->num != CI_BSD_COMPRESS 317 if (data->optlen != 1 || data->num != CI_BSD_COMPRESS
317 || BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) 318 || BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION)
318 return NULL; 319 return NULL;
319 320
320 bits = BSD_NBITS(data->options[0]); 321 bits = BSD_NBITS(data->options[0]);
321 322
322 if (bits < 9 || bits > 15) 323 if(bits < 9 || bits > 15)
323 return NULL; 324 return NULL;
324 325
325 hsize = htab[bits - 9][0]; 326 hsize = htab[bits-9][0];
326 hshift = htab[bits - 9][1]; 327 hshift = htab[bits-9][1];
327 328
328 /* 329 /*
329 * Allocate the main control structure for this instance. 330 * Allocate the main control structure for this instance.
330 */ 331 */
331 maxmaxcode = MAXCODE(bits); 332 maxmaxcode = MAXCODE(bits);
332 db = kzalloc(sizeof(struct bsd_db), GFP_KERNEL); 333 db = kzalloc (sizeof (struct bsd_db),GFP_KERNEL);
333 if (!db) 334 if (!db)
334 return NULL; 335 return NULL;
335 336
@@ -342,7 +343,7 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
342 */ 343 */
343 db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); 344 db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
344 if (!db->dict) { 345 if (!db->dict) {
345 bsd_free(db); 346 bsd_free (db);
346 return NULL; 347 return NULL;
347 } 348 }
348 349
@@ -355,7 +356,7 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
355 else { 356 else {
356 db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); 357 db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
357 if (!db->lens) { 358 if (!db->lens) {
358 bsd_free(db); 359 bsd_free (db);
359 return (NULL); 360 return (NULL);
360 } 361 }
361 } 362 }
@@ -363,41 +364,41 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
363 /* 364 /*
364 * Initialize the data information for the compression code 365 * Initialize the data information for the compression code
365 */ 366 */
366 db->totlen = sizeof(struct bsd_db) + (sizeof(struct bsd_dict) * hsize); 367 db->totlen = sizeof (struct bsd_db) + (sizeof (struct bsd_dict) * hsize);
367 db->hsize = hsize; 368 db->hsize = hsize;
368 db->hshift = hshift; 369 db->hshift = hshift;
369 db->maxmaxcode = maxmaxcode; 370 db->maxmaxcode = maxmaxcode;
370 db->maxbits = bits; 371 db->maxbits = bits;
371 372
372 return (void *)db; 373 return (void *) db;
373} 374}
374 375
375/* 376/*
376 * Initialize the database. 377 * Initialize the database.
377 */ 378 */
378static int bsd_init(void *state, struct isdn_ppp_comp_data *data, int unit, int debug) 379static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int debug)
379{ 380{
380 struct bsd_db *db = state; 381 struct bsd_db *db = state;
381 int indx; 382 int indx;
382 int decomp; 383 int decomp;
383 384
384 if (!state || !data) { 385 if(!state || !data) {
385 printk(KERN_ERR "isdn_bsd_init: [%d] ERR, state %lx data %lx\n", unit, (long)state, (long)data); 386 printk(KERN_ERR "isdn_bsd_init: [%d] ERR, state %lx data %lx\n",unit,(long)state,(long)data);
386 return 0; 387 return 0;
387 } 388 }
388 389
389 decomp = db->xmit ? 0 : 1; 390 decomp = db->xmit ? 0 : 1;
390 391
391 if (data->optlen != 1 || data->num != CI_BSD_COMPRESS 392 if (data->optlen != 1 || data->num != CI_BSD_COMPRESS
392 || (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) 393 || (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION)
393 || (BSD_NBITS(data->options[0]) != db->maxbits) 394 || (BSD_NBITS(data->options[0]) != db->maxbits)
394 || (decomp && db->lens == NULL)) { 395 || (decomp && db->lens == NULL)) {
395 printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n", data->optlen, data->num, data->options[0], decomp, (unsigned long)db->lens); 396 printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n",data->optlen,data->num,data->options[0],decomp,(unsigned long)db->lens);
396 return 0; 397 return 0;
397 } 398 }
398 399
399 if (decomp) 400 if (decomp)
400 for (indx = LAST; indx >= 0; indx--) 401 for(indx=LAST;indx>=0;indx--)
401 db->lens[indx] = 1; 402 db->lens[indx] = 1;
402 403
403 indx = db->hsize; 404 indx = db->hsize;
@@ -410,9 +411,9 @@ static int bsd_init(void *state, struct isdn_ppp_comp_data *data, int unit, int
410 db->mru = 0; 411 db->mru = 0;
411 412
412 db->debug = 1; 413 db->debug = 1;
413 414
414 bsd_reset(db, 0, 0, NULL, 0, NULL); 415 bsd_reset(db,0,0,NULL,0,NULL);
415 416
416 return 1; 417 return 1;
417} 418}
418 419
@@ -420,37 +421,37 @@ static int bsd_init(void *state, struct isdn_ppp_comp_data *data, int unit, int
420 * Obtain pointers to the various structures in the compression tables 421 * Obtain pointers to the various structures in the compression tables
421 */ 422 */
422 423
423#define dict_ptrx(p, idx) &(p->dict[idx]) 424#define dict_ptrx(p,idx) &(p->dict[idx])
424#define lens_ptrx(p, idx) &(p->lens[idx]) 425#define lens_ptrx(p,idx) &(p->lens[idx])
425 426
426#ifdef DEBUG 427#ifdef DEBUG
427static unsigned short *lens_ptr(struct bsd_db *db, int idx) 428static unsigned short *lens_ptr(struct bsd_db *db, int idx)
428{ 429{
429 if ((unsigned int) idx > (unsigned int) db->maxmaxcode) { 430 if ((unsigned int) idx > (unsigned int) db->maxmaxcode) {
430 printk(KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx); 431 printk (KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx);
431 idx = 0; 432 idx = 0;
432 } 433 }
433 return lens_ptrx(db, idx); 434 return lens_ptrx (db, idx);
434} 435}
435 436
436static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx) 437static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx)
437{ 438{
438 if ((unsigned int) idx >= (unsigned int) db->hsize) { 439 if ((unsigned int) idx >= (unsigned int) db->hsize) {
439 printk(KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx); 440 printk (KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx);
440 idx = 0; 441 idx = 0;
441 } 442 }
442 return dict_ptrx(db, idx); 443 return dict_ptrx (db, idx);
443} 444}
444 445
445#else 446#else
446#define lens_ptr(db, idx) lens_ptrx(db, idx) 447#define lens_ptr(db,idx) lens_ptrx(db,idx)
447#define dict_ptr(db, idx) dict_ptrx(db, idx) 448#define dict_ptr(db,idx) dict_ptrx(db,idx)
448#endif 449#endif
449 450
450/* 451/*
451 * compress a packet 452 * compress a packet
452 */ 453 */
453static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, int proto) 454static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,int proto)
454{ 455{
455 struct bsd_db *db; 456 struct bsd_db *db;
456 int hshift; 457 int hshift;
@@ -462,31 +463,31 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
462 unsigned long fcode; 463 unsigned long fcode;
463 struct bsd_dict *dictp; 464 struct bsd_dict *dictp;
464 unsigned char c; 465 unsigned char c;
465 int hval, disp, ilen, mxcode; 466 int hval,disp,ilen,mxcode;
466 unsigned char *rptr = skb_in->data; 467 unsigned char *rptr = skb_in->data;
467 int isize = skb_in->len; 468 int isize = skb_in->len;
468 469
469#define OUTPUT(ent) \ 470#define OUTPUT(ent) \
470 { \ 471 { \
471 bitno -= n_bits; \ 472 bitno -= n_bits; \
472 accm |= ((ent) << bitno); \ 473 accm |= ((ent) << bitno); \
473 do { \ 474 do { \
474 if (skb_out && skb_tailroom(skb_out) > 0) \ 475 if(skb_out && skb_tailroom(skb_out) > 0) \
475 *(skb_put(skb_out, 1)) = (unsigned char)(accm >> 24); \ 476 *(skb_put(skb_out,1)) = (unsigned char) (accm>>24); \
476 accm <<= 8; \ 477 accm <<= 8; \
477 bitno += 8; \ 478 bitno += 8; \
478 } while (bitno <= 24); \ 479 } while (bitno <= 24); \
479 } 480 }
480 481
481 /* 482 /*
482 * If the protocol is not in the range we're interested in, 483 * If the protocol is not in the range we're interested in,
483 * just return without compressing the packet. If it is, 484 * just return without compressing the packet. If it is,
484 * the protocol becomes the first byte to compress. 485 * the protocol becomes the first byte to compress.
485 */ 486 */
486 printk(KERN_DEBUG "bsd_compress called with %x\n", proto); 487 printk(KERN_DEBUG "bsd_compress called with %x\n",proto);
487 488
488 ent = proto; 489 ent = proto;
489 if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1)) 490 if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1) )
490 return 0; 491 return 0;
491 492
492 db = (struct bsd_db *) state; 493 db = (struct bsd_db *) state;
@@ -495,25 +496,25 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
495 n_bits = db->n_bits; 496 n_bits = db->n_bits;
496 bitno = 32; 497 bitno = 32;
497 accm = 0; 498 accm = 0;
498 mxcode = MAXCODE(n_bits); 499 mxcode = MAXCODE (n_bits);
499 500
500 /* This is the PPP header information */ 501 /* This is the PPP header information */
501 if (skb_out && skb_tailroom(skb_out) >= 2) { 502 if(skb_out && skb_tailroom(skb_out) >= 2) {
502 char *v = skb_put(skb_out, 2); 503 char *v = skb_put(skb_out,2);
503 /* we only push our own data on the header, 504 /* we only push our own data on the header,
504 AC,PC and protos is pushed by caller */ 505 AC,PC and protos is pushed by caller */
505 v[0] = db->seqno >> 8; 506 v[0] = db->seqno >> 8;
506 v[1] = db->seqno; 507 v[1] = db->seqno;
507 } 508 }
508 509
509 ilen = ++isize; /* This is off by one, but that is what is in draft! */ 510 ilen = ++isize; /* This is off by one, but that is what is in draft! */
510 511
511 while (--ilen > 0) { 512 while (--ilen > 0) {
512 c = *rptr++; 513 c = *rptr++;
513 fcode = BSD_KEY(ent, c); 514 fcode = BSD_KEY (ent, c);
514 hval = BSD_HASH(ent, c, hshift); 515 hval = BSD_HASH (ent, c, hshift);
515 dictp = dict_ptr(db, hval); 516 dictp = dict_ptr (db, hval);
516 517
517 /* Validate and then check the entry. */ 518 /* Validate and then check the entry. */
518 if (dictp->codem1 >= max_ent) 519 if (dictp->codem1 >= max_ent)
519 goto nomatch; 520 goto nomatch;
@@ -522,7 +523,7 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
522 ent = dictp->codem1 + 1; 523 ent = dictp->codem1 + 1;
523 continue; /* found (prefix,suffix) */ 524 continue; /* found (prefix,suffix) */
524 } 525 }
525 526
526 /* continue probing until a match or invalid entry */ 527 /* continue probing until a match or invalid entry */
527 disp = (hval == 0) ? 1 : hval; 528 disp = (hval == 0) ? 1 : hval;
528 529
@@ -530,17 +531,17 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
530 hval += disp; 531 hval += disp;
531 if (hval >= db->hsize) 532 if (hval >= db->hsize)
532 hval -= db->hsize; 533 hval -= db->hsize;
533 dictp = dict_ptr(db, hval); 534 dictp = dict_ptr (db, hval);
534 if (dictp->codem1 >= max_ent) 535 if (dictp->codem1 >= max_ent)
535 goto nomatch; 536 goto nomatch;
536 } while (dictp->fcode != fcode); 537 } while (dictp->fcode != fcode);
537 538
538 ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */ 539 ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */
539 continue; 540 continue;
540 541
541 nomatch: 542nomatch:
542 OUTPUT(ent); /* output the prefix */ 543 OUTPUT(ent); /* output the prefix */
543 544
544 /* code -> hashtable */ 545 /* code -> hashtable */
545 if (max_ent < db->maxmaxcode) { 546 if (max_ent < db->maxmaxcode) {
546 struct bsd_dict *dictp2; 547 struct bsd_dict *dictp2;
@@ -550,16 +551,16 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
550 /* expand code size if needed */ 551 /* expand code size if needed */
551 if (max_ent >= mxcode) { 552 if (max_ent >= mxcode) {
552 db->n_bits = ++n_bits; 553 db->n_bits = ++n_bits;
553 mxcode = MAXCODE(n_bits); 554 mxcode = MAXCODE (n_bits);
554 } 555 }
555 556
556 /* 557 /*
557 * Invalidate old hash table entry using 558 * Invalidate old hash table entry using
558 * this code, and then take it over. 559 * this code, and then take it over.
559 */ 560 */
560 dictp2 = dict_ptr(db, max_ent + 1); 561 dictp2 = dict_ptr (db, max_ent + 1);
561 indx = dictp2->cptr; 562 indx = dictp2->cptr;
562 dictp3 = dict_ptr(db, indx); 563 dictp3 = dict_ptr (db, indx);
563 564
564 if (dictp3->codem1 == max_ent) 565 if (dictp3->codem1 == max_ent)
565 dictp3->codem1 = BADCODEM1; 566 dictp3->codem1 = BADCODEM1;
@@ -570,17 +571,17 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
570 db->max_ent = ++max_ent; 571 db->max_ent = ++max_ent;
571 572
572 if (db->lens) { 573 if (db->lens) {
573 unsigned short *len1 = lens_ptr(db, max_ent); 574 unsigned short *len1 = lens_ptr (db, max_ent);
574 unsigned short *len2 = lens_ptr(db, ent); 575 unsigned short *len2 = lens_ptr (db, ent);
575 *len1 = *len2 + 1; 576 *len1 = *len2 + 1;
576 } 577 }
577 } 578 }
578 ent = c; 579 ent = c;
579 } 580 }
580 581
581 OUTPUT(ent); /* output the last code */ 582 OUTPUT(ent); /* output the last code */
582 583
583 if (skb_out) 584 if(skb_out)
584 db->bytes_out += skb_out->len; /* Do not count bytes from here */ 585 db->bytes_out += skb_out->len; /* Do not count bytes from here */
585 db->uncomp_bytes += isize; 586 db->uncomp_bytes += isize;
586 db->in_count += isize; 587 db->in_count += isize;
@@ -595,15 +596,15 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
595 */ 596 */
596 597
597 if (bsd_check(db)) 598 if (bsd_check(db))
598 OUTPUT(CLEAR); 599 OUTPUT (CLEAR);
599 600
600 /* 601 /*
601 * Pad dribble bits of last code with ones. 602 * Pad dribble bits of last code with ones.
602 * Do not emit a completely useless byte of ones. 603 * Do not emit a completely useless byte of ones.
603 */ 604 */
604 if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0) 605 if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0)
605 *(skb_put(skb_out, 1)) = (unsigned char)((accm | (0xff << (bitno - 8))) >> 24); 606 *(skb_put(skb_out,1)) = (unsigned char) ((accm | (0xff << (bitno-8))) >> 24);
606 607
607 /* 608 /*
608 * Increase code size if we would have without the packet 609 * Increase code size if we would have without the packet
609 * boundary because the decompressor will do so. 610 * boundary because the decompressor will do so.
@@ -612,7 +613,7 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
612 db->n_bits++; 613 db->n_bits++;
613 614
614 /* If output length is too large then this is an incompressible frame. */ 615 /* If output length is too large then this is an incompressible frame. */
615 if (!skb_out || skb_out->len >= skb_in->len) { 616 if (!skb_out || (skb_out && skb_out->len >= skb_in->len) ) {
616 ++db->incomp_count; 617 ++db->incomp_count;
617 db->incomp_bytes += isize; 618 db->incomp_bytes += isize;
618 return 0; 619 return 0;
@@ -630,16 +631,16 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
630 * Update the "BSD Compress" dictionary on the receiver for 631 * Update the "BSD Compress" dictionary on the receiver for
631 * incompressible data by pretending to compress the incoming data. 632 * incompressible data by pretending to compress the incoming data.
632 */ 633 */
633static void bsd_incomp(void *state, struct sk_buff *skb_in, int proto) 634static void bsd_incomp (void *state, struct sk_buff *skb_in,int proto)
634{ 635{
635 bsd_compress(state, skb_in, NULL, proto); 636 bsd_compress (state, skb_in, NULL, proto);
636} 637}
637 638
638/* 639/*
639 * Decompress "BSD Compress". 640 * Decompress "BSD Compress".
640 */ 641 */
641static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, 642static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,
642 struct isdn_ppp_resetparams *rsparm) 643 struct isdn_ppp_resetparams *rsparm)
643{ 644{
644 struct bsd_db *db; 645 struct bsd_db *db;
645 unsigned int max_ent; 646 unsigned int max_ent;
@@ -652,7 +653,7 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
652 unsigned int incode; 653 unsigned int incode;
653 unsigned int oldcode; 654 unsigned int oldcode;
654 unsigned int finchar; 655 unsigned int finchar;
655 unsigned char *p, *ibuf; 656 unsigned char *p,*ibuf;
656 int ilen; 657 int ilen;
657 int codelen; 658 int codelen;
658 int extra; 659 int extra;
@@ -666,20 +667,20 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
666 667
667 printk(KERN_DEBUG "bsd_decompress called\n"); 668 printk(KERN_DEBUG "bsd_decompress called\n");
668 669
669 if (!skb_in || !skb_out) { 670 if(!skb_in || !skb_out) {
670 printk(KERN_ERR "bsd_decompress called with NULL parameter\n"); 671 printk(KERN_ERR "bsd_decompress called with NULL parameter\n");
671 return DECOMP_ERROR; 672 return DECOMP_ERROR;
672 } 673 }
673 674
674 /* 675 /*
675 * Get the sequence number. 676 * Get the sequence number.
676 */ 677 */
677 if ((p = skb_pull(skb_in, 2)) == NULL) { 678 if( (p = skb_pull(skb_in,2)) == NULL) {
678 return DECOMP_ERROR; 679 return DECOMP_ERROR;
679 } 680 }
680 p -= 2; 681 p-=2;
681 seq = (p[0] << 8) + p[1]; 682 seq = (p[0] << 8) + p[1];
682 ilen = skb_in->len; 683 ilen = skb_in->len;
683 ibuf = skb_in->data; 684 ibuf = skb_in->data;
684 685
685 /* 686 /*
@@ -689,7 +690,7 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
689 if (seq != db->seqno) { 690 if (seq != db->seqno) {
690 if (db->debug) { 691 if (db->debug) {
691 printk(KERN_DEBUG "bsd_decomp%d: bad sequence # %d, expected %d\n", 692 printk(KERN_DEBUG "bsd_decomp%d: bad sequence # %d, expected %d\n",
692 db->unit, seq, db->seqno - 1); 693 db->unit, seq, db->seqno - 1);
693 } 694 }
694 return DECOMP_ERROR; 695 return DECOMP_ERROR;
695 } 696 }
@@ -697,11 +698,11 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
697 ++db->seqno; 698 ++db->seqno;
698 db->bytes_out += ilen; 699 db->bytes_out += ilen;
699 700
700 if (skb_tailroom(skb_out) > 0) 701 if(skb_tailroom(skb_out) > 0)
701 *(skb_put(skb_out, 1)) = 0; 702 *(skb_put(skb_out,1)) = 0;
702 else 703 else
703 return DECOMP_ERR_NOMEM; 704 return DECOMP_ERR_NOMEM;
704 705
705 oldcode = CLEAR; 706 oldcode = CLEAR;
706 707
707 /* 708 /*
@@ -733,7 +734,7 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
733 /* 734 /*
734 * The dictionary must only be cleared at the end of a packet. 735 * The dictionary must only be cleared at the end of a packet.
735 */ 736 */
736 737
737 if (incode == CLEAR) { 738 if (incode == CLEAR) {
738 if (ilen > 0) { 739 if (ilen > 0) {
739 if (db->debug) 740 if (db->debug)
@@ -745,16 +746,16 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
745 } 746 }
746 747
747 if ((incode > max_ent + 2) || (incode > db->maxmaxcode) 748 if ((incode > max_ent + 2) || (incode > db->maxmaxcode)
748 || (incode > max_ent && oldcode == CLEAR)) { 749 || (incode > max_ent && oldcode == CLEAR)) {
749 if (db->debug) { 750 if (db->debug) {
750 printk(KERN_DEBUG "bsd_decomp%d: bad code 0x%x oldcode=0x%x ", 751 printk(KERN_DEBUG "bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
751 db->unit, incode, oldcode); 752 db->unit, incode, oldcode);
752 printk(KERN_DEBUG "max_ent=0x%x skb->Len=%d seqno=%d\n", 753 printk(KERN_DEBUG "max_ent=0x%x skb->Len=%d seqno=%d\n",
753 max_ent, skb_out->len, db->seqno); 754 max_ent, skb_out->len, db->seqno);
754 } 755 }
755 return DECOMP_FATALERROR; /* probably a bug */ 756 return DECOMP_FATALERROR; /* probably a bug */
756 } 757 }
757 758
758 /* Special case for KwKwK string. */ 759 /* Special case for KwKwK string. */
759 if (incode > max_ent) { 760 if (incode > max_ent) {
760 finchar = oldcode; 761 finchar = oldcode;
@@ -764,13 +765,13 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
764 extra = 0; 765 extra = 0;
765 } 766 }
766 767
767 codelen = *(lens_ptr(db, finchar)); 768 codelen = *(lens_ptr (db, finchar));
768 if (skb_tailroom(skb_out) < codelen + extra) { 769 if( skb_tailroom(skb_out) < codelen + extra) {
769 if (db->debug) { 770 if (db->debug) {
770 printk(KERN_DEBUG "bsd_decomp%d: ran out of mru\n", db->unit); 771 printk(KERN_DEBUG "bsd_decomp%d: ran out of mru\n", db->unit);
771#ifdef DEBUG 772#ifdef DEBUG
772 printk(KERN_DEBUG " len=%d, finchar=0x%x, codelen=%d,skblen=%d\n", 773 printk(KERN_DEBUG " len=%d, finchar=0x%x, codelen=%d,skblen=%d\n",
773 ilen, finchar, codelen, skb_out->len); 774 ilen, finchar, codelen, skb_out->len);
774#endif 775#endif
775 } 776 }
776 return DECOMP_FATALERROR; 777 return DECOMP_FATALERROR;
@@ -780,21 +781,21 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
780 * Decode this code and install it in the decompressed buffer. 781 * Decode this code and install it in the decompressed buffer.
781 */ 782 */
782 783
783 p = skb_put(skb_out, codelen); 784 p = skb_put(skb_out,codelen);
784 p += codelen; 785 p += codelen;
785 while (finchar > LAST) { 786 while (finchar > LAST) {
786 struct bsd_dict *dictp2 = dict_ptr(db, finchar); 787 struct bsd_dict *dictp2 = dict_ptr (db, finchar);
787 788
788 dictp = dict_ptr(db, dictp2->cptr); 789 dictp = dict_ptr (db, dictp2->cptr);
789 790
790#ifdef DEBUG 791#ifdef DEBUG
791 if (--codelen <= 0 || dictp->codem1 != finchar - 1) { 792 if (--codelen <= 0 || dictp->codem1 != finchar-1) {
792 if (codelen <= 0) { 793 if (codelen <= 0) {
793 printk(KERN_ERR "bsd_decomp%d: fell off end of chain ", db->unit); 794 printk(KERN_ERR "bsd_decomp%d: fell off end of chain ", db->unit);
794 printk(KERN_ERR "0x%x at 0x%x by 0x%x, max_ent=0x%x\n", incode, finchar, dictp2->cptr, max_ent); 795 printk(KERN_ERR "0x%x at 0x%x by 0x%x, max_ent=0x%x\n", incode, finchar, dictp2->cptr, max_ent);
795 } else { 796 } else {
796 if (dictp->codem1 != finchar - 1) { 797 if (dictp->codem1 != finchar-1) {
797 printk(KERN_ERR "bsd_decomp%d: bad code chain 0x%x finchar=0x%x ", db->unit, incode, finchar); 798 printk(KERN_ERR "bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",db->unit, incode, finchar);
798 printk(KERN_ERR "oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode, dictp2->cptr, dictp->codem1); 799 printk(KERN_ERR "oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode, dictp2->cptr, dictp->codem1);
799 } 800 }
800 } 801 }
@@ -809,15 +810,15 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
809 } 810 }
810 } 811 }
811 *--p = finchar; 812 *--p = finchar;
812 813
813#ifdef DEBUG 814#ifdef DEBUG
814 if (--codelen != 0) 815 if (--codelen != 0)
815 printk(KERN_ERR "bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n", db->unit, codelen, incode, max_ent); 816 printk(KERN_ERR "bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n", db->unit, codelen, incode, max_ent);
816#endif 817#endif
817 818
818 if (extra) /* the KwKwK case again */ 819 if (extra) /* the KwKwK case again */
819 *(skb_put(skb_out, 1)) = finchar; 820 *(skb_put(skb_out,1)) = finchar;
820 821
821 /* 822 /*
822 * If not first code in a packet, and 823 * If not first code in a packet, and
823 * if not out of code space, then allocate a new code. 824 * if not out of code space, then allocate a new code.
@@ -827,14 +828,14 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
827 */ 828 */
828 if (oldcode != CLEAR && max_ent < db->maxmaxcode) { 829 if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
829 struct bsd_dict *dictp2, *dictp3; 830 struct bsd_dict *dictp2, *dictp3;
830 u16 *lens1, *lens2; 831 u16 *lens1, *lens2;
831 unsigned long fcode; 832 unsigned long fcode;
832 int hval, disp, indx; 833 int hval, disp, indx;
833 834
834 fcode = BSD_KEY(oldcode, finchar); 835 fcode = BSD_KEY(oldcode,finchar);
835 hval = BSD_HASH(oldcode, finchar, db->hshift); 836 hval = BSD_HASH(oldcode,finchar,db->hshift);
836 dictp = dict_ptr(db, hval); 837 dictp = dict_ptr (db, hval);
837 838
838 /* look for a free hash table entry */ 839 /* look for a free hash table entry */
839 if (dictp->codem1 < max_ent) { 840 if (dictp->codem1 < max_ent) {
840 disp = (hval == 0) ? 1 : hval; 841 disp = (hval == 0) ? 1 : hval;
@@ -842,18 +843,18 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
842 hval += disp; 843 hval += disp;
843 if (hval >= db->hsize) 844 if (hval >= db->hsize)
844 hval -= db->hsize; 845 hval -= db->hsize;
845 dictp = dict_ptr(db, hval); 846 dictp = dict_ptr (db, hval);
846 } while (dictp->codem1 < max_ent); 847 } while (dictp->codem1 < max_ent);
847 } 848 }
848 849
849 /* 850 /*
850 * Invalidate previous hash table entry 851 * Invalidate previous hash table entry
851 * assigned this code, and then take it over 852 * assigned this code, and then take it over
852 */ 853 */
853 854
854 dictp2 = dict_ptr(db, max_ent + 1); 855 dictp2 = dict_ptr (db, max_ent + 1);
855 indx = dictp2->cptr; 856 indx = dictp2->cptr;
856 dictp3 = dict_ptr(db, indx); 857 dictp3 = dict_ptr (db, indx);
857 858
858 if (dictp3->codem1 == max_ent) 859 if (dictp3->codem1 == max_ent)
859 dictp3->codem1 = BADCODEM1; 860 dictp3->codem1 = BADCODEM1;
@@ -864,10 +865,10 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
864 db->max_ent = ++max_ent; 865 db->max_ent = ++max_ent;
865 866
866 /* Update the length of this string. */ 867 /* Update the length of this string. */
867 lens1 = lens_ptr(db, max_ent); 868 lens1 = lens_ptr (db, max_ent);
868 lens2 = lens_ptr(db, oldcode); 869 lens2 = lens_ptr (db, oldcode);
869 *lens1 = *lens2 + 1; 870 *lens1 = *lens2 + 1;
870 871
871 /* Expand code size if needed. */ 872 /* Expand code size if needed. */
872 if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) { 873 if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
873 db->n_bits = ++n_bits; 874 db->n_bits = ++n_bits;
@@ -885,7 +886,7 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
885 if (bsd_check(db)) { 886 if (bsd_check(db)) {
886 if (db->debug) 887 if (db->debug)
887 printk(KERN_DEBUG "bsd_decomp%d: peer should have cleared dictionary on %d\n", 888 printk(KERN_DEBUG "bsd_decomp%d: peer should have cleared dictionary on %d\n",
888 db->unit, db->seqno - 1); 889 db->unit, db->seqno - 1);
889 } 890 }
890 return skb_out->len; 891 return skb_out->len;
891} 892}
@@ -913,15 +914,15 @@ static struct isdn_ppp_compressor ippp_bsd_compress = {
913 914
914static int __init isdn_bsdcomp_init(void) 915static int __init isdn_bsdcomp_init(void)
915{ 916{
916 int answer = isdn_ppp_register_compressor(&ippp_bsd_compress); 917 int answer = isdn_ppp_register_compressor (&ippp_bsd_compress);
917 if (answer == 0) 918 if (answer == 0)
918 printk(KERN_INFO "PPP BSD Compression module registered\n"); 919 printk (KERN_INFO "PPP BSD Compression module registered\n");
919 return answer; 920 return answer;
920} 921}
921 922
922static void __exit isdn_bsdcomp_exit(void) 923static void __exit isdn_bsdcomp_exit(void)
923{ 924{
924 isdn_ppp_unregister_compressor(&ippp_bsd_compress); 925 isdn_ppp_unregister_compressor (&ippp_bsd_compress);
925} 926}
926 927
927module_init(isdn_bsdcomp_init); 928module_init(isdn_bsdcomp_init);
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index e2a945ee9f0..6ed82add6ff 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -46,6 +46,7 @@ static DEFINE_MUTEX(isdn_mutex);
46static char *isdn_revision = "$Revision: 1.1.2.3 $"; 46static char *isdn_revision = "$Revision: 1.1.2.3 $";
47 47
48extern char *isdn_net_revision; 48extern char *isdn_net_revision;
49extern char *isdn_tty_revision;
49#ifdef CONFIG_ISDN_PPP 50#ifdef CONFIG_ISDN_PPP
50extern char *isdn_ppp_revision; 51extern char *isdn_ppp_revision;
51#else 52#else
@@ -110,7 +111,7 @@ isdn_unlock_drivers(void)
110 111
111#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) 112#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP)
112void 113void
113isdn_dumppkt(char *s, u_char *p, int len, int dumplen) 114isdn_dumppkt(char *s, u_char * p, int len, int dumplen)
114{ 115{
115 int dumpc; 116 int dumpc;
116 117
@@ -162,58 +163,58 @@ isdn_wildmat(char *s, char *p)
162 register int nostar = 1; 163 register int nostar = 1;
163 164
164 if (!(*s) && !(*p)) 165 if (!(*s) && !(*p))
165 return (1); 166 return(1);
166 for (; *p; s++, p++) 167 for (; *p; s++, p++)
167 switch (*p) { 168 switch (*p) {
168 case '\\': 169 case '\\':
169 /* 170 /*
170 * Literal match with following character, 171 * Literal match with following character,
171 * fall through. 172 * fall through.
172 */ 173 */
173 p++;
174 default:
175 if (*s != *p)
176 return (*s == '\0') ? 2 : 1;
177 continue;
178 case '?':
179 /* Match anything. */
180 if (*s == '\0')
181 return (2);
182 continue;
183 case '*':
184 nostar = 0;
185 /* Trailing star matches everything. */
186 return (*++p ? isdn_star(s, p) : 0);
187 case '[':
188 /* [^....] means inverse character class. */
189 if ((reverse = (p[1] == '^')))
190 p++; 174 p++;
191 for (last = 0, matched = 0; *++p && (*p != ']'); last = *p) 175 default:
192 /* This next line requires a good C compiler. */ 176 if (*s != *p)
193 if (*p == '-' ? *s <= *++p && *s >= last : *s == *p) 177 return (*s == '\0')?2:1;
194 matched = 1; 178 continue;
195 if (matched == reverse) 179 case '?':
196 return (1); 180 /* Match anything. */
197 continue; 181 if (*s == '\0')
182 return (2);
183 continue;
184 case '*':
185 nostar = 0;
186 /* Trailing star matches everything. */
187 return (*++p ? isdn_star(s, p) : 0);
188 case '[':
189 /* [^....] means inverse character class. */
190 if ((reverse = (p[1] == '^')))
191 p++;
192 for (last = 0, matched = 0; *++p && (*p != ']'); last = *p)
193 /* This next line requires a good C compiler. */
194 if (*p == '-' ? *s <= *++p && *s >= last : *s == *p)
195 matched = 1;
196 if (matched == reverse)
197 return (1);
198 continue;
198 } 199 }
199 return (*s == '\0') ? 0 : nostar; 200 return (*s == '\0')?0:nostar;
200} 201}
201 202
202int isdn_msncmp(const char *msn1, const char *msn2) 203int isdn_msncmp( const char * msn1, const char * msn2 )
203{ 204{
204 char TmpMsn1[ISDN_MSNLEN]; 205 char TmpMsn1[ ISDN_MSNLEN ];
205 char TmpMsn2[ISDN_MSNLEN]; 206 char TmpMsn2[ ISDN_MSNLEN ];
206 char *p; 207 char *p;
207 208
208 for (p = TmpMsn1; *msn1 && *msn1 != ':';) // Strip off a SPID 209 for ( p = TmpMsn1; *msn1 && *msn1 != ':'; ) // Strip off a SPID
209 *p++ = *msn1++; 210 *p++ = *msn1++;
210 *p = '\0'; 211 *p = '\0';
211 212
212 for (p = TmpMsn2; *msn2 && *msn2 != ':';) // Strip off a SPID 213 for ( p = TmpMsn2; *msn2 && *msn2 != ':'; ) // Strip off a SPID
213 *p++ = *msn2++; 214 *p++ = *msn2++;
214 *p = '\0'; 215 *p = '\0';
215 216
216 return isdn_wildmat(TmpMsn1, TmpMsn2); 217 return isdn_wildmat( TmpMsn1, TmpMsn2 );
217} 218}
218 219
219int 220int
@@ -261,8 +262,8 @@ isdn_timer_funct(ulong dummy)
261 isdn_tty_carrier_timeout(); 262 isdn_tty_carrier_timeout();
262 } 263 }
263 } 264 }
264 if (tf) 265 if (tf)
265 mod_timer(&dev->timer, jiffies + ISDN_TIMER_RES); 266 mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES);
266} 267}
267 268
268void 269void
@@ -283,7 +284,7 @@ isdn_timer_ctrl(int tf, int onoff)
283 else 284 else
284 dev->tflags &= ~tf; 285 dev->tflags &= ~tf;
285 if (dev->tflags && !old_tflags) 286 if (dev->tflags && !old_tflags)
286 mod_timer(&dev->timer, jiffies + ISDN_TIMER_RES); 287 mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES);
287 spin_unlock_irqrestore(&dev->timerlock, flags); 288 spin_unlock_irqrestore(&dev->timerlock, flags);
288} 289}
289 290
@@ -301,7 +302,7 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb)
301 } 302 }
302 /* Update statistics */ 303 /* Update statistics */
303 dev->ibytes[i] += skb->len; 304 dev->ibytes[i] += skb->len;
304 305
305 /* First, try to deliver data to network-device */ 306 /* First, try to deliver data to network-device */
306 if (isdn_net_rcv_skb(i, skb)) 307 if (isdn_net_rcv_skb(i, skb))
307 return; 308 return;
@@ -338,40 +339,40 @@ isdn_command(isdn_ctrl *cmd)
338{ 339{
339 if (cmd->driver == -1) { 340 if (cmd->driver == -1) {
340 printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command); 341 printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command);
341 return (1); 342 return(1);
342 } 343 }
343 if (!dev->drv[cmd->driver]) { 344 if (!dev->drv[cmd->driver]) {
344 printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d] NULL\n", 345 printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d] NULL\n",
345 cmd->command, cmd->driver); 346 cmd->command, cmd->driver);
346 return (1); 347 return(1);
347 } 348 }
348 if (!dev->drv[cmd->driver]->interface) { 349 if (!dev->drv[cmd->driver]->interface) {
349 printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d]->interface NULL\n", 350 printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d]->interface NULL\n",
350 cmd->command, cmd->driver); 351 cmd->command, cmd->driver);
351 return (1); 352 return(1);
352 } 353 }
353 if (cmd->command == ISDN_CMD_SETL2) { 354 if (cmd->command == ISDN_CMD_SETL2) {
354 int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255); 355 int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255);
355 unsigned long l2prot = (cmd->arg >> 8) & 255; 356 unsigned long l2prot = (cmd->arg >> 8) & 255;
356 unsigned long features = (dev->drv[cmd->driver]->interface->features 357 unsigned long features = (dev->drv[cmd->driver]->interface->features
357 >> ISDN_FEATURE_L2_SHIFT) & 358 >> ISDN_FEATURE_L2_SHIFT) &
358 ISDN_FEATURE_L2_MASK; 359 ISDN_FEATURE_L2_MASK;
359 unsigned long l2_feature = (1 << l2prot); 360 unsigned long l2_feature = (1 << l2prot);
360 361
361 switch (l2prot) { 362 switch (l2prot) {
362 case ISDN_PROTO_L2_V11096: 363 case ISDN_PROTO_L2_V11096:
363 case ISDN_PROTO_L2_V11019: 364 case ISDN_PROTO_L2_V11019:
364 case ISDN_PROTO_L2_V11038: 365 case ISDN_PROTO_L2_V11038:
365 /* If V.110 requested, but not supported by 366 /* If V.110 requested, but not supported by
366 * HL-driver, set emulator-flag and change 367 * HL-driver, set emulator-flag and change
367 * Layer-2 to transparent 368 * Layer-2 to transparent
368 */ 369 */
369 if (!(features & l2_feature)) { 370 if (!(features & l2_feature)) {
370 dev->v110emu[idx] = l2prot; 371 dev->v110emu[idx] = l2prot;
371 cmd->arg = (cmd->arg & 255) | 372 cmd->arg = (cmd->arg & 255) |
372 (ISDN_PROTO_L2_TRANS << 8); 373 (ISDN_PROTO_L2_TRANS << 8);
373 } else 374 } else
374 dev->v110emu[idx] = 0; 375 dev->v110emu[idx] = 0;
375 } 376 }
376 } 377 }
377 return dev->drv[cmd->driver]->interface->command(cmd); 378 return dev->drv[cmd->driver]->interface->command(cmd);
@@ -392,7 +393,7 @@ isdn_all_eaz(int di, int ch)
392} 393}
393 394
394/* 395/*
395 * Begin of a CAPI like LL<->HL interface, currently used only for 396 * Begin of a CAPI like LL<->HL interface, currently used only for
396 * supplementary service (CAPI 2.0 part III) 397 * supplementary service (CAPI 2.0 part III)
397 */ 398 */
398#include <linux/isdn/capicmd.h> 399#include <linux/isdn/capicmd.h>
@@ -400,17 +401,17 @@ isdn_all_eaz(int di, int ch)
400static int 401static int
401isdn_capi_rec_hl_msg(capi_msg *cm) 402isdn_capi_rec_hl_msg(capi_msg *cm)
402{ 403{
403 switch (cm->Command) { 404 switch(cm->Command) {
404 case CAPI_FACILITY: 405 case CAPI_FACILITY:
405 /* in the moment only handled in tty */ 406 /* in the moment only handled in tty */
406 return (isdn_tty_capi_facility(cm)); 407 return(isdn_tty_capi_facility(cm));
407 default: 408 default:
408 return (-1); 409 return(-1);
409 } 410 }
410} 411}
411 412
412static int 413static int
413isdn_status_callback(isdn_ctrl *c) 414isdn_status_callback(isdn_ctrl * c)
414{ 415{
415 int di; 416 int di;
416 u_long flags; 417 u_long flags;
@@ -423,314 +424,314 @@ isdn_status_callback(isdn_ctrl *c)
423 di = c->driver; 424 di = c->driver;
424 i = isdn_dc2minor(di, c->arg); 425 i = isdn_dc2minor(di, c->arg);
425 switch (c->command) { 426 switch (c->command) {
426 case ISDN_STAT_BSENT: 427 case ISDN_STAT_BSENT:
427 if (i < 0) 428 if (i < 0)
428 return -1; 429 return -1;
429 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 430 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
430 return 0; 431 return 0;
431 if (isdn_net_stat_callback(i, c)) 432 if (isdn_net_stat_callback(i, c))
432 return 0; 433 return 0;
433 if (isdn_v110_stat_callback(i, c)) 434 if (isdn_v110_stat_callback(i, c))
434 return 0; 435 return 0;
435 if (isdn_tty_stat_callback(i, c)) 436 if (isdn_tty_stat_callback(i, c))
436 return 0; 437 return 0;
437 wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]); 438 wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]);
438 break; 439 break;
439 case ISDN_STAT_STAVAIL: 440 case ISDN_STAT_STAVAIL:
440 dev->drv[di]->stavail += c->arg; 441 dev->drv[di]->stavail += c->arg;
441 wake_up_interruptible(&dev->drv[di]->st_waitq); 442 wake_up_interruptible(&dev->drv[di]->st_waitq);
442 break; 443 break;
443 case ISDN_STAT_RUN: 444 case ISDN_STAT_RUN:
444 dev->drv[di]->flags |= DRV_FLAG_RUNNING; 445 dev->drv[di]->flags |= DRV_FLAG_RUNNING;
445 for (i = 0; i < ISDN_MAX_CHANNELS; i++) 446 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
446 if (dev->drvmap[i] == di) 447 if (dev->drvmap[i] == di)
447 isdn_all_eaz(di, dev->chanmap[i]); 448 isdn_all_eaz(di, dev->chanmap[i]);
448 set_global_features(); 449 set_global_features();
449 break; 450 break;
450 case ISDN_STAT_STOP: 451 case ISDN_STAT_STOP:
451 dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; 452 dev->drv[di]->flags &= ~DRV_FLAG_RUNNING;
452 break; 453 break;
453 case ISDN_STAT_ICALL: 454 case ISDN_STAT_ICALL:
454 if (i < 0) 455 if (i < 0)
455 return -1; 456 return -1;
456#ifdef ISDN_DEBUG_STATCALLB 457#ifdef ISDN_DEBUG_STATCALLB
457 printk(KERN_DEBUG "ICALL (net): %d %ld %s\n", di, c->arg, c->parm.num); 458 printk(KERN_DEBUG "ICALL (net): %d %ld %s\n", di, c->arg, c->parm.num);
458#endif 459#endif
459 if (dev->global_flags & ISDN_GLOBAL_STOPPED) { 460 if (dev->global_flags & ISDN_GLOBAL_STOPPED) {
460 cmd.driver = di;
461 cmd.arg = c->arg;
462 cmd.command = ISDN_CMD_HANGUP;
463 isdn_command(&cmd);
464 return 0;
465 }
466 /* Try to find a network-interface which will accept incoming call */
467 r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup));
468 switch (r) {
469 case 0:
470 /* No network-device replies.
471 * Try ttyI's.
472 * These return 0 on no match, 1 on match and
473 * 3 on eventually match, if CID is longer.
474 */
475 if (c->command == ISDN_STAT_ICALL)
476 if ((retval = isdn_tty_find_icall(di, c->arg, &c->parm.setup))) return (retval);
477#ifdef CONFIG_ISDN_DIVERSION
478 if (divert_if)
479 if ((retval = divert_if->stat_callback(c)))
480 return (retval); /* processed */
481#endif /* CONFIG_ISDN_DIVERSION */
482 if ((!retval) && (dev->drv[di]->flags & DRV_FLAG_REJBUS)) {
483 /* No tty responding */
484 cmd.driver = di; 461 cmd.driver = di;
485 cmd.arg = c->arg; 462 cmd.arg = c->arg;
486 cmd.command = ISDN_CMD_HANGUP; 463 cmd.command = ISDN_CMD_HANGUP;
487 isdn_command(&cmd); 464 isdn_command(&cmd);
488 retval = 2; 465 return 0;
489 } 466 }
490 break; 467 /* Try to find a network-interface which will accept incoming call */
491 case 1: 468 r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup));
492 /* Schedule connection-setup */ 469 switch (r) {
493 isdn_net_dial(); 470 case 0:
494 cmd.driver = di; 471 /* No network-device replies.
495 cmd.arg = c->arg; 472 * Try ttyI's.
496 cmd.command = ISDN_CMD_ACCEPTD; 473 * These return 0 on no match, 1 on match and
497 for (p = dev->netdev; p; p = p->next) 474 * 3 on eventually match, if CID is longer.
498 if (p->local->isdn_channel == cmd.arg) 475 */
499 { 476 if (c->command == ISDN_STAT_ICALL)
500 strcpy(cmd.parm.setup.eazmsn, p->local->msn); 477 if ((retval = isdn_tty_find_icall(di, c->arg, &c->parm.setup))) return(retval);
501 isdn_command(&cmd); 478#ifdef CONFIG_ISDN_DIVERSION
502 retval = 1; 479 if (divert_if)
480 if ((retval = divert_if->stat_callback(c)))
481 return(retval); /* processed */
482#endif /* CONFIG_ISDN_DIVERSION */
483 if ((!retval) && (dev->drv[di]->flags & DRV_FLAG_REJBUS)) {
484 /* No tty responding */
485 cmd.driver = di;
486 cmd.arg = c->arg;
487 cmd.command = ISDN_CMD_HANGUP;
488 isdn_command(&cmd);
489 retval = 2;
490 }
491 break;
492 case 1:
493 /* Schedule connection-setup */
494 isdn_net_dial();
495 cmd.driver = di;
496 cmd.arg = c->arg;
497 cmd.command = ISDN_CMD_ACCEPTD;
498 for ( p = dev->netdev; p; p = p->next )
499 if ( p->local->isdn_channel == cmd.arg )
500 {
501 strcpy( cmd.parm.setup.eazmsn, p->local->msn );
502 isdn_command(&cmd);
503 retval = 1;
504 break;
505 }
503 break; 506 break;
504 }
505 break;
506 507
507 case 2: /* For calling back, first reject incoming call ... */ 508 case 2: /* For calling back, first reject incoming call ... */
508 case 3: /* Interface found, but down, reject call actively */ 509 case 3: /* Interface found, but down, reject call actively */
509 retval = 2; 510 retval = 2;
510 printk(KERN_INFO "isdn: Rejecting Call\n"); 511 printk(KERN_INFO "isdn: Rejecting Call\n");
511 cmd.driver = di; 512 cmd.driver = di;
512 cmd.arg = c->arg; 513 cmd.arg = c->arg;
513 cmd.command = ISDN_CMD_HANGUP; 514 cmd.command = ISDN_CMD_HANGUP;
514 isdn_command(&cmd); 515 isdn_command(&cmd);
515 if (r == 3) 516 if (r == 3)
516 break; 517 break;
517 /* Fall through */ 518 /* Fall through */
518 case 4: 519 case 4:
519 /* ... then start callback. */ 520 /* ... then start callback. */
520 isdn_net_dial(); 521 isdn_net_dial();
521 break; 522 break;
522 case 5: 523 case 5:
523 /* Number would eventually match, if longer */ 524 /* Number would eventually match, if longer */
524 retval = 3; 525 retval = 3;
525 break; 526 break;
526 } 527 }
527#ifdef ISDN_DEBUG_STATCALLB 528#ifdef ISDN_DEBUG_STATCALLB
528 printk(KERN_DEBUG "ICALL: ret=%d\n", retval); 529 printk(KERN_DEBUG "ICALL: ret=%d\n", retval);
529#endif 530#endif
530 return retval; 531 return retval;
531 break; 532 break;
532 case ISDN_STAT_CINF: 533 case ISDN_STAT_CINF:
533 if (i < 0) 534 if (i < 0)
534 return -1; 535 return -1;
535#ifdef ISDN_DEBUG_STATCALLB 536#ifdef ISDN_DEBUG_STATCALLB
536 printk(KERN_DEBUG "CINF: %ld %s\n", c->arg, c->parm.num); 537 printk(KERN_DEBUG "CINF: %ld %s\n", c->arg, c->parm.num);
537#endif 538#endif
538 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 539 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
539 return 0; 540 return 0;
540 if (strcmp(c->parm.num, "0")) 541 if (strcmp(c->parm.num, "0"))
541 isdn_net_stat_callback(i, c); 542 isdn_net_stat_callback(i, c);
542 isdn_tty_stat_callback(i, c); 543 isdn_tty_stat_callback(i, c);
543 break; 544 break;
544 case ISDN_STAT_CAUSE: 545 case ISDN_STAT_CAUSE:
545#ifdef ISDN_DEBUG_STATCALLB 546#ifdef ISDN_DEBUG_STATCALLB
546 printk(KERN_DEBUG "CAUSE: %ld %s\n", c->arg, c->parm.num); 547 printk(KERN_DEBUG "CAUSE: %ld %s\n", c->arg, c->parm.num);
547#endif 548#endif
548 printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", 549 printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n",
549 dev->drvid[di], c->arg, c->parm.num); 550 dev->drvid[di], c->arg, c->parm.num);
550 isdn_tty_stat_callback(i, c); 551 isdn_tty_stat_callback(i, c);
551#ifdef CONFIG_ISDN_DIVERSION 552#ifdef CONFIG_ISDN_DIVERSION
552 if (divert_if) 553 if (divert_if)
553 divert_if->stat_callback(c); 554 divert_if->stat_callback(c);
554#endif /* CONFIG_ISDN_DIVERSION */ 555#endif /* CONFIG_ISDN_DIVERSION */
555 break; 556 break;
556 case ISDN_STAT_DISPLAY: 557 case ISDN_STAT_DISPLAY:
557#ifdef ISDN_DEBUG_STATCALLB 558#ifdef ISDN_DEBUG_STATCALLB
558 printk(KERN_DEBUG "DISPLAY: %ld %s\n", c->arg, c->parm.display); 559 printk(KERN_DEBUG "DISPLAY: %ld %s\n", c->arg, c->parm.display);
559#endif 560#endif
560 isdn_tty_stat_callback(i, c); 561 isdn_tty_stat_callback(i, c);
561#ifdef CONFIG_ISDN_DIVERSION 562#ifdef CONFIG_ISDN_DIVERSION
562 if (divert_if) 563 if (divert_if)
563 divert_if->stat_callback(c); 564 divert_if->stat_callback(c);
564#endif /* CONFIG_ISDN_DIVERSION */ 565#endif /* CONFIG_ISDN_DIVERSION */
565 break; 566 break;
566 case ISDN_STAT_DCONN: 567 case ISDN_STAT_DCONN:
567 if (i < 0) 568 if (i < 0)
568 return -1; 569 return -1;
569#ifdef ISDN_DEBUG_STATCALLB 570#ifdef ISDN_DEBUG_STATCALLB
570 printk(KERN_DEBUG "DCONN: %ld\n", c->arg); 571 printk(KERN_DEBUG "DCONN: %ld\n", c->arg);
571#endif 572#endif
572 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 573 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
573 return 0; 574 return 0;
574 /* Find any net-device, waiting for D-channel setup */ 575 /* Find any net-device, waiting for D-channel setup */
575 if (isdn_net_stat_callback(i, c)) 576 if (isdn_net_stat_callback(i, c))
576 break; 577 break;
577 isdn_v110_stat_callback(i, c); 578 isdn_v110_stat_callback(i, c);
578 /* Find any ttyI, waiting for D-channel setup */ 579 /* Find any ttyI, waiting for D-channel setup */
579 if (isdn_tty_stat_callback(i, c)) { 580 if (isdn_tty_stat_callback(i, c)) {
580 cmd.driver = di; 581 cmd.driver = di;
581 cmd.arg = c->arg; 582 cmd.arg = c->arg;
582 cmd.command = ISDN_CMD_ACCEPTB; 583 cmd.command = ISDN_CMD_ACCEPTB;
583 isdn_command(&cmd); 584 isdn_command(&cmd);
585 break;
586 }
584 break; 587 break;
585 } 588 case ISDN_STAT_DHUP:
586 break; 589 if (i < 0)
587 case ISDN_STAT_DHUP: 590 return -1;
588 if (i < 0)
589 return -1;
590#ifdef ISDN_DEBUG_STATCALLB 591#ifdef ISDN_DEBUG_STATCALLB
591 printk(KERN_DEBUG "DHUP: %ld\n", c->arg); 592 printk(KERN_DEBUG "DHUP: %ld\n", c->arg);
592#endif 593#endif
593 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 594 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
594 return 0; 595 return 0;
595 dev->drv[di]->online &= ~(1 << (c->arg)); 596 dev->drv[di]->online &= ~(1 << (c->arg));
596 isdn_info_update(); 597 isdn_info_update();
597 /* Signal hangup to network-devices */ 598 /* Signal hangup to network-devices */
598 if (isdn_net_stat_callback(i, c)) 599 if (isdn_net_stat_callback(i, c))
599 break; 600 break;
600 isdn_v110_stat_callback(i, c); 601 isdn_v110_stat_callback(i, c);
601 if (isdn_tty_stat_callback(i, c)) 602 if (isdn_tty_stat_callback(i, c))
602 break; 603 break;
603#ifdef CONFIG_ISDN_DIVERSION 604#ifdef CONFIG_ISDN_DIVERSION
604 if (divert_if) 605 if (divert_if)
605 divert_if->stat_callback(c); 606 divert_if->stat_callback(c);
606#endif /* CONFIG_ISDN_DIVERSION */ 607#endif /* CONFIG_ISDN_DIVERSION */
607 break; 608 break;
608 break; 609 break;
609 case ISDN_STAT_BCONN: 610 case ISDN_STAT_BCONN:
610 if (i < 0) 611 if (i < 0)
611 return -1; 612 return -1;
612#ifdef ISDN_DEBUG_STATCALLB 613#ifdef ISDN_DEBUG_STATCALLB
613 printk(KERN_DEBUG "BCONN: %ld\n", c->arg); 614 printk(KERN_DEBUG "BCONN: %ld\n", c->arg);
614#endif 615#endif
615 /* Signal B-channel-connect to network-devices */ 616 /* Signal B-channel-connect to network-devices */
616 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 617 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
617 return 0; 618 return 0;
618 dev->drv[di]->online |= (1 << (c->arg)); 619 dev->drv[di]->online |= (1 << (c->arg));
619 isdn_info_update(); 620 isdn_info_update();
620 if (isdn_net_stat_callback(i, c)) 621 if (isdn_net_stat_callback(i, c))
621 break; 622 break;
622 isdn_v110_stat_callback(i, c); 623 isdn_v110_stat_callback(i, c);
623 if (isdn_tty_stat_callback(i, c)) 624 if (isdn_tty_stat_callback(i, c))
625 break;
624 break; 626 break;
625 break; 627 case ISDN_STAT_BHUP:
626 case ISDN_STAT_BHUP: 628 if (i < 0)
627 if (i < 0) 629 return -1;
628 return -1;
629#ifdef ISDN_DEBUG_STATCALLB 630#ifdef ISDN_DEBUG_STATCALLB
630 printk(KERN_DEBUG "BHUP: %ld\n", c->arg); 631 printk(KERN_DEBUG "BHUP: %ld\n", c->arg);
631#endif 632#endif
632 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 633 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
633 return 0; 634 return 0;
634 dev->drv[di]->online &= ~(1 << (c->arg)); 635 dev->drv[di]->online &= ~(1 << (c->arg));
635 isdn_info_update(); 636 isdn_info_update();
636#ifdef CONFIG_ISDN_X25 637#ifdef CONFIG_ISDN_X25
637 /* Signal hangup to network-devices */ 638 /* Signal hangup to network-devices */
638 if (isdn_net_stat_callback(i, c)) 639 if (isdn_net_stat_callback(i, c))
639 break; 640 break;
640#endif 641#endif
641 isdn_v110_stat_callback(i, c); 642 isdn_v110_stat_callback(i, c);
642 if (isdn_tty_stat_callback(i, c)) 643 if (isdn_tty_stat_callback(i, c))
644 break;
643 break; 645 break;
644 break; 646 case ISDN_STAT_NODCH:
645 case ISDN_STAT_NODCH: 647 if (i < 0)
646 if (i < 0) 648 return -1;
647 return -1;
648#ifdef ISDN_DEBUG_STATCALLB 649#ifdef ISDN_DEBUG_STATCALLB
649 printk(KERN_DEBUG "NODCH: %ld\n", c->arg); 650 printk(KERN_DEBUG "NODCH: %ld\n", c->arg);
650#endif 651#endif
651 if (dev->global_flags & ISDN_GLOBAL_STOPPED) 652 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
652 return 0; 653 return 0;
653 if (isdn_net_stat_callback(i, c)) 654 if (isdn_net_stat_callback(i, c))
655 break;
656 if (isdn_tty_stat_callback(i, c))
657 break;
654 break; 658 break;
655 if (isdn_tty_stat_callback(i, c)) 659 case ISDN_STAT_ADDCH:
660 spin_lock_irqsave(&dev->lock, flags);
661 if (isdn_add_channels(dev->drv[di], di, c->arg, 1)) {
662 spin_unlock_irqrestore(&dev->lock, flags);
663 return -1;
664 }
665 spin_unlock_irqrestore(&dev->lock, flags);
666 isdn_info_update();
656 break; 667 break;
657 break; 668 case ISDN_STAT_DISCH:
658 case ISDN_STAT_ADDCH: 669 spin_lock_irqsave(&dev->lock, flags);
659 spin_lock_irqsave(&dev->lock, flags); 670 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
660 if (isdn_add_channels(dev->drv[di], di, c->arg, 1)) { 671 if ((dev->drvmap[i] == di) &&
672 (dev->chanmap[i] == c->arg)) {
673 if (c->parm.num[0])
674 dev->usage[i] &= ~ISDN_USAGE_DISABLED;
675 else
676 if (USG_NONE(dev->usage[i])) {
677 dev->usage[i] |= ISDN_USAGE_DISABLED;
678 }
679 else
680 retval = -1;
681 break;
682 }
661 spin_unlock_irqrestore(&dev->lock, flags); 683 spin_unlock_irqrestore(&dev->lock, flags);
662 return -1; 684 isdn_info_update();
663 } 685 break;
664 spin_unlock_irqrestore(&dev->lock, flags); 686 case ISDN_STAT_UNLOAD:
665 isdn_info_update(); 687 while (dev->drv[di]->locks > 0) {
666 break; 688 isdn_unlock_driver(dev->drv[di]);
667 case ISDN_STAT_DISCH:
668 spin_lock_irqsave(&dev->lock, flags);
669 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
670 if ((dev->drvmap[i] == di) &&
671 (dev->chanmap[i] == c->arg)) {
672 if (c->parm.num[0])
673 dev->usage[i] &= ~ISDN_USAGE_DISABLED;
674 else
675 if (USG_NONE(dev->usage[i])) {
676 dev->usage[i] |= ISDN_USAGE_DISABLED;
677 }
678 else
679 retval = -1;
680 break;
681 }
682 spin_unlock_irqrestore(&dev->lock, flags);
683 isdn_info_update();
684 break;
685 case ISDN_STAT_UNLOAD:
686 while (dev->drv[di]->locks > 0) {
687 isdn_unlock_driver(dev->drv[di]);
688 }
689 spin_lock_irqsave(&dev->lock, flags);
690 isdn_tty_stat_callback(i, c);
691 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
692 if (dev->drvmap[i] == di) {
693 dev->drvmap[i] = -1;
694 dev->chanmap[i] = -1;
695 dev->usage[i] &= ~ISDN_USAGE_DISABLED;
696 } 689 }
697 dev->drivers--; 690 spin_lock_irqsave(&dev->lock, flags);
698 dev->channels -= dev->drv[di]->channels; 691 isdn_tty_stat_callback(i, c);
699 kfree(dev->drv[di]->rcverr); 692 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
700 kfree(dev->drv[di]->rcvcount); 693 if (dev->drvmap[i] == di) {
701 for (i = 0; i < dev->drv[di]->channels; i++) 694 dev->drvmap[i] = -1;
702 skb_queue_purge(&dev->drv[di]->rpqueue[i]); 695 dev->chanmap[i] = -1;
703 kfree(dev->drv[di]->rpqueue); 696 dev->usage[i] &= ~ISDN_USAGE_DISABLED;
704 kfree(dev->drv[di]->rcv_waitq); 697 }
705 kfree(dev->drv[di]); 698 dev->drivers--;
706 dev->drv[di] = NULL; 699 dev->channels -= dev->drv[di]->channels;
707 dev->drvid[di][0] = '\0'; 700 kfree(dev->drv[di]->rcverr);
708 isdn_info_update(); 701 kfree(dev->drv[di]->rcvcount);
709 set_global_features(); 702 for (i = 0; i < dev->drv[di]->channels; i++)
710 spin_unlock_irqrestore(&dev->lock, flags); 703 skb_queue_purge(&dev->drv[di]->rpqueue[i]);
711 return 0; 704 kfree(dev->drv[di]->rpqueue);
712 case ISDN_STAT_L1ERR: 705 kfree(dev->drv[di]->rcv_waitq);
713 break; 706 kfree(dev->drv[di]);
714 case CAPI_PUT_MESSAGE: 707 dev->drv[di] = NULL;
715 return (isdn_capi_rec_hl_msg(&c->parm.cmsg)); 708 dev->drvid[di][0] = '\0';
709 isdn_info_update();
710 set_global_features();
711 spin_unlock_irqrestore(&dev->lock, flags);
712 return 0;
713 case ISDN_STAT_L1ERR:
714 break;
715 case CAPI_PUT_MESSAGE:
716 return(isdn_capi_rec_hl_msg(&c->parm.cmsg));
716#ifdef CONFIG_ISDN_TTY_FAX 717#ifdef CONFIG_ISDN_TTY_FAX
717 case ISDN_STAT_FAXIND: 718 case ISDN_STAT_FAXIND:
718 isdn_tty_stat_callback(i, c); 719 isdn_tty_stat_callback(i, c);
719 break; 720 break;
720#endif 721#endif
721#ifdef CONFIG_ISDN_AUDIO 722#ifdef CONFIG_ISDN_AUDIO
722 case ISDN_STAT_AUDIO: 723 case ISDN_STAT_AUDIO:
723 isdn_tty_stat_callback(i, c); 724 isdn_tty_stat_callback(i, c);
724 break; 725 break;
725#endif 726#endif
726#ifdef CONFIG_ISDN_DIVERSION 727#ifdef CONFIG_ISDN_DIVERSION
727 case ISDN_STAT_PROT: 728 case ISDN_STAT_PROT:
728 case ISDN_STAT_REDIR: 729 case ISDN_STAT_REDIR:
729 if (divert_if) 730 if (divert_if)
730 return (divert_if->stat_callback(c)); 731 return(divert_if->stat_callback(c));
731#endif /* CONFIG_ISDN_DIVERSION */ 732#endif /* CONFIG_ISDN_DIVERSION */
732 default: 733 default:
733 return -1; 734 return -1;
734 } 735 }
735 return 0; 736 return 0;
736} 737}
@@ -754,17 +755,17 @@ isdn_getnum(char **p)
754 * isdn_readbchan() tries to get data from the read-queue. 755 * isdn_readbchan() tries to get data from the read-queue.
755 * It MUST be called with interrupts off. 756 * It MUST be called with interrupts off.
756 * 757 *
757 * Be aware that this is not an atomic operation when sleep != 0, even though 758 * Be aware that this is not an atomic operation when sleep != 0, even though
758 * interrupts are turned off! Well, like that we are currently only called 759 * interrupts are turned off! Well, like that we are currently only called
759 * on behalf of a read system call on raw device files (which are documented 760 * on behalf of a read system call on raw device files (which are documented
760 * to be dangerous and for debugging purpose only). The inode semaphore 761 * to be dangerous and for debugging purpose only). The inode semaphore
761 * takes care that this is not called for the same minor device number while 762 * takes care that this is not called for the same minor device number while
762 * we are sleeping, but access is not serialized against simultaneous read() 763 * we are sleeping, but access is not serialized against simultaneous read()
763 * from the corresponding ttyI device. Can other ugly events, like changes 764 * from the corresponding ttyI device. Can other ugly events, like changes
764 * of the mapping (di,ch)<->minor, happen during the sleep? --he 765 * of the mapping (di,ch)<->minor, happen during the sleep? --he
765 */ 766 */
766int 767int
767isdn_readbchan(int di, int channel, u_char *buf, u_char *fp, int len, wait_queue_head_t *sleep) 768isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_queue_head_t *sleep)
768{ 769{
769 int count; 770 int count;
770 int count_pull; 771 int count_pull;
@@ -889,10 +890,10 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
889 if (!dev->drv[di]) 890 if (!dev->drv[di])
890 return 0; 891 return 0;
891 if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) 892 if (skb_queue_empty(&dev->drv[di]->rpqueue[channel]))
892 return 0; 893 return 0;
893 894
894 len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); 895 len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]);
895 if (len == 0) 896 if(len == 0)
896 return len; 897 return len;
897 898
898 count = 0; 899 count = 0;
@@ -911,7 +912,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
911 count_pull = count_put = 0; 912 count_pull = count_put = 0;
912 while ((count_pull < skb->len) && (len > 0)) { 913 while ((count_pull < skb->len) && (len > 0)) {
913 /* push every character but the last to the tty buffer directly */ 914 /* push every character but the last to the tty buffer directly */
914 if (count_put) 915 if ( count_put )
915 tty_insert_flip_char(tty, last, TTY_NORMAL); 916 tty_insert_flip_char(tty, last, TTY_NORMAL);
916 len--; 917 len--;
917 if (dev->drv[di]->DLEflag & DLEmask) { 918 if (dev->drv[di]->DLEflag & DLEmask) {
@@ -939,7 +940,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
939 dflag = 0; 940 dflag = 0;
940 } 941 }
941 count_put = count_pull; 942 count_put = count_pull;
942 if (count_put > 1) 943 if(count_put > 1)
943 tty_insert_flip_string(tty, skb->data, count_put - 1); 944 tty_insert_flip_string(tty, skb->data, count_put - 1);
944 last = skb->data[count_put - 1]; 945 last = skb->data[count_put - 1];
945 len -= count_put; 946 len -= count_put;
@@ -951,7 +952,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
951 /* We got all the data in this buff. 952 /* We got all the data in this buff.
952 * Now we can dequeue it. 953 * Now we can dequeue it.
953 */ 954 */
954 if (cisco_hack) 955 if(cisco_hack)
955 tty_insert_flip_char(tty, last, 0xFF); 956 tty_insert_flip_char(tty, last, 0xFF);
956 else 957 else
957 tty_insert_flip_char(tty, last, TTY_NORMAL); 958 tty_insert_flip_char(tty, last, TTY_NORMAL);
@@ -1056,7 +1057,7 @@ isdn_info_update(void)
1056} 1057}
1057 1058
1058static ssize_t 1059static ssize_t
1059isdn_read(struct file *file, char __user *buf, size_t count, loff_t *off) 1060isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1060{ 1061{
1061 uint minor = iminor(file->f_path.dentry->d_inode); 1062 uint minor = iminor(file->f_path.dentry->d_inode);
1062 int len = 0; 1063 int len = 0;
@@ -1111,7 +1112,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t *off)
1111 len = isdn_readbchan(drvidx, chidx, p, NULL, count, 1112 len = isdn_readbchan(drvidx, chidx, p, NULL, count,
1112 &dev->drv[drvidx]->rcv_waitq[chidx]); 1113 &dev->drv[drvidx]->rcv_waitq[chidx]);
1113 *off += len; 1114 *off += len;
1114 if (copy_to_user(buf, p, len)) 1115 if (copy_to_user(buf,p,len))
1115 len = -EFAULT; 1116 len = -EFAULT;
1116 kfree(p); 1117 kfree(p);
1117 retval = len; 1118 retval = len;
@@ -1134,7 +1135,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t *off)
1134 if (count > dev->drv[drvidx]->stavail) 1135 if (count > dev->drv[drvidx]->stavail)
1135 count = dev->drv[drvidx]->stavail; 1136 count = dev->drv[drvidx]->stavail;
1136 len = dev->drv[drvidx]->interface->readstat(buf, count, 1137 len = dev->drv[drvidx]->interface->readstat(buf, count,
1137 drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL)); 1138 drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL));
1138 if (len < 0) { 1139 if (len < 0) {
1139 retval = len; 1140 retval = len;
1140 goto out; 1141 goto out;
@@ -1157,13 +1158,13 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t *off)
1157 } 1158 }
1158#endif 1159#endif
1159 retval = -ENODEV; 1160 retval = -ENODEV;
1160out: 1161 out:
1161 mutex_unlock(&isdn_mutex); 1162 mutex_unlock(&isdn_mutex);
1162 return retval; 1163 return retval;
1163} 1164}
1164 1165
1165static ssize_t 1166static ssize_t
1166isdn_write(struct file *file, const char __user *buf, size_t count, loff_t *off) 1167isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
1167{ 1168{
1168 uint minor = iminor(file->f_path.dentry->d_inode); 1169 uint minor = iminor(file->f_path.dentry->d_inode);
1169 int drvidx; 1170 int drvidx;
@@ -1203,11 +1204,11 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
1203 * 1204 *
1204 if (!(dev->drv[drvidx]->flags & DRV_FLAG_RUNNING)) 1205 if (!(dev->drv[drvidx]->flags & DRV_FLAG_RUNNING))
1205 return -ENODEV; 1206 return -ENODEV;
1206 */ 1207 */
1207 if (dev->drv[drvidx]->interface->writecmd) 1208 if (dev->drv[drvidx]->interface->writecmd)
1208 retval = dev->drv[drvidx]->interface-> 1209 retval = dev->drv[drvidx]->interface->
1209 writecmd(buf, count, drvidx, 1210 writecmd(buf, count, drvidx,
1210 isdn_minor2chan(minor - ISDN_MINOR_CTRL)); 1211 isdn_minor2chan(minor - ISDN_MINOR_CTRL));
1211 else 1212 else
1212 retval = count; 1213 retval = count;
1213 goto out; 1214 goto out;
@@ -1219,13 +1220,13 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
1219 } 1220 }
1220#endif 1221#endif
1221 retval = -ENODEV; 1222 retval = -ENODEV;
1222out: 1223 out:
1223 mutex_unlock(&isdn_mutex); 1224 mutex_unlock(&isdn_mutex);
1224 return retval; 1225 return retval;
1225} 1226}
1226 1227
1227static unsigned int 1228static unsigned int
1228isdn_poll(struct file *file, poll_table *wait) 1229isdn_poll(struct file *file, poll_table * wait)
1229{ 1230{
1230 unsigned int mask = 0; 1231 unsigned int mask = 0;
1231 unsigned int minor = iminor(file->f_path.dentry->d_inode); 1232 unsigned int minor = iminor(file->f_path.dentry->d_inode);
@@ -1260,7 +1261,7 @@ isdn_poll(struct file *file, poll_table *wait)
1260 } 1261 }
1261#endif 1262#endif
1262 mask = POLLERR; 1263 mask = POLLERR;
1263out: 1264 out:
1264 mutex_unlock(&isdn_mutex); 1265 mutex_unlock(&isdn_mutex);
1265 return mask; 1266 return mask;
1266} 1267}
@@ -1293,36 +1294,38 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1293 1294
1294 if (minor == ISDN_MINOR_STATUS) { 1295 if (minor == ISDN_MINOR_STATUS) {
1295 switch (cmd) { 1296 switch (cmd) {
1296 case IIOCGETDVR: 1297 case IIOCGETDVR:
1297 return (TTY_DV + 1298 return (TTY_DV +
1298 (NET_DV << 8) + 1299 (NET_DV << 8) +
1299 (INF_DV << 16)); 1300 (INF_DV << 16));
1300 case IIOCGETCPS: 1301 case IIOCGETCPS:
1301 if (arg) { 1302 if (arg) {
1302 ulong __user *p = argp; 1303 ulong __user *p = argp;
1303 int i; 1304 int i;
1304 if (!access_ok(VERIFY_WRITE, p, 1305 if (!access_ok(VERIFY_WRITE, p,
1305 sizeof(ulong) * ISDN_MAX_CHANNELS * 2)) 1306 sizeof(ulong) * ISDN_MAX_CHANNELS * 2))
1306 return -EFAULT; 1307 return -EFAULT;
1307 for (i = 0; i < ISDN_MAX_CHANNELS; i++) { 1308 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1308 put_user(dev->ibytes[i], p++); 1309 put_user(dev->ibytes[i], p++);
1309 put_user(dev->obytes[i], p++); 1310 put_user(dev->obytes[i], p++);
1310 } 1311 }
1311 return 0; 1312 return 0;
1312 } else 1313 } else
1313 return -EINVAL; 1314 return -EINVAL;
1314 break; 1315 break;
1315 case IIOCNETGPN: 1316#ifdef CONFIG_NETDEVICES
1316 /* Get peer phone number of a connected 1317 case IIOCNETGPN:
1317 * isdn network interface */ 1318 /* Get peer phone number of a connected
1318 if (arg) { 1319 * isdn network interface */
1319 if (copy_from_user(&phone, argp, sizeof(phone))) 1320 if (arg) {
1320 return -EFAULT; 1321 if (copy_from_user(&phone, argp, sizeof(phone)))
1321 return isdn_net_getpeer(&phone, argp); 1322 return -EFAULT;
1322 } else 1323 return isdn_net_getpeer(&phone, argp);
1324 } else
1325 return -EINVAL;
1326#endif
1327 default:
1323 return -EINVAL; 1328 return -EINVAL;
1324 default:
1325 return -EINVAL;
1326 } 1329 }
1327 } 1330 }
1328 if (!dev->drivers) 1331 if (!dev->drivers)
@@ -1344,358 +1347,360 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1344 * are serialized by means of a semaphore. 1347 * are serialized by means of a semaphore.
1345 */ 1348 */
1346 switch (cmd) { 1349 switch (cmd) {
1347 case IIOCNETDWRSET: 1350 case IIOCNETDWRSET:
1348 printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n"); 1351 printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n");
1349 return (-EINVAL); 1352 return(-EINVAL);
1350 case IIOCNETLCR: 1353 case IIOCNETLCR:
1351 printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); 1354 printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n");
1352 return -ENODEV; 1355 return -ENODEV;
1353 case IIOCNETAIF: 1356#ifdef CONFIG_NETDEVICES
1354 /* Add a network-interface */ 1357 case IIOCNETAIF:
1355 if (arg) { 1358 /* Add a network-interface */
1356 if (copy_from_user(name, argp, sizeof(name))) 1359 if (arg) {
1357 return -EFAULT; 1360 if (copy_from_user(name, argp, sizeof(name)))
1358 s = name; 1361 return -EFAULT;
1359 } else { 1362 s = name;
1360 s = NULL;
1361 }
1362 ret = mutex_lock_interruptible(&dev->mtx);
1363 if (ret) return ret;
1364 if ((s = isdn_net_new(s, NULL))) {
1365 if (copy_to_user(argp, s, strlen(s) + 1)) {
1366 ret = -EFAULT;
1367 } else {
1368 ret = 0;
1369 }
1370 } else
1371 ret = -ENODEV;
1372 mutex_unlock(&dev->mtx);
1373 return ret;
1374 case IIOCNETASL:
1375 /* Add a slave to a network-interface */
1376 if (arg) {
1377 if (copy_from_user(bname, argp, sizeof(bname) - 1))
1378 return -EFAULT;
1379 } else
1380 return -EINVAL;
1381 ret = mutex_lock_interruptible(&dev->mtx);
1382 if (ret) return ret;
1383 if ((s = isdn_net_newslave(bname))) {
1384 if (copy_to_user(argp, s, strlen(s) + 1)) {
1385 ret = -EFAULT;
1386 } else { 1363 } else {
1387 ret = 0; 1364 s = NULL;
1388 } 1365 }
1389 } else
1390 ret = -ENODEV;
1391 mutex_unlock(&dev->mtx);
1392 return ret;
1393 case IIOCNETDIF:
1394 /* Delete a network-interface */
1395 if (arg) {
1396 if (copy_from_user(name, argp, sizeof(name)))
1397 return -EFAULT;
1398 ret = mutex_lock_interruptible(&dev->mtx); 1366 ret = mutex_lock_interruptible(&dev->mtx);
1399 if (ret) return ret; 1367 if( ret ) return ret;
1400 ret = isdn_net_rm(name); 1368 if ((s = isdn_net_new(s, NULL))) {
1369 if (copy_to_user(argp, s, strlen(s) + 1)){
1370 ret = -EFAULT;
1371 } else {
1372 ret = 0;
1373 }
1374 } else
1375 ret = -ENODEV;
1401 mutex_unlock(&dev->mtx); 1376 mutex_unlock(&dev->mtx);
1402 return ret; 1377 return ret;
1403 } else 1378 case IIOCNETASL:
1404 return -EINVAL; 1379 /* Add a slave to a network-interface */
1405 case IIOCNETSCF: 1380 if (arg) {
1406 /* Set configurable parameters of a network-interface */ 1381 if (copy_from_user(bname, argp, sizeof(bname) - 1))
1407 if (arg) {
1408 if (copy_from_user(&cfg, argp, sizeof(cfg)))
1409 return -EFAULT;
1410 return isdn_net_setcfg(&cfg);
1411 } else
1412 return -EINVAL;
1413 case IIOCNETGCF:
1414 /* Get configurable parameters of a network-interface */
1415 if (arg) {
1416 if (copy_from_user(&cfg, argp, sizeof(cfg)))
1417 return -EFAULT;
1418 if (!(ret = isdn_net_getcfg(&cfg))) {
1419 if (copy_to_user(argp, &cfg, sizeof(cfg)))
1420 return -EFAULT; 1382 return -EFAULT;
1421 } 1383 } else
1422 return ret; 1384 return -EINVAL;
1423 } else
1424 return -EINVAL;
1425 case IIOCNETANM:
1426 /* Add a phone-number to a network-interface */
1427 if (arg) {
1428 if (copy_from_user(&phone, argp, sizeof(phone)))
1429 return -EFAULT;
1430 ret = mutex_lock_interruptible(&dev->mtx);
1431 if (ret) return ret;
1432 ret = isdn_net_addphone(&phone);
1433 mutex_unlock(&dev->mtx);
1434 return ret;
1435 } else
1436 return -EINVAL;
1437 case IIOCNETGNM:
1438 /* Get list of phone-numbers of a network-interface */
1439 if (arg) {
1440 if (copy_from_user(&phone, argp, sizeof(phone)))
1441 return -EFAULT;
1442 ret = mutex_lock_interruptible(&dev->mtx);
1443 if (ret) return ret;
1444 ret = isdn_net_getphones(&phone, argp);
1445 mutex_unlock(&dev->mtx);
1446 return ret;
1447 } else
1448 return -EINVAL;
1449 case IIOCNETDNM:
1450 /* Delete a phone-number of a network-interface */
1451 if (arg) {
1452 if (copy_from_user(&phone, argp, sizeof(phone)))
1453 return -EFAULT;
1454 ret = mutex_lock_interruptible(&dev->mtx); 1385 ret = mutex_lock_interruptible(&dev->mtx);
1455 if (ret) return ret; 1386 if( ret ) return ret;
1456 ret = isdn_net_delphone(&phone); 1387 if ((s = isdn_net_newslave(bname))) {
1388 if (copy_to_user(argp, s, strlen(s) + 1)){
1389 ret = -EFAULT;
1390 } else {
1391 ret = 0;
1392 }
1393 } else
1394 ret = -ENODEV;
1457 mutex_unlock(&dev->mtx); 1395 mutex_unlock(&dev->mtx);
1458 return ret; 1396 return ret;
1459 } else 1397 case IIOCNETDIF:
1460 return -EINVAL; 1398 /* Delete a network-interface */
1461 case IIOCNETDIL: 1399 if (arg) {
1462 /* Force dialing of a network-interface */ 1400 if (copy_from_user(name, argp, sizeof(name)))
1463 if (arg) {
1464 if (copy_from_user(name, argp, sizeof(name)))
1465 return -EFAULT;
1466 return isdn_net_force_dial(name);
1467 } else
1468 return -EINVAL;
1469#ifdef CONFIG_ISDN_PPP
1470 case IIOCNETALN:
1471 if (!arg)
1472 return -EINVAL;
1473 if (copy_from_user(name, argp, sizeof(name)))
1474 return -EFAULT;
1475 return isdn_ppp_dial_slave(name);
1476 case IIOCNETDLN:
1477 if (!arg)
1478 return -EINVAL;
1479 if (copy_from_user(name, argp, sizeof(name)))
1480 return -EFAULT;
1481 return isdn_ppp_hangup_slave(name);
1482#endif
1483 case IIOCNETHUP:
1484 /* Force hangup of a network-interface */
1485 if (!arg)
1486 return -EINVAL;
1487 if (copy_from_user(name, argp, sizeof(name)))
1488 return -EFAULT;
1489 return isdn_net_force_hangup(name);
1490 break;
1491 case IIOCSETVER:
1492 dev->net_verbose = arg;
1493 printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose);
1494 return 0;
1495 case IIOCSETGST:
1496 if (arg)
1497 dev->global_flags |= ISDN_GLOBAL_STOPPED;
1498 else
1499 dev->global_flags &= ~ISDN_GLOBAL_STOPPED;
1500 printk(KERN_INFO "isdn: Global Mode %s\n",
1501 (dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running");
1502 return 0;
1503 case IIOCSETBRJ:
1504 drvidx = -1;
1505 if (arg) {
1506 int i;
1507 char *p;
1508 if (copy_from_user(&iocts, argp,
1509 sizeof(isdn_ioctl_struct)))
1510 return -EFAULT;
1511 iocts.drvid[sizeof(iocts.drvid) - 1] = 0;
1512 if (strlen(iocts.drvid)) {
1513 if ((p = strchr(iocts.drvid, ',')))
1514 *p = 0;
1515 drvidx = -1;
1516 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
1517 if (!(strcmp(dev->drvid[i], iocts.drvid))) {
1518 drvidx = i;
1519 break;
1520 }
1521 }
1522 }
1523 if (drvidx == -1)
1524 return -ENODEV;
1525 if (iocts.arg)
1526 dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS;
1527 else
1528 dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS;
1529 return 0;
1530 case IIOCSIGPRF:
1531 dev->profd = current;
1532 return 0;
1533 break;
1534 case IIOCGETPRF:
1535 /* Get all Modem-Profiles */
1536 if (arg) {
1537 char __user *p = argp;
1538 int i;
1539
1540 if (!access_ok(VERIFY_WRITE, argp,
1541 (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN)
1542 * ISDN_MAX_CHANNELS))
1543 return -EFAULT;
1544
1545 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1546 if (copy_to_user(p, dev->mdm.info[i].emu.profile,
1547 ISDN_MODEM_NUMREG))
1548 return -EFAULT; 1401 return -EFAULT;
1549 p += ISDN_MODEM_NUMREG; 1402 ret = mutex_lock_interruptible(&dev->mtx);
1550 if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN)) 1403 if( ret ) return ret;
1404 ret = isdn_net_rm(name);
1405 mutex_unlock(&dev->mtx);
1406 return ret;
1407 } else
1408 return -EINVAL;
1409 case IIOCNETSCF:
1410 /* Set configurable parameters of a network-interface */
1411 if (arg) {
1412 if (copy_from_user(&cfg, argp, sizeof(cfg)))
1551 return -EFAULT; 1413 return -EFAULT;
1552 p += ISDN_MSNLEN; 1414 return isdn_net_setcfg(&cfg);
1553 if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) 1415 } else
1416 return -EINVAL;
1417 case IIOCNETGCF:
1418 /* Get configurable parameters of a network-interface */
1419 if (arg) {
1420 if (copy_from_user(&cfg, argp, sizeof(cfg)))
1554 return -EFAULT; 1421 return -EFAULT;
1555 p += ISDN_LMSNLEN; 1422 if (!(ret = isdn_net_getcfg(&cfg))) {
1556 } 1423 if (copy_to_user(argp, &cfg, sizeof(cfg)))
1557 return (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) * ISDN_MAX_CHANNELS; 1424 return -EFAULT;
1558 } else 1425 }
1559 return -EINVAL; 1426 return ret;
1560 break; 1427 } else
1561 case IIOCSETPRF: 1428 return -EINVAL;
1562 /* Set all Modem-Profiles */ 1429 case IIOCNETANM:
1563 if (arg) { 1430 /* Add a phone-number to a network-interface */
1564 char __user *p = argp; 1431 if (arg) {
1565 int i; 1432 if (copy_from_user(&phone, argp, sizeof(phone)))
1566
1567 if (!access_ok(VERIFY_READ, argp,
1568 (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN)
1569 * ISDN_MAX_CHANNELS))
1570 return -EFAULT;
1571
1572 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1573 if (copy_from_user(dev->mdm.info[i].emu.profile, p,
1574 ISDN_MODEM_NUMREG))
1575 return -EFAULT; 1433 return -EFAULT;
1576 p += ISDN_MODEM_NUMREG; 1434 ret = mutex_lock_interruptible(&dev->mtx);
1577 if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) 1435 if( ret ) return ret;
1436 ret = isdn_net_addphone(&phone);
1437 mutex_unlock(&dev->mtx);
1438 return ret;
1439 } else
1440 return -EINVAL;
1441 case IIOCNETGNM:
1442 /* Get list of phone-numbers of a network-interface */
1443 if (arg) {
1444 if (copy_from_user(&phone, argp, sizeof(phone)))
1445 return -EFAULT;
1446 ret = mutex_lock_interruptible(&dev->mtx);
1447 if( ret ) return ret;
1448 ret = isdn_net_getphones(&phone, argp);
1449 mutex_unlock(&dev->mtx);
1450 return ret;
1451 } else
1452 return -EINVAL;
1453 case IIOCNETDNM:
1454 /* Delete a phone-number of a network-interface */
1455 if (arg) {
1456 if (copy_from_user(&phone, argp, sizeof(phone)))
1457 return -EFAULT;
1458 ret = mutex_lock_interruptible(&dev->mtx);
1459 if( ret ) return ret;
1460 ret = isdn_net_delphone(&phone);
1461 mutex_unlock(&dev->mtx);
1462 return ret;
1463 } else
1464 return -EINVAL;
1465 case IIOCNETDIL:
1466 /* Force dialing of a network-interface */
1467 if (arg) {
1468 if (copy_from_user(name, argp, sizeof(name)))
1578 return -EFAULT; 1469 return -EFAULT;
1579 p += ISDN_LMSNLEN; 1470 return isdn_net_force_dial(name);
1580 if (copy_from_user(dev->mdm.info[i].emu.pmsn, p, ISDN_MSNLEN)) 1471 } else
1472 return -EINVAL;
1473#ifdef CONFIG_ISDN_PPP
1474 case IIOCNETALN:
1475 if (!arg)
1476 return -EINVAL;
1477 if (copy_from_user(name, argp, sizeof(name)))
1478 return -EFAULT;
1479 return isdn_ppp_dial_slave(name);
1480 case IIOCNETDLN:
1481 if (!arg)
1482 return -EINVAL;
1483 if (copy_from_user(name, argp, sizeof(name)))
1484 return -EFAULT;
1485 return isdn_ppp_hangup_slave(name);
1486#endif
1487 case IIOCNETHUP:
1488 /* Force hangup of a network-interface */
1489 if (!arg)
1490 return -EINVAL;
1491 if (copy_from_user(name, argp, sizeof(name)))
1492 return -EFAULT;
1493 return isdn_net_force_hangup(name);
1494 break;
1495#endif /* CONFIG_NETDEVICES */
1496 case IIOCSETVER:
1497 dev->net_verbose = arg;
1498 printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose);
1499 return 0;
1500 case IIOCSETGST:
1501 if (arg)
1502 dev->global_flags |= ISDN_GLOBAL_STOPPED;
1503 else
1504 dev->global_flags &= ~ISDN_GLOBAL_STOPPED;
1505 printk(KERN_INFO "isdn: Global Mode %s\n",
1506 (dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running");
1507 return 0;
1508 case IIOCSETBRJ:
1509 drvidx = -1;
1510 if (arg) {
1511 int i;
1512 char *p;
1513 if (copy_from_user(&iocts, argp,
1514 sizeof(isdn_ioctl_struct)))
1581 return -EFAULT; 1515 return -EFAULT;
1582 p += ISDN_MSNLEN; 1516 iocts.drvid[sizeof(iocts.drvid)-1] = 0;
1517 if (strlen(iocts.drvid)) {
1518 if ((p = strchr(iocts.drvid, ',')))
1519 *p = 0;
1520 drvidx = -1;
1521 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
1522 if (!(strcmp(dev->drvid[i], iocts.drvid))) {
1523 drvidx = i;
1524 break;
1525 }
1526 }
1583 } 1527 }
1528 if (drvidx == -1)
1529 return -ENODEV;
1530 if (iocts.arg)
1531 dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS;
1532 else
1533 dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS;
1584 return 0; 1534 return 0;
1585 } else 1535 case IIOCSIGPRF:
1586 return -EINVAL; 1536 dev->profd = current;
1587 break; 1537 return 0;
1588 case IIOCSETMAP: 1538 break;
1589 case IIOCGETMAP: 1539 case IIOCGETPRF:
1590 /* Set/Get MSN->EAZ-Mapping for a driver */ 1540 /* Get all Modem-Profiles */
1591 if (arg) { 1541 if (arg) {
1542 char __user *p = argp;
1543 int i;
1544
1545 if (!access_ok(VERIFY_WRITE, argp,
1546 (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN)
1547 * ISDN_MAX_CHANNELS))
1548 return -EFAULT;
1592 1549
1593 if (copy_from_user(&iocts, argp, 1550 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1594 sizeof(isdn_ioctl_struct))) 1551 if (copy_to_user(p, dev->mdm.info[i].emu.profile,
1595 return -EFAULT; 1552 ISDN_MODEM_NUMREG))
1596 iocts.drvid[sizeof(iocts.drvid) - 1] = 0; 1553 return -EFAULT;
1597 if (strlen(iocts.drvid)) { 1554 p += ISDN_MODEM_NUMREG;
1598 drvidx = -1; 1555 if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN))
1599 for (i = 0; i < ISDN_MAX_DRIVERS; i++) 1556 return -EFAULT;
1600 if (!(strcmp(dev->drvid[i], iocts.drvid))) { 1557 p += ISDN_MSNLEN;
1601 drvidx = i; 1558 if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN))
1602 break; 1559 return -EFAULT;
1603 } 1560 p += ISDN_LMSNLEN;
1561 }
1562 return (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) * ISDN_MAX_CHANNELS;
1604 } else 1563 } else
1605 drvidx = 0; 1564 return -EINVAL;
1606 if (drvidx == -1) 1565 break;
1607 return -ENODEV; 1566 case IIOCSETPRF:
1608 if (cmd == IIOCSETMAP) { 1567 /* Set all Modem-Profiles */
1609 int loop = 1; 1568 if (arg) {
1569 char __user *p = argp;
1570 int i;
1571
1572 if (!access_ok(VERIFY_READ, argp,
1573 (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN)
1574 * ISDN_MAX_CHANNELS))
1575 return -EFAULT;
1610 1576
1611 p = (char __user *) iocts.arg; 1577 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1612 i = 0; 1578 if (copy_from_user(dev->mdm.info[i].emu.profile, p,
1613 while (loop) { 1579 ISDN_MODEM_NUMREG))
1614 int j = 0; 1580 return -EFAULT;
1581 p += ISDN_MODEM_NUMREG;
1582 if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN))
1583 return -EFAULT;
1584 p += ISDN_LMSNLEN;
1585 if (copy_from_user(dev->mdm.info[i].emu.pmsn, p, ISDN_MSNLEN))
1586 return -EFAULT;
1587 p += ISDN_MSNLEN;
1588 }
1589 return 0;
1590 } else
1591 return -EINVAL;
1592 break;
1593 case IIOCSETMAP:
1594 case IIOCGETMAP:
1595 /* Set/Get MSN->EAZ-Mapping for a driver */
1596 if (arg) {
1615 1597
1616 while (1) { 1598 if (copy_from_user(&iocts, argp,
1617 if (!access_ok(VERIFY_READ, p, 1)) 1599 sizeof(isdn_ioctl_struct)))
1618 return -EFAULT; 1600 return -EFAULT;
1619 get_user(bname[j], p++); 1601 iocts.drvid[sizeof(iocts.drvid)-1] = 0;
1620 switch (bname[j]) { 1602 if (strlen(iocts.drvid)) {
1621 case '\0': 1603 drvidx = -1;
1622 loop = 0; 1604 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
1623 /* Fall through */ 1605 if (!(strcmp(dev->drvid[i], iocts.drvid))) {
1624 case ',': 1606 drvidx = i;
1625 bname[j] = '\0';
1626 strcpy(dev->drv[drvidx]->msn2eaz[i], bname);
1627 j = ISDN_MSNLEN;
1628 break; 1607 break;
1629 default:
1630 j++;
1631 } 1608 }
1632 if (j >= ISDN_MSNLEN) 1609 } else
1610 drvidx = 0;
1611 if (drvidx == -1)
1612 return -ENODEV;
1613 if (cmd == IIOCSETMAP) {
1614 int loop = 1;
1615
1616 p = (char __user *) iocts.arg;
1617 i = 0;
1618 while (loop) {
1619 int j = 0;
1620
1621 while (1) {
1622 if (!access_ok(VERIFY_READ, p, 1))
1623 return -EFAULT;
1624 get_user(bname[j], p++);
1625 switch (bname[j]) {
1626 case '\0':
1627 loop = 0;
1628 /* Fall through */
1629 case ',':
1630 bname[j] = '\0';
1631 strcpy(dev->drv[drvidx]->msn2eaz[i], bname);
1632 j = ISDN_MSNLEN;
1633 break;
1634 default:
1635 j++;
1636 }
1637 if (j >= ISDN_MSNLEN)
1638 break;
1639 }
1640 if (++i > 9)
1633 break; 1641 break;
1634 } 1642 }
1635 if (++i > 9) 1643 } else {
1636 break; 1644 p = (char __user *) iocts.arg;
1637 } 1645 for (i = 0; i < 10; i++) {
1638 } else { 1646 snprintf(bname, sizeof(bname), "%s%s",
1639 p = (char __user *) iocts.arg; 1647 strlen(dev->drv[drvidx]->msn2eaz[i]) ?
1640 for (i = 0; i < 10; i++) { 1648 dev->drv[drvidx]->msn2eaz[i] : "_",
1641 snprintf(bname, sizeof(bname), "%s%s", 1649 (i < 9) ? "," : "\0");
1642 strlen(dev->drv[drvidx]->msn2eaz[i]) ? 1650 if (copy_to_user(p, bname, strlen(bname) + 1))
1643 dev->drv[drvidx]->msn2eaz[i] : "_", 1651 return -EFAULT;
1644 (i < 9) ? "," : "\0"); 1652 p += strlen(bname);
1645 if (copy_to_user(p, bname, strlen(bname) + 1))
1646 return -EFAULT;
1647 p += strlen(bname);
1648 }
1649 }
1650 return 0;
1651 } else
1652 return -EINVAL;
1653 case IIOCDBGVAR:
1654 if (arg) {
1655 if (copy_to_user(argp, &dev, sizeof(ulong)))
1656 return -EFAULT;
1657 return 0;
1658 } else
1659 return -EINVAL;
1660 break;
1661 default:
1662 if ((cmd & IIOCDRVCTL) == IIOCDRVCTL)
1663 cmd = ((cmd >> _IOC_NRSHIFT) & _IOC_NRMASK) & ISDN_DRVIOCTL_MASK;
1664 else
1665 return -EINVAL;
1666 if (arg) {
1667 int i;
1668 char *p;
1669 if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct)))
1670 return -EFAULT;
1671 iocts.drvid[sizeof(iocts.drvid) - 1] = 0;
1672 if (strlen(iocts.drvid)) {
1673 if ((p = strchr(iocts.drvid, ',')))
1674 *p = 0;
1675 drvidx = -1;
1676 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
1677 if (!(strcmp(dev->drvid[i], iocts.drvid))) {
1678 drvidx = i;
1679 break;
1680 } 1653 }
1654 }
1655 return 0;
1681 } else 1656 } else
1682 drvidx = 0; 1657 return -EINVAL;
1683 if (drvidx == -1) 1658 case IIOCDBGVAR:
1684 return -ENODEV; 1659 if (arg) {
1685 if (!access_ok(VERIFY_WRITE, argp, 1660 if (copy_to_user(argp, &dev, sizeof(ulong)))
1686 sizeof(isdn_ioctl_struct))) 1661 return -EFAULT;
1687 return -EFAULT; 1662 return 0;
1688 c.driver = drvidx; 1663 } else
1689 c.command = ISDN_CMD_IOCTL; 1664 return -EINVAL;
1690 c.arg = cmd; 1665 break;
1691 memcpy(c.parm.num, &iocts.arg, sizeof(ulong)); 1666 default:
1692 ret = isdn_command(&c); 1667 if ((cmd & IIOCDRVCTL) == IIOCDRVCTL)
1693 memcpy(&iocts.arg, c.parm.num, sizeof(ulong)); 1668 cmd = ((cmd >> _IOC_NRSHIFT) & _IOC_NRMASK) & ISDN_DRVIOCTL_MASK;
1694 if (copy_to_user(argp, &iocts, sizeof(isdn_ioctl_struct))) 1669 else
1695 return -EFAULT; 1670 return -EINVAL;
1696 return ret; 1671 if (arg) {
1697 } else 1672 int i;
1698 return -EINVAL; 1673 char *p;
1674 if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct)))
1675 return -EFAULT;
1676 iocts.drvid[sizeof(iocts.drvid)-1] = 0;
1677 if (strlen(iocts.drvid)) {
1678 if ((p = strchr(iocts.drvid, ',')))
1679 *p = 0;
1680 drvidx = -1;
1681 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
1682 if (!(strcmp(dev->drvid[i], iocts.drvid))) {
1683 drvidx = i;
1684 break;
1685 }
1686 } else
1687 drvidx = 0;
1688 if (drvidx == -1)
1689 return -ENODEV;
1690 if (!access_ok(VERIFY_WRITE, argp,
1691 sizeof(isdn_ioctl_struct)))
1692 return -EFAULT;
1693 c.driver = drvidx;
1694 c.command = ISDN_CMD_IOCTL;
1695 c.arg = cmd;
1696 memcpy(c.parm.num, &iocts.arg, sizeof(ulong));
1697 ret = isdn_command(&c);
1698 memcpy(&iocts.arg, c.parm.num, sizeof(ulong));
1699 if (copy_to_user(argp, &iocts, sizeof(isdn_ioctl_struct)))
1700 return -EFAULT;
1701 return ret;
1702 } else
1703 return -EINVAL;
1699 } 1704 }
1700 } 1705 }
1701#ifdef CONFIG_ISDN_PPP 1706#ifdef CONFIG_ISDN_PPP
@@ -1783,7 +1788,7 @@ isdn_open(struct inode *ino, struct file *filep)
1783 goto out; 1788 goto out;
1784 } 1789 }
1785#endif 1790#endif
1786out: 1791 out:
1787 nonseekable_open(ino, filep); 1792 nonseekable_open(ino, filep);
1788 mutex_unlock(&isdn_mutex); 1793 mutex_unlock(&isdn_mutex);
1789 return retval; 1794 return retval;
@@ -1827,7 +1832,7 @@ isdn_close(struct inode *ino, struct file *filep)
1827 isdn_ppp_release(minor - ISDN_MINOR_PPP, filep); 1832 isdn_ppp_release(minor - ISDN_MINOR_PPP, filep);
1828#endif 1833#endif
1829 1834
1830out: 1835 out:
1831 mutex_unlock(&isdn_mutex); 1836 mutex_unlock(&isdn_mutex);
1832 return 0; 1837 return 0;
1833} 1838}
@@ -1863,14 +1868,14 @@ isdn_map_eaz2msn(char *msn, int di)
1863 * Find an unused ISDN-channel, whose feature-flags match the 1868 * Find an unused ISDN-channel, whose feature-flags match the
1864 * given L2- and L3-protocols. 1869 * given L2- and L3-protocols.
1865 */ 1870 */
1866#define L2V (~(ISDN_FEATURE_L2_V11096 | ISDN_FEATURE_L2_V11019 | ISDN_FEATURE_L2_V11038)) 1871#define L2V (~(ISDN_FEATURE_L2_V11096|ISDN_FEATURE_L2_V11019|ISDN_FEATURE_L2_V11038))
1867 1872
1868/* 1873/*
1869 * This function must be called with holding the dev->lock. 1874 * This function must be called with holding the dev->lock.
1870 */ 1875 */
1871int 1876int
1872isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev 1877isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev
1873 , int pre_chan, char *msn) 1878 ,int pre_chan, char *msn)
1874{ 1879{
1875 int i; 1880 int i;
1876 ulong features; 1881 ulong features;
@@ -1878,7 +1883,7 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev
1878 1883
1879 features = ((1 << l2_proto) | (0x10000 << l3_proto)); 1884 features = ((1 << l2_proto) | (0x10000 << l3_proto));
1880 vfeatures = (((1 << l2_proto) | (0x10000 << l3_proto)) & 1885 vfeatures = (((1 << l2_proto) | (0x10000 << l3_proto)) &
1881 ~(ISDN_FEATURE_L2_V11096 | ISDN_FEATURE_L2_V11019 | ISDN_FEATURE_L2_V11038)); 1886 ~(ISDN_FEATURE_L2_V11096|ISDN_FEATURE_L2_V11019|ISDN_FEATURE_L2_V11038));
1882 /* If Layer-2 protocol is V.110, accept drivers with 1887 /* If Layer-2 protocol is V.110, accept drivers with
1883 * transparent feature even if these don't support V.110 1888 * transparent feature even if these don't support V.110
1884 * because we can emulate this in linklevel. 1889 * because we can emulate this in linklevel.
@@ -1888,12 +1893,12 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev
1888 (dev->drvmap[i] != -1)) { 1893 (dev->drvmap[i] != -1)) {
1889 int d = dev->drvmap[i]; 1894 int d = dev->drvmap[i];
1890 if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && 1895 if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) &&
1891 ((pre_dev != d) || (pre_chan != dev->chanmap[i]))) 1896 ((pre_dev != d) || (pre_chan != dev->chanmap[i])))
1892 continue; 1897 continue;
1893 if (!strcmp(isdn_map_eaz2msn(msn, d), "-")) 1898 if (!strcmp(isdn_map_eaz2msn(msn, d), "-"))
1894 continue; 1899 continue;
1895 if (dev->usage[i] & ISDN_USAGE_DISABLED) 1900 if (dev->usage[i] & ISDN_USAGE_DISABLED)
1896 continue; /* usage not allowed */ 1901 continue; /* usage not allowed */
1897 if (dev->drv[d]->flags & DRV_FLAG_RUNNING) { 1902 if (dev->drv[d]->flags & DRV_FLAG_RUNNING) {
1898 if (((dev->drv[d]->interface->features & features) == features) || 1903 if (((dev->drv[d]->interface->features & features) == features) ||
1899 (((dev->drv[d]->interface->features & vfeatures) == vfeatures) && 1904 (((dev->drv[d]->interface->features & vfeatures) == vfeatures) &&
@@ -1927,7 +1932,7 @@ isdn_free_channel(int di, int ch, int usage)
1927 1932
1928 if ((di < 0) || (ch < 0)) { 1933 if ((di < 0) || (ch < 0)) {
1929 printk(KERN_WARNING "%s: called with invalid drv(%d) or channel(%d)\n", 1934 printk(KERN_WARNING "%s: called with invalid drv(%d) or channel(%d)\n",
1930 __func__, di, ch); 1935 __func__, di, ch);
1931 return; 1936 return;
1932 } 1937 }
1933 for (i = 0; i < ISDN_MAX_CHANNELS; i++) 1938 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
@@ -1971,7 +1976,7 @@ isdn_unexclusive_channel(int di, int ch)
1971 * writebuf replacement for SKB_ABLE drivers 1976 * writebuf replacement for SKB_ABLE drivers
1972 */ 1977 */
1973static int 1978static int
1974isdn_writebuf_stub(int drvidx, int chan, const u_char __user *buf, int len) 1979isdn_writebuf_stub(int drvidx, int chan, const u_char __user * buf, int len)
1975{ 1980{
1976 int ret; 1981 int ret;
1977 int hl = dev->drv[drvidx]->interface->hl_hdrlen; 1982 int hl = dev->drv[drvidx]->interface->hl_hdrlen;
@@ -2021,8 +2026,8 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb)
2021 } else { 2026 } else {
2022 int hl = dev->drv[drvidx]->interface->hl_hdrlen; 2027 int hl = dev->drv[drvidx]->interface->hl_hdrlen;
2023 2028
2024 if (skb_headroom(skb) < hl) { 2029 if( skb_headroom(skb) < hl ){
2025 /* 2030 /*
2026 * This should only occur when new HL driver with 2031 * This should only occur when new HL driver with
2027 * increased hl_hdrlen was loaded after netdevice 2032 * increased hl_hdrlen was loaded after netdevice
2028 * was created and connected to the new driver. 2033 * was created and connected to the new driver.
@@ -2030,13 +2035,13 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb)
2030 * The V.110 branch (re-allocates on its own) does 2035 * The V.110 branch (re-allocates on its own) does
2031 * not need this 2036 * not need this
2032 */ 2037 */
2033 struct sk_buff *skb_tmp; 2038 struct sk_buff * skb_tmp;
2034 2039
2035 skb_tmp = skb_realloc_headroom(skb, hl); 2040 skb_tmp = skb_realloc_headroom(skb, hl);
2036 printk(KERN_DEBUG "isdn_writebuf_skb_stub: reallocating headroom%s\n", skb_tmp ? "" : " failed"); 2041 printk(KERN_DEBUG "isdn_writebuf_skb_stub: reallocating headroom%s\n", skb_tmp ? "" : " failed");
2037 if (!skb_tmp) return -ENOMEM; /* 0 better? */ 2042 if (!skb_tmp) return -ENOMEM; /* 0 better? */
2038 ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, ack, skb_tmp); 2043 ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, ack, skb_tmp);
2039 if (ret > 0) { 2044 if( ret > 0 ){
2040 dev_kfree_skb(skb); 2045 dev_kfree_skb(skb);
2041 } else { 2046 } else {
2042 dev_kfree_skb(skb_tmp); 2047 dev_kfree_skb(skb_tmp);
@@ -2054,7 +2059,7 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb)
2054 /* For V.110 return unencoded data length */ 2059 /* For V.110 return unencoded data length */
2055 ret = v110_ret; 2060 ret = v110_ret;
2056 /* if the complete frame was send we free the skb; 2061 /* if the complete frame was send we free the skb;
2057 if not upper function will requeue the skb */ 2062 if not upper function will requeue the skb */
2058 if (ret == skb->len) 2063 if (ret == skb->len)
2059 dev_kfree_skb(skb); 2064 dev_kfree_skb(skb);
2060 } 2065 }
@@ -2072,7 +2077,7 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
2072 init_waitqueue_head(&d->st_waitq); 2077 init_waitqueue_head(&d->st_waitq);
2073 if (d->flags & DRV_FLAG_RUNNING) 2078 if (d->flags & DRV_FLAG_RUNNING)
2074 return -1; 2079 return -1;
2075 if (n < 1) return 0; 2080 if (n < 1) return 0;
2076 2081
2077 m = (adding) ? d->channels + n : n; 2082 m = (adding) ? d->channels + n : n;
2078 2083
@@ -2109,7 +2114,7 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
2109 kfree(d->rcvcount); 2114 kfree(d->rcvcount);
2110 kfree(d->rcverr); 2115 kfree(d->rcverr);
2111 } 2116 }
2112 return -1; 2117 return -1;
2113 } 2118 }
2114 for (j = 0; j < m; j++) { 2119 for (j = 0; j < m; j++) {
2115 skb_queue_head_init(&d->rpqueue[j]); 2120 skb_queue_head_init(&d->rpqueue[j]);
@@ -2167,45 +2172,45 @@ set_global_features(void)
2167 2172
2168static char *map_drvname(int di) 2173static char *map_drvname(int di)
2169{ 2174{
2170 if ((di < 0) || (di >= ISDN_MAX_DRIVERS)) 2175 if ((di < 0) || (di >= ISDN_MAX_DRIVERS))
2171 return (NULL); 2176 return(NULL);
2172 return (dev->drvid[di]); /* driver name */ 2177 return(dev->drvid[di]); /* driver name */
2173} /* map_drvname */ 2178} /* map_drvname */
2174 2179
2175static int map_namedrv(char *id) 2180static int map_namedrv(char *id)
2176{ int i; 2181{ int i;
2177 2182
2178 for (i = 0; i < ISDN_MAX_DRIVERS; i++) 2183 for (i = 0; i < ISDN_MAX_DRIVERS; i++)
2179 { if (!strcmp(dev->drvid[i], id)) 2184 { if (!strcmp(dev->drvid[i],id))
2180 return (i); 2185 return(i);
2181 } 2186 }
2182 return (-1); 2187 return(-1);
2183} /* map_namedrv */ 2188} /* map_namedrv */
2184 2189
2185int DIVERT_REG_NAME(isdn_divert_if *i_div) 2190int DIVERT_REG_NAME(isdn_divert_if *i_div)
2186{ 2191{
2187 if (i_div->if_magic != DIVERT_IF_MAGIC) 2192 if (i_div->if_magic != DIVERT_IF_MAGIC)
2188 return (DIVERT_VER_ERR); 2193 return(DIVERT_VER_ERR);
2189 switch (i_div->cmd) 2194 switch (i_div->cmd)
2190 { 2195 {
2191 case DIVERT_CMD_REL: 2196 case DIVERT_CMD_REL:
2192 if (divert_if != i_div) 2197 if (divert_if != i_div)
2193 return (DIVERT_REL_ERR); 2198 return(DIVERT_REL_ERR);
2194 divert_if = NULL; /* free interface */ 2199 divert_if = NULL; /* free interface */
2195 return (DIVERT_NO_ERR); 2200 return(DIVERT_NO_ERR);
2196 2201
2197 case DIVERT_CMD_REG: 2202 case DIVERT_CMD_REG:
2198 if (divert_if) 2203 if (divert_if)
2199 return (DIVERT_REG_ERR); 2204 return(DIVERT_REG_ERR);
2200 i_div->ll_cmd = isdn_command; /* set command function */ 2205 i_div->ll_cmd = isdn_command; /* set command function */
2201 i_div->drv_to_name = map_drvname; 2206 i_div->drv_to_name = map_drvname;
2202 i_div->name_to_drv = map_namedrv; 2207 i_div->name_to_drv = map_namedrv;
2203 divert_if = i_div; /* remember interface */ 2208 divert_if = i_div; /* remember interface */
2204 return (DIVERT_NO_ERR); 2209 return(DIVERT_NO_ERR);
2205 2210
2206 default: 2211 default:
2207 return (DIVERT_CMD_ERR); 2212 return(DIVERT_CMD_ERR);
2208 } 2213 }
2209} /* DIVERT_REG_NAME */ 2214} /* DIVERT_REG_NAME */
2210 2215
2211EXPORT_SYMBOL(DIVERT_REG_NAME); 2216EXPORT_SYMBOL(DIVERT_REG_NAME);
@@ -2220,7 +2225,7 @@ EXPORT_SYMBOL(isdn_ppp_unregister_compressor);
2220#endif 2225#endif
2221 2226
2222int 2227int
2223register_isdn(isdn_if *i) 2228register_isdn(isdn_if * i)
2224{ 2229{
2225 isdn_driver_t *d; 2230 isdn_driver_t *d;
2226 int j; 2231 int j;
@@ -2275,10 +2280,10 @@ register_isdn(isdn_if *i)
2275} 2280}
2276 2281
2277/* 2282/*
2278***************************************************************************** 2283 *****************************************************************************
2279* And now the modules code. 2284 * And now the modules code.
2280***************************************************************************** 2285 *****************************************************************************
2281*/ 2286 */
2282 2287
2283static char * 2288static char *
2284isdn_getrev(const char *revision) 2289isdn_getrev(const char *revision)
@@ -2303,11 +2308,11 @@ static int __init isdn_init(void)
2303 int i; 2308 int i;
2304 char tmprev[50]; 2309 char tmprev[50];
2305 2310
2306 dev = vzalloc(sizeof(isdn_dev)); 2311 if (!(dev = vmalloc(sizeof(isdn_dev)))) {
2307 if (!dev) {
2308 printk(KERN_WARNING "isdn: Could not allocate device-struct.\n"); 2312 printk(KERN_WARNING "isdn: Could not allocate device-struct.\n");
2309 return -EIO; 2313 return -EIO;
2310 } 2314 }
2315 memset((char *) dev, 0, sizeof(isdn_dev));
2311 init_timer(&dev->timer); 2316 init_timer(&dev->timer);
2312 dev->timer.function = isdn_timer_funct; 2317 dev->timer.function = isdn_timer_funct;
2313 spin_lock_init(&dev->lock); 2318 spin_lock_init(&dev->lock);
@@ -2322,6 +2327,8 @@ static int __init isdn_init(void)
2322 dev->chanmap[i] = -1; 2327 dev->chanmap[i] = -1;
2323 dev->m_idx[i] = -1; 2328 dev->m_idx[i] = -1;
2324 strcpy(dev->num[i], "???"); 2329 strcpy(dev->num[i], "???");
2330 init_waitqueue_head(&dev->mdm.info[i].open_wait);
2331 init_waitqueue_head(&dev->mdm.info[i].close_wait);
2325 } 2332 }
2326 if (register_chrdev(ISDN_MAJOR, "isdn", &isdn_fops)) { 2333 if (register_chrdev(ISDN_MAJOR, "isdn", &isdn_fops)) {
2327 printk(KERN_WARNING "isdn: Could not register control devices\n"); 2334 printk(KERN_WARNING "isdn: Could not register control devices\n");
@@ -2346,6 +2353,8 @@ static int __init isdn_init(void)
2346 2353
2347 strcpy(tmprev, isdn_revision); 2354 strcpy(tmprev, isdn_revision);
2348 printk(KERN_NOTICE "ISDN subsystem Rev: %s/", isdn_getrev(tmprev)); 2355 printk(KERN_NOTICE "ISDN subsystem Rev: %s/", isdn_getrev(tmprev));
2356 strcpy(tmprev, isdn_tty_revision);
2357 printk("%s/", isdn_getrev(tmprev));
2349 strcpy(tmprev, isdn_net_revision); 2358 strcpy(tmprev, isdn_net_revision);
2350 printk("%s/", isdn_getrev(tmprev)); 2359 printk("%s/", isdn_getrev(tmprev));
2351 strcpy(tmprev, isdn_ppp_revision); 2360 strcpy(tmprev, isdn_ppp_revision);
diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h
index 9a471f62e1d..082735dbb41 100644
--- a/drivers/isdn/i4l/isdn_common.h
+++ b/drivers/isdn/i4l/isdn_common.h
@@ -29,19 +29,19 @@ extern void isdn_lock_drivers(void);
29extern void isdn_unlock_drivers(void); 29extern void isdn_unlock_drivers(void);
30extern void isdn_free_channel(int di, int ch, int usage); 30extern void isdn_free_channel(int di, int ch, int usage);
31extern void isdn_all_eaz(int di, int ch); 31extern void isdn_all_eaz(int di, int ch);
32extern int isdn_command(isdn_ctrl *); 32extern int isdn_command(isdn_ctrl *);
33extern int isdn_dc2minor(int di, int ch); 33extern int isdn_dc2minor(int di, int ch);
34extern void isdn_info_update(void); 34extern void isdn_info_update(void);
35extern char *isdn_map_eaz2msn(char *msn, int di); 35extern char *isdn_map_eaz2msn(char *msn, int di);
36extern void isdn_timer_ctrl(int tf, int onoff); 36extern void isdn_timer_ctrl(int tf, int onoff);
37extern void isdn_unexclusive_channel(int di, int ch); 37extern void isdn_unexclusive_channel(int di, int ch);
38extern int isdn_getnum(char **); 38extern int isdn_getnum(char **);
39extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); 39extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *);
40extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); 40extern int isdn_readbchan_tty(int, int, struct tty_struct *, int);
41extern int isdn_get_free_channel(int, int, int, int, int, char *); 41extern int isdn_get_free_channel(int, int, int, int, int, char *);
42extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); 42extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *);
43extern int register_isdn(isdn_if *i); 43extern int register_isdn(isdn_if * i);
44extern int isdn_msncmp(const char *, const char *); 44extern int isdn_msncmp( const char *, const char *);
45#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) 45#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP)
46extern void isdn_dumppkt(char *, u_char *, int, int); 46extern void isdn_dumppkt(char *, u_char *, int, int);
47#endif 47#endif
diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
index 91d57304d4d..d568689669f 100644
--- a/drivers/isdn/i4l/isdn_concap.c
+++ b/drivers/isdn/i4l/isdn_concap.c
@@ -1,5 +1,5 @@
1/* $Id: isdn_concap.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $ 1/* $Id: isdn_concap.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $
2 * 2 *
3 * Linux ISDN subsystem, protocol encapsulation 3 * Linux ISDN subsystem, protocol encapsulation
4 * 4 *
5 * This software may be used and distributed according to the terms 5 * This software may be used and distributed according to the terms
@@ -25,57 +25,57 @@
25 protocols that require for reliable datalink semantics. That means: 25 protocols that require for reliable datalink semantics. That means:
26 26
27 - before any data is to be submitted the connection must explicitly 27 - before any data is to be submitted the connection must explicitly
28 be set up. 28 be set up.
29 - after the successful set up of the connection is signalled the 29 - after the successful set up of the connection is signalled the
30 connection is considered to be reliably up. 30 connection is considered to be reliably up.
31 31
32 Auto-dialing ist not compatible with this requirements. Thus, auto-dialing 32 Auto-dialing ist not compatible with this requirements. Thus, auto-dialing
33 is completely bypassed. 33 is completely bypassed.
34 34
35 It might be possible to implement a (non standardized) datalink protocol 35 It might be possible to implement a (non standardized) datalink protocol
36 that provides a reliable data link service while using some auto dialing 36 that provides a reliable data link service while using some auto dialing
37 mechanism. Such a protocol would need an auxiliary channel (i.e. user-user- 37 mechanism. Such a protocol would need an auxiliary channel (i.e. user-user-
38 signaling on the D-channel) while the B-channel is down. 38 signaling on the D-channel) while the B-channel is down.
39*/ 39 */
40 40
41 41
42static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb) 42static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
43{ 43{
44 struct net_device *ndev = concap->net_dev; 44 struct net_device *ndev = concap -> net_dev;
45 isdn_net_dev *nd = ((isdn_net_local *) netdev_priv(ndev))->netdev; 45 isdn_net_dev *nd = ((isdn_net_local *) netdev_priv(ndev))->netdev;
46 isdn_net_local *lp = isdn_net_get_locked_lp(nd); 46 isdn_net_local *lp = isdn_net_get_locked_lp(nd);
47 47
48 IX25DEBUG("isdn_concap_dl_data_req: %s \n", concap->net_dev->name); 48 IX25DEBUG( "isdn_concap_dl_data_req: %s \n", concap->net_dev->name);
49 if (!lp) { 49 if (!lp) {
50 IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 1); 50 IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 1);
51 return 1; 51 return 1;
52 } 52 }
53 lp->huptimer = 0; 53 lp->huptimer = 0;
54 isdn_net_writebuf_skb(lp, skb); 54 isdn_net_writebuf_skb(lp, skb);
55 spin_unlock_bh(&lp->xmit_lock); 55 spin_unlock_bh(&lp->xmit_lock);
56 IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 0); 56 IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 0);
57 return 0; 57 return 0;
58} 58}
59 59
60 60
61static int isdn_concap_dl_connect_req(struct concap_proto *concap) 61static int isdn_concap_dl_connect_req(struct concap_proto *concap)
62{ 62{
63 struct net_device *ndev = concap->net_dev; 63 struct net_device *ndev = concap -> net_dev;
64 isdn_net_local *lp = netdev_priv(ndev); 64 isdn_net_local *lp = netdev_priv(ndev);
65 int ret; 65 int ret;
66 IX25DEBUG("isdn_concap_dl_connect_req: %s \n", ndev->name); 66 IX25DEBUG( "isdn_concap_dl_connect_req: %s \n", ndev -> name);
67 67
68 /* dial ... */ 68 /* dial ... */
69 ret = isdn_net_dial_req(lp); 69 ret = isdn_net_dial_req( lp );
70 if (ret) IX25DEBUG("dialing failed\n"); 70 if ( ret ) IX25DEBUG("dialing failed\n");
71 return ret; 71 return ret;
72} 72}
73 73
74static int isdn_concap_dl_disconn_req(struct concap_proto *concap) 74static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
75{ 75{
76 IX25DEBUG("isdn_concap_dl_disconn_req: %s \n", concap->net_dev->name); 76 IX25DEBUG( "isdn_concap_dl_disconn_req: %s \n", concap -> net_dev -> name);
77 77
78 isdn_net_hangup(concap->net_dev); 78 isdn_net_hangup( concap -> net_dev );
79 return 0; 79 return 0;
80} 80}
81 81
@@ -88,10 +88,10 @@ struct concap_device_ops isdn_concap_reliable_dl_dops = {
88/* The following should better go into a dedicated source file such that 88/* The following should better go into a dedicated source file such that
89 this sourcefile does not need to include any protocol specific header 89 this sourcefile does not need to include any protocol specific header
90 files. For now: 90 files. For now:
91*/ 91 */
92struct concap_proto *isdn_concap_new(int encap) 92struct concap_proto * isdn_concap_new( int encap )
93{ 93{
94 switch (encap) { 94 switch ( encap ) {
95 case ISDN_NET_ENCAP_X25IFACE: 95 case ISDN_NET_ENCAP_X25IFACE:
96 return isdn_x25iface_proto_new(); 96 return isdn_x25iface_proto_new();
97 } 97 }
diff --git a/drivers/isdn/i4l/isdn_concap.h b/drivers/isdn/i4l/isdn_concap.h
index cd7e3ba74e2..6ac7e0445ea 100644
--- a/drivers/isdn/i4l/isdn_concap.h
+++ b/drivers/isdn/i4l/isdn_concap.h
@@ -8,4 +8,6 @@
8 */ 8 */
9 9
10extern struct concap_device_ops isdn_concap_reliable_dl_dops; 10extern struct concap_device_ops isdn_concap_reliable_dl_dops;
11extern struct concap_proto *isdn_concap_new(int); 11extern struct concap_proto * isdn_concap_new( int );
12
13
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index babc621a07f..1f73d7f7e02 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -9,7 +9,7 @@
9 * This software may be used and distributed according to the terms 9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference. 10 * of the GNU General Public License, incorporated herein by reference.
11 * 11 *
12 * Data Over Voice (DOV) support added - Guy Ellis 23-Mar-02 12 * Data Over Voice (DOV) support added - Guy Ellis 23-Mar-02
13 * guy@traverse.com.au 13 * guy@traverse.com.au
14 * Outgoing calls - looks for a 'V' in first char of dialed number 14 * Outgoing calls - looks for a 'V' in first char of dialed number
15 * Incoming calls - checks first character of eaz as follows: 15 * Incoming calls - checks first character of eaz as follows:
@@ -18,7 +18,7 @@
18 * 'B' - accept BOTH DATA and DOV types 18 * 'B' - accept BOTH DATA and DOV types
19 * 19 *
20 * Jan 2001: fix CISCO HDLC Bjoern A. Zeeb <i4l@zabbadoz.net> 20 * Jan 2001: fix CISCO HDLC Bjoern A. Zeeb <i4l@zabbadoz.net>
21 * for info on the protocol, see 21 * for info on the protocol, see
22 * http://i4l.zabbadoz.net/i4l/cisco-hdlc.txt 22 * http://i4l.zabbadoz.net/i4l/cisco-hdlc.txt
23 */ 23 */
24 24
@@ -40,7 +40,7 @@
40 40
41 41
42/* 42/*
43 * Outline of new tbusy handling: 43 * Outline of new tbusy handling:
44 * 44 *
45 * Old method, roughly spoken, consisted of setting tbusy when entering 45 * Old method, roughly spoken, consisted of setting tbusy when entering
46 * isdn_net_start_xmit() and at several other locations and clearing 46 * isdn_net_start_xmit() and at several other locations and clearing
@@ -59,14 +59,14 @@
59 * Most of the changes were pretty obvious and basically done by HE already. 59 * Most of the changes were pretty obvious and basically done by HE already.
60 * 60 *
61 * One problem of the isdn net device code is that is uses struct net_device 61 * One problem of the isdn net device code is that is uses struct net_device
62 * for masters and slaves. However, only master interface are registered to 62 * for masters and slaves. However, only master interface are registered to
63 * the network layer, and therefore, it only makes sense to call netif_* 63 * the network layer, and therefore, it only makes sense to call netif_*
64 * functions on them. 64 * functions on them.
65 * 65 *
66 * --KG 66 * --KG
67 */ 67 */
68 68
69/* 69/*
70 * Find out if the netdevice has been ifup-ed yet. 70 * Find out if the netdevice has been ifup-ed yet.
71 * For slaves, look at the corresponding master. 71 * For slaves, look at the corresponding master.
72 */ 72 */
@@ -74,8 +74,8 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n)
74{ 74{
75 isdn_net_local *lp = n->local; 75 isdn_net_local *lp = n->local;
76 struct net_device *dev; 76 struct net_device *dev;
77 77
78 if (lp->master) 78 if (lp->master)
79 dev = lp->master; 79 dev = lp->master;
80 else 80 else
81 dev = n->dev; 81 dev = n->dev;
@@ -88,7 +88,7 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n)
88 */ 88 */
89static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp) 89static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp)
90{ 90{
91 if (lp->master) 91 if (lp->master)
92 netif_wake_queue(lp->master); 92 netif_wake_queue(lp->master);
93 else 93 else
94 netif_wake_queue(lp->netdev->dev); 94 netif_wake_queue(lp->netdev->dev);
@@ -108,7 +108,7 @@ static __inline__ void isdn_net_device_stop_queue(isdn_net_local *lp)
108 108
109/* 109/*
110 * find out if the net_device which this lp belongs to (lp can be 110 * find out if the net_device which this lp belongs to (lp can be
111 * master or slave) is busy. It's busy iff all (master and slave) 111 * master or slave) is busy. It's busy iff all (master and slave)
112 * queues are busy 112 * queues are busy
113 */ 113 */
114static __inline__ int isdn_net_device_busy(isdn_net_local *lp) 114static __inline__ int isdn_net_device_busy(isdn_net_local *lp)
@@ -124,7 +124,7 @@ static __inline__ int isdn_net_device_busy(isdn_net_local *lp)
124 nd = ISDN_MASTER_PRIV(lp)->netdev; 124 nd = ISDN_MASTER_PRIV(lp)->netdev;
125 else 125 else
126 nd = lp->netdev; 126 nd = lp->netdev;
127 127
128 spin_lock_irqsave(&nd->queue_lock, flags); 128 spin_lock_irqsave(&nd->queue_lock, flags);
129 nlp = lp->next; 129 nlp = lp->next;
130 while (nlp != lp) { 130 while (nlp != lp) {
@@ -155,7 +155,7 @@ static __inline__ void isdn_net_dec_frame_cnt(isdn_net_local *lp)
155 } else { 155 } else {
156 isdn_net_device_wake_queue(lp); 156 isdn_net_device_wake_queue(lp);
157 } 157 }
158 } 158 }
159} 159}
160 160
161static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) 161static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp)
@@ -163,36 +163,36 @@ static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp)
163 atomic_set(&lp->frame_cnt, 0); 163 atomic_set(&lp->frame_cnt, 0);
164} 164}
165 165
166/* For 2.2.x we leave the transmitter busy timeout at 2 secs, just 166/* For 2.2.x we leave the transmitter busy timeout at 2 secs, just
167 * to be safe. 167 * to be safe.
168 * For 2.3.x we push it up to 20 secs, because call establishment 168 * For 2.3.x we push it up to 20 secs, because call establishment
169 * (in particular callback) may take such a long time, and we 169 * (in particular callback) may take such a long time, and we
170 * don't want confusing messages in the log. However, there is a slight 170 * don't want confusing messages in the log. However, there is a slight
171 * possibility that this large timeout will break other things like MPPP, 171 * possibility that this large timeout will break other things like MPPP,
172 * which might rely on the tx timeout. If so, we'll find out this way... 172 * which might rely on the tx timeout. If so, we'll find out this way...
173 */ 173 */
174 174
175#define ISDN_NET_TX_TIMEOUT (20 * HZ) 175#define ISDN_NET_TX_TIMEOUT (20*HZ)
176 176
177/* Prototypes */ 177/* Prototypes */
178 178
179static int isdn_net_force_dial_lp(isdn_net_local *); 179static int isdn_net_force_dial_lp(isdn_net_local *);
180static netdev_tx_t isdn_net_start_xmit(struct sk_buff *, 180static netdev_tx_t isdn_net_start_xmit(struct sk_buff *,
181 struct net_device *); 181 struct net_device *);
182 182
183static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); 183static void isdn_net_ciscohdlck_connected(isdn_net_local *lp);
184static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); 184static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp);
185 185
186char *isdn_net_revision = "$Revision: 1.1.2.2 $"; 186char *isdn_net_revision = "$Revision: 1.1.2.2 $";
187 187
188/* 188 /*
189 * Code for raw-networking over ISDN 189 * Code for raw-networking over ISDN
190 */ 190 */
191 191
192static void 192static void
193isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason) 193isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason)
194{ 194{
195 if (skb) { 195 if(skb) {
196 196
197 u_short proto = ntohs(skb->protocol); 197 u_short proto = ntohs(skb->protocol);
198 198
@@ -200,13 +200,13 @@ isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason)
200 dev->name, 200 dev->name,
201 (reason != NULL) ? reason : "unknown", 201 (reason != NULL) ? reason : "unknown",
202 (proto != ETH_P_IP) ? "Protocol != ETH_P_IP" : ""); 202 (proto != ETH_P_IP) ? "Protocol != ETH_P_IP" : "");
203 203
204 dst_link_failure(skb); 204 dst_link_failure(skb);
205 } 205 }
206 else { /* dial not triggered by rawIP packet */ 206 else { /* dial not triggered by rawIP packet */
207 printk(KERN_DEBUG "isdn_net: %s: %s\n", 207 printk(KERN_DEBUG "isdn_net: %s: %s\n",
208 dev->name, 208 dev->name,
209 (reason != NULL) ? reason : "reason unknown"); 209 (reason != NULL) ? reason : "reason unknown");
210 } 210 }
211} 211}
212 212
@@ -214,14 +214,14 @@ static void
214isdn_net_reset(struct net_device *dev) 214isdn_net_reset(struct net_device *dev)
215{ 215{
216#ifdef CONFIG_ISDN_X25 216#ifdef CONFIG_ISDN_X25
217 struct concap_device_ops *dops = 217 struct concap_device_ops * dops =
218 ((isdn_net_local *)netdev_priv(dev))->dops; 218 ((isdn_net_local *) netdev_priv(dev))->dops;
219 struct concap_proto *cprot = 219 struct concap_proto * cprot =
220 ((isdn_net_local *)netdev_priv(dev))->netdev->cprot; 220 ((isdn_net_local *) netdev_priv(dev))->netdev->cprot;
221#endif 221#endif
222#ifdef CONFIG_ISDN_X25 222#ifdef CONFIG_ISDN_X25
223 if (cprot && cprot->pops && dops) 223 if( cprot && cprot -> pops && dops )
224 cprot->pops->restart(cprot, dev, dops); 224 cprot -> pops -> restart ( cprot, dev, dops );
225#endif 225#endif
226} 226}
227 227
@@ -248,7 +248,7 @@ isdn_net_open(struct net_device *dev)
248 */ 248 */
249 struct in_ifaddr *ifa = in_dev->ifa_list; 249 struct in_ifaddr *ifa = in_dev->ifa_list;
250 if (ifa != NULL) 250 if (ifa != NULL)
251 memcpy(dev->dev_addr + 2, &ifa->ifa_local, 4); 251 memcpy(dev->dev_addr+2, &ifa->ifa_local, 4);
252 } 252 }
253 253
254 /* If this interface has slaves, start them also */ 254 /* If this interface has slaves, start them also */
@@ -267,7 +267,7 @@ isdn_net_open(struct net_device *dev)
267 * Assign an ISDN-channel to a net-interface 267 * Assign an ISDN-channel to a net-interface
268 */ 268 */
269static void 269static void
270isdn_net_bind_channel(isdn_net_local *lp, int idx) 270isdn_net_bind_channel(isdn_net_local * lp, int idx)
271{ 271{
272 lp->flags |= ISDN_NET_CONNECTED; 272 lp->flags |= ISDN_NET_CONNECTED;
273 lp->isdn_device = dev->drvmap[idx]; 273 lp->isdn_device = dev->drvmap[idx];
@@ -280,7 +280,7 @@ isdn_net_bind_channel(isdn_net_local *lp, int idx)
280 * unbind a net-interface (resets interface after an error) 280 * unbind a net-interface (resets interface after an error)
281 */ 281 */
282static void 282static void
283isdn_net_unbind_channel(isdn_net_local *lp) 283isdn_net_unbind_channel(isdn_net_local * lp)
284{ 284{
285 skb_queue_purge(&lp->super_tx_queue); 285 skb_queue_purge(&lp->super_tx_queue);
286 286
@@ -288,7 +288,7 @@ isdn_net_unbind_channel(isdn_net_local *lp)
288 /* Moral equivalent of dev_purge_queues(): 288 /* Moral equivalent of dev_purge_queues():
289 BEWARE! This chunk of code cannot be called from hardware 289 BEWARE! This chunk of code cannot be called from hardware
290 interrupt handler. I hope it is true. --ANK 290 interrupt handler. I hope it is true. --ANK
291 */ 291 */
292 qdisc_reset_all_tx(lp->netdev->dev); 292 qdisc_reset_all_tx(lp->netdev->dev);
293 } 293 }
294 lp->dialstate = 0; 294 lp->dialstate = 0;
@@ -368,7 +368,7 @@ isdn_net_autohup(void)
368 isdn_net_hangup(p->dev); 368 isdn_net_hangup(p->dev);
369 } 369 }
370 370
371 if (dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*l) == ISDN_NET_DM_OFF)) { 371 if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*l) == ISDN_NET_DM_OFF)) {
372 isdn_net_hangup(p->dev); 372 isdn_net_hangup(p->dev);
373 break; 373 break;
374 } 374 }
@@ -403,143 +403,143 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c)
403 struct concap_proto_ops *pops = cprot ? cprot->pops : NULL; 403 struct concap_proto_ops *pops = cprot ? cprot->pops : NULL;
404#endif 404#endif
405 switch (cmd) { 405 switch (cmd) {
406 case ISDN_STAT_BSENT: 406 case ISDN_STAT_BSENT:
407 /* A packet has successfully been sent out */ 407 /* A packet has successfully been sent out */
408 if ((lp->flags & ISDN_NET_CONNECTED) && 408 if ((lp->flags & ISDN_NET_CONNECTED) &&
409 (!lp->dialstate)) { 409 (!lp->dialstate)) {
410 isdn_net_dec_frame_cnt(lp); 410 isdn_net_dec_frame_cnt(lp);
411 lp->stats.tx_packets++; 411 lp->stats.tx_packets++;
412 lp->stats.tx_bytes += c->parm.length; 412 lp->stats.tx_bytes += c->parm.length;
413 } 413 }
414 return 1;
415 case ISDN_STAT_DCONN:
416 /* D-Channel is up */
417 switch (lp->dialstate) {
418 case 4:
419 case 7:
420 case 8:
421 lp->dialstate++;
422 return 1;
423 case 12:
424 lp->dialstate = 5;
425 return 1; 414 return 1;
426 } 415 case ISDN_STAT_DCONN:
427 break; 416 /* D-Channel is up */
428 case ISDN_STAT_DHUP: 417 switch (lp->dialstate) {
429 /* Either D-Channel-hangup or error during dialout */ 418 case 4:
419 case 7:
420 case 8:
421 lp->dialstate++;
422 return 1;
423 case 12:
424 lp->dialstate = 5;
425 return 1;
426 }
427 break;
428 case ISDN_STAT_DHUP:
429 /* Either D-Channel-hangup or error during dialout */
430#ifdef CONFIG_ISDN_X25 430#ifdef CONFIG_ISDN_X25
431 /* If we are not connencted then dialing had 431 /* If we are not connencted then dialing had
432 failed. If there are generic encap protocol 432 failed. If there are generic encap protocol
433 receiver routines signal the closure of 433 receiver routines signal the closure of
434 the link*/ 434 the link*/
435 435
436 if (!(lp->flags & ISDN_NET_CONNECTED) 436 if( !(lp->flags & ISDN_NET_CONNECTED)
437 && pops && pops->disconn_ind) 437 && pops && pops -> disconn_ind )
438 pops->disconn_ind(cprot); 438 pops -> disconn_ind(cprot);
439#endif /* CONFIG_ISDN_X25 */ 439#endif /* CONFIG_ISDN_X25 */
440 if ((!lp->dialstate) && (lp->flags & ISDN_NET_CONNECTED)) { 440 if ((!lp->dialstate) && (lp->flags & ISDN_NET_CONNECTED)) {
441 if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) 441 if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK)
442 isdn_net_ciscohdlck_disconnected(lp); 442 isdn_net_ciscohdlck_disconnected(lp);
443#ifdef CONFIG_ISDN_PPP 443#ifdef CONFIG_ISDN_PPP
444 if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) 444 if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
445 isdn_ppp_free(lp); 445 isdn_ppp_free(lp);
446#endif 446#endif
447 isdn_net_lp_disconnected(lp); 447 isdn_net_lp_disconnected(lp);
448 isdn_all_eaz(lp->isdn_device, lp->isdn_channel); 448 isdn_all_eaz(lp->isdn_device, lp->isdn_channel);
449 printk(KERN_INFO "%s: remote hangup\n", p->dev->name); 449 printk(KERN_INFO "%s: remote hangup\n", p->dev->name);
450 printk(KERN_INFO "%s: Chargesum is %d\n", p->dev->name, 450 printk(KERN_INFO "%s: Chargesum is %d\n", p->dev->name,
451 lp->charge); 451 lp->charge);
452 isdn_net_unbind_channel(lp); 452 isdn_net_unbind_channel(lp);
453 return 1; 453 return 1;
454 } 454 }
455 break; 455 break;
456#ifdef CONFIG_ISDN_X25 456#ifdef CONFIG_ISDN_X25
457 case ISDN_STAT_BHUP: 457 case ISDN_STAT_BHUP:
458 /* B-Channel-hangup */ 458 /* B-Channel-hangup */
459 /* try if there are generic encap protocol 459 /* try if there are generic encap protocol
460 receiver routines and signal the closure of 460 receiver routines and signal the closure of
461 the link */ 461 the link */
462 if (pops && pops->disconn_ind) { 462 if( pops && pops -> disconn_ind ){
463 pops->disconn_ind(cprot); 463 pops -> disconn_ind(cprot);
464 return 1; 464 return 1;
465 }
466 break;
467#endif /* CONFIG_ISDN_X25 */
468 case ISDN_STAT_BCONN:
469 /* B-Channel is up */
470 isdn_net_zero_frame_cnt(lp);
471 switch (lp->dialstate) {
472 case 5:
473 case 6:
474 case 7:
475 case 8:
476 case 9:
477 case 10:
478 case 12:
479 if (lp->dialstate <= 6) {
480 dev->usage[idx] |= ISDN_USAGE_OUTGOING;
481 isdn_info_update();
482 } else
483 dev->rx_netdev[idx] = p;
484 lp->dialstate = 0;
485 isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1);
486 if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK)
487 isdn_net_ciscohdlck_connected(lp);
488 if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) {
489 if (lp->master) { /* is lp a slave? */
490 isdn_net_dev *nd = ISDN_MASTER_PRIV(lp)->netdev;
491 isdn_net_add_to_bundle(nd, lp);
492 } 465 }
493 } 466 break;
494 printk(KERN_INFO "isdn_net: %s connected\n", p->dev->name); 467#endif /* CONFIG_ISDN_X25 */
495 /* If first Chargeinfo comes before B-Channel connect, 468 case ISDN_STAT_BCONN:
496 * we correct the timestamp here. 469 /* B-Channel is up */
497 */ 470 isdn_net_zero_frame_cnt(lp);
498 lp->chargetime = jiffies; 471 switch (lp->dialstate) {
472 case 5:
473 case 6:
474 case 7:
475 case 8:
476 case 9:
477 case 10:
478 case 12:
479 if (lp->dialstate <= 6) {
480 dev->usage[idx] |= ISDN_USAGE_OUTGOING;
481 isdn_info_update();
482 } else
483 dev->rx_netdev[idx] = p;
484 lp->dialstate = 0;
485 isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1);
486 if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK)
487 isdn_net_ciscohdlck_connected(lp);
488 if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) {
489 if (lp->master) { /* is lp a slave? */
490 isdn_net_dev *nd = ISDN_MASTER_PRIV(lp)->netdev;
491 isdn_net_add_to_bundle(nd, lp);
492 }
493 }
494 printk(KERN_INFO "isdn_net: %s connected\n", p->dev->name);
495 /* If first Chargeinfo comes before B-Channel connect,
496 * we correct the timestamp here.
497 */
498 lp->chargetime = jiffies;
499 499
500 /* reset dial-timeout */ 500 /* reset dial-timeout */
501 lp->dialstarted = 0; 501 lp->dialstarted = 0;
502 lp->dialwait_timer = 0; 502 lp->dialwait_timer = 0;
503 503
504#ifdef CONFIG_ISDN_PPP 504#ifdef CONFIG_ISDN_PPP
505 if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) 505 if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
506 isdn_ppp_wakeup_daemon(lp); 506 isdn_ppp_wakeup_daemon(lp);
507#endif 507#endif
508#ifdef CONFIG_ISDN_X25 508#ifdef CONFIG_ISDN_X25
509 /* try if there are generic concap receiver routines */ 509 /* try if there are generic concap receiver routines */
510 if (pops) 510 if( pops )
511 if (pops->connect_ind) 511 if( pops->connect_ind)
512 pops->connect_ind(cprot); 512 pops->connect_ind(cprot);
513#endif /* CONFIG_ISDN_X25 */ 513#endif /* CONFIG_ISDN_X25 */
514 /* ppp needs to do negotiations first */ 514 /* ppp needs to do negotiations first */
515 if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) 515 if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP)
516 isdn_net_device_wake_queue(lp); 516 isdn_net_device_wake_queue(lp);
517 return 1; 517 return 1;
518 } 518 }
519 break; 519 break;
520 case ISDN_STAT_NODCH: 520 case ISDN_STAT_NODCH:
521 /* No D-Channel avail. */ 521 /* No D-Channel avail. */
522 if (lp->dialstate == 4) { 522 if (lp->dialstate == 4) {
523 lp->dialstate--; 523 lp->dialstate--;
524 return 1;
525 }
526 break;
527 case ISDN_STAT_CINF:
528 /* Charge-info from TelCo. Calculate interval between
529 * charge-infos and set timestamp for last info for
530 * usage by isdn_net_autohup()
531 */
532 lp->charge++;
533 if (lp->hupflags & ISDN_HAVECHARGE) {
534 lp->hupflags &= ~ISDN_WAITCHARGE;
535 lp->chargeint = jiffies - lp->chargetime - (2 * HZ);
536 }
537 if (lp->hupflags & ISDN_WAITCHARGE)
538 lp->hupflags |= ISDN_HAVECHARGE;
539 lp->chargetime = jiffies;
540 printk(KERN_DEBUG "isdn_net: Got CINF chargetime of %s now %lu\n",
541 p->dev->name, lp->chargetime);
524 return 1; 542 return 1;
525 }
526 break;
527 case ISDN_STAT_CINF:
528 /* Charge-info from TelCo. Calculate interval between
529 * charge-infos and set timestamp for last info for
530 * usage by isdn_net_autohup()
531 */
532 lp->charge++;
533 if (lp->hupflags & ISDN_HAVECHARGE) {
534 lp->hupflags &= ~ISDN_WAITCHARGE;
535 lp->chargeint = jiffies - lp->chargetime - (2 * HZ);
536 }
537 if (lp->hupflags & ISDN_WAITCHARGE)
538 lp->hupflags |= ISDN_HAVECHARGE;
539 lp->chargetime = jiffies;
540 printk(KERN_DEBUG "isdn_net: Got CINF chargetime of %s now %lu\n",
541 p->dev->name, lp->chargetime);
542 return 1;
543 } 543 }
544 } 544 }
545 return 0; 545 return 0;
@@ -562,7 +562,7 @@ isdn_net_dial(void)
562 int anymore = 0; 562 int anymore = 0;
563 int i; 563 int i;
564 isdn_ctrl cmd; 564 isdn_ctrl cmd;
565 u_char *phone_number; 565 u_char *phone_number;
566 566
567 while (p) { 567 while (p) {
568 isdn_net_local *lp = p->local; 568 isdn_net_local *lp = p->local;
@@ -572,249 +572,249 @@ isdn_net_dial(void)
572 printk(KERN_DEBUG "%s: dialstate=%d\n", p->dev->name, lp->dialstate); 572 printk(KERN_DEBUG "%s: dialstate=%d\n", p->dev->name, lp->dialstate);
573#endif 573#endif
574 switch (lp->dialstate) { 574 switch (lp->dialstate) {
575 case 0: 575 case 0:
576 /* Nothing to do for this interface */ 576 /* Nothing to do for this interface */
577 break;
578 case 1:
579 /* Initiate dialout. Set phone-number-pointer to first number
580 * of interface.
581 */
582 lp->dial = lp->phone[1];
583 if (!lp->dial) {
584 printk(KERN_WARNING "%s: phone number deleted?\n",
585 p->dev->name);
586 isdn_net_hangup(p->dev);
587 break; 577 break;
588 } 578 case 1:
589 anymore = 1; 579 /* Initiate dialout. Set phone-number-pointer to first number
590 580 * of interface.
591 if (lp->dialtimeout > 0) 581 */
592 if (lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) { 582 lp->dial = lp->phone[1];
593 lp->dialstarted = jiffies; 583 if (!lp->dial) {
594 lp->dialwait_timer = 0; 584 printk(KERN_WARNING "%s: phone number deleted?\n",
585 p->dev->name);
586 isdn_net_hangup(p->dev);
587 break;
595 } 588 }
589 anymore = 1;
596 590
597 lp->dialstate++; 591 if(lp->dialtimeout > 0)
598 /* Fall through */ 592 if(lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) {
599 case 2: 593 lp->dialstarted = jiffies;
600 /* Prepare dialing. Clear EAZ, then set EAZ. */ 594 lp->dialwait_timer = 0;
601 cmd.driver = lp->isdn_device;
602 cmd.arg = lp->isdn_channel;
603 cmd.command = ISDN_CMD_CLREAZ;
604 isdn_command(&cmd);
605 sprintf(cmd.parm.num, "%s", isdn_map_eaz2msn(lp->msn, cmd.driver));
606 cmd.command = ISDN_CMD_SETEAZ;
607 isdn_command(&cmd);
608 lp->dialretry = 0;
609 anymore = 1;
610 lp->dialstate++;
611 /* Fall through */
612 case 3:
613 /* Setup interface, dial current phone-number, switch to next number.
614 * If list of phone-numbers is exhausted, increment
615 * retry-counter.
616 */
617 if (dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) {
618 char *s;
619 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
620 s = "dial suppressed: isdn system stopped";
621 else
622 s = "dial suppressed: dialmode `off'";
623 isdn_net_unreachable(p->dev, NULL, s);
624 isdn_net_hangup(p->dev);
625 break;
626 }
627 cmd.driver = lp->isdn_device;
628 cmd.command = ISDN_CMD_SETL2;
629 cmd.arg = lp->isdn_channel + (lp->l2_proto << 8);
630 isdn_command(&cmd);
631 cmd.driver = lp->isdn_device;
632 cmd.command = ISDN_CMD_SETL3;
633 cmd.arg = lp->isdn_channel + (lp->l3_proto << 8);
634 isdn_command(&cmd);
635 cmd.driver = lp->isdn_device;
636 cmd.arg = lp->isdn_channel;
637 if (!lp->dial) {
638 printk(KERN_WARNING "%s: phone number deleted?\n",
639 p->dev->name);
640 isdn_net_hangup(p->dev);
641 break;
642 }
643 if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) {
644 lp->dialstate = 4;
645 printk(KERN_INFO "%s: Open leased line ...\n", p->dev->name);
646 } else {
647 if (lp->dialtimeout > 0)
648 if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) {
649 lp->dialwait_timer = jiffies + lp->dialwait;
650 lp->dialstarted = 0;
651 isdn_net_unreachable(p->dev, NULL, "dial: timed out");
652 isdn_net_hangup(p->dev);
653 break;
654 } 595 }
655 596
597 lp->dialstate++;
598 /* Fall through */
599 case 2:
600 /* Prepare dialing. Clear EAZ, then set EAZ. */
656 cmd.driver = lp->isdn_device; 601 cmd.driver = lp->isdn_device;
657 cmd.command = ISDN_CMD_DIAL; 602 cmd.arg = lp->isdn_channel;
658 cmd.parm.setup.si2 = 0; 603 cmd.command = ISDN_CMD_CLREAZ;
659 604 isdn_command(&cmd);
660 /* check for DOV */ 605 sprintf(cmd.parm.num, "%s", isdn_map_eaz2msn(lp->msn, cmd.driver));
661 phone_number = lp->dial->num; 606 cmd.command = ISDN_CMD_SETEAZ;
662 if ((*phone_number == 'v') || 607 isdn_command(&cmd);
663 (*phone_number == 'V')) { /* DOV call */ 608 lp->dialretry = 0;
664 cmd.parm.setup.si1 = 1; 609 anymore = 1;
665 } else { /* DATA call */ 610 lp->dialstate++;
666 cmd.parm.setup.si1 = 7; 611 /* Fall through */
667 } 612 case 3:
668 613 /* Setup interface, dial current phone-number, switch to next number.
669 strcpy(cmd.parm.setup.phone, phone_number); 614 * If list of phone-numbers is exhausted, increment
670 /* 615 * retry-counter.
671 * Switch to next number or back to start if at end of list.
672 */ 616 */
673 if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { 617 if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) {
674 lp->dial = lp->phone[1]; 618 char *s;
675 lp->dialretry++; 619 if (dev->global_flags & ISDN_GLOBAL_STOPPED)
676 620 s = "dial suppressed: isdn system stopped";
677 if (lp->dialretry > lp->dialmax) { 621 else
678 if (lp->dialtimeout == 0) { 622 s = "dial suppressed: dialmode `off'";
623 isdn_net_unreachable(p->dev, NULL, s);
624 isdn_net_hangup(p->dev);
625 break;
626 }
627 cmd.driver = lp->isdn_device;
628 cmd.command = ISDN_CMD_SETL2;
629 cmd.arg = lp->isdn_channel + (lp->l2_proto << 8);
630 isdn_command(&cmd);
631 cmd.driver = lp->isdn_device;
632 cmd.command = ISDN_CMD_SETL3;
633 cmd.arg = lp->isdn_channel + (lp->l3_proto << 8);
634 isdn_command(&cmd);
635 cmd.driver = lp->isdn_device;
636 cmd.arg = lp->isdn_channel;
637 if (!lp->dial) {
638 printk(KERN_WARNING "%s: phone number deleted?\n",
639 p->dev->name);
640 isdn_net_hangup(p->dev);
641 break;
642 }
643 if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) {
644 lp->dialstate = 4;
645 printk(KERN_INFO "%s: Open leased line ...\n", p->dev->name);
646 } else {
647 if(lp->dialtimeout > 0)
648 if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) {
679 lp->dialwait_timer = jiffies + lp->dialwait; 649 lp->dialwait_timer = jiffies + lp->dialwait;
680 lp->dialstarted = 0; 650 lp->dialstarted = 0;
681 isdn_net_unreachable(p->dev, NULL, "dial: tried all numbers dialmax times"); 651 isdn_net_unreachable(p->dev, NULL, "dial: timed out");
652 isdn_net_hangup(p->dev);
653 break;
682 } 654 }
683 isdn_net_hangup(p->dev); 655
684 break; 656 cmd.driver = lp->isdn_device;
657 cmd.command = ISDN_CMD_DIAL;
658 cmd.parm.setup.si2 = 0;
659
660 /* check for DOV */
661 phone_number = lp->dial->num;
662 if ((*phone_number == 'v') ||
663 (*phone_number == 'V')) { /* DOV call */
664 cmd.parm.setup.si1 = 1;
665 } else { /* DATA call */
666 cmd.parm.setup.si1 = 7;
685 } 667 }
668
669 strcpy(cmd.parm.setup.phone, phone_number);
670 /*
671 * Switch to next number or back to start if at end of list.
672 */
673 if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) {
674 lp->dial = lp->phone[1];
675 lp->dialretry++;
676
677 if (lp->dialretry > lp->dialmax) {
678 if (lp->dialtimeout == 0) {
679 lp->dialwait_timer = jiffies + lp->dialwait;
680 lp->dialstarted = 0;
681 isdn_net_unreachable(p->dev, NULL, "dial: tried all numbers dialmax times");
682 }
683 isdn_net_hangup(p->dev);
684 break;
685 }
686 }
687 sprintf(cmd.parm.setup.eazmsn, "%s",
688 isdn_map_eaz2msn(lp->msn, cmd.driver));
689 i = isdn_dc2minor(lp->isdn_device, lp->isdn_channel);
690 if (i >= 0) {
691 strcpy(dev->num[i], cmd.parm.setup.phone);
692 dev->usage[i] |= ISDN_USAGE_OUTGOING;
693 isdn_info_update();
694 }
695 printk(KERN_INFO "%s: dialing %d %s... %s\n", p->dev->name,
696 lp->dialretry, cmd.parm.setup.phone,
697 (cmd.parm.setup.si1 == 1) ? "DOV" : "");
698 lp->dtimer = 0;
699#ifdef ISDN_DEBUG_NET_DIAL
700 printk(KERN_DEBUG "dial: d=%d c=%d\n", lp->isdn_device,
701 lp->isdn_channel);
702#endif
703 isdn_command(&cmd);
686 } 704 }
687 sprintf(cmd.parm.setup.eazmsn, "%s", 705 lp->huptimer = 0;
688 isdn_map_eaz2msn(lp->msn, cmd.driver)); 706 lp->outgoing = 1;
689 i = isdn_dc2minor(lp->isdn_device, lp->isdn_channel); 707 if (lp->chargeint) {
690 if (i >= 0) { 708 lp->hupflags |= ISDN_HAVECHARGE;
691 strcpy(dev->num[i], cmd.parm.setup.phone); 709 lp->hupflags &= ~ISDN_WAITCHARGE;
692 dev->usage[i] |= ISDN_USAGE_OUTGOING; 710 } else {
693 isdn_info_update(); 711 lp->hupflags |= ISDN_WAITCHARGE;
712 lp->hupflags &= ~ISDN_HAVECHARGE;
694 } 713 }
695 printk(KERN_INFO "%s: dialing %d %s... %s\n", p->dev->name, 714 anymore = 1;
696 lp->dialretry, cmd.parm.setup.phone, 715 lp->dialstate =
697 (cmd.parm.setup.si1 == 1) ? "DOV" : ""); 716 (lp->cbdelay &&
717 (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4;
718 break;
719 case 4:
720 /* Wait for D-Channel-connect.
721 * If timeout, switch back to state 3.
722 * Dialmax-handling moved to state 3.
723 */
724 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10)
725 lp->dialstate = 3;
726 anymore = 1;
727 break;
728 case 5:
729 /* Got D-Channel-Connect, send B-Channel-request */
730 cmd.driver = lp->isdn_device;
731 cmd.arg = lp->isdn_channel;
732 cmd.command = ISDN_CMD_ACCEPTB;
733 anymore = 1;
698 lp->dtimer = 0; 734 lp->dtimer = 0;
699#ifdef ISDN_DEBUG_NET_DIAL 735 lp->dialstate++;
700 printk(KERN_DEBUG "dial: d=%d c=%d\n", lp->isdn_device,
701 lp->isdn_channel);
702#endif
703 isdn_command(&cmd); 736 isdn_command(&cmd);
704 } 737 break;
705 lp->huptimer = 0; 738 case 6:
706 lp->outgoing = 1; 739 /* Wait for B- or D-Channel-connect. If timeout,
707 if (lp->chargeint) { 740 * switch back to state 3.
708 lp->hupflags |= ISDN_HAVECHARGE; 741 */
709 lp->hupflags &= ~ISDN_WAITCHARGE;
710 } else {
711 lp->hupflags |= ISDN_WAITCHARGE;
712 lp->hupflags &= ~ISDN_HAVECHARGE;
713 }
714 anymore = 1;
715 lp->dialstate =
716 (lp->cbdelay &&
717 (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4;
718 break;
719 case 4:
720 /* Wait for D-Channel-connect.
721 * If timeout, switch back to state 3.
722 * Dialmax-handling moved to state 3.
723 */
724 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10)
725 lp->dialstate = 3;
726 anymore = 1;
727 break;
728 case 5:
729 /* Got D-Channel-Connect, send B-Channel-request */
730 cmd.driver = lp->isdn_device;
731 cmd.arg = lp->isdn_channel;
732 cmd.command = ISDN_CMD_ACCEPTB;
733 anymore = 1;
734 lp->dtimer = 0;
735 lp->dialstate++;
736 isdn_command(&cmd);
737 break;
738 case 6:
739 /* Wait for B- or D-Channel-connect. If timeout,
740 * switch back to state 3.
741 */
742#ifdef ISDN_DEBUG_NET_DIAL 742#ifdef ISDN_DEBUG_NET_DIAL
743 printk(KERN_DEBUG "dialtimer2: %d\n", lp->dtimer); 743 printk(KERN_DEBUG "dialtimer2: %d\n", lp->dtimer);
744#endif 744#endif
745 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) 745 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10)
746 lp->dialstate = 3; 746 lp->dialstate = 3;
747 anymore = 1; 747 anymore = 1;
748 break; 748 break;
749 case 7: 749 case 7:
750 /* Got incoming Call, setup L2 and L3 protocols, 750 /* Got incoming Call, setup L2 and L3 protocols,
751 * then wait for D-Channel-connect 751 * then wait for D-Channel-connect
752 */ 752 */
753#ifdef ISDN_DEBUG_NET_DIAL 753#ifdef ISDN_DEBUG_NET_DIAL
754 printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); 754 printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer);
755#endif 755#endif
756 cmd.driver = lp->isdn_device; 756 cmd.driver = lp->isdn_device;
757 cmd.command = ISDN_CMD_SETL2; 757 cmd.command = ISDN_CMD_SETL2;
758 cmd.arg = lp->isdn_channel + (lp->l2_proto << 8); 758 cmd.arg = lp->isdn_channel + (lp->l2_proto << 8);
759 isdn_command(&cmd); 759 isdn_command(&cmd);
760 cmd.driver = lp->isdn_device; 760 cmd.driver = lp->isdn_device;
761 cmd.command = ISDN_CMD_SETL3; 761 cmd.command = ISDN_CMD_SETL3;
762 cmd.arg = lp->isdn_channel + (lp->l3_proto << 8); 762 cmd.arg = lp->isdn_channel + (lp->l3_proto << 8);
763 isdn_command(&cmd); 763 isdn_command(&cmd);
764 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) 764 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15)
765 isdn_net_hangup(p->dev); 765 isdn_net_hangup(p->dev);
766 else { 766 else {
767 anymore = 1;
768 lp->dialstate++;
769 }
770 break;
771 case 9:
772 /* Got incoming D-Channel-Connect, send B-Channel-request */
773 cmd.driver = lp->isdn_device;
774 cmd.arg = lp->isdn_channel;
775 cmd.command = ISDN_CMD_ACCEPTB;
776 isdn_command(&cmd);
767 anymore = 1; 777 anymore = 1;
778 lp->dtimer = 0;
768 lp->dialstate++; 779 lp->dialstate++;
769 } 780 break;
770 break; 781 case 8:
771 case 9: 782 case 10:
772 /* Got incoming D-Channel-Connect, send B-Channel-request */ 783 /* Wait for B- or D-channel-connect */
773 cmd.driver = lp->isdn_device;
774 cmd.arg = lp->isdn_channel;
775 cmd.command = ISDN_CMD_ACCEPTB;
776 isdn_command(&cmd);
777 anymore = 1;
778 lp->dtimer = 0;
779 lp->dialstate++;
780 break;
781 case 8:
782 case 10:
783 /* Wait for B- or D-channel-connect */
784#ifdef ISDN_DEBUG_NET_DIAL 784#ifdef ISDN_DEBUG_NET_DIAL
785 printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); 785 printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer);
786#endif 786#endif
787 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) 787 if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10)
788 isdn_net_hangup(p->dev); 788 isdn_net_hangup(p->dev);
789 else 789 else
790 anymore = 1;
791 break;
792 case 11:
793 /* Callback Delay */
794 if (lp->dtimer++ > lp->cbdelay)
795 lp->dialstate = 1;
790 anymore = 1; 796 anymore = 1;
791 break; 797 break;
792 case 11: 798 case 12:
793 /* Callback Delay */ 799 /* Remote does callback. Hangup after cbdelay, then wait for incoming
794 if (lp->dtimer++ > lp->cbdelay) 800 * call (in state 4).
795 lp->dialstate = 1; 801 */
796 anymore = 1; 802 if (lp->dtimer++ > lp->cbdelay)
797 break; 803 {
798 case 12: 804 printk(KERN_INFO "%s: hangup waiting for callback ...\n", p->dev->name);
799 /* Remote does callback. Hangup after cbdelay, then wait for incoming 805 lp->dtimer = 0;
800 * call (in state 4). 806 lp->dialstate = 4;
801 */ 807 cmd.driver = lp->isdn_device;
802 if (lp->dtimer++ > lp->cbdelay) 808 cmd.command = ISDN_CMD_HANGUP;
803 { 809 cmd.arg = lp->isdn_channel;
804 printk(KERN_INFO "%s: hangup waiting for callback ...\n", p->dev->name); 810 isdn_command(&cmd);
805 lp->dtimer = 0; 811 isdn_all_eaz(lp->isdn_device, lp->isdn_channel);
806 lp->dialstate = 4; 812 }
807 cmd.driver = lp->isdn_device; 813 anymore = 1;
808 cmd.command = ISDN_CMD_HANGUP; 814 break;
809 cmd.arg = lp->isdn_channel; 815 default:
810 isdn_command(&cmd); 816 printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n",
811 isdn_all_eaz(lp->isdn_device, lp->isdn_channel); 817 lp->dialstate, p->dev->name);
812 }
813 anymore = 1;
814 break;
815 default:
816 printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n",
817 lp->dialstate, p->dev->name);
818 } 818 }
819 p = (isdn_net_dev *) p->next; 819 p = (isdn_net_dev *) p->next;
820 } 820 }
@@ -839,8 +839,8 @@ isdn_net_hangup(struct net_device *d)
839 isdn_net_local *slp = ISDN_SLAVE_PRIV(lp); 839 isdn_net_local *slp = ISDN_SLAVE_PRIV(lp);
840 if (slp->flags & ISDN_NET_CONNECTED) { 840 if (slp->flags & ISDN_NET_CONNECTED) {
841 printk(KERN_INFO 841 printk(KERN_INFO
842 "isdn_net: hang up slave %s before %s\n", 842 "isdn_net: hang up slave %s before %s\n",
843 lp->slave->name, d->name); 843 lp->slave->name, d->name);
844 isdn_net_hangup(lp->slave); 844 isdn_net_hangup(lp->slave);
845 } 845 }
846 } 846 }
@@ -854,8 +854,8 @@ isdn_net_hangup(struct net_device *d)
854 /* try if there are generic encap protocol 854 /* try if there are generic encap protocol
855 receiver routines and signal the closure of 855 receiver routines and signal the closure of
856 the link */ 856 the link */
857 if (pops && pops->disconn_ind) 857 if( pops && pops -> disconn_ind )
858 pops->disconn_ind(cprot); 858 pops -> disconn_ind(cprot);
859#endif /* CONFIG_ISDN_X25 */ 859#endif /* CONFIG_ISDN_X25 */
860 860
861 cmd.driver = lp->isdn_device; 861 cmd.driver = lp->isdn_device;
@@ -874,7 +874,7 @@ typedef struct {
874} ip_ports; 874} ip_ports;
875 875
876static void 876static void
877isdn_net_log_skb(struct sk_buff *skb, isdn_net_local *lp) 877isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp)
878{ 878{
879 /* hopefully, this was set correctly */ 879 /* hopefully, this was set correctly */
880 const u_char *p = skb_network_header(skb); 880 const u_char *p = skb_network_header(skb);
@@ -887,72 +887,72 @@ isdn_net_log_skb(struct sk_buff *skb, isdn_net_local *lp)
887 /* This check stolen from 2.1.72 dev_queue_xmit_nit() */ 887 /* This check stolen from 2.1.72 dev_queue_xmit_nit() */
888 if (p < skb->data || skb->network_header >= skb->tail) { 888 if (p < skb->data || skb->network_header >= skb->tail) {
889 /* fall back to old isdn_net_log_packet method() */ 889 /* fall back to old isdn_net_log_packet method() */
890 char *buf = skb->data; 890 char * buf = skb->data;
891 891
892 printk(KERN_DEBUG "isdn_net: protocol %04x is buggy, dev %s\n", skb->protocol, lp->netdev->dev->name); 892 printk(KERN_DEBUG "isdn_net: protocol %04x is buggy, dev %s\n", skb->protocol, lp->netdev->dev->name);
893 p = buf; 893 p = buf;
894 proto = ETH_P_IP; 894 proto = ETH_P_IP;
895 switch (lp->p_encap) { 895 switch (lp->p_encap) {
896 case ISDN_NET_ENCAP_IPTYP: 896 case ISDN_NET_ENCAP_IPTYP:
897 proto = ntohs(*(__be16 *)&buf[0]); 897 proto = ntohs(*(__be16 *)&buf[0]);
898 p = &buf[2]; 898 p = &buf[2];
899 break; 899 break;
900 case ISDN_NET_ENCAP_ETHER: 900 case ISDN_NET_ENCAP_ETHER:
901 proto = ntohs(*(__be16 *)&buf[12]); 901 proto = ntohs(*(__be16 *)&buf[12]);
902 p = &buf[14]; 902 p = &buf[14];
903 break; 903 break;
904 case ISDN_NET_ENCAP_CISCOHDLC: 904 case ISDN_NET_ENCAP_CISCOHDLC:
905 proto = ntohs(*(__be16 *)&buf[2]); 905 proto = ntohs(*(__be16 *)&buf[2]);
906 p = &buf[4]; 906 p = &buf[4];
907 break; 907 break;
908#ifdef CONFIG_ISDN_PPP 908#ifdef CONFIG_ISDN_PPP
909 case ISDN_NET_ENCAP_SYNCPPP: 909 case ISDN_NET_ENCAP_SYNCPPP:
910 proto = ntohs(skb->protocol); 910 proto = ntohs(skb->protocol);
911 p = &buf[IPPP_MAX_HEADER]; 911 p = &buf[IPPP_MAX_HEADER];
912 break; 912 break;
913#endif 913#endif
914 } 914 }
915 } 915 }
916 data_ofs = ((p[0] & 15) * 4); 916 data_ofs = ((p[0] & 15) * 4);
917 switch (proto) { 917 switch (proto) {
918 case ETH_P_IP: 918 case ETH_P_IP:
919 switch (p[9]) { 919 switch (p[9]) {
920 case 1: 920 case 1:
921 strcpy(addinfo, " ICMP"); 921 strcpy(addinfo, " ICMP");
922 break; 922 break;
923 case 2: 923 case 2:
924 strcpy(addinfo, " IGMP"); 924 strcpy(addinfo, " IGMP");
925 break; 925 break;
926 case 4: 926 case 4:
927 strcpy(addinfo, " IPIP"); 927 strcpy(addinfo, " IPIP");
928 break; 928 break;
929 case 6: 929 case 6:
930 ipp = (ip_ports *) (&p[data_ofs]); 930 ipp = (ip_ports *) (&p[data_ofs]);
931 sprintf(addinfo, " TCP, port: %d -> %d", ntohs(ipp->source), 931 sprintf(addinfo, " TCP, port: %d -> %d", ntohs(ipp->source),
932 ntohs(ipp->dest)); 932 ntohs(ipp->dest));
933 break; 933 break;
934 case 8: 934 case 8:
935 strcpy(addinfo, " EGP"); 935 strcpy(addinfo, " EGP");
936 break; 936 break;
937 case 12: 937 case 12:
938 strcpy(addinfo, " PUP"); 938 strcpy(addinfo, " PUP");
939 break; 939 break;
940 case 17: 940 case 17:
941 ipp = (ip_ports *) (&p[data_ofs]); 941 ipp = (ip_ports *) (&p[data_ofs]);
942 sprintf(addinfo, " UDP, port: %d -> %d", ntohs(ipp->source), 942 sprintf(addinfo, " UDP, port: %d -> %d", ntohs(ipp->source),
943 ntohs(ipp->dest)); 943 ntohs(ipp->dest));
944 break;
945 case 22:
946 strcpy(addinfo, " IDP");
947 break;
948 }
949 printk(KERN_INFO "OPEN: %pI4 -> %pI4%s\n",
950 p + 12, p + 16, addinfo);
944 break; 951 break;
945 case 22: 952 case ETH_P_ARP:
946 strcpy(addinfo, " IDP"); 953 printk(KERN_INFO "OPEN: ARP %pI4 -> *.*.*.* ?%pI4\n",
954 p + 14, p + 24);
947 break; 955 break;
948 }
949 printk(KERN_INFO "OPEN: %pI4 -> %pI4%s\n",
950 p + 12, p + 16, addinfo);
951 break;
952 case ETH_P_ARP:
953 printk(KERN_INFO "OPEN: ARP %pI4 -> *.*.*.* ?%pI4\n",
954 p + 14, p + 24);
955 break;
956 } 956 }
957} 957}
958 958
@@ -964,7 +964,7 @@ isdn_net_log_skb(struct sk_buff *skb, isdn_net_local *lp)
964void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb) 964void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb)
965{ 965{
966 if (in_irq()) { 966 if (in_irq()) {
967 // we can't grab the lock from irq context, 967 // we can't grab the lock from irq context,
968 // so we just queue the packet 968 // so we just queue the packet
969 skb_queue_tail(&lp->super_tx_queue, skb); 969 skb_queue_tail(&lp->super_tx_queue, skb);
970 schedule_work(&lp->tqueue); 970 schedule_work(&lp->tqueue);
@@ -993,12 +993,12 @@ static void isdn_net_softint(struct work_struct *work)
993 skb = skb_dequeue(&lp->super_tx_queue); 993 skb = skb_dequeue(&lp->super_tx_queue);
994 if (!skb) 994 if (!skb)
995 break; 995 break;
996 isdn_net_writebuf_skb(lp, skb); 996 isdn_net_writebuf_skb(lp, skb);
997 } 997 }
998 spin_unlock_bh(&lp->xmit_lock); 998 spin_unlock_bh(&lp->xmit_lock);
999} 999}
1000 1000
1001/* 1001/*
1002 * all frames sent from the (net) LL to a HL driver should go via this function 1002 * all frames sent from the (net) LL to a HL driver should go via this function
1003 * it's serialized by the caller holding the lp->xmit_lock spinlock 1003 * it's serialized by the caller holding the lp->xmit_lock spinlock
1004 */ 1004 */
@@ -1024,12 +1024,12 @@ void isdn_net_writebuf_skb(isdn_net_local *lp, struct sk_buff *skb)
1024 printk(KERN_WARNING "%s: HL driver queue full\n", lp->netdev->dev->name); 1024 printk(KERN_WARNING "%s: HL driver queue full\n", lp->netdev->dev->name);
1025 goto error; 1025 goto error;
1026 } 1026 }
1027 1027
1028 lp->transcount += len; 1028 lp->transcount += len;
1029 isdn_net_inc_frame_cnt(lp); 1029 isdn_net_inc_frame_cnt(lp);
1030 return; 1030 return;
1031 1031
1032error: 1032 error:
1033 dev_kfree_skb(skb); 1033 dev_kfree_skb(skb);
1034 lp->stats.tx_errors++; 1034 lp->stats.tx_errors++;
1035 1035
@@ -1129,14 +1129,14 @@ isdn_net_adjust_hdr(struct sk_buff *skb, struct net_device *dev)
1129} 1129}
1130 1130
1131 1131
1132static void isdn_net_tx_timeout(struct net_device *ndev) 1132static void isdn_net_tx_timeout(struct net_device * ndev)
1133{ 1133{
1134 isdn_net_local *lp = netdev_priv(ndev); 1134 isdn_net_local *lp = netdev_priv(ndev);
1135 1135
1136 printk(KERN_WARNING "isdn_tx_timeout dev %s dialstate %d\n", ndev->name, lp->dialstate); 1136 printk(KERN_WARNING "isdn_tx_timeout dev %s dialstate %d\n", ndev->name, lp->dialstate);
1137 if (!lp->dialstate) { 1137 if (!lp->dialstate){
1138 lp->stats.tx_errors++; 1138 lp->stats.tx_errors++;
1139 /* 1139 /*
1140 * There is a certain probability that this currently 1140 * There is a certain probability that this currently
1141 * works at all because if we always wake up the interface, 1141 * works at all because if we always wake up the interface,
1142 * then upper layer will try to send the next packet 1142 * then upper layer will try to send the next packet
@@ -1149,7 +1149,7 @@ static void isdn_net_tx_timeout(struct net_device *ndev)
1149 * 1149 *
1150 * actually, this may not matter at all, because ISDN hardware 1150 * actually, this may not matter at all, because ISDN hardware
1151 * should not see transmitter hangs at all IMO 1151 * should not see transmitter hangs at all IMO
1152 * changed KERN_DEBUG to KERN_WARNING to find out if this is 1152 * changed KERN_DEBUG to KERN_WARNING to find out if this is
1153 * ever called --KG 1153 * ever called --KG
1154 */ 1154 */
1155 } 1155 }
@@ -1167,27 +1167,27 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1167{ 1167{
1168 isdn_net_local *lp = netdev_priv(ndev); 1168 isdn_net_local *lp = netdev_priv(ndev);
1169#ifdef CONFIG_ISDN_X25 1169#ifdef CONFIG_ISDN_X25
1170 struct concap_proto *cprot = lp->netdev->cprot; 1170 struct concap_proto * cprot = lp -> netdev -> cprot;
1171/* At this point hard_start_xmit() passes control to the encapsulation 1171/* At this point hard_start_xmit() passes control to the encapsulation
1172 protocol (if present). 1172 protocol (if present).
1173 For X.25 auto-dialing is completly bypassed because: 1173 For X.25 auto-dialing is completly bypassed because:
1174 - It does not conform with the semantics of a reliable datalink 1174 - It does not conform with the semantics of a reliable datalink
1175 service as needed by X.25 PLP. 1175 service as needed by X.25 PLP.
1176 - I don't want that the interface starts dialing when the network layer 1176 - I don't want that the interface starts dialing when the network layer
1177 sends a message which requests to disconnect the lapb link (or if it 1177 sends a message which requests to disconnect the lapb link (or if it
1178 sends any other message not resulting in data transmission). 1178 sends any other message not resulting in data transmission).
1179 Instead, dialing will be initiated by the encapsulation protocol entity 1179 Instead, dialing will be initiated by the encapsulation protocol entity
1180 when a dl_establish request is received from the upper layer. 1180 when a dl_establish request is received from the upper layer.
1181*/ 1181*/
1182 if (cprot && cprot->pops) { 1182 if (cprot && cprot -> pops) {
1183 int ret = cprot->pops->encap_and_xmit(cprot, skb); 1183 int ret = cprot -> pops -> encap_and_xmit ( cprot , skb);
1184 1184
1185 if (ret) 1185 if (ret)
1186 netif_stop_queue(ndev); 1186 netif_stop_queue(ndev);
1187 return ret; 1187 return ret;
1188 } else 1188 } else
1189#endif 1189#endif
1190 /* auto-dialing xmit function */ 1190 /* auto-dialing xmit function */
1191 { 1191 {
1192#ifdef ISDN_DEBUG_NET_DUMP 1192#ifdef ISDN_DEBUG_NET_DUMP
1193 u_char *buf; 1193 u_char *buf;
@@ -1209,12 +1209,12 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1209 if (lp->phone[1]) { 1209 if (lp->phone[1]) {
1210 ulong flags; 1210 ulong flags;
1211 1211
1212 if (lp->dialwait_timer <= 0) 1212 if(lp->dialwait_timer <= 0)
1213 if (lp->dialstarted > 0 && lp->dialtimeout > 0 && time_before(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) 1213 if(lp->dialstarted > 0 && lp->dialtimeout > 0 && time_before(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait))
1214 lp->dialwait_timer = lp->dialstarted + lp->dialtimeout + lp->dialwait; 1214 lp->dialwait_timer = lp->dialstarted + lp->dialtimeout + lp->dialwait;
1215 1215
1216 if (lp->dialwait_timer > 0) { 1216 if(lp->dialwait_timer > 0) {
1217 if (time_before(jiffies, lp->dialwait_timer)) { 1217 if(time_before(jiffies, lp->dialwait_timer)) {
1218 isdn_net_unreachable(ndev, skb, "dial rejected: retry-time not reached"); 1218 isdn_net_unreachable(ndev, skb, "dial rejected: retry-time not reached");
1219 dev_kfree_skb(skb); 1219 dev_kfree_skb(skb);
1220 return NETDEV_TX_OK; 1220 return NETDEV_TX_OK;
@@ -1224,26 +1224,26 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1224 /* Grab a free ISDN-Channel */ 1224 /* Grab a free ISDN-Channel */
1225 spin_lock_irqsave(&dev->lock, flags); 1225 spin_lock_irqsave(&dev->lock, flags);
1226 if (((chi = 1226 if (((chi =
1227 isdn_get_free_channel( 1227 isdn_get_free_channel(
1228 ISDN_USAGE_NET, 1228 ISDN_USAGE_NET,
1229 lp->l2_proto, 1229 lp->l2_proto,
1230 lp->l3_proto, 1230 lp->l3_proto,
1231 lp->pre_device, 1231 lp->pre_device,
1232 lp->pre_channel, 1232 lp->pre_channel,
1233 lp->msn) 1233 lp->msn)
1234 ) < 0) && 1234 ) < 0) &&
1235 ((chi = 1235 ((chi =
1236 isdn_get_free_channel( 1236 isdn_get_free_channel(
1237 ISDN_USAGE_NET, 1237 ISDN_USAGE_NET,
1238 lp->l2_proto, 1238 lp->l2_proto,
1239 lp->l3_proto, 1239 lp->l3_proto,
1240 lp->pre_device, 1240 lp->pre_device,
1241 lp->pre_channel^1, 1241 lp->pre_channel^1,
1242 lp->msn) 1242 lp->msn)
1243 ) < 0)) { 1243 ) < 0)) {
1244 spin_unlock_irqrestore(&dev->lock, flags); 1244 spin_unlock_irqrestore(&dev->lock, flags);
1245 isdn_net_unreachable(ndev, skb, 1245 isdn_net_unreachable(ndev, skb,
1246 "No channel"); 1246 "No channel");
1247 dev_kfree_skb(skb); 1247 dev_kfree_skb(skb);
1248 return NETDEV_TX_OK; 1248 return NETDEV_TX_OK;
1249 } 1249 }
@@ -1290,13 +1290,13 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1290 return NETDEV_TX_OK; 1290 return NETDEV_TX_OK;
1291 } 1291 }
1292 } else { 1292 } else {
1293 /* Device is connected to an ISDN channel */ 1293 /* Device is connected to an ISDN channel */
1294 ndev->trans_start = jiffies; 1294 ndev->trans_start = jiffies;
1295 if (!lp->dialstate) { 1295 if (!lp->dialstate) {
1296 /* ISDN connection is established, try sending */ 1296 /* ISDN connection is established, try sending */
1297 int ret; 1297 int ret;
1298 ret = (isdn_net_xmit(ndev, skb)); 1298 ret = (isdn_net_xmit(ndev, skb));
1299 if (ret) netif_stop_queue(ndev); 1299 if(ret) netif_stop_queue(ndev);
1300 return ret; 1300 return ret;
1301 } else 1301 } else
1302 netif_stop_queue(ndev); 1302 netif_stop_queue(ndev);
@@ -1313,13 +1313,13 @@ isdn_net_close(struct net_device *dev)
1313{ 1313{
1314 struct net_device *p; 1314 struct net_device *p;
1315#ifdef CONFIG_ISDN_X25 1315#ifdef CONFIG_ISDN_X25
1316 struct concap_proto *cprot = 1316 struct concap_proto * cprot =
1317 ((isdn_net_local *)netdev_priv(dev))->netdev->cprot; 1317 ((isdn_net_local *) netdev_priv(dev))->netdev->cprot;
1318 /* printk(KERN_DEBUG "isdn_net_close %s\n" , dev-> name); */ 1318 /* printk(KERN_DEBUG "isdn_net_close %s\n" , dev-> name ); */
1319#endif 1319#endif
1320 1320
1321#ifdef CONFIG_ISDN_X25 1321#ifdef CONFIG_ISDN_X25
1322 if (cprot && cprot->pops) cprot->pops->close(cprot); 1322 if( cprot && cprot -> pops ) cprot -> pops -> close( cprot );
1323#endif 1323#endif
1324 netif_stop_queue(dev); 1324 netif_stop_queue(dev);
1325 p = MASTER_TO_SLAVE(dev); 1325 p = MASTER_TO_SLAVE(dev);
@@ -1327,10 +1327,10 @@ isdn_net_close(struct net_device *dev)
1327 /* If this interface has slaves, stop them also */ 1327 /* If this interface has slaves, stop them also */
1328 while (p) { 1328 while (p) {
1329#ifdef CONFIG_ISDN_X25 1329#ifdef CONFIG_ISDN_X25
1330 cprot = ((isdn_net_local *)netdev_priv(p)) 1330 cprot = ((isdn_net_local *) netdev_priv(p))
1331 ->netdev->cprot; 1331 -> netdev -> cprot;
1332 if (cprot && cprot->pops) 1332 if( cprot && cprot -> pops )
1333 cprot->pops->close(cprot); 1333 cprot -> pops -> close( cprot );
1334#endif 1334#endif
1335 isdn_net_hangup(p); 1335 isdn_net_hangup(p);
1336 p = MASTER_TO_SLAVE(p); 1336 p = MASTER_TO_SLAVE(p);
@@ -1405,7 +1405,7 @@ isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev)
1405} 1405}
1406 1406
1407 1407
1408/* 1408/*
1409 * CISCO HDLC keepalive specific stuff 1409 * CISCO HDLC keepalive specific stuff
1410 */ 1410 */
1411static struct sk_buff* 1411static struct sk_buff*
@@ -1417,7 +1417,7 @@ isdn_net_ciscohdlck_alloc_skb(isdn_net_local *lp, int len)
1417 skb = alloc_skb(hl + len, GFP_ATOMIC); 1417 skb = alloc_skb(hl + len, GFP_ATOMIC);
1418 if (skb) 1418 if (skb)
1419 skb_reserve(skb, hl); 1419 skb_reserve(skb, hl);
1420 else 1420 else
1421 printk("isdn out of mem at %s:%d!\n", __FILE__, __LINE__); 1421 printk("isdn out of mem at %s:%d!\n", __FILE__, __LINE__);
1422 return skb; 1422 return skb;
1423} 1423}
@@ -1439,52 +1439,52 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1439 1439
1440 switch (cmd) { 1440 switch (cmd) {
1441 /* get/set keepalive period */ 1441 /* get/set keepalive period */
1442 case SIOCGKEEPPERIOD: 1442 case SIOCGKEEPPERIOD:
1443 len = (unsigned long)sizeof(lp->cisco_keepalive_period); 1443 len = (unsigned long)sizeof(lp->cisco_keepalive_period);
1444 if (copy_to_user(ifr->ifr_data, 1444 if (copy_to_user(ifr->ifr_data,
1445 &lp->cisco_keepalive_period, len)) 1445 &lp->cisco_keepalive_period, len))
1446 rc = -EFAULT; 1446 rc = -EFAULT;
1447 break; 1447 break;
1448 case SIOCSKEEPPERIOD: 1448 case SIOCSKEEPPERIOD:
1449 tmp = lp->cisco_keepalive_period; 1449 tmp = lp->cisco_keepalive_period;
1450 len = (unsigned long)sizeof(lp->cisco_keepalive_period); 1450 len = (unsigned long)sizeof(lp->cisco_keepalive_period);
1451 if (copy_from_user(&period, ifr->ifr_data, len)) 1451 if (copy_from_user(&period, ifr->ifr_data, len))
1452 rc = -EFAULT; 1452 rc = -EFAULT;
1453 if ((period > 0) && (period <= 32767)) 1453 if ((period > 0) && (period <= 32767))
1454 lp->cisco_keepalive_period = period; 1454 lp->cisco_keepalive_period = period;
1455 else 1455 else
1456 rc = -EINVAL; 1456 rc = -EINVAL;
1457 if (!rc && (tmp != lp->cisco_keepalive_period)) { 1457 if (!rc && (tmp != lp->cisco_keepalive_period)) {
1458 expires = (unsigned long)(jiffies + 1458 expires = (unsigned long)(jiffies +
1459 lp->cisco_keepalive_period * HZ); 1459 lp->cisco_keepalive_period * HZ);
1460 mod_timer(&lp->cisco_timer, expires); 1460 mod_timer(&lp->cisco_timer, expires);
1461 printk(KERN_INFO "%s: Keepalive period set " 1461 printk(KERN_INFO "%s: Keepalive period set "
1462 "to %d seconds.\n", 1462 "to %d seconds.\n",
1463 dev->name, lp->cisco_keepalive_period); 1463 dev->name, lp->cisco_keepalive_period);
1464 } 1464 }
1465 break; 1465 break;
1466 1466
1467 /* get/set debugging */ 1467 /* get/set debugging */
1468 case SIOCGDEBSERINT: 1468 case SIOCGDEBSERINT:
1469 len = (unsigned long)sizeof(lp->cisco_debserint); 1469 len = (unsigned long)sizeof(lp->cisco_debserint);
1470 if (copy_to_user(ifr->ifr_data, 1470 if (copy_to_user(ifr->ifr_data,
1471 &lp->cisco_debserint, len)) 1471 &lp->cisco_debserint, len))
1472 rc = -EFAULT; 1472 rc = -EFAULT;
1473 break; 1473 break;
1474 case SIOCSDEBSERINT: 1474 case SIOCSDEBSERINT:
1475 len = (unsigned long)sizeof(lp->cisco_debserint); 1475 len = (unsigned long)sizeof(lp->cisco_debserint);
1476 if (copy_from_user(&debserint, 1476 if (copy_from_user(&debserint,
1477 ifr->ifr_data, len)) 1477 ifr->ifr_data, len))
1478 rc = -EFAULT; 1478 rc = -EFAULT;
1479 if ((debserint >= 0) && (debserint <= 64)) 1479 if ((debserint >= 0) && (debserint <= 64))
1480 lp->cisco_debserint = debserint; 1480 lp->cisco_debserint = debserint;
1481 else 1481 else
1482 rc = -EINVAL; 1482 rc = -EINVAL;
1483 break; 1483 break;
1484 1484
1485 default: 1485 default:
1486 rc = -EINVAL; 1486 rc = -EINVAL;
1487 break; 1487 break;
1488 } 1488 }
1489 return (rc); 1489 return (rc);
1490} 1490}
@@ -1524,30 +1524,30 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
1524 lp->cisco_myseq++; 1524 lp->cisco_myseq++;
1525 1525
1526 myseq_diff = (lp->cisco_myseq - lp->cisco_mineseen); 1526 myseq_diff = (lp->cisco_myseq - lp->cisco_mineseen);
1527 if ((lp->cisco_line_state) && ((myseq_diff >= 3) || (myseq_diff <= -3))) { 1527 if ((lp->cisco_line_state) && ((myseq_diff >= 3)||(myseq_diff <= -3))) {
1528 /* line up -> down */ 1528 /* line up -> down */
1529 lp->cisco_line_state = 0; 1529 lp->cisco_line_state = 0;
1530 printk(KERN_WARNING 1530 printk (KERN_WARNING
1531 "UPDOWN: Line protocol on Interface %s," 1531 "UPDOWN: Line protocol on Interface %s,"
1532 " changed state to down\n", lp->netdev->dev->name); 1532 " changed state to down\n", lp->netdev->dev->name);
1533 /* should stop routing higher-level data across */ 1533 /* should stop routing higher-level data across */
1534 } else if ((!lp->cisco_line_state) && 1534 } else if ((!lp->cisco_line_state) &&
1535 (myseq_diff >= 0) && (myseq_diff <= 2)) { 1535 (myseq_diff >= 0) && (myseq_diff <= 2)) {
1536 /* line down -> up */ 1536 /* line down -> up */
1537 lp->cisco_line_state = 1; 1537 lp->cisco_line_state = 1;
1538 printk(KERN_WARNING 1538 printk (KERN_WARNING
1539 "UPDOWN: Line protocol on Interface %s," 1539 "UPDOWN: Line protocol on Interface %s,"
1540 " changed state to up\n", lp->netdev->dev->name); 1540 " changed state to up\n", lp->netdev->dev->name);
1541 /* restart routing higher-level data across */ 1541 /* restart routing higher-level data across */
1542 } 1542 }
1543 1543
1544 if (lp->cisco_debserint) 1544 if (lp->cisco_debserint)
1545 printk(KERN_DEBUG "%s: HDLC " 1545 printk (KERN_DEBUG "%s: HDLC "
1546 "myseq %lu, mineseen %lu%c, yourseen %lu, %s\n", 1546 "myseq %lu, mineseen %lu%c, yourseen %lu, %s\n",
1547 lp->netdev->dev->name, last_cisco_myseq, lp->cisco_mineseen, 1547 lp->netdev->dev->name, last_cisco_myseq, lp->cisco_mineseen,
1548 ((last_cisco_myseq == lp->cisco_mineseen) ? '*' : 040), 1548 ((last_cisco_myseq == lp->cisco_mineseen) ? '*' : 040),
1549 lp->cisco_yourseq, 1549 lp->cisco_yourseq,
1550 ((lp->cisco_line_state) ? "line up" : "line down")); 1550 ((lp->cisco_line_state) ? "line up" : "line down"));
1551 1551
1552 skb = isdn_net_ciscohdlck_alloc_skb(lp, 4 + 14); 1552 skb = isdn_net_ciscohdlck_alloc_skb(lp, 4 + 14);
1553 if (!skb) 1553 if (!skb)
@@ -1570,7 +1570,7 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
1570 isdn_net_write_super(lp, skb); 1570 isdn_net_write_super(lp, skb);
1571 1571
1572 lp->cisco_timer.expires = jiffies + lp->cisco_keepalive_period * HZ; 1572 lp->cisco_timer.expires = jiffies + lp->cisco_keepalive_period * HZ;
1573 1573
1574 add_timer(&lp->cisco_timer); 1574 add_timer(&lp->cisco_timer);
1575} 1575}
1576 1576
@@ -1601,7 +1601,7 @@ isdn_net_ciscohdlck_slarp_send_request(isdn_net_local *lp)
1601 isdn_net_write_super(lp, skb); 1601 isdn_net_write_super(lp, skb);
1602} 1602}
1603 1603
1604static void 1604static void
1605isdn_net_ciscohdlck_connected(isdn_net_local *lp) 1605isdn_net_ciscohdlck_connected(isdn_net_local *lp)
1606{ 1606{
1607 lp->cisco_myseq = 0; 1607 lp->cisco_myseq = 0;
@@ -1622,7 +1622,7 @@ isdn_net_ciscohdlck_connected(isdn_net_local *lp)
1622 add_timer(&lp->cisco_timer); 1622 add_timer(&lp->cisco_timer);
1623} 1623}
1624 1624
1625static void 1625static void
1626isdn_net_ciscohdlck_disconnected(isdn_net_local *lp) 1626isdn_net_ciscohdlck_disconnected(isdn_net_local *lp)
1627{ 1627{
1628 del_timer(&lp->cisco_timer); 1628 del_timer(&lp->cisco_timer);
@@ -1703,20 +1703,20 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
1703 printk(KERN_INFO "%s: got slarp reply: remote ip: %pI4, local ip: %pI4 mask: %pI4\n", 1703 printk(KERN_INFO "%s: got slarp reply: remote ip: %pI4, local ip: %pI4 mask: %pI4\n",
1704 lp->netdev->dev->name, addr, &local, mask); 1704 lp->netdev->dev->name, addr, &local, mask);
1705 break; 1705 break;
1706 slarp_reply_out: 1706 slarp_reply_out:
1707 printk(KERN_INFO "%s: got invalid slarp reply (%pI4/%pI4) - ignored\n", 1707 printk(KERN_INFO "%s: got invalid slarp reply (%pI4/%pI4) - ignored\n",
1708 lp->netdev->dev->name, addr, mask); 1708 lp->netdev->dev->name, addr, mask);
1709 break; 1709 break;
1710 case CISCO_SLARP_KEEPALIVE: 1710 case CISCO_SLARP_KEEPALIVE:
1711 period = (int)((jiffies - lp->cisco_last_slarp_in 1711 period = (int)((jiffies - lp->cisco_last_slarp_in
1712 + HZ / 2 - 1) / HZ); 1712 + HZ/2 - 1) / HZ);
1713 if (lp->cisco_debserint && 1713 if (lp->cisco_debserint &&
1714 (period != lp->cisco_keepalive_period) && 1714 (period != lp->cisco_keepalive_period) &&
1715 lp->cisco_last_slarp_in) { 1715 lp->cisco_last_slarp_in) {
1716 printk(KERN_DEBUG "%s: Keepalive period mismatch - " 1716 printk(KERN_DEBUG "%s: Keepalive period mismatch - "
1717 "is %d but should be %d.\n", 1717 "is %d but should be %d.\n",
1718 lp->netdev->dev->name, period, 1718 lp->netdev->dev->name, period,
1719 lp->cisco_keepalive_period); 1719 lp->cisco_keepalive_period);
1720 } 1720 }
1721 lp->cisco_last_slarp_in = jiffies; 1721 lp->cisco_last_slarp_in = jiffies;
1722 my_seq = be32_to_cpup((__be32 *)(p + 0)); 1722 my_seq = be32_to_cpup((__be32 *)(p + 0));
@@ -1732,10 +1732,10 @@ static void
1732isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb) 1732isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb)
1733{ 1733{
1734 unsigned char *p; 1734 unsigned char *p;
1735 u8 addr; 1735 u8 addr;
1736 u8 ctrl; 1736 u8 ctrl;
1737 u16 type; 1737 u16 type;
1738 1738
1739 if (skb->len < 4) 1739 if (skb->len < 4)
1740 goto out_free; 1740 goto out_free;
1741 1741
@@ -1745,7 +1745,7 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb)
1745 type = be16_to_cpup((__be16 *)(p + 2)); 1745 type = be16_to_cpup((__be16 *)(p + 2));
1746 p += 4; 1746 p += 4;
1747 skb_pull(skb, 4); 1747 skb_pull(skb, 4);
1748 1748
1749 if (addr != CISCO_ADDR_UNICAST && addr != CISCO_ADDR_BROADCAST) { 1749 if (addr != CISCO_ADDR_UNICAST && addr != CISCO_ADDR_BROADCAST) {
1750 printk(KERN_WARNING "%s: Unknown Cisco addr 0x%02x\n", 1750 printk(KERN_WARNING "%s: Unknown Cisco addr 0x%02x\n",
1751 lp->netdev->dev->name, addr); 1751 lp->netdev->dev->name, addr);
@@ -1764,8 +1764,8 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb)
1764 case CISCO_TYPE_CDP: 1764 case CISCO_TYPE_CDP:
1765 if (lp->cisco_debserint) 1765 if (lp->cisco_debserint)
1766 printk(KERN_DEBUG "%s: Received CDP packet. use " 1766 printk(KERN_DEBUG "%s: Received CDP packet. use "
1767 "\"no cdp enable\" on cisco.\n", 1767 "\"no cdp enable\" on cisco.\n",
1768 lp->netdev->dev->name); 1768 lp->netdev->dev->name);
1769 goto out_free; 1769 goto out_free;
1770 default: 1770 default:
1771 /* no special cisco protocol */ 1771 /* no special cisco protocol */
@@ -1774,7 +1774,7 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb)
1774 return; 1774 return;
1775 } 1775 }
1776 1776
1777out_free: 1777 out_free:
1778 kfree_skb(skb); 1778 kfree_skb(skb);
1779} 1779}
1780 1780
@@ -1787,7 +1787,7 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb)
1787 isdn_net_local *lp = netdev_priv(ndev); 1787 isdn_net_local *lp = netdev_priv(ndev);
1788 isdn_net_local *olp = lp; /* original 'lp' */ 1788 isdn_net_local *olp = lp; /* original 'lp' */
1789#ifdef CONFIG_ISDN_X25 1789#ifdef CONFIG_ISDN_X25
1790 struct concap_proto *cprot = lp->netdev->cprot; 1790 struct concap_proto *cprot = lp -> netdev -> cprot;
1791#endif 1791#endif
1792 lp->transcount += skb->len; 1792 lp->transcount += skb->len;
1793 1793
@@ -1809,60 +1809,60 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb)
1809 isdn_dumppkt("R:", skb->data, skb->len, 40); 1809 isdn_dumppkt("R:", skb->data, skb->len, 40);
1810#endif 1810#endif
1811 switch (lp->p_encap) { 1811 switch (lp->p_encap) {
1812 case ISDN_NET_ENCAP_ETHER: 1812 case ISDN_NET_ENCAP_ETHER:
1813 /* Ethernet over ISDN */ 1813 /* Ethernet over ISDN */
1814 olp->huptimer = 0; 1814 olp->huptimer = 0;
1815 lp->huptimer = 0; 1815 lp->huptimer = 0;
1816 skb->protocol = isdn_net_type_trans(skb, ndev); 1816 skb->protocol = isdn_net_type_trans(skb, ndev);
1817 break; 1817 break;
1818 case ISDN_NET_ENCAP_UIHDLC: 1818 case ISDN_NET_ENCAP_UIHDLC:
1819 /* HDLC with UI-frame (for ispa with -h1 option) */ 1819 /* HDLC with UI-frame (for ispa with -h1 option) */
1820 olp->huptimer = 0; 1820 olp->huptimer = 0;
1821 lp->huptimer = 0; 1821 lp->huptimer = 0;
1822 skb_pull(skb, 2); 1822 skb_pull(skb, 2);
1823 /* Fall through */ 1823 /* Fall through */
1824 case ISDN_NET_ENCAP_RAWIP: 1824 case ISDN_NET_ENCAP_RAWIP:
1825 /* RAW-IP without MAC-Header */ 1825 /* RAW-IP without MAC-Header */
1826 olp->huptimer = 0; 1826 olp->huptimer = 0;
1827 lp->huptimer = 0; 1827 lp->huptimer = 0;
1828 skb->protocol = htons(ETH_P_IP); 1828 skb->protocol = htons(ETH_P_IP);
1829 break; 1829 break;
1830 case ISDN_NET_ENCAP_CISCOHDLCK: 1830 case ISDN_NET_ENCAP_CISCOHDLCK:
1831 isdn_net_ciscohdlck_receive(lp, skb); 1831 isdn_net_ciscohdlck_receive(lp, skb);
1832 return; 1832 return;
1833 case ISDN_NET_ENCAP_CISCOHDLC: 1833 case ISDN_NET_ENCAP_CISCOHDLC:
1834 /* CISCO-HDLC IP with type field and fake I-frame-header */ 1834 /* CISCO-HDLC IP with type field and fake I-frame-header */
1835 skb_pull(skb, 2); 1835 skb_pull(skb, 2);
1836 /* Fall through */ 1836 /* Fall through */
1837 case ISDN_NET_ENCAP_IPTYP: 1837 case ISDN_NET_ENCAP_IPTYP:
1838 /* IP with type field */ 1838 /* IP with type field */
1839 olp->huptimer = 0; 1839 olp->huptimer = 0;
1840 lp->huptimer = 0; 1840 lp->huptimer = 0;
1841 skb->protocol = *(__be16 *)&(skb->data[0]); 1841 skb->protocol = *(__be16 *)&(skb->data[0]);
1842 skb_pull(skb, 2); 1842 skb_pull(skb, 2);
1843 if (*(unsigned short *) skb->data == 0xFFFF) 1843 if (*(unsigned short *) skb->data == 0xFFFF)
1844 skb->protocol = htons(ETH_P_802_3); 1844 skb->protocol = htons(ETH_P_802_3);
1845 break; 1845 break;
1846#ifdef CONFIG_ISDN_PPP 1846#ifdef CONFIG_ISDN_PPP
1847 case ISDN_NET_ENCAP_SYNCPPP: 1847 case ISDN_NET_ENCAP_SYNCPPP:
1848 /* huptimer is done in isdn_ppp_push_higher */ 1848 /* huptimer is done in isdn_ppp_push_higher */
1849 isdn_ppp_receive(lp->netdev, olp, skb); 1849 isdn_ppp_receive(lp->netdev, olp, skb);
1850 return; 1850 return;
1851#endif 1851#endif
1852 1852
1853 default: 1853 default:
1854#ifdef CONFIG_ISDN_X25 1854#ifdef CONFIG_ISDN_X25
1855 /* try if there are generic sync_device receiver routines */ 1855 /* try if there are generic sync_device receiver routines */
1856 if (cprot) if (cprot->pops) 1856 if(cprot) if(cprot -> pops)
1857 if (cprot->pops->data_ind) { 1857 if( cprot -> pops -> data_ind){
1858 cprot->pops->data_ind(cprot, skb); 1858 cprot -> pops -> data_ind(cprot,skb);
1859 return; 1859 return;
1860 }; 1860 };
1861#endif /* CONFIG_ISDN_X25 */ 1861#endif /* CONFIG_ISDN_X25 */
1862 printk(KERN_WARNING "%s: unknown encapsulation, dropping\n", 1862 printk(KERN_WARNING "%s: unknown encapsulation, dropping\n",
1863 lp->netdev->dev->name); 1863 lp->netdev->dev->name);
1864 kfree_skb(skb); 1864 kfree_skb(skb);
1865 return; 1865 return;
1866 } 1866 }
1867 1867
1868 netif_rx(skb); 1868 netif_rx(skb);
@@ -1901,51 +1901,51 @@ static int isdn_net_header(struct sk_buff *skb, struct net_device *dev,
1901{ 1901{
1902 isdn_net_local *lp = netdev_priv(dev); 1902 isdn_net_local *lp = netdev_priv(dev);
1903 unsigned char *p; 1903 unsigned char *p;
1904 int len = 0; 1904 ushort len = 0;
1905 1905
1906 switch (lp->p_encap) { 1906 switch (lp->p_encap) {
1907 case ISDN_NET_ENCAP_ETHER: 1907 case ISDN_NET_ENCAP_ETHER:
1908 len = eth_header(skb, dev, type, daddr, saddr, plen); 1908 len = eth_header(skb, dev, type, daddr, saddr, plen);
1909 break; 1909 break;
1910#ifdef CONFIG_ISDN_PPP 1910#ifdef CONFIG_ISDN_PPP
1911 case ISDN_NET_ENCAP_SYNCPPP: 1911 case ISDN_NET_ENCAP_SYNCPPP:
1912 /* stick on a fake header to keep fragmentation code happy. */ 1912 /* stick on a fake header to keep fragmentation code happy. */
1913 len = IPPP_MAX_HEADER; 1913 len = IPPP_MAX_HEADER;
1914 skb_push(skb, len); 1914 skb_push(skb,len);
1915 break; 1915 break;
1916#endif 1916#endif
1917 case ISDN_NET_ENCAP_RAWIP: 1917 case ISDN_NET_ENCAP_RAWIP:
1918 printk(KERN_WARNING "isdn_net_header called with RAW_IP!\n"); 1918 printk(KERN_WARNING "isdn_net_header called with RAW_IP!\n");
1919 len = 0;
1920 break;
1921 case ISDN_NET_ENCAP_IPTYP:
1922 /* ethernet type field */
1923 *((__be16 *)skb_push(skb, 2)) = htons(type);
1924 len = 2;
1925 break;
1926 case ISDN_NET_ENCAP_UIHDLC:
1927 /* HDLC with UI-Frames (for ispa with -h1 option) */
1928 *((__be16 *)skb_push(skb, 2)) = htons(0x0103);
1929 len = 2;
1930 break;
1931 case ISDN_NET_ENCAP_CISCOHDLC:
1932 case ISDN_NET_ENCAP_CISCOHDLCK:
1933 p = skb_push(skb, 4);
1934 *(u8 *)(p + 0) = CISCO_ADDR_UNICAST;
1935 *(u8 *)(p + 1) = CISCO_CTRL;
1936 *(__be16 *)(p + 2) = cpu_to_be16(type);
1937 p += 4;
1938 len = 4;
1939 break;
1940#ifdef CONFIG_ISDN_X25
1941 default:
1942 /* try if there are generic concap protocol routines */
1943 if (lp->netdev->cprot) {
1944 printk(KERN_WARNING "isdn_net_header called with concap_proto!\n");
1945 len = 0; 1919 len = 0;
1946 break; 1920 break;
1947 } 1921 case ISDN_NET_ENCAP_IPTYP:
1948 break; 1922 /* ethernet type field */
1923 *((__be16 *)skb_push(skb, 2)) = htons(type);
1924 len = 2;
1925 break;
1926 case ISDN_NET_ENCAP_UIHDLC:
1927 /* HDLC with UI-Frames (for ispa with -h1 option) */
1928 *((__be16 *)skb_push(skb, 2)) = htons(0x0103);
1929 len = 2;
1930 break;
1931 case ISDN_NET_ENCAP_CISCOHDLC:
1932 case ISDN_NET_ENCAP_CISCOHDLCK:
1933 p = skb_push(skb, 4);
1934 *(u8 *)(p + 0) = CISCO_ADDR_UNICAST;
1935 *(u8 *)(p + 1) = CISCO_CTRL;
1936 *(__be16 *)(p + 2) = cpu_to_be16(type);
1937 p += 4;
1938 len = 4;
1939 break;
1940#ifdef CONFIG_ISDN_X25
1941 default:
1942 /* try if there are generic concap protocol routines */
1943 if( lp-> netdev -> cprot ){
1944 printk(KERN_WARNING "isdn_net_header called with concap_proto!\n");
1945 len = 0;
1946 break;
1947 }
1948 break;
1949#endif /* CONFIG_ISDN_X25 */ 1949#endif /* CONFIG_ISDN_X25 */
1950 } 1950 }
1951 return len; 1951 return len;
@@ -2045,12 +2045,12 @@ isdn_net_swapbind(int drvidx)
2045 while (p) { 2045 while (p) {
2046 if (p->local->pre_device == drvidx) 2046 if (p->local->pre_device == drvidx)
2047 switch (p->local->pre_channel) { 2047 switch (p->local->pre_channel) {
2048 case 0: 2048 case 0:
2049 p->local->pre_channel = 1; 2049 p->local->pre_channel = 1;
2050 break; 2050 break;
2051 case 1: 2051 case 1:
2052 p->local->pre_channel = 0; 2052 p->local->pre_channel = 0;
2053 break; 2053 break;
2054 } 2054 }
2055 p = (isdn_net_dev *) p->next; 2055 p = (isdn_net_dev *) p->next;
2056 } 2056 }
@@ -2134,7 +2134,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2134 ematch = wret = swapped = 0; 2134 ematch = wret = swapped = 0;
2135#ifdef ISDN_DEBUG_NET_ICALL 2135#ifdef ISDN_DEBUG_NET_ICALL
2136 printk(KERN_DEBUG "n_fi: di=%d ch=%d idx=%d usg=%d\n", di, ch, idx, 2136 printk(KERN_DEBUG "n_fi: di=%d ch=%d idx=%d usg=%d\n", di, ch, idx,
2137 dev->usage[idx]); 2137 dev->usage[idx]);
2138#endif 2138#endif
2139 while (p) { 2139 while (p) {
2140 int matchret; 2140 int matchret;
@@ -2142,32 +2142,32 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2142 2142
2143 /* If last check has triggered as binding-swap, revert it */ 2143 /* If last check has triggered as binding-swap, revert it */
2144 switch (swapped) { 2144 switch (swapped) {
2145 case 2: 2145 case 2:
2146 isdn_net_swap_usage(idx, sidx); 2146 isdn_net_swap_usage(idx, sidx);
2147 /* fall through */ 2147 /* fall through */
2148 case 1: 2148 case 1:
2149 isdn_net_swapbind(di); 2149 isdn_net_swapbind(di);
2150 break; 2150 break;
2151 } 2151 }
2152 swapped = 0; 2152 swapped = 0;
2153 /* check acceptable call types for DOV */ 2153 /* check acceptable call types for DOV */
2154 my_eaz = isdn_map_eaz2msn(lp->msn, di); 2154 my_eaz = isdn_map_eaz2msn(lp->msn, di);
2155 if (si1 == 1) { /* it's a DOV call, check if we allow it */ 2155 if (si1 == 1) { /* it's a DOV call, check if we allow it */
2156 if (*my_eaz == 'v' || *my_eaz == 'V' || 2156 if (*my_eaz == 'v' || *my_eaz == 'V' ||
2157 *my_eaz == 'b' || *my_eaz == 'B') 2157 *my_eaz == 'b' || *my_eaz == 'B')
2158 my_eaz++; /* skip to allow a match */ 2158 my_eaz++; /* skip to allow a match */
2159 else 2159 else
2160 my_eaz = NULL; /* force non match */ 2160 my_eaz = NULL; /* force non match */
2161 } else { /* it's a DATA call, check if we allow it */ 2161 } else { /* it's a DATA call, check if we allow it */
2162 if (*my_eaz == 'b' || *my_eaz == 'B') 2162 if (*my_eaz == 'b' || *my_eaz == 'B')
2163 my_eaz++; /* skip to allow a match */ 2163 my_eaz++; /* skip to allow a match */
2164 } 2164 }
2165 if (my_eaz) 2165 if (my_eaz)
2166 matchret = isdn_msncmp(eaz, my_eaz); 2166 matchret = isdn_msncmp(eaz, my_eaz);
2167 else 2167 else
2168 matchret = 1; 2168 matchret = 1;
2169 if (!matchret) 2169 if (!matchret)
2170 ematch = 1; 2170 ematch = 1;
2171 2171
2172 /* Remember if more numbers eventually can match */ 2172 /* Remember if more numbers eventually can match */
2173 if (matchret > wret) 2173 if (matchret > wret)
@@ -2181,8 +2181,8 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2181 (USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ 2181 (USG_NONE(dev->usage[idx]))) || /* and ch. unused or */
2182 ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */ 2182 ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */
2183 (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ 2183 (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */
2184 ))) 2184 )))
2185 { 2185 {
2186#ifdef ISDN_DEBUG_NET_ICALL 2186#ifdef ISDN_DEBUG_NET_ICALL
2187 printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n", 2187 printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n",
2188 lp->pre_device, lp->pre_channel); 2188 lp->pre_device, lp->pre_channel);
@@ -2312,7 +2312,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2312 p = (isdn_net_dev *) p->next; 2312 p = (isdn_net_dev *) p->next;
2313 continue; 2313 continue;
2314 } 2314 }
2315 } 2315 }
2316 if (lp->flags & ISDN_NET_CALLBACK) { 2316 if (lp->flags & ISDN_NET_CALLBACK) {
2317 int chi; 2317 int chi;
2318 /* 2318 /*
@@ -2330,18 +2330,18 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2330 if (lp->phone[1]) { 2330 if (lp->phone[1]) {
2331 /* Grab a free ISDN-Channel */ 2331 /* Grab a free ISDN-Channel */
2332 spin_lock_irqsave(&dev->lock, flags); 2332 spin_lock_irqsave(&dev->lock, flags);
2333 if ((chi = 2333 if ((chi =
2334 isdn_get_free_channel( 2334 isdn_get_free_channel(
2335 ISDN_USAGE_NET, 2335 ISDN_USAGE_NET,
2336 lp->l2_proto, 2336 lp->l2_proto,
2337 lp->l3_proto, 2337 lp->l3_proto,
2338 lp->pre_device, 2338 lp->pre_device,
2339 lp->pre_channel, 2339 lp->pre_channel,
2340 lp->msn) 2340 lp->msn)
2341 ) < 0) { 2341 ) < 0) {
2342 2342
2343 printk(KERN_WARNING "isdn_net_find_icall: No channel for %s\n", 2343 printk(KERN_WARNING "isdn_net_find_icall: No channel for %s\n",
2344 p->dev->name); 2344 p->dev->name);
2345 spin_unlock_irqrestore(&dev->lock, flags); 2345 spin_unlock_irqrestore(&dev->lock, flags);
2346 return 0; 2346 return 0;
2347 } 2347 }
@@ -2363,11 +2363,11 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2363 return (lp->flags & ISDN_NET_CBHUP) ? 2 : 4; 2363 return (lp->flags & ISDN_NET_CBHUP) ? 2 : 4;
2364 } else 2364 } else
2365 printk(KERN_WARNING "isdn_net: %s: No phone number\n", 2365 printk(KERN_WARNING "isdn_net: %s: No phone number\n",
2366 p->dev->name); 2366 p->dev->name);
2367 return 0; 2367 return 0;
2368 } else { 2368 } else {
2369 printk(KERN_DEBUG "%s: call from %s -> %s accepted\n", 2369 printk(KERN_DEBUG "%s: call from %s -> %s accepted\n",
2370 p->dev->name, nr, eaz); 2370 p->dev->name, nr, eaz);
2371 /* if this interface is dialing, it does it probably on a different 2371 /* if this interface is dialing, it does it probably on a different
2372 device, so free this device */ 2372 device, so free this device */
2373 if ((lp->dialstate == 4) || (lp->dialstate == 12)) { 2373 if ((lp->dialstate == 4) || (lp->dialstate == 12)) {
@@ -2377,7 +2377,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2377#endif 2377#endif
2378 isdn_net_lp_disconnected(lp); 2378 isdn_net_lp_disconnected(lp);
2379 isdn_free_channel(lp->isdn_device, lp->isdn_channel, 2379 isdn_free_channel(lp->isdn_device, lp->isdn_channel,
2380 ISDN_USAGE_NET); 2380 ISDN_USAGE_NET);
2381 } 2381 }
2382 spin_lock_irqsave(&dev->lock, flags); 2382 spin_lock_irqsave(&dev->lock, flags);
2383 dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; 2383 dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE;
@@ -2414,7 +2414,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
2414 /* If none of configured EAZ/MSN matched and not verbose, be silent */ 2414 /* If none of configured EAZ/MSN matched and not verbose, be silent */
2415 if (!ematch || dev->net_verbose) 2415 if (!ematch || dev->net_verbose)
2416 printk(KERN_INFO "isdn_net: call from %s -> %d %s ignored\n", nr, di, eaz); 2416 printk(KERN_INFO "isdn_net: call from %s -> %d %s ignored\n", nr, di, eaz);
2417 return (wret == 2) ? 5 : 0; 2417 return (wret == 2)?5:0;
2418} 2418}
2419 2419
2420/* 2420/*
@@ -2439,7 +2439,7 @@ isdn_net_findif(char *name)
2439 * from isdn_net_start_xmit(). 2439 * from isdn_net_start_xmit().
2440 */ 2440 */
2441static int 2441static int
2442isdn_net_force_dial_lp(isdn_net_local *lp) 2442isdn_net_force_dial_lp(isdn_net_local * lp)
2443{ 2443{
2444 if ((!(lp->flags & ISDN_NET_CONNECTED)) && !lp->dialstate) { 2444 if ((!(lp->flags & ISDN_NET_CONNECTED)) && !lp->dialstate) {
2445 int chi; 2445 int chi;
@@ -2449,14 +2449,14 @@ isdn_net_force_dial_lp(isdn_net_local *lp)
2449 /* Grab a free ISDN-Channel */ 2449 /* Grab a free ISDN-Channel */
2450 spin_lock_irqsave(&dev->lock, flags); 2450 spin_lock_irqsave(&dev->lock, flags);
2451 if ((chi = isdn_get_free_channel( 2451 if ((chi = isdn_get_free_channel(
2452 ISDN_USAGE_NET, 2452 ISDN_USAGE_NET,
2453 lp->l2_proto, 2453 lp->l2_proto,
2454 lp->l3_proto, 2454 lp->l3_proto,
2455 lp->pre_device, 2455 lp->pre_device,
2456 lp->pre_channel, 2456 lp->pre_channel,
2457 lp->msn)) < 0) { 2457 lp->msn)) < 0) {
2458 printk(KERN_WARNING "isdn_net_force_dial: No channel for %s\n", 2458 printk(KERN_WARNING "isdn_net_force_dial: No channel for %s\n",
2459 lp->netdev->dev->name); 2459 lp->netdev->dev->name);
2460 spin_unlock_irqrestore(&dev->lock, flags); 2460 spin_unlock_irqrestore(&dev->lock, flags);
2461 return -EAGAIN; 2461 return -EAGAIN;
2462 } 2462 }
@@ -2487,7 +2487,7 @@ isdn_net_force_dial_lp(isdn_net_local *lp)
2487 * themselves. 2487 * themselves.
2488 */ 2488 */
2489int 2489int
2490isdn_net_dial_req(isdn_net_local *lp) 2490isdn_net_dial_req(isdn_net_local * lp)
2491{ 2491{
2492 /* is there a better error code? */ 2492 /* is there a better error code? */
2493 if (!(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_AUTO)) return -EBUSY; 2493 if (!(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_AUTO)) return -EBUSY;
@@ -2531,7 +2531,7 @@ static void _isdn_setup(struct net_device *dev)
2531 ether_setup(dev); 2531 ether_setup(dev);
2532 2532
2533 /* Setup the generic properties */ 2533 /* Setup the generic properties */
2534 dev->flags = IFF_NOARP | IFF_POINTOPOINT; 2534 dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2535 2535
2536 /* isdn prepends a header in the tx path, can't share skbs */ 2536 /* isdn prepends a header in the tx path, can't share skbs */
2537 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 2537 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
@@ -2655,7 +2655,7 @@ isdn_net_newslave(char *parm)
2655 if (n->local->master) 2655 if (n->local->master)
2656 return NULL; 2656 return NULL;
2657 /* Master must not be started yet */ 2657 /* Master must not be started yet */
2658 if (isdn_net_device_started(n)) 2658 if (isdn_net_device_started(n))
2659 return NULL; 2659 return NULL;
2660 return (isdn_net_new(newname, n->dev)); 2660 return (isdn_net_new(newname, n->dev));
2661 } 2661 }
@@ -2669,7 +2669,7 @@ isdn_net_newslave(char *parm)
2669 * setup first, if only selected parameters are to be changed. 2669 * setup first, if only selected parameters are to be changed.
2670 */ 2670 */
2671int 2671int
2672isdn_net_setcfg(isdn_net_ioctl_cfg *cfg) 2672isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
2673{ 2673{
2674 isdn_net_dev *p = isdn_net_findif(cfg->name); 2674 isdn_net_dev *p = isdn_net_findif(cfg->name);
2675 ulong features; 2675 ulong features;
@@ -2692,9 +2692,9 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2692 printk(KERN_WARNING "isdn_net: No driver with selected features\n"); 2692 printk(KERN_WARNING "isdn_net: No driver with selected features\n");
2693 return -ENODEV; 2693 return -ENODEV;
2694 } 2694 }
2695 if (lp->p_encap != cfg->p_encap) { 2695 if (lp->p_encap != cfg->p_encap){
2696#ifdef CONFIG_ISDN_X25 2696#ifdef CONFIG_ISDN_X25
2697 struct concap_proto *cprot = p->cprot; 2697 struct concap_proto * cprot = p -> cprot;
2698#endif 2698#endif
2699 if (isdn_net_device_started(p)) { 2699 if (isdn_net_device_started(p)) {
2700 printk(KERN_WARNING "%s: cannot change encap when if is up\n", 2700 printk(KERN_WARNING "%s: cannot change encap when if is up\n",
@@ -2702,24 +2702,24 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2702 return -EBUSY; 2702 return -EBUSY;
2703 } 2703 }
2704#ifdef CONFIG_ISDN_X25 2704#ifdef CONFIG_ISDN_X25
2705 if (cprot && cprot->pops) 2705 if( cprot && cprot -> pops )
2706 cprot->pops->proto_del(cprot); 2706 cprot -> pops -> proto_del ( cprot );
2707 p->cprot = NULL; 2707 p -> cprot = NULL;
2708 lp->dops = NULL; 2708 lp -> dops = NULL;
2709 /* ... , prepare for configuration of new one ... */ 2709 /* ... , prepare for configuration of new one ... */
2710 switch (cfg->p_encap) { 2710 switch ( cfg -> p_encap ){
2711 case ISDN_NET_ENCAP_X25IFACE: 2711 case ISDN_NET_ENCAP_X25IFACE:
2712 lp->dops = &isdn_concap_reliable_dl_dops; 2712 lp -> dops = &isdn_concap_reliable_dl_dops;
2713 } 2713 }
2714 /* ... and allocate new one ... */ 2714 /* ... and allocate new one ... */
2715 p->cprot = isdn_concap_new(cfg->p_encap); 2715 p -> cprot = isdn_concap_new( cfg -> p_encap );
2716 /* p -> cprot == NULL now if p_encap is not supported 2716 /* p -> cprot == NULL now if p_encap is not supported
2717 by means of the concap_proto mechanism */ 2717 by means of the concap_proto mechanism */
2718 /* the protocol is not configured yet; this will 2718 /* the protocol is not configured yet; this will
2719 happen later when isdn_net_reset() is called */ 2719 happen later when isdn_net_reset() is called */
2720#endif 2720#endif
2721 } 2721 }
2722 switch (cfg->p_encap) { 2722 switch ( cfg->p_encap ) {
2723 case ISDN_NET_ENCAP_SYNCPPP: 2723 case ISDN_NET_ENCAP_SYNCPPP:
2724#ifndef CONFIG_ISDN_PPP 2724#ifndef CONFIG_ISDN_PPP
2725 printk(KERN_WARNING "%s: SyncPPP support not configured\n", 2725 printk(KERN_WARNING "%s: SyncPPP support not configured\n",
@@ -2743,8 +2743,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2743 case ISDN_NET_ENCAP_CISCOHDLCK: 2743 case ISDN_NET_ENCAP_CISCOHDLCK:
2744 break; 2744 break;
2745 default: 2745 default:
2746 if (cfg->p_encap >= 0 && 2746 if( cfg->p_encap >= 0 &&
2747 cfg->p_encap <= ISDN_NET_ENCAP_MAX_ENCAP) 2747 cfg->p_encap <= ISDN_NET_ENCAP_MAX_ENCAP )
2748 break; 2748 break;
2749 printk(KERN_WARNING 2749 printk(KERN_WARNING
2750 "%s: encapsulation protocol %d not supported\n", 2750 "%s: encapsulation protocol %d not supported\n",
@@ -2754,11 +2754,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2754 if (strlen(cfg->drvid)) { 2754 if (strlen(cfg->drvid)) {
2755 /* A bind has been requested ... */ 2755 /* A bind has been requested ... */
2756 char *c, 2756 char *c,
2757 *e; 2757 *e;
2758 2758
2759 if (strnlen(cfg->drvid, sizeof(cfg->drvid)) ==
2760 sizeof(cfg->drvid))
2761 return -EINVAL;
2762 drvidx = -1; 2759 drvidx = -1;
2763 chidx = -1; 2760 chidx = -1;
2764 strcpy(drvid, cfg->drvid); 2761 strcpy(drvid, cfg->drvid);
@@ -2789,8 +2786,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2789 /* If binding is exclusive, try to grab the channel */ 2786 /* If binding is exclusive, try to grab the channel */
2790 spin_lock_irqsave(&dev->lock, flags); 2787 spin_lock_irqsave(&dev->lock, flags);
2791 if ((i = isdn_get_free_channel(ISDN_USAGE_NET, 2788 if ((i = isdn_get_free_channel(ISDN_USAGE_NET,
2792 lp->l2_proto, lp->l3_proto, drvidx, 2789 lp->l2_proto, lp->l3_proto, drvidx,
2793 chidx, lp->msn)) < 0) { 2790 chidx, lp->msn)) < 0) {
2794 /* Grab failed, because desired channel is in use */ 2791 /* Grab failed, because desired channel is in use */
2795 lp->exclusive = -1; 2792 lp->exclusive = -1;
2796 spin_unlock_irqrestore(&dev->lock, flags); 2793 spin_unlock_irqrestore(&dev->lock, flags);
@@ -2834,23 +2831,23 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2834 else 2831 else
2835 lp->flags &= ~ISDN_NET_CBHUP; 2832 lp->flags &= ~ISDN_NET_CBHUP;
2836 switch (cfg->callback) { 2833 switch (cfg->callback) {
2837 case 0: 2834 case 0:
2838 lp->flags &= ~(ISDN_NET_CALLBACK | ISDN_NET_CBOUT); 2835 lp->flags &= ~(ISDN_NET_CALLBACK | ISDN_NET_CBOUT);
2839 break; 2836 break;
2840 case 1: 2837 case 1:
2841 lp->flags |= ISDN_NET_CALLBACK; 2838 lp->flags |= ISDN_NET_CALLBACK;
2842 lp->flags &= ~ISDN_NET_CBOUT; 2839 lp->flags &= ~ISDN_NET_CBOUT;
2843 break; 2840 break;
2844 case 2: 2841 case 2:
2845 lp->flags |= ISDN_NET_CBOUT; 2842 lp->flags |= ISDN_NET_CBOUT;
2846 lp->flags &= ~ISDN_NET_CALLBACK; 2843 lp->flags &= ~ISDN_NET_CALLBACK;
2847 break; 2844 break;
2848 } 2845 }
2849 lp->flags &= ~ISDN_NET_DIALMODE_MASK; /* first all bits off */ 2846 lp->flags &= ~ISDN_NET_DIALMODE_MASK; /* first all bits off */
2850 if (cfg->dialmode && !(cfg->dialmode & ISDN_NET_DIALMODE_MASK)) { 2847 if (cfg->dialmode && !(cfg->dialmode & ISDN_NET_DIALMODE_MASK)) {
2851 /* old isdnctrl version, where only 0 or 1 is given */ 2848 /* old isdnctrl version, where only 0 or 1 is given */
2852 printk(KERN_WARNING 2849 printk(KERN_WARNING
2853 "Old isdnctrl version detected! Please update.\n"); 2850 "Old isdnctrl version detected! Please update.\n");
2854 lp->flags |= ISDN_NET_DM_OFF; /* turn on `off' bit */ 2851 lp->flags |= ISDN_NET_DM_OFF; /* turn on `off' bit */
2855 } 2852 }
2856 else { 2853 else {
@@ -2871,13 +2868,13 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2871 if (cfg->p_encap != lp->p_encap) { 2868 if (cfg->p_encap != lp->p_encap) {
2872 if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) { 2869 if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) {
2873 p->dev->header_ops = NULL; 2870 p->dev->header_ops = NULL;
2874 p->dev->flags = IFF_NOARP | IFF_POINTOPOINT; 2871 p->dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2875 } else { 2872 } else {
2876 p->dev->header_ops = &isdn_header_ops; 2873 p->dev->header_ops = &isdn_header_ops;
2877 if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) 2874 if (cfg->p_encap == ISDN_NET_ENCAP_ETHER)
2878 p->dev->flags = IFF_BROADCAST | IFF_MULTICAST; 2875 p->dev->flags = IFF_BROADCAST | IFF_MULTICAST;
2879 else 2876 else
2880 p->dev->flags = IFF_NOARP | IFF_POINTOPOINT; 2877 p->dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2881 } 2878 }
2882 } 2879 }
2883 lp->p_encap = cfg->p_encap; 2880 lp->p_encap = cfg->p_encap;
@@ -2890,7 +2887,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg *cfg)
2890 * Perform get-interface-parameters.ioctl 2887 * Perform get-interface-parameters.ioctl
2891 */ 2888 */
2892int 2889int
2893isdn_net_getcfg(isdn_net_ioctl_cfg *cfg) 2890isdn_net_getcfg(isdn_net_ioctl_cfg * cfg)
2894{ 2891{
2895 isdn_net_dev *p = isdn_net_findif(cfg->name); 2892 isdn_net_dev *p = isdn_net_findif(cfg->name);
2896 2893
@@ -2924,7 +2921,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg *cfg)
2924 cfg->triggercps = lp->triggercps; 2921 cfg->triggercps = lp->triggercps;
2925 cfg->slavedelay = lp->slavedelay / HZ; 2922 cfg->slavedelay = lp->slavedelay / HZ;
2926 cfg->chargeint = (lp->hupflags & ISDN_CHARGEHUP) ? 2923 cfg->chargeint = (lp->hupflags & ISDN_CHARGEHUP) ?
2927 (lp->chargeint / HZ) : 0; 2924 (lp->chargeint / HZ) : 0;
2928 cfg->pppbind = lp->pppbind; 2925 cfg->pppbind = lp->pppbind;
2929 cfg->dialtimeout = lp->dialtimeout >= 0 ? lp->dialtimeout / HZ : -1; 2926 cfg->dialtimeout = lp->dialtimeout >= 0 ? lp->dialtimeout / HZ : -1;
2930 cfg->dialwait = lp->dialwait / HZ; 2927 cfg->dialwait = lp->dialwait / HZ;
@@ -2951,7 +2948,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg *cfg)
2951 * Add a phone-number to an interface. 2948 * Add a phone-number to an interface.
2952 */ 2949 */
2953int 2950int
2954isdn_net_addphone(isdn_net_ioctl_phone *phone) 2951isdn_net_addphone(isdn_net_ioctl_phone * phone)
2955{ 2952{
2956 isdn_net_dev *p = isdn_net_findif(phone->name); 2953 isdn_net_dev *p = isdn_net_findif(phone->name);
2957 isdn_net_phone *n; 2954 isdn_net_phone *n;
@@ -2972,7 +2969,7 @@ isdn_net_addphone(isdn_net_ioctl_phone *phone)
2972 * This might sleep and must be called with the isdn semaphore down. 2969 * This might sleep and must be called with the isdn semaphore down.
2973 */ 2970 */
2974int 2971int
2975isdn_net_getphones(isdn_net_ioctl_phone *phone, char __user *phones) 2972isdn_net_getphones(isdn_net_ioctl_phone * phone, char __user *phones)
2976{ 2973{
2977 isdn_net_dev *p = isdn_net_findif(phone->name); 2974 isdn_net_dev *p = isdn_net_findif(phone->name);
2978 int inout = phone->outgoing & 1; 2975 int inout = phone->outgoing & 1;
@@ -3015,15 +3012,15 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone __user *peer)
3015 /* 3012 /*
3016 * Theoretical race: while this executes, the remote number might 3013 * Theoretical race: while this executes, the remote number might
3017 * become invalid (hang up) or change (new connection), resulting 3014 * become invalid (hang up) or change (new connection), resulting
3018 * in (partially) wrong number copied to user. This race 3015 * in (partially) wrong number copied to user. This race
3019 * currently ignored. 3016 * currently ignored.
3020 */ 3017 */
3021 ch = p->local->isdn_channel; 3018 ch = p->local->isdn_channel;
3022 dv = p->local->isdn_device; 3019 dv = p->local->isdn_device;
3023 if (ch < 0 && dv < 0) 3020 if(ch < 0 && dv < 0)
3024 return -ENOTCONN; 3021 return -ENOTCONN;
3025 idx = isdn_dc2minor(dv, ch); 3022 idx = isdn_dc2minor(dv, ch);
3026 if (idx < 0) 3023 if (idx <0 )
3027 return -ENODEV; 3024 return -ENODEV;
3028 /* for pre-bound channels, we need this extra check */ 3025 /* for pre-bound channels, we need this extra check */
3029 if (strncmp(dev->num[idx], "???", 3) == 0) 3026 if (strncmp(dev->num[idx], "???", 3) == 0)
@@ -3038,7 +3035,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone __user *peer)
3038 * Delete a phone-number from an interface. 3035 * Delete a phone-number from an interface.
3039 */ 3036 */
3040int 3037int
3041isdn_net_delphone(isdn_net_ioctl_phone *phone) 3038isdn_net_delphone(isdn_net_ioctl_phone * phone)
3042{ 3039{
3043 isdn_net_dev *p = isdn_net_findif(phone->name); 3040 isdn_net_dev *p = isdn_net_findif(phone->name);
3044 int inout = phone->outgoing & 1; 3041 int inout = phone->outgoing & 1;
@@ -3071,7 +3068,7 @@ isdn_net_delphone(isdn_net_ioctl_phone *phone)
3071 * Delete all phone-numbers of an interface. 3068 * Delete all phone-numbers of an interface.
3072 */ 3069 */
3073static int 3070static int
3074isdn_net_rmallphone(isdn_net_dev *p) 3071isdn_net_rmallphone(isdn_net_dev * p)
3075{ 3072{
3076 isdn_net_phone *n; 3073 isdn_net_phone *n;
3077 isdn_net_phone *m; 3074 isdn_net_phone *m;
@@ -3118,7 +3115,7 @@ isdn_net_force_hangup(char *name)
3118 * Helper-function for isdn_net_rm: Do the real work. 3115 * Helper-function for isdn_net_rm: Do the real work.
3119 */ 3116 */
3120static int 3117static int
3121isdn_net_realrm(isdn_net_dev *p, isdn_net_dev *q) 3118isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q)
3122{ 3119{
3123 u_long flags; 3120 u_long flags;
3124 3121
@@ -3126,8 +3123,8 @@ isdn_net_realrm(isdn_net_dev *p, isdn_net_dev *q)
3126 return -EBUSY; 3123 return -EBUSY;
3127 } 3124 }
3128#ifdef CONFIG_ISDN_X25 3125#ifdef CONFIG_ISDN_X25
3129 if (p->cprot && p->cprot->pops) 3126 if( p -> cprot && p -> cprot -> pops )
3130 p->cprot->pops->proto_del(p->cprot); 3127 p -> cprot -> pops -> proto_del ( p -> cprot );
3131#endif 3128#endif
3132 /* Free all phone-entries */ 3129 /* Free all phone-entries */
3133 isdn_net_rmallphone(p); 3130 isdn_net_rmallphone(p);
diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h
index cca6d68da17..7511f08effa 100644
--- a/drivers/isdn/i4l/isdn_net.h
+++ b/drivers/isdn/i4l/isdn_net.h
@@ -11,7 +11,7 @@
11 * 11 *
12 */ 12 */
13 13
14/* Definitions for hupflags: */ 14 /* Definitions for hupflags: */
15#define ISDN_WAITCHARGE 1 /* did not get a charge info yet */ 15#define ISDN_WAITCHARGE 1 /* did not get a charge info yet */
16#define ISDN_HAVECHARGE 2 /* We know a charge info */ 16#define ISDN_HAVECHARGE 2 /* We know a charge info */
17#define ISDN_CHARGEHUP 4 /* We want to use the charge mechanism */ 17#define ISDN_CHARGEHUP 4 /* We want to use the charge mechanism */
@@ -58,8 +58,8 @@ extern void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb);
58 58
59#define ISDN_MASTER_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->master)) 59#define ISDN_MASTER_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->master))
60#define ISDN_SLAVE_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->slave)) 60#define ISDN_SLAVE_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->slave))
61#define MASTER_TO_SLAVE(master) \ 61#define MASTER_TO_SLAVE(master) \
62 (((isdn_net_local *) netdev_priv(master))->slave) 62 (((isdn_net_local *) netdev_priv(master))->slave)
63 63
64/* 64/*
65 * is this particular channel busy? 65 * is this particular channel busy?
@@ -68,7 +68,7 @@ static __inline__ int isdn_net_lp_busy(isdn_net_local *lp)
68{ 68{
69 if (atomic_read(&lp->frame_cnt) < ISDN_NET_MAX_QUEUE_LENGTH) 69 if (atomic_read(&lp->frame_cnt) < ISDN_NET_MAX_QUEUE_LENGTH)
70 return 0; 70 return 0;
71 else 71 else
72 return 1; 72 return 1;
73} 73}
74 74
@@ -76,7 +76,7 @@ static __inline__ int isdn_net_lp_busy(isdn_net_local *lp)
76 * For the given net device, this will get a non-busy channel out of the 76 * For the given net device, this will get a non-busy channel out of the
77 * corresponding bundle. The returned channel is locked. 77 * corresponding bundle. The returned channel is locked.
78 */ 78 */
79static __inline__ isdn_net_local *isdn_net_get_locked_lp(isdn_net_dev *nd) 79static __inline__ isdn_net_local * isdn_net_get_locked_lp(isdn_net_dev *nd)
80{ 80{
81 unsigned long flags; 81 unsigned long flags;
82 isdn_net_local *lp; 82 isdn_net_local *lp;
@@ -149,3 +149,4 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp)
149// __func__, master_lp->netdev->queue); 149// __func__, master_lp->netdev->queue);
150 spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags); 150 spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags);
151} 151}
152
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 61d78fa03b1..1b002b0002a 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -28,18 +28,18 @@
28/* Prototypes */ 28/* Prototypes */
29static int isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot); 29static int isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot);
30static int isdn_ppp_closewait(int slot); 30static int isdn_ppp_closewait(int slot);
31static void isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, 31static void isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp,
32 struct sk_buff *skb, int proto); 32 struct sk_buff *skb, int proto);
33static int isdn_ppp_if_get_unit(char *namebuf); 33static int isdn_ppp_if_get_unit(char *namebuf);
34static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_data *); 34static int isdn_ppp_set_compressor(struct ippp_struct *is,struct isdn_ppp_comp_data *);
35static struct sk_buff *isdn_ppp_decompress(struct sk_buff *, 35static struct sk_buff *isdn_ppp_decompress(struct sk_buff *,
36 struct ippp_struct *, struct ippp_struct *, int *proto); 36 struct ippp_struct *,struct ippp_struct *,int *proto);
37static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, 37static void isdn_ppp_receive_ccp(isdn_net_dev * net_dev, isdn_net_local * lp,
38 struct sk_buff *skb, int proto); 38 struct sk_buff *skb,int proto);
39static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in, int *proto, 39static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto,
40 struct ippp_struct *is, struct ippp_struct *master, int type); 40 struct ippp_struct *is,struct ippp_struct *master,int type);
41static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, 41static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
42 struct sk_buff *skb); 42 struct sk_buff *skb);
43 43
44/* New CCP stuff */ 44/* New CCP stuff */
45static void isdn_ppp_ccp_kickup(struct ippp_struct *is); 45static void isdn_ppp_ccp_kickup(struct ippp_struct *is);
@@ -52,7 +52,7 @@ static void isdn_ppp_ccp_reset_free_state(struct ippp_struct *is,
52 unsigned char id); 52 unsigned char id);
53static void isdn_ppp_ccp_timer_callback(unsigned long closure); 53static void isdn_ppp_ccp_timer_callback(unsigned long closure);
54static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, 54static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is,
55 unsigned char id); 55 unsigned char id);
56static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, 56static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
57 struct isdn_ppp_resetparams *rp); 57 struct isdn_ppp_resetparams *rp);
58static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, 58static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is,
@@ -61,17 +61,17 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is,
61 61
62 62
63#ifdef CONFIG_ISDN_MPP 63#ifdef CONFIG_ISDN_MPP
64static ippp_bundle *isdn_ppp_bundle_arr = NULL; 64static ippp_bundle * isdn_ppp_bundle_arr = NULL;
65 65
66static int isdn_ppp_mp_bundle_array_init(void); 66static int isdn_ppp_mp_bundle_array_init(void);
67static int isdn_ppp_mp_init(isdn_net_local *lp, ippp_bundle *add_to); 67static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to );
68static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, 68static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
69 struct sk_buff *skb); 69 struct sk_buff *skb);
70static void isdn_ppp_mp_cleanup(isdn_net_local *lp); 70static void isdn_ppp_mp_cleanup( isdn_net_local * lp );
71 71
72static int isdn_ppp_bundle(struct ippp_struct *, int unit); 72static int isdn_ppp_bundle(struct ippp_struct *, int unit);
73#endif /* CONFIG_ISDN_MPP */ 73#endif /* CONFIG_ISDN_MPP */
74 74
75char *isdn_ppp_revision = "$Revision: 1.1.2.3 $"; 75char *isdn_ppp_revision = "$Revision: 1.1.2.3 $";
76 76
77static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS]; 77static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS];
@@ -82,11 +82,11 @@ static struct isdn_ppp_compressor *ipc_head = NULL;
82 * frame log (debug) 82 * frame log (debug)
83 */ 83 */
84static void 84static void
85isdn_ppp_frame_log(char *info, char *data, int len, int maxlen, int unit, int slot) 85isdn_ppp_frame_log(char *info, char *data, int len, int maxlen,int unit,int slot)
86{ 86{
87 int cnt, 87 int cnt,
88 j, 88 j,
89 i; 89 i;
90 char buf[80]; 90 char buf[80];
91 91
92 if (len < maxlen) 92 if (len < maxlen)
@@ -94,8 +94,8 @@ isdn_ppp_frame_log(char *info, char *data, int len, int maxlen, int unit, int sl
94 94
95 for (i = 0, cnt = 0; cnt < maxlen; i++) { 95 for (i = 0, cnt = 0; cnt < maxlen; i++) {
96 for (j = 0; j < 16 && cnt < maxlen; j++, cnt++) 96 for (j = 0; j < 16 && cnt < maxlen; j++, cnt++)
97 sprintf(buf + j * 3, "%02x ", (unsigned char)data[cnt]); 97 sprintf(buf + j * 3, "%02x ", (unsigned char) data[cnt]);
98 printk(KERN_DEBUG "[%d/%d].%s[%d]: %s\n", unit, slot, info, i, buf); 98 printk(KERN_DEBUG "[%d/%d].%s[%d]: %s\n",unit,slot, info, i, buf);
99 } 99 }
100} 100}
101 101
@@ -105,13 +105,13 @@ isdn_ppp_frame_log(char *info, char *data, int len, int maxlen, int unit, int sl
105 * in this case we bind another lp to the master device 105 * in this case we bind another lp to the master device
106 */ 106 */
107int 107int
108isdn_ppp_free(isdn_net_local *lp) 108isdn_ppp_free(isdn_net_local * lp)
109{ 109{
110 struct ippp_struct *is; 110 struct ippp_struct *is;
111 111
112 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 112 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
113 printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", 113 printk(KERN_ERR "%s: ppp_slot(%d) out of range\n",
114 __func__, lp->ppp_slot); 114 __func__, lp->ppp_slot);
115 return 0; 115 return 0;
116 } 116 }
117 117
@@ -128,7 +128,7 @@ isdn_ppp_free(isdn_net_local *lp)
128#endif /* CONFIG_ISDN_MPP */ 128#endif /* CONFIG_ISDN_MPP */
129 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 129 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
130 printk(KERN_ERR "%s: ppp_slot(%d) now invalid\n", 130 printk(KERN_ERR "%s: ppp_slot(%d) now invalid\n",
131 __func__, lp->ppp_slot); 131 __func__, lp->ppp_slot);
132 return 0; 132 return 0;
133 } 133 }
134 is = ippp_table[lp->ppp_slot]; 134 is = ippp_table[lp->ppp_slot];
@@ -153,7 +153,7 @@ isdn_ppp_free(isdn_net_local *lp)
153 * no additional lock is needed 153 * no additional lock is needed
154 */ 154 */
155int 155int
156isdn_ppp_bind(isdn_net_local *lp) 156isdn_ppp_bind(isdn_net_local * lp)
157{ 157{
158 int i; 158 int i;
159 int unit = 0; 159 int unit = 0;
@@ -195,11 +195,11 @@ isdn_ppp_bind(isdn_net_local *lp)
195 unit = isdn_ppp_if_get_unit(lp->netdev->dev->name); 195 unit = isdn_ppp_if_get_unit(lp->netdev->dev->name);
196 if (unit < 0) { 196 if (unit < 0) {
197 printk(KERN_ERR "isdn_ppp_bind: illegal interface name %s.\n", 197 printk(KERN_ERR "isdn_ppp_bind: illegal interface name %s.\n",
198 lp->netdev->dev->name); 198 lp->netdev->dev->name);
199 retval = -1; 199 retval = -1;
200 goto out; 200 goto out;
201 } 201 }
202 202
203 lp->ppp_slot = i; 203 lp->ppp_slot = i;
204 is = ippp_table[i]; 204 is = ippp_table[i];
205 is->lp = lp; 205 is->lp = lp;
@@ -213,7 +213,7 @@ isdn_ppp_bind(isdn_net_local *lp)
213 213
214 retval = lp->ppp_slot; 214 retval = lp->ppp_slot;
215 215
216out: 216 out:
217 return retval; 217 return retval;
218} 218}
219 219
@@ -223,11 +223,11 @@ out:
223 */ 223 */
224 224
225void 225void
226isdn_ppp_wakeup_daemon(isdn_net_local *lp) 226isdn_ppp_wakeup_daemon(isdn_net_local * lp)
227{ 227{
228 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 228 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
229 printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", 229 printk(KERN_ERR "%s: ppp_slot(%d) out of range\n",
230 __func__, lp->ppp_slot); 230 __func__, lp->ppp_slot);
231 return; 231 return;
232 } 232 }
233 ippp_table[lp->ppp_slot]->state = IPPP_OPEN | IPPP_CONNECT | IPPP_NOBLOCK; 233 ippp_table[lp->ppp_slot]->state = IPPP_OPEN | IPPP_CONNECT | IPPP_NOBLOCK;
@@ -246,7 +246,7 @@ isdn_ppp_closewait(int slot)
246 246
247 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 247 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
248 printk(KERN_ERR "%s: slot(%d) out of range\n", 248 printk(KERN_ERR "%s: slot(%d) out of range\n",
249 __func__, slot); 249 __func__, slot);
250 return 0; 250 return 0;
251 } 251 }
252 is = ippp_table[slot]; 252 is = ippp_table[slot];
@@ -289,7 +289,7 @@ isdn_ppp_open(int min, struct file *file)
289 return -EBUSY; 289 return -EBUSY;
290 } 290 }
291 is = file->private_data = ippp_table[slot]; 291 is = file->private_data = ippp_table[slot];
292 292
293 printk(KERN_DEBUG "ippp, open, slot: %d, minor: %d, state: %04x\n", 293 printk(KERN_DEBUG "ippp, open, slot: %d, minor: %d, state: %04x\n",
294 slot, min, is->state); 294 slot, min, is->state);
295 295
@@ -385,21 +385,21 @@ isdn_ppp_release(int min, struct file *file)
385#endif 385#endif
386 386
387/* TODO: if this was the previous master: link the stuff to the new master */ 387/* TODO: if this was the previous master: link the stuff to the new master */
388 if (is->comp_stat) 388 if(is->comp_stat)
389 is->compressor->free(is->comp_stat); 389 is->compressor->free(is->comp_stat);
390 if (is->link_comp_stat) 390 if(is->link_comp_stat)
391 is->link_compressor->free(is->link_comp_stat); 391 is->link_compressor->free(is->link_comp_stat);
392 if (is->link_decomp_stat) 392 if(is->link_decomp_stat)
393 is->link_decompressor->free(is->link_decomp_stat); 393 is->link_decompressor->free(is->link_decomp_stat);
394 if (is->decomp_stat) 394 if(is->decomp_stat)
395 is->decompressor->free(is->decomp_stat); 395 is->decompressor->free(is->decomp_stat);
396 is->compressor = is->link_compressor = NULL; 396 is->compressor = is->link_compressor = NULL;
397 is->decompressor = is->link_decompressor = NULL; 397 is->decompressor = is->link_decompressor = NULL;
398 is->comp_stat = is->link_comp_stat = NULL; 398 is->comp_stat = is->link_comp_stat = NULL;
399 is->decomp_stat = is->link_decomp_stat = NULL; 399 is->decomp_stat = is->link_decomp_stat = NULL;
400 400
401 /* Clean up if necessary */ 401 /* Clean up if necessary */
402 if (is->reset) 402 if(is->reset)
403 isdn_ppp_ccp_reset_free(is); 403 isdn_ppp_ccp_reset_free(is);
404 404
405 /* this slot is ready for new connections */ 405 /* this slot is ready for new connections */
@@ -423,9 +423,9 @@ get_arg(void __user *b, void *val, int len)
423 * set arg .. ioctl helper 423 * set arg .. ioctl helper
424 */ 424 */
425static int 425static int
426set_arg(void __user *b, void *val, int len) 426set_arg(void __user *b, void *val,int len)
427{ 427{
428 if (len <= 0) 428 if(len <= 0)
429 len = sizeof(void *); 429 len = sizeof(void *);
430 if (copy_to_user(b, val, len)) 430 if (copy_to_user(b, val, len))
431 return -EFAULT; 431 return -EFAULT;
@@ -471,7 +471,7 @@ int
471isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) 471isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
472{ 472{
473 unsigned long val; 473 unsigned long val;
474 int r, i, j; 474 int r,i,j;
475 struct ippp_struct *is; 475 struct ippp_struct *is;
476 isdn_net_local *lp; 476 isdn_net_local *lp;
477 struct isdn_ppp_comp_data data; 477 struct isdn_ppp_comp_data data;
@@ -487,177 +487,177 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
487 return -EINVAL; 487 return -EINVAL;
488 488
489 switch (cmd) { 489 switch (cmd) {
490 case PPPIOCBUNDLE: 490 case PPPIOCBUNDLE:
491#ifdef CONFIG_ISDN_MPP 491#ifdef CONFIG_ISDN_MPP
492 if (!(is->state & IPPP_CONNECT)) 492 if (!(is->state & IPPP_CONNECT))
493 return -EINVAL; 493 return -EINVAL;
494 if ((r = get_arg(argp, &val, sizeof(val)))) 494 if ((r = get_arg(argp, &val, sizeof(val) )))
495 return r; 495 return r;
496 printk(KERN_DEBUG "iPPP-bundle: minor: %d, slave unit: %d, master unit: %d\n", 496 printk(KERN_DEBUG "iPPP-bundle: minor: %d, slave unit: %d, master unit: %d\n",
497 (int) min, (int) is->unit, (int) val); 497 (int) min, (int) is->unit, (int) val);
498 return isdn_ppp_bundle(is, val); 498 return isdn_ppp_bundle(is, val);
499#else 499#else
500 return -1; 500 return -1;
501#endif 501#endif
502 break; 502 break;
503 case PPPIOCGUNIT: /* get ppp/isdn unit number */ 503 case PPPIOCGUNIT: /* get ppp/isdn unit number */
504 if ((r = set_arg(argp, &is->unit, sizeof(is->unit)))) 504 if ((r = set_arg(argp, &is->unit, sizeof(is->unit) )))
505 return r; 505 return r;
506 break; 506 break;
507 case PPPIOCGIFNAME: 507 case PPPIOCGIFNAME:
508 if (!lp) 508 if(!lp)
509 return -EINVAL; 509 return -EINVAL;
510 if ((r = set_arg(argp, lp->netdev->dev->name, 510 if ((r = set_arg(argp, lp->netdev->dev->name,
511 strlen(lp->netdev->dev->name)))) 511 strlen(lp->netdev->dev->name))))
512 return r; 512 return r;
513 break; 513 break;
514 case PPPIOCGMPFLAGS: /* get configuration flags */ 514 case PPPIOCGMPFLAGS: /* get configuration flags */
515 if ((r = set_arg(argp, &is->mpppcfg, sizeof(is->mpppcfg)))) 515 if ((r = set_arg(argp, &is->mpppcfg, sizeof(is->mpppcfg) )))
516 return r; 516 return r;
517 break; 517 break;
518 case PPPIOCSMPFLAGS: /* set configuration flags */ 518 case PPPIOCSMPFLAGS: /* set configuration flags */
519 if ((r = get_arg(argp, &val, sizeof(val)))) 519 if ((r = get_arg(argp, &val, sizeof(val) )))
520 return r; 520 return r;
521 is->mpppcfg = val; 521 is->mpppcfg = val;
522 break; 522 break;
523 case PPPIOCGFLAGS: /* get configuration flags */ 523 case PPPIOCGFLAGS: /* get configuration flags */
524 if ((r = set_arg(argp, &is->pppcfg, sizeof(is->pppcfg)))) 524 if ((r = set_arg(argp, &is->pppcfg,sizeof(is->pppcfg) )))
525 return r; 525 return r;
526 break; 526 break;
527 case PPPIOCSFLAGS: /* set configuration flags */ 527 case PPPIOCSFLAGS: /* set configuration flags */
528 if ((r = get_arg(argp, &val, sizeof(val)))) { 528 if ((r = get_arg(argp, &val, sizeof(val) ))) {
529 return r; 529 return r;
530 } 530 }
531 if (val & SC_ENABLE_IP && !(is->pppcfg & SC_ENABLE_IP) && (is->state & IPPP_CONNECT)) { 531 if (val & SC_ENABLE_IP && !(is->pppcfg & SC_ENABLE_IP) && (is->state & IPPP_CONNECT)) {
532 if (lp) {
533 /* OK .. we are ready to send buffers */
534 is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */
535 netif_wake_queue(lp->netdev->dev);
536 break;
537 }
538 }
539 is->pppcfg = val;
540 break;
541 case PPPIOCGIDLE: /* get idle time information */
532 if (lp) { 542 if (lp) {
533 /* OK .. we are ready to send buffers */ 543 struct ppp_idle pidle;
534 is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */ 544 pidle.xmit_idle = pidle.recv_idle = lp->huptimer;
535 netif_wake_queue(lp->netdev->dev); 545 if ((r = set_arg(argp, &pidle,sizeof(struct ppp_idle))))
536 break; 546 return r;
537 } 547 }
538 } 548 break;
539 is->pppcfg = val; 549 case PPPIOCSMRU: /* set receive unit size for PPP */
540 break; 550 if ((r = get_arg(argp, &val, sizeof(val) )))
541 case PPPIOCGIDLE: /* get idle time information */
542 if (lp) {
543 struct ppp_idle pidle;
544 pidle.xmit_idle = pidle.recv_idle = lp->huptimer;
545 if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle))))
546 return r; 551 return r;
547 } 552 is->mru = val;
548 break; 553 break;
549 case PPPIOCSMRU: /* set receive unit size for PPP */ 554 case PPPIOCSMPMRU:
550 if ((r = get_arg(argp, &val, sizeof(val)))) 555 break;
551 return r; 556 case PPPIOCSMPMTU:
552 is->mru = val; 557 break;
553 break; 558 case PPPIOCSMAXCID: /* set the maximum compression slot id */
554 case PPPIOCSMPMRU: 559 if ((r = get_arg(argp, &val, sizeof(val) )))
555 break; 560 return r;
556 case PPPIOCSMPMTU: 561 val++;
557 break; 562 if (is->maxcid != val) {
558 case PPPIOCSMAXCID: /* set the maximum compression slot id */
559 if ((r = get_arg(argp, &val, sizeof(val))))
560 return r;
561 val++;
562 if (is->maxcid != val) {
563#ifdef CONFIG_ISDN_PPP_VJ 563#ifdef CONFIG_ISDN_PPP_VJ
564 struct slcompress *sltmp; 564 struct slcompress *sltmp;
565#endif 565#endif
566 if (is->debug & 0x1) 566 if (is->debug & 0x1)
567 printk(KERN_DEBUG "ippp, ioctl: changed MAXCID to %ld\n", val); 567 printk(KERN_DEBUG "ippp, ioctl: changed MAXCID to %ld\n", val);
568 is->maxcid = val; 568 is->maxcid = val;
569#ifdef CONFIG_ISDN_PPP_VJ 569#ifdef CONFIG_ISDN_PPP_VJ
570 sltmp = slhc_init(16, val); 570 sltmp = slhc_init(16, val);
571 if (!sltmp) { 571 if (!sltmp) {
572 printk(KERN_ERR "ippp, can't realloc slhc struct\n"); 572 printk(KERN_ERR "ippp, can't realloc slhc struct\n");
573 return -ENOMEM; 573 return -ENOMEM;
574 } 574 }
575 if (is->slcomp) 575 if (is->slcomp)
576 slhc_free(is->slcomp); 576 slhc_free(is->slcomp);
577 is->slcomp = sltmp; 577 is->slcomp = sltmp;
578#endif 578#endif
579 }
580 break;
581 case PPPIOCGDEBUG:
582 if ((r = set_arg(argp, &is->debug, sizeof(is->debug))))
583 return r;
584 break;
585 case PPPIOCSDEBUG:
586 if ((r = get_arg(argp, &val, sizeof(val))))
587 return r;
588 is->debug = val;
589 break;
590 case PPPIOCGCOMPRESSORS:
591 {
592 unsigned long protos[8] = {0,};
593 struct isdn_ppp_compressor *ipc = ipc_head;
594 while (ipc) {
595 j = ipc->num / (sizeof(long) * 8);
596 i = ipc->num % (sizeof(long) * 8);
597 if (j < 8)
598 protos[j] |= (1UL << i);
599 ipc = ipc->next;
600 }
601 if ((r = set_arg(argp, protos, 8 * sizeof(long))))
602 return r;
603 }
604 break;
605 case PPPIOCSCOMPRESSOR:
606 if ((r = get_arg(argp, &data, sizeof(struct isdn_ppp_comp_data))))
607 return r;
608 return isdn_ppp_set_compressor(is, &data);
609 case PPPIOCGCALLINFO:
610 {
611 struct pppcallinfo pci;
612 memset((char *)&pci, 0, sizeof(struct pppcallinfo));
613 if (lp)
614 {
615 strncpy(pci.local_num, lp->msn, 63);
616 if (lp->dial) {
617 strncpy(pci.remote_num, lp->dial->num, 63);
618 } 579 }
619 pci.charge_units = lp->charge; 580 break;
620 if (lp->outgoing) 581 case PPPIOCGDEBUG:
621 pci.calltype = CALLTYPE_OUTGOING; 582 if ((r = set_arg(argp, &is->debug, sizeof(is->debug) )))
622 else 583 return r;
623 pci.calltype = CALLTYPE_INCOMING; 584 break;
624 if (lp->flags & ISDN_NET_CALLBACK) 585 case PPPIOCSDEBUG:
625 pci.calltype |= CALLTYPE_CALLBACK; 586 if ((r = get_arg(argp, &val, sizeof(val) )))
626 } 587 return r;
627 return set_arg(argp, &pci, sizeof(struct pppcallinfo)); 588 is->debug = val;
628 } 589 break;
590 case PPPIOCGCOMPRESSORS:
591 {
592 unsigned long protos[8] = {0,};
593 struct isdn_ppp_compressor *ipc = ipc_head;
594 while(ipc) {
595 j = ipc->num / (sizeof(long)*8);
596 i = ipc->num % (sizeof(long)*8);
597 if(j < 8)
598 protos[j] |= (0x1<<i);
599 ipc = ipc->next;
600 }
601 if ((r = set_arg(argp,protos,8*sizeof(long) )))
602 return r;
603 }
604 break;
605 case PPPIOCSCOMPRESSOR:
606 if ((r = get_arg(argp, &data, sizeof(struct isdn_ppp_comp_data))))
607 return r;
608 return isdn_ppp_set_compressor(is, &data);
609 case PPPIOCGCALLINFO:
610 {
611 struct pppcallinfo pci;
612 memset((char *) &pci,0,sizeof(struct pppcallinfo));
613 if(lp)
614 {
615 strncpy(pci.local_num,lp->msn,63);
616 if(lp->dial) {
617 strncpy(pci.remote_num,lp->dial->num,63);
618 }
619 pci.charge_units = lp->charge;
620 if(lp->outgoing)
621 pci.calltype = CALLTYPE_OUTGOING;
622 else
623 pci.calltype = CALLTYPE_INCOMING;
624 if(lp->flags & ISDN_NET_CALLBACK)
625 pci.calltype |= CALLTYPE_CALLBACK;
626 }
627 return set_arg(argp,&pci,sizeof(struct pppcallinfo));
628 }
629#ifdef CONFIG_IPPP_FILTER 629#ifdef CONFIG_IPPP_FILTER
630 case PPPIOCSPASS: 630 case PPPIOCSPASS:
631 { 631 {
632 struct sock_filter *code; 632 struct sock_filter *code;
633 int len = get_filter(argp, &code); 633 int len = get_filter(argp, &code);
634 if (len < 0) 634 if (len < 0)
635 return len; 635 return len;
636 kfree(is->pass_filter); 636 kfree(is->pass_filter);
637 is->pass_filter = code; 637 is->pass_filter = code;
638 is->pass_len = len; 638 is->pass_len = len;
639 break; 639 break;
640 } 640 }
641 case PPPIOCSACTIVE: 641 case PPPIOCSACTIVE:
642 { 642 {
643 struct sock_filter *code; 643 struct sock_filter *code;
644 int len = get_filter(argp, &code); 644 int len = get_filter(argp, &code);
645 if (len < 0) 645 if (len < 0)
646 return len; 646 return len;
647 kfree(is->active_filter); 647 kfree(is->active_filter);
648 is->active_filter = code; 648 is->active_filter = code;
649 is->active_len = len; 649 is->active_len = len;
650 break; 650 break;
651 } 651 }
652#endif /* CONFIG_IPPP_FILTER */ 652#endif /* CONFIG_IPPP_FILTER */
653 default: 653 default:
654 break; 654 break;
655 } 655 }
656 return 0; 656 return 0;
657} 657}
658 658
659unsigned int 659unsigned int
660isdn_ppp_poll(struct file *file, poll_table *wait) 660isdn_ppp_poll(struct file *file, poll_table * wait)
661{ 661{
662 u_int mask; 662 u_int mask;
663 struct ippp_buf_queue *bf, *bl; 663 struct ippp_buf_queue *bf, *bl;
@@ -668,13 +668,13 @@ isdn_ppp_poll(struct file *file, poll_table *wait)
668 668
669 if (is->debug & 0x2) 669 if (is->debug & 0x2)
670 printk(KERN_DEBUG "isdn_ppp_poll: minor: %d\n", 670 printk(KERN_DEBUG "isdn_ppp_poll: minor: %d\n",
671 iminor(file->f_path.dentry->d_inode)); 671 iminor(file->f_path.dentry->d_inode));
672 672
673 /* just registers wait_queue hook. This doesn't really wait. */ 673 /* just registers wait_queue hook. This doesn't really wait. */
674 poll_wait(file, &is->wq, wait); 674 poll_wait(file, &is->wq, wait);
675 675
676 if (!(is->state & IPPP_OPEN)) { 676 if (!(is->state & IPPP_OPEN)) {
677 if (is->state == IPPP_CLOSEWAIT) 677 if(is->state == IPPP_CLOSEWAIT)
678 return POLLHUP; 678 return POLLHUP;
679 printk(KERN_DEBUG "isdn_ppp: device not open\n"); 679 printk(KERN_DEBUG "isdn_ppp: device not open\n");
680 return POLLERR; 680 return POLLERR;
@@ -827,7 +827,7 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count)
827 return 0; 827 return 0;
828 828
829 if ((dev->drv[lp->isdn_device]->flags & DRV_FLAG_RUNNING) && 829 if ((dev->drv[lp->isdn_device]->flags & DRV_FLAG_RUNNING) &&
830 lp->dialstate == 0 && 830 lp->dialstate == 0 &&
831 (lp->flags & ISDN_NET_CONNECTED)) { 831 (lp->flags & ISDN_NET_CONNECTED)) {
832 unsigned short hl; 832 unsigned short hl;
833 struct sk_buff *skb; 833 struct sk_buff *skb;
@@ -837,7 +837,7 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count)
837 * 16 bytes, now we are looking what the driver want 837 * 16 bytes, now we are looking what the driver want
838 */ 838 */
839 hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen; 839 hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen;
840 skb = alloc_skb(hl + count, GFP_ATOMIC); 840 skb = alloc_skb(hl+count, GFP_ATOMIC);
841 if (!skb) { 841 if (!skb) {
842 printk(KERN_WARNING "isdn_ppp_write: out of memory!\n"); 842 printk(KERN_WARNING "isdn_ppp_write: out of memory!\n");
843 return count; 843 return count;
@@ -850,10 +850,10 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count)
850 } 850 }
851 if (is->debug & 0x40) { 851 if (is->debug & 0x40) {
852 printk(KERN_DEBUG "ppp xmit: len %d\n", (int) skb->len); 852 printk(KERN_DEBUG "ppp xmit: len %d\n", (int) skb->len);
853 isdn_ppp_frame_log("xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 853 isdn_ppp_frame_log("xmit", skb->data, skb->len, 32,is->unit,lp->ppp_slot);
854 } 854 }
855 855
856 isdn_ppp_send_ccp(lp->netdev, lp, skb); /* keeps CCP/compression states in sync */ 856 isdn_ppp_send_ccp(lp->netdev,lp,skb); /* keeps CCP/compression states in sync */
857 857
858 isdn_net_write_super(lp, skb); 858 isdn_net_write_super(lp, skb);
859 } 859 }
@@ -869,10 +869,10 @@ int
869isdn_ppp_init(void) 869isdn_ppp_init(void)
870{ 870{
871 int i, 871 int i,
872 j; 872 j;
873 873
874#ifdef CONFIG_ISDN_MPP 874#ifdef CONFIG_ISDN_MPP
875 if (isdn_ppp_mp_bundle_array_init() < 0) 875 if( isdn_ppp_mp_bundle_array_init() < 0 )
876 return -ENOMEM; 876 return -ENOMEM;
877#endif /* CONFIG_ISDN_MPP */ 877#endif /* CONFIG_ISDN_MPP */
878 878
@@ -891,7 +891,7 @@ isdn_ppp_init(void)
891 for (j = 0; j < NUM_RCV_BUFFS; j++) { 891 for (j = 0; j < NUM_RCV_BUFFS; j++) {
892 ippp_table[i]->rq[j].buf = NULL; 892 ippp_table[i]->rq[j].buf = NULL;
893 ippp_table[i]->rq[j].last = ippp_table[i]->rq + 893 ippp_table[i]->rq[j].last = ippp_table[i]->rq +
894 (NUM_RCV_BUFFS + j - 1) % NUM_RCV_BUFFS; 894 (NUM_RCV_BUFFS + j - 1) % NUM_RCV_BUFFS;
895 ippp_table[i]->rq[j].next = ippp_table[i]->rq + (j + 1) % NUM_RCV_BUFFS; 895 ippp_table[i]->rq[j].next = ippp_table[i]->rq + (j + 1) % NUM_RCV_BUFFS;
896 } 896 }
897 } 897 }
@@ -916,7 +916,7 @@ isdn_ppp_cleanup(void)
916 * check for address/control field and skip if allowed 916 * check for address/control field and skip if allowed
917 * retval != 0 -> discard packet silently 917 * retval != 0 -> discard packet silently
918 */ 918 */
919static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb) 919static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb)
920{ 920{
921 if (skb->len < 1) 921 if (skb->len < 1)
922 return -1; 922 return -1;
@@ -930,7 +930,7 @@ static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb)
930 930
931 // skip address/control (AC) field 931 // skip address/control (AC) field
932 skb_pull(skb, 2); 932 skb_pull(skb, 2);
933 } else { 933 } else {
934 if (is->pppcfg & SC_REJ_COMP_AC) 934 if (is->pppcfg & SC_REJ_COMP_AC)
935 // if AC compression was not negotiated, but used, discard packet 935 // if AC compression was not negotiated, but used, discard packet
936 return -1; 936 return -1;
@@ -942,10 +942,10 @@ static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb)
942 * get the PPP protocol header and pull skb 942 * get the PPP protocol header and pull skb
943 * retval < 0 -> discard packet silently 943 * retval < 0 -> discard packet silently
944 */ 944 */
945static int isdn_ppp_strip_proto(struct sk_buff *skb) 945static int isdn_ppp_strip_proto(struct sk_buff *skb)
946{ 946{
947 int proto; 947 int proto;
948 948
949 if (skb->len < 1) 949 if (skb->len < 1)
950 return -1; 950 return -1;
951 951
@@ -966,7 +966,7 @@ static int isdn_ppp_strip_proto(struct sk_buff *skb)
966/* 966/*
967 * handler for incoming packets on a syncPPP interface 967 * handler for incoming packets on a syncPPP interface
968 */ 968 */
969void isdn_ppp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb) 969void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb)
970{ 970{
971 struct ippp_struct *is; 971 struct ippp_struct *is;
972 int slot; 972 int slot;
@@ -977,7 +977,7 @@ void isdn_ppp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff
977 slot = lp->ppp_slot; 977 slot = lp->ppp_slot;
978 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 978 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
979 printk(KERN_ERR "isdn_ppp_receive: lp->ppp_slot(%d)\n", 979 printk(KERN_ERR "isdn_ppp_receive: lp->ppp_slot(%d)\n",
980 lp->ppp_slot); 980 lp->ppp_slot);
981 kfree_skb(skb); 981 kfree_skb(skb);
982 return; 982 return;
983 } 983 }
@@ -985,35 +985,35 @@ void isdn_ppp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff
985 985
986 if (is->debug & 0x4) { 986 if (is->debug & 0x4) {
987 printk(KERN_DEBUG "ippp_receive: is:%08lx lp:%08lx slot:%d unit:%d len:%d\n", 987 printk(KERN_DEBUG "ippp_receive: is:%08lx lp:%08lx slot:%d unit:%d len:%d\n",
988 (long)is, (long)lp, lp->ppp_slot, is->unit, (int)skb->len); 988 (long)is,(long)lp,lp->ppp_slot,is->unit,(int) skb->len);
989 isdn_ppp_frame_log("receive", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 989 isdn_ppp_frame_log("receive", skb->data, skb->len, 32,is->unit,lp->ppp_slot);
990 } 990 }
991 991
992 if (isdn_ppp_skip_ac(is, skb) < 0) { 992 if (isdn_ppp_skip_ac(is, skb) < 0) {
993 kfree_skb(skb); 993 kfree_skb(skb);
994 return; 994 return;
995 } 995 }
996 proto = isdn_ppp_strip_proto(skb); 996 proto = isdn_ppp_strip_proto(skb);
997 if (proto < 0) { 997 if (proto < 0) {
998 kfree_skb(skb); 998 kfree_skb(skb);
999 return; 999 return;
1000 } 1000 }
1001 1001
1002#ifdef CONFIG_ISDN_MPP 1002#ifdef CONFIG_ISDN_MPP
1003 if (is->compflags & SC_LINK_DECOMP_ON) { 1003 if (is->compflags & SC_LINK_DECOMP_ON) {
1004 skb = isdn_ppp_decompress(skb, is, NULL, &proto); 1004 skb = isdn_ppp_decompress(skb, is, NULL, &proto);
1005 if (!skb) // decompression error 1005 if (!skb) // decompression error
1006 return; 1006 return;
1007 } 1007 }
1008 1008
1009 if (!(is->mpppcfg & SC_REJ_MP_PROT)) { // we agreed to receive MPPP 1009 if (!(is->mpppcfg & SC_REJ_MP_PROT)) { // we agreed to receive MPPP
1010 if (proto == PPP_MP) { 1010 if (proto == PPP_MP) {
1011 isdn_ppp_mp_receive(net_dev, lp, skb); 1011 isdn_ppp_mp_receive(net_dev, lp, skb);
1012 return; 1012 return;
1013 } 1013 }
1014 } 1014 }
1015#endif 1015#endif
1016 isdn_ppp_push_higher(net_dev, lp, skb, proto); 1016 isdn_ppp_push_higher(net_dev, lp, skb, proto);
1017} 1017}
1018 1018
1019/* 1019/*
@@ -1022,116 +1022,116 @@ void isdn_ppp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff
1022 * note: net_dev has to be master net_dev 1022 * note: net_dev has to be master net_dev
1023 */ 1023 */
1024static void 1024static void
1025isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb, int proto) 1025isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb, int proto)
1026{ 1026{
1027 struct net_device *dev = net_dev->dev; 1027 struct net_device *dev = net_dev->dev;
1028 struct ippp_struct *is, *mis; 1028 struct ippp_struct *is, *mis;
1029 isdn_net_local *mlp = NULL; 1029 isdn_net_local *mlp = NULL;
1030 int slot; 1030 int slot;
1031 1031
1032 slot = lp->ppp_slot; 1032 slot = lp->ppp_slot;
1033 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1033 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1034 printk(KERN_ERR "isdn_ppp_push_higher: lp->ppp_slot(%d)\n", 1034 printk(KERN_ERR "isdn_ppp_push_higher: lp->ppp_slot(%d)\n",
1035 lp->ppp_slot); 1035 lp->ppp_slot);
1036 goto drop_packet; 1036 goto drop_packet;
1037 } 1037 }
1038 is = ippp_table[slot]; 1038 is = ippp_table[slot];
1039 1039
1040 if (lp->master) { // FIXME? 1040 if (lp->master) { // FIXME?
1041 mlp = ISDN_MASTER_PRIV(lp); 1041 mlp = ISDN_MASTER_PRIV(lp);
1042 slot = mlp->ppp_slot; 1042 slot = mlp->ppp_slot;
1043 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1043 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1044 printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n", 1044 printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n",
1045 lp->ppp_slot); 1045 lp->ppp_slot);
1046 goto drop_packet; 1046 goto drop_packet;
1047 } 1047 }
1048 } 1048 }
1049 mis = ippp_table[slot]; 1049 mis = ippp_table[slot];
1050 1050
1051 if (is->debug & 0x10) { 1051 if (is->debug & 0x10) {
1052 printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto); 1052 printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto);
1053 isdn_ppp_frame_log("rpush", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 1053 isdn_ppp_frame_log("rpush", skb->data, skb->len, 32,is->unit,lp->ppp_slot);
1054 } 1054 }
1055 if (mis->compflags & SC_DECOMP_ON) { 1055 if (mis->compflags & SC_DECOMP_ON) {
1056 skb = isdn_ppp_decompress(skb, is, mis, &proto); 1056 skb = isdn_ppp_decompress(skb, is, mis, &proto);
1057 if (!skb) // decompression error 1057 if (!skb) // decompression error
1058 return; 1058 return;
1059 } 1059 }
1060 switch (proto) { 1060 switch (proto) {
1061 case PPP_IPX: /* untested */ 1061 case PPP_IPX: /* untested */
1062 if (is->debug & 0x20) 1062 if (is->debug & 0x20)
1063 printk(KERN_DEBUG "isdn_ppp: IPX\n"); 1063 printk(KERN_DEBUG "isdn_ppp: IPX\n");
1064 skb->protocol = htons(ETH_P_IPX); 1064 skb->protocol = htons(ETH_P_IPX);
1065 break; 1065 break;
1066 case PPP_IP: 1066 case PPP_IP:
1067 if (is->debug & 0x20) 1067 if (is->debug & 0x20)
1068 printk(KERN_DEBUG "isdn_ppp: IP\n"); 1068 printk(KERN_DEBUG "isdn_ppp: IP\n");
1069 skb->protocol = htons(ETH_P_IP); 1069 skb->protocol = htons(ETH_P_IP);
1070 break; 1070 break;
1071 case PPP_COMP: 1071 case PPP_COMP:
1072 case PPP_COMPFRAG: 1072 case PPP_COMPFRAG:
1073 printk(KERN_INFO "isdn_ppp: unexpected compressed frame dropped\n"); 1073 printk(KERN_INFO "isdn_ppp: unexpected compressed frame dropped\n");
1074 goto drop_packet;
1075#ifdef CONFIG_ISDN_PPP_VJ
1076 case PPP_VJC_UNCOMP:
1077 if (is->debug & 0x20)
1078 printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n");
1079 if (net_dev->local->ppp_slot < 0) {
1080 printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n",
1081 __func__, net_dev->local->ppp_slot);
1082 goto drop_packet;
1083 }
1084 if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) {
1085 printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n");
1086 goto drop_packet; 1074 goto drop_packet;
1087 } 1075#ifdef CONFIG_ISDN_PPP_VJ
1088 skb->protocol = htons(ETH_P_IP); 1076 case PPP_VJC_UNCOMP:
1089 break; 1077 if (is->debug & 0x20)
1090 case PPP_VJC_COMP: 1078 printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n");
1091 if (is->debug & 0x20)
1092 printk(KERN_DEBUG "isdn_ppp: VJC_COMP\n");
1093 {
1094 struct sk_buff *skb_old = skb;
1095 int pkt_len;
1096 skb = dev_alloc_skb(skb_old->len + 128);
1097
1098 if (!skb) {
1099 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name);
1100 skb = skb_old;
1101 goto drop_packet;
1102 }
1103 skb_put(skb, skb_old->len + 128);
1104 skb_copy_from_linear_data(skb_old, skb->data,
1105 skb_old->len);
1106 if (net_dev->local->ppp_slot < 0) { 1079 if (net_dev->local->ppp_slot < 0) {
1107 printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", 1080 printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n",
1108 __func__, net_dev->local->ppp_slot); 1081 __func__, net_dev->local->ppp_slot);
1109 goto drop_packet; 1082 goto drop_packet;
1110 } 1083 }
1111 pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp, 1084 if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) {
1112 skb->data, skb_old->len); 1085 printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n");
1113 kfree_skb(skb_old);
1114 if (pkt_len < 0)
1115 goto drop_packet; 1086 goto drop_packet;
1116 1087 }
1117 skb_trim(skb, pkt_len);
1118 skb->protocol = htons(ETH_P_IP); 1088 skb->protocol = htons(ETH_P_IP);
1119 }
1120 break;
1121#endif
1122 case PPP_CCP:
1123 case PPP_CCPFRAG:
1124 isdn_ppp_receive_ccp(net_dev, lp, skb, proto);
1125 /* Dont pop up ResetReq/Ack stuff to the daemon any
1126 longer - the job is done already */
1127 if (skb->data[0] == CCP_RESETREQ ||
1128 skb->data[0] == CCP_RESETACK)
1129 break; 1089 break;
1130 /* fall through */ 1090 case PPP_VJC_COMP:
1131 default: 1091 if (is->debug & 0x20)
1132 isdn_ppp_fill_rq(skb->data, skb->len, proto, lp->ppp_slot); /* push data to pppd device */ 1092 printk(KERN_DEBUG "isdn_ppp: VJC_COMP\n");
1133 kfree_skb(skb); 1093 {
1134 return; 1094 struct sk_buff *skb_old = skb;
1095 int pkt_len;
1096 skb = dev_alloc_skb(skb_old->len + 128);
1097
1098 if (!skb) {
1099 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name);
1100 skb = skb_old;
1101 goto drop_packet;
1102 }
1103 skb_put(skb, skb_old->len + 128);
1104 skb_copy_from_linear_data(skb_old, skb->data,
1105 skb_old->len);
1106 if (net_dev->local->ppp_slot < 0) {
1107 printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n",
1108 __func__, net_dev->local->ppp_slot);
1109 goto drop_packet;
1110 }
1111 pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp,
1112 skb->data, skb_old->len);
1113 kfree_skb(skb_old);
1114 if (pkt_len < 0)
1115 goto drop_packet;
1116
1117 skb_trim(skb, pkt_len);
1118 skb->protocol = htons(ETH_P_IP);
1119 }
1120 break;
1121#endif
1122 case PPP_CCP:
1123 case PPP_CCPFRAG:
1124 isdn_ppp_receive_ccp(net_dev,lp,skb,proto);
1125 /* Dont pop up ResetReq/Ack stuff to the daemon any
1126 longer - the job is done already */
1127 if(skb->data[0] == CCP_RESETREQ ||
1128 skb->data[0] == CCP_RESETACK)
1129 break;
1130 /* fall through */
1131 default:
1132 isdn_ppp_fill_rq(skb->data, skb->len, proto, lp->ppp_slot); /* push data to pppd device */
1133 kfree_skb(skb);
1134 return;
1135 } 1135 }
1136 1136
1137#ifdef CONFIG_IPPP_FILTER 1137#ifdef CONFIG_IPPP_FILTER
@@ -1156,7 +1156,7 @@ isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *
1156 if (!(is->active_filter 1156 if (!(is->active_filter
1157 && sk_run_filter(skb, is->active_filter) == 0)) { 1157 && sk_run_filter(skb, is->active_filter) == 0)) {
1158 if (is->debug & 0x2) 1158 if (is->debug & 0x2)
1159 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); 1159 printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n");
1160 lp->huptimer = 0; 1160 lp->huptimer = 0;
1161 if (mlp) 1161 if (mlp)
1162 mlp->huptimer = 0; 1162 mlp->huptimer = 0;
@@ -1173,7 +1173,7 @@ isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *
1173 /* net_dev->local->stats.rx_packets++; done in isdn_net.c */ 1173 /* net_dev->local->stats.rx_packets++; done in isdn_net.c */
1174 return; 1174 return;
1175 1175
1176drop_packet: 1176 drop_packet:
1177 net_dev->local->stats.rx_dropped++; 1177 net_dev->local->stats.rx_dropped++;
1178 kfree_skb(skb); 1178 kfree_skb(skb);
1179} 1179}
@@ -1183,11 +1183,11 @@ drop_packet:
1183 * checks whether we have enough space at the beginning of the skb 1183 * checks whether we have enough space at the beginning of the skb
1184 * and allocs a new SKB if necessary 1184 * and allocs a new SKB if necessary
1185 */ 1185 */
1186static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p, int len) 1186static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len)
1187{ 1187{
1188 struct sk_buff *skb = *skb_p; 1188 struct sk_buff *skb = *skb_p;
1189 1189
1190 if (skb_headroom(skb) < len) { 1190 if(skb_headroom(skb) < len) {
1191 struct sk_buff *nskb = skb_realloc_headroom(skb, len); 1191 struct sk_buff *nskb = skb_realloc_headroom(skb, len);
1192 1192
1193 if (!nskb) { 1193 if (!nskb) {
@@ -1195,12 +1195,12 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p, int len)
1195 dev_kfree_skb(skb); 1195 dev_kfree_skb(skb);
1196 return NULL; 1196 return NULL;
1197 } 1197 }
1198 printk(KERN_DEBUG "isdn_ppp_skb_push:under %d %d\n", skb_headroom(skb), len); 1198 printk(KERN_DEBUG "isdn_ppp_skb_push:under %d %d\n",skb_headroom(skb),len);
1199 dev_kfree_skb(skb); 1199 dev_kfree_skb(skb);
1200 *skb_p = nskb; 1200 *skb_p = nskb;
1201 return skb_push(nskb, len); 1201 return skb_push(nskb, len);
1202 } 1202 }
1203 return skb_push(skb, len); 1203 return skb_push(skb,len);
1204} 1204}
1205 1205
1206/* 1206/*
@@ -1214,10 +1214,10 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p, int len)
1214int 1214int
1215isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) 1215isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1216{ 1216{
1217 isdn_net_local *lp, *mlp; 1217 isdn_net_local *lp,*mlp;
1218 isdn_net_dev *nd; 1218 isdn_net_dev *nd;
1219 unsigned int proto = PPP_IP; /* 0x21 */ 1219 unsigned int proto = PPP_IP; /* 0x21 */
1220 struct ippp_struct *ipt, *ipts; 1220 struct ippp_struct *ipt,*ipts;
1221 int slot, retval = NETDEV_TX_OK; 1221 int slot, retval = NETDEV_TX_OK;
1222 1222
1223 mlp = netdev_priv(netdev); 1223 mlp = netdev_priv(netdev);
@@ -1226,7 +1226,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1226 slot = mlp->ppp_slot; 1226 slot = mlp->ppp_slot;
1227 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1227 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1228 printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n", 1228 printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n",
1229 mlp->ppp_slot); 1229 mlp->ppp_slot);
1230 kfree_skb(skb); 1230 kfree_skb(skb);
1231 goto out; 1231 goto out;
1232 } 1232 }
@@ -1240,17 +1240,17 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1240 } 1240 }
1241 1241
1242 switch (ntohs(skb->protocol)) { 1242 switch (ntohs(skb->protocol)) {
1243 case ETH_P_IP: 1243 case ETH_P_IP:
1244 proto = PPP_IP; 1244 proto = PPP_IP;
1245 break; 1245 break;
1246 case ETH_P_IPX: 1246 case ETH_P_IPX:
1247 proto = PPP_IPX; /* untested */ 1247 proto = PPP_IPX; /* untested */
1248 break; 1248 break;
1249 default: 1249 default:
1250 printk(KERN_ERR "isdn_ppp: skipped unsupported protocol: %#x.\n", 1250 printk(KERN_ERR "isdn_ppp: skipped unsupported protocol: %#x.\n",
1251 skb->protocol); 1251 skb->protocol);
1252 dev_kfree_skb(skb); 1252 dev_kfree_skb(skb);
1253 goto out; 1253 goto out;
1254 } 1254 }
1255 1255
1256 lp = isdn_net_get_locked_lp(nd); 1256 lp = isdn_net_get_locked_lp(nd);
@@ -1264,7 +1264,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1264 slot = lp->ppp_slot; 1264 slot = lp->ppp_slot;
1265 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1265 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1266 printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n", 1266 printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n",
1267 lp->ppp_slot); 1267 lp->ppp_slot);
1268 kfree_skb(skb); 1268 kfree_skb(skb);
1269 goto unlock; 1269 goto unlock;
1270 } 1270 }
@@ -1277,7 +1277,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1277 /* Pull off the fake header we stuck on earlier to keep 1277 /* Pull off the fake header we stuck on earlier to keep
1278 * the fragmentation code happy. 1278 * the fragmentation code happy.
1279 */ 1279 */
1280 skb_pull(skb, IPPP_MAX_HEADER); 1280 skb_pull(skb,IPPP_MAX_HEADER);
1281 1281
1282#ifdef CONFIG_IPPP_FILTER 1282#ifdef CONFIG_IPPP_FILTER
1283 /* check if we should pass this packet 1283 /* check if we should pass this packet
@@ -1302,7 +1302,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1302 if (!(ipt->active_filter 1302 if (!(ipt->active_filter
1303 && sk_run_filter(skb, ipt->active_filter) == 0)) { 1303 && sk_run_filter(skb, ipt->active_filter) == 0)) {
1304 if (ipt->debug & 0x4) 1304 if (ipt->debug & 0x4)
1305 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); 1305 printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n");
1306 lp->huptimer = 0; 1306 lp->huptimer = 0;
1307 } 1307 }
1308 skb_pull(skb, 4); 1308 skb_pull(skb, 4);
@@ -1312,26 +1312,26 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1312 1312
1313 if (ipt->debug & 0x4) 1313 if (ipt->debug & 0x4)
1314 printk(KERN_DEBUG "xmit skb, len %d\n", (int) skb->len); 1314 printk(KERN_DEBUG "xmit skb, len %d\n", (int) skb->len);
1315 if (ipts->debug & 0x40) 1315 if (ipts->debug & 0x40)
1316 isdn_ppp_frame_log("xmit0", skb->data, skb->len, 32, ipts->unit, lp->ppp_slot); 1316 isdn_ppp_frame_log("xmit0", skb->data, skb->len, 32,ipts->unit,lp->ppp_slot);
1317 1317
1318#ifdef CONFIG_ISDN_PPP_VJ 1318#ifdef CONFIG_ISDN_PPP_VJ
1319 if (proto == PPP_IP && ipts->pppcfg & SC_COMP_TCP) { /* ipts here? probably yes, but check this again */ 1319 if (proto == PPP_IP && ipts->pppcfg & SC_COMP_TCP) { /* ipts here? probably yes, but check this again */
1320 struct sk_buff *new_skb; 1320 struct sk_buff *new_skb;
1321 unsigned short hl; 1321 unsigned short hl;
1322 /* 1322 /*
1323 * we need to reserve enough space in front of 1323 * we need to reserve enough space in front of
1324 * sk_buff. old call to dev_alloc_skb only reserved 1324 * sk_buff. old call to dev_alloc_skb only reserved
1325 * 16 bytes, now we are looking what the driver want. 1325 * 16 bytes, now we are looking what the driver want.
1326 */ 1326 */
1327 hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen + IPPP_MAX_HEADER; 1327 hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen + IPPP_MAX_HEADER;
1328 /* 1328 /*
1329 * Note: hl might still be insufficient because the method 1329 * Note: hl might still be insufficient because the method
1330 * above does not account for a possibible MPPP slave channel 1330 * above does not account for a possibible MPPP slave channel
1331 * which had larger HL header space requirements than the 1331 * which had larger HL header space requirements than the
1332 * master. 1332 * master.
1333 */ 1333 */
1334 new_skb = alloc_skb(hl + skb->len, GFP_ATOMIC); 1334 new_skb = alloc_skb(hl+skb->len, GFP_ATOMIC);
1335 if (new_skb) { 1335 if (new_skb) {
1336 u_char *buf; 1336 u_char *buf;
1337 int pktlen; 1337 int pktlen;
@@ -1342,9 +1342,9 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1342 buf = skb->data; 1342 buf = skb->data;
1343 1343
1344 pktlen = slhc_compress(ipts->slcomp, skb->data, skb->len, new_skb->data, 1344 pktlen = slhc_compress(ipts->slcomp, skb->data, skb->len, new_skb->data,
1345 &buf, !(ipts->pppcfg & SC_NO_TCP_CCID)); 1345 &buf, !(ipts->pppcfg & SC_NO_TCP_CCID));
1346 1346
1347 if (buf != skb->data) { 1347 if (buf != skb->data) {
1348 if (new_skb->data != buf) 1348 if (new_skb->data != buf)
1349 printk(KERN_ERR "isdn_ppp: FATAL error after slhc_compress!!\n"); 1349 printk(KERN_ERR "isdn_ppp: FATAL error after slhc_compress!!\n");
1350 dev_kfree_skb(skb); 1350 dev_kfree_skb(skb);
@@ -1369,11 +1369,11 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1369 /* 1369 /*
1370 * normal (single link) or bundle compression 1370 * normal (single link) or bundle compression
1371 */ 1371 */
1372 if (ipts->compflags & SC_COMP_ON) { 1372 if(ipts->compflags & SC_COMP_ON) {
1373 /* We send compressed only if both down- und upstream 1373 /* We send compressed only if both down- und upstream
1374 compression is negotiated, that means, CCP is up */ 1374 compression is negotiated, that means, CCP is up */
1375 if (ipts->compflags & SC_DECOMP_ON) { 1375 if(ipts->compflags & SC_DECOMP_ON) {
1376 skb = isdn_ppp_compress(skb, &proto, ipt, ipts, 0); 1376 skb = isdn_ppp_compress(skb,&proto,ipt,ipts,0);
1377 } else { 1377 } else {
1378 printk(KERN_DEBUG "isdn_ppp: CCP not yet up - sending as-is\n"); 1378 printk(KERN_DEBUG "isdn_ppp: CCP not yet up - sending as-is\n");
1379 } 1379 }
@@ -1389,7 +1389,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1389 ipts->mp_seqno++; 1389 ipts->mp_seqno++;
1390 if (ipt->mpppcfg & SC_OUT_SHORT_SEQ) { 1390 if (ipt->mpppcfg & SC_OUT_SHORT_SEQ) {
1391 unsigned char *data = isdn_ppp_skb_push(&skb, 3); 1391 unsigned char *data = isdn_ppp_skb_push(&skb, 3);
1392 if (!data) 1392 if(!data)
1393 goto unlock; 1393 goto unlock;
1394 mp_seqno &= 0xfff; 1394 mp_seqno &= 0xfff;
1395 data[0] = MP_BEGIN_FRAG | MP_END_FRAG | ((mp_seqno >> 8) & 0xf); /* (B)egin & (E)ndbit .. */ 1395 data[0] = MP_BEGIN_FRAG | MP_END_FRAG | ((mp_seqno >> 8) & 0xf); /* (B)egin & (E)ndbit .. */
@@ -1397,7 +1397,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1397 data[2] = proto; /* PID compression */ 1397 data[2] = proto; /* PID compression */
1398 } else { 1398 } else {
1399 unsigned char *data = isdn_ppp_skb_push(&skb, 5); 1399 unsigned char *data = isdn_ppp_skb_push(&skb, 5);
1400 if (!data) 1400 if(!data)
1401 goto unlock; 1401 goto unlock;
1402 data[0] = MP_BEGIN_FRAG | MP_END_FRAG; /* (B)egin & (E)ndbit .. */ 1402 data[0] = MP_BEGIN_FRAG | MP_END_FRAG; /* (B)egin & (E)ndbit .. */
1403 data[1] = (mp_seqno >> 16) & 0xff; /* sequence number: 24bit */ 1403 data[1] = (mp_seqno >> 16) & 0xff; /* sequence number: 24bit */
@@ -1412,25 +1412,25 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1412 /* 1412 /*
1413 * 'link in bundle' compression ... 1413 * 'link in bundle' compression ...
1414 */ 1414 */
1415 if (ipt->compflags & SC_LINK_COMP_ON) 1415 if(ipt->compflags & SC_LINK_COMP_ON)
1416 skb = isdn_ppp_compress(skb, &proto, ipt, ipts, 1); 1416 skb = isdn_ppp_compress(skb,&proto,ipt,ipts,1);
1417 1417
1418 if ((ipt->pppcfg & SC_COMP_PROT) && (proto <= 0xff)) { 1418 if( (ipt->pppcfg & SC_COMP_PROT) && (proto <= 0xff) ) {
1419 unsigned char *data = isdn_ppp_skb_push(&skb, 1); 1419 unsigned char *data = isdn_ppp_skb_push(&skb,1);
1420 if (!data) 1420 if(!data)
1421 goto unlock; 1421 goto unlock;
1422 data[0] = proto & 0xff; 1422 data[0] = proto & 0xff;
1423 } 1423 }
1424 else { 1424 else {
1425 unsigned char *data = isdn_ppp_skb_push(&skb, 2); 1425 unsigned char *data = isdn_ppp_skb_push(&skb,2);
1426 if (!data) 1426 if(!data)
1427 goto unlock; 1427 goto unlock;
1428 data[0] = (proto >> 8) & 0xff; 1428 data[0] = (proto >> 8) & 0xff;
1429 data[1] = proto & 0xff; 1429 data[1] = proto & 0xff;
1430 } 1430 }
1431 if (!(ipt->pppcfg & SC_COMP_AC)) { 1431 if(!(ipt->pppcfg & SC_COMP_AC)) {
1432 unsigned char *data = isdn_ppp_skb_push(&skb, 2); 1432 unsigned char *data = isdn_ppp_skb_push(&skb,2);
1433 if (!data) 1433 if(!data)
1434 goto unlock; 1434 goto unlock;
1435 data[0] = 0xff; /* All Stations */ 1435 data[0] = 0xff; /* All Stations */
1436 data[1] = 0x03; /* Unnumbered information */ 1436 data[1] = 0x03; /* Unnumbered information */
@@ -1440,14 +1440,14 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1440 1440
1441 if (ipts->debug & 0x40) { 1441 if (ipts->debug & 0x40) {
1442 printk(KERN_DEBUG "skb xmit: len: %d\n", (int) skb->len); 1442 printk(KERN_DEBUG "skb xmit: len: %d\n", (int) skb->len);
1443 isdn_ppp_frame_log("xmit", skb->data, skb->len, 32, ipt->unit, lp->ppp_slot); 1443 isdn_ppp_frame_log("xmit", skb->data, skb->len, 32,ipt->unit,lp->ppp_slot);
1444 } 1444 }
1445 1445
1446 isdn_net_writebuf_skb(lp, skb); 1446 isdn_net_writebuf_skb(lp, skb);
1447 1447
1448unlock: 1448 unlock:
1449 spin_unlock_bh(&lp->xmit_lock); 1449 spin_unlock_bh(&lp->xmit_lock);
1450out: 1450 out:
1451 return retval; 1451 return retval;
1452} 1452}
1453 1453
@@ -1488,12 +1488,12 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
1488 p++; 1488 p++;
1489 *p = htons(proto); 1489 *p = htons(proto);
1490 } 1490 }
1491 1491
1492 drop |= is->pass_filter 1492 drop |= is->pass_filter
1493 && sk_run_filter(skb, is->pass_filter) == 0; 1493 && sk_run_filter(skb, is->pass_filter) == 0;
1494 drop |= is->active_filter 1494 drop |= is->active_filter
1495 && sk_run_filter(skb, is->active_filter) == 0; 1495 && sk_run_filter(skb, is->active_filter) == 0;
1496 1496
1497 skb_push(skb, IPPP_MAX_HEADER - 4); 1497 skb_push(skb, IPPP_MAX_HEADER - 4);
1498 return drop; 1498 return drop;
1499} 1499}
@@ -1502,8 +1502,8 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
1502 1502
1503/* this is _not_ rfc1990 header, but something we convert both short and long 1503/* this is _not_ rfc1990 header, but something we convert both short and long
1504 * headers to for convinience's sake: 1504 * headers to for convinience's sake:
1505 * byte 0 is flags as in rfc1990 1505 * byte 0 is flags as in rfc1990
1506 * bytes 1...4 is 24-bit seqence number converted to host byte order 1506 * bytes 1...4 is 24-bit seqence number converted to host byte order
1507 */ 1507 */
1508#define MP_HEADER_LEN 5 1508#define MP_HEADER_LEN 5
1509 1509
@@ -1511,51 +1511,51 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
1511#define MP_SHORTSEQ_MASK 0x00000fff 1511#define MP_SHORTSEQ_MASK 0x00000fff
1512#define MP_LONGSEQ_MAX MP_LONGSEQ_MASK 1512#define MP_LONGSEQ_MAX MP_LONGSEQ_MASK
1513#define MP_SHORTSEQ_MAX MP_SHORTSEQ_MASK 1513#define MP_SHORTSEQ_MAX MP_SHORTSEQ_MASK
1514#define MP_LONGSEQ_MAXBIT ((MP_LONGSEQ_MASK + 1) >> 1) 1514#define MP_LONGSEQ_MAXBIT ((MP_LONGSEQ_MASK+1)>>1)
1515#define MP_SHORTSEQ_MAXBIT ((MP_SHORTSEQ_MASK + 1) >> 1) 1515#define MP_SHORTSEQ_MAXBIT ((MP_SHORTSEQ_MASK+1)>>1)
1516 1516
1517/* sequence-wrap safe comparisons (for long sequence)*/ 1517/* sequence-wrap safe comparisons (for long sequence)*/
1518#define MP_LT(a, b) ((a - b) & MP_LONGSEQ_MAXBIT) 1518#define MP_LT(a,b) ((a-b)&MP_LONGSEQ_MAXBIT)
1519#define MP_LE(a, b) !((b - a) & MP_LONGSEQ_MAXBIT) 1519#define MP_LE(a,b) !((b-a)&MP_LONGSEQ_MAXBIT)
1520#define MP_GT(a, b) ((b - a) & MP_LONGSEQ_MAXBIT) 1520#define MP_GT(a,b) ((b-a)&MP_LONGSEQ_MAXBIT)
1521#define MP_GE(a, b) !((a - b) & MP_LONGSEQ_MAXBIT) 1521#define MP_GE(a,b) !((a-b)&MP_LONGSEQ_MAXBIT)
1522 1522
1523#define MP_SEQ(f) ((*(u32 *)(f->data + 1))) 1523#define MP_SEQ(f) ((*(u32*)(f->data+1)))
1524#define MP_FLAGS(f) (f->data[0]) 1524#define MP_FLAGS(f) (f->data[0])
1525 1525
1526static int isdn_ppp_mp_bundle_array_init(void) 1526static int isdn_ppp_mp_bundle_array_init(void)
1527{ 1527{
1528 int i; 1528 int i;
1529 int sz = ISDN_MAX_CHANNELS * sizeof(ippp_bundle); 1529 int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle);
1530 if ((isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL) 1530 if( (isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL )
1531 return -ENOMEM; 1531 return -ENOMEM;
1532 for (i = 0; i < ISDN_MAX_CHANNELS; i++) 1532 for( i = 0; i < ISDN_MAX_CHANNELS; i++ )
1533 spin_lock_init(&isdn_ppp_bundle_arr[i].lock); 1533 spin_lock_init(&isdn_ppp_bundle_arr[i].lock);
1534 return 0; 1534 return 0;
1535} 1535}
1536 1536
1537static ippp_bundle *isdn_ppp_mp_bundle_alloc(void) 1537static ippp_bundle * isdn_ppp_mp_bundle_alloc(void)
1538{ 1538{
1539 int i; 1539 int i;
1540 for (i = 0; i < ISDN_MAX_CHANNELS; i++) 1540 for( i = 0; i < ISDN_MAX_CHANNELS; i++ )
1541 if (isdn_ppp_bundle_arr[i].ref_ct <= 0) 1541 if (isdn_ppp_bundle_arr[i].ref_ct <= 0)
1542 return (isdn_ppp_bundle_arr + i); 1542 return (isdn_ppp_bundle_arr + i);
1543 return NULL; 1543 return NULL;
1544} 1544}
1545 1545
1546static int isdn_ppp_mp_init(isdn_net_local *lp, ippp_bundle *add_to) 1546static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to )
1547{ 1547{
1548 struct ippp_struct *is; 1548 struct ippp_struct * is;
1549 1549
1550 if (lp->ppp_slot < 0) { 1550 if (lp->ppp_slot < 0) {
1551 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", 1551 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n",
1552 __func__, lp->ppp_slot); 1552 __func__, lp->ppp_slot);
1553 return (-EINVAL); 1553 return(-EINVAL);
1554 } 1554 }
1555 1555
1556 is = ippp_table[lp->ppp_slot]; 1556 is = ippp_table[lp->ppp_slot];
1557 if (add_to) { 1557 if (add_to) {
1558 if (lp->netdev->pb) 1558 if( lp->netdev->pb )
1559 lp->netdev->pb->ref_ct--; 1559 lp->netdev->pb->ref_ct--;
1560 lp->netdev->pb = add_to; 1560 lp->netdev->pb = add_to;
1561 } else { /* first link in a bundle */ 1561 } else { /* first link in a bundle */
@@ -1568,76 +1568,76 @@ static int isdn_ppp_mp_init(isdn_net_local *lp, ippp_bundle *add_to)
1568 lp->netdev->pb->seq = UINT_MAX; 1568 lp->netdev->pb->seq = UINT_MAX;
1569 } 1569 }
1570 lp->netdev->pb->ref_ct++; 1570 lp->netdev->pb->ref_ct++;
1571 1571
1572 is->last_link_seqno = 0; 1572 is->last_link_seqno = 0;
1573 return 0; 1573 return 0;
1574} 1574}
1575 1575
1576static u32 isdn_ppp_mp_get_seq(int short_seq, 1576static u32 isdn_ppp_mp_get_seq( int short_seq,
1577 struct sk_buff *skb, u32 last_seq); 1577 struct sk_buff * skb, u32 last_seq );
1578static struct sk_buff *isdn_ppp_mp_discard(ippp_bundle *mp, 1578static struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp,
1579 struct sk_buff *from, struct sk_buff *to); 1579 struct sk_buff * from, struct sk_buff * to );
1580static void isdn_ppp_mp_reassembly(isdn_net_dev *net_dev, isdn_net_local *lp, 1580static void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp,
1581 struct sk_buff *from, struct sk_buff *to); 1581 struct sk_buff * from, struct sk_buff * to );
1582static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb); 1582static void isdn_ppp_mp_free_skb( ippp_bundle * mp, struct sk_buff * skb );
1583static void isdn_ppp_mp_print_recv_pkt(int slot, struct sk_buff *skb); 1583static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb );
1584 1584
1585static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, 1585static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp,
1586 struct sk_buff *skb) 1586 struct sk_buff *skb)
1587{ 1587{
1588 struct ippp_struct *is; 1588 struct ippp_struct *is;
1589 isdn_net_local *lpq; 1589 isdn_net_local * lpq;
1590 ippp_bundle *mp; 1590 ippp_bundle * mp;
1591 isdn_mppp_stats *stats; 1591 isdn_mppp_stats * stats;
1592 struct sk_buff *newfrag, *frag, *start, *nextf; 1592 struct sk_buff * newfrag, * frag, * start, *nextf;
1593 u32 newseq, minseq, thisseq; 1593 u32 newseq, minseq, thisseq;
1594 unsigned long flags; 1594 unsigned long flags;
1595 int slot; 1595 int slot;
1596 1596
1597 spin_lock_irqsave(&net_dev->pb->lock, flags); 1597 spin_lock_irqsave(&net_dev->pb->lock, flags);
1598 mp = net_dev->pb; 1598 mp = net_dev->pb;
1599 stats = &mp->stats; 1599 stats = &mp->stats;
1600 slot = lp->ppp_slot; 1600 slot = lp->ppp_slot;
1601 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1601 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1602 printk(KERN_ERR "%s: lp->ppp_slot(%d)\n", 1602 printk(KERN_ERR "%s: lp->ppp_slot(%d)\n",
1603 __func__, lp->ppp_slot); 1603 __func__, lp->ppp_slot);
1604 stats->frame_drops++; 1604 stats->frame_drops++;
1605 dev_kfree_skb(skb); 1605 dev_kfree_skb(skb);
1606 spin_unlock_irqrestore(&mp->lock, flags); 1606 spin_unlock_irqrestore(&mp->lock, flags);
1607 return; 1607 return;
1608 } 1608 }
1609 is = ippp_table[slot]; 1609 is = ippp_table[slot];
1610 if (++mp->frames > stats->max_queue_len) 1610 if( ++mp->frames > stats->max_queue_len )
1611 stats->max_queue_len = mp->frames; 1611 stats->max_queue_len = mp->frames;
1612 1612
1613 if (is->debug & 0x8) 1613 if (is->debug & 0x8)
1614 isdn_ppp_mp_print_recv_pkt(lp->ppp_slot, skb); 1614 isdn_ppp_mp_print_recv_pkt(lp->ppp_slot, skb);
1615 1615
1616 newseq = isdn_ppp_mp_get_seq(is->mpppcfg & SC_IN_SHORT_SEQ, 1616 newseq = isdn_ppp_mp_get_seq(is->mpppcfg & SC_IN_SHORT_SEQ,
1617 skb, is->last_link_seqno); 1617 skb, is->last_link_seqno);
1618 1618
1619 1619
1620 /* if this packet seq # is less than last already processed one, 1620 /* if this packet seq # is less than last already processed one,
1621 * toss it right away, but check for sequence start case first 1621 * toss it right away, but check for sequence start case first
1622 */ 1622 */
1623 if (mp->seq > MP_LONGSEQ_MAX && (newseq & MP_LONGSEQ_MAXBIT)) { 1623 if( mp->seq > MP_LONGSEQ_MAX && (newseq & MP_LONGSEQ_MAXBIT) ) {
1624 mp->seq = newseq; /* the first packet: required for 1624 mp->seq = newseq; /* the first packet: required for
1625 * rfc1990 non-compliant clients -- 1625 * rfc1990 non-compliant clients --
1626 * prevents constant packet toss */ 1626 * prevents constant packet toss */
1627 } else if (MP_LT(newseq, mp->seq)) { 1627 } else if( MP_LT(newseq, mp->seq) ) {
1628 stats->frame_drops++; 1628 stats->frame_drops++;
1629 isdn_ppp_mp_free_skb(mp, skb); 1629 isdn_ppp_mp_free_skb(mp, skb);
1630 spin_unlock_irqrestore(&mp->lock, flags); 1630 spin_unlock_irqrestore(&mp->lock, flags);
1631 return; 1631 return;
1632 } 1632 }
1633 1633
1634 /* find the minimum received sequence number over all links */ 1634 /* find the minimum received sequence number over all links */
1635 is->last_link_seqno = minseq = newseq; 1635 is->last_link_seqno = minseq = newseq;
1636 for (lpq = net_dev->queue;;) { 1636 for (lpq = net_dev->queue;;) {
1637 slot = lpq->ppp_slot; 1637 slot = lpq->ppp_slot;
1638 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 1638 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
1639 printk(KERN_ERR "%s: lpq->ppp_slot(%d)\n", 1639 printk(KERN_ERR "%s: lpq->ppp_slot(%d)\n",
1640 __func__, lpq->ppp_slot); 1640 __func__, lpq->ppp_slot);
1641 } else { 1641 } else {
1642 u32 lls = ippp_table[slot]->last_link_seqno; 1642 u32 lls = ippp_table[slot]->last_link_seqno;
1643 if (MP_LT(lls, minseq)) 1643 if (MP_LT(lls, minseq))
@@ -1651,17 +1651,17 @@ static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp,
1651 * packets */ 1651 * packets */
1652 newfrag = skb; 1652 newfrag = skb;
1653 1653
1654 /* if this new fragment is before the first one, then enqueue it now. */ 1654 /* if this new fragment is before the first one, then enqueue it now. */
1655 if ((frag = mp->frags) == NULL || MP_LT(newseq, MP_SEQ(frag))) { 1655 if ((frag = mp->frags) == NULL || MP_LT(newseq, MP_SEQ(frag))) {
1656 newfrag->next = frag; 1656 newfrag->next = frag;
1657 mp->frags = frag = newfrag; 1657 mp->frags = frag = newfrag;
1658 newfrag = NULL; 1658 newfrag = NULL;
1659 } 1659 }
1660 1660
1661 start = MP_FLAGS(frag) & MP_BEGIN_FRAG && 1661 start = MP_FLAGS(frag) & MP_BEGIN_FRAG &&
1662 MP_SEQ(frag) == mp->seq ? frag : NULL; 1662 MP_SEQ(frag) == mp->seq ? frag : NULL;
1663 1663
1664 /* 1664 /*
1665 * main fragment traversing loop 1665 * main fragment traversing loop
1666 * 1666 *
1667 * try to accomplish several tasks: 1667 * try to accomplish several tasks:
@@ -1675,71 +1675,71 @@ static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp,
1675 * come to complete such sequence and it should be discarded 1675 * come to complete such sequence and it should be discarded
1676 * 1676 *
1677 * loop completes when we accomplished the following tasks: 1677 * loop completes when we accomplished the following tasks:
1678 * - new fragment is inserted in the proper sequence ('newfrag' is 1678 * - new fragment is inserted in the proper sequence ('newfrag' is
1679 * set to NULL) 1679 * set to NULL)
1680 * - we hit a gap in the sequence, so no reassembly/processing is 1680 * - we hit a gap in the sequence, so no reassembly/processing is
1681 * possible ('start' would be set to NULL) 1681 * possible ('start' would be set to NULL)
1682 * 1682 *
1683 * algorithm for this code is derived from code in the book 1683 * algorithm for this code is derived from code in the book
1684 * 'PPP Design And Debugging' by James Carlson (Addison-Wesley) 1684 * 'PPP Design And Debugging' by James Carlson (Addison-Wesley)
1685 */ 1685 */
1686 while (start != NULL || newfrag != NULL) { 1686 while (start != NULL || newfrag != NULL) {
1687 1687
1688 thisseq = MP_SEQ(frag); 1688 thisseq = MP_SEQ(frag);
1689 nextf = frag->next; 1689 nextf = frag->next;
1690 1690
1691 /* drop any duplicate fragments */ 1691 /* drop any duplicate fragments */
1692 if (newfrag != NULL && thisseq == newseq) { 1692 if (newfrag != NULL && thisseq == newseq) {
1693 isdn_ppp_mp_free_skb(mp, newfrag); 1693 isdn_ppp_mp_free_skb(mp, newfrag);
1694 newfrag = NULL; 1694 newfrag = NULL;
1695 } 1695 }
1696 1696
1697 /* insert new fragment before next element if possible. */ 1697 /* insert new fragment before next element if possible. */
1698 if (newfrag != NULL && (nextf == NULL || 1698 if (newfrag != NULL && (nextf == NULL ||
1699 MP_LT(newseq, MP_SEQ(nextf)))) { 1699 MP_LT(newseq, MP_SEQ(nextf)))) {
1700 newfrag->next = nextf; 1700 newfrag->next = nextf;
1701 frag->next = nextf = newfrag; 1701 frag->next = nextf = newfrag;
1702 newfrag = NULL; 1702 newfrag = NULL;
1703 } 1703 }
1704 1704
1705 if (start != NULL) { 1705 if (start != NULL) {
1706 /* check for misplaced start */ 1706 /* check for misplaced start */
1707 if (start != frag && (MP_FLAGS(frag) & MP_BEGIN_FRAG)) { 1707 if (start != frag && (MP_FLAGS(frag) & MP_BEGIN_FRAG)) {
1708 printk(KERN_WARNING"isdn_mppp(seq %d): new " 1708 printk(KERN_WARNING"isdn_mppp(seq %d): new "
1709 "BEGIN flag with no prior END", thisseq); 1709 "BEGIN flag with no prior END", thisseq);
1710 stats->seqerrs++; 1710 stats->seqerrs++;
1711 stats->frame_drops++; 1711 stats->frame_drops++;
1712 start = isdn_ppp_mp_discard(mp, start, frag); 1712 start = isdn_ppp_mp_discard(mp, start,frag);
1713 nextf = frag->next; 1713 nextf = frag->next;
1714 } 1714 }
1715 } else if (MP_LE(thisseq, minseq)) { 1715 } else if (MP_LE(thisseq, minseq)) {
1716 if (MP_FLAGS(frag) & MP_BEGIN_FRAG) 1716 if (MP_FLAGS(frag) & MP_BEGIN_FRAG)
1717 start = frag; 1717 start = frag;
1718 else { 1718 else {
1719 if (MP_FLAGS(frag) & MP_END_FRAG) 1719 if (MP_FLAGS(frag) & MP_END_FRAG)
1720 stats->frame_drops++; 1720 stats->frame_drops++;
1721 if (mp->frags == frag) 1721 if( mp->frags == frag )
1722 mp->frags = nextf; 1722 mp->frags = nextf;
1723 isdn_ppp_mp_free_skb(mp, frag); 1723 isdn_ppp_mp_free_skb(mp, frag);
1724 frag = nextf; 1724 frag = nextf;
1725 continue; 1725 continue;
1726 } 1726 }
1727 } 1727 }
1728 1728
1729 /* if start is non-null and we have end fragment, then 1729 /* if start is non-null and we have end fragment, then
1730 * we have full reassembly sequence -- reassemble 1730 * we have full reassembly sequence -- reassemble
1731 * and process packet now 1731 * and process packet now
1732 */ 1732 */
1733 if (start != NULL && (MP_FLAGS(frag) & MP_END_FRAG)) { 1733 if (start != NULL && (MP_FLAGS(frag) & MP_END_FRAG)) {
1734 minseq = mp->seq = (thisseq + 1) & MP_LONGSEQ_MASK; 1734 minseq = mp->seq = (thisseq+1) & MP_LONGSEQ_MASK;
1735 /* Reassemble the packet then dispatch it */ 1735 /* Reassemble the packet then dispatch it */
1736 isdn_ppp_mp_reassembly(net_dev, lp, start, nextf); 1736 isdn_ppp_mp_reassembly(net_dev, lp, start, nextf);
1737
1738 start = NULL;
1739 frag = NULL;
1737 1740
1738 start = NULL; 1741 mp->frags = nextf;
1739 frag = NULL; 1742 }
1740
1741 mp->frags = nextf;
1742 }
1743 1743
1744 /* check if need to update start pointer: if we just 1744 /* check if need to update start pointer: if we just
1745 * reassembled the packet and sequence is contiguous 1745 * reassembled the packet and sequence is contiguous
@@ -1749,48 +1749,48 @@ static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp,
1749 * if sequence is not contiguous, either clear everything 1749 * if sequence is not contiguous, either clear everything
1750 * below low watermark and set start to the next frag or 1750 * below low watermark and set start to the next frag or
1751 * clear start ptr. 1751 * clear start ptr.
1752 */ 1752 */
1753 if (nextf != NULL && 1753 if (nextf != NULL &&
1754 ((thisseq + 1) & MP_LONGSEQ_MASK) == MP_SEQ(nextf)) { 1754 ((thisseq+1) & MP_LONGSEQ_MASK) == MP_SEQ(nextf)) {
1755 /* if we just reassembled and the next one is here, 1755 /* if we just reassembled and the next one is here,
1756 * then start another reassembly. */ 1756 * then start another reassembly. */
1757 1757
1758 if (frag == NULL) { 1758 if (frag == NULL) {
1759 if (MP_FLAGS(nextf) & MP_BEGIN_FRAG) 1759 if (MP_FLAGS(nextf) & MP_BEGIN_FRAG)
1760 start = nextf; 1760 start = nextf;
1761 else 1761 else
1762 { 1762 {
1763 printk(KERN_WARNING"isdn_mppp(seq %d):" 1763 printk(KERN_WARNING"isdn_mppp(seq %d):"
1764 " END flag with no following " 1764 " END flag with no following "
1765 "BEGIN", thisseq); 1765 "BEGIN", thisseq);
1766 stats->seqerrs++; 1766 stats->seqerrs++;
1767 } 1767 }
1768 } 1768 }
1769 1769
1770 } else { 1770 } else {
1771 if (nextf != NULL && frag != NULL && 1771 if ( nextf != NULL && frag != NULL &&
1772 MP_LT(thisseq, minseq)) { 1772 MP_LT(thisseq, minseq)) {
1773 /* we've got a break in the sequence 1773 /* we've got a break in the sequence
1774 * and we not at the end yet 1774 * and we not at the end yet
1775 * and we did not just reassembled 1775 * and we did not just reassembled
1776 *(if we did, there wouldn't be anything before) 1776 *(if we did, there wouldn't be anything before)
1777 * and we below the low watermark 1777 * and we below the low watermark
1778 * discard all the frames below low watermark 1778 * discard all the frames below low watermark
1779 * and start over */ 1779 * and start over */
1780 stats->frame_drops++; 1780 stats->frame_drops++;
1781 mp->frags = isdn_ppp_mp_discard(mp, start, nextf); 1781 mp->frags = isdn_ppp_mp_discard(mp,start,nextf);
1782 } 1782 }
1783 /* break in the sequence, no reassembly */ 1783 /* break in the sequence, no reassembly */
1784 start = NULL; 1784 start = NULL;
1785 } 1785 }
1786 1786
1787 frag = nextf; 1787 frag = nextf;
1788 } /* while -- main loop */ 1788 } /* while -- main loop */
1789 1789
1790 if (mp->frags == NULL) 1790 if (mp->frags == NULL)
1791 mp->frags = frag; 1791 mp->frags = frag;
1792 1792
1793 /* rather straighforward way to deal with (not very) possible 1793 /* rather straighforward way to deal with (not very) possible
1794 * queue overflow */ 1794 * queue overflow */
1795 if (mp->frames > MP_MAX_QUEUE_LEN) { 1795 if (mp->frames > MP_MAX_QUEUE_LEN) {
1796 stats->overflows++; 1796 stats->overflows++;
@@ -1803,11 +1803,11 @@ static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp,
1803 spin_unlock_irqrestore(&mp->lock, flags); 1803 spin_unlock_irqrestore(&mp->lock, flags);
1804} 1804}
1805 1805
1806static void isdn_ppp_mp_cleanup(isdn_net_local *lp) 1806static void isdn_ppp_mp_cleanup( isdn_net_local * lp )
1807{ 1807{
1808 struct sk_buff *frag = lp->netdev->pb->frags; 1808 struct sk_buff * frag = lp->netdev->pb->frags;
1809 struct sk_buff *nextfrag; 1809 struct sk_buff * nextfrag;
1810 while (frag) { 1810 while( frag ) {
1811 nextfrag = frag->next; 1811 nextfrag = frag->next;
1812 isdn_ppp_mp_free_skb(lp->netdev->pb, frag); 1812 isdn_ppp_mp_free_skb(lp->netdev->pb, frag);
1813 frag = nextfrag; 1813 frag = nextfrag;
@@ -1815,117 +1815,117 @@ static void isdn_ppp_mp_cleanup(isdn_net_local *lp)
1815 lp->netdev->pb->frags = NULL; 1815 lp->netdev->pb->frags = NULL;
1816} 1816}
1817 1817
1818static u32 isdn_ppp_mp_get_seq(int short_seq, 1818static u32 isdn_ppp_mp_get_seq( int short_seq,
1819 struct sk_buff *skb, u32 last_seq) 1819 struct sk_buff * skb, u32 last_seq )
1820{ 1820{
1821 u32 seq; 1821 u32 seq;
1822 int flags = skb->data[0] & (MP_BEGIN_FRAG | MP_END_FRAG); 1822 int flags = skb->data[0] & (MP_BEGIN_FRAG | MP_END_FRAG);
1823 1823
1824 if (!short_seq) 1824 if( !short_seq )
1825 { 1825 {
1826 seq = ntohl(*(__be32 *)skb->data) & MP_LONGSEQ_MASK; 1826 seq = ntohl(*(__be32 *)skb->data) & MP_LONGSEQ_MASK;
1827 skb_push(skb, 1); 1827 skb_push(skb,1);
1828 } 1828 }
1829 else 1829 else
1830 { 1830 {
1831 /* convert 12-bit short seq number to 24-bit long one 1831 /* convert 12-bit short seq number to 24-bit long one
1832 */ 1832 */
1833 seq = ntohs(*(__be16 *)skb->data) & MP_SHORTSEQ_MASK; 1833 seq = ntohs(*(__be16 *)skb->data) & MP_SHORTSEQ_MASK;
1834 1834
1835 /* check for seqence wrap */ 1835 /* check for seqence wrap */
1836 if (!(seq & MP_SHORTSEQ_MAXBIT) && 1836 if( !(seq & MP_SHORTSEQ_MAXBIT) &&
1837 (last_seq & MP_SHORTSEQ_MAXBIT) && 1837 (last_seq & MP_SHORTSEQ_MAXBIT) &&
1838 (unsigned long)last_seq <= MP_LONGSEQ_MAX) 1838 (unsigned long)last_seq <= MP_LONGSEQ_MAX )
1839 seq |= (last_seq + MP_SHORTSEQ_MAX + 1) & 1839 seq |= (last_seq + MP_SHORTSEQ_MAX+1) &
1840 (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK); 1840 (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK);
1841 else 1841 else
1842 seq |= last_seq & (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK); 1842 seq |= last_seq & (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK);
1843 1843
1844 skb_push(skb, 3); /* put converted seqence back in skb */ 1844 skb_push(skb, 3); /* put converted seqence back in skb */
1845 } 1845 }
1846 *(u32 *)(skb->data + 1) = seq; /* put seqence back in _host_ byte 1846 *(u32*)(skb->data+1) = seq; /* put seqence back in _host_ byte
1847 * order */ 1847 * order */
1848 skb->data[0] = flags; /* restore flags */ 1848 skb->data[0] = flags; /* restore flags */
1849 return seq; 1849 return seq;
1850} 1850}
1851 1851
1852struct sk_buff *isdn_ppp_mp_discard(ippp_bundle *mp, 1852struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp,
1853 struct sk_buff *from, struct sk_buff *to) 1853 struct sk_buff * from, struct sk_buff * to )
1854{ 1854{
1855 if (from) 1855 if( from )
1856 while (from != to) { 1856 while (from != to) {
1857 struct sk_buff *next = from->next; 1857 struct sk_buff * next = from->next;
1858 isdn_ppp_mp_free_skb(mp, from); 1858 isdn_ppp_mp_free_skb(mp, from);
1859 from = next; 1859 from = next;
1860 } 1860 }
1861 return from; 1861 return from;
1862} 1862}
1863 1863
1864void isdn_ppp_mp_reassembly(isdn_net_dev *net_dev, isdn_net_local *lp, 1864void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp,
1865 struct sk_buff *from, struct sk_buff *to) 1865 struct sk_buff * from, struct sk_buff * to )
1866{ 1866{
1867 ippp_bundle *mp = net_dev->pb; 1867 ippp_bundle * mp = net_dev->pb;
1868 int proto; 1868 int proto;
1869 struct sk_buff *skb; 1869 struct sk_buff * skb;
1870 unsigned int tot_len; 1870 unsigned int tot_len;
1871 1871
1872 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 1872 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
1873 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", 1873 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n",
1874 __func__, lp->ppp_slot); 1874 __func__, lp->ppp_slot);
1875 return; 1875 return;
1876 } 1876 }
1877 if (MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG)) { 1877 if( MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG) ) {
1878 if (ippp_table[lp->ppp_slot]->debug & 0x40) 1878 if( ippp_table[lp->ppp_slot]->debug & 0x40 )
1879 printk(KERN_DEBUG "isdn_mppp: reassembly: frame %d, " 1879 printk(KERN_DEBUG "isdn_mppp: reassembly: frame %d, "
1880 "len %d\n", MP_SEQ(from), from->len); 1880 "len %d\n", MP_SEQ(from), from->len );
1881 skb = from; 1881 skb = from;
1882 skb_pull(skb, MP_HEADER_LEN); 1882 skb_pull(skb, MP_HEADER_LEN);
1883 mp->frames--; 1883 mp->frames--;
1884 } else { 1884 } else {
1885 struct sk_buff *frag; 1885 struct sk_buff * frag;
1886 int n; 1886 int n;
1887 1887
1888 for (tot_len = n = 0, frag = from; frag != to; frag = frag->next, n++) 1888 for(tot_len=n=0, frag=from; frag != to; frag=frag->next, n++)
1889 tot_len += frag->len - MP_HEADER_LEN; 1889 tot_len += frag->len - MP_HEADER_LEN;
1890 1890
1891 if (ippp_table[lp->ppp_slot]->debug & 0x40) 1891 if( ippp_table[lp->ppp_slot]->debug & 0x40 )
1892 printk(KERN_DEBUG"isdn_mppp: reassembling frames %d " 1892 printk(KERN_DEBUG"isdn_mppp: reassembling frames %d "
1893 "to %d, len %d\n", MP_SEQ(from), 1893 "to %d, len %d\n", MP_SEQ(from),
1894 (MP_SEQ(from) + n - 1) & MP_LONGSEQ_MASK, tot_len); 1894 (MP_SEQ(from)+n-1) & MP_LONGSEQ_MASK, tot_len );
1895 if ((skb = dev_alloc_skb(tot_len)) == NULL) { 1895 if( (skb = dev_alloc_skb(tot_len)) == NULL ) {
1896 printk(KERN_ERR "isdn_mppp: cannot allocate sk buff " 1896 printk(KERN_ERR "isdn_mppp: cannot allocate sk buff "
1897 "of size %d\n", tot_len); 1897 "of size %d\n", tot_len);
1898 isdn_ppp_mp_discard(mp, from, to); 1898 isdn_ppp_mp_discard(mp, from, to);
1899 return; 1899 return;
1900 } 1900 }
1901 1901
1902 while (from != to) { 1902 while( from != to ) {
1903 unsigned int len = from->len - MP_HEADER_LEN; 1903 unsigned int len = from->len - MP_HEADER_LEN;
1904 1904
1905 skb_copy_from_linear_data_offset(from, MP_HEADER_LEN, 1905 skb_copy_from_linear_data_offset(from, MP_HEADER_LEN,
1906 skb_put(skb, len), 1906 skb_put(skb,len),
1907 len); 1907 len);
1908 frag = from->next; 1908 frag = from->next;
1909 isdn_ppp_mp_free_skb(mp, from); 1909 isdn_ppp_mp_free_skb(mp, from);
1910 from = frag; 1910 from = frag;
1911 } 1911 }
1912 } 1912 }
1913 proto = isdn_ppp_strip_proto(skb); 1913 proto = isdn_ppp_strip_proto(skb);
1914 isdn_ppp_push_higher(net_dev, lp, skb, proto); 1914 isdn_ppp_push_higher(net_dev, lp, skb, proto);
1915} 1915}
1916 1916
1917static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb) 1917static void isdn_ppp_mp_free_skb(ippp_bundle * mp, struct sk_buff * skb)
1918{ 1918{
1919 dev_kfree_skb(skb); 1919 dev_kfree_skb(skb);
1920 mp->frames--; 1920 mp->frames--;
1921} 1921}
1922 1922
1923static void isdn_ppp_mp_print_recv_pkt(int slot, struct sk_buff *skb) 1923static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb )
1924{ 1924{
1925 printk(KERN_DEBUG "mp_recv: %d/%d -> %02x %02x %02x %02x %02x %02x\n", 1925 printk(KERN_DEBUG "mp_recv: %d/%d -> %02x %02x %02x %02x %02x %02x\n",
1926 slot, (int) skb->len, 1926 slot, (int) skb->len,
1927 (int) skb->data[0], (int) skb->data[1], (int) skb->data[2], 1927 (int) skb->data[0], (int) skb->data[1], (int) skb->data[2],
1928 (int) skb->data[3], (int) skb->data[4], (int) skb->data[5]); 1928 (int) skb->data[3], (int) skb->data[4], (int) skb->data[5]);
1929} 1929}
1930 1930
1931static int 1931static int
@@ -1944,18 +1944,18 @@ isdn_ppp_bundle(struct ippp_struct *is, int unit)
1944 return -EINVAL; 1944 return -EINVAL;
1945 } 1945 }
1946 1946
1947 spin_lock_irqsave(&p->pb->lock, flags); 1947 spin_lock_irqsave(&p->pb->lock, flags);
1948 1948
1949 nlp = is->lp; 1949 nlp = is->lp;
1950 lp = p->queue; 1950 lp = p->queue;
1951 if (nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS || 1951 if( nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS ||
1952 lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 1952 lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS ) {
1953 printk(KERN_ERR "ippp_bundle: binding to invalid slot %d\n", 1953 printk(KERN_ERR "ippp_bundle: binding to invalid slot %d\n",
1954 nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS ? 1954 nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS ?
1955 nlp->ppp_slot : lp->ppp_slot); 1955 nlp->ppp_slot : lp->ppp_slot );
1956 rc = -EINVAL; 1956 rc = -EINVAL;
1957 goto out; 1957 goto out;
1958 } 1958 }
1959 1959
1960 isdn_net_add_to_bundle(p, nlp); 1960 isdn_net_add_to_bundle(p, nlp);
1961 1961
@@ -1971,9 +1971,9 @@ out:
1971 spin_unlock_irqrestore(&p->pb->lock, flags); 1971 spin_unlock_irqrestore(&p->pb->lock, flags);
1972 return rc; 1972 return rc;
1973} 1973}
1974 1974
1975#endif /* CONFIG_ISDN_MPP */ 1975#endif /* CONFIG_ISDN_MPP */
1976 1976
1977/* 1977/*
1978 * network device ioctl handlers 1978 * network device ioctl handlers
1979 */ 1979 */
@@ -2020,7 +2020,7 @@ isdn_ppp_dev_ioctl_stats(int slot, struct ifreq *ifr, struct net_device *dev)
2020int 2020int
2021isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2021isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2022{ 2022{
2023 int error = 0; 2023 int error=0;
2024 int len; 2024 int len;
2025 isdn_net_local *lp = netdev_priv(dev); 2025 isdn_net_local *lp = netdev_priv(dev);
2026 2026
@@ -2030,18 +2030,18 @@ isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2030 2030
2031 switch (cmd) { 2031 switch (cmd) {
2032#define PPP_VERSION "2.3.7" 2032#define PPP_VERSION "2.3.7"
2033 case SIOCGPPPVER: 2033 case SIOCGPPPVER:
2034 len = strlen(PPP_VERSION) + 1; 2034 len = strlen(PPP_VERSION) + 1;
2035 if (copy_to_user(ifr->ifr_data, PPP_VERSION, len)) 2035 if (copy_to_user(ifr->ifr_data, PPP_VERSION, len))
2036 error = -EFAULT; 2036 error = -EFAULT;
2037 break; 2037 break;
2038 2038
2039 case SIOCGPPPSTATS: 2039 case SIOCGPPPSTATS:
2040 error = isdn_ppp_dev_ioctl_stats(lp->ppp_slot, ifr, dev); 2040 error = isdn_ppp_dev_ioctl_stats(lp->ppp_slot, ifr, dev);
2041 break; 2041 break;
2042 default: 2042 default:
2043 error = -EINVAL; 2043 error = -EINVAL;
2044 break; 2044 break;
2045 } 2045 }
2046 return error; 2046 return error;
2047} 2047}
@@ -2050,9 +2050,9 @@ static int
2050isdn_ppp_if_get_unit(char *name) 2050isdn_ppp_if_get_unit(char *name)
2051{ 2051{
2052 int len, 2052 int len,
2053 i, 2053 i,
2054 unit = 0, 2054 unit = 0,
2055 deci; 2055 deci;
2056 2056
2057 len = strlen(name); 2057 len = strlen(name);
2058 2058
@@ -2129,7 +2129,7 @@ isdn_ppp_hangup_slave(char *name)
2129 break; 2129 break;
2130 } else if (mlp->flags & ISDN_NET_CONNECTED) 2130 } else if (mlp->flags & ISDN_NET_CONNECTED)
2131 break; 2131 break;
2132 2132
2133 sdev = mlp->slave; 2133 sdev = mlp->slave;
2134 } 2134 }
2135 if (!sdev) 2135 if (!sdev)
@@ -2202,8 +2202,8 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto,
2202 2202
2203 /* Alloc large enough skb */ 2203 /* Alloc large enough skb */
2204 hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen; 2204 hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen;
2205 skb = alloc_skb(len + hl + 16, GFP_ATOMIC); 2205 skb = alloc_skb(len + hl + 16,GFP_ATOMIC);
2206 if (!skb) { 2206 if(!skb) {
2207 printk(KERN_WARNING 2207 printk(KERN_WARNING
2208 "ippp: CCP cannot send reset - out of memory\n"); 2208 "ippp: CCP cannot send reset - out of memory\n");
2209 return; 2209 return;
@@ -2211,7 +2211,7 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto,
2211 skb_reserve(skb, hl); 2211 skb_reserve(skb, hl);
2212 2212
2213 /* We may need to stuff an address and control field first */ 2213 /* We may need to stuff an address and control field first */
2214 if (!(is->pppcfg & SC_COMP_AC)) { 2214 if(!(is->pppcfg & SC_COMP_AC)) {
2215 p = skb_put(skb, 2); 2215 p = skb_put(skb, 2);
2216 *p++ = 0xff; 2216 *p++ = 0xff;
2217 *p++ = 0x03; 2217 *p++ = 0x03;
@@ -2228,14 +2228,14 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto,
2228 *p++ = (cnt & 0xff); 2228 *p++ = (cnt & 0xff);
2229 2229
2230 /* Now stuff remaining bytes */ 2230 /* Now stuff remaining bytes */
2231 if (len) { 2231 if(len) {
2232 p = skb_put(skb, len); 2232 p = skb_put(skb, len);
2233 memcpy(p, data, len); 2233 memcpy(p, data, len);
2234 } 2234 }
2235 2235
2236 /* skb is now ready for xmit */ 2236 /* skb is now ready for xmit */
2237 printk(KERN_DEBUG "Sending CCP Frame:\n"); 2237 printk(KERN_DEBUG "Sending CCP Frame:\n");
2238 isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 2238 isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit,lp->ppp_slot);
2239 2239
2240 isdn_net_write_super(lp, skb); 2240 isdn_net_write_super(lp, skb);
2241} 2241}
@@ -2245,7 +2245,7 @@ static struct ippp_ccp_reset *isdn_ppp_ccp_reset_alloc(struct ippp_struct *is)
2245{ 2245{
2246 struct ippp_ccp_reset *r; 2246 struct ippp_ccp_reset *r;
2247 r = kzalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL); 2247 r = kzalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL);
2248 if (!r) { 2248 if(!r) {
2249 printk(KERN_ERR "ippp_ccp: failed to allocate reset data" 2249 printk(KERN_ERR "ippp_ccp: failed to allocate reset data"
2250 " structure - no mem\n"); 2250 " structure - no mem\n");
2251 return NULL; 2251 return NULL;
@@ -2262,8 +2262,8 @@ static void isdn_ppp_ccp_reset_free(struct ippp_struct *is)
2262 2262
2263 printk(KERN_DEBUG "ippp_ccp: freeing reset data structure %p\n", 2263 printk(KERN_DEBUG "ippp_ccp: freeing reset data structure %p\n",
2264 is->reset); 2264 is->reset);
2265 for (id = 0; id < 256; id++) { 2265 for(id = 0; id < 256; id++) {
2266 if (is->reset->rs[id]) { 2266 if(is->reset->rs[id]) {
2267 isdn_ppp_ccp_reset_free_state(is, (unsigned char)id); 2267 isdn_ppp_ccp_reset_free_state(is, (unsigned char)id);
2268 } 2268 }
2269 } 2269 }
@@ -2277,11 +2277,11 @@ static void isdn_ppp_ccp_reset_free_state(struct ippp_struct *is,
2277{ 2277{
2278 struct ippp_ccp_reset_state *rs; 2278 struct ippp_ccp_reset_state *rs;
2279 2279
2280 if (is->reset->rs[id]) { 2280 if(is->reset->rs[id]) {
2281 printk(KERN_DEBUG "ippp_ccp: freeing state for id %d\n", id); 2281 printk(KERN_DEBUG "ippp_ccp: freeing state for id %d\n", id);
2282 rs = is->reset->rs[id]; 2282 rs = is->reset->rs[id];
2283 /* Make sure the kernel will not call back later */ 2283 /* Make sure the kernel will not call back later */
2284 if (rs->ta) 2284 if(rs->ta)
2285 del_timer(&rs->timer); 2285 del_timer(&rs->timer);
2286 is->reset->rs[id] = NULL; 2286 is->reset->rs[id] = NULL;
2287 kfree(rs); 2287 kfree(rs);
@@ -2297,13 +2297,13 @@ static void isdn_ppp_ccp_timer_callback(unsigned long closure)
2297 struct ippp_ccp_reset_state *rs = 2297 struct ippp_ccp_reset_state *rs =
2298 (struct ippp_ccp_reset_state *)closure; 2298 (struct ippp_ccp_reset_state *)closure;
2299 2299
2300 if (!rs) { 2300 if(!rs) {
2301 printk(KERN_ERR "ippp_ccp: timer cb with zero closure.\n"); 2301 printk(KERN_ERR "ippp_ccp: timer cb with zero closure.\n");
2302 return; 2302 return;
2303 } 2303 }
2304 if (rs->ta && rs->state == CCPResetSentReq) { 2304 if(rs->ta && rs->state == CCPResetSentReq) {
2305 /* We are correct here */ 2305 /* We are correct here */
2306 if (!rs->expra) { 2306 if(!rs->expra) {
2307 /* Hmm, there is no Ack really expected. We can clean 2307 /* Hmm, there is no Ack really expected. We can clean
2308 up the state now, it will be reallocated if the 2308 up the state now, it will be reallocated if the
2309 decompressor insists on another reset */ 2309 decompressor insists on another reset */
@@ -2317,7 +2317,7 @@ static void isdn_ppp_ccp_timer_callback(unsigned long closure)
2317 isdn_ppp_ccp_xmit_reset(rs->is, PPP_CCP, CCP_RESETREQ, rs->id, 2317 isdn_ppp_ccp_xmit_reset(rs->is, PPP_CCP, CCP_RESETREQ, rs->id,
2318 rs->data, rs->dlen); 2318 rs->data, rs->dlen);
2319 /* Restart timer */ 2319 /* Restart timer */
2320 rs->timer.expires = jiffies + HZ * 5; 2320 rs->timer.expires = jiffies + HZ*5;
2321 add_timer(&rs->timer); 2321 add_timer(&rs->timer);
2322 } else { 2322 } else {
2323 printk(KERN_WARNING "ippp_ccp: timer cb in wrong state %d\n", 2323 printk(KERN_WARNING "ippp_ccp: timer cb in wrong state %d\n",
@@ -2327,16 +2327,16 @@ static void isdn_ppp_ccp_timer_callback(unsigned long closure)
2327 2327
2328/* Allocate a new reset transaction state */ 2328/* Allocate a new reset transaction state */
2329static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, 2329static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is,
2330 unsigned char id) 2330 unsigned char id)
2331{ 2331{
2332 struct ippp_ccp_reset_state *rs; 2332 struct ippp_ccp_reset_state *rs;
2333 if (is->reset->rs[id]) { 2333 if(is->reset->rs[id]) {
2334 printk(KERN_WARNING "ippp_ccp: old state exists for id %d\n", 2334 printk(KERN_WARNING "ippp_ccp: old state exists for id %d\n",
2335 id); 2335 id);
2336 return NULL; 2336 return NULL;
2337 } else { 2337 } else {
2338 rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL); 2338 rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL);
2339 if (!rs) 2339 if(!rs)
2340 return NULL; 2340 return NULL;
2341 rs->state = CCPResetIdle; 2341 rs->state = CCPResetIdle;
2342 rs->is = is; 2342 rs->is = is;
@@ -2357,21 +2357,21 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
2357{ 2357{
2358 struct ippp_ccp_reset_state *rs; 2358 struct ippp_ccp_reset_state *rs;
2359 2359
2360 if (rp->valid) { 2360 if(rp->valid) {
2361 /* The decompressor defines parameters by itself */ 2361 /* The decompressor defines parameters by itself */
2362 if (rp->rsend) { 2362 if(rp->rsend) {
2363 /* And he wants us to send a request */ 2363 /* And he wants us to send a request */
2364 if (!(rp->idval)) { 2364 if(!(rp->idval)) {
2365 printk(KERN_ERR "ippp_ccp: decompressor must" 2365 printk(KERN_ERR "ippp_ccp: decompressor must"
2366 " specify reset id\n"); 2366 " specify reset id\n");
2367 return; 2367 return;
2368 } 2368 }
2369 if (is->reset->rs[rp->id]) { 2369 if(is->reset->rs[rp->id]) {
2370 /* There is already a transaction in existence 2370 /* There is already a transaction in existence
2371 for this id. May be still waiting for a 2371 for this id. May be still waiting for a
2372 Ack or may be wrong. */ 2372 Ack or may be wrong. */
2373 rs = is->reset->rs[rp->id]; 2373 rs = is->reset->rs[rp->id];
2374 if (rs->state == CCPResetSentReq && rs->ta) { 2374 if(rs->state == CCPResetSentReq && rs->ta) {
2375 printk(KERN_DEBUG "ippp_ccp: reset" 2375 printk(KERN_DEBUG "ippp_ccp: reset"
2376 " trans still in progress" 2376 " trans still in progress"
2377 " for id %d\n", rp->id); 2377 " for id %d\n", rp->id);
@@ -2385,14 +2385,14 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
2385 printk(KERN_DEBUG "ippp_ccp: new trans for id" 2385 printk(KERN_DEBUG "ippp_ccp: new trans for id"
2386 " %d to be started\n", rp->id); 2386 " %d to be started\n", rp->id);
2387 rs = isdn_ppp_ccp_reset_alloc_state(is, rp->id); 2387 rs = isdn_ppp_ccp_reset_alloc_state(is, rp->id);
2388 if (!rs) { 2388 if(!rs) {
2389 printk(KERN_ERR "ippp_ccp: out of mem" 2389 printk(KERN_ERR "ippp_ccp: out of mem"
2390 " allocing ccp trans\n"); 2390 " allocing ccp trans\n");
2391 return; 2391 return;
2392 } 2392 }
2393 rs->state = CCPResetSentReq; 2393 rs->state = CCPResetSentReq;
2394 rs->expra = rp->expra; 2394 rs->expra = rp->expra;
2395 if (rp->dtval) { 2395 if(rp->dtval) {
2396 rs->dlen = rp->dlen; 2396 rs->dlen = rp->dlen;
2397 memcpy(rs->data, rp->data, rp->dlen); 2397 memcpy(rs->data, rp->data, rp->dlen);
2398 } 2398 }
@@ -2401,7 +2401,7 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
2401 CCP_RESETREQ, rs->id, 2401 CCP_RESETREQ, rs->id,
2402 rs->data, rs->dlen); 2402 rs->data, rs->dlen);
2403 /* Start the timer */ 2403 /* Start the timer */
2404 rs->timer.expires = jiffies + 5 * HZ; 2404 rs->timer.expires = jiffies + 5*HZ;
2405 add_timer(&rs->timer); 2405 add_timer(&rs->timer);
2406 rs->ta = 1; 2406 rs->ta = 1;
2407 } 2407 }
@@ -2413,12 +2413,12 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
2413 care about them, so we just send the minimal requests 2413 care about them, so we just send the minimal requests
2414 and increase ids only when an Ack is received for a 2414 and increase ids only when an Ack is received for a
2415 given id */ 2415 given id */
2416 if (is->reset->rs[is->reset->lastid]) { 2416 if(is->reset->rs[is->reset->lastid]) {
2417 /* There is already a transaction in existence 2417 /* There is already a transaction in existence
2418 for this id. May be still waiting for a 2418 for this id. May be still waiting for a
2419 Ack or may be wrong. */ 2419 Ack or may be wrong. */
2420 rs = is->reset->rs[is->reset->lastid]; 2420 rs = is->reset->rs[is->reset->lastid];
2421 if (rs->state == CCPResetSentReq && rs->ta) { 2421 if(rs->state == CCPResetSentReq && rs->ta) {
2422 printk(KERN_DEBUG "ippp_ccp: reset" 2422 printk(KERN_DEBUG "ippp_ccp: reset"
2423 " trans still in progress" 2423 " trans still in progress"
2424 " for id %d\n", rp->id); 2424 " for id %d\n", rp->id);
@@ -2432,7 +2432,7 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
2432 " %d to be started\n", is->reset->lastid); 2432 " %d to be started\n", is->reset->lastid);
2433 rs = isdn_ppp_ccp_reset_alloc_state(is, 2433 rs = isdn_ppp_ccp_reset_alloc_state(is,
2434 is->reset->lastid); 2434 is->reset->lastid);
2435 if (!rs) { 2435 if(!rs) {
2436 printk(KERN_ERR "ippp_ccp: out of mem" 2436 printk(KERN_ERR "ippp_ccp: out of mem"
2437 " allocing ccp trans\n"); 2437 " allocing ccp trans\n");
2438 return; 2438 return;
@@ -2446,7 +2446,7 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is,
2446 isdn_ppp_ccp_xmit_reset(is, PPP_CCP, CCP_RESETREQ, 2446 isdn_ppp_ccp_xmit_reset(is, PPP_CCP, CCP_RESETREQ,
2447 rs->id, NULL, 0); 2447 rs->id, NULL, 0);
2448 /* Start the timer */ 2448 /* Start the timer */
2449 rs->timer.expires = jiffies + 5 * HZ; 2449 rs->timer.expires = jiffies + 5*HZ;
2450 add_timer(&rs->timer); 2450 add_timer(&rs->timer);
2451 rs->ta = 1; 2451 rs->ta = 1;
2452 } 2452 }
@@ -2460,17 +2460,17 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is,
2460{ 2460{
2461 struct ippp_ccp_reset_state *rs = is->reset->rs[id]; 2461 struct ippp_ccp_reset_state *rs = is->reset->rs[id];
2462 2462
2463 if (rs) { 2463 if(rs) {
2464 if (rs->ta && rs->state == CCPResetSentReq) { 2464 if(rs->ta && rs->state == CCPResetSentReq) {
2465 /* Great, we are correct */ 2465 /* Great, we are correct */
2466 if (!rs->expra) 2466 if(!rs->expra)
2467 printk(KERN_DEBUG "ippp_ccp: ResetAck received" 2467 printk(KERN_DEBUG "ippp_ccp: ResetAck received"
2468 " for id %d but not expected\n", id); 2468 " for id %d but not expected\n", id);
2469 } else { 2469 } else {
2470 printk(KERN_INFO "ippp_ccp: ResetAck received out of" 2470 printk(KERN_INFO "ippp_ccp: ResetAck received out of"
2471 "sync for id %d\n", id); 2471 "sync for id %d\n", id);
2472 } 2472 }
2473 if (rs->ta) { 2473 if(rs->ta) {
2474 rs->ta = 0; 2474 rs->ta = 0;
2475 del_timer(&rs->timer); 2475 del_timer(&rs->timer);
2476 } 2476 }
@@ -2483,7 +2483,7 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is,
2483 is->reset->lastid++; 2483 is->reset->lastid++;
2484} 2484}
2485 2485
2486/* 2486/*
2487 * decompress packet 2487 * decompress packet
2488 * 2488 *
2489 * if master = 0, we're trying to uncompress an per-link compressed packet, 2489 * if master = 0, we're trying to uncompress an per-link compressed packet,
@@ -2495,8 +2495,8 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is,
2495 * NULL if decompression error 2495 * NULL if decompression error
2496 */ 2496 */
2497 2497
2498static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb, struct ippp_struct *is, struct ippp_struct *master, 2498static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struct *is,struct ippp_struct *master,
2499 int *proto) 2499 int *proto)
2500{ 2500{
2501 void *stat = NULL; 2501 void *stat = NULL;
2502 struct isdn_ppp_compressor *ipc = NULL; 2502 struct isdn_ppp_compressor *ipc = NULL;
@@ -2506,8 +2506,8 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb, struct ippp_stru
2506 struct isdn_ppp_resetparams rsparm; 2506 struct isdn_ppp_resetparams rsparm;
2507 unsigned char rsdata[IPPP_RESET_MAXDATABYTES]; 2507 unsigned char rsdata[IPPP_RESET_MAXDATABYTES];
2508 2508
2509 if (!master) { 2509 if(!master) {
2510 // per-link decompression 2510 // per-link decompression
2511 stat = is->link_decomp_stat; 2511 stat = is->link_decomp_stat;
2512 ipc = is->link_decompressor; 2512 ipc = is->link_decompressor;
2513 ri = is; 2513 ri = is;
@@ -2524,28 +2524,28 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb, struct ippp_stru
2524 } 2524 }
2525 BUG_ON(!stat); // if we have a compressor, stat has been set as well 2525 BUG_ON(!stat); // if we have a compressor, stat has been set as well
2526 2526
2527 if ((master && *proto == PPP_COMP) || (!master && *proto == PPP_COMPFRAG)) { 2527 if((master && *proto == PPP_COMP) || (!master && *proto == PPP_COMPFRAG) ) {
2528 // compressed packets are compressed by their protocol type 2528 // compressed packets are compressed by their protocol type
2529 2529
2530 // Set up reset params for the decompressor 2530 // Set up reset params for the decompressor
2531 memset(&rsparm, 0, sizeof(rsparm)); 2531 memset(&rsparm, 0, sizeof(rsparm));
2532 rsparm.data = rsdata; 2532 rsparm.data = rsdata;
2533 rsparm.maxdlen = IPPP_RESET_MAXDATABYTES; 2533 rsparm.maxdlen = IPPP_RESET_MAXDATABYTES;
2534 2534
2535 skb_out = dev_alloc_skb(is->mru + PPP_HDRLEN); 2535 skb_out = dev_alloc_skb(is->mru + PPP_HDRLEN);
2536 if (!skb_out) { 2536 if (!skb_out) {
2537 kfree_skb(skb); 2537 kfree_skb(skb);
2538 printk(KERN_ERR "ippp: decomp memory allocation failure\n"); 2538 printk(KERN_ERR "ippp: decomp memory allocation failure\n");
2539 return NULL; 2539 return NULL;
2540 } 2540 }
2541 len = ipc->decompress(stat, skb, skb_out, &rsparm); 2541 len = ipc->decompress(stat, skb, skb_out, &rsparm);
2542 kfree_skb(skb); 2542 kfree_skb(skb);
2543 if (len <= 0) { 2543 if (len <= 0) {
2544 switch (len) { 2544 switch(len) {
2545 case DECOMP_ERROR: 2545 case DECOMP_ERROR:
2546 printk(KERN_INFO "ippp: decomp wants reset %s params\n", 2546 printk(KERN_INFO "ippp: decomp wants reset %s params\n",
2547 rsparm.valid ? "with" : "without"); 2547 rsparm.valid ? "with" : "without");
2548 2548
2549 isdn_ppp_ccp_reset_trans(ri, &rsparm); 2549 isdn_ppp_ccp_reset_trans(ri, &rsparm);
2550 break; 2550 break;
2551 case DECOMP_FATALERROR: 2551 case DECOMP_FATALERROR:
@@ -2563,7 +2563,7 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb, struct ippp_stru
2563 return NULL; 2563 return NULL;
2564 } 2564 }
2565 return skb_out; 2565 return skb_out;
2566 } else { 2566 } else {
2567 // uncompressed packets are fed through the decompressor to 2567 // uncompressed packets are fed through the decompressor to
2568 // update the decompressor state 2568 // update the decompressor state
2569 ipc->incomp(stat, skb, *proto); 2569 ipc->incomp(stat, skb, *proto);
@@ -2572,31 +2572,31 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb, struct ippp_stru
2572} 2572}
2573 2573
2574/* 2574/*
2575 * compress a frame 2575 * compress a frame
2576 * type=0: normal/bundle compression 2576 * type=0: normal/bundle compression
2577 * =1: link compression 2577 * =1: link compression
2578 * returns original skb if we haven't compressed the frame 2578 * returns original skb if we haven't compressed the frame
2579 * and a new skb pointer if we've done it 2579 * and a new skb pointer if we've done it
2580 */ 2580 */
2581static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in, int *proto, 2581static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto,
2582 struct ippp_struct *is, struct ippp_struct *master, int type) 2582 struct ippp_struct *is,struct ippp_struct *master,int type)
2583{ 2583{
2584 int ret; 2584 int ret;
2585 int new_proto; 2585 int new_proto;
2586 struct isdn_ppp_compressor *compressor; 2586 struct isdn_ppp_compressor *compressor;
2587 void *stat; 2587 void *stat;
2588 struct sk_buff *skb_out; 2588 struct sk_buff *skb_out;
2589 2589
2590 /* we do not compress control protocols */ 2590 /* we do not compress control protocols */
2591 if (*proto < 0 || *proto > 0x3fff) { 2591 if(*proto < 0 || *proto > 0x3fff) {
2592 return skb_in; 2592 return skb_in;
2593 } 2593 }
2594 2594
2595 if (type) { /* type=1 => Link compression */ 2595 if(type) { /* type=1 => Link compression */
2596 return skb_in; 2596 return skb_in;
2597 } 2597 }
2598 else { 2598 else {
2599 if (!master) { 2599 if(!master) {
2600 compressor = is->compressor; 2600 compressor = is->compressor;
2601 stat = is->comp_stat; 2601 stat = is->comp_stat;
2602 } 2602 }
@@ -2607,90 +2607,90 @@ static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in, int *proto,
2607 new_proto = PPP_COMP; 2607 new_proto = PPP_COMP;
2608 } 2608 }
2609 2609
2610 if (!compressor) { 2610 if(!compressor) {
2611 printk(KERN_ERR "isdn_ppp: No compressor set!\n"); 2611 printk(KERN_ERR "isdn_ppp: No compressor set!\n");
2612 return skb_in; 2612 return skb_in;
2613 } 2613 }
2614 if (!stat) { 2614 if(!stat) {
2615 printk(KERN_ERR "isdn_ppp: Compressor not initialized?\n"); 2615 printk(KERN_ERR "isdn_ppp: Compressor not initialized?\n");
2616 return skb_in; 2616 return skb_in;
2617 } 2617 }
2618 2618
2619 /* Allow for at least 150 % expansion (for now) */ 2619 /* Allow for at least 150 % expansion (for now) */
2620 skb_out = alloc_skb(skb_in->len + skb_in->len / 2 + 32 + 2620 skb_out = alloc_skb(skb_in->len + skb_in->len/2 + 32 +
2621 skb_headroom(skb_in), GFP_ATOMIC); 2621 skb_headroom(skb_in), GFP_ATOMIC);
2622 if (!skb_out) 2622 if(!skb_out)
2623 return skb_in; 2623 return skb_in;
2624 skb_reserve(skb_out, skb_headroom(skb_in)); 2624 skb_reserve(skb_out, skb_headroom(skb_in));
2625 2625
2626 ret = (compressor->compress)(stat, skb_in, skb_out, *proto); 2626 ret = (compressor->compress)(stat,skb_in,skb_out,*proto);
2627 if (!ret) { 2627 if(!ret) {
2628 dev_kfree_skb(skb_out); 2628 dev_kfree_skb(skb_out);
2629 return skb_in; 2629 return skb_in;
2630 } 2630 }
2631 2631
2632 dev_kfree_skb(skb_in); 2632 dev_kfree_skb(skb_in);
2633 *proto = new_proto; 2633 *proto = new_proto;
2634 return skb_out; 2634 return skb_out;
2635} 2635}
2636 2636
2637/* 2637/*
2638 * we received a CCP frame .. 2638 * we received a CCP frame ..
2639 * not a clean solution, but we MUST handle a few cases in the kernel 2639 * not a clean solution, but we MUST handle a few cases in the kernel
2640 */ 2640 */
2641static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, 2641static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2642 struct sk_buff *skb, int proto) 2642 struct sk_buff *skb,int proto)
2643{ 2643{
2644 struct ippp_struct *is; 2644 struct ippp_struct *is;
2645 struct ippp_struct *mis; 2645 struct ippp_struct *mis;
2646 int len; 2646 int len;
2647 struct isdn_ppp_resetparams rsparm; 2647 struct isdn_ppp_resetparams rsparm;
2648 unsigned char rsdata[IPPP_RESET_MAXDATABYTES]; 2648 unsigned char rsdata[IPPP_RESET_MAXDATABYTES];
2649 2649
2650 printk(KERN_DEBUG "Received CCP frame from peer slot(%d)\n", 2650 printk(KERN_DEBUG "Received CCP frame from peer slot(%d)\n",
2651 lp->ppp_slot); 2651 lp->ppp_slot);
2652 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { 2652 if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
2653 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", 2653 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n",
2654 __func__, lp->ppp_slot); 2654 __func__, lp->ppp_slot);
2655 return; 2655 return;
2656 } 2656 }
2657 is = ippp_table[lp->ppp_slot]; 2657 is = ippp_table[lp->ppp_slot];
2658 isdn_ppp_frame_log("ccp-rcv", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 2658 isdn_ppp_frame_log("ccp-rcv", skb->data, skb->len, 32, is->unit,lp->ppp_slot);
2659 2659
2660 if (lp->master) { 2660 if(lp->master) {
2661 int slot = ISDN_MASTER_PRIV(lp)->ppp_slot; 2661 int slot = ISDN_MASTER_PRIV(lp)->ppp_slot;
2662 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 2662 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
2663 printk(KERN_ERR "%s: slot(%d) out of range\n", 2663 printk(KERN_ERR "%s: slot(%d) out of range\n",
2664 __func__, slot); 2664 __func__, slot);
2665 return; 2665 return;
2666 } 2666 }
2667 mis = ippp_table[slot]; 2667 mis = ippp_table[slot];
2668 } else 2668 } else
2669 mis = is; 2669 mis = is;
2670 2670
2671 switch (skb->data[0]) { 2671 switch(skb->data[0]) {
2672 case CCP_CONFREQ: 2672 case CCP_CONFREQ:
2673 if (is->debug & 0x10) 2673 if(is->debug & 0x10)
2674 printk(KERN_DEBUG "Disable compression here!\n"); 2674 printk(KERN_DEBUG "Disable compression here!\n");
2675 if (proto == PPP_CCP) 2675 if(proto == PPP_CCP)
2676 mis->compflags &= ~SC_COMP_ON; 2676 mis->compflags &= ~SC_COMP_ON;
2677 else 2677 else
2678 is->compflags &= ~SC_LINK_COMP_ON; 2678 is->compflags &= ~SC_LINK_COMP_ON;
2679 break; 2679 break;
2680 case CCP_TERMREQ: 2680 case CCP_TERMREQ:
2681 case CCP_TERMACK: 2681 case CCP_TERMACK:
2682 if (is->debug & 0x10) 2682 if(is->debug & 0x10)
2683 printk(KERN_DEBUG "Disable (de)compression here!\n"); 2683 printk(KERN_DEBUG "Disable (de)compression here!\n");
2684 if (proto == PPP_CCP) 2684 if(proto == PPP_CCP)
2685 mis->compflags &= ~(SC_DECOMP_ON | SC_COMP_ON); 2685 mis->compflags &= ~(SC_DECOMP_ON|SC_COMP_ON);
2686 else 2686 else
2687 is->compflags &= ~(SC_LINK_DECOMP_ON | SC_LINK_COMP_ON); 2687 is->compflags &= ~(SC_LINK_DECOMP_ON|SC_LINK_COMP_ON);
2688 break; 2688 break;
2689 case CCP_CONFACK: 2689 case CCP_CONFACK:
2690 /* if we RECEIVE an ackowledge we enable the decompressor */ 2690 /* if we RECEIVE an ackowledge we enable the decompressor */
2691 if (is->debug & 0x10) 2691 if(is->debug & 0x10)
2692 printk(KERN_DEBUG "Enable decompression here!\n"); 2692 printk(KERN_DEBUG "Enable decompression here!\n");
2693 if (proto == PPP_CCP) { 2693 if(proto == PPP_CCP) {
2694 if (!mis->decompressor) 2694 if (!mis->decompressor)
2695 break; 2695 break;
2696 mis->compflags |= SC_DECOMP_ON; 2696 mis->compflags |= SC_DECOMP_ON;
@@ -2706,11 +2706,11 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2706 len = (skb->data[2] << 8) | skb->data[3]; 2706 len = (skb->data[2] << 8) | skb->data[3];
2707 len -= 4; 2707 len -= 4;
2708 2708
2709 if (proto == PPP_CCP) { 2709 if(proto == PPP_CCP) {
2710 /* If a reset Ack was outstanding for this id, then 2710 /* If a reset Ack was outstanding for this id, then
2711 clean up the state engine */ 2711 clean up the state engine */
2712 isdn_ppp_ccp_reset_ack_rcvd(mis, skb->data[1]); 2712 isdn_ppp_ccp_reset_ack_rcvd(mis, skb->data[1]);
2713 if (mis->decompressor && mis->decomp_stat) 2713 if(mis->decompressor && mis->decomp_stat)
2714 mis->decompressor-> 2714 mis->decompressor->
2715 reset(mis->decomp_stat, 2715 reset(mis->decomp_stat,
2716 skb->data[0], 2716 skb->data[0],
@@ -2722,7 +2722,7 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2722 } 2722 }
2723 else { 2723 else {
2724 isdn_ppp_ccp_reset_ack_rcvd(is, skb->data[1]); 2724 isdn_ppp_ccp_reset_ack_rcvd(is, skb->data[1]);
2725 if (is->link_decompressor && is->link_decomp_stat) 2725 if(is->link_decompressor && is->link_decomp_stat)
2726 is->link_decompressor-> 2726 is->link_decompressor->
2727 reset(is->link_decomp_stat, 2727 reset(is->link_decomp_stat,
2728 skb->data[0], 2728 skb->data[0],
@@ -2740,12 +2740,12 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2740 /* Set up reset params for the reset entry */ 2740 /* Set up reset params for the reset entry */
2741 memset(&rsparm, 0, sizeof(rsparm)); 2741 memset(&rsparm, 0, sizeof(rsparm));
2742 rsparm.data = rsdata; 2742 rsparm.data = rsdata;
2743 rsparm.maxdlen = IPPP_RESET_MAXDATABYTES; 2743 rsparm.maxdlen = IPPP_RESET_MAXDATABYTES;
2744 /* Isolate data length */ 2744 /* Isolate data length */
2745 len = (skb->data[2] << 8) | skb->data[3]; 2745 len = (skb->data[2] << 8) | skb->data[3];
2746 len -= 4; 2746 len -= 4;
2747 if (proto == PPP_CCP) { 2747 if(proto == PPP_CCP) {
2748 if (mis->compressor && mis->comp_stat) 2748 if(mis->compressor && mis->comp_stat)
2749 mis->compressor-> 2749 mis->compressor->
2750 reset(mis->comp_stat, 2750 reset(mis->comp_stat,
2751 skb->data[0], 2751 skb->data[0],
@@ -2754,7 +2754,7 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2754 len, &rsparm); 2754 len, &rsparm);
2755 } 2755 }
2756 else { 2756 else {
2757 if (is->link_compressor && is->link_comp_stat) 2757 if(is->link_compressor && is->link_comp_stat)
2758 is->link_compressor-> 2758 is->link_compressor->
2759 reset(is->link_comp_stat, 2759 reset(is->link_comp_stat,
2760 skb->data[0], 2760 skb->data[0],
@@ -2763,9 +2763,9 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2763 len, &rsparm); 2763 len, &rsparm);
2764 } 2764 }
2765 /* Ack the Req as specified by rsparm */ 2765 /* Ack the Req as specified by rsparm */
2766 if (rsparm.valid) { 2766 if(rsparm.valid) {
2767 /* Compressor reset handler decided how to answer */ 2767 /* Compressor reset handler decided how to answer */
2768 if (rsparm.rsend) { 2768 if(rsparm.rsend) {
2769 /* We should send a Frame */ 2769 /* We should send a Frame */
2770 isdn_ppp_ccp_xmit_reset(is, proto, CCP_RESETACK, 2770 isdn_ppp_ccp_xmit_reset(is, proto, CCP_RESETACK,
2771 rsparm.idval ? rsparm.id 2771 rsparm.idval ? rsparm.id
@@ -2817,69 +2817,69 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
2817 2817
2818static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb) 2818static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb)
2819{ 2819{
2820 struct ippp_struct *mis, *is; 2820 struct ippp_struct *mis,*is;
2821 int proto, slot = lp->ppp_slot; 2821 int proto, slot = lp->ppp_slot;
2822 unsigned char *data; 2822 unsigned char *data;
2823 2823
2824 if (!skb || skb->len < 3) 2824 if(!skb || skb->len < 3)
2825 return; 2825 return;
2826 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 2826 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
2827 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", 2827 printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n",
2828 __func__, slot); 2828 __func__, slot);
2829 return; 2829 return;
2830 } 2830 }
2831 is = ippp_table[slot]; 2831 is = ippp_table[slot];
2832 /* Daemon may send with or without address and control field comp */ 2832 /* Daemon may send with or without address and control field comp */
2833 data = skb->data; 2833 data = skb->data;
2834 if (!(is->pppcfg & SC_COMP_AC) && data[0] == 0xff && data[1] == 0x03) { 2834 if(!(is->pppcfg & SC_COMP_AC) && data[0] == 0xff && data[1] == 0x03) {
2835 data += 2; 2835 data += 2;
2836 if (skb->len < 5) 2836 if(skb->len < 5)
2837 return; 2837 return;
2838 } 2838 }
2839 2839
2840 proto = ((int)data[0]<<8) + data[1]; 2840 proto = ((int)data[0]<<8)+data[1];
2841 if (proto != PPP_CCP && proto != PPP_CCPFRAG) 2841 if(proto != PPP_CCP && proto != PPP_CCPFRAG)
2842 return; 2842 return;
2843 2843
2844 printk(KERN_DEBUG "Received CCP frame from daemon:\n"); 2844 printk(KERN_DEBUG "Received CCP frame from daemon:\n");
2845 isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); 2845 isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit,lp->ppp_slot);
2846 2846
2847 if (lp->master) { 2847 if (lp->master) {
2848 slot = ISDN_MASTER_PRIV(lp)->ppp_slot; 2848 slot = ISDN_MASTER_PRIV(lp)->ppp_slot;
2849 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { 2849 if (slot < 0 || slot >= ISDN_MAX_CHANNELS) {
2850 printk(KERN_ERR "%s: slot(%d) out of range\n", 2850 printk(KERN_ERR "%s: slot(%d) out of range\n",
2851 __func__, slot); 2851 __func__, slot);
2852 return; 2852 return;
2853 } 2853 }
2854 mis = ippp_table[slot]; 2854 mis = ippp_table[slot];
2855 } else 2855 } else
2856 mis = is; 2856 mis = is;
2857 if (mis != is) 2857 if (mis != is)
2858 printk(KERN_DEBUG "isdn_ppp: Ouch! Master CCP sends on slave slot!\n"); 2858 printk(KERN_DEBUG "isdn_ppp: Ouch! Master CCP sends on slave slot!\n");
2859 2859
2860 switch (data[2]) { 2860 switch(data[2]) {
2861 case CCP_CONFREQ: 2861 case CCP_CONFREQ:
2862 if (is->debug & 0x10) 2862 if(is->debug & 0x10)
2863 printk(KERN_DEBUG "Disable decompression here!\n"); 2863 printk(KERN_DEBUG "Disable decompression here!\n");
2864 if (proto == PPP_CCP) 2864 if(proto == PPP_CCP)
2865 is->compflags &= ~SC_DECOMP_ON; 2865 is->compflags &= ~SC_DECOMP_ON;
2866 else 2866 else
2867 is->compflags &= ~SC_LINK_DECOMP_ON; 2867 is->compflags &= ~SC_LINK_DECOMP_ON;
2868 break; 2868 break;
2869 case CCP_TERMREQ: 2869 case CCP_TERMREQ:
2870 case CCP_TERMACK: 2870 case CCP_TERMACK:
2871 if (is->debug & 0x10) 2871 if(is->debug & 0x10)
2872 printk(KERN_DEBUG "Disable (de)compression here!\n"); 2872 printk(KERN_DEBUG "Disable (de)compression here!\n");
2873 if (proto == PPP_CCP) 2873 if(proto == PPP_CCP)
2874 is->compflags &= ~(SC_DECOMP_ON | SC_COMP_ON); 2874 is->compflags &= ~(SC_DECOMP_ON|SC_COMP_ON);
2875 else 2875 else
2876 is->compflags &= ~(SC_LINK_DECOMP_ON | SC_LINK_COMP_ON); 2876 is->compflags &= ~(SC_LINK_DECOMP_ON|SC_LINK_COMP_ON);
2877 break; 2877 break;
2878 case CCP_CONFACK: 2878 case CCP_CONFACK:
2879 /* if we SEND an ackowledge we can/must enable the compressor */ 2879 /* if we SEND an ackowledge we can/must enable the compressor */
2880 if (is->debug & 0x10) 2880 if(is->debug & 0x10)
2881 printk(KERN_DEBUG "Enable compression here!\n"); 2881 printk(KERN_DEBUG "Enable compression here!\n");
2882 if (proto == PPP_CCP) { 2882 if(proto == PPP_CCP) {
2883 if (!is->compressor) 2883 if (!is->compressor)
2884 break; 2884 break;
2885 is->compflags |= SC_COMP_ON; 2885 is->compflags |= SC_COMP_ON;
@@ -2891,21 +2891,21 @@ static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct
2891 break; 2891 break;
2892 case CCP_RESETACK: 2892 case CCP_RESETACK:
2893 /* If we send a ACK we should reset our compressor */ 2893 /* If we send a ACK we should reset our compressor */
2894 if (is->debug & 0x10) 2894 if(is->debug & 0x10)
2895 printk(KERN_DEBUG "Reset decompression state here!\n"); 2895 printk(KERN_DEBUG "Reset decompression state here!\n");
2896 printk(KERN_DEBUG "ResetAck from daemon passed by\n"); 2896 printk(KERN_DEBUG "ResetAck from daemon passed by\n");
2897 if (proto == PPP_CCP) { 2897 if(proto == PPP_CCP) {
2898 /* link to master? */ 2898 /* link to master? */
2899 if (is->compressor && is->comp_stat) 2899 if(is->compressor && is->comp_stat)
2900 is->compressor->reset(is->comp_stat, 0, 0, 2900 is->compressor->reset(is->comp_stat, 0, 0,
2901 NULL, 0, NULL); 2901 NULL, 0, NULL);
2902 is->compflags &= ~SC_COMP_DISCARD; 2902 is->compflags &= ~SC_COMP_DISCARD;
2903 } 2903 }
2904 else { 2904 else {
2905 if (is->link_compressor && is->link_comp_stat) 2905 if(is->link_compressor && is->link_comp_stat)
2906 is->link_compressor->reset(is->link_comp_stat, 2906 is->link_compressor->reset(is->link_comp_stat,
2907 0, 0, NULL, 0, NULL); 2907 0, 0, NULL, 0, NULL);
2908 is->compflags &= ~SC_LINK_COMP_DISCARD; 2908 is->compflags &= ~SC_LINK_COMP_DISCARD;
2909 } 2909 }
2910 break; 2910 break;
2911 case CCP_RESETREQ: 2911 case CCP_RESETREQ:
@@ -2919,7 +2919,7 @@ int isdn_ppp_register_compressor(struct isdn_ppp_compressor *ipc)
2919{ 2919{
2920 ipc->next = ipc_head; 2920 ipc->next = ipc_head;
2921 ipc->prev = NULL; 2921 ipc->prev = NULL;
2922 if (ipc_head) { 2922 if(ipc_head) {
2923 ipc_head->prev = ipc; 2923 ipc_head->prev = ipc;
2924 } 2924 }
2925 ipc_head = ipc; 2925 ipc_head = ipc;
@@ -2928,11 +2928,11 @@ int isdn_ppp_register_compressor(struct isdn_ppp_compressor *ipc)
2928 2928
2929int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc) 2929int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc)
2930{ 2930{
2931 if (ipc->prev) 2931 if(ipc->prev)
2932 ipc->prev->next = ipc->next; 2932 ipc->prev->next = ipc->next;
2933 else 2933 else
2934 ipc_head = ipc->next; 2934 ipc_head = ipc->next;
2935 if (ipc->next) 2935 if(ipc->next)
2936 ipc->next->prev = ipc->prev; 2936 ipc->next->prev = ipc->prev;
2937 ipc->prev = ipc->next = NULL; 2937 ipc->prev = ipc->next = NULL;
2938 return 0; 2938 return 0;
@@ -2945,26 +2945,26 @@ static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_
2945 void *stat; 2945 void *stat;
2946 int num = data->num; 2946 int num = data->num;
2947 2947
2948 if (is->debug & 0x10) 2948 if(is->debug & 0x10)
2949 printk(KERN_DEBUG "[%d] Set %s type %d\n", is->unit, 2949 printk(KERN_DEBUG "[%d] Set %s type %d\n",is->unit,
2950 (data->flags & IPPP_COMP_FLAG_XMIT) ? "compressor" : "decompressor", num); 2950 (data->flags&IPPP_COMP_FLAG_XMIT)?"compressor":"decompressor",num);
2951 2951
2952 /* If is has no valid reset state vector, we cannot allocate a 2952 /* If is has no valid reset state vector, we cannot allocate a
2953 decompressor. The decompressor would cause reset transactions 2953 decompressor. The decompressor would cause reset transactions
2954 sooner or later, and they need that vector. */ 2954 sooner or later, and they need that vector. */
2955 2955
2956 if (!(data->flags & IPPP_COMP_FLAG_XMIT) && !is->reset) { 2956 if(!(data->flags & IPPP_COMP_FLAG_XMIT) && !is->reset) {
2957 printk(KERN_ERR "ippp_ccp: no reset data structure - can't" 2957 printk(KERN_ERR "ippp_ccp: no reset data structure - can't"
2958 " allow decompression.\n"); 2958 " allow decompression.\n");
2959 return -ENOMEM; 2959 return -ENOMEM;
2960 } 2960 }
2961 2961
2962 while (ipc) { 2962 while(ipc) {
2963 if (ipc->num == num) { 2963 if(ipc->num == num) {
2964 stat = ipc->alloc(data); 2964 stat = ipc->alloc(data);
2965 if (stat) { 2965 if(stat) {
2966 ret = ipc->init(stat, data, is->unit, 0); 2966 ret = ipc->init(stat,data,is->unit,0);
2967 if (!ret) { 2967 if(!ret) {
2968 printk(KERN_ERR "Can't init (de)compression!\n"); 2968 printk(KERN_ERR "Can't init (de)compression!\n");
2969 ipc->free(stat); 2969 ipc->free(stat);
2970 stat = NULL; 2970 stat = NULL;
@@ -2976,32 +2976,32 @@ static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_
2976 break; 2976 break;
2977 } 2977 }
2978 2978
2979 if (data->flags & IPPP_COMP_FLAG_XMIT) { 2979 if(data->flags & IPPP_COMP_FLAG_XMIT) {
2980 if (data->flags & IPPP_COMP_FLAG_LINK) { 2980 if(data->flags & IPPP_COMP_FLAG_LINK) {
2981 if (is->link_comp_stat) 2981 if(is->link_comp_stat)
2982 is->link_compressor->free(is->link_comp_stat); 2982 is->link_compressor->free(is->link_comp_stat);
2983 is->link_comp_stat = stat; 2983 is->link_comp_stat = stat;
2984 is->link_compressor = ipc; 2984 is->link_compressor = ipc;
2985 } 2985 }
2986 else { 2986 else {
2987 if (is->comp_stat) 2987 if(is->comp_stat)
2988 is->compressor->free(is->comp_stat); 2988 is->compressor->free(is->comp_stat);
2989 is->comp_stat = stat; 2989 is->comp_stat = stat;
2990 is->compressor = ipc; 2990 is->compressor = ipc;
2991 } 2991 }
2992 } 2992 }
2993 else { 2993 else {
2994 if (data->flags & IPPP_COMP_FLAG_LINK) { 2994 if(data->flags & IPPP_COMP_FLAG_LINK) {
2995 if (is->link_decomp_stat) 2995 if(is->link_decomp_stat)
2996 is->link_decompressor->free(is->link_decomp_stat); 2996 is->link_decompressor->free(is->link_decomp_stat);
2997 is->link_decomp_stat = stat; 2997 is->link_decomp_stat = stat;
2998 is->link_decompressor = ipc; 2998 is->link_decompressor = ipc;
2999 } 2999 }
3000 else { 3000 else {
3001 if (is->decomp_stat) 3001 if(is->decomp_stat)
3002 is->decompressor->free(is->decomp_stat); 3002 is->decompressor->free(is->decomp_stat);
3003 is->decomp_stat = stat; 3003 is->decomp_stat = stat;
3004 is->decompressor = ipc; 3004 is->decompressor = ipc;
3005 } 3005 }
3006 } 3006 }
3007 return 0; 3007 return 0;
diff --git a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h
index 4e9b8935a4e..8cc05c7ccf7 100644
--- a/drivers/isdn/i4l/isdn_ppp.h
+++ b/drivers/isdn/i4l/isdn_ppp.h
@@ -39,3 +39,5 @@ extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc);
39#define IPPP_ASSIGNED 0x10 39#define IPPP_ASSIGNED 0x10
40 40
41#define IPPP_MAX_HEADER 10 41#define IPPP_MAX_HEADER 10
42
43
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index e09dc8a5e74..d8504279e50 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1,4 +1,5 @@
1/* 1/* $Id: isdn_tty.c,v 1.1.2.3 2004/02/10 01:07:13 keil Exp $
2 *
2 * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). 3 * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel).
3 * 4 *
4 * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) 5 * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de)
@@ -11,7 +12,6 @@
11#undef ISDN_TTY_STAT_DEBUG 12#undef ISDN_TTY_STAT_DEBUG
12 13
13#include <linux/isdn.h> 14#include <linux/isdn.h>
14#include <linux/serial.h> /* ASYNC_* flags */
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
@@ -48,6 +48,9 @@ static int bit2si[8] =
48static int si2bit[8] = 48static int si2bit[8] =
49{4, 1, 4, 4, 4, 4, 4, 4}; 49{4, 1, 4, 4, 4, 4, 4, 4};
50 50
51char *isdn_tty_revision = "$Revision: 1.1.2.3 $";
52
53
51/* isdn_tty_try_read() is called from within isdn_tty_rcv_skb() 54/* isdn_tty_try_read() is called from within isdn_tty_rcv_skb()
52 * to stuff incoming data directly into a tty's flip-buffer. This 55 * to stuff incoming data directly into a tty's flip-buffer. This
53 * is done to speed up tty-receiving if the receive-queue is empty. 56 * is done to speed up tty-receiving if the receive-queue is empty.
@@ -58,61 +61,56 @@ static int si2bit[8] =
58 * isdn_tty_readmodem(). 61 * isdn_tty_readmodem().
59 */ 62 */
60static int 63static int
61isdn_tty_try_read(modem_info *info, struct sk_buff *skb) 64isdn_tty_try_read(modem_info * info, struct sk_buff *skb)
62{ 65{
63 int c; 66 int c;
64 int len; 67 int len;
65 struct tty_struct *tty; 68 struct tty_struct *tty;
66 char last; 69 char last;
67 70
68 if (!info->online) 71 if (info->online) {
69 return 0; 72 if ((tty = info->tty)) {
70 73 if (info->mcr & UART_MCR_RTS) {
71 tty = info->port.tty; 74 len = skb->len
72 if (!tty)
73 return 0;
74
75 if (!(info->mcr & UART_MCR_RTS))
76 return 0;
77
78 len = skb->len
79#ifdef CONFIG_ISDN_AUDIO 75#ifdef CONFIG_ISDN_AUDIO
80 + ISDN_AUDIO_SKB_DLECOUNT(skb) 76 + ISDN_AUDIO_SKB_DLECOUNT(skb)
81#endif 77#endif
82 ; 78 ;
83
84 c = tty_buffer_request_room(tty, len);
85 if (c < len)
86 return 0;
87 79
80 c = tty_buffer_request_room(tty, len);
81 if (c >= len) {
88#ifdef CONFIG_ISDN_AUDIO 82#ifdef CONFIG_ISDN_AUDIO
89 if (ISDN_AUDIO_SKB_DLECOUNT(skb)) { 83 if (ISDN_AUDIO_SKB_DLECOUNT(skb)) {
90 int l = skb->len; 84 int l = skb->len;
91 unsigned char *dp = skb->data; 85 unsigned char *dp = skb->data;
92 while (--l) { 86 while (--l) {
93 if (*dp == DLE) 87 if (*dp == DLE)
94 tty_insert_flip_char(tty, DLE, 0); 88 tty_insert_flip_char(tty, DLE, 0);
95 tty_insert_flip_char(tty, *dp++, 0); 89 tty_insert_flip_char(tty, *dp++, 0);
96 } 90 }
97 if (*dp == DLE) 91 if (*dp == DLE)
98 tty_insert_flip_char(tty, DLE, 0); 92 tty_insert_flip_char(tty, DLE, 0);
99 last = *dp; 93 last = *dp;
100 } else { 94 } else {
101#endif 95#endif
102 if (len > 1) 96 if(len > 1)
103 tty_insert_flip_string(tty, skb->data, len - 1); 97 tty_insert_flip_string(tty, skb->data, len - 1);
104 last = skb->data[len - 1]; 98 last = skb->data[len - 1];
105#ifdef CONFIG_ISDN_AUDIO 99#ifdef CONFIG_ISDN_AUDIO
106 } 100 }
107#endif 101#endif
108 if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) 102 if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP)
109 tty_insert_flip_char(tty, last, 0xFF); 103 tty_insert_flip_char(tty, last, 0xFF);
110 else 104 else
111 tty_insert_flip_char(tty, last, TTY_NORMAL); 105 tty_insert_flip_char(tty, last, TTY_NORMAL);
112 tty_flip_buffer_push(tty); 106 tty_flip_buffer_push(tty);
113 kfree_skb(skb); 107 kfree_skb(skb);
114 108 return 1;
115 return 1; 109 }
110 }
111 }
112 }
113 return 0;
116} 114}
117 115
118/* isdn_tty_readmodem() is called periodically from within timer-interrupt. 116/* isdn_tty_readmodem() is called periodically from within timer-interrupt.
@@ -130,39 +128,35 @@ isdn_tty_readmodem(void)
130 modem_info *info; 128 modem_info *info;
131 129
132 for (i = 0; i < ISDN_MAX_CHANNELS; i++) { 130 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
133 midx = dev->m_idx[i]; 131 if ((midx = dev->m_idx[i]) >= 0) {
134 if (midx < 0) 132 info = &dev->mdm.info[midx];
135 continue; 133 if (info->online) {
136 134 r = 0;
137 info = &dev->mdm.info[midx];
138 if (!info->online)
139 continue;
140
141 r = 0;
142#ifdef CONFIG_ISDN_AUDIO 135#ifdef CONFIG_ISDN_AUDIO
143 isdn_audio_eval_dtmf(info); 136 isdn_audio_eval_dtmf(info);
144 if ((info->vonline & 1) && (info->emu.vpar[1])) 137 if ((info->vonline & 1) && (info->emu.vpar[1]))
145 isdn_audio_eval_silence(info); 138 isdn_audio_eval_silence(info);
146#endif 139#endif
147 tty = info->port.tty; 140 if ((tty = info->tty)) {
148 if (tty) { 141 if (info->mcr & UART_MCR_RTS) {
149 if (info->mcr & UART_MCR_RTS) { 142 /* CISCO AsyncPPP Hack */
150 /* CISCO AsyncPPP Hack */ 143 if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP))
151 if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) 144 r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0);
152 r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0); 145 else
153 else 146 r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1);
154 r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1); 147 if (r)
155 if (r) 148 tty_flip_buffer_push(tty);
156 tty_flip_buffer_push(tty); 149 } else
157 } else 150 r = 1;
158 r = 1; 151 } else
159 } else 152 r = 1;
160 r = 1; 153 if (r) {
161 if (r) { 154 info->rcvsched = 0;
162 info->rcvsched = 0; 155 resched = 1;
163 resched = 1; 156 } else
164 } else 157 info->rcvsched = 1;
165 info->rcvsched = 1; 158 }
159 }
166 } 160 }
167 if (!resched) 161 if (!resched)
168 isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0); 162 isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0);
@@ -185,7 +179,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb)
185 info = &dev->mdm.info[midx]; 179 info = &dev->mdm.info[midx];
186#ifdef CONFIG_ISDN_AUDIO 180#ifdef CONFIG_ISDN_AUDIO
187 ifmt = 1; 181 ifmt = 1;
188 182
189 if ((info->vonline) && (!info->emu.vpar[4])) 183 if ((info->vonline) && (!info->emu.vpar[4]))
190 isdn_audio_calc_dtmf(info, skb->data, skb->len, ifmt); 184 isdn_audio_calc_dtmf(info, skb->data, skb->len, ifmt);
191 if ((info->vonline & 1) && (info->emu.vpar[1])) 185 if ((info->vonline & 1) && (info->emu.vpar[1]))
@@ -219,29 +213,29 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb)
219 if (info->vonline & 1) { 213 if (info->vonline & 1) {
220 /* voice conversion/compression */ 214 /* voice conversion/compression */
221 switch (info->emu.vpar[3]) { 215 switch (info->emu.vpar[3]) {
222 case 2: 216 case 2:
223 case 3: 217 case 3:
224 case 4: 218 case 4:
225 /* adpcm 219 /* adpcm
226 * Since compressed data takes less 220 * Since compressed data takes less
227 * space, we can overwrite the buffer. 221 * space, we can overwrite the buffer.
228 */ 222 */
229 skb_trim(skb, isdn_audio_xlaw2adpcm(info->adpcmr, 223 skb_trim(skb, isdn_audio_xlaw2adpcm(info->adpcmr,
230 ifmt, 224 ifmt,
231 skb->data, 225 skb->data,
232 skb->data, 226 skb->data,
233 skb->len)); 227 skb->len));
234 break; 228 break;
235 case 5: 229 case 5:
236 /* a-law */ 230 /* a-law */
237 if (!ifmt) 231 if (!ifmt)
238 isdn_audio_ulaw2alaw(skb->data, skb->len); 232 isdn_audio_ulaw2alaw(skb->data, skb->len);
239 break; 233 break;
240 case 6: 234 case 6:
241 /* u-law */ 235 /* u-law */
242 if (ifmt) 236 if (ifmt)
243 isdn_audio_alaw2ulaw(skb->data, skb->len); 237 isdn_audio_alaw2ulaw(skb->data, skb->len);
244 break; 238 break;
245 } 239 }
246 ISDN_AUDIO_SKB_DLECOUNT(skb) = 240 ISDN_AUDIO_SKB_DLECOUNT(skb) =
247 isdn_tty_countDLE(skb->data, skb->len); 241 isdn_tty_countDLE(skb->data, skb->len);
@@ -281,7 +275,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb)
281} 275}
282 276
283static void 277static void
284isdn_tty_cleanup_xmit(modem_info *info) 278isdn_tty_cleanup_xmit(modem_info * info)
285{ 279{
286 skb_queue_purge(&info->xmit_queue); 280 skb_queue_purge(&info->xmit_queue);
287#ifdef CONFIG_ISDN_AUDIO 281#ifdef CONFIG_ISDN_AUDIO
@@ -290,7 +284,7 @@ isdn_tty_cleanup_xmit(modem_info *info)
290} 284}
291 285
292static void 286static void
293isdn_tty_tint(modem_info *info) 287isdn_tty_tint(modem_info * info)
294{ 288{
295 struct sk_buff *skb = skb_dequeue(&info->xmit_queue); 289 struct sk_buff *skb = skb_dequeue(&info->xmit_queue);
296 int len, slen; 290 int len, slen;
@@ -300,7 +294,7 @@ isdn_tty_tint(modem_info *info)
300 len = skb->len; 294 len = skb->len;
301 if ((slen = isdn_writebuf_skb_stub(info->isdn_driver, 295 if ((slen = isdn_writebuf_skb_stub(info->isdn_driver,
302 info->isdn_channel, 1, skb)) == len) { 296 info->isdn_channel, 1, skb)) == len) {
303 struct tty_struct *tty = info->port.tty; 297 struct tty_struct *tty = info->tty;
304 info->send_outstanding++; 298 info->send_outstanding++;
305 info->msr &= ~UART_MSR_CTS; 299 info->msr &= ~UART_MSR_CTS;
306 info->lsr &= ~UART_LSR_TEMT; 300 info->lsr &= ~UART_LSR_TEMT;
@@ -331,51 +325,51 @@ isdn_tty_countDLE(unsigned char *buf, int len)
331 * DLE-decoding when sending audio-data. 325 * DLE-decoding when sending audio-data.
332 */ 326 */
333static int 327static int
334isdn_tty_handleDLEdown(modem_info *info, atemu *m, int len) 328isdn_tty_handleDLEdown(modem_info * info, atemu * m, int len)
335{ 329{
336 unsigned char *p = &info->port.xmit_buf[info->xmit_count]; 330 unsigned char *p = &info->xmit_buf[info->xmit_count];
337 int count = 0; 331 int count = 0;
338 332
339 while (len > 0) { 333 while (len > 0) {
340 if (m->lastDLE) { 334 if (m->lastDLE) {
341 m->lastDLE = 0; 335 m->lastDLE = 0;
342 switch (*p) { 336 switch (*p) {
343 case DLE: 337 case DLE:
344 /* Escape code */ 338 /* Escape code */
345 if (len > 1) 339 if (len > 1)
346 memmove(p, p + 1, len - 1); 340 memmove(p, p + 1, len - 1);
347 p--; 341 p--;
348 count++; 342 count++;
349 break; 343 break;
350 case ETX: 344 case ETX:
351 /* End of data */ 345 /* End of data */
352 info->vonline |= 4; 346 info->vonline |= 4;
353 return count; 347 return count;
354 case DC4: 348 case DC4:
355 /* Abort RX */ 349 /* Abort RX */
356 info->vonline &= ~1; 350 info->vonline &= ~1;
357#ifdef ISDN_DEBUG_MODEM_VOICE
358 printk(KERN_DEBUG
359 "DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n",
360 info->line);
361#endif
362 isdn_tty_at_cout("\020\003", info);
363 if (!info->vonline) {
364#ifdef ISDN_DEBUG_MODEM_VOICE 351#ifdef ISDN_DEBUG_MODEM_VOICE
365 printk(KERN_DEBUG 352 printk(KERN_DEBUG
366 "DLEdown: send VCON on ttyI%d\n", 353 "DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n",
367 info->line); 354 info->line);
368#endif 355#endif
369 isdn_tty_at_cout("\r\nVCON\r\n", info); 356 isdn_tty_at_cout("\020\003", info);
370 } 357 if (!info->vonline) {
371 /* Fall through */ 358#ifdef ISDN_DEBUG_MODEM_VOICE
372 case 'q': 359 printk(KERN_DEBUG
373 case 's': 360 "DLEdown: send VCON on ttyI%d\n",
374 /* Silence */ 361 info->line);
375 if (len > 1) 362#endif
376 memmove(p, p + 1, len - 1); 363 isdn_tty_at_cout("\r\nVCON\r\n", info);
377 p--; 364 }
378 break; 365 /* Fall through */
366 case 'q':
367 case 's':
368 /* Silence */
369 if (len > 1)
370 memmove(p, p + 1, len - 1);
371 p--;
372 break;
379 } 373 }
380 } else { 374 } else {
381 if (*p == DLE) 375 if (*p == DLE)
@@ -422,7 +416,7 @@ static int voice_cf[7] =
422 * T.70 if necessary, and finally queues it up for sending via isdn_tty_tint. 416 * T.70 if necessary, and finally queues it up for sending via isdn_tty_tint.
423 */ 417 */
424static void 418static void
425isdn_tty_senddown(modem_info *info) 419isdn_tty_senddown(modem_info * info)
426{ 420{
427 int buflen; 421 int buflen;
428 int skb_res; 422 int skb_res;
@@ -446,9 +440,9 @@ isdn_tty_senddown(modem_info *info)
446#endif 440#endif
447 if (!(buflen = info->xmit_count)) 441 if (!(buflen = info->xmit_count))
448 return; 442 return;
449 if ((info->emu.mdmreg[REG_CTS] & BIT_CTS) != 0) 443 if ((info->emu.mdmreg[REG_CTS] & BIT_CTS) != 0)
450 info->msr &= ~UART_MSR_CTS; 444 info->msr &= ~UART_MSR_CTS;
451 info->lsr &= ~UART_LSR_TEMT; 445 info->lsr &= ~UART_LSR_TEMT;
452 /* info->xmit_count is modified here and in isdn_tty_write(). 446 /* info->xmit_count is modified here and in isdn_tty_write().
453 * So we return here if isdn_tty_write() is in the 447 * So we return here if isdn_tty_write() is in the
454 * critical section. 448 * critical section.
@@ -477,7 +471,7 @@ isdn_tty_senddown(modem_info *info)
477 return; 471 return;
478 } 472 }
479 skb_reserve(skb, skb_res); 473 skb_reserve(skb, skb_res);
480 memcpy(skb_put(skb, buflen), info->port.xmit_buf, buflen); 474 memcpy(skb_put(skb, buflen), info->xmit_buf, buflen);
481 info->xmit_count = 0; 475 info->xmit_count = 0;
482#ifdef CONFIG_ISDN_AUDIO 476#ifdef CONFIG_ISDN_AUDIO
483 if (info->vonline & 2) { 477 if (info->vonline & 2) {
@@ -491,32 +485,32 @@ isdn_tty_senddown(modem_info *info)
491 485
492 /* voice conversion/decompression */ 486 /* voice conversion/decompression */
493 switch (info->emu.vpar[3]) { 487 switch (info->emu.vpar[3]) {
494 case 2: 488 case 2:
495 case 3: 489 case 3:
496 case 4: 490 case 4:
497 /* adpcm, compatible to ZyXel 1496 modem 491 /* adpcm, compatible to ZyXel 1496 modem
498 * with ROM revision 6.01 492 * with ROM revision 6.01
499 */ 493 */
500 audio_len = isdn_audio_adpcm2xlaw(info->adpcms, 494 audio_len = isdn_audio_adpcm2xlaw(info->adpcms,
501 ifmt, 495 ifmt,
502 skb->data, 496 skb->data,
503 skb_put(skb, audio_len), 497 skb_put(skb, audio_len),
504 buflen); 498 buflen);
505 skb_pull(skb, buflen); 499 skb_pull(skb, buflen);
506 skb_trim(skb, audio_len); 500 skb_trim(skb, audio_len);
507 break; 501 break;
508 case 5: 502 case 5:
509 /* a-law */ 503 /* a-law */
510 if (!ifmt) 504 if (!ifmt)
511 isdn_audio_alaw2ulaw(skb->data, 505 isdn_audio_alaw2ulaw(skb->data,
512 buflen); 506 buflen);
513 break; 507 break;
514 case 6: 508 case 6:
515 /* u-law */ 509 /* u-law */
516 if (ifmt) 510 if (ifmt)
517 isdn_audio_ulaw2alaw(skb->data, 511 isdn_audio_ulaw2alaw(skb->data,
518 buflen); 512 buflen);
519 break; 513 break;
520 } 514 }
521 } 515 }
522#endif /* CONFIG_ISDN_AUDIO */ 516#endif /* CONFIG_ISDN_AUDIO */
@@ -556,7 +550,7 @@ isdn_tty_modem_do_ncarrier(unsigned long data)
556 * low. 550 * low.
557 */ 551 */
558static void 552static void
559isdn_tty_modem_ncarrier(modem_info *info) 553isdn_tty_modem_ncarrier(modem_info * info)
560{ 554{
561 if (info->ncarrier) { 555 if (info->ncarrier) {
562 info->nc_timer.expires = jiffies + HZ; 556 info->nc_timer.expires = jiffies + HZ;
@@ -574,30 +568,30 @@ isdn_calc_usage(int si, int l2)
574 568
575#ifdef CONFIG_ISDN_AUDIO 569#ifdef CONFIG_ISDN_AUDIO
576 if (si == 1) { 570 if (si == 1) {
577 switch (l2) { 571 switch(l2) {
578 case ISDN_PROTO_L2_MODEM: 572 case ISDN_PROTO_L2_MODEM:
579 usg = ISDN_USAGE_MODEM; 573 usg = ISDN_USAGE_MODEM;
580 break; 574 break;
581#ifdef CONFIG_ISDN_TTY_FAX 575#ifdef CONFIG_ISDN_TTY_FAX
582 case ISDN_PROTO_L2_FAX: 576 case ISDN_PROTO_L2_FAX:
583 usg = ISDN_USAGE_FAX; 577 usg = ISDN_USAGE_FAX;
584 break; 578 break;
585#endif 579#endif
586 case ISDN_PROTO_L2_TRANS: 580 case ISDN_PROTO_L2_TRANS:
587 default: 581 default:
588 usg = ISDN_USAGE_VOICE; 582 usg = ISDN_USAGE_VOICE;
589 break; 583 break;
590 } 584 }
591 } 585 }
592#endif 586#endif
593 return (usg); 587 return(usg);
594} 588}
595 589
596/* isdn_tty_dial() performs dialing of a tty an the necessary 590/* isdn_tty_dial() performs dialing of a tty an the necessary
597 * setup of the lower levels before that. 591 * setup of the lower levels before that.
598 */ 592 */
599static void 593static void
600isdn_tty_dial(char *n, modem_info *info, atemu *m) 594isdn_tty_dial(char *n, modem_info * info, atemu * m)
601{ 595{
602 int usg = ISDN_USAGE_MODEM; 596 int usg = ISDN_USAGE_MODEM;
603 int si = 7; 597 int si = 7;
@@ -614,10 +608,10 @@ isdn_tty_dial(char *n, modem_info *info, atemu *m)
614 } 608 }
615 usg = isdn_calc_usage(si, l2); 609 usg = isdn_calc_usage(si, l2);
616#ifdef CONFIG_ISDN_AUDIO 610#ifdef CONFIG_ISDN_AUDIO
617 if ((si == 1) && 611 if ((si == 1) &&
618 (l2 != ISDN_PROTO_L2_MODEM) 612 (l2 != ISDN_PROTO_L2_MODEM)
619#ifdef CONFIG_ISDN_TTY_FAX 613#ifdef CONFIG_ISDN_TTY_FAX
620 && (l2 != ISDN_PROTO_L2_FAX) 614 && (l2 != ISDN_PROTO_L2_FAX)
621#endif 615#endif
622 ) { 616 ) {
623 l2 = ISDN_PROTO_L2_TRANS; 617 l2 = ISDN_PROTO_L2_TRANS;
@@ -685,7 +679,7 @@ isdn_tty_dial(char *n, modem_info *info, atemu *m)
685 * and some cleanup is done also. 679 * and some cleanup is done also.
686 */ 680 */
687void 681void
688isdn_tty_modem_hup(modem_info *info, int local) 682isdn_tty_modem_hup(modem_info * info, int local)
689{ 683{
690 isdn_ctrl cmd; 684 isdn_ctrl cmd;
691 int di, ch; 685 int di, ch;
@@ -705,7 +699,7 @@ isdn_tty_modem_hup(modem_info *info, int local)
705 printk(KERN_DEBUG "Mhup ttyI%d\n", info->line); 699 printk(KERN_DEBUG "Mhup ttyI%d\n", info->line);
706#endif 700#endif
707 info->rcvsched = 0; 701 info->rcvsched = 0;
708 isdn_tty_flush_buffer(info->port.tty); 702 isdn_tty_flush_buffer(info->tty);
709 if (info->online) { 703 if (info->online) {
710 info->last_lhup = local; 704 info->last_lhup = local;
711 info->online = 0; 705 info->online = 0;
@@ -729,7 +723,7 @@ isdn_tty_modem_hup(modem_info *info, int local)
729 info->adpcmr = NULL; 723 info->adpcmr = NULL;
730#endif 724#endif
731 if ((info->msr & UART_MSR_RI) && 725 if ((info->msr & UART_MSR_RI) &&
732 (info->emu.mdmreg[REG_RUNG] & BIT_RUNG)) 726 (info->emu.mdmreg[REG_RUNG] & BIT_RUNG))
733 isdn_tty_modem_result(RESULT_RUNG, info); 727 isdn_tty_modem_result(RESULT_RUNG, info);
734 info->msr &= ~(UART_MSR_DCD | UART_MSR_RI); 728 info->msr &= ~(UART_MSR_DCD | UART_MSR_RI);
735 info->lsr |= UART_LSR_TEMT; 729 info->lsr |= UART_LSR_TEMT;
@@ -752,24 +746,23 @@ isdn_tty_modem_hup(modem_info *info, int local)
752} 746}
753 747
754/* 748/*
755 * Begin of a CAPI like interface, currently used only for 749 * Begin of a CAPI like interface, currently used only for
756 * supplementary service (CAPI 2.0 part III) 750 * supplementary service (CAPI 2.0 part III)
757 */ 751 */
758#include <linux/isdn/capicmd.h> 752#include <linux/isdn/capicmd.h>
759#include <linux/module.h>
760 753
761int 754int
762isdn_tty_capi_facility(capi_msg *cm) { 755isdn_tty_capi_facility(capi_msg *cm) {
763 return (-1); /* dummy */ 756 return(-1); /* dummy */
764} 757}
765 758
766/* isdn_tty_suspend() tries to suspend the current tty connection 759/* isdn_tty_suspend() tries to suspend the current tty connection
767 */ 760 */
768static void 761static void
769isdn_tty_suspend(char *id, modem_info *info, atemu *m) 762isdn_tty_suspend(char *id, modem_info * info, atemu * m)
770{ 763{
771 isdn_ctrl cmd; 764 isdn_ctrl cmd;
772 765
773 int l; 766 int l;
774 767
775 if (!info) 768 if (!info)
@@ -780,7 +773,7 @@ isdn_tty_suspend(char *id, modem_info *info, atemu *m)
780#endif 773#endif
781 l = strlen(id); 774 l = strlen(id);
782 if ((info->isdn_driver >= 0)) { 775 if ((info->isdn_driver >= 0)) {
783 cmd.parm.cmsg.Length = l + 18; 776 cmd.parm.cmsg.Length = l+18;
784 cmd.parm.cmsg.Command = CAPI_FACILITY; 777 cmd.parm.cmsg.Command = CAPI_FACILITY;
785 cmd.parm.cmsg.Subcommand = CAPI_REQ; 778 cmd.parm.cmsg.Subcommand = CAPI_REQ;
786 cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; 779 cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1;
@@ -806,7 +799,7 @@ isdn_tty_suspend(char *id, modem_info *info, atemu *m)
806 */ 799 */
807 800
808static void 801static void
809isdn_tty_resume(char *id, modem_info *info, atemu *m) 802isdn_tty_resume(char *id, modem_info * info, atemu * m)
810{ 803{
811 int usg = ISDN_USAGE_MODEM; 804 int usg = ISDN_USAGE_MODEM;
812 int si = 7; 805 int si = 7;
@@ -825,10 +818,10 @@ isdn_tty_resume(char *id, modem_info *info, atemu *m)
825 } 818 }
826 usg = isdn_calc_usage(si, l2); 819 usg = isdn_calc_usage(si, l2);
827#ifdef CONFIG_ISDN_AUDIO 820#ifdef CONFIG_ISDN_AUDIO
828 if ((si == 1) && 821 if ((si == 1) &&
829 (l2 != ISDN_PROTO_L2_MODEM) 822 (l2 != ISDN_PROTO_L2_MODEM)
830#ifdef CONFIG_ISDN_TTY_FAX 823#ifdef CONFIG_ISDN_TTY_FAX
831 && (l2 != ISDN_PROTO_L2_FAX) 824 && (l2 != ISDN_PROTO_L2_FAX)
832#endif 825#endif
833 ) { 826 ) {
834 l2 = ISDN_PROTO_L2_TRANS; 827 l2 = ISDN_PROTO_L2_TRANS;
@@ -870,18 +863,18 @@ isdn_tty_resume(char *id, modem_info *info, atemu *m)
870 isdn_command(&cmd); 863 isdn_command(&cmd);
871 cmd.driver = info->isdn_driver; 864 cmd.driver = info->isdn_driver;
872 cmd.arg = info->isdn_channel; 865 cmd.arg = info->isdn_channel;
873 cmd.parm.cmsg.Length = l + 18; 866 cmd.parm.cmsg.Length = l+18;
874 cmd.parm.cmsg.Command = CAPI_FACILITY; 867 cmd.parm.cmsg.Command = CAPI_FACILITY;
875 cmd.parm.cmsg.Subcommand = CAPI_REQ; 868 cmd.parm.cmsg.Subcommand = CAPI_REQ;
876 cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; 869 cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1;
877 cmd.parm.cmsg.para[0] = 3; /* 16 bit 0x0003 suplementary service */ 870 cmd.parm.cmsg.para[0] = 3; /* 16 bit 0x0003 suplementary service */
878 cmd.parm.cmsg.para[1] = 0; 871 cmd.parm.cmsg.para[1] = 0;
879 cmd.parm.cmsg.para[2] = l + 3; 872 cmd.parm.cmsg.para[2] = l+3;
880 cmd.parm.cmsg.para[3] = 5; /* 16 bit 0x0005 Resume */ 873 cmd.parm.cmsg.para[3] = 5; /* 16 bit 0x0005 Resume */
881 cmd.parm.cmsg.para[4] = 0; 874 cmd.parm.cmsg.para[4] = 0;
882 cmd.parm.cmsg.para[5] = l; 875 cmd.parm.cmsg.para[5] = l;
883 strncpy(&cmd.parm.cmsg.para[6], id, l); 876 strncpy(&cmd.parm.cmsg.para[6], id, l);
884 cmd.command = CAPI_PUT_MESSAGE; 877 cmd.command =CAPI_PUT_MESSAGE;
885 info->dialing = 1; 878 info->dialing = 1;
886// strcpy(dev->num[i], n); 879// strcpy(dev->num[i], n);
887 isdn_info_update(); 880 isdn_info_update();
@@ -895,7 +888,7 @@ isdn_tty_resume(char *id, modem_info *info, atemu *m)
895 */ 888 */
896 889
897static void 890static void
898isdn_tty_send_msg(modem_info *info, atemu *m, char *msg) 891isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
899{ 892{
900 int usg = ISDN_USAGE_MODEM; 893 int usg = ISDN_USAGE_MODEM;
901 int si = 7; 894 int si = 7;
@@ -918,10 +911,10 @@ isdn_tty_send_msg(modem_info *info, atemu *m, char *msg)
918 } 911 }
919 usg = isdn_calc_usage(si, l2); 912 usg = isdn_calc_usage(si, l2);
920#ifdef CONFIG_ISDN_AUDIO 913#ifdef CONFIG_ISDN_AUDIO
921 if ((si == 1) && 914 if ((si == 1) &&
922 (l2 != ISDN_PROTO_L2_MODEM) 915 (l2 != ISDN_PROTO_L2_MODEM)
923#ifdef CONFIG_ISDN_TTY_FAX 916#ifdef CONFIG_ISDN_TTY_FAX
924 && (l2 != ISDN_PROTO_L2_FAX) 917 && (l2 != ISDN_PROTO_L2_FAX)
925#endif 918#endif
926 ) { 919 ) {
927 l2 = ISDN_PROTO_L2_TRANS; 920 l2 = ISDN_PROTO_L2_TRANS;
@@ -962,14 +955,14 @@ isdn_tty_send_msg(modem_info *info, atemu *m, char *msg)
962 isdn_command(&cmd); 955 isdn_command(&cmd);
963 cmd.driver = info->isdn_driver; 956 cmd.driver = info->isdn_driver;
964 cmd.arg = info->isdn_channel; 957 cmd.arg = info->isdn_channel;
965 cmd.parm.cmsg.Length = l + 14; 958 cmd.parm.cmsg.Length = l+14;
966 cmd.parm.cmsg.Command = CAPI_MANUFACTURER; 959 cmd.parm.cmsg.Command = CAPI_MANUFACTURER;
967 cmd.parm.cmsg.Subcommand = CAPI_REQ; 960 cmd.parm.cmsg.Subcommand = CAPI_REQ;
968 cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; 961 cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1;
969 cmd.parm.cmsg.para[0] = l + 1; 962 cmd.parm.cmsg.para[0] = l+1;
970 strncpy(&cmd.parm.cmsg.para[1], msg, l); 963 strncpy(&cmd.parm.cmsg.para[1], msg, l);
971 cmd.parm.cmsg.para[l + 1] = 0xd; 964 cmd.parm.cmsg.para[l+1] = 0xd;
972 cmd.command = CAPI_PUT_MESSAGE; 965 cmd.command =CAPI_PUT_MESSAGE;
973/* info->dialing = 1; 966/* info->dialing = 1;
974 strcpy(dev->num[i], n); 967 strcpy(dev->num[i], n);
975 isdn_info_update(); 968 isdn_info_update();
@@ -984,7 +977,7 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine)
984#ifdef MODEM_PARANOIA_CHECK 977#ifdef MODEM_PARANOIA_CHECK
985 if (!info) { 978 if (!info) {
986 printk(KERN_WARNING "isdn_tty: null info_struct for %s in %s\n", 979 printk(KERN_WARNING "isdn_tty: null info_struct for %s in %s\n",
987 name, routine); 980 name, routine);
988 return 1; 981 return 1;
989 } 982 }
990 if (info->magic != ISDN_ASYNC_MAGIC) { 983 if (info->magic != ISDN_ASYNC_MAGIC) {
@@ -1001,23 +994,22 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine)
1001 * the specified baud rate for a serial port. 994 * the specified baud rate for a serial port.
1002 */ 995 */
1003static void 996static void
1004isdn_tty_change_speed(modem_info *info) 997isdn_tty_change_speed(modem_info * info)
1005{ 998{
1006 struct tty_port *port = &info->port;
1007 uint cflag, 999 uint cflag,
1008 cval, 1000 cval,
1009 quot; 1001 quot;
1010 int i; 1002 int i;
1011 1003
1012 if (!port->tty) 1004 if (!info->tty || !info->tty->termios)
1013 return; 1005 return;
1014 cflag = port->tty->termios.c_cflag; 1006 cflag = info->tty->termios->c_cflag;
1015 1007
1016 quot = i = cflag & CBAUD; 1008 quot = i = cflag & CBAUD;
1017 if (i & CBAUDEX) { 1009 if (i & CBAUDEX) {
1018 i &= ~CBAUDEX; 1010 i &= ~CBAUDEX;
1019 if (i < 1 || i > 2) 1011 if (i < 1 || i > 2)
1020 port->tty->termios.c_cflag &= ~CBAUDEX; 1012 info->tty->termios->c_cflag &= ~CBAUDEX;
1021 else 1013 else
1022 i += 15; 1014 i += 15;
1023 } 1015 }
@@ -1047,20 +1039,20 @@ isdn_tty_change_speed(modem_info *info)
1047 1039
1048 /* CTS flow control flag and modem status interrupts */ 1040 /* CTS flow control flag and modem status interrupts */
1049 if (cflag & CRTSCTS) { 1041 if (cflag & CRTSCTS) {
1050 port->flags |= ASYNC_CTS_FLOW; 1042 info->flags |= ISDN_ASYNC_CTS_FLOW;
1051 } else 1043 } else
1052 port->flags &= ~ASYNC_CTS_FLOW; 1044 info->flags &= ~ISDN_ASYNC_CTS_FLOW;
1053 if (cflag & CLOCAL) 1045 if (cflag & CLOCAL)
1054 port->flags &= ~ASYNC_CHECK_CD; 1046 info->flags &= ~ISDN_ASYNC_CHECK_CD;
1055 else { 1047 else {
1056 port->flags |= ASYNC_CHECK_CD; 1048 info->flags |= ISDN_ASYNC_CHECK_CD;
1057 } 1049 }
1058} 1050}
1059 1051
1060static int 1052static int
1061isdn_tty_startup(modem_info *info) 1053isdn_tty_startup(modem_info * info)
1062{ 1054{
1063 if (info->port.flags & ASYNC_INITIALIZED) 1055 if (info->flags & ISDN_ASYNC_INITIALIZED)
1064 return 0; 1056 return 0;
1065 isdn_lock_drivers(); 1057 isdn_lock_drivers();
1066#ifdef ISDN_DEBUG_MODEM_OPEN 1058#ifdef ISDN_DEBUG_MODEM_OPEN
@@ -1070,14 +1062,14 @@ isdn_tty_startup(modem_info *info)
1070 * Now, initialize the UART 1062 * Now, initialize the UART
1071 */ 1063 */
1072 info->mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; 1064 info->mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
1073 if (info->port.tty) 1065 if (info->tty)
1074 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); 1066 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1075 /* 1067 /*
1076 * and set the speed of the serial port 1068 * and set the speed of the serial port
1077 */ 1069 */
1078 isdn_tty_change_speed(info); 1070 isdn_tty_change_speed(info);
1079 1071
1080 info->port.flags |= ASYNC_INITIALIZED; 1072 info->flags |= ISDN_ASYNC_INITIALIZED;
1081 info->msr |= (UART_MSR_DSR | UART_MSR_CTS); 1073 info->msr |= (UART_MSR_DSR | UART_MSR_CTS);
1082 info->send_outstanding = 0; 1074 info->send_outstanding = 0;
1083 return 0; 1075 return 0;
@@ -1088,16 +1080,16 @@ isdn_tty_startup(modem_info *info)
1088 * DTR is dropped if the hangup on close termio flag is on. 1080 * DTR is dropped if the hangup on close termio flag is on.
1089 */ 1081 */
1090static void 1082static void
1091isdn_tty_shutdown(modem_info *info) 1083isdn_tty_shutdown(modem_info * info)
1092{ 1084{
1093 if (!(info->port.flags & ASYNC_INITIALIZED)) 1085 if (!(info->flags & ISDN_ASYNC_INITIALIZED))
1094 return; 1086 return;
1095#ifdef ISDN_DEBUG_MODEM_OPEN 1087#ifdef ISDN_DEBUG_MODEM_OPEN
1096 printk(KERN_DEBUG "Shutting down isdnmodem port %d ....\n", info->line); 1088 printk(KERN_DEBUG "Shutting down isdnmodem port %d ....\n", info->line);
1097#endif 1089#endif
1098 isdn_unlock_drivers(); 1090 isdn_unlock_drivers();
1099 info->msr &= ~UART_MSR_RI; 1091 info->msr &= ~UART_MSR_RI;
1100 if (!info->port.tty || (info->port.tty->termios.c_cflag & HUPCL)) { 1092 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
1101 info->mcr &= ~(UART_MCR_DTR | UART_MCR_RTS); 1093 info->mcr &= ~(UART_MCR_DTR | UART_MCR_RTS);
1102 if (info->emu.mdmreg[REG_DTRHUP] & BIT_DTRHUP) { 1094 if (info->emu.mdmreg[REG_DTRHUP] & BIT_DTRHUP) {
1103 isdn_tty_modem_reset_regs(info, 0); 1095 isdn_tty_modem_reset_regs(info, 0);
@@ -1107,10 +1099,10 @@ isdn_tty_shutdown(modem_info *info)
1107 isdn_tty_modem_hup(info, 1); 1099 isdn_tty_modem_hup(info, 1);
1108 } 1100 }
1109 } 1101 }
1110 if (info->port.tty) 1102 if (info->tty)
1111 set_bit(TTY_IO_ERROR, &info->port.tty->flags); 1103 set_bit(TTY_IO_ERROR, &info->tty->flags);
1112 1104
1113 info->port.flags &= ~ASYNC_INITIALIZED; 1105 info->flags &= ~ISDN_ASYNC_INITIALIZED;
1114} 1106}
1115 1107
1116/* isdn_tty_write() is the main send-routine. It is called from the upper 1108/* isdn_tty_write() is the main send-routine. It is called from the upper
@@ -1123,7 +1115,7 @@ isdn_tty_shutdown(modem_info *info)
1123 * - If dialing, abort dial. 1115 * - If dialing, abort dial.
1124 */ 1116 */
1125static int 1117static int
1126isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count) 1118isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count)
1127{ 1119{
1128 int c; 1120 int c;
1129 int total = 0; 1121 int total = 0;
@@ -1153,7 +1145,7 @@ isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count)
1153 isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c, 1145 isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c,
1154 &(m->pluscount), 1146 &(m->pluscount),
1155 &(m->lastplus)); 1147 &(m->lastplus));
1156 memcpy(&info->port.xmit_buf[info->xmit_count], buf, c); 1148 memcpy(&(info->xmit_buf[info->xmit_count]), buf, c);
1157#ifdef CONFIG_ISDN_AUDIO 1149#ifdef CONFIG_ISDN_AUDIO
1158 if (info->vonline) { 1150 if (info->vonline) {
1159 int cc = isdn_tty_handleDLEdown(info, m, c); 1151 int cc = isdn_tty_handleDLEdown(info, m, c);
@@ -1183,27 +1175,27 @@ isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count)
1183 } 1175 }
1184 } 1176 }
1185 } else 1177 } else
1186 if (TTY_IS_FCLASS1(info)) { 1178 if (TTY_IS_FCLASS1(info)) {
1187 int cc = isdn_tty_handleDLEdown(info, m, c); 1179 int cc = isdn_tty_handleDLEdown(info, m, c);
1188 1180
1189 if (info->vonline & 4) { /* ETX seen */ 1181 if (info->vonline & 4) { /* ETX seen */
1190 isdn_ctrl c; 1182 isdn_ctrl c;
1191 1183
1192 c.command = ISDN_CMD_FAXCMD; 1184 c.command = ISDN_CMD_FAXCMD;
1193 c.driver = info->isdn_driver; 1185 c.driver = info->isdn_driver;
1194 c.arg = info->isdn_channel; 1186 c.arg = info->isdn_channel;
1195 c.parm.aux.cmd = ISDN_FAX_CLASS1_CTRL; 1187 c.parm.aux.cmd = ISDN_FAX_CLASS1_CTRL;
1196 c.parm.aux.subcmd = ETX; 1188 c.parm.aux.subcmd = ETX;
1197 isdn_command(&c); 1189 isdn_command(&c);
1198 } 1190 }
1199 info->vonline = 0; 1191 info->vonline = 0;
1200#ifdef ISDN_DEBUG_MODEM_VOICE 1192#ifdef ISDN_DEBUG_MODEM_VOICE
1201 printk(KERN_DEBUG "fax dle cc/c %d/%d\n", cc, c); 1193 printk(KERN_DEBUG "fax dle cc/c %d/%d\n", cc, c);
1202#endif 1194#endif
1203 info->xmit_count += cc; 1195 info->xmit_count += cc;
1204 } else 1196 } else
1205#endif 1197#endif
1206 info->xmit_count += c; 1198 info->xmit_count += c;
1207 } else { 1199 } else {
1208 info->msr |= UART_MSR_CTS; 1200 info->msr |= UART_MSR_CTS;
1209 info->lsr |= UART_LSR_TEMT; 1201 info->lsr |= UART_LSR_TEMT;
@@ -1339,7 +1331,7 @@ isdn_tty_unthrottle(struct tty_struct *tty)
1339 * allows RS485 driver to be written in user space. 1331 * allows RS485 driver to be written in user space.
1340 */ 1332 */
1341static int 1333static int
1342isdn_tty_get_lsr_info(modem_info *info, uint __user *value) 1334isdn_tty_get_lsr_info(modem_info * info, uint __user * value)
1343{ 1335{
1344 u_char status; 1336 u_char status;
1345 uint result; 1337 uint result;
@@ -1370,16 +1362,16 @@ isdn_tty_tiocmget(struct tty_struct *tty)
1370 status = info->msr; 1362 status = info->msr;
1371 mutex_unlock(&modem_info_mutex); 1363 mutex_unlock(&modem_info_mutex);
1372 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) 1364 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
1373 | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) 1365 | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
1374 | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) 1366 | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
1375 | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) 1367 | ((status & UART_MSR_RI) ? TIOCM_RNG : 0)
1376 | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) 1368 | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0)
1377 | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); 1369 | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
1378} 1370}
1379 1371
1380static int 1372static int
1381isdn_tty_tiocmset(struct tty_struct *tty, 1373isdn_tty_tiocmset(struct tty_struct *tty,
1382 unsigned int set, unsigned int clear) 1374 unsigned int set, unsigned int clear)
1383{ 1375{
1384 modem_info *info = (modem_info *) tty->driver_data; 1376 modem_info *info = (modem_info *) tty->driver_data;
1385 1377
@@ -1429,34 +1421,34 @@ isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg)
1429 if (tty->flags & (1 << TTY_IO_ERROR)) 1421 if (tty->flags & (1 << TTY_IO_ERROR))
1430 return -EIO; 1422 return -EIO;
1431 switch (cmd) { 1423 switch (cmd) {
1432 case TCSBRK: /* SVID version: non-zero arg --> no break */ 1424 case TCSBRK: /* SVID version: non-zero arg --> no break */
1433#ifdef ISDN_DEBUG_MODEM_IOCTL 1425#ifdef ISDN_DEBUG_MODEM_IOCTL
1434 printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line); 1426 printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line);
1435#endif 1427#endif
1436 retval = tty_check_change(tty); 1428 retval = tty_check_change(tty);
1437 if (retval) 1429 if (retval)
1438 return retval; 1430 return retval;
1439 tty_wait_until_sent(tty, 0); 1431 tty_wait_until_sent(tty, 0);
1440 return 0; 1432 return 0;
1441 case TCSBRKP: /* support for POSIX tcsendbreak() */ 1433 case TCSBRKP: /* support for POSIX tcsendbreak() */
1442#ifdef ISDN_DEBUG_MODEM_IOCTL 1434#ifdef ISDN_DEBUG_MODEM_IOCTL
1443 printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line); 1435 printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line);
1444#endif 1436#endif
1445 retval = tty_check_change(tty); 1437 retval = tty_check_change(tty);
1446 if (retval) 1438 if (retval)
1447 return retval; 1439 return retval;
1448 tty_wait_until_sent(tty, 0); 1440 tty_wait_until_sent(tty, 0);
1449 return 0; 1441 return 0;
1450 case TIOCSERGETLSR: /* Get line status register */ 1442 case TIOCSERGETLSR: /* Get line status register */
1451#ifdef ISDN_DEBUG_MODEM_IOCTL 1443#ifdef ISDN_DEBUG_MODEM_IOCTL
1452 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); 1444 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line);
1453#endif 1445#endif
1454 return isdn_tty_get_lsr_info(info, (uint __user *) arg); 1446 return isdn_tty_get_lsr_info(info, (uint __user *) arg);
1455 default: 1447 default:
1456#ifdef ISDN_DEBUG_MODEM_IOCTL 1448#ifdef ISDN_DEBUG_MODEM_IOCTL
1457 printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line); 1449 printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line);
1458#endif 1450#endif
1459 return -ENOIOCTLCMD; 1451 return -ENOIOCTLCMD;
1460 } 1452 }
1461 return 0; 1453 return 0;
1462} 1454}
@@ -1469,13 +1461,13 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1469 if (!old_termios) 1461 if (!old_termios)
1470 isdn_tty_change_speed(info); 1462 isdn_tty_change_speed(info);
1471 else { 1463 else {
1472 if (tty->termios.c_cflag == old_termios->c_cflag && 1464 if (tty->termios->c_cflag == old_termios->c_cflag &&
1473 tty->termios.c_ispeed == old_termios->c_ispeed && 1465 tty->termios->c_ispeed == old_termios->c_ispeed &&
1474 tty->termios.c_ospeed == old_termios->c_ospeed) 1466 tty->termios->c_ospeed == old_termios->c_ospeed)
1475 return; 1467 return;
1476 isdn_tty_change_speed(info); 1468 isdn_tty_change_speed(info);
1477 if ((old_termios->c_cflag & CRTSCTS) && 1469 if ((old_termios->c_cflag & CRTSCTS) &&
1478 !(tty->termios.c_cflag & CRTSCTS)) 1470 !(tty->termios->c_cflag & CRTSCTS))
1479 tty->hw_stopped = 0; 1471 tty->hw_stopped = 0;
1480 } 1472 }
1481} 1473}
@@ -1485,17 +1477,106 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1485 * isdn_tty_open() and friends 1477 * isdn_tty_open() and friends
1486 * ------------------------------------------------------------ 1478 * ------------------------------------------------------------
1487 */ 1479 */
1488 1480static int
1489static int isdn_tty_install(struct tty_driver *driver, struct tty_struct *tty) 1481isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * info)
1490{ 1482{
1491 modem_info *info = &dev->mdm.info[tty->index]; 1483 DECLARE_WAITQUEUE(wait, NULL);
1492 1484 int do_clocal = 0;
1493 if (isdn_tty_paranoia_check(info, tty->name, __func__)) 1485 int retval;
1494 return -ENODEV;
1495
1496 tty->driver_data = info;
1497 1486
1498 return tty_port_install(&info->port, driver, tty); 1487 /*
1488 * If the device is in the middle of being closed, then block
1489 * until it's done, and then try again.
1490 */
1491 if (tty_hung_up_p(filp) ||
1492 (info->flags & ISDN_ASYNC_CLOSING)) {
1493 if (info->flags & ISDN_ASYNC_CLOSING)
1494 interruptible_sleep_on(&info->close_wait);
1495#ifdef MODEM_DO_RESTART
1496 if (info->flags & ISDN_ASYNC_HUP_NOTIFY)
1497 return -EAGAIN;
1498 else
1499 return -ERESTARTSYS;
1500#else
1501 return -EAGAIN;
1502#endif
1503 }
1504 /*
1505 * If non-blocking mode is set, then make the check up front
1506 * and then exit.
1507 */
1508 if ((filp->f_flags & O_NONBLOCK) ||
1509 (tty->flags & (1 << TTY_IO_ERROR))) {
1510 if (info->flags & ISDN_ASYNC_CALLOUT_ACTIVE)
1511 return -EBUSY;
1512 info->flags |= ISDN_ASYNC_NORMAL_ACTIVE;
1513 return 0;
1514 }
1515 if (info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) {
1516 if (info->normal_termios.c_cflag & CLOCAL)
1517 do_clocal = 1;
1518 } else {
1519 if (tty->termios->c_cflag & CLOCAL)
1520 do_clocal = 1;
1521 }
1522 /*
1523 * Block waiting for the carrier detect and the line to become
1524 * free (i.e., not in use by the callout). While we are in
1525 * this loop, info->count is dropped by one, so that
1526 * isdn_tty_close() knows when to free things. We restore it upon
1527 * exit, either normal or abnormal.
1528 */
1529 retval = 0;
1530 add_wait_queue(&info->open_wait, &wait);
1531#ifdef ISDN_DEBUG_MODEM_OPEN
1532 printk(KERN_DEBUG "isdn_tty_block_til_ready before block: ttyi%d, count = %d\n",
1533 info->line, info->count);
1534#endif
1535 if (!(tty_hung_up_p(filp)))
1536 info->count--;
1537 info->blocked_open++;
1538 while (1) {
1539 set_current_state(TASK_INTERRUPTIBLE);
1540 if (tty_hung_up_p(filp) ||
1541 !(info->flags & ISDN_ASYNC_INITIALIZED)) {
1542#ifdef MODEM_DO_RESTART
1543 if (info->flags & ISDN_ASYNC_HUP_NOTIFY)
1544 retval = -EAGAIN;
1545 else
1546 retval = -ERESTARTSYS;
1547#else
1548 retval = -EAGAIN;
1549#endif
1550 break;
1551 }
1552 if (!(info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) &&
1553 !(info->flags & ISDN_ASYNC_CLOSING) &&
1554 (do_clocal || (info->msr & UART_MSR_DCD))) {
1555 break;
1556 }
1557 if (signal_pending(current)) {
1558 retval = -ERESTARTSYS;
1559 break;
1560 }
1561#ifdef ISDN_DEBUG_MODEM_OPEN
1562 printk(KERN_DEBUG "isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n",
1563 info->line, info->count);
1564#endif
1565 schedule();
1566 }
1567 current->state = TASK_RUNNING;
1568 remove_wait_queue(&info->open_wait, &wait);
1569 if (!tty_hung_up_p(filp))
1570 info->count++;
1571 info->blocked_open--;
1572#ifdef ISDN_DEBUG_MODEM_OPEN
1573 printk(KERN_DEBUG "isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n",
1574 info->line, info->count);
1575#endif
1576 if (retval)
1577 return retval;
1578 info->flags |= ISDN_ASYNC_NORMAL_ACTIVE;
1579 return 0;
1499} 1580}
1500 1581
1501/* 1582/*
@@ -1507,16 +1588,26 @@ static int isdn_tty_install(struct tty_driver *driver, struct tty_struct *tty)
1507static int 1588static int
1508isdn_tty_open(struct tty_struct *tty, struct file *filp) 1589isdn_tty_open(struct tty_struct *tty, struct file *filp)
1509{ 1590{
1510 modem_info *info = tty->driver_data; 1591 modem_info *info;
1511 struct tty_port *port = &info->port; 1592 int retval, line;
1512 int retval;
1513 1593
1594 line = tty->index;
1595 if (line < 0 || line >= ISDN_MAX_CHANNELS)
1596 return -ENODEV;
1597 info = &dev->mdm.info[line];
1598 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open"))
1599 return -ENODEV;
1600 if (!try_module_get(info->owner)) {
1601 printk(KERN_WARNING "%s: cannot reserve module\n", __func__);
1602 return -ENODEV;
1603 }
1514#ifdef ISDN_DEBUG_MODEM_OPEN 1604#ifdef ISDN_DEBUG_MODEM_OPEN
1515 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, 1605 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
1516 port->count); 1606 info->count);
1517#endif 1607#endif
1518 port->count++; 1608 info->count++;
1519 port->tty = tty; 1609 tty->driver_data = info;
1610 info->tty = tty;
1520 /* 1611 /*
1521 * Start up serial port 1612 * Start up serial port
1522 */ 1613 */
@@ -1525,13 +1616,15 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
1525#ifdef ISDN_DEBUG_MODEM_OPEN 1616#ifdef ISDN_DEBUG_MODEM_OPEN
1526 printk(KERN_DEBUG "isdn_tty_open return after startup\n"); 1617 printk(KERN_DEBUG "isdn_tty_open return after startup\n");
1527#endif 1618#endif
1619 module_put(info->owner);
1528 return retval; 1620 return retval;
1529 } 1621 }
1530 retval = tty_port_block_til_ready(port, tty, filp); 1622 retval = isdn_tty_block_til_ready(tty, filp, info);
1531 if (retval) { 1623 if (retval) {
1532#ifdef ISDN_DEBUG_MODEM_OPEN 1624#ifdef ISDN_DEBUG_MODEM_OPEN
1533 printk(KERN_DEBUG "isdn_tty_open return after isdn_tty_block_til_ready \n"); 1625 printk(KERN_DEBUG "isdn_tty_open return after isdn_tty_block_til_ready \n");
1534#endif 1626#endif
1627 module_put(info->owner);
1535 return retval; 1628 return retval;
1536 } 1629 }
1537#ifdef ISDN_DEBUG_MODEM_OPEN 1630#ifdef ISDN_DEBUG_MODEM_OPEN
@@ -1548,7 +1641,6 @@ static void
1548isdn_tty_close(struct tty_struct *tty, struct file *filp) 1641isdn_tty_close(struct tty_struct *tty, struct file *filp)
1549{ 1642{
1550 modem_info *info = (modem_info *) tty->driver_data; 1643 modem_info *info = (modem_info *) tty->driver_data;
1551 struct tty_port *port = &info->port;
1552 ulong timeout; 1644 ulong timeout;
1553 1645
1554 if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) 1646 if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close"))
@@ -1559,7 +1651,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1559#endif 1651#endif
1560 return; 1652 return;
1561 } 1653 }
1562 if ((tty->count == 1) && (port->count != 1)) { 1654 if ((tty->count == 1) && (info->count != 1)) {
1563 /* 1655 /*
1564 * Uh, oh. tty->count is 1, which means that the tty 1656 * Uh, oh. tty->count is 1, which means that the tty
1565 * structure will be freed. Info->count should always 1657 * structure will be freed. Info->count should always
@@ -1568,21 +1660,30 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1568 * serial port won't be shutdown. 1660 * serial port won't be shutdown.
1569 */ 1661 */
1570 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " 1662 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
1571 "info->count is %d\n", port->count); 1663 "info->count is %d\n", info->count);
1572 port->count = 1; 1664 info->count = 1;
1573 } 1665 }
1574 if (--port->count < 0) { 1666 if (--info->count < 0) {
1575 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n", 1667 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
1576 info->line, port->count); 1668 info->line, info->count);
1577 port->count = 0; 1669 info->count = 0;
1578 } 1670 }
1579 if (port->count) { 1671 if (info->count) {
1580#ifdef ISDN_DEBUG_MODEM_OPEN 1672#ifdef ISDN_DEBUG_MODEM_OPEN
1581 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); 1673 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
1582#endif 1674#endif
1675 module_put(info->owner);
1583 return; 1676 return;
1584 } 1677 }
1585 port->flags |= ASYNC_CLOSING; 1678 info->flags |= ISDN_ASYNC_CLOSING;
1679 /*
1680 * Save the termios structure, since this port may have
1681 * separate termios for callout and dialin.
1682 */
1683 if (info->flags & ISDN_ASYNC_NORMAL_ACTIVE)
1684 info->normal_termios = *tty->termios;
1685 if (info->flags & ISDN_ASYNC_CALLOUT_ACTIVE)
1686 info->callout_termios = *tty->termios;
1586 1687
1587 tty->closing = 1; 1688 tty->closing = 1;
1588 /* 1689 /*
@@ -1591,8 +1692,8 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1591 * interrupt driver to stop checking the data ready bit in the 1692 * interrupt driver to stop checking the data ready bit in the
1592 * line status register. 1693 * line status register.
1593 */ 1694 */
1594 if (port->flags & ASYNC_INITIALIZED) { 1695 if (info->flags & ISDN_ASYNC_INITIALIZED) {
1595 tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ 1696 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
1596 /* 1697 /*
1597 * Before we drop DTR, make sure the UART transmitter 1698 * Before we drop DTR, make sure the UART transmitter
1598 * has completely drained; this is especially 1699 * has completely drained; this is especially
@@ -1601,7 +1702,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1601 timeout = jiffies + HZ; 1702 timeout = jiffies + HZ;
1602 while (!(info->lsr & UART_LSR_TEMT)) { 1703 while (!(info->lsr & UART_LSR_TEMT)) {
1603 schedule_timeout_interruptible(20); 1704 schedule_timeout_interruptible(20);
1604 if (time_after(jiffies, timeout)) 1705 if (time_after(jiffies,timeout))
1605 break; 1706 break;
1606 } 1707 }
1607 } 1708 }
@@ -1609,10 +1710,16 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1609 isdn_tty_shutdown(info); 1710 isdn_tty_shutdown(info);
1610 isdn_tty_flush_buffer(tty); 1711 isdn_tty_flush_buffer(tty);
1611 tty_ldisc_flush(tty); 1712 tty_ldisc_flush(tty);
1612 port->tty = NULL; 1713 info->tty = NULL;
1613 info->ncarrier = 0; 1714 info->ncarrier = 0;
1614 1715 tty->closing = 0;
1615 tty_port_close_end(port, tty); 1716 module_put(info->owner);
1717 if (info->blocked_open) {
1718 msleep_interruptible(500);
1719 wake_up_interruptible(&info->open_wait);
1720 }
1721 info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CLOSING);
1722 wake_up_interruptible(&info->close_wait);
1616#ifdef ISDN_DEBUG_MODEM_OPEN 1723#ifdef ISDN_DEBUG_MODEM_OPEN
1617 printk(KERN_DEBUG "isdn_tty_close normal exit\n"); 1724 printk(KERN_DEBUG "isdn_tty_close normal exit\n");
1618#endif 1725#endif
@@ -1625,21 +1732,20 @@ static void
1625isdn_tty_hangup(struct tty_struct *tty) 1732isdn_tty_hangup(struct tty_struct *tty)
1626{ 1733{
1627 modem_info *info = (modem_info *) tty->driver_data; 1734 modem_info *info = (modem_info *) tty->driver_data;
1628 struct tty_port *port = &info->port;
1629 1735
1630 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) 1736 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
1631 return; 1737 return;
1632 isdn_tty_shutdown(info); 1738 isdn_tty_shutdown(info);
1633 port->count = 0; 1739 info->count = 0;
1634 port->flags &= ~ASYNC_NORMAL_ACTIVE; 1740 info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE);
1635 port->tty = NULL; 1741 info->tty = NULL;
1636 wake_up_interruptible(&port->open_wait); 1742 wake_up_interruptible(&info->open_wait);
1637} 1743}
1638 1744
1639/* This routine initializes all emulator-data. 1745/* This routine initializes all emulator-data.
1640 */ 1746 */
1641static void 1747static void
1642isdn_tty_reset_profile(atemu *m) 1748isdn_tty_reset_profile(atemu * m)
1643{ 1749{
1644 m->profile[0] = 0; 1750 m->profile[0] = 0;
1645 m->profile[1] = 0; 1751 m->profile[1] = 0;
@@ -1669,7 +1775,7 @@ isdn_tty_reset_profile(atemu *m)
1669 1775
1670#ifdef CONFIG_ISDN_AUDIO 1776#ifdef CONFIG_ISDN_AUDIO
1671static void 1777static void
1672isdn_tty_modem_reset_vpar(atemu *m) 1778isdn_tty_modem_reset_vpar(atemu * m)
1673{ 1779{
1674 m->vpar[0] = 2; /* Voice-device (2 = phone line) */ 1780 m->vpar[0] = 2; /* Voice-device (2 = phone line) */
1675 m->vpar[1] = 0; /* Silence detection level (0 = none ) */ 1781 m->vpar[1] = 0; /* Silence detection level (0 = none ) */
@@ -1682,7 +1788,7 @@ isdn_tty_modem_reset_vpar(atemu *m)
1682 1788
1683#ifdef CONFIG_ISDN_TTY_FAX 1789#ifdef CONFIG_ISDN_TTY_FAX
1684static void 1790static void
1685isdn_tty_modem_reset_faxpar(modem_info *info) 1791isdn_tty_modem_reset_faxpar(modem_info * info)
1686{ 1792{
1687 T30_s *f = info->fax; 1793 T30_s *f = info->fax;
1688 1794
@@ -1715,7 +1821,7 @@ isdn_tty_modem_reset_faxpar(modem_info *info)
1715#endif 1821#endif
1716 1822
1717static void 1823static void
1718isdn_tty_modem_reset_regs(modem_info *info, int force) 1824isdn_tty_modem_reset_regs(modem_info * info, int force)
1719{ 1825{
1720 atemu *m = &info->emu; 1826 atemu *m = &info->emu;
1721 if ((m->mdmreg[REG_DTRR] & BIT_DTRR) || force) { 1827 if ((m->mdmreg[REG_DTRR] & BIT_DTRR) || force) {
@@ -1734,7 +1840,7 @@ isdn_tty_modem_reset_regs(modem_info *info, int force)
1734} 1840}
1735 1841
1736static void 1842static void
1737modem_write_profile(atemu *m) 1843modem_write_profile(atemu * m)
1738{ 1844{
1739 memcpy(m->profile, m->mdmreg, ISDN_MODEM_NUMREG); 1845 memcpy(m->profile, m->mdmreg, ISDN_MODEM_NUMREG);
1740 memcpy(m->pmsn, m->msn, ISDN_MSNLEN); 1846 memcpy(m->pmsn, m->msn, ISDN_MSNLEN);
@@ -1744,8 +1850,7 @@ modem_write_profile(atemu *m)
1744} 1850}
1745 1851
1746static const struct tty_operations modem_ops = { 1852static const struct tty_operations modem_ops = {
1747 .install = isdn_tty_install, 1853 .open = isdn_tty_open,
1748 .open = isdn_tty_open,
1749 .close = isdn_tty_close, 1854 .close = isdn_tty_close,
1750 .write = isdn_tty_write, 1855 .write = isdn_tty_write,
1751 .flush_chars = isdn_tty_flush_chars, 1856 .flush_chars = isdn_tty_flush_chars,
@@ -1761,16 +1866,6 @@ static const struct tty_operations modem_ops = {
1761 .tiocmset = isdn_tty_tiocmset, 1866 .tiocmset = isdn_tty_tiocmset,
1762}; 1867};
1763 1868
1764static int isdn_tty_carrier_raised(struct tty_port *port)
1765{
1766 modem_info *info = container_of(port, modem_info, port);
1767 return info->msr & UART_MSR_DCD;
1768}
1769
1770static const struct tty_port_operations isdn_tty_port_ops = {
1771 .carrier_raised = isdn_tty_carrier_raised,
1772};
1773
1774int 1869int
1775isdn_tty_modem_init(void) 1870isdn_tty_modem_init(void)
1776{ 1871{
@@ -1789,7 +1884,7 @@ isdn_tty_modem_init(void)
1789 m->tty_modem->subtype = SERIAL_TYPE_NORMAL; 1884 m->tty_modem->subtype = SERIAL_TYPE_NORMAL;
1790 m->tty_modem->init_termios = tty_std_termios; 1885 m->tty_modem->init_termios = tty_std_termios;
1791 m->tty_modem->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1886 m->tty_modem->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1792 m->tty_modem->flags = TTY_DRIVER_REAL_RAW; 1887 m->tty_modem->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1793 m->tty_modem->driver_name = "isdn_tty"; 1888 m->tty_modem->driver_name = "isdn_tty";
1794 tty_set_operations(m->tty_modem, &modem_ops); 1889 tty_set_operations(m->tty_modem, &modem_ops);
1795 retval = tty_register_driver(m->tty_modem); 1890 retval = tty_register_driver(m->tty_modem);
@@ -1806,8 +1901,9 @@ isdn_tty_modem_init(void)
1806 goto err_unregister; 1901 goto err_unregister;
1807 } 1902 }
1808#endif 1903#endif
1809 tty_port_init(&info->port); 1904#ifdef MODULE
1810 info->port.ops = &isdn_tty_port_ops; 1905 info->owner = THIS_MODULE;
1906#endif
1811 spin_lock_init(&info->readlock); 1907 spin_lock_init(&info->readlock);
1812 sprintf(info->last_cause, "0000"); 1908 sprintf(info->last_cause, "0000");
1813 sprintf(info->last_num, "none"); 1909 sprintf(info->last_num, "none");
@@ -1819,7 +1915,12 @@ isdn_tty_modem_init(void)
1819 isdn_tty_modem_reset_regs(info, 1); 1915 isdn_tty_modem_reset_regs(info, 1);
1820 info->magic = ISDN_ASYNC_MAGIC; 1916 info->magic = ISDN_ASYNC_MAGIC;
1821 info->line = i; 1917 info->line = i;
1918 info->tty = NULL;
1822 info->x_char = 0; 1919 info->x_char = 0;
1920 info->count = 0;
1921 info->blocked_open = 0;
1922 init_waitqueue_head(&info->open_wait);
1923 init_waitqueue_head(&info->close_wait);
1823 info->isdn_driver = -1; 1924 info->isdn_driver = -1;
1824 info->isdn_channel = -1; 1925 info->isdn_channel = -1;
1825 info->drv_index = -1; 1926 info->drv_index = -1;
@@ -1831,15 +1932,13 @@ isdn_tty_modem_init(void)
1831#ifdef CONFIG_ISDN_AUDIO 1932#ifdef CONFIG_ISDN_AUDIO
1832 skb_queue_head_init(&info->dtmf_queue); 1933 skb_queue_head_init(&info->dtmf_queue);
1833#endif 1934#endif
1834 info->port.xmit_buf = kmalloc(ISDN_SERIAL_XMIT_MAX + 5, 1935 if (!(info->xmit_buf = kmalloc(ISDN_SERIAL_XMIT_MAX + 5, GFP_KERNEL))) {
1835 GFP_KERNEL);
1836 if (!info->port.xmit_buf) {
1837 printk(KERN_ERR "Could not allocate modem xmit-buffer\n"); 1936 printk(KERN_ERR "Could not allocate modem xmit-buffer\n");
1838 retval = -ENOMEM; 1937 retval = -ENOMEM;
1839 goto err_unregister; 1938 goto err_unregister;
1840 } 1939 }
1841 /* Make room for T.70 header */ 1940 /* Make room for T.70 header */
1842 info->port.xmit_buf += 4; 1941 info->xmit_buf += 4;
1843 } 1942 }
1844 return 0; 1943 return 0;
1845err_unregister: 1944err_unregister:
@@ -1848,12 +1947,10 @@ err_unregister:
1848#ifdef CONFIG_ISDN_TTY_FAX 1947#ifdef CONFIG_ISDN_TTY_FAX
1849 kfree(info->fax); 1948 kfree(info->fax);
1850#endif 1949#endif
1851 kfree(info->port.xmit_buf - 4); 1950 kfree(info->xmit_buf - 4);
1852 info->port.xmit_buf = NULL;
1853 tty_port_destroy(&info->port);
1854 } 1951 }
1855 tty_unregister_driver(m->tty_modem); 1952 tty_unregister_driver(m->tty_modem);
1856err: 1953 err:
1857 put_tty_driver(m->tty_modem); 1954 put_tty_driver(m->tty_modem);
1858 m->tty_modem = NULL; 1955 m->tty_modem = NULL;
1859 return retval; 1956 return retval;
@@ -1871,9 +1968,7 @@ isdn_tty_exit(void)
1871#ifdef CONFIG_ISDN_TTY_FAX 1968#ifdef CONFIG_ISDN_TTY_FAX
1872 kfree(info->fax); 1969 kfree(info->fax);
1873#endif 1970#endif
1874 kfree(info->port.xmit_buf - 4); 1971 kfree(info->xmit_buf - 4);
1875 info->port.xmit_buf = NULL;
1876 tty_port_destroy(&info->port);
1877 } 1972 }
1878 tty_unregister_driver(dev->mdm.tty_modem); 1973 tty_unregister_driver(dev->mdm.tty_modem);
1879 put_tty_driver(dev->mdm.tty_modem); 1974 put_tty_driver(dev->mdm.tty_modem);
@@ -1925,8 +2020,8 @@ isdn_tty_match_icall(char *cid, atemu *emu, int di)
1925 int tmp; 2020 int tmp;
1926 tmp = isdn_msncmp(cid, isdn_map_eaz2msn(emu->msn, di)); 2021 tmp = isdn_msncmp(cid, isdn_map_eaz2msn(emu->msn, di));
1927#ifdef ISDN_DEBUG_MODEM_ICALL 2022#ifdef ISDN_DEBUG_MODEM_ICALL
1928 printk(KERN_DEBUG "m_fi: mmsn=%s -> tmp=%d\n", 2023 printk(KERN_DEBUG "m_fi: mmsn=%s -> tmp=%d\n",
1929 isdn_map_eaz2msn(emu->msn, di), tmp); 2024 isdn_map_eaz2msn(emu->msn, di), tmp);
1930#endif 2025#endif
1931 return tmp; 2026 return tmp;
1932 } 2027 }
@@ -1975,20 +2070,20 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
1975 for (i = 0; i < ISDN_MAX_CHANNELS; i++) { 2070 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
1976 modem_info *info = &dev->mdm.info[i]; 2071 modem_info *info = &dev->mdm.info[i];
1977 2072
1978 if (info->port.count == 0) 2073 if (info->count == 0)
1979 continue; 2074 continue;
1980 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */ 2075 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
1981 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */ 2076 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
1982 idx = isdn_dc2minor(di, ch); 2077 idx = isdn_dc2minor(di, ch);
1983#ifdef ISDN_DEBUG_MODEM_ICALL 2078#ifdef ISDN_DEBUG_MODEM_ICALL
1984 printk(KERN_DEBUG "m_fi: match1 wret=%d\n", wret); 2079 printk(KERN_DEBUG "m_fi: match1 wret=%d\n", wret);
1985 printk(KERN_DEBUG "m_fi: idx=%d flags=%08lx drv=%d ch=%d usg=%d\n", idx, 2080 printk(KERN_DEBUG "m_fi: idx=%d flags=%08lx drv=%d ch=%d usg=%d\n", idx,
1986 info->port.flags, info->isdn_driver, 2081 info->flags, info->isdn_driver, info->isdn_channel,
1987 info->isdn_channel, dev->usage[idx]); 2082 dev->usage[idx]);
1988#endif 2083#endif
1989 if ( 2084 if (
1990#ifndef FIX_FILE_TRANSFER 2085#ifndef FIX_FILE_TRANSFER
1991 (info->port.flags & ASYNC_NORMAL_ACTIVE) && 2086 (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) &&
1992#endif 2087#endif
1993 (info->isdn_driver == -1) && 2088 (info->isdn_driver == -1) &&
1994 (info->isdn_channel == -1) && 2089 (info->isdn_channel == -1) &&
@@ -2003,7 +2098,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
2003 info->drv_index = idx; 2098 info->drv_index = idx;
2004 dev->m_idx[idx] = info->line; 2099 dev->m_idx[idx] = info->line;
2005 dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; 2100 dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE;
2006 dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); 2101 dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]);
2007 strcpy(dev->num[idx], nr); 2102 strcpy(dev->num[idx], nr);
2008 strcpy(info->emu.cpn, eaz); 2103 strcpy(info->emu.cpn, eaz);
2009 info->emu.mdmreg[REG_SI1I] = si2bit[si1]; 2104 info->emu.mdmreg[REG_SI1I] = si2bit[si1];
@@ -2023,11 +2118,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
2023 } 2118 }
2024 spin_unlock_irqrestore(&dev->lock, flags); 2119 spin_unlock_irqrestore(&dev->lock, flags);
2025 printk(KERN_INFO "isdn_tty: call from %s -> %s %s\n", nr, eaz, 2120 printk(KERN_INFO "isdn_tty: call from %s -> %s %s\n", nr, eaz,
2026 ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2)) ? "rejected" : "ignored"); 2121 ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2))? "rejected" : "ignored");
2027 return (wret == 2) ? 3 : 0; 2122 return (wret == 2)?3:0;
2028} 2123}
2029 2124
2030#define TTY_IS_ACTIVE(info) (info->port.flags & ASYNC_NORMAL_ACTIVE) 2125#define TTY_IS_ACTIVE(info) \
2126 (info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE))
2031 2127
2032int 2128int
2033isdn_tty_stat_callback(int i, isdn_ctrl *c) 2129isdn_tty_stat_callback(int i, isdn_ctrl *c)
@@ -2041,175 +2137,174 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c)
2041 if ((mi = dev->m_idx[i]) >= 0) { 2137 if ((mi = dev->m_idx[i]) >= 0) {
2042 info = &dev->mdm.info[mi]; 2138 info = &dev->mdm.info[mi];
2043 switch (c->command) { 2139 switch (c->command) {
2044 case ISDN_STAT_CINF: 2140 case ISDN_STAT_CINF:
2045 printk(KERN_DEBUG "CHARGEINFO on ttyI%d: %ld %s\n", info->line, c->arg, c->parm.num); 2141 printk(KERN_DEBUG "CHARGEINFO on ttyI%d: %ld %s\n", info->line, c->arg, c->parm.num);
2046 info->emu.charge = (unsigned) simple_strtoul(c->parm.num, &e, 10); 2142 info->emu.charge = (unsigned) simple_strtoul(c->parm.num, &e, 10);
2047 if (e == (char *)c->parm.num) 2143 if (e == (char *)c->parm.num)
2048 info->emu.charge = 0; 2144 info->emu.charge = 0;
2049 2145
2050 break; 2146 break;
2051 case ISDN_STAT_BSENT: 2147 case ISDN_STAT_BSENT:
2052#ifdef ISDN_TTY_STAT_DEBUG 2148#ifdef ISDN_TTY_STAT_DEBUG
2053 printk(KERN_DEBUG "tty_STAT_BSENT ttyI%d\n", info->line); 2149 printk(KERN_DEBUG "tty_STAT_BSENT ttyI%d\n", info->line);
2054#endif 2150#endif
2055 if ((info->isdn_driver == c->driver) && 2151 if ((info->isdn_driver == c->driver) &&
2056 (info->isdn_channel == c->arg)) { 2152 (info->isdn_channel == c->arg)) {
2057 info->msr |= UART_MSR_CTS; 2153 info->msr |= UART_MSR_CTS;
2058 if (info->send_outstanding) 2154 if (info->send_outstanding)
2059 if (!(--info->send_outstanding)) 2155 if (!(--info->send_outstanding))
2060 info->lsr |= UART_LSR_TEMT; 2156 info->lsr |= UART_LSR_TEMT;
2061 isdn_tty_tint(info); 2157 isdn_tty_tint(info);
2062 return 1; 2158 return 1;
2063 } 2159 }
2064 break; 2160 break;
2065 case ISDN_STAT_CAUSE: 2161 case ISDN_STAT_CAUSE:
2066#ifdef ISDN_TTY_STAT_DEBUG 2162#ifdef ISDN_TTY_STAT_DEBUG
2067 printk(KERN_DEBUG "tty_STAT_CAUSE ttyI%d\n", info->line); 2163 printk(KERN_DEBUG "tty_STAT_CAUSE ttyI%d\n", info->line);
2068#endif 2164#endif
2069 /* Signal cause to tty-device */ 2165 /* Signal cause to tty-device */
2070 strncpy(info->last_cause, c->parm.num, 5); 2166 strncpy(info->last_cause, c->parm.num, 5);
2071 return 1; 2167 return 1;
2072 case ISDN_STAT_DISPLAY: 2168 case ISDN_STAT_DISPLAY:
2073#ifdef ISDN_TTY_STAT_DEBUG 2169#ifdef ISDN_TTY_STAT_DEBUG
2074 printk(KERN_DEBUG "tty_STAT_DISPLAY ttyI%d\n", info->line); 2170 printk(KERN_DEBUG "tty_STAT_DISPLAY ttyI%d\n", info->line);
2075#endif 2171#endif
2076 /* Signal display to tty-device */ 2172 /* Signal display to tty-device */
2077 if ((info->emu.mdmreg[REG_DISPLAY] & BIT_DISPLAY) && 2173 if ((info->emu.mdmreg[REG_DISPLAY] & BIT_DISPLAY) &&
2078 !(info->emu.mdmreg[REG_RESPNUM] & BIT_RESPNUM)) { 2174 !(info->emu.mdmreg[REG_RESPNUM] & BIT_RESPNUM)) {
2079 isdn_tty_at_cout("\r\n", info); 2175 isdn_tty_at_cout("\r\n", info);
2080 isdn_tty_at_cout("DISPLAY: ", info); 2176 isdn_tty_at_cout("DISPLAY: ", info);
2081 isdn_tty_at_cout(c->parm.display, info); 2177 isdn_tty_at_cout(c->parm.display, info);
2082 isdn_tty_at_cout("\r\n", info); 2178 isdn_tty_at_cout("\r\n", info);
2083 } 2179 }
2084 return 1; 2180 return 1;
2085 case ISDN_STAT_DCONN: 2181 case ISDN_STAT_DCONN:
2086#ifdef ISDN_TTY_STAT_DEBUG 2182#ifdef ISDN_TTY_STAT_DEBUG
2087 printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); 2183 printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line);
2088#endif 2184#endif
2089 if (TTY_IS_ACTIVE(info)) { 2185 if (TTY_IS_ACTIVE(info)) {
2090 if (info->dialing == 1) { 2186 if (info->dialing == 1) {
2091 info->dialing = 2; 2187 info->dialing = 2;
2092 return 1; 2188 return 1;
2189 }
2093 } 2190 }
2094 } 2191 break;
2095 break; 2192 case ISDN_STAT_DHUP:
2096 case ISDN_STAT_DHUP:
2097#ifdef ISDN_TTY_STAT_DEBUG 2193#ifdef ISDN_TTY_STAT_DEBUG
2098 printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line); 2194 printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line);
2099#endif 2195#endif
2100 if (TTY_IS_ACTIVE(info)) { 2196 if (TTY_IS_ACTIVE(info)) {
2101 if (info->dialing == 1) 2197 if (info->dialing == 1)
2102 isdn_tty_modem_result(RESULT_BUSY, info); 2198 isdn_tty_modem_result(RESULT_BUSY, info);
2103 if (info->dialing > 1) 2199 if (info->dialing > 1)
2104 isdn_tty_modem_result(RESULT_NO_CARRIER, info); 2200 isdn_tty_modem_result(RESULT_NO_CARRIER, info);
2105 info->dialing = 0; 2201 info->dialing = 0;
2106#ifdef ISDN_DEBUG_MODEM_HUP 2202#ifdef ISDN_DEBUG_MODEM_HUP
2107 printk(KERN_DEBUG "Mhup in ISDN_STAT_DHUP\n"); 2203 printk(KERN_DEBUG "Mhup in ISDN_STAT_DHUP\n");
2108#endif 2204#endif
2109 isdn_tty_modem_hup(info, 0); 2205 isdn_tty_modem_hup(info, 0);
2110 return 1; 2206 return 1;
2111 } 2207 }
2112 break; 2208 break;
2113 case ISDN_STAT_BCONN: 2209 case ISDN_STAT_BCONN:
2114#ifdef ISDN_TTY_STAT_DEBUG 2210#ifdef ISDN_TTY_STAT_DEBUG
2115 printk(KERN_DEBUG "tty_STAT_BCONN ttyI%d\n", info->line); 2211 printk(KERN_DEBUG "tty_STAT_BCONN ttyI%d\n", info->line);
2116#endif 2212#endif
2117 /* Wake up any processes waiting 2213 /* Wake up any processes waiting
2118 * for incoming call of this device when 2214 * for incoming call of this device when
2119 * DCD follow the state of incoming carrier 2215 * DCD follow the state of incoming carrier
2120 */ 2216 */
2121 if (info->port.blocked_open && 2217 if (info->blocked_open &&
2122 (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { 2218 (info->emu.mdmreg[REG_DCD] & BIT_DCD)) {
2123 wake_up_interruptible(&info->port.open_wait); 2219 wake_up_interruptible(&info->open_wait);
2124 } 2220 }
2125 2221
2126 /* Schedule CONNECT-Message to any tty 2222 /* Schedule CONNECT-Message to any tty
2127 * waiting for it and 2223 * waiting for it and
2128 * set DCD-bit of its modem-status. 2224 * set DCD-bit of its modem-status.
2129 */ 2225 */
2130 if (TTY_IS_ACTIVE(info) || 2226 if (TTY_IS_ACTIVE(info) ||
2131 (info->port.blocked_open && 2227 (info->blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) {
2132 (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { 2228 info->msr |= UART_MSR_DCD;
2133 info->msr |= UART_MSR_DCD; 2229 info->emu.charge = 0;
2134 info->emu.charge = 0; 2230 if (info->dialing & 0xf)
2135 if (info->dialing & 0xf) 2231 info->last_dir = 1;
2136 info->last_dir = 1; 2232 else
2137 else 2233 info->last_dir = 0;
2138 info->last_dir = 0; 2234 info->dialing = 0;
2139 info->dialing = 0; 2235 info->rcvsched = 1;
2140 info->rcvsched = 1; 2236 if (USG_MODEM(dev->usage[i])) {
2141 if (USG_MODEM(dev->usage[i])) { 2237 if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) {
2142 if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { 2238 strcpy(info->emu.connmsg, c->parm.num);
2143 strcpy(info->emu.connmsg, c->parm.num); 2239 isdn_tty_modem_result(RESULT_CONNECT, info);
2144 isdn_tty_modem_result(RESULT_CONNECT, info); 2240 } else
2145 } else 2241 isdn_tty_modem_result(RESULT_CONNECT64000, info);
2146 isdn_tty_modem_result(RESULT_CONNECT64000, info); 2242 }
2243 if (USG_VOICE(dev->usage[i]))
2244 isdn_tty_modem_result(RESULT_VCON, info);
2245 return 1;
2147 } 2246 }
2148 if (USG_VOICE(dev->usage[i])) 2247 break;
2149 isdn_tty_modem_result(RESULT_VCON, info); 2248 case ISDN_STAT_BHUP:
2150 return 1;
2151 }
2152 break;
2153 case ISDN_STAT_BHUP:
2154#ifdef ISDN_TTY_STAT_DEBUG 2249#ifdef ISDN_TTY_STAT_DEBUG
2155 printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line); 2250 printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line);
2156#endif 2251#endif
2157 if (TTY_IS_ACTIVE(info)) { 2252 if (TTY_IS_ACTIVE(info)) {
2158#ifdef ISDN_DEBUG_MODEM_HUP 2253#ifdef ISDN_DEBUG_MODEM_HUP
2159 printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n"); 2254 printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n");
2160#endif 2255#endif
2161 isdn_tty_modem_hup(info, 0); 2256 isdn_tty_modem_hup(info, 0);
2162 return 1; 2257 return 1;
2163 } 2258 }
2164 break; 2259 break;
2165 case ISDN_STAT_NODCH: 2260 case ISDN_STAT_NODCH:
2166#ifdef ISDN_TTY_STAT_DEBUG 2261#ifdef ISDN_TTY_STAT_DEBUG
2167 printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); 2262 printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line);
2168#endif 2263#endif
2169 if (TTY_IS_ACTIVE(info)) { 2264 if (TTY_IS_ACTIVE(info)) {
2170 if (info->dialing) { 2265 if (info->dialing) {
2171 info->dialing = 0; 2266 info->dialing = 0;
2172 info->last_l2 = -1; 2267 info->last_l2 = -1;
2173 info->last_si = 0; 2268 info->last_si = 0;
2174 sprintf(info->last_cause, "0000"); 2269 sprintf(info->last_cause, "0000");
2175 isdn_tty_modem_result(RESULT_NO_DIALTONE, info); 2270 isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
2271 }
2272 isdn_tty_modem_hup(info, 0);
2273 return 1;
2176 } 2274 }
2177 isdn_tty_modem_hup(info, 0); 2275 break;
2178 return 1; 2276 case ISDN_STAT_UNLOAD:
2179 }
2180 break;
2181 case ISDN_STAT_UNLOAD:
2182#ifdef ISDN_TTY_STAT_DEBUG 2277#ifdef ISDN_TTY_STAT_DEBUG
2183 printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); 2278 printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line);
2184#endif 2279#endif
2185 for (i = 0; i < ISDN_MAX_CHANNELS; i++) { 2280 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
2186 info = &dev->mdm.info[i]; 2281 info = &dev->mdm.info[i];
2187 if (info->isdn_driver == c->driver) { 2282 if (info->isdn_driver == c->driver) {
2188 if (info->online) 2283 if (info->online)
2189 isdn_tty_modem_hup(info, 1); 2284 isdn_tty_modem_hup(info, 1);
2285 }
2190 } 2286 }
2191 } 2287 return 1;
2192 return 1;
2193#ifdef CONFIG_ISDN_TTY_FAX 2288#ifdef CONFIG_ISDN_TTY_FAX
2194 case ISDN_STAT_FAXIND: 2289 case ISDN_STAT_FAXIND:
2195 if (TTY_IS_ACTIVE(info)) { 2290 if (TTY_IS_ACTIVE(info)) {
2196 isdn_tty_fax_command(info, c); 2291 isdn_tty_fax_command(info, c);
2197 } 2292 }
2198 break; 2293 break;
2199#endif 2294#endif
2200#ifdef CONFIG_ISDN_AUDIO 2295#ifdef CONFIG_ISDN_AUDIO
2201 case ISDN_STAT_AUDIO: 2296 case ISDN_STAT_AUDIO:
2202 if (TTY_IS_ACTIVE(info)) { 2297 if (TTY_IS_ACTIVE(info)) {
2203 switch (c->parm.num[0]) { 2298 switch(c->parm.num[0]) {
2204 case ISDN_AUDIO_DTMF: 2299 case ISDN_AUDIO_DTMF:
2205 if (info->vonline) { 2300 if (info->vonline) {
2206 isdn_audio_put_dle_code(info, 2301 isdn_audio_put_dle_code(info,
2207 c->parm.num[1]); 2302 c->parm.num[1]);
2303 }
2304 break;
2208 } 2305 }
2209 break;
2210 } 2306 }
2211 } 2307 break;
2212 break;
2213#endif 2308#endif
2214 } 2309 }
2215 } 2310 }
@@ -2218,16 +2313,16 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c)
2218 2313
2219/********************************************************************* 2314/*********************************************************************
2220 Modem-Emulator-Routines 2315 Modem-Emulator-Routines
2221*********************************************************************/ 2316 *********************************************************************/
2222 2317
2223#define cmdchar(c) ((c >= ' ') && (c <= 0x7f)) 2318#define cmdchar(c) ((c>=' ')&&(c<=0x7f))
2224 2319
2225/* 2320/*
2226 * Put a message from the AT-emulator into receive-buffer of tty, 2321 * Put a message from the AT-emulator into receive-buffer of tty,
2227 * convert CR, LF, and BS to values in modem-registers 3, 4 and 5. 2322 * convert CR, LF, and BS to values in modem-registers 3, 4 and 5.
2228 */ 2323 */
2229void 2324void
2230isdn_tty_at_cout(char *msg, modem_info *info) 2325isdn_tty_at_cout(char *msg, modem_info * info)
2231{ 2326{
2232 struct tty_struct *tty; 2327 struct tty_struct *tty;
2233 atemu *m = &info->emu; 2328 atemu *m = &info->emu;
@@ -2246,8 +2341,8 @@ isdn_tty_at_cout(char *msg, modem_info *info)
2246 l = strlen(msg); 2341 l = strlen(msg);
2247 2342
2248 spin_lock_irqsave(&info->readlock, flags); 2343 spin_lock_irqsave(&info->readlock, flags);
2249 tty = info->port.tty; 2344 tty = info->tty;
2250 if ((info->port.flags & ASYNC_CLOSING) || (!tty)) { 2345 if ((info->flags & ISDN_ASYNC_CLOSING) || (!tty)) {
2251 spin_unlock_irqrestore(&info->readlock, flags); 2346 spin_unlock_irqrestore(&info->readlock, flags);
2252 return; 2347 return;
2253 } 2348 }
@@ -2255,7 +2350,7 @@ isdn_tty_at_cout(char *msg, modem_info *info)
2255 /* use queue instead of direct, if online and */ 2350 /* use queue instead of direct, if online and */
2256 /* data is in queue or buffer is full */ 2351 /* data is in queue or buffer is full */
2257 if (info->online && ((tty_buffer_request_room(tty, l) < l) || 2352 if (info->online && ((tty_buffer_request_room(tty, l) < l) ||
2258 !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { 2353 !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) {
2259 skb = alloc_skb(l, GFP_ATOMIC); 2354 skb = alloc_skb(l, GFP_ATOMIC);
2260 if (!skb) { 2355 if (!skb) {
2261 spin_unlock_irqrestore(&info->readlock, flags); 2356 spin_unlock_irqrestore(&info->readlock, flags);
@@ -2270,22 +2365,22 @@ isdn_tty_at_cout(char *msg, modem_info *info)
2270 2365
2271 for (p = msg; *p; p++) { 2366 for (p = msg; *p; p++) {
2272 switch (*p) { 2367 switch (*p) {
2273 case '\r': 2368 case '\r':
2274 c = m->mdmreg[REG_CR]; 2369 c = m->mdmreg[REG_CR];
2275 break; 2370 break;
2276 case '\n': 2371 case '\n':
2277 c = m->mdmreg[REG_LF]; 2372 c = m->mdmreg[REG_LF];
2278 break; 2373 break;
2279 case '\b': 2374 case '\b':
2280 c = m->mdmreg[REG_BS]; 2375 c = m->mdmreg[REG_BS];
2281 break; 2376 break;
2282 default: 2377 default:
2283 c = *p; 2378 c = *p;
2284 } 2379 }
2285 if (skb) { 2380 if (skb) {
2286 *sp++ = c; 2381 *sp++ = c;
2287 } else { 2382 } else {
2288 if (tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) 2383 if(tty_insert_flip_char(tty, c, TTY_NORMAL) == 0)
2289 break; 2384 break;
2290 } 2385 }
2291 } 2386 }
@@ -2307,7 +2402,7 @@ isdn_tty_at_cout(char *msg, modem_info *info)
2307 * Perform ATH Hangup 2402 * Perform ATH Hangup
2308 */ 2403 */
2309static void 2404static void
2310isdn_tty_on_hook(modem_info *info) 2405isdn_tty_on_hook(modem_info * info)
2311{ 2406{
2312 if (info->isdn_channel >= 0) { 2407 if (info->isdn_channel >= 0) {
2313#ifdef ISDN_DEBUG_MODEM_HUP 2408#ifdef ISDN_DEBUG_MODEM_HUP
@@ -2323,8 +2418,8 @@ isdn_tty_off_hook(void)
2323 printk(KERN_DEBUG "isdn_tty_off_hook\n"); 2418 printk(KERN_DEBUG "isdn_tty_off_hook\n");
2324} 2419}
2325 2420
2326#define PLUSWAIT1 (HZ / 2) /* 0.5 sec. */ 2421#define PLUSWAIT1 (HZ/2) /* 0.5 sec. */
2327#define PLUSWAIT2 (HZ * 3 / 2) /* 1.5 sec */ 2422#define PLUSWAIT2 (HZ*3/2) /* 1.5 sec */
2328 2423
2329/* 2424/*
2330 * Check Buffer for Modem-escape-sequence, activate timer-callback to 2425 * Check Buffer for Modem-escape-sequence, activate timer-callback to
@@ -2338,7 +2433,7 @@ isdn_tty_off_hook(void)
2338 * lastplus timestamp of last character 2433 * lastplus timestamp of last character
2339 */ 2434 */
2340static void 2435static void
2341isdn_tty_check_esc(const u_char *p, u_char plus, int count, int *pluscount, 2436isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount,
2342 u_long *lastplus) 2437 u_long *lastplus)
2343{ 2438{
2344 if (plus > 127) 2439 if (plus > 127)
@@ -2378,69 +2473,69 @@ isdn_tty_check_esc(const u_char *p, u_char plus, int count, int *pluscount,
2378 */ 2473 */
2379 2474
2380static void 2475static void
2381isdn_tty_modem_result(int code, modem_info *info) 2476isdn_tty_modem_result(int code, modem_info * info)
2382{ 2477{
2383 atemu *m = &info->emu; 2478 atemu *m = &info->emu;
2384 static char *msg[] = 2479 static char *msg[] =
2385 {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR", 2480 {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR",
2386 "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER", 2481 "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER",
2387 "RINGING", "NO MSN/EAZ", "VCON", "RUNG"}; 2482 "RINGING", "NO MSN/EAZ", "VCON", "RUNG"};
2388 char s[ISDN_MSNLEN + 10]; 2483 char s[ISDN_MSNLEN+10];
2389 2484
2390 switch (code) { 2485 switch (code) {
2391 case RESULT_RING: 2486 case RESULT_RING:
2392 m->mdmreg[REG_RINGCNT]++; 2487 m->mdmreg[REG_RINGCNT]++;
2393 if (m->mdmreg[REG_RINGCNT] == m->mdmreg[REG_RINGATA]) 2488 if (m->mdmreg[REG_RINGCNT] == m->mdmreg[REG_RINGATA])
2394 /* Automatically accept incoming call */ 2489 /* Automatically accept incoming call */
2395 isdn_tty_cmd_ATA(info); 2490 isdn_tty_cmd_ATA(info);
2396 break; 2491 break;
2397 case RESULT_NO_CARRIER: 2492 case RESULT_NO_CARRIER:
2398#ifdef ISDN_DEBUG_MODEM_HUP 2493#ifdef ISDN_DEBUG_MODEM_HUP
2399 printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", 2494 printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n",
2400 (info->port.flags & ASYNC_CLOSING), 2495 (info->flags & ISDN_ASYNC_CLOSING),
2401 (!info->port.tty)); 2496 (!info->tty));
2402#endif 2497#endif
2403 m->mdmreg[REG_RINGCNT] = 0; 2498 m->mdmreg[REG_RINGCNT] = 0;
2404 del_timer(&info->nc_timer); 2499 del_timer(&info->nc_timer);
2405 info->ncarrier = 0; 2500 info->ncarrier = 0;
2406 if ((info->port.flags & ASYNC_CLOSING) || (!info->port.tty)) 2501 if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) {
2407 return; 2502 return;
2408 2503 }
2409#ifdef CONFIG_ISDN_AUDIO 2504#ifdef CONFIG_ISDN_AUDIO
2410 if (info->vonline & 1) { 2505 if (info->vonline & 1) {
2411#ifdef ISDN_DEBUG_MODEM_VOICE 2506#ifdef ISDN_DEBUG_MODEM_VOICE
2412 printk(KERN_DEBUG "res3: send DLE-ETX on ttyI%d\n", 2507 printk(KERN_DEBUG "res3: send DLE-ETX on ttyI%d\n",
2413 info->line); 2508 info->line);
2414#endif 2509#endif
2415 /* voice-recording, add DLE-ETX */ 2510 /* voice-recording, add DLE-ETX */
2416 isdn_tty_at_cout("\020\003", info); 2511 isdn_tty_at_cout("\020\003", info);
2417 } 2512 }
2418 if (info->vonline & 2) { 2513 if (info->vonline & 2) {
2419#ifdef ISDN_DEBUG_MODEM_VOICE 2514#ifdef ISDN_DEBUG_MODEM_VOICE
2420 printk(KERN_DEBUG "res3: send DLE-DC4 on ttyI%d\n", 2515 printk(KERN_DEBUG "res3: send DLE-DC4 on ttyI%d\n",
2421 info->line); 2516 info->line);
2422#endif 2517#endif
2423 /* voice-playing, add DLE-DC4 */ 2518 /* voice-playing, add DLE-DC4 */
2424 isdn_tty_at_cout("\020\024", info); 2519 isdn_tty_at_cout("\020\024", info);
2425 } 2520 }
2426#endif 2521#endif
2427 break; 2522 break;
2428 case RESULT_CONNECT: 2523 case RESULT_CONNECT:
2429 case RESULT_CONNECT64000: 2524 case RESULT_CONNECT64000:
2430 sprintf(info->last_cause, "0000"); 2525 sprintf(info->last_cause, "0000");
2431 if (!info->online) 2526 if (!info->online)
2432 info->online = 2; 2527 info->online = 2;
2433 break; 2528 break;
2434 case RESULT_VCON: 2529 case RESULT_VCON:
2435#ifdef ISDN_DEBUG_MODEM_VOICE 2530#ifdef ISDN_DEBUG_MODEM_VOICE
2436 printk(KERN_DEBUG "res3: send VCON on ttyI%d\n", 2531 printk(KERN_DEBUG "res3: send VCON on ttyI%d\n",
2437 info->line); 2532 info->line);
2438#endif 2533#endif
2439 sprintf(info->last_cause, "0000"); 2534 sprintf(info->last_cause, "0000");
2440 if (!info->online) 2535 if (!info->online)
2441 info->online = 1; 2536 info->online = 1;
2442 break; 2537 break;
2443 } /* switch (code) */ 2538 } /* switch(code) */
2444 2539
2445 if (m->mdmreg[REG_RESP] & BIT_RESP) { 2540 if (m->mdmreg[REG_RESP] & BIT_RESP) {
2446 /* Show results */ 2541 /* Show results */
@@ -2450,97 +2545,100 @@ isdn_tty_modem_result(int code, modem_info *info)
2450 isdn_tty_at_cout(s, info); 2545 isdn_tty_at_cout(s, info);
2451 } else { 2546 } else {
2452 if (code == RESULT_RING) { 2547 if (code == RESULT_RING) {
2453 /* return if "show RUNG" and ringcounter>1 */ 2548 /* return if "show RUNG" and ringcounter>1 */
2454 if ((m->mdmreg[REG_RUNG] & BIT_RUNG) && 2549 if ((m->mdmreg[REG_RUNG] & BIT_RUNG) &&
2455 (m->mdmreg[REG_RINGCNT] > 1)) 2550 (m->mdmreg[REG_RINGCNT] > 1))
2456 return; 2551 return;
2457 /* print CID, _before_ _every_ ring */ 2552 /* print CID, _before_ _every_ ring */
2458 if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { 2553 if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) {
2459 isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); 2554 isdn_tty_at_cout("\r\nCALLER NUMBER: ", info);
2460 isdn_tty_at_cout(dev->num[info->drv_index], info); 2555 isdn_tty_at_cout(dev->num[info->drv_index], info);
2461 if (m->mdmreg[REG_CDN] & BIT_CDN) { 2556 if (m->mdmreg[REG_CDN] & BIT_CDN) {
2462 isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); 2557 isdn_tty_at_cout("\r\nCALLED NUMBER: ", info);
2463 isdn_tty_at_cout(info->emu.cpn, info); 2558 isdn_tty_at_cout(info->emu.cpn, info);
2464 } 2559 }
2465 } 2560 }
2466 } 2561 }
2467 isdn_tty_at_cout("\r\n", info); 2562 isdn_tty_at_cout("\r\n", info);
2468 isdn_tty_at_cout(msg[code], info); 2563 isdn_tty_at_cout(msg[code], info);
2469 switch (code) { 2564 switch (code) {
2470 case RESULT_CONNECT: 2565 case RESULT_CONNECT:
2471 switch (m->mdmreg[REG_L2PROT]) { 2566 switch (m->mdmreg[REG_L2PROT]) {
2472 case ISDN_PROTO_L2_MODEM: 2567 case ISDN_PROTO_L2_MODEM:
2473 isdn_tty_at_cout(" ", info); 2568 isdn_tty_at_cout(" ", info);
2474 isdn_tty_at_cout(m->connmsg, info); 2569 isdn_tty_at_cout(m->connmsg, info);
2475 break; 2570 break;
2476 }
2477 break;
2478 case RESULT_RING:
2479 /* Append CPN, if enabled */
2480 if ((m->mdmreg[REG_CPN] & BIT_CPN)) {
2481 sprintf(s, "/%s", m->cpn);
2482 isdn_tty_at_cout(s, info);
2483 }
2484 /* Print CID only once, _after_ 1st RING */
2485 if ((m->mdmreg[REG_CIDONCE] & BIT_CIDONCE) &&
2486 (m->mdmreg[REG_RINGCNT] == 1)) {
2487 isdn_tty_at_cout("\r\n", info);
2488 isdn_tty_at_cout("CALLER NUMBER: ", info);
2489 isdn_tty_at_cout(dev->num[info->drv_index], info);
2490 if (m->mdmreg[REG_CDN] & BIT_CDN) {
2491 isdn_tty_at_cout("\r\nCALLED NUMBER: ", info);
2492 isdn_tty_at_cout(info->emu.cpn, info);
2493 } 2571 }
2494 }
2495 break;
2496 case RESULT_NO_CARRIER:
2497 case RESULT_NO_DIALTONE:
2498 case RESULT_BUSY:
2499 case RESULT_NO_ANSWER:
2500 m->mdmreg[REG_RINGCNT] = 0;
2501 /* Append Cause-Message if enabled */
2502 if (m->mdmreg[REG_RESPXT] & BIT_RESPXT) {
2503 sprintf(s, "/%s", info->last_cause);
2504 isdn_tty_at_cout(s, info);
2505 }
2506 break;
2507 case RESULT_CONNECT64000:
2508 /* Append Protocol to CONNECT message */
2509 switch (m->mdmreg[REG_L2PROT]) {
2510 case ISDN_PROTO_L2_X75I:
2511 case ISDN_PROTO_L2_X75UI:
2512 case ISDN_PROTO_L2_X75BUI:
2513 isdn_tty_at_cout("/X.75", info);
2514 break;
2515 case ISDN_PROTO_L2_HDLC:
2516 isdn_tty_at_cout("/HDLC", info);
2517 break; 2572 break;
2518 case ISDN_PROTO_L2_V11096: 2573 case RESULT_RING:
2519 isdn_tty_at_cout("/V110/9600", info); 2574 /* Append CPN, if enabled */
2575 if ((m->mdmreg[REG_CPN] & BIT_CPN)) {
2576 sprintf(s, "/%s", m->cpn);
2577 isdn_tty_at_cout(s, info);
2578 }
2579 /* Print CID only once, _after_ 1st RING */
2580 if ((m->mdmreg[REG_CIDONCE] & BIT_CIDONCE) &&
2581 (m->mdmreg[REG_RINGCNT] == 1)) {
2582 isdn_tty_at_cout("\r\n", info);
2583 isdn_tty_at_cout("CALLER NUMBER: ", info);
2584 isdn_tty_at_cout(dev->num[info->drv_index], info);
2585 if (m->mdmreg[REG_CDN] & BIT_CDN) {
2586 isdn_tty_at_cout("\r\nCALLED NUMBER: ", info);
2587 isdn_tty_at_cout(info->emu.cpn, info);
2588 }
2589 }
2520 break; 2590 break;
2521 case ISDN_PROTO_L2_V11019: 2591 case RESULT_NO_CARRIER:
2522 isdn_tty_at_cout("/V110/19200", info); 2592 case RESULT_NO_DIALTONE:
2593 case RESULT_BUSY:
2594 case RESULT_NO_ANSWER:
2595 m->mdmreg[REG_RINGCNT] = 0;
2596 /* Append Cause-Message if enabled */
2597 if (m->mdmreg[REG_RESPXT] & BIT_RESPXT) {
2598 sprintf(s, "/%s", info->last_cause);
2599 isdn_tty_at_cout(s, info);
2600 }
2523 break; 2601 break;
2524 case ISDN_PROTO_L2_V11038: 2602 case RESULT_CONNECT64000:
2525 isdn_tty_at_cout("/V110/38400", info); 2603 /* Append Protocol to CONNECT message */
2604 switch (m->mdmreg[REG_L2PROT]) {
2605 case ISDN_PROTO_L2_X75I:
2606 case ISDN_PROTO_L2_X75UI:
2607 case ISDN_PROTO_L2_X75BUI:
2608 isdn_tty_at_cout("/X.75", info);
2609 break;
2610 case ISDN_PROTO_L2_HDLC:
2611 isdn_tty_at_cout("/HDLC", info);
2612 break;
2613 case ISDN_PROTO_L2_V11096:
2614 isdn_tty_at_cout("/V110/9600", info);
2615 break;
2616 case ISDN_PROTO_L2_V11019:
2617 isdn_tty_at_cout("/V110/19200", info);
2618 break;
2619 case ISDN_PROTO_L2_V11038:
2620 isdn_tty_at_cout("/V110/38400", info);
2621 break;
2622 }
2623 if (m->mdmreg[REG_T70] & BIT_T70) {
2624 isdn_tty_at_cout("/T.70", info);
2625 if (m->mdmreg[REG_T70] & BIT_T70_EXT)
2626 isdn_tty_at_cout("+", info);
2627 }
2526 break; 2628 break;
2527 }
2528 if (m->mdmreg[REG_T70] & BIT_T70) {
2529 isdn_tty_at_cout("/T.70", info);
2530 if (m->mdmreg[REG_T70] & BIT_T70_EXT)
2531 isdn_tty_at_cout("+", info);
2532 }
2533 break;
2534 } 2629 }
2535 isdn_tty_at_cout("\r\n", info); 2630 isdn_tty_at_cout("\r\n", info);
2536 } 2631 }
2537 } 2632 }
2538 if (code == RESULT_NO_CARRIER) { 2633 if (code == RESULT_NO_CARRIER) {
2539 if ((info->port.flags & ASYNC_CLOSING) || (!info->port.tty)) 2634 if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) {
2540 return; 2635 return;
2541 2636 }
2542 if (info->port.flags & ASYNC_CHECK_CD) 2637 if ((info->flags & ISDN_ASYNC_CHECK_CD) &&
2543 tty_hangup(info->port.tty); 2638 (!((info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) &&
2639 (info->flags & ISDN_ASYNC_CALLOUT_NOHUP)))) {
2640 tty_hangup(info->tty);
2641 }
2544 } 2642 }
2545} 2643}
2546 2644
@@ -2549,7 +2647,7 @@ isdn_tty_modem_result(int code, modem_info *info)
2549 * Display a modem-register-value. 2647 * Display a modem-register-value.
2550 */ 2648 */
2551static void 2649static void
2552isdn_tty_show_profile(int ridx, modem_info *info) 2650isdn_tty_show_profile(int ridx, modem_info * info)
2553{ 2651{
2554 char v[6]; 2652 char v[6];
2555 2653
@@ -2568,7 +2666,7 @@ isdn_tty_get_msnstr(char *n, char **p)
2568 while (((*p[0] >= '0' && *p[0] <= '9') || 2666 while (((*p[0] >= '0' && *p[0] <= '9') ||
2569 /* Why a comma ??? */ 2667 /* Why a comma ??? */
2570 (*p[0] == ',') || (*p[0] == ':')) && 2668 (*p[0] == ',') || (*p[0] == ':')) &&
2571 (limit--)) 2669 (limit--))
2572 *n++ = *p[0]++; 2670 *n++ = *p[0]++;
2573 *n = '\0'; 2671 *n = '\0';
2574} 2672}
@@ -2577,20 +2675,20 @@ isdn_tty_get_msnstr(char *n, char **p)
2577 * Get phone-number from modem-commandbuffer 2675 * Get phone-number from modem-commandbuffer
2578 */ 2676 */
2579static void 2677static void
2580isdn_tty_getdial(char *p, char *q, int cnt) 2678isdn_tty_getdial(char *p, char *q,int cnt)
2581{ 2679{
2582 int first = 1; 2680 int first = 1;
2583 int limit = ISDN_MSNLEN - 1; /* MUST match the size of interface var to avoid 2681 int limit = ISDN_MSNLEN - 1; /* MUST match the size of interface var to avoid
2584 buffer overflow */ 2682 buffer overflow */
2585 2683
2586 while (strchr(" 0123456789,#.*WPTSR-", *p) && *p && --cnt > 0) { 2684 while (strchr(" 0123456789,#.*WPTSR-", *p) && *p && --cnt>0) {
2587 if ((*p >= '0' && *p <= '9') || ((*p == 'S') && first) || 2685 if ((*p >= '0' && *p <= '9') || ((*p == 'S') && first) ||
2588 ((*p == 'R') && first) || 2686 ((*p == 'R') && first) ||
2589 (*p == '*') || (*p == '#')) { 2687 (*p == '*') || (*p == '#')) {
2590 *q++ = *p; 2688 *q++ = *p;
2591 limit--; 2689 limit--;
2592 } 2690 }
2593 if (!limit) 2691 if(!limit)
2594 break; 2692 break;
2595 p++; 2693 p++;
2596 first = 0; 2694 first = 0;
@@ -2602,7 +2700,7 @@ isdn_tty_getdial(char *p, char *q, int cnt)
2602#define PARSE_ERROR1 { isdn_tty_modem_result(RESULT_ERROR, info); return 1; } 2700#define PARSE_ERROR1 { isdn_tty_modem_result(RESULT_ERROR, info); return 1; }
2603 2701
2604static void 2702static void
2605isdn_tty_report(modem_info *info) 2703isdn_tty_report(modem_info * info)
2606{ 2704{
2607 atemu *m = &info->emu; 2705 atemu *m = &info->emu;
2608 char s[80]; 2706 char s[80];
@@ -2614,39 +2712,39 @@ isdn_tty_report(modem_info *info)
2614 isdn_tty_at_cout(s, info); 2712 isdn_tty_at_cout(s, info);
2615 isdn_tty_at_cout(" Layer-2 Protocol: ", info); 2713 isdn_tty_at_cout(" Layer-2 Protocol: ", info);
2616 switch (info->last_l2) { 2714 switch (info->last_l2) {
2617 case ISDN_PROTO_L2_X75I: 2715 case ISDN_PROTO_L2_X75I:
2618 isdn_tty_at_cout("X.75i", info); 2716 isdn_tty_at_cout("X.75i", info);
2619 break; 2717 break;
2620 case ISDN_PROTO_L2_X75UI: 2718 case ISDN_PROTO_L2_X75UI:
2621 isdn_tty_at_cout("X.75ui", info); 2719 isdn_tty_at_cout("X.75ui", info);
2622 break; 2720 break;
2623 case ISDN_PROTO_L2_X75BUI: 2721 case ISDN_PROTO_L2_X75BUI:
2624 isdn_tty_at_cout("X.75bui", info); 2722 isdn_tty_at_cout("X.75bui", info);
2625 break; 2723 break;
2626 case ISDN_PROTO_L2_HDLC: 2724 case ISDN_PROTO_L2_HDLC:
2627 isdn_tty_at_cout("HDLC", info); 2725 isdn_tty_at_cout("HDLC", info);
2628 break; 2726 break;
2629 case ISDN_PROTO_L2_V11096: 2727 case ISDN_PROTO_L2_V11096:
2630 isdn_tty_at_cout("V.110 9600 Baud", info); 2728 isdn_tty_at_cout("V.110 9600 Baud", info);
2631 break; 2729 break;
2632 case ISDN_PROTO_L2_V11019: 2730 case ISDN_PROTO_L2_V11019:
2633 isdn_tty_at_cout("V.110 19200 Baud", info); 2731 isdn_tty_at_cout("V.110 19200 Baud", info);
2634 break; 2732 break;
2635 case ISDN_PROTO_L2_V11038: 2733 case ISDN_PROTO_L2_V11038:
2636 isdn_tty_at_cout("V.110 38400 Baud", info); 2734 isdn_tty_at_cout("V.110 38400 Baud", info);
2637 break; 2735 break;
2638 case ISDN_PROTO_L2_TRANS: 2736 case ISDN_PROTO_L2_TRANS:
2639 isdn_tty_at_cout("transparent", info); 2737 isdn_tty_at_cout("transparent", info);
2640 break; 2738 break;
2641 case ISDN_PROTO_L2_MODEM: 2739 case ISDN_PROTO_L2_MODEM:
2642 isdn_tty_at_cout("modem", info); 2740 isdn_tty_at_cout("modem", info);
2643 break; 2741 break;
2644 case ISDN_PROTO_L2_FAX: 2742 case ISDN_PROTO_L2_FAX:
2645 isdn_tty_at_cout("fax", info); 2743 isdn_tty_at_cout("fax", info);
2646 break; 2744 break;
2647 default: 2745 default:
2648 isdn_tty_at_cout("unknown", info); 2746 isdn_tty_at_cout("unknown", info);
2649 break; 2747 break;
2650 } 2748 }
2651 if (m->mdmreg[REG_T70] & BIT_T70) { 2749 if (m->mdmreg[REG_T70] & BIT_T70) {
2652 isdn_tty_at_cout("/T.70", info); 2750 isdn_tty_at_cout("/T.70", info);
@@ -2656,19 +2754,19 @@ isdn_tty_report(modem_info *info)
2656 isdn_tty_at_cout("\r\n", info); 2754 isdn_tty_at_cout("\r\n", info);
2657 isdn_tty_at_cout(" Service: ", info); 2755 isdn_tty_at_cout(" Service: ", info);
2658 switch (info->last_si) { 2756 switch (info->last_si) {
2659 case 1: 2757 case 1:
2660 isdn_tty_at_cout("audio\r\n", info); 2758 isdn_tty_at_cout("audio\r\n", info);
2661 break; 2759 break;
2662 case 5: 2760 case 5:
2663 isdn_tty_at_cout("btx\r\n", info); 2761 isdn_tty_at_cout("btx\r\n", info);
2664 break; 2762 break;
2665 case 7: 2763 case 7:
2666 isdn_tty_at_cout("data\r\n", info); 2764 isdn_tty_at_cout("data\r\n", info);
2667 break; 2765 break;
2668 default: 2766 default:
2669 sprintf(s, "%d\r\n", info->last_si); 2767 sprintf(s, "%d\r\n", info->last_si);
2670 isdn_tty_at_cout(s, info); 2768 isdn_tty_at_cout(s, info);
2671 break; 2769 break;
2672 } 2770 }
2673 sprintf(s, " Hangup location: %s\r\n", info->last_lhup ? "local" : "remote"); 2771 sprintf(s, " Hangup location: %s\r\n", info->last_lhup ? "local" : "remote");
2674 isdn_tty_at_cout(s, info); 2772 isdn_tty_at_cout(s, info);
@@ -2680,7 +2778,7 @@ isdn_tty_report(modem_info *info)
2680 * Parse AT&.. commands. 2778 * Parse AT&.. commands.
2681 */ 2779 */
2682static int 2780static int
2683isdn_tty_cmd_ATand(char **p, modem_info *info) 2781isdn_tty_cmd_ATand(char **p, modem_info * info)
2684{ 2782{
2685 atemu *m = &info->emu; 2783 atemu *m = &info->emu;
2686 int i; 2784 int i;
@@ -2689,224 +2787,224 @@ isdn_tty_cmd_ATand(char **p, modem_info *info)
2689#define MAXRB (sizeof(rb) - 1) 2787#define MAXRB (sizeof(rb) - 1)
2690 2788
2691 switch (*p[0]) { 2789 switch (*p[0]) {
2692 case 'B': 2790 case 'B':
2693 /* &B - Set Buffersize */ 2791 /* &B - Set Buffersize */
2694 p[0]++; 2792 p[0]++;
2695 i = isdn_getnum(p); 2793 i = isdn_getnum(p);
2696 if ((i < 0) || (i > ISDN_SERIAL_XMIT_MAX)) 2794 if ((i < 0) || (i > ISDN_SERIAL_XMIT_MAX))
2697 PARSE_ERROR1; 2795 PARSE_ERROR1;
2698#ifdef CONFIG_ISDN_AUDIO 2796#ifdef CONFIG_ISDN_AUDIO
2699 if ((m->mdmreg[REG_SI1] & 1) && (i > VBUF)) 2797 if ((m->mdmreg[REG_SI1] & 1) && (i > VBUF))
2700 PARSE_ERROR1; 2798 PARSE_ERROR1;
2701#endif 2799#endif
2702 m->mdmreg[REG_PSIZE] = i / 16; 2800 m->mdmreg[REG_PSIZE] = i / 16;
2703 info->xmit_size = m->mdmreg[REG_PSIZE] * 16; 2801 info->xmit_size = m->mdmreg[REG_PSIZE] * 16;
2704 switch (m->mdmreg[REG_L2PROT]) { 2802 switch (m->mdmreg[REG_L2PROT]) {
2705 case ISDN_PROTO_L2_V11096: 2803 case ISDN_PROTO_L2_V11096:
2706 case ISDN_PROTO_L2_V11019: 2804 case ISDN_PROTO_L2_V11019:
2707 case ISDN_PROTO_L2_V11038: 2805 case ISDN_PROTO_L2_V11038:
2708 info->xmit_size /= 10; 2806 info->xmit_size /= 10;
2709 } 2807 }
2710 break;
2711 case 'C':
2712 /* &C - DCD Status */
2713 p[0]++;
2714 switch (isdn_getnum(p)) {
2715 case 0:
2716 m->mdmreg[REG_DCD] &= ~BIT_DCD;
2717 break; 2808 break;
2718 case 1: 2809 case 'C':
2719 m->mdmreg[REG_DCD] |= BIT_DCD; 2810 /* &C - DCD Status */
2811 p[0]++;
2812 switch (isdn_getnum(p)) {
2813 case 0:
2814 m->mdmreg[REG_DCD] &= ~BIT_DCD;
2815 break;
2816 case 1:
2817 m->mdmreg[REG_DCD] |= BIT_DCD;
2818 break;
2819 default:
2820 PARSE_ERROR1
2821 }
2720 break; 2822 break;
2721 default: 2823 case 'D':
2722 PARSE_ERROR1 2824 /* &D - Set DTR-Low-behavior */
2723 } 2825 p[0]++;
2724 break; 2826 switch (isdn_getnum(p)) {
2725 case 'D': 2827 case 0:
2726 /* &D - Set DTR-Low-behavior */ 2828 m->mdmreg[REG_DTRHUP] &= ~BIT_DTRHUP;
2727 p[0]++; 2829 m->mdmreg[REG_DTRR] &= ~BIT_DTRR;
2728 switch (isdn_getnum(p)) { 2830 break;
2729 case 0: 2831 case 2:
2730 m->mdmreg[REG_DTRHUP] &= ~BIT_DTRHUP; 2832 m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP;
2731 m->mdmreg[REG_DTRR] &= ~BIT_DTRR; 2833 m->mdmreg[REG_DTRR] &= ~BIT_DTRR;
2834 break;
2835 case 3:
2836 m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP;
2837 m->mdmreg[REG_DTRR] |= BIT_DTRR;
2838 break;
2839 default:
2840 PARSE_ERROR1
2841 }
2732 break; 2842 break;
2733 case 2: 2843 case 'E':
2734 m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; 2844 /* &E -Set EAZ/MSN */
2735 m->mdmreg[REG_DTRR] &= ~BIT_DTRR; 2845 p[0]++;
2846 isdn_tty_get_msnstr(m->msn, p);
2736 break; 2847 break;
2737 case 3: 2848 case 'F':
2738 m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; 2849 /* &F -Set Factory-Defaults */
2739 m->mdmreg[REG_DTRR] |= BIT_DTRR; 2850 p[0]++;
2851 if (info->msr & UART_MSR_DCD)
2852 PARSE_ERROR1;
2853 isdn_tty_reset_profile(m);
2854 isdn_tty_modem_reset_regs(info, 1);
2740 break; 2855 break;
2741 default:
2742 PARSE_ERROR1
2743 }
2744 break;
2745 case 'E':
2746 /* &E -Set EAZ/MSN */
2747 p[0]++;
2748 isdn_tty_get_msnstr(m->msn, p);
2749 break;
2750 case 'F':
2751 /* &F -Set Factory-Defaults */
2752 p[0]++;
2753 if (info->msr & UART_MSR_DCD)
2754 PARSE_ERROR1;
2755 isdn_tty_reset_profile(m);
2756 isdn_tty_modem_reset_regs(info, 1);
2757 break;
2758#ifdef DUMMY_HAYES_AT 2856#ifdef DUMMY_HAYES_AT
2759 case 'K': 2857 case 'K':
2760 /* only for be compilant with common scripts */ 2858 /* only for be compilant with common scripts */
2761 /* &K Flowcontrol - no function */ 2859 /* &K Flowcontrol - no function */
2762 p[0]++; 2860 p[0]++;
2763 isdn_getnum(p); 2861 isdn_getnum(p);
2764 break;
2765#endif
2766 case 'L':
2767 /* &L -Set Numbers to listen on */
2768 p[0]++;
2769 i = 0;
2770 while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) &&
2771 (i < ISDN_LMSNLEN - 1))
2772 m->lmsn[i++] = *p[0]++;
2773 m->lmsn[i] = '\0';
2774 break;
2775 case 'R':
2776 /* &R - Set V.110 bitrate adaption */
2777 p[0]++;
2778 i = isdn_getnum(p);
2779 switch (i) {
2780 case 0:
2781 /* Switch off V.110, back to X.75 */
2782 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
2783 m->mdmreg[REG_SI2] = 0;
2784 info->xmit_size = m->mdmreg[REG_PSIZE] * 16;
2785 break;
2786 case 9600:
2787 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11096;
2788 m->mdmreg[REG_SI2] = 197;
2789 info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10;
2790 break;
2791 case 19200:
2792 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11019;
2793 m->mdmreg[REG_SI2] = 199;
2794 info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10;
2795 break; 2862 break;
2796 case 38400: 2863#endif
2797 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11038; 2864 case 'L':
2798 m->mdmreg[REG_SI2] = 198; /* no existing standard for this */ 2865 /* &L -Set Numbers to listen on */
2799 info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; 2866 p[0]++;
2867 i = 0;
2868 while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) &&
2869 (i < ISDN_LMSNLEN - 1))
2870 m->lmsn[i++] = *p[0]++;
2871 m->lmsn[i] = '\0';
2872 break;
2873 case 'R':
2874 /* &R - Set V.110 bitrate adaption */
2875 p[0]++;
2876 i = isdn_getnum(p);
2877 switch (i) {
2878 case 0:
2879 /* Switch off V.110, back to X.75 */
2880 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
2881 m->mdmreg[REG_SI2] = 0;
2882 info->xmit_size = m->mdmreg[REG_PSIZE] * 16;
2883 break;
2884 case 9600:
2885 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11096;
2886 m->mdmreg[REG_SI2] = 197;
2887 info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10;
2888 break;
2889 case 19200:
2890 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11019;
2891 m->mdmreg[REG_SI2] = 199;
2892 info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10;
2893 break;
2894 case 38400:
2895 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11038;
2896 m->mdmreg[REG_SI2] = 198; /* no existing standard for this */
2897 info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10;
2898 break;
2899 default:
2900 PARSE_ERROR1;
2901 }
2902 /* Switch off T.70 */
2903 m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT);
2904 /* Set Service 7 */
2905 m->mdmreg[REG_SI1] |= 4;
2800 break; 2906 break;
2801 default: 2907 case 'S':
2802 PARSE_ERROR1; 2908 /* &S - Set Windowsize */
2803 }
2804 /* Switch off T.70 */
2805 m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT);
2806 /* Set Service 7 */
2807 m->mdmreg[REG_SI1] |= 4;
2808 break;
2809 case 'S':
2810 /* &S - Set Windowsize */
2811 p[0]++;
2812 i = isdn_getnum(p);
2813 if ((i > 0) && (i < 9))
2814 m->mdmreg[REG_WSIZE] = i;
2815 else
2816 PARSE_ERROR1;
2817 break;
2818 case 'V':
2819 /* &V - Show registers */
2820 p[0]++;
2821 isdn_tty_at_cout("\r\n", info);
2822 for (i = 0; i < ISDN_MODEM_NUMREG; i++) {
2823 sprintf(rb, "S%02d=%03d%s", i,
2824 m->mdmreg[i], ((i + 1) % 10) ? " " : "\r\n");
2825 isdn_tty_at_cout(rb, info);
2826 }
2827 sprintf(rb, "\r\nEAZ/MSN: %.50s\r\n",
2828 strlen(m->msn) ? m->msn : "None");
2829 isdn_tty_at_cout(rb, info);
2830 if (strlen(m->lmsn)) {
2831 isdn_tty_at_cout("\r\nListen: ", info);
2832 isdn_tty_at_cout(m->lmsn, info);
2833 isdn_tty_at_cout("\r\n", info);
2834 }
2835 break;
2836 case 'W':
2837 /* &W - Write Profile */
2838 p[0]++;
2839 switch (*p[0]) {
2840 case '0':
2841 p[0]++; 2909 p[0]++;
2842 modem_write_profile(m); 2910 i = isdn_getnum(p);
2911 if ((i > 0) && (i < 9))
2912 m->mdmreg[REG_WSIZE] = i;
2913 else
2914 PARSE_ERROR1;
2843 break; 2915 break;
2844 default: 2916 case 'V':
2845 PARSE_ERROR1; 2917 /* &V - Show registers */
2846 } 2918 p[0]++;
2847 break; 2919 isdn_tty_at_cout("\r\n", info);
2848 case 'X': 2920 for (i = 0; i < ISDN_MODEM_NUMREG; i++) {
2849 /* &X - Switch to BTX-Mode and T.70 */ 2921 sprintf(rb, "S%02d=%03d%s", i,
2850 p[0]++; 2922 m->mdmreg[i], ((i + 1) % 10) ? " " : "\r\n");
2851 switch (isdn_getnum(p)) { 2923 isdn_tty_at_cout(rb, info);
2852 case 0: 2924 }
2853 m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); 2925 sprintf(rb, "\r\nEAZ/MSN: %.50s\r\n",
2854 info->xmit_size = m->mdmreg[REG_PSIZE] * 16; 2926 strlen(m->msn) ? m->msn : "None");
2927 isdn_tty_at_cout(rb, info);
2928 if (strlen(m->lmsn)) {
2929 isdn_tty_at_cout("\r\nListen: ", info);
2930 isdn_tty_at_cout(m->lmsn, info);
2931 isdn_tty_at_cout("\r\n", info);
2932 }
2855 break; 2933 break;
2856 case 1: 2934 case 'W':
2857 m->mdmreg[REG_T70] |= BIT_T70; 2935 /* &W - Write Profile */
2858 m->mdmreg[REG_T70] &= ~BIT_T70_EXT; 2936 p[0]++;
2859 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; 2937 switch (*p[0]) {
2860 info->xmit_size = 112; 2938 case '0':
2861 m->mdmreg[REG_SI1] = 4; 2939 p[0]++;
2862 m->mdmreg[REG_SI2] = 0; 2940 modem_write_profile(m);
2941 break;
2942 default:
2943 PARSE_ERROR1;
2944 }
2863 break; 2945 break;
2864 case 2: 2946 case 'X':
2865 m->mdmreg[REG_T70] |= (BIT_T70 | BIT_T70_EXT); 2947 /* &X - Switch to BTX-Mode and T.70 */
2866 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; 2948 p[0]++;
2867 info->xmit_size = 112; 2949 switch (isdn_getnum(p)) {
2868 m->mdmreg[REG_SI1] = 4; 2950 case 0:
2869 m->mdmreg[REG_SI2] = 0; 2951 m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT);
2952 info->xmit_size = m->mdmreg[REG_PSIZE] * 16;
2953 break;
2954 case 1:
2955 m->mdmreg[REG_T70] |= BIT_T70;
2956 m->mdmreg[REG_T70] &= ~BIT_T70_EXT;
2957 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
2958 info->xmit_size = 112;
2959 m->mdmreg[REG_SI1] = 4;
2960 m->mdmreg[REG_SI2] = 0;
2961 break;
2962 case 2:
2963 m->mdmreg[REG_T70] |= (BIT_T70 | BIT_T70_EXT);
2964 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
2965 info->xmit_size = 112;
2966 m->mdmreg[REG_SI1] = 4;
2967 m->mdmreg[REG_SI2] = 0;
2968 break;
2969 default:
2970 PARSE_ERROR1;
2971 }
2870 break; 2972 break;
2871 default: 2973 default:
2872 PARSE_ERROR1; 2974 PARSE_ERROR1;
2873 }
2874 break;
2875 default:
2876 PARSE_ERROR1;
2877 } 2975 }
2878 return 0; 2976 return 0;
2879} 2977}
2880 2978
2881static int 2979static int
2882isdn_tty_check_ats(int mreg, int mval, modem_info *info, atemu *m) 2980isdn_tty_check_ats(int mreg, int mval, modem_info * info, atemu * m)
2883{ 2981{
2884 /* Some plausibility checks */ 2982 /* Some plausibility checks */
2885 switch (mreg) { 2983 switch (mreg) {
2886 case REG_L2PROT: 2984 case REG_L2PROT:
2887 if (mval > ISDN_PROTO_L2_MAX) 2985 if (mval > ISDN_PROTO_L2_MAX)
2888 return 1; 2986 return 1;
2889 break; 2987 break;
2890 case REG_PSIZE: 2988 case REG_PSIZE:
2891 if ((mval * 16) > ISDN_SERIAL_XMIT_MAX) 2989 if ((mval * 16) > ISDN_SERIAL_XMIT_MAX)
2892 return 1; 2990 return 1;
2893#ifdef CONFIG_ISDN_AUDIO 2991#ifdef CONFIG_ISDN_AUDIO
2894 if ((m->mdmreg[REG_SI1] & 1) && (mval > VBUFX)) 2992 if ((m->mdmreg[REG_SI1] & 1) && (mval > VBUFX))
2895 return 1; 2993 return 1;
2896#endif 2994#endif
2897 info->xmit_size = mval * 16; 2995 info->xmit_size = mval * 16;
2898 switch (m->mdmreg[REG_L2PROT]) { 2996 switch (m->mdmreg[REG_L2PROT]) {
2899 case ISDN_PROTO_L2_V11096: 2997 case ISDN_PROTO_L2_V11096:
2900 case ISDN_PROTO_L2_V11019: 2998 case ISDN_PROTO_L2_V11019:
2901 case ISDN_PROTO_L2_V11038: 2999 case ISDN_PROTO_L2_V11038:
2902 info->xmit_size /= 10; 3000 info->xmit_size /= 10;
2903 } 3001 }
2904 break; 3002 break;
2905 case REG_SI1I: 3003 case REG_SI1I:
2906 case REG_PLAN: 3004 case REG_PLAN:
2907 case REG_SCREEN: 3005 case REG_SCREEN:
2908 /* readonly registers */ 3006 /* readonly registers */
2909 return 1; 3007 return 1;
2910 } 3008 }
2911 return 0; 3009 return 0;
2912} 3010}
@@ -2915,7 +3013,7 @@ isdn_tty_check_ats(int mreg, int mval, modem_info *info, atemu *m)
2915 * Perform ATS command 3013 * Perform ATS command
2916 */ 3014 */
2917static int 3015static int
2918isdn_tty_cmd_ATS(char **p, modem_info *info) 3016isdn_tty_cmd_ATS(char **p, modem_info * info)
2919{ 3017{
2920 atemu *m = &info->emu; 3018 atemu *m = &info->emu;
2921 int bitpos; 3019 int bitpos;
@@ -2927,52 +3025,52 @@ isdn_tty_cmd_ATS(char **p, modem_info *info)
2927 if (mreg < 0 || mreg >= ISDN_MODEM_NUMREG) 3025 if (mreg < 0 || mreg >= ISDN_MODEM_NUMREG)
2928 PARSE_ERROR1; 3026 PARSE_ERROR1;
2929 switch (*p[0]) { 3027 switch (*p[0]) {
2930 case '=':
2931 p[0]++;
2932 mval = isdn_getnum(p);
2933 if (mval < 0 || mval > 255)
2934 PARSE_ERROR1;
2935 if (isdn_tty_check_ats(mreg, mval, info, m))
2936 PARSE_ERROR1;
2937 m->mdmreg[mreg] = mval;
2938 break;
2939 case '.':
2940 /* Set/Clear a single bit */
2941 p[0]++;
2942 bitpos = isdn_getnum(p);
2943 if ((bitpos < 0) || (bitpos > 7))
2944 PARSE_ERROR1;
2945 switch (*p[0]) {
2946 case '=': 3028 case '=':
2947 p[0]++; 3029 p[0]++;
2948 bval = isdn_getnum(p); 3030 mval = isdn_getnum(p);
2949 if (bval < 0 || bval > 1) 3031 if (mval < 0 || mval > 255)
2950 PARSE_ERROR1; 3032 PARSE_ERROR1;
2951 if (bval)
2952 mval = m->mdmreg[mreg] | (1 << bitpos);
2953 else
2954 mval = m->mdmreg[mreg] & ~(1 << bitpos);
2955 if (isdn_tty_check_ats(mreg, mval, info, m)) 3033 if (isdn_tty_check_ats(mreg, mval, info, m))
2956 PARSE_ERROR1; 3034 PARSE_ERROR1;
2957 m->mdmreg[mreg] = mval; 3035 m->mdmreg[mreg] = mval;
2958 break; 3036 break;
3037 case '.':
3038 /* Set/Clear a single bit */
3039 p[0]++;
3040 bitpos = isdn_getnum(p);
3041 if ((bitpos < 0) || (bitpos > 7))
3042 PARSE_ERROR1;
3043 switch (*p[0]) {
3044 case '=':
3045 p[0]++;
3046 bval = isdn_getnum(p);
3047 if (bval < 0 || bval > 1)
3048 PARSE_ERROR1;
3049 if (bval)
3050 mval = m->mdmreg[mreg] | (1 << bitpos);
3051 else
3052 mval = m->mdmreg[mreg] & ~(1 << bitpos);
3053 if (isdn_tty_check_ats(mreg, mval, info, m))
3054 PARSE_ERROR1;
3055 m->mdmreg[mreg] = mval;
3056 break;
3057 case '?':
3058 p[0]++;
3059 isdn_tty_at_cout("\r\n", info);
3060 isdn_tty_at_cout((m->mdmreg[mreg] & (1 << bitpos)) ? "1" : "0",
3061 info);
3062 break;
3063 default:
3064 PARSE_ERROR1;
3065 }
3066 break;
2959 case '?': 3067 case '?':
2960 p[0]++; 3068 p[0]++;
2961 isdn_tty_at_cout("\r\n", info); 3069 isdn_tty_show_profile(mreg, info);
2962 isdn_tty_at_cout((m->mdmreg[mreg] & (1 << bitpos)) ? "1" : "0",
2963 info);
2964 break; 3070 break;
2965 default: 3071 default:
2966 PARSE_ERROR1; 3072 PARSE_ERROR1;
2967 } 3073 break;
2968 break;
2969 case '?':
2970 p[0]++;
2971 isdn_tty_show_profile(mreg, info);
2972 break;
2973 default:
2974 PARSE_ERROR1;
2975 break;
2976 } 3074 }
2977 return 0; 3075 return 0;
2978} 3076}
@@ -2981,7 +3079,7 @@ isdn_tty_cmd_ATS(char **p, modem_info *info)
2981 * Perform ATA command 3079 * Perform ATA command
2982 */ 3080 */
2983static void 3081static void
2984isdn_tty_cmd_ATA(modem_info *info) 3082isdn_tty_cmd_ATA(modem_info * info)
2985{ 3083{
2986 atemu *m = &info->emu; 3084 atemu *m = &info->emu;
2987 isdn_ctrl cmd; 3085 isdn_ctrl cmd;
@@ -3035,7 +3133,7 @@ isdn_tty_cmd_ATA(modem_info *info)
3035 * Parse AT+F.. commands 3133 * Parse AT+F.. commands
3036 */ 3134 */
3037static int 3135static int
3038isdn_tty_cmd_PLUSF(char **p, modem_info *info) 3136isdn_tty_cmd_PLUSF(char **p, modem_info * info)
3039{ 3137{
3040 atemu *m = &info->emu; 3138 atemu *m = &info->emu;
3041 char rs[20]; 3139 char rs[20];
@@ -3043,81 +3141,81 @@ isdn_tty_cmd_PLUSF(char **p, modem_info *info)
3043 if (!strncmp(p[0], "CLASS", 5)) { 3141 if (!strncmp(p[0], "CLASS", 5)) {
3044 p[0] += 5; 3142 p[0] += 5;
3045 switch (*p[0]) { 3143 switch (*p[0]) {
3046 case '?': 3144 case '?':
3047 p[0]++;
3048 sprintf(rs, "\r\n%d",
3049 (m->mdmreg[REG_SI1] & 1) ? 8 : 0);
3050#ifdef CONFIG_ISDN_TTY_FAX
3051 if (TTY_IS_FCLASS2(info))
3052 sprintf(rs, "\r\n2");
3053 else if (TTY_IS_FCLASS1(info))
3054 sprintf(rs, "\r\n1");
3055#endif
3056 isdn_tty_at_cout(rs, info);
3057 break;
3058 case '=':
3059 p[0]++;
3060 switch (*p[0]) {
3061 case '0':
3062 p[0]++; 3145 p[0]++;
3063 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; 3146 sprintf(rs, "\r\n%d",
3064 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; 3147 (m->mdmreg[REG_SI1] & 1) ? 8 : 0);
3065 m->mdmreg[REG_SI1] = 4;
3066 info->xmit_size =
3067 m->mdmreg[REG_PSIZE] * 16;
3068 break;
3069#ifdef CONFIG_ISDN_TTY_FAX 3148#ifdef CONFIG_ISDN_TTY_FAX
3070 case '1': 3149 if (TTY_IS_FCLASS2(info))
3071 p[0]++; 3150 sprintf(rs, "\r\n2");
3072 if (!(dev->global_features & 3151 else if (TTY_IS_FCLASS1(info))
3073 ISDN_FEATURE_L3_FCLASS1)) 3152 sprintf(rs, "\r\n1");
3074 PARSE_ERROR1;
3075 m->mdmreg[REG_SI1] = 1;
3076 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX;
3077 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS1;
3078 info->xmit_size =
3079 m->mdmreg[REG_PSIZE] * 16;
3080 break;
3081 case '2':
3082 p[0]++;
3083 if (!(dev->global_features &
3084 ISDN_FEATURE_L3_FCLASS2))
3085 PARSE_ERROR1;
3086 m->mdmreg[REG_SI1] = 1;
3087 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX;
3088 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS2;
3089 info->xmit_size =
3090 m->mdmreg[REG_PSIZE] * 16;
3091 break;
3092#endif 3153#endif
3093 case '8': 3154 isdn_tty_at_cout(rs, info);
3094 p[0]++;
3095 /* L2 will change on dialout with si=1 */
3096 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
3097 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS;
3098 m->mdmreg[REG_SI1] = 5;
3099 info->xmit_size = VBUF;
3100 break; 3155 break;
3101 case '?': 3156 case '=':
3102 p[0]++; 3157 p[0]++;
3103 strcpy(rs, "\r\n0,"); 3158 switch (*p[0]) {
3159 case '0':
3160 p[0]++;
3161 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
3162 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS;
3163 m->mdmreg[REG_SI1] = 4;
3164 info->xmit_size =
3165 m->mdmreg[REG_PSIZE] * 16;
3166 break;
3104#ifdef CONFIG_ISDN_TTY_FAX 3167#ifdef CONFIG_ISDN_TTY_FAX
3105 if (dev->global_features & 3168 case '1':
3106 ISDN_FEATURE_L3_FCLASS1) 3169 p[0]++;
3107 strcat(rs, "1,"); 3170 if (!(dev->global_features &
3108 if (dev->global_features & 3171 ISDN_FEATURE_L3_FCLASS1))
3109 ISDN_FEATURE_L3_FCLASS2) 3172 PARSE_ERROR1;
3110 strcat(rs, "2,"); 3173 m->mdmreg[REG_SI1] = 1;
3111#endif 3174 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX;
3112 strcat(rs, "8"); 3175 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS1;
3113 isdn_tty_at_cout(rs, info); 3176 info->xmit_size =
3177 m->mdmreg[REG_PSIZE] * 16;
3178 break;
3179 case '2':
3180 p[0]++;
3181 if (!(dev->global_features &
3182 ISDN_FEATURE_L3_FCLASS2))
3183 PARSE_ERROR1;
3184 m->mdmreg[REG_SI1] = 1;
3185 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX;
3186 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS2;
3187 info->xmit_size =
3188 m->mdmreg[REG_PSIZE] * 16;
3189 break;
3190#endif
3191 case '8':
3192 p[0]++;
3193 /* L2 will change on dialout with si=1 */
3194 m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I;
3195 m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS;
3196 m->mdmreg[REG_SI1] = 5;
3197 info->xmit_size = VBUF;
3198 break;
3199 case '?':
3200 p[0]++;
3201 strcpy(rs, "\r\n0,");
3202#ifdef CONFIG_ISDN_TTY_FAX
3203 if (dev->global_features &
3204 ISDN_FEATURE_L3_FCLASS1)
3205 strcat(rs, "1,");
3206 if (dev->global_features &
3207 ISDN_FEATURE_L3_FCLASS2)
3208 strcat(rs, "2,");
3209#endif
3210 strcat(rs, "8");
3211 isdn_tty_at_cout(rs, info);
3212 break;
3213 default:
3214 PARSE_ERROR1;
3215 }
3114 break; 3216 break;
3115 default: 3217 default:
3116 PARSE_ERROR1; 3218 PARSE_ERROR1;
3117 }
3118 break;
3119 default:
3120 PARSE_ERROR1;
3121 } 3219 }
3122 return 0; 3220 return 0;
3123 } 3221 }
@@ -3132,12 +3230,12 @@ isdn_tty_cmd_PLUSF(char **p, modem_info *info)
3132 * Parse AT+V.. commands 3230 * Parse AT+V.. commands
3133 */ 3231 */
3134static int 3232static int
3135isdn_tty_cmd_PLUSV(char **p, modem_info *info) 3233isdn_tty_cmd_PLUSV(char **p, modem_info * info)
3136{ 3234{
3137 atemu *m = &info->emu; 3235 atemu *m = &info->emu;
3138 isdn_ctrl cmd; 3236 isdn_ctrl cmd;
3139 static char *vcmd[] = 3237 static char *vcmd[] =
3140 {"NH", "IP", "LS", "RX", "SD", "SM", "TX", "DD", NULL}; 3238 {"NH", "IP", "LS", "RX", "SD", "SM", "TX", "DD", NULL};
3141 int i; 3239 int i;
3142 int par1; 3240 int par1;
3143 int par2; 3241 int par2;
@@ -3152,256 +3250,256 @@ isdn_tty_cmd_PLUSV(char **p, modem_info *info)
3152 i++; 3250 i++;
3153 } 3251 }
3154 switch (i) { 3252 switch (i) {
3155 case 0: 3253 case 0:
3156 /* AT+VNH - Auto hangup feature */ 3254 /* AT+VNH - Auto hangup feature */
3157 switch (*p[0]) {
3158 case '?':
3159 p[0]++;
3160 isdn_tty_at_cout("\r\n1", info);
3161 break;
3162 case '=':
3163 p[0]++;
3164 switch (*p[0]) { 3255 switch (*p[0]) {
3165 case '1': 3256 case '?':
3166 p[0]++; 3257 p[0]++;
3167 break; 3258 isdn_tty_at_cout("\r\n1", info);
3168 case '?': 3259 break;
3169 p[0]++; 3260 case '=':
3170 isdn_tty_at_cout("\r\n1", info); 3261 p[0]++;
3171 break; 3262 switch (*p[0]) {
3172 default: 3263 case '1':
3173 PARSE_ERROR1; 3264 p[0]++;
3265 break;
3266 case '?':
3267 p[0]++;
3268 isdn_tty_at_cout("\r\n1", info);
3269 break;
3270 default:
3271 PARSE_ERROR1;
3272 }
3273 break;
3274 default:
3275 PARSE_ERROR1;
3174 } 3276 }
3175 break; 3277 break;
3176 default: 3278 case 1:
3177 PARSE_ERROR1; 3279 /* AT+VIP - Reset all voice parameters */
3178 } 3280 isdn_tty_modem_reset_vpar(m);
3179 break;
3180 case 1:
3181 /* AT+VIP - Reset all voice parameters */
3182 isdn_tty_modem_reset_vpar(m);
3183 break;
3184 case 2:
3185 /* AT+VLS - Select device, accept incoming call */
3186 switch (*p[0]) {
3187 case '?':
3188 p[0]++;
3189 sprintf(rs, "\r\n%d", m->vpar[0]);
3190 isdn_tty_at_cout(rs, info);
3191 break; 3281 break;
3192 case '=': 3282 case 2:
3193 p[0]++; 3283 /* AT+VLS - Select device, accept incoming call */
3194 switch (*p[0]) { 3284 switch (*p[0]) {
3195 case '0': 3285 case '?':
3196 p[0]++; 3286 p[0]++;
3197 m->vpar[0] = 0; 3287 sprintf(rs, "\r\n%d", m->vpar[0]);
3198 break; 3288 isdn_tty_at_cout(rs, info);
3199 case '2': 3289 break;
3200 p[0]++; 3290 case '=':
3201 m->vpar[0] = 2; 3291 p[0]++;
3202 break; 3292 switch (*p[0]) {
3203 case '?': 3293 case '0':
3204 p[0]++; 3294 p[0]++;
3205 isdn_tty_at_cout("\r\n0,2", info); 3295 m->vpar[0] = 0;
3206 break; 3296 break;
3207 default: 3297 case '2':
3208 PARSE_ERROR1; 3298 p[0]++;
3299 m->vpar[0] = 2;
3300 break;
3301 case '?':
3302 p[0]++;
3303 isdn_tty_at_cout("\r\n0,2", info);
3304 break;
3305 default:
3306 PARSE_ERROR1;
3307 }
3308 break;
3309 default:
3310 PARSE_ERROR1;
3209 } 3311 }
3210 break; 3312 break;
3211 default: 3313 case 3:
3212 PARSE_ERROR1; 3314 /* AT+VRX - Start recording */
3213 } 3315 if (!m->vpar[0])
3214 break;
3215 case 3:
3216 /* AT+VRX - Start recording */
3217 if (!m->vpar[0])
3218 PARSE_ERROR1;
3219 if (info->online != 1) {
3220 isdn_tty_modem_result(RESULT_NO_ANSWER, info);
3221 return 1;
3222 }
3223 info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state);
3224 if (!info->dtmf_state) {
3225 printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n");
3226 PARSE_ERROR1;
3227 }
3228 info->silence_state = isdn_audio_silence_init(info->silence_state);
3229 if (!info->silence_state) {
3230 printk(KERN_WARNING "isdn_tty: Couldn't malloc silence state\n");
3231 PARSE_ERROR1;
3232 }
3233 if (m->vpar[3] < 5) {
3234 info->adpcmr = isdn_audio_adpcm_init(info->adpcmr, m->vpar[3]);
3235 if (!info->adpcmr) {
3236 printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n");
3237 PARSE_ERROR1; 3316 PARSE_ERROR1;
3317 if (info->online != 1) {
3318 isdn_tty_modem_result(RESULT_NO_ANSWER, info);
3319 return 1;
3320 }
3321 info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state);
3322 if (!info->dtmf_state) {
3323 printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n");
3324 PARSE_ERROR1;
3325 }
3326 info->silence_state = isdn_audio_silence_init(info->silence_state);
3327 if (!info->silence_state) {
3328 printk(KERN_WARNING "isdn_tty: Couldn't malloc silence state\n");
3329 PARSE_ERROR1;
3330 }
3331 if (m->vpar[3] < 5) {
3332 info->adpcmr = isdn_audio_adpcm_init(info->adpcmr, m->vpar[3]);
3333 if (!info->adpcmr) {
3334 printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n");
3335 PARSE_ERROR1;
3336 }
3238 } 3337 }
3239 }
3240#ifdef ISDN_DEBUG_AT 3338#ifdef ISDN_DEBUG_AT
3241 printk(KERN_DEBUG "AT: +VRX\n"); 3339 printk(KERN_DEBUG "AT: +VRX\n");
3242#endif 3340#endif
3243 info->vonline |= 1; 3341 info->vonline |= 1;
3244 isdn_tty_modem_result(RESULT_CONNECT, info); 3342 isdn_tty_modem_result(RESULT_CONNECT, info);
3245 return 0; 3343 return 0;
3246 break;
3247 case 4:
3248 /* AT+VSD - Silence detection */
3249 switch (*p[0]) {
3250 case '?':
3251 p[0]++;
3252 sprintf(rs, "\r\n<%d>,<%d>",
3253 m->vpar[1],
3254 m->vpar[2]);
3255 isdn_tty_at_cout(rs, info);
3256 break; 3344 break;
3257 case '=': 3345 case 4:
3258 p[0]++; 3346 /* AT+VSD - Silence detection */
3259 if ((*p[0] >= '0') && (*p[0] <= '9')) { 3347 switch (*p[0]) {
3260 par1 = isdn_getnum(p); 3348 case '?':
3261 if ((par1 < 0) || (par1 > 31))
3262 PARSE_ERROR1;
3263 if (*p[0] != ',')
3264 PARSE_ERROR1;
3265 p[0]++;
3266 par2 = isdn_getnum(p);
3267 if ((par2 < 0) || (par2 > 255))
3268 PARSE_ERROR1;
3269 m->vpar[1] = par1;
3270 m->vpar[2] = par2;
3271 break;
3272 } else
3273 if (*p[0] == '?') {
3274 p[0]++; 3349 p[0]++;
3275 isdn_tty_at_cout("\r\n<0-31>,<0-255>", 3350 sprintf(rs, "\r\n<%d>,<%d>",
3276 info); 3351 m->vpar[1],
3352 m->vpar[2]);
3353 isdn_tty_at_cout(rs, info);
3277 break; 3354 break;
3278 } else 3355 case '=':
3356 p[0]++;
3357 if ((*p[0]>='0') && (*p[0]<='9')) {
3358 par1 = isdn_getnum(p);
3359 if ((par1 < 0) || (par1 > 31))
3360 PARSE_ERROR1;
3361 if (*p[0] != ',')
3362 PARSE_ERROR1;
3363 p[0]++;
3364 par2 = isdn_getnum(p);
3365 if ((par2 < 0) || (par2 > 255))
3366 PARSE_ERROR1;
3367 m->vpar[1] = par1;
3368 m->vpar[2] = par2;
3369 break;
3370 } else
3371 if (*p[0] == '?') {
3372 p[0]++;
3373 isdn_tty_at_cout("\r\n<0-31>,<0-255>",
3374 info);
3375 break;
3376 } else
3279 PARSE_ERROR1; 3377 PARSE_ERROR1;
3378 break;
3379 default:
3380 PARSE_ERROR1;
3381 }
3280 break; 3382 break;
3281 default: 3383 case 5:
3282 PARSE_ERROR1; 3384 /* AT+VSM - Select compression */
3283 }
3284 break;
3285 case 5:
3286 /* AT+VSM - Select compression */
3287 switch (*p[0]) {
3288 case '?':
3289 p[0]++;
3290 sprintf(rs, "\r\n<%d>,<%d><8000>",
3291 m->vpar[3],
3292 m->vpar[1]);
3293 isdn_tty_at_cout(rs, info);
3294 break;
3295 case '=':
3296 p[0]++;
3297 switch (*p[0]) { 3385 switch (*p[0]) {
3298 case '2': 3386 case '?':
3299 case '3': 3387 p[0]++;
3300 case '4': 3388 sprintf(rs, "\r\n<%d>,<%d><8000>",
3301 case '5': 3389 m->vpar[3],
3302 case '6': 3390 m->vpar[1]);
3303 par1 = isdn_getnum(p); 3391 isdn_tty_at_cout(rs, info);
3304 if ((par1 < 2) || (par1 > 6)) 3392 break;
3393 case '=':
3394 p[0]++;
3395 switch (*p[0]) {
3396 case '2':
3397 case '3':
3398 case '4':
3399 case '5':
3400 case '6':
3401 par1 = isdn_getnum(p);
3402 if ((par1 < 2) || (par1 > 6))
3403 PARSE_ERROR1;
3404 m->vpar[3] = par1;
3405 break;
3406 case '?':
3407 p[0]++;
3408 isdn_tty_at_cout("\r\n2;ADPCM;2;0;(8000)\r\n",
3409 info);
3410 isdn_tty_at_cout("3;ADPCM;3;0;(8000)\r\n",
3411 info);
3412 isdn_tty_at_cout("4;ADPCM;4;0;(8000)\r\n",
3413 info);
3414 isdn_tty_at_cout("5;ALAW;8;0;(8000)\r\n",
3415 info);
3416 isdn_tty_at_cout("6;ULAW;8;0;(8000)\r\n",
3417 info);
3418 break;
3419 default:
3420 PARSE_ERROR1;
3421 }
3422 break;
3423 default:
3305 PARSE_ERROR1; 3424 PARSE_ERROR1;
3306 m->vpar[3] = par1;
3307 break;
3308 case '?':
3309 p[0]++;
3310 isdn_tty_at_cout("\r\n2;ADPCM;2;0;(8000)\r\n",
3311 info);
3312 isdn_tty_at_cout("3;ADPCM;3;0;(8000)\r\n",
3313 info);
3314 isdn_tty_at_cout("4;ADPCM;4;0;(8000)\r\n",
3315 info);
3316 isdn_tty_at_cout("5;ALAW;8;0;(8000)\r\n",
3317 info);
3318 isdn_tty_at_cout("6;ULAW;8;0;(8000)\r\n",
3319 info);
3320 break;
3321 default:
3322 PARSE_ERROR1;
3323 } 3425 }
3324 break; 3426 break;
3325 default: 3427 case 6:
3326 PARSE_ERROR1; 3428 /* AT+VTX - Start sending */
3327 } 3429 if (!m->vpar[0])
3328 break;
3329 case 6:
3330 /* AT+VTX - Start sending */
3331 if (!m->vpar[0])
3332 PARSE_ERROR1;
3333 if (info->online != 1) {
3334 isdn_tty_modem_result(RESULT_NO_ANSWER, info);
3335 return 1;
3336 }
3337 info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state);
3338 if (!info->dtmf_state) {
3339 printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n");
3340 PARSE_ERROR1;
3341 }
3342 if (m->vpar[3] < 5) {
3343 info->adpcms = isdn_audio_adpcm_init(info->adpcms, m->vpar[3]);
3344 if (!info->adpcms) {
3345 printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n");
3346 PARSE_ERROR1; 3430 PARSE_ERROR1;
3431 if (info->online != 1) {
3432 isdn_tty_modem_result(RESULT_NO_ANSWER, info);
3433 return 1;
3434 }
3435 info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state);
3436 if (!info->dtmf_state) {
3437 printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n");
3438 PARSE_ERROR1;
3439 }
3440 if (m->vpar[3] < 5) {
3441 info->adpcms = isdn_audio_adpcm_init(info->adpcms, m->vpar[3]);
3442 if (!info->adpcms) {
3443 printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n");
3444 PARSE_ERROR1;
3445 }
3347 } 3446 }
3348 }
3349#ifdef ISDN_DEBUG_AT 3447#ifdef ISDN_DEBUG_AT
3350 printk(KERN_DEBUG "AT: +VTX\n"); 3448 printk(KERN_DEBUG "AT: +VTX\n");
3351#endif 3449#endif
3352 m->lastDLE = 0; 3450 m->lastDLE = 0;
3353 info->vonline |= 2; 3451 info->vonline |= 2;
3354 isdn_tty_modem_result(RESULT_CONNECT, info); 3452 isdn_tty_modem_result(RESULT_CONNECT, info);
3355 return 0; 3453 return 0;
3356 break;
3357 case 7:
3358 /* AT+VDD - DTMF detection */
3359 switch (*p[0]) {
3360 case '?':
3361 p[0]++;
3362 sprintf(rs, "\r\n<%d>,<%d>",
3363 m->vpar[4],
3364 m->vpar[5]);
3365 isdn_tty_at_cout(rs, info);
3366 break; 3454 break;
3367 case '=': 3455 case 7:
3368 p[0]++; 3456 /* AT+VDD - DTMF detection */
3369 if ((*p[0] >= '0') && (*p[0] <= '9')) { 3457 switch (*p[0]) {
3370 if (info->online != 1) 3458 case '?':
3371 PARSE_ERROR1;
3372 par1 = isdn_getnum(p);
3373 if ((par1 < 0) || (par1 > 15))
3374 PARSE_ERROR1;
3375 if (*p[0] != ',')
3376 PARSE_ERROR1;
3377 p[0]++;
3378 par2 = isdn_getnum(p);
3379 if ((par2 < 0) || (par2 > 255))
3380 PARSE_ERROR1;
3381 m->vpar[4] = par1;
3382 m->vpar[5] = par2;
3383 cmd.driver = info->isdn_driver;
3384 cmd.command = ISDN_CMD_AUDIO;
3385 cmd.arg = info->isdn_channel + (ISDN_AUDIO_SETDD << 8);
3386 cmd.parm.num[0] = par1;
3387 cmd.parm.num[1] = par2;
3388 isdn_command(&cmd);
3389 break;
3390 } else
3391 if (*p[0] == '?') {
3392 p[0]++; 3459 p[0]++;
3393 isdn_tty_at_cout("\r\n<0-15>,<0-255>", 3460 sprintf(rs, "\r\n<%d>,<%d>",
3394 info); 3461 m->vpar[4],
3462 m->vpar[5]);
3463 isdn_tty_at_cout(rs, info);
3395 break; 3464 break;
3396 } else 3465 case '=':
3466 p[0]++;
3467 if ((*p[0]>='0') && (*p[0]<='9')) {
3468 if (info->online != 1)
3469 PARSE_ERROR1;
3470 par1 = isdn_getnum(p);
3471 if ((par1 < 0) || (par1 > 15))
3472 PARSE_ERROR1;
3473 if (*p[0] != ',')
3474 PARSE_ERROR1;
3475 p[0]++;
3476 par2 = isdn_getnum(p);
3477 if ((par2 < 0) || (par2 > 255))
3478 PARSE_ERROR1;
3479 m->vpar[4] = par1;
3480 m->vpar[5] = par2;
3481 cmd.driver = info->isdn_driver;
3482 cmd.command = ISDN_CMD_AUDIO;
3483 cmd.arg = info->isdn_channel + (ISDN_AUDIO_SETDD << 8);
3484 cmd.parm.num[0] = par1;
3485 cmd.parm.num[1] = par2;
3486 isdn_command(&cmd);
3487 break;
3488 } else
3489 if (*p[0] == '?') {
3490 p[0]++;
3491 isdn_tty_at_cout("\r\n<0-15>,<0-255>",
3492 info);
3493 break;
3494 } else
3495 PARSE_ERROR1;
3496 break;
3497 default:
3397 PARSE_ERROR1; 3498 PARSE_ERROR1;
3499 }
3398 break; 3500 break;
3399 default: 3501 default:
3400 PARSE_ERROR1; 3502 PARSE_ERROR1;
3401 }
3402 break;
3403 default:
3404 PARSE_ERROR1;
3405 } 3503 }
3406 return 0; 3504 return 0;
3407} 3505}
@@ -3411,7 +3509,7 @@ isdn_tty_cmd_PLUSV(char **p, modem_info *info)
3411 * Parse and perform an AT-command-line. 3509 * Parse and perform an AT-command-line.
3412 */ 3510 */
3413static void 3511static void
3414isdn_tty_parse_at(modem_info *info) 3512isdn_tty_parse_at(modem_info * info)
3415{ 3513{
3416 atemu *m = &info->emu; 3514 atemu *m = &info->emu;
3417 char *p; 3515 char *p;
@@ -3422,188 +3520,188 @@ isdn_tty_parse_at(modem_info *info)
3422#endif 3520#endif
3423 for (p = &m->mdmcmd[2]; *p;) { 3521 for (p = &m->mdmcmd[2]; *p;) {
3424 switch (*p) { 3522 switch (*p) {
3425 case ' ': 3523 case ' ':
3426 p++;
3427 break;
3428 case 'A':
3429 /* A - Accept incoming call */
3430 p++;
3431 isdn_tty_cmd_ATA(info);
3432 return;
3433 break;
3434 case 'D':
3435 /* D - Dial */
3436 if (info->msr & UART_MSR_DCD)
3437 PARSE_ERROR;
3438 if (info->msr & UART_MSR_RI) {
3439 isdn_tty_modem_result(RESULT_NO_CARRIER, info);
3440 return;
3441 }
3442 isdn_tty_getdial(++p, ds, sizeof ds);
3443 p += strlen(p);
3444 if (!strlen(m->msn))
3445 isdn_tty_modem_result(RESULT_NO_MSN_EAZ, info);
3446 else if (strlen(ds))
3447 isdn_tty_dial(ds, info, m);
3448 else
3449 PARSE_ERROR;
3450 return;
3451 case 'E':
3452 /* E - Turn Echo on/off */
3453 p++;
3454 switch (isdn_getnum(&p)) {
3455 case 0:
3456 m->mdmreg[REG_ECHO] &= ~BIT_ECHO;
3457 break;
3458 case 1:
3459 m->mdmreg[REG_ECHO] |= BIT_ECHO;
3460 break;
3461 default:
3462 PARSE_ERROR;
3463 }
3464 break;
3465 case 'H':
3466 /* H - On/Off-hook */
3467 p++;
3468 switch (*p) {
3469 case '0':
3470 p++; 3524 p++;
3471 isdn_tty_on_hook(info);
3472 break; 3525 break;
3473 case '1': 3526 case 'A':
3527 /* A - Accept incoming call */
3474 p++; 3528 p++;
3475 isdn_tty_off_hook(); 3529 isdn_tty_cmd_ATA(info);
3476 break; 3530 return;
3477 default:
3478 isdn_tty_on_hook(info);
3479 break; 3531 break;
3480 } 3532 case 'D':
3481 break; 3533 /* D - Dial */
3482 case 'I': 3534 if (info->msr & UART_MSR_DCD)
3483 /* I - Information */ 3535 PARSE_ERROR;
3484 p++; 3536 if (info->msr & UART_MSR_RI) {
3485 isdn_tty_at_cout("\r\nLinux ISDN", info); 3537 isdn_tty_modem_result(RESULT_NO_CARRIER, info);
3486 switch (*p) { 3538 return;
3487 case '0': 3539 }
3488 case '1': 3540 isdn_tty_getdial(++p, ds, sizeof ds);
3541 p += strlen(p);
3542 if (!strlen(m->msn))
3543 isdn_tty_modem_result(RESULT_NO_MSN_EAZ, info);
3544 else if (strlen(ds))
3545 isdn_tty_dial(ds, info, m);
3546 else
3547 PARSE_ERROR;
3548 return;
3549 case 'E':
3550 /* E - Turn Echo on/off */
3489 p++; 3551 p++;
3552 switch (isdn_getnum(&p)) {
3553 case 0:
3554 m->mdmreg[REG_ECHO] &= ~BIT_ECHO;
3555 break;
3556 case 1:
3557 m->mdmreg[REG_ECHO] |= BIT_ECHO;
3558 break;
3559 default:
3560 PARSE_ERROR;
3561 }
3490 break; 3562 break;
3491 case '2': 3563 case 'H':
3564 /* H - On/Off-hook */
3492 p++; 3565 p++;
3493 isdn_tty_report(info); 3566 switch (*p) {
3567 case '0':
3568 p++;
3569 isdn_tty_on_hook(info);
3570 break;
3571 case '1':
3572 p++;
3573 isdn_tty_off_hook();
3574 break;
3575 default:
3576 isdn_tty_on_hook(info);
3577 break;
3578 }
3494 break; 3579 break;
3495 case '3': 3580 case 'I':
3581 /* I - Information */
3496 p++; 3582 p++;
3497 snprintf(ds, sizeof(ds), "\r\n%d", info->emu.charge); 3583 isdn_tty_at_cout("\r\nLinux ISDN", info);
3498 isdn_tty_at_cout(ds, info); 3584 switch (*p) {
3585 case '0':
3586 case '1':
3587 p++;
3588 break;
3589 case '2':
3590 p++;
3591 isdn_tty_report(info);
3592 break;
3593 case '3':
3594 p++;
3595 snprintf(ds, sizeof(ds), "\r\n%d", info->emu.charge);
3596 isdn_tty_at_cout(ds, info);
3597 break;
3598 default:;
3599 }
3499 break; 3600 break;
3500 default:;
3501 }
3502 break;
3503#ifdef DUMMY_HAYES_AT 3601#ifdef DUMMY_HAYES_AT
3504 case 'L': 3602 case 'L':
3505 case 'M': 3603 case 'M':
3506 /* only for be compilant with common scripts */ 3604 /* only for be compilant with common scripts */
3507 /* no function */ 3605 /* no function */
3508 p++; 3606 p++;
3509 isdn_getnum(&p); 3607 isdn_getnum(&p);
3510 break;
3511#endif
3512 case 'O':
3513 /* O - Go online */
3514 p++;
3515 if (info->msr & UART_MSR_DCD)
3516 /* if B-Channel is up */
3517 isdn_tty_modem_result((m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) ? RESULT_CONNECT : RESULT_CONNECT64000, info);
3518 else
3519 isdn_tty_modem_result(RESULT_NO_CARRIER, info);
3520 return;
3521 case 'Q':
3522 /* Q - Turn Emulator messages on/off */
3523 p++;
3524 switch (isdn_getnum(&p)) {
3525 case 0:
3526 m->mdmreg[REG_RESP] |= BIT_RESP;
3527 break;
3528 case 1:
3529 m->mdmreg[REG_RESP] &= ~BIT_RESP;
3530 break; 3608 break;
3531 default: 3609#endif
3532 PARSE_ERROR; 3610 case 'O':
3533 } 3611 /* O - Go online */
3534 break; 3612 p++;
3535 case 'S': 3613 if (info->msr & UART_MSR_DCD)
3536 /* S - Set/Get Register */ 3614 /* if B-Channel is up */
3537 p++; 3615 isdn_tty_modem_result((m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) ? RESULT_CONNECT:RESULT_CONNECT64000, info);
3538 if (isdn_tty_cmd_ATS(&p, info)) 3616 else
3617 isdn_tty_modem_result(RESULT_NO_CARRIER, info);
3539 return; 3618 return;
3540 break; 3619 case 'Q':
3541 case 'V': 3620 /* Q - Turn Emulator messages on/off */
3542 /* V - Numeric or ASCII Emulator-messages */ 3621 p++;
3543 p++; 3622 switch (isdn_getnum(&p)) {
3544 switch (isdn_getnum(&p)) { 3623 case 0:
3545 case 0: 3624 m->mdmreg[REG_RESP] |= BIT_RESP;
3546 m->mdmreg[REG_RESP] |= BIT_RESPNUM; 3625 break;
3547 break; 3626 case 1:
3548 case 1: 3627 m->mdmreg[REG_RESP] &= ~BIT_RESP;
3549 m->mdmreg[REG_RESP] &= ~BIT_RESPNUM; 3628 break;
3629 default:
3630 PARSE_ERROR;
3631 }
3550 break; 3632 break;
3551 default: 3633 case 'S':
3552 PARSE_ERROR; 3634 /* S - Set/Get Register */
3553 }
3554 break;
3555 case 'Z':
3556 /* Z - Load Registers from Profile */
3557 p++;
3558 if (info->msr & UART_MSR_DCD) {
3559 info->online = 0;
3560 isdn_tty_on_hook(info);
3561 }
3562 isdn_tty_modem_reset_regs(info, 1);
3563 break;
3564 case '+':
3565 p++;
3566 switch (*p) {
3567#ifdef CONFIG_ISDN_AUDIO
3568 case 'F':
3569 p++; 3635 p++;
3570 if (isdn_tty_cmd_PLUSF(&p, info)) 3636 if (isdn_tty_cmd_ATS(&p, info))
3571 return; 3637 return;
3572 break; 3638 break;
3573 case 'V': 3639 case 'V':
3574 if ((!(m->mdmreg[REG_SI1] & 1)) || 3640 /* V - Numeric or ASCII Emulator-messages */
3575 (m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM))
3576 PARSE_ERROR;
3577 p++; 3641 p++;
3578 if (isdn_tty_cmd_PLUSV(&p, info)) 3642 switch (isdn_getnum(&p)) {
3579 return; 3643 case 0:
3644 m->mdmreg[REG_RESP] |= BIT_RESPNUM;
3645 break;
3646 case 1:
3647 m->mdmreg[REG_RESP] &= ~BIT_RESPNUM;
3648 break;
3649 default:
3650 PARSE_ERROR;
3651 }
3580 break; 3652 break;
3581#endif /* CONFIG_ISDN_AUDIO */ 3653 case 'Z':
3582 case 'S': /* SUSPEND */ 3654 /* Z - Load Registers from Profile */
3583 p++; 3655 p++;
3584 isdn_tty_get_msnstr(ds, &p); 3656 if (info->msr & UART_MSR_DCD) {
3585 isdn_tty_suspend(ds, info, m); 3657 info->online = 0;
3658 isdn_tty_on_hook(info);
3659 }
3660 isdn_tty_modem_reset_regs(info, 1);
3586 break; 3661 break;
3587 case 'R': /* RESUME */ 3662 case '+':
3588 p++; 3663 p++;
3589 isdn_tty_get_msnstr(ds, &p); 3664 switch (*p) {
3590 isdn_tty_resume(ds, info, m); 3665#ifdef CONFIG_ISDN_AUDIO
3666 case 'F':
3667 p++;
3668 if (isdn_tty_cmd_PLUSF(&p, info))
3669 return;
3670 break;
3671 case 'V':
3672 if ((!(m->mdmreg[REG_SI1] & 1)) ||
3673 (m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM))
3674 PARSE_ERROR;
3675 p++;
3676 if (isdn_tty_cmd_PLUSV(&p, info))
3677 return;
3678 break;
3679#endif /* CONFIG_ISDN_AUDIO */
3680 case 'S': /* SUSPEND */
3681 p++;
3682 isdn_tty_get_msnstr(ds, &p);
3683 isdn_tty_suspend(ds, info, m);
3684 break;
3685 case 'R': /* RESUME */
3686 p++;
3687 isdn_tty_get_msnstr(ds, &p);
3688 isdn_tty_resume(ds, info, m);
3689 break;
3690 case 'M': /* MESSAGE */
3691 p++;
3692 isdn_tty_send_msg(info, m, p);
3693 break;
3694 default:
3695 PARSE_ERROR;
3696 }
3591 break; 3697 break;
3592 case 'M': /* MESSAGE */ 3698 case '&':
3593 p++; 3699 p++;
3594 isdn_tty_send_msg(info, m, p); 3700 if (isdn_tty_cmd_ATand(&p, info))
3701 return;
3595 break; 3702 break;
3596 default: 3703 default:
3597 PARSE_ERROR; 3704 PARSE_ERROR;
3598 }
3599 break;
3600 case '&':
3601 p++;
3602 if (isdn_tty_cmd_ATand(&p, info))
3603 return;
3604 break;
3605 default:
3606 PARSE_ERROR;
3607 } 3705 }
3608 } 3706 }
3609#ifdef CONFIG_ISDN_AUDIO 3707#ifdef CONFIG_ISDN_AUDIO
@@ -3615,7 +3713,7 @@ isdn_tty_parse_at(modem_info *info)
3615/* Need own toupper() because standard-toupper is not available 3713/* Need own toupper() because standard-toupper is not available
3616 * within modules. 3714 * within modules.
3617 */ 3715 */
3618#define my_toupper(c) (((c >= 'a') && (c <= 'z')) ? (c & 0xdf) : c) 3716#define my_toupper(c) (((c>='a')&&(c<='z'))?(c&0xdf):c)
3619 3717
3620/* 3718/*
3621 * Perform line-editing of AT-commands 3719 * Perform line-editing of AT-commands
@@ -3626,7 +3724,7 @@ isdn_tty_parse_at(modem_info *info)
3626 * channel index to line (minor-device) 3724 * channel index to line (minor-device)
3627 */ 3725 */
3628static int 3726static int
3629isdn_tty_edit_at(const char *p, int count, modem_info *info) 3727isdn_tty_edit_at(const char *p, int count, modem_info * info)
3630{ 3728{
3631 atemu *m = &info->emu; 3729 atemu *m = &info->emu;
3632 int total = 0; 3730 int total = 0;
@@ -3669,23 +3767,23 @@ isdn_tty_edit_at(const char *p, int count, modem_info *info)
3669 if (m->mdmcmdl < 255) { 3767 if (m->mdmcmdl < 255) {
3670 c = my_toupper(c); 3768 c = my_toupper(c);
3671 switch (m->mdmcmdl) { 3769 switch (m->mdmcmdl) {
3672 case 1: 3770 case 1:
3673 if (c == 'T') { 3771 if (c == 'T') {
3674 m->mdmcmd[m->mdmcmdl] = c; 3772 m->mdmcmd[m->mdmcmdl] = c;
3675 m->mdmcmd[++m->mdmcmdl] = 0; 3773 m->mdmcmd[++m->mdmcmdl] = 0;
3774 break;
3775 } else
3776 m->mdmcmdl = 0;
3777 /* Fall through, check for 'A' */
3778 case 0:
3779 if (c == 'A') {
3780 m->mdmcmd[m->mdmcmdl] = c;
3781 m->mdmcmd[++m->mdmcmdl] = 0;
3782 }
3676 break; 3783 break;
3677 } else 3784 default:
3678 m->mdmcmdl = 0;
3679 /* Fall through, check for 'A' */
3680 case 0:
3681 if (c == 'A') {
3682 m->mdmcmd[m->mdmcmdl] = c; 3785 m->mdmcmd[m->mdmcmdl] = c;
3683 m->mdmcmd[++m->mdmcmdl] = 0; 3786 m->mdmcmd[++m->mdmcmdl] = 0;
3684 }
3685 break;
3686 default:
3687 m->mdmcmd[m->mdmcmdl] = c;
3688 m->mdmcmd[++m->mdmcmdl] = 0;
3689 } 3787 }
3690 } 3788 }
3691 } 3789 }
@@ -3707,19 +3805,19 @@ isdn_tty_modem_escape(void)
3707 int midx; 3805 int midx;
3708 3806
3709 for (i = 0; i < ISDN_MAX_CHANNELS; i++) 3807 for (i = 0; i < ISDN_MAX_CHANNELS; i++)
3710 if (USG_MODEM(dev->usage[i]) && (midx = dev->m_idx[i]) >= 0) { 3808 if (USG_MODEM(dev->usage[i]))
3711 modem_info *info = &dev->mdm.info[midx]; 3809 if ((midx = dev->m_idx[i]) >= 0) {
3712 if (info->online) { 3810 modem_info *info = &dev->mdm.info[midx];
3713 ton = 1; 3811 if (info->online) {
3714 if ((info->emu.pluscount == 3) && 3812 ton = 1;
3715 time_after(jiffies, 3813 if ((info->emu.pluscount == 3) &&
3716 info->emu.lastplus + PLUSWAIT2)) { 3814 time_after(jiffies , info->emu.lastplus + PLUSWAIT2)) {
3717 info->emu.pluscount = 0; 3815 info->emu.pluscount = 0;
3718 info->online = 0; 3816 info->online = 0;
3719 isdn_tty_modem_result(RESULT_OK, info); 3817 isdn_tty_modem_result(RESULT_OK, info);
3818 }
3720 } 3819 }
3721 } 3820 }
3722 }
3723 isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton); 3821 isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton);
3724} 3822}
3725 3823
@@ -3777,14 +3875,15 @@ isdn_tty_carrier_timeout(void)
3777 3875
3778 for (i = 0; i < ISDN_MAX_CHANNELS; i++) { 3876 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
3779 modem_info *info = &dev->mdm.info[i]; 3877 modem_info *info = &dev->mdm.info[i];
3780 if (!info->dialing) 3878 if (info->dialing) {
3781 continue; 3879 if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) {
3782 if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) { 3880 info->dialing = 0;
3783 info->dialing = 0; 3881 isdn_tty_modem_result(RESULT_NO_CARRIER, info);
3784 isdn_tty_modem_result(RESULT_NO_CARRIER, info); 3882 isdn_tty_modem_hup(info, 1);
3785 isdn_tty_modem_hup(info, 1); 3883 }
3786 } else 3884 else
3787 ton = 1; 3885 ton = 1;
3886 }
3788 } 3887 }
3789 isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton); 3888 isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton);
3790} 3889}
diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h
index a6f801d2263..692c74d6b74 100644
--- a/drivers/isdn/i4l/isdn_tty.h
+++ b/drivers/isdn/i4l/isdn_tty.h
@@ -93,11 +93,11 @@
93#define RESULT_VCON 11 93#define RESULT_VCON 11
94#define RESULT_RUNG 12 94#define RESULT_RUNG 12
95 95
96#define TTY_IS_FCLASS1(info) \ 96#define TTY_IS_FCLASS1(info) \
97 ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ 97 ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \
98 (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS1)) 98 (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS1))
99#define TTY_IS_FCLASS2(info) \ 99#define TTY_IS_FCLASS2(info) \
100 ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ 100 ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \
101 (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) 101 (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2))
102 102
103extern void isdn_tty_modem_escape(void); 103extern void isdn_tty_modem_escape(void);
@@ -110,7 +110,7 @@ extern void isdn_tty_readmodem(void);
110extern int isdn_tty_find_icall(int, int, setup_parm *); 110extern int isdn_tty_find_icall(int, int, setup_parm *);
111extern int isdn_tty_stat_callback(int, isdn_ctrl *); 111extern int isdn_tty_stat_callback(int, isdn_ctrl *);
112extern int isdn_tty_rcv_skb(int, int, int, struct sk_buff *); 112extern int isdn_tty_rcv_skb(int, int, int, struct sk_buff *);
113extern int isdn_tty_capi_facility(capi_msg *cm); 113extern int isdn_tty_capi_facility(capi_msg *cm);
114extern void isdn_tty_at_cout(char *, modem_info *); 114extern void isdn_tty_at_cout(char *, modem_info *);
115extern void isdn_tty_modem_hup(modem_info *, int); 115extern void isdn_tty_modem_hup(modem_info *, int);
116#ifdef CONFIG_ISDN_TTY_FAX 116#ifdef CONFIG_ISDN_TTY_FAX
diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c
index 47aae491673..4c41f191d4e 100644
--- a/drivers/isdn/i4l/isdn_ttyfax.c
+++ b/drivers/isdn/i4l/isdn_ttyfax.c
@@ -45,7 +45,7 @@ isdn_getrev(const char *revision)
45 */ 45 */
46 46
47static void 47static void
48isdn_tty_fax_modem_result(int code, modem_info *info) 48isdn_tty_fax_modem_result(int code, modem_info * info)
49{ 49{
50 atemu *m = &info->emu; 50 atemu *m = &info->emu;
51 T30_s *f = info->fax; 51 T30_s *f = info->fax;
@@ -54,9 +54,9 @@ isdn_tty_fax_modem_result(int code, modem_info *info)
54 char *rp; 54 char *rp;
55 int i; 55 int i;
56 static char *msg[] = 56 static char *msg[] =
57 {"OK", "ERROR", "+FCON", "+FCSI:", "+FDIS:", 57 {"OK", "ERROR", "+FCON", "+FCSI:", "+FDIS:",
58 "+FHNG:", "+FDCS:", "CONNECT", "+FTSI:", 58 "+FHNG:", "+FDCS:", "CONNECT", "+FTSI:",
59 "+FCFR", "+FPTS:", "+FET:"}; 59 "+FCFR", "+FPTS:", "+FET:"};
60 60
61 61
62 isdn_tty_at_cout("\r\n", info); 62 isdn_tty_at_cout("\r\n", info);
@@ -64,95 +64,95 @@ isdn_tty_fax_modem_result(int code, modem_info *info)
64 64
65#ifdef ISDN_TTY_FAX_CMD_DEBUG 65#ifdef ISDN_TTY_FAX_CMD_DEBUG
66 printk(KERN_DEBUG "isdn_tty: Fax send %s on ttyI%d\n", 66 printk(KERN_DEBUG "isdn_tty: Fax send %s on ttyI%d\n",
67 msg[code], info->line); 67 msg[code], info->line);
68#endif 68#endif
69 switch (code) { 69 switch (code) {
70 case 0: /* OK */ 70 case 0: /* OK */
71 break; 71 break;
72 case 1: /* ERROR */ 72 case 1: /* ERROR */
73 break; 73 break;
74 case 2: /* +FCON */ 74 case 2: /* +FCON */
75 /* Append CPN, if enabled */ 75 /* Append CPN, if enabled */
76 if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) && 76 if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) &&
77 (!(dev->usage[info->isdn_channel] & ISDN_USAGE_OUTGOING))) { 77 (!(dev->usage[info->isdn_channel] & ISDN_USAGE_OUTGOING))) {
78 sprintf(rs, "/%s", m->cpn); 78 sprintf(rs, "/%s", m->cpn);
79 isdn_tty_at_cout(rs, info);
80 }
81 info->online = 1;
82 f->fet = 0;
83 if (f->phase == ISDN_FAX_PHASE_A)
84 f->phase = ISDN_FAX_PHASE_B;
85 break;
86 case 3: /* +FCSI */
87 case 8: /* +FTSI */
88 sprintf(rs, "\"%s\"", f->r_id);
89 isdn_tty_at_cout(rs, info);
90 break;
91 case 4: /* +FDIS */
92 rs[0] = 0;
93 rp = &f->r_resolution;
94 for (i = 0; i < 8; i++) {
95 sprintf(rss, "%c%s", rp[i] + 48,
96 (i < 7) ? "," : "");
97 strcat(rs, rss);
98 }
79 isdn_tty_at_cout(rs, info); 99 isdn_tty_at_cout(rs, info);
80 }
81 info->online = 1;
82 f->fet = 0;
83 if (f->phase == ISDN_FAX_PHASE_A)
84 f->phase = ISDN_FAX_PHASE_B;
85 break;
86 case 3: /* +FCSI */
87 case 8: /* +FTSI */
88 sprintf(rs, "\"%s\"", f->r_id);
89 isdn_tty_at_cout(rs, info);
90 break;
91 case 4: /* +FDIS */
92 rs[0] = 0;
93 rp = &f->r_resolution;
94 for (i = 0; i < 8; i++) {
95 sprintf(rss, "%c%s", rp[i] + 48,
96 (i < 7) ? "," : "");
97 strcat(rs, rss);
98 }
99 isdn_tty_at_cout(rs, info);
100#ifdef ISDN_TTY_FAX_CMD_DEBUG 100#ifdef ISDN_TTY_FAX_CMD_DEBUG
101 printk(KERN_DEBUG "isdn_tty: Fax DIS=%s on ttyI%d\n", 101 printk(KERN_DEBUG "isdn_tty: Fax DIS=%s on ttyI%d\n",
102 rs, info->line); 102 rs, info->line);
103#endif 103#endif
104 break; 104 break;
105 case 5: /* +FHNG */ 105 case 5: /* +FHNG */
106 sprintf(rs, "%d", f->code); 106 sprintf(rs, "%d", f->code);
107 isdn_tty_at_cout(rs, info); 107 isdn_tty_at_cout(rs, info);
108 info->faxonline = 0; 108 info->faxonline = 0;
109 break; 109 break;
110 case 6: /* +FDCS */ 110 case 6: /* +FDCS */
111 rs[0] = 0; 111 rs[0] = 0;
112 rp = &f->r_resolution; 112 rp = &f->r_resolution;
113 for (i = 0; i < 8; i++) { 113 for (i = 0; i < 8; i++) {
114 sprintf(rss, "%c%s", rp[i] + 48, 114 sprintf(rss, "%c%s", rp[i] + 48,
115 (i < 7) ? "," : ""); 115 (i < 7) ? "," : "");
116 strcat(rs, rss); 116 strcat(rs, rss);
117 } 117 }
118 isdn_tty_at_cout(rs, info); 118 isdn_tty_at_cout(rs, info);
119#ifdef ISDN_TTY_FAX_CMD_DEBUG 119#ifdef ISDN_TTY_FAX_CMD_DEBUG
120 printk(KERN_DEBUG "isdn_tty: Fax DCS=%s on ttyI%d\n", 120 printk(KERN_DEBUG "isdn_tty: Fax DCS=%s on ttyI%d\n",
121 rs, info->line); 121 rs, info->line);
122#endif 122#endif
123 break; 123 break;
124 case 7: /* CONNECT */ 124 case 7: /* CONNECT */
125 info->faxonline |= 2; 125 info->faxonline |= 2;
126 break; 126 break;
127 case 9: /* FCFR */ 127 case 9: /* FCFR */
128 break; 128 break;
129 case 10: /* FPTS */ 129 case 10: /* FPTS */
130 isdn_tty_at_cout("1", info); 130 isdn_tty_at_cout("1", info);
131 break; 131 break;
132 case 11: /* FET */ 132 case 11: /* FET */
133 sprintf(rs, "%d", f->fet); 133 sprintf(rs, "%d", f->fet);
134 isdn_tty_at_cout(rs, info); 134 isdn_tty_at_cout(rs, info);
135 break; 135 break;
136 } 136 }
137 137
138 isdn_tty_at_cout("\r\n", info); 138 isdn_tty_at_cout("\r\n", info);
139 139
140 switch (code) { 140 switch (code) {
141 case 7: /* CONNECT */ 141 case 7: /* CONNECT */
142 info->online = 2; 142 info->online = 2;
143 if (info->faxonline & 1) { 143 if (info->faxonline & 1) {
144 sprintf(rs, "%c", XON); 144 sprintf(rs, "%c", XON);
145 isdn_tty_at_cout(rs, info); 145 isdn_tty_at_cout(rs, info);
146 } 146 }
147 break; 147 break;
148 } 148 }
149} 149}
150 150
151static int 151static int
152isdn_tty_fax_command1(modem_info *info, isdn_ctrl *c) 152isdn_tty_fax_command1(modem_info * info, isdn_ctrl * c)
153{ 153{
154 static char *msg[] = 154 static char *msg[] =
155 {"OK", "CONNECT", "NO CARRIER", "ERROR", "FCERROR"}; 155 {"OK", "CONNECT", "NO CARRIER", "ERROR", "FCERROR"};
156 156
157#ifdef ISDN_TTY_FAX_CMD_DEBUG 157#ifdef ISDN_TTY_FAX_CMD_DEBUG
158 printk(KERN_DEBUG "isdn_tty: FCLASS1 cmd(%d)\n", c->parm.aux.cmd); 158 printk(KERN_DEBUG "isdn_tty: FCLASS1 cmd(%d)\n", c->parm.aux.cmd);
@@ -165,30 +165,30 @@ isdn_tty_fax_command1(modem_info *info, isdn_ctrl *c)
165 isdn_tty_at_cout("\r\n", info); 165 isdn_tty_at_cout("\r\n", info);
166 } 166 }
167 switch (c->parm.aux.cmd) { 167 switch (c->parm.aux.cmd) {
168 case ISDN_FAX_CLASS1_CONNECT: 168 case ISDN_FAX_CLASS1_CONNECT:
169 info->online = 2; 169 info->online = 2;
170 break; 170 break;
171 case ISDN_FAX_CLASS1_OK: 171 case ISDN_FAX_CLASS1_OK:
172 case ISDN_FAX_CLASS1_FCERROR: 172 case ISDN_FAX_CLASS1_FCERROR:
173 case ISDN_FAX_CLASS1_ERROR: 173 case ISDN_FAX_CLASS1_ERROR:
174 case ISDN_FAX_CLASS1_NOCARR: 174 case ISDN_FAX_CLASS1_NOCARR:
175 break; 175 break;
176 case ISDN_FAX_CLASS1_QUERY: 176 case ISDN_FAX_CLASS1_QUERY:
177 isdn_tty_at_cout("\r\n", info);
178 if (!c->parm.aux.para[0]) {
179 isdn_tty_at_cout(msg[ISDN_FAX_CLASS1_ERROR], info);
180 isdn_tty_at_cout("\r\n", info); 177 isdn_tty_at_cout("\r\n", info);
181 } else { 178 if (!c->parm.aux.para[0]) {
182 isdn_tty_at_cout(c->parm.aux.para, info); 179 isdn_tty_at_cout(msg[ISDN_FAX_CLASS1_ERROR], info);
183 isdn_tty_at_cout("\r\nOK\r\n", info); 180 isdn_tty_at_cout("\r\n", info);
184 } 181 } else {
185 break; 182 isdn_tty_at_cout(c->parm.aux.para, info);
183 isdn_tty_at_cout("\r\nOK\r\n", info);
184 }
185 break;
186 } 186 }
187 return (0); 187 return (0);
188} 188}
189 189
190int 190int
191isdn_tty_fax_command(modem_info *info, isdn_ctrl *c) 191isdn_tty_fax_command(modem_info * info, isdn_ctrl * c)
192{ 192{
193 T30_s *f = info->fax; 193 T30_s *f = info->fax;
194 char rs[10]; 194 char rs[10];
@@ -201,78 +201,78 @@ isdn_tty_fax_command(modem_info *info, isdn_ctrl *c)
201 f->r_code, info->line); 201 f->r_code, info->line);
202#endif 202#endif
203 switch (f->r_code) { 203 switch (f->r_code) {
204 case ISDN_TTY_FAX_FCON: 204 case ISDN_TTY_FAX_FCON:
205 info->faxonline = 1; 205 info->faxonline = 1;
206 isdn_tty_fax_modem_result(2, info); /* +FCON */ 206 isdn_tty_fax_modem_result(2, info); /* +FCON */
207 return (0); 207 return (0);
208 case ISDN_TTY_FAX_FCON_I: 208 case ISDN_TTY_FAX_FCON_I:
209 info->faxonline = 16; 209 info->faxonline = 16;
210 isdn_tty_fax_modem_result(2, info); /* +FCON */ 210 isdn_tty_fax_modem_result(2, info); /* +FCON */
211 return (0); 211 return (0);
212 case ISDN_TTY_FAX_RID: 212 case ISDN_TTY_FAX_RID:
213 if (info->faxonline & 1) 213 if (info->faxonline & 1)
214 isdn_tty_fax_modem_result(3, info); /* +FCSI */ 214 isdn_tty_fax_modem_result(3, info); /* +FCSI */
215 if (info->faxonline & 16) 215 if (info->faxonline & 16)
216 isdn_tty_fax_modem_result(8, info); /* +FTSI */ 216 isdn_tty_fax_modem_result(8, info); /* +FTSI */
217 return (0); 217 return (0);
218 case ISDN_TTY_FAX_DIS: 218 case ISDN_TTY_FAX_DIS:
219 isdn_tty_fax_modem_result(4, info); /* +FDIS */ 219 isdn_tty_fax_modem_result(4, info); /* +FDIS */
220 return (0); 220 return (0);
221 case ISDN_TTY_FAX_HNG: 221 case ISDN_TTY_FAX_HNG:
222 if (f->phase == ISDN_FAX_PHASE_C) { 222 if (f->phase == ISDN_FAX_PHASE_C) {
223 if (f->direction == ISDN_TTY_FAX_CONN_IN) { 223 if (f->direction == ISDN_TTY_FAX_CONN_IN) {
224 sprintf(rs, "%c%c", DLE, ETX); 224 sprintf(rs, "%c%c", DLE, ETX);
225 isdn_tty_at_cout(rs, info); 225 isdn_tty_at_cout(rs, info);
226 } else { 226 } else {
227 sprintf(rs, "%c", 0x18); 227 sprintf(rs, "%c", 0x18);
228 isdn_tty_at_cout(rs, info); 228 isdn_tty_at_cout(rs, info);
229 }
230 info->faxonline &= ~2; /* leave data mode */
231 info->online = 1;
229 } 232 }
233 f->phase = ISDN_FAX_PHASE_E;
234 isdn_tty_fax_modem_result(5, info); /* +FHNG */
235 isdn_tty_fax_modem_result(0, info); /* OK */
236 return (0);
237 case ISDN_TTY_FAX_DCS:
238 isdn_tty_fax_modem_result(6, info); /* +FDCS */
239 isdn_tty_fax_modem_result(7, info); /* CONNECT */
240 f->phase = ISDN_FAX_PHASE_C;
241 return (0);
242 case ISDN_TTY_FAX_TRAIN_OK:
243 isdn_tty_fax_modem_result(6, info); /* +FDCS */
244 isdn_tty_fax_modem_result(0, info); /* OK */
245 return (0);
246 case ISDN_TTY_FAX_SENT:
247 isdn_tty_fax_modem_result(0, info); /* OK */
248 return (0);
249 case ISDN_TTY_FAX_CFR:
250 isdn_tty_fax_modem_result(9, info); /* +FCFR */
251 return (0);
252 case ISDN_TTY_FAX_ET:
253 sprintf(rs, "%c%c", DLE, ETX);
254 isdn_tty_at_cout(rs, info);
255 isdn_tty_fax_modem_result(10, info); /* +FPTS */
256 isdn_tty_fax_modem_result(11, info); /* +FET */
257 isdn_tty_fax_modem_result(0, info); /* OK */
230 info->faxonline &= ~2; /* leave data mode */ 258 info->faxonline &= ~2; /* leave data mode */
231 info->online = 1; 259 info->online = 1;
232 } 260 f->phase = ISDN_FAX_PHASE_D;
233 f->phase = ISDN_FAX_PHASE_E; 261 return (0);
234 isdn_tty_fax_modem_result(5, info); /* +FHNG */ 262 case ISDN_TTY_FAX_PTS:
235 isdn_tty_fax_modem_result(0, info); /* OK */ 263 isdn_tty_fax_modem_result(10, info); /* +FPTS */
236 return (0); 264 if (f->direction == ISDN_TTY_FAX_CONN_OUT) {
237 case ISDN_TTY_FAX_DCS: 265 if (f->fet == 1)
238 isdn_tty_fax_modem_result(6, info); /* +FDCS */ 266 f->phase = ISDN_FAX_PHASE_B;
239 isdn_tty_fax_modem_result(7, info); /* CONNECT */ 267 if (f->fet == 0)
240 f->phase = ISDN_FAX_PHASE_C; 268 isdn_tty_fax_modem_result(0, info); /* OK */
241 return (0); 269 }
242 case ISDN_TTY_FAX_TRAIN_OK: 270 return (0);
243 isdn_tty_fax_modem_result(6, info); /* +FDCS */ 271 case ISDN_TTY_FAX_EOP:
244 isdn_tty_fax_modem_result(0, info); /* OK */ 272 info->faxonline &= ~2; /* leave data mode */
245 return (0); 273 info->online = 1;
246 case ISDN_TTY_FAX_SENT: 274 f->phase = ISDN_FAX_PHASE_D;
247 isdn_tty_fax_modem_result(0, info); /* OK */ 275 return (0);
248 return (0);
249 case ISDN_TTY_FAX_CFR:
250 isdn_tty_fax_modem_result(9, info); /* +FCFR */
251 return (0);
252 case ISDN_TTY_FAX_ET:
253 sprintf(rs, "%c%c", DLE, ETX);
254 isdn_tty_at_cout(rs, info);
255 isdn_tty_fax_modem_result(10, info); /* +FPTS */
256 isdn_tty_fax_modem_result(11, info); /* +FET */
257 isdn_tty_fax_modem_result(0, info); /* OK */
258 info->faxonline &= ~2; /* leave data mode */
259 info->online = 1;
260 f->phase = ISDN_FAX_PHASE_D;
261 return (0);
262 case ISDN_TTY_FAX_PTS:
263 isdn_tty_fax_modem_result(10, info); /* +FPTS */
264 if (f->direction == ISDN_TTY_FAX_CONN_OUT) {
265 if (f->fet == 1)
266 f->phase = ISDN_FAX_PHASE_B;
267 if (f->fet == 0)
268 isdn_tty_fax_modem_result(0, info); /* OK */
269 }
270 return (0);
271 case ISDN_TTY_FAX_EOP:
272 info->faxonline &= ~2; /* leave data mode */
273 info->online = 1;
274 f->phase = ISDN_FAX_PHASE_D;
275 return (0);
276 276
277 } 277 }
278 return (-1); 278 return (-1);
@@ -280,7 +280,7 @@ isdn_tty_fax_command(modem_info *info, isdn_ctrl *c)
280 280
281 281
282void 282void
283isdn_tty_fax_bitorder(modem_info *info, struct sk_buff *skb) 283isdn_tty_fax_bitorder(modem_info * info, struct sk_buff *skb)
284{ 284{
285 __u8 LeftMask; 285 __u8 LeftMask;
286 __u8 RightMask; 286 __u8 RightMask;
@@ -292,10 +292,10 @@ isdn_tty_fax_bitorder(modem_info *info, struct sk_buff *skb)
292 for (i = 0; i < skb->len; i++) { 292 for (i = 0; i < skb->len; i++) {
293 Data = skb->data[i]; 293 Data = skb->data[i];
294 for ( 294 for (
295 LeftMask = 0x80, RightMask = 0x01; 295 LeftMask = 0x80, RightMask = 0x01;
296 LeftMask > RightMask; 296 LeftMask > RightMask;
297 LeftMask >>= 1, RightMask <<= 1 297 LeftMask >>= 1, RightMask <<= 1
298 ) { 298 ) {
299 fBit = (Data & LeftMask); 299 fBit = (Data & LeftMask);
300 if (Data & RightMask) 300 if (Data & RightMask)
301 Data |= LeftMask; 301 Data |= LeftMask;
@@ -317,10 +317,10 @@ isdn_tty_fax_bitorder(modem_info *info, struct sk_buff *skb)
317 */ 317 */
318 318
319static int 319static int
320isdn_tty_cmd_FCLASS1(char **p, modem_info *info) 320isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
321{ 321{
322 static char *cmd[] = 322 static char *cmd[] =
323 {"AE", "TS", "RS", "TM", "RM", "TH", "RH"}; 323 {"AE", "TS", "RS", "TM", "RM", "TH", "RH"};
324 isdn_ctrl c; 324 isdn_ctrl c;
325 int par, i; 325 int par, i;
326 u_long flags; 326 u_long flags;
@@ -337,28 +337,28 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info *info)
337 337
338 p[0] += 2; 338 p[0] += 2;
339 switch (*p[0]) { 339 switch (*p[0]) {
340 case '?': 340 case '?':
341 p[0]++;
342 c.parm.aux.subcmd = AT_QUERY;
343 break;
344 case '=':
345 p[0]++;
346 if (*p[0] == '?') {
347 p[0]++; 341 p[0]++;
348 c.parm.aux.subcmd = AT_EQ_QUERY; 342 c.parm.aux.subcmd = AT_QUERY;
349 } else { 343 break;
350 par = isdn_getnum(p); 344 case '=':
351 if ((par < 0) || (par > 255)) 345 p[0]++;
352 PARSE_ERROR1; 346 if (*p[0] == '?') {
353 c.parm.aux.subcmd = AT_EQ_VALUE; 347 p[0]++;
354 c.parm.aux.para[0] = par; 348 c.parm.aux.subcmd = AT_EQ_QUERY;
355 } 349 } else {
356 break; 350 par = isdn_getnum(p);
357 case 0: 351 if ((par < 0) || (par > 255))
358 c.parm.aux.subcmd = AT_COMMAND; 352 PARSE_ERROR1;
359 break; 353 c.parm.aux.subcmd = AT_EQ_VALUE;
360 default: 354 c.parm.aux.para[0] = par;
361 PARSE_ERROR1; 355 }
356 break;
357 case 0:
358 c.parm.aux.subcmd = AT_COMMAND;
359 break;
360 default:
361 PARSE_ERROR1;
362 } 362 }
363 c.command = ISDN_CMD_FAXCMD; 363 c.command = ISDN_CMD_FAXCMD;
364#ifdef ISDN_TTY_FAX_CMD_DEBUG 364#ifdef ISDN_TTY_FAX_CMD_DEBUG
@@ -409,7 +409,7 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info *info)
409 */ 409 */
410 410
411static int 411static int
412isdn_tty_cmd_FCLASS2(char **p, modem_info *info) 412isdn_tty_cmd_FCLASS2(char **p, modem_info * info)
413{ 413{
414 atemu *m = &info->emu; 414 atemu *m = &info->emu;
415 T30_s *f = info->fax; 415 T30_s *f = info->fax;
@@ -418,25 +418,25 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
418 char rs[50]; 418 char rs[50];
419 char rss[50]; 419 char rss[50];
420 int maxdccval[] = 420 int maxdccval[] =
421 {1, 5, 2, 2, 3, 2, 0, 7}; 421 {1, 5, 2, 2, 3, 2, 0, 7};
422 422
423 /* FAA still unchanged */ 423 /* FAA still unchanged */
424 if (!strncmp(p[0], "AA", 2)) { /* TODO */ 424 if (!strncmp(p[0], "AA", 2)) { /* TODO */
425 p[0] += 2; 425 p[0] += 2;
426 switch (*p[0]) { 426 switch (*p[0]) {
427 case '?': 427 case '?':
428 p[0]++; 428 p[0]++;
429 sprintf(rs, "\r\n%d", 0); 429 sprintf(rs, "\r\n%d", 0);
430 isdn_tty_at_cout(rs, info); 430 isdn_tty_at_cout(rs, info);
431 break; 431 break;
432 case '=': 432 case '=':
433 p[0]++; 433 p[0]++;
434 par = isdn_getnum(p); 434 par = isdn_getnum(p);
435 if ((par < 0) || (par > 255)) 435 if ((par < 0) || (par > 255))
436 PARSE_ERROR1;
437 break;
438 default:
436 PARSE_ERROR1; 439 PARSE_ERROR1;
437 break;
438 default:
439 PARSE_ERROR1;
440 } 440 }
441 return 0; 441 return 0;
442 } 442 }
@@ -444,29 +444,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
444 if (!strncmp(p[0], "BADLIN", 6)) { 444 if (!strncmp(p[0], "BADLIN", 6)) {
445 p[0] += 6; 445 p[0] += 6;
446 switch (*p[0]) { 446 switch (*p[0]) {
447 case '?': 447 case '?':
448 p[0]++;
449 sprintf(rs, "\r\n%d", f->badlin);
450 isdn_tty_at_cout(rs, info);
451 break;
452 case '=':
453 p[0]++;
454 if (*p[0] == '?') {
455 p[0]++; 448 p[0]++;
456 sprintf(rs, "\r\n0-255"); 449 sprintf(rs, "\r\n%d", f->badlin);
457 isdn_tty_at_cout(rs, info); 450 isdn_tty_at_cout(rs, info);
458 } else { 451 break;
459 par = isdn_getnum(p); 452 case '=':
460 if ((par < 0) || (par > 255)) 453 p[0]++;
461 PARSE_ERROR1; 454 if (*p[0] == '?') {
462 f->badlin = par; 455 p[0]++;
456 sprintf(rs, "\r\n0-255");
457 isdn_tty_at_cout(rs, info);
458 } else {
459 par = isdn_getnum(p);
460 if ((par < 0) || (par > 255))
461 PARSE_ERROR1;
462 f->badlin = par;
463#ifdef ISDN_TTY_FAX_STAT_DEBUG 463#ifdef ISDN_TTY_FAX_STAT_DEBUG
464 printk(KERN_DEBUG "isdn_tty: Fax FBADLIN=%d\n", par); 464 printk(KERN_DEBUG "isdn_tty: Fax FBADLIN=%d\n", par);
465#endif 465#endif
466 } 466 }
467 break; 467 break;
468 default: 468 default:
469 PARSE_ERROR1; 469 PARSE_ERROR1;
470 } 470 }
471 return 0; 471 return 0;
472 } 472 }
@@ -474,29 +474,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
474 if (!strncmp(p[0], "BADMUL", 6)) { 474 if (!strncmp(p[0], "BADMUL", 6)) {
475 p[0] += 6; 475 p[0] += 6;
476 switch (*p[0]) { 476 switch (*p[0]) {
477 case '?': 477 case '?':
478 p[0]++;
479 sprintf(rs, "\r\n%d", f->badmul);
480 isdn_tty_at_cout(rs, info);
481 break;
482 case '=':
483 p[0]++;
484 if (*p[0] == '?') {
485 p[0]++; 478 p[0]++;
486 sprintf(rs, "\r\n0-255"); 479 sprintf(rs, "\r\n%d", f->badmul);
487 isdn_tty_at_cout(rs, info); 480 isdn_tty_at_cout(rs, info);
488 } else { 481 break;
489 par = isdn_getnum(p); 482 case '=':
490 if ((par < 0) || (par > 255)) 483 p[0]++;
491 PARSE_ERROR1; 484 if (*p[0] == '?') {
492 f->badmul = par; 485 p[0]++;
486 sprintf(rs, "\r\n0-255");
487 isdn_tty_at_cout(rs, info);
488 } else {
489 par = isdn_getnum(p);
490 if ((par < 0) || (par > 255))
491 PARSE_ERROR1;
492 f->badmul = par;
493#ifdef ISDN_TTY_FAX_STAT_DEBUG 493#ifdef ISDN_TTY_FAX_STAT_DEBUG
494 printk(KERN_DEBUG "isdn_tty: Fax FBADMUL=%d\n", par); 494 printk(KERN_DEBUG "isdn_tty: Fax FBADMUL=%d\n", par);
495#endif 495#endif
496 } 496 }
497 break; 497 break;
498 default: 498 default:
499 PARSE_ERROR1; 499 PARSE_ERROR1;
500 } 500 }
501 return 0; 501 return 0;
502 } 502 }
@@ -504,29 +504,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
504 if (!strncmp(p[0], "BOR", 3)) { 504 if (!strncmp(p[0], "BOR", 3)) {
505 p[0] += 3; 505 p[0] += 3;
506 switch (*p[0]) { 506 switch (*p[0]) {
507 case '?': 507 case '?':
508 p[0]++;
509 sprintf(rs, "\r\n%d", f->bor);
510 isdn_tty_at_cout(rs, info);
511 break;
512 case '=':
513 p[0]++;
514 if (*p[0] == '?') {
515 p[0]++; 508 p[0]++;
516 sprintf(rs, "\r\n0,1"); 509 sprintf(rs, "\r\n%d", f->bor);
517 isdn_tty_at_cout(rs, info); 510 isdn_tty_at_cout(rs, info);
518 } else { 511 break;
519 par = isdn_getnum(p); 512 case '=':
520 if ((par < 0) || (par > 1)) 513 p[0]++;
521 PARSE_ERROR1; 514 if (*p[0] == '?') {
522 f->bor = par; 515 p[0]++;
516 sprintf(rs, "\r\n0,1");
517 isdn_tty_at_cout(rs, info);
518 } else {
519 par = isdn_getnum(p);
520 if ((par < 0) || (par > 1))
521 PARSE_ERROR1;
522 f->bor = par;
523#ifdef ISDN_TTY_FAX_STAT_DEBUG 523#ifdef ISDN_TTY_FAX_STAT_DEBUG
524 printk(KERN_DEBUG "isdn_tty: Fax FBOR=%d\n", par); 524 printk(KERN_DEBUG "isdn_tty: Fax FBOR=%d\n", par);
525#endif 525#endif
526 } 526 }
527 break; 527 break;
528 default: 528 default:
529 PARSE_ERROR1; 529 PARSE_ERROR1;
530 } 530 }
531 return 0; 531 return 0;
532 } 532 }
@@ -534,29 +534,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
534 if (!strncmp(p[0], "NBC", 3)) { 534 if (!strncmp(p[0], "NBC", 3)) {
535 p[0] += 3; 535 p[0] += 3;
536 switch (*p[0]) { 536 switch (*p[0]) {
537 case '?': 537 case '?':
538 p[0]++;
539 sprintf(rs, "\r\n%d", f->nbc);
540 isdn_tty_at_cout(rs, info);
541 break;
542 case '=':
543 p[0]++;
544 if (*p[0] == '?') {
545 p[0]++; 538 p[0]++;
546 sprintf(rs, "\r\n0,1"); 539 sprintf(rs, "\r\n%d", f->nbc);
547 isdn_tty_at_cout(rs, info); 540 isdn_tty_at_cout(rs, info);
548 } else { 541 break;
549 par = isdn_getnum(p); 542 case '=':
550 if ((par < 0) || (par > 1)) 543 p[0]++;
551 PARSE_ERROR1; 544 if (*p[0] == '?') {
552 f->nbc = par; 545 p[0]++;
546 sprintf(rs, "\r\n0,1");
547 isdn_tty_at_cout(rs, info);
548 } else {
549 par = isdn_getnum(p);
550 if ((par < 0) || (par > 1))
551 PARSE_ERROR1;
552 f->nbc = par;
553#ifdef ISDN_TTY_FAX_STAT_DEBUG 553#ifdef ISDN_TTY_FAX_STAT_DEBUG
554 printk(KERN_DEBUG "isdn_tty: Fax FNBC=%d\n", par); 554 printk(KERN_DEBUG "isdn_tty: Fax FNBC=%d\n", par);
555#endif 555#endif
556 } 556 }
557 break; 557 break;
558 default: 558 default:
559 PARSE_ERROR1; 559 PARSE_ERROR1;
560 } 560 }
561 return 0; 561 return 0;
562 } 562 }
@@ -576,36 +576,36 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
576 int i, r; 576 int i, r;
577 p[0] += 3; 577 p[0] += 3;
578 switch (*p[0]) { 578 switch (*p[0]) {
579 case '?': 579 case '?':
580 p[0]++;
581 sprintf(rs, "\r\n\"%s\"", f->pollid);
582 isdn_tty_at_cout(rs, info);
583 break;
584 case '=':
585 p[0]++;
586 if (*p[0] == '?') {
587 p[0]++; 580 p[0]++;
588 sprintf(rs, "\r\n\"STRING\""); 581 sprintf(rs, "\r\n\"%s\"", f->pollid);
589 isdn_tty_at_cout(rs, info); 582 isdn_tty_at_cout(rs, info);
590 } else { 583 break;
591 if (*p[0] == '"') 584 case '=':
592 p[0]++; 585 p[0]++;
593 for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { 586 if (*p[0] == '?') {
594 f->pollid[i] = *p[0]++;
595 }
596 if (*p[0] == '"')
597 p[0]++; 587 p[0]++;
598 for (r = i; r < FAXIDLEN; r++) { 588 sprintf(rs, "\r\n\"STRING\"");
599 f->pollid[r] = 32; 589 isdn_tty_at_cout(rs, info);
600 } 590 } else {
601 f->pollid[FAXIDLEN - 1] = 0; 591 if (*p[0] == '"')
592 p[0]++;
593 for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) {
594 f->pollid[i] = *p[0]++;
595 }
596 if (*p[0] == '"')
597 p[0]++;
598 for (r = i; r < FAXIDLEN; r++) {
599 f->pollid[r] = 32;
600 }
601 f->pollid[FAXIDLEN - 1] = 0;
602#ifdef ISDN_TTY_FAX_STAT_DEBUG 602#ifdef ISDN_TTY_FAX_STAT_DEBUG
603 printk(KERN_DEBUG "isdn_tty: Fax local poll ID rx \"%s\"\n", f->pollid); 603 printk(KERN_DEBUG "isdn_tty: Fax local poll ID rx \"%s\"\n", f->pollid);
604#endif 604#endif
605 } 605 }
606 break; 606 break;
607 default: 607 default:
608 PARSE_ERROR1; 608 PARSE_ERROR1;
609 } 609 }
610 return 0; 610 return 0;
611 } 611 }
@@ -613,29 +613,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
613 if (!strncmp(p[0], "CQ", 2)) { 613 if (!strncmp(p[0], "CQ", 2)) {
614 p[0] += 2; 614 p[0] += 2;
615 switch (*p[0]) { 615 switch (*p[0]) {
616 case '?': 616 case '?':
617 p[0]++;
618 sprintf(rs, "\r\n%d", f->cq);
619 isdn_tty_at_cout(rs, info);
620 break;
621 case '=':
622 p[0]++;
623 if (*p[0] == '?') {
624 p[0]++; 617 p[0]++;
625 sprintf(rs, "\r\n0,1,2"); 618 sprintf(rs, "\r\n%d", f->cq);
626 isdn_tty_at_cout(rs, info); 619 isdn_tty_at_cout(rs, info);
627 } else { 620 break;
628 par = isdn_getnum(p); 621 case '=':
629 if ((par < 0) || (par > 2)) 622 p[0]++;
630 PARSE_ERROR1; 623 if (*p[0] == '?') {
631 f->cq = par; 624 p[0]++;
625 sprintf(rs, "\r\n0,1,2");
626 isdn_tty_at_cout(rs, info);
627 } else {
628 par = isdn_getnum(p);
629 if ((par < 0) || (par > 2))
630 PARSE_ERROR1;
631 f->cq = par;
632#ifdef ISDN_TTY_FAX_STAT_DEBUG 632#ifdef ISDN_TTY_FAX_STAT_DEBUG
633 printk(KERN_DEBUG "isdn_tty: Fax FCQ=%d\n", par); 633 printk(KERN_DEBUG "isdn_tty: Fax FCQ=%d\n", par);
634#endif 634#endif
635 } 635 }
636 break; 636 break;
637 default: 637 default:
638 PARSE_ERROR1; 638 PARSE_ERROR1;
639 } 639 }
640 return 0; 640 return 0;
641 } 641 }
@@ -643,29 +643,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
643 if (!strncmp(p[0], "CR", 2)) { 643 if (!strncmp(p[0], "CR", 2)) {
644 p[0] += 2; 644 p[0] += 2;
645 switch (*p[0]) { 645 switch (*p[0]) {
646 case '?': 646 case '?':
647 p[0]++;
648 sprintf(rs, "\r\n%d", f->cr); /* read actual value from struct and print */
649 isdn_tty_at_cout(rs, info);
650 break;
651 case '=':
652 p[0]++;
653 if (*p[0] == '?') {
654 p[0]++; 647 p[0]++;
655 sprintf(rs, "\r\n0,1"); /* display online help */ 648 sprintf(rs, "\r\n%d", f->cr); /* read actual value from struct and print */
656 isdn_tty_at_cout(rs, info); 649 isdn_tty_at_cout(rs, info);
657 } else { 650 break;
658 par = isdn_getnum(p); 651 case '=':
659 if ((par < 0) || (par > 1)) 652 p[0]++;
660 PARSE_ERROR1; 653 if (*p[0] == '?') {
661 f->cr = par; 654 p[0]++;
655 sprintf(rs, "\r\n0,1"); /* display online help */
656 isdn_tty_at_cout(rs, info);
657 } else {
658 par = isdn_getnum(p);
659 if ((par < 0) || (par > 1))
660 PARSE_ERROR1;
661 f->cr = par;
662#ifdef ISDN_TTY_FAX_STAT_DEBUG 662#ifdef ISDN_TTY_FAX_STAT_DEBUG
663 printk(KERN_DEBUG "isdn_tty: Fax FCR=%d\n", par); 663 printk(KERN_DEBUG "isdn_tty: Fax FCR=%d\n", par);
664#endif 664#endif
665 } 665 }
666 break; 666 break;
667 default: 667 default:
668 PARSE_ERROR1; 668 PARSE_ERROR1;
669 } 669 }
670 return 0; 670 return 0;
671 } 671 }
@@ -673,29 +673,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
673 if (!strncmp(p[0], "CTCRTY", 6)) { 673 if (!strncmp(p[0], "CTCRTY", 6)) {
674 p[0] += 6; 674 p[0] += 6;
675 switch (*p[0]) { 675 switch (*p[0]) {
676 case '?': 676 case '?':
677 p[0]++;
678 sprintf(rs, "\r\n%d", f->ctcrty);
679 isdn_tty_at_cout(rs, info);
680 break;
681 case '=':
682 p[0]++;
683 if (*p[0] == '?') {
684 p[0]++; 677 p[0]++;
685 sprintf(rs, "\r\n0-255"); 678 sprintf(rs, "\r\n%d", f->ctcrty);
686 isdn_tty_at_cout(rs, info); 679 isdn_tty_at_cout(rs, info);
687 } else { 680 break;
688 par = isdn_getnum(p); 681 case '=':
689 if ((par < 0) || (par > 255)) 682 p[0]++;
690 PARSE_ERROR1; 683 if (*p[0] == '?') {
691 f->ctcrty = par; 684 p[0]++;
685 sprintf(rs, "\r\n0-255");
686 isdn_tty_at_cout(rs, info);
687 } else {
688 par = isdn_getnum(p);
689 if ((par < 0) || (par > 255))
690 PARSE_ERROR1;
691 f->ctcrty = par;
692#ifdef ISDN_TTY_FAX_STAT_DEBUG 692#ifdef ISDN_TTY_FAX_STAT_DEBUG
693 printk(KERN_DEBUG "isdn_tty: Fax FCTCRTY=%d\n", par); 693 printk(KERN_DEBUG "isdn_tty: Fax FCTCRTY=%d\n", par);
694#endif 694#endif
695 } 695 }
696 break; 696 break;
697 default: 697 default:
698 PARSE_ERROR1; 698 PARSE_ERROR1;
699 } 699 }
700 return 0; 700 return 0;
701 } 701 }
@@ -706,42 +706,42 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
706 706
707 p[0] += 3; 707 p[0] += 3;
708 switch (*p[0]) { 708 switch (*p[0]) {
709 case '?': 709 case '?':
710 p[0]++;
711 strcpy(rs, "\r\n");
712 for (i = 0; i < 8; i++) {
713 sprintf(rss, "%c%s", rp[i] + 48,
714 (i < 7) ? "," : "");
715 strcat(rs, rss);
716 }
717 isdn_tty_at_cout(rs, info);
718 break;
719 case '=':
720 p[0]++;
721 if (*p[0] == '?') {
722 isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info);
723 p[0]++; 710 p[0]++;
724 } else { 711 strcpy(rs, "\r\n");
725 for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { 712 for (i = 0; i < 8; i++) {
726 if (*p[0] != ',') { 713 sprintf(rss, "%c%s", rp[i] + 48,
727 if ((*p[0] - 48) > maxdccval[i]) { 714 (i < 7) ? "," : "");
728 PARSE_ERROR1; 715 strcat(rs, rss);
729 }
730 rp[i] = *p[0] - 48;
731 p[0]++;
732 if (*p[0] == ',')
733 p[0]++;
734 } else
735 p[0]++;
736 } 716 }
717 isdn_tty_at_cout(rs, info);
718 break;
719 case '=':
720 p[0]++;
721 if (*p[0] == '?') {
722 isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info);
723 p[0]++;
724 } else {
725 for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) {
726 if (*p[0] != ',') {
727 if ((*p[0] - 48) > maxdccval[i]) {
728 PARSE_ERROR1;
729 }
730 rp[i] = *p[0] - 48;
731 p[0]++;
732 if (*p[0] == ',')
733 p[0]++;
734 } else
735 p[0]++;
736 }
737#ifdef ISDN_TTY_FAX_STAT_DEBUG 737#ifdef ISDN_TTY_FAX_STAT_DEBUG
738 printk(KERN_DEBUG "isdn_tty: Fax FDCC capabilities DCE=%d,%d,%d,%d,%d,%d,%d,%d\n", 738 printk(KERN_DEBUG "isdn_tty: Fax FDCC capabilities DCE=%d,%d,%d,%d,%d,%d,%d,%d\n",
739 rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]); 739 rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]);
740#endif 740#endif
741 } 741 }
742 break; 742 break;
743 default: 743 default:
744 PARSE_ERROR1; 744 PARSE_ERROR1;
745 } 745 }
746 return 0; 746 return 0;
747 } 747 }
@@ -752,42 +752,42 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
752 752
753 p[0] += 3; 753 p[0] += 3;
754 switch (*p[0]) { 754 switch (*p[0]) {
755 case '?': 755 case '?':
756 p[0]++;
757 strcpy(rs, "\r\n");
758 for (i = 0; i < 8; i++) {
759 sprintf(rss, "%c%s", rp[i] + 48,
760 (i < 7) ? "," : "");
761 strcat(rs, rss);
762 }
763 isdn_tty_at_cout(rs, info);
764 break;
765 case '=':
766 p[0]++;
767 if (*p[0] == '?') {
768 isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info);
769 p[0]++; 756 p[0]++;
770 } else { 757 strcpy(rs, "\r\n");
771 for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { 758 for (i = 0; i < 8; i++) {
772 if (*p[0] != ',') { 759 sprintf(rss, "%c%s", rp[i] + 48,
773 if ((*p[0] - 48) > maxdccval[i]) { 760 (i < 7) ? "," : "");
774 PARSE_ERROR1; 761 strcat(rs, rss);
775 }
776 rp[i] = *p[0] - 48;
777 p[0]++;
778 if (*p[0] == ',')
779 p[0]++;
780 } else
781 p[0]++;
782 } 762 }
763 isdn_tty_at_cout(rs, info);
764 break;
765 case '=':
766 p[0]++;
767 if (*p[0] == '?') {
768 isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info);
769 p[0]++;
770 } else {
771 for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) {
772 if (*p[0] != ',') {
773 if ((*p[0] - 48) > maxdccval[i]) {
774 PARSE_ERROR1;
775 }
776 rp[i] = *p[0] - 48;
777 p[0]++;
778 if (*p[0] == ',')
779 p[0]++;
780 } else
781 p[0]++;
782 }
783#ifdef ISDN_TTY_FAX_STAT_DEBUG 783#ifdef ISDN_TTY_FAX_STAT_DEBUG
784 printk(KERN_DEBUG "isdn_tty: Fax FDIS session parms=%d,%d,%d,%d,%d,%d,%d,%d\n", 784 printk(KERN_DEBUG "isdn_tty: Fax FDIS session parms=%d,%d,%d,%d,%d,%d,%d,%d\n",
785 rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]); 785 rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]);
786#endif 786#endif
787 } 787 }
788 break; 788 break;
789 default: 789 default:
790 PARSE_ERROR1; 790 PARSE_ERROR1;
791 } 791 }
792 return 0; 792 return 0;
793 } 793 }
@@ -808,18 +808,18 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
808 f->phase = ISDN_FAX_PHASE_C; 808 f->phase = ISDN_FAX_PHASE_C;
809 } else if (f->phase == ISDN_FAX_PHASE_D) { 809 } else if (f->phase == ISDN_FAX_PHASE_D) {
810 switch (f->fet) { 810 switch (f->fet) {
811 case 0: /* next page will be received */ 811 case 0: /* next page will be received */
812 f->phase = ISDN_FAX_PHASE_C; 812 f->phase = ISDN_FAX_PHASE_C;
813 isdn_tty_fax_modem_result(7, info); /* CONNECT */ 813 isdn_tty_fax_modem_result(7, info); /* CONNECT */
814 break; 814 break;
815 case 1: /* next doc will be received */ 815 case 1: /* next doc will be received */
816 f->phase = ISDN_FAX_PHASE_B; 816 f->phase = ISDN_FAX_PHASE_B;
817 break; 817 break;
818 case 2: /* fax session is terminating */ 818 case 2: /* fax session is terminating */
819 f->phase = ISDN_FAX_PHASE_E; 819 f->phase = ISDN_FAX_PHASE_E;
820 break; 820 break;
821 default: 821 default:
822 PARSE_ERROR1; 822 PARSE_ERROR1;
823 } 823 }
824 } 824 }
825 } else { 825 } else {
@@ -830,7 +830,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
830 /* DT=df,vr,wd,ln - TX phase C data command (release DCE to proceed with negotiation) */ 830 /* DT=df,vr,wd,ln - TX phase C data command (release DCE to proceed with negotiation) */
831 if (!strncmp(p[0], "DT", 2)) { 831 if (!strncmp(p[0], "DT", 2)) {
832 int i, val[] = 832 int i, val[] =
833 {4, 0, 2, 3}; 833 {4, 0, 2, 3};
834 char *rp = &f->resolution; 834 char *rp = &f->resolution;
835 835
836 p[0] += 2; 836 p[0] += 2;
@@ -872,29 +872,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
872 if (!strncmp(p[0], "ECM", 3)) { 872 if (!strncmp(p[0], "ECM", 3)) {
873 p[0] += 3; 873 p[0] += 3;
874 switch (*p[0]) { 874 switch (*p[0]) {
875 case '?': 875 case '?':
876 p[0]++;
877 sprintf(rs, "\r\n%d", f->ecm);
878 isdn_tty_at_cout(rs, info);
879 break;
880 case '=':
881 p[0]++;
882 if (*p[0] == '?') {
883 p[0]++; 876 p[0]++;
884 sprintf(rs, "\r\n0,2"); 877 sprintf(rs, "\r\n%d", f->ecm);
885 isdn_tty_at_cout(rs, info); 878 isdn_tty_at_cout(rs, info);
886 } else { 879 break;
887 par = isdn_getnum(p); 880 case '=':
888 if ((par != 0) && (par != 2)) 881 p[0]++;
889 PARSE_ERROR1; 882 if (*p[0] == '?') {
890 f->ecm = par; 883 p[0]++;
884 sprintf(rs, "\r\n0,2");
885 isdn_tty_at_cout(rs, info);
886 } else {
887 par = isdn_getnum(p);
888 if ((par != 0) && (par != 2))
889 PARSE_ERROR1;
890 f->ecm = par;
891#ifdef ISDN_TTY_FAX_STAT_DEBUG 891#ifdef ISDN_TTY_FAX_STAT_DEBUG
892 printk(KERN_DEBUG "isdn_tty: Fax FECM=%d\n", par); 892 printk(KERN_DEBUG "isdn_tty: Fax FECM=%d\n", par);
893#endif 893#endif
894 } 894 }
895 break; 895 break;
896 default: 896 default:
897 PARSE_ERROR1; 897 PARSE_ERROR1;
898 } 898 }
899 return 0; 899 return 0;
900 } 900 }
@@ -938,36 +938,36 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
938 int i, r; 938 int i, r;
939 p[0] += 3; 939 p[0] += 3;
940 switch (*p[0]) { 940 switch (*p[0]) {
941 case '?': 941 case '?':
942 p[0]++;
943 sprintf(rs, "\r\n\"%s\"", f->id);
944 isdn_tty_at_cout(rs, info);
945 break;
946 case '=':
947 p[0]++;
948 if (*p[0] == '?') {
949 p[0]++; 942 p[0]++;
950 sprintf(rs, "\r\n\"STRING\""); 943 sprintf(rs, "\r\n\"%s\"", f->id);
951 isdn_tty_at_cout(rs, info); 944 isdn_tty_at_cout(rs, info);
952 } else { 945 break;
953 if (*p[0] == '"') 946 case '=':
954 p[0]++; 947 p[0]++;
955 for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { 948 if (*p[0] == '?') {
956 f->id[i] = *p[0]++;
957 }
958 if (*p[0] == '"')
959 p[0]++; 949 p[0]++;
960 for (r = i; r < FAXIDLEN; r++) { 950 sprintf(rs, "\r\n\"STRING\"");
961 f->id[r] = 32; 951 isdn_tty_at_cout(rs, info);
962 } 952 } else {
963 f->id[FAXIDLEN - 1] = 0; 953 if (*p[0] == '"')
954 p[0]++;
955 for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) {
956 f->id[i] = *p[0]++;
957 }
958 if (*p[0] == '"')
959 p[0]++;
960 for (r = i; r < FAXIDLEN; r++) {
961 f->id[r] = 32;
962 }
963 f->id[FAXIDLEN - 1] = 0;
964#ifdef ISDN_TTY_FAX_STAT_DEBUG 964#ifdef ISDN_TTY_FAX_STAT_DEBUG
965 printk(KERN_DEBUG "isdn_tty: Fax local ID \"%s\"\n", f->id); 965 printk(KERN_DEBUG "isdn_tty: Fax local ID \"%s\"\n", f->id);
966#endif 966#endif
967 } 967 }
968 break; 968 break;
969 default: 969 default:
970 PARSE_ERROR1; 970 PARSE_ERROR1;
971 } 971 }
972 return 0; 972 return 0;
973 } 973 }
@@ -994,29 +994,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
994 if (!strncmp(p[0], "MINSP", 5)) { 994 if (!strncmp(p[0], "MINSP", 5)) {
995 p[0] += 5; 995 p[0] += 5;
996 switch (*p[0]) { 996 switch (*p[0]) {
997 case '?': 997 case '?':
998 p[0]++;
999 sprintf(rs, "\r\n%d", f->minsp);
1000 isdn_tty_at_cout(rs, info);
1001 break;
1002 case '=':
1003 p[0]++;
1004 if (*p[0] == '?') {
1005 p[0]++; 998 p[0]++;
1006 sprintf(rs, "\r\n0-5"); 999 sprintf(rs, "\r\n%d", f->minsp);
1007 isdn_tty_at_cout(rs, info); 1000 isdn_tty_at_cout(rs, info);
1008 } else { 1001 break;
1009 par = isdn_getnum(p); 1002 case '=':
1010 if ((par < 0) || (par > 5)) 1003 p[0]++;
1011 PARSE_ERROR1; 1004 if (*p[0] == '?') {
1012 f->minsp = par; 1005 p[0]++;
1006 sprintf(rs, "\r\n0-5");
1007 isdn_tty_at_cout(rs, info);
1008 } else {
1009 par = isdn_getnum(p);
1010 if ((par < 0) || (par > 5))
1011 PARSE_ERROR1;
1012 f->minsp = par;
1013#ifdef ISDN_TTY_FAX_STAT_DEBUG 1013#ifdef ISDN_TTY_FAX_STAT_DEBUG
1014 printk(KERN_DEBUG "isdn_tty: Fax FMINSP=%d\n", par); 1014 printk(KERN_DEBUG "isdn_tty: Fax FMINSP=%d\n", par);
1015#endif 1015#endif
1016 } 1016 }
1017 break; 1017 break;
1018 default: 1018 default:
1019 PARSE_ERROR1; 1019 PARSE_ERROR1;
1020 } 1020 }
1021 return 0; 1021 return 0;
1022 } 1022 }
@@ -1024,29 +1024,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
1024 if (!strncmp(p[0], "PHCTO", 5)) { 1024 if (!strncmp(p[0], "PHCTO", 5)) {
1025 p[0] += 5; 1025 p[0] += 5;
1026 switch (*p[0]) { 1026 switch (*p[0]) {
1027 case '?': 1027 case '?':
1028 p[0]++;
1029 sprintf(rs, "\r\n%d", f->phcto);
1030 isdn_tty_at_cout(rs, info);
1031 break;
1032 case '=':
1033 p[0]++;
1034 if (*p[0] == '?') {
1035 p[0]++; 1028 p[0]++;
1036 sprintf(rs, "\r\n0-255"); 1029 sprintf(rs, "\r\n%d", f->phcto);
1037 isdn_tty_at_cout(rs, info); 1030 isdn_tty_at_cout(rs, info);
1038 } else { 1031 break;
1039 par = isdn_getnum(p); 1032 case '=':
1040 if ((par < 0) || (par > 255)) 1033 p[0]++;
1041 PARSE_ERROR1; 1034 if (*p[0] == '?') {
1042 f->phcto = par; 1035 p[0]++;
1036 sprintf(rs, "\r\n0-255");
1037 isdn_tty_at_cout(rs, info);
1038 } else {
1039 par = isdn_getnum(p);
1040 if ((par < 0) || (par > 255))
1041 PARSE_ERROR1;
1042 f->phcto = par;
1043#ifdef ISDN_TTY_FAX_STAT_DEBUG 1043#ifdef ISDN_TTY_FAX_STAT_DEBUG
1044 printk(KERN_DEBUG "isdn_tty: Fax FPHCTO=%d\n", par); 1044 printk(KERN_DEBUG "isdn_tty: Fax FPHCTO=%d\n", par);
1045#endif 1045#endif
1046 } 1046 }
1047 break; 1047 break;
1048 default: 1048 default:
1049 PARSE_ERROR1; 1049 PARSE_ERROR1;
1050 } 1050 }
1051 return 0; 1051 return 0;
1052 } 1052 }
@@ -1055,29 +1055,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
1055 if (!strncmp(p[0], "REL", 3)) { 1055 if (!strncmp(p[0], "REL", 3)) {
1056 p[0] += 3; 1056 p[0] += 3;
1057 switch (*p[0]) { 1057 switch (*p[0]) {
1058 case '?': 1058 case '?':
1059 p[0]++;
1060 sprintf(rs, "\r\n%d", f->rel);
1061 isdn_tty_at_cout(rs, info);
1062 break;
1063 case '=':
1064 p[0]++;
1065 if (*p[0] == '?') {
1066 p[0]++; 1059 p[0]++;
1067 sprintf(rs, "\r\n0,1"); 1060 sprintf(rs, "\r\n%d", f->rel);
1068 isdn_tty_at_cout(rs, info); 1061 isdn_tty_at_cout(rs, info);
1069 } else { 1062 break;
1070 par = isdn_getnum(p); 1063 case '=':
1071 if ((par < 0) || (par > 1)) 1064 p[0]++;
1072 PARSE_ERROR1; 1065 if (*p[0] == '?') {
1073 f->rel = par; 1066 p[0]++;
1067 sprintf(rs, "\r\n0,1");
1068 isdn_tty_at_cout(rs, info);
1069 } else {
1070 par = isdn_getnum(p);
1071 if ((par < 0) || (par > 1))
1072 PARSE_ERROR1;
1073 f->rel = par;
1074#ifdef ISDN_TTY_FAX_STAT_DEBUG 1074#ifdef ISDN_TTY_FAX_STAT_DEBUG
1075 printk(KERN_DEBUG "isdn_tty: Fax FREL=%d\n", par); 1075 printk(KERN_DEBUG "isdn_tty: Fax FREL=%d\n", par);
1076#endif 1076#endif
1077 } 1077 }
1078 break; 1078 break;
1079 default: 1079 default:
1080 PARSE_ERROR1; 1080 PARSE_ERROR1;
1081 } 1081 }
1082 return 0; 1082 return 0;
1083 } 1083 }
@@ -1100,11 +1100,11 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
1100 printk(KERN_DEBUG "isdn_tty: Fax FTBC=%c\n", *p[0]); 1100 printk(KERN_DEBUG "isdn_tty: Fax FTBC=%c\n", *p[0]);
1101#endif 1101#endif
1102 switch (*p[0]) { 1102 switch (*p[0]) {
1103 case '0': 1103 case '0':
1104 p[0]++; 1104 p[0]++;
1105 break; 1105 break;
1106 default: 1106 default:
1107 PARSE_ERROR1; 1107 PARSE_ERROR1;
1108 } 1108 }
1109 return 0; 1109 return 0;
1110 } 1110 }
@@ -1113,7 +1113,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info *info)
1113} 1113}
1114 1114
1115int 1115int
1116isdn_tty_cmd_PLUSF_FAX(char **p, modem_info *info) 1116isdn_tty_cmd_PLUSF_FAX(char **p, modem_info * info)
1117{ 1117{
1118 if (TTY_IS_FCLASS2(info)) 1118 if (TTY_IS_FCLASS2(info))
1119 return (isdn_tty_cmd_FCLASS2(p, info)); 1119 return (isdn_tty_cmd_FCLASS2(p, info));
diff --git a/drivers/isdn/i4l/isdn_ttyfax.h b/drivers/isdn/i4l/isdn_ttyfax.h
index ccda4fcf8f7..757a8901002 100644
--- a/drivers/isdn/i4l/isdn_ttyfax.h
+++ b/drivers/isdn/i4l/isdn_ttyfax.h
@@ -15,3 +15,4 @@
15#define XON 0x11 15#define XON 0x11
16#define XOFF 0x13 16#define XOFF 0x13
17#define DC2 0x12 17#define DC2 0x12
18
diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c
index 52827a80c51..c5d02b6aafa 100644
--- a/drivers/isdn/i4l/isdn_v110.c
+++ b/drivers/isdn/i4l/isdn_v110.c
@@ -26,8 +26,8 @@ char *isdn_v110_revision = "$Revision: 1.1.2.2 $";
26#define V110_19200 15 26#define V110_19200 15
27#define V110_9600 3 27#define V110_9600 3
28 28
29/* 29/*
30 * The following data are precoded matrices, online and offline matrix 30 * The following data are precoded matrices, online and offline matrix
31 * for 9600, 19200 und 38400, respectively 31 * for 9600, 19200 und 38400, respectively
32 */ 32 */
33static unsigned char V110_OnMatrix_9600[] = 33static unsigned char V110_OnMatrix_9600[] =
@@ -56,7 +56,7 @@ static unsigned char V110_OnMatrix_38400[] =
56static unsigned char V110_OffMatrix_38400[] = 56static unsigned char V110_OffMatrix_38400[] =
57{0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff}; 57{0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff};
58 58
59/* 59/*
60 * FlipBits reorders sequences of keylen bits in one byte. 60 * FlipBits reorders sequences of keylen bits in one byte.
61 * E.g. source order 7654321 will be converted to 45670123 when keylen = 4, 61 * E.g. source order 7654321 will be converted to 45670123 when keylen = 4,
62 * and to 67452301 when keylen = 2. This is necessary because ordering on 62 * and to 67452301 when keylen = 2. This is necessary because ordering on
@@ -103,18 +103,18 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
103 v->decodelen = 0; 103 v->decodelen = 0;
104 104
105 switch (key) { 105 switch (key) {
106 case V110_38400: 106 case V110_38400:
107 v->OnlineFrame = V110_OnMatrix_38400; 107 v->OnlineFrame = V110_OnMatrix_38400;
108 v->OfflineFrame = V110_OffMatrix_38400; 108 v->OfflineFrame = V110_OffMatrix_38400;
109 break; 109 break;
110 case V110_19200: 110 case V110_19200:
111 v->OnlineFrame = V110_OnMatrix_19200; 111 v->OnlineFrame = V110_OnMatrix_19200;
112 v->OfflineFrame = V110_OffMatrix_19200; 112 v->OfflineFrame = V110_OffMatrix_19200;
113 break; 113 break;
114 default: 114 default:
115 v->OnlineFrame = V110_OnMatrix_9600; 115 v->OnlineFrame = V110_OnMatrix_9600;
116 v->OfflineFrame = V110_OffMatrix_9600; 116 v->OfflineFrame = V110_OffMatrix_9600;
117 break; 117 break;
118 } 118 }
119 v->framelen = v->nbytes * 10; 119 v->framelen = v->nbytes * 10;
120 v->SyncInit = 5; 120 v->SyncInit = 5;
@@ -132,7 +132,7 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
132 132
133/* isdn_v110_close frees private V.110 data structures */ 133/* isdn_v110_close frees private V.110 data structures */
134void 134void
135isdn_v110_close(isdn_v110_stream *v) 135isdn_v110_close(isdn_v110_stream * v)
136{ 136{
137 if (v == NULL) 137 if (v == NULL)
138 return; 138 return;
@@ -144,11 +144,11 @@ isdn_v110_close(isdn_v110_stream *v)
144} 144}
145 145
146 146
147/* 147/*
148 * ValidHeaderBytes return the number of valid bytes in v->decodebuf 148 * ValidHeaderBytes return the number of valid bytes in v->decodebuf
149 */ 149 */
150static int 150static int
151ValidHeaderBytes(isdn_v110_stream *v) 151ValidHeaderBytes(isdn_v110_stream * v)
152{ 152{
153 int i; 153 int i;
154 for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++) 154 for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++)
@@ -157,11 +157,11 @@ ValidHeaderBytes(isdn_v110_stream *v)
157 return i; 157 return i;
158} 158}
159 159
160/* 160/*
161 * SyncHeader moves the decodebuf ptr to the next valid header 161 * SyncHeader moves the decodebuf ptr to the next valid header
162 */ 162 */
163static void 163static void
164SyncHeader(isdn_v110_stream *v) 164SyncHeader(isdn_v110_stream * v)
165{ 165{
166 unsigned char *rbuf = v->decodebuf; 166 unsigned char *rbuf = v->decodebuf;
167 int len = v->decodelen; 167 int len = v->decodelen;
@@ -185,9 +185,9 @@ SyncHeader(isdn_v110_stream *v)
185 only complete matices must be given. 185 only complete matices must be given.
186 From these, netto data is extracted and returned in buf. The return-value 186 From these, netto data is extracted and returned in buf. The return-value
187 is the bytecount of the decoded data. 187 is the bytecount of the decoded data.
188*/ 188 */
189static int 189static int
190DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf) 190DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf)
191{ 191{
192 int line = 0; 192 int line = 0;
193 int buflen = 0; 193 int buflen = 0;
@@ -203,7 +203,7 @@ DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf)
203 printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n"); 203 printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n");
204 /* returning now is not the right thing, though :-( */ 204 /* returning now is not the right thing, though :-( */
205#endif 205#endif
206 } 206 }
207 line++; /* next line of matrix */ 207 line++; /* next line of matrix */
208 continue; 208 continue;
209 } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */ 209 } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */
@@ -217,7 +217,7 @@ DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf)
217 continue; 217 continue;
218 } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */ 218 } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */
219 introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */ 219 introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */
220 next_byte: 220 next_byte:
221 if (mbit > 2) { /* was it the last bit in this line ? */ 221 if (mbit > 2) { /* was it the last bit in this line ? */
222 mbit >>= 1; /* no -> take next */ 222 mbit >>= 1; /* no -> take next */
223 continue; 223 continue;
@@ -246,13 +246,13 @@ DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf)
246 return buflen; /* return number of bytes in the output buffer */ 246 return buflen; /* return number of bytes in the output buffer */
247} 247}
248 248
249/* 249/*
250 * DecodeStream receives V.110 coded data from the input stream. It recovers the 250 * DecodeStream receives V.110 coded data from the input stream. It recovers the
251 * original frames. 251 * original frames.
252 * The input stream doesn't need to be framed 252 * The input stream doesn't need to be framed
253 */ 253 */
254struct sk_buff * 254struct sk_buff *
255isdn_v110_decode(isdn_v110_stream *v, struct sk_buff *skb) 255isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
256{ 256{
257 int i; 257 int i;
258 int j; 258 int j;
@@ -283,7 +283,7 @@ isdn_v110_decode(isdn_v110_stream *v, struct sk_buff *skb)
283 /* copy new data to decode-buffer */ 283 /* copy new data to decode-buffer */
284 memcpy(&(v->decodebuf[v->decodelen]), rbuf, len); 284 memcpy(&(v->decodebuf[v->decodelen]), rbuf, len);
285 v->decodelen += len; 285 v->decodelen += len;
286ReSync: 286 ReSync:
287 if (v->decodelen < v->nbytes) { /* got a new header ? */ 287 if (v->decodelen < v->nbytes) { /* got a new header ? */
288 dev_kfree_skb(skb); 288 dev_kfree_skb(skb);
289 return NULL; /* no, try later */ 289 return NULL; /* no, try later */
@@ -320,7 +320,7 @@ ReSync:
320/* EncodeMatrix takes input data in buf, len is the bytecount. 320/* EncodeMatrix takes input data in buf, len is the bytecount.
321 Data is encoded into v110 frames in m. Return value is the number of 321 Data is encoded into v110 frames in m. Return value is the number of
322 matrix-lines generated. 322 matrix-lines generated.
323*/ 323 */
324static int 324static int
325EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) 325EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
326{ 326{
@@ -333,14 +333,14 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
333 333
334 while ((i < len) && (line < mlen)) { /* while we still have input data */ 334 while ((i < len) && (line < mlen)) { /* while we still have input data */
335 switch (line % 10) { /* in which line of the matrix are we? */ 335 switch (line % 10) { /* in which line of the matrix are we? */
336 case 0: 336 case 0:
337 m[line++] = 0x00; /* line 0 is always 0 */ 337 m[line++] = 0x00; /* line 0 is always 0 */
338 mbit = 128; /* go on with the 7th bit */ 338 mbit = 128; /* go on with the 7th bit */
339 break; 339 break;
340 case 5: 340 case 5:
341 m[line++] = 0xbf; /* line 5 is always 10111111 */ 341 m[line++] = 0xbf; /* line 5 is always 10111111 */
342 mbit = 128; /* go on with the 7th bit */ 342 mbit = 128; /* go on with the 7th bit */
343 break; 343 break;
344 } 344 }
345 if (line >= mlen) { 345 if (line >= mlen) {
346 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); 346 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
@@ -348,16 +348,16 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
348 } 348 }
349 next_bit: 349 next_bit:
350 switch (mbit) { /* leftmost or rightmost bit ? */ 350 switch (mbit) { /* leftmost or rightmost bit ? */
351 case 1: 351 case 1:
352 line++; /* rightmost -> go to next line */ 352 line++; /* rightmost -> go to next line */
353 if (line >= mlen) { 353 if (line >= mlen) {
354 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); 354 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
355 return line; 355 return line;
356 } 356 }
357 case 128: 357 case 128:
358 m[line] = 128; /* leftmost -> set byte to 1000000 */ 358 m[line] = 128; /* leftmost -> set byte to 1000000 */
359 mbit = 64; /* current bit in the matrix line */ 359 mbit = 64; /* current bit in the matrix line */
360 continue; 360 continue;
361 } 361 }
362 if (introducer) { /* set 110 sequence ? */ 362 if (introducer) { /* set 110 sequence ? */
363 introducer--; /* set on digit less */ 363 introducer--; /* set on digit less */
@@ -384,24 +384,24 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
384 /* if necessary, generate remaining lines of the matrix... */ 384 /* if necessary, generate remaining lines of the matrix... */
385 if ((line) && ((line + 10) < mlen)) 385 if ((line) && ((line + 10) < mlen))
386 switch (++line % 10) { 386 switch (++line % 10) {
387 case 1: 387 case 1:
388 m[line++] = 0xfe; 388 m[line++] = 0xfe;
389 case 2: 389 case 2:
390 m[line++] = 0xfe; 390 m[line++] = 0xfe;
391 case 3: 391 case 3:
392 m[line++] = 0xfe; 392 m[line++] = 0xfe;
393 case 4: 393 case 4:
394 m[line++] = 0xfe; 394 m[line++] = 0xfe;
395 case 5: 395 case 5:
396 m[line++] = 0xbf; 396 m[line++] = 0xbf;
397 case 6: 397 case 6:
398 m[line++] = 0xfe; 398 m[line++] = 0xfe;
399 case 7: 399 case 7:
400 m[line++] = 0xfe; 400 m[line++] = 0xfe;
401 case 8: 401 case 8:
402 m[line++] = 0xfe; 402 m[line++] = 0xfe;
403 case 9: 403 case 9:
404 m[line++] = 0xfe; 404 m[line++] = 0xfe;
405 } 405 }
406 return line; /* that's how many lines we have */ 406 return line; /* that's how many lines we have */
407} 407}
@@ -447,7 +447,7 @@ isdn_v110_idle(isdn_v110_stream *v)
447} 447}
448 448
449struct sk_buff * 449struct sk_buff *
450isdn_v110_encode(isdn_v110_stream *v, struct sk_buff *skb) 450isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb)
451{ 451{
452 int i; 452 int i;
453 int j; 453 int j;
@@ -524,93 +524,93 @@ isdn_v110_stat_callback(int idx, isdn_ctrl *c)
524 if (idx < 0) 524 if (idx < 0)
525 return 0; 525 return 0;
526 switch (c->command) { 526 switch (c->command) {
527 case ISDN_STAT_BSENT: 527 case ISDN_STAT_BSENT:
528 /* Keep the send-queue of the driver filled 528 /* Keep the send-queue of the driver filled
529 * with frames: 529 * with frames:
530 * If number of outstanding frames < 3, 530 * If number of outstanding frames < 3,
531 * send down an Idle-Frame (or an Sync-Frame, if 531 * send down an Idle-Frame (or an Sync-Frame, if
532 * v->SyncInit != 0). 532 * v->SyncInit != 0).
533 */ 533 */
534 if (!(v = dev->v110[idx])) 534 if (!(v = dev->v110[idx]))
535 return 0; 535 return 0;
536 atomic_inc(&dev->v110use[idx]); 536 atomic_inc(&dev->v110use[idx]);
537 for (i = 0; i * v->framelen < c->parm.length; i++) { 537 for (i=0; i * v->framelen < c->parm.length; i++) {
538 if (v->skbidle > 0) { 538 if (v->skbidle > 0) {
539 v->skbidle--; 539 v->skbidle--;
540 ret = 1; 540 ret = 1;
541 } else {
542 if (v->skbuser > 0)
543 v->skbuser--;
544 ret = 0;
545 }
546 }
547 for (i = v->skbuser + v->skbidle; i < 2; i++) {
548 struct sk_buff *skb;
549 if (v->SyncInit > 0)
550 skb = isdn_v110_sync(v);
551 else
552 skb = isdn_v110_idle(v);
553 if (skb) {
554 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
555 dev_kfree_skb(skb);
556 break;
557 } else { 541 } else {
558 if (v->SyncInit) 542 if (v->skbuser > 0)
559 v->SyncInit--; 543 v->skbuser--;
560 v->skbidle++; 544 ret = 0;
561 } 545 }
562 } else
563 break;
564 }
565 atomic_dec(&dev->v110use[idx]);
566 return ret;
567 case ISDN_STAT_DHUP:
568 case ISDN_STAT_BHUP:
569 while (1) {
570 atomic_inc(&dev->v110use[idx]);
571 if (atomic_dec_and_test(&dev->v110use[idx])) {
572 isdn_v110_close(dev->v110[idx]);
573 dev->v110[idx] = NULL;
574 break;
575 }
576 mdelay(1);
577 }
578 break;
579 case ISDN_STAT_BCONN:
580 if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
581 int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
582 int maxsize = dev->drv[c->driver]->interface->maxbufsize;
583 atomic_inc(&dev->v110use[idx]);
584 switch (dev->v110emu[idx]) {
585 case ISDN_PROTO_L2_V11096:
586 dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
587 break;
588 case ISDN_PROTO_L2_V11019:
589 dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
590 break;
591 case ISDN_PROTO_L2_V11038:
592 dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
593 break;
594 default:;
595 } 546 }
596 if ((v = dev->v110[idx])) { 547 for (i = v->skbuser + v->skbidle; i < 2; i++) {
597 while (v->SyncInit) { 548 struct sk_buff *skb;
598 struct sk_buff *skb = isdn_v110_sync(v); 549 if (v->SyncInit > 0)
550 skb = isdn_v110_sync(v);
551 else
552 skb = isdn_v110_idle(v);
553 if (skb) {
599 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { 554 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
600 dev_kfree_skb(skb); 555 dev_kfree_skb(skb);
601 /* Unable to send, try later */
602 break; 556 break;
557 } else {
558 if (v->SyncInit)
559 v->SyncInit--;
560 v->skbidle++;
603 } 561 }
604 v->SyncInit--; 562 } else
605 v->skbidle++; 563 break;
606 } 564 }
607 } else
608 printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
609 atomic_dec(&dev->v110use[idx]); 565 atomic_dec(&dev->v110use[idx]);
610 } 566 return ret;
611 break; 567 case ISDN_STAT_DHUP:
612 default: 568 case ISDN_STAT_BHUP:
613 return 0; 569 while (1) {
570 atomic_inc(&dev->v110use[idx]);
571 if (atomic_dec_and_test(&dev->v110use[idx])) {
572 isdn_v110_close(dev->v110[idx]);
573 dev->v110[idx] = NULL;
574 break;
575 }
576 mdelay(1);
577 }
578 break;
579 case ISDN_STAT_BCONN:
580 if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
581 int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
582 int maxsize = dev->drv[c->driver]->interface->maxbufsize;
583 atomic_inc(&dev->v110use[idx]);
584 switch (dev->v110emu[idx]) {
585 case ISDN_PROTO_L2_V11096:
586 dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
587 break;
588 case ISDN_PROTO_L2_V11019:
589 dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
590 break;
591 case ISDN_PROTO_L2_V11038:
592 dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
593 break;
594 default:;
595 }
596 if ((v = dev->v110[idx])) {
597 while (v->SyncInit) {
598 struct sk_buff *skb = isdn_v110_sync(v);
599 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
600 dev_kfree_skb(skb);
601 /* Unable to send, try later */
602 break;
603 }
604 v->SyncInit--;
605 v->skbidle++;
606 }
607 } else
608 printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
609 atomic_dec(&dev->v110use[idx]);
610 }
611 break;
612 default:
613 return 0;
614 } 614 }
615 return 0; 615 return 0;
616} 616}
diff --git a/drivers/isdn/i4l/isdn_v110.h b/drivers/isdn/i4l/isdn_v110.h
index de774ab598c..08f274bbc43 100644
--- a/drivers/isdn/i4l/isdn_v110.h
+++ b/drivers/isdn/i4l/isdn_v110.h
@@ -12,18 +12,18 @@
12#ifndef _isdn_v110_h_ 12#ifndef _isdn_v110_h_
13#define _isdn_v110_h_ 13#define _isdn_v110_h_
14 14
15/* 15/*
16 * isdn_v110_encode will take raw data and encode it using V.110 16 * isdn_v110_encode will take raw data and encode it using V.110
17 */ 17 */
18extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *); 18extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *);
19 19
20/* 20/*
21 * isdn_v110_decode receives V.110 coded data from the stream and rebuilds 21 * isdn_v110_decode receives V.110 coded data from the stream and rebuilds
22 * frames from them. The source stream doesn't need to be framed. 22 * frames from them. The source stream doesn't need to be framed.
23 */ 23 */
24extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *); 24extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *);
25 25
26extern int isdn_v110_stat_callback(int, isdn_ctrl *); 26extern int isdn_v110_stat_callback(int, isdn_ctrl *);
27extern void isdn_v110_close(isdn_v110_stream *v); 27extern void isdn_v110_close(isdn_v110_stream * v);
28 28
29#endif 29#endif
diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
index e2d4e58230f..fd10d7c785d 100644
--- a/drivers/isdn/i4l/isdn_x25iface.c
+++ b/drivers/isdn/i4l/isdn_x25iface.c
@@ -26,7 +26,7 @@
26#include "isdn_x25iface.h" 26#include "isdn_x25iface.h"
27 27
28/* for debugging messages not to cause an oops when device pointer is NULL*/ 28/* for debugging messages not to cause an oops when device pointer is NULL*/
29#define MY_DEVNAME(dev) ((dev) ? (dev)->name : "DEVICE UNSPECIFIED") 29#define MY_DEVNAME(dev) ( (dev) ? (dev)->name : "DEVICE UNSPECIFIED" )
30 30
31 31
32typedef struct isdn_x25iface_proto_data { 32typedef struct isdn_x25iface_proto_data {
@@ -34,22 +34,22 @@ typedef struct isdn_x25iface_proto_data {
34 enum wan_states state; 34 enum wan_states state;
35 /* Private stuff, not to be accessed via proto_data. We provide the 35 /* Private stuff, not to be accessed via proto_data. We provide the
36 other storage for the concap_proto instance here as well, 36 other storage for the concap_proto instance here as well,
37 enabling us to allocate both with just one kmalloc(): */ 37 enabling us to allocate both with just one kmalloc(): */
38 struct concap_proto priv; 38 struct concap_proto priv;
39} ix25_pdata_t; 39} ix25_pdata_t;
40 40
41 41
42 42
43/* is now in header file (extern): struct concap_proto * isdn_x25iface_proto_new(void); */ 43/* is now in header file (extern): struct concap_proto * isdn_x25iface_proto_new(void); */
44static void isdn_x25iface_proto_del(struct concap_proto *); 44static void isdn_x25iface_proto_del( struct concap_proto * );
45static int isdn_x25iface_proto_close(struct concap_proto *); 45static int isdn_x25iface_proto_close( struct concap_proto * );
46static int isdn_x25iface_proto_restart(struct concap_proto *, 46static int isdn_x25iface_proto_restart( struct concap_proto *,
47 struct net_device *, 47 struct net_device *,
48 struct concap_device_ops *); 48 struct concap_device_ops *);
49static int isdn_x25iface_xmit(struct concap_proto *, struct sk_buff *); 49static int isdn_x25iface_xmit( struct concap_proto *, struct sk_buff * );
50static int isdn_x25iface_receive(struct concap_proto *, struct sk_buff *); 50static int isdn_x25iface_receive( struct concap_proto *, struct sk_buff * );
51static int isdn_x25iface_connect_ind(struct concap_proto *); 51static int isdn_x25iface_connect_ind( struct concap_proto * );
52static int isdn_x25iface_disconn_ind(struct concap_proto *); 52static int isdn_x25iface_disconn_ind( struct concap_proto * );
53 53
54 54
55static struct concap_proto_ops ix25_pops = { 55static struct concap_proto_ops ix25_pops = {
@@ -64,65 +64,65 @@ static struct concap_proto_ops ix25_pops = {
64}; 64};
65 65
66/* error message helper function */ 66/* error message helper function */
67static void illegal_state_warn(unsigned state, unsigned char firstbyte) 67static void illegal_state_warn( unsigned state, unsigned char firstbyte)
68{ 68{
69 printk(KERN_WARNING "isdn_x25iface: firstbyte %x illegal in" 69 printk( KERN_WARNING "isdn_x25iface: firstbyte %x illegal in"
70 "current state %d\n", firstbyte, state); 70 "current state %d\n",firstbyte, state );
71} 71}
72 72
73/* check protocol data field for consistency */ 73/* check protocol data field for consistency */
74static int pdata_is_bad(ix25_pdata_t *pda) { 74static int pdata_is_bad( ix25_pdata_t * pda ){
75 75
76 if (pda && pda->magic == ISDN_X25IFACE_MAGIC) return 0; 76 if( pda && pda -> magic == ISDN_X25IFACE_MAGIC ) return 0;
77 printk(KERN_WARNING 77 printk( KERN_WARNING
78 "isdn_x25iface_xxx: illegal pointer to proto data\n"); 78 "isdn_x25iface_xxx: illegal pointer to proto data\n" );
79 return 1; 79 return 1;
80} 80}
81 81
82/* create a new x25 interface protocol instance 82/* create a new x25 interface protocol instance
83 */ 83 */
84struct concap_proto *isdn_x25iface_proto_new(void) 84struct concap_proto * isdn_x25iface_proto_new(void)
85{ 85{
86 ix25_pdata_t *tmp = kmalloc(sizeof(ix25_pdata_t), GFP_KERNEL); 86 ix25_pdata_t * tmp = kmalloc(sizeof(ix25_pdata_t),GFP_KERNEL);
87 IX25DEBUG("isdn_x25iface_proto_new\n"); 87 IX25DEBUG("isdn_x25iface_proto_new\n");
88 if (tmp) { 88 if( tmp ){
89 tmp->magic = ISDN_X25IFACE_MAGIC; 89 tmp -> magic = ISDN_X25IFACE_MAGIC;
90 tmp->state = WAN_UNCONFIGURED; 90 tmp -> state = WAN_UNCONFIGURED;
91 /* private data space used to hold the concap_proto data. 91 /* private data space used to hold the concap_proto data.
92 Only to be accessed via the returned pointer */ 92 Only to be accessed via the returned pointer */
93 spin_lock_init(&tmp->priv.lock); 93 spin_lock_init(&tmp->priv.lock);
94 tmp->priv.dops = NULL; 94 tmp -> priv.dops = NULL;
95 tmp->priv.net_dev = NULL; 95 tmp -> priv.net_dev = NULL;
96 tmp->priv.pops = &ix25_pops; 96 tmp -> priv.pops = &ix25_pops;
97 tmp->priv.flags = 0; 97 tmp -> priv.flags = 0;
98 tmp->priv.proto_data = tmp; 98 tmp -> priv.proto_data = tmp;
99 return (&(tmp->priv)); 99 return( &(tmp -> priv) );
100 } 100 }
101 return NULL; 101 return NULL;
102}; 102};
103 103
104/* close the x25iface encapsulation protocol 104/* close the x25iface encapsulation protocol
105 */ 105 */
106static int isdn_x25iface_proto_close(struct concap_proto *cprot) { 106static int isdn_x25iface_proto_close(struct concap_proto *cprot){
107 107
108 ix25_pdata_t *tmp; 108 ix25_pdata_t *tmp;
109 int ret = 0; 109 int ret = 0;
110 ulong flags; 110 ulong flags;
111 111
112 if (!cprot) { 112 if( ! cprot ){
113 printk(KERN_ERR "isdn_x25iface_proto_close: " 113 printk( KERN_ERR "isdn_x25iface_proto_close: "
114 "invalid concap_proto pointer\n"); 114 "invalid concap_proto pointer\n" );
115 return -1; 115 return -1;
116 } 116 }
117 IX25DEBUG("isdn_x25iface_proto_close %s \n", MY_DEVNAME(cprot->net_dev)); 117 IX25DEBUG( "isdn_x25iface_proto_close %s \n", MY_DEVNAME(cprot -> net_dev) );
118 spin_lock_irqsave(&cprot->lock, flags); 118 spin_lock_irqsave(&cprot->lock, flags);
119 cprot->dops = NULL; 119 cprot -> dops = NULL;
120 cprot->net_dev = NULL; 120 cprot -> net_dev = NULL;
121 tmp = cprot->proto_data; 121 tmp = cprot -> proto_data;
122 if (pdata_is_bad(tmp)) { 122 if( pdata_is_bad( tmp ) ){
123 ret = -1; 123 ret = -1;
124 } else { 124 } else {
125 tmp->state = WAN_UNCONFIGURED; 125 tmp -> state = WAN_UNCONFIGURED;
126 } 126 }
127 spin_unlock_irqrestore(&cprot->lock, flags); 127 spin_unlock_irqrestore(&cprot->lock, flags);
128 return ret; 128 return ret;
@@ -130,100 +130,100 @@ static int isdn_x25iface_proto_close(struct concap_proto *cprot) {
130 130
131/* Delete the x25iface encapsulation protocol instance 131/* Delete the x25iface encapsulation protocol instance
132 */ 132 */
133static void isdn_x25iface_proto_del(struct concap_proto *cprot) { 133static void isdn_x25iface_proto_del(struct concap_proto *cprot){
134
135 ix25_pdata_t *tmp;
136 134
137 IX25DEBUG("isdn_x25iface_proto_del \n"); 135 ix25_pdata_t * tmp;
138 if (!cprot) { 136
139 printk(KERN_ERR "isdn_x25iface_proto_del: " 137 IX25DEBUG( "isdn_x25iface_proto_del \n" );
140 "concap_proto pointer is NULL\n"); 138 if( ! cprot ){
139 printk( KERN_ERR "isdn_x25iface_proto_del: "
140 "concap_proto pointer is NULL\n" );
141 return; 141 return;
142 } 142 }
143 tmp = cprot->proto_data; 143 tmp = cprot -> proto_data;
144 if (tmp == NULL) { 144 if( tmp == NULL ){
145 printk(KERN_ERR "isdn_x25iface_proto_del: inconsistent " 145 printk( KERN_ERR "isdn_x25iface_proto_del: inconsistent "
146 "proto_data pointer (maybe already deleted?)\n"); 146 "proto_data pointer (maybe already deleted?)\n");
147 return; 147 return;
148 } 148 }
149 /* close if the protocol is still open */ 149 /* close if the protocol is still open */
150 if (cprot->dops) isdn_x25iface_proto_close(cprot); 150 if( cprot -> dops ) isdn_x25iface_proto_close(cprot);
151 /* freeing the storage should be sufficient now. But some additional 151 /* freeing the storage should be sufficient now. But some additional
152 settings might help to catch wild pointer bugs */ 152 settings might help to catch wild pointer bugs */
153 tmp->magic = 0; 153 tmp -> magic = 0;
154 cprot->proto_data = NULL; 154 cprot -> proto_data = NULL;
155 155
156 kfree(tmp); 156 kfree( tmp );
157 return; 157 return;
158} 158}
159 159
160/* (re-)initialize the data structures for x25iface encapsulation 160/* (re-)initialize the data structures for x25iface encapsulation
161 */ 161 */
162static int isdn_x25iface_proto_restart(struct concap_proto *cprot, 162static int isdn_x25iface_proto_restart(struct concap_proto *cprot,
163 struct net_device *ndev, 163 struct net_device *ndev,
164 struct concap_device_ops *dops) 164 struct concap_device_ops *dops)
165{ 165{
166 ix25_pdata_t *pda = cprot->proto_data; 166 ix25_pdata_t * pda = cprot -> proto_data ;
167 ulong flags; 167 ulong flags;
168 168
169 IX25DEBUG("isdn_x25iface_proto_restart %s \n", MY_DEVNAME(ndev)); 169 IX25DEBUG( "isdn_x25iface_proto_restart %s \n", MY_DEVNAME(ndev) );
170 170
171 if (pdata_is_bad(pda)) return -1; 171 if ( pdata_is_bad( pda ) ) return -1;
172 172
173 if (!(dops && dops->data_req && dops->connect_req 173 if( !( dops && dops -> data_req && dops -> connect_req
174 && dops->disconn_req)) { 174 && dops -> disconn_req ) ){
175 printk(KERN_WARNING "isdn_x25iface_restart: required dops" 175 printk( KERN_WARNING "isdn_x25iface_restart: required dops"
176 " missing\n"); 176 " missing\n" );
177 isdn_x25iface_proto_close(cprot); 177 isdn_x25iface_proto_close(cprot);
178 return -1; 178 return -1;
179 } 179 }
180 spin_lock_irqsave(&cprot->lock, flags); 180 spin_lock_irqsave(&cprot->lock, flags);
181 cprot->net_dev = ndev; 181 cprot -> net_dev = ndev;
182 cprot->pops = &ix25_pops; 182 cprot -> pops = &ix25_pops;
183 cprot->dops = dops; 183 cprot -> dops = dops;
184 pda->state = WAN_DISCONNECTED; 184 pda -> state = WAN_DISCONNECTED;
185 spin_unlock_irqrestore(&cprot->lock, flags); 185 spin_unlock_irqrestore(&cprot->lock, flags);
186 return 0; 186 return 0;
187} 187}
188 188
189/* deliver a dl_data frame received from i4l HL driver to the network layer 189/* deliver a dl_data frame received from i4l HL driver to the network layer
190 */ 190 */
191static int isdn_x25iface_receive(struct concap_proto *cprot, struct sk_buff *skb) 191static int isdn_x25iface_receive(struct concap_proto *cprot, struct sk_buff *skb)
192{ 192{
193 IX25DEBUG("isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev)); 193 IX25DEBUG( "isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev) );
194 if (((ix25_pdata_t *)(cprot->proto_data)) 194 if ( ( (ix25_pdata_t*) (cprot->proto_data) )
195 ->state == WAN_CONNECTED) { 195 -> state == WAN_CONNECTED ){
196 if (skb_push(skb, 1)) { 196 if( skb_push(skb, 1)){
197 skb->data[0] = X25_IFACE_DATA; 197 skb->data[0] = X25_IFACE_DATA;
198 skb->protocol = x25_type_trans(skb, cprot->net_dev); 198 skb->protocol = x25_type_trans(skb, cprot->net_dev);
199 netif_rx(skb); 199 netif_rx(skb);
200 return 0; 200 return 0;
201 } 201 }
202 } 202 }
203 printk(KERN_WARNING "isdn_x25iface_receive %s: not connected, skb dropped\n", MY_DEVNAME(cprot->net_dev)); 203 printk(KERN_WARNING "isdn_x25iface_receive %s: not connected, skb dropped\n", MY_DEVNAME(cprot->net_dev) );
204 dev_kfree_skb(skb); 204 dev_kfree_skb(skb);
205 return -1; 205 return -1;
206} 206}
207 207
208/* a connection set up is indicated by lower layer 208/* a connection set up is indicated by lower layer
209 */ 209 */
210static int isdn_x25iface_connect_ind(struct concap_proto *cprot) 210static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
211{ 211{
212 struct sk_buff *skb; 212 struct sk_buff * skb;
213 enum wan_states *state_p 213 enum wan_states *state_p
214 = &(((ix25_pdata_t *)(cprot->proto_data))->state); 214 = &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state);
215 IX25DEBUG("isdn_x25iface_connect_ind %s \n" 215 IX25DEBUG( "isdn_x25iface_connect_ind %s \n"
216 , MY_DEVNAME(cprot->net_dev)); 216 , MY_DEVNAME(cprot->net_dev) );
217 if (*state_p == WAN_UNCONFIGURED) { 217 if( *state_p == WAN_UNCONFIGURED ){
218 printk(KERN_WARNING 218 printk(KERN_WARNING
219 "isdn_x25iface_connect_ind while unconfigured %s\n" 219 "isdn_x25iface_connect_ind while unconfigured %s\n"
220 , MY_DEVNAME(cprot->net_dev)); 220 , MY_DEVNAME(cprot->net_dev) );
221 return -1; 221 return -1;
222 } 222 }
223 *state_p = WAN_CONNECTED; 223 *state_p = WAN_CONNECTED;
224 224
225 skb = dev_alloc_skb(1); 225 skb = dev_alloc_skb(1);
226 if (skb) { 226 if( skb ){
227 *(skb_put(skb, 1)) = X25_IFACE_CONNECT; 227 *(skb_put(skb, 1)) = X25_IFACE_CONNECT;
228 skb->protocol = x25_type_trans(skb, cprot->net_dev); 228 skb->protocol = x25_type_trans(skb, cprot->net_dev);
229 netif_rx(skb); 229 netif_rx(skb);
@@ -231,28 +231,28 @@ static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
231 } else { 231 } else {
232 printk(KERN_WARNING "isdn_x25iface_connect_ind: " 232 printk(KERN_WARNING "isdn_x25iface_connect_ind: "
233 " out of memory -- disconnecting\n"); 233 " out of memory -- disconnecting\n");
234 cprot->dops->disconn_req(cprot); 234 cprot -> dops -> disconn_req(cprot);
235 return -1; 235 return -1;
236 } 236 }
237} 237}
238 238
239/* a disconnect is indicated by lower layer 239/* a disconnect is indicated by lower layer
240 */ 240 */
241static int isdn_x25iface_disconn_ind(struct concap_proto *cprot) 241static int isdn_x25iface_disconn_ind(struct concap_proto *cprot)
242{ 242{
243 struct sk_buff *skb; 243 struct sk_buff *skb;
244 enum wan_states *state_p 244 enum wan_states *state_p
245 = &(((ix25_pdata_t *)(cprot->proto_data))->state); 245 = &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state);
246 IX25DEBUG("isdn_x25iface_disconn_ind %s \n", MY_DEVNAME(cprot->net_dev)); 246 IX25DEBUG( "isdn_x25iface_disconn_ind %s \n", MY_DEVNAME(cprot -> net_dev) );
247 if (*state_p == WAN_UNCONFIGURED) { 247 if( *state_p == WAN_UNCONFIGURED ){
248 printk(KERN_WARNING 248 printk(KERN_WARNING
249 "isdn_x25iface_disconn_ind while unconfigured\n"); 249 "isdn_x25iface_disconn_ind while unconfigured\n");
250 return -1; 250 return -1;
251 } 251 }
252 if (!cprot->net_dev) return -1; 252 if(! cprot -> net_dev) return -1;
253 *state_p = WAN_DISCONNECTED; 253 *state_p = WAN_DISCONNECTED;
254 skb = dev_alloc_skb(1); 254 skb = dev_alloc_skb(1);
255 if (skb) { 255 if( skb ){
256 *(skb_put(skb, 1)) = X25_IFACE_DISCONNECT; 256 *(skb_put(skb, 1)) = X25_IFACE_DISCONNECT;
257 skb->protocol = x25_type_trans(skb, cprot->net_dev); 257 skb->protocol = x25_type_trans(skb, cprot->net_dev);
258 netif_rx(skb); 258 netif_rx(skb);
@@ -266,57 +266,57 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *cprot)
266 266
267/* process a frame handed over to us from linux network layer. First byte 267/* process a frame handed over to us from linux network layer. First byte
268 semantics as defined in Documentation/networking/x25-iface.txt 268 semantics as defined in Documentation/networking/x25-iface.txt
269*/ 269 */
270static int isdn_x25iface_xmit(struct concap_proto *cprot, struct sk_buff *skb) 270static int isdn_x25iface_xmit(struct concap_proto *cprot, struct sk_buff *skb)
271{ 271{
272 unsigned char firstbyte = skb->data[0]; 272 unsigned char firstbyte = skb->data[0];
273 enum wan_states *state = &((ix25_pdata_t *)cprot->proto_data)->state; 273 enum wan_states *state = &((ix25_pdata_t*)cprot->proto_data)->state;
274 int ret = 0; 274 int ret = 0;
275 IX25DEBUG("isdn_x25iface_xmit: %s first=%x state=%d\n", 275 IX25DEBUG("isdn_x25iface_xmit: %s first=%x state=%d\n",
276 MY_DEVNAME(cprot->net_dev), firstbyte, *state); 276 MY_DEVNAME(cprot->net_dev), firstbyte, *state);
277 switch (firstbyte) { 277 switch ( firstbyte ){
278 case X25_IFACE_DATA: 278 case X25_IFACE_DATA:
279 if (*state == WAN_CONNECTED) { 279 if( *state == WAN_CONNECTED ){
280 skb_pull(skb, 1); 280 skb_pull(skb, 1);
281 cprot->net_dev->trans_start = jiffies; 281 cprot -> net_dev -> trans_start = jiffies;
282 ret = (cprot->dops->data_req(cprot, skb)); 282 ret = ( cprot -> dops -> data_req(cprot, skb) );
283 /* prepare for future retransmissions */ 283 /* prepare for future retransmissions */
284 if (ret) skb_push(skb, 1); 284 if( ret ) skb_push(skb,1);
285 return ret; 285 return ret;
286 } 286 }
287 illegal_state_warn(*state, firstbyte); 287 illegal_state_warn( *state, firstbyte );
288 break; 288 break;
289 case X25_IFACE_CONNECT: 289 case X25_IFACE_CONNECT:
290 if (*state == WAN_DISCONNECTED) { 290 if( *state == WAN_DISCONNECTED ){
291 *state = WAN_CONNECTING; 291 *state = WAN_CONNECTING;
292 ret = cprot->dops->connect_req(cprot); 292 ret = cprot -> dops -> connect_req(cprot);
293 if (ret) { 293 if(ret){
294 /* reset state and notify upper layer about 294 /* reset state and notify upper layer about
295 * immidiatly failed attempts */ 295 * immidiatly failed attempts */
296 isdn_x25iface_disconn_ind(cprot); 296 isdn_x25iface_disconn_ind(cprot);
297 } 297 }
298 } else { 298 } else {
299 illegal_state_warn(*state, firstbyte); 299 illegal_state_warn( *state, firstbyte );
300 } 300 }
301 break; 301 break;
302 case X25_IFACE_DISCONNECT: 302 case X25_IFACE_DISCONNECT:
303 switch (*state) { 303 switch ( *state ){
304 case WAN_DISCONNECTED: 304 case WAN_DISCONNECTED:
305 /* Should not happen. However, give upper layer a 305 /* Should not happen. However, give upper layer a
306 chance to recover from inconstistency but don't 306 chance to recover from inconstistency but don't
307 trust the lower layer sending the disconn_confirm 307 trust the lower layer sending the disconn_confirm
308 when already disconnected */ 308 when already disconnected */
309 printk(KERN_WARNING "isdn_x25iface_xmit: disconnect " 309 printk(KERN_WARNING "isdn_x25iface_xmit: disconnect "
310 " requested while disconnected\n"); 310 " requested while disconnected\n" );
311 isdn_x25iface_disconn_ind(cprot); 311 isdn_x25iface_disconn_ind(cprot);
312 break; /* prevent infinite loops */ 312 break; /* prevent infinite loops */
313 case WAN_CONNECTING: 313 case WAN_CONNECTING:
314 case WAN_CONNECTED: 314 case WAN_CONNECTED:
315 *state = WAN_DISCONNECTED; 315 *state = WAN_DISCONNECTED;
316 cprot->dops->disconn_req(cprot); 316 cprot -> dops -> disconn_req(cprot);
317 break; 317 break;
318 default: 318 default:
319 illegal_state_warn(*state, firstbyte); 319 illegal_state_warn( *state, firstbyte );
320 } 320 }
321 break; 321 break;
322 case X25_IFACE_PARAMS: 322 case X25_IFACE_PARAMS:
diff --git a/drivers/isdn/i4l/isdn_x25iface.h b/drivers/isdn/i4l/isdn_x25iface.h
index 0b26e3b336e..41a3d497746 100644
--- a/drivers/isdn/i4l/isdn_x25iface.h
+++ b/drivers/isdn/i4l/isdn_x25iface.h
@@ -13,9 +13,9 @@
13#define ISDN_X25IFACE_MAGIC 0x1e75a2b9 13#define ISDN_X25IFACE_MAGIC 0x1e75a2b9
14/* #define DEBUG_ISDN_X25 if you want isdn_x25 debugging messages */ 14/* #define DEBUG_ISDN_X25 if you want isdn_x25 debugging messages */
15#ifdef DEBUG_ISDN_X25 15#ifdef DEBUG_ISDN_X25
16# define IX25DEBUG(fmt, args...) printk(KERN_DEBUG fmt, ##args) 16# define IX25DEBUG(fmt,args...) printk(KERN_DEBUG fmt , ## args)
17#else 17#else
18# define IX25DEBUG(fmt, args...) 18# define IX25DEBUG(fmt,args...)
19#endif 19#endif
20 20
21#include <linux/skbuff.h> 21#include <linux/skbuff.h>
@@ -23,9 +23,17 @@
23#include <linux/isdn.h> 23#include <linux/isdn.h>
24#include <linux/concap.h> 24#include <linux/concap.h>
25 25
26extern struct concap_proto_ops *isdn_x25iface_concap_proto_ops_pt; 26extern struct concap_proto_ops * isdn_x25iface_concap_proto_ops_pt;
27extern struct concap_proto *isdn_x25iface_proto_new(void); 27extern struct concap_proto * isdn_x25iface_proto_new(void);
28 28
29 29
30 30
31#endif 31#endif
32
33
34
35
36
37
38
39
diff --git a/drivers/isdn/i4l/isdnhdlc.c b/drivers/isdn/i4l/isdnhdlc.c
index 027d1c59067..c989aa35dc2 100644
--- a/drivers/isdn/i4l/isdnhdlc.c
+++ b/drivers/isdn/i4l/isdnhdlc.c
@@ -88,7 +88,7 @@ check_frame(struct isdnhdlc_vars *hdlc)
88{ 88{
89 int status; 89 int status;
90 90
91 if (hdlc->dstpos < 2) /* too small - framing error */ 91 if (hdlc->dstpos < 2) /* too small - framing error */
92 status = -HDLC_FRAMING_ERROR; 92 status = -HDLC_FRAMING_ERROR;
93 else if (hdlc->crc != 0xf0b8) /* crc error */ 93 else if (hdlc->crc != 0xf0b8) /* crc error */
94 status = -HDLC_CRC_ERROR; 94 status = -HDLC_CRC_ERROR;
@@ -127,9 +127,9 @@ check_frame(struct isdnhdlc_vars *hdlc)
127 dsize - destination buffer size 127 dsize - destination buffer size
128 returns - number of decoded bytes in the destination buffer and status 128 returns - number of decoded bytes in the destination buffer and status
129 flag. 129 flag.
130*/ 130 */
131int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen, 131int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
132 int *count, u8 *dst, int dsize) 132 int *count, u8 *dst, int dsize)
133{ 133{
134 int status = 0; 134 int status = 0;
135 135
@@ -145,28 +145,28 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
145 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff 145 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff
146 }; 146 };
147 147
148#define handle_fast_flag(h) \ 148#define handle_fast_flag(h) \
149 do { \ 149 do {\
150 if (h->cbin == fast_flag[h->bit_shift]) { \ 150 if (h->cbin == fast_flag[h->bit_shift]) {\
151 h->ffvalue = fast_flag_value[h->bit_shift]; \ 151 h->ffvalue = fast_flag_value[h->bit_shift];\
152 h->state = HDLC_FAST_FLAG; \ 152 h->state = HDLC_FAST_FLAG;\
153 h->ffbit_shift = h->bit_shift; \ 153 h->ffbit_shift = h->bit_shift;\
154 h->bit_shift = 1; \ 154 h->bit_shift = 1;\
155 } else { \ 155 } else {\
156 h->state = HDLC_GET_DATA; \ 156 h->state = HDLC_GET_DATA;\
157 h->data_received = 0; \ 157 h->data_received = 0;\
158 } \ 158 } \
159 } while (0) 159 } while (0)
160 160
161#define handle_abort(h) \ 161#define handle_abort(h) \
162 do { \ 162 do {\
163 h->shift_reg = fast_abort[h->ffbit_shift - 1]; \ 163 h->shift_reg = fast_abort[h->ffbit_shift - 1];\
164 h->hdlc_bits1 = h->ffbit_shift - 2; \ 164 h->hdlc_bits1 = h->ffbit_shift - 2;\
165 if (h->hdlc_bits1 < 0) \ 165 if (h->hdlc_bits1 < 0)\
166 h->hdlc_bits1 = 0; \ 166 h->hdlc_bits1 = 0;\
167 h->data_bits = h->ffbit_shift - 1; \ 167 h->data_bits = h->ffbit_shift - 1;\
168 h->state = HDLC_GET_DATA; \ 168 h->state = HDLC_GET_DATA;\
169 h->data_received = 0; \ 169 h->data_received = 0;\
170 } while (0) 170 } while (0)
171 171
172 *count = slen; 172 *count = slen;
@@ -204,7 +204,7 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
204 if ((!hdlc->do_adapt56) && 204 if ((!hdlc->do_adapt56) &&
205 (++hdlc->hdlc_bits1 >= 8) && 205 (++hdlc->hdlc_bits1 >= 8) &&
206 (hdlc->bit_shift == 1)) 206 (hdlc->bit_shift == 1))
207 hdlc->state = HDLC_FAST_IDLE; 207 hdlc->state = HDLC_FAST_IDLE;
208 } 208 }
209 hdlc->cbin <<= 1; 209 hdlc->cbin <<= 1;
210 hdlc->bit_shift--; 210 hdlc->bit_shift--;
@@ -295,7 +295,7 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
295 hdlc->data_bits = 0; 295 hdlc->data_bits = 0;
296 hdlc->data_received = 1; 296 hdlc->data_received = 1;
297 hdlc->crc = crc_ccitt_byte(hdlc->crc, 297 hdlc->crc = crc_ccitt_byte(hdlc->crc,
298 hdlc->shift_reg); 298 hdlc->shift_reg);
299 299
300 /* good byte received */ 300 /* good byte received */
301 if (hdlc->dstpos < dsize) 301 if (hdlc->dstpos < dsize)
@@ -352,7 +352,7 @@ EXPORT_SYMBOL(isdnhdlc_decode);
352 returns - number of encoded bytes in the destination buffer 352 returns - number of encoded bytes in the destination buffer
353*/ 353*/
354int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen, 354int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
355 int *count, u8 *dst, int dsize) 355 int *count, u8 *dst, int dsize)
356{ 356{
357 static const unsigned char xfast_flag_value[] = { 357 static const unsigned char xfast_flag_value[] = {
358 0x7e, 0x3f, 0x9f, 0xcf, 0xe7, 0xf3, 0xf9, 0xfc, 0x7e 358 0x7e, 0x3f, 0x9f, 0xcf, 0xe7, 0xf3, 0xf9, 0xfc, 0x7e
@@ -478,7 +478,7 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
478 } 478 }
479 if (hdlc->bit_shift == 8) 479 if (hdlc->bit_shift == 8)
480 hdlc->crc = crc_ccitt_byte(hdlc->crc, 480 hdlc->crc = crc_ccitt_byte(hdlc->crc,
481 hdlc->shift_reg); 481 hdlc->shift_reg);
482 if (hdlc->shift_reg & 0x01) { 482 if (hdlc->shift_reg & 0x01) {
483 hdlc->hdlc_bits1++; 483 hdlc->hdlc_bits1++;
484 hdlc->cbin++; 484 hdlc->cbin++;