diff --git a/rfcMgr/mtlsUtils.h b/rfcMgr/mtlsUtils.h index dedf323a..768b85a4 100644 --- a/rfcMgr/mtlsUtils.h +++ b/rfcMgr/mtlsUtils.h @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -56,7 +57,10 @@ int isStateRedSupported(void); int isInStateRed(void); #endif int getMtlscert(MtlsAuth_t *sec); - +#if defined(RDKB_SUPPORT) +std::string getErouterMac(); +std::string geteCMMac(); +#endif #ifdef __cplusplus } #endif diff --git a/rfcMgr/rfc_manager.cpp b/rfcMgr/rfc_manager.cpp index 0a23f19c..ec4c5183 100644 --- a/rfcMgr/rfc_manager.cpp +++ b/rfcMgr/rfc_manager.cpp @@ -40,7 +40,7 @@ namespace rfc { #endif RFCManager ::RFCManager() { /* Initialize RDK Logger */ - rdk_logger_init(0 == access("/opt/debug.ini", R_OK) ? "/opt/debug.ini" : "/etc/debug.ini"); + rdk_logger_init(0 == access(OVERIDE_DEBUG_INI_FILE, R_OK) ? OVERIDE_DEBUG_INI_FILE : DEBUG_INI_FILE); /* Initialize IARM Bus */ InitializeIARM(); diff --git a/rfcMgr/rfc_manager.h b/rfcMgr/rfc_manager.h index c019ce3f..4a1ccd95 100644 --- a/rfcMgr/rfc_manager.h +++ b/rfcMgr/rfc_manager.h @@ -35,6 +35,11 @@ /* Macros */ /*----------------------------------------------------------------------------*/ #define DEBUG_INI_FILE "/etc/debug.ini" +#if !defined(RDKB_SUPPORT) +#define OVERIDE_DEBUG_INI_FILE "/opt/debug.ini" +#else +#define OVERIDE_DEBUG_INI_FILE "/nvram/debug.ini" +#endif #define DNS_RESOLV_FILE "/etc/resolv.dnsmasq" #define IP_ROUTE_FLAG "/tmp/route_available" #define GATEWAYIP_FILE "/tmp/.GatewayIP_dfltroute" diff --git a/rfcMgr/rfc_xconf_handler.cpp b/rfcMgr/rfc_xconf_handler.cpp index 53db964d..d0517ebe 100644 --- a/rfcMgr/rfc_xconf_handler.cpp +++ b/rfcMgr/rfc_xconf_handler.cpp @@ -93,9 +93,20 @@ int RuntimeFeatureControlProcessor:: InitializeRuntimeFeatureControlProcessor(vo GetAccountID(); GetOsClass(); -#if !defined(RDKB_SUPPORT) - _is_first_request = IsNewFirmwareFirstRequest(); -#endif + #if !defined(RDKB_SUPPORT) + _is_first_request = IsNewFirmwareFirstRequest(); + #else + if (access("/tmp/RFC/.timeValue", F_OK) != 0) + { + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "Consider as First RFC Request since /tmp/RFC/.timeValue file not found \n"); + _is_first_request = true; + } + else + { + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "Setting _is_first_request=false as /tmp/RFC/.timeValue file found \n"); + _is_first_request = false; + } + #endif return SUCCESS; } @@ -403,7 +414,7 @@ bool RuntimeFeatureControlProcessor::ParseConfigValue(const std::string& configK rbusValue_Release(newValue); if (rc == RBUS_ERROR_SUCCESS) { - RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "RFC: updated for %s from value old=%s, to new=%s\n", paramName.c_str(), paramValue.c_str(), configValue.c_str()); + RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "RFC: updated for %s from value old=%s, to new=%s\n", paramName.c_str(), paramValue.c_str(), configValue.c_str()); // Special handling for account ID if (paramName == RFC_ACCOUNT_ID_KEY_STR) { @@ -421,7 +432,7 @@ bool RuntimeFeatureControlProcessor::ParseConfigValue(const std::string& configK if (rebootValue == 1) { if (!rfcRebootCronNeeded) { rfcRebootCronNeeded = true; - RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "RFC: Enabling RfcRebootCronNeeded since %s old value=%s, new value=%s, RebootValue=%d\n", paramName.c_str(), paramValue.c_str(), configValue.c_str(), rebootValue); + RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "RFC: Enabling RfcRebootCronNeeded since %s old value=%s, new value=%s, RebootValue=%d\n", paramName.c_str(), paramValue.c_str(), configValue.c_str(), rebootValue); } } } else { @@ -812,7 +823,7 @@ void RuntimeFeatureControlProcessor::GetAccountID() { // Time file doesn't exist, set AccountID to Unknown _accountId = "Unknown"; - RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "GetAccountID: .timeValue file not found, setting AccountID to Unknown\n"); + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "GetAccountID: /tmp/RFC/.timeValue file not found, setting AccountID to Unknown\n"); } saveAccountIdToFile(_accountId, RFC_ACCOUNT_ID_KEY_STR, "string"); #endif @@ -1681,9 +1692,11 @@ void RuntimeFeatureControlProcessor::GetStoredHashAndTime( std ::string &valueHa { if(!_last_firmware.compare( _firmware_version )) { + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] Last Image version %s and current image version %s are same \n", __FUNCTION__, __LINE__, _last_firmware.c_str(), _firmware_version.c_str()); /*Both the input strings are equal.*/ - if((rfc_state == Init) && (isXconfSelectorSlotProd() == true)) + if((rfc_state == Init) && (isXconfSelectorSlotProd() == false)) { + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] Received XconfSelector as Non Prod for RFC state as INIT \n", __FUNCTION__, __LINE__); valueTime = "0"; valueHash = "OVERRIDE_HASH"; } @@ -1694,13 +1707,15 @@ void RuntimeFeatureControlProcessor::GetStoredHashAndTime( std ::string &valueHa } else { + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] Last Image version %s and current image version %s are different \n", __FUNCTION__, __LINE__, _last_firmware.c_str(), _firmware_version.c_str()); valueTime = "0"; valueHash = "UPGRADE_HASH"; } - std::string InvalidStr = "Unkown"; + std::string InvalidStr = "Unknown"; if ((!_partner_id.compare(InvalidStr)) || (!_accountId.compare(InvalidStr))) { + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] Invalid partner or account as Unknown, Passing OVERRIDE_HASH \n", __FUNCTION__, __LINE__); valueHash="OVERRIDE_HASH"; } @@ -1964,10 +1979,12 @@ void RuntimeFeatureControlProcessor::PreProcessJsonResponse(char *xconfResp) if(features) { CreateConfigDataValueMap(features); + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] First Xconf Request after reboot=%d\n", __FUNCTION__, __LINE__,_is_first_request); if( _is_first_request == true) { RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] GetValidAccountId\n", __FUNCTION__, __LINE__); GetValidAccountId(); + RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR, "[%s][%d] GetValidPartnerId\n", __FUNCTION__, __LINE__); GetValidPartnerId(); _is_first_request = false; } @@ -2053,7 +2070,7 @@ void RuntimeFeatureControlProcessor::GetValidPartnerId() if(value.empty()) { - RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR,"[%s][%d] Not found Parner ID\n", __FUNCTION__, __LINE__); + RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR,"[%s][%d] Not found Partner ID\n", __FUNCTION__, __LINE__); _valid_partnerId = "Unknown"; } else diff --git a/rfcMgr/rfc_xconf_handler.h b/rfcMgr/rfc_xconf_handler.h index 4d108c03..8289fcc8 100644 --- a/rfcMgr/rfc_xconf_handler.h +++ b/rfcMgr/rfc_xconf_handler.h @@ -133,7 +133,7 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler std::string _osclass; bool isRebootRequired; std::string bkup_hash; - bool _is_first_request; + bool _is_first_request = false; bool _url_validation_in_progress = false; std::string rfcSelectOpt; std:: string rfcSelectorSlot; diff --git a/rfcMgr/xconf_handler.cpp b/rfcMgr/xconf_handler.cpp index 6c345a97..7d990d20 100644 --- a/rfcMgr/xconf_handler.cpp +++ b/rfcMgr/xconf_handler.cpp @@ -27,6 +27,7 @@ extern "C" { #include #include #include +#include "mtlsUtils.h" namespace xconf { @@ -46,65 +47,6 @@ int XconfHandler::ExecuteRequest(FileDwnl_t *file_dwnl, MtlsAuth_t *security, in return curl_ret_code; } -std::string getErouterMac() -{ - std::string erouterMac; - - FILE* pipe = popen("dmcli eRT retv Device.DeviceInfo.X_COMCAST-COM_WAN_MAC", "r"); - if (pipe) { - char buffer[128] = {0}; - if (fgets(buffer, sizeof(buffer), pipe) != nullptr) { - erouterMac = buffer; - // Trim trailing newline - if (!erouterMac.empty() && erouterMac.back() == '\n') { - erouterMac.pop_back(); - } - } - pclose(pipe); - } - - return erouterMac; -} - -std::string geteCMMac() -{ - std::string macAddress; - - // Array of commands to try in order - const char* commands[] = { - "dmcli eRT retv Device.DPoE.Mac_address", - "dmcli eRT retv Device.X_CISCO_COM_CableModem.MACAddress", - "dmcli eRT retv Device.DeviceInfo.X_COMCAST-COM_CM_MAC", - "dmcli eRT retv Device.DeviceInfo.X_-COM_WAN_MAC", - "sysevent get eth_wan_mac" - }; - - // Try each command until we get a valid MAC address - for (const auto& command : commands) { - FILE* pipe = popen(command, "r"); - if (pipe) { - char buffer[128] = {0}; - if (fgets(buffer, sizeof(buffer), pipe) != nullptr) { - macAddress = buffer; - // Trim trailing newline - if (!macAddress.empty() && macAddress.back() == '\n') { - macAddress.pop_back(); - } - pclose(pipe); - - // If we got a non-empty result, return it - if (!macAddress.empty()) { - break; - } - } else { - pclose(pipe); - } - } - } - - return macAddress; -} - int XconfHandler:: initializeXconfHandler() { char tmpbuf[200] = {0}; @@ -188,3 +130,4 @@ int XconfHandler:: initializeXconfHandler() #endif +