00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <string.h>
00029
00030 #include <mISDNuser/mISDNlib.h>
00031 #include <mISDNuser/isdn_net.h>
00032 #include <mISDNuser/l3dss1.h>
00033 #include <mISDNuser/net_l3.h>
00034 #include "asterisk/localtime.h"
00035
00036
00037
00038 #define MISDN_IE_DEBG 0
00039
00040
00041 static void strnncpy(char *dest, const char *src, size_t len, size_t dst_len)
00042 {
00043 if (len > dst_len-1)
00044 len = dst_len-1;
00045 strncpy(dest, src, len);
00046 dest[len] = '\0';
00047 }
00048
00049
00050
00051 static void enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete, int nt, struct misdn_bchannel *bc)
00052 {
00053 unsigned char *p;
00054 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00055
00056 if (complete<0 || complete>1)
00057 {
00058 printf("%s: ERROR: complete(%d) is out of range.\n", __FUNCTION__, complete);
00059 return;
00060 }
00061
00062 if (complete)
00063 if (MISDN_IE_DEBG) printf(" complete=%d\n", complete);
00064
00065 if (complete)
00066 {
00067 p = msg_put(msg, 1);
00068 if (nt)
00069 {
00070 *ntmode = p;
00071 } else
00072 qi->QI_ELEMENT(sending_complete) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00073
00074 p[0] = IE_COMPLETE;
00075 }
00076 }
00077
00078 static void dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete, int nt, struct misdn_bchannel *bc)
00079 {
00080 *complete = 0;
00081 if (!nt)
00082 {
00083 if (qi->QI_ELEMENT(sending_complete))
00084 *complete = 1;
00085 } else
00086 if (p)
00087 *complete = 1;
00088
00089 if (*complete)
00090 if (MISDN_IE_DEBG) printf(" complete=%d\n", *complete);
00091 }
00092
00093
00094
00095 static void enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int capability, int mode, int rate, int multi, int user, int nt, struct misdn_bchannel *bc)
00096 {
00097 unsigned char *p;
00098 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00099 int l;
00100
00101 if (coding<0 || coding>3)
00102 {
00103 printf("%s: ERROR: coding(%d) is out of range.\n", __FUNCTION__, coding);
00104 return;
00105 }
00106 if (capability<0 || capability>31)
00107 {
00108 printf("%s: ERROR: capability(%d) is out of range.\n", __FUNCTION__, capability);
00109 return;
00110 }
00111 if (mode<0 || mode>3)
00112 {
00113 printf("%s: ERROR: mode(%d) is out of range.\n", __FUNCTION__, mode);
00114 return;
00115 }
00116 if (rate<0 || rate>31)
00117 {
00118 printf("%s: ERROR: rate(%d) is out of range.\n", __FUNCTION__, rate);
00119 return;
00120 }
00121 if (multi>127)
00122 {
00123 printf("%s: ERROR: multi(%d) is out of range.\n", __FUNCTION__, multi);
00124 return;
00125 }
00126 if (user>31)
00127 {
00128 printf("%s: ERROR: user L1(%d) is out of range.\n", __FUNCTION__, rate);
00129 return;
00130 }
00131 if (rate!=24 && multi>=0)
00132 {
00133 printf("%s: WARNING: multi(%d) is only possible if rate(%d) would be 24.\n", __FUNCTION__, multi, rate);
00134 multi = -1;
00135 }
00136
00137 if (MISDN_IE_DEBG) printf(" coding=%d capability=%d mode=%d rate=%d multi=%d user=%d\n", coding, capability, mode, rate, multi, user);
00138
00139 l = 2 + (multi>=0) + (user>=0);
00140 p = msg_put(msg, l+2);
00141 if (nt)
00142 *ntmode = p+1;
00143 else
00144 qi->QI_ELEMENT(bearer_capability) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00145 p[0] = IE_BEARER;
00146 p[1] = l;
00147 p[2] = 0x80 + (coding<<5) + capability;
00148 p[3] = 0x80 + (mode<<5) + rate;
00149 if (multi >= 0)
00150 p[4] = 0x80 + multi;
00151 if (user >= 0)
00152 p[4+(multi>=0)] = 0xa0 + user;
00153 }
00154
00155 static void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *capability, int *mode, int *rate, int *multi, int *user,
00156 int *async, int *urate, int *stopbits, int *dbits, int *parity, int nt, struct misdn_bchannel *bc)
00157 {
00158 int octet;
00159 *coding = -1;
00160 *capability = -1;
00161 *mode = -1;
00162 *rate = -1;
00163 *multi = -1;
00164 *user = -1;
00165 *async = -1;
00166 *urate = -1;
00167 *stopbits = -1;
00168 *dbits = -1;
00169 *parity = -1;
00170
00171 if (!nt)
00172 {
00173 p = NULL;
00174 #ifdef LLC_SUPPORT
00175 if (qi->QI_ELEMENT(llc)) {
00176
00177 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(llc) + 1;
00178 }
00179 #endif
00180 if (qi->QI_ELEMENT(bearer_capability))
00181 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(bearer_capability) + 1;
00182 }
00183 if (!p)
00184 return;
00185
00186 if (p[0] < 2)
00187 {
00188 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00189 return;
00190 }
00191
00192 *coding = (p[1]&0x60) >> 5;
00193 *capability = p[1] & 0x1f;
00194 octet = 2;
00195 if (!(p[1] & 0x80))
00196 octet++;
00197
00198 if (p[0] < octet)
00199 goto done;
00200
00201 *mode = (p[octet]&0x60) >> 5;
00202 *rate = p[octet] & 0x1f;
00203
00204 octet++;
00205
00206 if (p[0] < octet)
00207 goto done;
00208
00209 if (*rate == 0x18) {
00210
00211 *multi = p[octet++] & 0x7f;
00212 }
00213
00214 if (p[0] < octet)
00215 goto done;
00216
00217
00218 if ((p[octet] & 0x60) == 0x20) {
00219 *user = p[octet] & 0x1f;
00220
00221 if (p[0] <= octet)
00222 goto done;
00223
00224 if (p[octet++] & 0x80)
00225 goto l2;
00226
00227 *async = !!(p[octet] & 0x40);
00228
00229 *urate = p[octet] & 0x1f;
00230
00231 if (p[0] <= octet)
00232 goto done;
00233
00234 if (p[octet++] & 0x80)
00235 goto l2;
00236
00237
00238
00239 if (p[0] <= octet)
00240 goto done;
00241
00242 if (p[octet++] & 0x80)
00243 goto l2;
00244
00245
00246
00247 if (p[0] <= octet)
00248 goto done;
00249
00250 if (~p[octet++] & 0x80)
00251 goto l2;
00252
00253
00254
00255 *stopbits = (p[octet] & 0x60) >> 5;
00256 *dbits = (p[octet] & 0x18) >> 3;
00257 *parity = p[octet] & 7;
00258
00259 octet++;
00260 }
00261 l2:
00262 done:
00263 if (MISDN_IE_DEBG) printf(" coding=%d capability=%d mode=%d rate=%d multi=%d user=%d async=%d urate=%d stopbits=%d dbits=%d parity=%d\n", *coding, *capability, *mode, *rate, *multi, *user, *async, *urate, *stopbits, *dbits, *parity);
00264 }
00265
00266
00267
00268 #if 0
00269 static void enc_ie_call_id(unsigned char **ntmode, msg_t *msg, char *callid, int callid_len, int nt, struct misdn_bchannel *bc)
00270 {
00271 unsigned char *p;
00272 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00273 int l;
00274
00275 char debug[25];
00276 int i;
00277
00278 if (!callid || callid_len<=0)
00279 {
00280 return;
00281 }
00282 if (callid_len>8)
00283 {
00284 printf("%s: ERROR: callid_len(%d) is out of range.\n", __FUNCTION__, callid_len);
00285 return;
00286 }
00287
00288 i = 0;
00289 while(i < callid_len)
00290 {
00291 if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", callid[i]);
00292 i++;
00293 }
00294
00295 if (MISDN_IE_DEBG) printf(" callid%s\n", debug);
00296
00297 l = callid_len;
00298 p = msg_put(msg, l+2);
00299 if (nt)
00300 *ntmode = p+1;
00301 else
00302 qi->QI_ELEMENT(call_id) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00303 p[0] = IE_CALL_ID;
00304 p[1] = l;
00305 memcpy(p+2, callid, callid_len);
00306 }
00307 #endif
00308
00309 #if 0
00310 static void dec_ie_call_id(unsigned char *p, Q931_info_t *qi, char *callid, int *callid_len, int nt, struct misdn_bchannel *bc)
00311 {
00312 char debug[25];
00313 int i;
00314
00315 *callid_len = -1;
00316
00317 if (!nt)
00318 {
00319 p = NULL;
00320 if (qi->QI_ELEMENT(call_id))
00321 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(call_id) + 1;
00322 }
00323 if (!p)
00324 return;
00325 if (p[0] > 8)
00326 {
00327 printf("%s: ERROR: IE too long (%d).\n", __FUNCTION__, p[0]);
00328 return;
00329 }
00330
00331 *callid_len = p[0];
00332 memcpy(callid, p+1, *callid_len);
00333
00334 i = 0;
00335 while(i < *callid_len)
00336 {
00337 if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", callid[i]);
00338 i++;
00339 }
00340
00341 if (MISDN_IE_DEBG) printf(" callid%s\n", debug);
00342 }
00343 #endif
00344
00345
00346 static void enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, char *number, int nt, struct misdn_bchannel *bc)
00347 {
00348 unsigned char *p;
00349 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00350 int l;
00351
00352 if (type<0 || type>7)
00353 {
00354 printf("%s: ERROR: type(%d) is out of range.\n", __FUNCTION__, type);
00355 return;
00356 }
00357 if (plan<0 || plan>15)
00358 {
00359 printf("%s: ERROR: plan(%d) is out of range.\n", __FUNCTION__, plan);
00360 return;
00361 }
00362 if (!number[0])
00363 {
00364 printf("%s: ERROR: number is not given.\n", __FUNCTION__);
00365 return;
00366 }
00367
00368 if (MISDN_IE_DEBG) printf(" type=%d plan=%d number='%s'\n", type, plan, number);
00369
00370 l = 1+strlen((char *)number);
00371 p = msg_put(msg, l+2);
00372 if (nt)
00373 *ntmode = p+1;
00374 else
00375 qi->QI_ELEMENT(called_nr) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00376 p[0] = IE_CALLED_PN;
00377 p[1] = l;
00378 p[2] = 0x80 + (type<<4) + plan;
00379 strncpy((char *)p+3, (char *)number, strlen((char *)number));
00380 }
00381
00382 static void dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, char *number, size_t number_len, int nt, struct misdn_bchannel *bc)
00383 {
00384 *type = -1;
00385 *plan = -1;
00386 *number = '\0';
00387
00388 if (!nt)
00389 {
00390 p = NULL;
00391 if (qi->QI_ELEMENT(called_nr))
00392 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(called_nr) + 1;
00393 }
00394 if (!p)
00395 return;
00396 if (p[0] < 2)
00397 {
00398 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00399 return;
00400 }
00401
00402 *type = (p[1]&0x70) >> 4;
00403 *plan = p[1] & 0xf;
00404 strnncpy(number, (char *)p+2, p[0]-1, number_len);
00405
00406 if (MISDN_IE_DEBG) printf(" type=%d plan=%d number='%s'\n", *type, *plan, number);
00407 }
00408
00409
00410
00411 static void enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, char *number, int nt, struct misdn_bchannel *bc)
00412 {
00413 unsigned char *p;
00414 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00415 int l;
00416
00417 if (type<0 || type>7)
00418 {
00419 printf("%s: ERROR: type(%d) is out of range.\n", __FUNCTION__, type);
00420 return;
00421 }
00422 if (plan<0 || plan>15)
00423 {
00424 printf("%s: ERROR: plan(%d) is out of range.\n", __FUNCTION__, plan);
00425 return;
00426 }
00427 if (present>3)
00428 {
00429 printf("%s: ERROR: present(%d) is out of range.\n", __FUNCTION__, present);
00430 return;
00431 }
00432 if (present >= 0) if (screen<0 || screen>3)
00433 {
00434 printf("%s: ERROR: screen(%d) is out of range.\n", __FUNCTION__, screen);
00435 return;
00436 }
00437
00438 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d screen=%d number='%s'\n", type, plan, present, screen, number);
00439
00440 l = 1;
00441 if (number) if (number[0])
00442 l += strlen((char *)number);
00443 if (present >= 0)
00444 l += 1;
00445 p = msg_put(msg, l+2);
00446 if (nt)
00447 *ntmode = p+1;
00448 else
00449 qi->QI_ELEMENT(calling_nr) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00450 p[0] = IE_CALLING_PN;
00451 p[1] = l;
00452 if (present >= 0)
00453 {
00454 p[2] = 0x00 + (type<<4) + plan;
00455 p[3] = 0x80 + (present<<5) + screen;
00456 if (number) if (number[0])
00457 strncpy((char *)p+4, (char *)number, strlen((char *)number));
00458 } else
00459 {
00460 p[2] = 0x80 + (type<<4) + plan;
00461 if (number) if (number[0])
00462 strncpy((char *)p+3, (char *)number, strlen((char *)number));
00463 }
00464 }
00465
00466 static void dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, char *number, size_t number_len, int nt, struct misdn_bchannel *bc)
00467 {
00468 *type = -1;
00469 *plan = -1;
00470 *present = -1;
00471 *screen = -1;
00472 *number = '\0';
00473
00474 if (!nt)
00475 {
00476 p = NULL;
00477 if (qi->QI_ELEMENT(calling_nr))
00478 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(calling_nr) + 1;
00479 }
00480 if (!p)
00481 return;
00482 if (p[0] < 1)
00483 {
00484 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00485 return;
00486 }
00487
00488 *type = (p[1]&0x70) >> 4;
00489 *plan = p[1] & 0xf;
00490 if (!(p[1] & 0x80))
00491 {
00492 if (p[0] < 2)
00493 {
00494 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00495 return;
00496 }
00497 *present = (p[2]&0x60) >> 5;
00498 *screen = p[2] & 0x3;
00499 strnncpy(number, (char *)p+3, p[0]-2, number_len);
00500 } else
00501 {
00502 strnncpy(number, (char *)p+2, p[0]-1, number_len);
00503
00504
00505
00506 }
00507
00508 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d screen=%d number='%s'\n", *type, *plan, *present, *screen, number);
00509 }
00510
00511
00512
00513 static void enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, char *number, int nt, struct misdn_bchannel *bc)
00514 {
00515 unsigned char *p;
00516 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00517 int l;
00518
00519 if (type<0 || type>7)
00520 {
00521 printf("%s: ERROR: type(%d) is out of range.\n", __FUNCTION__, type);
00522 return;
00523 }
00524 if (plan<0 || plan>15)
00525 {
00526 printf("%s: ERROR: plan(%d) is out of range.\n", __FUNCTION__, plan);
00527 return;
00528 }
00529 if (present>3)
00530 {
00531 printf("%s: ERROR: present(%d) is out of range.\n", __FUNCTION__, present);
00532 return;
00533 }
00534 if (present >= 0) if (screen<0 || screen>3)
00535 {
00536 printf("%s: ERROR: screen(%d) is out of range.\n", __FUNCTION__, screen);
00537 return;
00538 }
00539
00540 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d screen=%d number='%s'\n", type, plan, present, screen, number);
00541
00542 l = 1;
00543 if (number) if (number[0])
00544 l += strlen((char *)number);
00545 if (present >= 0)
00546 l += 1;
00547 p = msg_put(msg, l+2);
00548 if (nt)
00549 *ntmode = p+1;
00550 else
00551 qi->QI_ELEMENT(connected_nr) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00552 p[0] = IE_CONNECT_PN;
00553 p[1] = l;
00554 if (present >= 0)
00555 {
00556 p[2] = 0x00 + (type<<4) + plan;
00557 p[3] = 0x80 + (present<<5) + screen;
00558 if (number) if (number[0])
00559 strncpy((char *)p+4, (char *)number, strlen((char *)number));
00560 } else
00561 {
00562 p[2] = 0x80 + (type<<4) + plan;
00563 if (number) if (number[0])
00564 strncpy((char *)p+3, (char *)number, strlen((char *)number));
00565 }
00566 }
00567
00568 static void dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, char *number, size_t number_len, int nt, struct misdn_bchannel *bc)
00569 {
00570 *type = -1;
00571 *plan = -1;
00572 *present = -1;
00573 *screen = -1;
00574 *number = '\0';
00575
00576 if (!nt)
00577 {
00578 p = NULL;
00579 if (qi->QI_ELEMENT(connected_nr))
00580 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(connected_nr) + 1;
00581 }
00582 if (!p)
00583 return;
00584 if (p[0] < 1)
00585 {
00586 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00587 return;
00588 }
00589
00590 *type = (p[1]&0x70) >> 4;
00591 *plan = p[1] & 0xf;
00592 if (!(p[1] & 0x80))
00593 {
00594 if (p[0] < 2)
00595 {
00596 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00597 return;
00598 }
00599 *present = (p[2]&0x60) >> 5;
00600 *screen = p[2] & 0x3;
00601 strnncpy(number, (char *)p+3, p[0]-2, number_len);
00602 } else
00603 {
00604 strnncpy(number, (char *)p+2, p[0]-1, number_len);
00605 }
00606
00607 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d screen=%d number='%s'\n", *type, *plan, *present, *screen, number);
00608 }
00609
00610
00611
00612 static void enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int cause, int nt, struct misdn_bchannel *bc)
00613 {
00614 unsigned char *p;
00615 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00616 int l;
00617
00618 if (location<0 || location>7)
00619 {
00620 printf("%s: ERROR: location(%d) is out of range.\n", __FUNCTION__, location);
00621 return;
00622 }
00623 if (cause<0 || cause>127)
00624 {
00625 printf("%s: ERROR: cause(%d) is out of range.\n", __FUNCTION__, cause);
00626 return;
00627 }
00628
00629 if (MISDN_IE_DEBG) printf(" location=%d cause=%d\n", location, cause);
00630
00631 l = 2;
00632 p = msg_put(msg, l+2);
00633 if (nt)
00634 *ntmode = p+1;
00635 else
00636 qi->QI_ELEMENT(cause) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00637 p[0] = IE_CAUSE;
00638 p[1] = l;
00639 p[2] = 0x80 + location;
00640 p[3] = 0x80 + cause;
00641 }
00642
00643 #if 0
00644 static void enc_ie_cause_standalone(unsigned char **ntmode, msg_t *msg, int location, int cause, int nt, struct misdn_bchannel *bc)
00645 {
00646 unsigned char *p = msg_put(msg, 4);
00647 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00648 if (ntmode)
00649 *ntmode = p+1;
00650 else
00651 qi->QI_ELEMENT(cause) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00652 p[0] = IE_CAUSE;
00653 p[1] = 2;
00654 p[2] = 0x80 + location;
00655 p[3] = 0x80 + cause;
00656 }
00657 #endif
00658
00659 static void dec_ie_cause(unsigned char *p, Q931_info_t *qi, int *location, int *cause, int nt, struct misdn_bchannel *bc)
00660 {
00661 *location = -1;
00662 *cause = -1;
00663
00664 if (!nt)
00665 {
00666 p = NULL;
00667 if (qi->QI_ELEMENT(cause))
00668 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(cause) + 1;
00669 }
00670 if (!p)
00671 return;
00672 if (p[0] < 2)
00673 {
00674 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00675 return;
00676 }
00677
00678 *location = p[1] & 0x0f;
00679 *cause = p[2] & 0x7f;
00680
00681 if (MISDN_IE_DEBG) printf(" location=%d cause=%d\n", *location, *cause);
00682 }
00683
00684
00685
00686 static void enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, int channel, int nt, struct misdn_bchannel *bc)
00687 {
00688 unsigned char *p;
00689 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00690 int l;
00691 struct misdn_stack *stack=get_stack_by_bc(bc);
00692 int pri = stack->pri;
00693
00694 if (exclusive<0 || exclusive>1)
00695 {
00696 printf("%s: ERROR: exclusive(%d) is out of range.\n", __FUNCTION__, exclusive);
00697 return;
00698 }
00699 if ((channel<0 || channel>0xff)
00700 || (!pri && (channel>2 && channel<0xff))
00701 || (pri && (channel>31 && channel<0xff))
00702 || (pri && channel==16))
00703 {
00704 printf("%s: ERROR: channel(%d) is out of range.\n", __FUNCTION__, channel);
00705 return;
00706 }
00707
00708
00709
00710
00711 if (!pri)
00712 {
00713
00714 l = 1;
00715 p = msg_put(msg, l+2);
00716 if (nt)
00717 *ntmode = p+1;
00718 else
00719 qi->QI_ELEMENT(channel_id) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00720 p[0] = IE_CHANNEL_ID;
00721 p[1] = l;
00722 if (channel == 0xff)
00723 channel = 3;
00724 p[2] = 0x80 + (exclusive<<3) + channel;
00725
00726 } else
00727 {
00728
00729 if (channel == 0)
00730 return;
00731
00732 if (channel == 0xff)
00733 {
00734 l = 1;
00735 p = msg_put(msg, l+2);
00736 if (nt)
00737 *ntmode = p+1;
00738 else
00739 qi->QI_ELEMENT(channel_id) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00740 p[0] = IE_CHANNEL_ID;
00741 p[1] = l;
00742 p[2] = 0x80 + 0x20 + 0x03;
00743
00744 return;
00745 }
00746 l = 3;
00747 p = msg_put(msg, l+2);
00748 if (nt)
00749 *ntmode = p+1;
00750 else
00751 qi->QI_ELEMENT(channel_id) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00752 p[0] = IE_CHANNEL_ID;
00753 p[1] = l;
00754 p[2] = 0x80 + 0x20 + (exclusive<<3) + 0x01;
00755 p[3] = 0x80 + 3;
00756 p[4] = 0x80 + channel;
00757
00758 }
00759 }
00760
00761 static void dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, int *channel, int nt, struct misdn_bchannel *bc)
00762 {
00763 struct misdn_stack *stack=get_stack_by_bc(bc);
00764 int pri =stack->pri;
00765
00766 *exclusive = -1;
00767 *channel = -1;
00768
00769 if (!nt)
00770 {
00771 p = NULL;
00772 if (qi->QI_ELEMENT(channel_id))
00773 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(channel_id) + 1;
00774 }
00775 if (!p)
00776 return;
00777 if (p[0] < 1)
00778 {
00779 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00780 return;
00781 }
00782
00783 if (p[1] & 0x40)
00784 {
00785 printf("%s: ERROR: refering to channels of other interfaces is not supported.\n", __FUNCTION__);
00786 return;
00787 }
00788 if (p[1] & 0x04)
00789 {
00790 printf("%s: ERROR: using d-channel is not supported.\n", __FUNCTION__);
00791 return;
00792 }
00793
00794 *exclusive = (p[1]&0x08) >> 3;
00795 if (!pri)
00796 {
00797
00798 if (p[1] & 0x20)
00799 {
00800 printf("%s: ERROR: extended channel ID with non PRI interface.\n", __FUNCTION__);
00801 return;
00802 }
00803 *channel = p[1] & 0x03;
00804 if (*channel == 3)
00805 *channel = 0xff;
00806 } else
00807 {
00808
00809 if (p[0] < 1)
00810 {
00811 printf("%s: ERROR: IE too short for PRI (%d).\n", __FUNCTION__, p[0]);
00812 return;
00813 }
00814 if (!(p[1] & 0x20))
00815 {
00816 printf("%s: ERROR: basic channel ID with PRI interface.\n", __FUNCTION__);
00817 return;
00818 }
00819 if ((p[1]&0x03) == 0x00)
00820 {
00821
00822 *channel = 0;
00823 return;
00824 }
00825 if ((p[1]&0x03) == 0x03)
00826 {
00827
00828 *channel = 0xff;
00829 return;
00830 }
00831 if (p[0] < 3)
00832 {
00833 printf("%s: ERROR: IE too short for PRI with channel(%d).\n", __FUNCTION__, p[0]);
00834 return;
00835 }
00836 if (p[2] & 0x10)
00837 {
00838 printf("%s: ERROR: channel map not supported.\n", __FUNCTION__);
00839 return;
00840 }
00841 *channel = p[3] & 0x7f;
00842 if ( (*channel<1) | (*channel==16) | (*channel>31))
00843 {
00844 printf("%s: ERROR: PRI interface channel out of range (%d).\n", __FUNCTION__, *channel);
00845 return;
00846 }
00847
00848 }
00849
00850 if (MISDN_IE_DEBG) printf(" exclusive=%d channel=%d\n", *exclusive, *channel);
00851 }
00852
00853
00854
00855 static void enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int nt, struct misdn_bchannel *bc)
00856 {
00857 unsigned char *p;
00858 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00859 int l;
00860 struct timeval tv = { ti, 0 };
00861 struct ast_tm tm;
00862
00863 ast_localtime(&tv, &tm, NULL);
00864 if (MISDN_IE_DEBG) printf(" year=%d month=%d day=%d hour=%d minute=%d\n", tm.tm_year%100, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
00865
00866 l = 5;
00867 p = msg_put(msg, l+2);
00868 if (nt)
00869 *ntmode = p+1;
00870 else
00871 qi->QI_ELEMENT(date) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00872 p[0] = IE_DATE;
00873 p[1] = l;
00874 p[2] = tm.tm_year % 100;
00875 p[3] = tm.tm_mon + 1;
00876 p[4] = tm.tm_mday;
00877 p[5] = tm.tm_hour;
00878 p[6] = tm.tm_min;
00879 }
00880
00881
00882
00883 static void enc_ie_display(unsigned char **ntmode, msg_t *msg, char *display, int nt, struct misdn_bchannel *bc)
00884 {
00885 unsigned char *p;
00886 Q931_info_t *qi = (Q931_info_t *) (msg->data + mISDN_HEADER_LEN);
00887 int l;
00888
00889 if (!display[0])
00890 {
00891 printf("%s: ERROR: display text not given.\n", __FUNCTION__);
00892 return;
00893 }
00894
00895 l = strlen(display);
00896 if (80 < l)
00897 {
00898 l = 80;
00899 printf("%s: WARNING: display text too long (max %d chars), cutting.\n", __FUNCTION__, l);
00900 display[l] = '\0';
00901 }
00902
00903
00904
00905 p = msg_put(msg, l + 2);
00906 if (nt)
00907 *ntmode = p + 1;
00908 else
00909 qi->QI_ELEMENT(display) = p - (unsigned char *) qi - sizeof(Q931_info_t);
00910 p[0] = IE_DISPLAY;
00911 p[1] = l;
00912 strncpy((char *) p + 2, display, l);
00913 }
00914
00915 #if 0
00916 static void dec_ie_display(unsigned char *p, Q931_info_t *qi, char *display, size_t display_len, int nt, struct misdn_bchannel *bc)
00917 {
00918 *display = '\0';
00919
00920 if (!nt)
00921 {
00922 p = NULL;
00923 if (qi->QI_ELEMENT(display))
00924 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(display) + 1;
00925 }
00926 if (!p)
00927 return;
00928 if (p[0] < 1)
00929 {
00930 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00931 return;
00932 }
00933
00934 strnncpy(display, (char *)p+1, p[0], display_len);
00935
00936 if (MISDN_IE_DEBG) printf(" display='%s'\n", display);
00937 }
00938 #endif
00939
00940
00941 #if 1
00942 static void enc_ie_keypad(unsigned char **ntmode, msg_t *msg, char *keypad, int nt, struct misdn_bchannel *bc)
00943 {
00944 unsigned char *p;
00945 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00946 int l;
00947
00948 if (!keypad[0])
00949 {
00950 printf("%s: ERROR: keypad info not given.\n", __FUNCTION__);
00951 return;
00952 }
00953
00954 if (MISDN_IE_DEBG) printf(" keypad='%s'\n", keypad);
00955
00956 l = strlen(keypad);
00957 p = msg_put(msg, l+2);
00958 if (nt)
00959 *ntmode = p+1;
00960 else
00961 qi->QI_ELEMENT(keypad) = p - (unsigned char *)qi - sizeof(Q931_info_t);
00962 p[0] = IE_KEYPAD;
00963 p[1] = l;
00964 strncpy((char *)p+2, keypad, strlen(keypad));
00965 }
00966 #endif
00967
00968 static void dec_ie_keypad(unsigned char *p, Q931_info_t *qi, char *keypad, size_t keypad_len, int nt, struct misdn_bchannel *bc)
00969 {
00970 *keypad = '\0';
00971
00972 if (!nt)
00973 {
00974 p = NULL;
00975 if (qi->QI_ELEMENT(keypad))
00976 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(keypad) + 1;
00977 }
00978 if (!p)
00979 return;
00980 if (p[0] < 1)
00981 {
00982 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
00983 return;
00984 }
00985
00986 strnncpy(keypad, (char *)p+1, p[0], keypad_len);
00987
00988 if (MISDN_IE_DEBG) printf(" keypad='%s'\n", keypad);
00989 }
00990
00991
00992
00993 static void enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify, int nt, struct misdn_bchannel *bc)
00994 {
00995 unsigned char *p;
00996 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
00997 int l;
00998
00999 if (notify<0 || notify>0x7f)
01000 {
01001 printf("%s: ERROR: notify(%d) is out of range.\n", __FUNCTION__, notify);
01002 return;
01003 }
01004
01005 if (MISDN_IE_DEBG) printf(" notify=%d\n", notify);
01006
01007 l = 1;
01008 p = msg_put(msg, l+2);
01009 if (nt)
01010 *ntmode = p+1;
01011 else
01012 qi->QI_ELEMENT(notify) = p - (unsigned char *)qi - sizeof(Q931_info_t);
01013 p[0] = IE_NOTIFY;
01014 p[1] = l;
01015 p[2] = 0x80 + notify;
01016 }
01017
01018 static void dec_ie_notify(unsigned char *p, Q931_info_t *qi, int *notify, int nt, struct misdn_bchannel *bc)
01019 {
01020 *notify = -1;
01021
01022 if (!nt)
01023 {
01024 p = NULL;
01025 if (qi->QI_ELEMENT(notify))
01026 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(notify) + 1;
01027 }
01028 if (!p)
01029 return;
01030 if (p[0] < 1)
01031 {
01032 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
01033 return;
01034 }
01035
01036 *notify = p[1] & 0x7f;
01037
01038 if (MISDN_IE_DEBG) printf(" notify=%d\n", *notify);
01039 }
01040
01041
01042
01043 static void enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int location, int progress, int nt, struct misdn_bchannel *bc)
01044 {
01045 unsigned char *p;
01046 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
01047 int l;
01048
01049 if (coding<0 || coding>0x03)
01050 {
01051 printf("%s: ERROR: coding(%d) is out of range.\n", __FUNCTION__, coding);
01052 return;
01053 }
01054 if (location<0 || location>0x0f)
01055 {
01056 printf("%s: ERROR: location(%d) is out of range.\n", __FUNCTION__, location);
01057 return;
01058 }
01059 if (progress<0 || progress>0x7f)
01060 {
01061 printf("%s: ERROR: progress(%d) is out of range.\n", __FUNCTION__, progress);
01062 return;
01063 }
01064
01065 if (MISDN_IE_DEBG) printf(" coding=%d location=%d progress=%d\n", coding, location, progress);
01066
01067 l = 2;
01068 p = msg_put(msg, l+2);
01069 if (nt)
01070 *ntmode = p+1;
01071 else
01072 qi->QI_ELEMENT(progress) = p - (unsigned char *)qi - sizeof(Q931_info_t);
01073 p[0] = IE_PROGRESS;
01074 p[1] = l;
01075 p[2] = 0x80 + (coding<<5) + location;
01076 p[3] = 0x80 + progress;
01077 }
01078
01079 static void dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int *location, int *progress, int nt, struct misdn_bchannel *bc)
01080 {
01081 *coding = -1;
01082 *location = -1;
01083
01084 *progress = 0;
01085
01086 if (!nt)
01087 {
01088 p = NULL;
01089 if (qi->QI_ELEMENT(progress))
01090 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(progress) + 1;
01091 }
01092 if (!p)
01093 return;
01094 if (p[0] < 1)
01095 {
01096 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
01097 return;
01098 }
01099
01100 *coding = (p[1]&0x60) >> 5;
01101 *location = p[1] & 0x0f;
01102 *progress = p[2] & 0x7f;
01103
01104 if (MISDN_IE_DEBG) printf(" coding=%d location=%d progress=%d\n", *coding, *location, *progress);
01105 }
01106
01107
01108
01109 static void enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, int reason, char *number, int nt, struct misdn_bchannel *bc)
01110 {
01111 unsigned char *p;
01112 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
01113 int l;
01114
01115 if (type<0 || type>7)
01116 {
01117 printf("%s: ERROR: type(%d) is out of range.\n", __FUNCTION__, type);
01118 return;
01119 }
01120 if (plan<0 || plan>15)
01121 {
01122 printf("%s: ERROR: plan(%d) is out of range.\n", __FUNCTION__, plan);
01123 return;
01124 }
01125 if (present > 3)
01126 {
01127 printf("%s: ERROR: present(%d) is out of range.\n", __FUNCTION__, present);
01128 return;
01129 }
01130 if (present >= 0) if (screen<0 || screen>3)
01131 {
01132 printf("%s: ERROR: screen(%d) is out of range.\n", __FUNCTION__, screen);
01133 return;
01134 }
01135 if (reason > 0x0f)
01136 {
01137 printf("%s: ERROR: reason(%d) is out of range.\n", __FUNCTION__, reason);
01138 return;
01139 }
01140
01141 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d screen=%d readon=%d number='%s'\n", type, plan, present, screen, reason, number);
01142
01143 l = 1;
01144 if (number)
01145 l += strlen((char *)number);
01146 if (present >= 0)
01147 {
01148 l += 1;
01149 if (reason >= 0)
01150 l += 1;
01151 }
01152 p = msg_put(msg, l+2);
01153 if (nt)
01154 *ntmode = p+1;
01155 else
01156 qi->QI_ELEMENT(redirect_nr) = p - (unsigned char *)qi - sizeof(Q931_info_t);
01157 p[0] = IE_REDIR_NR;
01158 p[1] = l;
01159 if (present >= 0)
01160 {
01161 if (reason >= 0)
01162 {
01163 p[2] = 0x00 + (type<<4) + plan;
01164 p[3] = 0x00 + (present<<5) + screen;
01165 p[4] = 0x80 + reason;
01166 if (number)
01167 strncpy((char *)p+5, (char *)number, strlen((char *)number));
01168 } else
01169 {
01170 p[2] = 0x00 + (type<<4) + plan;
01171 p[3] = 0x80 + (present<<5) + screen;
01172 if (number)
01173 strncpy((char *)p+4, (char *)number, strlen((char *)number));
01174 }
01175 } else
01176 {
01177 p[2] = 0x80 + (type<<4) + plan;
01178 if (number) if (number[0])
01179 strncpy((char *)p+3, (char *)number, strlen((char *)number));
01180 }
01181 }
01182
01183 static void dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, int *reason, char *number, size_t number_len, int nt, struct misdn_bchannel *bc)
01184 {
01185 *type = -1;
01186 *plan = -1;
01187 *present = -1;
01188 *screen = -1;
01189 *reason = -1;
01190 *number = '\0';
01191
01192 if (!nt)
01193 {
01194 p = NULL;
01195 if (qi->QI_ELEMENT(redirect_nr))
01196 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(redirect_nr) + 1;
01197 }
01198 if (!p)
01199 return;
01200 if (p[0] < 1)
01201 {
01202 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
01203 return;
01204 }
01205
01206 *type = (p[1]&0x70) >> 4;
01207 *plan = p[1] & 0xf;
01208 if (!(p[1] & 0x80))
01209 {
01210 *present = (p[2]&0x60) >> 5;
01211 *screen = p[2] & 0x3;
01212 if (!(p[2] & 0x80))
01213 {
01214 *reason = p[3] & 0x0f;
01215 strnncpy(number, (char *)p+4, p[0]-3, number_len);
01216 } else
01217 {
01218 strnncpy(number, (char *)p+3, p[0]-2, number_len);
01219 }
01220 } else
01221 {
01222 strnncpy(number, (char *)p+2, p[0]-1, number_len);
01223 }
01224
01225 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d screen=%d reason=%d number='%s'\n", *type, *plan, *present, *screen, *reason, number);
01226 }
01227
01228
01229
01230 static void enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, char *number, int nt, struct misdn_bchannel *bc)
01231 {
01232 unsigned char *p;
01233 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
01234 int l;
01235
01236 if (type<0 || type>7)
01237 {
01238 printf("%s: ERROR: type(%d) is out of range.\n", __FUNCTION__, type);
01239 return;
01240 }
01241 if (plan<0 || plan>15)
01242 {
01243 printf("%s: ERROR: plan(%d) is out of range.\n", __FUNCTION__, plan);
01244 return;
01245 }
01246 if (present > 3)
01247 {
01248 printf("%s: ERROR: present(%d) is out of range.\n", __FUNCTION__, present);
01249 return;
01250 }
01251
01252 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d number='%s'\n", type, plan, present, number);
01253
01254 l = 1;
01255 if (number)
01256 l += strlen((char *)number);
01257 if (present >= 0)
01258 l += 1;
01259 p = msg_put(msg, l+2);
01260 if (nt)
01261 *ntmode = p+1;
01262 else {
01263 qi->QI_ELEMENT(redirect_dn) = p - (unsigned char *)qi - sizeof(Q931_info_t);
01264 }
01265 p[0] = IE_REDIR_DN;
01266 p[1] = l;
01267 if (present >= 0)
01268 {
01269 p[2] = 0x00 + (type<<4) + plan;
01270 p[3] = 0x80 + (present<<5);
01271 if (number)
01272 strncpy((char *)p+4, (char *)number, strlen((char *)number));
01273 } else
01274 {
01275 p[2] = 0x80 + (type<<4) + plan;
01276 if (number)
01277 strncpy((char *)p+3, (char *)number, strlen((char *)number));
01278 }
01279 }
01280
01281 static void dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, char *number, size_t number_len, int nt, struct misdn_bchannel *bc)
01282 {
01283 *type = -1;
01284 *plan = -1;
01285 *present = -1;
01286 *number = '\0';
01287
01288 if (!nt)
01289 {
01290 p = NULL;
01291 if (qi->QI_ELEMENT(redirect_dn))
01292 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(redirect_dn) + 1;
01293 }
01294 if (!p)
01295 return;
01296 if (p[0] < 1)
01297 {
01298 printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
01299 return;
01300 }
01301
01302 *type = (p[1]&0x70) >> 4;
01303 *plan = p[1] & 0xf;
01304 if (!(p[1] & 0x80))
01305 {
01306 *present = (p[2]&0x60) >> 5;
01307 strnncpy(number, (char *)p+3, p[0]-2, number_len);
01308 } else
01309 {
01310 strnncpy(number, (char *)p+2, p[0]-1, number_len);
01311 }
01312
01313 if (MISDN_IE_DEBG) printf(" type=%d plan=%d present=%d number='%s'\n", *type, *plan, *present, number);
01314 }
01315
01316
01317
01318 #if 1
01319 static void enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, char *user, int user_len, int nt, struct misdn_bchannel *bc)
01320 {
01321 unsigned char *p;
01322 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
01323 int l;
01324
01325 if (protocol<0 || protocol>127)
01326 {
01327 printf("%s: ERROR: protocol(%d) is out of range.\n", __FUNCTION__, protocol);
01328 return;
01329 }
01330 if (!user || user_len<=0)
01331 {
01332 return;
01333 }
01334
01335 if (MISDN_IE_DEBG) {
01336 size_t i;
01337 char debug[768];
01338
01339 for (i = 0; i < user_len; ++i) {
01340 sprintf(debug + (i * 3), " %02x", user[i]);
01341 }
01342 debug[i * 3] = 0;
01343 printf(" protocol=%d user-user%s\n", protocol, debug);
01344 }
01345
01346 l = user_len+1;
01347 p = msg_put(msg, l+3);
01348 if (nt)
01349 *ntmode = p+1;
01350 else
01351 qi->QI_ELEMENT(useruser) = p - (unsigned char *)qi - sizeof(Q931_info_t);
01352 p[0] = IE_USER_USER;
01353 p[1] = l;
01354 p[2] = protocol;
01355 memcpy(p+3, user, user_len);
01356 }
01357 #endif
01358
01359 #if 1
01360 static void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, char *user, int *user_len, int nt, struct misdn_bchannel *bc)
01361 {
01362 *user_len = 0;
01363 *protocol = -1;
01364
01365 if (!nt)
01366 {
01367 p = NULL;
01368 if (qi->QI_ELEMENT(useruser))
01369 p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(useruser) + 1;
01370 }
01371 if (!p)
01372 return;
01373
01374 *user_len = p[0]-1;
01375 if (p[0] < 1)
01376 return;
01377 *protocol = p[1];
01378 memcpy(user, p+2, (*user_len<=128)?*(user_len):128);
01379
01380 if (MISDN_IE_DEBG) {
01381 int i;
01382 char debug[768];
01383
01384 for (i = 0; i < *user_len; ++i) {
01385 sprintf(debug + (i * 3), " %02x", user[i]);
01386 }
01387 debug[i * 3] = 0;
01388 printf(" protocol=%d user-user%s\n", *protocol, debug);
01389 }
01390 }
01391 #endif
01392
01393
01394 static void enc_ie_restart_ind(unsigned char **ntmode, msg_t *msg, unsigned char rind, int nt, struct misdn_bchannel *bc)
01395 {
01396 unsigned char *p;
01397 Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
01398
01399
01400 p = msg_put(msg, 3);
01401 if (nt)
01402 *ntmode = p+1;
01403 else
01404 qi->QI_ELEMENT(restart_ind) = p - (unsigned char *)qi - sizeof(Q931_info_t);
01405 p[0] = IE_RESTART_IND;
01406 p[1] = 1;
01407 p[2] = rind;
01408
01409 }
01410