Skip to content
Draft
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
Empty file added AUTHORS
Empty file.
Empty file added ChangeLog
Empty file.
Empty file added NEWS
Empty file.
46 changes: 46 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
This folder contains utilities for the RFC. Following utilities are present
_______________________________________________________________
rfctool
---------------------------------------------------------------

This tool is used to parse json message and extract all list files into specified folders.
The following variables are used in this case
RFC_LIST_FILE_NAME_PREFIX - This will be used to to provide the prefix to file name
RFC_LIST_FILE_NAME_SUFFIX - The suffix part
RFC_PATH - The RFC directory

The tool will extract all list items present in the root folder of each object and store it
as
RFC_PATH/RFC_LIST_FILE_NAME_PREFIX<<listType>>RFC_LIST_FILE_NAME_SUFFIX
where listype is taken from the name of the list present in json
a sample form of json will be

{
"name": "SNMP2WL",
"effectiveImmediate": false,
"enable": true,
"configData": {

},
"listType": "SNMPIPv4",
"listSize": 2,
"SNMP IP4 WL": ["128.82.34.17",
"10.0.0.32/6"]
}

_______________________________________________________________
tr181Set
---------------------------------------------------------------
This utility is used to set a parameter for host interface using iarm tool
The usage will be

Usage : tr181Set [-g] [-d] [-s] [-v value] ParamName
-g get operation
-s set operation
-d enable debug
-v value of parameter
If -s option is set -v is mandatory, otherwise -g option is default

if you need just the parameter value for get operation use following format
tr181Set param 1>/dev/null

49 changes: 49 additions & 0 deletions rfcMgr/gtest/gtest_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,55 @@ TEST(rfcMgrTest, checkWhoamiSupport) {
EXPECT_EQ(result, true);
}

TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dev) {
writeToTr181storeFile("BUILD_TYPE", "dev", "/tmp/device.properties", Plain);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
bool result = rfcObj->isSecureDbgSrvUnlocked();
delete rfcObj;
EXPECT_EQ(result, true);
}

TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_true) {
writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain);
writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain);
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted);
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "true", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
bool result = rfcObj->isSecureDbgSrvUnlocked();
delete rfcObj;
EXPECT_EQ(result, true);
}

TEST(rfcMgrTest, isSecureDbgSrvUnlocked_prod) {
writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain);
writeToTr181storeFile("LABSIGNED_ENABLED", "false", "/tmp/device.properties", Plain);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
bool result = rfcObj->isSecureDbgSrvUnlocked();
delete rfcObj;
EXPECT_EQ(result, false);
}

TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dType_prod) {
writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain);
writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain);
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "prod", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
bool result = rfcObj->isSecureDbgSrvUnlocked();
delete rfcObj;
EXPECT_EQ(result, false);
}

TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_DbgSrv_false) {
writeToTr181storeFile("BUILD_TYPE", "prod", "/tmp/device.properties", Plain);
writeToTr181storeFile("LABSIGNED_ENABLED", "true", "/tmp/device.properties", Plain);
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType", "test", "/opt/secure/RFC/tr181store.ini", Quoted);
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "false", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
bool result = rfcObj->isSecureDbgSrvUnlocked();
delete rfcObj;
EXPECT_EQ(result, false);
}

TEST(rfcMgrTest, isDebugServicesEnabled) {
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable", "true", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
Expand Down
68 changes: 64 additions & 4 deletions rfcMgr/rfc_xconf_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,40 @@ extern "C" {
#define MTLS_FAILURE -1
#endif

bool RuntimeFeatureControlProcessor::isSecureDbgSrvUnlocked(void) {
bool isDebugServicesUnlocked = false; // return value

if (_ebuild_type == eDEV) {
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Enabling Debug Services\n", __FUNCTION__, __LINE__);
isDebugServicesUnlocked = true;
}
else if (_ebuild_type == ePROD)
{
char deviceType[16] = {0};
char value[8] = {0};
bool dbgServices = isDebugServicesEnabled(); // check debug services enabled from RFC
getDeviceTypeRFC(deviceType, sizeof(deviceType));
int ret = getDevicePropertyData("LABSIGNED_ENABLED", value, sizeof(value));
if (ret != 1) {
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "[%s][%d] Failed to get LABSIGNED_ENABLED property. Status: %d\n", __FUNCTION__, __LINE__, ret);
return isDebugServicesUnlocked;
}
if ((strcasecmp(value, "true") == 0) && (strcasecmp(deviceType, "test") == 0) && dbgServices)
{
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Enabling Debug Services\n", __FUNCTION__, __LINE__);
isDebugServicesUnlocked = true;
}
else
{
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] unable to enable Debug Services\n", __FUNCTION__, __LINE__);
}
}
return isDebugServicesUnlocked;
}

