SALoader_Interface* hlloader_initialize(char const * pWorkdir, susiaccess_agent_conf_body_t const * pConfig, susiaccess_agent_profile_body_t const * pProfile, void* pLogHandle) { SALoader_Interface* pSALoader = NULL; if(! pWorkdir) return pSALoader; if(! pConfig) return pSALoader; if(! pProfile) return pSALoader; if(hlloader_is_exist(pWorkdir)) { pSALoader = malloc(sizeof(SALoader_Interface)); memset(pSALoader, 0, sizeof(SALoader_Interface)); if(hlloader_load(pWorkdir, pSALoader)) { printf("HandlerLoader loaded\r\n"); pSALoader->LogHandle = pLogHandle; if(pSALoader->Loader_Initialize_API) pSALoader->Loader_Initialize_API(pWorkdir, pConfig, pProfile, pLogHandle); } else { char *err = hlloader_get_error(); SAManagerLog(pLogHandle, Warning, "Load HandlerLoader failed!\r\n %s!!", err); free(err); free(pSALoader); pSALoader = NULL; } } else { char *err = hlloader_get_error(); SAManagerLog(pLogHandle, Warning, "Cannot find HandlerLoader!\r\n %s!!", err); free(err); } return pSALoader; }
AGENT_SEND_STATUS SAManager_SendAutoReport( HANDLE const handle, char const * const requestData, unsigned int const requestLen, void *pRev1, void* pRev2 ) { AGENT_SEND_STATUS result = cagent_send_data_error; Handler_info* plugin = NULL; susiaccess_packet_body_t* packet = NULL; char topicStr[128] = {0}; if(handle == NULL) return result; plugin = (Handler_info*)handle; if(plugin->agentInfo == NULL) return result; packet = SAManager_WrapAutoReportPacket(plugin, requestData, requestLen, false); if(packet == NULL) { SAManagerLog(g_samanagerlogger, Warning, "Request Packet is empty!"); return result; } sprintf(topicStr, DEF_AUTOREPORT_TOPIC, plugin->agentInfo->devId, AUTOREPORT_TOPIC); if(g_publishCB) { if(g_publishCB(topicStr, packet) == true) result = cagent_success; else result = cagent_send_data_error; } else result = cagent_callback_null; if(packet->content) free(packet->content); free(packet); return result; }
AGENT_SEND_STATUS SAManager_SendCustMessage( HANDLE const handle, int enum_act, char const * const topic, char const * const requestData, unsigned int const requestLen, void *pRev1, void* pRev2 ) { AGENT_SEND_STATUS result = cagent_send_data_error; Handler_info* plugin = NULL; susiaccess_packet_body_t* packet = NULL; char topicStr[128] = {0}; //SAManagerLog(g_samanagerlogger, Normal, "Topic: %s, Data: %s", topic, requestData); if(handle == NULL) return result; plugin = (Handler_info*)handle; if(plugin->agentInfo == NULL) return result; packet = SAManager_WrapReqPacket(plugin, enum_act, requestData, requestLen, true); if(packet == NULL) { SAManagerLog(g_samanagerlogger, Warning, "Request Packet is empty!"); return result; } if(g_publishCB) { if(g_publishCB(topic, packet) == true) result = cagent_success; else result = cagent_send_data_error; } else result = cagent_callback_null; if(packet->content) free(packet->content); free(packet); return result; }
void hlloader_handler_recv(SALoader_Interface* pSALoader, Handler_List_t *pHandlerList, char* topic, susiaccess_packet_body_t *pkt, void *pRev1, void* pRev2) { Handler_Loader_Interface* handler = NULL; char* pReqInfoPayload = NULL; if(!pSALoader) return; pReqInfoPayload = pkg_parser_packet_print(pkt); if(pSALoader->Loader_FindHandler_API) { /*Support V3.1 Version */ handler = pSALoader->Loader_FindHandler_API(pHandlerList, pkt->handlerName); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } /*Support V3.0 or Older Version */ else{ int reqID = pkt->requestID; if(pSALoader) { /*Support V3.0 Version */ handler = pSALoader->Loader_FindHandlerByReqID_API(pHandlerList, reqID); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } /*Support Older Version */ else if(reqID == cagent_request_device_monitoring) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "device_monitoring"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "device_monitoring" ); } } else if(reqID == cagent_request_power_onoff) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "power_onoff"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "power_onoff" ); } } else if(reqID == cagent_request_remote_kvm) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "remote_kvm"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "remote_kvm" ); } } else if(reqID == cagent_request_protection) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "protection"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "protection" ); } } else if(reqID == cagent_request_recovery) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "recovery"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "recovery" ); } } else if(reqID == cagent_request_software_monitoring) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "software_monitoring"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "software_monitoring" ); } } else if(reqID == cagent_request_global) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "general"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "global" ); } } else if(reqID == cagent_request_terminal) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "terminal"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "terminal" ); } } else if(reqID == cagent_request_screenshot) { if(pSALoader) { handler = pSALoader->Loader_FindHandler_API(pHandlerList, "screenshot"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(pSALoader->LogHandle, Warning, "Cannot find handler: %s", "screenshot" ); } } } free(pReqInfoPayload); }
void* threat_keepalive(void* args) { struct kepalive_ctx* ctx = (struct kepalive_ctx*)args; //#ifdef WIN32 PIPECLINETHANDLE pipeClientHandle = NULL; WATCHMSG watchMsg; //#endif bool isLogConnectFail = true; bool bRet = true; while(ctx->isThreadRunning) { //#ifdef WIN32 pipeClientHandle = NamedPipeClientConnect(DEF_PIPE_NAME, DEF_COMM_ID, NULL); if(pipeClientHandle) { usleep(1000*1000); //On CentOS, NamedPipeClient Connect need more time SAManagerLog(g_keepalivelogger, Normal, "NamedPipe: %s, CommID: %d, IPC Connect successfully!", DEF_PIPE_NAME, DEF_COMM_ID); isLogConnectFail = true; memset(&watchMsg, 0, sizeof(WATCHMSG)); watchMsg.commCmd = START_WATCH; watchMsg.commID = DEF_COMM_ID; watchMsg.commParams.starWatchInfo.objType = WIN_SERVICE; watchMsg.commParams.starWatchInfo.watchPID = getpid(); bRet = NamedPipeClientSend(pipeClientHandle, (char *)&watchMsg, sizeof(WATCHMSG)); if(!bRet) { SAManagerLog(g_keepalivelogger, Error, "NamedPipe: %s, CommID: %d, Start watch failed!", DEF_PIPE_NAME, DEF_COMM_ID); goto done; } usleep(1000*1000); //On CentOS, NamedPipeClient Send Packet need more time while(ctx->isThreadRunning) { //#endif CheckHandlerStatus(ctx); //#ifdef WIN32 //memset(&watchMsg, 0, sizeof(WATCHMSG)); watchMsg.commCmd = KEEPALIVE; watchMsg.commID = DEF_COMM_ID; bRet = NamedPipeClientSend(pipeClientHandle, (char *)&watchMsg, sizeof(WATCHMSG)); if(!bRet) { //SAManagerLog(g_keepalivelogger, Error, "NamedPipe: %s, CommID: %d, Send keepalive failed!", DEF_PIPE_NAME, DEF_COMM_ID); goto done; } //#endif usleep(DEF_KEEPALIVE_INTERVAL_S*1000*1000); //#ifdef WIN32 } //memset(&watchMsg, 0, sizeof(WATCHMSG)); watchMsg.commCmd = STOP_WATCH; watchMsg.commID = DEF_COMM_ID; bRet = NamedPipeClientSend(pipeClientHandle, (char *)&watchMsg, sizeof(WATCHMSG)); if(!bRet) SAManagerLog(g_keepalivelogger, Error, "NamedPipe: %s, CommID: %d, Stop watch failed!", DEF_PIPE_NAME, DEF_COMM_ID); else SAManagerLog(g_keepalivelogger, Normal, "NamedPipe: %s, CommID: %d, Stop watch successfully!", DEF_PIPE_NAME, DEF_COMM_ID); } else { if(isLogConnectFail) {//Continuous failure log only once SAManagerLog(g_keepalivelogger,Error, "NamedPipe: %s, CommID: %d, IPC Connect failed!", DEF_PIPE_NAME, DEF_COMM_ID); isLogConnectFail = false; } } done: if(pipeClientHandle)NamedPipeClientDisconnect(pipeClientHandle); usleep(1000*1000); //#endif } pthread_exit(0); return 0; }
void CheckHandlerStatus(struct kepalive_ctx* ctx) { Handler_Loader_Interface *pInterfaceTmp = NULL; if(!ctx) return; pInterfaceTmp = ctx->pHandlerList->items; while(pInterfaceTmp) { HANDLER_THREAD_STATUS pOutStatus; bool bRestart = false; if(pInterfaceTmp->Workable == false) { pInterfaceTmp = pInterfaceTmp->next; continue; } if(pInterfaceTmp->type != user_handler) { pInterfaceTmp = pInterfaceTmp->next; continue; } if(!ctx->isThreadRunning) break; if(pInterfaceTmp->Handler_Get_Status_API) { handler_result result = pInterfaceTmp->Handler_Get_Status_API(&pOutStatus); if(result == handler_success) { handler_countdown_st *phandlercd = FindHandlerCD(pInterfaceTmp->Name); if(pOutStatus == handler_status_busy) { if(!phandlercd) { phandlercd = AddhHandlerCD(pInterfaceTmp->Name, 3); } phandlercd->count++; SAManagerLog(g_keepalivelogger, Warning, "Handler %s is busy count %d!", pInterfaceTmp->Name, phandlercd->count); if(phandlercd->count >= phandlercd->limit) { bRestart = true; RemoveHandlerCD(pInterfaceTmp->Name); } } else if(phandlercd) { RemoveHandlerCD(pInterfaceTmp->Name); } } } if(!ctx->isThreadRunning) break; if(bRestart) { if(pInterfaceTmp->Handler_Stop_API) { SAManagerLog(g_keepalivelogger, Warning, "Stop Handler %s!", pInterfaceTmp->Name); pInterfaceTmp->Handler_Stop_API(); } if(!ctx->isThreadRunning) break; if(pInterfaceTmp->Handler_Start_API) { SAManagerLog(g_keepalivelogger, Warning, "Restart Handler %s!", pInterfaceTmp->Name); pInterfaceTmp->Handler_Start_API(); } } pInterfaceTmp = pInterfaceTmp->next; } }
void SAMANAGER_API SAManager_Initialize(susiaccess_agent_conf_body_t * config, susiaccess_agent_profile_body_t * profile, void * loghandle) { char workdir[MAX_PATH] = {0}; Handler_Loader_Interface GlobalPlugin; g_samanagerlogger = loghandle; memset(&g_statethreadctx, 0, sizeof(struct state_ctx)); g_statethreadctx.msgqueue = malloc(sizeof( struct statequeue)); if(g_statethreadctx.msgqueue) { if(!queue_init(g_statethreadctx.msgqueue, 1000)) { free(g_statethreadctx.msgqueue); g_statethreadctx.msgqueue = NULL; } g_statethreadctx.isThreadRunning = true; if (app_os_thread_create(&g_statethreadctx.threadHandler, StateQueueThread, &g_statethreadctx) != 0) { g_statethreadctx.isThreadRunning = false; queue_uninit(g_statethreadctx.msgqueue); free(g_statethreadctx.msgqueue); g_statethreadctx.msgqueue = NULL; } } if(strlen(profile->workdir)>0) strcpy(workdir, profile->workdir); else app_os_get_module_path(workdir); memset(&g_handlerList, 0, sizeof(Handler_List_t)); /*Load Handler Loader*/ if(dl_IsExistSALoaderLib(profile->workdir)) { g_SALoader = malloc(sizeof(SALoader_Interface)); memset(g_SALoader, 0, sizeof(SALoader_Interface)); if(dl_LoadSALoaderLib(profile->workdir, g_SALoader)) { printf("HandlerLoader loaded\r\n"); if(g_SALoader->Loader_Initialize_API) g_SALoader->Loader_Initialize_API(workdir, config, profile, loghandle); if(g_SALoader->Loader_SetFuncCB_API) { Callback_Functions_t functions; memset(&functions, 0, sizeof(Callback_Functions_t)); functions.sendcbf = SAManager_SendMessage; functions.sendcustcbf = SAManager_SendCustMessage; functions.subscribecustcbf = SAManager_SubscribeCustTopic; functions.sendreportcbf = SAManager_SendAutoReport; functions.sendcapabilitycbf = SAManager_SendCapability; functions.sendevnetcbf = SAManager_SendEventNotify; functions.connectservercbf = SAManager_ConnectServer; functions.disconnectcbf = SAManager_Disconnect; g_SALoader->Loader_SetFuncCB_API(&functions); } //if(g_SALoader->Loader_SetSendCB_API) // g_SALoader->Loader_SetSendCB_API(SAManager_SendMessage); //if(g_SALoader->Loader_SetCustSendCB_API) // g_SALoader->Loader_SetCustSendCB_API(SAManager_SendCustMessage); //if(g_SALoader->Loader_SetAutoReportCB_API) // g_SALoader->Loader_SetAutoReportCB_API(SAManager_SendAutoReport); //if(g_SALoader->Loader_SetCustSubscribeCB_API) // g_SALoader->Loader_SetCustSubscribeCB_API(SAManager_SubscribeCustTopic); } else { char *err = dl_GetLoadError(); SAManagerLog(g_samanagerlogger, Warning, "Load HandlerLoader failed!\r\n %s!!", err); free(err); } } else { char *err = dl_GetLoadError(); SAManagerLog(g_samanagerlogger, Warning, "Cannot find HandlerLoader!\r\n %s!!", err); free(err); } memset(&GlobalPlugin, 0, sizeof(Handler_Loader_Interface)); if(dl_IsExistSAGeneralLib(profile->workdir)) { g_SAGeneral = malloc(sizeof(SAGeneral_Interface)); memset(g_SAGeneral, 0, sizeof(SAGeneral_Interface)); if(dl_LoadSAGeneralLib(profile->workdir, g_SAGeneral)) { printf("GeneralHandler loaded\r\n"); if(g_SALoader) { if(g_SALoader->Loader_GetBasicHandlerLoaderInterface_API) g_SALoader->Loader_GetBasicHandlerLoaderInterface_API(&GlobalPlugin); } strcpy(GlobalPlugin.Name, "general"); strncpy(GlobalPlugin.pHandlerInfo->ServerIP, config->serverIP, strlen(config->serverIP)+1); GlobalPlugin.pHandlerInfo->ServerPort = atol(config->serverPort); GlobalPlugin.type = core_handler; if(g_SAGeneral->General_Initialize_API) { GlobalPlugin.Handler_Init_API = (HANDLER_INITLIZE)g_SAGeneral->General_Initialize_API; g_SAGeneral->General_Initialize_API(GlobalPlugin.pHandlerInfo); } if(g_SAGeneral->General_HandleRecv_API) GlobalPlugin.Handler_Recv_API = (HANDLER_RECV)g_SAGeneral->General_HandleRecv_API; if(g_SAGeneral->General_Start_API) GlobalPlugin.Handler_Start_API = (HANDLER_START)g_SAGeneral->General_Start_API; if(g_SAGeneral->General_Stop_API) GlobalPlugin.Handler_Stop_API = (HANDLER_STOP)g_SAGeneral->General_Stop_API; if(g_SAGeneral->General_OnStatusChanges_API) GlobalPlugin.Handler_OnStatusChange_API = (HANDLER_ONSTATUSCAHNGE)g_SAGeneral->General_OnStatusChanges_API; GlobalPlugin.Workable = true; } else { char *err = dl_GetLoadError(); SAManagerLog(g_samanagerlogger, Warning, "Load GeneralHandler failed!\r\n %s!!", err); free(err); } } else { char *err = dl_GetLoadError(); SAManagerLog(g_samanagerlogger, Warning, "Cannot find GeneralHandler!\r\n %s!!", err); free(err); } if(g_SALoader) { if(g_SAGeneral) { if(g_SAGeneral->General_SetPluginHandlers_API) g_SAGeneral->General_SetPluginHandlers_API(&g_handlerList); if(g_SALoader->Loader_AddHandler_API) g_SALoader->Loader_AddHandler_API(&g_handlerList, &GlobalPlugin); } g_SALoader->Loader_LoadAllHandler_API(&g_handlerList, workdir); g_SALoader->Loader_StartAllHandler_API(&g_handlerList); //#ifdef WIN32 keepalive_initialize(&g_handlerList, g_samanagerlogger); //#endif } }
void SAManager_RecvInternalCommandReq(char* topic, susiaccess_packet_body_t *pkt, void *pRev1, void* pRev2) { Handler_Loader_Interface* handler = NULL; PJSON ReqInfoJSON = NULL; char* pReqInfoPayload = NULL; ReqInfoJSON = SAParser_CreateAgentPacketToJSON(pkt); pReqInfoPayload = SAParser_PrintUnformatted(ReqInfoJSON); SAParser_Free(ReqInfoJSON); if(g_SALoader) { /*Support V3.1 Version */ handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, pkt->handlerName); } if(handler != NULL) { //SAManagerLog(g_samanagerlogger, Normal, "Handler find by name: %s", pkt->handlerName ); if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } /*Support V3.0 or Older Version */ else{ int reqID = pkt->requestID; if(g_SALoader) { /*Support V3.0 Version */ handler = g_SALoader->Loader_FindHandlerByReqID_API(&g_handlerList, reqID); } if(handler != NULL) { //SAManagerLog(g_samanagerlogger, Normal, "Handler find by ID: %d", reqID ); if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } /*Support Older Version */ else if(reqID == cagent_request_device_monitoring) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "device_monitoring"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "device_monitoring" ); } } else if(reqID == cagent_request_power_onoff) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "power_onoff"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "power_onoff" ); } } else if(reqID == cagent_request_remote_kvm) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "remote_kvm"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "remote_kvm" ); } } else if(reqID == cagent_request_protection) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "protection"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "protection" ); } } else if(reqID == cagent_request_recovery) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "recovery"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "recovery" ); } } else if(reqID == cagent_request_software_monitoring) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "software_monitoring"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "software_monitoring" ); } } else if(reqID == cagent_request_global) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "general"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "global" ); } } else if(reqID == cagent_request_terminal) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "terminal"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "terminal" ); } } else if(reqID == cagent_request_screenshot) { if(g_SALoader) { handler = g_SALoader->Loader_FindHandler_API(&g_handlerList, "screenshot"); } if(handler != NULL) { if( handler->Handler_Recv_API ) handler->Handler_Recv_API(topic, pReqInfoPayload, strlen(pReqInfoPayload), pRev1, pRev2); } else { SAManagerLog(g_samanagerlogger, Warning, "Cannot find handler: %s", "screenshot" ); } } } free(pReqInfoPayload); }