[Asterisk-cvs] asterisk-addons/asterisk-ooh323c/ooh323c/src Makefile.am, 1.1, 1.2 Makefile.in, 1.1, 1.2 dlist.c, 1.1, 1.2 ooCalls.c, 1.1, 1.2 ooCapability.h, 1.1, 1.2 ooSocket.c, 1.1, 1.2 ooSocket.h, 1.1, 1.2 ooStackCmds.c, 1.1, 1.2 ooStackCmds.h, 1.1, 1.2 ooasn1.h, 1.1, 1.2 oochannels.c, 1.1, 1.2 oochannels.h, 1.1, 1.2 ooh245.c, 1.1, 1.2 ooh323.c, 1.1, 1.2 ooh323ep.c, 1.1, 1.2 ooh323ep.h, 1.1, 1.2 ooports.c, 1.1, 1.2 ooports.h, 1.1, 1.2 ooq931.c, 1.1, 1.2 ooq931.h, 1.1, 1.2 ootypes.h, 1.1, 1.2

vphirke at lists.digium.com vphirke at lists.digium.com
Thu May 26 09:30:33 CDT 2005


Update of /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src
In directory mongoose.digium.com:/tmp/cvs-serv5973/ooh323c/src

Modified Files:
	Makefile.am Makefile.in dlist.c ooCalls.c ooCapability.h 
	ooSocket.c ooSocket.h ooStackCmds.c ooStackCmds.h ooasn1.h 
	oochannels.c oochannels.h ooh245.c ooh323.c ooh323ep.c 
	ooh323ep.h ooports.c ooports.h ooq931.c ooq931.h ootypes.h 
Log Message:
Updated stack source from sourceforge

Index: Makefile.am
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am	23 May 2005 21:19:58 -0000	1.1
+++ Makefile.am	26 May 2005 13:34:36 -0000	1.2
@@ -1,4 +1,4 @@
-AUTOMKAE_OPTIONS = gnu
+AUTOMAKE_OPTIONS = gnu
 CFLAGS = @OOH323CFLAGS@
 
 noinst_LIBRARIES = liboostk.a

Index: Makefile.in
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.in	23 May 2005 21:19:58 -0000	1.1
+++ Makefile.in	26 May 2005 13:34:36 -0000	1.2
@@ -86,7 +86,7 @@
 am__include = @am__include@
 am__quote = @am__quote@
 install_sh = @install_sh@
-AUTOMKAE_OPTIONS = gnu
+AUTOMAKE_OPTIONS = gnu
 CFLAGS = @OOH323CFLAGS@
 
 noinst_LIBRARIES = liboostk.a

Index: dlist.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/dlist.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dlist.c	23 May 2005 21:03:55 -0000	1.1
+++ dlist.c	26 May 2005 13:34:36 -0000	1.2
@@ -71,6 +71,21 @@
    return pListNode;
 }
 
+/* Delete the head node from the list and return the data item stored	*/
+/* in that node..							*/
+
+void* dListDeleteHead (OOCTXT* pctxt, DList* pList)
+{
+   DListNode* pNode = (0 != pList) ? pList->head : 0;
+   if (0 != pNode) {
+      void* pdata = pNode->data;
+      dListRemove (pList, pNode);
+      memFreePtr (pctxt, pNode);
+      return pdata;
+   }
+   return 0;
+}
+
 /* Free all nodes, but not the data */
 void dListFreeNodes (OOCTXT* pctxt, DList* pList)
 {

Index: ooCalls.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCalls.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooCalls.c	23 May 2005 21:03:55 -0000	1.1
+++ ooCalls.c	26 May 2005 13:34:36 -0000	1.2
@@ -40,10 +40,10 @@
       OOTRACEERR1("ERROR:Failed to create OOCTXT for new call\n");
       return NULL;
    }
-   call = (OOH323CallData*)ASN1MALLOC(pctxt, sizeof(OOH323CallData));
+   call = (OOH323CallData*)memAlloc(pctxt, sizeof(OOH323CallData));
    if(!call)
    {
-      OOTRACEERR1("ERROR: Failed to allocate memory for new call data\n");
+      OOTRACEERR1("ERROR:Memory - ooCreateCall - call\n");
       return NULL;
    } 
    /*   memset(call, 0, sizeof(OOH323CallData));*/
@@ -79,6 +79,7 @@
    
    call->callState = OO_CALL_CREATED;
    call->callEndReason = OO_REASON_UNKNOWN;
+   call->pCallFwdData = NULL;
 
    if(!strcmp(call->callType, "incoming"))
    {
@@ -94,8 +95,8 @@
          {
             strcpy(call->callingPartyNumber, gH323ep.callingPartyNumber);
          }else{
-            OOTRACEERR3("Error:Failed to allocate memory for calling party "
-                        "number.(%s, %s)\n", call->callType, call->callToken);
+            OOTRACEERR3("Error:Memory - ooCreateCall - callingPartyNumber"
+                        ".(%s, %s)\n", call->callType, call->callToken);
             freeContext(pctxt);
             return NULL;
          }
@@ -194,13 +195,18 @@
    }
 
 
-   if(!OO_TESTFLAG(call->flags, OO_M_RELEASE_BUILT))   
+   if(!call->pH225Channel || call->pH225Channel->sock ==0)
    {
-      if(call->callState == OO_CALL_CLEAR || 
-         call->callState == OO_CALL_CLEAR_RELEASERECVD)
+      call->callState = OO_CALL_CLEARED;
+   }else{
+      if(!OO_TESTFLAG(call->flags, OO_M_RELEASE_BUILT))   
       {
-         ooSendReleaseComplete(call);
-         OO_SETFLAG(call->flags, OO_M_RELEASE_BUILT);
+         if(call->callState == OO_CALL_CLEAR || 
+            call->callState == OO_CALL_CLEAR_RELEASERECVD)
+         {
+            ooSendReleaseComplete(call);
+            OO_SETFLAG(call->flags, OO_M_RELEASE_BUILT);
+         }
       }
    }
       
@@ -288,7 +294,7 @@
       }
    }else {
       if(gH323ep.h323Callbacks.onCallCleared)
-        gH323ep.h323Callbacks.onCallCleared(call);
+         gH323ep.h323Callbacks.onCallCleared(call);
    }
 
    pctxt = call->pctxt;
@@ -316,8 +322,9 @@
    {
      strcpy(call->callingPartyNumber, number);
    }else{
-      OOTRACEERR3("Error:Failed to allocate memory for calling party number."
-                  "(%s, %s)\n", call->callType, call->callToken);
+      OOTRACEERR3("Error:Memory - ooCallSetCallingPartyNumber - "
+                  "callingPartyNumber.(%s, %s)\n", call->callType, 
+                  call->callToken);
       return OO_FAILED;
    }
    /* Set dialed digits alias */
@@ -353,8 +360,9 @@
    {
      strcpy(call->calledPartyNumber, number);
    }else{
-      OOTRACEERR3("Error:Failed to allocate memory for calling party number."
-                  "(%s, %s)\n", call->callType, call->callToken);
+      OOTRACEERR3("Error:Memory - ooCallSetCalledPartyNumber - "
+                  "calledPartyNumber.(%s, %s)\n", call->callType, 
+                  call->callToken);
       return OO_FAILED;
    }
    return OO_OK;
@@ -385,20 +393,20 @@
 int ooCallAddAliasH323ID(OOH323CallData *call, const char* h323id)
 {
    ooAliases * psNewAlias=NULL;
-   psNewAlias = (ooAliases*)ASN1MALLOC(call->pctxt, sizeof(ooAliases));
+   psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
    if(!psNewAlias)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for new H323-ID alias for"
+      OOTRACEERR3("Error:Memory - ooCallAddAliasH323ID - psNewAlias"
                   "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
    psNewAlias->type = T_H225AliasAddress_h323_ID;
-   psNewAlias->value = (char*) ASN1MALLOC(call->pctxt, strlen(h323id)+1);
+   psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(h323id)+1);
    if(!psNewAlias->value)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for the new H323-ID alias "
-                  "value. (%s, %s)\n", call->callType, call->callToken);
-      ASN1MEMFREEPTR(call->pctxt, psNewAlias);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasH323ID - psNewAlias->value"
+                  " (%s, %s)\n", call->callType, call->callToken);
+      memFreePtr(call->pctxt, psNewAlias);
       return OO_FAILED;
    }
    strcpy(psNewAlias->value, h323id);
@@ -414,20 +422,21 @@
 {
 
    ooAliases * psNewAlias=NULL;
-   psNewAlias = (ooAliases*)ASN1MALLOC(call->pctxt, sizeof(ooAliases));
+   psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
    if(!psNewAlias)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for new DialedDigits alias"
-                  " for (%s, %s)\n", call->callType, call->callToken);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasDialedDigits - psNewAlias"
+                  "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
    psNewAlias->type = T_H225AliasAddress_dialedDigits;
-   psNewAlias->value = (char*) ASN1MALLOC(call->pctxt, strlen(dialedDigits)+1);
+   psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(dialedDigits)+1);
    if(!psNewAlias->value)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for the new DialedDigits "
-                  "alias value. (%s, %s)\n", call->callType, call->callToken);
-      ASN1MEMFREEPTR(call->pctxt, psNewAlias);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasDialedDigits - "
+                  "psNewAlias->value. (%s, %s)\n", call->callType, 
+                   call->callToken);
+      memFreePtr(call->pctxt, psNewAlias);
       return OO_FAILED;
    }
    strcpy(psNewAlias->value, dialedDigits);
@@ -444,20 +453,20 @@
 {
 
    ooAliases * psNewAlias=NULL;
-   psNewAlias = (ooAliases*)ASN1MALLOC(call->pctxt, sizeof(ooAliases));
+   psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
    if(!psNewAlias)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for new email id alias"
-                  " for (%s, %s)\n", call->callType, call->callToken);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasEmailID - psNewAlias"
+                  "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
    psNewAlias->type = T_H225AliasAddress_email_ID;
-   psNewAlias->value = (char*) ASN1MALLOC(call->pctxt, strlen(email)+1);
+   psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(email)+1);
    if(!psNewAlias->value)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for the new email-id "
-                  "alias value. (%s, %s)\n", call->callType, call->callToken);
-      ASN1MEMFREEPTR(call->pctxt, psNewAlias);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasEmailID - psNewAlias->value "
+                  "(%s, %s)\n", call->callType, call->callToken);
+      memFreePtr(call->pctxt, psNewAlias);
       return OO_FAILED;
    }
    strcpy(psNewAlias->value, email);
@@ -474,20 +483,20 @@
 {
 
    ooAliases * psNewAlias=NULL;
-   psNewAlias = (ooAliases*)ASN1MALLOC(call->pctxt, sizeof(ooAliases));
+   psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
    if(!psNewAlias)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for new url id alias"
-                  " for (%s, %s)\n", call->callType, call->callToken);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasURLID - psNewAlias"
+                  "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
    psNewAlias->type = T_H225AliasAddress_url_ID;
-   psNewAlias->value = (char*) ASN1MALLOC(call->pctxt, strlen(url)+1);
+   psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(url)+1);
    if(!psNewAlias->value)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for the new url-id "
