2 * Chan_Misdn -- Channel Driver for Asterisk
6 * Copyright (C) 2004, Christian Richter
8 * Christian Richter <crich@beronet.com>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
15 #include "isdn_lib_intern.h"
23 static void set_channel(struct misdn_bchannel *bc, int channel)
26 cb_log(3,bc->port,"set_channel: bc->channel:%d channel:%d\n", bc->channel, channel);
34 /* ALERT: is that everytime true ? */
35 if (channel > 0 && bc->nt ) {
37 if (bc->channel && ( bc->channel != 0xff) ) {
38 cb_log(0,bc->port,"We already have a channel (%d)\n", bc->channel);
40 bc->channel = channel;
41 cb_event(EVENT_NEW_CHANNEL,bc,NULL);
45 if (channel > 0 && !bc->nt ) {
46 bc->channel = channel;
47 cb_event(EVENT_NEW_CHANNEL,bc,NULL);
51 static void parse_proceeding (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
53 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
54 CALL_PROCEEDING_t *proceeding=(CALL_PROCEEDING_t*)((unsigned long)msg->data+ HEADER_LEN);
55 //struct misdn_stack *stack=get_stack_by_bc(bc);
58 int exclusive, channel;
59 dec_ie_channel_id(proceeding->CHANNEL_ID, (Q931_info_t *)proceeding, &exclusive, &channel, nt,bc);
61 set_channel(bc,channel);
65 dec_ie_progress(proceeding->PROGRESS, (Q931_info_t *)proceeding, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
69 printf("Parsing PROCEEDING Msg\n");
72 static msg_t *build_proceeding (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
74 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
75 CALL_PROCEEDING_t *proceeding;
76 msg_t *msg =(msg_t*)create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, bc?bc->l3_id:-1, sizeof(CALL_PROCEEDING_t) ,nt);
78 proceeding=(CALL_PROCEEDING_t*)((msg->data+HEADER_LEN));
80 enc_ie_channel_id(&proceeding->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
83 enc_ie_progress(&proceeding->PROGRESS, msg, 0, nt?1:5, 8, nt,bc);
87 printf("Building PROCEEDING Msg\n");
92 static void parse_alerting (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
94 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
95 ALERTING_t *alerting=(ALERTING_t*)((unsigned long)(msg->data+HEADER_LEN));
96 //Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN);
98 dec_ie_progress(alerting->PROGRESS, (Q931_info_t *)alerting, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
101 printf("Parsing ALERTING Msg\n");
107 static msg_t *build_alerting (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
109 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
110 ALERTING_t *alerting;
111 msg_t *msg =(msg_t*)create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING, bc?bc->l3_id:-1, sizeof(ALERTING_t) ,nt);
113 alerting=(ALERTING_t*)((msg->data+HEADER_LEN));
115 enc_ie_channel_id(&alerting->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
118 enc_ie_progress(&alerting->PROGRESS, msg, 0, nt?1:5, 8, nt,bc);
120 printf("Building ALERTING Msg\n");
126 static void parse_progress (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
128 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
129 PROGRESS_t *progress=(PROGRESS_t*)((unsigned long)(msg->data+HEADER_LEN));
130 //Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN);
132 dec_ie_progress(progress->PROGRESS, (Q931_info_t *)progress, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
135 printf("Parsing PROGRESS Msg\n");
139 static msg_t *build_progress (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
141 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
142 PROGRESS_t *progress;
143 msg_t *msg =(msg_t*)create_l3msg(CC_PROGRESS | REQUEST, MT_PROGRESS, bc?bc->l3_id:-1, sizeof(PROGRESS_t) ,nt);
145 progress=(PROGRESS_t*)((msg->data+HEADER_LEN));
148 printf("Building PROGRESS Msg\n");
153 static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
155 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
156 SETUP_t *setup= (SETUP_t*)((unsigned long)msg->data+HEADER_LEN);
157 Q931_info_t *qi=(Q931_info_t*)((unsigned long)msg->data+HEADER_LEN);
160 printf("Parsing SETUP Msg\n");
163 int type,plan,present, screen;
165 dec_ie_calling_pn(setup->CALLING_PN, qi, &type, &plan, &present, &screen, id, sizeof(id)-1, nt,bc);
171 bc->pres=0; /* screened */
174 bc->pres=1; /* not screened */
189 dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)setup, &type, &plan, number, sizeof(number)-1, nt,bc);
190 strcpy(bc->dad, number);
195 dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)setup, keypad, sizeof(keypad)-1, nt,bc);
196 strcpy(bc->keypad, keypad);
200 dec_ie_complete(setup->COMPLETE, (Q931_info_t *)setup, &bc->sending_complete, nt,bc);
205 int type, plan, present, screen, reason;
207 dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)setup, &type, &plan, &present, &screen, &reason, id, sizeof(id)-1, nt,bc);
213 int coding, capability, mode, rate, multi, user, async, urate, stopbits, dbits, parity;
214 dec_ie_bearer(setup->BEARER, (Q931_info_t *)setup, &coding, &capability, &mode, &rate, &multi, &user, &async, &urate, &stopbits, &dbits, &parity, nt,bc);
215 switch (capability) {
216 case -1: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED;
218 case 0: bc->capability=INFO_CAPABILITY_SPEECH;
220 case 18: bc->capability=INFO_CAPABILITY_VIDEO;
222 case 8: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED;
229 case 9: bc->capability=INFO_CAPABILITY_DIGITAL_RESTRICTED;
237 bc->law=INFO_CODEC_ULAW;
240 bc->law=INFO_CODEC_ALAW;
243 bc->law=INFO_CODEC_ALAW;
247 bc->capability=capability;
250 int exclusive, channel;
251 dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)setup, &exclusive, &channel, nt,bc);
253 set_channel(bc,channel);
258 dec_ie_useruser(setup->USER_USER, (Q931_info_t *)setup, &protocol, bc->uu, &bc->uulen, nt,bc);
259 if (bc->uulen) cb_log(1,bc->port,"USERUESRINFO:%s\n",bc->uu);
261 cb_log(1,bc->port,"NO USERUESRINFO\n");
264 dec_ie_progress(setup->PROGRESS, (Q931_info_t *)setup, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
268 #define ANY_CHANNEL 0xff /* IE attribut for 'any channel' */
269 static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
271 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
273 msg_t *msg =(msg_t*)create_l3msg(CC_SETUP | REQUEST, MT_SETUP, bc?bc->l3_id:-1, sizeof(SETUP_t) ,nt);
275 setup=(SETUP_t*)((msg->data+HEADER_LEN));
277 if (bc->channel == 0 || bc->channel == ANY_CHANNEL || bc->channel==-1)
278 enc_ie_channel_id(&setup->CHANNEL_ID, msg, 0, bc->channel, nt,bc);
280 enc_ie_channel_id(&setup->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
284 int type=bc->onumplan,plan=1,present=bc->pres,screen=bc->screen;
285 enc_ie_calling_pn(&setup->CALLING_PN, msg, type, plan, present,
286 screen, bc->oad, nt, bc);
291 enc_ie_called_pn(&setup->CALLED_PN, msg, bc->dnumplan, 1, bc->dad, nt,bc);
296 enc_ie_redir_nr(&setup->REDIR_NR, msg, 1, 1, bc->pres, bc->screen, 0, bc->rad, nt,bc);
301 enc_ie_keypad(&setup->KEYPAD, msg, bc->keypad, nt,bc);
306 enc_ie_display(&setup->DISPLAY, msg, bc->display, nt,bc);
310 int coding=0, capability, mode=0 /* 2 for packet ! */
314 case INFO_CODEC_ULAW: user=2;
316 case INFO_CODEC_ALAW: user=3;
322 switch (bc->capability) {
323 case INFO_CAPABILITY_SPEECH: capability = 0;
325 case INFO_CAPABILITY_DIGITAL_UNRESTRICTED: capability = 8;
330 case INFO_CAPABILITY_DIGITAL_RESTRICTED: capability = 9;
334 capability=bc->capability;
339 enc_ie_bearer(&setup->BEARER, msg, coding, capability, mode, rate, -1, user, nt,bc);
342 if (bc->sending_complete) {
343 enc_ie_complete(&setup->COMPLETE,msg, bc->sending_complete, nt, bc);
348 enc_ie_useruser(&setup->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc);
349 cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu);
353 printf("Building SETUP Msg\n");
358 static void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
360 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
361 CONNECT_t *connect=(CONNECT_t*)((unsigned long)(msg->data+HEADER_LEN));
363 int plan,pres,screen;
365 bc->ces = connect->ces;
366 bc->ces = connect->ces;
368 dec_ie_progress(connect->PROGRESS, (Q931_info_t *)connect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
370 dec_ie_connected_pn(connect->CONNECT_PN,(Q931_info_t *)connect, &bc->cpnnumplan, &plan, &pres, &screen, bc->cad, 31, nt, bc);
373 cb_log(1,bc->port,"CONNETED PN: %s cpn_dialplan:%d\n", connected_pn, type);
377 printf("Parsing CONNECT Msg\n");
381 static msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
383 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
385 msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_t) ,nt);
387 cb_log(6,bc->port,"BUILD_CONNECT: bc:%p bc->l3id:%d, nt:%d\n",bc,bc->l3_id,nt);
389 connect=(CONNECT_t*)((msg->data+HEADER_LEN));
394 enc_ie_date(&connect->DATE, msg, now, nt,bc);
398 int type=bc->cpnnumplan, plan=1, present=2, screen=0;
399 enc_ie_connected_pn(&connect->CONNECT_PN, msg, type,plan, present, screen, bc->cad, nt , bc);
403 printf("Building CONNECT Msg\n");
408 static void parse_setup_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
410 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
411 SETUP_ACKNOWLEDGE_t *setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((unsigned long)(msg->data+HEADER_LEN));
414 int exclusive, channel;
415 dec_ie_channel_id(setup_acknowledge->CHANNEL_ID, (Q931_info_t *)setup_acknowledge, &exclusive, &channel, nt,bc);
418 set_channel(bc, channel);
421 dec_ie_progress(setup_acknowledge->PROGRESS, (Q931_info_t *)setup_acknowledge, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
423 printf("Parsing SETUP_ACKNOWLEDGE Msg\n");
429 static msg_t *build_setup_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
431 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
432 SETUP_ACKNOWLEDGE_t *setup_acknowledge;
433 msg_t *msg =(msg_t*)create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SETUP_ACKNOWLEDGE_t) ,nt);
435 setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
437 enc_ie_channel_id(&setup_acknowledge->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
440 enc_ie_progress(&setup_acknowledge->PROGRESS, msg, 0, nt?1:5, 8, nt,bc);
443 printf("Building SETUP_ACKNOWLEDGE Msg\n");
448 static void parse_connect_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
451 printf("Parsing CONNECT_ACKNOWLEDGE Msg\n");
457 static msg_t *build_connect_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
459 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
460 CONNECT_ACKNOWLEDGE_t *connect_acknowledge;
461 msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_ACKNOWLEDGE_t) ,nt);
463 connect_acknowledge=(CONNECT_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
465 enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
468 printf("Building CONNECT_ACKNOWLEDGE Msg\n");
473 static void parse_user_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
476 printf("Parsing USER_INFORMATION Msg\n");
482 static msg_t *build_user_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
484 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
485 USER_INFORMATION_t *user_information;
486 msg_t *msg =(msg_t*)create_l3msg(CC_USER_INFORMATION | REQUEST, MT_USER_INFORMATION, bc?bc->l3_id:-1, sizeof(USER_INFORMATION_t) ,nt);
488 user_information=(USER_INFORMATION_t*)((msg->data+HEADER_LEN));
491 printf("Building USER_INFORMATION Msg\n");
496 static void parse_suspend_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
499 printf("Parsing SUSPEND_REJECT Msg\n");
505 static msg_t *build_suspend_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
507 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
508 SUSPEND_REJECT_t *suspend_reject;
509 msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, bc?bc->l3_id:-1, sizeof(SUSPEND_REJECT_t) ,nt);
511 suspend_reject=(SUSPEND_REJECT_t*)((msg->data+HEADER_LEN));
514 printf("Building SUSPEND_REJECT Msg\n");
519 static void parse_resume_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
522 printf("Parsing RESUME_REJECT Msg\n");
528 static msg_t *build_resume_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
530 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
531 RESUME_REJECT_t *resume_reject;
532 msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, bc?bc->l3_id:-1, sizeof(RESUME_REJECT_t) ,nt);
534 resume_reject=(RESUME_REJECT_t*)((msg->data+HEADER_LEN));
537 printf("Building RESUME_REJECT Msg\n");
542 static void parse_hold (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
545 printf("Parsing HOLD Msg\n");
551 static msg_t *build_hold (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
553 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
555 msg_t *msg =(msg_t*)create_l3msg(CC_HOLD | REQUEST, MT_HOLD, bc?bc->l3_id:-1, sizeof(HOLD_t) ,nt);
557 hold=(HOLD_t*)((msg->data+HEADER_LEN));
560 printf("Building HOLD Msg\n");
565 static void parse_suspend (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
568 printf("Parsing SUSPEND Msg\n");
574 static msg_t *build_suspend (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
576 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
578 msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND | REQUEST, MT_SUSPEND, bc?bc->l3_id:-1, sizeof(SUSPEND_t) ,nt);
580 suspend=(SUSPEND_t*)((msg->data+HEADER_LEN));
583 printf("Building SUSPEND Msg\n");
588 static void parse_resume (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
591 printf("Parsing RESUME Msg\n");
597 static msg_t *build_resume (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
599 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
601 msg_t *msg =(msg_t*)create_l3msg(CC_RESUME | REQUEST, MT_RESUME, bc?bc->l3_id:-1, sizeof(RESUME_t) ,nt);
603 resume=(RESUME_t*)((msg->data+HEADER_LEN));
606 printf("Building RESUME Msg\n");
611 static void parse_hold_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
614 printf("Parsing HOLD_ACKNOWLEDGE Msg\n");
620 static msg_t *build_hold_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
622 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
623 HOLD_ACKNOWLEDGE_t *hold_acknowledge;
624 msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(HOLD_ACKNOWLEDGE_t) ,nt);
626 hold_acknowledge=(HOLD_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
629 printf("Building HOLD_ACKNOWLEDGE Msg\n");
634 static void parse_suspend_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
637 printf("Parsing SUSPEND_ACKNOWLEDGE Msg\n");
643 static msg_t *build_suspend_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
645 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
646 SUSPEND_ACKNOWLEDGE_t *suspend_acknowledge;
647 msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SUSPEND_ACKNOWLEDGE_t) ,nt);
649 suspend_acknowledge=(SUSPEND_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
652 printf("Building SUSPEND_ACKNOWLEDGE Msg\n");
657 static void parse_resume_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
660 printf("Parsing RESUME_ACKNOWLEDGE Msg\n");
666 static msg_t *build_resume_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
668 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
669 RESUME_ACKNOWLEDGE_t *resume_acknowledge;
670 msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RESUME_ACKNOWLEDGE_t) ,nt);
672 resume_acknowledge=(RESUME_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
675 printf("Building RESUME_ACKNOWLEDGE Msg\n");
680 static void parse_hold_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
683 printf("Parsing HOLD_REJECT Msg\n");
689 static msg_t *build_hold_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
691 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
692 HOLD_REJECT_t *hold_reject;
693 msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, bc?bc->l3_id:-1, sizeof(HOLD_REJECT_t) ,nt);
695 hold_reject=(HOLD_REJECT_t*)((msg->data+HEADER_LEN));
698 printf("Building HOLD_REJECT Msg\n");
703 static void parse_retrieve (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
706 printf("Parsing RETRIEVE Msg\n");
712 static msg_t *build_retrieve (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
714 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
715 RETRIEVE_t *retrieve;
716 msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE | REQUEST, MT_RETRIEVE, bc?bc->l3_id:-1, sizeof(RETRIEVE_t) ,nt);
718 retrieve=(RETRIEVE_t*)((msg->data+HEADER_LEN));
721 printf("Building RETRIEVE Msg\n");
726 static void parse_retrieve_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
729 printf("Parsing RETRIEVE_ACKNOWLEDGE Msg\n");
735 static msg_t *build_retrieve_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
737 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
738 RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge;
739 msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RETRIEVE_ACKNOWLEDGE_t) ,nt);
741 retrieve_acknowledge=(RETRIEVE_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
743 enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
745 printf("Building RETRIEVE_ACKNOWLEDGE Msg\n");
750 static void parse_retrieve_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
753 printf("Parsing RETRIEVE_REJECT Msg\n");
759 static msg_t *build_retrieve_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
761 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
762 RETRIEVE_REJECT_t *retrieve_reject;
763 msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, bc?bc->l3_id:-1, sizeof(RETRIEVE_REJECT_t) ,nt);
765 retrieve_reject=(RETRIEVE_REJECT_t*)((msg->data+HEADER_LEN));
768 printf("Building RETRIEVE_REJECT Msg\n");
773 static void parse_disconnect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
775 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
776 DISCONNECT_t *disconnect=(DISCONNECT_t*)((unsigned long)(msg->data+HEADER_LEN));
779 dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)(disconnect), &location, &cause, nt,bc);
780 if (cause>0) bc->cause=cause;
782 dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)disconnect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
784 printf("Parsing DISCONNECT Msg\n");
790 static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
792 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
793 DISCONNECT_t *disconnect;
794 msg_t *msg =(msg_t*)create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, bc?bc->l3_id:-1, sizeof(DISCONNECT_t) ,nt);
796 disconnect=(DISCONNECT_t*)((msg->data+HEADER_LEN));
798 enc_ie_cause(&disconnect->CAUSE, msg, (nt)?1:0, bc->out_cause,nt,bc);
799 if (nt) enc_ie_progress(&disconnect->PROGRESS, msg, 0, nt?1:5, 8 ,nt,bc);
802 printf("Building DISCONNECT Msg\n");
807 static void parse_restart (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
809 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
810 RESTART_t *restart=(RESTART_t*)((unsigned long)(msg->data+HEADER_LEN));
812 struct misdn_stack *stack=get_stack_by_bc(bc);
815 printf("Parsing RESTART Msg\n");
820 dec_ie_channel_id(restart->CHANNEL_ID, (Q931_info_t *)restart, &exclusive, &bc->restart_channel, nt,bc);
821 cb_log(3, stack->port, "CC_RESTART Request on channel:%d on this port.\n", bc->restart_channel);
826 static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
828 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
830 msg_t *msg =(msg_t*)create_l3msg(CC_RESTART | REQUEST, MT_RESTART, bc?bc->l3_id:-1, sizeof(RESTART_t) ,nt);
832 restart=(RESTART_t*)((msg->data+HEADER_LEN));
835 printf("Building RESTART Msg\n");
837 enc_ie_channel_id(&restart->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
838 enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x80, nt, bc);
840 cb_log(0,bc->port, "Restarting channel %d\n", bc->channel);
844 static void parse_release (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
846 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
847 RELEASE_t *release=(RELEASE_t*)((unsigned long)(msg->data+HEADER_LEN));
851 dec_ie_cause(release->CAUSE, (Q931_info_t *)(release), &location, &cause, nt,bc);
852 if (cause>0) bc->cause=cause;
854 printf("Parsing RELEASE Msg\n");
860 static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
862 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
864 msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, bc?bc->l3_id:-1, sizeof(RELEASE_t) ,nt);
866 release=(RELEASE_t*)((msg->data+HEADER_LEN));
868 if (bc->out_cause>= 0)
869 enc_ie_cause(&release->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc);
872 printf("Building RELEASE Msg\n");
877 static void parse_release_complete (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
879 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
880 RELEASE_COMPLETE_t *release_complete=(RELEASE_COMPLETE_t*)((unsigned long)(msg->data+HEADER_LEN));
883 iframe_t *frm = (iframe_t*) msg->data;
885 struct misdn_stack *stack=get_stack_by_bc(bc);
886 mISDNuser_head_t *hh;
887 hh=(mISDNuser_head_t*)msg->data;
889 /*hh=(mISDN_head_t*)msg->data;
893 if (hh->prim == (CC_RELEASE_COMPLETE|CONFIRM)) {
894 cb_log(0, stack->port, "CC_RELEASE_COMPLETE|CONFIRM [NT] \n");
898 if (frm->prim == (CC_RELEASE_COMPLETE|CONFIRM)) {
899 cb_log(0, stack->port, "CC_RELEASE_COMPLETE|CONFIRM [TE] \n");
903 dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)(release_complete), &location, &cause, nt,bc);
904 if (cause>0) bc->cause=cause;
907 printf("Parsing RELEASE_COMPLETE Msg\n");
911 static msg_t *build_release_complete (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
913 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
914 RELEASE_COMPLETE_t *release_complete;
915 msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, bc?bc->l3_id:-1, sizeof(RELEASE_COMPLETE_t) ,nt);
917 release_complete=(RELEASE_COMPLETE_t*)((msg->data+HEADER_LEN));
919 enc_ie_cause(&release_complete->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc);
922 printf("Building RELEASE_COMPLETE Msg\n");
927 static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
929 int HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN;
930 FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN);
931 Q931_info_t *qi = (Q931_info_t*)(msg->data+HEADER_LEN);
932 unsigned char *p = NULL;
936 printf("Parsing FACILITY Msg\n");
940 if (qi->QI_ELEMENT(facility))
941 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(facility) + 1;
943 p = facility->FACILITY;
948 err = decodeFac(p, &(bc->fac_in));
950 cb_log(1, bc->port, "Decoding FACILITY failed! (%d)\n", err);
954 static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
957 HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN;
958 unsigned char *ie_fac,
960 msg_t *msg =(msg_t*)create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, bc?bc->l3_id:-1, sizeof(FACILITY_t) ,nt);
961 FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN);
965 printf("Building FACILITY Msg\n");
968 len = encodeFac(fac_tmp, &(bc->fac_out));
972 ie_fac = msg_put(msg, len);
974 facility->FACILITY = ie_fac + 1;
976 qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
977 qi->QI_ELEMENT(facility) = ie_fac - (unsigned char *)qi - sizeof(Q931_info_t);
980 memcpy(ie_fac, fac_tmp, len);
983 printf("Sending %s as Display\n", bc->display);
984 enc_ie_display(&facility->DISPLAY, msg, bc->display, nt,bc);
990 static void parse_notify (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
993 printf("Parsing NOTIFY Msg\n");
997 static msg_t *build_notify (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
999 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1001 msg_t *msg =(msg_t*)create_l3msg(CC_NOTIFY | REQUEST, MT_NOTIFY, bc?bc->l3_id:-1, sizeof(NOTIFY_t) ,nt);
1003 notify=(NOTIFY_t*)((msg->data+HEADER_LEN));
1006 printf("Building NOTIFY Msg\n");
1011 static void parse_status_enquiry (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
1014 printf("Parsing STATUS_ENQUIRY Msg\n");
1018 static msg_t *build_status_enquiry (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
1020 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1021 STATUS_ENQUIRY_t *status_enquiry;
1022 msg_t *msg =(msg_t*)create_l3msg(CC_STATUS_ENQUIRY | REQUEST, MT_STATUS_ENQUIRY, bc?bc->l3_id:-1, sizeof(STATUS_ENQUIRY_t) ,nt);
1024 status_enquiry=(STATUS_ENQUIRY_t*)((msg->data+HEADER_LEN));
1027 printf("Building STATUS_ENQUIRY Msg\n");
1032 static void parse_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
1034 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1035 INFORMATION_t *information=(INFORMATION_t*)((unsigned long)(msg->data+HEADER_LEN));
1040 dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)information, &type, &plan, number, sizeof(number)-1, nt, bc);
1041 dec_ie_keypad(information->KEYPAD, (Q931_info_t *)information, keypad, sizeof(keypad)-1, nt, bc);
1042 strcpy(bc->info_dad, number);
1043 strcpy(bc->keypad,keypad);
1046 printf("Parsing INFORMATION Msg\n");
1050 static msg_t *build_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
1052 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1053 INFORMATION_t *information;
1054 msg_t *msg =(msg_t*)create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, bc?bc->l3_id:-1, sizeof(INFORMATION_t) ,nt);
1056 information=(INFORMATION_t*)((msg->data+HEADER_LEN));
1059 enc_ie_called_pn(&information->CALLED_PN, msg, 0, 1, bc->info_dad, nt,bc);
1064 printf("Sending %s as Display\n", bc->display);
1065 enc_ie_display(&information->DISPLAY, msg, bc->display, nt,bc);
1070 printf("Building INFORMATION Msg\n");
1075 static void parse_status (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
1077 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1078 STATUS_t *status=(STATUS_t*)((unsigned long)(msg->data+HEADER_LEN));
1082 dec_ie_cause(status->CAUSE, (Q931_info_t *)(status), &location, &cause, nt,bc);
1083 if (cause>0) bc->cause=cause;
1087 printf("Parsing STATUS Msg\n");
1091 static msg_t *build_status (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
1093 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1095 msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS, bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt);
1097 status=(STATUS_t*)((msg->data+HEADER_LEN));
1100 printf("Building STATUS Msg\n");
1105 static void parse_timeout (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
1108 printf("Parsing STATUS Msg\n");
1112 static msg_t *build_timeout (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
1114 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
1116 msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS, bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt);
1118 status=(STATUS_t*)((msg->data+HEADER_LEN));
1121 printf("Building STATUS Msg\n");
1127 /************************************/
1134 struct isdn_msg msgs_g[] = {
1135 {CC_PROCEEDING,L3,EVENT_PROCEEDING,
1136 parse_proceeding,build_proceeding,
1138 {CC_ALERTING,L3,EVENT_ALERTING,
1139 parse_alerting,build_alerting,
1141 {CC_PROGRESS,L3,EVENT_PROGRESS,
1142 parse_progress,build_progress,
1144 {CC_SETUP,L3,EVENT_SETUP,
1145 parse_setup,build_setup,
1147 {CC_CONNECT,L3,EVENT_CONNECT,
1148 parse_connect,build_connect,
1150 {CC_SETUP_ACKNOWLEDGE,L3,EVENT_SETUP_ACKNOWLEDGE,
1151 parse_setup_acknowledge,build_setup_acknowledge,
1152 "SETUP_ACKNOWLEDGE"},
1153 {CC_CONNECT_ACKNOWLEDGE ,L3,EVENT_CONNECT_ACKNOWLEDGE ,
1154 parse_connect_acknowledge ,build_connect_acknowledge,
1155 "CONNECT_ACKNOWLEDGE "},
1156 {CC_USER_INFORMATION,L3,EVENT_USER_INFORMATION,
1157 parse_user_information,build_user_information,
1158 "USER_INFORMATION"},
1159 {CC_SUSPEND_REJECT,L3,EVENT_SUSPEND_REJECT,
1160 parse_suspend_reject,build_suspend_reject,
1162 {CC_RESUME_REJECT,L3,EVENT_RESUME_REJECT,
1163 parse_resume_reject,build_resume_reject,
1165 {CC_HOLD,L3,EVENT_HOLD,
1166 parse_hold,build_hold,
1168 {CC_SUSPEND,L3,EVENT_SUSPEND,
1169 parse_suspend,build_suspend,
1171 {CC_RESUME,L3,EVENT_RESUME,
1172 parse_resume,build_resume,
1174 {CC_HOLD_ACKNOWLEDGE,L3,EVENT_HOLD_ACKNOWLEDGE,
1175 parse_hold_acknowledge,build_hold_acknowledge,
1176 "HOLD_ACKNOWLEDGE"},
1177 {CC_SUSPEND_ACKNOWLEDGE,L3,EVENT_SUSPEND_ACKNOWLEDGE,
1178 parse_suspend_acknowledge,build_suspend_acknowledge,
1179 "SUSPEND_ACKNOWLEDGE"},
1180 {CC_RESUME_ACKNOWLEDGE,L3,EVENT_RESUME_ACKNOWLEDGE,
1181 parse_resume_acknowledge,build_resume_acknowledge,
1182 "RESUME_ACKNOWLEDGE"},
1183 {CC_HOLD_REJECT,L3,EVENT_HOLD_REJECT,
1184 parse_hold_reject,build_hold_reject,
1186 {CC_RETRIEVE,L3,EVENT_RETRIEVE,
1187 parse_retrieve,build_retrieve,
1189 {CC_RETRIEVE_ACKNOWLEDGE,L3,EVENT_RETRIEVE_ACKNOWLEDGE,
1190 parse_retrieve_acknowledge,build_retrieve_acknowledge,
1191 "RETRIEVE_ACKNOWLEDGE"},
1192 {CC_RETRIEVE_REJECT,L3,EVENT_RETRIEVE_REJECT,
1193 parse_retrieve_reject,build_retrieve_reject,
1195 {CC_DISCONNECT,L3,EVENT_DISCONNECT,
1196 parse_disconnect,build_disconnect,
1198 {CC_RESTART,L3,EVENT_RESTART,
1199 parse_restart,build_restart,
1201 {CC_RELEASE,L3,EVENT_RELEASE,
1202 parse_release,build_release,
1204 {CC_RELEASE_COMPLETE,L3,EVENT_RELEASE_COMPLETE,
1205 parse_release_complete,build_release_complete,
1206 "RELEASE_COMPLETE"},
1207 {CC_FACILITY,L3,EVENT_FACILITY,
1208 parse_facility,build_facility,
1210 {CC_NOTIFY,L3,EVENT_NOTIFY,
1211 parse_notify,build_notify,
1213 {CC_STATUS_ENQUIRY,L3,EVENT_STATUS_ENQUIRY,
1214 parse_status_enquiry,build_status_enquiry,
1216 {CC_INFORMATION,L3,EVENT_INFORMATION,
1217 parse_information,build_information,
1219 {CC_STATUS,L3,EVENT_STATUS,
1220 parse_status,build_status,
1222 {CC_TIMEOUT,L3,EVENT_TIMEOUT,
1223 parse_timeout,build_timeout,
1225 {0,0,0,NULL,NULL,NULL}
1228 #define msgs_max (sizeof(msgs_g)/sizeof(struct isdn_msg))
1230 /** INTERFACE FCTS ***/
1231 int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt)
1236 mISDNuser_head_t *hh = (mISDNuser_head_t*)msg->data;
1238 for (i=0; i< msgs_max -1; i++) {
1239 if ( (hh->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i;
1243 iframe_t *frm = (iframe_t*)msg->data;
1245 for (i=0; i< msgs_max -1; i++)
1246 if ( (frm->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i;
1252 int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt)
1255 for (i=0; i< msgs_max; i++)
1256 if ( event == msgs[i].event) return i;
1258 cb_log(10,0, "get_index: event not found!\n");
1263 enum event_e isdn_msg_get_event(struct isdn_msg msgs[], msg_t *msg, int nt)
1265 int i=isdn_msg_get_index(msgs, msg, nt);
1266 if(i>=0) return msgs[i].event;
1267 return EVENT_UNKNOWN;
1270 char * isdn_msg_get_info(struct isdn_msg msgs[], msg_t *msg, int nt)
1272 int i=isdn_msg_get_index(msgs, msg, nt);
1273 if(i>=0) return msgs[i].info;
1278 char EVENT_CLEAN_INFO[] = "CLEAN_UP";
1279 char EVENT_DTMF_TONE_INFO[] = "DTMF_TONE";
1280 char EVENT_NEW_L3ID_INFO[] = "NEW_L3ID";
1281 char EVENT_NEW_BC_INFO[] = "NEW_BC";
1282 char EVENT_PORT_ALARM_INFO[] = "ALARM";
1283 char EVENT_NEW_CHANNEL_INFO[] = "NEW_CHANNEL";
1284 char EVENT_BCHAN_DATA_INFO[] = "BCHAN_DATA";
1285 char EVENT_BCHAN_ACTIVATED_INFO[] = "BCHAN_ACTIVATED";
1286 char EVENT_TONE_GENERATE_INFO[] = "TONE_GENERATE";
1287 char EVENT_BCHAN_ERROR_INFO[] = "BCHAN_ERROR";
1289 char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
1291 int i=isdn_msg_get_index_by_event(msgs, event, nt);
1293 if(i>=0) return msgs[i].info;
1295 if (event == EVENT_CLEANUP) return EVENT_CLEAN_INFO;
1296 if (event == EVENT_DTMF_TONE) return EVENT_DTMF_TONE_INFO;
1297 if (event == EVENT_NEW_L3ID) return EVENT_NEW_L3ID_INFO;
1298 if (event == EVENT_NEW_BC) return EVENT_NEW_BC_INFO;
1299 if (event == EVENT_NEW_CHANNEL) return EVENT_NEW_CHANNEL_INFO;
1300 if (event == EVENT_BCHAN_DATA) return EVENT_BCHAN_DATA_INFO;
1301 if (event == EVENT_BCHAN_ACTIVATED) return EVENT_BCHAN_ACTIVATED_INFO;
1302 if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO;
1303 if (event == EVENT_PORT_ALARM) return EVENT_PORT_ALARM_INFO;
1304 if (event == EVENT_BCHAN_ERROR) return EVENT_BCHAN_ERROR_INFO;
1309 int isdn_msg_parse_event(struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
1311 int i=isdn_msg_get_index(msgs, msg, nt);
1314 msgs[i].msg_parser(msgs, msg, bc, nt);
1318 msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt)
1320 int i=isdn_msg_get_index_by_event(msgs, event, nt);
1321 if(i<0) return NULL;
1323 return msgs[i].msg_builder(msgs, bc, nt);