capi.c 31.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
/* $Id: capi.c,v 1.9.6.2 2001/09/23 22:24:32 kai Exp $
 *
 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
 * CAPI encoder/decoder
 *
 * Author       Fritz Elfert
 * Copyright    by Fritz Elfert      <fritz@isdn4linux.de>
 *
 * This software may be used and distributed according to the terms
 * of the GNU General Public License, incorporated herein by reference.
 *
 * Thanks to Friedemann Baitinger and IBM Germany
 *
 */

#include "act2000.h"
#include "capi.h"

static actcapi_msgdsc valid_msg[] = {
	{{ 0x86, 0x02}, "DATA_B3_IND"},       /* DATA_B3_IND/CONF must be first because of speed!!! */
	{{ 0x86, 0x01}, "DATA_B3_CONF"},
	{{ 0x02, 0x01}, "CONNECT_CONF"},
	{{ 0x02, 0x02}, "CONNECT_IND"},
	{{ 0x09, 0x01}, "CONNECT_INFO_CONF"},
	{{ 0x03, 0x02}, "CONNECT_ACTIVE_IND"},
	{{ 0x04, 0x01}, "DISCONNECT_CONF"},
	{{ 0x04, 0x02}, "DISCONNECT_IND"},
	{{ 0x05, 0x01}, "LISTEN_CONF"},
	{{ 0x06, 0x01}, "GET_PARAMS_CONF"},
	{{ 0x07, 0x01}, "INFO_CONF"},
	{{ 0x07, 0x02}, "INFO_IND"},
	{{ 0x08, 0x01}, "DATA_CONF"},
	{{ 0x08, 0x02}, "DATA_IND"},
	{{ 0x40, 0x01}, "SELECT_B2_PROTOCOL_CONF"},
	{{ 0x80, 0x01}, "SELECT_B3_PROTOCOL_CONF"},
	{{ 0x81, 0x01}, "LISTEN_B3_CONF"},
	{{ 0x82, 0x01}, "CONNECT_B3_CONF"},
	{{ 0x82, 0x02}, "CONNECT_B3_IND"},
	{{ 0x83, 0x02}, "CONNECT_B3_ACTIVE_IND"},
	{{ 0x84, 0x01}, "DISCONNECT_B3_CONF"},
	{{ 0x84, 0x02}, "DISCONNECT_B3_IND"},
	{{ 0x85, 0x01}, "GET_B3_PARAMS_CONF"},
	{{ 0x01, 0x01}, "RESET_B3_CONF"},
	{{ 0x01, 0x02}, "RESET_B3_IND"},
	/* {{ 0x87, 0x02, "HANDSET_IND"}, not implemented */
	{{ 0xff, 0x01}, "MANUFACTURER_CONF"},
	{{ 0xff, 0x02}, "MANUFACTURER_IND"},
#ifdef DEBUG_MSG
	/* Requests */
	{{ 0x01, 0x00}, "RESET_B3_REQ"},
	{{ 0x02, 0x00}, "CONNECT_REQ"},
	{{ 0x04, 0x00}, "DISCONNECT_REQ"},
	{{ 0x05, 0x00}, "LISTEN_REQ"},
	{{ 0x06, 0x00}, "GET_PARAMS_REQ"},
	{{ 0x07, 0x00}, "INFO_REQ"},
	{{ 0x08, 0x00}, "DATA_REQ"},
	{{ 0x09, 0x00}, "CONNECT_INFO_REQ"},
	{{ 0x40, 0x00}, "SELECT_B2_PROTOCOL_REQ"},
	{{ 0x80, 0x00}, "SELECT_B3_PROTOCOL_REQ"},
	{{ 0x81, 0x00}, "LISTEN_B3_REQ"},
	{{ 0x82, 0x00}, "CONNECT_B3_REQ"},
	{{ 0x84, 0x00}, "DISCONNECT_B3_REQ"},
	{{ 0x85, 0x00}, "GET_B3_PARAMS_REQ"},
	{{ 0x86, 0x00}, "DATA_B3_REQ"},
	{{ 0xff, 0x00}, "MANUFACTURER_REQ"},
	/* Responses */
	{{ 0x01, 0x03}, "RESET_B3_RESP"},
	{{ 0x02, 0x03}, "CONNECT_RESP"},
	{{ 0x03, 0x03}, "CONNECT_ACTIVE_RESP"},
	{{ 0x04, 0x03}, "DISCONNECT_RESP"},
	{{ 0x07, 0x03}, "INFO_RESP"},
	{{ 0x08, 0x03}, "DATA_RESP"},
	{{ 0x82, 0x03}, "CONNECT_B3_RESP"},
	{{ 0x83, 0x03}, "CONNECT_B3_ACTIVE_RESP"},
	{{ 0x84, 0x03}, "DISCONNECT_B3_RESP"},
	{{ 0x86, 0x03}, "DATA_B3_RESP"},
	{{ 0xff, 0x03}, "MANUFACTURER_RESP"},
#endif
	{{ 0x00, 0x00}, NULL},
};
#define num_valid_imsg 27 /* MANUFACTURER_IND */

/*
 * Check for a valid incoming CAPI message.
 * Return:
 *   0 = Invalid message
 *   1 = Valid message, no B-Channel-data
 *   2 = Valid message, B-Channel-data
 */
int
actcapi_chkhdr(act2000_card *card, actcapi_msghdr *hdr)
{
	int i;

	if (hdr->applicationID != 1)
		return 0;
	if (hdr->len < 9)
		return 0;
	for (i = 0; i < num_valid_imsg; i++)
		if ((hdr->cmd.cmd == valid_msg[i].cmd.cmd) &&
		    (hdr->cmd.subcmd == valid_msg[i].cmd.subcmd)) {
			return (i ? 1 : 2);
		}
	return 0;
}