-                  "alias value. (%s, %s)\n", call->callType, call->callToken);
-      ASN1MEMFREEPTR(call->pctxt, psNewAlias);
+      OOTRACEERR3("Error:Memory - ooCallAddAliasURLID - psNewAlias->value"
+                  "(%s, %s)\n", call->callType, call->callToken);
+      memFreePtr(call->pctxt, psNewAlias);
       return OO_FAILED;
    }
    strcpy(psNewAlias->value, url);
@@ -503,20 +512,21 @@
 int ooCallAddRemoteAliasH323ID(OOH323CallData *call, const char* h323id)
 {
    ooAliases * psNewAlias=NULL;
-   psNewAlias = (ooAliases*)ASN1MALLOC(call->pctxt, sizeof(ooAliases));
+   psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
    if(!psNewAlias)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for remote H323-ID alias "
-                  "for (%s, %s)\n", call->callType, call->callToken);
+      OOTRACEERR3("Error:Memory - ooCallAddRemoteAliasH323ID - psNewAlias "
+                  "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
    psNewAlias->type = T_H225AliasAddress_h323_ID;
-   psNewAlias->value = (char*) ASN1MALLOC(call->pctxt, strlen(h323id)+1);
+   psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(h323id)+1);
    if(!psNewAlias->value)
    {
-      OOTRACEERR3("Error: Failed to allocate memory for the remote H323-ID "
-                  "alias value. (%s, %s)\n", call->callType, call->callToken);
-      ASN1MEMFREEPTR(call->pctxt, psNewAlias);
+      OOTRACEERR3("Error:Memory - ooCallAddRemoteAliasH323ID - "
+                  "psNewAlias->value. (%s, %s)\n", call->callType, 
+                   call->callToken);
+      memFreePtr(call->pctxt, psNewAlias);
       return OO_FAILED;
    }
    strcpy(psNewAlias->value, h323id);
@@ -636,11 +646,11 @@
    OOTRACEDBGC5("Adding new media channel for cap %d dir %s (%s, %s)\n",
 		epCap->cap, dir, call->callType, call->callToken);
    /* Create a new logical channel entry */
-   pNewChannel = (ooLogicalChannel*)ASN1MALLOC(call->pctxt, 
+   pNewChannel = (ooLogicalChannel*)memAlloc(call->pctxt, 
                                                      sizeof(ooLogicalChannel));
    if(!pNewChannel)
    {
-      OOTRACEERR3("ERROR:Memory allocation for new logical channel failed "
+      OOTRACEERR3("ERROR:Memory - ooAddNewLogicalChannel - pNewChannel "
                   "(%s, %s)\n", call->callType, call->callToken);
       return NULL;
    }
@@ -863,6 +873,10 @@
    int ret = OO_OK;
    ooLogicalChannel *pLogicalChannel = NULL;
    ooH323EpCapability *epCap=NULL;
+
+   OOTRACEDBGC4("Clearing logical channel number %d. (%s, %s)\n", channelNo,
+		call->callType, call->callToken);
+
    pLogicalChannel = ooFindLogicalChannelByLogicalChannelNo(call,channelNo);
    if(!pLogicalChannel)
    {
@@ -878,7 +892,7 @@
       {
          epCap->stopReceiveChannel(call, pLogicalChannel);
          OOTRACEINFO4("Stopped Receive channel %d (%s, %s)\n", 
-              channelNo, call->callType, call->callToken);
+                                 channelNo, call->callType, call->callToken);
       }
       else{
          OOTRACEERR4("ERROR:No callback registered for stopReceiveChannel %d "
@@ -893,11 +907,12 @@
          {
             epCap->stopTransmitChannel(call, pLogicalChannel);
             OOTRACEINFO4("Stopped Transmit channel %d (%s, %s)\n", 
-                 channelNo, call->callType, call->callToken);
+                          channelNo, call->callType, call->callToken);
          }
          else{
-            OOTRACEERR4("ERROR:No callback registered for stopTransmitChannel %d "
-                        "(%s, %s)\n", channelNo, call->callType, call->callToken);
+            OOTRACEERR4("ERROR:No callback registered for stopTransmitChannel"
+                        " %d (%s, %s)\n", channelNo, call->callType, 
+                        call->callToken);
          }
       }
    }
@@ -926,8 +941,8 @@
          if(!prev)   call->logicalChans = temp->next;
          else   prev->next = temp->next;
          //ASN1MEMFREEPTR(call->pctxt, temp->chanCap->cap);
-         ASN1MEMFREEPTR(call->pctxt, temp->chanCap);
-         ASN1MEMFREEPTR(call->pctxt, temp);
+         memFreePtr(call->pctxt, temp->chanCap);
+         memFreePtr(call->pctxt, temp);
          OOTRACEDBGC4("Removed logical channel %d (%s, %s)\n", ChannelNo,
                        call->callType, call->callToken);
          call->noOfLogicalChannels--;
@@ -942,7 +957,8 @@
    return OO_FAILED;
 }
 
-int ooOnLogicalChannelEstablished(OOH323CallData *call, ooLogicalChannel * pChannel)
+int ooOnLogicalChannelEstablished
+   (OOH323CallData *call, ooLogicalChannel * pChannel)
 {
    ooLogicalChannel * temp = NULL, *prev=NULL; 
    /* Change the state of the channel as established and close all other 
@@ -983,10 +999,10 @@
                    call->callType, call->callToken);
       return OO_FAILED;
    }
-   newMediaInfo = (ooMediaInfo*) ASN1MALLOC(call->pctxt, sizeof(ooMediaInfo));
+   newMediaInfo = (ooMediaInfo*) memAlloc(call->pctxt, sizeof(ooMediaInfo));
    if(!newMediaInfo)
    {
-      OOTRACEERR3("Error:failed to allocate memory for new mediaInfo. "
+      OOTRACEERR3("Error:Memory - ooAddMediaInfo - newMediaInfo. "
                   "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }

Index: ooCapability.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooCapability.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooCapability.h	23 May 2005 21:03:55 -0000	1.1
+++ ooCapability.h	26 May 2005 13:34:36 -0000	1.2
@@ -69,6 +69,15 @@
    OOBOOL comfortNoise;
 } ooGSMCapParams;
 
+typedef struct OOH263CapParams {
+   unsigned sqcifMPI;
+   unsigned qcifMPI;
+   unsigned cifMPI;
+   unsigned cif16MPI;
+   unsigned maxBitRate;
+   unsigned frameRate;
+} OOH263CapParams;
+
 struct OOH323CallData;
 
 #ifdef __cplusplus

Index: ooSocket.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooSocket.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooSocket.c	23 May 2005 21:03:55 -0000	1.1
+++ ooSocket.c	26 May 2005 13:34:36 -0000	1.2
@@ -369,6 +369,18 @@
    return ASN_OK;
 }
 
+int ooSocketRecvPeek(OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize)
+{
+   int len;
+   int flags = MSG_PEEK;
+
+   if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
+
+   if ((len = recv (socket, (char*) pbuf, bufsize, flags)) == -1)
+      return ASN_E_INVSOCKET;
+   return len;
+}
+
 int ooSocketRecv (OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize)
 {
    int len;

Index: ooSocket.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooSocket.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooSocket.h	23 May 2005 21:03:55 -0000	1.1
+++ ooSocket.h	26 May 2005 13:34:36 -0000	1.2
@@ -214,6 +214,21 @@
  */
 EXTERN int ooSocketListen (OOSOCKET socket, int maxConnection);
 
+
+/**
+ * This function is used to peek at the received data without actually removing
+ * it from the receive socket buffer. A receive call after this will get the
+ * same data from the socket.
+ * @param socket       The socket's handle created by call to ::rtSocketCreate
+ *                     or ::rtSocketAccept function.
+ * @param pbuf         Pointer to the buffer for the incoming data.
+ * @param bufsize      Length of the buffer.
+ * @return             If no error occurs, returns the number of bytes
+ *                     received. Otherwise, the negative value is error code.
+ */
+EXTERN int ooSocketRecvPeek
+   (OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize);
+
 /**
  * This function receives data from a connected socket. It is used to read
  * incoming data on sockets. The socket must be connected before calling this

Index: ooStackCmds.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooStackCmds.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooStackCmds.c	23 May 2005 21:03:55 -0000	1.1
+++ ooStackCmds.c	26 May 2005 13:34:36 -0000	1.2
@@ -27,14 +27,14 @@
 int ooMakeCall 
    (const char* dest, char* callToken, size_t bufsiz, ooCallOptions *opts)
 {
-   ooCommand *cmd;
+   OOStackCommand *cmd;
    int ret;
 #ifdef _WIN32
    EnterCriticalSection(&gCmdMutex);
 #else
    pthread_mutex_lock(&gCmdMutex);
 #endif
-   cmd = (ooCommand*) memAlloc (&gH323ep.ctxt, sizeof(ooCommand));
+   cmd = (OOStackCommand*) memAlloc (&gH323ep.ctxt, sizeof(OOStackCommand));
    if(!cmd)
    {
       OOTRACEERR1("Error:Memory - ooMakeCall - cmd\n");
@@ -109,19 +109,19 @@
 
 int ooAnswerCall(char *callToken)
 {
-   ooCommand *cmd;
+   OOStackCommand *cmd;
 #ifdef _WIN32
    EnterCriticalSection(&gCmdMutex);
 #else
    pthread_mutex_lock(&gCmdMutex);
 #endif
-   cmd = (ooCommand*)memAlloc(&gH323ep.ctxt, sizeof(ooCommand));
+   cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
    if(!cmd)
    {
       OOTRACEERR1("Error:Memory - ooAnswerCall - cmd\n");
       return OO_FAILED;
    }
-   memset(cmd, 0, sizeof(ooCommand));
+   memset(cmd, 0, sizeof(OOStackCommand));
    cmd->type = OO_CMD_ANSCALL;
 
    cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
@@ -152,19 +152,19 @@
 
 int ooForwardCall(char* callToken, char *dest)
 {
-   ooCommand *cmd;
+   OOStackCommand *cmd;
 #ifdef _WIN32
    EnterCriticalSection(&gCmdMutex);
 #else
    pthread_mutex_lock(&gCmdMutex);
 #endif
-   cmd = (ooCommand*)memAlloc(&gH323ep.ctxt, sizeof(ooCommand));
+   cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
    if(!cmd)
    {
       OOTRACEERR1("Error:Memory - ooForwardCall - cmd\n");
       return OO_FAILED;
    }
-   memset(cmd, 0, sizeof(ooCommand));
+   memset(cmd, 0, sizeof(OOStackCommand));
    cmd->type = OO_CMD_FWDCALL;
 
    cmd->param1 = (void*) memAlloc(&gH323ep.ctxt, strlen(callToken)+1);
@@ -196,20 +196,20 @@
 
 int ooHangCall(char * callToken, OOCallClearReason reason)
 {
-   ooCommand *cmd;
+   OOStackCommand *cmd;
 #ifdef _WIN32
    EnterCriticalSection(&gCmdMutex);
 #else
    pthread_mutex_lock(&gCmdMutex);
 #endif
-   cmd = (ooCommand*)memAlloc(&gH323ep.ctxt, sizeof(ooCommand));
+   cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
    if(!cmd)
    {
       OOTRACEERR1("Error:Allocating memory for command structure - HangCall\n");
       return OO_FAILED;
    }
 
-   memset(cmd, 0, sizeof(ooCommand));
+   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));
@@ -238,21 +238,88 @@
    return OO_OK;
 }
 
+int ooProcStackCmds()
+{
+   if (gH323ep.stkCmdList.count > 0)
+   {
+      OOStackCommand *cmd;
+      while (0 != (cmd = dListDeleteHead (&gH323ep.ctxt, &gH323ep.stkCmdList)))
+      {
+	 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);
+               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));
+               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);
+               break;
+
+            case OO_CMD_HANGCALL: 
+               OOTRACEINFO2("Processing Hang call command %s\n", 
+                             (char*)cmd->param1);
+               ooH323HangCall((char*)cmd->param1, 
+                                       *(OOCallClearReason*)cmd->param2);
+               break;
+
+            case OO_CMD_STOPMONITOR: 
+               OOTRACEINFO1("Processing StopMonitor command\n");
+               ooStopMonitorCalls();
+               break;
+
+            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);
+      }
+   }
+
+   return OO_OK;
+}
+
 int ooStopMonitor()
 {
-   ooCommand *cmd;
+   OOStackCommand *cmd;
 #ifdef _WIN32
    EnterCriticalSection(&gCmdMutex);
 #else
    pthread_mutex_lock(&gCmdMutex);
 #endif
-   cmd = (ooCommand*)memAlloc(&gH323ep.ctxt, sizeof(ooCommand));
+   cmd = (OOStackCommand*)memAlloc(&gH323ep.ctxt, sizeof(OOStackCommand));
    if(!cmd)
    {
       OOTRACEERR1("Error:Allocating memory for command structure - StopMonitor\n");
       return OO_FAILED;
    }
-   memset(cmd, 0, sizeof(ooCommand));
+   memset(cmd, 0, sizeof(OOStackCommand));
    cmd->type = OO_CMD_STOPMONITOR;
    
    dListAppend (&gH323ep.ctxt, &gH323ep.stkCmdList, cmd);

Index: ooStackCmds.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooStackCmds.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooStackCmds.h	23 May 2005 21:03:55 -0000	1.1
+++ ooStackCmds.h	26 May 2005 13:34:36 -0000	1.2
@@ -40,6 +40,30 @@
  * @{
  */
 /**
+ * This is an enumeration of stack command codes.
+ */
+typedef enum OOStackCmdID {
+   OO_CMD_MAKECALL,          /*!< Make call */
+   OO_CMD_ANSCALL,           /*!< Answer call */
+   OO_CMD_FWDCALL,           /*!< Forward call */
+   OO_CMD_HANGCALL,          /*!< Terminate call */
+   OO_CMD_STOPMONITOR        /*!< Stop the event monitor */
+} OOStackCmdID;
+
+/**
+ * This structure is used to queue a stack command for processing in 
+ * the event handler loop.
+ */
+typedef struct OOStackCommand {
+   OOStackCmdID type;
+   void* param1;
+   void* param2;
+   void* param3;
+} OOStackCommand;
+
+#define ooCommand OOStackCommand;
+
+/**
  * This function is used by an application to place a call.
  * @param dest        Call Destination - IP:port / alias
  * @param callToken   Pointer to a buffer in which callToken will be returned
@@ -81,6 +105,12 @@
 EXTERN int ooHangCall(char * callToken, OOCallClearReason reason);
 
 /**
+ * This function is invoked from the main event handling loop to 
+ * process queued stack commands.
+ */
+EXTERN int ooProcStackCmds ();
+
+/**
  * This function is used by the user application to stop monitoring calls.
  * @param None
  *

Index: ooasn1.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooasn1.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooasn1.h	23 May 2005 21:03:55 -0000	1.1
+++ ooasn1.h	26 May 2005 13:34:36 -0000	1.2
@@ -16,7 +16,8 @@
 /** 
  * @file ooasn1.h 
  * Common ASN.1 runtime constants, data structure definitions, and run-time
- * functions to support BER/DER/PER as defined in the ITU-T standards.
+ * functions to support ASN.1 PER encoding/decoding as defined in the 
+ * ITU-T standards.
  */
 #ifndef _OOASN1_H_
 #define _OOASN1_H_
@@ -25,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stddef.h>
+#include "dlist.h"
 #include "ootrace.h"
 /** 
  * @defgroup cruntime C Runtime Common Functions 
@@ -367,20 +369,6 @@
    unsigned     alignedBits;
 } Asn116BitCharSet;
 
-/* Doubly-linked list */
-
-typedef struct _DListNode {
-   void* data;
-   struct _DListNode* next;
-   struct _DListNode* prev;
-} DListNode;
-
-typedef struct _DList {
-   ASN1UINT count;
-   DListNode* head;
-   DListNode* tail;
-} DList;
-
 /* ASN.1 size constraint structure */
 
 typedef struct _Asn1SizeCnst {
@@ -498,10 +486,6 @@
 #define ALLOC_ASN1ELEM(pctxt,type) \
 (type*) memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type))
 
