31 #include "hostIf_tr69ReqHandler.h"
34 #include "hostIf_updateHandler.h"
35 #include "hostIf_utils.h"
40 #include "integrationSettings.h"
42 #ifdef SNMP_ADAPTER_ENABLED
47 static bool TR69_HostIf_Mgr_Init();
48 static bool TR69_HostIf_Mgr_Connect();
49 static bool TR69_HostIf_Mgr_Get_RegisterCall();
50 static IARM_Result_t tr69hostIfMgr_Stop(
void);
51 static IARM_Result_t _Gettr69HostIfMgr(
void *arg);
52 static IARM_Result_t _Settr69HostIfMgr(
void *arg);
53 static IARM_Result_t _SetAttributestr69HostIfMgr(
void *arg);
54 static IARM_Result_t _GetAttributestr69HostIfMgr(
void *arg);
55 static IARM_Result_t _RegisterForEventstr69HostIfMgr(
void *arg);
56 static void _hostIf_EventHandler(
const char *, IARM_EventId_t,
void *,
size_t);
61 bool hostIf_IARM_IF_Start()
64 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
66 if ( TR69_HostIf_Mgr_Init() &&
67 TR69_HostIf_Mgr_Connect() &&
68 TR69_HostIf_Mgr_Get_RegisterCall() )
73 pMsgHandler = DSClientReqHandler::getInstance();
75 pMsgHandler = DeviceClientReqHandler::getInstance();
78 #ifdef SNMP_ADAPTER_ENABLED
79 pMsgHandler = SNMPClientReqHandler::getInstance();
84 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
92 static bool TR69_HostIf_Mgr_Init()
94 IARM_Result_t err = IARM_RESULT_SUCCESS;
95 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
96 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"#######################################################");
99 if(IARM_RESULT_SUCCESS != err)
101 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s()] Failed to 'IARM_Bus_Init(%s)', return with Error "\
107 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
113 static bool TR69_HostIf_Mgr_Connect()
115 IARM_Result_t err = IARM_RESULT_SUCCESS;
117 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
121 if(IARM_RESULT_SUCCESS != err)
123 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Failed to IARM_Bus_Connect(), return with Error code: %d\n", __FUNCTION__, err);
127 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
131 static IARM_Result_t _RegisterForEventstr69HostIfMgr(
void *arg)
133 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
134 updateHandler::reset();
135 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
136 return IARM_RESULT_SUCCESS;
144 static bool TR69_HostIf_Mgr_Get_RegisterCall()
147 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
169 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
173 void hostIf_GetAttributesReqHandler(
void *arg)
177 g_printf(
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
180 ret = hostIf_SetAttributesMsgHandler(stMsgData);
181 g_printf(
"[hostIf_GetAttributesReqHandler : hostIf_MsgHandler()] Return value : %d\n", ret);
191 g_printf(
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
195 static IARM_Result_t _GetAttributestr69HostIfMgr(
void *arg)
197 g_printf(
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
204 hostIf_GetAttributesReqHandler(arg);
208 g_printf(
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
209 return IARM_RESULT_SUCCESS;
212 void hostIf_SetAttributesReqHandler(
void *arg)
216 g_printf(
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
219 ret = hostIf_SetAttributesMsgHandler(stMsgData);
220 g_printf(
"[*****hostIf_SetAttributesReqHandler : hostIf_MsgHandler()] Return value : %d for Parameter %s\n", ret,stMsgData->
paramName);
230 g_printf(
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
234 static IARM_Result_t _SetAttributestr69HostIfMgr(
void *arg)
236 g_printf(
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
243 hostIf_SetAttributesReqHandler(arg);
247 g_printf(
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
248 return IARM_RESULT_SUCCESS;
255 void hostIf_IARM_IF_Stop()
258 msgHandler *pMsgHandler = DSClientReqHandler::getInstance();
260 tr69hostIfMgr_Stop();
265 static IARM_Result_t tr69hostIfMgr_Stop(
void)
267 IARM_Result_t err = IARM_RESULT_SUCCESS;
268 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering...\n", __FUNCTION__, __FILE__);
270 if(IARM_RESULT_SUCCESS != err)
272 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Failed to IARM_Bus_Disconnect(), return with Error code: %d\n", __FUNCTION__, err);
276 if(IARM_RESULT_SUCCESS != err)
278 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Failed to IARM_Bus_Term(), return with Error code: %d\n", __FUNCTION__, err);
280 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
284 void hostIf_SetReqHandler(
void *arg)
288 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
293 ret = hostIf_SetMsgHandler(stMsgData);
294 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[hostIf_SetReqHandler : hostIf_MsgHandler()] Return value : %d\n", ret);
304 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
311 static IARM_Result_t _Settr69HostIfMgr(
void *arg)
313 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
319 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] paramName :%s \n", __FUNCTION__, __FILE__, (
char *)param->
paramName);
320 hostIf_SetReqHandler(arg);
324 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
325 return IARM_RESULT_SUCCESS;
332 void hostIf_GetReqHandler(
void *arg)
342 if(!getParamInfoFromDataModel(getDataModelHandle(), stMsgData->
paramName, &dmParam))
344 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s: Invalid parameter name %s: doesn't exist in data-model\n", __FUNCTION__, stMsgData->
paramName);
346 stMsgData->
bsUpdate = getBSUpdateEnum(dmParam.bsUpdate);
347 if(dmParam.objectName)
348 free(dmParam.objectName);
349 if(dmParam.paramName)
350 free(dmParam.paramName);
352 free(dmParam.bsUpdate);
354 free(dmParam.access);
356 free(dmParam.dataType);
357 if(dmParam.defaultValue)
358 free(dmParam.defaultValue);
361 ret = hostIf_GetMsgHandler(stMsgData);
362 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[hostIf_GetReqHandler : hostIf_MsgHandler()] Return value : %d\n", ret);
370 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s()] Failed with returned Value : %d for [%s]\n",
371 __FUNCTION__, ret, stMsgData->
paramName);
373 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
379 static IARM_Result_t _Gettr69HostIfMgr(
void *arg)
381 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
387 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] paramName :%s \n", __FUNCTION__, __FILE__, (
char *)param->
paramName);
389 hostIf_GetReqHandler(arg);
390 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
391 return IARM_RESULT_SUCCESS;
398 static void _hostIf_EventHandler(
const char *owner, IARM_EventId_t eventId,
void *data,
size_t len)
400 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
401 if (0 == strcmp(owner, IARM_TR69_CLIENT))
404 IARM_Bus_TR69Agent_EventData_t *tr69AgentData = (IARM_Bus_TR69Agent_EventData_t *)data;
405 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] EventId: %d value : %d \n", __FILE__, __FUNCTION__, (IARM_Bus_tr69Agent_EventId_t)eventId, tr69AgentData->value);
409 case IARM_BUS_TR69Agent_ACS_CONN_EVENT:
410 set_ACSStatus((tr69AgentData->value == ACS_CONNECTED) ?
true:
false);
411 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] get_ACSStatus :%d \n", __FUNCTION__, __FILE__, get_ACSStatus());
421 int gatewayConnState = eventData->data.systemStates.state;
422 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] Getting events from %s for Gateway Connection State : %d\n", __FILE__, __FUNCTION__, __LINE__,
IARM_BUS_SYSMGR_NAME, gatewayConnState);
424 set_ACSStatus((gatewayConnState) ?
true:
false);
427 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);