00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "isdn_lib_intern.h"
00016
00017
00018 #include "isdn_lib.h"
00019
00020 #include "ie.c"
00021
00022
00023 static void set_channel(struct misdn_bchannel *bc, int channel)
00024 {
00025
00026 cb_log(3,bc->port,"set_channel: bc->channel:%d channel:%d\n", bc->channel, channel);
00027
00028
00029 if (channel==0xff) {
00030
00031 channel=-1;
00032 }
00033
00034
00035 if (channel > 0 && bc->nt ) {
00036
00037 if (bc->channel && ( bc->channel != 0xff) ) {
00038 cb_log(0,bc->port,"We already have a channel (%d)\n", bc->channel);
00039 } else {
00040 bc->channel = channel;
00041 cb_event(EVENT_NEW_CHANNEL,bc,NULL);
00042 }
00043 }
00044
00045 if (channel > 0 && !bc->nt ) {
00046 bc->channel = channel;
00047 cb_event(EVENT_NEW_CHANNEL,bc,NULL);
00048 }
00049 }
00050
00051 static void parse_proceeding (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00052 {
00053 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00054 CALL_PROCEEDING_t *proceeding=(CALL_PROCEEDING_t*)((unsigned long)msg->data+ HEADER_LEN);
00055
00056
00057 {
00058 int exclusive, channel;
00059 dec_ie_channel_id(proceeding->CHANNEL_ID, (Q931_info_t *)proceeding, &exclusive, &channel, nt,bc);
00060
00061 set_channel(bc,channel);
00062
00063 }
00064
00065 dec_ie_progress(proceeding->PROGRESS, (Q931_info_t *)proceeding, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00066
00067
00068 #if DEBUG
00069 printf("Parsing PROCEEDING Msg\n");
00070 #endif
00071 }
00072 static msg_t *build_proceeding (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00073 {
00074 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00075 CALL_PROCEEDING_t *proceeding;
00076 msg_t *msg =(msg_t*)create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, bc?bc->l3_id:-1, sizeof(CALL_PROCEEDING_t) ,nt);
00077
00078 proceeding=(CALL_PROCEEDING_t*)((msg->data+HEADER_LEN));
00079
00080 enc_ie_channel_id(&proceeding->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
00081
00082 if (nt)
00083 enc_ie_progress(&proceeding->PROGRESS, msg, 0, nt?1:5, 8, nt,bc);
00084
00085
00086 #if DEBUG
00087 printf("Building PROCEEDING Msg\n");
00088 #endif
00089 return msg;
00090 }
00091
00092 static void parse_alerting (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00093 {
00094 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00095 ALERTING_t *alerting=(ALERTING_t*)((unsigned long)(msg->data+HEADER_LEN));
00096
00097
00098 dec_ie_progress(alerting->PROGRESS, (Q931_info_t *)alerting, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00099
00100 #if DEBUG
00101 printf("Parsing ALERTING Msg\n");
00102 #endif
00103
00104
00105 }
00106
00107 static msg_t *build_alerting (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00108 {
00109 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00110 ALERTING_t *alerting;
00111 msg_t *msg =(msg_t*)create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING, bc?bc->l3_id:-1, sizeof(ALERTING_t) ,nt);
00112
00113 alerting=(ALERTING_t*)((msg->data+HEADER_LEN));
00114
00115 enc_ie_channel_id(&alerting->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
00116
00117 if (nt)
00118 enc_ie_progress(&alerting->PROGRESS, msg, 0, nt?1:5, 8, nt,bc);
00119 #if DEBUG
00120 printf("Building ALERTING Msg\n");
00121 #endif
00122 return msg;
00123 }
00124
00125
00126 static void parse_progress (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00127 {
00128 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00129 PROGRESS_t *progress=(PROGRESS_t*)((unsigned long)(msg->data+HEADER_LEN));
00130
00131
00132 dec_ie_progress(progress->PROGRESS, (Q931_info_t *)progress, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00133
00134 #if DEBUG
00135 printf("Parsing PROGRESS Msg\n");
00136 #endif
00137 }
00138
00139 static msg_t *build_progress (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00140 {
00141 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00142 PROGRESS_t *progress;
00143 msg_t *msg =(msg_t*)create_l3msg(CC_PROGRESS | REQUEST, MT_PROGRESS, bc?bc->l3_id:-1, sizeof(PROGRESS_t) ,nt);
00144
00145 progress=(PROGRESS_t*)((msg->data+HEADER_LEN));
00146
00147 #if DEBUG
00148 printf("Building PROGRESS Msg\n");
00149 #endif
00150 return msg;
00151 }
00152
00153 static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00154 {
00155 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00156 SETUP_t *setup= (SETUP_t*)((unsigned long)msg->data+HEADER_LEN);
00157 Q931_info_t *qi=(Q931_info_t*)((unsigned long)msg->data+HEADER_LEN);
00158
00159 #if DEBUG
00160 printf("Parsing SETUP Msg\n");
00161 #endif
00162 {
00163 int type,plan,present, screen;
00164 char id[32];
00165 dec_ie_calling_pn(setup->CALLING_PN, qi, &type, &plan, &present, &screen, id, sizeof(id)-1, nt,bc);
00166
00167 bc->onumplan=type;
00168 strcpy(bc->oad, id);
00169 switch (present) {
00170 case 0:
00171 bc->pres=0;
00172 break;
00173 case 1:
00174 bc->pres=1;
00175 break;
00176 default:
00177 bc->pres=0;
00178 }
00179 switch (screen) {
00180 case 0:
00181 break;
00182 default:
00183 ;
00184 }
00185 }
00186 {
00187 int type, plan;
00188 char number[32];
00189 dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)setup, &type, &plan, number, sizeof(number)-1, nt,bc);
00190 strcpy(bc->dad, number);
00191 bc->dnumplan=type;
00192 }
00193 {
00194 char keypad[32];
00195 dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)setup, keypad, sizeof(keypad)-1, nt,bc);
00196 strcpy(bc->keypad, keypad);
00197 }
00198
00199 {
00200 dec_ie_complete(setup->COMPLETE, (Q931_info_t *)setup, &bc->sending_complete, nt,bc);
00201
00202 }
00203
00204 {
00205 int type, plan, present, screen, reason;
00206 char id[32];
00207 dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)setup, &type, &plan, &present, &screen, &reason, id, sizeof(id)-1, nt,bc);
00208
00209 strcpy(bc->rad, id);
00210 bc->rnumplan=type;
00211 }
00212 {
00213 int coding, capability, mode, rate, multi, user, async, urate, stopbits, dbits, parity;
00214 dec_ie_bearer(setup->BEARER, (Q931_info_t *)setup, &coding, &capability, &mode, &rate, &multi, &user, &async, &urate, &stopbits, &dbits, &parity, nt,bc);
00215 switch (capability) {
00216 case -1: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED;
00217 break;
00218 case 0: bc->capability=INFO_CAPABILITY_SPEECH;
00219 break;
00220 case 18: bc->capability=INFO_CAPABILITY_VIDEO;
00221 break;
00222 case 8: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED;
00223 bc->user1 = user;
00224 bc->urate = urate;
00225
00226 bc->rate = rate;
00227 bc->mode = mode;
00228 break;
00229 case 9: bc->capability=INFO_CAPABILITY_DIGITAL_RESTRICTED;
00230 break;
00231 default:
00232 break;
00233 }
00234
00235 switch(user) {
00236 case 2:
00237 bc->law=INFO_CODEC_ULAW;
00238 break;
00239 case 3:
00240 bc->law=INFO_CODEC_ALAW;
00241 break;
00242 default:
00243 bc->law=INFO_CODEC_ALAW;
00244
00245 }
00246
00247 bc->capability=capability;
00248 }
00249 {
00250 int exclusive, channel;
00251 dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)setup, &exclusive, &channel, nt,bc);
00252
00253 set_channel(bc,channel);
00254 }
00255
00256 {
00257 int protocol ;
00258 dec_ie_useruser(setup->USER_USER, (Q931_info_t *)setup, &protocol, bc->uu, &bc->uulen, nt,bc);
00259 if (bc->uulen) cb_log(1,bc->port,"USERUESRINFO:%s\n",bc->uu);
00260 else
00261 cb_log(1,bc->port,"NO USERUESRINFO\n");
00262 }
00263
00264 dec_ie_progress(setup->PROGRESS, (Q931_info_t *)setup, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00265
00266 }
00267
00268 #define ANY_CHANNEL 0xff
00269 static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00270 {
00271 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00272 SETUP_t *setup;
00273 msg_t *msg =(msg_t*)create_l3msg(CC_SETUP | REQUEST, MT_SETUP, bc?bc->l3_id:-1, sizeof(SETUP_t) ,nt);
00274
00275 setup=(SETUP_t*)((msg->data+HEADER_LEN));
00276
00277 if (bc->channel == 0 || bc->channel == ANY_CHANNEL || bc->channel==-1)
00278 enc_ie_channel_id(&setup->CHANNEL_ID, msg, 0, bc->channel, nt,bc);
00279 else
00280 enc_ie_channel_id(&setup->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
00281
00282
00283 {
00284 int type=bc->onumplan,plan=1,present=bc->pres,screen=bc->screen;
00285 enc_ie_calling_pn(&setup->CALLING_PN, msg, type, plan, present,
00286 screen, bc->oad, nt, bc);
00287 }
00288
00289 {
00290 if (bc->dad[0])
00291 enc_ie_called_pn(&setup->CALLED_PN, msg, bc->dnumplan, 1, bc->dad, nt,bc);
00292 }
00293
00294 {
00295 if (bc->rad[0])
00296 enc_ie_redir_nr(&setup->REDIR_NR, msg, 1, 1, bc->pres, bc->screen, 0, bc->rad, nt,bc);
00297 }
00298
00299 {
00300 if (bc->keypad[0])
00301 enc_ie_keypad(&setup->KEYPAD, msg, bc->keypad, nt,bc);
00302 }
00303
00304
00305 if (*bc->display) {
00306 enc_ie_display(&setup->DISPLAY, msg, bc->display, nt,bc);
00307 }
00308
00309 {
00310 int coding=0, capability, mode=0
00311 ,user, rate=0x10;
00312
00313 switch (bc->law) {
00314 case INFO_CODEC_ULAW: user=2;
00315 break;
00316 case INFO_CODEC_ALAW: user=3;
00317 break;
00318 default:
00319 user=3;
00320 }
00321
00322 switch (bc->capability) {
00323 case INFO_CAPABILITY_SPEECH: capability = 0;
00324 break;
00325 case INFO_CAPABILITY_DIGITAL_UNRESTRICTED: capability = 8;
00326 user=-1;
00327 mode=bc->mode;
00328 rate=bc->rate;
00329 break;
00330 case INFO_CAPABILITY_DIGITAL_RESTRICTED: capability = 9;
00331 user=-1;
00332 break;
00333 default:
00334 capability=bc->capability;
00335 }
00336
00337
00338
00339 enc_ie_bearer(&setup->BEARER, msg, coding, capability, mode, rate, -1, user, nt,bc);
00340 }
00341
00342 if (bc->sending_complete) {
00343 enc_ie_complete(&setup->COMPLETE,msg, bc->sending_complete, nt, bc);
00344 }
00345
00346 if (bc->uulen) {
00347 int protocol=4;
00348 enc_ie_useruser(&setup->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc);
00349 cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu);
00350 }
00351
00352 #if DEBUG
00353 printf("Building SETUP Msg\n");
00354 #endif
00355 return msg;
00356 }
00357
00358 static void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00359 {
00360 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00361 CONNECT_t *connect=(CONNECT_t*)((unsigned long)(msg->data+HEADER_LEN));
00362
00363 int plan,pres,screen;
00364
00365 bc->ces = connect->ces;
00366 bc->ces = connect->ces;
00367
00368 dec_ie_progress(connect->PROGRESS, (Q931_info_t *)connect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00369
00370 dec_ie_connected_pn(connect->CONNECT_PN,(Q931_info_t *)connect, &bc->cpnnumplan, &plan, &pres, &screen, bc->cad, 31, nt, bc);
00371
00372
00373
00374
00375
00376 #if DEBUG
00377 printf("Parsing CONNECT Msg\n");
00378 #endif
00379 }
00380
00381 static msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00382 {
00383 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00384 CONNECT_t *connect;
00385 msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_t) ,nt);
00386
00387 cb_log(6,bc->port,"BUILD_CONNECT: bc:%p bc->l3id:%d, nt:%d\n",bc,bc->l3_id,nt);
00388
00389 connect=(CONNECT_t*)((msg->data+HEADER_LEN));
00390
00391 if (nt) {
00392 time_t now;
00393 time(&now);
00394 enc_ie_date(&connect->DATE, msg, now, nt,bc);
00395 }
00396
00397 {
00398 int type=bc->cpnnumplan, plan=1, present=2, screen=0;
00399 enc_ie_connected_pn(&connect->CONNECT_PN, msg, type,plan, present, screen, bc->cad, nt , bc);
00400 }
00401
00402 #if DEBUG
00403 printf("Building CONNECT Msg\n");
00404 #endif
00405 return msg;
00406 }
00407
00408 static void parse_setup_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00409 {
00410 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00411 SETUP_ACKNOWLEDGE_t *setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((unsigned long)(msg->data+HEADER_LEN));
00412
00413 {
00414 int exclusive, channel;
00415 dec_ie_channel_id(setup_acknowledge->CHANNEL_ID, (Q931_info_t *)setup_acknowledge, &exclusive, &channel, nt,bc);
00416
00417
00418 set_channel(bc, channel);
00419 }
00420
00421 dec_ie_progress(setup_acknowledge->PROGRESS, (Q931_info_t *)setup_acknowledge, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00422 #if DEBUG
00423 printf("Parsing SETUP_ACKNOWLEDGE Msg\n");
00424 #endif
00425
00426
00427 }
00428
00429 static msg_t *build_setup_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00430 {
00431 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00432 SETUP_ACKNOWLEDGE_t *setup_acknowledge;
00433 msg_t *msg =(msg_t*)create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SETUP_ACKNOWLEDGE_t) ,nt);
00434
00435 setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
00436
00437 enc_ie_channel_id(&setup_acknowledge->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
00438
00439 if (nt)
00440 enc_ie_progress(&setup_acknowledge->PROGRESS, msg, 0, nt?1:5, 8, nt,bc);
00441
00442 #if DEBUG
00443 printf("Building SETUP_ACKNOWLEDGE Msg\n");
00444 #endif
00445 return msg;
00446 }
00447
00448 static void parse_connect_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00449 {
00450 #if DEBUG
00451 printf("Parsing CONNECT_ACKNOWLEDGE Msg\n");
00452 #endif
00453
00454
00455 }
00456
00457 static msg_t *build_connect_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00458 {
00459 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00460 CONNECT_ACKNOWLEDGE_t *connect_acknowledge;
00461 msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, bc?bc->l3_id:-1, sizeof(CONNECT_ACKNOWLEDGE_t) ,nt);
00462
00463 connect_acknowledge=(CONNECT_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
00464
00465 enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
00466
00467 #if DEBUG
00468 printf("Building CONNECT_ACKNOWLEDGE Msg\n");
00469 #endif
00470 return msg;
00471 }
00472
00473 static void parse_user_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00474 {
00475 #if DEBUG
00476 printf("Parsing USER_INFORMATION Msg\n");
00477 #endif
00478
00479
00480 }
00481
00482 static msg_t *build_user_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00483 {
00484 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00485 USER_INFORMATION_t *user_information;
00486 msg_t *msg =(msg_t*)create_l3msg(CC_USER_INFORMATION | REQUEST, MT_USER_INFORMATION, bc?bc->l3_id:-1, sizeof(USER_INFORMATION_t) ,nt);
00487
00488 user_information=(USER_INFORMATION_t*)((msg->data+HEADER_LEN));
00489
00490 #if DEBUG
00491 printf("Building USER_INFORMATION Msg\n");
00492 #endif
00493 return msg;
00494 }
00495
00496 static void parse_suspend_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00497 {
00498 #if DEBUG
00499 printf("Parsing SUSPEND_REJECT Msg\n");
00500 #endif
00501
00502
00503 }
00504
00505 static msg_t *build_suspend_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00506 {
00507 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00508 SUSPEND_REJECT_t *suspend_reject;
00509 msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, bc?bc->l3_id:-1, sizeof(SUSPEND_REJECT_t) ,nt);
00510
00511 suspend_reject=(SUSPEND_REJECT_t*)((msg->data+HEADER_LEN));
00512
00513 #if DEBUG
00514 printf("Building SUSPEND_REJECT Msg\n");
00515 #endif
00516 return msg;
00517 }
00518
00519 static void parse_resume_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00520 {
00521 #if DEBUG
00522 printf("Parsing RESUME_REJECT Msg\n");
00523 #endif
00524
00525
00526 }
00527
00528 static msg_t *build_resume_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00529 {
00530 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00531 RESUME_REJECT_t *resume_reject;
00532 msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, bc?bc->l3_id:-1, sizeof(RESUME_REJECT_t) ,nt);
00533
00534 resume_reject=(RESUME_REJECT_t*)((msg->data+HEADER_LEN));
00535
00536 #if DEBUG
00537 printf("Building RESUME_REJECT Msg\n");
00538 #endif
00539 return msg;
00540 }
00541
00542 static void parse_hold (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00543 {
00544 #if DEBUG
00545 printf("Parsing HOLD Msg\n");
00546 #endif
00547
00548
00549 }
00550
00551 static msg_t *build_hold (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00552 {
00553 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00554 HOLD_t *hold;
00555 msg_t *msg =(msg_t*)create_l3msg(CC_HOLD | REQUEST, MT_HOLD, bc?bc->l3_id:-1, sizeof(HOLD_t) ,nt);
00556
00557 hold=(HOLD_t*)((msg->data+HEADER_LEN));
00558
00559 #if DEBUG
00560 printf("Building HOLD Msg\n");
00561 #endif
00562 return msg;
00563 }
00564
00565 static void parse_suspend (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00566 {
00567 #if DEBUG
00568 printf("Parsing SUSPEND Msg\n");
00569 #endif
00570
00571
00572 }
00573
00574 static msg_t *build_suspend (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00575 {
00576 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00577 SUSPEND_t *suspend;
00578 msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND | REQUEST, MT_SUSPEND, bc?bc->l3_id:-1, sizeof(SUSPEND_t) ,nt);
00579
00580 suspend=(SUSPEND_t*)((msg->data+HEADER_LEN));
00581
00582 #if DEBUG
00583 printf("Building SUSPEND Msg\n");
00584 #endif
00585 return msg;
00586 }
00587
00588 static void parse_resume (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00589 {
00590 #if DEBUG
00591 printf("Parsing RESUME Msg\n");
00592 #endif
00593
00594
00595 }
00596
00597 static msg_t *build_resume (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00598 {
00599 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00600 RESUME_t *resume;
00601 msg_t *msg =(msg_t*)create_l3msg(CC_RESUME | REQUEST, MT_RESUME, bc?bc->l3_id:-1, sizeof(RESUME_t) ,nt);
00602
00603 resume=(RESUME_t*)((msg->data+HEADER_LEN));
00604
00605 #if DEBUG
00606 printf("Building RESUME Msg\n");
00607 #endif
00608 return msg;
00609 }
00610
00611 static void parse_hold_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00612 {
00613 #if DEBUG
00614 printf("Parsing HOLD_ACKNOWLEDGE Msg\n");
00615 #endif
00616
00617
00618 }
00619
00620 static msg_t *build_hold_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00621 {
00622 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00623 HOLD_ACKNOWLEDGE_t *hold_acknowledge;
00624 msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(HOLD_ACKNOWLEDGE_t) ,nt);
00625
00626 hold_acknowledge=(HOLD_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
00627
00628 #if DEBUG
00629 printf("Building HOLD_ACKNOWLEDGE Msg\n");
00630 #endif
00631 return msg;
00632 }
00633
00634 static void parse_suspend_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00635 {
00636 #if DEBUG
00637 printf("Parsing SUSPEND_ACKNOWLEDGE Msg\n");
00638 #endif
00639
00640
00641 }
00642
00643 static msg_t *build_suspend_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00644 {
00645 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00646 SUSPEND_ACKNOWLEDGE_t *suspend_acknowledge;
00647 msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(SUSPEND_ACKNOWLEDGE_t) ,nt);
00648
00649 suspend_acknowledge=(SUSPEND_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
00650
00651 #if DEBUG
00652 printf("Building SUSPEND_ACKNOWLEDGE Msg\n");
00653 #endif
00654 return msg;
00655 }
00656
00657 static void parse_resume_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00658 {
00659 #if DEBUG
00660 printf("Parsing RESUME_ACKNOWLEDGE Msg\n");
00661 #endif
00662
00663
00664 }
00665
00666 static msg_t *build_resume_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00667 {
00668 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00669 RESUME_ACKNOWLEDGE_t *resume_acknowledge;
00670 msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RESUME_ACKNOWLEDGE_t) ,nt);
00671
00672 resume_acknowledge=(RESUME_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
00673
00674 #if DEBUG
00675 printf("Building RESUME_ACKNOWLEDGE Msg\n");
00676 #endif
00677 return msg;
00678 }
00679
00680 static void parse_hold_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00681 {
00682 #if DEBUG
00683 printf("Parsing HOLD_REJECT Msg\n");
00684 #endif
00685
00686
00687 }
00688
00689 static msg_t *build_hold_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00690 {
00691 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00692 HOLD_REJECT_t *hold_reject;
00693 msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, bc?bc->l3_id:-1, sizeof(HOLD_REJECT_t) ,nt);
00694
00695 hold_reject=(HOLD_REJECT_t*)((msg->data+HEADER_LEN));
00696
00697 #if DEBUG
00698 printf("Building HOLD_REJECT Msg\n");
00699 #endif
00700 return msg;
00701 }
00702
00703 static void parse_retrieve (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00704 {
00705 #if DEBUG
00706 printf("Parsing RETRIEVE Msg\n");
00707 #endif
00708
00709
00710 }
00711
00712 static msg_t *build_retrieve (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00713 {
00714 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00715 RETRIEVE_t *retrieve;
00716 msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE | REQUEST, MT_RETRIEVE, bc?bc->l3_id:-1, sizeof(RETRIEVE_t) ,nt);
00717
00718 retrieve=(RETRIEVE_t*)((msg->data+HEADER_LEN));
00719
00720 #if DEBUG
00721 printf("Building RETRIEVE Msg\n");
00722 #endif
00723 return msg;
00724 }
00725
00726 static void parse_retrieve_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00727 {
00728 #if DEBUG
00729 printf("Parsing RETRIEVE_ACKNOWLEDGE Msg\n");
00730 #endif
00731
00732
00733 }
00734
00735 static msg_t *build_retrieve_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00736 {
00737 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00738 RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge;
00739 msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, bc?bc->l3_id:-1, sizeof(RETRIEVE_ACKNOWLEDGE_t) ,nt);
00740
00741 retrieve_acknowledge=(RETRIEVE_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN));
00742
00743 enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc);
00744 #if DEBUG
00745 printf("Building RETRIEVE_ACKNOWLEDGE Msg\n");
00746 #endif
00747 return msg;
00748 }
00749
00750 static void parse_retrieve_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00751 {
00752 #if DEBUG
00753 printf("Parsing RETRIEVE_REJECT Msg\n");
00754 #endif
00755
00756
00757 }
00758
00759 static msg_t *build_retrieve_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00760 {
00761 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00762 RETRIEVE_REJECT_t *retrieve_reject;
00763 msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, bc?bc->l3_id:-1, sizeof(RETRIEVE_REJECT_t) ,nt);
00764
00765 retrieve_reject=(RETRIEVE_REJECT_t*)((msg->data+HEADER_LEN));
00766
00767 #if DEBUG
00768 printf("Building RETRIEVE_REJECT Msg\n");
00769 #endif
00770 return msg;
00771 }
00772
00773 static void parse_disconnect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00774 {
00775 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00776 DISCONNECT_t *disconnect=(DISCONNECT_t*)((unsigned long)(msg->data+HEADER_LEN));
00777 int location;
00778 int cause;
00779 dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)(disconnect), &location, &cause, nt,bc);
00780 if (cause>0) bc->cause=cause;
00781
00782 dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)disconnect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
00783 #if DEBUG
00784 printf("Parsing DISCONNECT Msg\n");
00785 #endif
00786
00787
00788 }
00789
00790 static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
00791 {
00792 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00793 DISCONNECT_t *disconnect;
00794 msg_t *msg =(msg_t*)create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, bc?bc->l3_id:-1, sizeof(DISCONNECT_t) ,nt);
00795
00796 disconnect=(DISCONNECT_t*)((msg->data+HEADER_LEN));
00797
00798 enc_ie_cause(&disconnect->CAUSE, msg, (nt)?1:0, bc->out_cause,nt,bc);
00799 if (nt) enc_ie_progress(&disconnect->PROGRESS, msg, 0, nt?1:5, 8 ,nt,bc);
00800
00801 if (bc->uulen) {
00802 int protocol=4;
00803 enc_ie_useruser(&disconnect->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc);
00804 cb_log(1,bc->port,"ENCODING USERUESRINFO:%s\n",bc->uu);
00805 }
00806
00807 #if DEBUG
00808 printf("Building DISCONNECT Msg\n");
00809 #endif
00810 return msg;
00811 }
00812
00813 static void parse_restart (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
00814 {
00815 int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
00816 RESTART_t *restart=(RESTART_t*)((unsigned long)(msg->data+HEADER_LEN));
00817
00818 struct misdn_stack *stack=get_stack_by_bc(bc);
00819
00820 #if DEBUG
00821 printf("Parsing RESTART Msg\n");
00822 #endif
00823
00824 {