-#define ALLOC_ASN1ELEMDNODE(pctxt,type) \
-(type*) (((char*)memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type) + \
-sizeof(DListNode))) + sizeof(DListNode))
-
 /**
  * Allocate memory. This macro allocates the given number of bytes. It is
  * similar to the C \c malloc run-time function.
@@ -692,131 +676,6 @@
  * @} cmfun
  */
 /**
- * @defgroup llfuns Linked List Utility Functions
- *
- * Linked list and stack utility functions are used to maintain linked lists
- * and stacks used within the ASN.1 run-time library functions. @{
- */
-/**
- * This function appends an item to the linked list structure. The data item is
- * passed into the function as a void pointer that can point to any object of
- * any type. The memAlloc function is used to allocated the memory for the
- * list node structure; therefore, all internal list memory will be released
- * whenever memFree is called. The pointer to the data item itself is stored
- * in the node structure - a copy is not made.
- *
- * @param pctxt        A pointer to a context structure. This provides a
- *                     storage area for the function to store all working
- *                     variables that must be maintained between function
- *                     calls.
- * @param pList        A pointer to a linked list structure onto which the data
- *                     item is to be appended. A pointer to an updated linked
- *                     list structure.
- * @param pData        A pointer to a data item to be appended to the list.
- * @return             A pointer to an allocated node structure used to link
- *                     the given data value into the list.
- */ 
-EXTERN DListNode* dListAppend (OOCTXT* pctxt, DList* pList, void* pData);
-
-EXTERN DListNode* dListAppendNode (OOCTXT* pctxt, DList* pList, void* pData);
-EXTERN DListNode* dListFindByIndex (DList* pList, int index);
-/**
- * This function initializes a doubly linked list structure. It sets the number
- * of elements to zero and sets al internal pointer values to NULL. A doubly
- * linked-list structure is described by the DList type defined in
- * ooasn1.h. Nodes of the list are of type DListNode.
- *
- * Memory for the structures is allocated using the memAlloc run-time
- * function and is maintained within the context structure that is a required
- * parameter to all dList functions. This memory is released when memFree
- * is called or the Context is released. Unless otherwise noted, all data
- * passed into the list functions is simply stored on the list by value (i.e. a
- * deep-copy of the data is not done).
- *
- * @param pList        A pointer to a linked list structure to be initialized.
- */
-EXTERN void dListInit (DList* pList);
-
-/**
- * This function removes all nodes from the linked list and releases the memory
- * that was allocated for storing the node structures (DListNode). The data
- * will not be released.
- *
- * @param pctxt        A pointer to a context structure. This provides a
- *                     storage area for the function to store all working
- *                     variables that must be maintained between function
- *                     calls.
- * @param pList        A pointer to a linked list structure onto which the data
- *                     item is to be appended. A pointer to an updated linked
- *                     list structure.
- */
-EXTERN void dListFreeNodes (OOCTXT* pctxt, DList* pList);
-
-/** 
- * This function removes all nodes from the linked list structure and releases
- * the memory that was allocated for storing the node structures
- * (DListNode) and for data. The memory for data in each node must have
- * been previously allocated with calls to memAlloc, memAllocZ, or
- * memRealloc functions.
- *
- * @param pctxt        Pointer to a context structure. This provides a
- *                     storage area for the function to store all working
- *                     variables that must be maintained between function
- *                     calls.
- * @param pList        Pointer to a linked list structure.
- */
-EXTERN void dListFreeAll (OOCTXT* pctxt, DList* pList);
-
-/**
- * This function inserts an item into the linked list structure before the 
- * specified element.
- * 
- * @param pctxt         Pointer to a context structure.
- * @param pList		A pointer to a linked list structure into which the 
- *                        data item is to be inserted.
- * @param node          The position in the list where the item is to be 
- *                        inserted.  The item will be inserted before this 
- *                        node or appended to the list if node is null.
- * @param pData		A pointer to the data item to be inserted to the list.
- * @return		A pointer to an allocated node structure used to 
- *                        link the given data value into the list.
- */
-EXTERN DListNode* dListInsertBefore 
-(OOCTXT* pctxt, DList* pList, DListNode* node, const void* pData);
-
-/**
- * This function inserts an item into the linked list structure after the 
- * specified element.
- * 
- * @param pctxt         Pointer to a context structure.
- * @param pList		A pointer to a linked list structure into which the 
- *                        data item is to be inserted.
- * @param node          The position in the list where the item is to be 
- *                        inserted.  The item will be inserted after this 
- *                        node or added as the head element if node is null.
- * @param pData		A pointer to the data item to be inserted to the list.
- * @return		A pointer to an allocated node structure used to 
- *                        link the given data value into the list.
- */
-EXTERN DListNode* dListInsertAfter 
-(OOCTXT* pctxt, DList* pList, DListNode* node, const void* pData);
-
-/**
- * This function removes a node from the linked list structure. The memAlloc
- * function was used to allocate the memory for the list node structure,
- * therefore, all internal list memory will be released whenever memFree or
- * memFreePtr is called.
- *
- * @param pList        A pointer to a linked list structure onto which the data
- *                     item is to be removed. A pointer to an updated linked
- *                     list structure.
- * @param node         A pointer to the node that is to be removed. It should
- *                     already be in the linked list structure.
- */
-EXTERN void  dListRemove (DList* pList, DListNode* node);
-void dListFindAndRemove(DList* pList, void* data);
-
-/**
  * @defgroup errfp Error Formatting and Print Functions 
  * @{
  *

Index: oochannels.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/oochannels.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- oochannels.c	23 May 2005 21:03:55 -0000	1.1
+++ oochannels.c	26 May 2005 13:34:36 -0000	1.2
@@ -54,11 +54,11 @@
                   " (%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
-   call->h245listenport = (int*) ASN1MALLOC(call->pctxt, sizeof(int));
+   call->h245listenport = (int*) memAlloc(call->pctxt, sizeof(int));
    *(call->h245listenport) = ret;
-   call->h245listener = (OOSOCKET*)ASN1MALLOC(call->pctxt, sizeof(OOSOCKET));
+   call->h245listener = (OOSOCKET*)memAlloc(call->pctxt, sizeof(OOSOCKET));
    *(call->h245listener) = channelSocket;
-   ret = ooSocketListen(*(call->h245listener), 5);
+   ret = ooSocketListen(*(call->h245listener), 20);
    if(ret != ASN_OK)
    {
       OOTRACEERR3("Error:Unable to listen on H.245 socket (%s, %s)\n", 
@@ -180,12 +180,21 @@
          return OO_FAILED;
       }
    }
-	   
+
+   /* We need to send EndSessionCommand immediately.*/	   
    if(!OO_TESTFLAG(call->flags, OO_M_TUNNELING)){
-      dListAppend (call->pctxt, &call->pH245Channel->outQueue, encodebuf);
-      OOTRACEDBGC4("Queued H245 messages %d. (%s, %s)\n", 
-		call->pH245Channel->outQueue.count, 
-		call->callType, call->callToken);   
+      if(encodebuf[0]== OOEndSessionCommand) /* High priority message */
+      {
+         dListFreeAll(call->pctxt, &call->pH245Channel->outQueue);
+         dListAppend (call->pctxt, &call->pH245Channel->outQueue, encodebuf);
+         ooSendMsg(call, OOH245MSG);
+      }else{
+
+         dListAppend (call->pctxt, &call->pH245Channel->outQueue, encodebuf);
+         OOTRACEDBGC4("Queued H245 messages %d. (%s, %s)\n", 
+		   call->pH245Channel->outQueue.count, 
+		   call->callType, call->callToken);   
+      }
    }
    else{
       msgType = encodebuf[0];
@@ -244,12 +253,21 @@
       return OO_FAILED;
    }
 