#define ACTCAPI_MKHDR(l, c, s) {				\
		skb = alloc_skb(l + 8, GFP_ATOMIC);		\
		if (skb) {					\
			m = (actcapi_msg *)skb_put(skb, l + 8); \
			m->hdr.len = l + 8;			\
			m->hdr.applicationID = 1;		\
			m->hdr.cmd.cmd = c;			\
			m->hdr.cmd.subcmd = s;			\
			m->hdr.msgnum = actcapi_nextsmsg(card); \
		} else m = NULL;				\
	}

#define ACTCAPI_CHKSKB if (!skb) {					\
		printk(KERN_WARNING "actcapi: alloc_skb failed\n");	\
		return;							\
	}

#define ACTCAPI_QUEUE_TX {				\
		actcapi_debug_msg(skb, 1);		\
		skb_queue_tail(&card->sndq, skb);	\
		act2000_schedule_tx(card);		\
	}

int
actcapi_listen_req(act2000_card *card)
{
	__u16 eazmask = 0;
	int i;
	actcapi_msg *m;
	struct sk_buff *skb;

	for (i = 0; i < ACT2000_BCH; i++)
		eazmask |= card->bch[i].eazmask;
	ACTCAPI_MKHDR(9, 0x05, 0x00);
	if (!skb) {
		printk(KERN_WARNING "actcapi: alloc_skb failed\n");
		return -ENOMEM;
	}
	m->msg.listen_req.controller = 0;
	m->msg.listen_req.infomask = 0x3f; /* All information */
	m->msg.listen_req.eazmask = eazmask;
	m->msg.listen_req.simask = (eazmask) ? 0x86 : 0; /* All SI's  */
	ACTCAPI_QUEUE_TX;
	return 0;
}

int
actcapi_connect_req(act2000_card *card, act2000_chan *chan, char *phone,
		    char eaz, int si1, int si2)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR((11 + strlen(phone)), 0x02, 0x00);
	if (!skb) {
		printk(KERN_WARNING "actcapi: alloc_skb failed\n");
		chan->fsm_state = ACT2000_STATE_NULL;
		return -ENOMEM;
	}
	m->msg.connect_req.controller = 0;
	m->msg.connect_req.bchan = 0x83;
	m->msg.connect_req.infomask = 0x3f;
	m->msg.connect_req.si1 = si1;
	m->msg.connect_req.si2 = si2;
	m->msg.connect_req.eaz = eaz ? eaz : '0';
	m->msg.connect_req.addr.len = strlen(phone) + 1;
	m->msg.connect_req.addr.tnp = 0x81;
	memcpy(m->msg.connect_req.addr.num, phone, strlen(phone));
	chan->callref = m->hdr.msgnum;
	ACTCAPI_QUEUE_TX;
	return 0;
}

static void
actcapi_connect_b3_req(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(17, 0x82, 0x00);
	ACTCAPI_CHKSKB;
	m->msg.connect_b3_req.plci = chan->plci;
	memset(&m->msg.connect_b3_req.ncpi, 0,
	       sizeof(m->msg.connect_b3_req.ncpi));
	m->msg.connect_b3_req.ncpi.len = 13;
	m->msg.connect_b3_req.ncpi.modulo = 8;
	ACTCAPI_QUEUE_TX;
}

/*
 * Set net type (1TR6) or (EDSS1)
 */
int
actcapi_manufacturer_req_net(act2000_card *card)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(5, 0xff, 0x00);
	if (!skb) {
		printk(KERN_WARNING "actcapi: alloc_skb failed\n");
		return -ENOMEM;
	}
	m->msg.manufacturer_req_net.manuf_msg = 0x11;
	m->msg.manufacturer_req_net.controller = 1;
	m->msg.manufacturer_req_net.nettype = (card->ptype == ISDN_PTYPE_EURO) ? 1 : 0;
	ACTCAPI_QUEUE_TX;
	printk(KERN_INFO "act2000 %s: D-channel protocol now %s\n",
	       card->interface.id, (card->ptype == ISDN_PTYPE_EURO) ? "euro" : "1tr6");
	card->interface.features &=
		~(ISDN_FEATURE_P_UNKNOWN | ISDN_FEATURE_P_EURO | ISDN_FEATURE_P_1TR6);
	card->interface.features |=
		((card->ptype == ISDN_PTYPE_EURO) ? ISDN_FEATURE_P_EURO : ISDN_FEATURE_P_1TR6);
	return 0;
}

/*
 * Switch V.42 on or off
 */
#if 0
int
actcapi_manufacturer_req_v42(act2000_card *card, ulong arg)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(8, 0xff, 0x00);
	if (!skb) {

		printk(KERN_WARNING "actcapi: alloc_skb failed\n");
		return -ENOMEM;
	}
	m->msg.manufacturer_req_v42.manuf_msg = 0x10;
	m->msg.manufacturer_req_v42.controller = 0;
	m->msg.manufacturer_req_v42.v42control = (arg ? 1 : 0);
	ACTCAPI_QUEUE_TX;
	return 0;
}
#endif  /*  0  */

/*
 * Set error-handler
 */
