2009-06-30 16:40:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004-2005 by Objective Systems, Inc.
|
|
|
|
*
|
2017-12-22 14:23:22 +00:00
|
|
|
* This software is furnished under an open source license and may be
|
|
|
|
* used and copied only in accordance with the terms of this license.
|
|
|
|
* The text of the license may generally be found in the root
|
|
|
|
* directory of this installation in the COPYING file. It
|
2009-06-30 16:40:38 +00:00
|
|
|
* can also be viewed online at the following URL:
|
|
|
|
*
|
|
|
|
* http://www.obj-sys.com/open/license.html
|
|
|
|
*
|
2017-12-22 14:23:22 +00:00
|
|
|
* Any redistributions of this file including modified versions must
|
2009-06-30 16:40:38 +00:00
|
|
|
* maintain this copyright notice.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2010-03-25 23:38:58 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
#include "asterisk/lock.h"
|
2010-03-25 20:40:48 +00:00
|
|
|
#include "asterisk/utils.h"
|
2011-04-12 21:59:18 +00:00
|
|
|
#include "asterisk/config.h"
|
|
|
|
#include "asterisk/netsock2.h"
|
2009-11-04 22:10:44 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
#include "ooq931.h"
|
|
|
|
#include "ootrace.h"
|
|
|
|
#include "ooasn1.h"
|
|
|
|
#include "oochannels.h"
|
|
|
|
#include "printHandler.h"
|
|
|
|
#include "ooCalls.h"
|
|
|
|
#include "ooh323.h"
|
|
|
|
#include "ooh245.h"
|
|
|
|
#include "ooh323ep.h"
|
|
|
|
#include "ooCapability.h"
|
|
|
|
#include "ooGkClient.h"
|
|
|
|
#include "ooUtils.h"
|
|
|
|
#include "ootypes.h"
|
|
|
|
#include <time.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg,
|
|
|
|
ASN1UINT *fsCount, ASN1DynOctStr **fsElem);
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/** Global endpoint structure */
|
|
|
|
extern OOH323EndPoint gH323ep;
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
extern ast_mutex_t newCallLock;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
static ASN1OBJID gProtocolID = {
|
|
|
|
6, { 0, 0, 8, 2250, 0, 4 }
|
|
|
|
};
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
EXTERN int ooQ931Decode
|
2010-01-10 17:53:59 +00:00
|
|
|
(OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data, int docallbacks)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
int offset, x;
|
|
|
|
int rv = ASN_OK;
|
|
|
|
char number[128];
|
2011-02-10 13:29:19 +00:00
|
|
|
char *display = NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
dListInit (&msg->ies); /* clear information elements list */
|
|
|
|
|
|
|
|
if (length < 5) /* Packet too short */
|
|
|
|
return Q931_E_TOOSHORT;
|
|
|
|
|
|
|
|
msg->protocolDiscriminator = data[0];
|
|
|
|
OOTRACEDBGB2(" protocolDiscriminator = %d\n", msg->protocolDiscriminator);
|
|
|
|
if (data[1] != 2) /* Call reference must be 2 bytes long */
|
|
|
|
return Q931_E_INVCALLREF;
|
|
|
|
|
|
|
|
msg->callReference = ((data[2] & 0x7f) << 8) | data[3];
|
|
|
|
|
|
|
|
OOTRACEDBGB2(" callReference = %d\n", msg->callReference);
|
|
|
|
|
|
|
|
msg->fromDestination = (data[2] & 0x80) != 0;
|
|
|
|
if(msg->fromDestination)
|
|
|
|
OOTRACEDBGB1(" from = destination\n");
|
|
|
|
else
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGB1(" from = originator\n");
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
msg->messageType = data[4];
|
|
|
|
OOTRACEDBGB2(" messageType = %x\n", msg->messageType);
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Have preamble, start getting the informationElements into buffers */
|
|
|
|
offset = 5;
|
|
|
|
while (offset < length) {
|
|
|
|
Q931InformationElement *ie;
|
|
|
|
int ieOff = offset;
|
|
|
|
/* Get field discriminator */
|
|
|
|
int discriminator = data[offset++];
|
|
|
|
|
|
|
|
/* For discriminator with high bit set there is no data */
|
|
|
|
if ((discriminator & 0x80) == 0) {
|
|
|
|
int len = data[offset++], alen;
|
|
|
|
|
|
|
|
if (discriminator == Q931UserUserIE) {
|
|
|
|
/* Special case of User-user field, there is some confusion here as
|
|
|
|
the Q931 documentation claims the length is a single byte,
|
|
|
|
unfortunately all H.323 based apps have a 16 bit length here, so
|
|
|
|
we allow for said longer length. There is presumably an addendum
|
2017-12-22 14:23:22 +00:00
|
|
|
to Q931 which describes this, and provides a means to
|
|
|
|
discriminate between the old 1 byte and the new 2 byte systems.
|
2009-06-30 16:40:38 +00:00
|
|
|
However, at present we assume it is always 2 bytes until we find
|
2017-12-22 14:23:22 +00:00
|
|
|
something that breaks it.
|
2009-06-30 16:40:38 +00:00
|
|
|
*/
|
|
|
|
len <<= 8;
|
|
|
|
len |= data[offset++];
|
|
|
|
|
|
|
|
/* we also have a protocol discriminator, which we ignore */
|
|
|
|
offset++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* watch out for negative lengths! (ED, 11/5/03) */
|
|
|
|
if (len < 0) {
|
|
|
|
return Q931_E_INVLENGTH;
|
|
|
|
}
|
|
|
|
else if (offset + len > length) {
|
|
|
|
alen = 0;
|
|
|
|
len = -len;
|
|
|
|
rv = Q931_E_INVLENGTH;
|
|
|
|
}
|
|
|
|
else alen = len;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
ie = (Q931InformationElement*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAlloc (pctxt, sizeof(*ie) - sizeof(ie->data) + alen);
|
|
|
|
if(!ie)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooQ931Decode - ie(%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
ie->discriminator = discriminator;
|
|
|
|
ie->offset = ieOff;
|
|
|
|
ie->length = len;
|
2017-12-22 14:23:22 +00:00
|
|
|
if (alen != 0)
|
2009-06-30 16:40:38 +00:00
|
|
|
memcpy(ie->data, data + offset, alen);
|
|
|
|
offset += len;
|
|
|
|
}
|
|
|
|
else {
|
2017-12-22 14:23:22 +00:00
|
|
|
ie = (Q931InformationElement*) memAlloc (pctxt,
|
2012-05-03 14:35:30 +00:00
|
|
|
sizeof(*ie));
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!ie)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooQ931Decode - ie(%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
ie->discriminator = discriminator;
|
|
|
|
ie->offset = offset;
|
|
|
|
ie->length = 0;
|
|
|
|
}
|
|
|
|
if(ie->discriminator == Q931BearerCapabilityIE)
|
|
|
|
{
|
|
|
|
OOTRACEDBGB1(" Bearer-Capability IE = {\n");
|
|
|
|
for(x=0; x<ie->length; x++)
|
|
|
|
{
|
|
|
|
if(x==0)
|
|
|
|
OOTRACEDBGB2(" %x", ie->data[x]);
|
|
|
|
else
|
|
|
|
OOTRACEDBGB2(", %x", ie->data[x]);
|
|
|
|
}
|
|
|
|
OOTRACEDBGB1(" }\n");
|
|
|
|
}
|
|
|
|
if(ie->discriminator == Q931DisplayIE)
|
|
|
|
{
|
2011-02-10 13:29:19 +00:00
|
|
|
if (!(display = memAllocZ(pctxt, ie->length + 1))) {
|
|
|
|
OOTRACEERR4("Can't alloc DisplayIE buffer for %n bytes, (%s, %s)\n", ie->length,
|
|
|
|
call->callType, call->callToken);
|
|
|
|
} else {
|
|
|
|
memcpy(display, ie->data,ie->length);
|
|
|
|
OOTRACEDBGB1(" Display IE = {\n");
|
|
|
|
OOTRACEDBGB2(" %s\n", display);
|
|
|
|
OOTRACEDBGB1(" }\n");
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ie->discriminator == Q931KeypadIE)
|
|
|
|
{
|
|
|
|
OOTRACEDBGB1(" Keypad IE = {\n");
|
2010-03-07 00:45:35 +00:00
|
|
|
OOTRACEDBGB2(" %c\n", ie->data[0]);
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEDBGB1(" }\n");
|
2010-01-10 17:53:59 +00:00
|
|
|
if(docallbacks && gH323ep.h323Callbacks.onReceivedDTMF)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
gH323ep.h323Callbacks.onReceivedDTMF(call, (char *)ie->data);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Extract calling party number TODO:Give respect to presentation and
|
2009-06-30 16:40:38 +00:00
|
|
|
screening indicators ;-) */
|
|
|
|
if(ie->discriminator == Q931CallingPartyNumberIE)
|
|
|
|
{
|
|
|
|
OOTRACEDBGB1(" CallingPartyNumber IE = {\n");
|
|
|
|
if(ie->length < OO_MAX_NUMBER_LENGTH)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int numoffset=1;
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!(0x80 & ie->data[0])) numoffset = 2;
|
|
|
|
memcpy(number, ie->data+numoffset,ie->length-numoffset);
|
|
|
|
number[ie->length-numoffset]='\0';
|
|
|
|
OOTRACEDBGB2(" %s\n", number);
|
|
|
|
if(!call->callingPartyNumber)
|
|
|
|
ooCallSetCallingPartyNumber(call, number);
|
|
|
|
}
|
|
|
|
else{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Calling party number too long. (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
OOTRACEDBGB1(" }\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract called party number */
|
|
|
|
if(ie->discriminator == Q931CalledPartyNumberIE)
|
|
|
|
{
|
|
|
|
OOTRACEDBGB1(" CalledPartyNumber IE = {\n");
|
|
|
|
if(ie->length < OO_MAX_NUMBER_LENGTH)
|
|
|
|
{
|
|
|
|
memcpy(number, ie->data+1,ie->length-1);
|
|
|
|
number[ie->length-1]='\0';
|
|
|
|
OOTRACEDBGB2(" %s\n", number);
|
|
|
|
if(!call->calledPartyNumber)
|
|
|
|
ooCallSetCalledPartyNumber(call, number);
|
|
|
|
}
|
|
|
|
else{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Calling party number too long. (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
OOTRACEDBGB1(" }\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle Cause ie */
|
|
|
|
if(ie->discriminator == Q931CauseIE)
|
|
|
|
{
|
|
|
|
msg->causeIE = ie;
|
|
|
|
OOTRACEDBGB1(" Cause IE = {\n");
|
|
|
|
OOTRACEDBGB2(" %s\n", ooGetQ931CauseValueText(ie->data[1]&0x7f));
|
|
|
|
OOTRACEDBGB1(" }\n");
|
|
|
|
}
|
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
/* Handle CallState ie */
|
|
|
|
if(ie->discriminator == Q931CallStateIE)
|
|
|
|
{
|
|
|
|
msg->causeIE = ie;
|
|
|
|
OOTRACEDBGB1(" CallState IE = {\n");
|
|
|
|
OOTRACEDBGB2(" %d\n", ie->data[0]);
|
|
|
|
OOTRACEDBGB1(" }\n");
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* TODO: Get rid of ie list.*/
|
|
|
|
dListAppend (pctxt, &msg->ies, ie);
|
|
|
|
if (rv != ASN_OK)
|
|
|
|
return rv;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
/*cisco router sends Q931Notify without UU ie,
|
2009-06-30 16:40:38 +00:00
|
|
|
we just ignore notify message as of now as handling is optional for
|
|
|
|
end point*/
|
2009-12-30 23:51:32 +00:00
|
|
|
if(msg->messageType != Q931NotifyMsg && msg->messageType != Q931StatusMsg)
|
2009-11-04 22:10:44 +00:00
|
|
|
rv = ooDecodeUUIE(pctxt, msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
EXTERN Q931InformationElement* ooQ931GetIE (const Q931Message* q931msg,
|
2009-06-30 16:40:38 +00:00
|
|
|
int ieCode)
|
|
|
|
{
|
|
|
|
DListNode* curNode;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for(i = 0, curNode = q931msg->ies.head; i < q931msg->ies.count; i++) {
|
|
|
|
Q931InformationElement *ie = (Q931InformationElement*) curNode->data;
|
|
|
|
if (ie->discriminator == ieCode) {
|
|
|
|
return ie;
|
|
|
|
}
|
|
|
|
curNode = curNode->next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* ooQ931GetMessageTypeName(int messageType, char* buf) {
|
|
|
|
switch (messageType) {
|
|
|
|
case Q931AlertingMsg :
|
|
|
|
strcpy(buf, "Alerting");
|
|
|
|
break;
|
|
|
|
case Q931CallProceedingMsg :
|
|
|
|
strcpy(buf, "CallProceeding");
|
|
|
|
break;
|
|
|
|
case Q931ConnectMsg :
|
|
|
|
strcpy(buf, "Connect");
|
|
|
|
break;
|
|
|
|
case Q931ConnectAckMsg :
|
|
|
|
strcpy(buf, "ConnectAck");
|
|
|
|
break;
|
|
|
|
case Q931ProgressMsg :
|
|
|
|
strcpy(buf, "Progress");
|
|
|
|
break;
|
|
|
|
case Q931SetupMsg :
|
|
|
|
strcpy(buf, "Setup");
|
|
|
|
break;
|
|
|
|
case Q931SetupAckMsg :
|
|
|
|
strcpy(buf, "SetupAck");
|
|
|
|
break;
|
|
|
|
case Q931FacilityMsg :
|
|
|
|
strcpy(buf, "Facility");
|
|
|
|
break;
|
|
|
|
case Q931ReleaseCompleteMsg :
|
|
|
|
strcpy(buf, "ReleaseComplete");
|
|
|
|
break;
|
|
|
|
case Q931StatusEnquiryMsg :
|
|
|
|
strcpy(buf, "StatusEnquiry");
|
|
|
|
break;
|
|
|
|
case Q931StatusMsg :
|
|
|
|
strcpy(buf, "Status");
|
|
|
|
break;
|
|
|
|
case Q931InformationMsg :
|
|
|
|
strcpy(buf, "Information");
|
|
|
|
break;
|
|
|
|
case Q931NationalEscapeMsg :
|
|
|
|
strcpy(buf, "Escape");
|
|
|
|
break;
|
|
|
|
default:
|
2014-07-22 14:22:00 +00:00
|
|
|
sprintf(buf, "<%d>", messageType);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* ooQ931GetIEName(int number, char* buf) {
|
|
|
|
switch (number) {
|
|
|
|
case Q931BearerCapabilityIE :
|
|
|
|
strcpy(buf, "Bearer-Capability");
|
|
|
|
break;
|
|
|
|
case Q931CauseIE :
|
|
|
|
strcpy(buf, "Cause");
|
|
|
|
break;
|
|
|
|
case Q931FacilityIE :
|
|
|
|
strcpy(buf, "Facility");
|
|
|
|
break;
|
|
|
|
case Q931ProgressIndicatorIE :
|
|
|
|
strcpy(buf, "Progress-Indicator");
|
|
|
|
break;
|
|
|
|
case Q931CallStateIE :
|
|
|
|
strcpy(buf, "Call-State");
|
|
|
|
break;
|
|
|
|
case Q931DisplayIE :
|
|
|
|
strcpy(buf, "Display");
|
|
|
|
break;
|
|
|
|
case Q931SignalIE :
|
|
|
|
strcpy(buf, "Signal");
|
|
|
|
break;
|
|
|
|
case Q931CallingPartyNumberIE :
|
|
|
|
strcpy(buf, "Calling-Party-Number");
|
|
|
|
break;
|
|
|
|
case Q931CalledPartyNumberIE :
|
|
|
|
strcpy(buf, "Called-Party-Number");
|
|
|
|
break;
|
|
|
|
case Q931RedirectingNumberIE :
|
|
|
|
strcpy(buf, "Redirecting-Number");
|
|
|
|
break;
|
|
|
|
case Q931UserUserIE :
|
|
|
|
strcpy(buf, "User-User");
|
|
|
|
break;
|
|
|
|
default:
|
2014-07-22 14:22:00 +00:00
|
|
|
sprintf(buf, "0x%02x", (unsigned)number);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERN void ooQ931Print (const Q931Message* q931msg) {
|
|
|
|
char buf[1000];
|
|
|
|
DListNode* curNode;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
printf("Q.931 Message:\n");
|
2014-07-22 14:22:00 +00:00
|
|
|
printf(" protocolDiscriminator: %u\n", q931msg->protocolDiscriminator);
|
|
|
|
printf(" callReference: %u\n", q931msg->callReference);
|
2017-12-22 14:23:22 +00:00
|
|
|
printf(" from: %s\n", (q931msg->fromDestination ?
|
2009-06-30 16:40:38 +00:00
|
|
|
"destination" : "originator"));
|
2017-12-22 14:23:22 +00:00
|
|
|
printf(" messageType: %s (0x%X)\n\n",
|
|
|
|
ooQ931GetMessageTypeName(q931msg->messageType, buf),
|
2009-06-30 16:40:38 +00:00
|
|
|
q931msg->messageType);
|
|
|
|
|
|
|
|
for(i = 0, curNode = q931msg->ies.head; i < q931msg->ies.count; i++) {
|
|
|
|
Q931InformationElement *ie = (Q931InformationElement*) curNode->data;
|
|
|
|
int length = (ie->length >= 0) ? ie->length : -ie->length;
|
2014-07-22 14:22:00 +00:00
|
|
|
printf(" IE[%u] (offset 0x%X):\n", i, (unsigned)ie->offset);
|
2017-12-22 14:23:22 +00:00
|
|
|
printf(" discriminator: %s (0x%X)\n",
|
2014-07-22 14:22:00 +00:00
|
|
|
ooQ931GetIEName(ie->discriminator, buf), (unsigned)ie->discriminator);
|
2009-06-30 16:40:38 +00:00
|
|
|
printf(" data length: %i\n", length);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
curNode = curNode->next;
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooCreateQ931Message(OOCTXT* pctxt, Q931Message **q931msg, int msgType)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
*q931msg = (Q931Message*)memAllocZ(pctxt, sizeof(Q931Message));
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!*q931msg)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooCreateQ931Message - q931msg\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
(*q931msg)->protocolDiscriminator = 8;
|
|
|
|
(*q931msg)->fromDestination = FALSE;
|
|
|
|
(*q931msg)->messageType = msgType;
|
|
|
|
(*q931msg)->tunneledMsgType = msgType;
|
|
|
|
(*q931msg)->logicalChannelNo = 0;
|
|
|
|
(*q931msg)->bearerCapabilityIE = NULL;
|
|
|
|
(*q931msg)->callingPartyNumberIE = NULL;
|
|
|
|
(*q931msg)->calledPartyNumberIE = NULL;
|
|
|
|
(*q931msg)->causeIE = NULL;
|
2011-11-09 19:08:44 +00:00
|
|
|
(*q931msg)->callstateIE = NULL;
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ooGenerateCallToken (char *callToken, size_t size)
|
|
|
|
{
|
|
|
|
static int counter = 1;
|
|
|
|
char aCallToken[200];
|
|
|
|
int ret = 0;
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ast_mutex_lock(&newCallLock);
|
2009-06-30 16:40:38 +00:00
|
|
|
sprintf (aCallToken, "ooh323c_%d", counter++);
|
|
|
|
|
|
|
|
if (counter > OO_MAX_CALL_TOKEN)
|
|
|
|
counter = 1;
|
2009-11-04 22:10:44 +00:00
|
|
|
ast_mutex_unlock(&newCallLock);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if ((strlen(aCallToken)+1) < size)
|
|
|
|
strcpy (callToken, aCallToken);
|
|
|
|
else {
|
|
|
|
OOTRACEERR1 ("Error: Insufficient buffer size to generate call token");
|
|
|
|
ret = OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CallReference is a two octet field, thus max value can be 0xffff
|
|
|
|
or 65535 decimal. We restrict max value to 32760, however, this should
|
|
|
|
not cause any problems as there won't be those many simultaneous calls
|
|
|
|
CallRef has to be locally unique and generated by caller.
|
|
|
|
*/
|
|
|
|
ASN1USINT ooGenerateCallReference()
|
|
|
|
{
|
|
|
|
static ASN1USINT lastCallRef=0;
|
|
|
|
ASN1USINT newCallRef=0;
|
|
|
|
|
|
|
|
|
|
|
|
if(lastCallRef == 0)
|
|
|
|
{
|
|
|
|
/* Generate a new random callRef */
|
|
|
|
srand((unsigned)time(0));
|
|
|
|
lastCallRef = (ASN1USINT)(rand()%100);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lastCallRef++;
|
|
|
|
|
|
|
|
/* Note callReference can be at the most 15 bits that is from 0 to 32767.
|
|
|
|
if we generate number bigger than that, bring it in range.
|
|
|
|
*/
|
|
|
|
if(lastCallRef>=32766)
|
|
|
|
lastCallRef=1;
|
|
|
|
|
|
|
|
newCallRef = lastCallRef;
|
|
|
|
|
|
|
|
|
|
|
|
OOTRACEDBGC2("Generated callRef %d\n", newCallRef);
|
|
|
|
return newCallRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ooGenerateCallIdentifier(H225CallIdentifier *callid)
|
|
|
|
{
|
|
|
|
ASN1INT64 timestamp;
|
|
|
|
int i=0;
|
|
|
|
#ifdef _WIN32
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
SYSTEMTIME systemTime;
|
|
|
|
GetLocalTime(&systemTime);
|
|
|
|
SystemTimeToFileTime(&systemTime, (LPFILETIME)×tamp);
|
|
|
|
#else
|
|
|
|
struct timeval systemTime;
|
|
|
|
gettimeofday(&systemTime, NULL);
|
|
|
|
timestamp = systemTime.tv_sec * 10000000 + systemTime.tv_usec*10;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
callid->guid.numocts = 16;
|
|
|
|
callid->guid.data[0] = 'o';
|
|
|
|
callid->guid.data[1] = 'o';
|
|
|
|
callid->guid.data[2] = 'h';
|
|
|
|
callid->guid.data[3] = '3';
|
|
|
|
callid->guid.data[4] = '2';
|
|
|
|
callid->guid.data[5] = '3';
|
|
|
|
callid->guid.data[6] = 'c';
|
|
|
|
callid->guid.data[7] = '-';
|
|
|
|
|
|
|
|
for (i = 8; i < 16; i++)
|
|
|
|
callid->guid.data[i] = (ASN1OCTET)((timestamp>>((i-8+1)*8))&0xff);
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooFreeQ931Message(OOCTXT* pctxt, Q931Message *q931Msg)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
if(!q931Msg)
|
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(pctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooEncodeUUIE(OOCTXT* pctxt, Q931Message *q931msg)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
2011-11-04 19:50:10 +00:00
|
|
|
ASN1OCTET msgbuf[ASN_K_ENCBUFSIZ];
|
2009-06-30 16:40:38 +00:00
|
|
|
ASN1OCTET * msgptr=NULL;
|
|
|
|
int len;
|
|
|
|
ASN1BOOL aligned = TRUE;
|
|
|
|
Q931InformationElement* ie=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
memset(msgbuf, 0, sizeof(msgbuf));
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!q931msg)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR: Invalid Q931 message in add user-user IE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR: No User-User IE to encode\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
setPERBuffer(pctxt, msgbuf, sizeof(msgbuf), aligned);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
if(asn1PE_H225H323_UserInformation (pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
q931msg->userInfo)==ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEDBGC1("UserInfo encoding - successful\n");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
OOTRACEERR1("ERROR: UserInfo encoding failed\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
msgptr = encodeGetMsgPtr(pctxt, &len);
|
|
|
|
|
|
|
|
/* Allocate memory to hold complete UserUser Information */
|
|
|
|
ie = (Q931InformationElement*)memAlloc (pctxt,
|
|
|
|
sizeof(*ie) - sizeof(ie->data) + len);
|
|
|
|
if(ie == NULL)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error: Memory - ooEncodeUUIE - ie\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
ie->discriminator = Q931UserUserIE;
|
|
|
|
ie->length = len;
|
|
|
|
memcpy(ie->data, msgptr, len);
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Add the user to user IE NOTE: ALL IEs SHOULD BE IN ASCENDING ORDER OF
|
|
|
|
THEIR DISCRIMINATOR AS PER SPEC.
|
2009-06-30 16:40:38 +00:00
|
|
|
*/
|
|
|
|
dListInit (&(q931msg->ies));
|
2017-12-22 14:23:22 +00:00
|
|
|
if((dListAppend (pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
&(q931msg->ies), ie)) == NULL)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error: Failed to add UUIE in outgoing message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooDecodeUUIE(OOCTXT* pctxt, Q931Message *q931Msg)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
DListNode* curNode;
|
|
|
|
unsigned int i;
|
|
|
|
ASN1BOOL aligned=TRUE;
|
|
|
|
int stat;
|
|
|
|
Q931InformationElement *ie;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2009-06-30 16:40:38 +00:00
|
|
|
if(q931Msg ==NULL)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error: ooDecodeUUIE failed - NULL q931 message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Search for UserUser IE */
|
2017-12-22 14:23:22 +00:00
|
|
|
for(i = 0, curNode = q931Msg->ies.head; i < q931Msg->ies.count;
|
|
|
|
i++, curNode = curNode->next)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
ie = (Q931InformationElement*) curNode->data;
|
2009-11-04 22:10:44 +00:00
|
|
|
if(ie && ie->discriminator == Q931UserUserIE)
|
2009-06-30 16:40:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(i == q931Msg->ies.count)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("No UserUser IE found in ooDecodeUUIE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Decode user-user ie */
|
|
|
|
q931Msg->userInfo = (H225H323_UserInformation *) memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931Msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooDecodeUUIE - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(q931Msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
|
|
|
|
|
|
|
setPERBuffer (pctxt, ie->data, ie->length, aligned);
|
|
|
|
|
|
|
|
stat = asn1PD_H225H323_UserInformation (pctxt, q931Msg->userInfo);
|
|
|
|
if(stat != ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error: UserUser IE decode failed\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
OOTRACEDBGC1("UUIE decode successful\n");
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _COMPACT
|
2017-12-22 14:23:22 +00:00
|
|
|
static void ooQ931PrintMessage
|
2009-06-30 16:40:38 +00:00
|
|
|
(OOH323CallData* call, ASN1OCTET *msgbuf, ASN1UINT msglen)
|
|
|
|
{
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
Q931Message q931Msg;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
initializePrintHandler(&printHandler, "Q931 Message");
|
|
|
|
|
|
|
|
/* Set event handler */
|
|
|
|
setEventHandler (pctxt, &printHandler);
|
|
|
|
|
|
|
|
setPERBuffer (pctxt, msgbuf, msglen, TRUE);
|
|
|
|
|
2010-01-10 17:53:59 +00:00
|
|
|
ret = ooQ931Decode (call, &q931Msg, msglen, msgbuf, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Failed decoding Q931 message. (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
finishPrint();
|
|
|
|
removeEventHandler(pctxt);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
int ooEncodeH225Message(OOH323CallData *call, Q931Message *pq931Msg,
|
2009-06-30 16:40:38 +00:00
|
|
|
char *msgbuf, int size)
|
|
|
|
{
|
|
|
|
int len=0, i=0, j=0, ieLen=0;
|
|
|
|
int stat=0;
|
|
|
|
DListNode* curNode=NULL;
|
|
|
|
|
|
|
|
if(!msgbuf || size<200)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Invalid message buffer/size for ooEncodeH245Message."
|
|
|
|
" (%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pq931Msg->messageType == Q931SetupMsg){
|
|
|
|
msgbuf[i++] = OOSetup;
|
|
|
|
}
|
|
|
|
else if(pq931Msg->messageType == Q931ConnectMsg){
|
|
|
|
msgbuf[i++] = OOConnect;
|
|
|
|
}
|
|
|
|
else if(pq931Msg->messageType == Q931CallProceedingMsg){
|
|
|
|
msgbuf[i++] = OOCallProceeding;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
else if(pq931Msg->messageType == Q931AlertingMsg ||
|
2009-11-04 22:10:44 +00:00
|
|
|
pq931Msg->messageType == Q931ProgressMsg){
|
2009-06-30 16:40:38 +00:00
|
|
|
msgbuf[i++] = OOAlert;
|
|
|
|
}
|
|
|
|
else if(pq931Msg->messageType == Q931ReleaseCompleteMsg){
|
|
|
|
msgbuf[i++] = OOReleaseComplete;
|
|
|
|
}
|
|
|
|
else if(pq931Msg->messageType == Q931InformationMsg){
|
|
|
|
msgbuf[i++] = OOInformationMessage;
|
|
|
|
}
|
2011-11-09 19:08:44 +00:00
|
|
|
else if(pq931Msg->messageType == Q931StatusMsg ||
|
|
|
|
pq931Msg->messageType == Q931StatusEnquiryMsg){
|
|
|
|
msgbuf[i++] = OOStatus;
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
else if(pq931Msg->messageType == Q931FacilityMsg){
|
|
|
|
msgbuf[i++] = OOFacility;
|
|
|
|
msgbuf[i++] = pq931Msg->tunneledMsgType;
|
|
|
|
msgbuf[i++] = pq931Msg->logicalChannelNo>>8;
|
|
|
|
msgbuf[i++] = pq931Msg->logicalChannelNo;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
OOTRACEERR3("Error:Unknow Q931 message type. (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
stat = ooEncodeUUIE(call->msgctxt, pq931Msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(stat != OO_OK)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Failed to encode uuie. (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
msgbuf[i++] = 3; /* TPKT version */
|
|
|
|
msgbuf[i++] = 0; /* TPKT resevred */
|
|
|
|
/* 1st octet of length, will be populated once len is determined */
|
2017-12-22 14:23:22 +00:00
|
|
|
msgbuf[i++] = 0;
|
2009-06-30 16:40:38 +00:00
|
|
|
/* 2nd octet of length, will be populated once len is determined */
|
2017-12-22 14:23:22 +00:00
|
|
|
msgbuf[i++] = 0;
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Q931 protocol discriminator */
|
|
|
|
msgbuf[i++] = pq931Msg->protocolDiscriminator;
|
|
|
|
msgbuf[i++] = 2; /* length of call ref is two octets */
|
|
|
|
msgbuf[i] = (pq931Msg->callReference >> 8); /* populate 1st octet */
|
|
|
|
if(!strcmp(call->callType, "incoming"))
|
|
|
|
msgbuf[i++] |= 0x80; /* fromDestination*/
|
|
|
|
else
|
|
|
|
i++; /* fromOriginator*/
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
msgbuf[i++] = pq931Msg->callReference; /* populate 2nd octet */
|
|
|
|
msgbuf[i++] = pq931Msg->messageType; /* type of q931 message */
|
|
|
|
|
|
|
|
/* Note: the order in which ies are added is important. It is in the
|
2017-12-22 14:23:22 +00:00
|
|
|
ascending order of ie codes.
|
2009-06-30 16:40:38 +00:00
|
|
|
*/
|
|
|
|
/* Add bearer IE */
|
|
|
|
if(pq931Msg->bearerCapabilityIE)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
msgbuf[i++] = Q931BearerCapabilityIE; /* ie discriminator */
|
|
|
|
msgbuf[i++] = pq931Msg->bearerCapabilityIE->length;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(msgbuf+i, pq931Msg->bearerCapabilityIE->data,
|
2009-06-30 16:40:38 +00:00
|
|
|
pq931Msg->bearerCapabilityIE->length);
|
|
|
|
i += pq931Msg->bearerCapabilityIE->length;
|
2017-12-22 14:23:22 +00:00
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Add cause IE */
|
|
|
|
if(pq931Msg->causeIE)
|
|
|
|
{
|
|
|
|
msgbuf[i++] = Q931CauseIE;
|
|
|
|
msgbuf[i++] = pq931Msg->causeIE->length;
|
|
|
|
memcpy(msgbuf+i, pq931Msg->causeIE->data, pq931Msg->causeIE->length);
|
|
|
|
i += pq931Msg->causeIE->length;
|
2017-12-22 14:23:22 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 21:46:44 +00:00
|
|
|
/* Add progress indicator IE */
|
|
|
|
if(pq931Msg->messageType == Q931AlertingMsg || pq931Msg->messageType == Q931ProgressMsg)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
msgbuf[i++] = Q931ProgressIndicatorIE;
|
|
|
|
msgbuf[i++] = 2; //Length is 2 octet
|
|
|
|
msgbuf[i++] = 0x80; //PI=8
|
|
|
|
msgbuf[i++] = 0x88;
|
2015-09-09 21:46:44 +00:00
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
/*Add display ie. for all but Status message as per ASTERISK-18748 */
|
|
|
|
if(!ooUtilsIsStrEmpty(call->ourCallerId) && (pq931Msg->messageType != Q931StatusMsg))
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
msgbuf[i++] = Q931DisplayIE;
|
|
|
|
ieLen = strlen(call->ourCallerId)+1;
|
|
|
|
msgbuf[i++] = ieLen;
|
|
|
|
memcpy(msgbuf+i, call->ourCallerId, ieLen-1);
|
|
|
|
i += ieLen-1;
|
|
|
|
msgbuf[i++] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add calling Party ie */
|
|
|
|
if(pq931Msg->callingPartyNumberIE)
|
|
|
|
{
|
|
|
|
msgbuf[i++] = Q931CallingPartyNumberIE;
|
|
|
|
msgbuf[i++] = pq931Msg->callingPartyNumberIE->length;
|
|
|
|
memcpy(msgbuf+i, pq931Msg->callingPartyNumberIE->data,
|
|
|
|
pq931Msg->callingPartyNumberIE->length);
|
|
|
|
i += pq931Msg->callingPartyNumberIE->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add called Party ie */
|
|
|
|
if(pq931Msg->calledPartyNumberIE)
|
|
|
|
{
|
|
|
|
msgbuf[i++] = Q931CalledPartyNumberIE;
|
|
|
|
msgbuf[i++] = pq931Msg->calledPartyNumberIE->length;
|
|
|
|
memcpy(msgbuf+i, pq931Msg->calledPartyNumberIE->data,
|
|
|
|
pq931Msg->calledPartyNumberIE->length);
|
|
|
|
i += pq931Msg->calledPartyNumberIE->length;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Add keypad ie */
|
|
|
|
if(pq931Msg->keypadIE)
|
|
|
|
{
|
|
|
|
msgbuf[i++] = Q931KeypadIE;
|
|
|
|
msgbuf[i++] = pq931Msg->keypadIE->length;
|
|
|
|
memcpy(msgbuf+i, pq931Msg->keypadIE->data, pq931Msg->keypadIE->length);
|
|
|
|
i += pq931Msg->keypadIE->length;
|
|
|
|
}
|
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
if(pq931Msg->callstateIE) {
|
|
|
|
msgbuf[i++] = Q931CallStateIE;
|
|
|
|
msgbuf[i++] = pq931Msg->callstateIE->length;
|
|
|
|
memcpy(msgbuf+i, pq931Msg->callstateIE->data, pq931Msg->callstateIE->length);
|
|
|
|
i += pq931Msg->callstateIE->length;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Note: Have to fix this, though it works. Need to get rid of ie list.
|
2009-06-30 16:40:38 +00:00
|
|
|
Right now we only put UUIE in ie list. Can be easily removed.
|
|
|
|
*/
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
for(j = 0, curNode = pq931Msg->ies.head; j < (int)pq931Msg->ies.count; j++)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
Q931InformationElement *ie = (Q931InformationElement*) curNode->data;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ieLen = ie->length;
|
|
|
|
|
|
|
|
/* Add the ie discriminator in message buffer */
|
2017-12-22 14:23:22 +00:00
|
|
|
msgbuf[i++] = ie->discriminator;
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* For user-user IE, we have to add protocol discriminator */
|
|
|
|
if (ie->discriminator == Q931UserUserIE)
|
|
|
|
{
|
|
|
|
ieLen++; /* length includes protocol discriminator octet. */
|
|
|
|
msgbuf[i++] = (ieLen>>8); /* 1st octet for length */
|
|
|
|
msgbuf[i++] = ieLen; /* 2nd octet for length */
|
|
|
|
ieLen--;
|
|
|
|
msgbuf[i++] = 5; /* protocol discriminator */
|
|
|
|
memcpy((msgbuf + i), ie->data, ieLen);
|
|
|
|
|
|
|
|
i += ieLen;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OOTRACEWARN1("Warning: Only UUIE is supported currently\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// len = i+1-4; /* complete message length */
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Tpkt length octets populated with total length of the message */
|
|
|
|
if(msgbuf[0] != OOFacility)
|
|
|
|
{
|
|
|
|
len = i-1;
|
2017-12-22 14:23:22 +00:00
|
|
|
msgbuf[3] = (len >> 8);
|
2009-06-30 16:40:38 +00:00
|
|
|
msgbuf[4] = len; /* including tpkt header */
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
len = i-4;
|
|
|
|
msgbuf[6] = (len >> 8);
|
|
|
|
msgbuf[7] = len;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
#ifndef _COMPACT
|
|
|
|
if(msgbuf[0] != OOFacility)
|
2009-11-04 22:10:44 +00:00
|
|
|
ooQ931PrintMessage (call, (unsigned char *)msgbuf+5, len-4);
|
2009-06-30 16:40:38 +00:00
|
|
|
else
|
2009-11-04 22:10:44 +00:00
|
|
|
ooQ931PrintMessage (call, (unsigned char *)msgbuf+8, len-4);
|
2009-06-30 16:40:38 +00:00
|
|
|
#endif
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-04 21:42:05 +00:00
|
|
|
/* Handle FS receive channels for early media */
|
|
|
|
|
|
|
|
int ooHandleFastStartChannels(OOH323CallData *pCall)
|
|
|
|
{
|
2012-07-05 11:42:23 +00:00
|
|
|
int i = 0, remoteMediaControlPort = 0, dir = 0;
|
2012-07-04 21:42:05 +00:00
|
|
|
char remoteMediaControlIP[2 + 8 * 4 + 7];
|
|
|
|
DListNode *pNode = NULL;
|
|
|
|
H245OpenLogicalChannel *olc = NULL;
|
|
|
|
ooH323EpCapability *epCap = NULL;
|
|
|
|
H245H2250LogicalChannelParameters *h2250lcp = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* If fast start supported and remote endpoint has sent faststart element */
|
|
|
|
if (OO_TESTFLAG(pCall->flags, OO_M_FASTSTART) &&
|
|
|
|
pCall->remoteFastStartOLCs.count>0) {
|
|
|
|
|
|
|
|
/* Go though all the proposed channels */
|
|
|
|
|
2012-07-05 11:42:23 +00:00
|
|
|
for (i = 0; i < (int)pCall->remoteFastStartOLCs.count; i++) {
|
2012-07-04 21:42:05 +00:00
|
|
|
|
|
|
|
pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i);
|
|
|
|
olc = (H245OpenLogicalChannel*)pNode->data;
|
|
|
|
|
|
|
|
/* Don't support both direction channel */
|
|
|
|
if (olc->forwardLogicalChannelParameters.dataType.t !=
|
|
|
|
T_H245DataType_nullData &&
|
|
|
|
olc->m.reverseLogicalChannelParametersPresent) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check forward logic channel */
|
|
|
|
if (olc->forwardLogicalChannelParameters.dataType.t !=
|
|
|
|
T_H245DataType_nullData) {
|
|
|
|
/* Forward Channel - remote transmits - local receives */
|
|
|
|
OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n",
|
|
|
|
olc->forwardLogicalChannelNumber, pCall->callType,
|
|
|
|
pCall->callToken);
|
|
|
|
dir = OORX;
|
|
|
|
epCap = ooIsDataTypeSupported(pCall,
|
|
|
|
&olc->forwardLogicalChannelParameters.dataType,
|
|
|
|
OORX);
|
|
|
|
|
|
|
|
if (!epCap) {
|
|
|
|
continue; /* Not Supported Channel */
|
|
|
|
}
|
|
|
|
|
|
|
|
OOTRACEINFO1("Receive Channel data type supported\n");
|
|
|
|
if (olc->forwardLogicalChannelParameters.multiplexParameters.t !=
|
|
|
|
T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) {
|
|
|
|
OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
|
|
|
|
"channel %d (%s, %s)\n",
|
|
|
|
olc->forwardLogicalChannelNumber,
|
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
|
|
|
|
|
|
|
|
/* Check session is Not already established */
|
|
|
|
if (ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive")) {
|
|
|
|
|
|
|
|
OOTRACEINFO4("Receive channel with sessionID %d already "
|
|
|
|
"established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID,
|
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract mediaControlChannel info, if supplied */
|
|
|
|
if (h2250lcp->m.mediaControlChannelPresent) {
|
|
|
|
if (OO_OK != ooGetIpPortFromH245TransportAddress(pCall,
|
|
|
|
&h2250lcp->mediaControlChannel,
|
|
|
|
remoteMediaControlIP, &remoteMediaControlPort)) {
|
|
|
|
OOTRACEERR3("Error: Invalid media control channel address "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Don't check reverse channels */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir & OORX) {
|
|
|
|
remoteMediaControlPort--;
|
|
|
|
if (gH323ep.h323Callbacks.onMediaChanged &&
|
|
|
|
pCall->callState < OO_CALL_CLEAR) {
|
|
|
|
gH323ep.h323Callbacks.onMediaChanged(pCall, remoteMediaControlIP,
|
|
|
|
remoteMediaControlPort);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return ASN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg,
|
2009-06-30 16:40:38 +00:00
|
|
|
ASN1UINT *fsCount, ASN1DynOctStr **fsElem)
|
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2017-12-22 14:23:22 +00:00
|
|
|
OOCTXT *pctxt = pCall->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
int ret = 0, i=0, j=0, remoteMediaPort=0, remoteMediaControlPort = 0, dir=0;
|
2011-04-12 21:59:18 +00:00
|
|
|
char remoteMediaIP[2+8*4+7], remoteMediaControlIP[2+8*4+7];
|
2009-06-30 16:40:38 +00:00
|
|
|
DListNode *pNode = NULL;
|
|
|
|
H245OpenLogicalChannel *olc = NULL, printOlc;
|
|
|
|
ooH323EpCapability *epCap = NULL;
|
|
|
|
ASN1DynOctStr *pFS=NULL;
|
2017-12-22 14:23:22 +00:00
|
|
|
H245H2250LogicalChannelParameters *h2250lcp = NULL;
|
2009-06-30 16:40:38 +00:00
|
|
|
ooLogicalChannel* pChannel;
|
|
|
|
|
|
|
|
|
|
|
|
if(pCall->pFastStartRes) {
|
|
|
|
ASN1UINT k = 0;
|
|
|
|
ASN1OCTET* pData;
|
|
|
|
|
|
|
|
/* copy the stored fast start response to structure */
|
|
|
|
*fsCount = pCall->pFastStartRes->n;
|
|
|
|
*fsElem = (ASN1DynOctStr*)
|
|
|
|
memAlloc(pctxt, pCall->pFastStartRes->n * sizeof(ASN1DynOctStr));
|
|
|
|
|
|
|
|
for(k = 0; k < pCall->pFastStartRes->n; k ++) {
|
|
|
|
(*fsElem)[k].numocts = pCall->pFastStartRes->elem[k].numocts;
|
|
|
|
pData = (ASN1OCTET*) memAlloc(
|
|
|
|
pctxt, (*fsElem)[k].numocts * sizeof(ASN1OCTET));
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(pData,
|
|
|
|
pCall->pFastStartRes->elem[k].data,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->pFastStartRes->elem[k].numocts);
|
|
|
|
(*fsElem)[k].data = pData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ASN_OK;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* If fast start supported and remote endpoint has sent faststart element */
|
2017-12-22 14:23:22 +00:00
|
|
|
if(OO_TESTFLAG(pCall->flags, OO_M_FASTSTART) &&
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->remoteFastStartOLCs.count>0)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
pFS = (ASN1DynOctStr*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr));
|
|
|
|
if(!pFS)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooSetFastStartResponse - pFS (%s, %s)\n",
|
|
|
|
pCall->callType, pCall->callToken);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(pFS, 0, pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr));
|
|
|
|
|
|
|
|
/* Go though all the proposed channels */
|
|
|
|
for(i=0, j=0; i<(int)pCall->remoteFastStartOLCs.count; i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i);
|
|
|
|
olc = (H245OpenLogicalChannel*)pNode->data;
|
|
|
|
|
|
|
|
/* Don't support both direction channel */
|
2017-12-22 14:23:22 +00:00
|
|
|
if(olc->forwardLogicalChannelParameters.dataType.t !=
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H245DataType_nullData &&
|
|
|
|
olc->m.reverseLogicalChannelParametersPresent)
|
|
|
|
{
|
|
|
|
OOTRACEINFO3("Ignoring bidirectional OLC as it is not supported."
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check forward logic channel */
|
2017-12-22 14:23:22 +00:00
|
|
|
if(olc->forwardLogicalChannelParameters.dataType.t !=
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H245DataType_nullData)
|
|
|
|
{
|
|
|
|
/* Forward Channel - remote transmits - local receives */
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n",
|
|
|
|
olc->forwardLogicalChannelNumber, pCall->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callToken);
|
|
|
|
dir = OORX;
|
2017-12-22 14:23:22 +00:00
|
|
|
epCap = ooIsDataTypeSupported(pCall,
|
2009-06-30 16:40:38 +00:00
|
|
|
&olc->forwardLogicalChannelParameters.dataType,
|
|
|
|
OORX);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!epCap) { continue; } /* Not Supported Channel */
|
|
|
|
|
|
|
|
OOTRACEINFO1("Receive Channel data type supported\n");
|
|
|
|
if(olc->forwardLogicalChannelParameters.multiplexParameters.t !=
|
|
|
|
T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
|
|
|
|
{
|
|
|
|
OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
|
2017-12-22 14:23:22 +00:00
|
|
|
"channel %d (%s, %s)\n",
|
|
|
|
olc->forwardLogicalChannelNumber,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
|
|
|
|
|
|
|
|
/* Check session is Not already established */
|
|
|
|
if(ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive"))
|
|
|
|
{
|
|
|
|
|
|
|
|
OOTRACEINFO4("Receive channel with sessionID %d already "
|
2017-12-22 14:23:22 +00:00
|
|
|
"established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract mediaControlChannel info, if supplied */
|
|
|
|
if(h2250lcp->m.mediaControlChannelPresent)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall,
|
|
|
|
&h2250lcp->mediaControlChannel,
|
2009-06-30 16:40:38 +00:00
|
|
|
remoteMediaControlIP, &remoteMediaControlPort))
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Invalid media control channel address "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Check reverse logical channel */
|
|
|
|
else if(olc->m.reverseLogicalChannelParametersPresent)
|
|
|
|
{
|
|
|
|
/* Reverse channel - remote receives - local transmits */
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGC4("Processing received reverse olc %d (%s, %s)\n",
|
|
|
|
olc->forwardLogicalChannelNumber, pCall->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callToken);
|
|
|
|
dir = OOTX;
|
2017-12-22 14:23:22 +00:00
|
|
|
epCap = ooIsDataTypeSupported(pCall,
|
2009-06-30 16:40:38 +00:00
|
|
|
&olc->reverseLogicalChannelParameters.dataType,
|
|
|
|
OOTX);
|
|
|
|
|
|
|
|
if(!epCap) { continue; } /* Capability not supported */
|
|
|
|
|
|
|
|
OOTRACEINFO1("Transmit Channel data type supported\n");
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
if(olc->reverseLogicalChannelParameters.multiplexParameters.t !=
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
|
|
|
|
{
|
|
|
|
OOTRACEERR4("ERROR:Unknown multiplex parameter type for "
|
2017-12-22 14:23:22 +00:00
|
|
|
"channel %d (%s, %s)\n",
|
|
|
|
olc->forwardLogicalChannelNumber,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check session is not established */
|
|
|
|
if(ooIsSessionEstablished(pCall, olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "transmit"))
|
|
|
|
{
|
|
|
|
|
|
|
|
OOTRACEINFO4("Transmit session with sessionID %d already "
|
|
|
|
"established.(%s, %s)\n", olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, pCall->callType, pCall->callToken);
|
|
|
|
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Extract the remote media endpoint address */
|
|
|
|
h2250lcp = olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
|
|
|
|
if(!h2250lcp)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
|
|
|
|
"reverse Logical Channel Parameters found. "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Reverse Channel info will be always present, crash proof */
|
|
|
|
if(!h2250lcp->m.mediaChannelPresent)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
|
|
|
|
"reverse media channel information found. "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get IP, PORT of reverse channel */
|
2017-12-22 14:23:22 +00:00
|
|
|
if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall,
|
|
|
|
&h2250lcp->mediaChannel,
|
2009-06-30 16:40:38 +00:00
|
|
|
remoteMediaIP, &remoteMediaPort))
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Invalid media channel address "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract mediaControlChannel info, if supplied */
|
|
|
|
if(h2250lcp->m.mediaControlChannelPresent)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall,
|
|
|
|
&h2250lcp->mediaControlChannel,
|
2009-06-30 16:40:38 +00:00
|
|
|
remoteMediaControlIP, &remoteMediaControlPort))
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Invalid media control channel address "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
memFreePtr(pCall->pctxt, epCap);
|
|
|
|
epCap = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dir & OOTX)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
/* According to the spec if we are accepting olc for transmission
|
|
|
|
from called endpoint to calling endpoint, called endpoint should
|
|
|
|
insert a unqiue forwardLogicalChannelNumber into olc
|
|
|
|
*/
|
|
|
|
olc->forwardLogicalChannelNumber = pCall->logicalChanNoCur++;
|
|
|
|
if(pCall->logicalChanNoCur > pCall->logicalChanNoMax)
|
|
|
|
pCall->logicalChanNoCur = pCall->logicalChanNoBase;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ooBuildFastStartOLC(pCall, olc, epCap, pctxt, dir);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
pChannel = ooFindLogicalChannelByLogicalChannelNo
|
|
|
|
(pCall, olc->forwardLogicalChannelNumber);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* start receive and tramsmit channel listening */
|
|
|
|
if(dir & OORX)
|
|
|
|
{
|
|
|
|
strcpy(pChannel->remoteIP, remoteMediaControlIP);
|
|
|
|
pChannel->remoteMediaControlPort = remoteMediaControlPort;
|
|
|
|
if(epCap->startReceiveChannel)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
|
|
|
epCap->startReceiveChannel(pCall, pChannel);
|
|
|
|
OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
(epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video",
|
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
OOTRACEERR4("ERROR:No callback registered to start receive %s"
|
2017-12-22 14:23:22 +00:00
|
|
|
" channel (%s, %s)\n",
|
|
|
|
(epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video",
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dir & OOTX)
|
|
|
|
{
|
|
|
|
pChannel->remoteMediaPort = remoteMediaPort;
|
|
|
|
strcpy(pChannel->remoteIP, remoteMediaIP);
|
|
|
|
pChannel->remoteMediaControlPort = remoteMediaControlPort;
|
|
|
|
|
|
|
|
if(epCap->startTransmitChannel)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
|
|
|
epCap->startTransmitChannel(pCall, pChannel);
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEINFO3("Transmit channel of type audio started "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
/*OO_SETFLAG (pCall->flags, OO_M_AUDIO);*/
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
OOTRACEERR3("ERROR:No callback registered to start transmit"
|
2017-12-22 14:23:22 +00:00
|
|
|
" audio channel (%s, %s)\n", pCall->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Encode fast start element */
|
|
|
|
setPERBuffer(pctxt, NULL, 0, 1);
|
|
|
|
if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Encoding of olc failed for faststart "
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, pQ931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(pCall->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
pCall->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
pCall->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
pFS[j].data = (unsigned char *) encodeGetMsgPtr(pctxt, (int *)&(pFS[j].numocts));
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* start print call */
|
2009-11-04 22:10:44 +00:00
|
|
|
setPERBuffer(pctxt, (unsigned char*)pFS[j].data, pFS[j].numocts, 1);
|
2009-06-30 16:40:38 +00:00
|
|
|
initializePrintHandler(&printHandler, "FastStart Element");
|
|
|
|
setEventHandler (pctxt, &printHandler);
|
|
|
|
memset(&printOlc, 0, sizeof(printOlc));
|
|
|
|
ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc));
|
|
|
|
if(ret != ASN_OK)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error: Failed decoding FastStart Element (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callType, pCall->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, pQ931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(pCall->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
pCall->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
pCall->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
finishPrint();
|
2017-12-22 14:23:22 +00:00
|
|
|
removeEventHandler(pctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
/* end print call */
|
|
|
|
|
|
|
|
olc = NULL;
|
|
|
|
j++;
|
|
|
|
epCap = NULL;
|
|
|
|
}
|
|
|
|
OOTRACEDBGA4("Added %d fast start elements to message "
|
|
|
|
"(%s, %s)\n", j, pCall->callType, pCall->callToken);
|
|
|
|
if(j != 0)
|
|
|
|
{
|
|
|
|
ASN1UINT k = 0;
|
|
|
|
ASN1OCTET* pData;
|
|
|
|
//*fsPresent = TRUE;
|
|
|
|
*fsCount = j;
|
2017-12-22 14:23:22 +00:00
|
|
|
*fsElem = pFS;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* save the fast start response for later use in ALERTING, CONNECT */
|
|
|
|
pCall->pFastStartRes = (FastStartResponse*)
|
|
|
|
memAlloc(pCall->pctxt, sizeof(FastStartResponse));
|
|
|
|
pCall->pFastStartRes->n = j;
|
2017-12-22 14:23:22 +00:00
|
|
|
pCall->pFastStartRes->elem = (ASN1DynOctStr*) memAlloc(pCall->pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->pFastStartRes->n * sizeof(ASN1DynOctStr));
|
|
|
|
|
|
|
|
for(k = 0; k < pCall->pFastStartRes->n; k ++) {
|
|
|
|
pCall->pFastStartRes->elem[k].numocts = (*fsElem)[k].numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
pData = (ASN1OCTET*) memAlloc(pCall->pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->pFastStartRes->elem[k].numocts * sizeof(ASN1OCTET));
|
|
|
|
memcpy(pData, (*fsElem)[k].data, (*fsElem)[k].numocts);
|
|
|
|
pCall->pFastStartRes->elem[k].data = pData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
OOTRACEINFO3("None of the faststart elements received in setup can be"
|
2017-12-22 14:23:22 +00:00
|
|
|
" supported, rejecting faststart.(%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
pCall->callType, pCall->callToken);
|
|
|
|
//*fsPresent = FALSE;
|
|
|
|
OO_CLRFLAG(pCall->flags, OO_M_FASTSTART);
|
|
|
|
OOTRACEDBGC3("Faststart for pCall is disabled by local endpoint."
|
|
|
|
"(%s, %s)\n", pCall->callType, pCall->callToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ASN_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
H225 CapSet/MS determination helper function
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ooSendTCSandMSD(OOH323CallData *call)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
if(call->localTermCapState == OO_LocalTermCapExchange_Idle) {
|
|
|
|
ret = ooSendTermCapMsg(call);
|
|
|
|
if(ret != OO_OK) {
|
|
|
|
OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ooSendCallProceeding(OOH323CallData *call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2009-06-30 16:40:38 +00:00
|
|
|
H225VendorIdentifier *vendor;
|
|
|
|
H225CallProceeding_UUIE *callProceeding;
|
|
|
|
Q931Message *q931msg=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGC3("Building CallProceeding (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931CallProceedingMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR1("Error: In allocating memory for - H225 Call "
|
|
|
|
"Proceeding message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendCallProceeding - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG(call->flags, OO_M_TUNNELING);
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_callProceeding;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
callProceeding = (H225CallProceeding_UUIE*)memAlloc(pctxt,
|
|
|
|
sizeof(H225CallProceeding_UUIE));
|
|
|
|
if(!callProceeding)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendCallProceeding - callProceeding\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(callProceeding, 0, sizeof(H225CallProceeding_UUIE));
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.callProceeding = callProceeding;
|
|
|
|
callProceeding->m.multipleCallsPresent = 1;
|
|
|
|
callProceeding->m.maintainConnectionPresent = 1;
|
|
|
|
callProceeding->multipleCalls = FALSE;
|
|
|
|
callProceeding->maintainConnection = FALSE;
|
|
|
|
|
|
|
|
callProceeding->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
callProceeding->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(callProceeding->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
callProceeding->protocolIdentifier = gProtocolID;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Pose as Terminal or Gateway */
|
|
|
|
if(gH323ep.isGateway)
|
|
|
|
callProceeding->destinationInfo.m.gatewayPresent = TRUE;
|
|
|
|
else
|
|
|
|
callProceeding->destinationInfo.m.terminalPresent = TRUE;
|
|
|
|
|
|
|
|
callProceeding->destinationInfo.m.vendorPresent = 1;
|
|
|
|
vendor = &callProceeding->destinationInfo.vendor;
|
|
|
|
if(gH323ep.productID)
|
|
|
|
{
|
|
|
|
vendor->m.productIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(vendor->productId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->productId.data, gH323ep.productID,
|
2009-06-30 16:40:38 +00:00
|
|
|
vendor->productId.numocts);
|
|
|
|
}
|
|
|
|
if(gH323ep.versionID)
|
|
|
|
{
|
|
|
|
vendor->m.versionIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(vendor->versionId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->versionId.data, gH323ep.versionID,
|
|
|
|
vendor->versionId.numocts);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode;
|
|
|
|
vendor->vendor.t35Extension = gH323ep.t35Extension;
|
|
|
|
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
OOTRACEDBGA3("Built Call Proceeding(%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
2009-06-30 16:40:38 +00:00
|
|
|
ret = ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue CallProceeding message to outbound queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooSendAlerting(OOH323CallData *call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2009-06-30 16:40:38 +00:00
|
|
|
H225Alerting_UUIE *alerting;
|
|
|
|
H225VendorIdentifier *vendor;
|
|
|
|
Q931Message *q931msg=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931AlertingMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR1("Error: In allocating memory for - H225 "
|
|
|
|
"Alerting message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
call->alertingTime = (H235TimeStamp) time(NULL);
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendAlerting - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags,
|
|
|
|
OO_M_TUNNELING);
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_alerting;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
alerting = (H225Alerting_UUIE*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H225Alerting_UUIE));
|
|
|
|
if(!alerting)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendAlerting - alerting\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(alerting, 0, sizeof(H225Alerting_UUIE));
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.alerting = alerting;
|
|
|
|
alerting->m.multipleCallsPresent = 1;
|
|
|
|
alerting->m.maintainConnectionPresent = 1;
|
|
|
|
alerting->multipleCalls = FALSE;
|
|
|
|
alerting->maintainConnection = FALSE;
|
|
|
|
|
|
|
|
/*Populate aliases */
|
|
|
|
alerting->m.alertingAddressPresent = TRUE;
|
|
|
|
if(call->ourAliases)
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, call->ourAliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&alerting->alertingAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
else
|
|
|
|
ret = ooPopulateAliasList(pctxt, gH323ep.aliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&alerting->alertingAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(OO_OK != ret)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Failed to populate alias list in Alert message\n");
|
|
|
|
memReset(pctxt);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
alerting->m.presentationIndicatorPresent = TRUE;
|
2017-12-22 14:23:22 +00:00
|
|
|
alerting->presentationIndicator.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225PresentationIndicator_presentationAllowed;
|
|
|
|
alerting->m.screeningIndicatorPresent = TRUE;
|
|
|
|
alerting->screeningIndicator = userProvidedNotScreened;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alerting->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
alerting->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(alerting->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
alerting->protocolIdentifier = gProtocolID;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Pose as Terminal or Gateway */
|
|
|
|
if(gH323ep.isGateway)
|
|
|
|
alerting->destinationInfo.m.gatewayPresent = TRUE;
|
|
|
|
else
|
|
|
|
alerting->destinationInfo.m.terminalPresent = TRUE;
|
|
|
|
|
|
|
|
alerting->destinationInfo.m.vendorPresent = 1;
|
|
|
|
vendor = &alerting->destinationInfo.vendor;
|
|
|
|
if(gH323ep.productID)
|
|
|
|
{
|
|
|
|
vendor->m.productIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(vendor->productId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->productId.data, gH323ep.productID,
|
2009-06-30 16:40:38 +00:00
|
|
|
vendor->productId.numocts);
|
|
|
|
}
|
|
|
|
if(gH323ep.versionID)
|
|
|
|
{
|
|
|
|
vendor->m.versionIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(vendor->versionId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->versionId.data, gH323ep.versionID,
|
|
|
|
vendor->versionId.numocts);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode;
|
|
|
|
vendor->vendor.t35Extension = gH323ep.t35Extension;
|
|
|
|
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
if (!call->fsSent) {
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooSetFastStartResponse(call, q931msg,
|
2009-11-04 22:10:44 +00:00
|
|
|
&alerting->fastStart.n, &alerting->fastStart.elem);
|
|
|
|
if(ret != ASN_OK) { return ret; }
|
|
|
|
if(alerting->fastStart.n > 0) {
|
|
|
|
alerting->m.fastStartPresent = TRUE;
|
|
|
|
call->fsSent = TRUE;
|
|
|
|
} else
|
|
|
|
alerting->m.fastStartPresent = FALSE;
|
|
|
|
} else {
|
2009-06-30 16:40:38 +00:00
|
|
|
alerting->m.fastStartPresent = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
OOTRACEDBGA3("Built Alerting (%s, %s)\n", call->callType, call->callToken);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ret = ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
|
2011-02-10 13:29:19 +00:00
|
|
|
if (call->h225version >= 4) {
|
|
|
|
ooSendTCSandMSD(call);
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
memReset (call->msgctxt);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooSendProgress(OOH323CallData *call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2009-11-04 22:10:44 +00:00
|
|
|
H225Progress_UUIE *progress;
|
|
|
|
H225VendorIdentifier *vendor;
|
|
|
|
Q931Message *q931msg=NULL;
|
|
|
|
H225TransportAddress_ipAddress *h245IpAddr;
|
2011-04-12 21:59:18 +00:00
|
|
|
H225TransportAddress_ip6Address *h245Ip6Addr;
|
2009-11-04 22:10:44 +00:00
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
|
|
|
|
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931ProgressMsg);
|
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
OOTRACEERR1("Error: In allocating memory for - H225 "
|
|
|
|
"Alerting message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendAlerting - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags,
|
|
|
|
OO_M_TUNNELING);
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-11-04 22:10:44 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_progress;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
progress = (H225Progress_UUIE*)memAlloc(pctxt,
|
2009-11-04 22:10:44 +00:00
|
|
|
sizeof(H225Progress_UUIE));
|
|
|
|
if(!progress)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendProgress- alerting\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(progress, 0, sizeof(H225Progress_UUIE));
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.progress = progress;
|
|
|
|
progress->m.multipleCallsPresent = 1;
|
|
|
|
progress->m.maintainConnectionPresent = 1;
|
|
|
|
progress->multipleCalls = FALSE;
|
|
|
|
progress->maintainConnection = FALSE;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
progress->callIdentifier.guid.numocts =
|
2009-11-04 22:10:44 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(progress->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-11-04 22:10:44 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
progress->protocolIdentifier = gProtocolID;
|
2009-11-04 22:10:44 +00:00
|
|
|
|
|
|
|
/* Pose as Terminal or Gateway */
|
|
|
|
if(gH323ep.isGateway)
|
|
|
|
progress->destinationInfo.m.gatewayPresent = TRUE;
|
|
|
|
else
|
|
|
|
progress->destinationInfo.m.terminalPresent = TRUE;
|
|
|
|
|
|
|
|
progress->destinationInfo.m.vendorPresent = 1;
|
|
|
|
vendor = &progress->destinationInfo.vendor;
|
|
|
|
if(gH323ep.productID)
|
|
|
|
{
|
|
|
|
vendor->m.productIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID),
|
2009-11-04 22:10:44 +00:00
|
|
|
sizeof(vendor->productId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->productId.data, gH323ep.productID,
|
2009-11-04 22:10:44 +00:00
|
|
|
vendor->productId.numocts);
|
|
|
|
}
|
|
|
|
if(gH323ep.versionID)
|
|
|
|
{
|
|
|
|
vendor->m.versionIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID),
|
2009-11-04 22:10:44 +00:00
|
|
|
sizeof(vendor->versionId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->versionId.data, gH323ep.versionID,
|
|
|
|
vendor->versionId.numocts);
|
2009-11-04 22:10:44 +00:00
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode;
|
|
|
|
vendor->vendor.t35Extension = gH323ep.t35Extension;
|
|
|
|
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
if (!call->fsSent) {
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooSetFastStartResponse(call, q931msg,
|
2009-11-04 22:10:44 +00:00
|
|
|
&progress->fastStart.n, &progress->fastStart.elem);
|
|
|
|
if(ret != ASN_OK) { return ret; }
|
|
|
|
if(progress->fastStart.n > 0) {
|
|
|
|
progress->m.fastStartPresent = TRUE;
|
|
|
|
call->fsSent = TRUE;
|
|
|
|
} else
|
|
|
|
progress->m.fastStartPresent = FALSE;
|
|
|
|
} else {
|
|
|
|
progress->m.fastStartPresent = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add h245 listener address. Do not add H245 listener address in case
|
|
|
|
of tunneling. */
|
2017-12-22 14:23:22 +00:00
|
|
|
if (/* (!OO_TESTFLAG(call->flags, OO_M_FASTSTART) ||
|
2009-11-04 22:10:44 +00:00
|
|
|
call->remoteFastStartOLCs.count == 0) && */
|
|
|
|
!OO_TESTFLAG (call->flags, OO_M_TUNNELING) &&
|
|
|
|
!call->h245listener && ooCreateH245Listener(call) == OO_OK)
|
|
|
|
{
|
2011-04-12 21:59:18 +00:00
|
|
|
if (call->versionIP == 6) {
|
|
|
|
progress->m.h245AddressPresent = TRUE;
|
|
|
|
progress->h245Address.t = T_H225TransportAddress_ip6Address;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
h245Ip6Addr = (H225TransportAddress_ip6Address*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address));
|
|
|
|
if(!h245Ip6Addr)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooSendProgress - h245Ip6Addr"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data);
|
|
|
|
h245Ip6Addr->ip.numocts=16;
|
|
|
|
h245Ip6Addr->port = *(call->h245listenport);
|
|
|
|
progress->h245Address.u.ip6Address = h245Ip6Addr;
|
|
|
|
} else {
|
2009-11-04 22:10:44 +00:00
|
|
|
progress->m.h245AddressPresent = TRUE;
|
|
|
|
progress->h245Address.t = T_H225TransportAddress_ipAddress;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
h245IpAddr = (H225TransportAddress_ipAddress*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress));
|
|
|
|
if(!h245IpAddr)
|
|
|
|
{
|
2011-04-12 21:59:18 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooSendProgress - h245IpAddr"
|
2009-11-04 22:10:44 +00:00
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2011-04-12 21:59:18 +00:00
|
|
|
inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data);
|
2009-11-04 22:10:44 +00:00
|
|
|
h245IpAddr->ip.numocts=4;
|
|
|
|
h245IpAddr->port = *(call->h245listenport);
|
|
|
|
progress->h245Address.u.ipAddress = h245IpAddr;
|
2011-04-12 21:59:18 +00:00
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OOTRACEDBGA3("Built Progress (%s, %s)\n", call->callType, call->callToken);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
|
2010-12-25 16:35:09 +00:00
|
|
|
if (!OO_TESTFLAG(call->flags, OO_M_TUNNELING) && call->h245listener)
|
|
|
|
ooSendStartH245Facility(call);
|
|
|
|
|
2011-02-10 13:29:19 +00:00
|
|
|
if (call->h225version >= 4) {
|
|
|
|
ooSendTCSandMSD(call);
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
memReset (call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-04 21:42:05 +00:00
|
|
|
int ooSendFSUpdate(OOH323CallData *call)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
Q931Message *pQ931Msg = NULL;
|
|
|
|
H225Facility_UUIE *facility = NULL;
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
|
|
|
|
|
|
|
OOTRACEDBGA3("Building FS update message (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
|
|
|
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg);
|
|
|
|
if (ret != OO_OK) {
|
|
|
|
OOTRACEERR3("ERROR: In allocating memory for facility message (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if (!pQ931Msg->userInfo) {
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendFSUpdate - userInfo(%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent = 1;
|
|
|
|
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG (call->flags, OO_M_TUNNELING);
|
|
|
|
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
|
|
|
T_H225H323_UU_PDU_h323_message_body_facility;
|
|
|
|
|
|
|
|
facility = (H225Facility_UUIE*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225Facility_UUIE));
|
|
|
|
|
|
|
|
if (!facility) {
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendFS Update - facility (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility;
|
|
|
|
|
|
|
|
/* Populate Facility UUIE */
|
|
|
|
facility->protocolIdentifier = gProtocolID;
|
|
|
|
facility->m.callIdentifierPresent = 1;
|
|
|
|
facility->callIdentifier.guid.numocts =
|
|
|
|
call->callIdentifier.guid.numocts;
|
|
|
|
memcpy(facility->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.numocts);
|
|
|
|
facility->reason.t = T_H225FacilityReason_forwardedElements;
|
|
|
|
|
|
|
|
ret = ooSetFastStartResponse(call, pQ931Msg,
|
|
|
|
&facility->fastStart.n, &facility->fastStart.elem);
|
|
|
|
if (ret != ASN_OK) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (facility->fastStart.n > 0) {
|
|
|
|
facility->m.fastStartPresent = TRUE;
|
|
|
|
call->fsSent = TRUE;
|
|
|
|
} else {
|
|
|
|
facility->m.fastStartPresent = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
|
|
|
|
|
|
|
ret = ooSendH225Msg(call, pQ931Msg);
|
|
|
|
if (ret != OO_OK) {
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue Facility message to outbound "
|
|
|
|
"queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
memReset(call->msgctxt);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooSendStartH245Facility(OOH323CallData *call)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
int ret=0;
|
|
|
|
Q931Message *pQ931Msg = NULL;
|
|
|
|
H225Facility_UUIE *facility=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
|
|
|
H225TransportAddress_ipAddress *h245IpAddr;
|
2011-04-12 21:59:18 +00:00
|
|
|
H225TransportAddress_ip6Address *h245Ip6Addr;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
OOTRACEDBGA3("Building Facility message (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3
|
|
|
|
("ERROR: In allocating memory for facility message (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!pQ931Msg->userInfo)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendFacility - userInfo(%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG (call->flags, OO_M_TUNNELING);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_facility;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
facility = (H225Facility_UUIE*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAllocZ (pctxt, sizeof(H225Facility_UUIE));
|
|
|
|
|
|
|
|
if(!facility)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendFacility - facility (%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility;
|
|
|
|
|
|
|
|
/* Populate Facility UUIE */
|
2017-12-22 14:23:22 +00:00
|
|
|
facility->protocolIdentifier = gProtocolID;
|
2009-06-30 16:40:38 +00:00
|
|
|
facility->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
facility->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(facility->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2009-11-04 22:10:44 +00:00
|
|
|
facility->reason.t = T_H225FacilityReason_startH245;
|
|
|
|
|
|
|
|
if (!call->h245listener && ooCreateH245Listener(call) != OO_OK) {
|
|
|
|
OOTRACEERR3("Error:No H245Listener, can't send startH245 facility (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
facility->m.h245AddressPresent = TRUE;
|
2011-04-12 21:59:18 +00:00
|
|
|
if (call->versionIP == 6) {
|
|
|
|
facility->h245Address.t = T_H225TransportAddress_ip6Address;
|
2009-11-04 22:10:44 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
h245Ip6Addr = (H225TransportAddress_ip6Address*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address));
|
|
|
|
if(!h245Ip6Addr) {
|
|
|
|
OOTRACEERR3("Error:Memory - ooSendFacility - h245Ip6Addr"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data);
|
|
|
|
h245Ip6Addr->ip.numocts=16;
|
|
|
|
h245Ip6Addr->port = *(call->h245listenport);
|
|
|
|
facility->h245Address.u.ip6Address = h245Ip6Addr;
|
|
|
|
} else {
|
|
|
|
facility->h245Address.t = T_H225TransportAddress_ipAddress;
|
|
|
|
|
|
|
|
h245IpAddr = (H225TransportAddress_ipAddress*)
|
2009-11-04 22:10:44 +00:00
|
|
|
memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress));
|
2011-04-12 21:59:18 +00:00
|
|
|
if(!h245IpAddr) {
|
2009-11-04 22:10:44 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooSendFacility - h245IpAddr"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
2011-04-12 21:59:18 +00:00
|
|
|
}
|
|
|
|
inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data);
|
|
|
|
h245IpAddr->ip.numocts=4;
|
|
|
|
h245IpAddr->port = *(call->h245listenport);
|
|
|
|
facility->h245Address.u.ipAddress = h245IpAddr;
|
2009-11-04 22:10:44 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
|
|
|
|
|
|
|
ret = ooSendH225Msg(call, pQ931Msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3
|
|
|
|
("Error:Failed to enqueue Facility message to outbound "
|
|
|
|
"queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset (&gH323ep.msgctxt); */
|
|
|
|
memReset (call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ooSendStatus(OOH323CallData *call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2011-11-09 19:08:44 +00:00
|
|
|
H225Status_UUIE *status;
|
|
|
|
Q931Message *q931msg=NULL;
|
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGC3("Building StatusMsg (%s, %s)\n", call->callType,
|
2011-11-09 19:08:44 +00:00
|
|
|
call->callToken);
|
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusMsg);
|
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2011-11-09 19:08:44 +00:00
|
|
|
OOTRACEERR1("Error: In allocating memory for - H225 Status "
|
|
|
|
"message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendStatus - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG(call->flags, OO_M_TUNNELING);
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2011-11-09 19:08:44 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_status;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
status = (H225Status_UUIE*)memAllocZ(pctxt,
|
|
|
|
sizeof(H225Status_UUIE));
|
|
|
|
if(!status)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendStatus \n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.status = status;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
status->callIdentifier.guid.numocts =
|
2011-11-09 19:08:44 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(status->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2011-11-09 19:08:44 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
status->protocolIdentifier = gProtocolID;
|
2011-11-09 19:08:44 +00:00
|
|
|
|
|
|
|
ooQ931SetCauseIE(pctxt, q931msg, Q931StatusEnquiryResponse, 0, 0);
|
|
|
|
ooQ931SetCallStateIE(pctxt, q931msg, 10);
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGA3("Built Status (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
2011-11-09 19:08:44 +00:00
|
|
|
ret = ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue Status message to outbound queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooSendStatusInquiry(OOH323CallData *call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2011-11-09 19:08:44 +00:00
|
|
|
H225StatusInquiry_UUIE *statusInq;
|
|
|
|
Q931Message *q931msg=NULL;
|
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGC3("Building StatusInquryMsg (%s, %s)\n", call->callType,
|
2011-11-09 19:08:44 +00:00
|
|
|
call->callToken);
|
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusEnquiryMsg);
|
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2011-11-09 19:08:44 +00:00
|
|
|
OOTRACEERR1("Error: In allocating memory for - H225 Status "
|
|
|
|
"message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendStatus - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG(call->flags, OO_M_TUNNELING);
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2011-11-09 19:08:44 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_statusInquiry;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
statusInq = (H225StatusInquiry_UUIE*)memAllocZ(pctxt,
|
|
|
|
sizeof(H225StatusInquiry_UUIE));
|
|
|
|
if(!statusInq)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendStatusInquiry \n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.statusInquiry = statusInq;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
statusInq->callIdentifier.guid.numocts =
|
2011-11-09 19:08:44 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(statusInq->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2011-11-09 19:08:44 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
statusInq->protocolIdentifier = gProtocolID;
|
2011-11-09 19:08:44 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGA3("Built StatusInquiry (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
2011-11-09 19:08:44 +00:00
|
|
|
ret = ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue Status message to outbound queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
int ooSendReleaseComplete(OOH323CallData *call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2009-06-30 16:40:38 +00:00
|
|
|
Q931Message *q931msg=NULL;
|
|
|
|
H225ReleaseComplete_UUIE *releaseComplete;
|
|
|
|
enum Q931CauseValues cause = Q931ErrorInCauseIE;
|
|
|
|
unsigned h225ReasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEDBGA3("Building Release Complete message to send(%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931ReleaseCompleteMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR3("Error: In ooCreateQ931Message - H225 Release Complete "
|
|
|
|
"message(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooSendReleaseComplete - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
|
|
|
|
|
|
|
releaseComplete = (H225ReleaseComplete_UUIE*)memAlloc(pctxt,
|
|
|
|
sizeof(H225ReleaseComplete_UUIE));
|
|
|
|
if(!releaseComplete)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooSendReleaseComplete - releaseComplete"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(releaseComplete, 0, sizeof(H225ReleaseComplete_UUIE));
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_releaseComplete;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Get cause value and h225 reason code corresponding to OOCallClearReason*/
|
2017-12-22 14:23:22 +00:00
|
|
|
ooQ931GetCauseAndReasonCodeFromCallClearReason(call->callEndReason,
|
2009-06-30 16:40:38 +00:00
|
|
|
&cause, &h225ReasonCode);
|
2009-11-04 22:10:44 +00:00
|
|
|
if (call->q931cause == 0)
|
|
|
|
call->q931cause = cause;
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Set Cause IE */
|
2009-11-04 22:10:44 +00:00
|
|
|
ooQ931SetCauseIE(pctxt, q931msg, call->q931cause, 0, 0);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Set H225 releaseComplete reasonCode */
|
|
|
|
releaseComplete->m.reasonPresent = TRUE;
|
|
|
|
releaseComplete->reason.t = h225ReasonCode;
|
|
|
|
|
|
|
|
/* Add user-user ie */
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_releaseComplete;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.releaseComplete =
|
2009-06-30 16:40:38 +00:00
|
|
|
releaseComplete;
|
|
|
|
releaseComplete->m.callIdentifierPresent = 1;
|
|
|
|
releaseComplete->protocolIdentifier = gProtocolID;
|
2017-12-22 14:23:22 +00:00
|
|
|
releaseComplete->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(releaseComplete->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.numocts);
|
|
|
|
|
|
|
|
OOTRACEDBGA3("Built Release Complete message (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Send H225 message */
|
2009-06-30 16:40:38 +00:00
|
|
|
ret = ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue ReleaseComplete message to outbound"
|
|
|
|
" queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooSendConnect(OOH323CallData *call)
|
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
|
|
|
|
call->connectTime = (H235TimeStamp) time(NULL);
|
|
|
|
|
|
|
|
if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) {
|
|
|
|
if(gH323ep.gkClient->state == GkClientRegistered) {
|
|
|
|
ooGkClientSendIRR(gH323ep.gkClient, call);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ooAcceptCall(call);
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*TODO: Need to clean logical channel in case of failure after creating one */
|
|
|
|
int ooAcceptCall(OOH323CallData *call)
|
|
|
|
{
|
|
|
|
int ret = 0, i=0;
|
|
|
|
H225Connect_UUIE *connect;
|
|
|
|
H225TransportAddress_ipAddress *h245IpAddr;
|
2011-04-12 21:59:18 +00:00
|
|
|
H225TransportAddress_ip6Address *h245Ip6Addr;
|
2009-06-30 16:40:38 +00:00
|
|
|
H225VendorIdentifier *vendor;
|
|
|
|
Q931Message *q931msg=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2017-12-22 14:23:22 +00:00
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931ConnectMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR1("Error: In allocating memory for - H225 "
|
|
|
|
"Connect message\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
/* Set bearer capability */
|
2017-12-22 14:23:22 +00:00
|
|
|
if(OO_OK != ooSetBearerCapabilityIE(pctxt, q931msg, Q931CCITTStd,
|
2009-11-04 22:10:44 +00:00
|
|
|
// Q931TransferUnrestrictedDigital, Q931TransferPacketMode,
|
|
|
|
// Q931TransferRatePacketMode, Q931UserInfoLayer1G722G725))
|
|
|
|
Q931TransferSpeech, Q931TransferCircuitMode,
|
|
|
|
Q931TransferRate64Kbps, Q931UserInfoLayer1G711ALaw))
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Failed to set bearer capability ie. (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)
|
|
|
|
memAllocZ (pctxt,sizeof(H225H323_UserInformation));
|
|
|
|
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooAcceptCall - userInfo\n");
|
|
|
|
return OO_FAILED;
|
2017-12-22 14:23:22 +00:00
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=TRUE;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG (call->flags, OO_M_TUNNELING);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_connect;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
connect = (H225Connect_UUIE*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225Connect_UUIE));
|
|
|
|
|
|
|
|
if(!connect)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooAcceptCall - connect\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.connect = connect;
|
|
|
|
connect->m.fastStartPresent = 0;
|
|
|
|
connect->m.multipleCallsPresent = 1;
|
|
|
|
connect->m.maintainConnectionPresent = 1;
|
|
|
|
connect->multipleCalls = FALSE;
|
|
|
|
connect->maintainConnection = FALSE;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
connect->conferenceID.numocts = 16;
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
connect->conferenceID.data[i] = i + 1;
|
|
|
|
|
|
|
|
connect->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
connect->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(connect->callIdentifier.guid.data, call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
connect->conferenceID.numocts = call->confIdentifier.numocts;
|
|
|
|
memcpy(connect->conferenceID.data, call->confIdentifier.data,
|
|
|
|
call->confIdentifier.numocts);
|
|
|
|
/* Populate alias addresses */
|
|
|
|
connect->m.connectedAddressPresent = TRUE;
|
|
|
|
if(call->ourAliases)
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, call->ourAliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&connect->connectedAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
else
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, gH323ep.aliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&connect->connectedAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(OO_OK != ret)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Failed to populate alias list in Connect message\n");
|
|
|
|
memReset(pctxt);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
connect->m.presentationIndicatorPresent = TRUE;
|
2017-12-22 14:23:22 +00:00
|
|
|
connect->presentationIndicator.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225PresentationIndicator_presentationAllowed;
|
|
|
|
connect->m.screeningIndicatorPresent = TRUE;
|
|
|
|
connect->screeningIndicator = userProvidedNotScreened;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
connect->protocolIdentifier = gProtocolID;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Pose as Terminal or Gateway */
|
|
|
|
if(gH323ep.isGateway)
|
|
|
|
connect->destinationInfo.m.gatewayPresent = TRUE;
|
|
|
|
else
|
|
|
|
connect->destinationInfo.m.terminalPresent = TRUE;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
connect->destinationInfo.m.vendorPresent = 1;
|
|
|
|
vendor = &connect->destinationInfo.vendor;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
vendor->vendor.t35CountryCode = gH323ep.t35CountryCode;
|
|
|
|
vendor->vendor.t35Extension = gH323ep.t35Extension;
|
|
|
|
vendor->vendor.manufacturerCode = gH323ep.manufacturerCode;
|
|
|
|
if(gH323ep.productID)
|
|
|
|
{
|
|
|
|
vendor->m.productIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(vendor->productId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->productId.data, gH323ep.productID,
|
2009-06-30 16:40:38 +00:00
|
|
|
vendor->productId.numocts);
|
|
|
|
}
|
|
|
|
if(gH323ep.versionID)
|
|
|
|
{
|
|
|
|
vendor->m.versionIdPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(vendor->versionId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char *)vendor->versionId.data, gH323ep.versionID,
|
|
|
|
vendor->versionId.numocts);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
if (!call->fsSent) {
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooSetFastStartResponse(call, q931msg,
|
2009-11-04 22:10:44 +00:00
|
|
|
&connect->fastStart.n, &connect->fastStart.elem);
|
|
|
|
if(ret != ASN_OK) { return ret; }
|
|
|
|
if(connect->fastStart.n > 0) {
|
|
|
|
connect->m.fastStartPresent = TRUE;
|
|
|
|
call->fsSent = TRUE;
|
|
|
|
} else
|
|
|
|
connect->m.fastStartPresent = FALSE;
|
|
|
|
} else {
|
2009-06-30 16:40:38 +00:00
|
|
|
connect->m.fastStartPresent = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* free the stored fast start response */
|
|
|
|
if(call->pFastStartRes) {
|
|
|
|
int k;
|
|
|
|
for(k = 0; k < call->pFastStartRes->n; k ++) {
|
|
|
|
memFreePtr(call->pctxt, call->pFastStartRes->elem[k].data);
|
|
|
|
}
|
|
|
|
memFreePtr(call->pctxt, call->pFastStartRes->elem);
|
|
|
|
memFreePtr(call->pctxt, call->pFastStartRes);
|
|
|
|
call->pFastStartRes = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-10 13:29:19 +00:00
|
|
|
/* Add h245 listener address. */
|
|
|
|
/* Do not add H245 listener address in case
|
|
|
|
of fast-start. why? */
|
|
|
|
/* May 20110205 */
|
|
|
|
/* Send h245 listener addr any case if H245 connection isn't established */
|
2017-12-22 14:23:22 +00:00
|
|
|
if (/* (!OO_TESTFLAG(call->flags, OO_M_FASTSTART) ||
|
2009-11-04 22:10:44 +00:00
|
|
|
call->remoteFastStartOLCs.count == 0) && */
|
|
|
|
!OO_TESTFLAG (call->flags, OO_M_TUNNELING) &&
|
2011-02-10 13:29:19 +00:00
|
|
|
( (!call->h245listener && ooCreateH245Listener(call) == OO_OK) ||
|
|
|
|
!call->pH245Channel))
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
connect->m.h245AddressPresent = TRUE;
|
2011-04-12 21:59:18 +00:00
|
|
|
if (call->versionIP == 6) {
|
|
|
|
connect->h245Address.t = T_H225TransportAddress_ip6Address;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
h245Ip6Addr = (H225TransportAddress_ip6Address*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address));
|
|
|
|
if(!h245Ip6Addr)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooAcceptCall - h245Ip6Addr"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data);
|
|
|
|
h245Ip6Addr->ip.numocts=16;
|
|
|
|
h245Ip6Addr->port = *(call->h245listenport);
|
|
|
|
connect->h245Address.u.ip6Address = h245Ip6Addr;
|
|
|
|
} else {
|
|
|
|
connect->h245Address.t = T_H225TransportAddress_ipAddress;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
h245IpAddr = (H225TransportAddress_ipAddress*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress));
|
2011-04-12 21:59:18 +00:00
|
|
|
if(!h245IpAddr)
|
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooAcceptCall - h245IpAddr"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
2011-04-12 21:59:18 +00:00
|
|
|
}
|
|
|
|
inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data);
|
|
|
|
h245IpAddr->ip.numocts=4;
|
|
|
|
h245IpAddr->port = *(call->h245listenport);
|
|
|
|
connect->h245Address.u.ipAddress = h245IpAddr;
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OOTRACEDBGA3("Built H.225 Connect message (%s, %s)\n", call->callType,
|
|
|
|
call->callToken);
|
|
|
|
|
|
|
|
/* H225 message callback */
|
|
|
|
if(gH323ep.h225Callbacks.onBuiltConnect)
|
|
|
|
gH323ep.h225Callbacks.onBuiltConnect(call, q931msg);
|
|
|
|
|
|
|
|
ret=ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue Connect message to outbound queue.(%s, %s)\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt);*/
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
2011-02-10 13:29:19 +00:00
|
|
|
ooSendTCSandMSD(call);
|
2009-11-04 22:10:44 +00:00
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2010-03-14 14:42:59 +00:00
|
|
|
call->callState = OO_CALL_CONNECTED;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2010-03-14 14:42:59 +00:00
|
|
|
if (call->rtdrCount > 0 && call->rtdrInterval > 0) {
|
|
|
|
return ooSendRoundTripDelayRequest(call);
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooH323HandleCallFwdRequest(OOH323CallData *call)
|
|
|
|
{
|
|
|
|
OOH323CallData *fwdedCall=NULL;
|
|
|
|
OOCTXT *pctxt;
|
|
|
|
ooAliases *pNewAlias=NULL, *alias=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
struct timespec ts;
|
2010-03-25 20:40:48 +00:00
|
|
|
struct timeval tv;
|
2012-07-04 18:46:56 +00:00
|
|
|
int i=0, irand=0;
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Note: We keep same callToken, for new call which is going
|
|
|
|
to replace an existing call, thus treating it as a single call.*/
|
|
|
|
|
|
|
|
fwdedCall = ooCreateCall("outgoing", call->callToken);
|
|
|
|
|
|
|
|
pctxt = fwdedCall->pctxt;
|
|
|
|
|
|
|
|
/* Retrieve new destination info from original call */
|
|
|
|
if(!ooUtilsIsStrEmpty(call->pCallFwdData->ip))
|
|
|
|
{
|
|
|
|
strcpy(fwdedCall->remoteIP, call->pCallFwdData->ip);
|
|
|
|
}
|
|
|
|
fwdedCall->remotePort = call->pCallFwdData->port;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->pCallFwdData->aliases)
|
|
|
|
{
|
|
|
|
alias = call->pCallFwdData->aliases;
|
|
|
|
while(alias)
|
|
|
|
{
|
|
|
|
pNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases));
|
|
|
|
pNewAlias->value = (char*) memAlloc(pctxt, strlen(alias->value)+1);
|
|
|
|
if(!pNewAlias || !pNewAlias->value)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323HandleCallFwdRequest - "
|
|
|
|
"pNewAlias/pNewAlias->value"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
ooCleanCall(fwdedCall);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
pNewAlias->type = alias->type;
|
|
|
|
strcpy(pNewAlias->value, alias->value);
|
|
|
|
pNewAlias->next = fwdedCall->remoteAliases;
|
|
|
|
fwdedCall->remoteAliases = pNewAlias;
|
|
|
|
alias = alias->next;
|
|
|
|
pNewAlias = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fwdedCall->callReference = ooGenerateCallReference();
|
|
|
|
ooGenerateCallIdentifier(&fwdedCall->callIdentifier);
|
|
|
|
fwdedCall->confIdentifier.numocts = 16;
|
|
|
|
irand = rand();
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
fwdedCall->confIdentifier.data[i] = irand++;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(gH323ep.gkClient && !OO_TESTFLAG(fwdedCall->flags, OO_M_DISABLEGK))
|
|
|
|
{
|
|
|
|
/* No need to check registration status here as it is already checked for
|
|
|
|
MakeCall command */
|
2012-07-04 18:46:56 +00:00
|
|
|
ooGkClientSendAdmissionRequest(gH323ep.gkClient, fwdedCall, FALSE);
|
2009-06-30 16:40:38 +00:00
|
|
|
fwdedCall->callState = OO_CALL_WAITING_ADMISSION;
|
2009-11-04 22:10:44 +00:00
|
|
|
ast_mutex_lock(&fwdedCall->Lock);
|
2010-03-25 20:40:48 +00:00
|
|
|
tv = ast_tvnow();
|
|
|
|
ts.tv_sec += tv.tv_sec + 24;
|
|
|
|
ts.tv_nsec = tv.tv_usec * 1000;
|
2009-11-04 22:10:44 +00:00
|
|
|
ast_cond_timedwait(&fwdedCall->gkWait, &fwdedCall->Lock, &ts);
|
|
|
|
if (fwdedCall->callState == OO_CALL_WAITING_ADMISSION) /* GK is not responding */
|
|
|
|
fwdedCall->callState = OO_CALL_CLEAR;
|
|
|
|
ast_mutex_unlock(&fwdedCall->Lock);
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
if (fwdedCall->callState < OO_CALL_CLEAR) {
|
|
|
|
ast_mutex_lock(&fwdedCall->Lock);
|
2012-07-04 18:46:56 +00:00
|
|
|
ooH323CallAdmitted (fwdedCall);
|
2009-11-04 22:10:44 +00:00
|
|
|
ast_mutex_unlock(&fwdedCall->Lock);
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooH323NewCall(char *callToken) {
|
|
|
|
OOH323CallData* call;
|
|
|
|
if(!callToken)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR: Invalid callToken parameter to make call\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
call = ooCreateCall("outgoing", callToken);
|
|
|
|
if (!call)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR: Can't create call %s\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts)
|
|
|
|
{
|
|
|
|
OOH323CallData *call;
|
2010-03-27 23:51:13 +00:00
|
|
|
int ret=OO_OK, i=0, irand=0;
|
2011-04-12 21:59:18 +00:00
|
|
|
char tmp[2+8*4+7]="\0";
|
2009-06-30 16:40:38 +00:00
|
|
|
char *ip=NULL, *port = NULL;
|
2010-03-25 20:40:48 +00:00
|
|
|
struct timeval tv;
|
2009-11-04 22:10:44 +00:00
|
|
|
struct timespec ts;
|
2011-04-12 21:59:18 +00:00
|
|
|
struct ast_sockaddr m_addr;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(!dest)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Invalid destination for new call\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
if(!callToken)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR: Invalid callToken parameter to make call\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* call = ooCreateCall("outgoing", callToken); */
|
|
|
|
call = ooFindCallByToken(callToken);
|
|
|
|
if (!call)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR: Can't create call %s\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(opts)
|
|
|
|
{
|
|
|
|
if(opts->fastStart)
|
|
|
|
OO_SETFLAG(call->flags, OO_M_FASTSTART);
|
|
|
|
else
|
|
|
|
OO_CLRFLAG(call->flags, OO_M_FASTSTART);
|
|
|
|
|
|
|
|
if(opts->tunneling)
|
|
|
|
OO_SETFLAG(call->flags, OO_M_TUNNELING);
|
|
|
|
else
|
|
|
|
OO_CLRFLAG(call->flags, OO_M_TUNNELING);
|
|
|
|
|
2012-06-20 17:48:20 +00:00
|
|
|
if(opts->disableGk || gH323ep.gkClient == NULL)
|
2009-06-30 16:40:38 +00:00
|
|
|
OO_SETFLAG(call->flags, OO_M_DISABLEGK);
|
|
|
|
else
|
|
|
|
OO_CLRFLAG(call->flags, OO_M_DISABLEGK);
|
|
|
|
|
|
|
|
call->callMode = opts->callMode;
|
2009-11-04 22:10:44 +00:00
|
|
|
call->transfercap = opts->transfercap;
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
ret = ooParseDestination(call, dest, tmp, 2+8*4+7, &call->remoteAliases);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR2("Error: Failed to parse the destination string %s for "
|
|
|
|
"new call\n", dest);
|
|
|
|
ooCleanCall(call);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Check whether we have ip address */
|
|
|
|
if(!ooUtilsIsStrEmpty(tmp)) {
|
|
|
|
ip = tmp;
|
2011-04-12 21:59:18 +00:00
|
|
|
port = strrchr(tmp, ':');
|
2009-06-30 16:40:38 +00:00
|
|
|
*port = '\0';
|
|
|
|
port++;
|
|
|
|
strcpy(call->remoteIP, ip);
|
2011-04-12 21:59:18 +00:00
|
|
|
ast_parse_arg(ip, PARSE_ADDR, &m_addr);
|
|
|
|
if (ast_sockaddr_is_ipv6(&m_addr))
|
|
|
|
call->versionIP = 6;
|
|
|
|
else
|
|
|
|
call->versionIP = 4;
|
2009-06-30 16:40:38 +00:00
|
|
|
call->remotePort = atoi(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(callToken, call->callToken);
|
|
|
|
call->callReference = ooGenerateCallReference();
|
|
|
|
ooGenerateCallIdentifier(&call->callIdentifier);
|
|
|
|
call->confIdentifier.numocts = 16;
|
|
|
|
irand = rand();
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
call->confIdentifier.data[i] = irand++;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK))
|
|
|
|
{
|
2011-08-30 22:16:13 +00:00
|
|
|
if(gH323ep.gkClient->state == GkClientRegistered) {
|
|
|
|
call->callState = OO_CALL_WAITING_ADMISSION;
|
2014-03-28 18:00:18 +00:00
|
|
|
ast_mutex_lock(&call->GkLock);
|
2011-08-30 22:16:13 +00:00
|
|
|
ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE);
|
|
|
|
tv = ast_tvnow();
|
|
|
|
ts.tv_sec = tv.tv_sec + 24;
|
|
|
|
ts.tv_nsec = tv.tv_usec * 1000;
|
|
|
|
if (call->callState == OO_CALL_WAITING_ADMISSION)
|
|
|
|
ast_cond_timedwait(&call->gkWait, &call->GkLock, &ts);
|
|
|
|
if (call->callState == OO_CALL_WAITING_ADMISSION)
|
2009-11-04 22:10:44 +00:00
|
|
|
call->callState = OO_CALL_CLEAR;
|
2011-08-30 22:16:13 +00:00
|
|
|
ast_mutex_unlock(&call->GkLock);
|
|
|
|
} else {
|
|
|
|
OOTRACEERR1("Error:Aborting outgoing call as not yet"
|
|
|
|
"registered with Gk\n");
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
call->callEndReason = OO_REASON_GK_UNREACHABLE;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* Send as H225 message to calling endpoint */
|
|
|
|
ast_mutex_lock(&call->Lock);
|
2010-03-27 23:51:13 +00:00
|
|
|
if (call->callState < OO_CALL_CLEAR) {
|
2009-11-04 22:10:44 +00:00
|
|
|
if ((ret = ooH323CallAdmitted (call)) != OO_OK) {
|
|
|
|
ast_mutex_unlock(&call->Lock);
|
|
|
|
return ret;
|
|
|
|
}
|
2010-03-27 23:51:13 +00:00
|
|
|
} else ret = OO_FAILED;
|
2009-11-04 22:10:44 +00:00
|
|
|
ast_mutex_unlock(&call->Lock);
|
|
|
|
|
2010-03-27 23:51:13 +00:00
|
|
|
return ret;
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ooH323CallAdmitted(OOH323CallData *call)
|
|
|
|
{
|
|
|
|
int ret=0;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!call)
|
|
|
|
{
|
|
|
|
/* Call not supplied. Must locate it in list */
|
|
|
|
OOTRACEERR1("ERROR: Invalid call parameter to ooH323CallAdmitted");
|
2017-12-22 14:23:22 +00:00
|
|
|
return OO_FAILED;
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp(call->callType, "outgoing")) {
|
|
|
|
ret = ooCreateH225Connection(call);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("ERROR:Failed to create H225 connection to %s:%d\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->remoteIP, call->remotePort);
|
|
|
|
if(call->callState< OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
call->callEndReason = OO_REASON_UNKNOWN;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
|
|
|
|
if(gH323ep.h323Callbacks.onOutgoingCall) {
|
|
|
|
/* Outgoing call callback function */
|
2011-04-12 21:59:18 +00:00
|
|
|
if (gH323ep.h323Callbacks.onOutgoingCall(call) != OO_OK) {
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("ERROR:Failed to setup media to (%s,%d)\n",
|
2011-04-12 21:59:18 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
if(call->callState< OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
call->callEndReason = OO_REASON_UNKNOWN;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ret = ooH323MakeCall_helper(call);
|
2017-12-22 14:23:22 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-06-30 16:40:38 +00:00
|
|
|
/* incoming call */
|
|
|
|
if(gH323ep.h323Callbacks.onIncomingCall) {
|
|
|
|
/* Incoming call callback function */
|
|
|
|
gH323ep.h323Callbacks.onIncomingCall(call);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for manual ringback generation */
|
|
|
|
if(!OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK))
|
|
|
|
{
|
|
|
|
ooSendAlerting(call); /* Send alerting message */
|
|
|
|
|
|
|
|
if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) {
|
|
|
|
ooSendConnect(call); /* Send connect message - call accepted */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooH323MakeCall_helper(OOH323CallData *call)
|
|
|
|
{
|
|
|
|
int ret=0,i=0, k;
|
|
|
|
Q931Message *q931msg = NULL;
|
|
|
|
H225Setup_UUIE *setup;
|
|
|
|
|
|
|
|
ASN1DynOctStr *pFS=NULL;
|
2011-04-12 21:59:18 +00:00
|
|
|
H225TransportAddress_ipAddress *destCallSignalIpAddress,*srcCallSignalIpAddress;
|
|
|
|
H225TransportAddress_ip6Address *destCallSignalIp6Address,*srcCallSignalIp6Address;
|
2009-06-30 16:40:38 +00:00
|
|
|
ooH323EpCapability *epCap=NULL;
|
|
|
|
OOCTXT *pctxt = NULL;
|
|
|
|
H245OpenLogicalChannel *olc, printOlc;
|
|
|
|
ASN1BOOL aligned = 1;
|
|
|
|
ooAliases *pAlias = NULL;
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* pctxt = &gH323ep.msgctxt; */
|
|
|
|
pctxt = call->msgctxt;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931SetupMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Failed to Create Q931 SETUP Message\n ");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
/* Set bearer capability */
|
2017-12-22 14:23:22 +00:00
|
|
|
if(OO_OK != ooSetBearerCapabilityIE(pctxt, q931msg, Q931CCITTStd,
|
2009-11-04 22:10:44 +00:00
|
|
|
// Q931TransferUnrestrictedDigital, Q931TransferPacketMode,
|
|
|
|
call->transfercap, Q931TransferCircuitMode,
|
|
|
|
// Q931TransferRatePacketMode, Q931UserInfoLayer1G722G725))
|
|
|
|
Q931TransferRate64Kbps, Q931UserInfoLayer1G711ALaw))
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Failed to set bearer capability ie.(%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set calling party number Q931 IE */
|
2009-11-04 22:10:44 +00:00
|
|
|
if(call->callingPartyNumber && call->callingPartyNumber[0])
|
|
|
|
ooQ931SetCallingPartyNumberIE(pctxt, q931msg,
|
2009-06-30 16:40:38 +00:00
|
|
|
(const char*)call->callingPartyNumber, 1, 0, 0, 0);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Set called party number Q931 IE */
|
|
|
|
if(call->calledPartyNumber)
|
2017-12-22 14:23:22 +00:00
|
|
|
ooQ931SetCalledPartyNumberIE(pctxt, q931msg,
|
2009-06-30 16:40:38 +00:00
|
|
|
(const char*)call->calledPartyNumber, 1, 0);
|
|
|
|
else if(call->remoteAliases) {
|
|
|
|
pAlias = call->remoteAliases;
|
|
|
|
while(pAlias) {
|
|
|
|
if(pAlias->type == T_H225AliasAddress_dialedDigits)
|
|
|
|
break;
|
|
|
|
pAlias = pAlias->next;
|
|
|
|
}
|
|
|
|
if(pAlias)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
call->calledPartyNumber = (char*)memAlloc(call->pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
strlen(pAlias->value)+1);
|
|
|
|
if(!call->calledPartyNumber)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - "
|
2017-12-22 14:23:22 +00:00
|
|
|
"calledPartyNumber(%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
strcpy(call->calledPartyNumber, pAlias->value);
|
2017-12-22 14:23:22 +00:00
|
|
|
ooQ931SetCalledPartyNumberIE(pctxt, q931msg,
|
2009-06-30 16:40:38 +00:00
|
|
|
(const char*)call->calledPartyNumber, 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("ERROR:Memory - ooH323MakeCall_helper - userInfo\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(q931msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
|
|
|
|
|
|
|
setup = (H225Setup_UUIE*) memAlloc(pctxt, sizeof(H225Setup_UUIE));
|
|
|
|
if(!setup)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - setup (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (setup, 0, sizeof(H225Setup_UUIE));
|
|
|
|
setup->protocolIdentifier = gProtocolID;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Populate Alias Address.*/
|
|
|
|
|
|
|
|
if(call->ourAliases || gH323ep.aliases)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
setup->m.sourceAddressPresent = TRUE;
|
|
|
|
if(call->ourAliases)
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, call->ourAliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&setup->sourceAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
else if(gH323ep.aliases)
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, gH323ep.aliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&setup->sourceAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(OO_OK != ret)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Failed to populate alias list in SETUP message\n");
|
|
|
|
memReset(pctxt);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setup->m.presentationIndicatorPresent = TRUE;
|
2017-12-22 14:23:22 +00:00
|
|
|
setup->presentationIndicator.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225PresentationIndicator_presentationAllowed;
|
|
|
|
setup->m.screeningIndicatorPresent = TRUE;
|
|
|
|
setup->screeningIndicator = userProvidedNotScreened;
|
|
|
|
|
|
|
|
setup->m.multipleCallsPresent = TRUE;
|
|
|
|
setup->multipleCalls = FALSE;
|
|
|
|
setup->m.maintainConnectionPresent = TRUE;
|
|
|
|
setup->maintainConnection = FALSE;
|
|
|
|
|
|
|
|
/* Populate Destination aliases */
|
|
|
|
if(call->remoteAliases)
|
|
|
|
{
|
|
|
|
setup->m.destinationAddressPresent = TRUE;
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, call->remoteAliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&setup->destinationAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(OO_OK != ret)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Failed to populate destination alias list in SETUP"
|
|
|
|
"message\n");
|
|
|
|
memReset(pctxt);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Populate the vendor information */
|
|
|
|
if(gH323ep.isGateway)
|
|
|
|
setup->sourceInfo.m.gatewayPresent = TRUE;
|
|
|
|
else
|
|
|
|
setup->sourceInfo.m.terminalPresent = TRUE;
|
|
|
|
|
|
|
|
setup->sourceInfo.m.vendorPresent=TRUE;
|
|
|
|
setup->sourceInfo.vendor.vendor.t35CountryCode = gH323ep.t35CountryCode;
|
|
|
|
setup->sourceInfo.vendor.vendor.t35Extension = gH323ep.t35Extension;
|
|
|
|
setup->sourceInfo.vendor.vendor.manufacturerCode= gH323ep.manufacturerCode;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(gH323ep.productID)
|
|
|
|
{
|
|
|
|
setup->sourceInfo.vendor.m.productIdPresent=TRUE;
|
|
|
|
setup->sourceInfo.vendor.productId.numocts = ASN1MIN(
|
2017-12-22 14:23:22 +00:00
|
|
|
strlen(gH323ep.productID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(setup->sourceInfo.vendor.productId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char*)setup->sourceInfo.vendor.productId.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
gH323ep.productID, setup->sourceInfo.vendor.productId.numocts);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
setup->sourceInfo.vendor.m.productIdPresent=FALSE;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(gH323ep.versionID)
|
|
|
|
{
|
|
|
|
setup->sourceInfo.vendor.m.versionIdPresent=TRUE;
|
|
|
|
setup->sourceInfo.vendor.versionId.numocts = ASN1MIN(
|
2017-12-22 14:23:22 +00:00
|
|
|
strlen(gH323ep.versionID),
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(setup->sourceInfo.vendor.versionId.data));
|
2017-12-22 14:23:22 +00:00
|
|
|
strncpy((char*)setup->sourceInfo.vendor.versionId.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
gH323ep.versionID, setup->sourceInfo.vendor.versionId.numocts);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
setup->sourceInfo.vendor.m.versionIdPresent=FALSE;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
setup->sourceInfo.mc = FALSE;
|
|
|
|
setup->sourceInfo.undefinedNode = FALSE;
|
|
|
|
|
|
|
|
/* Populate the destination Call Signal Address */
|
2011-04-12 21:59:18 +00:00
|
|
|
setup->m.destCallSignalAddressPresent=TRUE;
|
|
|
|
setup->activeMC=FALSE;
|
|
|
|
if (call->versionIP == 6) {
|
|
|
|
setup->destCallSignalAddress.t=T_H225TransportAddress_ip6Address;
|
|
|
|
destCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt,
|
|
|
|
sizeof(H225TransportAddress_ip6Address));
|
|
|
|
if(!destCallSignalIp6Address)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - "
|
2017-12-22 14:23:22 +00:00
|
|
|
"destCallSignal6Address. (%s, %s)\n", call->callType,
|
2011-04-12 21:59:18 +00:00
|
|
|
call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
inet_pton(AF_INET6, call->remoteIP, destCallSignalIp6Address->ip.data);
|
|
|
|
|
|
|
|
destCallSignalIp6Address->ip.numocts=16;
|
|
|
|
destCallSignalIp6Address->port = call->remotePort;
|
|
|
|
|
|
|
|
setup->destCallSignalAddress.u.ip6Address = destCallSignalIp6Address;
|
|
|
|
} else {
|
|
|
|
setup->destCallSignalAddress.t=T_H225TransportAddress_ipAddress;
|
|
|
|
destCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H225TransportAddress_ipAddress));
|
2011-04-12 21:59:18 +00:00
|
|
|
if(!destCallSignalIpAddress)
|
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - "
|
2017-12-22 14:23:22 +00:00
|
|
|
"destCallSignalAddress. (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
return OO_FAILED;
|
2011-04-12 21:59:18 +00:00
|
|
|
}
|
|
|
|
inet_pton(AF_INET, call->remoteIP, destCallSignalIpAddress->ip.data);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
destCallSignalIpAddress->ip.numocts=4;
|
|
|
|
destCallSignalIpAddress->port = call->remotePort;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
setup->destCallSignalAddress.u.ipAddress = destCallSignalIpAddress;
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Populate the source Call Signal Address */
|
2011-04-12 21:59:18 +00:00
|
|
|
setup->m.sourceCallSignalAddressPresent=TRUE;
|
|
|
|
if (call->versionIP == 6) {
|
|
|
|
setup->sourceCallSignalAddress.t=T_H225TransportAddress_ip6Address;
|
|
|
|
srcCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt,
|
|
|
|
sizeof(H225TransportAddress_ip6Address));
|
|
|
|
if(!srcCallSignalIp6Address)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - srcCallSignal6Address"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
inet_pton(AF_INET6, call->localIP, srcCallSignalIp6Address->ip.data);
|
|
|
|
|
|
|
|
srcCallSignalIp6Address->ip.numocts=16;
|
|
|
|
srcCallSignalIp6Address->port= call->pH225Channel->port;
|
|
|
|
setup->sourceCallSignalAddress.u.ip6Address = srcCallSignalIp6Address;
|
|
|
|
} else {
|
|
|
|
setup->sourceCallSignalAddress.t=T_H225TransportAddress_ipAddress;
|
|
|
|
srcCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H225TransportAddress_ipAddress));
|
2011-04-12 21:59:18 +00:00
|
|
|
if(!srcCallSignalIpAddress)
|
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - srcCallSignalAddress"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
2011-04-12 21:59:18 +00:00
|
|
|
}
|
|
|
|
inet_pton(AF_INET, call->localIP, srcCallSignalIpAddress->ip.data);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
srcCallSignalIpAddress->ip.numocts=4;
|
|
|
|
srcCallSignalIpAddress->port= call->pH225Channel->port;
|
|
|
|
setup->sourceCallSignalAddress.u.ipAddress = srcCallSignalIpAddress;
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
/* No fast start */
|
2009-11-04 22:10:44 +00:00
|
|
|
if(!OO_TESTFLAG(call->flags, OO_M_FASTSTART))
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
setup->m.fastStartPresent = FALSE;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
setup->m.fastStartPresent = TRUE;
|
|
|
|
pFS = (ASN1DynOctStr*)memAlloc(pctxt, gH323ep.noOfCaps*
|
|
|
|
sizeof(ASN1DynOctStr));
|
|
|
|
if(!pFS)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - pFS(%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use preference order of codecs */
|
|
|
|
i=0;
|
|
|
|
for(k=0; k< call->capPrefs.index; k++)
|
|
|
|
{
|
|
|
|
OOTRACEDBGC5("Preffered capability at index %d is %s. (%s, %s)\n",
|
2017-12-22 14:23:22 +00:00
|
|
|
k, ooGetCapTypeText(call->capPrefs.order[k]),
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
|
|
|
|
if(call->ourCaps) {
|
|
|
|
epCap = call->ourCaps;
|
|
|
|
OOTRACEDBGC3("Using call specific capabilities in faststart of "
|
2017-12-22 14:23:22 +00:00
|
|
|
"setup message. (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
epCap = gH323ep.myCaps;
|
|
|
|
OOTRACEDBGC3("Using end-point capabilities for faststart of setup"
|
2017-12-22 14:23:22 +00:00
|
|
|
"message. (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
while(epCap){
|
|
|
|
if(epCap->cap == call->capPrefs.order[k]) break;
|
|
|
|
else epCap = epCap->next;
|
|
|
|
}
|
|
|
|
if(!epCap)
|
|
|
|
{
|
|
|
|
OOTRACEWARN4("Warn:Preferred capability %s is abscent in "
|
2017-12-22 14:23:22 +00:00
|
|
|
"capability list. (%s, %s)\n",
|
|
|
|
ooGetCapTypeText(call->capPrefs.order[k]),
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
/* don't send t38/other data caps in fasstart olcs */
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
if (epCap->capType == OO_CAP_TYPE_DATA)
|
|
|
|
continue;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGC4("Building olcs with capability %s. (%s, %s)\n",
|
|
|
|
ooGetCapTypeText(epCap->cap), call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
if(epCap->dir & OORX)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
olc = (H245OpenLogicalChannel*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H245OpenLogicalChannel));
|
|
|
|
if(!olc)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooH323MakeCall_helper - olc(%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, q931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(olc, 0, sizeof(H245OpenLogicalChannel));
|
2017-12-22 14:23:22 +00:00
|
|
|
olc->forwardLogicalChannelNumber = call->logicalChanNoCur++;
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->logicalChanNoCur > call->logicalChanNoMax)
|
|
|
|
call->logicalChanNoCur = call->logicalChanNoBase;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ooBuildFastStartOLC(call, olc, epCap, pctxt, OORX);
|
|
|
|
/* Do not specify msg buffer let automatic allocation work */
|
|
|
|
setPERBuffer(pctxt, NULL, 0, aligned);
|
|
|
|
if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Encoding of olc failed for faststart(%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, q931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
pFS[i].data = (unsigned char *)encodeGetMsgPtr(pctxt, (int *)&(pFS[i].numocts));
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Dump faststart element in logfile for debugging purpose */
|
2009-11-04 22:10:44 +00:00
|
|
|
setPERBuffer(pctxt, (unsigned char*)pFS[i].data, pFS[i].numocts, 1);
|
2009-06-30 16:40:38 +00:00
|
|
|
initializePrintHandler(&printHandler, "FastStart Element");
|
|
|
|
setEventHandler (pctxt, &printHandler);
|
|
|
|
memset(&printOlc, 0, sizeof(printOlc));
|
|
|
|
ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc));
|
|
|
|
if(ret != ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Failed decoding FastStart Element."
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, q931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
finishPrint();
|
2017-12-22 14:23:22 +00:00
|
|
|
removeEventHandler(pctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
olc = NULL;
|
|
|
|
i++;
|
|
|
|
OOTRACEDBGC5("Added RX fs element %d with capability %s(%s, %s)\n",
|
2017-12-22 14:23:22 +00:00
|
|
|
i, ooGetCapTypeText(epCap->cap), call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(epCap->dir & OOTX)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
olc = (H245OpenLogicalChannel*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H245OpenLogicalChannel));
|
|
|
|
if(!olc)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooH323MakeCall_helper - olc(%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, q931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset(olc, 0, sizeof(H245OpenLogicalChannel));
|
2017-12-22 14:23:22 +00:00
|
|
|
olc->forwardLogicalChannelNumber = call->logicalChanNoCur++;
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->logicalChanNoCur > call->logicalChanNoMax)
|
|
|
|
call->logicalChanNoCur = call->logicalChanNoBase;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ooBuildFastStartOLC(call, olc, epCap, pctxt, OOTX);
|
|
|
|
/* Do not specify msg buffer let automatic allocation work */
|
|
|
|
setPERBuffer(pctxt, NULL, 0, aligned);
|
|
|
|
if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Encoding of olc failed for faststart(%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, q931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
pFS[i].data = (unsigned char *)encodeGetMsgPtr(pctxt, (int *)&(pFS[i].numocts));
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
/* Dump faststart element in logfile for debugging purpose */
|
2009-11-04 22:10:44 +00:00
|
|
|
setPERBuffer(pctxt, (unsigned char*)pFS[i].data, pFS[i].numocts, 1);
|
2009-06-30 16:40:38 +00:00
|
|
|
initializePrintHandler(&printHandler, "FastStart Element");
|
|
|
|
setEventHandler (pctxt, &printHandler);
|
|
|
|
memset(&printOlc, 0, sizeof(printOlc));
|
|
|
|
ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc));
|
|
|
|
if(ret != ASN_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error: Failed decoding FastStart Element."
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
ooFreeQ931Message(pctxt, q931msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
finishPrint();
|
2017-12-22 14:23:22 +00:00
|
|
|
removeEventHandler(pctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
olc = NULL;
|
|
|
|
i++;
|
|
|
|
OOTRACEDBGC5("Added TX fs element %d with capability %s(%s, %s)\n",
|
2017-12-22 14:23:22 +00:00
|
|
|
i, ooGetCapTypeText(epCap->cap), call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
OOTRACEDBGA4("Added %d fast start elements to SETUP message (%s, %s)\n",
|
|
|
|
i, call->callType, call->callToken);
|
|
|
|
setup->fastStart.n = i;
|
2017-12-22 14:23:22 +00:00
|
|
|
setup->fastStart.elem = pFS;
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setup->conferenceID.numocts= call->confIdentifier.numocts;
|
|
|
|
memcpy(setup->conferenceID.data, call->confIdentifier.data,
|
|
|
|
call->confIdentifier.numocts);
|
|
|
|
|
|
|
|
setup->conferenceGoal.t = T_H225Setup_UUIE_conferenceGoal_create;
|
|
|
|
/* H.225 point to point call */
|
|
|
|
setup->callType.t = T_H225CallType_pointToPoint;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Populate optional fields */
|
|
|
|
setup->m.callIdentifierPresent = TRUE;
|
|
|
|
/*ooGenerateCallIdentifier(&setup->callIdentifier);*/
|
|
|
|
setup->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(setup->callIdentifier.guid.data, call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
setup->m.mediaWaitForConnectPresent = TRUE;
|
|
|
|
if(OO_TESTFLAG(call->flags, OO_M_MEDIAWAITFORCONN)) {
|
|
|
|
setup->mediaWaitForConnect = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setup->mediaWaitForConnect = FALSE;
|
|
|
|
}
|
|
|
|
setup->m.canOverlapSendPresent = TRUE;
|
|
|
|
setup->canOverlapSend = FALSE;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Populate the userInfo structure with the setup UUIE */
|
|
|
|
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_setup;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.setup = setup;
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling =
|
2009-06-30 16:40:38 +00:00
|
|
|
OO_TESTFLAG (call->flags, OO_M_TUNNELING);
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
/* For H.323 version 4 and higher, if fast connect, tunneling should be
|
2009-06-30 16:40:38 +00:00
|
|
|
supported.
|
2011-02-10 13:29:19 +00:00
|
|
|
why?
|
2009-06-30 16:40:38 +00:00
|
|
|
*/
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGA3("Built SETUP message (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* H225 message callback */
|
|
|
|
if(gH323ep.h225Callbacks.onBuiltSetup)
|
|
|
|
gH323ep.h225Callbacks.onBuiltSetup(call, q931msg);
|
|
|
|
|
|
|
|
ret=ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue SETUP message to outbound queue. (%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt);*/
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ooQ931SendDTMFAsKeyPadIE(OOH323CallData *call, const char* data)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
int ret;
|
2009-06-30 16:40:38 +00:00
|
|
|
H225Information_UUIE *information=NULL;
|
|
|
|
Q931Message *q931msg=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &q931msg, Q931InformationMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR3("Error: In allocating memory for - H225 Information message."
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
q931msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!q931msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooQ931SendDTMFAsKeypadIE - userInfo"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags,
|
|
|
|
OO_M_TUNNELING);
|
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_information;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
information = (H225Information_UUIE*)memAllocZ(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H225Information_UUIE));
|
|
|
|
if(!information)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooQ931SendDTMFAsKeypadIE - information"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
q931msg->userInfo->h323_uu_pdu.h323_message_body.u.information =
|
|
|
|
information;
|
2009-06-30 16:40:38 +00:00
|
|
|
information->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
information->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(information->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
|
|
|
information->protocolIdentifier = gProtocolID;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/*Add keypad IE*/
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooQ931SetKeypadIE(pctxt, q931msg, data);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("Error:Creating keypad IE for (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret=ooSendH225Msg(call, q931msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue Information message to outbound "
|
|
|
|
"queue. (%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooH323ForwardCall(char* callToken, char *dest)
|
|
|
|
{
|
|
|
|
int ret=0;
|
|
|
|
Q931Message *pQ931Msg = NULL;
|
|
|
|
H225Facility_UUIE *facility=NULL;
|
|
|
|
OOCTXT *pctxt = &gH323ep.msgctxt;
|
|
|
|
OOH323CallData *call;
|
2011-04-12 21:59:18 +00:00
|
|
|
char ip[2+8*4+7]="\0", *pcPort=NULL;
|
2009-06-30 16:40:38 +00:00
|
|
|
H225TransportAddress_ipAddress *fwdCallSignalIpAddress;
|
2011-04-12 21:59:18 +00:00
|
|
|
H225TransportAddress_ip6Address *fwdCallSignalIp6Address;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
call= ooFindCallByToken(callToken);
|
|
|
|
if(!call)
|
|
|
|
{
|
|
|
|
OOTRACEERR2("ERROR: Invalid call token for forward - %s\n", callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGA3("Building Facility message for call forward (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
2017-12-22 14:23:22 +00:00
|
|
|
call->pCallFwdData = (OOCallFwdData*)memAllocZ(call->pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(OOCallFwdData));
|
|
|
|
if(!call->pCallFwdData)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323ForwardCall - pCallFwdData (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooParseDestination(call, dest, ip, 2+8*4+7,
|
2009-06-30 16:40:38 +00:00
|
|
|
&call->pCallFwdData->aliases);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR4("Error:Failed to parse the destination %s for call fwd."
|
|
|
|
"(%s, %s)\n", dest, call->callType, call->callToken);
|
|
|
|
memFreePtr(call->pctxt, call->pCallFwdData);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ooUtilsIsStrEmpty(ip))
|
|
|
|
{
|
2011-04-12 21:59:18 +00:00
|
|
|
pcPort = strrchr(ip, ':');
|
2009-06-30 16:40:38 +00:00
|
|
|
if(pcPort)
|
|
|
|
{
|
|
|
|
*pcPort = '\0';
|
|
|
|
pcPort++;
|
|
|
|
call->pCallFwdData->port = atoi(pcPort);
|
|
|
|
}
|
|
|
|
strcpy(call->pCallFwdData->ip, ip);
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3
|
|
|
|
("ERROR: In allocating memory for call transfer facility message "
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!pQ931Msg->userInfo)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEERR3("ERROR:Memory - ooH323ForwardCall - userInfo(%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling =
|
|
|
|
OO_TESTFLAG (call->flags, OO_M_TUNNELING);
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_facility;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
facility = (H225Facility_UUIE*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAllocZ (pctxt, sizeof(H225Facility_UUIE));
|
|
|
|
|
|
|
|
if(!facility)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooH323ForwardCall - facility (%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
|
|
|
facility->protocolIdentifier = gProtocolID;
|
2009-06-30 16:40:38 +00:00
|
|
|
facility->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
facility->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(facility->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
|
|
|
|
|
|
|
facility->reason.t = T_H225FacilityReason_callForwarded;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
if(!ooUtilsIsStrEmpty(call->pCallFwdData->ip))
|
|
|
|
{
|
|
|
|
facility->m.alternativeAddressPresent = TRUE;
|
2011-04-12 21:59:18 +00:00
|
|
|
if (call->versionIP == 6) {
|
|
|
|
facility->alternativeAddress.t=T_H225TransportAddress_ip6Address;
|
|
|
|
fwdCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt,
|
|
|
|
sizeof(H225TransportAddress_ip6Address));
|
|
|
|
if(!fwdCallSignalIp6Address)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Memory - ooH323ForwardCall - fwdCallSignal6Address"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
inet_pton(AF_INET6, call->pCallFwdData->ip,
|
2011-04-12 21:59:18 +00:00
|
|
|
fwdCallSignalIp6Address->ip.data);
|
|
|
|
|
|
|
|
fwdCallSignalIp6Address->ip.numocts=16;
|
|
|
|
fwdCallSignalIp6Address->port = call->pCallFwdData->port;
|
|
|
|
facility->alternativeAddress.u.ip6Address = fwdCallSignalIp6Address;
|
|
|
|
} else {
|
|
|
|
facility->alternativeAddress.t=T_H225TransportAddress_ipAddress;
|
|
|
|
fwdCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(H225TransportAddress_ipAddress));
|
2011-04-12 21:59:18 +00:00
|
|
|
if(!fwdCallSignalIpAddress)
|
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
OOTRACEERR3("Error:Memory - ooH323ForwardCall - fwdCallSignalAddress"
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
2011-04-12 21:59:18 +00:00
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
inet_pton(AF_INET, call->pCallFwdData->ip,
|
2009-06-30 16:40:38 +00:00
|
|
|
fwdCallSignalIpAddress->ip.data);
|
|
|
|
|
2011-04-12 21:59:18 +00:00
|
|
|
fwdCallSignalIpAddress->ip.numocts=4;
|
|
|
|
fwdCallSignalIpAddress->port = call->pCallFwdData->port;
|
|
|
|
facility->alternativeAddress.u.ipAddress = fwdCallSignalIpAddress;
|
|
|
|
}
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(call->pCallFwdData->aliases)
|
2017-12-22 14:23:22 +00:00
|
|
|
{
|
2009-06-30 16:40:38 +00:00
|
|
|
facility->m.alternativeAliasAddressPresent = TRUE;
|
2017-12-22 14:23:22 +00:00
|
|
|
ret = ooPopulateAliasList(pctxt, call->pCallFwdData->aliases,
|
2010-03-27 23:51:13 +00:00
|
|
|
&facility->alternativeAliasAddress, 0);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to populate alternate aliases in "
|
2017-12-22 14:23:22 +00:00
|
|
|
"ooH323ForwardCall. (%s, %s)\n", call->callType,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ooSendH225Msg(call, pQ931Msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3
|
|
|
|
("Error:Failed to enqueue Forward Facility message to outbound "
|
|
|
|
"queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
call->callEndReason = OO_REASON_LOCAL_FWDED;
|
|
|
|
memReset (&gH323ep.msgctxt);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooH323HangCall(char * callToken, OOCallClearReason reason, int q931cause)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
OOH323CallData *call;
|
|
|
|
|
|
|
|
call= ooFindCallByToken(callToken);
|
|
|
|
if(!call)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEWARN2("WARN: Call hangup failed - Call %s not present\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
OOTRACEINFO3("Hanging up call (%s, %s)\n", call->callType, call->callToken);
|
|
|
|
if(call->callState < OO_CALL_CLEAR)
|
|
|
|
{
|
|
|
|
call->callEndReason = reason;
|
2009-11-04 22:10:44 +00:00
|
|
|
call->q931cause = q931cause;
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callState = OO_CALL_CLEAR;
|
|
|
|
}
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooSetBearerCapabilityIE
|
2017-12-22 14:23:22 +00:00
|
|
|
(OOCTXT* pctxt, Q931Message *pmsg, enum Q931CodingStandard codingStandard,
|
|
|
|
enum Q931InformationTransferCapability capability,
|
2009-06-30 16:40:38 +00:00
|
|
|
enum Q931TransferMode transferMode, enum Q931TransferRate transferRate,
|
|
|
|
enum Q931UserInfoLayer1Protocol userInfoLayer1)
|
|
|
|
{
|
|
|
|
unsigned size = 3;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(pmsg->bearerCapabilityIE)
|
|
|
|
{
|
|
|
|
memFreePtr(pctxt, pmsg->bearerCapabilityIE);
|
|
|
|
pmsg->bearerCapabilityIE = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pmsg->bearerCapabilityIE = (Q931InformationElement*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAlloc(pctxt, sizeof(Q931InformationElement)+size-1);
|
|
|
|
if(!pmsg->bearerCapabilityIE)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooSetBearerCapabilityIE - bearerCapabilityIE"
|
|
|
|
"\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pmsg->bearerCapabilityIE->discriminator = Q931BearerCapabilityIE;
|
|
|
|
pmsg->bearerCapabilityIE->length = size;
|
|
|
|
pmsg->bearerCapabilityIE->data[0] = (ASN1OCTET)(0x80 | ((codingStandard&3) << 5) | (capability&31));
|
|
|
|
|
|
|
|
pmsg->bearerCapabilityIE->data[1] = (0x80 | ((transferMode & 3) << 5) | (transferRate & 31));
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
pmsg->bearerCapabilityIE->data[2] = (0x80 | (1<<5) | userInfoLayer1);
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
int ooQ931SetKeypadIE(OOCTXT* pctxt, Q931Message *pmsg, const char* data)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
unsigned len = 0;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
len = strlen(data);
|
2017-12-22 14:23:22 +00:00
|
|
|
pmsg->keypadIE = (Q931InformationElement*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAlloc(pctxt, sizeof(Q931InformationElement)+len-1);
|
|
|
|
if(!pmsg->keypadIE)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooQ931SetKeypadIE - keypadIE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pmsg->keypadIE->discriminator = Q931KeypadIE;
|
|
|
|
pmsg->keypadIE->length = len;
|
|
|
|
memcpy(pmsg->keypadIE->data, data, len);
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ooQ931SetCallingPartyNumberIE
|
2017-12-22 14:23:22 +00:00
|
|
|
(OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type,
|
2009-06-30 16:40:38 +00:00
|
|
|
unsigned presentation, unsigned screening)
|
|
|
|
{
|
|
|
|
unsigned len = 0;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(pmsg->callingPartyNumberIE)
|
|
|
|
{
|
|
|
|
memFreePtr(pctxt, pmsg->callingPartyNumberIE);
|
|
|
|
pmsg->callingPartyNumberIE = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = strlen(number);
|
2017-12-22 14:23:22 +00:00
|
|
|
pmsg->callingPartyNumberIE = (Q931InformationElement*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAlloc(pctxt, sizeof(Q931InformationElement)+len+2-1);
|
|
|
|
if(!pmsg->callingPartyNumberIE)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooQ931SetCallingPartyNumberIE - "
|
|
|
|
"callingPartyNumberIE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
pmsg->callingPartyNumberIE->discriminator = Q931CallingPartyNumberIE;
|
|
|
|
pmsg->callingPartyNumberIE->length = len+2;
|
|
|
|
pmsg->callingPartyNumberIE->data[0] = (((type&7)<<4)|(plan&15));
|
|
|
|
pmsg->callingPartyNumberIE->data[1] = (0x80|((presentation&3)<<5)|(screening&3));
|
|
|
|
memcpy(pmsg->callingPartyNumberIE->data+2, number, len);
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooQ931SetCalledPartyNumberIE
|
2009-11-04 22:10:44 +00:00
|
|
|
(OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type)
|
2009-06-30 16:40:38 +00:00
|
|
|
{
|
|
|
|
unsigned len = 0;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(pmsg->calledPartyNumberIE)
|
|
|
|
{
|
|
|
|
memFreePtr(pctxt, pmsg->calledPartyNumberIE);
|
|
|
|
pmsg->calledPartyNumberIE = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = strlen(number);
|
2017-12-22 14:23:22 +00:00
|
|
|
pmsg->calledPartyNumberIE = (Q931InformationElement*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAlloc(pctxt, sizeof(Q931InformationElement)+len+1-1);
|
|
|
|
if(!pmsg->calledPartyNumberIE)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooQ931SetCalledPartyNumberIE - "
|
|
|
|
"calledPartyNumberIE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
pmsg->calledPartyNumberIE->discriminator = Q931CalledPartyNumberIE;
|
|
|
|
pmsg->calledPartyNumberIE->length = len+1;
|
|
|
|
pmsg->calledPartyNumberIE->data[0] = (0x80|((type&7)<<4)|(plan&15));
|
|
|
|
memcpy(pmsg->calledPartyNumberIE->data+1, number, len);
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
int ooQ931SetCallStateIE
|
|
|
|
(OOCTXT* pctxt, Q931Message *pmsg, unsigned char callstate)
|
|
|
|
{
|
|
|
|
if(pmsg->callstateIE){
|
|
|
|
memFreePtr(pctxt, pmsg->callstateIE);
|
|
|
|
pmsg->callstateIE = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pmsg->callstateIE = (Q931InformationElement*)
|
2011-11-09 19:08:44 +00:00
|
|
|
memAllocZ(pctxt, sizeof(Q931InformationElement));
|
|
|
|
if(!pmsg->callstateIE)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooQ931SetCallstateIE - causeIE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
pmsg->callstateIE->discriminator = Q931CallStateIE;
|
|
|
|
pmsg->callstateIE->length = 1;
|
|
|
|
pmsg->callstateIE->data[0] = callstate;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2011-11-09 19:08:44 +00:00
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
int ooQ931SetCauseIE
|
2017-12-22 14:23:22 +00:00
|
|
|
(OOCTXT* pctxt, Q931Message *pmsg, enum Q931CauseValues cause, unsigned coding,
|
2009-06-30 16:40:38 +00:00
|
|
|
unsigned location)
|
|
|
|
{
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
2009-06-30 16:40:38 +00:00
|
|
|
|
|
|
|
if(pmsg->causeIE){
|
|
|
|
memFreePtr(pctxt, pmsg->causeIE);
|
|
|
|
pmsg->causeIE = NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pmsg->causeIE = (Q931InformationElement*)
|
2009-06-30 16:40:38 +00:00
|
|
|
memAlloc(pctxt, sizeof(Q931InformationElement)+1);
|
|
|
|
if(!pmsg->causeIE)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooQ931SetCauseIE - causeIE\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
pmsg->causeIE->discriminator = Q931CauseIE;
|
|
|
|
pmsg->causeIE->length = 2;
|
|
|
|
pmsg->causeIE->data[0] = (0x80 | ((coding & 0x03) <<5) | (location & 0x0F));
|
|
|
|
|
|
|
|
pmsg->causeIE->data[1] = (0x80 | cause);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Build a Facility message and tunnel H.245 message through it */
|
2017-12-22 14:23:22 +00:00
|
|
|
int ooSendAsTunneledMessage(OOH323CallData *call, ASN1OCTET* msgbuf,
|
2009-06-30 16:40:38 +00:00
|
|
|
int h245Len, int h245MsgType, int associatedChan)
|
|
|
|
{
|
|
|
|
Q931Message *pQ931Msg = NULL;
|
|
|
|
H225H323_UU_PDU *pH323UUPDU = NULL;
|
|
|
|
H225H323_UU_PDU_h245Control *pH245Control = NULL;
|
|
|
|
ASN1DynOctStr * elem;
|
|
|
|
int ret =0;
|
|
|
|
H225Facility_UUIE *facility=NULL;
|
2009-11-04 22:10:44 +00:00
|
|
|
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
|
|
|
|
OOCTXT *pctxt = call->msgctxt;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEDBGA4("Building Facility message for tunneling %s (%s, %s)\n",
|
2009-06-30 16:40:38 +00:00
|
|
|
ooGetMsgTypeText(h245MsgType), call->callType, call->callToken);
|
|
|
|
|
2009-11-04 22:10:44 +00:00
|
|
|
ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg);
|
2009-06-30 16:40:38 +00:00
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR: In allocating memory for facility message "
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->callReference = call->callReference;
|
|
|
|
|
|
|
|
pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
|
|
|
|
sizeof(H225H323_UserInformation));
|
|
|
|
if(!pQ931Msg->userInfo)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - userInfo"
|
|
|
|
" (%s, %s)\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt);*/
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation));
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1;
|
2009-06-30 16:40:38 +00:00
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling =
|
2009-06-30 16:40:38 +00:00
|
|
|
OO_TESTFLAG (call->flags, OO_M_TUNNELING);
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t =
|
2009-06-30 16:40:38 +00:00
|
|
|
T_H225H323_UU_PDU_h323_message_body_facility;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
facility = (H225Facility_UUIE*)
|
|
|
|
memAllocZ (pctxt, sizeof(H225Facility_UUIE));
|
|
|
|
|
|
|
|
if(!facility)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - facility (%s, %s)"
|
|
|
|
"\n", call->callType, call->callToken);
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memReset(&gH323ep.msgctxt); */
|
|
|
|
memReset(call->msgctxt);
|
2009-06-30 16:40:38 +00:00
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility;
|
|
|
|
/* Populate Facility UUIE */
|
2017-12-22 14:23:22 +00:00
|
|
|
facility->protocolIdentifier = gProtocolID;
|
2009-06-30 16:40:38 +00:00
|
|
|
facility->m.callIdentifierPresent = 1;
|
2017-12-22 14:23:22 +00:00
|
|
|
facility->callIdentifier.guid.numocts =
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
memcpy(facility->callIdentifier.guid.data,
|
|
|
|
call->callIdentifier.guid.data,
|
2009-06-30 16:40:38 +00:00
|
|
|
call->callIdentifier.guid.numocts);
|
|
|
|
|
|
|
|
facility->reason.t = T_H225FacilityReason_transportedInformation;
|
|
|
|
|
|
|
|
pH323UUPDU = (H225H323_UU_PDU*) &pQ931Msg->userInfo->h323_uu_pdu;
|
|
|
|
pH323UUPDU->m.h245TunnelingPresent = TRUE;
|
|
|
|
pH323UUPDU->m.h245ControlPresent = TRUE;
|
|
|
|
pH323UUPDU->h245Tunneling = TRUE;
|
|
|
|
pH245Control = (H225H323_UU_PDU_h245Control*)
|
|
|
|
&pH323UUPDU->h245Control;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
elem = (ASN1DynOctStr*) memAlloc(pctxt,
|
2009-06-30 16:40:38 +00:00
|
|
|
sizeof(ASN1DynOctStr));
|
|
|
|
if(!elem)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - elem "
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
elem->data = msgbuf;
|
|
|
|
elem->numocts = h245Len;
|
|
|
|
pH245Control->elem = elem;
|
|
|
|
pH245Control->n = 1;
|
|
|
|
pQ931Msg->tunneledMsgType = h245MsgType;
|
|
|
|
pQ931Msg->logicalChannelNo = associatedChan;
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
ret = ooSendH225Msg(call, pQ931Msg);
|
|
|
|
if(ret != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEERR3("Error:Failed to enqueue Facility(tunneling) message to "
|
|
|
|
"outbound queue.(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Can't do memReset here because if we are sending H.245 message as a
|
2009-06-30 16:40:38 +00:00
|
|
|
response to received tunneled h.245 message, we can't reset unless the \
|
|
|
|
main received H225 message processing is finished. Rule. No reset when
|
|
|
|
tunneling
|
|
|
|
*/
|
2009-11-04 22:10:44 +00:00
|
|
|
/* memFreePtr(&gH323ep.msgctxt, pQ931Msg); */
|
|
|
|
memFreePtr(call->msgctxt, pQ931Msg);
|
2009-06-30 16:40:38 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ooCallEstbTimerExpired(void *data)
|
|
|
|
{
|
|
|
|
|
|
|
|
ooTimerCallback *cbData = (ooTimerCallback*) data;
|
|
|
|
OOH323CallData *call = cbData->call;
|
2017-12-22 14:23:22 +00:00
|
|
|
OOTRACEINFO3("Call Establishment timer expired. (%s, %s)\n",
|
|
|
|
call->callType, call->callToken);
|
2009-06-30 16:40:38 +00:00
|
|
|
memFreePtr(call->pctxt, cbData);
|
|
|
|
if(call->callState < OO_CALL_CLEAR){
|
|
|
|
call->callState = OO_CALL_CLEAR;
|
2017-12-22 14:23:22 +00:00
|
|
|
call->callEndReason = OO_REASON_LOCAL_CLEARED;
|
2009-06-30 16:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ooQ931GetCauseAndReasonCodeFromCallClearReason
|
2017-12-22 14:23:22 +00:00
|
|
|
(OOCallClearReason clearReason, enum Q931CauseValues *cause,
|
2009-06-30 16:40:38 +00:00
|
|
|
unsigned *reasonCode)
|
|
|
|
{
|
|
|
|
switch(clearReason)
|
|
|
|
{
|
|
|
|
case OO_REASON_INVALIDMESSAGE:
|
|
|
|
case OO_REASON_TRANSPORTFAILURE:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
|
|
|
*cause = Q931ProtocolErrorUnspecified;
|
|
|
|
break;
|
|
|
|
case OO_REASON_NOBW:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_noBandwidth;
|
|
|
|
*cause = Q931ErrorInCauseIE;
|
|
|
|
break;
|
|
|
|
case OO_REASON_GK_NOCALLEDUSER:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_calledPartyNotRegistered;
|
|
|
|
*cause = Q931SubscriberAbsent;
|
|
|
|
break;
|
|
|
|
case OO_REASON_GK_NOCALLERUSER:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_callerNotRegistered;
|
2017-12-22 14:23:22 +00:00
|
|
|
*cause = Q931SubscriberAbsent;
|
2009-06-30 16:40:38 +00:00
|
|
|
break;
|
|
|
|
case OO_REASON_GK_UNREACHABLE:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_unreachableGatekeeper;
|
|
|
|
*cause = Q931TemporaryFailure;
|
|
|
|
break;
|
|
|
|
case OO_REASON_GK_NORESOURCES:
|
|
|
|
case OO_REASON_GK_CLEARED:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_gatekeeperResources;
|
|
|
|
*cause = Q931Congestion;
|
|
|
|
break;
|
|
|
|
case OO_REASON_NOCOMMON_CAPABILITIES:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
|
|
|
*cause = Q931IncompatibleDestination;
|
|
|
|
break;
|
|
|
|
case OO_REASON_LOCAL_FWDED:
|
|
|
|
case OO_REASON_REMOTE_FWDED:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_facilityCallDeflection;
|
|
|
|
*cause = Q931Redirection;
|
|
|
|
break;
|
|
|
|
case OO_REASON_REMOTE_CLEARED:
|
|
|
|
case OO_REASON_LOCAL_CLEARED:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
|
|
|
*cause = Q931NormalCallClearing;
|
|
|
|
break;
|
|
|
|
case OO_REASON_REMOTE_BUSY:
|
|
|
|
case OO_REASON_LOCAL_BUSY:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_inConf;
|
|
|
|
*cause = Q931UserBusy;
|
|
|
|
break;
|
|
|
|
case OO_REASON_REMOTE_NOANSWER:
|
|
|
|
case OO_REASON_LOCAL_NOTANSWERED:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
|
|
|
*cause = Q931NoAnswer;
|
|
|
|
break;
|
|
|
|
case OO_REASON_REMOTE_REJECTED:
|
|
|
|
case OO_REASON_LOCAL_REJECTED:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_destinationRejection;
|
|
|
|
*cause = Q931CallRejected;
|
|
|
|
break;
|
|
|
|
case OO_REASON_REMOTE_CONGESTED:
|
|
|
|
case OO_REASON_LOCAL_CONGESTED:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_noBandwidth;
|
|
|
|
*cause = Q931Congestion;
|
|
|
|
break;
|
|
|
|
case OO_REASON_NOROUTE:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_unreachableDestination;
|
|
|
|
*cause = Q931NoRouteToDestination;
|
|
|
|
break;
|
|
|
|
case OO_REASON_NOUSER:
|
2017-12-22 14:23:22 +00:00
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
2009-06-30 16:40:38 +00:00
|
|
|
*cause = Q931SubscriberAbsent;
|
|
|
|
break;
|
|
|
|
case OO_REASON_UNKNOWN:
|
|
|
|
default:
|
|
|
|
*reasonCode = T_H225ReleaseCompleteReason_undefinedReason;
|
|
|
|
*cause = Q931NormalUnspecified;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode
|
|
|
|
(enum Q931CauseValues cause, unsigned reasonCode)
|
|
|
|
{
|
|
|
|
switch(cause)
|
|
|
|
{
|
|
|
|
case Q931NormalCallClearing:
|
|
|
|
return OO_REASON_REMOTE_CLEARED;
|
|
|
|
|
|
|
|
case Q931UserBusy:
|
|
|
|
return OO_REASON_REMOTE_BUSY;
|
|
|
|
|
|
|
|
case Q931NoResponse:
|
|
|
|
case Q931NoAnswer:
|
|
|
|
return OO_REASON_REMOTE_NOANSWER;
|
|
|
|
|
|
|
|
case Q931CallRejected:
|
|
|
|
return OO_REASON_REMOTE_REJECTED;
|
|
|
|
|
|
|
|
case Q931Redirection:
|
|
|
|
return OO_REASON_REMOTE_FWDED;
|
|
|
|
|
|
|
|
case Q931NetworkOutOfOrder:
|
|
|
|
case Q931TemporaryFailure:
|
|
|
|
return OO_REASON_TRANSPORTFAILURE;
|
|
|
|
|
|
|
|
case Q931NoCircuitChannelAvailable:
|
|
|
|
case Q931Congestion:
|
|
|
|
case Q931RequestedCircuitUnAvailable:
|
|
|
|
case Q931ResourcesUnavailable:
|
|
|
|
return OO_REASON_REMOTE_CONGESTED;
|
|
|
|
|
|
|
|
case Q931NoRouteToDestination:
|
|
|
|
case Q931NoRouteToNetwork:
|
|
|
|
return OO_REASON_NOROUTE;
|
|
|
|
case Q931NumberChanged:
|
|
|
|
case Q931UnallocatedNumber:
|
|
|
|
case Q931SubscriberAbsent:
|
|
|
|
return OO_REASON_NOUSER;
|
|
|
|
case Q931ChannelUnacceptable:
|
|
|
|
case Q931DestinationOutOfOrder:
|
|
|
|
case Q931InvalidNumberFormat:
|
|
|
|
case Q931NormalUnspecified:
|
|
|
|
case Q931StatusEnquiryResponse:
|
|
|
|
case Q931IncompatibleDestination:
|
|
|
|
case Q931ProtocolErrorUnspecified:
|
|
|
|
case Q931RecoveryOnTimerExpiry:
|
|
|
|
case Q931InvalidCallReference:
|
|
|
|
default:
|
|
|
|
switch(reasonCode)
|
|
|
|
{
|
|
|
|
case T_H225ReleaseCompleteReason_noBandwidth:
|
|
|
|
return OO_REASON_NOBW;
|
|
|
|
case T_H225ReleaseCompleteReason_gatekeeperResources:
|
|
|
|
return OO_REASON_GK_NORESOURCES;
|
|
|
|
case T_H225ReleaseCompleteReason_unreachableDestination:
|
|
|
|
return OO_REASON_NOROUTE;
|
|
|
|
case T_H225ReleaseCompleteReason_destinationRejection:
|
|
|
|
return OO_REASON_REMOTE_REJECTED;
|
|
|
|
case T_H225ReleaseCompleteReason_inConf:
|
|
|
|
return OO_REASON_REMOTE_BUSY;
|
|
|
|
case T_H225ReleaseCompleteReason_facilityCallDeflection:
|
|
|
|
return OO_REASON_REMOTE_FWDED;
|
|
|
|
case T_H225ReleaseCompleteReason_calledPartyNotRegistered:
|
|
|
|
return OO_REASON_GK_NOCALLEDUSER;
|
|
|
|
case T_H225ReleaseCompleteReason_callerNotRegistered:
|
|
|
|
return OO_REASON_GK_NOCALLERUSER;
|
|
|
|
case T_H225ReleaseCompleteReason_gatewayResources:
|
|
|
|
return OO_REASON_GK_NORESOURCES;
|
|
|
|
case T_H225ReleaseCompleteReason_unreachableGatekeeper:
|
|
|
|
return OO_REASON_GK_UNREACHABLE;
|
|
|
|
case T_H225ReleaseCompleteReason_invalidRevision:
|
|
|
|
case T_H225ReleaseCompleteReason_noPermission:
|
|
|
|
case T_H225ReleaseCompleteReason_badFormatAddress:
|
|
|
|
case T_H225ReleaseCompleteReason_adaptiveBusy:
|
|
|
|
case T_H225ReleaseCompleteReason_undefinedReason:
|
|
|
|
case T_H225ReleaseCompleteReason_securityDenied:
|
|
|
|
case T_H225ReleaseCompleteReason_newConnectionNeeded:
|
|
|
|
case T_H225ReleaseCompleteReason_nonStandardReason:
|
|
|
|
case T_H225ReleaseCompleteReason_replaceWithConferenceInvite:
|
|
|
|
case T_H225ReleaseCompleteReason_genericDataReason:
|
|
|
|
case T_H225ReleaseCompleteReason_neededFeatureNotSupported:
|
|
|
|
case T_H225ReleaseCompleteReason_tunnelledSignallingRejected:
|
|
|
|
case T_H225ReleaseCompleteReason_invalidCID:
|
|
|
|
case T_H225ReleaseCompleteReason_securityError:
|
|
|
|
case T_H225ReleaseCompleteReason_hopCountExceeded:
|
|
|
|
case T_H225ReleaseCompleteReason_extElem1:
|
|
|
|
default:
|
|
|
|
return OO_REASON_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OO_REASON_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function is used to parse destination string passed to ooH323MakeCall and
|
|
|
|
ooH323ForwardCall. If the string contains ip address and port, it is returned
|
|
|
|
in the parsedIP buffer and if it contains alias, it is added to aliasList
|
|
|
|
*/
|
|
|
|
int ooParseDestination
|
|
|
|
(struct OOH323CallData *call, char *dest, char* parsedIP, unsigned len,
|
|
|
|
ooAliases** aliasList)
|
|
|
|
{
|
|
|
|
int iEk=-1, iDon=-1, iTeen=-1, iChaar=-1, iPort = -1, i;
|
|
|
|
ooAliases * psNewAlias = NULL;
|
|
|
|
char *cAt = NULL, *host=NULL;
|
|
|
|
char tmp[256], buf[30];
|
|
|
|
char *alias=NULL;
|
|
|
|
OOCTXT *pctxt = call->pctxt;
|
2011-04-12 21:59:18 +00:00
|
|
|
struct ast_sockaddr tmpaddr;
|
2009-06-30 16:40:38 +00:00
|
|
|
parsedIP[0] = '\0';
|
|
|
|
|
|
|
|
OOTRACEINFO2("Parsing destination %s\n", dest);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* Test for an IP address:Note that only supports dotted IPv4.
|
|
|
|
IPv6 won't pass the test and so will numeric IP representation*/
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
sscanf(dest, "%d.%d.%d.%d:%d", &iEk, &iDon, &iTeen, &iChaar, &iPort);
|
|
|
|
if((iEk > 0 && iEk <= 255) &&
|
|
|
|
(iDon >= 0 && iDon <= 255) &&
|
|
|
|
(iTeen >=0 && iTeen <= 255) &&
|
|
|
|
(iChaar >= 0 && iChaar <= 255) &&
|
|
|
|
(!strchr(dest, ':') || iPort != -1))
|
|
|
|
{
|
|
|
|
if(!strchr(dest, ':'))
|
|
|
|
iPort = 1720; /*Default h.323 port */
|
|
|
|
|
|
|
|
sprintf(buf, "%d.%d.%d.%d:%d", iEk, iDon, iTeen, iChaar, iPort);
|
|
|
|
if(strlen(buf)+1>len)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Insufficient buffer space for parsed ip - "
|
|
|
|
"ooParseDestination\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
strcpy(parsedIP, buf);
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-09 17:12:27 +00:00
|
|
|
/* parse direct IP dest */
|
|
|
|
if ((strchr(dest, ':') || strchr(dest,'[') || strchr(dest,'.')) && !ast_parse_arg(dest, PARSE_ADDR, &tmpaddr)) {
|
2011-04-12 21:59:18 +00:00
|
|
|
if(strlen(dest)+7>len)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Insufficient buffer space for parsed ip - "
|
|
|
|
"ooParseDestination\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
strcpy(parsedIP, ast_sockaddr_stringify_addr(&tmpaddr));
|
|
|
|
strcat(parsedIP, ":");
|
|
|
|
strcat(parsedIP, ast_sockaddr_stringify_port(&tmpaddr));
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* alias@host */
|
|
|
|
strncpy(tmp, dest, sizeof(tmp)-1);
|
|
|
|
tmp[sizeof(tmp)-1]='\0';
|
|
|
|
if((host=strchr(tmp, '@')) != NULL)
|
|
|
|
{
|
|
|
|
*host = '\0';
|
|
|
|
host++;
|
|
|
|
sscanf(host, "%d.%d.%d.%d:%d", &iEk, &iDon, &iTeen, &iChaar, &iPort);
|
|
|
|
if((iEk > 0 && iEk <= 255) &&
|
|
|
|
(iDon >= 0 && iDon <= 255) &&
|
|
|
|
(iTeen >=0 && iTeen <= 255) &&
|
|
|
|
(iChaar >= 0 && iChaar <= 255) &&
|
|
|
|
(!strchr(host, ':') || iPort != -1))
|
|
|
|
{
|
|
|
|
if(!strchr(dest, ':'))
|
|
|
|
iPort = 1720; /*Default h.323 port */
|
|
|
|
|
|
|
|
sprintf(buf, "%d.%d.%d.%d:%d", iEk, iDon, iTeen, iChaar, iPort);
|
|
|
|
if(strlen(buf)+1>len)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Insufficient buffer space for parsed ip - "
|
|
|
|
"ooParseDestination\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(parsedIP, buf, len-1);
|
|
|
|
parsedIP[len-1]='\0';
|
|
|
|
alias = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!alias)
|
|
|
|
{
|
|
|
|
alias = dest;
|
|
|
|
}
|
|
|
|
/* url test */
|
|
|
|
if(alias == strstr(alias, "http://"))
|
|
|
|
{
|
|
|
|
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases));
|
|
|
|
if(!psNewAlias)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
psNewAlias->type = T_H225AliasAddress_url_ID;
|
|
|
|
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1);
|
|
|
|
if(!psNewAlias->value)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - "
|
|
|
|
"psNewAlias->value\n");
|
|
|
|
memFreePtr(pctxt, psNewAlias);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
strcpy(psNewAlias->value, alias);
|
|
|
|
psNewAlias->next = *aliasList;
|
|
|
|
*aliasList = psNewAlias;
|
|
|
|
OOTRACEINFO2("Destination parsed as url %s\n", psNewAlias->value);
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* E-mail ID test */
|
|
|
|
if((cAt = strchr(alias, '@')) && alias != strchr(alias, '@'))
|
|
|
|
{
|
|
|
|
if(strchr(cAt, '.'))
|
|
|
|
{
|
|
|
|
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases));
|
|
|
|
if(!psNewAlias)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
psNewAlias->type = T_H225AliasAddress_email_ID;
|
|
|
|
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1);
|
|
|
|
if(!psNewAlias->value)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - "
|
|
|
|
"psNewAlias->value\n");
|
|
|
|
memFreePtr(pctxt, psNewAlias);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
strcpy(psNewAlias->value, alias);
|
|
|
|
psNewAlias->next = *aliasList;
|
|
|
|
*aliasList = psNewAlias;
|
|
|
|
OOTRACEINFO2("Destination is parsed as email %s\n",psNewAlias->value);
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2009-06-30 16:40:38 +00:00
|
|
|
/* e-164 */
|
|
|
|
/* strspn(dest, "1234567890*#,") == strlen(dest)*/
|
|
|
|
/* Dialed digits test*/
|
|
|
|
for(i=0; *(alias+i) != '\0'; i++)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
if(!isdigit(alias[i]) && alias[i] != '#' && alias[i] != '*' &&
|
2009-06-30 16:40:38 +00:00
|
|
|
alias[i] != ',')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(*(alias+i) == '\0')
|
|
|
|
{
|
|
|
|
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases));
|
|
|
|
if(!psNewAlias)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
/* memset(psNewAlias, 0, sizeof(ooAliases));*/
|
|
|
|
psNewAlias->type = T_H225AliasAddress_dialedDigits;
|
|
|
|
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1);
|
|
|
|
if(!psNewAlias->value)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memroy - ooParseDestination - "
|
|
|
|
"psNewAlias->value\n");
|
|
|
|
memFreePtr(pctxt, psNewAlias);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
strcpy(psNewAlias->value, alias);
|
|
|
|
psNewAlias->next = *aliasList;
|
|
|
|
*aliasList = psNewAlias;
|
|
|
|
OOTRACEINFO2("Destination is parsed as dialed digits %s\n",
|
|
|
|
psNewAlias->value);
|
|
|
|
/* Also set called party number */
|
|
|
|
if(!call->calledPartyNumber)
|
|
|
|
{
|
|
|
|
if(ooCallSetCalledPartyNumber(call, alias) != OO_OK)
|
|
|
|
{
|
|
|
|
OOTRACEWARN3("Warning:Failed to set calling party number."
|
|
|
|
"(%s, %s)\n", call->callType, call->callToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
/* Evrything else is an h323-id for now */
|
|
|
|
psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases));
|
|
|
|
if(!psNewAlias)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
psNewAlias->type = T_H225AliasAddress_h323_ID;
|
|
|
|
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1);
|
|
|
|
if(!psNewAlias->value)
|
|
|
|
{
|
|
|
|
OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias->value\n");
|
|
|
|
memFreePtr(pctxt, psNewAlias);
|
|
|
|
return OO_FAILED;
|
|
|
|
}
|
|
|
|
strcpy(psNewAlias->value, alias);
|
|
|
|
psNewAlias->next = *aliasList;
|
|
|
|
*aliasList = psNewAlias;
|
|
|
|
OOTRACEINFO2("Destination for new call is parsed as h323-id %s \n",
|
|
|
|
psNewAlias->value);
|
|
|
|
return OO_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* ooGetMsgTypeText (int msgType)
|
|
|
|
{
|
|
|
|
static const char *msgTypeText[]={
|
|
|
|
"OOQ931MSG",
|
|
|
|
"OOH245MSG",
|
|
|
|
"OOSetup",
|
|
|
|
"OOCallProceeding",
|
|
|
|
"OOAlert",
|
|
|
|
"OOConnect",
|
|
|
|
"OOReleaseComplete",
|
|
|
|
"OOFacility",
|
|
|
|
"OOInformation",
|
|
|
|
"OOMasterSlaveDetermination",
|
|
|
|
"OOMasterSlaveAck",
|
|
|
|
"OOMasterSlaveReject",
|
|
|
|
"OOMasterSlaveRelease",
|
|
|
|
"OOTerminalCapabilitySet",
|
|
|
|
"OOTerminalCapabilitySetAck",
|
|
|
|
"OOTerminalCapabilitySetReject",
|
|
|
|
"OOTerminalCapabilitySetRelease",
|
|
|
|
"OOOpenLogicalChannel",
|
|
|
|
"OOOpenLogicalChannelAck",
|
|
|
|
"OOOpenLogicalChannelReject",
|
|
|
|
"OOOpenLogicalChannelRelease",
|
|
|
|
"OOOpenLogicalChannelConfirm",
|
|
|
|
"OOCloseLogicalChannel",
|
|
|
|
"OOCloseLogicalChannelAck",
|
|
|
|
"OORequestChannelClose",
|
|
|
|
"OORequestChannelCloseAck",
|
|
|
|
"OORequestChannelCloseReject",
|
|
|
|
"OORequestChannelCloseRelease",
|
2009-11-04 22:10:44 +00:00
|
|
|
"OOEndSessionCommand",
|
|
|
|
"OOUserInputIndication",
|
|
|
|
"OORequestModeAck",
|
|
|
|
"OORequestModeReject",
|
2010-03-14 14:42:59 +00:00
|
|
|
"OORequestMode",
|
|
|
|
"OORequestDelayResponse",
|
|
|
|
"OORequestDelayRequest"
|
2009-06-30 16:40:38 +00:00
|
|
|
};
|
|
|
|
int idx = msgType - OO_MSGTYPE_MIN;
|
|
|
|
return ooUtilsGetText (idx, msgTypeText, OONUMBEROF(msgTypeText));
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* ooGetQ931CauseValueText(int val)
|
|
|
|
{
|
|
|
|
switch(val)
|
|
|
|
{
|
2017-12-22 14:23:22 +00:00
|
|
|
case Q931UnallocatedNumber:
|
2009-06-30 16:40:38 +00:00
|
|
|
return "Q931UnallocatedNumber";
|
|
|
|
case Q931NoRouteToNetwork:
|
|
|
|
return "Q931NoRouteToNetwork";
|
|
|
|
case Q931NoRouteToDestination:
|
|
|
|
return "Q931NoRouteToDestination";
|
2017-12-22 14:23:22 +00:00
|
|
|
case Q931ChannelUnacceptable:
|
2009-06-30 16:40:38 +00:00
|
|
|
return "Q931ChannelUnacceptable";
|
|
|
|
case Q931NormalCallClearing:
|
|
|
|
return "Q931NormalCallClearing";
|
|
|
|
case Q931UserBusy:
|
|
|
|
return "Q931UserBusy";
|
|
|
|
case Q931NoResponse:
|
|
|
|
return "Q931NoResponse";
|
|
|
|
case Q931NoAnswer:
|
|
|
|
return "Q931NoAnswer";
|
|
|
|
case Q931SubscriberAbsent:
|
|
|
|
return "Q931SubscriberAbsent";
|
|
|
|
case Q931CallRejected:
|
|
|
|
return "Q931CallRejected";
|
|
|
|
case Q931NumberChanged:
|
|
|
|
return "Q931NumberChanged";
|
|
|
|
case Q931Redirection:
|
|
|
|
return "Q931Redirection";
|
|
|
|
case Q931DestinationOutOfOrder:
|
|
|
|
return "Q931DestinationOutOfOrder";
|
|
|
|
case Q931InvalidNumberFormat:
|
|
|
|
return "Q931InvalidNumberFormat";
|
|
|
|
case Q931NormalUnspecified:
|
|
|
|
return "Q931NormalUnspecified";
|
|
|
|
case Q931StatusEnquiryResponse:
|
|
|
|
return "Q931StatusEnquiryResponse";
|
|
|
|
case Q931NoCircuitChannelAvailable:
|
|
|
|
return "Q931NoCircuitChannelAvailable";
|
|
|
|
case Q931NetworkOutOfOrder:
|
|
|
|
return "Q931NetworkOutOfOrder";
|
|
|
|
case Q931TemporaryFailure:
|
|
|
|
return "Q931TemporaryFailure";
|
|
|
|
case Q931Congestion:
|
|
|
|
return "Q931Congestion";
|
|
|
|
case Q931RequestedCircuitUnAvailable:
|
|
|
|
return "Q931RequestedCircuitUnavailable";
|
|
|
|
case Q931ResourcesUnavailable:
|
|
|
|
return "Q931ResourcesUnavailable";
|
|
|
|
case Q931IncompatibleDestination:
|
|
|
|
return "Q931IncompatibleDestination";
|
|
|
|
case Q931ProtocolErrorUnspecified:
|
|
|
|
return "Q931ProtocolErrorUnspecified";
|
|
|
|
case Q931RecoveryOnTimerExpiry:
|
|
|
|
return "Q931RecoveryOnTimerExpiry";
|
|
|
|
case Q931InvalidCallReference:
|
|
|
|
return "Q931InvaliedCallReference";
|
|
|
|
default:
|
|
|
|
return "Unsupported Cause Type";
|
|
|
|
}
|
|
|
|
return "Unsupported Cause Type";
|
|
|
|
}
|