-   dListAppend (call->pctxt, &call->pH225Channel->outQueue, encodebuf);
-
-   OOTRACEDBGC4("Queued H225 messages %d. (%s, %s)\n", 
-		call->pH225Channel->outQueue.count, 
-		call->callType, call->callToken);  
+   /* If high priority messages, send immediately.*/
+   if(encodebuf[0] == OOReleaseComplete || 
+      (encodebuf[0]==OOFacility && encodebuf[1]==OOEndSessionCommand))
+   {
+      dListFreeAll(call->pctxt, &call->pH225Channel->outQueue);
+      dListAppend (call->pctxt, &call->pH225Channel->outQueue, encodebuf);
+      ooSendMsg(call, OOQ931MSG);
+   }else{
 
+      dListAppend (call->pctxt, &call->pH225Channel->outQueue, encodebuf);
+ 
+      OOTRACEDBGC4("Queued H225 messages %d. (%s, %s)\n", 
+                                     call->pH225Channel->outQueue.count, 
+                                     call->callType, call->callToken);  
+   }
    return OO_OK;
 }
 
@@ -262,6 +280,11 @@
    {
       OOTRACEERR3("Failed to create socket for transmit H2250 channel (%s, %s)"
                   "\n", call->callType, call->callToken);
+      if(call->callState < OO_CALL_CLEAR)
+      {
+         call->callState = OO_CALL_CLEAR;
+         call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+      }
       return OO_FAILED;
    }
    else
@@ -283,6 +306,11 @@
       {
          OOTRACEERR3("Error:Unable to bind to a TCP port (%s, %s)\n", 
          call->callType, call->callToken);
+         if(call->callState < OO_CALL_CLEAR)
+         {
+            call->callState = OO_CALL_CLEAR;
+            call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+         }
          return OO_FAILED;
       }
 
@@ -310,6 +338,11 @@
       {
          OOTRACEERR3("ERROR:Failed to connect to remote destination for "
                     "transmit H2250 channel\n",call->callType,call->callToken);
+         if(call->callState < OO_CALL_CLEAR)
+         {  /* No one is listening at remote end */
+            call->callState = OO_CALL_CLEAR;
+            call->callEndReason = OO_REASON_NOUSER;
+         }
          return OO_FAILED;
       }
 
@@ -349,10 +382,10 @@
    if((ret=ooSocketBind (channelSocket, ipaddrs, 
                          gH323ep.listenPort))==ASN_OK) 
    {
-      gH323ep.listener = (OOSOCKET*)ASN1MALLOC(&gH323ep.ctxt,sizeof(OOSOCKET));
+      gH323ep.listener = (OOSOCKET*)memAlloc(&gH323ep.ctxt,sizeof(OOSOCKET));
       *(gH323ep.listener) = channelSocket;
           
-      ooSocketListen(channelSocket, 5); /*listen on socket*/
+      ooSocketListen(channelSocket,20); /*listen on socket*/
       OOTRACEINFO1("H323 listener creation - successful\n");
       return OO_OK;
    }
@@ -443,8 +476,6 @@
    struct timeval toMin, toNext;
    fd_set readfds, writefds;
    OOH323CallData *call, *prev=NULL;
-   DListNode *curNode;
-   ooCommand *cmd;
    int i=0;
 #ifdef HAVE_PIPE   
    char buf[2];
@@ -610,69 +641,13 @@
 	read(gH323ep.cmdPipe[0], buf, 1);
       }
 #endif
-      if (gH323ep.stkCmdList.count > 0)
-      {
-         for(i=0; i< (int)gH323ep.stkCmdList.count; i++)
-         {
-            curNode = dListFindByIndex (&gH323ep.stkCmdList, i) ;
-            cmd = (ooCommand*) curNode->data;
-            switch(cmd->type)
-            {
-            case OO_CMD_MAKECALL: 
-               if(gH323ep.gkClient && 
-                  gH323ep.gkClient->state != GkClientRegistered)
-               {
-                  OOTRACEWARN1("WARN: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);
-               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));
-               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);
-               break;
-            case OO_CMD_HANGCALL: 
-               OOTRACEINFO2("Processing Hang call command %s\n", 
-                             (char*)cmd->param1);
-               ooH323HangCall((char*)cmd->param1, 
-                                       *(OOCallClearReason*)cmd->param2);
-               break;
-            case OO_CMD_STOPMONITOR: 
-               OOTRACEINFO1("Processing StopMonitor command\n");
-               ooStopMonitorCalls();
-               break;
-            default: OOTRACEERR1("ERROR:Unhandled command\n");
-            }
-           dListRemove (&gH323ep.stkCmdList, curNode);
-           memFreePtr (&gH323ep.ctxt, curNode);
-           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);
-         }
-      }
+      ooProcStackCmds();
+
 #ifdef _WIN32
-   LeaveCriticalSection(&gCmdMutex);
+      LeaveCriticalSection(&gCmdMutex);
 #else
-   pthread_mutex_unlock(&gCmdMutex);
+      pthread_mutex_unlock(&gCmdMutex);
 #endif
       /* Manage ready descriptors after select */
 
@@ -937,7 +912,7 @@
    struct timeval timeout;
    fd_set readfds;
    
-   pmsg = (H245Message*)ASN1MALLOC(pctxt, sizeof(H245Message));
+   pmsg = (H245Message*)memAlloc(pctxt, sizeof(H245Message));
 
    /* First read just TPKT header which is four bytes */
    recvLen = ooSocketRecv (call->pH245Channel->sock, message, 4);
