38 #include "safec_lib.h"
41 updateCallback EthernetClientReqHandler::mUpdateCallback = NULL;
42 int EthernetClientReqHandler::curNumOfDevices[10] = {0,};
44 msgHandler* EthernetClientReqHandler::getInstance()
51 void EthernetClientReqHandler::reset()
53 hostIf_EthernetInterface::getLock();
54 memset(curNumOfDevices,0,
sizeof(curNumOfDevices));
55 hostIf_EthernetInterface::releaseLock();
86 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
88 hostIf_EthernetInterface::closeAllInstances();
89 hostIf_EthernetInterfaceStats::closeAllInstances();
91 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
109 int ret = NOT_HANDLED;
110 const char *pSetting;
112 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
114 "Device.Ethernet.Interface",&pSetting,instanceNumber))
117 hostIf_EthernetInterface::getLock();
123 hostIf_EthernetInterface::releaseLock();
126 if (strcasecmp(pSetting,
"Enable") == 0)
130 else if (strcasecmp(pSetting,
"Alias") == 0)
134 else if (strcasecmp(pSetting,
"LowerLayers") == 0)
138 else if (strcasecmp(pSetting,
"MaxBitRate") == 0)
142 else if (strcasecmp(pSetting,
"DuplexMode") == 0)
149 stMsgData->
faultCode = fcAttemptToSetaNonWritableParameter;
150 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Failed, since Attempt To Set a NonWritable Parameter \"%s\"\n", __FUNCTION__, stMsgData->
paramName);
153 hostIf_EthernetInterface::releaseLock();
172 int ret = NOT_HANDLED;
173 const char *pSetting;
175 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s:%d] Found string as %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
176 hostIf_EthernetInterface::getLock();
177 if(strcasecmp(stMsgData->
paramName,
"Device.Ethernet.InterfaceNumberOfEntries") == 0)
181 else if(matchComponent(stMsgData->
paramName,
182 "Device.Ethernet.Interface",&pSetting,instanceNumber))
184 if(!instanceNumber) {
185 hostIf_EthernetInterface::releaseLock();
189 memset(&msgData,0,
sizeof(msgData));
192 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Get number of interfaces failed \n", __FUNCTION__, __LINE__);
193 hostIf_EthernetInterface::releaseLock();
197 int tmpInterfaceCount = get_int(msgData.
paramValue);
198 if(instanceNumber > tmpInterfaceCount)
200 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] instanceNumber : \'%d\' is Not Supported. Total number of interfaces : \'%d\' \n", __FUNCTION__, __LINE__, \
201 instanceNumber,tmpInterfaceCount);
202 hostIf_EthernetInterface::releaseLock();
210 hostIf_EthernetInterface::releaseLock();
214 if (strcasecmp(pSetting,
"Enable") == 0)
218 else if (strcasecmp(pSetting,
"Status") == 0)
222 else if (strcasecmp(pSetting,
"Name") == 0)
226 else if (strcasecmp(pSetting,
"LastChange") == 0)
230 else if (strcasecmp(pSetting,
"Upstream") == 0)
234 else if (strcasecmp(pSetting,
"MACAddress") == 0)
238 else if (strcasecmp(pSetting,
"LowerLayers") == 0)
242 else if (strcasecmp(pSetting,
"MaxBitRate") == 0)
246 else if (strcasecmp(pSetting,
"DuplexMode") == 0)
250 else if (strcasecmp(pSetting,
"Stats.BytesSent") == 0)
254 else if (strcasecmp(pSetting,
"Stats.BytesReceived") == 0)
258 else if (strcasecmp(pSetting,
"Stats.PacketsSent") == 0)
262 else if (strcasecmp(pSetting,
"Stats.PacketsReceived") == 0)
266 else if (strcasecmp(pSetting,
"Stats.ErrorsSent") == 0)
270 else if (strcasecmp(pSetting,
"Stats.ErrorsReceived") == 0)
274 else if (strcasecmp(pSetting,
"Stats.UnicastPacketsSent") == 0)
278 else if (strcasecmp(pSetting,
"Stats.UnicastPacketsReceived") == 0)
282 else if (strcasecmp(pSetting,
"Stats.DiscardPacketsSent") == 0)
286 else if (strcasecmp(pSetting,
"Stats.DiscardPacketsReceived") == 0)
290 else if (strcasecmp(pSetting,
"Stats.MulticastPacketsSent") == 0)
294 else if (strcasecmp(pSetting,
"Stats.MulticastPacketsReceived") == 0)
298 else if (strcasecmp(pSetting,
"Stats.BroadcastPacketsSent") == 0)
302 else if (strcasecmp(pSetting,
"Stats.BroadcastPacketsReceived") == 0)
306 else if (strcasecmp(pSetting,
"Stats.UnknownProtoPacketsReceived") == 0)
312 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Parameter : \'%s\' is Not Supported \n", __FUNCTION__, __LINE__, stMsgData->
paramName);
313 stMsgData->
faultCode = fcInvalidParameterName;
318 hostIf_EthernetInterface::releaseLock();
322 int EthernetClientReqHandler::handleGetAttributesMsg(
HOSTIF_MsgData_t *stMsgData)
324 int ret = NOT_HANDLED;
325 int instanceNumber = 0;
327 hostIf_EthernetInterface::getLock();
332 hostIf_EthernetInterface::releaseLock();
336 GHashTable* notifyhash = pIface->getNotifyHash();
337 if(notifyhash != NULL)
339 int* notifyvalue = (
int*) g_hash_table_lookup(notifyhash,stMsgData->
paramName);
341 stMsgData->
paramtype = hostIf_IntegerType;
348 hostIf_EthernetInterface::releaseLock();
352 int EthernetClientReqHandler::handleSetAttributesMsg(
HOSTIF_MsgData_t *stMsgData)
354 int ret = NOT_HANDLED;
355 int instanceNumber = 0;
357 hostIf_EthernetInterface::getLock();
362 hostIf_EthernetInterface::releaseLock();
365 GHashTable* notifyhash = pIface->getNotifyHash();
366 if(notifyhash != NULL)
369 notifyValuePtr = (
int*) malloc(1 *
sizeof(
int));
374 char *notifyKey = NULL;
375 notifyKey = (
char*) calloc(
sizeof(
char),strlen(stMsgData->
paramName)+1);
376 if((NULL != notifyValuePtr) && (NULL != notifyKey))
385 g_hash_table_insert(notifyhash,notifyKey,notifyValuePtr);
391 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] EthernetClientReqHandler Not able to allocate Notify pointer %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
394 free(notifyValuePtr);
399 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] EthernetClientReqHandler Not able to get notifyhash %s\n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramName);
401 hostIf_EthernetInterface::releaseLock();
405 void EthernetClientReqHandler::registerUpdateCallback(updateCallback cb)
407 mUpdateCallback = cb;
408 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] Callback Registered .. Exiting..\n", __FILE__, __FUNCTION__);
410 void EthernetClientReqHandler::checkForUpdates()
412 const char *pSetting;
413 int instanceNumber = 0;
414 GHashTable* notifyhash = NULL;
418 char tmp_buff[TR69HOSTIFMGR_MAX_PARAM_LEN];
419 hostIf_EthernetInterface::getLock();
421 memset(&msgData,0,
sizeof(msgData));
422 memset(tmp_buff,0,TR69HOSTIFMGR_MAX_PARAM_LEN);
426 char tmp[TR69HOSTIFMGR_MAX_PARAM_LEN] =
"";
427 sprintf(tmp_buff,
"Device.Ethernet.Interface");
428 while(curNumOfDevices[index] > tmpNoDev)
430 sprintf(tmp,
"%s.%d.",tmp_buff,tmpNoDev);
434 while(curNumOfDevices[index] < tmpNoDev)
436 sprintf(tmp,
"%s.",tmp_buff);
440 curNumOfDevices[index] = get_int(msgData.
paramValue);
443 #ifdef HAVE_VALUE_CHANGE_EVENT
448 notifyhash = dIface->getNotifyHash();
452 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] Unable to get Device Info Instance\n", __FUNCTION__, __FILE__);
456 if(NULL != notifyhash)
458 GHashTableIter notifyHashIterator;
460 gpointer notifyEnable;
463 g_hash_table_iter_init (¬ifyHashIterator, notifyhash);
464 while (g_hash_table_iter_next (¬ifyHashIterator, ¶mName, ¬ifyEnable))
466 int* isNotifyEnabled = (
int *)notifyEnable;
468 if(matchComponent((
const char*)paramName,
"Device.Ethernet.Interface",&pSetting,instanceNumber))
472 hostIf_EthernetInterface::releaseLock();
478 if (strcasecmp(pSetting,
"Status") == 0)
480 memset(&msgData,0,
sizeof(msgData));
485 if(mUpdateCallback && (*isNotifyEnabled == 1))
491 else if(strcasecmp(pSetting,
"Enable") == 0)
493 memset(&msgData,0,
sizeof(msgData));
498 if(mUpdateCallback && (*isNotifyEnabled == 1))
504 else if(strcasecmp(pSetting,
"Name") == 0)
506 memset(&msgData,0,
sizeof(msgData));
511 if(mUpdateCallback && (*isNotifyEnabled == 1))
517 else if(strcasecmp(pSetting,
"LastChange") == 0)
519 memset(&msgData,0,
sizeof(msgData));
524 if(mUpdateCallback && (*isNotifyEnabled == 1))
530 else if (strcasecmp(pSetting,
"Upstream") == 0)
532 memset(&msgData,0,
sizeof(msgData));
537 if(mUpdateCallback && (*isNotifyEnabled == 1))
543 else if (strcasecmp(pSetting,
"MACAddress") == 0)
545 memset(&msgData,0,
sizeof(msgData));
550 if(mUpdateCallback && (*isNotifyEnabled == 1))
556 else if (strcasecmp(pSetting,
"LowerLayers") == 0)
558 memset(&msgData,0,
sizeof(msgData));
563 if(mUpdateCallback && (*isNotifyEnabled == 1))
569 else if (strcasecmp(pSetting,
"MaxBitRate") == 0)
571 memset(&msgData,0,
sizeof(msgData));
576 if(mUpdateCallback && (*isNotifyEnabled == 1))
582 else if (strcasecmp(pSetting,
"DuplexMode") == 0)
584 memset(&msgData,0,
sizeof(msgData));
589 if(mUpdateCallback && (*isNotifyEnabled == 1))
599 if (strcasecmp(pSetting,
"Stats.BytesSent") == 0)
601 memset(&msgData,0,
sizeof(msgData));
606 if(mUpdateCallback && (*isNotifyEnabled == 1))
612 else if (strcasecmp(pSetting,
"Stats.BytesReceived") == 0)
614 memset(&msgData,0,
sizeof(msgData));
619 if(mUpdateCallback && (*isNotifyEnabled == 1))
625 else if (strcasecmp(pSetting,
"Stats.PacketsSent") == 0)
627 memset(&msgData,0,
sizeof(msgData));
632 if(mUpdateCallback && (*isNotifyEnabled == 1))
638 else if (strcasecmp(pSetting,
"Stats.PacketsReceived") == 0)
640 memset(&msgData,0,
sizeof(msgData));
645 if(mUpdateCallback && (*isNotifyEnabled == 1))
651 else if (strcasecmp(pSetting,
"Stats.ErrorsSent") == 0)
653 memset(&msgData,0,
sizeof(msgData));
658 if(mUpdateCallback && (*isNotifyEnabled == 1))
664 else if (strcasecmp(pSetting,
"Stats.ErrorsReceived") == 0)
666 memset(&msgData,0,
sizeof(msgData));
671 if(mUpdateCallback && (*isNotifyEnabled == 1))
677 else if (strcasecmp(pSetting,
"Stats.UnicastPacketsSent") == 0)
679 memset(&msgData,0,
sizeof(msgData));
684 if(mUpdateCallback && (*isNotifyEnabled == 1))
690 else if (strcasecmp(pSetting,
"Stats.UnicastPacketsReceived") == 0)
692 memset(&msgData,0,
sizeof(msgData));
697 if(mUpdateCallback && (*isNotifyEnabled == 1))
703 else if (strcasecmp(pSetting,
"Stats.DiscardPacketsSent") == 0)
705 memset(&msgData,0,
sizeof(msgData));
710 if(mUpdateCallback && (*isNotifyEnabled == 1))
716 else if (strcasecmp(pSetting,
"Stats.DiscardPacketsReceived") == 0)
718 memset(&msgData,0,
sizeof(msgData));
723 if(mUpdateCallback && (*isNotifyEnabled == 1))
729 else if (strcasecmp(pSetting,
"Stats.MulticastPacketsSent") == 0)
731 memset(&msgData,0,
sizeof(msgData));
736 if(mUpdateCallback && (*isNotifyEnabled == 1))
742 else if (strcasecmp(pSetting,
"Stats.MulticastPacketsReceived") == 0)
744 memset(&msgData,0,
sizeof(msgData));
749 if(mUpdateCallback && (*isNotifyEnabled == 1))
755 else if (strcasecmp(pSetting,
"Stats.BroadcastPacketsSent") == 0)
757 memset(&msgData,0,
sizeof(msgData));
762 if(mUpdateCallback && (*isNotifyEnabled == 1))
768 else if (strcasecmp(pSetting,
"Stats.BroadcastPacketsReceived") == 0)
770 memset(&msgData,0,
sizeof(msgData));
775 if(mUpdateCallback && (*isNotifyEnabled == 1))
781 else if (strcasecmp(pSetting,
"Stats.UnknownProtoPacketsReceived") == 0)
783 memset(&msgData,0,
sizeof(msgData));
788 if(mUpdateCallback && (*isNotifyEnabled == 1))
800 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] Unable to get Notify Hash table\n", __FUNCTION__, __FILE__);
803 hostIf_EthernetInterface::releaseLock();