int RuntimeFeatureControlProcessor:: InitializeRuntimeFeatureControlProcessor(void)
{
std::string rfc_file;
bool dbgServices = isDebugServicesEnabled();

int rc = GetBootstrapXconfUrl(_boot_strap_xconf_url);
if(rc != 0)
Expand All @@ -63,7 +93,7 @@ int RuntimeFeatureControlProcessor:: InitializeRuntimeFeatureControlProcessor(vo

GetRFCPartnerID();

if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && (_ebuild_type != ePROD || dbgServices == true))
if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && (isSecureDbgSrvUnlocked()))
{
rfc_file = RFC_PROPERTIES_PERSISTENCE_FILE;
rfc_state = Local;
Expand Down Expand Up @@ -154,6 +184,36 @@ bool RuntimeFeatureControlProcessor::isDebugServicesEnabled(void)
return result;
}

void RuntimeFeatureControlProcessor::getDeviceTypeRFC(char *deviceType, size_t size)
{
if (deviceType == NULL || size == 0){
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "[%s][%d] Error, invalid arguments passed!!!\n", __FUNCTION__, __LINE__);
return;
}

const char* type = "unknown";
char rfc_data[RFC_VALUE_BUF_SIZE] = {0};
strncpy(deviceType, type, size - 1);
deviceType[size - 1] = '\0';
int ret = read_RFCProperty("LABSGND", RFC_DEVICETYPE, rfc_data, sizeof(rfc_data));

if (ret == -1) {
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "[%s][%d] rfc device type =%s failed Status %d\n", __FUNCTION__, __LINE__, RFC_DEVICETYPE, ret);
return;
}

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] rfc device type = %s\n", __FUNCTION__, __LINE__, rfc_data);

if (strncasecmp(rfc_data, "prod", 4) == 0) {
type = "prod";
} else if (strncasecmp(rfc_data, "test", 4) == 0) {
type = "test";
}

strncpy(deviceType, type, size - 1);
deviceType[size - 1] = '\0';
}


bool RuntimeFeatureControlProcessor::IsNewFirmwareFirstRequest(void)
{
Expand Down Expand Up @@ -1532,13 +1592,13 @@ int RuntimeFeatureControlProcessor::ProcessRuntimeFeatureControlReq()
int result = FAILURE;

bool skip_direct = IsDirectBlocked();
bool dbgServices = isDebugServicesEnabled();
bool isDebugServicesUnlocked = isSecureDbgSrvUnlocked();

if(skip_direct == false)
{
while(retries < RETRY_COUNT)
{
if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && (_ebuild_type != ePROD || dbgServices == true))
if((filePresentCheck(RFC_PROPERTIES_PERSISTENCE_FILE) == RDK_API_SUCCESS) && isDebugServicesUnlocked)
{
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Setting URL from local override to %s\n", __FUNCTION__, __LINE__, _xconf_server_url.c_str());
NotifyTelemetry2Value("SYST_INFO_RFC_XconflocalURL", _xconf_server_url.c_str());
Expand Down
8 changes: 8 additions & 0 deletions rfcMgr/rfc_xconf_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ extern "C" {
#define TR181STOREFILE "/opt/secure/RFC/tr181store.ini"
#define DIRECT_BLOCK_FILENAME "/tmp/.lastdirectfail_rfc"
#define RFC_DEBUGSRV "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable"
#define RFC_DEVICETYPE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType"

#define RFC_VIDEO_CONTROL_ID 2504
#define RFC_VIDEO_VOD_ID 15660
Expand Down Expand Up @@ -108,6 +109,7 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler
bool getRebootRequirement();
void NotifyTelemetry2Count(std ::string markerName);
void NotifyTelemetry2Value(std ::string markerName, std ::string value);
bool isSecureDbgSrvUnlocked(void);

private:

Expand Down Expand Up @@ -205,6 +207,7 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler
void cleanAllFile();
int ProcessXconfUrl(const char *XconfUrl);
bool isDebugServicesEnabled(void);
void getDeviceTypeRFC(char *deviceType, size_t size);

#if defined(GTEST_ENABLE)
FRIEND_TEST(rfcMgrTest, isNewFirmwareFirstRequest);
Expand All @@ -228,6 +231,11 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler
FRIEND_TEST(rfcMgrTest, cleanAllFile);
FRIEND_TEST(rfcMgrTest, checkWhoamiSupport);
FRIEND_TEST(rfcMgrTest, isDebugServicesEnabled);
FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dev);
FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_true);
FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_prod);
FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_dType_prod);
FRIEND_TEST(rfcMgrTest, isSecureDbgSrvUnlocked_labsigned_DbgSrv_false);
FRIEND_TEST(rfcMgrTest, isMaintenanceEnabled);
FRIEND_TEST(rfcMgrTest, GetOsClass);
FRIEND_TEST(rfcMgrTest, set_RFCProperty);
Expand Down
Loading