@@ -1080,9 +1055,11 @@
 {
 
    int len=0, ret=0, msgType=0, tunneledMsgType=0, logicalChannelNo = 0;
-   int i =0; 
+   int i =0;  
    DListNode * p_msgNode=NULL;
    ASN1OCTET *msgptr, *msgToSend=NULL;
+   
+
 
    if(call->callState == OO_CALL_CLEARED)
    {
@@ -1092,7 +1069,7 @@
    }
 
    if(type == OOQ931MSG)
-     {
+   {
       if(call->pH225Channel->outQueue.count == 0)
       {
          OOTRACEWARN3("WARN:No H.2250 message to send. (%s, %s)\n", 
@@ -1127,8 +1104,23 @@
       dListRemove(&(call->pH225Channel->outQueue), p_msgNode);
       if(p_msgNode)
          memFreePtr(call->pctxt, p_msgNode);
-
-      /* Send message out via TCP */
+      
+      /*TODO: This is not required ideally. We will see for some time and if
+         we don't face any problems we will delete this code */
+#if 0 
+      /* Check whether connection with remote is alright */
+      if(!ooChannelsIsConnectionOK(call, call->pH225Channel->sock))
+      {
+         OOTRACEERR3("Error:Transport failure for signalling channel. "
+                     "Abandoning message send and marking call for cleanup.(%s"
+                     "'%s)\n", call->callType, call->callToken);
+         if(call->callState < OO_CALL_CLEAR)
+            call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+         call->callState = OO_CALL_CLEARED;
+         return OO_OK;
+      }
+#endif     
+      /* Send message out via TCP */      
       ret = ooSocketSend(call->pH225Channel->sock, msgToSend, len);
       if(ret == ASN_OK)
       {
@@ -1177,7 +1169,7 @@
          memFreePtr(call->pctxt, p_msgNode);
 
       /* Send message out */
-      if (0 == call->pH245Channel && !OO_TESTFLAG (call->flags, OO_M_TUNNELING))
+      if (0 == call->pH245Channel && !OO_TESTFLAG(call->flags, OO_M_TUNNELING))
       {
          OOTRACEWARN3("Neither H.245 channel nor tunneling active "
                      "(%s, %s)\n", call->callType, call->callToken);
@@ -1275,7 +1267,7 @@
 }
 
 int ooOnSendMsg
-      (OOH323CallData *call, int msgType, int tunneledMsgType, int associatedChan)
+   (OOH323CallData *call, int msgType, int tunneledMsgType, int associatedChan)
 {
    ooTimerCallback *cbData=NULL;
    switch(msgType)
@@ -1284,7 +1276,7 @@
       OOTRACEINFO3("Sent Message - Setup (%s, %s)\n", call->callType, 
                     call->callToken);
       /* Start call establishment timer */
-      cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+      cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                      sizeof(ooTimerCallback));
       if(!cbData)
       {
@@ -1299,7 +1291,7 @@
       {
          OOTRACEERR3("Error:Unable to create call establishment timer. "
                      "(%s, %s)\n", call->callType, call->callToken);
-         ASN1MEMFREEPTR(call->pctxt, cbData);
+         memFreePtr(call->pctxt, cbData);
          return OO_FAILED;
       }
 
@@ -1311,9 +1303,9 @@
                     call->callToken);
       break;
    case OOAlert:
-      OOTRACEINFO3("Sent Message - Alerting (%s, %s)\n", call->callType,
+      OOTRACEINFO3("Sent Message - Alerting (%s, %s) \n", call->callType,
                     call->callToken);
-      if(gH323ep.h323Callbacks.onAlerting)
+      if(gH323ep.h323Callbacks.onAlerting && call->callState < OO_CALL_CLEAR)
          gH323ep.h323Callbacks.onAlerting(call);
       break;
    case OOConnect:
@@ -1341,7 +1333,7 @@
       if(call->callState == OO_CALL_CLEAR_RELEASESENT && 
          call->h245SessionState == OO_H245SESSION_IDLE)
       {
-         cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+         cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                   sizeof(ooTimerCallback));
          if(!cbData)
          {
@@ -1358,7 +1350,7 @@
             OOTRACEERR3("Error:Unable to create EndSession timer- "
                         "ReleaseComplete.(%s, %s)\n", call->callType, 
                         call->callToken);
-            ASN1MEMFREEPTR(call->pctxt, cbData);
+            memFreePtr(call->pctxt, cbData);
             return OO_FAILED;
          }
       }
@@ -1393,7 +1385,7 @@
          OOTRACEINFO3("Sent Message - MasterSlaveDetermination (%s, %s)\n", 
                        call->callType, call->callToken);
        /* Start MSD timer */
-      cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+      cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                      sizeof(ooTimerCallback));
       if(!cbData)
       {
@@ -1408,7 +1400,7 @@
       {
          OOTRACEERR3("Error:Unable to create MSD timer. "
                      "(%s, %s)\n", call->callType, call->callToken);
-         ASN1MEMFREEPTR(call->pctxt, cbData);
+         memFreePtr(call->pctxt, cbData);
          return OO_FAILED;
       }
 
@@ -1450,7 +1442,7 @@
          OOTRACEINFO3("Sent Message - TerminalCapabilitySet (%s, %s)\n", 
                        call->callType, call->callToken);
       /* Start TCS timer */
-      cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+      cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                      sizeof(ooTimerCallback));
       if(!cbData)
       {
@@ -1465,7 +1457,7 @@
       {
          OOTRACEERR3("Error:Unable to create TCS timer. "
                      "(%s, %s)\n", call->callType, call->callToken);
-         ASN1MEMFREEPTR(call->pctxt, cbData);
+         memFreePtr(call->pctxt, cbData);
          return OO_FAILED;
       }
 
@@ -1494,7 +1486,7 @@
          OOTRACEINFO4("Sent Message - OpenLogicalChannel(%d). (%s, %s)\n", 
                        associatedChan, call->callType, call->callToken);
       /* Start LogicalChannel timer */
-      cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+      cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                      sizeof(ooTimerCallback));
       if(!cbData)
       {
@@ -1511,7 +1503,7 @@
       {
          OOTRACEERR3("Error:Unable to create OpenLogicalChannel timer. "
                      "(%s, %s)\n", call->callType, call->callToken);
-         ASN1MEMFREEPTR(call->pctxt, cbData);
+         memFreePtr(call->pctxt, cbData);
          return OO_FAILED;
       }
       
@@ -1544,7 +1536,7 @@
       { 
          /* Start EndSession timer */
          call->h245SessionState = OO_H245SESSION_ENDSENT;
-         cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+         cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                   sizeof(ooTimerCallback));
          if(!cbData)
          {
@@ -1560,7 +1552,7 @@
          {
             OOTRACEERR3("Error:Unable to create EndSession timer. "
                         "(%s, %s)\n", call->callType, call->callToken);
-            ASN1MEMFREEPTR(call->pctxt, cbData);
+            memFreePtr(call->pctxt, cbData);
             return OO_FAILED;
          }
       }else{
@@ -1575,7 +1567,7 @@
          OOTRACEINFO3("Sent Message - CloseLogicalChannel (%s, %s)\n", 
                        call->callType, call->callToken);
       /* Start LogicalChannel timer */
-      cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+      cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                      sizeof(ooTimerCallback));
       if(!cbData)
       {
@@ -1592,7 +1584,7 @@
       {
          OOTRACEERR3("Error:Unable to create CloseLogicalChannel timer. "
                      "(%s, %s)\n", call->callType, call->callToken);
-         ASN1MEMFREEPTR(call->pctxt, cbData);
+         memFreePtr(call->pctxt, cbData);
          return OO_FAILED;
       }
       
@@ -1613,7 +1605,7 @@
          OOTRACEINFO3("Sent Message - RequestChannelClose (%s, %s)\n", 
                        call->callType, call->callToken);
       /* Start RequestChannelClose timer */
-      cbData = (ooTimerCallback*) ASN1MALLOC(call->pctxt, 
+      cbData = (ooTimerCallback*) memAlloc(call->pctxt, 
                                                      sizeof(ooTimerCallback));
       if(!cbData)
       {
@@ -1630,7 +1622,7 @@
       {
          OOTRACEERR3("Error:Unable to create RequestChannelClose timer. "
                      "(%s, %s)\n", call->callType, call->callToken);
-         ASN1MEMFREEPTR(call->pctxt, cbData);
+         memFreePtr(call->pctxt, cbData);
          return OO_FAILED;
       }
       break;
@@ -1685,3 +1677,44 @@
    }
    return OO_OK;
 }
+
+OOBOOL ooChannelsIsConnectionOK(OOH323CallData *call, OOSOCKET sock)
+{
+   struct timeval to;
+   fd_set readfds;
+   int ret = 0, nfds=0; 
+
+   to.tv_sec = 0;
+   to.tv_usec = 500;
+   FD_ZERO(&readfds);
+
+   FD_SET(sock, &readfds);
+   if(nfds < (int)sock)
+      nfds = (int)sock;
+
+   nfds++;
+
+   ret = ooSocketSelect(nfds, &readfds, NULL, NULL, &to);
+      
+   if(ret == -1)
+   {
+      OOTRACEERR3("Error in select ...broken pipe check(%s, %s)\n",
+                   call->callType, call->callToken );
+      return FALSE;
+   }
+
+   if(FD_ISSET(sock, &readfds))
+   {
+      char buf[2];      
+      if(ooSocketRecvPeek(sock, buf, 2) == 0)
+      {
+         OOTRACEWARN3("Broken pipe detected. (%s, %s)", call->callType, 
+                       call->callToken);
+         if(call->callState < OO_CALL_CLEAR)
+            call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+         call->callState = OO_CALL_CLEARED;
+         return FALSE;
+      }
+   }
+   return TRUE;
+}  

Index: oochannels.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/oochannels.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- oochannels.h	23 May 2005 21:03:55 -0000	1.1
+++ oochannels.h	26 May 2005 13:34:36 -0000	1.2
@@ -25,6 +25,7 @@
 #include "MULTIMEDIA-SYSTEM-CONTROL.h"
 #include "ootypes.h"
 #include "ooSocket.h"
+#include "ooCalls.h"
 
 #define OORECEIVER 1
 #define OOTRANSMITTER 2
@@ -43,6 +44,7 @@
 #endif /* EXTERN */
 
 struct OOH323CallData;
+struct Q931Message;
 
 /** 
  * @defgroup channels Channel Management
@@ -162,7 +164,7 @@
  *
  * @return          OO_OK, on success. OO_FAILED, on failure.
  */
-EXTERN int ooSendH225Msg(struct OOH323CallData *call, Q931Message *msg);
+EXTERN int ooSendH225Msg(struct OOH323CallData *call, struct Q931Message *msg);
 
 /**
  * This function is used to enqueue an H.245 message into an outgoing queue for
@@ -200,7 +202,14 @@
    (struct OOH323CallData *call, int msgType, int tunneledMsgType, 
     int associatedChan);
 
-
+/**
+ * This function is used to check the status of tcp connection. 
+ * @param call     Handle to the call to which connection belongs.
+ * @param sock     Connected socket.
+ *
+ * @return         True if connection is ok, false otherwise.
+ */
+EXTERN OOBOOL ooChannelsIsConnectionOK(OOH323CallData *call, OOSOCKET sock);
 
 /** 
  * @} 

Index: ooh245.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh245.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooh245.c	23 May 2005 21:03:55 -0000	1.1
+++ ooh245.c	26 May 2005 13:34:36 -0000	1.2
@@ -595,8 +595,9 @@
 
    if(ret != OO_OK)
    {
-      OOTRACEERR3("Error:Failed to enqueue MasterSlaveDetermination message to outbound queue. (%s, %s)\n", 
-                      call->callType, call->callToken);
+      OOTRACEERR3("Error:Failed to enqueue MasterSlaveDetermination message to"
+                  " outbound queue. (%s, %s)\n", call->callType, 
+                  call->callToken);
    }else
       call->masterSlaveState = OO_MasterSlave_DetermineSent;
    
@@ -1349,16 +1350,22 @@
                }
 	    }
             ooCloseH245Connection(call);
-      }else{
+         }else{
 
-         call->h245SessionState = OO_H245SESSION_ENDRECVD;
-         if(call->callState < OO_CALL_CLEAR)
-            call->callState = OO_CALL_CLEAR;
-		      /*   if(call->callState < OO_CALL_CLEAR_ENDSESSION)
+            call->h245SessionState = OO_H245SESSION_ENDRECVD;
+#if 0
+            if(call->callState < OO_CALL_CLEAR)
+               call->callState = OO_CALL_CLEAR;
+#else 
+            if(call->logicalChans)
             {
-               ooSendEndSessionCommand(call);
-               call->callState = OO_CALL_CLEAR_ENDSESSION;
-	       }*/
+               OOTRACEINFO3("In response to received EndSessionCommand - "
+                            "Clearing all logical channels. (%s, %s)\n", 
+                            call->callType, call->callToken);
+               ooClearAllLogicalChannels(call);
+	    }
+            ooSendEndSessionCommand(call);
+#endif
          }
             
             

Index: ooh323.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh323.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooh323.c	23 May 2005 21:03:55 -0000	1.1
+++ ooh323.c	26 May 2005 13:34:36 -0000	1.2
@@ -64,25 +64,7 @@
       }
    }
 
-   if(call->h245SessionState != OO_H245SESSION_IDLE && 
-      call->h245SessionState != OO_H245SESSION_CLOSED)
-      ooCloseH245Connection(call);   
-
-   if(call->callState == OO_CALL_CLEAR_RELEASESENT)
-      call->callState = OO_CALL_CLEARED;
-   else{
-      call->callState = OO_CALL_CLEAR_RELEASERECVD;
-
-      if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK))
-      {
-         if(gH323ep.gkClient->state == GkClientRegistered){
-            OOTRACEDBGA3("Sending DRQ after received ReleaseComplete."
-                         "(%s, %s)\n", call->callType, call->callToken);
-            ooGkClientSendDisengageRequest(gH323ep.gkClient, call);
-         }
-      }
-   }
-
+ 
    if(!q931Msg->userInfo)
    {
       OOTRACEERR3("ERROR:No User-User IE in received ReleaseComplete message "
@@ -109,7 +91,7 @@
    if(call->callEndReason == OO_REASON_UNKNOWN)
       call->callEndReason = ooGetCallClearReasonFromCauseAndReasonCode(cause, 
                                                                    reasonCode);
-
+#if 0
    if (q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent &&
        q931Msg->userInfo->h323_uu_pdu.h245Tunneling          &&
        OO_TESTFLAG (call->flags, OO_M_TUNNELING) )
@@ -121,6 +103,26 @@
       OOTRACEDBGB3("Finished handling tunneled messages in ReleaseComplete."
                    " (%s, %s)\n", call->callType, call->callToken);
    }
+#endif
+   if(call->h245SessionState != OO_H245SESSION_IDLE && 
+      call->h245SessionState != OO_H245SESSION_CLOSED)
+   {
+      ooCloseH245Connection(call);
+   }
+
+   if(call->callState != OO_CALL_CLEAR_RELEASESENT)
+   {
+      if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK))
+      {
+         if(gH323ep.gkClient->state == GkClientRegistered){
+            OOTRACEDBGA3("Sending DRQ after received ReleaseComplete."
+                         "(%s, %s)\n", call->callType, call->callToken);
+            ooGkClientSendDisengageRequest(gH323ep.gkClient, call);
+         }
+      }
+   }
+   call->callState = OO_CALL_CLEARED;
+
    return ret;
 }
 
