31 #include "hostIf_utils.h"
34 #include "safec_lib.h"
38 updateCallback InterfaceStackClientReqHandler::mUpdateCallback = NULL;
39 int InterfaceStackClientReqHandler::curNumOfEntriesInInterfaceStack = 0;
41 msgHandler* InterfaceStackClientReqHandler::getInstance()
43 hostif_InterfaceStack::getLock();
46 hostif_InterfaceStack::releaseLock();
50 void InterfaceStackClientReqHandler::reset()
52 hostif_InterfaceStack::getLock();
53 curNumOfEntriesInInterfaceStack = 0;
54 hostif_InterfaceStack::releaseLock();
82 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s()] Interface Stack manager DeInitializing\n", __FUNCTION__);
83 hostif_InterfaceStack::closeAllInstances();
103 int ret = NOT_HANDLED;
105 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Found string as %s. Set command not supported.\n",
106 __FUNCTION__, __FILE__, stMsgData->
paramName);
107 stMsgData->
faultCode = fcAttemptToSetaNonWritableParameter;
126 int ret = NOT_HANDLED;
127 const char *pSetting;
128 int instanceNumber = 0;
129 hostif_InterfaceStack::getLock();
131 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
132 if(strcasecmp(stMsgData->
paramName,
"Device.InterfaceStackNumberOfEntries") == 0)
134 ret = hostif_InterfaceStack::get_Device_InterfaceStackNumberOfEntries(stMsgData);
136 else if(matchComponent(stMsgData->
paramName,
"Device.InterfaceStack",&pSetting,instanceNumber))
138 hostif_InterfaceStack *pInterfaceStack = hostif_InterfaceStack::getInstance(instanceNumber);
142 if(strcasecmp(pSetting,
"HigherLayer") == 0)
144 ret = pInterfaceStack->get_Device_InterfaceStack_HigherLayer(stMsgData);
146 else if(strcasecmp(pSetting,
"LowerLayer") == 0)
148 ret = pInterfaceStack->get_Device_InterfaceStack_LowerLayer(stMsgData);
152 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Parameter : \'%s\' is Not Supported \n", __FUNCTION__, __LINE__, stMsgData->
paramName);
153 stMsgData->
faultCode = fcInvalidParameterName;
160 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%s:%d] hostif_InterfaceStack::getInstance() returned NULL for instance %d",
161 __FUNCTION__, __FILE__, __LINE__, instanceNumber);
165 hostif_InterfaceStack::releaseLock();
168 int InterfaceStackClientReqHandler::handleGetAttributesMsg(
HOSTIF_MsgData_t *stMsgData)
170 int ret = NOT_HANDLED;
171 int instanceNumber = 0;
173 hostif_InterfaceStack::getLock();
174 hostif_InterfaceStack *pIface = hostif_InterfaceStack::getInstance(instanceNumber);
178 hostif_InterfaceStack::releaseLock();
182 GHashTable* notifyhash = pIface->getNotifyHash();
183 if(notifyhash != NULL)
185 int* notifyvalue = (
int*) g_hash_table_lookup(notifyhash,stMsgData->
paramName);
187 stMsgData->
paramtype = hostIf_IntegerType;
194 hostif_InterfaceStack::releaseLock();
198 int InterfaceStackClientReqHandler::handleSetAttributesMsg(
HOSTIF_MsgData_t *stMsgData)
200 int ret = NOT_HANDLED;
201 int instanceNumber = 0;
203 hostif_InterfaceStack::getLock();
204 hostif_InterfaceStack *pIface = hostif_InterfaceStack::getInstance(instanceNumber);
208 hostif_InterfaceStack::releaseLock();
211 GHashTable* notifyhash = pIface->getNotifyHash();
212 if(notifyhash != NULL)
215 notifyValuePtr = (
int*) malloc(1 *
sizeof(
int));
220 char *notifyKey = NULL;
221 notifyKey = (
char*) calloc(
sizeof(
char),strlen(stMsgData->
paramName)+1);
222 if((NULL != notifyValuePtr) && (NULL != notifyValuePtr))
231 g_hash_table_insert(notifyhash,notifyKey,notifyValuePtr);
237 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] Not able to allocate Notify pointer %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
240 free(notifyValuePtr);
245 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] Not able to get notifyhash %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
247 hostif_InterfaceStack::releaseLock();
251 void InterfaceStackClientReqHandler::registerUpdateCallback(updateCallback cb)
253 mUpdateCallback = cb;
256 void InterfaceStackClientReqHandler::checkForUpdates()
263 GHashTable* notifyhash = NULL;
264 const char *pSetting;
266 char tmp_buff[TR69HOSTIFMGR_MAX_PARAM_LEN];
267 hostif_InterfaceStack::getLock();
269 memset(&msgData,0,
sizeof(msgData));
270 memset(tmp_buff,0,TR69HOSTIFMGR_MAX_PARAM_LEN);
271 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FILE__, __FUNCTION__);
274 if(hostif_InterfaceStack::get_Device_InterfaceStackNumberOfEntries(&msgData) == OK)
277 char tmp[TR69HOSTIFMGR_MAX_PARAM_LEN] =
"";
278 snprintf(tmp_buff,
sizeof(tmp_buff),
"Device.InterfaceStack");
279 while(curNumOfEntriesInInterfaceStack > tmpNoDev)
281 snprintf(tmp,
sizeof(tmp),
"%s.%d.", tmp_buff, tmpNoDev);
283 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] InterfaceStack Removed Event..\n", __FILE__, __FUNCTION__);
287 while(curNumOfEntriesInInterfaceStack < tmpNoDev)
289 snprintf(tmp,
sizeof(tmp),
"%s.", tmp_buff);
291 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] InterfaceStack Added Event..\n", __FILE__, __FUNCTION__);
295 curNumOfEntriesInInterfaceStack = get_int(msgData.
paramValue);
298 #ifdef HAVE_VALUE_CHANGE_EVENT
301 hostif_InterfaceStack *pInterfaceStackClient = hostif_InterfaceStack::getInstance(instanceNumber);
302 if(NULL != pInterfaceStackClient)
304 notifyhash = pInterfaceStackClient->getNotifyHash();
307 if(NULL != notifyhash)
309 GHashTableIter notifyHashIterator;
311 gpointer notifyEnable;
314 g_hash_table_iter_init (¬ifyHashIterator, notifyhash);
315 while (g_hash_table_iter_next (¬ifyHashIterator, ¶mName, ¬ifyEnable))
317 int* isNotifyEnabled = (
int *)notifyEnable;
319 if(matchComponent((
const char*)paramName,
"Device.InterfaceStack.",&pSetting,instanceNumber))
321 hostif_InterfaceStack *pIface = hostif_InterfaceStack::getInstance(instanceNumber);
324 if (strcasecmp(pSetting,
"HigherLayer") == 0)
326 memset(&msgData,0,
sizeof(msgData));
328 pIface->get_Device_InterfaceStack_HigherLayer(&msgData,&bChanged);
331 if(mUpdateCallback && (*isNotifyEnabled == 1))
337 if (strcasecmp(pSetting,
"LowerLayer") == 0)
339 memset(&msgData,0,
sizeof(msgData));
341 pIface->get_Device_InterfaceStack_LowerLayer(&msgData,&bChanged);
344 if(mUpdateCallback && (*isNotifyEnabled == 1))
355 hostif_InterfaceStack::releaseLock();