From 0c5bad9b8902818ce4886fd9989ce11134df1e7f Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Tue, 11 Mar 2025 11:44:32 +0000 Subject: [PATCH 001/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin with retry Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- .../handlers/src/hostIf_IARM_ReqHandler.cpp | 97 ++++-- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 55 ++-- .../profiles/DeviceInfo/Device_DeviceInfo.h | 6 + src/unittest/stubs/power_controller.h | 300 ++++++++++++++++++ 4 files changed, 403 insertions(+), 55 deletions(-) create mode 100644 src/unittest/stubs/power_controller.h diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 76dd14c55..09b23ac2c 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -36,7 +36,8 @@ #include "libIBus.h" #include "libIARM.h" #include "sysMgr.h" -#include "pwrMgr.h" +#include "power_controller.h" +#include #ifdef SNMP_ADAPTER_ENABLED #include "hostIf_SNMPClient_ReqHandler.h" #endif @@ -46,6 +47,7 @@ #include "safec_lib.h" #define X_RDK_RFC_DEEPSLEEP_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Power.DeepSleepNotification.Enable" +#define RETRYSLEEP 300 // static bool TR69_HostIf_Mgr_Init(); static bool TR69_HostIf_Mgr_Connect(); @@ -56,7 +58,8 @@ static IARM_Result_t _Settr69HostIfMgr(void *arg); static IARM_Result_t _SetAttributestr69HostIfMgr(void *arg); static IARM_Result_t _GetAttributestr69HostIfMgr(void *arg); static IARM_Result_t _RegisterForEventstr69HostIfMgr(void *arg); -static void _hostIf_EventHandler(const char *, IARM_EventId_t, void *, size_t); +static void _hostIf_EventHandler(const PowerController_PowerState_t currentState, + const PowerController_PowerState_t newState, void* userdata); //---------------------------------------------------------------------- // hostIf_IARM_IF_Start: This shall be use to initialize and register // the hostIf application to IARM bus. @@ -89,6 +92,28 @@ bool hostIf_IARM_IF_Start() return ret; } +void getPwrContInterface() +{ + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + while(true) + { + if(POWER_CONTROLLER_ERROR_NONE == PowerController_Connect()) + { + hostIf_DeviceInfo::getInstance(0)->setPowerConInterface(true); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Got the powercontroller interface..\n", __FUNCTION__, __FILE__); + break; + } + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Retry after %d usec..\n", __FUNCTION__, __FILE__, RETRYSLEEP); + usleep(RETRYSLEEP); //retry after RETRYSLEEP milli seconds. + + } + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Registering power mode change callback..\n", __FUNCTION__, __FILE__); + PowerController_RegisterPowerModeChangedCallback(_hostIf_EventHandler, nullptr); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Registered power mode change callback..\n", __FUNCTION__, __FILE__); + + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); +} + //---------------------------------------------------------------------- //Initialization: This shall be initialized tr69 application to IARM bus. //---------------------------------------------------------------------- @@ -107,6 +132,21 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## } RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] Success 'IARM_Bus_Init(%s)'.\n", __FUNCTION__, IARM_BUS_TR69HOSTIFMGR_NAME); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); + PowerController_Init(); + // Get powercontroller thunder client interface in separate thread + std::thread pwrThread(getPwrContInterface); + if(pwrThead.joinable()) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: created getPwrContInterface thread.. \n", __FUNCTION__, __LINE__); + pwrThread.detach(); // Detach the thread to run independently + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: Failed to create getPwrContInterface thread.. \n", __FUNCTION__, __LINE__); + } + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Init().. \n", __FUNCTION__, __LINE__); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return true; } @@ -161,8 +201,6 @@ static bool TR69_HostIf_Mgr_Get_RegisterCall() /* Notification RPC:*/ IARM_Bus_RegisterEvent(IARM_BUS_TR69HOSTIFMGR_EVENT_MAX); - IARM_Bus_RegisterEventHandler(IARM_BUS_PWRMGR_NAME,IARM_BUS_PWRMGR_EVENT_MODECHANGED, _hostIf_EventHandler); - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return ret; } @@ -274,6 +312,11 @@ static IARM_Result_t tr69hostIfMgr_Stop(void) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Failed to IARM_Bus_Term(), return with Error code: %d\n", __FUNCTION__, err); } + + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Term().. \n", __FUNCTION__, __LINE__); + PowerController_Term(); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Term().. \n", __FUNCTION__, __LINE__); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return err; } @@ -392,47 +435,43 @@ static IARM_Result_t _Gettr69HostIfMgr(void *arg) //---------------------------------------------------------------------- //_hostIf_EventHandler: This is to listen the IARM events and handles. //---------------------------------------------------------------------- -static void _hostIf_EventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) +static void _hostIf_EventHandler(const PowerController_PowerState_t currentState, + const PowerController_PowerState_t newState, void* userdata) { - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); - if (0 == strcmp(owner, IARM_BUS_PWRMGR_NAME)) + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + errno_t rc = -1; + HOSTIF_MsgData_t stRfcData = {0}; + rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_DEEPSLEEP_ENABLE); + if(rc!=EOK) + { + ERR_CHK(rc); + } + if((hostIf_DeviceInfo::getInstance(0)->get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0)) { - errno_t rc = -1; - HOSTIF_MsgData_t stRfcData = {0}; - rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_DEEPSLEEP_ENABLE); - if(rc!=EOK) - { - ERR_CHK(rc); - } - if((hostIf_DeviceInfo::getInstance(0)->get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0)) - { - IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; - IARM_Bus_PWRMgr_PowerState_t curPowerState = param->data.state.curState; - IARM_Bus_PWRMgr_PowerState_t newPowerState = param->data.state.newState; const char *event_time = NULL; - if((newPowerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) && - (curPowerState != IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP)) + if((newState == POWER_STATE_STANDBY_DEEP_SLEEP) && + (currentState != POWER_STATE_STANDBY_DEEP_SLEEP)) { std::string event_time_string = std::to_string(std::time(nullptr)); event_time = event_time_string.c_str(); NotificationHandler::getInstance()->push_device_deepsleep_notifications("device-enter-deepsleep-state", event_time); } - else if((newPowerState != IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) && - (curPowerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP)) + else if((newState != POWER_STATE_STANDBY_DEEP_SLEEP) && + (currentState == POWER_STATE_STANDBY_DEEP_SLEEP)) { std::string event_time_string = std::to_string(std::time(nullptr)); event_time = event_time_string.c_str(); NotificationHandler::getInstance()->push_device_deepsleep_notifications("device-exit-deepsleep-state", event_time); } - } - else - { - RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] RFC Parameter (%s) is disabled, so not sending DeepSleep notification. \n", + } + else + { + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] RFC Parameter (%s) is disabled, so not sending DeepSleep notification. \n", __FUNCTION__, X_RDK_RFC_DEEPSLEEP_ENABLE ); - } } - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); } /** @} */ diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index d23dbe1df..a330bb117 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -63,7 +63,7 @@ #include "mfrMgr.h" #include "Device_DeviceInfo.h" #include "hostIf_utils.h" -#include "pwrMgr.h" +#include "power_controller.h" #include "rbus.h" #include @@ -1452,40 +1452,42 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_MsgData_t * stMsgData, bool *pChanged) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__); - IARM_Result_t err; - int ret = NOK; + int ret = NOK, pwr_ret = -1; const char *pwrState = "PowerOFF"; int str_len = 0; - IARM_Bus_PWRMgr_GetPowerState_Param_t param; - memset(¶m, 0, sizeof(param)); - - err = IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, - IARM_BUS_PWRMGR_API_GetPowerState, - (void *)¶m, - sizeof(param)); - if(err == IARM_RESULT_SUCCESS) - { - pwrState = (param.curState==IARM_BUS_PWRMGR_POWERSTATE_OFF)?"PowerOFF":(param.curState==IARM_BUS_PWRMGR_POWERSTATE_ON)?"PowerON":"Standby"; + PowerController_PowerState_t curState = POWER_STATE_UNKNOWN, previousState = POWER_STATE_UNKNOWN; -// RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Current state is : (%d)%s\n",param.curState, pwrState); - str_len = strlen(pwrState); - try + if(hostIf_DeviceInfo::bPowerControllerEnable) { + pwr_ret = PowerController_GetPowerState(&curState, &previousState); + if (0 == pwr_ret) { - strncpy((char *)stMsgData->paramValue, pwrState, str_len); - stMsgData->paramValue[str_len+1] = '\0'; - stMsgData->paramLen = str_len; - stMsgData->paramtype = hostIf_StringType; - ret = OK; - } catch (const std::exception &e) + pwrState = (curState==POWER_STATE_OFF)?"PowerOFF":(curState==POWER_STATE_ON)?"PowerON":"Standby"; + + //TODO: will comment this. + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Current state is : (%d)%s\n",curState, pwrState); + str_len = strlen(pwrState); + try + { + strncpy((char *)stMsgData->paramValue, pwrState, str_len); + stMsgData->paramValue[str_len+1] = '\0'; + stMsgData->paramLen = str_len; + stMsgData->paramtype = hostIf_StringType; + ret = OK; + } catch (const std::exception &e) + { + RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__); + ret = NOK; + } + } + else { - RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed in power controller thunder cleint call for parameter : %s [param.type:%s with error code:%d]\n",stMsgData->paramName, pwrState, pwr_ret); ret = NOK; } } - else + else { - 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); - ret = NOK; + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Interface failed : %d \n", hostIf_DeviceInfo::bPowerControllerEnable); } //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); @@ -4191,6 +4193,7 @@ int hostIf_DeviceInfo::set_xRDKCentralComXREContainerRFCEnable(HOSTIF_MsgData_t return ret; } + void executeRfcMgr() { char buff[1024] = { '\0' }; diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 6974c3cc3..2df5385c2 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -313,6 +313,12 @@ class hostIf_DeviceInfo { GHashTable* getNotifyHash(); + bool bPowerControllerEnable; + static void setPowerConInterface( bool isPwrContEnalbe) + { + bPowerControllerEnable = isPwrContEnalbe; + } + // void runSystemMgmtTimePathMonitor(); /** * Description. This is the getter api for DeviceInfo for diff --git a/src/unittest/stubs/power_controller.h b/src/unittest/stubs/power_controller.h new file mode 100644 index 000000000..8ecad407d --- /dev/null +++ b/src/unittest/stubs/power_controller.h @@ -0,0 +1,300 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2025 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef POWERMANAGER_CLIENT_H +#define POWERMANAGER_CLIENT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum PowerController_PowerState { + POWER_STATE_UNKNOWN = 0 /* UNKNOWN */, + POWER_STATE_OFF = 1 /* OFF */, + POWER_STATE_STANDBY = 2 /* STANDBY */, + POWER_STATE_ON = 3 /* ON */, + POWER_STATE_STANDBY_LIGHT_SLEEP = 4 /* LIGHT_SLEEP */, + POWER_STATE_STANDBY_DEEP_SLEEP = 5 /* DEEP_SLEEP */ +} PowerController_PowerState_t; + +typedef enum PowerController_ThermalTemperature { + THERMAL_TEMPERATURE_UNKNOWN = 0 /* UNKNOWN Thermal Temperature */, + THERMAL_TEMPERATURE_NORMAL = 1 /* Normal Thermal Temperature */, + THERMAL_TEMPERATURE_HIGH = 2 /* High Thermal Temperature */, + THERMAL_TEMPERATURE_CRITICAL = 4 /* Critial Thermal Temperature */ +} PowerController_ThermalTemperature_t; + +typedef enum PowerController_WakeupSrcType { + WAKEUP_SRC_UNKNOWN = 0 /* UNKNOWN */, + WAKEUP_SRC_VOICE = 1 /* VOICE */, + WAKEUP_SRC_PRESENCEDETECTED = 2 /* PRESENCEDETECTED */, + WAKEUP_SRC_BLUETOOTH = 3 /* BLUETOOTH */, + WAKEUP_SRC_WIFI = 4 /* WIFI */, + WAKEUP_SRC_IR = 5 /* IR */, + WAKEUP_SRC_POWERKEY = 6 /* POWERKEY */, + WAKEUP_SRC_TIMER = 7 /* TIMER */, + WAKEUP_SRC_CEC = 8 /* CEC */, + WAKEUP_SRC_LAN = 9 /* LAN */, + WAKEUP_SRC_RF4CE = 10 /* RF4CE */ +} PowerController_WakeupSrcType_t; + +typedef enum PowerController_WakeupReason { + WAKEUP_REASON_UNKNOWN = 0 /* UNKNOWN */, + WAKEUP_REASON_IR = 1 /* IR */, + WAKEUP_REASON_BLUETOOTH = 2 /* BLUETOOTH */, + WAKEUP_REASON_RF4CE = 3 /* RF4CE */, + WAKEUP_REASON_GPIO = 4 /* GPIO */, + WAKEUP_REASON_LAN = 5 /* LAN */, + WAKEUP_REASON_WIFI = 6 /* WIFI */, + WAKEUP_REASON_TIMER = 7 /* TIMER */, + WAKEUP_REASON_FRONTPANEL = 8 /* FRONTPANEL */, + WAKEUP_REASON_WATCHDOG = 9 /* WATCHDOG */, + WAKEUP_REASON_SOFTWARERESET = 10 /* SOFTWARERESET */, + WAKEUP_REASON_THERMALRESET = 11 /* THERMALRESET */, + WAKEUP_REASON_WARMRESET = 12 /* WARMRESET */, + WAKEUP_REASON_COLDBOOT = 13 /* COLDBOOT */, + WAKEUP_REASON_STRAUTHFAIL = 14 /* STR_AUTH_FAIL */, + WAKEUP_REASON_CEC = 15 /* CEC */, + WAKEUP_REASON_PRESENCE = 16 /* PRESENCE */, + WAKEUP_REASON_VOICE = 17 /* VOICE */ +} PowerController_WakeupReason_t; + +typedef enum PowerController_SystemMode { + SYSTEM_MODE_UNKNOWN = 0 /* UNKNOWN */, + SYSTEM_MODE_NORMAL = 1 /* NORMAL */, + SYSTEM_MODE_EAS = 2 /* EAS */, + SYSTEM_MODE_WAREHOUSE = 3 /* WAREHOUSE */ +} PowerController_SystemMode_t; + +#define POWER_CONTROLLER_ERROR_NONE 0 +#define POWER_CONTROLLER_ERROR_GENERAL 1 +#define POWER_CONTROLLER_ERROR_UNAVAILABLE 2 + +/** + * @brief Initializes the Power Controller. + * + * This function creates an instance of the PowerManager plugin client interface and increments the client instance count. + * + * @details + * - If the Power Controller instance does not already exist, it will be created. + * - The instance count is incremented each time this function is called. + * + * @see PowerController_Term + */ +void PowerController_Init(); + +/** + * @brief Terminates the Power Controller. + * + * This function decrements client instance count attempts to delete Power Controller instance + * + * @details + * - If the controller reference count is greater than one, this function only decrements the count. + * - When the reference count reaches zero, the controller instance is destroyed, and all associated resources are released (PowerManager plugin client instance). + * - Ensure that this function is called once for every call to `PowerController_Init`. + * + * @see PowerController_Init + */ +void PowerController_Term(); + +/** + * @brief Checks if the Power Manager plugin is active & operational + * + * This function determines whether the Power Manager interface is operational and ready to handle requests. + * It can be used to verify the availability of the Power Manager client before initiating operations that depend on it. + * + * @return `true` if the Power Manager interface is active and operational, otherwise `false`. + * + * @details + * - Use this function to confirm the operational status of the Power Manager plugin. + * - Calling this function is NOT MANDATORY but optional + * - Clients can register for notifications about state changes using `PowerController_RegisterOperationalStateChangeCallback`. + * - If the Power Manager interface is not active, subsequent Power Manager operations will fail with the error `POWER_CONTROLLER_ERROR_UNAVAILABLE`. + * + * @see PowerController_RegisterOperationalStateChangeCallback + */ +bool PowerController_IsOperational(); + +/** Gets the Power State.*/ +// @text getPowerState +// @brief Get Power State +// @param powerState: Get current power state +uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState /* @out */, PowerController_PowerState_t* previousState /* @out */); + +/** Sets Power State . */ +// @text setPowerState +// @brief Set Power State +// @param keyCode: NA for most platfroms, to be depricated +// @param powerState: Set power to this state +// @param reason: null terminated string stating reason for for state change +uint32_t PowerController_SetPowerState(const int keyCode /* @in */, const PowerController_PowerState_t powerstate /* @in */, const char* reason /* @in */); + +/** Gets the current Thermal state.*/ +// @text getThermalState +// @brief Get Current Thermal State (temperature) +// @param currentTemperature: current temperature +uint32_t PowerController_GetThermalState(float* currentTemperature /* @out */); + +/** Sets the Temperature Thresholds.*/ +// @text setTemperatureThresholds +// @brief Set Temperature Thresholds +// @param high: high threshold +// @param critical : critical threshold +uint32_t PowerController_SetTemperatureThresholds(float high /* @in */, float critical /* @in */); + +/** Gets the current Temperature Thresholds.*/ +// @text getTemperatureThresholds +// @brief Get Temperature Thresholds +// @param high: high threshold +// @param critical : critical threshold +uint32_t PowerController_GetTemperatureThresholds(float* high /* @out */, float* critical /* @out */); + +/** Sets the current Temperature Grace interval.*/ +// @property +// @text PowerController_SetOvertempGraceInterval +// @brief Set Temperature Thresholds +// @param graceInterval: interval in secs? +uint32_t PowerController_SetOvertempGraceInterval(const int graceInterval /* @in */); + +/** Gets the grace interval for over-temperature.*/ +// @property +// @text PowerController_GetOvertempGraceInterval +// @brief Get Temperature Grace interval +// @param graceInterval: interval in secs? +uint32_t PowerController_GetOvertempGraceInterval(int* graceInterval /* @out */); + +/** Set Deep Sleep Timer for later wakeup */ +// @property +// @text setDeepSleepTimer +// @brief Set Deep sleep timer for timeOut period +// @param timeOut: deep sleep timeout +uint32_t PowerController_SetDeepSleepTimer(const int timeOut /* @in */); + +/** Get Last Wakeup reason */ +// @property +// @text getLastWakeupReason +// @brief Get Last Wake up reason +// @param wakeupReason: wake up reason +uint32_t PowerController_GetLastWakeupReason(PowerController_WakeupReason_t* wakeupReason /* @out */); + +/** Get Last Wakeup key code */ +// @property +// @text getLastWakeupKeyCode +// @brief Get the key code that can be used for wakeup +// @param keycode: Key code for wakeup +uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); + +/** Request Reboot with PowerManager */ +// @text reboot +// @brief Reboot device +// @param rebootRequestor: null terminated string identifier for the entity requesting the reboot. +// @param rebootReasonCustom: custom-defined reason for the reboot, provided as a null terminated string. +// @param rebootReasonOther: null terminated string describing any other reasons for the reboot. +uint32_t PowerController_Reboot(const char* rebootRequestor /* @in */, const char* rebootReasonCustom /* @in */, const char* rebootReasonOther /* @in */); + +/** Set Network Standby Mode */ +// @property +// @text setNetworkStandbyMode +// @brief Set the standby mode for Network +// @param standbyMode: Network standby mode +uint32_t PowerController_SetNetworkStandbyMode(const bool standbyMode /* @in */); + +/** Get Network Standby Mode */ +// @text getNetworkStandbyMode +// @brief Get the standby mode for Network +// @param standbyMode: Network standby mode +uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); + +/** Set Wakeup source configuration */ +// @text setWakeupSrcConfig +// @brief Set the source configuration for device wakeup +// @param powerMode: power mode +// @param wakeSrcType: source type +// @param config: config +uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const int wakeSrcType /* @in */, int config /* @in */); + +/** Get Wakeup source configuration */ +// @text getWakeupSrcConfig +// @brief Get the source configuration for device wakeup +// @param powerMode: power mode +// @param srcType: source type +// @param config: config +uint32_t PowerController_GetWakeupSrcConfig(int* powerMode /* @out */, int* srcType /* @out */, int* config /* @out */); + +/** Initiate System mode change */ +// @text PowerController_SetSystemMode +// @brief System mode change +// @param oldMode: current mode +// @param newMode: new mode +uint32_t PowerController_SetSystemMode(const PowerController_SystemMode_t currentMode /* @in */, const PowerController_SystemMode_t newMode /* @in */); + +/** Get Power State before last reboot */ +// @text PowerController_GetPowerStateBeforeReboot +// @brief Get Power state before last reboot +// @param powerStateBeforeReboot: power state +uint32_t PowerController_GetPowerStateBeforeReboot(PowerController_PowerState_t* powerStateBeforeReboot /* @out */); + +/* Callback data types for event notifications from power manager plugin */ +typedef void (*PowerController_OperationalStateChangeCb)(bool isOperational, void* userdata); +typedef void (*PowerController_PowerModeChangedCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); +typedef void (*PowerController_PowerModePreChangeCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); +typedef void (*PowerController_DeepSleepTimeoutCb)(const int wakeupTimeout, void* userdata); +typedef void (*PowerController_NetworkStandbyModeChangedCb)(const bool enabled, void* userdata); +typedef void (*PowerController_ThermalModeChangedCb)(const PowerController_ThermalTemperature_t currentThermalLevel, const PowerController_ThermalTemperature_t newThermalLevel, const float currentTemperature, void* userdata); +typedef void (*PowerController_RebootBeginCb)(const char* rebootReasonCustom, const char* rebootReasonOther, const char* rebootRequestor, void* userdata); + +/* Type defines for callbacks / notifications */ +/* userdata in all callbacks are opque, clients can use to have context to callbacks */ + +/** Register for PowerManager plugin operational state change event callback, for initial state use `PowerController_IsOperational` call */ +uint32_t PowerController_RegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback, void* userdata); +/** UnRegister (previously registered) PowerManager plugin operational state change event callback */ +uint32_t PowerController_UnRegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback); +/** Register for PowerMode changed callback */ +uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata); +/** UnRegister (previously registered) PowerMode changed callback */ +uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback); +/** Register for PowerMode pre-change callback */ +uint32_t PowerController_RegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback, void* userdata); +/** UnRegister (previously registered) PowerMode pre-change callback */ +uint32_t PowerController_UnRegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback); +/** Register for PowerMode pre-change callback */ +uint32_t PowerController_RegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback, void* userdata); +/** UnRegister (previously registered) DeepSleep Timeout callback */ +uint32_t PowerController_UnRegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback); +/** Register for Network Standby Mode changed event - only on XIone */ +uint32_t PowerController_RegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback, void* userdata); +/** UnRegister (previously registered) Network Standby Mode changed callback */ +uint32_t PowerController_UnRegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback); +/** Register for Thermal Mode changed event callback */ +uint32_t PowerController_RegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback, void* userdata); +/** UnRegister (previously registered) Thermal Mode changed event callback */ +uint32_t PowerController_UnRegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback); +/** Register for reboot start event callback */ +uint32_t PowerController_RegisterRebootBeginCallback(PowerController_RebootBeginCb callback, void* userdata); +/** UnRegister (previously registered) reboot start event callback */ +uint32_t PowerController_UnRegisterRebootBeginCallback(PowerController_RebootBeginCb callback); + +#ifdef __cplusplus +}; // extern "C" +#endif + +#endif // POWERMANAGER_CLIENT_H From abff1ff990d4cf34a55ab39e58791400238455f3 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Tue, 11 Mar 2025 11:53:16 +0000 Subject: [PATCH 002/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin with retry Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 5 +++++ src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index a330bb117..9c41b1c9c 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1436,6 +1436,11 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData return OK; } +static void hostIf_DeviceInfo::setPowerConInterface( bool isPwrContEnalbe) +{ + hostIf_DeviceInfo::bPowerControllerEnable = isPwrContEnalbe; +} + /** * @brief The X_COMCAST_COM_PowerStatus as get parameter results in the power status * being performed on the device. Power status of the device based on the front panel diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 2df5385c2..b0efc65e3 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -314,10 +314,7 @@ class hostIf_DeviceInfo { GHashTable* getNotifyHash(); bool bPowerControllerEnable; - static void setPowerConInterface( bool isPwrContEnalbe) - { - bPowerControllerEnable = isPwrContEnalbe; - } + static void setPowerConInterface( bool isPwrContEnalbe); // void runSystemMgmtTimePathMonitor(); /** From 0fae8d3add53c2eb6911ce739304336447e117c0 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Tue, 11 Mar 2025 13:53:58 +0000 Subject: [PATCH 003/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 2 +- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 9c41b1c9c..96c900574 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1436,7 +1436,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData return OK; } -static void hostIf_DeviceInfo::setPowerConInterface( bool isPwrContEnalbe) +void hostIf_DeviceInfo::setPowerConInterface( bool isPwrContEnalbe) { hostIf_DeviceInfo::bPowerControllerEnable = isPwrContEnalbe; } diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index b0efc65e3..591f84aa1 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -252,6 +252,8 @@ class hostIf_DeviceInfo { std::string m_strXOpsRPCFwDwldStartedNotification; bool m_bXOpsRPCFwDwldCompletedNotification; + static bool bPowerControllerEnable; + string getEstbIp(); bool isRsshactive(); bool isShortsEnabled(); @@ -313,7 +315,6 @@ class hostIf_DeviceInfo { GHashTable* getNotifyHash(); - bool bPowerControllerEnable; static void setPowerConInterface( bool isPwrContEnalbe); // void runSystemMgmtTimePathMonitor(); From 09398684139e191379e8e1241c4d2f4f1422fa37 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Wed, 12 Mar 2025 09:35:22 +0000 Subject: [PATCH 004/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin with retry Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 2 +- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 09b23ac2c..409858686 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -136,7 +136,7 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## PowerController_Init(); // Get powercontroller thunder client interface in separate thread std::thread pwrThread(getPwrContInterface); - if(pwrThead.joinable()) + if(pwrThread.joinable()) { RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: created getPwrContInterface thread.. \n", __FUNCTION__, __LINE__); pwrThread.detach(); // Detach the thread to run independently diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 96c900574..8afa8a8b7 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1492,7 +1492,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_Ms } else { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Interface failed : %d \n", hostIf_DeviceInfo::bPowerControllerEnable); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d \n", hostIf_DeviceInfo::bPowerControllerEnable); } //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); From 6058070c875f5c495612b37fe5bed4f330acb5f3 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Wed, 12 Mar 2025 11:15:03 +0000 Subject: [PATCH 005/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin with retry Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- .../handlers/src/hostIf_IARM_ReqHandler.cpp | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 409858686..020e2f581 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -49,6 +49,7 @@ #define X_RDK_RFC_DEEPSLEEP_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Power.DeepSleepNotification.Enable" #define RETRYSLEEP 300 // +static bool IsPwrCtlInt = false; static bool TR69_HostIf_Mgr_Init(); static bool TR69_HostIf_Mgr_Connect(); static bool TR69_HostIf_Mgr_Get_RegisterCall(); @@ -92,7 +93,7 @@ bool hostIf_IARM_IF_Start() return ret; } -void getPwrContInterface() +void hostIf_getPwrContInterface() { RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); while(true) @@ -100,7 +101,8 @@ void getPwrContInterface() if(POWER_CONTROLLER_ERROR_NONE == PowerController_Connect()) { hostIf_DeviceInfo::getInstance(0)->setPowerConInterface(true); - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Got the powercontroller interface..\n", __FUNCTION__, __FILE__); + IsPwrCtlInt = true; + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Got the powercontroller interface.. IsPwrCtlInt = %s\n", __FUNCTION__, __FILE__ , (IsPwrCtlInt?"true":"false")); break; } RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Retry after %d usec..\n", __FUNCTION__, __FILE__, RETRYSLEEP); @@ -135,7 +137,7 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); PowerController_Init(); // Get powercontroller thunder client interface in separate thread - std::thread pwrThread(getPwrContInterface); + std::thread pwrThread(hostIf_getPwrContInterface); if(pwrThread.joinable()) { RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: created getPwrContInterface thread.. \n", __FUNCTION__, __LINE__); @@ -313,10 +315,20 @@ static IARM_Result_t tr69hostIfMgr_Stop(void) RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Failed to IARM_Bus_Term(), return with Error code: %d\n", __FUNCTION__, err); } - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Term().. \n", __FUNCTION__, __LINE__); - PowerController_Term(); - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Term().. \n", __FUNCTION__, __LINE__); + if (IsPwrCtlInt) + { + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Registering power mode change callback..\n", __FUNCTION__, __FILE__); + PowerController_UnRegisterPowerModeChangedCallback(_hostIf_EventHandler, nullptr); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Registered power mode change callback..\n", __FUNCTION__, __FILE__); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Term().. \n", __FUNCTION__, __LINE__); + PowerController_Term(); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Term().. \n", __FUNCTION__, __LINE__); + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: No PowerController interface .. IsPwrCtlInt = %d\n", __FUNCTION__, __LINE__, IsPwrCtlInt); + } RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return err; } From 55b2dcf5c4b7428cdaa245cf7a78b7b785aadd98 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Wed, 12 Mar 2025 14:36:14 +0000 Subject: [PATCH 006/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 2 +- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 020e2f581..b599adcb6 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -318,7 +318,7 @@ static IARM_Result_t tr69hostIfMgr_Stop(void) if (IsPwrCtlInt) { RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Registering power mode change callback..\n", __FUNCTION__, __FILE__); - PowerController_UnRegisterPowerModeChangedCallback(_hostIf_EventHandler, nullptr); + PowerController_UnRegisterPowerModeChangedCallback(_hostIf_EventHandler); RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Registered power mode change callback..\n", __FUNCTION__, __FILE__); RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Term().. \n", __FUNCTION__, __LINE__); diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 19667a202..e4c396195 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -93,6 +93,8 @@ #include "hostIf_NotificationHandler.h" #include "safec_lib.h" +#include "power_controller.h" + #define VERSION_FILE "/version.txt" #define SOC_ID_FILE "/var/log/socprov.log" #define PREFERRED_GATEWAY_FILE "/opt/prefered-gateway" @@ -1434,7 +1436,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData void hostIf_DeviceInfo::setPowerConInterface( bool isPwrContEnalbe) { - hostIf_DeviceInfo::bPowerControllerEnable = isPwrContEnalbe; + bPowerControllerEnable = isPwrContEnalbe; } /** @@ -1458,7 +1460,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_Ms int str_len = 0; PowerController_PowerState_t curState = POWER_STATE_UNKNOWN, previousState = POWER_STATE_UNKNOWN; - if(hostIf_DeviceInfo::bPowerControllerEnable) { + if(bPowerControllerEnable) { pwr_ret = PowerController_GetPowerState(&curState, &previousState); if (0 == pwr_ret) { @@ -1488,7 +1490,8 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_Ms } else { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d \n", hostIf_DeviceInfo::bPowerControllerEnable); + //RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d \n", hostIf_DeviceInfo::bPowerControllerEnable); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d \n", bPowerControllerEnable); } //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); From 6542d9ffa4202818c78c4a5a569c1b594a8aa15c Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 13 Mar 2025 01:48:38 +0000 Subject: [PATCH 007/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 4 ++++ src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 8 +++++--- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h | 2 -- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index b599adcb6..2e4437f64 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -324,6 +324,10 @@ static IARM_Result_t tr69hostIfMgr_Stop(void) RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Term().. \n", __FUNCTION__, __LINE__); PowerController_Term(); RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Term().. \n", __FUNCTION__, __LINE__); + hostIf_DeviceInfo::getInstance(0)->setPowerConInterface(false); + IsPwrCtlInt = false; + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: setPowerConInterface flag to false. and IsPwrCtlInt=%s\n", __FUNCTION__, __LINE__, (IsPwrCtlInt?"true":"false")); + } else { diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index e4c396195..635a568bf 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -153,6 +153,8 @@ XRFCStorage hostIf_DeviceInfo::m_rfcStorage; XBSStore* hostIf_DeviceInfo::m_bsStore; string hostIf_DeviceInfo::m_xrPollingAction = "0"; +static bool bPowerControllerEnable; + /****************************************************************************************************************************************************/ // Device.DeviceInfo Profile. Getters: /****************************************************************************************************************************************************/ @@ -1490,11 +1492,11 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_Ms } else { - //RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d \n", hostIf_DeviceInfo::bPowerControllerEnable); - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d \n", bPowerControllerEnable); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Powercontroller Interface failed : %d. Try after sometime. \n", bPowerControllerEnable); + ret = NOK; } - //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); return ret; } diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 1286ed6ff..78c2227f2 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -252,8 +252,6 @@ class hostIf_DeviceInfo { std::string m_strXOpsDevManageableNotification; std::string m_strXOpsRPCFwDwldStartedNotification; bool m_bXOpsRPCFwDwldCompletedNotification; - - static bool bPowerControllerEnable; string getEstbIp(); bool isRsshactive(); From 88334fc027cb2b95702e7a3120bc971568958c52 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 13 Mar 2025 13:57:38 +0000 Subject: [PATCH 008/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- tr69hostif.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tr69hostif.service b/tr69hostif.service index 5152d8775..358b60bfe 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -18,7 +18,7 @@ ########################################################################## [Unit] Description=TR69 Host Interface Daemon -After=lighttpd.service securemount.service dsmgr.service +After=wpeframework-powermanager.service lighttpd.service securemount.service dsmgr.service [Service] Type=notify From c38f2339a471fe0aad119ab9e1d301b6bd3ef909 Mon Sep 17 00:00:00 2001 From: Saranya Date: Mon, 17 Mar 2025 04:36:46 +0000 Subject: [PATCH 009/161] RDK-56084 : Replace Script with rdm-agent for RRD Dynamic Profile --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index fb1ef8c4e..380bd963f 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -5101,7 +5101,6 @@ int hostIf_DeviceInfo::get_X_RDK_FirmwareName(HOSTIF_MsgData_t * stMsgData) int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t * stMsgData) { int ret = NOK; - const char *rdm_comm = "/etc/rdm/rdmBundleMgr.sh"; RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering..\n", __FUNCTION__ ); @@ -5110,9 +5109,9 @@ int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t * return NOK; } - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Executing command - sh %s %s & \n", __FUNCTION__ , rdm_comm, stMsgData->paramValue); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Performing Download for %s \n", __FUNCTION__ , stMsgData->paramValue); - ret = v_secure_system("backgroundrun sh %s %s", rdm_comm, stMsgData->paramValue); + ret = v_secure_system("rdm -c %s &", stMsgData->paramValue); if (ret != 0) { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Failed to execute the command. Returned error code '%d'\n", __FUNCTION__, ret); From 7be347e45ee481fee56465dc2e3c49d86b40171c Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Mon, 17 Mar 2025 07:03:05 +0000 Subject: [PATCH 010/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 2e4437f64..2a26c3b09 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -47,7 +47,7 @@ #include "safec_lib.h" #define X_RDK_RFC_DEEPSLEEP_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Power.DeepSleepNotification.Enable" -#define RETRYSLEEP 300 // +#define RETRYSLEEP (300 * 1000) //Retry sleep static bool IsPwrCtlInt = false; static bool TR69_HostIf_Mgr_Init(); From 75169542388d3f65e7a8fa615d31917f64a9474b Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Mon, 17 Mar 2025 07:28:44 +0000 Subject: [PATCH 011/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Fixing L1 test error. Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/Makefile.am | 1 + src/unittest/stubs/power_controller.h | 142 +++++++++++++++++++------- 2 files changed, 108 insertions(+), 35 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 24fab1a3b..ec74964db 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,6 +98,7 @@ AM_LDFLAGS = $(GLIB_LDFLAGS) $(GLIB_LIBS) \ -lds -ldshalcli endif +AM_LDFLAGS += -lWPEFrameworkPowerController AM_CFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) diff --git a/src/unittest/stubs/power_controller.h b/src/unittest/stubs/power_controller.h index 8ecad407d..e147e53a6 100644 --- a/src/unittest/stubs/power_controller.h +++ b/src/unittest/stubs/power_controller.h @@ -22,6 +22,18 @@ #include #include +#undef EXTERNAL +#if defined(WIN32) || defined(_WINDOWS) || defined (__CYGWIN__) || defined(_WIN64) +#ifdef DEVICEINFO_EXPORTS +#define EXTERNAL __declspec(dllexport) +#else +#define EXTERNAL __declspec(dllimport) +#pragma comment(lib, "deviceinfo.lib") +#endif +#else +#define EXTERNAL __attribute__((visibility("default"))) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -96,10 +108,33 @@ typedef enum PowerController_SystemMode { * @details * - If the Power Controller instance does not already exist, it will be created. * - The instance count is incremented each time this function is called. + * - After Init, & before making any PowerController request client needs to ensure + * - Power Manager plugin is activated and operational via `PowerController_IsOperational`. + * - If not operational, clients can use this Connect API to establish COM-RPC connection with the Power Manager plugin. + * - If there us any failure in Connect all PowerController requests will fail with `POWER_CONTROLLER_ERROR_UNAVAILABLE` (Except for callback register / unregister APIs). * * @see PowerController_Term */ -void PowerController_Init(); +EXTERNAL void PowerController_Init(); + +/** + * @brief PowerController attempts to connect to the Power Manager plugin. + * + * This function connects to the Power Manager plugin. + * + * @details + * - This function is used to connect to the Power Manager plugin. + * - Before making any PowerController request client needs to ensure + * - Power Manager plugin is activated and operational via `PowerController_IsOperational`. + * - If not operational, clients can use this Connect API to establish COM-RPC connection with the Power Manager plugin. + * - If there us any failure in Connect all PowerController requests will fail with `POWER_CONTROLLER_ERROR_UNAVAILABLE` (Except for callback register / unregister APIs). + * - In case of failure this API should be called again with brief delay. + * + * @return `POWER_CONTROLLER_ERROR_NONE` on success. + * @return `POWER_CONTROLLER_ERROR_UNAVAILABLE` if Thunder RPC server is not running / error establishing RPC communication channel. + * @return `POWER_CONTROLLER_ERROR_NOT_EXIST` if the PowerManager plugin is not activated yet. + */ +EXTERNAL uint32_t PowerController_Connect(); /** * @brief Terminates the Power Controller. @@ -113,7 +148,7 @@ void PowerController_Init(); * * @see PowerController_Init */ -void PowerController_Term(); +EXTERNAL void PowerController_Term(); /** * @brief Checks if the Power Manager plugin is active & operational @@ -121,6 +156,8 @@ void PowerController_Term(); * This function determines whether the Power Manager interface is operational and ready to handle requests. * It can be used to verify the availability of the Power Manager client before initiating operations that depend on it. * + * IMPORTANT - This is the first function that should be called after `PowerController_Init`. + * * @return `true` if the Power Manager interface is active and operational, otherwise `false`. * * @details @@ -128,16 +165,17 @@ void PowerController_Term(); * - Calling this function is NOT MANDATORY but optional * - Clients can register for notifications about state changes using `PowerController_RegisterOperationalStateChangeCallback`. * - If the Power Manager interface is not active, subsequent Power Manager operations will fail with the error `POWER_CONTROLLER_ERROR_UNAVAILABLE`. + * - Therefore in failure cases, clients can use `PowerController_Connect` to establish COM-RPC connection with the Power Manager plugin. * * @see PowerController_RegisterOperationalStateChangeCallback */ -bool PowerController_IsOperational(); +EXTERNAL bool PowerController_IsOperational(); /** Gets the Power State.*/ // @text getPowerState // @brief Get Power State // @param powerState: Get current power state -uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState /* @out */, PowerController_PowerState_t* previousState /* @out */); +EXTERNAL uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState /* @out */, PowerController_PowerState_t* previousState /* @out */); /** Sets Power State . */ // @text setPowerState @@ -145,62 +183,62 @@ uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentStat // @param keyCode: NA for most platfroms, to be depricated // @param powerState: Set power to this state // @param reason: null terminated string stating reason for for state change -uint32_t PowerController_SetPowerState(const int keyCode /* @in */, const PowerController_PowerState_t powerstate /* @in */, const char* reason /* @in */); +EXTERNAL uint32_t PowerController_SetPowerState(const int keyCode /* @in */, const PowerController_PowerState_t powerstate /* @in */, const char* reason /* @in */); /** Gets the current Thermal state.*/ // @text getThermalState // @brief Get Current Thermal State (temperature) // @param currentTemperature: current temperature -uint32_t PowerController_GetThermalState(float* currentTemperature /* @out */); +EXTERNAL uint32_t PowerController_GetThermalState(float* currentTemperature /* @out */); /** Sets the Temperature Thresholds.*/ // @text setTemperatureThresholds // @brief Set Temperature Thresholds // @param high: high threshold // @param critical : critical threshold -uint32_t PowerController_SetTemperatureThresholds(float high /* @in */, float critical /* @in */); +EXTERNAL uint32_t PowerController_SetTemperatureThresholds(float high /* @in */, float critical /* @in */); /** Gets the current Temperature Thresholds.*/ // @text getTemperatureThresholds // @brief Get Temperature Thresholds // @param high: high threshold // @param critical : critical threshold -uint32_t PowerController_GetTemperatureThresholds(float* high /* @out */, float* critical /* @out */); +EXTERNAL uint32_t PowerController_GetTemperatureThresholds(float* high /* @out */, float* critical /* @out */); /** Sets the current Temperature Grace interval.*/ // @property // @text PowerController_SetOvertempGraceInterval // @brief Set Temperature Thresholds // @param graceInterval: interval in secs? -uint32_t PowerController_SetOvertempGraceInterval(const int graceInterval /* @in */); +EXTERNAL uint32_t PowerController_SetOvertempGraceInterval(const int graceInterval /* @in */); /** Gets the grace interval for over-temperature.*/ // @property // @text PowerController_GetOvertempGraceInterval // @brief Get Temperature Grace interval // @param graceInterval: interval in secs? -uint32_t PowerController_GetOvertempGraceInterval(int* graceInterval /* @out */); +EXTERNAL uint32_t PowerController_GetOvertempGraceInterval(int* graceInterval /* @out */); /** Set Deep Sleep Timer for later wakeup */ // @property // @text setDeepSleepTimer // @brief Set Deep sleep timer for timeOut period // @param timeOut: deep sleep timeout -uint32_t PowerController_SetDeepSleepTimer(const int timeOut /* @in */); +EXTERNAL uint32_t PowerController_SetDeepSleepTimer(const int timeOut /* @in */); /** Get Last Wakeup reason */ // @property // @text getLastWakeupReason // @brief Get Last Wake up reason // @param wakeupReason: wake up reason -uint32_t PowerController_GetLastWakeupReason(PowerController_WakeupReason_t* wakeupReason /* @out */); +EXTERNAL uint32_t PowerController_GetLastWakeupReason(PowerController_WakeupReason_t* wakeupReason /* @out */); /** Get Last Wakeup key code */ // @property // @text getLastWakeupKeyCode // @brief Get the key code that can be used for wakeup // @param keycode: Key code for wakeup -uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); +EXTERNAL uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); /** Request Reboot with PowerManager */ // @text reboot @@ -208,20 +246,20 @@ uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); // @param rebootRequestor: null terminated string identifier for the entity requesting the reboot. // @param rebootReasonCustom: custom-defined reason for the reboot, provided as a null terminated string. // @param rebootReasonOther: null terminated string describing any other reasons for the reboot. -uint32_t PowerController_Reboot(const char* rebootRequestor /* @in */, const char* rebootReasonCustom /* @in */, const char* rebootReasonOther /* @in */); +EXTERNAL uint32_t PowerController_Reboot(const char* rebootRequestor /* @in */, const char* rebootReasonCustom /* @in */, const char* rebootReasonOther /* @in */); /** Set Network Standby Mode */ // @property // @text setNetworkStandbyMode // @brief Set the standby mode for Network // @param standbyMode: Network standby mode -uint32_t PowerController_SetNetworkStandbyMode(const bool standbyMode /* @in */); +EXTERNAL uint32_t PowerController_SetNetworkStandbyMode(const bool standbyMode /* @in */); /** Get Network Standby Mode */ // @text getNetworkStandbyMode // @brief Get the standby mode for Network // @param standbyMode: Network standby mode -uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); +EXTERNAL uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); /** Set Wakeup source configuration */ // @text setWakeupSrcConfig @@ -229,7 +267,7 @@ uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); // @param powerMode: power mode // @param wakeSrcType: source type // @param config: config -uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const int wakeSrcType /* @in */, int config /* @in */); +EXTERNAL uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const int wakeSrcType /* @in */, int config /* @in */); /** Get Wakeup source configuration */ // @text getWakeupSrcConfig @@ -237,61 +275,95 @@ uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const // @param powerMode: power mode // @param srcType: source type // @param config: config -uint32_t PowerController_GetWakeupSrcConfig(int* powerMode /* @out */, int* srcType /* @out */, int* config /* @out */); +EXTERNAL uint32_t PowerController_GetWakeupSrcConfig(int* powerMode /* @out */, int* srcType /* @out */, int* config /* @out */); /** Initiate System mode change */ // @text PowerController_SetSystemMode // @brief System mode change // @param oldMode: current mode // @param newMode: new mode -uint32_t PowerController_SetSystemMode(const PowerController_SystemMode_t currentMode /* @in */, const PowerController_SystemMode_t newMode /* @in */); +EXTERNAL uint32_t PowerController_SetSystemMode(const PowerController_SystemMode_t currentMode /* @in */, const PowerController_SystemMode_t newMode /* @in */); /** Get Power State before last reboot */ // @text PowerController_GetPowerStateBeforeReboot // @brief Get Power state before last reboot // @param powerStateBeforeReboot: power state -uint32_t PowerController_GetPowerStateBeforeReboot(PowerController_PowerState_t* powerStateBeforeReboot /* @out */); +EXTERNAL uint32_t PowerController_GetPowerStateBeforeReboot(PowerController_PowerState_t* powerStateBeforeReboot /* @out */); /* Callback data types for event notifications from power manager plugin */ + +// @brief Operational state changed event +// @param isOperational: true if PowerManager plugin is activated, false otherwise +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_OperationalStateChangeCb)(bool isOperational, void* userdata); + +// @brief Power mode changed +// @param currentState: Current Power State +// @param newState: New Power State +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_PowerModeChangedCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); + +// @brief Power mode Pre-change event +// @param currentState: Current Power State +// @param newState: Changing power state to this New Power State +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_PowerModePreChangeCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); + +// @brief Deep sleep timeout event +// @param wakeupTimeout: Deep sleep wakeup timeout in seconds +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_DeepSleepTimeoutCb)(const int wakeupTimeout, void* userdata); + +// @brief Network Standby Mode changed event - only on XIone +// @param enabled: network standby enabled or disabled +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_NetworkStandbyModeChangedCb)(const bool enabled, void* userdata); + +// @brief Thermal Mode changed event +// @param currentThermalLevel: current thermal level +// @param newThermalLevel: new thermal level +// @param currentTemperature: current temperature +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_ThermalModeChangedCb)(const PowerController_ThermalTemperature_t currentThermalLevel, const PowerController_ThermalTemperature_t newThermalLevel, const float currentTemperature, void* userdata); + +// @brief Reboot begin event +// @param rebootReasonCustom: Reboot reason custom +// @param rebootReasonOther: Reboot reason other +// @param rebootRequestor: Reboot requested by +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_RebootBeginCb)(const char* rebootReasonCustom, const char* rebootReasonOther, const char* rebootRequestor, void* userdata); /* Type defines for callbacks / notifications */ -/* userdata in all callbacks are opque, clients can use to have context to callbacks */ +/* userdata in all callbacks are opaque, clients can use it to have context to callbacks */ /** Register for PowerManager plugin operational state change event callback, for initial state use `PowerController_IsOperational` call */ -uint32_t PowerController_RegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback, void* userdata); /** UnRegister (previously registered) PowerManager plugin operational state change event callback */ -uint32_t PowerController_UnRegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback); +EXTERNAL uint32_t PowerController_UnRegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback); /** Register for PowerMode changed callback */ -uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata); /** UnRegister (previously registered) PowerMode changed callback */ -uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback); +EXTERNAL uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback); /** Register for PowerMode pre-change callback */ -uint32_t PowerController_RegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback, void* userdata); /** UnRegister (previously registered) PowerMode pre-change callback */ -uint32_t PowerController_UnRegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback); +EXTERNAL uint32_t PowerController_UnRegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback); /** Register for PowerMode pre-change callback */ -uint32_t PowerController_RegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback, void* userdata); /** UnRegister (previously registered) DeepSleep Timeout callback */ -uint32_t PowerController_UnRegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback); +EXTERNAL uint32_t PowerController_UnRegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback); /** Register for Network Standby Mode changed event - only on XIone */ -uint32_t PowerController_RegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback, void* userdata); /** UnRegister (previously registered) Network Standby Mode changed callback */ -uint32_t PowerController_UnRegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback); +EXTERNAL uint32_t PowerController_UnRegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback); /** Register for Thermal Mode changed event callback */ -uint32_t PowerController_RegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback, void* userdata); /** UnRegister (previously registered) Thermal Mode changed event callback */ -uint32_t PowerController_UnRegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback); +EXTERNAL uint32_t PowerController_UnRegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback); /** Register for reboot start event callback */ -uint32_t PowerController_RegisterRebootBeginCallback(PowerController_RebootBeginCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterRebootBeginCallback(PowerController_RebootBeginCb callback, void* userdata); /** UnRegister (previously registered) reboot start event callback */ -uint32_t PowerController_UnRegisterRebootBeginCallback(PowerController_RebootBeginCb callback); +EXTERNAL uint32_t PowerController_UnRegisterRebootBeginCallback(PowerController_RebootBeginCb callback); #ifdef __cplusplus }; // extern "C" From 828a5432517dd335320cf46ab09d38d93df42a33 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Mon, 17 Mar 2025 07:28:44 +0000 Subject: [PATCH 012/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Fixing L1 test error. Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/Makefile.am | 1 + .../profiles/DeviceInfo/gtest/Makefile.am | 2 + src/unittest/stubs/power_controller.h | 142 +++++++++++++----- 3 files changed, 110 insertions(+), 35 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 24fab1a3b..ec74964db 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,6 +98,7 @@ AM_LDFLAGS = $(GLIB_LDFLAGS) $(GLIB_LIBS) \ -lds -ldshalcli endif +AM_LDFLAGS += -lWPEFrameworkPowerController AM_CFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) diff --git a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am index 4612c850b..b3829b0a2 100755 --- a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am +++ b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am @@ -36,6 +36,8 @@ if LIBSOUP3_ENABLE COMMON_LDADD += -lsoup-3.0 endif +COMMON_LDADD += -lWPEFrameworkPowerController + # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/unittest/stubs/power_controller.h b/src/unittest/stubs/power_controller.h index 8ecad407d..e147e53a6 100644 --- a/src/unittest/stubs/power_controller.h +++ b/src/unittest/stubs/power_controller.h @@ -22,6 +22,18 @@ #include #include +#undef EXTERNAL +#if defined(WIN32) || defined(_WINDOWS) || defined (__CYGWIN__) || defined(_WIN64) +#ifdef DEVICEINFO_EXPORTS +#define EXTERNAL __declspec(dllexport) +#else +#define EXTERNAL __declspec(dllimport) +#pragma comment(lib, "deviceinfo.lib") +#endif +#else +#define EXTERNAL __attribute__((visibility("default"))) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -96,10 +108,33 @@ typedef enum PowerController_SystemMode { * @details * - If the Power Controller instance does not already exist, it will be created. * - The instance count is incremented each time this function is called. + * - After Init, & before making any PowerController request client needs to ensure + * - Power Manager plugin is activated and operational via `PowerController_IsOperational`. + * - If not operational, clients can use this Connect API to establish COM-RPC connection with the Power Manager plugin. + * - If there us any failure in Connect all PowerController requests will fail with `POWER_CONTROLLER_ERROR_UNAVAILABLE` (Except for callback register / unregister APIs). * * @see PowerController_Term */ -void PowerController_Init(); +EXTERNAL void PowerController_Init(); + +/** + * @brief PowerController attempts to connect to the Power Manager plugin. + * + * This function connects to the Power Manager plugin. + * + * @details + * - This function is used to connect to the Power Manager plugin. + * - Before making any PowerController request client needs to ensure + * - Power Manager plugin is activated and operational via `PowerController_IsOperational`. + * - If not operational, clients can use this Connect API to establish COM-RPC connection with the Power Manager plugin. + * - If there us any failure in Connect all PowerController requests will fail with `POWER_CONTROLLER_ERROR_UNAVAILABLE` (Except for callback register / unregister APIs). + * - In case of failure this API should be called again with brief delay. + * + * @return `POWER_CONTROLLER_ERROR_NONE` on success. + * @return `POWER_CONTROLLER_ERROR_UNAVAILABLE` if Thunder RPC server is not running / error establishing RPC communication channel. + * @return `POWER_CONTROLLER_ERROR_NOT_EXIST` if the PowerManager plugin is not activated yet. + */ +EXTERNAL uint32_t PowerController_Connect(); /** * @brief Terminates the Power Controller. @@ -113,7 +148,7 @@ void PowerController_Init(); * * @see PowerController_Init */ -void PowerController_Term(); +EXTERNAL void PowerController_Term(); /** * @brief Checks if the Power Manager plugin is active & operational @@ -121,6 +156,8 @@ void PowerController_Term(); * This function determines whether the Power Manager interface is operational and ready to handle requests. * It can be used to verify the availability of the Power Manager client before initiating operations that depend on it. * + * IMPORTANT - This is the first function that should be called after `PowerController_Init`. + * * @return `true` if the Power Manager interface is active and operational, otherwise `false`. * * @details @@ -128,16 +165,17 @@ void PowerController_Term(); * - Calling this function is NOT MANDATORY but optional * - Clients can register for notifications about state changes using `PowerController_RegisterOperationalStateChangeCallback`. * - If the Power Manager interface is not active, subsequent Power Manager operations will fail with the error `POWER_CONTROLLER_ERROR_UNAVAILABLE`. + * - Therefore in failure cases, clients can use `PowerController_Connect` to establish COM-RPC connection with the Power Manager plugin. * * @see PowerController_RegisterOperationalStateChangeCallback */ -bool PowerController_IsOperational(); +EXTERNAL bool PowerController_IsOperational(); /** Gets the Power State.*/ // @text getPowerState // @brief Get Power State // @param powerState: Get current power state -uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState /* @out */, PowerController_PowerState_t* previousState /* @out */); +EXTERNAL uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState /* @out */, PowerController_PowerState_t* previousState /* @out */); /** Sets Power State . */ // @text setPowerState @@ -145,62 +183,62 @@ uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentStat // @param keyCode: NA for most platfroms, to be depricated // @param powerState: Set power to this state // @param reason: null terminated string stating reason for for state change -uint32_t PowerController_SetPowerState(const int keyCode /* @in */, const PowerController_PowerState_t powerstate /* @in */, const char* reason /* @in */); +EXTERNAL uint32_t PowerController_SetPowerState(const int keyCode /* @in */, const PowerController_PowerState_t powerstate /* @in */, const char* reason /* @in */); /** Gets the current Thermal state.*/ // @text getThermalState // @brief Get Current Thermal State (temperature) // @param currentTemperature: current temperature -uint32_t PowerController_GetThermalState(float* currentTemperature /* @out */); +EXTERNAL uint32_t PowerController_GetThermalState(float* currentTemperature /* @out */); /** Sets the Temperature Thresholds.*/ // @text setTemperatureThresholds // @brief Set Temperature Thresholds // @param high: high threshold // @param critical : critical threshold -uint32_t PowerController_SetTemperatureThresholds(float high /* @in */, float critical /* @in */); +EXTERNAL uint32_t PowerController_SetTemperatureThresholds(float high /* @in */, float critical /* @in */); /** Gets the current Temperature Thresholds.*/ // @text getTemperatureThresholds // @brief Get Temperature Thresholds // @param high: high threshold // @param critical : critical threshold -uint32_t PowerController_GetTemperatureThresholds(float* high /* @out */, float* critical /* @out */); +EXTERNAL uint32_t PowerController_GetTemperatureThresholds(float* high /* @out */, float* critical /* @out */); /** Sets the current Temperature Grace interval.*/ // @property // @text PowerController_SetOvertempGraceInterval // @brief Set Temperature Thresholds // @param graceInterval: interval in secs? -uint32_t PowerController_SetOvertempGraceInterval(const int graceInterval /* @in */); +EXTERNAL uint32_t PowerController_SetOvertempGraceInterval(const int graceInterval /* @in */); /** Gets the grace interval for over-temperature.*/ // @property // @text PowerController_GetOvertempGraceInterval // @brief Get Temperature Grace interval // @param graceInterval: interval in secs? -uint32_t PowerController_GetOvertempGraceInterval(int* graceInterval /* @out */); +EXTERNAL uint32_t PowerController_GetOvertempGraceInterval(int* graceInterval /* @out */); /** Set Deep Sleep Timer for later wakeup */ // @property // @text setDeepSleepTimer // @brief Set Deep sleep timer for timeOut period // @param timeOut: deep sleep timeout -uint32_t PowerController_SetDeepSleepTimer(const int timeOut /* @in */); +EXTERNAL uint32_t PowerController_SetDeepSleepTimer(const int timeOut /* @in */); /** Get Last Wakeup reason */ // @property // @text getLastWakeupReason // @brief Get Last Wake up reason // @param wakeupReason: wake up reason -uint32_t PowerController_GetLastWakeupReason(PowerController_WakeupReason_t* wakeupReason /* @out */); +EXTERNAL uint32_t PowerController_GetLastWakeupReason(PowerController_WakeupReason_t* wakeupReason /* @out */); /** Get Last Wakeup key code */ // @property // @text getLastWakeupKeyCode // @brief Get the key code that can be used for wakeup // @param keycode: Key code for wakeup -uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); +EXTERNAL uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); /** Request Reboot with PowerManager */ // @text reboot @@ -208,20 +246,20 @@ uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); // @param rebootRequestor: null terminated string identifier for the entity requesting the reboot. // @param rebootReasonCustom: custom-defined reason for the reboot, provided as a null terminated string. // @param rebootReasonOther: null terminated string describing any other reasons for the reboot. -uint32_t PowerController_Reboot(const char* rebootRequestor /* @in */, const char* rebootReasonCustom /* @in */, const char* rebootReasonOther /* @in */); +EXTERNAL uint32_t PowerController_Reboot(const char* rebootRequestor /* @in */, const char* rebootReasonCustom /* @in */, const char* rebootReasonOther /* @in */); /** Set Network Standby Mode */ // @property // @text setNetworkStandbyMode // @brief Set the standby mode for Network // @param standbyMode: Network standby mode -uint32_t PowerController_SetNetworkStandbyMode(const bool standbyMode /* @in */); +EXTERNAL uint32_t PowerController_SetNetworkStandbyMode(const bool standbyMode /* @in */); /** Get Network Standby Mode */ // @text getNetworkStandbyMode // @brief Get the standby mode for Network // @param standbyMode: Network standby mode -uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); +EXTERNAL uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); /** Set Wakeup source configuration */ // @text setWakeupSrcConfig @@ -229,7 +267,7 @@ uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); // @param powerMode: power mode // @param wakeSrcType: source type // @param config: config -uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const int wakeSrcType /* @in */, int config /* @in */); +EXTERNAL uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const int wakeSrcType /* @in */, int config /* @in */); /** Get Wakeup source configuration */ // @text getWakeupSrcConfig @@ -237,61 +275,95 @@ uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const // @param powerMode: power mode // @param srcType: source type // @param config: config -uint32_t PowerController_GetWakeupSrcConfig(int* powerMode /* @out */, int* srcType /* @out */, int* config /* @out */); +EXTERNAL uint32_t PowerController_GetWakeupSrcConfig(int* powerMode /* @out */, int* srcType /* @out */, int* config /* @out */); /** Initiate System mode change */ // @text PowerController_SetSystemMode // @brief System mode change // @param oldMode: current mode // @param newMode: new mode -uint32_t PowerController_SetSystemMode(const PowerController_SystemMode_t currentMode /* @in */, const PowerController_SystemMode_t newMode /* @in */); +EXTERNAL uint32_t PowerController_SetSystemMode(const PowerController_SystemMode_t currentMode /* @in */, const PowerController_SystemMode_t newMode /* @in */); /** Get Power State before last reboot */ // @text PowerController_GetPowerStateBeforeReboot // @brief Get Power state before last reboot // @param powerStateBeforeReboot: power state -uint32_t PowerController_GetPowerStateBeforeReboot(PowerController_PowerState_t* powerStateBeforeReboot /* @out */); +EXTERNAL uint32_t PowerController_GetPowerStateBeforeReboot(PowerController_PowerState_t* powerStateBeforeReboot /* @out */); /* Callback data types for event notifications from power manager plugin */ + +// @brief Operational state changed event +// @param isOperational: true if PowerManager plugin is activated, false otherwise +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_OperationalStateChangeCb)(bool isOperational, void* userdata); + +// @brief Power mode changed +// @param currentState: Current Power State +// @param newState: New Power State +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_PowerModeChangedCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); + +// @brief Power mode Pre-change event +// @param currentState: Current Power State +// @param newState: Changing power state to this New Power State +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_PowerModePreChangeCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); + +// @brief Deep sleep timeout event +// @param wakeupTimeout: Deep sleep wakeup timeout in seconds +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_DeepSleepTimeoutCb)(const int wakeupTimeout, void* userdata); + +// @brief Network Standby Mode changed event - only on XIone +// @param enabled: network standby enabled or disabled +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_NetworkStandbyModeChangedCb)(const bool enabled, void* userdata); + +// @brief Thermal Mode changed event +// @param currentThermalLevel: current thermal level +// @param newThermalLevel: new thermal level +// @param currentTemperature: current temperature +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_ThermalModeChangedCb)(const PowerController_ThermalTemperature_t currentThermalLevel, const PowerController_ThermalTemperature_t newThermalLevel, const float currentTemperature, void* userdata); + +// @brief Reboot begin event +// @param rebootReasonCustom: Reboot reason custom +// @param rebootReasonOther: Reboot reason other +// @param rebootRequestor: Reboot requested by +// @param userdata: opaque data, client can use it to have context to callbacks typedef void (*PowerController_RebootBeginCb)(const char* rebootReasonCustom, const char* rebootReasonOther, const char* rebootRequestor, void* userdata); /* Type defines for callbacks / notifications */ -/* userdata in all callbacks are opque, clients can use to have context to callbacks */ +/* userdata in all callbacks are opaque, clients can use it to have context to callbacks */ /** Register for PowerManager plugin operational state change event callback, for initial state use `PowerController_IsOperational` call */ -uint32_t PowerController_RegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback, void* userdata); /** UnRegister (previously registered) PowerManager plugin operational state change event callback */ -uint32_t PowerController_UnRegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback); +EXTERNAL uint32_t PowerController_UnRegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback); /** Register for PowerMode changed callback */ -uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata); /** UnRegister (previously registered) PowerMode changed callback */ -uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback); +EXTERNAL uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback); /** Register for PowerMode pre-change callback */ -uint32_t PowerController_RegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback, void* userdata); /** UnRegister (previously registered) PowerMode pre-change callback */ -uint32_t PowerController_UnRegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback); +EXTERNAL uint32_t PowerController_UnRegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback); /** Register for PowerMode pre-change callback */ -uint32_t PowerController_RegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback, void* userdata); /** UnRegister (previously registered) DeepSleep Timeout callback */ -uint32_t PowerController_UnRegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback); +EXTERNAL uint32_t PowerController_UnRegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback); /** Register for Network Standby Mode changed event - only on XIone */ -uint32_t PowerController_RegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback, void* userdata); /** UnRegister (previously registered) Network Standby Mode changed callback */ -uint32_t PowerController_UnRegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback); +EXTERNAL uint32_t PowerController_UnRegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback); /** Register for Thermal Mode changed event callback */ -uint32_t PowerController_RegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback, void* userdata); /** UnRegister (previously registered) Thermal Mode changed event callback */ -uint32_t PowerController_UnRegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback); +EXTERNAL uint32_t PowerController_UnRegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback); /** Register for reboot start event callback */ -uint32_t PowerController_RegisterRebootBeginCallback(PowerController_RebootBeginCb callback, void* userdata); +EXTERNAL uint32_t PowerController_RegisterRebootBeginCallback(PowerController_RebootBeginCb callback, void* userdata); /** UnRegister (previously registered) reboot start event callback */ -uint32_t PowerController_UnRegisterRebootBeginCallback(PowerController_RebootBeginCb callback); +EXTERNAL uint32_t PowerController_UnRegisterRebootBeginCallback(PowerController_RebootBeginCb callback); #ifdef __cplusplus }; // extern "C" From dae04bb7714f383c7f8f8b192a9440127e2aae77 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Tue, 18 Mar 2025 11:54:52 +0000 Subject: [PATCH 013/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/profiles/DeviceInfo/gtest/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am index c5fe415ec..fa5797a1d 100755 --- a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am +++ b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am @@ -36,8 +36,6 @@ if LIBSOUP3_ENABLE COMMON_LDADD += -lsoup-3.0 endif -COMMON_LDADD += -lWPEFrameworkPowerController - # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage From e24041a4a7238e9e344cba96880c3dabd668b8b3 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Tue, 18 Mar 2025 11:54:52 +0000 Subject: [PATCH 014/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Fix L1. update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/profiles/DeviceInfo/gtest/Makefile.am | 2 -- src/unittest/stubs/dm_stubs.cpp | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am index c5fe415ec..fa5797a1d 100755 --- a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am +++ b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am @@ -36,8 +36,6 @@ if LIBSOUP3_ENABLE COMMON_LDADD += -lsoup-3.0 endif -COMMON_LDADD += -lWPEFrameworkPowerController - # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/unittest/stubs/dm_stubs.cpp b/src/unittest/stubs/dm_stubs.cpp index a2788c2e5..fc7a2542c 100644 --- a/src/unittest/stubs/dm_stubs.cpp +++ b/src/unittest/stubs/dm_stubs.cpp @@ -136,6 +136,11 @@ uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_Powe return POWER_CONTROLLER_ERROR_NONE; } +uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState, PowerController_PowerState_t* previousState) +{ + return POWER_CONTROLLER_ERROR_NONE; +} + rbusValue_t rbusValue_Init(rbusValue_t* value) { return NULL; From 89bf58aeea8828adde28a4ff8bf858bbfc642e27 Mon Sep 17 00:00:00 2001 From: Saranya Date: Thu, 20 Mar 2025 08:15:01 +0000 Subject: [PATCH 015/161] RDK-56082: Addressing Review Comments --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 380bd963f..c8dd288d6 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -5109,9 +5109,9 @@ int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t * return NOK; } - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Performing Download for %s \n", __FUNCTION__ , stMsgData->paramValue); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Executing Command rdm %s \n", __FUNCTION__ , stMsgData->paramValue); - ret = v_secure_system("rdm -c %s &", stMsgData->paramValue); + ret = v_secure_system("rdm -v \"%s\" &", stMsgData->paramValue); if (ret != 0) { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Failed to execute the command. Returned error code '%d'\n", __FUNCTION__, ret); From d64755dfcc1bfc9b4ec0daa4f7cd8a40b003c028 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 20 Mar 2025 14:42:52 +0000 Subject: [PATCH 016/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 2a26c3b09..73fe0b184 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -96,6 +96,11 @@ bool hostIf_IARM_IF_Start() void hostIf_getPwrContInterface() { RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + + /*TODO: remove this sleep after fix METROL-1045*/ + sleep(5);//added sleep wait for the WPEframework active. + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); + PowerController_Init(); while(true) { if(POWER_CONTROLLER_ERROR_NONE == PowerController_Connect()) @@ -134,8 +139,6 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## } RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] Success 'IARM_Bus_Init(%s)'.\n", __FUNCTION__, IARM_BUS_TR69HOSTIFMGR_NAME); - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); - PowerController_Init(); // Get powercontroller thunder client interface in separate thread std::thread pwrThread(hostIf_getPwrContInterface); if(pwrThread.joinable()) From da7168c6249f5c7e7d8ad8de5298efadf7ae4544 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 20 Mar 2025 14:55:06 +0000 Subject: [PATCH 017/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- tr69hostif.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tr69hostif.service b/tr69hostif.service index 358b60bfe..5152d8775 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -18,7 +18,7 @@ ########################################################################## [Unit] Description=TR69 Host Interface Daemon -After=wpeframework-powermanager.service lighttpd.service securemount.service dsmgr.service +After=lighttpd.service securemount.service dsmgr.service [Service] Type=notify From 85285c443eaaeecaf89bda32277513b73051af61 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Fri, 21 Mar 2025 05:53:40 +0000 Subject: [PATCH 018/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 73fe0b184..bcfbbe6e4 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -99,8 +99,9 @@ void hostIf_getPwrContInterface() /*TODO: remove this sleep after fix METROL-1045*/ sleep(5);//added sleep wait for the WPEframework active. - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); PowerController_Init(); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Init().. \n", __FUNCTION__, __LINE__); while(true) { if(POWER_CONTROLLER_ERROR_NONE == PowerController_Connect()) @@ -114,7 +115,7 @@ void hostIf_getPwrContInterface() usleep(RETRYSLEEP); //retry after RETRYSLEEP milli seconds. } - RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Registering power mode change callback..\n", __FUNCTION__, __FILE__); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Registering power mode change callback..\n", __FUNCTION__, __FILE__); PowerController_RegisterPowerModeChangedCallback(_hostIf_EventHandler, nullptr); RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Registered power mode change callback..\n", __FUNCTION__, __FILE__); @@ -150,7 +151,6 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: Failed to create getPwrContInterface thread.. \n", __FUNCTION__, __LINE__); } - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Init().. \n", __FUNCTION__, __LINE__); RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return true; From 3b9414cc7ebf46704c7272c9ac448c878b9f4b73 Mon Sep 17 00:00:00 2001 From: vdinak240 Date: Tue, 25 Mar 2025 18:23:58 +0000 Subject: [PATCH 019/161] RDKEMW-2503 : Add RFC to data model- tr69hostif Reason for change: RFC URL for EAA Compliance Test Procedure: Mentioned in ticket Risks: Low Signed-off-by: vdinak240 --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 563a17d8f..ac7167d30 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4351,6 +4351,14 @@ + + + + + + + + From f56c066f49c0f97be48efd3d011ac42136f609dd Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Tue, 25 Mar 2025 21:53:15 -0400 Subject: [PATCH 020/161] 1.0.13 release changelog updates --- CHANGELOG.md | 99 ++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abdab8f40..fcc374a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,74 +4,83 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -#### [1.0.12](https://github.com-venkat0557/rdkcentral/tr69hostif/compare/1.0.11...1.0.12) +#### [1.0.13](https://github.com/rdkcentral/tr69hostif/compare/1.0.12...1.0.13) -- RDKEMW-2308: Secure wrapper API fixes [`#53`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/53) -- Rebase with develop [`#55`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/55) -- RDKEMW-1803: Add debugs for Mutex issue [`#54`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/54) -- Fix libsyswrapper to run in background [`033ce3c`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/033ce3c77f38e3c0b8b80b98b9a8184d942ca0ba) -- Fix libsyswrapper calls [`969dc69`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/969dc69d2bd1ad05f8597b009c91846cee3d7ea1) -- Update Device_IP_Interface_IPv4Address.cpp [`c53c0b8`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/c53c0b8c1b7fb05b9d1d21b7fa1d91222933dcdb) +- RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo [`#60`](https://github.com/rdkcentral/tr69hostif/pull/60) +- rebase topic branch [`#73`](https://github.com/rdkcentral/tr69hostif/pull/73) +- RDKEMW-2621:Default ReserveTTS RFC to true [`#68`](https://github.com/rdkcentral/tr69hostif/pull/68) +- Merge tag '1.0.12' into develop [`97eb199`](https://github.com/rdkcentral/tr69hostif/commit/97eb19993dc0220d362ea5c4602f292397d221ef) -#### [1.0.11](https://github.com-venkat0557/rdkcentral/tr69hostif/compare/1.0.10...1.0.11) +#### [1.0.12](https://github.com/rdkcentral/tr69hostif/compare/1.0.11...1.0.12) + +> 13 March 2025 + +- RDKEMW-2308: Secure wrapper API fixes [`#53`](https://github.com/rdkcentral/tr69hostif/pull/53) +- Rebase with develop [`#55`](https://github.com/rdkcentral/tr69hostif/pull/55) +- RDKEMW-1803: Add debugs for Mutex issue [`#54`](https://github.com/rdkcentral/tr69hostif/pull/54) +- Fix libsyswrapper to run in background [`033ce3c`](https://github.com/rdkcentral/tr69hostif/commit/033ce3c77f38e3c0b8b80b98b9a8184d942ca0ba) +- Fix libsyswrapper calls [`969dc69`](https://github.com/rdkcentral/tr69hostif/commit/969dc69d2bd1ad05f8597b009c91846cee3d7ea1) +- 1.0.12 release changelog updates [`4bd638b`](https://github.com/rdkcentral/tr69hostif/commit/4bd638ba5afb4a88143c18e2452694d14b6703ba) + +#### [1.0.11](https://github.com/rdkcentral/tr69hostif/compare/1.0.10...1.0.11) > 11 March 2025 -- RDK-56444: Define tr181 parameter and handlers for the IUI Version [`#44`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/44) -- Rebase from develop [`#49`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/49) -- RDKEMW-1524: Upgrade tr69hostif to libsoup-3.0 [`#48`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/48) -- Migrate tr69hostif to libsoup3 [`b5d1732`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/b5d173213a18e77e85efd4963af15b00442c701e) -- RDK-56444: Add IUI version as mandatory field [`017f1ee`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/017f1ee6acb556ba6c93b9c60cb3dd993196f32e) -- RDK-56444: Add IUI version as mandatory field [`4c04b1d`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/4c04b1d0ddc61cd292ec4eda19ce543f4d7c41b0) +- RDK-56444: Define tr181 parameter and handlers for the IUI Version [`#44`](https://github.com/rdkcentral/tr69hostif/pull/44) +- Rebase from develop [`#49`](https://github.com/rdkcentral/tr69hostif/pull/49) +- RDKEMW-1524: Upgrade tr69hostif to libsoup-3.0 [`#48`](https://github.com/rdkcentral/tr69hostif/pull/48) +- Migrate tr69hostif to libsoup3 [`b5d1732`](https://github.com/rdkcentral/tr69hostif/commit/b5d173213a18e77e85efd4963af15b00442c701e) +- RDK-56444: Add IUI version as mandatory field [`017f1ee`](https://github.com/rdkcentral/tr69hostif/commit/017f1ee6acb556ba6c93b9c60cb3dd993196f32e) +- RDK-56444: Add IUI version as mandatory field [`4c04b1d`](https://github.com/rdkcentral/tr69hostif/commit/4c04b1d0ddc61cd292ec4eda19ce543f4d7c41b0) -#### [1.0.10](https://github.com-venkat0557/rdkcentral/tr69hostif/compare/1.0.9...1.0.10) +#### [1.0.10](https://github.com/rdkcentral/tr69hostif/compare/1.0.9...1.0.10) > 6 March 2025 -- RDKEMW-1524: Upgrade tr69hostif to libsoup-3.0 [`#16`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/16) -- Rebase from develop [`#37`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/37) -- Rebase from develop [`#24`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/24) -- Rebase with develop [`#17`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/17) -- 1.0.10 release changelog updates [`edd483e`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/edd483ee04648fb081bff93ccc0d0b882653c6ce) -- Merge tag '1.0.9' into develop [`763605c`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/763605c3a2489875062e530327aa801e20ea81ab) -- Update http_server.cpp [`80a5044`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/80a5044813baeea57db9b9d505ac9522226d575d) +- RDKEMW-1524: Upgrade tr69hostif to libsoup-3.0 [`#16`](https://github.com/rdkcentral/tr69hostif/pull/16) +- Rebase from develop [`#37`](https://github.com/rdkcentral/tr69hostif/pull/37) +- Rebase from develop [`#24`](https://github.com/rdkcentral/tr69hostif/pull/24) +- Rebase with develop [`#17`](https://github.com/rdkcentral/tr69hostif/pull/17) +- 1.0.10 release changelog updates [`edd483e`](https://github.com/rdkcentral/tr69hostif/commit/edd483ee04648fb081bff93ccc0d0b882653c6ce) +- Merge tag '1.0.9' into develop [`763605c`](https://github.com/rdkcentral/tr69hostif/commit/763605c3a2489875062e530327aa801e20ea81ab) +- Update http_server.cpp [`80a5044`](https://github.com/rdkcentral/tr69hostif/commit/80a5044813baeea57db9b9d505ac9522226d575d) -#### [1.0.9](https://github.com-venkat0557/rdkcentral/tr69hostif/compare/1.0.8...1.0.9) +#### [1.0.9](https://github.com/rdkcentral/tr69hostif/compare/1.0.8...1.0.9) > 5 March 2025 -- RDKEMW-1803: Add debugs for Mutex issue [`#32`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/32) -- 1.0.9 release changelog updates [`2b1264e`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/2b1264ea3141e3a43165a6371fa363bfc6330696) -- Merge tag '1.0.8' into develop [`6c47ac4`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/6c47ac49bc702139b011cd44eb8e0c68d8a7ea2b) +- RDKEMW-1803: Add debugs for Mutex issue [`#32`](https://github.com/rdkcentral/tr69hostif/pull/32) +- 1.0.9 release changelog updates [`2b1264e`](https://github.com/rdkcentral/tr69hostif/commit/2b1264ea3141e3a43165a6371fa363bfc6330696) +- Merge tag '1.0.8' into develop [`6c47ac4`](https://github.com/rdkcentral/tr69hostif/commit/6c47ac49bc702139b011cd44eb8e0c68d8a7ea2b) -#### [1.0.8](https://github.com-venkat0557/rdkcentral/tr69hostif/compare/1.0.7...1.0.8) +#### [1.0.8](https://github.com/rdkcentral/tr69hostif/compare/1.0.7...1.0.8) > 5 March 2025 -- RDKEMW-2015 Reboot is not happening when initiating reboot using RPC.RebootNow [`f76d8b0`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/f76d8b0dd44f37faa9f4f097e3c8d179948d9ccd) -- 1.0.8 release changelog updates [`fd82254`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/fd82254dbb56648e41ee1cf39dc3724ba6416159) -- Merge tag '1.0.7' into develop [`48cac37`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/48cac376d46d1796963e5b6e563b719b7ffa95f0) +- RDKEMW-2015 Reboot is not happening when initiating reboot using RPC.RebootNow [`f76d8b0`](https://github.com/rdkcentral/tr69hostif/commit/f76d8b0dd44f37faa9f4f097e3c8d179948d9ccd) +- 1.0.8 release changelog updates [`fd82254`](https://github.com/rdkcentral/tr69hostif/commit/fd82254dbb56648e41ee1cf39dc3724ba6416159) +- Merge tag '1.0.7' into develop [`48cac37`](https://github.com/rdkcentral/tr69hostif/commit/48cac376d46d1796963e5b6e563b719b7ffa95f0) -#### [1.0.7](https://github.com-venkat0557/rdkcentral/tr69hostif/compare/1.0.6...1.0.7) +#### [1.0.7](https://github.com/rdkcentral/tr69hostif/compare/1.0.6...1.0.7) > 3 March 2025 -- RDKVREFPLT-4470:Enable https for webpa.rdkcentral.com [`#21`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/21) -- RDK-55468 : tr69hsotif L2 test framework [`#5`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/5) -- rebase from develop [`#20`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/20) -- DELIA-65776 : Removal of unused attributes [`#14`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/14) -- RDKE-697: [MEMCR] AppHibernate RFC XML tags are missed in data-model.xml [`#11`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/11) -- RDK-55339: Add debug services RFC [`#10`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/10) -- 1.0.7 release changelog updates [`41777d2`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/41777d2466b09db9a975a5c7ccf25ab1496d651c) -- RDKE-697: [RDKE][MEMCR] AppHibernate RFC XML tags are missed in data-model.xml. [`28d01fd`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/28d01fd31d0dd2493126936521567190ea83b077) -- Merge tag '1.0.6' into develop [`0b3f03f`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/0b3f03f65014dea97c4d64c71fd184f974cbf642) +- RDKVREFPLT-4470:Enable https for webpa.rdkcentral.com [`#21`](https://github.com/rdkcentral/tr69hostif/pull/21) +- RDK-55468 : tr69hsotif L2 test framework [`#5`](https://github.com/rdkcentral/tr69hostif/pull/5) +- rebase from develop [`#20`](https://github.com/rdkcentral/tr69hostif/pull/20) +- DELIA-65776 : Removal of unused attributes [`#14`](https://github.com/rdkcentral/tr69hostif/pull/14) +- RDKE-697: [MEMCR] AppHibernate RFC XML tags are missed in data-model.xml [`#11`](https://github.com/rdkcentral/tr69hostif/pull/11) +- RDK-55339: Add debug services RFC [`#10`](https://github.com/rdkcentral/tr69hostif/pull/10) +- 1.0.7 release changelog updates [`41777d2`](https://github.com/rdkcentral/tr69hostif/commit/41777d2466b09db9a975a5c7ccf25ab1496d651c) +- RDKE-697: [RDKE][MEMCR] AppHibernate RFC XML tags are missed in data-model.xml. [`28d01fd`](https://github.com/rdkcentral/tr69hostif/commit/28d01fd31d0dd2493126936521567190ea83b077) +- Merge tag '1.0.6' into develop [`0b3f03f`](https://github.com/rdkcentral/tr69hostif/commit/0b3f03f65014dea97c4d64c71fd184f974cbf642) #### 1.0.6 > 30 January 2025 -- RDKECMF-216 Fix names in native_full_build workflow [`#2`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/2) -- RDKE-622 Fix warnings in tr69hostif [`#1`](https://github.com-venkat0557/rdkcentral/tr69hostif/pull/1) -- Import of source (develop) [`db913d7`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/db913d7e78c379f68c2743350abf00b185314946) -- 1.0.6 release changelog updates [`67c968f`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/67c968f937dc7680bfd7f48196a6e0438d7faba6) -- Fix comments in native_full_build workflow [`b7e46af`](https://github.com-venkat0557/rdkcentral/tr69hostif/commit/b7e46af54c78bba2dd9fecfd8fb75766756aedd8) +- RDKECMF-216 Fix names in native_full_build workflow [`#2`](https://github.com/rdkcentral/tr69hostif/pull/2) +- RDKE-622 Fix warnings in tr69hostif [`#1`](https://github.com/rdkcentral/tr69hostif/pull/1) +- Import of source (develop) [`db913d7`](https://github.com/rdkcentral/tr69hostif/commit/db913d7e78c379f68c2743350abf00b185314946) +- 1.0.6 release changelog updates [`67c968f`](https://github.com/rdkcentral/tr69hostif/commit/67c968f937dc7680bfd7f48196a6e0438d7faba6) +- Fix comments in native_full_build workflow [`b7e46af`](https://github.com/rdkcentral/tr69hostif/commit/b7e46af54c78bba2dd9fecfd8fb75766756aedd8) From cd31ebc83261a38f8d38beb53b90b3284362b62e Mon Sep 17 00:00:00 2001 From: mtirum011 Date: Wed, 26 Mar 2025 06:22:36 +0000 Subject: [PATCH 021/161] RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo --- cov_build.sh | 7 +- run_l2.sh | 7 +- .../conf/data-model-generic.xml | 4422 ----------------- 3 files changed, 10 insertions(+), 4426 deletions(-) delete mode 100755 src/integrationtest/conf/data-model-generic.xml diff --git a/cov_build.sh b/cov_build.sh index e1e4fdb6c..91e7fd5a6 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -28,10 +28,11 @@ cd $ROOT rm -rf rdk-halif-device_settings rm -rf rdkvhal-devicesettings-raspberrypi4 rm -rf iarmbus +rm -rf remote_debugger git clone https://github.com/rdkcentral/rdk-halif-device_settings.git git clone https://github.com/rdkcentral/rdkvhal-devicesettings-raspberrypi4.git git clone https://github.com/rdkcentral/iarmbus.git - +git clone https://github.com/rdkcentral/remote_debugger.git # Build devicesettings version with fixes for native build and use that as a stub # TODO This is not present in mainline versions. Component maintainers will have to provide this in future. @@ -62,7 +63,7 @@ rm -f ./src/unittest/stubs/rdk_debug.h autoreconf -i ./configure --enable-libsoup3=yes -make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -DLIBSOUP3_ENABLE" \ -AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE" +make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DLIBSOUP3_ENABLE" \ +AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" make install diff --git a/run_l2.sh b/run_l2.sh index 96d921bc8..e19c8dd9a 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -23,7 +23,12 @@ export top_srcdir=`pwd` RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" -cp ./src/integrationtest/conf/data-model-generic.xml /etc/data-model.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml + +sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /etc/data-model.xml +sed '/> /etc/data-model.xml + cp ./src/integrationtest/conf/mgrlist.conf /etc/ mkdir -p /opt/secure/RFC/ diff --git a/src/integrationtest/conf/data-model-generic.xml b/src/integrationtest/conf/data-model-generic.xml deleted file mode 100755 index 13dfcc5cd..000000000 --- a/src/integrationtest/conf/data-model-generic.xml +++ /dev/null @@ -1,4422 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From bfda4f17453c1ececcfef8b61118f7d6797e1e91 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 26 Mar 2025 21:21:56 -0400 Subject: [PATCH 022/161] RDK-56550 : Add new RFC value for LaunchDarkly env key Signed-off-by: Venkata Bojja --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 563a17d8f..46e53d8f1 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4390,5 +4390,13 @@ + + + + + + + + From 6ffeb93932575399dc910e74230d69999d4017f7 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 26 Mar 2025 21:37:58 -0400 Subject: [PATCH 023/161] 1.0.14 release changelog updates --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcc374a07..c862e84fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.14](https://github.com/rdkcentral/tr69hostif/compare/1.0.13...1.0.14) + +- RDK-56550 : Add new RFC value for LaunchDarkly env key [`#84`](https://github.com/rdkcentral/tr69hostif/pull/84) +- RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo [`#82`](https://github.com/rdkcentral/tr69hostif/pull/82) +- RDK-56084 : Replace Script with rdm-agent for RRD Dynamic Profile [`#65`](https://github.com/rdkcentral/tr69hostif/pull/65) +- Merge tag '1.0.13' into develop [`0cf30c0`](https://github.com/rdkcentral/tr69hostif/commit/0cf30c03ebae0f3cab8041551b2b2b299d5e128f) +- RDK-56082: Addressing Review Comments [`89bf58a`](https://github.com/rdkcentral/tr69hostif/commit/89bf58aeea8828adde28a4ff8bf858bbfc642e27) + #### [1.0.13](https://github.com/rdkcentral/tr69hostif/compare/1.0.12...1.0.13) +> 25 March 2025 + - RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo [`#60`](https://github.com/rdkcentral/tr69hostif/pull/60) - rebase topic branch [`#73`](https://github.com/rdkcentral/tr69hostif/pull/73) - RDKEMW-2621:Default ReserveTTS RFC to true [`#68`](https://github.com/rdkcentral/tr69hostif/pull/68) +- 1.0.13 release changelog updates [`f56c066`](https://github.com/rdkcentral/tr69hostif/commit/f56c066f49c0f97be48efd3d011ac42136f609dd) - Merge tag '1.0.12' into develop [`97eb199`](https://github.com/rdkcentral/tr69hostif/commit/97eb19993dc0220d362ea5c4602f292397d221ef) #### [1.0.12](https://github.com/rdkcentral/tr69hostif/compare/1.0.11...1.0.12) From 405cff1763c94f4e459b5048d392144757ee825f Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 27 Mar 2025 06:34:23 +0000 Subject: [PATCH 024/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Fixing L2 in tr69hostif. Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com Signed-off-by: gsanto722 --- .../stubs/libWPEFrameworkPowerController.so | Bin 0 -> 24912 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 src/unittest/stubs/libWPEFrameworkPowerController.so diff --git a/src/unittest/stubs/libWPEFrameworkPowerController.so b/src/unittest/stubs/libWPEFrameworkPowerController.so new file mode 100755 index 0000000000000000000000000000000000000000..42c6d7ef2616577cba13fa327927d9d198e91e04 GIT binary patch literal 24912 zcmeHvX?R@4m3G~}y-B6blB~_L-4Zq!+uCe-#m0*y+rlfh2{v(PTHP(HajRQ&w`7|= z5JE`U0|WvD0we(f36O=5K$s*zAS5IVLr5}YLXu&d%&^Rtg|PX1-&6N?w`4Q%JkR&z z`$0Xr_tdF6b*k#rsZ*z_b?cnI4QnjRQf{!-EahU|NWABxczKntTZL2rc{9`z%pZ9? zpp^RrLBhxDJZ^cQ68;6We0+jg!vD_|O8vRQl4m6f^y2Y5`5wYbK1k$)KR(QN>!=0p zJ~NQc$IUzb#as;NL4oC~@N7kXas6fB#fRkq1l9uDc-C$@L0y>Wyy^9%y5;UWpNzdV z`>W60zVw36lpwDZ58Fz<8wS*Mkb%WC292i-PdO0;bXNkqHGQrB{)^6iyU$Mj{mYj` z)tVzJzVgP8e`$ZmAsGjj8KI#qtWl}XDz=bqt5sblDtI;CjT3P8)eRv;in0~)xp>?V zLS&7L0Jh>;SyX`h&%tvAI!ifKqlYH|UILslApQ>EjYavV0>7*%|8u~vF3Nu#_;p3N z3Ws+Or&Hl`^KJRIu+j@8A!%W-l22C(S4EdU?LSs zCQgs5E$O}SOiwzM%cPUZcqZJRO5_eo+#b&iAC!nfsd)5Y;;l}5g!9I9EZ#E|N$rlu zdLqf>KqR{7AVw#o{?|p;#&g1cTP~7AXHVL+Ew?z4&V~mf*?2d*(9_j726;u|k%2@Q zH2cu2Ly+~7ESVU{=3>z~bK0}%_Ju@;^ReC0XgEu(i|NsP`iWcm)?^~X@xAHHo(UoZ z9m%@Y+711yd&2YF*p40H`H1)I*s*GLe|Xi_jp45L`R(&D$PzrzSJ?b%so_3`kbZQBLQA9}_6 zLfebp7jAm7;)Tmz2)^eZv2L#_*F&mixFS^ zt>A{>#xr|EYtHID@VA#<_pc8e7g}?A@2fi=dS&s-1Alw=VfFC!;5~qc^Y@d0wVgM; zSR1Z~B4}s3VE&xvZde7)Rz4!dp_Ah+vpV?vG z+pu)9JmxuC)GitJPmMzDxsXYwx6Fj|E)cbzjuIB=)>@#1U{6&hZ6Wu0v}4?LkWC<1TKPe za0UFoen767^eqW@JMc6IazUlva1kK)a@>p2f4CXt8Ug8NP631~sG9K5&!qpv{n20E zKagIGawwuMhEqX*Nxvh6hyKbWJmROKFysFMhV)a`;iT!sBh6n`jo#kuqtSkcuMUutJ+&@O}6Uo2CLC(@-$nm)@*C8r`HxAmhCrE zQ|b}4VFobDn*F4#i~GYo56&Rm)Qgc%nOzQg`hadQbakyRT`%&<=e7y_rX$U#EU7{y z!GUI|!*dKC>)h8{3<-x|*4MC4X!;v=@k1EBl}KS2!E-dWSgNwl(mz78C!dHu*`F+( z{27d|{d{Tl^QhhmY$;8GayF5`mN`eDzPa!(tvC{cj6p4W@S5`^SOm5$AhD&U#Q?nX z%00ewbOY4K<2zTc7x+nSp|u|0MS7aRi}ezLm*~v`FV%5@m+3PEUZKA%@GAX7f!F9? z3%pMMMd0W4B&fH?cfDRD@J78u;LUo!z+3gj0>7lM6ZmEQRe@j8PYS$U|4HB-T4UOH zd|%bA0`Jo61in#swzT^%b?2kA9^YT7Z&5_q$&#B}udZ_!->Z`E4`-lkImzpO74 zc!&O`z`OKs1b$5)5O|NC0@d~S@6*Q!{D$5o@SA$Cz;Ed*1%6xKE%1K*xWMn|KMH(6 ze|<8`e^);$@O%12fe&gQwAbT*NY51beZ58C!+MXvALxq({z%_0@DcsEz(@6~0w2?* zFh3sukM(SUkLy(epU?vWf1=M9_@ur~;7|3V0)M7|EAT1(cL&yE8|Cr;TrY6oHi5s; zr#bL4fluqZ9r&ccf7Y)$uncClR9kf&gk@IUdctz6E=f4Ws$f4#r&$%0b7_lJLHU-> zuqr6m(pgr8lsnq0kaDxF3YMGxE6ls#it>9g3+Mg@ac}S>eJc?AeprFvuJYNOiEYdY zo?LY{;#Z{Px&5HaW*nK-AonwE@nYwHeRcdwl1IE{wk(*Fj}5O z4jG(+oI&P(4lGqUE8KH7NLa&}NIx%MQu2l`#Ux2PUKZGgj#?i>-jJJbk)`VVBbW!Tuc}5jXhf}# zBmY9uh=98O4aOsQPvGa^au?{W8}eC7|10dQC%C=p0i+?)+r)%((Z2^rPsvjKUjmQOe;2q+`y~HZ{eZv~`ilZr>3b!AwSGuokA6a6uYOkG8hx73 zt<`4bZ_e=K-h|5o6jeqG>h?VHN{A>Ax6q2~)cRrd?rqfZf-)E^f(tZxx`n*P4P zjQ)3lIqjQ9KBM|bfn$2DzG=3FVupmi#$*zt1RQu)(FrR zqGO(u5lx`r0ZbMj;z1&+#2k8P`#Uxag>{B)O#_Dm!0kjbYb$ajAg9`#YUIP z%976#PNT9jJmne8=6ymH8&9G1uTit|lyB7+A>UKJO`j!jyIJ2Iq6VGvtWHR~NXmkbUYKi6fPv~%oH}Ew~ff6ftGHg(ZCs2j?j>J2d7!2Gd zdHz!*&-VqCJ;v)xq;eqf9f!`91bux3-atFVpsOH<5>M5A!lUZDX!9~}pa)?2X?Pv` zPnhPFotFL{$fiAp0#!4$$M?84KESWES^NK}&D#I(+N}96YP06QtbZwM|0|kn|B6^* zO!=O*b6~^rw}7Wr;=ZuNyrad`do3-d-e+l=dbHTz`))c6Q^arav?OGpXXD_LA4{8y3BlG^8)-i24q(wbKopNn4A98>#e#;;(#>t{;6 z$FS@MQ}45+xwesF^u7kIuDNas%Lb(9Nu<^`m`2@+hSWBihE#w-ZIh||Jkm^&3L9AH zSxBgnUA0x+a*DOnuKWYi0x#pWib8n@5i9?~FP`YuYTrhrR-fc4BSiyJEWT7=D&9R6 zZ!$CNsU{==eQ-nIpN*+eJy`ieG=mRomPm6ra!#m2}>`PPD<`s1F8%Rxz>-{JmKSgPui z?Mf;ww*VGvmzVM#N%`DjOEbAGkRno_^4&qjzuT^46Xr2bUhJJA2+%b6zK6M1{UyVJ z8;OZjl^d|^RIjnQxe$+PVwd{c%DL?@J!!JQx%x3nnpMf)M5`aSxC^m3tjb?Y zd5ww0A7iSti7^#m-~H3st9wPt+^ZDw4SWA5A%*I1HPJ|O4>K{}$Df?5>rJ1yxe)^8 zs}r_HAU#ZGWtPM!BNeEpKsHj`cbLMoeuj#&QobjdH(*brF`z{(vTpvTnRnU@&JP+% zQ>VX_;(elysWh1ro9e#p^_ry4#=>s*0H4Z71j#K;(XAo^VUzYhY)Gq zM*XSbh_#-H%$m|i@m4mD15|xwfO@O!Coq!rwZ3(rhuvHSg8Iq!F~oWhZ}3khOW6>5 z!)Q~ZukkJhaeK}JnW1*x^~Be!D&X|PMdziF8u&Gs-F-n3khkUfZnw`rvyGi>_zO{)Z% zWuL@)RtqxM-h=tx)LZunxLBR`SJ}2TwHE>Dwx45}b<*m^_9?J?P5pu_v#&zunvT=^ z(1n%uPFA|Hnr6M%-T=`zZK~utu*Uvp$ggR0@KSJFYoE(9$5(y<$U6I4B0I}J0R~&_ zjg-Mh>u*QS4*N7DHSKD=56CY2C+z9Rq&cV9KV?HtF5%$D>~_`@E~Qcr*#U~`6lq)1 zwkVK+;Qe4QqP(}EqA39x65oSpX!BI7l6u08x?_{>M_Zd;@ksJ8llfACn?dD!gn2%D z67352^2T(CK@%$94QN2~Urk|d@-5CH!@+kC^UBOLv3ATW8H#8s-|X8_Gtc*-6DWIK3rP)y+a4x9X{X%UYTOk|VR6bo`Y+y0)(<4K3)Dc@_TqWNP+PCWQ9?Gwh1u&#v4 zG+*l}y9kiN;<1Ps1w-Ilz*=i<8GD|USkw(8G2ibv3~|Gr`}%^EEgBc#u<+@B2DC({4tBhdTw6Z-&wTGDQ^;MdzW9X(pwl{8zFIr^-slbD%=I zl>b)B?|jMP(NJ;L3uJhrFyv`bF+&Qu`9aY>9v~H!@_n5{z1=KeB{)QyC@!X{z@2#a z=Z4kXsevHl_7UJXwL~m{vi}2ferl;8Ub_Nan5qQ{+5>3r)G|TJ?5&XX)N(D=%)i?b?}sOSg|dzXY^1i{XNmj6BfyCS{`=65<_o3e zJQ^&jfqhiIZK$ld#TX@?8Opp?zORt4ZIXF}Sm?14uJ3J5v4AB_=h@;xj7!+`GDE;a z$AbtOI1#H10Z$_hfvgIqX}@P193P&?l+p$m_95t5^VOcRFd%0zk1n0Ovi<1PEmQfX z6nU6wS}rb|=;B>d z`DR%jk`~v?^gHYMW?3Gc7T5b3tZ+|H<(p-Bpjuon(|=yiH_P&vwYXkxFW;WZH_Mh` z2VJPwj8qvj->T=E47lkoRPGGsdX#PcxFzl*cjJbKQNdH0_gzc8R_@RXd5#J`3(n0y zu*7ZU0o_D`2n(!7{3A5X?j~@C*$+cu<7lM>loj`cvoW?<1v<< z*EECi9`Kw#ziAoc?da+B?k29G-uKYv=}YTmm%bVEWctcVs+xBS+B1EXiN68;o8HqP zo8WgzzqUbk@|#G%QM_qy6X`dZ`0J$K5|R!2MX*iNKW6xRit$qn&1Xp;pL`12u$+Av ztV<$ZeJR?!I5a=Vb3prR$Osu%SlJ$w4jEV2YkvuzZ0K0=SA+JW=yRx7kTQEM%k&9S zW#36;jUcu5`{;IPtso8d7s+6qAkFr7P;;nXkdXZiNGf!kAT#XUMAiqnL!V{uA+kY` zqwNuNKD0@Y+4fJ!V2dDgY##oGwhA)WzK}WF1!=SY73M$mQ9;`6nV9vVU4nGjNpcGd z(rG`&G7&+#>}$y_D#$$heCEUjnQuQwZb?D9?G|zy7G#0)hcHT^(`8T1gH%yq@#xeM z+evs<-LXgx@X)pT0C<+QlveGb#Q8t3EoI`yEBiG_ucf?_yBX|r(iqj23cCkn8(uu{3tm; zVrf&L3M@ISH#H)3KS;KkGUdS_wFRSbkH?Y+Y$~gExP1Zk?`N4yD z(`MhVq3^9Xn10DAd0`j>JhRqJtmS!pEm3a|xEyih6rRXk}l z9dVO%jA!9y8^P0Z<-Z-0n6XH97(5;~Sv*iz{yUk~T}^~1=8ljqB(LiyvGlw7)Qw+5 zy*_&Z{_A1W`&@LqJhhm4bj7hD92fJW1vO~_T4hc8JEERR?;*vWw1y3zRDriod7Dsd zW~UuMfx3FkxS5?+)rmj?yYSk48eSHenU@@)Y*~aNjLqQh4=-WjeFg+qeMrN>zz#**6}L94maP1%r2I`HedRDmfndDcb#$^NRC3uBk-u^F>s$t z+N<)k54yB-PbTfLAX|#(s5{Z{xhaYdHSPRQ!lO!A^zwYslQyDFR;&M`|4orh^;^4s z17`eJ5-2A+p(tVgSIBeBzXo;hM8Z}K9=vAfzd~@{QB{9JyoK%I&s@zQvBE2QRjCn2Avc^~q zYp=-H4sL})_z5lF(w1`5&?@+kYSJw9s2N?WuCeS2txa#qsiwwq(NqN!YOCBnOkQHd z;9JrH9jbGLA~JxZ4WR{>wp6p#MrsX~)h~^MCid5Kpt7cRm2Zy72(zIEJeNT(*lu+r)2_fe$7ew6kQH^L*>$K)Hgw+jj0>$sqkQx6L5U1^ zcV3tDMHV`-0JtLr!56Yqrp%&z{~)1xBBRB5_Kv!uA7LbM zV4Zj`iTgLiOg0fsZ?v`-&Tw zm(7~OR3zuMR7B1sT8(w}`B}+4%qu(SPE#fvcMOQJsalO5Q1LbtES6Fm*&!<5CNG3~ ztR_ies%)NYk;4`WroU!IV>gCMspH#0+TB<@3Aav#+HbYKvs#}}zeDfTCqh=+e5$L4 zc4WImU{Oz4XPsr8BlG?v{mRpDHtIcbojS`pkHfsfunoy5?i@e0+`5!HsW?Naj~1gL zRJN-fwHC;+kWV!0Nr)cHxM~OVSk^lg<@jY^zL>ON^DS#S*97^|@`CTl ze`mB;SRI`m2>1s9l=FF(G4UB?b$UD|f&b)azo0C^Td~~O>KeEJo{5!pjAk<(*-W$} z79SYh-LZEhKInd<)fP=A;;9_I&B{bFiFmf7yS=-;t1Z*DpksF;*Rd@Tmiewne=91x&NFoCgjA(pcG(M6` z;OoYboRh>-{O<~uN~WU`eAUP(Q`3yO-}@N`V9W-%oD=vUGLlQXtme!?+XoZ7K?~&? z$;4xEd;uAch0`NhQyy%QhB$Q1G#7Drav}gkVYEzp+R&y{J|U7JPn6k<A zFuo|nSBGxG1T-98)4!q5&_aHr(OgkNAxlIBDzw6($_=}PD4Dj=aZLeYh>fsJJRBYz z!FQ2P!$fu_!-%WRtpnXNDJFN~cw_Xskb@DABzLDXiQLfe;NBQgFm%fXMia>##6lMn zwt!QZzM?(V^4Izo`g}D$%U|P1DxK5G4j%F!ad6CoPaQ2`Kxf=uY*~KG>+v<(lR{pk z+v(6atbH7oGgvz|w3fAZz{pJ;oLLFugHf65QwKhn>v zC@UA|oxOIQW9BnliZamAe7@^kyZNr4?&7YG@8a%`Aw*^f?tW!eMb-Jn#m>Fx0%^pFowG^gwc+9?eiDF=!wmXW=Hw?c4*bM z5Rwr-dJQmR9fbx|x zDcm)G9NN>}w`Gi4oJ)@;lTfwnzCnCaOj|I29;!Ke9JLB(htiqcz~~_A9gBpM_`Vrm zG;a<=v-f~H8_$g~bIaxv`?iL+ZC|y$kMB*rt9L5=2U2=0t{{*c{uc?&-!IMQ7sB(p zMiOZB-b6M|Q|8Vov~6r0s}nY@-?aI}O=@s3Ihq|p6B5~UbjgzN-fT3IVw232I=r5D zXZJ=%`nGQC469rkQ!EonL1yU7Ud*C+IG&1uA#6Rq%HF5KgPAzK=gvAk9xqblCL_DE zg#lXF4OtY+VDlz6HkA{R9_njn_Ecs(3c@-jLC)bGj_gB1bTpHRr=t7A+5N)tuWdt3I_ce9)P0ljUM!+ zxqPWD-;7Izv1~ewZ_{J^ULG1TiuMd9)2IV#gQlu5M1u6>=x|C6qA9SXGIVI0GjNV( zj1@Xukl9{X$-Ln3W&ZAvyhc;m#BMA-A$EUwK-w8TX>;omzPAC3->pau*Mst9i^^fa6vIF)w^B$NC%EvhDTb1;#Nr_yR{aPLS4!WvYA z>5({E&*>5^*ac{OBA1Zc48kKSi%ShKxS|P|T8HSV+zfyT2)`v}x?*NQk)94@p;=K( zeUN1%V`iFCmEliD!?6ThMreY}9hrntsCXux$xz~`Sq<(@#Nv+Fi*4m-HlB$^auJn^ z?~ddWV9Y^LnDtK2#v;j4DkEp5*xy51tb=4Pmo`9UQRxB*5d9xSYton;=zy8B5;Zo5 zmn4k08*A2Jz+DBUUWUUk6NhKudTCTn8%i7AVVED8$;J+%pz+*uUDy?uRK!rM0B%{FBc^kDXL z8KIRKF`_Cqq;9zl{cG24cMH0@AmS6n`bU!!E6ZliDVn|Ane^yLBDGtV+@3jey1JZ? z!$NJtxuMbF0l>kL(dDUlI>jjMP#gUJhpk6E z+cuPdFN{_UZt3qi;xsGRb;K5!wT0C?OAN)q zMPV!_3toDVJfO(%>tnJW7%vDlFXr?@DQb2$I>Z$SsbU9m!y{09lVBEA3~3Ivkdihn zHO0&mY150xeg%yd8QOY7c5i`4d(CQ=>MT{t&m_*j>A2`Wrkd>HwNJm^b zS?u64jwRBgS?AIgXKhqxi}m7=(gSh553vsP6%RGdQAq}CgQ)|q0Sssaqr@Rhqz2Q6 zr<0LwW_EUU746rs_Q+i^GHl$b(k^k3G2r4k89NH|9u`9`hH}7NVdGdE;XjQ;qR>HX zT485VKE+kfh?9au%3v-5^9bXJh09$8D1ec0wwML!LKI3i9;IU`4hJ+ZMI^zDL^j6l zCA;*G7W6_VF^ppRIEpgGVTCvrW-o&j#G8Sm@T(m6q0PY zeXAJ9&pk!KmfJQ83AWtAQH=Bdm;U@QE$OHr`p_x?hHtwPR-n>4R_^8n6| zWQml1Tw55Lq4?v4*nO{v&!aQRauO)&ISP7}(;-EBeo zR%B4OO)&Mli4m}UEbrzHU z!h2>IT>kF-;=jfG4(Tp#0cU&N`GTGuQl9+JEE9}8U7Ye{`NH^Ds`ra4APuN4~4S9_a5(cHNo(7Rt8+ciYSIOPTNJ1M@jwTziFoPm%WR z$d7NS$ZJ;-PWn@d@Ga!$1b)~u0=)Px(F=eV-$i;O@Z!5izX!bdZqe6(UxM-QfEVv7 zwGk=4i?o{=PGEgIitrF{etGPM5F+PKz;7(VTao|mBAoopLYY=GBI0$1_r@c8;F78t zG3KP&k%M*qaQ3!1O5Ly+3%hX*P&k_#9UN?j^OsD96T>6;9XJ*qlpkUXcc+Ho2V%d5 z!w>ibv2=KMGChDZ>KJ}O%!VVQ`xKqzBz_=?;WnQ`Qt(Dq+%%fWME2usIG5q36lY-J z*y!*ue?BR~WS2jV6i2LES8ePI_igIsy{_TngK6?rQbdJ&cWzp>k!LbtT=wcxJ3`sK zX3e&~?cwdKR&VGdkK(IOR~~ff=pnax6BFITg^B6o_a+l_55u*aSVT?$CMN#F1LZ^P z2zc%5O1XE{xo!1-yd(Dz*Xd>sd719GD{~Ehx!3g&E#RJHTnkh?eow)n5+Hv55;)|> zQt4d09Vd0|;v}~vVoI=~2!3{IkL^#Pq=DFFNX{63d%;1_I3$cb>>^2TA|pw7u;LiE z<1hnpQK9xsT23t5ar10D4h~}bRC|2L=%pbyDrv~wIG9F;6H!!%1KxJSU?7`S?U)e5 z&~qj1BDq{9F)*6L^l6vVMHJ_qzj;(nW!$WR0UQLmggkL{<1$BF1Tu1?q`?VU0Z-$< zIkGr_b2w&F_;r)`;RpH`TrOyaitovGIXJGT{8!6gojb(n-}2#a%f_P>hg!VZ#Ym&i zLw@vo#rFjyAJP)?pFLONAue=y(I@78XKrw#>yY5yT}D5dPY7vly)4h?1U$U!jB)zU ze6}DCAo+w0F+B8=Nk_k$59@IGk&bK3Fdova#?y@ThEE7_(&1m1gfHpF@UX31!nqFe zaeuo;lF$*JhR3DjdM6JvoWOedoQcP!qhH3ySuTZ=Gz{nAap|}o^I?13;L?2x38Z6x z>1Xi?F~JEg-Q~cMJVL(3_qCfHL!lqn8#>`fKZ1|TgDlbo7(n1)a+SNfIai5FRw$j1&C}76Nc-3CaI4lWgcHI4D~u(%e8gK2PF7uF%oH z=>(n23(5KT(}hvqwIac|bTcN< zRpFmrt}0ZUmmlw*XPHhX?>5j4p^a`}9-n0s=*qU3xi^t+gG1-0Zvx%%E&@ni47(=K z-2}QplO=DLj*xT14M8wF1&T%y?!?2cSK*;8pbofU=tNwPRaDUB$F3FAtv*Sqq??I6 HH~N189Z Date: Thu, 27 Mar 2025 10:14:22 +0000 Subject: [PATCH 025/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change:Fix L2 link issue Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- cov_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cov_build.sh b/cov_build.sh index e1e4fdb6c..5369bc6d2 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -54,6 +54,7 @@ g++ -fPIC -shared -o libIARMBus.so iarm_stubs.cpp -I$WORKDIR/src/hostif/parodus cp libIARMBus.so /usr/local/lib cp libIBus.h /usr/local/include cp libIARM.h /usr/local/include +cp libWPEFrameworkPowerController.so /usr/local/lib echo "##### Building tr69hostif module" cd $WORKDIR From 2ff572c7c5ff3b15793d5da70a81013ad91f6110 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 27 Mar 2025 10:14:22 +0000 Subject: [PATCH 026/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change:Fix L2 link issue Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- cov_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cov_build.sh b/cov_build.sh index e1e4fdb6c..7f5a68704 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -54,6 +54,7 @@ g++ -fPIC -shared -o libIARMBus.so iarm_stubs.cpp -I$WORKDIR/src/hostif/parodus cp libIARMBus.so /usr/local/lib cp libIBus.h /usr/local/include cp libIARM.h /usr/local/include +cp libIARMBus.so /usr/local/lib/libWPEFrameworkPowerController.so echo "##### Building tr69hostif module" cd $WORKDIR From b20b527e0052b76b947edfc21f64fe8cd0871814 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 27 Mar 2025 10:33:19 +0000 Subject: [PATCH 027/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change:FIx L2 linking issue. Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- cov_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cov_build.sh b/cov_build.sh index 490988452..e34bf7ee0 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -65,6 +65,6 @@ autoreconf -i ./configure --enable-libsoup3=yes make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -DLIBSOUP3_ENABLE" \ -AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE" +AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE" make install From e7efde14ba035c26ed9e60700fd436463c12d7d5 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 27 Mar 2025 11:54:31 +0000 Subject: [PATCH 028/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Fix L2 test Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- cov_build.sh | 3 ++- ...roller.so => libWPEFrameworkPowerController1.so} | Bin 2 files changed, 2 insertions(+), 1 deletion(-) rename src/unittest/stubs/{libWPEFrameworkPowerController.so => libWPEFrameworkPowerController1.so} (100%) diff --git a/cov_build.sh b/cov_build.sh index 0aebb416c..70febf52b 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -52,10 +52,11 @@ echo "Building IARMBus stubs" cd $WORKDIR cd ./src/unittest/stubs g++ -fPIC -shared -o libIARMBus.so iarm_stubs.cpp -I$WORKDIR/src/hostif/parodusClient/pal -I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/parodusClient/waldb -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/include -I$WORKDIR/src/hostif/profiles/DeviceInfo -I$WORKDIR/src/hostif/parodusClient/pal -fpermissive +g++ -fPIC -shared -o libWPEFrameworkPowerController.so dm_stubs.cpp -I$WORKDIR/src/hostif/parodusClient/pal -I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/parodusClient/waldb -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/include -I$WORKDIR/src/hostif/profiles/DeviceInfo -I$WORKDIR/src/hostif/parodusClient/pal -fpermissive cp libIARMBus.so /usr/local/lib cp libIBus.h /usr/local/include cp libIARM.h /usr/local/include -cp libIARMBus.so /usr/local/lib/libWPEFrameworkPowerController.so +cp libWPEFrameworkPowerController.so /usr/local/lib/libWPEFrameworkPowerController.so echo "##### Building tr69hostif module" diff --git a/src/unittest/stubs/libWPEFrameworkPowerController.so b/src/unittest/stubs/libWPEFrameworkPowerController1.so similarity index 100% rename from src/unittest/stubs/libWPEFrameworkPowerController.so rename to src/unittest/stubs/libWPEFrameworkPowerController1.so From ffb78bf2db547f0d53342fc2d2dbebe08d74a7cb Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 18:06:59 +0530 Subject: [PATCH 029/161] Update run_l2.sh --- run_l2.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index aea807a02..abd1b3a8f 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -27,8 +27,8 @@ mkdir -p "$RESULT_DIR" cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml -sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /etc/data-model.xml -sed '/> /etc/data-model.xml +sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /tmp/data-model.xml +sed '/> /tmp/data-model.xml cp ./src/integrationtest/conf/mgrlist.conf /etc/ From af17cc1eedcf45103ead201757d07d65c28de710 Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 18:28:59 +0530 Subject: [PATCH 030/161] Update run_l2.sh --- run_l2.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index abd1b3a8f..f6c0151e3 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -28,7 +28,8 @@ cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /tmp/data-model.xml -sed '/> /tmp/data-model.xml +sed '0,/> /tmp/data-model.xml + cp ./src/integrationtest/conf/mgrlist.conf /etc/ From 08527a0b5e534f80c035b4055ee1d9e1608ca394 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 27 Mar 2025 13:08:23 +0000 Subject: [PATCH 031/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Update the MW clients to use Power Manager Plugin Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- cov_build.sh | 2 +- src/unittest/stubs/powerctrl_stubs.cpp | 49 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/unittest/stubs/powerctrl_stubs.cpp diff --git a/cov_build.sh b/cov_build.sh index 70febf52b..ed49bb037 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -52,7 +52,7 @@ echo "Building IARMBus stubs" cd $WORKDIR cd ./src/unittest/stubs g++ -fPIC -shared -o libIARMBus.so iarm_stubs.cpp -I$WORKDIR/src/hostif/parodusClient/pal -I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/parodusClient/waldb -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/include -I$WORKDIR/src/hostif/profiles/DeviceInfo -I$WORKDIR/src/hostif/parodusClient/pal -fpermissive -g++ -fPIC -shared -o libWPEFrameworkPowerController.so dm_stubs.cpp -I$WORKDIR/src/hostif/parodusClient/pal -I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/parodusClient/waldb -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/include -I$WORKDIR/src/hostif/profiles/DeviceInfo -I$WORKDIR/src/hostif/parodusClient/pal -fpermissive +g++ -fPIC -shared -o libWPEFrameworkPowerController.so powerctrl_stubs.cpp -I$WORKDIR/src/unittest/stubs -fpermissive cp libIARMBus.so /usr/local/lib cp libIBus.h /usr/local/include cp libIARM.h /usr/local/include diff --git a/src/unittest/stubs/powerctrl_stubs.cpp b/src/unittest/stubs/powerctrl_stubs.cpp new file mode 100644 index 000000000..92a404615 --- /dev/null +++ b/src/unittest/stubs/powerctrl_stubs.cpp @@ -0,0 +1,49 @@ +/* + * Copyright 2024 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "power_controller.h" + +void PowerController_Init() +{ + +} + +void PowerController_Term() +{ + +} + +uint32_t PowerController_Connect() +{ + return POWER_CONTROLLER_ERROR_NONE; +} + +uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata) +{ + return POWER_CONTROLLER_ERROR_NONE; +} + +uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback) +{ + return POWER_CONTROLLER_ERROR_NONE; +} + +uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState, PowerController_PowerState_t* previousState) +{ + return POWER_CONTROLLER_ERROR_NONE; +} \ No newline at end of file From a6cfa9b66cd784555f3216c27d8785656cfb8373 Mon Sep 17 00:00:00 2001 From: gsanto722 Date: Thu, 27 Mar 2025 13:31:33 +0000 Subject: [PATCH 032/161] RDK-55702: Update the MW clients to use Power Manager Plugin Reason for change: Fix L2 and native compilation. Test Procedure: Refer RDK-55702 Risks: Low Signed-off-by:gsanto722 grandhi_santoshkumar@comcast.com --- .../stubs/libWPEFrameworkPowerController1.so | Bin 24912 -> 0 bytes src/unittest/stubs/powerctrl_stubs.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100755 src/unittest/stubs/libWPEFrameworkPowerController1.so diff --git a/src/unittest/stubs/libWPEFrameworkPowerController1.so b/src/unittest/stubs/libWPEFrameworkPowerController1.so deleted file mode 100755 index 42c6d7ef2616577cba13fa327927d9d198e91e04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24912 zcmeHvX?R@4m3G~}y-B6blB~_L-4Zq!+uCe-#m0*y+rlfh2{v(PTHP(HajRQ&w`7|= z5JE`U0|WvD0we(f36O=5K$s*zAS5IVLr5}YLXu&d%&^Rtg|PX1-&6N?w`4Q%JkR&z z`$0Xr_tdF6b*k#rsZ*z_b?cnI4QnjRQf{!-EahU|NWABxczKntTZL2rc{9`z%pZ9? zpp^RrLBhxDJZ^cQ68;6We0+jg!vD_|O8vRQl4m6f^y2Y5`5wYbK1k$)KR(QN>!=0p zJ~NQc$IUzb#as;NL4oC~@N7kXas6fB#fRkq1l9uDc-C$@L0y>Wyy^9%y5;UWpNzdV z`>W60zVw36lpwDZ58Fz<8wS*Mkb%WC292i-PdO0;bXNkqHGQrB{)^6iyU$Mj{mYj` z)tVzJzVgP8e`$ZmAsGjj8KI#qtWl}XDz=bqt5sblDtI;CjT3P8)eRv;in0~)xp>?V zLS&7L0Jh>;SyX`h&%tvAI!ifKqlYH|UILslApQ>EjYavV0>7*%|8u~vF3Nu#_;p3N z3Ws+Or&Hl`^KJRIu+j@8A!%W-l22C(S4EdU?LSs zCQgs5E$O}SOiwzM%cPUZcqZJRO5_eo+#b&iAC!nfsd)5Y;;l}5g!9I9EZ#E|N$rlu zdLqf>KqR{7AVw#o{?|p;#&g1cTP~7AXHVL+Ew?z4&V~mf*?2d*(9_j726;u|k%2@Q zH2cu2Ly+~7ESVU{=3>z~bK0}%_Ju@;^ReC0XgEu(i|NsP`iWcm)?^~X@xAHHo(UoZ z9m%@Y+711yd&2YF*p40H`H1)I*s*GLe|Xi_jp45L`R(&D$PzrzSJ?b%so_3`kbZQBLQA9}_6 zLfebp7jAm7;)Tmz2)^eZv2L#_*F&mixFS^ zt>A{>#xr|EYtHID@VA#<_pc8e7g}?A@2fi=dS&s-1Alw=VfFC!;5~qc^Y@d0wVgM; zSR1Z~B4}s3VE&xvZde7)Rz4!dp_Ah+vpV?vG z+pu)9JmxuC)GitJPmMzDxsXYwx6Fj|E)cbzjuIB=)>@#1U{6&hZ6Wu0v}4?LkWC<1TKPe za0UFoen767^eqW@JMc6IazUlva1kK)a@>p2f4CXt8Ug8NP631~sG9K5&!qpv{n20E zKagIGawwuMhEqX*Nxvh6hyKbWJmROKFysFMhV)a`;iT!sBh6n`jo#kuqtSkcuMUutJ+&@O}6Uo2CLC(@-$nm)@*C8r`HxAmhCrE zQ|b}4VFobDn*F4#i~GYo56&Rm)Qgc%nOzQg`hadQbakyRT`%&<=e7y_rX$U#EU7{y z!GUI|!*dKC>)h8{3<-x|*4MC4X!;v=@k1EBl}KS2!E-dWSgNwl(mz78C!dHu*`F+( z{27d|{d{Tl^QhhmY$;8GayF5`mN`eDzPa!(tvC{cj6p4W@S5`^SOm5$AhD&U#Q?nX z%00ewbOY4K<2zTc7x+nSp|u|0MS7aRi}ezLm*~v`FV%5@m+3PEUZKA%@GAX7f!F9? z3%pMMMd0W4B&fH?cfDRD@J78u;LUo!z+3gj0>7lM6ZmEQRe@j8PYS$U|4HB-T4UOH zd|%bA0`Jo61in#swzT^%b?2kA9^YT7Z&5_q$&#B}udZ_!->Z`E4`-lkImzpO74 zc!&O`z`OKs1b$5)5O|NC0@d~S@6*Q!{D$5o@SA$Cz;Ed*1%6xKE%1K*xWMn|KMH(6 ze|<8`e^);$@O%12fe&gQwAbT*NY51beZ58C!+MXvALxq({z%_0@DcsEz(@6~0w2?* zFh3sukM(SUkLy(epU?vWf1=M9_@ur~;7|3V0)M7|EAT1(cL&yE8|Cr;TrY6oHi5s; zr#bL4fluqZ9r&ccf7Y)$uncClR9kf&gk@IUdctz6E=f4Ws$f4#r&$%0b7_lJLHU-> zuqr6m(pgr8lsnq0kaDxF3YMGxE6ls#it>9g3+Mg@ac}S>eJc?AeprFvuJYNOiEYdY zo?LY{;#Z{Px&5HaW*nK-AonwE@nYwHeRcdwl1IE{wk(*Fj}5O z4jG(+oI&P(4lGqUE8KH7NLa&}NIx%MQu2l`#Ux2PUKZGgj#?i>-jJJbk)`VVBbW!Tuc}5jXhf}# zBmY9uh=98O4aOsQPvGa^au?{W8}eC7|10dQC%C=p0i+?)+r)%((Z2^rPsvjKUjmQOe;2q+`y~HZ{eZv~`ilZr>3b!AwSGuokA6a6uYOkG8hx73 zt<`4bZ_e=K-h|5o6jeqG>h?VHN{A>Ax6q2~)cRrd?rqfZf-)E^f(tZxx`n*P4P zjQ)3lIqjQ9KBM|bfn$2DzG=3FVupmi#$*zt1RQu)(FrR zqGO(u5lx`r0ZbMj;z1&+#2k8P`#Uxag>{B)O#_Dm!0kjbYb$ajAg9`#YUIP z%976#PNT9jJmne8=6ymH8&9G1uTit|lyB7+A>UKJO`j!jyIJ2Iq6VGvtWHR~NXmkbUYKi6fPv~%oH}Ew~ff6ftGHg(ZCs2j?j>J2d7!2Gd zdHz!*&-VqCJ;v)xq;eqf9f!`91bux3-atFVpsOH<5>M5A!lUZDX!9~}pa)?2X?Pv` zPnhPFotFL{$fiAp0#!4$$M?84KESWES^NK}&D#I(+N}96YP06QtbZwM|0|kn|B6^* zO!=O*b6~^rw}7Wr;=ZuNyrad`do3-d-e+l=dbHTz`))c6Q^arav?OGpXXD_LA4{8y3BlG^8)-i24q(wbKopNn4A98>#e#;;(#>t{;6 z$FS@MQ}45+xwesF^u7kIuDNas%Lb(9Nu<^`m`2@+hSWBihE#w-ZIh||Jkm^&3L9AH zSxBgnUA0x+a*DOnuKWYi0x#pWib8n@5i9?~FP`YuYTrhrR-fc4BSiyJEWT7=D&9R6 zZ!$CNsU{==eQ-nIpN*+eJy`ieG=mRomPm6ra!#m2}>`PPD<`s1F8%Rxz>-{JmKSgPui z?Mf;ww*VGvmzVM#N%`DjOEbAGkRno_^4&qjzuT^46Xr2bUhJJA2+%b6zK6M1{UyVJ z8;OZjl^d|^RIjnQxe$+PVwd{c%DL?@J!!JQx%x3nnpMf)M5`aSxC^m3tjb?Y zd5ww0A7iSti7^#m-~H3st9wPt+^ZDw4SWA5A%*I1HPJ|O4>K{}$Df?5>rJ1yxe)^8 zs}r_HAU#ZGWtPM!BNeEpKsHj`cbLMoeuj#&QobjdH(*brF`z{(vTpvTnRnU@&JP+% zQ>VX_;(elysWh1ro9e#p^_ry4#=>s*0H4Z71j#K;(XAo^VUzYhY)Gq zM*XSbh_#-H%$m|i@m4mD15|xwfO@O!Coq!rwZ3(rhuvHSg8Iq!F~oWhZ}3khOW6>5 z!)Q~ZukkJhaeK}JnW1*x^~Be!D&X|PMdziF8u&Gs-F-n3khkUfZnw`rvyGi>_zO{)Z% zWuL@)RtqxM-h=tx)LZunxLBR`SJ}2TwHE>Dwx45}b<*m^_9?J?P5pu_v#&zunvT=^ z(1n%uPFA|Hnr6M%-T=`zZK~utu*Uvp$ggR0@KSJFYoE(9$5(y<$U6I4B0I}J0R~&_ zjg-Mh>u*QS4*N7DHSKD=56CY2C+z9Rq&cV9KV?HtF5%$D>~_`@E~Qcr*#U~`6lq)1 zwkVK+;Qe4QqP(}EqA39x65oSpX!BI7l6u08x?_{>M_Zd;@ksJ8llfACn?dD!gn2%D z67352^2T(CK@%$94QN2~Urk|d@-5CH!@+kC^UBOLv3ATW8H#8s-|X8_Gtc*-6DWIK3rP)y+a4x9X{X%UYTOk|VR6bo`Y+y0)(<4K3)Dc@_TqWNP+PCWQ9?Gwh1u&#v4 zG+*l}y9kiN;<1Ps1w-Ilz*=i<8GD|USkw(8G2ibv3~|Gr`}%^EEgBc#u<+@B2DC({4tBhdTw6Z-&wTGDQ^;MdzW9X(pwl{8zFIr^-slbD%=I zl>b)B?|jMP(NJ;L3uJhrFyv`bF+&Qu`9aY>9v~H!@_n5{z1=KeB{)QyC@!X{z@2#a z=Z4kXsevHl_7UJXwL~m{vi}2ferl;8Ub_Nan5qQ{+5>3r)G|TJ?5&XX)N(D=%)i?b?}sOSg|dzXY^1i{XNmj6BfyCS{`=65<_o3e zJQ^&jfqhiIZK$ld#TX@?8Opp?zORt4ZIXF}Sm?14uJ3J5v4AB_=h@;xj7!+`GDE;a z$AbtOI1#H10Z$_hfvgIqX}@P193P&?l+p$m_95t5^VOcRFd%0zk1n0Ovi<1PEmQfX z6nU6wS}rb|=;B>d z`DR%jk`~v?^gHYMW?3Gc7T5b3tZ+|H<(p-Bpjuon(|=yiH_P&vwYXkxFW;WZH_Mh` z2VJPwj8qvj->T=E47lkoRPGGsdX#PcxFzl*cjJbKQNdH0_gzc8R_@RXd5#J`3(n0y zu*7ZU0o_D`2n(!7{3A5X?j~@C*$+cu<7lM>loj`cvoW?<1v<< z*EECi9`Kw#ziAoc?da+B?k29G-uKYv=}YTmm%bVEWctcVs+xBS+B1EXiN68;o8HqP zo8WgzzqUbk@|#G%QM_qy6X`dZ`0J$K5|R!2MX*iNKW6xRit$qn&1Xp;pL`12u$+Av ztV<$ZeJR?!I5a=Vb3prR$Osu%SlJ$w4jEV2YkvuzZ0K0=SA+JW=yRx7kTQEM%k&9S zW#36;jUcu5`{;IPtso8d7s+6qAkFr7P;;nXkdXZiNGf!kAT#XUMAiqnL!V{uA+kY` zqwNuNKD0@Y+4fJ!V2dDgY##oGwhA)WzK}WF1!=SY73M$mQ9;`6nV9vVU4nGjNpcGd z(rG`&G7&+#>}$y_D#$$heCEUjnQuQwZb?D9?G|zy7G#0)hcHT^(`8T1gH%yq@#xeM z+evs<-LXgx@X)pT0C<+QlveGb#Q8t3EoI`yEBiG_ucf?_yBX|r(iqj23cCkn8(uu{3tm; zVrf&L3M@ISH#H)3KS;KkGUdS_wFRSbkH?Y+Y$~gExP1Zk?`N4yD z(`MhVq3^9Xn10DAd0`j>JhRqJtmS!pEm3a|xEyih6rRXk}l z9dVO%jA!9y8^P0Z<-Z-0n6XH97(5;~Sv*iz{yUk~T}^~1=8ljqB(LiyvGlw7)Qw+5 zy*_&Z{_A1W`&@LqJhhm4bj7hD92fJW1vO~_T4hc8JEERR?;*vWw1y3zRDriod7Dsd zW~UuMfx3FkxS5?+)rmj?yYSk48eSHenU@@)Y*~aNjLqQh4=-WjeFg+qeMrN>zz#**6}L94maP1%r2I`HedRDmfndDcb#$^NRC3uBk-u^F>s$t z+N<)k54yB-PbTfLAX|#(s5{Z{xhaYdHSPRQ!lO!A^zwYslQyDFR;&M`|4orh^;^4s z17`eJ5-2A+p(tVgSIBeBzXo;hM8Z}K9=vAfzd~@{QB{9JyoK%I&s@zQvBE2QRjCn2Avc^~q zYp=-H4sL})_z5lF(w1`5&?@+kYSJw9s2N?WuCeS2txa#qsiwwq(NqN!YOCBnOkQHd z;9JrH9jbGLA~JxZ4WR{>wp6p#MrsX~)h~^MCid5Kpt7cRm2Zy72(zIEJeNT(*lu+r)2_fe$7ew6kQH^L*>$K)Hgw+jj0>$sqkQx6L5U1^ zcV3tDMHV`-0JtLr!56Yqrp%&z{~)1xBBRB5_Kv!uA7LbM zV4Zj`iTgLiOg0fsZ?v`-&Tw zm(7~OR3zuMR7B1sT8(w}`B}+4%qu(SPE#fvcMOQJsalO5Q1LbtES6Fm*&!<5CNG3~ ztR_ies%)NYk;4`WroU!IV>gCMspH#0+TB<@3Aav#+HbYKvs#}}zeDfTCqh=+e5$L4 zc4WImU{Oz4XPsr8BlG?v{mRpDHtIcbojS`pkHfsfunoy5?i@e0+`5!HsW?Naj~1gL zRJN-fwHC;+kWV!0Nr)cHxM~OVSk^lg<@jY^zL>ON^DS#S*97^|@`CTl ze`mB;SRI`m2>1s9l=FF(G4UB?b$UD|f&b)azo0C^Td~~O>KeEJo{5!pjAk<(*-W$} z79SYh-LZEhKInd<)fP=A;;9_I&B{bFiFmf7yS=-;t1Z*DpksF;*Rd@Tmiewne=91x&NFoCgjA(pcG(M6` z;OoYboRh>-{O<~uN~WU`eAUP(Q`3yO-}@N`V9W-%oD=vUGLlQXtme!?+XoZ7K?~&? z$;4xEd;uAch0`NhQyy%QhB$Q1G#7Drav}gkVYEzp+R&y{J|U7JPn6k<A zFuo|nSBGxG1T-98)4!q5&_aHr(OgkNAxlIBDzw6($_=}PD4Dj=aZLeYh>fsJJRBYz z!FQ2P!$fu_!-%WRtpnXNDJFN~cw_Xskb@DABzLDXiQLfe;NBQgFm%fXMia>##6lMn zwt!QZzM?(V^4Izo`g}D$%U|P1DxK5G4j%F!ad6CoPaQ2`Kxf=uY*~KG>+v<(lR{pk z+v(6atbH7oGgvz|w3fAZz{pJ;oLLFugHf65QwKhn>v zC@UA|oxOIQW9BnliZamAe7@^kyZNr4?&7YG@8a%`Aw*^f?tW!eMb-Jn#m>Fx0%^pFowG^gwc+9?eiDF=!wmXW=Hw?c4*bM z5Rwr-dJQmR9fbx|x zDcm)G9NN>}w`Gi4oJ)@;lTfwnzCnCaOj|I29;!Ke9JLB(htiqcz~~_A9gBpM_`Vrm zG;a<=v-f~H8_$g~bIaxv`?iL+ZC|y$kMB*rt9L5=2U2=0t{{*c{uc?&-!IMQ7sB(p zMiOZB-b6M|Q|8Vov~6r0s}nY@-?aI}O=@s3Ihq|p6B5~UbjgzN-fT3IVw232I=r5D zXZJ=%`nGQC469rkQ!EonL1yU7Ud*C+IG&1uA#6Rq%HF5KgPAzK=gvAk9xqblCL_DE zg#lXF4OtY+VDlz6HkA{R9_njn_Ecs(3c@-jLC)bGj_gB1bTpHRr=t7A+5N)tuWdt3I_ce9)P0ljUM!+ zxqPWD-;7Izv1~ewZ_{J^ULG1TiuMd9)2IV#gQlu5M1u6>=x|C6qA9SXGIVI0GjNV( zj1@Xukl9{X$-Ln3W&ZAvyhc;m#BMA-A$EUwK-w8TX>;omzPAC3->pau*Mst9i^^fa6vIF)w^B$NC%EvhDTb1;#Nr_yR{aPLS4!WvYA z>5({E&*>5^*ac{OBA1Zc48kKSi%ShKxS|P|T8HSV+zfyT2)`v}x?*NQk)94@p;=K( zeUN1%V`iFCmEliD!?6ThMreY}9hrntsCXux$xz~`Sq<(@#Nv+Fi*4m-HlB$^auJn^ z?~ddWV9Y^LnDtK2#v;j4DkEp5*xy51tb=4Pmo`9UQRxB*5d9xSYton;=zy8B5;Zo5 zmn4k08*A2Jz+DBUUWUUk6NhKudTCTn8%i7AVVED8$;J+%pz+*uUDy?uRK!rM0B%{FBc^kDXL z8KIRKF`_Cqq;9zl{cG24cMH0@AmS6n`bU!!E6ZliDVn|Ane^yLBDGtV+@3jey1JZ? z!$NJtxuMbF0l>kL(dDUlI>jjMP#gUJhpk6E z+cuPdFN{_UZt3qi;xsGRb;K5!wT0C?OAN)q zMPV!_3toDVJfO(%>tnJW7%vDlFXr?@DQb2$I>Z$SsbU9m!y{09lVBEA3~3Ivkdihn zHO0&mY150xeg%yd8QOY7c5i`4d(CQ=>MT{t&m_*j>A2`Wrkd>HwNJm^b zS?u64jwRBgS?AIgXKhqxi}m7=(gSh553vsP6%RGdQAq}CgQ)|q0Sssaqr@Rhqz2Q6 zr<0LwW_EUU746rs_Q+i^GHl$b(k^k3G2r4k89NH|9u`9`hH}7NVdGdE;XjQ;qR>HX zT485VKE+kfh?9au%3v-5^9bXJh09$8D1ec0wwML!LKI3i9;IU`4hJ+ZMI^zDL^j6l zCA;*G7W6_VF^ppRIEpgGVTCvrW-o&j#G8Sm@T(m6q0PY zeXAJ9&pk!KmfJQ83AWtAQH=Bdm;U@QE$OHr`p_x?hHtwPR-n>4R_^8n6| zWQml1Tw55Lq4?v4*nO{v&!aQRauO)&ISP7}(;-EBeo zR%B4OO)&Mli4m}UEbrzHU z!h2>IT>kF-;=jfG4(Tp#0cU&N`GTGuQl9+JEE9}8U7Ye{`NH^Ds`ra4APuN4~4S9_a5(cHNo(7Rt8+ciYSIOPTNJ1M@jwTziFoPm%WR z$d7NS$ZJ;-PWn@d@Ga!$1b)~u0=)Px(F=eV-$i;O@Z!5izX!bdZqe6(UxM-QfEVv7 zwGk=4i?o{=PGEgIitrF{etGPM5F+PKz;7(VTao|mBAoopLYY=GBI0$1_r@c8;F78t zG3KP&k%M*qaQ3!1O5Ly+3%hX*P&k_#9UN?j^OsD96T>6;9XJ*qlpkUXcc+Ho2V%d5 z!w>ibv2=KMGChDZ>KJ}O%!VVQ`xKqzBz_=?;WnQ`Qt(Dq+%%fWME2usIG5q36lY-J z*y!*ue?BR~WS2jV6i2LES8ePI_igIsy{_TngK6?rQbdJ&cWzp>k!LbtT=wcxJ3`sK zX3e&~?cwdKR&VGdkK(IOR~~ff=pnax6BFITg^B6o_a+l_55u*aSVT?$CMN#F1LZ^P z2zc%5O1XE{xo!1-yd(Dz*Xd>sd719GD{~Ehx!3g&E#RJHTnkh?eow)n5+Hv55;)|> zQt4d09Vd0|;v}~vVoI=~2!3{IkL^#Pq=DFFNX{63d%;1_I3$cb>>^2TA|pw7u;LiE z<1hnpQK9xsT23t5ar10D4h~}bRC|2L=%pbyDrv~wIG9F;6H!!%1KxJSU?7`S?U)e5 z&~qj1BDq{9F)*6L^l6vVMHJ_qzj;(nW!$WR0UQLmggkL{<1$BF1Tu1?q`?VU0Z-$< zIkGr_b2w&F_;r)`;RpH`TrOyaitovGIXJGT{8!6gojb(n-}2#a%f_P>hg!VZ#Ym&i zLw@vo#rFjyAJP)?pFLONAue=y(I@78XKrw#>yY5yT}D5dPY7vly)4h?1U$U!jB)zU ze6}DCAo+w0F+B8=Nk_k$59@IGk&bK3Fdova#?y@ThEE7_(&1m1gfHpF@UX31!nqFe zaeuo;lF$*JhR3DjdM6JvoWOedoQcP!qhH3ySuTZ=Gz{nAap|}o^I?13;L?2x38Z6x z>1Xi?F~JEg-Q~cMJVL(3_qCfHL!lqn8#>`fKZ1|TgDlbo7(n1)a+SNfIai5FRw$j1&C}76Nc-3CaI4lWgcHI4D~u(%e8gK2PF7uF%oH z=>(n23(5KT(}hvqwIac|bTcN< zRpFmrt}0ZUmmlw*XPHhX?>5j4p^a`}9-n0s=*qU3xi^t+gG1-0Zvx%%E&@ni47(=K z-2}QplO=DLj*xT14M8wF1&T%y?!?2cSK*;8pbofU=tNwPRaDUB$F3FAtv*Sqq??I6 HH~N189Z Date: Thu, 27 Mar 2025 20:02:02 +0530 Subject: [PATCH 033/161] Update run_l2.sh --- run_l2.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index f6c0151e3..eaf739d46 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -24,12 +24,7 @@ RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" -cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml -cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml - -sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /tmp/data-model.xml -sed '0,/> /tmp/data-model.xml - +cp ./src/integrationtest/conf/data-model-generic.xml /tmp/data-model.xml cp ./src/integrationtest/conf/mgrlist.conf /etc/ From 449df8c7ddf48ebd81de3651ddcbadd2f6efd80b Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 21:08:14 +0530 Subject: [PATCH 034/161] Update run_l2.sh --- run_l2.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index eaf739d46..85e226783 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -24,7 +24,11 @@ RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" -cp ./src/integrationtest/conf/data-model-generic.xml /tmp/data-model.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml + + cp ./src/integrationtest/conf/mgrlist.conf /etc/ From 01869b2e6caf464027d3c8275e069fa7bc889850 Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 21:58:03 +0530 Subject: [PATCH 035/161] Update run_l2.sh --- run_l2.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index 85e226783..13c8db2eb 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -24,9 +24,9 @@ RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" -cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml -cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml -cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml + +cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /tmp/data-model.xml + From 01e374ee58e590ffe26a48478191b210d20c3afe Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 22:16:42 +0530 Subject: [PATCH 036/161] Update run_l2.sh --- run_l2.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index 13c8db2eb..85b613563 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -25,7 +25,10 @@ mkdir -p "$RESULT_DIR" -cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /tmp/data-model.xml +sed '/<\/model>/d; /<\/dm:document>/d' ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml > ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml +sed '/> ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml + +cp ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml /tmp/data-model.xml From 8d7f0df669522dd5a055b0653c804b4401befca3 Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 22:31:39 +0530 Subject: [PATCH 037/161] Update run_l2.sh --- run_l2.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index 85b613563..38ad2bb4a 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -25,10 +25,9 @@ mkdir -p "$RESULT_DIR" -sed '/<\/model>/d; /<\/dm:document>/d' ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml > ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml -sed '/> ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml - -cp ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml /tmp/data-model.xml + cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml + cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml + cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml From 37e48e4b59ddc14f18ceedb13edd6da1c1d8e06a Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 22:50:43 +0530 Subject: [PATCH 038/161] Update helper_functions.py --- test/functional-tests/tests/helper_functions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/functional-tests/tests/helper_functions.py b/test/functional-tests/tests/helper_functions.py index 94c5093d1..445d925a4 100644 --- a/test/functional-tests/tests/helper_functions.py +++ b/test/functional-tests/tests/helper_functions.py @@ -30,6 +30,18 @@ def run_module(module_path: str): return subprocess.run("{module_path}", shell=True) +def set_rdk_profile(): + file_path = "/etc/device.properties" + try: + # Open the file in append mode and write the key-value pair + with open(file_path, 'a') as file: + file.write("RDK_PROFILE=TV\n") + print(f"Successfully added RDK_PROFILE=TV to {file_path}") + except PermissionError: + print(f"Permission denied: Unable to write to {file_path}. Try running as root or with sudo.") + except Exception as e: + print(f"An error occurred: {e}") + #tr69hostif def kill_module(module: str, signal: int=9): print(f"Recived Signal to kill {module} {signal} with pid {get_pid({module})}") From d401d6c5c088a441e8e4aaa03de9230e6f31d698 Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 23:02:25 +0530 Subject: [PATCH 039/161] Update test_bootup_sequence.py --- test/functional-tests/tests/test_bootup_sequence.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/functional-tests/tests/test_bootup_sequence.py b/test/functional-tests/tests/test_bootup_sequence.py index a3291d01c..b15cb94d1 100644 --- a/test/functional-tests/tests/test_bootup_sequence.py +++ b/test/functional-tests/tests/test_bootup_sequence.py @@ -26,6 +26,10 @@ MODULE_NAME = "tr69hostif" +def initialize_rdk_profile(): + """Set the RDK_PROFILE environment variable.""" + + def profile_init_run_command(): """Run the rbuscli curl command and return the result.""" command = [ From 5023d3b03635133152ddf3b692fea72b713f4d6d Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 23:36:26 +0530 Subject: [PATCH 040/161] Update helper_functions.py --- test/functional-tests/tests/helper_functions.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/functional-tests/tests/helper_functions.py b/test/functional-tests/tests/helper_functions.py index 445d925a4..fa28848b0 100644 --- a/test/functional-tests/tests/helper_functions.py +++ b/test/functional-tests/tests/helper_functions.py @@ -30,17 +30,6 @@ def run_module(module_path: str): return subprocess.run("{module_path}", shell=True) -def set_rdk_profile(): - file_path = "/etc/device.properties" - try: - # Open the file in append mode and write the key-value pair - with open(file_path, 'a') as file: - file.write("RDK_PROFILE=TV\n") - print(f"Successfully added RDK_PROFILE=TV to {file_path}") - except PermissionError: - print(f"Permission denied: Unable to write to {file_path}. Try running as root or with sudo.") - except Exception as e: - print(f"An error occurred: {e}") #tr69hostif def kill_module(module: str, signal: int=9): From 56444396e88353dd51104f8ce7c2c6e204adee82 Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 23:38:04 +0530 Subject: [PATCH 041/161] Update test_bootup_sequence.py --- test/functional-tests/tests/test_bootup_sequence.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/functional-tests/tests/test_bootup_sequence.py b/test/functional-tests/tests/test_bootup_sequence.py index b15cb94d1..faf632be2 100644 --- a/test/functional-tests/tests/test_bootup_sequence.py +++ b/test/functional-tests/tests/test_bootup_sequence.py @@ -26,9 +26,7 @@ MODULE_NAME = "tr69hostif" -def initialize_rdk_profile(): - """Set the RDK_PROFILE environment variable.""" - + def profile_init_run_command(): """Run the rbuscli curl command and return the result.""" From 2bcd03445d775d8224067176735764f1140ef0d5 Mon Sep 17 00:00:00 2001 From: Vismalskumar0 Date: Thu, 27 Mar 2025 23:39:10 +0530 Subject: [PATCH 042/161] Update run_l2.sh --- run_l2.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_l2.sh b/run_l2.sh index 38ad2bb4a..411085d08 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -30,6 +30,8 @@ mkdir -p "$RESULT_DIR" cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml + echo "RDK_PROFILE=STB" > /etc/device.properties + From c404f57bd3664528c842fc6a0537ddb9e3a0eef3 Mon Sep 17 00:00:00 2001 From: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> Date: Thu, 27 Mar 2025 15:15:41 -0400 Subject: [PATCH 043/161] Revert "RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features" --- run_l2.sh | 14 +- run_ut.sh | 2 +- src/hostif/include/hostIf_main.h | 10 -- .../parodusClient/pal/webpa_parameter.h | 2 +- src/hostif/parodusClient/waldb/waldb.cpp | 2 +- src/hostif/src/hostIf_main.cpp | 129 +----------------- .../tests/helper_functions.py | 1 - .../tests/test_bootup_sequence.py | 2 - 8 files changed, 8 insertions(+), 154 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index 411085d08..e19c8dd9a 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -23,17 +23,11 @@ export top_srcdir=`pwd` RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" +cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml - - cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml - cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml - cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml - - - echo "RDK_PROFILE=STB" > /etc/device.properties - - - +sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /etc/data-model.xml +sed '/> /etc/data-model.xml cp ./src/integrationtest/conf/mgrlist.conf /etc/ diff --git a/run_ut.sh b/run_ut.sh index c6143381c..cb98f05d8 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -25,7 +25,7 @@ apt-get -y install libsoup-3.0-dev sed '/<\/model>/d; /<\/dm:document>/d' ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml > ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml sed '/> ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml -cp ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml /tmp/data-model.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml /etc/data-model.xml cp ./src/unittest/stubs/rfc.properties /etc/rfc.properties cp ./src/unittest/stubs/rfcdefaults.ini /tmp/rfcdefaults.ini diff --git a/src/hostif/include/hostIf_main.h b/src/hostif/include/hostIf_main.h index 4b064fade..61830123c 100644 --- a/src/hostif/include/hostIf_main.h +++ b/src/hostif/include/hostIf_main.h @@ -92,7 +92,6 @@ #include #include #include -#include #include #include #include @@ -111,16 +110,7 @@ extern gchar *date_str; -typedef enum { - MERGE_SUCCESS, - MERGE_FAILURE -} MergeStatus; - - - void tr69hostIf_logger (const gchar *log_domain, GLogLevelFlags log_level,const gchar *message, gpointer user_data); -MergeStatus mergeDataModel(); -bool filter_and_merge_xml(const char *input1, const char *input2, const char *output); #define G_LOG_DOMAIN ((gchar*) 0) #define LOG_TR69HOSTIF "LOG.RDK.TR69HOSTIF" diff --git a/src/hostif/parodusClient/pal/webpa_parameter.h b/src/hostif/parodusClient/pal/webpa_parameter.h index 995557875..de08411a1 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.h +++ b/src/hostif/parodusClient/pal/webpa_parameter.h @@ -33,7 +33,7 @@ extern "C" #include "webpa_adapter.h" -#define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" +#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" #define MAX_NUM_PARAMETERS 2048 #define MAX_DATATYPE_LENGTH 48 #define MAX_PARAM_LENGTH TR69HOSTIFMGR_MAX_PARAM_LEN diff --git a/src/hostif/parodusClient/waldb/waldb.cpp b/src/hostif/parodusClient/waldb/waldb.cpp index 89fb44e27..c15d0dabe 100644 --- a/src/hostif/parodusClient/waldb/waldb.cpp +++ b/src/hostif/parodusClient/waldb/waldb.cpp @@ -60,7 +60,7 @@ void appendNextObject(char* currentParam, const char* pAttparam); int getNumberofInstances(const char* paramName); -#define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" +#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" static void *g_dbhandle = NULL; std::mutex g_db_mutex; diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index 009808fe4..0ef7c8dfc 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -101,13 +101,6 @@ static void usage(); T_ARGLIST argList = {{'\0'}, 0}; static int isShutdownTriggered = 0; -#define DEVICE_PROPS_FILE "/etc/device.properties" -#define GENERIC_XML_FILE "/etc/data-model-generic.xml" -#define STB_XML_FILE "/etc/data-model-stb.xml" -#define TV_XML_FILE "/etc/data-model-tv.xml" -#define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" - - std::mutex mtx_httpServerThreadDone; std::condition_variable cv_httpServerThreadDone; bool httpServerThreadDone = false; @@ -409,14 +402,7 @@ int main(int argc, char *argv[]) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to start hostIf_IARM_IF_Start()\n"); } - MergeStatus mergeStatus = mergeDataModel(); - if (mergeStatus != MERGE_SUCCESS) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error in merging Data Model\n"); - return DB_FAILURE; // Or handle the failure appropriately - } - else { - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Successfully merged Data Model.\n"); - } + /* Load the data model xml file*/ DB_STATUS status = loadDataModel(); if(status != DB_SUCCESS) @@ -651,118 +637,5 @@ static void usage() #endif } - -bool filter_and_merge_xml(const char *input1, const char *input2, const char *output) { - FILE *in_fp1 = fopen(input1, "r"); - FILE *in_fp2 = fopen(input2, "r"); - FILE *out_fp = fopen(output, "w"); - - if (!in_fp1 || !in_fp2 || !out_fp) { - perror("Error opening files"); - if (in_fp1) fclose(in_fp1); - if (in_fp2) fclose(in_fp2); - if (out_fp) fclose(out_fp); - return false; - } - char line[1024]; - char last_model_line[1024] = {0}; - char last_dm_document_line[1024] = {0}; - long model_last_line_pos = -1, dm_document_last_line_pos = -1; - long line_pos = 0; - while (fgets(line, sizeof(line), in_fp2)) { - if (strstr(line, "")) { - strcpy(last_model_line, line); - model_last_line_pos = line_pos; - } - if (strstr(line, "")) { - strcpy(last_dm_document_line, line); - dm_document_last_line_pos = line_pos; - } - line_pos++; - } - rewind(in_fp2); - line_pos = 0; - while (fgets(line, sizeof(line), in_fp2)) { - if ((line_pos == model_last_line_pos && strstr(line, "")) || - (line_pos == dm_document_last_line_pos && strstr(line, ""))) { - line_pos++; - continue; - } - fputs(line, out_fp); - line_pos++; - } - int skip_range = 0; - while (fgets(line, sizeof(line), in_fp1)) { - if (strstr(line, "")) { - skip_range = 1; - continue; - } - if (skip_range && strstr(line, "")) { - skip_range = 0; - continue; - } - if (skip_range) { - continue; - } - fputs(line, out_fp); - } - -fclose(in_fp1); -fclose(in_fp2); -fclose(out_fp); - -RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Merged XML files successfully into %s\n", output); -return true; - -} - - -MergeStatus mergeDataModel() { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Entering \n"); - FILE *fp = fopen(DEVICE_PROPS_FILE, "r"); - if (fp != NULL) { - char line[256]; - char rdk_profile[256] = {0}; - while (fgets(line, sizeof(line), fp)) - { - int sscanf_result = sscanf(line, "RDK_PROFILE=%s", rdk_profile); - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "mergeDataModel: sscanf result: %d, line: %s", sscanf_result, line); - if (sscanf_result == 1) - { - break; - } - } - fclose(fp); - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "mergeDataModel: Closed /etc/device.properties\n"); - const char *generic_file = GENERIC_XML_FILE; - const char *output_file = WEBPA_DATA_MODEL_FILE; - if (strcmp(rdk_profile, "TV") == 0) { - const char *tv_file = TV_XML_FILE; - if (!filter_and_merge_xml(generic_file, tv_file, output_file)) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error while merging XML files for TV profile\n"); - return MERGE_FAILURE; - } - } - else if (strcmp(rdk_profile, "STB") == 0) { - const char *stb_file = STB_XML_FILE; - if (!filter_and_merge_xml(generic_file, stb_file, output_file)) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error while merging XML files for STB profile\n"); - return MERGE_FAILURE; - } - } - else { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Unsupported RDK_PROFILE: %s\n", rdk_profile); - return MERGE_FAILURE; - } - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Merged XML written to %s\n", output_file); - return MERGE_SUCCESS; - } - else - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Failed to open /etc/device.properties\n"); - return MERGE_FAILURE; - } -} - /** @} */ /** @} */ diff --git a/test/functional-tests/tests/helper_functions.py b/test/functional-tests/tests/helper_functions.py index fa28848b0..94c5093d1 100644 --- a/test/functional-tests/tests/helper_functions.py +++ b/test/functional-tests/tests/helper_functions.py @@ -30,7 +30,6 @@ def run_module(module_path: str): return subprocess.run("{module_path}", shell=True) - #tr69hostif def kill_module(module: str, signal: int=9): print(f"Recived Signal to kill {module} {signal} with pid {get_pid({module})}") diff --git a/test/functional-tests/tests/test_bootup_sequence.py b/test/functional-tests/tests/test_bootup_sequence.py index faf632be2..a3291d01c 100644 --- a/test/functional-tests/tests/test_bootup_sequence.py +++ b/test/functional-tests/tests/test_bootup_sequence.py @@ -26,8 +26,6 @@ MODULE_NAME = "tr69hostif" - - def profile_init_run_command(): """Run the rbuscli curl command and return the result.""" command = [ From 93dccdfb662a00c113d909488be04e98cfcd3c20 Mon Sep 17 00:00:00 2001 From: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> Date: Thu, 27 Mar 2025 15:20:04 -0400 Subject: [PATCH 044/161] Revert "Revert "RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features"" --- run_l2.sh | 14 +- run_ut.sh | 2 +- src/hostif/include/hostIf_main.h | 10 ++ .../parodusClient/pal/webpa_parameter.h | 2 +- src/hostif/parodusClient/waldb/waldb.cpp | 2 +- src/hostif/src/hostIf_main.cpp | 129 +++++++++++++++++- .../tests/helper_functions.py | 1 + .../tests/test_bootup_sequence.py | 2 + 8 files changed, 154 insertions(+), 8 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index e19c8dd9a..411085d08 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -23,11 +23,17 @@ export top_srcdir=`pwd` RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" -cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml -cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml -sed '/<\/model>/d; /<\/dm:document>/d' /etc/data-model-tv.xml > /etc/data-model.xml -sed '/> /etc/data-model.xml + + cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml + cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml + cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml + + + echo "RDK_PROFILE=STB" > /etc/device.properties + + + cp ./src/integrationtest/conf/mgrlist.conf /etc/ diff --git a/run_ut.sh b/run_ut.sh index cb98f05d8..c6143381c 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -25,7 +25,7 @@ apt-get -y install libsoup-3.0-dev sed '/<\/model>/d; /<\/dm:document>/d' ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml > ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml sed '/> ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml -cp ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml /etc/data-model.xml +cp ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml /tmp/data-model.xml cp ./src/unittest/stubs/rfc.properties /etc/rfc.properties cp ./src/unittest/stubs/rfcdefaults.ini /tmp/rfcdefaults.ini diff --git a/src/hostif/include/hostIf_main.h b/src/hostif/include/hostIf_main.h index 61830123c..4b064fade 100644 --- a/src/hostif/include/hostIf_main.h +++ b/src/hostif/include/hostIf_main.h @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -110,7 +111,16 @@ extern gchar *date_str; +typedef enum { + MERGE_SUCCESS, + MERGE_FAILURE +} MergeStatus; + + + void tr69hostIf_logger (const gchar *log_domain, GLogLevelFlags log_level,const gchar *message, gpointer user_data); +MergeStatus mergeDataModel(); +bool filter_and_merge_xml(const char *input1, const char *input2, const char *output); #define G_LOG_DOMAIN ((gchar*) 0) #define LOG_TR69HOSTIF "LOG.RDK.TR69HOSTIF" diff --git a/src/hostif/parodusClient/pal/webpa_parameter.h b/src/hostif/parodusClient/pal/webpa_parameter.h index de08411a1..995557875 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.h +++ b/src/hostif/parodusClient/pal/webpa_parameter.h @@ -33,7 +33,7 @@ extern "C" #include "webpa_adapter.h" -#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" +#define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" #define MAX_NUM_PARAMETERS 2048 #define MAX_DATATYPE_LENGTH 48 #define MAX_PARAM_LENGTH TR69HOSTIFMGR_MAX_PARAM_LEN diff --git a/src/hostif/parodusClient/waldb/waldb.cpp b/src/hostif/parodusClient/waldb/waldb.cpp index c15d0dabe..89fb44e27 100644 --- a/src/hostif/parodusClient/waldb/waldb.cpp +++ b/src/hostif/parodusClient/waldb/waldb.cpp @@ -60,7 +60,7 @@ void appendNextObject(char* currentParam, const char* pAttparam); int getNumberofInstances(const char* paramName); -#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" +#define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" static void *g_dbhandle = NULL; std::mutex g_db_mutex; diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index 0ef7c8dfc..009808fe4 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -101,6 +101,13 @@ static void usage(); T_ARGLIST argList = {{'\0'}, 0}; static int isShutdownTriggered = 0; +#define DEVICE_PROPS_FILE "/etc/device.properties" +#define GENERIC_XML_FILE "/etc/data-model-generic.xml" +#define STB_XML_FILE "/etc/data-model-stb.xml" +#define TV_XML_FILE "/etc/data-model-tv.xml" +#define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" + + std::mutex mtx_httpServerThreadDone; std::condition_variable cv_httpServerThreadDone; bool httpServerThreadDone = false; @@ -402,7 +409,14 @@ int main(int argc, char *argv[]) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to start hostIf_IARM_IF_Start()\n"); } - + MergeStatus mergeStatus = mergeDataModel(); + if (mergeStatus != MERGE_SUCCESS) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error in merging Data Model\n"); + return DB_FAILURE; // Or handle the failure appropriately + } + else { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Successfully merged Data Model.\n"); + } /* Load the data model xml file*/ DB_STATUS status = loadDataModel(); if(status != DB_SUCCESS) @@ -637,5 +651,118 @@ static void usage() #endif } + +bool filter_and_merge_xml(const char *input1, const char *input2, const char *output) { + FILE *in_fp1 = fopen(input1, "r"); + FILE *in_fp2 = fopen(input2, "r"); + FILE *out_fp = fopen(output, "w"); + + if (!in_fp1 || !in_fp2 || !out_fp) { + perror("Error opening files"); + if (in_fp1) fclose(in_fp1); + if (in_fp2) fclose(in_fp2); + if (out_fp) fclose(out_fp); + return false; + } + char line[1024]; + char last_model_line[1024] = {0}; + char last_dm_document_line[1024] = {0}; + long model_last_line_pos = -1, dm_document_last_line_pos = -1; + long line_pos = 0; + while (fgets(line, sizeof(line), in_fp2)) { + if (strstr(line, "")) { + strcpy(last_model_line, line); + model_last_line_pos = line_pos; + } + if (strstr(line, "")) { + strcpy(last_dm_document_line, line); + dm_document_last_line_pos = line_pos; + } + line_pos++; + } + rewind(in_fp2); + line_pos = 0; + while (fgets(line, sizeof(line), in_fp2)) { + if ((line_pos == model_last_line_pos && strstr(line, "")) || + (line_pos == dm_document_last_line_pos && strstr(line, ""))) { + line_pos++; + continue; + } + fputs(line, out_fp); + line_pos++; + } + int skip_range = 0; + while (fgets(line, sizeof(line), in_fp1)) { + if (strstr(line, "")) { + skip_range = 1; + continue; + } + if (skip_range && strstr(line, "")) { + skip_range = 0; + continue; + } + if (skip_range) { + continue; + } + fputs(line, out_fp); + } + +fclose(in_fp1); +fclose(in_fp2); +fclose(out_fp); + +RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Merged XML files successfully into %s\n", output); +return true; + +} + + +MergeStatus mergeDataModel() { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Entering \n"); + FILE *fp = fopen(DEVICE_PROPS_FILE, "r"); + if (fp != NULL) { + char line[256]; + char rdk_profile[256] = {0}; + while (fgets(line, sizeof(line), fp)) + { + int sscanf_result = sscanf(line, "RDK_PROFILE=%s", rdk_profile); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "mergeDataModel: sscanf result: %d, line: %s", sscanf_result, line); + if (sscanf_result == 1) + { + break; + } + } + fclose(fp); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "mergeDataModel: Closed /etc/device.properties\n"); + const char *generic_file = GENERIC_XML_FILE; + const char *output_file = WEBPA_DATA_MODEL_FILE; + if (strcmp(rdk_profile, "TV") == 0) { + const char *tv_file = TV_XML_FILE; + if (!filter_and_merge_xml(generic_file, tv_file, output_file)) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error while merging XML files for TV profile\n"); + return MERGE_FAILURE; + } + } + else if (strcmp(rdk_profile, "STB") == 0) { + const char *stb_file = STB_XML_FILE; + if (!filter_and_merge_xml(generic_file, stb_file, output_file)) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error while merging XML files for STB profile\n"); + return MERGE_FAILURE; + } + } + else { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Unsupported RDK_PROFILE: %s\n", rdk_profile); + return MERGE_FAILURE; + } + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Merged XML written to %s\n", output_file); + return MERGE_SUCCESS; + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Failed to open /etc/device.properties\n"); + return MERGE_FAILURE; + } +} + /** @} */ /** @} */ diff --git a/test/functional-tests/tests/helper_functions.py b/test/functional-tests/tests/helper_functions.py index 94c5093d1..fa28848b0 100644 --- a/test/functional-tests/tests/helper_functions.py +++ b/test/functional-tests/tests/helper_functions.py @@ -30,6 +30,7 @@ def run_module(module_path: str): return subprocess.run("{module_path}", shell=True) + #tr69hostif def kill_module(module: str, signal: int=9): print(f"Recived Signal to kill {module} {signal} with pid {get_pid({module})}") diff --git a/test/functional-tests/tests/test_bootup_sequence.py b/test/functional-tests/tests/test_bootup_sequence.py index a3291d01c..faf632be2 100644 --- a/test/functional-tests/tests/test_bootup_sequence.py +++ b/test/functional-tests/tests/test_bootup_sequence.py @@ -26,6 +26,8 @@ MODULE_NAME = "tr69hostif" + + def profile_init_run_command(): """Run the rbuscli curl command and return the result.""" command = [ From a4e8cada53b122642bb6c17ad32c5289309a2b46 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Thu, 27 Mar 2025 15:31:33 -0400 Subject: [PATCH 045/161] 1.1.0 release changelog updates --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c862e84fa..c8856acf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,29 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.0](https://github.com/rdkcentral/tr69hostif/compare/1.0.14...1.1.0) + +- RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features [`#91`](https://github.com/rdkcentral/tr69hostif/pull/91) +- Revert "RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features" [`#90`](https://github.com/rdkcentral/tr69hostif/pull/90) +- RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features [`#69`](https://github.com/rdkcentral/tr69hostif/pull/69) +- Feature/rdk52635 [`#78`](https://github.com/rdkcentral/tr69hostif/pull/78) +- Merge [`#74`](https://github.com/rdkcentral/tr69hostif/pull/74) +- Merge [`#72`](https://github.com/rdkcentral/tr69hostif/pull/72) +- rebase [`#66`](https://github.com/rdkcentral/tr69hostif/pull/66) +- merge [`#59`](https://github.com/rdkcentral/tr69hostif/pull/59) +- Merge [`#52`](https://github.com/rdkcentral/tr69hostif/pull/52) +- Revert "Revert "RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features"" [`93dccdf`](https://github.com/rdkcentral/tr69hostif/commit/93dccdfb662a00c113d909488be04e98cfcd3c20) +- Update hostIf_main.cpp [`df05ebd`](https://github.com/rdkcentral/tr69hostif/commit/df05ebdbffedbfd129ae68b32122a2b7d1280635) +- Update hostIf_main.cpp [`42d4d33`](https://github.com/rdkcentral/tr69hostif/commit/42d4d336432611ff5b9aba5871622558919e3010) + #### [1.0.14](https://github.com/rdkcentral/tr69hostif/compare/1.0.13...1.0.14) +> 26 March 2025 + - RDK-56550 : Add new RFC value for LaunchDarkly env key [`#84`](https://github.com/rdkcentral/tr69hostif/pull/84) - RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo [`#82`](https://github.com/rdkcentral/tr69hostif/pull/82) - RDK-56084 : Replace Script with rdm-agent for RRD Dynamic Profile [`#65`](https://github.com/rdkcentral/tr69hostif/pull/65) +- 1.0.14 release changelog updates [`6ffeb93`](https://github.com/rdkcentral/tr69hostif/commit/6ffeb93932575399dc910e74230d69999d4017f7) - Merge tag '1.0.13' into develop [`0cf30c0`](https://github.com/rdkcentral/tr69hostif/commit/0cf30c03ebae0f3cab8041551b2b2b299d5e128f) - RDK-56082: Addressing Review Comments [`89bf58a`](https://github.com/rdkcentral/tr69hostif/commit/89bf58aeea8828adde28a4ff8bf858bbfc642e27) From 1db790041e0af21131182dd3d5c9d911253a83e2 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Thu, 27 Mar 2025 21:35:09 -0400 Subject: [PATCH 046/161] 1.1.1 release changelog updates --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8856acf6..9db443008 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.1](https://github.com/rdkcentral/tr69hostif/compare/1.1.0...1.1.1) + +- RDK-55702: Update the MW clients to use Power Manager Plugin [`#47`](https://github.com/rdkcentral/tr69hostif/pull/47) +- sync to develop [`#58`](https://github.com/rdkcentral/tr69hostif/pull/58) +- Merge tag '1.1.0' into develop [`6f7faef`](https://github.com/rdkcentral/tr69hostif/commit/6f7faef0a12bd75bbd9a1f126f60610b278b70e4) + #### [1.1.0](https://github.com/rdkcentral/tr69hostif/compare/1.0.14...1.1.0) +> 27 March 2025 + - RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features [`#91`](https://github.com/rdkcentral/tr69hostif/pull/91) - Revert "RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features" [`#90`](https://github.com/rdkcentral/tr69hostif/pull/90) - RDK-52635 [RDKE-MW][tr69hostif] Remove all product/platform/region specific build time configs/variables/distro features [`#69`](https://github.com/rdkcentral/tr69hostif/pull/69) From 132c1d5df30a79da52a8fd8bb85a95693f7f64a1 Mon Sep 17 00:00:00 2001 From: fzahir786 Date: Fri, 28 Mar 2025 11:52:19 +0530 Subject: [PATCH 047/161] RDKEMW-2234: Updated MigrationStatus tr181 param --- .../src/hostIf_DeviceClient_ReqHandler.cpp | 4 ++ .../waldb/data-model/data-model-generic.xml | 7 +++ .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 45 +++++++++++++++++++ .../profiles/DeviceInfo/Device_DeviceInfo.h | 18 ++++++++ 4 files changed, 74 insertions(+) diff --git a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp index 21c7e9bfd..08f80904a 100644 --- a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp @@ -522,6 +522,10 @@ int DeviceClientReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) { ret = pIface->get_Device_DeviceInfo_SoftwareVersion(stMsgData); } + else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.Migration.MigrationStatus") == 0) + { + ret = pIface->get_Device_DeviceInfo_Migration_MigrationStatus(stMsgData); + } else if (strcasecmp(stMsgData->paramName,IUI_VERSION) == 0) { ret = pIface->get_Device_DeviceInfo_IUI_Version(stMsgData); diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 46e53d8f1..a1dbb16c2 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4398,5 +4398,12 @@ + + + + + + + diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 4338c0fb9..f3cfb2538 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -121,6 +121,7 @@ #define DEVICEID_SCRIPT_PATH "/lib/rdk/getDeviceId.sh" #define SCRIPT_OUTPUT_BUFFER_SIZE 512 #define ENTRY_WIDTH 64 +#define MigrationStatus "/opt/MigrationStatus" GHashTable* hostIf_DeviceInfo::ifHash = NULL; GHashTable* hostIf_DeviceInfo::m_notifyHash = NULL; @@ -477,6 +478,50 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t * return OK; } +/** + * @brief This function retrieves the Migration Status from the MigrationStatus file. + * + * @param[out] stMsgData TR-069 Host interface message request. + * @param[in] pChanged Status of the operation. + * + * @return Returns the status of the operation. + * + * @retval OK if it is successful. + * @retval ERR_INTERNAL_ERROR if not able to fetch from device. + * @ingroup TR69_HOSTIF_DEVICEINFO_API + */ +int hostIf_DeviceInfo::get_Device_DeviceInfo_Migration_MigrationStatus(HOSTIF_MsgData_t * stMsgData, bool *pChanged) +{ + string line = "NOT_STARTED"; + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Entering..\n", __FUNCTION__ ); + ifstream file_read (MigrationStatus); + try { + if (file_read.is_open()) + { + if (file_read.peek() != EOF) { // Check if the file is not empty + std::getline(file_read, line); + } + file_read.close(); + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Failed to open file\n", __FUNCTION__); + } + } + catch (const std::exception &e) { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()]Exception caught.\n", __FUNCTION__); + return NOK; + } + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] value:%s\n", __FUNCTION__, line.c_str()); + int len = strlen(line.c_str()); + stMsgData->paramtype = hostIf_StringType; + strncpy(stMsgData->paramValue, line.c_str(), len); + stMsgData->paramValue[len+1] = '\0'; + stMsgData->paramLen = len; + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ ); + return OK; +} + /** * @brief This function retrieves manufacturer specific data from the box using IARM Bus call. * The IARM Manager gets the manufacture information from mfr library. diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 7c7ab39dd..ed1f9005d 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -514,6 +514,24 @@ class hostIf_DeviceInfo { * @see get_Device_DeviceInfo_ProductClass. */ int get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t *, bool *pChanged = NULL); + + /** + * @brief get_Device_DeviceInfo_Migration_MigrationStatus. + * + * This function provides the status of the migration. + * The Status (human readable string). + * + * @return The status of the operation. + * + * @retval OK if Device_DeviceInfo_Migration_MigrationStatus was successfully fetched. + * @retval ERR_INTERNAL_ERROR if not able to fetch from device. + * + * @sideeffect All necessary structures and buffers are deallocated. + * @execution Synchronous. + * + * @see get_Device_DeviceInfo_Migration_MigrationStatus. + */ + int get_Device_DeviceInfo_Migration_MigrationStatus(HOSTIF_MsgData_t *, bool *pChanged = NULL); /** * @brief get_Device_DeviceInfo_IUI_Version. From 4697e266261fb23b00b44a814b3d89d4ad3656ef Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Tue, 1 Apr 2025 14:14:05 -0400 Subject: [PATCH 048/161] 1.1.2 release changelog updates --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9db443008..3b82ac111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.2](https://github.com/rdkcentral/tr69hostif/compare/1.1.1...1.1.2) + +- RDKEMW-2503 : Add RFC to data model- tr69hostif [`#79`](https://github.com/rdkcentral/tr69hostif/pull/79) +- rebase [`#100`](https://github.com/rdkcentral/tr69hostif/pull/100) +- RDKEMW-2234: Updated MigrationStatus tr181 param [`#96`](https://github.com/rdkcentral/tr69hostif/pull/96) +- Merge tag '1.1.1' into develop [`2e87e9f`](https://github.com/rdkcentral/tr69hostif/commit/2e87e9f85e3c46957dd59927fce3637175736b3c) + #### [1.1.1](https://github.com/rdkcentral/tr69hostif/compare/1.1.0...1.1.1) +> 27 March 2025 + - RDK-55702: Update the MW clients to use Power Manager Plugin [`#47`](https://github.com/rdkcentral/tr69hostif/pull/47) - sync to develop [`#58`](https://github.com/rdkcentral/tr69hostif/pull/58) +- 1.1.1 release changelog updates [`1db7900`](https://github.com/rdkcentral/tr69hostif/commit/1db790041e0af21131182dd3d5c9d911253a83e2) - Merge tag '1.1.0' into develop [`6f7faef`](https://github.com/rdkcentral/tr69hostif/commit/6f7faef0a12bd75bbd9a1f126f60610b278b70e4) #### [1.1.0](https://github.com/rdkcentral/tr69hostif/compare/1.0.14...1.1.0) From f2d402a8fe8afe4c2524b1ebed508aeb58c11826 Mon Sep 17 00:00:00 2001 From: fzahir786 Date: Wed, 2 Apr 2025 16:25:03 +0530 Subject: [PATCH 049/161] RDKEMW-2234: Updated MigrationStatus to persistent dir --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index f3cfb2538..7bbc703e9 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -121,7 +121,7 @@ #define DEVICEID_SCRIPT_PATH "/lib/rdk/getDeviceId.sh" #define SCRIPT_OUTPUT_BUFFER_SIZE 512 #define ENTRY_WIDTH 64 -#define MigrationStatus "/opt/MigrationStatus" +#define MigrationStatus "/opt/secure/persistent/MigrationStatus" GHashTable* hostIf_DeviceInfo::ifHash = NULL; GHashTable* hostIf_DeviceInfo::m_notifyHash = NULL; From a47d3a45f626fe914eb235beb4c4dacf88731de2 Mon Sep 17 00:00:00 2001 From: nhanasi Date: Wed, 2 Apr 2025 16:37:32 -0400 Subject: [PATCH 050/161] Update cov_build.sh --- cov_build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cov_build.sh b/cov_build.sh index ed49bb037..9d0f1ce62 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -66,7 +66,7 @@ rm -f ./src/unittest/stubs/rdk_debug.h autoreconf -i ./configure --enable-libsoup3=yes -make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -DLIBSOUP3_ENABLE" \ -AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE" +make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DLIBSOUP3_ENABLE" \ +AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" make install From 5a6233627f6d52b08865123d94c7135e1b2acc6f Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 4 Apr 2025 03:27:09 +0530 Subject: [PATCH 051/161] [RDKE] L2 Tests And Integration With CI for Remote Debugger Dynamic Updates (#109) * Update data-model-generic.xml * Update data-model-generic.xml * Update Device_DeviceInfo.cpp * Update hostIf_rbus_Dml_Provider.cpp * Update Device_DeviceInfo.h * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update cov_build.sh * Update data-model-generic.xml * Update cov_build.sh * Update cov_build.sh --- .../handlers/src/hostIf_rbus_Dml_Provider.cpp | 5 ++ .../waldb/data-model/data-model-generic.xml | 5 ++ .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 58 +++++++++++++++++++ .../profiles/DeviceInfo/Device_DeviceInfo.h | 2 + 4 files changed, 70 insertions(+) diff --git a/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp b/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp index 0cdc2147f..ffca45e7a 100644 --- a/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp +++ b/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp @@ -152,6 +152,11 @@ rbusError_t TR_Dml_EventSubHandler(rbusHandle_t handle, rbusEventSubAction_t act RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s][rbusdml] Disable Autopublish for action=%s eventName=%s", action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribe" : "unsubscribe", __FUNCTION__, eventName); *autoPublish = false; } + else if(!strcmp("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus", eventName)) + { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s][rbusdml] Disable Autopublish for action=%s eventName=%s", action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribe" : "unsubscribe", __FUNCTION__, eventName); + *autoPublish = false; + } else { RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s][rbusdml]: Autopublish enabled by default for all DM!\n", __FUNCTION__); diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 1740d1e46..a73280472 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -3548,6 +3548,11 @@ + + + + + diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 7bbc703e9..7aa3a9776 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -3749,6 +3749,10 @@ int hostIf_DeviceInfo::set_xRDKCentralComRFC(HOSTIF_MsgData_t * stMsgData) { ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(stMsgData); } + else if (strcasecmp(stMsgData->paramName,RDK_DOWNLOAD_STATUS) == 0) + { + ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerDownloadStatus(stMsgData); + } #endif else if (strcasecmp(stMsgData->paramName,RDK_REBOOTSTOP_ENABLE) == 0) { @@ -4010,7 +4014,61 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerI return retVal; } +int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerDownloadStatus(HOSTIF_MsgData_t *stMsgData) +{ + int ret = NOK; + bool isenabled = false; + LOG_ENTRY_EXIT; + + if(stMsgData->paramtype == hostIf_BooleanType) + { + isenabled = get_boolean(stMsgData->paramValue); + + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, isenabled); + + rbusError_t rc = RBUS_ERROR_BUS_ERROR; + rbusValue_t value, byVal; + rbusObject_t data; + rbusEvent_t event = {0}; + + rbusValue_Init(&value); + rbusValue_Init(&byVal); + rbusValue_SetBoolean(value, isenabled); + rbusValue_SetString(byVal, "tr69hostif"); + + rbusObject_Init(&data, NULL); + rbusObject_SetValue(data, "value", value); + rbusObject_SetValue(data, "by", byVal); + event.name = RDM_DOWNLOAD_EVENT; + event.data = data; + event.type = RBUS_EVENT_VALUE_CHANGED; + + rc = rbusEvent_Publish(rbusHandle, &event); + if ((rc != RBUS_ERROR_SUCCESS) && (rc != RBUS_ERROR_NOSUBSCRIBERS)) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event failed for %s with return : %s !!! \n ", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT, rbusError_ToString(rc)); + ret = NOK; + } + else + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event success for %s !!! \n ", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT ); + ret = OK; + } + + rbusValue_Release(value); + rbusValue_Release(byVal); + rbusObject_Release(data); + } + else + { + 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); + stMsgData->faultCode = fcInvalidParameterType; + ret=NOK; + } + + return ret; +} int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData (HOSTIF_MsgData_t *stMsgData) { char *issueStr = NULL; diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index ed1f9005d..8d541f1d5 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -185,6 +185,7 @@ #define RDK_REMOTE_DEBUGGER_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable" #define RDK_REMOTE_DEBUGGER_ISSUETYPE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" #define RDK_REMOTE_DEBUGGER_WEBCFGDATA "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData" +#define RDK_DOWNLOAD_STATUS "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus" #endif /* Profile: X_RDKCENTRAL-COM_RFC.Feature.RebootStop */ @@ -1203,6 +1204,7 @@ class hostIf_DeviceInfo { int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(HOSTIF_MsgData_t *); int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(HOSTIF_MsgData_t *); + int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerDownloadStatus(HOSTIF_MsgData_t *); #endif /* * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable From fe5d15ddda835fb13fc8bd163815a6edc360abeb Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Thu, 3 Apr 2025 21:47:08 -0400 Subject: [PATCH 052/161] 1.1.3 release changelog updates --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b82ac111..dc1cb9b7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.3](https://github.com/rdkcentral/tr69hostif/compare/1.1.2...1.1.3) + +- [RDKE] L2 Tests And Integration With CI for Remote Debugger Dynamic Updates [`#109`](https://github.com/rdkcentral/tr69hostif/pull/109) +- RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo [`#106`](https://github.com/rdkcentral/tr69hostif/pull/106) +- RDKEMW-2234: Updated MigrationStatus to persistent dir [`#103`](https://github.com/rdkcentral/tr69hostif/pull/103) +- Update cov_build.sh [`a47d3a4`](https://github.com/rdkcentral/tr69hostif/commit/a47d3a45f626fe914eb235beb4c4dacf88731de2) +- Merge tag '1.1.2' into develop [`22fd47f`](https://github.com/rdkcentral/tr69hostif/commit/22fd47f6b9f069fed6121af9eac0319788f6d659) + #### [1.1.2](https://github.com/rdkcentral/tr69hostif/compare/1.1.1...1.1.2) +> 1 April 2025 + - RDKEMW-2503 : Add RFC to data model- tr69hostif [`#79`](https://github.com/rdkcentral/tr69hostif/pull/79) - rebase [`#100`](https://github.com/rdkcentral/tr69hostif/pull/100) - RDKEMW-2234: Updated MigrationStatus tr181 param [`#96`](https://github.com/rdkcentral/tr69hostif/pull/96) +- 1.1.2 release changelog updates [`4697e26`](https://github.com/rdkcentral/tr69hostif/commit/4697e266261fb23b00b44a814b3d89d4ad3656ef) - Merge tag '1.1.1' into develop [`2e87e9f`](https://github.com/rdkcentral/tr69hostif/commit/2e87e9f85e3c46957dd59927fce3637175736b3c) #### [1.1.1](https://github.com/rdkcentral/tr69hostif/compare/1.1.0...1.1.1) From 1131e6595aebd1da474a2f09c92dd69424b2e989 Mon Sep 17 00:00:00 2001 From: nhanasi Date: Fri, 4 Apr 2025 15:55:02 +0000 Subject: [PATCH 053/161] Tr69hostif Sync c8e6c449 2024-08-26 apatel859 RDKTV-32602: Miracast : increase scan inter to 5 sec a13520f3 2024-07-16 Nikita Poltorapavlo RDKTV-31830 : split Cloud Store in a separate plugin Anand Kandasamy/Nikita Reviewing. Will follow up and bring to RDKE by 4/4. 8383b1f RDK-53840: Added new tr181 parameter along with custom get method 7691a1c RDK-54942: Segmented global/system-wide profile --- .../src/hostIf_DeviceClient_ReqHandler.cpp | 4 + .../waldb/data-model/data-model-generic.xml | 17 +- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 184 +++++++++++++++++- .../profiles/DeviceInfo/Device_DeviceInfo.h | 21 +- 4 files changed, 218 insertions(+), 8 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp index 08f80904a..8b73c0fc0 100644 --- a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp @@ -522,6 +522,10 @@ int DeviceClientReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) { ret = pIface->get_Device_DeviceInfo_SoftwareVersion(stMsgData); } + else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.MigrationPreparer.MigrationReady") == 0) + { + ret = pIface->get_Device_DeviceInfo_MigrationPreparer_MigrationReady(stMsgData); + } else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.Migration.MigrationStatus") == 0) { ret = pIface->get_Device_DeviceInfo_Migration_MigrationStatus(stMsgData); diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index a73280472..0966d4762 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4080,6 +4080,14 @@ + + + + + + + + @@ -4349,7 +4357,7 @@ - + @@ -4418,5 +4426,12 @@ + + + + + + + diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 7aa3a9776..563649ba6 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -3041,6 +3041,141 @@ int hostIf_DeviceInfo::set_xOpsReverseSshTrigger(HOSTIF_MsgData_t *stMsgData) return OK; } +/** + * @brief This function retrieves the MigrationReady param value from the MigrationReadyFile. + * + * @param[out] stMsgData TR-069 Host interface message request. + * @param[in] pChanged Status of the operation. + * + * @return Returns the status of the operation. + * + * @retval OK if it is successful. + * @retval ERR_INTERNAL_ERROR if not able to fetch from device. + * @ingroup TR69_HOSTIF_DEVICEINFO_API + */ +int hostIf_DeviceInfo::get_Device_DeviceInfo_MigrationPreparer_MigrationReady(HOSTIF_MsgData_t * stMsgData, bool *pChanged) +{ + std::string response; + std::string postData; + std::string tokenheader; + std::string value; + int i = 0; + CURL *curl = curl_easy_init(); + if(curl) + { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: call curl to get Components that are Ready..\n", __FUNCTION__); + + std::string sToken = get_security_token(); + tokenheader = "Authorization: Bearer " + sToken; + + postData = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.MigrationPreparer.getComponentReadiness\" }"; + + struct curl_slist *list = NULL; + + list = curl_slist_append(list, tokenheader.c_str()); + list = curl_slist_append(list, "Content-Type: application/json"); + + if(curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list) != CURLE_OK){ + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s:%d curl setup failed for CURLOPT_HTTPHEADER\n", __FUNCTION__, __LINE__); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + return NOK; + } + if(curl_easy_setopt(curl, CURLOPT_POST, 1L) != CURLE_OK){ + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s:%d curl setup failed for CURLOPT_POST\n", __FUNCTION__, __LINE__); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + return NOK; + } + if(curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str()) != CURLE_OK){ + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s:%d curl setup failed for CURLOPT_POSTFIELDS\n", __FUNCTION__, __LINE__); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + return NOK; + } + if(curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCurlResponse) != CURLE_OK){ + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s:%d curl setup failed for CURLOPT_WRITEFUNCTION\n", __FUNCTION__, __LINE__); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + return NOK; + } + if(curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response) != CURLE_OK){ + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s:%d curl setup failed for CURLOPT_WRITEDATA\n", __FUNCTION__, __LINE__); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + return NOK; + } + if(curl_easy_setopt(curl, CURLOPT_URL, JSONRPC_URL) != CURLE_OK){ + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s:%d: curl setup failed for CURLOPT_URL\n", __FUNCTION__, __LINE__); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + return NOK; + } + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); + + CURLcode res = curl_easy_perform(curl); + long http_code = 0; + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response : %d http response code: %ld\n", __FUNCTION__, res, http_code); + curl_easy_cleanup(curl); + curl_slist_free_all(list); + + if(res == CURLE_OK) + { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); + cJSON* root = cJSON_Parse(response.c_str()); + if(root) + { + cJSON* jsonObj = cJSON_GetObjectItem(root, "result"); + + if (jsonObj) + { + cJSON *ComponentList_obj = cJSON_GetObjectItem(jsonObj, "ComponentList"); + if (ComponentList_obj != NULL && cJSON_IsArray(ComponentList_obj)) { + int ComponentList_obj_count = cJSON_GetArraySize(ComponentList_obj); + for ( ; i < ComponentList_obj_count-1; i++) { + cJSON *Component = cJSON_GetArrayItem(ComponentList_obj, i); + if (cJSON_IsString(Component)) { + printf(" - %s\n", Component->valuestring); + value = value + Component->valuestring + "_"; + } + } + cJSON *Component = cJSON_GetArrayItem(ComponentList_obj, i); + value = value + Component->valuestring ; + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] componentList is not present \n", __FUNCTION__); + return NOK; + } + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + cJSON_Delete(root); + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: json parse error\n", __FUNCTION__); + } + } + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: curl init failed\n", __FUNCTION__); + } + + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(value.c_str()); + strncpy(stMsgData->paramValue, value.c_str(), stMsgData->paramLen); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ ); + return OK; +} + int hostIf_DeviceInfo::get_xOpsReverseSshArgs(HOSTIF_MsgData_t *stMsgData) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__); @@ -3419,6 +3554,7 @@ int hostIf_DeviceInfo::set_xRDKCentralComBootstrap(HOSTIF_MsgData_t * stMsgData) static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) { const char *apparmor_profiledir = "/etc/apparmor.d"; + const char *earlypolicy_base_dir = "/etc/apparmor/earlypolicy"; struct dirent *entry=NULL; DIR *dir=NULL; char *files_name = NULL; @@ -3492,12 +3628,48 @@ static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) sub_string=strstr(files_name, subtoken); if(sub_string != NULL) { fprintf(tmp_fptr,"%s\n",token); - } - else { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Invalid arguments %s error found in the parser\n", subtoken); - free(files_name); - return FALSE; - } + } else { + bool profile_found = false; + DIR *earlypolicy_dir_ptr = opendir(earlypolicy_base_dir); + if (earlypolicy_dir_ptr != NULL) { + struct dirent *earlypolicy_entry = NULL; + while ((earlypolicy_entry = readdir(earlypolicy_dir_ptr)) != NULL) { + // Skip . and .. entries + if (strcmp(earlypolicy_entry->d_name, ".") == 0 || strcmp(earlypolicy_entry->d_name, "..") == 0) { + continue; + } + // Construct the full path to the subdirectory + char subdir_path[1024]; + snprintf(subdir_path, sizeof(subdir_path), "%s/%s", earlypolicy_base_dir, earlypolicy_entry->d_name); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"snprintf args %s and %s\n", earlypolicy_base_dir, earlypolicy_entry->d_name); + // Open the subdirectory to search for the profile + DIR *subdir = opendir(subdir_path); + if (subdir != NULL) { + struct dirent *sub_entry = NULL; + while ((sub_entry = readdir(subdir)) != NULL) { + // Check if the file ends with .service.sp and matches subtoken + if (strstr(sub_entry->d_name, subtoken) != NULL && + strstr(sub_entry->d_name, ".service.sp") != NULL) { + profile_found = true; + break; + } + } + closedir(subdir); + } + if (profile_found) { + break; + } + } + closedir(earlypolicy_dir_ptr); + } + if (profile_found) { + fprintf(tmp_fptr, "%s\n", token); + } else { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Invalid arguments %s error found in the parser\n", subtoken); + free(files_name); + return FALSE; + } + } } token=strtok_r(NULL,"#",&sp); } diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 8d541f1d5..3c13b294c 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -515,7 +515,26 @@ class hostIf_DeviceInfo { * @see get_Device_DeviceInfo_ProductClass. */ int get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t *, bool *pChanged = NULL); - + + /** + * @brief get_Device_DeviceInfo_MigrationPreparer_MigrationReady. + * + * This function provides the component list which are ready for migration. + * The component name (human readable string). + * + * @return The status of the operation. + * + * @retval OK if DeviceInfo_MigrationPreparer_MigrationReady was successfully fetched. + :1 + * @retval ERR_INTERNAL_ERROR if not able to fetch from device. + * + * @sideeffect All necessary structures and buffers are deallocated. + * @execution Synchronous. + * + * @see get_Device_DeviceInfo_MigrationPreparer_MigrationReady. + */ + int get_Device_DeviceInfo_MigrationPreparer_MigrationReady(HOSTIF_MsgData_t *, bool *pChanged = NULL); + /** * @brief get_Device_DeviceInfo_Migration_MigrationStatus. * From 5197de2417ddd6205fb83024540cd6e32b8e65c0 Mon Sep 17 00:00:00 2001 From: nhanasi Date: Fri, 4 Apr 2025 15:55:02 +0000 Subject: [PATCH 054/161] Tr69hostif Sync c8e6c449 2024-08-26 apatel859 RDKTV-32602: Miracast : increase scan inter to 5 sec a13520f3 2024-07-16 Nikita Poltorapavlo RDKTV-31830 : split Cloud Store in a separate plugin Anand Kandasamy/Nikita Reviewing. Will follow up and bring to RDKE by 4/4. 8383b1f RDK-53840: Added new tr181 parameter along with custom get method 7691a1c RDK-54942: Segmented global/system-wide profile --- .../src/hostIf_DeviceClient_ReqHandler.cpp | 4 + .../waldb/data-model/data-model-generic.xml | 17 ++- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 129 +++++++++++++++++- .../profiles/DeviceInfo/Device_DeviceInfo.h | 21 ++- 4 files changed, 163 insertions(+), 8 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp index 08f80904a..8b73c0fc0 100644 --- a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp @@ -522,6 +522,10 @@ int DeviceClientReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) { ret = pIface->get_Device_DeviceInfo_SoftwareVersion(stMsgData); } + else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.MigrationPreparer.MigrationReady") == 0) + { + ret = pIface->get_Device_DeviceInfo_MigrationPreparer_MigrationReady(stMsgData); + } else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.Migration.MigrationStatus") == 0) { ret = pIface->get_Device_DeviceInfo_Migration_MigrationStatus(stMsgData); diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index a73280472..0966d4762 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4080,6 +4080,14 @@ + + + + + + + + @@ -4349,7 +4357,7 @@ - + @@ -4418,5 +4426,12 @@ + + + + + + + diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 7aa3a9776..ce432d9e1 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -3041,6 +3041,86 @@ int hostIf_DeviceInfo::set_xOpsReverseSshTrigger(HOSTIF_MsgData_t *stMsgData) return OK; } +/** + * @brief This function retrieves the MigrationReady param value from the MigrationReadyFile. + * + * @param[out] stMsgData TR-069 Host interface message request. + * @param[in] pChanged Status of the operation. + * + * @return Returns the status of the operation. + * + * @retval OK if it is successful. + * @retval ERR_INTERNAL_ERROR if not able to fetch from device. + * @ingroup TR69_HOSTIF_DEVICEINFO_API + */ +int hostIf_DeviceInfo::get_Device_DeviceInfo_MigrationPreparer_MigrationReady(HOSTIF_MsgData_t * stMsgData, bool *pChanged) +{ + std::string response; + std::string postData; + std::string value; + int i = 0; + + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: call curl to get Components that are Ready..\n", __FUNCTION__); + + postData = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.MigrationPreparer.getComponentReadiness\" }"; + response = getJsonRPCData(postData); + + if(response.c_str()) + { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); + cJSON* root = cJSON_Parse(response.c_str()); + if(root) + { + cJSON* jsonObj = cJSON_GetObjectItem(root, "result"); + if (jsonObj) + { + cJSON *ComponentList_obj = cJSON_GetObjectItem(jsonObj, "ComponentList"); + if (ComponentList_obj != NULL && cJSON_IsArray(ComponentList_obj)) + { + int ComponentList_obj_count = cJSON_GetArraySize(ComponentList_obj); + for ( ; i < ComponentList_obj_count-1; i++) + { + cJSON *Component = cJSON_GetArrayItem(ComponentList_obj, i); + if (cJSON_IsString(Component)) + { + printf(" - %s\n", Component->valuestring); + value = value + Component->valuestring + "_"; + } + } + cJSON *Component = cJSON_GetArrayItem(ComponentList_obj, i); + value = value + Component->valuestring ; + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] componentList is not present \n", __FUNCTION__); + return NOK; + } + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + cJSON_Delete(root); + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: json parse error\n", __FUNCTION__); + } + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: curl init failed\n", __FUNCTION__); + } + + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(value.c_str()); + strncpy(stMsgData->paramValue, value.c_str(), stMsgData->paramLen); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ ); + return OK; +} + int hostIf_DeviceInfo::get_xOpsReverseSshArgs(HOSTIF_MsgData_t *stMsgData) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__); @@ -3419,6 +3499,7 @@ int hostIf_DeviceInfo::set_xRDKCentralComBootstrap(HOSTIF_MsgData_t * stMsgData) static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) { const char *apparmor_profiledir = "/etc/apparmor.d"; + const char *earlypolicy_base_dir = "/etc/apparmor/earlypolicy"; struct dirent *entry=NULL; DIR *dir=NULL; char *files_name = NULL; @@ -3492,12 +3573,48 @@ static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) sub_string=strstr(files_name, subtoken); if(sub_string != NULL) { fprintf(tmp_fptr,"%s\n",token); - } - else { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Invalid arguments %s error found in the parser\n", subtoken); - free(files_name); - return FALSE; - } + } else { + bool profile_found = false; + DIR *earlypolicy_dir_ptr = opendir(earlypolicy_base_dir); + if (earlypolicy_dir_ptr != NULL) { + struct dirent *earlypolicy_entry = NULL; + while ((earlypolicy_entry = readdir(earlypolicy_dir_ptr)) != NULL) { + // Skip . and .. entries + if (strcmp(earlypolicy_entry->d_name, ".") == 0 || strcmp(earlypolicy_entry->d_name, "..") == 0) { + continue; + } + // Construct the full path to the subdirectory + char subdir_path[1024]; + snprintf(subdir_path, sizeof(subdir_path), "%s/%s", earlypolicy_base_dir, earlypolicy_entry->d_name); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"snprintf args %s and %s\n", earlypolicy_base_dir, earlypolicy_entry->d_name); + // Open the subdirectory to search for the profile + DIR *subdir = opendir(subdir_path); + if (subdir != NULL) { + struct dirent *sub_entry = NULL; + while ((sub_entry = readdir(subdir)) != NULL) { + // Check if the file ends with .service.sp and matches subtoken + if (strstr(sub_entry->d_name, subtoken) != NULL && + strstr(sub_entry->d_name, ".service.sp") != NULL) { + profile_found = true; + break; + } + } + closedir(subdir); + } + if (profile_found) { + break; + } + } + closedir(earlypolicy_dir_ptr); + } + if (profile_found) { + fprintf(tmp_fptr, "%s\n", token); + } else { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Invalid arguments %s error found in the parser\n", subtoken); + free(files_name); + return FALSE; + } + } } token=strtok_r(NULL,"#",&sp); } diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 8d541f1d5..3c13b294c 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -515,7 +515,26 @@ class hostIf_DeviceInfo { * @see get_Device_DeviceInfo_ProductClass. */ int get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t *, bool *pChanged = NULL); - + + /** + * @brief get_Device_DeviceInfo_MigrationPreparer_MigrationReady. + * + * This function provides the component list which are ready for migration. + * The component name (human readable string). + * + * @return The status of the operation. + * + * @retval OK if DeviceInfo_MigrationPreparer_MigrationReady was successfully fetched. + :1 + * @retval ERR_INTERNAL_ERROR if not able to fetch from device. + * + * @sideeffect All necessary structures and buffers are deallocated. + * @execution Synchronous. + * + * @see get_Device_DeviceInfo_MigrationPreparer_MigrationReady. + */ + int get_Device_DeviceInfo_MigrationPreparer_MigrationReady(HOSTIF_MsgData_t *, bool *pChanged = NULL); + /** * @brief get_Device_DeviceInfo_Migration_MigrationStatus. * From 8196aaacc5a229cf1516d69a5dc8376f7cfb122e Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Fri, 4 Apr 2025 15:15:53 -0400 Subject: [PATCH 055/161] RDK-51094 : XIONE-16968 : Add the new RFC config to data-model-generic.xml Signed-off-by: Venkata Bojja --- .../parodusClient/waldb/data-model/data-model-generic.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 0966d4762..de6fd17e2 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4411,6 +4411,13 @@ + + + + + + + From 5fbfe431cd0d4a69033bdd136cf4637f32b4b9c0 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Tue, 8 Apr 2025 14:40:58 -0400 Subject: [PATCH 056/161] 1.1.4 release changelog updates --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc1cb9b7e..fa0a743c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.4](https://github.com/rdkcentral/tr69hostif/compare/1.1.3...1.1.4) + +- RDK-51094 : XIONE-16968 : Add the new RFC config to data-model-generi… [`#115`](https://github.com/rdkcentral/tr69hostif/pull/115) +- Tr69hostif Sync [`#114`](https://github.com/rdkcentral/tr69hostif/pull/114) +- RDK-51094 : XIONE-16968 : Add the new RFC config to data-model-generic.xml [`8196aaa`](https://github.com/rdkcentral/tr69hostif/commit/8196aaacc5a229cf1516d69a5dc8376f7cfb122e) +- Merge tag '1.1.3' into develop [`00f6a70`](https://github.com/rdkcentral/tr69hostif/commit/00f6a701419ca6c21563e485ecfe9a4543186af2) + #### [1.1.3](https://github.com/rdkcentral/tr69hostif/compare/1.1.2...1.1.3) +> 3 April 2025 + - [RDKE] L2 Tests And Integration With CI for Remote Debugger Dynamic Updates [`#109`](https://github.com/rdkcentral/tr69hostif/pull/109) - RDK-56451 [RDKE] Move tr69hostif L2 binary into common docker repo [`#106`](https://github.com/rdkcentral/tr69hostif/pull/106) - RDKEMW-2234: Updated MigrationStatus to persistent dir [`#103`](https://github.com/rdkcentral/tr69hostif/pull/103) +- 1.1.3 release changelog updates [`fe5d15d`](https://github.com/rdkcentral/tr69hostif/commit/fe5d15ddda835fb13fc8bd163815a6edc360abeb) - Update cov_build.sh [`a47d3a4`](https://github.com/rdkcentral/tr69hostif/commit/a47d3a45f626fe914eb235beb4c4dacf88731de2) - Merge tag '1.1.2' into develop [`22fd47f`](https://github.com/rdkcentral/tr69hostif/commit/22fd47f6b9f069fed6121af9eac0319788f6d659) From ed1d27bd968a19bcaa28dc90b2c8aadf8ed6c584 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Fri, 11 Apr 2025 09:24:08 -0400 Subject: [PATCH 057/161] RDKE-778: Add logs to rdmagent (#121) * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index ce432d9e1..12613b765 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -5344,7 +5344,7 @@ int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t * RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Executing Command rdm %s \n", __FUNCTION__ , stMsgData->paramValue); - ret = v_secure_system("rdm -v \"%s\" &", stMsgData->paramValue); + ret = v_secure_system("backgroundrun rdm -v \"%s\" >> /opt/logs/rdm_status.log 2>&1", stMsgData->paramValue); if (ret != 0) { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Failed to execute the command. Returned error code '%d'\n", __FUNCTION__, ret); From 8f8eaf384a87378bb19321f4477e9d4ad3baccb8 Mon Sep 17 00:00:00 2001 From: mtirum011 Date: Tue, 15 Apr 2025 14:24:27 +0000 Subject: [PATCH 058/161] RDK-48829 [RDK-E] L2 test framework for tr69hostif --- cov_build.sh | 4 +- run_l2.sh | 9 +- .../features/tr69hostif_deviceip.feature | 30 +++ .../functional-tests/tests/basic_constants.py | 1 + .../tests/tr69hostif_deviceip.py | 187 ++++++++++++++++++ 5 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 test/functional-tests/features/tr69hostif_deviceip.feature create mode 100644 test/functional-tests/tests/tr69hostif_deviceip.py diff --git a/cov_build.sh b/cov_build.sh index 9d0f1ce62..af71d4e70 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -64,9 +64,9 @@ cd $WORKDIR sed -i '/PKG_CHECK_MODULES(\[PROCPS\], \[libproc >= 3.2.8\])/s/^/#/' ./configure.ac rm -f ./src/unittest/stubs/rdk_debug.h autoreconf -i -./configure --enable-libsoup3=yes +./configure --enable-libsoup3=yes --enable-IPv6=yes -make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DLIBSOUP3_ENABLE" \ +make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DLIBSOUP3_ENABLE -DIPV6_SUPPORT" \ AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" make install diff --git a/run_l2.sh b/run_l2.sh index 411085d08..d2b29933c 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -23,16 +23,22 @@ export top_srcdir=`pwd` RESULT_DIR="/tmp/l2_test_report" mkdir -p "$RESULT_DIR" +apt-get update && apt-get install -y iproute2 cp ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml /etc/data-model-tv.xml cp ./src/hostif/parodusClient/waldb/data-model/data-model-generic.xml /etc/data-model-generic.xml cp ./src/hostif/parodusClient/waldb/data-model/data-model-stb.xml /etc/data-model-stb.xml +sed -i '/ModelName/ {n; n; a\ + +}' /etc/data-model-stb.xml - echo "RDK_PROFILE=STB" > /etc/device.properties +dos2unix /etc/data-model-stb.xml + echo "RDK_PROFILE=STB" > /etc/device.properties +echo "VERSION=99.99.15.07" >> /version.txt cp ./src/integrationtest/conf/mgrlist.conf /etc/ @@ -56,4 +62,5 @@ fi pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/bootup_sequence.json test/functional-tests/tests/test_bootup_sequence.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/handlers_communications.json test/functional-tests/tests/test_handlers_communications.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/deviceip.json test/functional-tests/tests/tr69hostif_deviceip.py diff --git a/test/functional-tests/features/tr69hostif_deviceip.feature b/test/functional-tests/features/tr69hostif_deviceip.feature new file mode 100644 index 000000000..fee15f3c9 --- /dev/null +++ b/test/functional-tests/features/tr69hostif_deviceip.feature @@ -0,0 +1,30 @@ +#################################################################################### +# If not stated otherwise in this file or this component's Licenses.txt file the +# following copyright and licenses apply: +# +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#################################################################################### + + +Feature: tr69hostif runs as daemon to collect data + + Scenario: tr69hostif runs as daemon + Given When the tr69hostif binary is invoked + Then the tr69hostif should be running as a daemon + And when the tr69hostif is initialized successfully + Then the tr69hostif Profile Initialization is done for Device.DeviceInfo + Then the tr69hostif validation is done for Device.DeviceInfo get/set handlers + Then the tr69hostif validation is done for Device.IP get/set handlers + Then the tr69hostif validation is done for Device.Services get/set handlers diff --git a/test/functional-tests/tests/basic_constants.py b/test/functional-tests/tests/basic_constants.py index 3b10f8d0d..506361886 100644 --- a/test/functional-tests/tests/basic_constants.py +++ b/test/functional-tests/tests/basic_constants.py @@ -41,6 +41,7 @@ T2_REPORT_PROFILE_PARAM_MSG_PCK="Device.X_RDKCENTRAL-COM_T2.ReportProfilesMsgPack" T2_TEMP_REPORT_PROFILE_PARAM="Device.X_RDKCENTRAL-COM_T2.Temp_ReportProfiles" RBUS_EXCEPTION_STRING = "Failed to get the data" +RBUS_SUCCESS_STRING = "setvalues succeeded.." LOG_FILE = "/opt/logs/tr69hostif.log.0" diff --git a/test/functional-tests/tests/tr69hostif_deviceip.py b/test/functional-tests/tests/tr69hostif_deviceip.py new file mode 100644 index 000000000..97bb570d3 --- /dev/null +++ b/test/functional-tests/tests/tr69hostif_deviceip.py @@ -0,0 +1,187 @@ +#################################################################################### +# If not stated otherwise in this file or this component's Licenses file the +# following copyright and licenses apply: +# +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#################################################################################### + + +import subprocess +import pytest +from time import sleep + +from helper_functions import * + +@pytest.mark.run(order=13) +def test_DeviceDefault_Set_Get_Handler(): + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.SoftwareVersion" + VERSION_MSG = "99.99.15.07" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert VERSION_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.ModelName" + MODEL_NAME = "DOCKER" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert MODEL_NAME in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.X_COMCAST-COM_FirmwareFilename" + FW_FILE_NAME = "Platform_Cotainer_1.0.0" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert FW_FILE_NAME in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.Enable" + STATUS_MSG = "true" + rbus_set_data(DATA_ELEMENT_NAME, "string", STATUS_MSG) + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + + +@pytest.mark.run(order=14) +def test_DeviceIP_Set_Get_Handler(): + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Prefix.1.Autonomous" + STATUS_MSG = "false" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Address.1.Anycast" + STATUS_MSG = "false" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Address.1.Enable" + STATUS_MSG = "true" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Prefix.1.StaticType" + STATUS_MSG = "Inapplicable" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6AddressNumberOfEntries" + ENTRY_COUNT_MSG = "1" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert ENTRY_COUNT_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Address.1.Origin" + ORIGIN_MSG = "WellKnown" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert ORIGIN_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv4Address.1.Enable" + STATUS_MSG = "true" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Prefix.1.PrefixStatus" + PREFIX_STATUS_MSG = "Preferred" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert PREFIX_STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Address.1.PreferredLifetime" + PREF_LTF_STATUS_MSG = "0001-01-01T00:00:00Z" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert PREF_LTF_STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Enable" + STATUS_MSG = "true" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.IP.Interface.1.IPv6Prefix.1.ValidLifetime" + PREF_LTF_STATUS_MSG = "0001-01-01T00:00:00Z" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert PREF_LTF_STATUS_MSG in rstdout + +@pytest.mark.run(order=15) +def test_DeviceServices_Set_Get_Handler(): + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.Services.STBServiceNumberOfEntries" + STB_ENTRY_COUNT_MSG = "1" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert STB_ENTRY_COUNT_MSG in rstdout + +@pytest.mark.run(order=16) +def test_ReverseSSH_Set_Get_Handler(): + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshStatus" + SSH_STATUS_MSG = "INACTIVE" + # Force reload config fetch from xconf + rstdout = rbus_get_data(DATA_ELEMENT_NAME) + assert RBUS_EXCEPTION_STRING not in rstdout + assert SSH_STATUS_MSG in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshTrigger" + SSH_TRG_MSG = "start shorts" + rstdout = rbus_set_data(DATA_ELEMENT_NAME, "string", SSH_TRG_MSG) + # Force reload config fetch from xconf + assert RBUS_SUCCESS_STRING in rstdout + + #clear_T2logs() + DATA_ELEMENT_NAME = "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshArgs" + SSH_ARGS_MSG = "host=skyfoxtel.xcal.tv;hostIp=skyfoxtel.xcal.tv;stunnelport=2009;idletimeout=300;revsshport=3008;sshport=2221;user=webpa_user01;" + rstdout = rbus_set_data(DATA_ELEMENT_NAME, "string", SSH_ARGS_MSG) + # Force reload config fetch from xconf + assert RBUS_SUCCESS_STRING in rstdout + From 032cfc8c435e660f590e94172e3c2bec825f40d0 Mon Sep 17 00:00:00 2001 From: sborushevsky Date: Wed, 23 Apr 2025 16:11:51 +0300 Subject: [PATCH 059/161] RDK-31923 : Added Enable parameter for Telemetry RFC. (#123) --- .../parodusClient/waldb/data-model/data-model-generic.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index de6fd17e2..f5d947e06 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4096,6 +4096,11 @@ + + + + + From 576b8acd33a780b70f74c08b2b2fe44010a1331b Mon Sep 17 00:00:00 2001 From: sborushevsky Date: Thu, 24 Apr 2025 19:04:20 +0300 Subject: [PATCH 060/161] Revert "RDK-31923 : Added Enable parameter for Telemetry RFC. (#123)" (#129) This reverts commit 032cfc8c435e660f590e94172e3c2bec825f40d0. --- .../parodusClient/waldb/data-model/data-model-generic.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index f5d947e06..de6fd17e2 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4096,11 +4096,6 @@ - - - - - From 580f18dfe6ffc25e4b6eabb889f118428cea8fc6 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Sun, 27 Apr 2025 18:17:41 -0400 Subject: [PATCH 061/161] 1.1.5 release changelog updates --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0a743c6..8b5432bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.5](https://github.com/rdkcentral/tr69hostif/compare/1.1.4...1.1.5) + +- Revert "RDK-31923 : Added Enable parameter for Telemetry RFC. (#123)" [`#129`](https://github.com/rdkcentral/tr69hostif/pull/129) +- RDK-48829 [RDK-E] L2 test framework for tr69hostif [`#124`](https://github.com/rdkcentral/tr69hostif/pull/124) +- RDK-31923 : Added Enable parameter for Telemetry RFC. [`#123`](https://github.com/rdkcentral/tr69hostif/pull/123) +- RDKE-778: Add logs to rdmagent [`#121`](https://github.com/rdkcentral/tr69hostif/pull/121) +- Merge tag '1.1.4' into develop [`7b0f8e0`](https://github.com/rdkcentral/tr69hostif/commit/7b0f8e0521d97021556f7e97c7cc8e22d9cfa137) + #### [1.1.4](https://github.com/rdkcentral/tr69hostif/compare/1.1.3...1.1.4) +> 8 April 2025 + - RDK-51094 : XIONE-16968 : Add the new RFC config to data-model-generi… [`#115`](https://github.com/rdkcentral/tr69hostif/pull/115) - Tr69hostif Sync [`#114`](https://github.com/rdkcentral/tr69hostif/pull/114) +- 1.1.4 release changelog updates [`5fbfe43`](https://github.com/rdkcentral/tr69hostif/commit/5fbfe431cd0d4a69033bdd136cf4637f32b4b9c0) - RDK-51094 : XIONE-16968 : Add the new RFC config to data-model-generic.xml [`8196aaa`](https://github.com/rdkcentral/tr69hostif/commit/8196aaacc5a229cf1516d69a5dc8376f7cfb122e) - Merge tag '1.1.3' into develop [`00f6a70`](https://github.com/rdkcentral/tr69hostif/commit/00f6a701419ca6c21563e485ecfe9a4543186af2) From 2350976d583ca413a8751c7dbfe48a6d405555bb Mon Sep 17 00:00:00 2001 From: fzahir786 Date: Tue, 29 Apr 2025 22:31:43 +0530 Subject: [PATCH 062/161] RDKEMW-3545: Modified MigrationStatus Default value to NOT_NEEDED (#127) --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 12613b765..890bd76df 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -492,7 +492,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t * */ int hostIf_DeviceInfo::get_Device_DeviceInfo_Migration_MigrationStatus(HOSTIF_MsgData_t * stMsgData, bool *pChanged) { - string line = "NOT_STARTED"; + string line = "NOT_NEEDED"; RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Entering..\n", __FUNCTION__ ); ifstream file_read (MigrationStatus); try { From cd02e0e9493b78e65ab55fba181a0d71f8c1e344 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Wed, 30 Apr 2025 06:50:44 +0530 Subject: [PATCH 063/161] RDK-56124-RDKE-Fix coverity issues in tr69hostif and profiles (#105) * Update Device_WiFi_EndPoint_Security.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update Device_WiFi.cpp * Update Device_WiFi_EndPoint.cpp * Update IniFile.cpp * Update Device_InterfaceStack.cpp * RDK-56124-[RDKE] Fix coverity issues in tr69hostif and profiles * fix the coverity issues * Final changes * Update waldb.cpp * Update waldb.cpp * Update startParodus.cpp * Update startParodus.cpp * Testing branch * Update XrdkCentralComBSStore.cpp * Update Device_WiFi_SSID.cpp * Update Device_WiFi_EndPoint.cpp * Update Device_DeviceInfo.cpp * Update XrdkCentralComBSStore.cpp * Update XrdkCentralComBSStore.cpp * Update XrdkCentralComBSStore.cpp * Update startParodus.cpp * Update startParodus.cpp * Update Device_Ethernet_Interface.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update Device_Time.cpp * Update Device_Time.cpp * Update waldb.cpp * Update Device_DeviceInfo_Processor.cpp * Update Device_DeviceInfo_Processor.cpp * Update Device_Time.cpp * Update Device_DeviceInfo_Processor.cpp * Update startParodus.cpp * Update waldb.cpp * Update Device_Time.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update Device_Time.cpp * Update Device_Time.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update startParodus.cpp * Update Components_XrdkSDCard.cpp * Update Components_XrdkSDCard.cpp * Update XrdkCentralComBSStore.cpp * Update Device_Ethernet_Interface.cpp * Update Device_DeviceInfo.cpp * Update Device_WiFi_SSID.cpp * Update XrdkCentralComBSStore.cpp * Update Device_Ethernet_Interface.cpp * Update XrdkCentralComBSStore.cpp * Update XrdkCentralComBSStore.cpp * Update XrdkCentralComBSStore.cpp * Update waldb.cpp * Update waldb.cpp * Update waldb.cpp * Update waldb.cpp * Update XrdkCentralComBSStore.cpp * Update XrdkCentralComBSStore.cpp * Update XrdkCentralComBSStore.cpp --- .../startParodus/startParodus.cpp | 576 +++++++++-------- src/hostif/parodusClient/waldb/waldb.cpp | 4 +- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 17 +- .../Device_DeviceInfo_Processor.cpp | 4 +- .../DeviceInfo/XrdkCentralComBSStore.cpp | 74 ++- .../Ethernet/Device_Ethernet_Interface.cpp | 8 +- .../Device_Ethernet_Interface_Stats.cpp | 6 +- .../InterfaceStack/Device_InterfaceStack.cpp | 2 +- .../STBService/Components_XrdkSDCard.cpp | 37 +- src/hostif/profiles/Time/Device_Time.cpp | 10 +- src/hostif/profiles/wifi/Device_WiFi.cpp | 4 +- .../profiles/wifi/Device_WiFi_EndPoint.cpp | 5 +- .../wifi/Device_WiFi_EndPoint_Security.cpp | 5 +- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 4 +- src/hostif/src/IniFile.cpp | 2 +- src/hostif/src/hostIf_main.cpp | 610 +++++++++--------- src/hostif/src/hostIf_utils.cpp | 9 +- 17 files changed, 754 insertions(+), 623 deletions(-) diff --git a/src/hostif/parodusClient/startParodus/startParodus.cpp b/src/hostif/parodusClient/startParodus/startParodus.cpp index 558d1ce97..1b724ecf1 100644 --- a/src/hostif/parodusClient/startParodus/startParodus.cpp +++ b/src/hostif/parodusClient/startParodus/startParodus.cpp @@ -29,6 +29,7 @@ #include "cJSON.h" #include "rfcapi.h" #include "hostIf_utils.h" +//#include "rdk_debug.h" #include "secure_wrapper.h" #include #include @@ -53,6 +54,7 @@ #define PARTNERID "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId" #define UNKNOWN_PARTNERID "unknown" #define PARTNERID_APPEND "*," +#define MAX_PARTNER_ID_SIZE 128 #ifndef CONFIG_RES_FILE // please update with the orginal value based on your device #define CONFIG_RES_FILE "/tmp/data" @@ -79,7 +81,8 @@ std::string get_HWMAcAddress() fp = fopen(HWMAC_FILE, "r"); if (fp != NULL) { - fread(tempMAC, 1, 17, fp); + size_t bytesRead = fread(tempMAC, 1, 17, fp); + printf("The value of bytes read: %zu\n", bytesRead); fclose(fp); for (srcCount = 0; dstCount < 12 && srcCount < 17; srcCount++) { @@ -96,7 +99,6 @@ std::string get_HWMAcAddress() } return hwAddr; } - std::string get_PartnerId() { char PartnerId[128] = ""; @@ -104,30 +106,41 @@ std::string get_PartnerId() FILE *fp = NULL; int ch_count = 0; std::string partnerId = ""; - struct stat status; + int fd; RFC_ParamData_t param = {0}; - // use partner-id from auth service to start parodus - if ((stat(PARTNERID_FILE, &status) == 0)) + fd = open(PARTNERID_FILE, O_RDONLY); + if (fd != -1) { - fp = fopen(PARTNERID_FILE, "r"); - fseek(fp, 0, SEEK_END); - ch_count = ftell(fp); - if (ch_count < 1) - { - printf("Partner ID file is Empty %s\n", PARTNERID_FILE); - fclose(fp); - } - else + fp = fdopen(fd, "r"); + if (fp != NULL) { - fseek(fp, 0, SEEK_SET); - fread(PartnerId, 1, ch_count, fp); - fclose(fp); - fp = NULL; - partnerId = PartnerId; - printf("[%s:%d]PARTNERID = [ %s ] \n", __FUNCTION__, __LINE__, PartnerId); + fseek(fp, 0, SEEK_END); + ch_count = ftell(fp); + if (ch_count < 1) + { + printf("Partner ID file is Empty %s\n", PARTNERID_FILE); + fclose(fp); + } + else + { + fseek(fp, 0, SEEK_SET); + size_t bytesRead = fread(PartnerId, 1, ch_count, fp); + if (bytesRead != (size_t)ch_count) + { + printf("Error reading Partner ID, bytes read: %zu\n", bytesRead); + fclose(fp); + return partnerId; + } + PartnerId[ch_count] = '\0'; + fclose(fp); + fp = NULL; + partnerId = PartnerId; + printf("[%s:%d]PARTNERID = [ %s ] \n", __FUNCTION__, __LINE__, PartnerId); + } } - } + close(fd); + } else { getRFCParameter((char *)"webcfg", PARTNERID, ¶m); @@ -136,8 +149,10 @@ std::string get_PartnerId() { printf("[%s:%d]PARTNERID RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); // remove quotes arround data - strncpy(PartnerId, ¶m.value[0], dataLen); - PartnerId[dataLen] = '\0'; + strncpy(PartnerId, ¶m.value[0], sizeof(PartnerId) - 1); + PartnerId[sizeof(PartnerId) - 1] = '\0'; + + } } if (!strncmp(PartnerId, UNKNOWN_PARTNERID, sizeof(UNKNOWN_PARTNERID))) @@ -163,51 +178,62 @@ std::string get_RebootReason() FILE *fp = NULL; int ch_count = 0; std::string reboot_reason = ""; - struct stat status; + int fd; - if ((stat(REBOOT_REASON_SECURE_FILE, &status) == 0)) - fp = fopen(REBOOT_REASON_SECURE_FILE, "r"); - if (fp != NULL) + fd = open(REBOOT_REASON_SECURE_FILE, O_RDONLY); + if (fd != -1) { - fseek(fp, 0, SEEK_END); - ch_count = ftell(fp); - if (ch_count < 1) + fp = fdopen(fd, "r"); + if (fp != NULL) { - printf("Reboot reason file is Empty %s\n", REBOOT_REASON_SECURE_FILE); - fclose(fp); - } - else - { - fseek(fp, 0, SEEK_SET); - rebootReasonFile = (char *)malloc(sizeof(char) * (ch_count + 1)); - if (rebootReasonFile) - { - fread(rebootReasonFile, 1, ch_count, fp); - rebootReasonFile[ch_count] = '\0'; - fclose(fp); - fp = NULL; - - // CID:18143 - NEGATIVE RETURNS - since ch_count cannot be negative - cJSON *rebootFile = cJSON_Parse(rebootReasonFile); - if (rebootFile) - { - cJSON *reason = NULL; - - reason = cJSON_GetObjectItem(rebootFile, "reason"); - if ((NULL != reason && NULL != reason->valuestring)) - { - reboot_reason = reason->valuestring; - reboot_reason.erase(std::remove(reboot_reason.begin(), reboot_reason.end(), '\n'), reboot_reason.cend()); - } - } - free(rebootReasonFile); // CID:18606 - Resource leak - } - else - { - fclose(fp); - fp = NULL; + fseek(fp, 0, SEEK_END); + ch_count = ftell(fp); + if (ch_count < 1) + { + printf("Reboot reason file is Empty %s\n", REBOOT_REASON_SECURE_FILE); + fclose(fp); + } + else + { + fseek(fp, 0, SEEK_SET); + rebootReasonFile = (char *)malloc(sizeof(char) * (ch_count + 1)); + if (rebootReasonFile) + { + size_t bytesRead = fread(rebootReasonFile, 1, ch_count, fp); + if (bytesRead != (size_t)ch_count) + { + printf("Error reading file, bytes read: %zu\n", bytesRead); + free(rebootReasonFile); + fclose(fp); + return reboot_reason; + } + rebootReasonFile[ch_count] = '\0'; + fclose(fp); + fp = NULL; + + // CID:18143 - NEGATIVE RETURNS - since ch_count cannot be negative + cJSON *rebootFile = cJSON_Parse(rebootReasonFile); + if (rebootFile) + { + cJSON *reason = NULL; + + reason = cJSON_GetObjectItem(rebootFile, "reason"); + if ((NULL != reason && NULL != reason->valuestring)) + { + reboot_reason = reason->valuestring; + reboot_reason.erase(std::remove(reboot_reason.begin(), reboot_reason.end(), '\n'), reboot_reason.cend()); + } + } + free(rebootReasonFile); // CID:18606 - Resource leak + } + else + { + fclose(fp); + fp = NULL; + } } } + close(fd); } else { @@ -228,7 +254,13 @@ std::string get_FwName() fgets(line, 128, fp); token = strtok(line, ":"); token = strtok(NULL, ":"); - strncpy(imageName, token, strlen(token)); + if (token != NULL) { + snprintf(imageName, sizeof(imageName), "%s", token); + } + else { + // Handle the null case if necessary + printf("Error: Token is null\n"); + } fclose(fp); fp = NULL; fw_name = imageName; @@ -239,226 +271,262 @@ std::string get_FwName() int main(int argc, char *argv[]) { - /*Parameter for the parodus client*/ - std::string webpa_url = ""; - std::string partnerId = ""; - char *manufacturer = NULL; - char *model = NULL; - std::string serialNumber = ""; - std::string networkIf = ""; - std::string dnsTextUrl = ""; - std::string tokenServerUrl = ""; - std::string bootTime = ""; - std::string clientCertFile = ""; - int acquireJWT = 0; - int serverPort = 0; - int pingWaitTime = 0; - struct stat status; - FILE *fp = NULL; - int ch_count = 0; - char *webpaCfgFile = NULL; - RFC_ParamData_t param = {0}; - int dataLen = 0; - - // parodus_Gloop = g_main_loop_new(NULL, FALSE); - - signal(SIGTERM, processExit); - signal(SIGKILL, processExit); - signal(SIGABRT, processExit); - - // Get the server IP from RFC parameter - getRFCParameter((char *)"webcfg", SERVER_IP_URL, ¶m); - dataLen = strlen(param.value); - if (dataLen != 0) - { - printf("[%s:%d]SERVER_IP_URL RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); - webpa_url = param.value; - } - - // Get the data from Configuration file - if ((stat(WEBPA_CFG_OVERIDE_FILE, &status) == 0)) - { - fp = fopen(WEBPA_CFG_OVERIDE_FILE, "r"); - } - else - { - fp = fopen(WEBPA_CFG_FILE, "r"); - } - - if (fp != NULL) - { - fseek(fp, 0, SEEK_END); - ch_count = ftell(fp); + try + { + /*Parameter for the parodus client*/ + std::string webpa_url = ""; + std::string partnerId = ""; + char *manufacturer = NULL; + char *model = NULL; + std::string serialNumber = ""; + std::string networkIf = ""; + std::string dnsTextUrl = ""; + std::string tokenServerUrl = ""; + std::string bootTime = ""; + std::string clientCertFile = ""; + int acquireJWT = 0; + int serverPort = 0; + int pingWaitTime = 0; + struct stat status; + FILE *fp = NULL; + int ch_count = 0; + char *webpaCfgFile = NULL; + RFC_ParamData_t param = {0}; + int dataLen = 0; + + // parodus_Gloop = g_main_loop_new(NULL, FALSE); + + signal(SIGTERM, processExit); + signal(SIGKILL, processExit); + signal(SIGABRT, processExit); + + // Get the server IP from RFC parameter + getRFCParameter((char *)"webcfg", SERVER_IP_URL, ¶m); + dataLen = strlen(param.value); + if (dataLen != 0) + { + printf("[%s:%d]SERVER_IP_URL RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); + webpa_url = param.value; + } - if (ch_count < 1) + // Get the data from Configuration file + int fd = open(WEBPA_CFG_OVERIDE_FILE, O_RDONLY); + if (fd != -1) { - printf("WebPA config file is Empty %s\n", WEBPA_CFG_FILE); - fclose(fp); + fp = fdopen(fd, "r"); } else { - fseek(fp, 0, SEEK_SET); - webpaCfgFile = (char *)malloc(sizeof(char) * (ch_count + 1)); - - if (webpaCfgFile) + fd = open(WEBPA_CFG_FILE, O_RDONLY); + if (fd != -1) { - fread(webpaCfgFile, 1, ch_count, fp); - webpaCfgFile[ch_count] = '\0'; - // CID:18143 - NEGATIVE RETURNS - since ch_count cannot be negative - cJSON *webpa_cfg = cJSON_Parse(webpaCfgFile); - if (webpa_cfg) - { - cJSON *serverIp = NULL; - cJSON *aJwt = NULL; - cJSON *DeviceNwkIf = NULL; - cJSON *srvrPort = NULL; - cJSON *MaxPingWaitTimeInSec = NULL; - - serverIp = cJSON_GetObjectItem(webpa_cfg, "ServerIP"); - aJwt = cJSON_GetObjectItem(webpa_cfg, "acquire-jwt"); - DeviceNwkIf = cJSON_GetObjectItem(webpa_cfg, "DeviceNetworkInterface"); - srvrPort = cJSON_GetObjectItem(webpa_cfg, "ServerPort"); - MaxPingWaitTimeInSec = cJSON_GetObjectItem(webpa_cfg, "MaxPingWaitTimeInSec"); - - if ((NULL != serverIp && NULL != serverIp->valuestring) && (webpa_url.empty())) - { - // strncpy(ServerIP,serverIp->valuestring,strlen(serverIp->valuestring)); - // printf("[%s:%d]ServerIP = [ %s ] \n", __FUNCTION__, __LINE__, ServerIP); - webpa_url = serverIp->valuestring; - } + fp = fdopen(fd, "r"); + } + } - if ((NULL != aJwt)) - { - acquireJWT = aJwt->valueint; - printf("acquireJWT = [ %d ] \n", acquireJWT); - } + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); + ch_count = ftell(fp); - if ((NULL != DeviceNwkIf && NULL != DeviceNwkIf->valuestring)) - { - networkIf = DeviceNwkIf->valuestring; - printf("NetworkIF = [ %s] \n", networkIf.c_str()); - } + if (ch_count < 1) + { + printf("WebPA config file is Empty %s\n", WEBPA_CFG_FILE); + fclose(fp); + } + else + { + fseek(fp, 0, SEEK_SET); + webpaCfgFile = (char *)malloc(sizeof(char) * (ch_count + 1)); - if ((NULL != srvrPort)) + if (webpaCfgFile) + { + size_t bytesRead = fread(webpaCfgFile, 1, ch_count, fp); + if (bytesRead != static_cast(ch_count)) { - serverPort = srvrPort->valueint; - printf("serverPort = [ %d ] \n", serverPort); + printf("Error reading WebPA config file, bytes read: %zu\n", bytesRead); + free(webpaCfgFile); + fclose(fp); + close(fd); + return 1; // or handle the error as needed + } + + webpaCfgFile[ch_count] = '\0'; + // CID:18143 - NEGATIVE RETURNS - since ch_count cannot be negative + cJSON *webpa_cfg = cJSON_Parse(webpaCfgFile); + if (webpa_cfg) + { + cJSON *serverIp = NULL; + cJSON *aJwt = NULL; + cJSON *DeviceNwkIf = NULL; + cJSON *srvrPort = NULL; + cJSON *MaxPingWaitTimeInSec = NULL; + + serverIp = cJSON_GetObjectItem(webpa_cfg, "ServerIP"); + aJwt = cJSON_GetObjectItem(webpa_cfg, "acquire-jwt"); + DeviceNwkIf = cJSON_GetObjectItem(webpa_cfg, "DeviceNetworkInterface"); + srvrPort = cJSON_GetObjectItem(webpa_cfg, "ServerPort"); + MaxPingWaitTimeInSec = cJSON_GetObjectItem(webpa_cfg, "MaxPingWaitTimeInSec"); + + if ((NULL != serverIp && NULL != serverIp->valuestring) && (webpa_url.empty())) + { + // strncpy(ServerIP,serverIp->valuestring,strlen(serverIp->valuestring)); + // printf("[%s:%d]ServerIP = [ %s ] \n", __FUNCTION__, __LINE__, ServerIP); + webpa_url = serverIp->valuestring; + } + + if ((NULL != aJwt)) + { + acquireJWT = aJwt->valueint; + printf("acquireJWT = [ %d ] \n", acquireJWT); + } + + if ((NULL != DeviceNwkIf && NULL != DeviceNwkIf->valuestring)) + { + networkIf = DeviceNwkIf->valuestring; + printf("NetworkIF = [ %s] \n", networkIf.c_str()); + } + + if ((NULL != srvrPort)) + { + serverPort = srvrPort->valueint; + printf("serverPort = [ %d ] \n", serverPort); + } + + if ((NULL != MaxPingWaitTimeInSec)) + { + pingWaitTime = MaxPingWaitTimeInSec->valueint; + printf("pingWaitTime = [ %d ] \n", pingWaitTime); + } } - - if ((NULL != MaxPingWaitTimeInSec)) + free(webpaCfgFile); // CID:18606 - Resource leak + if (fp) { - pingWaitTime = MaxPingWaitTimeInSec->valueint; - printf("pingWaitTime = [ %d ] \n", pingWaitTime); + fclose(fp); + fp = NULL; } } - free(webpaCfgFile); // CID:18606 - Resource leak - if (fp) + else { fclose(fp); fp = NULL; } } - else - { - fclose(fp); - fp = NULL; - } } - } - else - { - printf("Failed to open Webpa cfg file %s\n", WEBPA_CFG_FILE); - } + else + { + printf("Failed to open Webpa cfg file %s\n", WEBPA_CFG_FILE); + } -#ifdef RDKCLISSA - getDeviceConfigFile(); -#endif + #ifdef RDKCLISSA + getDeviceConfigFile(); + #endif - // Getting Webpa Parameters - // Get "Device.X_RDK_WebPA_DNSText.URL" - getRFCParameter((char *)"webcfg", DNS_TEXT_URL, ¶m); - dataLen = strlen(param.value); - if (dataLen != 0) - { - printf("[%s:%d]DNS_TEXT_URL RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); - dnsTextUrl = param.value; - } + // Getting Webpa Parameters + // Get "Device.X_RDK_WebPA_DNSText.URL" + getRFCParameter((char *)"webcfg", DNS_TEXT_URL, ¶m); + dataLen = strlen(param.value); + if (dataLen != 0) + { + printf("[%s:%d]DNS_TEXT_URL RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); + dnsTextUrl = param.value; + } - // X_RDK_WebPA_TokenServer - getRFCParameter((char *)"webcfg", TOKEN_SERVER_URL, ¶m); - dataLen = strlen(param.value); - if (dataLen != 0) - { - printf("[%s:%d]TOKEN_SERVER_URL RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); - // remove quotes arround data - tokenServerUrl = param.value; - } + // X_RDK_WebPA_TokenServer + getRFCParameter((char *)"webcfg", TOKEN_SERVER_URL, ¶m); + dataLen = strlen(param.value); + if (dataLen != 0) + { + printf("[%s:%d]TOKEN_SERVER_URL RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); + // remove quotes arround data + tokenServerUrl = param.value; + } - // Manufacturer - manufacturer = getenv("MANUFACTURE"); + // Manufacturer + manufacturer = getenv("MANUFACTURE"); - // Model Number - model = getenv("MODEL_NUM"); + // Model Number + model = getenv("MODEL_NUM"); - // Partner ID - partnerId = get_PartnerId(); + // Partner ID + partnerId = get_PartnerId(); - // Reboot reason - std::string reboot_reason = get_RebootReason(); + // Reboot reason + std::string reboot_reason = get_RebootReason(); - /*Get HW MAc Address*/ - std::string hw_addr = get_HWMAcAddress(); + /*Get HW MAc Address*/ + std::string hw_addr = get_HWMAcAddress(); - // Image Name - std::string fw_name = get_FwName(); + // Image Name + std::string fw_name = get_FwName(); - // Serial Number - getRFCParameter((char *)"webcfg", SERIAL_NUMBER, ¶m); - dataLen = strlen(param.value); - if (dataLen != 0) - { - printf("[%s:%d] SERIAL_NUMBER RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); - serialNumber = param.value; - } + // Serial Number + getRFCParameter((char *)"webcfg", SERIAL_NUMBER, ¶m); + dataLen = strlen(param.value); + if (dataLen != 0) + { + printf("[%s:%d] SERIAL_NUMBER RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); + serialNumber = param.value; + } - // get_Boottime - getRFCParameter((char *)"webcfg", BOOT_TIME, ¶m); - dataLen = strlen(param.value); - if (dataLen != 0) - { - printf("[%s:%d]BOOT_TIME RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); - bootTime = param.value; - } + // get_Boottime + getRFCParameter((char *)"webcfg", BOOT_TIME, ¶m); + dataLen = strlen(param.value); + if (dataLen != 0) + { + printf("[%s:%d]BOOT_TIME RFC PARAM VALUE = [ %s ] \n", __FUNCTION__, __LINE__, param.value); + bootTime = param.value; + } - // Config File check - if ((stat(CONFIG_RES_FILE, &status) == 0)) - { - clientCertFile = CONFIG_RES_FILE; - } - // Starting Parodus - printf("Parodus Process satrting with Arguments: = [ /usr/bin/parodus \ - --hw-mac=%s --webpa-ping-time=%d --webpa-interface-used=%s --webpa-url=%s \ - --partner-id=%s --webpa-backoff-max=9 --ssl-cert-path=%s --acquire-jwt=%d \ - --dns-txt-url=%s --jwt-public-key-file=%s --jwt-algo=RS256 --record-jwt-payload=%s \ - --crud-config-file=%s --hw-manufacturer=%s --fw-name=%s --hw-model=%s \ - --hw-serial-number=%s --boot-time=%s --hw-last-reboot-reason=\"%s\" --client-cert-path=%s --token-server-url=%s & ]\n", - hw_addr.c_str(), pingWaitTime, networkIf.c_str(), webpa_url.c_str(), - partnerId.c_str(), SSL_CERT_FILE, acquireJWT, - dnsTextUrl.c_str(), JWT_KEY, RECORD_JWT_PAYLOAD_FILE, - CRUD_CONFIG_FILE, manufacturer, fw_name.c_str(), model, - serialNumber.c_str(), bootTime.c_str(), reboot_reason.c_str(), clientCertFile.c_str(), tokenServerUrl.c_str()); - - v_secure_system("backgroundrun /usr/bin/parodus \ - --hw-mac=%s --webpa-ping-time=%d --webpa-interface-used=%s --webpa-url=%s \ - --partner-id=%s --webpa-backoff-max=9 --ssl-cert-path=%s --acquire-jwt=%d \ - --dns-txt-url=%s --jwt-public-key-file=%s --jwt-algo=RS256 --record-jwt-payload=%s \ - --crud-config-file=%s --hw-manufacturer=%s --fw-name=%s --hw-model=%s \ - --hw-serial-number=%s --boot-time=%s --hw-last-reboot-reason=\"%s\" --client-cert-path=%s --token-server-url=%s", - hw_addr.c_str(), pingWaitTime, networkIf.c_str(), webpa_url.c_str(), - partnerId.c_str(), SSL_CERT_FILE, acquireJWT, - dnsTextUrl.c_str(), JWT_KEY, RECORD_JWT_PAYLOAD_FILE, - CRUD_CONFIG_FILE, manufacturer, fw_name.c_str(), model, - serialNumber.c_str(), bootTime.c_str(), reboot_reason.c_str(), clientCertFile.c_str(), tokenServerUrl.c_str()); - - return 0; + // Config File check + if ((stat(CONFIG_RES_FILE, &status) == 0)) + { + clientCertFile = CONFIG_RES_FILE; + } + // Starting Parodus + printf("Parodus Process satrting with Arguments: = [ /usr/bin/parodus \ + --hw-mac=%s --webpa-ping-time=%d --webpa-interface-used=%s --webpa-url=%s \ + --partner-id=%s --webpa-backoff-max=9 --ssl-cert-path=%s --acquire-jwt=%d \ + --dns-txt-url=%s --jwt-public-key-file=%s --jwt-algo=RS256 --record-jwt-payload=%s \ + --crud-config-file=%s --hw-manufacturer=%s --fw-name=%s --hw-model=%s \ + --hw-serial-number=%s --boot-time=%s --hw-last-reboot-reason=\"%s\" --client-cert-path=%s --token-server-url=%s & ]\n", + hw_addr.c_str(), pingWaitTime, networkIf.c_str(), webpa_url.c_str(), + partnerId.c_str(), SSL_CERT_FILE, acquireJWT, + dnsTextUrl.c_str(), JWT_KEY, RECORD_JWT_PAYLOAD_FILE, + CRUD_CONFIG_FILE, manufacturer, fw_name.c_str(), model, + serialNumber.c_str(), bootTime.c_str(), reboot_reason.c_str(), clientCertFile.c_str(), tokenServerUrl.c_str()); + + v_secure_system("backgroundrun /usr/bin/parodus \ + --hw-mac=%s --webpa-ping-time=%d --webpa-interface-used=%s --webpa-url=%s \ + --partner-id=%s --webpa-backoff-max=9 --ssl-cert-path=%s --acquire-jwt=%d \ + --dns-txt-url=%s --jwt-public-key-file=%s --jwt-algo=RS256 --record-jwt-payload=%s \ + --crud-config-file=%s --hw-manufacturer=%s --fw-name=%s --hw-model=%s \ + --hw-serial-number=%s --boot-time=%s --hw-last-reboot-reason=\"%s\" --client-cert-path=%s --token-server-url=%s", + hw_addr.c_str(), pingWaitTime, networkIf.c_str(), webpa_url.c_str(), + partnerId.c_str(), SSL_CERT_FILE, acquireJWT, + dnsTextUrl.c_str(), JWT_KEY, RECORD_JWT_PAYLOAD_FILE, + CRUD_CONFIG_FILE, manufacturer, fw_name.c_str(), model, + serialNumber.c_str(), bootTime.c_str(), reboot_reason.c_str(), clientCertFile.c_str(), tokenServerUrl.c_str()); + + + } + catch (const std::bad_cast& e) + { + std::cerr << "Bad cast exception: " << e.what() << std::endl; + return 1; + } + catch (const std::exception& e) + { + std::cerr << "Exception: " << e.what() << std::endl; + return 1; + } + catch (...) + { + std::cerr << "Unknown exception occurred" << std::endl; + return 1; + } + + + +return 0; } diff --git a/src/hostif/parodusClient/waldb/waldb.cpp b/src/hostif/parodusClient/waldb/waldb.cpp index 89fb44e27..62a28be96 100644 --- a/src/hostif/parodusClient/waldb/waldb.cpp +++ b/src/hostif/parodusClient/waldb/waldb.cpp @@ -405,6 +405,7 @@ void appendNextObject(char* currentParam, const char* pAttparam) // TO DO: Since the size of the destination buffer is not predictable using strcpy strcpy(currentParam, pAttparam); } + /** * @brief Get the list of parameters which is matching with paramName * @@ -538,7 +539,7 @@ static XMLNode* getList(XMLNode *pParent,char *paramName,char* currentParam,char sChild = getList(pChild,tparaName,currentParam,ptrParamList,pParamDataTypeList,paramCount); //TO DO:Since curretParam size is not predictable using strcpy strcpy(currentParam+len, INSTANCE_NUMBER_INDICATOR); - i++; + i++; } pChild = sChild; // Seems like instance count is empty @@ -956,7 +957,6 @@ static DB_STATUS get_complete_parameter_list_from_dml_xml ( { appendNextObject(currentParam, pAttrib->Value()); std::string str = pAttrib->Value(); - if (str.compare(str.size()-5,5,".{i}.") == 0) { if(params_count < MAX_NUM_PARAMETERS) { diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 890bd76df..fc3fd060b 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1221,7 +1221,7 @@ string hostIf_DeviceInfo::getEstbIp() #if MEDIA_CLIENT std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetPrimaryInterface\"}"; - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); @@ -1264,7 +1264,7 @@ string hostIf_DeviceInfo::getEstbIp() } postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetIPSettings\", \"params\" : { \"interface\" : \"" + ifc + "\"}}"; - response = getJsonRPCData(postData); + response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); @@ -1758,6 +1758,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPerce { RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): Last Field: [%s]\n", __FUNCTION__, lastField); strncpy(output, lastField, 8); + output[7] = '\0'; firmwareDownloadPercent = strtol (output, NULL, 10); RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] FirmwareDownloadPercent = [%d]\n", __FUNCTION__, firmwareDownloadPercent); put_int (stMsgData->paramValue, firmwareDownloadPercent); @@ -2679,7 +2680,7 @@ int hostIf_DeviceInfo::get_PartnerId_From_Script( string& current_PartnerId ) partnerId = ""; } } - current_PartnerId = partnerId; + current_PartnerId = std::move(partnerId); return OK; } @@ -4021,7 +4022,7 @@ int hostIf_DeviceInfo::get_xRDKCentralComRFCAccountId(HOSTIF_MsgData_t *stMsgDat RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: call curl to get Account ID..\n", __FUNCTION__); - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); @@ -4424,7 +4425,11 @@ int hostIf_DeviceInfo::set_xRDKCentralComDABRFCEnable(HOSTIF_MsgData_t *stMsgDat ofstream dabStatusFile(RDKV_DAB_ENABLE_FILE); dabStatusFile.close(); } else { - remove(RDKV_DAB_ENABLE_FILE); + if (remove(RDKV_DAB_ENABLE_FILE) != 0) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Failed to remove file %s.\n", __FUNCTION__, __LINE__, RDKV_DAB_ENABLE_FILE); + } else { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s:%d] File %s successfully removed.\n",__FUNCTION__, __LINE__, RDKV_DAB_ENABLE_FILE); + } } RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, enable); ret = OK; @@ -5222,7 +5227,7 @@ int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_experience( HOSTIF_MsgData_t *stMsgD string experience = ""; std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.AuthService.getExperience\" }"; - string resp = getJsonRPCData(postData); + string resp = getJsonRPCData(std::move(postData)); if(resp.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] curl response string = %s\n", __FUNCTION__, resp.c_str()); diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp index d5923a09b..ef7fccbb8 100755 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp @@ -38,6 +38,7 @@ #include "Device_DeviceInfo_Processor.h" + GHashTable* hostIf_DeviceProcessorInterface::ifHash = NULL; GMutex hostIf_DeviceProcessorInterface::m_mutex; @@ -181,7 +182,8 @@ int hostIf_DeviceProcessorInterface::get_Device_DeviceInfo_Processor_Architectur uname(&utsName); RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Get Architecture value: '%s'\n", utsName.machine); - strncpy(stMsgData->paramValue, utsName.machine, strlen(utsName.machine)); + strncpy(stMsgData->paramValue, utsName.machine, sizeof(stMsgData->paramValue) - 1); + stMsgData->paramValue[sizeof(stMsgData->paramValue) - 1] = '\0'; if(pChanged && bCalledArchitecture && strncpy(stMsgData->paramValue,backupArchitecture,strlen(stMsgData->paramValue))) { *pChanged = true; diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp index 96c031c8b..52cac2b9f 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp @@ -44,6 +44,7 @@ #define BSP_COMPLETE_TMP "/tmp/bspcomplete" #define RFC_DIRECTORY "/opt/RFC" #define AUTH_SERVICE_PARODUS_RESTART "/tmp/authservice_parodus_restart" +#define MAX_FILENAME_LENGTH 256 #define CURL_EASY_SETOPT(CURL , CURLoption , Value)\ if (curl_easy_setopt(CURL , CURLoption , Value) != CURLE_OK ) {\ @@ -151,6 +152,7 @@ void XBSStore::getAuthServicePartnerID() if (foundWWW && foundAuthService && fileExists(filePath)) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s File %s already exists. Monitoring for modifications...\n", __FUNCTION__, targetFile.c_str()); wd = inotify_add_watch(inotifyFd, filePath.c_str(), IN_CLOSE_WRITE); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Watch descriptor (wd) value: %d\n", wd); partnerIdWatchAdded = true; // Check if the BSP_COMPLETE file exists @@ -167,10 +169,12 @@ void XBSStore::getAuthServicePartnerID() if (foundAuthService) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Directory %s already exists.\n", authServiceDir.c_str()); wd = inotify_add_watch(inotifyFd, authServiceDir.c_str(), IN_CREATE | IN_CLOSE_WRITE); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Watch descriptor (wd) value: %d\n", wd); RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Now monitoring %s for partnerId3.dat creation and modifications...\n", authServiceDir.c_str()); } else { // Add a watch on /opt/www to monitor for authService creation wd = inotify_add_watch(inotifyFd, wwwDir.c_str(), IN_CREATE); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Watch descriptor (wd) value: %d\n", wd); RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Now monitoring %s for authService directory creation...\n", wwwDir.c_str()); } } @@ -187,42 +191,62 @@ void XBSStore::getAuthServicePartnerID() struct inotify_event *event = (struct inotify_event *)ptr; // If www is created - if (!foundWWW && (event->mask & IN_CREATE) && (event->mask & IN_ISDIR) && strcmp(event->name, "www") == 0) { - foundWWW = true; - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Directory %s created!\n", wwwDir.c_str()); - - // Immediately check if authService already exists - foundAuthService = fileExists(authServiceDir); - if (foundAuthService) { - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Directory %s already exists.\n", authServiceDir.c_str()); - wd = inotify_add_watch(inotifyFd, authServiceDir.c_str(), IN_CREATE | IN_CLOSE_WRITE); - RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Now monitoring %s for partnerId3.dat creation and modifications...\n", authServiceDir.c_str()); - } else { + if (!foundWWW && (event->mask & IN_CREATE) && (event->mask & IN_ISDIR) ) { + char nameBuf[NAME_MAX +1] = {0}; + strncpy(nameBuf, event->name, NAME_MAX); + if (strcmp(nameBuf, "www") == 0) + { + foundWWW = true; + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Directory %s created!\n", wwwDir.c_str()); + + // Immediately check if authService already exists + foundAuthService = fileExists(authServiceDir); + if (foundAuthService) { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Directory %s already exists.\n", authServiceDir.c_str()); + wd = inotify_add_watch(inotifyFd, authServiceDir.c_str(), IN_CREATE | IN_CLOSE_WRITE); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Watch descriptor (wd) value: %d\n", wd); // Log the value of wd + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Now monitoring %s for partnerId3.dat creation and modifications...\n", authServiceDir.c_str()); + } else { // Add a new watch for /opt/www/authService creation - wd = inotify_add_watch(inotifyFd, wwwDir.c_str(), IN_CREATE); - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Now monitoring %s for authService directory creation...\n", wwwDir.c_str()); + wd = inotify_add_watch(inotifyFd, wwwDir.c_str(), IN_CREATE); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Watch descriptor (wd) value: %d\n", wd); // Log the value of wd + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Now monitoring %s for authService directory creation...\n", wwwDir.c_str()); + } } - } + } // If authService is created - else if (foundWWW && !foundAuthService && (event->mask & IN_CREATE) && (event->mask & IN_ISDIR) && strcmp(event->name, "authService") == 0) { - foundAuthService = true; + else if (foundWWW && !foundAuthService && (event->mask & IN_CREATE) && (event->mask & IN_ISDIR)) { + char nameBuf[NAME_MAX +1]; + strncpy(nameBuf, event->name, NAME_MAX); + nameBuf[NAME_MAX] ='\0'; + if (strcmp(nameBuf, "authService") == 0) { + foundAuthService = true; RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "Directory %s created!\n", authServiceDir.c_str()); - // Add a new watch for partnerId3.dat + // Add a new watch for partnerId3.dat wd = inotify_add_watch(inotifyFd, authServiceDir.c_str(), IN_CREATE | IN_CLOSE_WRITE); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Watch descriptor (wd) value: %d\n", wd); // Log the value of wd RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Now monitoring %s for partnerId3.dat creation and modifications...\n", authServiceDir.c_str()); + } } // If partnerId3.dat is created - else if (foundAuthService && !partnerIdWatchAdded && (event->mask & IN_CREATE) && strcmp(event->name, targetFile.c_str()) == 0) { - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s File %s created!\n", __FUNCTION__, event->name); - partnerIdWatchAdded = true; - partnerFileUpdated = true; - - // Monitor the file for close after writing - RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Now monitoring %s for modifications...\n", filePath.c_str()); - break; + else if (foundAuthService && !partnerIdWatchAdded && (event->mask & IN_CREATE)) { + // Create a null-terminated copy of event->name + char safeEventName[NAME_MAX + 1]; + strncpy(safeEventName, event->name, NAME_MAX); + safeEventName[NAME_MAX] = '\0'; // Ensure null termination + + if (strcmp(safeEventName, targetFile.c_str()) == 0) { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s File %s created!\n", __FUNCTION__, safeEventName); + partnerIdWatchAdded = true; + partnerFileUpdated = true; + + // Monitor the file for close after writing + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Now monitoring %s for modifications...\n", filePath.c_str()); + break; + } } // If partnerId3.dat is modified diff --git a/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp b/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp index 6184146f7..65954203b 100644 --- a/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp +++ b/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp @@ -270,7 +270,7 @@ static int get_Device_Ethernet_Interface_Fields(unsigned int ethInterfaceNum,EEt errno_t rc = -1; char cmd[BUFF_LENGTH] = {'\0'}; int temp = 0, isEnabled = 0; - char ethernetInterfaceName[BUFF_LENGTH_64]; + char ethernetInterfaceName[BUFF_LENGTH_64] ={'\0'}; char *value = NULL; if(!ethInterfaceNum) @@ -371,7 +371,8 @@ static int get_Device_Ethernet_Interface_Fields(unsigned int ethInterfaceNum,EEt if(value == NULL) return 0; - strncpy(hostIf_EthernetInterface::stEthInterface.mACAddress, value, S_LENGTH); + strncpy(hostIf_EthernetInterface::stEthInterface.mACAddress, value, sizeof(hostIf_EthernetInterface::stEthInterface.mACAddress) - 1); + hostIf_EthernetInterface::stEthInterface.mACAddress[sizeof(hostIf_EthernetInterface::stEthInterface.mACAddress) - 1] = '\0'; RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): Interface %u MACAddress: %s \n", __FUNCTION__, ethInterfaceNum, hostIf_EthernetInterface::stEthInterface.mACAddress); @@ -404,7 +405,8 @@ static int get_Device_Ethernet_Interface_Fields(unsigned int ethInterfaceNum,EEt if(value == NULL) return 0; - strncpy(hostIf_EthernetInterface::stEthInterface.duplexMode, value, _BUF_LEN_16); + strncpy(hostIf_EthernetInterface::stEthInterface.duplexMode, value, _BUF_LEN_16- 1); + hostIf_EthernetInterface::stEthInterface.duplexMode[_BUF_LEN_16 - 1] = '\0'; RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s(): Interface %u DuplexMode: %s\n", __FUNCTION__, ethInterfaceNum, hostIf_EthernetInterface::stEthInterface.duplexMode); diff --git a/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp b/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp index 2cbd2cbc4..bd460ab30 100644 --- a/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp +++ b/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp @@ -110,7 +110,7 @@ static int read_Device_Ethernet_Interface_Stats_Fields(unsigned int ethInterface if(ret == -1) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"\n read_Device_Ethernet_Interface_Stats_Fields(): Error in readFile eBytesSent\n"); - + return 0; } break; @@ -121,8 +121,8 @@ static int read_Device_Ethernet_Interface_Stats_Fields(unsigned int ethInterface ret = readStatFile(cmd, hostIf_EthernetInterfaceStats::stEthInterfaceStats.bytesReceived); if(ret == -1) { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"\n read_Device_Ethernet_Interface_Stats_Fields(): Error in readFile eBytesSent\n"); - + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"\n read_Device_Ethernet_Interface_Stats_Fields(): Error in readFile eBytesReceived\n"); + return 0; } break; diff --git a/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp b/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp index d747171bc..eb757e082 100644 --- a/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp +++ b/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp @@ -728,7 +728,7 @@ int hostif_InterfaceStack::addBridgeChildLayerInfo(InterfaceStackMap_t &layerInf { LayerInfo_t tempLayerInfo; - tempLayerInfo.higherLayer = bridgeHigherLayer; + tempLayerInfo.higherLayer = std::move(bridgeHigherLayer); tempLayerInfo.lowerLayer = std::string(""); layerInfo.insert( std::pair(ifname, tempLayerInfo)); diff --git a/src/hostif/profiles/STBService/Components_XrdkSDCard.cpp b/src/hostif/profiles/STBService/Components_XrdkSDCard.cpp index 752f11a49..95f54239f 100755 --- a/src/hostif/profiles/STBService/Components_XrdkSDCard.cpp +++ b/src/hostif/profiles/STBService/Components_XrdkSDCard.cpp @@ -504,7 +504,7 @@ int hostIf_STBServiceXSDCard::getSerialNumber(HOSTIF_MsgData_t *stMsgData) memset(¶m, '\0', sizeof(param)); param.eSDPropType = SD_SerialNumber; if(getSDCardProperties(¶m) ) { - sprintf(stMsgData->paramValue,"%s" ,param.sdCardProp.uchVal); + snprintf(stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s", param.sdCardProp.uchVal); } stMsgData->paramtype=hostIf_StringType; } @@ -626,28 +626,37 @@ bool getSDCardProperties(strMgrSDcardPropParam_t *sdCardParam) { if (sdCardParam->eSDPropType == SD_LifeElapsed) { - eSTMGRHealthInfo healthInfo; - memset (&healthInfo, 0 , sizeof(healthInfo)); - if (RDK_STMGR_RETURN_SUCCESS == rdkStorage_getHealth (sdCardDeviceID, &healthInfo)) + eSTMGRHealthInfo* healthInfo = (eSTMGRHealthInfo*)malloc(sizeof(eSTMGRHealthInfo)); + if (healthInfo != NULL) { - sdCardParam->sdCardProp.iVal = -1; - /* FIXME: Update string from "used" to a proper proposed value */ - for (int i = 0; i < healthInfo.m_diagnostics.m_list.m_numOfAttributes; i++) + memset(healthInfo, 0, sizeof(eSTMGRHealthInfo)); + if (RDK_STMGR_RETURN_SUCCESS == rdkStorage_getHealth(sdCardDeviceID, healthInfo)) { - if (0 == strcmp (healthInfo.m_diagnostics.m_list.m_diagnostics[i].m_name, "used")) + sdCardParam->sdCardProp.iVal = -1; + /* FIXME: Update string from "used" to a proper proposed value */ + for (int i = 0; i < healthInfo->m_diagnostics.m_list.m_numOfAttributes; i++) { - sdCardParam->sdCardProp.iVal = atoi (healthInfo.m_diagnostics.m_list.m_diagnostics[i].m_value); - break; + if (0 == strcmp(healthInfo->m_diagnostics.m_list.m_diagnostics[i].m_name, "used")) + { + sdCardParam->sdCardProp.iVal = atoi(healthInfo->m_diagnostics.m_list.m_diagnostics[i].m_value); + break; + } } } + else + { + sdCardParam->sdCardProp.iVal = -1; + } + free(healthInfo); } else - { + { + // Handle memory allocation failure sdCardParam->sdCardProp.iVal = -1; } - } - else - { + } + else + { eSTMGRDeviceInfo deviceInfo; memset (&deviceInfo, 0 , sizeof(deviceInfo)); if (RDK_STMGR_RETURN_SUCCESS == rdkStorage_getDeviceInfo (sdCardDeviceID, &deviceInfo)) diff --git a/src/hostif/profiles/Time/Device_Time.cpp b/src/hostif/profiles/Time/Device_Time.cpp index 1c2f8de3d..0ecddf911 100644 --- a/src/hostif/profiles/Time/Device_Time.cpp +++ b/src/hostif/profiles/Time/Device_Time.cpp @@ -168,6 +168,7 @@ int hostIf_Time::get_Device_Time_LocalTimeZone(HOSTIF_MsgData_t *stMsgData, bool { struct timeval time_now; struct tm *newtime = NULL; + char tmp[_BUF_LEN_64]; @@ -186,9 +187,10 @@ int hostIf_Time::get_Device_Time_LocalTimeZone(HOSTIF_MsgData_t *stMsgData, bool } bCalledLocalTimeZone = true; - strncpy(stMsgData->paramValue,tmp,_BUF_LEN_64-1); - strncpy(backupLocalTimeZone,tmp,_BUF_LEN_64-1); - + strncpy(stMsgData->paramValue,tmp,sizeof(stMsgData->paramValue) -1); + stMsgData->paramValue[sizeof(stMsgData->paramValue) - 1] = '\0'; + strncpy(backupLocalTimeZone,tmp,sizeof(backupLocalTimeZone) -1); + backupLocalTimeZone[sizeof(backupLocalTimeZone) -1] = '\0'; stMsgData->paramtype = hostIf_StringType; stMsgData->paramLen = strlen(stMsgData->paramValue); return OK; @@ -226,7 +228,7 @@ int hostIf_Time::get_Device_Time_CurrentLocalTime(HOSTIF_MsgData_t *stMsgData, b { time_t rawtime; struct tm * timeinfo; - errno_t rc = -1; + errno_t rc = -1; char buffer [_BUF_LEN_64] = {'\0'}; RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FILE__, __FUNCTION__); char timeZoneTmp[7]; diff --git a/src/hostif/profiles/wifi/Device_WiFi.cpp b/src/hostif/profiles/wifi/Device_WiFi.cpp index c019bff25..2b4fd07e7 100644 --- a/src/hostif/profiles/wifi/Device_WiFi.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi.cpp @@ -259,7 +259,7 @@ int hostIf_WiFi::get_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) LOG_ENTRY_EXIT; std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetAvailableInterfaces\"}"; - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { @@ -327,7 +327,7 @@ int hostIf_WiFi::set_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.DisableInterface\", \"params\" : { \"type\" : \"WIFI\"}}"; } - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); diff --git a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp index 220f30838..74c7280f9 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp @@ -288,7 +288,7 @@ int hostIf_WiFi_EndPoint::refreshCache() std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetWifiState\"}"; - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); @@ -395,6 +395,7 @@ int hostIf_WiFi_EndPoint::refreshCache() cJSON *ssid = cJSON_GetObjectItem(jsonObj, "ssid"); //ASSIGN TO OP HERE strncpy (SSIDReference, ssid->valuestring, BUFF_LENGTH_256); + SSIDReference[BUFF_LENGTH_256 - 1] = '\0'; } else { @@ -417,7 +418,7 @@ int hostIf_WiFi_EndPoint::refreshCache() } postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetWiFiSignalStrength\"}"; - response = getJsonRPCData(postData); + response = getJsonRPCData(std::move(postData)); if(response.c_str()) { diff --git a/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp b/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp index bec0970c9..5d4ca6c88 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp @@ -126,7 +126,7 @@ int hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_Security_ModesEnable std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetConnectedSSID\"}"; - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); @@ -140,7 +140,8 @@ int hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_Security_ModesEnable cJSON *securityModeObj = cJSON_GetObjectItem(jsonObj, "securityMode"); //ASSIGN TO OP HERE - strncpy(stMsgData->paramValue,securityModeObj->valuestring,sizeof(stMsgData->paramValue)); + strncpy(stMsgData->paramValue,securityModeObj->valuestring,sizeof(stMsgData->paramValue) -1); + stMsgData->paramValue[sizeof(stMsgData->paramValue) - 1] = '\0'; stMsgData->paramtype = hostIf_StringType; stMsgData->paramLen = strlen(stMsgData->paramValue); diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 1311714d4..6d71086ee 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -133,7 +133,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) if (pDev) { std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetConnectedSSID\"}"; - string response = getJsonRPCData(postData); + string response = getJsonRPCData(std::move(postData)); if(response.c_str()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); @@ -237,7 +237,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) } postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetWifiState\"}"; - response = getJsonRPCData(postData); + response = getJsonRPCData(std::move(postData)); if(response.c_str()) { diff --git a/src/hostif/src/IniFile.cpp b/src/hostif/src/IniFile.cpp index df4deb5d8..7c12b7f86 100644 --- a/src/hostif/src/IniFile.cpp +++ b/src/hostif/src/IniFile.cpp @@ -50,7 +50,7 @@ bool IniFile::load(const string &filename) if (splitterPos < line.length()) { string key = line.substr(0, splitterPos); string value = line.substr(splitterPos+1, line.length()); - m_dict[key] = value; + m_dict[key] = std::move(value); } } diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index 009808fe4..da50b489b 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -194,189 +194,191 @@ bool GetFeatureEnabled(char *cmd) //------------------------------------------------------------------------------ int main(int argc, char *argv[]) { - int ch = 0; - errno_t rc = -1; -#ifdef WEBPA_RFC_ENABLED - bool retVal=false; -#endif - const char* debugConfigFile = NULL; - const char* webpaNotifyConfigFile = NULL; - //------------------------------------------------------------------------------ - // Signal handlers: - //------------------------------------------------------------------------------ - struct sigaction sigact; - - while (1) + try { - static struct option long_options[] = + int ch = 0; + errno_t rc = -1; + #ifdef WEBPA_RFC_ENABLED + bool retVal=false; + #endif + const char* debugConfigFile = NULL; + const char* webpaNotifyConfigFile = NULL; + //------------------------------------------------------------------------------ + // Signal handlers: + //------------------------------------------------------------------------------ + struct sigaction sigact; + + while (1) { - /* These options don't set a flag. - We distinguish them by their indices. */ - {"help", no_argument, 0, 'h'}, - {"logfile", required_argument, 0, 'l'}, - {"conffile", required_argument, 0, 'c'}, - {"port", required_argument, 0, 'p'}, -#ifndef NEW_HTTP_SERVER_DISABLE - {"httpserverport", required_argument, 0, 's'}, -#endif - {"debugconfig", required_argument, 0, 'd'}, - {"notifyconfig", required_argument, 0, 'w'}, - {0, 0, 0, 0} - }; - - /* getopt_long stores the option index here. */ - int option_index = 0; -#ifndef NEW_HTTP_SERVER_DISABLE - ch = getopt_long (argc, argv, "hHl:c:p:s:d:w:", - long_options, &option_index); -#else - ch = getopt_long (argc, argv, "hHl:c:p:d:w:", - long_options, &option_index); -#endif - /* Detect the end of the options. */ - if (ch == -1) - break; + static struct option long_options[] = + { + /* These options don't set a flag. + We distinguish them by their indices. */ + {"help", no_argument, 0, 'h'}, + {"logfile", required_argument, 0, 'l'}, + {"conffile", required_argument, 0, 'c'}, + {"port", required_argument, 0, 'p'}, + #ifndef NEW_HTTP_SERVER_DISABLE + {"httpserverport", required_argument, 0, 's'}, + #endif + {"debugconfig", required_argument, 0, 'd'}, + {"notifyconfig", required_argument, 0, 'w'}, + {0, 0, 0, 0} + }; + + /* getopt_long stores the option index here. */ + int option_index = 0; + #ifndef NEW_HTTP_SERVER_DISABLE + ch = getopt_long (argc, argv, "hHl:c:p:s:d:w:", + long_options, &option_index); + #else + ch = getopt_long (argc, argv, "hHl:c:p:d:w:", + long_options, &option_index); + #endif + /* Detect the end of the options. */ + if (ch == -1) + break; - switch (ch) - { - case 'c': - if(optarg) + switch (ch) { - memset(argList.confFile, '\0', sizeof (argList.confFile)); - rc=strcpy_s (argList.confFile,sizeof(argList.confFile),optarg); - if(rc!=EOK) - { + case 'c': + if(optarg) + { + memset(argList.confFile, '\0', sizeof (argList.confFile)); + rc=strcpy_s (argList.confFile,sizeof(argList.confFile),optarg); + if(rc!=EOK) + { ERR_CHK(rc); - } -// RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"argList.confFile : %s optarg : %s\n", argList.confFile, optarg); - } - break; + } +// RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"argList.confFile : %s optarg : %s\n", argList.confFile, optarg); + } + break; - case 'd': - if(optarg) - { - debugConfigFile = optarg; - } - break; - case 'w': - if(optarg) - { - webpaNotifyConfigFile = optarg; - } - break; + case 'd': + if(optarg) + { + debugConfigFile = optarg; + } + break; + case 'w': + if(optarg) + { + webpaNotifyConfigFile = optarg; + } + break; - case 'p': - if(optarg) - { - argList.httpPort = atoi(optarg); - } - break; -#ifndef NEW_HTTP_SERVER_DISABLE - case 's': - if(optarg) - { - argList.httpServerPort = atoi(optarg); + case 'p': + if(optarg) + { + argList.httpPort = atoi(optarg); + } + break; + #ifndef NEW_HTTP_SERVER_DISABLE + case 's': + if(optarg) + { + argList.httpServerPort = atoi(optarg); + } + break; + #endif + case 'h': + case 'H': + case '?': + default: + usage(); + exit(0); } - break; -#endif - case 'h': - case 'H': - case '?': - default: - usage(); - exit(0); } - } - /* Enable RDK logger.*/ - if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; + /* Enable RDK logger.*/ + if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; - if (optind < argc) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"non-option ARGV-elements: "); - while (optind < argc) - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s ", argv[optind++]); - putchar ('\n'); - usage(); - exit (0); - } - -#ifdef WEBPA_RFC_ENABLED - retVal = GetFeatureEnabled("WEBPAXG"); - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] WEBPAXG returns %d\n", __FUNCTION__, retVal); - if( retVal == false) - { - // Send a notification to systemd to stop the service - int ret = sd_pid_notify(0, SD_FINALIZING); - - if (ret < 0) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Error sending stop notification: %s\n", strerror(-ret)); - return 1; - } - - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Service stop notification sent successfully.\n"); - return ch; - } -#endif + if (optind < argc) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"non-option ARGV-elements: "); + while (optind < argc) + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s ", argv[optind++]); + putchar ('\n'); + usage(); + exit (0); + } - if (sem_init(&shutdown_thread_sem, 0, 0) == -1) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] sem_init() failed\n", __FUNCTION__, __FILE__); - return 1; - } + #ifdef WEBPA_RFC_ENABLED + retVal = GetFeatureEnabled("WEBPAXG"); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s] WEBPAXG returns %d\n", __FUNCTION__, retVal); + if( retVal == false) + { + // Send a notification to systemd to stop the service + int ret = sd_pid_notify(0, SD_FINALIZING); - if (pthread_create(&shutdown_thread, NULL, shutdown_thread_entry, NULL) != 0) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] pthread_create() failed\n", __FUNCTION__, __FILE__); - return 1; - } + if (ret < 0) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Error sending stop notification: %s\n", strerror(-ret)); + return 1; + } - // The actions for SIGINT, SIGTERM, SIGSEGV, and SIGQUIT are set - sigemptyset(&sigact.sa_mask); - sigact.sa_handler = quit_handler; - sigact.sa_flags = SA_ONSTACK; + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Service stop notification sent successfully.\n"); + return ch; + } + #endif - sigaction (SIGINT, &sigact, NULL); - sigaction (SIGTERM, &sigact, NULL); - sigaction (SIGHUP, &sigact, NULL); - signal (SIGPIPE, SIG_IGN); + if (sem_init(&shutdown_thread_sem, 0, 0) == -1) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] sem_init() failed\n", __FUNCTION__, __FILE__); + return 1; + } - setvbuf(stdout, NULL, _IOLBF, 0); + if (pthread_create(&shutdown_thread, NULL, shutdown_thread_entry, NULL) != 0) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] pthread_create() failed\n", __FUNCTION__, __FILE__); + return 1; + } - //------------------------------------------------------------------------------ - // Initialize the glib, g_time and logger - //------------------------------------------------------------------------------ -#if GLIB_VERSION_CUR_STABLE <= GLIB_VERSION_2_32 - if(!g_thread_supported()) - { - g_thread_init(NULL); - RDK_LOG(RDK_LOG_NOTICE,LOG_TR69HOSTIF,"g_thread supported\n"); - } - else - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"g_thread NOT supported\n"); - } -#endif - /* Enable RDK logger.*/ - if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; + // The actions for SIGINT, SIGTERM, SIGSEGV, and SIGQUIT are set + sigemptyset(&sigact.sa_mask); + sigact.sa_handler = quit_handler; + sigact.sa_flags = SA_ONSTACK; -#if defined(USE_WIFI_PROFILE) - /* Perform the necessary operations to initialise the WiFi device */ - (void)WiFiDevice::init(); -#endif -// g_get_current_time(&timeval); -// char* logoutfile = (char *)LOG_FILE; -#if 0 - /* Commented: Since logs are directed to /opt/logs/ folder, - * so no need to use separate log file */ - char* logoutfile = (char *)argList.logFileName; + sigaction (SIGINT, &sigact, NULL); + sigaction (SIGTERM, &sigact, NULL); + sigaction (SIGHUP, &sigact, NULL); + signal (SIGPIPE, SIG_IGN); + setvbuf(stdout, NULL, _IOLBF, 0); - g_log_set_handler(G_LOG_DOMAIN, (GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_MESSAGE | \ - G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | \ - G_LOG_LEVEL_ERROR), tr69hostIf_logger, (void *)logoutfile); -#endif + //------------------------------------------------------------------------------ + // Initialize the glib, g_time and logger + //------------------------------------------------------------------------------ + #if GLIB_VERSION_CUR_STABLE <= GLIB_VERSION_2_32 + if(!g_thread_supported()) + { + g_thread_init(NULL); + RDK_LOG(RDK_LOG_NOTICE,LOG_TR69HOSTIF,"g_thread supported\n"); + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"g_thread NOT supported\n"); + } + #endif + /* Enable RDK logger.*/ + if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; + + #if defined(USE_WIFI_PROFILE) + /* Perform the necessary operations to initialise the WiFi device */ + (void)WiFiDevice::init(); + #endif + // g_get_current_time(&timeval); + // char* logoutfile = (char *)LOG_FILE; + #if 0 + /* Commented: Since logs are directed to /opt/logs/ folder, + * so no need to use separate log file */ + char* logoutfile = (char *)argList.logFileName; + + + g_log_set_handler(G_LOG_DOMAIN, (GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_MESSAGE | \ + G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | \ + G_LOG_LEVEL_ERROR), tr69hostIf_logger, (void *)logoutfile); + #endif RDK_LOG(RDK_LOG_NOTICE,LOG_TR69HOSTIF,"Starting tr69HostIf Service\n"); @@ -387,158 +389,174 @@ int main(int argc, char *argv[]) based on the group of configuration. */ //if(false == hostIf_ConfigProperties_Init()) - if(false == hostIf_initalize_ConfigManger()) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to hostIf_initalize_ConfigManger()\n"); - } + if(false == hostIf_initalize_ConfigManger()) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to hostIf_initalize_ConfigManger()\n"); + } -#ifndef NEW_HTTP_SERVER_DISABLE - ifstream ifs_legacyEnabled(LEGACY_RFC_ENABLED_PATH); - if(!ifs_legacyEnabled.is_open()) - { - setLegacyRFCEnabled(false); - } - else - { - setLegacyRFCEnabled(true); - ifs_legacyEnabled.close(); - } -#endif + #ifndef NEW_HTTP_SERVER_DISABLE + ifstream ifs_legacyEnabled(LEGACY_RFC_ENABLED_PATH); + if(!ifs_legacyEnabled.is_open()) + { + setLegacyRFCEnabled(false); + } + else + { + setLegacyRFCEnabled(true); + ifs_legacyEnabled.close(); + } + #endif - if(false == hostIf_IARM_IF_Start() ) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to start hostIf_IARM_IF_Start()\n"); - } - MergeStatus mergeStatus = mergeDataModel(); - if (mergeStatus != MERGE_SUCCESS) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error in merging Data Model\n"); - return DB_FAILURE; // Or handle the failure appropriately - } - else { - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Successfully merged Data Model.\n"); - } - /* Load the data model xml file*/ - DB_STATUS status = loadDataModel(); - if(status != DB_SUCCESS) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Error in Data Model Initialization\n"); - return DB_FAILURE; - } - else - { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Successfully initialize Data Model.\n"); - } + if(false == hostIf_IARM_IF_Start() ) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to start hostIf_IARM_IF_Start()\n"); + } + MergeStatus mergeStatus = mergeDataModel(); + if (mergeStatus != MERGE_SUCCESS) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error in merging Data Model\n"); + return DB_FAILURE; // Or handle the failure appropriately + } + else { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Successfully merged Data Model.\n"); + } + /* Load the data model xml file*/ + DB_STATUS status = loadDataModel(); + if(status != DB_SUCCESS) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Error in Data Model Initialization\n"); + return DB_FAILURE; + } + else + { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Successfully initialize Data Model.\n"); + } //------------------------------------------------------------------------------ // hostIf_HttpServerStart: Soup HTTP Server //------------------------------------------------------------------------------ - if( (hostIf_JsonIfThread = g_thread_try_new( "json_if_handler_thread", (GThreadFunc)jsonIfHandlerThread, (void *)hostIf_JsonIfMsg, &err1)) == NULL) - { - g_critical("Thread create failed: %s!!\n", err1->message ); - g_error_free (err1); - } -#ifndef NEW_HTTP_SERVER_DISABLE - if(!legacyRFCEnabled()) - { - RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"legacyRFC Set to False, Starting New HTTP Server\n"); - if((HTTPServerThread = g_thread_try_new("http_server_thread", (GThreadFunc)HTTPServerStartThread, (void *)HTTPServerName, &httpError)) == NULL) + if( (hostIf_JsonIfThread = g_thread_try_new( "json_if_handler_thread", (GThreadFunc)jsonIfHandlerThread, (void *)hostIf_JsonIfMsg, &err1)) == NULL) { - g_critical("New HTTP Server Thread Create failed: %s!!\n", httpError->message ); - g_error_free (httpError); + g_critical("Thread create failed: %s!!\n", err1->message ); + g_error_free (err1); + } + #ifndef NEW_HTTP_SERVER_DISABLE + if(!legacyRFCEnabled()) + { + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"legacyRFC Set to False, Starting New HTTP Server\n"); + if((HTTPServerThread = g_thread_try_new("http_server_thread", (GThreadFunc)HTTPServerStartThread, (void *)HTTPServerName, &httpError)) == NULL) + { + g_critical("New HTTP Server Thread Create failed: %s!!\n", httpError->message ); + g_error_free (httpError); + } } - } - else - { - RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"legacyRFC Set to True, New HTTP Server is not started\n"); - } -#endif - -#ifdef PID_FILE_PATH -#define xstr(s) str(s) -#define str(s) #s - // write pidfile because sd_notify() does not work inside container - IARM_Bus_WritePIDFile(xstr(PID_FILE_PATH) "/tr69hostif.pid"); -#endif + else + { + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"legacyRFC Set to True, New HTTP Server is not started\n"); + } + #endif + + #ifdef PID_FILE_PATH + #define xstr(s) str(s) + #define str(s) #s + // write pidfile because sd_notify() does not work inside container + IARM_Bus_WritePIDFile(xstr(PID_FILE_PATH) "/tr69hostif.pid"); + #endif + + //------------------------------------------------------------------------------ + // updateHandler::init : Update handler thread for polling table profiles + //------------------------------------------------------------------------------ + updateHandler::Init(); + + #if defined(PARODUS_ENABLE) + //------------------------------------------------------------------------------ + // Initialize WebPA Module + //------------------------------------------------------------------------------ + + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Starting WEBPA Parodus Connections\n"); + libpd_set_notifyConfigFile(webpaNotifyConfigFile); + if(0 == pthread_create(&parodus_init_tid, NULL, libpd_client_mgr, NULL)) + { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Initiating Connection with PARODUS success.. \n"); + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Parodus init thread create failed\n"); + } + #endif - //------------------------------------------------------------------------------ - // updateHandler::init : Update handler thread for polling table profiles - //------------------------------------------------------------------------------ - updateHandler::Init(); + #if defined(WEB_CONFIG_ENABLED) + initWebConfigMultipartTask(0); + #elif defined(WEBCONFIG_LITE_ENABLE) + if(0 == pthread_create(&webconfig_threadId, NULL, initWebConfigTask, NULL)) + { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"webconfig thread created success.. \n"); + } + else + { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"webconfig thread created failed.. \n"); + } + #endif -#if defined(PARODUS_ENABLE) - //------------------------------------------------------------------------------ - // Initialize WebPA Module - //------------------------------------------------------------------------------ + /* Initialized Rbus interface for TR181 Data*/ + init_rbus_dml_provider(); - RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Starting WEBPA Parodus Connections\n"); - libpd_set_notifyConfigFile(webpaNotifyConfigFile); - if(0 == pthread_create(&parodus_init_tid, NULL, libpd_client_mgr, NULL)) - { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Initiating Connection with PARODUS success.. \n"); - } - else - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Parodus init thread create failed\n"); - } -#endif + // Send sd notify event after http server thread is complete. + if (httpServerThreadDone == false) + { + std::unique_lock lck(mtx_httpServerThreadDone); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Waiting(max 10 sec) for http server thread to be complete...\n"); + auto sec = chrono::seconds(1); + cv_httpServerThreadDone.wait_for(lck, 10*sec, [] {return httpServerThreadDone;}); + } + #ifdef ENABLE_SD_NOTIFY + sd_notifyf(0, "READY=1\n" + "STATUS=tr69hostif is Successfully Initialized\n" + "MAINPID=%lu", (unsigned long) getpid()); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"tr69hostif sd notify envent is sent Successfully, httpServerThreadDone=%d\n", httpServerThreadDone); + #endif -#if defined(WEB_CONFIG_ENABLED) - initWebConfigMultipartTask(0); -#elif defined(WEBCONFIG_LITE_ENABLE) - if(0 == pthread_create(&webconfig_threadId, NULL, initWebConfigTask, NULL)) - { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"webconfig thread created success.. \n"); - } - else - { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"webconfig thread created failed.. \n"); - } -#endif + hostIf_DeviceInfo::send_DeviceManageableNotification(); - /* Initialized Rbus interface for TR181 Data*/ - init_rbus_dml_provider(); + main_loop = g_main_loop_new (NULL, FALSE); - // Send sd notify event after http server thread is complete. - if (httpServerThreadDone == false) - { - std::unique_lock lck(mtx_httpServerThreadDone); - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Waiting(max 10 sec) for http server thread to be complete...\n"); - auto sec = chrono::seconds(1); - cv_httpServerThreadDone.wait_for(lck, 10*sec, [] {return httpServerThreadDone;}); - } -#ifdef ENABLE_SD_NOTIFY - sd_notifyf(0, "READY=1\n" - "STATUS=tr69hostif is Successfully Initialized\n" - "MAINPID=%lu", (unsigned long) getpid()); - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"tr69hostif sd notify envent is sent Successfully, httpServerThreadDone=%d\n", httpServerThreadDone); -#endif + if(main_loop) { + g_main_loop_run(main_loop); + g_main_loop_unref (main_loop); + } + else { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Fails to Create a main loop.", __FUNCTION__); + } - hostIf_DeviceInfo::send_DeviceManageableNotification(); + if(hostIf_JsonIfThread) + g_thread_join(hostIf_JsonIfThread); - main_loop = g_main_loop_new (NULL, FALSE); + #ifndef NEW_HTTP_SERVER_DISABLE + if(HTTPServerThread) + g_thread_join(HTTPServerThread); + #endif + #if defined(PARODUS_ENABLE) + if(parodus_init_tid) + pthread_join(parodus_init_tid,NULL); + #endif - if(main_loop) { - g_main_loop_run(main_loop); - g_main_loop_unref (main_loop); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"\n\n----------------------EXITING MAIN PROGRAM----------------------\n"); + return 0 ; } - else { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Fails to Create a main loop.", __FUNCTION__); + catch (const std::bad_cast& e) + { + std::cerr << "Bad cast exception: " << e.what() << std::endl; + return 1; + } + catch (const std::exception& e) + { + std::cerr << "Exception: " << e.what() << std::endl; + return 1; + } + catch (...) + { + std::cerr << "Unknown exception occurred" << std::endl; + return 1; } - - if(hostIf_JsonIfThread) - g_thread_join(hostIf_JsonIfThread); - -#ifndef NEW_HTTP_SERVER_DISABLE - if(HTTPServerThread) - g_thread_join(HTTPServerThread); -#endif -#if defined(PARODUS_ENABLE) - if(parodus_init_tid) - pthread_join(parodus_init_tid,NULL); -#endif - - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"\n\n----------------------EXITING MAIN PROGRAM----------------------\n"); - return 0 ; } //------------------------------------------------------------------------------ diff --git a/src/hostif/src/hostIf_utils.cpp b/src/hostif/src/hostIf_utils.cpp index 6cc33f430..054a55c29 100644 --- a/src/hostif/src/hostIf_utils.cpp +++ b/src/hostif/src/hostIf_utils.cpp @@ -541,16 +541,15 @@ std::string get_security_token() { } else { RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error\n", __FUNCTION__); - if (NULL != pSecurity) - v_secure_pclose(pSecurity); } - } + } + v_secure_pclose(pSecurity); } + else { RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,"%s: Failed to open security utility\n", __FUNCTION__); } - if (NULL != pSecurity) - v_secure_pclose(pSecurity); + return sToken; } From b6a0b0bd54e8593a77433b0f1b4dfb808a535cb7 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 30 Apr 2025 07:36:11 -0400 Subject: [PATCH 064/161] 1.1.6 release changelog updates --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b5432bba..38e29efde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.6](https://github.com/rdkcentral/tr69hostif/compare/1.1.5...1.1.6) + +- RDK-56124-RDKE-Fix coverity issues in tr69hostif and profiles [`#105`](https://github.com/rdkcentral/tr69hostif/pull/105) +- RDKEMW-3545: Modified MigrationStatus Default value to NOT_NEEDED [`#127`](https://github.com/rdkcentral/tr69hostif/pull/127) +- Merge tag '1.1.5' into develop [`852cc26`](https://github.com/rdkcentral/tr69hostif/commit/852cc26965e03dbd20a5f3b0b55782126a45b87b) + #### [1.1.5](https://github.com/rdkcentral/tr69hostif/compare/1.1.4...1.1.5) +> 27 April 2025 + - Revert "RDK-31923 : Added Enable parameter for Telemetry RFC. (#123)" [`#129`](https://github.com/rdkcentral/tr69hostif/pull/129) - RDK-48829 [RDK-E] L2 test framework for tr69hostif [`#124`](https://github.com/rdkcentral/tr69hostif/pull/124) - RDK-31923 : Added Enable parameter for Telemetry RFC. [`#123`](https://github.com/rdkcentral/tr69hostif/pull/123) - RDKE-778: Add logs to rdmagent [`#121`](https://github.com/rdkcentral/tr69hostif/pull/121) +- 1.1.5 release changelog updates [`580f18d`](https://github.com/rdkcentral/tr69hostif/commit/580f18dfe6ffc25e4b6eabb889f118428cea8fc6) - Merge tag '1.1.4' into develop [`7b0f8e0`](https://github.com/rdkcentral/tr69hostif/commit/7b0f8e0521d97021556f7e97c7cc8e22d9cfa137) #### [1.1.4](https://github.com/rdkcentral/tr69hostif/compare/1.1.3...1.1.4) From 056db49babdf17c65810b513ca78d4a27f768130 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 7 May 2025 18:45:22 +0530 Subject: [PATCH 065/161] RDK-56291 L2 Tests And Integration With CI for Remote Debugger Dynamic Updates (#141) * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.h * Update data-model-generic.xml * Update Device_DeviceInfo.h * Update hostIf_DeviceClient_ReqHandler.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.h * Update Device_DeviceInfo.cpp * Update data-model-generic.xml * Update hostIf_rbus_Dml_Provider.cpp * Update Device_DeviceInfo.cpp --------- Co-authored-by: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> --- .../src/hostIf_DeviceClient_ReqHandler.cpp | 4 + .../handlers/src/hostIf_rbus_Dml_Provider.cpp | 5 - .../waldb/data-model/data-model-generic.xml | 10 +- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 120 +++++++++--------- .../profiles/DeviceInfo/Device_DeviceInfo.h | 4 +- 5 files changed, 73 insertions(+), 70 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp index 8b73c0fc0..afa49102b 100644 --- a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp @@ -232,6 +232,10 @@ int DeviceClientReqHandler::handleSetMsg(HOSTIF_MsgData_t *stMsgData) { ret = pIface->set_xRDKDownloadManager_InstallPackage(stMsgData); } + else if (strcasecmp(stMsgData->paramName,X_RDKDownloadManager_DownloadStatus) == 0) + { + ret = pIface->set_xRDKDownloadManager_DownloadStatus(stMsgData); + } else if (strcasecmp(stMsgData->paramName,IPREMOTE_SUPPORT) == 0) { ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(stMsgData); diff --git a/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp b/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp index ffca45e7a..0cdc2147f 100644 --- a/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp +++ b/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp @@ -152,11 +152,6 @@ rbusError_t TR_Dml_EventSubHandler(rbusHandle_t handle, rbusEventSubAction_t act RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s][rbusdml] Disable Autopublish for action=%s eventName=%s", action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribe" : "unsubscribe", __FUNCTION__, eventName); *autoPublish = false; } - else if(!strcmp("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus", eventName)) - { - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s][rbusdml] Disable Autopublish for action=%s eventName=%s", action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribe" : "unsubscribe", __FUNCTION__, eventName); - *autoPublish = false; - } else { RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s][rbusdml]: Autopublish enabled by default for all DM!\n", __FUNCTION__); diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index de6fd17e2..5e7e9ad50 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -3179,6 +3179,11 @@ + + + + + @@ -3548,11 +3553,6 @@ - - - - - diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index fc3fd060b..3434beec4 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -3867,10 +3867,6 @@ int hostIf_DeviceInfo::set_xRDKCentralComRFC(HOSTIF_MsgData_t * stMsgData) { ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(stMsgData); } - else if (strcasecmp(stMsgData->paramName,RDK_DOWNLOAD_STATUS) == 0) - { - ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerDownloadStatus(stMsgData); - } #endif else if (strcasecmp(stMsgData->paramName,RDK_REBOOTSTOP_ENABLE) == 0) { @@ -4132,61 +4128,7 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerI return retVal; } -int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerDownloadStatus(HOSTIF_MsgData_t *stMsgData) -{ - int ret = NOK; - bool isenabled = false; - LOG_ENTRY_EXIT; - - if(stMsgData->paramtype == hostIf_BooleanType) - { - isenabled = get_boolean(stMsgData->paramValue); - RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, isenabled); - - rbusError_t rc = RBUS_ERROR_BUS_ERROR; - rbusValue_t value, byVal; - rbusObject_t data; - rbusEvent_t event = {0}; - - rbusValue_Init(&value); - rbusValue_Init(&byVal); - rbusValue_SetBoolean(value, isenabled); - rbusValue_SetString(byVal, "tr69hostif"); - - rbusObject_Init(&data, NULL); - rbusObject_SetValue(data, "value", value); - rbusObject_SetValue(data, "by", byVal); - - event.name = RDM_DOWNLOAD_EVENT; - event.data = data; - event.type = RBUS_EVENT_VALUE_CHANGED; - - rc = rbusEvent_Publish(rbusHandle, &event); - if ((rc != RBUS_ERROR_SUCCESS) && (rc != RBUS_ERROR_NOSUBSCRIBERS)) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event failed for %s with return : %s !!! \n ", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT, rbusError_ToString(rc)); - ret = NOK; - } - else - { - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event success for %s !!! \n ", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT ); - ret = OK; - } - - rbusValue_Release(value); - rbusValue_Release(byVal); - rbusObject_Release(data); - } - else - { - 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); - stMsgData->faultCode = fcInvalidParameterType; - ret=NOK; - } - - return ret; -} int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData (HOSTIF_MsgData_t *stMsgData) { char *issueStr = NULL; @@ -5359,6 +5301,68 @@ int hostIf_DeviceInfo::set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t * RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Exiting..\n", __FUNCTION__ ); return OK; } +#ifdef USE_REMOTE_DEBUGGER +int hostIf_DeviceInfo::set_xRDKDownloadManager_DownloadStatus(HOSTIF_MsgData_t * stMsgData) +{ + int ret = NOK; + bool isenabled = false; + LOG_ENTRY_EXIT; + + if(stMsgData->paramtype == hostIf_BooleanType) + { + isenabled = get_boolean(stMsgData->paramValue); + + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%d] Successfully set \"%s\" to \"%d\". \n", __FUNCTION__, __LINE__, stMsgData->paramName, isenabled); + + rbusError_t rc = RBUS_ERROR_BUS_ERROR; + rbusValue_t value, byVal, preValue; + rbusObject_t data; + rbusEvent_t event = {0}; + + rbusValue_Init(&value); + rbusValue_Init(&byVal); + rbusValue_Init(&preValue); + rbusValue_SetBoolean(value, isenabled); + rbusValue_SetBoolean(preValue, stMsgData->paramValue); + rbusValue_SetString(byVal, "tr69hostif"); + + + rbusObject_Init(&data, NULL); + rbusObject_SetValue(data, "value", value); + rbusObject_SetValue(data, "oldValue", preValue); + rbusObject_SetValue(data, "by", byVal); + + event.name = RDM_DOWNLOAD_EVENT; + event.data = data; + event.type = RBUS_EVENT_VALUE_CHANGED; + + rc = rbusEvent_Publish(rbusHandle, &event); + if ((rc != RBUS_ERROR_SUCCESS) && (rc != RBUS_ERROR_NOSUBSCRIBERS)) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event failed for %s with return : %s !!! \n ", __FUNCTION__, __LINE__,RDM_DOWNLOAD_EVENT , rbusError_ToString(rc)); + ret = NOK; + } + else + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event success for %s !!! \n ", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT); + ret = OK; + } + + rbusValue_Release(value); + rbusValue_Release(byVal); + rbusValue_Release(preValue); + rbusObject_Release(data); + } + else + { + 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); + stMsgData->faultCode = fcInvalidParameterType; + ret=NOK; + } + + return ret; +} +#endif /* End of doxygen group */ /** * @} diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 3c13b294c..e73920915 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -134,6 +134,7 @@ /* Profile: X_RDKCENTRAL-COM_RDKDownloadManager. */ #define X_RDKDownloadManager_InstallPackage "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage" +#define X_RDKDownloadManager_DownloadStatus "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus" /* Profile: X_RDKCENTRAL-COM_xOpsDeviceMgmt.Logging. */ #define xOpsDMUploadLogsNow_STR "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.Logging.xOpsDMUploadLogsNow" #define xOpsDMLogsUploadStatus_STR "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.Logging.xOpsDMLogsUploadStatus" @@ -185,7 +186,6 @@ #define RDK_REMOTE_DEBUGGER_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable" #define RDK_REMOTE_DEBUGGER_ISSUETYPE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" #define RDK_REMOTE_DEBUGGER_WEBCFGDATA "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData" -#define RDK_DOWNLOAD_STATUS "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus" #endif /* Profile: X_RDKCENTRAL-COM_RFC.Feature.RebootStop */ @@ -1223,7 +1223,6 @@ class hostIf_DeviceInfo { int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(HOSTIF_MsgData_t *); int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(HOSTIF_MsgData_t *); - int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerDownloadStatus(HOSTIF_MsgData_t *); #endif /* * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable @@ -1483,6 +1482,7 @@ class hostIf_DeviceInfo { int get_X_RDK_FirmwareName(HOSTIF_MsgData_t *); int set_xRDKDownloadManager_InstallPackage(HOSTIF_MsgData_t *); + int set_xRDKDownloadManager_DownloadStatus(HOSTIF_MsgData_t *); }; /* End of doxygen group */ /** From a406a9736a63b4c215714a14123b498e39ee5a10 Mon Sep 17 00:00:00 2001 From: nanimatta Date: Fri, 9 May 2025 15:57:37 +0000 Subject: [PATCH 066/161] RDKEMW-3401: fetch failure in telemetry2_0 Reason for change: fetch failure in telemetry2_0 Test Procedure: Refer JIRA Risks: Low Priority: P0 Signed-off-by: nanimatta --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 3434beec4..c122a3b9d 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -546,6 +546,10 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_Manufacturer(HOSTIF_MsgData_t * stM param.type = mfrSERIALIZED_TYPE_MANUFACTURER; iarm_ret = IARM_Bus_Call(IARM_BUS_MFRLIB_NAME, IARM_BUS_MFRLIB_API_GetSerializedData, ¶m, sizeof(param)); + std::string temp_buf(param.buffer); + std::replace(temp_buf.begin(), temp_buf.end(), ' ', '_'); + strncpy(param.buffer, temp_buf.c_str(), MAX_SERIALIZED_BUF - 1); + param.buffer[MAX_SERIALIZED_BUF - 1] = '\0'; 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); if(iarm_ret == IARM_RESULT_SUCCESS) { From 22958aef88c38c616f7b051cca64f6d939045973 Mon Sep 17 00:00:00 2001 From: deepthi-ps Date: Mon, 12 May 2025 14:55:16 +0000 Subject: [PATCH 067/161] REFPLTV-2816: Update xconf server to golang based --- partners_defaults.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partners_defaults.json b/partners_defaults.json index 8693518bb..e4a754fa9 100644 --- a/partners_defaults.json +++ b/partners_defaults.json @@ -46,7 +46,7 @@ "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName" : "community", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerProductName" : "", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.NetflixESNprefix" : "", - "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.XconfUrl" : "https://xconf.rdkcentral.com:19092", + "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.XconfUrl" : "https://xconf.rdkcentral.com", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.XconfRecoveryUrl" : "", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.SsrUrl" : "", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.LSA.Enable" : "False", From 4ad981f01d57a3a65e7aca2791b5d490be524e3b Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 14 May 2025 15:33:00 -0400 Subject: [PATCH 068/161] 1.1.7 release changelog updates --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e29efde..7335a96c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.7](https://github.com/rdkcentral/tr69hostif/compare/1.1.6...1.1.7) + +- REFPLTV-2816: Update xconf server to golang based [`#150`](https://github.com/rdkcentral/tr69hostif/pull/150) +- RDKEMW-3401: fetch failure in telemetry2_0 [`#148`](https://github.com/rdkcentral/tr69hostif/pull/148) +- RDK-56291 L2 Tests And Integration With CI for Remote Debugger Dynamic Updates [`#141`](https://github.com/rdkcentral/tr69hostif/pull/141) +- Merge tag '1.1.6' into develop [`244c520`](https://github.com/rdkcentral/tr69hostif/commit/244c520c41af34b50a4d62fdffb1ff7bce04f309) + #### [1.1.6](https://github.com/rdkcentral/tr69hostif/compare/1.1.5...1.1.6) +> 30 April 2025 + - RDK-56124-RDKE-Fix coverity issues in tr69hostif and profiles [`#105`](https://github.com/rdkcentral/tr69hostif/pull/105) - RDKEMW-3545: Modified MigrationStatus Default value to NOT_NEEDED [`#127`](https://github.com/rdkcentral/tr69hostif/pull/127) +- 1.1.6 release changelog updates [`b6a0b0b`](https://github.com/rdkcentral/tr69hostif/commit/b6a0b0bd54e8593a77433b0f1b4dfb808a535cb7) - Merge tag '1.1.5' into develop [`852cc26`](https://github.com/rdkcentral/tr69hostif/commit/852cc26965e03dbd20a5f3b0b55782126a45b87b) #### [1.1.5](https://github.com/rdkcentral/tr69hostif/compare/1.1.4...1.1.5) From 70025d633d1e62d173cd36c6e36417493695bf6a Mon Sep 17 00:00:00 2001 From: mtirum011 Date: Fri, 9 May 2025 08:32:49 +0000 Subject: [PATCH 069/161] RDK-57360 [RDK-E] L2 test framework for tr69hostif - webpa path --- cov_build.sh | 2 + run_l2.sh | 7 +- .../pal/mock-parodus/Makefile.am | 75 ++++++ .../pal/mock-parodus/configure.ac | 6 + .../pal/mock-parodus/mock_parodus_build.sh | 3 + .../pal/mock-parodus/parodus.cpp | 49 ++++ src/unittest/stubs/paramMgr.c | 4 + src/unittest/stubs/paramMgr.h | 18 ++ .../features/tr69hostif_webpa.feature | 59 +++++ .../functional-tests/tests/basic_constants.py | 1 + .../tests/helper_functions.py | 11 + .../tests/tr69hostif_webpa.py | 249 ++++++++++++++++++ 12 files changed, 483 insertions(+), 1 deletion(-) create mode 100644 src/hostif/parodusClient/pal/mock-parodus/Makefile.am create mode 100644 src/hostif/parodusClient/pal/mock-parodus/configure.ac create mode 100644 src/hostif/parodusClient/pal/mock-parodus/mock_parodus_build.sh create mode 100644 src/hostif/parodusClient/pal/mock-parodus/parodus.cpp create mode 100644 src/unittest/stubs/paramMgr.c create mode 100644 src/unittest/stubs/paramMgr.h create mode 100644 test/functional-tests/features/tr69hostif_webpa.feature create mode 100644 test/functional-tests/tests/tr69hostif_webpa.py diff --git a/cov_build.sh b/cov_build.sh index af71d4e70..fe1ba354f 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -70,3 +70,5 @@ make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" make install +cd ./src/hostif/parodusClient/pal/mock-parodus/ +sh mock_parodus_build.sh diff --git a/run_l2.sh b/run_l2.sh index d2b29933c..66d582680 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -39,7 +39,11 @@ dos2unix /etc/data-model-stb.xml echo "RDK_PROFILE=STB" > /etc/device.properties echo "VERSION=99.99.15.07" >> /version.txt - +echo "Proto|http" >> /opt/fwdnldstatus.txt +echo "Status|Download In Progress" >> /opt/fwdnldstatus.txt +echo "DnldFile|ELTE11MWR_E037.000.00.8.1s22_DEV.bin" >> /opt/fwdnldstatus.txt +echo "DnldURL|https://dac15cdlserver.ae.ccp.xcal.tv/Images" >> /opt/fwdnldstatus.txt +echo "FwUpdateState|Download complete" >> /opt/fwdnldstatus.txt cp ./src/integrationtest/conf/mgrlist.conf /etc/ @@ -63,4 +67,5 @@ fi pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/bootup_sequence.json test/functional-tests/tests/test_bootup_sequence.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/handlers_communications.json test/functional-tests/tests/test_handlers_communications.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/deviceip.json test/functional-tests/tests/tr69hostif_deviceip.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/webpa.json test/functional-tests/tests/tr69hostif_webpa.py diff --git a/src/hostif/parodusClient/pal/mock-parodus/Makefile.am b/src/hostif/parodusClient/pal/mock-parodus/Makefile.am new file mode 100644 index 000000000..1e789bd95 --- /dev/null +++ b/src/hostif/parodusClient/pal/mock-parodus/Makefile.am @@ -0,0 +1,75 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +bin_PROGRAMS = parodus +PARODUS_INSTALL_DIR = /usr/local +LOCAL_DIR = /usr/local + + +parodus_SOURCES = \ + parodus.cpp \ + ../webpa_notification.cpp \ + ../libpd.cpp \ + ../webpa_parameter.cpp \ + ../webpa_adapter.cpp ../webpa_attribute.cpp \ + ../../../handlers/src/hostIf_msgHandler.cpp \ + ../../../src/hostIf_utils.cpp \ + ../../../handlers/src/hostIf_NotificationHandler.cpp \ + ../../../handlers/src/hostIf_TimeClient_ReqHandler.cpp \ + ../../../profiles/Time/Device_Time.cpp \ + ../../../profiles/DeviceInfo/XrdkCentralComBSStore.cpp \ + ../../../profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp \ + ../../../profiles/DeviceInfo/Device_DeviceInfo.cpp \ + ../../../handlers/src/hostIf_DeviceClient_ReqHandler.cpp \ + ../../../profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus_Process.cpp \ + ../../../handlers/src/hostIf_EthernetClient_ReqHandler.cpp \ + ../../../profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp \ + ../../../profiles/Ethernet/Device_Ethernet_Interface.cpp \ + ../../../profiles/DeviceInfo/XrdkCentralComRFC.cpp \ + ../../../profiles/DeviceInfo/XrdkCentralComRFCStore.cpp \ + ../../../profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp \ + ../../../profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.cpp \ + ../../../src/IniFile.cpp \ + ../../../../unittest/stubs/powerctrl_stubs.cpp \ + ../../../../unittest/stubs/paramMgr.c \ + ../../../handlers/src/hostIf_IPClient_ReqHandler.cpp \ + ../../../profiles/IP/Device_IP_Interface.cpp \ + ../../../profiles/IP/Device_IP.cpp \ + ../../../profiles/IP/Device_IP_Interface_IPv4Address.cpp \ + ../../../profiles/IP/Device_IP_Diagnostics_IPPing.cpp \ + ../../../profiles/IP/Device_IP_Interface_Stats.cpp \ + ../../../profiles/IP/Device_IP_ActivePort.cpp \ + ../../../handlers/src/hostIf_updateHandler.cpp \ + ../../../handlers/src/hostIf_dsClient_ReqHandler.cpp \ + ../../../profiles/STBService/Components_VideoOutput.cpp \ + ../../../profiles/STBService/Components_HDMI.cpp \ + ../../../profiles/STBService/Components_AudioOutput.cpp \ + ../../../profiles/STBService/Components_VideoDecoder.cpp \ + ../../../profiles/STBService/Components_SPDIF.cpp \ + ../../../profiles/STBService/Capabilities.cpp \ + ../../../profiles/STBService/Components_DisplayDevice.cpp \ + ../../../handlers/src/x_rdk_req_handler.cpp \ + ../../../profiles/Device/x_rdk_profile.cpp \ + ../../../handlers/src/hostIf_XrdkCentralT2_ReqHandler.cpp \ + ../../../handlers/src/hostIf_rbus_Dml_Provider.cpp + +parodus_CPPFLAGS = -I../ -I../../../../unittest/stubs/ -I/usr/local/include/wrp-c/ -I../../waldb/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include/wdmp-c/ -I/usr/local/include/rbus -I../../../include/ -I../../../../unittest/stubs/ -I../../../handlers/src/ -I/usr/local/include/cjson/ -I/usr/local/include/libparodus/ -I./ -I../../waldb/ -I../../../handlers/include/ -I../../../profiles/Time/ -I../../../profiles/DeviceInfo/ -I../../../profiles/Device -I../../../handlers/include/ -I../../../../unittest/stubs/ds -I../../../profiles/Ethernet/ -I../../../include/ -I../../../profiles/IP/ -I../../../profiles/STBService/ -I/usr/rdk-halif-device_settings/include/ -I/usr/rdkvhal-devicesettings-raspberrypi4/ -DUSE_REMOTE_DEBUGGER -I/usr/remote_debugger/src/ + +parodus_LDADD = -llibparodus -lrdkloggers -lwdmp-c -lwrp-c -lmsgpackc -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -lcjson -lpthread -lglib-2.0 -lnanomsg -lrbus -lIARMBus -lyajl -lds -ldshalcli -ldbus-1 -lsecure_wrapper -lcurl -L../../waldb/.libs/ -l:libwaldb.a -L../../../profiles/Time/.libs/ -l:libhostIfTime.a -ltinyxml2 -lIARMBus + diff --git a/src/hostif/parodusClient/pal/mock-parodus/configure.ac b/src/hostif/parodusClient/pal/mock-parodus/configure.ac new file mode 100644 index 000000000..d4987e75b --- /dev/null +++ b/src/hostif/parodusClient/pal/mock-parodus/configure.ac @@ -0,0 +1,6 @@ +AC_INIT([mock_parodus_for_t2], [1.0], [your_email@example.com]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) +AC_PROG_CC +AC_PROG_CXX +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/src/hostif/parodusClient/pal/mock-parodus/mock_parodus_build.sh b/src/hostif/parodusClient/pal/mock-parodus/mock_parodus_build.sh new file mode 100644 index 000000000..b018aec1d --- /dev/null +++ b/src/hostif/parodusClient/pal/mock-parodus/mock_parodus_build.sh @@ -0,0 +1,3 @@ +sed -i '/getCurrentTime/,/^ *}/d' ../../../src/hostIf_utils.cpp +autoreconf --install && \ +./configure --prefix=/usr/local && make && make install diff --git a/src/hostif/parodusClient/pal/mock-parodus/parodus.cpp b/src/hostif/parodusClient/pal/mock-parodus/parodus.cpp new file mode 100644 index 000000000..a12e7e8a7 --- /dev/null +++ b/src/hostif/parodusClient/pal/mock-parodus/parodus.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include +#include +#include "webpa_adapter.h" + +int main(int argc, char* argv[]) +{ + + std::cout <<"parodus start" << std::endl; + wrp_msg_t *wrp_msg; + wrp_msg_t *res_wrp_msg ; + + wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + res_wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + memset(res_wrp_msg, 0, sizeof(wrp_msg_t)); + + wrp_msg->msg_type = WRP_MSG_TYPE__REQ; + + const char *payload = argv[1]; + wrp_msg->u.req.payload = (void*)payload; + + wrp_msg->u.req.payload_size = strlen((char*)wrp_msg->u.req.payload); + + processRequest((char*)wrp_msg->u.req.payload, (char*)wrp_msg->u.req.transaction_uuid, ((char **)(&(res_wrp_msg->u.req.payload)))); + + std::cout << "Response payload: " << (char*)res_wrp_msg->u.req.payload << std::endl; + + char *json_response = (char*)res_wrp_msg->u.req.payload; + if (json_response && json_response[0] != '\0') + { + std::ofstream logFile("/opt/logs/parodus.log"); + + if (logFile.is_open()) { + + logFile << "Response payload: " << json_response << std::endl; + logFile.close(); + } else { + std::cerr << "Failed to open parodus log file" << std::endl; + } + + } else { + std::cout << "Response is empty, not writing to parodus.log" << std::endl; + } + + std::cout << "parodus end"<< std::endl; +} diff --git a/src/unittest/stubs/paramMgr.c b/src/unittest/stubs/paramMgr.c new file mode 100644 index 000000000..44a568f61 --- /dev/null +++ b/src/unittest/stubs/paramMgr.c @@ -0,0 +1,4 @@ +#include "paramMgr.h" + +GHashTable* paramMgrhash = NULL; // Definition +T_ARGLIST argList = {0}; diff --git a/src/unittest/stubs/paramMgr.h b/src/unittest/stubs/paramMgr.h new file mode 100644 index 000000000..1d70b18a0 --- /dev/null +++ b/src/unittest/stubs/paramMgr.h @@ -0,0 +1,18 @@ +// paramMgr.h +#ifndef PARAM_MGR_H +#define PARAM_MGR_H + +#include + +extern GHashTable* paramMgrhash; // Declaration + +typedef struct argsList { + char logFileName[64]; + char confFile[100]; + int httpPort; +#ifndef NEW_HTTP_SERVER_DISABLE + int httpServerPort; //new HTTP Server Port for JSON Requests +#endif +} T_ARGLIST; + +#endif diff --git a/test/functional-tests/features/tr69hostif_webpa.feature b/test/functional-tests/features/tr69hostif_webpa.feature new file mode 100644 index 000000000..e9ba25db3 --- /dev/null +++ b/test/functional-tests/features/tr69hostif_webpa.feature @@ -0,0 +1,59 @@ +#################################################################################### +# If not stated otherwise in this file or this component's Licenses.txt file the +# following copyright and licenses apply: +# +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#################################################################################### + + +Feature: WebPA Set Get using mock parodus + + Background: + Given the mock parodus executable is avaliable at "/usr/local/bin/parodus" + And it accepts payloads as input + + + Scenario: Set a WebPA parameter using mock parodus + Given a valid WebPA set request payload: + """ + { + "command": "SET", + "parameters": [ + { + "name": "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable", + "value": "false", + "dataType": 3 + } + ] + } + """ + When I execute the mock parodus with the payload + Then the response should indicate success + And the parameter "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable" should be "false" + + Scenario: Get a WebPA parameter using mock parodus + Given a valid WebPA get request payload: + """ + { + "command": "GET", + "names": [ + "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable" + ] + } + """ + When I execute the mock parodus with the payload + Then the response should indicate success + And the returned value should be "false" + diff --git a/test/functional-tests/tests/basic_constants.py b/test/functional-tests/tests/basic_constants.py index 506361886..9bad64f88 100644 --- a/test/functional-tests/tests/basic_constants.py +++ b/test/functional-tests/tests/basic_constants.py @@ -45,5 +45,6 @@ LOG_FILE = "/opt/logs/tr69hostif.log.0" +PARODUS_LOG_FILE = "/opt/logs/parodus.log" DATA_LAKE_URL = "https://mockxconf:50051" DL_ADMIN_URL = "https://mockxconf:50051/adminSupport" diff --git a/test/functional-tests/tests/helper_functions.py b/test/functional-tests/tests/helper_functions.py index fa28848b0..d807194ca 100644 --- a/test/functional-tests/tests/helper_functions.py +++ b/test/functional-tests/tests/helper_functions.py @@ -167,3 +167,14 @@ def run_shell_command(command): result = subprocess.run(command, shell=True, capture_output=True, text=True) return result.stdout.strip() +def grep_paroduslogs(search: str): + search_result = "" + search_pattern = re.compile(re.escape(search), re.IGNORECASE) + try: + with open(PARODUS_LOG_FILE, 'r', encoding='utf-8', errors='ignore') as file: + for line_number, line in enumerate(file, start=1): + if search_pattern.search(line): + search_result = search_result + " \n" + line + except Exception as e: + print(f"Could not read file {PARODUS_LOG_FILE}: {e}") + return search_result diff --git a/test/functional-tests/tests/tr69hostif_webpa.py b/test/functional-tests/tests/tr69hostif_webpa.py new file mode 100644 index 000000000..914ca85b0 --- /dev/null +++ b/test/functional-tests/tests/tr69hostif_webpa.py @@ -0,0 +1,249 @@ +#################################################################################### +# If not stated otherwise in this file or this component's Licenses file the +# following copyright and licenses apply: +# +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#################################################################################### + + +import subprocess +import pytest +from time import sleep + +from helper_functions import * + +@pytest.mark.run(order=17) +def test_WebPA_Set_XCONF_URL_Handler(): + print("Starting parodus mock process") + payload = '{"command":"SET","parameters":[{"name":"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.XconfUrl","dataType":0,"value":"https://rdkautotool.ccp.xcal.tv/featureControl/getSettings"}]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + +@pytest.mark.run(order=18) +def test_WebPA_Get_XCONF_URL_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.XconfUrl"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + XCONF_URL_STATUS_MSG = '"value":"https://rdkautotool.ccp.xcal.tv/featureControl/getSettings"' + assert XCONF_URL_STATUS_MSG in grep_paroduslogs(XCONF_URL_STATUS_MSG) + +@pytest.mark.run(order=19) +def test_WebPA_Set_FWUPDATE_Handler(): + print("Starting parodus mock process") + payload = '{"command":"SET","parameters":[{"name":"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable","dataType":3,"value":"false"}]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + +@pytest.mark.run(order=20) +def test_WebPA_Get_FWUPDATE_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + FWUPDATE_STATUS_MSG = '"value":"false"' + assert FWUPDATE_STATUS_MSG in grep_paroduslogs(FWUPDATE_STATUS_MSG) + +@pytest.mark.run(order=21) +def test_WebPA_Set_LOGURL_Handler(): + print("Starting parodus mock process") + payload = '{"command":"SET","parameters":[{"name":"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.LogUpload.LogServerUrl","dataType":0,"value":"logs.xcal.tv"}]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + +@pytest.mark.run(order=22) +def test_WebPA_Get_LOGURL_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.LogUpload.LogServerUrl"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + LOGURL_MSG = '"value":"logs.xcal.tv"' + assert LOGURL_MSG in grep_paroduslogs(LOGURL_MSG) + +@pytest.mark.run(order=23) +def test_WebPA_Get_SPEED_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.LowSpeed"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + SPEED_STATUS_MSG = '"value":"12800"' + assert SPEED_STATUS_MSG in grep_paroduslogs(SPEED_STATUS_MSG) + +@pytest.mark.run(order=24) +def test_WebPA_Get_FW_PROTOCOL_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadProtocol"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + FWDL_PROTOCOL_MSG = '"value":"http"' + assert FWDL_PROTOCOL_MSG in grep_paroduslogs(FWDL_PROTOCOL_MSG) + +@pytest.mark.run(order=25) +def test_WebPA_Get_FWDL_STATUS_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadStatus"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + FWDL_STATUS_MSG = '"value":"Download In Progress"' + assert FWDL_STATUS_MSG in grep_paroduslogs(FWDL_STATUS_MSG) + +@pytest.mark.run(order=26) +def test_WebPA_Get_FWDL_URL_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadURL"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + FWDL_URL_MSG = '"value":"https://dac15cdlserver.ae.ccp.xcal.tv/Images"' + assert FWDL_URL_MSG in grep_paroduslogs(FWDL_URL_MSG) + +@pytest.mark.run(order=27) +def test_WebPA_Get_FWDL_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareToDownload"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + FWDL_MSG = '"value":"ELTE11MWR_E037.000.00.8.1s22_DEV.bin"' + assert FWDL_MSG in grep_paroduslogs(FWDL_MSG) + +@pytest.mark.run(order=28) +def test_WebPA_Get_FWUPDATE_STATUS_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareUpdateState"]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + FWUPDATE_STATUS_MSG = '"value":"Download complete"' + assert FWUPDATE_STATUS_MSG in grep_paroduslogs(FWUPDATE_STATUS_MSG) + +@pytest.mark.run(order=29) +def test_WebPA_Get_WILDCARD_STATUS_Handler(): + print("Starting parodus mock process") + payload ='{"command":"GET","names":["Device.DeviceInfo."]}' + command = ["/usr/local/bin/parodus", payload] + + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + STATUS_CODE_MSG = '"statusCode":200' + assert STATUS_CODE_MSG in grep_paroduslogs(STATUS_CODE_MSG) + + SUCCESS_STATUS_MSG = '"message":"Success"' + assert SUCCESS_STATUS_MSG in grep_paroduslogs(SUCCESS_STATUS_MSG) + + From 84456ddcb78733197fc7737796f4053b58ac900c Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 22 May 2025 01:02:15 +0530 Subject: [PATCH 070/161] Update data-model-generic.xml --- .../waldb/data-model/data-model-generic.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 5e7e9ad50..0e9250462 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4439,6 +4439,13 @@ - + + + + + + + + From 94f912e35adeea0f4cb69d5ca0560d650ce0d738 Mon Sep 17 00:00:00 2001 From: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> Date: Wed, 21 May 2025 16:13:28 -0400 Subject: [PATCH 071/161] RDKEMW-3656 : tr69hostif Crash in mutex unlock (#156) * RDKEMW-3656 : tr69hostif Crash in mutex unlock Signed-off-by: Venkata Bojja * RDKEMW-3656 : tr69hostif Crash in mutex unlock Signed-off-by: Venkata Bojja --------- Signed-off-by: Venkata Bojja Co-authored-by: Venkata Bojja --- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 64 ++++++++++++++----- .../profiles/DeviceInfo/Device_DeviceInfo.h | 6 +- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index c122a3b9d..b236d1e67 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -125,14 +125,16 @@ GHashTable* hostIf_DeviceInfo::ifHash = NULL; GHashTable* hostIf_DeviceInfo::m_notifyHash = NULL; -GMutex hostIf_DeviceInfo::m_mutex; + +pthread_mutex_t hostIf_DeviceInfo::m_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_mutexattr_t hostIf_DeviceInfo::m_mutex_attr; +pthread_once_t hostIf_DeviceInfo::m_mutex_init_once = PTHREAD_ONCE_INIT; extern rbusHandle_t rbusHandle; void *ResetFunc(void *); static char stbMacCache[TR69HOSTIFMGR_MAX_PARAM_LEN] = {'\0'}; -static int mutex_lock = 0; static string reverseSSHArgs,shortsArgs,nonShortsArgs; map stunnelSSHArgs; const string sshCommand = "/lib/rdk/startTunnel.sh"; @@ -267,23 +269,53 @@ void hostIf_DeviceInfo::closeAllInstances() } } -void hostIf_DeviceInfo::getLock() -{ - g_mutex_init(&hostIf_DeviceInfo::m_mutex); - g_mutex_lock(&hostIf_DeviceInfo::m_mutex); - mutex_lock = 1; +// Function to be called by pthread_once +void hostIf_DeviceInfo::initMutexAttributes() { + pthread_mutexattr_init(&hostIf_DeviceInfo::m_mutex_attr); + pthread_mutexattr_settype(&hostIf_DeviceInfo::m_mutex_attr, PTHREAD_MUTEX_ERRORCHECK); + pthread_mutex_init(&hostIf_DeviceInfo::m_mutex, &hostIf_DeviceInfo::m_mutex_attr); } -void hostIf_DeviceInfo::releaseLock() -{ - if(mutex_lock == 1) - { - mutex_lock = 0; - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Unlocking mutex... \n", __FUNCTION__, __LINE__); - g_mutex_unlock(&hostIf_DeviceInfo::m_mutex); +void hostIf_DeviceInfo::initMutexOnce() { + pthread_once(&m_mutex_init_once, (void (*)(void))&hostIf_DeviceInfo::initMutexAttributes); +} + +void hostIf_DeviceInfo::getLock() { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Attempting to lock mutex\n", __FUNCTION__, __LINE__); + + // Ensure mutex is initialized + hostIf_DeviceInfo::initMutexOnce(); + + // Try to lock + int lock_result = pthread_mutex_lock(&hostIf_DeviceInfo::m_mutex); + if (lock_result == 0) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Locked mutex\n", __FUNCTION__, __LINE__); + } else { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Failed to lock mutex: %s\n", + __FUNCTION__, __LINE__, strerror(lock_result)); } - else { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%d] Mutex is not locked, cannot unlock... \n", __FUNCTION__, __LINE__); +} + +void hostIf_DeviceInfo::releaseLock() { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Unlocking mutex...\n", __FUNCTION__, __LINE__); + + // Try to unlock and handle errors + int unlock_result = pthread_mutex_unlock(&hostIf_DeviceInfo::m_mutex); + + if (unlock_result == 0) { + // Successful unlock + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Successfully unlocked mutex\n", + __FUNCTION__, __LINE__); + } else if (unlock_result == EPERM) { + // Thread doesn't own the mutex + RDK_LOG(RDK_LOG_WARN, LOG_TR69HOSTIF, + "[%s:%d] Thread doesn't own the mutex, skipping unlock\n", + __FUNCTION__, __LINE__); + } else { + // Other error + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, + "[%s:%d] Error unlocking mutex: %s\n", + __FUNCTION__, __LINE__, strerror(unlock_result)); } } diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index e73920915..be3597b97 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -202,7 +202,11 @@ class hostIf_DeviceInfo { static GHashTable *m_notifyHash; - static GMutex m_mutex; + static pthread_mutex_t m_mutex; + static pthread_mutexattr_t m_mutex_attr; + static pthread_once_t m_mutex_init_once; + static void initMutexOnce(); + static void initMutexAttributes(); int dev_id; From cb1eccd20b00974a05198f508ecf9fca8659f214 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Fri, 6 Jun 2025 18:47:02 +0530 Subject: [PATCH 072/161] RDKEMW-2629 [RDKE] Review and Cleanup tr69hostif module debug and error logs (#167) * Update hostIf_IARM_ReqHandler.cpp * Update hostIf_msgHandler.cpp * Update hostIf_rbus_Dml_Provider.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update XrdkCentralComRFCStore.cpp * Update hostIf_main.cpp * Update rdk_debug.h * Update Device_DeviceInfo.cpp * Update hostIf_msgHandler.cpp * Update Device_DeviceInfo.cpp --- .../handlers/src/hostIf_IARM_ReqHandler.cpp | 2 +- src/hostif/handlers/src/hostIf_msgHandler.cpp | 36 +++++++++++++++++++ .../handlers/src/hostIf_rbus_Dml_Provider.cpp | 2 +- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 4 +-- .../DeviceInfo/XrdkCentralComRFCStore.cpp | 4 +-- src/hostif/src/hostIf_main.cpp | 2 +- src/unittest/stubs/rdk_debug.h | 3 ++ 7 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index bcfbbe6e4..05d801e2e 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -95,7 +95,7 @@ bool hostIf_IARM_IF_Start() void hostIf_getPwrContInterface() { - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); /*TODO: remove this sleep after fix METROL-1045*/ sleep(5);//added sleep wait for the WPEframework active. diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 8e35c75f8..b09db975c 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -30,6 +30,7 @@ **/ #include +#include #include "hostIf_main.h" #include "hostIf_msgHandler.h" #include "hostIf_utils.h" @@ -68,12 +69,18 @@ extern GHashTable* paramMgrhash; extern T_ARGLIST argList; static std::mutex get_handler_mutex; static std::mutex set_handler_mutex; +static int getCount = 0; +static int setCount = 0; int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; int ret = NOK; + getCount++; + if (getCount % 10 == 0) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s:%d] GET called %d times\n",__FUNCTION__, __LINE__, getCount); + } std::lock_guard lock(get_handler_mutex); try { @@ -81,7 +88,20 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) msgHandler *pMsgHandler = HostIf_GetMgr(stMsgData); if(pMsgHandler) + { + auto startTime = std::chrono::high_resolution_clock::now(); ret = pMsgHandler->handleGetMsg(stMsgData); + auto endTime = std::chrono::high_resolution_clock::now(); + auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); + + // Calculate time taken in microseconds + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", + __FUNCTION__, __LINE__, ret, + stMsgData->paramName, + stMsgData->paramValue, + timeTaken); + } } catch (const std::exception& e) { @@ -94,6 +114,10 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) { int ret = NOK; + setCount++; + if (setCount % 10 == 0) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s:%d] SET called %d times\n",__FUNCTION__, __LINE__, setCount); + } std::lock_guard lock(set_handler_mutex); RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); @@ -102,7 +126,19 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) msgHandler *pMsgHandler = HostIf_GetMgr(stMsgData); if(pMsgHandler) + { + auto startTime = std::chrono::high_resolution_clock::now(); ret = pMsgHandler->handleSetMsg(stMsgData); + auto endTime = std::chrono::high_resolution_clock::now(); + auto timeTakenset = std::chrono::duration_cast(endTime - startTime).count(); + + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", + __FUNCTION__, __LINE__, ret, + stMsgData->paramName, + stMsgData->paramValue, + timeTakenset); + } RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return ret; diff --git a/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp b/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp index 0cdc2147f..60a043e33 100644 --- a/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp +++ b/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp @@ -514,7 +514,7 @@ void init_rbus_dml_provider() DataModelParam dmParam = {0}; if (getParamInfoFromDataModel(dataBaseHandle, dataElements[rbus_param_counter].name, &dmParam) == 0) { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s][rbusdml] Parameter not found. \n ", __FUNCTION__); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s][rbusdml] Parameter not found: %s\n", __FUNCTION__, dataElements[rbus_param_counter].name); } else { diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index b236d1e67..7e94754e6 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -525,7 +525,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_SoftwareVersion(HOSTIF_MsgData_t * int hostIf_DeviceInfo::get_Device_DeviceInfo_Migration_MigrationStatus(HOSTIF_MsgData_t * stMsgData, bool *pChanged) { string line = "NOT_NEEDED"; - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Entering..\n", __FUNCTION__ ); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()] Entering..\n", __FUNCTION__ ); ifstream file_read (MigrationStatus); try { if (file_read.is_open()) @@ -550,7 +550,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_Migration_MigrationStatus(HOSTIF_Ms strncpy(stMsgData->paramValue, line.c_str(), len); stMsgData->paramValue[len+1] = '\0'; stMsgData->paramLen = len; - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ ); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()] Exiting..\n", __FUNCTION__ ); return OK; } diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp index 2dd8384a0..21441f830 100644 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp @@ -245,7 +245,7 @@ faultCode_t XRFCStore::getValue(HOSTIF_MsgData_t *stMsgData) return fcInternalError; } string rawValue = getRawValue(stMsgData->paramName); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "rawValue: %s\n", rawValue.c_str()); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "Parameter: %s, rawValue: %s\n", stMsgData->paramName, rawValue.c_str()); if(rawValue.length() > 0) { putValue(stMsgData, rawValue.c_str()); @@ -265,7 +265,7 @@ faultCode_t XRFCStore::getValue(HOSTIF_MsgData_t *stMsgData) putValue(stMsgData, rawValue.c_str()); stMsgData->faultCode = fcNoFault; - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "stMsgData->paramValue = %s\n", stMsgData->paramValue); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "stMsgData->paramValue = %s\n", stMsgData->paramValue); } else { diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index da50b489b..123567d04 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -751,7 +751,7 @@ MergeStatus mergeDataModel() { } } fclose(fp); - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "mergeDataModel: Closed /etc/device.properties\n"); + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "mergeDataModel: Closed /etc/device.properties\n"); const char *generic_file = GENERIC_XML_FILE; const char *output_file = WEBPA_DATA_MODEL_FILE; if (strcmp(rdk_profile, "TV") == 0) { diff --git a/src/unittest/stubs/rdk_debug.h b/src/unittest/stubs/rdk_debug.h index b721e2af1..62e201e9a 100644 --- a/src/unittest/stubs/rdk_debug.h +++ b/src/unittest/stubs/rdk_debug.h @@ -43,6 +43,9 @@ else if (( level == RDK_LOG_ERROR )) { \ printf("ERROR: %s: ", module); \ } \ + else if (( level == RDK_LOG_TRACE1 )) { \ + printf("TRACE: %s: ", module); \ + } \ printf(__VA_ARGS__); \ } while (0) From 577d42c7dfdf4edc838e65a635021f6137d3f36d Mon Sep 17 00:00:00 2001 From: apatel859 <48992974+apatel859@users.noreply.github.com> Date: Mon, 9 Jun 2025 11:51:44 -0400 Subject: [PATCH 073/161] Rdkemw 4383 remove dsmgr dependency (#168) * DELIA-67810: remove dsmgr dependency Signed-off-by: apatel859 * DELIA-67810: remove dsmgr dependency Signed-off-by: apatel859 * Update data-model-generic.xml * RDKEMW-4383: remove dsmgr dependency Signed-off-by: apatel859 --------- Signed-off-by: apatel859 Co-authored-by: Vismal S Kumar Co-authored-by: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> --- src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp | 8 +++++--- tr69hostif.service | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 05d801e2e..9451b4a6c 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -77,8 +77,6 @@ bool hostIf_IARM_IF_Start() ret = true; /* Initialize Managers */ msgHandler *pMsgHandler; - pMsgHandler = DSClientReqHandler::getInstance(); - pMsgHandler->init(); pMsgHandler = DeviceClientReqHandler::getInstance(); pMsgHandler->init(); @@ -98,7 +96,11 @@ void hostIf_getPwrContInterface() RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); /*TODO: remove this sleep after fix METROL-1045*/ - sleep(5);//added sleep wait for the WPEframework active. + sleep(10);//added sleep wait for the WPEframework active. + msgHandler *pMsgHandler; + pMsgHandler = DSClientReqHandler::getInstance(); + pMsgHandler->init(); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: start PowerController_Init().. \n", __FUNCTION__, __LINE__); PowerController_Init(); RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d]: completed PowerController_Init().. \n", __FUNCTION__, __LINE__); diff --git a/tr69hostif.service b/tr69hostif.service index 5152d8775..4750ed9e2 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -18,7 +18,7 @@ ########################################################################## [Unit] Description=TR69 Host Interface Daemon -After=lighttpd.service securemount.service dsmgr.service +After=lighttpd.service securemount.service [Service] Type=notify From 4f4519e4e2765af4f1cb54cacf325b13d24d6db0 Mon Sep 17 00:00:00 2001 From: tpaul627 <69359527+tpaul627@users.noreply.github.com> Date: Tue, 10 Jun 2025 04:52:10 +0530 Subject: [PATCH 074/161] RDKEMW-3396:Default AV Hijack RFC to true (#174) Reason for change: Default ReserveTTS rfc to true Test Procedure: as per RDKEMW-3396 Priority: P1 Risks: Low Signed-off-by: Tony Paul --- .../parodusClient/waldb/data-model/data-model-generic.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 0e9250462..32ed43226 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4325,7 +4325,7 @@ - + From 25a14512db9b26453a4e9fd2e97ddf2cb9e36f59 Mon Sep 17 00:00:00 2001 From: Shrinivas Kamath Date: Tue, 10 Jun 2025 18:09:05 +0530 Subject: [PATCH 075/161] Hard stop for tr69hostif service during cleanup --- tr69hostif.service | 1 + 1 file changed, 1 insertion(+) diff --git a/tr69hostif.service b/tr69hostif.service index 5152d8775..3c4ab4862 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -30,6 +30,7 @@ ExecStart=/usr/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 -s 11999 -d $DEBUGIN ExecStop=/bin/kill -15 $MAINPID RestartSec=10s Restart=always +TimeoutStopSec=5 [Install] WantedBy=multi-user.target From a48a187a96f1a86c152e50aec3578cc2d3e52355 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Tue, 10 Jun 2025 10:01:13 -0400 Subject: [PATCH 076/161] RDKTV-36715: Logs flooding issue observed in tr69hostif.log "refreshInterfaceName:" (#169) * Update Device_InterfaceStack.cpp * Update Device_InterfaceStack.cpp * Update Device_InterfaceStack.cpp * Update Device_InterfaceStack.cpp * Update Device_InterfaceStack.cpp --- .../InterfaceStack/Device_InterfaceStack.cpp | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp b/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp index eb757e082..93e50a014 100644 --- a/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp +++ b/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp @@ -49,6 +49,7 @@ #define MAX_CMD_LEN 256 #define MAX_IFNAME_LEN 64 #define SYS_CLASS_NET_PATH "/sys/class/net/" +#define MAX_IFCS 256 #define IN #define OUT @@ -834,6 +835,38 @@ int hostif_InterfaceStack::buildBridgeTableLayerInfo(InterfaceStackMap_t &layerI return(rc); } +/* getIPInterfaceIDs + * This function populates interface ID Array for all available IP interfaces + */ + +void getIPInterfaceIDs(int *ifindexes) { + int count = 0; + FILE *fp = popen("ls /sys/class/net", "r"); + if (!fp) { + perror("popen"); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s:%d Failed to open /sys/class/net contents\n", __FILE__, __LINE__); + return; + } + + char iface[256]; + while (fgets(iface, sizeof(iface), fp)) { + iface[strcspn(iface, "\n")] = 0; + + char command[512]; + snprintf(command, sizeof(command), "cat /sys/class/net/%s/ifindex", iface); + + FILE *ifindex_fp = popen(command, "r"); + if (ifindex_fp) { + char buffer[64]; + if (fgets(buffer, sizeof(buffer), ifindex_fp)) { + ifindexes[count++] = atoi(buffer); + } + pclose(ifindex_fp); + } + } + pclose(fp); +} + /* getIPInterfaces * This function builds up a map for all the available IP interfaces. */ @@ -854,10 +887,13 @@ int hostif_InterfaceStack::getIPInterfaces(IPInterfacesMap_t& interfaceList) ipNumOfEntries=get_int(msgData.paramValue); RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"%s:%d ipNumOfEntries = %d\n", __FUNCTION__, __LINE__, ipNumOfEntries); - for(ipIndex=1; ipIndex <= ipNumOfEntries; ipIndex++) + int ifindexes[MAX_IFCS]; + getIPInterfaceIDs(ifindexes); + + for(ipIndex=0; ipIndex < ipNumOfEntries && ipIndex < MAX_IFCS; ipIndex++) { std::string ipIfName; - hostIf_IPInterface *pIface = hostIf_IPInterface::getInstance(ipIndex); + hostIf_IPInterface *pIface = hostIf_IPInterface::getInstance(ifindexes[ipIndex]); if(!pIface) { @@ -874,6 +910,9 @@ int hostif_InterfaceStack::getIPInterfaces(IPInterfacesMap_t& interfaceList) interfaceList.insert( std::pair(ipIfName, ipIndex)); } } + if (ipIndex >= MAX_IFCS) { + RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"%s:%d Available interfaces exceeds max no. of interfaces (%d)\n", __FILE__, __LINE__, MAX_IFCS); + } } return(rc); } From 0e9e1fbfd7ec08656c5bb69d71793d8d1f455b9f Mon Sep 17 00:00:00 2001 From: madhubabutt <114217841+madhubabutt@users.noreply.github.com> Date: Thu, 12 Jun 2025 03:12:52 +0530 Subject: [PATCH 077/161] RDK-49251 [RDK-E] L2 Test In CI Loops For Firewall (#170) * RDK-49251 [RDK-E] L2 Test In CI Loops For Firewall * Update cov_build.sh --------- Co-authored-by: mtirum011 --- cov_build.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cov_build.sh b/cov_build.sh index fe1ba354f..d2dbced0d 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -9,10 +9,16 @@ cd $ROOT git clone https://github.com/rdkcentral/rfc.git cd rfc autoreconf -i -./configure --enable-rfctool=yes --enable-tr181set=yes +./configure --enable-rfctool=yes --enable-tr181set=yes --enable-tr69hostif=yes cd rfcapi make librfcapi_la_CPPFLAGS="-I/usr/include/cjson" make install +cd ../tr181api +cp /usr/include/cjson/cJSON.h ./ +cp /usr/local/include/wdmp-c/wdmp-c.h ./ +make AM_CXXFLAGS="-DUSE_TR69HOSTIF" && make install +cd ../utils +make && make install #Build yajl - tr69 alone needs this specific version cd $ROOT @@ -72,3 +78,6 @@ make install cd ./src/hostif/parodusClient/pal/mock-parodus/ sh mock_parodus_build.sh + +ln -sf /usr/local/bin/tr181 /usr/bin/tr181Set +rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable boolean true From 0088d6eb5b823e2136b25ad8c7f236bd2fa217d6 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:27:38 -0400 Subject: [PATCH 078/161] RDKTV-36715: Logs flooding issue observed in tr69hostif.log "refreshInterfaceName:" (#176) * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update Device_InterfaceStack.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update Device_InterfaceStack.cpp * Update hostIf_IPClient_ReqHandler.cpp * Update Device_InterfaceStack.cpp --- .../src/hostIf_IPClient_ReqHandler.cpp | 74 ++++++++++++++----- .../InterfaceStack/Device_InterfaceStack.cpp | 12 +-- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp index 614086b16..a902a075e 100644 --- a/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp @@ -1,3 +1,4 @@ + /* * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: @@ -46,8 +47,11 @@ #include "Device_IP.h" #include "Device_IP_Diagnostics_IPPing.h" #include "safec_lib.h" +#include "secure_wrapper.h" #include +#define MAX_IFCS 256 + std::mutex IPClientReqHandler::m_mutex; IPClientReqHandler* IPClientReqHandler::pInstance = NULL; updateCallback IPClientReqHandler::mUpdateCallback = NULL; @@ -425,6 +429,34 @@ void IPClientReqHandler::registerUpdateCallback(updateCallback cb) mUpdateCallback = cb; } +void getIPIfcIDs(int *ifindexes) { + int count = 0; + FILE *fp = v_secure_popen("r", "ls /sys/class/net"); + if (!fp) { + perror("popen"); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s:%d Failed to open /sys/class/net contents\n", __FILE__, __LINE__); + return; + } + + char iface[256]; + while (fgets(iface, sizeof(iface), fp)) { + iface[strcspn(iface, "\n")] = 0; + + //char command[512]; + //snprintf(command, sizeof(command), "cat /sys/class/net/%s/ifindex", iface); + + FILE *ifindex_fp = v_secure_popen("r", "cat /sys/class/net/%s/ifindex", iface); + if (ifindex_fp) { + char buffer[64]; + if (fgets(buffer, sizeof(buffer), ifindex_fp)) { + ifindexes[count++] = atoi(buffer); + } + v_secure_pclose(ifindex_fp); + } + } + v_secure_pclose(fp); +} + void IPClientReqHandler::checkForUpdates() { if (mUpdateCallback == 0) @@ -449,28 +481,34 @@ void IPClientReqHandler::checkForUpdates() sendAddRemoveEvents (mUpdateCallback, interfaceNumberOfEntries, curNumOfIPInterface, objectPath); } - for (int i = 1; i <= interfaceNumberOfEntries; i++) + int ifindexes[MAX_IFCS]; + getIPIfcIDs(ifindexes); + for (int i = 0; i < interfaceNumberOfEntries && i < MAX_IFCS; i++) { - int ipv4AddressNumberOfEntries = hostIf_IPInterface::getInstance (i)->getIPv4AddressNumberOfEntries (); - RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv4AddressNumberOfEntries = %d, curNumOfInterfaceIPv4Addresses[%d] = %d\n", - __FILE__, __FUNCTION__, __LINE__, ipv4AddressNumberOfEntries, i, curNumOfInterfaceIPv4Addresses[i]); - sprintf (objectPath, "Device.IP.Interface.%d.IPv4Address.", i); - sendAddRemoveEvents (mUpdateCallback, ipv4AddressNumberOfEntries, curNumOfInterfaceIPv4Addresses[i], objectPath); + + if (ifindexes[i] > 0 && ifindexes[i] < sizeof(curNumOfInterfaceIPv4Addresses)/sizeof(curNumOfInterfaceIPv4Addresses[0])) { + int ipv4AddressNumberOfEntries = hostIf_IPInterface::getInstance (ifindexes[i])->getIPv4AddressNumberOfEntries (); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv4AddressNumberOfEntries = %d, curNumOfInterfaceIPv4Addresses[%d] = %d\n", + __FILE__, __FUNCTION__, __LINE__, ipv4AddressNumberOfEntries, ifindexes[i], curNumOfInterfaceIPv4Addresses[ifindexes[i]]); + sprintf (objectPath, "Device.IP.Interface.%d.IPv4Address.", ifindexes[i]); + sendAddRemoveEvents (mUpdateCallback, ipv4AddressNumberOfEntries, curNumOfInterfaceIPv4Addresses[ifindexes[i]], objectPath); #ifdef IPV6_SUPPORT - int ipv6AddressNumberOfEntries = hostIf_IPInterface::getInstance (i)->getIPv6AddressNumberOfEntries (); - RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv6AddressNumberOfEntries = %d, curNumOfInterfaceIPv6Addresses[%d] = %d\n", - __FILE__, __FUNCTION__, __LINE__, ipv6AddressNumberOfEntries, i, curNumOfInterfaceIPv6Addresses[i]); - sprintf (objectPath, "Device.IP.Interface.%d.IPv6Address.", i); - sendAddRemoveEvents (mUpdateCallback, ipv6AddressNumberOfEntries, curNumOfInterfaceIPv6Addresses[i], objectPath); - - int ipv6PrefixNumberOfEntries = hostIf_IPInterface::getInstance (i)->getIPv6PrefixNumberOfEntries (); - RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv6PrefixNumberOfEntries = %d, curNumOfInterfaceIPv6Prefixes[%d] = %d\n", - __FILE__, __FUNCTION__, __LINE__, ipv6PrefixNumberOfEntries, i, curNumOfInterfaceIPv6Prefixes[i]); - sprintf (objectPath, "Device.IP.Interface.%d.IPv6Prefix.", i); - sendAddRemoveEvents (mUpdateCallback, ipv6PrefixNumberOfEntries, curNumOfInterfaceIPv6Prefixes[i], objectPath); - + if (ifindexes[i] < sizeof(curNumOfInterfaceIPv6Addresses)/sizeof(curNumOfInterfaceIPv6Addresses[0])) { + int ipv6AddressNumberOfEntries = hostIf_IPInterface::getInstance (ifindexes[i])->getIPv6AddressNumberOfEntries (); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv6AddressNumberOfEntries = %d, curNumOfInterfaceIPv6Addresses[%d] = %d\n", + __FILE__, __FUNCTION__, __LINE__, ipv6AddressNumberOfEntries, ifindexes[i], curNumOfInterfaceIPv6Addresses[ifindexes[i]]); + sprintf (objectPath, "Device.IP.Interface.%d.IPv6Address.", ifindexes[i]); + sendAddRemoveEvents (mUpdateCallback, ipv6AddressNumberOfEntries, curNumOfInterfaceIPv6Addresses[ifindexes[i]], objectPath); + + int ipv6PrefixNumberOfEntries = hostIf_IPInterface::getInstance (ifindexes[i])->getIPv6PrefixNumberOfEntries (); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s:%d] ipv6PrefixNumberOfEntries = %d, curNumOfInterfaceIPv6Prefixes[%d] = %d\n", + __FILE__, __FUNCTION__, __LINE__, ipv6PrefixNumberOfEntries, ifindexes[i], curNumOfInterfaceIPv6Prefixes[ifindexes[i]]); + sprintf (objectPath, "Device.IP.Interface.%d.IPv6Prefix.", ifindexes[i]); + sendAddRemoveEvents (mUpdateCallback, ipv6PrefixNumberOfEntries, curNumOfInterfaceIPv6Prefixes[ifindexes[i]], objectPath); + } #endif // IPV6_SUPPORT + } } hostIf_IP::releaseLock(); diff --git a/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp b/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp index 93e50a014..844c8f43f 100644 --- a/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp +++ b/src/hostif/profiles/InterfaceStack/Device_InterfaceStack.cpp @@ -841,7 +841,7 @@ int hostif_InterfaceStack::buildBridgeTableLayerInfo(InterfaceStackMap_t &layerI void getIPInterfaceIDs(int *ifindexes) { int count = 0; - FILE *fp = popen("ls /sys/class/net", "r"); + FILE *fp = v_secure_popen("r", "ls /sys/class/net"); if (!fp) { perror("popen"); RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"%s:%d Failed to open /sys/class/net contents\n", __FILE__, __LINE__); @@ -852,19 +852,19 @@ void getIPInterfaceIDs(int *ifindexes) { while (fgets(iface, sizeof(iface), fp)) { iface[strcspn(iface, "\n")] = 0; - char command[512]; - snprintf(command, sizeof(command), "cat /sys/class/net/%s/ifindex", iface); + //char command[512]; + //snprintf(command, sizeof(command), "cat /sys/class/net/%s/ifindex", iface); - FILE *ifindex_fp = popen(command, "r"); + FILE *ifindex_fp = v_secure_popen("r", "cat /sys/class/net/%s/ifindex", iface); if (ifindex_fp) { char buffer[64]; if (fgets(buffer, sizeof(buffer), ifindex_fp)) { ifindexes[count++] = atoi(buffer); } - pclose(ifindex_fp); + v_secure_pclose(ifindex_fp); } } - pclose(fp); + v_secure_pclose(fp); } /* getIPInterfaces From f762c8b689547f90328af5a628cd3fb4ca627eba Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Tue, 17 Jun 2025 21:13:02 -0400 Subject: [PATCH 079/161] 1.1.8 release changelog updates --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7335a96c5..12ecc4d1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,31 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.8](https://github.com/rdkcentral/tr69hostif/compare/1.1.7...1.1.8) + +- RDKEMW-4029 Hard stop for tr69hostif service during cleanup [`#175`](https://github.com/rdkcentral/tr69hostif/pull/175) +- RDKTV-36715: Logs flooding issue observed in tr69hostif.log "refreshInterfaceName:" [`#176`](https://github.com/rdkcentral/tr69hostif/pull/176) +- RDK-49251 [RDK-E] L2 Test In CI Loops For Firewall [`#170`](https://github.com/rdkcentral/tr69hostif/pull/170) +- RDKTV-36715: Logs flooding issue observed in tr69hostif.log "refreshInterfaceName:" [`#169`](https://github.com/rdkcentral/tr69hostif/pull/169) +- RDKEMW-3396:Default AV Hijack RFC to true [`#174`](https://github.com/rdkcentral/tr69hostif/pull/174) +- Rdkemw 4383 remove dsmgr dependency [`#168`](https://github.com/rdkcentral/tr69hostif/pull/168) +- RDKEMW-2629 [RDKE] Review and Cleanup tr69hostif module debug and error logs [`#167`](https://github.com/rdkcentral/tr69hostif/pull/167) +- RDKEMW-4334-InactiveApplications- tr181 parameter does not exist in data model [`#160`](https://github.com/rdkcentral/tr69hostif/pull/160) +- RDKEMW-3656 : tr69hostif Crash in mutex unlock (#156) [`#161`](https://github.com/rdkcentral/tr69hostif/pull/161) +- RDKEMW-3656 : tr69hostif Crash in mutex unlock [`#156`](https://github.com/rdkcentral/tr69hostif/pull/156) +- RDK-57360 [RDK-E] L2 test framework for tr69hostif - webpa path [`#147`](https://github.com/rdkcentral/tr69hostif/pull/147) +- Update data-model-generic.xml [`84456dd`](https://github.com/rdkcentral/tr69hostif/commit/84456ddcb78733197fc7737796f4053b58ac900c) +- Hard stop for tr69hostif service during cleanup [`25a1451`](https://github.com/rdkcentral/tr69hostif/commit/25a14512db9b26453a4e9fd2e97ddf2cb9e36f59) +- Merge tag '1.1.7' into develop [`b734976`](https://github.com/rdkcentral/tr69hostif/commit/b734976d85bdfb3cbc8ab93389fd5cb2ecbf3c58) + #### [1.1.7](https://github.com/rdkcentral/tr69hostif/compare/1.1.6...1.1.7) +> 14 May 2025 + - REFPLTV-2816: Update xconf server to golang based [`#150`](https://github.com/rdkcentral/tr69hostif/pull/150) - RDKEMW-3401: fetch failure in telemetry2_0 [`#148`](https://github.com/rdkcentral/tr69hostif/pull/148) - RDK-56291 L2 Tests And Integration With CI for Remote Debugger Dynamic Updates [`#141`](https://github.com/rdkcentral/tr69hostif/pull/141) +- 1.1.7 release changelog updates [`4ad981f`](https://github.com/rdkcentral/tr69hostif/commit/4ad981f01d57a3a65e7aca2791b5d490be524e3b) - Merge tag '1.1.6' into develop [`244c520`](https://github.com/rdkcentral/tr69hostif/commit/244c520c41af34b50a4d62fdffb1ff7bce04f309) #### [1.1.6](https://github.com/rdkcentral/tr69hostif/compare/1.1.5...1.1.6) From 1e6bff6c3773dbf6665a68ed952f687553fe6cef Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Wed, 18 Jun 2025 08:32:04 -0400 Subject: [PATCH 080/161] Update hostIf_IPClient_ReqHandler.cpp --- src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp index a902a075e..9f5a0cb7a 100644 --- a/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp @@ -429,7 +429,7 @@ void IPClientReqHandler::registerUpdateCallback(updateCallback cb) mUpdateCallback = cb; } -void getIPIfcIDs(int *ifindexes) { +void getIPIfcIDs(unsigned int *ifindexes) { int count = 0; FILE *fp = v_secure_popen("r", "ls /sys/class/net"); if (!fp) { @@ -481,7 +481,7 @@ void IPClientReqHandler::checkForUpdates() sendAddRemoveEvents (mUpdateCallback, interfaceNumberOfEntries, curNumOfIPInterface, objectPath); } - int ifindexes[MAX_IFCS]; + unsigned int ifindexes[MAX_IFCS]; getIPIfcIDs(ifindexes); for (int i = 0; i < interfaceNumberOfEntries && i < MAX_IFCS; i++) { From 4e8c53e7592386bd584e4b528e207b5931aa880b Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 18 Jun 2025 12:18:14 -0400 Subject: [PATCH 081/161] 1.1.9 release changelog updates --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ecc4d1b..259b89151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.1.9](https://github.com/rdkcentral/tr69hostif/compare/1.1.8...1.1.9) + +- RDKTV-36715: Logs flooding issue observed in tr69hostif.log [`#181`](https://github.com/rdkcentral/tr69hostif/pull/181) +- Update hostIf_IPClient_ReqHandler.cpp [`1e6bff6`](https://github.com/rdkcentral/tr69hostif/commit/1e6bff6c3773dbf6665a68ed952f687553fe6cef) +- Merge tag '1.1.8' into develop [`39c4fc6`](https://github.com/rdkcentral/tr69hostif/commit/39c4fc61311cad2a685cb7ac15e9321fdbddc6fe) + #### [1.1.8](https://github.com/rdkcentral/tr69hostif/compare/1.1.7...1.1.8) +> 17 June 2025 + - RDKEMW-4029 Hard stop for tr69hostif service during cleanup [`#175`](https://github.com/rdkcentral/tr69hostif/pull/175) - RDKTV-36715: Logs flooding issue observed in tr69hostif.log "refreshInterfaceName:" [`#176`](https://github.com/rdkcentral/tr69hostif/pull/176) - RDK-49251 [RDK-E] L2 Test In CI Loops For Firewall [`#170`](https://github.com/rdkcentral/tr69hostif/pull/170) @@ -17,9 +25,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - RDKEMW-3656 : tr69hostif Crash in mutex unlock (#156) [`#161`](https://github.com/rdkcentral/tr69hostif/pull/161) - RDKEMW-3656 : tr69hostif Crash in mutex unlock [`#156`](https://github.com/rdkcentral/tr69hostif/pull/156) - RDK-57360 [RDK-E] L2 test framework for tr69hostif - webpa path [`#147`](https://github.com/rdkcentral/tr69hostif/pull/147) +- 1.1.8 release changelog updates [`f762c8b`](https://github.com/rdkcentral/tr69hostif/commit/f762c8b689547f90328af5a628cd3fb4ca627eba) - Update data-model-generic.xml [`84456dd`](https://github.com/rdkcentral/tr69hostif/commit/84456ddcb78733197fc7737796f4053b58ac900c) - Hard stop for tr69hostif service during cleanup [`25a1451`](https://github.com/rdkcentral/tr69hostif/commit/25a14512db9b26453a4e9fd2e97ddf2cb9e36f59) -- Merge tag '1.1.7' into develop [`b734976`](https://github.com/rdkcentral/tr69hostif/commit/b734976d85bdfb3cbc8ab93389fd5cb2ecbf3c58) #### [1.1.7](https://github.com/rdkcentral/tr69hostif/compare/1.1.6...1.1.7) From ec6aab93659a4d1487755f648ecf1b5cf62f0709 Mon Sep 17 00:00:00 2001 From: rdkcmf Date: Tue, 24 Jun 2025 15:06:43 +0100 Subject: [PATCH 082/161] Deploy cla action --- .github/workflows/cla.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/cla.yml diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 000000000..055047932 --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,13 @@ +name: "CLA" +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened,closed,synchronize] + +jobs: + CLA-Lite: + name: "Signature" + uses: rdkcentral/cmf-actions/.github/workflows/cla.yml@main + secrets: + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT }} \ No newline at end of file From 72989a218330d65ee6e1a55fc2f2169fc3c04881 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Fri, 27 Jun 2025 20:37:09 +0530 Subject: [PATCH 083/161] RDK-57649 [RDKE] - TR69HostIf Performance Monitoring and Optimized Logging (#185) * Update Makefile.am * Update configure.ac * Update configure.ac * Update Makefile.am * Update hostIf_msgHandler.cpp * Update hostIf_main.h * Update hostIf_main.cpp * Update hostIf_msgHandler.cpp * Update Makefile.am * Update Makefile.am * Update hostIf_main.h * Update hostIf_main.cpp * Update hostIf_msgHandler.cpp * Update hostIf_msgHandler.cpp * Update Makefile.am * Update Makefile.am * Update Makefile.am * Update Makefile.am * Update hostIf_main.cpp * Update hostIf_main.cpp * Update hostIf_msgHandler.cpp * Update hostIf_utils.h * Update hostIf_main.h * Update hostIf_main.cpp * Update hostIf_main.cpp * Update hostIf_msgHandler.cpp * Update hostIf_msgHandler.cpp * Update hostIf_msgHandler.cpp --- configure.ac | 15 +++ src/Makefile.am | 7 ++ src/configure.ac | 15 +++ src/hostif/handlers/Makefile.am | 8 ++ src/hostif/handlers/src/hostIf_msgHandler.cpp | 102 ++++++++++++++++++ src/hostif/httpserver/Makefile.am | 2 + src/hostif/include/hostIf_main.h | 6 ++ src/hostif/include/hostIf_utils.h | 4 + src/hostif/src/hostIf_main.cpp | 25 ++++- 9 files changed, 182 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2800a2fae..b26ad55ad 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,21 @@ AC_ARG_ENABLE([notification], ], [echo "Notification support is disabled"]) +AC_ARG_ENABLE([t2api], + AS_HELP_STRING([--enable-t2api],[enables telemetry]), + [ + case "${enableval}" in + yes) IS_TELEMETRY2_ENABLED=true + T2_EVENT_FLAG=" -DT2_EVENT_ENABLED ";; + no) IS_TELEMETRY2_ENABLED=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-t2enable]) ;; + esac + ], + [echo "telemetry is disabled"]) +AM_CONDITIONAL([IS_TELEMETRY2_ENABLED], [test x$IS_TELEMETRY2_ENABLED = xtrue]) +AC_SUBST(T2_EVENT_FLAG) + + AC_ARG_ENABLE([rf4ce], AS_HELP_STRING([--enable-rf4ce],[enable X_RDKCENTRAL_COM RF4CE profile (default is no)]), diff --git a/src/Makefile.am b/src/Makefile.am index 6b3453634..7d9de753d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -56,6 +56,8 @@ else NEXUS_LIB = endif + + if WITH_WIFI_PROFILE AM_CXXFLAGS += -DUSE_WIFI_PROFILE AM_CXXFLAGS += -I$(top_srcdir)/src/hostif/profiles/wifi @@ -116,6 +118,11 @@ else AM_LDFLAGS += $(SYSTEMD_SDNOTIFY_LDFLAGS) endif +if IS_TELEMETRY2_ENABLED +AM_CXXFLAGS += $(T2_EVENT_FLAG) +AM_LDFLAGS += -ltelemetry_msgsender -lt2utils +endif + bin_PROGRAMS = tr69hostif backgroundrun tr69hostif_SOURCES = $(top_srcdir)/src/hostif/src/hostIf_main.cpp $(top_srcdir)/src/hostif/src/hostIf_utils.cpp tr69hostif_SOURCES += $(top_srcdir)/src/hostif/src/IniFile.cpp diff --git a/src/configure.ac b/src/configure.ac index fc5a6577a..e704399ee 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -52,6 +52,21 @@ AC_ARG_ENABLE([libsoup3], esac],[libsoup3=false]) AM_CONDITIONAL([LIBSOUP3_ENABLE], [test x$libsoup3 = xtrue]) +AC_ARG_ENABLE([t2api], + AS_HELP_STRING([--enable-t2api],[enables telemetry]), + [ + case "${enableval}" in + yes) IS_TELEMETRY2_ENABLED=true + T2_EVENT_FLAG=" -DT2_EVENT_ENABLED ";; + no) IS_TELEMETRY2_ENABLED=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-t2enable]) ;; + esac + ], + [echo "telemetry is disabled"]) +AM_CONDITIONAL([IS_TELEMETRY2_ENABLED], [test x$IS_TELEMETRY2_ENABLED = xtrue]) +AC_SUBST(T2_EVENT_FLAG) + + # Generate the Makefile AC_CONFIG_FILES([ hostif/parodusClient/gtest/Makefile \ diff --git a/src/hostif/handlers/Makefile.am b/src/hostif/handlers/Makefile.am index 155cae827..687ef8eb5 100644 --- a/src/hostif/handlers/Makefile.am +++ b/src/hostif/handlers/Makefile.am @@ -84,6 +84,8 @@ AM_CXXFLAGS += -DBTMGR_ENABLE_IARM_INTERFACE AM_CXXFLAGS += -I$(top_srcdir)/src/hostif/profiles/DeviceInfo endif + + if WITH_HWSELFTEST_PROFILE AM_CXXFLAGS += $(HWSELFTEST_PROFILE_FLAG) endif @@ -97,6 +99,12 @@ if WIFI_CLIENT_ROAMING AM_CXXFLAGS += -DWIFI_CLIENT_ROAMING endif +if IS_TELEMETRY2_ENABLED +AM_CXXFLAGS += $(T2_EVENT_FLAG) +AM_LDFLAGS += -ltelemetry_msgsender -lt2utils +endif + + noinst_LTLIBRARIES = libMsgHandlers.la libMsgHandlers_la_SOURCES = src/hostIf_IARM_ReqHandler.cpp \ src/hostIf_msgHandler.cpp \ diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index b09db975c..d2d1e3931 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -31,6 +31,8 @@ #include #include +#include +#include #include "hostIf_main.h" #include "hostIf_msgHandler.h" #include "hostIf_utils.h" @@ -71,6 +73,14 @@ static std::mutex get_handler_mutex; static std::mutex set_handler_mutex; static int getCount = 0; static int setCount = 0; +static std::atomic getCountSinceBoot{0}; +static time_t bootTimeSec = 0; +static std::atomic setCountSinceBoot{0}; +static time_t bootTimeSecSet =0; +static std::atomic loggedGet200Within1Min {false}; +static std::atomic loggedGet1000Within5Min {false}; +static std::atomic loggedSet200Within1Min {false}; +static std::atomic loggedSet1000Within5Min {false}; int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { @@ -82,6 +92,40 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,"[%s:%d] GET called %d times\n",__FUNCTION__, __LINE__, getCount); } std::lock_guard lock(get_handler_mutex); + // On first call, record boot time + if (bootTimeSec == 0) { + struct timespec ts; + clock_gettime(CLOCK_BOOTTIME, &ts); + bootTimeSec = ts.tv_sec; + } + getCountSinceBoot++; + + // Calculate seconds since boot + struct timespec now; + clock_gettime(CLOCK_BOOTTIME, &now); + long secondsSinceBoot = now.tv_sec - bootTimeSec; + + // Log if getCount reaches 200 before 1 minute from boot + if ( !loggedGet200Within1Min && getCountSinceBoot >= 200 && secondsSinceBoot <= 60) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s:%d] GET count reached 200 within 1 minute after boot (actual: %ld seconds)\n", + __FUNCTION__, __LINE__, secondsSinceBoot); + #ifdef T2_EVENT_ENABLED + t2CountNotify("TR69HOSTIF_GET_200_WITHIN_1MIN", 1); + #endif + loggedGet200Within1Min = true; + } + + // Log if getCount reaches 1000 before 5 minutes from boot + if ( !loggedGet1000Within5Min && getCountSinceBoot >= 1000 && secondsSinceBoot <= 300) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s:%d] GET count reached 1000 within 5 minutes after boot (actual: %ld seconds)\n", + __FUNCTION__, __LINE__, secondsSinceBoot); + #ifdef T2_EVENT_ENABLED + t2CountNotify("TR69HOSTIF_GET_1000_WITHIN_5MIN", 1); + #endif + loggedGet1000Within5Min =true; + } try { /* Find the respective manager and forward the request*/ @@ -101,7 +145,20 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) stMsgData->paramName, stMsgData->paramValue, timeTaken); + // Telemetry and debug log if processing time > 5 second (1,000,000 us) + if (timeTaken > 5000000) { + // Debug log + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, + "[%s:%d] Slow GET detected: paramName: %s, timeTaken: %lld ms\n", + __FUNCTION__, __LINE__, stMsgData->paramName, timeTaken/1000); + #ifdef T2_EVENT_ENABLED + // Telemetry: report paramName + t2ValNotify("TR69HOSTIF_GET_TIMEOUT_PARAM", stMsgData->paramName); + #endif + + } } + } catch (const std::exception& e) { @@ -122,6 +179,41 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) std::lock_guard lock(set_handler_mutex); RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + if (bootTimeSecSet == 0) { + struct timespec ts; + clock_gettime(CLOCK_BOOTTIME, &ts); + bootTimeSecSet = ts.tv_sec; + } + setCountSinceBoot++; + + // Calculate seconds since boot for SET + struct timespec now; + clock_gettime(CLOCK_BOOTTIME, &now); + long secondsSinceBoot = now.tv_sec - bootTimeSecSet; + + // Log if setCount reaches 200 before 1 minute from boot + if (!loggedSet200Within1Min && setCountSinceBoot >= 200 && secondsSinceBoot <= 60) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s:%d] SET count reached 200 within 1 minute after boot (actual: %ld seconds)\n", + __FUNCTION__, __LINE__, secondsSinceBoot); + #ifdef T2_EVENT_ENABLED + t2CountNotify("TR69HOSTIF_SET_200_WITHIN_1MIN", 1); + #endif + loggedSet200Within1Min = true ; + } + + // Log if setCount reaches 1000 before 5 minutes from boot + if (!loggedSet1000Within5Min && setCountSinceBoot >= 1000 && secondsSinceBoot <= 300) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s:%d] SET count reached 1000 within 5 minutes after boot (actual: %ld seconds)\n", + __FUNCTION__, __LINE__, secondsSinceBoot); + #ifdef T2_EVENT_ENABLED + t2CountNotify("TR69HOSTIF_SET_1000_WITHIN_5MIN", 1); + #endif + loggedSet1000Within5Min = true; + } + + /* Find the respective manager and forward the request*/ msgHandler *pMsgHandler = HostIf_GetMgr(stMsgData); @@ -138,6 +230,16 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) stMsgData->paramName, stMsgData->paramValue, timeTakenset); + // Telemetry and debug log if processing time > 5 seconds (5,000,000 us) + if (timeTakenset > 5000000) { + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, + "[%s:%d] Slow SET detected: paramName: %s, timeTaken: %lld ms\n", + __FUNCTION__, __LINE__, stMsgData->paramName, timeTakenset/1000); + #ifdef T2_EVENT_ENABLED + t2ValNotify("TR69HOSTIF_SET_TIMEOUT_PARAM", stMsgData->paramName); + #endif + + } } RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); diff --git a/src/hostif/httpserver/Makefile.am b/src/hostif/httpserver/Makefile.am index 2fe67f71a..8538515ce 100644 --- a/src/hostif/httpserver/Makefile.am +++ b/src/hostif/httpserver/Makefile.am @@ -45,6 +45,8 @@ else AM_CXXFLAGS += -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/libsoup-2.4 endif + + libhttpserver_la_LIBADD = $(top_builddir)/src/hostif/parodusClient/waldb/libwaldb.la \ $(top_builddir)/src/hostif/handlers/libMsgHandlers.la diff --git a/src/hostif/include/hostIf_main.h b/src/hostif/include/hostIf_main.h index 4b064fade..d615a1a9e 100644 --- a/src/hostif/include/hostIf_main.h +++ b/src/hostif/include/hostIf_main.h @@ -109,6 +109,8 @@ #include #include "rdk_debug.h" + + extern gchar *date_str; typedef enum { @@ -125,6 +127,8 @@ bool filter_and_merge_xml(const char *input1, const char *input2, const char *ou #define G_LOG_DOMAIN ((gchar*) 0) #define LOG_TR69HOSTIF "LOG.RDK.TR69HOSTIF" + + using namespace std; enum { @@ -147,6 +151,8 @@ static volatile sig_atomic_t time_to_quit = 0; void quit_handler (int sig_received); void exit_gracefully (int sig_received); + + void *tr69IfHandlerThread(void *); void *jsonIfHandlerThread(void *); pid_t getTid(); diff --git a/src/hostif/include/hostIf_utils.h b/src/hostif/include/hostIf_utils.h index 2e2e5c1c8..d0b6ad7d2 100755 --- a/src/hostif/include/hostIf_utils.h +++ b/src/hostif/include/hostIf_utils.h @@ -148,6 +148,10 @@ long timeValDiff(struct timespec *starttime, struct timespec *finishtime); void setLegacyRFCEnabled(bool value); bool legacyRFCEnabled(); #endif +#ifdef T2_EVENT_ENABLED +void t2CountNotify(const char *marker, int val); +void t2ValNotify(const char *marker, const char *val); +#endif HostIf_Source_Type_t getBSUpdateEnum(const char *bsUpdate); bool isWebpaReady(); diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index 123567d04..cbcb751a0 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -77,6 +77,10 @@ extern "C" { #include #endif +#ifdef T2_EVENT_ENABLED +#include +#endif + #include "hostIf_rbus_Dml_Provider.h" #include "Device_DeviceInfo.h" #include "safec_lib.h" @@ -186,7 +190,20 @@ bool GetFeatureEnabled(char *cmd) } #endif +/* Description: Use for sending telemetry Log + * @param marker: use for send marker details + * @return : void + * */ +#ifdef T2_EVENT_ENABLED +void t2CountNotify(const char *marker, int val) { + t2_event_d(marker, val); +} +void t2ValNotify( const char *marker, const char *val ) +{ + t2_event_s(marker, val); +} +#endif //------------------------------------------------------------------------------ @@ -292,7 +309,9 @@ int main(int argc, char *argv[]) /* Enable RDK logger.*/ if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; - + #ifdef T2_EVENT_ENABLED + t2_init(const_cast("tr69hostif")); + #endif if (optind < argc) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"non-option ARGV-elements: "); @@ -594,7 +613,9 @@ void exit_gracefully (int sig_received) if(pthread_mutex_trylock(&graceful_exit_mutex) == 0) { RDK_LOG(RDK_LOG_NOTICE,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); isShutdownTriggered = 1; - +#ifdef T2_EVENT_ENABLED + t2_uninit(); +#endif #if defined(USE_WIFI_PROFILE) /* Perform the necessary operations to shut down the WiFi device */ WiFiDevice::shutdown(); From 0e68c7e79ca5b155a93fa1ac6a11db218486504d Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Fri, 27 Jun 2025 11:21:47 -0400 Subject: [PATCH 084/161] 1.2.0 release changelog updates --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259b89151..b14d8315b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.0](https://github.com/rdkcentral/tr69hostif/compare/1.1.9...1.2.0) + +- RDK-57649 [RDKE] - TR69HostIf Performance Monitoring and Optimized Logging [`#185`](https://github.com/rdkcentral/tr69hostif/pull/185) +- Merge tag '1.1.9' into develop [`083a042`](https://github.com/rdkcentral/tr69hostif/commit/083a042ce2eb4bcfc24bf95f24e8f04e897fe7c4) + #### [1.1.9](https://github.com/rdkcentral/tr69hostif/compare/1.1.8...1.1.9) +> 18 June 2025 + - RDKTV-36715: Logs flooding issue observed in tr69hostif.log [`#181`](https://github.com/rdkcentral/tr69hostif/pull/181) +- 1.1.9 release changelog updates [`4e8c53e`](https://github.com/rdkcentral/tr69hostif/commit/4e8c53e7592386bd584e4b528e207b5931aa880b) - Update hostIf_IPClient_ReqHandler.cpp [`1e6bff6`](https://github.com/rdkcentral/tr69hostif/commit/1e6bff6c3773dbf6665a68ed952f687553fe6cef) - Merge tag '1.1.8' into develop [`39c4fc6`](https://github.com/rdkcentral/tr69hostif/commit/39c4fc61311cad2a685cb7ac15e9321fdbddc6fe) From c864f824c9e04f05eb17c2c301231a7e8dd0019b Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 2 Jul 2025 09:10:03 -0400 Subject: [PATCH 085/161] RDK-57867 : Default the IUI layer separation RFC globally for EntOS Signed-off-by: Venkata Bojja --- src/hostif/parodusClient/waldb/data-model/data-model-generic.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 32ed43226..8702609b7 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4415,6 +4415,7 @@ + From cda900d6d35170fcfe0c3ac8382271575eba077b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 10 Jul 2025 12:20:18 +0530 Subject: [PATCH 086/161] Update Device_DeviceInfo.cpp --- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 7e94754e6..222e13acb 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4165,6 +4165,122 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerI return retVal; } +int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(HOSTIF_MsgData_t *stMsgData) +{ + + stMsgData->paramtype = hostIf_StringType; + int retStatus = NOK; + + const char *filename = "/etc/rrd/remote_debugger.json"; + FILE *fp = nullptr; + char *fileBuf = nullptr; + long fileSz = 0; + size_t bytesRead = 0; + cJSON *root = nullptr; + cJSON *filtered = nullptr; + char *outStr = nullptr; + size_t outLen = 0; + + RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, + "[%s] Entering …\n", __FUNCTION__); + + + fp = fopen(filename, "rb"); + if(!fp) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, + "[%s] Cannot open %s\n", __FUNCTION__, filename); + goto CLEAN_UP; + } + + if(fseek(fp, 0L, SEEK_END) != 0) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, + "[%s] fseek failed\n", __FUNCTION__); + goto CLEAN_UP; + } + fileSz = ftell(fp); + rewind(fp); + + fileBuf = (char*)malloc((size_t)fileSz + 1); + if(!fileBuf) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, + "[%s] malloc(%ld) failed\n", __FUNCTION__, fileSz + 1); + goto CLEAN_UP; + } + + bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); + fileBuf[bytesRead] = '\0'; + fclose(fp); fp = nullptr; + + + root = cJSON_Parse(fileBuf); + if(!root) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, + "[%s] JSON parse error: %s\n", + __FUNCTION__, cJSON_GetErrorPtr()); + goto CLEAN_UP; + } + + + filtered = cJSON_CreateObject(); + if(!filtered) + goto CLEAN_UP; + + for(cJSON *top = root->child; top; top = top->next) + { + if(top->type != cJSON_Object) + continue; + + cJSON *arr = cJSON_CreateArray(); + if(!arr) + goto CLEAN_UP; + + for(cJSON *sub = top->child; sub; sub = sub->next) + cJSON_AddItemToArray(arr, cJSON_CreateString(sub->string)); + + if(cJSON_GetArraySize(arr) > 0) + cJSON_AddItemToObject(filtered, top->string, arr); + else + cJSON_Delete(arr); + } + + + outStr = cJSON_PrintUnformatted(filtered); + if(!outStr) + goto CLEAN_UP; + + + outLen = strlen(outStr); + if(outLen >= sizeof(stMsgData->paramValue)) + outLen = sizeof(stMsgData->paramValue) - 1; + + memcpy(stMsgData->paramValue, outStr, outLen); + stMsgData->paramValue[outLen] = '\0'; + stMsgData->paramLen = outLen; + + + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, + "[%s] Extracted profile map: %s\n", __FUNCTION__, outStr); + + retStatus = OK; + +CLEAN_UP: + if(fp) fclose(fp); + if(fileBuf) free(fileBuf); + cJSON_Delete(root); + cJSON_Delete(filtered); + if(outStr) free(outStr); + + RDK_LOG((retStatus == OK) ? RDK_LOG_TRACE1 : RDK_LOG_ERROR, + LOG_TR69HOSTIF, "[%s] Leaving with %s\n", + __FUNCTION__, (retStatus == OK) ? "OK" : "NOK"); + + return retStatus; +} + int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData (HOSTIF_MsgData_t *stMsgData) { char *issueStr = NULL; From e8153cb87fc5cf27b3cbc54e9746526a0cd592ae Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 10 Jul 2025 12:21:30 +0530 Subject: [PATCH 087/161] Update Device_DeviceInfo.h --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index be3597b97..2ebed8e07 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -1227,6 +1227,7 @@ class hostIf_DeviceInfo { int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(HOSTIF_MsgData_t *); int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(HOSTIF_MsgData_t *); + int get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(HOSTIF_MsgData_t *); #endif /* * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable From 255b5d1d38e3c82bcc811e0f5fcb0a0c84ebe07d Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 10 Jul 2025 12:23:47 +0530 Subject: [PATCH 088/161] Update data-model-generic.xml --- .../parodusClient/waldb/data-model/data-model-generic.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 8702609b7..d9f808f0e 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -3543,6 +3543,11 @@ + + + + + From 90ae35d3d17eebe2e66f269d321fabc6c665280b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 10 Jul 2025 12:29:11 +0530 Subject: [PATCH 089/161] Update hostIf_DeviceClient_ReqHandler.cpp --- src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp index afa49102b..00367c28b 100644 --- a/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp @@ -490,6 +490,11 @@ int DeviceClientReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) { ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_BootStatus(stMsgData); } + + else if(strcasecmp(stMsgData->paramName,"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.getProfileData") == 0) + { + ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(stMsgData); + } else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.X_RDKCENTRAL-COM_PreferredGatewayType") == 0) { ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(stMsgData); From 87f6d500544460808cc508b623eb58ae3da4a9fd Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:31:51 +0530 Subject: [PATCH 090/161] Update Device_DeviceInfo.cpp --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 222e13acb..bc5d36507 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4205,11 +4205,14 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg fileBuf = (char*)malloc((size_t)fileSz + 1); if(!fileBuf) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, - "[%s] malloc(%ld) failed\n", __FUNCTION__, fileSz + 1); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] malloc(%ld) failed\n", __FUNCTION__, fileSz + 1); goto CLEAN_UP; } - + if(fileSz < 0 ) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fileSz is being negative, Returning....\n", __FUNCTION__, fileSz + 1); + goto CLEAN_UP; + } bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); fileBuf[bytesRead] = '\0'; fclose(fp); fp = nullptr; From fa1270219c4f78d2adad6c4f9ad38aa5fb907b58 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:55:46 +0530 Subject: [PATCH 091/161] Update Device_DeviceInfo.cpp --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index bc5d36507..5229dffe9 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4210,7 +4210,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg } if(fileSz < 0 ) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fileSz is being negative, Returning....\n", __FUNCTION__, fileSz + 1); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fileSz is being negative, Returning....\n", __FUNCTION__); goto CLEAN_UP; } bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); From 93db3643b74702357a8c664b123213d9d2904138 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 11 Jul 2025 18:16:08 +0530 Subject: [PATCH 092/161] Update Device_DeviceInfo.cpp --- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 58 +++++++------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 5229dffe9..808f1a1cd 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4181,27 +4181,20 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg char *outStr = nullptr; size_t outLen = 0; - RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, - "[%s] Entering …\n", __FUNCTION__); - - + RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__); fp = fopen(filename, "rb"); if(!fp) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, - "[%s] Cannot open %s\n", __FUNCTION__, filename); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Cannot open %s\n", __FUNCTION__, filename); goto CLEAN_UP; } - if(fseek(fp, 0L, SEEK_END) != 0) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, - "[%s] fseek failed\n", __FUNCTION__); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fseek failed\n", __FUNCTION__); goto CLEAN_UP; } fileSz = ftell(fp); rewind(fp); - fileBuf = (char*)malloc((size_t)fileSz + 1); if(!fileBuf) { @@ -4216,58 +4209,54 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); fileBuf[bytesRead] = '\0'; fclose(fp); fp = nullptr; - - root = cJSON_Parse(fileBuf); if(!root) { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, - "[%s] JSON parse error: %s\n", - __FUNCTION__, cJSON_GetErrorPtr()); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] JSON parse error: %s\n", __FUNCTION__, cJSON_GetErrorPtr()); goto CLEAN_UP; } - - filtered = cJSON_CreateObject(); if(!filtered) + { goto CLEAN_UP; - + } for(cJSON *top = root->child; top; top = top->next) { if(top->type != cJSON_Object) - continue; - + { + continue; + } cJSON *arr = cJSON_CreateArray(); if(!arr) + { goto CLEAN_UP; - + } for(cJSON *sub = top->child; sub; sub = sub->next) cJSON_AddItemToArray(arr, cJSON_CreateString(sub->string)); if(cJSON_GetArraySize(arr) > 0) + { cJSON_AddItemToObject(filtered, top->string, arr); + } else - cJSON_Delete(arr); + { + cJSON_Delete(arr); + } } - - outStr = cJSON_PrintUnformatted(filtered); if(!outStr) + { goto CLEAN_UP; - - + } outLen = strlen(outStr); if(outLen >= sizeof(stMsgData->paramValue)) + { outLen = sizeof(stMsgData->paramValue) - 1; - + } memcpy(stMsgData->paramValue, outStr, outLen); stMsgData->paramValue[outLen] = '\0'; stMsgData->paramLen = outLen; - - - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, - "[%s] Extracted profile map: %s\n", __FUNCTION__, outStr); - + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Extracted profile map: %s\n", __FUNCTION__, outStr); retStatus = OK; CLEAN_UP: @@ -4277,10 +4266,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg cJSON_Delete(filtered); if(outStr) free(outStr); - RDK_LOG((retStatus == OK) ? RDK_LOG_TRACE1 : RDK_LOG_ERROR, - LOG_TR69HOSTIF, "[%s] Leaving with %s\n", - __FUNCTION__, (retStatus == OK) ? "OK" : "NOK"); - + RDK_LOG((retStatus == OK) ? RDK_LOG_TRACE1 : RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with %s\n", __FUNCTION__, (retStatus == OK) ? "OK" : "NOK"); return retStatus; } From 33e2b50a19cbbba161675d3f711f2befc1c05562 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 11 Jul 2025 18:17:44 +0530 Subject: [PATCH 093/161] Update Device_DeviceInfo.cpp --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 808f1a1cd..8c2c5ac81 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4232,8 +4232,9 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg goto CLEAN_UP; } for(cJSON *sub = top->child; sub; sub = sub->next) + { cJSON_AddItemToArray(arr, cJSON_CreateString(sub->string)); - + } if(cJSON_GetArraySize(arr) > 0) { cJSON_AddItemToObject(filtered, top->string, arr); From 585597ce6ce541f469588b1ecc5287d345b29151 Mon Sep 17 00:00:00 2001 From: nhanas001c Date: Mon, 14 Jul 2025 18:28:02 +0000 Subject: [PATCH 094/161] RDK-57868 : Default IPControl RFC for EU partners Reason for change: Set default value to IPControl parameters Test Procedure: Verify with tr181 get Risks: Low Priority: P1 --- .../parodusClient/waldb/data-model/data-model-generic.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 8702609b7..015203db1 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -224,13 +224,13 @@ - + - + From 381b3c2cba32cf43e1b32489fc06a9daa7b9465c Mon Sep 17 00:00:00 2001 From: nhanas001c Date: Fri, 18 Jul 2025 19:31:39 +0000 Subject: [PATCH 095/161] RDK-58526 : Default IPControl RFC for EU partners Reason for change: Set default value to Apps parameters Test Procedure: Verify with tr181 get Risks: Low Priority: P1 --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 015203db1..593757a19 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -511,6 +511,14 @@ + + + + + + + + From fe9e71f712ffef234215145461d767ae7d1691a4 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Fri, 18 Jul 2025 16:04:05 -0400 Subject: [PATCH 096/161] 1.2.1 release changelog updates --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b14d8315b..98e67ffa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.1](https://github.com/rdkcentral/tr69hostif/compare/1.2.0...1.2.1) + +- RDK-58526 : Default IPControl RFC for EU partners [`#203`](https://github.com/rdkcentral/tr69hostif/pull/203) +- RDK-57868 : Default IPControl RFC for EU partners [`#200`](https://github.com/rdkcentral/tr69hostif/pull/200) +- RDK-57867 : Default the IUI layer separation RFC globally for EntOS [`#193`](https://github.com/rdkcentral/tr69hostif/pull/193) +- Merge tag '1.2.0' into develop [`9b98df0`](https://github.com/rdkcentral/tr69hostif/commit/9b98df0330008138a47b6f18a4314df6f0a7adc1) + #### [1.2.0](https://github.com/rdkcentral/tr69hostif/compare/1.1.9...1.2.0) +> 27 June 2025 + - RDK-57649 [RDKE] - TR69HostIf Performance Monitoring and Optimized Logging [`#185`](https://github.com/rdkcentral/tr69hostif/pull/185) +- 1.2.0 release changelog updates [`0e68c7e`](https://github.com/rdkcentral/tr69hostif/commit/0e68c7e79ca5b155a93fa1ac6a11db218486504d) - Merge tag '1.1.9' into develop [`083a042`](https://github.com/rdkcentral/tr69hostif/commit/083a042ce2eb4bcfc24bf95f24e8f04e897fe7c4) #### [1.1.9](https://github.com/rdkcentral/tr69hostif/compare/1.1.8...1.1.9) From 5441b702ad40eb9523499670b9254ea3fcbda0cc Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:25:34 +0530 Subject: [PATCH 097/161] Update Device_DeviceInfo.cpp --- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 8c2c5ac81..21a36d69b 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4165,6 +4165,124 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerI return retVal; } +int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(HOSTIF_MsgData_t *stMsgData) +{ + stMsgData->paramtype = hostIf_StringType; + int retStatus = NOK; + + const char *filename = "/etc/rrd/remote_debugger.json"; + FILE *fp = nullptr; + char *fileBuf = nullptr; + long fileSz = 0; + size_t bytesRead = 0; + cJSON *root = nullptr; + cJSON *filtered = nullptr; + char *outStr = nullptr; + size_t outLen = 0; + + RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__); + + fp = fopen(filename, "rb"); + if (!fp) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Cannot open %s\n", __FUNCTION__, filename); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + if (fseek(fp, 0L, SEEK_END) != 0) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fseek failed\n", __FUNCTION__); + fclose(fp); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + fileSz = ftell(fp); + rewind(fp); + if (fileSz < 0) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fileSz is negative, Returning....\n", __FUNCTION__); + fclose(fp); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + fileBuf = (char*)malloc((size_t)fileSz + 1); + if (!fileBuf) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] malloc(%ld) failed\n", __FUNCTION__, fileSz + 1); + fclose(fp); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); + fileBuf[bytesRead] = '\0'; + fclose(fp); fp = nullptr; + + root = cJSON_Parse(fileBuf); + if (!root) { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] JSON parse error: %s\n", __FUNCTION__, cJSON_GetErrorPtr()); + free(fileBuf); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + filtered = cJSON_CreateObject(); + if (!filtered) { + free(fileBuf); + cJSON_Delete(root); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + for (cJSON *top = root->child; top; top = top->next) { + if (top->type != cJSON_Object) { + continue; + } + cJSON *arr = cJSON_CreateArray(); + if (!arr) { + free(fileBuf); + cJSON_Delete(root); + cJSON_Delete(filtered); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + for (cJSON *sub = top->child; sub; sub = sub->next) { + cJSON_AddItemToArray(arr, cJSON_CreateString(sub->string)); + } + if (cJSON_GetArraySize(arr) > 0) { + cJSON_AddItemToObject(filtered, top->string, arr); + } else { + cJSON_Delete(arr); + } + } + + outStr = cJSON_PrintUnformatted(filtered); + if (!outStr) { + free(fileBuf); + cJSON_Delete(root); + cJSON_Delete(filtered); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); + return retStatus; + } + + outLen = strlen(outStr); + if (outLen >= sizeof(stMsgData->paramValue)) { + outLen = sizeof(stMsgData->paramValue) - 1; + } + memcpy(stMsgData->paramValue, outStr, outLen); + stMsgData->paramValue[outLen] = '\0'; + stMsgData->paramLen = outLen; + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Extracted profile map: %s\n", __FUNCTION__, outStr); + retStatus = OK; + + free(fileBuf); + cJSON_Delete(root); + cJSON_Delete(filtered); + free(outStr); + + RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Leaving with OK\n", __FUNCTION__); + return retStatus; +} +/* int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(HOSTIF_MsgData_t *stMsgData) { @@ -4331,6 +4449,7 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerW return retVal; } +*/ #endif int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(HOSTIF_MsgData_t *stMsgData) From 2588fdc79263f7aad9f4df7db3e7c471d5cf6e50 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Tue, 22 Jul 2025 15:22:28 -0400 Subject: [PATCH 098/161] RDK-58323: Canary firmware updates (#199) * Update Makefile.am * Update hostIf_XREClient_ReqHandler.h * Update hostIf_XREClient_ReqHandler.cpp * Update data-model-generic.xml * Update Device_DeviceInfo.h * Update Device_DeviceInfo.cpp * Update hostIf_XREClient_ReqHandler.cpp * Add backgroundrun call for rdk-e * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update hostIf_XREClient_ReqHandler.cpp * Update hostIf_XREClient_ReqHandler.cpp --- src/hostif/handlers/Makefile.am | 2 +- .../include/hostIf_XREClient_ReqHandler.h | 3 ++ .../src/hostIf_XREClient_ReqHandler.cpp | 48 +++++++++++++++++++ .../waldb/data-model/data-model-generic.xml | 12 +++++ .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 34 +++++++++++++ .../profiles/DeviceInfo/Device_DeviceInfo.h | 21 ++++++++ 6 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/hostif/handlers/Makefile.am b/src/hostif/handlers/Makefile.am index 687ef8eb5..bdb7fbf5b 100644 --- a/src/hostif/handlers/Makefile.am +++ b/src/hostif/handlers/Makefile.am @@ -94,7 +94,7 @@ if WITH_SNMP_ADAPTER AM_CXXFLAGS += -DSNMP_ADAPTER_ENABLED -I$(top_srcdir)/src/hostif/snmpAdapter endif -AM_LDFLAGS = $(GLIB_LIBS) $(G_THREAD_LIBS) $(SOUP_LIBS) $(PROCPS_LIBS) -lIARMBus -lyajl -lds -ldshalcli -ldbus-1 +AM_LDFLAGS = $(GLIB_LIBS) $(G_THREAD_LIBS) $(SOUP_LIBS) $(PROCPS_LIBS) -lIARMBus -lyajl -lds -ldshalcli -ldbus-1 -lsecure_wrapper if WIFI_CLIENT_ROAMING AM_CXXFLAGS += -DWIFI_CLIENT_ROAMING endif diff --git a/src/hostif/handlers/include/hostIf_XREClient_ReqHandler.h b/src/hostif/handlers/include/hostIf_XREClient_ReqHandler.h index 64f922c2f..2f4cb38c0 100755 --- a/src/hostif/handlers/include/hostIf_XREClient_ReqHandler.h +++ b/src/hostif/handlers/include/hostIf_XREClient_ReqHandler.h @@ -50,6 +50,7 @@ #include "hostIf_msgHandler.h" #include "hostIf_updateHandler.h" #include "hostIf_main.h" +#include "secure_wrapper.h" /** * @brief This class provides the interface for getting XRE request handler information. @@ -78,6 +79,8 @@ class XREClientReqHandler : public msgHandler static msgHandler* getInstance(); }; +int set_Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow(HOSTIF_MsgData_t *stMsgData); +int get_Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow(HOSTIF_MsgData_t *stMsgData); #endif /* HOSTIF_XRECLIENT_REQHANDLER_H_ */ /* End of HOSTIF_XRECLIENT_REQHANDLER_H_ doxygen group */ /** diff --git a/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp index e4add2545..0c5ee286d 100644 --- a/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp @@ -45,6 +45,8 @@ updateCallback XREClientReqHandler::mUpdateCallback = NULL; GMutex XREClientReqHandler::m_mutex; int XREClientReqHandler::numOfEntries = 0; +#define XCONF_CHECKNOW_SCRIPT_CMD "backgroundrun /usr/bin/rdkvfwupgrader 0 3 >> /opt/logs/swupdate.log" + msgHandler* XREClientReqHandler::getInstance() { @@ -199,6 +201,10 @@ int XREClientReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) { ret = get_Device_X_COMCAST_COM_Xcalibur_Client_XRE_xreEnable(stMsgData); } + else if(strcasecmp(stMsgData->paramName,"Device.X_COMCAST-COM_Xcalibur.Client.xconfCheckNow") == 0) + { + ret = get_Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow(stMsgData); + } else if(strcasecmp(stMsgData->paramName,"Device.X_COMCAST-COM_Xcalibur.Client.XRE.xreStatus") == 0) { ret = get_Device_X_COMCAST_COM_Xcalibur_Client_XRE_xreStatus(stMsgData); @@ -469,6 +475,48 @@ void XREClientReqHandler::registerUpdateCallback(updateCallback cb) mUpdateCallback = cb; } +int set_Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow(HOSTIF_MsgData_t *stMsgData) +{ + FILE *file = fopen("/tmp/xconfchecknow_val", "w"); + if (file == NULL) { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: Error opening file for write.\n",__FILE__,__FUNCTION__,__LINE__); + return NOK; + } + fprintf(file, "%s", stMsgData->paramValue); + fclose(file); + if(0 == strncasecmp("TRUE",stMsgData->paramValue ,strlen("TRUE")) || 0 == strncasecmp("CANARY",stMsgData->paramValue ,strlen("CANARY"))) + { + /*On setting xconfCheckNow,results the device to connect with the XCONF server + for the purpose of firmware and configuration checks.*/ + if(-1 == v_secure_system(XCONF_CHECKNOW_SCRIPT_CMD)) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: Running checkNow script failed.\n",__FILE__,__FUNCTION__,__LINE__); + + return NOK; + } + + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: CheckNow Running... \n",__FILE__,__FUNCTION__,__LINE__); + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: \"%s\" Invalid Input. Valid Input is \"TRUE\" \n",__FILE__,__FUNCTION__,__LINE__,stMsgData->paramValue); + return NOK; + } + return OK; +} + +int get_Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow(HOSTIF_MsgData_t *stMsgData) +{ + FILE *file = fopen("/tmp/xconfchecknow_val", "r"); + if (file == NULL) { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: Error opening file for read.\n",__FILE__,__FUNCTION__,__LINE__); + return NOK; + } + fscanf(file, "%9s", stMsgData->paramValue); + fclose(file); + return OK; +} + void XREClientReqHandler::checkForUpdates() { HOSTIF_MsgData_t msgData; diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 593757a19..7a0d81180 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -3562,6 +3562,18 @@ + + + + + + + + + + + + diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 7e94754e6..48e2323b0 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -3904,6 +3904,14 @@ int hostIf_DeviceInfo::set_xRDKCentralComRFC(HOSTIF_MsgData_t * stMsgData) ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(stMsgData); } #endif + else if (strcasecmp(stMsgData->paramName,CANARY_START_TIME) == 0) + { + ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpStart(stMsgData); + } + else if (strcasecmp(stMsgData->paramName,CANARY_END_TIME) == 0) + { + ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd(stMsgData); + } else if (strcasecmp(stMsgData->paramName,RDK_REBOOTSTOP_ENABLE) == 0) { ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(stMsgData); @@ -4227,6 +4235,32 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerW } #endif +int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpStart (HOSTIF_MsgData_t *stMsgData) +{ + int startTime = 0; + int retVal = NOK; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__); + startTime = atoi(stMsgData->paramValue); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] Start Time Value is %d \n",__FUNCTION__, startTime); + retVal = OK; + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__); + return retVal; +} + +int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd (HOSTIF_MsgData_t *stMsgData) +{ + int endTime = 0; + int retVal = NOK; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__); + endTime = atoi(stMsgData->paramValue); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s] End Time Value is %d \n",__FUNCTION__, endTime); + retVal = OK; + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Exiting... \n",__FUNCTION__); + return retVal; +} + int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(HOSTIF_MsgData_t *stMsgData) { int ret = NOK; diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index be3597b97..60f10be50 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -192,6 +192,10 @@ #define RDK_REBOOTSTOP_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.Enable" #define APPARMOR_BLOCKLIST_PROCESS "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonRootSupport.ApparmorBlocklist" +/* Profile: X_RDKCENTRAL-COM_RFC.Canary */ +#define CANARY_START_TIME "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart" +#define CANARY_END_TIME "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd" + /** * @brief This class provides the interface for getting device information. * @ingroup TR69_HOSTIF_DEVICEINFO_CLASSES @@ -1228,6 +1232,23 @@ class hostIf_DeviceInfo { int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(HOSTIF_MsgData_t *); int set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(HOSTIF_MsgData_t *); #endif + + /* + * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_CanaryStartTime, set_Device_DeviceInfo_X_RDKCENTRAL_COM_CanaryEndTime, set_Device_DeviceInfo_X_RDKCENTRAL_COM_CanaryExtendTime + * + * This method is to get the Issuetype from QA. + * with following TR-069 definition: + * Parameter Name: Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart, + * Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd, + * Data type: String - Arguments Start/End Time + * + * @retval OK if it is successful. + * @retval NOK if operation fails. + */ + + int set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpStart(HOSTIF_MsgData_t *); + int set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd(HOSTIF_MsgData_t *); + /* * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable * From dc2505e06fca126353534a41c566625b4a30d850 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 25 Jul 2025 11:24:58 +0530 Subject: [PATCH 099/161] Update Device_DeviceInfo.cpp --- src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 21a36d69b..f92304be5 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4388,7 +4388,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg RDK_LOG((retStatus == OK) ? RDK_LOG_TRACE1 : RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with %s\n", __FUNCTION__, (retStatus == OK) ? "OK" : "NOK"); return retStatus; } - +*/ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData (HOSTIF_MsgData_t *stMsgData) { char *issueStr = NULL; @@ -4449,7 +4449,6 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerW return retVal; } -*/ #endif int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(HOSTIF_MsgData_t *stMsgData) From 5502c0c13c3f8687c172739ee852dd527e1afc34 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:14:13 +0530 Subject: [PATCH 100/161] Update Device_DeviceInfo.cpp --- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 106 ------------------ 1 file changed, 106 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index f92304be5..e61796c8e 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4282,113 +4282,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Leaving with OK\n", __FUNCTION__); return retStatus; } -/* -int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(HOSTIF_MsgData_t *stMsgData) -{ - - stMsgData->paramtype = hostIf_StringType; - int retStatus = NOK; - - const char *filename = "/etc/rrd/remote_debugger.json"; - FILE *fp = nullptr; - char *fileBuf = nullptr; - long fileSz = 0; - size_t bytesRead = 0; - cJSON *root = nullptr; - cJSON *filtered = nullptr; - char *outStr = nullptr; - size_t outLen = 0; - - RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__); - fp = fopen(filename, "rb"); - if(!fp) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Cannot open %s\n", __FUNCTION__, filename); - goto CLEAN_UP; - } - if(fseek(fp, 0L, SEEK_END) != 0) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fseek failed\n", __FUNCTION__); - goto CLEAN_UP; - } - fileSz = ftell(fp); - rewind(fp); - fileBuf = (char*)malloc((size_t)fileSz + 1); - if(!fileBuf) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] malloc(%ld) failed\n", __FUNCTION__, fileSz + 1); - goto CLEAN_UP; - } - if(fileSz < 0 ) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fileSz is being negative, Returning....\n", __FUNCTION__); - goto CLEAN_UP; - } - bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); - fileBuf[bytesRead] = '\0'; - fclose(fp); fp = nullptr; - root = cJSON_Parse(fileBuf); - if(!root) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] JSON parse error: %s\n", __FUNCTION__, cJSON_GetErrorPtr()); - goto CLEAN_UP; - } - filtered = cJSON_CreateObject(); - if(!filtered) - { - goto CLEAN_UP; - } - for(cJSON *top = root->child; top; top = top->next) - { - if(top->type != cJSON_Object) - { - continue; - } - cJSON *arr = cJSON_CreateArray(); - if(!arr) - { - goto CLEAN_UP; - } - for(cJSON *sub = top->child; sub; sub = sub->next) - { - cJSON_AddItemToArray(arr, cJSON_CreateString(sub->string)); - } - if(cJSON_GetArraySize(arr) > 0) - { - cJSON_AddItemToObject(filtered, top->string, arr); - } - else - { - cJSON_Delete(arr); - } - } - outStr = cJSON_PrintUnformatted(filtered); - if(!outStr) - { - goto CLEAN_UP; - } - outLen = strlen(outStr); - if(outLen >= sizeof(stMsgData->paramValue)) - { - outLen = sizeof(stMsgData->paramValue) - 1; - } - memcpy(stMsgData->paramValue, outStr, outLen); - stMsgData->paramValue[outLen] = '\0'; - stMsgData->paramLen = outLen; - RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Extracted profile map: %s\n", __FUNCTION__, outStr); - retStatus = OK; - -CLEAN_UP: - if(fp) fclose(fp); - if(fileBuf) free(fileBuf); - cJSON_Delete(root); - cJSON_Delete(filtered); - if(outStr) free(outStr); - RDK_LOG((retStatus == OK) ? RDK_LOG_TRACE1 : RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with %s\n", __FUNCTION__, (retStatus == OK) ? "OK" : "NOK"); - return retStatus; -} -*/ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData (HOSTIF_MsgData_t *stMsgData) { char *issueStr = NULL; From 4104dc5c20319987f6c7e811c60fae6793bc92b9 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:18:09 +0530 Subject: [PATCH 101/161] Update Device_DeviceInfo.cpp --- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index e61796c8e..28dd3716e 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -4169,7 +4169,6 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg { stMsgData->paramtype = hostIf_StringType; int retStatus = NOK; - const char *filename = "/etc/rrd/remote_debugger.json"; FILE *fp = nullptr; char *fileBuf = nullptr; @@ -4179,93 +4178,99 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg cJSON *filtered = nullptr; char *outStr = nullptr; size_t outLen = 0; - RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__); - fp = fopen(filename, "rb"); - if (!fp) { + if (!fp) + { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Cannot open %s\n", __FUNCTION__, filename); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - - if (fseek(fp, 0L, SEEK_END) != 0) { + if (fseek(fp, 0L, SEEK_END) != 0) + { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fseek failed\n", __FUNCTION__); fclose(fp); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - fileSz = ftell(fp); rewind(fp); - if (fileSz < 0) { + if (fileSz < 0) + { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fileSz is negative, Returning....\n", __FUNCTION__); fclose(fp); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - fileBuf = (char*)malloc((size_t)fileSz + 1); - if (!fileBuf) { + if (!fileBuf) + { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] malloc(%ld) failed\n", __FUNCTION__, fileSz + 1); fclose(fp); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); fileBuf[bytesRead] = '\0'; fclose(fp); fp = nullptr; - root = cJSON_Parse(fileBuf); - if (!root) { + if (!root) + { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] JSON parse error: %s\n", __FUNCTION__, cJSON_GetErrorPtr()); free(fileBuf); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - filtered = cJSON_CreateObject(); - if (!filtered) { + if (!filtered) + { free(fileBuf); cJSON_Delete(root); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - for (cJSON *top = root->child; top; top = top->next) { - if (top->type != cJSON_Object) { + for (cJSON *top = root->child; top; top = top->next) + { + if (top->type != cJSON_Object) + { continue; } cJSON *arr = cJSON_CreateArray(); - if (!arr) { + if (!arr) + { free(fileBuf); cJSON_Delete(root); cJSON_Delete(filtered); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - for (cJSON *sub = top->child; sub; sub = sub->next) { + for (cJSON *sub = top->child; sub; sub = sub->next) + { cJSON_AddItemToArray(arr, cJSON_CreateString(sub->string)); } - if (cJSON_GetArraySize(arr) > 0) { + if (cJSON_GetArraySize(arr) > 0) + { cJSON_AddItemToObject(filtered, top->string, arr); - } else { + } + else + { cJSON_Delete(arr); } } outStr = cJSON_PrintUnformatted(filtered); - if (!outStr) { + if (!outStr) + { free(fileBuf); cJSON_Delete(root); cJSON_Delete(filtered); RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Leaving with NOK\n", __FUNCTION__); return retStatus; } - outLen = strlen(outStr); - if (outLen >= sizeof(stMsgData->paramValue)) { + if (outLen >= sizeof(stMsgData->paramValue)) + { outLen = sizeof(stMsgData->paramValue) - 1; } memcpy(stMsgData->paramValue, outStr, outLen); @@ -4273,12 +4278,10 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerg stMsgData->paramLen = outLen; RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Extracted profile map: %s\n", __FUNCTION__, outStr); retStatus = OK; - free(fileBuf); cJSON_Delete(root); cJSON_Delete(filtered); free(outStr); - RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Leaving with OK\n", __FUNCTION__); return retStatus; } From 839d68bd1f159f79ddcaf82f559e0bae2417baef Mon Sep 17 00:00:00 2001 From: tpaul627 <69359527+tpaul627@users.noreply.github.com> Date: Fri, 25 Jul 2025 20:13:14 +0530 Subject: [PATCH 102/161] RDKEMW-6328: set AVHijack rfc to false (#208) --- .../parodusClient/waldb/data-model/data-model-generic.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 7a0d81180..e3c9469fb 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4345,7 +4345,7 @@ - + From c1760d3fc35655603c7fea45f86421149cbc8659 Mon Sep 17 00:00:00 2001 From: madhubabutt <114217841+madhubabutt@users.noreply.github.com> Date: Tue, 29 Jul 2025 20:00:52 +0530 Subject: [PATCH 103/161] RDKEMW-6193 Code Coverage support for tr69hostif (#211) Co-authored-by: mtirum011 --- .github/workflows/code-coverage.yml | 52 +++++++++++++++++++++++ run_ut.sh | 28 ++++++++---- src/unittest/stubs/ds/audioOutputPort.hpp | 2 +- src/unittest/stubs/ds/host.hpp | 2 +- 4 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 000000000..2e29b0b79 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,52 @@ +name: Code Coverage + +on: + pull_request: + branches: [ main ] + +jobs: + execute-unit-code-coverage-report-on-release: + name: Test coverage report for release + runs-on: ubuntu-latest + container: + image: ghcr.io/rdkcentral/docker-rdk-ci:latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run unit tests with coverage flags enabled + run: | + sh run_ut.sh --enable-cov + - name: Caculate the code coverage summary + run: | + lcov --list tr69hostif_coverage.info | grep "Lines\|Total" > /tmp/coverage_summary.txt + cd - + + - name: Update the coverage report to Pull request using actions + uses: actions/github-script@v4 + with: + script: | + const fs = require('fs'); + const lcov_result = fs.readFileSync('/tmp/coverage_summary.txt', 'utf8'); + + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: + '## Code Coverage Summary \n' + + ' ' + + '```' + + lcov_result + + '```' + }); + - name: Generate the html report + run: | + genhtml tr69hostif_coverage.info --output-directory /tmp/coverage_report + cd - + - name: Upload the coverage report to Pull request using actions + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: /tmp/coverage_report diff --git a/run_ut.sh b/run_ut.sh index c6143381c..92abdfec0 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -18,6 +18,17 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################################ + +ENABLE_COV=false + +if [ "x$1" = "x--enable-cov" ]; then + echo "Enabling coverage options" + export CXXFLAGS="-g -O0 -fprofile-arcs -ftest-coverage" + export CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage" + export LDFLAGS="-lgcov --coverage" + ENABLE_COV=true +fi + apt-get update apt-get -y install libtinyxml2-dev apt-get -y install libsoup-3.0-dev @@ -57,12 +68,6 @@ make ./dm_gtest echo "********************" - -lcov --capture --directory . --output-file coverage.info -lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info -genhtml coverage.filtered.info --output-directory out - - echo "**** Compiling DeviceInfo gtest ****" cd $TOP_DIR/src/hostif/profiles/DeviceInfo/gtest rm devieInfo_gtest @@ -70,7 +75,12 @@ make ./devieInfo_gtest echo "********************" +cd $TOP_DIR -lcov --capture --directory . --output-file coverage.info -lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info -genhtml coverage.filtered.info --output-directory out +if [ "$ENABLE_COV" = true ]; then + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info '/usr/*' '*/gtest/*' '*/mocks/*' --output-file filtered.info + lcov --extract filtered.info '*/src/hostif*' --output-file tr69hostif_coverage.info + lcov --list tr69hostif_coverage.info +fi + diff --git a/src/unittest/stubs/ds/audioOutputPort.hpp b/src/unittest/stubs/ds/audioOutputPort.hpp index 073740291..2821f7ad7 100644 --- a/src/unittest/stubs/ds/audioOutputPort.hpp +++ b/src/unittest/stubs/ds/audioOutputPort.hpp @@ -173,7 +173,7 @@ class AudioOutputPort : public Enumerable { void setSAD(std::vector sad_list); void enableARC(dsAudioARCTypes_t type, bool enable); void enableMS12Config(const dsMS12FEATURE_t feature,const bool enable){} - dsError_t enableLEConfig(const bool enable); + dsError_t enableLEConfig(const bool enable) { return dsERR_NONE; }; bool GetLEConfig(); void setAudioDelay(const uint32_t audioDelayMs); void setAudioDelayOffset(const uint32_t audioDelayOffsetMs); diff --git a/src/unittest/stubs/ds/host.hpp b/src/unittest/stubs/ds/host.hpp index a18c55f71..95ed08b3f 100644 --- a/src/unittest/stubs/ds/host.hpp +++ b/src/unittest/stubs/ds/host.hpp @@ -83,7 +83,7 @@ class Host { AudioOutputPort &getAudioOutputPort(const std::string &name){}; AudioOutputPort &getAudioOutputPort(int id){}; void notifyPowerChange(const int mode); - float getCPUTemperature(); + float getCPUTemperature() { return 42.5f; }; uint32_t getVersion(void); void setVersion(uint32_t versionNumber); void getHostEDID(std::vector &edid) const; From d3eda5205f0cb00c7ab8bbcccb70a31a7ce29a45 Mon Sep 17 00:00:00 2001 From: shibu-kv Date: Tue, 29 Jul 2025 09:02:34 -0700 Subject: [PATCH 104/161] Changelog updates for release 1.2.2 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e67ffa2..76809d9ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.2](https://github.com/rdkcentral/tr69hostif/compare/1.2.1...1.2.2) + +- RDKEMW-6193 Code Coverage support for tr69hostif [`#211`](https://github.com/rdkcentral/tr69hostif/pull/211) +- RDKEMW-6328: set AVHijack rfc to false [`#208`](https://github.com/rdkcentral/tr69hostif/pull/208) +- RDK-58323: Canary firmware updates [`#199`](https://github.com/rdkcentral/tr69hostif/pull/199) +- Merge tag '1.2.1' into develop [`17d019b`](https://github.com/rdkcentral/tr69hostif/commit/17d019b0bed5e8cc9c1f4fe68520c08fc530ff00) + #### [1.2.1](https://github.com/rdkcentral/tr69hostif/compare/1.2.0...1.2.1) +> 18 July 2025 + - RDK-58526 : Default IPControl RFC for EU partners [`#203`](https://github.com/rdkcentral/tr69hostif/pull/203) - RDK-57868 : Default IPControl RFC for EU partners [`#200`](https://github.com/rdkcentral/tr69hostif/pull/200) - RDK-57867 : Default the IUI layer separation RFC globally for EntOS [`#193`](https://github.com/rdkcentral/tr69hostif/pull/193) +- 1.2.1 release changelog updates [`fe9e71f`](https://github.com/rdkcentral/tr69hostif/commit/fe9e71f712ffef234215145461d767ae7d1691a4) - Merge tag '1.2.0' into develop [`9b98df0`](https://github.com/rdkcentral/tr69hostif/commit/9b98df0330008138a47b6f18a4314df6f0a7adc1) #### [1.2.0](https://github.com/rdkcentral/tr69hostif/compare/1.1.9...1.2.0) From 5916d051062aa0ba792685d21259342ca4a89a5c Mon Sep 17 00:00:00 2001 From: nmuthu523 Date: Wed, 30 Jul 2025 14:52:25 +0000 Subject: [PATCH 105/161] RDKEMW-4344 : Include the missed RFCs in RDKE. Reason for change: Include DebugMode and TR069support RFC's with default valuse as false. Priority: P1 Test Procedure: Follow the steps provided in description. Risks: Low Signed-off-by:Natraj Muthusamy --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 ++++++++ .../parodusClient/waldb/data-model/data-model-stb.xml | 8 ++++++++ .../parodusClient/waldb/data-model/data-model-tv.xml | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index e3c9469fb..e97e68f0e 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -342,6 +342,14 @@ + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml index 6ab3a6bf8..ede3d12ff 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml @@ -461,6 +461,14 @@ + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml index 96c2790d9..bffa5bc07 100644 --- a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml @@ -367,6 +367,14 @@ + + + + + + + + From 61a1355641b0ca47ae0d24b65f6a66b80210a9d5 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Fri, 1 Aug 2025 14:18:33 +0530 Subject: [PATCH 106/161] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 81 ++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index d2d1e3931..803c1de7f 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -137,13 +137,51 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) ret = pMsgHandler->handleGetMsg(stMsgData); auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); + char paramValueStr[128] = {0}; + switch (stMsgData->paramtype) { + case hostIf_StringType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_IntegerType: { + int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); + break; + } + case hostIf_UnsignedIntType: { + unsigned int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); + break; + } + case hostIf_BooleanType: { + bool val = false; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); + break; + } + case hostIf_DateTimeType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_UnsignedLongType: { + unsigned long val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); + break; + } + default: + snprintf(paramValueStr, sizeof(paramValueStr), ""); + break; + } + + // Calculate time taken in microseconds RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", __FUNCTION__, __LINE__, ret, stMsgData->paramName, - stMsgData->paramValue, + paramValueStr, timeTaken); // Telemetry and debug log if processing time > 5 second (1,000,000 us) if (timeTaken > 5000000) { @@ -224,11 +262,50 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto endTime = std::chrono::high_resolution_clock::now(); auto timeTakenset = std::chrono::duration_cast(endTime - startTime).count(); + char paramValueStr[128] = {0}; + switch (stMsgData->paramtype) { + case hostIf_StringType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_IntegerType: { + int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); + break; + } + case hostIf_UnsignedIntType: { + unsigned int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); + break; + } + case hostIf_BooleanType: { + bool val = false; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); + break; + } + case hostIf_DateTimeType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_UnsignedLongType: { + unsigned long val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); + break; + } + default: + snprintf(paramValueStr, sizeof(paramValueStr), ""); + break; + } + + + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", __FUNCTION__, __LINE__, ret, stMsgData->paramName, - stMsgData->paramValue, + paramValueStr, timeTakenset); // Telemetry and debug log if processing time > 5 seconds (5,000,000 us) if (timeTakenset > 5000000) { From 49c85aa9151b4d926bfa60fa66dc54889d265679 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Mon, 4 Aug 2025 12:36:21 -0400 Subject: [PATCH 107/161] RDKEMW-6520: tr69hostif service starts before iarmbusd --- tr69hostif.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tr69hostif.service b/tr69hostif.service index 3a256e0d3..946b03e33 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -18,7 +18,7 @@ ########################################################################## [Unit] Description=TR69 Host Interface Daemon -After=lighttpd.service securemount.service +After=lighttpd.service securemount.service iarmbusd.service [Service] Type=notify From e1aff4bdcf2cb24d0d53f80ed82045ac8192de7e Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Tue, 5 Aug 2025 13:29:18 +0530 Subject: [PATCH 108/161] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 803c1de7f..6b31bcdd1 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -140,7 +140,7 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) char paramValueStr[128] = {0}; switch (stMsgData->paramtype) { case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_IntegerType: { int val = 0; @@ -161,7 +161,7 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) break; } case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_UnsignedLongType: { unsigned long val = 0; From 0f467d83d0f7e116874c7694713dfd7332187cb8 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Tue, 5 Aug 2025 14:43:21 +0530 Subject: [PATCH 109/161] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 6b31bcdd1..7319f4e6d 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -265,7 +265,7 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) char paramValueStr[128] = {0}; switch (stMsgData->paramtype) { case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_IntegerType: { int val = 0; @@ -286,7 +286,7 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) break; } case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_UnsignedLongType: { unsigned long val = 0; From b273a3a8f9cb9a3d570fcbc20a09b7ca97c88daf Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Wed, 6 Aug 2025 12:38:45 +0530 Subject: [PATCH 110/161] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 7319f4e6d..e3a5a06f7 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -82,6 +82,8 @@ static std::atomic loggedGet1000Within5Min {false}; static std::atomic loggedSet200Within1Min {false}; static std::atomic loggedSet1000Within5Min {false}; +#define PARAM_VALUE_STR_SIZE 128 + int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -137,40 +139,42 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) ret = pMsgHandler->handleGetMsg(stMsgData); auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); - char paramValueStr[128] = {0}; + char paramValueStr[PARAM_VALUE_STR_SIZE] = {0}; switch (stMsgData->paramtype) { case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); + //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_IntegerType: { int val = 0; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%d", val); break; } case hostIf_UnsignedIntType: { unsigned int val = 0; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%u", val); break; } case hostIf_BooleanType: { bool val = false; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", val ? "true" : "false"); break; } case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); + //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); break; case hostIf_UnsignedLongType: { unsigned long val = 0; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%lu", val); break; } default: - snprintf(paramValueStr, sizeof(paramValueStr), ""); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, ""); break; } From 6844bc988ecb174f2c01f3ed6ba54105cb0f0ac3 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 7 Aug 2025 16:00:26 +0530 Subject: [PATCH 111/161] Update hostIf_msgHandler.h --- src/hostif/handlers/include/hostIf_msgHandler.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hostif/handlers/include/hostIf_msgHandler.h b/src/hostif/handlers/include/hostIf_msgHandler.h index cc9512838..a385cf586 100644 --- a/src/hostif/handlers/include/hostIf_msgHandler.h +++ b/src/hostif/handlers/include/hostIf_msgHandler.h @@ -98,6 +98,8 @@ void hostIf_Print_msgData(HOSTIF_MsgData_t *stMsgData); void hostIf_Free_stMsgData (HOSTIF_MsgData_t *stMsgData); +void paramValueToString(const HOSTIF_MsgData_t *stMsgData, char *paramValueStr, size_t strSize); + bool hostIf_initalize_ConfigManger(); bool hostIf_ConfigProperties_Init(); class msgHandler { From 05c52c6c5bb363bb3f56eb62e20f766efb795bfb Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 7 Aug 2025 16:32:05 +0530 Subject: [PATCH 112/161] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 121 +++++++----------- 1 file changed, 46 insertions(+), 75 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index e3a5a06f7..a73572299 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -84,6 +84,50 @@ static std::atomic loggedSet1000Within5Min {false}; #define PARAM_VALUE_STR_SIZE 128 + +void paramValueToString(const HOSTIF_MsgData_t *stMsgData, char *paramValueStr, size_t strSize) +{ + if (!stMsgData || !paramValueStr || strSize == 0) { + if (paramValueStr && strSize > 0) + snprintf(paramValueStr, strSize, ""); + return; + } + + switch (stMsgData->paramtype) { + case hostIf_StringType: + case hostIf_DateTimeType: + snprintf(paramValueStr, strSize, "%s", (const char*)stMsgData->paramValue); + break; + case hostIf_IntegerType: { + int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%d", val); + break; + } + case hostIf_UnsignedIntType: { + unsigned int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%u", val); + break; + } + case hostIf_BooleanType: { + bool val = false; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%s", val ? "true" : "false"); + break; + } + case hostIf_UnsignedLongType: { + unsigned long val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%lu", val); + break; + } + default: + snprintf(paramValueStr, strSize, ""); + break; + } +} + int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -140,44 +184,7 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); char paramValueStr[PARAM_VALUE_STR_SIZE] = {0}; - switch (stMsgData->paramtype) { - case hostIf_StringType: - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); - //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - break; - case hostIf_IntegerType: { - int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%d", val); - break; - } - case hostIf_UnsignedIntType: { - unsigned int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%u", val); - break; - } - case hostIf_BooleanType: { - bool val = false; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", val ? "true" : "false"); - break; - } - case hostIf_DateTimeType: - //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); - break; - case hostIf_UnsignedLongType: { - unsigned long val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%lu", val); - break; - } - default: - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, ""); - break; - } - + paramValueToString(stMsgData, paramValueStr, sizeof(paramValueStr)); // Calculate time taken in microseconds @@ -267,43 +274,7 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto timeTakenset = std::chrono::duration_cast(endTime - startTime).count(); char paramValueStr[128] = {0}; - switch (stMsgData->paramtype) { - case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - break; - case hostIf_IntegerType: { - int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); - break; - } - case hostIf_UnsignedIntType: { - unsigned int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); - break; - } - case hostIf_BooleanType: { - bool val = false; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); - break; - } - case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - break; - case hostIf_UnsignedLongType: { - unsigned long val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); - break; - } - default: - snprintf(paramValueStr, sizeof(paramValueStr), ""); - break; - } - - + paramValueToString(stMsgData, paramValueStr, sizeof(paramValueStr)); RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", From dcd202aa5fa1110e36de193afcc42c003f048384 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 21 Aug 2025 10:43:55 +0530 Subject: [PATCH 113/161] Update cov_build.sh --- cov_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cov_build.sh b/cov_build.sh index d2dbced0d..3554110e9 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -11,7 +11,7 @@ cd rfc autoreconf -i ./configure --enable-rfctool=yes --enable-tr181set=yes --enable-tr69hostif=yes cd rfcapi -make librfcapi_la_CPPFLAGS="-I/usr/include/cjson" +make librfcapi_la_CPPFLAGS="-I/usr/include/cjson -DUSE_IARMBUS" make install cd ../tr181api cp /usr/include/cjson/cJSON.h ./ From ae294e300c25b1a113c71e9e14027e96f9567a8e Mon Sep 17 00:00:00 2001 From: Tharun Kumar Venkatachalem Date: Thu, 21 Aug 2025 09:07:28 +0000 Subject: [PATCH 114/161] RDKEMW-7135 : Gamepad RFC is not enabled by default Reason for change: Set Gamepad RFC as True Test Procedure: verify the steps in Ticket description Risks: Medium Priority: P1 Signed-off-by: Tharun Kumar Venkatachalem --- .../parodusClient/waldb/data-model/data-model-generic.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index e97e68f0e..3e65a1950 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -338,7 +338,7 @@ - + From 264f065ac8bddd756012f5d13eca20e2044b52e1 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Thu, 21 Aug 2025 12:38:22 -0400 Subject: [PATCH 115/161] 1.2.3 release changelog updates --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76809d9ce..5c34d8147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.3](https://github.com/rdkcentral/tr69hostif/compare/1.2.2...1.2.3) + +- RDK-56291 - [RDKE] Increase L2 Test Coverage For Remote Debugger : Target 80% [ Phase 2 ] [`#227`](https://github.com/rdkcentral/tr69hostif/pull/227) +- [RDKEMW-5582] -[RDKE] tr69hostif.log contains any garbage data for the paramValue field [`#219`](https://github.com/rdkcentral/tr69hostif/pull/219) +- RDKEMW-6520: tr69hostif service starts before iarmbusd [`#218`](https://github.com/rdkcentral/tr69hostif/pull/218) +- RDKEMW-4344 : Include the missed RFCs in RDKE. [`#216`](https://github.com/rdkcentral/tr69hostif/pull/216) +- Update hostIf_msgHandler.cpp [`05c52c6`](https://github.com/rdkcentral/tr69hostif/commit/05c52c6c5bb363bb3f56eb62e20f766efb795bfb) +- Update hostIf_msgHandler.cpp [`61a1355`](https://github.com/rdkcentral/tr69hostif/commit/61a1355641b0ca47ae0d24b65f6a66b80210a9d5) +- Update hostIf_msgHandler.cpp [`b273a3a`](https://github.com/rdkcentral/tr69hostif/commit/b273a3a8f9cb9a3d570fcbc20a09b7ca97c88daf) + #### [1.2.2](https://github.com/rdkcentral/tr69hostif/compare/1.2.1...1.2.2) +> 29 July 2025 + - RDKEMW-6193 Code Coverage support for tr69hostif [`#211`](https://github.com/rdkcentral/tr69hostif/pull/211) - RDKEMW-6328: set AVHijack rfc to false [`#208`](https://github.com/rdkcentral/tr69hostif/pull/208) - RDK-58323: Canary firmware updates [`#199`](https://github.com/rdkcentral/tr69hostif/pull/199) +- Changelog updates for release 1.2.2 [`d3eda52`](https://github.com/rdkcentral/tr69hostif/commit/d3eda5205f0cb00c7ab8bbcccb70a31a7ce29a45) - Merge tag '1.2.1' into develop [`17d019b`](https://github.com/rdkcentral/tr69hostif/commit/17d019b0bed5e8cc9c1f4fe68520c08fc530ff00) #### [1.2.1](https://github.com/rdkcentral/tr69hostif/compare/1.2.0...1.2.1) From 1b63a82935bcb4a9d67086f712b6ba4fa67acddc Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 22 Aug 2025 15:03:38 +0530 Subject: [PATCH 116/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 7d9856225..8218cf513 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -38,7 +38,7 @@ /* Function Prototypes */ /*----------------------------------------------------------------------------*/ static WDMP_STATUS GetParamInfo (const char *pParameterName, param_t ***parametervalPtrPtr, int *paramCountPtr,int paramIndex); -static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam); +static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataModelParam *dmParam); int isWildCardParam(const char *paramName); static void converttohostIfType(char *ParamDataType,HostIf_ParamType_t* pParamType); static void converttoWalType(HostIf_ParamType_t paramType,WAL_DATA_TYPE* pwalType); @@ -358,7 +358,7 @@ static WDMP_STATUS GetParamInfo (const char *pParameterName, param_t ***paramete (*parametervalPtrPtr)[index][wc_cnt].value = NULL; // Convert Param.paramtype to ParamVal.type - getRet = get_ParamValues_tr69hostIf (&Param); + getRet = get_ParamValues_tr69hostIf (&Param, NULL); // Fill Only if we can able to get Proper value if(WDMP_SUCCESS == getRet) { @@ -441,7 +441,7 @@ static WDMP_STATUS GetParamInfo (const char *pParameterName, param_t ***paramete } freeDataModelParam(dmParam); Param.instanceNum = 0; - ret = get_ParamValues_tr69hostIf (&Param); + ret = get_ParamValues_tr69hostIf (&Param, &dmParam); if (ret == WDMP_SUCCESS) { int iParamValSize = MAX_PARAM_LENGTH; @@ -652,7 +652,7 @@ static WAL_STATUS SetParamInfo(ParamVal paramVal, char * transactionID) /** * generic Api for get HostIf parameters **/ -static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam) +static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataModelParam *dmParam) { int status = -1; ptrParam->reqType = HOSTIF_GET; @@ -660,6 +660,10 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam) status = hostIf_GetMsgHandler(ptrParam); if(status != 0) { + if (dmParam->defaultValue) + { + retStatus = WDMP_SUCCESS; + } RDK_LOG(RDK_LOG_ERROR,LOG_PARODUS_IF,"[%s:%s:%d] Error in Get Message Handler : %d\n", __FILE__, __FUNCTION__, __LINE__, status); retStatus =(WDMP_STATUS) convertFaultCodeToWalStatus(ptrParam->faultCode); // returning appropriate fault code for get RDK_LOG(RDK_LOG_DEBUG,LOG_PARODUS_IF,"[%s:%d] return status of fault code: %d\n", __FUNCTION__, __LINE__, retStatus); From 0738d8368cc86cdae180a5f58389b4a978036f1d Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 22 Aug 2025 21:15:23 +0530 Subject: [PATCH 117/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 8218cf513..002a40afe 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -663,6 +663,8 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataMo if (dmParam->defaultValue) { retStatus = WDMP_SUCCESS; + RDK_LOG(RDK_LOG_DEBUG,LOG_PARODUS_IF,"[%s:%d] return status success - inside if check : %d\n", __FUNCTION__, __LINE__, retStatus); + return retStatus; } RDK_LOG(RDK_LOG_ERROR,LOG_PARODUS_IF,"[%s:%s:%d] Error in Get Message Handler : %d\n", __FILE__, __FUNCTION__, __LINE__, status); retStatus =(WDMP_STATUS) convertFaultCodeToWalStatus(ptrParam->faultCode); // returning appropriate fault code for get From 2b231428259af6633c882d5336fea8d4972e986b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 22 Aug 2025 21:23:47 +0530 Subject: [PATCH 118/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 002a40afe..a92873eb5 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -439,9 +439,9 @@ static WDMP_STATUS GetParamInfo (const char *pParameterName, param_t ***paramete { converttohostIfType (dmParam.dataType, &(Param.paramtype)); //CID:18170 - FORWARD NULL } - freeDataModelParam(dmParam); Param.instanceNum = 0; ret = get_ParamValues_tr69hostIf (&Param, &dmParam); + freeDataModelParam(dmParam); if (ret == WDMP_SUCCESS) { int iParamValSize = MAX_PARAM_LENGTH; From 935b6e053804365d7cc67f328e3a6b76f55879d6 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sat, 23 Aug 2025 00:02:24 +0530 Subject: [PATCH 119/161] Fix tr69hostif native build failure (#232) * Update cov_build.sh * Update hostIf_utils.cpp * Update cov_build.sh * Update cov_build.sh * Update cov_build.sh * Update cov_build.sh * Update hostIf_utils.cpp --- cov_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cov_build.sh b/cov_build.sh index 3554110e9..9a833b727 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -73,7 +73,7 @@ autoreconf -i ./configure --enable-libsoup3=yes --enable-IPv6=yes make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DLIBSOUP3_ENABLE -DIPV6_SUPPORT" \ -AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" +AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lglib-2.0 -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" make install cd ./src/hostif/parodusClient/pal/mock-parodus/ From 24f28b2e5e8086a5e40b97342292a04ae361ec35 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sat, 23 Aug 2025 21:06:48 +0530 Subject: [PATCH 120/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index a92873eb5..3586cea08 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -663,8 +663,8 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataMo if (dmParam->defaultValue) { retStatus = WDMP_SUCCESS; - RDK_LOG(RDK_LOG_DEBUG,LOG_PARODUS_IF,"[%s:%d] return status success - inside if check : %d\n", __FUNCTION__, __LINE__, retStatus); - return retStatus; + RDK_LOG(RDK_LOG_DEBUG,LOG_PARODUS_IF,"[%s:%d] Default value present in datamodel : %d\n", __FUNCTION__, __LINE__, dmParam->defaultValue); + return WDMP_SUCCESS; } RDK_LOG(RDK_LOG_ERROR,LOG_PARODUS_IF,"[%s:%s:%d] Error in Get Message Handler : %d\n", __FILE__, __FUNCTION__, __LINE__, status); retStatus =(WDMP_STATUS) convertFaultCodeToWalStatus(ptrParam->faultCode); // returning appropriate fault code for get From 137d931dbbcbb30061d4de78d23f5aa00930f265 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sat, 23 Aug 2025 23:07:20 +0530 Subject: [PATCH 121/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 3586cea08..0f57b2dcb 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -661,9 +661,7 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataMo if(status != 0) { if (dmParam->defaultValue) - { - retStatus = WDMP_SUCCESS; - RDK_LOG(RDK_LOG_DEBUG,LOG_PARODUS_IF,"[%s:%d] Default value present in datamodel : %d\n", __FUNCTION__, __LINE__, dmParam->defaultValue); + { return WDMP_SUCCESS; } RDK_LOG(RDK_LOG_ERROR,LOG_PARODUS_IF,"[%s:%s:%d] Error in Get Message Handler : %d\n", __FILE__, __FUNCTION__, __LINE__, status); From d60820fe160a3192c1727b7edbe7b115d27b9896 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Tue, 26 Aug 2025 03:30:36 +0530 Subject: [PATCH 122/161] RDKTV-38130-[RDKE_Trials][8.2p2s2]: Increase in "tr69hostif" crash with function "hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields" and "81598460" fingerprint (#223) * Update Device_WiFi.cpp * Update Device_WiFi_SSID.cpp * Update Device_WiFi_EndPoint.cpp --------- Co-authored-by: nhanasi Co-authored-by: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi.cpp | 2 +- src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp | 2 +- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi.cpp b/src/hostif/profiles/wifi/Device_WiFi.cpp index 2b4fd07e7..0f235fd24 100644 --- a/src/hostif/profiles/wifi/Device_WiFi.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi.cpp @@ -281,7 +281,7 @@ int hostIf_WiFi::get_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) } //ASSIGN TO OP HERE - cJSON *result = cJSON_GetObjectItem(interface, "isEnabled"); + cJSON *result = cJSON_GetObjectItem(interface, "enabled"); put_boolean(stMsgData->paramValue, result->type); stMsgData->paramtype = hostIf_BooleanType; stMsgData->paramLen=1; diff --git a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp index 74c7280f9..87f16ad77 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp @@ -309,7 +309,7 @@ int hostIf_WiFi_EndPoint::refreshCache() } //ASSIGN TO OP HERE - cJSON *result = cJSON_GetObjectItem(interface, "isEnabled"); + cJSON *result = cJSON_GetObjectItem(interface, "enabled"); Enable = result->type; cJSON *state = cJSON_GetObjectItem(jsonObj, "state"); diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 6d71086ee..129f6ff3d 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -212,7 +212,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { ERR_CHK(rc); } - cJSON *isEnabled = cJSON_GetObjectItem(interface, "isEnabled"); + cJSON *isEnabled = cJSON_GetObjectItem(interface, "enabled"); enable=isEnabled->type; RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: ENABLE = %d \n", __FUNCTION__, enable); } From 8e011afa24cd7d56ef21ca1de82799971b65dc73 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 26 Aug 2025 09:53:47 +0530 Subject: [PATCH 123/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 0f57b2dcb..36762830e 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -661,7 +661,9 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataMo if(status != 0) { if (dmParam->defaultValue) - { + { + strncpy(ptrParam->paramValue, dmParam->defaultValue, MAX_PARAM_LENGTH - 1); + ptrParam->paramValue[MAX_PARAM_LENGTH - 1] = '\0'; return WDMP_SUCCESS; } RDK_LOG(RDK_LOG_ERROR,LOG_PARODUS_IF,"[%s:%s:%d] Error in Get Message Handler : %d\n", __FILE__, __FUNCTION__, __LINE__, status); From b112be6f22ab852b37604562d3a4341d94160cdb Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 27 Aug 2025 13:41:58 -0400 Subject: [PATCH 124/161] 1.2.4 release changelog updates --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c34d8147..25acc72d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.4](https://github.com/rdkcentral/tr69hostif/compare/1.2.3...1.2.4) + +- RDKEMW-4759 - Review and Analyze the RRD Static Profiles for RDK devices [`#198`](https://github.com/rdkcentral/tr69hostif/pull/198) +- RDKEMW-7135 : Gamepad RFC is not enabled by default [`#228`](https://github.com/rdkcentral/tr69hostif/pull/228) +- RDKTV-38130-[RDKE_Trials][8.2p2s2]: Increase in "tr69hostif" crash with function "hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields" and "81598460" fingerprint [`#223`](https://github.com/rdkcentral/tr69hostif/pull/223) +- Fix tr69hostif native build failure [`#232`](https://github.com/rdkcentral/tr69hostif/pull/232) +- Rebase [`#209`](https://github.com/rdkcentral/tr69hostif/pull/209) +- Merge tag '1.2.3' into develop [`84c45dd`](https://github.com/rdkcentral/tr69hostif/commit/84c45dd1c8bac75d25f06fbbc14575c02d8a153a) +- Update Device_DeviceInfo.cpp [`5441b70`](https://github.com/rdkcentral/tr69hostif/commit/5441b702ad40eb9523499670b9254ea3fcbda0cc) +- Update Device_DeviceInfo.cpp [`cda900d`](https://github.com/rdkcentral/tr69hostif/commit/cda900d6d35170fcfe0c3ac8382271575eba077b) + #### [1.2.3](https://github.com/rdkcentral/tr69hostif/compare/1.2.2...1.2.3) +> 21 August 2025 + - RDK-56291 - [RDKE] Increase L2 Test Coverage For Remote Debugger : Target 80% [ Phase 2 ] [`#227`](https://github.com/rdkcentral/tr69hostif/pull/227) - [RDKEMW-5582] -[RDKE] tr69hostif.log contains any garbage data for the paramValue field [`#219`](https://github.com/rdkcentral/tr69hostif/pull/219) - RDKEMW-6520: tr69hostif service starts before iarmbusd [`#218`](https://github.com/rdkcentral/tr69hostif/pull/218) From 8eb32e51eb5c9512209d3d12f9ddc42aa8d369a5 Mon Sep 17 00:00:00 2001 From: madhubabutt <114217841+madhubabutt@users.noreply.github.com> Date: Thu, 28 Aug 2025 21:13:17 +0530 Subject: [PATCH 125/161] RDK-57737 [ tr69hostif ] : L1 Functional Coverage from 31.2% to 75-80% (#225) * RDK-57737 [ tr69hostif ] : L1 Functional Coverage from 31.2% to 75-80% * Update Device_DeviceInfo.cpp --------- Co-authored-by: mtirum011 --- dependent_rdk_pkg_installer.sh | 111 ++ run_ut.sh | 83 +- src/configure.ac | 11 +- .../httpserver/include/XrdkCentralComRFCVar.h | 8 + src/hostif/httpserver/src/gtest/Makefile.am | 48 + .../httpserver/src/gtest/gtest_httpserver.cpp | 393 ++++ src/hostif/httpserver/src/request_handler.cpp | 33 + src/hostif/include/hostIf_utils.h | 4 +- src/hostif/parodusClient/gtest/Makefile.am | 18 +- src/hostif/parodusClient/gtest/dm_test.cpp | 510 +++++ src/hostif/parodusClient/pal/libpd.cpp | 12 + .../parodusClient/pal/webpa_adapter.cpp | 12 + src/hostif/parodusClient/pal/webpa_adapter.h | 4 + .../parodusClient/pal/webpa_attribute.cpp | 24 + .../parodusClient/pal/webpa_notification.cpp | 7 + .../parodusClient/pal/webpa_parameter.cpp | 40 + .../startParodus/startParodus.cpp | 2 + .../parodusClient/startParodus/startParodus.h | 35 + src/hostif/parodusClient/waldb/waldb.h | 8 + .../profiles/DHCPv4/Device_DHCPv4_Client.cpp | 3 +- .../profiles/DHCPv4/Device_DHCPv4_Client.h | 11 +- src/hostif/profiles/DHCPv4/gtest/Makefile.am | 49 + .../profiles/DHCPv4/gtest/gtest_dhcpv4.cpp | 100 + src/hostif/profiles/Device/gtest/Makefile.am | 49 + .../profiles/Device/gtest/gtest_device.cpp | 176 ++ src/hostif/profiles/Device/x_rdk_profile.h | 11 + .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 18 +- .../profiles/DeviceInfo/Device_DeviceInfo.h | 35 + .../Device_DeviceInfo_ProcessStatus.h | 8 + .../DeviceInfo/XrdkCentralComBSStore.h | 18 + .../DeviceInfo/XrdkCentralComBSStoreJournal.h | 10 + .../profiles/DeviceInfo/XrdkCentralComRFC.h | 8 + .../DeviceInfo/XrdkCentralComRFCStore.h | 4 + .../profiles/DeviceInfo/gtest/Makefile.am | 4 +- .../profiles/DeviceInfo/gtest/gtest_main.cpp | 1639 ++++++++++++++++- .../Ethernet/Device_Ethernet_Interface.cpp | 6 + .../profiles/Ethernet/gtest/Makefile.am | 50 + .../Ethernet/gtest/gtest_ethernet.cpp | 410 +++++ src/hostif/profiles/Time/gtest/Makefile.am | 49 + src/hostif/profiles/Time/gtest/gtest_time.cpp | 138 ++ src/hostif/src/gtest/Makefile.am | 49 + src/hostif/src/gtest/gtest_src.cpp | 264 +++ src/integrationtest/conf/rfcVariable.ini | 2 + src/unittest/stubs/dm_stubs.cpp | 6 +- src/unittest/stubs/ds/aspectRatio.hpp | 10 +- src/unittest/stubs/ds/audioEncoding.hpp | 14 +- src/unittest/stubs/ds/audioOutputPort.hpp | 59 +- src/unittest/stubs/ds/audioStereoMode.hpp | 6 +- src/unittest/stubs/ds/frameRate.hpp | 8 +- src/unittest/stubs/ds/host.hpp | 23 +- src/unittest/stubs/ds/libprocps.cpp | 19 + src/unittest/stubs/ds/manager.hpp | 4 +- src/unittest/stubs/ds/pixelResolution.hpp | 4 +- src/unittest/stubs/ds/videoDFC.hpp | 4 +- src/unittest/stubs/ds/videoDevice.hpp | 39 +- src/unittest/stubs/ds/videoOutputPort.hpp | 54 +- src/unittest/stubs/ds/videoOutputPortType.hpp | 12 +- src/unittest/stubs/ds/videoResolution.hpp | 25 +- src/unittest/stubs/file_writer.cpp | 65 + src/unittest/stubs/file_writer.h | 22 + src/unittest/stubs/libparodus.h | 212 +++ src/unittest/stubs/libparodus_log.h | 84 + src/unittest/stubs/rbus/include/rbus.h | 13 +- .../stubs/rbus/include/rbus_property.h | 20 +- src/unittest/stubs/rbus/include/rbus_value.h | 5 +- src/unittest/stubs/rdk_debug.h | 1 + src/unittest/stubs/rfcapi.h | 11 +- src/unittest/stubs/tr181store.ini | 8 + src/unittest/stubs/wrp-c.h | 298 +++ 69 files changed, 5381 insertions(+), 119 deletions(-) create mode 100644 dependent_rdk_pkg_installer.sh create mode 100644 src/hostif/httpserver/src/gtest/Makefile.am create mode 100644 src/hostif/httpserver/src/gtest/gtest_httpserver.cpp create mode 100644 src/hostif/parodusClient/startParodus/startParodus.h create mode 100644 src/hostif/profiles/DHCPv4/gtest/Makefile.am create mode 100644 src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp create mode 100644 src/hostif/profiles/Device/gtest/Makefile.am create mode 100644 src/hostif/profiles/Device/gtest/gtest_device.cpp create mode 100644 src/hostif/profiles/Ethernet/gtest/Makefile.am create mode 100644 src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp create mode 100644 src/hostif/profiles/Time/gtest/Makefile.am create mode 100644 src/hostif/profiles/Time/gtest/gtest_time.cpp create mode 100644 src/hostif/src/gtest/Makefile.am create mode 100644 src/hostif/src/gtest/gtest_src.cpp create mode 100644 src/integrationtest/conf/rfcVariable.ini create mode 100644 src/unittest/stubs/ds/libprocps.cpp create mode 100644 src/unittest/stubs/file_writer.cpp create mode 100644 src/unittest/stubs/file_writer.h create mode 100644 src/unittest/stubs/libparodus.h create mode 100644 src/unittest/stubs/libparodus_log.h create mode 100644 src/unittest/stubs/wrp-c.h diff --git a/dependent_rdk_pkg_installer.sh b/dependent_rdk_pkg_installer.sh new file mode 100644 index 000000000..d4bc1afd4 --- /dev/null +++ b/dependent_rdk_pkg_installer.sh @@ -0,0 +1,111 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2024 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +# Clone and build rbus +export RBUS_ROOT=/usr +export RBUS_INSTALL_DIR=${RBUS_ROOT}/local +mkdir -p $RBUS_INSTALL_DIR +cd $RBUS_ROOT + + +WORKDIR=/opt/WORKDIR +mkdir -p $WORKDIR + +cd $WORKDIR +git clone https://github.com/xmidt-org/trower-base64.git +cd trower-base64 +meson setup build +ninja -C build +ninja -C build install +cd $WORKDIR +rm -rf trower-base64 + +# cJson flavor used in RDK stack +cd $WORKDIR +git clone https://github.com/DaveGamble/cJSON.git +cd cJSON +mkdir build +cd build +cmake .. +make && make install +cd $WORKDIR +rm -rf cJSON + +# Include WDMP package +cd $WORKDIR +git clone https://github.com/xmidt-org/wdmp-c.git +cd wdmp-c +sed -i '/WDMP_ERR_SESSION_IN_PROGRESS/a\ WDMP_ERR_INTERNAL_ERROR,\n WDMP_ERR_DEFAULT_VALUE,' src/wdmp-c.h +cmake -H. -Bbuild -DBUILD_FOR_DESKTOP=ON -DCMAKE_BUILD_TYPE=Debug +make -C build && make -C build install +cd $WORKDIR +rm -rf wdmp-c + +# Install dependencies of libparodus +cd $WORKDIR +git clone https://github.com/nanomsg/nanomsg.git +cd nanomsg +mkdir build +cd build +cmake .. +cmake --build . +cmake --build . --target install +cd $WORKDIR +rm -rf nanomsg + +git clone https://github.com/xmidt-org/cimplog.git +cd cimplog +git checkout 8a5fb3c2f182241d17f5342bea5b7688c28cd1fd +mkdir build +cd build +cmake .. +make && make install +cd $WORKDIR +rm -rf cimplog + + +cd $WORKDIR +git clone https://github.com/xmidt-org/wrp-c.git +cd wrp-c +git checkout 9587e8db33dbbfcd9b78ef66cc2eaf16dfb9afcf +# replace 7a98138f27f27290e680bf8fbf1f8d1b089bf138 with 445880108a1d171f755ff6ac77e03fbebbb23729 in CMakeLists.txt +# Message pack revision used in libparadous is not buildable with latest gcc versions +sed -i 's/7a98138f27f27290e680bf8fbf1f8d1b089bf138/445880108a1d171f755ff6ac77e03fbebbb23729/g' CMakeLists.txt +mkdir build +cd build +cmake .. +make && make install +cd $WORKDIR +rm -rf wrp-c + +cd $WORKDIR +git clone https://github.com/xmidt-org/libparodus.git +cd libparodus +# replace 7a98138f27f27290e680bf8fbf1f8d1b089bf138 with 445880108a1d171f755ff6ac77e03fbebbb23729 in CMakeLists.txt +# Message pack revision used in libparadous is not buildable with latest gcc versions +sed -i 's/7a98138f27f27290e680bf8fbf1f8d1b089bf138/445880108a1d171f755ff6ac77e03fbebbb23729/g' CMakeLists.txt +mkdir build +cd build +cmake .. +make && make install +cd $WORKDIR +rm -rf libparodus + + +#rtrouted -f -l DEBUG diff --git a/run_ut.sh b/run_ut.sh index 92abdfec0..880235a74 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -18,7 +18,20 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################################ - +WORKDIR=`pwd` +sh dependent_rdk_pkg_installer.sh +export ROOT=/usr + +cd $ROOT +rm -rf remote_debugger +rm -rf rdk-halif-device_settings +rm -rf rdkvhal-devicesettings-raspberrypi4 +git clone https://github.com/rdkcentral/remote_debugger.git +git clone https://github.com/rdkcentral/rdk-halif-device_settings.git +git clone https://github.com/rdkcentral/rdkvhal-devicesettings-raspberrypi4.git + +cd $WORKDIR +ls -l /usr/local/include/libparodus/ ENABLE_COV=false if [ "x$1" = "x--enable-cov" ]; then @@ -32,6 +45,9 @@ fi apt-get update apt-get -y install libtinyxml2-dev apt-get -y install libsoup-3.0-dev +apt-get -y install libprocps-dev +apt-get -y install libnanomsg-dev +apt-get -y install iproute2 sed '/<\/model>/d; /<\/dm:document>/d' ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml > ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml sed '/> ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml @@ -43,12 +59,25 @@ cp ./src/unittest/stubs/rfcdefaults.ini /tmp/rfcdefaults.ini mkdir /opt/secure mkdir /opt/secure/RFC +mkdir -p /opt/secure/reboot/ +mkdir -p /opt/www/authService/ +mkdir -p /tmp/webpa +mkdir -p /opt/persistent/ +mkdir -p /etc/rfcdefaults +mkdir -p /etc/apparmor.d cp ./src/unittest/stubs/tr181store.ini /opt/secure/RFC/tr181store.ini +cp ./src/integrationtest/conf/bootstrap.ini /opt/secure/RFC/ +cp ./src/integrationtest/conf/rfcVariable.ini /opt/secure/RFC/ cp partners_defaults.json /etc/partners_defaults.json cp ./src/unittest/stubs/partners_defaults_device.json /etc/partners_defaults_device.json cp ./src/unittest/stubs/fwdnldstatus.txt /opt/fwdnldstatus.txt +touch /tmp/timeReceivedNTP +touch /tmp/webpa/start_time +touch /opt/persistent/firstNtpTime + + -export TOP_DIR=`pwd` +export TOP_DIR=$WORKDIR cd ./src/ automake --add-missing @@ -64,13 +93,59 @@ echo "TOP_DIR = $TOP_DIR" echo "**** Compiling data model gtest ****" cd $TOP_DIR/src/hostif/parodusClient/gtest rm dm_gtest +sed -i '/getCurrentTime/,/^ *}/d' ../../src/hostIf_utils.cpp make ./dm_gtest echo "********************" +echo "**** Compiling httpserver gtest ****" +cd $TOP_DIR/src/hostif/httpserver/src/gtest +rm httpserver_gtest +sed -i '$a void getCurrentTime(struct timespec *timer)\n{\n clock_gettime(CLOCK_REALTIME, timer);\n}' ../../../src/hostIf_utils.cpp +make clean +make +./httpserver_gtest +echo "********************" + +echo "**** Compiling src gtest ****" +cd $TOP_DIR/src/hostif/src/gtest +rm src_gtest +make clean +make +./src_gtest +echo "********************" + +echo "**** Compiling DHCPv4 gtest ****" +cd $TOP_DIR/src/hostif/profiles/DHCPv4/gtest +rm dhcpv4_gtest +make +./dhcpv4_gtest +echo "********************" + +echo "**** Compiling Device gtest ****" +cd $TOP_DIR/src/hostif/profiles/Device/gtest +rm device_gtest +make +./device_gtest +echo "********************" + +echo "**** Compiling Ethernet gtest ****" +cd $TOP_DIR/src/hostif/profiles/Ethernet/gtest +rm ethernet_gtest +make +./ethernet_gtest +echo "********************" + +echo "**** Compiling Time gtest ****" +cd $TOP_DIR/src/hostif/profiles/Time/gtest +rm time_gtest +make +./time_gtest +echo "********************" + echo "**** Compiling DeviceInfo gtest ****" cd $TOP_DIR/src/hostif/profiles/DeviceInfo/gtest -rm devieInfo_gtest +rm devieInfo_gtest /opt/www/authService/partnerId3.dat make ./devieInfo_gtest echo "********************" @@ -80,7 +155,7 @@ cd $TOP_DIR if [ "$ENABLE_COV" = true ]; then lcov --capture --directory . --output-file coverage.info lcov --remove coverage.info '/usr/*' '*/gtest/*' '*/mocks/*' --output-file filtered.info - lcov --extract filtered.info '*/src/hostif*' --output-file tr69hostif_coverage.info + lcov --extract filtered.info '*/src/hostif/httpserver/*' '*/src/hostif/parodusClient/*' '*/src/hostif/src/*' '*/src/hostif/profiles/DHCPv4/*' '*/src/hostif/profiles/Device/*' '*/src/hostif/profiles/DeviceInfo/*' '*/src/hostif/profiles/Ethernet/*' '*/src/hostif/profiles/Time/*' --output-file tr69hostif_coverage.info lcov --list tr69hostif_coverage.info fi diff --git a/src/configure.ac b/src/configure.ac index e704399ee..d62a94a95 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -69,8 +69,15 @@ AC_SUBST(T2_EVENT_FLAG) # Generate the Makefile AC_CONFIG_FILES([ - hostif/parodusClient/gtest/Makefile \ - hostif/profiles/DeviceInfo/gtest/Makefile]) + hostif/parodusClient/gtest/Makefile + hostif/httpserver/src/gtest/Makefile + hostif/src/gtest/Makefile + hostif/profiles/DHCPv4/gtest/Makefile + hostif/profiles/Device/gtest/Makefile + hostif/profiles/Ethernet/gtest/Makefile + hostif/profiles/Time/gtest/Makefile + hostif/profiles/DeviceInfo/gtest/Makefile + ]) # Generate the configure script AC_OUTPUT diff --git a/src/hostif/httpserver/include/XrdkCentralComRFCVar.h b/src/hostif/httpserver/include/XrdkCentralComRFCVar.h index 590ba90a8..0fdd1ce10 100644 --- a/src/hostif/httpserver/include/XrdkCentralComRFCVar.h +++ b/src/hostif/httpserver/include/XrdkCentralComRFCVar.h @@ -23,6 +23,10 @@ #include #include +#if defined(GTEST_ENABLE) +#include +#endif + using namespace std; #define XRFC_VAR_STORE_RELOADCACHE "RFC_CONTROL_RELOADCACHE" @@ -49,6 +53,10 @@ class XRFCVarStore void initRFCVarFileName(); bool loadRFCVarIntoCache(); +#if defined(GTEST_ENABLE) + FRIEND_TEST(httpserverTest, initRFCVarFileName); + FRIEND_TEST(httpserverTest, loadRFCVarIntoCache); +#endif }; #endif // XRDKCENTRALCOMRFCVARSTORE_H diff --git a/src/hostif/httpserver/src/gtest/Makefile.am b/src/hostif/httpserver/src/gtest/Makefile.am new file mode 100644 index 000000000..ebdd454f0 --- /dev/null +++ b/src/hostif/httpserver/src/gtest/Makefile.am @@ -0,0 +1,48 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects +# Define the program name and the source files +bin_PROGRAMS = httpserver_gtest + +# Define the include directories +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -Isrc/unittest/stubs/rbus/include/ + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lglib-2.0 + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif + + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage + +httpserver_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_parameter.cpp $(TOP_DIR)/src/unittest/stubs/file_writer.cpp $(TOP_DIR)/src/hostif/httpserver/src/gtest/gtest_httpserver.cpp + +# Apply common properties to each program +httpserver_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +httpserver_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) +httpserver_gtest_LDADD = $(COMMON_LDADD) diff --git a/src/hostif/httpserver/src/gtest/gtest_httpserver.cpp b/src/hostif/httpserver/src/gtest/gtest_httpserver.cpp new file mode 100644 index 000000000..e21e11197 --- /dev/null +++ b/src/hostif/httpserver/src/gtest/gtest_httpserver.cpp @@ -0,0 +1,393 @@ +#include +#include +#include +#include "hostIf_tr69ReqHandler.h" +#include "hostIf_utils.h" +#include "XrdkCentralComRFCStore.h" +#include "XrdkCentralComBSStore.h" +#include "XrdkCentralComBSStoreJournal.h" +#include "Device_DeviceInfo_Processor.h" +#include "Device_DeviceInfo_ProcessStatus.h" +#include "XrdkCentralComRFCVar.h" +#include "request_handler.h" +#include "IniFile.h" +#include "hostIf_utils.h" +#include "hostIf_main.h" +#include "webpa_notification.h" +#include "webpa_parameter.h" +#include "rbus_value.h" + +#include "rdk_debug.h" +#include "waldb.h" +#include "file_writer.h" + +#ifdef __cplusplus +extern "C" +{ +#endif +#include +#include +#ifdef __cplusplus +} +#endif + +#include "Device_DeviceInfo.h" + +#include +#include "cJSON.h" + +#include +#include + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "hostif_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +using namespace std; + +XRFCStore* m_rfcStore; +XBSStore* m_bsStore; +XBSStoreJournal* m_bsStoreJournal; +XRFCVarStore* m_varStore; + +std::mutex mtx_httpServerThreadDone; +std::condition_variable cv_httpServerThreadDone; +bool httpServerThreadDone = false; +GThread *HTTPServerThread = NULL; +char *HTTPServerName = (char *)"HTTPServerThread"; +GError *httpError = NULL; +T_ARGLIST argList = {{'\0'}, 0}; + +#ifdef GTEST_ENABLE +extern DATA_TYPE (*getWdmpDataTypeFunc())(char * ); +extern HostIf_ParamType_t (*getHostIfParamTypeFunc())(DATA_TYPE wdmpDataType); +bool (*validateParamValueFunc())(const string ¶mValue, HostIf_ParamType_t dataType); +WDMP_STATUS (*handleRFCRequestFunc())(REQ_TYPE reqType, param_t *param); +WDMP_STATUS (*invokeHostIfAPIFunc())(REQ_TYPE reqType, param_t *param, HostIf_Source_Type_t bsUpdate, const char *pcCallerID); +WDMP_STATUS (*validateAgainstDataModelFunc())(REQ_TYPE reqType, char* paramName, const char* paramValue, DATA_TYPE *dataType, char **defaultValue, HostIf_Source_Type_t *bsUpdate); +#endif + +TEST(httpserverTest,initRFCVarFileName){ + m_varStore=XRFCVarStore::getInstance(); + if(m_varStore) + { + m_varStore->initRFCVarFileName(); + m_varStore->m_filename.erase(std::remove(m_varStore->m_filename.begin(),m_varStore->m_filename.end(),'"'),m_varStore->m_filename.end()); + EXPECT_EQ(m_varStore->m_filename,"/opt/secure/RFC/rfcVariable.ini"); + } +} + +TEST(httpserverTest, loadRFCVarIntoCache) { + m_varStore = XRFCVarStore::getInstance(); + if(m_varStore) + { + bool ret = m_varStore->loadRFCVarIntoCache(); + EXPECT_EQ(ret, true); + } +} + +TEST(httpserverTest, getValue) { + m_varStore = XRFCVarStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData"; + if(m_varStore) + { + string value = m_varStore->getValue(key); + EXPECT_EQ(value, "testCfg"); + } +} + + +TEST(httpserverTest, getWdmpDataType) { + EXPECT_EQ(getWdmpDataTypeFunc()("string"), WDMP_STRING); + EXPECT_EQ(getWdmpDataTypeFunc()("boolean"), WDMP_BOOLEAN); + EXPECT_EQ(getWdmpDataTypeFunc()("unsignedInt"), WDMP_UINT); + EXPECT_EQ(getWdmpDataTypeFunc()("int"), WDMP_INT); + EXPECT_EQ(getWdmpDataTypeFunc()("unsignedLong"), WDMP_ULONG); + EXPECT_EQ(getWdmpDataTypeFunc()("dataTime"), WDMP_DATETIME); +} + +TEST(httpserverTest, getHostIfParamType) { + EXPECT_EQ(getHostIfParamTypeFunc()(WDMP_STRING), hostIf_StringType); + EXPECT_EQ(getHostIfParamTypeFunc()(WDMP_INT), hostIf_IntegerType); + EXPECT_EQ(getHostIfParamTypeFunc()(WDMP_UINT), hostIf_UnsignedIntType); + EXPECT_EQ(getHostIfParamTypeFunc()(WDMP_BOOLEAN), hostIf_BooleanType); + EXPECT_EQ(getHostIfParamTypeFunc()(WDMP_DATETIME), hostIf_DateTimeType); + EXPECT_EQ(getHostIfParamTypeFunc()(WDMP_BASE64), hostIf_StringType); +} + +TEST(httpserverTest, validateParamValue) { + const string sparamValue = "testimage"; + HostIf_ParamType_t dataType = hostIf_StringType; + EXPECT_EQ(validateParamValueFunc()(sparamValue, dataType), true); + + const string bparamValue = "0"; + dataType = hostIf_BooleanType; + EXPECT_EQ(validateParamValueFunc()(bparamValue, dataType), true); + + const string iparamValue = "12800"; + dataType = hostIf_IntegerType; + EXPECT_EQ(validateParamValueFunc()(iparamValue, dataType), true); + + const string uiparamValue = "12"; + dataType = hostIf_UnsignedIntType; + EXPECT_EQ(validateParamValueFunc()(uiparamValue, dataType), true); +} + +TEST(httpserverTest, handleRFCRequest_GET) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType"); + + REQ_TYPE reqType = GET; + WDMP_STATUS status = handleRFCRequestFunc()(reqType, ¶m); + EXPECT_EQ(status, WDMP_SUCCESS); + + EXPECT_STREQ(param.value, "testtype"); + free(param.name); +} + +TEST(httpserverTest, handleRFCRequest_SET) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup(XRFC_VAR_STORE_RELOADCACHE); + param.value = strdup("true"); + + REQ_TYPE reqType = SET; + WDMP_STATUS status = handleRFCRequestFunc()(reqType, ¶m); + EXPECT_EQ(status, WDMP_SUCCESS); + free(param.name); + free(param.value); +} + +TEST(httpserverTest, handleRFCInvalidRequest) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.Control.ClearDB"); + param.value = strdup("true"); + + REQ_TYPE reqType = SET; + WDMP_STATUS status = handleRFCRequestFunc()(reqType, ¶m); + EXPECT_EQ(status, WDMP_ERR_METHOD_NOT_SUPPORTED); + free(param.name); + free(param.value); +} + +TEST(httpserverTest, invokeHostIfAPI) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable"); + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable", "true", "/opt/secure/RFC/tr181store.ini", Plain); + const char *pcCallerID = "rfc"; + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + REQ_TYPE reqType = GET; + WDMP_STATUS status = invokeHostIfAPIFunc()(reqType, ¶m, msgData.bsUpdate, pcCallerID); + EXPECT_EQ(status, WDMP_SUCCESS); + +} + +TEST(httpserverTest, validateAgainstDataModel_GET) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + char paramName [] = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable"; + const char* paramValue = NULL; + DATA_TYPE dataType = WDMP_BOOLEAN; + + REQ_TYPE reqType = GET; + char defaultValue[66]; + char* defaultValuePtr = defaultValue; + WDMP_STATUS status = validateAgainstDataModelFunc()(reqType, paramName, paramValue, &dataType, &defaultValuePtr, &msgData.bsUpdate); + EXPECT_EQ(status, WDMP_SUCCESS); + EXPECT_STREQ(defaultValuePtr, "false"); + +} + +TEST(httpserverTest, validateAgainstDataModel_SET_NullParam) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + char paramName [] = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName"; + const char* paramValue = NULL; + DATA_TYPE dataType = WDMP_BOOLEAN; + + REQ_TYPE reqType = SET; + char defaultValue[66]; + char* defaultValuePtr = defaultValue; + WDMP_STATUS status = validateAgainstDataModelFunc()(SET, paramName, paramValue, &dataType, &defaultValuePtr, &msgData.bsUpdate); + EXPECT_EQ(status, WDMP_ERR_VALUE_IS_NULL); +} + +TEST(httpserverTest, validateAgainstDataModel_SET_ReadOnly) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + char paramName [] = "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshStatus"; + const char* paramValue = "reverseSsh"; + DATA_TYPE dataType = WDMP_BOOLEAN; + + REQ_TYPE reqType = SET; + char defaultValue[66]; + char* defaultValuePtr = defaultValue; + WDMP_STATUS status = validateAgainstDataModelFunc()(SET, paramName, paramValue, &dataType, &defaultValuePtr, &msgData.bsUpdate); + EXPECT_EQ(status, WDMP_ERR_NOT_WRITABLE); +} + +TEST(httpserverTest, handleRequest_GET) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + get_req_t *getReq = (get_req_t *)malloc(sizeof(get_req_t)); + getReq->paramCnt = 1; + getReq->paramNames[0] = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"); + //getReq->paramNames[1] = strdup("Device.DeviceInfo."); + req_struct reqSt; + reqSt.reqType = GET; // Replace with actual enum value if it's defined + reqSt.u.getReq = getReq; + + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + EXPECT_EQ(respSt->retStatus[0], WDMP_ERR_DEFAULT_VALUE); +} + +TEST(httpserverTest, handlewildRequest_GET) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + get_req_t *getReq = (get_req_t *)malloc(sizeof(get_req_t)); + getReq->paramCnt = 1; + getReq->paramNames[0] = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary."); + //getReq->paramNames[1] = strdup("Device.DeviceInfo."); + req_struct reqSt; + reqSt.reqType = GET; // Replace with actual enum value if it's defined + reqSt.u.getReq = getReq; + + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + //EXPECT_EQ(respSt->retStatus[0], WDMP_ERR_DEFAULT_VALUE); + EXPECT_EQ(respSt->retStatus[0], 0); + +} + +TEST(httpserverTest, handleRequest_SET) { + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + + param_t *params = (param_t *) malloc(sizeof(param_t) * 3); + params[0].name = strdup("Device.X_CISCO_COM_DeviceControl.RebootDevice"); + params[0].value = strdup("true"); + params[0].type = WDMP_BOOLEAN; + + params[1].name = strdup("Device.DeviceInfo."); + params[1].value = strdup("true"); + params[1].type = WDMP_BOOLEAN; + + params[2].name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"); + params[2].value = NULL; + params[2].type = WDMP_BOOLEAN; + + set_req_t *setReq = (set_req_t *)malloc(sizeof(set_req_t)); + setReq->param = params; + setReq->paramCnt = 3; + + req_struct reqSt; + reqSt.reqType = SET; // Replace with actual enum value + reqSt.u.setReq = setReq; + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + EXPECT_EQ(respSt->retStatus[0], WDMP_FAILURE); + EXPECT_EQ(respSt->retStatus[1], WDMP_ERR_WILDCARD_NOT_SUPPORTED); + EXPECT_EQ(respSt->retStatus[2], WDMP_ERR_VALUE_IS_NULL); +} + + +GTEST_API_ int main(int argc, char *argv[]){ + char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; + char buffer[GTEST_REPORT_FILEPATH_SIZE]; + + memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE ); + memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE ); + snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME); + + ::testing::GTEST_FLAG(output) = testresults_fullfilepath; + ::testing::InitGoogleMock(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/src/hostif/httpserver/src/request_handler.cpp b/src/hostif/httpserver/src/request_handler.cpp index 20cf518f8..43e3e9543 100644 --- a/src/hostif/httpserver/src/request_handler.cpp +++ b/src/hostif/httpserver/src/request_handler.cpp @@ -738,3 +738,36 @@ res_struct* handleRequest(const char* pcCallerID, req_struct *reqSt) RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"Leaving... %s\n", __FUNCTION__); return respSt; } + +#ifdef GTEST_ENABLE +DATA_TYPE (*getWdmpDataTypeFunc())(char * ) +{ + return &getWdmpDataType; +} + +HostIf_ParamType_t (*getHostIfParamTypeFunc())(DATA_TYPE wdmpDataType) +{ + return &getHostIfParamType; +} + +bool (*validateParamValueFunc())(const string ¶mValue, HostIf_ParamType_t dataType) +{ + return &validateParamValue; +} + +WDMP_STATUS (*handleRFCRequestFunc())(REQ_TYPE reqType, param_t *param) +{ + return &handleRFCRequest; +} + +WDMP_STATUS (*invokeHostIfAPIFunc())(REQ_TYPE reqType, param_t *param, HostIf_Source_Type_t bsUpdate, const char *pcCallerID) +{ + return &invokeHostIfAPI; +} + +WDMP_STATUS (*validateAgainstDataModelFunc())(REQ_TYPE reqType, char* paramName, const char* paramValue, DATA_TYPE *dataType, char ** +defaultValue, HostIf_Source_Type_t *bsUpdate) +{ + return &validateAgainstDataModel; +} +#endif diff --git a/src/hostif/include/hostIf_utils.h b/src/hostif/include/hostIf_utils.h index d0b6ad7d2..aee1ce8f9 100755 --- a/src/hostif/include/hostIf_utils.h +++ b/src/hostif/include/hostIf_utils.h @@ -124,11 +124,13 @@ unsigned long string_to_ulong(const char *value); bool string_to_bool(const char *value); +std::string bool_to_string(bool value); + std::string getStringValue(HOSTIF_MsgData_t *stMsgData); void putValue(HOSTIF_MsgData_t *stMsgData, const std::string &value); -bool set_GatewayConnStatus(); +void set_GatewayConnStatus( bool enabled); bool get_GatewayConnStatus(); /** diff --git a/src/hostif/parodusClient/gtest/Makefile.am b/src/hostif/parodusClient/gtest/Makefile.am index dbafed8ad..b24578528 100644 --- a/src/hostif/parodusClient/gtest/Makefile.am +++ b/src/hostif/parodusClient/gtest/Makefile.am @@ -22,16 +22,26 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = dm_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -I$(TOP_DIR)/src/unittest/stubs -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/parodusClient/waldb/ -I$(TOP_DIR)/src/hostif/parodusClient/pal/ -I$(TOP_DIR)/src/hostif/include/ -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs/rbus/include +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DUSE_DEV_PROPERTIES_CONF -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -Isrc/unittest/stubs/rbus/include/ -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/STBService -I/usr/rdk-halif-device_settings/include/ -I/usr/rdkvhal-devicesettings-raspberrypi4/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I/usr/remote_debugger/src/ -I/usr/local/include/libparodus/ -I/usr/local/include/wrp-c/ -I$(TOP_DIR)/src/hostif/parodusClient/startParodus/ + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lglib-2.0 -llibparodus -lwrp-c -lnanomsg -lmsgpackc -ltrower-base64 -lcimplog + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) -fprofile-arcs -ftest-coverage -# Define the source files -dm_gtest_SOURCES = dm_test.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp + +dm_gtest_SOURCES = dm_test.cpp $(TOP_DIR)/src/hostif/parodusClient/startParodus/startParodus.cpp $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_attribute.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_parameter.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/libpd.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_adapter.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_msgHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_XrdkCentralT2_ReqHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus_Process.cpp $(TOP_DIR)/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_DisplayDevice.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_EthernetClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_TimeClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface.cpp $(TOP_DIR)/src/hostif/profiles/Time/Device_Time.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_updateHandler.cpp $(TOP_DIR)/src/hostif/profiles/Device/x_rdk_profile.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_dsClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Capabilities.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_SPDIF.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_VideoDecoder.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_AudioOutput.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_HDMI.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_VideoOutput.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface_Stats.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_ActivePort.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Diagnostics_IPPing.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface_IPv4Address.cpp $(TOP_DIR)/src/hostif/handlers/src/x_rdk_req_handler.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.cpp $(TOP_DIR)/src/unittest/stubs/ds/libprocps.cpp $(TOP_DIR)/src/unittest/stubs/file_writer.cpp # Apply common properties to each program dm_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) diff --git a/src/hostif/parodusClient/gtest/dm_test.cpp b/src/hostif/parodusClient/gtest/dm_test.cpp index 27812bb8f..ade9dc19c 100644 --- a/src/hostif/parodusClient/gtest/dm_test.cpp +++ b/src/hostif/parodusClient/gtest/dm_test.cpp @@ -20,16 +20,62 @@ #include #include #include "dm_stubs.h" +#include "startParodus.h" +#include "file_writer.h" +#include "webpa_notification.h" +#include "webpa_parameter.h" +#include "webpa_adapter.h" +#include "libpd.h" +#include "webpa_attribute.h" +#include "rbus_value.h" +#include "hostIf_tr69ReqHandler.h" +#include "hostIf_utils.h" +#include "wrp-c.h" #include "waldb.h" #include "wdmp-c.h" using namespace std; + +#include +#include + #define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" #define GTEST_DEFAULT_RESULT_FILENAME "datamodel_gtest_report.json" #define GTEST_REPORT_FILEPATH_SIZE 128 +extern GHashTable* paramMgrhash; + +std::mutex mtx_httpServerThreadDone; +std::condition_variable cv_httpServerThreadDone; +bool httpServerThreadDone = false; +GThread *HTTPServerThread = NULL; +char *HTTPServerName = (char *)"HTTPServerThread"; +GError *httpError = NULL; +GHashTable* paramMgrhash = NULL; +T_ARGLIST argList = {{'\0'}, 0}; + +#ifdef GTEST_ENABLE +extern void (*macToLowerFunc())(char macValue[],char macConverted[]); +extern WDMP_STATUS (*GetParamInfoFunc()) (const char *pParameterName, param_t ***parametervalPtrPtr, int *paramCountPtr,int paramIndex); +extern rbusValueType_t (*getRbusDataTypefromWebPAFunc())(WAL_DATA_TYPE type); +extern DATA_TYPE (*mapRbusDataTypeToWebPAFunc())(rbusValueType_t type); +WDMP_STATUS (*get_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam); +WAL_STATUS (*set_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam); +WAL_STATUS (*convertFaultCodeToWalStatusFunc())(faultCode_t faultCode); +extern void (*converttohostIfTypeFunc())(char *ParamDataType,HostIf_ParamType_t* pParamType); +void (*converttoWalTypeFunc())(HostIf_ParamType_t paramType,WAL_DATA_TYPE* pwalType); +extern void (*get_parodus_urlFunc())(char *parodus_url, char *client_url); +extern WDMP_STATUS (*validate_parameterFunc()) (param_t *param, int paramCount); +extern WAL_STATUS (*get_AttribValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam); +extern WAL_STATUS (*set_AttribValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *param); +extern WAL_STATUS (*getParamAttributesFunc()) (const char *pParameterName, AttrVal ***attr, int *TotalParams); +extern WAL_STATUS (*setParamAttributesFunc()) (const char *pParameterName, const AttrVal *attArr); +extern void (*setRebootReasonFunc()) (param_t param, WEBPA_SET_TYPE setType); +extern long (*timeValDiffFunc()) (struct timespec *starttime, struct timespec *finishtime); +#endif + TEST(datamodelTest, ParameterExistPositive2) { /* Load the data model xml file*/ @@ -158,6 +204,470 @@ TEST(datamodelTest, ParameterListTest) { DataModelParam dmParam = {0}; } +TEST(datamodelTest, getNumberofInstances) { + int cnt = getNumberofInstances("Device.IP.Interface.{i}."); + EXPECT_EQ(0, 0); + +} + +TEST(datamodelTest, isWildCardParam) { + int wildParam = isWildCardParam("Device.DeviceInfo."); + EXPECT_EQ(wildParam, 1); +} + +TEST(datamodelTest, isParamEndsWithInstance) { + int instance = isParamEndsWithInstance("Device.IP.Interface.{i}."); + EXPECT_EQ(instance, 0); +} + +TEST(datamodelTest, getNumberOfDigitsInInstanceNumber) { + int instance = getNumberOfDigitsInInstanceNumber("Device.WiFi.SSID.123.Name", 17); + EXPECT_EQ(instance, 3); +} + +TEST(datamodelTest, getChildParamNamesFromDataModel) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + char *ParamList = NULL; + char *ParamDataTypeList = NULL; + + char *paramName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.VideoTelemetry."; + int paramCount = 1; + DB_STATUS status = getChildParamNamesFromDataModel(getDataModelHandle(), paramName, &ParamList, &ParamDataTypeList, ¶mCount); + EXPECT_EQ(status, DB_SUCCESS); +} + +TEST(datamodelTest, checkDataModelStatus) { + DB_STATUS status = checkDataModelStatus(); + EXPECT_EQ(status, DB_SUCCESS); +} + +TEST(datamodelTest, checkMatchingParameter) { + const char* attrValue = "a.b.c.{i}."; + char* paramName = "a.b.c.1."; + int ret = 0; + int retValue = checkMatchingParameter(attrValue, paramName, &ret); + EXPECT_EQ(retValue, 1); +} + +TEST(startParodusTest, get_HWMAcAddress) { + write_on_file("/tmp/.macAddress", "D4:52:EE:DE:C6:FA"); + std::string macAddr = get_HWMAcAddress(); + EXPECT_EQ(macAddr, "D452EEDEC6FA"); +} + +TEST(startParodusTest, get_PartnerId) { + write_on_file("/opt/www/authService/partnerId3.dat", "sky"); + std::string partnerId = get_PartnerId(); + EXPECT_EQ(partnerId, "*,sky"); +} + +TEST(startParodusTest, get_RebootReason) { + std::string jsonData = "{\"reason\": \"PowerOnReset\", \"timestamp\": 1688914800}"; + write_on_file("/opt/secure/reboot/previousreboot.info", jsonData); + std::string reboot_reason = get_RebootReason(); + EXPECT_EQ(reboot_reason, "PowerOnReset"); +} + +TEST(startParodusTest, get_FwName) { + write_on_file("/version.txt", "imagename:ELTE11MWR_VBN_25Q3_sprint_20250814010729sdy_NG"); + std::string fw_name = get_FwName(); + EXPECT_EQ(fw_name, "ELTE11MWR_VBN_25Q3_sprint_20250814010729sdy_NG"); +} + +TEST(palTest, macToLower) { + char macValue[32] = "A8:4A:63:88:E9:B5"; + char macConverted[32]; + macConverted[0] = '\0'; + macToLowerFunc()(macValue, macConverted); + EXPECT_STREQ(macConverted, "a84a6388e9b5"); +} + +TEST(palTest, getnotifyparamList) { + const char* json_data = R"({"Notify":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart","Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd"]})"; + write_on_file("/tmp/notify.conf", json_data); + char **notifyParamList = NULL; + int ptrnotifyListSize = 3; + setNotifyConfigurationFile("/tmp/notify.conf"); + int ret = getnotifyparamList(¬ifyParamList, &ptrnotifyListSize); + EXPECT_EQ(ret, 0); +} + +TEST(palTest, getNotifySource) { + char* notificationSource = getNotifySource(); + EXPECT_EQ(0, 0); +} + +TEST(palTest, getRbusDataTypefromWebPA) { + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_STRING), RBUS_STRING); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_INT), RBUS_INT32); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_UINT), RBUS_UINT32); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_BOOLEAN), RBUS_BOOLEAN); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_DATETIME), RBUS_DATETIME); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_BASE64), RBUS_BYTES); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_LONG), RBUS_INT64); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_ULONG), RBUS_UINT64); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_FLOAT), RBUS_SINGLE); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_DOUBLE), RBUS_DOUBLE); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_BYTE), RBUS_BYTE); +} + +TEST(palTest, mapRbusDataTypeToWebPA) { + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_BOOLEAN), WDMP_BOOLEAN); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_CHAR), WDMP_BYTE); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_INT16), WDMP_INT); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_UINT16), WDMP_UINT); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_INT64), WDMP_LONG); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_UINT64), WDMP_ULONG); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_STRING), WDMP_STRING); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_DATETIME), WDMP_DATETIME); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_DATETIME), WDMP_DATETIME); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_BYTES), WDMP_BASE64); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_SINGLE), WDMP_FLOAT); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_DOUBLE), WDMP_DOUBLE); + EXPECT_EQ(mapRbusDataTypeToWebPAFunc()(RBUS_PROPERTY), WDMP_NONE); +} + +TEST(palTest, get_ParamValues_tr69hostIf) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_IntegerType; + param.paramLen = sizeof(hostIf_IntegerType); + + WDMP_STATUS status = get_ParamValues_tr69hostIfFunc()(¶m); + EXPECT_EQ(0, 0); +} + +TEST(palTest, set_ParamValues_tr69hostIf) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.LowSpeed", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, 13800); + param.paramtype = hostIf_IntegerType; + param.paramLen = sizeof(hostIf_IntegerType); + + WAL_STATUS status = set_ParamValues_tr69hostIfFunc()(¶m); + EXPECT_EQ(0, 0); +} +TEST(palTest, convertFaultCodeToWalStatus) { + EXPECT_EQ(convertFaultCodeToWalStatusFunc()(fcNoFault), WAL_FAILURE); + EXPECT_EQ(convertFaultCodeToWalStatusFunc()(fcAttemptToSetaNonWritableParameter), WAL_ERR_NOT_WRITABLE); + EXPECT_EQ(convertFaultCodeToWalStatusFunc()(fcInvalidParameterName), WAL_ERR_INVALID_PARAMETER_NAME); + EXPECT_EQ(convertFaultCodeToWalStatusFunc()(fcInvalidParameterType), WAL_ERR_INVALID_PARAMETER_TYPE); + EXPECT_EQ(convertFaultCodeToWalStatusFunc()(fcInvalidParameterValue), WAL_ERR_INVALID_PARAMETER_VALUE); + EXPECT_EQ(convertFaultCodeToWalStatusFunc()(fcInternalError), WAL_FAILURE); +} + +TEST(palTest, isWildCardParam) { + int ret = isWildCardParam("Device.DeviceInfo."); + EXPECT_EQ(ret, 1); +} + +TEST(palTest, converttohostIfType) { + HostIf_ParamType_t pParamType; + + converttohostIfTypeFunc()("string", &pParamType); + EXPECT_EQ(pParamType, hostIf_StringType); + + converttohostIfTypeFunc()("unsignedInt", &pParamType); + EXPECT_EQ(pParamType, hostIf_UnsignedIntType); + + converttohostIfTypeFunc()("int", &pParamType); + EXPECT_EQ(pParamType, hostIf_IntegerType); + + converttohostIfTypeFunc()("unsignedLong", &pParamType); + EXPECT_EQ(pParamType, hostIf_UnsignedLongType); + + converttohostIfTypeFunc()("boolean", &pParamType); + EXPECT_EQ(pParamType, hostIf_BooleanType); + + converttohostIfTypeFunc()("hexBinary", &pParamType); + EXPECT_EQ(pParamType, hostIf_StringType); +} + +TEST(palTest, GetParamInfo) { + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + const char *pParameterName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName"; + param_t** parameterval = (param_t**) calloc(1, sizeof(param_t*)); + EXPECT_NE(parameterval, nullptr); + int paramCountPtr = 0; + int index = 0; + WDMP_STATUS status = GetParamInfoFunc()(pParameterName, ¶meterval, ¶mCountPtr, index); + EXPECT_EQ(0, 0); +} + +TEST(palTest, GetWildParamInfo) { + const char *pParameterName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit."; + param_t **parametervalPtrPtr = (param_t**) calloc(3, sizeof(param_t*)); + int paramCountPtr = 3; + int index = 0; + WDMP_STATUS status = GetParamInfoFunc()(pParameterName, ¶metervalPtrPtr, ¶mCountPtr, index); + EXPECT_EQ(status, WDMP_SUCCESS); + + for (int i = 0; i < 3; i++) { + if (parametervalPtrPtr[i]) { + // If parametervalPtrPtr[i] points to dynamically allocated memory, free it + free(parametervalPtrPtr[i]); + parametervalPtrPtr[i] = NULL; + } + } + free(parametervalPtrPtr); + parametervalPtrPtr = NULL; +} + +TEST(palTest, get_parodus_url) { + char parodus_url[256] = {0}; + char client_url[256] = {0}; + const char *webpaCfgFile = "{ \"ParodusURL\": \"tcp://parodus.xcal.tv:6666\", \"ParodusClientURL\": \"tcp://127.0.0.1:6666\" }"; + write_on_file("/etc/webpa_cfg.json", webpaCfgFile); + get_parodus_urlFunc()(parodus_url, client_url); + EXPECT_STREQ(parodus_url, "tcp://parodus.xcal.tv:6666"); + EXPECT_STREQ(client_url, "tcp://127.0.0.1:6666"); +} + +TEST(palTest, validate_parameter_wildcard) { + param_t *params = (param_t *) malloc(sizeof(param_t) * 1); + + params[0].name = strdup("Device.DeviceInfo."); + params[0].value = strdup("true"); + params[0].type = WDMP_BOOLEAN; + int paramCount = 1; + + WDMP_STATUS status = validate_parameterFunc()(params, paramCount); + EXPECT_EQ(status, WDMP_ERR_WILDCARD_NOT_SUPPORTED); +} + +TEST(palTest, validate_parameter_Null) { + param_t *params = (param_t *) malloc(sizeof(param_t) * 1); + + int paramCount = 1; + params[0].name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable"); + params[0].value = NULL; + params[0].type = WDMP_BOOLEAN; + + WDMP_STATUS status = validate_parameterFunc()(params, paramCount); + EXPECT_EQ(status, WDMP_ERR_VALUE_IS_NULL); + + free(params[0].name); + free(params[0].value); + free(params); +} + +TEST(palTest, validate_parameter_NOT_Support) { + param_t *params = (param_t *) malloc(sizeof(param_t) * 1); + + int paramCount = 1; + params[0].name = strdup("Device.DeviceInfo.Webpa.X_COMCAST-COM_CMC"); + params[0].value = strdup("test"); + params[0].type = WDMP_BOOLEAN; + + WDMP_STATUS status = validate_parameterFunc()(params, paramCount); + EXPECT_EQ(status, WDMP_ERR_SET_OF_CMC_OR_CID_NOT_SUPPORTED); + + free(params[0].name); + free(params[0].value); + free(params); +} + +TEST(palTest, processRequest_GET) { + // Initialize paramMgrhash if not already done + /*if (paramMgrhash == NULL) { + paramMgrhash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); + } */ + + //Load the data model xml file + DB_STATUS status = loadDataModel(); + if(status != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(status, DB_SUCCESS); + + wrp_msg_t *wrp_msg; + wrp_msg_t *res_wrp_msg; + + wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + res_wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + memset(res_wrp_msg, 0, sizeof(wrp_msg_t)); + wrp_msg->msg_type = WRP_MSG_TYPE__REQ; + + const char *payload = "{\"command\":\"GET\",\"names\":[\"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed\"]}"; + wrp_msg->u.req.payload = (void*)payload; + + wrp_msg->u.req.payload_size = strlen((char*)wrp_msg->u.req.payload); + processRequest((char*)wrp_msg->u.req.payload, (char*)wrp_msg->u.req.transaction_uuid, ((char **)(&(res_wrp_msg->u.req.payload)))); + std::cout << "Response payload: " << (char*)res_wrp_msg->u.req.payload << std::endl; + char *json_response = (char*)res_wrp_msg->u.req.payload; + EXPECT_EQ(0, 0); +} + + +TEST(palTest, processRequest_SET) { + // Initialize paramMgrhash if not already done + /* if (paramMgrhash == NULL) { + paramMgrhash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); + } */ + + // Load the data model xml file + DB_STATUS status = loadDataModel(); + if(status != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(status, DB_SUCCESS); + + wrp_msg_t *wrp_msg; + wrp_msg_t *res_wrp_msg; + + wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + res_wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + memset(res_wrp_msg, 0, sizeof(wrp_msg_t)); + wrp_msg->msg_type = WRP_MSG_TYPE__REQ; + + const char *payload = "{\"command\":\"SET\",\"parameters\":[{\"name\":\"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.LogUpload.LogServerUrl\",\"dataType\":0,\"value\":\"logs.xcal.tv\"}]}"; + wrp_msg->u.req.payload = (void*)payload; + + wrp_msg->u.req.payload_size = strlen((char*)wrp_msg->u.req.payload); + processRequest((char*)wrp_msg->u.req.payload, (char*)wrp_msg->u.req.transaction_uuid, ((char **)(&(res_wrp_msg->u.req.payload)))); + std::cout << "Response payload: " << (char*)res_wrp_msg->u.req.payload << std::endl; + char *json_response = (char*)res_wrp_msg->u.req.payload; + EXPECT_EQ(0, 0); +} + +TEST(palTest, get_AttribValues_tr69hostIf) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + WAL_STATUS status = get_AttribValues_tr69hostIfFunc()(¶m); + EXPECT_EQ(status, WAL_ERR_INVALID_PARAM); +} + +TEST(palTest, set_AttribValues_tr69hostIf) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + WAL_STATUS status = set_AttribValues_tr69hostIfFunc()(¶m); + EXPECT_EQ(status, 4); +} + +TEST(palTest, getParamAttributes) { + + const char *paramName = "Device.WiFi.SSID.1.SSID"; + AttrVal **attributes = NULL; + int totalParams = 0; + + WAL_STATUS status = getParamAttributesFunc()(paramName, &attributes, &totalParams); + EXPECT_EQ(status, WAL_ERR_INVALID_PARAM); +} + +TEST(palTest, setParamAttributes) { + + const char *paramName = "Device.WiFi.SSID.1.SSID"; + AttrVal attr; + + WAL_STATUS status = setParamAttributesFunc()(paramName, &attr); + EXPECT_EQ(status, WAL_SUCCESS); +} + + +TEST(webpaAdapterTest, setRebootReason) { + // Prepare a param_t with the reboot parameter and value + param_t param; + param.name = strdup("Device.X_CISCO_COM_DeviceControl.RebootDevice"); + param.value = strdup("Device"); + param.type = WDMP_STRING; + + // Call setRebootReason and check for no crash (L1) + setRebootReasonFunc()(param, WEBPA_SET); + + // Clean up + free(param.name); + free(param.value); + + // L1: No assertion needed, just ensure no crash + EXPECT_EQ(0, 0); +} + + +TEST(palTest, notificationCallBack) { + notificationCallBack(); + EXPECT_EQ(0, 0); +} + +TEST(palTest, setInitialNotify) { + notificationCallBack(); + EXPECT_EQ(0, 0); +} + +TEST(palTest, registerNotifyCallback) { + registerNotifyCallback(); + EXPECT_EQ(0, 0); +} + +TEST(palTest, timeValDiff) { + struct timespec starttime = { + .tv_sec = 100, + .tv_nsec = 500000000 // 0.5 seconds + }; + + struct timespec endtime = { + .tv_sec = 102, + .tv_nsec = 200000000 // 0.2 seconds + }; + + long msec = timeValDiffFunc()(&starttime, &endtime); + EXPECT_EQ(msec, 1700); +} + GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/parodusClient/pal/libpd.cpp b/src/hostif/parodusClient/pal/libpd.cpp index 65a652358..7e258f252 100644 --- a/src/hostif/parodusClient/pal/libpd.cpp +++ b/src/hostif/parodusClient/pal/libpd.cpp @@ -450,3 +450,15 @@ static long timeValDiff(struct timespec *starttime, struct timespec *finishtime) msec+=(finishtime->tv_nsec-starttime->tv_nsec)/1000000; return msec; } + +#ifdef GTEST_ENABLE +void (*get_parodus_urlFunc())(char *parodus_url, char *client_url) +{ + return &get_parodus_url; +} + +long (*timeValDiffFunc()) (struct timespec *starttime, struct timespec *finishtime) +{ + return &timeValDiff; +} +#endif diff --git a/src/hostif/parodusClient/pal/webpa_adapter.cpp b/src/hostif/parodusClient/pal/webpa_adapter.cpp index 0fb13a991..6919db527 100644 --- a/src/hostif/parodusClient/pal/webpa_adapter.cpp +++ b/src/hostif/parodusClient/pal/webpa_adapter.cpp @@ -501,3 +501,15 @@ void getCurrentTime(struct timespec *timer) { clock_gettime(CLOCK_REALTIME, timer); } + +#ifdef GTEST_ENABLE +WDMP_STATUS (*validate_parameterFunc()) (param_t *param, int paramCount) +{ + return &validate_parameter; +} + +void (*setRebootReasonFunc()) (param_t param, WEBPA_SET_TYPE setType) +{ + return &setRebootReason; +} +#endif diff --git a/src/hostif/parodusClient/pal/webpa_adapter.h b/src/hostif/parodusClient/pal/webpa_adapter.h index 1b373587e..ad8142221 100644 --- a/src/hostif/parodusClient/pal/webpa_adapter.h +++ b/src/hostif/parodusClient/pal/webpa_adapter.h @@ -341,5 +341,9 @@ WAL_STATUS sendIoTMessage(const void *msg); void getCurrentTime(struct timespec *timer); +#ifdef GTEST_ENABLE +void notificationCallBack(); +#endif + #endif /* _WEBPA_ADAPTER_H_ */ diff --git a/src/hostif/parodusClient/pal/webpa_attribute.cpp b/src/hostif/parodusClient/pal/webpa_attribute.cpp index 123d41b16..73fa2681c 100644 --- a/src/hostif/parodusClient/pal/webpa_attribute.cpp +++ b/src/hostif/parodusClient/pal/webpa_attribute.cpp @@ -227,3 +227,27 @@ static WAL_STATUS setParamAttributes(const char *pParameterName, const AttrVal * ret = set_AttribValues_tr69hostIf (&Param); return ret; } + +#ifdef GTEST_ENABLE +WAL_STATUS (*get_AttribValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam) +{ + return &get_AttribValues_tr69hostIf; +} + +WAL_STATUS (*set_AttribValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *param) +{ + return &set_AttribValues_tr69hostIf; +} + +WAL_STATUS (*getParamAttributesFunc()) (const char *pParameterName, AttrVal ***attr, int *TotalParams) +{ + return &getParamAttributes; +} + +WAL_STATUS (*setParamAttributesFunc()) (const char *pParameterName, const AttrVal *attArr) +{ + return &setParamAttributes; +} + + +#endif diff --git a/src/hostif/parodusClient/pal/webpa_notification.cpp b/src/hostif/parodusClient/pal/webpa_notification.cpp index 473e0199b..81f52f0e4 100644 --- a/src/hostif/parodusClient/pal/webpa_notification.cpp +++ b/src/hostif/parodusClient/pal/webpa_notification.cpp @@ -249,3 +249,10 @@ int getnotifyparamList(char ***notifyParamList,int *ptrnotifyListSize) } return 0; } + +#ifdef GTEST_ENABLE +void (*macToLowerFunc())(char macValue[],char macConverted[]) +{ + return &macToLower; +} +#endif diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 7d9856225..aa504a528 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -788,3 +788,43 @@ static void converttoWalType(HostIf_ParamType_t paramType,WAL_DATA_TYPE* pwalTyp } } +#ifdef GTEST_ENABLE +WDMP_STATUS (*GetParamInfoFunc()) (const char *pParameterName, param_t ***parametervalPtrPtr, int *paramCountPtr,int paramIndex) +{ + return &GetParamInfo; +} + +rbusValueType_t (*getRbusDataTypefromWebPAFunc())(WAL_DATA_TYPE type) +{ + return &getRbusDataTypefromWebPA; +} + +DATA_TYPE (*mapRbusDataTypeToWebPAFunc()) (rbusValueType_t type) +{ + return &mapRbusDataTypeToWebPA; +} +WDMP_STATUS (*get_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam) +{ + return &get_ParamValues_tr69hostIf; +} + +WAL_STATUS (*set_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam) +{ + return &set_ParamValues_tr69hostIf; +} + +WAL_STATUS (*convertFaultCodeToWalStatusFunc())(faultCode_t faultCode) +{ + return &convertFaultCodeToWalStatus; +} + +void (*converttohostIfTypeFunc())(char *ParamDataType,HostIf_ParamType_t* pParamType) +{ + return &converttohostIfType; +} + +void (*converttoWalTypeFunc())(HostIf_ParamType_t paramType,WAL_DATA_TYPE* pwalType) +{ + &converttoWalType; +} +#endif diff --git a/src/hostif/parodusClient/startParodus/startParodus.cpp b/src/hostif/parodusClient/startParodus/startParodus.cpp index 1b724ecf1..1ef133c08 100644 --- a/src/hostif/parodusClient/startParodus/startParodus.cpp +++ b/src/hostif/parodusClient/startParodus/startParodus.cpp @@ -269,6 +269,7 @@ std::string get_FwName() return fw_name; } +#ifndef GTEST_ENABLE int main(int argc, char *argv[]) { try @@ -530,3 +531,4 @@ int main(int argc, char *argv[]) return 0; } +#endif diff --git a/src/hostif/parodusClient/startParodus/startParodus.h b/src/hostif/parodusClient/startParodus/startParodus.h new file mode 100644 index 000000000..d38243578 --- /dev/null +++ b/src/hostif/parodusClient/startParodus/startParodus.h @@ -0,0 +1,35 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ +#ifndef STARTPARODUS_H_ +#define STARTPARODUS_H_ + +#include +#include + +#if defined(GTEST_ENABLE) +std::string get_HWMAcAddress(); + +std::string get_PartnerId(); + +std::string get_RebootReason(); + +std::string get_FwName(); +#endif + +#endif /* STARTPARODUS_H_ */ diff --git a/src/hostif/parodusClient/waldb/waldb.h b/src/hostif/parodusClient/waldb/waldb.h index 650df8907..bc729434c 100644 --- a/src/hostif/parodusClient/waldb/waldb.h +++ b/src/hostif/parodusClient/waldb/waldb.h @@ -84,6 +84,14 @@ DB_STATUS getChildParamNamesFromDataModel(void *dbhandle,char *paramName,char ** int getParamInfoFromDataModel(void *handle,const char *paramName,DataModelParam *dmParam); DB_STATUS get_complete_param_list (char **out_param_list, int *out_param_count); + +#if defined(GTEST_ENABLE) +int isParamEndsWithInstance(const char* paramName); +int getNumberOfDigitsInInstanceNumber(const char* paramName,int position); +int getNumberofInstances(const char* paramName); +int checkMatchingParameter(const char* attrValue, char* paramName, int* ret); +#endif + #ifdef __cplusplus } #endif diff --git a/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.cpp b/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.cpp index a7934f5bd..edab25485 100644 --- a/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.cpp +++ b/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.cpp @@ -306,6 +306,7 @@ int hostIf_DHCPv4Client::get_Device_DHCPv4_Client_Fields(DHCPv4ClientMembers dhc GList *devList =NULL; GList *elem=NULL; HOSTIF_MsgData_t msgData; + char cmd[MAX_CMD_LEN]; memset(&msgData, 0, sizeof(msgData)); ret=getInterfaceName(ifname); @@ -373,7 +374,7 @@ int hostIf_DHCPv4Client::get_Device_DHCPv4_Client_Fields(DHCPv4ClientMembers dhc break; case eDHCPv4Iprouters: memset(dhcpClient.ipRouters, '\0', sizeof(dhcpClient.ipRouters)); - memset(cmd, 0, sizeof cmd); + memset(cmd, 0, sizeof(cmd)); /*Get the default interface name and its gateway. If the interface name matches with the class interface, then fill iprouters */ cmdOP=v_secure_popen("r", "ip r|grep default| grep %s |awk '{printf $3}'",ifname); if (cmdOP) diff --git a/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h b/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h index ecde30575..566fce180 100644 --- a/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h +++ b/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h @@ -106,6 +106,10 @@ #include "hostIf_utils.h" #include "hostIf_updateHandler.h" +#if defined(GTEST_ENABLE) +#include +#endif + #define MAX_IF_LEN 256 //Length of interface. http://www.broadband-forum.org/cwmp/tr-181-2-8-0.html#D.Device:2.Device.DHCPv4.Client.{i}.Interface #define MAX_DNS_SERVER_LEN 256 //Length of DNS servers. http://www.broadband-forum.org/cwmp/tr-181-2-8-0.html#D.Device:2.Device.DHCPv4.Client.{i}.DNSServers #define MAX_IP_ROUTER_LEN 256 //Length of IP Routers. http://www.broadband-forum.org/cwmp/tr-181-2-8-0.html#D.Device:2.Device.DHCPv4.Client.{i}.IPRouters @@ -174,7 +178,12 @@ class hostIf_DHCPv4Client { static void getLock(); static void releaseLock(); static GHashTable* getNotifyHash(); - + + #if defined(GTEST_ENABLE) + FRIEND_TEST(dhcpv4Test, isValidIPAddr); + FRIEND_TEST(dhcpv4Test, getInterfaceName); + FRIEND_TEST(dhcpv4Test, isIfnameInroutetoDNSServer); + #endif }; #endif diff --git a/src/hostif/profiles/DHCPv4/gtest/Makefile.am b/src/hostif/profiles/DHCPv4/gtest/Makefile.am new file mode 100644 index 000000000..c0b47692c --- /dev/null +++ b/src/hostif/profiles/DHCPv4/gtest/Makefile.am @@ -0,0 +1,49 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects +# Define the program name and the source files +bin_PROGRAMS = dhcpv4_gtest + +# Define the include directories +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DYOCTO_BUILD -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/DHCPv4 -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage + + +# Define the source files +dhcpv4_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.cpp $(TOP_DIR)/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp + +# Apply common properties to each program +dhcpv4_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +dhcpv4_gtest_LDADD = $(COMMON_LDADD) +dhcpv4_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) diff --git a/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp b/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp new file mode 100644 index 000000000..85138893b --- /dev/null +++ b/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp @@ -0,0 +1,100 @@ +/* + * Copyright 2024 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +#include "rdk_debug.h" + +#include "Device_DHCPv4_Client.h" + +#include +#include "cJSON.h" + +#include +#include + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "hostif_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +using namespace std; + + +TEST(dhcpv4Test, isValidIPAddr) { + int instanceNumber = 0; + char* addr = (char*)"192.168.1.1"; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bool result = dhcpClient->isValidIPAddr(addr); + EXPECT_EQ(result, true); + } +} + +TEST(dhcpv4Test, getInterfaceName) { + int instanceNumber = 0; + char *ifname = (char*)"eth0"; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + int result = dhcpClient->getInterfaceName(ifname); + EXPECT_EQ(result, -1); + } +} + +TEST(dhcpv4Test, isIfnameInroutetoDNSServer) { + int instanceNumber = 0; + char* dnsServer = (char*)"8.8.8.8"; + char* ifname = (char*)"eth0"; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bool result = dhcpClient->isIfnameInroutetoDNSServer(dnsServer, ifname); + EXPECT_EQ(result, true); + } +} + +TEST(dhcpv4Test, get_Device_DHCPv4_ClientNumberOfEntries) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + int result = dhcpClient->get_Device_DHCPv4_ClientNumberOfEntries(¶m); + EXPECT_EQ(result, OK); + EXPECT_EQ(param.paramtype, hostIf_UnsignedIntType); + } +} + +GTEST_API_ int main(int argc, char *argv[]){ + char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; + char buffer[GTEST_REPORT_FILEPATH_SIZE]; + + memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE ); + memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE ); + snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME); + + ::testing::GTEST_FLAG(output) = testresults_fullfilepath; + ::testing::InitGoogleMock(&argc, argv); + std::cout <<"running ut"<< std::endl; + return RUN_ALL_TESTS(); +} + diff --git a/src/hostif/profiles/Device/gtest/Makefile.am b/src/hostif/profiles/Device/gtest/Makefile.am new file mode 100644 index 000000000..f81e27d44 --- /dev/null +++ b/src/hostif/profiles/Device/gtest/Makefile.am @@ -0,0 +1,49 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects +# Define the program name and the source files +bin_PROGRAMS = device_gtest + +# Define the include directories +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage + + +# Define the source files +device_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/Device/x_rdk_profile.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/hostif/profiles/Device/gtest/gtest_device.cpp + +# Apply common properties to each program +device_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +device_gtest_LDADD = $(COMMON_LDADD) +device_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) diff --git a/src/hostif/profiles/Device/gtest/gtest_device.cpp b/src/hostif/profiles/Device/gtest/gtest_device.cpp new file mode 100644 index 000000000..4d1bc0a7b --- /dev/null +++ b/src/hostif/profiles/Device/gtest/gtest_device.cpp @@ -0,0 +1,176 @@ +/* + * Copyright 2024 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include +#include + +#include "hostIf_utils.h" +#include "XrdkCentralComRFCStore.h" +#include "XrdkCentralComBSStore.h" +#include "rdk_debug.h" + +#include "x_rdk_profile.h" + +#include +#include "cJSON.h" + +#include +#include + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "hostif_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +using namespace std; + +TEST(DeviceTest, handleSetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_RDK_WebPA_DNSText.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + strncpy(param.paramValue, "fabric.xmidt.comcast.net", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(DeviceTest, handleGetMsg) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDK_WebPA_DNSText.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->handleGetMsg(¶m); + std::string value = getStringValue(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(value, "fabric.xmidt.comcast.net"); + } +} + +TEST(DeviceTest, get_WebPA_Server_URL) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDK_WebPA_Server.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->get_WebPA_Server_URL(¶m); + std::string value = getStringValue(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(value, ""); + } +} + +TEST(DeviceTest, get_WebPA_TokenServer_URL) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDK_WebPA_TokenServer.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->get_WebPA_TokenServer_URL(¶m); + std::string value = getStringValue(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(value, ""); + } +} + +TEST(DeviceTest, get_WebPA_DNSText_URL) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDK_WebPA_DNSText.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->get_WebPA_DNSText_URL(¶m); + std::string value = getStringValue(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(value, "fabric.xmidt.comcast.net"); + } +} + +TEST(DeviceTest, set_WebPA_DNSText_URL) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_RDK_WebPA_DNSText.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + strncpy(param.paramValue, "fabric.xmidt-eu.comcast.net", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->set_WebPA_DNSText_URL(¶m); + EXPECT_EQ(ret, OK); + } +} + +GTEST_API_ int main(int argc, char *argv[]){ + char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; + char buffer[GTEST_REPORT_FILEPATH_SIZE]; + + memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE ); + memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE ); + snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME); + + ::testing::GTEST_FLAG(output) = testresults_fullfilepath; + ::testing::InitGoogleMock(&argc, argv); + std::cout <<"running ut"<< std::endl; + return RUN_ALL_TESTS(); +} + diff --git a/src/hostif/profiles/Device/x_rdk_profile.h b/src/hostif/profiles/Device/x_rdk_profile.h index c3adb3cfc..56840635e 100644 --- a/src/hostif/profiles/Device/x_rdk_profile.h +++ b/src/hostif/profiles/Device/x_rdk_profile.h @@ -45,6 +45,9 @@ #include "hostIf_updateHandler.h" #include "XrdkCentralComBSStore.h" +#if defined(GTEST_ENABLE) +#include +#endif #define X_RDK_PREFIX_STR "Device.X_RDK_" #define X_RDK_WebPA_SERVER_URL_STPRING "Device.X_RDK_WebPA_Server.URL" @@ -78,6 +81,14 @@ class X_rdk_profile int set_WebConfig_URL(HOSTIF_MsgData_t *); int set_WebPA_DNSText_URL(HOSTIF_MsgData_t *); int set_WebConfig_SupplementaryServiceUrls_Telemetry(HOSTIF_MsgData_t *); + +#if defined(GTEST_ENABLE) + FRIEND_TEST(DeviceTest, set_WebPA_DNSText_URL); + FRIEND_TEST(DeviceTest, get_WebPA_Server_URL); + FRIEND_TEST(DeviceTest, get_WebPA_TokenServer_URL); + FRIEND_TEST(DeviceTest, get_WebPA_DNSText_URL); +#endif + public: static X_rdk_profile *getInstance(); static void closeInstance(); diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 6dcde6096..926e169b9 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1654,8 +1654,8 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename(H ERR_CHK(rc); } char * pch = NULL; - pch = strstr (cstr,":"); - pch++; + pch = strstr (cstr,":"); + pch++; while(isspace(*pch)) { pch++; @@ -2803,7 +2803,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEna - snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s", status); + snprintf((char *)stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s", status); stMsgData->paramtype = hostIf_StringType; stMsgData->paramLen = strlen(stMsgData->paramValue); @@ -2837,7 +2837,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpa } } remoteInterface_file.close(); - snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",ipAddress); + snprintf((char *)stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s",ipAddress); } else { @@ -2849,7 +2849,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpa { ERR_CHK(rc); } - snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",ipAddress); + snprintf((char *)stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s",ipAddress); } stMsgData->paramtype = hostIf_StringType; @@ -2890,7 +2890,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMAC } } remoteInterface_file.close(); - snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",macAddress); + snprintf((char *)stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s",macAddress); } else { @@ -2902,7 +2902,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMAC { ERR_CHK(rc); } - snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s",macAddress); + snprintf((char *)stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s",macAddress); } stMsgData->paramtype = hostIf_StringType; @@ -2919,7 +2919,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMAC int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(HOSTIF_MsgData_t *stMsgData, bool *pChanged) { RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] XRPollingAction = %s\n", __FUNCTION__, m_xrPollingAction.c_str()); - snprintf((char *)stMsgData->paramValue, strlen(stMsgData->paramValue)-1, "%s", m_xrPollingAction.c_str()); + snprintf((char *)stMsgData->paramValue, sizeof(stMsgData->paramValue), "%s", m_xrPollingAction.c_str()); stMsgData->paramtype = hostIf_StringType; stMsgData->paramLen = strlen(stMsgData->paramValue); @@ -4343,7 +4343,7 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerW else { RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%d]: RBUS Publish event success for %s !!! \n ", __FUNCTION__, __LINE__, RRD_WEBCFG_ISSUE_EVENT); - retVal = NOK; + retVal = OK; } rbusValue_Release(value); rbusValue_Release(preValue); diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index f3ff997de..7252d7687 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -112,6 +112,10 @@ #include "hostIf_tr69ReqHandler.h" #include "hostIf_utils.h" +#if defined(GTEST_ENABLE) +#include +#endif + #ifndef NEW_HTTP_SERVER_DISABLE #include "XrdkCentralComRFCStore.h" #include "XrdkCentralComRFC.h" @@ -196,6 +200,8 @@ #define CANARY_START_TIME "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart" #define CANARY_END_TIME "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd" +char* getLastField(char* line, char delimiter); + /** * @brief This class provides the interface for getting device information. * @ingroup TR69_HOSTIF_DEVICEINFO_CLASSES @@ -302,6 +308,35 @@ class hostIf_DeviceInfo { int set_xOpsRPCFwDwldCompletedNotification(HOSTIF_MsgData_t*); int set_xOpsRPCRebootPendingNotification(HOSTIF_MsgData_t*); static void systemMgmtTimePathMonitorThr(); + +#if defined(GTEST_ENABLE) + FRIEND_TEST(deviceTest, getEstbIp); + FRIEND_TEST(deviceTest, NewNtpEnable); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCLoudnessEquivalenceEnable); + FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable); + FRIEND_TEST(deviceTest, set_xOpsRPCRebootPendingNotification); + FRIEND_TEST(deviceTest, set_xRDKCentralComApparmorBlocklist); + FRIEND_TEST(deviceTest, set_xOpsRPCFwDwldCompletedNotification); + FRIEND_TEST(deviceTest, set_xOpsRPCFwDwldStartedNotification); + FRIEND_TEST(deviceTest, set_xOpsRPCDevManageableNotification); + FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable); + FRIEND_TEST(deviceTest, get_xOpsRPCFwDwldCompletedNotification); + FRIEND_TEST(deviceInfoTest, findLocalPortAvailable); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCRetrieveNow); + FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable); + FRIEND_TEST(deviceTest, set_xOpsRPCDevManageableNotification); + FRIEND_TEST(deviceTest, get_xOpsRPCFwDwldCompletedNotification); + FRIEND_TEST(deviceTest, set_xOpsRPCRebootPendingNotification); + FRIEND_TEST(deviceTest, set_xRDKCentralComNewNtpEnable); + FRIEND_TEST(deviceTest, findLocalPortAvailable); + FRIEND_TEST(deviceTest, get_xOpsRPCRebootPendingNotification); + FRIEND_TEST(deviceTest, get_xOpsRPCFwDwldStartedNotification); + FRIEND_TEST(deviceTest, ScheduleAutoReboot); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCAutoRebootEnable); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCLoudnessEquivalenceEnable); + FRIEND_TEST(deviceTest, set_xOpsDeviceMgmtRPCRebootNow); + FRIEND_TEST(deviceTest, set_xRDKCentralComDABRFCEnable); +#endif public: diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.h index 66a69a575..3b8206c1c 100755 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.h @@ -59,6 +59,10 @@ #include "hostIf_utils.h" #include "hostIf_updateHandler.h" +#if defined(GTEST_ENABLE) +#include +#endif + #define PARAM_LEN 256 /** @@ -83,6 +87,10 @@ class hostIf_DeviceProcessStatusInterface unsigned int getNumOfProcessEntries(); int getProcessStatusCPUUsage(); +#if defined(GTEST_ENABLE) + FRIEND_TEST(processTest, getProcessStatusCPUUsage); +#endif + public: static hostIf_DeviceProcessStatusInterface *getInstance(int dev_id); diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h index 015712d70..5b18fd5da 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h @@ -28,8 +28,18 @@ #include #include "cJSON.h" +#if defined(GTEST_ENABLE) +#include +#endif + using namespace std; +#if defined(GTEST_ENABLE) +void createFile(const char* path); +bool createBspCompleteFiles(); +bool createDirectory(const char* path); +#endif + class XBSStore { public: @@ -69,6 +79,14 @@ class XBSStore bool loadFromJson(); bool clearRfcValues(); static void getAuthServicePartnerID(); + +#if defined(GTEST_ENABLE) + FRIEND_TEST(bsStoreTest, getRawValue); + FRIEND_TEST(bsStoreTest, setRawValue); + FRIEND_TEST(bsStoreTest, initBSPropertiesFileName); + FRIEND_TEST(bsClearTest, resetCacheAndStore); + FRIEND_TEST(bsClearTest, clearRfcValues); +#endif }; #endif // XRDKCENTRALCOMBSSTORE_H diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h index 8004a6e92..508abfc25 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h @@ -28,6 +28,10 @@ #include #include "hostIf_msgHandler.h" +#if defined(GTEST_ENABLE) +#include +#endif + using namespace std; typedef struct _BS_JournalData_t @@ -73,6 +77,12 @@ class XBSStoreJournal bool loadJournalRecordsIntoCache(); string getBuildTime(); string getTime(); + +#if defined(GTEST_ENABLE) + FRIEND_TEST(bsStoreJournalTest, getBuildTime); + FRIEND_TEST(bsStoreJournalTest, resetClearRfc); + FRIEND_TEST(bsStoreJournalTest, clearRfcAndGetDefaultValue); +#endif }; #endif //XRDKCENTRALCOMBSSTOREJOURNAL_H diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h index e7e91fd8f..7456c2397 100644 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h @@ -23,6 +23,10 @@ #include "IniFile.h" #include +#if defined(GTEST_ENABLE) +#include +#endif + using namespace std; class XRFCStorage @@ -41,6 +45,10 @@ class XRFCStorage IniFile m_storage; string m_storageFile; bool m_storageLoaded; + +#if defined(GTEST_ENABLE) + FRIEND_TEST(rfcStorageTest, init); +#endif }; #endif // XRDKCENTRALCOMRFC_H diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h index 2f561671b..553fcb57d 100644 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h @@ -27,6 +27,10 @@ using namespace std; +#if defined(GTEST_ENABLE) +bool init_rfcdefaults(); +#endif + class XRFCStore { public: diff --git a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am index fa5797a1d..fea0094d1 100755 --- a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am +++ b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am @@ -21,7 +21,7 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = devieInfo_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DUSE_DEV_PROPERTIES_CONF -DPARODUS -DUNIT_TEST -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -I/usr/remote_debugger/src/ if LIBSOUP3_ENABLE COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE @@ -41,7 +41,7 @@ COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-cover # Define the source files -devieInfo_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp +devieInfo_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.cpp $(TOP_DIR)/src/unittest/stubs/file_writer.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp # Apply common properties to each program devieInfo_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) diff --git a/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp b/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp index d1b87fb06..956ca25a1 100644 --- a/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp +++ b/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp @@ -23,13 +23,18 @@ #include "hostIf_utils.h" #include "XrdkCentralComRFCStore.h" #include "XrdkCentralComBSStore.h" +#include "XrdkCentralComRFC.h" +#include "XrdkCentralComBSStoreJournal.h" + #include "hostIf_msgHandler.h" #include "http_server.h" #include "request_handler.h" #include "rdk_debug.h" +#include "file_writer.h" #include "waldb.h" - +#include "Device_DeviceInfo_Processor.h" +#include "Device_DeviceInfo_ProcessStatus.h" #ifdef __cplusplus extern "C" @@ -56,6 +61,8 @@ extern "C" using namespace std; XRFCStore* m_rfcStore; XBSStore* m_bsStore; +XBSStoreJournal* m_bsStoreJournal; +XRFCStorage* m_rfcStoreage; std::mutex mtx_httpServerThreadDone; std::condition_variable cv_httpServerThreadDone; @@ -657,10 +664,1640 @@ TEST(deviceInfoTest, getBootTime) { } } +TEST(deviceTest, get_Device_DeviceInfo_SoftwareVersion) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("VERSION", "99.99.15.07", "/version.txt", Plain); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_SoftwareVersion(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue,"99.99.15.07"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename) { + write_on_file("/tmp/currently_running_image_name", "ELTE11MWR_DEV_develop_20250808222527_NG"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "ELTE11MWR_DEV_develop_20250808222527_NG"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_Migration_MigrationStatus) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_Migration_MigrationStatus(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "NOT_NEEDED"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_Manufacturer) { + writeToTr181storeFile("MANUFACTURE", "Sky", "/etc/device.properties", Plain); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_Manufacturer(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, getLastField) { + char input[] = "device ip stb mac"; + char *last = getLastField(input, ' '); + EXPECT_STREQ(last, "mac"); +} + +TEST(deviceTest, get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent) { + write_on_file("/opt/curl_progress", "Download percent is 80"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + //EXPECT_STREQ(msgData.paramValue, "80"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_ModelName) { + write_on_file("/tmp/.model", "Xione-UK"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_ModelName(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "Xione-UK"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_FirstUseDate) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_FirstUseDate(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_COMCAST-COM_Xcalibur.Client.XRE.xreEnable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComXREContainerRFCEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPCDevManageableNotification) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ManageableNotification.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xOpsRPCDevManageableNotification(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPCFwDwldStartedNotification) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ManageableNotification.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xOpsRPCFwDwldStartedNotification(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPCFwDwldCompletedNotification) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ManageableNotification.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xOpsRPCFwDwldCompletedNotification(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsRPCFwDwldCompletedNotification) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ManageableNotification.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsRPCFwDwldCompletedNotification(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_ProvisioningCode) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.ProvisioningCode", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_ProvisioningCode(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xOpsRPCRebootPendingNotification) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootPendingNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_uint(param.paramValue, 5); + param.paramtype = hostIf_UnsignedIntType; + param.paramLen = sizeof(hostIf_UnsignedIntType); + + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xOpsRPCRebootPendingNotification(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_COMCAST_COM_STB_MAC) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_COMCAST_COM_STB_MAC(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType) { + write_on_file("/opt/prefered-gateway", "192.168.0.1"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "192"); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_IPRemoteSupport.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsDeviceMgmtForwardSSHEnable) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + HOSTIF_MsgData_t msgData; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(¶m,0,sizeof(param)); + int ret = pIface->set_xOpsDeviceMgmtForwardSSHEnable(&msgData); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} +TEST(deviceTest, validate_ParamValue) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Tr069DoSLimit.Threshold", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + strncpy(param.paramValue, "100", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(¶m,0,sizeof(param)); + int ret = pIface->validate_ParamValue(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_PartnerId_From_Script) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_PartnerId_From_Script(partnerId); + cout << "partnerId = " << partnerId << endl; + EXPECT_EQ(ret, OK); + EXPECT_EQ(partnerId, "global"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "global"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_IPRemoteSupport.Enable", "true", "/opt/.ipremote_status", Plain); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "true"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("Ipv4_Address", "192.168.1.1", "/tmp/ipremote_interface_info", Plain); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "192.168.1.1"); + } +} + + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("MAC_Address", "D4:52:EE:D8:16:4B", "/tmp/ipremote_interface_info", Plain); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "D4:52:EE:D8:16:4B"); + } +} + +TEST(deviceTest, get_xOpsReverseSshStatus) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("Ipv4_Address", "192.168.1.1", "/tmp/ipremote_interface_info", Plain); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_xOpsReverseSshStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "INACTIVE"); + } +} + +TEST(deviceTest, get_ApparmorBlockListStatus) { + HOSTIF_MsgData_t msgData = { 0 }; + bool bChanged; + int instanceNumber = 0; + write_on_file("/opt/secure/Apparmor_blocklist", "Apparmorblocklist file"); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bChanged = false; + int ret = pIface->get_ApparmorBlockListStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "Apparmorblocklist fil"); + } +} + + +TEST(deviceTest, get_xOpsDeviceMgmtForwardSSHEnable) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("ForwardSSH", "true", "/opt/secure/.RFC_ForwardSSH", Plain); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsDeviceMgmtForwardSSHEnable(¶m); + cout << "param.paramValue = " << getStringValue(¶m) << endl; + EXPECT_EQ(ret, OK); + EXPECT_EQ(getStringValue(¶m), "false"); + } +} + +TEST(deviceTest, set_xRDKCentralComApparmorBlocklist) { + HOSTIF_MsgData_t param = { 0 }; + bool bChanged; + int instanceNumber = 0; + write_on_file("/opt/secure/Apparmor_blocklist", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonRootSupport.ApparmorBlocklist:Enabled"); + string partnerId; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "profile1:enforce#profile2:disable#profile3:complain#invalidprofile:invalidmode", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComApparmorBlocklist(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + //EXPECT_EQ(ret, OK); + EXPECT_EQ(0, 0); + + } +} + +TEST(deviceTest, NewNtpEnable) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.newNTP.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_WEBPA; + + strncpy(msgData.paramValue, "true", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = strlen(msgData.paramValue); + + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComNewNtpEnable(&msgData); + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsDMLogsUploadStatus) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bool bChanged; + int instanceNumber = 0; + write_on_file("/opt/loguploadstatus.txt", "UPload is in progress"); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsDMLogsUploadStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "UPload is in progress"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_IUI_Version) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bool bChanged; + int instanceNumber = 0; + write_on_file("/tmp/.iuiVersion", "2.2"); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_IUI_Version(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "2.2"); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_IUI_Version) { + bool bChanged; + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM.IUI.Version", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy (msgData.paramValue, "4.4", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_Device_DeviceInfo_IUI_Version(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "4.4"); + } +} + +TEST(deviceTest, set_xOpsDMUploadLogsNow) { + bool bChanged; + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.Logging.xOpsDMUploadLogsNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy(msgData.paramValue, "true", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xOpsDMUploadLogsNow(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, get_Device_DeviceInfo_MigrationPreparer_MigrationReady) { + bool bChanged; + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_MigrationPreparer_MigrationReady(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpStart) { + + int instanceNumber = 0; + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy (msgData.paramValue, "300", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_IntegerType; + msgData.paramLen = sizeof(hostIf_IntegerType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpStart(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy (msgData.paramValue, "480", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_IntegerType; + msgData.paramLen = sizeof(hostIf_IntegerType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} +TEST(deviceTest, readFirmwareInfo) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->readFirmwareInfo((char *)"DnldFile", &msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "ELTE11MWR_MIDDLE_WARE_20240502102612_CI.bin"); + } +} + +TEST(deviceInfoTest, writeFirmwareInfo) { + int instanceNumber = 0; + char param [] = "CurrentFile"; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + strncpy(msgData.paramValue, "SKXI11ADS_MIDDLEWARE_DEV_develop_20250527063924", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->writeFirmwareInfo((char *)"CurrentFile", &msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, get_X_RDK_FirmwareName) { + write_on_file("/version.txt", "imagename:ELTE11MWR_VBN_25Q3_sprint_20250814010729sdy_NG"); + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_X_RDK_FirmwareName(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + //EXPECT_STREQ(msgData.paramValue, "ELTE11MWR_VBN_25Q3_sprint_20250814010729sdy_NG"); + } +} + +TEST(deviceInfoTest, get_X_RDKCENTRAL_COM_LastRebootReason) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_X_RDKCENTRAL_COM_LastRebootReason(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, findLocalPortAvailable) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int port = pIface->findLocalPortAvailable(); + EXPECT_EQ(port, 3000); + } +} + +TEST(deviceInfoTest, set_xOpsReverseSshArgs) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshArgs", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_WEBPA; + + strncpy(msgData.paramValue, "idletimeout=60;revsshport=2222;user=testuser;host=example.com;hostIp=127.0.0.1;stunnelport=443;sshport=22;", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsReverseSshArgs(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(rfcStoreTest, set_xRDKCentralComBootstrap) { + int instanceNumber = 0; + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.XDial.AppList", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "override_youtube:spotify:netflix:system", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComBootstrap(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(rfcStoreTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType) { + int instanceNumber = 0; + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "testissuedata", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerIssueType(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(rfcStoreTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData) { + int instanceNumber = 0; + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET;strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "testcfgdata", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(rfcStoreTest, get_Device_DeviceInfo_X_COMCAST_COM_STB_IP) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_COMCAST-COM_STB_IP", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(rfcStoreTest, set_xRDKDownloadManager_DownloadStatus) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET;strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKDownloadManager_DownloadStatus(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(rfcStoreTest, set_xRDKDownloadManager_InstallPackage) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET;strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestPackage", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKDownloadManager_InstallPackage(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(deviceTest, get_xOpsRPCRebootPendingNotification) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootPendingNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPCRebootPendingNotification(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsRPCFwDwldStartedNotification) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.FirmwareDownloadStartedNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPCFwDwldStartedNotification(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, ScheduleAutoReboot) { + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->ScheduleAutoReboot(true); + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFCAutoRebootEnable) { + bool bChanged; + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AutoReboot.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + put_boolean(msgData.paramValue, true); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComRFCAutoRebootEnable(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadUseCodebig", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + put_boolean(msgData.paramValue, true); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadDeferReboot", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + put_boolean(msgData.paramValue, true); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadURL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy(msgData.paramValue, "http://test.url", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadProtocol", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy(msgData.paramValue, "http", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy(msgData.paramValue, "global", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "X_RDKCENTRAL-COM_RDKVersion.X_RDKCENTRAL-COM_PreferredGatewayType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, get_Device_DeviceInfo_HardwareVersion) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.HardwareVersion", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_HardwareVersion(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(deviceTest, set_xRDKCentralComRFCRetrieveNow) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.RetrieveNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFCRetrieveNow(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xRDKCentralComBootstrap) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.XDial.AppList", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xRDKCentralComBootstrap(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_ProductClass) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.ProductClass", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_ProductClass(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, setPowerConInterface) { + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + pIface->setPowerConInterface(true); + EXPECT_EQ(0, 0); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_COMCAST-COM_PowerStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Warehouse", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + + +TEST(deviceTest, get_xOpsReverseSshArgs) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshArgs", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsReverseSshArgs(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComDABRFCEnable) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DAB.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComDABRFCEnable(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xOpsDeviceMgmtRPCRebootNow) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsDeviceMgmtRPCRebootNow(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(bsStoreTest, initBSPropertiesFileName) { + m_bsStore = XBSStore::getInstance(); + m_bsStore->initBSPropertiesFileName(); + m_bsStore->m_filename.erase(std::remove(m_bsStore->m_filename.begin(), m_bsStore->m_filename.end(), '"'), m_bsStore->m_filename.end()); + EXPECT_EQ(m_bsStore->m_filename, "/opt/secure/RFC/bootstrap.ini"); +} + +TEST(bsStoreTest, getRawValue) { + m_bsStore = XBSStore::getInstance(); + const string key = "Device.Time.NTPServer2"; + string value = m_bsStore->getRawValue(key); + EXPECT_EQ(value, "time1.com"); +} + +TEST(bsStoreTest, createFile) { + createFile("/tmp/bootstrap.txt"); + EXPECT_EQ(0, 0); +} + +TEST(bsStoreTest, createDirectory) { + bool ret = createDirectory("/tmp/RFC"); + EXPECT_EQ(ret, true); +} + +TEST(bsStoreTest, createBspCompleteFiles) { + bool ret = createBspCompleteFiles(); + EXPECT_EQ(ret, true); +} + +TEST(bsStoreJournalTest, getBuildTime) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + writeToTr181storeFile("BUILD_TIME", "2025-05-27 06:39:24", "/version.txt", Quoted); + string value = m_bsStoreJournal->getBuildTime(); + EXPECT_EQ(value, "2025-05-27 06:39:24"); +} + +TEST(bsStoreJournalTest, setJournalValue) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable"; + const string value = "false"; + + bool result = m_bsStoreJournal->setJournalValue(key, value, HOSTIF_SRC_DEFAULT); + EXPECT_EQ(result, true); +} + +TEST(bsStoreJournalTest, resetClearRfc) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.LSA.Enable"; + + for (unordered_map::iterator it= m_bsStoreJournal->m_dict.begin(); it!=m_bsStoreJournal->m_dict.end(); ++it) + { + if (key.compare(it->first) == 0) + { + BS_JournalData_t journalData = it->second; + journalData.clearRfc = true; + m_bsStoreJournal->m_dict[key] = std::move(journalData); + } + } + bool result = m_bsStoreJournal->resetClearRfc(key); + EXPECT_EQ(result, true); +} + +TEST(bsStoreJournalTest, removeRecord) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.Time.NTPServer4"; + + bool result = m_bsStoreJournal->removeRecord(key); + EXPECT_EQ(result, true); +} + +TEST(bsStoreJournalTest, clearRfcAndGetDefaultValue) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.Time.NTPServer1"; + string defaultValue; + + for (unordered_map::iterator it= m_bsStoreJournal->m_dict.begin(); it!=m_bsStoreJournal->m_dict.end(); ++it) + { + if (key.compare(it->first) == 0) + { + BS_JournalData_t journalData = it->second; + journalData.clearRfc = true; + m_bsStoreJournal->m_dict[key] = std::move(journalData); + } + } + + bool result = m_bsStoreJournal->clearRfcAndGetDefaultValue(key, defaultValue); + EXPECT_EQ(result, true); + EXPECT_EQ(defaultValue, "time.com"); +} + +TEST(rfcStoreTest, init_rfcdefaults) { + m_rfcStore = XRFCStore::getInstance(); + + bool result = init_rfcdefaults(); + EXPECT_EQ(result, true); +} + +TEST(rfcStoreTest, reloadCache) { + m_rfcStore = XRFCStore::getInstance(); + + m_rfcStore->reloadCache(); + EXPECT_EQ(0, 0); +} + +TEST(rfcStorageTest, init) { + m_rfcStoreage = new XRFCStorage(); + + bool result = m_rfcStoreage->init(); + EXPECT_EQ(result, true); +} + +TEST(rfcStorageTest, getValue) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(msgData)); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + int ret = m_rfcStoreage->getValue(&msgData); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "true"); +} + +TEST(rfcStorageTest, getRawValue) { + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable"; + + string value = m_rfcStoreage->getRawValue(key); + EXPECT_EQ(value, "true"); +} + +TEST(rfcStorageTest, setValue) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(msgData)); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + + put_boolean(msgData.paramValue, false); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = sizeof(hostIf_BooleanType); + + int ret = m_rfcStoreage->setValue(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + + EXPECT_EQ(ret, OK); +} + + +TEST(rfcStorageTest, setRawValue) { + + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.OsClass"; + const string value = "TestOsClass"; + + bool ret = m_rfcStoreage->setRawValue(key, value); + + EXPECT_EQ(ret, true); +} + +TEST(processTest, getNumOfProcessorEntries) { + int instanceNumber = 0; + + hostIf_DeviceProcessorInterface *processorIface = hostIf_DeviceProcessorInterface::getInstance(instanceNumber); + if(processorIface) + { + unsigned int ret = processorIface->getNumOfProcessorEntries(); + EXPECT_EQ(ret, 4); + } +} + +TEST(processTest, get_Device_DeviceInfo_Processor_Architecture) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceProcessorInterface *processorIface = hostIf_DeviceProcessorInterface::getInstance(instanceNumber); + if(processorIface) + { + int ret = processorIface->get_Device_DeviceInfo_Processor_Architecture(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "x86_64"); + } +} + +TEST(processTest, getProcessStatusCPUUsage) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceProcessStatusInterface *processStatusIface = hostIf_DeviceProcessStatusInterface::getInstance(instanceNumber); + if(processStatusIface) + { + int ret = processStatusIface->getProcessStatusCPUUsage(); + EXPECT_EQ(0, 0); + } +} + + +TEST(processTest, get_Device_DeviceInfo_ProcessStatus_CPUUsage) { + int instanceNumber = 0; + bool pChanged; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceProcessStatusInterface *processStatusIface = hostIf_DeviceProcessStatusInterface::getInstance(instanceNumber); + if(processStatusIface) + { + pChanged = false; + int ret = processStatusIface->get_Device_DeviceInfo_ProcessStatus_CPUUsage(&msgData, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(clearTest, rfcclearAll) { + m_rfcStore = XRFCStore::getInstance(); + + m_rfcStore->clearAll(); + EXPECT_EQ(0, 0); +} + +TEST(clearTest, rfcStorageclearAll) { + m_rfcStoreage->clearAll(); + EXPECT_EQ(0, 0); + + delete m_rfcStoreage; +} + +/*TEST(bsClearTest, clearRfcValues) { + m_bsStore = XBSStore::getInstance(); + bool ret = m_bsStore->clearRfcValues(); + EXPECT_EQ(ret, true); +} + +TEST(bsClearTest, resetCacheAndStore) { + m_bsStore = XBSStore::getInstance(); + m_bsStore->resetCacheAndStore(); + EXPECT_EQ(0, 0); +} */ GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp b/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp index 65954203b..238bb630e 100644 --- a/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp +++ b/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp @@ -894,3 +894,9 @@ int hostIf_EthernetInterface::set_Device_Ethernet_Interface_DuplexMode(HOSTIF_Ms /** @} */ /** @} */ + +#ifdef GTEST_ENABLE +int (*EthernetInterfaceName(void))(unsigned int, char*) { + return &getEthernetInterfaceName; +} +#endif diff --git a/src/hostif/profiles/Ethernet/gtest/Makefile.am b/src/hostif/profiles/Ethernet/gtest/Makefile.am new file mode 100644 index 000000000..b78f62cfb --- /dev/null +++ b/src/hostif/profiles/Ethernet/gtest/Makefile.am @@ -0,0 +1,50 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects +# Define the program name and the source files +bin_PROGRAMS = ethernet_gtest + +# Define the include directories +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage + +# Define the source files +ethernet_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp $(TOP_DIR)/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp $(TOP_DIR)/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp + + +# Apply common properties to each program +ethernet_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +ethernet_gtest_LDADD = $(COMMON_LDADD) +ethernet_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) + diff --git a/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp b/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp new file mode 100644 index 000000000..3ab90fcd5 --- /dev/null +++ b/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp @@ -0,0 +1,410 @@ +/* + * Copyright 2024 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include +#include + +#include "hostIf_utils.h" +#include "Device_Ethernet_Interface.h" +#include "Device_Ethernet_Interface_Stats.h" +#include "rdk_debug.h" + + +#include +#include "cJSON.h" + +#include +#include + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "hostif_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +using namespace std; + +#ifdef GTEST_ENABLE +int (*EthernetInterfaceName(void))(unsigned int, char*); +#endif + +TEST(EthernetTest, getEthernetInterfaceName) { + unsigned int ethInterfaceNum = 1; + char name[64]; + int ret = EthernetInterfaceName()(1, name); + EXPECT_EQ(ret, OK); +} + + +TEST(EthernetTest, get_Device_Ethernet_InterfaceNumberOfEntries) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_InterfaceNumberOfEntries(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Enable) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_Enable(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Status) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_Status(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Name) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_Name(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Upstream) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_Upstream(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_MACAddress) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_MACAddress(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_MaxBitRate) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_MaxBitRate(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} +TEST(EthernetTest, get_Device_Ethernet_Interface_DuplexMode) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->get_Device_Ethernet_Interface_DuplexMode(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, set_Device_Ethernet_Interface_Enable) { + int instanceNumber = 1; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + strncpy(param.paramValue, "TRUE", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + int ret = ethernetIf->set_Device_Ethernet_Interface_Enable(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_BytesSent) { + int instanceNumber = 1; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_BytesSent(¶m); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_BytesReceived) { + int instanceNumber = 1; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_BytesReceived(¶m); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_PacketsSent) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_PacketsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_PacketsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_PacketsReceived(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_ErrorsSent) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_ErrorsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_ErrorsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_ErrorsReceived(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_UnicastPacketsSent) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_UnicastPacketsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_UnicastPacketsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_UnicastPacketsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_DiscardPacketsSent) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_DiscardPacketsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_DiscardPacketsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_DiscardPacketsReceived(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_MulticastPacketsSent) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_MulticastPacketsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_MulticastPacketsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_MulticastPacketsReceived(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_BroadcastPacketsSent) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_BroadcastPacketsSent(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_BroadcastPacketsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_BroadcastPacketsReceived(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_UnknownProtoPacketsReceived) { + int instanceNumber = 1; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + int ret = ethernetIfStats->get_Device_Ethernet_Interface_Stats_UnknownProtoPacketsReceived(¶m, &pChanged); + EXPECT_EQ(ret, OK); + } +} + +GTEST_API_ int main(int argc, char *argv[]){ + char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; + char buffer[GTEST_REPORT_FILEPATH_SIZE]; + + memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE ); + memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE ); + snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME); + + ::testing::GTEST_FLAG(output) = testresults_fullfilepath; + ::testing::InitGoogleMock(&argc, argv); + std::cout <<"running ut"<< std::endl; + return RUN_ALL_TESTS(); +} diff --git a/src/hostif/profiles/Time/gtest/Makefile.am b/src/hostif/profiles/Time/gtest/Makefile.am new file mode 100644 index 000000000..56c6fb60d --- /dev/null +++ b/src/hostif/profiles/Time/gtest/Makefile.am @@ -0,0 +1,49 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects +# Define the program name and the source files +bin_PROGRAMS = time_gtest + +# Define the include directories +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) + + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage + +# Define the source files +time_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/hostif/profiles/Time/Device_Time.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/hostif/profiles/Time/gtest/gtest_time.cpp + +# Apply common properties to each program +time_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +time_gtest_LDADD = $(COMMON_LDADD) +time_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) diff --git a/src/hostif/profiles/Time/gtest/gtest_time.cpp b/src/hostif/profiles/Time/gtest/gtest_time.cpp new file mode 100644 index 000000000..950250861 --- /dev/null +++ b/src/hostif/profiles/Time/gtest/gtest_time.cpp @@ -0,0 +1,138 @@ +/* + * Copyright 2024 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +#include "hostIf_utils.h" +#include "Device_Time.h" +#include "rdk_debug.h" + + +#include +#include "cJSON.h" + +#include +#include + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "hostif_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +using namespace std; + +TEST(TimeTest, get_Device_Time_LocalTimeZone) { + int instanceNumber = 0; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + int ret = hostIfTime->get_Device_Time_LocalTimeZone(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(param.paramtype, hostIf_StringType); + } +} + +TEST(TimeTest, get_Device_Time_CurrentLocalTime) { + int instanceNumber = 0; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + int ret = hostIfTime->get_Device_Time_CurrentLocalTime(¶m, &pChanged); + EXPECT_EQ(ret, OK); + EXPECT_EQ(param.paramtype, hostIf_StringType); + } +} + +TEST(TimeTest, get_xRDKCentralComBootstrap) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.XDial.AppList", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + int ret = hostIfTime->get_xRDKCentralComBootstrap(¶m); + std::string value = getStringValue(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(value, "youtube:spotify:netflix:system"); + } +} + +TEST(TimeTest, set_xRDKCentralComBootstrap) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.XconfUrl", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "https://xconf.xdp.eu-1.xcal.tv", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + int ret = hostIfTime->set_xRDKCentralComBootstrap(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(TimeTest, get_Device_Time_CurrentUTCTime) { + int instanceNumber = 0; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + int ret = hostIfTime->get_Device_Time_CurrentUTCTime(¶m, &pChanged); + EXPECT_EQ(ret, OK); + EXPECT_EQ(param.paramtype, hostIf_StringType); + } +} + +GTEST_API_ int main(int argc, char *argv[]){ + char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; + char buffer[GTEST_REPORT_FILEPATH_SIZE]; + + memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE ); + memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE ); + snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME); + + ::testing::GTEST_FLAG(output) = testresults_fullfilepath; + ::testing::InitGoogleMock(&argc, argv); + std::cout <<"running ut"<< std::endl; + return RUN_ALL_TESTS(); +} diff --git a/src/hostif/src/gtest/Makefile.am b/src/hostif/src/gtest/Makefile.am new file mode 100644 index 000000000..72cb04efa --- /dev/null +++ b/src/hostif/src/gtest/Makefile.am @@ -0,0 +1,49 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects +# Define the program name and the source files +bin_PROGRAMS = src_gtest + +# Define the include directories +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus + +if LIBSOUP3_ENABLE +COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE +else +COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 +endif + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl + +if LIBSOUP3_ENABLE +COMMON_LDADD += -lsoup-3.0 +endif + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage + + +# Define the source files +src_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/unittest/stubs/file_writer.cpp $(TOP_DIR)/src/hostif/src/gtest/gtest_src.cpp + +# Apply common properties to each program +src_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +src_gtest_LDADD = $(COMMON_LDADD) +src_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) diff --git a/src/hostif/src/gtest/gtest_src.cpp b/src/hostif/src/gtest/gtest_src.cpp new file mode 100644 index 000000000..b6ae6fcca --- /dev/null +++ b/src/hostif/src/gtest/gtest_src.cpp @@ -0,0 +1,264 @@ +#include +#include +#include "hostIf_tr69ReqHandler.h" +#include "hostIf_utils.h" +#include "XrdkCentralComRFCStore.h" +#include "XrdkCentralComBSStore.h" +#include "XrdkCentralComBSStoreJournal.h" +#include "Device_DeviceInfo_Processor.h" +#include "Device_DeviceInfo_ProcessStatus.h" +#include "XrdkCentralComRFCVar.h" +#include "request_handler.h" +#include "IniFile.h" +#include "hostIf_utils.h" +#include "hostIf_main.h" +#include "webpa_notification.h" +#include "webpa_parameter.h" +#include "rbus_value.h" + +#include "hostIf_msgHandler.h" +#include "http_server.h" +#include "request_handler.h" +#include "rdk_debug.h" +#include "waldb.h" +#include "file_writer.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif +#include +#include +#ifdef __cplusplus +} +#endif + +#include "Device_DeviceInfo.h" + +#include +#include "cJSON.h" + +#include +#include + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "hostif_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +using namespace std; + +XRFCStore* m_rfcStore; +XBSStore* m_bsStore; +XBSStoreJournal* m_bsStoreJournal; +XRFCVarStore* m_varStore; + +std::mutex mtx_httpServerThreadDone; +std::condition_variable cv_httpServerThreadDone; +bool httpServerThreadDone = false; +GThread *HTTPServerThread = NULL; +char *HTTPServerName = (char *)"HTTPServerThread"; +GError *httpError = NULL; +T_ARGLIST argList = {{'\0'}, 0}; + +TEST(srcTest, load) { + IniFile* m_ini = new IniFile(); + const string filename = "/opt/secure/RFC/bootstrap.ini"; + bool result = m_ini->load(filename); + EXPECT_EQ(result, true); + delete m_ini; +} + +TEST(srcTest, value) { + IniFile* m_ini = new IniFile(); + const string key = "Device.Time.NTPServer5"; + const string defaultValue = "time"; + + bool ret = m_ini->load("/opt/secure/RFC/bootstrap.ini"); + string result = m_ini->value(key, defaultValue); + EXPECT_EQ(result, "time"); + delete m_ini; +} + +TEST(srcTest, srcsetValue) { + IniFile* m_ini = new IniFile(); + const string key = "Device.Time.NTPServer4"; + const string value = "overidetime3.com"; + + bool ret = m_ini->load("/opt/secure/RFC/bootstrap.ini"); + bool result = m_ini->setValue(key, value); + EXPECT_EQ(result, true); + delete m_ini; +} + + +/* TEST(srcTest, clear) { + IniFile *inFile = new IniFile(); + inFile->load("/opt/secure/RFC/bootstrap.ini"); + bool result = inFile->clear(); + EXPECT_EQ(result, true); +} */ + +TEST(srcTest, getStringFromEnum) { + EnumStringMapper myEnumMap[] = { + {0, "ZERO"}, + {1, "ONE"}, + {2, "TWO"}, + {3, "THREE"} + }; + + int size = sizeof(myEnumMap) / sizeof(myEnumMap[0]); + int inputCode = 2; + + const char *result = getStringFromEnum(myEnumMap, size, inputCode); + EXPECT_EQ(result, "TWO"); +} + +TEST(srcTest, getEnumFromString) { + EnumStringMapper myEnumMap[] = { + {0, "ZERO"}, + {1, "ONE"}, + {2, "TWO"}, + {3, "THREE"} + }; + + int size = sizeof(myEnumMap) / sizeof(myEnumMap[0]); + + int ret = getEnumFromString(myEnumMap, size, "THREE"); + EXPECT_EQ(ret, 3); +} + +TEST(srcTest, type_conversions) { + int d = 100; + string itosret = int_to_string(d); + EXPECT_EQ(itosret, "100"); + + uint unum = 143; + string uitosret = uint_to_string(unum); + EXPECT_EQ(uitosret, "143"); + + unsigned long ulnum = 123456789UL; + string ultosret = ulong_to_string(ulnum); + EXPECT_EQ(ultosret, "123456789"); + + int num = 42; + const char* ptr = (const char*)# + int iret = get_int(ptr); + EXPECT_EQ(iret, 42); + + uint number = 123456; + char *uptr = (char *)&number; + uint uiret = get_uint(uptr); + EXPECT_EQ(uiret, number); + + /*const char* input = "true"; + bool ret = get_boolean("true"); + EXPECT_EQ(ret, true); */ + + string btosret = bool_to_string(false); + EXPECT_EQ(btosret, "false"); + + int stoiret = string_to_int("123"); + EXPECT_EQ(stoiret, 123); + + uint stouret = string_to_uint("42"); + EXPECT_EQ(stouret, 42); + + unsigned long stoulret = string_to_ulong("1234"); + EXPECT_EQ(stoulret, 1234); + + bool stobret = string_to_bool("false"); + EXPECT_EQ(stobret, false); +} + +TEST(srcTest, getBSUpdateEnum) { + HostIf_Source_Type_t type; + type = getBSUpdateEnum("allUpdate"); + EXPECT_EQ(type, HOSTIF_SRC_ALL); + + type = getBSUpdateEnum("rfcUpdate"); + EXPECT_EQ(type, HOSTIF_SRC_RFC); + + type = getBSUpdateEnum("default"); + EXPECT_EQ(type, HOSTIF_SRC_DEFAULT); +} + + +TEST(srcTest, isWebpaReady) { + bool ret = isWebpaReady(); + EXPECT_EQ(ret, true); +} + +TEST(srcTest, isNtpTimeFilePresent) { + bool ret = isNtpTimeFilePresent(); + EXPECT_EQ(ret, true); +} + +TEST(srcTest, get_system_manageble_ntp_time) { + write_on_file("/tmp/timeReceivedNTP", "Mon Aug 11 14:22:30 UTC 2025"); + unsigned long ret = get_system_manageble_ntp_time(); + EXPECT_EQ(ret, 1754922150); +} + +TEST(srcTest, get_device_manageble_time) { + write_on_file("/tmp/webpa/start_time", "1754835750"); + unsigned long ret = get_device_manageble_time(); + EXPECT_EQ(ret, 1754835750); +} + + +TEST(srcTest, set_get_GatewayConnStatus) { + set_GatewayConnStatus(true); + bool status = get_GatewayConnStatus(); + EXPECT_EQ(status, true); +} + +TEST(srcTest, set_get_LegacyRFCEnabled) { + setLegacyRFCEnabled(true); + bool status = legacyRFCEnabled(); + EXPECT_EQ(status, true); +} + +TEST(srcTest, matchComponent) { + const char* param = "Device.WiFi.SSID.3.SSID"; + const char* key = "Device.WiFi.SSID"; + const char* setting = nullptr; + int instance = 0; + bool matched = matchComponent(param, key, &setting, instance); + EXPECT_EQ(matched, true); +} + +TEST(srcTest, getJsonRPCData) { + std::string jsonRequest = "{\"jsonrpc\":\"2.0\",\"method\":\"getTime\",\"params\":{},\"id\":1}"; + string result = getJsonRPCData(jsonRequest); + EXPECT_EQ(0, 0); +} + +TEST(srcTest, timeValDiff) { + struct timespec starttime = { + .tv_sec = 100, + .tv_nsec = 500000000 // 0.5 seconds + }; + + struct timespec endtime = { + .tv_sec = 102, + .tv_nsec = 200000000 // 0.2 seconds + }; + + long msec = timeValDiff(&starttime, &endtime); + EXPECT_EQ(msec, 1700); +} + + +GTEST_API_ int main(int argc, char *argv[]){ + char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; + char buffer[GTEST_REPORT_FILEPATH_SIZE]; + + memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE ); + memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE ); + snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME); + + ::testing::GTEST_FLAG(output) = testresults_fullfilepath; + ::testing::InitGoogleMock(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/src/integrationtest/conf/rfcVariable.ini b/src/integrationtest/conf/rfcVariable.ini new file mode 100644 index 000000000..a1d29a81d --- /dev/null +++ b/src/integrationtest/conf/rfcVariable.ini @@ -0,0 +1,2 @@ +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType=testtype +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData=testCfg diff --git a/src/unittest/stubs/dm_stubs.cpp b/src/unittest/stubs/dm_stubs.cpp index fc7a2542c..c8f59d54d 100644 --- a/src/unittest/stubs/dm_stubs.cpp +++ b/src/unittest/stubs/dm_stubs.cpp @@ -24,6 +24,7 @@ #include "rbus.h" #include "power_controller.h" +#ifdef PARODUS rbusHandle_t rbusHandle = NULL; int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { @@ -54,6 +55,9 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) * for wildcards request where it represents the number of param/value pairs retrieved for the particular wildcard parameter. * @param[out] retStatus List of Return status. */ +#endif + +#ifdef UNIT_TEST void getValues (const char *paramName[], const unsigned int paramCount, param_t ***paramValArr,size_t **retValCount, WDMP_STATUS **retStatus) { @@ -69,7 +73,7 @@ void setValues(const ParamVal paramVal[], const unsigned int paramCount, const W { } - +#endif IARM_Result_t IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *arg, size_t argLen) { return IARM_RESULT_SUCCESS; diff --git a/src/unittest/stubs/ds/aspectRatio.hpp b/src/unittest/stubs/ds/aspectRatio.hpp index 6dac1e1a4..0bbdb5314 100644 --- a/src/unittest/stubs/ds/aspectRatio.hpp +++ b/src/unittest/stubs/ds/aspectRatio.hpp @@ -54,11 +54,15 @@ class AspectRatio : public DSConstant { static const int k16x9; //!< Indicates 16x9 aspect ratio. static const int kMax; //!< Indicates maximum number of aspect ratios supported. - static const AspectRatio & getInstance(int id); + static const AspectRatio & getInstance(int id) + { + static AspectRatio aspectRatio(id); + return aspectRatio; + } static const AspectRatio & getInstance(const std::string &name); - AspectRatio(int id); - virtual ~AspectRatio(); + AspectRatio(int id) {} + virtual ~AspectRatio() {} }; diff --git a/src/unittest/stubs/ds/audioEncoding.hpp b/src/unittest/stubs/ds/audioEncoding.hpp index 800359bec..e3771ccd2 100644 --- a/src/unittest/stubs/ds/audioEncoding.hpp +++ b/src/unittest/stubs/ds/audioEncoding.hpp @@ -51,17 +51,17 @@ namespace device { class AudioEncoding : public DSConstant { public: - static const int kNone; //!< Value indicating encoding type None. - static const int kDisplay; //!< Value indicating digital audio encoding format. - static const int kPCM; //!< Value indicating PCM digital audio encoding format. - static const int kAC3; //!< Value indicating AC3 digital audio encoding format. - static const int kMax; //!< Indicates the maximum encoding formats supported. + static constexpr int kNone = 0; //!< Value indicating encoding type None. + static constexpr int kDisplay = 1; //!< Value indicating digital audio encoding format. + static constexpr int kPCM = 2; //!< Value indicating PCM digital audio encoding format. + static constexpr int kAC3 = 3; //!< Value indicating AC3 digital audio encoding format. + static constexpr int kMax = 4; //!< Indicates the maximum encoding formats supported. static const AudioEncoding & getInstance(int id); static const AudioEncoding & getInstance(const std::string &name); - AudioEncoding(int id); - virtual ~AudioEncoding(); + AudioEncoding(int id) {} + virtual ~AudioEncoding() {} }; diff --git a/src/unittest/stubs/ds/audioOutputPort.hpp b/src/unittest/stubs/ds/audioOutputPort.hpp index 2821f7ad7..9bf77c587 100644 --- a/src/unittest/stubs/ds/audioOutputPort.hpp +++ b/src/unittest/stubs/ds/audioOutputPort.hpp @@ -84,11 +84,16 @@ class AudioOutputPort : public Enumerable { public: - static AudioOutputPort & getInstance(int id); + static AudioOutputPort & getInstance(int id) + { + static AudioOutputPort instance(id); + return instance; + } static AudioOutputPort & getInstance(const std::string &name); AudioOutputPort(const int type, const int index, const int id); - virtual ~AudioOutputPort(); + AudioOutputPort(int id) {} + virtual ~AudioOutputPort() {} const AudioOutputPortType & getType() const; int getId() const {return _id;}; @@ -108,9 +113,13 @@ class AudioOutputPort : public Enumerable { const List getSupportedStereoModes() const; - const AudioEncoding &getEncoding() const; - int getCompression() const; - int getDialogEnhancement() const; + const AudioEncoding &getEncoding() const + { + static AudioEncoding audioObj(AudioEncoding::kPCM); + return audioObj; + } + int getCompression() const { return 1; } + int getDialogEnhancement() const { return 1; } bool getDolbyVolumeMode() const; int getIntelligentEqualizerMode() const; dsVolumeLeveller_t getVolumeLeveller() const; @@ -122,7 +131,11 @@ class AudioOutputPort : public Enumerable { int getGraphicEqualizerMode() const; const std::string getMS12AudioProfile() const; std::vector getMS12AudioProfileList() const; - const AudioStereoMode &getStereoMode(bool usePersist = false); + const AudioStereoMode &getStereoMode(bool usePersist = false) + { + static AudioStereoMode stereoObj(AudioStereoMode::kStereo); + return stereoObj; + } dsError_t setEnablePort(bool enabled); dsError_t reInitializeAudioOutputPort(); @@ -134,25 +147,25 @@ class AudioOutputPort : public Enumerable { bool getStereoAuto(); - float getGain() const; - float getDB() const; - float getLevel() const; - float getMaxDB() const; - float getMinDB() const; - float getOptimalLevel() const; + float getGain() const { return 0.6f; }; + float getDB() const { return 0.6f; }; + float getLevel() const { return 0.6f; }; + float getMaxDB() const { return 0.6f; }; + float getMinDB() const { return 0.6f; }; + float getOptimalLevel() const { return 0.6f; }; bool getAudioDelay(uint32_t& audioDelayMs) const; bool getAudioDelayOffset(uint32_t& audioDelayOffsetMs) const; - bool isLoopThru() const; - bool isMuted() const; + bool isLoopThru() const { return true; } + bool isMuted() const { return true; }; bool isConnected() const; - bool isEnabled() const; + bool isEnabled() const { return true; }; bool isAudioMSDecode() const; bool isAudioMS12Decode() const; - void setEncoding(const int encoding); - void setCompression(const int compression); - void setDialogEnhancement(const int level); + void setEncoding(const int encoding) {} + void setCompression(const int compression) {} + void setDialogEnhancement(const int level) {} void setDolbyVolumeMode(const bool mode); void setIntelligentEqualizerMode(const int mode); void setVolumeLeveller(const dsVolumeLeveller_t volLeveller); @@ -164,7 +177,7 @@ class AudioOutputPort : public Enumerable { void setGraphicEqualizerMode(const int mode); void setMS12AudioProfile(std::string profile); - void setStereoMode(const int mode, const bool toPersist = true); + void setStereoMode(const int mode, const bool toPersist = true) {} void setStereoAuto(const bool autoMode, const bool toPersist = true); void setEncoding(const std::string & encoding); @@ -189,11 +202,11 @@ class AudioOutputPort : public Enumerable { void setSecondaryLanguage(const std::string sLang); void getSecondaryLanguage(std::string &sLang); - void setDB(const float db); + void setDB(const float db) {} void setGain(const float newGain); - void setLevel(const float level); - void setLoopThru(const bool loopThru); - void setMuted(const bool mute); + void setLevel(const float level) {} + void setLoopThru(const bool loopThru) {} + void setMuted(const bool mute) {} void setAudioDucking(dsAudioDuckingAction_t action, dsAudioDuckingType_t, const unsigned char level); void getAudioCapabilities(int *capabilities); void getMS12Capabilities(int *capabilities); diff --git a/src/unittest/stubs/ds/audioStereoMode.hpp b/src/unittest/stubs/ds/audioStereoMode.hpp index 8b7538c32..89852cfac 100644 --- a/src/unittest/stubs/ds/audioStereoMode.hpp +++ b/src/unittest/stubs/ds/audioStereoMode.hpp @@ -53,7 +53,7 @@ class AudioStereoMode : public DSConstant { public: static const int kMono; //!< Indicates audio mode of type mono. - static const int kStereo; //!< Indicates audio mode of type stereo. + static const int kStereo = 1; //!< Indicates audio mode of type stereo. static const int kSurround; //!< Indicates audio mode of type surround. static const int kPassThru; //!< Indicates audio mode of type pass through. static const int kDD; //!< Indicates audio mode of type dolby digital. @@ -63,8 +63,8 @@ class AudioStereoMode : public DSConstant { static const AudioStereoMode & getInstance(int id); static const AudioStereoMode & getInstance(const std::string &name); - AudioStereoMode(int id); - virtual ~AudioStereoMode(); + AudioStereoMode(int id) {} + virtual ~AudioStereoMode() {} }; diff --git a/src/unittest/stubs/ds/frameRate.hpp b/src/unittest/stubs/ds/frameRate.hpp index a8d4b150a..bfc3e2805 100644 --- a/src/unittest/stubs/ds/frameRate.hpp +++ b/src/unittest/stubs/ds/frameRate.hpp @@ -53,7 +53,7 @@ class FrameRate : public DSConstant { static const int k24; //!< Indicates video frame rate of 24 fps. static const int k25; //!< Indicates video frame rate of 25 fps. static const int k30; //!< Indicates video frame rate of 30 fps. - static const int k60; //!< Indicates video frame rate of 60 fps. + static constexpr int k60 = 60; //!< Indicates video frame rate of 60 fps. static const int k23dot98; //!< Indicates video frame rate of 23.98 fps. static const int k29dot97; //!< Indicates video frame rate of 29.97 fps. static const int k50; //!< Indicates video frame rate of 50 fps. @@ -63,9 +63,9 @@ class FrameRate : public DSConstant { static const FrameRate & getInstance(int id); static const FrameRate & getInstance(const std::string &name); - FrameRate(float value); - FrameRate(int id); - virtual ~FrameRate(); + FrameRate(float value) {} + FrameRate(int id) {} + virtual ~FrameRate() {} }; } diff --git a/src/unittest/stubs/ds/host.hpp b/src/unittest/stubs/ds/host.hpp index 95ed08b3f..af0d3a5cf 100644 --- a/src/unittest/stubs/ds/host.hpp +++ b/src/unittest/stubs/ds/host.hpp @@ -63,8 +63,11 @@ class Host { static const int kPowerOff; static const int kPowerStandby; - bool setPowerMode(int mode); - int getPowerMode(); + bool setPowerMode(int mode) + { + return true; + } + int getPowerMode() { return 10; } SleepMode getPreferredSleepMode(); int setPreferredSleepMode(const SleepMode); List getAvailableSleepModes(); @@ -77,8 +80,18 @@ class Host { List getVideoOutputPorts(); List getAudioOutputPorts(){}; - List getVideoDevices(); - VideoOutputPort &getVideoOutputPort(const std::string &name); + List getVideoDevices() + { + List devices; + devices.push_back(VideoDevice(1)); + devices.push_back(VideoDevice(2)); + return devices; + } + VideoOutputPort &getVideoOutputPort(const std::string &name) + { + static VideoOutputPort vPort(name); + return vPort; + } VideoOutputPort &getVideoOutputPort(int id); AudioOutputPort &getAudioOutputPort(const std::string &name){}; AudioOutputPort &getAudioOutputPort(int id){}; @@ -99,7 +112,7 @@ class Host { void setSecondaryLanguage(const std::string sLang); void getSecondaryLanguage(std::string &sLang); bool isHDMIOutPortPresent(); - std::string getDefaultVideoPortName(); + std::string getDefaultVideoPortName() { return "port"; } std::string getDefaultAudioPortName(); void getCurrentAudioFormat(dsAudioFormat_t &audioFormat); void getMS12ConfigDetails(std::string &configType); diff --git a/src/unittest/stubs/ds/libprocps.cpp b/src/unittest/stubs/ds/libprocps.cpp new file mode 100644 index 000000000..a25577f69 --- /dev/null +++ b/src/unittest/stubs/ds/libprocps.cpp @@ -0,0 +1,19 @@ +extern "C" { +#include +} + +static int call_count = 0; + +PROCTAB* openproc(int flags, ...) { + // Your stub implementation here + return nullptr; +} + +void closeproc(PROCTAB* pt) { + // Your stub implementation here +} + +proc_t* readproc(PROCTAB* pt, proc_t* buffer) { + // Your stub implementation here + return nullptr; +} diff --git a/src/unittest/stubs/ds/manager.hpp b/src/unittest/stubs/ds/manager.hpp index 4513024ae..c715a8836 100644 --- a/src/unittest/stubs/ds/manager.hpp +++ b/src/unittest/stubs/ds/manager.hpp @@ -166,8 +166,8 @@ class Manager { Manager(); virtual ~Manager(); public: - static void Initialize(); - static void DeInitialize(); + static void Initialize() {} + static void DeInitialize() {} static int IsInitialized; //!< Indicates the application has initialized with devicettings modules. }; diff --git a/src/unittest/stubs/ds/pixelResolution.hpp b/src/unittest/stubs/ds/pixelResolution.hpp index a3b6dbb94..938b242da 100644 --- a/src/unittest/stubs/ds/pixelResolution.hpp +++ b/src/unittest/stubs/ds/pixelResolution.hpp @@ -65,8 +65,8 @@ class PixelResolution : public DSConstant { static const PixelResolution & getInstance(int id); static const PixelResolution & getInstance(const std::string &name); - PixelResolution(int id); - virtual ~PixelResolution(); + PixelResolution(int id) {} + virtual ~PixelResolution() {} }; } diff --git a/src/unittest/stubs/ds/videoDFC.hpp b/src/unittest/stubs/ds/videoDFC.hpp index 600aa87b5..044c933b1 100644 --- a/src/unittest/stubs/ds/videoDFC.hpp +++ b/src/unittest/stubs/ds/videoDFC.hpp @@ -76,8 +76,8 @@ class VideoDFC : public DSConstant { static const VideoDFC & getInstance(int id); static const VideoDFC & getInstance(const std::string &name); - VideoDFC(int id); - virtual ~VideoDFC(); + VideoDFC(int id) {} + virtual ~VideoDFC() {} }; } diff --git a/src/unittest/stubs/ds/videoDevice.hpp b/src/unittest/stubs/ds/videoDevice.hpp index 61ec375df..0468c3e90 100644 --- a/src/unittest/stubs/ds/videoDevice.hpp +++ b/src/unittest/stubs/ds/videoDevice.hpp @@ -60,21 +60,42 @@ class VideoDevice : public DSConstant { static const char * kPropertyDFC; public: - static VideoDevice & getInstance(int id); - static VideoDevice & getInstance(const std::string &name); - - VideoDevice(int id); + static VideoDevice & getInstance(int id) + { + static VideoDevice instance(id); + return instance; + } + static VideoDevice & getInstance(const std::string &name) + { + static VideoDevice instance(0); + return instance; + } + + VideoDevice(int id) {} void setDFC(const std::string & name); void setDFC(int id); void setPlatformDFC(); - const VideoDFC & getDFC(); + const VideoDFC & getDFC() + { + static VideoDFC vDFC(0); + return vDFC; + } const List getSupportedDFCs() const; void addDFC(const VideoDFC &dfc); - virtual ~VideoDevice(); + virtual ~VideoDevice() {} void getHDRCapabilities(int *capabilities); - void getSettopSupportedResolutions(std::list& stbSupportedResoltuions); - unsigned int getSupportedVideoCodingFormats() const; - dsVideoCodecInfo_t getVideoCodecInfo(dsVideoCodingFormat_t format) const; + void getSettopSupportedResolutions(std::list& stbSupportedResoltuions) + { + stbSupportedResoltuions.push_back("1920x1080"); + stbSupportedResoltuions.push_back("1280x720"); + } + unsigned int getSupportedVideoCodingFormats() const { return 0x1F; } + dsVideoCodecInfo_t getVideoCodecInfo(dsVideoCodingFormat_t format) const + { + dsVideoCodecInfo_t codecInfo = {}; + codecInfo.num_entries = 2; + return codecInfo; + } int forceDisableHDRSupport(bool disable); int getFRFMode(int *frfmode) const; int setFRFMode(int frfmode) const; diff --git a/src/unittest/stubs/ds/videoOutputPort.hpp b/src/unittest/stubs/ds/videoOutputPort.hpp index c1b78be7c..0986d0e7c 100644 --- a/src/unittest/stubs/ds/videoOutputPort.hpp +++ b/src/unittest/stubs/ds/videoOutputPort.hpp @@ -38,6 +38,9 @@ #include #include "dsTypes.h" +#include "videoResolution.hpp" +#include "frameRate.hpp" +#include "videoOutputPortType.hpp" /** * @file videoOutputPort.hpp @@ -105,7 +108,7 @@ class VideoOutputPort : public Enumerable { Display() :_handle(0), _productCode(0), _serialNumber(0), _manufacturerYear(0), _manufacturerWeek(0),_aspectRatio(0),_hdmiDeviceType(true), _isSurroundCapable(false), _isDeviceRepeater(false), _physicalAddressA(1),_physicalAddressB(0),_physicalAddressC(0),_physicalAddressD(0){}; Display(VideoOutputPort &vPort); - virtual ~Display(); + virtual ~Display() {} /** @@ -154,7 +157,7 @@ class VideoOutputPort : public Enumerable { */ int getConnectedDeviceType() const {return _hdmiDeviceType;}; bool isConnectedDeviceRepeater() const {return _isDeviceRepeater;}; - void getEDIDBytes(std::vector &edid) const; + void getEDIDBytes(std::vector &edid) const { edid.clear(); } /** * @fn int hasSurround() const @@ -198,12 +201,20 @@ class VideoOutputPort : public Enumerable { physicalAddressC = _physicalAddressC;physicalAddressD = _physicalAddressD;}; }; - static VideoOutputPort & getInstance(int id); + static VideoOutputPort & getInstance(int id) + { + static VideoOutputPort port(0, 0, 0, 0, "1080p60"); + return port; + } static VideoOutputPort & getInstance(const std::string &name); VideoOutputPort(const int type, const int index, const int id, int audioPortId, const std::string &resolution); - virtual ~VideoOutputPort(); + virtual ~VideoOutputPort() {} - const VideoOutputPortType &getType() const; + const VideoOutputPortType &getType() const + { + static VideoOutputPortType portType(0); + return portType; + } /** @@ -234,13 +245,25 @@ class VideoOutputPort : public Enumerable { int getIndex() const {return _index; }; AudioOutputPort &getAudioOutputPort(); - const VideoResolution &getResolution() ; - const VideoResolution &getDefaultResolution() const; - - const VideoOutputPort::Display &getDisplay(); - bool isDisplayConnected() const; + const VideoResolution &getResolution() + { + static VideoResolution videoRes(0, "1080p60", 1, 1, 0, FrameRate::k60, false, true); + return videoRes; + } + const VideoResolution &getDefaultResolution() const + { + static VideoResolution videoRes(0, "1080p60", 1, 1, 0, 5, false, true); + return videoRes; + } + + const VideoOutputPort::Display &getDisplay() + { + static Display display; + return display; + } + bool isDisplayConnected() const { return true; } bool isContentProtected() const; - bool isEnabled() const; + bool isEnabled() const { return true; } bool isActive() const; bool isDynamicResolutionSupported() const; @@ -253,11 +276,11 @@ class VideoOutputPort : public Enumerable { * @return None. */ void setAudioPort(int id) { _aPortId = id; }; - void setResolution(const std::string &resolution, bool persist = true, bool isIgnoreEdid=false); + void setResolution(const std::string &resolution, bool persist = true, bool isIgnoreEdid=false) {} void setDisplayConnected(const bool connected); - void enable(); - void disable(); - int getHDCPStatus(); + void enable() {} + void disable() {} + int getHDCPStatus() { return 1; } int getHDCPProtocol(); int getHDCPReceiverProtocol(); int getHDCPCurrentProtocol(); @@ -280,6 +303,7 @@ class VideoOutputPort : public Enumerable { const unsigned int getPreferredColorDepth(bool persist = true) ; void setPreferredColorDepth(const unsigned int colordepth, bool persist = true); void getColorDepthCapabilities (unsigned int *capabilities) const; + VideoOutputPort(const std::string& name) {} private: Display _display; diff --git a/src/unittest/stubs/ds/videoOutputPortType.hpp b/src/unittest/stubs/ds/videoOutputPortType.hpp index 066e61f98..00cc2a68f 100644 --- a/src/unittest/stubs/ds/videoOutputPortType.hpp +++ b/src/unittest/stubs/ds/videoOutputPortType.hpp @@ -50,6 +50,7 @@ */ namespace device { +class VideoOutputPort; /** * @class VideoOutputPortType @@ -83,15 +84,20 @@ class VideoOutputPortType : public DSConstant { static VideoOutputPortType & getInstance(const std::string &name); - VideoOutputPortType(const int id); - virtual ~VideoOutputPortType(); + VideoOutputPortType(const int id) {} + virtual ~VideoOutputPortType() {} int getTypeId() const; bool isDTCPSupported() const; bool isHDCPSupported() const; bool isDynamicResolutionsSupported() const; int getRestrictedResolution() const ; - const List getSupportedResolutions() const; + const List getSupportedResolutions() const + { + List supportedResolutions; + supportedResolutions.push_back(VideoResolution(0, "1080p60", 1, 1, 0, 5, false, true)); + return supportedResolutions; + } const VideoResolution & getOutputResolution(const VideoResolution &inputResolution) const; const List getPorts() const; diff --git a/src/unittest/stubs/ds/videoResolution.hpp b/src/unittest/stubs/ds/videoResolution.hpp index a6bb6c2d0..a50cd636f 100644 --- a/src/unittest/stubs/ds/videoResolution.hpp +++ b/src/unittest/stubs/ds/videoResolution.hpp @@ -67,19 +67,32 @@ class VideoResolution : public DSConstant { public: - static const VideoResolution & getInstance(int id); + static const VideoResolution & getInstance(int id) {} static const VideoResolution & getInstance(const std::string &name, bool isIgnoreEdid=false); VideoResolution(const int id, const std::string &name, int resolutionId, int ratioid, int ssModeId, - int frameRateId, bool interlacedId, bool enabled = true); - virtual ~VideoResolution(); - const PixelResolution & getPixelResolution() const; + int frameRateId, bool interlacedId, bool enabled = true) + { + } + virtual ~VideoResolution() {} + const PixelResolution & getPixelResolution() const + { + static PixelResolution pixelRes(0); + return pixelRes; + } const AspectRatio & getAspectRatio() const; const StereoScopicMode & getStereoscopicMode()const; - const FrameRate & getFrameRate() const; - bool isInterlaced() const; + const FrameRate & getFrameRate() const + { + static FrameRate frameRate(FrameRate::k60); + return frameRate; + } + bool isInterlaced() const + { + return true; + } bool isEnabled() const; }; diff --git a/src/unittest/stubs/file_writer.cpp b/src/unittest/stubs/file_writer.cpp new file mode 100644 index 000000000..7f064b656 --- /dev/null +++ b/src/unittest/stubs/file_writer.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include "file_writer.h" + +void writeToTr181storeFile(const std::string& key, const std::string& value, const std::string& filePath, ValueFormat format) { + // Check if the file exists and is openable in read mode + std::ifstream fileStream(filePath); + bool found = false; + std::string line; + std::vector lines; + + std::string formattedLine = (format == Quoted) + ? key + "=\"" + value + "\"" + : key + "=" + value; + + if (fileStream.is_open()) { + while (getline(fileStream, line)) { + // Check if the current line contains the key + if (line.find(key) != std::string::npos && line.substr(0, key.length()) == key) { + // Replace the line with the new key-value pair + line = formattedLine; + found = true; + } + lines.push_back(line); + } + fileStream.close(); + } else { + std::cout << "File does not exist or cannot be opened for reading. It will be created." << std::endl; + } + + // If the key was not found in an existing file or the file did not exist, add it to the vector + if (!found) { + lines.push_back(formattedLine); + } + + // Open the file in write mode to overwrite old content or create new file + std::ofstream outFileStream(filePath); + if (outFileStream.is_open()) { + for (const auto& outputLine : lines) { + outFileStream << outputLine << std::endl; + } + outFileStream.close(); + std::cout << "Configuration updated successfully." << std::endl; + } else { + std::cout << "Error opening file for writing." << std::endl; + } +} + + +void write_on_file(const std::string& filePath, const std::string& data) +{ + std::ofstream outfile(filePath, std::ios::app); + if (outfile.is_open()) { + std::cout << "File Open" << std::endl; + outfile << data ; + std::cout << "Writing in file" << std::endl; + outfile.close(); + std::cout << "File written successfully." << std::endl; + } else { + std::cerr << "Unable to open file." << std::endl ; + } + +} diff --git a/src/unittest/stubs/file_writer.h b/src/unittest/stubs/file_writer.h new file mode 100644 index 000000000..b313e1193 --- /dev/null +++ b/src/unittest/stubs/file_writer.h @@ -0,0 +1,22 @@ +#ifndef FILE_WRITER_H +#define FILE_WRITER_H + +#include + +enum ValueFormat { + Plain, // key=value + Quoted // key="value" +}; + +/** + * @brief Writes or updates a key="value" pair in a flat TR-181-style config file. + * + * @param key The TR-181 parameter name (e.g., "Device.DeviceInfo...") + * @param value The string value to be assigned (e.g., "true") + * @param filePath Path to the config file to read/update/create + */ +void writeToTr181storeFile(const std::string& key, const std::string& value, const std::string& filePath, ValueFormat format); + +void write_on_file(const std::string& filePath, const std::string& data); + +#endif // FILE_WRITER_H diff --git a/src/unittest/stubs/libparodus.h b/src/unittest/stubs/libparodus.h new file mode 100644 index 000000000..80ab3ab46 --- /dev/null +++ b/src/unittest/stubs/libparodus.h @@ -0,0 +1,212 @@ +/** + * Copyright 2016 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _LIBPARODUS_H +#define _LIBPARODUS_H + +#include "wrp-c.h" +#include "libparodus_log.h" + +#ifdef __cplusplus +extern "C" { /* open extern "C" */ +#endif + +/** + * This module is linked with the client, and provides connectivity + * to the parodus service. + */ + +typedef struct { + const char *service_name; + bool receive; + int keepalive_timeout_secs; + const char *parodus_url; + const char *client_url; + unsigned test_flags; // always 0 except when testing +} libpd_cfg_t; + +typedef void *libpd_instance_t; + + +/** + * @brief libparodus error rtn codes + * + */ +typedef enum { + /** + * @brief Error on libparodus_init + * could not create new instance + */ + LIBPD_ERROR_INIT_INST = -101, + /** + * @brief Error on libparodus_init + * invalid cfg parameter + */ + LIBPD_ERROR_INIT_CFG = -102, + /** + * @brief Error on libparodus_init + * error connecting + */ + LIBPD_ERROR_INIT_CONNECT = -103, + /** + * @brief Error on libparodus_close_receiver + * null instance given + */ + LIBPD_ERROR_CLOSE_RCV_NULL_INST = -301, + /** + * @brief Error on libparodus_close_receiver + * run state error + */ + LIBPD_ERROR_CLOSE_RCV_STATE = -302, + /** + * @brief Error on libparodus_close_receiver + * not configured for receive + */ + LIBPD_ERROR_CLOSE_RCV_CFG = -303, + /** + * @brief Error on libparodus_close_receiver + * queue send error, timed out + */ + LIBPD_ERROR_CLOSE_RCV_TIMEDOUT = -304, + /** + * @brief Error on libparodus_close_receiver + * unable to send close recevier message + */ + LIBPD_ERROR_CLOSE_RCV_SEND = -305, + /** + * @brief Error on libparodus_close_receiver + * thread limit exceeded + */ + LIBPD_ERROR_CLOSE_RCV_THR_LIMIT = -306, + /** + * @brief Error on libparodus_send + * null instance given + */ + LIBPD_ERROR_SEND_NULL_INST = -401, + /** + * @brief Error on libparodus_send + * run state error + */ + LIBPD_ERROR_SEND_STATE = -402, + /** + * @brief Error on libparodus_send + * invalid WRP message + */ + LIBPD_ERROR_SEND_WRP_MSG = -403, + /** + * @brief Error on libparodus_send + * socket send error + */ + LIBPD_ERROR_SEND_SOCKET = -404, + /** + * @brief Error on libparodus_send + * thread limit exceeded + */ + LIBPD_ERROR_SEND_THR_LIMIT = -405 +} libpd_error_t; + +/** + * Initialize the parodus wrp interface + * + * @param instance pointer to receive instance object that must be provided + * to all subsequent API calls. + * @param cfg configuration information: service_name must be provided, + * @return 0 on success, else: + * LIBPD_ERROR_INIT_INST = -101, could not create new instance + * LIBPD_ERROR_INIT_CFG = -102, invalid config parameter + * LIBPD_ERROR_INIT_CONNECT = -103, error connecting + * LIBPD_ERROR_INIT_RCV_THREAD = -104, error creating wrp receiver thread + * LIBPD_ERROR_INIT_QUEUE = -105, error creating wrp msg receive queue + * LIBPD_ERROR_INIT_REGISTER = -106, error sending registration msg + * + * @note libparodus_shutdown must be called even if there is an error + * on libparodus_init + */ +int libparodus_init (libpd_instance_t *instance, libpd_cfg_t *libpd_cfg); + +/** + * Receives the next message in the queue that was sent to this service, waiting + * the prescribed number of milliseconds before returning. + * + * @note msg will be set to NULL if no message is present during the time + * allotted. + * + * @param instance instance object + * @param msg the pointer to receive the next msg struct + * @param ms the number of milliseconds to wait for the next message + * + * @return 0 on success, 2 if closed msg received, 1 if timed out, else: + * LIBPD_ERROR_RCV_NULL_INST = -201, null instance given + * LIBPD_ERROR_RCV_STATE = -202, run state error, not running + * LIBPD_ERROR_RCV_CFG = -203, not configured for receive + * LIBPD_ERROR_RCV_RCV = -204, receive error + * + * @note don't free the msg when return is 2. + */ +int libparodus_receive (libpd_instance_t instance, wrp_msg_t **msg, uint32_t ms); + +/** + * Sends a close message to the receiver + * + * @param instance instance object + * @return 0 on success, else: + * LIBPD_ERROR_CLOSE_RCV_NULL_INST = -301, null instance given + * LIBPD_ERROR_CLOSE_RCV_STATE = -302, run state error, not running + * LIBPD_ERROR_CLOSE_RCV_CFG = -303, not configured for receive + * LIBPD_ERROR_CLOSE_RCV_TIMEDOUT = -304, timed out on queue send + * LIBPD_ERROR_CLOSE_RCV_SEND = -305, unable to send close receiver msg + */ +int libparodus_close_receiver (libpd_instance_t instance); + +/** + * Shut down the parodus wrp interface + * + * @param instance instance object + * @return always 0 +*/ + +int libparodus_shutdown (libpd_instance_t *instance); + + +/** + * Send a wrp message to the parodus service + * + * @param instance instance object + * @param msg wrp message to send + * + * @return 0 on success, else: + * LIBPD_ERROR_SEND_NULL_INST = -501, null instance given + * LIBPD_ERROR_SEND_STATE = -502, run state error, not running + * LIBPD_ERROR_SEND_WRP_MSG = -503, invalid wrp message + * LIBPD_ERROR_SEND_SOCKET = -504, socket send error + */ +int libparodus_send (libpd_instance_t instance, wrp_msg_t *msg); + +/** + * Return the string value of a libparodus error code + * + * @param err libparodus error code + * + * @return string value of the specified error code + */ +const char *libparodus_strerror (libpd_error_t err); + +#ifdef __cplusplus +} /* close extern "C" */ +#endif + +#endif diff --git a/src/unittest/stubs/libparodus_log.h b/src/unittest/stubs/libparodus_log.h new file mode 100644 index 000000000..a2e427c85 --- /dev/null +++ b/src/unittest/stubs/libparodus_log.h @@ -0,0 +1,84 @@ +/** + * Copyright 2016 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef _LIBPARODUS_LOG_H +#define _LIBPARODUS_LOG_H + +#include + +#define LEVEL_ERROR 0 +#define LEVEL_INFO 1 +#define LEVEL_DEBUG 2 + +// if TEST_ENVIRONMENT is not defined, then the macros libpd_log and libpd_log_err +// generate nothing +//#define TEST_ENVIRONMENT 1 + +#ifndef TEST_ENVIRONMENT +#define libpd_log(level,msg) +#define libpd_log_err(level,errcode,msg) +#else +// TEST_ENVIRONMENT defined + +#include +#include + +// When TEST_ENVIRONMENT == 1, printf is used. +// If TEST_ENVIRONMENT > 1, then you need to provide +// external functions 'CheckLevel' and 'Printf' + +#if TEST_ENVIRONMENT==1 +#define Printf printf +#define output_level(level) \ + if ((level) == LEVEL_ERROR) \ + Printf ("Error: "); \ + else if ((level) == LEVEL_INFO) \ + Printf ("Info: "); \ + else \ + Printf ("Debug: "); + +#define libpd_log(level,msg) \ + do { \ + output_level (level); \ + Printf msg; \ + } while (false) + +#else +// TEST_ENVIRONMENT > 1 + + extern bool CheckLevel (int level); + extern int Printf (const char *format, ...); + +#define libpd_log(level,msg) if (CheckLevel (level)) Printf msg + +#endif +// Example: libpd_log (LEVEL_ERROR, ("Unable to allocate new instance\n")); +// notice you need an extra set of parentheses + +#define libpd_log_err(level,errcode,msg) \ + libpd_log (level, msg); \ + do { \ + char errbuf[100]; \ + Printf (" : %s\n", strerror_r (errcode, errbuf, 100)); \ + } while (false) + +// Example: libpd_log_err (LEVEL_ERROR, errno, ("Unable to bind to receive_socket %s\n", rcv_url)); +// notice you need an extra set of parentheses + +#endif + + +#endif diff --git a/src/unittest/stubs/rbus/include/rbus.h b/src/unittest/stubs/rbus/include/rbus.h index ebc056129..c2d14cb64 100644 --- a/src/unittest/stubs/rbus/include/rbus.h +++ b/src/unittest/stubs/rbus/include/rbus.h @@ -938,12 +938,21 @@ rbusError_t rbus_get( * RBUS_ERROR_ELEMENT_DOES_NOT_EXIST: Data Element was not previously registered. * RBUS_ERROR_DESTINATION_NOT_REACHABLE: Destination element was not reachable. */ -rbusError_t rbus_getExt( +static inline rbusError_t rbus_getExt( rbusHandle_t handle, int paramCount, char const** paramNames, int *numProps, - rbusProperty_t* properties); + rbusProperty_t* properties) +{ + (void)handle; + (void)paramCount; + (void)paramNames; + (void)numProps; + (void)properties; + + return RBUS_ERROR_SUCCESS; +} /** @fn rbusError_t rbus_getBoolean( * rbusHandle_t handle, diff --git a/src/unittest/stubs/rbus/include/rbus_property.h b/src/unittest/stubs/rbus/include/rbus_property.h index 4ba5cb32e..b415dcbc9 100644 --- a/src/unittest/stubs/rbus/include/rbus_property.h +++ b/src/unittest/stubs/rbus/include/rbus_property.h @@ -61,7 +61,14 @@ typedef struct _rbusProperty* rbusProperty_t; * If the value is NULL, the property's value will be NULL. * @return The new property */ -rbusProperty_t rbusProperty_Init(rbusProperty_t* pproperty, char const* name, rbusValue_t value); +static inline rbusProperty_t rbusProperty_Init(rbusProperty_t* pproperty, char const* name, rbusValue_t value) +{ + (void)pproperty; + (void)name; + (void)value; + + return NULL; +} /** @name rbusProperty_Init[Type] * @brief These function allocate and initialize a property @@ -109,7 +116,10 @@ void rbusProperty_Retain(rbusProperty_t property); * a property that was retained with either rbusProperty_Init or rbusProperty_Retain. * @param property the property to release */ -void rbusProperty_Release(rbusProperty_t property); +static inline void rbusProperty_Release(rbusProperty_t property) +{ + (void)property; +} void rbusProperty_Releases(int count, ...); @@ -277,7 +287,11 @@ rbusProperty_t rbusProperty_AppendObject(rbusProperty_t property, char const* na * it should take ownership by calling rbusProperty_Retain and then * when its done with it, call rbusProperty_Release. */ -rbusProperty_t rbusProperty_GetNext(rbusProperty_t property); +static inline rbusProperty_t rbusProperty_GetNext(rbusProperty_t property) +{ + (void)property; + return NULL; +} /** @fn void rbusProperty_SetNext(rbusProperty_t property, rbusProperty_t next) * @brief Set the next property in the list. Properties can be linked together into a list. diff --git a/src/unittest/stubs/rbus/include/rbus_value.h b/src/unittest/stubs/rbus/include/rbus_value.h index e3dcf048f..9cd23c90f 100644 --- a/src/unittest/stubs/rbus/include/rbus_value.h +++ b/src/unittest/stubs/rbus/include/rbus_value.h @@ -337,7 +337,10 @@ void rbusValue_Swap(rbusValue_t* v1, rbusValue_t* v2); * @param str A string representation of the data which will be coerced to the type specified by the type param and assigned to the value. * @return bool true if this function succeeds to coerce the type and set the value or false if it fails */ -bool rbusValue_SetFromString(rbusValue_t value, rbusValueType_t type, const char* str); +static inline bool rbusValue_SetFromString(rbusValue_t value, rbusValueType_t type, const char* str) +{ + return true; +} /** @fn void rbusValue_fwrite(rbusValue_t obj, int depth, FILE* fout) * @brief A debug utility function to write the value as a string to a file stream. diff --git a/src/unittest/stubs/rdk_debug.h b/src/unittest/stubs/rdk_debug.h index 62e201e9a..040eb9a7d 100644 --- a/src/unittest/stubs/rdk_debug.h +++ b/src/unittest/stubs/rdk_debug.h @@ -28,6 +28,7 @@ #define RDK_LOG_INFO 3 #define RDK_LOG_WARN 4 #define RDK_LOG_ERROR 5 +#define RDK_LOG_TRACE2 6 #define rdk_logger_init(DEBUG_INI_NAME) ; diff --git a/src/unittest/stubs/rfcapi.h b/src/unittest/stubs/rfcapi.h index 161b7bb31..b46c45c41 100644 --- a/src/unittest/stubs/rfcapi.h +++ b/src/unittest/stubs/rfcapi.h @@ -63,15 +63,20 @@ typedef struct _RFC_Param_t { #ifdef RDKC int getRFCParameter(const char* pcParameterName, RFC_ParamData_t *pstParamData); #else -WDMP_STATUS getRFCParameter(const char *pcCallerID, const char* pcParameterName, RFC_ParamData_t *pstParamData); -WDMP_STATUS setRFCParameter(const char *pcCallerID, const char* pcParameterName, const char* pcParameterValue, DATA_TYPE eDataType); +//WDMP_STATUS getRFCParameter(const char *pcCallerID, const char* pcParameterName, RFC_ParamData_t *pstParamData); +//WDMP_STATUS setRFCParameter(const char *pcCallerID, const char* pcParameterName, const char* pcParameterValue, DATA_TYPE eDataType); -WDMP_STATUS setRFCParameter(const char *pcCallerID, const char* pcParameterName, const char* pcParameterValue, DATA_TYPE eDataType) +static inline WDMP_STATUS setRFCParameter(const char *pcCallerID, const char* pcParameterName, const char* pcParameterValue, DATA_TYPE eDataType) { WDMP_STATUS status = WDMP_SUCCESS; return status; } +static inline WDMP_STATUS getRFCParameter(const char *pcCallerID, const char* pcParameterName, RFC_ParamData_t *pstParamData) +{ + WDMP_STATUS status = WDMP_SUCCESS; + return status; +} const char* getRFCErrorString(WDMP_STATUS code); bool isRFCEnabled(const char *); bool isFileInDirectory(const char *, const char *); diff --git a/src/unittest/stubs/tr181store.ini b/src/unittest/stubs/tr181store.ini index 1cedddc0d..6e0b14787 100644 --- a/src/unittest/stubs/tr181store.ini +++ b/src/unittest/stubs/tr181store.ini @@ -1 +1,9 @@ Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable=false +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable=false +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed=1280000 +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName=comcast +Device.IP.InterfaceNumberOfEntries=4 +Device.DeviceInfo.X_COMCAST-COM_STB_MAC=A84A6388E9B5 +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable=true +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart=300 +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd=480 diff --git a/src/unittest/stubs/wrp-c.h b/src/unittest/stubs/wrp-c.h new file mode 100644 index 000000000..ffab9bf56 --- /dev/null +++ b/src/unittest/stubs/wrp-c.h @@ -0,0 +1,298 @@ +/** + * Copyright 2016 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef __WRP_C_H__ +#define __WRP_C_H__ + +#include +#include +#include +#include "wdmp-c.h" + +/*----------------------------------------------------------------------------*/ +/* Macros */ +/*----------------------------------------------------------------------------*/ +/* none */ + +/*----------------------------------------------------------------------------*/ +/* Data Structures */ +/*----------------------------------------------------------------------------*/ +enum wrp_msg_type { + WRP_MSG_TYPE__AUTH = 2, + WRP_MSG_TYPE__REQ = 3, + WRP_MSG_TYPE__EVENT = 4, + WRP_MSG_TYPE__CREATE = 5, + WRP_MSG_TYPE__RETREIVE = 6, + WRP_MSG_TYPE__UPDATE = 7, + WRP_MSG_TYPE__DELETE = 8, + WRP_MSG_TYPE__SVC_REGISTRATION = 9, + WRP_MSG_TYPE__SVC_ALIVE = 10, + WRP_MSG_TYPE__UNKNOWN = 200 +}; + +enum wrp_format { + WRP_BYTES = 0, + WRP_BASE64 = 1, + WRP_STRING = 2 +}; + +enum wrp_device_id_element { + WRP_ID_ELEMENT__SCHEME = 0, + WRP_ID_ELEMENT__ID = 1, + WRP_ID_ELEMENT__SERVICE = 2, + WRP_ID_ELEMENT__APPLICATION = 3 +}; + +enum wrp_token_name { + SOURCE = 0, + DEST = 1 +}; + +struct wrp_auth_msg { + int status; +}; + +typedef struct headers_struct { + size_t count; + // Flexible Array Must be the last element + char *headers[]; +} headers_t; + +typedef struct partners_struct { + size_t count; + char *partner_ids[]; +} partners_t; + +struct data { + char *name; + char *value; +}; + +typedef struct data_struct { + size_t count; + struct data *data_items; +} data_t; + +struct wrp_req_msg { + char *transaction_uuid; + char *content_type; + char *accept; + char *source; + char *dest; + partners_t *partner_ids; + headers_t *headers; /* NULL terminated list */ + data_t *metadata; + bool include_spans; + money_trace_spans spans; + int qos; + int rdr; + void *payload; + size_t payload_size; +}; + +struct wrp_event_msg { + char *content_type; + char *source; + char *dest; + partners_t *partner_ids; + int qos; + char *transaction_uuid; + headers_t *headers; /* NULL terminated list */ + data_t *metadata; + void *payload; + size_t payload_size; + char *session_id; + int rdr; +}; + +struct wrp_crud_msg { + char *content_type; + char *accept; + char *transaction_uuid; + char *source; + char *dest; + partners_t *partner_ids; + headers_t *headers; /* NULL terminated list */ + data_t *metadata; + bool include_spans; + money_trace_spans spans; + int status; + int rdr; + int qos; + char *path; + void *payload; + size_t payload_size; +}; + +struct wrp_svc_registration_msg { + char *service_name; + char *url; +}; + +typedef struct { + enum wrp_msg_type msg_type; + + union { + struct wrp_auth_msg auth; + struct wrp_req_msg req; + struct wrp_event_msg event; + struct wrp_crud_msg crud; + struct wrp_svc_registration_msg reg; + } u; +} wrp_msg_t; + +/*----------------------------------------------------------------------------*/ +/* File Scoped Variables */ +/*----------------------------------------------------------------------------*/ +/* none */ + +/*----------------------------------------------------------------------------*/ +/* Function Prototypes */ +/*----------------------------------------------------------------------------*/ +/* none */ + +/*----------------------------------------------------------------------------*/ +/* External Functions */ +/*----------------------------------------------------------------------------*/ + +/** + * Converts one of the wrp data structures into the sequence of bytes + * representation. + * + * @note If the value returned is greater than 0, the value pointed at by + * bytes must be freed using free() by the caller. + * + * @param msg [in] the wrp_msg_t structure to convert + * @param fmt [in] the format the output should be converted into + * @param bytes [out] the resulting bytes (not changed on error) + * + * @return the length of the bytes if successful or less than 1 otherwise + */ +ssize_t wrp_struct_to( const wrp_msg_t *msg, const enum wrp_format fmt, + void **bytes ); + +/** + * Converts a sequence of bytes into a wrp_msg_t if possible. + * + * @note If the value returned is not NULL, the resulting structure must + * be freed using the wrp_free_struct() function. + * + * @note fmt may only be: WRP_BYTES or WRP_BASE64. + * + * @param bytes [in] the sequence of bytes to process + * @param length [in] the length of the bytes passed in + * @param fmt [in] the format the input should be converted from + * @param msg [out] the resulting wrp_msg_t structure if successful + * unchanged otherwise (not changed on error) + * + * @return the number of bytes 'consumed' by making this transformation if + * successful, less than 1 otherwise + */ +ssize_t wrp_to_struct( const void *bytes, const size_t length, + const enum wrp_format fmt, + wrp_msg_t **msg ); + + +/** + * Converts a wrp_msg_t structure into a printable string. + * + * @note If the value returned is greater than 0, the value pointed at by + * bytes must be freed using free() by the caller. + * + * @param msg [in] the wrp_msg_t structure to convert + */ +char* wrp_struct_to_string( const wrp_msg_t *msg ); + + +/** + * Free the wrp_msg_t structure if allocated by the wrp-c library. + * + * @note Do not call this function on the wrp_msg_t structure if the wrp-c + * library did not create the structure! + * + * @param msg [in] the wrp_msg_t structure to free + */ +void wrp_free_struct( wrp_msg_t *msg ); + +/** + * Encode/pack only metadata from wrp_msg_t structure. + * + * @note Do not call free of output data in failure case! + * + * @param msg [in] packData the data_t structure to pack/encode + * @param msg [out] the encoded output + * @return encoded buffer size or less than 1 in failure case + */ + +ssize_t wrp_pack_metadata( const data_t *packData, void **data ); + +/** + * @brief appendEncodedData function to append two encoded buffer and change MAP size accordingly. + * + * @note appendEncodedData function allocates memory for buffer, caller needs to free the buffer(appendData)in + * both success or failure case. use wrp_free_struct() for free + * + * @param[in] encodedBuffer msgpack object (first buffer) + * @param[in] encodedSize is size of first buffer + * @param[in] metadataPack msgpack object (second buffer) + * @param[in] metadataSize is size of second buffer + * @param[out] appendData final encoded buffer after append + * @return appended total buffer size or less than 1 in failure case + */ + +size_t appendEncodedData( void **appendData, void *encodedBuffer, size_t encodedSize, void *metadataPack, size_t metadataSize ); + +/** + * Find the destination of a wrp_msg_t + * + * @param msg [in] the wrp_msg_t structure to examine + * @return pointer to destination, or NULL if there is no + * destination for this message type + */ +const char *wrp_get_msg_dest( const wrp_msg_t *wrp_msg ); + +/** + * Find the source of a wrp_msg_t + * + * @param msg [in] the wrp_msg_t structure to examine + * @return pointer to source, or NULL if there is no + * source for this message type + */ + +/** + * Find an element of the source or destination of a wrp_msg_t + * + * @note Returned memory must be freed using free(). + * + * @param [in] the element requested to parse + * @param msg [in] the wrp_msg_t structure to examine + * @param [in] the wrp_token source or destination to examine + * + * @return pointer to the element requested, or NULL otherwise + */ +char *wrp_get_msg_element( const enum wrp_device_id_element element, + const wrp_msg_t *wrp_msg, const enum wrp_token_name wrp_token ); + +/** + * Check to see if the service matches based on the specified device_id. + * + * @param [in] service the service name check the device_id for + * @param [in] device_id the device-id string to examine looking for the service + * + * @return 0 if there is a match, -1 otherwise. + */ +int wrp_does_service_match( const char *service, const char *device_id ); +#endif From 7b12e1f3b1790899806f41f1144c17435905d450 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 29 Aug 2025 14:55:07 +0530 Subject: [PATCH 126/161] Update webpa_parameter.cpp --- src/hostif/parodusClient/pal/webpa_parameter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 36762830e..1fede7c57 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -664,6 +664,8 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataMo { strncpy(ptrParam->paramValue, dmParam->defaultValue, MAX_PARAM_LENGTH - 1); ptrParam->paramValue[MAX_PARAM_LENGTH - 1] = '\0'; + paramValueToString(ptrParam, ptrParam->paramValue, sizeof(ptrParam->paramValue)); + status = WDMP_ERR_DEFAULT_VALUE; return WDMP_SUCCESS; } RDK_LOG(RDK_LOG_ERROR,LOG_PARODUS_IF,"[%s:%s:%d] Error in Get Message Handler : %d\n", __FILE__, __FUNCTION__, __LINE__, status); From eaf12a2e74ef8caf041cc7d105023289d0d84149 Mon Sep 17 00:00:00 2001 From: Leena D <74546271+leenaS-d@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:17:09 -0400 Subject: [PATCH 127/161] RDKEMW-8367: Add Valid Public NTP servers for community --- partners_defaults.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/partners_defaults.json b/partners_defaults.json index e4a754fa9..1d9396de9 100644 --- a/partners_defaults.json +++ b/partners_defaults.json @@ -38,11 +38,11 @@ "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DefaultSupportedLocales" : "" }, "community" : { - "Device.Time.NTPServer1" : "time.com", - "Device.Time.NTPServer2" : "time1.com", - "Device.Time.NTPServer3" : "time2.com", - "Device.Time.NTPServer4" : "time3.com", - "Device.Time.NTPServer5" : "time4.com", + "Device.Time.NTPServer1" : "time.google.com", + "Device.Time.NTPServer2" : "time1.google.com", + "Device.Time.NTPServer3" : "time2.google.com", + "Device.Time.NTPServer4" : "time3.google.com", + "Device.Time.NTPServer5" : "time4.google.com", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName" : "community", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerProductName" : "", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.NetflixESNprefix" : "", From eabd444bbe5087fa2f09f98c912fb7914bc67a66 Mon Sep 17 00:00:00 2001 From: nhanas001c Date: Wed, 24 Sep 2025 15:38:29 +0000 Subject: [PATCH 128/161] SERXIONE-7905: Device is not accessible via SSH after DRI execution Reason for change: Add check to confirm and create BSP file for parodus start --- .../profiles/DeviceInfo/XrdkCentralComBSStore.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp index 52cac2b9f..f99215c57 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp @@ -110,7 +110,9 @@ bool createBspCompleteFiles() RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,"Directory %s already exists.\n", RFC_DIRECTORY); } + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"Creating BSP Complete File %s\n", BSP_COMPLETE); createFile(BSP_COMPLETE); + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"Creating BSP Complete File %s in tmp Directory%s\n", BSP_COMPLETE_TMP); createFile(BSP_COMPLETE_TMP); return true; } @@ -279,12 +281,15 @@ void XBSStore::getAuthServicePartnerID() // Create a new file "/tmp/authservice_parodus_restart" createFile(AUTH_SERVICE_PARODUS_RESTART); RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"BSP_COMPLETE exists. Created /tmp/authservice_parodus_restart.\n"); - } else { - // If BSP_COMPLETE doesn't exist, create it so parodus.service can start. - createBspCompleteFiles(); - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"BSP_COMPLETE did not exist. Created BSP_COMPLETE.\n"); - } + } } + + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"Check and create BSP_COMPLETE for parodus.service to start.\n"); + if (!fileExists(BSP_COMPLETE)) { + // If BSP_COMPLETE doesn't exist, create it so parodus.service can start. + createBspCompleteFiles(); + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"BSP_COMPLETE did not exist. Created BSP_COMPLETE.\n"); + } } else { From d2403ec6c93375e8fc16993c8781e8973ef83cf7 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Wed, 24 Sep 2025 21:37:32 +0530 Subject: [PATCH 129/161] RDK-58963-[RDK-V/E] Federated Source Code For tr69hostif - Phase 2 (#250) * Update hostIf_IARM_ReqHandler.cpp * Update hostIf_IARM_ReqHandler.cpp * Update Device_DeviceInfo.cpp * Update Device_DeviceInfo.cpp * Update Device_WiFi_EndPoint_Security.cpp * Update Device_WiFi_Radio.cpp * Update Device_WiFi_Radio.h * Update Device_WiFi.cpp * Update Device_WiFi.h * Update Device_WiFi_EndPoint.cpp * Update Device_WiFi_Radio.cpp * Update Device_WiFi_Radio_Stats.cpp * Update Device_WiFi_Radio_Stats.h * Update Device_WiFi_SSID.cpp * Create tr69hostif.service.rdkv * Delete tr69hostif.service.rdkv * Update tr69hostif.service * Adding the data-model changes * Adding the data-model dependency * Networkmanager * Update tr69hostif.service * New changes * Adding the memsight changes * Update Makefile.am * Update Makefile.am * Update Makefile.am * Correcting * Final changes * Update hostIf_IARM_ReqHandler.cpp * Update hostIf_IARM_ReqHandler.cpp * Update hostIf_IARM_ReqHandler.cpp * Update Device_WiFi.cpp * Adding new changes * CHANGES * Final * Final patch * Adding * Adding * Makefile change * Linker flags * Create data-model-generic.xml * Update data-model-generic.xml * Update data-model-generic.xml --- configure.ac | 9 + src/Makefile.am | 2 + src/configure.ac | 10 +- src/hostif/handlers/Makefile.am | 11 +- .../handlers/src/hostIf_IARM_ReqHandler.cpp | 74 +- .../handlers/src/hostIf_WiFi_ReqHandler.cpp | 240 ++ .../src/hostIf_XREClient_ReqHandler.cpp | 13 +- .../src/hostIf_jsonReqHandlerThread.cpp | 126 - src/hostif/httpserver/Makefile.am | 17 +- src/hostif/httpserver/src/http_server.cpp | 176 +- src/hostif/include/hostIf_main.h | 5 +- src/hostif/include/hostIf_utils.h | 10 + .../parodusClient/pal/webpa_parameter.h | 5 +- .../waldb/data-model-generic.xml | 2025 +++++++++++++++++ .../waldb/data-model/data-model-generic.xml | 13 + src/hostif/parodusClient/waldb/waldb.cpp | 5 +- .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 328 ++- .../profiles/DeviceInfo/Device_DeviceInfo.h | 24 +- .../profiles/IP/Device_IP_Interface.cpp | 2 + .../IP/Device_IP_Interface_IPv6Address.cpp | 2 + src/hostif/profiles/wifi/Device_WiFi.cpp | 116 + src/hostif/profiles/wifi/Device_WiFi.h | 16 + .../profiles/wifi/Device_WiFi_EndPoint.cpp | 57 +- .../wifi/Device_WiFi_EndPoint_Security.cpp | 38 +- .../profiles/wifi/Device_WiFi_Radio.cpp | 384 ++++ src/hostif/profiles/wifi/Device_WiFi_Radio.h | 5 +- .../profiles/wifi/Device_WiFi_Radio_Stats.cpp | 162 +- .../profiles/wifi/Device_WiFi_Radio_Stats.h | 4 + src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 69 +- src/hostif/src/hostIf_main.cpp | 7 +- tr69hostif.service | 2 +- 31 files changed, 3600 insertions(+), 357 deletions(-) create mode 100644 src/hostif/parodusClient/waldb/data-model-generic.xml diff --git a/configure.ac b/configure.ac index b26ad55ad..25ca20954 100644 --- a/configure.ac +++ b/configure.ac @@ -226,6 +226,15 @@ AC_ARG_ENABLE([t2api], AM_CONDITIONAL([IS_TELEMETRY2_ENABLED], [test x$IS_TELEMETRY2_ENABLED = xtrue]) AC_SUBST(T2_EVENT_FLAG) +AC_ARG_ENABLE([powercontroller], +[ --enable-powercontroller Enable linking WPEFrameworkPowerController], +[case "${enableval}" in + yes) powercontroller=true ;; + no) powercontroller=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-powercontroller]) ;; +esac],[powercontroller=false]) +AM_CONDITIONAL([POWERCONTROLLER_ENABLE], [test x$powercontroller = xtrue]) + AC_ARG_ENABLE([rf4ce], diff --git a/src/Makefile.am b/src/Makefile.am index 7d9de753d..21fef82e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,7 +100,9 @@ AM_LDFLAGS = $(GLIB_LDFLAGS) $(GLIB_LIBS) \ -lds -ldshalcli endif +if POWERCONTROLLER_ENABLE AM_LDFLAGS += -lWPEFrameworkPowerController +endif AM_CFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) diff --git a/src/configure.ac b/src/configure.ac index d62a94a95..4ad41b460 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -42,15 +42,7 @@ AC_FUNC_REALLOC # Check for GLib 2.0 PKG_CHECK_MODULES([GLIB], [glib-2.0]) -# This enables libsoup-3 support -AC_ARG_ENABLE([libsoup3], -[ --enable-libsoup3 Turn on libsoup-3 support], -[case "${enableval}" in - yes) libsoup3=true ;; - no) libsoup3=false ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-libsoup3]) ;; -esac],[libsoup3=false]) -AM_CONDITIONAL([LIBSOUP3_ENABLE], [test x$libsoup3 = xtrue]) + AC_ARG_ENABLE([t2api], AS_HELP_STRING([--enable-t2api],[enables telemetry]), diff --git a/src/hostif/handlers/Makefile.am b/src/hostif/handlers/Makefile.am index bdb7fbf5b..3f73b9d7b 100644 --- a/src/hostif/handlers/Makefile.am +++ b/src/hostif/handlers/Makefile.am @@ -44,13 +44,8 @@ AM_CXXFLAGS = -I$(top_srcdir)/src/hostif/include \ -I=/usr/include/rdk/ds/ \ -I=/usr/include/rdk/ds-hal/ \ $(XRDK_RF4CE_PROFILE_FLAG) \ - -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/rbus/ - -if LIBSOUP3_ENABLE -AM_CXXFLAGS += -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -AM_CXXFLAGS += -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/libsoup-2.4 -endif + -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/rbus/ \ + -I=/usr/include/libsoup-3.0/ AM_CXXFLAGS += "-std=c++11" $(PROCPS_CFLAGS) @@ -94,7 +89,7 @@ if WITH_SNMP_ADAPTER AM_CXXFLAGS += -DSNMP_ADAPTER_ENABLED -I$(top_srcdir)/src/hostif/snmpAdapter endif -AM_LDFLAGS = $(GLIB_LIBS) $(G_THREAD_LIBS) $(SOUP_LIBS) $(PROCPS_LIBS) -lIARMBus -lyajl -lds -ldshalcli -ldbus-1 -lsecure_wrapper +AM_LDFLAGS = $(GLIB_LIBS) $(G_THREAD_LIBS) $(SOUP_LIBS) $(PROCPS_LIBS) -lIARMBus -lyajl -lds -ldshalcli -ldbus-1 -lsoup-3.0 -lgobject-2.0 -lsecure_wrapper if WIFI_CLIENT_ROAMING AM_CXXFLAGS += -DWIFI_CLIENT_ROAMING endif diff --git a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp index 9451b4a6c..36bd01b2f 100644 --- a/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_IARM_ReqHandler.cpp @@ -36,8 +36,12 @@ #include "libIBus.h" #include "libIARM.h" #include "sysMgr.h" +#ifdef RDKV_TR69 +#include "pwrMgr.h" +#else #include "power_controller.h" #include +#endif #ifdef SNMP_ADAPTER_ENABLED #include "hostIf_SNMPClient_ReqHandler.h" #endif @@ -48,8 +52,9 @@ #define X_RDK_RFC_DEEPSLEEP_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Power.DeepSleepNotification.Enable" #define RETRYSLEEP (300 * 1000) //Retry sleep - +#ifndef RDKV_TR69 static bool IsPwrCtlInt = false; +#endif static bool TR69_HostIf_Mgr_Init(); static bool TR69_HostIf_Mgr_Connect(); static bool TR69_HostIf_Mgr_Get_RegisterCall(); @@ -59,8 +64,12 @@ static IARM_Result_t _Settr69HostIfMgr(void *arg); static IARM_Result_t _SetAttributestr69HostIfMgr(void *arg); static IARM_Result_t _GetAttributestr69HostIfMgr(void *arg); static IARM_Result_t _RegisterForEventstr69HostIfMgr(void *arg); +#ifdef RDKV_TR69 +static void _hostIf_EventHandler(const char *, IARM_EventId_t, void *, size_t); +#else static void _hostIf_EventHandler(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); +#endif //---------------------------------------------------------------------- // hostIf_IARM_IF_Start: This shall be use to initialize and register // the hostIf application to IARM bus. @@ -77,8 +86,13 @@ bool hostIf_IARM_IF_Start() ret = true; /* Initialize Managers */ msgHandler *pMsgHandler; + #ifdef RDKV_TR69 + pMsgHandler = DSClientReqHandler::getInstance(); + pMsgHandler->init(); + #endif pMsgHandler = DeviceClientReqHandler::getInstance(); pMsgHandler->init(); + #ifdef SNMP_ADAPTER_ENABLED pMsgHandler = SNMPClientReqHandler::getInstance(); @@ -90,7 +104,7 @@ bool hostIf_IARM_IF_Start() return ret; } - +#ifndef RDKV_TR69 void hostIf_getPwrContInterface() { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); @@ -123,6 +137,7 @@ void hostIf_getPwrContInterface() RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); } +#endif //---------------------------------------------------------------------- //Initialization: This shall be initialized tr69 application to IARM bus. @@ -141,7 +156,7 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## return false; } RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] Success 'IARM_Bus_Init(%s)'.\n", __FUNCTION__, IARM_BUS_TR69HOSTIFMGR_NAME); - + #ifndef RDKV_TR69 // Get powercontroller thunder client interface in separate thread std::thread pwrThread(hostIf_getPwrContInterface); if(pwrThread.joinable()) @@ -153,6 +168,7 @@ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"########################################## { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: Failed to create getPwrContInterface thread.. \n", __FUNCTION__, __LINE__); } + #endif RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return true; @@ -208,6 +224,9 @@ static bool TR69_HostIf_Mgr_Get_RegisterCall() /* Notification RPC:*/ IARM_Bus_RegisterEvent(IARM_BUS_TR69HOSTIFMGR_EVENT_MAX); + #ifdef RDKV_TR69 + IARM_Bus_RegisterEventHandler(IARM_BUS_PWRMGR_NAME,IARM_BUS_PWRMGR_EVENT_MODECHANGED, _hostIf_EventHandler); + #endif RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return ret; } @@ -319,7 +338,7 @@ static IARM_Result_t tr69hostIfMgr_Stop(void) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Failed to IARM_Bus_Term(), return with Error code: %d\n", __FUNCTION__, err); } - + #ifndef RDKV_TR69 if (IsPwrCtlInt) { RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Registering power mode change callback..\n", __FUNCTION__, __FILE__); @@ -338,6 +357,7 @@ static IARM_Result_t tr69hostIfMgr_Stop(void) { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d]: No PowerController interface .. IsPwrCtlInt = %d\n", __FUNCTION__, __LINE__, IsPwrCtlInt); } + #endif RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return err; } @@ -456,6 +476,51 @@ static IARM_Result_t _Gettr69HostIfMgr(void *arg) //---------------------------------------------------------------------- //_hostIf_EventHandler: This is to listen the IARM events and handles. //---------------------------------------------------------------------- + +#ifdef RDKV_TR69 +static void _hostIf_EventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + if (0 == strcmp(owner, IARM_BUS_PWRMGR_NAME)) + { + errno_t rc = -1; + HOSTIF_MsgData_t stRfcData = {0}; + rc=strcpy_s(stRfcData.paramName,sizeof(stRfcData.paramName), X_RDK_RFC_DEEPSLEEP_ENABLE); + if(rc!=EOK) + { + ERR_CHK(rc); + } + if((hostIf_DeviceInfo::getInstance(0)->get_xRDKCentralComRFC(&stRfcData) == OK) && (strncmp(stRfcData.paramValue, "true", sizeof("true")) == 0)) + { + IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; + IARM_Bus_PWRMgr_PowerState_t curPowerState = param->data.state.curState; + IARM_Bus_PWRMgr_PowerState_t newPowerState = param->data.state.newState; + const char *event_time = NULL; + + if((newPowerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) && + (curPowerState != IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP)) + { + std::string event_time_string = std::to_string(std::time(nullptr)); + event_time = event_time_string.c_str(); + NotificationHandler::getInstance()->push_device_deepsleep_notifications("device-enter-deepsleep-state", event_time); + } + else if((newPowerState != IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP) && + (curPowerState == IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP)) + { + std::string event_time_string = std::to_string(std::time(nullptr)); + event_time = event_time_string.c_str(); + NotificationHandler::getInstance()->push_device_deepsleep_notifications("device-exit-deepsleep-state", event_time); + } + } + else + { + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] RFC Parameter (%s) is disabled, so not sending DeepSleep notification. \n", + __FUNCTION__, X_RDK_RFC_DEEPSLEEP_ENABLE ); + } + } + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); +} +#else static void _hostIf_EventHandler(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata) { @@ -494,6 +559,7 @@ static void _hostIf_EventHandler(const PowerController_PowerState_t currentState RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); } +#endif /** @} */ /** @} */ diff --git a/src/hostif/handlers/src/hostIf_WiFi_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_WiFi_ReqHandler.cpp index 33c48e292..1b4be8168 100644 --- a/src/hostif/handlers/src/hostIf_WiFi_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_WiFi_ReqHandler.cpp @@ -255,6 +255,44 @@ int WiFiReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) const char *pSetting; const int maxSSID_Instances = 1; int instanceNum = 0; + #ifdef RDKV_TR69 + const int maxRadioInstances = 1; + int radioIndex = 1; + if (strcasecmp(stMsgData->paramName,"Device.WiFi.RadioNumberOfEntries") == 0) + { + stMsgData->instanceNum = maxRadioInstances; + hostIf_WiFi *pIface = hostIf_WiFi::getInstance(maxRadioInstances); + + if(!pIface) + { + return NOK; + } + + ret = pIface->get_Device_WiFi_RadioNumberOfEntries(stMsgData); + } + else if (strcasecmp(stMsgData->paramName,"Device.WiFi.SSIDNumberOfEntries") == 0) + { + stMsgData->instanceNum = maxSSID_Instances; + hostIf_WiFi *pIface = hostIf_WiFi::getInstance(maxSSID_Instances); + + if(!pIface) + { + return NOK; + } + + ret = pIface->get_Device_WiFi_SSIDNumberOfEntries(stMsgData); + } + else if (strcasecmp(stMsgData->paramName,"Device.WiFi.AccessPointNumberOfEntries") == 0) + { + stMsgData->instanceNum = 0; + hostIf_WiFi *pIface = hostIf_WiFi::getInstance(stMsgData->instanceNum); + if(!pIface) + { + return NOK; + } + ret = pIface->get_Device_WiFi_AccessPointNumberOfEntries(stMsgData); + } + #else if (strcasecmp(stMsgData->paramName,"Device.WiFi.AccessPointNumberOfEntries") == 0) { @@ -268,6 +306,7 @@ int WiFiReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) ret = pIface->get_Device_WiFi_AccessPointNumberOfEntries(stMsgData); } + #endif else if (strcasecmp(stMsgData->paramName,"Device.WiFi.EndPointNumberOfEntries") == 0) { hostIf_WiFi *pIface = hostIf_WiFi::getInstance (1); @@ -288,6 +327,179 @@ int WiFiReqHandler::handleGetMsg(HOSTIF_MsgData_t *stMsgData) } ret = pIface->get_Device_WiFi_EnableWiFi(stMsgData); } + #ifdef RDKV_TR69 + else if (matchComponent(stMsgData->paramName, "Device.WiFi.Radio", &pSetting, instanceNum)) + { + if ((instanceNum <= 0) || (instanceNum > maxRadioInstances)) + { + return NOK; + } + + stMsgData->instanceNum = instanceNum; + hostIf_WiFi_Radio *pWifiRadio = hostIf_WiFi_Radio::getInstance(stMsgData->instanceNum); + hostIf_WiFi_Radio_Stats *pWifiRadioStats = hostIf_WiFi_Radio_Stats::getInstance(stMsgData->instanceNum); + + if ((!pWifiRadio) || (!pWifiRadioStats)) + { + return NOK; + } + + if (strcasecmp(pSetting,"Enable") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_Enable(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Status") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_Status(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Alias") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_Alias(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Name") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_Name(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"LastChange") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_LastChange(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"LowerLayers") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_LowerLayers(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Upstream") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_Upstream(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"MaxBitRate") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_MaxBitRate(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"SupportedFrequencyBands") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_SupportedFrequencyBands(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"OperatingFrequencyBand") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_OperatingFrequencyBand(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"SupportedStandards") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_SupportedStandards(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"OperatingStandards") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_OperatingStandards(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"PossibleChannels") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_PossibleChannels(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"ChannelsInUse") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_ChannelsInUse(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Channel") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_Channel(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"AutoChannelSupported") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_AutoChannelSupported(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"AutoChannelEnable") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_AutoChannelEnable(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"AutoChannelRefreshPeriod") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_AutoChannelRefreshPeriod(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"OperatingChannelBandwidth") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_OperatingChannelBandwidth(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"ExtensionChannel") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_ExtensionChannel(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"GuardInterval") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_GuardInterval(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"MCS") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_MCS(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"MCS") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_MCS(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"TransmitPowerSupported") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_TransmitPowerSupported(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"TransmitPower") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_TransmitPower(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"IEEE80211hSupported") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_IEEE80211hSupported(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"IEEE80211hEnabled") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_IEEE80211hEnabled(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"RegulatoryDomain") == 0) + { + ret = pWifiRadio->get_Device_WiFi_Radio_RegulatoryDomain(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.BytesSent") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_BytesSent(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.BytesReceived") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_BytesReceived(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.PacketsSent") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_PacketsSent(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.PacketsReceived") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_PacketsReceived(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.ErrorsSent") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_ErrorsSent(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.ErrorsReceived") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_ErrorsReceived(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.DiscardPacketsSent") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_DiscardPacketsSent(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.DiscardPacketsReceived") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_DiscardPacketsReceived(stMsgData,radioIndex); + } + else if (strcasecmp(pSetting,"Stats.Noise") == 0) + { + ret = pWifiRadioStats->get_Device_WiFi_Radio_Stats_NoiseFloor(stMsgData,radioIndex); + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%d] Parameter : \'%s\' is Not Supported \n", __FUNCTION__, __LINE__, stMsgData->paramName); + stMsgData->faultCode = fcInvalidParameterName; + ret = NOK; + } + } + #endif else if (matchComponent(stMsgData->paramName, "Device.WiFi.Endpoint", &pSetting, instanceNum)) { stMsgData->instanceNum = instanceNum; @@ -557,6 +769,34 @@ void WiFiReqHandler::checkForUpdates() RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%s] hostIf_WiFi::getInstance(1) returned NULL\n", __FILE__, __FUNCTION__); return; } + #ifdef RDKV_TR69 + HOSTIF_MsgData_t stMsgData; + + if (OK == pIface->get_Device_WiFi_SSIDNumberOfEntries(&stMsgData)) + { + int currentSSIDNumberOfEntries = get_int (stMsgData.paramValue); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] currentSSIDNumberOfEntries = %d, savedSSIDNumberOfEntries = %d\n", + __FILE__, __FUNCTION__, currentSSIDNumberOfEntries, savedSSIDNumberOfEntries); + sendAddRemoveEvents (mUpdateCallback, currentSSIDNumberOfEntries, savedSSIDNumberOfEntries, (char *)DEVICE_WIFI_SSID_PROFILE); + } + + if (!bfirstInstance && (OK == pIface->get_Device_WiFi_RadioNumberOfEntries (&stMsgData))) + { + bfirstInstance = true; + int currentRadioNumberOfEntries = get_int (stMsgData.paramValue); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] currentRadioNumberOfEntries = %d, savedRadioNumberOfEntries = %d\n", + __FILE__, __FUNCTION__, currentRadioNumberOfEntries, savedRadioNumberOfEntries); + sendAddRemoveEvents (mUpdateCallback, currentRadioNumberOfEntries, savedRadioNumberOfEntries, (char *)DEVICE_WIFI_RADIO_PROFILE); + } + + if (OK == pIface->get_Device_WiFi_EndPointNumberOfEntries (&stMsgData)) + { + int currentEndPointNumberOfEntries = get_int (stMsgData.paramValue); + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s:%s] currentEndPointNumberOfEntries = %d, savedEndPointNumberOfEntries = %d\n", + __FILE__, __FUNCTION__, currentEndPointNumberOfEntries, savedEndPointNumberOfEntries); + sendAddRemoveEvents (mUpdateCallback, currentEndPointNumberOfEntries, savedEndPointNumberOfEntries, (char *)DEVICE_WIFI_ENDPOINT_PROFILE); + } + #endif } #endif /* #ifdef USE_WIFI_PROFILE */ diff --git a/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp index 0c5ee286d..3f67b39a4 100644 --- a/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_XREClient_ReqHandler.cpp @@ -162,6 +162,17 @@ int XREClientReqHandler::handleSetMsg(HOSTIF_MsgData_t *stMsgData) { ret = set_Device_X_COMCAST_COM_Xcalibur_Client_XRE_xreLogLevel(stMsgData); } + #ifdef RDKV_TR69 + else if(strcasecmp(stMsgData->paramName,"Device.X_COMCAST-COM_Xcalibur.Client.XRE.xreReceiverRestart") == 0) + { + ret = setXreReceiverRestart(stMsgData); + } + else if(strcasecmp(stMsgData->paramName,"Device.X_COMCAST-COM_Xcalibur.DevApp.devAppRestartRequest") == 0) + { + // xreReceiverRestart uses /lib/rdk/restartReceiver.sh, which sometimes doesn't start receiver back + ret = setDevAppRestartRequest(stMsgData); + } + #endif else { stMsgData->faultCode = fcInvalidParameterName; @@ -499,7 +510,7 @@ int set_Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow(HOSTIF_MsgData_t *stM } else { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: \"%s\" Invalid Input. Valid Input is \"TRUE\" \n",__FILE__,__FUNCTION__,__LINE__,stMsgData->paramValue); + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF, "[%s:%s:%d]Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: \"%s\" Invalid Input. Valid Input is \"TRUE or CANARY\" \n",__FILE__,__FUNCTION__,__LINE__,stMsgData->paramValue); return NOK; } return OK; diff --git a/src/hostif/handlers/src/hostIf_jsonReqHandlerThread.cpp b/src/hostif/handlers/src/hostIf_jsonReqHandlerThread.cpp index 8ca599b7c..66eb2a43b 100644 --- a/src/hostif/handlers/src/hostIf_jsonReqHandlerThread.cpp +++ b/src/hostif/handlers/src/hostIf_jsonReqHandlerThread.cpp @@ -34,11 +34,7 @@ #include "hostIf_msgHandler.h" #include "hostIf_utils.h" #include -#ifdef LIBSOUP3_ENABLE #include "libsoup-3.0/libsoup/soup.h" -#else -#include "libsoup-2.4/libsoup/soup.h" -#endif #include #include extern T_ARGLIST argList; @@ -222,7 +218,6 @@ hostIf_HTTPJsonParse(const unsigned char *message, int length) return context.list; } -#ifdef LIBSOUP3_ENABLE void hostIf_HTTPJsonMsgHandler( SoupServer *server, SoupServerMessage *msg, @@ -338,123 +333,6 @@ void hostIf_HTTPJsonMsgHandler( RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return; } -#else -void hostIf_HTTPJsonMsgHandler( - SoupServer *server, - SoupMessage *msg, - const gchar *path, - GHashTable *query, - SoupClientContext *client, - gpointer user_data) -{ - GList *params; - - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); - - if (!msg->request_body || - !msg->request_body->data || - !msg->request_body->length) - { - soup_message_set_status_full (msg, SOUP_STATUS_BAD_REQUEST, "No request data."); - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting.. Failed due to no message data.\n", __FUNCTION__, __FILE__); - return; - } - - params = hostIf_HTTPJsonParse((const unsigned char *) msg->request_body->data, msg->request_body->length); - if (!params) - { - soup_message_set_status_full (msg, SOUP_STATUS_BAD_REQUEST, "No request data."); - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting... Failed due to Parse HTTP Json messages. \n", __FUNCTION__, __FILE__); - return; - } - - yajl_gen json; -#ifndef YAJL_V2 - json = yajl_gen_alloc(/* &allocFuncs */ NULL, NULL); -#else - json = yajl_gen_alloc(NULL); -#endif - if (!json) - { - soup_message_set_status_full (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, "Cannot create return object"); - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting.. Failed to create json object\n", __FUNCTION__, __FILE__); - return; - } - - yajl_gen_map_open(json); - yajl_gen_string(json, (const unsigned char *) "paramList", 9); - yajl_gen_array_open(json); - - GList *l = params; - while (l) - { - HOSTIF_MsgData_t *param = (HOSTIF_MsgData_t *) g_malloc0(sizeof(HOSTIF_MsgData_t)); - strncpy( param->paramName,(char *) l->data,TR69HOSTIFMGR_MAX_PARAM_LEN ); - // requestList = g_list_append(requestList, param); - - if (hostIf_GetMsgHandler(param) == OK) //We are expecting on Get call from JSON - { - yajl_gen_map_open(json); - yajl_gen_string(json, (const unsigned char *) "name", 4); - yajl_gen_string(json, (const unsigned char *) param->paramName, strlen(param->paramName)); - - yajl_gen_string(json, (const unsigned char *) "value", 5); - switch (param->paramtype) { - case hostIf_StringType: - yajl_gen_string(json, (const unsigned char*) param->paramValue, strlen((char*)param->paramValue)); - break; - case hostIf_IntegerType: - case hostIf_UnsignedIntType: - yajl_gen_integer(json, get_int(param->paramValue)); - break; - case hostIf_UnsignedLongType: - yajl_gen_integer(json, get_ulong(param->paramValue)); - break; - case hostIf_BooleanType: - yajl_gen_bool(json, get_boolean(param->paramValue)); - break; - case hostIf_DateTimeType: - // TODO: What to do here? What is the actual data representation? - yajl_gen_string(json, (const unsigned char *) "Unknown", 7); - break; - default: - RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Unknown data type: %d", param->paramtype); - break; - } - - yajl_gen_map_close(json); - } - hostIf_Free_stMsgData(param); - - - l = l->next; - } - // Free the list, but do NOT deallocate the strings. They're now in the requestList - g_list_free_full(params, g_free); - params = NULL; - - // Close out the structures - yajl_gen_array_close(json); - yajl_gen_map_close(json); - - // Get the string - const unsigned char *buf; - unsigned int len; - yajl_gen_get_buf(json, &buf, &len); - - // TODO: What is the correct MIME type? - soup_message_set_response(msg, (const char *) "application/json", SOUP_MEMORY_COPY, (const char *) buf, len); - soup_message_set_status (msg, SOUP_STATUS_OK); - - yajl_gen_free(json); - - //json_t* incommingReq = NULL; - //json_t* outRes = NULL; - // ret = hostIf_JsonReqResHandler (incommingReq, outRes); - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); - return; -} -#endif /** * @brief This API is used to initialize and start the HTTP server process. It use to serve the @@ -471,11 +349,7 @@ void hostIf_HttpServerStart() #endif if(server == NULL) -#ifdef LIBSOUP3_ENABLE server = soup_server_new("server-header", "hostif", NULL); -#else - server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "hostif", NULL); -#endif if (!server) { diff --git a/src/hostif/httpserver/Makefile.am b/src/hostif/httpserver/Makefile.am index 8538515ce..2e8769a34 100644 --- a/src/hostif/httpserver/Makefile.am +++ b/src/hostif/httpserver/Makefile.am @@ -21,12 +21,8 @@ noinst_LTLIBRARIES=libhttpserver.la libhttpserver_la_SOURCES=src/http_server.cpp src/request_handler.cpp src/XrdkCentralComRFCVar.cpp -libhttpserver_la_LDFLAGS = -lrdkloggers -lwdmp-c $(SOUP_LIBS) -lcjson -if LIBSOUP3_ENABLE -libhttpserver_la_LDFLAGS += -lsoup-3.0 -else -libhttpserver_la_LDFLAGS += -lsoup-2.4 -endif +libhttpserver_la_LDFLAGS = -lrdkloggers -lwdmp-c $(SOUP_LIBS) -lcjson -lsoup-3.0 + AM_CXXFLAGS = "-std=c++11" $(SOUP_CFLAGS) -I$(top_srcdir)/src/hostif/httpserver/include \ -I$(top_srcdir)/src/hostif/include \ @@ -37,13 +33,8 @@ AM_CXXFLAGS = "-std=c++11" $(SOUP_CFLAGS) -I$(top_srcdir)/src/hostif/httpserver/ -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/glib-2.0 \ -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/glib-2.0/include \ -I$(top_srcdir)/src/hostif/parodusClient/waldb \ - -I$(top_srcdir)/src/hostif/parodusClient/pal - -if LIBSOUP3_ENABLE -AM_CXXFLAGS += -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -AM_CXXFLAGS += -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/libsoup-2.4 -endif + -I$(top_srcdir)/src/hostif/parodusClient/pal \ + -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/libsoup-3.0 diff --git a/src/hostif/httpserver/src/http_server.cpp b/src/hostif/httpserver/src/http_server.cpp index 47479fbb5..cfd53d163 100644 --- a/src/hostif/httpserver/src/http_server.cpp +++ b/src/hostif/httpserver/src/http_server.cpp @@ -48,7 +48,7 @@ extern bool httpServerThreadDone; extern T_ARGLIST argList; static SoupServer *http_server = NULL; -#ifdef LIBSOUP3_ENABLE + static void HTTPRequestHandler( SoupServer *server, SoupServerMessage *msg, @@ -220,177 +220,7 @@ static void HTTPRequestHandler( RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return; } -#else -static void HTTPRequestHandler( - SoupServer *server, - SoupMessage *msg, - const char *path, - GHashTable *query, - SoupClientContext *client, - void *user_data) -{ - cJSON *jsonRequest = NULL; - cJSON *jsonResponse = NULL; - req_struct *reqSt = NULL; - res_struct *respSt = NULL; - struct timespec start,end,*startPtr,*endPtr; - startPtr = &start; - endPtr = &end; - - RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); - getCurrentTime(startPtr); - if (!msg->request_body || - !msg->request_body->data || - !msg->request_body->length) - { - soup_message_set_status_full (msg, SOUP_STATUS_BAD_REQUEST, "No request data."); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. Failed due to no message data.\n", __FUNCTION__, __FILE__); - return; - } - - const char *pcCallerID = (char *)soup_message_headers_get_one(msg->request_headers, "CallerID"); - - jsonRequest = cJSON_Parse((const char *) msg->request_body->data); - - if(jsonRequest) - { - reqSt = (req_struct *)malloc(sizeof(req_struct)); - if(reqSt == NULL) - { - soup_message_set_status_full (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, "Cannot create return object"); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. Failed to create req_struct\n", __FUNCTION__, __FILE__); - return; - } - memset(reqSt, 0, sizeof(req_struct)); - - if(!strcmp(msg->method, "GET")) - { - if(!pcCallerID || !strlen(pcCallerID)) - { - pcCallerID = "Unknown"; - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%s] Unknown Caller ID, GET is allowed by default\n", __FUNCTION__, __FILE__); - } - else - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"[%s:%s] GET with CallerID : %s..\n", __FUNCTION__, __FILE__, pcCallerID); - parse_get_request(jsonRequest, &reqSt, WDMP_TR181); - respSt = handleRequest(pcCallerID, reqSt); - if(respSt) - { - jsonResponse = cJSON_CreateObject(); - wdmp_form_get_response(respSt, jsonResponse); - - // WDMP Code sets a generic statusCode, the following lines replace it with an actual error code. - int new_st_code = 0; - - for(size_t paramIndex = 0; paramIndex < respSt->paramCnt; paramIndex++) - { - if(respSt->retStatus[paramIndex] != 0 || paramIndex == respSt->paramCnt-1) - { - new_st_code = respSt->retStatus[paramIndex]; - break; - } - } - cJSON * stcode = cJSON_GetObjectItem(jsonResponse, "statusCode"); - if( NULL != stcode) - { - cJSON_SetIntValue(stcode, new_st_code); - } - } - else - { - soup_message_set_status_full (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, "Invalid request format"); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. Request couldn't be processed\n", __FUNCTION__, __FILE__); - return; - } - } - else if(!strcmp(msg->method, "POST")) - { - if(!pcCallerID || !strlen(pcCallerID)) - { - soup_message_set_status_full (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, "POST Not Allowed without CallerID"); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. POST operation not allowed with unknown CallerID\n", __FUNCTION__, __FILE__); - wdmp_free_req_struct(reqSt); - reqSt = NULL; - return; - } - else - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"[%s:%s] POST with CallerID : %s..\n", __FUNCTION__, __FILE__, pcCallerID); - - parse_set_request(jsonRequest, &reqSt, WDMP_TR181); - RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"Calling handleRequest...\n"); - respSt = handleRequest(pcCallerID, reqSt); - if(respSt) - { - jsonResponse = cJSON_CreateObject(); - wdmp_form_set_response(respSt, jsonResponse); - // WDMP Code sets a generic statusCode, the following lines replace it with an actual error code. - int new_st_code = 0; - - for(size_t paramIndex = 0; paramIndex < respSt->paramCnt; paramIndex++) - { - if(respSt->retStatus[paramIndex] != 0 || paramIndex == respSt->paramCnt-1) - { - new_st_code = respSt->retStatus[paramIndex]; - break; - } - } - cJSON * stcode = cJSON_GetObjectItem(jsonResponse, "statusCode"); - if( NULL != stcode) - { - cJSON_SetIntValue(stcode, new_st_code); - } - } - else - { - soup_message_set_status_full (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, "Invalid request format"); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. Request couldn't be processed\n", __FUNCTION__, __FILE__); - wdmp_free_req_struct(reqSt); - reqSt = NULL; - return; - } - } - else - { - soup_message_set_status_full (msg, SOUP_STATUS_NOT_IMPLEMENTED, "Method not implemented"); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. Unsupported operation \n", __FUNCTION__, __FILE__); - wdmp_free_req_struct(reqSt); - reqSt = NULL; - return; - } - - char *buf = cJSON_Print(jsonResponse); - - if(buf) { - soup_message_set_response(msg, (const char *) "application/json", SOUP_MEMORY_COPY, buf, strlen(buf)); - soup_message_set_status (msg, SOUP_STATUS_OK); - } - - wdmp_free_req_struct(reqSt); - reqSt = NULL; - cJSON_Delete(jsonRequest); - cJSON_Delete(jsonResponse); - wdmp_free_res_struct(respSt); - respSt = NULL; - - if(buf != NULL) { - free(buf); - buf = NULL; - } - } - else - { - soup_message_set_status_full (msg, SOUP_STATUS_BAD_REQUEST, "Bad Request"); - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF,"[%s:%s] Exiting.. Failed to parse JSON Message \n", __FUNCTION__, __FILE__); - return; - } - - getCurrentTime(endPtr); - RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Curl Request Processing Time : %lu ms\n", timeValDiff(startPtr, endPtr)); - RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); - return; -} -#endif void *HTTPServerStartThread(void *msg) { @@ -413,11 +243,7 @@ void *HTTPServerStartThread(void *msg) } if(http_server == NULL) -#ifdef LIBSOUP3_ENABLE http_server = soup_server_new("server-header", "HTTPServer", NULL); -#else - http_server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "HTTPServer", NULL); -#endif if (!http_server) { diff --git a/src/hostif/include/hostIf_main.h b/src/hostif/include/hostIf_main.h index d615a1a9e..79b155ec0 100644 --- a/src/hostif/include/hostIf_main.h +++ b/src/hostif/include/hostIf_main.h @@ -112,17 +112,20 @@ extern gchar *date_str; - +#ifndef RDKV_TR69 typedef enum { MERGE_SUCCESS, MERGE_FAILURE } MergeStatus; +#endif void tr69hostIf_logger (const gchar *log_domain, GLogLevelFlags log_level,const gchar *message, gpointer user_data); +#ifndef RDKV_TR69 MergeStatus mergeDataModel(); bool filter_and_merge_xml(const char *input1, const char *input2, const char *output); +#endif #define G_LOG_DOMAIN ((gchar*) 0) #define LOG_TR69HOSTIF "LOG.RDK.TR69HOSTIF" diff --git a/src/hostif/include/hostIf_utils.h b/src/hostif/include/hostIf_utils.h index aee1ce8f9..179aa5760 100755 --- a/src/hostif/include/hostIf_utils.h +++ b/src/hostif/include/hostIf_utils.h @@ -54,6 +54,16 @@ #define BUFF_LENGTH_1024 1024 #define BUFF_LENGTH BUFF_LENGTH_1024 +#ifdef RDKV_TR69 +static const char* NOT_IMPLEMENTED = "Not Implemented"; + +static const char* STATE_UP = "Up"; +static const char* STATE_DOWN = "Down"; + +static const char* TIME_UNKNOWN = "0001-01-01T00:00:00Z"; +static const char* TIME_INFINITY = "9999-12-31T23:59:59Z"; +#endif + typedef enum __eSTBResetState { NoReset = 0, diff --git a/src/hostif/parodusClient/pal/webpa_parameter.h b/src/hostif/parodusClient/pal/webpa_parameter.h index 995557875..ca2d81dbb 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.h +++ b/src/hostif/parodusClient/pal/webpa_parameter.h @@ -32,8 +32,11 @@ extern "C" #endif #include "webpa_adapter.h" - +#ifdef RDKV_TR69 +#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" +#else #define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" +#endif #define MAX_NUM_PARAMETERS 2048 #define MAX_DATATYPE_LENGTH 48 #define MAX_PARAM_LENGTH TR69HOSTIFMGR_MAX_PARAM_LEN diff --git a/src/hostif/parodusClient/waldb/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model-generic.xml new file mode 100644 index 000000000..7db6d2ccd --- /dev/null +++ b/src/hostif/parodusClient/waldb/data-model-generic.xml @@ -0,0 +1,2025 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 49b797f36..4d69646ab 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -3586,6 +3586,19 @@ + + + + + + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/waldb.cpp b/src/hostif/parodusClient/waldb/waldb.cpp index 62a28be96..e62467998 100644 --- a/src/hostif/parodusClient/waldb/waldb.cpp +++ b/src/hostif/parodusClient/waldb/waldb.cpp @@ -59,8 +59,11 @@ int checkMatchingParameter(const char* attrValue, char* paramName, int* ret); void appendNextObject(char* currentParam, const char* pAttparam); int getNumberofInstances(const char* paramName); - +#ifdef RDKV_TR69 +#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" +#else #define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" +#endif static void *g_dbhandle = NULL; std::mutex g_db_mutex; diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 926e169b9..4dacf35c1 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -63,7 +63,11 @@ #include "mfrMgr.h" #include "Device_DeviceInfo.h" #include "hostIf_utils.h" +#ifdef RDKV_TR69 +#include "pwrMgr.h" +#else #include "power_controller.h" +#endif #include "rbus.h" #include @@ -74,6 +78,12 @@ #include "audioOutputPort.hpp" #include "sysMgr.h" +#ifdef RDKV_NM +#ifdef MEDIA_CLIENT +#include "netsrvmgrIarm.h" +#endif +#endif + #ifdef USE_REMOTE_DEBUGGER #include "rrdInterface.h" #endif @@ -93,7 +103,7 @@ #include "hostIf_NotificationHandler.h" #include "safec_lib.h" -#include "power_controller.h" + #define VERSION_FILE "/version.txt" #define SOC_ID_FILE "/var/log/socprov.log" @@ -118,6 +128,8 @@ #define MIN_PORT_RANGE 3000 #define MAX_PORT_RANGE 3020 +#define MEMINSIGHT_SERVICE "meminsight-runner.service" +#define MEMINSIGHT_ENABLE_FILE "/opt/.enable_meminsight" #define DEVICEID_SCRIPT_PATH "/lib/rdk/getDeviceId.sh" #define SCRIPT_OUTPUT_BUFFER_SIZE 512 #define ENTRY_WIDTH 64 @@ -155,8 +167,9 @@ XRFCStorage hostIf_DeviceInfo::m_rfcStorage; #endif XBSStore* hostIf_DeviceInfo::m_bsStore; string hostIf_DeviceInfo::m_xrPollingAction = "0"; - +#ifndef RDKV_TR69 static bool bPowerControllerEnable; +#endif /****************************************************************************************************************************************************/ // Device.DeviceInfo Profile. Getters: @@ -1252,9 +1265,27 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_MAC(HOSTIF_MsgDat string hostIf_DeviceInfo::getEstbIp() { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__); + #ifdef RDKV_TR69 + string retAddr; + #else string retAddr = ""; string ifc = ""; + #endif #if MEDIA_CLIENT + #ifdef RDKV_TR69 + IARM_Result_t ret = IARM_RESULT_SUCCESS; + IARM_BUS_NetSrvMgr_Iface_EventData_t param; + memset(¶m, 0, sizeof(param)); + try + { + ret = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME,IARM_BUS_NETSRVMGR_API_getSTBip, (void*)¶m, sizeof(param)); + if (ret != IARM_RESULT_SUCCESS ) + { + RDK_LOG(RDK_LOG_DEBUG, LOG_TR69HOSTIF,"[%s():%d] IARM_BUS_NETSRVMGR_API_getActiveInterface failed \n", __FUNCTION__, __LINE__); + } + retAddr=param.activeIfaceIpaddr; + } + #else std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetPrimaryInterface\"}"; string response = getJsonRPCData(std::move(postData)); @@ -1298,7 +1329,7 @@ string hostIf_DeviceInfo::getEstbIp() { RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData failed\n", __FUNCTION__); } - + postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetIPSettings\", \"params\" : { \"interface\" : \"" + ifc + "\"}}"; response = getJsonRPCData(std::move(postData)); if(response.c_str()) @@ -1341,7 +1372,8 @@ string hostIf_DeviceInfo::getEstbIp() { RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData failed\n", __FUNCTION__); } - //Legacy way of getting estb ip. + #endif +////Legacy way of getting estb ip. #else struct ifaddrs *ifAddrStr = NULL; @@ -1440,14 +1472,24 @@ string hostIf_DeviceInfo::getEstbIp() else { retAddr = tmp_buff; } - } catch (const std::exception& e) { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Exception getting IP\n",__FUNCTION__); + } + #ifndef RDKV_TR69 + catch (const std::exception& e) { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Exception getting IP\n",__FUNCTION__); + } + #endif +#endif +#ifdef RDKV_TR69 +catch (const std::exception &e) + { + RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s()]Exception caught %s\n", __FUNCTION__, e.what()); } #endif RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); return retAddr; } + bool hostIf_DeviceInfo::isRsshactive() { const string pidfile("/var/tmp/rssh.pid"); @@ -1489,6 +1531,8 @@ bool hostIf_DeviceInfo::isRsshactive() * @retval ERR_INTERNAL_ERROR if not able to fetch data from the device. * @ingroup TR69_HOSTIF_DEVICEINFO_API */ + + int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData_t * stMsgData, bool *pChanged) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__); @@ -1517,10 +1561,14 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_STB_IP(HOSTIF_MsgData return OK; } + +#ifndef RDKV_TR69 void hostIf_DeviceInfo::setPowerConInterface( bool isPwrContEnalbe) { bPowerControllerEnable = isPwrContEnalbe; + } +#endif /** * @brief The X_COMCAST_COM_PowerStatus as get parameter results in the power status @@ -1535,6 +1583,52 @@ void hostIf_DeviceInfo::setPowerConInterface( bool isPwrContEnalbe) * @retval NOK if not able to fetch data from the device. * @ingroup TR69_HOSTIF_DEVICEINFO_API */ + +#ifdef RDKV_TR69 +int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_MsgData_t * stMsgData, bool *pChanged) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__); + IARM_Result_t err; + int ret = NOK; + const char *pwrState = "PowerOFF"; + int str_len = 0; + IARM_Bus_PWRMgr_GetPowerState_Param_t param; + memset(¶m, 0, sizeof(param)); + IARM_Result_t iarm_ret = IARM_RESULT_IPCCORE_FAIL; + + err = IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, + IARM_BUS_PWRMGR_API_GetPowerState, + (void *)¶m, + sizeof(param)); + if(err == IARM_RESULT_SUCCESS) + { + pwrState = (param.curState==IARM_BUS_PWRMGR_POWERSTATE_OFF)?"PowerOFF":(param.curState==IARM_BUS_PWRMGR_POWERSTATE_ON)?"PowerON":"Standby"; + +// RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Current state is : (%d)%s\n",param.curState, pwrState); + str_len = strlen(pwrState); + try + { + strncpy((char *)stMsgData->paramValue, pwrState, str_len); + stMsgData->paramValue[str_len+1] = '\0'; + stMsgData->paramLen = str_len; + stMsgData->paramtype = hostIf_StringType; + ret = OK; + } catch (const std::exception e) + { + RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__); + ret = NOK; + } + } + else + { + 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); + ret = NOK; + } + + //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); + return ret; +} +#else int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_MsgData_t * stMsgData, bool *pChanged) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Entering..\n", __FUNCTION__); @@ -1580,6 +1674,7 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_Ms RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s()]Exiting..\n", __FUNCTION__); return ret; } +#endif /** * @brief Get the filename of the firmware currently running on the device. @@ -2987,10 +3082,11 @@ int hostIf_DeviceInfo::findLocalPortAvailable() return -1; } + int hostIf_DeviceInfo::set_xOpsReverseSshTrigger(HOSTIF_MsgData_t *stMsgData) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s] Entering... \n",__FUNCTION__); -#ifdef PRIVACYMODES_CONTROL + #ifdef PRIVACYMODES_CONTROL string privacyModeValue; string queryJsonPrivacy = "{\"jsonrpc\":\"2.0\",\"id\":\"3\",\"method\": \"org.rdk.System.getPrivacyMode\" }"; string response = getJsonRPCData(queryJsonPrivacy); @@ -3533,6 +3629,114 @@ int hostIf_DeviceInfo::set_xRDKCentralComBootstrap(HOSTIF_MsgData_t * stMsgData) return ret; } +#ifdef RDKV_TR69 +static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) +{ + const char *apparmor_profiledir = "/etc/apparmor.d"; + const char *service_profiles_dir = "/etc/apparmor/service_profiles"; + struct dirent *entry=NULL; + DIR *dir=NULL; + char *files_name = NULL; + size_t files_name_len = 0; + int number_of_profiles = 0; + char *token=NULL; + char *subtoken=NULL; + char *sub_string=NULL; + char *sp=NULL; + char *sptr=NULL; + char tmp[ENTRY_WIDTH]= {0}; + char *arg=NULL; + if(tmp_fptr == NULL){ + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"tmp_fptr empty, returning false\n"); + return FALSE; + } + dir=opendir(apparmor_profiledir); + if(dir == NULL) { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Failed to open Apparmor Profile directory\n"); + return FALSE; + } + while ((entry = readdir(dir)) != NULL) { + number_of_profiles++; + } + if (closedir(dir) != 0) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Failed to close Apparmor Profile directory\n"); + return false; + } + // Allocate the exact required buffer size directly + files_name = (char *)malloc(number_of_profiles * ENTRY_WIDTH); + if (files_name == NULL) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Memory allocation failed\n"); + return false; + } + files_name[0] = '\0'; // Ensure the buffer is initially empty + dir = opendir(apparmor_profiledir); + if (dir == NULL) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Failed to open Apparmor Profile directory\n"); + free(files_name); + return false; + } + // Read the entries and store in the buffer + while ((entry = readdir(dir)) != NULL) { + strncat(files_name, entry->d_name, ENTRY_WIDTH - 1); + files_name_len += strlen(entry->d_name); + } + if (closedir(dir) != 0) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Failed to close Apparmor Profile directory\n"); + free(files_name); + return false; + } + /* Read the input arguments and ensure the corresponding profiles exist or not by searching in + Apparmor profile directory (/etc/apparmor.d/). Returns false if input does not have the + apparmor profile, Returns true if apparmor profile finds for the input */ + token=strtok_r( input,"#", &sp); + while(token != NULL) { + arg=strchr(token,':'); + if (arg == NULL) { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Missing ':' in token: %s\n", token); + free(files_name); + return false; + } + if ( ( (strcmp(arg+1,"disable") != 0) && (strcmp(arg+1,"complain") != 0) && (strcmp(arg+1,"enforce") != 0) ) ) { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Invalid arguments in the parser:%s\n", token); + free(files_name); + return FALSE; + } + strncpy(tmp,token,sizeof(tmp)-1); + subtoken=strtok_r(tmp,":",&sptr); + if(subtoken != NULL) { + sub_string=strstr(files_name, subtoken); + if(sub_string != NULL) { + fprintf(tmp_fptr,"%s\n",token); + } else { + bool profile_found = false; + DIR *service_profiles_dir_ptr = opendir(service_profiles_dir); + if (service_profiles_dir_ptr != NULL) { + struct dirent *profile_entry = NULL; + while ((profile_entry = readdir(service_profiles_dir_ptr)) != NULL) { + // Check if the file ends with .service.sp and matches subtoken + if (strstr(profile_entry->d_name, subtoken) != NULL && + strstr(profile_entry->d_name, ".service.sp") != NULL) { + profile_found = true; + break; + } + } + closedir(service_profiles_dir_ptr); + } + if (profile_found) { + fprintf(tmp_fptr, "%s\n", token); + } else { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Invalid arguments %s error found in the parser\n", subtoken); + free(files_name); + return FALSE; + } + } + } + token=strtok_r(NULL,"#",&sp); + } + free(files_name); + return TRUE; +} +#else static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) { const char *apparmor_profiledir = "/etc/apparmor.d"; @@ -3658,7 +3862,7 @@ static bool ValidateInput_Arguments(char *input, FILE *tmp_fptr) free(files_name); return TRUE; } - +#endif int hostIf_DeviceInfo::set_xRDKCentralComApparmorBlocklist(HOSTIF_MsgData_t *stMsgData) { const char *apparmor_config = "/opt/secure/Apparmor_blocklist"; @@ -3912,6 +4116,10 @@ int hostIf_DeviceInfo::set_xRDKCentralComRFC(HOSTIF_MsgData_t * stMsgData) { ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd(stMsgData); } + else if (strcasecmp(stMsgData->paramName, X_MEMINSIGHT_ENABLE) == 0) + { + ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_XMemInsight_Enable(stMsgData); + } else if (strcasecmp(stMsgData->paramName,RDK_REBOOTSTOP_ENABLE) == 0) { ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(stMsgData); @@ -4382,6 +4590,109 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd ( return retVal; } +int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_XMemInsight_Enable(HOSTIF_MsgData_t *stMsgData) +{ + int ret = NOK; + bool is_xmem_enabled = false; + + if (!stMsgData) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] NULL parameter passed\n", __FUNCTION__, __LINE__); + return NOK; + } + + if (stMsgData->paramtype != hostIf_BooleanType) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Invalid parameter type for %s. Expected boolean(0/1)\n", __FUNCTION__, __LINE__, stMsgData->paramName); + stMsgData->faultCode = fcInvalidParameterType; + return NOK; + } + + is_xmem_enabled = get_boolean(stMsgData->paramValue); + + if (is_xmem_enabled) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Enabling MemInsight feature\n", __FUNCTION__, __LINE__); + + std::ofstream enableFile(MEMINSIGHT_ENABLE_FILE); + if (enableFile.is_open()) + { + enableFile.close(); + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Successfully enabled MemInsight. File created: %s\n", __FUNCTION__, __LINE__, MEMINSIGHT_ENABLE_FILE); + ret = OK; + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Failed to create MemInsight enable file: %s. Error: %s\n", __FUNCTION__, __LINE__, MEMINSIGHT_ENABLE_FILE, strerror(errno)); + stMsgData->faultCode = fcInternalError; + ret = NOK; + } + } + else + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Disabling MemInsight feature\n", __FUNCTION__, __LINE__); + + std::ifstream checkFile(MEMINSIGHT_ENABLE_FILE); + if (checkFile.is_open()) + { + checkFile.close(); + if (remove(MEMINSIGHT_ENABLE_FILE) == 0) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Successfully disabled MemInsight. File removed: %s\n", __FUNCTION__, __LINE__, MEMINSIGHT_ENABLE_FILE); + ret = OK; + + int sysRet = v_secure_system("systemctl is-active %s", MEMINSIGHT_SERVICE); + + if (sysRet == 0) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] %s is currently active\n", __FUNCTION__, __LINE__, MEMINSIGHT_SERVICE); + sysRet = v_secure_system("systemctl stop %s", MEMINSIGHT_SERVICE); + + if (sysRet == 0) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] %s stopped successfully\n", __FUNCTION__, __LINE__, MEMINSIGHT_SERVICE); + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Failed to stop %s. Return code: %d\n", __FUNCTION__, __LINE__, MEMINSIGHT_SERVICE, sysRet); + } + sysRet = v_secure_system("systemctl is-active %s", MEMINSIGHT_SERVICE); + + if (sysRet != 0) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Confirmed: %s is now inactive\n", __FUNCTION__, __LINE__, MEMINSIGHT_SERVICE); + } + else + { + RDK_LOG(RDK_LOG_WARN, LOG_TR69HOSTIF, "[%s:%d] Warning: %s appears to still be active after stop command\n", __FUNCTION__, __LINE__, MEMINSIGHT_SERVICE); + } + } + else + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] MemInsight service %s is already inactive\n", __FUNCTION__, __LINE__, MEMINSIGHT_SERVICE); + } + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Failed to remove MemInsight enable file: %s. Error: %s\n", __FUNCTION__, __LINE__, MEMINSIGHT_ENABLE_FILE, strerror(errno)); + stMsgData->faultCode = fcInternalError; + ret = NOK; + } + } + else + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] MemInsight is already disabled. File not found: %s\n", __FUNCTION__, __LINE__, MEMINSIGHT_ENABLE_FILE); + ret = OK; + } + } + + if (ret == OK) + { + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] Successfully set MemInsight enable to %s\n", __FUNCTION__, __LINE__, is_xmem_enabled ? "true" : "false"); + } + return ret; +} + int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(HOSTIF_MsgData_t *stMsgData) { int ret = NOK; @@ -5412,6 +5723,7 @@ int hostIf_DeviceInfo::get_X_RDKCENTRAL_COM_experience( HOSTIF_MsgData_t *stMsgD return OK; } + /** * @brief This function identifying the imagename of the running image * This Value comes from "imagename" property in /version.txt file diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 7252d7687..6fd2b7294 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -200,6 +200,10 @@ #define CANARY_START_TIME "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart" #define CANARY_END_TIME "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd" +/* Profile: X_RDKCENTRAL-COM_RFC.Feature.xMemInsight */ +#define X_MEMINSIGHT_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.xMemInsight.Enable" +#define X_MEMINSIGHT_ARGS "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.xMemInsight.Args" + char* getLastField(char* line, char delimiter); /** @@ -357,8 +361,9 @@ class hostIf_DeviceInfo { static int sendDeviceMgtNotification(const char* source, const char* type); GHashTable* getNotifyHash(); - + #ifndef RDKV_TR69 static void setPowerConInterface( bool isPwrContEnalbe); + #endif // void runSystemMgmtTimePathMonitor(); /** @@ -1285,6 +1290,23 @@ class hostIf_DeviceInfo { int set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpStart(HOSTIF_MsgData_t *); int set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd(HOSTIF_MsgData_t *); + + /* + * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_XMemInsight_Enable + * + * This method is used to enable/disable the xmeminsight memory & CPU Analysis Tool. + * with following TR-069 definition: + * Parameter Name: Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.xMemInsight.Enable + * Data type: boolean - Enable (True)/ disable (False) xmeminsight tool. + * + * @retval OK if it is successful. + * @retval NOK if operation fails. + */ + + int set_Device_DeviceInfo_X_RDKCENTRAL_COM_XMemInsight_Enable(HOSTIF_MsgData_t *); + + + /* * @brief set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable * diff --git a/src/hostif/profiles/IP/Device_IP_Interface.cpp b/src/hostif/profiles/IP/Device_IP_Interface.cpp index 89d82fc12..a0db01bf5 100755 --- a/src/hostif/profiles/IP/Device_IP_Interface.cpp +++ b/src/hostif/profiles/IP/Device_IP_Interface.cpp @@ -50,8 +50,10 @@ #include #include "Device_IP.h" #include "safec_lib.h" +#ifndef RDKV_TR69 static const char* STATE_UP = "Up"; static const char* STATE_DOWN = "Down"; +#endif // TODO: fix potential bug with initialization, as structure definition now has a "#ifdef IPV6_SUPPORT" IPInterface hostIf_IPInterface::stIPInterfaceInstance = {FALSE,FALSE,FALSE,FALSE,{"Down"},{'\0'},{'\0'},0,{'\0'},{'\0'},FALSE,0,{"Normal"},FALSE,0, diff --git a/src/hostif/profiles/IP/Device_IP_Interface_IPv6Address.cpp b/src/hostif/profiles/IP/Device_IP_Interface_IPv6Address.cpp index 32ab2b3e8..e3ec7214b 100644 --- a/src/hostif/profiles/IP/Device_IP_Interface_IPv6Address.cpp +++ b/src/hostif/profiles/IP/Device_IP_Interface_IPv6Address.cpp @@ -46,10 +46,12 @@ #include "Device_IP.h" #include "safec_lib.h" #include +#ifndef RDKV_TR69 static const char* TIME_INFINITY = "9999-12-31T23:59:59Z"; static const char* TIME_UNKNOWN = "0001-01-01T00:00:00Z"; static const char* STATE_DOWN = "Down"; static const char* NOT_IMPLEMENTED = "Not Implemented"; +#endif /** * @struct in6_ifreq diff --git a/src/hostif/profiles/wifi/Device_WiFi.cpp b/src/hostif/profiles/wifi/Device_WiFi.cpp index 0f235fd24..a1fd34d18 100644 --- a/src/hostif/profiles/wifi/Device_WiFi.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi.cpp @@ -43,9 +43,18 @@ #include "Device_WiFi.h" #include #include +#ifdef RDKV_NM +extern "C" { + /* #include "c_only_header.h"*/ +#include "wifi_client_hal.h" +#include "wifiSrvMgrIarmIf.h" +#include "netsrvmgrIarm.h" +}; +#else #include #include "cJSON.h" #include "hostIf_utils.h" +#endif //char *moca_interface = NULL; GHashTable* WiFiDevice::devHash = NULL; @@ -226,7 +235,64 @@ void hostIf_WiFi::closeAllInstances() /****************************************************************************************************************************************************/ // Device.WiFi. Profile. Getters: /****************************************************************************************************************************************************/ +#ifdef RDKV_NM +int hostIf_WiFi::get_Device_WiFi_RadioNumberOfEntries(HOSTIF_MsgData_t *stMsgData) +{ + ULONG radioNumOfEntries = 0; + IARM_Result_t retVal = IARM_RESULT_SUCCESS; + IARM_BUS_WiFi_DiagsPropParam_t param; + int ret = OK; + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + + param.numEntry=IARM_BUS_WIFI_MGR_RadioEntry; +// ret = wifi_getRadioNumberOfEntries(&radioNumOfEntries); + + retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getSSIDProps, (void *)¶m, sizeof(param)); + if (IARM_RESULT_SUCCESS != retVal) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal); + return NOK; + } + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s] param.data.radioNumberOfEntries returned %d radioNumOfEntries:%lu\n", + __FUNCTION__, __FILE__, ret, param.data.radioNumberOfEntries); + radioNumOfEntries=param.data.radioNumberOfEntries; + put_int(stMsgData->paramValue,radioNumOfEntries); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen = sizeof(radioNumOfEntries); + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + + return ret; +} + +int hostIf_WiFi::get_Device_WiFi_SSIDNumberOfEntries(HOSTIF_MsgData_t *stMsgData) +{ + ULONG ssidNumOfEntries = 0; + IARM_Result_t retVal = IARM_RESULT_SUCCESS; + int ret = OK; + IARM_BUS_WiFi_DiagsPropParam_t param; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + param.numEntry=IARM_BUS_WIFI_MGR_SSIDEntry; + + retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getSSIDProps, (void *)¶m, sizeof(param)); + if (IARM_RESULT_SUCCESS != retVal) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal); + return NOK; + } + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering.. param.data.ssidNumberOfEntries %d \n", __FUNCTION__, __FILE__,param.data.ssidNumberOfEntries); + ssidNumOfEntries=param.data.ssidNumberOfEntries; + put_int(stMsgData->paramValue,ssidNumOfEntries); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen = 4; + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + + return ret; +} +#endif int hostIf_WiFi::get_Device_WiFi_AccessPointNumberOfEntries(HOSTIF_MsgData_t *stMsgData) { unsigned int accessPointNumOfEntries = 1; @@ -253,7 +319,20 @@ int hostIf_WiFi::get_Device_WiFi_EndPointNumberOfEntries(HOSTIF_MsgData_t *stMsg return OK; } +#ifdef RDKV_NM +int hostIf_WiFi::get_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) +{ + LOG_ENTRY_EXIT; + IARM_BUS_NetSrvMgr_Iface_EventData_t param = {0}; + snprintf (param.setInterface, INTERFACE_SIZE, "WIFI"); + IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_isInterfaceEnabled, (void*)¶m, sizeof(param)); + put_boolean(stMsgData->paramValue, param.isInterfaceEnabled); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + return OK; +} +#else int hostIf_WiFi::get_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -307,7 +386,43 @@ int hostIf_WiFi::get_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) } return OK; } +#endif +#ifdef RDKV_NM +int hostIf_WiFi::set_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) +{ + LOG_ENTRY_EXIT; + if (stMsgData->paramtype != hostIf_BooleanType) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Failed due to wrong data type for %s, please use boolean(0/1) to set.\n", __FUNCTION__, stMsgData->paramName); + stMsgData->faultCode = fcInvalidParameterType; + return NOK; + } + IARM_BUS_NetSrvMgr_Iface_EventData_t iarmData = { 0 }; + snprintf (iarmData.setInterface, INTERFACE_SIZE, "WIFI"); + iarmData.isInterfaceEnabled = get_boolean(stMsgData->paramValue); + iarmData.persist = true; // set interface control persistence = true, whether WiFi is asked to be enabled or not + + if (IARM_RESULT_SUCCESS == IARM_Bus_Call (IARM_BUS_NM_SRV_MGR_NAME, + IARM_BUS_NETSRVMGR_API_setInterfaceEnabled, + (void*)&iarmData, sizeof(iarmData))) + { + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, + "[%s] IARM call succeeded %s %s (interface = %s enabled = %d persist = %d)\n", + __FUNCTION__, IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_setInterfaceEnabled, + iarmData.setInterface, iarmData.isInterfaceEnabled, iarmData.persist); + return OK; + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, + "[%s] IARM call failed %s %s (interface = %s enabled = %d persist = %d)\n", + __FUNCTION__, IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_setInterfaceEnabled, + iarmData.setInterface, iarmData.isInterfaceEnabled, iarmData.persist); + return NOK; + } +} +#else int hostIf_WiFi::set_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -362,6 +477,7 @@ int hostIf_WiFi::set_Device_WiFi_EnableWiFi(HOSTIF_MsgData_t *stMsgData) } return OK; } +#endif #endif /* End of doxygen group */ diff --git a/src/hostif/profiles/wifi/Device_WiFi.h b/src/hostif/profiles/wifi/Device_WiFi.h index 6147f5dfc..3056df8aa 100644 --- a/src/hostif/profiles/wifi/Device_WiFi.h +++ b/src/hostif/profiles/wifi/Device_WiFi.h @@ -207,6 +207,22 @@ class hostIf_WiFi { static GList* getAllIntefaces(); static void closeAllInstances(); + #ifdef RDKV_NM + /** + * @ingroup TR69_HOSTIF_WIFI_API + * @{ + */ + /** + * @brief This function provides the number of entries in the Radio table. + */ + int get_Device_WiFi_RadioNumberOfEntries(HOSTIF_MsgData_t *); + + + /** + * @brief This function provides the number of entries in the SSID table. + */ + int get_Device_WiFi_SSIDNumberOfEntries(HOSTIF_MsgData_t *); + #endif /** * @brief This function provides the number of entries in the AccessPoint table. */ diff --git a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp index 87f16ad77..72dfd8c58 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp @@ -39,9 +39,15 @@ #include "Device_WiFi_EndPoint.h" #include #include "safec_lib.h" +#ifdef RDKV_NM +extern "C" { +#include "wifiSrvMgrIarmIf.h" +}; +#else #include #include "cJSON.h" #include "hostIf_utils.h" +#endif GHashTable* hostIf_WiFi_EndPoint::ifHash = NULL; @@ -268,6 +274,55 @@ int hostIf_WiFi_EndPoint::get_Device_WiFi_EndPoint_Stats_Retransmissions (HOSTIF /** * @brief Refreshes the cache of Device.WiFi.EndPoint. parameters */ +#ifdef RDKV_NM +int hostIf_WiFi_EndPoint::refreshCache() +{ + LOG_ENTRY_EXIT; + static time_t time_of_last_successful_query = 0; + static int last_call_status = NOK; + static std::mutex m; + std::lock_guard lg (m); + // Using a 1-second cache. + if ((last_call_status == OK ) && (time (0) <= time_of_last_successful_query + 1)) + { + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] Cache not stale. last call status is SUCCESS, Refresh not required.\n", __FUNCTION__); + return OK; + } + + IARM_BUS_WiFi_DiagsPropParam_t param; + IARM_Result_t retVal = IARM_Bus_Call (IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getEndPointProps, (void *) ¶m, sizeof(param)); + if (IARM_RESULT_SUCCESS != retVal) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Cache refresh failed. IARM_Bus_Call to netsrvmgr returned [%d]\n", __FUNCTION__, retVal); + last_call_status = NOK; + return NOK; + } + + time_of_last_successful_query = time (0); + + Enable = param.data.endPointInfo.enable; + strncpy (Status, param.data.endPointInfo.status, BUFF_LENGTH_64); + strncpy (Alias, param.data.endPointInfo.alias, BUFF_LENGTH_64); + strncpy (ProfileReference, param.data.endPointInfo.ProfileReference, BUFF_LENGTH_256); + strncpy (SSIDReference, param.data.endPointInfo.SSIDReference, BUFF_LENGTH_256); + ProfileNumberOfEntries = param.data.endPointInfo.ProfileNumberOfEntries; + stats.LastDataDownlinkRate = param.data.endPointInfo.stats.lastDataDownlinkRate; + stats.LastDataUplinkRate = param.data.endPointInfo.stats.lastDataUplinkRate; + stats.SignalStrength = param.data.endPointInfo.stats.signalStrength; + stats.Retransmissions = param.data.endPointInfo.stats.retransmissions; + + RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF, "[%s] Cache refreshed.\n", __FUNCTION__); + + if (false == param.data.endPointInfo.enable) // "Disabled" endpoint + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] EndPoint is disabled\n", __FUNCTION__); + last_call_status = NOK; + return OK; + } + last_call_status = OK; + return OK; +} +#else int hostIf_WiFi_EndPoint::refreshCache() { LOG_ENTRY_EXIT; @@ -471,5 +526,5 @@ int hostIf_WiFi_EndPoint::refreshCache() last_call_status = OK; return OK; } - +#endif #endif /* #ifdef USE_WIFI_PROFILE */ diff --git a/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp b/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp index 5d4ca6c88..5630d7e64 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_EndPoint_Security.cpp @@ -37,10 +37,15 @@ *****************************************************************************/ #ifdef USE_WIFI_PROFILE #include "Device_WiFi_EndPoint_Security.h" +#ifdef RDKV_NM +extern "C" { +#include "wifiSrvMgrIarmIf.h" +}; +#else #include #include "cJSON.h" #include "hostIf_utils.h" - +#endif GHashTable* hostIf_WiFi_EndPoint_Security::ifHash = NULL; hostIf_WiFi_EndPoint_Security* hostIf_WiFi_EndPoint_Security::getInstance(int dev_id) @@ -111,7 +116,37 @@ hostIf_WiFi_EndPoint_Security::hostIf_WiFi_EndPoint_Security(int dev_id) { memset(ModesSupported, 0, 64); } +#ifdef RDKV_NM +int hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_Security_ModesEnabled(HOSTIF_MsgData_t *stMsgData ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering.. \n", __FUNCTION__, __FILE__); + + IARM_Result_t retVal = IARM_RESULT_IPCCORE_FAIL; + IARM_Bus_WiFiSrvMgr_Param_t param; + if(NULL == stMsgData) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] Input arg stMsgData is NULL\n", __FILE__, __FUNCTION__); + return retVal; + } + + memset(¶m, 0, sizeof(param)); + retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getPairedSSIDInfo, (void *)¶m, sizeof(param)); + + if(retVal != IARM_RESULT_SUCCESS) { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal); + return retVal; + }else{ + strncpy(stMsgData->paramValue,param.data.getPairedSSIDInfo.security,sizeof(stMsgData->paramValue)); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(stMsgData->paramValue); + retVal = IARM_RESULT_SUCCESS; + RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] WiFi Security Mode : %s\n",__FUNCTION__,stMsgData->paramValue); + } + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return retVal; +} +#else int hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_Security_ModesEnabled(HOSTIF_MsgData_t *stMsgData ) { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering.. \n", __FUNCTION__, __FILE__); @@ -172,6 +207,7 @@ int hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_Security_ModesEnable RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return retVal; } +#endif int hostIf_WiFi_EndPoint_Security::get_hostIf_WiFi_EndPoint_ModesSupported(HOSTIF_MsgData_t *stMsgData ) { return 0; diff --git a/src/hostif/profiles/wifi/Device_WiFi_Radio.cpp b/src/hostif/profiles/wifi/Device_WiFi_Radio.cpp index f6cde044f..affca9375 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_Radio.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_Radio.cpp @@ -39,6 +39,14 @@ *****************************************************************************/ #include "Device_WiFi_Radio.h" +#ifdef RDKV_NM +extern "C" { + /* #include "c_only_header.h"*/ +#include "wifi_client_hal.h" +#include "wifiSrvMgrIarmIf.h" +}; +#endif + GHashTable* hostIf_WiFi_Radio::ifHash = NULL; /*hostIf_WiFi_Radio::hostIf_WiFi_Radio(int dev_id):dev_id(dev_id) @@ -147,5 +155,381 @@ hostIf_WiFi_Radio::hostIf_WiFi_Radio(int dev_id): memset(TransmitPowerSupported, 0, sizeof(TransmitPowerSupported)); memset(RegulatoryDomain, 0, sizeof(RegulatoryDomain)); } +#ifdef RDKV_NM +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Props_Fields(int radioIndex) +{ + IARM_Result_t retVal = IARM_RESULT_SUCCESS; + IARM_BUS_WiFi_DiagsPropParam_t param = {0}; + int ret; + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + hostIf_WiFi_Radio *pDev = hostIf_WiFi_Radio::getInstance(dev_id); + if(pDev) + { + retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getRadioProps, (void *)¶m, sizeof(param)); + if (IARM_RESULT_SUCCESS != retVal) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal); + return NOK; + } + Enable = param.data.radio.params.enable; + snprintf(Status,BUFF_LENGTH_64,param.data.radio.params.status); + snprintf(Alias,BUFF_LENGTH_64,param.data.radio.params.alias); + snprintf(Name,BUFF_LENGTH_64,param.data.radio.params.name); + LastChange = param.data.radio.params.lastChange; + snprintf(LowerLayers,BUFF_LENGTH_1024,param.data.radio.params.lowerLayers); + Upstream = param.data.radio.params.upstream; + MaxBitRate = param.data.radio.params.maxBitRate; + snprintf(SupportedFrequencyBands,BUFF_LENGTH_256,param.data.radio.params.supportedFrequencyBands); + snprintf(OperatingFrequencyBand,BUFF_LENGTH_64,param.data.radio.params.operatingFrequencyBand); + snprintf(SupportedStandards,BUFF_LENGTH_64,param.data.radio.params.supportedStandards); + snprintf(OperatingStandards,BUFF_LENGTH_64,param.data.radio.params.operatingStandards); + snprintf(PossibleChannels,BUFF_LENGTH_256,param.data.radio.params.possibleChannels); + snprintf(ChannelsInUse,BUFF_LENGTH_1024,param.data.radio.params.channelsInUse); + Channel = param.data.radio.params.channel; + AutoChannelSupported = param.data.radio.params.autoChannelSupported; + AutoChannelEnable = param.data.radio.params.autoChannelEnable; + AutoChannelRefreshPeriod = param.data.radio.params.autoChannelRefreshPeriod; + snprintf(OperatingChannelBandwidth,BUFF_LENGTH_1024,param.data.radio.params.operatingChannelBandwidth); + snprintf(ExtensionChannel,BUFF_LENGTH_64,param.data.radio.params.extensionChannel); + snprintf(GuardInterval,BUFF_LENGTH_64,param.data.radio.params.guardInterval); + mcs = param.data.radio.params.mcs; + snprintf(TransmitPowerSupported,BUFF_LENGTH_64,param.data.radio.params.transmitPowerSupported); + TransmitPower = param.data.radio.params.transmitPower; +// IEEE80211hSupported = param.data.radio.params.IEEE80211hSupported; +// IEEE80211hEnabled = param.data.radio.params.IEEE80211hEnabled; + snprintf(RegulatoryDomain,BUFF_MIN_16,param.data.radio.params.regulatoryDomain); + radioFirstExTime = time (NULL); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s]Error! Unable to connect to wifi instance\n", __FILE__, __FUNCTION__); + return NOK; + } +} + +void hostIf_WiFi_Radio::checkWifiRadioFetch(int radioIndex) +{ + int retVal=NOK; + time_t currExTime = time (NULL); + if((currExTime - radioFirstExTime ) > QUERY_INTERVAL) + { + retVal = get_Device_WiFi_Radio_Props_Fields(radioIndex); + if( OK != retVal) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] Failed to fetch : %d.\n", __FILE__, __FUNCTION__, retVal); + } + } +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Enable(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_boolean(stMsgData->paramValue, Enable); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Upstream(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_boolean(stMsgData->paramValue, Upstream); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_AutoChannelSupported(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_boolean(stMsgData->paramValue, AutoChannelSupported); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_AutoChannelEnable(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_boolean(stMsgData->paramValue, AutoChannelEnable); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_IEEE80211hSupported(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_boolean(stMsgData->paramValue, IEEE80211hSupported); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_IEEE80211hEnabled(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + + + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_boolean(stMsgData->paramValue, IEEE80211hEnabled); + stMsgData->paramtype = hostIf_BooleanType; + stMsgData->paramLen=1; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_LastChange(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_int(stMsgData->paramValue, LastChange); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_MaxBitRate(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_int(stMsgData->paramValue, MaxBitRate); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Channel(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_int(stMsgData->paramValue, Channel); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_AutoChannelRefreshPeriod(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_int(stMsgData->paramValue, AutoChannelRefreshPeriod); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_MCS(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_int(stMsgData->paramValue, mcs); + stMsgData->paramtype = hostIf_IntegerType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_TransmitPower(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + put_int(stMsgData->paramValue, TransmitPower); + stMsgData->paramtype = hostIf_IntegerType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Status(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, Status,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(Status); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Alias(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, Alias,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(Alias); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_Name(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, Name,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(Name); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_SupportedFrequencyBands(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, SupportedFrequencyBands,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(SupportedFrequencyBands); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_OperatingFrequencyBand(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, OperatingFrequencyBand,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(OperatingFrequencyBand); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_SupportedStandards(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, SupportedStandards,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(SupportedStandards); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_OperatingStandards(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, OperatingStandards,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(OperatingStandards); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_PossibleChannels(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, PossibleChannels,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(PossibleChannels); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_ChannelsInUse(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, ChannelsInUse,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(ChannelsInUse); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_OperatingChannelBandwidth(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, OperatingChannelBandwidth,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(OperatingChannelBandwidth); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_ExtensionChannel(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, ExtensionChannel,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(ExtensionChannel); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_GuardInterval(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, GuardInterval,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(GuardInterval); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_LowerLayers(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, LowerLayers,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(LowerLayers); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_TransmitPowerSupported(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, TransmitPowerSupported,TR69HOSTIFMGR_MAX_PARAM_LEN ); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(TransmitPowerSupported); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio::get_Device_WiFi_Radio_RegulatoryDomain(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioFetch(radioIndex); + strncpy(stMsgData->paramValue, RegulatoryDomain,TR69HOSTIFMGR_MAX_PARAM_LEN); + stMsgData->paramtype = hostIf_StringType; + stMsgData->paramLen = strlen(RegulatoryDomain); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} +#endif #endif /* #ifdef USE_WIFI_PROFILE */ diff --git a/src/hostif/profiles/wifi/Device_WiFi_Radio.h b/src/hostif/profiles/wifi/Device_WiFi_Radio.h index 045fe3f3a..348bb690b 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_Radio.h +++ b/src/hostif/profiles/wifi/Device_WiFi_Radio.h @@ -118,7 +118,10 @@ class hostIf_WiFi_Radio { static GList* getAllAssociateDevs(); static void closeInstance(hostIf_WiFi_Radio *); static void closeAllInstances(); - + #ifdef RDKV_NM + int get_Device_WiFi_Radio_Props_Fields(int radioIndex); + void checkWifiRadioFetch(int radioIndex); + #endif bool Enable; char Status[BUFF_LENGTH_64]; char Alias[BUFF_LENGTH_64]; diff --git a/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.cpp b/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.cpp index ce37ab4fc..5fa032b7f 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.cpp @@ -36,9 +36,17 @@ * STANDARD INCLUDE FILES *****************************************************************************/ #include "Device_WiFi_Radio_Stats.h" - +#ifdef RDKV_NM +extern "C" { +#include "wifiSrvMgrIarmIf.h" + /* #include "c_only_header.h"*/ +}; +#endif GHashTable* hostIf_WiFi_Radio_Stats::ifHash = NULL; +#ifdef RDKV_NM +static time_t radioFirstExTime = 0; +#endif hostIf_WiFi_Radio_Stats *hostIf_WiFi_Radio_Stats::getInstance(int dev_id) { @@ -111,4 +119,156 @@ hostIf_WiFi_Radio_Stats::hostIf_WiFi_Radio_Stats(int dev_id): } +#ifdef RDKV_NM +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_Props_Fields(int radioIndex) +{ + IARM_Result_t retVal = IARM_RESULT_SUCCESS; + IARM_BUS_WiFi_DiagsPropParam_t param = {0}; + int ret; + radioIndex=1; + + hostIf_WiFi_Radio_Stats *pDev = hostIf_WiFi_Radio_Stats::getInstance(dev_id); + if(pDev) + { + retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getRadioStatsProps, (void *)¶m, sizeof(param)); + if (IARM_RESULT_SUCCESS != retVal) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal); + return NOK; + } + BytesSent = param.data.radio_stats.params.bytesSent; + BytesReceived = param.data.radio_stats.params.bytesReceived; + PacketsSent = param.data.radio_stats.params.packetsSent; + PacketsReceived = param.data.radio_stats.params.packetsReceived; + ErrorsSent = param.data.radio_stats.params.errorsSent; + ErrorsReceived = param.data.radio_stats.params.errorsReceived; + DiscardPacketsSent = param.data.radio_stats.params.discardPacketsSent; + DiscardPacketsReceived = param.data.radio_stats.params.discardPacketsReceived; + NoiseFloor = param.data.radio_stats.params.noiseFloor; + radioFirstExTime = time (NULL); + return OK; + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s]Error! Unable to connect to wifi instance\n", __FILE__, __FUNCTION__); + return NOK; + } + +} + +void hostIf_WiFi_Radio_Stats::checkWifiRadioPropsFetch(int radioIndex) +{ + int ret = NOK; + time_t currExTime = time (NULL); + if ((currExTime - radioFirstExTime ) > QUERY_INTERVAL) + { + ret = get_Device_WiFi_Radio_Stats_Props_Fields(radioIndex); + if( OK != ret) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] Failed to fetch : %d.\n", __FILE__, __FUNCTION__, ret); + } + } +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_BytesSent(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, BytesSent); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; + +} + + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_BytesReceived(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, BytesReceived); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_PacketsSent(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, PacketsSent); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_PacketsReceived(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, PacketsReceived); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_ErrorsSent(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, ErrorsSent); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_ErrorsReceived(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, ErrorsReceived); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_DiscardPacketsSent(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, DiscardPacketsSent); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} + +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_DiscardPacketsReceived(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, DiscardPacketsReceived); + stMsgData->paramtype = hostIf_UnsignedIntType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} +int hostIf_WiFi_Radio_Stats::get_Device_WiFi_Radio_Stats_NoiseFloor(HOSTIF_MsgData_t *stMsgData,int radioIndex ) +{ + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + checkWifiRadioPropsFetch(radioIndex); + put_int(stMsgData->paramValue, NoiseFloor); + stMsgData->paramtype = hostIf_IntegerType; + stMsgData->paramLen=4; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; +} +#endif + #endif /* #ifdef USE_WIFI_PROFILE */ diff --git a/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.h b/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.h index 198eb0388..876286d76 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.h +++ b/src/hostif/profiles/wifi/Device_WiFi_Radio_Stats.h @@ -76,6 +76,10 @@ class hostIf_WiFi_Radio_Stats { static GList* getAllAssociateDevs(); static void closeInstance(hostIf_WiFi_Radio_Stats *); static void closeAllInstances(); + #ifdef RDKV_NM + int get_Device_WiFi_Radio_Stats_Props_Fields(int radioIndex); + void checkWifiRadioPropsFetch(int radioIndex); + #endif unsigned long BytesSent; unsigned long BytesReceived; diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 129f6ff3d..6c9e82096 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -37,12 +37,20 @@ *****************************************************************************/ #include #include "safec_lib.h" -#include -#include "cJSON.h" -#include "hostIf_utils.h" #ifdef USE_WIFI_PROFILE #include "Device_WiFi_SSID.h" +#ifdef RDKV_NM +extern "C" { + /* #include "c_only_header.h"*/ +#include "wifi_common_hal.h" +#include "wifiSrvMgrIarmIf.h" +}; +#else +#include +#include "cJSON.h" +#include "hostIf_utils.h" +#endif static time_t firstExTime = 0; @@ -123,7 +131,61 @@ hostIf_WiFi_SSID::hostIf_WiFi_SSID(int dev_id): memset(MACAddress,0, sizeof(MACAddress)); memset(SSID,0, sizeof(SSID)); //CID:103108 - OVERRUN } +#ifdef RDKV_NM +int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) +{ + errno_t rc = -1; + IARM_Result_t retVal = IARM_RESULT_SUCCESS; + IARM_BUS_WiFi_DiagsPropParam_t param = {0}; + int ret; + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); + hostIf_WiFi_SSID *pDev = hostIf_WiFi_SSID::getInstance(dev_id); + if (pDev) + { + retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getSSIDProps, (void *)¶m, sizeof(param)); + if (IARM_RESULT_SUCCESS != retVal) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal); + return NOK; + } + rc=strcpy_s(name,sizeof(name),param.data.ssid.params.name); + if(rc!=EOK) + { + ERR_CHK(rc); + } + rc=strcpy_s(BSSID,sizeof(BSSID),param.data.ssid.params.bssid); + if(rc!=EOK) + { + ERR_CHK(rc); + } + rc=strcpy_s(MACAddress,sizeof(MACAddress),param.data.ssid.params.macaddr); + if(rc!=EOK) + { + ERR_CHK(rc); + } + rc=strcpy_s(SSID,sizeof(SSID),param.data.ssid.params.ssid); + if(rc!=EOK) + { + ERR_CHK(rc); + } + rc=strcpy_s(status,sizeof(status),param.data.ssid.params.status); + if(rc!=EOK) + { + ERR_CHK(rc); + } + enable=param.data.ssid.params.enable; + firstExTime = time (NULL); + RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + return OK; + } + else + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s:%s]Error! Unable to connect to wifi instance\n", __FILE__, __FUNCTION__); + return NOK; + } +} +#else int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { errno_t rc = -1; @@ -332,6 +394,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) return NOK; } } +#endif void hostIf_WiFi_SSID::checkWifiSSIDFetch(int ssidIndex) { diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index cbcb751a0..1d1e6e1dc 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -105,11 +105,13 @@ static void usage(); T_ARGLIST argList = {{'\0'}, 0}; static int isShutdownTriggered = 0; +#ifndef RDKV_TR69 #define DEVICE_PROPS_FILE "/etc/device.properties" #define GENERIC_XML_FILE "/etc/data-model-generic.xml" #define STB_XML_FILE "/etc/data-model-stb.xml" #define TV_XML_FILE "/etc/data-model-tv.xml" #define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" +#endif std::mutex mtx_httpServerThreadDone; @@ -430,6 +432,7 @@ int main(int argc, char *argv[]) { RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Failed to start hostIf_IARM_IF_Start()\n"); } + #ifndef RDKV_TR69 MergeStatus mergeStatus = mergeDataModel(); if (mergeStatus != MERGE_SUCCESS) { RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "Error in merging Data Model\n"); @@ -438,6 +441,7 @@ int main(int argc, char *argv[]) else { RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "Successfully merged Data Model.\n"); } + #endif /* Load the data model xml file*/ DB_STATUS status = loadDataModel(); if(status != DB_SUCCESS) @@ -690,7 +694,7 @@ static void usage() #endif } - +#ifndef RDKV_TR69 bool filter_and_merge_xml(const char *input1, const char *input2, const char *output) { FILE *in_fp1 = fopen(input1, "r"); FILE *in_fp2 = fopen(input2, "r"); @@ -802,6 +806,7 @@ MergeStatus mergeDataModel() { return MERGE_FAILURE; } } +#endif /** @} */ /** @} */ diff --git a/tr69hostif.service b/tr69hostif.service index 946b03e33..243bac9cc 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -18,7 +18,7 @@ ########################################################################## [Unit] Description=TR69 Host Interface Daemon -After=lighttpd.service securemount.service iarmbusd.service +After=lighttpd.service securemount.service @DSMGR_DEPENDENCY@ [Service] Type=notify From a787aa4866e769fad654d2ee89f16afa21204ede Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Wed, 24 Sep 2025 12:09:16 -0400 Subject: [PATCH 130/161] 1.2.5 release changelog updates --- CHANGELOG.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25acc72d8..02ed907d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,32 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.5](https://github.com/rdkcentral/tr69hostif/compare/1.2.4...1.2.5) + +- RDK-58963-[RDK-V/E] Federated Source Code For tr69hostif - Phase 2 [`#250`](https://github.com/rdkcentral/tr69hostif/pull/250) +- RDKEMW-8367: Add Valid Public NTP servers for community [`#255`](https://github.com/rdkcentral/tr69hostif/pull/255) +- DELIA-68569 - WebPA Query fails for RRD Enabled command [`#235`](https://github.com/rdkcentral/tr69hostif/pull/235) +- rebase [`#244`](https://github.com/rdkcentral/tr69hostif/pull/244) +- RDK-57737 [ tr69hostif ] : L1 Functional Coverage from 31.2% to 75-80% [`#225`](https://github.com/rdkcentral/tr69hostif/pull/225) +- Rebase [`#237`](https://github.com/rdkcentral/tr69hostif/pull/237) +- Rebase [`#234`](https://github.com/rdkcentral/tr69hostif/pull/234) +- rebase [`#231`](https://github.com/rdkcentral/tr69hostif/pull/231) +- Update webpa_parameter.cpp [`7b12e1f`](https://github.com/rdkcentral/tr69hostif/commit/7b12e1f3b1790899806f41f1144c17435905d450) +- Merge tag '1.2.4' into develop [`364c312`](https://github.com/rdkcentral/tr69hostif/commit/364c312c2c7cc15d94350692024cb5142336e3e6) +- Update webpa_parameter.cpp [`1b63a82`](https://github.com/rdkcentral/tr69hostif/commit/1b63a82935bcb4a9d67086f712b6ba4fa67acddc) + #### [1.2.4](https://github.com/rdkcentral/tr69hostif/compare/1.2.3...1.2.4) +> 27 August 2025 + - RDKEMW-4759 - Review and Analyze the RRD Static Profiles for RDK devices [`#198`](https://github.com/rdkcentral/tr69hostif/pull/198) - RDKEMW-7135 : Gamepad RFC is not enabled by default [`#228`](https://github.com/rdkcentral/tr69hostif/pull/228) - RDKTV-38130-[RDKE_Trials][8.2p2s2]: Increase in "tr69hostif" crash with function "hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields" and "81598460" fingerprint [`#223`](https://github.com/rdkcentral/tr69hostif/pull/223) - Fix tr69hostif native build failure [`#232`](https://github.com/rdkcentral/tr69hostif/pull/232) - Rebase [`#209`](https://github.com/rdkcentral/tr69hostif/pull/209) +- 1.2.4 release changelog updates [`b112be6`](https://github.com/rdkcentral/tr69hostif/commit/b112be6f22ab852b37604562d3a4341d94160cdb) - Merge tag '1.2.3' into develop [`84c45dd`](https://github.com/rdkcentral/tr69hostif/commit/84c45dd1c8bac75d25f06fbbc14575c02d8a153a) - Update Device_DeviceInfo.cpp [`5441b70`](https://github.com/rdkcentral/tr69hostif/commit/5441b702ad40eb9523499670b9254ea3fcbda0cc) -- Update Device_DeviceInfo.cpp [`cda900d`](https://github.com/rdkcentral/tr69hostif/commit/cda900d6d35170fcfe0c3ac8382271575eba077b) #### [1.2.3](https://github.com/rdkcentral/tr69hostif/compare/1.2.2...1.2.3) From 9e00c401c8a3901d0c22efaf5b06c34ecfa438ba Mon Sep 17 00:00:00 2001 From: nhanasi Date: Wed, 24 Sep 2025 12:59:09 -0400 Subject: [PATCH 131/161] Potential fix for code scanning alert no. 10: Too few arguments to formatting function Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp index f99215c57..8b08f679c 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp @@ -112,7 +112,7 @@ bool createBspCompleteFiles() RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"Creating BSP Complete File %s\n", BSP_COMPLETE); createFile(BSP_COMPLETE); - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"Creating BSP Complete File %s in tmp Directory%s\n", BSP_COMPLETE_TMP); + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,"Creating BSP Complete File %s in tmp Directory\n", BSP_COMPLETE_TMP); createFile(BSP_COMPLETE_TMP); return true; } From 3b3daaa2b859bee8d8af3ebeeabbb6178cad3528 Mon Sep 17 00:00:00 2001 From: rdkcmf Date: Thu, 25 Sep 2025 17:38:21 +0100 Subject: [PATCH 132/161] Deploy cla action --- .github/workflows/cla.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 055047932..c58b1b0b1 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -1,13 +1,20 @@ name: "CLA" + +permissions: + contents: read + pull-requests: write + actions: write + statuses: write + on: issue_comment: types: [created] pull_request_target: - types: [opened,closed,synchronize] + types: [opened, closed, synchronize] jobs: CLA-Lite: name: "Signature" - uses: rdkcentral/cmf-actions/.github/workflows/cla.yml@main + uses: rdkcentral/cmf-actions/.github/workflows/cla.yml@v1 secrets: - PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT }} \ No newline at end of file + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT }} From 03732462432c422dd79c192e8f89617700dc96ad Mon Sep 17 00:00:00 2001 From: madhubabutt <114217841+madhubabutt@users.noreply.github.com> Date: Fri, 26 Sep 2025 22:05:33 +0530 Subject: [PATCH 133/161] RDK-58962 [ tr69hostif ] : L1 Functional Coverage from 56% to 75-80% (#252) Co-authored-by: mtirum011 --- cov_build.sh | 4 +- run_ut.sh | 31 +- src/configure.ac | 1 + .../include/hostIf_rbus_Dml_Provider.h | 11 + src/hostif/handlers/src/gtest/Makefile.am | 39 + .../handlers/src/gtest/handlers_test.cpp | 1530 ++++++++++ .../handlers/src/hostIf_rbus_Dml_Provider.cpp | 7 + .../httpserver/include/XrdkCentralComRFCVar.h | 1 + src/hostif/httpserver/src/gtest/Makefile.am | 17 +- .../httpserver/src/gtest/gtest_httpserver.cpp | 333 ++ src/hostif/httpserver/src/http_server.cpp | 12 + src/hostif/httpserver/src/request_handler.cpp | 10 + src/hostif/include/IniFile.h | 8 + src/hostif/parodusClient/gtest/Makefile.am | 14 +- src/hostif/parodusClient/gtest/dm_test.cpp | 701 ++++- src/hostif/parodusClient/pal/libpd.cpp | 6 + .../parodusClient/pal/webpa_parameter.cpp | 22 +- src/hostif/parodusClient/waldb/waldb.h | 3 + .../profiles/DHCPv4/Device_DHCPv4_Client.h | 3 + src/hostif/profiles/DHCPv4/gtest/Makefile.am | 14 +- .../profiles/DHCPv4/gtest/gtest_dhcpv4.cpp | 113 +- src/hostif/profiles/Device/gtest/Makefile.am | 14 +- .../profiles/Device/gtest/gtest_device.cpp | 58 + .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 35 +- .../profiles/DeviceInfo/Device_DeviceInfo.h | 12 + .../DeviceInfo/XrdkCentralComBSStore.h | 9 +- .../DeviceInfo/XrdkCentralComBSStoreJournal.h | 2 + .../profiles/DeviceInfo/XrdkCentralComRFC.cpp | 7 +- .../profiles/DeviceInfo/XrdkCentralComRFC.h | 1 + .../DeviceInfo/XrdkCentralComRFCStore.h | 14 + .../profiles/DeviceInfo/gtest/Makefile.am | 14 +- .../profiles/DeviceInfo/gtest/gtest_main.cpp | 2708 ++++++++++++++++- .../profiles/Ethernet/gtest/Makefile.am | 14 +- .../Ethernet/gtest/gtest_ethernet.cpp | 26 + src/hostif/profiles/Time/Device_Time.h | 4 + src/hostif/profiles/Time/gtest/Makefile.am | 15 +- src/hostif/profiles/Time/gtest/gtest_time.cpp | 30 + src/hostif/src/gtest/Makefile.am | 16 +- src/hostif/src/gtest/gtest_src.cpp | 222 +- src/hostif/src/hostIf_utils.cpp | 6 + src/integrationtest/conf/bootstrap.ini | 1 + src/unittest/stubs/remote_debugger.json | 68 + src/unittest/stubs/rfcdefaults.ini | 1 + 43 files changed, 5933 insertions(+), 224 deletions(-) create mode 100644 src/hostif/handlers/src/gtest/Makefile.am create mode 100644 src/hostif/handlers/src/gtest/handlers_test.cpp create mode 100644 src/unittest/stubs/remote_debugger.json diff --git a/cov_build.sh b/cov_build.sh index 9a833b727..a9e92048b 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -70,9 +70,9 @@ cd $WORKDIR sed -i '/PKG_CHECK_MODULES(\[PROCPS\], \[libproc >= 3.2.8\])/s/^/#/' ./configure.ac rm -f ./src/unittest/stubs/rdk_debug.h autoreconf -i -./configure --enable-libsoup3=yes --enable-IPv6=yes +./configure --enable-IPv6=yes -make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DLIBSOUP3_ENABLE -DIPV6_SUPPORT" \ +make AM_CXXFLAGS="-I$WORKDIR/src/unittest/stubs -I$WORKDIR/src/hostif/include -I/usr/include/cjson -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$WORKDIR/src/hostif/handlers/include -I$WORKDIR/src/hostif/parodusClient/waldb -I$WORKDIR/src/hostif/profiles/DeviceInfo -I/usr/include/cjson -I$WORKDIR/src/hostif/profiles/Time -I$WORKDIR/src/hostif/profiles/Device -I/usr/include/libsoup-3.0 -I/usr/include/yajl -I$WORKDIR/src/hostif/profiles/STBService -I$WORKDIR/src/unittest/stubs/ds -I/usr/devicesettings/ds -I/usr/local/include -I$WORKDIR/src/hostif/profiles/IP -I$WORKDIR/src/hostif/profiles/Ethernet -I/usr/local/include/rbus -I$WORKDIR/src/hostif/parodusClient/pal -I/usr/rdk-halif-device_settings/include -I/usr/local/include/libparodus -I/usr/local/include -I/usr/rdkvhal-devicesettings-raspberrypi4 -I/usr/local/include/ -I/usr/include/yajl -I/usr/tinyxml2 -I/usr/devicesettings/ds -I/$WORKDIR/src/hostif/httpserver/include -I/usr/remote_debugger/src/ -DIPV6_SUPPORT" \ AM_LDFLAGS="-L/usr/local/lib -lrbus -lsecure_wrapper -lcurl -lrfcapi -lrdkloggers -llibparodus -lglib-2.0 -lnanomsg -lIARMBus -lWPEFrameworkPowerController -lds -ldshalcli -ldshalsrv -lwrp-c -lwdmp-c -lprocps -ltrower-base64 -lcimplog -lsoup-3.0 -L/usr/lib/x86_64-linux-gnu -lyajl -L/usr/local/lib/x86_64-linux-gnu -ltinyxml2" CXXFLAGS="-fpermissive -DPARODUS_ENABLE -DUSE_REMOTE_DEBUGGER" make install diff --git a/run_ut.sh b/run_ut.sh index 880235a74..23a4b3e65 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -48,7 +48,6 @@ apt-get -y install libsoup-3.0-dev apt-get -y install libprocps-dev apt-get -y install libnanomsg-dev apt-get -y install iproute2 - sed '/<\/model>/d; /<\/dm:document>/d' ./src/hostif/parodusClient/waldb/data-model/data-model-tv.xml > ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml sed '/> ./src/hostif/parodusClient/waldb/data-model/data-model-merged.xml @@ -65,17 +64,26 @@ mkdir -p /tmp/webpa mkdir -p /opt/persistent/ mkdir -p /etc/rfcdefaults mkdir -p /etc/apparmor.d +mkdir -p /opt/secure/persistent/ +mkdir -p /etc/rrd/ cp ./src/unittest/stubs/tr181store.ini /opt/secure/RFC/tr181store.ini cp ./src/integrationtest/conf/bootstrap.ini /opt/secure/RFC/ cp ./src/integrationtest/conf/rfcVariable.ini /opt/secure/RFC/ cp partners_defaults.json /etc/partners_defaults.json cp ./src/unittest/stubs/partners_defaults_device.json /etc/partners_defaults_device.json cp ./src/unittest/stubs/fwdnldstatus.txt /opt/fwdnldstatus.txt +cp ./src/integrationtest/conf/mgrlist.conf /etc/mgrlist.conf +cp ./src/unittest/stubs/remote_debugger.json /etc/rrd/remote_debugger.json touch /tmp/timeReceivedNTP touch /tmp/webpa/start_time touch /opt/persistent/firstNtpTime - - +touch /etc/rfcdefaults/rfcdefaults.ini +touch /opt/XRE_container_enable /opt/dab-enable +touch /opt/.ntpEnabled +touch /var/tmp/rssh.pid +cat /version.txt +rm -rf /version.txt +echo "Method|" >> /opt/fwdnldstatus.txt export TOP_DIR=$WORKDIR cd ./src/ @@ -90,10 +98,20 @@ make clean echo "TOP_DIR = $TOP_DIR" +echo "**** Compiling handlers gtest ****" +cd $TOP_DIR/src/hostif/handlers/src/gtest +rm handlers_gtest +sed -i '/getCurrentTime/,/^ *}/d' ../../../src/hostIf_utils.cpp +make clean +make +./handlers_gtest +echo "********************" + + echo "**** Compiling data model gtest ****" cd $TOP_DIR/src/hostif/parodusClient/gtest rm dm_gtest -sed -i '/getCurrentTime/,/^ *}/d' ../../src/hostIf_utils.cpp +#sed -i '/getCurrentTime/,/^ *}/d' ../../src/hostIf_utils.cpp make ./dm_gtest echo "********************" @@ -101,7 +119,8 @@ echo "********************" echo "**** Compiling httpserver gtest ****" cd $TOP_DIR/src/hostif/httpserver/src/gtest rm httpserver_gtest -sed -i '$a void getCurrentTime(struct timespec *timer)\n{\n clock_gettime(CLOCK_REALTIME, timer);\n}' ../../../src/hostIf_utils.cpp +#sed -i '$a void getCurrentTime(struct timespec *timer)\n{\n clock_gettime(CLOCK_REALTIME, timer);\n}' ../../../src/hostIf_utils.cpp +#sed -i '/getCurrentTime/,/^ *}/d' ../../src/hostIf_utils.cpp make clean make ./httpserver_gtest @@ -110,6 +129,7 @@ echo "********************" echo "**** Compiling src gtest ****" cd $TOP_DIR/src/hostif/src/gtest rm src_gtest +sed -i '$a void getCurrentTime(struct timespec *timer)\n{\n clock_gettime(CLOCK_REALTIME, timer);\n}' ../hostIf_utils.cpp make clean make ./src_gtest @@ -145,6 +165,7 @@ echo "********************" echo "**** Compiling DeviceInfo gtest ****" cd $TOP_DIR/src/hostif/profiles/DeviceInfo/gtest +cp ../../../../unittest/stubs/rfc.properties /etc/rfc.properties rm devieInfo_gtest /opt/www/authService/partnerId3.dat make ./devieInfo_gtest diff --git a/src/configure.ac b/src/configure.ac index 4ad41b460..5a4d58d68 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -69,6 +69,7 @@ AC_SUBST(T2_EVENT_FLAG) hostif/profiles/Ethernet/gtest/Makefile hostif/profiles/Time/gtest/Makefile hostif/profiles/DeviceInfo/gtest/Makefile + hostif/handlers/src/gtest/Makefile ]) # Generate the configure script diff --git a/src/hostif/handlers/include/hostIf_rbus_Dml_Provider.h b/src/hostif/handlers/include/hostIf_rbus_Dml_Provider.h index 2cb9f5cf1..322e6766c 100644 --- a/src/hostif/handlers/include/hostIf_rbus_Dml_Provider.h +++ b/src/hostif/handlers/include/hostIf_rbus_Dml_Provider.h @@ -48,11 +48,22 @@ #ifndef HOSTIF_RBUS_DML_PROVIDER_H_ #define HOSTIF_RBUS_DML_PROVIDER_H_ +#ifdef GTEST_ENABLE +#include "rbus_value.h" +#include "rbus.h" +#endif + void init_rbus_dml_provider(); int setRbusStringParam(const char *paramName, char* paramValue); int getRbusStringParam(const char *paramName, char** paramValue); +#ifdef GTEST_ENABLE +rbusError_t TR_Dml_EventSubHandler(rbusHandle_t handle, rbusEventSubAction_t action, const char* eventName, rbusFilter_t filter, int32_t interval, bool* autoPublish); +rbusError_t TR_Dml_GetHandler(rbusHandle_t handle, rbusProperty_t inProperty, rbusGetHandlerOptions_t* opts); +rbusError_t TR_Dml_SetHandler(rbusHandle_t handle, rbusProperty_t inProperty, rbusSetHandlerOptions_t* opts); +#endif + #endif /* HOSTIF_RBUS_DML_PROVIDER_H_ */ /* End of HOSTIF_RBUS_DML_PROVIDER_H_ API doxygen group */ diff --git a/src/hostif/handlers/src/gtest/Makefile.am b/src/hostif/handlers/src/gtest/Makefile.am new file mode 100644 index 000000000..279fb4966 --- /dev/null +++ b/src/hostif/handlers/src/gtest/Makefile.am @@ -0,0 +1,39 @@ +################################################################################ +# Copyright 2024 Comcast Cable Communications Management, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +AUTOMAKE_OPTIONS = subdir-objects + +# Define the program name and the source files +bin_PROGRAMS = handlers_gtest + +# Define the include directories + +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DYOCTO_BUILD -DUSE_DEV_PROPERTIES_CONF -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -Isrc/unittest/stubs/rbus/include/ -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/STBService -I/usr/rdk-halif-device_settings/include/ -I/usr/rdkvhal-devicesettings-raspberrypi4/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I/usr/remote_debugger/src/ -I/usr/local/include/libparodus/ -I/usr/local/include/wrp-c/ -I$(TOP_DIR)/src/hostif/parodusClient/startParodus/ -I$(TOP_DIR)/src/hostif/profiles/DHCPv4 -I/usr/include/libsoup-3.0 + +# Define the libraries to link against +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lglib-2.0 -llibparodus -lwrp-c -lnanomsg -lmsgpackc -ltrower-base64 -lcimplog -lsoup-3.0 + +# Define the compiler flags +COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) -fprofile-arcs -ftest-coverage + +handlers_gtest_SOURCES = handlers_test.cpp $(TOP_DIR)/src/hostif/parodusClient/startParodus/startParodus.cpp $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_attribute.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_parameter.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/libpd.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_adapter.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_msgHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_XrdkCentralT2_ReqHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_IPClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus_Process.cpp $(TOP_DIR)/src/hostif/profiles/Ethernet/Device_Ethernet_Interface.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_DisplayDevice.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_EthernetClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/Ethernet/Device_Ethernet_Interface_Stats.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_TimeClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface.cpp $(TOP_DIR)/src/hostif/profiles/Time/Device_Time.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_updateHandler.cpp $(TOP_DIR)/src/hostif/profiles/Device/x_rdk_profile.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_dsClient_ReqHandler.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_rbus_Dml_Provider.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Capabilities.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_SPDIF.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_VideoDecoder.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_AudioOutput.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_HDMI.cpp $(TOP_DIR)/src/hostif/profiles/STBService/Components_VideoOutput.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface_Stats.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_ActivePort.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Diagnostics_IPPing.cpp $(TOP_DIR)/src/hostif/profiles/IP/Device_IP_Interface_IPv4Address.cpp $(TOP_DIR)/src/hostif/handlers/src/x_rdk_req_handler.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_Processor.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo_ProcessStatus.cpp $(TOP_DIR)/src/unittest/stubs/ds/libprocps.cpp $(TOP_DIR)/src/unittest/stubs/file_writer.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_DHCPv4Client_ReqHandler.cpp $(TOP_DIR)/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.cpp + +# Apply common properties to each program +handlers_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) +handlers_gtest_LDADD = $(COMMON_LDADD) +handlers_gtest_CXXFLAGS = $(COMMON_CXXFLAGS) diff --git a/src/hostif/handlers/src/gtest/handlers_test.cpp b/src/hostif/handlers/src/gtest/handlers_test.cpp new file mode 100644 index 000000000..11faa7765 --- /dev/null +++ b/src/hostif/handlers/src/gtest/handlers_test.cpp @@ -0,0 +1,1530 @@ +/* + * Copyright 2024 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include +#include +#include "dm_stubs.h" +#include "startParodus.h" +#include "file_writer.h" +#include "webpa_notification.h" +#include "webpa_parameter.h" +#include "webpa_adapter.h" +#include "libpd.h" +#include "webpa_attribute.h" +#include "rbus_value.h" +#include "hostIf_tr69ReqHandler.h" +#include "hostIf_utils.h" +#include "wrp-c.h" +#include "x_rdk_req_handler.h" +#include "hostIf_rbus_Dml_Provider.h" +#include "rbus_value.h" +#include "rbus.h" +#include "hostIf_XrdkCentralT2_ReqHandler.h" +#include "hostIf_TimeClient_ReqHandler.h" +#include "hostIf_DeviceClient_ReqHandler.h" +#include "hostIf_EthernetClient_ReqHandler.h" +#include "hostIf_IPClient_ReqHandler.h" +#include "hostIf_DHCPv4Client_ReqHandler.h" + + +#include "waldb.h" +#include "wdmp-c.h" + +using namespace std; + + +#include +#include + + +#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" +#define GTEST_DEFAULT_RESULT_FILENAME "datamodel_gtest_report.json" +#define GTEST_REPORT_FILEPATH_SIZE 128 + +extern GHashTable* paramMgrhash; + +std::mutex mtx_httpServerThreadDone; +std::condition_variable cv_httpServerThreadDone; +bool httpServerThreadDone = false; +GThread *HTTPServerThread = NULL; +char *HTTPServerName = (char *)"HTTPServerThread"; +GError *httpError = NULL; +GHashTable* paramMgrhash = NULL; +T_ARGLIST argList = {{'\0'}, 0}; + +extern int (*convertRbus2hostIfDataTypeFunc()) (rbusValueType_t type, HostIf_ParamType_t* pParamType); + + +TEST(handlersTest, handleGetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDK_WebPA_DNSText.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_req_hdlr* reqHandler = static_cast(X_rdk_req_hdlr::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, handleSetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_RDK_WebPA_DNSText.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + strncpy(param.paramValue, "fabric.xmidt.comcast.net", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + X_rdk_req_hdlr* reqHandler = static_cast(X_rdk_req_hdlr::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, convertRbus2hostIfDataType) { + HostIf_ParamType_t paramType; + + EXPECT_EQ(convertRbus2hostIfDataTypeFunc()(RBUS_BOOLEAN, ¶mType), 0); + EXPECT_EQ(convertRbus2hostIfDataTypeFunc()(RBUS_INT8, ¶mType), 0); + EXPECT_EQ(convertRbus2hostIfDataTypeFunc()(RBUS_UINT8, ¶mType), 0); + EXPECT_EQ(convertRbus2hostIfDataTypeFunc()(RBUS_INT64, ¶mType), 0); + EXPECT_EQ(convertRbus2hostIfDataTypeFunc()(RBUS_STRING, ¶mType), 0); + EXPECT_EQ(convertRbus2hostIfDataTypeFunc()(RBUS_DATETIME, ¶mType), 0); +} + +TEST(handlersTest, TR_Dml_EventSubHandler) { + HostIf_ParamType_t paramType; + rbusHandle_t handle; + rbusEventSubAction_t action; + const char* eventName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType"; + rbusFilter_t filter; + int32_t interval = 60; + bool autoPublish = false; + + rbusError_t rc = TR_Dml_EventSubHandler(handle, action, eventName, filter, interval, &autoPublish); + EXPECT_EQ(rc, RBUS_ERROR_SUCCESS); +} + +TEST(handlersTest, TR_Dml_GetHandler) { + //MockRbusProperty mockProp = { "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable" }; + //rbusProperty_t testProp = (rbusProperty_t)&mockProp; + rbusProperty_t testProp; + + rbusHandle_t handle; + rbusGetHandlerOptions_t opts = {}; + + rbusError_t rc = TR_Dml_GetHandler(handle, testProp, &opts); + EXPECT_EQ(rc, 2); +} + +TEST(handlersTest, setRbusStringParam) { + const char *paramName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType"; + char* paramValue = "testdata"; + + int rc = setRbusStringParam(paramName, paramValue); + EXPECT_EQ(rc, -1); +} + +TEST(handlersTest, getRbusStringParam) { + const char *paramName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType"; + char* paramValue = nullptr; + + int rc = getRbusStringParam(paramName, ¶mValue); + EXPECT_EQ(rc, -1); +} + +TEST(handlersTest, XrdkCentralT2handleSetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_RDKCENTRAL-COM_T2.ReportProfiles", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + strncpy(param.paramValue, "testprofile", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + XRdkCentralT2* reqHandler = static_cast(XRdkCentralT2::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, XrdkCentralT2handleGetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDKCENTRAL-COM_T2.ReportProfiles", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + XRdkCentralT2* reqHandler = static_cast(XRdkCentralT2::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, TimeClientReqHandler_handleGetMsg_Enable) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.Time.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + + +TEST(handlersTest, TimeClientReqHandler_handleGetMsg_Status) { + write_on_file("/tmp/ntp_status", "ntp status"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.Time.Status", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(param.paramValue, "ntp status"); + } +} + +TEST(handlersTest, TimeClientReqHandler_handleGetMsg_LocalTimeZone) { + write_on_file("/tmp/ntp_status", "ntp status"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.Time.LocalTimeZone", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, TimeClientReqHandler_handleGetMsg_CurrentLocalTime) { + write_on_file("/tmp/ntp_status", "ntp status"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.Time.CurrentLocalTime", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, TimeClientReqHandler_handleGetMsg_X_RDK_CurrentUTCTime) { + write_on_file("/tmp/ntp_status", "ntp status"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.Time.X_RDK_CurrentUTCTime", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, TimeClientReqHandler_handleSetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.Time.NTPServer5", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_SRC_RFC; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "override_time4.com", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + + +TEST(handlersTest, TimeClientReqHandler_handleGetAttributesMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.Time.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetAttributesMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, TimeClientReqHandler_handleSetAttributesMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.Time.NTPServer4", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "override_time3.com", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + TimeClientReqHandler* reqHandler = static_cast(TimeClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetAttributesMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.SsrUrl", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_SRC_RFC; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "https://ssr.ccp.xcal.tv", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_FirmwareDownloadStatus) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Download Started", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_FirmwareDownloadProtocol) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadProtocol", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "http", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_FirmwareDownloadURL) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadURL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "https://xconf.xdp.eu-1.xcal.tv", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_PreferredGatewayType) { + write_on_file("/opt/prefered-gateway", "192.168.1.1"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_PreferredGatewayType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_set_xOpsDMUploadLogsNow) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.Logging.xOpsDMUploadLogsNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "true", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_ForwardSSHEnable) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_DownloadStatus) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_IPRemoteSupportEnable) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_IPRemoteSupport.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleSetMsg_PartnerId) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "global", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleSetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.SsrUrl", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_SRC_RFC; + param.requestor = HOSTIF_SRC_RFC; + + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_PreferredGatewayType) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_PreferredGatewayType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_Manufacturer) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.Manufacturer", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_ManufacturerOUI) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.ManufacturerOUI", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, -2); + } +} + + + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_ModelName) { + write_on_file("/tmp/.model", "SKY"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.ModelName", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(param.paramValue, "SKY"); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_Description) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.Description", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_HardwareVersion) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.HardwareVersion", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, NOK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_SoftwareVersion) { + writeToTr181storeFile("VERSION", "99.99.15.07", "/version.txt", Plain); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.SoftwareVersion", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } + std::remove("/version.txt"); +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_MigrationStatus) { + write_on_file("/opt/secure/persistent/MigrationStatus", "NEEDED"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.Migration.MigrationStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(param.paramValue, "NEEDED"); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_IUI_Version) { + write_on_file("/tmp/.iuiVersion", "4.4"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM.IUI.Version", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(param.paramValue, "4.4"); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_UpTime) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.UpTime", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_FirstUseDate) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.FirstUseDate", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + } +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_FirmwareFilename) { + write_on_file("/tmp/currently_running_image_name", "ELTE11MWR_DEV_develop_20250808222826_NG"); + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareFilename", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(param.paramValue, "ELTE11MWR_DEV_develop_20250808222826_NG"); + } + std::remove("/tmp/currently_running_image_name"); +} + +TEST(handlersTest, DeviceClientReqHandler_handleGetMsg_FirmwareDownloadStatus) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + DeviceClientReqHandler* reqHandler = static_cast(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) + { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DeviceClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleSetAttributesMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleSetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(EthernetClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleSetAttributesMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(IPClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(IPClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleSetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DHCPv4ClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DHCPv4ClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DHCPv4ClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DHCPv4ClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DHCPv4ClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleSetAttributesMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue <(DHCPv4ClientReqHandler::getInstance()); + if(reqHandler) { + int ret = reqHandler->handleGetAttributesMsg(¶m); + cout << "msgData.paramValue = " << param.paramValue < +#include #include "rdk_debug.h" #include "waldb.h" @@ -50,13 +53,18 @@ XBSStore* m_bsStore; XBSStoreJournal* m_bsStoreJournal; XRFCVarStore* m_varStore; +extern GHashTable* paramMgrhash; + std::mutex mtx_httpServerThreadDone; std::condition_variable cv_httpServerThreadDone; bool httpServerThreadDone = false; GThread *HTTPServerThread = NULL; char *HTTPServerName = (char *)"HTTPServerThread"; GError *httpError = NULL; +GHashTable* paramMgrhash = NULL; T_ARGLIST argList = {{'\0'}, 0}; +static SoupServer *http_server = NULL; + #ifdef GTEST_ENABLE extern DATA_TYPE (*getWdmpDataTypeFunc())(char * ); @@ -65,6 +73,14 @@ bool (*validateParamValueFunc())(const string ¶mValue, HostIf_ParamType_t da WDMP_STATUS (*handleRFCRequestFunc())(REQ_TYPE reqType, param_t *param); WDMP_STATUS (*invokeHostIfAPIFunc())(REQ_TYPE reqType, param_t *param, HostIf_Source_Type_t bsUpdate, const char *pcCallerID); WDMP_STATUS (*validateAgainstDataModelFunc())(REQ_TYPE reqType, char* paramName, const char* paramValue, DATA_TYPE *dataType, char **defaultValue, HostIf_Source_Type_t *bsUpdate); +extern void (*HTTPRequestHandlerFunc()) ( + SoupServer *server, + SoupServerMessage *msg, + const char *path, + GHashTable *query, + void *user_data); +extern void (*convertAndAssignParamValueFunc()) (HOSTIF_MsgData_t *param, char *value); +extern char* (*getStringValueFunc()) (HostIf_ParamType_t paramType, char *value); #endif TEST(httpserverTest,initRFCVarFileName){ @@ -104,6 +120,7 @@ TEST(httpserverTest, getWdmpDataType) { EXPECT_EQ(getWdmpDataTypeFunc()("int"), WDMP_INT); EXPECT_EQ(getWdmpDataTypeFunc()("unsignedLong"), WDMP_ULONG); EXPECT_EQ(getWdmpDataTypeFunc()("dataTime"), WDMP_DATETIME); + EXPECT_EQ(getWdmpDataTypeFunc()("float"), WDMP_NONE); } TEST(httpserverTest, getHostIfParamType) { @@ -131,6 +148,18 @@ TEST(httpserverTest, validateParamValue) { const string uiparamValue = "12"; dataType = hostIf_UnsignedIntType; EXPECT_EQ(validateParamValueFunc()(uiparamValue, dataType), true); + + const string paramValue = "flase"; + dataType = hostIf_BooleanType; + EXPECT_EQ(validateParamValueFunc()(paramValue, dataType), false); + + const string invalidIntValue = "123abc"; + dataType = hostIf_IntegerType; + EXPECT_EQ(validateParamValueFunc()(invalidIntValue, dataType), false); + + const string invalidLongValue = "123dab"; + dataType = hostIf_UnsignedLongType; + EXPECT_EQ(validateParamValueFunc()(invalidLongValue, dataType), false); } TEST(httpserverTest, handleRFCRequest_GET) { @@ -159,6 +188,19 @@ TEST(httpserverTest, handleRFCRequest_SET) { free(param.value); } +TEST(httpserverTest, InvalidReqtype) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup(XRFC_VAR_STORE_RELOADCACHE); + param.value = strdup("true"); + + REQ_TYPE reqType = DELETE_ROW; + WDMP_STATUS status = handleRFCRequestFunc()(reqType, ¶m); + EXPECT_EQ(status, WDMP_SUCCESS); + free(param.name); + free(param.value); +} + TEST(httpserverTest, handleRFCInvalidRequest) { param_t param; memset(¶m,0,sizeof(param_t)); @@ -172,7 +214,28 @@ TEST(httpserverTest, handleRFCInvalidRequest) { free(param.value); } +TEST(httpserverTest, invokeHostIfAPI_SET_FAILURE) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"); + param.value = strdup("true"); + + const char *pcCallerID = "rfc"; + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + REQ_TYPE reqType = SET; + WDMP_STATUS status = invokeHostIfAPIFunc()(reqType, ¶m, msgData.bsUpdate, pcCallerID); + EXPECT_EQ(status, 37); +} + + TEST(httpserverTest, invokeHostIfAPI) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + param_t param; memset(¶m,0,sizeof(param_t)); param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable"); @@ -189,6 +252,45 @@ TEST(httpserverTest, invokeHostIfAPI) { } +TEST(httpserverTest, invokeHostIfAPI_SET) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.SsrUrl"); + param.value = strdup("https://ssr.ccp.xcal.tv"); + + const char *pcCallerID = "rfc"; + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + REQ_TYPE reqType = SET; + WDMP_STATUS status = invokeHostIfAPIFunc()(reqType, ¶m, msgData.bsUpdate, pcCallerID); + EXPECT_EQ(status, WDMP_SUCCESS); +} + +TEST(httpserverTest, invokeHostIfAPI_InvalidReq) { + param_t param; + memset(¶m,0,sizeof(param_t)); + param.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.XconfUrl"); + const char *pcCallerID = "webpa"; + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + strncpy(msgData.paramValue, "https://ssr.ccp.xcal.tv", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + REQ_TYPE reqType = REPLACE_ROWS; + WDMP_STATUS status = invokeHostIfAPIFunc()(reqType, ¶m, msgData.bsUpdate, pcCallerID); + EXPECT_EQ(status, WDMP_ERR_INTERNAL_ERROR); +} + TEST(httpserverTest, validateAgainstDataModel_GET) { /* Load the data model xml file*/ @@ -278,6 +380,35 @@ TEST(httpserverTest, validateAgainstDataModel_SET_ReadOnly) { EXPECT_EQ(status, WDMP_ERR_NOT_WRITABLE); } +TEST(httpserverTest, validateAgainstDataModel_INVALID_PARAMETER_NAME) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + HOSTIF_MsgData_t msgData = { 0 }; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.bsUpdate = HOSTIF_NONE; + + char paramName [] = "Device.DeviceInfoTest.FriendlyName"; + const char* paramValue = "reverseSsh"; + DATA_TYPE dataType = WDMP_BOOLEAN; + + REQ_TYPE reqType = SET; + char defaultValue[66]; + char* defaultValuePtr = defaultValue; + WDMP_STATUS status = validateAgainstDataModelFunc()(SET, paramName, paramValue, &dataType, &defaultValuePtr, &msgData.bsUpdate); + EXPECT_EQ(status, WDMP_ERR_INVALID_PARAMETER_NAME); +} + TEST(httpserverTest, handleRequest_GET) { /* Load the data model xml file*/ @@ -336,6 +467,112 @@ TEST(httpserverTest, handlewildRequest_GET) { } +TEST(httpserverTest, handlewildRequestINVALIDPARAM_GET) { + + /* Load the data model xml file*/ + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + get_req_t *getReq = (get_req_t *)malloc(sizeof(get_req_t)); + getReq->paramCnt = 1; + getReq->paramNames[0] = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.SystemServices.FriendlyName"); + req_struct reqSt; + reqSt.reqType = GET; // Replace with actual enum value if it's defined + reqSt.u.getReq = getReq; + + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + EXPECT_EQ(respSt->retStatus[0], 22); +} + +/* TEST(httpserverTest, paramCount_GET) { + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + get_req_t *getReq = (get_req_t *)malloc(sizeof(get_req_t)); + getReq->paramCnt = 0; + // getReq->paramNames[0] = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.SystemServices.FriendlyName"); + req_struct reqSt; + reqSt.reqType = GET; // Replace with actual enum value if it's defined + reqSt.u.getReq = getReq; + + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + EXPECT_EQ(respSt->retStatus[0], NULL); +} + + +TEST(httpserverTest, paramCount_SET) { + + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + get_req_t *getReq = (get_req_t *)malloc(sizeof(get_req_t)); + getReq->paramCnt = 0; + // getReq->paramNames[0] = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.SystemServices.FriendlyName"); + req_struct reqSt; + reqSt.reqType = SET; // Replace with actual enum value if it's defined + reqSt.u.getReq = getReq; + + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + EXPECT_EQ(respSt->retStatus[0], NULL); +} +*/ + +/* TEST(httpserverTest, paramCount_InvalidParamName) { + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char* pcCallerID = "rfc"; + get_req_t *getReq = (get_req_t *)malloc(sizeof(get_req_t)); + getReq->paramCnt = 1; + getReq->paramNames[0] = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable.Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable.Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable.Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable.Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable"); + req_struct reqSt; + reqSt.reqType = SET; // Replace with actual enum value if it's defined + reqSt.u.getReq = getReq; + + + res_struct* respSt = handleRequest(pcCallerID, &reqSt); + EXPECT_EQ(respSt->retStatus[0], WDMP_ERR_INVALID_PARAMETER_NAME); +} */ + TEST(httpserverTest, handleRequest_SET) { /* Load the data model xml file*/ DB_STATUS dbStatus = loadDataModel(); @@ -379,6 +616,102 @@ TEST(httpserverTest, handleRequest_SET) { } +TEST(httpserverTest, convertAndAssignParamValue_BooleanType) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + convertAndAssignParamValueFunc()(¶m, "true"); + EXPECT_EQ(0, 0); +} + +TEST(httpserverTest, convertAndAssignParamValue_StringType) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + convertAndAssignParamValueFunc()(¶m, "Testtype"); + EXPECT_EQ(0, 0); +} + +TEST(httpserverTest, convertAndAssignParamValue_IntegerType) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + param.paramtype = hostIf_IntegerType; + param.paramLen = sizeof(hostIf_IntegerType); + + convertAndAssignParamValueFunc()(¶m, "1180000"); + EXPECT_EQ(0, 0); +} + +TEST(httpserverTest, convertAndAssignParamValue_UnsignedLongType) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.Ethernet.Interface.1.Stats.BytesReceived", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + param.paramtype = hostIf_UnsignedLongType; + param.paramLen = sizeof(hostIf_UnsignedLongType); + + convertAndAssignParamValueFunc()(¶m, "123456789"); + EXPECT_EQ(0, 0); +} + +TEST(httpserverTest, getStringValue) { + EXPECT_STREQ(getStringValueFunc()(hostIf_StringType, "global"), "global"); + EXPECT_STREQ(getStringValueFunc()(hostIf_IntegerType, "100"), "3158065"); + EXPECT_STREQ(getStringValueFunc()(hostIf_BooleanType, "true"), "false"); + EXPECT_STREQ(getStringValueFunc()(hostIf_BooleanType, "false"), "false"); + EXPECT_STREQ(getStringValueFunc()(hostIf_UnsignedLongType, "123456789"), "4050765991979987505"); +} + +TEST(httpserverTest, Invalid_RFC_filename) { + m_varStore = XRFCVarStore::getInstance(); + m_varStore->m_filename = "/opt/secure/RFC1/rfctest_Variable.ini"; + std::ofstream file("/opt/secure/RFC1/rfctest_Variable.ini"); + file.close(); + if(m_varStore) + { + bool ret = m_varStore->loadRFCVarIntoCache(); + EXPECT_EQ(ret, false); + } +} + +TEST(httpserverTest, HTTPRequestHandler_GET) { + + // Create a SoupMessage for POST + SoupServer *server = soup_server_new(nullptr, nullptr); + SoupMessage *msg = soup_message_new("POST", "http://localhost/api/status"); + const char *json_body = "{\"action\":\"ping\"}"; + GBytes *body_bytes = g_bytes_new_static(json_body, strlen(json_body)); + soup_message_set_request_body_from_bytes(msg, "application/json", body_bytes); + SoupMessageHeaders *headers = soup_message_get_request_headers(msg); + soup_message_headers_append(headers, "CallerID", "unittest"); + + HTTPRequestHandlerFunc()(server, reinterpret_cast(msg), "/api/status", nullptr, nullptr); + EXPECT_EQ(0, 0); +} + + GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; char buffer[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/httpserver/src/http_server.cpp b/src/hostif/httpserver/src/http_server.cpp index cfd53d163..d7ae0c1e1 100644 --- a/src/hostif/httpserver/src/http_server.cpp +++ b/src/hostif/httpserver/src/http_server.cpp @@ -289,3 +289,15 @@ void HttpServerStop() RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF,"SERVER: Stopped server successfully.\n"); } } + +#ifdef GTEST_ENABLE +void (*HTTPRequestHandlerFunc()) ( + SoupServer *server, + SoupServerMessage *msg, + const char *path, + GHashTable *query, + void *user_data) +{ + return &HTTPRequestHandler; +} +#endif diff --git a/src/hostif/httpserver/src/request_handler.cpp b/src/hostif/httpserver/src/request_handler.cpp index 43e3e9543..a324f5f23 100644 --- a/src/hostif/httpserver/src/request_handler.cpp +++ b/src/hostif/httpserver/src/request_handler.cpp @@ -770,4 +770,14 @@ defaultValue, HostIf_Source_Type_t *bsUpdate) { return &validateAgainstDataModel; } + +void (*convertAndAssignParamValueFunc()) (HOSTIF_MsgData_t *param, char *value) +{ + return &convertAndAssignParamValue; +} + +char* (*getStringValueFunc()) (HostIf_ParamType_t paramType, char *value) +{ + return &getStringValue; +} #endif diff --git a/src/hostif/include/IniFile.h b/src/hostif/include/IniFile.h index 013a7cecc..1bff86c3c 100644 --- a/src/hostif/include/IniFile.h +++ b/src/hostif/include/IniFile.h @@ -23,6 +23,10 @@ #include #include +#if defined(GTEST_ENABLE) +#include +#endif + class IniFile { public: @@ -36,6 +40,10 @@ class IniFile private: std::string m_filename; std::map m_dict; + +#if defined(GTEST_ENABLE) + FRIEND_TEST(srcTest, flush); +#endif }; #endif /* INIFILE_H_ */ diff --git a/src/hostif/parodusClient/gtest/Makefile.am b/src/hostif/parodusClient/gtest/Makefile.am index b24578528..ba4a499bc 100644 --- a/src/hostif/parodusClient/gtest/Makefile.am +++ b/src/hostif/parodusClient/gtest/Makefile.am @@ -22,20 +22,10 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = dm_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DUSE_DEV_PROPERTIES_CONF -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -Isrc/unittest/stubs/rbus/include/ -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/STBService -I/usr/rdk-halif-device_settings/include/ -I/usr/rdkvhal-devicesettings-raspberrypi4/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I/usr/remote_debugger/src/ -I/usr/local/include/libparodus/ -I/usr/local/include/wrp-c/ -I$(TOP_DIR)/src/hostif/parodusClient/startParodus/ - -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DUSE_DEV_PROPERTIES_CONF -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -Isrc/unittest/stubs/rbus/include/ -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/STBService -I/usr/rdk-halif-device_settings/include/ -I/usr/rdkvhal-devicesettings-raspberrypi4/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I/usr/remote_debugger/src/ -I/usr/local/include/libparodus/ -I/usr/local/include/wrp-c/ -I$(TOP_DIR)/src/hostif/parodusClient/startParodus/ -I/usr/include/libsoup-3.0 # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lglib-2.0 -llibparodus -lwrp-c -lnanomsg -lmsgpackc -ltrower-base64 -lcimplog - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lglib-2.0 -llibparodus -lwrp-c -lnanomsg -lmsgpackc -ltrower-base64 -lcimplog -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) -fprofile-arcs -ftest-coverage diff --git a/src/hostif/parodusClient/gtest/dm_test.cpp b/src/hostif/parodusClient/gtest/dm_test.cpp index ade9dc19c..83f6dba14 100644 --- a/src/hostif/parodusClient/gtest/dm_test.cpp +++ b/src/hostif/parodusClient/gtest/dm_test.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "dm_stubs.h" #include "startParodus.h" #include "file_writer.h" @@ -31,6 +32,9 @@ #include "hostIf_tr69ReqHandler.h" #include "hostIf_utils.h" #include "wrp-c.h" +#include "hostIf_msgHandler.h" +#include "Device_DeviceInfo_ProcessStatus_Process.h" +#include "cJSON.h" #include "waldb.h" #include "wdmp-c.h" @@ -56,12 +60,19 @@ GError *httpError = NULL; GHashTable* paramMgrhash = NULL; T_ARGLIST argList = {{'\0'}, 0}; +typedef struct { + char name[512]; + char value[512]; + int statusCode; + char message[512]; +} ParsedResult; + #ifdef GTEST_ENABLE extern void (*macToLowerFunc())(char macValue[],char macConverted[]); extern WDMP_STATUS (*GetParamInfoFunc()) (const char *pParameterName, param_t ***parametervalPtrPtr, int *paramCountPtr,int paramIndex); extern rbusValueType_t (*getRbusDataTypefromWebPAFunc())(WAL_DATA_TYPE type); extern DATA_TYPE (*mapRbusDataTypeToWebPAFunc())(rbusValueType_t type); -WDMP_STATUS (*get_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam); +WDMP_STATUS (*get_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam, DataModelParam *dmParam); WAL_STATUS (*set_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam); WAL_STATUS (*convertFaultCodeToWalStatusFunc())(faultCode_t faultCode); extern void (*converttohostIfTypeFunc())(char *ParamDataType,HostIf_ParamType_t* pParamType); @@ -74,8 +85,53 @@ extern WAL_STATUS (*getParamAttributesFunc()) (const char *pParameterName, AttrV extern WAL_STATUS (*setParamAttributesFunc()) (const char *pParameterName, const AttrVal *attArr); extern void (*setRebootReasonFunc()) (param_t param, WEBPA_SET_TYPE setType); extern long (*timeValDiffFunc()) (struct timespec *starttime, struct timespec *finishtime); +extern WDMP_STATUS (*rbusGetParamInfoFunc()) (const char *pParameterName, param_t ***parametervalPtrPtr, int *paramCountPtr, int index); +extern WAL_STATUS (*rbusSetParamInfoFunc()) (ParamVal paramVal, char * transactionID); +extern WAL_STATUS (*SetParamInfoFunc()) (ParamVal paramVal, char * transactionID); +void (*parodus_receive_waitFunc()) (); #endif +int parse_json(char *json_str, ParsedResult *result) { + cJSON *root = cJSON_Parse(json_str); + if (!root) return 0; // parse error + + cJSON *statusCode = cJSON_GetObjectItem(root, "statusCode"); + if (cJSON_IsNumber(statusCode)) { + result->statusCode = statusCode->valueint; + } else { + cJSON_Delete(root); + return 0; + } + + cJSON *parameters = cJSON_GetObjectItem(root, "parameters"); + if (cJSON_IsArray(parameters)) { + cJSON *param = cJSON_GetArrayItem(parameters, 0); + if (param) { + cJSON *name = cJSON_GetObjectItem(param, "name"); + cJSON *value = cJSON_GetObjectItem(param, "value"); + cJSON *message = cJSON_GetObjectItem(param, "message"); + + if (cJSON_IsString(name)) { + strncpy(result->name, name->valuestring, sizeof(result->name) - 1); + result->name[sizeof(result->name) - 1] = '\0'; + } + + if (cJSON_IsString(value)) { + strncpy(result->value, value->valuestring, sizeof(result->value) - 1); + result->value[sizeof(result->value) - 1] = '\0'; + } + + if (cJSON_IsString(message)) { + strncpy(result->message, message->valuestring, sizeof(result->message) - 1); + result->message[sizeof(result->message) - 1] = '\0'; + } + } + } + + cJSON_Delete(root); + return 1; // success +} + TEST(datamodelTest, ParameterExistPositive2) { /* Load the data model xml file*/ @@ -248,6 +304,28 @@ TEST(datamodelTest, getChildParamNamesFromDataModel) { EXPECT_EQ(status, DB_SUCCESS); } +TEST(datamodelTest, getChildParamNamesFromDataModel_InvalidParam) { + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + char *ParamList = NULL; + char *ParamDataTypeList = NULL; + + char *paramName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.FriendlyName"; + int paramCount = 1; + DB_STATUS status = getChildParamNamesFromDataModel(getDataModelHandle(), paramName, &ParamList, &ParamDataTypeList, ¶mCount); + EXPECT_EQ(status, 2); +} + TEST(datamodelTest, checkDataModelStatus) { DB_STATUS status = checkDataModelStatus(); EXPECT_EQ(status, DB_SUCCESS); @@ -267,12 +345,32 @@ TEST(startParodusTest, get_HWMAcAddress) { EXPECT_EQ(macAddr, "D452EEDEC6FA"); } +TEST(startParodusTest, get_PartnerId_Empty) { + write_on_file("/opt/www/authService/partnerId3.dat", ""); + std::string partnerId = get_PartnerId(); + EXPECT_EQ(partnerId, "*,"); +} + TEST(startParodusTest, get_PartnerId) { write_on_file("/opt/www/authService/partnerId3.dat", "sky"); std::string partnerId = get_PartnerId(); EXPECT_EQ(partnerId, "*,sky"); } +TEST(startParodusTest, get_PartnerId_Unknown) { + std::remove("/opt/www/authService/partnerId3.dat"); + write_on_file("/opt/www/authService/partnerId3.dat", "unknown"); + std::string partnerId = get_PartnerId(); + EXPECT_EQ(partnerId, "unknown"); + std::remove("/opt/www/authService/partnerId3.dat"); +} + +TEST(startParodusTest, get_RebootReason_Empty) { + write_on_file("/opt/secure/reboot/previousreboot.info", ""); + std::string reboot_reason = get_RebootReason(); + EXPECT_EQ(reboot_reason, ""); +} + TEST(startParodusTest, get_RebootReason) { std::string jsonData = "{\"reason\": \"PowerOnReset\", \"timestamp\": 1688914800}"; write_on_file("/opt/secure/reboot/previousreboot.info", jsonData); @@ -294,6 +392,14 @@ TEST(palTest, macToLower) { EXPECT_STREQ(macConverted, "a84a6388e9b5"); } +TEST(palTest, getnotifyparamList_Empty) { + setNotifyConfigurationFile("/tmp/empty.conf"); + char **notifyParamList = NULL; + int ptrnotifyListSize = 3; + int ret = getnotifyparamList(¬ifyParamList, &ptrnotifyListSize); + EXPECT_EQ(ret, -1); +} + TEST(palTest, getnotifyparamList) { const char* json_data = R"({"Notify":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart","Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd"]})"; write_on_file("/tmp/notify.conf", json_data); @@ -304,11 +410,46 @@ TEST(palTest, getnotifyparamList) { EXPECT_EQ(ret, 0); } -TEST(palTest, getNotifySource) { +/* TEST(palTest, getParamAttributes_Canary) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + + const char *paramName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart"; + AttrVal **attributes = NULL; + int totalParams = 1; + + WAL_STATUS status = getParamAttributesFunc()(paramName, &attributes, &totalParams); + EXPECT_EQ(status, WAL_SUCCESS); +} */ + +TEST(palTest, getNotifySource_Empty) { + char* notificationSource = getNotifySource(); + EXPECT_EQ(0, 0); +} + +TEST(palTest, getNotifySource) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); char* notificationSource = getNotifySource(); EXPECT_EQ(0, 0); } +TEST(palTest, setNotifyConfigurationFile) { + setNotifyConfigurationFile(NULL); + EXPECT_EQ(0, 0); +} + TEST(palTest, getRbusDataTypefromWebPA) { EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_STRING), RBUS_STRING); EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_INT), RBUS_INT32); @@ -321,6 +462,7 @@ TEST(palTest, getRbusDataTypefromWebPA) { EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_FLOAT), RBUS_SINGLE); EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_DOUBLE), RBUS_DOUBLE); EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_BYTE), RBUS_BYTE); + EXPECT_EQ(getRbusDataTypefromWebPAFunc()(WAL_NONE), RBUS_STRING); } TEST(palTest, mapRbusDataTypeToWebPA) { @@ -349,7 +491,11 @@ TEST(palTest, get_ParamValues_tr69hostIf) { param.paramtype = hostIf_IntegerType; param.paramLen = sizeof(hostIf_IntegerType); - WDMP_STATUS status = get_ParamValues_tr69hostIfFunc()(¶m); + DataModelParam dmParam = {0}; + const char* dbParamName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"; + int match = getParamInfoFromDataModel(getDataModelHandle(), dbParamName, &dmParam); + + WDMP_STATUS status = get_ParamValues_tr69hostIfFunc()(¶m, &dmParam); EXPECT_EQ(0, 0); } @@ -361,7 +507,7 @@ TEST(palTest, set_ParamValues_tr69hostIf) { param.bsUpdate = HOSTIF_NONE; param.requestor = HOSTIF_SRC_RFC; - put_boolean(param.paramValue, 13800); + put_int(param.paramValue, 13800); param.paramtype = hostIf_IntegerType; param.paramLen = sizeof(hostIf_IntegerType); @@ -402,10 +548,58 @@ TEST(palTest, converttohostIfType) { converttohostIfTypeFunc()("hexBinary", &pParamType); EXPECT_EQ(pParamType, hostIf_StringType); + + converttohostIfTypeFunc()("float", &pParamType); + EXPECT_EQ(pParamType, hostIf_StringType); } TEST(palTest, GetParamInfo) { + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + const char *pParameterName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"; + param_t** parameterval = (param_t**) calloc(1, sizeof(param_t*)); + EXPECT_NE(parameterval, nullptr); + int paramCountPtr = 0; + int index = 0; + WDMP_STATUS status = GetParamInfoFunc()(pParameterName, ¶meterval, ¶mCountPtr, index); + EXPECT_EQ(0, 0); +} + +TEST(palTest, GetParamInfo_UnsignedInt) { + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + const char *pParameterName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.collectd.PortNumber"; + param_t** parameterval = (param_t**) calloc(1, sizeof(param_t*)); + EXPECT_NE(parameterval, nullptr); + int paramCountPtr = 0; + int index = 0; + WDMP_STATUS status = GetParamInfoFunc()(pParameterName, ¶meterval, ¶mCountPtr, index); + EXPECT_EQ(0, 0); +} + +TEST(palTest, GetParamInfo_String) { + + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + DB_STATUS dbStatus = loadDataModel(); if(dbStatus != DB_SUCCESS) { @@ -425,6 +619,85 @@ TEST(palTest, GetParamInfo) { EXPECT_EQ(0, 0); } +TEST(palTest, SetParamInfoFunc_Bool) { + + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + ParamVal param; + param.name = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.IncrementalCDL.Enable"; + param.value = "false"; + param.type = WAL_BOOLEAN; + + char transactionID[] = "txn12344"; + + WAL_STATUS status = SetParamInfoFunc() (param, transactionID); + EXPECT_EQ(status, WAL_SUCCESS); +} + + +TEST(palTest, SetParamInfoFunc_Int) { + + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + ParamVal param; + param.name = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.LowSpeed"; + param.value = "14800"; + param.type = WAL_INT; + + char transactionID[] = "txn12344"; + + WAL_STATUS status = SetParamInfoFunc() (param, transactionID); + EXPECT_EQ(status, WAL_SUCCESS); +} + +TEST(palTest, SetParamInfoFunc_String) { + + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + + DB_STATUS dbStatus = loadDataModel(); + if(dbStatus != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(dbStatus, DB_SUCCESS); + ParamVal param; + param.name = "Device.X_RDKCENTRAL-COM_T2.ReportProfiles"; + param.value = "TestProfiles"; + param.type = WAL_STRING; + + char transactionID[] = "txn12344"; + + WAL_STATUS status = SetParamInfoFunc() (param, transactionID); + EXPECT_EQ(status, WAL_SUCCESS); +} + TEST(palTest, GetWildParamInfo) { const char *pParameterName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit."; param_t **parametervalPtrPtr = (param_t**) calloc(3, sizeof(param_t*)); @@ -444,6 +717,46 @@ TEST(palTest, GetWildParamInfo) { parametervalPtrPtr = NULL; } +TEST(palTest, GetWildParamInfo_String) { + const char *pParameterName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger."; + param_t **parametervalPtrPtr = (param_t**) calloc(4, sizeof(param_t*)); + int paramCountPtr = 4; + int index = 0; + WDMP_STATUS status = GetParamInfoFunc()(pParameterName, ¶metervalPtrPtr, ¶mCountPtr, index); + EXPECT_EQ(status, WDMP_SUCCESS); + + for (int i = 0; i < 4; i++) { + if (parametervalPtrPtr[i]) { + // If parametervalPtrPtr[i] points to dynamically allocated memory, free it + free(parametervalPtrPtr[i]); + parametervalPtrPtr[i] = NULL; + } + } + free(parametervalPtrPtr); + parametervalPtrPtr = NULL; +} + + +TEST(palTest, get_parodus_url_EmptyConfigFileSetsDefaults) { + // Write empty config file + std::ofstream ofs("/etc/webpa_cfg.json"); + ofs.close(); + char parodus_url[64] = {'\0'}; + char client_url[64] = {'\0'}; + get_parodus_urlFunc()(parodus_url, client_url); + EXPECT_NE(parodus_url, ""); + EXPECT_NE(client_url, ""); +} + +TEST(palPdTest, get_parodus_url_MissingConfigFileSetsDefaults) { + unlink("/etc/webpa_cfg.json"); + char parodus_url[64] = {'\0'}; + char client_url[64] = {'\0'}; + get_parodus_urlFunc()(parodus_url, client_url); + EXPECT_NE(parodus_url, ""); + EXPECT_NE(client_url, ""); +} + TEST(palTest, get_parodus_url) { char parodus_url[256] = {0}; char client_url[256] = {0}; @@ -454,6 +767,16 @@ TEST(palTest, get_parodus_url) { EXPECT_STREQ(client_url, "tcp://127.0.0.1:6666"); } +/*TEST(LibPdTest, sendNotification_ValidPayloadSends) { + // This requires a mock/fake for libparodus_send, wrp_free_struct, etc. + // For now, ensure function does not crash with valid input + char payload[] = "{\"command\":\"GET\",\"names\":[\"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed\"]}"; + char source[] = "source"; + char dest[] = "dest"; + sendNotification(payload, source, dest); + EXPECT_EQ(0, 0); +} */ + TEST(palTest, validate_parameter_wildcard) { param_t *params = (param_t *) malloc(sizeof(param_t) * 1); @@ -498,11 +821,9 @@ TEST(palTest, validate_parameter_NOT_Support) { free(params); } -TEST(palTest, processRequest_GET) { - // Initialize paramMgrhash if not already done - /*if (paramMgrhash == NULL) { - paramMgrhash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); - } */ +TEST(palTest, processRequest_GET) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); //Load the data model xml file DB_STATUS status = loadDataModel(); @@ -531,17 +852,50 @@ TEST(palTest, processRequest_GET) { processRequest((char*)wrp_msg->u.req.payload, (char*)wrp_msg->u.req.transaction_uuid, ((char **)(&(res_wrp_msg->u.req.payload)))); std::cout << "Response payload: " << (char*)res_wrp_msg->u.req.payload << std::endl; char *json_response = (char*)res_wrp_msg->u.req.payload; - EXPECT_EQ(0, 0); + + ParsedResult result = {0}; + if (parse_json(json_response, &result)) + { + EXPECT_EQ(result.statusCode, 200); + EXPECT_STREQ(result.message, "Success"); + EXPECT_STREQ(result.name, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"); + EXPECT_STREQ(result.value, "1280000"); + } } +TEST(palTest, processRequest_GETWildCard) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); -TEST(palTest, processRequest_SET) { - // Initialize paramMgrhash if not already done - /* if (paramMgrhash == NULL) { - paramMgrhash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); - } */ + //Load the data model xml file + DB_STATUS status = loadDataModel(); + if(status != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(status, DB_SUCCESS); + wrp_msg_t *wrp_msg; + wrp_msg_t *res_wrp_msg; - // Load the data model xml file + wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + res_wrp_msg = (wrp_msg_t *)malloc(sizeof(wrp_msg_t)); + memset(res_wrp_msg, 0, sizeof(wrp_msg_t)); + wrp_msg->msg_type = WRP_MSG_TYPE__REQ; + const char *payload = "{\"command\":\"GET_ATTRIBUTES\",\"attributes\":\"notify\",\"names\":[\"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.\"]}"; + wrp_msg->u.req.payload = (void*)payload; + wrp_msg->u.req.payload_size = strlen((char*)wrp_msg->u.req.payload); + processRequest((char*)wrp_msg->u.req.payload, (char*)wrp_msg->u.req.transaction_uuid, ((char **)(&(res_wrp_msg->u.req.payload)))); + std::cout << "Response payload: " << (char*)res_wrp_msg->u.req.payload << std::endl; + char *json_response = (char*)res_wrp_msg->u.req.payload; + EXPECT_EQ(0, 0); +} + +TEST(palTest, processRequest_SET) { + // Load the data model xml file DB_STATUS status = loadDataModel(); if(status != DB_SUCCESS) { @@ -568,10 +922,38 @@ TEST(palTest, processRequest_SET) { processRequest((char*)wrp_msg->u.req.payload, (char*)wrp_msg->u.req.transaction_uuid, ((char **)(&(res_wrp_msg->u.req.payload)))); std::cout << "Response payload: " << (char*)res_wrp_msg->u.req.payload << std::endl; char *json_response = (char*)res_wrp_msg->u.req.payload; + + ParsedResult result = {0}; + if (parse_json(json_response, &result)) + { + EXPECT_EQ(result.statusCode, 200); + EXPECT_STREQ(result.message, "Success"); + EXPECT_STREQ(result.name, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.LogUpload.LogServerUrl"); + } +} + +TEST(srcTest, getCurrentTime) { + struct timespec ts; + getCurrentTime(&ts); + EXPECT_GT(ts.tv_sec, 0); + + EXPECT_GE(ts.tv_nsec, 0); + EXPECT_LT(ts.tv_nsec, 1000000000L); +} + +TEST(srcTest, setInitialNotifyConfigFile) { + std::remove("/tmp/notify.conf"); + const char* json_data = R"({"Notify":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable","Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"]})"; + write_on_file("/tmp/notify.conf", json_data); + char **notifyParamList = NULL; + int ptrnotifyListSize = 2; + setInitialNotifyConfigFile("/tmp/notify.conf"); + int ret = getnotifyparamList(¬ifyParamList, &ptrnotifyListSize); + setInitialNotify(); EXPECT_EQ(0, 0); } -TEST(palTest, get_AttribValues_tr69hostIf) { +/* TEST(palTest, get_AttribValues_tr69hostIf) { HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); param.reqType = HOSTIF_GET; @@ -581,9 +963,12 @@ TEST(palTest, get_AttribValues_tr69hostIf) { WAL_STATUS status = get_AttribValues_tr69hostIfFunc()(¶m); EXPECT_EQ(status, WAL_ERR_INVALID_PARAM); -} +} */ TEST(palTest, set_AttribValues_tr69hostIf) { + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); param.reqType = HOSTIF_SET; @@ -596,7 +981,7 @@ TEST(palTest, set_AttribValues_tr69hostIf) { param.paramLen = sizeof(hostIf_BooleanType); WAL_STATUS status = set_AttribValues_tr69hostIfFunc()(¶m); - EXPECT_EQ(status, 4); + EXPECT_EQ(status, WAL_SUCCESS); } TEST(palTest, getParamAttributes) { @@ -618,8 +1003,83 @@ TEST(palTest, setParamAttributes) { EXPECT_EQ(status, WAL_SUCCESS); } +TEST(palTest, setParamAttributes_notifyList) { + std::remove("/tmp/notify.conf"); + const char* json_data = R"({"Notify":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable","Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"]})"; + write_on_file("/tmp/notify.conf", json_data); + char **notifyParamList = NULL; + int ptrnotifyListSize = 3; + setNotifyConfigurationFile("/tmp/notify.conf"); + int ret = getnotifyparamList(¬ifyParamList, &ptrnotifyListSize); + const char *paramName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"; + AttrVal attr; + + attr.name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"); + attr.value = strdup("168000"); + + WAL_STATUS status = setParamAttributesFunc()(paramName, &attr); + EXPECT_EQ(status, WAL_SUCCESS); +} + +TEST(palTest, getAttributes) { + const char *paramNames[] = { + "Device.DeviceInfo.ModelName", + "Device.DeviceInfo.SerialNumber" + }; + unsigned int paramCount = sizeof(paramNames) / sizeof(paramNames[0]); + + money_trace_spans span = {0}; // Optional, or nullptr + + AttrVal **attrArray = nullptr; + int attrCount = 0; + WAL_STATUS status = WAL_FAILURE; + + getAttributes(paramNames, paramCount, &span, &attrArray, &attrCount, &status); + + EXPECT_EQ(status, 14); +} + +TEST(palTest, setAttributes) { + std::remove("/tmp/notify.conf"); + const char* json_data = R"({"Notify":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"]})"; + write_on_file("/tmp/notify.conf", json_data); + char **notifyParamList = NULL; + int ptrnotifyListSize = 1; + setNotifyConfigurationFile("/tmp/notify.conf"); + int ret = getnotifyparamList(¬ifyParamList, &ptrnotifyListSize); + + ParamVal params[1]; + params[0].name = strdup("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"); + params[0].value = strdup("true"); + params[0].type = WAL_BOOLEAN; + + unsigned int paramCount = 1; + money_trace_spans traceSpan = {0}; + AttrVal val1 = { (char *)"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable", (char *)"true", WAL_BOOLEAN }; + const AttrVal *attrList[1] = { &val1 }; + WDMP_STATUS* statuses = new WDMP_STATUS[1]; + + setAttributes(params, paramCount, &traceSpan, attrList, &statuses); + EXPECT_EQ(0, 0); +} + +/* TEST(webpaAdapterTest, setRebootReason) { + + strcpy(argList.confFile, "/etc/mgrlist.conf"); + bool ret = hostIf_initalize_ConfigManger(); + + //Load the data model xml file + DB_STATUS status = loadDataModel(); + if(status != DB_SUCCESS) + { + std::cout << "Error in Data Model Initialization" << std::endl; + } + else + { + std::cout << "Successfully initialize Data Model." << std::endl; + } + EXPECT_EQ(status, DB_SUCCESS); -TEST(webpaAdapterTest, setRebootReason) { // Prepare a param_t with the reboot parameter and value param_t param; param.name = strdup("Device.X_CISCO_COM_DeviceControl.RebootDevice"); @@ -635,8 +1095,20 @@ TEST(webpaAdapterTest, setRebootReason) { // L1: No assertion needed, just ensure no crash EXPECT_EQ(0, 0); +} */ + + +TEST(palTest, parodus_receive_waitFunc) { + parodus_receive_waitFunc(); + sleep(30); + stop_parodus_recv_wait(); + EXPECT_EQ(0, 0); } +TEST(palTest, stop_parodus_recv_wait) { + stop_parodus_recv_wait(); + EXPECT_EQ(0, 0); +} TEST(palTest, notificationCallBack) { notificationCallBack(); @@ -648,6 +1120,15 @@ TEST(palTest, setInitialNotify) { EXPECT_EQ(0, 0); } +TEST(palTest, libpd_set_notifyConfigFile) { + std::remove("/tmp/notify.conf"); const char* json_data = R"({"Notify":["Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.Enable","Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed"]})"; + write_on_file("/tmp/notify.conf", json_data); + char **notifyParamList = NULL; + int ptrnotifyListSize = 2; + libpd_set_notifyConfigFile("/tmp/notify.conf"); + EXPECT_EQ(0, 0); +} + TEST(palTest, registerNotifyCallback) { registerNotifyCallback(); EXPECT_EQ(0, 0); @@ -668,6 +1149,186 @@ TEST(palTest, timeValDiff) { EXPECT_EQ(msec, 1700); } +TEST(palTest, replaceWithInstanceNumber) { + char paramName[50] = "Device.DeviceInfo.XXXX.{i}"; + int instanceNumber = 3; + replaceWithInstanceNumber(paramName, instanceNumber); + EXPECT_STREQ(paramName, "Device.DeviceInfo.XXXX.{i}"); +} + +TEST(palTest, appendNextObject) { + char currentParam[100] = "Device.WiFi.{i}.SSID."; + const char* pAttparam = "Device.WiFi.{i}.SSID.Enable"; + appendNextObject(currentParam, pAttparam); + + EXPECT_STREQ(currentParam, "Device.WiFi.{i}.SSID.Enable"); +} + +TEST(palTest, test_get_complete_param_list) { + test_get_complete_param_list(); + EXPECT_EQ(0, 0); +} + +TEST(palTest, converttoWalType) { + WAL_DATA_TYPE walType = WAL_STRING; + + converttoWalTypeFunc()(hostIf_IntegerType, &walType); + EXPECT_EQ(walType, WAL_INT); + + converttoWalTypeFunc()(hostIf_UnsignedIntType, &walType); + EXPECT_EQ(walType, WAL_UINT); + + converttoWalTypeFunc()(hostIf_BooleanType, &walType); + EXPECT_EQ(walType, WAL_BOOLEAN); + + converttoWalTypeFunc()(hostIf_UnsignedLongType, &walType); + EXPECT_EQ(walType, WAL_ULONG); + + converttoWalTypeFunc()(hostIf_DateTimeType, &walType); + EXPECT_EQ(walType, WAL_DATETIME); +} + +TEST(palTest, rbusSetParamInfo) { + ParamVal param; + param.name = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable"; + param.value = "true"; + param.type = WAL_BOOLEAN; + + char transactionID[] = "txn12345"; + + WAL_STATUS status = rbusSetParamInfoFunc() (param, transactionID); + EXPECT_EQ(status, WAL_SUCCESS); +} + +TEST(palTest, getnotifyparamList_NULL) { + char **dummyList = NULL; + int result = getnotifyparamList(&dummyList, NULL); + EXPECT_EQ(result, -1); + + int dummySize = 0; + int ret = getnotifyparamList(NULL, &dummySize); + EXPECT_EQ(ret, -1); +} + +TEST(ProcessStatus, DeviceInfo_ProcessStatus_Process_PID) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.ProcessStatus.Process.1.PID", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceProcess *hostIf_DeviceProcess = hostIf_DeviceProcess::getInstance(instanceNumber); + if(hostIf_DeviceProcess) + { + bChanged = false; + int ret = hostIf_DeviceProcess->get_Device_DeviceInfo_ProcessStatus_Process_PID(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(ProcessStatus, DeviceInfo_ProcessStatus_Process_Command) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.ProcessStatus.Process.1.Command", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceProcess *hostIf_DeviceProcess = hostIf_DeviceProcess::getInstance(instanceNumber); + if(hostIf_DeviceProcess) + { + bChanged = false; + int ret = hostIf_DeviceProcess->get_Device_DeviceInfo_ProcessStatus_Process_PID(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(ProcessStatus, DeviceInfo_ProcessStatus_Process_Size) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.ProcessStatus.Process.1.Size", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceProcess *hostIf_DeviceProcess = hostIf_DeviceProcess::getInstance(instanceNumber); + if(hostIf_DeviceProcess) + { + bChanged = false; + int ret = hostIf_DeviceProcess->get_Device_DeviceInfo_ProcessStatus_Process_PID(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(ProcessStatus, DeviceInfo_ProcessStatus_Process_Priority) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.ProcessStatus.Process.1.Priority", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceProcess *hostIf_DeviceProcess = hostIf_DeviceProcess::getInstance(instanceNumber); + if(hostIf_DeviceProcess) + { + bChanged = false; + int ret = hostIf_DeviceProcess->get_Device_DeviceInfo_ProcessStatus_Process_PID(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(ProcessStatus, DeviceInfo_ProcessStatus_Process_CPUTime) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.ProcessStatus.Process.1.CPUTime", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceProcess *hostIf_DeviceProcess = hostIf_DeviceProcess::getInstance(instanceNumber); + if(hostIf_DeviceProcess) + { + bChanged = false; + int ret = hostIf_DeviceProcess->get_Device_DeviceInfo_ProcessStatus_Process_PID(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + +TEST(ProcessStatus, DeviceInfo_ProcessStatus_Process_State) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.ProcessStatus.Process.1.State", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceProcess *hostIf_DeviceProcess = hostIf_DeviceProcess::getInstance(instanceNumber); + if(hostIf_DeviceProcess) + { + bChanged = false; + int ret = hostIf_DeviceProcess->get_Device_DeviceInfo_ProcessStatus_Process_PID(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/parodusClient/pal/libpd.cpp b/src/hostif/parodusClient/pal/libpd.cpp index 7e258f252..d21935651 100644 --- a/src/hostif/parodusClient/pal/libpd.cpp +++ b/src/hostif/parodusClient/pal/libpd.cpp @@ -461,4 +461,10 @@ long (*timeValDiffFunc()) (struct timespec *starttime, struct timespec *finishti { return &timeValDiff; } + +void (*parodus_receive_waitFunc()) () +{ + return &parodus_receive_wait; +} + #endif diff --git a/src/hostif/parodusClient/pal/webpa_parameter.cpp b/src/hostif/parodusClient/pal/webpa_parameter.cpp index 0cf204bc9..9ef5b0987 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.cpp +++ b/src/hostif/parodusClient/pal/webpa_parameter.cpp @@ -660,7 +660,7 @@ static WDMP_STATUS get_ParamValues_tr69hostIf(HOSTIF_MsgData_t *ptrParam, DataMo status = hostIf_GetMsgHandler(ptrParam); if(status != 0) { - if (dmParam->defaultValue) + if (dmParam != NULL && dmParam->defaultValue) { strncpy(ptrParam->paramValue, dmParam->defaultValue, MAX_PARAM_LENGTH - 1); ptrParam->paramValue[MAX_PARAM_LENGTH - 1] = '\0'; @@ -811,7 +811,8 @@ DATA_TYPE (*mapRbusDataTypeToWebPAFunc()) (rbusValueType_t type) { return &mapRbusDataTypeToWebPA; } -WDMP_STATUS (*get_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam) + +WDMP_STATUS (*get_ParamValues_tr69hostIfFunc()) (HOSTIF_MsgData_t *ptrParam, DataModelParam *dmParam) { return &get_ParamValues_tr69hostIf; } @@ -833,6 +834,21 @@ void (*converttohostIfTypeFunc())(char *ParamDataType,HostIf_ParamType_t* pParam void (*converttoWalTypeFunc())(HostIf_ParamType_t paramType,WAL_DATA_TYPE* pwalType) { - &converttoWalType; + return &converttoWalType; +} + +WDMP_STATUS (*rbusGetParamInfoFunc()) (const char *pParameterName, param_t ***parametervalPtrPtr, int *paramCountPtr, int index) +{ + return &rbusGetParamInfo; +} + +WAL_STATUS (*rbusSetParamInfoFunc()) (ParamVal paramVal, char * transactionID) +{ + return &rbusSetParamInfo; +} + +WAL_STATUS (*SetParamInfoFunc()) (ParamVal paramVal, char * transactionID) +{ + return &SetParamInfo; } #endif diff --git a/src/hostif/parodusClient/waldb/waldb.h b/src/hostif/parodusClient/waldb/waldb.h index bc729434c..94cd823ac 100644 --- a/src/hostif/parodusClient/waldb/waldb.h +++ b/src/hostif/parodusClient/waldb/waldb.h @@ -90,6 +90,9 @@ int isParamEndsWithInstance(const char* paramName); int getNumberOfDigitsInInstanceNumber(const char* paramName,int position); int getNumberofInstances(const char* paramName); int checkMatchingParameter(const char* attrValue, char* paramName, int* ret); +void replaceWithInstanceNumber(char *paramName, int instanceNumber); +void appendNextObject(char* currentParam, const char* pAttparam); +void test_get_complete_param_list(); #endif #ifdef __cplusplus diff --git a/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h b/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h index 566fce180..4edf4d995 100644 --- a/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h +++ b/src/hostif/profiles/DHCPv4/Device_DHCPv4_Client.h @@ -181,6 +181,9 @@ class hostIf_DHCPv4Client { #if defined(GTEST_ENABLE) FRIEND_TEST(dhcpv4Test, isValidIPAddr); + FRIEND_TEST(dhcpv4Test, InvalidIPAddr); + FRIEND_TEST(dhcpv4Test, InvalidIP); + FRIEND_TEST(dhcpv4Test, InvalidIPAddr_alpha); FRIEND_TEST(dhcpv4Test, getInterfaceName); FRIEND_TEST(dhcpv4Test, isIfnameInroutetoDNSServer); #endif diff --git a/src/hostif/profiles/DHCPv4/gtest/Makefile.am b/src/hostif/profiles/DHCPv4/gtest/Makefile.am index c0b47692c..d0d878001 100644 --- a/src/hostif/profiles/DHCPv4/gtest/Makefile.am +++ b/src/hostif/profiles/DHCPv4/gtest/Makefile.am @@ -21,20 +21,10 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = dhcpv4_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DYOCTO_BUILD -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/DHCPv4 -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) - -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DYOCTO_BUILD -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/DHCPv4 -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) -I/usr/include/libsoup-3.0 # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp b/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp index 85138893b..07677f5b8 100644 --- a/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp +++ b/src/hostif/profiles/DHCPv4/gtest/gtest_dhcpv4.cpp @@ -36,9 +36,10 @@ using namespace std; +#define IFNAMSIZ 16 TEST(dhcpv4Test, isValidIPAddr) { - int instanceNumber = 0; + int instanceNumber = 1; char* addr = (char*)"192.168.1.1"; hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); if(dhcpClient) @@ -48,19 +49,53 @@ TEST(dhcpv4Test, isValidIPAddr) { } } +TEST(dhcpv4Test, InvalidIPAddr) { + int instanceNumber = 1; + char* addr = (char*)"192.168.1.1.1"; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bool result = dhcpClient->isValidIPAddr(addr); + EXPECT_EQ(result, false); + } +} + +TEST(dhcpv4Test, InvalidIP) { + int instanceNumber = 1; + char* addr = (char*)"192.168.256.1"; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bool result = dhcpClient->isValidIPAddr(addr); + EXPECT_EQ(result, false); + } +} + +TEST(dhcpv4Test, InvalidIPAddr_alpha) { + int instanceNumber = 1; + char* addr = (char*)"192.168.a.1"; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bool result = dhcpClient->isValidIPAddr(addr); + EXPECT_EQ(result, false); + } +} + TEST(dhcpv4Test, getInterfaceName) { - int instanceNumber = 0; - char *ifname = (char*)"eth0"; + int instanceNumber = 1; + char ifname[IFNAMSIZ]={'\0'}; hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); if(dhcpClient) { int result = dhcpClient->getInterfaceName(ifname); - EXPECT_EQ(result, -1); + EXPECT_EQ(result, OK); } } -TEST(dhcpv4Test, isIfnameInroutetoDNSServer) { - int instanceNumber = 0; + +/* TEST(dhcpv4Test, isIfnameInroutetoDNSServer) { + int instanceNumber = 1; char* dnsServer = (char*)"8.8.8.8"; char* ifname = (char*)"eth0"; hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); @@ -69,21 +104,83 @@ TEST(dhcpv4Test, isIfnameInroutetoDNSServer) { bool result = dhcpClient->isIfnameInroutetoDNSServer(dnsServer, ifname); EXPECT_EQ(result, true); } -} +} */ TEST(dhcpv4Test, get_Device_DHCPv4_ClientNumberOfEntries) { - int instanceNumber = 0; + int instanceNumber = 1; HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); if(dhcpClient) { int result = dhcpClient->get_Device_DHCPv4_ClientNumberOfEntries(¶m); + cout << "param.paramValue = " << param.paramValue << endl; EXPECT_EQ(result, OK); EXPECT_EQ(param.paramtype, hostIf_UnsignedIntType); } } +TEST(dhcpv4Test, get_Device_DHCPv4_Client_IPRouters) { + int instanceNumber = 1; + bool bChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bChanged = false; + int result = dhcpClient->get_Device_DHCPv4_Client_IPRouters(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(result, OK); + EXPECT_EQ(param.paramtype, hostIf_StringType); + } +} + +TEST(dhcpv4Test, get_Device_DHCPv4_Client_DnsServer) { + int instanceNumber = 1; + bool bChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bChanged = false; + int result = dhcpClient->get_Device_DHCPv4_Client_DnsServer(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(result, OK); + EXPECT_EQ(param.paramtype, hostIf_StringType); + } +} + +TEST(dhcpv4Test, get_Device_DHCPv4_Client_InterfaceReference) { + int instanceNumber = 1; + bool bChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + bChanged = false; + int result = dhcpClient->get_Device_DHCPv4_Client_InterfaceReference(¶m, &bChanged); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(result, OK); + EXPECT_EQ(param.paramtype, hostIf_StringType); + } +} + +TEST(dhcpv4Test, Lock_ReleaseLock) { + int instanceNumber = 1; + hostIf_DHCPv4Client *dhcpClient= hostIf_DHCPv4Client::getInstance(instanceNumber); + if(dhcpClient) + { + dhcpClient->getLock(); + dhcpClient->releaseLock(); + EXPECT_EQ(0, 0); + } + dhcpClient->closeInstance(dhcpClient); + dhcpClient->closeAllInstances(); +} + GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; char buffer[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/profiles/Device/gtest/Makefile.am b/src/hostif/profiles/Device/gtest/Makefile.am index f81e27d44..44b882747 100644 --- a/src/hostif/profiles/Device/gtest/Makefile.am +++ b/src/hostif/profiles/Device/gtest/Makefile.am @@ -21,20 +21,10 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = device_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) - -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/IP -I$(TOP_DIR)/src/hostif/profiles/Device -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) -I/usr/include/libsoup-3.0 # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/hostif/profiles/Device/gtest/gtest_device.cpp b/src/hostif/profiles/Device/gtest/gtest_device.cpp index 4d1bc0a7b..f4995fef8 100644 --- a/src/hostif/profiles/Device/gtest/gtest_device.cpp +++ b/src/hostif/profiles/Device/gtest/gtest_device.cpp @@ -160,6 +160,64 @@ TEST(DeviceTest, set_WebPA_DNSText_URL) { } } +TEST(DeviceTest, handleGetMsg_WebPA_Server_URL) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.X_RDK_WebPA_Server.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->handleGetMsg(¶m); + std::string value = getStringValue(¶m); + EXPECT_EQ(ret, OK); + EXPECT_EQ(value, ""); + } +} + +TEST(DeviceTest, handleSetMsg_InvalidParam) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.FriendlyName.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->handleSetMsg(¶m); + EXPECT_EQ(ret, NOK); + EXPECT_EQ(param.faultCode, fcInvalidParameterName); + } +} + +TEST(DeviceTest, handleGetMsg_InvalidParam) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.FriendlyName.URL", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_WEBPA; + param.paramtype = hostIf_StringType; + param.paramLen = sizeof(hostIf_StringType); + + X_rdk_profile* profile = X_rdk_profile::getInstance(); + if(profile) + { + int ret = profile->handleGetMsg(¶m); + EXPECT_EQ(ret, NOK); + EXPECT_EQ(param.faultCode, fcInvalidParameterName); + } + profile->closeInstance(); +} + GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; char buffer[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 4dacf35c1..186d79224 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1742,31 +1742,25 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename(H } if(line.length()) { - char * cstr = new char [line.length()+1]; - rc=strcpy_s (cstr,(line.length()+1), line.c_str()); - if(rc!=EOK) + std::string::size_type pos = line.find(':'); + if (pos == std::string::npos) { - ERR_CHK(rc); + return NOK; } - char * pch = NULL; - pch = strstr (cstr,":"); - pch++; - - while(isspace(*pch)) { - pch++; - } - delete[] cstr; - - if(bCalledX_COMCAST_COM_FirmwareFilename && pChanged && strncmp(pch,backupX_COMCAST_COM_FirmwareFilename,_BUF_LEN_64 )) + std::string value = line.substr(pos + 1); + value.erase(0, value.find_first_not_of(" \t")); + + if(bCalledX_COMCAST_COM_FirmwareFilename && pChanged && strncmp(value.c_str(),backupX_COMCAST_COM_FirmwareFilename,_BUF_LEN_64 )) { *pChanged = true; } bCalledX_COMCAST_COM_FirmwareFilename = true; - strncpy(backupX_COMCAST_COM_FirmwareFilename,pch,sizeof(backupX_COMCAST_COM_FirmwareFilename) -1); //CID:136569 - Buffer size + strncpy(backupX_COMCAST_COM_FirmwareFilename,value.c_str(),sizeof(backupX_COMCAST_COM_FirmwareFilename) -1); //CID:136569 - Buffer size backupX_COMCAST_COM_FirmwareFilename[sizeof(backupX_COMCAST_COM_FirmwareFilename) -1] = '\0'; - strncpy(stMsgData->paramValue,pch,_BUF_LEN_64 ); - strncpy((char *) stMsgData->paramValue, pch, stMsgData->paramLen +1 ); + strncpy((char *) stMsgData->paramValue, value.c_str(), sizeof(stMsgData->paramValue)-1); + stMsgData->paramValue[sizeof(stMsgData->paramValue)-1] = '\0'; + stMsgData->paramLen = value.length(); } } @@ -5866,6 +5860,13 @@ int hostIf_DeviceInfo::set_xRDKDownloadManager_DownloadStatus(HOSTIF_MsgData_t * return ret; } #endif + +#ifdef GTEST_ENABLE +bool (*ValidateInput_ArgumentsFunc()) (char *input, FILE *tmp_fptr) +{ + return &ValidateInput_Arguments; +} +#endif /* End of doxygen group */ /** * @} diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h index 6fd2b7294..8f8e9ee26 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h @@ -318,6 +318,8 @@ class hostIf_DeviceInfo { FRIEND_TEST(deviceTest, NewNtpEnable); FRIEND_TEST(deviceTest, set_xRDKCentralComRFCLoudnessEquivalenceEnable); FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable); + FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCDisable); + FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCInvalidtype); FRIEND_TEST(deviceTest, set_xOpsRPCRebootPendingNotification); FRIEND_TEST(deviceTest, set_xRDKCentralComApparmorBlocklist); FRIEND_TEST(deviceTest, set_xOpsRPCFwDwldCompletedNotification); @@ -332,6 +334,7 @@ class hostIf_DeviceInfo { FRIEND_TEST(deviceTest, get_xOpsRPCFwDwldCompletedNotification); FRIEND_TEST(deviceTest, set_xOpsRPCRebootPendingNotification); FRIEND_TEST(deviceTest, set_xRDKCentralComNewNtpEnable); + FRIEND_TEST(deviceTest, NewNtpEnable_Disable); FRIEND_TEST(deviceTest, findLocalPortAvailable); FRIEND_TEST(deviceTest, get_xOpsRPCRebootPendingNotification); FRIEND_TEST(deviceTest, get_xOpsRPCFwDwldStartedNotification); @@ -340,6 +343,15 @@ class hostIf_DeviceInfo { FRIEND_TEST(deviceTest, set_xRDKCentralComRFCLoudnessEquivalenceEnable); FRIEND_TEST(deviceTest, set_xOpsDeviceMgmtRPCRebootNow); FRIEND_TEST(deviceTest, set_xRDKCentralComDABRFCEnable); + FRIEND_TEST(deviceTest, set_xRDKCentralComDABRFCDisable); + FRIEND_TEST(deviceTest, set_xRDKCentralComDABRFCInvalidtype); + FRIEND_TEST(deviceTest, get_xOpsRPCDevManageableNotification); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCRoamTrigger); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCLoudnessEquivalenceEnable_InvalidType); + FRIEND_TEST(deviceTest, set_xRDKCentralComRFCAutoRebootEnable_Invalidtype); + FRIEND_TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable_FileRemoved); + FRIEND_TEST(deviceTest, NewNtpEnable_Disable_FileRemoved); + FRIEND_TEST(deviceTest, get_xRDKCentralComRFCAccountId); #endif public: diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h index 5b18fd5da..918cafa21 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.h @@ -84,8 +84,13 @@ class XBSStore FRIEND_TEST(bsStoreTest, getRawValue); FRIEND_TEST(bsStoreTest, setRawValue); FRIEND_TEST(bsStoreTest, initBSPropertiesFileName); - FRIEND_TEST(bsClearTest, resetCacheAndStore); - FRIEND_TEST(bsClearTest, clearRfcValues); + FRIEND_TEST(StoreClearTest, resetCacheAndStore); + FRIEND_TEST(StoreClearTest, clearRfcValues); + FRIEND_TEST(bsStoreTest, getPartnerDeviceConfig); + FRIEND_TEST(bsStoreTest, getPartnerDeviceConfig_generic); + FRIEND_TEST(bsStoreTest, getPartnerDeviceConfig_FileRemoved); + FRIEND_TEST(bsStoreTest, getRawValue_Empty); + FRIEND_TEST(StoreClearTest, setRawValue_Flush); #endif }; diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h index 508abfc25..8e6b4d51a 100755 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.h @@ -82,6 +82,8 @@ class XBSStoreJournal FRIEND_TEST(bsStoreJournalTest, getBuildTime); FRIEND_TEST(bsStoreJournalTest, resetClearRfc); FRIEND_TEST(bsStoreJournalTest, clearRfcAndGetDefaultValue); + FRIEND_TEST(bsStoreJournalTest, constructor); + FRIEND_TEST(bsStoreJournalTest, getBuildTime_Version); #endif }; diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp index 7268e9140..a63a0114e 100644 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp @@ -99,7 +99,12 @@ bool XRFCStorage::init() // get the file path IniFile file; - file.load(RFC_PROPERTIES_FILE); + if(!file.load(RFC_PROPERTIES_FILE)) + { + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF, "[%s] [%d] Failed to load file: %s\n", __FUNCTION__, __LINE__, RFC_PROPERTIES_FILE); + return false; + } + m_storageFile = file.value(TR181_RFC_STORE_KEY); if (m_storageFile.empty()) { diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h index 7456c2397..fe3707451 100644 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.h @@ -48,6 +48,7 @@ class XRFCStorage #if defined(GTEST_ENABLE) FRIEND_TEST(rfcStorageTest, init); + FRIEND_TEST(StoreClearTest, init); #endif }; diff --git a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h index 553fcb57d..dda061a4f 100644 --- a/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h +++ b/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.h @@ -25,6 +25,10 @@ #include #include +#if defined(GTEST_ENABLE) +#include +#endif + using namespace std; #if defined(GTEST_ENABLE) @@ -65,6 +69,16 @@ class XRFCStore void initTR181PropertiesFileName(); bool loadFileToCache(const string &filename, unordered_map &dict); bool loadTR181PropertiesIntoCache(); + +#if defined(GTEST_ENABLE) + FRIEND_TEST(rfcStoreTest, getRawValue); + FRIEND_TEST(rfcStoreTest, getRawValue_NONPERSISTENT_FILE); + FRIEND_TEST(rfcStoreTest, setRawValue_NONPERSISTENT_FILE); + FRIEND_TEST(rfcStoreTest, writeHashToFile); + FRIEND_TEST(rfcStoreTest, loadTR181PropertiesIntoCache); + FRIEND_TEST(rfcStoreTest, setRawValue_Invalid_FILE); + FRIEND_TEST(rfcStoreTest, loadFileToCache); +#endif }; #endif // XRDKCENTRALCOMRFCSTORE_H diff --git a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am index fea0094d1..255f9b672 100755 --- a/src/hostif/profiles/DeviceInfo/gtest/Makefile.am +++ b/src/hostif/profiles/DeviceInfo/gtest/Makefile.am @@ -21,20 +21,10 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = devieInfo_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DUSE_DEV_PROPERTIES_CONF -DPARODUS -DUNIT_TEST -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -I/usr/remote_debugger/src/ - -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DUSE_DEV_PROPERTIES_CONF -DPARODUS -DUNIT_TEST -DUSE_REMOTE_DEBUGGER -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -I/usr/remote_debugger/src/ -I/usr/include/libsoup-3.0 # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp b/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp index 956ca25a1..01e95fbb1 100644 --- a/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp +++ b/src/hostif/profiles/DeviceInfo/gtest/gtest_main.cpp @@ -72,6 +72,10 @@ char *HTTPServerName = (char *)"HTTPServerThread"; GError *httpError = NULL; T_ARGLIST argList = {{'\0'}, 0}; +#ifdef GTEST_ENABLE +extern bool (*ValidateInput_ArgumentsFunc()) (char *input, FILE *tmp_fptr); +#endif + TEST(rfcStoreTest, setValue) { m_rfcStore = XRFCStore::getInstance(); @@ -681,6 +685,23 @@ TEST(deviceTest, get_Device_DeviceInfo_SoftwareVersion) { } } +TEST(deviceTest, get_JENKINS_BUILD_NUMBER) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("trunk", "124", "/version.txt", Plain); + writeToTr181storeFile("JENKINS_BUILD_NUMBER", "5680", "/version.txt", Plain); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_SoftwareVersion(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename) { write_on_file("/tmp/currently_running_image_name", "ELTE11MWR_DEV_develop_20250808222527_NG"); HOSTIF_MsgData_t msgData; @@ -710,10 +731,29 @@ TEST(deviceTest, get_Device_DeviceInfo_Migration_MigrationStatus) { int ret = pIface->get_Device_DeviceInfo_Migration_MigrationStatus(&msgData,&bChanged); cout << "msgData.paramValue = " << msgData.paramValue << endl; EXPECT_EQ(ret, OK); - EXPECT_STREQ(msgData.paramValue, "NOT_NEEDED"); + EXPECT_STREQ(msgData.paramValue, "NEEDED"); } } +TEST(deviceTest, get_Device_DeviceInfo_Migration_MigrationStatus_Update) { + std::remove("/opt/secure/persistent/MigrationStatus"); + write_on_file("/opt/secure/persistent/MigrationStatus", "Migrated"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_Migration_MigrationStatus(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "Migrated"); + } +} + + TEST(deviceTest, get_Device_DeviceInfo_Manufacturer) { writeToTr181storeFile("MANUFACTURE", "Sky", "/etc/device.properties", Plain); HOSTIF_MsgData_t msgData; @@ -747,13 +787,14 @@ TEST(deviceTest, get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent) { memset(&msgData,0,sizeof(msgData)); bChanged = false; int ret = pIface->get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent(&msgData,&bChanged); - cout << "msgData.paramValue = " << msgData.paramValue << endl; - EXPECT_EQ(ret, OK); - //EXPECT_STREQ(msgData.paramValue, "80"); + cout << "msgData.paramValue = " << get_int(msgData.paramValue) << " msgData.faultCode=" << msgData.faultCode << endl; + EXPECT_EQ(ret, OK); + EXPECT_EQ(get_int(msgData.paramValue), 80); } } TEST(deviceTest, get_Device_DeviceInfo_ModelName) { + std::remove("/tmp/.model"); write_on_file("/tmp/.model", "Xione-UK"); HOSTIF_MsgData_t msgData; bool bChanged; @@ -785,6 +826,70 @@ TEST(deviceTest, get_Device_DeviceInfo_FirstUseDate) { } } +TEST(deviceTest, get_Device_DeviceInfo_FirstUseDate_FileRemoved) { + std::remove("/opt/persistent/firstNtpTime"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_FirstUseDate(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, set_xRDKCentralComXREContainerRFCDisable) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_COMCAST-COM_Xcalibur.Client.XRE.xreEnable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComXREContainerRFCEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComXREContainerRFCInvalidtype) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_COMCAST-COM_Xcalibur.Client.XRE.xreEnable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestName2", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComXREContainerRFCEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable) { HOSTIF_MsgData_t param; bool bChanged; @@ -809,6 +914,31 @@ TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable) { } } +TEST(deviceTest, set_xRDKCentralComXREContainerRFCEnable_FileRemoved) { + std::remove("/opt/XRE_container_enable"); + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.X_COMCAST-COM_Xcalibur.Client.XRE.xreEnable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComXREContainerRFCEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + TEST(deviceTest, set_xOpsRPCDevManageableNotification) { HOSTIF_MsgData_t param; bool bChanged; @@ -976,6 +1106,22 @@ TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType) { } } +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType_FileRemoved) { + std::remove("/opt/prefered-gateway"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable) { HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); @@ -1000,6 +1146,31 @@ TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable) { } } +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportDisable) { + write_on_file("/opt/.ipremote_status", "disabled"); + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_IPRemoteSupport.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + TEST(deviceTest, set_xOpsDeviceMgmtForwardSSHEnable) { HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); @@ -1024,6 +1195,55 @@ TEST(deviceTest, set_xOpsDeviceMgmtForwardSSHEnable) { } } +TEST(deviceTest, set_xOpsDeviceMgmtForwardSSHDisable) { + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + HOSTIF_MsgData_t msgData; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(¶m,0,sizeof(param)); + int ret = pIface->set_xOpsDeviceMgmtForwardSSHEnable(&msgData); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsDeviceMgmtForwardSSH_FileRemoved) { + std::remove("/opt/secure/.RFC_ForwardSSH"); + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + HOSTIF_MsgData_t msgData; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(¶m,0,sizeof(param)); + int ret = pIface->set_xOpsDeviceMgmtForwardSSHEnable(&msgData); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + TEST(deviceTest, validate_ParamValue) { HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); @@ -1099,6 +1319,24 @@ TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable) { } } +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportDisable) { + std::remove("/opt/.ipremote_status"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportEnable(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "false"); + } +} + TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress) { HOSTIF_MsgData_t msgData; bool bChanged; @@ -1117,12 +1355,30 @@ TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress } } +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress_Unknown) { + std::remove("/tmp/ipremote_interface_info"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportIpaddress(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "unknown"); + } +} + TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress) { HOSTIF_MsgData_t msgData; bool bChanged; int instanceNumber = 0; - writeToTr181storeFile("MAC_Address", "D4:52:EE:D8:16:4B", "/tmp/ipremote_interface_info", Plain); + writeToTr181storeFile("MAC_Address", " D4:52:EE:D8:16:4B", "/tmp/ipremote_interface_info", Plain); string partnerId; hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) @@ -1136,6 +1392,24 @@ TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddres } } +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress_Unknown) { + std::remove("/tmp/ipremote_interface_info"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_IPRemoteSupportMACaddress(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "unknown"); + } +} + TEST(deviceTest, get_xOpsReverseSshStatus) { HOSTIF_MsgData_t msgData; bool bChanged; @@ -1199,23 +1473,76 @@ TEST(deviceTest, get_xOpsDeviceMgmtForwardSSHEnable) { } } -TEST(deviceTest, set_xRDKCentralComApparmorBlocklist) { +TEST(deviceTest, get_xOpsDeviceMgmtForwardSSHEnable_Disable) { + + std::remove("/opt/secure/.RFC_ForwardSSH"); HOSTIF_MsgData_t param = { 0 }; - bool bChanged; - int instanceNumber = 0; - write_on_file("/opt/secure/Apparmor_blocklist", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonRootSupport.ApparmorBlocklist:Enabled"); - string partnerId; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); - param.reqType = HOSTIF_SET; - strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); param.bsUpdate = HOSTIF_NONE; - param.requestor = HOSTIF_SRC_RFC; - strncpy(param.paramValue, "profile1:enforce#profile2:disable#profile3:complain#invalidprofile:invalidmode", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); - param.paramtype = hostIf_StringType; - param.paramLen = strlen(param.paramValue); + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); - hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + bool bChanged; + int instanceNumber = 0; + writeToTr181storeFile("ForwardSSH", "false", "/opt/secure/.RFC_ForwardSSH", Plain); + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsDeviceMgmtForwardSSHEnable(¶m); + cout << "param.paramValue = " << getStringValue(¶m) << endl; + EXPECT_EQ(ret, OK); + EXPECT_EQ(getStringValue(¶m), "false"); + } +} + +TEST(deviceTest, get_xOpsDeviceMgmtForwardSSHEnable_FileRemoved) { + std::remove("/opt/secure/.RFC_ForwardSSH"); + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ForwardSSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsDeviceMgmtForwardSSHEnable(¶m); + cout << "param.paramValue = " << getStringValue(¶m) << endl; + EXPECT_EQ(ret, NOK); + EXPECT_EQ(getStringValue(¶m), "true"); + } +} + +TEST(deviceTest, set_xRDKCentralComApparmorBlocklist) { + HOSTIF_MsgData_t param = { 0 }; + bool bChanged; + int instanceNumber = 0; + write_on_file("/opt/secure/Apparmor_blocklist", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonRootSupport.ApparmorBlocklist:Enabled"); + string partnerId; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "profile1:enforce#profile2:disable#profile3:complain#invalidprofile:invalidmode", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { bChanged = false; @@ -1235,7 +1562,53 @@ TEST(deviceTest, NewNtpEnable) { msgData.bsUpdate = HOSTIF_NONE; msgData.requestor = HOSTIF_SRC_WEBPA; - strncpy(msgData.paramValue, "true", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + put_boolean(msgData.paramValue, true); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = strlen(msgData.paramValue); + + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComNewNtpEnable(&msgData); + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, NewNtpEnable_Disable) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.newNTP.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_WEBPA; + + put_boolean(msgData.paramValue, false); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = strlen(msgData.paramValue); + + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComNewNtpEnable(&msgData); + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, NewNtpEnable_Disable_FileRemoved) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.newNTP.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_WEBPA; + + put_boolean(msgData.paramValue, false); msgData.paramtype = hostIf_BooleanType; msgData.paramLen = strlen(msgData.paramValue); @@ -1267,12 +1640,48 @@ TEST(deviceTest, get_xOpsDMLogsUploadStatus) { } } +TEST(deviceTest, get_xOpsDMLogsUploadStatus_FileRemoved) { + std::remove("/opt/loguploadstatus.txt"); + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsDMLogsUploadStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsDMLogsUploadStatus_EmptyFile) { + const char* filePath = "/opt/loguploadstatus.txt"; + std::ofstream file(filePath); + file.close(); + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_xOpsDMLogsUploadStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + TEST(deviceTest, get_Device_DeviceInfo_IUI_Version) { + std::remove("/tmp/.iuiVersion"); HOSTIF_MsgData_t msgData; memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); bool bChanged; int instanceNumber = 0; - write_on_file("/tmp/.iuiVersion", "2.2"); + write_on_file("/tmp/.iuiVersion", "2.2\n"); hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { @@ -1284,6 +1693,31 @@ TEST(deviceTest, get_Device_DeviceInfo_IUI_Version) { } } +TEST(deviceTest, set_Device_DeviceInfoEmpty_IUI_Version) { + bool bChanged; + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM.IUI.Version", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy (msgData.paramValue, "", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_Device_DeviceInfo_IUI_Version(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + TEST(deviceTest, set_Device_DeviceInfo_IUI_Version) { bool bChanged; int instanceNumber = 0; @@ -1310,6 +1744,39 @@ TEST(deviceTest, set_Device_DeviceInfo_IUI_Version) { } } +TEST(deviceTest, get_Device_DeviceInfo_IUI_Version_FileRemoved) { + std::remove("/tmp/.iuiVersion"); + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_IUI_Version(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_IUI_Version_EmptyFile) { + std::ofstream file("/tmp/.iuiVersion"); + file.close(); + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_IUI_Version(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOT_HANDLED); + } +} + TEST(deviceTest, set_xOpsDMUploadLogsNow) { bool bChanged; int instanceNumber = 0; @@ -1335,6 +1802,32 @@ TEST(deviceTest, set_xOpsDMUploadLogsNow) { } } +TEST(deviceTest, set_xOpsDMUploadLogsNow_Disable) { + bool bChanged; + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.Logging.xOpsDMUploadLogsNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + put_boolean(msgData.paramValue, false); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xOpsDMUploadLogsNow(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + TEST(deviceInfoTest, get_Device_DeviceInfo_MigrationPreparer_MigrationReady) { bool bChanged; int instanceNumber = 0; @@ -1398,6 +1891,9 @@ TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Canary_wakeUpEnd) { } } TEST(deviceTest, readFirmwareInfo) { + + int ret = system("cp ../../../../unittest/stubs/fwdnldstatus.txt /opt/fwdnldstatus.txt"); + EXPECT_EQ(ret, 0); int instanceNumber = 0; HOSTIF_MsgData_t msgData; @@ -1415,7 +1911,6 @@ TEST(deviceTest, readFirmwareInfo) { TEST(deviceInfoTest, writeFirmwareInfo) { int instanceNumber = 0; - char param [] = "CurrentFile"; HOSTIF_MsgData_t msgData; memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); @@ -1434,7 +1929,7 @@ TEST(deviceInfoTest, writeFirmwareInfo) { } TEST(deviceInfoTest, get_X_RDK_FirmwareName) { - write_on_file("/version.txt", "imagename:ELTE11MWR_VBN_25Q3_sprint_20250814010729sdy_NG"); + write_on_file("/version.txt", "imagename:ELTE11MWR_VBN_25Q3_sprint_2025 0814010729sdy_NG"); int instanceNumber = 0; HOSTIF_MsgData_t msgData; @@ -1461,6 +1956,7 @@ TEST(deviceInfoTest, get_X_RDKCENTRAL_COM_LastRebootReason) { int ret = pIface->get_X_RDKCENTRAL_COM_LastRebootReason(&msgData); cout << "msgData.paramValue = " << msgData.paramValue << endl; EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "PowerOnReset"); } } @@ -1623,6 +2119,27 @@ TEST(rfcStoreTest, set_xRDKDownloadManager_DownloadStatus) { } } +TEST(deviceTest, set_xRDKDownloadManager_DownloadStatus_InvalidParameterType) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET;strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "true", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKDownloadManager_DownloadStatus(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + TEST(rfcStoreTest, set_xRDKDownloadManager_InstallPackage) { int instanceNumber = 0; HOSTIF_MsgData_t param = { 0 }; @@ -1644,6 +2161,27 @@ TEST(rfcStoreTest, set_xRDKDownloadManager_InstallPackage) { } } +TEST(rfcStoreTest, set_xRDKDownloadManager_InvalidParamValue) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET;strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKDownloadManager_InstallPackage(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, -1); + } +} + TEST(deviceTest, get_xOpsRPCRebootPendingNotification) { int instanceNumber = 0; HOSTIF_MsgData_t param = { 0 }; @@ -1715,36 +2253,38 @@ TEST(deviceTest, set_xRDKCentralComRFCAutoRebootEnable) { } } -TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig) { +TEST(deviceTest, set_xRDKCentralComRFCAutoRebootEnable_Invalidtype) { + bool bChanged; int instanceNumber = 0; HOSTIF_MsgData_t msgData; memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); msgData.reqType = HOSTIF_SET; - strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadUseCodebig", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AutoReboot.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); msgData.bsUpdate = HOSTIF_NONE; msgData.requestor = HOSTIF_SRC_RFC; - put_boolean(msgData.paramValue, true); - msgData.paramtype = hostIf_BooleanType; - msgData.paramLen = sizeof(hostIf_BooleanType); + strncpy(msgData.paramValue, "TestName2", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { - int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig(&msgData); + bChanged = false; + int ret = pIface->set_xRDKCentralComRFCAutoRebootEnable(&msgData); cout << "msgData.paramValue = " << msgData.paramValue << endl; - EXPECT_EQ(ret, OK); + EXPECT_EQ(ret, NOK); } } -TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot) { +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig) { int instanceNumber = 0; HOSTIF_MsgData_t msgData; memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); msgData.reqType = HOSTIF_SET; - strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadDeferReboot", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadUseCodebig", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); msgData.bsUpdate = HOSTIF_NONE; msgData.requestor = HOSTIF_SRC_RFC; @@ -1755,7 +2295,30 @@ TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDefe hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { - int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(&msgData); + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadUseCodebig(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadDeferReboot", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + put_boolean(msgData.paramValue, true); + msgData.paramtype = hostIf_BooleanType; + msgData.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadDeferReboot(&msgData); cout << "msgData.paramValue = " << msgData.paramValue << endl; EXPECT_EQ(ret, OK); } @@ -1801,7 +2364,7 @@ TEST(deviceTest, set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol) { hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { - int ret = pIface->set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadURL(&msgData); + int ret = pIface->set_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadProtocol(&msgData); cout << "msgData.paramValue = " << msgData.paramValue << endl; EXPECT_EQ(ret, OK); } @@ -1830,6 +2393,52 @@ TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerI } } +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId_Unknown) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy(msgData.paramValue, "unknown", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId_Empty) { + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + strncpy(msgData.paramValue, "", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Syndication_PartnerId(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType) { int instanceNumber = 0; @@ -1849,6 +2458,65 @@ TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType } } +TEST(deviceInfoTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType_FileRemoved) { + std::remove("/opt/prefered-gateway"); + int instanceNumber = 0; + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "X_RDKCENTRAL-COM_RDKVersion.X_RDKCENTRAL-COM_PreferredGatewayType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType_FileRemoved) { + int instanceNumber = 0; + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "X_RDKCENTRAL-COM_RDKVersion.X_RDKCENTRAL-COM_PreferredGatewayType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceInfoTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType_EmptyFile) { + std::ofstream file("/opt/prefered-gateway"); + file.close(); + + int instanceNumber = 0; + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "X_RDKCENTRAL-COM_RDKVersion.X_RDKCENTRAL-COM_PreferredGatewayType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_PreferredGatewayType(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + TEST(deviceInfoTest, get_Device_DeviceInfo_HardwareVersion) { int instanceNumber = 0; @@ -1950,7 +2618,30 @@ TEST(deviceTest, get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus) { } } -TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset) { +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset_Warehouse_Cold) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Cold", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset_Warehouse) { int instanceNumber = 0; HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); @@ -1972,6 +2663,93 @@ TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset) { } } +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset_Factory) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Factory", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset_Customer) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Customer", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset_InvalidInput) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "User", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOT_HANDLED); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset_NULL) { + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + param.paramValue[0] = '\0'; + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} TEST(deviceTest, get_xOpsReverseSshArgs) @@ -2017,59 +2795,1539 @@ TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable) } } -TEST(deviceTest, set_xRDKCentralComDABRFCEnable) +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable_Invalidtype) { int instanceNumber = 0; HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); param.reqType = HOSTIF_GET; - strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DAB.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); param.bsUpdate = HOSTIF_NONE; param.requestor = HOSTIF_SRC_RFC; - put_boolean(param.paramValue, true); - param.paramtype = hostIf_BooleanType; - param.paramLen = sizeof(hostIf_BooleanType); + strncpy(param.paramValue, "TestName2", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { - int ret = pIface->set_xRDKCentralComDABRFCEnable(¶m); + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_RebootStopEnable(¶m); cout << "msgData.paramValue = " << param.paramValue << endl; - EXPECT_EQ(ret, OK); + EXPECT_EQ(ret, NOK); + EXPECT_EQ(param.faultCode, fcInvalidParameterType); } } - -TEST(deviceTest, set_xOpsDeviceMgmtRPCRebootNow) +TEST(deviceTest, set_xRDKCentralComDABRFCDisable) { int instanceNumber = 0; HOSTIF_MsgData_t param = { 0 }; memset(¶m,0,sizeof(HOSTIF_MsgData_t)); param.reqType = HOSTIF_GET; - strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DAB.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); param.bsUpdate = HOSTIF_NONE; param.requestor = HOSTIF_SRC_RFC; - put_boolean(param.paramValue, true); + put_boolean(param.paramValue, false); param.paramtype = hostIf_BooleanType; param.paramLen = sizeof(hostIf_BooleanType); hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); if(pIface) { - int ret = pIface->set_xOpsDeviceMgmtRPCRebootNow(¶m); + int ret = pIface->set_xRDKCentralComDABRFCEnable(¶m); cout << "msgData.paramValue = " << param.paramValue << endl; EXPECT_EQ(ret, OK); } } +TEST(deviceTest, set_xRDKCentralComDABRFCInvalidtype) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DAB.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestName2", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); -TEST(bsStoreTest, initBSPropertiesFileName) { - m_bsStore = XBSStore::getInstance(); - m_bsStore->initBSPropertiesFileName(); - m_bsStore->m_filename.erase(std::remove(m_bsStore->m_filename.begin(), m_bsStore->m_filename.end(), '"'), m_bsStore->m_filename.end()); - EXPECT_EQ(m_bsStore->m_filename, "/opt/secure/RFC/bootstrap.ini"); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComDABRFCEnable(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + EXPECT_EQ(param.faultCode, fcInvalidParameterType); + } +} + + +TEST(deviceTest, set_xRDKCentralComDABRFCEnable) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DAB.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComDABRFCEnable(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xOpsDeviceMgmtRPCRebootNow) +{ + int instanceNumber = 0; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsDeviceMgmtRPCRebootNow(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_ManufacturerOUI) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.ManufacturerOUI", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_ManufacturerOUI(¶m, &pChanged); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOT_HANDLED); + } + pIface->closeInstance(pIface); + pIface->closeAllInstances(); +} + +TEST(deviceTest, get_Device_DeviceInfo_SerialNumber) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.SerialNumber", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_SerialNumber(¶m, &pChanged); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_AdditionalSoftwareVersion) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.AdditionalSoftwareVersion", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_AdditionalSoftwareVersion(¶m, &pChanged); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_BootStatus) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM.BootStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_BootStatus(¶m, &pChanged); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsDMMoCALogEnabled) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.xOpsDMUploadLogsNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsDMMoCALogEnabled(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsDMMoCALogEnabled) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.xOpsDMUploadLogsNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsDMMoCALogEnabled(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_XRPolling.Action", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + + strncpy(param.paramValue, "XRPoll", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_XRPollingAction(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsReverseSshTrigger) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.ReverseSSH.xOpsReverseSshTrigger", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + + strncpy(param.paramValue, "start shorts", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsReverseSshTrigger(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ClearDB", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_ClearDB_False) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ClearDB", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + + +TEST(deviceTest, set_xRDKCentralComRFC_ClearDBEnd) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ClearDBEnd", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_ClearDBEnd_False) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ClearDBEnd", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, false); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_RoamTrigger) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RoamTrigger", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestTriggerUpdate", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xRDKCentralComRFC_ISSUETYPE) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xRDKCentralComRFC_WebCfgData) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestType", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_CANARY_START_TIME) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpStart", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "300", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_IntegerType; + param.paramLen = sizeof(hostIf_IntegerType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xRDKCentralComRFC_CANARY_END_TIME) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Canary.wakeUpEnd", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "480", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_IntegerType; + param.paramLen = sizeof(hostIf_IntegerType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xRDKCentralComRFC_RebootStopEnable) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_RebootStopEnable_newNTP) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.newNTP.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_RebootStopEnable_AUTOREBOOT) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AutoReboot.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFC_RebootStopEnable_XRE_CONTAINER_RFC_ENABLE) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.LXC.XRE.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFC(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, RDKRemoteDebuggergetProfileData) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.getProfileData", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, RDKRemoteDebuggergetProfileData_FileRemoved) +{ + std::remove("/etc/rrd/remote_debugger.json"); + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.getProfileData", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, RDKRemoteDebuggergetProfileData_EmptyFile) +{ + std::ofstream file("/etc/rrd/remote_debugger.json"); + file.close(); + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.getProfileData", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, set_xRDKCentralComRFCRoamTrigger) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RoamTrigger", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestTrigger", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xRDKCentralComRFCRoamTrigger(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xFirmwareDownloadNow) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_FirmwareDownloadNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xFirmwareDownloadNow(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, get_xOpsRPCDevManageableNotification) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.DeviceManageableNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPCDevManageableNotification(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPC_Profile_RebootNow) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPC_Profile_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.DeviceManageableNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, set_xOpsRPC_Profile_STARTED_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.FirmwareDownloadStartedNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + strncpy(param.paramValue, "Started", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPC_Profile_COMPLETED_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.FirmwareDownloadCompletedNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Completed", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPC_Profile_PENDING_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootPendingNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "Pending", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsRPC_Profile_InvalidParameterName) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->set_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_EQ(param.faultCode, fcInvalidParameterName); + } +} + +TEST(deviceTest, send_DeviceManageableNotification) +{ + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + pIface->send_DeviceManageableNotification(); + EXPECT_EQ(0, 0); + } +} + +TEST(deviceTest, get_X_RDKCENTRAL_COM_experience) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_COMCAST-COM_EXPERIENCE", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_X_RDKCENTRAL_COM_experience(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceInfoTest, get_X_RDK_FirmwareName_FileRemoved) { + std::remove("/version.txt"); + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_X_RDK_FirmwareName(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceInfoTest, get_X_RDKCENTRAL_COM_LastRebootReason_FileRemoved) { + std::remove("/opt/secure/reboot/previousreboot.info"); + int instanceNumber = 0; + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_X_RDKCENTRAL_COM_LastRebootReason(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceInfoTest, writeFirmwareInfo_FileRemoved) { + std::remove("/opt/fwdnldstatus.txt"); + int instanceNumber = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + + strncpy(msgData.paramValue, "SKXI11ADS_MIDDLEWARE_DEV_develop_20250527063924", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->writeFirmwareInfo((char *)"CurrentFile", &msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, get_PartnerId_From_Script_File) { + write_on_file("/opt/www/authService/partnerId3.dat", "sky"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_PartnerId_From_Script(partnerId); + cout << "partnerId = " << partnerId << endl; + EXPECT_EQ(ret, OK); + EXPECT_EQ(partnerId, "sky"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename_Version_TXT_File) { + std::ofstream file("/tmp/currently_running_image_name"); + file.close(); + write_on_file("/version.txt", "imagename:XUSHTC11MWR_8.2s14_PROD"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "XUSHTC11MWR_8.2s14_PROD"); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload_Version_TXT) { + std::ofstream file("/version.txt"); + file.close(); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareToDownload(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus_Version_TXT) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareDownloadStatus(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent_FileRemoved) { + std::remove("/opt/curl_progress"); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_COMCAST_COM_FirmwareDownloadPercent(&msgData,&bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, get_ApparmorBlockListStatus_FileRemoved) { + std::remove("/opt/secure/Apparmor_blocklist"); + HOSTIF_MsgData_t msgData = { 0 }; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bChanged = false; + int ret = pIface->get_ApparmorBlockListStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, -1); + EXPECT_STREQ(msgData.paramValue, "Apparmorblocklist is empty"); + } +} + +TEST(deviceTest, ValidateInput_Arguments) { + FILE *tmp_fptr = NULL; + bool ret = ValidateInput_ArgumentsFunc()(NULL, tmp_fptr); + EXPECT_EQ(ret, false); +} + +TEST(deviceTest, readFirmwareInfo_EmptyFile) { + std::remove("/opt/fwdnldstatus.txt"); + std::ofstream file("/opt/fwdnldstatus.txt"); + file.close(); + + HOSTIF_MsgData_t msgData = { 0 }; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bChanged = false; + int ret = pIface->readFirmwareInfo((char *)"DnldFile", &msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, readFirmwareInfo_WithoutPipe) { + write_on_file("/opt/fwdnldstatus.txt", "Proto:http"); + + HOSTIF_MsgData_t msgData = { 0 }; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + bChanged = false; + int ret = pIface->readFirmwareInfo((char *)"Proto", &msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceInfoTest, get_X_RDKCENTRAL_COM_LastRebootReason_FileEmpty) { + std::ofstream file("/opt/secure/reboot/previousreboot.info"); + file.close(); + int instanceNumber = 0; + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_X_RDKCENTRAL_COM_LastRebootReason(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceInfoTest, GetLock_ShouldAcquireMutex) { + int instanceNumber = 0; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + pIface->getLock(); + pIface->releaseLock(); + EXPECT_EQ(0, 0); + } +} + +TEST(deviceTest, get_xOpsRPC_Profile_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.DeviceManageableNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsRPC_Profile_STARTED_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.FirmwareDownloadStartedNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, get_xOpsRPC_Profile_COMPLETED_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.FirmwareDownloadCompletedNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + + +TEST(deviceTest, get_xOpsRPC_Profile_PENDING_NOTIFICATION) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.RPC.RebootPendingNotification", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsRPC_Profile_InvalidParameterName) +{ + int instanceNumber = 0; + bool pChanged; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + int ret = pIface->get_xOpsRPC_Profile(¶m); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + EXPECT_EQ(param.faultCode, fcInvalidParameterName); + } +} + +TEST(deviceTest, set_xRDKCentralComRFCLoudnessEquivalenceEnable_InvalidType) { + HOSTIF_MsgData_t param; + bool bChanged; + int instanceNumber = 0; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.LoudnessEquivalence.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + strncpy(param.paramValue, "TestEquivalence", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + bChanged = false; + int ret = pIface->set_xRDKCentralComRFCLoudnessEquivalenceEnable(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(ret, NOK); + EXPECT_EQ(param.faultCode, fcInvalidParameterType); + } +} + +TEST(deviceTest, get_xOpsReverseSshStatus_Active) { + std::ofstream pidFile("/var/tmp/rssh.pid"); + pidFile << getpid(); // use current process PID which is definitely valid + pidFile.close(); + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + string partnerId; + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_xOpsReverseSshStatus(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "ACTIVE"); + } +} + +TEST(deviceTest, get_xRDKCentralComRFC) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.Time.NTPServer5", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_xRDKCentralComRFC(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(0, 0); + } +} + +TEST(deviceTest, set_X_RDKCENTRAL_COM_LastRebootReason) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_SET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_LastRebootReason", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->set_X_RDKCENTRAL_COM_LastRebootReason(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xOpsDMMoCALogPeriod) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.xOpsDMLogsUploadStatus", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_xOpsDMMoCALogPeriod(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, AdditionalHardwareVersion) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.HardwareVersion", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_AdditionalHardwareVersion(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, COM_Reset) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_X_RDKCENTRAL_COM_Reset(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, VendorConfigFileNumberOfEntries) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_Reset", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_VendorConfigFileNumberOfEntries(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, SupportedDataModelNumber) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.SupportedDataModelNumberOfEntries", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_SupportedDataModelNumberOfEntries(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, VendorLogFileNumberOfEntries) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.VendorLogFileNumberOfEntries", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_Device_DeviceInfo_VendorLogFileNumberOfEntries(&msgData, &bChanged); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(deviceTest, xOpsDMUploadLogsNow) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.xOpsDMUploadLogsNow", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_xOpsDMUploadLogsNow(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, set_xOpsDMMoCALogPeriod) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.xOpsDMMoCALogPeriod", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->set_xOpsDMMoCALogPeriod(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, OK); + } +} + +TEST(deviceTest, get_xRDKCentralComRFCAccountId) { + HOSTIF_MsgData_t msgData; + bool bChanged; + int instanceNumber = 0; + msgData.reqType = HOSTIF_GET; + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.bsUpdate = HOSTIF_NONE; + msgData.requestor = HOSTIF_SRC_RFC; + + hostIf_DeviceInfo *pIface = hostIf_DeviceInfo::getInstance(instanceNumber); + if(pIface) + { + memset(&msgData,0,sizeof(msgData)); + bChanged = false; + int ret = pIface->get_xRDKCentralComRFCAccountId(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + EXPECT_EQ(ret, NOK); + } +} + +TEST(bsStoreTest, initBSPropertiesFileName) { + m_bsStore = XBSStore::getInstance(); + m_bsStore->initBSPropertiesFileName(); + m_bsStore->m_filename.erase(std::remove(m_bsStore->m_filename.begin(), m_bsStore->m_filename.end(), '"'), m_bsStore->m_filename.end()); + EXPECT_EQ(m_bsStore->m_filename, "/opt/secure/RFC/bootstrap.ini"); } TEST(bsStoreTest, getRawValue) { @@ -2079,6 +4337,66 @@ TEST(bsStoreTest, getRawValue) { EXPECT_EQ(value, "time1.com"); } +TEST(bsStoreTest, getRawValue_Empty) { + m_bsStore = XBSStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"; + string value = m_bsStore->getRawValue(key); + EXPECT_EQ(value, ""); +} + +TEST(bsStoreTest, getValue) { + m_bsStore = XBSStore::getInstance(); + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.getProfileData", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + int ret = m_bsStore->getValue(¶m); //Get value before partnerId + + std::cout << "paramValue: " << getStringValue(¶m) << " ret = " << ret << std::endl; + EXPECT_EQ(ret, fcInternalError); +} + +TEST(bsStoreTest, setValue_BS_CLEAR_DB_START) { + m_bsStore = XBSStore::getInstance(); + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.Control.ClearDB", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + int ret = m_bsStore->overrideValue(¶m); + + std::cout << "ret = " << ret << std::endl; + EXPECT_EQ(ret, 0); +} + +TEST(bsStoreTest, setValue_BS_CLEAR_DB_END) { + m_bsStore = XBSStore::getInstance(); + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.Control.ClearDBEnd", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + int ret = m_bsStore->overrideValue(¶m); + + std::cout << "ret = " << ret << std::endl; + EXPECT_EQ(ret, 0); +} + TEST(bsStoreTest, createFile) { createFile("/tmp/bootstrap.txt"); EXPECT_EQ(0, 0); @@ -2089,11 +4407,53 @@ TEST(bsStoreTest, createDirectory) { EXPECT_EQ(ret, true); } +TEST(bsStoreTest, createDirectory_Error) { + bool ret = createDirectory("/opt/test/RFC"); + EXPECT_EQ(ret, false); +} + TEST(bsStoreTest, createBspCompleteFiles) { bool ret = createBspCompleteFiles(); EXPECT_EQ(ret, true); } +TEST(bsStoreTest, getPartnerDeviceConfig) { + m_bsStore = XBSStore::getInstance(); + const string partnerId = "comcast"; + + cJSON* partnerConfig = cJSON_CreateObject(); + cJSON_AddStringToObject(partnerConfig, "firmwareVersion", "v1.2.3"); + + bool ret = m_bsStore->getPartnerDeviceConfig(partnerConfig, partnerId); + EXPECT_EQ(ret, true); + cJSON_Delete(partnerConfig); +} + +TEST(bsStoreTest, getPartnerDeviceConfig_generic) { + m_bsStore = XBSStore::getInstance(); + const string partnerId = "default"; + + cJSON* partnerConfig = cJSON_CreateObject(); + cJSON_AddStringToObject(partnerConfig, "Device.Time.NTPServer1", "time.com"); + + bool ret = m_bsStore->getPartnerDeviceConfig(partnerConfig, partnerId); + EXPECT_EQ(ret, true); + cJSON_Delete(partnerConfig); +} + +TEST(bsStoreTest, getPartnerDeviceConfig_FileRemoved) { + std::remove("/etc/partners_defaults_device.json"); + m_bsStore = XBSStore::getInstance(); + const string partnerId = "comcast"; + + cJSON* partnerConfig = cJSON_CreateObject(); + cJSON_AddStringToObject(partnerConfig, "firmwareVersion", "v1.2.3"); + + bool ret = m_bsStore->getPartnerDeviceConfig(partnerConfig, partnerId); + EXPECT_EQ(ret, true); + cJSON_Delete(partnerConfig); +} + TEST(bsStoreJournalTest, getBuildTime) { m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); writeToTr181storeFile("BUILD_TIME", "2025-05-27 06:39:24", "/version.txt", Quoted); @@ -2155,6 +4515,53 @@ TEST(bsStoreJournalTest, clearRfcAndGetDefaultValue) { EXPECT_EQ(defaultValue, "time.com"); } +TEST(bsStoreJournalTest, rfcUpdateStarted) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.Time.NTPServer4"; + + bool result = m_bsStoreJournal->rfcUpdateStarted(); + EXPECT_EQ(result, true); +} + +TEST(bsStoreJournalTest, rfcUpdateEnd) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.Time.NTPServer4"; + + bool result = m_bsStoreJournal->rfcUpdateEnd(); + EXPECT_EQ(result, true); +} + +TEST(bsStoreJournalTest, constructor) { + XBSStoreJournal* journalPtr = new XBSStoreJournal(); + EXPECT_EQ(0, 0); +} + +TEST(bsStoreJournalTest, setJournalValue_New_Key) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MOCASSH.Enable"; + const string value = "false"; + + bool result = m_bsStoreJournal->setJournalValue(key, value, HOSTIF_SRC_RFC); + EXPECT_EQ(result, true); +} + +TEST(bsStoreJournalTest, setJournalValue_HOSTIF_SRC_DEFAULT) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable"; + const string value = "true"; + + bool result = m_bsStoreJournal->setJournalValue(key, value, HOSTIF_SRC_DEFAULT); + EXPECT_EQ(result, true); +} + +/* TEST(bsStoreJournalTest, resetCacheAndStore) { + m_bsStoreJournal = XBSStoreJournal::getInstance("/opt/secure/RFC/bootstrap.journal"); + const string key = "Device.Time.NTPServer4"; + + m_bsStoreJournal->resetCacheAndStore(); + EXPECT_EQ(0, 0); +} */ + TEST(rfcStoreTest, init_rfcdefaults) { m_rfcStore = XRFCStore::getInstance(); @@ -2163,17 +4570,98 @@ TEST(rfcStoreTest, init_rfcdefaults) { } TEST(rfcStoreTest, reloadCache) { + writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonPersistent.WebPACDL.Enable", "true", "/opt/secure/RFC/tr181store_nonpersist.ini", Plain); m_rfcStore = XRFCStore::getInstance(); - m_rfcStore->reloadCache(); EXPECT_EQ(0, 0); } +TEST(rfcStoreTest, loadTR181PropertiesIntoCache) { + std::remove("/tmp/rfcdefaults.ini"); + m_rfcStore = XRFCStore::getInstance(); + + bool ret = m_rfcStore->loadTR181PropertiesIntoCache(); + EXPECT_EQ(ret, true); +} + +TEST(rfcStoreTest, getRawValue) { + m_rfcStore = XRFCStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonPersistent.Enable"; + string value = m_rfcStore->getRawValue(key); + EXPECT_EQ(value, ""); +} + +TEST(rfcStoreTest, getRawValue_NONPERSISTENT_FILE) { + write_on_file("/tmp/.rfcSyncDone", "PREFIX)"); + m_rfcStore = XRFCStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonPersistent.WebPACDL.Enable"; + string value = m_rfcStore->getRawValue(key); + EXPECT_EQ(value, "true"); +} + +TEST(rfcStoreTest, setRawValue_Invalid_FILE) { + m_rfcStore = XRFCStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MTLS.mTlsCrashdumpUpload.Enable"; + const string value = "true"; + m_rfcStore->m_updateInProgress = true; + m_rfcStore->m_filename = "/opt/secure/RFC/bootrap.ini"; + bool ret = m_rfcStore->setRawValue(key, value); + EXPECT_EQ(ret, true); +} + +TEST(rfcStoreTest, writeHashToFile) { + m_rfcStore = XRFCStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MTLS.mTlsCrashdumpUpload.Enable"; + const string value = "true"; + unordered_map dict; + bool ret = m_rfcStore->writeHashToFile(key, value, dict, "/opt/secure/RFC1/boottrap.ini"); + EXPECT_EQ(ret, false); +} + +TEST(rfcStoreTest, setValue_RFC_PREFIX) { + m_rfcStore = XRFCStore::getInstance(); + + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.NonPersistent.WebPACDL.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + faultCode_t ret = m_rfcStore->setValue(¶m); + + EXPECT_EQ(ret, fcNoFault); +} + +TEST(rfcStoreTest, loadFileToCache) { + std::ofstream file("/opt/secure/RFC/tr181temp.ini"); + file.close(); + m_rfcStore = XRFCStore::getInstance(); + unordered_map dict; + bool ret = m_rfcStore->loadFileToCache("/opt/secure/RFC/tr181temp.ini", dict); + + EXPECT_EQ(ret, true); +} + +TEST(rfcStoreTest, getValue_rfcdefaults) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(msgData)); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + int ret = m_rfcStore->getValue(&msgData); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "true"); +} + TEST(rfcStorageTest, init) { + int ret = system("cp ../../../../unittest/stubs/rfc.properties /etc/rfc.properties"); + EXPECT_EQ(ret, 0); m_rfcStoreage = new XRFCStorage(); bool result = m_rfcStoreage->init(); - EXPECT_EQ(result, true); + EXPECT_EQ(result, true); } TEST(rfcStorageTest, getValue) { @@ -2185,6 +4673,15 @@ TEST(rfcStorageTest, getValue) { EXPECT_STREQ(msgData.paramValue, "true"); } +/* TEST(rfcStorageTest, getValue_rfcdefaults) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(msgData)); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + int ret = m_rfcStoreage->getValue(&msgData); + EXPECT_EQ(ret, OK); + EXPECT_STREQ(msgData.paramValue, "true"); +} */ + TEST(rfcStorageTest, getRawValue) { const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable"; @@ -2207,6 +4704,20 @@ TEST(rfcStorageTest, setValue) { EXPECT_EQ(ret, OK); } +TEST(rfcStorageTest, setSameValue) { + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(msgData)); + strncpy (msgData.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + + strncpy(msgData.paramValue, "comcast", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + msgData.paramtype = hostIf_StringType; + msgData.paramLen = strlen(msgData.paramValue); + + int ret = m_rfcStoreage->setValue(&msgData); + cout << "msgData.paramValue = " << msgData.paramValue << endl; + + EXPECT_EQ(ret, OK); +} TEST(rfcStorageTest, setRawValue) { @@ -2214,7 +4725,6 @@ TEST(rfcStorageTest, setRawValue) { const string value = "TestOsClass"; bool ret = m_rfcStoreage->setRawValue(key, value); - EXPECT_EQ(ret, true); } @@ -2244,6 +4754,21 @@ TEST(processTest, get_Device_DeviceInfo_Processor_Architecture) { } } +TEST(processTest, Processor_Lock_ReleaseLock) { + int instanceNumber = 0; + + hostIf_DeviceProcessorInterface *processorIface = hostIf_DeviceProcessorInterface::getInstance(instanceNumber); + if(processorIface) + { + processorIface->getLock(); + processorIface->releaseLock(); + EXPECT_EQ(0, 0); + } + processorIface->closeInstance(processorIface); + processorIface->closeAllInstances(); + +} + TEST(processTest, getProcessStatusCPUUsage) { int instanceNumber = 0; @@ -2273,6 +4798,48 @@ TEST(processTest, get_Device_DeviceInfo_ProcessStatus_CPUUsage) { } } +TEST(processTest, getProcessStatParam) { + int instanceNumber = 0; + bool pChanged; + + long long unsigned int mUser = 0; + long long unsigned int mNice = 0; + long long unsigned int mSystem = 0; + long long unsigned int mIdle = 0; + long long unsigned int mIOwait = 0; + long long unsigned int mIrq = 0; + long long unsigned int mSoftirq = 0; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceProcessStatusInterface *processStatusIface = hostIf_DeviceProcessStatusInterface::getInstance(instanceNumber); + if(processStatusIface) + { + pChanged = false; + int ret = processStatusIface->getProcessStatParam(&mUser, &mNice, &mSystem, &mIdle, &mIOwait, &mIrq, &mSoftirq); + EXPECT_EQ(ret, OK); + } +} + +TEST(processTest, ProcessStatus_Lock_ReleaseLock) { + int instanceNumber = 0; + bool pChanged; + + HOSTIF_MsgData_t msgData; + memset(&msgData,0,sizeof(HOSTIF_MsgData_t)); + hostIf_DeviceProcessStatusInterface *processStatusIface = hostIf_DeviceProcessStatusInterface::getInstance(instanceNumber); + if(processStatusIface) + { + pChanged = false; + processStatusIface->getLock(); + processStatusIface->releaseLock(); + EXPECT_EQ(0, 0); + } + processStatusIface->closeInstance(processStatusIface); + processStatusIface->closeAllInstances(); +} + + TEST(clearTest, rfcclearAll) { m_rfcStore = XRFCStore::getInstance(); @@ -2283,20 +4850,47 @@ TEST(clearTest, rfcclearAll) { TEST(clearTest, rfcStorageclearAll) { m_rfcStoreage->clearAll(); EXPECT_EQ(0, 0); - - delete m_rfcStoreage; } -/*TEST(bsClearTest, clearRfcValues) { +TEST(StoreClearTest, clearRfcValues) { m_bsStore = XBSStore::getInstance(); bool ret = m_bsStore->clearRfcValues(); EXPECT_EQ(ret, true); } -TEST(bsClearTest, resetCacheAndStore) { +TEST(StoreClearTest, resetCacheAndStore) { m_bsStore = XBSStore::getInstance(); m_bsStore->resetCacheAndStore(); EXPECT_EQ(0, 0); +} + +/* TEST(StoreClearTest, init) { + std::remove("/opt/secure/RFC/tr181store.ini"); + std::ofstream file("/opt/secure/RFC/tr181store.ini"); + file.close(); + + bool ret = m_rfcStoreage->init(); + EXPECT_EQ(ret, false); +} + +TEST(StoreClearTest, getRawValue) { + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.Enable"; + string value = m_rfcStoreage->getRawValue(key); + EXPECT_EQ(value, ""); +} + +TEST(StoreClearTest, setRawValue_Flush) { + m_bsStore = XBSStore::getInstance(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName"; + const string value = "sky"; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_SET; + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + m_bsStore->m_initialUpdate = true; + bool ret = m_bsStore->setRawValue(key, value,param.requestor); + EXPECT_EQ(ret, true); } */ GTEST_API_ int main(int argc, char *argv[]){ diff --git a/src/hostif/profiles/Ethernet/gtest/Makefile.am b/src/hostif/profiles/Ethernet/gtest/Makefile.am index b78f62cfb..1f03470da 100644 --- a/src/hostif/profiles/Ethernet/gtest/Makefile.am +++ b/src/hostif/profiles/Ethernet/gtest/Makefile.am @@ -21,20 +21,10 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = ethernet_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) - -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/profiles/Ethernet -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) -I/usr/include/libsoup-3.0 # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp b/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp index 3ab90fcd5..28a6bcb8e 100644 --- a/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp +++ b/src/hostif/profiles/Ethernet/gtest/gtest_ethernet.cpp @@ -178,6 +178,19 @@ TEST(EthernetTest, set_Device_Ethernet_Interface_Enable) { } } +TEST(EthernetTest, InterfaceLock_ReleaseLock) { + int instanceNumber = 0; + hostIf_EthernetInterface *ethernetIf= hostIf_EthernetInterface::getInstance(instanceNumber); + if(ethernetIf) + { + ethernetIf->getLock(); + ethernetIf->releaseLock(); + EXPECT_EQ(0, 0); + } + ethernetIf->closeInstance(ethernetIf); + ethernetIf->closeAllInstances(); +} + TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_BytesSent) { int instanceNumber = 1; HOSTIF_MsgData_t param = { 0 }; @@ -395,6 +408,19 @@ TEST(EthernetTest, get_Device_Ethernet_Interface_Stats_UnknownProtoPacketsReceiv } } +TEST(EthernetTest, Lock_ReleaseLock) { + int instanceNumber = 0; + hostIf_EthernetInterfaceStats *ethernetIfStats = hostIf_EthernetInterfaceStats::getInstance(instanceNumber); + if(ethernetIfStats) + { + ethernetIfStats->getLock(); + ethernetIfStats->releaseLock(); + EXPECT_EQ(0, 0); + } + ethernetIfStats->closeInstance(ethernetIfStats); + ethernetIfStats->closeAllInstances(); +} + GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; char buffer[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/profiles/Time/Device_Time.h b/src/hostif/profiles/Time/Device_Time.h index 9378b49bf..7fc5cd481 100644 --- a/src/hostif/profiles/Time/Device_Time.h +++ b/src/hostif/profiles/Time/Device_Time.h @@ -436,6 +436,10 @@ class hostIf_Time { int get_Device_Time_CurrentUTCTime(HOSTIF_MsgData_t *, bool *pChanged = NULL); +#if defined(GTEST_ENABLE) + FRIEND_TEST(TimeTest, releaseLock); +#endif + }; /* End of TR_069_DEVICE_TIME_SETTER_API doxygen group. */ /** diff --git a/src/hostif/profiles/Time/gtest/Makefile.am b/src/hostif/profiles/Time/gtest/Makefile.am index 56c6fb60d..b3b56f490 100644 --- a/src/hostif/profiles/Time/gtest/Makefile.am +++ b/src/hostif/profiles/Time/gtest/Makefile.am @@ -21,21 +21,10 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = time_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) - - -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/handlers/include -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/profiles/Time -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I/usr/include/rbus -I/usr/local/include/rbus $(GLIB_CFLAGS) $(G_THREAD_CFLAGS) -I/usr/include/libsoup-3.0 # Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage diff --git a/src/hostif/profiles/Time/gtest/gtest_time.cpp b/src/hostif/profiles/Time/gtest/gtest_time.cpp index 950250861..6d07b29e5 100644 --- a/src/hostif/profiles/Time/gtest/gtest_time.cpp +++ b/src/hostif/profiles/Time/gtest/gtest_time.cpp @@ -123,6 +123,36 @@ TEST(TimeTest, get_Device_Time_CurrentUTCTime) { } } +TEST(TimeTest, releaseLock) { + int instanceNumber = 0; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + hostIfTime->getLock(); + gboolean locked = g_mutex_trylock(&hostIfTime->m_mutex); + EXPECT_EQ(locked, false); + hostIfTime->releaseLock(); + } +} + +TEST(TimeTest, closeInstance) { + int instanceNumber = 0; + bool pChanged = false; + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + + hostIf_Time *hostIfTime= hostIf_Time::getInstance(instanceNumber); + if(hostIfTime) + { + hostIf_Time::closeInstance(hostIfTime); + hostIfTime->closeAllInstances(); + } +} + GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; char buffer[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/src/gtest/Makefile.am b/src/hostif/src/gtest/Makefile.am index 72cb04efa..abe5dd873 100644 --- a/src/hostif/src/gtest/Makefile.am +++ b/src/hostif/src/gtest/Makefile.am @@ -21,25 +21,13 @@ AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = src_gtest # Define the include directories -COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus +COMMON_CPPFLAGS = -std=c++11 -DGTEST_ENABLE -DPARODUS -DUNIT_TEST -I/usr/include -I/usr/include/cjson -I$(TOP_DIR)/src/hostif/include -I$(TOP_DIR)/src/hostif/profiles/DeviceInfo -I$(TOP_DIR)/src/unittest/stubs -I$(TOP_DIR)/src/unittest/stubs/ds -I$(TOP_DIR)/src/unittest/stubs/rbus/include -I$(TOP_DIR)/src/hostif/handlers/include -I$(TOP_DIR)/src/hostif/parodusClient/pal -I$(TOP_DIR)/src/hostif/parodusClient/waldb -I$(TOP_DIR)/src/hostif/httpserver/include -I$(TOP_DIR)/src/hostif/handlers/src -I/usr/include/rbus -I/usr/local/include/rbus -I/usr/include/libsoup-3.0 -if LIBSOUP3_ENABLE -COMMON_CPPFLAGS += -I/usr/include/libsoup-3.0 -DLIBSOUP3_ENABLE -else -COMMON_CPPFLAGS += -I/usr/include/libsoup-2.4 -endif - -# Define the libraries to link against -COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl - -if LIBSOUP3_ENABLE -COMMON_LDADD += -lsoup-3.0 -endif +COMMON_LDADD = -lgtest -lgtest_main -lgmock_main -lgmock -lgcov $(GLIB_LIBS) -ltinyxml2 -lcjson -lcurl -lsoup-3.0 # Define the compiler flags COMMON_CXXFLAGS = -frtti $(GLIB_CFLAGS) $(SOUP_LIBS) -fprofile-arcs -ftest-coverage - # Define the source files src_gtest_SOURCES = $(TOP_DIR)/src/hostif/src/hostIf_utils.cpp $(TOP_DIR)/src/hostif/src/IniFile.cpp $(TOP_DIR)/src/unittest/stubs/secure_wrapper.c $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFCStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComRFC.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStore.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/XrdkCentralComBSStoreJournal.cpp $(TOP_DIR)/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp $(TOP_DIR)/src/hostif/handlers/src/hostIf_NotificationHandler.cpp $(TOP_DIR)/src/hostif/parodusClient/pal/webpa_notification.cpp $(TOP_DIR)/src/unittest/stubs/dm_stubs.cpp $(TOP_DIR)/src/hostif/parodusClient/waldb/waldb.cpp $(TOP_DIR)/src/unittest/stubs/wdmp-c.c $(TOP_DIR)/src/unittest/stubs/wdmp_internal.c $(TOP_DIR)/src/hostif/httpserver/src/http_server.cpp $(TOP_DIR)/src/hostif/httpserver/src/request_handler.cpp $(TOP_DIR)/src/hostif/httpserver/src/XrdkCentralComRFCVar.cpp $(TOP_DIR)/src/unittest/stubs/file_writer.cpp $(TOP_DIR)/src/hostif/src/gtest/gtest_src.cpp diff --git a/src/hostif/src/gtest/gtest_src.cpp b/src/hostif/src/gtest/gtest_src.cpp index b6ae6fcca..639b3f0a8 100644 --- a/src/hostif/src/gtest/gtest_src.cpp +++ b/src/hostif/src/gtest/gtest_src.cpp @@ -48,6 +48,10 @@ extern "C" using namespace std; +#ifdef GTEST_ENABLE +extern size_t (*getWriteCurlResponse(void))(void *ptr, size_t size, size_t nmemb, std::string stream); +#endif + XRFCStore* m_rfcStore; XBSStore* m_bsStore; XBSStoreJournal* m_bsStoreJournal; @@ -69,6 +73,14 @@ TEST(srcTest, load) { delete m_ini; } +TEST(srcTest, inValidFile) { + IniFile* m_ini = new IniFile(); + const string filename = "/opt/secure/RFC/bootstrap_test.ini"; + bool result = m_ini->load(filename); + EXPECT_EQ(result, false); + delete m_ini; +} + TEST(srcTest, value) { IniFile* m_ini = new IniFile(); const string key = "Device.Time.NTPServer5"; @@ -76,7 +88,7 @@ TEST(srcTest, value) { bool ret = m_ini->load("/opt/secure/RFC/bootstrap.ini"); string result = m_ini->value(key, defaultValue); - EXPECT_EQ(result, "time"); + EXPECT_EQ(result, "override_time4.com"); delete m_ini; } @@ -91,6 +103,26 @@ TEST(srcTest, srcsetValue) { delete m_ini; } +TEST(srcTest, srcsetDefaultValue) { + IniFile* m_ini = new IniFile(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId"; + const string value = "sky"; + + bool result = m_ini->setValue(key, value); + EXPECT_EQ(result, false); + delete m_ini; +} + +TEST(srcTest, flush) { + IniFile* m_ini = new IniFile(); + const string key = "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId"; + const string value = "sky"; + + m_ini->m_filename = "/opt/secure/RFC_test/bootstrap_temp.ini"; + bool result = m_ini->flush(); + EXPECT_EQ(result, false); + delete m_ini; +} /* TEST(srcTest, clear) { IniFile *inFile = new IniFile(); @@ -112,6 +144,8 @@ TEST(srcTest, getStringFromEnum) { const char *result = getStringFromEnum(myEnumMap, size, inputCode); EXPECT_EQ(result, "TWO"); + + const char *ret = getStringFromEnum(myEnumMap, 0, inputCode); } TEST(srcTest, getEnumFromString) { @@ -126,6 +160,9 @@ TEST(srcTest, getEnumFromString) { int ret = getEnumFromString(myEnumMap, size, "THREE"); EXPECT_EQ(ret, 3); + + int result = getEnumFromString(myEnumMap, 0, "THREE"); + EXPECT_EQ(result, -1); } TEST(srcTest, type_conversions) { @@ -151,13 +188,6 @@ TEST(srcTest, type_conversions) { uint uiret = get_uint(uptr); EXPECT_EQ(uiret, number); - /*const char* input = "true"; - bool ret = get_boolean("true"); - EXPECT_EQ(ret, true); */ - - string btosret = bool_to_string(false); - EXPECT_EQ(btosret, "false"); - int stoiret = string_to_int("123"); EXPECT_EQ(stoiret, 123); @@ -171,6 +201,22 @@ TEST(srcTest, type_conversions) { EXPECT_EQ(stobret, false); } +TEST(srcTest, bool_to_string) { + std::string value = bool_to_string(true); + EXPECT_EQ(value, "true"); + + string ret = bool_to_string(false); + EXPECT_EQ(ret, "false"); +} + +TEST(srcTest, string_to_bool) { + bool ret = string_to_bool("false"); + EXPECT_EQ(ret, false); + + bool value = string_to_bool("1"); + EXPECT_EQ(value, true); +} + TEST(srcTest, getBSUpdateEnum) { HostIf_Source_Type_t type; type = getBSUpdateEnum("allUpdate"); @@ -181,6 +227,12 @@ TEST(srcTest, getBSUpdateEnum) { type = getBSUpdateEnum("default"); EXPECT_EQ(type, HOSTIF_SRC_DEFAULT); + + type = getBSUpdateEnum("none"); + EXPECT_EQ(type, HOSTIF_NONE); + + type = getBSUpdateEnum(NULL); + EXPECT_EQ(type, HOSTIF_NONE); } @@ -249,6 +301,160 @@ TEST(srcTest, timeValDiff) { EXPECT_EQ(msec, 1700); } +TEST(srcTest, writeCurlResponse) { + const char* input = "MockCurlData"; + size_t size = 1; + size_t nmemb = strlen(input); + std::string response; + size_t written = getWriteCurlResponse()((void*)input, size, nmemb, response); + EXPECT_EQ(written, nmemb); +} + +TEST(srcTest, getCurrentTime) { + struct timespec ts; + getCurrentTime(&ts); + EXPECT_GT(ts.tv_sec, 0); + + EXPECT_GE(ts.tv_nsec, 0); + EXPECT_LT(ts.tv_nsec, 1000000000L); + +} + +TEST(srcTest, ReturnsEnvValueIfSet) +{ + const char* envName = "TEST_ENV_VAR"; + const char* envValue = "expected_value"; + const char* defaultValue = "default_value"; + + // Set environment variable + setenv(envName, envValue, 1); + + // Call function + char* result = getenvOrDefault(envName, defaultValue); + + // Validate + EXPECT_EQ(std::string(result), std::string(envValue)); +} + + +TEST(srcTest, triggerResetScript) +{ + setResetState(ColdReset); + triggerResetScript(); + + setResetState(FactoryReset); + triggerResetScript(); + + setResetState(WarehouseReset); + triggerResetScript(); + + setResetState(CustomerReset); + triggerResetScript(); + + EXPECT_EQ(0, 0); +} + +TEST(srcTest, getResetState) +{ + setResetState(FactoryReset); + eSTBResetState state = getResetState(); + EXPECT_EQ(state, FactoryReset); +} + +TEST(srcTest, get_security_token) +{ + std::string token = get_security_token(); + EXPECT_EQ(token, ""); +} + +TEST(srcTest, putBoolValue) +{ + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + putValue(¶m, "true"); + cout << "msgData.paramValue = " << get_boolean(param.paramValue) << endl; + EXPECT_EQ(get_boolean(param.paramValue), true); +} + +TEST(srcTest, putIntValue) +{ + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.SWDLSpLimit.TopSpeed", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_IntegerType; + param.paramLen = sizeof(hostIf_IntegerType); + + putValue(¶m, "14200"); + cout << "msgData.paramValue = " << get_int(param.paramValue) << endl; + EXPECT_EQ(get_int(param.paramValue), 14200); +} + +TEST(srcTest, putStringValue) +{ + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerProductName", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_StringType; + param.paramLen = strlen(param.paramValue); + + putValue(¶m, "testName"); + cout << "msgData.paramValue = " << param.paramValue << endl; + EXPECT_STREQ(param.paramValue, "testName"); +} + +TEST(srcTest, putUnsignedValue) +{ + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.IP.Interface.1.Stats.BytesReceived", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + param.paramtype = hostIf_UnsignedLongType; + param.paramLen = sizeof(hostIf_UnsignedLongType); + + putValue(¶m, "1048576"); + cout << "msgData.paramValue = " << get_ulong(param.paramValue) << endl; + EXPECT_EQ(get_ulong(param.paramValue), 1048576); +} + +TEST(srcTest, ReturnsTrueWhenInputIsTrue) +{ + bool value = true; + EXPECT_EQ(get_boolean((const char *)&value), true); +} + + +TEST(srcTest, getStringValue) +{ + HOSTIF_MsgData_t param = { 0 }; + memset(¶m,0,sizeof(HOSTIF_MsgData_t)); + param.reqType = HOSTIF_GET; + strncpy (param.paramName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable", TR69HOSTIFMGR_MAX_PARAM_LEN - 1); + param.bsUpdate = HOSTIF_NONE; + param.requestor = HOSTIF_SRC_RFC; + + put_boolean(param.paramValue, true); + param.paramtype = hostIf_BooleanType; + param.paramLen = sizeof(hostIf_BooleanType); + + std::string value = getStringValue(¶m); + cout << "param.paramValue = " << param.paramValue << endl; + EXPECT_EQ(value, "true"); +} GTEST_API_ int main(int argc, char *argv[]){ char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; diff --git a/src/hostif/src/hostIf_utils.cpp b/src/hostif/src/hostIf_utils.cpp index 054a55c29..68627f913 100644 --- a/src/hostif/src/hostIf_utils.cpp +++ b/src/hostif/src/hostIf_utils.cpp @@ -643,5 +643,11 @@ string getJsonRPCData(std::string postData) } } +#ifdef GTEST_ENABLE +size_t (*getWriteCurlResponse(void))(void *ptr, size_t size, size_t nmemb, std::string stream) { + return &writeCurlResponse; +} +#endif + /** @} */ /** @} */ diff --git a/src/integrationtest/conf/bootstrap.ini b/src/integrationtest/conf/bootstrap.ini index 2c68c633c..99467fef3 100644 --- a/src/integrationtest/conf/bootstrap.ini +++ b/src/integrationtest/conf/bootstrap.ini @@ -1 +1,2 @@ Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.PartnerId=global +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.PartnerName=comcast diff --git a/src/unittest/stubs/remote_debugger.json b/src/unittest/stubs/remote_debugger.json new file mode 100644 index 000000000..1f36b579c --- /dev/null +++ b/src/unittest/stubs/remote_debugger.json @@ -0,0 +1,68 @@ +{ + "DebugCategory": { + "DebugIssueType": { + "DebugCommands": "command1;command2;commmand3", + "DebugTimeout" : 10 + } + }, + "Sanity": { + "Check" : { + "Commands" : [ "rm -rf", "kill", "pkill", "iptables", "ip6tables" ] + } + }, + "Device" : { + "Info" : { + "Commands": "cat /version.txt;cat /etc/device.properties;uname -r", + "Timeout" : 10 + }, + "Uptime" : { + "Commands": "uptime", + "Timeout" : 10 + }, + "Dump" : { + "Commands": "tcpdump -w RRD_LOCATION/capture.pcap &", + "Timeout" : 10 + } + }, + "Command" : { + "Harm" : { + "Commands": "rm -rf", + "Timeout" : 10 + } + }, + "Process" : { + "ProcessStatus" : { + "Commands": "cat /opt/logs/top_log.txt*", + "Timeout" : 10 + }, + "ServiceStatus" : { + "Commands": "systemctl list-units --type=service --all", + "Timeout" : 10 + } + }, + "DeepSleep": { + "Audio" : { + "AudioStatus" : { + "Commands": "cat /sys/class/avsync_session0/session_stat;cat /sys/class/vdec/vdec_status;hal_dump", + "Timeout" : 10 + } + }, + "Video" : { + "VideoStatus" : { + "Commands": "cat /sys/class/avsync_session0/session_stat;cat /sys/class/vdec/vdec_status;hal_dump", + "Timeout" : 10 + } + }, + "Process" : { + "ProcessStatus" : { + "Commands": "cat /opt/logs/top_log.txt*", + "Timeout" : 10 + }, + "ServiceStatus" : { + "Commands": "systemctl list-units --type=service --all", + "Timeout" : 10 + } + + } + } +} diff --git a/src/unittest/stubs/rfcdefaults.ini b/src/unittest/stubs/rfcdefaults.ini index 1cedddc0d..a3713354e 100644 --- a/src/unittest/stubs/rfcdefaults.ini +++ b/src/unittest/stubs/rfcdefaults.ini @@ -1 +1,2 @@ Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.Airplay.Enable=false +Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable=true From 0358f905d10b8a70c0bf959de692670f8d599ba4 Mon Sep 17 00:00:00 2001 From: MonekaLakshmi <101797473+MonekaLakshmi@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:07:36 +0530 Subject: [PATCH 134/161] RDKE-900 RDKEMW-4899: Default to MTLS connection on all endpoints Reason for change: Remove MTLS RFC Test Procedure: Make sure all communication is MTLS & secure Risks: Medium Priority: P1 --- .../waldb/data-model/data-model-generic.xml | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 4d69646ab..2f36c03a6 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -3530,21 +3530,6 @@ - - - - - - - - - - - - - - - @@ -4153,14 +4138,6 @@ - - - - - - - - From a6a57994dda2ead5d589cfbce9bcc3ba82a25c9e Mon Sep 17 00:00:00 2001 From: rdkcmf Date: Mon, 29 Sep 2025 14:11:25 +0100 Subject: [PATCH 135/161] Deploy fossid_integration_stateless_diffscan_target_repo action --- ...d_integration_stateless_diffscan_target_repo.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml index da02b8b4f..7b8c1cba1 100644 --- a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml +++ b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml @@ -1,11 +1,18 @@ name: Fossid Stateless Diff Scan -on: pull_request +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: read jobs: call-fossid-workflow: - uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@develop - secrets: + if: ${{ ! github.event.pull_request.head.repo.fork }} + uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@1.0.0 + secrets: FOSSID_CONTAINER_USERNAME: ${{ secrets.FOSSID_CONTAINER_USERNAME }} FOSSID_CONTAINER_PASSWORD: ${{ secrets.FOSSID_CONTAINER_PASSWORD }} FOSSID_HOST_USERNAME: ${{ secrets.FOSSID_HOST_USERNAME }} From 49f4b47afac72bba29ca5851b574aacf8ac0d652 Mon Sep 17 00:00:00 2001 From: Tony Paul Date: Wed, 3 Sep 2025 09:00:08 +0000 Subject: [PATCH 136/161] RDKEMW-6455: separate Blacklist RFC, and enabled by default --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 -------- .../parodusClient/waldb/data-model/data-model-stb.xml | 8 ++++++++ .../parodusClient/waldb/data-model/data-model-tv.xml | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 4d69646ab..2d8165c30 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4367,14 +4367,6 @@ - - - - - - - - diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml index ede3d12ff..2dc3e3745 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml @@ -476,5 +476,13 @@ + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml index bffa5bc07..eeb9a4f1e 100644 --- a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml @@ -477,5 +477,13 @@ + + + + + + + + From 17026ffce615ea45727c4fcf6632e9c1ffe23c08 Mon Sep 17 00:00:00 2001 From: udaykrishnag <33549128+udaykrishnag@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:25:01 -0400 Subject: [PATCH 137/161] RDK-58220 : [RDKE] Migrate Functionality In TR-69Hostif And NTP Scripts To Core Modules (#276) * RDK-58220 Migrate Functionality In TR-69Hostif Scripts To Core Modules * RDK-58220 Migrate Functionality In TR-69Hostif Scripts To Core Modules * RDK-58220 : [RDKE] Migrate Functionality In TR-69Hostif And NTP Scripts To Core Modules --------- Co-authored-by: Garpathi, Uday Krishna --- run_l2.sh | 2 +- src/hostif/src/hostIf_main.cpp | 23 ++--------------------- tr69hostif.service | 3 +-- tr69hostif_no_new_http_server.service | 3 +-- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index 66d582680..10cd51fb3 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -62,7 +62,7 @@ if [ ! -z "$pid" ]; then kill -9 `pidof tr69hostif` fi -/usr/local/bin/tr69hostif -c /etc/mgrlist.conf -d /etc/debug.ini -p 10999 -s 11999 | tee /opt/logs/tr69hostIf.log.0 & +/usr/local/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 -s 11999 | tee /opt/logs/tr69hostIf.log.0 & pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/bootup_sequence.json test/functional-tests/tests/test_bootup_sequence.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/handlers_communications.json test/functional-tests/tests/test_handlers_communications.py diff --git a/src/hostif/src/hostIf_main.cpp b/src/hostif/src/hostIf_main.cpp index 1d1e6e1dc..94f0aadd2 100644 --- a/src/hostif/src/hostIf_main.cpp +++ b/src/hostif/src/hostIf_main.cpp @@ -220,8 +220,6 @@ int main(int argc, char *argv[]) #ifdef WEBPA_RFC_ENABLED bool retVal=false; #endif - const char* debugConfigFile = NULL; - const char* webpaNotifyConfigFile = NULL; //------------------------------------------------------------------------------ // Signal handlers: //------------------------------------------------------------------------------ @@ -240,8 +238,6 @@ int main(int argc, char *argv[]) #ifndef NEW_HTTP_SERVER_DISABLE {"httpserverport", required_argument, 0, 's'}, #endif - {"debugconfig", required_argument, 0, 'd'}, - {"notifyconfig", required_argument, 0, 'w'}, {0, 0, 0, 0} }; @@ -273,19 +269,6 @@ int main(int argc, char *argv[]) } break; - case 'd': - if(optarg) - { - debugConfigFile = optarg; - } - break; - case 'w': - if(optarg) - { - webpaNotifyConfigFile = optarg; - } - break; - case 'p': if(optarg) { @@ -310,7 +293,7 @@ int main(int argc, char *argv[]) } /* Enable RDK logger.*/ - if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; + if(rdk_logger_init(0 == access("/opt/debug.ini", R_OK) ? "/opt/debug.ini" : "/etc/debug.ini") == 0) rdk_logger_enabled = 1; #ifdef T2_EVENT_ENABLED t2_init(const_cast("tr69hostif")); #endif @@ -381,8 +364,6 @@ int main(int argc, char *argv[]) RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"g_thread NOT supported\n"); } #endif - /* Enable RDK logger.*/ - if(rdk_logger_init(debugConfigFile) == 0) rdk_logger_enabled = 1; #if defined(USE_WIFI_PROFILE) /* Perform the necessary operations to initialise the WiFi device */ @@ -496,7 +477,7 @@ int main(int argc, char *argv[]) //------------------------------------------------------------------------------ RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"Starting WEBPA Parodus Connections\n"); - libpd_set_notifyConfigFile(webpaNotifyConfigFile); + libpd_set_notifyConfigFile(0 == access("/opt/notify_webpa_cfg.json", R_OK) ? "/opt/notify_webpa_cfg.json" : "/etc/notify_webpa_cfg.json"); if(0 == pthread_create(&parodus_init_tid, NULL, libpd_client_mgr, NULL)) { RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"Initiating Connection with PARODUS success.. \n"); diff --git a/tr69hostif.service b/tr69hostif.service index 243bac9cc..ffac64af2 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -25,8 +25,7 @@ Type=notify SyslogIdentifier="tr69hostif" EnvironmentFile=/etc/device.properties ExecStartPre=/bin/mkdir -p /opt/tr-181 -ExecStartPre=/bin/sh -c '/lib/rdk/opt-override.sh' -ExecStart=/usr/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 -s 11999 -d $DEBUGINIFILE -w $WEBPANOTIFYINCFG +ExecStart=/usr/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 -s 11999 ExecStop=/bin/kill -15 $MAINPID RestartSec=10s Restart=always diff --git a/tr69hostif_no_new_http_server.service b/tr69hostif_no_new_http_server.service index e6b6e25a2..d78a0f3bc 100644 --- a/tr69hostif_no_new_http_server.service +++ b/tr69hostif_no_new_http_server.service @@ -26,8 +26,7 @@ Type=notify SyslogIdentifier="tr69hostif" EnvironmentFile=/etc/device.properties ExecStartPre=/bin/mkdir -p /opt/tr-181 -ExecStartPre=/bin/sh -c '/lib/rdk/opt-override.sh' -ExecStart=/usr/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 -d $DEBUGINIFILE -w $WEBPANOTIFYINCFG +ExecStart=/usr/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 ExecStop=/bin/kill -15 $MAINPID Restart=always From 1d0bd711eceff47346e7771730d7a0cee23b2c00 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Wed, 8 Oct 2025 00:24:49 +0530 Subject: [PATCH 138/161] Build error due to L1 changes (#279) * Update hostIf_dsClient_ReqHandler.cpp * Update hostIf_dsClient_ReqHandler.cpp * Update data-model-generic.xml * Update hostIf_dsClient_ReqHandler.cpp --------- Co-authored-by: mtirum011 --- .../parodusClient/waldb/data-model-generic.xml | 13 +++++++++++++ .../profiles/DeviceInfo/Device_DeviceInfo.cpp | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model-generic.xml index 7db6d2ccd..d9f3e6128 100644 --- a/src/hostif/parodusClient/waldb/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model-generic.xml @@ -660,6 +660,19 @@ + + + + + + + + + + + + + diff --git a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp index 186d79224..f09399464 100644 --- a/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp +++ b/src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp @@ -1690,7 +1690,6 @@ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_COMCAST_COM_PowerStatus(HOSTIF_Ms */ int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_FirmwareFilename(HOSTIF_MsgData_t * stMsgData, bool *pChanged) { - errno_t rc = -1; string line; bool curFileFlag = true; ifstream curFwfile(CURENT_FW_FILE); From f4656eda99c463b933aae474e112f0cb19d667a8 Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Tue, 7 Oct 2025 16:07:09 -0400 Subject: [PATCH 139/161] RDK-41133 : New RFC to force maintenance every X mins Signed-off-by: Venkata Bojja --- .../parodusClient/waldb/data-model/data-model-generic.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 2d8165c30..008be575a 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4486,5 +4486,12 @@ + + + + + + + From 4ca7ede72249fada45da35b4df3ef27ac0d95e0d Mon Sep 17 00:00:00 2001 From: NareshM1702 Date: Wed, 8 Oct 2025 01:50:40 +0530 Subject: [PATCH 140/161] RDKEMW-7921:Enable network isolation to deny SSH from Dev Jump VM to Prod VM using SHORTS (#278) Reason for change: Change RFC Default value to PROD Test Procedure: get the RFC value and verify Risks: low Priority: P1 Co-authored-by: Venkata Bojja <39968865+venkat0557@users.noreply.github.com> --- .../parodusClient/waldb/data-model/data-model-generic.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 008be575a..b2458a1d5 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4340,7 +4340,7 @@ - + From 382af7197b338cc4ec379d14fa742f160a66caca Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Tue, 7 Oct 2025 16:44:38 -0400 Subject: [PATCH 141/161] 1.2.6 release changelog updates --- CHANGELOG.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02ed907d7..f0911544d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.6](https://github.com/rdkcentral/tr69hostif/compare/1.2.5...1.2.6) + +- RDKEMW-7921:Enable network isolation to deny SSH from Dev Jump VM to Prod VM using SHORTS [`#278`](https://github.com/rdkcentral/tr69hostif/pull/278) +- RDK-41133 : New RFC to force maintenance every X mins [`#281`](https://github.com/rdkcentral/tr69hostif/pull/281) +- Build error due to L1 changes [`#279`](https://github.com/rdkcentral/tr69hostif/pull/279) +- RDK-58220 : [RDKE] Migrate Functionality In TR-69Hostif And NTP Scripts To Core Modules [`#276`](https://github.com/rdkcentral/tr69hostif/pull/276) +- RDKEMW-6455: separate Blacklist RFC, and enabled by default [`#273`](https://github.com/rdkcentral/tr69hostif/pull/273) +- Deploy fossid_integration_stateless_diffscan_target_repo action [`#271`](https://github.com/rdkcentral/tr69hostif/pull/271) +- RDK-58962 [ tr69hostif ] : L1 Functional Coverage from 56% to 75-80% [`#252`](https://github.com/rdkcentral/tr69hostif/pull/252) +- Deploy cla action [`#186`](https://github.com/rdkcentral/tr69hostif/pull/186) +- SERXIONE-7905: Device is not accessible via SSH after DRI execution [`#267`](https://github.com/rdkcentral/tr69hostif/pull/267) +- Potential fix for code scanning alert no. 10: Too few arguments to formatting function [`9e00c40`](https://github.com/rdkcentral/tr69hostif/commit/9e00c401c8a3901d0c22efaf5b06c34ecfa438ba) +- Merge tag '1.2.5' into develop [`4be75e7`](https://github.com/rdkcentral/tr69hostif/commit/4be75e7d29ebdd31980a202d103a63d8d941d5d6) + #### [1.2.5](https://github.com/rdkcentral/tr69hostif/compare/1.2.4...1.2.5) +> 24 September 2025 + - RDK-58963-[RDK-V/E] Federated Source Code For tr69hostif - Phase 2 [`#250`](https://github.com/rdkcentral/tr69hostif/pull/250) - RDKEMW-8367: Add Valid Public NTP servers for community [`#255`](https://github.com/rdkcentral/tr69hostif/pull/255) - DELIA-68569 - WebPA Query fails for RRD Enabled command [`#235`](https://github.com/rdkcentral/tr69hostif/pull/235) @@ -14,9 +30,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Rebase [`#237`](https://github.com/rdkcentral/tr69hostif/pull/237) - Rebase [`#234`](https://github.com/rdkcentral/tr69hostif/pull/234) - rebase [`#231`](https://github.com/rdkcentral/tr69hostif/pull/231) +- 1.2.5 release changelog updates [`a787aa4`](https://github.com/rdkcentral/tr69hostif/commit/a787aa4866e769fad654d2ee89f16afa21204ede) - Update webpa_parameter.cpp [`7b12e1f`](https://github.com/rdkcentral/tr69hostif/commit/7b12e1f3b1790899806f41f1144c17435905d450) - Merge tag '1.2.4' into develop [`364c312`](https://github.com/rdkcentral/tr69hostif/commit/364c312c2c7cc15d94350692024cb5142336e3e6) -- Update webpa_parameter.cpp [`1b63a82`](https://github.com/rdkcentral/tr69hostif/commit/1b63a82935bcb4a9d67086f712b6ba4fa67acddc) #### [1.2.4](https://github.com/rdkcentral/tr69hostif/compare/1.2.3...1.2.4) From c575dd557eee7ae6ea3f7284b11a5e695a3eaf3d Mon Sep 17 00:00:00 2001 From: apatel859 <48992974+apatel859@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:50:00 -0400 Subject: [PATCH 142/161] RDKEMW-8971: fix retry logic (#288) Signed-off-by: apatel859 --- .../src/hostIf_dsClient_ReqHandler.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_dsClient_ReqHandler.cpp b/src/hostif/handlers/src/hostIf_dsClient_ReqHandler.cpp index d3db9e82f..3783b6549 100644 --- a/src/hostif/handlers/src/hostIf_dsClient_ReqHandler.cpp +++ b/src/hostif/handlers/src/hostIf_dsClient_ReqHandler.cpp @@ -82,15 +82,22 @@ bool DSClientReqHandler::init() { RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__); RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] Device manager Initializing\n", __FUNCTION__); - try + while(true) { - device::Manager::Initialize(); + try + { + device::Manager::Initialize(); + } + catch(const std::exception &e) + { + RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Exception thrown while initializing device manager %s\n", e.what()); + sleep(3); + continue; + } + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s()] Device manager Initialized success break loop \n", __FUNCTION__); + break; } - catch(const std::exception &e) - { - RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Exception thrown while initializing device manager %s\n", e.what()); - } - RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); + RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__); return true; } From 0a90ffc1ab43c5e7cf7b3424c007bee48e132370 Mon Sep 17 00:00:00 2001 From: Stephen Barrett Date: Sun, 12 Oct 2025 15:39:14 +0100 Subject: [PATCH 143/161] Update CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4e29ed9af..9863dcd46 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,4 +2,4 @@ # the repo. Unless a later match takes precedence, # @global-owner1 and @global-owner2 will be requested for # review when someone opens a pull request. -* @rdkcentral/rdke_ghec_tr69_maintainer @rdkcentral/rdke_ghec_tr69_admin +* @rdkcentral/tr69hostif-maintainers From c53a8062aec24f3aa1434b33aed1c9a20c37837f Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Mon, 13 Oct 2025 21:17:18 -0400 Subject: [PATCH 144/161] RDK-59587 : RFC feature to support Downloadable IUI Fallback Signed-off-by: Venkata Bojja --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 6e6a2b50a..7c836db9d 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4434,6 +4434,14 @@ + + + + + + + + From 107fae207def673e965d97899c82fe71b70f510f Mon Sep 17 00:00:00 2001 From: Venkata Bojja Date: Mon, 13 Oct 2025 21:31:23 -0400 Subject: [PATCH 145/161] 1.2.7 release changelog updates --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0911544d..d3f1ef4b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.7](https://github.com/rdkcentral/tr69hostif/compare/1.2.6...1.2.7) + +- RDK-59587 : RFC feature to support Downloadable IUI Fallback [`#291`](https://github.com/rdkcentral/tr69hostif/pull/291) +- RDKE-900 RDKEMW-4899: Default to MTLS connection on all endpoints [`#270`](https://github.com/rdkcentral/tr69hostif/pull/270) +- Rebase with develop [`#290`](https://github.com/rdkcentral/tr69hostif/pull/290) +- Update CODEOWNERS [`#289`](https://github.com/rdkcentral/tr69hostif/pull/289) +- RDKEMW-8971: fix retry logic [`#288`](https://github.com/rdkcentral/tr69hostif/pull/288) +- Rebase with develop [`#274`](https://github.com/rdkcentral/tr69hostif/pull/274) +- Rebase with develop [`#272`](https://github.com/rdkcentral/tr69hostif/pull/272) +- Merge tag '1.2.6' into develop [`2e546d5`](https://github.com/rdkcentral/tr69hostif/commit/2e546d5de878a5c8ee7a3558099cdcddc28f10a4) + #### [1.2.6](https://github.com/rdkcentral/tr69hostif/compare/1.2.5...1.2.6) +> 7 October 2025 + - RDKEMW-7921:Enable network isolation to deny SSH from Dev Jump VM to Prod VM using SHORTS [`#278`](https://github.com/rdkcentral/tr69hostif/pull/278) - RDK-41133 : New RFC to force maintenance every X mins [`#281`](https://github.com/rdkcentral/tr69hostif/pull/281) - Build error due to L1 changes [`#279`](https://github.com/rdkcentral/tr69hostif/pull/279) @@ -15,6 +28,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - RDK-58962 [ tr69hostif ] : L1 Functional Coverage from 56% to 75-80% [`#252`](https://github.com/rdkcentral/tr69hostif/pull/252) - Deploy cla action [`#186`](https://github.com/rdkcentral/tr69hostif/pull/186) - SERXIONE-7905: Device is not accessible via SSH after DRI execution [`#267`](https://github.com/rdkcentral/tr69hostif/pull/267) +- 1.2.6 release changelog updates [`382af71`](https://github.com/rdkcentral/tr69hostif/commit/382af7197b338cc4ec379d14fa742f160a66caca) - Potential fix for code scanning alert no. 10: Too few arguments to formatting function [`9e00c40`](https://github.com/rdkcentral/tr69hostif/commit/9e00c401c8a3901d0c22efaf5b06c34ecfa438ba) - Merge tag '1.2.5' into develop [`4be75e7`](https://github.com/rdkcentral/tr69hostif/commit/4be75e7d29ebdd31980a202d103a63d8d941d5d6) From 7fcceef6189ee05e9d89d3b97ed89247f8101875 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Fri, 24 Oct 2025 19:07:01 +0530 Subject: [PATCH 146/161] RDK-59202-[RDK-V/E] Data Model Federation For tr69hostif (#295) * Adding the logic * Update data-model-generic.xml * Update hostIf_main.cpp * Update waldb.cpp * Update hostIf_rbus_Dml_Provider.cpp * Final * Update hostIf_rbus_Dml_Provider.cpp * Update hostIf_main.cpp * Optimize memory management in hostIf_rbus_Dml_Provider Removed redundant memory freeing for parameter names before freeing dataElements. * Update request_handler.h * Update request_handler.h * Update hostIf_rbus_Dml_Provider.cpp * Revert MAX_PARAMETER_LENGTH to 512 Reverted MAX_PARAMETER_LENGTH from 2048 to 512. * Revert MAX_PARAMETER_LENGTH to 512 Reverted MAX_PARAMETER_LENGTH from 2048 to 512. * Update webpa_adapter.h * Update webpa_adapter.h * Implement RDKV and RDKE specific XML merging logic RDK-59579- Reason for change:Refactor XML data model merging logic into separate functions - Extract RDKV-specific merging logic into mergeDataModelRDKV() - Extract RDKE-specific merging logic into mergeDataModelRDKE() * RDK-59202-[RDK-V/E] Data Model Federation For tr69hostif RDK-59202-[RDK-V/E] Data Model Federation For tr69hostif - Extract RDKV-specific merging logic into mergeDataModelRDKV() - Extract RDKE-specific merging logic into mergeDataModelRDKE() - Use conditional compilation flags to call appropriate function - Simplify mergeDataModel() to dispatch to variant-specific handlers - Maintain backward compatibility for both RDKV and RDKE builds RDKV: Two-step merge Build time:Device specific and rdkv specific combination Run time :Build time base+generic+profile-specific during run time RDKE: Single-step merge (generic + profile-specific) * RDK-59579-Implement RDKV and RDKE specific XML merging logic RDK-59579-Implement RDKV and RDKE specific XML merging logic Reason for change:Refactor XML data model merging logic into separate functions - Extract RDKV-specific merging logic into mergeDataModelRDKV() - Extract RDKE-specific merging logic into mergeDataModelRDKE() * RDK-59202-[RDK-V/E] Data Model Federation For tr69hostif RDK-59202-[RDK-V/E] Data Model Federation For tr69hostif - Extract RDKV-specific merging logic into mergeDataModelRDKV() - Extract RDKE-specific merging logic into mergeDataModelRDKE() - Use conditional compilation flags to call appropriate function - Simplify mergeDataModel() to dispatch to variant-specific handlers - Maintain backward compatibility for both RDKV and RDKE builds RDKV: Two-step merge Build time:Device specific and rdkv specific combination Run time :Build time base+generic+profile-specific during run time RDKE: Single-step merge (generic + profile-specific) --- .../httpserver/include/request_handler.h | 2 +- src/hostif/include/hostIf_main.h | 8 +- src/hostif/parodusClient/pal/webpa_adapter.h | 2 +- .../parodusClient/pal/webpa_parameter.h | 7 +- .../waldb/data-model-generic.xml | 2087 +++-------------- src/hostif/parodusClient/waldb/waldb.cpp | 10 +- src/hostif/src/hostIf_main.cpp | 113 +- 7 files changed, 421 insertions(+), 1808 deletions(-) diff --git a/src/hostif/httpserver/include/request_handler.h b/src/hostif/httpserver/include/request_handler.h index 9b8814433..657e94b9e 100644 --- a/src/hostif/httpserver/include/request_handler.h +++ b/src/hostif/httpserver/include/request_handler.h @@ -65,7 +65,7 @@ #include "waldb.h" -#define MAX_PARAMETER_LEN 512 +#define MAX_PARAMETER_LEN 512 #define MAX_PARAMETERNAME_LEN 256 #ifdef __cplusplus diff --git a/src/hostif/include/hostIf_main.h b/src/hostif/include/hostIf_main.h index 79b155ec0..f99cb0195 100644 --- a/src/hostif/include/hostIf_main.h +++ b/src/hostif/include/hostIf_main.h @@ -112,20 +112,16 @@ extern gchar *date_str; -#ifndef RDKV_TR69 typedef enum { MERGE_SUCCESS, MERGE_FAILURE } MergeStatus; -#endif - - void tr69hostIf_logger (const gchar *log_domain, GLogLevelFlags log_level,const gchar *message, gpointer user_data); -#ifndef RDKV_TR69 MergeStatus mergeDataModel(); bool filter_and_merge_xml(const char *input1, const char *input2, const char *output); -#endif +MergeStatus mergeDataModelRDKV(const char* rdk_profile); +MergeStatus mergeDataModelRDKE(const char* rdk_profile); #define G_LOG_DOMAIN ((gchar*) 0) #define LOG_TR69HOSTIF "LOG.RDK.TR69HOSTIF" diff --git a/src/hostif/parodusClient/pal/webpa_adapter.h b/src/hostif/parodusClient/pal/webpa_adapter.h index ad8142221..ab07ee5e3 100644 --- a/src/hostif/parodusClient/pal/webpa_adapter.h +++ b/src/hostif/parodusClient/pal/webpa_adapter.h @@ -50,7 +50,7 @@ #define LOG_PARODUS_IF "LOG.RDK.PARODUSIF" #define WAL_FREE(__x__) if(__x__ != NULL) { free((void*)(__x__)); __x__ = NULL;} -#define MAX_PARAMETER_LEN 512 +#define MAX_PARAMETER_LEN 512 #define RDKC_XPC_SYNC_PARAM_CID #define MAX_PARAMETERNAME_LEN 256 diff --git a/src/hostif/parodusClient/pal/webpa_parameter.h b/src/hostif/parodusClient/pal/webpa_parameter.h index ca2d81dbb..32644d570 100644 --- a/src/hostif/parodusClient/pal/webpa_parameter.h +++ b/src/hostif/parodusClient/pal/webpa_parameter.h @@ -32,15 +32,12 @@ extern "C" #endif #include "webpa_adapter.h" -#ifdef RDKV_TR69 -#define WEBPA_DATA_MODEL_FILE "/etc/data-model.xml" -#else + #define WEBPA_DATA_MODEL_FILE "/tmp/data-model.xml" -#endif #define MAX_NUM_PARAMETERS 2048 #define MAX_DATATYPE_LENGTH 48 #define MAX_PARAM_LENGTH TR69HOSTIFMGR_MAX_PARAM_LEN -#define MAX_PARAMETER_LENGTH 512 +#define MAX_PARAMETER_LENGTH 512 #define MAX_PARAMETERVALUE_LEN 128 diff --git a/src/hostif/parodusClient/waldb/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model-generic.xml index d9f3e6128..d64990d42 100644 --- a/src/hostif/parodusClient/waldb/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model-generic.xml @@ -1,4 +1,3 @@ -