@@ -323,9 +325,8 @@
                                               sizeof(H245OpenLogicalChannel));
          if(!olc)
          {
-            OOTRACEERR3("ERROR:Allocating memory for OLC, in received "
-                        "faststart SETUP message (%s, %s)\n", call->callType, 
-                        call->callToken);
+            OOTRACEERR3("ERROR:Memory - ooOnReceivedSetup - olc (%s, %s)\n", 
+                        call->callType, call->callToken);
             /*Mark call for clearing */
             if(call->callState < OO_CALL_CLEAR)
             {
@@ -431,9 +432,8 @@
                                               sizeof(H245OpenLogicalChannel));
          if(!olc)
          {
-            OOTRACEERR3("ERROR:Allocating memory for OLC, in received "
-                        "faststart CONNECT message (%s, %s)\n", 
-                        call->callType, call->callToken);
+            OOTRACEERR3("ERROR:Memory - ooOnReceivedSignalConnect - olc"
+                        "(%s, %s)\n", call->callType, call->callToken);
             /*Mark call for clearing */
             if(call->callState < OO_CALL_CLEAR)
             {
@@ -596,7 +596,7 @@
          }
       }
    }
-   if (OO_TESTFLAG (call->flags, OO_M_TUNNELING))
+   if (OO_TESTFLAG(call->flags, OO_M_TUNNELING))
    {
       OOTRACEDBGB3("Handling tunneled messages in CONNECT. (%s, %s)\n",
                     call->callType, call->callToken);
@@ -605,26 +605,31 @@
       OOTRACEDBGB3("Finished tunneled messages in Connect. (%s, %s)\n",
                     call->callType, call->callToken);
 
-#if 0
+      /*Send TCS as call established and no capability exchange has yet 
+        started. This will be true only when separate h245 connection is not
+        established and tunneling is being used.*/
       if(call->localTermCapState == OO_LocalTermCapExchange_Idle)
       {
-      /* Start terminal capability exchange and master slave determination */
-      ret = ooSendTermCapMsg(call);
-      if(ret != OO_OK)
-      {
-         OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n",
-                      call->callType, call->callToken);
-         return ret;
+         /*Start terminal capability exchange and master slave determination */
+         ret = ooSendTermCapMsg(call);
+         if(ret != OO_OK)
+         {
+            OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n",
+                         call->callType, call->callToken);
+            return ret;
+         }
       }
-      ret = ooSendMasterSlaveDetermination(call);
-      if(ret != OO_OK)
+      if(call->masterSlaveState == OO_MasterSlave_Idle)
       {
-         OOTRACEERR3("ERROR:Sending Master-slave determination message "
-                  "(%s, %s)\n", call->callType, call->callToken);
-         return ret;
-      }   
+         ret = ooSendMasterSlaveDetermination(call);
+         if(ret != OO_OK)
+         {
+            OOTRACEERR3("ERROR:Sending Master-slave determination message "
+                     "(%s, %s)\n", call->callType, call->callToken);
+            return ret;
+         }   
       }
-#endif
+
    }
    return OO_OK;  
 }
@@ -685,7 +690,7 @@
          OOTRACEINFO3("H.225 Alerting message received (%s, %s)\n", 
                       call->callType, call->callToken);
 
-         if(gH323ep.h323Callbacks.onAlerting)
+         if(gH323ep.h323Callbacks.onAlerting && call->callState<OO_CALL_CLEAR)
             gH323ep.h323Callbacks.onAlerting(call);
          ooFreeQ931Message(q931Msg);
          break;
@@ -982,6 +987,12 @@
                          "(%s, %s)\n",i+1, pH323UUPdu->h245Control.n,
                          call->callType, call->callToken);
             pmsg = (H245Message*)memAlloc(pctxt, sizeof(H245Message));
+            if(!pmsg)
+            {
+               OOTRACEERR3("Error:Memory - ooHandleH245TunneledMessages - pmsg"
+                          "(%s, %s)\n", call->callType, call->callToken);
+               return OO_FAILED;
+            }
 
 	    setPERBuffer(pctxt, 
 			 (ASN1OCTET*)pH323UUPdu->h245Control.elem[i].data,
@@ -1059,6 +1070,14 @@
          newAlias->type = T_H225AliasAddress_dialedDigits;
          newAlias->value = (char*) memAlloc(call->pctxt, 
                          strlen(pAliasAddress->u.dialedDigits)*sizeof(char)+1);
+         if(!newAlias->value)
+         {
+            OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - "
+                        "newAlias->value(dialedDigits) (%s, %s)\n", 
+                         call->callType, call->callToken);
+            memFreePtr(call->pctxt, newAlias);  
+            return OO_FAILED;
+         }
 
          memcpy(newAlias->value, pAliasAddress->u.dialedDigits,
                            strlen(pAliasAddress->u.dialedDigits)*sizeof(char));
@@ -1068,6 +1087,14 @@
          newAlias->type = T_H225AliasAddress_h323_ID;
          newAlias->value = (char*)memAlloc(call->pctxt, 
                          (pAliasAddress->u.h323_ID.nchars+1)*sizeof(char)+1);
+         if(!newAlias->value)
+         {
+            OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - "
+                        "newAlias->value(h323id) (%s, %s)\n", call->callType, 
+                         call->callToken);
+            memFreePtr(call->pctxt, newAlias);  
+            return OO_FAILED;
+         }
 
          for(j=0, k=0; j<(int)pAliasAddress->u.h323_ID.nchars; j++)
          {
@@ -1082,6 +1109,14 @@
          newAlias->type = T_H225AliasAddress_url_ID;
          newAlias->value = (char*)memAlloc(call->pctxt,
                               strlen(pAliasAddress->u.url_ID)*sizeof(char)+1);
+         if(!newAlias->value)
+         {
+            OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - "
+                        "newAlias->value(urlid) (%s, %s)\n", call->callType, 
+                         call->callToken);
+            memFreePtr(call->pctxt, newAlias);  
+            return OO_FAILED;
+         }
 
          memcpy(newAlias->value, pAliasAddress->u.url_ID,
                                strlen(pAliasAddress->u.url_ID)*sizeof(char));
@@ -1111,7 +1146,15 @@
       case T_H225AliasAddress_email_ID:
          newAlias->type = T_H225AliasAddress_email_ID;
          newAlias->value = (char*)memAlloc(call->pctxt, 
-                                  strlen(pAliasAddress->u.email_ID)*sizeof(char)+1);
+                             strlen(pAliasAddress->u.email_ID)*sizeof(char)+1);
+         if(!newAlias->value)
+         {
+            OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - "
+                        "newAlias->value(emailid) (%s, %s)\n", call->callType, 
+                         call->callToken);
+            memFreePtr(call->pctxt, newAlias);  
+            return OO_FAILED;
+         }
 
          memcpy(newAlias->value, pAliasAddress->u.email_ID,
                               strlen(pAliasAddress->u.email_ID)*sizeof(char));
@@ -1154,7 +1197,7 @@
                                                      sizeof(H225AliasAddress));
          if(!pAliasEntry)
          {
-            OOTRACEERR1("ERROR: Failed to allocate memory for alias entry\n");
+            OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - pAliasEntry\n");
             return OO_FAILED;
          }
          switch(pAlias->type)
@@ -1165,8 +1208,9 @@
                                                      strlen(pAlias->value)+1);
             if(!pAliasEntry->u.dialedDigits)
             {
-               OOTRACEERR1("ERROR:Failed to allocated memory for dialedDigits"
-                           " alias entry\n");
+               OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - "
+                           "dialedDigits\n");
+               memFreePtr(pctxt, pAliasEntry);
                return OO_FAILED;
             }
             strcpy((char*)pAliasEntry->u.dialedDigits, pAlias->value);
@@ -1180,8 +1224,8 @@
             
             if(!pAliasEntry->u.h323_ID.data)
             {
-               OOTRACEERR1("Error: Failed to allocate memory for h323id"
-                           " data alias entry\n");
+               OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - h323_id\n");
+               memFreePtr(pctxt, pAliasEntry);
                return OO_FAILED;
             }
             for(i=0; i<(int)strlen(pAlias->value); i++)
@@ -1194,8 +1238,8 @@
                                                      strlen(pAlias->value)+1);
             if(!pAliasEntry->u.url_ID)
             {
-               OOTRACEERR1("ERROR: Failed to allocate memory for urlID alias "
-                           "entry \n");
+               OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - url_id\n");
+               memFreePtr(pctxt, pAliasEntry);               
                return OO_FAILED;
             }
             strcpy((char*)pAliasEntry->u.url_ID, pAlias->value);

Index: ooh323ep.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh323ep.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooh323ep.c	23 May 2005 21:03:55 -0000	1.1
+++ ooh323ep.c	26 May 2005 13:34:36 -0000	1.2
@@ -631,3 +631,75 @@
    }
 
 }
+/* 0-1024 are reserved for well known services */
+int ooH323EpSetTCPPortRange(int base, int max)
+{
+   if(base <= 1024)
+      gH323ep.tcpPorts.start = 1025;
+   else
+      gH323ep.tcpPorts.start = base;
+   if(max > 65500)
+      gH323ep.tcpPorts.max = 65500;
+   else 
+      gH323ep.tcpPorts.max = max;
+
+   if(gH323ep.tcpPorts.max<gH323ep.tcpPorts.start)
+   {
+      OOTRACEERR1("Error: Failed to set tcp ports- "
+                  "Max port number less than Start port number\n");
+      return OO_FAILED;
+   }
+   gH323ep.tcpPorts.current = gH323ep.tcpPorts.start;
+        
+   OOTRACEINFO1("TCP port range initialize - successful\n");
+   return OO_OK;
+}
+
+int ooH323EpSetUDPPortRange(int base, int max)
+{
+   if(base <= 1024)
+      gH323ep.udpPorts.start = 1025;
+   else
+      gH323ep.udpPorts.start = base;
+   if(max > 65500)
+      gH323ep.udpPorts.max = 65500;
+   else 
+      gH323ep.udpPorts.max = max;
+        
+   if(gH323ep.udpPorts.max<gH323ep.udpPorts.start)
+   {
+      OOTRACEERR1("Error: Failed to set udp ports- Max port number"
+                  " less than Start port number\n");
+      return OO_FAILED;
+   }
+        
+   gH323ep.udpPorts.current = gH323ep.udpPorts.start;
+        
+   OOTRACEINFO1("UDP port range initialize - successful\n");
+
+   return OO_OK;
+}
+
+int ooH323EpSetRTPPortRange(int base, int max)
+{
+   if(base <= 1024)
+      gH323ep.rtpPorts.start = 1025;
+   else
+      gH323ep.rtpPorts.start = base;
+   if(max > 65500)
+      gH323ep.rtpPorts.max = 65500;
+   else 
+      gH323ep.rtpPorts.max = max;
+        
+   if(gH323ep.rtpPorts.max<gH323ep.rtpPorts.start)
+   {
+      OOTRACEERR1("Error: Failed to set rtp ports- Max port number"
+                  " less than Start port number\n");
+      return OO_FAILED;
+   }
+        
+   gH323ep.rtpPorts.current = gH323ep.rtpPorts.start;
+   OOTRACEINFO1("RTP port range initialize - successful\n");
+   return OO_OK;
+}
+