int
actcapi_manufacturer_req_errh(act2000_card *card)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(4, 0xff, 0x00);
	if (!skb) {

		printk(KERN_WARNING "actcapi: alloc_skb failed\n");
		return -ENOMEM;
	}
	m->msg.manufacturer_req_err.manuf_msg = 0x03;
	m->msg.manufacturer_req_err.controller = 0;
	ACTCAPI_QUEUE_TX;
	return 0;
}

/*
 * Set MSN-Mapping.
 */
int
actcapi_manufacturer_req_msn(act2000_card *card)
{
	msn_entry *p = card->msn_list;
	actcapi_msg *m;
	struct sk_buff *skb;
	int len;

	while (p) {
		int i;

		len = strlen(p->msn);
		for (i = 0; i < 2; i++) {
			ACTCAPI_MKHDR(6 + len, 0xff, 0x00);
			if (!skb) {
				printk(KERN_WARNING "actcapi: alloc_skb failed\n");
				return -ENOMEM;
			}
			m->msg.manufacturer_req_msn.manuf_msg = 0x13 + i;
			m->msg.manufacturer_req_msn.controller = 0;
			m->msg.manufacturer_req_msn.msnmap.eaz = p->eaz;
			m->msg.manufacturer_req_msn.msnmap.len = len;
			memcpy(m->msg.manufacturer_req_msn.msnmap.msn, p->msn, len);
			ACTCAPI_QUEUE_TX;
		}
		p = p->next;
	}
	return 0;
}

