diff options
author | Joe Perches <joe@perches.com> | 2012-02-19 22:52:38 -0500 |
---|---|---|
committer | Joe Perches <joe@perches.com> | 2012-02-21 12:04:01 -0500 |
commit | 475be4d85a274d0961593db41cf85689db1d583c (patch) | |
tree | b2b8931eb747794730522c3cf1898e46948527b9 /drivers/isdn/i4l | |
parent | 0b0a635f79f91f3755b6518627ea06dd0dbfd523 (diff) |
isdn: whitespace coding style cleanup
isdn source code uses a not-current coding style.
Update the coding style used on a per-line basis
so that git diff -w shows only elided blank lines
at EOF.
Done with emacs and some scripts and some typing.
Built x86 allyesconfig.
No detected change in objdump -d or size.
Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r-- | drivers/isdn/i4l/isdn_audio.c | 126 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_bsdcomp.c | 374 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_common.c | 1502 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_common.h | 18 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_concap.c | 36 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_concap.h | 4 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_net.c | 1498 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_net.h | 11 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_ppp.c | 1442 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_ppp.h | 2 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_tty.c | 2440 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_tty.h | 10 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_ttyfax.c | 1092 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_ttyfax.h | 1 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_v110.c | 294 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_v110.h | 8 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_x25iface.c | 226 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_x25iface.h | 16 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdnhdlc.c | 54 |
19 files changed, 4570 insertions, 4584 deletions
diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index d5013935ac62..78ce42214713 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 | |||
242 | isdn_audio_linear2ulaw(int sample) | 242 | isdn_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 | ||
301 | static int | 301 | static int |
302 | isdn_audio_get_bits(adpcm_state * s, unsigned char **in, int *len) | 302 | isdn_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 | ||
314 | static void | 314 | static void |
315 | isdn_audio_put_bits(int data, int nbits, adpcm_state * s, | 315 | isdn_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 | ||
328 | adpcm_state * | 328 | adpcm_state * |
329 | isdn_audio_adpcm_init(adpcm_state * s, int nbits) | 329 | isdn_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 | ||
343 | dtmf_state * | 343 | dtmf_state * |
344 | isdn_audio_dtmf_init(dtmf_state * s) | 344 | isdn_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 | ||
360 | int | 360 | int |
361 | isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in, | 361 | isdn_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 | ||
395 | int | 395 | int |
396 | isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in, | 396 | isdn_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 | */ |
447 | static void | 447 | static void |
448 | isdn_audio_goertzel(int *sample, modem_info * info) | 448 | isdn_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 | ||
494 | void | 494 | void |
495 | isdn_audio_eval_dtmf(modem_info * info) | 495 | isdn_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 | */ |
592 | void | 592 | void |
593 | isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt) | 593 | isdn_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 | ||
621 | silence_state * | 621 | silence_state * |
622 | isdn_audio_silence_init(silence_state * s) | 622 | isdn_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 | ||
633 | void | 633 | void |
634 | isdn_audio_calc_silence(modem_info * info, unsigned char *buf, int len, int fmt) | 634 | isdn_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 | ||
660 | void | 660 | void |
661 | isdn_audio_put_dle_code(modem_info * info, u_char code) | 661 | isdn_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 | ||
690 | void | 690 | void |
691 | isdn_audio_eval_silence(modem_info * info) | 691 | isdn_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 aa0b6a6f5ef4..7f3c54d40474 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 |
@@ -121,7 +121,7 @@ struct bsd_db { | |||
121 | unsigned char maxbits; /* maximum bits/code */ | 121 | unsigned char maxbits; /* maximum bits/code */ |
122 | unsigned char debug; /* non-zero if debug desired */ | 122 | unsigned char debug; /* non-zero if debug desired */ |
123 | unsigned char unit; /* ppp unit number */ | 123 | unsigned char unit; /* ppp unit number */ |
124 | u16 seqno; /* sequence # of next packet */ | 124 | u16 seqno; /* sequence # of next packet */ |
125 | unsigned int mru; /* size of receive (decompress) bufr */ | 125 | unsigned int mru; /* size of receive (decompress) bufr */ |
126 | unsigned int maxmaxcode; /* largest valid code */ | 126 | unsigned int maxmaxcode; /* largest valid code */ |
127 | unsigned int max_ent; /* largest code in use */ | 127 | unsigned int max_ent; /* largest code in use */ |
@@ -157,16 +157,16 @@ struct bsd_db { | |||
157 | #define MAXCODE(b) ((1 << (b)) - 1) | 157 | #define MAXCODE(b) ((1 << (b)) - 1) |
158 | #define BADCODEM1 MAXCODE(MAX_BSD_BITS) | 158 | #define BADCODEM1 MAXCODE(MAX_BSD_BITS) |
159 | 159 | ||
160 | #define BSD_HASH(prefix,suffix,hshift) ((((unsigned long)(suffix))<<(hshift)) \ | 160 | #define BSD_HASH(prefix, suffix, hshift) ((((unsigned long)(suffix)) << (hshift)) \ |
161 | ^ (unsigned long)(prefix)) | 161 | ^ (unsigned long)(prefix)) |
162 | #define BSD_KEY(prefix,suffix) ((((unsigned long)(suffix)) << 16) \ | 162 | #define BSD_KEY(prefix, suffix) ((((unsigned long)(suffix)) << 16) \ |
163 | + (unsigned long)(prefix)) | 163 | + (unsigned long)(prefix)) |
164 | 164 | ||
165 | #define CHECK_GAP 10000 /* Ratio check interval */ | 165 | #define CHECK_GAP 10000 /* Ratio check interval */ |
166 | 166 | ||
167 | #define RATIO_SCALE_LOG 8 | 167 | #define RATIO_SCALE_LOG 8 |
168 | #define RATIO_SCALE (1<<RATIO_SCALE_LOG) | 168 | #define RATIO_SCALE (1 << RATIO_SCALE_LOG) |
169 | #define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG) | 169 | #define RATIO_MAX (0x7fffffff >> RATIO_SCALE_LOG) |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * clear the dictionary | 172 | * clear the dictionary |
@@ -175,7 +175,7 @@ struct bsd_db { | |||
175 | static void bsd_clear(struct bsd_db *db) | 175 | static void bsd_clear(struct bsd_db *db) |
176 | { | 176 | { |
177 | db->clear_count++; | 177 | db->clear_count++; |
178 | db->max_ent = FIRST-1; | 178 | db->max_ent = FIRST - 1; |
179 | db->n_bits = BSD_INIT_BITS; | 179 | db->n_bits = BSD_INIT_BITS; |
180 | db->bytes_out = 0; | 180 | db->bytes_out = 0; |
181 | db->in_count = 0; | 181 | db->in_count = 0; |
@@ -197,56 +197,56 @@ static void bsd_clear(struct bsd_db *db) | |||
197 | * the absence of CLEAR codes (while packets are incompressible), they | 197 | * the absence of CLEAR codes (while packets are incompressible), they |
198 | * must compute the same ratio. | 198 | * must compute the same ratio. |
199 | */ | 199 | */ |
200 | static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */ | 200 | static int bsd_check(struct bsd_db *db) /* 1=output CLEAR */ |
201 | { | 201 | { |
202 | unsigned int new_ratio; | 202 | unsigned int new_ratio; |
203 | 203 | ||
204 | if (db->in_count >= db->checkpoint) | 204 | if (db->in_count >= db->checkpoint) |
205 | { | 205 | { |
206 | /* age the ratio by limiting the size of the counts */ | 206 | /* age the ratio by limiting the size of the counts */ |
207 | if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) | 207 | if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) |
208 | { | 208 | { |
209 | db->in_count -= (db->in_count >> 2); | 209 | db->in_count -= (db->in_count >> 2); |
210 | db->bytes_out -= (db->bytes_out >> 2); | 210 | db->bytes_out -= (db->bytes_out >> 2); |
211 | } | 211 | } |
212 | 212 | ||
213 | db->checkpoint = db->in_count + CHECK_GAP; | 213 | db->checkpoint = db->in_count + CHECK_GAP; |
214 | 214 | ||
215 | if (db->max_ent >= db->maxmaxcode) | 215 | if (db->max_ent >= db->maxmaxcode) |
216 | { | 216 | { |
217 | /* Reset the dictionary only if the ratio is worse, | 217 | /* Reset the dictionary only if the ratio is worse, |
218 | * or if it looks as if it has been poisoned | 218 | * or if it looks as if it has been poisoned |
219 | * by incompressible data. | 219 | * by incompressible data. |
220 | * | 220 | * |
221 | * This does not overflow, because | 221 | * This does not overflow, because |
222 | * db->in_count <= RATIO_MAX. | 222 | * db->in_count <= RATIO_MAX. |
223 | */ | 223 | */ |
224 | 224 | ||
225 | new_ratio = db->in_count << RATIO_SCALE_LOG; | 225 | new_ratio = db->in_count << RATIO_SCALE_LOG; |
226 | if (db->bytes_out != 0) | 226 | if (db->bytes_out != 0) |
227 | { | 227 | { |
228 | new_ratio /= db->bytes_out; | 228 | new_ratio /= db->bytes_out; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) | 231 | if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) |
232 | { | 232 | { |
233 | bsd_clear (db); | 233 | bsd_clear(db); |
234 | return 1; | 234 | return 1; |
235 | } | 235 | } |
236 | db->ratio = new_ratio; | 236 | db->ratio = new_ratio; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | return 0; | 239 | return 0; |
240 | } | 240 | } |
241 | 241 | ||
242 | /* | 242 | /* |
243 | * Return statistics. | 243 | * Return statistics. |
244 | */ | 244 | */ |
245 | 245 | ||
246 | static void bsd_stats (void *state, struct compstat *stats) | 246 | static void bsd_stats(void *state, struct compstat *stats) |
247 | { | 247 | { |
248 | struct bsd_db *db = (struct bsd_db *) state; | 248 | struct bsd_db *db = (struct bsd_db *) state; |
249 | 249 | ||
250 | stats->unc_bytes = db->uncomp_bytes; | 250 | stats->unc_bytes = db->uncomp_bytes; |
251 | stats->unc_packets = db->uncomp_count; | 251 | stats->unc_packets = db->uncomp_count; |
252 | stats->comp_bytes = db->comp_bytes; | 252 | stats->comp_bytes = db->comp_bytes; |
@@ -260,9 +260,9 @@ static void bsd_stats (void *state, struct compstat *stats) | |||
260 | /* | 260 | /* |
261 | * Reset state, as on a CCP ResetReq. | 261 | * Reset state, as on a CCP ResetReq. |
262 | */ | 262 | */ |
263 | static void bsd_reset (void *state,unsigned char code, unsigned char id, | 263 | static void bsd_reset(void *state, unsigned char code, unsigned char id, |
264 | unsigned char *data, unsigned len, | 264 | unsigned char *data, unsigned len, |
265 | struct isdn_ppp_resetparams *rsparm) | 265 | struct isdn_ppp_resetparams *rsparm) |
266 | { | 266 | { |
267 | struct bsd_db *db = (struct bsd_db *) state; | 267 | struct bsd_db *db = (struct bsd_db *) state; |
268 | 268 | ||
@@ -274,7 +274,7 @@ static void bsd_reset (void *state,unsigned char code, unsigned char id, | |||
274 | /* | 274 | /* |
275 | * Release the compression structure | 275 | * Release the compression structure |
276 | */ | 276 | */ |
277 | static void bsd_free (void *state) | 277 | static void bsd_free(void *state) |
278 | { | 278 | { |
279 | struct bsd_db *db = (struct bsd_db *) state; | 279 | struct bsd_db *db = (struct bsd_db *) state; |
280 | 280 | ||
@@ -302,7 +302,7 @@ static void bsd_free (void *state) | |||
302 | /* | 302 | /* |
303 | * Allocate space for a (de) compressor. | 303 | * Allocate space for a (de) compressor. |
304 | */ | 304 | */ |
305 | static void *bsd_alloc (struct isdn_ppp_comp_data *data) | 305 | static void *bsd_alloc(struct isdn_ppp_comp_data *data) |
306 | { | 306 | { |
307 | int bits; | 307 | int bits; |
308 | unsigned int hsize, hshift, maxmaxcode; | 308 | unsigned int hsize, hshift, maxmaxcode; |
@@ -310,27 +310,27 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) | |||
310 | int decomp; | 310 | int decomp; |
311 | 311 | ||
312 | static unsigned int htab[][2] = { | 312 | static unsigned int htab[][2] = { |
313 | { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , | 313 | { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , |
314 | { 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 } | 314 | { 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 } |
315 | }; | 315 | }; |
316 | 316 | ||
317 | if (data->optlen != 1 || data->num != CI_BSD_COMPRESS | 317 | if (data->optlen != 1 || data->num != CI_BSD_COMPRESS |
318 | || BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) | 318 | || BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) |
319 | return NULL; | 319 | return NULL; |
320 | 320 | ||
321 | bits = BSD_NBITS(data->options[0]); | 321 | bits = BSD_NBITS(data->options[0]); |
322 | 322 | ||
323 | if(bits < 9 || bits > 15) | 323 | if (bits < 9 || bits > 15) |
324 | return NULL; | 324 | return NULL; |
325 | 325 | ||
326 | hsize = htab[bits-9][0]; | 326 | hsize = htab[bits - 9][0]; |
327 | hshift = htab[bits-9][1]; | 327 | hshift = htab[bits - 9][1]; |
328 | 328 | ||
329 | /* | 329 | /* |
330 | * Allocate the main control structure for this instance. | 330 | * Allocate the main control structure for this instance. |
331 | */ | 331 | */ |
332 | maxmaxcode = MAXCODE(bits); | 332 | maxmaxcode = MAXCODE(bits); |
333 | db = kzalloc (sizeof (struct bsd_db),GFP_KERNEL); | 333 | db = kzalloc(sizeof(struct bsd_db), GFP_KERNEL); |
334 | if (!db) | 334 | if (!db) |
335 | return NULL; | 335 | return NULL; |
336 | 336 | ||
@@ -343,7 +343,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) | |||
343 | */ | 343 | */ |
344 | db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); | 344 | db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); |
345 | if (!db->dict) { | 345 | if (!db->dict) { |
346 | bsd_free (db); | 346 | bsd_free(db); |
347 | return NULL; | 347 | return NULL; |
348 | } | 348 | } |
349 | 349 | ||
@@ -356,7 +356,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) | |||
356 | else { | 356 | else { |
357 | db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); | 357 | db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); |
358 | if (!db->lens) { | 358 | if (!db->lens) { |
359 | bsd_free (db); | 359 | bsd_free(db); |
360 | return (NULL); | 360 | return (NULL); |
361 | } | 361 | } |
362 | } | 362 | } |
@@ -364,41 +364,41 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) | |||
364 | /* | 364 | /* |
365 | * Initialize the data information for the compression code | 365 | * Initialize the data information for the compression code |
366 | */ | 366 | */ |
367 | db->totlen = sizeof (struct bsd_db) + (sizeof (struct bsd_dict) * hsize); | 367 | db->totlen = sizeof(struct bsd_db) + (sizeof(struct bsd_dict) * hsize); |
368 | db->hsize = hsize; | 368 | db->hsize = hsize; |
369 | db->hshift = hshift; | 369 | db->hshift = hshift; |
370 | db->maxmaxcode = maxmaxcode; | 370 | db->maxmaxcode = maxmaxcode; |
371 | db->maxbits = bits; | 371 | db->maxbits = bits; |
372 | 372 | ||
373 | return (void *) db; | 373 | return (void *)db; |
374 | } | 374 | } |
375 | 375 | ||
376 | /* | 376 | /* |
377 | * Initialize the database. | 377 | * Initialize the database. |
378 | */ | 378 | */ |
379 | static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int debug) | 379 | static int bsd_init(void *state, struct isdn_ppp_comp_data *data, int unit, int debug) |
380 | { | 380 | { |
381 | struct bsd_db *db = state; | 381 | struct bsd_db *db = state; |
382 | int indx; | 382 | int indx; |
383 | int decomp; | 383 | int decomp; |
384 | 384 | ||
385 | if(!state || !data) { | 385 | if (!state || !data) { |
386 | 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); |
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | 389 | ||
390 | decomp = db->xmit ? 0 : 1; | 390 | decomp = db->xmit ? 0 : 1; |
391 | 391 | ||
392 | if (data->optlen != 1 || data->num != CI_BSD_COMPRESS | 392 | if (data->optlen != 1 || data->num != CI_BSD_COMPRESS |
393 | || (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) | 393 | || (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) |
394 | || (BSD_NBITS(data->options[0]) != db->maxbits) | 394 | || (BSD_NBITS(data->options[0]) != db->maxbits) |
395 | || (decomp && db->lens == NULL)) { | 395 | || (decomp && db->lens == NULL)) { |
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 | printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n", data->optlen, data->num, data->options[0], decomp, (unsigned long)db->lens); |
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | if (decomp) | 400 | if (decomp) |
401 | for(indx=LAST;indx>=0;indx--) | 401 | for (indx = LAST; indx >= 0; indx--) |
402 | db->lens[indx] = 1; | 402 | db->lens[indx] = 1; |
403 | 403 | ||
404 | indx = db->hsize; | 404 | indx = db->hsize; |
@@ -411,9 +411,9 @@ static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int | |||
411 | db->mru = 0; | 411 | db->mru = 0; |
412 | 412 | ||
413 | db->debug = 1; | 413 | db->debug = 1; |
414 | 414 | ||
415 | bsd_reset(db,0,0,NULL,0,NULL); | 415 | bsd_reset(db, 0, 0, NULL, 0, NULL); |
416 | 416 | ||
417 | return 1; | 417 | return 1; |
418 | } | 418 | } |
419 | 419 | ||
@@ -421,37 +421,37 @@ static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int | |||
421 | * Obtain pointers to the various structures in the compression tables | 421 | * Obtain pointers to the various structures in the compression tables |
422 | */ | 422 | */ |
423 | 423 | ||
424 | #define dict_ptrx(p,idx) &(p->dict[idx]) | 424 | #define dict_ptrx(p, idx) &(p->dict[idx]) |
425 | #define lens_ptrx(p,idx) &(p->lens[idx]) | 425 | #define lens_ptrx(p, idx) &(p->lens[idx]) |
426 | 426 | ||
427 | #ifdef DEBUG | 427 | #ifdef DEBUG |
428 | static unsigned short *lens_ptr(struct bsd_db *db, int idx) | 428 | static unsigned short *lens_ptr(struct bsd_db *db, int idx) |
429 | { | 429 | { |
430 | if ((unsigned int) idx > (unsigned int) db->maxmaxcode) { | 430 | if ((unsigned int) idx > (unsigned int) db->maxmaxcode) { |
431 | printk (KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx); | 431 | printk(KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx); |
432 | idx = 0; | 432 | idx = 0; |
433 | } | 433 | } |
434 | return lens_ptrx (db, idx); | 434 | return lens_ptrx(db, idx); |
435 | } | 435 | } |
436 | 436 | ||
437 | static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx) | 437 | static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx) |
438 | { | 438 | { |
439 | if ((unsigned int) idx >= (unsigned int) db->hsize) { | 439 | if ((unsigned int) idx >= (unsigned int) db->hsize) { |
440 | printk (KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx); | 440 | printk(KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx); |
441 | idx = 0; | 441 | idx = 0; |
442 | } | 442 | } |
443 | return dict_ptrx (db, idx); | 443 | return dict_ptrx(db, idx); |
444 | } | 444 | } |
445 | 445 | ||
446 | #else | 446 | #else |
447 | #define lens_ptr(db,idx) lens_ptrx(db,idx) | 447 | #define lens_ptr(db, idx) lens_ptrx(db, idx) |
448 | #define dict_ptr(db,idx) dict_ptrx(db,idx) | 448 | #define dict_ptr(db, idx) dict_ptrx(db, idx) |
449 | #endif | 449 | #endif |
450 | 450 | ||
451 | /* | 451 | /* |
452 | * compress a packet | 452 | * compress a packet |
453 | */ | 453 | */ |
454 | static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,int proto) | 454 | static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, int proto) |
455 | { | 455 | { |
456 | struct bsd_db *db; | 456 | struct bsd_db *db; |
457 | int hshift; | 457 | int hshift; |
@@ -463,31 +463,31 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk | |||
463 | unsigned long fcode; | 463 | unsigned long fcode; |
464 | struct bsd_dict *dictp; | 464 | struct bsd_dict *dictp; |
465 | unsigned char c; | 465 | unsigned char c; |
466 | int hval,disp,ilen,mxcode; | 466 | int hval, disp, ilen, mxcode; |
467 | unsigned char *rptr = skb_in->data; | 467 | unsigned char *rptr = skb_in->data; |
468 | int isize = skb_in->len; | 468 | int isize = skb_in->len; |
469 | 469 | ||
470 | #define OUTPUT(ent) \ | 470 | #define OUTPUT(ent) \ |
471 | { \ | 471 | { \ |
472 | bitno -= n_bits; \ | 472 | bitno -= n_bits; \ |
473 | accm |= ((ent) << bitno); \ | 473 | accm |= ((ent) << bitno); \ |
474 | do { \ | 474 | do { \ |
475 | if(skb_out && skb_tailroom(skb_out) > 0) \ | 475 | if (skb_out && skb_tailroom(skb_out) > 0) \ |
476 | *(skb_put(skb_out,1)) = (unsigned char) (accm>>24); \ | 476 | *(skb_put(skb_out, 1)) = (unsigned char)(accm >> 24); \ |
477 | accm <<= 8; \ | 477 | accm <<= 8; \ |
478 | bitno += 8; \ | 478 | bitno += 8; \ |
479 | } while (bitno <= 24); \ | 479 | } while (bitno <= 24); \ |
480 | } | 480 | } |
481 | 481 | ||
482 | /* | 482 | /* |
483 | * 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, |
484 | * just return without compressing the packet. If it is, | 484 | * just return without compressing the packet. If it is, |
485 | * the protocol becomes the first byte to compress. | 485 | * the protocol becomes the first byte to compress. |
486 | */ | 486 | */ |
487 | printk(KERN_DEBUG "bsd_compress called with %x\n",proto); | 487 | printk(KERN_DEBUG "bsd_compress called with %x\n", proto); |
488 | 488 | ||
489 | ent = proto; | 489 | ent = proto; |
490 | if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1) ) | 490 | if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1)) |
491 | return 0; | 491 | return 0; |
492 | 492 | ||
493 | db = (struct bsd_db *) state; | 493 | db = (struct bsd_db *) state; |
@@ -496,25 +496,25 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk | |||
496 | n_bits = db->n_bits; | 496 | n_bits = db->n_bits; |
497 | bitno = 32; | 497 | bitno = 32; |
498 | accm = 0; | 498 | accm = 0; |
499 | mxcode = MAXCODE (n_bits); | 499 | mxcode = MAXCODE(n_bits); |
500 | 500 | ||
501 | /* This is the PPP header information */ | 501 | /* This is the PPP header information */ |
502 | if(skb_out && skb_tailroom(skb_out) >= 2) { | 502 | if (skb_out && skb_tailroom(skb_out) >= 2) { |
503 | char *v = skb_put(skb_out,2); | 503 | char *v = skb_put(skb_out, 2); |
504 | /* we only push our own data on the header, | 504 | /* we only push our own data on the header, |
505 | AC,PC and protos is pushed by caller */ | 505 | AC,PC and protos is pushed by caller */ |
506 | v[0] = db->seqno >> 8; | 506 | v[0] = db->seqno >> 8; |
507 | v[1] = db->seqno; | 507 | v[1] = db->seqno; |
508 | } | 508 | } |
509 | 509 | ||
510 | 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! */ |
511 | 511 | ||
512 | while (--ilen > 0) { | 512 | while (--ilen > 0) { |
513 | c = *rptr++; | 513 | c = *rptr++; |
514 | fcode = BSD_KEY (ent, c); | 514 | fcode = BSD_KEY(ent, c); |
515 | hval = BSD_HASH (ent, c, hshift); | 515 | hval = BSD_HASH(ent, c, hshift); |
516 | dictp = dict_ptr (db, hval); | 516 | dictp = dict_ptr(db, hval); |
517 | 517 | ||
518 | /* Validate and then check the entry. */ | 518 | /* Validate and then check the entry. */ |
519 | if (dictp->codem1 >= max_ent) | 519 | if (dictp->codem1 >= max_ent) |
520 | goto nomatch; | 520 | goto nomatch; |
@@ -523,7 +523,7 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk | |||
523 | ent = dictp->codem1 + 1; | 523 | ent = dictp->codem1 + 1; |
524 | continue; /* found (prefix,suffix) */ | 524 | continue; /* found (prefix,suffix) */ |
525 | } | 525 | } |
526 | 526 | ||
527 | /* continue probing until a match or invalid entry */ | 527 | /* continue probing until a match or invalid entry */ |
528 | disp = (hval == 0) ? 1 : hval; | 528 | disp = (hval == 0) ? 1 : hval; |
529 | 529 | ||
@@ -531,17 +531,17 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk | |||
531 | hval += disp; | 531 | hval += disp; |
532 | if (hval >= db->hsize) | 532 | if (hval >= db->hsize) |
533 | hval -= db->hsize; | 533 | hval -= db->hsize; |
534 | dictp = dict_ptr (db, hval); | 534 | dictp = dict_ptr(db, hval); |
535 | if (dictp->codem1 >= max_ent) | 535 | if (dictp->codem1 >= max_ent) |
536 | goto nomatch; | 536 | goto nomatch; |
537 | } while (dictp->fcode != fcode); | 537 | } while (dictp->fcode != fcode); |
538 | 538 | ||
539 | ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */ | 539 | ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */ |
540 | continue; | 540 | continue; |
541 | 541 | ||
542 | nomatch: | 542 | nomatch: |
543 | OUTPUT(ent); /* output the prefix */ | 543 | OUTPUT(ent); /* output the prefix */ |
544 | 544 | ||
545 | /* code -> hashtable */ | 545 | /* code -> hashtable */ |
546 | if (max_ent < db->maxmaxcode) { | 546 | if (max_ent < db->maxmaxcode) { |
547 | struct bsd_dict *dictp2; | 547 | struct bsd_dict *dictp2; |
@@ -551,16 +551,16 @@ nomatch: | |||
551 | /* expand code size if needed */ | 551 | /* expand code size if needed */ |
552 | if (max_ent >= mxcode) { | 552 | if (max_ent >= mxcode) { |
553 | db->n_bits = ++n_bits; | 553 | db->n_bits = ++n_bits; |
554 | mxcode = MAXCODE (n_bits); | 554 | mxcode = MAXCODE(n_bits); |
555 | } | 555 | } |
556 | 556 | ||
557 | /* | 557 | /* |
558 | * Invalidate old hash table entry using | 558 | * Invalidate old hash table entry using |
559 | * this code, and then take it over. | 559 | * this code, and then take it over. |
560 | */ | 560 | */ |
561 | dictp2 = dict_ptr (db, max_ent + 1); | 561 | dictp2 = dict_ptr(db, max_ent + 1); |
562 | indx = dictp2->cptr; | 562 | indx = dictp2->cptr; |
563 | dictp3 = dict_ptr (db, indx); | 563 | dictp3 = dict_ptr(db, indx); |
564 | 564 | ||
565 | if (dictp3->codem1 == max_ent) | 565 | if (dictp3->codem1 == max_ent) |
566 | dictp3->codem1 = BADCODEM1; | 566 | dictp3->codem1 = BADCODEM1; |
@@ -571,17 +571,17 @@ nomatch: | |||
571 | db->max_ent = ++max_ent; | 571 | db->max_ent = ++max_ent; |
572 | 572 | ||
573 | if (db->lens) { | 573 | if (db->lens) { |
574 | unsigned short *len1 = lens_ptr (db, max_ent); | 574 | unsigned short *len1 = lens_ptr(db, max_ent); |
575 | unsigned short *len2 = lens_ptr (db, ent); | 575 | unsigned short *len2 = lens_ptr(db, ent); |
576 | *len1 = *len2 + 1; | 576 | *len1 = *len2 + 1; |
577 | } | 577 | } |
578 | } | 578 | } |
579 | ent = c; | 579 | ent = c; |
580 | } | 580 | } |
581 | 581 | ||
582 | OUTPUT(ent); /* output the last code */ | 582 | OUTPUT(ent); /* output the last code */ |
583 | 583 | ||
584 | if(skb_out) | 584 | if (skb_out) |
585 | 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 */ |
586 | db->uncomp_bytes += isize; | 586 | db->uncomp_bytes += isize; |
587 | db->in_count += isize; | 587 | db->in_count += isize; |
@@ -596,15 +596,15 @@ nomatch: | |||
596 | */ | 596 | */ |
597 | 597 | ||
598 | if (bsd_check(db)) | 598 | if (bsd_check(db)) |
599 | OUTPUT (CLEAR); | 599 | OUTPUT(CLEAR); |
600 | 600 | ||
601 | /* | 601 | /* |
602 | * Pad dribble bits of last code with ones. | 602 | * Pad dribble bits of last code with ones. |
603 | * Do not emit a completely useless byte of ones. | 603 | * Do not emit a completely useless byte of ones. |
604 | */ | 604 | */ |
605 | if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0) | 605 | if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0) |
606 | *(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); |
607 | 607 | ||
608 | /* | 608 | /* |
609 | * Increase code size if we would have without the packet | 609 | * Increase code size if we would have without the packet |
610 | * boundary because the decompressor will do so. | 610 | * boundary because the decompressor will do so. |
@@ -613,7 +613,7 @@ nomatch: | |||
613 | db->n_bits++; | 613 | db->n_bits++; |
614 | 614 | ||
615 | /* 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. */ |
616 | if (!skb_out || (skb_out && skb_out->len >= skb_in->len) ) { | 616 | if (!skb_out || (skb_out && skb_out->len >= skb_in->len)) { |
617 | ++db->incomp_count; | 617 | ++db->incomp_count; |
618 | db->incomp_bytes += isize; | 618 | db->incomp_bytes += isize; |
619 | return 0; | 619 | return 0; |
@@ -631,16 +631,16 @@ nomatch: | |||
631 | * Update the "BSD Compress" dictionary on the receiver for | 631 | * Update the "BSD Compress" dictionary on the receiver for |
632 | * incompressible data by pretending to compress the incoming data. | 632 | * incompressible data by pretending to compress the incoming data. |
633 | */ | 633 | */ |
634 | static void bsd_incomp (void *state, struct sk_buff *skb_in,int proto) | 634 | static void bsd_incomp(void *state, struct sk_buff *skb_in, int proto) |
635 | { | 635 | { |
636 | bsd_compress (state, skb_in, NULL, proto); | 636 | bsd_compress(state, skb_in, NULL, proto); |
637 | } | 637 | } |
638 | 638 | ||
639 | /* | 639 | /* |
640 | * Decompress "BSD Compress". | 640 | * Decompress "BSD Compress". |
641 | */ | 641 | */ |
642 | static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, | 642 | static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, |
643 | struct isdn_ppp_resetparams *rsparm) | 643 | struct isdn_ppp_resetparams *rsparm) |
644 | { | 644 | { |
645 | struct bsd_db *db; | 645 | struct bsd_db *db; |
646 | unsigned int max_ent; | 646 | unsigned int max_ent; |
@@ -653,7 +653,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
653 | unsigned int incode; | 653 | unsigned int incode; |
654 | unsigned int oldcode; | 654 | unsigned int oldcode; |
655 | unsigned int finchar; | 655 | unsigned int finchar; |
656 | unsigned char *p,*ibuf; | 656 | unsigned char *p, *ibuf; |
657 | int ilen; | 657 | int ilen; |
658 | int codelen; | 658 | int codelen; |
659 | int extra; | 659 | int extra; |
@@ -667,20 +667,20 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
667 | 667 | ||
668 | printk(KERN_DEBUG "bsd_decompress called\n"); | 668 | printk(KERN_DEBUG "bsd_decompress called\n"); |
669 | 669 | ||
670 | if(!skb_in || !skb_out) { | 670 | if (!skb_in || !skb_out) { |
671 | printk(KERN_ERR "bsd_decompress called with NULL parameter\n"); | 671 | printk(KERN_ERR "bsd_decompress called with NULL parameter\n"); |
672 | return DECOMP_ERROR; | 672 | return DECOMP_ERROR; |
673 | } | 673 | } |
674 | 674 | ||
675 | /* | 675 | /* |
676 | * Get the sequence number. | 676 | * Get the sequence number. |
677 | */ | 677 | */ |
678 | if( (p = skb_pull(skb_in,2)) == NULL) { | 678 | if ((p = skb_pull(skb_in, 2)) == NULL) { |
679 | return DECOMP_ERROR; | 679 | return DECOMP_ERROR; |
680 | } | 680 | } |
681 | p-=2; | 681 | p -= 2; |
682 | seq = (p[0] << 8) + p[1]; | 682 | seq = (p[0] << 8) + p[1]; |
683 | ilen = skb_in->len; | 683 | ilen = skb_in->len; |
684 | ibuf = skb_in->data; | 684 | ibuf = skb_in->data; |
685 | 685 | ||
686 | /* | 686 | /* |
@@ -690,7 +690,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
690 | if (seq != db->seqno) { | 690 | if (seq != db->seqno) { |
691 | if (db->debug) { | 691 | if (db->debug) { |
692 | 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", |
693 | db->unit, seq, db->seqno - 1); | 693 | db->unit, seq, db->seqno - 1); |
694 | } | 694 | } |
695 | return DECOMP_ERROR; | 695 | return DECOMP_ERROR; |
696 | } | 696 | } |
@@ -698,11 +698,11 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
698 | ++db->seqno; | 698 | ++db->seqno; |
699 | db->bytes_out += ilen; | 699 | db->bytes_out += ilen; |
700 | 700 | ||
701 | if(skb_tailroom(skb_out) > 0) | 701 | if (skb_tailroom(skb_out) > 0) |
702 | *(skb_put(skb_out,1)) = 0; | 702 | *(skb_put(skb_out, 1)) = 0; |
703 | else | 703 | else |
704 | return DECOMP_ERR_NOMEM; | 704 | return DECOMP_ERR_NOMEM; |
705 | 705 | ||
706 | oldcode = CLEAR; | 706 | oldcode = CLEAR; |
707 | 707 | ||
708 | /* | 708 | /* |
@@ -734,7 +734,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
734 | /* | 734 | /* |
735 | * 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. |
736 | */ | 736 | */ |
737 | 737 | ||
738 | if (incode == CLEAR) { | 738 | if (incode == CLEAR) { |
739 | if (ilen > 0) { | 739 | if (ilen > 0) { |
740 | if (db->debug) | 740 | if (db->debug) |
@@ -746,16 +746,16 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
746 | } | 746 | } |
747 | 747 | ||
748 | if ((incode > max_ent + 2) || (incode > db->maxmaxcode) | 748 | if ((incode > max_ent + 2) || (incode > db->maxmaxcode) |
749 | || (incode > max_ent && oldcode == CLEAR)) { | 749 | || (incode > max_ent && oldcode == CLEAR)) { |
750 | if (db->debug) { | 750 | if (db->debug) { |
751 | 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 ", |
752 | db->unit, incode, oldcode); | 752 | db->unit, incode, oldcode); |
753 | 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", |
754 | max_ent, skb_out->len, db->seqno); | 754 | max_ent, skb_out->len, db->seqno); |
755 | } | 755 | } |
756 | return DECOMP_FATALERROR; /* probably a bug */ | 756 | return DECOMP_FATALERROR; /* probably a bug */ |
757 | } | 757 | } |
758 | 758 | ||
759 | /* Special case for KwKwK string. */ | 759 | /* Special case for KwKwK string. */ |
760 | if (incode > max_ent) { | 760 | if (incode > max_ent) { |
761 | finchar = oldcode; | 761 | finchar = oldcode; |
@@ -765,13 +765,13 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
765 | extra = 0; | 765 | extra = 0; |
766 | } | 766 | } |
767 | 767 | ||
768 | codelen = *(lens_ptr (db, finchar)); | 768 | codelen = *(lens_ptr(db, finchar)); |
769 | if( skb_tailroom(skb_out) < codelen + extra) { | 769 | if (skb_tailroom(skb_out) < codelen + extra) { |
770 | if (db->debug) { | 770 | if (db->debug) { |
771 | 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); |
772 | #ifdef DEBUG | 772 | #ifdef DEBUG |
773 | 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", |
774 | ilen, finchar, codelen, skb_out->len); | 774 | ilen, finchar, codelen, skb_out->len); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | return DECOMP_FATALERROR; | 777 | return DECOMP_FATALERROR; |
@@ -781,21 +781,21 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
781 | * Decode this code and install it in the decompressed buffer. | 781 | * Decode this code and install it in the decompressed buffer. |
782 | */ | 782 | */ |
783 | 783 | ||
784 | p = skb_put(skb_out,codelen); | 784 | p = skb_put(skb_out, codelen); |
785 | p += codelen; | 785 | p += codelen; |
786 | while (finchar > LAST) { | 786 | while (finchar > LAST) { |
787 | struct bsd_dict *dictp2 = dict_ptr (db, finchar); | 787 | struct bsd_dict *dictp2 = dict_ptr(db, finchar); |
788 | 788 | ||
789 | dictp = dict_ptr (db, dictp2->cptr); | 789 | dictp = dict_ptr(db, dictp2->cptr); |
790 | 790 | ||
791 | #ifdef DEBUG | 791 | #ifdef DEBUG |
792 | if (--codelen <= 0 || dictp->codem1 != finchar-1) { | 792 | if (--codelen <= 0 || dictp->codem1 != finchar - 1) { |
793 | if (codelen <= 0) { | 793 | if (codelen <= 0) { |
794 | 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); |
795 | 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); |
796 | } else { | 796 | } else { |
797 | if (dictp->codem1 != finchar-1) { | 797 | if (dictp->codem1 != finchar - 1) { |
798 | 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); |
799 | 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); |
800 | } | 800 | } |
801 | } | 801 | } |
@@ -810,15 +810,15 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
810 | } | 810 | } |
811 | } | 811 | } |
812 | *--p = finchar; | 812 | *--p = finchar; |
813 | 813 | ||
814 | #ifdef DEBUG | 814 | #ifdef DEBUG |
815 | if (--codelen != 0) | 815 | if (--codelen != 0) |
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 | printk(KERN_ERR "bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n", db->unit, codelen, incode, max_ent); |
817 | #endif | 817 | #endif |
818 | 818 | ||
819 | if (extra) /* the KwKwK case again */ | 819 | if (extra) /* the KwKwK case again */ |
820 | *(skb_put(skb_out,1)) = finchar; | 820 | *(skb_put(skb_out, 1)) = finchar; |
821 | 821 | ||
822 | /* | 822 | /* |
823 | * If not first code in a packet, and | 823 | * If not first code in a packet, and |
824 | * if not out of code space, then allocate a new code. | 824 | * if not out of code space, then allocate a new code. |
@@ -828,14 +828,14 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
828 | */ | 828 | */ |
829 | if (oldcode != CLEAR && max_ent < db->maxmaxcode) { | 829 | if (oldcode != CLEAR && max_ent < db->maxmaxcode) { |
830 | struct bsd_dict *dictp2, *dictp3; | 830 | struct bsd_dict *dictp2, *dictp3; |
831 | u16 *lens1, *lens2; | 831 | u16 *lens1, *lens2; |
832 | unsigned long fcode; | 832 | unsigned long fcode; |
833 | int hval, disp, indx; | 833 | int hval, disp, indx; |
834 | 834 | ||
835 | fcode = BSD_KEY(oldcode,finchar); | 835 | fcode = BSD_KEY(oldcode, finchar); |
836 | hval = BSD_HASH(oldcode,finchar,db->hshift); | 836 | hval = BSD_HASH(oldcode, finchar, db->hshift); |
837 | dictp = dict_ptr (db, hval); | 837 | dictp = dict_ptr(db, hval); |
838 | 838 | ||
839 | /* look for a free hash table entry */ | 839 | /* look for a free hash table entry */ |
840 | if (dictp->codem1 < max_ent) { | 840 | if (dictp->codem1 < max_ent) { |
841 | disp = (hval == 0) ? 1 : hval; | 841 | disp = (hval == 0) ? 1 : hval; |
@@ -843,18 +843,18 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
843 | hval += disp; | 843 | hval += disp; |
844 | if (hval >= db->hsize) | 844 | if (hval >= db->hsize) |
845 | hval -= db->hsize; | 845 | hval -= db->hsize; |
846 | dictp = dict_ptr (db, hval); | 846 | dictp = dict_ptr(db, hval); |
847 | } while (dictp->codem1 < max_ent); | 847 | } while (dictp->codem1 < max_ent); |
848 | } | 848 | } |
849 | 849 | ||
850 | /* | 850 | /* |
851 | * Invalidate previous hash table entry | 851 | * Invalidate previous hash table entry |
852 | * assigned this code, and then take it over | 852 | * assigned this code, and then take it over |
853 | */ | 853 | */ |
854 | 854 | ||
855 | dictp2 = dict_ptr (db, max_ent + 1); | 855 | dictp2 = dict_ptr(db, max_ent + 1); |
856 | indx = dictp2->cptr; | 856 | indx = dictp2->cptr; |
857 | dictp3 = dict_ptr (db, indx); | 857 | dictp3 = dict_ptr(db, indx); |
858 | 858 | ||
859 | if (dictp3->codem1 == max_ent) | 859 | if (dictp3->codem1 == max_ent) |
860 | dictp3->codem1 = BADCODEM1; | 860 | dictp3->codem1 = BADCODEM1; |
@@ -865,10 +865,10 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
865 | db->max_ent = ++max_ent; | 865 | db->max_ent = ++max_ent; |
866 | 866 | ||
867 | /* Update the length of this string. */ | 867 | /* Update the length of this string. */ |
868 | lens1 = lens_ptr (db, max_ent); | 868 | lens1 = lens_ptr(db, max_ent); |
869 | lens2 = lens_ptr (db, oldcode); | 869 | lens2 = lens_ptr(db, oldcode); |
870 | *lens1 = *lens2 + 1; | 870 | *lens1 = *lens2 + 1; |
871 | 871 | ||
872 | /* Expand code size if needed. */ | 872 | /* Expand code size if needed. */ |
873 | if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) { | 873 | if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) { |
874 | db->n_bits = ++n_bits; | 874 | db->n_bits = ++n_bits; |
@@ -886,7 +886,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * | |||
886 | if (bsd_check(db)) { | 886 | if (bsd_check(db)) { |
887 | if (db->debug) | 887 | if (db->debug) |
888 | 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", |
889 | db->unit, db->seqno - 1); | 889 | db->unit, db->seqno - 1); |
890 | } | 890 | } |
891 | return skb_out->len; | 891 | return skb_out->len; |
892 | } | 892 | } |
@@ -914,15 +914,15 @@ static struct isdn_ppp_compressor ippp_bsd_compress = { | |||
914 | 914 | ||
915 | static int __init isdn_bsdcomp_init(void) | 915 | static int __init isdn_bsdcomp_init(void) |
916 | { | 916 | { |
917 | int answer = isdn_ppp_register_compressor (&ippp_bsd_compress); | 917 | int answer = isdn_ppp_register_compressor(&ippp_bsd_compress); |
918 | if (answer == 0) | 918 | if (answer == 0) |
919 | printk (KERN_INFO "PPP BSD Compression module registered\n"); | 919 | printk(KERN_INFO "PPP BSD Compression module registered\n"); |
920 | return answer; | 920 | return answer; |
921 | } | 921 | } |
922 | 922 | ||
923 | static void __exit isdn_bsdcomp_exit(void) | 923 | static void __exit isdn_bsdcomp_exit(void) |
924 | { | 924 | { |
925 | isdn_ppp_unregister_compressor (&ippp_bsd_compress); | 925 | isdn_ppp_unregister_compressor(&ippp_bsd_compress); |
926 | } | 926 | } |
927 | 927 | ||
928 | module_init(isdn_bsdcomp_init); | 928 | module_init(isdn_bsdcomp_init); |
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 6ddb795e31c5..d9f5524593fb 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c | |||
@@ -111,7 +111,7 @@ isdn_unlock_drivers(void) | |||
111 | 111 | ||
112 | #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) | 112 | #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) |
113 | void | 113 | void |
114 | isdn_dumppkt(char *s, u_char * p, int len, int dumplen) | 114 | isdn_dumppkt(char *s, u_char *p, int len, int dumplen) |
115 | { | 115 | { |
116 | int dumpc; | 116 | int dumpc; |
117 | 117 | ||
@@ -163,58 +163,58 @@ isdn_wildmat(char *s, char *p) | |||
163 | register int nostar = 1; | 163 | register int nostar = 1; |
164 | 164 | ||
165 | if (!(*s) && !(*p)) | 165 | if (!(*s) && !(*p)) |
166 | return(1); | 166 | return (1); |
167 | for (; *p; s++, p++) | 167 | for (; *p; s++, p++) |
168 | switch (*p) { | 168 | switch (*p) { |
169 | case '\\': | 169 | case '\\': |
170 | /* | 170 | /* |
171 | * Literal match with following character, | 171 | * Literal match with following character, |
172 | * fall through. | 172 | * fall through. |
173 | */ | 173 | */ |
174 | p++; | ||
175 | default: | ||
176 | if (*s != *p) | ||
177 | return (*s == '\0') ? 2 : 1; | ||
178 | continue; | ||
179 | case '?': | ||
180 | /* Match anything. */ | ||
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] == '^'))) | ||
174 | p++; | 191 | p++; |
175 | default: | 192 | for (last = 0, matched = 0; *++p && (*p != ']'); last = *p) |
176 | if (*s != *p) | 193 | /* This next line requires a good C compiler. */ |
177 | return (*s == '\0')?2:1; | 194 | if (*p == '-' ? *s <= *++p && *s >= last : *s == *p) |
178 | continue; | 195 | matched = 1; |
179 | case '?': | 196 | if (matched == reverse) |
180 | /* Match anything. */ | 197 | return (1); |
181 | if (*s == '\0') | 198 | continue; |
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; | ||
199 | } | 199 | } |
200 | return (*s == '\0')?0:nostar; | 200 | return (*s == '\0') ? 0 : nostar; |
201 | } | 201 | } |
202 | 202 | ||
203 | int isdn_msncmp( const char * msn1, const char * msn2 ) | 203 | int isdn_msncmp(const char *msn1, const char *msn2) |
204 | { | 204 | { |
205 | char TmpMsn1[ ISDN_MSNLEN ]; | 205 | char TmpMsn1[ISDN_MSNLEN]; |
206 | char TmpMsn2[ ISDN_MSNLEN ]; | 206 | char TmpMsn2[ISDN_MSNLEN]; |
207 | char *p; | 207 | char *p; |
208 | 208 | ||
209 | for ( p = TmpMsn1; *msn1 && *msn1 != ':'; ) // Strip off a SPID | 209 | for (p = TmpMsn1; *msn1 && *msn1 != ':';) // Strip off a SPID |
210 | *p++ = *msn1++; | 210 | *p++ = *msn1++; |
211 | *p = '\0'; | 211 | *p = '\0'; |
212 | 212 | ||
213 | for ( p = TmpMsn2; *msn2 && *msn2 != ':'; ) // Strip off a SPID | 213 | for (p = TmpMsn2; *msn2 && *msn2 != ':';) // Strip off a SPID |
214 | *p++ = *msn2++; | 214 | *p++ = *msn2++; |
215 | *p = '\0'; | 215 | *p = '\0'; |
216 | 216 | ||
217 | return isdn_wildmat( TmpMsn1, TmpMsn2 ); | 217 | return isdn_wildmat(TmpMsn1, TmpMsn2); |
218 | } | 218 | } |
219 | 219 | ||
220 | int | 220 | int |
@@ -262,8 +262,8 @@ isdn_timer_funct(ulong dummy) | |||
262 | isdn_tty_carrier_timeout(); | 262 | isdn_tty_carrier_timeout(); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | if (tf) | 265 | if (tf) |
266 | mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES); | 266 | mod_timer(&dev->timer, jiffies + ISDN_TIMER_RES); |
267 | } | 267 | } |
268 | 268 | ||
269 | void | 269 | void |
@@ -284,7 +284,7 @@ isdn_timer_ctrl(int tf, int onoff) | |||
284 | else | 284 | else |
285 | dev->tflags &= ~tf; | 285 | dev->tflags &= ~tf; |
286 | if (dev->tflags && !old_tflags) | 286 | if (dev->tflags && !old_tflags) |
287 | mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES); | 287 | mod_timer(&dev->timer, jiffies + ISDN_TIMER_RES); |
288 | spin_unlock_irqrestore(&dev->timerlock, flags); | 288 | spin_unlock_irqrestore(&dev->timerlock, flags); |
289 | } | 289 | } |
290 | 290 | ||
@@ -302,7 +302,7 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) | |||
302 | } | 302 | } |
303 | /* Update statistics */ | 303 | /* Update statistics */ |
304 | dev->ibytes[i] += skb->len; | 304 | dev->ibytes[i] += skb->len; |
305 | 305 | ||
306 | /* First, try to deliver data to network-device */ | 306 | /* First, try to deliver data to network-device */ |
307 | if (isdn_net_rcv_skb(i, skb)) | 307 | if (isdn_net_rcv_skb(i, skb)) |
308 | return; | 308 | return; |
@@ -339,40 +339,40 @@ isdn_command(isdn_ctrl *cmd) | |||
339 | { | 339 | { |
340 | if (cmd->driver == -1) { | 340 | if (cmd->driver == -1) { |
341 | 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); |
342 | return(1); | 342 | return (1); |
343 | } | 343 | } |
344 | if (!dev->drv[cmd->driver]) { | 344 | if (!dev->drv[cmd->driver]) { |
345 | 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", |
346 | cmd->command, cmd->driver); | 346 | cmd->command, cmd->driver); |
347 | return(1); | 347 | return (1); |
348 | } | 348 | } |
349 | if (!dev->drv[cmd->driver]->interface) { | 349 | if (!dev->drv[cmd->driver]->interface) { |
350 | 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", |
351 | cmd->command, cmd->driver); | 351 | cmd->command, cmd->driver); |
352 | return(1); | 352 | return (1); |
353 | } | 353 | } |
354 | if (cmd->command == ISDN_CMD_SETL2) { | 354 | if (cmd->command == ISDN_CMD_SETL2) { |
355 | int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255); | 355 | int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255); |
356 | unsigned long l2prot = (cmd->arg >> 8) & 255; | 356 | unsigned long l2prot = (cmd->arg >> 8) & 255; |
357 | unsigned long features = (dev->drv[cmd->driver]->interface->features | 357 | unsigned long features = (dev->drv[cmd->driver]->interface->features |
358 | >> ISDN_FEATURE_L2_SHIFT) & | 358 | >> ISDN_FEATURE_L2_SHIFT) & |
359 | ISDN_FEATURE_L2_MASK; | 359 | ISDN_FEATURE_L2_MASK; |
360 | unsigned long l2_feature = (1 << l2prot); | 360 | unsigned long l2_feature = (1 << l2prot); |
361 | 361 | ||
362 | switch (l2prot) { | 362 | switch (l2prot) { |
363 | case ISDN_PROTO_L2_V11096: | 363 | case ISDN_PROTO_L2_V11096: |
364 | case ISDN_PROTO_L2_V11019: | 364 | case ISDN_PROTO_L2_V11019: |
365 | case ISDN_PROTO_L2_V11038: | 365 | case ISDN_PROTO_L2_V11038: |
366 | /* If V.110 requested, but not supported by | 366 | /* If V.110 requested, but not supported by |
367 | * HL-driver, set emulator-flag and change | 367 | * HL-driver, set emulator-flag and change |
368 | * Layer-2 to transparent | 368 | * Layer-2 to transparent |
369 | */ | 369 | */ |
370 | if (!(features & l2_feature)) { | 370 | if (!(features & l2_feature)) { |
371 | dev->v110emu[idx] = l2prot; | 371 | dev->v110emu[idx] = l2prot; |
372 | cmd->arg = (cmd->arg & 255) | | 372 | cmd->arg = (cmd->arg & 255) | |
373 | (ISDN_PROTO_L2_TRANS << 8); | 373 | (ISDN_PROTO_L2_TRANS << 8); |
374 | } else | 374 | } else |
375 | dev->v110emu[idx] = 0; | 375 | dev->v110emu[idx] = 0; |
376 | } | 376 | } |
377 | } | 377 | } |
378 | return dev->drv[cmd->driver]->interface->command(cmd); | 378 | return dev->drv[cmd->driver]->interface->command(cmd); |
@@ -393,7 +393,7 @@ isdn_all_eaz(int di, int ch) | |||
393 | } | 393 | } |
394 | 394 | ||
395 | /* | 395 | /* |
396 | * 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 |
397 | * supplementary service (CAPI 2.0 part III) | 397 | * supplementary service (CAPI 2.0 part III) |
398 | */ | 398 | */ |
399 | #include <linux/isdn/capicmd.h> | 399 | #include <linux/isdn/capicmd.h> |
@@ -401,17 +401,17 @@ isdn_all_eaz(int di, int ch) | |||
401 | static int | 401 | static int |
402 | isdn_capi_rec_hl_msg(capi_msg *cm) | 402 | isdn_capi_rec_hl_msg(capi_msg *cm) |
403 | { | 403 | { |
404 | switch(cm->Command) { | 404 | switch (cm->Command) { |
405 | case CAPI_FACILITY: | 405 | case CAPI_FACILITY: |
406 | /* in the moment only handled in tty */ | 406 | /* in the moment only handled in tty */ |
407 | return(isdn_tty_capi_facility(cm)); | 407 | return (isdn_tty_capi_facility(cm)); |
408 | default: | 408 | default: |
409 | return(-1); | 409 | return (-1); |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | static int | 413 | static int |
414 | isdn_status_callback(isdn_ctrl * c) | 414 | isdn_status_callback(isdn_ctrl *c) |
415 | { | 415 | { |
416 | int di; | 416 | int di; |
417 | u_long flags; | 417 | u_long flags; |
@@ -424,314 +424,314 @@ isdn_status_callback(isdn_ctrl * c) | |||
424 | di = c->driver; | 424 | di = c->driver; |
425 | i = isdn_dc2minor(di, c->arg); | 425 | i = isdn_dc2minor(di, c->arg); |
426 | switch (c->command) { | 426 | switch (c->command) { |
427 | case ISDN_STAT_BSENT: | 427 | case ISDN_STAT_BSENT: |
428 | if (i < 0) | 428 | if (i < 0) |
429 | return -1; | 429 | return -1; |
430 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 430 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
431 | return 0; | 431 | return 0; |
432 | if (isdn_net_stat_callback(i, c)) | 432 | if (isdn_net_stat_callback(i, c)) |
433 | return 0; | 433 | return 0; |
434 | if (isdn_v110_stat_callback(i, c)) | 434 | if (isdn_v110_stat_callback(i, c)) |
435 | return 0; | 435 | return 0; |
436 | if (isdn_tty_stat_callback(i, c)) | 436 | if (isdn_tty_stat_callback(i, c)) |
437 | return 0; | 437 | return 0; |
438 | wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]); | 438 | wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]); |
439 | break; | 439 | break; |
440 | case ISDN_STAT_STAVAIL: | 440 | case ISDN_STAT_STAVAIL: |
441 | dev->drv[di]->stavail += c->arg; | 441 | dev->drv[di]->stavail += c->arg; |
442 | wake_up_interruptible(&dev->drv[di]->st_waitq); | 442 | wake_up_interruptible(&dev->drv[di]->st_waitq); |
443 | break; | 443 | break; |
444 | case ISDN_STAT_RUN: | 444 | case ISDN_STAT_RUN: |
445 | dev->drv[di]->flags |= DRV_FLAG_RUNNING; | 445 | dev->drv[di]->flags |= DRV_FLAG_RUNNING; |
446 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) | 446 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) |
447 | if (dev->drvmap[i] == di) | 447 | if (dev->drvmap[i] == di) |
448 | isdn_all_eaz(di, dev->chanmap[i]); | 448 | isdn_all_eaz(di, dev->chanmap[i]); |
449 | set_global_features(); | 449 | set_global_features(); |
450 | break; | 450 | break; |
451 | case ISDN_STAT_STOP: | 451 | case ISDN_STAT_STOP: |
452 | dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; | 452 | dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; |
453 | break; | 453 | break; |
454 | case ISDN_STAT_ICALL: | 454 | case ISDN_STAT_ICALL: |
455 | if (i < 0) | 455 | if (i < 0) |
456 | return -1; | 456 | return -1; |
457 | #ifdef ISDN_DEBUG_STATCALLB | 457 | #ifdef ISDN_DEBUG_STATCALLB |
458 | 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); |
459 | #endif | 459 | #endif |
460 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) { | 460 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) { |
461 | cmd.driver = di; | ||
462 | cmd.arg = c->arg; | ||
463 | cmd.command = ISDN_CMD_HANGUP; | ||
464 | isdn_command(&cmd); | ||
465 | return 0; | ||
466 | } | ||
467 | /* Try to find a network-interface which will accept incoming call */ | ||
468 | r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup)); | ||
469 | switch (r) { | ||
470 | case 0: | ||
471 | /* No network-device replies. | ||
472 | * Try ttyI's. | ||
473 | * These return 0 on no match, 1 on match and | ||
474 | * 3 on eventually match, if CID is longer. | ||
475 | */ | ||
476 | if (c->command == ISDN_STAT_ICALL) | ||
477 | if ((retval = isdn_tty_find_icall(di, c->arg, &c->parm.setup))) return (retval); | ||
478 | #ifdef CONFIG_ISDN_DIVERSION | ||
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 */ | ||
461 | cmd.driver = di; | 485 | cmd.driver = di; |
462 | cmd.arg = c->arg; | 486 | cmd.arg = c->arg; |
463 | cmd.command = ISDN_CMD_HANGUP; | 487 | cmd.command = ISDN_CMD_HANGUP; |
464 | isdn_command(&cmd); | 488 | isdn_command(&cmd); |
465 | return 0; | 489 | retval = 2; |
466 | } | 490 | } |
467 | /* Try to find a network-interface which will accept incoming call */ | 491 | break; |
468 | r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup)); | 492 | case 1: |
469 | switch (r) { | 493 | /* Schedule connection-setup */ |
470 | case 0: | 494 | isdn_net_dial(); |
471 | /* No network-device replies. | 495 | cmd.driver = di; |
472 | * Try ttyI's. | 496 | cmd.arg = c->arg; |
473 | * These return 0 on no match, 1 on match and | 497 | cmd.command = ISDN_CMD_ACCEPTD; |
474 | * 3 on eventually match, if CID is longer. | 498 | for (p = dev->netdev; p; p = p->next) |
475 | */ | 499 | if (p->local->isdn_channel == cmd.arg) |
476 | if (c->command == ISDN_STAT_ICALL) | 500 | { |
477 | if ((retval = isdn_tty_find_icall(di, c->arg, &c->parm.setup))) return(retval); | 501 | strcpy(cmd.parm.setup.eazmsn, p->local->msn); |
478 | #ifdef CONFIG_ISDN_DIVERSION | ||
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 | } | ||
506 | break; | ||
507 | |||
508 | case 2: /* For calling back, first reject incoming call ... */ | ||
509 | case 3: /* Interface found, but down, reject call actively */ | ||
510 | retval = 2; | ||
511 | printk(KERN_INFO "isdn: Rejecting Call\n"); | ||
512 | cmd.driver = di; | ||
513 | cmd.arg = c->arg; | ||
514 | cmd.command = ISDN_CMD_HANGUP; | ||
515 | isdn_command(&cmd); | 502 | isdn_command(&cmd); |
516 | if (r == 3) | 503 | retval = 1; |
517 | break; | ||
518 | /* Fall through */ | ||
519 | case 4: | ||
520 | /* ... then start callback. */ | ||
521 | isdn_net_dial(); | ||
522 | break; | ||
523 | case 5: | ||
524 | /* Number would eventually match, if longer */ | ||
525 | retval = 3; | ||
526 | break; | 504 | break; |
527 | } | 505 | } |
506 | break; | ||
507 | |||
508 | case 2: /* For calling back, first reject incoming call ... */ | ||
509 | case 3: /* Interface found, but down, reject call actively */ | ||
510 | retval = 2; | ||
511 | printk(KERN_INFO "isdn: Rejecting Call\n"); | ||
512 | cmd.driver = di; | ||
513 | cmd.arg = c->arg; | ||
514 | cmd.command = ISDN_CMD_HANGUP; | ||
515 | isdn_command(&cmd); | ||
516 | if (r == 3) | ||
517 | break; | ||
518 | /* Fall through */ | ||
519 | case 4: | ||
520 | /* ... then start callback. */ | ||
521 | isdn_net_dial(); | ||
522 | break; | ||
523 | case 5: | ||
524 | /* Number would eventually match, if longer */ | ||
525 | retval = 3; | ||
526 | break; | ||
527 | } | ||
528 | #ifdef ISDN_DEBUG_STATCALLB | 528 | #ifdef ISDN_DEBUG_STATCALLB |
529 | printk(KERN_DEBUG "ICALL: ret=%d\n", retval); | 529 | printk(KERN_DEBUG "ICALL: ret=%d\n", retval); |
530 | #endif | 530 | #endif |
531 | return retval; | 531 | return retval; |
532 | break; | 532 | break; |
533 | case ISDN_STAT_CINF: | 533 | case ISDN_STAT_CINF: |
534 | if (i < 0) | 534 | if (i < 0) |
535 | return -1; | 535 | return -1; |
536 | #ifdef ISDN_DEBUG_STATCALLB | 536 | #ifdef ISDN_DEBUG_STATCALLB |
537 | 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); |
538 | #endif | 538 | #endif |
539 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 539 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
540 | return 0; | 540 | return 0; |
541 | if (strcmp(c->parm.num, "0")) | 541 | if (strcmp(c->parm.num, "0")) |
542 | isdn_net_stat_callback(i, c); | 542 | isdn_net_stat_callback(i, c); |
543 | isdn_tty_stat_callback(i, c); | 543 | isdn_tty_stat_callback(i, c); |
544 | break; | 544 | break; |
545 | case ISDN_STAT_CAUSE: | 545 | case ISDN_STAT_CAUSE: |
546 | #ifdef ISDN_DEBUG_STATCALLB | 546 | #ifdef ISDN_DEBUG_STATCALLB |
547 | 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); |
548 | #endif | 548 | #endif |
549 | printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", | 549 | printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", |
550 | dev->drvid[di], c->arg, c->parm.num); | 550 | dev->drvid[di], c->arg, c->parm.num); |
551 | isdn_tty_stat_callback(i, c); | 551 | isdn_tty_stat_callback(i, c); |
552 | #ifdef CONFIG_ISDN_DIVERSION | 552 | #ifdef CONFIG_ISDN_DIVERSION |
553 | if (divert_if) | 553 | if (divert_if) |
554 | divert_if->stat_callback(c); | 554 | divert_if->stat_callback(c); |
555 | #endif /* CONFIG_ISDN_DIVERSION */ | 555 | #endif /* CONFIG_ISDN_DIVERSION */ |
556 | break; | 556 | break; |
557 | case ISDN_STAT_DISPLAY: | 557 | case ISDN_STAT_DISPLAY: |
558 | #ifdef ISDN_DEBUG_STATCALLB | 558 | #ifdef ISDN_DEBUG_STATCALLB |
559 | 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); |
560 | #endif | 560 | #endif |
561 | isdn_tty_stat_callback(i, c); | 561 | isdn_tty_stat_callback(i, c); |
562 | #ifdef CONFIG_ISDN_DIVERSION | 562 | #ifdef CONFIG_ISDN_DIVERSION |
563 | if (divert_if) | 563 | if (divert_if) |
564 | divert_if->stat_callback(c); | 564 | divert_if->stat_callback(c); |
565 | #endif /* CONFIG_ISDN_DIVERSION */ | 565 | #endif /* CONFIG_ISDN_DIVERSION */ |
566 | break; | 566 | break; |
567 | case ISDN_STAT_DCONN: | 567 | case ISDN_STAT_DCONN: |
568 | if (i < 0) | 568 | if (i < 0) |
569 | return -1; | 569 | return -1; |
570 | #ifdef ISDN_DEBUG_STATCALLB | 570 | #ifdef ISDN_DEBUG_STATCALLB |
571 | printk(KERN_DEBUG "DCONN: %ld\n", c->arg); | 571 | printk(KERN_DEBUG "DCONN: %ld\n", c->arg); |
572 | #endif | 572 | #endif |
573 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 573 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
574 | return 0; | 574 | return 0; |
575 | /* Find any net-device, waiting for D-channel setup */ | 575 | /* Find any net-device, waiting for D-channel setup */ |
576 | if (isdn_net_stat_callback(i, c)) | 576 | if (isdn_net_stat_callback(i, c)) |
577 | break; | ||
578 | isdn_v110_stat_callback(i, c); | ||
579 | /* Find any ttyI, waiting for D-channel setup */ | ||
580 | if (isdn_tty_stat_callback(i, c)) { | ||
581 | cmd.driver = di; | ||
582 | cmd.arg = c->arg; | ||
583 | cmd.command = ISDN_CMD_ACCEPTB; | ||
584 | isdn_command(&cmd); | ||
585 | break; | ||
586 | } | ||
587 | break; | 577 | break; |
588 | case ISDN_STAT_DHUP: | 578 | isdn_v110_stat_callback(i, c); |
589 | if (i < 0) | 579 | /* Find any ttyI, waiting for D-channel setup */ |
590 | return -1; | 580 | if (isdn_tty_stat_callback(i, c)) { |
581 | cmd.driver = di; | ||
582 | cmd.arg = c->arg; | ||
583 | cmd.command = ISDN_CMD_ACCEPTB; | ||
584 | isdn_command(&cmd); | ||
585 | break; | ||
586 | } | ||
587 | break; | ||
588 | case ISDN_STAT_DHUP: | ||
589 | if (i < 0) | ||
590 | return -1; | ||
591 | #ifdef ISDN_DEBUG_STATCALLB | 591 | #ifdef ISDN_DEBUG_STATCALLB |
592 | printk(KERN_DEBUG "DHUP: %ld\n", c->arg); | 592 | printk(KERN_DEBUG "DHUP: %ld\n", c->arg); |
593 | #endif | 593 | #endif |
594 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 594 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
595 | return 0; | 595 | return 0; |
596 | dev->drv[di]->online &= ~(1 << (c->arg)); | 596 | dev->drv[di]->online &= ~(1 << (c->arg)); |
597 | isdn_info_update(); | 597 | isdn_info_update(); |
598 | /* Signal hangup to network-devices */ | 598 | /* Signal hangup to network-devices */ |
599 | if (isdn_net_stat_callback(i, c)) | 599 | if (isdn_net_stat_callback(i, c)) |
600 | break; | ||
601 | isdn_v110_stat_callback(i, c); | ||
602 | if (isdn_tty_stat_callback(i, c)) | ||
603 | break; | ||
604 | #ifdef CONFIG_ISDN_DIVERSION | ||
605 | if (divert_if) | ||
606 | divert_if->stat_callback(c); | ||
607 | #endif /* CONFIG_ISDN_DIVERSION */ | ||
608 | break; | 600 | break; |
601 | isdn_v110_stat_callback(i, c); | ||
602 | if (isdn_tty_stat_callback(i, c)) | ||
609 | break; | 603 | break; |
610 | case ISDN_STAT_BCONN: | 604 | #ifdef CONFIG_ISDN_DIVERSION |
611 | if (i < 0) | 605 | if (divert_if) |
612 | return -1; | 606 | divert_if->stat_callback(c); |
607 | #endif /* CONFIG_ISDN_DIVERSION */ | ||
608 | break; | ||
609 | break; | ||
610 | case ISDN_STAT_BCONN: | ||
611 | if (i < 0) | ||
612 | return -1; | ||
613 | #ifdef ISDN_DEBUG_STATCALLB | 613 | #ifdef ISDN_DEBUG_STATCALLB |
614 | printk(KERN_DEBUG "BCONN: %ld\n", c->arg); | 614 | printk(KERN_DEBUG "BCONN: %ld\n", c->arg); |
615 | #endif | 615 | #endif |
616 | /* Signal B-channel-connect to network-devices */ | 616 | /* Signal B-channel-connect to network-devices */ |
617 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 617 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
618 | return 0; | 618 | return 0; |
619 | dev->drv[di]->online |= (1 << (c->arg)); | 619 | dev->drv[di]->online |= (1 << (c->arg)); |
620 | isdn_info_update(); | 620 | isdn_info_update(); |
621 | if (isdn_net_stat_callback(i, c)) | 621 | if (isdn_net_stat_callback(i, c)) |
622 | break; | 622 | break; |
623 | isdn_v110_stat_callback(i, c); | 623 | isdn_v110_stat_callback(i, c); |
624 | if (isdn_tty_stat_callback(i, c)) | 624 | if (isdn_tty_stat_callback(i, c)) |
625 | break; | ||
626 | break; | 625 | break; |
627 | case ISDN_STAT_BHUP: | 626 | break; |
628 | if (i < 0) | 627 | case ISDN_STAT_BHUP: |
629 | return -1; | 628 | if (i < 0) |
629 | return -1; | ||
630 | #ifdef ISDN_DEBUG_STATCALLB | 630 | #ifdef ISDN_DEBUG_STATCALLB |
631 | printk(KERN_DEBUG "BHUP: %ld\n", c->arg); | 631 | printk(KERN_DEBUG "BHUP: %ld\n", c->arg); |
632 | #endif | 632 | #endif |
633 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 633 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
634 | return 0; | 634 | return 0; |
635 | dev->drv[di]->online &= ~(1 << (c->arg)); | 635 | dev->drv[di]->online &= ~(1 << (c->arg)); |
636 | isdn_info_update(); | 636 | isdn_info_update(); |
637 | #ifdef CONFIG_ISDN_X25 | 637 | #ifdef CONFIG_ISDN_X25 |
638 | /* Signal hangup to network-devices */ | 638 | /* Signal hangup to network-devices */ |
639 | if (isdn_net_stat_callback(i, c)) | 639 | if (isdn_net_stat_callback(i, c)) |
640 | break; | 640 | break; |
641 | #endif | 641 | #endif |
642 | isdn_v110_stat_callback(i, c); | 642 | isdn_v110_stat_callback(i, c); |
643 | if (isdn_tty_stat_callback(i, c)) | 643 | if (isdn_tty_stat_callback(i, c)) |
644 | break; | ||
645 | break; | 644 | break; |
646 | case ISDN_STAT_NODCH: | 645 | break; |
647 | if (i < 0) | 646 | case ISDN_STAT_NODCH: |
648 | return -1; | 647 | if (i < 0) |
648 | return -1; | ||
649 | #ifdef ISDN_DEBUG_STATCALLB | 649 | #ifdef ISDN_DEBUG_STATCALLB |
650 | printk(KERN_DEBUG "NODCH: %ld\n", c->arg); | 650 | printk(KERN_DEBUG "NODCH: %ld\n", c->arg); |
651 | #endif | 651 | #endif |
652 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) | 652 | if (dev->global_flags & ISDN_GLOBAL_STOPPED) |
653 | return 0; | 653 | return 0; |
654 | 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; | ||
658 | break; | 655 | break; |
659 | case ISDN_STAT_ADDCH: | 656 | if (isdn_tty_stat_callback(i, c)) |
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(); | ||
667 | break; | 657 | break; |
668 | case ISDN_STAT_DISCH: | 658 | break; |
669 | spin_lock_irqsave(&dev->lock, flags); | 659 | case ISDN_STAT_ADDCH: |
670 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) | 660 | spin_lock_irqsave(&dev->lock, flags); |
671 | if ((dev->drvmap[i] == di) && | 661 | if (isdn_add_channels(dev->drv[di], di, c->arg, 1)) { |
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 | } | ||
683 | spin_unlock_irqrestore(&dev->lock, flags); | 662 | spin_unlock_irqrestore(&dev->lock, flags); |
684 | isdn_info_update(); | 663 | return -1; |
685 | break; | 664 | } |
686 | case ISDN_STAT_UNLOAD: | 665 | spin_unlock_irqrestore(&dev->lock, flags); |
687 | while (dev->drv[di]->locks > 0) { | 666 | isdn_info_update(); |
688 | isdn_unlock_driver(dev->drv[di]); | 667 | break; |
689 | } | 668 | case ISDN_STAT_DISCH: |
690 | spin_lock_irqsave(&dev->lock, flags); | 669 | spin_lock_irqsave(&dev->lock, flags); |
691 | isdn_tty_stat_callback(i, c); | 670 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) |
692 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) | 671 | if ((dev->drvmap[i] == di) && |
693 | if (dev->drvmap[i] == di) { | 672 | (dev->chanmap[i] == c->arg)) { |
694 | dev->drvmap[i] = -1; | 673 | if (c->parm.num[0]) |
695 | dev->chanmap[i] = -1; | ||
696 | dev->usage[i] &= ~ISDN_USAGE_DISABLED; | 674 | dev->usage[i] &= ~ISDN_USAGE_DISABLED; |
697 | } | 675 | else |
698 | dev->drivers--; | 676 | if (USG_NONE(dev->usage[i])) { |
699 | dev->channels -= dev->drv[di]->channels; | 677 | dev->usage[i] |= ISDN_USAGE_DISABLED; |
700 | kfree(dev->drv[di]->rcverr); | 678 | } |
701 | kfree(dev->drv[di]->rcvcount); | 679 | else |
702 | for (i = 0; i < dev->drv[di]->channels; i++) | 680 | retval = -1; |
703 | skb_queue_purge(&dev->drv[di]->rpqueue[i]); | 681 | break; |
704 | kfree(dev->drv[di]->rpqueue); | 682 | } |
705 | kfree(dev->drv[di]->rcv_waitq); | 683 | spin_unlock_irqrestore(&dev->lock, flags); |
706 | kfree(dev->drv[di]); | 684 | isdn_info_update(); |
707 | dev->drv[di] = NULL; | 685 | break; |
708 | dev->drvid[di][0] = '\0'; | 686 | case ISDN_STAT_UNLOAD: |
709 | isdn_info_update(); | 687 | while (dev->drv[di]->locks > 0) { |
710 | set_global_features(); | 688 | isdn_unlock_driver(dev->drv[di]); |
711 | spin_unlock_irqrestore(&dev->lock, flags); | 689 | } |
712 | return 0; | 690 | spin_lock_irqsave(&dev->lock, flags); |
713 | case ISDN_STAT_L1ERR: | 691 | isdn_tty_stat_callback(i, c); |
714 | break; | 692 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) |
715 | case CAPI_PUT_MESSAGE: | 693 | if (dev->drvmap[i] == di) { |
716 | return(isdn_capi_rec_hl_msg(&c->parm.cmsg)); | 694 | dev->drvmap[i] = -1; |
695 | dev->chanmap[i] = -1; | ||
696 | dev->usage[i] &= ~ISDN_USAGE_DISABLED; | ||
697 | } | ||
698 | dev->drivers--; | ||
699 | dev->channels -= dev->drv[di]->channels; | ||
700 | kfree(dev->drv[di]->rcverr); | ||
701 | kfree(dev->drv[di]->rcvcount); | ||
702 | for (i = 0; i < dev->drv[di]->channels; i++) | ||
703 | skb_queue_purge(&dev->drv[di]->rpqueue[i]); | ||
704 | kfree(dev->drv[di]->rpqueue); | ||
705 | kfree(dev->drv[di]->rcv_waitq); | ||
706 | kfree(dev->drv[di]); | ||
707 | dev->drv[di] = NULL; | ||
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)); | ||
717 | #ifdef CONFIG_ISDN_TTY_FAX | 717 | #ifdef CONFIG_ISDN_TTY_FAX |
718 | case ISDN_STAT_FAXIND: | 718 | case ISDN_STAT_FAXIND: |
719 | isdn_tty_stat_callback(i, c); | 719 | isdn_tty_stat_callback(i, c); |
720 | break; | 720 | break; |
721 | #endif | 721 | #endif |
722 | #ifdef CONFIG_ISDN_AUDIO | 722 | #ifdef CONFIG_ISDN_AUDIO |
723 | case ISDN_STAT_AUDIO: | 723 | case ISDN_STAT_AUDIO: |
724 | isdn_tty_stat_callback(i, c); | 724 | isdn_tty_stat_callback(i, c); |
725 | break; | 725 | break; |
726 | #endif | 726 | #endif |
727 | #ifdef CONFIG_ISDN_DIVERSION | 727 | #ifdef CONFIG_ISDN_DIVERSION |
728 | case ISDN_STAT_PROT: | 728 | case ISDN_STAT_PROT: |
729 | case ISDN_STAT_REDIR: | 729 | case ISDN_STAT_REDIR: |
730 | if (divert_if) | 730 | if (divert_if) |
731 | return(divert_if->stat_callback(c)); | 731 | return (divert_if->stat_callback(c)); |
732 | #endif /* CONFIG_ISDN_DIVERSION */ | 732 | #endif /* CONFIG_ISDN_DIVERSION */ |
733 | default: | 733 | default: |
734 | return -1; | 734 | return -1; |
735 | } | 735 | } |
736 | return 0; | 736 | return 0; |
737 | } | 737 | } |
@@ -755,17 +755,17 @@ isdn_getnum(char **p) | |||
755 | * isdn_readbchan() tries to get data from the read-queue. | 755 | * isdn_readbchan() tries to get data from the read-queue. |
756 | * It MUST be called with interrupts off. | 756 | * It MUST be called with interrupts off. |
757 | * | 757 | * |
758 | * 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 |
759 | * 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 |
760 | * 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 |
761 | * to be dangerous and for debugging purpose only). The inode semaphore | 761 | * to be dangerous and for debugging purpose only). The inode semaphore |
762 | * 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 |
763 | * we are sleeping, but access is not serialized against simultaneous read() | 763 | * we are sleeping, but access is not serialized against simultaneous read() |
764 | * from the corresponding ttyI device. Can other ugly events, like changes | 764 | * from the corresponding ttyI device. Can other ugly events, like changes |
765 | * of the mapping (di,ch)<->minor, happen during the sleep? --he | 765 | * of the mapping (di,ch)<->minor, happen during the sleep? --he |
766 | */ | 766 | */ |
767 | int | 767 | int |
768 | isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_queue_head_t *sleep) | 768 | isdn_readbchan(int di, int channel, u_char *buf, u_char *fp, int len, wait_queue_head_t *sleep) |
769 | { | 769 | { |
770 | int count; | 770 | int count; |
771 | int count_pull; | 771 | int count_pull; |
@@ -890,10 +890,10 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) | |||
890 | if (!dev->drv[di]) | 890 | if (!dev->drv[di]) |
891 | return 0; | 891 | return 0; |
892 | if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) | 892 | if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) |
893 | return 0; | 893 | return 0; |
894 | 894 | ||
895 | len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); | 895 | len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); |
896 | if(len == 0) | 896 | if (len == 0) |
897 | return len; | 897 | return len; |
898 | 898 | ||
899 | count = 0; | 899 | count = 0; |
@@ -912,7 +912,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) | |||
912 | count_pull = count_put = 0; | 912 | count_pull = count_put = 0; |
913 | while ((count_pull < skb->len) && (len > 0)) { | 913 | while ((count_pull < skb->len) && (len > 0)) { |
914 | /* push every character but the last to the tty buffer directly */ | 914 | /* push every character but the last to the tty buffer directly */ |
915 | if ( count_put ) | 915 | if (count_put) |
916 | tty_insert_flip_char(tty, last, TTY_NORMAL); | 916 | tty_insert_flip_char(tty, last, TTY_NORMAL); |
917 | len--; | 917 | len--; |
918 | if (dev->drv[di]->DLEflag & DLEmask) { | 918 | if (dev->drv[di]->DLEflag & DLEmask) { |
@@ -940,7 +940,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) | |||
940 | dflag = 0; | 940 | dflag = 0; |
941 | } | 941 | } |
942 | count_put = count_pull; | 942 | count_put = count_pull; |
943 | if(count_put > 1) | 943 | if (count_put > 1) |
944 | tty_insert_flip_string(tty, skb->data, count_put - 1); | 944 | tty_insert_flip_string(tty, skb->data, count_put - 1); |
945 | last = skb->data[count_put - 1]; | 945 | last = skb->data[count_put - 1]; |
946 | len -= count_put; | 946 | len -= count_put; |
@@ -952,7 +952,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) | |||
952 | /* We got all the data in this buff. | 952 | /* We got all the data in this buff. |
953 | * Now we can dequeue it. | 953 | * Now we can dequeue it. |
954 | */ | 954 | */ |
955 | if(cisco_hack) | 955 | if (cisco_hack) |
956 | tty_insert_flip_char(tty, last, 0xFF); | 956 | tty_insert_flip_char(tty, last, 0xFF); |
957 | else | 957 | else |
958 | tty_insert_flip_char(tty, last, TTY_NORMAL); | 958 | tty_insert_flip_char(tty, last, TTY_NORMAL); |
@@ -1057,7 +1057,7 @@ isdn_info_update(void) | |||
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | static ssize_t | 1059 | static ssize_t |
1060 | isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) | 1060 | isdn_read(struct file *file, char __user *buf, size_t count, loff_t *off) |
1061 | { | 1061 | { |
1062 | uint minor = iminor(file->f_path.dentry->d_inode); | 1062 | uint minor = iminor(file->f_path.dentry->d_inode); |
1063 | int len = 0; | 1063 | int len = 0; |
@@ -1112,7 +1112,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) | |||
1112 | len = isdn_readbchan(drvidx, chidx, p, NULL, count, | 1112 | len = isdn_readbchan(drvidx, chidx, p, NULL, count, |
1113 | &dev->drv[drvidx]->rcv_waitq[chidx]); | 1113 | &dev->drv[drvidx]->rcv_waitq[chidx]); |
1114 | *off += len; | 1114 | *off += len; |
1115 | if (copy_to_user(buf,p,len)) | 1115 | if (copy_to_user(buf, p, len)) |
1116 | len = -EFAULT; | 1116 | len = -EFAULT; |
1117 | kfree(p); | 1117 | kfree(p); |
1118 | retval = len; | 1118 | retval = len; |
@@ -1135,7 +1135,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) | |||
1135 | if (count > dev->drv[drvidx]->stavail) | 1135 | if (count > dev->drv[drvidx]->stavail) |
1136 | count = dev->drv[drvidx]->stavail; | 1136 | count = dev->drv[drvidx]->stavail; |
1137 | len = dev->drv[drvidx]->interface->readstat(buf, count, | 1137 | len = dev->drv[drvidx]->interface->readstat(buf, count, |
1138 | drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL)); | 1138 | drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL)); |
1139 | if (len < 0) { | 1139 | if (len < 0) { |
1140 | retval = len; | 1140 | retval = len; |
1141 | goto out; | 1141 | goto out; |
@@ -1158,13 +1158,13 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) | |||
1158 | } | 1158 | } |
1159 | #endif | 1159 | #endif |
1160 | retval = -ENODEV; | 1160 | retval = -ENODEV; |
1161 | out: | 1161 | out: |
1162 | mutex_unlock(&isdn_mutex); | 1162 | mutex_unlock(&isdn_mutex); |
1163 | return retval; | 1163 | return retval; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | static ssize_t | 1166 | static ssize_t |
1167 | isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off) | 1167 | isdn_write(struct file *file, const char __user *buf, size_t count, loff_t *off) |
1168 | { | 1168 | { |
1169 | uint minor = iminor(file->f_path.dentry->d_inode); | 1169 | uint minor = iminor(file->f_path.dentry->d_inode); |
1170 | int drvidx; | 1170 | int drvidx; |
@@ -1204,11 +1204,11 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off | |||
1204 | * | 1204 | * |
1205 | if (!(dev->drv[drvidx]->flags & DRV_FLAG_RUNNING)) | 1205 | if (!(dev->drv[drvidx]->flags & DRV_FLAG_RUNNING)) |
1206 | return -ENODEV; | 1206 | return -ENODEV; |
1207 | */ | 1207 | */ |
1208 | if (dev->drv[drvidx]->interface->writecmd) | 1208 | if (dev->drv[drvidx]->interface->writecmd) |
1209 | retval = dev->drv[drvidx]->interface-> | 1209 | retval = dev->drv[drvidx]->interface-> |
1210 | writecmd(buf, count, drvidx, | 1210 | writecmd(buf, count, drvidx, |
1211 | isdn_minor2chan(minor - ISDN_MINOR_CTRL)); | 1211 | isdn_minor2chan(minor - ISDN_MINOR_CTRL)); |
1212 | else | 1212 | else |
1213 | retval = count; | 1213 | retval = count; |
1214 | goto out; | 1214 | goto out; |
@@ -1220,13 +1220,13 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off | |||
1220 | } | 1220 | } |
1221 | #endif | 1221 | #endif |
1222 | retval = -ENODEV; | 1222 | retval = -ENODEV; |
1223 | out: | 1223 | out: |
1224 | mutex_unlock(&isdn_mutex); | 1224 | mutex_unlock(&isdn_mutex); |
1225 | return retval; | 1225 | return retval; |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | static unsigned int | 1228 | static unsigned int |
1229 | isdn_poll(struct file *file, poll_table * wait) | 1229 | isdn_poll(struct file *file, poll_table *wait) |
1230 | { | 1230 | { |
1231 | unsigned int mask = 0; | 1231 | unsigned int mask = 0; |
1232 | unsigned int minor = iminor(file->f_path.dentry->d_inode); | 1232 | unsigned int minor = iminor(file->f_path.dentry->d_inode); |
@@ -1261,7 +1261,7 @@ isdn_poll(struct file *file, poll_table * wait) | |||
1261 | } | 1261 | } |
1262 | #endif | 1262 | #endif |
1263 | mask = POLLERR; | 1263 | mask = POLLERR; |
1264 | out: | 1264 | out: |
1265 | mutex_unlock(&isdn_mutex); | 1265 | mutex_unlock(&isdn_mutex); |
1266 | return mask; | 1266 | return mask; |
1267 | } | 1267 | } |
@@ -1294,38 +1294,38 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg) | |||
1294 | 1294 | ||
1295 | if (minor == ISDN_MINOR_STATUS) { | 1295 | if (minor == ISDN_MINOR_STATUS) { |
1296 | switch (cmd) { | 1296 | switch (cmd) { |
1297 | case IIOCGETDVR: | 1297 | case IIOCGETDVR: |
1298 | return (TTY_DV + | 1298 | return (TTY_DV + |
1299 | (NET_DV << 8) + | 1299 | (NET_DV << 8) + |
1300 | (INF_DV << 16)); | 1300 | (INF_DV << 16)); |
1301 | case IIOCGETCPS: | 1301 | case IIOCGETCPS: |
1302 | if (arg) { | 1302 | if (arg) { |
1303 | ulong __user *p = argp; | 1303 | ulong __user *p = argp; |
1304 | int i; | 1304 | int i; |
1305 | if (!access_ok(VERIFY_WRITE, p, | 1305 | if (!access_ok(VERIFY_WRITE, p, |
1306 | sizeof(ulong) * ISDN_MAX_CHANNELS * 2)) | 1306 | sizeof(ulong) * ISDN_MAX_CHANNELS * 2)) |
1307 | return -EFAULT; | 1307 | return -EFAULT; |
1308 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 1308 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
1309 | put_user(dev->ibytes[i], p++); | 1309 | put_user(dev->ibytes[i], p++); |
1310 | put_user(dev->obytes[i], p++); | 1310 | put_user(dev->obytes[i], p++); |
1311 | } | 1311 | } |
1312 | return 0; | 1312 | return 0; |
1313 | } else | 1313 | } else |
1314 | return -EINVAL; | 1314 | return -EINVAL; |
1315 | break; | 1315 | break; |
1316 | #ifdef CONFIG_NETDEVICES | 1316 | #ifdef CONFIG_NETDEVICES |
1317 | case IIOCNETGPN: | 1317 | case IIOCNETGPN: |
1318 | /* Get peer phone number of a connected | 1318 | /* Get peer phone number of a connected |
1319 | * isdn network interface */ | 1319 | * isdn network interface */ |
1320 | if (arg) { | 1320 | if (arg) { |
1321 | if (copy_from_user(&phone, argp, sizeof(phone))) | 1321 | if (copy_from_user(&phone, argp, sizeof(phone))) |
1322 | return -EFAULT; | 1322 | return -EFAULT; |
1323 | return isdn_net_getpeer(&phone, argp); | 1323 | return isdn_net_getpeer(&phone, argp); |
1324 | } else | 1324 | } else |
1325 | return -EINVAL; | ||
1326 | #endif | ||
1327 | default: | ||
1328 | return -EINVAL; | 1325 | return -EINVAL; |
1326 | #endif | ||
1327 | default: | ||
1328 | return -EINVAL; | ||
1329 | } | 1329 | } |
1330 | } | 1330 | } |
1331 | if (!dev->drivers) | 1331 | if (!dev->drivers) |
@@ -1347,360 +1347,360 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg) | |||
1347 | * are serialized by means of a semaphore. | 1347 | * are serialized by means of a semaphore. |
1348 | */ | 1348 | */ |
1349 | switch (cmd) { | 1349 | switch (cmd) { |
1350 | case IIOCNETDWRSET: | 1350 | case IIOCNETDWRSET: |
1351 | printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n"); | 1351 | printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n"); |
1352 | return(-EINVAL); | 1352 | return (-EINVAL); |
1353 | case IIOCNETLCR: | 1353 | case IIOCNETLCR: |
1354 | printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); | 1354 | printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); |
1355 | return -ENODEV; | 1355 | return -ENODEV; |
1356 | #ifdef CONFIG_NETDEVICES | 1356 | #ifdef CONFIG_NETDEVICES |
1357 | case IIOCNETAIF: | 1357 | case IIOCNETAIF: |
1358 | /* Add a network-interface */ | 1358 | /* Add a network-interface */ |
1359 | if (arg) { | 1359 | if (arg) { |
1360 | if (copy_from_user(name, argp, sizeof(name))) | 1360 | if (copy_from_user(name, argp, sizeof(name))) |
1361 | return -EFAULT; | 1361 | return -EFAULT; |
1362 | s = name; | 1362 | s = name; |
1363 | } else { | ||
1364 | s = NULL; | ||
1365 | } | ||
1366 | ret = mutex_lock_interruptible(&dev->mtx); | ||
1367 | if (ret) return ret; | ||
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; | ||
1376 | mutex_unlock(&dev->mtx); | ||
1377 | return ret; | ||
1378 | case IIOCNETASL: | ||
1379 | /* Add a slave to a network-interface */ | ||
1380 | if (arg) { | ||
1381 | if (copy_from_user(bname, argp, sizeof(bname) - 1)) | ||
1382 | return -EFAULT; | ||
1383 | } else | ||
1384 | return -EINVAL; | ||
1385 | ret = mutex_lock_interruptible(&dev->mtx); | ||
1386 | if (ret) return ret; | ||
1387 | if ((s = isdn_net_newslave(bname))) { | ||
1388 | if (copy_to_user(argp, s, strlen(s) + 1)) { | ||
1389 | ret = -EFAULT; | ||
1363 | } else { | 1390 | } else { |
1364 | s = NULL; | 1391 | ret = 0; |
1365 | } | 1392 | } |
1393 | } else | ||
1394 | ret = -ENODEV; | ||
1395 | mutex_unlock(&dev->mtx); | ||
1396 | return ret; | ||
1397 | case IIOCNETDIF: | ||
1398 | /* Delete a network-interface */ | ||
1399 | if (arg) { | ||
1400 | if (copy_from_user(name, argp, sizeof(name))) | ||
1401 | return -EFAULT; | ||
1366 | ret = mutex_lock_interruptible(&dev->mtx); | 1402 | ret = mutex_lock_interruptible(&dev->mtx); |
1367 | if( ret ) return ret; | 1403 | if (ret) return ret; |
1368 | if ((s = isdn_net_new(s, NULL))) { | 1404 | ret = isdn_net_rm(name); |
1369 | if (copy_to_user(argp, s, strlen(s) + 1)){ | ||
1370 | ret = -EFAULT; | ||
1371 | } else { | ||
1372 | ret = 0; | ||
1373 | } | ||
1374 | } else | ||
1375 | ret = -ENODEV; | ||
1376 | mutex_unlock(&dev->mtx); | 1405 | mutex_unlock(&dev->mtx); |
1377 | return ret; | 1406 | return ret; |
1378 | case IIOCNETASL: | 1407 | } else |
1379 | /* Add a slave to a network-interface */ | 1408 | return -EINVAL; |
1380 | if (arg) { | 1409 | case IIOCNETSCF: |
1381 | if (copy_from_user(bname, argp, sizeof(bname) - 1)) | 1410 | /* Set configurable parameters of a network-interface */ |
1411 | if (arg) { | ||
1412 | if (copy_from_user(&cfg, argp, sizeof(cfg))) | ||
1413 | return -EFAULT; | ||
1414 | return isdn_net_setcfg(&cfg); | ||
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))) | ||
1421 | return -EFAULT; | ||
1422 | if (!(ret = isdn_net_getcfg(&cfg))) { | ||
1423 | if (copy_to_user(argp, &cfg, sizeof(cfg))) | ||
1382 | return -EFAULT; | 1424 | return -EFAULT; |
1383 | } else | 1425 | } |
1384 | return -EINVAL; | 1426 | return ret; |
1427 | } else | ||
1428 | return -EINVAL; | ||
1429 | case IIOCNETANM: | ||
1430 | /* Add a phone-number to a network-interface */ | ||
1431 | if (arg) { | ||
1432 | if (copy_from_user(&phone, argp, sizeof(phone))) | ||
1433 | return -EFAULT; | ||
1385 | ret = mutex_lock_interruptible(&dev->mtx); | 1434 | ret = mutex_lock_interruptible(&dev->mtx); |
1386 | if( ret ) return ret; | 1435 | if (ret) return ret; |
1387 | if ((s = isdn_net_newslave(bname))) { | 1436 | ret = isdn_net_addphone(&phone); |
1388 | if (copy_to_user(argp, s, strlen(s) + 1)){ | ||
1389 | ret = -EFAULT; | ||
1390 | } else { | ||
1391 | ret = 0; | ||
1392 | } | ||
1393 | } else | ||
1394 | ret = -ENODEV; | ||
1395 | mutex_unlock(&dev->mtx); | 1437 | mutex_unlock(&dev->mtx); |
1396 | return ret; | 1438 | return ret; |
1397 | case IIOCNETDIF: | 1439 | } else |
1398 | /* Delete a network-interface */ | 1440 | return -EINVAL; |
1399 | if (arg) { | 1441 | case IIOCNETGNM: |
1400 | if (copy_from_user(name, argp, sizeof(name))) | 1442 | /* Get list of phone-numbers of a network-interface */ |
1401 | return -EFAULT; | 1443 | if (arg) { |
1402 | ret = mutex_lock_interruptible(&dev->mtx); | 1444 | if (copy_from_user(&phone, argp, sizeof(phone))) |
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))) | ||
1413 | return -EFAULT; | ||
1414 | return isdn_net_setcfg(&cfg); | ||
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))) | ||
1421 | return -EFAULT; | ||
1422 | if (!(ret = isdn_net_getcfg(&cfg))) { | ||
1423 | if (copy_to_user(argp, &cfg, sizeof(cfg))) | ||
1424 | return -EFAULT; | ||
1425 | } | ||
1426 | return ret; | ||
1427 | } else | ||
1428 | return -EINVAL; | ||
1429 | case IIOCNETANM: | ||
1430 | /* Add a phone-number to a network-interface */ | ||
1431 | if (arg) { | ||
1432 | if (copy_from_user(&phone, argp, sizeof(phone))) | ||
1433 | return -EFAULT; | ||
1434 | ret = mutex_lock_interruptible(&dev->mtx); | ||
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))) | ||
1469 | return -EFAULT; | ||
1470 | return isdn_net_force_dial(name); | ||
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; | 1445 | return -EFAULT; |
1479 | return isdn_ppp_dial_slave(name); | 1446 | ret = mutex_lock_interruptible(&dev->mtx); |
1480 | case IIOCNETDLN: | 1447 | if (ret) return ret; |
1481 | if (!arg) | 1448 | ret = isdn_net_getphones(&phone, argp); |
1482 | return -EINVAL; | 1449 | mutex_unlock(&dev->mtx); |
1483 | if (copy_from_user(name, argp, sizeof(name))) | 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))) | ||
1484 | return -EFAULT; | 1457 | return -EFAULT; |
1485 | return isdn_ppp_hangup_slave(name); | 1458 | ret = mutex_lock_interruptible(&dev->mtx); |
1486 | #endif | 1459 | if (ret) return ret; |
1487 | case IIOCNETHUP: | 1460 | ret = isdn_net_delphone(&phone); |
1488 | /* Force hangup of a network-interface */ | 1461 | mutex_unlock(&dev->mtx); |
1489 | if (!arg) | 1462 | return ret; |
1490 | return -EINVAL; | 1463 | } else |
1464 | return -EINVAL; | ||
1465 | case IIOCNETDIL: | ||
1466 | /* Force dialing of a network-interface */ | ||
1467 | if (arg) { | ||
1491 | if (copy_from_user(name, argp, sizeof(name))) | 1468 | if (copy_from_user(name, argp, sizeof(name))) |
1492 | return -EFAULT; | 1469 | return -EFAULT; |
1493 | return isdn_net_force_hangup(name); | 1470 | return isdn_net_force_dial(name); |
1494 | break; | 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 */ | 1495 | #endif /* CONFIG_NETDEVICES */ |
1496 | case IIOCSETVER: | 1496 | case IIOCSETVER: |
1497 | dev->net_verbose = arg; | 1497 | dev->net_verbose = arg; |
1498 | printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose); | 1498 | printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose); |
1499 | return 0; | 1499 | return 0; |
1500 | case IIOCSETGST: | 1500 | case IIOCSETGST: |
1501 | if (arg) | 1501 | if (arg) |
1502 | dev->global_flags |= ISDN_GLOBAL_STOPPED; | 1502 | dev->global_flags |= ISDN_GLOBAL_STOPPED; |
1503 | else | 1503 | else |
1504 | dev->global_flags &= ~ISDN_GLOBAL_STOPPED; | 1504 | dev->global_flags &= ~ISDN_GLOBAL_STOPPED; |
1505 | printk(KERN_INFO "isdn: Global Mode %s\n", | 1505 | printk(KERN_INFO "isdn: Global Mode %s\n", |
1506 | (dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running"); | 1506 | (dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running"); |
1507 | return 0; | 1507 | return 0; |
1508 | case IIOCSETBRJ: | 1508 | case IIOCSETBRJ: |
1509 | drvidx = -1; | 1509 | drvidx = -1; |
1510 | if (arg) { | 1510 | if (arg) { |
1511 | int i; | 1511 | int i; |
1512 | char *p; | 1512 | char *p; |
1513 | if (copy_from_user(&iocts, argp, | 1513 | if (copy_from_user(&iocts, argp, |
1514 | sizeof(isdn_ioctl_struct))) | 1514 | sizeof(isdn_ioctl_struct))) |
1515 | return -EFAULT; | 1515 | return -EFAULT; |
1516 | iocts.drvid[sizeof(iocts.drvid)-1] = 0; | 1516 | iocts.drvid[sizeof(iocts.drvid) - 1] = 0; |
1517 | if (strlen(iocts.drvid)) { | 1517 | if (strlen(iocts.drvid)) { |
1518 | if ((p = strchr(iocts.drvid, ','))) | 1518 | if ((p = strchr(iocts.drvid, ','))) |
1519 | *p = 0; | 1519 | *p = 0; |
1520 | drvidx = -1; | 1520 | drvidx = -1; |
1521 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) | 1521 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) |
1522 | if (!(strcmp(dev->drvid[i], iocts.drvid))) { | 1522 | if (!(strcmp(dev->drvid[i], iocts.drvid))) { |
1523 | drvidx = i; | 1523 | drvidx = i; |
1524 | break; | 1524 | break; |
1525 | } | 1525 | } |
1526 | } | ||
1527 | } | 1526 | } |
1528 | if (drvidx == -1) | 1527 | } |
1529 | return -ENODEV; | 1528 | if (drvidx == -1) |
1530 | if (iocts.arg) | 1529 | return -ENODEV; |
1531 | dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS; | 1530 | if (iocts.arg) |
1532 | else | 1531 | dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS; |
1533 | dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS; | 1532 | else |
1534 | return 0; | 1533 | dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS; |
1535 | case IIOCSIGPRF: | 1534 | return 0; |
1536 | dev->profd = current; | 1535 | case IIOCSIGPRF: |
1537 | return 0; | 1536 | dev->profd = current; |
1538 | break; | 1537 | return 0; |
1539 | case IIOCGETPRF: | 1538 | break; |
1540 | /* Get all Modem-Profiles */ | 1539 | case IIOCGETPRF: |
1541 | if (arg) { | 1540 | /* Get all Modem-Profiles */ |
1542 | char __user *p = argp; | 1541 | if (arg) { |
1543 | int i; | 1542 | char __user *p = argp; |
1544 | 1543 | int i; | |
1545 | if (!access_ok(VERIFY_WRITE, argp, | 1544 | |
1546 | (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) | 1545 | if (!access_ok(VERIFY_WRITE, argp, |
1547 | * ISDN_MAX_CHANNELS)) | 1546 | (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) |
1547 | * ISDN_MAX_CHANNELS)) | ||
1548 | return -EFAULT; | ||
1549 | |||
1550 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | ||
1551 | if (copy_to_user(p, dev->mdm.info[i].emu.profile, | ||
1552 | ISDN_MODEM_NUMREG)) | ||
1553 | return -EFAULT; | ||
1554 | p += ISDN_MODEM_NUMREG; | ||
1555 | if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN)) | ||
1548 | return -EFAULT; | 1556 | return -EFAULT; |
1557 | p += ISDN_MSNLEN; | ||
1558 | if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) | ||
1559 | return -EFAULT; | ||
1560 | p += ISDN_LMSNLEN; | ||
1561 | } | ||
1562 | return (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) * ISDN_MAX_CHANNELS; | ||
1563 | } else | ||
1564 | return -EINVAL; | ||
1565 | break; | ||
1566 | case IIOCSETPRF: | ||
1567 | /* Set all Modem-Profiles */ | ||
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; | ||
1549 | 1576 | ||
1550 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 1577 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
1551 | if (copy_to_user(p, dev->mdm.info[i].emu.profile, | 1578 | if (copy_from_user(dev->mdm.info[i].emu.profile, p, |
1552 | ISDN_MODEM_NUMREG)) | 1579 | ISDN_MODEM_NUMREG)) |
1553 | return -EFAULT; | 1580 | return -EFAULT; |
1554 | p += ISDN_MODEM_NUMREG; | 1581 | p += ISDN_MODEM_NUMREG; |
1555 | if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN)) | 1582 | if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) |
1556 | return -EFAULT; | ||
1557 | p += ISDN_MSNLEN; | ||
1558 | if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) | ||
1559 | return -EFAULT; | ||
1560 | p += ISDN_LMSNLEN; | ||
1561 | } | ||
1562 | return (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) * ISDN_MAX_CHANNELS; | ||
1563 | } else | ||
1564 | return -EINVAL; | ||
1565 | break; | ||
1566 | case IIOCSETPRF: | ||
1567 | /* Set all Modem-Profiles */ | ||
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; | 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) { | ||
1576 | 1597 | ||
1577 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 1598 | if (copy_from_user(&iocts, argp, |
1578 | if (copy_from_user(dev->mdm.info[i].emu.profile, p, | 1599 | sizeof(isdn_ioctl_struct))) |
1579 | ISDN_MODEM_NUMREG)) | 1600 | return -EFAULT; |
1580 | return -EFAULT; | 1601 | iocts.drvid[sizeof(iocts.drvid) - 1] = 0; |
1581 | p += ISDN_MODEM_NUMREG; | 1602 | if (strlen(iocts.drvid)) { |
1582 | if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) | 1603 | drvidx = -1; |
1583 | return -EFAULT; | 1604 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) |
1584 | p += ISDN_LMSNLEN; | 1605 | if (!(strcmp(dev->drvid[i], iocts.drvid))) { |
1585 | if (copy_from_user(dev->mdm.info[i].emu.pmsn, p, ISDN_MSNLEN)) | 1606 | drvidx = i; |
1586 | return -EFAULT; | 1607 | break; |
1587 | p += ISDN_MSNLEN; | 1608 | } |
1588 | } | ||
1589 | return 0; | ||
1590 | } else | 1609 | } else |
1591 | return -EINVAL; | 1610 | drvidx = 0; |
1592 | break; | 1611 | if (drvidx == -1) |
1593 | case IIOCSETMAP: | 1612 | return -ENODEV; |
1594 | case IIOCGETMAP: | 1613 | if (cmd == IIOCSETMAP) { |
1595 | /* Set/Get MSN->EAZ-Mapping for a driver */ | 1614 | int loop = 1; |
1596 | if (arg) { | ||
1597 | 1615 | ||
1598 | if (copy_from_user(&iocts, argp, | 1616 | p = (char __user *) iocts.arg; |
1599 | sizeof(isdn_ioctl_struct))) | 1617 | i = 0; |
1600 | return -EFAULT; | 1618 | while (loop) { |
1601 | iocts.drvid[sizeof(iocts.drvid)-1] = 0; | 1619 | int j = 0; |
1602 | if (strlen(iocts.drvid)) { | 1620 | |
1603 | drvidx = -1; | 1621 | while (1) { |
1604 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) | 1622 | if (!access_ok(VERIFY_READ, p, 1)) |
1605 | if (!(strcmp(dev->drvid[i], iocts.drvid))) { | 1623 | return -EFAULT; |
1606 | drvidx = i; | 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; | ||
1607 | break; | 1633 | break; |
1634 | default: | ||
1635 | j++; | ||
1608 | } | 1636 | } |
1609 | } else | 1637 | if (j >= ISDN_MSNLEN) |
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) | ||
1641 | break; | 1638 | break; |
1642 | } | 1639 | } |
1643 | } else { | 1640 | if (++i > 9) |
1644 | p = (char __user *) iocts.arg; | 1641 | break; |
1645 | for (i = 0; i < 10; i++) { | ||
1646 | snprintf(bname, sizeof(bname), "%s%s", | ||
1647 | strlen(dev->drv[drvidx]->msn2eaz[i]) ? | ||
1648 | dev->drv[drvidx]->msn2eaz[i] : "_", | ||
1649 | (i < 9) ? "," : "\0"); | ||
1650 | if (copy_to_user(p, bname, strlen(bname) + 1)) | ||
1651 | return -EFAULT; | ||
1652 | p += strlen(bname); | ||
1653 | } | ||
1654 | } | 1642 | } |
1655 | return 0; | 1643 | } else { |
1656 | } else | 1644 | p = (char __user *) iocts.arg; |
1657 | return -EINVAL; | 1645 | for (i = 0; i < 10; i++) { |
1658 | case IIOCDBGVAR: | 1646 | snprintf(bname, sizeof(bname), "%s%s", |
1659 | if (arg) { | 1647 | strlen(dev->drv[drvidx]->msn2eaz[i]) ? |
1660 | if (copy_to_user(argp, &dev, sizeof(ulong))) | 1648 | dev->drv[drvidx]->msn2eaz[i] : "_", |
1661 | return -EFAULT; | 1649 | (i < 9) ? "," : "\0"); |
1662 | return 0; | 1650 | if (copy_to_user(p, bname, strlen(bname) + 1)) |
1663 | } else | 1651 | return -EFAULT; |
1664 | return -EINVAL; | 1652 | p += strlen(bname); |
1665 | break; | 1653 | } |
1666 | default: | 1654 | } |
1667 | if ((cmd & IIOCDRVCTL) == IIOCDRVCTL) | 1655 | return 0; |
1668 | cmd = ((cmd >> _IOC_NRSHIFT) & _IOC_NRMASK) & ISDN_DRVIOCTL_MASK; | 1656 | } else |
1669 | else | 1657 | return -EINVAL; |
1670 | return -EINVAL; | 1658 | case IIOCDBGVAR: |
1671 | if (arg) { | 1659 | if (arg) { |
1672 | int i; | 1660 | if (copy_to_user(argp, &dev, sizeof(ulong))) |
1673 | char *p; | 1661 | return -EFAULT; |
1674 | if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct))) | 1662 | return 0; |
1675 | return -EFAULT; | 1663 | } else |
1676 | iocts.drvid[sizeof(iocts.drvid)-1] = 0; | 1664 | return -EINVAL; |
1677 | if (strlen(iocts.drvid)) { | 1665 | break; |
1678 | if ((p = strchr(iocts.drvid, ','))) | 1666 | default: |
1679 | *p = 0; | 1667 | if ((cmd & IIOCDRVCTL) == IIOCDRVCTL) |
1680 | drvidx = -1; | 1668 | cmd = ((cmd >> _IOC_NRSHIFT) & _IOC_NRMASK) & ISDN_DRVIOCTL_MASK; |
1681 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) | 1669 | else |
1682 | if (!(strcmp(dev->drvid[i], iocts.drvid))) { | 1670 | return -EINVAL; |
1683 | drvidx = i; | 1671 | if (arg) { |
1684 | break; | 1672 | int i; |
1685 | } | 1673 | char *p; |
1686 | } else | 1674 | if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct))) |
1687 | drvidx = 0; | 1675 | return -EFAULT; |
1688 | if (drvidx == -1) | 1676 | iocts.drvid[sizeof(iocts.drvid) - 1] = 0; |
1689 | return -ENODEV; | 1677 | if (strlen(iocts.drvid)) { |
1690 | if (!access_ok(VERIFY_WRITE, argp, | 1678 | if ((p = strchr(iocts.drvid, ','))) |
1691 | sizeof(isdn_ioctl_struct))) | 1679 | *p = 0; |
1692 | return -EFAULT; | 1680 | drvidx = -1; |
1693 | c.driver = drvidx; | 1681 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) |
1694 | c.command = ISDN_CMD_IOCTL; | 1682 | if (!(strcmp(dev->drvid[i], iocts.drvid))) { |
1695 | c.arg = cmd; | 1683 | drvidx = i; |
1696 | memcpy(c.parm.num, &iocts.arg, sizeof(ulong)); | 1684 | break; |
1697 | ret = isdn_command(&c); | 1685 | } |
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 | 1686 | } else |
1703 | return -EINVAL; | 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; | ||
1704 | } | 1704 | } |
1705 | } | 1705 | } |
1706 | #ifdef CONFIG_ISDN_PPP | 1706 | #ifdef CONFIG_ISDN_PPP |
@@ -1788,7 +1788,7 @@ isdn_open(struct inode *ino, struct file *filep) | |||
1788 | goto out; | 1788 | goto out; |
1789 | } | 1789 | } |
1790 | #endif | 1790 | #endif |
1791 | out: | 1791 | out: |
1792 | nonseekable_open(ino, filep); | 1792 | nonseekable_open(ino, filep); |
1793 | mutex_unlock(&isdn_mutex); | 1793 | mutex_unlock(&isdn_mutex); |
1794 | return retval; | 1794 | return retval; |
@@ -1832,7 +1832,7 @@ isdn_close(struct inode *ino, struct file *filep) | |||
1832 | isdn_ppp_release(minor - ISDN_MINOR_PPP, filep); | 1832 | isdn_ppp_release(minor - ISDN_MINOR_PPP, filep); |
1833 | #endif | 1833 | #endif |
1834 | 1834 | ||
1835 | out: | 1835 | out: |
1836 | mutex_unlock(&isdn_mutex); | 1836 | mutex_unlock(&isdn_mutex); |
1837 | return 0; | 1837 | return 0; |
1838 | } | 1838 | } |
@@ -1868,14 +1868,14 @@ isdn_map_eaz2msn(char *msn, int di) | |||
1868 | * Find an unused ISDN-channel, whose feature-flags match the | 1868 | * Find an unused ISDN-channel, whose feature-flags match the |
1869 | * given L2- and L3-protocols. | 1869 | * given L2- and L3-protocols. |
1870 | */ | 1870 | */ |
1871 | #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)) |
1872 | 1872 | ||
1873 | /* | 1873 | /* |
1874 | * This function must be called with holding the dev->lock. | 1874 | * This function must be called with holding the dev->lock. |
1875 | */ | 1875 | */ |
1876 | int | 1876 | int |
1877 | isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev | 1877 | isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev |
1878 | ,int pre_chan, char *msn) | 1878 | , int pre_chan, char *msn) |
1879 | { | 1879 | { |
1880 | int i; | 1880 | int i; |
1881 | ulong features; | 1881 | ulong features; |
@@ -1883,7 +1883,7 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev | |||
1883 | 1883 | ||
1884 | features = ((1 << l2_proto) | (0x10000 << l3_proto)); | 1884 | features = ((1 << l2_proto) | (0x10000 << l3_proto)); |
1885 | vfeatures = (((1 << l2_proto) | (0x10000 << l3_proto)) & | 1885 | vfeatures = (((1 << l2_proto) | (0x10000 << l3_proto)) & |
1886 | ~(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)); |
1887 | /* If Layer-2 protocol is V.110, accept drivers with | 1887 | /* If Layer-2 protocol is V.110, accept drivers with |
1888 | * transparent feature even if these don't support V.110 | 1888 | * transparent feature even if these don't support V.110 |
1889 | * because we can emulate this in linklevel. | 1889 | * because we can emulate this in linklevel. |
@@ -1893,12 +1893,12 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev | |||
1893 | (dev->drvmap[i] != -1)) { | 1893 | (dev->drvmap[i] != -1)) { |
1894 | int d = dev->drvmap[i]; | 1894 | int d = dev->drvmap[i]; |
1895 | if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && | 1895 | if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && |
1896 | ((pre_dev != d) || (pre_chan != dev->chanmap[i]))) | 1896 | ((pre_dev != d) || (pre_chan != dev->chanmap[i]))) |
1897 | continue; | 1897 | continue; |
1898 | if (!strcmp(isdn_map_eaz2msn(msn, d), "-")) | 1898 | if (!strcmp(isdn_map_eaz2msn(msn, d), "-")) |
1899 | continue; | 1899 | continue; |
1900 | if (dev->usage[i] & ISDN_USAGE_DISABLED) | 1900 | if (dev->usage[i] & ISDN_USAGE_DISABLED) |
1901 | continue; /* usage not allowed */ | 1901 | continue; /* usage not allowed */ |
1902 | if (dev->drv[d]->flags & DRV_FLAG_RUNNING) { | 1902 | if (dev->drv[d]->flags & DRV_FLAG_RUNNING) { |
1903 | if (((dev->drv[d]->interface->features & features) == features) || | 1903 | if (((dev->drv[d]->interface->features & features) == features) || |
1904 | (((dev->drv[d]->interface->features & vfeatures) == vfeatures) && | 1904 | (((dev->drv[d]->interface->features & vfeatures) == vfeatures) && |
@@ -1932,7 +1932,7 @@ isdn_free_channel(int di, int ch, int usage) | |||
1932 | 1932 | ||
1933 | if ((di < 0) || (ch < 0)) { | 1933 | if ((di < 0) || (ch < 0)) { |
1934 | 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", |
1935 | __func__, di, ch); | 1935 | __func__, di, ch); |
1936 | return; | 1936 | return; |
1937 | } | 1937 | } |
1938 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) | 1938 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) |
@@ -1976,7 +1976,7 @@ isdn_unexclusive_channel(int di, int ch) | |||
1976 | * writebuf replacement for SKB_ABLE drivers | 1976 | * writebuf replacement for SKB_ABLE drivers |
1977 | */ | 1977 | */ |
1978 | static int | 1978 | static int |
1979 | isdn_writebuf_stub(int drvidx, int chan, const u_char __user * buf, int len) | 1979 | isdn_writebuf_stub(int drvidx, int chan, const u_char __user *buf, int len) |
1980 | { | 1980 | { |
1981 | int ret; | 1981 | int ret; |
1982 | int hl = dev->drv[drvidx]->interface->hl_hdrlen; | 1982 | int hl = dev->drv[drvidx]->interface->hl_hdrlen; |
@@ -2026,8 +2026,8 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb) | |||
2026 | } else { | 2026 | } else { |
2027 | int hl = dev->drv[drvidx]->interface->hl_hdrlen; | 2027 | int hl = dev->drv[drvidx]->interface->hl_hdrlen; |
2028 | 2028 | ||
2029 | if( skb_headroom(skb) < hl ){ | 2029 | if (skb_headroom(skb) < hl) { |
2030 | /* | 2030 | /* |
2031 | * This should only occur when new HL driver with | 2031 | * This should only occur when new HL driver with |
2032 | * increased hl_hdrlen was loaded after netdevice | 2032 | * increased hl_hdrlen was loaded after netdevice |
2033 | * was created and connected to the new driver. | 2033 | * was created and connected to the new driver. |
@@ -2035,13 +2035,13 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb) | |||
2035 | * The V.110 branch (re-allocates on its own) does | 2035 | * The V.110 branch (re-allocates on its own) does |
2036 | * not need this | 2036 | * not need this |
2037 | */ | 2037 | */ |
2038 | struct sk_buff * skb_tmp; | 2038 | struct sk_buff *skb_tmp; |
2039 | 2039 | ||
2040 | skb_tmp = skb_realloc_headroom(skb, hl); | 2040 | skb_tmp = skb_realloc_headroom(skb, hl); |
2041 | 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"); |
2042 | if (!skb_tmp) return -ENOMEM; /* 0 better? */ | 2042 | if (!skb_tmp) return -ENOMEM; /* 0 better? */ |
2043 | 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); |
2044 | if( ret > 0 ){ | 2044 | if (ret > 0) { |
2045 | dev_kfree_skb(skb); | 2045 | dev_kfree_skb(skb); |
2046 | } else { | 2046 | } else { |
2047 | dev_kfree_skb(skb_tmp); | 2047 | dev_kfree_skb(skb_tmp); |
@@ -2059,7 +2059,7 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb) | |||
2059 | /* For V.110 return unencoded data length */ | 2059 | /* For V.110 return unencoded data length */ |
2060 | ret = v110_ret; | 2060 | ret = v110_ret; |
2061 | /* if the complete frame was send we free the skb; | 2061 | /* if the complete frame was send we free the skb; |
2062 | if not upper function will requeue the skb */ | 2062 | if not upper function will requeue the skb */ |
2063 | if (ret == skb->len) | 2063 | if (ret == skb->len) |
2064 | dev_kfree_skb(skb); | 2064 | dev_kfree_skb(skb); |
2065 | } | 2065 | } |
@@ -2077,7 +2077,7 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) | |||
2077 | init_waitqueue_head(&d->st_waitq); | 2077 | init_waitqueue_head(&d->st_waitq); |
2078 | if (d->flags & DRV_FLAG_RUNNING) | 2078 | if (d->flags & DRV_FLAG_RUNNING) |
2079 | return -1; | 2079 | return -1; |
2080 | if (n < 1) return 0; | 2080 | if (n < 1) return 0; |
2081 | 2081 | ||
2082 | m = (adding) ? d->channels + n : n; | 2082 | m = (adding) ? d->channels + n : n; |
2083 | 2083 | ||
@@ -2114,7 +2114,7 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) | |||
2114 | kfree(d->rcvcount); | 2114 | kfree(d->rcvcount); |
2115 | kfree(d->rcverr); | 2115 | kfree(d->rcverr); |
2116 | } | 2116 | } |
2117 | return -1; | 2117 | return -1; |
2118 | } | 2118 | } |
2119 | for (j = 0; j < m; j++) { | 2119 | for (j = 0; j < m; j++) { |
2120 | skb_queue_head_init(&d->rpqueue[j]); | 2120 | skb_queue_head_init(&d->rpqueue[j]); |
@@ -2172,45 +2172,45 @@ set_global_features(void) | |||
2172 | 2172 | ||
2173 | static char *map_drvname(int di) | 2173 | static char *map_drvname(int di) |
2174 | { | 2174 | { |
2175 | if ((di < 0) || (di >= ISDN_MAX_DRIVERS)) | 2175 | if ((di < 0) || (di >= ISDN_MAX_DRIVERS)) |
2176 | return(NULL); | 2176 | return (NULL); |
2177 | return(dev->drvid[di]); /* driver name */ | 2177 | return (dev->drvid[di]); /* driver name */ |
2178 | } /* map_drvname */ | 2178 | } /* map_drvname */ |
2179 | 2179 | ||
2180 | static int map_namedrv(char *id) | 2180 | static int map_namedrv(char *id) |
2181 | { int i; | 2181 | { int i; |
2182 | 2182 | ||
2183 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) | 2183 | for (i = 0; i < ISDN_MAX_DRIVERS; i++) |
2184 | { if (!strcmp(dev->drvid[i],id)) | 2184 | { if (!strcmp(dev->drvid[i], id)) |
2185 | return(i); | 2185 | return (i); |
2186 | } | 2186 | } |
2187 | return(-1); | 2187 | return (-1); |
2188 | } /* map_namedrv */ | 2188 | } /* map_namedrv */ |
2189 | 2189 | ||
2190 | int DIVERT_REG_NAME(isdn_divert_if *i_div) | 2190 | int DIVERT_REG_NAME(isdn_divert_if *i_div) |
2191 | { | 2191 | { |
2192 | if (i_div->if_magic != DIVERT_IF_MAGIC) | 2192 | if (i_div->if_magic != DIVERT_IF_MAGIC) |
2193 | return(DIVERT_VER_ERR); | 2193 | return (DIVERT_VER_ERR); |
2194 | switch (i_div->cmd) | 2194 | switch (i_div->cmd) |
2195 | { | 2195 | { |
2196 | case DIVERT_CMD_REL: | 2196 | case DIVERT_CMD_REL: |
2197 | if (divert_if != i_div) | 2197 | if (divert_if != i_div) |
2198 | return(DIVERT_REL_ERR); | 2198 | return (DIVERT_REL_ERR); |
2199 | divert_if = NULL; /* free interface */ | 2199 | divert_if = NULL; /* free interface */ |
2200 | return(DIVERT_NO_ERR); | 2200 | return (DIVERT_NO_ERR); |
2201 | 2201 | ||
2202 | case DIVERT_CMD_REG: | 2202 | case DIVERT_CMD_REG: |
2203 | if (divert_if) | 2203 | if (divert_if) |
2204 | return(DIVERT_REG_ERR); | 2204 | return (DIVERT_REG_ERR); |
2205 | i_div->ll_cmd = isdn_command; /* set command function */ | 2205 | i_div->ll_cmd = isdn_command; /* set command function */ |
2206 | i_div->drv_to_name = map_drvname; | 2206 | i_div->drv_to_name = map_drvname; |
2207 | i_div->name_to_drv = map_namedrv; | 2207 | i_div->name_to_drv = map_namedrv; |
2208 | divert_if = i_div; /* remember interface */ | 2208 | divert_if = i_div; /* remember interface */ |
2209 | return(DIVERT_NO_ERR); | 2209 | return (DIVERT_NO_ERR); |
2210 | 2210 | ||
2211 | default: | 2211 | default: |
2212 | return(DIVERT_CMD_ERR); | 2212 | return (DIVERT_CMD_ERR); |
2213 | } | 2213 | } |
2214 | } /* DIVERT_REG_NAME */ | 2214 | } /* DIVERT_REG_NAME */ |
2215 | 2215 | ||
2216 | EXPORT_SYMBOL(DIVERT_REG_NAME); | 2216 | EXPORT_SYMBOL(DIVERT_REG_NAME); |
@@ -2225,7 +2225,7 @@ EXPORT_SYMBOL(isdn_ppp_unregister_compressor); | |||
2225 | #endif | 2225 | #endif |
2226 | 2226 | ||
2227 | int | 2227 | int |
2228 | register_isdn(isdn_if * i) | 2228 | register_isdn(isdn_if *i) |
2229 | { | 2229 | { |
2230 | isdn_driver_t *d; | 2230 | isdn_driver_t *d; |
2231 | int j; | 2231 | int j; |
@@ -2280,10 +2280,10 @@ register_isdn(isdn_if * i) | |||
2280 | } | 2280 | } |
2281 | 2281 | ||
2282 | /* | 2282 | /* |
2283 | ***************************************************************************** | 2283 | ***************************************************************************** |
2284 | * And now the modules code. | 2284 | * And now the modules code. |
2285 | ***************************************************************************** | 2285 | ***************************************************************************** |
2286 | */ | 2286 | */ |
2287 | 2287 | ||
2288 | static char * | 2288 | static char * |
2289 | isdn_getrev(const char *revision) | 2289 | isdn_getrev(const char *revision) |
diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 082735dbb412..9a471f62e1d4 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); | |||
29 | extern void isdn_unlock_drivers(void); | 29 | extern void isdn_unlock_drivers(void); |
30 | extern void isdn_free_channel(int di, int ch, int usage); | 30 | extern void isdn_free_channel(int di, int ch, int usage); |
31 | extern void isdn_all_eaz(int di, int ch); | 31 | extern void isdn_all_eaz(int di, int ch); |
32 | extern int isdn_command(isdn_ctrl *); | 32 | extern int isdn_command(isdn_ctrl *); |
33 | extern int isdn_dc2minor(int di, int ch); | 33 | extern int isdn_dc2minor(int di, int ch); |
34 | extern void isdn_info_update(void); | 34 | extern void isdn_info_update(void); |
35 | extern char *isdn_map_eaz2msn(char *msn, int di); | 35 | extern char *isdn_map_eaz2msn(char *msn, int di); |
36 | extern void isdn_timer_ctrl(int tf, int onoff); | 36 | extern void isdn_timer_ctrl(int tf, int onoff); |
37 | extern void isdn_unexclusive_channel(int di, int ch); | 37 | extern void isdn_unexclusive_channel(int di, int ch); |
38 | extern int isdn_getnum(char **); | 38 | extern int isdn_getnum(char **); |
39 | extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); | 39 | extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); |
40 | extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); | 40 | extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); |
41 | extern int isdn_get_free_channel(int, int, int, int, int, char *); | 41 | extern int isdn_get_free_channel(int, int, int, int, int, char *); |
42 | extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); | 42 | extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); |
43 | extern int register_isdn(isdn_if * i); | 43 | extern int register_isdn(isdn_if *i); |
44 | extern int isdn_msncmp( const char *, const char *); | 44 | extern 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) |
46 | extern void isdn_dumppkt(char *, u_char *, int, int); | 46 | extern 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 d568689669f8..91d57304d4d3 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 | ||
42 | static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb) | 42 | static 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 | ||
61 | static int isdn_concap_dl_connect_req(struct concap_proto *concap) | 61 | static 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 | ||
74 | static int isdn_concap_dl_disconn_req(struct concap_proto *concap) | 74 | static 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 | */ |
92 | struct concap_proto * isdn_concap_new( int encap ) | 92 | struct 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 6ac7e0445ea5..cd7e3ba74e25 100644 --- a/drivers/isdn/i4l/isdn_concap.h +++ b/drivers/isdn/i4l/isdn_concap.h | |||
@@ -8,6 +8,4 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | extern struct concap_device_ops isdn_concap_reliable_dl_dops; | 10 | extern struct concap_device_ops isdn_concap_reliable_dl_dops; |
11 | extern struct concap_proto * isdn_concap_new( int ); | 11 | extern 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 802ab87a78b6..babc621a07fb 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 | */ |
89 | static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp) | 89 | static __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 | */ |
114 | static __inline__ int isdn_net_device_busy(isdn_net_local *lp) | 114 | static __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 | ||
161 | static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) | 161 | static __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 | ||
179 | static int isdn_net_force_dial_lp(isdn_net_local *); | 179 | static int isdn_net_force_dial_lp(isdn_net_local *); |
180 | static netdev_tx_t isdn_net_start_xmit(struct sk_buff *, | 180 | static netdev_tx_t isdn_net_start_xmit(struct sk_buff *, |
181 | struct net_device *); | 181 | struct net_device *); |
182 | 182 | ||
183 | static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); | 183 | static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); |
184 | static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); | 184 | static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); |
185 | 185 | ||
186 | char *isdn_net_revision = "$Revision: 1.1.2.2 $"; | 186 | char *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 | ||
192 | static void | 192 | static void |
193 | isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason) | 193 | isdn_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 | |||
214 | isdn_net_reset(struct net_device *dev) | 214 | isdn_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 | */ |
269 | static void | 269 | static void |
270 | isdn_net_bind_channel(isdn_net_local * lp, int idx) | 270 | isdn_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 | */ |
282 | static void | 282 | static void |
283 | isdn_net_unbind_channel(isdn_net_local * lp) | 283 | isdn_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++; | ||
414 | return 1; | 422 | return 1; |
415 | case ISDN_STAT_DCONN: | 423 | case 12: |
416 | /* D-Channel is up */ | 424 | lp->dialstate = 5; |
417 | switch (lp->dialstate) { | 425 | return 1; |
418 | case 4: | 426 | } |
419 | case 7: | 427 | break; |
420 | case 8: | 428 | case ISDN_STAT_DHUP: |
421 | lp->dialstate++; | 429 | /* Either D-Channel-hangup or error during dialout */ |
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 | } | 465 | } |
466 | break; | 466 | break; |
467 | #endif /* CONFIG_ISDN_X25 */ | 467 | #endif /* CONFIG_ISDN_X25 */ |
468 | case ISDN_STAT_BCONN: | 468 | case ISDN_STAT_BCONN: |
469 | /* B-Channel is up */ | 469 | /* B-Channel is up */ |
470 | isdn_net_zero_frame_cnt(lp); | 470 | isdn_net_zero_frame_cnt(lp); |
471 | switch (lp->dialstate) { | 471 | switch (lp->dialstate) { |
472 | case 5: | 472 | case 5: |
473 | case 6: | 473 | case 6: |
474 | case 7: | 474 | case 7: |
475 | case 8: | 475 | case 8: |
476 | case 9: | 476 | case 9: |
477 | case 10: | 477 | case 10: |
478 | case 12: | 478 | case 12: |
479 | if (lp->dialstate <= 6) { | 479 | if (lp->dialstate <= 6) { |
480 | dev->usage[idx] |= ISDN_USAGE_OUTGOING; | 480 | dev->usage[idx] |= ISDN_USAGE_OUTGOING; |
481 | isdn_info_update(); | 481 | isdn_info_update(); |
482 | } else | 482 | } else |
483 | dev->rx_netdev[idx] = p; | 483 | dev->rx_netdev[idx] = p; |
484 | lp->dialstate = 0; | 484 | lp->dialstate = 0; |
485 | isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); | 485 | isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); |
486 | if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) | 486 | if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) |
487 | isdn_net_ciscohdlck_connected(lp); | 487 | isdn_net_ciscohdlck_connected(lp); |
488 | if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) { | 488 | if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) { |
489 | if (lp->master) { /* is lp a slave? */ | 489 | if (lp->master) { /* is lp a slave? */ |
490 | isdn_net_dev *nd = ISDN_MASTER_PRIV(lp)->netdev; | 490 | isdn_net_dev *nd = ISDN_MASTER_PRIV(lp)->netdev; |
491 | isdn_net_add_to_bundle(nd, lp); | 491 | isdn_net_add_to_bundle(nd, lp); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | printk(KERN_INFO "isdn_net: %s connected\n", p->dev->name); | 494 | printk(KERN_INFO "isdn_net: %s connected\n", p->dev->name); |
495 | /* If first Chargeinfo comes before B-Channel connect, | 495 | /* If first Chargeinfo comes before B-Channel connect, |
496 | * we correct the timestamp here. | 496 | * we correct the timestamp here. |
497 | */ | 497 | */ |
498 | lp->chargetime = jiffies; | 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; | ||
518 | } | ||
519 | break; | ||
520 | case ISDN_STAT_NODCH: | ||
521 | /* No D-Channel avail. */ | ||
522 | if (lp->dialstate == 4) { | ||
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); | ||
542 | return 1; | 517 | return 1; |
518 | } | ||
519 | break; | ||
520 | case ISDN_STAT_NODCH: | ||
521 | /* No D-Channel avail. */ | ||
522 | if (lp->dialstate == 4) { | ||
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); | ||
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); | ||
577 | break; | 587 | break; |
578 | case 1: | 588 | } |
579 | /* Initiate dialout. Set phone-number-pointer to first number | 589 | anymore = 1; |
580 | * of interface. | 590 | |
581 | */ | 591 | if (lp->dialtimeout > 0) |
582 | lp->dial = lp->phone[1]; | 592 | if (lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) { |
583 | if (!lp->dial) { | 593 | lp->dialstarted = jiffies; |
584 | printk(KERN_WARNING "%s: phone number deleted?\n", | 594 | lp->dialwait_timer = 0; |
585 | p->dev->name); | ||
586 | isdn_net_hangup(p->dev); | ||
587 | break; | ||
588 | } | 595 | } |
589 | anymore = 1; | ||
590 | 596 | ||
591 | if(lp->dialtimeout > 0) | 597 | lp->dialstate++; |
592 | if(lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) { | 598 | /* Fall through */ |
593 | lp->dialstarted = jiffies; | 599 | case 2: |
594 | lp->dialwait_timer = 0; | 600 | /* Prepare dialing. Clear EAZ, then set EAZ. */ |
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; | ||
595 | } | 654 | } |
596 | 655 | ||
597 | lp->dialstate++; | ||
598 | /* Fall through */ | ||
599 | case 2: | ||
600 | /* Prepare dialing. Clear EAZ, then set EAZ. */ | ||
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; | 656 | cmd.driver = lp->isdn_device; |
636 | cmd.arg = lp->isdn_channel; | 657 | cmd.command = ISDN_CMD_DIAL; |
637 | if (!lp->dial) { | 658 | cmd.parm.setup.si2 = 0; |
638 | printk(KERN_WARNING "%s: phone number deleted?\n", | 659 | |
639 | p->dev->name); | 660 | /* check for DOV */ |
640 | isdn_net_hangup(p->dev); | 661 | phone_number = lp->dial->num; |
641 | break; | 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; | ||
642 | } | 667 | } |
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 | } | ||
655 | 668 | ||
656 | cmd.driver = lp->isdn_device; | 669 | strcpy(cmd.parm.setup.phone, phone_number); |
657 | cmd.command = ISDN_CMD_DIAL; | 670 | /* |
658 | cmd.parm.setup.si2 = 0; | 671 | * Switch to next number or back to start if at end of list. |
659 | 672 | */ | |
660 | /* check for DOV */ | 673 | if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { |
661 | phone_number = lp->dial->num; | 674 | lp->dial = lp->phone[1]; |
662 | if ((*phone_number == 'v') || | 675 | lp->dialretry++; |
663 | (*phone_number == 'V')) { /* DOV call */ | ||
664 | cmd.parm.setup.si1 = 1; | ||
665 | } else { /* DATA call */ | ||
666 | cmd.parm.setup.si1 = 7; | ||
667 | } | ||
668 | 676 | ||
669 | strcpy(cmd.parm.setup.phone, phone_number); | 677 | if (lp->dialretry > lp->dialmax) { |
670 | /* | 678 | if (lp->dialtimeout == 0) { |
671 | * Switch to next number or back to start if at end of list. | 679 | lp->dialwait_timer = jiffies + lp->dialwait; |
672 | */ | 680 | lp->dialstarted = 0; |
673 | if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { | 681 | isdn_net_unreachable(p->dev, NULL, "dial: tried all numbers dialmax times"); |
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 | } | 682 | } |
683 | isdn_net_hangup(p->dev); | ||
684 | break; | ||
686 | } | 685 | } |
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); | ||
704 | } | 686 | } |
705 | lp->huptimer = 0; | 687 | sprintf(cmd.parm.setup.eazmsn, "%s", |
706 | lp->outgoing = 1; | 688 | isdn_map_eaz2msn(lp->msn, cmd.driver)); |
707 | if (lp->chargeint) { | 689 | i = isdn_dc2minor(lp->isdn_device, lp->isdn_channel); |
708 | lp->hupflags |= ISDN_HAVECHARGE; | 690 | if (i >= 0) { |
709 | lp->hupflags &= ~ISDN_WAITCHARGE; | 691 | strcpy(dev->num[i], cmd.parm.setup.phone); |
710 | } else { | 692 | dev->usage[i] |= ISDN_USAGE_OUTGOING; |
711 | lp->hupflags |= ISDN_WAITCHARGE; | 693 | isdn_info_update(); |
712 | lp->hupflags &= ~ISDN_HAVECHARGE; | ||
713 | } | 694 | } |
714 | anymore = 1; | 695 | printk(KERN_INFO "%s: dialing %d %s... %s\n", p->dev->name, |
715 | lp->dialstate = | 696 | lp->dialretry, cmd.parm.setup.phone, |
716 | (lp->cbdelay && | 697 | (cmd.parm.setup.si1 == 1) ? "DOV" : ""); |
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; | 698 | lp->dtimer = 0; |
735 | lp->dialstate++; | 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 | ||
736 | isdn_command(&cmd); | 703 | isdn_command(&cmd); |
737 | break; | 704 | } |
738 | case 6: | 705 | lp->huptimer = 0; |
739 | /* Wait for B- or D-Channel-connect. If timeout, | 706 | lp->outgoing = 1; |
740 | * switch back to state 3. | 707 | if (lp->chargeint) { |
741 | */ | 708 | lp->hupflags |= ISDN_HAVECHARGE; |
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); | ||
777 | anymore = 1; | 767 | anymore = 1; |
778 | lp->dtimer = 0; | ||
779 | lp->dialstate++; | 768 | lp->dialstate++; |
780 | break; | 769 | } |
781 | case 8: | 770 | break; |
782 | case 10: | 771 | case 9: |
783 | /* Wait for B- or D-channel-connect */ | 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); | ||
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; | ||
796 | anymore = 1; | ||
797 | break; | ||
798 | case 12: | ||
799 | /* Remote does callback. Hangup after cbdelay, then wait for incoming | ||
800 | * call (in state 4). | ||
801 | */ | ||
802 | if (lp->dtimer++ > lp->cbdelay) | ||
803 | { | ||
804 | printk(KERN_INFO "%s: hangup waiting for callback ...\n", p->dev->name); | ||
805 | lp->dtimer = 0; | ||
806 | lp->dialstate = 4; | ||
807 | cmd.driver = lp->isdn_device; | ||
808 | cmd.command = ISDN_CMD_HANGUP; | ||
809 | cmd.arg = lp->isdn_channel; | ||
810 | isdn_command(&cmd); | ||
811 | isdn_all_eaz(lp->isdn_device, lp->isdn_channel); | ||
812 | } | ||
813 | anymore = 1; | 790 | anymore = 1; |
814 | break; | 791 | break; |
815 | default: | 792 | case 11: |
816 | printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n", | 793 | /* Callback Delay */ |
817 | lp->dialstate, p->dev->name); | 794 | if (lp->dtimer++ > lp->cbdelay) |
795 | lp->dialstate = 1; | ||
796 | anymore = 1; | ||
797 | break; | ||
798 | case 12: | ||
799 | /* Remote does callback. Hangup after cbdelay, then wait for incoming | ||
800 | * call (in state 4). | ||
801 | */ | ||
802 | if (lp->dtimer++ > lp->cbdelay) | ||
803 | { | ||
804 | printk(KERN_INFO "%s: hangup waiting for callback ...\n", p->dev->name); | ||
805 | lp->dtimer = 0; | ||
806 | lp->dialstate = 4; | ||
807 | cmd.driver = lp->isdn_device; | ||
808 | cmd.command = ISDN_CMD_HANGUP; | ||
809 | cmd.arg = lp->isdn_channel; | ||
810 | isdn_command(&cmd); | ||
811 | isdn_all_eaz(lp->isdn_device, lp->isdn_channel); | ||
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 | ||
876 | static void | 876 | static void |
877 | isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp) | 877 | isdn_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); | ||
951 | break; | 944 | break; |
952 | case ETH_P_ARP: | 945 | case 22: |
953 | printk(KERN_INFO "OPEN: ARP %pI4 -> *.*.*.* ?%pI4\n", | 946 | strcpy(addinfo, " IDP"); |
954 | p + 14, p + 24); | ||
955 | break; | 947 | 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) | |||
964 | void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb) | 964 | void 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 | ||
1032 | error: | 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 | ||
1132 | static void isdn_net_tx_timeout(struct net_device * ndev) | 1132 | static 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 | */ |
1411 | static struct sk_buff* | 1411 | static 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; | ||
1483 | break; | ||
1484 | |||
1485 | default: | ||
1486 | rc = -EINVAL; | 1482 | rc = -EINVAL; |
1487 | break; | 1483 | break; |
1484 | |||
1485 | default: | ||
1486 | rc = -EINVAL; | ||
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 | ||
1604 | static void | 1604 | static void |
1605 | isdn_net_ciscohdlck_connected(isdn_net_local *lp) | 1605 | isdn_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 | ||
1625 | static void | 1625 | static void |
1626 | isdn_net_ciscohdlck_disconnected(isdn_net_local *lp) | 1626 | isdn_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 | |||
1732 | isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb) | 1732 | isdn_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 | ||
1777 | out_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); |
@@ -1904,48 +1904,48 @@ static int isdn_net_header(struct sk_buff *skb, struct net_device *dev, | |||
1904 | int len = 0; | 1904 | int 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; | 1919 | len = 0; |
1920 | break; | 1920 | break; |
1921 | case ISDN_NET_ENCAP_IPTYP: | 1921 | case ISDN_NET_ENCAP_IPTYP: |
1922 | /* ethernet type field */ | 1922 | /* ethernet type field */ |
1923 | *((__be16 *)skb_push(skb, 2)) = htons(type); | 1923 | *((__be16 *)skb_push(skb, 2)) = htons(type); |
1924 | len = 2; | 1924 | len = 2; |
1925 | break; | 1925 | break; |
1926 | case ISDN_NET_ENCAP_UIHDLC: | 1926 | case ISDN_NET_ENCAP_UIHDLC: |
1927 | /* HDLC with UI-Frames (for ispa with -h1 option) */ | 1927 | /* HDLC with UI-Frames (for ispa with -h1 option) */ |
1928 | *((__be16 *)skb_push(skb, 2)) = htons(0x0103); | 1928 | *((__be16 *)skb_push(skb, 2)) = htons(0x0103); |
1929 | len = 2; | 1929 | len = 2; |
1930 | break; | 1930 | break; |
1931 | case ISDN_NET_ENCAP_CISCOHDLC: | 1931 | case ISDN_NET_ENCAP_CISCOHDLC: |
1932 | case ISDN_NET_ENCAP_CISCOHDLCK: | 1932 | case ISDN_NET_ENCAP_CISCOHDLCK: |
1933 | p = skb_push(skb, 4); | 1933 | p = skb_push(skb, 4); |
1934 | *(u8 *)(p + 0) = CISCO_ADDR_UNICAST; | 1934 | *(u8 *)(p + 0) = CISCO_ADDR_UNICAST; |
1935 | *(u8 *)(p + 1) = CISCO_CTRL; | 1935 | *(u8 *)(p + 1) = CISCO_CTRL; |
1936 | *(__be16 *)(p + 2) = cpu_to_be16(type); | 1936 | *(__be16 *)(p + 2) = cpu_to_be16(type); |
1937 | p += 4; | 1937 | p += 4; |
1938 | len = 4; | 1938 | len = 4; |
1939 | break; | 1939 | break; |
1940 | #ifdef CONFIG_ISDN_X25 | 1940 | #ifdef CONFIG_ISDN_X25 |
1941 | default: | 1941 | default: |
1942 | /* try if there are generic concap protocol routines */ | 1942 | /* try if there are generic concap protocol routines */ |
1943 | if( lp-> netdev -> cprot ){ | 1943 | if (lp->netdev->cprot) { |
1944 | printk(KERN_WARNING "isdn_net_header called with concap_proto!\n"); | 1944 | printk(KERN_WARNING "isdn_net_header called with concap_proto!\n"); |
1945 | len = 0; | 1945 | len = 0; |
1946 | break; | ||
1947 | } | ||
1948 | break; | 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 | */ |
2441 | static int | 2441 | static int |
2442 | isdn_net_force_dial_lp(isdn_net_local * lp) | 2442 | isdn_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 | */ |
2489 | int | 2489 | int |
2490 | isdn_net_dial_req(isdn_net_local * lp) | 2490 | isdn_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 | */ |
2671 | int | 2671 | int |
2672 | isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) | 2672 | isdn_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,10 +2754,10 @@ 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)) == | 2759 | if (strnlen(cfg->drvid, sizeof(cfg->drvid)) == |
2760 | sizeof(cfg->drvid)) | 2760 | sizeof(cfg->drvid)) |
2761 | return -EINVAL; | 2761 | return -EINVAL; |
2762 | drvidx = -1; | 2762 | drvidx = -1; |
2763 | chidx = -1; | 2763 | chidx = -1; |
@@ -2789,8 +2789,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) | |||
2789 | /* If binding is exclusive, try to grab the channel */ | 2789 | /* If binding is exclusive, try to grab the channel */ |
2790 | spin_lock_irqsave(&dev->lock, flags); | 2790 | spin_lock_irqsave(&dev->lock, flags); |
2791 | if ((i = isdn_get_free_channel(ISDN_USAGE_NET, | 2791 | if ((i = isdn_get_free_channel(ISDN_USAGE_NET, |
2792 | lp->l2_proto, lp->l3_proto, drvidx, | 2792 | lp->l2_proto, lp->l3_proto, drvidx, |
2793 | chidx, lp->msn)) < 0) { | 2793 | chidx, lp->msn)) < 0) { |
2794 | /* Grab failed, because desired channel is in use */ | 2794 | /* Grab failed, because desired channel is in use */ |
2795 | lp->exclusive = -1; | 2795 | lp->exclusive = -1; |
2796 | spin_unlock_irqrestore(&dev->lock, flags); | 2796 | spin_unlock_irqrestore(&dev->lock, flags); |
@@ -2834,23 +2834,23 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) | |||
2834 | else | 2834 | else |
2835 | lp->flags &= ~ISDN_NET_CBHUP; | 2835 | lp->flags &= ~ISDN_NET_CBHUP; |
2836 | switch (cfg->callback) { | 2836 | switch (cfg->callback) { |
2837 | case 0: | 2837 | case 0: |
2838 | lp->flags &= ~(ISDN_NET_CALLBACK | ISDN_NET_CBOUT); | 2838 | lp->flags &= ~(ISDN_NET_CALLBACK | ISDN_NET_CBOUT); |
2839 | break; | 2839 | break; |
2840 | case 1: | 2840 | case 1: |
2841 | lp->flags |= ISDN_NET_CALLBACK; | 2841 | lp->flags |= ISDN_NET_CALLBACK; |
2842 | lp->flags &= ~ISDN_NET_CBOUT; | 2842 | lp->flags &= ~ISDN_NET_CBOUT; |
2843 | break; | 2843 | break; |
2844 | case 2: | 2844 | case 2: |
2845 | lp->flags |= ISDN_NET_CBOUT; | 2845 | lp->flags |= ISDN_NET_CBOUT; |
2846 | lp->flags &= ~ISDN_NET_CALLBACK; | 2846 | lp->flags &= ~ISDN_NET_CALLBACK; |
2847 | break; | 2847 | break; |
2848 | } | 2848 | } |
2849 | lp->flags &= ~ISDN_NET_DIALMODE_MASK; /* first all bits off */ | 2849 | lp->flags &= ~ISDN_NET_DIALMODE_MASK; /* first all bits off */ |
2850 | if (cfg->dialmode && !(cfg->dialmode & ISDN_NET_DIALMODE_MASK)) { | 2850 | if (cfg->dialmode && !(cfg->dialmode & ISDN_NET_DIALMODE_MASK)) { |
2851 | /* old isdnctrl version, where only 0 or 1 is given */ | 2851 | /* old isdnctrl version, where only 0 or 1 is given */ |
2852 | printk(KERN_WARNING | 2852 | printk(KERN_WARNING |
2853 | "Old isdnctrl version detected! Please update.\n"); | 2853 | "Old isdnctrl version detected! Please update.\n"); |
2854 | lp->flags |= ISDN_NET_DM_OFF; /* turn on `off' bit */ | 2854 | lp->flags |= ISDN_NET_DM_OFF; /* turn on `off' bit */ |
2855 | } | 2855 | } |
2856 | else { | 2856 | else { |
@@ -2871,13 +2871,13 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) | |||
2871 | if (cfg->p_encap != lp->p_encap) { | 2871 | if (cfg->p_encap != lp->p_encap) { |
2872 | if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) { | 2872 | if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) { |
2873 | p->dev->header_ops = NULL; | 2873 | p->dev->header_ops = NULL; |
2874 | p->dev->flags = IFF_NOARP|IFF_POINTOPOINT; | 2874 | p->dev->flags = IFF_NOARP | IFF_POINTOPOINT; |
2875 | } else { | 2875 | } else { |
2876 | p->dev->header_ops = &isdn_header_ops; | 2876 | p->dev->header_ops = &isdn_header_ops; |
2877 | if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) | 2877 | if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) |
2878 | p->dev->flags = IFF_BROADCAST | IFF_MULTICAST; | 2878 | p->dev->flags = IFF_BROADCAST | IFF_MULTICAST; |
2879 | else | 2879 | else |
2880 | p->dev->flags = IFF_NOARP|IFF_POINTOPOINT; | 2880 | p->dev->flags = IFF_NOARP | IFF_POINTOPOINT; |
2881 | } | 2881 | } |
2882 | } | 2882 | } |
2883 | lp->p_encap = cfg->p_encap; | 2883 | lp->p_encap = cfg->p_encap; |
@@ -2890,7 +2890,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) | |||
2890 | * Perform get-interface-parameters.ioctl | 2890 | * Perform get-interface-parameters.ioctl |
2891 | */ | 2891 | */ |
2892 | int | 2892 | int |
2893 | isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) | 2893 | isdn_net_getcfg(isdn_net_ioctl_cfg *cfg) |
2894 | { | 2894 | { |
2895 | isdn_net_dev *p = isdn_net_findif(cfg->name); | 2895 | isdn_net_dev *p = isdn_net_findif(cfg->name); |
2896 | 2896 | ||
@@ -2924,7 +2924,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) | |||
2924 | cfg->triggercps = lp->triggercps; | 2924 | cfg->triggercps = lp->triggercps; |
2925 | cfg->slavedelay = lp->slavedelay / HZ; | 2925 | cfg->slavedelay = lp->slavedelay / HZ; |
2926 | cfg->chargeint = (lp->hupflags & ISDN_CHARGEHUP) ? | 2926 | cfg->chargeint = (lp->hupflags & ISDN_CHARGEHUP) ? |
2927 | (lp->chargeint / HZ) : 0; | 2927 | (lp->chargeint / HZ) : 0; |
2928 | cfg->pppbind = lp->pppbind; | 2928 | cfg->pppbind = lp->pppbind; |
2929 | cfg->dialtimeout = lp->dialtimeout >= 0 ? lp->dialtimeout / HZ : -1; | 2929 | cfg->dialtimeout = lp->dialtimeout >= 0 ? lp->dialtimeout / HZ : -1; |
2930 | cfg->dialwait = lp->dialwait / HZ; | 2930 | cfg->dialwait = lp->dialwait / HZ; |
@@ -2951,7 +2951,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) | |||
2951 | * Add a phone-number to an interface. | 2951 | * Add a phone-number to an interface. |
2952 | */ | 2952 | */ |
2953 | int | 2953 | int |
2954 | isdn_net_addphone(isdn_net_ioctl_phone * phone) | 2954 | isdn_net_addphone(isdn_net_ioctl_phone *phone) |
2955 | { | 2955 | { |
2956 | isdn_net_dev *p = isdn_net_findif(phone->name); | 2956 | isdn_net_dev *p = isdn_net_findif(phone->name); |
2957 | isdn_net_phone *n; | 2957 | isdn_net_phone *n; |
@@ -2972,7 +2972,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) | |||
2972 | * This might sleep and must be called with the isdn semaphore down. | 2972 | * This might sleep and must be called with the isdn semaphore down. |
2973 | */ | 2973 | */ |
2974 | int | 2974 | int |
2975 | isdn_net_getphones(isdn_net_ioctl_phone * phone, char __user *phones) | 2975 | isdn_net_getphones(isdn_net_ioctl_phone *phone, char __user *phones) |
2976 | { | 2976 | { |
2977 | isdn_net_dev *p = isdn_net_findif(phone->name); | 2977 | isdn_net_dev *p = isdn_net_findif(phone->name); |
2978 | int inout = phone->outgoing & 1; | 2978 | int inout = phone->outgoing & 1; |
@@ -3015,15 +3015,15 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone __user *peer) | |||
3015 | /* | 3015 | /* |
3016 | * Theoretical race: while this executes, the remote number might | 3016 | * Theoretical race: while this executes, the remote number might |
3017 | * become invalid (hang up) or change (new connection), resulting | 3017 | * become invalid (hang up) or change (new connection), resulting |
3018 | * in (partially) wrong number copied to user. This race | 3018 | * in (partially) wrong number copied to user. This race |
3019 | * currently ignored. | 3019 | * currently ignored. |
3020 | */ | 3020 | */ |
3021 | ch = p->local->isdn_channel; | 3021 | ch = p->local->isdn_channel; |
3022 | dv = p->local->isdn_device; | 3022 | dv = p->local->isdn_device; |
3023 | if(ch < 0 && dv < 0) | 3023 | if (ch < 0 && dv < 0) |
3024 | return -ENOTCONN; | 3024 | return -ENOTCONN; |
3025 | idx = isdn_dc2minor(dv, ch); | 3025 | idx = isdn_dc2minor(dv, ch); |
3026 | if (idx <0 ) | 3026 | if (idx < 0) |
3027 | return -ENODEV; | 3027 | return -ENODEV; |
3028 | /* for pre-bound channels, we need this extra check */ | 3028 | /* for pre-bound channels, we need this extra check */ |
3029 | if (strncmp(dev->num[idx], "???", 3) == 0) | 3029 | if (strncmp(dev->num[idx], "???", 3) == 0) |
@@ -3038,7 +3038,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone __user *peer) | |||
3038 | * Delete a phone-number from an interface. | 3038 | * Delete a phone-number from an interface. |
3039 | */ | 3039 | */ |
3040 | int | 3040 | int |
3041 | isdn_net_delphone(isdn_net_ioctl_phone * phone) | 3041 | isdn_net_delphone(isdn_net_ioctl_phone *phone) |
3042 | { | 3042 | { |
3043 | isdn_net_dev *p = isdn_net_findif(phone->name); | 3043 | isdn_net_dev *p = isdn_net_findif(phone->name); |
3044 | int inout = phone->outgoing & 1; | 3044 | int inout = phone->outgoing & 1; |
@@ -3071,7 +3071,7 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone) | |||
3071 | * Delete all phone-numbers of an interface. | 3071 | * Delete all phone-numbers of an interface. |
3072 | */ | 3072 | */ |
3073 | static int | 3073 | static int |
3074 | isdn_net_rmallphone(isdn_net_dev * p) | 3074 | isdn_net_rmallphone(isdn_net_dev *p) |
3075 | { | 3075 | { |
3076 | isdn_net_phone *n; | 3076 | isdn_net_phone *n; |
3077 | isdn_net_phone *m; | 3077 | isdn_net_phone *m; |
@@ -3118,7 +3118,7 @@ isdn_net_force_hangup(char *name) | |||
3118 | * Helper-function for isdn_net_rm: Do the real work. | 3118 | * Helper-function for isdn_net_rm: Do the real work. |
3119 | */ | 3119 | */ |
3120 | static int | 3120 | static int |
3121 | isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) | 3121 | isdn_net_realrm(isdn_net_dev *p, isdn_net_dev *q) |
3122 | { | 3122 | { |
3123 | u_long flags; | 3123 | u_long flags; |
3124 | 3124 | ||
@@ -3126,8 +3126,8 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) | |||
3126 | return -EBUSY; | 3126 | return -EBUSY; |
3127 | } | 3127 | } |
3128 | #ifdef CONFIG_ISDN_X25 | 3128 | #ifdef CONFIG_ISDN_X25 |
3129 | if( p -> cprot && p -> cprot -> pops ) | 3129 | if (p->cprot && p->cprot->pops) |
3130 | p -> cprot -> pops -> proto_del ( p -> cprot ); | 3130 | p->cprot->pops->proto_del(p->cprot); |
3131 | #endif | 3131 | #endif |
3132 | /* Free all phone-entries */ | 3132 | /* Free all phone-entries */ |
3133 | isdn_net_rmallphone(p); | 3133 | isdn_net_rmallphone(p); |
diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h index 7511f08effa5..cca6d68da171 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 | */ |
79 | static __inline__ isdn_net_local * isdn_net_get_locked_lp(isdn_net_dev *nd) | 79 | static __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,4 +149,3 @@ 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 e38f674a7bd3..a1e760150821 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c | |||
@@ -28,18 +28,18 @@ | |||
28 | /* Prototypes */ | 28 | /* Prototypes */ |
29 | static int isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot); | 29 | static int isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot); |
30 | static int isdn_ppp_closewait(int slot); | 30 | static int isdn_ppp_closewait(int slot); |
31 | static void isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, | 31 | static 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); |
33 | static int isdn_ppp_if_get_unit(char *namebuf); | 33 | static int isdn_ppp_if_get_unit(char *namebuf); |
34 | static int isdn_ppp_set_compressor(struct ippp_struct *is,struct isdn_ppp_comp_data *); | 34 | static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_data *); |
35 | static struct sk_buff *isdn_ppp_decompress(struct sk_buff *, | 35 | static 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); |
37 | static void isdn_ppp_receive_ccp(isdn_net_dev * net_dev, isdn_net_local * lp, | 37 | static 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); |
39 | static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto, | 39 | static 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); |
41 | static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, | 41 | static 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 */ |
45 | static void isdn_ppp_ccp_kickup(struct ippp_struct *is); | 45 | static 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); |
53 | static void isdn_ppp_ccp_timer_callback(unsigned long closure); | 53 | static void isdn_ppp_ccp_timer_callback(unsigned long closure); |
54 | static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, | 54 | static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, |
55 | unsigned char id); | 55 | unsigned char id); |
56 | static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, | 56 | static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, |
57 | struct isdn_ppp_resetparams *rp); | 57 | struct isdn_ppp_resetparams *rp); |
58 | static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, | 58 | static 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 |
64 | static ippp_bundle * isdn_ppp_bundle_arr = NULL; | 64 | static ippp_bundle *isdn_ppp_bundle_arr = NULL; |
65 | 65 | ||
66 | static int isdn_ppp_mp_bundle_array_init(void); | 66 | static int isdn_ppp_mp_bundle_array_init(void); |
67 | static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to ); | 67 | static int isdn_ppp_mp_init(isdn_net_local *lp, ippp_bundle *add_to); |
68 | static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, | 68 | static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, |
69 | struct sk_buff *skb); | 69 | struct sk_buff *skb); |
70 | static void isdn_ppp_mp_cleanup( isdn_net_local * lp ); | 70 | static void isdn_ppp_mp_cleanup(isdn_net_local *lp); |
71 | 71 | ||
72 | static int isdn_ppp_bundle(struct ippp_struct *, int unit); | 72 | static int isdn_ppp_bundle(struct ippp_struct *, int unit); |
73 | #endif /* CONFIG_ISDN_MPP */ | 73 | #endif /* CONFIG_ISDN_MPP */ |
74 | 74 | ||
75 | char *isdn_ppp_revision = "$Revision: 1.1.2.3 $"; | 75 | char *isdn_ppp_revision = "$Revision: 1.1.2.3 $"; |
76 | 76 | ||
77 | static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS]; | 77 | static 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 | */ |
84 | static void | 84 | static void |
85 | isdn_ppp_frame_log(char *info, char *data, int len, int maxlen,int unit,int slot) | 85 | isdn_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 slot | |||
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 slot | |||
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 | */ |
107 | int | 107 | int |
108 | isdn_ppp_free(isdn_net_local * lp) | 108 | isdn_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 | */ |
155 | int | 155 | int |
156 | isdn_ppp_bind(isdn_net_local * lp) | 156 | isdn_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 | ||
216 | out: | 216 | out: |
217 | return retval; | 217 | return retval; |
218 | } | 218 | } |
219 | 219 | ||
@@ -223,11 +223,11 @@ isdn_ppp_bind(isdn_net_local * lp) | |||
223 | */ | 223 | */ |
224 | 224 | ||
225 | void | 225 | void |
226 | isdn_ppp_wakeup_daemon(isdn_net_local * lp) | 226 | isdn_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 | */ |
425 | static int | 425 | static int |
426 | set_arg(void __user *b, void *val,int len) | 426 | set_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 | |||
471 | isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) | 471 | isdn_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 */ | ||
542 | if (lp) { | 532 | if (lp) { |
543 | struct ppp_idle pidle; | 533 | /* OK .. we are ready to send buffers */ |
544 | pidle.xmit_idle = pidle.recv_idle = lp->huptimer; | 534 | is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */ |
545 | if ((r = set_arg(argp, &pidle,sizeof(struct ppp_idle)))) | 535 | netif_wake_queue(lp->netdev->dev); |
546 | return r; | 536 | break; |
547 | } | 537 | } |
548 | break; | 538 | } |
549 | case PPPIOCSMRU: /* set receive unit size for PPP */ | 539 | is->pppcfg = val; |
550 | if ((r = get_arg(argp, &val, sizeof(val) ))) | 540 | break; |
551 | return r; | 541 | case PPPIOCGIDLE: /* get idle time information */ |
552 | is->mru = val; | 542 | if (lp) { |
553 | break; | 543 | struct ppp_idle pidle; |
554 | case PPPIOCSMPMRU: | 544 | pidle.xmit_idle = pidle.recv_idle = lp->huptimer; |
555 | break; | 545 | if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle)))) |
556 | case PPPIOCSMPMTU: | ||
557 | break; | ||
558 | case PPPIOCSMAXCID: /* set the maximum compression slot id */ | ||
559 | if ((r = get_arg(argp, &val, sizeof(val) ))) | ||
560 | return r; | 546 | return r; |
561 | val++; | 547 | } |
562 | if (is->maxcid != val) { | 548 | break; |
549 | case PPPIOCSMRU: /* set receive unit size for PPP */ | ||
550 | if ((r = get_arg(argp, &val, sizeof(val)))) | ||
551 | return r; | ||
552 | is->mru = val; | ||
553 | break; | ||
554 | case PPPIOCSMPMRU: | ||
555 | break; | ||
556 | case PPPIOCSMPMTU: | ||
557 | break; | ||
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 | } | ||
575 | if (is->slcomp) | ||
576 | slhc_free(is->slcomp); | ||
577 | is->slcomp = sltmp; | ||
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] |= (0x1<<i); | ||
599 | ipc = ipc->next; | ||
600 | } | ||
601 | if ((r = set_arg(argp,protos,8*sizeof(long) ))) | ||
602 | return r; | ||
603 | } | 574 | } |
604 | break; | 575 | if (is->slcomp) |
605 | case PPPIOCSCOMPRESSOR: | 576 | slhc_free(is->slcomp); |
606 | if ((r = get_arg(argp, &data, sizeof(struct isdn_ppp_comp_data)))) | 577 | is->slcomp = sltmp; |
607 | return r; | 578 | #endif |
608 | return isdn_ppp_set_compressor(is, &data); | 579 | } |
609 | case PPPIOCGCALLINFO: | 580 | break; |
610 | { | 581 | case PPPIOCGDEBUG: |
611 | struct pppcallinfo pci; | 582 | if ((r = set_arg(argp, &is->debug, sizeof(is->debug)))) |
612 | memset((char *) &pci,0,sizeof(struct pppcallinfo)); | 583 | return r; |
613 | if(lp) | 584 | break; |
614 | { | 585 | case PPPIOCSDEBUG: |
615 | strncpy(pci.local_num,lp->msn,63); | 586 | if ((r = get_arg(argp, &val, sizeof(val)))) |
616 | if(lp->dial) { | 587 | return r; |
617 | strncpy(pci.remote_num,lp->dial->num,63); | 588 | is->debug = val; |
618 | } | 589 | break; |
619 | pci.charge_units = lp->charge; | 590 | case PPPIOCGCOMPRESSORS: |
620 | if(lp->outgoing) | 591 | { |
621 | pci.calltype = CALLTYPE_OUTGOING; | 592 | unsigned long protos[8] = {0,}; |
622 | else | 593 | struct isdn_ppp_compressor *ipc = ipc_head; |
623 | pci.calltype = CALLTYPE_INCOMING; | 594 | while (ipc) { |
624 | if(lp->flags & ISDN_NET_CALLBACK) | 595 | j = ipc->num / (sizeof(long) * 8); |
625 | pci.calltype |= CALLTYPE_CALLBACK; | 596 | i = ipc->num % (sizeof(long) * 8); |
626 | } | 597 | if (j < 8) |
627 | return set_arg(argp,&pci,sizeof(struct pppcallinfo)); | 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); | ||
628 | } | 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 | ||
659 | unsigned int | 659 | unsigned int |
660 | isdn_ppp_poll(struct file *file, poll_table * wait) | 660 | isdn_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 | |||
869 | isdn_ppp_init(void) | 869 | isdn_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 | */ |
919 | static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb) | 919 | static 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 | */ |
945 | static int isdn_ppp_strip_proto(struct sk_buff *skb) | 945 | static 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 | */ |
969 | void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb) | 969 | void 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_buf | |||
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_buf | |||
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_buf | |||
1022 | * note: net_dev has to be master net_dev | 1022 | * note: net_dev has to be master net_dev |
1023 | */ | 1023 | */ |
1024 | static void | 1024 | static void |
1025 | isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb, int proto) | 1025 | isdn_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; | 1074 | goto drop_packet; |
1075 | #ifdef CONFIG_ISDN_PPP_VJ | 1075 | #ifdef CONFIG_ISDN_PPP_VJ |
1076 | case PPP_VJC_UNCOMP: | 1076 | case PPP_VJC_UNCOMP: |
1077 | if (is->debug & 0x20) | 1077 | if (is->debug & 0x20) |
1078 | printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n"); | 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; | ||
1087 | } | ||
1088 | skb->protocol = htons(ETH_P_IP); | ||
1089 | break; | ||
1090 | case PPP_VJC_COMP: | ||
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); | ||
1079 | if (net_dev->local->ppp_slot < 0) { | 1106 | if (net_dev->local->ppp_slot < 0) { |
1080 | printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", | 1107 | printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", |
1081 | __func__, net_dev->local->ppp_slot); | 1108 | __func__, net_dev->local->ppp_slot); |
1082 | goto drop_packet; | 1109 | goto drop_packet; |
1083 | } | 1110 | } |
1084 | if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) { | 1111 | pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp, |
1085 | printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n"); | 1112 | skb->data, skb_old->len); |
1113 | kfree_skb(skb_old); | ||
1114 | if (pkt_len < 0) | ||
1086 | goto drop_packet; | 1115 | goto drop_packet; |
1087 | } | 1116 | |
1117 | skb_trim(skb, pkt_len); | ||
1088 | skb->protocol = htons(ETH_P_IP); | 1118 | skb->protocol = htons(ETH_P_IP); |
1089 | break; | 1119 | } |
1090 | case PPP_VJC_COMP: | 1120 | break; |
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) { | ||
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 | 1121 | #endif |
1122 | case PPP_CCP: | 1122 | case PPP_CCP: |
1123 | case PPP_CCPFRAG: | 1123 | case PPP_CCPFRAG: |
1124 | isdn_ppp_receive_ccp(net_dev,lp,skb,proto); | 1124 | isdn_ppp_receive_ccp(net_dev, lp, skb, proto); |
1125 | /* Dont pop up ResetReq/Ack stuff to the daemon any | 1125 | /* Dont pop up ResetReq/Ack stuff to the daemon any |
1126 | longer - the job is done already */ | 1126 | longer - the job is done already */ |
1127 | if(skb->data[0] == CCP_RESETREQ || | 1127 | if (skb->data[0] == CCP_RESETREQ || |
1128 | skb->data[0] == CCP_RESETACK) | 1128 | skb->data[0] == CCP_RESETACK) |
1129 | break; | 1129 | break; |
1130 | /* fall through */ | 1130 | /* fall through */ |
1131 | default: | 1131 | default: |
1132 | isdn_ppp_fill_rq(skb->data, skb->len, proto, lp->ppp_slot); /* push data to pppd device */ | 1132 | isdn_ppp_fill_rq(skb->data, skb->len, proto, lp->ppp_slot); /* push data to pppd device */ |
1133 | kfree_skb(skb); | 1133 | kfree_skb(skb); |
1134 | return; | 1134 | return; |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | #ifdef CONFIG_IPPP_FILTER | 1137 | #ifdef CONFIG_IPPP_FILTER |
@@ -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 | ||
1176 | drop_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 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff | |||
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 | */ |
1186 | static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len) | 1186 | static 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) | |||
1214 | int | 1214 | int |
1215 | isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) | 1215 | isdn_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 |
@@ -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 | ||
1448 | unlock: | 1448 | unlock: |
1449 | spin_unlock_bh(&lp->xmit_lock); | 1449 | spin_unlock_bh(&lp->xmit_lock); |
1450 | out: | 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 | ||
1526 | static int isdn_ppp_mp_bundle_array_init(void) | 1526 | static 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 | ||
1537 | static ippp_bundle * isdn_ppp_mp_bundle_alloc(void) | 1537 | static 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 | ||
1546 | static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to ) | 1546 | static 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 | ||
1576 | static u32 isdn_ppp_mp_get_seq( int short_seq, | 1576 | static 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); |
1578 | static struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp, | 1578 | static 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); |
1580 | static void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp, | 1580 | static 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); |
1582 | static void isdn_ppp_mp_free_skb( ippp_bundle * mp, struct sk_buff * skb ); | 1582 | static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb); |
1583 | static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb ); | 1583 | static void isdn_ppp_mp_print_recv_pkt(int slot, struct sk_buff *skb); |
1584 | 1584 | ||
1585 | static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, | 1585 | static 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; | ||
1740 | 1737 | ||
1741 | mp->frags = nextf; | 1738 | start = NULL; |
1742 | } | 1739 | frag = NULL; |
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 | ||
1806 | static void isdn_ppp_mp_cleanup( isdn_net_local * lp ) | 1806 | static 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 | ||
1818 | static u32 isdn_ppp_mp_get_seq( int short_seq, | 1818 | static 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 | ||
1852 | struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp, | 1852 | struct 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 | ||
1864 | void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp, | 1864 | void 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 | ||
1917 | static void isdn_ppp_mp_free_skb(ippp_bundle * mp, struct sk_buff * skb) | 1917 | static 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 | ||
1923 | static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb ) | 1923 | static 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 | ||
1931 | static int | 1931 | static 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) | |||
2020 | int | 2020 | int |
2021 | isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 2021 | isdn_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 | |||
2050 | isdn_ppp_if_get_unit(char *name) | 2050 | isdn_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 */ |
2329 | static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, | 2329 | static 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 | ||
2498 | static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struct *is,struct ippp_struct *master, | 2498 | static 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_struc | |||
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_struc | |||
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_struc | |||
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_struc | |||
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 | */ |
2581 | static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto, | 2581 | static 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 | */ |
2641 | static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, | 2641 | static 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 | ||
2818 | static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb) | 2818 | static 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 | ||
2929 | int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc) | 2929 | int 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 8cc05c7ccf78..4e9b8935a4eb 100644 --- a/drivers/isdn/i4l/isdn_ppp.h +++ b/drivers/isdn/i4l/isdn_ppp.h | |||
@@ -39,5 +39,3 @@ 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 2c26b64ebbea..89a28872c636 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -61,7 +61,7 @@ char *isdn_tty_revision = "$Revision: 1.1.2.3 $"; | |||
61 | * isdn_tty_readmodem(). | 61 | * isdn_tty_readmodem(). |
62 | */ | 62 | */ |
63 | static int | 63 | static int |
64 | isdn_tty_try_read(modem_info * info, struct sk_buff *skb) | 64 | isdn_tty_try_read(modem_info *info, struct sk_buff *skb) |
65 | { | 65 | { |
66 | int c; | 66 | int c; |
67 | int len; | 67 | int len; |
@@ -93,7 +93,7 @@ isdn_tty_try_read(modem_info * info, struct sk_buff *skb) | |||
93 | last = *dp; | 93 | last = *dp; |
94 | } else { | 94 | } else { |
95 | #endif | 95 | #endif |
96 | if(len > 1) | 96 | if (len > 1) |
97 | tty_insert_flip_string(tty, skb->data, len - 1); | 97 | tty_insert_flip_string(tty, skb->data, len - 1); |
98 | last = skb->data[len - 1]; | 98 | last = skb->data[len - 1]; |
99 | #ifdef CONFIG_ISDN_AUDIO | 99 | #ifdef CONFIG_ISDN_AUDIO |
@@ -179,7 +179,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) | |||
179 | info = &dev->mdm.info[midx]; | 179 | info = &dev->mdm.info[midx]; |
180 | #ifdef CONFIG_ISDN_AUDIO | 180 | #ifdef CONFIG_ISDN_AUDIO |
181 | ifmt = 1; | 181 | ifmt = 1; |
182 | 182 | ||
183 | if ((info->vonline) && (!info->emu.vpar[4])) | 183 | if ((info->vonline) && (!info->emu.vpar[4])) |
184 | isdn_audio_calc_dtmf(info, skb->data, skb->len, ifmt); | 184 | isdn_audio_calc_dtmf(info, skb->data, skb->len, ifmt); |
185 | if ((info->vonline & 1) && (info->emu.vpar[1])) | 185 | if ((info->vonline & 1) && (info->emu.vpar[1])) |
@@ -213,29 +213,29 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) | |||
213 | if (info->vonline & 1) { | 213 | if (info->vonline & 1) { |
214 | /* voice conversion/compression */ | 214 | /* voice conversion/compression */ |
215 | switch (info->emu.vpar[3]) { | 215 | switch (info->emu.vpar[3]) { |
216 | case 2: | 216 | case 2: |
217 | case 3: | 217 | case 3: |
218 | case 4: | 218 | case 4: |
219 | /* adpcm | 219 | /* adpcm |
220 | * Since compressed data takes less | 220 | * Since compressed data takes less |
221 | * space, we can overwrite the buffer. | 221 | * space, we can overwrite the buffer. |
222 | */ | 222 | */ |
223 | skb_trim(skb, isdn_audio_xlaw2adpcm(info->adpcmr, | 223 | skb_trim(skb, isdn_audio_xlaw2adpcm(info->adpcmr, |
224 | ifmt, | 224 | ifmt, |
225 | skb->data, | 225 | skb->data, |
226 | skb->data, | 226 | skb->data, |
227 | skb->len)); | 227 | skb->len)); |
228 | break; | 228 | break; |
229 | case 5: | 229 | case 5: |
230 | /* a-law */ | 230 | /* a-law */ |
231 | if (!ifmt) | 231 | if (!ifmt) |
232 | isdn_audio_ulaw2alaw(skb->data, skb->len); | 232 | isdn_audio_ulaw2alaw(skb->data, skb->len); |
233 | break; | 233 | break; |
234 | case 6: | 234 | case 6: |
235 | /* u-law */ | 235 | /* u-law */ |
236 | if (ifmt) | 236 | if (ifmt) |
237 | isdn_audio_alaw2ulaw(skb->data, skb->len); | 237 | isdn_audio_alaw2ulaw(skb->data, skb->len); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | ISDN_AUDIO_SKB_DLECOUNT(skb) = | 240 | ISDN_AUDIO_SKB_DLECOUNT(skb) = |
241 | isdn_tty_countDLE(skb->data, skb->len); | 241 | isdn_tty_countDLE(skb->data, skb->len); |
@@ -275,7 +275,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) | |||
275 | } | 275 | } |
276 | 276 | ||
277 | static void | 277 | static void |
278 | isdn_tty_cleanup_xmit(modem_info * info) | 278 | isdn_tty_cleanup_xmit(modem_info *info) |
279 | { | 279 | { |
280 | skb_queue_purge(&info->xmit_queue); | 280 | skb_queue_purge(&info->xmit_queue); |
281 | #ifdef CONFIG_ISDN_AUDIO | 281 | #ifdef CONFIG_ISDN_AUDIO |
@@ -284,7 +284,7 @@ isdn_tty_cleanup_xmit(modem_info * info) | |||
284 | } | 284 | } |
285 | 285 | ||
286 | static void | 286 | static void |
287 | isdn_tty_tint(modem_info * info) | 287 | isdn_tty_tint(modem_info *info) |
288 | { | 288 | { |
289 | struct sk_buff *skb = skb_dequeue(&info->xmit_queue); | 289 | struct sk_buff *skb = skb_dequeue(&info->xmit_queue); |
290 | int len, slen; | 290 | int len, slen; |
@@ -325,7 +325,7 @@ isdn_tty_countDLE(unsigned char *buf, int len) | |||
325 | * DLE-decoding when sending audio-data. | 325 | * DLE-decoding when sending audio-data. |
326 | */ | 326 | */ |
327 | static int | 327 | static int |
328 | isdn_tty_handleDLEdown(modem_info * info, atemu * m, int len) | 328 | isdn_tty_handleDLEdown(modem_info *info, atemu *m, int len) |
329 | { | 329 | { |
330 | unsigned char *p = &info->xmit_buf[info->xmit_count]; | 330 | unsigned char *p = &info->xmit_buf[info->xmit_count]; |
331 | int count = 0; | 331 | int count = 0; |
@@ -334,42 +334,42 @@ isdn_tty_handleDLEdown(modem_info * info, atemu * m, int len) | |||
334 | if (m->lastDLE) { | 334 | if (m->lastDLE) { |
335 | m->lastDLE = 0; | 335 | m->lastDLE = 0; |
336 | switch (*p) { | 336 | switch (*p) { |
337 | case DLE: | 337 | case DLE: |
338 | /* Escape code */ | 338 | /* Escape code */ |
339 | if (len > 1) | 339 | if (len > 1) |
340 | memmove(p, p + 1, len - 1); | 340 | memmove(p, p + 1, len - 1); |
341 | p--; | 341 | p--; |
342 | count++; | 342 | count++; |
343 | break; | 343 | break; |
344 | case ETX: | 344 | case ETX: |
345 | /* End of data */ | 345 | /* End of data */ |
346 | info->vonline |= 4; | 346 | info->vonline |= 4; |
347 | return count; | 347 | return count; |
348 | case DC4: | 348 | case DC4: |
349 | /* Abort RX */ | 349 | /* Abort RX */ |
350 | info->vonline &= ~1; | 350 | info->vonline &= ~1; |
351 | #ifdef ISDN_DEBUG_MODEM_VOICE | 351 | #ifdef ISDN_DEBUG_MODEM_VOICE |
352 | printk(KERN_DEBUG | 352 | printk(KERN_DEBUG |
353 | "DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n", | 353 | "DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n", |
354 | info->line); | 354 | info->line); |
355 | #endif | 355 | #endif |
356 | isdn_tty_at_cout("\020\003", info); | 356 | isdn_tty_at_cout("\020\003", info); |
357 | if (!info->vonline) { | 357 | if (!info->vonline) { |
358 | #ifdef ISDN_DEBUG_MODEM_VOICE | 358 | #ifdef ISDN_DEBUG_MODEM_VOICE |
359 | printk(KERN_DEBUG | 359 | printk(KERN_DEBUG |
360 | "DLEdown: send VCON on ttyI%d\n", | 360 | "DLEdown: send VCON on ttyI%d\n", |
361 | info->line); | 361 | info->line); |
362 | #endif | 362 | #endif |
363 | isdn_tty_at_cout("\r\nVCON\r\n", info); | 363 | isdn_tty_at_cout("\r\nVCON\r\n", info); |
364 | } | 364 | } |
365 | /* Fall through */ | 365 | /* Fall through */ |
366 | case 'q': | 366 | case 'q': |
367 | case 's': | 367 | case 's': |
368 | /* Silence */ | 368 | /* Silence */ |
369 | if (len > 1) | 369 | if (len > 1) |
370 | memmove(p, p + 1, len - 1); | 370 | memmove(p, p + 1, len - 1); |
371 | p--; | 371 | p--; |
372 | break; | 372 | break; |
373 | } | 373 | } |
374 | } else { | 374 | } else { |
375 | if (*p == DLE) | 375 | if (*p == DLE) |
@@ -416,7 +416,7 @@ static int voice_cf[7] = | |||
416 | * 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. |
417 | */ | 417 | */ |
418 | static void | 418 | static void |
419 | isdn_tty_senddown(modem_info * info) | 419 | isdn_tty_senddown(modem_info *info) |
420 | { | 420 | { |
421 | int buflen; | 421 | int buflen; |
422 | int skb_res; | 422 | int skb_res; |
@@ -440,9 +440,9 @@ isdn_tty_senddown(modem_info * info) | |||
440 | #endif | 440 | #endif |
441 | if (!(buflen = info->xmit_count)) | 441 | if (!(buflen = info->xmit_count)) |
442 | return; | 442 | return; |
443 | if ((info->emu.mdmreg[REG_CTS] & BIT_CTS) != 0) | 443 | if ((info->emu.mdmreg[REG_CTS] & BIT_CTS) != 0) |
444 | info->msr &= ~UART_MSR_CTS; | 444 | info->msr &= ~UART_MSR_CTS; |
445 | info->lsr &= ~UART_LSR_TEMT; | 445 | info->lsr &= ~UART_LSR_TEMT; |
446 | /* info->xmit_count is modified here and in isdn_tty_write(). | 446 | /* info->xmit_count is modified here and in isdn_tty_write(). |
447 | * So we return here if isdn_tty_write() is in the | 447 | * So we return here if isdn_tty_write() is in the |
448 | * critical section. | 448 | * critical section. |
@@ -485,32 +485,32 @@ isdn_tty_senddown(modem_info * info) | |||
485 | 485 | ||
486 | /* voice conversion/decompression */ | 486 | /* voice conversion/decompression */ |
487 | switch (info->emu.vpar[3]) { | 487 | switch (info->emu.vpar[3]) { |
488 | case 2: | 488 | case 2: |
489 | case 3: | 489 | case 3: |
490 | case 4: | 490 | case 4: |
491 | /* adpcm, compatible to ZyXel 1496 modem | 491 | /* adpcm, compatible to ZyXel 1496 modem |
492 | * with ROM revision 6.01 | 492 | * with ROM revision 6.01 |
493 | */ | 493 | */ |
494 | audio_len = isdn_audio_adpcm2xlaw(info->adpcms, | 494 | audio_len = isdn_audio_adpcm2xlaw(info->adpcms, |
495 | ifmt, | 495 | ifmt, |
496 | skb->data, | 496 | skb->data, |
497 | skb_put(skb, audio_len), | 497 | skb_put(skb, audio_len), |
498 | buflen); | 498 | buflen); |
499 | skb_pull(skb, buflen); | 499 | skb_pull(skb, buflen); |
500 | skb_trim(skb, audio_len); | 500 | skb_trim(skb, audio_len); |
501 | break; | 501 | break; |
502 | case 5: | 502 | case 5: |
503 | /* a-law */ | 503 | /* a-law */ |
504 | if (!ifmt) | 504 | if (!ifmt) |
505 | isdn_audio_alaw2ulaw(skb->data, | 505 | isdn_audio_alaw2ulaw(skb->data, |
506 | buflen); | 506 | buflen); |
507 | break; | 507 | break; |
508 | case 6: | 508 | case 6: |
509 | /* u-law */ | 509 | /* u-law */ |
510 | if (ifmt) | 510 | if (ifmt) |
511 | isdn_audio_ulaw2alaw(skb->data, | 511 | isdn_audio_ulaw2alaw(skb->data, |
512 | buflen); | 512 | buflen); |
513 | break; | 513 | break; |
514 | } | 514 | } |
515 | } | 515 | } |
516 | #endif /* CONFIG_ISDN_AUDIO */ | 516 | #endif /* CONFIG_ISDN_AUDIO */ |
@@ -550,7 +550,7 @@ isdn_tty_modem_do_ncarrier(unsigned long data) | |||
550 | * low. | 550 | * low. |
551 | */ | 551 | */ |
552 | static void | 552 | static void |
553 | isdn_tty_modem_ncarrier(modem_info * info) | 553 | isdn_tty_modem_ncarrier(modem_info *info) |
554 | { | 554 | { |
555 | if (info->ncarrier) { | 555 | if (info->ncarrier) { |
556 | info->nc_timer.expires = jiffies + HZ; | 556 | info->nc_timer.expires = jiffies + HZ; |
@@ -568,30 +568,30 @@ isdn_calc_usage(int si, int l2) | |||
568 | 568 | ||
569 | #ifdef CONFIG_ISDN_AUDIO | 569 | #ifdef CONFIG_ISDN_AUDIO |
570 | if (si == 1) { | 570 | if (si == 1) { |
571 | switch(l2) { | 571 | switch (l2) { |
572 | case ISDN_PROTO_L2_MODEM: | 572 | case ISDN_PROTO_L2_MODEM: |
573 | usg = ISDN_USAGE_MODEM; | 573 | usg = ISDN_USAGE_MODEM; |
574 | break; | 574 | break; |
575 | #ifdef CONFIG_ISDN_TTY_FAX | 575 | #ifdef CONFIG_ISDN_TTY_FAX |
576 | case ISDN_PROTO_L2_FAX: | 576 | case ISDN_PROTO_L2_FAX: |
577 | usg = ISDN_USAGE_FAX; | 577 | usg = ISDN_USAGE_FAX; |
578 | break; | 578 | break; |
579 | #endif | 579 | #endif |
580 | case ISDN_PROTO_L2_TRANS: | 580 | case ISDN_PROTO_L2_TRANS: |
581 | default: | 581 | default: |
582 | usg = ISDN_USAGE_VOICE; | 582 | usg = ISDN_USAGE_VOICE; |
583 | break; | 583 | break; |
584 | } | 584 | } |
585 | } | 585 | } |
586 | #endif | 586 | #endif |
587 | return(usg); | 587 | return (usg); |
588 | } | 588 | } |
589 | 589 | ||
590 | /* isdn_tty_dial() performs dialing of a tty an the necessary | 590 | /* isdn_tty_dial() performs dialing of a tty an the necessary |
591 | * setup of the lower levels before that. | 591 | * setup of the lower levels before that. |
592 | */ | 592 | */ |
593 | static void | 593 | static void |
594 | isdn_tty_dial(char *n, modem_info * info, atemu * m) | 594 | isdn_tty_dial(char *n, modem_info *info, atemu *m) |
595 | { | 595 | { |
596 | int usg = ISDN_USAGE_MODEM; | 596 | int usg = ISDN_USAGE_MODEM; |
597 | int si = 7; | 597 | int si = 7; |
@@ -608,10 +608,10 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) | |||
608 | } | 608 | } |
609 | usg = isdn_calc_usage(si, l2); | 609 | usg = isdn_calc_usage(si, l2); |
610 | #ifdef CONFIG_ISDN_AUDIO | 610 | #ifdef CONFIG_ISDN_AUDIO |
611 | if ((si == 1) && | 611 | if ((si == 1) && |
612 | (l2 != ISDN_PROTO_L2_MODEM) | 612 | (l2 != ISDN_PROTO_L2_MODEM) |
613 | #ifdef CONFIG_ISDN_TTY_FAX | 613 | #ifdef CONFIG_ISDN_TTY_FAX |
614 | && (l2 != ISDN_PROTO_L2_FAX) | 614 | && (l2 != ISDN_PROTO_L2_FAX) |
615 | #endif | 615 | #endif |
616 | ) { | 616 | ) { |
617 | l2 = ISDN_PROTO_L2_TRANS; | 617 | l2 = ISDN_PROTO_L2_TRANS; |
@@ -679,7 +679,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) | |||
679 | * and some cleanup is done also. | 679 | * and some cleanup is done also. |
680 | */ | 680 | */ |
681 | void | 681 | void |
682 | isdn_tty_modem_hup(modem_info * info, int local) | 682 | isdn_tty_modem_hup(modem_info *info, int local) |
683 | { | 683 | { |
684 | isdn_ctrl cmd; | 684 | isdn_ctrl cmd; |
685 | int di, ch; | 685 | int di, ch; |
@@ -723,7 +723,7 @@ isdn_tty_modem_hup(modem_info * info, int local) | |||
723 | info->adpcmr = NULL; | 723 | info->adpcmr = NULL; |
724 | #endif | 724 | #endif |
725 | if ((info->msr & UART_MSR_RI) && | 725 | if ((info->msr & UART_MSR_RI) && |
726 | (info->emu.mdmreg[REG_RUNG] & BIT_RUNG)) | 726 | (info->emu.mdmreg[REG_RUNG] & BIT_RUNG)) |
727 | isdn_tty_modem_result(RESULT_RUNG, info); | 727 | isdn_tty_modem_result(RESULT_RUNG, info); |
728 | info->msr &= ~(UART_MSR_DCD | UART_MSR_RI); | 728 | info->msr &= ~(UART_MSR_DCD | UART_MSR_RI); |
729 | info->lsr |= UART_LSR_TEMT; | 729 | info->lsr |= UART_LSR_TEMT; |
@@ -746,7 +746,7 @@ isdn_tty_modem_hup(modem_info * info, int local) | |||
746 | } | 746 | } |
747 | 747 | ||
748 | /* | 748 | /* |
749 | * Begin of a CAPI like interface, currently used only for | 749 | * Begin of a CAPI like interface, currently used only for |
750 | * supplementary service (CAPI 2.0 part III) | 750 | * supplementary service (CAPI 2.0 part III) |
751 | */ | 751 | */ |
752 | #include <linux/isdn/capicmd.h> | 752 | #include <linux/isdn/capicmd.h> |
@@ -754,16 +754,16 @@ isdn_tty_modem_hup(modem_info * info, int local) | |||
754 | 754 | ||
755 | int | 755 | int |
756 | isdn_tty_capi_facility(capi_msg *cm) { | 756 | isdn_tty_capi_facility(capi_msg *cm) { |
757 | return(-1); /* dummy */ | 757 | return (-1); /* dummy */ |
758 | } | 758 | } |
759 | 759 | ||
760 | /* isdn_tty_suspend() tries to suspend the current tty connection | 760 | /* isdn_tty_suspend() tries to suspend the current tty connection |
761 | */ | 761 | */ |
762 | static void | 762 | static void |
763 | isdn_tty_suspend(char *id, modem_info * info, atemu * m) | 763 | isdn_tty_suspend(char *id, modem_info *info, atemu *m) |
764 | { | 764 | { |
765 | isdn_ctrl cmd; | 765 | isdn_ctrl cmd; |
766 | 766 | ||
767 | int l; | 767 | int l; |
768 | 768 | ||
769 | if (!info) | 769 | if (!info) |
@@ -774,7 +774,7 @@ isdn_tty_suspend(char *id, modem_info * info, atemu * m) | |||
774 | #endif | 774 | #endif |
775 | l = strlen(id); | 775 | l = strlen(id); |
776 | if ((info->isdn_driver >= 0)) { | 776 | if ((info->isdn_driver >= 0)) { |
777 | cmd.parm.cmsg.Length = l+18; | 777 | cmd.parm.cmsg.Length = l + 18; |
778 | cmd.parm.cmsg.Command = CAPI_FACILITY; | 778 | cmd.parm.cmsg.Command = CAPI_FACILITY; |
779 | cmd.parm.cmsg.Subcommand = CAPI_REQ; | 779 | cmd.parm.cmsg.Subcommand = CAPI_REQ; |
780 | cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; | 780 | cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; |
@@ -800,7 +800,7 @@ isdn_tty_suspend(char *id, modem_info * info, atemu * m) | |||
800 | */ | 800 | */ |
801 | 801 | ||
802 | static void | 802 | static void |
803 | isdn_tty_resume(char *id, modem_info * info, atemu * m) | 803 | isdn_tty_resume(char *id, modem_info *info, atemu *m) |
804 | { | 804 | { |
805 | int usg = ISDN_USAGE_MODEM; | 805 | int usg = ISDN_USAGE_MODEM; |
806 | int si = 7; | 806 | int si = 7; |
@@ -819,10 +819,10 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) | |||
819 | } | 819 | } |
820 | usg = isdn_calc_usage(si, l2); | 820 | usg = isdn_calc_usage(si, l2); |
821 | #ifdef CONFIG_ISDN_AUDIO | 821 | #ifdef CONFIG_ISDN_AUDIO |
822 | if ((si == 1) && | 822 | if ((si == 1) && |
823 | (l2 != ISDN_PROTO_L2_MODEM) | 823 | (l2 != ISDN_PROTO_L2_MODEM) |
824 | #ifdef CONFIG_ISDN_TTY_FAX | 824 | #ifdef CONFIG_ISDN_TTY_FAX |
825 | && (l2 != ISDN_PROTO_L2_FAX) | 825 | && (l2 != ISDN_PROTO_L2_FAX) |
826 | #endif | 826 | #endif |
827 | ) { | 827 | ) { |
828 | l2 = ISDN_PROTO_L2_TRANS; | 828 | l2 = ISDN_PROTO_L2_TRANS; |
@@ -864,18 +864,18 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) | |||
864 | isdn_command(&cmd); | 864 | isdn_command(&cmd); |
865 | cmd.driver = info->isdn_driver; | 865 | cmd.driver = info->isdn_driver; |
866 | cmd.arg = info->isdn_channel; | 866 | cmd.arg = info->isdn_channel; |
867 | cmd.parm.cmsg.Length = l+18; | 867 | cmd.parm.cmsg.Length = l + 18; |
868 | cmd.parm.cmsg.Command = CAPI_FACILITY; | 868 | cmd.parm.cmsg.Command = CAPI_FACILITY; |
869 | cmd.parm.cmsg.Subcommand = CAPI_REQ; | 869 | cmd.parm.cmsg.Subcommand = CAPI_REQ; |
870 | cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; | 870 | cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; |
871 | cmd.parm.cmsg.para[0] = 3; /* 16 bit 0x0003 suplementary service */ | 871 | cmd.parm.cmsg.para[0] = 3; /* 16 bit 0x0003 suplementary service */ |
872 | cmd.parm.cmsg.para[1] = 0; | 872 | cmd.parm.cmsg.para[1] = 0; |
873 | cmd.parm.cmsg.para[2] = l+3; | 873 | cmd.parm.cmsg.para[2] = l + 3; |
874 | cmd.parm.cmsg.para[3] = 5; /* 16 bit 0x0005 Resume */ | 874 | cmd.parm.cmsg.para[3] = 5; /* 16 bit 0x0005 Resume */ |
875 | cmd.parm.cmsg.para[4] = 0; | 875 | cmd.parm.cmsg.para[4] = 0; |
876 | cmd.parm.cmsg.para[5] = l; | 876 | cmd.parm.cmsg.para[5] = l; |
877 | strncpy(&cmd.parm.cmsg.para[6], id, l); | 877 | strncpy(&cmd.parm.cmsg.para[6], id, l); |
878 | cmd.command =CAPI_PUT_MESSAGE; | 878 | cmd.command = CAPI_PUT_MESSAGE; |
879 | info->dialing = 1; | 879 | info->dialing = 1; |
880 | // strcpy(dev->num[i], n); | 880 | // strcpy(dev->num[i], n); |
881 | isdn_info_update(); | 881 | isdn_info_update(); |
@@ -889,7 +889,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) | |||
889 | */ | 889 | */ |
890 | 890 | ||
891 | static void | 891 | static void |
892 | isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) | 892 | isdn_tty_send_msg(modem_info *info, atemu *m, char *msg) |
893 | { | 893 | { |
894 | int usg = ISDN_USAGE_MODEM; | 894 | int usg = ISDN_USAGE_MODEM; |
895 | int si = 7; | 895 | int si = 7; |
@@ -912,10 +912,10 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) | |||
912 | } | 912 | } |
913 | usg = isdn_calc_usage(si, l2); | 913 | usg = isdn_calc_usage(si, l2); |
914 | #ifdef CONFIG_ISDN_AUDIO | 914 | #ifdef CONFIG_ISDN_AUDIO |
915 | if ((si == 1) && | 915 | if ((si == 1) && |
916 | (l2 != ISDN_PROTO_L2_MODEM) | 916 | (l2 != ISDN_PROTO_L2_MODEM) |
917 | #ifdef CONFIG_ISDN_TTY_FAX | 917 | #ifdef CONFIG_ISDN_TTY_FAX |
918 | && (l2 != ISDN_PROTO_L2_FAX) | 918 | && (l2 != ISDN_PROTO_L2_FAX) |
919 | #endif | 919 | #endif |
920 | ) { | 920 | ) { |
921 | l2 = ISDN_PROTO_L2_TRANS; | 921 | l2 = ISDN_PROTO_L2_TRANS; |
@@ -956,14 +956,14 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) | |||
956 | isdn_command(&cmd); | 956 | isdn_command(&cmd); |
957 | cmd.driver = info->isdn_driver; | 957 | cmd.driver = info->isdn_driver; |
958 | cmd.arg = info->isdn_channel; | 958 | cmd.arg = info->isdn_channel; |
959 | cmd.parm.cmsg.Length = l+14; | 959 | cmd.parm.cmsg.Length = l + 14; |
960 | cmd.parm.cmsg.Command = CAPI_MANUFACTURER; | 960 | cmd.parm.cmsg.Command = CAPI_MANUFACTURER; |
961 | cmd.parm.cmsg.Subcommand = CAPI_REQ; | 961 | cmd.parm.cmsg.Subcommand = CAPI_REQ; |
962 | cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; | 962 | cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; |
963 | cmd.parm.cmsg.para[0] = l+1; | 963 | cmd.parm.cmsg.para[0] = l + 1; |
964 | strncpy(&cmd.parm.cmsg.para[1], msg, l); | 964 | strncpy(&cmd.parm.cmsg.para[1], msg, l); |
965 | cmd.parm.cmsg.para[l+1] = 0xd; | 965 | cmd.parm.cmsg.para[l + 1] = 0xd; |
966 | cmd.command =CAPI_PUT_MESSAGE; | 966 | cmd.command = CAPI_PUT_MESSAGE; |
967 | /* info->dialing = 1; | 967 | /* info->dialing = 1; |
968 | strcpy(dev->num[i], n); | 968 | strcpy(dev->num[i], n); |
969 | isdn_info_update(); | 969 | isdn_info_update(); |
@@ -978,7 +978,7 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine) | |||
978 | #ifdef MODEM_PARANOIA_CHECK | 978 | #ifdef MODEM_PARANOIA_CHECK |
979 | if (!info) { | 979 | if (!info) { |
980 | printk(KERN_WARNING "isdn_tty: null info_struct for %s in %s\n", | 980 | printk(KERN_WARNING "isdn_tty: null info_struct for %s in %s\n", |
981 | name, routine); | 981 | name, routine); |
982 | return 1; | 982 | return 1; |
983 | } | 983 | } |
984 | if (info->magic != ISDN_ASYNC_MAGIC) { | 984 | if (info->magic != ISDN_ASYNC_MAGIC) { |
@@ -995,11 +995,11 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine) | |||
995 | * the specified baud rate for a serial port. | 995 | * the specified baud rate for a serial port. |
996 | */ | 996 | */ |
997 | static void | 997 | static void |
998 | isdn_tty_change_speed(modem_info * info) | 998 | isdn_tty_change_speed(modem_info *info) |
999 | { | 999 | { |
1000 | uint cflag, | 1000 | uint cflag, |
1001 | cval, | 1001 | cval, |
1002 | quot; | 1002 | quot; |
1003 | int i; | 1003 | int i; |
1004 | 1004 | ||
1005 | if (!info->tty || !info->tty->termios) | 1005 | if (!info->tty || !info->tty->termios) |
@@ -1051,7 +1051,7 @@ isdn_tty_change_speed(modem_info * info) | |||
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | static int | 1053 | static int |
1054 | isdn_tty_startup(modem_info * info) | 1054 | isdn_tty_startup(modem_info *info) |
1055 | { | 1055 | { |
1056 | if (info->flags & ISDN_ASYNC_INITIALIZED) | 1056 | if (info->flags & ISDN_ASYNC_INITIALIZED) |
1057 | return 0; | 1057 | return 0; |
@@ -1081,7 +1081,7 @@ isdn_tty_startup(modem_info * info) | |||
1081 | * DTR is dropped if the hangup on close termio flag is on. | 1081 | * DTR is dropped if the hangup on close termio flag is on. |
1082 | */ | 1082 | */ |
1083 | static void | 1083 | static void |
1084 | isdn_tty_shutdown(modem_info * info) | 1084 | isdn_tty_shutdown(modem_info *info) |
1085 | { | 1085 | { |
1086 | if (!(info->flags & ISDN_ASYNC_INITIALIZED)) | 1086 | if (!(info->flags & ISDN_ASYNC_INITIALIZED)) |
1087 | return; | 1087 | return; |
@@ -1116,7 +1116,7 @@ isdn_tty_shutdown(modem_info * info) | |||
1116 | * - If dialing, abort dial. | 1116 | * - If dialing, abort dial. |
1117 | */ | 1117 | */ |
1118 | static int | 1118 | static int |
1119 | isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count) | 1119 | isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count) |
1120 | { | 1120 | { |
1121 | int c; | 1121 | int c; |
1122 | int total = 0; | 1122 | int total = 0; |
@@ -1176,27 +1176,27 @@ isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count) | |||
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | } else | 1178 | } else |
1179 | if (TTY_IS_FCLASS1(info)) { | 1179 | if (TTY_IS_FCLASS1(info)) { |
1180 | int cc = isdn_tty_handleDLEdown(info, m, c); | 1180 | int cc = isdn_tty_handleDLEdown(info, m, c); |
1181 | 1181 | ||
1182 | if (info->vonline & 4) { /* ETX seen */ | 1182 | if (info->vonline & 4) { /* ETX seen */ |
1183 | isdn_ctrl c; | 1183 | isdn_ctrl c; |
1184 | 1184 | ||
1185 | c.command = ISDN_CMD_FAXCMD; | 1185 | c.command = ISDN_CMD_FAXCMD; |
1186 | c.driver = info->isdn_driver; | 1186 | c.driver = info->isdn_driver; |
1187 | c.arg = info->isdn_channel; | 1187 | c.arg = info->isdn_channel; |
1188 | c.parm.aux.cmd = ISDN_FAX_CLASS1_CTRL; | 1188 | c.parm.aux.cmd = ISDN_FAX_CLASS1_CTRL; |
1189 | c.parm.aux.subcmd = ETX; | 1189 | c.parm.aux.subcmd = ETX; |
1190 | isdn_command(&c); | 1190 | isdn_command(&c); |
1191 | } | 1191 | } |
1192 | info->vonline = 0; | 1192 | info->vonline = 0; |
1193 | #ifdef ISDN_DEBUG_MODEM_VOICE | 1193 | #ifdef ISDN_DEBUG_MODEM_VOICE |
1194 | printk(KERN_DEBUG "fax dle cc/c %d/%d\n", cc, c); | 1194 | printk(KERN_DEBUG "fax dle cc/c %d/%d\n", cc, c); |
1195 | #endif | 1195 | #endif |
1196 | info->xmit_count += cc; | 1196 | info->xmit_count += cc; |
1197 | } else | 1197 | } else |
1198 | #endif | 1198 | #endif |
1199 | info->xmit_count += c; | 1199 | info->xmit_count += c; |
1200 | } else { | 1200 | } else { |
1201 | info->msr |= UART_MSR_CTS; | 1201 | info->msr |= UART_MSR_CTS; |
1202 | info->lsr |= UART_LSR_TEMT; | 1202 | info->lsr |= UART_LSR_TEMT; |
@@ -1332,7 +1332,7 @@ isdn_tty_unthrottle(struct tty_struct *tty) | |||
1332 | * allows RS485 driver to be written in user space. | 1332 | * allows RS485 driver to be written in user space. |
1333 | */ | 1333 | */ |
1334 | static int | 1334 | static int |
1335 | isdn_tty_get_lsr_info(modem_info * info, uint __user * value) | 1335 | isdn_tty_get_lsr_info(modem_info *info, uint __user *value) |
1336 | { | 1336 | { |
1337 | u_char status; | 1337 | u_char status; |
1338 | uint result; | 1338 | uint result; |
@@ -1363,16 +1363,16 @@ isdn_tty_tiocmget(struct tty_struct *tty) | |||
1363 | status = info->msr; | 1363 | status = info->msr; |
1364 | mutex_unlock(&modem_info_mutex); | 1364 | mutex_unlock(&modem_info_mutex); |
1365 | return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) | 1365 | return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) |
1366 | | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | 1366 | | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) |
1367 | | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) | 1367 | | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) |
1368 | | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) | 1368 | | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) |
1369 | | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) | 1369 | | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) |
1370 | | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); | 1370 | | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | static int | 1373 | static int |
1374 | isdn_tty_tiocmset(struct tty_struct *tty, | 1374 | isdn_tty_tiocmset(struct tty_struct *tty, |
1375 | unsigned int set, unsigned int clear) | 1375 | unsigned int set, unsigned int clear) |
1376 | { | 1376 | { |
1377 | modem_info *info = (modem_info *) tty->driver_data; | 1377 | modem_info *info = (modem_info *) tty->driver_data; |
1378 | 1378 | ||
@@ -1422,34 +1422,34 @@ isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg) | |||
1422 | if (tty->flags & (1 << TTY_IO_ERROR)) | 1422 | if (tty->flags & (1 << TTY_IO_ERROR)) |
1423 | return -EIO; | 1423 | return -EIO; |
1424 | switch (cmd) { | 1424 | switch (cmd) { |
1425 | case TCSBRK: /* SVID version: non-zero arg --> no break */ | 1425 | case TCSBRK: /* SVID version: non-zero arg --> no break */ |
1426 | #ifdef ISDN_DEBUG_MODEM_IOCTL | 1426 | #ifdef ISDN_DEBUG_MODEM_IOCTL |
1427 | printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line); | 1427 | printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line); |
1428 | #endif | 1428 | #endif |
1429 | retval = tty_check_change(tty); | 1429 | retval = tty_check_change(tty); |
1430 | if (retval) | 1430 | if (retval) |
1431 | return retval; | 1431 | return retval; |
1432 | tty_wait_until_sent(tty, 0); | 1432 | tty_wait_until_sent(tty, 0); |
1433 | return 0; | 1433 | return 0; |
1434 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | 1434 | case TCSBRKP: /* support for POSIX tcsendbreak() */ |
1435 | #ifdef ISDN_DEBUG_MODEM_IOCTL | 1435 | #ifdef ISDN_DEBUG_MODEM_IOCTL |
1436 | printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line); | 1436 | printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line); |
1437 | #endif | 1437 | #endif |
1438 | retval = tty_check_change(tty); | 1438 | retval = tty_check_change(tty); |
1439 | if (retval) | 1439 | if (retval) |
1440 | return retval; | 1440 | return retval; |
1441 | tty_wait_until_sent(tty, 0); | 1441 | tty_wait_until_sent(tty, 0); |
1442 | return 0; | 1442 | return 0; |
1443 | case TIOCSERGETLSR: /* Get line status register */ | 1443 | case TIOCSERGETLSR: /* Get line status register */ |
1444 | #ifdef ISDN_DEBUG_MODEM_IOCTL | 1444 | #ifdef ISDN_DEBUG_MODEM_IOCTL |
1445 | printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); | 1445 | printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); |
1446 | #endif | 1446 | #endif |
1447 | return isdn_tty_get_lsr_info(info, (uint __user *) arg); | 1447 | return isdn_tty_get_lsr_info(info, (uint __user *) arg); |
1448 | default: | 1448 | default: |
1449 | #ifdef ISDN_DEBUG_MODEM_IOCTL | 1449 | #ifdef ISDN_DEBUG_MODEM_IOCTL |
1450 | printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line); | 1450 | printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line); |
1451 | #endif | 1451 | #endif |
1452 | return -ENOIOCTLCMD; | 1452 | return -ENOIOCTLCMD; |
1453 | } | 1453 | } |
1454 | return 0; | 1454 | return 0; |
1455 | } | 1455 | } |
@@ -1479,7 +1479,7 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1479 | * ------------------------------------------------------------ | 1479 | * ------------------------------------------------------------ |
1480 | */ | 1480 | */ |
1481 | static int | 1481 | static int |
1482 | isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * info) | 1482 | isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info) |
1483 | { | 1483 | { |
1484 | DECLARE_WAITQUEUE(wait, NULL); | 1484 | DECLARE_WAITQUEUE(wait, NULL); |
1485 | int do_clocal = 0; | 1485 | int do_clocal = 0; |
@@ -1603,7 +1603,7 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp) | |||
1603 | return -ENODEV; | 1603 | return -ENODEV; |
1604 | } | 1604 | } |
1605 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1605 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1606 | printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, | 1606 | printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, |
1607 | info->count); | 1607 | info->count); |
1608 | #endif | 1608 | #endif |
1609 | info->count++; | 1609 | info->count++; |
@@ -1703,7 +1703,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1703 | timeout = jiffies + HZ; | 1703 | timeout = jiffies + HZ; |
1704 | while (!(info->lsr & UART_LSR_TEMT)) { | 1704 | while (!(info->lsr & UART_LSR_TEMT)) { |
1705 | schedule_timeout_interruptible(20); | 1705 | schedule_timeout_interruptible(20); |
1706 | if (time_after(jiffies,timeout)) | 1706 | if (time_after(jiffies, timeout)) |
1707 | break; | 1707 | break; |
1708 | } | 1708 | } |
1709 | } | 1709 | } |
@@ -1746,7 +1746,7 @@ isdn_tty_hangup(struct tty_struct *tty) | |||
1746 | /* This routine initializes all emulator-data. | 1746 | /* This routine initializes all emulator-data. |
1747 | */ | 1747 | */ |
1748 | static void | 1748 | static void |
1749 | isdn_tty_reset_profile(atemu * m) | 1749 | isdn_tty_reset_profile(atemu *m) |
1750 | { | 1750 | { |
1751 | m->profile[0] = 0; | 1751 | m->profile[0] = 0; |
1752 | m->profile[1] = 0; | 1752 | m->profile[1] = 0; |
@@ -1776,7 +1776,7 @@ isdn_tty_reset_profile(atemu * m) | |||
1776 | 1776 | ||
1777 | #ifdef CONFIG_ISDN_AUDIO | 1777 | #ifdef CONFIG_ISDN_AUDIO |
1778 | static void | 1778 | static void |
1779 | isdn_tty_modem_reset_vpar(atemu * m) | 1779 | isdn_tty_modem_reset_vpar(atemu *m) |
1780 | { | 1780 | { |
1781 | m->vpar[0] = 2; /* Voice-device (2 = phone line) */ | 1781 | m->vpar[0] = 2; /* Voice-device (2 = phone line) */ |
1782 | m->vpar[1] = 0; /* Silence detection level (0 = none ) */ | 1782 | m->vpar[1] = 0; /* Silence detection level (0 = none ) */ |
@@ -1789,7 +1789,7 @@ isdn_tty_modem_reset_vpar(atemu * m) | |||
1789 | 1789 | ||
1790 | #ifdef CONFIG_ISDN_TTY_FAX | 1790 | #ifdef CONFIG_ISDN_TTY_FAX |
1791 | static void | 1791 | static void |
1792 | isdn_tty_modem_reset_faxpar(modem_info * info) | 1792 | isdn_tty_modem_reset_faxpar(modem_info *info) |
1793 | { | 1793 | { |
1794 | T30_s *f = info->fax; | 1794 | T30_s *f = info->fax; |
1795 | 1795 | ||
@@ -1822,7 +1822,7 @@ isdn_tty_modem_reset_faxpar(modem_info * info) | |||
1822 | #endif | 1822 | #endif |
1823 | 1823 | ||
1824 | static void | 1824 | static void |
1825 | isdn_tty_modem_reset_regs(modem_info * info, int force) | 1825 | isdn_tty_modem_reset_regs(modem_info *info, int force) |
1826 | { | 1826 | { |
1827 | atemu *m = &info->emu; | 1827 | atemu *m = &info->emu; |
1828 | if ((m->mdmreg[REG_DTRR] & BIT_DTRR) || force) { | 1828 | if ((m->mdmreg[REG_DTRR] & BIT_DTRR) || force) { |
@@ -1841,7 +1841,7 @@ isdn_tty_modem_reset_regs(modem_info * info, int force) | |||
1841 | } | 1841 | } |
1842 | 1842 | ||
1843 | static void | 1843 | static void |
1844 | modem_write_profile(atemu * m) | 1844 | modem_write_profile(atemu *m) |
1845 | { | 1845 | { |
1846 | memcpy(m->profile, m->mdmreg, ISDN_MODEM_NUMREG); | 1846 | memcpy(m->profile, m->mdmreg, ISDN_MODEM_NUMREG); |
1847 | memcpy(m->pmsn, m->msn, ISDN_MSNLEN); | 1847 | memcpy(m->pmsn, m->msn, ISDN_MSNLEN); |
@@ -1851,7 +1851,7 @@ modem_write_profile(atemu * m) | |||
1851 | } | 1851 | } |
1852 | 1852 | ||
1853 | static const struct tty_operations modem_ops = { | 1853 | static const struct tty_operations modem_ops = { |
1854 | .open = isdn_tty_open, | 1854 | .open = isdn_tty_open, |
1855 | .close = isdn_tty_close, | 1855 | .close = isdn_tty_close, |
1856 | .write = isdn_tty_write, | 1856 | .write = isdn_tty_write, |
1857 | .flush_chars = isdn_tty_flush_chars, | 1857 | .flush_chars = isdn_tty_flush_chars, |
@@ -1951,7 +1951,7 @@ err_unregister: | |||
1951 | kfree(info->xmit_buf - 4); | 1951 | kfree(info->xmit_buf - 4); |
1952 | } | 1952 | } |
1953 | tty_unregister_driver(m->tty_modem); | 1953 | tty_unregister_driver(m->tty_modem); |
1954 | err: | 1954 | err: |
1955 | put_tty_driver(m->tty_modem); | 1955 | put_tty_driver(m->tty_modem); |
1956 | m->tty_modem = NULL; | 1956 | m->tty_modem = NULL; |
1957 | return retval; | 1957 | return retval; |
@@ -2021,8 +2021,8 @@ isdn_tty_match_icall(char *cid, atemu *emu, int di) | |||
2021 | int tmp; | 2021 | int tmp; |
2022 | tmp = isdn_msncmp(cid, isdn_map_eaz2msn(emu->msn, di)); | 2022 | tmp = isdn_msncmp(cid, isdn_map_eaz2msn(emu->msn, di)); |
2023 | #ifdef ISDN_DEBUG_MODEM_ICALL | 2023 | #ifdef ISDN_DEBUG_MODEM_ICALL |
2024 | printk(KERN_DEBUG "m_fi: mmsn=%s -> tmp=%d\n", | 2024 | printk(KERN_DEBUG "m_fi: mmsn=%s -> tmp=%d\n", |
2025 | isdn_map_eaz2msn(emu->msn, di), tmp); | 2025 | isdn_map_eaz2msn(emu->msn, di), tmp); |
2026 | #endif | 2026 | #endif |
2027 | return tmp; | 2027 | return tmp; |
2028 | } | 2028 | } |
@@ -2071,8 +2071,8 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) | |||
2071 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 2071 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
2072 | modem_info *info = &dev->mdm.info[i]; | 2072 | modem_info *info = &dev->mdm.info[i]; |
2073 | 2073 | ||
2074 | if (info->count == 0) | 2074 | if (info->count == 0) |
2075 | continue; | 2075 | continue; |
2076 | if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */ | 2076 | if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */ |
2077 | (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */ | 2077 | (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */ |
2078 | idx = isdn_dc2minor(di, ch); | 2078 | idx = isdn_dc2minor(di, ch); |
@@ -2099,7 +2099,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) | |||
2099 | info->drv_index = idx; | 2099 | info->drv_index = idx; |
2100 | dev->m_idx[idx] = info->line; | 2100 | dev->m_idx[idx] = info->line; |
2101 | dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; | 2101 | dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; |
2102 | dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); | 2102 | dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); |
2103 | strcpy(dev->num[idx], nr); | 2103 | strcpy(dev->num[idx], nr); |
2104 | strcpy(info->emu.cpn, eaz); | 2104 | strcpy(info->emu.cpn, eaz); |
2105 | info->emu.mdmreg[REG_SI1I] = si2bit[si1]; | 2105 | info->emu.mdmreg[REG_SI1I] = si2bit[si1]; |
@@ -2119,11 +2119,11 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) | |||
2119 | } | 2119 | } |
2120 | spin_unlock_irqrestore(&dev->lock, flags); | 2120 | spin_unlock_irqrestore(&dev->lock, flags); |
2121 | printk(KERN_INFO "isdn_tty: call from %s -> %s %s\n", nr, eaz, | 2121 | printk(KERN_INFO "isdn_tty: call from %s -> %s %s\n", nr, eaz, |
2122 | ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2))? "rejected" : "ignored"); | 2122 | ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2)) ? "rejected" : "ignored"); |
2123 | return (wret == 2)?3:0; | 2123 | return (wret == 2) ? 3 : 0; |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | #define TTY_IS_ACTIVE(info) \ | 2126 | #define TTY_IS_ACTIVE(info) \ |
2127 | (info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE)) | 2127 | (info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE)) |
2128 | 2128 | ||
2129 | int | 2129 | int |
@@ -2138,174 +2138,174 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) | |||
2138 | if ((mi = dev->m_idx[i]) >= 0) { | 2138 | if ((mi = dev->m_idx[i]) >= 0) { |
2139 | info = &dev->mdm.info[mi]; | 2139 | info = &dev->mdm.info[mi]; |
2140 | switch (c->command) { | 2140 | switch (c->command) { |
2141 | case ISDN_STAT_CINF: | 2141 | case ISDN_STAT_CINF: |
2142 | printk(KERN_DEBUG "CHARGEINFO on ttyI%d: %ld %s\n", info->line, c->arg, c->parm.num); | 2142 | printk(KERN_DEBUG "CHARGEINFO on ttyI%d: %ld %s\n", info->line, c->arg, c->parm.num); |
2143 | info->emu.charge = (unsigned) simple_strtoul(c->parm.num, &e, 10); | 2143 | info->emu.charge = (unsigned) simple_strtoul(c->parm.num, &e, 10); |
2144 | if (e == (char *)c->parm.num) | 2144 | if (e == (char *)c->parm.num) |
2145 | info->emu.charge = 0; | 2145 | info->emu.charge = 0; |
2146 | 2146 | ||
2147 | break; | 2147 | break; |
2148 | case ISDN_STAT_BSENT: | 2148 | case ISDN_STAT_BSENT: |
2149 | #ifdef ISDN_TTY_STAT_DEBUG | ||
2150 | printk(KERN_DEBUG "tty_STAT_BSENT ttyI%d\n", info->line); | ||
2151 | #endif | ||
2152 | if ((info->isdn_driver == c->driver) && | ||
2153 | (info->isdn_channel == c->arg)) { | ||
2154 | info->msr |= UART_MSR_CTS; | ||
2155 | if (info->send_outstanding) | ||
2156 | if (!(--info->send_outstanding)) | ||
2157 | info->lsr |= UART_LSR_TEMT; | ||
2158 | isdn_tty_tint(info); | ||
2159 | return 1; | ||
2160 | } | ||
2161 | break; | ||
2162 | case ISDN_STAT_CAUSE: | ||
2163 | #ifdef ISDN_TTY_STAT_DEBUG | 2149 | #ifdef ISDN_TTY_STAT_DEBUG |
2164 | printk(KERN_DEBUG "tty_STAT_CAUSE ttyI%d\n", info->line); | 2150 | printk(KERN_DEBUG "tty_STAT_BSENT ttyI%d\n", info->line); |
2165 | #endif | 2151 | #endif |
2166 | /* Signal cause to tty-device */ | 2152 | if ((info->isdn_driver == c->driver) && |
2167 | strncpy(info->last_cause, c->parm.num, 5); | 2153 | (info->isdn_channel == c->arg)) { |
2154 | info->msr |= UART_MSR_CTS; | ||
2155 | if (info->send_outstanding) | ||
2156 | if (!(--info->send_outstanding)) | ||
2157 | info->lsr |= UART_LSR_TEMT; | ||
2158 | isdn_tty_tint(info); | ||
2168 | return 1; | 2159 | return 1; |
2169 | case ISDN_STAT_DISPLAY: | 2160 | } |
2161 | break; | ||
2162 | case ISDN_STAT_CAUSE: | ||
2170 | #ifdef ISDN_TTY_STAT_DEBUG | 2163 | #ifdef ISDN_TTY_STAT_DEBUG |
2171 | printk(KERN_DEBUG "tty_STAT_DISPLAY ttyI%d\n", info->line); | 2164 | printk(KERN_DEBUG "tty_STAT_CAUSE ttyI%d\n", info->line); |
2172 | #endif | 2165 | #endif |
2173 | /* Signal display to tty-device */ | 2166 | /* Signal cause to tty-device */ |
2174 | if ((info->emu.mdmreg[REG_DISPLAY] & BIT_DISPLAY) && | 2167 | strncpy(info->last_cause, c->parm.num, 5); |
2175 | !(info->emu.mdmreg[REG_RESPNUM] & BIT_RESPNUM)) { | 2168 | return 1; |
2176 | isdn_tty_at_cout("\r\n", info); | 2169 | case ISDN_STAT_DISPLAY: |
2177 | isdn_tty_at_cout("DISPLAY: ", info); | ||
2178 | isdn_tty_at_cout(c->parm.display, info); | ||
2179 | isdn_tty_at_cout("\r\n", info); | ||
2180 | } | ||
2181 | return 1; | ||
2182 | case ISDN_STAT_DCONN: | ||
2183 | #ifdef ISDN_TTY_STAT_DEBUG | 2170 | #ifdef ISDN_TTY_STAT_DEBUG |
2184 | printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); | 2171 | printk(KERN_DEBUG "tty_STAT_DISPLAY ttyI%d\n", info->line); |
2185 | #endif | 2172 | #endif |
2186 | if (TTY_IS_ACTIVE(info)) { | 2173 | /* Signal display to tty-device */ |
2187 | if (info->dialing == 1) { | 2174 | if ((info->emu.mdmreg[REG_DISPLAY] & BIT_DISPLAY) && |
2188 | info->dialing = 2; | 2175 | !(info->emu.mdmreg[REG_RESPNUM] & BIT_RESPNUM)) { |
2189 | return 1; | 2176 | isdn_tty_at_cout("\r\n", info); |
2190 | } | 2177 | isdn_tty_at_cout("DISPLAY: ", info); |
2178 | isdn_tty_at_cout(c->parm.display, info); | ||
2179 | isdn_tty_at_cout("\r\n", info); | ||
2180 | } | ||
2181 | return 1; | ||
2182 | case ISDN_STAT_DCONN: | ||
2183 | #ifdef ISDN_TTY_STAT_DEBUG | ||
2184 | printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); | ||
2185 | #endif | ||
2186 | if (TTY_IS_ACTIVE(info)) { | ||
2187 | if (info->dialing == 1) { | ||
2188 | info->dialing = 2; | ||
2189 | return 1; | ||
2191 | } | 2190 | } |
2192 | break; | 2191 | } |
2193 | case ISDN_STAT_DHUP: | 2192 | break; |
2193 | case ISDN_STAT_DHUP: | ||
2194 | #ifdef ISDN_TTY_STAT_DEBUG | 2194 | #ifdef ISDN_TTY_STAT_DEBUG |
2195 | printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line); | 2195 | printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line); |
2196 | #endif | 2196 | #endif |
2197 | if (TTY_IS_ACTIVE(info)) { | 2197 | if (TTY_IS_ACTIVE(info)) { |
2198 | if (info->dialing == 1) | 2198 | if (info->dialing == 1) |
2199 | isdn_tty_modem_result(RESULT_BUSY, info); | 2199 | isdn_tty_modem_result(RESULT_BUSY, info); |
2200 | if (info->dialing > 1) | 2200 | if (info->dialing > 1) |
2201 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); | 2201 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); |
2202 | info->dialing = 0; | 2202 | info->dialing = 0; |
2203 | #ifdef ISDN_DEBUG_MODEM_HUP | 2203 | #ifdef ISDN_DEBUG_MODEM_HUP |
2204 | printk(KERN_DEBUG "Mhup in ISDN_STAT_DHUP\n"); | 2204 | printk(KERN_DEBUG "Mhup in ISDN_STAT_DHUP\n"); |
2205 | #endif | 2205 | #endif |
2206 | isdn_tty_modem_hup(info, 0); | 2206 | isdn_tty_modem_hup(info, 0); |
2207 | return 1; | 2207 | return 1; |
2208 | } | 2208 | } |
2209 | break; | 2209 | break; |
2210 | case ISDN_STAT_BCONN: | 2210 | case ISDN_STAT_BCONN: |
2211 | #ifdef ISDN_TTY_STAT_DEBUG | 2211 | #ifdef ISDN_TTY_STAT_DEBUG |
2212 | printk(KERN_DEBUG "tty_STAT_BCONN ttyI%d\n", info->line); | 2212 | printk(KERN_DEBUG "tty_STAT_BCONN ttyI%d\n", info->line); |
2213 | #endif | 2213 | #endif |
2214 | /* Wake up any processes waiting | 2214 | /* Wake up any processes waiting |
2215 | * for incoming call of this device when | 2215 | * for incoming call of this device when |
2216 | * DCD follow the state of incoming carrier | 2216 | * DCD follow the state of incoming carrier |
2217 | */ | 2217 | */ |
2218 | if (info->blocked_open && | 2218 | if (info->blocked_open && |
2219 | (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { | 2219 | (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { |
2220 | wake_up_interruptible(&info->open_wait); | 2220 | wake_up_interruptible(&info->open_wait); |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | /* Schedule CONNECT-Message to any tty | 2223 | /* Schedule CONNECT-Message to any tty |
2224 | * waiting for it and | 2224 | * waiting for it and |
2225 | * set DCD-bit of its modem-status. | 2225 | * set DCD-bit of its modem-status. |
2226 | */ | 2226 | */ |
2227 | if (TTY_IS_ACTIVE(info) || | 2227 | if (TTY_IS_ACTIVE(info) || |
2228 | (info->blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { | 2228 | (info->blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { |
2229 | info->msr |= UART_MSR_DCD; | 2229 | info->msr |= UART_MSR_DCD; |
2230 | info->emu.charge = 0; | 2230 | info->emu.charge = 0; |
2231 | if (info->dialing & 0xf) | 2231 | if (info->dialing & 0xf) |
2232 | info->last_dir = 1; | 2232 | info->last_dir = 1; |
2233 | else | 2233 | else |
2234 | info->last_dir = 0; | 2234 | info->last_dir = 0; |
2235 | info->dialing = 0; | 2235 | info->dialing = 0; |
2236 | info->rcvsched = 1; | 2236 | info->rcvsched = 1; |
2237 | if (USG_MODEM(dev->usage[i])) { | 2237 | if (USG_MODEM(dev->usage[i])) { |
2238 | if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { | 2238 | if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { |
2239 | strcpy(info->emu.connmsg, c->parm.num); | 2239 | strcpy(info->emu.connmsg, c->parm.num); |
2240 | isdn_tty_modem_result(RESULT_CONNECT, info); | 2240 | isdn_tty_modem_result(RESULT_CONNECT, info); |
2241 | } else | 2241 | } else |
2242 | isdn_tty_modem_result(RESULT_CONNECT64000, info); | 2242 | isdn_tty_modem_result(RESULT_CONNECT64000, info); |
2243 | } | ||
2244 | if (USG_VOICE(dev->usage[i])) | ||
2245 | isdn_tty_modem_result(RESULT_VCON, info); | ||
2246 | return 1; | ||
2247 | } | 2243 | } |
2248 | break; | 2244 | if (USG_VOICE(dev->usage[i])) |
2249 | case ISDN_STAT_BHUP: | 2245 | isdn_tty_modem_result(RESULT_VCON, info); |
2246 | return 1; | ||
2247 | } | ||
2248 | break; | ||
2249 | case ISDN_STAT_BHUP: | ||
2250 | #ifdef ISDN_TTY_STAT_DEBUG | 2250 | #ifdef ISDN_TTY_STAT_DEBUG |
2251 | printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line); | 2251 | printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line); |
2252 | #endif | 2252 | #endif |
2253 | if (TTY_IS_ACTIVE(info)) { | 2253 | if (TTY_IS_ACTIVE(info)) { |
2254 | #ifdef ISDN_DEBUG_MODEM_HUP | 2254 | #ifdef ISDN_DEBUG_MODEM_HUP |
2255 | printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n"); | 2255 | printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n"); |
2256 | #endif | 2256 | #endif |
2257 | isdn_tty_modem_hup(info, 0); | 2257 | isdn_tty_modem_hup(info, 0); |
2258 | return 1; | 2258 | return 1; |
2259 | } | 2259 | } |
2260 | break; | 2260 | break; |
2261 | case ISDN_STAT_NODCH: | 2261 | case ISDN_STAT_NODCH: |
2262 | #ifdef ISDN_TTY_STAT_DEBUG | 2262 | #ifdef ISDN_TTY_STAT_DEBUG |
2263 | printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); | 2263 | printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); |
2264 | #endif | 2264 | #endif |
2265 | if (TTY_IS_ACTIVE(info)) { | 2265 | if (TTY_IS_ACTIVE(info)) { |
2266 | if (info->dialing) { | 2266 | if (info->dialing) { |
2267 | info->dialing = 0; | 2267 | info->dialing = 0; |
2268 | info->last_l2 = -1; | 2268 | info->last_l2 = -1; |
2269 | info->last_si = 0; | 2269 | info->last_si = 0; |
2270 | sprintf(info->last_cause, "0000"); | 2270 | sprintf(info->last_cause, "0000"); |
2271 | isdn_tty_modem_result(RESULT_NO_DIALTONE, info); | 2271 | isdn_tty_modem_result(RESULT_NO_DIALTONE, info); |
2272 | } | ||
2273 | isdn_tty_modem_hup(info, 0); | ||
2274 | return 1; | ||
2275 | } | 2272 | } |
2276 | break; | 2273 | isdn_tty_modem_hup(info, 0); |
2277 | case ISDN_STAT_UNLOAD: | 2274 | return 1; |
2275 | } | ||
2276 | break; | ||
2277 | case ISDN_STAT_UNLOAD: | ||
2278 | #ifdef ISDN_TTY_STAT_DEBUG | 2278 | #ifdef ISDN_TTY_STAT_DEBUG |
2279 | printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); | 2279 | printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); |
2280 | #endif | 2280 | #endif |
2281 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 2281 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
2282 | info = &dev->mdm.info[i]; | 2282 | info = &dev->mdm.info[i]; |
2283 | if (info->isdn_driver == c->driver) { | 2283 | if (info->isdn_driver == c->driver) { |
2284 | if (info->online) | 2284 | if (info->online) |
2285 | isdn_tty_modem_hup(info, 1); | 2285 | isdn_tty_modem_hup(info, 1); |
2286 | } | ||
2287 | } | 2286 | } |
2288 | return 1; | 2287 | } |
2288 | return 1; | ||
2289 | #ifdef CONFIG_ISDN_TTY_FAX | 2289 | #ifdef CONFIG_ISDN_TTY_FAX |
2290 | case ISDN_STAT_FAXIND: | 2290 | case ISDN_STAT_FAXIND: |
2291 | if (TTY_IS_ACTIVE(info)) { | 2291 | if (TTY_IS_ACTIVE(info)) { |
2292 | isdn_tty_fax_command(info, c); | 2292 | isdn_tty_fax_command(info, c); |
2293 | } | 2293 | } |
2294 | break; | 2294 | break; |
2295 | #endif | 2295 | #endif |
2296 | #ifdef CONFIG_ISDN_AUDIO | 2296 | #ifdef CONFIG_ISDN_AUDIO |
2297 | case ISDN_STAT_AUDIO: | 2297 | case ISDN_STAT_AUDIO: |
2298 | if (TTY_IS_ACTIVE(info)) { | 2298 | if (TTY_IS_ACTIVE(info)) { |
2299 | switch(c->parm.num[0]) { | 2299 | switch (c->parm.num[0]) { |
2300 | case ISDN_AUDIO_DTMF: | 2300 | case ISDN_AUDIO_DTMF: |
2301 | if (info->vonline) { | 2301 | if (info->vonline) { |
2302 | isdn_audio_put_dle_code(info, | 2302 | isdn_audio_put_dle_code(info, |
2303 | c->parm.num[1]); | 2303 | c->parm.num[1]); |
2304 | } | ||
2305 | break; | ||
2306 | } | 2304 | } |
2305 | break; | ||
2307 | } | 2306 | } |
2308 | break; | 2307 | } |
2308 | break; | ||
2309 | #endif | 2309 | #endif |
2310 | } | 2310 | } |
2311 | } | 2311 | } |
@@ -2314,16 +2314,16 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) | |||
2314 | 2314 | ||
2315 | /********************************************************************* | 2315 | /********************************************************************* |
2316 | Modem-Emulator-Routines | 2316 | Modem-Emulator-Routines |
2317 | *********************************************************************/ | 2317 | *********************************************************************/ |
2318 | 2318 | ||
2319 | #define cmdchar(c) ((c>=' ')&&(c<=0x7f)) | 2319 | #define cmdchar(c) ((c >= ' ') && (c <= 0x7f)) |
2320 | 2320 | ||
2321 | /* | 2321 | /* |
2322 | * Put a message from the AT-emulator into receive-buffer of tty, | 2322 | * Put a message from the AT-emulator into receive-buffer of tty, |
2323 | * convert CR, LF, and BS to values in modem-registers 3, 4 and 5. | 2323 | * convert CR, LF, and BS to values in modem-registers 3, 4 and 5. |
2324 | */ | 2324 | */ |
2325 | void | 2325 | void |
2326 | isdn_tty_at_cout(char *msg, modem_info * info) | 2326 | isdn_tty_at_cout(char *msg, modem_info *info) |
2327 | { | 2327 | { |
2328 | struct tty_struct *tty; | 2328 | struct tty_struct *tty; |
2329 | atemu *m = &info->emu; | 2329 | atemu *m = &info->emu; |
@@ -2351,7 +2351,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) | |||
2351 | /* use queue instead of direct, if online and */ | 2351 | /* use queue instead of direct, if online and */ |
2352 | /* data is in queue or buffer is full */ | 2352 | /* data is in queue or buffer is full */ |
2353 | if (info->online && ((tty_buffer_request_room(tty, l) < l) || | 2353 | if (info->online && ((tty_buffer_request_room(tty, l) < l) || |
2354 | !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { | 2354 | !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { |
2355 | skb = alloc_skb(l, GFP_ATOMIC); | 2355 | skb = alloc_skb(l, GFP_ATOMIC); |
2356 | if (!skb) { | 2356 | if (!skb) { |
2357 | spin_unlock_irqrestore(&info->readlock, flags); | 2357 | spin_unlock_irqrestore(&info->readlock, flags); |
@@ -2366,22 +2366,22 @@ isdn_tty_at_cout(char *msg, modem_info * info) | |||
2366 | 2366 | ||
2367 | for (p = msg; *p; p++) { | 2367 | for (p = msg; *p; p++) { |
2368 | switch (*p) { | 2368 | switch (*p) { |
2369 | case '\r': | 2369 | case '\r': |
2370 | c = m->mdmreg[REG_CR]; | 2370 | c = m->mdmreg[REG_CR]; |
2371 | break; | 2371 | break; |
2372 | case '\n': | 2372 | case '\n': |
2373 | c = m->mdmreg[REG_LF]; | 2373 | c = m->mdmreg[REG_LF]; |
2374 | break; | 2374 | break; |
2375 | case '\b': | 2375 | case '\b': |
2376 | c = m->mdmreg[REG_BS]; | 2376 | c = m->mdmreg[REG_BS]; |
2377 | break; | 2377 | break; |
2378 | default: | 2378 | default: |
2379 | c = *p; | 2379 | c = *p; |
2380 | } | 2380 | } |
2381 | if (skb) { | 2381 | if (skb) { |
2382 | *sp++ = c; | 2382 | *sp++ = c; |
2383 | } else { | 2383 | } else { |
2384 | if(tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) | 2384 | if (tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) |
2385 | break; | 2385 | break; |
2386 | } | 2386 | } |
2387 | } | 2387 | } |
@@ -2403,7 +2403,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) | |||
2403 | * Perform ATH Hangup | 2403 | * Perform ATH Hangup |
2404 | */ | 2404 | */ |
2405 | static void | 2405 | static void |
2406 | isdn_tty_on_hook(modem_info * info) | 2406 | isdn_tty_on_hook(modem_info *info) |
2407 | { | 2407 | { |
2408 | if (info->isdn_channel >= 0) { | 2408 | if (info->isdn_channel >= 0) { |
2409 | #ifdef ISDN_DEBUG_MODEM_HUP | 2409 | #ifdef ISDN_DEBUG_MODEM_HUP |
@@ -2419,8 +2419,8 @@ isdn_tty_off_hook(void) | |||
2419 | printk(KERN_DEBUG "isdn_tty_off_hook\n"); | 2419 | printk(KERN_DEBUG "isdn_tty_off_hook\n"); |
2420 | } | 2420 | } |
2421 | 2421 | ||
2422 | #define PLUSWAIT1 (HZ/2) /* 0.5 sec. */ | 2422 | #define PLUSWAIT1 (HZ / 2) /* 0.5 sec. */ |
2423 | #define PLUSWAIT2 (HZ*3/2) /* 1.5 sec */ | 2423 | #define PLUSWAIT2 (HZ * 3 / 2) /* 1.5 sec */ |
2424 | 2424 | ||
2425 | /* | 2425 | /* |
2426 | * Check Buffer for Modem-escape-sequence, activate timer-callback to | 2426 | * Check Buffer for Modem-escape-sequence, activate timer-callback to |
@@ -2434,7 +2434,7 @@ isdn_tty_off_hook(void) | |||
2434 | * lastplus timestamp of last character | 2434 | * lastplus timestamp of last character |
2435 | */ | 2435 | */ |
2436 | static void | 2436 | static void |
2437 | isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount, | 2437 | isdn_tty_check_esc(const u_char *p, u_char plus, int count, int *pluscount, |
2438 | u_long *lastplus) | 2438 | u_long *lastplus) |
2439 | { | 2439 | { |
2440 | if (plus > 127) | 2440 | if (plus > 127) |
@@ -2474,69 +2474,69 @@ isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount, | |||
2474 | */ | 2474 | */ |
2475 | 2475 | ||
2476 | static void | 2476 | static void |
2477 | isdn_tty_modem_result(int code, modem_info * info) | 2477 | isdn_tty_modem_result(int code, modem_info *info) |
2478 | { | 2478 | { |
2479 | atemu *m = &info->emu; | 2479 | atemu *m = &info->emu; |
2480 | static char *msg[] = | 2480 | static char *msg[] = |
2481 | {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR", | 2481 | {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR", |
2482 | "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER", | 2482 | "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER", |
2483 | "RINGING", "NO MSN/EAZ", "VCON", "RUNG"}; | 2483 | "RINGING", "NO MSN/EAZ", "VCON", "RUNG"}; |
2484 | char s[ISDN_MSNLEN+10]; | 2484 | char s[ISDN_MSNLEN + 10]; |
2485 | 2485 | ||
2486 | switch (code) { | 2486 | switch (code) { |
2487 | case RESULT_RING: | 2487 | case RESULT_RING: |
2488 | m->mdmreg[REG_RINGCNT]++; | 2488 | m->mdmreg[REG_RINGCNT]++; |
2489 | if (m->mdmreg[REG_RINGCNT] == m->mdmreg[REG_RINGATA]) | 2489 | if (m->mdmreg[REG_RINGCNT] == m->mdmreg[REG_RINGATA]) |
2490 | /* Automatically accept incoming call */ | 2490 | /* Automatically accept incoming call */ |
2491 | isdn_tty_cmd_ATA(info); | 2491 | isdn_tty_cmd_ATA(info); |
2492 | break; | 2492 | break; |
2493 | case RESULT_NO_CARRIER: | 2493 | case RESULT_NO_CARRIER: |
2494 | #ifdef ISDN_DEBUG_MODEM_HUP | 2494 | #ifdef ISDN_DEBUG_MODEM_HUP |
2495 | printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", | 2495 | printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", |
2496 | (info->flags & ISDN_ASYNC_CLOSING), | 2496 | (info->flags & ISDN_ASYNC_CLOSING), |
2497 | (!info->tty)); | 2497 | (!info->tty)); |
2498 | #endif | 2498 | #endif |
2499 | m->mdmreg[REG_RINGCNT] = 0; | 2499 | m->mdmreg[REG_RINGCNT] = 0; |
2500 | del_timer(&info->nc_timer); | 2500 | del_timer(&info->nc_timer); |
2501 | info->ncarrier = 0; | 2501 | info->ncarrier = 0; |
2502 | if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) { | 2502 | if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) { |
2503 | return; | 2503 | return; |
2504 | } | 2504 | } |
2505 | #ifdef CONFIG_ISDN_AUDIO | 2505 | #ifdef CONFIG_ISDN_AUDIO |
2506 | if (info->vonline & 1) { | 2506 | if (info->vonline & 1) { |
2507 | #ifdef ISDN_DEBUG_MODEM_VOICE | 2507 | #ifdef ISDN_DEBUG_MODEM_VOICE |
2508 | printk(KERN_DEBUG "res3: send DLE-ETX on ttyI%d\n", | 2508 | printk(KERN_DEBUG "res3: send DLE-ETX on ttyI%d\n", |
2509 | info->line); | 2509 | info->line); |
2510 | #endif | 2510 | #endif |
2511 | /* voice-recording, add DLE-ETX */ | 2511 | /* voice-recording, add DLE-ETX */ |
2512 | isdn_tty_at_cout("\020\003", info); | 2512 | isdn_tty_at_cout("\020\003", info); |
2513 | } | 2513 | } |
2514 | if (info->vonline & 2) { | 2514 | if (info->vonline & 2) { |
2515 | #ifdef ISDN_DEBUG_MODEM_VOICE | 2515 | #ifdef ISDN_DEBUG_MODEM_VOICE |
2516 | printk(KERN_DEBUG "res3: send DLE-DC4 on ttyI%d\n", | 2516 | printk(KERN_DEBUG "res3: send DLE-DC4 on ttyI%d\n", |
2517 | info->line); | 2517 | info->line); |
2518 | #endif | 2518 | #endif |
2519 | /* voice-playing, add DLE-DC4 */ | 2519 | /* voice-playing, add DLE-DC4 */ |
2520 | isdn_tty_at_cout("\020\024", info); | 2520 | isdn_tty_at_cout("\020\024", info); |
2521 | } | 2521 | } |
2522 | #endif | 2522 | #endif |
2523 | break; | 2523 | break; |
2524 | case RESULT_CONNECT: | 2524 | case RESULT_CONNECT: |
2525 | case RESULT_CONNECT64000: | 2525 | case RESULT_CONNECT64000: |
2526 | sprintf(info->last_cause, "0000"); | 2526 | sprintf(info->last_cause, "0000"); |
2527 | if (!info->online) | 2527 | if (!info->online) |
2528 | info->online = 2; | 2528 | info->online = 2; |
2529 | break; | 2529 | break; |
2530 | case RESULT_VCON: | 2530 | case RESULT_VCON: |
2531 | #ifdef ISDN_DEBUG_MODEM_VOICE | 2531 | #ifdef ISDN_DEBUG_MODEM_VOICE |
2532 | printk(KERN_DEBUG "res3: send VCON on ttyI%d\n", | 2532 | printk(KERN_DEBUG "res3: send VCON on ttyI%d\n", |
2533 | info->line); | 2533 | info->line); |
2534 | #endif | 2534 | #endif |
2535 | sprintf(info->last_cause, "0000"); | 2535 | sprintf(info->last_cause, "0000"); |
2536 | if (!info->online) | 2536 | if (!info->online) |
2537 | info->online = 1; | 2537 | info->online = 1; |
2538 | break; | 2538 | break; |
2539 | } /* switch(code) */ | 2539 | } /* switch (code) */ |
2540 | 2540 | ||
2541 | if (m->mdmreg[REG_RESP] & BIT_RESP) { | 2541 | if (m->mdmreg[REG_RESP] & BIT_RESP) { |
2542 | /* Show results */ | 2542 | /* Show results */ |
@@ -2546,87 +2546,87 @@ isdn_tty_modem_result(int code, modem_info * info) | |||
2546 | isdn_tty_at_cout(s, info); | 2546 | isdn_tty_at_cout(s, info); |
2547 | } else { | 2547 | } else { |
2548 | if (code == RESULT_RING) { | 2548 | if (code == RESULT_RING) { |
2549 | /* return if "show RUNG" and ringcounter>1 */ | 2549 | /* return if "show RUNG" and ringcounter>1 */ |
2550 | if ((m->mdmreg[REG_RUNG] & BIT_RUNG) && | 2550 | if ((m->mdmreg[REG_RUNG] & BIT_RUNG) && |
2551 | (m->mdmreg[REG_RINGCNT] > 1)) | 2551 | (m->mdmreg[REG_RINGCNT] > 1)) |
2552 | return; | 2552 | return; |
2553 | /* print CID, _before_ _every_ ring */ | 2553 | /* print CID, _before_ _every_ ring */ |
2554 | if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { | 2554 | if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { |
2555 | isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); | 2555 | isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); |
2556 | isdn_tty_at_cout(dev->num[info->drv_index], info); | 2556 | isdn_tty_at_cout(dev->num[info->drv_index], info); |
2557 | if (m->mdmreg[REG_CDN] & BIT_CDN) { | 2557 | if (m->mdmreg[REG_CDN] & BIT_CDN) { |
2558 | isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); | 2558 | isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); |
2559 | isdn_tty_at_cout(info->emu.cpn, info); | 2559 | isdn_tty_at_cout(info->emu.cpn, info); |
2560 | } | 2560 | } |
2561 | } | 2561 | } |
2562 | } | 2562 | } |
2563 | isdn_tty_at_cout("\r\n", info); | 2563 | isdn_tty_at_cout("\r\n", info); |
2564 | isdn_tty_at_cout(msg[code], info); | 2564 | isdn_tty_at_cout(msg[code], info); |
2565 | switch (code) { | 2565 | switch (code) { |
2566 | case RESULT_CONNECT: | 2566 | case RESULT_CONNECT: |
2567 | switch (m->mdmreg[REG_L2PROT]) { | 2567 | switch (m->mdmreg[REG_L2PROT]) { |
2568 | case ISDN_PROTO_L2_MODEM: | 2568 | case ISDN_PROTO_L2_MODEM: |
2569 | isdn_tty_at_cout(" ", info); | 2569 | isdn_tty_at_cout(" ", info); |
2570 | isdn_tty_at_cout(m->connmsg, info); | 2570 | isdn_tty_at_cout(m->connmsg, info); |
2571 | break; | ||
2572 | } | ||
2573 | break; | 2571 | break; |
2574 | case RESULT_RING: | 2572 | } |
2575 | /* Append CPN, if enabled */ | 2573 | break; |
2576 | if ((m->mdmreg[REG_CPN] & BIT_CPN)) { | 2574 | case RESULT_RING: |
2577 | sprintf(s, "/%s", m->cpn); | 2575 | /* Append CPN, if enabled */ |
2578 | isdn_tty_at_cout(s, info); | 2576 | if ((m->mdmreg[REG_CPN] & BIT_CPN)) { |
2579 | } | 2577 | sprintf(s, "/%s", m->cpn); |
2580 | /* Print CID only once, _after_ 1st RING */ | 2578 | isdn_tty_at_cout(s, info); |
2581 | if ((m->mdmreg[REG_CIDONCE] & BIT_CIDONCE) && | 2579 | } |
2582 | (m->mdmreg[REG_RINGCNT] == 1)) { | 2580 | /* Print CID only once, _after_ 1st RING */ |
2583 | isdn_tty_at_cout("\r\n", info); | 2581 | if ((m->mdmreg[REG_CIDONCE] & BIT_CIDONCE) && |
2584 | isdn_tty_at_cout("CALLER NUMBER: ", info); | 2582 | (m->mdmreg[REG_RINGCNT] == 1)) { |
2585 | isdn_tty_at_cout(dev->num[info->drv_index], info); | 2583 | isdn_tty_at_cout("\r\n", info); |
2586 | if (m->mdmreg[REG_CDN] & BIT_CDN) { | 2584 | isdn_tty_at_cout("CALLER NUMBER: ", info); |
2587 | isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); | 2585 | isdn_tty_at_cout(dev->num[info->drv_index], info); |
2588 | isdn_tty_at_cout(info->emu.cpn, info); | 2586 | if (m->mdmreg[REG_CDN] & BIT_CDN) { |
2589 | } | 2587 | isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); |
2588 | isdn_tty_at_cout(info->emu.cpn, info); | ||
2590 | } | 2589 | } |
2590 | } | ||
2591 | break; | ||
2592 | case RESULT_NO_CARRIER: | ||
2593 | case RESULT_NO_DIALTONE: | ||
2594 | case RESULT_BUSY: | ||
2595 | case RESULT_NO_ANSWER: | ||
2596 | m->mdmreg[REG_RINGCNT] = 0; | ||
2597 | /* Append Cause-Message if enabled */ | ||
2598 | if (m->mdmreg[REG_RESPXT] & BIT_RESPXT) { | ||
2599 | sprintf(s, "/%s", info->last_cause); | ||
2600 | isdn_tty_at_cout(s, info); | ||
2601 | } | ||
2602 | break; | ||
2603 | case RESULT_CONNECT64000: | ||
2604 | /* Append Protocol to CONNECT message */ | ||
2605 | switch (m->mdmreg[REG_L2PROT]) { | ||
2606 | case ISDN_PROTO_L2_X75I: | ||
2607 | case ISDN_PROTO_L2_X75UI: | ||
2608 | case ISDN_PROTO_L2_X75BUI: | ||
2609 | isdn_tty_at_cout("/X.75", info); | ||
2591 | break; | 2610 | break; |
2592 | case RESULT_NO_CARRIER: | 2611 | case ISDN_PROTO_L2_HDLC: |
2593 | case RESULT_NO_DIALTONE: | 2612 | isdn_tty_at_cout("/HDLC", info); |
2594 | case RESULT_BUSY: | ||
2595 | case RESULT_NO_ANSWER: | ||
2596 | m->mdmreg[REG_RINGCNT] = 0; | ||
2597 | /* Append Cause-Message if enabled */ | ||
2598 | if (m->mdmreg[REG_RESPXT] & BIT_RESPXT) { | ||
2599 | sprintf(s, "/%s", info->last_cause); | ||
2600 | isdn_tty_at_cout(s, info); | ||
2601 | } | ||
2602 | break; | 2613 | break; |
2603 | case RESULT_CONNECT64000: | 2614 | case ISDN_PROTO_L2_V11096: |
2604 | /* Append Protocol to CONNECT message */ | 2615 | isdn_tty_at_cout("/V110/9600", info); |
2605 | switch (m->mdmreg[REG_L2PROT]) { | 2616 | break; |
2606 | case ISDN_PROTO_L2_X75I: | 2617 | case ISDN_PROTO_L2_V11019: |
2607 | case ISDN_PROTO_L2_X75UI: | 2618 | isdn_tty_at_cout("/V110/19200", info); |
2608 | case ISDN_PROTO_L2_X75BUI: | 2619 | break; |
2609 | isdn_tty_at_cout("/X.75", info); | 2620 | case ISDN_PROTO_L2_V11038: |
2610 | break; | 2621 | isdn_tty_at_cout("/V110/38400", info); |
2611 | case ISDN_PROTO_L2_HDLC: | ||
2612 | isdn_tty_at_cout("/HDLC", info); | ||
2613 | break; | ||
2614 | case ISDN_PROTO_L2_V11096: | ||
2615 | isdn_tty_at_cout("/V110/9600", info); | ||
2616 | break; | ||
2617 | case ISDN_PROTO_L2_V11019: | ||
2618 | isdn_tty_at_cout("/V110/19200", info); | ||
2619 | break; | ||
2620 | case ISDN_PROTO_L2_V11038: | ||
2621 | isdn_tty_at_cout("/V110/38400", info); | ||
2622 | break; | ||
2623 | } | ||
2624 | if (m->mdmreg[REG_T70] & BIT_T70) { | ||
2625 | isdn_tty_at_cout("/T.70", info); | ||
2626 | if (m->mdmreg[REG_T70] & BIT_T70_EXT) | ||
2627 | isdn_tty_at_cout("+", info); | ||
2628 | } | ||
2629 | break; | 2622 | break; |
2623 | } | ||
2624 | if (m->mdmreg[REG_T70] & BIT_T70) { | ||
2625 | isdn_tty_at_cout("/T.70", info); | ||
2626 | if (m->mdmreg[REG_T70] & BIT_T70_EXT) | ||
2627 | isdn_tty_at_cout("+", info); | ||
2628 | } | ||
2629 | break; | ||
2630 | } | 2630 | } |
2631 | isdn_tty_at_cout("\r\n", info); | 2631 | isdn_tty_at_cout("\r\n", info); |
2632 | } | 2632 | } |
@@ -2648,7 +2648,7 @@ isdn_tty_modem_result(int code, modem_info * info) | |||
2648 | * Display a modem-register-value. | 2648 | * Display a modem-register-value. |
2649 | */ | 2649 | */ |
2650 | static void | 2650 | static void |
2651 | isdn_tty_show_profile(int ridx, modem_info * info) | 2651 | isdn_tty_show_profile(int ridx, modem_info *info) |
2652 | { | 2652 | { |
2653 | char v[6]; | 2653 | char v[6]; |
2654 | 2654 | ||
@@ -2667,7 +2667,7 @@ isdn_tty_get_msnstr(char *n, char **p) | |||
2667 | while (((*p[0] >= '0' && *p[0] <= '9') || | 2667 | while (((*p[0] >= '0' && *p[0] <= '9') || |
2668 | /* Why a comma ??? */ | 2668 | /* Why a comma ??? */ |
2669 | (*p[0] == ',') || (*p[0] == ':')) && | 2669 | (*p[0] == ',') || (*p[0] == ':')) && |
2670 | (limit--)) | 2670 | (limit--)) |
2671 | *n++ = *p[0]++; | 2671 | *n++ = *p[0]++; |
2672 | *n = '\0'; | 2672 | *n = '\0'; |
2673 | } | 2673 | } |
@@ -2676,20 +2676,20 @@ isdn_tty_get_msnstr(char *n, char **p) | |||
2676 | * Get phone-number from modem-commandbuffer | 2676 | * Get phone-number from modem-commandbuffer |
2677 | */ | 2677 | */ |
2678 | static void | 2678 | static void |
2679 | isdn_tty_getdial(char *p, char *q,int cnt) | 2679 | isdn_tty_getdial(char *p, char *q, int cnt) |
2680 | { | 2680 | { |
2681 | int first = 1; | 2681 | int first = 1; |
2682 | int limit = ISDN_MSNLEN - 1; /* MUST match the size of interface var to avoid | 2682 | int limit = ISDN_MSNLEN - 1; /* MUST match the size of interface var to avoid |
2683 | buffer overflow */ | 2683 | buffer overflow */ |
2684 | 2684 | ||
2685 | while (strchr(" 0123456789,#.*WPTSR-", *p) && *p && --cnt>0) { | 2685 | while (strchr(" 0123456789,#.*WPTSR-", *p) && *p && --cnt > 0) { |
2686 | if ((*p >= '0' && *p <= '9') || ((*p == 'S') && first) || | 2686 | if ((*p >= '0' && *p <= '9') || ((*p == 'S') && first) || |
2687 | ((*p == 'R') && first) || | 2687 | ((*p == 'R') && first) || |
2688 | (*p == '*') || (*p == '#')) { | 2688 | (*p == '*') || (*p == '#')) { |
2689 | *q++ = *p; | 2689 | *q++ = *p; |
2690 | limit--; | 2690 | limit--; |
2691 | } | 2691 | } |
2692 | if(!limit) | 2692 | if (!limit) |
2693 | break; | 2693 | break; |
2694 | p++; | 2694 | p++; |
2695 | first = 0; | 2695 | first = 0; |
@@ -2701,7 +2701,7 @@ isdn_tty_getdial(char *p, char *q,int cnt) | |||
2701 | #define PARSE_ERROR1 { isdn_tty_modem_result(RESULT_ERROR, info); return 1; } | 2701 | #define PARSE_ERROR1 { isdn_tty_modem_result(RESULT_ERROR, info); return 1; } |
2702 | 2702 | ||
2703 | static void | 2703 | static void |
2704 | isdn_tty_report(modem_info * info) | 2704 | isdn_tty_report(modem_info *info) |
2705 | { | 2705 | { |
2706 | atemu *m = &info->emu; | 2706 | atemu *m = &info->emu; |
2707 | char s[80]; | 2707 | char s[80]; |
@@ -2713,39 +2713,39 @@ isdn_tty_report(modem_info * info) | |||
2713 | isdn_tty_at_cout(s, info); | 2713 | isdn_tty_at_cout(s, info); |
2714 | isdn_tty_at_cout(" Layer-2 Protocol: ", info); | 2714 | isdn_tty_at_cout(" Layer-2 Protocol: ", info); |
2715 | switch (info->last_l2) { | 2715 | switch (info->last_l2) { |
2716 | case ISDN_PROTO_L2_X75I: | 2716 | case ISDN_PROTO_L2_X75I: |
2717 | isdn_tty_at_cout("X.75i", info); | 2717 | isdn_tty_at_cout("X.75i", info); |
2718 | break; | 2718 | break; |
2719 | case ISDN_PROTO_L2_X75UI: | 2719 | case ISDN_PROTO_L2_X75UI: |
2720 | isdn_tty_at_cout("X.75ui", info); | 2720 | isdn_tty_at_cout("X.75ui", info); |
2721 | break; | 2721 | break; |
2722 | case ISDN_PROTO_L2_X75BUI: | 2722 | case ISDN_PROTO_L2_X75BUI: |
2723 | isdn_tty_at_cout("X.75bui", info); | 2723 | isdn_tty_at_cout("X.75bui", info); |
2724 | break; | 2724 | break; |
2725 | case ISDN_PROTO_L2_HDLC: | 2725 | case ISDN_PROTO_L2_HDLC: |
2726 | isdn_tty_at_cout("HDLC", info); | 2726 | isdn_tty_at_cout("HDLC", info); |
2727 | break; | 2727 | break; |
2728 | case ISDN_PROTO_L2_V11096: | 2728 | case ISDN_PROTO_L2_V11096: |
2729 | isdn_tty_at_cout("V.110 9600 Baud", info); | 2729 | isdn_tty_at_cout("V.110 9600 Baud", info); |
2730 | break; | 2730 | break; |
2731 | case ISDN_PROTO_L2_V11019: | 2731 | case ISDN_PROTO_L2_V11019: |
2732 | isdn_tty_at_cout("V.110 19200 Baud", info); | 2732 | isdn_tty_at_cout("V.110 19200 Baud", info); |
2733 | break; | 2733 | break; |
2734 | case ISDN_PROTO_L2_V11038: | 2734 | case ISDN_PROTO_L2_V11038: |
2735 | isdn_tty_at_cout("V.110 38400 Baud", info); | 2735 | isdn_tty_at_cout("V.110 38400 Baud", info); |
2736 | break; | 2736 | break; |
2737 | case ISDN_PROTO_L2_TRANS: | 2737 | case ISDN_PROTO_L2_TRANS: |
2738 | isdn_tty_at_cout("transparent", info); | 2738 | isdn_tty_at_cout("transparent", info); |
2739 | break; | 2739 | break; |
2740 | case ISDN_PROTO_L2_MODEM: | 2740 | case ISDN_PROTO_L2_MODEM: |
2741 | isdn_tty_at_cout("modem", info); | 2741 | isdn_tty_at_cout("modem", info); |
2742 | break; | 2742 | break; |
2743 | case ISDN_PROTO_L2_FAX: | 2743 | case ISDN_PROTO_L2_FAX: |
2744 | isdn_tty_at_cout("fax", info); | 2744 | isdn_tty_at_cout("fax", info); |
2745 | break; | 2745 | break; |
2746 | default: | 2746 | default: |
2747 | isdn_tty_at_cout("unknown", info); | 2747 | isdn_tty_at_cout("unknown", info); |
2748 | break; | 2748 | break; |
2749 | } | 2749 | } |
2750 | if (m->mdmreg[REG_T70] & BIT_T70) { | 2750 | if (m->mdmreg[REG_T70] & BIT_T70) { |
2751 | isdn_tty_at_cout("/T.70", info); | 2751 | isdn_tty_at_cout("/T.70", info); |
@@ -2755,19 +2755,19 @@ isdn_tty_report(modem_info * info) | |||
2755 | isdn_tty_at_cout("\r\n", info); | 2755 | isdn_tty_at_cout("\r\n", info); |
2756 | isdn_tty_at_cout(" Service: ", info); | 2756 | isdn_tty_at_cout(" Service: ", info); |
2757 | switch (info->last_si) { | 2757 | switch (info->last_si) { |
2758 | case 1: | 2758 | case 1: |
2759 | isdn_tty_at_cout("audio\r\n", info); | 2759 | isdn_tty_at_cout("audio\r\n", info); |
2760 | break; | 2760 | break; |
2761 | case 5: | 2761 | case 5: |
2762 | isdn_tty_at_cout("btx\r\n", info); | 2762 | isdn_tty_at_cout("btx\r\n", info); |
2763 | break; | 2763 | break; |
2764 | case 7: | 2764 | case 7: |
2765 | isdn_tty_at_cout("data\r\n", info); | 2765 | isdn_tty_at_cout("data\r\n", info); |
2766 | break; | 2766 | break; |
2767 | default: | 2767 | default: |
2768 | sprintf(s, "%d\r\n", info->last_si); | 2768 | sprintf(s, "%d\r\n", info->last_si); |
2769 | isdn_tty_at_cout(s, info); | 2769 | isdn_tty_at_cout(s, info); |
2770 | break; | 2770 | break; |
2771 | } | 2771 | } |
2772 | sprintf(s, " Hangup location: %s\r\n", info->last_lhup ? "local" : "remote"); | 2772 | sprintf(s, " Hangup location: %s\r\n", info->last_lhup ? "local" : "remote"); |
2773 | isdn_tty_at_cout(s, info); | 2773 | isdn_tty_at_cout(s, info); |
@@ -2779,7 +2779,7 @@ isdn_tty_report(modem_info * info) | |||
2779 | * Parse AT&.. commands. | 2779 | * Parse AT&.. commands. |
2780 | */ | 2780 | */ |
2781 | static int | 2781 | static int |
2782 | isdn_tty_cmd_ATand(char **p, modem_info * info) | 2782 | isdn_tty_cmd_ATand(char **p, modem_info *info) |
2783 | { | 2783 | { |
2784 | atemu *m = &info->emu; | 2784 | atemu *m = &info->emu; |
2785 | int i; | 2785 | int i; |
@@ -2788,224 +2788,224 @@ isdn_tty_cmd_ATand(char **p, modem_info * info) | |||
2788 | #define MAXRB (sizeof(rb) - 1) | 2788 | #define MAXRB (sizeof(rb) - 1) |
2789 | 2789 | ||
2790 | switch (*p[0]) { | 2790 | switch (*p[0]) { |
2791 | case 'B': | 2791 | case 'B': |
2792 | /* &B - Set Buffersize */ | 2792 | /* &B - Set Buffersize */ |
2793 | p[0]++; | 2793 | p[0]++; |
2794 | i = isdn_getnum(p); | 2794 | i = isdn_getnum(p); |
2795 | if ((i < 0) || (i > ISDN_SERIAL_XMIT_MAX)) | 2795 | if ((i < 0) || (i > ISDN_SERIAL_XMIT_MAX)) |
2796 | PARSE_ERROR1; | 2796 | PARSE_ERROR1; |
2797 | #ifdef CONFIG_ISDN_AUDIO | 2797 | #ifdef CONFIG_ISDN_AUDIO |
2798 | if ((m->mdmreg[REG_SI1] & 1) && (i > VBUF)) | 2798 | if ((m->mdmreg[REG_SI1] & 1) && (i > VBUF)) |
2799 | PARSE_ERROR1; | 2799 | PARSE_ERROR1; |
2800 | #endif | 2800 | #endif |
2801 | m->mdmreg[REG_PSIZE] = i / 16; | 2801 | m->mdmreg[REG_PSIZE] = i / 16; |
2802 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16; | 2802 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16; |
2803 | switch (m->mdmreg[REG_L2PROT]) { | 2803 | switch (m->mdmreg[REG_L2PROT]) { |
2804 | case ISDN_PROTO_L2_V11096: | 2804 | case ISDN_PROTO_L2_V11096: |
2805 | case ISDN_PROTO_L2_V11019: | 2805 | case ISDN_PROTO_L2_V11019: |
2806 | case ISDN_PROTO_L2_V11038: | 2806 | case ISDN_PROTO_L2_V11038: |
2807 | info->xmit_size /= 10; | 2807 | info->xmit_size /= 10; |
2808 | } | 2808 | } |
2809 | break; | ||
2810 | case 'C': | ||
2811 | /* &C - DCD Status */ | ||
2812 | p[0]++; | ||
2813 | switch (isdn_getnum(p)) { | ||
2814 | case 0: | ||
2815 | m->mdmreg[REG_DCD] &= ~BIT_DCD; | ||
2809 | break; | 2816 | break; |
2810 | case 'C': | 2817 | case 1: |
2811 | /* &C - DCD Status */ | 2818 | m->mdmreg[REG_DCD] |= BIT_DCD; |
2812 | p[0]++; | ||
2813 | switch (isdn_getnum(p)) { | ||
2814 | case 0: | ||
2815 | m->mdmreg[REG_DCD] &= ~BIT_DCD; | ||
2816 | break; | ||
2817 | case 1: | ||
2818 | m->mdmreg[REG_DCD] |= BIT_DCD; | ||
2819 | break; | ||
2820 | default: | ||
2821 | PARSE_ERROR1 | ||
2822 | } | ||
2823 | break; | 2819 | break; |
2824 | case 'D': | 2820 | default: |
2825 | /* &D - Set DTR-Low-behavior */ | 2821 | PARSE_ERROR1 |
2826 | p[0]++; | 2822 | } |
2827 | switch (isdn_getnum(p)) { | 2823 | break; |
2828 | case 0: | 2824 | case 'D': |
2829 | m->mdmreg[REG_DTRHUP] &= ~BIT_DTRHUP; | 2825 | /* &D - Set DTR-Low-behavior */ |
2830 | m->mdmreg[REG_DTRR] &= ~BIT_DTRR; | 2826 | p[0]++; |
2831 | break; | 2827 | switch (isdn_getnum(p)) { |
2832 | case 2: | 2828 | case 0: |
2833 | m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; | 2829 | m->mdmreg[REG_DTRHUP] &= ~BIT_DTRHUP; |
2834 | m->mdmreg[REG_DTRR] &= ~BIT_DTRR; | 2830 | m->mdmreg[REG_DTRR] &= ~BIT_DTRR; |
2835 | break; | ||
2836 | case 3: | ||
2837 | m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; | ||
2838 | m->mdmreg[REG_DTRR] |= BIT_DTRR; | ||
2839 | break; | ||
2840 | default: | ||
2841 | PARSE_ERROR1 | ||
2842 | } | ||
2843 | break; | 2831 | break; |
2844 | case 'E': | 2832 | case 2: |
2845 | /* &E -Set EAZ/MSN */ | 2833 | m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; |
2846 | p[0]++; | 2834 | m->mdmreg[REG_DTRR] &= ~BIT_DTRR; |
2847 | isdn_tty_get_msnstr(m->msn, p); | ||
2848 | break; | 2835 | break; |
2849 | case 'F': | 2836 | case 3: |
2850 | /* &F -Set Factory-Defaults */ | 2837 | m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; |
2851 | p[0]++; | 2838 | m->mdmreg[REG_DTRR] |= BIT_DTRR; |
2852 | if (info->msr & UART_MSR_DCD) | ||
2853 | PARSE_ERROR1; | ||
2854 | isdn_tty_reset_profile(m); | ||
2855 | isdn_tty_modem_reset_regs(info, 1); | ||
2856 | break; | 2839 | break; |
2840 | default: | ||
2841 | PARSE_ERROR1 | ||
2842 | } | ||
2843 | break; | ||
2844 | case 'E': | ||
2845 | /* &E -Set EAZ/MSN */ | ||
2846 | p[0]++; | ||
2847 | isdn_tty_get_msnstr(m->msn, p); | ||
2848 | break; | ||
2849 | case 'F': | ||
2850 | /* &F -Set Factory-Defaults */ | ||
2851 | p[0]++; | ||
2852 | if (info->msr & UART_MSR_DCD) | ||
2853 | PARSE_ERROR1; | ||
2854 | isdn_tty_reset_profile(m); | ||
2855 | isdn_tty_modem_reset_regs(info, 1); | ||
2856 | break; | ||
2857 | #ifdef DUMMY_HAYES_AT | 2857 | #ifdef DUMMY_HAYES_AT |
2858 | case 'K': | 2858 | case 'K': |
2859 | /* only for be compilant with common scripts */ | 2859 | /* only for be compilant with common scripts */ |
2860 | /* &K Flowcontrol - no function */ | 2860 | /* &K Flowcontrol - no function */ |
2861 | p[0]++; | 2861 | p[0]++; |
2862 | isdn_getnum(p); | 2862 | isdn_getnum(p); |
2863 | break; | ||
2864 | #endif | ||
2865 | case 'L': | ||
2866 | /* &L -Set Numbers to listen on */ | ||
2867 | p[0]++; | ||
2868 | i = 0; | ||
2869 | while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) && | ||
2870 | (i < ISDN_LMSNLEN - 1)) | ||
2871 | m->lmsn[i++] = *p[0]++; | ||
2872 | m->lmsn[i] = '\0'; | ||
2873 | break; | ||
2874 | case 'R': | ||
2875 | /* &R - Set V.110 bitrate adaption */ | ||
2876 | p[0]++; | ||
2877 | i = isdn_getnum(p); | ||
2878 | switch (i) { | ||
2879 | case 0: | ||
2880 | /* Switch off V.110, back to X.75 */ | ||
2881 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; | ||
2882 | m->mdmreg[REG_SI2] = 0; | ||
2883 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16; | ||
2863 | break; | 2884 | break; |
2864 | #endif | 2885 | case 9600: |
2865 | case 'L': | 2886 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11096; |
2866 | /* &L -Set Numbers to listen on */ | 2887 | m->mdmreg[REG_SI2] = 197; |
2867 | p[0]++; | 2888 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; |
2868 | i = 0; | ||
2869 | while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) && | ||
2870 | (i < ISDN_LMSNLEN - 1)) | ||
2871 | m->lmsn[i++] = *p[0]++; | ||
2872 | m->lmsn[i] = '\0'; | ||
2873 | break; | ||
2874 | case 'R': | ||
2875 | /* &R - Set V.110 bitrate adaption */ | ||
2876 | p[0]++; | ||
2877 | i = isdn_getnum(p); | ||
2878 | switch (i) { | ||
2879 | case 0: | ||
2880 | /* Switch off V.110, back to X.75 */ | ||
2881 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; | ||
2882 | m->mdmreg[REG_SI2] = 0; | ||
2883 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16; | ||
2884 | break; | ||
2885 | case 9600: | ||
2886 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11096; | ||
2887 | m->mdmreg[REG_SI2] = 197; | ||
2888 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; | ||
2889 | break; | ||
2890 | case 19200: | ||
2891 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11019; | ||
2892 | m->mdmreg[REG_SI2] = 199; | ||
2893 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; | ||
2894 | break; | ||
2895 | case 38400: | ||
2896 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11038; | ||
2897 | m->mdmreg[REG_SI2] = 198; /* no existing standard for this */ | ||
2898 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; | ||
2899 | break; | ||
2900 | default: | ||
2901 | PARSE_ERROR1; | ||
2902 | } | ||
2903 | /* Switch off T.70 */ | ||
2904 | m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); | ||
2905 | /* Set Service 7 */ | ||
2906 | m->mdmreg[REG_SI1] |= 4; | ||
2907 | break; | 2889 | break; |
2908 | case 'S': | 2890 | case 19200: |
2909 | /* &S - Set Windowsize */ | 2891 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11019; |
2910 | p[0]++; | 2892 | m->mdmreg[REG_SI2] = 199; |
2911 | i = isdn_getnum(p); | 2893 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; |
2912 | if ((i > 0) && (i < 9)) | ||
2913 | m->mdmreg[REG_WSIZE] = i; | ||
2914 | else | ||
2915 | PARSE_ERROR1; | ||
2916 | break; | 2894 | break; |
2917 | case 'V': | 2895 | case 38400: |
2918 | /* &V - Show registers */ | 2896 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11038; |
2919 | p[0]++; | 2897 | m->mdmreg[REG_SI2] = 198; /* no existing standard for this */ |
2920 | isdn_tty_at_cout("\r\n", info); | 2898 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; |
2921 | for (i = 0; i < ISDN_MODEM_NUMREG; i++) { | ||
2922 | sprintf(rb, "S%02d=%03d%s", i, | ||
2923 | m->mdmreg[i], ((i + 1) % 10) ? " " : "\r\n"); | ||
2924 | isdn_tty_at_cout(rb, info); | ||
2925 | } | ||
2926 | sprintf(rb, "\r\nEAZ/MSN: %.50s\r\n", | ||
2927 | strlen(m->msn) ? m->msn : "None"); | ||
2928 | isdn_tty_at_cout(rb, info); | ||
2929 | if (strlen(m->lmsn)) { | ||
2930 | isdn_tty_at_cout("\r\nListen: ", info); | ||
2931 | isdn_tty_at_cout(m->lmsn, info); | ||
2932 | isdn_tty_at_cout("\r\n", info); | ||
2933 | } | ||
2934 | break; | 2899 | break; |
2935 | case 'W': | 2900 | default: |
2936 | /* &W - Write Profile */ | 2901 | PARSE_ERROR1; |
2902 | } | ||
2903 | /* Switch off T.70 */ | ||
2904 | m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); | ||
2905 | /* Set Service 7 */ | ||
2906 | m->mdmreg[REG_SI1] |= 4; | ||
2907 | break; | ||
2908 | case 'S': | ||
2909 | /* &S - Set Windowsize */ | ||
2910 | p[0]++; | ||
2911 | i = isdn_getnum(p); | ||
2912 | if ((i > 0) && (i < 9)) | ||
2913 | m->mdmreg[REG_WSIZE] = i; | ||
2914 | else | ||
2915 | PARSE_ERROR1; | ||
2916 | break; | ||
2917 | case 'V': | ||
2918 | /* &V - Show registers */ | ||
2919 | p[0]++; | ||
2920 | isdn_tty_at_cout("\r\n", info); | ||
2921 | for (i = 0; i < ISDN_MODEM_NUMREG; i++) { | ||
2922 | sprintf(rb, "S%02d=%03d%s", i, | ||
2923 | m->mdmreg[i], ((i + 1) % 10) ? " " : "\r\n"); | ||
2924 | isdn_tty_at_cout(rb, info); | ||
2925 | } | ||
2926 | sprintf(rb, "\r\nEAZ/MSN: %.50s\r\n", | ||
2927 | strlen(m->msn) ? m->msn : "None"); | ||
2928 | isdn_tty_at_cout(rb, info); | ||
2929 | if (strlen(m->lmsn)) { | ||
2930 | isdn_tty_at_cout("\r\nListen: ", info); | ||
2931 | isdn_tty_at_cout(m->lmsn, info); | ||
2932 | isdn_tty_at_cout("\r\n", info); | ||
2933 | } | ||
2934 | break; | ||
2935 | case 'W': | ||
2936 | /* &W - Write Profile */ | ||
2937 | p[0]++; | ||
2938 | switch (*p[0]) { | ||
2939 | case '0': | ||
2937 | p[0]++; | 2940 | p[0]++; |
2938 | switch (*p[0]) { | 2941 | modem_write_profile(m); |
2939 | case '0': | ||
2940 | p[0]++; | ||
2941 | modem_write_profile(m); | ||
2942 | break; | ||
2943 | default: | ||
2944 | PARSE_ERROR1; | ||
2945 | } | ||
2946 | break; | 2942 | break; |
2947 | case 'X': | 2943 | default: |
2948 | /* &X - Switch to BTX-Mode and T.70 */ | 2944 | PARSE_ERROR1; |
2949 | p[0]++; | 2945 | } |
2950 | switch (isdn_getnum(p)) { | 2946 | break; |
2951 | case 0: | 2947 | case 'X': |
2952 | m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); | 2948 | /* &X - Switch to BTX-Mode and T.70 */ |
2953 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16; | 2949 | p[0]++; |
2954 | break; | 2950 | switch (isdn_getnum(p)) { |
2955 | case 1: | 2951 | case 0: |
2956 | m->mdmreg[REG_T70] |= BIT_T70; | 2952 | m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); |
2957 | m->mdmreg[REG_T70] &= ~BIT_T70_EXT; | 2953 | info->xmit_size = m->mdmreg[REG_PSIZE] * 16; |
2958 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; | 2954 | break; |
2959 | info->xmit_size = 112; | 2955 | case 1: |
2960 | m->mdmreg[REG_SI1] = 4; | 2956 | m->mdmreg[REG_T70] |= BIT_T70; |
2961 | m->mdmreg[REG_SI2] = 0; | 2957 | m->mdmreg[REG_T70] &= ~BIT_T70_EXT; |
2962 | break; | 2958 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; |
2963 | case 2: | 2959 | info->xmit_size = 112; |
2964 | m->mdmreg[REG_T70] |= (BIT_T70 | BIT_T70_EXT); | 2960 | m->mdmreg[REG_SI1] = 4; |
2965 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; | 2961 | m->mdmreg[REG_SI2] = 0; |
2966 | info->xmit_size = 112; | 2962 | break; |
2967 | m->mdmreg[REG_SI1] = 4; | 2963 | case 2: |
2968 | m->mdmreg[REG_SI2] = 0; | 2964 | m->mdmreg[REG_T70] |= (BIT_T70 | BIT_T70_EXT); |
2969 | break; | 2965 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; |
2970 | default: | 2966 | info->xmit_size = 112; |
2971 | PARSE_ERROR1; | 2967 | m->mdmreg[REG_SI1] = 4; |
2972 | } | 2968 | m->mdmreg[REG_SI2] = 0; |
2973 | break; | 2969 | break; |
2974 | default: | 2970 | default: |
2975 | PARSE_ERROR1; | 2971 | PARSE_ERROR1; |
2972 | } | ||
2973 | break; | ||
2974 | default: | ||
2975 | PARSE_ERROR1; | ||
2976 | } | 2976 | } |
2977 | return 0; | 2977 | return 0; |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | static int | 2980 | static int |
2981 | isdn_tty_check_ats(int mreg, int mval, modem_info * info, atemu * m) | 2981 | isdn_tty_check_ats(int mreg, int mval, modem_info *info, atemu *m) |
2982 | { | 2982 | { |
2983 | /* Some plausibility checks */ | 2983 | /* Some plausibility checks */ |
2984 | switch (mreg) { | 2984 | switch (mreg) { |
2985 | case REG_L2PROT: | 2985 | case REG_L2PROT: |
2986 | if (mval > ISDN_PROTO_L2_MAX) | 2986 | if (mval > ISDN_PROTO_L2_MAX) |
2987 | return 1; | 2987 | return 1; |
2988 | break; | 2988 | break; |
2989 | case REG_PSIZE: | 2989 | case REG_PSIZE: |
2990 | if ((mval * 16) > ISDN_SERIAL_XMIT_MAX) | 2990 | if ((mval * 16) > ISDN_SERIAL_XMIT_MAX) |
2991 | return 1; | 2991 | return 1; |
2992 | #ifdef CONFIG_ISDN_AUDIO | 2992 | #ifdef CONFIG_ISDN_AUDIO |
2993 | if ((m->mdmreg[REG_SI1] & 1) && (mval > VBUFX)) | 2993 | if ((m->mdmreg[REG_SI1] & 1) && (mval > VBUFX)) |
2994 | return 1; | ||
2995 | #endif | ||
2996 | info->xmit_size = mval * 16; | ||
2997 | switch (m->mdmreg[REG_L2PROT]) { | ||
2998 | case ISDN_PROTO_L2_V11096: | ||
2999 | case ISDN_PROTO_L2_V11019: | ||
3000 | case ISDN_PROTO_L2_V11038: | ||
3001 | info->xmit_size /= 10; | ||
3002 | } | ||
3003 | break; | ||
3004 | case REG_SI1I: | ||
3005 | case REG_PLAN: | ||
3006 | case REG_SCREEN: | ||
3007 | /* readonly registers */ | ||
3008 | return 1; | 2994 | return 1; |
2995 | #endif | ||
2996 | info->xmit_size = mval * 16; | ||
2997 | switch (m->mdmreg[REG_L2PROT]) { | ||
2998 | case ISDN_PROTO_L2_V11096: | ||
2999 | case ISDN_PROTO_L2_V11019: | ||
3000 | case ISDN_PROTO_L2_V11038: | ||
3001 | info->xmit_size /= 10; | ||
3002 | } | ||
3003 | break; | ||
3004 | case REG_SI1I: | ||
3005 | case REG_PLAN: | ||
3006 | case REG_SCREEN: | ||
3007 | /* readonly registers */ | ||
3008 | return 1; | ||
3009 | } | 3009 | } |
3010 | return 0; | 3010 | return 0; |
3011 | } | 3011 | } |
@@ -3014,7 +3014,7 @@ isdn_tty_check_ats(int mreg, int mval, modem_info * info, atemu * m) | |||
3014 | * Perform ATS command | 3014 | * Perform ATS command |
3015 | */ | 3015 | */ |
3016 | static int | 3016 | static int |
3017 | isdn_tty_cmd_ATS(char **p, modem_info * info) | 3017 | isdn_tty_cmd_ATS(char **p, modem_info *info) |
3018 | { | 3018 | { |
3019 | atemu *m = &info->emu; | 3019 | atemu *m = &info->emu; |
3020 | int bitpos; | 3020 | int bitpos; |
@@ -3026,52 +3026,52 @@ isdn_tty_cmd_ATS(char **p, modem_info * info) | |||
3026 | if (mreg < 0 || mreg >= ISDN_MODEM_NUMREG) | 3026 | if (mreg < 0 || mreg >= ISDN_MODEM_NUMREG) |
3027 | PARSE_ERROR1; | 3027 | PARSE_ERROR1; |
3028 | switch (*p[0]) { | 3028 | switch (*p[0]) { |
3029 | case '=': | ||
3030 | p[0]++; | ||
3031 | mval = isdn_getnum(p); | ||
3032 | if (mval < 0 || mval > 255) | ||
3033 | PARSE_ERROR1; | ||
3034 | if (isdn_tty_check_ats(mreg, mval, info, m)) | ||
3035 | PARSE_ERROR1; | ||
3036 | m->mdmreg[mreg] = mval; | ||
3037 | break; | ||
3038 | case '.': | ||
3039 | /* Set/Clear a single bit */ | ||
3040 | p[0]++; | ||
3041 | bitpos = isdn_getnum(p); | ||
3042 | if ((bitpos < 0) || (bitpos > 7)) | ||
3043 | PARSE_ERROR1; | ||
3044 | switch (*p[0]) { | ||
3029 | case '=': | 3045 | case '=': |
3030 | p[0]++; | 3046 | p[0]++; |
3031 | mval = isdn_getnum(p); | 3047 | bval = isdn_getnum(p); |
3032 | if (mval < 0 || mval > 255) | 3048 | if (bval < 0 || bval > 1) |
3033 | PARSE_ERROR1; | 3049 | PARSE_ERROR1; |
3050 | if (bval) | ||
3051 | mval = m->mdmreg[mreg] | (1 << bitpos); | ||
3052 | else | ||
3053 | mval = m->mdmreg[mreg] & ~(1 << bitpos); | ||
3034 | if (isdn_tty_check_ats(mreg, mval, info, m)) | 3054 | if (isdn_tty_check_ats(mreg, mval, info, m)) |
3035 | PARSE_ERROR1; | 3055 | PARSE_ERROR1; |
3036 | m->mdmreg[mreg] = mval; | 3056 | m->mdmreg[mreg] = mval; |
3037 | break; | 3057 | break; |
3038 | case '.': | ||
3039 | /* Set/Clear a single bit */ | ||
3040 | p[0]++; | ||
3041 | bitpos = isdn_getnum(p); | ||
3042 | if ((bitpos < 0) || (bitpos > 7)) | ||
3043 | PARSE_ERROR1; | ||
3044 | switch (*p[0]) { | ||
3045 | case '=': | ||
3046 | p[0]++; | ||
3047 | bval = isdn_getnum(p); | ||
3048 | if (bval < 0 || bval > 1) | ||
3049 | PARSE_ERROR1; | ||
3050 | if (bval) | ||
3051 | mval = m->mdmreg[mreg] | (1 << bitpos); | ||
3052 | else | ||
3053 | mval = m->mdmreg[mreg] & ~(1 << bitpos); | ||
3054 | if (isdn_tty_check_ats(mreg, mval, info, m)) | ||
3055 | PARSE_ERROR1; | ||
3056 | m->mdmreg[mreg] = mval; | ||
3057 | break; | ||
3058 | case '?': | ||
3059 | p[0]++; | ||
3060 | isdn_tty_at_cout("\r\n", info); | ||
3061 | isdn_tty_at_cout((m->mdmreg[mreg] & (1 << bitpos)) ? "1" : "0", | ||
3062 | info); | ||
3063 | break; | ||
3064 | default: | ||
3065 | PARSE_ERROR1; | ||
3066 | } | ||
3067 | break; | ||
3068 | case '?': | 3058 | case '?': |
3069 | p[0]++; | 3059 | p[0]++; |
3070 | isdn_tty_show_profile(mreg, info); | 3060 | isdn_tty_at_cout("\r\n", info); |
3061 | isdn_tty_at_cout((m->mdmreg[mreg] & (1 << bitpos)) ? "1" : "0", | ||
3062 | info); | ||
3071 | break; | 3063 | break; |
3072 | default: | 3064 | default: |
3073 | PARSE_ERROR1; | 3065 | PARSE_ERROR1; |
3074 | break; | 3066 | } |
3067 | break; | ||
3068 | case '?': | ||
3069 | p[0]++; | ||
3070 | isdn_tty_show_profile(mreg, info); | ||
3071 | break; | ||
3072 | default: | ||
3073 | PARSE_ERROR1; | ||
3074 | break; | ||
3075 | } | 3075 | } |
3076 | return 0; | 3076 | return 0; |
3077 | } | 3077 | } |
@@ -3080,7 +3080,7 @@ isdn_tty_cmd_ATS(char **p, modem_info * info) | |||
3080 | * Perform ATA command | 3080 | * Perform ATA command |
3081 | */ | 3081 | */ |
3082 | static void | 3082 | static void |
3083 | isdn_tty_cmd_ATA(modem_info * info) | 3083 | isdn_tty_cmd_ATA(modem_info *info) |
3084 | { | 3084 | { |
3085 | atemu *m = &info->emu; | 3085 | atemu *m = &info->emu; |
3086 | isdn_ctrl cmd; | 3086 | isdn_ctrl cmd; |
@@ -3134,7 +3134,7 @@ isdn_tty_cmd_ATA(modem_info * info) | |||
3134 | * Parse AT+F.. commands | 3134 | * Parse AT+F.. commands |
3135 | */ | 3135 | */ |
3136 | static int | 3136 | static int |
3137 | isdn_tty_cmd_PLUSF(char **p, modem_info * info) | 3137 | isdn_tty_cmd_PLUSF(char **p, modem_info *info) |
3138 | { | 3138 | { |
3139 | atemu *m = &info->emu; | 3139 | atemu *m = &info->emu; |
3140 | char rs[20]; | 3140 | char rs[20]; |
@@ -3142,81 +3142,81 @@ isdn_tty_cmd_PLUSF(char **p, modem_info * info) | |||
3142 | if (!strncmp(p[0], "CLASS", 5)) { | 3142 | if (!strncmp(p[0], "CLASS", 5)) { |
3143 | p[0] += 5; | 3143 | p[0] += 5; |
3144 | switch (*p[0]) { | 3144 | switch (*p[0]) { |
3145 | case '?': | 3145 | case '?': |
3146 | p[0]++; | 3146 | p[0]++; |
3147 | sprintf(rs, "\r\n%d", | 3147 | sprintf(rs, "\r\n%d", |
3148 | (m->mdmreg[REG_SI1] & 1) ? 8 : 0); | 3148 | (m->mdmreg[REG_SI1] & 1) ? 8 : 0); |
3149 | #ifdef CONFIG_ISDN_TTY_FAX | 3149 | #ifdef CONFIG_ISDN_TTY_FAX |
3150 | if (TTY_IS_FCLASS2(info)) | 3150 | if (TTY_IS_FCLASS2(info)) |
3151 | sprintf(rs, "\r\n2"); | 3151 | sprintf(rs, "\r\n2"); |
3152 | else if (TTY_IS_FCLASS1(info)) | 3152 | else if (TTY_IS_FCLASS1(info)) |
3153 | sprintf(rs, "\r\n1"); | 3153 | sprintf(rs, "\r\n1"); |
3154 | #endif | 3154 | #endif |
3155 | isdn_tty_at_cout(rs, info); | 3155 | isdn_tty_at_cout(rs, info); |
3156 | break; | 3156 | break; |
3157 | case '=': | 3157 | case '=': |
3158 | p[0]++; | ||
3159 | switch (*p[0]) { | ||
3160 | case '0': | ||
3158 | p[0]++; | 3161 | p[0]++; |
3159 | switch (*p[0]) { | 3162 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; |
3160 | case '0': | 3163 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; |
3161 | p[0]++; | 3164 | m->mdmreg[REG_SI1] = 4; |
3162 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; | 3165 | info->xmit_size = |
3163 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; | 3166 | m->mdmreg[REG_PSIZE] * 16; |
3164 | m->mdmreg[REG_SI1] = 4; | 3167 | break; |
3165 | info->xmit_size = | ||
3166 | m->mdmreg[REG_PSIZE] * 16; | ||
3167 | break; | ||
3168 | #ifdef CONFIG_ISDN_TTY_FAX | 3168 | #ifdef CONFIG_ISDN_TTY_FAX |
3169 | case '1': | 3169 | case '1': |
3170 | p[0]++; | 3170 | p[0]++; |
3171 | if (!(dev->global_features & | 3171 | if (!(dev->global_features & |
3172 | ISDN_FEATURE_L3_FCLASS1)) | 3172 | ISDN_FEATURE_L3_FCLASS1)) |
3173 | PARSE_ERROR1; | 3173 | PARSE_ERROR1; |
3174 | m->mdmreg[REG_SI1] = 1; | 3174 | m->mdmreg[REG_SI1] = 1; |
3175 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; | 3175 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; |
3176 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS1; | 3176 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS1; |
3177 | info->xmit_size = | 3177 | info->xmit_size = |
3178 | m->mdmreg[REG_PSIZE] * 16; | 3178 | m->mdmreg[REG_PSIZE] * 16; |
3179 | break; | 3179 | break; |
3180 | case '2': | 3180 | case '2': |
3181 | p[0]++; | 3181 | p[0]++; |
3182 | if (!(dev->global_features & | 3182 | if (!(dev->global_features & |
3183 | ISDN_FEATURE_L3_FCLASS2)) | 3183 | ISDN_FEATURE_L3_FCLASS2)) |
3184 | PARSE_ERROR1; | 3184 | PARSE_ERROR1; |
3185 | m->mdmreg[REG_SI1] = 1; | 3185 | m->mdmreg[REG_SI1] = 1; |
3186 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; | 3186 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; |
3187 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS2; | 3187 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS2; |
3188 | info->xmit_size = | 3188 | info->xmit_size = |
3189 | m->mdmreg[REG_PSIZE] * 16; | 3189 | m->mdmreg[REG_PSIZE] * 16; |
3190 | break; | 3190 | break; |
3191 | #endif | 3191 | #endif |
3192 | case '8': | 3192 | case '8': |
3193 | p[0]++; | 3193 | p[0]++; |
3194 | /* L2 will change on dialout with si=1 */ | 3194 | /* L2 will change on dialout with si=1 */ |
3195 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; | 3195 | m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; |
3196 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; | 3196 | m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; |
3197 | m->mdmreg[REG_SI1] = 5; | 3197 | m->mdmreg[REG_SI1] = 5; |
3198 | info->xmit_size = VBUF; | 3198 | info->xmit_size = VBUF; |
3199 | break; | 3199 | break; |
3200 | case '?': | 3200 | case '?': |
3201 | p[0]++; | 3201 | p[0]++; |
3202 | strcpy(rs, "\r\n0,"); | 3202 | strcpy(rs, "\r\n0,"); |
3203 | #ifdef CONFIG_ISDN_TTY_FAX | 3203 | #ifdef CONFIG_ISDN_TTY_FAX |
3204 | if (dev->global_features & | 3204 | if (dev->global_features & |
3205 | ISDN_FEATURE_L3_FCLASS1) | 3205 | ISDN_FEATURE_L3_FCLASS1) |
3206 | strcat(rs, "1,"); | 3206 | strcat(rs, "1,"); |
3207 | if (dev->global_features & | 3207 | if (dev->global_features & |
3208 | ISDN_FEATURE_L3_FCLASS2) | 3208 | ISDN_FEATURE_L3_FCLASS2) |
3209 | strcat(rs, "2,"); | 3209 | strcat(rs, "2,"); |
3210 | #endif | 3210 | #endif |
3211 | strcat(rs, "8"); | 3211 | strcat(rs, "8"); |
3212 | isdn_tty_at_cout(rs, info); | 3212 | isdn_tty_at_cout(rs, info); |
3213 | break; | ||
3214 | default: | ||
3215 | PARSE_ERROR1; | ||
3216 | } | ||
3217 | break; | 3213 | break; |
3218 | default: | 3214 | default: |
3219 | PARSE_ERROR1; | 3215 | PARSE_ERROR1; |
3216 | } | ||
3217 | break; | ||
3218 | default: | ||
3219 | PARSE_ERROR1; | ||
3220 | } | 3220 | } |
3221 | return 0; | 3221 | return 0; |
3222 | } | 3222 | } |
@@ -3231,12 +3231,12 @@ isdn_tty_cmd_PLUSF(char **p, modem_info * info) | |||
3231 | * Parse AT+V.. commands | 3231 | * Parse AT+V.. commands |
3232 | */ | 3232 | */ |
3233 | static int | 3233 | static int |
3234 | isdn_tty_cmd_PLUSV(char **p, modem_info * info) | 3234 | isdn_tty_cmd_PLUSV(char **p, modem_info *info) |
3235 | { | 3235 | { |
3236 | atemu *m = &info->emu; | 3236 | atemu *m = &info->emu; |
3237 | isdn_ctrl cmd; | 3237 | isdn_ctrl cmd; |
3238 | static char *vcmd[] = | 3238 | static char *vcmd[] = |
3239 | {"NH", "IP", "LS", "RX", "SD", "SM", "TX", "DD", NULL}; | 3239 | {"NH", "IP", "LS", "RX", "SD", "SM", "TX", "DD", NULL}; |
3240 | int i; | 3240 | int i; |
3241 | int par1; | 3241 | int par1; |
3242 | int par2; | 3242 | int par2; |
@@ -3251,256 +3251,256 @@ isdn_tty_cmd_PLUSV(char **p, modem_info * info) | |||
3251 | i++; | 3251 | i++; |
3252 | } | 3252 | } |
3253 | switch (i) { | 3253 | switch (i) { |
3254 | case 0: | 3254 | case 0: |
3255 | /* AT+VNH - Auto hangup feature */ | 3255 | /* AT+VNH - Auto hangup feature */ |
3256 | switch (*p[0]) { | ||
3257 | case '?': | ||
3258 | p[0]++; | ||
3259 | isdn_tty_at_cout("\r\n1", info); | ||
3260 | break; | ||
3261 | case '=': | ||
3262 | p[0]++; | ||
3256 | switch (*p[0]) { | 3263 | switch (*p[0]) { |
3257 | case '?': | 3264 | case '1': |
3258 | p[0]++; | 3265 | p[0]++; |
3259 | isdn_tty_at_cout("\r\n1", info); | 3266 | break; |
3260 | break; | 3267 | case '?': |
3261 | case '=': | 3268 | p[0]++; |
3262 | p[0]++; | 3269 | isdn_tty_at_cout("\r\n1", info); |
3263 | switch (*p[0]) { | 3270 | break; |
3264 | case '1': | 3271 | default: |
3265 | p[0]++; | 3272 | PARSE_ERROR1; |
3266 | break; | ||
3267 | case '?': | ||
3268 | p[0]++; | ||
3269 | isdn_tty_at_cout("\r\n1", info); | ||
3270 | break; | ||
3271 | default: | ||
3272 | PARSE_ERROR1; | ||
3273 | } | ||
3274 | break; | ||
3275 | default: | ||
3276 | PARSE_ERROR1; | ||
3277 | } | 3273 | } |
3278 | break; | 3274 | break; |
3279 | case 1: | 3275 | default: |
3280 | /* AT+VIP - Reset all voice parameters */ | 3276 | PARSE_ERROR1; |
3281 | isdn_tty_modem_reset_vpar(m); | 3277 | } |
3278 | break; | ||
3279 | case 1: | ||
3280 | /* AT+VIP - Reset all voice parameters */ | ||
3281 | isdn_tty_modem_reset_vpar(m); | ||
3282 | break; | ||
3283 | case 2: | ||
3284 | /* AT+VLS - Select device, accept incoming call */ | ||
3285 | switch (*p[0]) { | ||
3286 | case '?': | ||
3287 | p[0]++; | ||
3288 | sprintf(rs, "\r\n%d", m->vpar[0]); | ||
3289 | isdn_tty_at_cout(rs, info); | ||
3282 | break; | 3290 | break; |
3283 | case 2: | 3291 | case '=': |
3284 | /* AT+VLS - Select device, accept incoming call */ | 3292 | p[0]++; |
3285 | switch (*p[0]) { | 3293 | switch (*p[0]) { |
3286 | case '?': | 3294 | case '0': |
3287 | p[0]++; | 3295 | p[0]++; |
3288 | sprintf(rs, "\r\n%d", m->vpar[0]); | 3296 | m->vpar[0] = 0; |
3289 | isdn_tty_at_cout(rs, info); | 3297 | break; |
3290 | break; | 3298 | case '2': |
3291 | case '=': | 3299 | p[0]++; |
3292 | p[0]++; | 3300 | m->vpar[0] = 2; |
3293 | switch (*p[0]) { | 3301 | break; |
3294 | case '0': | 3302 | case '?': |
3295 | p[0]++; | 3303 | p[0]++; |
3296 | m->vpar[0] = 0; | 3304 | isdn_tty_at_cout("\r\n0,2", info); |
3297 | break; | 3305 | break; |
3298 | case '2': | 3306 | default: |
3299 | p[0]++; | ||
3300 | m->vpar[0] = 2; | ||
3301 | break; | ||
3302 | case '?': | ||
3303 | p[0]++; | ||
3304 | isdn_tty_at_cout("\r\n0,2", info); | ||
3305 | break; | ||
3306 | default: | ||
3307 | PARSE_ERROR1; | ||
3308 | } | ||
3309 | break; | ||
3310 | default: | ||
3311 | PARSE_ERROR1; | ||
3312 | } | ||
3313 | break; | ||
3314 | case 3: | ||
3315 | /* AT+VRX - Start recording */ | ||
3316 | if (!m->vpar[0]) | ||
3317 | PARSE_ERROR1; | ||
3318 | if (info->online != 1) { | ||
3319 | isdn_tty_modem_result(RESULT_NO_ANSWER, info); | ||
3320 | return 1; | ||
3321 | } | ||
3322 | info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); | ||
3323 | if (!info->dtmf_state) { | ||
3324 | printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); | ||
3325 | PARSE_ERROR1; | 3307 | PARSE_ERROR1; |
3326 | } | 3308 | } |
3327 | info->silence_state = isdn_audio_silence_init(info->silence_state); | 3309 | break; |
3328 | if (!info->silence_state) { | 3310 | default: |
3329 | printk(KERN_WARNING "isdn_tty: Couldn't malloc silence state\n"); | 3311 | PARSE_ERROR1; |
3312 | } | ||
3313 | break; | ||
3314 | case 3: | ||
3315 | /* AT+VRX - Start recording */ | ||
3316 | if (!m->vpar[0]) | ||
3317 | PARSE_ERROR1; | ||
3318 | if (info->online != 1) { | ||
3319 | isdn_tty_modem_result(RESULT_NO_ANSWER, info); | ||
3320 | return 1; | ||
3321 | } | ||
3322 | info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); | ||
3323 | if (!info->dtmf_state) { | ||
3324 | printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); | ||
3325 | PARSE_ERROR1; | ||
3326 | } | ||
3327 | info->silence_state = isdn_audio_silence_init(info->silence_state); | ||
3328 | if (!info->silence_state) { | ||
3329 | printk(KERN_WARNING "isdn_tty: Couldn't malloc silence state\n"); | ||
3330 | PARSE_ERROR1; | ||
3331 | } | ||
3332 | if (m->vpar[3] < 5) { | ||
3333 | info->adpcmr = isdn_audio_adpcm_init(info->adpcmr, m->vpar[3]); | ||
3334 | if (!info->adpcmr) { | ||
3335 | printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); | ||
3330 | PARSE_ERROR1; | 3336 | PARSE_ERROR1; |
3331 | } | 3337 | } |
3332 | if (m->vpar[3] < 5) { | 3338 | } |
3333 | info->adpcmr = isdn_audio_adpcm_init(info->adpcmr, m->vpar[3]); | ||
3334 | if (!info->adpcmr) { | ||
3335 | printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); | ||
3336 | PARSE_ERROR1; | ||
3337 | } | ||
3338 | } | ||
3339 | #ifdef ISDN_DEBUG_AT | 3339 | #ifdef ISDN_DEBUG_AT |
3340 | printk(KERN_DEBUG "AT: +VRX\n"); | 3340 | printk(KERN_DEBUG "AT: +VRX\n"); |
3341 | #endif | 3341 | #endif |
3342 | info->vonline |= 1; | 3342 | info->vonline |= 1; |
3343 | isdn_tty_modem_result(RESULT_CONNECT, info); | 3343 | isdn_tty_modem_result(RESULT_CONNECT, info); |
3344 | return 0; | 3344 | return 0; |
3345 | break; | ||
3346 | case 4: | ||
3347 | /* AT+VSD - Silence detection */ | ||
3348 | switch (*p[0]) { | ||
3349 | case '?': | ||
3350 | p[0]++; | ||
3351 | sprintf(rs, "\r\n<%d>,<%d>", | ||
3352 | m->vpar[1], | ||
3353 | m->vpar[2]); | ||
3354 | isdn_tty_at_cout(rs, info); | ||
3345 | break; | 3355 | break; |
3346 | case 4: | 3356 | case '=': |
3347 | /* AT+VSD - Silence detection */ | 3357 | p[0]++; |
3348 | switch (*p[0]) { | 3358 | if ((*p[0] >= '0') && (*p[0] <= '9')) { |
3349 | case '?': | 3359 | par1 = isdn_getnum(p); |
3350 | p[0]++; | 3360 | if ((par1 < 0) || (par1 > 31)) |
3351 | sprintf(rs, "\r\n<%d>,<%d>", | ||
3352 | m->vpar[1], | ||
3353 | m->vpar[2]); | ||
3354 | isdn_tty_at_cout(rs, info); | ||
3355 | break; | ||
3356 | case '=': | ||
3357 | p[0]++; | ||
3358 | if ((*p[0]>='0') && (*p[0]<='9')) { | ||
3359 | par1 = isdn_getnum(p); | ||
3360 | if ((par1 < 0) || (par1 > 31)) | ||
3361 | PARSE_ERROR1; | ||
3362 | if (*p[0] != ',') | ||
3363 | PARSE_ERROR1; | ||
3364 | p[0]++; | ||
3365 | par2 = isdn_getnum(p); | ||
3366 | if ((par2 < 0) || (par2 > 255)) | ||
3367 | PARSE_ERROR1; | ||
3368 | m->vpar[1] = par1; | ||
3369 | m->vpar[2] = par2; | ||
3370 | break; | ||
3371 | } else | ||
3372 | if (*p[0] == '?') { | ||
3373 | p[0]++; | ||
3374 | isdn_tty_at_cout("\r\n<0-31>,<0-255>", | ||
3375 | info); | ||
3376 | break; | ||
3377 | } else | ||
3378 | PARSE_ERROR1; | 3361 | PARSE_ERROR1; |
3379 | break; | 3362 | if (*p[0] != ',') |
3380 | default: | ||
3381 | PARSE_ERROR1; | 3363 | PARSE_ERROR1; |
3382 | } | 3364 | p[0]++; |
3383 | break; | 3365 | par2 = isdn_getnum(p); |
3384 | case 5: | 3366 | if ((par2 < 0) || (par2 > 255)) |
3385 | /* AT+VSM - Select compression */ | 3367 | PARSE_ERROR1; |
3386 | switch (*p[0]) { | 3368 | m->vpar[1] = par1; |
3387 | case '?': | 3369 | m->vpar[2] = par2; |
3388 | p[0]++; | 3370 | break; |
3389 | sprintf(rs, "\r\n<%d>,<%d><8000>", | 3371 | } else |
3390 | m->vpar[3], | 3372 | if (*p[0] == '?') { |
3391 | m->vpar[1]); | ||
3392 | isdn_tty_at_cout(rs, info); | ||
3393 | break; | ||
3394 | case '=': | ||
3395 | p[0]++; | 3373 | p[0]++; |
3396 | switch (*p[0]) { | 3374 | isdn_tty_at_cout("\r\n<0-31>,<0-255>", |
3397 | case '2': | 3375 | info); |
3398 | case '3': | ||
3399 | case '4': | ||
3400 | case '5': | ||
3401 | case '6': | ||
3402 | par1 = isdn_getnum(p); | ||
3403 | if ((par1 < 2) || (par1 > 6)) | ||
3404 | PARSE_ERROR1; | ||
3405 | m->vpar[3] = par1; | ||
3406 | break; | ||
3407 | case '?': | ||
3408 | p[0]++; | ||
3409 | isdn_tty_at_cout("\r\n2;ADPCM;2;0;(8000)\r\n", | ||
3410 | info); | ||
3411 | isdn_tty_at_cout("3;ADPCM;3;0;(8000)\r\n", | ||
3412 | info); | ||
3413 | isdn_tty_at_cout("4;ADPCM;4;0;(8000)\r\n", | ||
3414 | info); | ||
3415 | isdn_tty_at_cout("5;ALAW;8;0;(8000)\r\n", | ||
3416 | info); | ||
3417 | isdn_tty_at_cout("6;ULAW;8;0;(8000)\r\n", | ||
3418 | info); | ||
3419 | break; | ||
3420 | default: | ||
3421 | PARSE_ERROR1; | ||
3422 | } | ||
3423 | break; | 3376 | break; |
3424 | default: | 3377 | } else |
3425 | PARSE_ERROR1; | 3378 | PARSE_ERROR1; |
3426 | } | ||
3427 | break; | 3379 | break; |
3428 | case 6: | 3380 | default: |
3429 | /* AT+VTX - Start sending */ | 3381 | PARSE_ERROR1; |
3430 | if (!m->vpar[0]) | 3382 | } |
3383 | break; | ||
3384 | case 5: | ||
3385 | /* AT+VSM - Select compression */ | ||
3386 | switch (*p[0]) { | ||
3387 | case '?': | ||
3388 | p[0]++; | ||
3389 | sprintf(rs, "\r\n<%d>,<%d><8000>", | ||
3390 | m->vpar[3], | ||
3391 | m->vpar[1]); | ||
3392 | isdn_tty_at_cout(rs, info); | ||
3393 | break; | ||
3394 | case '=': | ||
3395 | p[0]++; | ||
3396 | switch (*p[0]) { | ||
3397 | case '2': | ||
3398 | case '3': | ||
3399 | case '4': | ||
3400 | case '5': | ||
3401 | case '6': | ||
3402 | par1 = isdn_getnum(p); | ||
3403 | if ((par1 < 2) || (par1 > 6)) | ||
3404 | PARSE_ERROR1; | ||
3405 | m->vpar[3] = par1; | ||
3406 | break; | ||
3407 | case '?': | ||
3408 | p[0]++; | ||
3409 | isdn_tty_at_cout("\r\n2;ADPCM;2;0;(8000)\r\n", | ||
3410 | info); | ||
3411 | isdn_tty_at_cout("3;ADPCM;3;0;(8000)\r\n", | ||
3412 | info); | ||
3413 | isdn_tty_at_cout("4;ADPCM;4;0;(8000)\r\n", | ||
3414 | info); | ||
3415 | isdn_tty_at_cout("5;ALAW;8;0;(8000)\r\n", | ||
3416 | info); | ||
3417 | isdn_tty_at_cout("6;ULAW;8;0;(8000)\r\n", | ||
3418 | info); | ||
3419 | break; | ||
3420 | default: | ||
3431 | PARSE_ERROR1; | 3421 | PARSE_ERROR1; |
3432 | if (info->online != 1) { | ||
3433 | isdn_tty_modem_result(RESULT_NO_ANSWER, info); | ||
3434 | return 1; | ||
3435 | } | 3422 | } |
3436 | info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); | 3423 | break; |
3437 | if (!info->dtmf_state) { | 3424 | default: |
3438 | printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); | 3425 | PARSE_ERROR1; |
3426 | } | ||
3427 | break; | ||
3428 | case 6: | ||
3429 | /* AT+VTX - Start sending */ | ||
3430 | if (!m->vpar[0]) | ||
3431 | PARSE_ERROR1; | ||
3432 | if (info->online != 1) { | ||
3433 | isdn_tty_modem_result(RESULT_NO_ANSWER, info); | ||
3434 | return 1; | ||
3435 | } | ||
3436 | info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); | ||
3437 | if (!info->dtmf_state) { | ||
3438 | printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); | ||
3439 | PARSE_ERROR1; | ||
3440 | } | ||
3441 | if (m->vpar[3] < 5) { | ||
3442 | info->adpcms = isdn_audio_adpcm_init(info->adpcms, m->vpar[3]); | ||
3443 | if (!info->adpcms) { | ||
3444 | printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); | ||
3439 | PARSE_ERROR1; | 3445 | PARSE_ERROR1; |
3440 | } | 3446 | } |
3441 | if (m->vpar[3] < 5) { | 3447 | } |
3442 | info->adpcms = isdn_audio_adpcm_init(info->adpcms, m->vpar[3]); | ||
3443 | if (!info->adpcms) { | ||
3444 | printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); | ||
3445 | PARSE_ERROR1; | ||
3446 | } | ||
3447 | } | ||
3448 | #ifdef ISDN_DEBUG_AT | 3448 | #ifdef ISDN_DEBUG_AT |
3449 | printk(KERN_DEBUG "AT: +VTX\n"); | 3449 | printk(KERN_DEBUG "AT: +VTX\n"); |
3450 | #endif | 3450 | #endif |
3451 | m->lastDLE = 0; | 3451 | m->lastDLE = 0; |
3452 | info->vonline |= 2; | 3452 | info->vonline |= 2; |
3453 | isdn_tty_modem_result(RESULT_CONNECT, info); | 3453 | isdn_tty_modem_result(RESULT_CONNECT, info); |
3454 | return 0; | 3454 | return 0; |
3455 | break; | ||
3456 | case 7: | ||
3457 | /* AT+VDD - DTMF detection */ | ||
3458 | switch (*p[0]) { | ||
3459 | case '?': | ||
3460 | p[0]++; | ||
3461 | sprintf(rs, "\r\n<%d>,<%d>", | ||
3462 | m->vpar[4], | ||
3463 | m->vpar[5]); | ||
3464 | isdn_tty_at_cout(rs, info); | ||
3455 | break; | 3465 | break; |
3456 | case 7: | 3466 | case '=': |
3457 | /* AT+VDD - DTMF detection */ | 3467 | p[0]++; |
3458 | switch (*p[0]) { | 3468 | if ((*p[0] >= '0') && (*p[0] <= '9')) { |
3459 | case '?': | 3469 | if (info->online != 1) |
3460 | p[0]++; | ||
3461 | sprintf(rs, "\r\n<%d>,<%d>", | ||
3462 | m->vpar[4], | ||
3463 | m->vpar[5]); | ||
3464 | isdn_tty_at_cout(rs, info); | ||
3465 | break; | ||
3466 | case '=': | ||
3467 | p[0]++; | ||
3468 | if ((*p[0]>='0') && (*p[0]<='9')) { | ||
3469 | if (info->online != 1) | ||
3470 | PARSE_ERROR1; | ||
3471 | par1 = isdn_getnum(p); | ||
3472 | if ((par1 < 0) || (par1 > 15)) | ||
3473 | PARSE_ERROR1; | ||
3474 | if (*p[0] != ',') | ||
3475 | PARSE_ERROR1; | ||
3476 | p[0]++; | ||
3477 | par2 = isdn_getnum(p); | ||
3478 | if ((par2 < 0) || (par2 > 255)) | ||
3479 | PARSE_ERROR1; | ||
3480 | m->vpar[4] = par1; | ||
3481 | m->vpar[5] = par2; | ||
3482 | cmd.driver = info->isdn_driver; | ||
3483 | cmd.command = ISDN_CMD_AUDIO; | ||
3484 | cmd.arg = info->isdn_channel + (ISDN_AUDIO_SETDD << 8); | ||
3485 | cmd.parm.num[0] = par1; | ||
3486 | cmd.parm.num[1] = par2; | ||
3487 | isdn_command(&cmd); | ||
3488 | break; | ||
3489 | } else | ||
3490 | if (*p[0] == '?') { | ||
3491 | p[0]++; | ||
3492 | isdn_tty_at_cout("\r\n<0-15>,<0-255>", | ||
3493 | info); | ||
3494 | break; | ||
3495 | } else | ||
3496 | PARSE_ERROR1; | 3470 | PARSE_ERROR1; |
3471 | par1 = isdn_getnum(p); | ||
3472 | if ((par1 < 0) || (par1 > 15)) | ||
3473 | PARSE_ERROR1; | ||
3474 | if (*p[0] != ',') | ||
3475 | PARSE_ERROR1; | ||
3476 | p[0]++; | ||
3477 | par2 = isdn_getnum(p); | ||
3478 | if ((par2 < 0) || (par2 > 255)) | ||
3479 | PARSE_ERROR1; | ||
3480 | m->vpar[4] = par1; | ||
3481 | m->vpar[5] = par2; | ||
3482 | cmd.driver = info->isdn_driver; | ||
3483 | cmd.command = ISDN_CMD_AUDIO; | ||
3484 | cmd.arg = info->isdn_channel + (ISDN_AUDIO_SETDD << 8); | ||
3485 | cmd.parm.num[0] = par1; | ||
3486 | cmd.parm.num[1] = par2; | ||
3487 | isdn_command(&cmd); | ||
3488 | break; | ||
3489 | } else | ||
3490 | if (*p[0] == '?') { | ||
3491 | p[0]++; | ||
3492 | isdn_tty_at_cout("\r\n<0-15>,<0-255>", | ||
3493 | info); | ||
3497 | break; | 3494 | break; |
3498 | default: | 3495 | } else |
3499 | PARSE_ERROR1; | 3496 | PARSE_ERROR1; |
3500 | } | ||
3501 | break; | 3497 | break; |
3502 | default: | 3498 | default: |
3503 | PARSE_ERROR1; | 3499 | PARSE_ERROR1; |
3500 | } | ||
3501 | break; | ||
3502 | default: | ||
3503 | PARSE_ERROR1; | ||
3504 | } | 3504 | } |
3505 | return 0; | 3505 | return 0; |
3506 | } | 3506 | } |
@@ -3510,7 +3510,7 @@ isdn_tty_cmd_PLUSV(char **p, modem_info * info) | |||
3510 | * Parse and perform an AT-command-line. | 3510 | * Parse and perform an AT-command-line. |
3511 | */ | 3511 | */ |
3512 | static void | 3512 | static void |
3513 | isdn_tty_parse_at(modem_info * info) | 3513 | isdn_tty_parse_at(modem_info *info) |
3514 | { | 3514 | { |
3515 | atemu *m = &info->emu; | 3515 | atemu *m = &info->emu; |
3516 | char *p; | 3516 | char *p; |
@@ -3521,188 +3521,188 @@ isdn_tty_parse_at(modem_info * info) | |||
3521 | #endif | 3521 | #endif |
3522 | for (p = &m->mdmcmd[2]; *p;) { | 3522 | for (p = &m->mdmcmd[2]; *p;) { |
3523 | switch (*p) { | 3523 | switch (*p) { |
3524 | case ' ': | 3524 | case ' ': |
3525 | p++; | 3525 | p++; |
3526 | break; | ||
3527 | case 'A': | ||
3528 | /* A - Accept incoming call */ | ||
3529 | p++; | ||
3530 | isdn_tty_cmd_ATA(info); | ||
3531 | return; | ||
3532 | break; | ||
3533 | case 'D': | ||
3534 | /* D - Dial */ | ||
3535 | if (info->msr & UART_MSR_DCD) | ||
3536 | PARSE_ERROR; | ||
3537 | if (info->msr & UART_MSR_RI) { | ||
3538 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); | ||
3539 | return; | ||
3540 | } | ||
3541 | isdn_tty_getdial(++p, ds, sizeof ds); | ||
3542 | p += strlen(p); | ||
3543 | if (!strlen(m->msn)) | ||
3544 | isdn_tty_modem_result(RESULT_NO_MSN_EAZ, info); | ||
3545 | else if (strlen(ds)) | ||
3546 | isdn_tty_dial(ds, info, m); | ||
3547 | else | ||
3548 | PARSE_ERROR; | ||
3549 | return; | ||
3550 | case 'E': | ||
3551 | /* E - Turn Echo on/off */ | ||
3552 | p++; | ||
3553 | switch (isdn_getnum(&p)) { | ||
3554 | case 0: | ||
3555 | m->mdmreg[REG_ECHO] &= ~BIT_ECHO; | ||
3526 | break; | 3556 | break; |
3527 | case 'A': | 3557 | case 1: |
3528 | /* A - Accept incoming call */ | 3558 | m->mdmreg[REG_ECHO] |= BIT_ECHO; |
3559 | break; | ||
3560 | default: | ||
3561 | PARSE_ERROR; | ||
3562 | } | ||
3563 | break; | ||
3564 | case 'H': | ||
3565 | /* H - On/Off-hook */ | ||
3566 | p++; | ||
3567 | switch (*p) { | ||
3568 | case '0': | ||
3529 | p++; | 3569 | p++; |
3530 | isdn_tty_cmd_ATA(info); | 3570 | isdn_tty_on_hook(info); |
3531 | return; | ||
3532 | break; | 3571 | break; |
3533 | case 'D': | 3572 | case '1': |
3534 | /* D - Dial */ | ||
3535 | if (info->msr & UART_MSR_DCD) | ||
3536 | PARSE_ERROR; | ||
3537 | if (info->msr & UART_MSR_RI) { | ||
3538 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); | ||
3539 | return; | ||
3540 | } | ||
3541 | isdn_tty_getdial(++p, ds, sizeof ds); | ||
3542 | p += strlen(p); | ||
3543 | if (!strlen(m->msn)) | ||
3544 | isdn_tty_modem_result(RESULT_NO_MSN_EAZ, info); | ||
3545 | else if (strlen(ds)) | ||
3546 | isdn_tty_dial(ds, info, m); | ||
3547 | else | ||
3548 | PARSE_ERROR; | ||
3549 | return; | ||
3550 | case 'E': | ||
3551 | /* E - Turn Echo on/off */ | ||
3552 | p++; | 3573 | p++; |
3553 | switch (isdn_getnum(&p)) { | 3574 | isdn_tty_off_hook(); |
3554 | case 0: | ||
3555 | m->mdmreg[REG_ECHO] &= ~BIT_ECHO; | ||
3556 | break; | ||
3557 | case 1: | ||
3558 | m->mdmreg[REG_ECHO] |= BIT_ECHO; | ||
3559 | break; | ||
3560 | default: | ||
3561 | PARSE_ERROR; | ||
3562 | } | ||
3563 | break; | 3575 | break; |
3564 | case 'H': | 3576 | default: |
3565 | /* H - On/Off-hook */ | 3577 | isdn_tty_on_hook(info); |
3578 | break; | ||
3579 | } | ||
3580 | break; | ||
3581 | case 'I': | ||
3582 | /* I - Information */ | ||
3583 | p++; | ||
3584 | isdn_tty_at_cout("\r\nLinux ISDN", info); | ||
3585 | switch (*p) { | ||
3586 | case '0': | ||
3587 | case '1': | ||
3566 | p++; | 3588 | p++; |
3567 | switch (*p) { | ||
3568 | case '0': | ||
3569 | p++; | ||
3570 | isdn_tty_on_hook(info); | ||
3571 | break; | ||
3572 | case '1': | ||
3573 | p++; | ||
3574 | isdn_tty_off_hook(); | ||
3575 | break; | ||
3576 | default: | ||
3577 | isdn_tty_on_hook(info); | ||
3578 | break; | ||
3579 | } | ||
3580 | break; | 3589 | break; |
3581 | case 'I': | 3590 | case '2': |
3582 | /* I - Information */ | ||
3583 | p++; | 3591 | p++; |
3584 | isdn_tty_at_cout("\r\nLinux ISDN", info); | 3592 | isdn_tty_report(info); |
3585 | switch (*p) { | ||
3586 | case '0': | ||
3587 | case '1': | ||
3588 | p++; | ||
3589 | break; | ||
3590 | case '2': | ||
3591 | p++; | ||
3592 | isdn_tty_report(info); | ||
3593 | break; | ||
3594 | case '3': | ||
3595 | p++; | ||
3596 | snprintf(ds, sizeof(ds), "\r\n%d", info->emu.charge); | ||
3597 | isdn_tty_at_cout(ds, info); | ||
3598 | break; | ||
3599 | default:; | ||
3600 | } | ||
3601 | break; | 3593 | break; |
3602 | #ifdef DUMMY_HAYES_AT | 3594 | case '3': |
3603 | case 'L': | ||
3604 | case 'M': | ||
3605 | /* only for be compilant with common scripts */ | ||
3606 | /* no function */ | ||
3607 | p++; | 3595 | p++; |
3608 | isdn_getnum(&p); | 3596 | snprintf(ds, sizeof(ds), "\r\n%d", info->emu.charge); |
3597 | isdn_tty_at_cout(ds, info); | ||
3609 | break; | 3598 | break; |
3599 | default:; | ||
3600 | } | ||
3601 | break; | ||
3602 | #ifdef DUMMY_HAYES_AT | ||
3603 | case 'L': | ||
3604 | case 'M': | ||
3605 | /* only for be compilant with common scripts */ | ||
3606 | /* no function */ | ||
3607 | p++; | ||
3608 | isdn_getnum(&p); | ||
3609 | break; | ||
3610 | #endif | 3610 | #endif |
3611 | case 'O': | 3611 | case 'O': |
3612 | /* O - Go online */ | 3612 | /* O - Go online */ |
3613 | p++; | 3613 | p++; |
3614 | if (info->msr & UART_MSR_DCD) | 3614 | if (info->msr & UART_MSR_DCD) |
3615 | /* if B-Channel is up */ | 3615 | /* if B-Channel is up */ |
3616 | isdn_tty_modem_result((m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) ? RESULT_CONNECT:RESULT_CONNECT64000, info); | 3616 | isdn_tty_modem_result((m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) ? RESULT_CONNECT : RESULT_CONNECT64000, info); |
3617 | else | 3617 | else |
3618 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); | 3618 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); |
3619 | return; | ||
3620 | case 'Q': | ||
3621 | /* Q - Turn Emulator messages on/off */ | ||
3622 | p++; | ||
3623 | switch (isdn_getnum(&p)) { | ||
3624 | case 0: | ||
3625 | m->mdmreg[REG_RESP] |= BIT_RESP; | ||
3626 | break; | ||
3627 | case 1: | ||
3628 | m->mdmreg[REG_RESP] &= ~BIT_RESP; | ||
3629 | break; | ||
3630 | default: | ||
3631 | PARSE_ERROR; | ||
3632 | } | ||
3633 | break; | ||
3634 | case 'S': | ||
3635 | /* S - Set/Get Register */ | ||
3636 | p++; | ||
3637 | if (isdn_tty_cmd_ATS(&p, info)) | ||
3619 | return; | 3638 | return; |
3620 | case 'Q': | 3639 | break; |
3621 | /* Q - Turn Emulator messages on/off */ | 3640 | case 'V': |
3622 | p++; | 3641 | /* V - Numeric or ASCII Emulator-messages */ |
3623 | switch (isdn_getnum(&p)) { | 3642 | p++; |
3624 | case 0: | 3643 | switch (isdn_getnum(&p)) { |
3625 | m->mdmreg[REG_RESP] |= BIT_RESP; | 3644 | case 0: |
3626 | break; | 3645 | m->mdmreg[REG_RESP] |= BIT_RESPNUM; |
3627 | case 1: | 3646 | break; |
3628 | m->mdmreg[REG_RESP] &= ~BIT_RESP; | 3647 | case 1: |
3629 | break; | 3648 | m->mdmreg[REG_RESP] &= ~BIT_RESPNUM; |
3630 | default: | ||
3631 | PARSE_ERROR; | ||
3632 | } | ||
3633 | break; | 3649 | break; |
3634 | case 'S': | 3650 | default: |
3635 | /* S - Set/Get Register */ | 3651 | PARSE_ERROR; |
3652 | } | ||
3653 | break; | ||
3654 | case 'Z': | ||
3655 | /* Z - Load Registers from Profile */ | ||
3656 | p++; | ||
3657 | if (info->msr & UART_MSR_DCD) { | ||
3658 | info->online = 0; | ||
3659 | isdn_tty_on_hook(info); | ||
3660 | } | ||
3661 | isdn_tty_modem_reset_regs(info, 1); | ||
3662 | break; | ||
3663 | case '+': | ||
3664 | p++; | ||
3665 | switch (*p) { | ||
3666 | #ifdef CONFIG_ISDN_AUDIO | ||
3667 | case 'F': | ||
3636 | p++; | 3668 | p++; |
3637 | if (isdn_tty_cmd_ATS(&p, info)) | 3669 | if (isdn_tty_cmd_PLUSF(&p, info)) |
3638 | return; | 3670 | return; |
3639 | break; | 3671 | break; |
3640 | case 'V': | 3672 | case 'V': |
3641 | /* V - Numeric or ASCII Emulator-messages */ | 3673 | if ((!(m->mdmreg[REG_SI1] & 1)) || |
3674 | (m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM)) | ||
3675 | PARSE_ERROR; | ||
3642 | p++; | 3676 | p++; |
3643 | switch (isdn_getnum(&p)) { | 3677 | if (isdn_tty_cmd_PLUSV(&p, info)) |
3644 | case 0: | 3678 | return; |
3645 | m->mdmreg[REG_RESP] |= BIT_RESPNUM; | ||
3646 | break; | ||
3647 | case 1: | ||
3648 | m->mdmreg[REG_RESP] &= ~BIT_RESPNUM; | ||
3649 | break; | ||
3650 | default: | ||
3651 | PARSE_ERROR; | ||
3652 | } | ||
3653 | break; | 3679 | break; |
3654 | case 'Z': | 3680 | #endif /* CONFIG_ISDN_AUDIO */ |
3655 | /* Z - Load Registers from Profile */ | 3681 | case 'S': /* SUSPEND */ |
3656 | p++; | 3682 | p++; |
3657 | if (info->msr & UART_MSR_DCD) { | 3683 | isdn_tty_get_msnstr(ds, &p); |
3658 | info->online = 0; | 3684 | isdn_tty_suspend(ds, info, m); |
3659 | isdn_tty_on_hook(info); | ||
3660 | } | ||
3661 | isdn_tty_modem_reset_regs(info, 1); | ||
3662 | break; | 3685 | break; |
3663 | case '+': | 3686 | case 'R': /* RESUME */ |
3664 | p++; | 3687 | p++; |
3665 | switch (*p) { | 3688 | isdn_tty_get_msnstr(ds, &p); |
3666 | #ifdef CONFIG_ISDN_AUDIO | 3689 | isdn_tty_resume(ds, info, m); |
3667 | case 'F': | ||
3668 | p++; | ||
3669 | if (isdn_tty_cmd_PLUSF(&p, info)) | ||
3670 | return; | ||
3671 | break; | ||
3672 | case 'V': | ||
3673 | if ((!(m->mdmreg[REG_SI1] & 1)) || | ||
3674 | (m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM)) | ||
3675 | PARSE_ERROR; | ||
3676 | p++; | ||
3677 | if (isdn_tty_cmd_PLUSV(&p, info)) | ||
3678 | return; | ||
3679 | break; | ||
3680 | #endif /* CONFIG_ISDN_AUDIO */ | ||
3681 | case 'S': /* SUSPEND */ | ||
3682 | p++; | ||
3683 | isdn_tty_get_msnstr(ds, &p); | ||
3684 | isdn_tty_suspend(ds, info, m); | ||
3685 | break; | ||
3686 | case 'R': /* RESUME */ | ||
3687 | p++; | ||
3688 | isdn_tty_get_msnstr(ds, &p); | ||
3689 | isdn_tty_resume(ds, info, m); | ||
3690 | break; | ||
3691 | case 'M': /* MESSAGE */ | ||
3692 | p++; | ||
3693 | isdn_tty_send_msg(info, m, p); | ||
3694 | break; | ||
3695 | default: | ||
3696 | PARSE_ERROR; | ||
3697 | } | ||
3698 | break; | 3690 | break; |
3699 | case '&': | 3691 | case 'M': /* MESSAGE */ |
3700 | p++; | 3692 | p++; |
3701 | if (isdn_tty_cmd_ATand(&p, info)) | 3693 | isdn_tty_send_msg(info, m, p); |
3702 | return; | ||
3703 | break; | 3694 | break; |
3704 | default: | 3695 | default: |
3705 | PARSE_ERROR; | 3696 | PARSE_ERROR; |
3697 | } | ||
3698 | break; | ||
3699 | case '&': | ||
3700 | p++; | ||
3701 | if (isdn_tty_cmd_ATand(&p, info)) | ||
3702 | return; | ||
3703 | break; | ||
3704 | default: | ||
3705 | PARSE_ERROR; | ||
3706 | } | 3706 | } |
3707 | } | 3707 | } |
3708 | #ifdef CONFIG_ISDN_AUDIO | 3708 | #ifdef CONFIG_ISDN_AUDIO |
@@ -3714,7 +3714,7 @@ isdn_tty_parse_at(modem_info * info) | |||
3714 | /* Need own toupper() because standard-toupper is not available | 3714 | /* Need own toupper() because standard-toupper is not available |
3715 | * within modules. | 3715 | * within modules. |
3716 | */ | 3716 | */ |
3717 | #define my_toupper(c) (((c>='a')&&(c<='z'))?(c&0xdf):c) | 3717 | #define my_toupper(c) (((c >= 'a') && (c <= 'z')) ? (c & 0xdf) : c) |
3718 | 3718 | ||
3719 | /* | 3719 | /* |
3720 | * Perform line-editing of AT-commands | 3720 | * Perform line-editing of AT-commands |
@@ -3725,7 +3725,7 @@ isdn_tty_parse_at(modem_info * info) | |||
3725 | * channel index to line (minor-device) | 3725 | * channel index to line (minor-device) |
3726 | */ | 3726 | */ |
3727 | static int | 3727 | static int |
3728 | isdn_tty_edit_at(const char *p, int count, modem_info * info) | 3728 | isdn_tty_edit_at(const char *p, int count, modem_info *info) |
3729 | { | 3729 | { |
3730 | atemu *m = &info->emu; | 3730 | atemu *m = &info->emu; |
3731 | int total = 0; | 3731 | int total = 0; |
@@ -3768,23 +3768,23 @@ isdn_tty_edit_at(const char *p, int count, modem_info * info) | |||
3768 | if (m->mdmcmdl < 255) { | 3768 | if (m->mdmcmdl < 255) { |
3769 | c = my_toupper(c); | 3769 | c = my_toupper(c); |
3770 | switch (m->mdmcmdl) { | 3770 | switch (m->mdmcmdl) { |
3771 | case 1: | 3771 | case 1: |
3772 | if (c == 'T') { | 3772 | if (c == 'T') { |
3773 | m->mdmcmd[m->mdmcmdl] = c; | 3773 | m->mdmcmd[m->mdmcmdl] = c; |
3774 | m->mdmcmd[++m->mdmcmdl] = 0; | 3774 | m->mdmcmd[++m->mdmcmdl] = 0; |
3775 | break; | ||
3776 | } else | ||
3777 | m->mdmcmdl = 0; | ||
3778 | /* Fall through, check for 'A' */ | ||
3779 | case 0: | ||
3780 | if (c == 'A') { | ||
3781 | m->mdmcmd[m->mdmcmdl] = c; | ||
3782 | m->mdmcmd[++m->mdmcmdl] = 0; | ||
3783 | } | ||
3784 | break; | 3775 | break; |
3785 | default: | 3776 | } else |
3777 | m->mdmcmdl = 0; | ||
3778 | /* Fall through, check for 'A' */ | ||
3779 | case 0: | ||
3780 | if (c == 'A') { | ||
3786 | m->mdmcmd[m->mdmcmdl] = c; | 3781 | m->mdmcmd[m->mdmcmdl] = c; |
3787 | m->mdmcmd[++m->mdmcmdl] = 0; | 3782 | m->mdmcmd[++m->mdmcmdl] = 0; |
3783 | } | ||
3784 | break; | ||
3785 | default: | ||
3786 | m->mdmcmd[m->mdmcmdl] = c; | ||
3787 | m->mdmcmd[++m->mdmcmdl] = 0; | ||
3788 | } | 3788 | } |
3789 | } | 3789 | } |
3790 | } | 3790 | } |
diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 692c74d6b749..a6f801d2263b 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 | ||
103 | extern void isdn_tty_modem_escape(void); | 103 | extern void isdn_tty_modem_escape(void); |
@@ -110,7 +110,7 @@ extern void isdn_tty_readmodem(void); | |||
110 | extern int isdn_tty_find_icall(int, int, setup_parm *); | 110 | extern int isdn_tty_find_icall(int, int, setup_parm *); |
111 | extern int isdn_tty_stat_callback(int, isdn_ctrl *); | 111 | extern int isdn_tty_stat_callback(int, isdn_ctrl *); |
112 | extern int isdn_tty_rcv_skb(int, int, int, struct sk_buff *); | 112 | extern int isdn_tty_rcv_skb(int, int, int, struct sk_buff *); |
113 | extern int isdn_tty_capi_facility(capi_msg *cm); | 113 | extern int isdn_tty_capi_facility(capi_msg *cm); |
114 | extern void isdn_tty_at_cout(char *, modem_info *); | 114 | extern void isdn_tty_at_cout(char *, modem_info *); |
115 | extern void isdn_tty_modem_hup(modem_info *, int); | 115 | extern 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 4c41f191d4e2..47aae4916730 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 | ||
47 | static void | 47 | static void |
48 | isdn_tty_fax_modem_result(int code, modem_info * info) | 48 | isdn_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 | } | ||
99 | isdn_tty_at_cout(rs, info); | 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 | } | ||
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 | ||
151 | static int | 151 | static int |
152 | isdn_tty_fax_command1(modem_info * info, isdn_ctrl * c) | 152 | isdn_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); | ||
177 | isdn_tty_at_cout("\r\n", info); | 180 | isdn_tty_at_cout("\r\n", info); |
178 | if (!c->parm.aux.para[0]) { | 181 | } else { |
179 | isdn_tty_at_cout(msg[ISDN_FAX_CLASS1_ERROR], info); | 182 | isdn_tty_at_cout(c->parm.aux.para, info); |
180 | isdn_tty_at_cout("\r\n", info); | 183 | isdn_tty_at_cout("\r\nOK\r\n", info); |
181 | } else { | 184 | } |
182 | isdn_tty_at_cout(c->parm.aux.para, info); | 185 | break; |
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 | ||
190 | int | 190 | int |
191 | isdn_tty_fax_command(modem_info * info, isdn_ctrl * c) | 191 | isdn_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; | ||
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 */ | ||
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 | } | 229 | } |
270 | return (0); | ||
271 | case ISDN_TTY_FAX_EOP: | ||
272 | info->faxonline &= ~2; /* leave data mode */ | 230 | info->faxonline &= ~2; /* leave data mode */ |
273 | info->online = 1; | 231 | info->online = 1; |
274 | f->phase = ISDN_FAX_PHASE_D; | 232 | } |
275 | return (0); | 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 */ | ||
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 | ||
282 | void | 282 | void |
283 | isdn_tty_fax_bitorder(modem_info * info, struct sk_buff *skb) | 283 | isdn_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 | ||
319 | static int | 319 | static int |
320 | isdn_tty_cmd_FCLASS1(char **p, modem_info * info) | 320 | isdn_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]++; | 341 | p[0]++; |
342 | c.parm.aux.subcmd = AT_QUERY; | 342 | c.parm.aux.subcmd = AT_QUERY; |
343 | break; | 343 | break; |
344 | case '=': | 344 | case '=': |
345 | p[0]++; | ||
346 | if (*p[0] == '?') { | ||
345 | p[0]++; | 347 | p[0]++; |
346 | if (*p[0] == '?') { | 348 | c.parm.aux.subcmd = AT_EQ_QUERY; |
347 | p[0]++; | 349 | } else { |
348 | c.parm.aux.subcmd = AT_EQ_QUERY; | 350 | par = isdn_getnum(p); |
349 | } else { | 351 | if ((par < 0) || (par > 255)) |
350 | par = isdn_getnum(p); | 352 | PARSE_ERROR1; |
351 | if ((par < 0) || (par > 255)) | 353 | c.parm.aux.subcmd = AT_EQ_VALUE; |
352 | PARSE_ERROR1; | 354 | c.parm.aux.para[0] = par; |
353 | c.parm.aux.subcmd = AT_EQ_VALUE; | 355 | } |
354 | c.parm.aux.para[0] = par; | 356 | break; |
355 | } | 357 | case 0: |
356 | break; | 358 | c.parm.aux.subcmd = AT_COMMAND; |
357 | case 0: | 359 | break; |
358 | c.parm.aux.subcmd = AT_COMMAND; | 360 | default: |
359 | break; | 361 | PARSE_ERROR1; |
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 | ||
411 | static int | 411 | static int |
412 | isdn_tty_cmd_FCLASS2(char **p, modem_info * info) | 412 | isdn_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: | ||
439 | PARSE_ERROR1; | 436 | 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] == '?') { | ||
448 | p[0]++; | 455 | p[0]++; |
449 | sprintf(rs, "\r\n%d", f->badlin); | 456 | sprintf(rs, "\r\n0-255"); |
450 | isdn_tty_at_cout(rs, info); | 457 | isdn_tty_at_cout(rs, info); |
451 | break; | 458 | } else { |
452 | case '=': | 459 | par = isdn_getnum(p); |
453 | p[0]++; | 460 | if ((par < 0) || (par > 255)) |
454 | if (*p[0] == '?') { | 461 | PARSE_ERROR1; |
455 | p[0]++; | 462 | f->badlin = par; |
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] == '?') { | ||
478 | p[0]++; | 485 | p[0]++; |
479 | sprintf(rs, "\r\n%d", f->badmul); | 486 | sprintf(rs, "\r\n0-255"); |
480 | isdn_tty_at_cout(rs, info); | 487 | isdn_tty_at_cout(rs, info); |
481 | break; | 488 | } else { |
482 | case '=': | 489 | par = isdn_getnum(p); |
483 | p[0]++; | 490 | if ((par < 0) || (par > 255)) |
484 | if (*p[0] == '?') { | 491 | PARSE_ERROR1; |
485 | p[0]++; | 492 | f->badmul = par; |
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] == '?') { | ||
508 | p[0]++; | 515 | p[0]++; |
509 | sprintf(rs, "\r\n%d", f->bor); | 516 | sprintf(rs, "\r\n0,1"); |
510 | isdn_tty_at_cout(rs, info); | 517 | isdn_tty_at_cout(rs, info); |
511 | break; | 518 | } else { |
512 | case '=': | 519 | par = isdn_getnum(p); |
513 | p[0]++; | 520 | if ((par < 0) || (par > 1)) |
514 | if (*p[0] == '?') { | 521 | PARSE_ERROR1; |
515 | p[0]++; | 522 | f->bor = par; |
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] == '?') { | ||
538 | p[0]++; | 545 | p[0]++; |
539 | sprintf(rs, "\r\n%d", f->nbc); | 546 | sprintf(rs, "\r\n0,1"); |
540 | isdn_tty_at_cout(rs, info); | 547 | isdn_tty_at_cout(rs, info); |
541 | break; | 548 | } else { |
542 | case '=': | 549 | par = isdn_getnum(p); |
543 | p[0]++; | 550 | if ((par < 0) || (par > 1)) |
544 | if (*p[0] == '?') { | 551 | PARSE_ERROR1; |
545 | p[0]++; | 552 | f->nbc = par; |
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] == '?') { | ||
580 | p[0]++; | 587 | p[0]++; |
581 | sprintf(rs, "\r\n\"%s\"", f->pollid); | 588 | sprintf(rs, "\r\n\"STRING\""); |
582 | isdn_tty_at_cout(rs, info); | 589 | isdn_tty_at_cout(rs, info); |
583 | break; | 590 | } else { |
584 | case '=': | 591 | if (*p[0] == '"') |
585 | p[0]++; | ||
586 | if (*p[0] == '?') { | ||
587 | p[0]++; | 592 | p[0]++; |
588 | sprintf(rs, "\r\n\"STRING\""); | 593 | for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { |
589 | isdn_tty_at_cout(rs, info); | 594 | f->pollid[i] = *p[0]++; |
590 | } else { | 595 | } |
591 | if (*p[0] == '"') | 596 | if (*p[0] == '"') |
592 | p[0]++; | 597 | p[0]++; |
593 | for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { | 598 | for (r = i; r < FAXIDLEN; r++) { |
594 | f->pollid[i] = *p[0]++; | 599 | f->pollid[r] = 32; |
595 | } | 600 | } |
596 | if (*p[0] == '"') | 601 | f->pollid[FAXIDLEN - 1] = 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] == '?') { | ||
617 | p[0]++; | 624 | p[0]++; |
618 | sprintf(rs, "\r\n%d", f->cq); | 625 | sprintf(rs, "\r\n0,1,2"); |
619 | isdn_tty_at_cout(rs, info); | 626 | isdn_tty_at_cout(rs, info); |
620 | break; | 627 | } else { |
621 | case '=': | 628 | par = isdn_getnum(p); |
622 | p[0]++; | 629 | if ((par < 0) || (par > 2)) |
623 | if (*p[0] == '?') { | 630 | PARSE_ERROR1; |
624 | p[0]++; | 631 | f->cq = par; |
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] == '?') { | ||
647 | p[0]++; | 654 | p[0]++; |
648 | sprintf(rs, "\r\n%d", f->cr); /* read actual value from struct and print */ | 655 | sprintf(rs, "\r\n0,1"); /* display online help */ |
649 | isdn_tty_at_cout(rs, info); | 656 | isdn_tty_at_cout(rs, info); |
650 | break; | 657 | } else { |
651 | case '=': | 658 | par = isdn_getnum(p); |
652 | p[0]++; | 659 | if ((par < 0) || (par > 1)) |
653 | if (*p[0] == '?') { | 660 | PARSE_ERROR1; |
654 | p[0]++; | 661 | f->cr = par; |
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] == '?') { | ||
677 | p[0]++; | 684 | p[0]++; |
678 | sprintf(rs, "\r\n%d", f->ctcrty); | 685 | sprintf(rs, "\r\n0-255"); |
679 | isdn_tty_at_cout(rs, info); | 686 | isdn_tty_at_cout(rs, info); |
680 | break; | 687 | } else { |
681 | case '=': | 688 | par = isdn_getnum(p); |
682 | p[0]++; | 689 | if ((par < 0) || (par > 255)) |
683 | if (*p[0] == '?') { | 690 | PARSE_ERROR1; |
684 | p[0]++; | 691 | f->ctcrty = par; |
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]++; | 710 | p[0]++; |
711 | strcpy(rs, "\r\n"); | 711 | strcpy(rs, "\r\n"); |
712 | for (i = 0; i < 8; i++) { | 712 | for (i = 0; i < 8; i++) { |
713 | sprintf(rss, "%c%s", rp[i] + 48, | 713 | sprintf(rss, "%c%s", rp[i] + 48, |
714 | (i < 7) ? "," : ""); | 714 | (i < 7) ? "," : ""); |
715 | strcat(rs, rss); | 715 | strcat(rs, rss); |
716 | } | 716 | } |
717 | isdn_tty_at_cout(rs, info); | 717 | isdn_tty_at_cout(rs, info); |
718 | break; | 718 | break; |
719 | case '=': | 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); | ||
720 | p[0]++; | 723 | p[0]++; |
721 | if (*p[0] == '?') { | 724 | } else { |
722 | isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info); | 725 | for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { |
723 | p[0]++; | 726 | if (*p[0] != ',') { |
724 | } else { | 727 | if ((*p[0] - 48) > maxdccval[i]) { |
725 | for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { | 728 | PARSE_ERROR1; |
726 | if (*p[0] != ',') { | 729 | } |
727 | if ((*p[0] - 48) > maxdccval[i]) { | 730 | rp[i] = *p[0] - 48; |
728 | PARSE_ERROR1; | 731 | p[0]++; |
729 | } | 732 | if (*p[0] == ',') |
730 | rp[i] = *p[0] - 48; | ||
731 | p[0]++; | ||
732 | if (*p[0] == ',') | ||
733 | p[0]++; | ||
734 | } else | ||
735 | p[0]++; | 733 | p[0]++; |
736 | } | 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]++; | 756 | p[0]++; |
757 | strcpy(rs, "\r\n"); | 757 | strcpy(rs, "\r\n"); |
758 | for (i = 0; i < 8; i++) { | 758 | for (i = 0; i < 8; i++) { |
759 | sprintf(rss, "%c%s", rp[i] + 48, | 759 | sprintf(rss, "%c%s", rp[i] + 48, |
760 | (i < 7) ? "," : ""); | 760 | (i < 7) ? "," : ""); |
761 | strcat(rs, rss); | 761 | strcat(rs, rss); |
762 | } | 762 | } |
763 | isdn_tty_at_cout(rs, info); | 763 | isdn_tty_at_cout(rs, info); |
764 | break; | 764 | break; |
765 | case '=': | 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); | ||
766 | p[0]++; | 769 | p[0]++; |
767 | if (*p[0] == '?') { | 770 | } else { |
768 | isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info); | 771 | for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { |
769 | p[0]++; | 772 | if (*p[0] != ',') { |
770 | } else { | 773 | if ((*p[0] - 48) > maxdccval[i]) { |
771 | for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { | 774 | PARSE_ERROR1; |
772 | if (*p[0] != ',') { | 775 | } |
773 | if ((*p[0] - 48) > maxdccval[i]) { | 776 | rp[i] = *p[0] - 48; |
774 | PARSE_ERROR1; | 777 | p[0]++; |
775 | } | 778 | if (*p[0] == ',') |
776 | rp[i] = *p[0] - 48; | ||
777 | p[0]++; | ||
778 | if (*p[0] == ',') | ||
779 | p[0]++; | ||
780 | } else | ||
781 | p[0]++; | 779 | p[0]++; |
782 | } | 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] == '?') { | ||
876 | p[0]++; | 883 | p[0]++; |
877 | sprintf(rs, "\r\n%d", f->ecm); | 884 | sprintf(rs, "\r\n0,2"); |
878 | isdn_tty_at_cout(rs, info); | 885 | isdn_tty_at_cout(rs, info); |
879 | break; | 886 | } else { |
880 | case '=': | 887 | par = isdn_getnum(p); |
881 | p[0]++; | 888 | if ((par != 0) && (par != 2)) |
882 | if (*p[0] == '?') { | 889 | PARSE_ERROR1; |
883 | p[0]++; | 890 | f->ecm = par; |
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] == '?') { | ||
942 | p[0]++; | 949 | p[0]++; |
943 | sprintf(rs, "\r\n\"%s\"", f->id); | 950 | sprintf(rs, "\r\n\"STRING\""); |
944 | isdn_tty_at_cout(rs, info); | 951 | isdn_tty_at_cout(rs, info); |
945 | break; | 952 | } else { |
946 | case '=': | 953 | if (*p[0] == '"') |
947 | p[0]++; | ||
948 | if (*p[0] == '?') { | ||
949 | p[0]++; | 954 | p[0]++; |
950 | sprintf(rs, "\r\n\"STRING\""); | 955 | for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { |
951 | isdn_tty_at_cout(rs, info); | 956 | f->id[i] = *p[0]++; |
952 | } else { | 957 | } |
953 | if (*p[0] == '"') | 958 | if (*p[0] == '"') |
954 | p[0]++; | 959 | p[0]++; |
955 | for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { | 960 | for (r = i; r < FAXIDLEN; r++) { |
956 | f->id[i] = *p[0]++; | 961 | f->id[r] = 32; |
957 | } | 962 | } |
958 | if (*p[0] == '"') | 963 | f->id[FAXIDLEN - 1] = 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] == '?') { | ||
998 | p[0]++; | 1005 | p[0]++; |
999 | sprintf(rs, "\r\n%d", f->minsp); | 1006 | sprintf(rs, "\r\n0-5"); |
1000 | isdn_tty_at_cout(rs, info); | 1007 | isdn_tty_at_cout(rs, info); |
1001 | break; | 1008 | } else { |
1002 | case '=': | 1009 | par = isdn_getnum(p); |
1003 | p[0]++; | 1010 | if ((par < 0) || (par > 5)) |
1004 | if (*p[0] == '?') { | 1011 | PARSE_ERROR1; |
1005 | p[0]++; | 1012 | f->minsp = par; |
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] == '?') { | ||
1028 | p[0]++; | 1035 | p[0]++; |
1029 | sprintf(rs, "\r\n%d", f->phcto); | 1036 | sprintf(rs, "\r\n0-255"); |
1030 | isdn_tty_at_cout(rs, info); | 1037 | isdn_tty_at_cout(rs, info); |
1031 | break; | 1038 | } else { |
1032 | case '=': | 1039 | par = isdn_getnum(p); |
1033 | p[0]++; | 1040 | if ((par < 0) || (par > 255)) |
1034 | if (*p[0] == '?') { | 1041 | PARSE_ERROR1; |
1035 | p[0]++; | 1042 | f->phcto = par; |
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] == '?') { | ||
1059 | p[0]++; | 1066 | p[0]++; |
1060 | sprintf(rs, "\r\n%d", f->rel); | 1067 | sprintf(rs, "\r\n0,1"); |
1061 | isdn_tty_at_cout(rs, info); | 1068 | isdn_tty_at_cout(rs, info); |
1062 | break; | 1069 | } else { |
1063 | case '=': | 1070 | par = isdn_getnum(p); |
1064 | p[0]++; | 1071 | if ((par < 0) || (par > 1)) |
1065 | if (*p[0] == '?') { | 1072 | PARSE_ERROR1; |
1066 | p[0]++; | 1073 | f->rel = par; |
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 | ||
1115 | int | 1115 | int |
1116 | isdn_tty_cmd_PLUSF_FAX(char **p, modem_info * info) | 1116 | isdn_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 757a89010020..ccda4fcf8f7b 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.h +++ b/drivers/isdn/i4l/isdn_ttyfax.h | |||
@@ -15,4 +15,3 @@ | |||
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 c5d02b6aafab..52827a80c51f 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 | */ |
33 | static unsigned char V110_OnMatrix_9600[] = | 33 | static unsigned char V110_OnMatrix_9600[] = |
@@ -56,7 +56,7 @@ static unsigned char V110_OnMatrix_38400[] = | |||
56 | static unsigned char V110_OffMatrix_38400[] = | 56 | static 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 */ |
134 | void | 134 | void |
135 | isdn_v110_close(isdn_v110_stream * v) | 135 | isdn_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 | */ |
150 | static int | 150 | static int |
151 | ValidHeaderBytes(isdn_v110_stream * v) | 151 | ValidHeaderBytes(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 | */ |
163 | static void | 163 | static void |
164 | SyncHeader(isdn_v110_stream * v) | 164 | SyncHeader(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 | */ |
189 | static int | 189 | static int |
190 | DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf) | 190 | DecodeMatrix(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 | */ |
254 | struct sk_buff * | 254 | struct sk_buff * |
255 | isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb) | 255 | isdn_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; |
286 | ReSync: | 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 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb) | |||
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 | */ |
324 | static int | 324 | static int |
325 | EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) | 325 | EncodeMatrix(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 | ||
449 | struct sk_buff * | 449 | struct sk_buff * |
450 | isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb) | 450 | isdn_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; | ||
541 | } else { | 557 | } else { |
542 | if (v->skbuser > 0) | 558 | if (v->SyncInit) |
543 | v->skbuser--; | 559 | v->SyncInit--; |
544 | ret = 0; | 560 | v->skbidle++; |
545 | } | 561 | } |
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:; | ||
546 | } | 595 | } |
547 | for (i = v->skbuser + v->skbidle; i < 2; i++) { | 596 | if ((v = dev->v110[idx])) { |
548 | struct sk_buff *skb; | 597 | while (v->SyncInit) { |
549 | if (v->SyncInit > 0) | 598 | struct sk_buff *skb = isdn_v110_sync(v); |
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) { | 599 | if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { |
555 | dev_kfree_skb(skb); | 600 | dev_kfree_skb(skb); |
601 | /* Unable to send, try later */ | ||
556 | break; | 602 | break; |
557 | } else { | ||
558 | if (v->SyncInit) | ||
559 | v->SyncInit--; | ||
560 | v->skbidle++; | ||
561 | } | 603 | } |
562 | } else | 604 | v->SyncInit--; |
563 | break; | 605 | v->skbidle++; |
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 | } | 606 | } |
576 | mdelay(1); | 607 | } else |
577 | } | 608 | printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx); |
578 | break; | 609 | atomic_dec(&dev->v110use[idx]); |
579 | case ISDN_STAT_BCONN: | 610 | } |
580 | if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) { | 611 | break; |
581 | int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; | 612 | default: |
582 | int maxsize = dev->drv[c->driver]->interface->maxbufsize; | 613 | return 0; |
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 08f274bbc438..de774ab598c9 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 | */ |
18 | extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *); | 18 | extern 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 | */ |
24 | extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *); | 24 | extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *); |
25 | 25 | ||
26 | extern int isdn_v110_stat_callback(int, isdn_ctrl *); | 26 | extern int isdn_v110_stat_callback(int, isdn_ctrl *); |
27 | extern void isdn_v110_close(isdn_v110_stream * v); | 27 | extern 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 fd10d7c785d4..e2d4e58230f5 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 | ||
32 | typedef struct isdn_x25iface_proto_data { | 32 | typedef 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); */ |
44 | static void isdn_x25iface_proto_del( struct concap_proto * ); | 44 | static void isdn_x25iface_proto_del(struct concap_proto *); |
45 | static int isdn_x25iface_proto_close( struct concap_proto * ); | 45 | static int isdn_x25iface_proto_close(struct concap_proto *); |
46 | static int isdn_x25iface_proto_restart( struct concap_proto *, | 46 | static 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 *); |
49 | static int isdn_x25iface_xmit( struct concap_proto *, struct sk_buff * ); | 49 | static int isdn_x25iface_xmit(struct concap_proto *, struct sk_buff *); |
50 | static int isdn_x25iface_receive( struct concap_proto *, struct sk_buff * ); | 50 | static int isdn_x25iface_receive(struct concap_proto *, struct sk_buff *); |
51 | static int isdn_x25iface_connect_ind( struct concap_proto * ); | 51 | static int isdn_x25iface_connect_ind(struct concap_proto *); |
52 | static int isdn_x25iface_disconn_ind( struct concap_proto * ); | 52 | static int isdn_x25iface_disconn_ind(struct concap_proto *); |
53 | 53 | ||
54 | 54 | ||
55 | static struct concap_proto_ops ix25_pops = { | 55 | static 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 */ |
67 | static void illegal_state_warn( unsigned state, unsigned char firstbyte) | 67 | static 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 */ |
74 | static int pdata_is_bad( ix25_pdata_t * pda ){ | 74 | static 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 | */ |
84 | struct concap_proto * isdn_x25iface_proto_new(void) | 84 | struct 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 | */ |
106 | static int isdn_x25iface_proto_close(struct concap_proto *cprot){ | 106 | static 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 | */ |
133 | static void isdn_x25iface_proto_del(struct concap_proto *cprot){ | 133 | static void isdn_x25iface_proto_del(struct concap_proto *cprot) { |
134 | |||
135 | ix25_pdata_t *tmp; | ||
134 | 136 | ||
135 | ix25_pdata_t * tmp; | 137 | IX25DEBUG("isdn_x25iface_proto_del \n"); |
136 | 138 | if (!cprot) { | |
137 | IX25DEBUG( "isdn_x25iface_proto_del \n" ); | 139 | printk(KERN_ERR "isdn_x25iface_proto_del: " |
138 | if( ! cprot ){ | 140 | "concap_proto pointer is NULL\n"); |
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 | */ |
162 | static int isdn_x25iface_proto_restart(struct concap_proto *cprot, | 162 | static 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 | */ |
191 | static int isdn_x25iface_receive(struct concap_proto *cprot, struct sk_buff *skb) | 191 | static 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 | */ |
210 | static int isdn_x25iface_connect_ind(struct concap_proto *cprot) | 210 | static 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 | */ |
241 | static int isdn_x25iface_disconn_ind(struct concap_proto *cprot) | 241 | static 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 | */ |
270 | static int isdn_x25iface_xmit(struct concap_proto *cprot, struct sk_buff *skb) | 270 | static 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 41a3d4977466..0b26e3b336e7 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,17 +23,9 @@ | |||
23 | #include <linux/isdn.h> | 23 | #include <linux/isdn.h> |
24 | #include <linux/concap.h> | 24 | #include <linux/concap.h> |
25 | 25 | ||
26 | extern struct concap_proto_ops * isdn_x25iface_concap_proto_ops_pt; | 26 | extern struct concap_proto_ops *isdn_x25iface_concap_proto_ops_pt; |
27 | extern struct concap_proto * isdn_x25iface_proto_new(void); | 27 | extern 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 c989aa35dc2f..027d1c590679 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 | */ |
131 | int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen, | 131 | int 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 | */ |
354 | int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen, | 354 | int 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++; |