45 #include <sys/sysinfo.h>
46 #include <sys/ioctl.h>
49 #include <sys/socket.h>
50 #include <netinet/in.h>
51 #include <arpa/inet.h>
54 #include <sys/inotify.h>
64 #include "hostIf_utils.h"
66 #include <curl/curl.h>
78 #ifdef USE_REMOTE_DEBUGGER
83 #include "secure_wrapper.h"
86 #ifdef USE_MoCA_PROFILE
90 #include "Device_XComcast_Xcalibur_Client_XRE_ConnectionTable.h"
92 #if USE_HWSELFTEST_PROFILE
93 #include "DeviceInfo_hwHealthTest.h"
96 #include "hostIf_NotificationHandler.h"
97 #include "safec_lib.h"
99 #define VERSION_FILE "/version.txt"
100 #define SOC_ID_FILE "/var/log/socprov.log"
101 #define PREFERRED_GATEWAY_FILE "/opt/prefered-gateway"
102 #define FORWARD_SSH_FILE "/opt/secure/.RFC_ForwardSSH"
103 #define GATEWAY_NAME_SIZE 4
104 #define IPREMOTE_SUPPORT_STATUS_FILE "/opt/.ipremote_status"
105 #define XRE_CONTAINER_SUPPORT_STATUS_FILE "/opt/XRE_container_enable"
106 #define IPREMOTE_INTERFACE_INFO "/tmp/ipremote_interface_info"
107 #define MODEL_NAME_FILE "/tmp/.model"
108 #define PREVIOUS_REBOT_REASON_FILE "/opt/secure/reboot/previousreboot.info"
109 #define NTPENABLED_FILE "/opt/.ntpEnabled"
110 #define TR069DOSLIMIT_THRESHOLD "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Tr069DoSLimit.Threshold"
111 #define MIN_TR69_DOS_THRESHOLD 0
112 #define MAX_TR69_DOS_THRESHOLD 30
116 #define MIN_PORT_RANGE 3000
117 #define MAX_PORT_RANGE 3020
119 #define DEVICEID_SCRIPT_PATH "/lib/rdk/getDeviceId.sh"
120 #define SCRIPT_OUTPUT_BUFFER_SIZE 512
122 GHashTable* hostIf_DeviceInfo::ifHash = NULL;
123 GHashTable* hostIf_DeviceInfo::m_notifyHash = NULL;
124 GMutex* hostIf_DeviceInfo::m_mutex = NULL;
130 static int get_PartnerId_From_Script(
string& );
131 static char stbMacCache[TR69HOSTIFMGR_MAX_PARAM_LEN] = {
'\0'};
132 static string reverseSSHArgs;
133 map<string,string> stunnelSSHArgs;
134 const string sshCommand =
"/lib/rdk/startTunnel.sh";
135 const string stunnelCommand =
"/lib/rdk/startStunnel.sh";
137 string hostIf_DeviceInfo::m_xFirmwareDownloadProtocol;
138 string hostIf_DeviceInfo::m_xFirmwareDownloadURL;
139 string hostIf_DeviceInfo::m_xFirmwareToDownload;
140 bool hostIf_DeviceInfo::m_xFirmwareDownloadNow;
141 bool hostIf_DeviceInfo::m_xFirmwareDownloadUseCodebig;
142 bool hostIf_DeviceInfo::m_xFirmwareDownloadDeferReboot;
144 #ifndef NEW_HTTP_SERVER_DISABLE
145 XRFCStore* hostIf_DeviceInfo::m_rfcStore;
150 XBSStore* hostIf_DeviceInfo::m_bsStore;
151 string hostIf_DeviceInfo::m_xrPollingAction =
"0";
165 bCalledSoftwareVersion(0),
166 bCalledX_COMCAST_COM_STB_IP(0),
167 bCalledX_COMCAST_COM_FirmwareFilename(0),
168 bCalledSerialNumber(false),
169 bCalledProductClass(false),
170 bCalledAdditionalSoftwareVersion(false),
171 bCalledManufacturer(false),
172 bCalledManufacturerOUI(false),
173 bCalledModelName(false),
174 bCalledHardwareVersion(false),
175 bCalledDeviceMAC(false)
177 memset(backupSoftwareVersion, 0, _BUF_LEN_16);
178 memset(backupSerialNumber, 0, _BUF_LEN_16);
179 memset(backupProductClass, 0, _BUF_LEN_16);
180 memset(backupManufacturer, 0, _BUF_LEN_16);
181 memset(backupManufacturerOUI, 0, _BUF_LEN_16);
182 memset(backupModelName, 0, _BUF_LEN_16);
183 memset(backupHardwareVersion, 0, _BUF_LEN_16);
184 memset(backupAdditionalSoftwareVersion, 0, _BUF_LEN_16);
185 memset(backupDeviceMAC, 0, _BUF_LEN_32);
186 memset(backupX_COMCAST_COM_STB_IP, 0, _BUF_LEN_64);
187 memset(backupX_COMCAST_COM_FirmwareFilename, 0, _BUF_LEN_64);
188 #ifndef NEW_HTTP_SERVER_DISABLE
189 if(!legacyRFCEnabled())
190 m_rfcStore = XRFCStore::getInstance();
192 m_bsStore = XBSStore::getInstance();
194 hostIf_DeviceInfo::~hostIf_DeviceInfo()
198 g_hash_table_destroy(m_notifyHash);
212 ifHash = g_hash_table_new(NULL,NULL);
221 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create MoCA Interface instance..\n");
223 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
228 GList* hostIf_DeviceInfo::getAllInstances()
231 return g_hash_table_get_keys(ifHash);
239 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
244 void hostIf_DeviceInfo::closeAllInstances()
248 GList* tmp_list = g_hash_table_get_values (ifHash);
253 tmp_list = tmp_list->next;
259 void hostIf_DeviceInfo::getLock()
263 m_mutex = g_mutex_new();
265 g_mutex_lock(m_mutex);
268 void hostIf_DeviceInfo::releaseLock()
270 g_mutex_unlock(m_mutex);
273 GHashTable* hostIf_DeviceInfo::getNotifyHash()
281 return m_notifyHash = g_hash_table_new(g_str_hash, g_str_equal);
304 stMsgData->
paramtype = hostIf_StringType;
306 #if !defined (USE_DEV_PROPERTIES_CONF)
308 memset(¶m, 0,
sizeof(param));
309 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
310 param.
type = mfrSERIALIZED_TYPE_SERIALNUMBER;
313 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
314 if(iarm_ret == IARM_RESULT_SUCCESS)
323 if(bCalledSerialNumber && pChanged && strncmp(stMsgData->
paramValue,backupSerialNumber,_BUF_LEN_16 ))
327 bCalledSerialNumber =
true;
328 strncpy(backupSerialNumber,stMsgData->
paramValue,_BUF_LEN_16 );
333 stMsgData->
faultCode = fcInvalidParameterValue;
335 }
catch (
const std::exception e)
337 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
338 stMsgData->
faultCode = fcInvalidParameterValue;
344 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
352 if (param.stb_serial_no.payload != NULL)
354 snprintf(stMsgData->
paramValue, _BUF_LEN_16,
"%s", param.stb_serial_no.payload);
355 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] SerialNumber : \"%s\".\n",__FUNCTION__, param.stb_serial_no.payload );
361 stMsgData->
faultCode = fcInvalidParameterValue;
367 stMsgData->
faultCode = fcInvalidParameterValue;
395 ifstream versionfile (VERSION_FILE);
396 bool isTrunkbuild =
false;
397 bool isJenkinsbuild =
false;
398 bool versionFlag =
false;
399 char version[100] = {
'\0'};
403 if (versionfile.is_open())
405 while ( getline (versionfile,line) )
407 if (line.find(
"trunk") !=string::npos)
411 if ((line.find(
"_VERSION") == string::npos) && (line.find(
"VERSION") != string::npos))
413 char *tmpStr = strstr((
char *)line.c_str(),
"=");
415 while(isspace(*tmpStr)) {
418 rc=strcpy_s(version,
sizeof(version), tmpStr);
424 if(!isTrunkbuild)
break;
429 if (line.find(
"JENKINS_BUILD_NUMBER") !=string::npos)
431 char *tmpStr = strstr((
char *)line.c_str(),
"=");
433 while(isspace(*tmpStr)) {
436 strcat(version,
".");
437 strcat(version,tmpStr);
438 isJenkinsbuild =
true;
440 if(versionFlag &&isJenkinsbuild)
450 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s()] Failed to open file\n", __FUNCTION__);
455 if(bCalledSoftwareVersion && pChanged && strncmp(version,backupSoftwareVersion,_BUF_LEN_16 ))
459 bCalledSoftwareVersion =
true;
460 strncpy(backupSoftwareVersion,version,_BUF_LEN_16 );
461 stMsgData->
paramLen = strlen(version);
463 stMsgData->
paramtype = hostIf_StringType;
465 catch (
const std::exception e) {
466 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()]Exception caught.\n", __FUNCTION__);
469 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()] Exiting..\n", __FUNCTION__ );
488 int ret = NOT_HANDLED;
489 stMsgData->
paramtype = hostIf_StringType;
490 #if !defined (USE_DEV_PROPERTIES_CONF)
492 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
493 memset(¶m, 0,
sizeof(param));
494 param.
type = mfrSERIALIZED_TYPE_MANUFACTURER;
497 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
498 if(iarm_ret == IARM_RESULT_SUCCESS)
506 if(bCalledManufacturer && pChanged && strncmp(stMsgData->
paramValue,backupManufacturer,_BUF_LEN_16 ))
510 bCalledManufacturer =
true;
511 strncpy(backupManufacturer,stMsgData->
paramValue,_BUF_LEN_16 );
512 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
517 }
catch (
const std::exception e)
519 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
525 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
530 char* manufact = NULL;
532 if(manufact != NULL) {
533 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] manufact = %s.\n",__FUNCTION__, __FILE__, __LINE__,manufact);
534 int len = strlen(manufact);
535 strncpy((
char *)stMsgData->
paramValue, manufact, len);
538 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s stMsgData->paramLen: %d \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue,stMsgData->
paramLen);
541 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] Failed to get manufacturer from device properties..!!\n",__FUNCTION__, __FILE__, __LINE__);
544 #endif // #if !defined (USE_DEV_PROPERTIES_CONF)
568 stMsgData->
paramtype = hostIf_StringType;
569 #if !defined (USE_DEV_PROPERTIES_CONF)
571 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
572 memset(¶m, 0,
sizeof(param));
573 param.
type = mfrSERIALIZED_TYPE_MANUFACTUREROUI;
574 param.
buffer[MAX_BUF] = {
'\0'};
577 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
578 if(iarm_ret == IARM_RESULT_SUCCESS)
583 #ifdef ENABLE_MFR_MFGOUI_HEX_CONVERSION
584 char tmpConv[2]=
"\0";
586 for(
int MOUI_indx=0;MOUI_indx<param.
bufLen;MOUI_indx++)
588 sprintf(tmpConv,
"%02hhX",param.
buffer[MOUI_indx]);
589 strcat((
char *)stMsgData->
paramValue,tmpConv);
598 if(bCalledManufacturerOUI && pChanged && strncmp(stMsgData->
paramValue,backupManufacturerOUI,_BUF_LEN_16 ))
602 bCalledManufacturerOUI =
true;
603 strncpy(backupManufacturerOUI,stMsgData->
paramValue,_BUF_LEN_16 );
604 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
609 }
catch (
const std::exception e)
611 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
617 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
622 #endif //#if !defined (USE_DEV_PROPERTIES_CONF)
623 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__);
643 stMsgData->
paramtype = hostIf_StringType;
644 #if !defined (USE_DEV_PROPERTIES_CONF)
646 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
647 memset(¶m, 0,
sizeof(param));
648 param.
type = mfrSERIALIZED_TYPE_MODELNAME;
651 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
653 if(iarm_ret == IARM_RESULT_SUCCESS)
661 if(bCalledModelName && pChanged && strncmp(stMsgData->
paramValue,backupModelName,_BUF_LEN_16 ))
665 bCalledModelName =
true;
666 strncpy(backupModelName,stMsgData->
paramValue,_BUF_LEN_16 );
667 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
672 }
catch (
const std::exception e)
674 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
680 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
686 char modelName[64] = {
'\0'};
688 fp = fopen(MODEL_NAME_FILE,
"r");
690 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] Failed to open MODEL Name file\n.!",__FUNCTION__, __FILE__, __LINE__);
693 if(fgets(modelName, 64,fp)!=NULL) {
695 int len = strlen(modelName);
696 if(modelName[len-1] ==
'\n') modelName[len-1] =
'\0';
697 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] modelName = %s.\n",__FUNCTION__, __FILE__, __LINE__,modelName);
700 stMsgData->
paramLen = strlen(modelName);
701 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s stMsgData->paramLen: %d \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue,stMsgData->
paramLen);
704 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s(): Failed to read model name.\n", __FUNCTION__);
708 #endif //#if !defined (USE_DEV_PROPERTIES_CONF)
709 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__);
726 stMsgData->
paramtype = hostIf_StringType;
727 const char *desc =
"TR-181, TR-135 and Comcast specific Datamodel Configuration";
728 snprintf((
char *)stMsgData->
paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN-1,
"%s", desc);
750 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__);
751 stMsgData->
paramtype = hostIf_StringType;
753 #ifndef FETCH_PRODUCTCLASS_FROM_MFRLIB
756 pc = getenv((
const char *)
"RECEIVER_PLAT_TYPE");
759 snprintf((
char *)stMsgData->
paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN-1,
"%s", pc);
766 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
767 memset(¶m, 0,
sizeof(param));
768 param.
type = mfrSERIALIZED_TYPE_PRODUCTCLASS;
769 param.
buffer[MAX_BUF] = {
'\0'};
772 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\n",__FUNCTION__, param.
buffer, param.
bufLen);
773 if(iarm_ret == IARM_RESULT_SUCCESS)
781 if(bCalledProductClass && pChanged && strncmp(stMsgData->
paramValue,backupProductClass,_BUF_LEN_16 ))
785 bCalledProductClass =
true;
786 strncpy(backupProductClass,stMsgData->
paramValue,_BUF_LEN_16 );
787 stMsgData->
paramtype = hostIf_StringType;
788 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
793 }
catch (
const std::exception e)
795 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\n",__FUNCTION__);
801 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
824 stMsgData->
paramtype = hostIf_StringType;
826 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
827 memset(¶m, 0,
sizeof(param));
828 param.
type = mfrSERIALIZED_TYPE_HARDWAREVERSION;
831 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
832 if(iarm_ret == IARM_RESULT_SUCCESS)
840 if(bCalledHardwareVersion && pChanged && strncmp(stMsgData->
paramValue,backupHardwareVersion,_BUF_LEN_16 ))
844 bCalledHardwareVersion =
true;
845 strncpy(backupHardwareVersion,stMsgData->
paramValue,_BUF_LEN_16 );
846 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
851 }
catch (
const std::exception e)
853 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
860 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
864 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__);
880 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__ );
903 int ret = NOT_HANDLED;
904 stMsgData->
paramtype = hostIf_StringType;
906 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
907 memset(¶m, 0,
sizeof(param));
909 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
911 param.
type = mfrSERIALIZED_TYPE_SOFTWAREVERSION;
915 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
916 if(iarm_ret == IARM_RESULT_SUCCESS)
923 if(bCalledAdditionalSoftwareVersion && pChanged && strncmp(stMsgData->
paramValue,backupAdditionalSoftwareVersion,_BUF_LEN_16 ))
927 bCalledAdditionalSoftwareVersion =
true;
928 strncpy(backupAdditionalSoftwareVersion,stMsgData->
paramValue,_BUF_LEN_16 );
931 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
936 }
catch (
const std::exception e)
938 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
944 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
968 stMsgData->
paramtype = hostIf_StringType;
970 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
971 memset(¶m, 0,
sizeof(param));
972 param.
type = mfrSERIALIZED_TYPE_PROVISIONINGCODE;
975 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
976 if(iarm_ret == IARM_RESULT_SUCCESS)
985 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->
paramValue, param.
buffer);
992 }
catch (
const std::exception e)
994 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
1001 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
1004 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__);
1024 struct sysinfo info;
1027 stMsgData->
paramtype = hostIf_IntegerType;
1051 char buffer [36] = {
'\0'};
1052 char timeZoneTmp[7] = {
'\0'};
1054 if (0 > stat(NTP_FILE_NAME, &st))
1056 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d]Failed:Error on stat() for %s \n",__FILE__,__FUNCTION__,__LINE__, NTP_FILE_NAME);
1060 tm = gmtime(&(st.st_mtime));
1061 strftime(buffer,
sizeof(buffer),
"%Y-%m-%dT%H:%M:%S", tm);
1062 strftime(timeZoneTmp,
sizeof(timeZoneTmp),
"%z", tm);
1063 sprintf(buffer + strlen(buffer),
".%.6d%s", tm->tm_sec, timeZoneTmp);
1065 stMsgData->
paramtype = hostIf_StringType;
1066 stMsgData->
paramLen = strlen(buffer);
1086 int ret = NOT_HANDLED;
1087 #if !defined (USE_DEV_PROPERTIES_CONF)
1089 memset(¶m, 0,
sizeof(param));
1090 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
1091 param.
type = mfrSERIALIZED_TYPE_DEVICEMAC;
1092 int len = strlen(stbMacCache);
1097 if((stbMacCache[0] ==
'\0') && (len == 0)) {
1099 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] IARM_BUS_MFRLIB_API_GetSerializedData returns params: %s with paramlen: %d.\r\n",__FUNCTION__, param.
buffer, param.
bufLen);
1100 if(iarm_ret == IARM_RESULT_SUCCESS)
1106 if(bCalledDeviceMAC && pChanged && strncmp(stMsgData->
paramValue,backupDeviceMAC,_BUF_LEN_32 ))
1110 bCalledDeviceMAC =
true;
1111 strncpy(backupDeviceMAC,stMsgData->
paramValue,_BUF_LEN_32 );
1112 memset(stbMacCache,
'\0', TR69HOSTIFMGR_MAX_PARAM_LEN );
1114 stMsgData->
paramtype = hostIf_StringType;
1118 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in \'IARM_BUS_MFRLIB_API_GetSerializedData\' for parameter : %s [ Value :%s with size :%d]\n",stMsgData->
paramName, param.
buffer, param.
bufLen);
1123 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%d with error code:%d]\n",stMsgData->
paramName,param.
type, ret);
1129 memset(stMsgData->
paramValue,
'\0', TR69HOSTIFMGR_MAX_PARAM_LEN );
1132 stMsgData->
paramtype = hostIf_StringType;
1135 }
catch (
const std::exception& e)
1137 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
1140 #else //if defined (USE_DEV_PROPERTIES_CONF)
1141 memset(stMsgData->
paramValue,
'\0', TR69HOSTIFMGR_MAX_PARAM_LEN );
1142 string stb_mac = getStbMacIf_fr_devProperties();
1143 if(!stb_mac.empty())
1152 stMsgData->
faultCode = fcInvalidParameterValue;
1153 stMsgData->
paramLen = stb_mac.length();
1154 stMsgData->
paramtype = hostIf_StringType;
1157 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s()]\n", __FUNCTION__);
1161 string hostIf_DeviceInfo::getEstbIp()
1163 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]Entering..\n", __FUNCTION__);
1166 IARM_Result_t ret = IARM_RESULT_SUCCESS;
1168 memset(¶m, 0,
sizeof(param));
1171 ret =
IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME,IARM_BUS_NETSRVMGR_API_getSTBip, (
void*)¶m,
sizeof(param));
1172 if (ret != IARM_RESULT_SUCCESS )
1174 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] IARM_BUS_NETSRVMGR_API_getActiveInterface failed \n", __FUNCTION__, __LINE__);
1176 retAddr=param.activeIfaceIpaddr;
1181 struct ifaddrs *ifAddrStr = NULL;
1182 struct ifaddrs * ifa = NULL;
1183 void * tmpAddrPtr = NULL;
1184 char tmp_buff[TR69HOSTIFMGR_MAX_PARAM_LEN] = {
'\0'};
1187 const char *ipv6_fileName =
"/tmp/estb_ipv6";
1188 const char *Wifi_Enable_file =
"/tmp/wifi-on";
1192 bool ipv6Enabled = (!access (ipv6_fileName, F_OK))?
true:
false;
1193 bool isWifiEnabled = (!access (Wifi_Enable_file, F_OK))?
true:
false;
1194 const char* ip_if = NULL;
1199 ip_if =
"DEFAULT_ESTB_INTERFACE";
1202 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] ipv6Enabled : %d; isWifiEnabled : %d ethIf : %s\n",
1203 __FUNCTION__, __LINE__, ipv6Enabled, isWifiEnabled, ethIf);
1205 if(getifaddrs(&ifAddrStr))
1207 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s():%d] Failed in getifaddrs().\n", __FUNCTION__, __LINE__);
1212 for (ifa = ifAddrStr; ifa != NULL; ifa = ifa->ifa_next)
1214 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] if name : %s; family : %d %s \n", __FUNCTION__, __LINE__,
1216 ifa ->ifa_addr->sa_family,
1217 (ifa ->ifa_addr->sa_family == AF_PACKET) ?
" (AF_PACKET)" :
1218 (ifa ->ifa_addr->sa_family == AF_INET) ?
" (AF_INET)" :
1219 (ifa ->ifa_addr->sa_family == AF_INET6) ?
" (AF_INET6)" :
"" );
1221 if (ifa->ifa_addr == NULL)
continue;
1226 if ((ifa ->ifa_addr->sa_family == AF_INET6))
1228 tmpAddrPtr=&((
struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
1229 inet_ntop(AF_INET6, tmpAddrPtr, tmp_buff, INET6_ADDRSTRLEN);
1231 if(isWifiEnabled && (!(IN6_IS_ADDR_LINKLOCAL(tmpAddrPtr)))) {
1232 if(!strcmp(ifa->ifa_name,
"wlan0")) {
1233 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] Got ipaddress \'%s\' for (%s), breaking loop.\n", __FUNCTION__, __LINE__, tmp_buff, ifa->ifa_name);
1238 if(!strcmp(ifa->ifa_name, ethIf) && (!(IN6_IS_ADDR_LINKLOCAL(tmpAddrPtr)))) {
1239 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] Got ipaddress \'%s\' for (%s), breaking loop.\n", __FUNCTION__, __LINE__, tmp_buff, ifa->ifa_name);
1247 if (ifa ->ifa_addr->sa_family == AF_INET) {
1248 tmpAddrPtr=&((
struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
1249 inet_ntop(AF_INET, tmpAddrPtr, tmp_buff, INET_ADDRSTRLEN);
1252 if(!strcmp(ifa->ifa_name,
"wlan0")) {
1253 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] Got ipaddress \'%s\' for (%s), breaking loop.\n", __FUNCTION__, __LINE__, tmp_buff, ifa->ifa_name);
1258 else if (strcmp(ifa->ifa_name, ethIf)==0) {
1259 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s():%d] Got ipaddress \'%s\' for (%s), breaking loop.\n", __FUNCTION__, __LINE__, tmp_buff, ifa->ifa_name);
1267 if (ifAddrStr!=NULL) {
1268 freeifaddrs(ifAddrStr);
1279 catch (
const std::exception &e)
1281 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()]Exception caught %s\n", __FUNCTION__, e.what());
1283 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]Exiting..\n", __FUNCTION__);
1287 bool hostIf_DeviceInfo::isRsshactive()
1289 const string pidfile(
"/var/tmp/rssh.pid");
1290 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
1291 bool retCode =
false;
1294 pidstrm.exceptions(std::ifstream::failbit | std::ifstream::badbit);
1296 pidstrm.open(pidfile.c_str());
1300 if (getpgid(sshpid) >= 0)
1302 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] SSH Session Active \n",__FUNCTION__);
1307 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] SSH Session inactive \n",__FUNCTION__);
1309 }
catch (
const std::exception& e) {
1310 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] SSH Session inactive ; Error opening pid file\n",__FUNCTION__);
1313 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
1330 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]Entering..\n", __FUNCTION__);
1332 string ipaddr = getEstbIp();
1336 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s()]Ipaddress is empty..\n", __FUNCTION__);
1340 if(bCalledX_COMCAST_COM_STB_IP && pChanged && strncmp(ipaddr.c_str(),backupX_COMCAST_COM_STB_IP,_BUF_LEN_64 ))
1344 bCalledX_COMCAST_COM_STB_IP =
true;
1345 strncpy(backupX_COMCAST_COM_STB_IP,ipaddr.c_str(),
sizeof(backupX_COMCAST_COM_STB_IP) -1);
1346 backupX_COMCAST_COM_STB_IP [
sizeof(backupX_COMCAST_COM_STB_IP) -1] =
'\0';
1347 memset(stMsgData->
paramValue,
'\0', _BUF_LEN_64);
1348 stMsgData->
paramLen = ipaddr.length();
1350 stMsgData->
paramtype = hostIf_StringType;
1352 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]Exiting..\n", __FUNCTION__);
1371 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()]Entering..\n", __FUNCTION__);
1374 const char *pwrState =
"PowerOFF";
1377 memset(¶m, 0,
sizeof(param));
1378 IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
1384 if(err == IARM_RESULT_SUCCESS)
1386 pwrState = (param.curState==IARM_BUS_PWRMGR_POWERSTATE_OFF)?
"PowerOFF":(param.curState==IARM_BUS_PWRMGR_POWERSTATE_ON)?
"PowerON":
"Standby";
1389 str_len = strlen(pwrState);
1392 strncpy((
char *)stMsgData->
paramValue, pwrState, str_len);
1395 stMsgData->
paramtype = hostIf_StringType;
1397 }
catch (
const std::exception e)
1399 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
1405 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in IARM_Bus_Call() for parameter : %s [param.type:%s with error code:%d]\n",stMsgData->
paramName, pwrState, ret);
1429 bool curFileFlag =
true;
1430 ifstream curFwfile(CURENT_FW_FILE);
1433 if(curFwfile.is_open())
1435 if(getline (curFwfile,line))
1438 strncpy(stMsgData->
paramValue, line.c_str(), line.length()+1 );
1441 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed: \'%s\' has no content or empty..\n", CURENT_FW_FILE);
1442 curFileFlag =
false;
1447 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed to read \'%s\' due to Empty Buffer. \n", CURENT_FW_FILE);
1448 curFileFlag =
false;
1454 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed \'%s\' due to [\'%s\' (%d)]. \n", CURENT_FW_FILE, strerror(errno), errno);
1455 curFileFlag =
false;
1460 ifstream myfile (
"/version.txt");
1461 if (myfile.is_open())
1463 while ( getline (myfile,line) )
1465 size_t found = line.find(
"imagename");
1466 if (found!=string::npos)
1475 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file\n", __FUNCTION__);
1479 char * cstr =
new char [line.length()+1];
1480 rc=strcpy_s (cstr,(line.length()+1), line.c_str());
1486 pch = strstr (cstr,
":");
1489 while(isspace(*pch)) {
1494 if(bCalledX_COMCAST_COM_FirmwareFilename && pChanged && strncmp(pch,backupX_COMCAST_COM_FirmwareFilename,_BUF_LEN_64 ))
1499 bCalledX_COMCAST_COM_FirmwareFilename =
true;
1500 strncpy(backupX_COMCAST_COM_FirmwareFilename,pch,
sizeof(backupX_COMCAST_COM_FirmwareFilename) -1);
1501 backupX_COMCAST_COM_FirmwareFilename[
sizeof(backupX_COMCAST_COM_FirmwareFilename) -1] =
'\0';
1502 strncpy(stMsgData->
paramValue,pch,_BUF_LEN_64 );
1507 stMsgData->
paramtype = hostIf_StringType;
1510 catch (
const std::exception e) {
1511 cout << __FUNCTION__ << endl;
1539 catch (
const std::exception & e) {
1540 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()] Exception occurred due to %s. \n", __FUNCTION__, e.what());
1579 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(
HOSTIF_MsgData_t* stMsgData,
bool *pChanged)
1581 stMsgData->
paramtype = hostIf_BooleanType;
1582 stMsgData->
paramLen =
sizeof(bool);
1589 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent (
HOSTIF_MsgData_t* stMsgData,
bool *pChanged)
1593 int firmwareDownloadPercent = -1;
1595 if (OK == read_command_output ((
char *)
"cat /opt/curl_progress | tr -s '\r' '\n' | tail -n 1 | sed 's/^ *//g' | tr -s ' ' | cut -d ' ' -f3", output, 8))
1597 output[strcspn(output,
"\n")] = 0;
1600 firmwareDownloadPercent = strtol (output, NULL, 10);
1604 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] FirmwareDownloadPercent = [%d]\n", __FUNCTION__, firmwareDownloadPercent);
1607 stMsgData->
paramtype = hostIf_IntegerType;
1613 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareUpdateState(
HOSTIF_MsgData_t * stMsgData,
bool *pChanged)
1663 char resultBuff[200] = {
'\0'};
1664 char cmd[200] =
"/bin/cat /proc/cpuinfo | /bin/grep processor | /usr/bin/wc -l";
1665 int noOfProcessorEntries = 0;
1667 fp = popen(cmd,
"r");
1670 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"%s(): Error popen\n", __FUNCTION__);
1674 if(fgets(resultBuff, 200,fp)!=NULL) {
1675 sscanf(resultBuff,
"%d",&noOfProcessorEntries);
1680 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"%s(): Processors Count: [%d]\n", __FUNCTION__, noOfProcessorEntries);
1683 stMsgData->
paramtype = hostIf_UnsignedIntType;
1742 struct sysinfo sys_info;
1744 sysinfo (&sys_info);
1745 put_int(stMsgData->
paramValue, (
unsigned int) (sys_info.totalram *(
unsigned long long)sys_info.mem_unit / 1024));
1746 stMsgData->
paramtype = hostIf_IntegerType;
1770 struct sysinfo sys_info;
1772 sysinfo (&sys_info);
1773 put_int(stMsgData->
paramValue,(
unsigned int) (sys_info.freeram *(
unsigned long long)sys_info.mem_unit / 1024));
1774 stMsgData->
paramtype = hostIf_IntegerType;
1804 int mocaStatus = NOK;
1805 bool check_AcsConnStatus =
false;
1806 bool check_GatewayConnStatus =
false;
1807 bool check_XreConnStatus =
false;
1808 char statusStr[TR69HOSTIFMGR_MAX_PARAM_LEN] = {
'\0'};
1811 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering \n",__FUNCTION__);
1820 #ifdef USE_MoCA_PROFILE
1824 check_AcsConnStatus =
true;
1827 if(mocaStatus == OK)
1829 check_AcsConnStatus =
true;
1838 if(check_GatewayConnStatus)
1841 if(get_GatewayConnStatus() ==
true)
1843 memset(statusStr,
'\0', TR69HOSTIFMGR_MAX_PARAM_LEN);
1844 rc=strcpy_s(statusStr,
sizeof(statusStr),
"Connection successful");
1849 check_AcsConnStatus =
true;
1851 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] BootStatus: %s GatewayConnStatuss: %d\n", __FILE__, __FUNCTION__, statusStr, get_GatewayConnStatus());
1859 snprintf(stTR069SupportData.
paramName, TR69HOSTIFMGR_MAX_PARAM_LEN-1,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.TR069support.Enable");
1860 stTR069SupportData.
paramtype = hostIf_BooleanType;
1861 get_xRDKCentralComRFC(&stTR069SupportData);
1863 bool isTr69RfcEnabled = get_boolean(stTR069SupportData.
paramValue);
1865 check_AcsConnStatus = (isTr69RfcEnabled)?
true:
false;
1867 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] %s: %d\n", __FUNCTION__, __LINE__, stTR069SupportData.
paramName, isTr69RfcEnabled);
1874 if(check_AcsConnStatus)
1876 if(get_ACSStatus() ==
true)
1878 memset(statusStr,
'\0', TR69HOSTIFMGR_MAX_PARAM_LEN);
1879 rc=strcpy_s(statusStr,
sizeof(statusStr),
"Contacting ACS");
1884 check_XreConnStatus =
true;
1889 check_XreConnStatus =
true;
1898 if(get_Device_X_COMCAST_COM_Xcalibur_Client_XRE_ConnectionTable_xreConnStatus(stMsgData) == OK)
1900 const char* xreConn =
"XRE connection established - Successful";
1901 const char* xreConnAcs =
"XRE connection established, ACS connection in progresss";
1903 if(strcasecmp(stMsgData->
paramValue,
"Connected" ) == 0) {
1904 memset(stMsgData->
paramValue,
'\0', TR69HOSTIFMGR_MAX_PARAM_LEN);
1905 snprintf(statusStr, TR69HOSTIFMGR_MAX_PARAM_LEN -1, ((check_XreConnStatus)?xreConn:((check_AcsConnStatus)?xreConnAcs:xreConn)));
1910 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] BootStatus string: %s \n", __FILE__, __FUNCTION__, statusStr);
1911 strncpy(stMsgData->
paramValue, statusStr, TR69HOSTIFMGR_MAX_PARAM_LEN);
1912 stMsgData->
paramLen = strlen(statusStr);
1913 stMsgData->
paramtype = hostIf_StringType;
1914 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting \n",__FUNCTION__);
1935 cpuTemp = (int)round(dsCpuTemp);
1937 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%s] Current CPU temperature is: %+7.2fC and roundoff CPUTemp : [%d] \n",
1938 __FILE__, __FUNCTION__, dsCpuTemp, cpuTemp);
1941 stMsgData->
paramtype = hostIf_IntegerType;
1949 char prefGatewayValue[GATEWAY_NAME_SIZE];
1951 if((fp=fopen(PREFERRED_GATEWAY_FILE,
"r"))==NULL)
1953 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file\n", __FUNCTION__);
1954 prefGatewayValue[0]=
'\0';
1959 if(fgets(prefGatewayValue, GATEWAY_NAME_SIZE, fp) == NULL)
1961 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]not able to read string from file \n", __FUNCTION__);
1962 prefGatewayValue[0]=
'\0';
1967 strncpy(stMsgData->
paramValue,prefGatewayValue,TR69HOSTIFMGR_MAX_PARAM_LEN );
1968 stMsgData->
paramtype = hostIf_StringType;
1982 RDK_LOG (RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"[%s]Entering...\n", __FUNCTION__);
1984 FILE *logUpfile = NULL;
1986 char* curLogUploadStatus = (
char*) malloc (n);
1988 if(curLogUploadStatus == NULL)
1990 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] curLogUploadStatus is Null\n", __FUNCTION__);
1992 else if ((logUpfile = fopen (CURRENT_LOG_UPLOAD_STATUS,
"r")) == NULL)
1994 sprintf (curLogUploadStatus,
"Unknown: Failed to open file '%s' due to \'%s\'.", CURRENT_LOG_UPLOAD_STATUS, strerror (errno));
1995 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] curLogUploadStatus = %s\n", __FUNCTION__, curLogUploadStatus);
1997 else if (-1 == getline (&curLogUploadStatus, &n, logUpfile))
1999 sprintf (curLogUploadStatus,
"Unknown: Failed to read file '%s'.", CURRENT_LOG_UPLOAD_STATUS);
2000 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] curLogUploadStatus = %s\n", __FUNCTION__, curLogUploadStatus);
2005 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] Successfully read from %s. The value is \'%s\'. \n", __FUNCTION__, CURRENT_LOG_UPLOAD_STATUS,
2006 curLogUploadStatus);
2011 strncat (stMsgData->
paramValue, curLogUploadStatus, TR69HOSTIFMGR_MAX_PARAM_LEN - 1);
2013 if (curLogUploadStatus)
2014 free (curLogUploadStatus);
2016 stMsgData->
paramtype = hostIf_StringType;
2019 RDK_LOG (RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"[%s]Exiting...\n", __FUNCTION__);
2024 int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_BootTime(
HOSTIF_MsgData_t * stMsgData,
bool *pChanged)
2027 static unsigned int bTime = 0;
2028 struct sysinfo sys_info;
2029 struct timeval currTime;
2033 if(sysinfo(&sys_info)) {
2034 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in sysinfo due to \'%s\' (%d). \n", strerror(errno), errno);
2038 unsigned long upTime = sys_info.uptime;
2040 if(gettimeofday(&currTime, NULL)) {
2041 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in sysinfo due to \'%s\' (%d). \n", strerror(errno), errno);
2044 bTime = (
unsigned int)(currTime.tv_sec - upTime);
2047 RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s]The Bootup Time is [%u].\n", __FUNCTION__, bTime);
2049 stMsgData->
paramtype = hostIf_UnsignedIntType;
2050 stMsgData->
paramLen =
sizeof(hostIf_UnsignedIntType);
2054 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(
HOSTIF_MsgData_t *stMsgData)
2058 if((fp=fopen(PREFERRED_GATEWAY_FILE,
"w"))==NULL)
2060 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file\n", __FUNCTION__);
2067 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]not able to read string from file \n", __FUNCTION__);
2101 char scriptbuff[100] = {
'\0'};
2104 pthread_t reset_Thread;
2105 pthread_attr_t attr;
2106 pthread_attr_init(&attr);
2107 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
2111 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s():] Set as NULL. Fail to execute \'X_COMCAST_COM_Reset\'Please give the correct input value as \
2112 a \'Cold\', \'Factory\', \'Warehouse\' or \'Customer\' String. \n",__FUNCTION__);
2115 if (0 == strcasecmp(val,
"Cold"))
2117 setResetState(ColdReset);
2119 else if (0 == strcasecmp(val,
"Factory"))
2121 setResetState(FactoryReset);
2123 else if (0 == strcasecmp(val,
"Warehouse"))
2125 setResetState(WarehouseReset);
2127 else if (0 == strcasecmp(val,
"Customer"))
2129 setResetState(CustomerReset);
2133 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Invalid input: %s. Please give the correct input value as a \'Cold\', \'Factory\', \'Warehouse\' or \'Customer\' String. \n",__FUNCTION__,val);
2137 rc = pthread_create(&reset_Thread, &attr,
ResetFunc, NULL);
2139 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"ERROR; return code from pthread_create() is %d\n", rc);
2140 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"ERROR; failed to do \'%s\' \n", val);
2153 triggerResetScript();
2159 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig(
HOSTIF_MsgData_t *stMsgData)
2161 m_xFirmwareDownloadUseCodebig = get_boolean(stMsgData->
paramValue);
2162 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s]Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, stMsgData->
paramName, m_xFirmwareDownloadUseCodebig);
2167 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(
HOSTIF_MsgData_t *stMsgData)
2169 m_xFirmwareDownloadDeferReboot = get_boolean(stMsgData->
paramValue);
2170 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s]Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, stMsgData->
paramName, m_xFirmwareDownloadDeferReboot);
2189 m_xFirmwareToDownload = stMsgData->
paramValue;
2191 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s]Successfully set \"%s\" to \"%s\". \n", __FUNCTION__, stMsgData->
paramName, m_xFirmwareToDownload.c_str() );
2214 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol (
HOSTIF_MsgData_t *stMsgData)
2217 m_xFirmwareDownloadProtocol = stMsgData->
paramValue;
2219 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s]Successfully set \"%s\" to \"%s\". \n", __FUNCTION__, stMsgData->
paramName, m_xFirmwareDownloadProtocol.c_str() );
2223 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL (
HOSTIF_MsgData_t *stMsgData)
2226 m_xFirmwareDownloadURL = stMsgData->
paramValue;
2228 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s]Successfully set \"%s\" to \"%s\". \n", __FUNCTION__, stMsgData->
paramName, m_xFirmwareDownloadURL.c_str() );
2234 bool triggerUploadLog =
false;
2235 char syscommand[256] = {
'\0'};
2237 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2238 triggerUploadLog = get_boolean(stMsgData->
paramValue);
2240 if(triggerUploadLog)
2243 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Start executing script to upload logs... \n",__FUNCTION__);
2244 sprintf(syscommand,
"%s &", LOG_UPLOAD_SCR);
2246 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Successfully executed %s. \n", syscommand);
2250 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Failed, the set value is %d, so failed to execute . Please set as true(1)\
2251 to execute trigger upload now. \n",__FUNCTION__, triggerUploadLog );
2254 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2260 bool mocaLogEnabled =
false;
2262 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2263 mocaLogEnabled = get_boolean(stMsgData->
paramValue);
2264 #ifdef USE_MoCA_PROFILE
2265 if (
IARM_Bus_BroadcastEvent(IARM_BUS_NM_SRV_MGR_NAME, (IARM_EventId_t) IARM_BUS_NETWORK_MANAGER_MOCA_TELEMETRY_LOG, (
void *)&mocaLogEnabled,
sizeof(mocaLogEnabled)) == IARM_RESULT_SUCCESS)
2267 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] MoCA Telemetry Logging is %d \n",__FUNCTION__, mocaLogEnabled);
2271 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] MoCA Telemetry Logging IARM FAILURE \n",__FUNCTION__);
2274 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2278 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(
HOSTIF_MsgData_t *stMsgData)
2280 const char *status = getStringValue(stMsgData).c_str();
2282 if(0 == strcasecmp(status,
"false"))
2285 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] IPRemoteSupport disable request\n", __FUNCTION__);
2286 ifstream ifp(IPREMOTE_SUPPORT_STATUS_FILE);
2289 if(remove(IPREMOTE_SUPPORT_STATUS_FILE) == 0)
2291 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Removed File %s, IPRemoteSupport is disabled\n", __FUNCTION__, IPREMOTE_SUPPORT_STATUS_FILE);
2296 else if(0 == strcasecmp(status,
"true"))
2298 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] IPRemoteSupport enable request\n", __FUNCTION__);
2299 ofstream ofp(IPREMOTE_SUPPORT_STATUS_FILE);
2300 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Created File %s, IPRemoteSupport is enabled\n", __FUNCTION__, IPREMOTE_SUPPORT_STATUS_FILE);
2304 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Value not passed for the param, IPRemoteSupport Status unchanged \n", __FUNCTION__);
2310 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(
HOSTIF_MsgData_t *stMsgData)
2312 m_xrPollingAction = getStringValue(stMsgData);
2313 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Setting XRPollingAction to %s\n", __FUNCTION__, m_xrPollingAction.c_str());
2317 size_t static writeCurlResponse(
void *ptr,
size_t size,
size_t nmemb,
string stream)
2319 size_t realsize = size * nmemb;
2320 string temp(
static_cast<const char*
>(ptr), realsize);
2321 stream.append(temp);
2327 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2328 string n_PartnerId=
"";
2329 string current_PartnerId=
"";
2332 n_PartnerId=getStringValue(stMsgData);
2334 if(n_PartnerId.empty())
2336 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] We received empty Buffer \n", __FUNCTION__);
2340 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Calling get_PartnerId_From_Script \n",__FUNCTION__);
2343 ret = get_PartnerId_From_Script (current_PartnerId);
2346 if( !current_PartnerId.empty() && ret == OK )
2348 if( n_PartnerId.compare(current_PartnerId) )
2350 CURL *curl = curl_easy_init();
2351 bool upload_flag =
false;
2352 std::string postData;
2353 std::string tokenheader;
2360 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] call curl to set partner ID.. with New PartnerId = %s \n", __FUNCTION__, n_PartnerId.c_str());
2364 tokenheader =
"Authorization: Bearer " + sToken;
2366 postData =
"{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.setPartnerId\", \"params\" : { \"partnerId\" : \"";
2367 postData += n_PartnerId;
2370 struct curl_slist *list = NULL;
2372 list = curl_slist_append(list, tokenheader.c_str());
2373 list = curl_slist_append(list,
"Content-Type: application/json");
2375 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
2376 curl_easy_setopt(curl, CURLOPT_POST, 1L);
2377 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (
long)postData.length());
2378 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());
2379 curl_easy_setopt(curl, CURLOPT_URL, JSONRPC_URL);
2381 CURLcode res = curl_easy_perform(curl);
2383 if ( res == CURLE_OK )
2385 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
2386 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] curl response : %d http response code: %ld\n", __FUNCTION__, res, http_code);
2389 curl_easy_cleanup(curl);
2390 curl_slist_free_all(list);
2392 if( res == CURLE_OK && http_code == HTTP_OK )
2395 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] PartnerID uploaded using Curl Success \n",__FUNCTION__);
2399 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] curl returned with error : %d http response code: %ld\n",\
2400 __FUNCTION__, res, http_code);
2405 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] curl init failed\n", __FUNCTION__);
2414 ret = m_bsStore->overrideValue(stMsgData);
2418 if ( !m_bsStore->call_loadJson() )
2420 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] loadFromJson() failed for new partner id %s,\
2421 continuing with older config from partner id %s \n", __FUNCTION__, n_PartnerId.c_str(), current_PartnerId.c_str());
2427 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Bootstrap update failed for new partner id %s,\
2428 continuing with older config from partner id %s\n",__FUNCTION__,n_PartnerId.c_str(), current_PartnerId.c_str());
2434 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] PartnerIDs are same. \n",__FUNCTION__);
2440 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] We received empty Buffer \n", __FUNCTION__);
2444 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] PartnerID uploaded using Curl Success =>\
2445 Updated new partnerid:%s to authservice \n",__FUNCTION__, n_PartnerId.c_str());
2446 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2450 int static get_PartnerId_From_Script(
string& current_PartnerId )
2452 FILE *deviceIdScript = NULL;
2453 char scriptoutput[SCRIPT_OUTPUT_BUFFER_SIZE] = {0};
2455 deviceIdScript = popen(DEVICEID_SCRIPT_PATH,
"r");
2456 if ( (NULL != deviceIdScript) ) {
2457 if (fgets(scriptoutput,SCRIPT_OUTPUT_BUFFER_SIZE,deviceIdScript)!=NULL) {
2458 cJSON* root = cJSON_Parse(scriptoutput);
2461 cJSON* partnerID = cJSON_GetObjectItem(root,
"partnerId");
2462 if (partnerID->type == cJSON_String && partnerID->valuestring && strlen(partnerID->valuestring) > 0)
2464 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"Found partnerID value = %s\n", partnerID->valuestring);
2465 current_PartnerId = partnerID->valuestring;
2471 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] json parse error\n", __FUNCTION__);
2472 pclose(deviceIdScript);
2477 pclose(deviceIdScript);
2482 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(
HOSTIF_MsgData_t *stMsgData)
2484 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2485 string current_PartnerId =
"";
2488 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Calling get_PartnerId_From_Script \n",__FUNCTION__);
2489 ret = get_PartnerId_From_Script( current_PartnerId );
2491 if( !current_PartnerId.empty() && ret == OK )
2493 stMsgData->
paramLen = current_PartnerId.length();
2495 stMsgData->
paramtype = hostIf_StringType;
2499 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] We received empty Buffer after curl \n", __FUNCTION__);
2507 unsigned int mocaLogDuration = 3600;
2509 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2510 mocaLogDuration = get_int(stMsgData->
paramValue);
2512 #ifdef USE_MoCA_PROFILE
2513 if (
IARM_Bus_BroadcastEvent(IARM_BUS_NM_SRV_MGR_NAME, (IARM_EventId_t) IARM_BUS_NETWORK_MANAGER_MOCA_TELEMETRY_LOG_DURATION, (
void *)&mocaLogDuration,
sizeof(mocaLogDuration)) == IARM_RESULT_SUCCESS)
2515 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] MoCA Telemetry Logging Duration is %d \n",__FUNCTION__, mocaLogDuration);
2519 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] MoCA Telemetry Logging Duration IARM FAILURE \n",__FUNCTION__);
2522 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2527 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2528 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
2530 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
2531 #ifdef USE_MoCA_PROFILE
2532 retVal =
IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME,IARM_BUS_NETWORK_MANAGER_MOCA_getTelemetryLogStatus, (
void *)¶m,
sizeof(param));
2534 if(retVal == IARM_RESULT_SUCCESS)
2537 stMsgData->
paramtype = hostIf_BooleanType;
2541 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] IARM Failed \n", __FUNCTION__, __FILE__, __LINE__);
2543 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2547 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
2549 const char *status =
"false";
2550 ifstream ifp(IPREMOTE_SUPPORT_STATUS_FILE);
2554 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] %s exists, IpRemoteSupport Status is enabled\n", __FUNCTION__, IPREMOTE_SUPPORT_STATUS_FILE);
2560 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] File not exists, IpRemoteSupport Status is Disabled\n", __FUNCTION__);
2564 stMsgData->
paramtype = hostIf_StringType;
2570 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress(
HOSTIF_MsgData_t *stMsgData)
2574 char ipAddress[100] = {
'\0'};
2575 ifstream remoteInterface_file(IPREMOTE_INTERFACE_INFO);
2578 if (remoteInterface_file.is_open())
2580 while ( getline (remoteInterface_file,line) )
2582 if (line.find(
"Ipv4_Address") !=string::npos)
2584 char *tmpStr = strstr((
char *)line.c_str(),
"=") ;
2586 while(isspace(*tmpStr)) {
2589 rc=strcpy_s(ipAddress,
sizeof(ipAddress), tmpStr);
2596 remoteInterface_file.close();
2601 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] File not exists, IpRemoteInterface file open failed \n", __FUNCTION__);
2604 rc=strcpy_s(ipAddress,
sizeof(ipAddress),
"unknown");
2612 stMsgData->
paramtype = hostIf_StringType;
2617 catch (
const std::exception e) {
2618 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()]Exception caught. \n", __FUNCTION__);
2623 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress(
HOSTIF_MsgData_t *stMsgData)
2627 char macAddress[100] = {
'\0'};
2628 ifstream remoteInterface_file(IPREMOTE_INTERFACE_INFO);
2631 if (remoteInterface_file.is_open())
2633 while ( getline (remoteInterface_file,line) )
2635 if (line.find(
"MAC_Address") !=string::npos)
2637 char *tmpStr = strstr((
char *)line.c_str(),
"=") ;
2639 while(isspace(*tmpStr)) {
2642 rc=strcpy_s(macAddress,
sizeof(macAddress), tmpStr);
2649 remoteInterface_file.close();
2654 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] File not exists, IpRemoteInterface file open failed \n", __FUNCTION__);
2657 rc=strcpy_s(macAddress,
sizeof(macAddress),
"unknown");
2665 stMsgData->
paramtype = hostIf_StringType;
2670 catch (
const std::exception e) {
2671 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()]Exception caught. \n", __FUNCTION__);
2676 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
2678 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] XRPollingAction = %s\n", __FUNCTION__, m_xrPollingAction.c_str());
2679 snprintf((
char *)stMsgData->
paramValue, strlen(stMsgData->
paramValue)-1,
"%s", m_xrPollingAction.c_str());
2680 stMsgData->
paramtype = hostIf_StringType;
2683 if(pChanged && m_xrPollingAction !=
"0") {
2692 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
2694 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2695 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
2696 #ifdef USE_MoCA_PROFILE
2697 retVal =
IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME,IARM_BUS_NETWORK_MANAGER_MOCA_getTelemetryLogDuration, (
void *)¶m,
sizeof(param));
2699 if(retVal == IARM_RESULT_SUCCESS)
2702 stMsgData->
paramtype = hostIf_UnsignedIntType;
2706 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d] IARM Failed \n", __FUNCTION__, __FILE__, __LINE__);
2708 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2713 bool hostIf_DeviceInfo::isShortsEnabled()
2716 strcpy(stRfcData.
paramName, SHORTS_RFC_ENABLE);
2718 if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.
paramValue,
"true",
sizeof(
"true")) == 0))
2720 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] SHORTS enabled: %s \n", __FUNCTION__,
"True");
2723 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] SHORTS enabled: %s \n", __FUNCTION__,
"False");
2728 int hostIf_DeviceInfo::findLocalPortAvailable()
2730 struct sockaddr_in address;
2731 int sockfd = -1, status;
2732 int port = MIN_PORT_RANGE;
2734 while (port <= MAX_PORT_RANGE) {
2735 address.sin_family = AF_INET;
2736 address.sin_addr.s_addr = inet_addr(
"127.0.0.1");
2737 address.sin_port = htons(port);
2739 sockfd = socket(AF_INET, SOCK_STREAM, 0);
2741 status = connect(sockfd, (
struct sockaddr *)&address,
sizeof(address));
2745 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Port %d is available.\n", __FUNCTION__, port);
2750 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Port %d is in use.\n", __FUNCTION__, port);
2759 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2761 const string startShorts =
"start shorts";
2762 bool trigger = strncmp(inputStr.c_str(),
"start",strlen(
"start")) == 0;
2763 bool trigger_shorts = strncmp(inputStr.c_str(), startShorts.c_str(), startShorts.length()) == 0;
2767 #ifdef __SINGLE_SESSION_ONLY__
2768 if (!isRsshactive())
2772 if (isShortsEnabled() && trigger_shorts) {
2773 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Starting Stunnel \n",__FUNCTION__);
2774 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] StunnelSSH Command = /bin/sh %s %s %s %s %s %s \n",
2776 stunnelCommand.c_str(),
2777 stunnelSSHArgs.at(
"localport").c_str(),
2778 stunnelSSHArgs.at(
"host").c_str(),
2779 stunnelSSHArgs.at(
"hostIp").c_str(),
2780 stunnelSSHArgs.at(
"stunnelport").c_str(),
2781 reverseSSHArgs.c_str());
2782 v_secure_system(
"/bin/sh %s %s %s %s %s %s &", stunnelCommand.c_str(),
2783 stunnelSSHArgs.at(
"localport").c_str(),
2784 stunnelSSHArgs.at(
"host").c_str(),
2785 stunnelSSHArgs.at(
"hostIp").c_str(),
2786 stunnelSSHArgs.at(
"stunnelport").c_str(),
2787 reverseSSHArgs.c_str());
2790 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Starting SSH Tunnel \n",__FUNCTION__);
2791 string command = sshCommand +
" start " + reverseSSHArgs;
2792 system(command.c_str());
2794 #ifdef __SINGLE_SESSION_ONLY__
2798 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] SSH Session is already active. Not starting again! \n",__FUNCTION__);
2805 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Stop SSH Tunnel \n",__FUNCTION__);
2806 string command = sshCommand +
" stop ";
2807 system(command.c_str());
2809 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2815 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2817 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
2818 stMsgData->
paramtype = hostIf_StringType;
2820 if (reverseSSHArgs.empty())
2822 strncpy(stMsgData->
paramValue,
"Not Set", TR69HOSTIFMGR_MAX_PARAM_LEN );
2829 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting ... \n",__FUNCTION__);
2835 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2838 map<string,string> parsedMap;
2840 std::size_t start = inputStr.find_first_not_of(
";"), end = start;
2841 while (start != string::npos)
2843 end = inputStr.find(
";",start);
2844 string chunk = inputStr.substr(start,end - start);
2845 std::size_t keyEnd = chunk.find(
"=");
2846 parsedMap[chunk.substr(0,keyEnd)] = chunk.substr(keyEnd +1);
2847 start = inputStr.find_first_not_of(
";",end);
2849 string parsedValues;
2850 for (
auto &it : parsedMap)
2852 parsedValues +=
"key = " + it.first +
" value = " + it.second +
";";
2854 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] parsed Values are : %s\n",__FUNCTION__,parsedValues.c_str());
2856 reverseSSHArgs =
" -I " + parsedMap[
"idletimeout"] +
" -f -N -y -T -R " + parsedMap[
"revsshport"] +
":";
2857 string estbip = getEstbIp();
2858 unsigned char buf[
sizeof(
struct in6_addr)];
2860 if (inet_pton(AF_INET6, estbip.c_str(), buf))
2862 reverseSSHArgs +=
"[" + estbip +
"]";
2863 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] SSH Tunnel estb ipv6 address is : %s\n",__FUNCTION__,estbip.c_str());
2867 reverseSSHArgs += estbip;
2868 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] SSH Tunnel estb ipv4 address is : %s\n",__FUNCTION__,estbip.c_str());
2871 reverseSSHArgs +=
":22 " + parsedMap[
"user"] +
"@";
2872 if (isShortsEnabled() && parsedMap.count(
"stunnelport")) {
2873 string localPort = to_string(findLocalPortAvailable());
2874 if (localPort ==
"-1") {
2875 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Reserved ports are not availale... \n",__FUNCTION__);
2878 reverseSSHArgs += string(
"localhost") +
" -p " + localPort;
2881 stunnelSSHArgs[
"localport"] = localPort;
2882 stunnelSSHArgs[
"host"] = parsedMap.at(
"host");
2883 stunnelSSHArgs[
"hostIp"] = parsedMap.at(
"hostIp");
2884 stunnelSSHArgs[
"stunnelport"] = parsedMap.at(
"stunnelport");
2885 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Stunnel Args = %s %s %s %s \n",
2886 __FUNCTION__, localPort,
2887 parsedMap.at(
"host"),
2888 parsedMap.at(
"hostIp"),
2889 parsedMap.at(
"stunnelport"));
2891 reverseSSHArgs += parsedMap[
"host"] +
" -p " + parsedMap[
"sshport"];
2894 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] String is : %s\n",__FUNCTION__,reverseSSHArgs.c_str());
2896 string::const_iterator it = std::find_if(reverseSSHArgs.begin(), reverseSSHArgs.end(), [](
char c) {
2897 return !(isalnum(c) || (c ==
' ') || (c ==
':') || (c ==
'-') || (c ==
'.') || (c ==
'@') || (c ==
'_') || (c ==
'[') || (c ==
']'));
2900 if (it != reverseSSHArgs.end())
2902 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Exception Accured... \n",__FUNCTION__);
2903 reverseSSHArgs =
"";
2907 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] ReverseSSH Args = %s \n",__FUNCTION__,reverseSSHArgs.c_str());
2909 }
catch (
const std::exception e) {
2910 std::cout << __FUNCTION__ <<
"An exception occurred. " << e.what() << endl;
2912 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Exception Accured... \n",__FUNCTION__);
2913 reverseSSHArgs =
"";
2917 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2923 const string activeStr(
"ACTIVE");
2924 const string inActiveStr(
"INACTIVE");
2925 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
2926 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
2927 stMsgData->
paramtype = hostIf_StringType;
2936 strncpy(stMsgData->
paramValue, inActiveStr.c_str(), TR69HOSTIFMGR_MAX_PARAM_LEN );
2939 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
2943 static void Replace_AllOccurrence(
char *str,
int size,
char ch,
char Newch)
2946 for(i = 0; i<size-1; i++)
2948 if(str[i] == ch || str[i] ==
'\r')
2956 int hostIf_DeviceInfo::get_ApparmorBlockListStatus(
HOSTIF_MsgData_t * stMsgData)
2958 const char *apparmor_config =
"/opt/secure/Apparmor_blocklist";
2959 const char *info_str =
"Apparmorblocklist is empty";
2967 fp = fopen(apparmor_config,
"r");
2969 read = getdelim( &buf, &len,
'\0', fp);
2982 strncpy( stMsgData->
paramValue,info_str,strlen(info_str));
2987 int hostIf_DeviceInfo::get_xOpsDeviceMgmtForwardSSHEnable(
HOSTIF_MsgData_t * stMsgData)
2990 char ForwardSSH[10]=
"true";
2992 char dataToBeRead[50];
2995 if((fp=fopen(FORWARD_SSH_FILE,
"r"))==NULL)
2997 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file\n", __FUNCTION__);
3003 while( fgets ( dataToBeRead, 50, fp ) != NULL )
3005 p = strchr(dataToBeRead,
'=');
3006 sprintf( ForwardSSH,
"%s", ++p ) ;
3007 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Enable value:%s --> Parameter[%s]\n", __FUNCTION__, ForwardSSH, stMsgData->
paramName);
3008 if( strcmp( ForwardSSH,
"true"))
3023 int hostIf_DeviceInfo::set_xOpsDeviceMgmtForwardSSHEnable(
HOSTIF_MsgData_t * stMsgData)
3027 char ForwardSSH[10]=
"true";
3030 if((fp=fopen(FORWARD_SSH_FILE,
"w"))==NULL)
3032 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file\n", __FUNCTION__);
3037 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Default Enable value:%s --> Parameter[%s]\n", __FUNCTION__, ForwardSSH, stMsgData->
paramName);
3045 rc=strcpy_s(ForwardSSH,
sizeof(ForwardSSH),
"true");
3054 rc=strcpy_s(ForwardSSH,
sizeof(ForwardSSH),
"false");
3060 fprintf(fp,
"ForwardSSH=%s", ForwardSSH);
3067 #ifdef USE_HWSELFTEST_PROFILE
3068 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_Enable(
HOSTIF_MsgData_t *stMsgData)
3070 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_Enable(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3073 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_ExecuteTest(
HOSTIF_MsgData_t *stMsgData)
3075 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_ExecuteTest(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3078 int hostIf_DeviceInfo::get_xOpsDeviceMgmt_hwHealthTest_Results(
HOSTIF_MsgData_t *stMsgData)
3080 return hwselftest::get_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_Results(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3083 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_SetTuneType(
HOSTIF_MsgData_t *stMsgData)
3085 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_SetTuneType(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3088 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_ExecuteTuneTest(
HOSTIF_MsgData_t *stMsgData)
3090 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_ExecuteTuneTest(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3093 int hostIf_DeviceInfo::get_xOpsDeviceMgmt_hwHealthTestTune_TuneResults(
HOSTIF_MsgData_t *stMsgData)
3095 return hwselftest::get_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTestTune_TuneResults(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3098 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_EnablePeriodicRun(
HOSTIF_MsgData_t *stMsgData)
3100 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_EnablePeriodicRun(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3103 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_PeriodicRunFrequency(
HOSTIF_MsgData_t *stMsgData)
3105 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_PeriodicRunFrequency(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3108 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_CpuThreshold(
HOSTIF_MsgData_t *stMsgData)
3110 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_CpuThreshold(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3113 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_DramThreshold(
HOSTIF_MsgData_t *stMsgData)
3115 return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_DramThreshold(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3118 int hostIf_DeviceInfo::set_RFC_hwHealthTestWAN_WANEndPointURL(
HOSTIF_MsgData_t *stMsgData)
3120 return hwselftest::set_Device_DeviceInfo_RFC_hwHealthTestWAN_WANEndPointURL(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3123 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_Enable(
HOSTIF_MsgData_t *stMsgData)
3125 return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_Enable(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3128 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_QueueDepth(
HOSTIF_MsgData_t *stMsgData)
3130 return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_QueueDepth(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3133 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_FilterParams(
HOSTIF_MsgData_t *stMsgData)
3135 return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_FilterParams(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3138 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_ResultsFiltered(
HOSTIF_MsgData_t *stMsgData)
3140 return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_ResultsFiltered(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3152 if (strcasecmp(stMsgData->
paramName,TR069DOSLIMIT_THRESHOLD) == 0)
3155 if(stMsgData->
paramtype == hostIf_StringType )
3157 tmpVal = strtol(stMsgData->
paramValue,NULL,10);
3159 else if(stMsgData->
paramtype == hostIf_UnsignedIntType )
3166 stMsgData->
faultCode = fcInvalidParameterType;
3169 if (tmpVal < MIN_TR69_DOS_THRESHOLD || tmpVal > MAX_TR69_DOS_THRESHOLD)
3172 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong Value,Value should be[0-30] for %s to set.\n", __FUNCTION__, __LINE__, stMsgData->
paramName);
3173 stMsgData->
faultCode = fcInvalidParameterValue;
3179 int hostIf_DeviceInfo::set_xRDKCentralComBootstrap(
HOSTIF_MsgData_t * stMsgData)
3182 ret = m_bsStore->overrideValue(stMsgData);
3186 static bool ValidateInput_Arguments(
char *input, FILE *tmp_fptr)
3188 const char *apparmor_profiledir =
"/etc/apparmor.d";
3189 struct dirent *entry=NULL;
3191 char files_name[1024]= {0};
3193 char *subtoken=NULL;
3194 char *sub_string=NULL;
3199 dir=opendir(apparmor_profiledir);
3200 if( (dir == NULL) || (tmp_fptr == NULL) ) {
3201 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Failed to open Apparmor Profile directory\n");
3204 entry = readdir(dir);
3205 memset(files_name,
'\0',
sizeof(files_name));
3207 while(entry != NULL) {
3208 strncat(files_name,entry->d_name,strlen(entry->d_name));
3209 entry = readdir(dir);
3211 if (closedir(dir) != 0) {
3212 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Failed to close Apparmor Profile directory\n");
3218 token=strtok_r( input,
"#", &sp);
3219 while(token != NULL) {
3220 arg=strchr(token,
':');
3221 if ( ( (strcmp(arg+1,
"disable") != 0) && (strcmp(arg+1,
"complain") != 0) && (strcmp(arg+1,
"enforce") != 0) ) ) {
3222 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Invalid arguments in the parser:%s\n", token);
3225 strncpy(tmp,token,
sizeof(tmp));
3226 subtoken=strtok_r(tmp,
":",&sptr);
3227 if(subtoken != NULL) {
3228 sub_string=strstr(files_name, subtoken);
3229 if(sub_string != NULL) {
3230 fprintf(tmp_fptr,
"%s\n",token);
3233 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Invalid arguments %s error found in the parser\n", subtoken);
3237 token=strtok_r(NULL,
"#",&sp);
3242 int hostIf_DeviceInfo::set_xRDKCentralComApparmorBlocklist(
HOSTIF_MsgData_t *stMsgData)
3244 const char *apparmor_config =
"/opt/secure/Apparmor_blocklist";
3245 const char *apparmor_tmp_config =
"/opt/secure/Apparmor_blocklist_bck.txt";
3247 FILE *tmp_fptr = NULL;
3248 char buf[128] = {0};
3250 char *sub_string = NULL;
3252 char tmp[128] = {0};
3255 fptr = fopen(apparmor_config,
"r");
3256 tmp_fptr = fopen(apparmor_tmp_config,
"w+");
3258 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Failed to open the file or invalid argument\n");
3263 while(fgets( buf,
sizeof(buf), fptr) != NULL) {
3264 buf[strcspn(buf,
"\n")] = 0;
3265 strncpy( tmp, buf,
sizeof(tmp));
3266 token=strtok_r(tmp,
":",&sp);
3268 sub_string=strstr(stMsgData->
paramValue, token);
3269 if(sub_string != NULL)
3272 fprintf(tmp_fptr,
"%s\n",buf);
3278 if (ValidateInput_Arguments(stMsgData->
paramValue, tmp_fptr) !=
TRUE) {
3281 if (tmp_fptr!= NULL)
3289 if(rename( apparmor_tmp_config, apparmor_config) != 0) {
3290 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"Error in renaming file\n");
3300 int validate_paramVal;
3303 if (strcasecmp(stMsgData->
paramName,TR181_RFC_RESET_DATA_START) == 0)
3305 #ifndef NEW_HTTP_SERVER_DISABLE
3306 if(!legacyRFCEnabled())
3308 string stringValue = getStringValue(stMsgData);
3309 if(!strcasecmp(stringValue.c_str(),
"true") || !strcmp(stringValue.c_str(),
"1"))
3311 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling clearAll in New RFC Store I/O\n",__FUNCTION__);
3312 m_rfcStore->clearAll();
3318 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Invalid Value : Only true is allowed\n",__FUNCTION__);
3324 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling clearAll in Old RFC Storage I/O\n",__FUNCTION__);
3325 m_rfcStorage.clearAll();
3328 m_rfcStorage.clearAll();
3331 else if(strcasecmp(stMsgData->
paramName, TR181_RFC_RESET_DATA_END) == 0)
3333 #ifndef NEW_HTTP_SERVER_DISABLE
3334 if(!legacyRFCEnabled())
3336 string stringValue = getStringValue(stMsgData);
3337 if(!strcasecmp(stringValue.c_str(),
"true") || !strcmp(stringValue.c_str(),
"1"))
3339 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling reloadCache in New RFC Store I/O\n",__FUNCTION__);
3340 m_rfcStore->reloadCache();
3346 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Invalid Value : Only true is allowed\n",__FUNCTION__);
3354 validate_paramVal = validate_ParamValue(stMsgData);
3355 if(validate_paramVal == OK)
3357 #ifndef NEW_HTTP_SERVER_DISABLE
3358 if(!legacyRFCEnabled())
3360 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling setValue in New RFC Store I/O\n",__FUNCTION__);
3361 ret = m_rfcStore->setValue(stMsgData);
3365 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling setValue in Old RFC Storage I/O\n",__FUNCTION__);
3366 ret = m_rfcStorage.setValue(stMsgData);
3369 ret = m_rfcStorage.setValue(stMsgData);
3375 stMsgData->
faultCode = fcInvalidParameterValue;
3376 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Invalid ParamValue/Type to SET for param [%s] \n", __FUNCTION__, __LINE__, stMsgData->
paramName);
3380 if (strcasecmp(stMsgData->
paramName,RFC_WL_ROAM_TRIGGER_RF) == 0)
3382 ret = set_xRDKCentralComRFCRoamTrigger(stMsgData);
3384 else if (strcasecmp(stMsgData->
paramName,MS12_DAPV2_RFC_ENABLE) == 0)
3386 bool enable = get_boolean(stMsgData->
paramValue);
3387 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] MS12->DAPV2 RFC status:%d\n",__FUNCTION__, enable);
3397 else if (strcasecmp(stMsgData->
paramName,MS12_DE_RFC_ENABLE) == 0)
3399 bool enable = get_boolean(stMsgData->
paramValue);
3400 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] MS12->DE RFC status:%d\n",__FUNCTION__, enable);
3410 else if (strcasecmp(stMsgData->
paramName,LE_RFC_ENABLE) == 0)
3412 ret = set_xRDKCentralComRFCLoudnessEquivalenceEnable(stMsgData);
3414 else if (strcasecmp(stMsgData->
paramName,HDR_RFC_ENABLE) == 0)
3416 ret = set_xRDKCentralComHdrRFCEnable(stMsgData);
3418 else if (strcasecmp(stMsgData->
paramName,UHD_RFC_ENABLE) == 0)
3420 ret = set_xRDKCentralComUhdRFCEnable(stMsgData);
3422 else if (strcasecmp(stMsgData->
paramName,XRE_CONTAINER_RFC_ENABLE) == 0)
3424 ret = set_xRDKCentralComXREContainerRFCEnable(stMsgData);
3426 else if (strcasecmp(stMsgData->
paramName,RFC_CTL_RETRIEVE_NOW) == 0)
3428 ret = set_xRDKCentralComRFCRetrieveNow(stMsgData);
3430 else if (strcasecmp(stMsgData->
paramName,APPARMOR_BLOCKLIST_PROCESS) == 0)
3432 ret = set_xRDKCentralComApparmorBlocklist(stMsgData);
3434 #ifdef USE_REMOTE_DEBUGGER
3435 else if (strcasecmp(stMsgData->
paramName,RDK_REMOTE_DEBUGGER_ISSUETYPE) == 0)
3437 ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(stMsgData);
3440 #ifdef ENABLE_LLAMA_PLATCO
3441 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.VideoTelemetry.FrequncyMinutes"))
3443 ret = set_xRDKCentralComRFCVideoTelFreq(stMsgData);
3446 else if (!strcasecmp(stMsgData->
paramName,TR181_AUTOREBOOT_ENABLE) )
3448 ret = set_xRDKCentralComRFCAutoRebootEnable(stMsgData);
3450 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.newNTP.Enable") )
3452 ret = set_xRDKCentralComNewNtpEnable(stMsgData);
3454 #ifdef USE_HWSELFTEST_PROFILE
3455 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.Enable"))
3457 ret = set_xOpsDeviceMgmt_hwHealthTest_Enable(stMsgData);
3459 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.EnablePeriodicRun"))
3461 ret = set_xOpsDeviceMgmt_hwHealthTest_EnablePeriodicRun(stMsgData);
3463 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.PeriodicRunFrequency"))
3465 ret = set_xOpsDeviceMgmt_hwHealthTest_PeriodicRunFrequency(stMsgData);
3467 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.cpuThreshold"))
3469 ret = set_xOpsDeviceMgmt_hwHealthTest_CpuThreshold(stMsgData);
3471 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.dramThreshold"))
3473 ret = set_xOpsDeviceMgmt_hwHealthTest_DramThreshold(stMsgData);
3475 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTestWAN.WANTestEndPointURL"))
3477 ret = set_RFC_hwHealthTestWAN_WANEndPointURL(stMsgData);
3479 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.Enable"))
3481 ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_Enable(stMsgData);
3483 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.QueueDepth"))
3485 ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_QueueDepth(stMsgData);
3487 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.FilterParams"))
3489 ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_FilterParams(stMsgData);
3491 else if (!strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.ResultsFiltered"))
3493 ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_ResultsFiltered(stMsgData);
3499 int hostIf_DeviceInfo::set_xRDKCentralComNewNtpEnable(
HOSTIF_MsgData_t *stMsgData)
3504 if(stMsgData->
paramtype == hostIf_BooleanType)
3509 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] set newNTP enable to true\n", __FUNCTION__);
3510 ofstream ofp(NTPENABLED_FILE);
3515 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] set newNTP.Enable to false\n", __FUNCTION__);
3516 ifstream ifp(NTPENABLED_FILE);
3519 if(remove(NTPENABLED_FILE) == 0)
3521 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Removed File %s, newNTP is disabled\n", __FUNCTION__, NTPENABLED_FILE);
3526 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Unable to remove File %s, newNTP.Enable is unchanged\n", __FUNCTION__, NTPENABLED_FILE);
3531 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] File %s is already removed, newNTP is disabled already\n", __FUNCTION__, NTPENABLED_FILE);
3538 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, __LINE__, stMsgData->
paramName);
3543 int hostIf_DeviceInfo::get_xRDKCentralComBootstrap(
HOSTIF_MsgData_t *stMsgData)
3545 return m_bsStore->getValue(stMsgData);
3551 #ifndef NEW_HTTP_SERVER_DISABLE
3552 if(!legacyRFCEnabled())
3554 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling getValue in New RFC Store I/O\n",__FUNCTION__);
3555 ret=m_rfcStore->getValue(stMsgData);
3559 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Calling getValue in Old RFC Storage I/O\n",__FUNCTION__);
3560 ret=m_rfcStorage.getValue(stMsgData);
3563 ret=m_rfcStorage.getValue(stMsgData);
3566 if (strcasecmp(stMsgData->
paramName,
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID") == 0 && (strlen(stMsgData->
paramValue) == 0 || strcasecmp(stMsgData->
paramValue,
"unknown") == 0))
3568 if ((ret = get_xRDKCentralComRFCAccountId(stMsgData)) == OK)
3571 m_rfcStorage.setValue(stMsgData);
3578 int hostIf_DeviceInfo::get_xRDKCentralComRFCAccountId(
HOSTIF_MsgData_t *stMsgData)
3582 std::string postData;
3583 std::string tokenheader;
3584 CURL *curl = curl_easy_init();
3587 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"%s: call curl to get Account ID..\n", __FUNCTION__);
3590 tokenheader =
"Authorization: Bearer " + sToken;
3592 postData =
"{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.getServiceAccountId\" }";
3594 struct curl_slist *list = NULL;
3596 list = curl_slist_append(list, tokenheader.c_str());
3597 list = curl_slist_append(list,
"Content-Type: application/json");
3599 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
3600 curl_easy_setopt(curl, CURLOPT_POST, 1L);
3601 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());
3602 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCurlResponse);
3603 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
3604 curl_easy_setopt(curl, CURLOPT_URL, JSONRPC_URL);
3606 CURLcode res = curl_easy_perform(curl);
3608 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
3609 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"%s: curl response : %d http response code: %ld\n", __FUNCTION__, res, http_code);
3610 curl_easy_cleanup(curl);
3611 curl_slist_free_all(list);
3615 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"%s: curl response string = %s\n", __FUNCTION__, response.c_str());
3616 cJSON* root = cJSON_Parse(response.c_str());
3619 cJSON* jsonObj = cJSON_GetObjectItem(root,
"result");
3623 cJSON *accountIdObj = cJSON_GetObjectItem(jsonObj,
"serviceAccountId");
3625 if (accountIdObj && accountIdObj->type == cJSON_String && accountIdObj->valuestring && strlen(accountIdObj->valuestring) > 0)
3627 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"Found serviceAccountId value = %s\n", accountIdObj->valuestring);
3628 putValue(stMsgData, accountIdObj->valuestring);
3634 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] json parse error, no \"serviceAccountId\" in the output from Thunder plugin\n", __FUNCTION__);
3641 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__);
3649 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"%s: json parse error\n", __FUNCTION__);
3655 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"%s: curl init failed\n", __FUNCTION__);
3660 #ifdef USE_REMOTE_DEBUGGER
3661 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType (
HOSTIF_MsgData_t *stMsgData)
3663 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Entering... \n",__FUNCTION__);
3664 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Param Value is %s \n",__FUNCTION__, stMsgData->
paramValue);
3666 strncpy(issueStr,stMsgData->
paramValue,
sizeof(issueStr)-1);
3667 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Issue string Value is %s \n",__FUNCTION__, issueStr);
3668 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] CAlling IARM_Bus_BroadcastEvent %s %d for %s \n",__FUNCTION__, IARM_BUS_RDK_REMOTE_DEBUGGER_NAME, IARM_BUS_RDK_REMOTE_DEBUGGER_ISSUETYPE, issueStr);
3669 if (
IARM_Bus_BroadcastEvent(IARM_BUS_RDK_REMOTE_DEBUGGER_NAME, (IARM_EventId_t) IARM_BUS_RDK_REMOTE_DEBUGGER_ISSUETYPE, (
void *) &issueStr,
sizeof(issueStr)) == IARM_RESULT_SUCCESS)
3671 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] SUCCESS: RDK Remote Debugger IARM BroadcastEvent %s \n",__FUNCTION__);
3675 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] FAILED: RDK Remote Debugger IARM BroadcastEvent \n",__FUNCTION__);
3677 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Exiting... \n",__FUNCTION__);
3683 int hostIf_DeviceInfo::set_xRDKCentralComRFCAutoRebootEnable(
HOSTIF_MsgData_t *stMsgData)
3685 bool enableStatus =
false;
3688 bool bValue =
false;
3690 if(stMsgData->
paramtype == hostIf_BooleanType)
3692 enableStatus=get_boolean(stMsgData->
paramValue);
3694 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] %s: %s\n", __FUNCTION__, __LINE__ \
3695 ,stMsgData->
paramName, (enableStatus)?
"true":
"false");
3698 ret = ScheduleAutoReboot(enableStatus);
3701 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] ScheduleAutoReboot Failed \n", __FUNCTION__);
3706 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Value Incorrect, Auto Reboot Enable status unchanged \n" \
3714 int hostIf_DeviceInfo::ScheduleAutoReboot(
bool bValue)
3717 char cmd[100] = {
'\0'};
3720 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] bValue = %s\n" \
3721 , __FUNCTION__, __LINE__, bValue?
"true" :
"false" );
3725 snprintf(cmd,
sizeof(cmd),
"sh /lib/rdk/ScheduleAutoReboot.sh %d &", bValue);
3727 v_secure_system(
"sh /lib/rdk/ScheduleAutoReboot.sh %d &", bValue);
3731 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Successfully executed \"%s\". \n", __FUNCTION__, __LINE__, cmd);
3736 int hostIf_DeviceInfo::set_xRDKCentralComRFCRoamTrigger(
HOSTIF_MsgData_t *stMsgData)
3742 char execBuf[100] = {
'\0'};
3743 sprintf(execBuf,
"wl roam_trigger %s &", stMsgData->
paramValue);
3745 v_secure_system(
"wl roam_trigger %s &", stMsgData->
paramValue);
3749 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Successfully executed \"%s\" with \"%s\". \n", __FUNCTION__, __LINE__, stMsgData->
paramName, execBuf);
3752 system(
"wl roam_trigger &");
3756 int hostIf_DeviceInfo::set_xRDKCentralComRFCLoudnessEquivalenceEnable(
HOSTIF_MsgData_t *stMsgData)
3759 bool enable =
false;
3762 if(stMsgData->
paramtype == hostIf_BooleanType)
3770 catch (
const std::exception e)
3772 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception %s.\n", e.what());
3778 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] enableLEConfig failed/unsupported \n",__FUNCTION__);
3788 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n"
3789 , __FUNCTION__, __LINE__, stMsgData->
paramName);
3790 stMsgData->
faultCode = fcInvalidParameterType;
3795 int hostIf_DeviceInfo::set_xRDKCentralComHdrRFCEnable(
HOSTIF_MsgData_t *stMsgData)
3798 bool enable =
false;
3800 if(stMsgData->
paramtype == hostIf_BooleanType)
3804 decoder.forceDisableHDRSupport(!enable);
3805 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->
paramName, enable);
3810 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, __LINE__, stMsgData->
paramName);
3811 stMsgData->
faultCode = fcInvalidParameterType;
3817 int hostIf_DeviceInfo::set_xRDKCentralComXREContainerRFCEnable(
HOSTIF_MsgData_t *stMsgData)
3822 if(stMsgData->
paramtype == hostIf_BooleanType)
3827 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] XRE_ContainerSupport enable request\n", __FUNCTION__);
3828 ofstream ofp(XRE_CONTAINER_SUPPORT_STATUS_FILE);
3829 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Created File %s, XRE_ContainerSupport is enabled\n", __FUNCTION__, XRE_CONTAINER_SUPPORT_STATUS_FILE);
3834 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] XRE_ContainerSupport disable request\n", __FUNCTION__);
3835 ifstream ifp(XRE_CONTAINER_SUPPORT_STATUS_FILE);
3838 if(remove(XRE_CONTAINER_SUPPORT_STATUS_FILE) == 0)
3840 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Removed File %s, XRE_ContainerSupport is disabled\n", __FUNCTION__, XRE_CONTAINER_SUPPORT_STATUS_FILE);
3845 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Unable to remove File %s, XRE_ContainerSupport Status unchanged\n", __FUNCTION__, XRE_CONTAINER_SUPPORT_STATUS_FILE);
3850 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] File %s is already removed, XRE_ContainerSupport is disabled already\n", __FUNCTION__, XRE_CONTAINER_SUPPORT_STATUS_FILE);
3857 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, __LINE__, stMsgData->
paramName);
3862 int hostIf_DeviceInfo::set_xRDKCentralComUhdRFCEnable(
HOSTIF_MsgData_t *stMsgData)
3865 bool enable =
false;
3867 if(stMsgData->
paramtype == hostIf_BooleanType)
3872 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->
paramName, enable);
3877 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, __LINE__, stMsgData->
paramName);
3878 stMsgData->
faultCode = fcInvalidParameterType;
3885 int hostIf_DeviceInfo::set_xRDKCentralComRFCRetrieveNow(
HOSTIF_MsgData_t *stMsgData)
3888 struct timeval currTime;
3889 char cmd[100] = {
'\0'};
3893 sprintf(cmd,
"sh /lib/rdk/RFCbase.sh &");
3896 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Successfully executed \"%s\" with \"%s\". \n", __FUNCTION__, __LINE__, stMsgData->
paramName, cmd);
3898 if(gettimeofday(&currTime, NULL))
3900 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Failed in sysinfo due to \'%s\' (%d). \n", strerror(errno), errno);
3904 put_ulong(stMsgData->
paramValue, (
unsigned int)currTime.tv_sec);
3905 stMsgData->
paramtype = hostIf_UnsignedIntType;
3906 stMsgData->
paramLen =
sizeof(hostIf_UnsignedIntType);
3908 #ifndef NEW_HTTP_SERVER_DISABLE
3909 ret = m_rfcStore->setValue(stMsgData);
3911 ret = m_rfcStorage.setValue(stMsgData);
3918 #ifdef ENABLE_LLAMA_PLATCO
3919 int hostIf_DeviceInfo::set_xRDKCentralComRFCVideoTelFreq(
HOSTIF_MsgData_t *stMsgData)
3922 unsigned int tmpVal = 0;
3923 char execBuf[100] = {
'\0'};
3924 if (stMsgData->
paramtype == hostIf_UnsignedIntType)
3927 if (tmpVal > 0 && tmpVal <=60)
3929 sprintf(execBuf,
"sh /lib/rdk/vdec-statistics.sh %d &", tmpVal);
3930 v_secure_system(
"sh /lib/rdk/vdec-statistics.sh %d &", tmpVal);
3931 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Successfully executed \"%s\" with \"%s\". \n", __FUNCTION__, __LINE__, stMsgData->
paramName, execBuf);
3936 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] FrequncyMinutes value should be in the range between 1 to 60 (Minutes) \n", __FUNCTION__, __LINE__);
3946 char cmd[400] = {
'\0'};
3947 sprintf(cmd,
"%s %s %s",
"/usr/local/tr69agent/host-if -H 127.0.0.1 -p 56981 -g", stMsgData->
paramName,
"| grep -i Value | cut -d \":\" -f2");
3949 char result[50] = {
'\0'};
3950 char buf[50] = {
'\0'};
3951 static bool bCalled =
false;
3953 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] CMD : [ %s ] \n",__FUNCTION__, cmd);
3956 fp = v_secure_popen(
"r",
"/usr/local/tr69agent/host-if -H 127.0.0.1 -p 56981 -g %s | grep -i Value | cut -d \":\" -f2", stMsgData->
paramName);
3958 fp = popen(cmd,
"r");
3963 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"Error popen : Not able to read through host-if from TR69 agent.\n");
3967 if(fgets(buf,50,fp) != NULL)
3969 sscanf(buf,
"%s", result);
3972 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s] result %s buf %s Reset. \n",__FUNCTION__, result, buf);
3975 v_secure_pclose(fp);
3979 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
3980 strncpy(stMsgData->
paramValue, result, TR69HOSTIFMGR_MAX_PARAM_LEN );
3981 stMsgData->
paramtype = hostIf_StringType;
3982 stMsgData->
paramLen = strlen(result);
4005 ifstream fwDwnfile(FW_DWN_FILE_PATH);
4008 if (fwDwnfile.is_open()) {
4009 while ( getline (fwDwnfile,line) ) {
4015 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file\n", __FUNCTION__);
4019 char *cstr =
new char [line.length()+1];
4024 if (0 == line.length()) {
4029 rc=strcpy_s (cstr,(line.length()+1), line.c_str());
4035 pch = strstr (cstr,
"|");
4041 while(isspace(*pch)) {
4044 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
4047 stMsgData->
paramtype = hostIf_StringType;
4051 }
catch (
const std::exception e) {
4052 std::cout << __FUNCTION__ <<
"An exception occurred. " << e.what() << endl;
4074 ifstream infwDwnfile(FW_DWN_FILE_PATH);
4076 if (!infwDwnfile.is_open()) {
4077 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s]Unable to open file %s\n", __FUNCTION__, FW_DWN_FILE_PATH);
4082 ofstream tmpfwDwnfile(TEMP_FW_DWN_FILE_PATH);
4083 while ( getline (infwDwnfile,line) )
4085 if(line.find(
"Method") != string::npos) {
4086 string tmpline =
"Method|tr69";
4087 tmpfwDwnfile << tmpline <<
"\n";
4089 else if (line.find(param)!=string::npos) {
4090 string tmpline = string(param);
4091 tmpline = tmpline +
"|" + stMsgData->
paramValue;
4092 tmpfwDwnfile << tmpline <<
"\n";;
4095 tmpfwDwnfile << line <<
"\n";;
4098 infwDwnfile.close();
4099 tmpfwDwnfile.close();
4102 if((remove(FW_DWN_FILE_PATH) == 0) && (rename(TEMP_FW_DWN_FILE_PATH, FW_DWN_FILE_PATH) == 0))
4104 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] File removed from the path , Temp file is set \n", __FUNCTION__);
4107 }
catch (
const std::exception e) {
4108 std::cout << __FUNCTION__ <<
"An exception occurred. " << e.what() << endl;
4114 int hostIf_DeviceInfo::set_xFirmwareDownloadNow(
HOSTIF_MsgData_t *stMsgData)
4117 const char *userTriggerDwScr =
"/lib/rdk/userInitiatedFWDnld.sh";
4121 if(stMsgData->
paramtype == hostIf_BooleanType)
4123 bool xDwnldTrigger = get_boolean(stMsgData->
paramValue);
4126 if(m_xFirmwareDownloadNow) {
4127 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to trigger Download, since download already in progress ....\n", __FUNCTION__, __LINE__);
4130 else if (hostIf_DeviceInfo::m_xFirmwareDownloadNow ==
false && xDwnldTrigger) {
4131 if(xDwnldTrigger && (!m_xFirmwareDownloadProtocol.empty()) &&
4132 (!m_xFirmwareDownloadURL.empty()) && (!m_xFirmwareToDownload.empty())) {
4134 char cmd[200] = {
'\0'};
4135 sprintf(cmd,
"%s %s %s %s %d %d &",userTriggerDwScr, m_xFirmwareDownloadProtocol.c_str(), m_xFirmwareDownloadURL.c_str(), m_xFirmwareToDownload.c_str(), m_xFirmwareDownloadUseCodebig, m_xFirmwareDownloadDeferReboot);
4138 ret = v_secure_system(
"%s %s %s %s %d %d &",userTriggerDwScr, m_xFirmwareDownloadProtocol.c_str(), m_xFirmwareDownloadURL.c_str(), m_xFirmwareToDownload.c_str(), m_xFirmwareDownloadUseCodebig, m_xFirmwareDownloadDeferReboot);
4144 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Failed to trigger Download, \'system (\"%s\")\' returned error code '%d'\n", __FUNCTION__, cmd, ret);
4147 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s:%d] Yw.. Successfully executed (\'%s\')Triggered Download.\n",__FUNCTION__,__LINE__, cmd);
4150 m_xFirmwareDownloadProtocol.clear();
4151 m_xFirmwareToDownload.clear();
4152 m_xFirmwareDownloadURL.clear();
4153 m_xFirmwareDownloadNow =
false;
4154 m_xFirmwareDownloadUseCodebig =
false;
4155 m_xFirmwareDownloadDeferReboot =
false;
4159 if(m_xFirmwareDownloadProtocol.empty())
4160 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to trigger Download, since \"FirmwareDownloadProtocols\" is not set/configured.\n", __FUNCTION__, __LINE__);
4161 if(m_xFirmwareDownloadURL.empty())
4162 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to trigger Download, since \"m_xFirmwareDownloadURL\" is not set/configured.\n", __FUNCTION__, __LINE__);
4163 if(m_xFirmwareToDownload.empty())
4164 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to trigger Download, since \"FirmwareToDownload\" is not set/configured. \n", __FUNCTION__, __LINE__);
4166 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Please configure other parameters, then trigger download. \n", __FUNCTION__, __LINE__);
4171 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to trigger Download, since \"FirmwareToDownload\" is not set. \n", __FUNCTION__, __LINE__);
4176 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, __LINE__, stMsgData->
paramName);
4193 std::transform (haystack.begin(), haystack.end(), haystack.begin(), ::tolower);
4194 std::transform (needle.begin(), needle.end(), needle.begin(), ::tolower);
4195 return haystack.find (needle, pos);
4198 string hostIf_DeviceInfo::getStbMacIf_fr_devProperties()
4202 char mac_buf[20] = {0};
4207 char *stbMacIf =
getenvOrDefault ((
const char*)
"DEFAULT_ESTB_INTERFACE", (
char*)
"");
4209 int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
4211 strncpy(ifr.ifr_name, stbMacIf,IFNAMSIZ-1);
4212 if (0 == ioctl(fd, SIOCGIFHWADDR, &ifr)) {
4213 unsigned char *mac = NULL;
4214 mac = (
unsigned char *) ifr.ifr_hwaddr.sa_data;
4216 sprintf (mac_buf,
"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
4218 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] STB MAC : \'%s\'..\n", __FUNCTION__, __LINE__, mac_buf );
4221 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to get ifr_hwaddr.sa_data\'%s\'..\n", __FUNCTION__, __LINE__, strerror (errno) );
4225 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed in ioctl() with \'%s\'..\n", __FUNCTION__, __LINE__, strerror (errno) );
4231 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Socket failed with \'%s\'..\n", __FUNCTION__, __LINE__, strerror (errno) );
4234 }
catch (
const std::exception &e) {
4235 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()]Exception caught %s\n", __FUNCTION__, e.what());
4240 int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_LastRebootReason(
HOSTIF_MsgData_t *stMsgData)
4245 char buffer[1024] = {0};
4246 char *reboot_reason = NULL;
4250 fp = fopen(PREVIOUS_REBOT_REASON_FILE,
"r");
4253 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
" '%s' file not Present.\n", PREVIOUS_REBOT_REASON_FILE);
4256 fread(buffer, 1024, 1, fp);
4257 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"Previous Reboot Info buffer: %s\n", buffer);
4260 bool reason_str_found =
false;
4261 char search[] =
"reason";
4262 char *ptr = strstr(buffer, search);
4266 reason_str_found =
true;
4270 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
" '%s' file doesn't contain '%s' string.\n", PREVIOUS_REBOT_REASON_FILE, search);
4273 if(reason_str_found)
4275 cJSON *root = cJSON_Parse(buffer);
4278 reboot_reason = cJSON_GetObjectItem(root,
"reason")->valuestring;
4282 memset(stMsgData->
paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
4285 stMsgData->
paramtype = hostIf_StringType;
4286 stMsgData->
paramLen = strlen(reboot_reason);
4303 if(strcmp(stMsgData->
paramName, X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION) == 0)
4305 ret = get_xOpsRPCDevManageableNotification(stMsgData);
4307 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_FW_DNLD_STARTED_NOTIFICATION) == 0)
4309 ret = get_xOpsRPCFwDwldStartedNotification(stMsgData);
4311 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_FW_DNLD_COMPLETED_NOTIFICATION) == 0)
4313 ret = get_xOpsRPCFwDwldCompletedNotification(stMsgData);
4315 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_REBOOT_PENDING_NOTIFICATION) == 0)
4317 ret = get_xOpsRPCRebootPendingNotification(stMsgData);
4321 stMsgData->
faultCode = fcInvalidParameterName;
4322 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Invalid Parameter Name\n", __FUNCTION__, stMsgData->
paramName);
4327 int hostIf_DeviceInfo::get_xOpsRPCDevManageableNotification(
HOSTIF_MsgData_t* stMsgData)
4329 char *chVal = (
char *)(!m_strXOpsDevManageableNotification.empty() ? m_strXOpsDevManageableNotification.c_str() :
"0");
4339 int hostIf_DeviceInfo::get_xOpsRPCFwDwldStartedNotification(
HOSTIF_MsgData_t* stMsgData)
4341 char *chVal = (
char *)((!m_strXOpsRPCFwDwldStartedNotification.empty()) ? m_strXOpsRPCFwDwldStartedNotification.c_str() :
"0");
4351 int hostIf_DeviceInfo::get_xOpsRPCFwDwldCompletedNotification(
HOSTIF_MsgData_t* stMsgData)
4357 int hostIf_DeviceInfo::get_xOpsRPCRebootPendingNotification(
HOSTIF_MsgData_t* stMsgData)
4365 if(strcmp(stMsgData->
paramName, X_OPS_RPC_REBOOTNOW) == 0)
4367 set_xOpsDeviceMgmtRPCRebootNow (stMsgData);
4369 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION) == 0)
4371 set_xOpsRPCDevManageableNotification(stMsgData);
4373 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_FW_DNLD_STARTED_NOTIFICATION) == 0)
4375 set_xOpsRPCFwDwldStartedNotification(stMsgData);
4377 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_FW_DNLD_COMPLETED_NOTIFICATION) == 0)
4379 set_xOpsRPCFwDwldCompletedNotification(stMsgData);
4381 else if(strcmp(stMsgData->
paramName, X_OPS_RPC_REBOOT_PENDING_NOTIFICATION) == 0)
4383 set_xOpsRPCRebootPendingNotification(stMsgData);
4387 stMsgData->
faultCode = fcInvalidParameterName;
4388 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Invalid Parameter Name\n", __FUNCTION__, stMsgData->
paramName);
4393 int hostIf_DeviceInfo::set_xOpsDeviceMgmtRPCRebootNow (
HOSTIF_MsgData_t * stMsgData)
4399 char* command = (
char *)
"(sleep 1; /lib/rdk/rebootNow.sh -s hostifDeviceInfo) &";
4400 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Invoking 'system (\"%s\")'. %s = true\n", __FUNCTION__, command, stMsgData->
paramName);
4401 int ret = system (command);
4404 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] 'system (\"%s\")' returned error code '%d'\n", __FUNCTION__, command, ret);
4410 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Not rebooting. %s = false\n", __FUNCTION__, stMsgData->
paramName);
4416 int hostIf_DeviceInfo::set_xOpsRPCDevManageableNotification(
HOSTIF_MsgData_t *stMsgData) {
4420 m_strXOpsDevManageableNotification.clear();
4423 rc=strcpy_s(stRfcData.
paramName,
sizeof(stRfcData.
paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4428 if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.
paramValue,
"true",
sizeof(
"true")) == 0))
4430 m_strXOpsDevManageableNotification = stMsgData->
paramValue;
4431 NotificationHandler::getInstance()->push_device_mgmt_notifications(NULL, NULL, NULL, (
char* )
"fully-manageable", stMsgData->
paramValue);
4433 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Successfully set [\"%s\"] and Send notification as \"status\":\"fully-manageable\" \
4434 \"system-ready-time\":\"%s\" \n", __FUNCTION__, stMsgData->
paramName, stMsgData->
paramValue);
4437 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] RFC Parameter (%s) is disabled, so not sending notification for [%s]. \n",
4438 __FUNCTION__, X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE, X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION );
4443 int hostIf_DeviceInfo::set_xOpsRPCFwDwldStartedNotification(
HOSTIF_MsgData_t *stMsgData) {
4447 m_strXOpsRPCFwDwldStartedNotification.clear();
4450 rc=strcpy_s(stRfcData.
paramName,
sizeof(stRfcData.
paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4455 if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.
paramValue,
"true",
sizeof(
"true")) == 0))
4457 m_strXOpsRPCFwDwldStartedNotification = stMsgData->
paramValue;
4458 NotificationHandler::getInstance()->push_device_mgmt_notifications(NULL, (
char *)m_strXOpsRPCFwDwldStartedNotification.c_str(), NULL, (
char* )
"firmware-download-started", NULL);
4459 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Successfully Set [\"%s\"] and Send notification as \"status\":\"firmware-download-started\" with \"start-time\":\"%s\" \n",
4463 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] RFC Parameter (%s) is disabled, so not sending notification for [%s]. \n",
4464 __FUNCTION__, X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE, X_OPS_RPC_FW_DNLD_STARTED_NOTIFICATION );
4469 int hostIf_DeviceInfo::set_xOpsRPCFwDwldCompletedNotification(
HOSTIF_MsgData_t *stMsgData) {
4474 rc=strcpy_s(stRfcData.
paramName,
sizeof(stRfcData.
paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4479 if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.
paramValue,
"true",
sizeof(
"true")) == 0))
4481 m_bXOpsRPCFwDwldCompletedNotification = get_boolean(stMsgData->
paramValue);
4482 const char *status = (m_bXOpsRPCFwDwldCompletedNotification)?
"true":
"false";
4483 char* start_time= (
char*) m_strXOpsRPCFwDwldStartedNotification.c_str();
4485 NotificationHandler::getInstance()->push_device_mgmt_notifications(NULL, start_time, (
char*)status, (
char* )
"firmware-download-completed", NULL);
4486 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Successfully Set [\"%s\"] and Send notification as \"status\":\"firmware-download-completed\" \
4487 with \"start-time\":\"%s\" and \"download-status\":\"%s\". \n", __FUNCTION__, stMsgData->
paramName, m_strXOpsRPCFwDwldStartedNotification.c_str(), status);
4490 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] RFC Parameter (%s) is disabled, so not sending notification for [%s]. \n",
4491 __FUNCTION__, X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE, X_OPS_RPC_FW_DNLD_COMPLETED_NOTIFICATION );
4496 int hostIf_DeviceInfo::set_xOpsRPCRebootPendingNotification(
HOSTIF_MsgData_t *stMsgData) {
4501 rc=strcpy_s(stRfcData.
paramName,
sizeof(stRfcData.
paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4506 if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.
paramValue,
"true",
sizeof(
"true")) == 0))
4508 unsigned int uinVal = get_uint(stMsgData->
paramValue);
4509 char temp_buff[64] = {0};
4510 sprintf(temp_buff,
"%d",uinVal);
4511 NotificationHandler::getInstance()->push_device_mgmt_notifications(temp_buff, NULL, NULL, (
char* )
"reboot-pending", NULL);
4513 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Successfully Set [\"%s\"] and Send \"reboot-pending\" notification \
4514 \n", __FUNCTION__, stMsgData->
paramName );
4517 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] RFC Parameter (%s) is disabled, so not sending notification for [%s]. \n",
4518 __FUNCTION__, X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE, X_OPS_RPC_REBOOT_PENDING_NOTIFICATION );
4524 int hostIf_DeviceInfo::set_X_RDKCENTRAL_COM_LastRebootReason(
HOSTIF_MsgData_t *stMsgData)
4527 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"This '%s' file contains the LastRebootReason.\n", PREVIOUS_REBOT_REASON_FILE);
4531 void hostIf_DeviceInfo::send_DeviceManageableNotification()
4534 std::thread systemMgmtTimeMonitorThrd(hostIf_DeviceInfo::systemMgmtTimePathMonitorThr);
4535 systemMgmtTimeMonitorThrd.detach();
4538 void hostIf_DeviceInfo::systemMgmtTimePathMonitorThr()
4540 unsigned long system_manageable_time = 0;
4543 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s]Entering...\n", __FUNCTION__);
4551 bool is_webpa_ready = 0;
4553 bool is_webpa_ready = (access(
"/tmp/webpa/start_time", F_OK) == 0)?
true:
false;
4554 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] is_webpa_ready : %d\n", __FUNCTION__, is_webpa_ready);
4555 if(is_webpa_ready) {
4557 system_manageable_time = get_device_manageble_time();
4559 sprintf(stMsgData.
paramName,
"%s", X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION);
4560 sprintf(stMsgData.
paramValue,
"%ld", system_manageable_time);
4562 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%d] Set [%s] to send the notification. \n",__FUNCTION__,__LINE__, X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION);
4563 hostIf_SetMsgHandler(&stMsgData);
4574 }
while(is_webpa_ready ==
false);
4576 if(is_webpa_ready ==
false)
4578 int inotifyFd = 0, wd = 0;
4579 std::string m_path =
"/tmp/webpa";
4580 inotifyFd = inotify_init();
4582 if (inotifyFd == -1)
4584 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d]: Failed in inotify_init. Exiting thread \n",__FUNCTION__,__LINE__);
4587 wd = inotify_add_watch(inotifyFd, m_path.c_str(), IN_CREATE | IN_ATTRIB);
4591 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d]Unable to create Watch inotify file descriptor. Exiting thread \n",__FUNCTION__,__LINE__);
4594 char buffer[
sizeof(
struct inotify_event) + NAME_MAX + 1] = {0};
4598 ssize_t count = read(inotifyFd, buffer,
sizeof(buffer));
4602 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%d] Failed to read. Exiting \n",__FUNCTION__,__LINE__);
4606 struct inotify_event *
event =
reinterpret_cast<struct inotify_event *
>(buffer);
4607 if (event->mask & IN_ATTRIB)
4609 if(!is_webpa_ready) {
4610 if(0 == (strcmp(event->name,
"start_time")))
4611 is_webpa_ready =
true;
4615 if(is_webpa_ready) {
4616 system_manageable_time = get_device_manageble_time();
4618 sprintf(stMsgData.
paramName,
"%s", X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION);
4619 sprintf(stMsgData.
paramValue,
"%ld", system_manageable_time);
4620 hostIf_SetMsgHandler(&stMsgData);
4625 inotify_rm_watch( inotifyFd, wd );
4628 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s]Exiting...\n", __FUNCTION__);
4631 int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_experience(
HOSTIF_MsgData_t *stMsgData)
4634 string experience =
"";
4635 std::string postData;
4636 std::string tokenheader;
4638 CURL *curl = curl_easy_init();
4642 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s]Failed at curl_easy_init.\n", __FUNCTION__);
4649 tokenheader =
"Authorization: Bearer " + sToken;
4651 postData =
"{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.getExperience\" }";
4653 struct curl_slist *list = NULL;
4655 list = curl_slist_append(list, tokenheader.c_str());
4656 list = curl_slist_append(list,
"Content-Type: application/json");
4658 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
4659 curl_easy_setopt(curl, CURLOPT_POST, 1L);
4660 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());
4661 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCurlResponse);
4662 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resp);
4663 curl_easy_setopt(curl, CURLOPT_URL, JSONRPC_URL);
4665 CURLcode res = curl_easy_perform(curl);
4671 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
4672 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] curl response : %d http response code: %ld\n", __FUNCTION__, res, http_code);
4675 curl_easy_cleanup(curl);
4676 curl_slist_free_all(list);
4678 if(res == CURLE_OK && http_code == HTTP_OK )
4680 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] curl response string = %s\n", __FUNCTION__, resp.c_str());
4682 cJSON* root = cJSON_Parse(resp.c_str());
4686 cJSON* jsonObj = cJSON_GetObjectItem(root,
"result");
4690 cJSON *experienceObj = cJSON_GetObjectItem(jsonObj,
"experience");
4692 if(experienceObj && experienceObj->type == cJSON_String && experienceObj->valuestring && (strlen(experienceObj->valuestring) > 0))
4694 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s]The parameter [%s] value is [%s].\n", __FUNCTION__, stMsgData->
paramName, experienceObj->valuestring);
4695 experience = experienceObj->valuestring;
4699 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] json parse error, no \"experience\" in the output from Thunder plugin\n", __FUNCTION__);
4706 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__);
4715 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] json parse error\n", __FUNCTION__);
4721 if(!experience.empty()) {
4722 strncpy(stMsgData->
paramValue, experience.c_str(), TR69HOSTIFMGR_MAX_PARAM_LEN-1 );
4746 ifstream versionfile (VERSION_FILE);
4747 char imagename[100] = {
'\0'};
4751 if (versionfile.is_open()) {
4752 while ( getline (versionfile,line) ) {
4753 if (line.find(
"imagename") !=string::npos) {
4754 char *tmpStr = strstr((
char *)line.c_str(),
":");
4756 while(isspace(*tmpStr)) {
4759 rc=strcpy_s(imagename,
sizeof(imagename), tmpStr);
4766 versionfile.close();
4770 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s()] Failed to open [%s] file.\n", __FUNCTION__, VERSION_FILE);
4774 if(imagename[0] !=
'\0') {
4775 stMsgData->
paramLen = strlen(imagename);
4778 stMsgData->
paramtype = hostIf_StringType;
4780 catch (
const std::exception e) {
4781 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s()]Exception caught.\n", __FUNCTION__);
4784 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s()] Exiting..\n", __FUNCTION__ );
4788 int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(
HOSTIF_MsgData_t * stMsgData)
4791 char *rdm_comm =
"/etc/rdm/rdmBundleMgr.sh";
4792 char *install_cmd = NULL;
4794 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"[%s] Entering..\n", __FUNCTION__ );
4797 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Invalid parameter value\n", __FUNCTION__);
4801 RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Executing command - sh %s %s & \n", __FUNCTION__ , rdm_comm, stMsgData->
paramValue);
4804 ret = v_secure_system(
"sh %s %s &", rdm_comm, stMsgData->
paramValue);
4806 install_cmd = (
char *) calloc(strlen(rdm_comm) + strlen(stMsgData->
paramValue) + 10,
sizeof(char));
4807 sprintf(install_cmd,
"sh %s \"%s\" &", rdm_comm, stMsgData->
paramValue);
4808 ret = system(install_cmd);
4813 RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Failed to execute the command. Returned error code '%d'\n", __FUNCTION__, ret);
4817 RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,
"[%s] Exiting..\n", __FUNCTION__ );