void
actcapi_select_b2_protocol_req(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(10, 0x40, 0x00);
	ACTCAPI_CHKSKB;
	m->msg.select_b2_protocol_req.plci = chan->plci;
	memset(&m->msg.select_b2_protocol_req.dlpd, 0,
	       sizeof(m->msg.select_b2_protocol_req.dlpd));
	m->msg.select_b2_protocol_req.dlpd.len = 6;
	switch (chan->l2prot) {
	case ISDN_PROTO_L2_TRANS:
		m->msg.select_b2_protocol_req.protocol = 0x03;
		m->msg.select_b2_protocol_req.dlpd.dlen = 4000;
		break;
	case ISDN_PROTO_L2_HDLC:
		m->msg.select_b2_protocol_req.protocol = 0x02;
		m->msg.select_b2_protocol_req.dlpd.dlen = 4000;
		break;
	case ISDN_PROTO_L2_X75I:
	case ISDN_PROTO_L2_X75UI:
	case ISDN_PROTO_L2_X75BUI:
		m->msg.select_b2_protocol_req.protocol = 0x01;
		m->msg.select_b2_protocol_req.dlpd.dlen = 4000;
		m->msg.select_b2_protocol_req.dlpd.laa = 3;
		m->msg.select_b2_protocol_req.dlpd.lab = 1;
		m->msg.select_b2_protocol_req.dlpd.win = 7;
		m->msg.select_b2_protocol_req.dlpd.modulo = 8;
		break;
	}
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_select_b3_protocol_req(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(17, 0x80, 0x00);
	ACTCAPI_CHKSKB;
	m->msg.select_b3_protocol_req.plci = chan->plci;
	memset(&m->msg.select_b3_protocol_req.ncpd, 0,
	       sizeof(m->msg.select_b3_protocol_req.ncpd));
	switch (chan->l3prot) {
	case ISDN_PROTO_L3_TRANS:
		m->msg.select_b3_protocol_req.protocol = 0x04;
		m->msg.select_b3_protocol_req.ncpd.len = 13;
		m->msg.select_b3_protocol_req.ncpd.modulo = 8;
		break;
	}
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_listen_b3_req(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(2, 0x81, 0x00);
	ACTCAPI_CHKSKB;
	m->msg.listen_b3_req.plci = chan->plci;
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_disconnect_req(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(3, 0x04, 0x00);
	ACTCAPI_CHKSKB;
	m->msg.disconnect_req.plci = chan->plci;
	m->msg.disconnect_req.cause = 0;
	ACTCAPI_QUEUE_TX;
}

void
actcapi_disconnect_b3_req(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(17, 0x84, 0x00);
	ACTCAPI_CHKSKB;
	m->msg.disconnect_b3_req.ncci = chan->ncci;
	memset(&m->msg.disconnect_b3_req.ncpi, 0,
	       sizeof(m->msg.disconnect_b3_req.ncpi));
	m->msg.disconnect_b3_req.ncpi.len = 13;
	m->msg.disconnect_b3_req.ncpi.modulo = 8;
	chan->fsm_state = ACT2000_STATE_BHWAIT;
	ACTCAPI_QUEUE_TX;
}

void
actcapi_connect_resp(act2000_card *card, act2000_chan *chan, __u8 cause)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(3, 0x02, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.connect_resp.plci = chan->plci;
	m->msg.connect_resp.rejectcause = cause;
	if (cause) {
		chan->fsm_state = ACT2000_STATE_NULL;
		chan->plci = 0x8000;
	} else
		chan->fsm_state = ACT2000_STATE_IWAIT;
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_connect_active_resp(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(2, 0x03, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.connect_resp.plci = chan->plci;
	if (chan->fsm_state == ACT2000_STATE_IWAIT)
		chan->fsm_state = ACT2000_STATE_IBWAIT;
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_connect_b3_resp(act2000_card *card, act2000_chan *chan, __u8 rejectcause)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR((rejectcause ? 3 : 17), 0x82, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.connect_b3_resp.ncci = chan->ncci;
	m->msg.connect_b3_resp.rejectcause = rejectcause;
	if (!rejectcause) {
		memset(&m->msg.connect_b3_resp.ncpi, 0,
		       sizeof(m->msg.connect_b3_resp.ncpi));
		m->msg.connect_b3_resp.ncpi.len = 13;
		m->msg.connect_b3_resp.ncpi.modulo = 8;
		chan->fsm_state = ACT2000_STATE_BWAIT;
	}
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_connect_b3_active_resp(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(2, 0x83, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.connect_b3_active_resp.ncci = chan->ncci;
	chan->fsm_state = ACT2000_STATE_ACTIVE;
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_info_resp(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(2, 0x07, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.info_resp.plci = chan->plci;
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_disconnect_b3_resp(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(2, 0x84, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.disconnect_b3_resp.ncci = chan->ncci;
	chan->ncci = 0x8000;
	chan->queued = 0;
	ACTCAPI_QUEUE_TX;
}

static void
actcapi_disconnect_resp(act2000_card *card, act2000_chan *chan)
{
	actcapi_msg *m;
	struct sk_buff *skb;

	ACTCAPI_MKHDR(2, 0x04, 0x03);
	ACTCAPI_CHKSKB;
	m->msg.disconnect_resp.plci = chan->plci;
	chan->plci = 0x8000;
	ACTCAPI_QUEUE_TX;
}

static int
new_plci(act2000_card *card, __u16 plci)
{
	int i;
	for (i = 0; i < ACT2000_BCH; i++)
		if (card->bch[i].plci == 0x8000) {
			card->bch[i].plci = plci;
			return i;
		}
	return -1;
}

static int
find_plci(act2000_card *card, __u16 plci)
{
	int i;
	for (i = 0; i < ACT2000_BCH; i++)
		if (card->bch[i].plci == plci)
			return i;
	return -1;
}

static int
find_ncci(act2000_card *card, __u16 ncci)
{
	int i;
	for (i = 0; i < ACT2000_BCH; i++)
		if (card->bch[i].ncci == ncci)
			return i;
	return -1;
}

static int
find_dialing(act2000_card *card, __u16 callref)
{
	int i;
	for (i = 0; i < ACT2000_BCH; i++)
		if ((card->bch[i].callref == callref) &&
		    (card->bch[i].fsm_state == ACT2000_STATE_OCALL))
			return i;
	return -1;
}

static int
actcapi_data_b3_ind(act2000_card *card, struct sk_buff *skb) {
	__u16 plci;
	__u16 ncci;
	__u16 controller;
	__u8  blocknr;
	int chan;
	actcapi_msg *msg = (actcapi_msg *)skb->data;

	EVAL_NCCI(msg->msg.data_b3_ind.fakencci, plci, controller, ncci);
	chan = find_ncci(card, ncci);
	if (chan < 0)
		return 0;
	if (card->bch[chan].fsm_state != ACT2000_STATE_ACTIVE)
		return 0;
	if (card->bch[chan].plci != plci)
		return 0;
	blocknr = msg->msg.data_b3_ind.blocknr;
	skb_pull(skb, 19);
	card->interface.rcvcallb_skb(card->myid, chan, skb);
	if (!(skb = alloc_skb(11, GFP_ATOMIC))) {
		printk(KERN_WARNING "actcapi: alloc_skb failed\n");
		return 1;
	}
	msg = (actcapi_msg *)skb_put(skb, 11);
	msg->hdr.len = 11;
	msg->hdr.applicationID = 1;
	msg->hdr.cmd.cmd = 0x86;
	msg->hdr.cmd.subcmd = 0x03;
	msg->hdr.msgnum = actcapi_nextsmsg(card);
	msg->msg.data_b3_resp.ncci = ncci;
	msg->msg.data_b3_resp.blocknr = blocknr;
	ACTCAPI_QUEUE_TX;
	return 1;
}

/*
 * Walk over ackq, unlink DATA_B3_REQ from it, if
 * ncci and blocknr are matching.
 * Decrement queued-bytes counter.
 */
static int
handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) {
	unsigned long flags;
	struct sk_buff *skb;
	struct sk_buff *tmp;
	struct actcapi_msg *m;
	int ret = 0;

	spin_lock_irqsave(&card->lock, flags);
	skb = skb_peek(&card->ackq);
	spin_unlock_irqrestore(&card->lock, flags);
	if (!skb) {
		printk(KERN_WARNING "act2000: handle_ack nothing found!\n");
		return 0;
	}
	tmp = skb;
	while (1) {
		m = (actcapi_msg *)tmp->data;
		if ((((m->msg.data_b3_req.fakencci >> 8) & 0xff) == chan->ncci) &&
		    (m->msg.data_b3_req.blocknr == blocknr)) {
			/* found corresponding DATA_B3_REQ */
			skb_unlink(tmp, &card->ackq);
			chan->queued -= m->msg.data_b3_req.datalen;
			if (m->msg.data_b3_req.flags)
				ret = m->msg.data_b3_req.datalen;
			dev_kfree_skb(tmp);
			if (chan->queued < 0)
				chan->queued = 0;
			return ret;
		}
		spin_lock_irqsave(&card->lock, flags);
		tmp = skb_peek((struct sk_buff_head *)tmp);
		spin_unlock_irqrestore(&card->lock, flags);
		if ((tmp == skb) || (tmp == NULL)) {
			/* reached end of queue */
			printk(KERN_WARNING "act2000: handle_ack nothing found!\n");
			return 0;
		}
	}
}

void
actcapi_dispatch(struct work_struct *work)
{
	struct act2000_card *card =
		container_of(work, struct act2000_card, rcv_tq);
	struct sk_buff *skb;
	actcapi_msg *msg;
	__u16 ccmd;
	int chan;
	int len;
	act2000_chan *ctmp;
	isdn_ctrl cmd;
	char tmp[170];

	while ((skb = skb_dequeue(&card->rcvq))) {
		actcapi_debug_msg(skb, 0);
		msg = (actcapi_msg *)skb->data;
		ccmd = ((msg->hdr.cmd.cmd << 8) | msg->hdr.cmd.subcmd);
		switch (ccmd) {
		case 0x8602:
			/* DATA_B3_IND */
			if (actcapi_data_b3_ind(card, skb))
				return;
			break;
		case 0x8601:
			/* DATA_B3_CONF */
			chan = find_ncci(card, msg->msg.data_b3_conf.ncci);
			if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_ACTIVE)) {
				if (msg->msg.data_b3_conf.info != 0)
					printk(KERN_WARNING "act2000: DATA_B3_CONF: %04x\n",
					       msg->msg.data_b3_conf.info);
				len = handle_ack(card, &card->bch[chan],
						 msg->msg.data_b3_conf.blocknr);
				if (len) {
					cmd.driver = card->myid;
					cmd.command = ISDN_STAT_BSENT;
					cmd.arg = chan;
					cmd.parm.length = len;
					card->interface.statcallb(&cmd);
				}
			}
			break;
		case 0x0201:
			/* CONNECT_CONF */
			chan = find_dialing(card, msg->hdr.msgnum);
			if (chan >= 0) {
				if (msg->msg.connect_conf.info) {
					card->bch[chan].fsm_state = ACT2000_STATE_NULL;
					cmd.driver = card->myid;
					cmd.command = ISDN_STAT_DHUP;
					cmd.arg = chan;
					card->interface.statcallb(&cmd);
				} else {
					card->bch[chan].fsm_state = ACT2000_STATE_OWAIT;
					card->bch[chan].plci = msg->msg.connect_conf.plci;
				}
			}
			break;
		case 0x0202:
			/* CONNECT_IND */
			chan = new_plci(card, msg->msg.connect_ind.plci);
			if (chan < 0) {
				ctmp = (act2000_chan *)tmp;
				ctmp->plci = msg->msg.connect_ind.plci;
				actcapi_connect_resp(card, ctmp, 0x11); /* All Card-Cannels busy */
			} else {
				card->bch[chan].fsm_state = ACT2000_STATE_ICALL;
				cmd.driver = card->myid;
				cmd.command = ISDN_STAT_ICALL;
				cmd.arg = chan;
				cmd.parm.setup.si1 = msg->msg.connect_ind.si1;
				cmd.parm.setup.si2 = msg->msg.connect_ind.si2;
				if (card->ptype == ISDN_PTYPE_EURO)
					strcpy(cmd.parm.setup.eazmsn,
					       act2000_find_eaz(card, msg->msg.connect_ind.eaz));
				else {
					cmd.parm.setup.eazmsn[0] = msg->msg.connect_ind.eaz;
					cmd.parm.setup.eazmsn[1] = 0;
				}
				memset(cmd.parm.setup.phone, 0, sizeof(cmd.parm.setup.phone));
				memcpy(cmd.parm.setup.phone, msg->msg.connect_ind.addr.num,
				       msg->msg.connect_ind.addr.len - 1);
				cmd.parm.setup.plan = msg->msg.connect_ind.addr.tnp;
				cmd.parm.setup.screen = 0;
				if (card->interface.statcallb(&cmd) == 2)
					actcapi_connect_resp(card, &card->bch[chan], 0x15); /* Reject Call */
			}
			break;
		case 0x0302:
			/* CONNECT_ACTIVE_IND */
			chan = find_plci(card, msg->msg.connect_active_ind.plci);
			if (chan >= 0)
				switch (card->bch[chan].fsm_state) {
				case ACT2000_STATE_IWAIT:
					actcapi_connect_active_resp(card, &card->bch[chan]);
					break;
				case ACT2000_STATE_OWAIT:
					actcapi_connect_active_resp(card, &card->bch[chan]);
					actcapi_select_b2_protocol_req(card, &card->bch[chan]);
					break;
				}
			break;
		case 0x8202:
			/* CONNECT_B3_IND */
			chan = find_plci(card, msg->msg.connect_b3_ind.plci);
			if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_IBWAIT)) {
				card->bch[chan].ncci = msg->msg.connect_b3_ind.ncci;
				actcapi_connect_b3_resp(card, &card->bch[chan], 0);
			} else {
				ctmp = (act2000_chan *)tmp;
				ctmp->ncci = msg->msg.connect_b3_ind.ncci;
				actcapi_connect_b3_resp(card, ctmp, 0x11); /* All Card-Cannels busy */
			}
			break;
		case 0x8302:
			/* CONNECT_B3_ACTIVE_IND */
			chan = find_ncci(card, msg->msg.connect_b3_active_ind.ncci);
			if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BWAIT)) {
				actcapi_connect_b3_active_resp(card, &card->bch[chan]);
				cmd.driver = card->myid;
				cmd.command = ISDN_STAT_BCONN;
				cmd.arg = chan;
				card->interface.statcallb(&cmd);
			}
			break;
		case 0x8402:
			/* DISCONNECT_B3_IND */
			chan = find_ncci(card, msg->msg.disconnect_b3_ind.ncci);
			if (chan >= 0) {
				ctmp = &card->bch[chan];
				actcapi_disconnect_b3_resp(card, ctmp);
				switch (ctmp->fsm_state) {
				case ACT2000_STATE_ACTIVE:
					ctmp->fsm_state = ACT2000_STATE_DHWAIT2;
					cmd.driver = card->myid;
					cmd.command = ISDN_STAT_BHUP;
					cmd.arg = chan;
					card->interface.statcallb(&cmd);
					break;
				case ACT2000_STATE_BHWAIT2:
					actcapi_disconnect_req(card, ctmp);
					ctmp->fsm_state = ACT2000_STATE_DHWAIT;
					cmd.driver = card->myid;
					cmd.command = ISDN_STAT_BHUP;
					cmd.arg = chan;
					card->interface.statcallb(&cmd);
					break;
				}
			}
			break;
		case 0x0402:
			/* DISCONNECT_IND */
			chan = find_plci(card, msg->msg.disconnect_ind.plci);
			if (chan >= 0) {
				ctmp = &card->bch[chan];
				actcapi_disconnect_resp(card, ctmp);
				ctmp->fsm_state = ACT2000_STATE_NULL;
				cmd.driver = card->myid;
				cmd.command = ISDN_STAT_DHUP;
				cmd.arg = chan;
				card->interface.statcallb(&cmd);
			} else {
				ctmp = (act2000_chan *)tmp;
				ctmp->plci = msg->msg.disconnect_ind.plci;
				actcapi_disconnect_resp(card, ctmp);
			}
			break;
		case 0x4001:
			/* SELECT_B2_PROTOCOL_CONF */
			chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci);
			if (chan >= 0)
				switch (card->bch[chan].fsm_state) {
				case ACT2000_STATE_ICALL:
				case ACT2000_STATE_OWAIT:
					ctmp = &card->bch[chan];
					if (msg->msg.select_b2_protocol_conf.info == 0)
						actcapi_select_b3_protocol_req(card, ctmp);
					else {
						ctmp->fsm_state = ACT2000_STATE_NULL;
						cmd.driver = card->myid;
						cmd.command = ISDN_STAT_DHUP;
						cmd.arg = chan;
						card->interface.statcallb(&cmd);
					}
					break;
				}
			break;
		case 0x8001:
			/* SELECT_B3_PROTOCOL_CONF */
			chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci);
			if (chan >= 0)
				switch (card->bch[chan].fsm_state) {
				case ACT2000_STATE_ICALL:
				case ACT2000_STATE_OWAIT:
					ctmp = &card->bch[chan];
					if (msg->msg.select_b3_protocol_conf.info == 0)
						actcapi_listen_b3_req(card, ctmp);
					else {
						ctmp->fsm_state = ACT2000_STATE_NULL;
						cmd.driver = card->myid;
						cmd.command = ISDN_STAT_DHUP;
						cmd.arg = chan;
						card->interface.statcallb(&cmd);
					}
				}
			break;
		case 0x8101:
			/* LISTEN_B3_CONF */
			chan = find_plci(card, msg->msg.listen_b3_conf.plci);
			if (chan >= 0)
				switch (card->bch[chan].fsm_state) {
				case ACT2000_STATE_ICALL:
					ctmp = &card->bch[chan];
					if (msg->msg.listen_b3_conf.info == 0)
						actcapi_connect_resp(card, ctmp, 0);
					else {
						ctmp->fsm_state = ACT2000_STATE_NULL;
						cmd.driver = card->myid;
						cmd.command = ISDN_STAT_DHUP;
						cmd.arg = chan;
						card->interface.statcallb(&cmd);
					}
					break;
				case ACT2000_STATE_OWAIT:
					ctmp = &card->bch[chan];
					if (msg->msg.listen_b3_conf.info == 0) {
						actcapi_connect_b3_req(card, ctmp);
						ctmp->fsm_state = ACT2000_STATE_OBWAIT;
						cmd.driver = card->myid;
						cmd.command = ISDN_STAT_DCONN;
						cmd.arg = chan;
						card->interface.statcallb(&cmd);
					} else {
						ctmp->fsm_state = ACT2000_STATE_NULL;
						cmd.driver = card->myid;
						cmd.command = ISDN_STAT_DHUP;
						cmd.arg = chan;
						card->interface.statcallb(&cmd);
					}
					break;
				}
			break;
		case 0x8201:
			/* CONNECT_B3_CONF */
			chan = find_plci(card, msg->msg.connect_b3_conf.plci);
			if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) {
				ctmp = &card->bch[chan];
				if (msg->msg.connect_b3_conf.info) {
					ctmp->fsm_state = ACT2000_STATE_NULL;
					cmd.driver = card->myid;
					cmd.command = ISDN_STAT_DHUP;
					cmd.arg = chan;
					card->interface.statcallb(&cmd);
				} else {
					ctmp->ncci = msg->msg.connect_b3_conf.ncci;
					ctmp->fsm_state = ACT2000_STATE_BWAIT;
				}
			}
			break;
		case 0x8401:
			/* DISCONNECT_B3_CONF */
			chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci);
			if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT))
				card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2;
			break;
		case 0x0702:
			/* INFO_IND */
			chan = find_plci(card, msg->msg.info_ind.plci);
			if (chan >= 0)
				/* TODO: Eval Charging info / cause */
				actcapi_info_resp(card, &card->bch[chan]);
			break;
		case 0x0401:
			/* LISTEN_CONF */
		case 0x0501:
			/* LISTEN_CONF */
		case 0xff01:
			/* MANUFACTURER_CONF */
			break;
		case 0xff02:
			/* MANUFACTURER_IND */
			if (msg->msg.manuf_msg == 3) {
				memset(tmp, 0, sizeof(tmp));
				strncpy(tmp,
					&msg->msg.manufacturer_ind_err.errstring,
					msg->hdr.len - 16);
				if (msg->msg.manufacturer_ind_err.errcode)
					printk(KERN_WARNING "act2000: %s\n", tmp);
				else {
					printk(KERN_DEBUG "act2000: %s\n", tmp);
					if ((!strncmp(tmp, "INFO: Trace buffer con", 22)) ||
					    (!strncmp(tmp, "INFO: Compile Date/Tim", 22))) {
						card->flags |= ACT2000_FLAGS_RUNNING;
						cmd.command = ISDN_STAT_RUN;
						cmd.driver = card->myid;
						cmd.arg = 0;
						actcapi_manufacturer_req_net(card);
						actcapi_manufacturer_req_msn(card);
						actcapi_listen_req(card);
						card->interface.statcallb(&cmd);
					}
				}
			}
			break;
		default:
			printk(KERN_WARNING "act2000: UNHANDLED Message %04x\n", ccmd);
			break;
		}
		dev_kfree_skb(skb);
	}
}

