RDK Documentation (Open Sourced RDK Components)
Device_DeviceInfo.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016-2019 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file Device_DeviceInfo.cpp
22  * @brief This source file contains the APIs for getting device information.
23  */
24 
25 
26 
27 
28 /*****************************************************************************
29  * STANDARD INCLUDE FILES
30  *****************************************************************************/
31 
32 
33 /**
34 * @defgroup tr69hostif
35 * @{
36 * @defgroup hostif
37 * @{
38 **/
39 
40 
41 #include <fstream>
42 #include <cmath>
43 #include <cstring>
44 #include <sys/stat.h>
45 #include <sys/sysinfo.h>
46 #include <sys/ioctl.h>
47 #include <net/if.h>
48 #include <sys/wait.h>
49 #include <sys/socket.h>
50 #include <netinet/in.h>
51 #include <arpa/inet.h>
52 #include <errno.h>
53 #include <ifaddrs.h>
54 #include <sys/inotify.h>
55 #include <map>
56 #include <string>
57 #include <iostream>
58 #include <fstream>
59 #include <algorithm>
60 #include <dirent.h>
61 #include "libIBus.h"
62 #include "mfrMgr.h"
63 #include "Device_DeviceInfo.h"
64 #include "hostIf_utils.h"
65 #include "pwrMgr.h"
66 #include <curl/curl.h>
67 
68 #include "dsTypes.h"
69 #include "host.hpp"
70 #include "manager.hpp"
71 #include "dsError.h"
72 #include "audioOutputPort.hpp"
73 #include "sysMgr.h"
74 #ifdef MEDIA_CLIENT
75 #include "netsrvmgrIarm.h"
76 #endif
77 
78 #ifdef USE_REMOTE_DEBUGGER
79 #include "rrdIarm.h"
80 #endif
81 
82 #ifdef YOCTO_BUILD
83 #include "secure_wrapper.h"
84 #endif
85 
86 #ifdef USE_MoCA_PROFILE
87 #include "Device_MoCA_Interface.h"
88 #endif
89 #ifdef USE_XRESRC
90 #include "Device_XComcast_Xcalibur_Client_XRE_ConnectionTable.h"
91 #endif
92 #if USE_HWSELFTEST_PROFILE
93 #include "DeviceInfo_hwHealthTest.h"
94 #endif
95 
96 #include "hostIf_NotificationHandler.h"
97 #include "safec_lib.h"
98 
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
113 #define HTTP_OK 200
114 
115 /* Localhost port range for stunnel client to listen/accept */
116 #define MIN_PORT_RANGE 3000
117 #define MAX_PORT_RANGE 3020
118 
119 #define DEVICEID_SCRIPT_PATH "/lib/rdk/getDeviceId.sh"
120 #define SCRIPT_OUTPUT_BUFFER_SIZE 512
121 
122 GHashTable* hostIf_DeviceInfo::ifHash = NULL;
123 GHashTable* hostIf_DeviceInfo::m_notifyHash = NULL;
124 GMutex* hostIf_DeviceInfo::m_mutex = NULL;
125 
126 void *ResetFunc(void *);
127 
128 
129 static int get_ParamValue_From_TR69Agent(HOSTIF_MsgData_t *);
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";
136 
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;
143 
144 #ifndef NEW_HTTP_SERVER_DISABLE
145 XRFCStore* hostIf_DeviceInfo::m_rfcStore;
146 XRFCStorage hostIf_DeviceInfo::m_rfcStorage;
147 #else
148 XRFCStorage hostIf_DeviceInfo::m_rfcStorage;
149 #endif
150 XBSStore* hostIf_DeviceInfo::m_bsStore;
151 string hostIf_DeviceInfo::m_xrPollingAction = "0";
152 
153 /****************************************************************************************************************************************************/
154 // Device.DeviceInfo Profile. Getters:
155 /****************************************************************************************************************************************************/
156 
157 /**
158  * @brief Class Constructor of the class hostIf_DeviceInfo.
159  *
160  * It memset the private members variables of the class such as backupSoftwareVersion, backupSerialNumber,
161  * backupManufacturer, backupModelName etc.
162  */
164  dev_id(dev_id),
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)
176 {
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();
191 #endif
192  m_bsStore = XBSStore::getInstance();
193 }
194 hostIf_DeviceInfo::~hostIf_DeviceInfo()
195 {
196  if(m_notifyHash)
197  {
198  g_hash_table_destroy(m_notifyHash);
199  }
200 }
201 
202 hostIf_DeviceInfo* hostIf_DeviceInfo::getInstance(int dev_id)
203 {
204  hostIf_DeviceInfo* pRet = NULL;
205 
206  if(ifHash)
207  {
208  pRet = (hostIf_DeviceInfo *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
209  }
210  else
211  {
212  ifHash = g_hash_table_new(NULL,NULL);
213  }
214 
215  if(!pRet)
216  {
217  try {
218  pRet = new hostIf_DeviceInfo(dev_id);
219  } catch(int e)
220  {
221  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception, not able create MoCA Interface instance..\n");
222  }
223  g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
224  }
225  return pRet;
226 }
227 
228 GList* hostIf_DeviceInfo::getAllInstances()
229 {
230  if(ifHash)
231  return g_hash_table_get_keys(ifHash);
232  return NULL;
233 }
234 
235 void hostIf_DeviceInfo::closeInstance(hostIf_DeviceInfo *pDev)
236 {
237  if(pDev)
238  {
239  g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
240  delete pDev;
241  }
242 }
243 
244 void hostIf_DeviceInfo::closeAllInstances()
245 {
246  if(ifHash)
247  {
248  GList* tmp_list = g_hash_table_get_values (ifHash);
249 
250  while(tmp_list)
251  {
252  hostIf_DeviceInfo* pDev = (hostIf_DeviceInfo *)tmp_list->data;
253  tmp_list = tmp_list->next;
254  closeInstance(pDev);
255  }
256  }
257 }
258 
259 void hostIf_DeviceInfo::getLock()
260 {
261  if(!m_mutex)
262  {
263  m_mutex = g_mutex_new();
264  }
265  g_mutex_lock(m_mutex);
266 }
267 
268 void hostIf_DeviceInfo::releaseLock()
269 {
270  g_mutex_unlock(m_mutex);
271 }
272 
273 GHashTable* hostIf_DeviceInfo::getNotifyHash()
274 {
275  if(m_notifyHash)
276  {
277  return m_notifyHash;
278  }
279  else
280  {
281  return m_notifyHash = g_hash_table_new(g_str_hash, g_str_equal);
282  }
283 }
284 
285 /**
286  * @brief This function provides the Identifier of the particular device that is
287  * unique for the indicated class of product and manufacturer. This is the Serial Number of the box.
288  * This value MUST remain fixed over the lifetime of the device, including
289  * across firmware updates. Any change would indicate that it's a new device
290  * and would therefore require to inform BOOTSTRAP.
291  *
292  * @param[out] stMsgData TR-069 Host interface message request.
293  * @param[in] pChanged Status of the operation.
294  *
295  * @return Returns the status of the operation.
296  *
297  * @retval OK if it is successful.
298  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
299  * @ingroup TR69_HOSTIF_DEVICEINFO_API
300  */
302 {
303  int ret=NOT_HANDLED;
304  stMsgData->paramtype = hostIf_StringType;
305 
306 #if !defined (USE_DEV_PROPERTIES_CONF)
308  memset(&param, 0, sizeof(param));
309  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
310  param.type = mfrSERIALIZED_TYPE_SERIALNUMBER;
312 
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)
315  {
316  try
317  {
318  if(param.buffer && param.bufLen)
319  {
320  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
321  stMsgData->paramValue[param.bufLen+1] = '\0';
322  stMsgData->paramLen = param.bufLen;
323  if(bCalledSerialNumber && pChanged && strncmp(stMsgData->paramValue,backupSerialNumber,_BUF_LEN_16 ))
324  {
325  *pChanged = true;
326  }
327  bCalledSerialNumber = true;
328  strncpy(backupSerialNumber,stMsgData->paramValue,_BUF_LEN_16 );
329  ret = OK;
330  }
331  else {
332  ret = NOK;
333  stMsgData->faultCode = fcInvalidParameterValue;
334  }
335  } catch (const std::exception e)
336  {
337  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
338  stMsgData->faultCode = fcInvalidParameterValue;
339  ret = NOK;
340  }
341  }
342  else
343  {
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);
345  ret = NOK;
346  }
347 #else
348  {
350  if(IARM_RESULT_SUCCESS == IARM_Bus_Call(IARM_BUS_SYSMGR_NAME, IARM_BUS_SYSMGR_API_GetSystemStates, &param, sizeof(param)))
351  {
352  if (param.stb_serial_no.payload != NULL)
353  {
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 );
356  ret = OK;
357  }
358  else
359  {
360  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Null for SerialNumber from \"%s\".\n",__FUNCTION__,IARM_BUS_SYSMGR_NAME);
361  stMsgData->faultCode = fcInvalidParameterValue;
362  ret = NOK;
363  }
364  }
365  else {
366  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] The parameter \"%s\" is failed to get from \"%s\".\n",__FUNCTION__, stMsgData->paramName, IARM_BUS_SYSMGR_NAME);
367  stMsgData->faultCode = fcInvalidParameterValue;
368  ret = NOK;
369  }
370  }
371 #endif //!defined (USE_DEV_PROPERTIES_CONF)
372  return ret;
373 }
374 
375 /**
376  * @brief This function identifying the Software/Firmware version of the running
377  * image on the box (Vx.y.z). A string identifying the software version currently installed
378  * in the CPE (i.e. version of the overall CPE firmware). To allow version comparisons,
379  * this element SHOULD be in the form of dot-delimited integers, where each successive
380  * integer represents a more minor category of variation.
381  * For example, 3.0.21 where the components mean: Major.Minor.Build.
382  *
383  * @param[out] stMsgData TR-069 Host interface message request.
384  * @param[in] pChanged Status of the operation.
385  *
386  * @return Returns the status of the operation.
387  *
388  * @retval OK if it is successful.
389  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
390  * @ingroup TR69_HOSTIF_DEVICEINFO_API
391  */
393 {
394  string line;
395  ifstream versionfile (VERSION_FILE);
396  bool isTrunkbuild = false;
397  bool isJenkinsbuild = false;
398  bool versionFlag = false;
399  char version[100] = {'\0'};
400  errno_t rc = -1;
401 
402  try {
403  if (versionfile.is_open())
404  {
405  while ( getline (versionfile,line) )
406  {
407  if (line.find("trunk") !=string::npos)
408  {
409  isTrunkbuild = true;
410  }
411  if ((line.find("_VERSION") == string::npos) && (line.find("VERSION") != string::npos))
412  {
413  char *tmpStr = strstr((char *)line.c_str(), "=");
414  tmpStr++;
415  while(isspace(*tmpStr)) {
416  tmpStr++;
417  }
418  rc=strcpy_s(version,sizeof(version), tmpStr);
419  if(rc!=EOK)
420  {
421  ERR_CHK(rc);
422  }
423  versionFlag = true;
424  if(!isTrunkbuild) break;
425  }
426 
427  if(isTrunkbuild)
428  {
429  if (line.find("JENKINS_BUILD_NUMBER") !=string::npos)
430  {
431  char *tmpStr = strstr((char *)line.c_str(), "=");
432  tmpStr++;
433  while(isspace(*tmpStr)) {
434  tmpStr++;
435  }
436  strcat(version, ".");
437  strcat(version,tmpStr);
438  isJenkinsbuild = true;
439  }
440  if(versionFlag &&isJenkinsbuild)
441  {
442  break;
443  }
444  }
445  }
446  versionfile.close();
447  }
448  else
449  {
450  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Failed to open file\n", __FUNCTION__);
451  return NOK;
452  }
453 
454 
455  if(bCalledSoftwareVersion && pChanged && strncmp(version,backupSoftwareVersion,_BUF_LEN_16 ))
456  {
457  *pChanged = true;
458  }
459  bCalledSoftwareVersion = true;
460  strncpy(backupSoftwareVersion,version,_BUF_LEN_16 );
461  stMsgData->paramLen = strlen(version);
462  strncpy(stMsgData->paramValue,version, stMsgData->paramLen);
463  stMsgData->paramtype = hostIf_StringType;
464  }
465  catch (const std::exception e) {
466  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught.\n", __FUNCTION__);
467  return NOK;
468  }
469  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ );
470  return OK;
471 }
472 
473 /**
474  * @brief This function retrieves manufacturer specific data from the box using IARM Bus call.
475  * The IARM Manager gets the manufacture information from mfr library.
476  *
477  * @param[out] stMsgData TR-069 Host interface message request.
478  * @param[in] pChanged Status of the operation.
479  *
480  * @return Returns the status of the operation.
481  *
482  * @retval OK if it is successful.
483  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
484  * @ingroup TR69_HOSTIF_DEVICEINFO_API
485  */
487 {
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(&param, 0, sizeof(param));
494  param.type = mfrSERIALIZED_TYPE_MANUFACTURER;
496 
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)
499  {
500  try {
501  if(param.buffer && param.bufLen)
502  {
503  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
504  stMsgData->paramValue[param.bufLen+1] = '\0';
505  stMsgData->paramLen = param.bufLen;
506  if(bCalledManufacturer && pChanged && strncmp(stMsgData->paramValue,backupManufacturer,_BUF_LEN_16 ))
507  {
508  *pChanged = true;
509  }
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);
513  ret = OK;
514  }
515  else
516  ret = NOK;
517  } catch (const std::exception e)
518  {
519  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
520  ret = NOK;
521  }
522  }
523  else
524  {
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);
526  ret = NOK;
527  }
528 #else
529  // Try to get the value from property files
530  char* manufact = NULL;
531  manufact = getenvOrDefault("MANUFACTURE","");
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);
536  stMsgData->paramValue[len+1] = '\0';
537  stMsgData->paramLen = 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);
539  ret = OK;
540  } else {
541  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s:%d] Failed to get manufacturer from device properties..!!\n",__FUNCTION__, __FILE__, __LINE__);
542  ret = NOK;
543  }
544 #endif // #if !defined (USE_DEV_PROPERTIES_CONF)
545  return ret;
546 }
547 
548 /**
549  * @brief This function provides the manufactureOUT information. Organizationally unique
550  * identifier of the device manufacturer. Represented as a six hexadecimal-digit value using
551  * all upper-case letters and including any leading zeros. Possible patterns: [0-9A-F]{6}.
552  * This value MUST remain fixed over the lifetime of the device and also across
553  * firmware updates. Any change would indicate that, it's a new device and would
554  * therefore require a BOOTSTRAP.
555  *
556  * @param[out] stMsgData TR-069 Host interface message request.
557  * @param[in] pChanged Status of the operation.
558  *
559  * @return Returns the status of the operation.
560  *
561  * @retval OK if ManufacturerOUI was successfully fetched.
562  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
563  * @ingroup TR69_HOSTIF_DEVICEINFO_API
564  */
566 {
567  int ret=NOT_HANDLED;
568  stMsgData->paramtype = hostIf_StringType;
569 #if !defined (USE_DEV_PROPERTIES_CONF)
571  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
572  memset(&param, 0, sizeof(param));
573  param.type = mfrSERIALIZED_TYPE_MANUFACTUREROUI;
574  param.buffer[MAX_BUF] = {'\0'};
576 
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)
579  {
580  try
581  {
582  if( param.buffer && param.bufLen) {
583 #ifdef ENABLE_MFR_MFGOUI_HEX_CONVERSION
584  char tmpConv[2]="\0";
585  memset(&(*((char *)stMsgData->paramValue)),0,sizeof((*((char *)stMsgData->paramValue))));
586  for(int MOUI_indx=0;MOUI_indx<param.bufLen;MOUI_indx++)
587  {
588  sprintf(tmpConv,"%02hhX",param.buffer[MOUI_indx]);
589  strcat((char *)stMsgData->paramValue,tmpConv);
590  }
591  stMsgData->paramValue[(param.bufLen * 2)+1] = '\0';
592  stMsgData->paramLen = (param.bufLen * 2);
593 #else
594  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
595  stMsgData->paramValue[param.bufLen+1] = '\0';
596  stMsgData->paramLen = param.bufLen;
597 #endif
598  if(bCalledManufacturerOUI && pChanged && strncmp(stMsgData->paramValue,backupManufacturerOUI,_BUF_LEN_16 ))
599  {
600  *pChanged = true;
601  }
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);
605  ret = OK;
606  }
607  else
608  ret = NOK;
609  } catch (const std::exception e)
610  {
611  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
612  ret = NOK;
613  }
614  }
615  else
616  {
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);
618  ret = NOK;
619  }
620 #else
621 
622 #endif //#if !defined (USE_DEV_PROPERTIES_CONF)
623  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__);
624  return ret;
625 }
626 
627 /**
628  * @brief This function provides the Model name of the device.
629  * This MUST be based on Comcast_X_HW* specification and of the format TUVVVWXY.
630  *
631  * @param[out] stMsgData TR-069 Host interface message request.
632  * @param[in] pChanged Status of the operation.
633  *
634  * @return Returns the status of the operation.
635  *
636  * @retval OK if ManufacturerOUI was successfully fetched.
637  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
638  * @ingroup TR69_HOSTIF_DEVICEINFO_API
639  */
641 {
642  int ret=NOT_HANDLED;
643  stMsgData->paramtype = hostIf_StringType;
644 #if !defined (USE_DEV_PROPERTIES_CONF)
646  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
647  memset(&param, 0, sizeof(param));
648  param.type = mfrSERIALIZED_TYPE_MODELNAME;
650 
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);
652 
653  if(iarm_ret == IARM_RESULT_SUCCESS)
654  {
655  try
656  {
657  if(param.buffer && param.bufLen) {
658  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
659  stMsgData->paramValue[param.bufLen+1] = '\0';
660  stMsgData->paramLen = param.bufLen;
661  if(bCalledModelName && pChanged && strncmp(stMsgData->paramValue,backupModelName,_BUF_LEN_16 ))
662  {
663  *pChanged = true;
664  }
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);
668  ret = OK;
669  }
670  else
671  ret = NOK;
672  } catch (const std::exception e)
673  {
674  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
675  ret = NOK;
676  }
677  }
678  else
679  {
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);
681  ret = NOK;
682  }
683 #else
684  // Try to get MODEL NAME from Device Properties
685  FILE *fp = NULL;
686  char modelName[64] = {'\0'};
687 
688  fp = fopen(MODEL_NAME_FILE,"r");
689  if(fp == NULL) {
690  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s:%d] Failed to open MODEL Name file\n.!",__FUNCTION__, __FILE__, __LINE__);
691  return NOK;
692  }
693  if(fgets(modelName, 64,fp)!=NULL) {
694  // Remove new line char if any in model name
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);
698  strncpy((char *)stMsgData->paramValue, modelName,sizeof(stMsgData->paramValue)-1);
699  stMsgData->paramValue[sizeof(stMsgData->paramValue)-1] = '\0';
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);
702  ret = OK;
703  } else {
704  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Failed to read model name.\n", __FUNCTION__);
705  }
706  fclose(fp);
707 
708 #endif //#if !defined (USE_DEV_PROPERTIES_CONF)
709  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__);
710  return ret;
711 
712 }
713 
714 /**
715  * @brief This function provides the A full description of the device.
716  * Currently not implemented.
717  *
718  * @param[out] stMsgData TR-069 Host interface message request.
719  * @param[in] pChanged Status of the operation.
720  *
721  * @return Returns enum integer '-1' on method completion.
722  * @ingroup TR69_HOSTIF_DEVICEINFO_API
723  */
725 {
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);
729  stMsgData->paramLen = strlen(stMsgData->paramValue);
730  return OK;
731 }
732 
733 /**
734  * @brief This function provides the Identifier of the class of product for which
735  * the serial number applies. That is, for a given manufacturer,
736  * this parameter is used to identify the product or class of product
737  * over which the SerialNumber parameter is unique. This value MUST remain fixed
738  * over the lifetime of the device and also across firmware updates. Any change
739  * would indicate that it's a new device and would therefore require a BOOTSTRAP.
740  * Currently not implemented.
741  *
742  * @param[out] stMsgData TR-069 Host interface message request.
743  * @param[in] pChanged Status of the operation.
744  *
745  * @return Returns enum integer '-1' on method completion.
746  * @ingroup TR69_HOSTIF_DEVICEINFO_API
747  */
749 {
750  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__);
751  stMsgData->paramtype = hostIf_StringType;
752 
753 #ifndef FETCH_PRODUCTCLASS_FROM_MFRLIB
754  /* Fixed DELIA-27160, always returns as OK */
755  char *pc = NULL;
756  pc = getenv((const char *)"RECEIVER_PLAT_TYPE");
757 
758  if(pc) {
759  snprintf((char *)stMsgData->paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN-1, "%s", pc);
760  stMsgData->paramLen = strlen(stMsgData->paramValue);
761  }
762  return OK;
763 #else /* FETCH_PRODUCTCLASS_FROM_MFRLIB */
764  int ret;
766  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
767  memset(&param, 0, sizeof(param));
768  param.type = mfrSERIALIZED_TYPE_PRODUCTCLASS;
769  param.buffer[MAX_BUF] = {'\0'};
771 
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)
774  {
775  try
776  {
777  if( param.buffer && param.bufLen) {
778  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
779  stMsgData->paramValue[param.bufLen+1] = '\0';
780  stMsgData->paramLen = param.bufLen;
781  if(bCalledProductClass && pChanged && strncmp(stMsgData->paramValue,backupProductClass,_BUF_LEN_16 ))
782  {
783  *pChanged = true;
784  }
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);
789  ret = OK;
790  }
791  else
792  ret = NOK;
793  } catch (const std::exception e)
794  {
795  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\n",__FUNCTION__);
796  ret = NOK;
797  }
798  }
799  else
800  {
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);
802  ret = NOK;
803  }
804  return ret;
805 #endif /* FETCH_PRODUCTCLASS_FROM_MFRLIB */
806 }
807 
808 /**
809  * @brief This function identifying the particular CPE model and version.
810  * This MUST be based on Comcast_X_HW* specification and of the format VM.m.R.
811  *
812  * @param[out] stMsgData TR-069 Host interface message request.
813  * @param[in] pChanged Status of the operation.
814  *
815  * @return Returns the status of the operation.
816  *
817  * @retval OK if it is successfully fetch data from device.
818  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
819  * @ingroup TR69_HOSTIF_DEVICEINFO_API
820  */
822 {
823  int ret=NOT_HANDLED;
824  stMsgData->paramtype = hostIf_StringType;
826  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
827  memset(&param, 0, sizeof(param));
828  param.type = mfrSERIALIZED_TYPE_HARDWAREVERSION;
830 
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)
833  {
834  try
835  {
836  if(param.buffer && param.bufLen) {
837  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
838  stMsgData->paramValue[param.bufLen+1] = '\0';
839  stMsgData->paramLen = param.bufLen;
840  if(bCalledHardwareVersion && pChanged && strncmp(stMsgData->paramValue,backupHardwareVersion,_BUF_LEN_16 ))
841  {
842  *pChanged = true;
843  }
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);
847  ret = OK;
848  }
849  else
850  ret = NOK;
851  } catch (const std::exception e)
852  {
853  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
854  ret = NOK;
855  }
856 
857  }
858  else
859  {
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);
861  ret = NOK;
862  }
863 
864  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__);
865  return ret;
866 }
867 
868 /**
869  * @brief This function identifying any additional CPE model and version.
870  * Currently not implemented.
871  *
872  * @param[out] stMsgData TR-069 Host interface message request.
873  * @param[in] pChanged Status of the operation.
874  *
875  * @return Returns enum integer '-1' on method completion.
876  * @ingroup TR69_HOSTIF_DEVICEINFO_API
877  */
879 {
880  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__ );
881  return NOK;
882 }
883 
884 /**
885  * @brief This function identifying any additional Software/Firmware version of the running
886  * image on the box (Vx.y.z). A string identifying the software version currently installed
887  * in the CPE (i.e. version of the overall CPE firmware).
888  * To allow version comparisons, the version number SHOULD be in the form of
889  * dot-delimited integers, where each successive integer represents a more
890  * minor category of variation.
891  * For example, 3.0.21 where the components mean: Major.Minor.Build.
892  *
893  * @param[out] stMsgData TR-069 Host interface message request.
894  * @param[in] pChanged Status of the operation.
895  *
896  * @return Returns the status of the operation.
897  * @retval OK if it is successful fetch data from device.
898  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
899  * @ingroup TR69_HOSTIF_DEVICEINFO_API
900  */
902 {
903  int ret = NOT_HANDLED;
904  stMsgData->paramtype = hostIf_StringType;
906  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
907  memset(&param, 0, sizeof(param));
908 
909  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
910 
911  param.type = mfrSERIALIZED_TYPE_SOFTWAREVERSION;
912 
914 
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)
917  {
918  try
919  {
920  if(param.buffer && param.bufLen) {
921  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
922  stMsgData->paramValue[param.bufLen+1] = '\0';
923  if(bCalledAdditionalSoftwareVersion && pChanged && strncmp(stMsgData->paramValue,backupAdditionalSoftwareVersion,_BUF_LEN_16 ))
924  {
925  *pChanged = true;
926  }
927  bCalledAdditionalSoftwareVersion = true;
928  strncpy(backupAdditionalSoftwareVersion,stMsgData->paramValue,_BUF_LEN_16 );
929 
930  stMsgData->paramLen = param.bufLen;
931  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramValue, param.buffer);
932  ret = OK;
933  }
934  else
935  ret = NOK;
936  } catch (const std::exception e)
937  {
938  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
939  ret = NOK;
940  }
941  }
942  else
943  {
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);
945  ret = NOK;
946  }
947  return ret;
948 }
949 
950 
951 /**
952  * @brief This is an identifier of the primary service provider and other provisioning
953  * information, which MAY be used to determine service provider-specific customization
954  * and provisioning parameters.
955  *
956  * @param[out] stMsgData TR-069 Host interface message request.
957  * @param[in] pChanged Status of the operation.
958  *
959  * @return Returns the status of the operation.
960  *
961  * @retval OK if it is successful fetch data from the device.
962  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
963  * @ingroup TR69_HOSTIF_DEVICEINFO_API
964  */
966 {
967  int ret=NOT_HANDLED;
968  stMsgData->paramtype = hostIf_StringType;
970  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
971  memset(&param, 0, sizeof(param));
972  param.type = mfrSERIALIZED_TYPE_PROVISIONINGCODE;
974 
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)
977  {
978  try
979  {
980  if(param.buffer && param.bufLen)
981  {
982  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
983  stMsgData->paramValue[param.bufLen+1] = '\0';
984  stMsgData->paramLen = param.bufLen;
985  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d] paramValue: %s param.pBuffer: %s \n", __FUNCTION__, __FILE__, __LINE__, stMsgData->paramValue, param.buffer);
986  ret = OK;
987  }
988  else
989  {
990  ret = NOK;
991  }
992  } catch (const std::exception e)
993  {
994  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
995  ret = NOK;
996  }
997 
998  }
999  else
1000  {
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);
1002  ret = NOK;
1003  }
1004  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__);
1005  return OK; // For any failures return OK for now to get empty results.
1006 }
1007 
1008 
1009 
1010 /**
1011  * @brief This is an identifier of time in seconds since the CPE was last restarted.
1012  *
1013  * @param[out] stMsgData TR-069 Host interface message request.
1014  * @param[in] pChanged Status of the operation.
1015  *
1016  * @return Returns the status of the operation.
1017  *
1018  * @retval OK if it is successful fetch data from the device.
1019  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1020  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1021  */
1023 {
1024  struct sysinfo info;
1025  sysinfo (&info);
1026  put_int(stMsgData->paramValue, (int) info.uptime);
1027  stMsgData->paramtype = hostIf_IntegerType;
1028  return OK;
1029 }
1030 
1031 /**
1032  * @brief This function use to get the 'Date' and 'Time' in UTC that the CPE first both
1033  * successfully established an IP-layer network connection and acquired an absolute time
1034  * reference using NTP or equivalent over that network connection. The CPE MAY reset this
1035  * date after a factory reset. If NTP or equivalent is not available, this parameter, if
1036  * present, SHOULD be set to the unknown time value.
1037  *
1038  * @param[out] stMsgData TR-069 Host interface message request.
1039  * @param[in] pChanged Status of the operation.
1040  *
1041  * @return Returns the status of the operation.
1042  *
1043  * @retval OK if it is successful fetch data from the device.
1044  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1045  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1046  */
1048 {
1049  struct stat st;
1050  struct tm *tm;
1051  char buffer [36] = {'\0'};
1052  char timeZoneTmp[7] = {'\0'};
1053 
1054  if (0 > stat(NTP_FILE_NAME, &st))
1055  {
1056  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Failed:Error on stat() for %s \n",__FILE__,__FUNCTION__,__LINE__, NTP_FILE_NAME);
1057  return NOK;
1058  }
1059 
1060  tm = gmtime(&(st.st_mtime));
1061  strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm); //CID:81299 - OVERRUN
1062  strftime(timeZoneTmp, sizeof(timeZoneTmp), "%z", tm);
1063  sprintf(buffer + strlen(buffer), ".%.6d%s", tm->tm_sec, timeZoneTmp);
1064 
1065  stMsgData->paramtype = hostIf_StringType;
1066  stMsgData->paramLen = strlen(buffer);
1067  strncpy(stMsgData->paramValue, buffer, stMsgData->paramLen +1);
1068  return OK;
1069 }
1070 
1071 /**
1072  * @brief This function use to get the MAC Address of the eth1 interface currently.
1073  *
1074  * @param[out] stMsgData TR-069 Host interface message request.
1075  * @param[in] pChanged Status of the operation.
1076  *
1077  * @return Returns the status of the operation.
1078  *
1079  * @retval OK if it is successfully fetch data from the device.
1080  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1081  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1082  */
1084 {
1085  errno_t rc = -1;
1086  int ret = NOT_HANDLED;
1087 #if !defined (USE_DEV_PROPERTIES_CONF)
1089  memset(&param, 0, sizeof(param));
1090  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
1091  param.type = mfrSERIALIZED_TYPE_DEVICEMAC;
1092  int len = strlen(stbMacCache);
1093 
1094 
1095  try
1096  {
1097  if((stbMacCache[0] == '\0') && (len == 0)) {
1098  iarm_ret = IARM_Bus_Call(IARM_BUS_MFRLIB_NAME, IARM_BUS_MFRLIB_API_GetSerializedData, &param, sizeof(param));
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)
1101  {
1102  if(param.buffer && param.bufLen) {
1103  strncpy((char *)stMsgData->paramValue, param.buffer, param.bufLen);
1104  stMsgData->paramValue[param.bufLen+1] = '\0';
1105  stMsgData->paramLen = param.bufLen;
1106  if(bCalledDeviceMAC && pChanged && strncmp(stMsgData->paramValue,backupDeviceMAC,_BUF_LEN_32 ))
1107  {
1108  *pChanged = true;
1109  }
1110  bCalledDeviceMAC = true;
1111  strncpy(backupDeviceMAC,stMsgData->paramValue,_BUF_LEN_32 );
1112  memset(stbMacCache, '\0', TR69HOSTIFMGR_MAX_PARAM_LEN );
1113  strncpy(stbMacCache, param.buffer, param.bufLen);
1114  stMsgData->paramtype = hostIf_StringType;
1115  ret = OK;
1116  }
1117  else {
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);
1119  ret = NOK;
1120  }
1121  }
1122  else {
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);
1124  ret = NOK;
1125  }
1126  }
1127  else
1128  {
1129  memset(stMsgData->paramValue, '\0', TR69HOSTIFMGR_MAX_PARAM_LEN );
1130  stMsgData->paramLen = len;
1131  strncpy(stMsgData->paramValue, stbMacCache, stMsgData->paramLen);
1132  stMsgData->paramtype = hostIf_StringType;
1133  ret = OK;
1134  }
1135  } catch (const std::exception& e)
1136  {
1137  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1138  ret = NOK;
1139  }
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())
1144  {
1145  rc=strcpy_s(stMsgData->paramValue,sizeof(stMsgData->paramValue), stb_mac.c_str());
1146  if(rc!=EOK)
1147  {
1148  ERR_CHK(rc);
1149  }
1150  }
1151  else
1152  stMsgData->faultCode = fcInvalidParameterValue;
1153  stMsgData->paramLen = stb_mac.length();
1154  stMsgData->paramtype = hostIf_StringType;
1155  ret = OK;
1156 #endif
1157  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()]\n", __FUNCTION__);
1158  return ret;
1159 }
1160 
1161 string hostIf_DeviceInfo::getEstbIp()
1162 {
1163  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__);
1164  string retAddr;
1165 #if MEDIA_CLIENT
1166  IARM_Result_t ret = IARM_RESULT_SUCCESS;
1168  memset(&param, 0, sizeof(param));
1169  try
1170  {
1171  ret = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME,IARM_BUS_NETSRVMGR_API_getSTBip, (void*)&param, sizeof(param));
1172  if (ret != IARM_RESULT_SUCCESS )
1173  {
1174  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"[%s():%d] IARM_BUS_NETSRVMGR_API_getActiveInterface failed \n", __FUNCTION__, __LINE__);
1175  }
1176  retAddr=param.activeIfaceIpaddr;
1177  }
1178  //Legacy way of getting estb ip.
1179 #else
1180 
1181  struct ifaddrs *ifAddrStr = NULL;
1182  struct ifaddrs * ifa = NULL;
1183  void * tmpAddrPtr = NULL;
1184  char tmp_buff[TR69HOSTIFMGR_MAX_PARAM_LEN] = {'\0'};
1185 
1186 
1187  const char *ipv6_fileName = "/tmp/estb_ipv6";
1188  const char *Wifi_Enable_file = "/tmp/wifi-on";
1189 
1190  try {
1191  /*check for ipv6 file*/
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;
1195 //#ifdef MEDIA_CLIENT
1196  /* Get configured moca interface */
1197 // ip_if = "MOCA_INTERFACE";
1198 //#else
1199  ip_if = "DEFAULT_ESTB_INTERFACE";
1200 //#endif
1201  char *ethIf = getenvOrDefault (ip_if, "");
1202  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"[%s():%d] ipv6Enabled : %d; isWifiEnabled : %d ethIf : %s\n",
1203  __FUNCTION__, __LINE__, ipv6Enabled, isWifiEnabled, ethIf);
1204 
1205  if(getifaddrs(&ifAddrStr))
1206  {
1207  RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s():%d] Failed in getifaddrs().\n", __FUNCTION__, __LINE__);
1208  return retAddr;
1209  }
1210  bool found = false;
1211 
1212  for (ifa = ifAddrStr; ifa != NULL; ifa = ifa->ifa_next)
1213  {
1214  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"[%s():%d] if name : %s; family : %d %s \n", __FUNCTION__, __LINE__,
1215  ifa->ifa_name,
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)" : "" );
1220 
1221  if (ifa->ifa_addr == NULL) continue;
1222 
1223  if (ipv6Enabled)
1224  {
1225  /* Check for IP6 */
1226  if ((ifa ->ifa_addr->sa_family == AF_INET6))
1227  {
1228  tmpAddrPtr=&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
1229  inet_ntop(AF_INET6, tmpAddrPtr, tmp_buff, INET6_ADDRSTRLEN);
1230 
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);
1234  found = true;
1235  break;
1236  }
1237  }
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);
1240  found = true;
1241  break;
1242  }
1243  }
1244  }
1245  else {
1246  /* Check for IP4 */
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);
1250 
1251  if(isWifiEnabled) {
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);
1254  found = true;
1255  break;
1256  }
1257  }
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);
1260  found = true;
1261  break;
1262  }
1263  }
1264  }
1265  }
1266 
1267  if (ifAddrStr!=NULL) {
1268  freeifaddrs(ifAddrStr);
1269  }
1270 
1271  if (!found) {
1272  return retAddr;
1273  }
1274  else {
1275  retAddr = tmp_buff;
1276  }
1277  }
1278 #endif
1279  catch (const std::exception &e)
1280  {
1281  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught %s\n", __FUNCTION__, e.what());
1282  }
1283  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__);
1284  return retAddr;
1285 }
1286 
1287 bool hostIf_DeviceInfo::isRsshactive()
1288 {
1289  const string pidfile("/var/tmp/rssh.pid");
1290  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
1291  bool retCode = false;
1292 
1293  ifstream pidstrm;
1294  pidstrm.exceptions(std::ifstream::failbit | std::ifstream::badbit);
1295  try {
1296  pidstrm.open(pidfile.c_str());
1297  int sshpid;
1298  pidstrm>>sshpid;
1299 
1300  if (getpgid(sshpid) >= 0)
1301  {
1302  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] SSH Session Active \n",__FUNCTION__);
1303  retCode = true;
1304  }
1305  else
1306  {
1307  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] SSH Session inactive \n",__FUNCTION__);
1308  }
1309  } catch (const std::exception& e) {
1310  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] SSH Session inactive ; Error opening pid file\n",__FUNCTION__);
1311  }
1312 
1313  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
1314  return retCode;
1315 }
1316 /**
1317  * @brief This function use to get the IPv4 Address of the eth1 interface currently.
1318  *
1319  * @param[out] stMsgData TR-069 Host interface message request.
1320  * @param[in] pChanged Status of the operation.
1321  *
1322  * @return Returns the status of the operation.
1323  *
1324  * @retval OK if it is successfully fetch data from the device.
1325  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1326  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1327  */
1329 {
1330  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__);
1331 
1332  string ipaddr = getEstbIp();
1333 
1334  if (ipaddr.empty())
1335  {
1336  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()]Ipaddress is empty..\n", __FUNCTION__);
1337  return NOK;
1338  }
1339  else {
1340  if(bCalledX_COMCAST_COM_STB_IP && pChanged && strncmp(ipaddr.c_str(),backupX_COMCAST_COM_STB_IP,_BUF_LEN_64 ))
1341  {
1342  *pChanged = true;
1343  }
1344  bCalledX_COMCAST_COM_STB_IP = true;
1345  strncpy(backupX_COMCAST_COM_STB_IP,ipaddr.c_str(),sizeof(backupX_COMCAST_COM_STB_IP) -1); //CID:136623 - Buffer size warning
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();
1349  strncpy(stMsgData->paramValue, ipaddr.c_str(), stMsgData->paramLen);
1350  stMsgData->paramtype = hostIf_StringType;
1351  }
1352  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__);
1353  return OK;
1354 }
1355 
1356 /**
1357  * @brief The X_COMCAST_COM_PowerStatus as get parameter results in the power status
1358  * being performed on the device. Power status of the device based on the front panel
1359  * power LED.
1360  *
1361  * @param[out] stMsgData TR-069 Host interface message request.
1362  * @param[in] pChanged Status of the operation.
1363  *
1364  * @return Returns the status of the operation. When read, this parameter returns an enumeration string.
1365  * @retval OK if it is successful fetch data from the device.
1366  * @retval NOK if not able to fetch data from the device.
1367  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1368  */
1370 {
1371  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__);
1372  IARM_Result_t err;
1373  int ret = NOK;
1374  const char *pwrState = "PowerOFF";
1375  int str_len = 0;
1377  memset(&param, 0, sizeof(param));
1378  IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL;
1379 
1382  (void *)&param,
1383  sizeof(param));
1384  if(err == IARM_RESULT_SUCCESS)
1385  {
1386  pwrState = (param.curState==IARM_BUS_PWRMGR_POWERSTATE_OFF)?"PowerOFF":(param.curState==IARM_BUS_PWRMGR_POWERSTATE_ON)?"PowerON":"Standby";
1387 
1388 // RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Current state is : (%d)%s\n",param.curState, pwrState);
1389  str_len = strlen(pwrState);
1390  try
1391  {
1392  strncpy((char *)stMsgData->paramValue, pwrState, str_len);
1393  stMsgData->paramValue[str_len+1] = '\0';
1394  stMsgData->paramLen = str_len;
1395  stMsgData->paramtype = hostIf_StringType;
1396  ret = OK;
1397  } catch (const std::exception e)
1398  {
1399  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1400  ret = NOK;
1401  }
1402  }
1403  else
1404  {
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);
1406  ret = NOK;
1407  }
1408 
1409  //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__);
1410  return ret;
1411 }
1412 
1413 /**
1414  * @brief Get the filename of the firmware currently running on the device.
1415  *
1416  * @param[out] stMsgData TR-069 Host interface message request.
1417  * @param[in] pChanged Status of the operation.
1418  *
1419  * @return Returns the Filename of the firmware currently running on the device.
1420  *
1421  * @retval OK if it is successfully fetch data from the device.
1422  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1423  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1424  */
1426 {
1427  errno_t rc = -1;
1428  string line;
1429  bool curFileFlag = true;
1430  ifstream curFwfile(CURENT_FW_FILE);
1431 
1432  try {
1433  if(curFwfile.is_open())
1434  {
1435  if(getline (curFwfile,line))
1436  {
1437  if(!line.empty()) {
1438  strncpy(stMsgData->paramValue, line.c_str(), line.length()+1 );
1439  }
1440  else {
1441  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed: \'%s\' has no content or empty..\n", CURENT_FW_FILE);
1442  curFileFlag = false;
1443  }
1444  }
1445  else
1446  {
1447  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to read \'%s\' due to Empty Buffer. \n", CURENT_FW_FILE);
1448  curFileFlag = false;
1449  }
1450  curFwfile.close();
1451  }
1452  else
1453  {
1454  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed \'%s\' due to [\'%s\' (%d)]. \n", CURENT_FW_FILE, strerror(errno), errno);
1455  curFileFlag = false;
1456  }
1457 
1458  if(!curFileFlag)
1459  {
1460  ifstream myfile ("/version.txt");
1461  if (myfile.is_open())
1462  {
1463  while ( getline (myfile,line) )
1464  {
1465  size_t found = line.find("imagename");
1466  if (found!=string::npos)
1467  {
1468  break;
1469  }
1470  }
1471  myfile.close();
1472  }
1473  else
1474  {
1475  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Unable to open file\n", __FUNCTION__);
1476  }
1477 
1478  if(line.length()) {
1479  char * cstr = new char [line.length()+1];
1480  rc=strcpy_s (cstr,(line.length()+1), line.c_str());
1481  if(rc!=EOK)
1482  {
1483  ERR_CHK(rc);
1484  }
1485  char * pch = NULL;
1486  pch = strstr (cstr,":");
1487  pch++;
1488 
1489  while(isspace(*pch)) {
1490  pch++;
1491  }
1492  delete[] cstr;
1493 
1494  if(bCalledX_COMCAST_COM_FirmwareFilename && pChanged && strncmp(pch,backupX_COMCAST_COM_FirmwareFilename,_BUF_LEN_64 ))
1495  {
1496  *pChanged = true;
1497  }
1498 
1499  bCalledX_COMCAST_COM_FirmwareFilename = true;
1500  strncpy(backupX_COMCAST_COM_FirmwareFilename,pch,sizeof(backupX_COMCAST_COM_FirmwareFilename) -1); //CID:136569 - Buffer size
1501  backupX_COMCAST_COM_FirmwareFilename[sizeof(backupX_COMCAST_COM_FirmwareFilename) -1] = '\0';
1502  strncpy(stMsgData->paramValue,pch,_BUF_LEN_64 );
1503  strncpy((char *) stMsgData->paramValue, pch, stMsgData->paramLen +1 );
1504  }
1505  }
1506 
1507  stMsgData->paramtype = hostIf_StringType;
1508  stMsgData->paramLen = strlen(stMsgData->paramValue);
1509  }
1510  catch (const std::exception e) {
1511  cout << __FUNCTION__ << endl;
1512  }
1513 
1514  return OK;
1515 }
1516 
1517 /**
1518  * @brief Get the filename of the firmware that the device was requested to download most recently.
1519  *
1520  * @param[out] stMsgData TR-069 Host interface message request.
1521  * @param[in] pChanged Status of the operation.
1522  *
1523  * @return Returns the filename of the firmware that was recently downloaded.
1524  *
1525  * @retval OK if it is successfully fetch data from the device.
1526  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1527  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1528  */
1530 {
1531  int ret = NOK;
1532  try
1533  {
1534  if(OK == readFirmwareInfo((char *)"DnldFile", stMsgData))
1535  ret = OK;
1536  else
1537  ret = NOK;
1538  }
1539  catch (const std::exception & e) {
1540  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()] Exception occurred due to %s. \n", __FUNCTION__, e.what());
1541  }
1542  return ret;
1543 }
1544 
1546 {
1547  if(OK == readFirmwareInfo((char *)"Status", stMsgData))
1548  return OK;
1549  else
1550  return NOK;
1551 }
1552 
1554 {
1555  if(OK == readFirmwareInfo((char *)"Proto", stMsgData))
1556  return OK;
1557  else
1558  return NOK;
1559 }
1560 
1562 {
1563  if(OK == readFirmwareInfo((char *)"DnldURL", stMsgData))
1564  return OK;
1565  else
1566  return NOK;
1567 }
1568 
1569 // Get the Codebig flag value (from /opt/fwdnldstatus.txt) which is already set using 'Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadUseCodebig' tr-181 parameter
1571 {
1572  if(OK == readFirmwareInfo((char *)"Codebig_Enable", stMsgData))
1573  return OK;
1574  else
1575  return NOK;
1576 }
1577 
1578 // Get the Defer Reboot flag value which is already set using 'Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadDeferReboot' tr-181 parameter
1579 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(HOSTIF_MsgData_t* stMsgData, bool *pChanged)
1580 {
1581  stMsgData->paramtype = hostIf_BooleanType;
1582  stMsgData->paramLen = sizeof(bool);
1583 
1584  put_boolean(stMsgData->paramValue, m_xFirmwareDownloadDeferReboot);
1585 
1586  return OK;
1587 }
1588 
1589 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent (HOSTIF_MsgData_t* stMsgData, bool *pChanged)
1590 {
1591  LOG_ENTRY_EXIT;
1592 
1593  int firmwareDownloadPercent = -1;
1594  char output[8];
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))
1596  {
1597  output[strcspn(output, "\n")] = 0;
1598  if (*output)
1599  {
1600  firmwareDownloadPercent = strtol (output, NULL, 10);
1601  }
1602  }
1603 
1604  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] FirmwareDownloadPercent = [%d]\n", __FUNCTION__, firmwareDownloadPercent);
1605 
1606  put_int (stMsgData->paramValue, firmwareDownloadPercent);
1607  stMsgData->paramtype = hostIf_IntegerType;
1608  stMsgData->paramLen = sizeof(int);
1609 
1610  return OK;
1611 }
1612 
1613 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareUpdateState(HOSTIF_MsgData_t * stMsgData, bool *pChanged)
1614 {
1615  if(OK == readFirmwareInfo((char *)"fwUpdateState", stMsgData))
1616  return OK;
1617  else
1618  return NOK;
1619 }
1620 
1621 /**
1622  * @brief This function gets the number of entries in the VendorConfigFile table.
1623  * Currently not implemented.
1624  *
1625  * @param[out] stMsgData TR-069 Host interface message request.
1626  * @param[in] pChanged Status of the operation.
1627  *
1628  * @return Returns the status of the operation.
1629  *
1630  * @retval OK if it is successful fetch data from the device.
1631  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1632  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1633  */
1635 {
1636  return NOK;
1637 }
1638 
1639 /**
1640  * @brief This function gets the number of entries in the SupportedDataModel table.
1641  * Currently not implemented.
1642  *
1643  * @param[out] stMsgData TR-069 Host interface message request.
1644  * @param[in] pChanged Status of the operation.
1645  *
1646  * @return Returns the status of the operation.
1647  *
1648  * @retval OK if it is successful fetch data from the device.
1649  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1650  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1651  */
1653 {
1654 // put_int(stMsgData->paramValue, (unsigned int)DEVICE_SUPPORTED_DATA_MODEL_NUMBER_OF_ENTRIES);
1655 
1656  /* Fixed DELIA-27160, always returns as OK */
1657  return OK;
1658 }
1659 
1661 {
1662  FILE *fp = NULL;
1663  char resultBuff[200] = {'\0'};
1664  char cmd[200] = "/bin/cat /proc/cpuinfo | /bin/grep processor | /usr/bin/wc -l";
1665  int noOfProcessorEntries = 0;
1666 
1667  fp = popen(cmd,"r");
1668 
1669  if(fp == NULL) {
1670  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s(): Error popen\n", __FUNCTION__);
1671  return 0;
1672  }
1673 
1674  if(fgets(resultBuff, 200,fp)!=NULL) {
1675  sscanf(resultBuff,"%d",&noOfProcessorEntries);
1676  }
1677 
1678  pclose(fp);
1679 
1680  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): Processors Count: [%d]\n", __FUNCTION__, noOfProcessorEntries);
1681 
1682  put_int(stMsgData->paramValue,noOfProcessorEntries);
1683  stMsgData->paramtype = hostIf_UnsignedIntType;
1684  stMsgData->paramLen=4;
1685 
1686  return OK;
1687 }
1688 
1689 /**
1690  * @brief The function gets the number of entries in the VendorLogFile table.
1691  * Currently not implemented.
1692  *
1693  * @param[out] stMsgData TR-069 Host interface message request.
1694  * @param[in] pChanged Status of the operation.
1695  *
1696  * @return Returns the status of the operation.
1697  *
1698  * @retval OK if it is successful fetch data from the device.
1699  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1700  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1701  */
1703 {
1704  return NOK;
1705 }
1706 
1707 /**
1708  * @brief This function get X_COMCAST-COM_Reset returns an empty string.
1709  * Currently not implemented.
1710  *
1711  * @param[out] stMsgData TR-069 Host interface message request.
1712  * @param[in] pChanged Status of the operation.
1713  *
1714  * @return Returns integer '-1' on method completion
1715  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1716  */
1718 {
1719  return NOK;
1720 }
1721 
1722 /*
1723  * Parameter Name: Device.DeviceInfo.MemoryStatus.Total
1724  * Status of the device's volatile physical memory.
1725  * The total physical RAM, in kilobytes, installed on the device.
1726  */
1727 
1728 /**
1729  * @brief Get the device total memory status.
1730  *
1731  * @param[out] stMsgData TR-069 Host interface message request.
1732  * @param[in] pChanged Status of the operation.
1733  *
1734  * @return Returns the status of the operation.
1735  *
1736  * @retval OK if it is successfully fetch data from the device.
1737  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1738  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1739  */
1741 {
1742  struct sysinfo sys_info;
1743 
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;
1747  return OK;
1748 }
1749 
1750 /*
1751  * Parameter Name: Device.DeviceInfo.MemoryStatus.Free
1752  * Status of the device's volatile physical memory.
1753  * The free physical RAM, in kilobytes, currently available on the device.
1754  */
1755 
1756 /**
1757  * @brief Get the device total free memory status.
1758  *
1759  * @param[out] stMsgData TR-069 Host interface message request.
1760  * @param[in] pChanged Status of the operation.
1761  *
1762  * @return Returns the status of the operation.
1763  *
1764  * @retval OK if it is successful fetch data from the device.
1765  * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device.
1766  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1767  */
1769 {
1770  struct sysinfo sys_info;
1771 
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;
1775  return OK;
1776 }
1777 
1778 /**
1779  * @brief This method is updated with the boot status of the device at the time of query.
1780  * If the device is currently starting up, this parameter will hold boot status as per the
1781  * boot sequence of the device.
1782  * BootStatus string - Boot status for an STB CPE via TR-069 ACS when powered On.
1783  * Enumeration of :
1784  * Coax connection confirmed, MoCA enabled
1785  * Discovering MoCA Network Coordinator: MoCA MAC: xx:xx:xx:xx:xx:xx
1786  * Joining MoCA Network
1787  * Connection successful
1788  * Acquiring IP Address from Gateway
1789  * Contacting ACS
1790  * Contacting XRE
1791  *
1792  * @param[out] stMsgData TR-069 Host interface message request.
1793  * @param[in] pChanged Status of the operation.
1794  *
1795  * @return Returns the status of the operation.
1796  *
1797  * @retval OK if it is successfully fetch data from the device.
1798  * @retval NOK if not able to fetch data from the device.
1799  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1800  */
1802 {
1803 
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'};
1809  errno_t rc = -1;
1810 
1811  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering \n",__FUNCTION__);
1812 
1813  /**
1814  * Checking following steps under : checkMoCABootStatus()
1815  * 1. Coax connection confirmed, MoCA enabled
1816  * 2. Discovering MoCA Network Coordinator: MoCA MAC: xx:xx:xx:xx:xx:xx
1817  * 3. Joining MoCA Network
1818  **/
1819 
1820 #ifdef USE_MoCA_PROFILE
1821  MoCAInterface *mIf = MoCAInterface::getInstance(0);
1822  mocaStatus = mIf->check_MoCABootStatus(statusStr);
1823 #else
1824  check_AcsConnStatus = true;
1825 #endif
1826 
1827  if(mocaStatus == OK)
1828  {
1829  check_AcsConnStatus = true;
1830  }
1831 
1832  /**
1833  * Check for Gateway Connection State
1834  * 4. Connection successful
1835  * 5. Acquiring IP Address from Gateway(Not valid)
1836  */
1837 
1838  if(check_GatewayConnStatus)
1839  {
1840 
1841  if(get_GatewayConnStatus() == true)
1842  {
1843  memset(statusStr, '\0', TR69HOSTIFMGR_MAX_PARAM_LEN);
1844  rc=strcpy_s(statusStr,sizeof(statusStr), "Connection successful");
1845  if(rc!=EOK)
1846  {
1847  ERR_CHK(rc);
1848  }
1849  check_AcsConnStatus = true;
1850  }
1851  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] BootStatus: %s GatewayConnStatuss: %d\n", __FILE__, __FUNCTION__, statusStr, get_GatewayConnStatus());
1852  }
1853 
1854 
1855  /*
1856  *
1857  * */
1858  HOSTIF_MsgData_t stTR069SupportData = {0};
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);
1862 
1863  bool isTr69RfcEnabled = get_boolean(stTR069SupportData.paramValue);
1864 
1865  check_AcsConnStatus = (isTr69RfcEnabled)?true:false;
1866 
1867  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] %s: %d\n", __FUNCTION__, __LINE__, stTR069SupportData.paramName, isTr69RfcEnabled);
1868 
1869  /**
1870  * Check for ACS Connection State
1871  * 6. Contacting ACS
1872  */
1873 
1874  if(check_AcsConnStatus)
1875  {
1876  if(get_ACSStatus() == true)
1877  {
1878  memset(statusStr, '\0', TR69HOSTIFMGR_MAX_PARAM_LEN);
1879  rc=strcpy_s(statusStr,sizeof(statusStr), "Contacting ACS");
1880  if(rc!=EOK)
1881  {
1882  ERR_CHK(rc);
1883  }
1884  check_XreConnStatus = true;
1885  }
1886 // RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] BootStatus: %s gAcsConnStatus: %d\n", __FILE__, __FUNCTION__, statusBuf, get_ACSStatus());
1887  }
1888  else {
1889  check_XreConnStatus = true;
1890  }
1891 
1892  /**
1893  * Check for Xre Connection State
1894  * 6. XRE connection established - Successful
1895  */
1896 
1897 #ifdef USE_XRESRC
1898  if(get_Device_X_COMCAST_COM_Xcalibur_Client_XRE_ConnectionTable_xreConnStatus(stMsgData) == OK)
1899  {
1900  const char* xreConn = "XRE connection established - Successful";
1901  const char* xreConnAcs = "XRE connection established, ACS connection in progresss";
1902 
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)));
1906  }
1907  }
1908 #endif /*USE_XRESRC*/
1909 
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__);
1915  return OK;
1916 }
1917 
1918 /**
1919  * @brief This method gets the CPU temperature for doing general health check up
1920  * of the box.
1921  *
1922  * @param[out] stMsgData TR-069 Host interface message request.
1923  * @param[in] pChanged Status of the operation.
1924  *
1925  * @return Returns the status of the operation.
1926  *
1927  * @retval OK if it is successfully fetch data from the device.
1928  * @retval NOK if not able to fetch data from the device.
1929  * @ingroup TR69_HOSTIF_DEVICEINFO_API
1930  */
1932 {
1933  int cpuTemp = 0;
1934  float dsCpuTemp = device::Host::getInstance().getCPUTemperature();
1935  cpuTemp = (int)round(dsCpuTemp);
1936 
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);
1939 
1940  put_int(stMsgData->paramValue, cpuTemp);
1941  stMsgData->paramtype = hostIf_IntegerType;
1942  return OK;
1943 }
1944 
1946 {
1947  errno_t rc = -1;
1948  int ret = OK;
1949  char prefGatewayValue[GATEWAY_NAME_SIZE];
1950  FILE *fp;
1951  if((fp=fopen(PREFERRED_GATEWAY_FILE,"r"))==NULL)
1952  {
1953  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Unable to open file\n", __FUNCTION__);
1954  prefGatewayValue[0]='\0';
1955 
1956  }
1957  else
1958  {
1959  if(fgets(prefGatewayValue, GATEWAY_NAME_SIZE, fp) == NULL)
1960  {
1961  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]not able to read string from file \n", __FUNCTION__);
1962  prefGatewayValue[0]='\0';
1963  }
1964  fclose(fp);
1965  }
1966 
1967  strncpy(stMsgData->paramValue,prefGatewayValue,TR69HOSTIFMGR_MAX_PARAM_LEN );
1968  stMsgData->paramtype = hostIf_StringType;
1969  stMsgData->paramLen = strlen(stMsgData->paramValue);
1970  return ret;
1971 }
1972 
1974 {
1975  // @TODO
1976  put_boolean(stMsgData->paramValue, false);
1977  return OK;
1978 }
1979 
1981 {
1982  RDK_LOG (RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s]Entering...\n", __FUNCTION__);
1983 
1984  FILE *logUpfile = NULL;
1985  size_t n = 1024;
1986  char* curLogUploadStatus = (char*) malloc (n);
1987 
1988  if(curLogUploadStatus == NULL) //CID:88476 - Reverse_inull
1989  {
1990  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] curLogUploadStatus is Null\n", __FUNCTION__); //CID:84731 - Forward Null
1991  }
1992  else if ((logUpfile = fopen (CURRENT_LOG_UPLOAD_STATUS, "r")) == NULL)
1993  {
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);
1996  }
1997  else if (-1 == getline (&curLogUploadStatus, &n, logUpfile))
1998  {
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);
2001  fclose (logUpfile);
2002  }
2003  else
2004  {
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);
2007  fclose (logUpfile);
2008  }
2009 
2010  stMsgData->paramValue[0] = 0;
2011  strncat (stMsgData->paramValue, curLogUploadStatus, TR69HOSTIFMGR_MAX_PARAM_LEN - 1);
2012 
2013  if (curLogUploadStatus)
2014  free (curLogUploadStatus);
2015 
2016  stMsgData->paramtype = hostIf_StringType;
2017  stMsgData->paramLen = strlen (stMsgData->paramValue);
2018 
2019  RDK_LOG (RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s]Exiting...\n", __FUNCTION__);
2020 
2021  return OK;
2022 }
2023 
2024 int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_BootTime(HOSTIF_MsgData_t * stMsgData,bool *pChanged)
2025 {
2026  int ret = OK;
2027  static unsigned int bTime = 0;
2028  struct sysinfo sys_info;
2029  struct timeval currTime;
2030 
2031  if(!bTime)
2032  {
2033  if(sysinfo(&sys_info)) {
2034  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed in sysinfo due to \'%s\' (%d). \n", strerror(errno), errno);
2035  return NOK;
2036  }
2037 
2038  unsigned long upTime = sys_info.uptime;
2039 
2040  if(gettimeofday(&currTime, NULL)) {
2041  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed in sysinfo due to \'%s\' (%d). \n", strerror(errno), errno);
2042  return NOK;
2043  }
2044  bTime = (unsigned int)(currTime.tv_sec - upTime);
2045  }
2046 
2047  RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s]The Bootup Time is [%u].\n", __FUNCTION__, bTime);
2048  put_ulong(stMsgData->paramValue, bTime);
2049  stMsgData->paramtype = hostIf_UnsignedIntType;
2050  stMsgData->paramLen = sizeof(hostIf_UnsignedIntType);
2051  return ret;
2052 }
2053 
2054 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(HOSTIF_MsgData_t *stMsgData)
2055 {
2056  int ret = NOK;
2057  FILE *fp;
2058  if((fp=fopen(PREFERRED_GATEWAY_FILE,"w"))==NULL)
2059  {
2060  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Unable to open file\n", __FUNCTION__);
2061 
2062  }
2063  else
2064  {
2065  if(fputs(stMsgData->paramValue, fp) == EOF)
2066  {
2067  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]not able to read string from file \n", __FUNCTION__);
2068  }
2069  else
2070  {
2071  ret=OK;
2072  }
2073  fclose(fp);
2074 
2075  }
2076 
2077  return ret;
2078 }
2079 
2080 /**
2081  * @brief This is set X_COMCAST-COM_Reset as setting this parameter results in
2082  * the reset being performed on the device. The level of reset performed
2083  * is defined by the value that is written into this parameter.
2084  * Enumeration of:
2085  * Cold
2086  * Factory
2087  * Warehouse
2088  * Customer
2089  *
2090  * @param[out] stMsgData TR-069 Host interface message request.
2091  *
2092  * @return Returns the status of the operation.
2093  *
2094  * @retval OK if it is successfully fetch the data from device.
2095  * @retval ERR_INTERNAL_ERROR if not able to fetch the data from device.
2096  * @ingroup TR69_HOSTIF_DEVICEINFO_API
2097  */
2099 {
2100  int ret = NOK;
2101  char scriptbuff[100] = {'\0'};
2102  const char *val = stMsgData->paramValue;
2103  int rc;
2104  pthread_t reset_Thread;
2105  pthread_attr_t attr;
2106  pthread_attr_init(&attr);
2107  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
2108 
2109  if(val[0] == '\0')
2110  {
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__);
2113  return ret;
2114  }
2115  if (0 == strcasecmp(val,"Cold"))
2116  {
2117  setResetState(ColdReset);
2118  }
2119  else if (0 == strcasecmp(val,"Factory"))
2120  {
2121  setResetState(FactoryReset);
2122  }
2123  else if (0 == strcasecmp(val,"Warehouse"))
2124  {
2125  setResetState(WarehouseReset);
2126  }
2127  else if (0 == strcasecmp(val,"Customer"))
2128  {
2129  setResetState(CustomerReset);
2130  }
2131  else
2132  {
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);
2134  return NOT_HANDLED;
2135  }
2136 
2137  rc = pthread_create(&reset_Thread, &attr, ResetFunc, NULL);
2138  if (rc) {
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);
2141  }
2142 
2143  return OK;
2144 }
2145 
2146 /**
2147  * @brief This method resets according to the STB reset state such as NoReset, ColdReset
2148  * FactoryReset, WarehouseReset and CustomerReset.
2149  */
2150 void *ResetFunc( void *)
2151 {
2152  sleep(2);
2153  triggerResetScript();
2154  return NULL;
2155 
2156 }
2157 
2158 // Set 'm_xFirmwareDownloadUseCodebig' based on 'Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadUseCodebig' request
2159 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig(HOSTIF_MsgData_t *stMsgData)
2160 {
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);
2163  return OK;
2164 }
2165 
2166 // Set 'FW download Defer Reboot' based on 'Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadDeferReboot' request
2167 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(HOSTIF_MsgData_t *stMsgData)
2168 {
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);
2171  return OK;
2172 }
2173 
2174 /**
2175  * @brief This method set the firmware download file path which is present in
2176  * "/opt/fwdnldstatus.txt"
2177  *
2178  * @param[out] stMsgData TR-069 Host interface message request.
2179  *
2180  * @return Returns the status of the operation.
2181  *
2182  * @retval OK if it is successfully fetch the data from device.
2183  * @retval NOK if not able to fetch the data from device.
2184  * @ingroup TR69_HOSTIF_DEVICEINFO_API
2185  */
2187 {
2188 // int ret = NOK;
2189  m_xFirmwareToDownload = stMsgData->paramValue;
2190 // ret = writeFirmwareInfo((char *)"DnldFile",stMsgData);
2191  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s]Successfully set \"%s\" to \"%s\". \n", __FUNCTION__, stMsgData->paramName, m_xFirmwareToDownload.c_str() );
2192  return OK;
2193 }
2194 
2195 /**
2196  * @brief This method set the status of the firmware download which is present in
2197  * "/opt/fwdnldstatus.txt"
2198  *
2199  * @param[out] stMsgData TR-069 Host interface message request.
2200  *
2201  * @return Return the status of the operation.
2202  *
2203  * @retval OK if it is successfully fetch the data from device.
2204  * @retval NOK if not able to fetch the data from device.
2205  * @ingroup TR69_HOSTIF_DEVICEINFO_API
2206  */
2208 {
2209  int ret = NOK;
2210  writeFirmwareInfo((char *)"Status",stMsgData);
2211  return OK;
2212 }
2213 
2214 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol (HOSTIF_MsgData_t *stMsgData)
2215 {
2216 // int ret = NOK;
2217  m_xFirmwareDownloadProtocol = stMsgData->paramValue;
2218 // ret = writeFirmwareInfo((char *)"Proto",stMsgData);
2219  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s]Successfully set \"%s\" to \"%s\". \n", __FUNCTION__, stMsgData->paramName, m_xFirmwareDownloadProtocol.c_str() );
2220  return OK;
2221 }
2222 
2223 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL (HOSTIF_MsgData_t *stMsgData)
2224 {
2225 // int ret = NOK;
2226  m_xFirmwareDownloadURL = stMsgData->paramValue;
2227 // ret = writeFirmwareInfo((char *)"DnldURL",stMsgData);
2228  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s]Successfully set \"%s\" to \"%s\". \n", __FUNCTION__, stMsgData->paramName, m_xFirmwareDownloadURL.c_str() );
2229  return OK;
2230 }
2231 
2233 {
2234  bool triggerUploadLog = false;
2235  char syscommand[256] = {'\0'};
2236 
2237  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2238  triggerUploadLog = get_boolean(stMsgData->paramValue);
2239 
2240  if(triggerUploadLog)
2241  {
2242  /*@ TODO: Execute the script;*/
2243  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Start executing script to upload logs... \n",__FUNCTION__);
2244  sprintf(syscommand,"%s &", LOG_UPLOAD_SCR);
2245  system(syscommand);
2246  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Successfully executed %s. \n", syscommand);
2247  }
2248  else
2249  {
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 );
2252  return OK;
2253  }
2254  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2255  return OK;
2256 }
2257 
2259 {
2260  bool mocaLogEnabled = false;
2261 
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)
2266  {
2267  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] MoCA Telemetry Logging is %d \n",__FUNCTION__, mocaLogEnabled);
2268  }
2269  else
2270  {
2271  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] MoCA Telemetry Logging IARM FAILURE \n",__FUNCTION__);
2272  }
2273 #endif
2274  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2275  return OK;
2276 }
2277 
2278 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(HOSTIF_MsgData_t *stMsgData)
2279 {
2280  const char *status = getStringValue(stMsgData).c_str();
2281 
2282  if(0 == strcasecmp(status,"false"))
2283  {
2284 
2285  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] IPRemoteSupport disable request\n", __FUNCTION__);
2286  ifstream ifp(IPREMOTE_SUPPORT_STATUS_FILE);
2287  if(ifp.is_open())
2288  {
2289  if(remove(IPREMOTE_SUPPORT_STATUS_FILE) == 0)
2290  {
2291  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Removed File %s, IPRemoteSupport is disabled\n", __FUNCTION__, IPREMOTE_SUPPORT_STATUS_FILE);
2292  }
2293  }
2294 
2295  }
2296  else if(0 == strcasecmp(status,"true"))
2297  {
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);
2301  }
2302  else
2303  {
2304  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] Value not passed for the param, IPRemoteSupport Status unchanged \n", __FUNCTION__);
2305  }
2306 
2307  return OK;
2308 }
2309 
2310 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(HOSTIF_MsgData_t *stMsgData)
2311 {
2312  m_xrPollingAction = getStringValue(stMsgData);
2313  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] Setting XRPollingAction to %s\n", __FUNCTION__, m_xrPollingAction.c_str());
2314  return OK;
2315 }
2316 
2317 size_t static writeCurlResponse(void *ptr, size_t size, size_t nmemb, string stream)
2318 {
2319  size_t realsize = size * nmemb;
2320  string temp(static_cast<const char*>(ptr), realsize);
2321  stream.append(temp);
2322  return realsize;
2323 }
2324 
2326 {
2327  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2328  string n_PartnerId="";
2329  string current_PartnerId="";
2330  int ret = NOK;
2331 
2332  n_PartnerId=getStringValue(stMsgData); /* this is the value to set from RFC */
2333 
2334  if(n_PartnerId.empty())
2335  {
2336  RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] We received empty Buffer \n", __FUNCTION__);
2337  return NOK;
2338  }
2339 
2340  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Calling get_PartnerId_From_Script \n",__FUNCTION__);
2341 
2342  /* get the value from the script and see if they are different */
2343  ret = get_PartnerId_From_Script (current_PartnerId);
2344 
2345  //we get a valid partnerID after the curl.
2346  if( !current_PartnerId.empty() && ret == OK )
2347  {
2348  if( n_PartnerId.compare(current_PartnerId) )
2349  {
2350  CURL *curl = curl_easy_init();
2351  bool upload_flag = false;
2352  std::string postData;
2353  std::string tokenheader;
2354 
2355  if(curl)
2356  {
2357  /* We have different partner IDs
2358  * set the partnerId using setpartnerid() */
2359  long http_code = 0;
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());
2361 
2362  std::string sToken = get_security_token();
2363 
2364  tokenheader = "Authorization: Bearer " + sToken;
2365 
2366  postData = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.setPartnerId\", \"params\" : { \"partnerId\" : \"";
2367  postData += n_PartnerId;
2368  postData += "\"}}";
2369 
2370  struct curl_slist *list = NULL;
2371 
2372  list = curl_slist_append(list, tokenheader.c_str());
2373  list = curl_slist_append(list, "Content-Type: application/json");
2374 
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);
2380 
2381  CURLcode res = curl_easy_perform(curl);
2382 
2383  if ( res == CURLE_OK )
2384  {
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);
2387  }
2388 
2389  curl_easy_cleanup(curl);
2390  curl_slist_free_all(list);
2391 
2392  if( res == CURLE_OK && http_code == HTTP_OK )
2393  {
2394  upload_flag = true;
2395  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] PartnerID uploaded using Curl Success \n",__FUNCTION__);
2396  }
2397  else
2398  {
2399  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] curl returned with error : %d http response code: %ld\n",\
2400  __FUNCTION__, res, http_code);
2401  return NOK;
2402  }
2403  }
2404  else {
2405  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] curl init failed\n", __FUNCTION__);
2406  return NOK;
2407  }
2408 
2409  /* Reload the bootstrap config if CURLE_OK */
2410  int ret=NOK;
2411 
2412  if (upload_flag)
2413  {
2414  ret = m_bsStore->overrideValue(stMsgData);
2415  }
2416  if (ret == OK)
2417  {
2418  if ( !m_bsStore->call_loadJson() )
2419  {
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());
2422  return NOK;
2423  }
2424  }
2425  else
2426  {
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());
2429  return NOK;
2430  }
2431  }
2432  else
2433  {
2434  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] PartnerIDs are same. \n",__FUNCTION__);
2435  return OK;
2436  }
2437  }
2438  else
2439  {
2440  RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] We received empty Buffer \n", __FUNCTION__);
2441  return NOK;
2442  }
2443 
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__);
2447  return OK;
2448 }
2449 
2450 int static get_PartnerId_From_Script( string& current_PartnerId )
2451 {
2452  FILE *deviceIdScript = NULL;
2453  char scriptoutput[SCRIPT_OUTPUT_BUFFER_SIZE] = {0};
2454 
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);
2459  if (root)
2460  {
2461  cJSON* partnerID = cJSON_GetObjectItem(root, "partnerId");
2462  if (partnerID->type == cJSON_String && partnerID->valuestring && strlen(partnerID->valuestring) > 0)
2463  {
2464  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Found partnerID value = %s\n", partnerID->valuestring);
2465  current_PartnerId = partnerID->valuestring;
2466  }
2467  cJSON_Delete(root);
2468  }
2469  else
2470  {
2471  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error\n", __FUNCTION__);
2472  pclose(deviceIdScript);
2473  return NOK;
2474  }
2475  }
2476  }
2477  pclose(deviceIdScript);
2478  return OK;
2479 }
2480 
2481 
2482 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(HOSTIF_MsgData_t *stMsgData)
2483 {
2484  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2485  string current_PartnerId = "";
2486  int ret = NOK;
2487 
2488  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Calling get_PartnerId_From_Script \n",__FUNCTION__);
2489  ret = get_PartnerId_From_Script( current_PartnerId );
2490  /* we get a valid partnerID */
2491  if( !current_PartnerId.empty() && ret == OK )
2492  {
2493  stMsgData->paramLen = current_PartnerId.length();
2494  strncpy(stMsgData->paramValue, current_PartnerId.c_str(), stMsgData->paramLen);
2495  stMsgData->paramtype = hostIf_StringType;
2496  }
2497  else
2498  {
2499  RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] We received empty Buffer after curl \n", __FUNCTION__);
2500  return NOK;
2501  }
2502  return OK;
2503 }
2504 
2506 {
2507  unsigned int mocaLogDuration = 3600;
2508 
2509  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2510  mocaLogDuration = get_int(stMsgData->paramValue);
2511 
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)
2514  {
2515  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] MoCA Telemetry Logging Duration is %d \n",__FUNCTION__, mocaLogDuration);
2516  }
2517  else
2518  {
2519  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] MoCA Telemetry Logging Duration IARM FAILURE \n",__FUNCTION__);
2520  }
2521 #endif
2522  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2523  return OK;
2524 }
2526 {
2527  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2528  IARM_Result_t retVal = IARM_RESULT_SUCCESS;
2529  bool param;
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 *)&param, sizeof(param));
2533 
2534  if(retVal == IARM_RESULT_SUCCESS)
2535  {
2536  put_boolean(stMsgData->paramValue,param);
2537  stMsgData->paramtype = hostIf_BooleanType;
2538  stMsgData->paramLen=1;
2539  }
2540  else
2541  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s:%d] IARM Failed \n", __FUNCTION__, __FILE__, __LINE__);
2542 #endif
2543  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2544  return OK;
2545 }
2546 
2547 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(HOSTIF_MsgData_t *stMsgData, bool *pChanged)
2548 {
2549  const char *status = "false";
2550  ifstream ifp(IPREMOTE_SUPPORT_STATUS_FILE);
2551  if(ifp.is_open())
2552  {
2553  status="true";
2554  RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] %s exists, IpRemoteSupport Status is enabled\n", __FUNCTION__, IPREMOTE_SUPPORT_STATUS_FILE);
2555 
2556  }
2557  else
2558  {
2559  status="false";
2560  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] File not exists, IpRemoteSupport Status is Disabled\n", __FUNCTION__);
2561  }
2562 
2563  snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s", status);
2564  stMsgData->paramtype = hostIf_StringType;
2565  stMsgData->paramLen = strlen(stMsgData->paramValue);
2566 
2567  return OK;
2568 }
2569 
2570 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress(HOSTIF_MsgData_t *stMsgData)
2571 {
2572  string line;
2573  errno_t rc = -1;
2574  char ipAddress[100] = {'\0'};
2575  ifstream remoteInterface_file(IPREMOTE_INTERFACE_INFO);
2576  try
2577  {
2578  if (remoteInterface_file.is_open())
2579  {
2580  while ( getline (remoteInterface_file,line) )
2581  {
2582  if (line.find("Ipv4_Address") !=string::npos)
2583  {
2584  char *tmpStr = strstr((char *)line.c_str(), "=") ;
2585  tmpStr++;
2586  while(isspace(*tmpStr)) {
2587  tmpStr++;
2588  }
2589  rc=strcpy_s(ipAddress,sizeof(ipAddress), tmpStr);
2590  if(rc!=EOK)
2591  {
2592  ERR_CHK(rc);
2593  }
2594  }
2595  }
2596  remoteInterface_file.close();
2597  snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",ipAddress);
2598  }
2599  else
2600  {
2601  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] File not exists, IpRemoteInterface file open failed \n", __FUNCTION__);
2602 
2603  //values not populated so unknown.
2604  rc=strcpy_s(ipAddress,sizeof(ipAddress),"unknown");
2605  if(rc!=EOK)
2606  {
2607  ERR_CHK(rc);
2608  }
2609  snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",ipAddress);
2610  }
2611 
2612  stMsgData->paramtype = hostIf_StringType;
2613  stMsgData->paramLen = strlen(stMsgData->paramValue);
2614 
2615  return OK;
2616  }
2617  catch (const std::exception e) {
2618  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught. \n", __FUNCTION__);
2619  return NOK;
2620  }
2621 }
2622 
2623 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress(HOSTIF_MsgData_t *stMsgData)
2624 {
2625  string line;
2626  errno_t rc = -1;
2627  char macAddress[100] = {'\0'};
2628  ifstream remoteInterface_file(IPREMOTE_INTERFACE_INFO);
2629  try
2630  {
2631  if (remoteInterface_file.is_open())
2632  {
2633  while ( getline (remoteInterface_file,line) )
2634  {
2635  if (line.find("MAC_Address") !=string::npos)
2636  {
2637  char *tmpStr = strstr((char *)line.c_str(), "=") ;
2638  tmpStr++;
2639  while(isspace(*tmpStr)) {
2640  tmpStr++;
2641  }
2642  rc=strcpy_s(macAddress,sizeof(macAddress), tmpStr);
2643  if(rc!=EOK)
2644  {
2645  ERR_CHK(rc);
2646  }
2647  }
2648  }
2649  remoteInterface_file.close();
2650  snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",macAddress);
2651  }
2652  else
2653  {
2654  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] File not exists, IpRemoteInterface file open failed \n", __FUNCTION__);
2655 
2656  //values not populated so unknown.
2657  rc=strcpy_s(macAddress,sizeof(macAddress),"unknown");
2658  if(rc!=EOK)
2659  {
2660  ERR_CHK(rc);
2661  }
2662  snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",macAddress);
2663  }
2664 
2665  stMsgData->paramtype = hostIf_StringType;
2666  stMsgData->paramLen = strlen(stMsgData->paramValue);
2667 
2668  return OK;
2669  }
2670  catch (const std::exception e) {
2671  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught. \n", __FUNCTION__);
2672  return NOK;
2673  }
2674 }
2675 
2676 int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(HOSTIF_MsgData_t *stMsgData, bool *pChanged)
2677 {
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;
2681  stMsgData->paramLen = strlen(stMsgData->paramValue);
2682 
2683  if(pChanged && m_xrPollingAction != "0") {
2684  *pChanged = true;
2685  }
2686  return OK;
2687 }
2688 
2690 {
2691 
2692  IARM_Result_t retVal = IARM_RESULT_SUCCESS;
2693  unsigned int param;
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 *)&param, sizeof(param));
2698 
2699  if(retVal == IARM_RESULT_SUCCESS)
2700  {
2701  put_int(stMsgData->paramValue,param);
2702  stMsgData->paramtype = hostIf_UnsignedIntType;
2703  stMsgData->paramLen=4;
2704  }
2705  else
2706  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s:%d] IARM Failed \n", __FUNCTION__, __FILE__, __LINE__);
2707 #endif
2708  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2709  return OK;
2710 }
2711 
2712 // Check SHORTS RFC
2713 bool hostIf_DeviceInfo::isShortsEnabled()
2714 {
2715  HOSTIF_MsgData_t stRfcData = {0};
2716  strcpy(stRfcData.paramName, SHORTS_RFC_ENABLE);
2717 
2718  if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0))
2719  {
2720  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] SHORTS enabled: %s \n", __FUNCTION__, "True");
2721  return true;
2722  }
2723  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] SHORTS enabled: %s \n", __FUNCTION__, "False");
2724  return false;
2725 }
2726 
2727 // Find localhost port available in specified range for stunnel-client to listen
2728 int hostIf_DeviceInfo::findLocalPortAvailable()
2729 {
2730  struct sockaddr_in address;
2731  int sockfd = -1, status;
2732  int port = MIN_PORT_RANGE;
2733 
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);
2738 
2739  sockfd = socket(AF_INET, SOCK_STREAM, 0);
2740 
2741  status = connect(sockfd, (struct sockaddr *)&address, sizeof(address));
2742 
2743  if (status<0)
2744  {
2745  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Port %d is available.\n", __FUNCTION__, port);
2746  close(sockfd);
2747  return port;
2748  }
2749 
2750  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Port %d is in use.\n", __FUNCTION__, port);
2751  close(sockfd);
2752  port++;
2753  }
2754  return -1;
2755 }
2756 
2758 {
2759  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2760  string inputStr(stMsgData->paramValue);
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;
2764 
2765  if (trigger)
2766  {
2767 #ifdef __SINGLE_SESSION_ONLY__
2768  if (!isRsshactive())
2769  {
2770 #endif
2771  // Run stunnel client to establish stunnel.
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",
2775  __FUNCTION__,
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());
2788  } else {
2789 
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());
2793  }
2794 #ifdef __SINGLE_SESSION_ONLY__
2795  }
2796  else
2797  {
2798  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s] SSH Session is already active. Not starting again! \n",__FUNCTION__);
2799  return NOK;
2800  }
2801 #endif
2802  }
2803  else
2804  {
2805  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Stop SSH Tunnel \n",__FUNCTION__);
2806  string command = sshCommand + " stop ";
2807  system(command.c_str());
2808  }
2809  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2810  return OK;
2811 }
2812 
2814 {
2815  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2816 
2817  memset(stMsgData->paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
2818  stMsgData->paramtype = hostIf_StringType;
2819 
2820  if (reverseSSHArgs.empty())
2821  {
2822  strncpy(stMsgData->paramValue, "Not Set", TR69HOSTIFMGR_MAX_PARAM_LEN );
2823  }
2824  else
2825  {
2826  strncpy(stMsgData->paramValue, reverseSSHArgs.c_str(), sizeof(stMsgData->paramValue) -1); //CID:136563 - Buffer size warning
2827  stMsgData->paramValue[sizeof(stMsgData->paramValue) -1] = '\0';
2828  }
2829  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting ... \n",__FUNCTION__);
2830  return OK;
2831 }
2832 
2834 {
2835  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__);
2836  try
2837  {
2838  map<string,string> parsedMap;
2839  string inputStr(stMsgData->paramValue);
2840  std::size_t start = inputStr.find_first_not_of(";"), end = start;
2841  while (start != string::npos)
2842  {
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);
2848  }
2849  string parsedValues;
2850  for (auto &it : parsedMap)
2851  {
2852  parsedValues += "key = " + it.first + " value = " + it.second + ";";
2853  }
2854  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] parsed Values are : %s\n",__FUNCTION__,parsedValues.c_str());
2855 
2856  reverseSSHArgs = " -I " + parsedMap["idletimeout"] + " -f -N -y -T -R " + parsedMap["revsshport"] + ":";
2857  string estbip = getEstbIp();
2858  unsigned char buf[sizeof(struct in6_addr)];
2859  //Check if estbip is ipv6 address
2860  if (inet_pton(AF_INET6, estbip.c_str(), buf))
2861  {
2862  reverseSSHArgs += "[" + estbip + "]";
2863  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] SSH Tunnel estb ipv6 address is : %s\n",__FUNCTION__,estbip.c_str());
2864  }
2865  else
2866  {
2867  reverseSSHArgs += estbip;
2868  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] SSH Tunnel estb ipv4 address is : %s\n",__FUNCTION__,estbip.c_str());
2869  }
2870 
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__);
2876  return NOK;
2877  }
2878  reverseSSHArgs += string("localhost") + " -p " + localPort;
2879 
2880  // Arguments for stunnel script in the form " Local port + Remote FQDN + Stunnel port "
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"));
2890  } else {
2891  reverseSSHArgs += parsedMap["host"] + " -p " + parsedMap["sshport"];
2892  }
2893 
2894  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] String is : %s\n",__FUNCTION__,reverseSSHArgs.c_str());
2895 
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 == ']'));
2898  });
2899 
2900  if (it != reverseSSHArgs.end())
2901  {
2902  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Exception Accured... \n",__FUNCTION__);
2903  reverseSSHArgs = "";
2904  return NOK;
2905  }
2906 
2907  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] ReverseSSH Args = %s \n",__FUNCTION__,reverseSSHArgs.c_str());
2908 
2909  } catch (const std::exception e) {
2910  std::cout << __FUNCTION__ << "An exception occurred. " << e.what() << endl;
2911 
2912  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Exception Accured... \n",__FUNCTION__);
2913  reverseSSHArgs = "";
2914  return NOK;
2915  }
2916 
2917  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2918  return OK;
2919 }
2920 
2922 {
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;
2928 
2929  if (isRsshactive())
2930  {
2931  strncpy(stMsgData->paramValue, activeStr.c_str(), sizeof(stMsgData->paramValue) -1); //CID:136402 - Buffer size warning
2932  stMsgData->paramValue[sizeof(stMsgData->paramValue) -1] = '\0';
2933  }
2934  else
2935  {
2936  strncpy(stMsgData->paramValue, inActiveStr.c_str(), TR69HOSTIFMGR_MAX_PARAM_LEN );
2937  }
2938 
2939  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
2940  return OK;
2941 }
2942 
2943 static void Replace_AllOccurrence(char *str, int size, char ch, char Newch)
2944 {
2945  int i=0;
2946  for(i = 0; i<size-1; i++)
2947  {
2948  if(str[i] == ch || str[i] == '\r')
2949  {
2950  str[i] = Newch;
2951  }
2952  }
2953  str[i]='\0';
2954 }
2955 
2956 int hostIf_DeviceInfo::get_ApparmorBlockListStatus(HOSTIF_MsgData_t * stMsgData)
2957 {
2958  const char *apparmor_config = "/opt/secure/Apparmor_blocklist";
2959  const char *info_str = "Apparmorblocklist is empty";
2960  char *buf = NULL;
2961  FILE *fp = NULL;
2962  size_t len = 0;
2963  ssize_t read = 0;
2964  errno_t rc = -1;
2965 
2966  /* check the parameter name and return the corresponding value */
2967  fp = fopen(apparmor_config,"r");
2968  if(fp != NULL) {
2969  read = getdelim( &buf, &len, '\0', fp);
2970  if (read != -1) {
2971  rc = strcpy_s(stMsgData->paramValue, sizeof(stMsgData->paramValue), buf);
2972  if(rc!=EOK)
2973  {
2974  ERR_CHK(rc);
2975  }
2976  Replace_AllOccurrence(stMsgData->paramValue, strlen(stMsgData->paramValue), '\n', '#');
2977  }
2978  fclose(fp);
2979  return 0;
2980  }
2981  else {
2982  strncpy( stMsgData->paramValue,info_str,strlen(info_str));
2983  }
2984  return -1;
2985 }
2986 
2987 int hostIf_DeviceInfo::get_xOpsDeviceMgmtForwardSSHEnable(HOSTIF_MsgData_t * stMsgData)
2988 {
2989  LOG_ENTRY_EXIT;
2990  char ForwardSSH[10]="true";
2991  char *p = NULL;
2992  char dataToBeRead[50];
2993  FILE *fp;
2994 
2995  if((fp=fopen(FORWARD_SSH_FILE,"r"))==NULL)
2996  {
2997  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Unable to open file\n", __FUNCTION__);
2998  put_boolean(stMsgData->paramValue, true); //Default value
2999  return NOK;
3000  }
3001  else
3002  {
3003  while( fgets ( dataToBeRead, 50, fp ) != NULL )
3004  {
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"))
3009  {
3010  put_boolean(stMsgData->paramValue, false);
3011  }
3012  else
3013  {
3014  put_boolean(stMsgData->paramValue, true);
3015  }
3016  }
3017  }
3018 
3019  fclose(fp);
3020  return OK;
3021 }
3022 
3023 int hostIf_DeviceInfo::set_xOpsDeviceMgmtForwardSSHEnable(HOSTIF_MsgData_t * stMsgData)
3024 {
3025  errno_t rc = -1;
3026  LOG_ENTRY_EXIT;
3027  char ForwardSSH[10]="true"; //Default value
3028  FILE *fp;
3029 
3030  if((fp=fopen(FORWARD_SSH_FILE,"w"))==NULL)
3031  {
3032  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Unable to open file\n", __FUNCTION__);
3033  return NOK;
3034  }
3035  else
3036  {
3037  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Default Enable value:%s --> Parameter[%s]\n", __FUNCTION__, ForwardSSH, stMsgData->paramName);
3038  /*rc = strcpy_s(ForwardSSH, sizeof(ForwardSSH), get_boolean(stMsgData->paramValue) ? "true" : "false");
3039  if (rc != EOK)
3040  {
3041  ERR_CHK(rc);
3042  }*/
3043  if (get_boolean(stMsgData->paramValue))
3044  {
3045  rc=strcpy_s(ForwardSSH,sizeof(ForwardSSH),"true");
3046  if(rc!=EOK)
3047  {
3048  ERR_CHK(rc);
3049 
3050  }
3051  }
3052  else
3053  {
3054  rc=strcpy_s(ForwardSSH,sizeof(ForwardSSH),"false");
3055  if(rc!=EOK)
3056  {
3057  ERR_CHK(rc);
3058  }
3059  }
3060  fprintf(fp,"ForwardSSH=%s", ForwardSSH);
3061  }
3062  fclose(fp);
3063  return OK;
3064 }
3065 
3066 
3067 #ifdef USE_HWSELFTEST_PROFILE
3068 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_Enable(HOSTIF_MsgData_t *stMsgData)
3069 {
3070  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_Enable(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3071 }
3072 
3073 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_ExecuteTest(HOSTIF_MsgData_t *stMsgData)
3074 {
3075  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_ExecuteTest(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3076 }
3077 
3078 int hostIf_DeviceInfo::get_xOpsDeviceMgmt_hwHealthTest_Results(HOSTIF_MsgData_t *stMsgData)
3079 {
3080  return hwselftest::get_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_Results(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3081 }
3082 
3083 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_SetTuneType(HOSTIF_MsgData_t *stMsgData)
3084 {
3085  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_SetTuneType(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3086 }
3087 
3088 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_ExecuteTuneTest(HOSTIF_MsgData_t *stMsgData)
3089 {
3090  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_ExecuteTuneTest(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3091 }
3092 
3093 int hostIf_DeviceInfo::get_xOpsDeviceMgmt_hwHealthTestTune_TuneResults(HOSTIF_MsgData_t *stMsgData)
3094 {
3095  return hwselftest::get_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTestTune_TuneResults(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3096 }
3097 
3098 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_EnablePeriodicRun(HOSTIF_MsgData_t *stMsgData)
3099 {
3100  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_EnablePeriodicRun(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3101 }
3102 
3103 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_PeriodicRunFrequency(HOSTIF_MsgData_t *stMsgData)
3104 {
3105  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_PeriodicRunFrequency(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3106 }
3107 
3108 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_CpuThreshold(HOSTIF_MsgData_t *stMsgData)
3109 {
3110  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_CpuThreshold(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3111 }
3112 
3113 int hostIf_DeviceInfo::set_xOpsDeviceMgmt_hwHealthTest_DramThreshold(HOSTIF_MsgData_t *stMsgData)
3114 {
3115  return hwselftest::set_Device_DeviceInfo_xOpsDeviceMgmt_hwHealthTest_DramThreshold(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3116 }
3117 
3118 int hostIf_DeviceInfo::set_RFC_hwHealthTestWAN_WANEndPointURL(HOSTIF_MsgData_t *stMsgData)
3119 {
3120  return hwselftest::set_Device_DeviceInfo_RFC_hwHealthTestWAN_WANEndPointURL(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3121 }
3122 
3123 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_Enable(HOSTIF_MsgData_t *stMsgData)
3124 {
3125  return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_Enable(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3126 }
3127 
3128 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_QueueDepth(HOSTIF_MsgData_t *stMsgData)
3129 {
3130  return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_QueueDepth(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3131 }
3132 
3133 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_FilterParams(HOSTIF_MsgData_t *stMsgData)
3134 {
3135  return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_FilterParams(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3136 }
3137 
3138 int hostIf_DeviceInfo::set_xRDKCentralComRFC_hwHealthTest_ResultFilter_ResultsFiltered(HOSTIF_MsgData_t *stMsgData)
3139 {
3140  return hwselftest::set_Device_DeviceInfo_xRDKCentralComRFC_hwHealthTest_ResultFilter_ResultsFiltered(LOG_TR69HOSTIF, stMsgData)? OK : NOK;
3141 }
3142 #endif /* USE_HWSELFTEST_PROFILE */
3143 /*
3144  * * int hostIf_DeviceInfo::validate_ParamValue(HOSTIF_MsgData * sMsgData)
3145  * * in : stMsgData pointer
3146  * * out : int OK/NOK
3147  * * this method is used to validate the RFC param Values limits for SET
3148  * */
3149 int hostIf_DeviceInfo::validate_ParamValue(HOSTIF_MsgData_t * stMsgData)
3150 {
3151  int ret = OK;
3152  if (strcasecmp(stMsgData->paramName,TR069DOSLIMIT_THRESHOLD) == 0)
3153  {
3154  long int tmpVal;
3155  if(stMsgData->paramtype == hostIf_StringType )
3156  {
3157  tmpVal = strtol(stMsgData->paramValue,NULL,10);
3158  }
3159  else if(stMsgData->paramtype == hostIf_UnsignedIntType )
3160  {
3161  tmpVal = get_uint(stMsgData->paramValue);
3162  }
3163  else
3164  {
3165  ret = NOK;
3166  stMsgData->faultCode = fcInvalidParameterType;
3167  return ret;
3168  }
3169  if (tmpVal < MIN_TR69_DOS_THRESHOLD || tmpVal > MAX_TR69_DOS_THRESHOLD)
3170  {
3171  ret = NOK;
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;
3174  }
3175  }
3176  return ret;
3177 }
3178 
3179 int hostIf_DeviceInfo::set_xRDKCentralComBootstrap(HOSTIF_MsgData_t * stMsgData)
3180 {
3181  int ret = NOK;
3182  ret = m_bsStore->overrideValue(stMsgData);
3183  return ret;
3184 }
3185 
3186 static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr)
3187 {
3188  const char *apparmor_profiledir = "/etc/apparmor.d";
3189  struct dirent *entry=NULL;
3190  DIR *dir=NULL;
3191  char files_name[1024]= {0};
3192  char *token=NULL;
3193  char *subtoken=NULL;
3194  char *sub_string=NULL;
3195  char *sp=NULL;
3196  char *sptr=NULL;
3197  char tmp[64]= {0};
3198  char *arg=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");
3202  return FALSE;
3203  }
3204  entry = readdir(dir);
3205  memset(files_name,'\0',sizeof(files_name));
3206  /* storing Apparmor profile (file) names into files_name which can be used to check with input arguments using strstr() */
3207  while(entry != NULL) {
3208  strncat(files_name,entry->d_name,strlen(entry->d_name));
3209  entry = readdir(dir);
3210  }
3211  if (closedir(dir) != 0) {
3212  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Failed to close Apparmor Profile directory\n");
3213  return FALSE;
3214  }
3215  /* Read the input arguments and ensure the corresponding profiles exist or not by searching in
3216  Apparmor profile directory (/etc/apparmor.d/). Returns false if input does not have the
3217  apparmor profile, Returns true if apparmor profile finds for the input */
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);
3223  return FALSE;
3224  }
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);
3231  }
3232  else {
3233  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Invalid arguments %s error found in the parser\n", subtoken);
3234  return FALSE;
3235  }
3236  }
3237  token=strtok_r(NULL,"#",&sp);
3238  }
3239  return TRUE;
3240 }
3241 
3242 int hostIf_DeviceInfo::set_xRDKCentralComApparmorBlocklist(HOSTIF_MsgData_t *stMsgData)
3243 {
3244  const char *apparmor_config = "/opt/secure/Apparmor_blocklist";
3245  const char *apparmor_tmp_config = "/opt/secure/Apparmor_blocklist_bck.txt";
3246  FILE *fptr = NULL;
3247  FILE *tmp_fptr = NULL;
3248  char buf[128] = {0};
3249  char *token = NULL;
3250  char *sub_string = NULL;
3251  char *sp = NULL;
3252  char tmp[128] = {0};
3253  int ret=NOK;
3254 
3255  fptr = fopen(apparmor_config,"r");
3256  tmp_fptr = fopen(apparmor_tmp_config,"w+");
3257  if( (!stMsgData->paramValue) || (strlen(stMsgData->paramValue) == 0) ||(tmp_fptr == NULL)) {
3258  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Failed to open the file or invalid argument\n");
3259  return ret;
3260  }
3261  /* Traversing the Blocklist file and write the contents into tmp file expect the entry in Blocklist if it matches with input arguments */
3262  if(fptr != NULL ) {
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);
3267  if(token != NULL) {
3268  sub_string=strstr(stMsgData->paramValue, token);
3269  if(sub_string != NULL)
3270  continue;
3271  else
3272  fprintf(tmp_fptr,"%s\n",buf);
3273  }
3274  }
3275  }
3276 
3277  /* To ensure input arguments are valid or not */
3278  if (ValidateInput_Arguments(stMsgData->paramValue, tmp_fptr) != TRUE) {
3279  if(fptr != NULL)
3280  fclose(fptr);
3281  if (tmp_fptr!= NULL)
3282  fclose(tmp_fptr);
3283  return ret;
3284  }
3285  /* Copying tmp file contents into main file by using rename() */
3286  if(fptr != NULL)
3287  fclose(fptr);
3288  fclose(tmp_fptr);
3289  if(rename( apparmor_tmp_config, apparmor_config) != 0) {
3290  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Error in renaming file\n");
3291  return ret;
3292  }
3293  ret=OK;
3294  return ret;
3295 }
3296 
3297 int hostIf_DeviceInfo::set_xRDKCentralComRFC(HOSTIF_MsgData_t * stMsgData)
3298 {
3299  int ret = NOK;
3300  int validate_paramVal;
3301 
3302  // any additional immediate handling
3303  if (strcasecmp(stMsgData->paramName,TR181_RFC_RESET_DATA_START) == 0) // used to clear out all data from storage
3304  {
3305 #ifndef NEW_HTTP_SERVER_DISABLE
3306  if(!legacyRFCEnabled())
3307  {
3308  string stringValue = getStringValue(stMsgData);
3309  if(!strcasecmp(stringValue.c_str(), "true") || !strcmp(stringValue.c_str(), "1"))
3310  {
3311  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Calling clearAll in New RFC Store I/O\n",__FUNCTION__);
3312  m_rfcStore->clearAll();
3313  ret = OK;
3314  stMsgData->faultCode = fcNoFault;
3315  }
3316  else
3317  {
3318  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Invalid Value : Only true is allowed\n",__FUNCTION__);
3319  stMsgData->faultCode = fcInternalError;
3320  }
3321  }
3322  else
3323  {
3324  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Calling clearAll in Old RFC Storage I/O\n",__FUNCTION__);
3325  m_rfcStorage.clearAll();
3326  }
3327 #else
3328  m_rfcStorage.clearAll();
3329 #endif
3330  }
3331  else if(strcasecmp(stMsgData->paramName, TR181_RFC_RESET_DATA_END) == 0)
3332  {
3333 #ifndef NEW_HTTP_SERVER_DISABLE
3334  if(!legacyRFCEnabled())
3335  {
3336  string stringValue = getStringValue(stMsgData);
3337  if(!strcasecmp(stringValue.c_str(), "true") || !strcmp(stringValue.c_str(), "1"))
3338  {
3339  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Calling reloadCache in New RFC Store I/O\n",__FUNCTION__);
3340  m_rfcStore->reloadCache();
3341  ret = OK;
3342  stMsgData->faultCode = fcNoFault;
3343  }
3344  else
3345  {
3346  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Invalid Value : Only true is allowed\n",__FUNCTION__);
3347  stMsgData->faultCode = fcInternalError;
3348  }
3349  }
3350 #endif
3351  }
3352  else
3353  {
3354  validate_paramVal = validate_ParamValue(stMsgData);
3355  if(validate_paramVal == OK)
3356  {
3357 #ifndef NEW_HTTP_SERVER_DISABLE
3358  if(!legacyRFCEnabled())
3359  {
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);
3362  }
3363  else
3364  {
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);
3367  }
3368 #else
3369  ret = m_rfcStorage.setValue(stMsgData);
3370 #endif
3371  }
3372  else
3373  {
3374  ret = NOK;
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);
3377  }
3378  }
3379 
3380  if (strcasecmp(stMsgData->paramName,RFC_WL_ROAM_TRIGGER_RF) == 0)
3381  {
3382  ret = set_xRDKCentralComRFCRoamTrigger(stMsgData);
3383  }
3384  else if (strcasecmp(stMsgData->paramName,MS12_DAPV2_RFC_ENABLE) == 0)
3385  {
3386  bool enable = get_boolean(stMsgData->paramValue);
3387  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] MS12->DAPV2 RFC status:%d\n",__FUNCTION__, enable);
3388  if(enable)
3389  {
3390  device::Host::getInstance().getAudioOutputPort("HDMI0").enableMS12Config(dsMS12FEATURE_DAPV2,1);
3391  }
3392  else
3393  {
3394  device::Host::getInstance().getAudioOutputPort("HDMI0").enableMS12Config(dsMS12FEATURE_DAPV2,0);
3395  }
3396  }
3397  else if (strcasecmp(stMsgData->paramName,MS12_DE_RFC_ENABLE) == 0)
3398  {
3399  bool enable = get_boolean(stMsgData->paramValue);
3400  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] MS12->DE RFC status:%d\n",__FUNCTION__, enable);
3401  if(enable)
3402  {
3403  device::Host::getInstance().getAudioOutputPort("HDMI0").enableMS12Config(dsMS12FEATURE_DE,1);
3404  }
3405  else
3406  {
3407  device::Host::getInstance().getAudioOutputPort("HDMI0").enableMS12Config(dsMS12FEATURE_DE,0);
3408  }
3409  }
3410  else if (strcasecmp(stMsgData->paramName,LE_RFC_ENABLE) == 0)
3411  {
3412  ret = set_xRDKCentralComRFCLoudnessEquivalenceEnable(stMsgData);
3413  }
3414  else if (strcasecmp(stMsgData->paramName,HDR_RFC_ENABLE) == 0)
3415  {
3416  ret = set_xRDKCentralComHdrRFCEnable(stMsgData);
3417  }
3418  else if (strcasecmp(stMsgData->paramName,UHD_RFC_ENABLE) == 0)
3419  {
3420  ret = set_xRDKCentralComUhdRFCEnable(stMsgData);
3421  }
3422  else if (strcasecmp(stMsgData->paramName,XRE_CONTAINER_RFC_ENABLE) == 0)
3423  {
3424  ret = set_xRDKCentralComXREContainerRFCEnable(stMsgData);
3425  }
3426  else if (strcasecmp(stMsgData->paramName,RFC_CTL_RETRIEVE_NOW) == 0)
3427  {
3428  ret = set_xRDKCentralComRFCRetrieveNow(stMsgData);
3429  }
3430  else if (strcasecmp(stMsgData->paramName,APPARMOR_BLOCKLIST_PROCESS) == 0)
3431  {
3432  ret = set_xRDKCentralComApparmorBlocklist(stMsgData);
3433  }
3434 #ifdef USE_REMOTE_DEBUGGER
3435  else if (strcasecmp(stMsgData->paramName,RDK_REMOTE_DEBUGGER_ISSUETYPE) == 0)
3436  {
3437  ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(stMsgData);
3438  }
3439 #endif
3440 #ifdef ENABLE_LLAMA_PLATCO
3441  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.VideoTelemetry.FrequncyMinutes"))
3442  {
3443  ret = set_xRDKCentralComRFCVideoTelFreq(stMsgData);
3444  }
3445 #endif
3446  else if (!strcasecmp(stMsgData->paramName,TR181_AUTOREBOOT_ENABLE) )
3447  {
3448  ret = set_xRDKCentralComRFCAutoRebootEnable(stMsgData);
3449  }
3450  else if (!strcasecmp(stMsgData->paramName,"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.newNTP.Enable") )
3451  {
3452  ret = set_xRDKCentralComNewNtpEnable(stMsgData);
3453  }
3454 #ifdef USE_HWSELFTEST_PROFILE
3455  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.Enable"))
3456  {
3457  ret = set_xOpsDeviceMgmt_hwHealthTest_Enable(stMsgData);
3458  }
3459  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.EnablePeriodicRun"))
3460  {
3461  ret = set_xOpsDeviceMgmt_hwHealthTest_EnablePeriodicRun(stMsgData);
3462  }
3463  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.PeriodicRunFrequency"))
3464  {
3465  ret = set_xOpsDeviceMgmt_hwHealthTest_PeriodicRunFrequency(stMsgData);
3466  }
3467  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.cpuThreshold"))
3468  {
3469  ret = set_xOpsDeviceMgmt_hwHealthTest_CpuThreshold(stMsgData);
3470  }
3471  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.dramThreshold"))
3472  {
3473  ret = set_xOpsDeviceMgmt_hwHealthTest_DramThreshold(stMsgData);
3474  }
3475  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTestWAN.WANTestEndPointURL"))
3476  {
3477  ret = set_RFC_hwHealthTestWAN_WANEndPointURL(stMsgData);
3478  }
3479  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.Enable"))
3480  {
3481  ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_Enable(stMsgData);
3482  }
3483  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.QueueDepth"))
3484  {
3485  ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_QueueDepth(stMsgData);
3486  }
3487  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.FilterParams"))
3488  {
3489  ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_FilterParams(stMsgData);
3490  }
3491  else if (!strcasecmp(stMsgData->paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.hwHealthTest.ResultFilter.ResultsFiltered"))
3492  {
3493  ret = set_xRDKCentralComRFC_hwHealthTest_ResultFilter_ResultsFiltered(stMsgData);
3494  }
3495 #endif /* USE_HWSELFTEST_PROFILE */
3496  return ret;
3497 }
3498 
3499 int hostIf_DeviceInfo::set_xRDKCentralComNewNtpEnable(HOSTIF_MsgData_t *stMsgData)
3500 {
3501  int ret = NOK;
3502  bool enable;
3503  LOG_ENTRY_EXIT;
3504  if(stMsgData->paramtype == hostIf_BooleanType)
3505  {
3506  enable = get_boolean(stMsgData->paramValue);
3507  if( enable )
3508  {
3509  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] set newNTP enable to true\n", __FUNCTION__);
3510  ofstream ofp(NTPENABLED_FILE);
3511  ret = OK;
3512  }
3513  else
3514  {
3515  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] set newNTP.Enable to false\n", __FUNCTION__);
3516  ifstream ifp(NTPENABLED_FILE);
3517  if(ifp.is_open())
3518  {
3519  if(remove(NTPENABLED_FILE) == 0)
3520  {
3521  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Removed File %s, newNTP is disabled\n", __FUNCTION__, NTPENABLED_FILE);
3522  ret = OK;
3523  }
3524  else
3525  {
3526  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Unable to remove File %s, newNTP.Enable is unchanged\n", __FUNCTION__, NTPENABLED_FILE);
3527  }
3528  }
3529  else
3530  {
3531  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] File %s is already removed, newNTP is disabled already\n", __FUNCTION__, NTPENABLED_FILE);
3532  ret = OK;
3533  }
3534  }
3535  }
3536  else
3537  {
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);
3539  }
3540  return ret;
3541 }
3542 
3543 int hostIf_DeviceInfo::get_xRDKCentralComBootstrap(HOSTIF_MsgData_t *stMsgData)
3544 {
3545  return m_bsStore->getValue(stMsgData);
3546 }
3547 
3548 int hostIf_DeviceInfo::get_xRDKCentralComRFC(HOSTIF_MsgData_t *stMsgData)
3549 {
3550  int ret=NOK;
3551 #ifndef NEW_HTTP_SERVER_DISABLE
3552  if(!legacyRFCEnabled())
3553  {
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);
3556  }
3557  else
3558  {
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);
3561  }
3562 #else
3563  ret=m_rfcStorage.getValue(stMsgData);
3564 #endif
3565 
3566  if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID") == 0 && (strlen(stMsgData->paramValue) == 0 || strcasecmp(stMsgData->paramValue,"unknown") == 0))
3567  {
3568  if ((ret = get_xRDKCentralComRFCAccountId(stMsgData)) == OK)
3569  {
3570  // Store the value from authservice into the db so we don't get here again
3571  m_rfcStorage.setValue(stMsgData);
3572  }
3573  }
3574 
3575  return ret;
3576 }
3577 
3578 int hostIf_DeviceInfo::get_xRDKCentralComRFCAccountId(HOSTIF_MsgData_t *stMsgData)
3579 {
3580  int ret=NOK;
3581  string response;
3582  std::string postData;
3583  std::string tokenheader;
3584  CURL *curl = curl_easy_init();
3585  if(curl)
3586  {
3587  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: call curl to get Account ID..\n", __FUNCTION__);
3588 
3589  std::string sToken = get_security_token();
3590  tokenheader = "Authorization: Bearer " + sToken;
3591 
3592  postData = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.getServiceAccountId\" }";
3593 
3594  struct curl_slist *list = NULL;
3595 
3596  list = curl_slist_append(list, tokenheader.c_str());
3597  list = curl_slist_append(list, "Content-Type: application/json");
3598 
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);
3605 
3606  CURLcode res = curl_easy_perform(curl);
3607  long http_code = 0;
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);
3612 
3613  if(res == CURLE_OK)
3614  {
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());
3617  if(root)
3618  {
3619  cJSON* jsonObj = cJSON_GetObjectItem(root, "result");
3620 
3621  if (jsonObj)
3622  {
3623  cJSON *accountIdObj = cJSON_GetObjectItem(jsonObj, "serviceAccountId");
3624 
3625  if (accountIdObj && accountIdObj->type == cJSON_String && accountIdObj->valuestring && strlen(accountIdObj->valuestring) > 0)
3626  {
3627  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Found serviceAccountId value = %s\n", accountIdObj->valuestring);
3628  putValue(stMsgData, accountIdObj->valuestring);
3629  stMsgData->faultCode = fcNoFault;
3630  ret = OK;
3631  }
3632  else
3633  {
3634  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"serviceAccountId\" in the output from Thunder plugin\n", __FUNCTION__);
3635  cJSON_Delete(root);
3636  return NOK;
3637  }
3638  }
3639  else
3640  {
3641  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__);
3642  cJSON_Delete(root);
3643  return NOK;
3644  }
3645  cJSON_Delete(root);
3646  }
3647  else
3648  {
3649  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: json parse error\n", __FUNCTION__);
3650  }
3651  }
3652  }
3653  else
3654  {
3655  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: curl init failed\n", __FUNCTION__);
3656  }
3657  return ret;
3658 }
3659 
3660 #ifdef USE_REMOTE_DEBUGGER
3661 int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType (HOSTIF_MsgData_t *stMsgData)
3662 {
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);
3665 
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)
3670  {
3671  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] SUCCESS: RDK Remote Debugger IARM BroadcastEvent %s \n",__FUNCTION__);
3672  }
3673  else
3674  {
3675  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] FAILED: RDK Remote Debugger IARM BroadcastEvent \n",__FUNCTION__);
3676  }
3677  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__);
3678 
3679  return OK;
3680 }
3681 #endif
3682 
3683 int hostIf_DeviceInfo::set_xRDKCentralComRFCAutoRebootEnable(HOSTIF_MsgData_t *stMsgData)
3684 {
3685  bool enableStatus = false;
3686  int ret = OK;
3687  int l_uptime = 0;
3688  bool bValue = false;
3689 
3690  if(stMsgData->paramtype == hostIf_BooleanType)
3691  {
3692  enableStatus=get_boolean(stMsgData->paramValue);
3693 
3694  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] %s: %s\n", __FUNCTION__, __LINE__ \
3695  ,stMsgData->paramName, (enableStatus)? "true":"false");
3696 
3697  /* Call Schedule Auto Reboot */
3698  ret = ScheduleAutoReboot(enableStatus);
3699  if ( NOK == ret )
3700  {
3701  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s] ScheduleAutoReboot Failed \n", __FUNCTION__);
3702  }
3703  }
3704  else
3705  {
3706  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] Value Incorrect, Auto Reboot Enable status unchanged \n" \
3707  , __FUNCTION__);
3708  ret=NOK;
3709  }
3710 
3711  return ret;
3712 }
3713 
3714 int hostIf_DeviceInfo::ScheduleAutoReboot(bool bValue)
3715 {
3716  int ret = OK;
3717  char cmd[100] = {'\0'};
3718 
3719 
3720  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] bValue = %s\n" \
3721  , __FUNCTION__, __LINE__, bValue? "true" : "false" );
3722 
3723  /* Call the script for scheduling
3724  * cron args with Reboot day and bValue */
3725  snprintf(cmd,sizeof(cmd),"sh /lib/rdk/ScheduleAutoReboot.sh %d &", bValue);
3726 #ifdef YOCTO_BUILD
3727  v_secure_system("sh /lib/rdk/ScheduleAutoReboot.sh %d &", bValue);
3728 #else
3729  system(cmd);
3730 #endif
3731  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Successfully executed \"%s\". \n", __FUNCTION__, __LINE__, cmd);
3732  ret = OK;
3733  return ret;
3734 }
3735 
3736 int hostIf_DeviceInfo::set_xRDKCentralComRFCRoamTrigger(HOSTIF_MsgData_t *stMsgData)
3737 {
3738  int ret = NOK;
3739  LOG_ENTRY_EXIT;
3740  //if(stMsgData->paramtype)
3741  {
3742  char execBuf[100] = {'\0'};
3743  sprintf(execBuf, "wl roam_trigger %s &", stMsgData->paramValue);
3744 #ifdef YOCTO_BUILD
3745  v_secure_system("wl roam_trigger %s &", stMsgData->paramValue);
3746 #else
3747  system(execBuf);
3748 #endif
3749  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Successfully executed \"%s\" with \"%s\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, execBuf);
3750  ret = OK;
3751  }
3752  system("wl roam_trigger &");
3753  return ret;
3754 }
3755 
3756 int hostIf_DeviceInfo::set_xRDKCentralComRFCLoudnessEquivalenceEnable(HOSTIF_MsgData_t *stMsgData)
3757 {
3758  int ret = NOK;
3759  bool enable = false;
3760  dsError_t status = dsERR_GENERAL;
3761 
3762  if(stMsgData->paramtype == hostIf_BooleanType)
3763  {
3764  enable = get_boolean(stMsgData->paramValue);
3765  try
3766  {
3767  //set the value TRUE/FALSE.
3768  status = device::Host::getInstance().getAudioOutputPort("HDMI0").enableLEConfig((enable)?1:0);
3769  }
3770  catch (const std::exception e)
3771  {
3772  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception %s.\n", e.what());
3773  }
3774 
3775  if(status != dsERR_NONE)
3776  {
3777  /* We return NOK and log for all failed/unsupported calls. */
3778  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] enableLEConfig failed/unsupported \n",__FUNCTION__);
3779  ret = NOK;
3780  }
3781  else
3782  {
3783  ret = OK;
3784  }
3785  }
3786  else
3787  {
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;
3791  }
3792  return ret;
3793 }
3794 
3795 int hostIf_DeviceInfo::set_xRDKCentralComHdrRFCEnable(HOSTIF_MsgData_t *stMsgData)
3796 {
3797  int ret = NOK;
3798  bool enable = false;
3799  LOG_ENTRY_EXIT;
3800  if(stMsgData->paramtype == hostIf_BooleanType)
3801  {
3802  enable = get_boolean(stMsgData->paramValue);
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);
3806  ret = OK;
3807  }
3808  else
3809  {
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;
3812  }
3813 
3814  return ret;
3815 }
3816 
3817 int hostIf_DeviceInfo::set_xRDKCentralComXREContainerRFCEnable(HOSTIF_MsgData_t *stMsgData)
3818 {
3819  int ret = NOK;
3820  bool enable;
3821  LOG_ENTRY_EXIT;
3822  if(stMsgData->paramtype == hostIf_BooleanType)
3823  {
3824  enable = get_boolean(stMsgData->paramValue);
3825  if( enable )
3826  {
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);
3830  ret = OK;
3831  }
3832  else
3833  {
3834  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] XRE_ContainerSupport disable request\n", __FUNCTION__);
3835  ifstream ifp(XRE_CONTAINER_SUPPORT_STATUS_FILE);
3836  if(ifp.is_open())
3837  {
3838  if(remove(XRE_CONTAINER_SUPPORT_STATUS_FILE) == 0)
3839  {
3840  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Removed File %s, XRE_ContainerSupport is disabled\n", __FUNCTION__, XRE_CONTAINER_SUPPORT_STATUS_FILE);
3841  ret = OK;
3842  }
3843  else
3844  {
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);
3846  }
3847  }
3848  else
3849  {
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);
3851  ret = OK;
3852  }
3853  }
3854  }
3855  else
3856  {
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);
3858  }
3859  return ret;
3860 }
3861 
3862 int hostIf_DeviceInfo::set_xRDKCentralComUhdRFCEnable(HOSTIF_MsgData_t *stMsgData)
3863 {
3864  int ret = NOK;
3865  bool enable = false;
3866  LOG_ENTRY_EXIT;
3867  if(stMsgData->paramtype == hostIf_BooleanType)
3868  {
3869  enable = get_boolean(stMsgData->paramValue);
3870  std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName();
3871  device::Host::getInstance().getVideoOutputPort(strVideoPort.c_str()).forceDisable4KSupport(!enable);
3872  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, enable);
3873  ret = OK;
3874  }
3875  else
3876  {
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;
3879  }
3880 
3881  return ret;
3882 }
3883 
3884 // Handle RFC RetrieveNow
3885 int hostIf_DeviceInfo::set_xRDKCentralComRFCRetrieveNow(HOSTIF_MsgData_t *stMsgData)
3886 {
3887  int ret = NOK;
3888  struct timeval currTime;
3889  char cmd[100] = {'\0'};
3890 
3891  LOG_ENTRY_EXIT;
3892 
3893  sprintf(cmd, "sh /lib/rdk/RFCbase.sh &");
3894  system (cmd);
3895  ret = OK;
3896  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Successfully executed \"%s\" with \"%s\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, cmd);
3897  // log the last RFC request
3898  if(gettimeofday(&currTime, NULL))
3899  {
3900  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed in sysinfo due to \'%s\' (%d). \n", strerror(errno), errno);
3901  }
3902  else
3903  {
3904  put_ulong(stMsgData->paramValue, (unsigned int)currTime.tv_sec);
3905  stMsgData->paramtype = hostIf_UnsignedIntType;
3906  stMsgData->paramLen = sizeof(hostIf_UnsignedIntType);
3907  // set the time in Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.RetrieveNow parameter
3908 #ifndef NEW_HTTP_SERVER_DISABLE
3909  ret = m_rfcStore->setValue(stMsgData);
3910 #else
3911  ret = m_rfcStorage.setValue(stMsgData);
3912 #endif
3913  }
3914 
3915  return ret;
3916 }
3917 
3918 #ifdef ENABLE_LLAMA_PLATCO
3919 int hostIf_DeviceInfo::set_xRDKCentralComRFCVideoTelFreq(HOSTIF_MsgData_t *stMsgData)
3920 {
3921  int ret = NOK;
3922  unsigned int tmpVal = 0;
3923  char execBuf[100] = {'\0'};
3924  if (stMsgData->paramtype == hostIf_UnsignedIntType)
3925  {
3926  tmpVal = get_uint(stMsgData->paramValue);
3927  if (tmpVal > 0 && tmpVal <=60)
3928  {
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);
3932  ret = OK;
3933  }
3934  else
3935  {
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__);
3937  }
3938  }
3939  return ret;
3940 }
3941 #endif
3942 int get_ParamValue_From_TR69Agent(HOSTIF_MsgData_t * stMsgData)
3943 {
3944  int ret = OK;
3945  FILE *fp;
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");
3948 
3949  char result[50] = {'\0'};
3950  char buf[50] = {'\0'};
3951  static bool bCalled = false;
3952 
3953  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] CMD : [ %s ] \n",__FUNCTION__, cmd);
3954 
3955 #ifdef YOCTO_BUILD
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);
3957 #else
3958  fp = popen(cmd,"r");
3959 #endif
3960 
3961  if(fp == NULL)
3962  {
3963  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "Error popen : Not able to read through host-if from TR69 agent.\n");
3964  return -1;
3965  }
3966 
3967  if(fgets(buf,50,fp) != NULL)
3968  {
3969  sscanf(buf,"%s", result);
3970  }
3971 
3972  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] result %s buf %s Reset. \n",__FUNCTION__, result, buf);
3973 
3974 #ifdef YOCTO_BUILD
3975  v_secure_pclose(fp);
3976 #else
3977  pclose(fp);
3978 #endif
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);
3983 
3984  return ret;
3985 }
3986 
3987 /**
3988  * @brief This method read the firmware information which is present in
3989  * "/opt/fwdnldstatus.txt"
3990  *
3991  * @param[in] param Firmware name string.
3992  * @param[out] stMsgData TR-069 Host interface message request.
3993  *
3994  * @return Returns the status of the operation.
3995  *
3996  * @retval OK if it is successfully fetch the data from device.
3997  * @retval NOK if not able to fetch the data from device.
3998  * @ingroup TR69_HOSTIF_DEVICEINFO_API
3999  */
4001 {
4002  int ret = NOK;
4003  errno_t rc = -1;
4004  string line;
4005  ifstream fwDwnfile(FW_DWN_FILE_PATH);
4006 
4007  try {
4008  if (fwDwnfile.is_open()) {
4009  while ( getline (fwDwnfile,line) ) {
4010  if (string::npos != findIgnoreCase (line, param))
4011  break;
4012  }
4013  fwDwnfile.close();
4014  } else {
4015  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Unable to open file\n", __FUNCTION__);
4016  return NOK;
4017  }
4018 
4019  char *cstr = new char [line.length()+1];
4020  if (NULL == cstr) {
4021  return NOK;
4022  }
4023 
4024  if (0 == line.length()) {
4025  delete[] cstr;
4026  return NOK;
4027  }
4028 
4029  rc=strcpy_s (cstr,(line.length()+1), line.c_str());
4030  if(rc!=EOK)
4031  {
4032  ERR_CHK(rc);
4033  }
4034  char * pch = NULL;
4035  pch = strstr (cstr,"|");
4036  if (pch == NULL) {
4037  delete[] cstr;
4038  return NOK;
4039  }
4040  pch++;
4041  while(isspace(*pch)) {
4042  pch++;
4043  }
4044  memset(stMsgData->paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
4045  strncpy(stMsgData->paramValue, pch, sizeof(stMsgData->paramValue) -1); //CID:136525 - Buffer size warning
4046  stMsgData->paramValue[sizeof(stMsgData->paramValue) -1] = '\0';
4047  stMsgData->paramtype = hostIf_StringType;
4048  stMsgData->paramLen = strlen(pch);
4049  delete[] cstr;
4050 
4051  } catch (const std::exception e) {
4052  std::cout << __FUNCTION__ << "An exception occurred. " << e.what() << endl;
4053  }
4054  return (ret = OK);
4055 }
4056 
4057 /**
4058  * @brief This method writes the firmware information which is present in
4059  * "/opt/fwdnldstatus.txt"
4060  *
4061  * @param[in] param Firmware name string.
4062  * @param[out] stMsgData TR-069 Host interface message request.
4063  *
4064  * @return Returns the status of the operation.
4065  *
4066  * @retval OK if it is successfully fetch the data from device.
4067  * @retval NOK if not able to fetch the data from device.
4068  * @ingroup TR69_HOSTIF_DEVICEINFO_API
4069  */
4071 {
4072  int ret = NOK;
4073  string line;
4074  ifstream infwDwnfile(FW_DWN_FILE_PATH);
4075  try {
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);
4078  return NOK;
4079  }
4080  else
4081  {
4082  ofstream tmpfwDwnfile(TEMP_FW_DWN_FILE_PATH);
4083  while ( getline (infwDwnfile,line) )
4084  {
4085  if(line.find("Method") != string::npos) {
4086  string tmpline = "Method|tr69";
4087  tmpfwDwnfile << tmpline << "\n";
4088  }
4089  else if (line.find(param)!=string::npos) {
4090  string tmpline = string(param);
4091  tmpline = tmpline + "|" + stMsgData->paramValue;
4092  tmpfwDwnfile << tmpline << "\n";;
4093  }
4094  else {
4095  tmpfwDwnfile << line << "\n";;
4096  }
4097  }
4098  infwDwnfile.close();
4099  tmpfwDwnfile.close();
4100  }
4101  //CID:90007 , 82197-Checked return
4102  if((remove(FW_DWN_FILE_PATH) == 0) && (rename(TEMP_FW_DWN_FILE_PATH, FW_DWN_FILE_PATH) == 0))
4103  {
4104  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] File removed from the path , Temp file is set \n", __FUNCTION__);
4105  }
4106 
4107  } catch (const std::exception e) {
4108  std::cout << __FUNCTION__ << "An exception occurred. " << e.what() << endl;
4109  }
4110  return (ret = OK);
4111 }
4112 
4113 
4114 int hostIf_DeviceInfo::set_xFirmwareDownloadNow(HOSTIF_MsgData_t *stMsgData)
4115 {
4116  int ret = NOK;
4117  const char *userTriggerDwScr = "/lib/rdk/userInitiatedFWDnld.sh";
4118 
4119  LOG_ENTRY_EXIT;
4120 
4121  if(stMsgData->paramtype == hostIf_BooleanType)
4122  {
4123  bool xDwnldTrigger = get_boolean(stMsgData->paramValue);
4124 
4125 
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__);
4128  return ret;
4129  }
4130  else if (hostIf_DeviceInfo::m_xFirmwareDownloadNow == false && xDwnldTrigger) {
4131  if(xDwnldTrigger && (!m_xFirmwareDownloadProtocol.empty()) &&
4132  (!m_xFirmwareDownloadURL.empty()) && (!m_xFirmwareToDownload.empty())) {
4133 
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);
4136 
4137 #ifdef YOCTO_BUILD
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);
4139 #else
4140  ret = system (cmd);
4141 #endif
4142 
4143  if (ret != 0) {
4144  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Failed to trigger Download, \'system (\"%s\")\' returned error code '%d'\n", __FUNCTION__, cmd, ret);
4145  return NOK;
4146  }
4147  RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF, "[%s:%d] Yw.. Successfully executed (\'%s\')Triggered Download.\n",__FUNCTION__,__LINE__, cmd);
4148 
4149  /*Reset all cache parameter values for download trigger on successfully executed*/
4150  m_xFirmwareDownloadProtocol.clear();
4151  m_xFirmwareToDownload.clear();
4152  m_xFirmwareDownloadURL.clear();
4153  m_xFirmwareDownloadNow = false;
4154  m_xFirmwareDownloadUseCodebig = false;
4155  m_xFirmwareDownloadDeferReboot = false;
4156  ret = OK;
4157  }
4158  else {
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__);
4165 
4166  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Please configure other parameters, then trigger download. \n", __FUNCTION__, __LINE__);
4167  return ret;
4168  }
4169  }
4170  else {
4171  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Failed to trigger Download, since \"FirmwareToDownload\" is not set. \n", __FUNCTION__, __LINE__);
4172  }
4173  }
4174  else
4175  {
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);
4177  }
4178 
4179  return ret;
4180 }
4181 
4182 /**
4183  * @brief Finds if one string occurs within another string. The search is case-insensitive.
4184  *
4185  * @param[in] haystack the string within which the search is to be performed.
4186  * @param[in] needle the string to be searched for.
4187  * @param[in] pos the index within 'haystack' from where the search for 'needle' is to be started.
4188  *
4189  * @return the index of where the 'needle' is found in the 'haystack', or npos if 'needle' is not found.
4190  */
4191 size_t hostIf_DeviceInfo::findIgnoreCase (std::string haystack, std::string needle, size_t pos)
4192 {
4193  std::transform (haystack.begin(), haystack.end(), haystack.begin(), ::tolower); // convert haystack to lower case
4194  std::transform (needle.begin(), needle.end(), needle.begin(), ::tolower); // convert needle to lower case
4195  return haystack.find (needle, pos); // find and return the location of the needle hidden in the haystack
4196 }
4197 
4198 string hostIf_DeviceInfo::getStbMacIf_fr_devProperties()
4199 {
4200  string stb_mac;
4201  try {
4202  char mac_buf[20] = {0};
4203 
4204  struct ifreq ifr;
4205 
4206  /* Get configured Estb Mac interface */
4207  char *stbMacIf = getenvOrDefault ((const char*)"DEFAULT_ESTB_INTERFACE", (char*)"");
4208 
4209  int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
4210  if(fd > 0) {
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;
4215  if(mac) {
4216  sprintf (mac_buf, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
4217  stb_mac = mac_buf;
4218  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] STB MAC : \'%s\'..\n", __FUNCTION__, __LINE__, mac_buf );
4219  }
4220  else {
4221  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Failed to get ifr_hwaddr.sa_data\'%s\'..\n", __FUNCTION__, __LINE__, strerror (errno) );
4222  }
4223  }
4224  else {
4225  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Failed in ioctl() with \'%s\'..\n", __FUNCTION__, __LINE__, strerror (errno) );
4226  }
4227  close (fd); //CID:89478 - NEGATIVE RETURNS
4228  }
4229  else
4230  {
4231  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Socket failed with \'%s\'..\n", __FUNCTION__, __LINE__, strerror (errno) );
4232  close (fd);
4233  }
4234  } catch (const std::exception &e) {
4235  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught %s\n", __FUNCTION__, e.what());
4236  }
4237  return stb_mac;
4238 }
4239 
4240 int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_LastRebootReason(HOSTIF_MsgData_t *stMsgData)
4241 {
4242 
4243  int ret = NOK;
4244  FILE *fp = NULL;
4245  char buffer[1024] = {0};
4246  char *reboot_reason = NULL;
4247 
4248  LOG_ENTRY_EXIT;
4249 
4250  fp = fopen(PREVIOUS_REBOT_REASON_FILE,"r");
4251  if(!fp)
4252  {
4253  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF," '%s' file not Present.\n", PREVIOUS_REBOT_REASON_FILE);
4254  return ret;
4255  }
4256  fread(buffer, 1024, 1, fp);
4257  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Previous Reboot Info buffer: %s\n", buffer);
4258  fclose(fp);
4259 
4260  bool reason_str_found = false;
4261  char search[] = "reason";
4262  char *ptr = strstr(buffer, search);
4263 
4264  if (ptr != NULL)
4265  {
4266  reason_str_found = true;
4267  }
4268  else /* Substring not found */
4269  {
4270  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF," '%s' file doesn't contain '%s' string.\n", PREVIOUS_REBOT_REASON_FILE, search);
4271  }
4272 
4273  if(reason_str_found)
4274  {
4275  cJSON *root = cJSON_Parse(buffer);
4276 
4277  if(root) {
4278  reboot_reason = cJSON_GetObjectItem(root, "reason")->valuestring;
4279 
4280  if(reboot_reason) {
4281  ret = OK;
4282  memset(stMsgData->paramValue, 0, TR69HOSTIFMGR_MAX_PARAM_LEN);
4283  strncpy(stMsgData->paramValue, reboot_reason, sizeof(stMsgData->paramValue) -1);
4284  stMsgData->paramValue[sizeof(stMsgData->paramValue) -1] = '\0';
4285  stMsgData->paramtype = hostIf_StringType;
4286  stMsgData->paramLen = strlen(reboot_reason);
4287  }
4288 
4289  cJSON_Delete(root);
4290  }
4291  else {
4292 
4293  }
4294 
4295  }
4296  return ret;
4297 }
4298 
4300 {
4301  int ret = NOK;
4302 
4303  if(strcmp(stMsgData->paramName, X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION) == 0)
4304  {
4305  ret = get_xOpsRPCDevManageableNotification(stMsgData);
4306  }
4307  else if(strcmp(stMsgData->paramName, X_OPS_RPC_FW_DNLD_STARTED_NOTIFICATION) == 0)
4308  {
4309  ret = get_xOpsRPCFwDwldStartedNotification(stMsgData);
4310  }
4311  else if(strcmp(stMsgData->paramName, X_OPS_RPC_FW_DNLD_COMPLETED_NOTIFICATION) == 0)
4312  {
4313  ret = get_xOpsRPCFwDwldCompletedNotification(stMsgData);
4314  }
4315  else if(strcmp(stMsgData->paramName, X_OPS_RPC_REBOOT_PENDING_NOTIFICATION) == 0)
4316  {
4317  ret = get_xOpsRPCRebootPendingNotification(stMsgData);
4318  }
4319  else
4320  {
4321  stMsgData->faultCode = fcInvalidParameterName;
4322  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Invalid Parameter Name\n", __FUNCTION__, stMsgData->paramName);
4323  }
4324  return ret;
4325 }
4326 
4327 int hostIf_DeviceInfo::get_xOpsRPCDevManageableNotification(HOSTIF_MsgData_t* stMsgData)
4328 {
4329  char *chVal = (char *)(!m_strXOpsDevManageableNotification.empty() ? m_strXOpsDevManageableNotification.c_str() : "0");
4330  errno_t rc = -1;
4331  rc=strcpy_s(stMsgData->paramValue,sizeof(stMsgData->paramValue), chVal);
4332  if(rc!=EOK)
4333  {
4334  ERR_CHK(rc);
4335  }
4336  return OK;
4337 }
4338 
4339 int hostIf_DeviceInfo::get_xOpsRPCFwDwldStartedNotification(HOSTIF_MsgData_t* stMsgData)
4340 {
4341  char *chVal = (char *)((!m_strXOpsRPCFwDwldStartedNotification.empty()) ? m_strXOpsRPCFwDwldStartedNotification.c_str() : "0");
4342  errno_t rc = -1;
4343  rc=strcpy_s(stMsgData->paramValue,sizeof(stMsgData->paramValue), chVal);
4344  if(rc!=EOK)
4345  {
4346  ERR_CHK(rc);
4347  }
4348  return OK;
4349 }
4350 
4351 int hostIf_DeviceInfo::get_xOpsRPCFwDwldCompletedNotification(HOSTIF_MsgData_t* stMsgData)
4352 {
4353  put_boolean(stMsgData->paramValue, m_bXOpsRPCFwDwldCompletedNotification);
4354  return OK;
4355 }
4356 
4357 int hostIf_DeviceInfo::get_xOpsRPCRebootPendingNotification(HOSTIF_MsgData_t* stMsgData)
4358 {
4359  put_uint(stMsgData->paramValue, 0);
4360  return OK;
4361 }
4362 
4363 int hostIf_DeviceInfo::set_xOpsRPC_Profile(HOSTIF_MsgData_t * stMsgData)
4364 {
4365  if(strcmp(stMsgData->paramName, X_OPS_RPC_REBOOTNOW) == 0)
4366  {
4367  set_xOpsDeviceMgmtRPCRebootNow (stMsgData);
4368  }
4369  else if(strcmp(stMsgData->paramName, X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION) == 0)
4370  {
4371  set_xOpsRPCDevManageableNotification(stMsgData);
4372  }
4373  else if(strcmp(stMsgData->paramName, X_OPS_RPC_FW_DNLD_STARTED_NOTIFICATION) == 0)
4374  {
4375  set_xOpsRPCFwDwldStartedNotification(stMsgData);
4376  }
4377  else if(strcmp(stMsgData->paramName, X_OPS_RPC_FW_DNLD_COMPLETED_NOTIFICATION) == 0)
4378  {
4379  set_xOpsRPCFwDwldCompletedNotification(stMsgData);
4380  }
4381  else if(strcmp(stMsgData->paramName, X_OPS_RPC_REBOOT_PENDING_NOTIFICATION) == 0)
4382  {
4383  set_xOpsRPCRebootPendingNotification(stMsgData);
4384  }
4385  else
4386  {
4387  stMsgData->faultCode = fcInvalidParameterName;
4388  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Invalid Parameter Name\n", __FUNCTION__, stMsgData->paramName);
4389  }
4390  return OK;
4391 }
4392 
4393 int hostIf_DeviceInfo::set_xOpsDeviceMgmtRPCRebootNow (HOSTIF_MsgData_t * stMsgData)
4394 {
4395  LOG_ENTRY_EXIT;
4396 
4397  if (get_boolean (stMsgData->paramValue))
4398  {
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);
4402  if (ret != 0)
4403  {
4404  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] 'system (\"%s\")' returned error code '%d'\n", __FUNCTION__, command, ret);
4405  return NOK;
4406  }
4407  }
4408  else
4409  {
4410  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Not rebooting. %s = false\n", __FUNCTION__, stMsgData->paramName);
4411  }
4412 
4413  return OK;
4414 }
4415 
4416 int hostIf_DeviceInfo::set_xOpsRPCDevManageableNotification(HOSTIF_MsgData_t *stMsgData) {
4417  LOG_ENTRY_EXIT;
4418 
4419  errno_t rc = -1;
4420  m_strXOpsDevManageableNotification.clear();
4421 
4422  HOSTIF_MsgData_t stRfcData = {0};
4423  rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4424  if(rc!=EOK)
4425  {
4426  ERR_CHK(rc);
4427  }
4428  if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0))
4429  {
4430  m_strXOpsDevManageableNotification = stMsgData->paramValue;
4431  NotificationHandler::getInstance()->push_device_mgmt_notifications(NULL, NULL, NULL, (char* )"fully-manageable", stMsgData->paramValue);
4432 
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);
4435  }
4436  else {
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 );
4439  }
4440  return OK;
4441 }
4442 
4443 int hostIf_DeviceInfo::set_xOpsRPCFwDwldStartedNotification(HOSTIF_MsgData_t *stMsgData) {
4444  LOG_ENTRY_EXIT;
4445 
4446  errno_t rc = -1;
4447  m_strXOpsRPCFwDwldStartedNotification.clear();
4448  /* Check for RFC */
4449  HOSTIF_MsgData_t stRfcData = {0};
4450  rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4451  if(rc!=EOK)
4452  {
4453  ERR_CHK(rc);
4454  }
4455  if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0))
4456  {
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",
4460  __FUNCTION__, stMsgData->paramName, stMsgData->paramValue);
4461  }
4462  else {
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 );
4465  }
4466  return OK;
4467 }
4468 
4469 int hostIf_DeviceInfo::set_xOpsRPCFwDwldCompletedNotification(HOSTIF_MsgData_t *stMsgData) {
4470  LOG_ENTRY_EXIT;
4471  errno_t rc = -1;
4472  /* Check for RFC */
4473  HOSTIF_MsgData_t stRfcData = {0};
4474  rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4475  if(rc!=EOK)
4476  {
4477  ERR_CHK(rc);
4478  }
4479  if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0))
4480  {
4481  m_bXOpsRPCFwDwldCompletedNotification = get_boolean(stMsgData->paramValue);
4482  const char *status = (m_bXOpsRPCFwDwldCompletedNotification)?"true":"false";
4483  char* start_time= (char*) m_strXOpsRPCFwDwldStartedNotification.c_str();
4484 
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);
4488  }
4489  else {
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 );
4492  }
4493  return OK;
4494 }
4495 
4496 int hostIf_DeviceInfo::set_xOpsRPCRebootPendingNotification(HOSTIF_MsgData_t *stMsgData) {
4497  LOG_ENTRY_EXIT;
4498  /* Check for RFC */
4499  errno_t rc = -1;
4500  HOSTIF_MsgData_t stRfcData = {0};
4501  rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_MANGEBLENOTIFICATION_ENABLE);
4502  if(rc!=EOK)
4503  {
4504  ERR_CHK(rc);
4505  }
4506  if((get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0))
4507  {
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);
4512 
4513  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Successfully Set [\"%s\"] and Send \"reboot-pending\" notification \
4514  \n", __FUNCTION__, stMsgData->paramName );
4515  }
4516  else {
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 );
4519  }
4520  return OK;
4521 }
4522 
4523 
4524 int hostIf_DeviceInfo::set_X_RDKCENTRAL_COM_LastRebootReason(HOSTIF_MsgData_t *stMsgData)
4525 {
4526  LOG_ENTRY_EXIT;
4527  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"This '%s' file contains the LastRebootReason.\n", PREVIOUS_REBOT_REASON_FILE);
4528  return OK;
4529 }
4530 
4531 void hostIf_DeviceInfo::send_DeviceManageableNotification()
4532 {
4533  LOG_ENTRY_EXIT;
4534  std::thread systemMgmtTimeMonitorThrd(hostIf_DeviceInfo::systemMgmtTimePathMonitorThr);
4535  systemMgmtTimeMonitorThrd.detach();
4536 }
4537 
4538 void hostIf_DeviceInfo::systemMgmtTimePathMonitorThr()
4539 {
4540  unsigned long system_manageable_time = 0;
4541 
4542  sleep(10);
4543  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s]Entering...\n", __FUNCTION__);
4544  /*This thread is to send the `DeviceManageableNotification` based on
4545  * Check for /tmp/webpa/start_time
4546  * 1. File exist for system manage up time, then send */
4547 
4548  LOG_ENTRY_EXIT;
4549 
4550  int count = 0;
4551  bool is_webpa_ready = 0;
4552  do {
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) {
4556  //system_manageable_time = get_system_manageble_time();
4557  system_manageable_time = get_device_manageble_time();
4558  HOSTIF_MsgData_t stMsgData = {0};
4559  sprintf(stMsgData.paramName, "%s", X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION);
4560  sprintf(stMsgData.paramValue, "%ld", system_manageable_time);
4561 
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);
4564  break;
4565  }
4566  else
4567  {
4568  sleep(60);
4569  count++;
4570  }
4571 
4572  if(count >= 5)
4573  break;
4574  } while(is_webpa_ready == false);
4575 
4576  if(is_webpa_ready == false)
4577  {
4578  int inotifyFd = 0, wd = 0;
4579  std::string m_path = "/tmp/webpa";
4580  inotifyFd = inotify_init();
4581 
4582  if (inotifyFd == -1)
4583  {
4584  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]: Failed in inotify_init. Exiting thread \n",__FUNCTION__,__LINE__);
4585  return;
4586  }
4587  wd = inotify_add_watch(inotifyFd, m_path.c_str(), IN_CREATE | IN_ATTRIB);
4588 
4589  if (wd == -1)
4590  {
4591  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d]Unable to create Watch inotify file descriptor. Exiting thread \n",__FUNCTION__,__LINE__);
4592  return;
4593  }
4594  char buffer[sizeof(struct inotify_event) + NAME_MAX + 1] = {0};
4595 
4596  while (1)
4597  {
4598  ssize_t count = read(inotifyFd, buffer, sizeof(buffer));
4599 
4600  if (count < 0)
4601  {
4602  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Failed to read. Exiting \n",__FUNCTION__,__LINE__);
4603  return;
4604  }
4605 
4606  struct inotify_event * event = reinterpret_cast<struct inotify_event *>(buffer);
4607  if (event->mask & IN_ATTRIB)
4608  {
4609  if(!is_webpa_ready) {
4610  if(0 == (strcmp(event->name, "start_time")))
4611  is_webpa_ready = true;
4612  }
4613 
4614 
4615  if(is_webpa_ready) {
4616  system_manageable_time = get_device_manageble_time();
4617  HOSTIF_MsgData_t stMsgData = {0};
4618  sprintf(stMsgData.paramName, "%s", X_OPS_RPC_DEV_MANAGEABLE_NOTIFICATION);
4619  sprintf(stMsgData.paramValue, "%ld", system_manageable_time);
4620  hostIf_SetMsgHandler(&stMsgData);
4621  break;
4622  }
4623  }
4624  }
4625  inotify_rm_watch( inotifyFd, wd );
4626  close( inotifyFd );
4627  }
4628  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s]Exiting...\n", __FUNCTION__);
4629 }
4630 
4631 int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_experience( HOSTIF_MsgData_t *stMsgData)
4632 {
4633  string resp="";
4634  string experience = "";
4635  std::string postData;
4636  std::string tokenheader;
4637 
4638  CURL *curl = curl_easy_init();
4639 
4640  if(NULL == curl)
4641  {
4642  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s]Failed at curl_easy_init.\n", __FUNCTION__);
4643  return NOK;
4644  }
4645 
4646  if(curl)
4647  {
4648  std::string sToken = get_security_token();
4649  tokenheader = "Authorization: Bearer " + sToken;
4650 
4651  postData = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.getExperience\" }";
4652 
4653  struct curl_slist *list = NULL;
4654 
4655  list = curl_slist_append(list, tokenheader.c_str());
4656  list = curl_slist_append(list, "Content-Type: application/json");
4657 
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);
4664 
4665  CURLcode res = curl_easy_perform(curl);
4666 
4667  long http_code = 0;
4668 
4669  if(res == CURLE_OK)
4670  {
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);
4673  }
4674 
4675  curl_easy_cleanup(curl);
4676  curl_slist_free_all(list);
4677 
4678  if(res == CURLE_OK && http_code == HTTP_OK )
4679  {
4680  RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] curl response string = %s\n", __FUNCTION__, resp.c_str());
4681 
4682  cJSON* root = cJSON_Parse(resp.c_str());
4683 
4684  if(root)
4685  {
4686  cJSON* jsonObj = cJSON_GetObjectItem(root, "result");
4687 
4688  if (jsonObj)
4689  {
4690  cJSON *experienceObj = cJSON_GetObjectItem(jsonObj, "experience");
4691 
4692  if(experienceObj && experienceObj->type == cJSON_String && experienceObj->valuestring && (strlen(experienceObj->valuestring) > 0))
4693  {
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;
4696  }
4697  else
4698  {
4699  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"experience\" in the output from Thunder plugin\n", __FUNCTION__);
4700  cJSON_Delete(root);
4701  return NOK;
4702  }
4703  }
4704  else
4705  {
4706  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__);
4707  cJSON_Delete(root);
4708  return NOK;
4709  }
4710 
4711  cJSON_Delete(root);
4712  }
4713  else
4714  {
4715  RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error\n", __FUNCTION__);
4716  return NOK;
4717  }
4718  }
4719  }
4720 
4721  if(!experience.empty()) {
4722  strncpy(stMsgData->paramValue, experience.c_str(), TR69HOSTIFMGR_MAX_PARAM_LEN-1 );
4723  }
4724  else {
4725  return NOK;
4726  }
4727 
4728  return OK;
4729 }
4730 
4731 /**
4732  * @brief This function identifying the imagename of the running image
4733  * This Value comes from "imagename" property in /version.txt file
4734  * @param[out] stMsgData TR-069 Host interface message request.
4735  * @param[in] pChanged Status of the operation.
4736  *
4737  * @return Returns the status of the operation.
4738  *
4739  * @retval OK if it is successful.
4740  * @retval ERR_INTERNAL_ERROR if not able to fetch from device.
4741  * @ingroup TR69_HOSTIF_DEVICEINFO_API
4742  */
4744 {
4745  string line;
4746  ifstream versionfile (VERSION_FILE);
4747  char imagename[100] = {'\0'};
4748  errno_t rc = -1;
4749 
4750  try {
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(), ":");
4755  tmpStr++;
4756  while(isspace(*tmpStr)) {
4757  tmpStr++;
4758  }
4759  rc=strcpy_s(imagename,sizeof(imagename), tmpStr);
4760  if(rc!=EOK) {
4761  ERR_CHK(rc);
4762  }
4763  break;
4764  }
4765  }
4766  versionfile.close();
4767  }
4768  else
4769  {
4770  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Failed to open [%s] file.\n", __FUNCTION__, VERSION_FILE);
4771  return NOK;
4772  }
4773 
4774  if(imagename[0] != '\0') {
4775  stMsgData->paramLen = strlen(imagename);
4776  strncpy(stMsgData->paramValue,imagename, stMsgData->paramLen);
4777  }
4778  stMsgData->paramtype = hostIf_StringType;
4779  }
4780  catch (const std::exception e) {
4781  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught.\n", __FUNCTION__);
4782  return NOK;
4783  }
4784  RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ );
4785  return OK;
4786 }
4787 
4788 int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t * stMsgData)
4789 {
4790  int ret = NOK;
4791  char *rdm_comm = "/etc/rdm/rdmBundleMgr.sh";
4792  char *install_cmd = NULL;
4793 
4794  RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering..\n", __FUNCTION__ );
4795 
4796  if( (!stMsgData->paramValue) || (strlen(stMsgData->paramValue) == 0 )) {
4797  RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Invalid parameter value\n", __FUNCTION__);
4798  return NOK;
4799  }
4800 
4801  RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Executing command - sh %s %s & \n", __FUNCTION__ , rdm_comm, stMsgData->paramValue);
4802 
4803 #ifdef YOCTO_BUILD
4804  ret = v_secure_system("sh %s %s &", rdm_comm, stMsgData->paramValue);
4805 #else
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);
4809  free(install_cmd);
4810 #endif
4811 
4812  if (ret != 0) {
4813  RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Failed to execute the command. Returned error code '%d'\n", __FUNCTION__, ret);
4814  return NOK;
4815  }
4816 
4817  RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Exiting..\n", __FUNCTION__ );
4818  return OK;
4819 }
4820 /* End of doxygen group */
4821 /**
4822  * @}
4823  */
4824 
4825 /* End of file xxx_api.c. */
4826 
4827 
4828 /** @} */
4829 /** @} */
4830 
hostIf_DeviceInfo::get_Device_DeviceInfo_ManufacturerOUI
int get_Device_DeviceInfo_ManufacturerOUI(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_Manufacturer.
Definition: Device_DeviceInfo.cpp:565
hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId
int set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(HOSTIF_MsgData_t *)
set_Device.DeviceInfo_X_RDKCENTRAL-COM_Syndication_PartnerId
Definition: Device_DeviceInfo.cpp:2325
IARM_BUS_PWRMGR_NAME
#define IARM_BUS_PWRMGR_NAME
Definition: pwrMgr.h:54
netsrvmgrIarm.h
The header file provides components netSrvMgrIarm information APIs.
MoCAInterface
Definition: Device_MoCA_Interface.h:114
hostIf_DeviceInfo::get_xOpsDMLogsUploadStatus
int get_xOpsDMLogsUploadStatus(HOSTIF_MsgData_t *)
get_xOpsDMLogsUploadStatus.
Definition: Device_DeviceInfo.cpp:1980
hostIf_DeviceInfo::get_Device_DeviceInfo_UpTime
int get_Device_DeviceInfo_UpTime(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_UpTime.
Definition: Device_DeviceInfo.cpp:1022
hostIf_DeviceInfo::get_Device_DeviceInfo_MemoryStatus_Total
int get_Device_DeviceInfo_MemoryStatus_Total(HOSTIF_MsgData_t *, bool *pChanged=NULL)
Get the device total memory status.
Definition: Device_DeviceInfo.cpp:1740
hostIf_DeviceInfo::set_xOpsDMMoCALogPeriod
int set_xOpsDMMoCALogPeriod(HOSTIF_MsgData_t *)
set_xOpsDMMoCALogPeriod.
Definition: Device_DeviceInfo.cpp:2505
getenvOrDefault
char * getenvOrDefault(const char *name, char *defaultValue)
Definition: hostIf_utils.cpp:404
hostIf_DeviceInfo::get_Device_DeviceInfo_Manufacturer
int get_Device_DeviceInfo_Manufacturer(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_Manufacturer.
Definition: Device_DeviceInfo.cpp:486
sysMgr.h
IARM-Bus Sys Manager Public API.
device::Host::getCPUTemperature
float getCPUTemperature()
This API gets CPU temperature.
Definition: host.cpp:470
hostIf_DeviceInfo::get_Device_DeviceInfo_FirstUseDate
int get_Device_DeviceInfo_FirstUseDate(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_FirstUseDate.
Definition: Device_DeviceInfo.cpp:1047
hostIf_DeviceInfo::findIgnoreCase
size_t findIgnoreCase(std::string haystack, std::string needle, size_t pos=0)
Finds if one string occurs within another string. The search is case-insensitive.
Definition: Device_DeviceInfo.cpp:4191
IARM_BUS_SYSMGR_NAME
#define IARM_BUS_SYSMGR_NAME
Definition: sysMgr.h:110
_IARM_Bus_PWRMgr_GetPowerState_Param_t
Structure which holds the current power state of the CPE.
Definition: pwrMgr.h:173
hostIf_DeviceInfo::get_Device_DeviceInfo_AdditionalSoftwareVersion
int get_Device_DeviceInfo_AdditionalSoftwareVersion(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_AdditionalSoftwareVersion.
Definition: Device_DeviceInfo.cpp:901
_IARM_Bus_MFRLib_GetSerializedData_Param_t::buffer
char buffer[(1280)]
Definition: mfrMgr.h:120
hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset
int set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(HOSTIF_MsgData_t *)
set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset.
Definition: Device_DeviceInfo.cpp:2098
XRFCStorage
Definition: XrdkCentralComRFC.h:28
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
dsTypes.h
Device Settings HAL types.
XBSStore
Definition: XrdkCentralComBSStore.h:33
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_BootStatus
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_BootStatus(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_BootStatus.
Definition: Device_DeviceInfo.cpp:1801
manager.hpp
It contains class referenced by manager.cpp file.
hostIf_DeviceInfo::get_Device_DeviceInfo_VendorLogFileNumberOfEntries
int get_Device_DeviceInfo_VendorLogFileNumberOfEntries(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_VendorLogFileNumberOfEntries.
Definition: Device_DeviceInfo.cpp:1702
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
IARM_BUS_PWRMGR_API_GetPowerState
#define IARM_BUS_PWRMGR_API_GetPowerState
Definition: pwrMgr.h:168
_IARM_Bus_MFRLib_GetSerializedData_Param_t::bufLen
int bufLen
Definition: mfrMgr.h:121
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_CPUTemp
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_CPUTemp(HOSTIF_MsgData_t *, bool *pChanged=NULL)
This method gets the CPU temperature for doing general health check up of the box.
Definition: Device_DeviceInfo.cpp:1931
hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus
int get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus.
Definition: Device_DeviceInfo.cpp:1369
hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP
int get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_COMCAST_COM_STB_IP.
Definition: Device_DeviceInfo.cpp:1328
hostIf_DeviceInfo::get_Device_DeviceInfo_VendorConfigFileNumberOfEntries
int get_Device_DeviceInfo_VendorConfigFileNumberOfEntries(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_VendorConfigFileNumberOfEntries.
Definition: Device_DeviceInfo.cpp:1634
hostIf_DeviceInfo::get_Device_DeviceInfo_ProcessorNumberOfEntries
static int get_Device_DeviceInfo_ProcessorNumberOfEntries(HOSTIF_MsgData_t *)
get_Device_DeviceInfo_ProcessorNumberOfEntries.
Definition: Device_DeviceInfo.cpp:1660
dsError.h
Device Settings HAL error codes.
_IARM_Bus_SYSMgr_GetSystemStates_Param_t
Definition: sysMgr.h:299
put_boolean
void put_boolean(char *ptr, bool val)
This function converts the input data to Boolean type.
Definition: hostIf_utils.cpp:191
hostIf_DeviceInfo::get_Device_DeviceInfo_SerialNumber
int get_Device_DeviceInfo_SerialNumber(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_SerialNumber.
Definition: Device_DeviceInfo.cpp:301
hostIf_DeviceInfo::get_xOpsReverseSshArgs
int get_xOpsReverseSshArgs(HOSTIF_MsgData_t *)
get_xOpsReverseSshArgs
Definition: Device_DeviceInfo.cpp:2813
dsERR_GENERAL
@ dsERR_GENERAL
Definition: dsError.h:86
hostIf_DeviceInfo::get_Device_DeviceInfo_Description
int get_Device_DeviceInfo_Description(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_Description.
Definition: Device_DeviceInfo.cpp:724
hostIf_DeviceInfo::get_Device_DeviceInfo_SupportedDataModelNumberOfEntries
int get_Device_DeviceInfo_SupportedDataModelNumberOfEntries(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_SupportedDataModelNumberOfEntries.
Definition: Device_DeviceInfo.cpp:1652
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
hostIf_DeviceInfo::get_xOpsReverseSshStatus
int get_xOpsReverseSshStatus(HOSTIF_MsgData_t *)
get_xOpsReverseSshStatus
Definition: Device_DeviceInfo.cpp:2921
hostIf_DeviceInfo::set_xOpsReverseSshArgs
int set_xOpsReverseSshArgs(HOSTIF_MsgData_t *)
set_xOpsReverseSshArgs
Definition: Device_DeviceInfo.cpp:2833
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig.
Definition: Device_DeviceInfo.cpp:1570
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload.
Definition: Device_DeviceInfo.cpp:1529
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
hostIf_DeviceInfo::get_Device_DeviceInfo_ProductClass
int get_Device_DeviceInfo_ProductClass(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_ProductClass.
Definition: Device_DeviceInfo.cpp:748
IARM_Bus_BroadcastEvent
IARM_Result_t IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *data, size_t len)
This API is used to publish an Asynchronous event to all IARM client registered for this perticular e...
hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_MAC
int get_Device_DeviceInfo_X_COMCAST_COM_STB_MAC(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_COMCAST_COM_STB_MAC.
Definition: Device_DeviceInfo.cpp:1083
_HostIf_MsgData_t::faultCode
faultCode_t faultCode
Definition: hostIf_tr69ReqHandler.h:179
hostIf_DeviceInfo::get_Device_DeviceInfo_HardwareVersion
int get_Device_DeviceInfo_HardwareVersion(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_HardwareVersion.
Definition: Device_DeviceInfo.cpp:821
libIBus.h
RDK IARM-Bus API Declarations.
hostIf_DeviceInfo::get_Device_DeviceInfo_SoftwareVersion
int get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_SoftwareVersion.
Definition: Device_DeviceInfo.cpp:392
Device_DeviceInfo.h
The header file provides TR69 device information APIs.
_HostIf_MsgData_t::paramName
char paramName[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:171
hostIf_DeviceInfo::set_xOpsDMUploadLogsNow
int set_xOpsDMUploadLogsNow(HOSTIF_MsgData_t *)
set_xOpsDMUploadLogsNow.
Definition: Device_DeviceInfo.cpp:2232
hostIf_DeviceInfo::get_X_RDK_FirmwareName
int get_X_RDK_FirmwareName(HOSTIF_MsgData_t *)
This function identifying the imagename of the running image This Value comes from "imagename" proper...
Definition: Device_DeviceInfo.cpp:4743
hostIf_DeviceInfo
This class provides the interface for getting device information.
Definition: Device_DeviceInfo.h:194
Device_MoCA_Interface.h
device::Host::getVideoDevices
List< VideoDevice > getVideoDevices()
This API is used to get the list of the video devices (i.e. Decoders) supported on the device....
Definition: host.cpp:331
get_security_token
std::string get_security_token()
Definition: hostIf_utils.cpp:572
device::Host::getAudioOutputPort
AudioOutputPort & getAudioOutputPort(const std::string &name)
This API is used to get the reference to the audio output port by its name. The name of the port must...
Definition: host.cpp:388
hostIf_DeviceInfo::readFirmwareInfo
int readFirmwareInfo(char *, HOSTIF_MsgData_t *)
This method read the firmware information which is present in "/opt/fwdnldstatus.txt".
Definition: Device_DeviceInfo.cpp:4000
hostIf_DeviceInfo::writeFirmwareInfo
int writeFirmwareInfo(char *, HOSTIF_MsgData_t *)
This method writes the firmware information which is present in "/opt/fwdnldstatus....
Definition: Device_DeviceInfo.cpp:4070
XRFCStore
Definition: XrdkCentralComRFCStore.h:30
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL
int get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL.
Definition: Device_DeviceInfo.cpp:1561
hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload
int set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload(HOSTIF_MsgData_t *)
This method set the firmware download file path which is present in "/opt/fwdnldstatus....
Definition: Device_DeviceInfo.cpp:2186
hostIf_DeviceInfo::get_Device_DeviceInfo_AdditionalHardwareVersion
int get_Device_DeviceInfo_AdditionalHardwareVersion(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_AdditionalHardwareVersion.
Definition: Device_DeviceInfo.cpp:878
IARM_BUS_MFRLIB_API_GetSerializedData
#define IARM_BUS_MFRLIB_API_GetSerializedData
Definition: mfrMgr.h:100
pwrMgr.h
IARM-Bus Power Manager Public API.
hostIf_DeviceInfo::hostIf_DeviceInfo
hostIf_DeviceInfo(int dev_id)
Class Constructor of the class hostIf_DeviceInfo.
Definition: Device_DeviceInfo.cpp:163
device::Host::getVideoOutputPort
VideoOutputPort & getVideoOutputPort(const std::string &name)
This API is used to get the reference to the video output port by its name. The name of the port must...
Definition: host.cpp:350
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType.
Definition: Device_DeviceInfo.cpp:1945
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset.
Definition: Device_DeviceInfo.cpp:1717
device::Host::getInstance
static Host & getInstance(void)
This API is used to get a reference to the single instance of the Host object.
Definition: host.cpp:88
IARM_BUS_MFRLIB_NAME
#define IARM_BUS_MFRLIB_NAME
Definition: mfrMgr.h:98
ResetFunc
void * ResetFunc(void *)
This method resets according to the STB reset state such as NoReset, ColdReset FactoryReset,...
Definition: Device_DeviceInfo.cpp:2150
device::VideoDevice
class extending DSConstant to implement the videoDevice interface.
Definition: videoDevice.hpp:53
MoCAInterface::check_MoCABootStatus
int check_MoCABootStatus(char *)
Get the MoCA status for BootStatus.
Definition: Device_MoCA_Interface.cpp:1146
_IARM_Bus_MFRLib_GetSerializedData_Param_t
Definition: mfrMgr.h:118
_IARM_Bus_MFRLib_GetSerializedData_Param_t::type
mfrSerializedType_t type
Definition: mfrMgr.h:119
_IARM_BUS_NetSrvMgr_Iface_EventData_t
IARM Bus struct contains active streaming interface, origional definition present in homenetworkingse...
Definition: priv_aamp.cpp:193
hostIf_DeviceInfo::get_xOpsDMMoCALogEnabled
int get_xOpsDMMoCALogEnabled(HOSTIF_MsgData_t *)
get_xOpsDMMoCALogEnabled.
Definition: Device_DeviceInfo.cpp:2525
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus.
Definition: Device_DeviceInfo.cpp:1545
hostIf_DeviceInfo::get_xOpsRPC_Profile
int get_xOpsRPC_Profile(HOSTIF_MsgData_t *)
set_xOpsDeviceMgmtRPCRebootNow
Definition: Device_DeviceInfo.cpp:4299
audioOutputPort.hpp
It contain variables,stuctures,class and functions referenced by audiooutputport code.
hostIf_DeviceInfo::get_xOpsDMUploadLogsNow
int get_xOpsDMUploadLogsNow(HOSTIF_MsgData_t *)
get_xOpsDMLogsUploadStatus.
Definition: Device_DeviceInfo.cpp:1973
hostIf_DeviceInfo::set_xOpsReverseSshTrigger
int set_xOpsReverseSshTrigger(HOSTIF_MsgData_t *)
set_xOpsReverseSshTrigger
Definition: Device_DeviceInfo.cpp:2757
hostIf_DeviceInfo::get_Device_DeviceInfo_ModelName
int get_Device_DeviceInfo_ModelName(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_ModelName.
Definition: Device_DeviceInfo.cpp:640
put_int
void put_int(char *ptr, int val)
This function converts the input data to integer type.
Definition: hostIf_utils.cpp:152
hostIf_DeviceInfo::get_Device_DeviceInfo_ProvisioningCode
int get_Device_DeviceInfo_ProvisioningCode(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_ProvisioningCode.
Definition: Device_DeviceInfo.cpp:965
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
hostIf_DeviceInfo::get_Device_DeviceInfo_MemoryStatus_Free
int get_Device_DeviceInfo_MemoryStatus_Free(HOSTIF_MsgData_t *, bool *pChanged=NULL)
Get the device total free memory status.
Definition: Device_DeviceInfo.cpp:1768
hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename
int get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename.
Definition: Device_DeviceInfo.cpp:1425
hostIf_DeviceInfo::set_xOpsDMMoCALogEnabled
int set_xOpsDMMoCALogEnabled(HOSTIF_MsgData_t *)
set_xOpsDMMoCALogEnabled.
Definition: Device_DeviceInfo.cpp:2258
TRUE
#define TRUE
Defines for TRUE/FALSE/ENABLE flags.
Definition: wifi_common_hal.h:199
_HostIf_MsgData_t::paramLen
short paramLen
Definition: hostIf_tr69ReqHandler.h:175
hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol
int get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol(HOSTIF_MsgData_t *, bool *pChanged=NULL)
get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol.
Definition: Device_DeviceInfo.cpp:1553
hostIf_DeviceInfo::get_xOpsDMMoCALogPeriod
int get_xOpsDMMoCALogPeriod(HOSTIF_MsgData_t *)
get_xOpsDMMoCALogPeriod.
Definition: Device_DeviceInfo.cpp:2689
hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus
int set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus(HOSTIF_MsgData_t *)
This method set the status of the firmware download which is present in "/opt/fwdnldstatus....
Definition: Device_DeviceInfo.cpp:2207
device::AudioOutputPort::enableLEConfig
dsError_t enableLEConfig(const bool enable)
This API is used to enable Loudness Equivalence *.
Definition: audioOutputPort.cpp:1615
device::AudioOutputPort::enableMS12Config
void enableMS12Config(const dsMS12FEATURE_t feature, const bool enable)
This API is used to enable MS12 features such as DAPV2 adn DE *.
Definition: audioOutputPort.cpp:1658
IARM_BUS_SYSMGR_API_GetSystemStates
#define IARM_BUS_SYSMGR_API_GetSystemStates
Definition: sysMgr.h:284