示例#1
0
int isRunning(char *callToken) {
  OOH323CallData *call;

  if((call = ooFindCallByToken(callToken)))
   if (call->Monitor)
    return 1;
  return 0;
}
示例#2
0
OOStkCmdStat ooHangCall(const char* callToken, OOCallClearReason reason, int q931cause)
{
   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_HANGCALL;
   cmd.param1 = (void*) malloc(strlen(callToken)+1);
   cmd.param2 = (void*) malloc(sizeof(OOCallClearReason));
   cmd.param3 = (void*) malloc(sizeof(int));
   if(!cmd.param1 || !cmd.param2 || !cmd.param3)
   {
      if(cmd.param1)   free(cmd.param1); /* Release memory */
      if(cmd.param2)   free(cmd.param2);
      if(cmd.param3)   free(cmd.param3);
      return OO_STKCMD_MEMERR;
   }
   strcpy((char*)cmd.param1, callToken);
   cmd.plen1 = strlen(callToken);
   *((OOCallClearReason*)cmd.param2) = reason;
   cmd.plen2 = sizeof(OOCallClearReason);
   *(int *)cmd.param3 = q931cause;
   cmd.plen3 = sizeof(int);

   if(ooWriteCallStackCommand(call, &cmd) != OO_OK)
   {
      free(cmd.param1);
      free(cmd.param2);
      free(cmd.param3);
      return OO_STKCMD_WRITEERR;
   }
   free(cmd.param1);
   free(cmd.param2);
   free(cmd.param3);
   
   return OO_STKCMD_SUCCESS;
}
示例#3
0
OOStkCmdStat ooRequestChangeMode(const char *callToken, int isT38Mode)
{
   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_REQMODE;

   cmd.param1 = (void*) malloc(strlen(callToken)+1);
   cmd.param2 = (void*) malloc(sizeof(int));
   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);
   *((int *) cmd.param2) = isT38Mode;
   cmd.plen2 = sizeof(int);
   
   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;
}
示例#4
0
OOStkCmdStat ooSendDTMFDigit(const char *callToken, const char* dtmf)
{
   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_SENDDIGIT;

   cmd.param1 = (void*) malloc(strlen(callToken)+1);
   cmd.param2 = (void*) malloc(strlen(dtmf)+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, dtmf);
   cmd.plen2 = strlen(dtmf);
   
   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;
}
示例#5
0
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 = ast_malloc(strlen(callToken)+1);
   cmd.param2 = ast_malloc(strlen(ani)+1);
   if(!cmd.param1 || !cmd.param2)
   {
      if(cmd.param1)   ast_free(cmd.param1); /* Release memory */
      if(cmd.param2)   ast_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)
   {
      ast_free(cmd.param1);
      ast_free(cmd.param2);
      return OO_STKCMD_WRITEERR;
   }
   ast_free(cmd.param1);
   ast_free(cmd.param2);

   return OO_STKCMD_SUCCESS;
}
示例#6
0
OOStkCmdStat ooManualProgress(const char *callToken)
{
   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;
   }

   if (call->h225version < 4)
      return OO_STKCMD_SUCCESS;

   memset(&cmd, 0, sizeof(OOStackCommand));
   cmd.type = OO_CMD_MANUALPROGRESS;
   cmd.param1 = (void*) malloc(strlen(callToken)+1);
   if(!cmd.param1)
   {
      return OO_STKCMD_MEMERR;
   }
   strcpy((char*)cmd.param1, callToken);
   cmd.plen1 = strlen(callToken);
   
   if(ooWriteCallStackCommand(call, &cmd) != OO_OK)
   {
      free(cmd.param1);
      return OO_STKCMD_WRITEERR;
   }

   free(cmd.param1);

   return OO_STKCMD_SUCCESS;
}
示例#7
0
OOStkCmdStat ooAnswerCall(const char *callToken)
{
   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_ANSCALL;

   cmd.param1 = ast_malloc(strlen(callToken)+1);
   if(!cmd.param1)
   {
      return OO_STKCMD_MEMERR;
   }
   strcpy((char*)cmd.param1, callToken);
   cmd.plen1 = strlen(callToken);   

   if(ooWriteCallStackCommand(call, &cmd) != OO_OK)
   {
      ast_free(cmd.param1);
      return OO_STKCMD_WRITEERR;
   }

   ast_free(cmd.param1);

   return OO_STKCMD_SUCCESS;
}
示例#8
0
OOStkCmdStat ooRunCall 
   (const char* dest, char* callToken, size_t bufsiz, ooCallOptions *opts)
{
   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;
   }

   if(!callToken)
      return OO_STKCMD_INVALIDPARAM;
  

   memset(&cmd, 0, sizeof(OOStackCommand));
   cmd.type = OO_CMD_MAKECALL;
   cmd.param1 = (void*) malloc(strlen(dest)+1);
   if(!cmd.param1)
   {
      return OO_STKCMD_MEMERR;
   }
   strcpy((char*)cmd.param1, dest);
   cmd.plen1 = strlen(dest);

  
   cmd.param2 = (void*) malloc(strlen(callToken)+1);
   if(!cmd.param2)
   {
      free(cmd.param1);
      return OO_STKCMD_MEMERR;
   }
   
   strcpy((char*)cmd.param2, callToken);
   cmd.plen2 = strlen(callToken);

   if(!opts)
   {
      cmd.param3 = 0;
   }
   else {
      cmd.param3 = (void*) malloc(sizeof(ooCallOptions));
      if(!cmd.param3)
      {
         free(cmd.param1);
         free(cmd.param2);
         return OO_STKCMD_MEMERR;
      }
      memcpy((void*)cmd.param3, opts, sizeof(ooCallOptions));
      cmd.plen3 = sizeof(ooCallOptions);
   }

   if(ooWriteCallStackCommand(call, &cmd) != OO_OK)
   {
      free(cmd.param1);
      free(cmd.param2);
      if(cmd.param3) free(cmd.param3);
      return OO_STKCMD_WRITEERR;
   }


   free(cmd.param1);
   free(cmd.param2);
   if(cmd.param3) free(cmd.param3);

   return OO_STKCMD_SUCCESS;
}
示例#9
0
OOStkCmdStat ooUpdateLogChannels(const char *callToken, const char* localIP, int port)
{
   OOStackCommand cmd;
   OOH323CallData *call;

   if (!callToken) {
      return OO_STKCMD_INVALIDPARAM;
   }

   if (!(call = ooFindCallByToken(callToken))) {
      return OO_STKCMD_INVALIDPARAM;
   }

   if (localIP == NULL) {
      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_UPDLC;

   cmd.param1 = ast_malloc(strlen(callToken) + 1);
   cmd.param2 = ast_malloc(strlen(localIP) + 1);
   cmd.param3 = ast_malloc(sizeof(int) + 1);
   if (!cmd.param1 || !cmd.param2 || !cmd.param3) {
      if (cmd.param1) {
	ast_free(cmd.param1); /* Release memory */
      }
      if (cmd.param2) {
	ast_free(cmd.param2);
      }
      if (cmd.param3) {
	ast_free(cmd.param3);
      }
      return OO_STKCMD_MEMERR;
   }
   strcpy((char*)cmd.param1, callToken);
   cmd.plen1 = strlen(callToken);
   strcpy((char*)cmd.param2, localIP);
   cmd.plen2 = strlen(localIP);
   *((int *)cmd.param3) = port;
   cmd.plen3 = sizeof(int) + 1;

   if (ooWriteCallStackCommand(call, &cmd) != OO_OK) {
      ast_free(cmd.param1);
      ast_free(cmd.param2);
      ast_free(cmd.param3);
      return OO_STKCMD_WRITEERR;
   }

   ast_free(cmd.param1);
   ast_free(cmd.param2);
   ast_free(cmd.param3);

   return OO_STKCMD_SUCCESS;
}
示例#10
0
int ooReadAndProcessStackCommand()
{
   OOH323CallData *pCall = NULL;   
   unsigned char buffer[MAXMSGLEN];
   int i, recvLen = 0;
   OOStackCommand cmd;
   memset(&cmd, 0, sizeof(OOStackCommand));
   ast_mutex_lock(&gCmdChanLock);
   recvLen = read(gH323ep.cmdSock, buffer, MAXMSGLEN);
   ast_mutex_unlock(&gCmdChanLock);
   if(recvLen <= 0)
   {
      OOTRACEERR1("Error:Failed to read CMD message\n");
      return OO_FAILED;
   }

   for(i=0; (int)(i+sizeof(OOStackCommand)) <= recvLen; i += sizeof(OOStackCommand))
   {
      memcpy(&cmd, buffer+i, sizeof(OOStackCommand));

      if(cmd.type == OO_CMD_NOOP)
         continue;

      if(gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered && cmd.type != OO_CMD_STOPMONITOR)
      {
         OOTRACEINFO1("Ignoring stack command as Gk Client is not registered"
                      " yet\n");
      }
      else {
         switch(cmd.type) {
            case OO_CMD_MAKECALL: 
               OOTRACEINFO2("Processing MakeCall command %s\n", 
                                    (char*)cmd.param2);
 
               ooH323NewCall ((char*)cmd.param2);
               break;

            case OO_CMD_MANUALPROGRESS:
                pCall = ooFindCallByToken((char*)cmd.param1);
                if(!pCall) {
                   OOTRACEINFO2("Call \"%s\" does not exist\n",
                                (char*)cmd.param1);
                   OOTRACEINFO1("Call migth be cleared/closed\n");
                }
                else {
                     ooSendProgress(ooFindCallByToken((char*)cmd.param1));
                }
               break;

            case OO_CMD_MANUALRINGBACK:
               if(OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK))
               {
                  pCall = ooFindCallByToken((char*)cmd.param1);
                  if(!pCall) {
                     OOTRACEINFO2("Call \"%s\" does not exist\n",
                                  (char*)cmd.param1);
                     OOTRACEINFO1("Call migth be cleared/closed\n");
                  }
                  else {
                     ooSendAlerting(ooFindCallByToken((char*)cmd.param1));
                     if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) {
                        ooSendConnect(ooFindCallByToken((char*)cmd.param1));
                     }
                  }
               }
               break;
 
            case OO_CMD_ANSCALL:
               pCall = ooFindCallByToken((char*)cmd.param1);
               if(!pCall) {
                  OOTRACEINFO2("Call \"%s\" does not exist\n",
                               (char*)cmd.param1);
                  OOTRACEINFO1("Call might be cleared/closed\n");
               }
               else {
                  OOTRACEINFO2("Processing Answer Call command for %s\n",
                               (char*)cmd.param1);
                  ooSendConnect(pCall);
               }
               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: 
               OOTRACEINFO3("Processing Hang call command %s with q931 cause %d\n", 
                             (char*)cmd.param1, *(int *) cmd.param3);
               ooH323HangCall((char*)cmd.param1, 
                              *(OOCallClearReason*)cmd.param2, *(int *) cmd.param3);
               break;
          
            case OO_CMD_SENDDIGIT:
               pCall = ooFindCallByToken((char*)cmd.param1);
               if(!pCall) {
                  OOTRACEERR2("ERROR:Invalid calltoken %s\n",
                              (char*)cmd.param1);
                  break;
               }
               if(pCall->jointDtmfMode & OO_CAP_DTMF_H245_alphanumeric) {
                  ooSendH245UserInputIndication_alphanumeric(
                     pCall, (const char*)cmd.param2);
               }
               else if(pCall->jointDtmfMode & OO_CAP_DTMF_H245_signal) {
                  ooSendH245UserInputIndication_signal(
                     pCall, (const char*)cmd.param2);
               }
               else {
                  ooQ931SendDTMFAsKeyPadIE(pCall, (const char*)cmd.param2);
               }

               break;

            case OO_CMD_STOPMONITOR: 
               OOTRACEINFO1("Processing StopMonitor command\n");
               ooStopMonitorCalls();
               break;

            default: OOTRACEERR1("ERROR:Unknown command\n");
         }
      }
      if(cmd.param1) free(cmd.param1);
      if(cmd.param2) free(cmd.param2);
      if(cmd.param3) free(cmd.param3);
   }


   return OO_OK;
}