#ifdef DEBUG_MSG
static void
actcapi_debug_caddr(actcapi_addr *addr)
{
	char tmp[30];

	printk(KERN_DEBUG " Alen  = %d\n", addr->len);
	if (addr->len > 0)
		printk(KERN_DEBUG " Atnp  = 0x%02x\n", addr->tnp);
	if (addr->len > 1) {
		memset(tmp, 0, 30);
		memcpy(tmp, addr->num, addr->len - 1);
		printk(KERN_DEBUG " Anum  = '%s'\n", tmp);
	}
}

static void
actcapi_debug_ncpi(actcapi_ncpi *ncpi)
{
	printk(KERN_DEBUG " ncpi.len = %d\n", ncpi->len);
	if (ncpi->len >= 2)
		printk(KERN_DEBUG " ncpi.lic = 0x%04x\n", ncpi->lic);
	if (ncpi->len >= 4)
		printk(KERN_DEBUG " ncpi.hic = 0x%04x\n", ncpi->hic);
	if (ncpi->len >= 6)
		printk(KERN_DEBUG " ncpi.ltc = 0x%04x\n", ncpi->ltc);
	if (ncpi->len >= 8)
		printk(KERN_DEBUG " ncpi.htc = 0x%04x\n", ncpi->htc);
	if (ncpi->len >= 10)
		printk(KERN_DEBUG " ncpi.loc = 0x%04x\n", ncpi->loc);
	if (ncpi->len >= 12)
		printk(KERN_DEBUG " ncpi.hoc = 0x%04x\n", ncpi->hoc);
	if (ncpi->len >= 13)
		printk(KERN_DEBUG " ncpi.mod = %d\n", ncpi->modulo);
}

