[Asterisk-cvs] asterisk-addons/asterisk-ooh323c/ooh323c/src
ooCalls.c, 1.7, 1.8 ooCalls.h, 1.6, 1.7 ooCapability.c, 1.8,
1.9 ooCapability.h, 1.6, 1.7 ooCommon.h, 1.1, 1.2 ooDateTime.c,
1.1, 1.2 ooLogChan.c, 1.2, 1.3 ooSocket.c, 1.5,
1.6 ooStackCmds.c, 1.7, 1.8 ooStackCmds.h, 1.6, 1.7 ooUtils.c,
1.1, 1.2 ooUtils.h, 1.1, 1.2 oochannels.c, 1.9, 1.10 ooh245.c,
1.10, 1.11 ooh323.c, 1.8, 1.9 ooh323ep.c, 1.6, 1.7 ooh323ep.h,
1.7, 1.8 ooq931.c, 1.16, 1.17 ooq931.h, 1.7, 1.8 ootrace.c,
1.5, 1.6 ootrace.h, 1.3, 1.4 ootypes.h, 1.7,
1.8 printHandler.c, 1.2, 1.3
vphirke
vphirke
Wed Oct 26 16:56:52 CDT 2005
- Previous message: [Asterisk-cvs] asterisk-addons/asterisk-ooh323c/src chan_h323.c,
1.12, 1.13 chan_h323.h, 1.2, 1.3 ooh323cDriver.c, 1.5, 1.6
- Next message: [Asterisk-cvs] asterisk/include/asterisk adsi.h, 1.12,
1.13 callerid.h, 1.14, 1.15 cdr.h, 1.30, 1.31 channel.h, 1.107,
1.108 config.h, 1.24, 1.25 devicestate.h, 1.5, 1.6 doxyref.h,
1.2, 1.3 enum.h, 1.8, 1.9 file.h, 1.28, 1.29 frame.h, 1.59,
1.60 manager.h, 1.22, 1.23 module.h, 1.23, 1.24 pbx.h, 1.54,
1.55 plc.h, 1.4, 1.5 strings.h, 1.13, 1.14 tdd.h, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src
In directory mongoose.digium.com:/tmp/cvs-serv18763/ooh323c/src
Modified Files:
ooCalls.c ooCalls.h ooCapability.c ooCapability.h ooCommon.h
ooDateTime.c ooLogChan.c ooSocket.c ooStackCmds.c
ooStackCmds.h ooUtils.c ooUtils.h oochannels.c ooh245.c
ooh323.c ooh323ep.c ooh323ep.h ooq931.c ooq931.h ootrace.c
ootrace.h ootypes.h printHandler.c
Log Message:
Updated stack source as well as channel driver
Index: ooCalls.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCalls.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ooCalls.c 2 Sep 2005 14:27:10 -0000 1.7
+++ ooCalls.c 26 Oct 2005 20:49:40 -0000 1.8
@@ -731,3 +731,50 @@
return OO_OK;
}
+
+const char* ooGetReasonCodeText (OOUINT32 code)
+{
+ static const char* reasonCodeText[] = {
+ "OO_REASON_UNKNOWN",
+ "OO_REASON_INVALIDMESSAGE",
+ "OO_REASON_TRANSPORTFAILURE",
+ "OO_REASON_NOROUTE",
+ "OO_REASON_NOUSER",
+ "OO_REASON_NOBW",
+ "OO_REASON_GK_NOCALLEDUSER",
+ "OO_REASON_GK_NOCALLERUSER",
+ "OO_REASON_GK_NORESOURCES",
+ "OO_REASON_GK_UNREACHABLE",
+ "OO_REASON_GK_CLEARED",
+ "OO_REASON_NOCOMMON_CAPABILITIES",
+ "OO_REASON_REMOTE_FWDED",
+ "OO_REASON_LOCAL_FWDED",
+ "OO_REASON_REMOTE_CLEARED",
+ "OO_REASON_LOCAL_CLEARED",
+ "OO_REASON_REMOTE_BUSY",
+ "OO_REASON_LOCAL_BUSY",
+ "OO_REASON_REMOTE_NOANSWER",
+ "OO_REASON_LOCAL_NOTANSWERED",
+ "OO_REASON_REMOTE_REJECTED",
+ "OO_REASON_LOCAL_REJECTED",
+ "OO_REASON_REMOTE_CONGESTED",
+ "OO_REASON_LOCAL_CONGESTED"
+ };
+ return ooUtilsGetText (code, reasonCodeText, OONUMBEROF(reasonCodeText));
+}
+
+const char* ooGetCallStateText (OOCallState callState)
+{
+ static const char* callStateText[] = {
+ "OO_CALL_CREATED",
+ "OO_CALL_WAITING_ADMISSION",
+ "OO_CALL_CONNECTING",
+ "OO_CALL_CONNECTED",
+ "OO_CALL_CLEAR",
+ "OO_CALL_CLEAR_RELEASERECVD",
+ "OO_CALL_CLEAR_RELEASESENT",
+ "OO_CALL_CLEARED"
+ };
+ return ooUtilsGetText (callState, callStateText, OONUMBEROF(callStateText));
+}
+
Index: ooCalls.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCalls.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ooCalls.h 16 Sep 2005 19:29:17 -0000 1.6
+++ ooCalls.h 26 Oct 2005 20:49:40 -0000 1.7
@@ -51,7 +51,7 @@
#define OO_M_FASTSTARTANSWERED 0x04000000
#define OO_M_FASTSTART 0x02000000
#define OO_M_DISABLEGK 0x01000000
-
+#define OO_M_MANUALRINGBACK 0x10000000
/**
@@ -756,6 +756,24 @@
*/
EXTERN int ooCallH245ConnectionRetryTimerExpired(void *data);
+/**
+ * This function is used to retrieve the description text for a reason
+ * code.
+ *
+ * @param code Reason code.
+ * @return The text description string.
+ */
+EXTERN const char* ooGetReasonCodeText (OOUINT32 code);
+
+/**
+ * This function is used to retrieve the description text for a call
+ * state.
+ *
+ * @param callState Call state.
+ * @return The text description string.
+ */
+EXTERN const char* ooGetCallStateText (OOCallState callState);
+
/**
* @}
*/
Index: ooCapability.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCapability.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ooCapability.c 2 Sep 2005 14:27:10 -0000 1.8
+++ ooCapability.c 26 Oct 2005 20:49:40 -0000 1.9
@@ -17,7 +17,7 @@
#include "ootrace.h"
#include "ooCalls.h"
#include "ooh323ep.h"
-
+#include "ooUtils.h"
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
@@ -223,8 +223,8 @@
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote)
{
- int iRet=0;
- ooH323EpCapability *epCap = NULL, *cur=NULL, *lHead=NULL;
+
+ ooH323EpCapability *epCap = NULL, *cur=NULL;
OOH263CapParams *params=NULL;
OOCTXT *pctxt=NULL;
char *pictureType = NULL;
@@ -257,7 +257,7 @@
if(cifMPI>0)
{
params->MPI = cifMPI;
- params->picFormat, OO_PICFORMAT_CIF;
+ params->picFormat = OO_PICFORMAT_CIF;
pictureType = "CIF";
}
if(cif4MPI>0)
@@ -347,8 +347,7 @@
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote)
{
- int iRet=0;
- ooH323EpCapability *epCap = NULL, *cur=NULL, *lHead=NULL;
+ ooH323EpCapability *epCap = NULL, *cur=NULL;
OOCapParams *params=NULL;
OOCTXT *pctxt=NULL;
if(!call) pctxt = &gH323ep.ctxt;
@@ -443,7 +442,7 @@
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote)
{
- int iRet=0;
+
ooH323EpCapability *epCap = NULL, *cur=NULL;
OOGSMCapParams *params=NULL;
OOCTXT *pctxt = NULL;
@@ -968,7 +967,7 @@
H245VideoCapability *pVideoCap, int dir)
{
H245H263VideoCapability *pH263Cap = NULL;
- unsigned cap = OO_H263VIDEO;
+
OOH263CapParams *params = epCap->params;
if(!pVideoCap->u.h263VideoCapability)
{
@@ -1826,7 +1825,7 @@
/* Decrease Pref order */
if(i < pos)
{
- for(i; i<pos; i++)
+ for( ; i<pos; i++)
capPrefs->order[i] = capPrefs->order[i+1];
capPrefs->order[i]=cap;
return OO_OK;
@@ -1893,8 +1892,6 @@
int dir)
{
int rxframes=0, txframes=0;
- ASN1USINT audioUnitSize=0;
- OOBOOL comfortNoise=FALSE, scrambled=FALSE;
switch(audioCap->t)
{
@@ -2194,3 +2191,45 @@
return OO_OK;
}
+
+const char* ooGetCapTypeText (OOCapabilities cap)
+{
+ static const char *capTypes[]={
+ "unknown",
+ "OO_NONSTANDARD",
+ "OO_G711ALAW64K",
+ "OO_G711ALAW56K",
+ "OO_G711ULAW64K",
+ "OO_G711ULAW56K",
+ "OO_G72264K",
+ "OO_G72256K",
+ "OO_G72248K",
+ "OO_G7231",
+ "OO_G728",
+ "OO_G729",
+ "OO_G729ANNEXA",
+ "OO_IS11172AUDIO",
+ "OO_IS13818AUDIO",
+ "OO_G729WANNEXB",
+ "OO_G729ANNEXAWANNEXB",
+ "OO_G7231ANNEXC",
+ "OO_GSMFULLRATE",
+ "OO_GSMHALFRATE",
+ "OO_GSMENHANCEDFULLRATE",
+ "OO_GENERICAUDIO",
+ "OO_G729EXTENSIONS",
+ "OO_VBD",
+ "OO_AUDIOTELEPHONYEVENT",
+ "OO_AUDIOTONE",
+ "OO_EXTELEM1",
+ "OO_VIDEO_BASE",
+ "OO_NONSTDVIDEO",
+ "OO_H261VIDEO",
+ "OO_H262VIDEO",
+ "OO_H263VIDEO",
+ "OO_IS11172VIDEO", /* mpeg */
+ "OO_GENERICVIDEO",
+ "OO_EXTELEMVIDEO"
+ };
+ return ooUtilsGetText (cap, capTypes, OONUMBEROF(capTypes));
+}
Index: ooCapability.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCapability.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ooCapability.h 2 Sep 2005 14:27:10 -0000 1.6
+++ ooCapability.h 26 Oct 2005 20:49:40 -0000 1.7
@@ -688,6 +688,14 @@
*/
EXTERN int ooPreppendCapToCapPrefs(struct OOH323CallData *call, int cap);
+/**
+ * This function is used to retrieve the text description for a capability
+ * type.
+ * @param cap Capability
+ * @return The text description string.
+ */
+EXTERN const char* ooGetCapTypeText (OOCapabilities cap);
+
/**
* @}
Index: ooCommon.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCommon.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooCommon.h 23 May 2005 21:03:55 -0000 1.1
+++ ooCommon.h 26 Oct 2005 20:49:40 -0000 1.2
@@ -101,6 +101,10 @@
#define OOMIN(a,b) (((a)<(b))?(a):(b))
#endif
+/* Get count of number of items in an array */
+
+#define OONUMBEROF(items) (sizeof(items)/sizeof(items[0]))
+
/* This is used for creating a Windows DLL. Specify -DMAKE_DLL to */
/* compile code for inclusion in a DLL. */
Index: ooDateTime.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooDateTime.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooDateTime.c 23 May 2005 21:03:55 -0000 1.1
+++ ooDateTime.c 26 Oct 2005 20:49:40 -0000 1.2
@@ -17,6 +17,8 @@
#include "ooCommon.h"
#if defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
+
+#ifndef __MINGW32__
#include <SYS\TIMEB.H>
int gettimeofday (struct timeval *tv, struct timezone *tz)
{
@@ -28,6 +30,135 @@
return 0;
}
+
+#else
+/* Mingw specific logic..probably works with regular winders
+ * too, but cannot test. --Ben
+ */
+#define uint64 unsigned long long
+#define uint32 unsigned long
+
+static uint64 calcEpocOffset() {
+ SYSTEMTIME st;
+ FILETIME ft;
+
+ memset(&st, 0, sizeof(st));
+ memset(&ft, 0, sizeof(ft));
+
+ st.wYear = 1970;
+ st.wMonth = 1;
+ st.wDayOfWeek = 0;
+ st.wDay = 1;
+ st.wHour = 0;
+ st.wMinute = 0;
+ st.wSecond = 0;
+ st.wMilliseconds = 0;
+
+ if (!SystemTimeToFileTime(&st, &ft)) {
+ //cout << "ERROR: SystemTimeToFileTime failed, err: "
+ // << GetLastError() << endl;
+ }
+
+ uint64 t = ft.dwHighDateTime;
+ t = t << 32;
+ t |= ft.dwLowDateTime;
+
+ return t;
+}
+
+// Gets high resolution by spinning up to 15ms. Don't call this often!!!
+static uint64 getRawCurMsSpin() {
+ FILETIME tm;
+ uint64 t_now;
+
+ static uint64 epocOffset = 0;
+ static int do_once = 1;
+ if (do_once) {
+ epocOffset = calcEpocOffset();
+ do_once = 0;
+ }
+
+ GetSystemTimeAsFileTime(&tm);
+ uint64 t_start = tm.dwHighDateTime;
+ t_start = t_start << 32;
+ t_start |= tm.dwLowDateTime;
+ while (1) {
+ GetSystemTimeAsFileTime(&tm);
+ t_now = tm.dwHighDateTime;
+ t_now = t_now << 32;
+ t_now |= tm.dwLowDateTime;
+
+ if (t_now != t_start) {
+ // Hit a boundary...as accurate as we are going to get.
+ break;
+ }
+ }
+
+
+ t_now -= epocOffset;
+
+ // t is in 100ns units, convert to usecs
+ t_now = t_now / 10000; //msecs
+
+ return t_now;
+}
+
+static uint64 baselineMs = 0;
+static uint32 tickBaseline = 0;
+
+int gettimeofday(struct timeval* tv, void* null) {
+
+ // Get baseline time, in seconds.
+ if (baselineMs == 0) {
+ baselineMs = getRawCurMsSpin();
+ tickBaseline = timeGetTime();
+ }
+
+ uint32 curTicks = timeGetTime();
+ if (curTicks < tickBaseline) {
+ // Wrap!
+ baselineMs = getRawCurMsSpin();
+ tickBaseline = timeGetTime();
+ }
+
+ uint64 now_ms = (baselineMs + (curTicks - tickBaseline));
+ *tv = oo_ms_to_tv(now_ms);
+ return 0;
+};
+
+
+/* Correctly synched with the 'real' time/date clock, but only exact to
+ * about 15ms. Set foo to non NULL if you want to recalculate the
+ */
+uint64 getCurMsFromClock() {
+ // This has resolution of only about 15ms
+ FILETIME tm;
+ // The Windows epoc is January 1, 1601 (UTC).
+ static uint64 offset = 0;
+ static int do_once = 1;
+ if (do_once) {
+ offset = calcEpocOffset();
+ do_once = 0;
+ }
+
+
+ GetSystemTimeAsFileTime(&tm);
+ uint64 t = tm.dwHighDateTime;
+ t = t << 32;
+ t |= tm.dwLowDateTime;
+
+ /*cout << "file-time: " << t << " offset: " << offset
+ << " normalized: " << (t - offset) << " hi: "
+ << tm.dwHighDateTime << " lo: " << tm.dwLowDateTime
+ << " calc-offset:\n" << calcEpocOffset() << "\n\n";
+ */
+ t -= offset;
+
+ // t is in 100ns units, convert to ms
+ t = t / 10000;
+ return t;
+}
+#endif
#endif
int ooGetTimeOfDay (struct timeval *tv, struct timezone *tz)
Index: ooLogChan.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooLogChan.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ooLogChan.c 16 Jun 2005 19:41:23 -0000 1.2
+++ ooLogChan.c 26 Oct 2005 20:49:40 -0000 1.3
@@ -183,6 +183,8 @@
pChannel = call->logicalChans;
while(pChannel)
{
+ OOTRACEDBGC3("ooFindLogicalChannel, checking channel: %d:%s\n",
+ pChannel->sessionID, pChannel->dir);
if(pChannel->sessionID == sessionID)
{
if(!strcmp(pChannel->dir, dir))
@@ -243,7 +245,7 @@
int ooClearLogicalChannel(OOH323CallData *call, int channelNo)
{
- int ret = OO_OK;
+
OOLogicalChannel *pLogicalChannel = NULL;
ooH323EpCapability *epCap=NULL;
@@ -253,7 +255,8 @@
pLogicalChannel = ooFindLogicalChannelByLogicalChannelNo(call,channelNo);
if(!pLogicalChannel)
{
- OOTRACEWARN4("Logical Channel %d doesn't exist (%s, %s)\n",
+ OOTRACEWARN4("Logical Channel %d doesn't exist, in clearLogicalChannel."
+ " (%s, %s)\n",
channelNo, call->callType, call->callToken);
return OO_OK;
}
Index: ooSocket.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooSocket.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ooSocket.c 6 Jul 2005 12:49:54 -0000 1.5
+++ ooSocket.c 26 Oct 2005 20:49:40 -0000 1.6
@@ -506,7 +506,7 @@
int ooSocketConvertIpToNwAddr(char *inetIp, char *netIp)
{
- int ret=0;
+
struct sockaddr_in sin = {0};
#ifdef _WIN32
sin.sin_addr.s_addr = inet_addr(inetIp);
@@ -536,10 +536,10 @@
if (bufsize < 8)
return ASN_E_BUFOVFLW;
- cnt += sprintf (buf1, "%d", (ipAddr >> 24) & 0xFF);
- cnt += sprintf (buf2, "%d", (ipAddr >> 16) & 0xFF);
- cnt += sprintf (buf3, "%d", (ipAddr >> 8) & 0xFF);
- cnt += sprintf (buf4, "%d", ipAddr & 0xFF);
+ cnt += sprintf (buf1, "%lu", (ipAddr >> 24) & 0xFF);
+ cnt += sprintf (buf2, "%lu", (ipAddr >> 16) & 0xFF);
+ cnt += sprintf (buf3, "%lu", (ipAddr >> 8) & 0xFF);
+ cnt += sprintf (buf4, "%lu", ipAddr & 0xFF);
if (bufsize < cnt + 4)
return ASN_E_BUFOVFLW;
sprintf (pbuf, "%s.%s.%s.%s", buf1, buf2, buf3, buf4);
Index: ooStackCmds.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooStackCmds.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ooStackCmds.c 16 Sep 2005 19:29:17 -0000 1.7
+++ ooStackCmds.c 26 Oct 2005 20:49:40 -0000 1.8
@@ -15,439 +15,324 @@
*****************************************************************************/
#include "ooStackCmds.h"
-#include "ootrace.h"
-#include "ooq931.h"
-#include "ooh245.h"
#include "ooh323ep.h"
-#include "oochannels.h"
#include "ooCalls.h"
+#include "ooCmdChannel.h"
-/** Global endpoint structure */
-extern OOH323EndPoint gH323ep;
+extern OOSOCKET gCmdChan;
-extern OO_MUTEX gCmdMutex;
+int ooGenerateOutgoingCallToken (char *callToken, size_t size)
+{
+ static int counter = 1;
+ char aCallToken[200];
+ int ret = 0;
-int ooMakeCall
+
+ sprintf (aCallToken, "ooh323c_o_%d", counter++);
+
+ if (counter > OO_MAX_CALL_TOKEN)
+ counter = 1;
+
+ if ((strlen(aCallToken)+1) < size)
+ strcpy (callToken, aCallToken);
+ else {
+ ret = OO_FAILED;
+ }
+
+ return ret;
+}
+
+
+OOStkCmdStat ooMakeCall
(const char* dest, char* callToken, size_t bufsiz, ooCallOptions *opts)
{
- OOStackCommand *cmd;
- int ret;
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
- cmd = (OOStackCommand*) memAlloc (&gH323ep.ctxt, sizeof(OOStackCommand));
- if(!cmd)
- {
- OOTRACEERR1("Error:Memory - ooMakeCall - cmd\n");
- return OO_FAILED;
+ OOStackCommand cmd;
+
+ if(!callToken)
+ return OO_STKCMD_INVALIDPARAM;
+
+
+ /* Generate call token*/
+ if (ooGenerateOutgoingCallToken (callToken, bufsiz) != OO_OK){
+ return OO_STKCMD_INVALIDPARAM;
}
- cmd->type = OO_CMD_MAKECALL;
- cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(dest)+1);
- if(!cmd->param1)
+
+ if(gCmdChan == 0)
{
- OOTRACEERR1("ERROR:Memory - ooMakeCall - param1\n");
- memFreePtr(&gH323ep.ctxt, cmd);
- return OO_FAILED;
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
- strcpy((char*)cmd->param1, dest);
- /* Generate call token*/
- if(!callToken)
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_MAKECALL;
+ cmd.param1 = (void*) malloc(strlen(dest)+1);
+ if(!cmd.param1)
{
- OOTRACEERR1("ERROR:Invalid 'callToken' parameter to 'ooMakeCall'\n");
- memFreePtr(&gH323ep.ctxt, cmd->param1);
- memFreePtr(&gH323ep.ctxt, cmd);
- return OO_FAILED;
+ return OO_STKCMD_MEMERR;
}
+ strcpy((char*)cmd.param1, dest);
- if ((ret = ooGenerateCallToken (callToken, bufsiz)) != 0)
- return ret;
-
- cmd->param2 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
- if(!cmd->param2)
+
+ cmd.param2 = (void*) malloc(strlen(callToken)+1);
+ if(!cmd.param2)
{
- OOTRACEERR1("ERROR:Memory - ooMakeCall - param2\n");
- memFreePtr(&gH323ep.ctxt, cmd->param1);
- memFreePtr(&gH323ep.ctxt, cmd);
- return OO_FAILED;
+ free(cmd.param1);
+ return OO_STKCMD_MEMERR;
}
- strcpy((char*)cmd->param2, callToken);
+ strcpy((char*)cmd.param2, callToken);
if(!opts)
{
- cmd->param3 = 0;
+ cmd.param3 = 0;
}else {
- cmd->param3 = (void*) memAlloc(&gH323ep.ctxt, sizeof(ooCallOptions));
- if(!cmd->param3)
+ cmd.param3 = (void*) malloc(sizeof(ooCallOptions));
+ if(!cmd.param3)
{
- OOTRACEERR1("ERROR:Memory - ooMakeCall - param3\n");
- memFreePtr(&gH323ep.ctxt, cmd->param1);
- memFreePtr(&gH323ep.ctxt, cmd->param2);
- memFreePtr(&gH323ep.ctxt, cmd);
- return OO_FAILED;
+ free(cmd.param1);
+ free(cmd.param2);
+ return OO_STKCMD_MEMERR;
}
- memcpy((void*)cmd->param3, opts, sizeof(ooCallOptions));
+ memcpy((void*)cmd.param3, opts, sizeof(ooCallOptions));
}
-
- dListAppend (&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);
-#ifdef HAVE_PIPE
- if(write(gH323ep.cmdPipe[1], "c", 1)<0)
+ if(ooWriteStackCommand(&cmd) != OO_OK)
{
- OOTRACEERR1("ERROR:Failed to write to command pipe\n");
+ free(cmd.param1);
+ free(cmd.param2);
+ if(cmd.param3) free(cmd.param3);
+ return OO_STKCMD_WRITEERR;
}
-#endif
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
-
- return OO_OK;
+ return OO_STKCMD_SUCCESS;
}
-int ooAnswerCall(char *callToken)
-{
- OOStackCommand *cmd;
+OOStkCmdStat ooManualRingback(const char *callToken)
+{
+ OOStackCommand cmd;
if(!callToken)
{
- OOTRACEERR1("ERROR: Invalid callToken passed to ooAnswerCall\n");
- return OO_FAILED;
+ return OO_STKCMD_INVALIDPARAM;
}
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
- cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
- if(!cmd)
+ if(gCmdChan == 0)
{
- OOTRACEERR1("Error:Memory - ooAnswerCall - cmd\n");
- return OO_FAILED;
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
- memset(cmd, 0, sizeof(OOStackCommand));
- cmd->type = OO_CMD_ANSCALL;
- cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
- if(!cmd->param1)
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_MANUALRINGBACK;
+ cmd.param1 = (void*) malloc(strlen(callToken)+1);
+ if(!cmd.param1)
{
- OOTRACEERR1("ERROR:Memory - ooAnswerCall - param1\n");
- return OO_FAILED;
+ return OO_STKCMD_MEMERR;
}
- strcpy((char*)cmd->param1, callToken);
-
- dListAppend(&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);
+ strcpy((char*)cmd.param1, callToken);
-#ifdef HAVE_PIPE
- if(write(gH323ep.cmdPipe[1], "c", 1)<0)
+ if(ooWriteStackCommand(&cmd) != OO_OK)
{
- OOTRACEERR1("ERROR:Failed to write to command pipe\n");
+ free(cmd.param1);
+ return OO_STKCMD_WRITEERR;
}
-#endif
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
-
- return OO_OK;
+ return OO_STKCMD_SUCCESS;
}
-int ooForwardCall(char* callToken, char *dest)
+OOStkCmdStat ooAnswerCall(const char *callToken)
{
- OOStackCommand *cmd;
+ OOStackCommand cmd;
- if(!callToken || !dest)
+ if(!callToken)
{
- OOTRACEERR1("ERROR: Invalid callToken/dest passed to ooForwardCall\n");
- return OO_FAILED;
+ return OO_STKCMD_INVALIDPARAM;
}
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
- cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
- if(!cmd)
+
+ if(gCmdChan == 0)
{
- OOTRACEERR1("Error:Memory - ooForwardCall - cmd\n");
- return OO_FAILED;
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
- memset(cmd, 0, sizeof(OOStackCommand));
- cmd->type = OO_CMD_FWDCALL;
- cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
- cmd->param2 = (void*) memAlloc(&gH323ep.ctxt, strlen(dest)+1);
- if(!cmd->param1 || !cmd->param2)
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_ANSCALL;
+
+ cmd.param1 = (void*) malloc(strlen(callToken)+1);
+ if(!cmd.param1)
{
- OOTRACEERR1("ERROR:Memory - ooForwardCall - param1/param2\n");
- return OO_FAILED;
+ return OO_STKCMD_MEMERR;
}
- strcpy((char*)cmd->param1, callToken);
- strcpy((char*)cmd->param2, dest);
- dListAppend(&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);
+ strcpy((char*)cmd.param1, callToken);
-#ifdef HAVE_PIPE
- if(write(gH323ep.cmdPipe[1], "c", 1)<0)
+ if(ooWriteStackCommand(&cmd) != OO_OK)
{
- OOTRACEERR1("ERROR:Failed to write to command pipe\n");
+ free(cmd.param1);
+ return OO_STKCMD_WRITEERR;
}
-#endif
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
- return OO_OK;
+ return OO_STKCMD_SUCCESS;
}
-
-int ooHangCall(char *callToken, OOCallClearReason reason)
+OOStkCmdStat ooForwardCall(const char* callToken, char *dest)
{
- OOStackCommand *cmd;
+ OOStackCommand cmd;
- if(!callToken)
+ if(!callToken || !dest)
{
- OOTRACEERR1("ERROR: Invalid callToken passed to ooHangCall\n");
- return OO_FAILED;
+ return OO_STKCMD_INVALIDPARAM;
}
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
-
- cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
- if(!cmd)
+ if(gCmdChan == 0)
{
- OOTRACEERR1("Error:Allocating memory for command structure - HangCall\n");
- return OO_FAILED;
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
- memset(cmd, 0, sizeof(OOStackCommand));
- cmd->type = OO_CMD_HANGCALL;
- cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
- cmd->param2 = (void*)memAlloc(&gH323ep.ctxt, sizeof(OOCallClearReason));
- if(!cmd->param1 || !cmd->param2)
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_FWDCALL;
+
+ cmd.param1 = (void*) malloc(strlen(callToken)+1);
+ cmd.param2 = (void*) malloc(strlen(dest)+1);
+ if(!cmd.param1 || !cmd.param2)
{
- OOTRACEERR1("ERROR:Allocating memory for cmd param1/param2- HangCall\n");
- return OO_FAILED;
+ if(cmd.param1) free(cmd.param1); /* Release memory */
+ if(cmd.param2) free(cmd.param2);
+ return OO_STKCMD_MEMERR;
}
- strcpy((char*)cmd->param1, callToken);
- *((OOCallClearReason*)cmd->param2) = reason;
-
- dListAppend(&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);
-
-#ifdef HAVE_PIPE
- if(write(gH323ep.cmdPipe[1], "c", 1)<0)
+ strcpy((char*)cmd.param1, callToken);
+ strcpy((char*)cmd.param2, dest);
+
+ if(ooWriteStackCommand(&cmd) != OO_OK)
{
- OOTRACEERR1("ERROR:Failed to write to command pipe\n");
+ free(cmd.param1);
+ free(cmd.param2);
+ return OO_STKCMD_WRITEERR;
}
-#endif
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
- return OO_OK;
+ return OO_STKCMD_SUCCESS;
}
-int ooProcStackCmds()
-{
- OOH323CallData *call = NULL;
- if (gH323ep.stkCmdList.count > 0)
- {
- OOStackCommand *cmd;
- DListNode *pNode = NULL;
- //while (0 !=(cmd=dListDeleteHead (&gH323ep.ctxt, &gH323ep.stkCmdList)))
- while (0 != (pNode = dListFindByIndex(&gH323ep.stkCmdList, 0)))
- {
- cmd = (OOStackCommand*)pNode->data;
- switch(cmd->type) {
- case OO_CMD_MAKECALL:
- if(gH323ep.gkClient &&
- gH323ep.gkClient->state != GkClientRegistered)
- {
- OOTRACEWARN1("WARNING: New outgoing call cmd is waiting for "
- "gatekeeper registration.\n");
- continue;
- }
-
- OOTRACEINFO2("Processing MakeCall command %s\n",
- (char*)cmd->param2);
-
- ooH323MakeCall ((char*)cmd->param1, (char*)cmd->param2,
- (ooCallOptions*)cmd->param3);
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
-
- case OO_CMD_ANSCALL:
- if(gH323ep.gkClient &&
- gH323ep.gkClient->state != GkClientRegistered)
- {
- OOTRACEWARN1("New answer call cmd is waiting for "
- "gatekeeper registration.\n");
- continue;
- }
- OOTRACEINFO2("Processing Answer Call command for %s\n",
- (char*)cmd->param1);
- ooSendConnect(ooFindCallByToken((char*)cmd->param1));
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
- case OO_CMD_FWDCALL:
- OOTRACEINFO3("Forwarding call %s to %s\n", (char*)cmd->param1,
- (char*)cmd->param2);
- ooH323ForwardCall((char*)cmd->param1, (char*)cmd->param2);
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
-
- case OO_CMD_HANGCALL:
- OOTRACEINFO2("Processing Hang call command %s\n",
- (char*)cmd->param1);
- ooH323HangCall((char*)cmd->param1,
- *(OOCallClearReason*)cmd->param2);
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
-
- case OO_CMD_SENDDIGIT:
- call = ooFindCallByToken((char*)cmd->param1);
- if(!call)
- {
- OOTRACEERR2("Error:Invalid calltoken %s\n",
- (char*)cmd->param1);
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
- }
- if(call->jointDtmfMode & OO_CAP_DTMF_H245_alphanumeric)
- ooSendH245UserInputIndication_alphanumeric(call,
- (const char*)cmd->param2);
- else if(call->jointDtmfMode & OO_CAP_DTMF_H245_signal)
- ooSendH245UserInputIndication_signal(call,
- (const char*)cmd->param2);
- else
- ooQ931SendDTMFAsKeyPadIE(call, (const char*)cmd->param2);
-
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
+OOStkCmdStat ooHangCall(const char* callToken, OOCallClearReason reason)
+{
+ OOStackCommand cmd;
- case OO_CMD_STOPMONITOR:
- OOTRACEINFO1("Processing StopMonitor command\n");
- ooStopMonitorCalls();
- dListRemove(&gH323ep.stkCmdList, pNode);
- memFreePtr(&gH323ep.ctxt, pNode);
- break;
+ if(!callToken)
+ {
+ return OO_STKCMD_INVALIDPARAM;
+ }
- default: OOTRACEERR1("ERROR:Unhandled command\n");
- }
- if(cmd->param1) memFreePtr(&gH323ep.ctxt, cmd->param1);
- if(cmd->param2) memFreePtr(&gH323ep.ctxt, cmd->param2);
- if(cmd->param3) memFreePtr(&gH323ep.ctxt, cmd->param3);
- memFreePtr (&gH323ep.ctxt, cmd);
- }
+ if(gCmdChan == 0)
+ {
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
- return OO_OK;
-}
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_HANGCALL;
+ cmd.param1 = (void*) malloc(strlen(callToken)+1);
+ cmd.param2 = (void*) malloc(sizeof(OOCallClearReason));
+ if(!cmd.param1 || !cmd.param2)
+ {
+ if(cmd.param1) free(cmd.param1); /* Release memory */
+ if(cmd.param2) free(cmd.param2);
+ return OO_STKCMD_MEMERR;
+ }
+ strcpy((char*)cmd.param1, callToken);
+ *((OOCallClearReason*)cmd.param2) = reason;
-int ooStopMonitor()
-{
- OOStackCommand *cmd;
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
- cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
- if(!cmd)
+ if(ooWriteStackCommand(&cmd) != OO_OK)
{
- OOTRACEERR1("Error:Allocating memory for command structure - StopMonitor\n");
- return OO_FAILED;
+ free(cmd.param1);
+ free(cmd.param2);
+ return OO_STKCMD_WRITEERR;
}
- memset(cmd, 0, sizeof(OOStackCommand));
- cmd->type = OO_CMD_STOPMONITOR;
- dListAppend (&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);
+ return OO_STKCMD_SUCCESS;
+}
-#ifdef HAVE_PIPE
- if(write(gH323ep.cmdPipe[1], "c", 1)<0)
+
+OOStkCmdStat ooStopMonitor()
+{
+ OOStackCommand cmd;
+
+ if(gCmdChan == 0)
{
- OOTRACEERR1("ERROR:Failed to write to command pipe\n");
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
-#endif
+
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_STOPMONITOR;
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
- return OO_OK;
+ if(ooWriteStackCommand(&cmd) != OO_OK)
+ return OO_STKCMD_WRITEERR;
+
+ return OO_STKCMD_SUCCESS;
}
-int ooSendDTMFDigit(char *callToken, char* dtmf)
+OOStkCmdStat ooSendDTMFDigit(const char *callToken, const char* dtmf)
{
- OOStackCommand *cmd = NULL;
+ OOStackCommand cmd;
if(!callToken)
{
- OOTRACEERR1("ERROR: Invalid callToken passed to ooSendDTMFDigit\n");
- return OO_FAILED;
+ return OO_STKCMD_INVALIDPARAM;
}
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
- cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
- if(!cmd)
+ if(gCmdChan == 0)
{
- OOTRACEERR1("Error:Memory - ooSendDTMFDigit - cmd\n");
- return OO_FAILED;
+ if(ooCreateCmdConnection() != OO_OK)
+ return OO_STKCMD_CONNECTIONERR;
}
- memset(cmd, 0, sizeof(OOStackCommand));
- cmd->type = OO_CMD_SENDDIGIT;
- cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
- cmd->param2 = (void*) memAlloc(&gH323ep.ctxt, strlen(dtmf)+1);
- if(!cmd->param1 || !cmd->param2)
+ memset(&cmd, 0, sizeof(OOStackCommand));
+ cmd.type = OO_CMD_SENDDIGIT;
+
+ cmd.param1 = (void*) malloc(strlen(callToken)+1);
+ cmd.param2 = (void*) malloc(strlen(dtmf)+1);
+ if(!cmd.param1 || !cmd.param2)
{
- OOTRACEERR1("ERROR:Memory - ooSendDTMFDigit - param1/param2\n");
- return OO_FAILED;
+ if(cmd.param1) free(cmd.param1); /* Release memory */
+ if(cmd.param2) free(cmd.param2);
+ return OO_STKCMD_MEMERR;
}
- strcpy((char*)cmd->param1, callToken);
- strcpy((char*)cmd->param2, dtmf);
-
- dListAppend(&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);
+ strcpy((char*)cmd.param1, callToken);
+ strcpy((char*)cmd.param2, dtmf);
-#ifdef HAVE_PIPE
- if(write(gH323ep.cmdPipe[1], "c", 1)<0)
+ if(ooWriteStackCommand(&cmd) != OO_OK)
{
- OOTRACEERR1("ERROR:Failed to write to command pipe\n");
+ free(cmd.param1);
+ free(cmd.param2);
+ return OO_STKCMD_WRITEERR;
}
-#endif
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
+ return OO_STKCMD_SUCCESS;
+}
- return OO_OK;
+
+const char* ooGetStkCmdStatusCodeTxt(OOStkCmdStat stat)
+{
+ switch(stat)
+ {
+ case OO_STKCMD_SUCCESS:
+ return "Stack command - successfully issued";
+
+ case OO_STKCMD_MEMERR:
+ return "Stack command - Memory allocation error";
+
+ case OO_STKCMD_INVALIDPARAM:
+ return "Stack command - Invalid parameter";
+
+ case OO_STKCMD_WRITEERR:
+ return "Stack command - write error";
+
+ case OO_STKCMD_CONNECTIONERR:
+ return "Stack command - Failed to create command channel";
+
+ default:
+ return "Invalid status code";
+ }
}
+
Index: ooStackCmds.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooStackCmds.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ooStackCmds.h 16 Sep 2005 19:29:17 -0000 1.6
+++ ooStackCmds.h 26 Oct 2005 20:49:40 -0000 1.7
@@ -37,19 +37,34 @@
#endif /* EXTERN */
+
/**
* @defgroup stackcmds Stack Control Commands
* @{
*/
+
+/**
+ * This is an enumeration of Stack Command return codes.
+ */
+typedef enum OOStkCmdStat{
+ OO_STKCMD_SUCCESS,
+ OO_STKCMD_MEMERR,
+ OO_STKCMD_INVALIDPARAM,
+ OO_STKCMD_WRITEERR,
+ OO_STKCMD_CONNECTIONERR
+}OOStkCmdStat;
+
/**
* This is an enumeration of stack command codes.
*/
typedef enum OOStackCmdID {
+ OO_CMD_NOOP,
OO_CMD_MAKECALL, /*!< Make call */
OO_CMD_ANSCALL, /*!< Answer call */
OO_CMD_FWDCALL, /*!< Forward call */
OO_CMD_HANGCALL, /*!< Terminate call */
OO_CMD_SENDDIGIT, /*!< Send dtmf */
+ OO_CMD_MANUALRINGBACK, /*!< Send Alerting - ringback */
OO_CMD_STOPMONITOR /*!< Stop the event monitor */
} OOStackCmdID;
@@ -75,19 +90,29 @@
* @param opts These are call specific options and if passed a non-null
* value, will override global endpoint options.
*
- * @return OO_OK, on success. OO_FAILED, on failure.
+ * @return Returns OOStkCmdStat value indication success or failure.
*/
-EXTERN int ooMakeCall
+EXTERN OOStkCmdStat ooMakeCall
(const char* dest, char *callToken, size_t bufsiz, ooCallOptions *opts);
+
+/**
+ * This function is used to send a manual ringback message (alerting message)
+ * for a call. Effective only when manual-ringback is enabled.
+ * @param callToken Unique token for the call.
+ *
+ * @return Returns OOStkCmdStat value indication success or failure.
+ */
+EXTERN OOStkCmdStat ooManualRingback(const char *callToken);
+
/**
* This function is used to answer a call
* @param callToken Unique token for the call
*
- * @return OO_OK, on success. OO_FAILED, otherwise.
+ * @return Returns OOStkCmdStat value indication success or failure.
*/
-EXTERN int ooAnswerCall(char *callToken);
+EXTERN OOStkCmdStat ooAnswerCall(const char *callToken);
/**
* This function is used to forward an existing call to third party.
@@ -95,18 +120,18 @@
* @param dest Address to which the call has to be forwarded. Can be
* IP:PORT or alias.
*
- * @return OO_OK, on success. OO_FAILED, on failure.
+ * @return Returns OOStkCmdStat value indication success or failure.
*/
-EXTERN int ooForwardCall(char* callToken, char *dest);
+EXTERN OOStkCmdStat ooForwardCall(const char* callToken, char *dest);
/**
* This function is used by an user application to terminate a call.
* @param callToken The uinque token for the call.
* @param reason Reason for hanging call.
*
- * @return OO_OK, on success. OO_FAILED, on failure.
+ * @return Returns OOStkCmdStat value indication success or failure.
*/
-EXTERN int ooHangCall(char * callToken, OOCallClearReason reason);
+EXTERN OOStkCmdStat ooHangCall(const char* callToken, OOCallClearReason reason);
/**
* This command function can be used by an user application to send a DTMF
@@ -114,23 +139,27 @@
* @param callToken Unique token for the call
* @param alpha Alphanumeric string reperesenting dtmf sequence
*
- * @return OO_OK, on success. OO_FAILED, on failure.
+ * @return Returns OOStkCmdStat value indication success or failure.
*/
-EXTERN int ooSendDTMFDigit(char *callToken, char* alpha);
+EXTERN OOStkCmdStat ooSendDTMFDigit(const char *callToken, const char* alpha);
+
/**
- * This function is invoked from the main event handling loop to
- * process queued stack commands.
+ * This function is used by the user application to stop stack thread.
+ *
+ * @return Returns OOStkCmdStat value indication success or failure.
*/
-EXTERN int ooProcStackCmds (void);
+EXTERN OOStkCmdStat ooStopMonitor(void);
+
/**
- * This function is used by the user application to stop monitoring calls.
+ * This function is used by application to obtain the text description for
+ * failure of tsack command.
+ * @param stat Status code returned by stack command api.
*
- * @return OO_OK, on success. OO_FAILED, on failure.
+ * @return Text description corresponding to the code.
*/
-EXTERN int ooStopMonitor(void);
-
+EXTERN const char* ooGetStkCmdStatusCodeTxt(OOStkCmdStat stat);
/**
* @}
*/
Index: ooUtils.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooUtils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooUtils.c 23 May 2005 21:03:55 -0000 1.1
+++ ooUtils.c 26 Oct 2005 20:49:40 -0000 1.2
@@ -16,8 +16,12 @@
#include "ooUtils.h"
+const char* ooUtilsGetText (OOUINT32 idx, const char** table, size_t tabsiz)
+{
+ return (idx < tabsiz) ? table[idx] : "?";
+}
-OOBOOL ooUtilsIsStrEmpty(char * str)
+OOBOOL ooUtilsIsStrEmpty (const char* str)
{
return (str == NULL || *str =='\0');
}
Index: ooUtils.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooUtils.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooUtils.h 23 May 2005 21:03:55 -0000 1.1
+++ ooUtils.h 26 Oct 2005 20:49:40 -0000 1.2
@@ -20,6 +20,25 @@
#ifndef _OOUTILS_H_
#define _OOUTILS_H_
#include "ootypes.h"
-EXTERN OOBOOL ooUtilsIsStrEmpty(char * str);
+
+/**
+ * Get text from a text table for a given enumeration index.
+ *
+ * @param idx Index of item in table
+ * @param table The table containing the text items
+ * @param tabsiz Number of items in the table
+ * @return Text for item or '?' if idx outside bounds of table
+ */
+EXTERN const char* ooUtilsGetText
+(OOUINT32 idx, const char** table, size_t tabsiz);
+
+/**
+ * Test if given string value is empty. String is considered to empty
+ * if value is NULL or there are no characters in string (strlen == 0).
+ *
+ * @param str String to test
+ * @return TRUE if string empty; FALSE otherwise
+ */
+EXTERN OOBOOL ooUtilsIsStrEmpty (const char * str);
#endif
Index: oochannels.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/oochannels.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- oochannels.c 2 Aug 2005 18:54:54 -0000 1.9
+++ oochannels.c 26 Oct 2005 20:49:40 -0000 1.10
@@ -27,20 +27,17 @@
#include "ooTimer.h"
#include "ooh323ep.h"
#include "ooStackCmds.h"
+#include "ooCmdChannel.h"
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
-extern OO_MUTEX gCmdMutex;
-
extern DList g_TimerList;
static OOBOOL gMonitor = FALSE;
+
int ooCreateH245Listener(OOH323CallData *call)
{
int ret=0;
@@ -477,22 +474,260 @@
return OO_OK;
}
+
+int ooSetFDSETs(fd_set *pReadfds, fd_set *pWritefds, int *nfds)
+{
+ OOH323CallData *call=NULL;
+
+ if(gH323ep.gkClient && gH323ep.gkClient->rasSocket != 0)
+ {
+ FD_SET(gH323ep.gkClient->rasSocket, pReadfds );
+ if ( *nfds < (int)gH323ep.gkClient->rasSocket)
+ *nfds = (int)gH323ep.gkClient->rasSocket;
+ }
+ if(gH323ep.listener)
+ {
+ FD_SET(*(gH323ep.listener), pReadfds);
+ if(*nfds < (int)*(gH323ep.listener))
+ *nfds = *((int*)gH323ep.listener);
+ }
+
+ if(gH323ep.cmdListener)
+ {
+ FD_SET(gH323ep.cmdListener, pReadfds);
+ if(*nfds < (int)gH323ep.cmdListener)
+ *nfds = (int)gH323ep.cmdListener;
+ }
+ if(gH323ep.cmdSock)
+ {
+ FD_SET(gH323ep.cmdSock, pReadfds);
+ if(*nfds < (int)gH323ep.cmdSock)
+ *nfds = (int)gH323ep.cmdSock;
+ }
+
+
+
+ if(gH323ep.callList)
+ {
+ call = gH323ep.callList;
+ while(call)
+ {
+ if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
+ {
+ FD_SET (call->pH225Channel->sock, pReadfds);
+ if (call->pH225Channel->outQueue.count > 0 ||
+ (OO_TESTFLAG (call->flags, OO_M_TUNNELING) &&
+ 0 != call->pH245Channel &&
+ call->pH245Channel->outQueue.count>0))
+ FD_SET (call->pH225Channel->sock, pWritefds);
+ if(*nfds < (int)call->pH225Channel->sock)
+ *nfds = call->pH225Channel->sock;
+ }
+
+ if (0 != call->pH245Channel && call->pH245Channel->sock != 0)
+ {
+ FD_SET(call->pH245Channel->sock, pReadfds);
+ if (call->pH245Channel->outQueue.count>0)
+ FD_SET(call->pH245Channel->sock, pWritefds);
+ if(*nfds < (int)call->pH245Channel->sock)
+ *nfds = call->pH245Channel->sock;
+ }
+ else if(call->h245listener)
+ {
+ OOTRACEINFO3("H.245 Listerner socket being monitored "
+ "(%s, %s)\n", call->callType, call->callToken);
+ FD_SET(*(call->h245listener), pReadfds);
+ if(*nfds < (int)*(call->h245listener))
+ *nfds = *(call->h245listener);
+ }
+ call = call->next;
+
+ }/* while(call) */
+ }/*if(gH323ep.callList) */
+
+
+ if(*nfds != 0) *nfds = *nfds+1;
+
+ return OO_OK;
+
+}
+
+int ooProcessFDSETsAndTimers
+ (fd_set *pReadfds, fd_set *pWritefds, struct timeval *pToMin)
+{
+ OOH323CallData *call, *prev=NULL;
+ struct timeval toNext;
+
+ /* Process gatekeeper client timers */
+ if(gH323ep.gkClient)
+ {
+ ooTimerFireExpired(&gH323ep.gkClient->ctxt,
+ &gH323ep.gkClient->timerList);
+ if(ooTimerNextTimeout(&gH323ep.gkClient->timerList, &toNext))
+ {
+ if(ooCompareTimeouts(pToMin, &toNext)>0)
+ {
+ pToMin->tv_sec = toNext.tv_sec;
+ pToMin->tv_usec = toNext.tv_usec;
+ }
+ }
+ if(gH323ep.gkClient->state == GkClientFailed ||
+ gH323ep.gkClient->state == GkClientGkErr)
+ {
+ if(ooGkClientHandleClientOrGkFailure(gH323ep.gkClient)!=OO_OK)
+ {
+ //ooStopMonitorCalls(); //Function calling ooProcessFDSETsAndTimers is responsible for this.
+ return OO_FAILED;
+ }
+ }
+ }
+
+
+ if(gH323ep.cmdListener)
+ {
+ if(FD_ISSET(gH323ep.cmdListener, pReadfds))
+ {
+ if(ooAcceptCmdConnection() != OO_OK){
+ OOTRACEERR1("Error:Failed to accept command connection\n");
+ return OO_FAILED;
+ }
+ }
+ }
+
+ if(gH323ep.cmdSock)
+ {
+ if(FD_ISSET(gH323ep.cmdSock, pReadfds))
+ {
+ ooReadAndProcessStackCommand();
+ }
+ }
+
+ /* Manage ready descriptors after select */
+
+ if(0 != gH323ep.gkClient && 0 != gH323ep.gkClient->rasSocket)
+ {
+ if(FD_ISSET( gH323ep.gkClient->rasSocket, pReadfds) )
+ {
+ ooGkClientReceive(gH323ep.gkClient);
+ if(gH323ep.gkClient->state == GkClientFailed ||
+ gH323ep.gkClient->state == GkClientGkErr)
+ ooGkClientHandleClientOrGkFailure(gH323ep.gkClient);
+ }
+ }
+
+ if(gH323ep.listener)
+ {
+ if(FD_ISSET(*(gH323ep.listener), pReadfds))
+ {
+ OOTRACEDBGA1("New connection at H225 receiver\n");
+ ooAcceptH225Connection();
+ }
+ }
+
+
+ if(gH323ep.callList)
+ {
+ call = gH323ep.callList;
+ while(call)
+ {
+ ooTimerFireExpired(call->pctxt, &call->timerList);
+ if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
+ {
+ if(FD_ISSET(call->pH225Channel->sock, pReadfds))
+ {
+ if(ooH2250Receive(call) != OO_OK)
+ {
+ OOTRACEERR3("ERROR:Failed ooH2250Receive - Clearing call "
+ "(%s, %s)\n", call->callType, call->callToken);
+ if(call->callState < OO_CALL_CLEAR)
+ {
+ call->callEndReason = OO_REASON_INVALIDMESSAGE;
+ call->callState = OO_CALL_CLEAR;
+ }
+ }
+ }
+ }
+
+
+ if (0 != call->pH245Channel && 0 != call->pH245Channel->sock)
+ {
+ if(FD_ISSET(call->pH245Channel->sock, pReadfds))
+ {
+ ooH245Receive(call);
+ }
+ }
+
+ if (0 != call->pH245Channel && 0 != call->pH245Channel->sock)
+ {
+ if(FD_ISSET(call->pH245Channel->sock, pWritefds))
+ {
+ if(call->pH245Channel->outQueue.count>0)
+ ooSendMsg(call, OOH245MSG);
+ }
+ }
+ else if(call->h245listener)
+ {
+ if(FD_ISSET(*(call->h245listener), pReadfds))
+ {
+ OOTRACEDBGC3("Incoming H.245 connection (%s, %s)\n",
+ call->callType, call->callToken);
+ ooAcceptH245Connection(call);
+ }
+ }
+
+ if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
+ {
+ if(FD_ISSET(call->pH225Channel->sock, pWritefds))
+ {
+ if(call->pH225Channel->outQueue.count>0)
+ {
+ OOTRACEDBGC3("Sending H225 message (%s, %s)\n",
+ call->callType, call->callToken);
+ ooSendMsg(call, OOQ931MSG);
+ }
+ if(call->pH245Channel &&
+ call->pH245Channel->outQueue.count>0 &&
+ OO_TESTFLAG (call->flags, OO_M_TUNNELING))
+ {
+ OOTRACEDBGC3("H245 message needs to be tunneled. "
+ "(%s, %s)\n", call->callType,
+ call->callToken);
+ ooSendMsg(call, OOH245MSG);
+ }
+ }
+ }
+
+ if(ooTimerNextTimeout(&call->timerList, &toNext))
+ {
+ if(ooCompareTimeouts(pToMin, &toNext) > 0)
+ {
+ pToMin->tv_sec = toNext.tv_sec;
+ pToMin->tv_usec = toNext.tv_usec;
+ }
+ }
+ prev = call;
+ call = call->next;
+ if(prev->callState >= OO_CALL_CLEAR)
+ ooEndCall(prev);
+ }/* while(call) */
+ }/* if(gH323ep.callList) */
+
+ return OO_OK;
+
+}
+
int ooMonitorChannels()
{
int ret=0, nfds=0;
struct timeval toMin, toNext;
fd_set readfds, writefds;
- OOH323CallData *call, *prev=NULL;
- int i=0;
-#ifdef HAVE_PIPE
- char buf[2];
-#endif
gMonitor = TRUE;
toMin.tv_sec = 3;
toMin.tv_usec = 0;
ooH323EpPrintConfig();
+
if(gH323ep.gkClient)
{
ooGkClientPrintConfig(gH323ep.gkClient);
@@ -508,64 +743,7 @@
FD_ZERO(&readfds);
FD_ZERO(&writefds);
nfds = 0;
-
- if(gH323ep.gkClient && gH323ep.gkClient->rasSocket != 0)
- {
- FD_SET(gH323ep.gkClient->rasSocket, &readfds );
- if ( nfds < (int)gH323ep.gkClient->rasSocket)
- nfds = (int)gH323ep.gkClient->rasSocket;
- }
- if(gH323ep.listener)
- {
- FD_SET(*(gH323ep.listener), &readfds);
- if(nfds < (int)*(gH323ep.listener))
- nfds = *((int*)gH323ep.listener);
- }
-
-#ifdef HAVE_PIPE
- FD_SET(gH323ep.cmdPipe[0], &readfds);
- if ( nfds < (int)gH323ep.cmdPipe[0])
- nfds = (int)gH323ep.cmdPipe[0];
-#endif
-
- if(gH323ep.callList)
- {
- call = gH323ep.callList;
- while(call)
- {
- if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
- {
- FD_SET (call->pH225Channel->sock, &readfds);
- if (call->pH225Channel->outQueue.count > 0 ||
- (OO_TESTFLAG (call->flags, OO_M_TUNNELING) &&
- 0 != call->pH245Channel &&
- call->pH245Channel->outQueue.count>0))
- FD_SET (call->pH225Channel->sock, &writefds);
- if(nfds < (int)call->pH225Channel->sock)
- nfds = call->pH225Channel->sock;
- }
-
- if (0 != call->pH245Channel && call->pH245Channel->sock != 0)
- {
- FD_SET(call->pH245Channel->sock, &readfds);
- if (call->pH245Channel->outQueue.count>0)
- FD_SET(call->pH245Channel->sock, &writefds);
- if(nfds < (int)call->pH245Channel->sock)
- nfds = call->pH245Channel->sock;
- }
- else if(call->h245listener)
- {
- OOTRACEINFO3("H.245 Listerner socket being monitored "
- "(%s, %s)\n", call->callType, call->callToken);
- FD_SET(*(call->h245listener), &readfds);
- if(nfds < (int)*(call->h245listener))
- nfds = *(call->h245listener);
- }
- call = call->next;
-
- }/* while(call) */
- }/*if(gH323ep.callList) */
-
+ ooSetFDSETs(&readfds, &writefds, &nfds);
if(!gMonitor)
{
@@ -573,7 +751,6 @@
break;
}
- if(nfds != 0) nfds = nfds+1;
if(nfds == 0)
#ifdef _WIN32
@@ -610,162 +787,12 @@
}
}
-
- if(gH323ep.gkClient)
- {
- ooTimerFireExpired(&gH323ep.gkClient->ctxt,
- &gH323ep.gkClient->timerList);
- if(ooTimerNextTimeout(&gH323ep.gkClient->timerList, &toNext))
- {
- if(ooCompareTimeouts(&toMin, &toNext)>0)
- {
- toMin.tv_sec = toNext.tv_sec;
- toMin.tv_usec = toNext.tv_usec;
- }
- }
- if(gH323ep.gkClient->state == GkClientFailed ||
- gH323ep.gkClient->state == GkClientGkErr)
- {
- if(ooGkClientHandleClientOrGkFailure(gH323ep.gkClient)!=OO_OK)
- {
- ooStopMonitorCalls();
- continue;
- }
- }
- }
-
-#ifdef _WIN32
- EnterCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_lock(&gCmdMutex);
-#endif
- /* If gatekeeper is present, then we should not be processing
- any call related command till we are registered with the gk.
- */
-#ifdef HAVE_PIPE
- if(FD_ISSET(gH323ep.cmdPipe[0], &readfds))
- {
- read(gH323ep.cmdPipe[0], buf, 1);
- }
-#endif
-
- ooProcStackCmds();
-
-#ifdef _WIN32
- LeaveCriticalSection(&gCmdMutex);
-#else
- pthread_mutex_unlock(&gCmdMutex);
-#endif
- /* Manage ready descriptors after select */
-
- if(0 != gH323ep.gkClient && 0 != gH323ep.gkClient->rasSocket)
- {
- if(FD_ISSET( gH323ep.gkClient->rasSocket, &readfds) )
- {
- ooGkClientReceive(gH323ep.gkClient);
- if(gH323ep.gkClient->state == GkClientFailed ||
- gH323ep.gkClient->state == GkClientGkErr)
- ooGkClientHandleClientOrGkFailure(gH323ep.gkClient);
- }
- }
-
- if(gH323ep.listener)
+ if(ooProcessFDSETsAndTimers(&readfds, &writefds, &toMin) != OO_OK)
{
- if(FD_ISSET(*(gH323ep.listener), &readfds))
- {
- OOTRACEDBGA1("New connection at H225 receiver\n");
- ooAcceptH225Connection();
- }
+ ooStopMonitorCalls();
+ continue;
}
-
-
- if(gH323ep.callList)
- {
- call = gH323ep.callList;
- while(call)
- {
- ooTimerFireExpired(call->pctxt, &call->timerList);
- if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
- {
- if(FD_ISSET(call->pH225Channel->sock, &readfds))
- {
- ret = ooH2250Receive(call);
- if(ret != OO_OK)
- {
- OOTRACEERR3("ERROR:Failed ooH2250Receive - Clearing call "
- "(%s, %s)\n", call->callType, call->callToken);
- if(call->callState < OO_CALL_CLEAR)
- {
- call->callEndReason = OO_REASON_INVALIDMESSAGE;
- call->callState = OO_CALL_CLEAR;
- }
- }
- }
- }
-
-
- if (0 != call->pH245Channel && 0 != call->pH245Channel->sock)
- {
- if(FD_ISSET(call->pH245Channel->sock, &readfds))
- {
- ooH245Receive(call);
- }
- }
-
- if (0 != call->pH245Channel && 0 != call->pH245Channel->sock)
- {
- if(FD_ISSET(call->pH245Channel->sock, &writefds))
- {
- if(call->pH245Channel->outQueue.count>0)
- ooSendMsg(call, OOH245MSG);
- }
- }
- else if(call->h245listener)
- {
- if(FD_ISSET(*(call->h245listener), &readfds))
- {
- OOTRACEDBGC3("Incoming H.245 connection (%s, %s)\n",
- call->callType, call->callToken);
- ooAcceptH245Connection(call);
- }
- }
-
- if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
- {
- if(FD_ISSET(call->pH225Channel->sock, &writefds))
- {
- if(call->pH225Channel->outQueue.count>0)
- {
- OOTRACEDBGC3("Sending H225 message (%s, %s)\n",
- call->callType, call->callToken);
- ooSendMsg(call, OOQ931MSG);
- }
- if(call->pH245Channel &&
- call->pH245Channel->outQueue.count>0 &&
- OO_TESTFLAG (call->flags, OO_M_TUNNELING))
- {
- OOTRACEDBGC3("H245 message needs to be tunneled. "
- "(%s, %s)\n", call->callType,
- call->callToken);
- ooSendMsg(call, OOH245MSG);
- }
- }
- }
- if(ooTimerNextTimeout(&call->timerList, &toNext))
- {
- if(ooCompareTimeouts(&toMin, &toNext) > 0)
- {
- toMin.tv_sec = toNext.tv_sec;
- toMin.tv_usec = toNext.tv_usec;
- }
- }
- prev = call;
- call = call->next;
- if(prev->callState >= OO_CALL_CLEAR)
- ooEndCall(prev);
- }/* while(call) */
- }/* if(gH323ep.callList) */
}/* while(1)*/
return OO_OK;
}
@@ -774,7 +801,7 @@
{
int recvLen=0, total=0, ret=0;
ASN1OCTET message[MAXMSGLEN], message1[MAXMSGLEN];
- int size =MAXMSGLEN, len;
+ int len;
Q931Message *pmsg;
OOCTXT *pctxt = &gH323ep.msgctxt;
struct timeval timeout;
@@ -918,8 +945,7 @@
{
int recvLen, ret, len, total=0;
ASN1OCTET message[MAXMSGLEN], message1[MAXMSGLEN];
- int size =MAXMSGLEN;
- ASN1BOOL aligned = TRUE, trace = FALSE;
+ ASN1BOOL aligned = TRUE;
H245Message *pmsg;
OOCTXT *pctxt = &gH323ep.msgctxt;
struct timeval timeout;
@@ -1072,7 +1098,6 @@
{
int len=0, ret=0, msgType=0, tunneledMsgType=0, logicalChannelNo = 0;
- int i =0;
DListNode * p_msgNode=NULL;
ASN1OCTET *msgptr, *msgToSend=NULL;
@@ -1672,6 +1697,10 @@
if(gMonitor)
{
OOTRACEINFO1("Doing ooStopMonitorCalls\n");
+ if(gH323ep.cmdSock)
+ {
+ ooCloseCmdConnection();
+ }
if(gH323ep.callList)
{
Index: ooh245.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh245.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ooh245.c 2 Sep 2005 18:27:51 -0000 1.10
+++ ooh245.c 26 Oct 2005 20:49:40 -0000 1.11
@@ -22,8 +22,10 @@
#include "ooTimer.h"
#ifdef _WIN32
#include <stdlib.h>
-#include <time.h>
+#include <process.h>
+#define getpid _getpid
#endif
+#include <time.h>
/** Global endpoint structure */
extern ooEndPoint gH323ep;
@@ -223,9 +225,9 @@
int ooSendH245Msg(OOH323CallData *call, H245Message *msg)
{
- int iRet=0, len=0, msgType=0, tunneledMsgType=0, logicalChannelNo = 0;
+ int iRet=0, len=0, msgType=0, logicalChannelNo = 0;
ASN1OCTET * encodebuf;
- ASN1OCTET *msgptr=NULL;
+
if(!call)
return OO_FAILED;
@@ -319,7 +321,6 @@
H245UserInputCapability *userInputCap = NULL;
H245CapabilityTableEntry *entry=NULL;
H245AlternativeCapabilitySet *altSet=NULL;
- DListNode * curNode=NULL;
H245CapabilityDescriptor *capDesc=NULL;
H245Message *ph245msg=NULL;
H245VideoCapability *videoCap=NULL;
@@ -658,9 +659,18 @@
ASN1UINT ooGenerateStatusDeterminationNumber()
{
ASN1UINT statusDeterminationNumber;
- ASN1UINT random_factor = (ASN1UINT)rand();
+ ASN1UINT random_factor = getpid();
+
+#ifdef _WIN32
+ SYSTEMTIME systemTime;
+ GetLocalTime(&systemTime);
+ srand((systemTime.wMilliseconds ^ systemTime.wSecond) + random_factor);
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ srand((tv.tv_usec ^ tv.tv_sec) + random_factor );
+#endif
- srand((unsigned)time( NULL )+random_factor );
statusDeterminationNumber = rand()%16777215;
return statusDeterminationNumber;
}
@@ -1676,7 +1686,7 @@
int ooCloseAllLogicalChannels(OOH323CallData *call)
{
ooLogicalChannel *temp;
- int outgoing=0;
+
temp = call->logicalChans;
while(temp)
{
@@ -2015,8 +2025,6 @@
H245CloseLogicalChannel* clc)
{
int ret=0;
- ooH323EpCapability *epCap=NULL;
- ooLogicalChannel *pLogicalChannel=NULL;
H245Message *ph245msg = NULL;
OOCTXT *pctxt = NULL;
H245CloseLogicalChannelAck * clcAck;
@@ -2076,7 +2084,7 @@
H245CloseLogicalChannelAck* clcAck)
{
int ret = OO_OK;
- return OO_OK;
+ return ret;
}
int ooHandleH245Message(OOH323CallData *call, H245Message * pmsg)
@@ -2399,7 +2407,6 @@
int ooOnReceivedTerminalCapabilitySet(OOH323CallData *call, H245Message *pmsg)
{
int ret = 0,k;
- OOCTXT *pctxt=NULL;
H245TerminalCapabilitySet *tcs=NULL;
DListNode *pNode=NULL;
H245CapabilityTableEntry *capEntry = NULL;
@@ -2816,7 +2823,7 @@
/* CapType indicates whether to Open Audio or Video channel */
int ooOpenLogicalChannel(OOH323CallData *call, enum OOCapType capType )
{
- ooH323EpCapability *epCap=NULL, *repCap=NULL;
+ ooH323EpCapability *epCap=NULL;
int k=0;
/* Check whether local endpoint has audio capability */
@@ -2919,7 +2926,6 @@
int ret;
H245Message *ph245msg = NULL;
H245RequestMessage * request;
- DListNode *curNode1 = NULL;
OOCTXT *pctxt = NULL;
H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp = NULL;
H245AudioCapability *audioCap = NULL;
@@ -3089,14 +3095,12 @@
{
OOBOOL reverse=FALSE, forward=FALSE;
unsigned sessionID=0;
- H245AudioCapability *audioCap=NULL;
- H245VideoCapability *videoCap = NULL;
H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp=NULL;
H245OpenLogicalChannel_reverseLogicalChannelParameters *rlcp=NULL;
H245H2250LogicalChannelParameters *pH2250lcp1=NULL, *pH2250lcp2=NULL;
H245UnicastAddress *pUnicastAddrs=NULL, *pUniAddrs=NULL;
H245UnicastAddress_iPAddress *pIpAddrs=NULL, *pUniIpAddrs=NULL;
-
+ unsigned session_id = 0;
ooLogicalChannel *pLogicalChannel = NULL;
int outgoing=FALSE;
@@ -3107,8 +3111,9 @@
{
OOTRACEDBGA3("Building OpenLogicalChannel for Receive Capability "
"(%s, %s)\n", call->callType, call->callToken);
+ session_id = ooCallGenerateSessionID(call, epCap->capType, "receive");
pLogicalChannel = ooAddNewLogicalChannel(call,
- olc->forwardLogicalChannelNumber, 1,
+ olc->forwardLogicalChannelNumber, session_id,
"receive", epCap);
if(outgoing)
reverse = TRUE;
@@ -3119,8 +3124,9 @@
{
OOTRACEDBGA3("Building OpenLogicalChannel for transmit Capability "
"(%s, %s)\n", call->callType, call->callToken);
+ session_id = ooCallGenerateSessionID(call, epCap->capType, "transmit");
pLogicalChannel = ooAddNewLogicalChannel(call,
- olc->forwardLogicalChannelNumber, 1,
+ olc->forwardLogicalChannelNumber, session_id,
"transmit", epCap);
if(outgoing)
forward = TRUE;
@@ -3398,7 +3404,7 @@
{
ooTimerCallback *cbData = (ooTimerCallback*)pdata;
OOH323CallData *call = cbData->call;
- ooLogicalChannel *pChannel = NULL;
+
OOTRACEINFO3("CloseLogicalChannelTimer expired. (%s, %s)\n", call->callType,
call->callToken);
@@ -3418,7 +3424,7 @@
int ret = 0;
ooTimerCallback *cbData = (ooTimerCallback*)pdata;
OOH323CallData *call = cbData->call;
- ooLogicalChannel *pChannel = NULL;
+
OOTRACEINFO3("OpenLogicalChannelTimer expired. (%s, %s)\n", call->callType,
call->callToken);
@@ -3513,15 +3519,16 @@
H245H2250LogicalChannelParameters *pH2250lcp1=NULL, *pH2250lcp2=NULL;
H245UnicastAddress *pUnicastAddrs=NULL, *pUniAddrs=NULL;
H245UnicastAddress_iPAddress *pIpAddrs=NULL, *pUniIpAddrs=NULL;
-
+ unsigned session_id = 0;
ooLogicalChannel *pLogicalChannel = NULL;
if(dir & OORX)
{
OOTRACEDBGA3("ooPrepareFastStartResponseOLC for Receive Capability "
"(%s, %s)\n", call->callType, call->callToken);
+ session_id = ooCallGenerateSessionID(call, epCap->capType, "receive");
pLogicalChannel = ooAddNewLogicalChannel(call,
- olc->forwardLogicalChannelNumber, 1,
+ olc->forwardLogicalChannelNumber, session_id,
"receive", epCap);
forward = TRUE;
}
@@ -3529,8 +3536,9 @@
{
OOTRACEDBGA3("ooPrepareFastStartResponseOLC for transmit Capability "
"(%s, %s)\n", call->callType, call->callToken);
+ session_id = ooCallGenerateSessionID(call, epCap->capType, "transmit");
pLogicalChannel = ooAddNewLogicalChannel(call,
- olc->forwardLogicalChannelNumber, 1,
+ olc->forwardLogicalChannelNumber, session_id,
"transmit", epCap);
reverse = TRUE;
}
Index: ooh323.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh323.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ooh323.c 2 Sep 2005 14:27:10 -0000 1.8
+++ ooh323.c 26 Oct 2005 20:49:40 -0000 1.9
@@ -134,8 +134,6 @@
H245OpenLogicalChannel* olc;
ASN1OCTET msgbuf[MAXMSGLEN];
H225TransportAddress_ipAddress_ip *ip = NULL;
- DListNode* pNode=NULL;
- H225AliasAddress *pAliasAddress=NULL;
Q931InformationElement* pDisplayIE=NULL;
OOAliases *pAlias=NULL;
@@ -270,22 +268,22 @@
/* Extract Remote IP address */
if(!setup->m.sourceCallSignalAddressPresent)
{
- OOTRACEERR3("ERROR:Missing source call signal address in received setup "
- "(%s, %s)\n", call->callType, call->callToken);
- return OO_FAILED;
- }
+ OOTRACEWARN3("WARNING:Missing source call signal address in received "
+ "setup (%s, %s)\n", call->callType, call->callToken);
+ }else{
- if(setup->sourceCallSignalAddress.t != T_H225TransportAddress_ipAddress)
- {
- OOTRACEERR3("ERROR: Source call signalling address type not ip (%s, %s)"
- "\n", call->callType, call->callToken);
- return OO_FAILED;
- }
+ if(setup->sourceCallSignalAddress.t != T_H225TransportAddress_ipAddress)
+ {
+ OOTRACEERR3("ERROR: Source call signalling address type not ip "
+ "(%s, %s)\n", call->callType, call->callToken);
+ return OO_FAILED;
+ }
- ip = &setup->sourceCallSignalAddress.u.ipAddress->ip;
- sprintf(call->remoteIP, "%d.%d.%d.%d", ip->data[0], ip->data[1],
- ip->data[2], ip->data[3]);
- call->remotePort = setup->sourceCallSignalAddress.u.ipAddress->port;
+ ip = &setup->sourceCallSignalAddress.u.ipAddress->ip;
+ sprintf(call->remoteIP, "%d.%d.%d.%d", ip->data[0], ip->data[1],
+ ip->data[2], ip->data[3]);
+ call->remotePort = setup->sourceCallSignalAddress.u.ipAddress->port;
+ }
/* check for fast start */
@@ -451,7 +449,8 @@
pChannel = ooFindLogicalChannelByOLC(call, olc);
if(!pChannel)
{
- OOTRACEERR4("ERROR: Logical Channel %d not found. (%s, %s)\n",
+ OOTRACEERR4("ERROR: Logical Channel %d not found, fast start. "
+ "(%s, %s)\n",
olc->forwardLogicalChannelNumber, call->callType,
call->callToken);
return OO_FAILED;
@@ -640,7 +639,8 @@
pChannel = ooFindLogicalChannelByOLC(call, olc);
if(!pChannel)
{
- OOTRACEERR4("ERROR: Logical Channel %d not found. (%s, %s)\n",
+ OOTRACEERR4("ERROR: Logical Channel %d not found, fast start. "
+ "(%s, %s)\n",
olc->forwardLogicalChannelNumber, call->callType,
call->callToken);
return OO_FAILED;
@@ -820,6 +820,8 @@
call->callEndReason = OO_REASON_LOCAL_CLEARED;
call->callState = OO_CALL_CLEAR;
}
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
memset(olc, 0, sizeof(H245OpenLogicalChannel));
@@ -838,6 +840,8 @@
call->callEndReason = OO_REASON_INVALIDMESSAGE;
call->callState = OO_CALL_CLEAR;
}
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
@@ -846,9 +850,12 @@
pChannel = ooFindLogicalChannelByOLC(call, olc);
if(!pChannel)
{
- OOTRACEERR4("ERROR: Logical Channel %d not found. (%s, %s)\n",
+ OOTRACEERR4("ERROR: Logical Channel %d not found, fasts start "
+ "answered. (%s, %s)\n",
olc->forwardLogicalChannelNumber, call->callType,
call->callToken);
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
if(pChannel->channelNo != olc->forwardLogicalChannelNumber)
@@ -877,6 +884,8 @@
OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
"forward Logical Channel Parameters found. (%s, %s)"
"\n", call->callType, call->callToken);
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
if(!h2250lcp->m.mediaChannelPresent)
@@ -884,6 +893,8 @@
OOTRACEERR3("ERROR:Invalid OLC received in fast start. No "
"reverse media channel information found. (%s, %s)"
"\n", call->callType, call->callToken);
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
@@ -894,12 +905,16 @@
{
OOTRACEERR3("ERROR:Unsupported media channel address type "
"(%s, %s)\n", call->callType, call->callToken);
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
if(!pChannel->chanCap->startTransmitChannel)
{
OOTRACEERR3("ERROR:No callback registered to start transmit "
"channel (%s, %s)\n",call->callType, call->callToken);
+ finishPrint();
+ removeEventHandler(call->pctxt);
return OO_FAILED;
}
pChannel->chanCap->startTransmitChannel(call, pChannel);
@@ -1161,7 +1176,7 @@
{
H225H323_UU_PDU * pH323UUPdu = NULL;
H225Facility_UUIE * facility = NULL;
- int i=0, ret;
+ int ret;
H225TransportAddress_ipAddress_ip *ip = NULL;
OOTRACEDBGC3("Received Facility Message.(%s, %s)\n", call->callType,
call->callToken);
@@ -1696,8 +1711,7 @@
OOAliases* ooH323AddAliasToList
(OOAliases **pAliasList, OOCTXT *pctxt, H225AliasAddress *pAliasAddress)
{
- int i=0,j=0,k=0;
- DListNode* pNode=NULL;
+ int j=0,k=0;
OOAliases *newAlias=NULL;
H225TransportAddress *pTransportAddrss=NULL;
Index: ooh323ep.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh323ep.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ooh323ep.c 16 Sep 2005 19:29:17 -0000 1.6
+++ ooh323ep.c 26 Oct 2005 20:49:40 -0000 1.7
@@ -18,29 +18,14 @@
#include "ooCalls.h"
#include "ooCapability.h"
#include "ooGkClient.h"
-
+#include "ooStackCmds.h"
+#include "ooCmdChannel.h"
/** Global endpoint structure */
ooEndPoint gH323ep;
-/**
- * Mutex to protect ooGenerateCallReference function.
- * This is required as this function will be called by
- * multiple threads trying to place calls using stack commands
- */
-OO_MUTEX gCallRefMutex;
-
-/**
- * Mutex to protect access to global call token variables.
- * This is required as these variables will be used by
- * multiple threads trying to place calls using stack commands
- */
-OO_MUTEX gCallTokenMutex;
-
-/**
- * Mutex to protect access to stack commands list
- */
-OO_MUTEX gCmdMutex;
+extern int gCmdPort;
+extern char gCmdIP[20];
extern DList g_TimerList;
int ooH323EpInitialize
@@ -124,15 +109,7 @@
gH323ep.callingPartyNumber[0]='\0';
gH323ep.callMode = callMode;
gH323ep.isGateway = FALSE;
-#ifdef _WIN32
- InitializeCriticalSection(&gCmdMutex);
- InitializeCriticalSection(&gCallTokenMutex);
- InitializeCriticalSection(&gCallRefMutex);
-#else
- pthread_mutex_init(&gCmdMutex, 0);
- pthread_mutex_init(&gCallTokenMutex, 0);
- pthread_mutex_init(&gCallRefMutex, 0);
-#endif
+
dListInit(&g_TimerList);/* This is for test application chansetup only*/
gH323ep.callEstablishmentTimeout = DEFAULT_CALLESTB_TIMEOUT;
@@ -145,14 +122,13 @@
gH323ep.sessionTimeout = DEFAULT_ENDSESSION_TIMEOUT;
gH323ep.ifList = NULL;
-#ifdef HAVE_PIPE
- if(pipe(gH323ep.cmdPipe)<0){
- OOTRACEERR1("Error:Failed to create command pipe\n");
- return OO_FAILED;
- }
-#endif
+
ooSetTraceThreshold(OOTRCLVLINFO);
OO_SETFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED);
+
+ gH323ep.cmdListener = 0;
+ gH323ep.cmdSock = 0;
+ gH323ep.cmdPort = OO_DEFAULT_CMDLISTENER_PORT;
return OO_OK;
}
@@ -162,12 +138,13 @@
return OO_OK;
}
-int ooH323EpSetLocalAddress(char * localip, int listenport)
+
+int ooH323EpSetLocalAddress(const char* localip, int listenport)
{
if(localip)
{
- memset(gH323ep.signallingIP, 0, sizeof(gH323ep.signallingIP));
strcpy(gH323ep.signallingIP, localip);
+ strcpy(gCmdIP, localip);
OOTRACEINFO2("Signalling IP address is set to %s\n", localip);
}
@@ -179,7 +156,20 @@
return OO_OK;
}
-int ooH323EpAddAliasH323ID(char *h323id)
+int ooH323EpCreateCmdListener(int cmdPort)
+{
+ if(cmdPort != 0)
+ {
+ gH323ep.cmdPort = cmdPort;
+ gCmdPort = cmdPort;
+ }
+ if(ooCreateCmdListener() != OO_OK)
+ return OO_FAILED;
+
+ return OO_OK;
+}
+
+int ooH323EpAddAliasH323ID(const char *h323id)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
@@ -205,13 +195,14 @@
return OO_OK;
}
-int ooH323EpAddAliasDialedDigits(char * dialedDigits)
+int ooH323EpAddAliasDialedDigits(const char* dialedDigits)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
- OOTRACEERR1("Error: Failed to allocate memory for new DialedDigits alias\n");
+ OOTRACEERR1("Error: Failed to allocate memory for new DialedDigits "
+ "alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_dialedDigits;
@@ -219,7 +210,8 @@
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(dialedDigits)+1);
if(!psNewAlias->value)
{
- OOTRACEERR1("Error: Failed to allocate memory for the new DialedDigits alias value\n");
+ OOTRACEERR1("Error: Failed to allocate memory for the new DialedDigits"
+ " alias value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
@@ -230,7 +222,7 @@
return OO_OK;
}
-int ooH323EpAddAliasURLID(char * url)
+int ooH323EpAddAliasURLID(const char * url)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
@@ -244,7 +236,8 @@
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(url)+1);
if(!psNewAlias->value)
{
- OOTRACEERR1("Error: Failed to allocate memory for the new URL-ID alias value\n");
+ OOTRACEERR1("Error: Failed to allocate memory for the new URL-ID alias"
+ " value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
@@ -255,7 +248,7 @@
return OO_OK;
}
-int ooH323EpAddAliasEmailID(char * email)
+int ooH323EpAddAliasEmailID(const char * email)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
@@ -281,13 +274,14 @@
return OO_OK;
}
-int ooH323EpAddAliasTransportID(char * ipaddress)
+int ooH323EpAddAliasTransportID(const char * ipaddress)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
- OOTRACEERR1("Error: Failed to allocate memory for new Transport-ID alias\n");
+ OOTRACEERR1("Error: Failed to allocate memory for new Transport-ID "
+ "alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_transportID;
@@ -309,9 +303,16 @@
int ooH323EpClearAllAliases(void)
{
+ ooAliases *pAlias = NULL, *pTemp;
if(gH323ep.aliases)
{
- memFreePtr(&gH323ep.ctxt, gH323ep.aliases);
+ pAlias = gH323ep.aliases;
+ while(pAlias)
+ {
+ pTemp = pAlias;
+ pAlias = pAlias->next;
+ memFreePtr(&gH323ep.ctxt, pTemp);
+ }
gH323ep.aliases = NULL;
}
return OO_OK;
@@ -381,11 +382,6 @@
freeContext(&(gH323ep.ctxt));
-#ifdef _WIN32
- DeleteCriticalSection(&gCmdMutex);
- DeleteCriticalSection(&gCallTokenMutex);
- DeleteCriticalSection(&gCallRefMutex);
-#endif
OO_CLRFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED);
}
return OO_OK;
@@ -415,6 +411,19 @@
return OO_OK;
}
+int ooH323EpEnableManualRingback(void)
+{
+ OO_SETFLAG(gH323ep.flags, OO_M_MANUALRINGBACK);
+ return OO_OK;
+}
+
+
+int ooH323EpDisableManualRingback(void)
+{
+ OO_CLRFLAG(gH323ep.flags, OO_M_MANUALRINGBACK);
+ return OO_OK;
+}
+
int ooH323EpEnableFastStart(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART);
Index: ooh323ep.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh323ep.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ooh323ep.h 16 Sep 2005 19:29:17 -0000 1.7
+++ ooh323ep.h 26 Oct 2005 20:49:40 -0000 1.8
@@ -66,6 +66,7 @@
#define RTPPORTSEND 14230 /*!< Ending RTP port number */
+
/**
* This structure is used to define the port ranges to be used
@@ -82,6 +83,7 @@
* endpoint created by an application
*/
typedef struct OOH323EndPoint {
+
/**
* This context should be used for allocation of memory for
* items within the endpoint structure.
@@ -142,9 +144,12 @@
ASN1UINT sessionTimeout;
int cmdPipe[2];
struct ooGkClient *gkClient;
- DList stkCmdList; /* stack command list */
+
OOInterface *ifList; /* interface list for the host we are running on*/
OOBOOL isGateway;
+ OOSOCKET cmdListener;
+ OOSOCKET cmdSock;
+ int cmdPort; /* default 7575 */
} OOH323EndPoint;
#define ooEndPoint OOH323EndPoint
@@ -162,6 +167,18 @@
(enum OOCallMode callMode, const char* tracefile);
+
+/**
+ * This function is used to create a command listener for the endpoint.
+ * Before any command is issued to the endpoint, command listener must be
+ * created.
+ * @param cmdPort Port number on which command listener waits for
+ * incoming requests.
+ *
+ * @return OO_OK, on success; OO_FAILED, on failure
+ */
+EXTERN int ooH323EpCreateCmdListener(int cmdPort);
+
/**
* This function is used to represent the H.323 application endpoint as
* gateway, instead of an H.323 phone endpoint.
@@ -178,7 +195,7 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-EXTERN int ooH323EpSetLocalAddress(char * localip, int listenport);
+EXTERN int ooH323EpSetLocalAddress(const char* localip, int listenport);
/**
* This function is used to set the range of tcp ports the application will
@@ -224,7 +241,7 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-EXTERN int ooH323EpAddAliasH323ID(char * h323id);
+EXTERN int ooH323EpAddAliasH323ID(const char* h323id);
/**
* This function is used to add the dialed digits alias for the
@@ -233,7 +250,7 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-EXTERN int ooH323EpAddAliasDialedDigits(char * dialedDigits);
+EXTERN int ooH323EpAddAliasDialedDigits(const char* dialedDigits);
/**
* This function is used to add the url alias for the endpoint.
@@ -241,7 +258,7 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-EXTERN int ooH323EpAddAliasURLID(char * url);
+EXTERN int ooH323EpAddAliasURLID(const char* url);
/**
* This function is used to add an email id as an alias for the endpoint.
@@ -249,7 +266,7 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-EXTERN int ooH323EpAddAliasEmailID(char * email);
+EXTERN int ooH323EpAddAliasEmailID(const char* email);
/**
* This function is used to add an ip address as an alias.
@@ -257,7 +274,7 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-EXTERN int ooH323EpAddAliasTransportID(char * ipaddress);
+EXTERN int ooH323EpAddAliasTransportID(const char* ipaddress);
/**
* This function is used to clear all the aliases used by the
@@ -315,6 +332,25 @@
EXTERN int ooH323EpDisableAutoAnswer(void);
/**
+ * This function is used to enable manual ringback. By default the stack sends
+ * alerting message automatically on behalf of the endpoint application.
+ * However, if endpoint application wants to do alerting user part first before
+ * sending out alerting message, it can enable this feature.
+ *
+ * @return OO_OK on success, OO_FAILED on failure
+ */
+EXTERN int ooH323EpEnableManualRingback(void);
+
+/**
+ * This function is used to disable manual ringback. By default the
+ * manual ringback feature is disabled, i.e, the stack sends alerting on behalf
+ * of the application automatically.
+ *
+ * @return OO_OK on success, OO_FAILED on failure
+ */
+EXTERN int ooH323EpDisableManualRingback(void);
+
+/**
* This function is used to enable faststart.
*
* @return OO_OK, on success. OO_FAILED, on failure.
Index: ooq931.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooq931.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- ooq931.c 16 Sep 2005 19:29:17 -0000 1.16
+++ ooq931.c 26 Oct 2005 20:49:40 -0000 1.17
@@ -27,13 +27,11 @@
#include "ooGkClient.h"
#include "ooUtils.h"
#include <time.h>
-
+#include <ctype.h>
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
-extern OO_MUTEX gCallRefMutex;
-extern OO_MUTEX gCallTokenMutex;
static ASN1OBJID gProtocolID = {
6, { 0, 0, 8, 2250, 0, 4 }
@@ -42,7 +40,7 @@
EXTERN int ooQ931Decode
(OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data)
{
- int offset, x;
+ int offset, x, i;
int rv = ASN_OK;
char number[128];
OOCTXT *pctxt = &gH323ep.msgctxt;
@@ -156,7 +154,10 @@
if(ie->discriminator == Q931DisplayIE)
{
OOTRACEDBGB1(" Display IE = {\n");
- OOTRACEDBGB2(" %s\n", ie->data);
+ OOTRACEDBGB1(" ");
+ for(i=0; i<ie->length; i++)
+ OOTRACEDBGB2("%c", ie->data[i]);
+ OOTRACEDBGB1("\n");
OOTRACEDBGB1(" }\n");
}
@@ -396,28 +397,18 @@
char aCallToken[200];
int ret = 0;
-#ifdef _WIN32
- EnterCriticalSection (&gCallTokenMutex);
-#else
- pthread_mutex_lock (&gCallTokenMutex);
-#endif
-
sprintf (aCallToken, "ooh323c_%d", counter++);
if (counter > OO_MAX_CALL_TOKEN)
counter = 1;
- if (strlen (aCallToken) < size)
+ if ((strlen(aCallToken)+1) < size)
strcpy (callToken, aCallToken);
else {
OOTRACEERR1 ("Error: Insufficient buffer size to generate call token");
ret = OO_FAILED;
}
-#ifdef _WIN32
- LeaveCriticalSection(&gCallTokenMutex);
-#else
- pthread_mutex_unlock(&gCallTokenMutex);
-#endif
+
return ret;
}
@@ -431,12 +422,8 @@
{
static ASN1USINT lastCallRef=0;
ASN1USINT newCallRef=0;
-#ifdef _WIN32
- EnterCriticalSection(&gCallRefMutex);
-#else
- pthread_mutex_lock(&gCallRefMutex);
-#endif
-
+
+
if(lastCallRef == 0)
{
/* Generate a new random callRef */
@@ -453,11 +440,8 @@
lastCallRef=1;
newCallRef = lastCallRef;
-#ifdef _WIN32
- LeaveCriticalSection(&gCallRefMutex);
-#else
- pthread_mutex_unlock(&gCallRefMutex);
-#endif
+
+
OOTRACEDBGC2("Generated callRef %d\n", newCallRef);
return newCallRef;
}
@@ -509,7 +493,7 @@
ASN1OCTET msgbuf[1024];
ASN1OCTET * msgptr=NULL;
int len;
- ASN1BOOL aligned = TRUE, trace = FALSE;
+ ASN1BOOL aligned = TRUE;
Q931InformationElement* ie=NULL;
OOCTXT *pctxt = &gH323ep.msgctxt;
/* memset(msgbuf, 0, sizeof(msgbuf));*/
@@ -567,7 +551,7 @@
{
DListNode* curNode;
unsigned int i;
- ASN1BOOL aligned=TRUE, trace=FALSE;
+ ASN1BOOL aligned=TRUE;
int stat;
Q931InformationElement *ie;
OOCTXT *pctxt = &gH323ep.msgctxt;
@@ -646,10 +630,10 @@
int ooEncodeH225Message(OOH323CallData *call, Q931Message *pq931Msg,
char *msgbuf, int size)
{
- int len=0, encodeLen=0, i=0, j=0, ieLen=0;
+ int len=0, i=0, j=0, ieLen=0;
int stat=0;
- ASN1OCTET* encodeptr=NULL;
DListNode* curNode=NULL;
+
if(!msgbuf || size<200)
{
OOTRACEERR3("Error: Invalid message buffer/size for ooEncodeH245Message."
@@ -1128,7 +1112,6 @@
int ooSendReleaseComplete(OOH323CallData *call)
{
int ret;
- Q931InformationElement* ie=NULL;
Q931Message *q931msg=NULL;
H225ReleaseComplete_UUIE *releaseComplete;
enum Q931CauseValues cause = Q931ErrorInCauseIE;
@@ -1808,7 +1791,7 @@
}
- ret = ooParseDestination(call->pctxt, dest, tmp, 30, &call->remoteAliases);
+ ret = ooParseDestination(call, dest, tmp, 30, &call->remoteAliases);
if(ret != OO_OK)
{
OOTRACEERR2("Error: Failed to parse the destination string %s for "
@@ -1880,9 +1863,15 @@
} else { /* An incoming call */
if(gH323ep.h323Callbacks.onIncomingCall)
gH323ep.h323Callbacks.onIncomingCall(call);
- ooSendAlerting(call); /* Send alerting message */
- if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER))
- ooSendConnect(call); /* Send connect message - call accepted */
+
+ /* 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 */
+ }
}
return OO_OK;
@@ -1899,11 +1888,9 @@
H225TransportAddress_ipAddress *srcCallSignalIpAddress;
ooH323EpCapability *epCap=NULL;
- DListNode *curNode = NULL;
OOCTXT *pctxt = NULL;
H245OpenLogicalChannel *olc, printOlc;
ASN1BOOL aligned = 1;
- H225AliasAddress * pAliasAddress=NULL;
ooAliases *pAlias = NULL;
pctxt = &gH323ep.msgctxt;
@@ -2435,7 +2422,6 @@
OOCTXT *pctxt = &gH323ep.msgctxt;
OOH323CallData *call;
char ip[30]="\0", *pcPort=NULL;
- int port=0;
H225TransportAddress_ipAddress *fwdCallSignalIpAddress;
call= ooFindCallByToken(callToken);
@@ -2455,7 +2441,7 @@
return OO_FAILED;
}
- ret = ooParseDestination(call->pctxt, dest, ip, 20,
+ ret = ooParseDestination(call, dest, ip, 20,
&call->pCallFwdData->aliases);
if(ret != OO_OK)
{
@@ -2576,7 +2562,6 @@
int ooH323HangCall(char * callToken, OOCallClearReason reason)
{
- int ret =0;
OOH323CallData *call;
call= ooFindCallByToken(callToken);
@@ -2739,187 +2724,12 @@
return OO_OK;
}
-#if 0
-/*TODO: Once we are comfortable with new parse function, get rid of this one */
-int ooParseDestination(OOH323CallData *call, char *dest)
-{
- int ret=0, iEk=-1, iDon=-1, iTeen=-1, iChaar=-1, iPort = -1, i;
- ooAliases * psNewAlias = NULL;
- char *cAt = NULL, *host=NULL;
- char tmp[256];
- char *alias=NULL;
- OOTRACEINFO2("Parsing destination %s\n", dest);
-
- /* Test for an IP address:Note that only supports dotted IPv4.
- IPv6 won't pass the test and so will numeric IP representation*/
-
- 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))
- {
- /* memset(call->remoteIP, 0, sizeof(call->remoteIP));*/
- sprintf(call->remoteIP, "%d.%d.%d.%d", iEk, iDon, iTeen, iChaar);
- if(strchr(dest, ':'))
- call->remotePort = iPort;
- else
- call->remotePort = 1720; /*Default h.323 port */
- OOTRACEINFO3("Destination for new call parsed as Ip %s and port %d\n",
- call->remoteIP, call->remotePort);
- return OO_OK;
- }
-
- /* alias at host */
- strncpy(tmp, dest, sizeof(tmp)-1);
- tmp[sizeof(tmp)-1]='\0';
- if(host=strchr(tmp, '@'))
- {
- *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))
- {
-
- sprintf(call->remoteIP, "%d.%d.%d.%d", iEk, iDon, iTeen, iChaar);
- if(strchr(dest, ':'))
- call->remotePort = iPort;
- else
- call->remotePort = 1720; /*Default h.323 port */
- OOTRACEINFO3("Destination for new call parsed as Ip %s and port %d\n",
- call->remoteIP, call->remotePort);
- alias = tmp;
- }
- }
-
- if(!alias)
- {
- alias = dest;
- }
- /* url test */
- if(alias == strstr(alias, "http://"))
- {
- psNewAlias = (ooAliases*) memAlloc(call->pctxt, sizeof(ooAliases));
- if(!psNewAlias)
- {
- OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
- return OO_FAILED;
- }
- /* memset(psNewAlias, 0, sizeof(ooAliases));*/
- psNewAlias->type = T_H225AliasAddress_url_ID;
- psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(alias)+1);
- if(!psNewAlias->value)
- {
- OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias->value\n");
- memFreePtr(call->pctxt, psNewAlias);
- return OO_FAILED;
- }
- strcpy(psNewAlias->value, alias);
- psNewAlias->next = call->remoteAliases;
- call->remoteAliases = psNewAlias;
- OOTRACEINFO2("Destination for new call 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(call->pctxt, sizeof(ooAliases));
- if(!psNewAlias)
- {
- OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
- return OO_FAILED;
- }
- /* memset(psNewAlias, 0, sizeof(ooAliases));*/
- psNewAlias->type = T_H225AliasAddress_email_ID;
- psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(alias)+1);
- if(!psNewAlias->value)
- {
- OOTRACEERR1("Error:Memory - ooParseDestination - "
- "psNewAlias->value\n");
- memFreePtr(call->pctxt, psNewAlias);
- return OO_FAILED;
- }
- strcpy(psNewAlias->value, alias);
- psNewAlias->next = call->remoteAliases;
- call->remoteAliases = psNewAlias;
- OOTRACEINFO2("Destination for new call is parsed as email %s\n",
- psNewAlias->value);
- return OO_OK;
- }
- }
-
-
- /* e-164 */
- /* strspn(dest, "1234567890*#") == strlen(dest)*/
- /* Dialed digits test*/
- for(i=0; *(alias+i) != '\0'; i++)
- {
- if(!isdigit(alias[i]))
- break;
- }
- if(*(alias+i) == '\0')
- {
- psNewAlias = (ooAliases*) memAlloc(call->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(call->pctxt, strlen(alias)+1);
- if(!psNewAlias->value)
- {
- OOTRACEERR1("Error:Memroy - ooParseDestination - psNewAlias->value\n");
- memFreePtr(call->pctxt, psNewAlias);
- return OO_FAILED;
- }
- strcpy(psNewAlias->value, alias);
- psNewAlias->next = call->remoteAliases;
- call->remoteAliases = psNewAlias;
- OOTRACEINFO2("Destination for new call is parsed as dialed digits %s\n",
- psNewAlias->value);
- return OO_OK;
- }
- /* Evrything else is an h323-id for now */
- psNewAlias = (ooAliases*) memAlloc(call->pctxt, sizeof(ooAliases));
- if(!psNewAlias)
- {
- OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n");
- return OO_FAILED;
- }
- /* memset(psNewAlias, 0, sizeof(ooAliases));*/
- psNewAlias->type = T_H225AliasAddress_h323_ID;
- psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(alias)+1);
- if(!psNewAlias->value)
- {
- OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias->value\n");
- memFreePtr(call->pctxt, psNewAlias);
- return OO_FAILED;
- }
- strcpy(psNewAlias->value, alias);
- psNewAlias->next = call->remoteAliases;
- call->remoteAliases = psNewAlias;
- OOTRACEINFO2("Destination for new call is parsed as h323-id %s\n",
- psNewAlias->value);
- return OO_OK;
-}
-#endif
/* Build a Facility message and tunnel H.245 message through it */
-int ooSendAsTunneledMessage(OOH323CallData *call, ASN1OCTET* msgbuf, int h245Len,
- int h245MsgType, int associatedChan)
+int ooSendAsTunneledMessage(OOH323CallData *call, ASN1OCTET* msgbuf,
+ int h245Len, int h245MsgType, int associatedChan)
{
- DListNode *pNode = NULL;
Q931Message *pQ931Msg = NULL;
H225H323_UU_PDU *pH323UUPDU = NULL;
H225H323_UU_PDU_h245Control *pH245Control = NULL;
@@ -3220,14 +3030,16 @@
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(OOCTXT *pctxt, char *dest, char* parsedIP, unsigned len,
- ooAliases** aliasList)
+int ooParseDestination
+ (struct OOH323CallData *call, char *dest, char* parsedIP, unsigned len,
+ ooAliases** aliasList)
{
- int ret=0, iEk=-1, iDon=-1, iTeen=-1, iChaar=-1, iPort = -1, i;
+ 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;
parsedIP[0] = '\0';
OOTRACEINFO2("Parsing destination %s\n", dest);
@@ -3260,7 +3072,7 @@
/* alias at host */
strncpy(tmp, dest, sizeof(tmp)-1);
tmp[sizeof(tmp)-1]='\0';
- if(host=strchr(tmp, '@'))
+ if((host=strchr(tmp, '@')) != NULL)
{
*host = '\0';
host++;
@@ -3368,7 +3180,8 @@
psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1);
if(!psNewAlias->value)
{
- OOTRACEERR1("Error:Memroy - ooParseDestination - psNewAlias->value\n");
+ OOTRACEERR1("Error:Memroy - ooParseDestination - "
+ "psNewAlias->value\n");
memFreePtr(pctxt, psNewAlias);
return OO_FAILED;
}
@@ -3377,6 +3190,15 @@
*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 */
@@ -3401,3 +3223,102 @@
psNewAlias->value);
return OO_OK;
}
+
+const char* ooGetMsgTypeText (int msgType)
+{
+ static const char *msgTypeText[]={
+ "OOQ931MSG",
+ "OOH245MSG",
+ "OOSetup",
+ "OOCallProceeding",
+ "OOAlert",
+ "OOConnect",
+ "OOReleaseComplete",
+ "OOFacility",
+ "OOMasterSlaveDetermination",
+ "OOMasterSlaveAck",
+ "OOMasterSlaveReject",
+ "OOMasterSlaveRelease",
+ "OOTerminalCapabilitySet",
+ "OOTerminalCapabilitySetAck",
+ "OOTerminalCapabilitySetReject",
+ "OOTerminalCapabilitySetRelease",
+ "OOOpenLogicalChannel",
+ "OOOpenLogicalChannelAck",
+ "OOOpenLogicalChannelReject",
+ "OOOpenLogicalChannelRelease",
+ "OOOpenLogicalChannelConfirm",
+ "OOCloseLogicalChannel",
+ "OOCloseLogicalChannelAck",
+ "OORequestChannelClose",
+ "OORequestChannelCloseAck",
+ "OORequestChannelCloseReject",
+ "OORequestChannelCloseRelease",
+ "OOEndSessionCommand"
+ };
+ int idx = msgType - OO_MSGTYPE_MIN;
+ return ooUtilsGetText (idx, msgTypeText, OONUMBEROF(msgTypeText));
+}
+
+const char* ooGetQ931CauseValueText(int val)
+{
+ switch(val)
+ {
+ case Q931UnallocatedNumber:
+ return "Q931UnallocatedNumber";
+ case Q931NoRouteToNetwork:
+ return "Q931NoRouteToNetwork";
+ case Q931NoRouteToDestination:
+ return "Q931NoRouteToDestination";
+ case Q931ChannelUnacceptable:
+ 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";
+}
+
Index: ooq931.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooq931.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ooq931.h 16 Sep 2005 19:29:17 -0000 1.7
+++ ooq931.h 26 Oct 2005 20:49:40 -0000 1.8
@@ -571,7 +571,7 @@
/**
* This function is used to parse the destination
- * @param pctxt Handle to context to be used for memory allocation
+ * @param call Handle to related call.
* @param dest Destination string to be parsed.
* @param parsedIP Pointer to buffer in which parsed ip:port will be returned.
* @param len Length of the buffer passed.
@@ -579,8 +579,9 @@
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
-int ooParseDestination(OOCTXT* pctxt, char *dest, char *parsedIP, unsigned len,
- OOAliases** aliasList);
+int ooParseDestination
+ (struct OOH323CallData *call, char *dest, char *parsedIP, unsigned len,
+ OOAliases** aliasList);
/**
* This function is used to generate a new call token
@@ -737,6 +738,24 @@
*/
EXTERN OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode
(enum Q931CauseValues cause, unsigned reasonCode);
+
+/**
+ * This function is used to retrieve the description text for a
+ * message type.
+ *
+ * @param msgType Message type.
+ * @return The text description string.
+ */
+EXTERN const char* ooGetMsgTypeText (int msgType);
+
+/**
+ * This function is used to retrieve the text description for a Q931 Cause
+ * value in Cause IE.
+ * @param val Q931 Cause value
+ * @return The text description string
+ */
+EXTERN const char* ooGetQ931CauseValueText (int val);
+
/**
* @}
*/
Index: ootrace.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ootrace.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ootrace.c 16 Sep 2005 19:29:17 -0000 1.5
+++ ootrace.c 26 Oct 2005 20:49:40 -0000 1.6
@@ -17,6 +17,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
+#include <time.h>
#include "ootypes.h"
#include "ootrace.h"
@@ -31,213 +32,6 @@
static OOUINT32 gs_traceLevel = TRACELVL;
-#define OONUMBEROF(items) (sizeof(items)/sizeof(items[0]))
-
-/**
- * Reasons for ending call
- */
-static const char* reasonCodeText[] = {
- "OO_REASON_UNKNOWN",
- "OO_REASON_INVALIDMESSAGE",
- "OO_REASON_TRANSPORTFAILURE",
- "OO_REASON_NOROUTE",
- "OO_REASON_NOUSER",
- "OO_REASON_NOBW",
- "OO_REASON_GK_NOCALLEDUSER",
- "OO_REASON_GK_NOCALLERUSER",
- "OO_REASON_GK_NORESOURCES",
- "OO_REASON_GK_UNREACHABLE",
- "OO_REASON_GK_CLEARED",
- "OO_REASON_NOCOMMON_CAPABILITIES",
- "OO_REASON_REMOTE_FWDED",
- "OO_REASON_LOCAL_FWDED",
- "OO_REASON_REMOTE_CLEARED",
- "OO_REASON_LOCAL_CLEARED",
- "OO_REASON_REMOTE_BUSY",
- "OO_REASON_LOCAL_BUSY",
- "OO_REASON_REMOTE_NOANSWER",
- "OO_REASON_LOCAL_NOTANSWERED",
- "OO_REASON_REMOTE_REJECTED",
- "OO_REASON_LOCAL_REJECTED",
- "OO_REASON_REMOTE_CONGESTED",
- "OO_REASON_LOCAL_CONGESTED"
-};
-
-static const char* callStateText[] = {
- "OO_CALL_CREATED",
- "OO_CALL_WAITING_ADMISSION",
- "OO_CALL_CONNECTING",
- "OO_CALL_CONNECTED",
- "OO_CALL_CLEAR",
- "OO_CALL_CLEAR_RELEASERECVD",
- "OO_CALL_CLEAR_RELEASESENT",
- "OO_CALL_CLEARED"
-};
-
-static const char *msgTypeText[]={
- "OOQ931MSG",
- "OOH245MSG",
- "OOSetup",
- "OOCallProceeding",
- "OOAlert",
- "OOConnect",
- "OOReleaseComplete",
- "OOFacility",
- "OOMasterSlaveDetermination",
- "OOMasterSlaveAck",
- "OOMasterSlaveReject",
- "OOMasterSlaveRelease",
- "OOTerminalCapabilitySet",
- "OOTerminalCapabilitySetAck",
- "OOTerminalCapabilitySetReject",
- "OOTerminalCapabilitySetRelease",
- "OOOpenLogicalChannel",
- "OOOpenLogicalChannelAck",
- "OOOpenLogicalChannelReject",
- "OOOpenLogicalChannelRelease",
- "OOOpenLogicalChannelConfirm",
- "OOCloseLogicalChannel",
- "OOCloseLogicalChannelAck",
- "OORequestChannelClose",
- "OORequestChannelCloseAck",
- "OORequestChannelCloseReject",
- "OORequestChannelCloseRelease",
- "OOEndSessionCommand"
-};
-
-static const char *capTypes[]={
- "unknown",
- "OO_NONSTANDARD",
- "OO_G711ALAW64K",
- "OO_G711ALAW56K",
- "OO_G711ULAW64K",
- "OO_G711ULAW56K",
- "OO_G72264K",
- "OO_G72256K",
- "OO_G72248K",
- "OO_G7231",
- "OO_G728",
- "OO_G729",
- "OO_G729ANNEXA",
- "OO_IS11172AUDIO",
- "OO_IS13818AUDIO",
- "OO_G729WANNEXB",
- "OO_G729ANNEXAWANNEXB",
- "OO_G7231ANNEXC",
- "OO_GSMFULLRATE",
- "OO_GSMHALFRATE",
- "OO_GSMENHANCEDFULLRATE",
- "OO_GENERICAUDIO",
- "OO_G729EXTENSIONS",
- "OO_VBD",
- "OO_AUDIOTELEPHONYEVENT",
- "OO_AUDIOTONE",
- "OO_EXTELEM1",
- "OO_VIDEO_BASE",
- "OO_NONSTDVIDEO",
- "OO_H261VIDEO",
- "OO_H262VIDEO",
- "OO_H263VIDEO",
- "OO_IS11172VIDEO", /* mpeg */
- "OO_GENERICVIDEO",
- "OO_EXTELEMVIDEO"
-};
-
-/*DTMF capabilities*/
-static const char* dtmfCaps []={
- "OO_CAP_DTMF_RFC2833",
- "OO_CAP_DTMF_Q931",
- "OO_CAP_DTMF_H245"
-};
-
-static const char* ooGetText (int idx, const char** table, size_t tabsiz)
-{
- return (idx < (int)tabsiz) ? table[idx] : "?";
-}
-
-const char* ooGetReasonCodeText (int code)
-{
- return ooGetText (code, reasonCodeText, OONUMBEROF(reasonCodeText));
-}
-
-const char* ooGetCallStateText (int callState)
-{
- return ooGetText (callState, callStateText, OONUMBEROF(callStateText));
-}
-
-const char* ooGetCapTypeText(int cap)
-{
- return ooGetText (cap, capTypes, OONUMBEROF(capTypes));
-}
-
-const char* ooGetMsgTypeText (int msgType)
-{
- int idx = msgType - OO_MSGTYPE_MIN;
- return ooGetText (idx, msgTypeText, OONUMBEROF(msgTypeText));
-}
-
-const char* ooGetQ931CauseValueText(int val)
-{
- switch(val)
- {
- case Q931UnallocatedNumber:
- return "Q931UnallocatedNumber";
- case Q931NoRouteToNetwork:
- return "Q931NoRouteToNetwork";
- case Q931NoRouteToDestination:
- return "Q931NoRouteToDestination";
- case Q931ChannelUnacceptable:
- 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";
-}
-
void ooSetTraceThreshold(OOUINT32 traceLevel)
{
gs_traceLevel = traceLevel;
@@ -267,7 +61,8 @@
SYSTEMTIME systemTime;
GetLocalTime(&systemTime);
- GetTimeFormat(LOCALE_SYSTEM_DEFAULT,0, &systemTime, "HH':'mm':'ss", timeString, 100);
+ GetTimeFormat(LOCALE_SYSTEM_DEFAULT,0, &systemTime, "HH':'mm':'ss",
+ timeString, 100);
GetTimeFormat(LOCALE_SYSTEM_DEFAULT,0, &systemTime, "H", currtime, 3);
if(lasttime> atoi(currtime))
printDate=1;
@@ -275,10 +70,9 @@
#else
struct tm *ptime;
- struct timeval systemTime;
char dateString[10];
- gettimeofday(&systemTime, NULL);
- ptime = (struct tm*)localtime(&systemTime.tv_sec);
+ time_t t = time(NULL);
+ ptime = localtime(&t);
strftime(timeString, 100, "%H:%M:%S", ptime);
strftime(currtime, 3, "%H", ptime);
if(lasttime>atoi(currtime))
@@ -294,9 +88,10 @@
fprintf(gH323ep.fptraceFile, "---------Date %d/%d/%d---------\n",
systemTime.wMonth, systemTime.wDay, systemTime.wYear);
}
- if(printTime)
- fprintf(gH323ep.fptraceFile, "%s:%03d %s", timeString,
- systemTime.wMilliseconds, logMessage);
+ if(printTime) {
+ fprintf(gH323ep.fptraceFile, "%s:%03d %s", timeString,
+ systemTime.wMilliseconds, logMessage);
+ }
else
fprintf(gH323ep.fptraceFile, "%s", logMessage);
@@ -309,9 +104,12 @@
fprintf(gH323ep.fptraceFile, "---------Date %s---------\n",
dateString);
}
- if(printTime)
- fprintf(gH323ep.fptraceFile, "%s:%03d %s", timeString,
- systemTime.tv_usec/1000, logMessage);
+ if(printTime) {
+ struct timeval systemTime;
+ gettimeofday(&systemTime, NULL);
+ fprintf(gH323ep.fptraceFile, "%s:%03ld %s", timeString,
+ systemTime.tv_usec/1000, logMessage);
+ }
else
fprintf(gH323ep.fptraceFile, "%s", logMessage);
Index: ootrace.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ootrace.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ootrace.h 16 Jun 2005 19:41:23 -0000 1.3
+++ ootrace.h 26 Oct 2005 20:49:40 -0000 1.4
@@ -110,51 +110,6 @@
#endif /* MAKE_DLL */
#endif /* EXTERN */
-
-/**
- * This function is used to retrieve the description text for a reason
- * code.
- *
- * @param code Reason code.
- * @return The text description string.
- */
-const char* ooGetReasonCodeText (int code);
-
-/**
- * This function is used to retrieve the description text for a call
- * state.
- *
- * @param callState Call state.
- * @return The text description string.
- */
-const char* ooGetCallStateText (int callState);
-
-/**
- * This function is used to retrieve the description text for a
- * message type.
- *
- * @param msgType Message type.
- * @return The text description string.
- */
-const char* ooGetMsgTypeText (int msgType);
-
-/**
- * This function is used to retrieve the text description for a capability
- * type.
- * @param cap Capability
- * @return The text description string.
- */
-const char* ooGetCapTypeText(int cap);
-
-/**
- * This function is used to retrieve the text description for a Q931 Cause
- * value in Cause IE.
- * @param val Q931 Cause value
- * @return The text description string
- */
-const char* ooGetQ931CauseValueText(int val);
-
-
/**
* This function is used to set the trace level.
* @param traceLevel New trace level. Various values are: OOTRCLVLERR,
Index: ootypes.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ootypes.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ootypes.h 16 Sep 2005 19:29:17 -0000 1.7
+++ ootypes.h 26 Oct 2005 20:49:40 -0000 1.8
@@ -59,11 +59,9 @@
#include "config.h"
#endif
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
-#define OOH323C_VERSION "vxx.aa"
+
+#define OOH323C_VERSION "v0.8"
#ifndef EXTERN
#ifdef MAKE_DLL
@@ -226,12 +224,7 @@
/** This macro tests a flag with a bit mask */
#define OO_TESTFLAG(flags,mask) ((flags & mask) != 0)
-/* Define common mutex type */
-#ifdef _WIN32
-#define OO_MUTEX CRITICAL_SECTION
-#else
-#define OO_MUTEX pthread_mutex_t
-#endif
+
/*TODO: Should add caller-id, callername etc. So that they can be changed per
call basis*/
Index: printHandler.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/printHandler.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- printHandler.c 6 Jul 2005 12:49:54 -0000 1.2
+++ printHandler.c 26 Oct 2005 20:49:40 -0000 1.3
@@ -108,19 +108,31 @@
void printBitStrValue (ASN1UINT numbits, const ASN1OCTET* data)
{
+#ifdef __MINGW32__
+ char s[numbits + 8];
+ indent ();
+ OOTRACEDBGB2("%s\n", bitStrToString (numbits, data, s, numbits+8));
+#else
char* s = (char*)malloc(numbits + 8);
indent ();
OOTRACEDBGB2("%s\n", bitStrToString (numbits, data, s, numbits+8));
free(s);
+#endif
}
void printOctStrValue (ASN1UINT numocts, const ASN1OCTET* data)
{
int bufsiz = (numocts * 2) + 8;
+#ifdef __MINGW32__
+ char s[bufsiz];
+ indent ();
+ OOTRACEDBGB2 ("%s\n", octStrToString (numocts, data, s, bufsiz));
+#else
char* s = (char*)malloc(bufsiz);
indent ();
OOTRACEDBGB2 ("%s\n", octStrToString (numocts, data, s, bufsiz));
free(s);
+#endif
}
void printCharStrValue (const char* value)
- Previous message: [Asterisk-cvs] asterisk-addons/asterisk-ooh323c/src chan_h323.c,
1.12, 1.13 chan_h323.h, 1.2, 1.3 ooh323cDriver.c, 1.5, 1.6
- Next message: [Asterisk-cvs] asterisk/include/asterisk adsi.h, 1.12,
1.13 callerid.h, 1.14, 1.15 cdr.h, 1.30, 1.31 channel.h, 1.107,
1.108 config.h, 1.24, 1.25 devicestate.h, 1.5, 1.6 doxyref.h,
1.2, 1.3 enum.h, 1.8, 1.9 file.h, 1.28, 1.29 frame.h, 1.59,
1.60 manager.h, 1.22, 1.23 module.h, 1.23, 1.24 pbx.h, 1.54,
1.55 plc.h, 1.4, 1.5 strings.h, 1.13, 1.14 tdd.h, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list