Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

extern PCCSP_CWMP_CPE_CONTROLLER_OBJECT g_pCcspCwmpCpeController;
extern char* g_Tr069PaOutboundIfName;
extern bool g_is_bridge_mode_enabled;
extern BridgeModeStatus g_bridge_mode_value;


char *CcspManagementServer_ComponentName = NULL;
Expand Down Expand Up @@ -1063,7 +1063,7 @@ ANSC_STATUS CcspManagementServer_GenerateConnectionRequestURL(
int res;
if(!fromValueChangeSignal){
#ifndef NO_PAM_COMP
if (g_is_bridge_mode_enabled) {
if (g_bridge_mode_value == MODE_FULL_BRIDGE) {
bool OutboundIfName_ip_found = false;

struct ifaddrs *if_addrs = NULL;
Expand Down
67 changes: 41 additions & 26 deletions source-embedded/Ssp/ssp_ccsp_cwmp_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include "cJSON.h"
#include "secure_wrapper.h"
#include "sysevent/sysevent.h"
#include "syscfg/syscfg.h"

extern int s_sysevent_connect (token_t *out_se_token);

Expand Down Expand Up @@ -114,7 +115,8 @@ extern char* g_Tr069PaOutboundIfName;
#define CCSP_TR069PA_CFG_Name_AcsDefAddr "Device.DeviceInfo.X_RDKCENTRAL-COM_Syndication.TR69ACSConnectURL"
extern char* g_Tr069PaAcsDefAddr;

bool g_is_bridge_mode_enabled = false;
BridgeModeStatus g_bridge_mode_value = MODE_ROUTER;


#define DEVICE_PROPERTIES "/etc/device.properties"

Expand Down Expand Up @@ -319,6 +321,37 @@ ANSC_STATUS CcspTr069PaSsp_JSON_GetItemByName (
return ANSC_STATUS_SUCCESS;
}

/* Checks bridge_mode sysevent and last_erouter_mode syscfg to distingush between
* full-bridge and pseudo bridge. For pseudo bridge and router mode function returns
* MODE_PSEUDO_BRIDGE, MODE_ROUTER respectively and Full bridge return MODE_FULL_BRIDGE */
static BridgeModeStatus Check_BridgeMode(void)
{
token_t token;
char buf[2] = {'\0'}; /* buffer for string with single digit number */
int sysevent_fd = s_sysevent_connect(&token);
if (sysevent_fd < 0) {
CcspTr069PaTraceError(("%s: sysevent_connect failed!!!\n", __func__));
return MODE_ERROR;
}
if (sysevent_get(sysevent_fd, token, "bridge_mode", buf, sizeof(buf)) != 0) {
CcspTr069PaTraceError(("%s: sysevent_get('bridge_mode') failed!!!\n", __func__));
return MODE_ERROR;
}
CcspTr069PaTraceInfo(("%s: bridge_mode from sysevent = '%s'\n", __func__, buf));
if (strcmp(buf, "2") != 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For router mode it will be zero. this condition will return mode as router for all values other than 2 which may not be proper. please confirm the values

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we checked, the bridge_mode sysevent has a value of 0 in router mode. In bridge mode (both FB and PB modes), it has a value of 2. We haven’t seen any case where this sysevent takes any other value. That is why we added the condition check in this way.
If the suggestion is to explicitly specify and compare against the value 0 for router mode here, we can make that change as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FB and PB will have different values. Please make the check explicit

return MODE_ROUTER;

if (syscfg_get(NULL, "last_erouter_mode", buf, sizeof(buf)) != 0) {
CcspTr069PaTraceError(("%s: syscfg_get('last_erouter_mode') failed!!!\n", __func__));
return MODE_ERROR;
}
CcspTr069PaTraceInfo(("%s: last_erouter_mode from syscfg = '%s'\n", __func__, buf));
if (strcmp(buf, "0") != 0)
return MODE_PSEUDO_BRIDGE;

return MODE_FULL_BRIDGE;
}

ANSC_STATUS
CcspTr069PaSsp_LoadCfgFile
(
Expand Down Expand Up @@ -416,34 +449,16 @@ CcspTr069PaSsp_LoadCfgFile
}

#endif

token_t token;
int sysevent_fd = s_sysevent_connect(&token);
if (sysevent_fd < 0) {
CcspTr069PaTraceError(("%s: sysevent_connect failed!!!\n", __func__));
returnStatus = ANSC_STATUS_FAILURE;
goto EXIT;
} else {
char *entry_name = "bridge_mode";

char buf[2] = {'\0'}; /* buffer for string with single digit number */
if (sysevent_get(sysevent_fd, token, entry_name, buf, sizeof(buf)) == 0) {
CcspTr069PaTraceInfo(("%s: bridge_mode from sysevent = '%s'\n", __func__, buf));

int cmp_result = -1;
strcmp_s(buf, sizeof(buf), "2", &cmp_result);
g_is_bridge_mode_enabled = (cmp_result == 0);
} else {
CcspTr069PaTraceError(("%s: sysevent_get('%s') failed!!!\n", __func__, entry_name));
returnStatus = ANSC_STATUS_FAILURE;
goto EXIT;
}
}

if (g_is_bridge_mode_enabled)
g_bridge_mode_value = Check_BridgeMode();
if (g_bridge_mode_value == MODE_FULL_BRIDGE) {
CcspTr069PaSsp_XML_GetOneItemByName(pRootNode, CCSP_TR069PA_CFG_Name_Outbound_If_Bridge_Mode, &g_Tr069PaOutboundIfName);
else
} else if ((g_bridge_mode_value == MODE_ROUTER) || (g_bridge_mode_value == MODE_PSEUDO_BRIDGE)) {
CcspTr069PaSsp_XML_GetOneItemByName(pRootNode, CCSP_TR069PA_CFG_Name_Outbound_If, &g_Tr069PaOutboundIfName);
} else {
returnStatus = ANSC_STATUS_FAILURE;
goto EXIT;
}

if(ANSC_STATUS_SUCCESS != CcspTr069PaSsp_JSON_GetItemByName(partnerID, CCSP_TR069PA_CFG_Name_AcsDefAddr, &g_Tr069PaAcsDefAddr)) {
returnStatus = ANSC_STATUS_FAILURE;
Expand Down
7 changes: 7 additions & 0 deletions source-embedded/include/ccsp_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ _CCSP_VARIABLE
}
CCSP_VARIABLE, *PCCSP_VARIABLE;

typedef enum
{
MODE_ERROR = -1,
MODE_ROUTER = 0,
MODE_PSEUDO_BRIDGE = 2,
MODE_FULL_BRIDGE = 3
}BridgeModeStatus;

#define CcspVariableInitialize(ccspVar) \
do { \
Expand Down
Loading