static void
actcapi_debug_dlpd(actcapi_dlpd *dlpd)
{
	printk(KERN_DEBUG " dlpd.len = %d\n", dlpd->len);
	if (dlpd->len >= 2)
		printk(KERN_DEBUG " dlpd.dlen   = 0x%04x\n", dlpd->dlen);
	if (dlpd->len >= 3)
		printk(KERN_DEBUG " dlpd.laa    = 0x%02x\n", dlpd->laa);
	if (dlpd->len >= 4)
		printk(KERN_DEBUG " dlpd.lab    = 0x%02x\n", dlpd->lab);
	if (dlpd->len >= 5)
		printk(KERN_DEBUG " dlpd.modulo = %d\n", dlpd->modulo);
	if (dlpd->len >= 6)
		printk(KERN_DEBUG " dlpd.win    = %d\n", dlpd->win);
}

#ifdef DEBUG_DUMP_SKB
static void dump_skb(struct sk_buff *skb) {
	char tmp[80];
	char *p = skb->data;
	char *t = tmp;
	int i;

	for (i = 0; i < skb->len; i++) {
		t += sprintf(t, "%02x ", *p++ & 0xff);
		if ((i & 0x0f) == 8) {
			printk(KERN_DEBUG "dump: %s\n", tmp);
			t = tmp;
		}
	}
	if (i & 0x07)
		printk(KERN_DEBUG "dump: %s\n", tmp);
}
#endif