Index: ooh323ep.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooh323ep.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooh323ep.h	23 May 2005 21:03:55 -0000	1.1
+++ ooh323ep.h	26 May 2005 13:34:36 -0000	1.2
@@ -22,6 +22,7 @@
 #include "ooCapability.h"
 #include "ooCalls.h"
 #include "ooGkClient.h"
+#include "ooports.h"
 
 #define DEFAULT_TRACEFILE "trace.log"
 #define DEFAULT_TERMTYPE 50
@@ -147,6 +148,36 @@
 EXTERN int ooH323EpSetLocalAddress(char * localip, int listenport);
 
 /**
+ * This function is used to set the range of tcp ports the application will
+ * use for tcp transport.
+ * @param base           Starting port number for the range
+ * @param max            Ending port number for the range.
+ *
+ * @return               OO_OK, on success. OO_FAILED, on failure.    
+ */
+EXTERN int ooH323EpSetTCPPortRange(int base, int max);
+
+/**
+ * This function is used to set the range of udp ports the application will
+ * use for udp transport.
+ * @param base           Starting port number for the range
+ * @param max            Ending port number for the range.
+ *
+ * @return               OO_OK, on success. OO_FAILED, on failure.    
+ */
+EXTERN int ooH323EpSetUDPPortRange(int base, int max);
+
+/**
+ * This function is used to set the range of rtp ports the application will
+ * use for media streams.
+ * @param base           Starting port number for the range
+ * @param max            Ending port number for the range.
+ *
+ * @return               OO_OK, on success. OO_FAILED, on failure.    
+ */
+EXTERN int ooH323EpSetRTPPortRange(int base, int max);
+
+/**
  * This function is used to set the trace level for the H.323 endpoint.
  * @param traceLevel     Level of tracing.
  *

Index: ooports.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooports.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooports.c	23 May 2005 21:03:55 -0000	1.1
+++ ooports.c	26 May 2005 13:34:36 -0000	1.2
@@ -22,83 +22,6 @@
 /** Global endpoint structure */
 extern OOH323EndPoint gH323ep;
 
