Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rfcMgr/mtlsUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rfcMgr/rfc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions rfcMgr/rfc_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 26 additions & 9 deletions rfcMgr/rfc_xconf_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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";
}
Expand All @@ -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";
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rfcMgr/rfc_xconf_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
61 changes: 2 additions & 59 deletions rfcMgr/xconf_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
#include <rdk_fwdl_utils.h>
#include <downloadUtil.h>
#include <common_device_api.h>
#include "mtlsUtils.h"

namespace xconf {

Expand All @@ -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};
Expand Down Expand Up @@ -188,3 +130,4 @@ int XconfHandler:: initializeXconfHandler()

#endif