| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#include "asterisk.h" |
| 18 |
#include "asterisk/lock.h" |
| 19 |
#include "asterisk/utils.h" |
| 20 |
#include "asterisk/config.h" |
| 21 |
#include "asterisk/netsock2.h" |
| 22 |
#include <time.h> |
| 23 |
|
| 24 |
#include "ooq931.h" |
| 25 |
#include "ootrace.h" |
| 26 |
#include "ooasn1.h" |
| 27 |
#include "oochannels.h" |
| 28 |
#include "printHandler.h" |
| 29 |
#include "ooCalls.h" |
| 30 |
#include "ooh323.h" |
| 31 |
#include "ooh245.h" |
| 32 |
#include "ooh323ep.h" |
| 33 |
#include "ooCapability.h" |
| 34 |
#include "ooGkClient.h" |
| 35 |
#include "ooUtils.h" |
| 36 |
#include "ootypes.h" |
| 37 |
#include <time.h> |
| 38 |
#include <ctype.h> |
| 39 |
|
| 40 |
int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg, |
| 41 |
ASN1UINT *fsCount, ASN1DynOctStr **fsElem); |
| 42 |
|
| 43 |
|
| 44 |
extern OOH323EndPoint gH323ep; |
| 45 |
|
| 46 |
extern ast_mutex_t newCallLock; |
| 47 |
|
| 48 |
static ASN1OBJID gProtocolID = { |
| 49 |
6, { 0, 0, 8, 2250, 0, 4 } |
| 50 |
}; |
| 51 |
|
| 52 |
EXTERN int ooQ931Decode |
| 53 |
(OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data, int docallbacks) |
| 54 |
{ |
| 55 |
int offset, x; |
| 56 |
int rv = ASN_OK; |
| 57 |
char number[128]; |
| 58 |
char *display = NULL; |
| 59 |
|
| 60 |
OOCTXT *pctxt = call->msgctxt; |
| 61 |
|
| 62 |
dListInit (&msg->ies); |
| 63 |
|
| 64 |
if (length < 5) |
| 65 |
return Q931_E_TOOSHORT; |
| 66 |
|
| 67 |
msg->protocolDiscriminator = data[0]; |
| 68 |
OOTRACEDBGB2(" protocolDiscriminator = %d\n", msg->protocolDiscriminator); |
| 69 |
if (data[1] != 2) |
| 70 |
return Q931_E_INVCALLREF; |
| 71 |
|
| 72 |
msg->callReference = ((data[2] & 0x7f) << 8) | data[3]; |
| 73 |
|
| 74 |
OOTRACEDBGB2(" callReference = %d\n", msg->callReference); |
| 75 |
|
| 76 |
msg->fromDestination = (data[2] & 0x80) != 0; |
| 77 |
if(msg->fromDestination) |
| 78 |
OOTRACEDBGB1(" from = destination\n"); |
| 79 |
else |
| 80 |
OOTRACEDBGB1(" from = originator\n"); |
| 81 |
|
| 82 |
|
| 83 |
msg->messageType = data[4]; |
| 84 |
OOTRACEDBGB2(" messageType = %x\n", msg->messageType); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
offset = 5; |
| 89 |
while (offset < length) { |
| 90 |
Q931InformationElement *ie; |
| 91 |
int ieOff = offset; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
int discriminator = data[offset++]; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
if ((discriminator & 0x80) == 0 && offset < length) { |
| 106 |
int len = data[offset], alen; |
| 107 |
|
| 108 |
if (discriminator == Q931UserUserIE) { |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
if (++offset >= length) { |
| 124 |
return Q931_E_INVLENGTH; |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
len <<= 8; |
| 132 |
len |= data[offset]; |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
if (++offset >= length) { |
| 140 |
return Q931_E_INVLENGTH; |
| 141 |
} |
| 142 |
len--; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
++offset; |
| 150 |
|
| 151 |
|
| 152 |
if (len < 0) { |
| 153 |
return Q931_E_INVLENGTH; |
| 154 |
} |
| 155 |
else if (offset + len > length) { |
| 156 |
alen = 0; |
| 157 |
len = -len; |
| 158 |
rv = Q931_E_INVLENGTH; |
| 159 |
} |
| 160 |
else alen = len; |
| 161 |
|
| 162 |
ie = (Q931InformationElement*) |
| 163 |
memAlloc (pctxt, sizeof(*ie) - sizeof(ie->data) + alen); |
| 164 |
if(!ie) |
| 165 |
{ |
| 166 |
OOTRACEERR3("Error:Memory - ooQ931Decode - ie(%s, %s)\n", |
| 167 |
call->callType, call->callToken); |
| 168 |
return OO_FAILED; |
| 169 |
} |
| 170 |
ie->discriminator = discriminator; |
| 171 |
ie->offset = ieOff; |
| 172 |
ie->length = len; |
| 173 |
if (alen != 0) |
| 174 |
memcpy(ie->data, data + offset, alen); |
| 175 |
offset += len; |
| 176 |
} |
| 177 |
else { |
| 178 |
ie = (Q931InformationElement*) memAlloc (pctxt, |
| 179 |
sizeof(*ie)); |
| 180 |
if(!ie) |
| 181 |
{ |
| 182 |
OOTRACEERR3("Error:Memory - ooQ931Decode - ie(%s, %s)\n", |
| 183 |
call->callType, call->callToken); |
| 184 |
return OO_FAILED; |
| 185 |
} |
| 186 |
ie->discriminator = discriminator; |
| 187 |
ie->offset = offset; |
| 188 |
ie->length = 0; |
| 189 |
} |
| 190 |
if(ie->discriminator == Q931BearerCapabilityIE) |
| 191 |
{ |
| 192 |
OOTRACEDBGB1(" Bearer-Capability IE = {\n"); |
| 193 |
for(x=0; x<ie->length; x++) |
| 194 |
{ |
| 195 |
if(x==0) |
| 196 |
OOTRACEDBGB2(" %x", ie->data[x]); |
| 197 |
else |
| 198 |
OOTRACEDBGB2(", %x", ie->data[x]); |
| 199 |
} |
| 200 |
OOTRACEDBGB1(" }\n"); |
| 201 |
} |
| 202 |
if(ie->discriminator == Q931DisplayIE) |
| 203 |
{ |
| 204 |
if (!(display = memAllocZ(pctxt, ie->length + 1))) { |
| 205 |
OOTRACEERR4("Can't alloc DisplayIE buffer for %n bytes, (%s, %s)\n", ie->length, |
| 206 |
call->callType, call->callToken); |
| 207 |
} else { |
| 208 |
memcpy(display, ie->data,ie->length); |
| 209 |
OOTRACEDBGB1(" Display IE = {\n"); |
| 210 |
OOTRACEDBGB2(" %s\n", display); |
| 211 |
OOTRACEDBGB1(" }\n"); |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
if(ie->discriminator == Q931KeypadIE) |
| 216 |
{ |
| 217 |
OOTRACEDBGB1(" Keypad IE = {\n"); |
| 218 |
OOTRACEDBGB2(" %c\n", ie->data[0]); |
| 219 |
OOTRACEDBGB1(" }\n"); |
| 220 |
if(docallbacks && gH323ep.h323Callbacks.onReceivedDTMF) |
| 221 |
{ |
| 222 |
gH323ep.h323Callbacks.onReceivedDTMF(call, (char *)ie->data); |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
if(ie->discriminator == Q931CallingPartyNumberIE) |
| 228 |
{ |
| 229 |
int numoffset=1; |
| 230 |
OOTRACEDBGB1(" CallingPartyNumber IE = {\n"); |
| 231 |
if(!(0x80 & ie->data[0])) numoffset = 2; |
| 232 |
|
| 233 |
if( (ie->length >= numoffset) && |
| 234 |
(ie->length < OO_MAX_NUMBER_LENGTH) ) |
| 235 |
{ |
| 236 |
memcpy(number, ie->data+numoffset,ie->length-numoffset); |
| 237 |
number[ie->length-numoffset]='\0'; |
| 238 |
OOTRACEDBGB2(" %s\n", number); |
| 239 |
if(!call->callingPartyNumber) |
| 240 |
ooCallSetCallingPartyNumber(call, number); |
| 241 |
} |
| 242 |
else{ |
| 243 |
OOTRACEERR3("Error:Calling party number outside range. (%s, %s)\n", |
| 244 |
call->callType, call->callToken); |
| 245 |
} |
| 246 |
OOTRACEDBGB1(" }\n"); |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
if(ie->discriminator == Q931CalledPartyNumberIE) |
| 251 |
{ |
| 252 |
OOTRACEDBGB1(" CalledPartyNumber IE = {\n"); |
| 253 |
if( (ie->length >= 1) && |
| 254 |
(ie->length < OO_MAX_NUMBER_LENGTH) ) |
| 255 |
{ |
| 256 |
memcpy(number, ie->data+1,ie->length-1); |
| 257 |
number[ie->length-1]='\0'; |
| 258 |
OOTRACEDBGB2(" %s\n", number); |
| 259 |
if(!call->calledPartyNumber) |
| 260 |
ooCallSetCalledPartyNumber(call, number); |
| 261 |
} |
| 262 |
else{ |
| 263 |
OOTRACEERR3("Error:Calling party number outside range. (%s, %s)\n", |
| 264 |
call->callType, call->callToken); |
| 265 |
} |
| 266 |
OOTRACEDBGB1(" }\n"); |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
if(ie->discriminator == Q931CauseIE) |
| 271 |
{ |
| 272 |
msg->causeIE = ie; |
| 273 |
OOTRACEDBGB1(" Cause IE = {\n"); |
| 274 |
OOTRACEDBGB2(" %s\n", ooGetQ931CauseValueText(ie->data[1]&0x7f)); |
| 275 |
OOTRACEDBGB1(" }\n"); |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
if(ie->discriminator == Q931CallStateIE) |
| 280 |
{ |
| 281 |
msg->causeIE = ie; |
| 282 |
OOTRACEDBGB1(" CallState IE = {\n"); |
| 283 |
OOTRACEDBGB2(" %d\n", ie->data[0]); |
| 284 |
OOTRACEDBGB1(" }\n"); |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
dListAppend (pctxt, &msg->ies, ie); |
| 289 |
if (rv != ASN_OK) |
| 290 |
return rv; |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
if(msg->messageType != Q931NotifyMsg && msg->messageType != Q931StatusMsg) |
| 297 |
rv = ooDecodeUUIE(pctxt, msg); |
| 298 |
return rv; |
| 299 |
} |
| 300 |
|
| 301 |
EXTERN Q931InformationElement* ooQ931GetIE (const Q931Message* q931msg, |
| 302 |
int ieCode) |
| 303 |
{ |
| 304 |
DListNode* curNode; |
| 305 |
unsigned int i; |
| 306 |
|
| 307 |
for(i = 0, curNode = q931msg->ies.head; i < q931msg->ies.count; i++) { |
| 308 |
Q931InformationElement *ie = (Q931InformationElement*) curNode->data; |
| 309 |
if (ie->discriminator == ieCode) { |
| 310 |
return ie; |
| 311 |
} |
| 312 |
curNode = curNode->next; |
| 313 |
} |
| 314 |
return NULL; |
| 315 |
} |
| 316 |
|
| 317 |
char* ooQ931GetMessageTypeName(int messageType, char* buf) { |
| 318 |
switch (messageType) { |
| 319 |
case Q931AlertingMsg : |
| 320 |
strcpy(buf, "Alerting"); |
| 321 |
break; |
| 322 |
case Q931CallProceedingMsg : |
| 323 |
strcpy(buf, "CallProceeding"); |
| 324 |
break; |
| 325 |
case Q931ConnectMsg : |
| 326 |
strcpy(buf, "Connect"); |
| 327 |
break; |
| 328 |
case Q931ConnectAckMsg : |
| 329 |
strcpy(buf, "ConnectAck"); |
| 330 |
break; |
| 331 |
case Q931ProgressMsg : |
| 332 |
strcpy(buf, "Progress"); |
| 333 |
break; |
| 334 |
case Q931SetupMsg : |
| 335 |
strcpy(buf, "Setup"); |
| 336 |
break; |
| 337 |
case Q931SetupAckMsg : |
| 338 |
strcpy(buf, "SetupAck"); |
| 339 |
break; |
| 340 |
case Q931FacilityMsg : |
| 341 |
strcpy(buf, "Facility"); |
| 342 |
break; |
| 343 |
case Q931ReleaseCompleteMsg : |
| 344 |
strcpy(buf, "ReleaseComplete"); |
| 345 |
break; |
| 346 |
case Q931StatusEnquiryMsg : |
| 347 |
strcpy(buf, "StatusEnquiry"); |
| 348 |
break; |
| 349 |
case Q931StatusMsg : |
| 350 |
strcpy(buf, "Status"); |
| 351 |
break; |
| 352 |
case Q931InformationMsg : |
| 353 |
strcpy(buf, "Information"); |
| 354 |
break; |
| 355 |
case Q931NationalEscapeMsg : |
| 356 |
strcpy(buf, "Escape"); |
| 357 |
break; |
| 358 |
default: |
| 359 |
sprintf(buf, "<%d>", messageType); |
| 360 |
} |
| 361 |
return buf; |
| 362 |
} |
| 363 |
|
| 364 |
char* ooQ931GetIEName(int number, char* buf) { |
| 365 |
switch (number) { |
| 366 |
case Q931BearerCapabilityIE : |
| 367 |
strcpy(buf, "Bearer-Capability"); |
| 368 |
break; |
| 369 |
case Q931CauseIE : |
| 370 |
strcpy(buf, "Cause"); |
| 371 |
break; |
| 372 |
case Q931FacilityIE : |
| 373 |
strcpy(buf, "Facility"); |
| 374 |
break; |
| 375 |
case Q931ProgressIndicatorIE : |
| 376 |
strcpy(buf, "Progress-Indicator"); |
| 377 |
break; |
| 378 |
case Q931CallStateIE : |
| 379 |
strcpy(buf, "Call-State"); |
| 380 |
break; |
| 381 |
case Q931DisplayIE : |
| 382 |
strcpy(buf, "Display"); |
| 383 |
break; |
| 384 |
case Q931SignalIE : |
| 385 |
strcpy(buf, "Signal"); |
| 386 |
break; |
| 387 |
case Q931CallingPartyNumberIE : |
| 388 |
strcpy(buf, "Calling-Party-Number"); |
| 389 |
break; |
| 390 |
case Q931CalledPartyNumberIE : |
| 391 |
strcpy(buf, "Called-Party-Number"); |
| 392 |
break; |
| 393 |
case Q931RedirectingNumberIE : |
| 394 |
strcpy(buf, "Redirecting-Number"); |
| 395 |
break; |
| 396 |
case Q931UserUserIE : |
| 397 |
strcpy(buf, "User-User"); |
| 398 |
break; |
| 399 |
default: |
| 400 |
sprintf(buf, "0x%02x", (unsigned)number); |
| 401 |
} |
| 402 |
return buf; |
| 403 |
} |
| 404 |
|
| 405 |
EXTERN void ooQ931Print (const Q931Message* q931msg) { |
| 406 |
char buf[1000]; |
| 407 |
DListNode* curNode; |
| 408 |
unsigned int i; |
| 409 |
|
| 410 |
printf("Q.931 Message:\n"); |
| 411 |
printf(" protocolDiscriminator: %u\n", q931msg->protocolDiscriminator); |
| 412 |
printf(" callReference: %u\n", q931msg->callReference); |
| 413 |
printf(" from: %s\n", (q931msg->fromDestination ? |
| 414 |
"destination" : "originator")); |
| 415 |
printf(" messageType: %s (0x%X)\n\n", |
| 416 |
ooQ931GetMessageTypeName(q931msg->messageType, buf), |
| 417 |
q931msg->messageType); |
| 418 |
|
| 419 |
for(i = 0, curNode = q931msg->ies.head; i < q931msg->ies.count; i++) { |
| 420 |
Q931InformationElement *ie = (Q931InformationElement*) curNode->data; |
| 421 |
int length = (ie->length >= 0) ? ie->length : -ie->length; |
| 422 |
printf(" IE[%u] (offset 0x%X):\n", i, (unsigned)ie->offset); |
| 423 |
printf(" discriminator: %s (0x%X)\n", |
| 424 |
ooQ931GetIEName(ie->discriminator, buf), (unsigned)ie->discriminator); |
| 425 |
printf(" data length: %i\n", length); |
| 426 |
|
| 427 |
curNode = curNode->next; |
| 428 |
printf("\n"); |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
int ooCreateQ931Message(OOCTXT* pctxt, Q931Message **q931msg, int msgType) |
| 433 |
{ |
| 434 |
|
| 435 |
|
| 436 |
*q931msg = (Q931Message*)memAllocZ(pctxt, sizeof(Q931Message)); |
| 437 |
|
| 438 |
if(!*q931msg) |
| 439 |
{ |
| 440 |
OOTRACEERR1("Error:Memory - ooCreateQ931Message - q931msg\n"); |
| 441 |
return OO_FAILED; |
| 442 |
} |
| 443 |
else |
| 444 |
{ |
| 445 |
(*q931msg)->protocolDiscriminator = 8; |
| 446 |
(*q931msg)->fromDestination = FALSE; |
| 447 |
(*q931msg)->messageType = msgType; |
| 448 |
(*q931msg)->tunneledMsgType = msgType; |
| 449 |
(*q931msg)->logicalChannelNo = 0; |
| 450 |
(*q931msg)->bearerCapabilityIE = NULL; |
| 451 |
(*q931msg)->callingPartyNumberIE = NULL; |
| 452 |
(*q931msg)->calledPartyNumberIE = NULL; |
| 453 |
(*q931msg)->causeIE = NULL; |
| 454 |
(*q931msg)->callstateIE = NULL; |
| 455 |
return OO_OK; |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
int ooGenerateCallToken (char *callToken, size_t size) |
| 461 |
{ |
| 462 |
static int counter = 1; |
| 463 |
char aCallToken[200]; |
| 464 |
int ret = 0; |
| 465 |
|
| 466 |
ast_mutex_lock(&newCallLock); |
| 467 |
sprintf (aCallToken, "ooh323c_%d", counter++); |
| 468 |
|
| 469 |
if (counter > OO_MAX_CALL_TOKEN) |
| 470 |
counter = 1; |
| 471 |
ast_mutex_unlock(&newCallLock); |
| 472 |
|
| 473 |
if ((strlen(aCallToken)+1) < size) |
| 474 |
strcpy (callToken, aCallToken); |
| 475 |
else { |
| 476 |
OOTRACEERR1 ("Error: Insufficient buffer size to generate call token"); |
| 477 |
ret = OO_FAILED; |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
return ret; |
| 482 |
} |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
ASN1USINT ooGenerateCallReference() |
| 490 |
{ |
| 491 |
static ASN1USINT lastCallRef=0; |
| 492 |
ASN1USINT newCallRef=0; |
| 493 |
|
| 494 |
|
| 495 |
if(lastCallRef == 0) |
| 496 |
{ |
| 497 |
|
| 498 |
srand((unsigned)time(0)); |
| 499 |
lastCallRef = (ASN1USINT)(rand()%100); |
| 500 |
} |
| 501 |
else |
| 502 |
lastCallRef++; |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
if(lastCallRef>=32766) |
| 508 |
lastCallRef=1; |
| 509 |
|
| 510 |
newCallRef = lastCallRef; |
| 511 |
|
| 512 |
|
| 513 |
OOTRACEDBGC2("Generated callRef %d\n", newCallRef); |
| 514 |
return newCallRef; |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
int ooGenerateCallIdentifier(H225CallIdentifier *callid) |
| 519 |
{ |
| 520 |
ASN1INT64 timestamp; |
| 521 |
int i=0; |
| 522 |
#ifdef _WIN32 |
| 523 |
|
| 524 |
SYSTEMTIME systemTime; |
| 525 |
GetLocalTime(&systemTime); |
| 526 |
SystemTimeToFileTime(&systemTime, (LPFILETIME)×tamp); |
| 527 |
#else |
| 528 |
struct timeval systemTime; |
| 529 |
gettimeofday(&systemTime, NULL); |
| 530 |
timestamp = systemTime.tv_sec * 10000000 + systemTime.tv_usec*10; |
| 531 |
#endif |
| 532 |
|
| 533 |
callid->guid.numocts = 16; |
| 534 |
callid->guid.data[0] = 'o'; |
| 535 |
callid->guid.data[1] = 'o'; |
| 536 |
callid->guid.data[2] = 'h'; |
| 537 |
callid->guid.data[3] = '3'; |
| 538 |
callid->guid.data[4] = '2'; |
| 539 |
callid->guid.data[5] = '3'; |
| 540 |
callid->guid.data[6] = 'c'; |
| 541 |
callid->guid.data[7] = '-'; |
| 542 |
|
| 543 |
for (i = 8; i < 16; i++) |
| 544 |
callid->guid.data[i] = (ASN1OCTET)((timestamp>>((i-8+1)*8))&0xff); |
| 545 |
|
| 546 |
return OO_OK; |
| 547 |
|
| 548 |
} |
| 549 |
|
| 550 |
int ooFreeQ931Message(OOCTXT* pctxt, Q931Message *q931Msg) |
| 551 |
{ |
| 552 |
if(!q931Msg) |
| 553 |
{ |
| 554 |
|
| 555 |
memReset(pctxt); |
| 556 |
} |
| 557 |
return OO_OK; |
| 558 |
} |
| 559 |
|
| 560 |
int ooEncodeUUIE(OOCTXT* pctxt, Q931Message *q931msg) |
| 561 |
{ |
| 562 |
ASN1OCTET msgbuf[ASN_K_ENCBUFSIZ]; |
| 563 |
ASN1OCTET * msgptr=NULL; |
| 564 |
int len; |
| 565 |
ASN1BOOL aligned = TRUE; |
| 566 |
Q931InformationElement* ie=NULL; |
| 567 |
|
| 568 |
memset(msgbuf, 0, sizeof(msgbuf)); |
| 569 |
if(!q931msg) |
| 570 |
{ |
| 571 |
OOTRACEERR1("ERROR: Invalid Q931 message in add user-user IE\n"); |
| 572 |
return OO_FAILED; |
| 573 |
} |
| 574 |
|
| 575 |
if(!q931msg->userInfo) |
| 576 |
{ |
| 577 |
OOTRACEERR1("ERROR: No User-User IE to encode\n"); |
| 578 |
return OO_FAILED; |
| 579 |
} |
| 580 |
|
| 581 |
setPERBuffer(pctxt, msgbuf, sizeof(msgbuf), aligned); |
| 582 |
|
| 583 |
if(asn1PE_H225H323_UserInformation (pctxt, |
| 584 |
q931msg->userInfo)==ASN_OK) |
| 585 |
{ |
| 586 |
OOTRACEDBGC1("UserInfo encoding - successful\n"); |
| 587 |
} |
| 588 |
else{ |
| 589 |
OOTRACEERR1("ERROR: UserInfo encoding failed\n"); |
| 590 |
return OO_FAILED; |
| 591 |
} |
| 592 |
msgptr = encodeGetMsgPtr(pctxt, &len); |
| 593 |
|
| 594 |
|
| 595 |
ie = (Q931InformationElement*)memAlloc (pctxt, |
| 596 |
sizeof(*ie) - sizeof(ie->data) + len); |
| 597 |
if(ie == NULL) |
| 598 |
{ |
| 599 |
OOTRACEERR1("Error: Memory - ooEncodeUUIE - ie\n"); |
| 600 |
return OO_FAILED; |
| 601 |
} |
| 602 |
ie->discriminator = Q931UserUserIE; |
| 603 |
ie->length = len; |
| 604 |
memcpy(ie->data, msgptr, len); |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
dListInit (&(q931msg->ies)); |
| 609 |
if((dListAppend (pctxt, |
| 610 |
&(q931msg->ies), ie)) == NULL) |
| 611 |
{ |
| 612 |
OOTRACEERR1("Error: Failed to add UUIE in outgoing message\n"); |
| 613 |
return OO_FAILED; |
| 614 |
} |
| 615 |
|
| 616 |
return OO_OK; |
| 617 |
} |
| 618 |
|
| 619 |
int ooDecodeUUIE(OOCTXT* pctxt, Q931Message *q931Msg) |
| 620 |
{ |
| 621 |
DListNode* curNode; |
| 622 |
unsigned int i; |
| 623 |
ASN1BOOL aligned=TRUE; |
| 624 |
int stat; |
| 625 |
Q931InformationElement *ie=NULL; |
| 626 |
|
| 627 |
if(q931Msg ==NULL) |
| 628 |
{ |
| 629 |
OOTRACEERR1("Error: ooDecodeUUIE failed - NULL q931 message\n"); |
| 630 |
return OO_FAILED; |
| 631 |
} |
| 632 |
|
| 633 |
|
| 634 |
for(i = 0, curNode = q931Msg->ies.head; i < q931Msg->ies.count; |
| 635 |
i++, curNode = curNode->next) |
| 636 |
{ |
| 637 |
ie = (Q931InformationElement*) curNode->data; |
| 638 |
if(ie && ie->discriminator == Q931UserUserIE) |
| 639 |
break; |
| 640 |
} |
| 641 |
if(i == q931Msg->ies.count) |
| 642 |
{ |
| 643 |
OOTRACEERR1("No UserUser IE found in ooDecodeUUIE\n"); |
| 644 |
return OO_FAILED; |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
q931Msg->userInfo = (H225H323_UserInformation *) memAlloc(pctxt, |
| 649 |
sizeof(H225H323_UserInformation)); |
| 650 |
if(!q931Msg->userInfo) |
| 651 |
{ |
| 652 |
OOTRACEERR1("ERROR:Memory - ooDecodeUUIE - userInfo\n"); |
| 653 |
return OO_FAILED; |
| 654 |
} |
| 655 |
memset(q931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 656 |
|
| 657 |
setPERBuffer (pctxt, ie->data, ie->length, aligned); |
| 658 |
|
| 659 |
stat = asn1PD_H225H323_UserInformation (pctxt, q931Msg->userInfo); |
| 660 |
if(stat != ASN_OK) |
| 661 |
{ |
| 662 |
OOTRACEERR1("Error: UserUser IE decode failed\n"); |
| 663 |
return OO_FAILED; |
| 664 |
} |
| 665 |
OOTRACEDBGC1("UUIE decode successful\n"); |
| 666 |
return OO_OK; |
| 667 |
} |
| 668 |
|
| 669 |
#ifndef _COMPACT |
| 670 |
static void ooQ931PrintMessage |
| 671 |
(OOH323CallData* call, ASN1OCTET *msgbuf, ASN1UINT msglen) |
| 672 |
{ |
| 673 |
|
| 674 |
|
| 675 |
OOCTXT *pctxt = call->msgctxt; |
| 676 |
Q931Message q931Msg; |
| 677 |
int ret; |
| 678 |
|
| 679 |
initializePrintHandler(&printHandler, "Q931 Message"); |
| 680 |
|
| 681 |
|
| 682 |
setEventHandler (pctxt, &printHandler); |
| 683 |
|
| 684 |
setPERBuffer (pctxt, msgbuf, msglen, TRUE); |
| 685 |
|
| 686 |
ret = ooQ931Decode (call, &q931Msg, msglen, msgbuf, 0); |
| 687 |
if(ret != OO_OK) |
| 688 |
{ |
| 689 |
OOTRACEERR3("Error:Failed decoding Q931 message. (%s, %s)\n", |
| 690 |
call->callType, call->callToken); |
| 691 |
} |
| 692 |
finishPrint(); |
| 693 |
removeEventHandler(pctxt); |
| 694 |
|
| 695 |
} |
| 696 |
#endif |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
int ooEncodeH225Message(OOH323CallData *call, Q931Message *pq931Msg, |
| 701 |
char *msgbuf, int size) |
| 702 |
{ |
| 703 |
int len=0, i=0, j=0, ieLen=0; |
| 704 |
int stat=0; |
| 705 |
DListNode* curNode=NULL; |
| 706 |
|
| 707 |
if(!msgbuf || size<200) |
| 708 |
{ |
| 709 |
OOTRACEERR3("Error: Invalid message buffer/size for ooEncodeH245Message." |
| 710 |
" (%s, %s)\n", call->callType, call->callToken); |
| 711 |
return OO_FAILED; |
| 712 |
} |
| 713 |
|
| 714 |
if(pq931Msg->messageType == Q931SetupMsg){ |
| 715 |
msgbuf[i++] = OOSetup; |
| 716 |
} |
| 717 |
else if(pq931Msg->messageType == Q931ConnectMsg){ |
| 718 |
msgbuf[i++] = OOConnect; |
| 719 |
} |
| 720 |
else if(pq931Msg->messageType == Q931CallProceedingMsg){ |
| 721 |
msgbuf[i++] = OOCallProceeding; |
| 722 |
} |
| 723 |
else if(pq931Msg->messageType == Q931AlertingMsg || |
| 724 |
pq931Msg->messageType == Q931ProgressMsg){ |
| 725 |
msgbuf[i++] = OOAlert; |
| 726 |
} |
| 727 |
else if(pq931Msg->messageType == Q931ReleaseCompleteMsg){ |
| 728 |
msgbuf[i++] = OOReleaseComplete; |
| 729 |
} |
| 730 |
else if(pq931Msg->messageType == Q931InformationMsg){ |
| 731 |
msgbuf[i++] = OOInformationMessage; |
| 732 |
} |
| 733 |
else if(pq931Msg->messageType == Q931StatusMsg || |
| 734 |
pq931Msg->messageType == Q931StatusEnquiryMsg){ |
| 735 |
msgbuf[i++] = OOStatus; |
| 736 |
} |
| 737 |
else if(pq931Msg->messageType == Q931FacilityMsg){ |
| 738 |
msgbuf[i++] = OOFacility; |
| 739 |
msgbuf[i++] = pq931Msg->tunneledMsgType; |
| 740 |
msgbuf[i++] = pq931Msg->logicalChannelNo>>8; |
| 741 |
msgbuf[i++] = pq931Msg->logicalChannelNo; |
| 742 |
} |
| 743 |
else{ |
| 744 |
OOTRACEERR3("Error:Unknow Q931 message type. (%s, %s)\n", call->callType, |
| 745 |
call->callToken); |
| 746 |
return OO_FAILED; |
| 747 |
} |
| 748 |
|
| 749 |
stat = ooEncodeUUIE(call->msgctxt, pq931Msg); |
| 750 |
if(stat != OO_OK) |
| 751 |
{ |
| 752 |
OOTRACEERR3("Error:Failed to encode uuie. (%s, %s)\n", call->callType, |
| 753 |
call->callToken); |
| 754 |
return OO_FAILED; |
| 755 |
} |
| 756 |
|
| 757 |
msgbuf[i++] = 3; |
| 758 |
msgbuf[i++] = 0; |
| 759 |
|
| 760 |
msgbuf[i++] = 0; |
| 761 |
|
| 762 |
msgbuf[i++] = 0; |
| 763 |
|
| 764 |
msgbuf[i++] = pq931Msg->protocolDiscriminator; |
| 765 |
msgbuf[i++] = 2; |
| 766 |
msgbuf[i] = (pq931Msg->callReference >> 8); |
| 767 |
if(!strcmp(call->callType, "incoming")) |
| 768 |
msgbuf[i++] |= 0x80; |
| 769 |
else |
| 770 |
i++; |
| 771 |
|
| 772 |
|
| 773 |
msgbuf[i++] = pq931Msg->callReference; |
| 774 |
msgbuf[i++] = pq931Msg->messageType; |
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
if(pq931Msg->bearerCapabilityIE) |
| 781 |
{ |
| 782 |
msgbuf[i++] = Q931BearerCapabilityIE; |
| 783 |
msgbuf[i++] = pq931Msg->bearerCapabilityIE->length; |
| 784 |
memcpy(msgbuf+i, pq931Msg->bearerCapabilityIE->data, |
| 785 |
pq931Msg->bearerCapabilityIE->length); |
| 786 |
i += pq931Msg->bearerCapabilityIE->length; |
| 787 |
} |
| 788 |
|
| 789 |
|
| 790 |
if(pq931Msg->causeIE) |
| 791 |
{ |
| 792 |
msgbuf[i++] = Q931CauseIE; |
| 793 |
msgbuf[i++] = pq931Msg->causeIE->length; |
| 794 |
memcpy(msgbuf+i, pq931Msg->causeIE->data, pq931Msg->causeIE->length); |
| 795 |
i += pq931Msg->causeIE->length; |
| 796 |
} |
| 797 |
|
| 798 |
|
| 799 |
if(pq931Msg->messageType == Q931AlertingMsg || pq931Msg->messageType == Q931ProgressMsg) |
| 800 |
{ |
| 801 |
msgbuf[i++] = Q931ProgressIndicatorIE; |
| 802 |
msgbuf[i++] = 2; |
| 803 |
msgbuf[i++] = 0x80; |
| 804 |
msgbuf[i++] = 0x88; |
| 805 |
} |
| 806 |
|
| 807 |
|
| 808 |
if(!ooUtilsIsStrEmpty(call->ourCallerId) && (pq931Msg->messageType != Q931StatusMsg)) |
| 809 |
{ |
| 810 |
msgbuf[i++] = Q931DisplayIE; |
| 811 |
ieLen = strlen(call->ourCallerId)+1; |
| 812 |
msgbuf[i++] = ieLen; |
| 813 |
memcpy(msgbuf+i, call->ourCallerId, ieLen-1); |
| 814 |
i += ieLen-1; |
| 815 |
msgbuf[i++] = '\0'; |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
if(pq931Msg->callingPartyNumberIE) |
| 820 |
{ |
| 821 |
msgbuf[i++] = Q931CallingPartyNumberIE; |
| 822 |
msgbuf[i++] = pq931Msg->callingPartyNumberIE->length; |
| 823 |
memcpy(msgbuf+i, pq931Msg->callingPartyNumberIE->data, |
| 824 |
pq931Msg->callingPartyNumberIE->length); |
| 825 |
i += pq931Msg->callingPartyNumberIE->length; |
| 826 |
} |
| 827 |
|
| 828 |
|
| 829 |
if(pq931Msg->calledPartyNumberIE) |
| 830 |
{ |
| 831 |
msgbuf[i++] = Q931CalledPartyNumberIE; |
| 832 |
msgbuf[i++] = pq931Msg->calledPartyNumberIE->length; |
| 833 |
memcpy(msgbuf+i, pq931Msg->calledPartyNumberIE->data, |
| 834 |
pq931Msg->calledPartyNumberIE->length); |
| 835 |
i += pq931Msg->calledPartyNumberIE->length; |
| 836 |
} |
| 837 |
|
| 838 |
|
| 839 |
if(pq931Msg->keypadIE) |
| 840 |
{ |
| 841 |
msgbuf[i++] = Q931KeypadIE; |
| 842 |
msgbuf[i++] = pq931Msg->keypadIE->length; |
| 843 |
memcpy(msgbuf+i, pq931Msg->keypadIE->data, pq931Msg->keypadIE->length); |
| 844 |
i += pq931Msg->keypadIE->length; |
| 845 |
} |
| 846 |
|
| 847 |
if(pq931Msg->callstateIE) { |
| 848 |
msgbuf[i++] = Q931CallStateIE; |
| 849 |
msgbuf[i++] = pq931Msg->callstateIE->length; |
| 850 |
memcpy(msgbuf+i, pq931Msg->callstateIE->data, pq931Msg->callstateIE->length); |
| 851 |
i += pq931Msg->callstateIE->length; |
| 852 |
} |
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
for(j = 0, curNode = pq931Msg->ies.head; j < (int)pq931Msg->ies.count; j++) |
| 859 |
{ |
| 860 |
Q931InformationElement *ie = (Q931InformationElement*) curNode->data; |
| 861 |
|
| 862 |
ieLen = ie->length; |
| 863 |
|
| 864 |
|
| 865 |
msgbuf[i++] = ie->discriminator; |
| 866 |
|
| 867 |
|
| 868 |
if (ie->discriminator == Q931UserUserIE) |
| 869 |
{ |
| 870 |
ieLen++; |
| 871 |
msgbuf[i++] = (ieLen>>8); |
| 872 |
msgbuf[i++] = ieLen; |
| 873 |
ieLen--; |
| 874 |
msgbuf[i++] = 5; |
| 875 |
memcpy((msgbuf + i), ie->data, ieLen); |
| 876 |
|
| 877 |
i += ieLen; |
| 878 |
|
| 879 |
} |
| 880 |
else |
| 881 |
{ |
| 882 |
OOTRACEWARN1("Warning: Only UUIE is supported currently\n"); |
| 883 |
return OO_FAILED; |
| 884 |
} |
| 885 |
} |
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
if(msgbuf[0] != OOFacility) |
| 891 |
{ |
| 892 |
len = i-1; |
| 893 |
msgbuf[3] = (len >> 8); |
| 894 |
msgbuf[4] = len; |
| 895 |
} |
| 896 |
else{ |
| 897 |
len = i-4; |
| 898 |
msgbuf[6] = (len >> 8); |
| 899 |
msgbuf[7] = len; |
| 900 |
} |
| 901 |
|
| 902 |
#ifndef _COMPACT |
| 903 |
if(msgbuf[0] != OOFacility) |
| 904 |
ooQ931PrintMessage (call, (unsigned char *)msgbuf+5, len-4); |
| 905 |
else |
| 906 |
ooQ931PrintMessage (call, (unsigned char *)msgbuf+8, len-4); |
| 907 |
#endif |
| 908 |
return OO_OK; |
| 909 |
} |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
int ooHandleFastStartChannels(OOH323CallData *pCall) |
| 914 |
{ |
| 915 |
int i = 0, remoteMediaControlPort = 0, dir = 0; |
| 916 |
char remoteMediaControlIP[2 + 8 * 4 + 7]; |
| 917 |
DListNode *pNode = NULL; |
| 918 |
H245OpenLogicalChannel *olc = NULL; |
| 919 |
ooH323EpCapability *epCap = NULL; |
| 920 |
H245H2250LogicalChannelParameters *h2250lcp = NULL; |
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
if (OO_TESTFLAG(pCall->flags, OO_M_FASTSTART) && |
| 925 |
pCall->remoteFastStartOLCs.count>0) { |
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
for (i = 0; i < (int)pCall->remoteFastStartOLCs.count; i++) { |
| 930 |
|
| 931 |
pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i); |
| 932 |
olc = (H245OpenLogicalChannel*)pNode->data; |
| 933 |
|
| 934 |
|
| 935 |
if (olc->forwardLogicalChannelParameters.dataType.t != |
| 936 |
T_H245DataType_nullData && |
| 937 |
olc->m.reverseLogicalChannelParametersPresent) { |
| 938 |
continue; |
| 939 |
} |
| 940 |
|
| 941 |
|
| 942 |
if (olc->forwardLogicalChannelParameters.dataType.t != |
| 943 |
T_H245DataType_nullData) { |
| 944 |
|
| 945 |
OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n", |
| 946 |
olc->forwardLogicalChannelNumber, pCall->callType, |
| 947 |
pCall->callToken); |
| 948 |
dir = OORX; |
| 949 |
epCap = ooIsDataTypeSupported(pCall, |
| 950 |
&olc->forwardLogicalChannelParameters.dataType, |
| 951 |
OORX); |
| 952 |
|
| 953 |
if (!epCap) { |
| 954 |
continue; |
| 955 |
} |
| 956 |
|
| 957 |
OOTRACEINFO1("Receive Channel data type supported\n"); |
| 958 |
if (olc->forwardLogicalChannelParameters.multiplexParameters.t != |
| 959 |
T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { |
| 960 |
OOTRACEERR4("ERROR:Unknown multiplex parameter type for " |
| 961 |
"channel %d (%s, %s)\n", |
| 962 |
olc->forwardLogicalChannelNumber, |
| 963 |
pCall->callType, pCall->callToken); |
| 964 |
memFreePtr(pCall->pctxt, epCap); |
| 965 |
epCap = NULL; |
| 966 |
continue; |
| 967 |
} |
| 968 |
h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; |
| 969 |
|
| 970 |
|
| 971 |
if (ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive")) { |
| 972 |
|
| 973 |
OOTRACEINFO4("Receive channel with sessionID %d already " |
| 974 |
"established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, |
| 975 |
pCall->callType, pCall->callToken); |
| 976 |
memFreePtr(pCall->pctxt, epCap); |
| 977 |
epCap = NULL; |
| 978 |
continue; |
| 979 |
} |
| 980 |
|
| 981 |
|
| 982 |
if (h2250lcp->m.mediaControlChannelPresent) { |
| 983 |
if (OO_OK != ooGetIpPortFromH245TransportAddress(pCall, |
| 984 |
&h2250lcp->mediaControlChannel, |
| 985 |
remoteMediaControlIP, &remoteMediaControlPort)) { |
| 986 |
OOTRACEERR3("Error: Invalid media control channel address " |
| 987 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 988 |
memFreePtr(pCall->pctxt, epCap); |
| 989 |
epCap = NULL; |
| 990 |
continue; |
| 991 |
} |
| 992 |
} else { |
| 993 |
continue; |
| 994 |
} |
| 995 |
} else { |
| 996 |
|
| 997 |
continue; |
| 998 |
} |
| 999 |
|
| 1000 |
if (dir & OORX) { |
| 1001 |
remoteMediaControlPort--; |
| 1002 |
if (gH323ep.h323Callbacks.onMediaChanged && |
| 1003 |
pCall->callState < OO_CALL_CLEAR) { |
| 1004 |
gH323ep.h323Callbacks.onMediaChanged(pCall, remoteMediaControlIP, |
| 1005 |
remoteMediaControlPort); |
| 1006 |
} |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
} |
| 1011 |
|
| 1012 |
} |
| 1013 |
return ASN_OK; |
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg, |
| 1018 |
ASN1UINT *fsCount, ASN1DynOctStr **fsElem) |
| 1019 |
{ |
| 1020 |
|
| 1021 |
OOCTXT *pctxt = pCall->msgctxt; |
| 1022 |
int ret = 0, i=0, j=0, remoteMediaPort=0, remoteMediaControlPort = 0, dir=0; |
| 1023 |
char remoteMediaIP[2+8*4+7], remoteMediaControlIP[2+8*4+7]; |
| 1024 |
DListNode *pNode = NULL; |
| 1025 |
H245OpenLogicalChannel *olc = NULL, printOlc; |
| 1026 |
ooH323EpCapability *epCap = NULL; |
| 1027 |
ASN1DynOctStr *pFS=NULL; |
| 1028 |
H245H2250LogicalChannelParameters *h2250lcp = NULL; |
| 1029 |
ooLogicalChannel* pChannel; |
| 1030 |
|
| 1031 |
|
| 1032 |
if(pCall->pFastStartRes) { |
| 1033 |
ASN1UINT k = 0; |
| 1034 |
ASN1OCTET* pData; |
| 1035 |
|
| 1036 |
|
| 1037 |
*fsCount = pCall->pFastStartRes->n; |
| 1038 |
*fsElem = (ASN1DynOctStr*) |
| 1039 |
memAlloc(pctxt, pCall->pFastStartRes->n * sizeof(ASN1DynOctStr)); |
| 1040 |
|
| 1041 |
for(k = 0; k < pCall->pFastStartRes->n; k ++) { |
| 1042 |
(*fsElem)[k].numocts = pCall->pFastStartRes->elem[k].numocts; |
| 1043 |
pData = (ASN1OCTET*) memAlloc( |
| 1044 |
pctxt, (*fsElem)[k].numocts * sizeof(ASN1OCTET)); |
| 1045 |
memcpy(pData, |
| 1046 |
pCall->pFastStartRes->elem[k].data, |
| 1047 |
pCall->pFastStartRes->elem[k].numocts); |
| 1048 |
(*fsElem)[k].data = pData; |
| 1049 |
} |
| 1050 |
|
| 1051 |
return ASN_OK; |
| 1052 |
} |
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
if(OO_TESTFLAG(pCall->flags, OO_M_FASTSTART) && |
| 1057 |
pCall->remoteFastStartOLCs.count>0) |
| 1058 |
{ |
| 1059 |
pFS = (ASN1DynOctStr*)memAlloc(pctxt, |
| 1060 |
pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr)); |
| 1061 |
if(!pFS) |
| 1062 |
{ |
| 1063 |
OOTRACEERR3("Error:Memory - ooSetFastStartResponse - pFS (%s, %s)\n", |
| 1064 |
pCall->callType, pCall->callToken); |
| 1065 |
return OO_FAILED; |
| 1066 |
} |
| 1067 |
memset(pFS, 0, pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr)); |
| 1068 |
|
| 1069 |
|
| 1070 |
for(i=0, j=0; i<(int)pCall->remoteFastStartOLCs.count; i++) |
| 1071 |
{ |
| 1072 |
|
| 1073 |
pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i); |
| 1074 |
olc = (H245OpenLogicalChannel*)pNode->data; |
| 1075 |
|
| 1076 |
|
| 1077 |
if(olc->forwardLogicalChannelParameters.dataType.t != |
| 1078 |
T_H245DataType_nullData && |
| 1079 |
olc->m.reverseLogicalChannelParametersPresent) |
| 1080 |
{ |
| 1081 |
OOTRACEINFO3("Ignoring bidirectional OLC as it is not supported." |
| 1082 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1083 |
continue; |
| 1084 |
} |
| 1085 |
|
| 1086 |
|
| 1087 |
if(olc->forwardLogicalChannelParameters.dataType.t != |
| 1088 |
T_H245DataType_nullData) |
| 1089 |
{ |
| 1090 |
|
| 1091 |
OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n", |
| 1092 |
olc->forwardLogicalChannelNumber, pCall->callType, |
| 1093 |
pCall->callToken); |
| 1094 |
dir = OORX; |
| 1095 |
epCap = ooIsDataTypeSupported(pCall, |
| 1096 |
&olc->forwardLogicalChannelParameters.dataType, |
| 1097 |
OORX); |
| 1098 |
|
| 1099 |
if(!epCap) { continue; } |
| 1100 |
|
| 1101 |
OOTRACEINFO1("Receive Channel data type supported\n"); |
| 1102 |
if(olc->forwardLogicalChannelParameters.multiplexParameters.t != |
| 1103 |
T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) |
| 1104 |
{ |
| 1105 |
OOTRACEERR4("ERROR:Unknown multiplex parameter type for " |
| 1106 |
"channel %d (%s, %s)\n", |
| 1107 |
olc->forwardLogicalChannelNumber, |
| 1108 |
pCall->callType, pCall->callToken); |
| 1109 |
memFreePtr(pCall->pctxt, epCap); |
| 1110 |
epCap = NULL; |
| 1111 |
continue; |
| 1112 |
} |
| 1113 |
h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; |
| 1114 |
|
| 1115 |
|
| 1116 |
if(ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive")) |
| 1117 |
{ |
| 1118 |
|
| 1119 |
OOTRACEINFO4("Receive channel with sessionID %d already " |
| 1120 |
"established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, |
| 1121 |
pCall->callType, pCall->callToken); |
| 1122 |
memFreePtr(pCall->pctxt, epCap); |
| 1123 |
epCap = NULL; |
| 1124 |
continue; |
| 1125 |
} |
| 1126 |
|
| 1127 |
|
| 1128 |
if(h2250lcp->m.mediaControlChannelPresent) |
| 1129 |
{ |
| 1130 |
if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, |
| 1131 |
&h2250lcp->mediaControlChannel, |
| 1132 |
remoteMediaControlIP, &remoteMediaControlPort)) |
| 1133 |
{ |
| 1134 |
OOTRACEERR3("Error: Invalid media control channel address " |
| 1135 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1136 |
memFreePtr(pCall->pctxt, epCap); |
| 1137 |
epCap = NULL; |
| 1138 |
continue; |
| 1139 |
} |
| 1140 |
} |
| 1141 |
} |
| 1142 |
|
| 1143 |
else if(olc->m.reverseLogicalChannelParametersPresent) |
| 1144 |
{ |
| 1145 |
|
| 1146 |
OOTRACEDBGC4("Processing received reverse olc %d (%s, %s)\n", |
| 1147 |
olc->forwardLogicalChannelNumber, pCall->callType, |
| 1148 |
pCall->callToken); |
| 1149 |
dir = OOTX; |
| 1150 |
epCap = ooIsDataTypeSupported(pCall, |
| 1151 |
&olc->reverseLogicalChannelParameters.dataType, |
| 1152 |
OOTX); |
| 1153 |
|
| 1154 |
if(!epCap) { continue; } |
| 1155 |
|
| 1156 |
OOTRACEINFO1("Transmit Channel data type supported\n"); |
| 1157 |
|
| 1158 |
if(olc->reverseLogicalChannelParameters.multiplexParameters.t != |
| 1159 |
T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) |
| 1160 |
{ |
| 1161 |
OOTRACEERR4("ERROR:Unknown multiplex parameter type for " |
| 1162 |
"channel %d (%s, %s)\n", |
| 1163 |
olc->forwardLogicalChannelNumber, |
| 1164 |
pCall->callType, pCall->callToken); |
| 1165 |
memFreePtr(pCall->pctxt, epCap); |
| 1166 |
epCap = NULL; |
| 1167 |
continue; |
| 1168 |
} |
| 1169 |
|
| 1170 |
|
| 1171 |
if(ooIsSessionEstablished(pCall, olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "transmit")) |
| 1172 |
{ |
| 1173 |
|
| 1174 |
OOTRACEINFO4("Transmit session with sessionID %d already " |
| 1175 |
"established.(%s, %s)\n", olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, pCall->callType, pCall->callToken); |
| 1176 |
|
| 1177 |
memFreePtr(pCall->pctxt, epCap); |
| 1178 |
epCap = NULL; |
| 1179 |
continue; |
| 1180 |
} |
| 1181 |
|
| 1182 |
|
| 1183 |
h2250lcp = olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; |
| 1184 |
if(!h2250lcp) |
| 1185 |
{ |
| 1186 |
OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " |
| 1187 |
"reverse Logical Channel Parameters found. " |
| 1188 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1189 |
memFreePtr(pCall->pctxt, epCap); |
| 1190 |
epCap = NULL; |
| 1191 |
return OO_FAILED; |
| 1192 |
} |
| 1193 |
|
| 1194 |
|
| 1195 |
if(!h2250lcp->m.mediaChannelPresent) |
| 1196 |
{ |
| 1197 |
OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " |
| 1198 |
"reverse media channel information found. " |
| 1199 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1200 |
memFreePtr(pCall->pctxt, epCap); |
| 1201 |
epCap = NULL; |
| 1202 |
return OO_FAILED; |
| 1203 |
} |
| 1204 |
|
| 1205 |
|
| 1206 |
if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, |
| 1207 |
&h2250lcp->mediaChannel, |
| 1208 |
remoteMediaIP, &remoteMediaPort)) |
| 1209 |
{ |
| 1210 |
OOTRACEERR3("Error: Invalid media channel address " |
| 1211 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1212 |
memFreePtr(pCall->pctxt, epCap); |
| 1213 |
epCap = NULL; |
| 1214 |
continue; |
| 1215 |
} |
| 1216 |
|
| 1217 |
|
| 1218 |
if(h2250lcp->m.mediaControlChannelPresent) |
| 1219 |
{ |
| 1220 |
if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, |
| 1221 |
&h2250lcp->mediaControlChannel, |
| 1222 |
remoteMediaControlIP, &remoteMediaControlPort)) |
| 1223 |
{ |
| 1224 |
OOTRACEERR3("Error: Invalid media control channel address " |
| 1225 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1226 |
memFreePtr(pCall->pctxt, epCap); |
| 1227 |
epCap = NULL; |
| 1228 |
continue; |
| 1229 |
} |
| 1230 |
} |
| 1231 |
} |
| 1232 |
|
| 1233 |
if(dir & OOTX) |
| 1234 |
{ |
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
olc->forwardLogicalChannelNumber = pCall->logicalChanNoCur++; |
| 1240 |
if(pCall->logicalChanNoCur > pCall->logicalChanNoMax) |
| 1241 |
pCall->logicalChanNoCur = pCall->logicalChanNoBase; |
| 1242 |
} |
| 1243 |
|
| 1244 |
|
| 1245 |
ooBuildFastStartOLC(pCall, olc, epCap, pctxt, dir); |
| 1246 |
|
| 1247 |
pChannel = ooFindLogicalChannelByLogicalChannelNo |
| 1248 |
(pCall, olc->forwardLogicalChannelNumber); |
| 1249 |
|
| 1250 |
|
| 1251 |
if(dir & OORX) |
| 1252 |
{ |
| 1253 |
strcpy(pChannel->remoteIP, remoteMediaControlIP); |
| 1254 |
pChannel->remoteMediaControlPort = remoteMediaControlPort; |
| 1255 |
if(epCap->startReceiveChannel) |
| 1256 |
{ |
| 1257 |
epCap->startReceiveChannel(pCall, pChannel); |
| 1258 |
OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n", |
| 1259 |
(epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", |
| 1260 |
pCall->callType, pCall->callToken); |
| 1261 |
} |
| 1262 |
else{ |
| 1263 |
OOTRACEERR4("ERROR:No callback registered to start receive %s" |
| 1264 |
" channel (%s, %s)\n", |
| 1265 |
(epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", |
| 1266 |
pCall->callType, pCall->callToken); |
| 1267 |
return OO_FAILED; |
| 1268 |
} |
| 1269 |
} |
| 1270 |
if(dir & OOTX) |
| 1271 |
{ |
| 1272 |
pChannel->remoteMediaPort = remoteMediaPort; |
| 1273 |
strcpy(pChannel->remoteIP, remoteMediaIP); |
| 1274 |
pChannel->remoteMediaControlPort = remoteMediaControlPort; |
| 1275 |
|
| 1276 |
if(epCap->startTransmitChannel) |
| 1277 |
{ |
| 1278 |
epCap->startTransmitChannel(pCall, pChannel); |
| 1279 |
OOTRACEINFO3("Transmit channel of type audio started " |
| 1280 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1281 |
|
| 1282 |
} |
| 1283 |
else{ |
| 1284 |
OOTRACEERR3("ERROR:No callback registered to start transmit" |
| 1285 |
" audio channel (%s, %s)\n", pCall->callType, |
| 1286 |
pCall->callToken); |
| 1287 |
return OO_FAILED; |
| 1288 |
} |
| 1289 |
} |
| 1290 |
|
| 1291 |
|
| 1292 |
setPERBuffer(pctxt, NULL, 0, 1); |
| 1293 |
if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK) |
| 1294 |
{ |
| 1295 |
OOTRACEERR3("ERROR:Encoding of olc failed for faststart " |
| 1296 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1297 |
ooFreeQ931Message(pctxt, pQ931msg); |
| 1298 |
if(pCall->callState < OO_CALL_CLEAR) |
| 1299 |
{ |
| 1300 |
pCall->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 1301 |
pCall->callState = OO_CALL_CLEAR; |
| 1302 |
} |
| 1303 |
return OO_FAILED; |
| 1304 |
} |
| 1305 |
pFS[j].data = (unsigned char *) encodeGetMsgPtr(pctxt, (int *)&(pFS[j].numocts)); |
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
setPERBuffer(pctxt, (unsigned char*)pFS[j].data, pFS[j].numocts, 1); |
| 1310 |
initializePrintHandler(&printHandler, "FastStart Element"); |
| 1311 |
setEventHandler (pctxt, &printHandler); |
| 1312 |
memset(&printOlc, 0, sizeof(printOlc)); |
| 1313 |
ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc)); |
| 1314 |
if(ret != ASN_OK) |
| 1315 |
{ |
| 1316 |
OOTRACEERR3("Error: Failed decoding FastStart Element (%s, %s)\n", |
| 1317 |
pCall->callType, pCall->callToken); |
| 1318 |
ooFreeQ931Message(pctxt, pQ931msg); |
| 1319 |
if(pCall->callState < OO_CALL_CLEAR) |
| 1320 |
{ |
| 1321 |
pCall->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 1322 |
pCall->callState = OO_CALL_CLEAR; |
| 1323 |
} |
| 1324 |
return OO_FAILED; |
| 1325 |
} |
| 1326 |
finishPrint(); |
| 1327 |
removeEventHandler(pctxt); |
| 1328 |
|
| 1329 |
|
| 1330 |
olc = NULL; |
| 1331 |
j++; |
| 1332 |
epCap = NULL; |
| 1333 |
} |
| 1334 |
OOTRACEDBGA4("Added %d fast start elements to message " |
| 1335 |
"(%s, %s)\n", j, pCall->callType, pCall->callToken); |
| 1336 |
if(j != 0) |
| 1337 |
{ |
| 1338 |
ASN1UINT k = 0; |
| 1339 |
ASN1OCTET* pData; |
| 1340 |
|
| 1341 |
*fsCount = j; |
| 1342 |
*fsElem = pFS; |
| 1343 |
|
| 1344 |
|
| 1345 |
pCall->pFastStartRes = (FastStartResponse*) |
| 1346 |
memAlloc(pCall->pctxt, sizeof(FastStartResponse)); |
| 1347 |
pCall->pFastStartRes->n = j; |
| 1348 |
pCall->pFastStartRes->elem = (ASN1DynOctStr*) memAlloc(pCall->pctxt, |
| 1349 |
pCall->pFastStartRes->n * sizeof(ASN1DynOctStr)); |
| 1350 |
|
| 1351 |
for(k = 0; k < pCall->pFastStartRes->n; k ++) { |
| 1352 |
pCall->pFastStartRes->elem[k].numocts = (*fsElem)[k].numocts; |
| 1353 |
pData = (ASN1OCTET*) memAlloc(pCall->pctxt, |
| 1354 |
pCall->pFastStartRes->elem[k].numocts * sizeof(ASN1OCTET)); |
| 1355 |
memcpy(pData, (*fsElem)[k].data, (*fsElem)[k].numocts); |
| 1356 |
pCall->pFastStartRes->elem[k].data = pData; |
| 1357 |
} |
| 1358 |
} |
| 1359 |
else{ |
| 1360 |
OOTRACEINFO3("None of the faststart elements received in setup can be" |
| 1361 |
" supported, rejecting faststart.(%s, %s)\n", |
| 1362 |
pCall->callType, pCall->callToken); |
| 1363 |
|
| 1364 |
OO_CLRFLAG(pCall->flags, OO_M_FASTSTART); |
| 1365 |
OOTRACEDBGC3("Faststart for pCall is disabled by local endpoint." |
| 1366 |
"(%s, %s)\n", pCall->callType, pCall->callToken); |
| 1367 |
} |
| 1368 |
} |
| 1369 |
return ASN_OK; |
| 1370 |
} |
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
int ooSendTCSandMSD(OOH323CallData *call) |
| 1379 |
{ |
| 1380 |
int ret; |
| 1381 |
if(call->localTermCapState == OO_LocalTermCapExchange_Idle) { |
| 1382 |
ret = ooSendTermCapMsg(call); |
| 1383 |
if(ret != OO_OK) { |
| 1384 |
OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n", |
| 1385 |
call->callType, call->callToken); |
| 1386 |
return ret; |
| 1387 |
} |
| 1388 |
} |
| 1389 |
|
| 1390 |
return OO_OK; |
| 1391 |
} |
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
int ooSendCallProceeding(OOH323CallData *call) |
| 1399 |
{ |
| 1400 |
int ret; |
| 1401 |
H225VendorIdentifier *vendor; |
| 1402 |
H225CallProceeding_UUIE *callProceeding; |
| 1403 |
Q931Message *q931msg=NULL; |
| 1404 |
|
| 1405 |
OOCTXT *pctxt = call->msgctxt; |
| 1406 |
|
| 1407 |
OOTRACEDBGC3("Building CallProceeding (%s, %s)\n", call->callType, |
| 1408 |
call->callToken); |
| 1409 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931CallProceedingMsg); |
| 1410 |
if(ret != OO_OK) |
| 1411 |
{ |
| 1412 |
OOTRACEERR1("Error: In allocating memory for - H225 Call " |
| 1413 |
"Proceeding message\n"); |
| 1414 |
return OO_FAILED; |
| 1415 |
} |
| 1416 |
|
| 1417 |
q931msg->callReference = call->callReference; |
| 1418 |
|
| 1419 |
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 1420 |
sizeof(H225H323_UserInformation)); |
| 1421 |
if(!q931msg->userInfo) |
| 1422 |
{ |
| 1423 |
OOTRACEERR1("ERROR:Memory - ooSendCallProceeding - userInfo\n"); |
| 1424 |
return OO_FAILED; |
| 1425 |
} |
| 1426 |
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 1427 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 1428 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 1429 |
OO_TESTFLAG(call->flags, OO_M_TUNNELING); |
| 1430 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 1431 |
T_H225H323_UU_PDU_h323_message_body_callProceeding; |
| 1432 |
|
| 1433 |
callProceeding = (H225CallProceeding_UUIE*)memAlloc(pctxt, |
| 1434 |
sizeof(H225CallProceeding_UUIE)); |
| 1435 |
if(!callProceeding) |
| 1436 |
{ |
| 1437 |
OOTRACEERR1("ERROR:Memory - ooSendCallProceeding - callProceeding\n"); |
| 1438 |
return OO_FAILED; |
| 1439 |
} |
| 1440 |
memset(callProceeding, 0, sizeof(H225CallProceeding_UUIE)); |
| 1441 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.callProceeding = callProceeding; |
| 1442 |
callProceeding->m.multipleCallsPresent = 1; |
| 1443 |
callProceeding->m.maintainConnectionPresent = 1; |
| 1444 |
callProceeding->multipleCalls = FALSE; |
| 1445 |
callProceeding->maintainConnection = FALSE; |
| 1446 |
|
| 1447 |
callProceeding->m.callIdentifierPresent = 1; |
| 1448 |
callProceeding->callIdentifier.guid.numocts = |
| 1449 |
call->callIdentifier.guid.numocts; |
| 1450 |
memcpy(callProceeding->callIdentifier.guid.data, |
| 1451 |
call->callIdentifier.guid.data, |
| 1452 |
call->callIdentifier.guid.numocts); |
| 1453 |
callProceeding->protocolIdentifier = gProtocolID; |
| 1454 |
|
| 1455 |
|
| 1456 |
if(gH323ep.isGateway) |
| 1457 |
callProceeding->destinationInfo.m.gatewayPresent = TRUE; |
| 1458 |
else |
| 1459 |
callProceeding->destinationInfo.m.terminalPresent = TRUE; |
| 1460 |
|
| 1461 |
callProceeding->destinationInfo.m.vendorPresent = 1; |
| 1462 |
vendor = &callProceeding->destinationInfo.vendor; |
| 1463 |
if(gH323ep.productID) |
| 1464 |
{ |
| 1465 |
vendor->m.productIdPresent = 1; |
| 1466 |
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), |
| 1467 |
sizeof(vendor->productId.data)); |
| 1468 |
strncpy((char *)vendor->productId.data, gH323ep.productID, |
| 1469 |
vendor->productId.numocts); |
| 1470 |
} |
| 1471 |
if(gH323ep.versionID) |
| 1472 |
{ |
| 1473 |
vendor->m.versionIdPresent = 1; |
| 1474 |
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), |
| 1475 |
sizeof(vendor->versionId.data)); |
| 1476 |
strncpy((char *)vendor->versionId.data, gH323ep.versionID, |
| 1477 |
vendor->versionId.numocts); |
| 1478 |
} |
| 1479 |
|
| 1480 |
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; |
| 1481 |
vendor->vendor.t35Extension = gH323ep.t35Extension; |
| 1482 |
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; |
| 1483 |
|
| 1484 |
OOTRACEDBGA3("Built Call Proceeding(%s, %s)\n", call->callType, |
| 1485 |
call->callToken); |
| 1486 |
ret = ooSendH225Msg(call, q931msg); |
| 1487 |
if(ret != OO_OK) |
| 1488 |
{ |
| 1489 |
OOTRACEERR3("Error:Failed to enqueue CallProceeding message to outbound queue.(%s, %s)\n", call->callType, call->callToken); |
| 1490 |
} |
| 1491 |
|
| 1492 |
|
| 1493 |
memReset(call->msgctxt); |
| 1494 |
|
| 1495 |
return ret; |
| 1496 |
} |
| 1497 |
|
| 1498 |
int ooSendAlerting(OOH323CallData *call) |
| 1499 |
{ |
| 1500 |
int ret; |
| 1501 |
H225Alerting_UUIE *alerting; |
| 1502 |
H225VendorIdentifier *vendor; |
| 1503 |
Q931Message *q931msg=NULL; |
| 1504 |
|
| 1505 |
OOCTXT *pctxt = call->msgctxt; |
| 1506 |
|
| 1507 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931AlertingMsg); |
| 1508 |
if(ret != OO_OK) |
| 1509 |
{ |
| 1510 |
OOTRACEERR1("Error: In allocating memory for - H225 " |
| 1511 |
"Alerting message\n"); |
| 1512 |
return OO_FAILED; |
| 1513 |
} |
| 1514 |
|
| 1515 |
call->alertingTime = (H235TimeStamp) time(NULL); |
| 1516 |
|
| 1517 |
q931msg->callReference = call->callReference; |
| 1518 |
|
| 1519 |
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 1520 |
sizeof(H225H323_UserInformation)); |
| 1521 |
if(!q931msg->userInfo) |
| 1522 |
{ |
| 1523 |
OOTRACEERR1("ERROR:Memory - ooSendAlerting - userInfo\n"); |
| 1524 |
return OO_FAILED; |
| 1525 |
} |
| 1526 |
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 1527 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 1528 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, |
| 1529 |
OO_M_TUNNELING); |
| 1530 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 1531 |
T_H225H323_UU_PDU_h323_message_body_alerting; |
| 1532 |
|
| 1533 |
alerting = (H225Alerting_UUIE*)memAlloc(pctxt, |
| 1534 |
sizeof(H225Alerting_UUIE)); |
| 1535 |
if(!alerting) |
| 1536 |
{ |
| 1537 |
OOTRACEERR1("ERROR:Memory - ooSendAlerting - alerting\n"); |
| 1538 |
return OO_FAILED; |
| 1539 |
} |
| 1540 |
memset(alerting, 0, sizeof(H225Alerting_UUIE)); |
| 1541 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.alerting = alerting; |
| 1542 |
alerting->m.multipleCallsPresent = 1; |
| 1543 |
alerting->m.maintainConnectionPresent = 1; |
| 1544 |
alerting->multipleCalls = FALSE; |
| 1545 |
alerting->maintainConnection = FALSE; |
| 1546 |
|
| 1547 |
|
| 1548 |
alerting->m.alertingAddressPresent = TRUE; |
| 1549 |
if(call->ourAliases) |
| 1550 |
ret = ooPopulateAliasList(pctxt, call->ourAliases, |
| 1551 |
&alerting->alertingAddress, 0); |
| 1552 |
else |
| 1553 |
ret = ooPopulateAliasList(pctxt, gH323ep.aliases, |
| 1554 |
&alerting->alertingAddress, 0); |
| 1555 |
if(OO_OK != ret) |
| 1556 |
{ |
| 1557 |
OOTRACEERR1("Error:Failed to populate alias list in Alert message\n"); |
| 1558 |
memReset(pctxt); |
| 1559 |
return OO_FAILED; |
| 1560 |
} |
| 1561 |
alerting->m.presentationIndicatorPresent = TRUE; |
| 1562 |
alerting->presentationIndicator.t = |
| 1563 |
T_H225PresentationIndicator_presentationAllowed; |
| 1564 |
alerting->m.screeningIndicatorPresent = TRUE; |
| 1565 |
alerting->screeningIndicator = userProvidedNotScreened; |
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
alerting->m.callIdentifierPresent = 1; |
| 1570 |
alerting->callIdentifier.guid.numocts = |
| 1571 |
call->callIdentifier.guid.numocts; |
| 1572 |
memcpy(alerting->callIdentifier.guid.data, |
| 1573 |
call->callIdentifier.guid.data, |
| 1574 |
call->callIdentifier.guid.numocts); |
| 1575 |
alerting->protocolIdentifier = gProtocolID; |
| 1576 |
|
| 1577 |
|
| 1578 |
if(gH323ep.isGateway) |
| 1579 |
alerting->destinationInfo.m.gatewayPresent = TRUE; |
| 1580 |
else |
| 1581 |
alerting->destinationInfo.m.terminalPresent = TRUE; |
| 1582 |
|
| 1583 |
alerting->destinationInfo.m.vendorPresent = 1; |
| 1584 |
vendor = &alerting->destinationInfo.vendor; |
| 1585 |
if(gH323ep.productID) |
| 1586 |
{ |
| 1587 |
vendor->m.productIdPresent = 1; |
| 1588 |
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), |
| 1589 |
sizeof(vendor->productId.data)); |
| 1590 |
strncpy((char *)vendor->productId.data, gH323ep.productID, |
| 1591 |
vendor->productId.numocts); |
| 1592 |
} |
| 1593 |
if(gH323ep.versionID) |
| 1594 |
{ |
| 1595 |
vendor->m.versionIdPresent = 1; |
| 1596 |
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), |
| 1597 |
sizeof(vendor->versionId.data)); |
| 1598 |
strncpy((char *)vendor->versionId.data, gH323ep.versionID, |
| 1599 |
vendor->versionId.numocts); |
| 1600 |
} |
| 1601 |
|
| 1602 |
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; |
| 1603 |
vendor->vendor.t35Extension = gH323ep.t35Extension; |
| 1604 |
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; |
| 1605 |
|
| 1606 |
if (!call->fsSent) { |
| 1607 |
ret = ooSetFastStartResponse(call, q931msg, |
| 1608 |
&alerting->fastStart.n, &alerting->fastStart.elem); |
| 1609 |
if(ret != ASN_OK) { return ret; } |
| 1610 |
if(alerting->fastStart.n > 0) { |
| 1611 |
alerting->m.fastStartPresent = TRUE; |
| 1612 |
call->fsSent = TRUE; |
| 1613 |
} else |
| 1614 |
alerting->m.fastStartPresent = FALSE; |
| 1615 |
} else { |
| 1616 |
alerting->m.fastStartPresent = FALSE; |
| 1617 |
} |
| 1618 |
|
| 1619 |
OOTRACEDBGA3("Built Alerting (%s, %s)\n", call->callType, call->callToken); |
| 1620 |
|
| 1621 |
ret = ooSendH225Msg(call, q931msg); |
| 1622 |
if(ret != OO_OK) |
| 1623 |
{ |
| 1624 |
OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken); |
| 1625 |
} |
| 1626 |
|
| 1627 |
if (call->h225version >= 4) { |
| 1628 |
ooSendTCSandMSD(call); |
| 1629 |
} |
| 1630 |
memReset (call->msgctxt); |
| 1631 |
|
| 1632 |
return ret; |
| 1633 |
} |
| 1634 |
|
| 1635 |
int ooSendProgress(OOH323CallData *call) |
| 1636 |
{ |
| 1637 |
int ret; |
| 1638 |
H225Progress_UUIE *progress; |
| 1639 |
H225VendorIdentifier *vendor; |
| 1640 |
Q931Message *q931msg=NULL; |
| 1641 |
H225TransportAddress_ipAddress *h245IpAddr; |
| 1642 |
H225TransportAddress_ip6Address *h245Ip6Addr; |
| 1643 |
OOCTXT *pctxt = call->msgctxt; |
| 1644 |
|
| 1645 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931ProgressMsg); |
| 1646 |
if(ret != OO_OK) |
| 1647 |
{ |
| 1648 |
OOTRACEERR1("Error: In allocating memory for - H225 " |
| 1649 |
"Alerting message\n"); |
| 1650 |
return OO_FAILED; |
| 1651 |
} |
| 1652 |
|
| 1653 |
q931msg->callReference = call->callReference; |
| 1654 |
|
| 1655 |
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 1656 |
sizeof(H225H323_UserInformation)); |
| 1657 |
if(!q931msg->userInfo) |
| 1658 |
{ |
| 1659 |
OOTRACEERR1("ERROR:Memory - ooSendAlerting - userInfo\n"); |
| 1660 |
return OO_FAILED; |
| 1661 |
} |
| 1662 |
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 1663 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 1664 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, |
| 1665 |
OO_M_TUNNELING); |
| 1666 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 1667 |
T_H225H323_UU_PDU_h323_message_body_progress; |
| 1668 |
|
| 1669 |
progress = (H225Progress_UUIE*)memAlloc(pctxt, |
| 1670 |
sizeof(H225Progress_UUIE)); |
| 1671 |
if(!progress) |
| 1672 |
{ |
| 1673 |
OOTRACEERR1("ERROR:Memory - ooSendProgress- alerting\n"); |
| 1674 |
return OO_FAILED; |
| 1675 |
} |
| 1676 |
memset(progress, 0, sizeof(H225Progress_UUIE)); |
| 1677 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.progress = progress; |
| 1678 |
progress->m.multipleCallsPresent = 1; |
| 1679 |
progress->m.maintainConnectionPresent = 1; |
| 1680 |
progress->multipleCalls = FALSE; |
| 1681 |
progress->maintainConnection = FALSE; |
| 1682 |
|
| 1683 |
progress->callIdentifier.guid.numocts = |
| 1684 |
call->callIdentifier.guid.numocts; |
| 1685 |
memcpy(progress->callIdentifier.guid.data, |
| 1686 |
call->callIdentifier.guid.data, |
| 1687 |
call->callIdentifier.guid.numocts); |
| 1688 |
progress->protocolIdentifier = gProtocolID; |
| 1689 |
|
| 1690 |
|
| 1691 |
if(gH323ep.isGateway) |
| 1692 |
progress->destinationInfo.m.gatewayPresent = TRUE; |
| 1693 |
else |
| 1694 |
progress->destinationInfo.m.terminalPresent = TRUE; |
| 1695 |
|
| 1696 |
progress->destinationInfo.m.vendorPresent = 1; |
| 1697 |
vendor = &progress->destinationInfo.vendor; |
| 1698 |
if(gH323ep.productID) |
| 1699 |
{ |
| 1700 |
vendor->m.productIdPresent = 1; |
| 1701 |
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), |
| 1702 |
sizeof(vendor->productId.data)); |
| 1703 |
strncpy((char *)vendor->productId.data, gH323ep.productID, |
| 1704 |
vendor->productId.numocts); |
| 1705 |
} |
| 1706 |
if(gH323ep.versionID) |
| 1707 |
{ |
| 1708 |
vendor->m.versionIdPresent = 1; |
| 1709 |
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), |
| 1710 |
sizeof(vendor->versionId.data)); |
| 1711 |
strncpy((char *)vendor->versionId.data, gH323ep.versionID, |
| 1712 |
vendor->versionId.numocts); |
| 1713 |
} |
| 1714 |
|
| 1715 |
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; |
| 1716 |
vendor->vendor.t35Extension = gH323ep.t35Extension; |
| 1717 |
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; |
| 1718 |
|
| 1719 |
if (!call->fsSent) { |
| 1720 |
ret = ooSetFastStartResponse(call, q931msg, |
| 1721 |
&progress->fastStart.n, &progress->fastStart.elem); |
| 1722 |
if(ret != ASN_OK) { return ret; } |
| 1723 |
if(progress->fastStart.n > 0) { |
| 1724 |
progress->m.fastStartPresent = TRUE; |
| 1725 |
call->fsSent = TRUE; |
| 1726 |
} else |
| 1727 |
progress->m.fastStartPresent = FALSE; |
| 1728 |
} else { |
| 1729 |
progress->m.fastStartPresent = FALSE; |
| 1730 |
} |
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
if ( |
| 1735 |
|
| 1736 |
!OO_TESTFLAG (call->flags, OO_M_TUNNELING) && |
| 1737 |
!call->h245listener && ooCreateH245Listener(call) == OO_OK) |
| 1738 |
{ |
| 1739 |
if (call->versionIP == 6) { |
| 1740 |
progress->m.h245AddressPresent = TRUE; |
| 1741 |
progress->h245Address.t = T_H225TransportAddress_ip6Address; |
| 1742 |
|
| 1743 |
h245Ip6Addr = (H225TransportAddress_ip6Address*) |
| 1744 |
memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address)); |
| 1745 |
if(!h245Ip6Addr) |
| 1746 |
{ |
| 1747 |
OOTRACEERR3("Error:Memory - ooSendProgress - h245Ip6Addr" |
| 1748 |
"(%s, %s)\n", call->callType, call->callToken); |
| 1749 |
return OO_FAILED; |
| 1750 |
} |
| 1751 |
inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data); |
| 1752 |
h245Ip6Addr->ip.numocts=16; |
| 1753 |
h245Ip6Addr->port = *(call->h245listenport); |
| 1754 |
progress->h245Address.u.ip6Address = h245Ip6Addr; |
| 1755 |
} else { |
| 1756 |
progress->m.h245AddressPresent = TRUE; |
| 1757 |
progress->h245Address.t = T_H225TransportAddress_ipAddress; |
| 1758 |
|
| 1759 |
h245IpAddr = (H225TransportAddress_ipAddress*) |
| 1760 |
memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress)); |
| 1761 |
if(!h245IpAddr) |
| 1762 |
{ |
| 1763 |
OOTRACEERR3("Error:Memory - ooSendProgress - h245IpAddr" |
| 1764 |
"(%s, %s)\n", call->callType, call->callToken); |
| 1765 |
return OO_FAILED; |
| 1766 |
} |
| 1767 |
inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data); |
| 1768 |
h245IpAddr->ip.numocts=4; |
| 1769 |
h245IpAddr->port = *(call->h245listenport); |
| 1770 |
progress->h245Address.u.ipAddress = h245IpAddr; |
| 1771 |
} |
| 1772 |
} |
| 1773 |
|
| 1774 |
OOTRACEDBGA3("Built Progress (%s, %s)\n", call->callType, call->callToken); |
| 1775 |
|
| 1776 |
ret = ooSendH225Msg(call, q931msg); |
| 1777 |
if(ret != OO_OK) |
| 1778 |
{ |
| 1779 |
OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken); |
| 1780 |
} |
| 1781 |
|
| 1782 |
if (!OO_TESTFLAG(call->flags, OO_M_TUNNELING) && call->h245listener) |
| 1783 |
ooSendStartH245Facility(call); |
| 1784 |
|
| 1785 |
if (call->h225version >= 4) { |
| 1786 |
ooSendTCSandMSD(call); |
| 1787 |
} |
| 1788 |
memReset (call->msgctxt); |
| 1789 |
|
| 1790 |
return ret; |
| 1791 |
} |
| 1792 |
|
| 1793 |
|
| 1794 |
int ooSendFSUpdate(OOH323CallData *call) |
| 1795 |
{ |
| 1796 |
int ret = 0; |
| 1797 |
Q931Message *pQ931Msg = NULL; |
| 1798 |
H225Facility_UUIE *facility = NULL; |
| 1799 |
OOCTXT *pctxt = call->msgctxt; |
| 1800 |
|
| 1801 |
OOTRACEDBGA3("Building FS update message (%s, %s)\n", call->callType, |
| 1802 |
call->callToken); |
| 1803 |
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); |
| 1804 |
if (ret != OO_OK) { |
| 1805 |
OOTRACEERR3("ERROR: In allocating memory for facility message (%s, %s)\n", |
| 1806 |
call->callType, call->callToken); |
| 1807 |
return OO_FAILED; |
| 1808 |
} |
| 1809 |
|
| 1810 |
pQ931Msg->callReference = call->callReference; |
| 1811 |
|
| 1812 |
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 1813 |
sizeof(H225H323_UserInformation)); |
| 1814 |
if (!pQ931Msg->userInfo) { |
| 1815 |
OOTRACEERR3("ERROR:Memory - ooSendFSUpdate - userInfo(%s, %s)\n", |
| 1816 |
call->callType, call->callToken); |
| 1817 |
return OO_FAILED; |
| 1818 |
} |
| 1819 |
memset(pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 1820 |
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent = 1; |
| 1821 |
|
| 1822 |
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 1823 |
OO_TESTFLAG (call->flags, OO_M_TUNNELING); |
| 1824 |
|
| 1825 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 1826 |
T_H225H323_UU_PDU_h323_message_body_facility; |
| 1827 |
|
| 1828 |
facility = (H225Facility_UUIE*) |
| 1829 |
memAllocZ (pctxt, sizeof(H225Facility_UUIE)); |
| 1830 |
|
| 1831 |
if (!facility) { |
| 1832 |
OOTRACEERR3("ERROR:Memory - ooSendFS Update - facility (%s, %s)\n", |
| 1833 |
call->callType, call->callToken); |
| 1834 |
return OO_FAILED; |
| 1835 |
} |
| 1836 |
|
| 1837 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; |
| 1838 |
|
| 1839 |
|
| 1840 |
facility->protocolIdentifier = gProtocolID; |
| 1841 |
facility->m.callIdentifierPresent = 1; |
| 1842 |
facility->callIdentifier.guid.numocts = |
| 1843 |
call->callIdentifier.guid.numocts; |
| 1844 |
memcpy(facility->callIdentifier.guid.data, |
| 1845 |
call->callIdentifier.guid.data, |
| 1846 |
call->callIdentifier.guid.numocts); |
| 1847 |
facility->reason.t = T_H225FacilityReason_forwardedElements; |
| 1848 |
|
| 1849 |
ret = ooSetFastStartResponse(call, pQ931Msg, |
| 1850 |
&facility->fastStart.n, &facility->fastStart.elem); |
| 1851 |
if (ret != ASN_OK) { |
| 1852 |
return ret; |
| 1853 |
} |
| 1854 |
if (facility->fastStart.n > 0) { |
| 1855 |
facility->m.fastStartPresent = TRUE; |
| 1856 |
call->fsSent = TRUE; |
| 1857 |
} else { |
| 1858 |
facility->m.fastStartPresent = FALSE; |
| 1859 |
} |
| 1860 |
|
| 1861 |
OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType, |
| 1862 |
call->callToken); |
| 1863 |
|
| 1864 |
ret = ooSendH225Msg(call, pQ931Msg); |
| 1865 |
if (ret != OO_OK) { |
| 1866 |
OOTRACEERR3("Error:Failed to enqueue Facility message to outbound " |
| 1867 |
"queue.(%s, %s)\n", call->callType, call->callToken); |
| 1868 |
} |
| 1869 |
memReset(call->msgctxt); |
| 1870 |
return ret; |
| 1871 |
} |
| 1872 |
|
| 1873 |
int ooSendStartH245Facility(OOH323CallData *call) |
| 1874 |
{ |
| 1875 |
int ret=0; |
| 1876 |
Q931Message *pQ931Msg = NULL; |
| 1877 |
H225Facility_UUIE *facility=NULL; |
| 1878 |
|
| 1879 |
OOCTXT *pctxt = call->msgctxt; |
| 1880 |
H225TransportAddress_ipAddress *h245IpAddr; |
| 1881 |
H225TransportAddress_ip6Address *h245Ip6Addr; |
| 1882 |
|
| 1883 |
OOTRACEDBGA3("Building Facility message (%s, %s)\n", call->callType, |
| 1884 |
call->callToken); |
| 1885 |
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); |
| 1886 |
if(ret != OO_OK) |
| 1887 |
{ |
| 1888 |
OOTRACEERR3 |
| 1889 |
("ERROR: In allocating memory for facility message (%s, %s)\n", |
| 1890 |
call->callType, call->callToken); |
| 1891 |
return OO_FAILED; |
| 1892 |
} |
| 1893 |
|
| 1894 |
pQ931Msg->callReference = call->callReference; |
| 1895 |
|
| 1896 |
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 1897 |
sizeof(H225H323_UserInformation)); |
| 1898 |
if(!pQ931Msg->userInfo) |
| 1899 |
{ |
| 1900 |
OOTRACEERR3("ERROR:Memory - ooSendFacility - userInfo(%s, %s)\n", |
| 1901 |
call->callType, call->callToken); |
| 1902 |
return OO_FAILED; |
| 1903 |
} |
| 1904 |
memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 1905 |
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 1906 |
|
| 1907 |
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 1908 |
OO_TESTFLAG (call->flags, OO_M_TUNNELING); |
| 1909 |
|
| 1910 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 1911 |
T_H225H323_UU_PDU_h323_message_body_facility; |
| 1912 |
|
| 1913 |
facility = (H225Facility_UUIE*) |
| 1914 |
memAllocZ (pctxt, sizeof(H225Facility_UUIE)); |
| 1915 |
|
| 1916 |
if(!facility) |
| 1917 |
{ |
| 1918 |
OOTRACEERR3("ERROR:Memory - ooSendFacility - facility (%s, %s)" |
| 1919 |
"\n", call->callType, call->callToken); |
| 1920 |
return OO_FAILED; |
| 1921 |
} |
| 1922 |
|
| 1923 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; |
| 1924 |
|
| 1925 |
|
| 1926 |
facility->protocolIdentifier = gProtocolID; |
| 1927 |
facility->m.callIdentifierPresent = 1; |
| 1928 |
facility->callIdentifier.guid.numocts = |
| 1929 |
call->callIdentifier.guid.numocts; |
| 1930 |
memcpy(facility->callIdentifier.guid.data, |
| 1931 |
call->callIdentifier.guid.data, |
| 1932 |
call->callIdentifier.guid.numocts); |
| 1933 |
facility->reason.t = T_H225FacilityReason_startH245; |
| 1934 |
|
| 1935 |
if (!call->h245listener && ooCreateH245Listener(call) != OO_OK) { |
| 1936 |
OOTRACEERR3("Error:No H245Listener, can't send startH245 facility (%s, %s)\n", |
| 1937 |
call->callType, call->callToken); |
| 1938 |
return OO_FAILED; |
| 1939 |
} |
| 1940 |
|
| 1941 |
facility->m.h245AddressPresent = TRUE; |
| 1942 |
if (call->versionIP == 6) { |
| 1943 |
facility->h245Address.t = T_H225TransportAddress_ip6Address; |
| 1944 |
|
| 1945 |
h245Ip6Addr = (H225TransportAddress_ip6Address*) |
| 1946 |
memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address)); |
| 1947 |
if(!h245Ip6Addr) { |
| 1948 |
OOTRACEERR3("Error:Memory - ooSendFacility - h245Ip6Addr" |
| 1949 |
"(%s, %s)\n", call->callType, call->callToken); |
| 1950 |
return OO_FAILED; |
| 1951 |
} |
| 1952 |
inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data); |
| 1953 |
h245Ip6Addr->ip.numocts=16; |
| 1954 |
h245Ip6Addr->port = *(call->h245listenport); |
| 1955 |
facility->h245Address.u.ip6Address = h245Ip6Addr; |
| 1956 |
} else { |
| 1957 |
facility->h245Address.t = T_H225TransportAddress_ipAddress; |
| 1958 |
|
| 1959 |
h245IpAddr = (H225TransportAddress_ipAddress*) |
| 1960 |
memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress)); |
| 1961 |
if(!h245IpAddr) { |
| 1962 |
OOTRACEERR3("Error:Memory - ooSendFacility - h245IpAddr" |
| 1963 |
"(%s, %s)\n", call->callType, call->callToken); |
| 1964 |
return OO_FAILED; |
| 1965 |
} |
| 1966 |
inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data); |
| 1967 |
h245IpAddr->ip.numocts=4; |
| 1968 |
h245IpAddr->port = *(call->h245listenport); |
| 1969 |
facility->h245Address.u.ipAddress = h245IpAddr; |
| 1970 |
} |
| 1971 |
|
| 1972 |
OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType, |
| 1973 |
call->callToken); |
| 1974 |
|
| 1975 |
ret = ooSendH225Msg(call, pQ931Msg); |
| 1976 |
if(ret != OO_OK) |
| 1977 |
{ |
| 1978 |
OOTRACEERR3 |
| 1979 |
("Error:Failed to enqueue Facility message to outbound " |
| 1980 |
"queue.(%s, %s)\n", call->callType, call->callToken); |
| 1981 |
} |
| 1982 |
|
| 1983 |
memReset (call->msgctxt); |
| 1984 |
return ret; |
| 1985 |
} |
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
|
| 1991 |
int ooSendStatus(OOH323CallData *call) |
| 1992 |
{ |
| 1993 |
int ret; |
| 1994 |
H225Status_UUIE *status; |
| 1995 |
Q931Message *q931msg=NULL; |
| 1996 |
|
| 1997 |
OOCTXT *pctxt = call->msgctxt; |
| 1998 |
|
| 1999 |
OOTRACEDBGC3("Building StatusMsg (%s, %s)\n", call->callType, |
| 2000 |
call->callToken); |
| 2001 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusMsg); |
| 2002 |
if(ret != OO_OK) |
| 2003 |
{ |
| 2004 |
OOTRACEERR1("Error: In allocating memory for - H225 Status " |
| 2005 |
"message\n"); |
| 2006 |
return OO_FAILED; |
| 2007 |
} |
| 2008 |
|
| 2009 |
q931msg->callReference = call->callReference; |
| 2010 |
|
| 2011 |
q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt, |
| 2012 |
sizeof(H225H323_UserInformation)); |
| 2013 |
if(!q931msg->userInfo) |
| 2014 |
{ |
| 2015 |
OOTRACEERR1("ERROR:Memory - ooSendStatus - userInfo\n"); |
| 2016 |
return OO_FAILED; |
| 2017 |
} |
| 2018 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 2019 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 2020 |
OO_TESTFLAG(call->flags, OO_M_TUNNELING); |
| 2021 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 2022 |
T_H225H323_UU_PDU_h323_message_body_status; |
| 2023 |
|
| 2024 |
status = (H225Status_UUIE*)memAllocZ(pctxt, |
| 2025 |
sizeof(H225Status_UUIE)); |
| 2026 |
if(!status) |
| 2027 |
{ |
| 2028 |
OOTRACEERR1("ERROR:Memory - ooSendStatus \n"); |
| 2029 |
return OO_FAILED; |
| 2030 |
} |
| 2031 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.status = status; |
| 2032 |
|
| 2033 |
status->callIdentifier.guid.numocts = |
| 2034 |
call->callIdentifier.guid.numocts; |
| 2035 |
memcpy(status->callIdentifier.guid.data, |
| 2036 |
call->callIdentifier.guid.data, |
| 2037 |
call->callIdentifier.guid.numocts); |
| 2038 |
status->protocolIdentifier = gProtocolID; |
| 2039 |
|
| 2040 |
ooQ931SetCauseIE(pctxt, q931msg, Q931StatusEnquiryResponse, 0, 0); |
| 2041 |
ooQ931SetCallStateIE(pctxt, q931msg, 10); |
| 2042 |
|
| 2043 |
OOTRACEDBGA3("Built Status (%s, %s)\n", call->callType, |
| 2044 |
call->callToken); |
| 2045 |
ret = ooSendH225Msg(call, q931msg); |
| 2046 |
if(ret != OO_OK) |
| 2047 |
{ |
| 2048 |
OOTRACEERR3("Error:Failed to enqueue Status message to outbound queue.(%s, %s)\n", call->callType, call->callToken); |
| 2049 |
} |
| 2050 |
|
| 2051 |
|
| 2052 |
memReset(call->msgctxt); |
| 2053 |
|
| 2054 |
return ret; |
| 2055 |
} |
| 2056 |
|
| 2057 |
int ooSendStatusInquiry(OOH323CallData *call) |
| 2058 |
{ |
| 2059 |
int ret; |
| 2060 |
H225StatusInquiry_UUIE *statusInq; |
| 2061 |
Q931Message *q931msg=NULL; |
| 2062 |
|
| 2063 |
OOCTXT *pctxt = call->msgctxt; |
| 2064 |
|
| 2065 |
OOTRACEDBGC3("Building StatusInquiryMsg (%s, %s)\n", call->callType, |
| 2066 |
call->callToken); |
| 2067 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusEnquiryMsg); |
| 2068 |
if(ret != OO_OK) |
| 2069 |
{ |
| 2070 |
OOTRACEERR1("Error: In allocating memory for - H225 Status " |
| 2071 |
"message\n"); |
| 2072 |
return OO_FAILED; |
| 2073 |
} |
| 2074 |
|
| 2075 |
q931msg->callReference = call->callReference; |
| 2076 |
|
| 2077 |
q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt, |
| 2078 |
sizeof(H225H323_UserInformation)); |
| 2079 |
if(!q931msg->userInfo) |
| 2080 |
{ |
| 2081 |
OOTRACEERR1("ERROR:Memory - ooSendStatus - userInfo\n"); |
| 2082 |
return OO_FAILED; |
| 2083 |
} |
| 2084 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 2085 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 2086 |
OO_TESTFLAG(call->flags, OO_M_TUNNELING); |
| 2087 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 2088 |
T_H225H323_UU_PDU_h323_message_body_statusInquiry; |
| 2089 |
|
| 2090 |
statusInq = (H225StatusInquiry_UUIE*)memAllocZ(pctxt, |
| 2091 |
sizeof(H225StatusInquiry_UUIE)); |
| 2092 |
if(!statusInq) |
| 2093 |
{ |
| 2094 |
OOTRACEERR1("ERROR:Memory - ooSendStatusInquiry \n"); |
| 2095 |
return OO_FAILED; |
| 2096 |
} |
| 2097 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.statusInquiry = statusInq; |
| 2098 |
|
| 2099 |
statusInq->callIdentifier.guid.numocts = |
| 2100 |
call->callIdentifier.guid.numocts; |
| 2101 |
memcpy(statusInq->callIdentifier.guid.data, |
| 2102 |
call->callIdentifier.guid.data, |
| 2103 |
call->callIdentifier.guid.numocts); |
| 2104 |
statusInq->protocolIdentifier = gProtocolID; |
| 2105 |
|
| 2106 |
OOTRACEDBGA3("Built StatusInquiry (%s, %s)\n", call->callType, |
| 2107 |
call->callToken); |
| 2108 |
ret = ooSendH225Msg(call, q931msg); |
| 2109 |
if(ret != OO_OK) |
| 2110 |
{ |
| 2111 |
OOTRACEERR3("Error:Failed to enqueue Status message to outbound queue.(%s, %s)\n", call->callType, call->callToken); |
| 2112 |
} |
| 2113 |
|
| 2114 |
|
| 2115 |
memReset(call->msgctxt); |
| 2116 |
|
| 2117 |
return ret; |
| 2118 |
} |
| 2119 |
int ooSendReleaseComplete(OOH323CallData *call) |
| 2120 |
{ |
| 2121 |
int ret; |
| 2122 |
Q931Message *q931msg=NULL; |
| 2123 |
H225ReleaseComplete_UUIE *releaseComplete; |
| 2124 |
enum Q931CauseValues cause = Q931ErrorInCauseIE; |
| 2125 |
unsigned h225ReasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 2126 |
|
| 2127 |
|
| 2128 |
OOCTXT *pctxt = call->msgctxt; |
| 2129 |
OOTRACEDBGA3("Building Release Complete message to send(%s, %s)\n", |
| 2130 |
call->callType, call->callToken); |
| 2131 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931ReleaseCompleteMsg); |
| 2132 |
if(ret != OO_OK) |
| 2133 |
{ |
| 2134 |
OOTRACEERR3("Error: In ooCreateQ931Message - H225 Release Complete " |
| 2135 |
"message(%s, %s)\n", call->callType, call->callToken); |
| 2136 |
if(call->callState < OO_CALL_CLEAR) |
| 2137 |
{ |
| 2138 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 2139 |
call->callState = OO_CALL_CLEAR; |
| 2140 |
} |
| 2141 |
return OO_FAILED; |
| 2142 |
} |
| 2143 |
|
| 2144 |
q931msg->callReference = call->callReference; |
| 2145 |
|
| 2146 |
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 2147 |
sizeof(H225H323_UserInformation)); |
| 2148 |
if(!q931msg->userInfo) |
| 2149 |
{ |
| 2150 |
OOTRACEERR1("ERROR:Memory - ooSendReleaseComplete - userInfo\n"); |
| 2151 |
return OO_FAILED; |
| 2152 |
} |
| 2153 |
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 2154 |
|
| 2155 |
releaseComplete = (H225ReleaseComplete_UUIE*)memAlloc(pctxt, |
| 2156 |
sizeof(H225ReleaseComplete_UUIE)); |
| 2157 |
if(!releaseComplete) |
| 2158 |
{ |
| 2159 |
OOTRACEERR3("Error:Memory - ooSendReleaseComplete - releaseComplete" |
| 2160 |
"(%s, %s)\n", call->callType, call->callToken); |
| 2161 |
return OO_FAILED; |
| 2162 |
} |
| 2163 |
memset(releaseComplete, 0, sizeof(H225ReleaseComplete_UUIE)); |
| 2164 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 2165 |
T_H225H323_UU_PDU_h323_message_body_releaseComplete; |
| 2166 |
|
| 2167 |
|
| 2168 |
ooQ931GetCauseAndReasonCodeFromCallClearReason(call->callEndReason, |
| 2169 |
&cause, &h225ReasonCode); |
| 2170 |
if (call->q931cause == 0) |
| 2171 |
call->q931cause = cause; |
| 2172 |
|
| 2173 |
ooQ931SetCauseIE(pctxt, q931msg, call->q931cause, 0, 0); |
| 2174 |
|
| 2175 |
|
| 2176 |
releaseComplete->m.reasonPresent = TRUE; |
| 2177 |
releaseComplete->reason.t = h225ReasonCode; |
| 2178 |
|
| 2179 |
|
| 2180 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 2181 |
T_H225H323_UU_PDU_h323_message_body_releaseComplete; |
| 2182 |
|
| 2183 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.releaseComplete = |
| 2184 |
releaseComplete; |
| 2185 |
releaseComplete->m.callIdentifierPresent = 1; |
| 2186 |
releaseComplete->protocolIdentifier = gProtocolID; |
| 2187 |
releaseComplete->callIdentifier.guid.numocts = |
| 2188 |
call->callIdentifier.guid.numocts; |
| 2189 |
memcpy(releaseComplete->callIdentifier.guid.data, |
| 2190 |
call->callIdentifier.guid.data, |
| 2191 |
call->callIdentifier.guid.numocts); |
| 2192 |
|
| 2193 |
OOTRACEDBGA3("Built Release Complete message (%s, %s)\n", |
| 2194 |
call->callType, call->callToken); |
| 2195 |
|
| 2196 |
ret = ooSendH225Msg(call, q931msg); |
| 2197 |
if(ret != OO_OK) |
| 2198 |
{ |
| 2199 |
OOTRACEERR3("Error:Failed to enqueue ReleaseComplete message to outbound" |
| 2200 |
" queue.(%s, %s)\n", call->callType, call->callToken); |
| 2201 |
} |
| 2202 |
|
| 2203 |
memReset(call->msgctxt); |
| 2204 |
|
| 2205 |
return ret; |
| 2206 |
} |
| 2207 |
|
| 2208 |
int ooSendConnect(OOH323CallData *call) |
| 2209 |
{ |
| 2210 |
|
| 2211 |
call->connectTime = (H235TimeStamp) time(NULL); |
| 2212 |
|
| 2213 |
if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { |
| 2214 |
if(gH323ep.gkClient->state == GkClientRegistered) { |
| 2215 |
ooGkClientSendIRR(gH323ep.gkClient, call); |
| 2216 |
} |
| 2217 |
} |
| 2218 |
|
| 2219 |
ooAcceptCall(call); |
| 2220 |
return OO_OK; |
| 2221 |
} |
| 2222 |
|
| 2223 |
|
| 2224 |
int ooAcceptCall(OOH323CallData *call) |
| 2225 |
{ |
| 2226 |
int ret = 0, i=0; |
| 2227 |
H225Connect_UUIE *connect; |
| 2228 |
H225TransportAddress_ipAddress *h245IpAddr; |
| 2229 |
H225TransportAddress_ip6Address *h245Ip6Addr; |
| 2230 |
H225VendorIdentifier *vendor; |
| 2231 |
Q931Message *q931msg=NULL; |
| 2232 |
|
| 2233 |
OOCTXT *pctxt = call->msgctxt; |
| 2234 |
|
| 2235 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931ConnectMsg); |
| 2236 |
if(ret != OO_OK) |
| 2237 |
{ |
| 2238 |
OOTRACEERR1("Error: In allocating memory for - H225 " |
| 2239 |
"Connect message\n"); |
| 2240 |
return OO_FAILED; |
| 2241 |
} |
| 2242 |
q931msg->callReference = call->callReference; |
| 2243 |
|
| 2244 |
|
| 2245 |
if(OO_OK != ooSetBearerCapabilityIE(pctxt, q931msg, Q931CCITTStd, |
| 2246 |
|
| 2247 |
|
| 2248 |
Q931TransferSpeech, Q931TransferCircuitMode, |
| 2249 |
Q931TransferRate64Kbps, Q931UserInfoLayer1G711ALaw)) |
| 2250 |
{ |
| 2251 |
OOTRACEERR3("Error: Failed to set bearer capability ie. (%s, %s)\n", |
| 2252 |
call->callType, call->callToken); |
| 2253 |
return OO_FAILED; |
| 2254 |
} |
| 2255 |
|
| 2256 |
q931msg->userInfo = (H225H323_UserInformation*) |
| 2257 |
memAllocZ (pctxt,sizeof(H225H323_UserInformation)); |
| 2258 |
|
| 2259 |
if(!q931msg->userInfo) |
| 2260 |
{ |
| 2261 |
OOTRACEERR1("ERROR:Memory - ooAcceptCall - userInfo\n"); |
| 2262 |
return OO_FAILED; |
| 2263 |
} |
| 2264 |
|
| 2265 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=TRUE; |
| 2266 |
|
| 2267 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 2268 |
OO_TESTFLAG (call->flags, OO_M_TUNNELING); |
| 2269 |
|
| 2270 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 2271 |
T_H225H323_UU_PDU_h323_message_body_connect; |
| 2272 |
|
| 2273 |
connect = (H225Connect_UUIE*) |
| 2274 |
memAllocZ (pctxt, sizeof(H225Connect_UUIE)); |
| 2275 |
|
| 2276 |
if(!connect) |
| 2277 |
{ |
| 2278 |
OOTRACEERR1("ERROR:Memory - ooAcceptCall - connect\n"); |
| 2279 |
return OO_FAILED; |
| 2280 |
} |
| 2281 |
|
| 2282 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.connect = connect; |
| 2283 |
connect->m.fastStartPresent = 0; |
| 2284 |
connect->m.multipleCallsPresent = 1; |
| 2285 |
connect->m.maintainConnectionPresent = 1; |
| 2286 |
connect->multipleCalls = FALSE; |
| 2287 |
connect->maintainConnection = FALSE; |
| 2288 |
|
| 2289 |
|
| 2290 |
connect->conferenceID.numocts = 16; |
| 2291 |
for (i = 0; i < 16; i++) |
| 2292 |
connect->conferenceID.data[i] = i + 1; |
| 2293 |
|
| 2294 |
connect->m.callIdentifierPresent = 1; |
| 2295 |
connect->callIdentifier.guid.numocts = |
| 2296 |
call->callIdentifier.guid.numocts; |
| 2297 |
memcpy(connect->callIdentifier.guid.data, call->callIdentifier.guid.data, |
| 2298 |
call->callIdentifier.guid.numocts); |
| 2299 |
|
| 2300 |
connect->conferenceID.numocts = call->confIdentifier.numocts; |
| 2301 |
memcpy(connect->conferenceID.data, call->confIdentifier.data, |
| 2302 |
call->confIdentifier.numocts); |
| 2303 |
|
| 2304 |
connect->m.connectedAddressPresent = TRUE; |
| 2305 |
if(call->ourAliases) |
| 2306 |
ret = ooPopulateAliasList(pctxt, call->ourAliases, |
| 2307 |
&connect->connectedAddress, 0); |
| 2308 |
else |
| 2309 |
ret = ooPopulateAliasList(pctxt, gH323ep.aliases, |
| 2310 |
&connect->connectedAddress, 0); |
| 2311 |
if(OO_OK != ret) |
| 2312 |
{ |
| 2313 |
OOTRACEERR1("Error:Failed to populate alias list in Connect message\n"); |
| 2314 |
memReset(pctxt); |
| 2315 |
return OO_FAILED; |
| 2316 |
} |
| 2317 |
connect->m.presentationIndicatorPresent = TRUE; |
| 2318 |
connect->presentationIndicator.t = |
| 2319 |
T_H225PresentationIndicator_presentationAllowed; |
| 2320 |
connect->m.screeningIndicatorPresent = TRUE; |
| 2321 |
connect->screeningIndicator = userProvidedNotScreened; |
| 2322 |
|
| 2323 |
connect->protocolIdentifier = gProtocolID; |
| 2324 |
|
| 2325 |
|
| 2326 |
if(gH323ep.isGateway) |
| 2327 |
connect->destinationInfo.m.gatewayPresent = TRUE; |
| 2328 |
else |
| 2329 |
connect->destinationInfo.m.terminalPresent = TRUE; |
| 2330 |
|
| 2331 |
|
| 2332 |
connect->destinationInfo.m.vendorPresent = 1; |
| 2333 |
vendor = &connect->destinationInfo.vendor; |
| 2334 |
|
| 2335 |
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; |
| 2336 |
vendor->vendor.t35Extension = gH323ep.t35Extension; |
| 2337 |
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; |
| 2338 |
if(gH323ep.productID) |
| 2339 |
{ |
| 2340 |
vendor->m.productIdPresent = 1; |
| 2341 |
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), |
| 2342 |
sizeof(vendor->productId.data)); |
| 2343 |
strncpy((char *)vendor->productId.data, gH323ep.productID, |
| 2344 |
vendor->productId.numocts); |
| 2345 |
} |
| 2346 |
if(gH323ep.versionID) |
| 2347 |
{ |
| 2348 |
vendor->m.versionIdPresent = 1; |
| 2349 |
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), |
| 2350 |
sizeof(vendor->versionId.data)); |
| 2351 |
strncpy((char *)vendor->versionId.data, gH323ep.versionID, |
| 2352 |
vendor->versionId.numocts); |
| 2353 |
} |
| 2354 |
|
| 2355 |
if (!call->fsSent) { |
| 2356 |
ret = ooSetFastStartResponse(call, q931msg, |
| 2357 |
&connect->fastStart.n, &connect->fastStart.elem); |
| 2358 |
if(ret != ASN_OK) { return ret; } |
| 2359 |
if(connect->fastStart.n > 0) { |
| 2360 |
connect->m.fastStartPresent = TRUE; |
| 2361 |
call->fsSent = TRUE; |
| 2362 |
} else |
| 2363 |
connect->m.fastStartPresent = FALSE; |
| 2364 |
} else { |
| 2365 |
connect->m.fastStartPresent = FALSE; |
| 2366 |
} |
| 2367 |
|
| 2368 |
|
| 2369 |
if(call->pFastStartRes) { |
| 2370 |
int k; |
| 2371 |
for(k = 0; k < call->pFastStartRes->n; k ++) { |
| 2372 |
memFreePtr(call->pctxt, call->pFastStartRes->elem[k].data); |
| 2373 |
} |
| 2374 |
memFreePtr(call->pctxt, call->pFastStartRes->elem); |
| 2375 |
memFreePtr(call->pctxt, call->pFastStartRes); |
| 2376 |
call->pFastStartRes = NULL; |
| 2377 |
} |
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
if ( |
| 2386 |
|
| 2387 |
!OO_TESTFLAG (call->flags, OO_M_TUNNELING) && |
| 2388 |
( (!call->h245listener && ooCreateH245Listener(call) == OO_OK) || |
| 2389 |
!call->pH245Channel)) |
| 2390 |
{ |
| 2391 |
connect->m.h245AddressPresent = TRUE; |
| 2392 |
if (call->versionIP == 6) { |
| 2393 |
connect->h245Address.t = T_H225TransportAddress_ip6Address; |
| 2394 |
|
| 2395 |
h245Ip6Addr = (H225TransportAddress_ip6Address*) |
| 2396 |
memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address)); |
| 2397 |
if(!h245Ip6Addr) |
| 2398 |
{ |
| 2399 |
OOTRACEERR3("Error:Memory - ooAcceptCall - h245Ip6Addr" |
| 2400 |
"(%s, %s)\n", call->callType, call->callToken); |
| 2401 |
return OO_FAILED; |
| 2402 |
} |
| 2403 |
inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data); |
| 2404 |
h245Ip6Addr->ip.numocts=16; |
| 2405 |
h245Ip6Addr->port = *(call->h245listenport); |
| 2406 |
connect->h245Address.u.ip6Address = h245Ip6Addr; |
| 2407 |
} else { |
| 2408 |
connect->h245Address.t = T_H225TransportAddress_ipAddress; |
| 2409 |
|
| 2410 |
h245IpAddr = (H225TransportAddress_ipAddress*) |
| 2411 |
memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress)); |
| 2412 |
if(!h245IpAddr) |
| 2413 |
{ |
| 2414 |
OOTRACEERR3("Error:Memory - ooAcceptCall - h245IpAddr" |
| 2415 |
"(%s, %s)\n", call->callType, call->callToken); |
| 2416 |
return OO_FAILED; |
| 2417 |
} |
| 2418 |
inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data); |
| 2419 |
h245IpAddr->ip.numocts=4; |
| 2420 |
h245IpAddr->port = *(call->h245listenport); |
| 2421 |
connect->h245Address.u.ipAddress = h245IpAddr; |
| 2422 |
} |
| 2423 |
} |
| 2424 |
|
| 2425 |
OOTRACEDBGA3("Built H.225 Connect message (%s, %s)\n", call->callType, |
| 2426 |
call->callToken); |
| 2427 |
|
| 2428 |
|
| 2429 |
if(gH323ep.h225Callbacks.onBuiltConnect) |
| 2430 |
gH323ep.h225Callbacks.onBuiltConnect(call, q931msg); |
| 2431 |
|
| 2432 |
ret=ooSendH225Msg(call, q931msg); |
| 2433 |
if(ret != OO_OK) |
| 2434 |
{ |
| 2435 |
OOTRACEERR3("Error:Failed to enqueue Connect message to outbound queue.(%s, %s)\n", call->callType, call->callToken); |
| 2436 |
|
| 2437 |
memReset(call->msgctxt); |
| 2438 |
return OO_FAILED; |
| 2439 |
} |
| 2440 |
|
| 2441 |
ooSendTCSandMSD(call); |
| 2442 |
memReset(call->msgctxt); |
| 2443 |
|
| 2444 |
call->callState = OO_CALL_CONNECTED; |
| 2445 |
|
| 2446 |
if (call->rtdrCount > 0 && call->rtdrInterval > 0) { |
| 2447 |
return ooSendRoundTripDelayRequest(call); |
| 2448 |
} |
| 2449 |
return OO_OK; |
| 2450 |
} |
| 2451 |
|
| 2452 |
int ooH323HandleCallFwdRequest(OOH323CallData *call) |
| 2453 |
{ |
| 2454 |
OOH323CallData *fwdedCall=NULL; |
| 2455 |
OOCTXT *pctxt; |
| 2456 |
ooAliases *pNewAlias=NULL, *alias=NULL; |
| 2457 |
struct timespec ts; |
| 2458 |
struct timeval tv; |
| 2459 |
int i=0, irand=0; |
| 2460 |
|
| 2461 |
|
| 2462 |
|
| 2463 |
fwdedCall = ooCreateCall("outgoing", call->callToken); |
| 2464 |
|
| 2465 |
pctxt = fwdedCall->pctxt; |
| 2466 |
|
| 2467 |
|
| 2468 |
if(!ooUtilsIsStrEmpty(call->pCallFwdData->ip)) |
| 2469 |
{ |
| 2470 |
strcpy(fwdedCall->remoteIP, call->pCallFwdData->ip); |
| 2471 |
} |
| 2472 |
fwdedCall->remotePort = call->pCallFwdData->port; |
| 2473 |
|
| 2474 |
if(call->pCallFwdData->aliases) |
| 2475 |
{ |
| 2476 |
alias = call->pCallFwdData->aliases; |
| 2477 |
while(alias) |
| 2478 |
{ |
| 2479 |
pNewAlias = (ooAliases*) memAllocZ(pctxt, sizeof(ooAliases)); |
| 2480 |
if (pNewAlias) { |
| 2481 |
pNewAlias->value = (char*) memAllocZ(pctxt, strlen(alias->value)+1); |
| 2482 |
} |
| 2483 |
if(!pNewAlias || !pNewAlias->value) |
| 2484 |
{ |
| 2485 |
OOTRACEERR3("Error:Memory - ooH323HandleCallFwdRequest - " |
| 2486 |
"pNewAlias/pNewAlias->value" |
| 2487 |
"(%s, %s)\n", call->callType, call->callToken); |
| 2488 |
ooCleanCall(fwdedCall); |
| 2489 |
return OO_FAILED; |
| 2490 |
} |
| 2491 |
pNewAlias->type = alias->type; |
| 2492 |
strcpy(pNewAlias->value, alias->value); |
| 2493 |
pNewAlias->next = fwdedCall->remoteAliases; |
| 2494 |
fwdedCall->remoteAliases = pNewAlias; |
| 2495 |
alias = alias->next; |
| 2496 |
pNewAlias = NULL; |
| 2497 |
} |
| 2498 |
} |
| 2499 |
|
| 2500 |
fwdedCall->callReference = ooGenerateCallReference(); |
| 2501 |
ooGenerateCallIdentifier(&fwdedCall->callIdentifier); |
| 2502 |
fwdedCall->confIdentifier.numocts = 16; |
| 2503 |
irand = rand(); |
| 2504 |
for (i = 0; i < 16; i++) { |
| 2505 |
fwdedCall->confIdentifier.data[i] = irand++; |
| 2506 |
} |
| 2507 |
|
| 2508 |
|
| 2509 |
if(gH323ep.gkClient && !OO_TESTFLAG(fwdedCall->flags, OO_M_DISABLEGK)) |
| 2510 |
{ |
| 2511 |
|
| 2512 |
|
| 2513 |
ooGkClientSendAdmissionRequest(gH323ep.gkClient, fwdedCall, FALSE); |
| 2514 |
fwdedCall->callState = OO_CALL_WAITING_ADMISSION; |
| 2515 |
ast_mutex_lock(&fwdedCall->Lock); |
| 2516 |
tv = ast_tvnow(); |
| 2517 |
ts.tv_sec += tv.tv_sec + 24; |
| 2518 |
ts.tv_nsec = tv.tv_usec * 1000; |
| 2519 |
ast_cond_timedwait(&fwdedCall->gkWait, &fwdedCall->Lock, &ts); |
| 2520 |
if (fwdedCall->callState == OO_CALL_WAITING_ADMISSION) |
| 2521 |
fwdedCall->callState = OO_CALL_CLEAR; |
| 2522 |
ast_mutex_unlock(&fwdedCall->Lock); |
| 2523 |
|
| 2524 |
} |
| 2525 |
if (fwdedCall->callState < OO_CALL_CLEAR) { |
| 2526 |
ast_mutex_lock(&fwdedCall->Lock); |
| 2527 |
ooH323CallAdmitted (fwdedCall); |
| 2528 |
ast_mutex_unlock(&fwdedCall->Lock); |
| 2529 |
} |
| 2530 |
|
| 2531 |
return OO_OK; |
| 2532 |
|
| 2533 |
} |
| 2534 |
|
| 2535 |
int ooH323NewCall(char *callToken) { |
| 2536 |
OOH323CallData* call; |
| 2537 |
if(!callToken) |
| 2538 |
{ |
| 2539 |
OOTRACEERR1("ERROR: Invalid callToken parameter to make call\n"); |
| 2540 |
return OO_FAILED; |
| 2541 |
} |
| 2542 |
call = ooCreateCall("outgoing", callToken); |
| 2543 |
if (!call) |
| 2544 |
{ |
| 2545 |
OOTRACEERR1("ERROR: Can't create call %s\n"); |
| 2546 |
return OO_FAILED; |
| 2547 |
} |
| 2548 |
|
| 2549 |
return OO_OK; |
| 2550 |
} |
| 2551 |
|
| 2552 |
int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts) |
| 2553 |
{ |
| 2554 |
OOH323CallData *call; |
| 2555 |
int ret=OO_OK, i=0, irand=0; |
| 2556 |
char tmp[2+8*4+7]="\0"; |
| 2557 |
char *ip=NULL, *port = NULL; |
| 2558 |
struct timeval tv; |
| 2559 |
struct timespec ts; |
| 2560 |
struct ast_sockaddr m_addr; |
| 2561 |
|
| 2562 |
if(!dest) |
| 2563 |
{ |
| 2564 |
OOTRACEERR1("ERROR:Invalid destination for new call\n"); |
| 2565 |
return OO_FAILED; |
| 2566 |
} |
| 2567 |
if(!callToken) |
| 2568 |
{ |
| 2569 |
OOTRACEERR1("ERROR: Invalid callToken parameter to make call\n"); |
| 2570 |
return OO_FAILED; |
| 2571 |
} |
| 2572 |
|
| 2573 |
|
| 2574 |
call = ooFindCallByToken(callToken); |
| 2575 |
if (!call) |
| 2576 |
{ |
| 2577 |
OOTRACEERR1("ERROR: Can't create call %s\n"); |
| 2578 |
return OO_FAILED; |
| 2579 |
} |
| 2580 |
|
| 2581 |
if(opts) |
| 2582 |
{ |
| 2583 |
if(opts->fastStart) |
| 2584 |
OO_SETFLAG(call->flags, OO_M_FASTSTART); |
| 2585 |
else |
| 2586 |
OO_CLRFLAG(call->flags, OO_M_FASTSTART); |
| 2587 |
|
| 2588 |
if(opts->tunneling) |
| 2589 |
OO_SETFLAG(call->flags, OO_M_TUNNELING); |
| 2590 |
else |
| 2591 |
OO_CLRFLAG(call->flags, OO_M_TUNNELING); |
| 2592 |
|
| 2593 |
if(opts->disableGk || gH323ep.gkClient == NULL) |
| 2594 |
OO_SETFLAG(call->flags, OO_M_DISABLEGK); |
| 2595 |
else |
| 2596 |
OO_CLRFLAG(call->flags, OO_M_DISABLEGK); |
| 2597 |
|
| 2598 |
call->callMode = opts->callMode; |
| 2599 |
call->transfercap = opts->transfercap; |
| 2600 |
} |
| 2601 |
|
| 2602 |
|
| 2603 |
ret = ooParseDestination(call, dest, tmp, 2+8*4+7, &call->remoteAliases); |
| 2604 |
if(ret != OO_OK) |
| 2605 |
{ |
| 2606 |
OOTRACEERR2("Error: Failed to parse the destination string %s for " |
| 2607 |
"new call\n", dest); |
| 2608 |
ooCleanCall(call); |
| 2609 |
return OO_FAILED; |
| 2610 |
} |
| 2611 |
|
| 2612 |
|
| 2613 |
if(!ooUtilsIsStrEmpty(tmp)) { |
| 2614 |
ip = tmp; |
| 2615 |
port = strrchr(tmp, ':'); |
| 2616 |
*port = '\0'; |
| 2617 |
port++; |
| 2618 |
strcpy(call->remoteIP, ip); |
| 2619 |
ast_parse_arg(ip, PARSE_ADDR, &m_addr); |
| 2620 |
if (ast_sockaddr_is_ipv6(&m_addr)) |
| 2621 |
call->versionIP = 6; |
| 2622 |
else |
| 2623 |
call->versionIP = 4; |
| 2624 |
call->remotePort = atoi(port); |
| 2625 |
} |
| 2626 |
|
| 2627 |
strcpy(callToken, call->callToken); |
| 2628 |
call->callReference = ooGenerateCallReference(); |
| 2629 |
ooGenerateCallIdentifier(&call->callIdentifier); |
| 2630 |
call->confIdentifier.numocts = 16; |
| 2631 |
irand = rand(); |
| 2632 |
for (i = 0; i < 16; i++) { |
| 2633 |
call->confIdentifier.data[i] = irand++; |
| 2634 |
} |
| 2635 |
|
| 2636 |
|
| 2637 |
if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) |
| 2638 |
{ |
| 2639 |
if(gH323ep.gkClient->state == GkClientRegistered) { |
| 2640 |
call->callState = OO_CALL_WAITING_ADMISSION; |
| 2641 |
ast_mutex_lock(&call->GkLock); |
| 2642 |
ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE); |
| 2643 |
tv = ast_tvnow(); |
| 2644 |
ts.tv_sec = tv.tv_sec + 24; |
| 2645 |
ts.tv_nsec = tv.tv_usec * 1000; |
| 2646 |
if (call->callState == OO_CALL_WAITING_ADMISSION) |
| 2647 |
ast_cond_timedwait(&call->gkWait, &call->GkLock, &ts); |
| 2648 |
if (call->callState == OO_CALL_WAITING_ADMISSION) |
| 2649 |
call->callState = OO_CALL_CLEAR; |
| 2650 |
ast_mutex_unlock(&call->GkLock); |
| 2651 |
} else { |
| 2652 |
OOTRACEERR1("Error:Aborting outgoing call as not yet" |
| 2653 |
"registered with Gk\n"); |
| 2654 |
call->callState = OO_CALL_CLEAR; |
| 2655 |
call->callEndReason = OO_REASON_GK_UNREACHABLE; |
| 2656 |
} |
| 2657 |
|
| 2658 |
} |
| 2659 |
|
| 2660 |
|
| 2661 |
ast_mutex_lock(&call->Lock); |
| 2662 |
if (call->callState < OO_CALL_CLEAR) { |
| 2663 |
if ((ret = ooH323CallAdmitted (call)) != OO_OK) { |
| 2664 |
ast_mutex_unlock(&call->Lock); |
| 2665 |
return ret; |
| 2666 |
} |
| 2667 |
} else ret = OO_FAILED; |
| 2668 |
ast_mutex_unlock(&call->Lock); |
| 2669 |
|
| 2670 |
return ret; |
| 2671 |
} |
| 2672 |
|
| 2673 |
|
| 2674 |
int ooH323CallAdmitted(OOH323CallData *call) |
| 2675 |
{ |
| 2676 |
int ret=0; |
| 2677 |
|
| 2678 |
if(!call) |
| 2679 |
{ |
| 2680 |
|
| 2681 |
OOTRACEERR1("ERROR: Invalid call parameter to ooH323CallAdmitted"); |
| 2682 |
return OO_FAILED; |
| 2683 |
} |
| 2684 |
|
| 2685 |
if(!strcmp(call->callType, "outgoing")) { |
| 2686 |
ret = ooCreateH225Connection(call); |
| 2687 |
if(ret != OO_OK) |
| 2688 |
{ |
| 2689 |
OOTRACEERR3("ERROR:Failed to create H225 connection to %s:%d\n", |
| 2690 |
call->remoteIP, call->remotePort); |
| 2691 |
if(call->callState< OO_CALL_CLEAR) |
| 2692 |
{ |
| 2693 |
call->callState = OO_CALL_CLEAR; |
| 2694 |
call->callEndReason = OO_REASON_UNKNOWN; |
| 2695 |
} |
| 2696 |
return OO_FAILED; |
| 2697 |
} |
| 2698 |
|
| 2699 |
if(gH323ep.h323Callbacks.onOutgoingCall) { |
| 2700 |
|
| 2701 |
if (gH323ep.h323Callbacks.onOutgoingCall(call) != OO_OK) { |
| 2702 |
OOTRACEERR3("ERROR:Failed to setup media to (%s,%d)\n", |
| 2703 |
call->callType, call->callToken); |
| 2704 |
if(call->callState< OO_CALL_CLEAR) |
| 2705 |
{ |
| 2706 |
call->callState = OO_CALL_CLEAR; |
| 2707 |
call->callEndReason = OO_REASON_UNKNOWN; |
| 2708 |
} |
| 2709 |
return OO_FAILED; |
| 2710 |
} |
| 2711 |
} |
| 2712 |
|
| 2713 |
ret = ooH323MakeCall_helper(call); |
| 2714 |
} |
| 2715 |
else { |
| 2716 |
|
| 2717 |
if(gH323ep.h323Callbacks.onIncomingCall) { |
| 2718 |
|
| 2719 |
gH323ep.h323Callbacks.onIncomingCall(call); |
| 2720 |
} |
| 2721 |
|
| 2722 |
|
| 2723 |
if(!OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK)) |
| 2724 |
{ |
| 2725 |
ooSendAlerting(call); |
| 2726 |
|
| 2727 |
if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) { |
| 2728 |
ooSendConnect(call); |
| 2729 |
} |
| 2730 |
} |
| 2731 |
} |
| 2732 |
|
| 2733 |
return OO_OK; |
| 2734 |
} |
| 2735 |
|
| 2736 |
int ooH323MakeCall_helper(OOH323CallData *call) |
| 2737 |
{ |
| 2738 |
int ret=0,i=0, k; |
| 2739 |
Q931Message *q931msg = NULL; |
| 2740 |
H225Setup_UUIE *setup; |
| 2741 |
|
| 2742 |
ASN1DynOctStr *pFS=NULL; |
| 2743 |
H225TransportAddress_ipAddress *destCallSignalIpAddress,*srcCallSignalIpAddress; |
| 2744 |
H225TransportAddress_ip6Address *destCallSignalIp6Address,*srcCallSignalIp6Address; |
| 2745 |
ooH323EpCapability *epCap=NULL; |
| 2746 |
OOCTXT *pctxt = NULL; |
| 2747 |
H245OpenLogicalChannel *olc, printOlc; |
| 2748 |
ASN1BOOL aligned = 1; |
| 2749 |
ooAliases *pAlias = NULL; |
| 2750 |
|
| 2751 |
|
| 2752 |
pctxt = call->msgctxt; |
| 2753 |
|
| 2754 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931SetupMsg); |
| 2755 |
if(ret != OO_OK) |
| 2756 |
{ |
| 2757 |
OOTRACEERR1("ERROR:Failed to Create Q931 SETUP Message\n "); |
| 2758 |
return OO_FAILED; |
| 2759 |
} |
| 2760 |
|
| 2761 |
q931msg->callReference = call->callReference; |
| 2762 |
|
| 2763 |
|
| 2764 |
if(OO_OK != ooSetBearerCapabilityIE(pctxt, q931msg, Q931CCITTStd, |
| 2765 |
|
| 2766 |
call->transfercap, Q931TransferCircuitMode, |
| 2767 |
|
| 2768 |
Q931TransferRate64Kbps, Q931UserInfoLayer1G711ALaw)) |
| 2769 |
{ |
| 2770 |
OOTRACEERR3("Error: Failed to set bearer capability ie.(%s, %s)\n", |
| 2771 |
call->callType, call->callToken); |
| 2772 |
return OO_FAILED; |
| 2773 |
} |
| 2774 |
|
| 2775 |
|
| 2776 |
if(call->callingPartyNumber && call->callingPartyNumber[0]) |
| 2777 |
ooQ931SetCallingPartyNumberIE(pctxt, q931msg, |
| 2778 |
(const char*)call->callingPartyNumber, 1, 0, 0, 0); |
| 2779 |
|
| 2780 |
|
| 2781 |
|
| 2782 |
if(call->calledPartyNumber) |
| 2783 |
ooQ931SetCalledPartyNumberIE(pctxt, q931msg, |
| 2784 |
(const char*)call->calledPartyNumber, 1, 0); |
| 2785 |
else if(call->remoteAliases) { |
| 2786 |
pAlias = call->remoteAliases; |
| 2787 |
while(pAlias) { |
| 2788 |
if(pAlias->type == T_H225AliasAddress_dialedDigits) |
| 2789 |
break; |
| 2790 |
pAlias = pAlias->next; |
| 2791 |
} |
| 2792 |
if(pAlias) |
| 2793 |
{ |
| 2794 |
call->calledPartyNumber = (char*)memAlloc(call->pctxt, |
| 2795 |
strlen(pAlias->value)+1); |
| 2796 |
if(!call->calledPartyNumber) |
| 2797 |
{ |
| 2798 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - " |
| 2799 |
"calledPartyNumber(%s, %s)\n", call->callType, |
| 2800 |
call->callToken); |
| 2801 |
return OO_FAILED; |
| 2802 |
} |
| 2803 |
strcpy(call->calledPartyNumber, pAlias->value); |
| 2804 |
ooQ931SetCalledPartyNumberIE(pctxt, q931msg, |
| 2805 |
(const char*)call->calledPartyNumber, 1, 0); |
| 2806 |
} |
| 2807 |
|
| 2808 |
} |
| 2809 |
|
| 2810 |
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 2811 |
sizeof(H225H323_UserInformation)); |
| 2812 |
if(!q931msg->userInfo) |
| 2813 |
{ |
| 2814 |
OOTRACEERR1("ERROR:Memory - ooH323MakeCall_helper - userInfo\n"); |
| 2815 |
return OO_FAILED; |
| 2816 |
} |
| 2817 |
memset(q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 2818 |
|
| 2819 |
setup = (H225Setup_UUIE*) memAlloc(pctxt, sizeof(H225Setup_UUIE)); |
| 2820 |
if(!setup) |
| 2821 |
{ |
| 2822 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - setup (%s, %s)\n", |
| 2823 |
call->callType, call->callToken); |
| 2824 |
return OO_FAILED; |
| 2825 |
} |
| 2826 |
memset (setup, 0, sizeof(H225Setup_UUIE)); |
| 2827 |
setup->protocolIdentifier = gProtocolID; |
| 2828 |
|
| 2829 |
|
| 2830 |
|
| 2831 |
if(call->ourAliases || gH323ep.aliases) |
| 2832 |
{ |
| 2833 |
setup->m.sourceAddressPresent = TRUE; |
| 2834 |
if(call->ourAliases) |
| 2835 |
ret = ooPopulateAliasList(pctxt, call->ourAliases, |
| 2836 |
&setup->sourceAddress, 0); |
| 2837 |
else if(gH323ep.aliases) |
| 2838 |
ret = ooPopulateAliasList(pctxt, gH323ep.aliases, |
| 2839 |
&setup->sourceAddress, 0); |
| 2840 |
if(OO_OK != ret) |
| 2841 |
{ |
| 2842 |
OOTRACEERR1("Error:Failed to populate alias list in SETUP message\n"); |
| 2843 |
memReset(pctxt); |
| 2844 |
return OO_FAILED; |
| 2845 |
} |
| 2846 |
} |
| 2847 |
|
| 2848 |
setup->m.presentationIndicatorPresent = TRUE; |
| 2849 |
setup->presentationIndicator.t = |
| 2850 |
T_H225PresentationIndicator_presentationAllowed; |
| 2851 |
setup->m.screeningIndicatorPresent = TRUE; |
| 2852 |
setup->screeningIndicator = userProvidedNotScreened; |
| 2853 |
|
| 2854 |
setup->m.multipleCallsPresent = TRUE; |
| 2855 |
setup->multipleCalls = FALSE; |
| 2856 |
setup->m.maintainConnectionPresent = TRUE; |
| 2857 |
setup->maintainConnection = FALSE; |
| 2858 |
|
| 2859 |
|
| 2860 |
if(call->remoteAliases) |
| 2861 |
{ |
| 2862 |
setup->m.destinationAddressPresent = TRUE; |
| 2863 |
ret = ooPopulateAliasList(pctxt, call->remoteAliases, |
| 2864 |
&setup->destinationAddress, 0); |
| 2865 |
if(OO_OK != ret) |
| 2866 |
{ |
| 2867 |
OOTRACEERR1("Error:Failed to populate destination alias list in SETUP" |
| 2868 |
"message\n"); |
| 2869 |
memReset(pctxt); |
| 2870 |
return OO_FAILED; |
| 2871 |
} |
| 2872 |
} |
| 2873 |
|
| 2874 |
|
| 2875 |
if(gH323ep.isGateway) |
| 2876 |
setup->sourceInfo.m.gatewayPresent = TRUE; |
| 2877 |
else |
| 2878 |
setup->sourceInfo.m.terminalPresent = TRUE; |
| 2879 |
|
| 2880 |
setup->sourceInfo.m.vendorPresent=TRUE; |
| 2881 |
setup->sourceInfo.vendor.vendor.t35CountryCode = gH323ep.t35CountryCode; |
| 2882 |
setup->sourceInfo.vendor.vendor.t35Extension = gH323ep.t35Extension; |
| 2883 |
setup->sourceInfo.vendor.vendor.manufacturerCode= gH323ep.manufacturerCode; |
| 2884 |
|
| 2885 |
if(gH323ep.productID) |
| 2886 |
{ |
| 2887 |
setup->sourceInfo.vendor.m.productIdPresent=TRUE; |
| 2888 |
setup->sourceInfo.vendor.productId.numocts = ASN1MIN( |
| 2889 |
strlen(gH323ep.productID), |
| 2890 |
sizeof(setup->sourceInfo.vendor.productId.data)); |
| 2891 |
strncpy((char*)setup->sourceInfo.vendor.productId.data, |
| 2892 |
gH323ep.productID, setup->sourceInfo.vendor.productId.numocts); |
| 2893 |
} |
| 2894 |
else |
| 2895 |
setup->sourceInfo.vendor.m.productIdPresent=FALSE; |
| 2896 |
|
| 2897 |
if(gH323ep.versionID) |
| 2898 |
{ |
| 2899 |
setup->sourceInfo.vendor.m.versionIdPresent=TRUE; |
| 2900 |
setup->sourceInfo.vendor.versionId.numocts = ASN1MIN( |
| 2901 |
strlen(gH323ep.versionID), |
| 2902 |
sizeof(setup->sourceInfo.vendor.versionId.data)); |
| 2903 |
strncpy((char*)setup->sourceInfo.vendor.versionId.data, |
| 2904 |
gH323ep.versionID, setup->sourceInfo.vendor.versionId.numocts); |
| 2905 |
} |
| 2906 |
else |
| 2907 |
setup->sourceInfo.vendor.m.versionIdPresent=FALSE; |
| 2908 |
|
| 2909 |
setup->sourceInfo.mc = FALSE; |
| 2910 |
setup->sourceInfo.undefinedNode = FALSE; |
| 2911 |
|
| 2912 |
|
| 2913 |
setup->m.destCallSignalAddressPresent=TRUE; |
| 2914 |
setup->activeMC=FALSE; |
| 2915 |
if (call->versionIP == 6) { |
| 2916 |
setup->destCallSignalAddress.t=T_H225TransportAddress_ip6Address; |
| 2917 |
destCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt, |
| 2918 |
sizeof(H225TransportAddress_ip6Address)); |
| 2919 |
if(!destCallSignalIp6Address) |
| 2920 |
{ |
| 2921 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - " |
| 2922 |
"destCallSignal6Address. (%s, %s)\n", call->callType, |
| 2923 |
call->callToken); |
| 2924 |
return OO_FAILED; |
| 2925 |
} |
| 2926 |
inet_pton(AF_INET6, call->remoteIP, destCallSignalIp6Address->ip.data); |
| 2927 |
|
| 2928 |
destCallSignalIp6Address->ip.numocts=16; |
| 2929 |
destCallSignalIp6Address->port = call->remotePort; |
| 2930 |
|
| 2931 |
setup->destCallSignalAddress.u.ip6Address = destCallSignalIp6Address; |
| 2932 |
} else { |
| 2933 |
setup->destCallSignalAddress.t=T_H225TransportAddress_ipAddress; |
| 2934 |
destCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, |
| 2935 |
sizeof(H225TransportAddress_ipAddress)); |
| 2936 |
if(!destCallSignalIpAddress) |
| 2937 |
{ |
| 2938 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - " |
| 2939 |
"destCallSignalAddress. (%s, %s)\n", call->callType, |
| 2940 |
call->callToken); |
| 2941 |
return OO_FAILED; |
| 2942 |
} |
| 2943 |
inet_pton(AF_INET, call->remoteIP, destCallSignalIpAddress->ip.data); |
| 2944 |
|
| 2945 |
destCallSignalIpAddress->ip.numocts=4; |
| 2946 |
destCallSignalIpAddress->port = call->remotePort; |
| 2947 |
|
| 2948 |
setup->destCallSignalAddress.u.ipAddress = destCallSignalIpAddress; |
| 2949 |
} |
| 2950 |
|
| 2951 |
|
| 2952 |
setup->m.sourceCallSignalAddressPresent=TRUE; |
| 2953 |
if (call->versionIP == 6) { |
| 2954 |
setup->sourceCallSignalAddress.t=T_H225TransportAddress_ip6Address; |
| 2955 |
srcCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt, |
| 2956 |
sizeof(H225TransportAddress_ip6Address)); |
| 2957 |
if(!srcCallSignalIp6Address) |
| 2958 |
{ |
| 2959 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - srcCallSignal6Address" |
| 2960 |
"(%s, %s)\n", call->callType, call->callToken); |
| 2961 |
return OO_FAILED; |
| 2962 |
} |
| 2963 |
inet_pton(AF_INET6, call->localIP, srcCallSignalIp6Address->ip.data); |
| 2964 |
|
| 2965 |
srcCallSignalIp6Address->ip.numocts=16; |
| 2966 |
srcCallSignalIp6Address->port= call->pH225Channel->port; |
| 2967 |
setup->sourceCallSignalAddress.u.ip6Address = srcCallSignalIp6Address; |
| 2968 |
} else { |
| 2969 |
setup->sourceCallSignalAddress.t=T_H225TransportAddress_ipAddress; |
| 2970 |
srcCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, |
| 2971 |
sizeof(H225TransportAddress_ipAddress)); |
| 2972 |
if(!srcCallSignalIpAddress) |
| 2973 |
{ |
| 2974 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - srcCallSignalAddress" |
| 2975 |
"(%s, %s)\n", call->callType, call->callToken); |
| 2976 |
return OO_FAILED; |
| 2977 |
} |
| 2978 |
inet_pton(AF_INET, call->localIP, srcCallSignalIpAddress->ip.data); |
| 2979 |
|
| 2980 |
srcCallSignalIpAddress->ip.numocts=4; |
| 2981 |
srcCallSignalIpAddress->port= call->pH225Channel->port; |
| 2982 |
setup->sourceCallSignalAddress.u.ipAddress = srcCallSignalIpAddress; |
| 2983 |
} |
| 2984 |
|
| 2985 |
if(!OO_TESTFLAG(call->flags, OO_M_FASTSTART)) |
| 2986 |
{ |
| 2987 |
setup->m.fastStartPresent = FALSE; |
| 2988 |
} |
| 2989 |
else{ |
| 2990 |
setup->m.fastStartPresent = TRUE; |
| 2991 |
pFS = (ASN1DynOctStr*)memAlloc(pctxt, gH323ep.noOfCaps* |
| 2992 |
sizeof(ASN1DynOctStr)); |
| 2993 |
if(!pFS) |
| 2994 |
{ |
| 2995 |
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - pFS(%s, %s)\n", |
| 2996 |
call->callType, call->callToken); |
| 2997 |
return OO_FAILED; |
| 2998 |
} |
| 2999 |
|
| 3000 |
|
| 3001 |
i=0; |
| 3002 |
for(k=0; k< call->capPrefs.index; k++) |
| 3003 |
{ |
| 3004 |
OOTRACEDBGC5("Preffered capability at index %d is %s. (%s, %s)\n", |
| 3005 |
k, ooGetCapTypeText(call->capPrefs.order[k]), |
| 3006 |
call->callType, call->callToken); |
| 3007 |
|
| 3008 |
if(call->ourCaps) { |
| 3009 |
epCap = call->ourCaps; |
| 3010 |
OOTRACEDBGC3("Using call specific capabilities in faststart of " |
| 3011 |
"setup message. (%s, %s)\n", call->callType, |
| 3012 |
call->callToken); |
| 3013 |
} |
| 3014 |
else{ |
| 3015 |
epCap = gH323ep.myCaps; |
| 3016 |
OOTRACEDBGC3("Using end-point capabilities for faststart of setup" |
| 3017 |
"message. (%s, %s)\n", call->callType, |
| 3018 |
call->callToken); |
| 3019 |
} |
| 3020 |
|
| 3021 |
while(epCap){ |
| 3022 |
if(epCap->cap == call->capPrefs.order[k]) break; |
| 3023 |
else epCap = epCap->next; |
| 3024 |
} |
| 3025 |
if(!epCap) |
| 3026 |
{ |
| 3027 |
OOTRACEWARN4("Warn:Preferred capability %s is absent in " |
| 3028 |
"capability list. (%s, %s)\n", |
| 3029 |
ooGetCapTypeText(call->capPrefs.order[k]), |
| 3030 |
call->callType, call->callToken); |
| 3031 |
continue; |
| 3032 |
} |
| 3033 |
|
| 3034 |
|
| 3035 |
|
| 3036 |
if (epCap->capType == OO_CAP_TYPE_DATA) |
| 3037 |
continue; |
| 3038 |
|
| 3039 |
OOTRACEDBGC4("Building olcs with capability %s. (%s, %s)\n", |
| 3040 |
ooGetCapTypeText(epCap->cap), call->callType, |
| 3041 |
call->callToken); |
| 3042 |
if(epCap->dir & OORX) |
| 3043 |
{ |
| 3044 |
olc = (H245OpenLogicalChannel*)memAlloc(pctxt, |
| 3045 |
sizeof(H245OpenLogicalChannel)); |
| 3046 |
if(!olc) |
| 3047 |
{ |
| 3048 |
OOTRACEERR3("ERROR:Memory - ooH323MakeCall_helper - olc(%s, %s)" |
| 3049 |
"\n", call->callType, call->callToken); |
| 3050 |
ooFreeQ931Message(pctxt, q931msg); |
| 3051 |
if(call->callState < OO_CALL_CLEAR) |
| 3052 |
{ |
| 3053 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3054 |
call->callState = OO_CALL_CLEAR; |
| 3055 |
} |
| 3056 |
return OO_FAILED; |
| 3057 |
} |
| 3058 |
memset(olc, 0, sizeof(H245OpenLogicalChannel)); |
| 3059 |
olc->forwardLogicalChannelNumber = call->logicalChanNoCur++; |
| 3060 |
if(call->logicalChanNoCur > call->logicalChanNoMax) |
| 3061 |
call->logicalChanNoCur = call->logicalChanNoBase; |
| 3062 |
|
| 3063 |
ooBuildFastStartOLC(call, olc, epCap, pctxt, OORX); |
| 3064 |
|
| 3065 |
setPERBuffer(pctxt, NULL, 0, aligned); |
| 3066 |
if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK) |
| 3067 |
{ |
| 3068 |
OOTRACEERR3("ERROR:Encoding of olc failed for faststart(%s, %s)" |
| 3069 |
"\n", call->callType, call->callToken); |
| 3070 |
ooFreeQ931Message(pctxt, q931msg); |
| 3071 |
if(call->callState < OO_CALL_CLEAR) |
| 3072 |
{ |
| 3073 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3074 |
call->callState = OO_CALL_CLEAR; |
| 3075 |
} |
| 3076 |
return OO_FAILED; |
| 3077 |
} |
| 3078 |
pFS[i].data = (unsigned char *)encodeGetMsgPtr(pctxt, (int *)&(pFS[i].numocts)); |
| 3079 |
|
| 3080 |
|
| 3081 |
|
| 3082 |
setPERBuffer(pctxt, (unsigned char*)pFS[i].data, pFS[i].numocts, 1); |
| 3083 |
initializePrintHandler(&printHandler, "FastStart Element"); |
| 3084 |
setEventHandler (pctxt, &printHandler); |
| 3085 |
memset(&printOlc, 0, sizeof(printOlc)); |
| 3086 |
ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc)); |
| 3087 |
if(ret != ASN_OK) |
| 3088 |
{ |
| 3089 |
OOTRACEERR3("Error: Failed decoding FastStart Element." |
| 3090 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3091 |
ooFreeQ931Message(pctxt, q931msg); |
| 3092 |
if(call->callState < OO_CALL_CLEAR) |
| 3093 |
{ |
| 3094 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3095 |
call->callState = OO_CALL_CLEAR; |
| 3096 |
} |
| 3097 |
return OO_FAILED; |
| 3098 |
} |
| 3099 |
finishPrint(); |
| 3100 |
removeEventHandler(pctxt); |
| 3101 |
|
| 3102 |
|
| 3103 |
olc = NULL; |
| 3104 |
i++; |
| 3105 |
OOTRACEDBGC5("Added RX fs element %d with capability %s(%s, %s)\n", |
| 3106 |
i, ooGetCapTypeText(epCap->cap), call->callType, |
| 3107 |
call->callToken); |
| 3108 |
} |
| 3109 |
|
| 3110 |
if(epCap->dir & OOTX) |
| 3111 |
{ |
| 3112 |
olc = (H245OpenLogicalChannel*)memAlloc(pctxt, |
| 3113 |
sizeof(H245OpenLogicalChannel)); |
| 3114 |
if(!olc) |
| 3115 |
{ |
| 3116 |
OOTRACEERR3("ERROR:Memory - ooH323MakeCall_helper - olc(%s, %s)" |
| 3117 |
"\n", call->callType, call->callToken); |
| 3118 |
ooFreeQ931Message(pctxt, q931msg); |
| 3119 |
if(call->callState < OO_CALL_CLEAR) |
| 3120 |
{ |
| 3121 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3122 |
call->callState = OO_CALL_CLEAR; |
| 3123 |
} |
| 3124 |
return OO_FAILED; |
| 3125 |
} |
| 3126 |
memset(olc, 0, sizeof(H245OpenLogicalChannel)); |
| 3127 |
olc->forwardLogicalChannelNumber = call->logicalChanNoCur++; |
| 3128 |
if(call->logicalChanNoCur > call->logicalChanNoMax) |
| 3129 |
call->logicalChanNoCur = call->logicalChanNoBase; |
| 3130 |
|
| 3131 |
ooBuildFastStartOLC(call, olc, epCap, pctxt, OOTX); |
| 3132 |
|
| 3133 |
setPERBuffer(pctxt, NULL, 0, aligned); |
| 3134 |
if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK) |
| 3135 |
{ |
| 3136 |
OOTRACEERR3("ERROR:Encoding of olc failed for faststart(%s, %s)" |
| 3137 |
"\n", call->callType, call->callToken); |
| 3138 |
ooFreeQ931Message(pctxt, q931msg); |
| 3139 |
if(call->callState < OO_CALL_CLEAR) |
| 3140 |
{ |
| 3141 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3142 |
call->callState = OO_CALL_CLEAR; |
| 3143 |
} |
| 3144 |
return OO_FAILED; |
| 3145 |
} |
| 3146 |
pFS[i].data = (unsigned char *)encodeGetMsgPtr(pctxt, (int *)&(pFS[i].numocts)); |
| 3147 |
|
| 3148 |
|
| 3149 |
setPERBuffer(pctxt, (unsigned char*)pFS[i].data, pFS[i].numocts, 1); |
| 3150 |
initializePrintHandler(&printHandler, "FastStart Element"); |
| 3151 |
setEventHandler (pctxt, &printHandler); |
| 3152 |
memset(&printOlc, 0, sizeof(printOlc)); |
| 3153 |
ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc)); |
| 3154 |
if(ret != ASN_OK) |
| 3155 |
{ |
| 3156 |
OOTRACEERR3("Error: Failed decoding FastStart Element." |
| 3157 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3158 |
ooFreeQ931Message(pctxt, q931msg); |
| 3159 |
if(call->callState < OO_CALL_CLEAR) |
| 3160 |
{ |
| 3161 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3162 |
call->callState = OO_CALL_CLEAR; |
| 3163 |
} |
| 3164 |
return OO_FAILED; |
| 3165 |
} |
| 3166 |
finishPrint(); |
| 3167 |
removeEventHandler(pctxt); |
| 3168 |
|
| 3169 |
|
| 3170 |
olc = NULL; |
| 3171 |
i++; |
| 3172 |
OOTRACEDBGC5("Added TX fs element %d with capability %s(%s, %s)\n", |
| 3173 |
i, ooGetCapTypeText(epCap->cap), call->callType, |
| 3174 |
call->callToken); |
| 3175 |
} |
| 3176 |
|
| 3177 |
} |
| 3178 |
OOTRACEDBGA4("Added %d fast start elements to SETUP message (%s, %s)\n", |
| 3179 |
i, call->callType, call->callToken); |
| 3180 |
setup->fastStart.n = i; |
| 3181 |
setup->fastStart.elem = pFS; |
| 3182 |
} |
| 3183 |
|
| 3184 |
setup->conferenceID.numocts= call->confIdentifier.numocts; |
| 3185 |
memcpy(setup->conferenceID.data, call->confIdentifier.data, |
| 3186 |
call->confIdentifier.numocts); |
| 3187 |
|
| 3188 |
setup->conferenceGoal.t = T_H225Setup_UUIE_conferenceGoal_create; |
| 3189 |
|
| 3190 |
setup->callType.t = T_H225CallType_pointToPoint; |
| 3191 |
|
| 3192 |
|
| 3193 |
setup->m.callIdentifierPresent = TRUE; |
| 3194 |
|
| 3195 |
setup->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; |
| 3196 |
memcpy(setup->callIdentifier.guid.data, call->callIdentifier.guid.data, |
| 3197 |
call->callIdentifier.guid.numocts); |
| 3198 |
|
| 3199 |
setup->m.mediaWaitForConnectPresent = TRUE; |
| 3200 |
if(OO_TESTFLAG(call->flags, OO_M_MEDIAWAITFORCONN)) { |
| 3201 |
setup->mediaWaitForConnect = TRUE; |
| 3202 |
} |
| 3203 |
else { |
| 3204 |
setup->mediaWaitForConnect = FALSE; |
| 3205 |
} |
| 3206 |
setup->m.canOverlapSendPresent = TRUE; |
| 3207 |
setup->canOverlapSend = FALSE; |
| 3208 |
|
| 3209 |
|
| 3210 |
|
| 3211 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 3212 |
T_H225H323_UU_PDU_h323_message_body_setup; |
| 3213 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.setup = setup; |
| 3214 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 3215 |
|
| 3216 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 3217 |
OO_TESTFLAG (call->flags, OO_M_TUNNELING); |
| 3218 |
|
| 3219 |
|
| 3220 |
|
| 3221 |
|
| 3222 |
|
| 3223 |
|
| 3224 |
OOTRACEDBGA3("Built SETUP message (%s, %s)\n", call->callType, |
| 3225 |
call->callToken); |
| 3226 |
|
| 3227 |
|
| 3228 |
if(gH323ep.h225Callbacks.onBuiltSetup) |
| 3229 |
gH323ep.h225Callbacks.onBuiltSetup(call, q931msg); |
| 3230 |
|
| 3231 |
ret=ooSendH225Msg(call, q931msg); |
| 3232 |
if(ret != OO_OK) |
| 3233 |
{ |
| 3234 |
OOTRACEERR3("Error:Failed to enqueue SETUP message to outbound queue. (%s, %s)\n", call->callType, call->callToken); |
| 3235 |
} |
| 3236 |
|
| 3237 |
memReset(call->msgctxt); |
| 3238 |
|
| 3239 |
return ret; |
| 3240 |
} |
| 3241 |
|
| 3242 |
|
| 3243 |
|
| 3244 |
int ooQ931SendDTMFAsKeyPadIE(OOH323CallData *call, const char* data) |
| 3245 |
{ |
| 3246 |
int ret; |
| 3247 |
H225Information_UUIE *information=NULL; |
| 3248 |
Q931Message *q931msg=NULL; |
| 3249 |
|
| 3250 |
OOCTXT *pctxt = call->msgctxt; |
| 3251 |
|
| 3252 |
ret = ooCreateQ931Message(pctxt, &q931msg, Q931InformationMsg); |
| 3253 |
if(ret != OO_OK) |
| 3254 |
{ |
| 3255 |
OOTRACEERR3("Error: In allocating memory for - H225 Information message." |
| 3256 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3257 |
return OO_FAILED; |
| 3258 |
} |
| 3259 |
|
| 3260 |
q931msg->callReference = call->callReference; |
| 3261 |
|
| 3262 |
q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt, |
| 3263 |
sizeof(H225H323_UserInformation)); |
| 3264 |
if(!q931msg->userInfo) |
| 3265 |
{ |
| 3266 |
OOTRACEERR3("ERROR:Memory - ooQ931SendDTMFAsKeypadIE - userInfo" |
| 3267 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3268 |
|
| 3269 |
memReset(call->msgctxt); |
| 3270 |
return OO_FAILED; |
| 3271 |
} |
| 3272 |
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 3273 |
q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, |
| 3274 |
OO_M_TUNNELING); |
| 3275 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 3276 |
T_H225H323_UU_PDU_h323_message_body_information; |
| 3277 |
|
| 3278 |
information = (H225Information_UUIE*)memAllocZ(pctxt, |
| 3279 |
sizeof(H225Information_UUIE)); |
| 3280 |
if(!information) |
| 3281 |
{ |
| 3282 |
OOTRACEERR3("ERROR:Memory - ooQ931SendDTMFAsKeypadIE - information" |
| 3283 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3284 |
|
| 3285 |
memReset(call->msgctxt); |
| 3286 |
return OO_FAILED; |
| 3287 |
} |
| 3288 |
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.information = |
| 3289 |
information; |
| 3290 |
information->m.callIdentifierPresent = 1; |
| 3291 |
information->callIdentifier.guid.numocts = |
| 3292 |
call->callIdentifier.guid.numocts; |
| 3293 |
memcpy(information->callIdentifier.guid.data, |
| 3294 |
call->callIdentifier.guid.data, |
| 3295 |
call->callIdentifier.guid.numocts); |
| 3296 |
information->protocolIdentifier = gProtocolID; |
| 3297 |
|
| 3298 |
|
| 3299 |
ret = ooQ931SetKeypadIE(pctxt, q931msg, data); |
| 3300 |
if(ret != OO_OK) |
| 3301 |
{ |
| 3302 |
OOTRACEERR3("Error:Creating keypad IE for (%s, %s)\n", call->callType, |
| 3303 |
call->callToken); |
| 3304 |
|
| 3305 |
memReset(call->msgctxt); |
| 3306 |
return OO_FAILED; |
| 3307 |
} |
| 3308 |
|
| 3309 |
ret=ooSendH225Msg(call, q931msg); |
| 3310 |
if(ret != OO_OK) |
| 3311 |
{ |
| 3312 |
OOTRACEERR3("Error:Failed to enqueue Information message to outbound " |
| 3313 |
"queue. (%s, %s)\n", call->callType, call->callToken); |
| 3314 |
} |
| 3315 |
|
| 3316 |
memReset(call->msgctxt); |
| 3317 |
|
| 3318 |
return ret; |
| 3319 |
|
| 3320 |
} |
| 3321 |
|
| 3322 |
int ooH323ForwardCall(char* callToken, char *dest) |
| 3323 |
{ |
| 3324 |
int ret=0; |
| 3325 |
Q931Message *pQ931Msg = NULL; |
| 3326 |
H225Facility_UUIE *facility=NULL; |
| 3327 |
OOCTXT *pctxt = &gH323ep.msgctxt; |
| 3328 |
OOH323CallData *call; |
| 3329 |
char ip[2+8*4+7]="\0", *pcPort=NULL; |
| 3330 |
H225TransportAddress_ipAddress *fwdCallSignalIpAddress; |
| 3331 |
H225TransportAddress_ip6Address *fwdCallSignalIp6Address; |
| 3332 |
|
| 3333 |
call= ooFindCallByToken(callToken); |
| 3334 |
if(!call) |
| 3335 |
{ |
| 3336 |
OOTRACEERR2("ERROR: Invalid call token for forward - %s\n", callToken); |
| 3337 |
return OO_FAILED; |
| 3338 |
} |
| 3339 |
OOTRACEDBGA3("Building Facility message for call forward (%s, %s)\n", |
| 3340 |
call->callType, call->callToken); |
| 3341 |
call->pCallFwdData = (OOCallFwdData*)memAllocZ(call->pctxt, |
| 3342 |
sizeof(OOCallFwdData)); |
| 3343 |
if(!call->pCallFwdData) |
| 3344 |
{ |
| 3345 |
OOTRACEERR3("Error:Memory - ooH323ForwardCall - pCallFwdData (%s, %s)\n", |
| 3346 |
call->callType, call->callToken); |
| 3347 |
return OO_FAILED; |
| 3348 |
} |
| 3349 |
|
| 3350 |
ret = ooParseDestination(call, dest, ip, 2+8*4+7, |
| 3351 |
&call->pCallFwdData->aliases); |
| 3352 |
if(ret != OO_OK) |
| 3353 |
{ |
| 3354 |
OOTRACEERR4("Error:Failed to parse the destination %s for call fwd." |
| 3355 |
"(%s, %s)\n", dest, call->callType, call->callToken); |
| 3356 |
memFreePtr(call->pctxt, call->pCallFwdData); |
| 3357 |
return OO_FAILED; |
| 3358 |
} |
| 3359 |
|
| 3360 |
if(!ooUtilsIsStrEmpty(ip)) |
| 3361 |
{ |
| 3362 |
pcPort = strrchr(ip, ':'); |
| 3363 |
if(pcPort) |
| 3364 |
{ |
| 3365 |
*pcPort = '\0'; |
| 3366 |
pcPort++; |
| 3367 |
call->pCallFwdData->port = atoi(pcPort); |
| 3368 |
} |
| 3369 |
strcpy(call->pCallFwdData->ip, ip); |
| 3370 |
} |
| 3371 |
|
| 3372 |
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); |
| 3373 |
if(ret != OO_OK) |
| 3374 |
{ |
| 3375 |
OOTRACEERR3 |
| 3376 |
("ERROR: In allocating memory for call transfer facility message " |
| 3377 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3378 |
return OO_FAILED; |
| 3379 |
} |
| 3380 |
|
| 3381 |
pQ931Msg->callReference = call->callReference; |
| 3382 |
|
| 3383 |
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 3384 |
sizeof(H225H323_UserInformation)); |
| 3385 |
if(!pQ931Msg->userInfo) |
| 3386 |
{ |
| 3387 |
OOTRACEERR3("ERROR:Memory - ooH323ForwardCall - userInfo(%s, %s)\n", |
| 3388 |
call->callType, call->callToken); |
| 3389 |
return OO_FAILED; |
| 3390 |
} |
| 3391 |
memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 3392 |
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 3393 |
|
| 3394 |
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 3395 |
OO_TESTFLAG (call->flags, OO_M_TUNNELING); |
| 3396 |
|
| 3397 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 3398 |
T_H225H323_UU_PDU_h323_message_body_facility; |
| 3399 |
|
| 3400 |
facility = (H225Facility_UUIE*) |
| 3401 |
memAllocZ (pctxt, sizeof(H225Facility_UUIE)); |
| 3402 |
|
| 3403 |
if(!facility) |
| 3404 |
{ |
| 3405 |
OOTRACEERR3("ERROR:Memory - ooH323ForwardCall - facility (%s, %s)" |
| 3406 |
"\n", call->callType, call->callToken); |
| 3407 |
return OO_FAILED; |
| 3408 |
} |
| 3409 |
|
| 3410 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; |
| 3411 |
|
| 3412 |
facility->protocolIdentifier = gProtocolID; |
| 3413 |
facility->m.callIdentifierPresent = 1; |
| 3414 |
facility->callIdentifier.guid.numocts = |
| 3415 |
call->callIdentifier.guid.numocts; |
| 3416 |
|
| 3417 |
memcpy(facility->callIdentifier.guid.data, |
| 3418 |
call->callIdentifier.guid.data, |
| 3419 |
call->callIdentifier.guid.numocts); |
| 3420 |
|
| 3421 |
facility->reason.t = T_H225FacilityReason_callForwarded; |
| 3422 |
|
| 3423 |
if(!ooUtilsIsStrEmpty(call->pCallFwdData->ip)) |
| 3424 |
{ |
| 3425 |
facility->m.alternativeAddressPresent = TRUE; |
| 3426 |
if (call->versionIP == 6) { |
| 3427 |
facility->alternativeAddress.t=T_H225TransportAddress_ip6Address; |
| 3428 |
fwdCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt, |
| 3429 |
sizeof(H225TransportAddress_ip6Address)); |
| 3430 |
if(!fwdCallSignalIp6Address) |
| 3431 |
{ |
| 3432 |
OOTRACEERR3("Error:Memory - ooH323ForwardCall - fwdCallSignal6Address" |
| 3433 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3434 |
return OO_FAILED; |
| 3435 |
} |
| 3436 |
inet_pton(AF_INET6, call->pCallFwdData->ip, |
| 3437 |
fwdCallSignalIp6Address->ip.data); |
| 3438 |
|
| 3439 |
fwdCallSignalIp6Address->ip.numocts=16; |
| 3440 |
fwdCallSignalIp6Address->port = call->pCallFwdData->port; |
| 3441 |
facility->alternativeAddress.u.ip6Address = fwdCallSignalIp6Address; |
| 3442 |
} else { |
| 3443 |
facility->alternativeAddress.t=T_H225TransportAddress_ipAddress; |
| 3444 |
fwdCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, |
| 3445 |
sizeof(H225TransportAddress_ipAddress)); |
| 3446 |
if(!fwdCallSignalIpAddress) |
| 3447 |
{ |
| 3448 |
OOTRACEERR3("Error:Memory - ooH323ForwardCall - fwdCallSignalAddress" |
| 3449 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3450 |
return OO_FAILED; |
| 3451 |
} |
| 3452 |
inet_pton(AF_INET, call->pCallFwdData->ip, |
| 3453 |
fwdCallSignalIpAddress->ip.data); |
| 3454 |
|
| 3455 |
fwdCallSignalIpAddress->ip.numocts=4; |
| 3456 |
fwdCallSignalIpAddress->port = call->pCallFwdData->port; |
| 3457 |
facility->alternativeAddress.u.ipAddress = fwdCallSignalIpAddress; |
| 3458 |
} |
| 3459 |
} |
| 3460 |
|
| 3461 |
if(call->pCallFwdData->aliases) |
| 3462 |
{ |
| 3463 |
facility->m.alternativeAliasAddressPresent = TRUE; |
| 3464 |
ret = ooPopulateAliasList(pctxt, call->pCallFwdData->aliases, |
| 3465 |
&facility->alternativeAliasAddress, 0); |
| 3466 |
if(ret != OO_OK) |
| 3467 |
{ |
| 3468 |
OOTRACEERR3("Error:Failed to populate alternate aliases in " |
| 3469 |
"ooH323ForwardCall. (%s, %s)\n", call->callType, |
| 3470 |
call->callToken); |
| 3471 |
return OO_FAILED; |
| 3472 |
} |
| 3473 |
} |
| 3474 |
|
| 3475 |
ret = ooSendH225Msg(call, pQ931Msg); |
| 3476 |
if(ret != OO_OK) |
| 3477 |
{ |
| 3478 |
OOTRACEERR3 |
| 3479 |
("Error:Failed to enqueue Forward Facility message to outbound " |
| 3480 |
"queue.(%s, %s)\n", call->callType, call->callToken); |
| 3481 |
} |
| 3482 |
call->callEndReason = OO_REASON_LOCAL_FWDED; |
| 3483 |
memReset (&gH323ep.msgctxt); |
| 3484 |
return ret; |
| 3485 |
} |
| 3486 |
|
| 3487 |
int ooH323HangCall(char * callToken, OOCallClearReason reason, int q931cause) |
| 3488 |
{ |
| 3489 |
OOH323CallData *call; |
| 3490 |
|
| 3491 |
call= ooFindCallByToken(callToken); |
| 3492 |
if(!call) |
| 3493 |
{ |
| 3494 |
OOTRACEWARN2("WARN: Call hangup failed - Call %s not present\n", |
| 3495 |
callToken); |
| 3496 |
return OO_FAILED; |
| 3497 |
} |
| 3498 |
OOTRACEINFO3("Hanging up call (%s, %s)\n", call->callType, call->callToken); |
| 3499 |
if(call->callState < OO_CALL_CLEAR) |
| 3500 |
{ |
| 3501 |
call->callEndReason = reason; |
| 3502 |
call->q931cause = q931cause; |
| 3503 |
call->callState = OO_CALL_CLEAR; |
| 3504 |
} |
| 3505 |
return OO_OK; |
| 3506 |
} |
| 3507 |
|
| 3508 |
int ooSetBearerCapabilityIE |
| 3509 |
(OOCTXT* pctxt, Q931Message *pmsg, enum Q931CodingStandard codingStandard, |
| 3510 |
enum Q931InformationTransferCapability capability, |
| 3511 |
enum Q931TransferMode transferMode, enum Q931TransferRate transferRate, |
| 3512 |
enum Q931UserInfoLayer1Protocol userInfoLayer1) |
| 3513 |
{ |
| 3514 |
unsigned size = 3; |
| 3515 |
|
| 3516 |
|
| 3517 |
if(pmsg->bearerCapabilityIE) |
| 3518 |
{ |
| 3519 |
memFreePtr(pctxt, pmsg->bearerCapabilityIE); |
| 3520 |
pmsg->bearerCapabilityIE = NULL; |
| 3521 |
} |
| 3522 |
|
| 3523 |
pmsg->bearerCapabilityIE = (Q931InformationElement*) |
| 3524 |
memAlloc(pctxt, sizeof(Q931InformationElement)+size-1); |
| 3525 |
if(!pmsg->bearerCapabilityIE) |
| 3526 |
{ |
| 3527 |
OOTRACEERR1("Error:Memory - ooSetBearerCapabilityIE - bearerCapabilityIE" |
| 3528 |
"\n"); |
| 3529 |
return OO_FAILED; |
| 3530 |
} |
| 3531 |
|
| 3532 |
pmsg->bearerCapabilityIE->discriminator = Q931BearerCapabilityIE; |
| 3533 |
pmsg->bearerCapabilityIE->length = size; |
| 3534 |
pmsg->bearerCapabilityIE->data[0] = (ASN1OCTET)(0x80 | ((codingStandard&3) << 5) | (capability&31)); |
| 3535 |
|
| 3536 |
pmsg->bearerCapabilityIE->data[1] = (0x80 | ((transferMode & 3) << 5) | (transferRate & 31)); |
| 3537 |
|
| 3538 |
pmsg->bearerCapabilityIE->data[2] = (0x80 | (1<<5) | userInfoLayer1); |
| 3539 |
|
| 3540 |
return OO_OK; |
| 3541 |
} |
| 3542 |
|
| 3543 |
int ooQ931SetKeypadIE(OOCTXT* pctxt, Q931Message *pmsg, const char* data) |
| 3544 |
{ |
| 3545 |
unsigned len = 0; |
| 3546 |
|
| 3547 |
|
| 3548 |
len = strlen(data); |
| 3549 |
pmsg->keypadIE = (Q931InformationElement*) |
| 3550 |
memAlloc(pctxt, sizeof(Q931InformationElement)+len-1); |
| 3551 |
if(!pmsg->keypadIE) |
| 3552 |
{ |
| 3553 |
OOTRACEERR1("Error:Memory - ooQ931SetKeypadIE - keypadIE\n"); |
| 3554 |
return OO_FAILED; |
| 3555 |
} |
| 3556 |
|
| 3557 |
pmsg->keypadIE->discriminator = Q931KeypadIE; |
| 3558 |
pmsg->keypadIE->length = len; |
| 3559 |
memcpy(pmsg->keypadIE->data, data, len); |
| 3560 |
return OO_OK; |
| 3561 |
} |
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
int ooQ931SetCallingPartyNumberIE |
| 3567 |
(OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type, |
| 3568 |
unsigned presentation, unsigned screening) |
| 3569 |
{ |
| 3570 |
unsigned len = 0; |
| 3571 |
|
| 3572 |
|
| 3573 |
if(pmsg->callingPartyNumberIE) |
| 3574 |
{ |
| 3575 |
memFreePtr(pctxt, pmsg->callingPartyNumberIE); |
| 3576 |
pmsg->callingPartyNumberIE = NULL; |
| 3577 |
} |
| 3578 |
|
| 3579 |
len = strlen(number); |
| 3580 |
pmsg->callingPartyNumberIE = (Q931InformationElement*) |
| 3581 |
memAlloc(pctxt, sizeof(Q931InformationElement)+len+2-1); |
| 3582 |
if(!pmsg->callingPartyNumberIE) |
| 3583 |
{ |
| 3584 |
OOTRACEERR1("Error:Memory - ooQ931SetCallingPartyNumberIE - " |
| 3585 |
"callingPartyNumberIE\n"); |
| 3586 |
return OO_FAILED; |
| 3587 |
} |
| 3588 |
pmsg->callingPartyNumberIE->discriminator = Q931CallingPartyNumberIE; |
| 3589 |
pmsg->callingPartyNumberIE->length = len+2; |
| 3590 |
pmsg->callingPartyNumberIE->data[0] = (((type&7)<<4)|(plan&15)); |
| 3591 |
pmsg->callingPartyNumberIE->data[1] = (0x80|((presentation&3)<<5)|(screening&3)); |
| 3592 |
memcpy(pmsg->callingPartyNumberIE->data+2, number, len); |
| 3593 |
|
| 3594 |
return OO_OK; |
| 3595 |
} |
| 3596 |
|
| 3597 |
int ooQ931SetCalledPartyNumberIE |
| 3598 |
(OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type) |
| 3599 |
{ |
| 3600 |
unsigned len = 0; |
| 3601 |
|
| 3602 |
|
| 3603 |
if(pmsg->calledPartyNumberIE) |
| 3604 |
{ |
| 3605 |
memFreePtr(pctxt, pmsg->calledPartyNumberIE); |
| 3606 |
pmsg->calledPartyNumberIE = NULL; |
| 3607 |
} |
| 3608 |
|
| 3609 |
len = strlen(number); |
| 3610 |
pmsg->calledPartyNumberIE = (Q931InformationElement*) |
| 3611 |
memAlloc(pctxt, sizeof(Q931InformationElement)+len+1-1); |
| 3612 |
if(!pmsg->calledPartyNumberIE) |
| 3613 |
{ |
| 3614 |
OOTRACEERR1("Error:Memory - ooQ931SetCalledPartyNumberIE - " |
| 3615 |
"calledPartyNumberIE\n"); |
| 3616 |
return OO_FAILED; |
| 3617 |
} |
| 3618 |
pmsg->calledPartyNumberIE->discriminator = Q931CalledPartyNumberIE; |
| 3619 |
pmsg->calledPartyNumberIE->length = len+1; |
| 3620 |
pmsg->calledPartyNumberIE->data[0] = (0x80|((type&7)<<4)|(plan&15)); |
| 3621 |
memcpy(pmsg->calledPartyNumberIE->data+1, number, len); |
| 3622 |
|
| 3623 |
return OO_OK; |
| 3624 |
} |
| 3625 |
|
| 3626 |
int ooQ931SetCallStateIE |
| 3627 |
(OOCTXT* pctxt, Q931Message *pmsg, unsigned char callstate) |
| 3628 |
{ |
| 3629 |
if(pmsg->callstateIE){ |
| 3630 |
memFreePtr(pctxt, pmsg->callstateIE); |
| 3631 |
pmsg->callstateIE = NULL; |
| 3632 |
} |
| 3633 |
|
| 3634 |
pmsg->callstateIE = (Q931InformationElement*) |
| 3635 |
memAllocZ(pctxt, sizeof(Q931InformationElement)); |
| 3636 |
if(!pmsg->callstateIE) |
| 3637 |
{ |
| 3638 |
OOTRACEERR1("Error:Memory - ooQ931SetCallstateIE - causeIE\n"); |
| 3639 |
return OO_FAILED; |
| 3640 |
} |
| 3641 |
pmsg->callstateIE->discriminator = Q931CallStateIE; |
| 3642 |
pmsg->callstateIE->length = 1; |
| 3643 |
pmsg->callstateIE->data[0] = callstate; |
| 3644 |
|
| 3645 |
return OO_OK; |
| 3646 |
} |
| 3647 |
|
| 3648 |
int ooQ931SetCauseIE |
| 3649 |
(OOCTXT* pctxt, Q931Message *pmsg, enum Q931CauseValues cause, unsigned coding, |
| 3650 |
unsigned location) |
| 3651 |
{ |
| 3652 |
|
| 3653 |
|
| 3654 |
if(pmsg->causeIE){ |
| 3655 |
memFreePtr(pctxt, pmsg->causeIE); |
| 3656 |
pmsg->causeIE = NULL; |
| 3657 |
} |
| 3658 |
|
| 3659 |
pmsg->causeIE = (Q931InformationElement*) |
| 3660 |
memAlloc(pctxt, sizeof(Q931InformationElement)+1); |
| 3661 |
if(!pmsg->causeIE) |
| 3662 |
{ |
| 3663 |
OOTRACEERR1("Error:Memory - ooQ931SetCauseIE - causeIE\n"); |
| 3664 |
return OO_FAILED; |
| 3665 |
} |
| 3666 |
pmsg->causeIE->discriminator = Q931CauseIE; |
| 3667 |
pmsg->causeIE->length = 2; |
| 3668 |
pmsg->causeIE->data[0] = (0x80 | ((coding & 0x03) <<5) | (location & 0x0F)); |
| 3669 |
|
| 3670 |
pmsg->causeIE->data[1] = (0x80 | cause); |
| 3671 |
|
| 3672 |
return OO_OK; |
| 3673 |
} |
| 3674 |
|
| 3675 |
|
| 3676 |
|
| 3677 |
int ooSendAsTunneledMessage(OOH323CallData *call, ASN1OCTET* msgbuf, |
| 3678 |
int h245Len, int h245MsgType, int associatedChan) |
| 3679 |
{ |
| 3680 |
Q931Message *pQ931Msg = NULL; |
| 3681 |
H225H323_UU_PDU *pH323UUPDU = NULL; |
| 3682 |
H225H323_UU_PDU_h245Control *pH245Control = NULL; |
| 3683 |
ASN1DynOctStr * elem; |
| 3684 |
int ret =0; |
| 3685 |
H225Facility_UUIE *facility=NULL; |
| 3686 |
|
| 3687 |
OOCTXT *pctxt = call->msgctxt; |
| 3688 |
|
| 3689 |
OOTRACEDBGA4("Building Facility message for tunneling %s (%s, %s)\n", |
| 3690 |
ooGetMsgTypeText(h245MsgType), call->callType, call->callToken); |
| 3691 |
|
| 3692 |
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); |
| 3693 |
if(ret != OO_OK) |
| 3694 |
{ |
| 3695 |
OOTRACEERR3("ERROR: In allocating memory for facility message " |
| 3696 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3697 |
return OO_FAILED; |
| 3698 |
} |
| 3699 |
|
| 3700 |
pQ931Msg->callReference = call->callReference; |
| 3701 |
|
| 3702 |
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, |
| 3703 |
sizeof(H225H323_UserInformation)); |
| 3704 |
if(!pQ931Msg->userInfo) |
| 3705 |
{ |
| 3706 |
OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - userInfo" |
| 3707 |
" (%s, %s)\n", call->callType, call->callToken); |
| 3708 |
|
| 3709 |
memReset(call->msgctxt); |
| 3710 |
return OO_FAILED; |
| 3711 |
} |
| 3712 |
memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); |
| 3713 |
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; |
| 3714 |
|
| 3715 |
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = |
| 3716 |
OO_TESTFLAG (call->flags, OO_M_TUNNELING); |
| 3717 |
|
| 3718 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = |
| 3719 |
T_H225H323_UU_PDU_h323_message_body_facility; |
| 3720 |
|
| 3721 |
facility = (H225Facility_UUIE*) |
| 3722 |
memAllocZ (pctxt, sizeof(H225Facility_UUIE)); |
| 3723 |
|
| 3724 |
if(!facility) |
| 3725 |
{ |
| 3726 |
OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - facility (%s, %s)" |
| 3727 |
"\n", call->callType, call->callToken); |
| 3728 |
|
| 3729 |
memReset(call->msgctxt); |
| 3730 |
return OO_FAILED; |
| 3731 |
} |
| 3732 |
|
| 3733 |
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; |
| 3734 |
|
| 3735 |
facility->protocolIdentifier = gProtocolID; |
| 3736 |
facility->m.callIdentifierPresent = 1; |
| 3737 |
facility->callIdentifier.guid.numocts = |
| 3738 |
call->callIdentifier.guid.numocts; |
| 3739 |
|
| 3740 |
memcpy(facility->callIdentifier.guid.data, |
| 3741 |
call->callIdentifier.guid.data, |
| 3742 |
call->callIdentifier.guid.numocts); |
| 3743 |
|
| 3744 |
facility->reason.t = T_H225FacilityReason_transportedInformation; |
| 3745 |
|
| 3746 |
pH323UUPDU = (H225H323_UU_PDU*) &pQ931Msg->userInfo->h323_uu_pdu; |
| 3747 |
pH323UUPDU->m.h245TunnelingPresent = TRUE; |
| 3748 |
pH323UUPDU->m.h245ControlPresent = TRUE; |
| 3749 |
pH323UUPDU->h245Tunneling = TRUE; |
| 3750 |
pH245Control = (H225H323_UU_PDU_h245Control*) |
| 3751 |
&pH323UUPDU->h245Control; |
| 3752 |
|
| 3753 |
elem = (ASN1DynOctStr*) memAlloc(pctxt, |
| 3754 |
sizeof(ASN1DynOctStr)); |
| 3755 |
if(!elem) |
| 3756 |
{ |
| 3757 |
OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - elem " |
| 3758 |
"(%s, %s)\n", call->callType, call->callToken); |
| 3759 |
return OO_FAILED; |
| 3760 |
} |
| 3761 |
elem->data = msgbuf; |
| 3762 |
elem->numocts = h245Len; |
| 3763 |
pH245Control->elem = elem; |
| 3764 |
pH245Control->n = 1; |
| 3765 |
pQ931Msg->tunneledMsgType = h245MsgType; |
| 3766 |
pQ931Msg->logicalChannelNo = associatedChan; |
| 3767 |
|
| 3768 |
|
| 3769 |
ret = ooSendH225Msg(call, pQ931Msg); |
| 3770 |
if(ret != OO_OK) |
| 3771 |
{ |
| 3772 |
OOTRACEERR3("Error:Failed to enqueue Facility(tunneling) message to " |
| 3773 |
"outbound queue.(%s, %s)\n", call->callType, call->callToken); |
| 3774 |
} |
| 3775 |
|
| 3776 |
|
| 3777 |
|
| 3778 |
|
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
memFreePtr(call->msgctxt, pQ931Msg); |
| 3783 |
return ret; |
| 3784 |
} |
| 3785 |
|
| 3786 |
int ooCallEstbTimerExpired(void *data) |
| 3787 |
{ |
| 3788 |
|
| 3789 |
ooTimerCallback *cbData = (ooTimerCallback*) data; |
| 3790 |
OOH323CallData *call = cbData->call; |
| 3791 |
OOTRACEINFO3("Call Establishment timer expired. (%s, %s)\n", |
| 3792 |
call->callType, call->callToken); |
| 3793 |
memFreePtr(call->pctxt, cbData); |
| 3794 |
if(call->callState < OO_CALL_CLEAR){ |
| 3795 |
call->callState = OO_CALL_CLEAR; |
| 3796 |
call->callEndReason = OO_REASON_LOCAL_CLEARED; |
| 3797 |
} |
| 3798 |
|
| 3799 |
return OO_OK; |
| 3800 |
} |
| 3801 |
|
| 3802 |
|
| 3803 |
int ooQ931GetCauseAndReasonCodeFromCallClearReason |
| 3804 |
(OOCallClearReason clearReason, enum Q931CauseValues *cause, |
| 3805 |
unsigned *reasonCode) |
| 3806 |
{ |
| 3807 |
switch(clearReason) |
| 3808 |
{ |
| 3809 |
case OO_REASON_INVALIDMESSAGE: |
| 3810 |
case OO_REASON_TRANSPORTFAILURE: |
| 3811 |
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 3812 |
*cause = Q931ProtocolErrorUnspecified; |
| 3813 |
break; |
| 3814 |
case OO_REASON_NOBW: |
| 3815 |
*reasonCode = T_H225ReleaseCompleteReason_noBandwidth; |
| 3816 |
*cause = Q931ErrorInCauseIE; |
| 3817 |
break; |
| 3818 |
case OO_REASON_GK_NOCALLEDUSER: |
| 3819 |
*reasonCode = T_H225ReleaseCompleteReason_calledPartyNotRegistered; |
| 3820 |
*cause = Q931SubscriberAbsent; |
| 3821 |
break; |
| 3822 |
case OO_REASON_GK_NOCALLERUSER: |
| 3823 |
*reasonCode = T_H225ReleaseCompleteReason_callerNotRegistered; |
| 3824 |
*cause = Q931SubscriberAbsent; |
| 3825 |
break; |
| 3826 |
case OO_REASON_GK_UNREACHABLE: |
| 3827 |
*reasonCode = T_H225ReleaseCompleteReason_unreachableGatekeeper; |
| 3828 |
*cause = Q931TemporaryFailure; |
| 3829 |
break; |
| 3830 |
case OO_REASON_GK_NORESOURCES: |
| 3831 |
case OO_REASON_GK_CLEARED: |
| 3832 |
*reasonCode = T_H225ReleaseCompleteReason_gatekeeperResources; |
| 3833 |
*cause = Q931Congestion; |
| 3834 |
break; |
| 3835 |
case OO_REASON_NOCOMMON_CAPABILITIES: |
| 3836 |
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 3837 |
*cause = Q931IncompatibleDestination; |
| 3838 |
break; |
| 3839 |
case OO_REASON_LOCAL_FWDED: |
| 3840 |
case OO_REASON_REMOTE_FWDED: |
| 3841 |
*reasonCode = T_H225ReleaseCompleteReason_facilityCallDeflection; |
| 3842 |
*cause = Q931Redirection; |
| 3843 |
break; |
| 3844 |
case OO_REASON_REMOTE_CLEARED: |
| 3845 |
case OO_REASON_LOCAL_CLEARED: |
| 3846 |
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 3847 |
*cause = Q931NormalCallClearing; |
| 3848 |
break; |
| 3849 |
case OO_REASON_REMOTE_BUSY: |
| 3850 |
case OO_REASON_LOCAL_BUSY: |
| 3851 |
*reasonCode = T_H225ReleaseCompleteReason_inConf; |
| 3852 |
*cause = Q931UserBusy; |
| 3853 |
break; |
| 3854 |
case OO_REASON_REMOTE_NOANSWER: |
| 3855 |
case OO_REASON_LOCAL_NOTANSWERED: |
| 3856 |
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 3857 |
*cause = Q931NoAnswer; |
| 3858 |
break; |
| 3859 |
case OO_REASON_REMOTE_REJECTED: |
| 3860 |
case OO_REASON_LOCAL_REJECTED: |
| 3861 |
*reasonCode = T_H225ReleaseCompleteReason_destinationRejection; |
| 3862 |
*cause = Q931CallRejected; |
| 3863 |
break; |
| 3864 |
case OO_REASON_REMOTE_CONGESTED: |
| 3865 |
case OO_REASON_LOCAL_CONGESTED: |
| 3866 |
*reasonCode = T_H225ReleaseCompleteReason_noBandwidth; |
| 3867 |
*cause = Q931Congestion; |
| 3868 |
break; |
| 3869 |
case OO_REASON_NOROUTE: |
| 3870 |
*reasonCode = T_H225ReleaseCompleteReason_unreachableDestination; |
| 3871 |
*cause = Q931NoRouteToDestination; |
| 3872 |
break; |
| 3873 |
case OO_REASON_NOUSER: |
| 3874 |
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 3875 |
*cause = Q931SubscriberAbsent; |
| 3876 |
break; |
| 3877 |
case OO_REASON_UNKNOWN: |
| 3878 |
default: |
| 3879 |
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason; |
| 3880 |
*cause = Q931NormalUnspecified; |
| 3881 |
} |
| 3882 |
|
| 3883 |
return OO_OK; |
| 3884 |
} |
| 3885 |
|
| 3886 |
enum OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode |
| 3887 |
(enum Q931CauseValues cause, unsigned reasonCode) |
| 3888 |
{ |
| 3889 |
switch(cause) |
| 3890 |
{ |
| 3891 |
case Q931NormalCallClearing: |
| 3892 |
return OO_REASON_REMOTE_CLEARED; |
| 3893 |
|
| 3894 |
case Q931UserBusy: |
| 3895 |
return OO_REASON_REMOTE_BUSY; |
| 3896 |
|
| 3897 |
case Q931NoResponse: |
| 3898 |
case Q931NoAnswer: |
| 3899 |
return OO_REASON_REMOTE_NOANSWER; |
| 3900 |
|
| 3901 |
case Q931CallRejected: |
| 3902 |
return OO_REASON_REMOTE_REJECTED; |
| 3903 |
|
| 3904 |
case Q931Redirection: |
| 3905 |
return OO_REASON_REMOTE_FWDED; |
| 3906 |
|
| 3907 |
case Q931NetworkOutOfOrder: |
| 3908 |
case Q931TemporaryFailure: |
| 3909 |
return OO_REASON_TRANSPORTFAILURE; |
| 3910 |
|
| 3911 |
case Q931NoCircuitChannelAvailable: |
| 3912 |
case Q931Congestion: |
| 3913 |
case Q931RequestedCircuitUnAvailable: |
| 3914 |
case Q931ResourcesUnavailable: |
| 3915 |
return OO_REASON_REMOTE_CONGESTED; |
| 3916 |
|
| 3917 |
case Q931NoRouteToDestination: |
| 3918 |
case Q931NoRouteToNetwork: |
| 3919 |
return OO_REASON_NOROUTE; |
| 3920 |
case Q931NumberChanged: |
| 3921 |
case Q931UnallocatedNumber: |
| 3922 |
case Q931SubscriberAbsent: |
| 3923 |
return OO_REASON_NOUSER; |
| 3924 |
case Q931ChannelUnacceptable: |
| 3925 |
case Q931DestinationOutOfOrder: |
| 3926 |
case Q931InvalidNumberFormat: |
| 3927 |
case Q931NormalUnspecified: |
| 3928 |
case Q931StatusEnquiryResponse: |
| 3929 |
case Q931IncompatibleDestination: |
| 3930 |
case Q931ProtocolErrorUnspecified: |
| 3931 |
case Q931RecoveryOnTimerExpiry: |
| 3932 |
case Q931InvalidCallReference: |
| 3933 |
default: |
| 3934 |
switch(reasonCode) |
| 3935 |
{ |
| 3936 |
case T_H225ReleaseCompleteReason_noBandwidth: |
| 3937 |
return OO_REASON_NOBW; |
| 3938 |
case T_H225ReleaseCompleteReason_gatekeeperResources: |
| 3939 |
return OO_REASON_GK_NORESOURCES; |
| 3940 |
case T_H225ReleaseCompleteReason_unreachableDestination: |
| 3941 |
return OO_REASON_NOROUTE; |
| 3942 |
case T_H225ReleaseCompleteReason_destinationRejection: |
| 3943 |
return OO_REASON_REMOTE_REJECTED; |
| 3944 |
case T_H225ReleaseCompleteReason_inConf: |
| 3945 |
return OO_REASON_REMOTE_BUSY; |
| 3946 |
case T_H225ReleaseCompleteReason_facilityCallDeflection: |
| 3947 |
return OO_REASON_REMOTE_FWDED; |
| 3948 |
case T_H225ReleaseCompleteReason_calledPartyNotRegistered: |
| 3949 |
return OO_REASON_GK_NOCALLEDUSER; |
| 3950 |
case T_H225ReleaseCompleteReason_callerNotRegistered: |
| 3951 |
return OO_REASON_GK_NOCALLERUSER; |
| 3952 |
case T_H225ReleaseCompleteReason_gatewayResources: |
| 3953 |
return OO_REASON_GK_NORESOURCES; |
| 3954 |
case T_H225ReleaseCompleteReason_unreachableGatekeeper: |
| 3955 |
return OO_REASON_GK_UNREACHABLE; |
| 3956 |
case T_H225ReleaseCompleteReason_invalidRevision: |
| 3957 |
case T_H225ReleaseCompleteReason_noPermission: |
| 3958 |
case T_H225ReleaseCompleteReason_badFormatAddress: |
| 3959 |
case T_H225ReleaseCompleteReason_adaptiveBusy: |
| 3960 |
case T_H225ReleaseCompleteReason_undefinedReason: |
| 3961 |
case T_H225ReleaseCompleteReason_securityDenied: |
| 3962 |
case T_H225ReleaseCompleteReason_newConnectionNeeded: |
| 3963 |
case T_H225ReleaseCompleteReason_nonStandardReason: |
| 3964 |
case T_H225ReleaseCompleteReason_replaceWithConferenceInvite: |
| 3965 |
case T_H225ReleaseCompleteReason_genericDataReason: |
| 3966 |
case T_H225ReleaseCompleteReason_neededFeatureNotSupported: |
| 3967 |
case T_H225ReleaseCompleteReason_tunnelledSignallingRejected: |
| 3968 |
case T_H225ReleaseCompleteReason_invalidCID: |
| 3969 |
case T_H225ReleaseCompleteReason_securityError: |
| 3970 |
case T_H225ReleaseCompleteReason_hopCountExceeded: |
| 3971 |
case T_H225ReleaseCompleteReason_extElem1: |
| 3972 |
default: |
| 3973 |
return OO_REASON_UNKNOWN; |
| 3974 |
} |
| 3975 |
} |
| 3976 |
return OO_REASON_UNKNOWN; |
| 3977 |
} |
| 3978 |
|
| 3979 |
|
| 3980 |
|
| 3981 |
|
| 3982 |
|
| 3983 |
|
| 3984 |
int ooParseDestination |
| 3985 |
(struct OOH323CallData *call, char *dest, char* parsedIP, unsigned len, |
| 3986 |
ooAliases** aliasList) |
| 3987 |
{ |
| 3988 |
int iEk=-1, iDon=-1, iTeen=-1, iChaar=-1, iPort = -1, i; |
| 3989 |
ooAliases * psNewAlias = NULL; |
| 3990 |
char *cAt = NULL, *host=NULL; |
| 3991 |
char tmp[256], buf[30]; |
| 3992 |
char *alias=NULL; |
| 3993 |
OOCTXT *pctxt = call->pctxt; |
| 3994 |
struct ast_sockaddr tmpaddr; |
| 3995 |
parsedIP[0] = '\0'; |
| 3996 |
|
| 3997 |
OOTRACEINFO2("Parsing destination %s\n", dest); |
| 3998 |
|
| 3999 |
|
| 4000 |
|
| 4001 |
|
| 4002 |
sscanf(dest, "%d.%d.%d.%d:%d", &iEk, &iDon, &iTeen, &iChaar, &iPort); |
| 4003 |
if((iEk > 0 && iEk <= 255) && |
| 4004 |
(iDon >= 0 && iDon <= 255) && |
| 4005 |
(iTeen >=0 && iTeen <= 255) && |
| 4006 |
(iChaar >= 0 && iChaar <= 255) && |
| 4007 |
(!strchr(dest, ':') || iPort != -1)) |
| 4008 |
{ |
| 4009 |
if(!strchr(dest, ':')) |
| 4010 |
iPort = 1720; |
| 4011 |
|
| 4012 |
sprintf(buf, "%d.%d.%d.%d:%d", iEk, iDon, iTeen, iChaar, iPort); |
| 4013 |
if(strlen(buf)+1>len) |
| 4014 |
{ |
| 4015 |
OOTRACEERR1("Error:Insufficient buffer space for parsed ip - " |
| 4016 |
"ooParseDestination\n"); |
| 4017 |
return OO_FAILED; |
| 4018 |
} |
| 4019 |
|
| 4020 |
strcpy(parsedIP, buf); |
| 4021 |
return OO_OK; |
| 4022 |
} |
| 4023 |
|
| 4024 |
|
| 4025 |
if ((strchr(dest, ':') || strchr(dest,'[') || strchr(dest,'.')) && !ast_parse_arg(dest, PARSE_ADDR, &tmpaddr)) { |
| 4026 |
if(strlen(dest)+7>len) |
| 4027 |
{ |
| 4028 |
OOTRACEERR1("Error:Insufficient buffer space for parsed ip - " |
| 4029 |
"ooParseDestination\n"); |
| 4030 |
return OO_FAILED; |
| 4031 |
} |
| 4032 |
strcpy(parsedIP, ast_sockaddr_stringify_addr(&tmpaddr)); |
| 4033 |
strcat(parsedIP, ":"); |
| 4034 |
strcat(parsedIP, ast_sockaddr_stringify_port(&tmpaddr)); |
| 4035 |
return OO_OK; |
| 4036 |
} |
| 4037 |
|
| 4038 |
|
| 4039 |
strncpy(tmp, dest, sizeof(tmp)-1); |
| 4040 |
tmp[sizeof(tmp)-1]='\0'; |
| 4041 |
if((host=strchr(tmp, '@')) != NULL) |
| 4042 |
{ |
| 4043 |
*host = '\0'; |
| 4044 |
host++; |
| 4045 |
sscanf(host, "%d.%d.%d.%d:%d", &iEk, &iDon, &iTeen, &iChaar, &iPort); |
| 4046 |
if((iEk > 0 && iEk <= 255) && |
| 4047 |
(iDon >= 0 && iDon <= 255) && |
| 4048 |
(iTeen >=0 && iTeen <= 255) && |
| 4049 |
(iChaar >= 0 && iChaar <= 255) && |
| 4050 |
(!strchr(host, ':') || iPort != -1)) |
| 4051 |
{ |
| 4052 |
if(!strchr(dest, ':')) |
| 4053 |
iPort = 1720; |
| 4054 |
|
| 4055 |
sprintf(buf, "%d.%d.%d.%d:%d", iEk, iDon, iTeen, iChaar, iPort); |
| 4056 |
if(strlen(buf)+1>len) |
| 4057 |
{ |
| 4058 |
OOTRACEERR1("Error:Insufficient buffer space for parsed ip - " |
| 4059 |
"ooParseDestination\n"); |
| 4060 |
return OO_FAILED; |
| 4061 |
} |
| 4062 |
|
| 4063 |
strncpy(parsedIP, buf, len-1); |
| 4064 |
parsedIP[len-1]='\0'; |
| 4065 |
alias = tmp; |
| 4066 |
} |
| 4067 |
} |
| 4068 |
|
| 4069 |
if(!alias) |
| 4070 |
{ |
| 4071 |
alias = dest; |
| 4072 |
} |
| 4073 |
|
| 4074 |
if(alias == strstr(alias, "http://")) |
| 4075 |
{ |
| 4076 |
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); |
| 4077 |
if(!psNewAlias) |
| 4078 |
{ |
| 4079 |
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); |
| 4080 |
return OO_FAILED; |
| 4081 |
} |
| 4082 |
psNewAlias->type = T_H225AliasAddress_url_ID; |
| 4083 |
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); |
| 4084 |
if(!psNewAlias->value) |
| 4085 |
{ |
| 4086 |
OOTRACEERR1("Error:Memory - ooParseDestination - " |
| 4087 |
"psNewAlias->value\n"); |
| 4088 |
memFreePtr(pctxt, psNewAlias); |
| 4089 |
return OO_FAILED; |
| 4090 |
} |
| 4091 |
strcpy(psNewAlias->value, alias); |
| 4092 |
psNewAlias->next = *aliasList; |
| 4093 |
*aliasList = psNewAlias; |
| 4094 |
OOTRACEINFO2("Destination parsed as url %s\n", psNewAlias->value); |
| 4095 |
return OO_OK; |
| 4096 |
} |
| 4097 |
|
| 4098 |
|
| 4099 |
if((cAt = strchr(alias, '@')) && alias != strchr(alias, '@')) |
| 4100 |
{ |
| 4101 |
if(strchr(cAt, '.')) |
| 4102 |
{ |
| 4103 |
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); |
| 4104 |
if(!psNewAlias) |
| 4105 |
{ |
| 4106 |
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); |
| 4107 |
return OO_FAILED; |
| 4108 |
} |
| 4109 |
psNewAlias->type = T_H225AliasAddress_email_ID; |
| 4110 |
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); |
| 4111 |
if(!psNewAlias->value) |
| 4112 |
{ |
| 4113 |
OOTRACEERR1("Error:Memory - ooParseDestination - " |
| 4114 |
"psNewAlias->value\n"); |
| 4115 |
memFreePtr(pctxt, psNewAlias); |
| 4116 |
return OO_FAILED; |
| 4117 |
} |
| 4118 |
strcpy(psNewAlias->value, alias); |
| 4119 |
psNewAlias->next = *aliasList; |
| 4120 |
*aliasList = psNewAlias; |
| 4121 |
OOTRACEINFO2("Destination is parsed as email %s\n",psNewAlias->value); |
| 4122 |
return OO_OK; |
| 4123 |
} |
| 4124 |
} |
| 4125 |
|
| 4126 |
|
| 4127 |
|
| 4128 |
|
| 4129 |
|
| 4130 |
for(i=0; *(alias+i) != '\0'; i++) |
| 4131 |
{ |
| 4132 |
if(!isdigit(alias[i]) && alias[i] != '#' && alias[i] != '*' && |
| 4133 |
alias[i] != ',') |
| 4134 |
break; |
| 4135 |
} |
| 4136 |
if(*(alias+i) == '\0') |
| 4137 |
{ |
| 4138 |
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); |
| 4139 |
if(!psNewAlias) |
| 4140 |
{ |
| 4141 |
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); |
| 4142 |
return OO_FAILED; |
| 4143 |
} |
| 4144 |
|
| 4145 |
psNewAlias->type = T_H225AliasAddress_dialedDigits; |
| 4146 |
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); |
| 4147 |
if(!psNewAlias->value) |
| 4148 |
{ |
| 4149 |
OOTRACEERR1("Error:Memroy - ooParseDestination - " |
| 4150 |
"psNewAlias->value\n"); |
| 4151 |
memFreePtr(pctxt, psNewAlias); |
| 4152 |
return OO_FAILED; |
| 4153 |
} |
| 4154 |
strcpy(psNewAlias->value, alias); |
| 4155 |
psNewAlias->next = *aliasList; |
| 4156 |
*aliasList = psNewAlias; |
| 4157 |
OOTRACEINFO2("Destination is parsed as dialed digits %s\n", |
| 4158 |
psNewAlias->value); |
| 4159 |
|
| 4160 |
if(!call->calledPartyNumber) |
| 4161 |
{ |
| 4162 |
if(ooCallSetCalledPartyNumber(call, alias) != OO_OK) |
| 4163 |
{ |
| 4164 |
OOTRACEWARN3("Warning:Failed to set calling party number." |
| 4165 |
"(%s, %s)\n", call->callType, call->callToken); |
| 4166 |
} |
| 4167 |
} |
| 4168 |
return OO_OK; |
| 4169 |
} |
| 4170 |
|
| 4171 |
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); |
| 4172 |
if(!psNewAlias) |
| 4173 |
{ |
| 4174 |
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); |
| 4175 |
return OO_FAILED; |
| 4176 |
} |
| 4177 |
psNewAlias->type = T_H225AliasAddress_h323_ID; |
| 4178 |
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); |
| 4179 |
if(!psNewAlias->value) |
| 4180 |
{ |
| 4181 |
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias->value\n"); |
| 4182 |
memFreePtr(pctxt, psNewAlias); |
| 4183 |
return OO_FAILED; |
| 4184 |
} |
| 4185 |
strcpy(psNewAlias->value, alias); |
| 4186 |
psNewAlias->next = *aliasList; |
| 4187 |
*aliasList = psNewAlias; |
| 4188 |
OOTRACEINFO2("Destination for new call is parsed as h323-id %s \n", |
| 4189 |
psNewAlias->value); |
| 4190 |
return OO_OK; |
| 4191 |
} |
| 4192 |
|
| 4193 |
const char* ooGetMsgTypeText (int msgType) |
| 4194 |
{ |
| 4195 |
static const char *msgTypeText[]={ |
| 4196 |
"OOQ931MSG", |
| 4197 |
"OOH245MSG", |
| 4198 |
"OOSetup", |
| 4199 |
"OOCallProceeding", |
| 4200 |
"OOAlert", |
| 4201 |
"OOConnect", |
| 4202 |
"OOReleaseComplete", |
| 4203 |
"OOFacility", |
| 4204 |
"OOInformation", |
| 4205 |
"OOMasterSlaveDetermination", |
| 4206 |
"OOMasterSlaveAck", |
| 4207 |
"OOMasterSlaveReject", |
| 4208 |
"OOMasterSlaveRelease", |
| 4209 |
"OOTerminalCapabilitySet", |
| 4210 |
"OOTerminalCapabilitySetAck", |
| 4211 |
"OOTerminalCapabilitySetReject", |
| 4212 |
"OOTerminalCapabilitySetRelease", |
| 4213 |
"OOOpenLogicalChannel", |
| 4214 |
"OOOpenLogicalChannelAck", |
| 4215 |
"OOOpenLogicalChannelReject", |
| 4216 |
"OOOpenLogicalChannelRelease", |
| 4217 |
"OOOpenLogicalChannelConfirm", |
| 4218 |
"OOCloseLogicalChannel", |
| 4219 |
"OOCloseLogicalChannelAck", |
| 4220 |
"OORequestChannelClose", |
| 4221 |
"OORequestChannelCloseAck", |
| 4222 |
"OORequestChannelCloseReject", |
| 4223 |
"OORequestChannelCloseRelease", |
| 4224 |
"OOEndSessionCommand", |
| 4225 |
"OOUserInputIndication", |
| 4226 |
"OORequestModeAck", |
| 4227 |
"OORequestModeReject", |
| 4228 |
"OORequestMode", |
| 4229 |
"OORequestDelayResponse", |
| 4230 |
"OORequestDelayRequest" |
| 4231 |
}; |
| 4232 |
int idx = msgType - OO_MSGTYPE_MIN; |
| 4233 |
return ooUtilsGetText (idx, msgTypeText, OONUMBEROF(msgTypeText)); |
| 4234 |
} |
| 4235 |
|
| 4236 |
const char* ooGetQ931CauseValueText(int val) |
| 4237 |
{ |
| 4238 |
switch(val) |
| 4239 |
{ |
| 4240 |
case Q931UnallocatedNumber: |
| 4241 |
return "Q931UnallocatedNumber"; |
| 4242 |
case Q931NoRouteToNetwork: |
| 4243 |
return "Q931NoRouteToNetwork"; |
| 4244 |
case Q931NoRouteToDestination: |
| 4245 |
return "Q931NoRouteToDestination"; |
| 4246 |
case Q931ChannelUnacceptable: |
| 4247 |
return "Q931ChannelUnacceptable"; |
| 4248 |
case Q931NormalCallClearing: |
| 4249 |
return "Q931NormalCallClearing"; |
| 4250 |
case Q931UserBusy: |
| 4251 |
return "Q931UserBusy"; |
| 4252 |
case Q931NoResponse: |
| 4253 |
return "Q931NoResponse"; |
| 4254 |
case Q931NoAnswer: |
| 4255 |
return "Q931NoAnswer"; |
| 4256 |
case Q931SubscriberAbsent: |
| 4257 |
return "Q931SubscriberAbsent"; |
| 4258 |
case Q931CallRejected: |
| 4259 |
return "Q931CallRejected"; |
| 4260 |
case Q931NumberChanged: |
| 4261 |
return "Q931NumberChanged"; |
| 4262 |
case Q931Redirection: |
| 4263 |
return "Q931Redirection"; |
| 4264 |
case Q931DestinationOutOfOrder: |
| 4265 |
return "Q931DestinationOutOfOrder"; |
| 4266 |
case Q931InvalidNumberFormat: |
| 4267 |
return "Q931InvalidNumberFormat"; |
| 4268 |
case Q931NormalUnspecified: |
| 4269 |
return "Q931NormalUnspecified"; |
| 4270 |
case Q931StatusEnquiryResponse: |
| 4271 |
return "Q931StatusEnquiryResponse"; |
| 4272 |
case Q931NoCircuitChannelAvailable: |
| 4273 |
return "Q931NoCircuitChannelAvailable"; |
| 4274 |
case Q931NetworkOutOfOrder: |
| 4275 |
return "Q931NetworkOutOfOrder"; |
| 4276 |
case Q931TemporaryFailure: |
| 4277 |
return "Q931TemporaryFailure"; |
| 4278 |
case Q931Congestion: |
| 4279 |
return "Q931Congestion"; |
| 4280 |
case Q931RequestedCircuitUnAvailable: |
| 4281 |
return "Q931RequestedCircuitUnavailable"; |
| 4282 |
case Q931ResourcesUnavailable: |
| 4283 |
return "Q931ResourcesUnavailable"; |
| 4284 |
case Q931IncompatibleDestination: |
| 4285 |
return "Q931IncompatibleDestination"; |
| 4286 |
case Q931ProtocolErrorUnspecified: |
| 4287 |
return "Q931ProtocolErrorUnspecified"; |
| 4288 |
case Q931RecoveryOnTimerExpiry: |
| 4289 |
return "Q931RecoveryOnTimerExpiry"; |
| 4290 |
case Q931InvalidCallReference: |
| 4291 |
return "Q931InvaliedCallReference"; |
| 4292 |
default: |
| 4293 |
return "Unsupported Cause Type"; |
| 4294 |
} |
| 4295 |
return "Unsupported Cause Type"; |
| 4296 |
} |