-int ooSetTCPPorts( int start, int max)
-{
-   if(start < 1024)
-      gH323ep.tcpPorts.start = 1024;
-   else
-      gH323ep.tcpPorts.start = start;
-   if(max > 65500)
-      gH323ep.tcpPorts.max = 65500;
-   else 
-      gH323ep.tcpPorts.max = max;
-
-   if(gH323ep.tcpPorts.max<gH323ep.tcpPorts.start)
-   {
-      OOTRACEERR1("Error: Failed to set tcp ports- "
-                  "Max port number less than Start port number\n");
-      return OO_FAILED;
-   }
-   gH323ep.tcpPorts.current = start;
-        
-   OOTRACEINFO1("TCP port range initialize - successful\n");
-   return OO_OK;
-}
-
-/* Sets the range of ports that can be potentially used for UDP
-   transport
-*/
-int ooSetUDPPorts(int start, int max)
-{
-   if(start < 1024)
-      gH323ep.udpPorts.start = 1024;
-   else
-      gH323ep.udpPorts.start = start;
-   if(max > 65500)
-      gH323ep.udpPorts.max = 65500;
-   else 
-      gH323ep.udpPorts.max = max;
-        
-   if(gH323ep.udpPorts.max<gH323ep.udpPorts.start)
-   {
-      OOTRACEERR1("Error: Failed to set udp ports- Max port number"
-                  " less than Start port number\n");
-      return OO_FAILED;
-   }
-        
-   gH323ep.udpPorts.current = start;
-        
-   OOTRACEINFO1("UDP port range initialize - successful\n");
-
-   return OO_OK;
-}
-
-/* Sets the range of ports that can be potentially used for RTP
-   RTCP transport
-*/
-int ooSetRTPPorts(int start, int max)
-{
-   if(start < 1024)
-      gH323ep.rtpPorts.start = 1024;
-   else
-      gH323ep.rtpPorts.start = start;
-   if(max > 65500)
-      gH323ep.rtpPorts.max = 65500;
-   else 
-      gH323ep.rtpPorts.max = max;
-        
-   if(gH323ep.rtpPorts.max<gH323ep.rtpPorts.start)
-   {
-      OOTRACEERR1("Error: Failed to set rtp ports- Max port number"
-                  " less than Start port number\n");
-      return OO_FAILED;
-   }
-        
-   gH323ep.rtpPorts.current = start;
-   OOTRACEINFO1("RTP port range initialize - successful\n");
-   return OO_OK;
-}
-
 /* Get the next port of type TCP/UDP/RTP */
 int ooGetNextPort (OOH323PortType type)
 {

Index: ooports.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooports.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooports.h	23 May 2005 21:03:55 -0000	1.1
+++ ooports.h	26 May 2005 13:34:36 -0000	1.2
@@ -42,44 +42,6 @@
 #endif /* EXTERN */
 
 /**
- * Sets the range of ports that can be potentially used for TCP 
- * connections.
- *
- * @param start     Starting port number for the range.
- * @param max       Ending port number for the range
- *
- * @return          Completion status of operation: 0 (OO_OK) = success,
- *                  negative return value is error.
- */
-EXTERN int ooSetTCPPorts(int start, int max);
-
-/**
- *  Sets the range of ports that can be potentially used for UDP
- *  transport
- *
- * @param start     Starting port number for the range.
- * @param max       Ending port number for the range
- *
- * @return          Completion status of operation: 0 (OO_OK) = success,
- *                  negative return value is error.
- */
-
-EXTERN int ooSetUDPPorts(int start, int max);
-
-/**
- * Sets the range of ports that can be potentially used for RTP
- * RTCP transport.
- *
- * @param start     Starting port number for the range.
- * @param max       Ending port number for the range
- *
- * @return           Completion status of operation: 0 (OO_OK) = success,
- *                   negative return value is error.
- */
-
-EXTERN int ooSetRTPPorts(int start, int max);
-
-/**
  * Get the next port of type TCP/UDP/RTP from the corresponding range.
  * When max value for the range is reached, it starts again from the 
  * first port number of the range.

Index: ooq931.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooq931.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooq931.c	23 May 2005 21:03:55 -0000	1.1
+++ ooq931.c	26 May 2005 13:34:36 -0000	1.2
@@ -1676,7 +1676,11 @@
       {
          OOTRACEERR3("ERROR:Failed to create H225 connection to %s:%d\n", 
                       call->remoteIP, call->remotePort);
-         ooCleanCall(call);
+         if(call->callState< OO_CALL_CLEAR)
+         {
+            call->callState = OO_CALL_CLEAR;
+            call->callEndReason = OO_REASON_UNKNOWN;
+         }
          return OO_FAILED;
       }
       

Index: ooq931.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ooq931.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ooq931.h	23 May 2005 21:03:55 -0000	1.1
+++ ooq931.h	26 May 2005 13:34:36 -0000	1.2
@@ -228,6 +228,26 @@
    ASN1OCTET data[1];
 } Q931InformationElement;
 
+/**
+ * Q.931 message structure. Contains context for memory allocation, 
+ * protocol discriminator, call reference, meesage type and list of 
+ * user-user information elements (IEs).
+ */
+typedef struct Q931Message {
+   ASN1UINT protocolDiscriminator;
+   ASN1UINT callReference;
+   ASN1BOOL fromDestination;
+   ASN1UINT messageType;      /* Q931MsgTypes */
+   ASN1UINT tunneledMsgType;  /* The H245 message this message is tunneling*/
+   ASN1INT  logicalChannelNo; /* channel number associated with tunneled */
+                              /* message, 0 if no channel */
+   DList ies;    
+   Q931InformationElement *bearerCapabilityIE;
+   Q931InformationElement *callingPartyNumberIE;
+   Q931InformationElement *calledPartyNumberIE;
+   Q931InformationElement *causeIE;
+   H225H323_UserInformation *userInfo;
+} Q931Message;
 
 struct OOH323CallData;
 

Index: ootypes.h
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/ooh323c/src/ootypes.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ootypes.h	23 May 2005 21:03:55 -0000	1.1
+++ ootypes.h	26 May 2005 13:34:36 -0000	1.2
@@ -13,11 +13,39 @@
  * maintain this copyright notice.
  *
  *****************************************************************************/
+/*! \mainpage 
+ * <H1>ooH323c Stack Functions</H1>
+ *
+ * The <B>Objective Open H.323 for C (ooH323c)</B> protocol stack is an 
+ * open source applications program interface (API) for building H.323 based 
+ * applications.   The stack implements Q.931/H.225 call signaling procedures, 
+ * H.245 logical channel operations, and Registration, Admission, and Status 
+ * (RAS) messaging for Gatekeeper communications.
+ *
+ * The categories of user functions provided are as follows:<UL>
+ * <LI>Stack command functions.  These are high level functions used to 
+ * initiate common H.323 telephony operations (for example, to make a 
+ * call).</LI>
+ * <LI>Gatekeeper functions.  These are high level functions for 
+ * managing communications with a gatekeeper using RAS messages.</LI>
+ * <LI>H.323 endpoint management functions.  These are function for 
+ * used for managing the global H.323 endpoint.</LI>
+ * <LI>Call management functions.  These are functions used to manage 
+ * active calls within the stack.</LI>
+ * <LI>Capability management functions.  These functions are used for 
+ * negotiating capabilities between two different terminals.</LI>
+ * <LI>H.225 and H.245 message handling functions.  Functions for 
+ * creating and handling H.323 standard ASN.1 messages.</LI>
+ * <LI>Q.931 functions.  Functions for the execution of various 
+ * standard Q.931 operations.</LI>
+ * <LI>TCP/IP and UDP socket communication functions.  Low-level 
+ * functions for writing data to and receiving data from sockets.</LI>
+ * </UL>
+ */ 
 /**
  * @file ootypes.h 
- * This file contains the definitions of common constants and data structures 
+ * This file contains definitions of common constants and data structures.
  */
-
 #ifndef _OOTYPES_H_
 #define _OOTYPES_H_
 
@@ -29,15 +57,19 @@
 
 #define OOH323C_VERSION "v0.6.1"
 
-/*  types */
-#define OO_FAILED -1
-#define OO_OK 1
+/** 
+ * @defgroup ootypes Common type and constant definitions.
+ * @{
+ */
+/* Function return codes */
+#define OO_FAILED	-1
+#define OO_OK		0
 
-/**
-  Various states of master slave determination prcedure
-*/
-/*TODO: States for both local and remote initiation should be maintained
+/* TODO: States for both local and remote initiation should be maintained
    separately */
+/**
+ * States defined for master/slave determination procedure.
+ */
 typedef enum OOMasterSlaveState {
    OO_MasterSlave_Idle,
    OO_MasterSlave_DetermineSent, 
@@ -46,7 +78,9 @@
    OO_MasterSlave_Slave
 } OOMasterSlaveState;
 
-/** States for Capability Exchange Procedure */
+/** 
+ * States defined for the capability exchange procedure. 
+ */
 typedef enum {
    OO_LocalTermCapExchange_Idle, 
    OO_LocalTermCapSetSent, 
@@ -56,7 +90,9 @@
    OO_RemoteTermCapSetAckSent
 } OOCapExchangeState;
 
-/** Call Clear Reasons */
+/** 
+ * Call clear reason codes.
+ */
 typedef enum OOCallClearReason {
    OO_REASON_UNKNOWN=0, 
    OO_REASON_INVALIDMESSAGE,
@@ -84,19 +120,23 @@
    OO_REASON_LOCAL_CONGESTED
 } OOCallClearReason;
 
-/** call states */
+/** 
+ * Call states.
+ */
 typedef enum {
-   OO_CALL_CREATED, 
-   OO_CALL_WAITING_ADMISSION, 
-   OO_CALL_CONNECTING, 
-   OO_CALL_CONNECTED,
-   OO_CALL_CLEAR,             /* call marked for clearing */
-   OO_CALL_CLEAR_RELEASERECVD,
-   OO_CALL_CLEAR_RELEASESENT,     /* Release Sent */
-   OO_CALL_CLEARED            /* Call Cleared */
+   OO_CALL_CREATED,               /*!< Call created. */
+   OO_CALL_WAITING_ADMISSION,     /*!< Call waiting for admission by GK */
+   OO_CALL_CONNECTING,            /*!< Call in process of connecting */
+   OO_CALL_CONNECTED,             /*!< Call currently connected. */
+   OO_CALL_CLEAR,                 /*!< Call marked for clearing */
+   OO_CALL_CLEAR_RELEASERECVD,    /*!< Release command received. */
+   OO_CALL_CLEAR_RELEASESENT,     /*!< Release sent */
+   OO_CALL_CLEARED                /*!< Call cleared */
 } OOCallState;
 
-/** H245 Session state */
+/** 
+ * H.245 session state 
+ */
 typedef enum {
    OO_H245SESSION_IDLE,
    OO_H245SESSION_ACTIVE,
@@ -105,7 +145,9 @@
    OO_H245SESSION_CLOSED
 } OOH245SessionState;
 
-/** Logical Channel states */
+/** 
+ * Logical channel states.
+ */
 typedef enum {
    OO_LOGICAL_CHAN_UNKNOWN, 
    OO_LOGICALCHAN_IDLE, 
@@ -113,12 +155,18 @@
    OO_LOGICALCHAN_ESTABLISHED
 } OOLogicalChannelState;
 
-/**
-   Terminal type of the endpoint. Default is 60.
-*/
+/** Terminal type of the endpoint. Default is 60. */
 #define OOTERMTYPE 60
+
+/** Maximum length of an IP address (xxx.xxx.xxx.xxx). */
 #define MAX_IP_LENGTH 15
+
+/** Maximum length of a log file message */
 #define MAXLOGMSGLEN 2048
+
+/** Number of times to retry a failed operation. */
+#define DEFAULT_MAX_RETRIES 3
+
 /**
    Various message types for H225 and H245 messages
 */
@@ -163,60 +211,44 @@
 #define OO_RCC_TIMER       (1<<5)
 #define OO_SESSION_TIMER   (1<<6)
 
-/**
-  Default port ranges used
-*/
-#define TCPPORTSSTART 12030
-#define TCPPORTSEND   12230
-#define UDPPORTSSTART 13030
-#define UDPPORTSEND   13230
-#define RTPPORTSSTART 14030
-#define RTPPORTSEND   14230
+/* Default port ranges */
+#define TCPPORTSSTART 12030  /*!< Starting TCP port number */
+#define TCPPORTSEND   12230  /*!< Ending TCP port number   */
+#define UDPPORTSSTART 13030  /*!< Starting UDP port number */
+#define UDPPORTSEND   13230  /*!< Ending UDP port number   */
+#define RTPPORTSSTART 14030  /*!< Starting RTP port number */
+#define RTPPORTSEND   14230  /*!< Ending RTP port number   */
 
-/**
- Maximum length for received messages 
-*/
+/** Maximum length for received messages */
 #define MAXMSGLEN 4096
-#define MAXFILENAME 256
-
-#define OO_CMD_MAKECALL      201
-#define OO_CMD_ANSCALL       202
-#define OO_CMD_FWDCALL       203
-#define OO_CMD_HANGCALL      204
-#define OO_CMD_STOPMONITOR   205
 
+/** Maximum length of a filename */
+#define MAXFILENAME 256
 
 /**
- Endpoint call modes. The call mode of the endpoint dictates what type
- of channels are created for the calls placed by the endpoint or received
- by the endpoint.
-*/
+ * Endpoint call modes. The call mode of the endpoint dictates what type
+ * of channels are created for the calls placed by the endpoint or received
+ * by the endpoint.
+ */
 typedef enum OOCallMode {
-   OO_CALLMODE_AUDIOCALL, 
-   OO_CALLMODE_AUDIORX,
-   OO_CALLMODE_AUDIOTX,
-   OO_CALLMODE_VIDEOCALL, 
-   OO_CALLMODE_FAX
+   OO_CALLMODE_AUDIOCALL,   /*!< Audio call */
+   OO_CALLMODE_AUDIORX,     /*!< Audio call - receive only */
+   OO_CALLMODE_AUDIOTX,     /*!< Audio call - transmit only */
+   OO_CALLMODE_VIDEOCALL,   /*!< Video call */
+   OO_CALLMODE_FAX          /*!< Fax transmission */
 } OOCallMode;
 
 /*
  * Flag macros - these operate on bit mask flags using mask values
  */
+/** This macro sets a flag within a bit mask */
 #define OO_SETFLAG(flags,mask) (flags |= mask)
-#define OO_CLRFLAG(flags,mask) (flags &= ~mask)
-#define OO_TESTFLAG(flags,mask) ((flags & mask) != 0)
 
-#define DEFAULT_MAX_RETRIES 3
-/** Type of callback functions to be registered at the time of
- * channel creation.
- */
-typedef int (*ChannelCallback)(void*);
+/** This macro clears a flag within a bit mask */
+#define OO_CLRFLAG(flags,mask) (flags &= ~mask)
 
-/**
- * Type of callback function registered at initialization
- * for handling commands
- */
-typedef int (*CommandCallback)(void);
+/** This macro tests a flag with a bit mask */
+#define OO_TESTFLAG(flags,mask) ((flags & mask) != 0)
 
 /* Define common mutex type */
 #ifdef _WIN32
@@ -225,23 +257,18 @@
 #define OO_MUTEX pthread_mutex_t
 #endif
 
-/**
- * Structure for stack commands */
-typedef struct ooCommand {
-   int type;
-   void * param1;
-   void * param2;
-   void * param3;
-} ooCommand;
-
-
 /*TODO: Should add caller-id, callername etc. So that they can be changed per
   call basis*/
+/**
+ * This structure defines options that can be set at the level of an 
+ * individual call. They override options set in the H.323 endpoint 
+ * structure.
+ */
 typedef struct ooCallOptions {
-   OOBOOL fastStart; /* faststart for this call. overrides endpoint setting*/
-   OOBOOL tunneling; /* tunneling for this call. overrides endpoint setting*/
-   OOBOOL disableGk; /* If gk is enabled, then you can avoid going through gk for a specific call */
-   OOCallMode callMode; /* Effective when faststart is used. Tells stack which type of channels to setup*/
+   OOBOOL fastStart;    /*!< Use FastStart signaling */
+   OOBOOL tunneling;    /*!< Use H.245 tunneling */
+   OOBOOL disableGk;    /*!< Disable use of gatekeeper */
+   OOCallMode callMode; /*!< Type of channel to setup with FastStart */
 }ooCallOptions;
  
 /**
@@ -255,28 +282,6 @@
    int current;
 };
 
-struct Q931InformationElement;
-/**
- Defines the Q931 message structure. Contains
- context for memory allocation, protocol Discriminator,
- call reference, meesage type and list of user user IEs.
-*/
-typedef struct Q931Message {
-   ASN1UINT protocolDiscriminator;
-   ASN1UINT callReference;
-   ASN1BOOL fromDestination;
-   ASN1UINT messageType;      /* Q931MsgTypes */
-   ASN1UINT tunneledMsgType;  /* The H245 message this message is tunneling*/
-   ASN1INT  logicalChannelNo; /* channel number associated with tunneled */
-                              /* message, 0 if no channel */
-   DList ies;    
-   struct Q931InformationElement *bearerCapabilityIE;
-   struct Q931InformationElement *callingPartyNumberIE;
-   struct Q931InformationElement *calledPartyNumberIE;
-   struct Q931InformationElement *causeIE;
-   H225H323_UserInformation *userInfo;
-} Q931Message;
-
 /**
  Defines the H245 message structure. All request/response
  and command messages are represented using this structure.
@@ -356,6 +361,7 @@
    OOBOOL fwdedByRemote; /*Set when we are being fwded by remote*/
 }OOCallFwdData;      
 
+struct Q931Message;
 /**
  * These are message callbacks which can be used by user applications
  * to perform application specific things on receiving a particular 
@@ -364,16 +370,16 @@
  * sent out.
  */
 typedef int (*cb_OnReceivedSetup)
-   (struct OOH323CallData *call, Q931Message *pmsg);
+   (struct OOH323CallData *call, struct Q931Message *pmsg);
 
 typedef int (*cb_OnReceivedConnect)
-   (struct OOH323CallData *call, Q931Message *pmsg);
+   (struct OOH323CallData *call, struct Q931Message *pmsg);
 
 typedef int (*cb_OnBuiltSetup)
-   (struct OOH323CallData *call, Q931Message *pmsg);
+   (struct OOH323CallData *call, struct Q931Message *pmsg);
 
 typedef int (*cb_OnBuiltConnect)
-   (struct OOH323CallData *call, Q931Message *pmsg);
+   (struct OOH323CallData *call, struct Q931Message *pmsg);
 
 typedef struct OOH225MsgCallbacks{
    cb_OnReceivedSetup onReceivedSetup;
@@ -383,7 +389,15 @@
 }OOH225MsgCallbacks;
 
 
+/**
+ * This callback function is triggered when a new call structure is 
+ * created inside the stack for an incoming or outgoing call.
+ *
+ * @param call H.323 call data structure
+ * @return 0 if callback was successful, non-zero error code if failure.
+ */
 typedef int (*cb_OnNewCallCreated)(struct OOH323CallData * call);
+
 typedef int (*cb_OnAlerting)(struct OOH323CallData * call);
 typedef int (*cb_OnIncomingCall)(struct OOH323CallData* call );
 typedef int (*cb_OnOutgoingCall)(struct OOH323CallData* call );
@@ -409,5 +423,8 @@
    cb_OpenLogicalChannels openLogicalChannels;
 } OOH323CALLBACKS;
 
+/**
+ * @}
+ */
 #endif
 




More information about the svn-commits mailing list