Пример #1
0
DSL_int32_t DSL_CPE_SoapInit(DSL_CPE_Control_Context_t *pContext)
{
   DSL_int32_t ret = 0;

   memset(&SoapEnv, 0, sizeof(Soap_env_t));

   soap_init(&SoapEnv.client.soap);

   /* Set client connection timeout (=1sec) therefore NONBLOCK mode activated.*/
   SoapEnv.client.soap.connect_timeout = 1;

   /* DO NOT INCLUDE "SOAP_IO_KEEPALIVE" FLAG FOR CLIENT BECAUSE THIS MIGHT
      RESULT IN PROBLEMS!!! */
   /*soap_init2(&SoapEnv.client.soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);*/
   SoapEnv.client.bInit = DSL_TRUE;

   /*soap_init(&SoapEnv.server.soap);*/
   soap_init2(&SoapEnv.server.soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);

   SoapEnv.server.soap.accept_timeout = 60;  /* let server time out after 60 sec of inactivity */

   SoapEnv.server.soap.send_timeout = 10;    /* 10 seconds */
   SoapEnv.server.soap.recv_timeout = 10;    /* 10 seconds */
   SoapEnv.server.soap.max_keep_alive = 100; /* max keep-alive sequence (100 packets) */

   SoapEnv.server.m = soap_bind ( &SoapEnv.server.soap, NULL, DSL_CPE_SOAP_PORT, 100 );
   if ( SoapEnv.server.m < 0 )
   {
      /*soap_print_fault ( &SoapEnv.server.soap, stderr );*/
      DSL_CCA_DEBUG(DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX
         "binding SOAP port (%d) failed - already in use?" DSL_CPE_CRLF,
         DSL_CPE_SOAP_PORT));
      return 1;
   }

   SoapEnv.bRun     = DSL_TRUE;
   SoapEnv.pContext = pContext;

   memset(&SoapControl, 0x00, sizeof(SoapControl));

   DSL_CPE_ThreadInit(&SoapControl, "dsl_soap", DSL_CPE_SOAP, DSL_CPE_SOAP_STACK_SIZE, DSL_CPE_PRIORITY, (DSL_uint32_t)&SoapEnv, (DSL_uint32_t)DSL_NULL);

   DSL_CPE_LockCreate(&SoapEnv.callBackSem);

   ret = DSL_CPE_CLI_Register(&SoapEnv.pSOAPCLIContext, &SoapEnv, DSL_CPE_Soap_Exit,
      SOAP_EventCallback);

   return ret;
}
Пример #2
0
/**
   Initialize the DTI
*/
DSL_Error_t DSL_CPE_Dti_Start(
                        DSL_CPE_Control_Context_t *pContext,
                        DSL_int_t      numOfPhyDevices,
                        DSL_int_t      numOfLinesPerPhyDevice,
                        DSL_uint16_t   dtiListenPort,
                        DSL_char_t     *pDtiServerIp,
                        DSL_boolean_t  bEnableCliAutoMsg,
                        DSL_boolean_t  bEnableDevAutoMsg,
                        DSL_boolean_t  bEnableSingleThreadMode)
{
   DSL_int_t                  ret = DSL_SUCCESS;
   DTI_AgentCtx_t             *pDtiAgent = DSL_NULL;
   DTI_AgentStartupSettings_t dtiStartup;

   if (DSL_CPE_GlobalDtiContext.pDtiAgent == DSL_NULL)
   {
      /* init the DTI control struct */
      memset(&DSL_CPE_GlobalDtiContext, 0, sizeof(DSL_CPE_Dti_Context_t));
      DSL_CPE_GlobalDtiContext.ifNum = -1;


      memset(&dtiStartup, 0x00, sizeof(DTI_AgentStartupSettings_t));

      /* physical device setup */
      dtiStartup.numOfDevices   = (IFX_int_t)numOfPhyDevices;
      dtiStartup.linesPerDevice = (IFX_int_t)numOfLinesPerPhyDevice;


      /* DTI IP Setup setup */
      strncpy(dtiStartup.serverIpAddr, pDtiServerIp, 16);
      dtiStartup.listenPort = (dtiListenPort == 0) ? 9000 : (IFX_uint16_t)dtiListenPort;

      /* DTI Agent configuration */
      dtiStartup.bStartupAutoCliMsgSupport = (bEnableCliAutoMsg == DSL_TRUE) ? 1 : 0;
      dtiStartup.bStartupAutoDevMsgSupport = (bEnableDevAutoMsg == DSL_TRUE) ? 1 : 0;

      dtiStartup.debugLevel = 3;

#if defined(DTI_SUPPORT_SINGLE_THREADED_MODE) && (DTI_SUPPORT_SINGLE_THREADED_MODE == 1)
      /*
         Out from the DTI Agent interface:
            This version ot the DTI Agent supports "single threaded mode"
      */
      if (bEnableSingleThreadMode == DSL_TRUE)
      {
         dtiStartup.bSingleThreadedMode = 1;
         dtiStartup.numOfUsedWorker     = 1;
      }
      else
      {
         dtiStartup.bSingleThreadedMode = 0;
         dtiStartup.numOfUsedWorker     = 4;
      }
#endif

      /*
         start the DTI Agent
      */
      if ( DTI_AgentStart(&pDtiAgent, &dtiStartup) != DTI_SUCCESS)
      {
         DSL_CPE_FPrintf(DSL_CPE_STDOUT, DSL_CPE_PREFIX"ERROR - start DTI agent" DSL_CPE_CRLF);

         return DSL_ERROR;
      }
      DSL_CPE_GlobalDtiContext.pDtiAgent = pDtiAgent;
   }
   else
   {
      DSL_CPE_FPrintf(DSL_CPE_STDOUT, DSL_CPE_PREFIX"WARNING - DTI agent already running" DSL_CPE_CRLF);
   }

#if defined(INCLUDE_DSL_CPE_CLI_SUPPORT)
   if (DSL_CPE_GlobalDtiContext.bEnabled != DSL_TRUE)
   {
      DSL_CPE_GlobalDtiContext.pDSLContext = pContext;

      if (dtiStartup.bStartupAutoCliMsgSupport == 1)
      {
         ret = DSL_CPE_CLI_Register(
                  &DSL_CPE_GlobalDtiContext.pCLIContext,
                  &DSL_CPE_GlobalDtiContext,
                  DSL_CPE_CLI_Dti_Exit,
                  DSL_CPE_CLI_Dti_Event);
      }
      else
      {
         ret = DSL_CPE_CLI_Register(
                  &DSL_CPE_GlobalDtiContext.pCLIContext,
                  &DSL_CPE_GlobalDtiContext,
                  DSL_CPE_CLI_Dti_Exit,
                  IFX_NULL);
      }


      /* register the exec within the DTI module */
      DSL_CPE_GlobalDtiContext.ifNum =  DTI_CLI_SendFunctionRegister(
                                            (IFX_void_t *)DSL_CPE_GlobalDtiContext.pDtiAgent,
                                            (IFX_void_t *)&DSL_CPE_GlobalDtiContext,
                                            "DSL_API",
                                            DSL_CPE_CLI_Dti_Exec,
                                            0x10000 /* size of response buffer */);
      if (DSL_CPE_GlobalDtiContext.ifNum < 0)
      {
         DSL_CPE_FPrintf(DSL_CPE_STDOUT, DSL_CPE_PREFIX"ERROR - start DTI agent, send fct register" DSL_CPE_CRLF);

         if (DSL_CPE_CLI_Unregister(DSL_CPE_GlobalDtiContext.pCLIContext) == DSL_SUCCESS)
         {
            DSL_CPE_Free(DSL_CPE_GlobalDtiContext.pCLIContext);
            DSL_CPE_GlobalDtiContext.pCLIContext = DSL_NULL;
         }

         return DSL_ERROR;
      }
   }
   else
   {
      DSL_CPE_FPrintf(DSL_CPE_STDOUT, DSL_CPE_PREFIX"WARNING - DTI agent already registered" DSL_CPE_CRLF);
   }
#endif /* #if defined(INCLUDE_DSL_CPE_CLI_SUPPORT)*/

   DSL_CPE_GlobalDtiContext.bEnabled = DSL_TRUE;

   return ret;
}