void
actcapi_debug_msg(struct sk_buff *skb, int direction)
{
	actcapi_msg *msg = (actcapi_msg *)skb->data;
	char *descr;
	int i;
	char tmp[170];

#ifndef DEBUG_DATA_MSG
	if (msg->hdr.cmd.cmd == 0x86)
		return;
#endif
	descr = "INVALID";
#ifdef DEBUG_DUMP_SKB
	dump_skb(skb);
#endif
	for (i = 0; i < ARRAY_SIZE(valid_msg); i++)
		if ((msg->hdr.cmd.cmd == valid_msg[i].cmd.cmd) &&
		    (msg->hdr.cmd.subcmd == valid_msg[i].cmd.subcmd)) {
			descr = valid_msg[i].description;
			break;
		}
	printk(KERN_DEBUG "%s %s msg\n", direction ? "Outgoing" : "Incoming", descr);
	printk(KERN_DEBUG " ApplID = %d\n", msg->hdr.applicationID);
	printk(KERN_DEBUG " Len    = %d\n", msg->hdr.len);
	printk(KERN_DEBUG " MsgNum = 0x%04x\n", msg->hdr.msgnum);
	printk(KERN_DEBUG " Cmd    = 0x%02x\n", msg->hdr.cmd.cmd);
	printk(KERN_DEBUG " SubCmd = 0x%02x\n", msg->hdr.cmd.subcmd);
	switch (i) {
	case 0:
		/* DATA B3 IND */
		printk(KERN_DEBUG " BLOCK = 0x%02x\n",
		       msg->msg.data_b3_ind.blocknr);
		break;
	case 2:
		/* CONNECT CONF */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.connect_conf.plci);
		printk(KERN_DEBUG " Info = 0x%04x\n",
		       msg->msg.connect_conf.info);
		break;
	case 3:
		/* CONNECT IND */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.connect_ind.plci);
		printk(KERN_DEBUG " Contr = %d\n",
		       msg->msg.connect_ind.controller);
		printk(KERN_DEBUG " SI1   = %d\n",
		       msg->msg.connect_ind.si1);
		printk(KERN_DEBUG " SI2   = %d\n",
		       msg->msg.connect_ind.si2);
		printk(KERN_DEBUG " EAZ   = '%c'\n",
		       msg->msg.connect_ind.eaz);
		actcapi_debug_caddr(&msg->msg.connect_ind.addr);
		break;
	case 5:
		/* CONNECT ACTIVE IND */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.connect_active_ind.plci);
		actcapi_debug_caddr(&msg->msg.connect_active_ind.addr);
		break;
	case 8:
		/* LISTEN CONF */
		printk(KERN_DEBUG " Contr = %d\n",
		       msg->msg.listen_conf.controller);
		printk(KERN_DEBUG " Info = 0x%04x\n",
		       msg->msg.listen_conf.info);
		break;
	case 11:
		/* INFO IND */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.info_ind.plci);
		printk(KERN_DEBUG " Imsk = 0x%04x\n",
		       msg->msg.info_ind.nr.mask);
		if (msg->hdr.len > 12) {
			int l = msg->hdr.len - 12;
			int j;
			char *p = tmp;
			for (j = 0; j < l; j++)
				p += sprintf(p, "%02x ", msg->msg.info_ind.el.display[j]);
			printk(KERN_DEBUG " D = '%s'\n", tmp);
		}
		break;
	case 14:
		/* SELECT B2 PROTOCOL CONF */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.select_b2_protocol_conf.plci);
		printk(KERN_DEBUG " Info = 0x%04x\n",
		       msg->msg.select_b2_protocol_conf.info);
		break;
	case 15:
		/* SELECT B3 PROTOCOL CONF */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.select_b3_protocol_conf.plci);
		printk(KERN_DEBUG " Info = 0x%04x\n",
		       msg->msg.select_b3_protocol_conf.info);
		break;
	case 16:
		/* LISTEN B3 CONF */
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.listen_b3_conf.plci);
		printk(KERN_DEBUG " Info = 0x%04x\n",
		       msg->msg.listen_b3_conf.info);
		break;
	case 18:
		/* CONNECT B3 IND */
		printk(KERN_DEBUG " NCCI = 0x%04x\n",
		       msg->msg.connect_b3_ind.ncci);
		printk(KERN_DEBUG " PLCI = 0x%04x\n",
		       msg->msg.connect_b3_ind.plci);
		actcapi_debug_ncpi(&msg->msg.connect_b3_ind.ncpi);
		break;
	case 19:
		/* CONNECT B3 ACTIVE IND */
		printk(KERN_DEBUG " NCCI = 0x%04x\n",
		       msg->msg.connect_b3_active_ind.ncci);
		actcapi_debug_ncpi(&msg->msg.connect_b3_active_ind.ncpi);
		break;
	case 26:
		/* MANUFACTURER IND */
		printk(KERN_DEBUG " Mmsg = 0x%02x\n",
		       msg->msg.manufacturer_ind_err.manuf_msg);
		switch (msg->msg.manufacturer_ind_err.manuf_msg) {
		case 3:
			printk(KERN_DEBUG " Contr = %d\n",
			       msg->msg.manufacturer_ind_err.controller);
			printk(KERN_DEBUG " Code = 0x%08x\n",
			       msg->msg.manufacturer_ind_err.errcode);
			memset(tmp, 0, sizeof(tmp));
			strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring,
				msg->hdr.len - 16);
			printk(KERN_DEBUG " Emsg = '%s'\n", tmp);
			break;
		}
		break;
	case 30:
		/* LISTEN REQ */
		printk(KERN_DEBUG " Imsk = 0x%08x\n",
		       msg->msg.listen_req.infomask);
		printk(KERN_DEBUG " Emsk = 0x%04x\n",
		       msg->msg.listen_req.eazmask);
		printk(KERN_DEBUG " Smsk = 0x%04x\n",
		       msg->msg.listen_req.simask);
		break;
	case 35:
		/* SELECT_B2_PROTOCOL_REQ */
		printk(KERN_DEBUG " PLCI  = 0x%04x\n",
		       msg->msg.select_b2_protocol_req.plci);
		printk(KERN_DEBUG " prot  = 0x%02x\n",
		       msg->msg.select_b2_protocol_req.protocol);
		if (msg->hdr.len >= 11)
			printk(KERN_DEBUG "No dlpd\n");
		else
			actcapi_debug_dlpd(&msg->msg.select_b2_protocol_req.dlpd);
		break;
	case 44:
		/* CONNECT RESP */
		printk(KERN_DEBUG " PLCI  = 0x%04x\n",
		       msg->msg.connect_resp.plci);
		printk(KERN_DEBUG " CAUSE = 0x%02x\n",
		       msg->msg.connect_resp.rejectcause);
		break;
	case 45:
		/* CONNECT ACTIVE RESP */
		printk(KERN_DEBUG " PLCI  = 0x%04x\n",
		       msg->msg.connect_active_resp.plci);
		break;
	}
}
#endif