AST_CONTROL_CONNECTED_LINE frame type processing added to setup DisplayIE field
authorAlexandr Anikin <may@telecom-service.ru>
Sun, 24 Jan 2010 22:42:11 +0000 (22:42 +0000)
committerAlexandr Anikin <may@telecom-service.ru>
Sun, 24 Jan 2010 22:42:11 +0000 (22:42 +0000)
incorrect q.931 message order filtered on incoming calls (first msg must be setup,
next must be not setup)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242645 65c4cc65-6c06-0410-ace0-fbb531ad65f3

addons/chan_ooh323.c
addons/ooh323c/src/ooCmdChannel.c
addons/ooh323c/src/ooStackCmds.c
addons/ooh323c/src/ooStackCmds.h
addons/ooh323c/src/oochannels.c
addons/ooh323c/src/ooh323.c

index 1d012a9..9c2ce6f 100644 (file)
@@ -902,6 +902,10 @@ static int ooh323_call(struct ast_channel *ast, char *dest, int timeout)
                if(p->callerid_name)
                        free(p->callerid_name);
                p->callerid_name = strdup(ast->connected.id.name);
+       } else if (ast->connected.id.number) {
+               if(p->callerid_name)
+                       free(p->callerid_name);
+               p->callerid_name = strdup(ast->connected.id.number);
        } else {
                ast->connected.id.name = strdup(gCallerID);
                if(p->callerid_name)
@@ -1206,6 +1210,13 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
                ast_rtp_instance_new_source(p->rtp);
                break;
 
+      case AST_CONTROL_CONNECTED_LINE:
+               if (gH323Debug)
+                       ast_log(LOG_DEBUG, "Sending connected line info for %s (%s)\n",
+                               callToken, ast->connected.id.name);
+               ooSetANI(callToken, ast->connected.id.name);
+               break;
+
       case AST_CONTROL_T38_PARAMETERS:
                if (p->t38support != T38_ENABLED) {
                        struct ast_control_t38_parameters parameters = { .request_response = 0 };
index 003a5df..27a28a2 100644 (file)
@@ -402,6 +402,15 @@ int ooReadAndProcessCallStackCommand(OOH323CallData* call)
               ooSendRequestMode(call, *(int *)cmd.param2);
               break;
 
+           case OO_CMD_SETANI:
+               OOTRACEINFO3("Processing SetANI command %s, ani is %s\n",
+                               (char *)cmd.param1, (char *)cmd.param2);
+               if(cmd.param2) {
+                       strncpy(call->ourCallerId, cmd.param2, sizeof(call->ourCallerId)-1);
+                       call->ourCallerId[sizeof(call->ourCallerId)-1] = '\0';
+               }
+               break;
+
             default: OOTRACEERR1("ERROR:Unknown command\n");
          }
       }
index f09d334..4c732d5 100644 (file)
@@ -494,6 +494,54 @@ OOStkCmdStat ooSendDTMFDigit(const char *callToken, const char* dtmf)
    return OO_STKCMD_SUCCESS;
 }
 
+OOStkCmdStat ooSetANI(const char *callToken, const char* ani)
+{
+   OOStackCommand cmd;
+   OOH323CallData *call;
+
+   if(!callToken)
+   {
+      return OO_STKCMD_INVALIDPARAM;
+   }
+
+   if(!(call = ooFindCallByToken(callToken))) {
+      return OO_STKCMD_INVALIDPARAM;
+   }
+
+   if(call->CmdChan == 0)
+   {
+      if(ooCreateCallCmdConnection(call) != OO_OK)
+         return OO_STKCMD_CONNECTIONERR;
+   }
+
+   memset(&cmd, 0, sizeof(OOStackCommand));
+   cmd.type = OO_CMD_SETANI;
+
+   cmd.param1 = (void*) malloc(strlen(callToken)+1);
+   cmd.param2 = (void*) malloc(strlen(ani)+1);
+   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);
+   cmd.plen1 = strlen(callToken);
+   strcpy((char*)cmd.param2, ani);
+   cmd.plen2 = strlen(ani);
+   
+   if(ooWriteCallStackCommand(call,&cmd) != OO_OK)
+   {
+      free(cmd.param1);
+      free(cmd.param2);
+      return OO_STKCMD_WRITEERR;
+   }
+   free(cmd.param1);
+   free(cmd.param2);
+
+   return OO_STKCMD_SUCCESS;
+}
+
 OOStkCmdStat ooRequestChangeMode(const char *callToken, int isT38Mode)
 {
    OOStackCommand cmd;
index 3fd1a8d..dc6a212 100644 (file)
@@ -67,7 +67,8 @@ typedef enum OOStackCmdID {
    OO_CMD_MANUALRINGBACK,    /*!< Send Alerting - ringback */
    OO_CMD_MANUALPROGRESS,    /*!< Send progress */
    OO_CMD_STOPMONITOR,       /*!< Stop the event monitor */
-   OO_CMD_REQMODE           /*!< Request new mode */
+   OO_CMD_REQMODE,          /*!< Request new mode */
+   OO_CMD_SETANI            /*! <Set conncted info */
    
 } OOStackCmdID;
 
@@ -176,6 +177,8 @@ EXTERN OOStkCmdStat ooRunCall(const char* dest, char* callToken, size_t bufsiz,
 
 int ooGenerateOutgoingCallToken (char *callToken, size_t size);
 
+EXTERN OOStkCmdStat ooSetANI(const char *callToken, const char* ani);
+
 #ifdef __cplusplus
 }
 #endif
index fd6cbb3..2b2f0b4 100644 (file)
@@ -1124,7 +1124,7 @@ int ooH2250Receive(OOH323CallData *call)
    finishPrint();
    removeEventHandler(pctxt);
    if(ret == OO_OK) {
-      ooHandleH2250Message(call, pmsg);
+      ret = ooHandleH2250Message(call, pmsg);
    }
    return ret;
 }
index 971b668..59b6afd 100644 (file)
@@ -1533,6 +1533,17 @@ int ooHandleH2250Message(OOH323CallData *call, Q931Message *q931Msg)
    OOTimer *pTimer=NULL;
    int type = q931Msg->messageType;
    struct timespec ts;
+
+/* checking of message validity for first/next messages of calls */
+
+   if (!strcmp(call->callType, "incoming")) {
+       if ((call->callState != OO_CALL_CREATED && type == Q931SetupMsg) ||
+           (call->callState == OO_CALL_CREATED && type != Q931SetupMsg)) {
+               ooFreeQ931Message(call->msgctxt, q931Msg);
+               return OO_FAILED;
+       }
+   }
+
    switch(type)
    {
       case Q931SetupMsg: /* SETUP message is received */