From 780483427632befc5c7eb980b847e66b2523fd64 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 12 Aug 2025 08:57:51 +0000 Subject: [PATCH 01/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 --- source/hotspotfd/hotspotfd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 786e9c3..743c914 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -371,8 +371,8 @@ STATIC void notify_tunnel_status(char *status) { CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); } - ret = CcspBaseIf_SendSignal_WithData(bus_handle, - "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); + char *signal_status = (strcmp(status, "Up") == 0) ? "TUNNEL_UP" : "TUNNEL_DOWN"; + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus", signal_status); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", @@ -2115,7 +2115,7 @@ void hotspot_start() } notify_tunnel_status("Up"); if (false == gWebConfTun){ - ret = CcspBaseIf_SendSignal_WithData(bus_handle, "TunnelStatus" , "TUNNEL_UP"); + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus" , "TUNNEL_UP"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2296,7 +2296,7 @@ void hotspot_start() } notify_tunnel_status("Up"); gWebConfTun = false; - ret = CcspBaseIf_SendSignal_WithData(bus_handle, "TunnelStatus" , "TUNNEL_UP"); + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus" , "TUNNEL_UP"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2367,7 +2367,7 @@ void hotspot_start() /*Signal wifi module for tunnel down */ notify_tunnel_status("Down"); - ret = CcspBaseIf_SendSignal_WithData(bus_handle, "TunnelStatus", "TUNNEL_DOWN"); + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus", "TUNNEL_DOWN"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2406,4 +2406,4 @@ void hotspot_start() } goto keep_it_alive; -} +} \ No newline at end of file From 158bc44ef25c255e772d4abc95c5f615b83e4ce7 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Thu, 21 Aug 2025 11:06:41 +0000 Subject: [PATCH 02/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 743c914..3ab85b6 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -371,8 +371,7 @@ STATIC void notify_tunnel_status(char *status) { CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); } - char *signal_status = (strcmp(status, "Up") == 0) ? "TUNNEL_UP" : "TUNNEL_DOWN"; - ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus", signal_status); + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", @@ -2046,13 +2045,22 @@ void hotspot_start() hotspotfd_log(); #ifdef WAN_FAILOVER_SUPPORTED - + rbusDataElement_t dataElements[1] = { + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, NULL, eventSubHandler, NULL}} + }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) { CcspTraceError(("HotspotTunnelEvent : rbus_open failed: %d\n", ret)); return; } + rc = rbus_regDataElements(handle, 1, dataElements); + if(rc != RBUS_ERROR_SUCCESS) + { + CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", rc)); + goto exit1; + } + CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); #endif @@ -2115,7 +2123,7 @@ void hotspot_start() } notify_tunnel_status("Up"); if (false == gWebConfTun){ - ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus" , "TUNNEL_UP"); + ret = CcspBaseIf_SendSignal_WithData(handle, "TunnelStatus" , "TUNNEL_UP"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2296,7 +2304,7 @@ void hotspot_start() } notify_tunnel_status("Up"); gWebConfTun = false; - ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus" , "TUNNEL_UP"); + ret = CcspBaseIf_SendSignal_WithData(handle, "TunnelStatus" , "TUNNEL_UP"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2367,7 +2375,7 @@ void hotspot_start() /*Signal wifi module for tunnel down */ notify_tunnel_status("Down"); - ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "TunnelStatus", "TUNNEL_DOWN"); + ret = CcspBaseIf_SendSignal_WithData(handle, "TunnelStatus", "TUNNEL_DOWN"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); From a04d5b36fd867ca547865a508cee5808a65bae54 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Fri, 22 Aug 2025 05:31:35 +0000 Subject: [PATCH 03/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 3ab85b6..4e36e8e 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -377,6 +377,9 @@ STATIC void notify_tunnel_status(char *status) CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", __FUNCTION__ ,ret)); } + else{ + CcspTraceInfo(("%s : TunnelStatus send rbus data success\n", __FUNCTION__)); + } if(strcmp("Down",status) == 0) { gVapIsUp = false; @@ -2046,7 +2049,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, NULL, eventSubHandler, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, CcspBaseIf_SendSignal_WithData_rbus, NULL, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) @@ -2054,13 +2057,15 @@ void hotspot_start() CcspTraceError(("HotspotTunnelEvent : rbus_open failed: %d\n", ret)); return; } - rc = rbus_regDataElements(handle, 1, dataElements); - if(rc != RBUS_ERROR_SUCCESS) + ret = rbus_regDataElements(handle, 1, dataElements); + if(ret != RBUS_ERROR_SUCCESS) { - CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", rc)); - goto exit1; + CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", ret)); + return; + } + else{ + CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); } - CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); #endif From 4d97df79bb85bd4655ccdfd3ac4bac68219be04e Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Fri, 22 Aug 2025 06:13:45 +0000 Subject: [PATCH 04/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 4e36e8e..85c9ea1 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -2049,7 +2049,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, CcspBaseIf_SendSignal_WithData_rbus, NULL, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, NULL, NULL, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) From d570fe3ffdef71f894ab88cf63039afea57aac5d Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Mon, 25 Aug 2025 09:59:29 +0000 Subject: [PATCH 05/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 46 +++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 85c9ea1..77e3276 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -280,6 +280,50 @@ Hotspotfd_MsgItem hotspotfdMsgArr[] = { #endif }; +char TunnelStatus[128] = {0}; +rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts) +{ + (void)handle; + (void)opts; + + CcspTraceInfo(("In %s\n", __FUNCTION__)); + + //rbus_set + rbusValue_t val; + rbusValue_Init(&val); + rbusValue_SetString(val, TunnelStatus); + rbusProperty_SetValue(property, val); + rbusValue_Release(val); + + CcspTraceInfo(("Out %s\n", __FUNCTION__)); + return RBUS_ERROR_SUCCESS; +} + +rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusSetHandlerOptions_t* opts) +{ + (void)handle; + (void)opts; + + CcspTraceInfo(("In %s\n", __FUNCTION__)); + + rbusValue_t value = rbusProperty_GetValue(property); + const char* newStatus = rbusValue_GetString(value, NULL); + if(newStatus && (strcmp(newStatus, "Up") == 0 || strcmp(newStatus, "Down") == 0)) + { + strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination + CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + } + else + { + CcspTraceError(("Invalid TunnelStatus value: %s\n", newStatus? newStatus : "NULL")); + return RBUS_ERROR_INVALID_INPUT; + } + + CcspTraceInfo(("Out %s\n", __FUNCTION__)); + return RBUS_ERROR_SUCCESS; +} + HotspotfdType Get_HotspotfdType(char * name) { @@ -2049,7 +2093,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, NULL, NULL, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) From abd31166d716fea0794df1f2b3c04e70f43a5e3c Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 26 Aug 2025 09:04:22 +0000 Subject: [PATCH 06/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 77e3276..3828143 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -313,6 +313,7 @@ rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t pr strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + notify_tunnel_status(TunnelStatus); } else { From cf467f94678237006355af34126c52dd45b45ea7 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 26 Aug 2025 10:03:26 +0000 Subject: [PATCH 07/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 91 ++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 3828143..10c34c0 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -195,6 +195,8 @@ rbusHandle_t handle; STATIC pthread_t dhcp_snooper_tid; +char TunnelStatus[128] = {0}; + int gSnoopNumberOfClients = 0; //shared variable across hotspotfd and dhcp_snooperd bool gSnoopEnable = true; @@ -280,51 +282,6 @@ Hotspotfd_MsgItem hotspotfdMsgArr[] = { #endif }; -char TunnelStatus[128] = {0}; -rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts) -{ - (void)handle; - (void)opts; - - CcspTraceInfo(("In %s\n", __FUNCTION__)); - - //rbus_set - rbusValue_t val; - rbusValue_Init(&val); - rbusValue_SetString(val, TunnelStatus); - rbusProperty_SetValue(property, val); - rbusValue_Release(val); - - CcspTraceInfo(("Out %s\n", __FUNCTION__)); - return RBUS_ERROR_SUCCESS; -} - -rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusSetHandlerOptions_t* opts) -{ - (void)handle; - (void)opts; - - CcspTraceInfo(("In %s\n", __FUNCTION__)); - - rbusValue_t value = rbusProperty_GetValue(property); - const char* newStatus = rbusValue_GetString(value, NULL); - if(newStatus && (strcmp(newStatus, "Up") == 0 || strcmp(newStatus, "Down") == 0)) - { - strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); - TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination - CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); - notify_tunnel_status(TunnelStatus); - } - else - { - CcspTraceError(("Invalid TunnelStatus value: %s\n", newStatus? newStatus : "NULL")); - return RBUS_ERROR_INVALID_INPUT; - } - - CcspTraceInfo(("Out %s\n", __FUNCTION__)); - return RBUS_ERROR_SUCCESS; -} - HotspotfdType Get_HotspotfdType(char * name) { @@ -435,6 +392,50 @@ STATIC void notify_tunnel_status(char *status) } } +rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts) +{ + (void)handle; + (void)opts; + + CcspTraceInfo(("In %s\n", __FUNCTION__)); + + //rbus_set + rbusValue_t val; + rbusValue_Init(&val); + rbusValue_SetString(val, TunnelStatus); + rbusProperty_SetValue(property, val); + rbusValue_Release(val); + + CcspTraceInfo(("Out %s\n", __FUNCTION__)); + return RBUS_ERROR_SUCCESS; +} + +rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusSetHandlerOptions_t* opts) +{ + (void)handle; + (void)opts; + + CcspTraceInfo(("In %s\n", __FUNCTION__)); + + rbusValue_t value = rbusProperty_GetValue(property); + const char* newStatus = rbusValue_GetString(value, NULL); + if(newStatus && (strcmp(newStatus, "Up") == 0 || strcmp(newStatus, "Down") == 0)) + { + strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination + CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + notify_tunnel_status(TunnelStatus); + } + else + { + CcspTraceError(("Invalid TunnelStatus value: %s\n", newStatus? newStatus : "NULL")); + return RBUS_ERROR_INVALID_INPUT; + } + + CcspTraceInfo(("Out %s\n", __FUNCTION__)); + return RBUS_ERROR_SUCCESS; +} + STATIC bool set_validatessid() { #if defined(RDK_ONEWIFI) From 181ebd8c393d73e99825f2318b27d97a3f1a4c40 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Wed, 27 Aug 2025 07:33:14 +0000 Subject: [PATCH 08/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 10c34c0..171ca48 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -365,6 +365,16 @@ STATIC bool set_tunnelstatus(char* status) { STATIC void notify_tunnel_status(char *status) { int ret; + static char lastPublishedStatus[128] = {0}; + // Avoid duplicate publishes + if (strcmp(lastPublishedStatus, status) == 0) + { + CcspTraceInfo(("TunnelStatus already published as %s. Skipping publish.\n", status)); + return; + } + strncpy(lastPublishedStatus, status, sizeof(lastPublishedStatus) - 1); + lastPublishedStatus[sizeof(lastPublishedStatus) - 1] = '\0'; + if(set_tunnelstatus(status)) { CcspTraceInfo(("TunnelStatus set to %s in TR181\n", status)); @@ -374,7 +384,11 @@ STATIC void notify_tunnel_status(char *status) CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); } ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); - if ( ret != CCSP_SUCCESS ) + if (ret == RBUS_ERROR_NOSUBSCRIBERS) + { + CcspTraceInfo(("%s : No subscribers for TunnelStatus. Skipping publish.\n", __FUNCTION__)); + } + else if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", __FUNCTION__ ,ret)); From 61731d54233d539e1e48b172c11bc798e57b0268 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Wed, 27 Aug 2025 08:37:50 +0000 Subject: [PATCH 09/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 171ca48..79f2c0c 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -2109,7 +2109,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) From 2e2692ac49f389da2416b23c96491738f31396be Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Wed, 27 Aug 2025 09:56:38 +0000 Subject: [PATCH 10/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 79f2c0c..241a141 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -365,7 +365,7 @@ STATIC bool set_tunnelstatus(char* status) { STATIC void notify_tunnel_status(char *status) { int ret; - static char lastPublishedStatus[128] = {0}; + /*static char lastPublishedStatus[128] = {0}; // Avoid duplicate publishes if (strcmp(lastPublishedStatus, status) == 0) { @@ -374,7 +374,7 @@ STATIC void notify_tunnel_status(char *status) } strncpy(lastPublishedStatus, status, sizeof(lastPublishedStatus) - 1); lastPublishedStatus[sizeof(lastPublishedStatus) - 1] = '\0'; - + */ if(set_tunnelstatus(status)) { CcspTraceInfo(("TunnelStatus set to %s in TR181\n", status)); @@ -438,7 +438,7 @@ rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t pr strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); - notify_tunnel_status(TunnelStatus); + //notify_tunnel_status(TunnelStatus); } else { From 7815fd835e6929f743bf4faa4cb58b8c99eb4830 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Thu, 28 Aug 2025 10:18:27 +0000 Subject: [PATCH 11/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 241a141..75f7ab4 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -365,30 +365,16 @@ STATIC bool set_tunnelstatus(char* status) { STATIC void notify_tunnel_status(char *status) { int ret; - /*static char lastPublishedStatus[128] = {0}; - // Avoid duplicate publishes - if (strcmp(lastPublishedStatus, status) == 0) - { - CcspTraceInfo(("TunnelStatus already published as %s. Skipping publish.\n", status)); - return; - } - strncpy(lastPublishedStatus, status, sizeof(lastPublishedStatus) - 1); - lastPublishedStatus[sizeof(lastPublishedStatus) - 1] = '\0'; - */ - if(set_tunnelstatus(status)) + /*if(set_tunnelstatus(status)) { CcspTraceInfo(("TunnelStatus set to %s in TR181\n", status)); } else { CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); - } + }*/ ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); - if (ret == RBUS_ERROR_NOSUBSCRIBERS) - { - CcspTraceInfo(("%s : No subscribers for TunnelStatus. Skipping publish.\n", __FUNCTION__)); - } - else if ( ret != CCSP_SUCCESS ) + if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", __FUNCTION__ ,ret)); @@ -413,7 +399,7 @@ rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t pr CcspTraceInfo(("In %s\n", __FUNCTION__)); - //rbus_set + //set value rbusValue_t val; rbusValue_Init(&val); rbusValue_SetString(val, TunnelStatus); @@ -435,10 +421,15 @@ rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t pr const char* newStatus = rbusValue_GetString(value, NULL); if(newStatus && (strcmp(newStatus, "Up") == 0 || strcmp(newStatus, "Down") == 0)) { - strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); - TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination - CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); - //notify_tunnel_status(TunnelStatus); + if(strcmp(TunnelStatus, newStatus) != 0){ + strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination + CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + notify_tunnel_status(TunnelStatus); + } + else{ + CcspTraceInfo(("TunnelStatus is already %s, no change needed\n", TunnelStatus)); + } } else { From 365fadafef0f0acf7c8f4caf3c5a514385f6dea7 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Fri, 29 Aug 2025 04:44:48 +0000 Subject: [PATCH 12/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 2 ++ source/hotspotfd/include/hotspotfd.h | 2 +- source/test/HotspotFdTest/HotspotFdTest.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 75f7ab4..e12caba 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -310,6 +310,7 @@ HotspotfdType Get_HotspotfdType(char * name) return HOTSPOTFD_ERROR; } +#if 0 STATIC bool set_tunnelstatus(char* status) { CCSP_MESSAGE_BUS_INFO *bus_info = (CCSP_MESSAGE_BUS_INFO *)bus_handle; @@ -361,6 +362,7 @@ STATIC bool set_tunnelstatus(char* status) { } return TRUE; } +#endif STATIC void notify_tunnel_status(char *status) { diff --git a/source/hotspotfd/include/hotspotfd.h b/source/hotspotfd/include/hotspotfd.h index 59fecf4..864b937 100644 --- a/source/hotspotfd/include/hotspotfd.h +++ b/source/hotspotfd/include/hotspotfd.h @@ -137,7 +137,7 @@ bool deleteSharedMem(int key, bool snooper); void hotspot_start(); #ifdef UNIT_TEST_DOCKER_SUPPORT -bool set_tunnelstatus(char* status); +//bool set_tunnelstatus(char* status); void notify_tunnel_status(char *status); bool set_validatessid(); bool get_validate_ssid(); diff --git a/source/test/HotspotFdTest/HotspotFdTest.cpp b/source/test/HotspotFdTest/HotspotFdTest.cpp index bc96166..b31d290 100755 --- a/source/test/HotspotFdTest/HotspotFdTest.cpp +++ b/source/test/HotspotFdTest/HotspotFdTest.cpp @@ -414,7 +414,7 @@ TEST_F(HotspotFdTestFixture, deleteSharedMem_CASE_2) { EXPECT_EQ(true, result); } -TEST_F(HotspotFdTestFixture, set_tunnelstatus) { +/*TEST_F(HotspotFdTestFixture, set_tunnelstatus) { bool result; char status[] = "Up"; char mockFaultParam[] = "TRUE"; @@ -466,7 +466,7 @@ TEST_F(HotspotFdTestFixture, notify_tunnel_status_DOWN) { .Times(1).WillOnce(Return(CCSP_SUCCESS)); notify_tunnel_status(status); -} +}*/ TEST_F(HotspotFdTestFixture, set_validatessid_CASE1) { bool result; From 9e0eac40f2cb44131732d88a286713d3a9bc68ce Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Fri, 29 Aug 2025 09:07:18 +0000 Subject: [PATCH 13/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index e12caba..43ff4f0 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -400,7 +400,14 @@ rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t pr (void)opts; CcspTraceInfo(("In %s\n", __FUNCTION__)); - + + // Initialize default if empty + if (TunnelStatus[0] == '\0') { + strncpy(TunnelStatus, "Up", sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; + CcspTraceInfo(("TunnelStatus defaulted to Up\n")); + } + //set value rbusValue_t val; rbusValue_Init(&val); @@ -2119,6 +2126,7 @@ void hotspot_start() else{ CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); } + sleep(1); pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); #endif From 56e852c7ca08ef50f0def4b13d5de78b71562aaf Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 2 Sep 2025 05:17:18 +0000 Subject: [PATCH 14/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 43ff4f0..8f00e57 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -375,6 +375,11 @@ STATIC void notify_tunnel_status(char *status) { CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); }*/ + + strncpy(TunnelStatus, status, sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination + CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); if ( ret != CCSP_SUCCESS ) { @@ -401,13 +406,6 @@ rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t pr CcspTraceInfo(("In %s\n", __FUNCTION__)); - // Initialize default if empty - if (TunnelStatus[0] == '\0') { - strncpy(TunnelStatus, "Up", sizeof(TunnelStatus) - 1); - TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; - CcspTraceInfo(("TunnelStatus defaulted to Up\n")); - } - //set value rbusValue_t val; rbusValue_Init(&val); @@ -431,9 +429,7 @@ rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t pr if(newStatus && (strcmp(newStatus, "Up") == 0 || strcmp(newStatus, "Down") == 0)) { if(strcmp(TunnelStatus, newStatus) != 0){ - strncpy(TunnelStatus, newStatus, sizeof(TunnelStatus) - 1); - TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination - CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + CcspTraceInfo(("Calling notify_tunnel_status\n")); notify_tunnel_status(TunnelStatus); } else{ @@ -2109,7 +2105,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) @@ -2189,7 +2185,7 @@ void hotspot_start() } notify_tunnel_status("Up"); if (false == gWebConfTun){ - ret = CcspBaseIf_SendSignal_WithData(handle, "TunnelStatus" , "TUNNEL_UP"); + ret = CcspBaseIf_SendSignal_WithData(bus_handle, "TunnelStatus" , "TUNNEL_UP"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2370,7 +2366,7 @@ void hotspot_start() } notify_tunnel_status("Up"); gWebConfTun = false; - ret = CcspBaseIf_SendSignal_WithData(handle, "TunnelStatus" , "TUNNEL_UP"); + ret = CcspBaseIf_SendSignal_WithData(bus_handle, "TunnelStatus" , "TUNNEL_UP"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); @@ -2441,7 +2437,7 @@ void hotspot_start() /*Signal wifi module for tunnel down */ notify_tunnel_status("Down"); - ret = CcspBaseIf_SendSignal_WithData(handle, "TunnelStatus", "TUNNEL_DOWN"); + ret = CcspBaseIf_SendSignal_WithData(bus_handle, "TunnelStatus", "TUNNEL_DOWN"); if ( ret != CCSP_SUCCESS ) { CcspTraceError(("%s : TunnelStatus send data failed, ret value is %d\n",__FUNCTION__ ,ret)); From de9ec24ab82ee8eb5479b7b6d15aa318141f0b97 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 2 Sep 2025 09:01:45 +0000 Subject: [PATCH 15/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 8f00e57..fe369c5 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -2105,7 +2105,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) From 26bfbe017ef4401546623e254b11388292ebe8eb Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 2 Sep 2025 10:13:17 +0000 Subject: [PATCH 16/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 6 +- source/test/HotspotFdTest/HotspotFdTest.cpp | 161 +++++++++++++++++--- 2 files changed, 141 insertions(+), 26 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index fe369c5..24a04b9 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -376,8 +376,8 @@ STATIC void notify_tunnel_status(char *status) CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); }*/ - strncpy(TunnelStatus, status, sizeof(TunnelStatus) - 1); - TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; // Ensure null termination + strncpy(TunnelStatus, status, strlen(status)); + TunnelStatus[strlen(status)] = '\0'; // Ensure null termination CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); @@ -430,7 +430,7 @@ rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t pr { if(strcmp(TunnelStatus, newStatus) != 0){ CcspTraceInfo(("Calling notify_tunnel_status\n")); - notify_tunnel_status(TunnelStatus); + notify_tunnel_status((char *)newStatus); } else{ CcspTraceInfo(("TunnelStatus is already %s, no change needed\n", TunnelStatus)); diff --git a/source/test/HotspotFdTest/HotspotFdTest.cpp b/source/test/HotspotFdTest/HotspotFdTest.cpp index b31d290..852d40b 100755 --- a/source/test/HotspotFdTest/HotspotFdTest.cpp +++ b/source/test/HotspotFdTest/HotspotFdTest.cpp @@ -430,44 +430,159 @@ TEST_F(HotspotFdTestFixture, deleteSharedMem_CASE_2) { result = set_tunnelstatus(status); EXPECT_EQ(true, result); -} +}*/ + +/*STATIC void notify_tunnel_status(char *status) +{ + int ret; + strncpy(TunnelStatus, status, strlen(status)); + TunnelStatus[strlen(status)] = '\0'; // Ensure null termination + CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + + ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); + if ( ret != CCSP_SUCCESS ) + { + CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", + __FUNCTION__ ,ret)); + } + else{ + CcspTraceInfo(("%s : TunnelStatus send rbus data success\n", __FUNCTION__)); + } + if(strcmp("Down",status) == 0) + { + gVapIsUp = false; + } + else if(strcmp("Up",status) == 0) + { + gVapIsUp = true; + } +}*/ + +//give gtest for notify_tunnel_status function -TEST_F(HotspotFdTestFixture, notify_tunnel_status_UP) { +TEST_F(HotspotFdTestFixture, notify_tunnel_status_SUCCESS) { char status[] = "Up"; - char mockFaultParam[] = "TRUE"; - EXPECT_CALL(*g_anscWrapperApiMock, AnscCloneString(status)).Times(1).WillOnce(Return(status)); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_setParameterValues(_, _, _, _, _, _, _, _, _)) + EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq(status))) .Times(1) - .WillOnce(testing::DoAll( - testing::WithArg<8>([&](char** faultParam){ - *faultParam = mockFaultParam; - }), - Return(CCSP_SUCCESS))); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), _)) - .Times(1).WillOnce(Return(CCSP_SUCCESS)); + .WillOnce(Return(CCSP_SUCCESS)); notify_tunnel_status(status); } -TEST_F(HotspotFdTestFixture, notify_tunnel_status_DOWN) { +TEST_F(HotspotFdTestFixture, notify_tunnel_status_FAIL) { char status[] = "Down"; - char mockFaultParam[] = "False"; - EXPECT_CALL(*g_anscWrapperApiMock, AnscCloneString(status)).Times(1).WillOnce(Return(status)); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_setParameterValues(_, _, _, _, _, _, _, _, _)) + EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq(status))) .Times(1) - .WillOnce(testing::DoAll( - testing::WithArg<8>([&](char** faultParam){ - *faultParam = mockFaultParam; - }), - Return(CCSP_SUCCESS))); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), _)) - .Times(1).WillOnce(Return(CCSP_SUCCESS)); + .WillOnce(Return(1)); notify_tunnel_status(status); +} + +/*rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts) +{ + (void)handle; + (void)opts; + + CcspTraceInfo(("In %s\n", __FUNCTION__)); + + //set value + rbusValue_t val; + rbusValue_Init(&val); + rbusValue_SetString(val, TunnelStatus); + rbusProperty_SetValue(property, val); + rbusValue_Release(val); + + CcspTraceInfo(("Out %s\n", __FUNCTION__)); + return RBUS_ERROR_SUCCESS; }*/ +//give gtest for TunnelStatus_GetStringHandler function + +TEST_F(HotspotFdTestFixture, TunnelStatus_GetStringHandler) { + rbusHandle_t handle = nullptr; + rbusProperty_t property; + rbusGetHandlerOptions_t* opts = nullptr; + + // Initialize property + rbusProperty_Init(&property, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"); + + // Set TunnelStatus to a mock value + strncpy(TunnelStatus, "Up", sizeof(TunnelStatus)); + + rbusError_t result = TunnelStatus_GetStringHandler(handle, property, opts); + + // Verify the result + EXPECT_EQ(RBUS_ERROR_SUCCESS, result); + + // Verify the value set in the property + rbusValue_t val = rbusProperty_GetValue(property); + const char* strValue = rbusValue_GetString(val, NULL); + EXPECT_STREQ("Up", strValue); + + // Release property + rbusProperty_Release(property); +} + +TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_SUCCESS) { + rbusHandle_t handle = nullptr; + rbusProperty_t property; + rbusSetHandlerOptions_t* opts = nullptr; + + // Initialize property with new status "Up" + rbusProperty_Init(&property, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"); + rbusValue_t val; + rbusValue_Init(&val); + rbusValue_SetString(val, "Up"); + rbusProperty_SetValue(property, val); + rbusValue_Release(val); + + // Set initial TunnelStatus to "Down" + strncpy(TunnelStatus, "Down", sizeof(TunnelStatus)); + + EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq("Up"))) + .Times(1) + .WillOnce(Return(CCSP_SUCCESS)); + + rbusError_t result = TunnelStatus_SetStringHandler(handle, property, opts); + + // Verify the result + EXPECT_EQ(RBUS_ERROR_SUCCESS, result); + + // Release property + rbusProperty_Release(property); +} + +TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_FAIL) { + rbusHandle_t handle = nullptr; + rbusProperty_t property; + rbusSetHandlerOptions_t* opts = nullptr; + + // Initialize property with new status "Down" + rbusProperty_Init(&property, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"); + rbusValue_t val; + rbusValue_Init(&val); + rbusValue_SetString(val, "Down"); + rbusProperty_SetValue(property, val); + rbusValue_Release(val); + + // Set initial TunnelStatus to "Up" + strncpy(TunnelStatus, "Up", sizeof(TunnelStatus)); + + EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq("Down"))) + .Times(1) + .WillOnce(Return(1)); + + rbusError_t result = TunnelStatus_SetStringHandler(handle, property, opts); + + // Verify the result + EXPECT_EQ(RBUS_ERROR_BUS_ERROR, result); + + // Release property + rbusProperty_Release(property); +} + TEST_F(HotspotFdTestFixture, set_validatessid_CASE1) { bool result; char mockValue[] = "false"; From 15da7bfba96123777698cac41df147fe597340eb Mon Sep 17 00:00:00 2001 From: Foosball18 Date: Fri, 28 Nov 2025 09:03:41 +0000 Subject: [PATCH 17/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 --- source/hotspotfd/hotspotfd.c | 42 +++-- source/hotspotfd/include/hotspotfd.h | 2 + source/test/HotspotFdTest/HotspotFdTest.cpp | 199 +++++++++----------- source/test/HotspotFdTest/Makefile.am | 6 +- source/test/mocks/mock_hotspotApi.cpp | 16 ++ source/test/mocks/mock_hotspotApi.h | 4 + 6 files changed, 144 insertions(+), 125 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 24a04b9..f2a7360 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -366,29 +366,35 @@ STATIC bool set_tunnelstatus(char* status) { STATIC void notify_tunnel_status(char *status) { - int ret; - /*if(set_tunnelstatus(status)) - { - CcspTraceInfo(("TunnelStatus set to %s in TR181\n", status)); - } - else - { - CcspTraceError(("Error setting TunnelStatus in TR181 Data Model\n")); - }*/ + rbusEvent_t event; + rbusObject_t data; + rbusValue_t value; + rbusError_t ret; - strncpy(TunnelStatus, status, strlen(status)); - TunnelStatus[strlen(status)] = '\0'; // Ensure null termination + strncpy(TunnelStatus, status, sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); - ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); - if ( ret != CCSP_SUCCESS ) - { - CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", - __FUNCTION__ ,ret)); + rbusValue_Init(&value); + rbusValue_SetString(value, status); + rbusObject_Init(&data, NULL); + rbusObject_SetValue(data, "TunnelStatus", value); + + event.name = "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"; + event.type = RBUS_EVENT_GENERAL; + event.data = data; + + ret = rbusEvent_Publish(handle, &event); + if(ret != RBUS_ERROR_SUCCESS) { + CcspTraceError(("rbusEvent_Publish failed: %d\n", ret)); } - else{ - CcspTraceInfo(("%s : TunnelStatus send rbus data success\n", __FUNCTION__)); + else { + CcspTraceInfo(("rbusEvent_Publish success\n")); } + + rbusValue_Release(value); + rbusObject_Release(data); + if(strcmp("Down",status) == 0) { gVapIsUp = false; diff --git a/source/hotspotfd/include/hotspotfd.h b/source/hotspotfd/include/hotspotfd.h index 864b937..36b18a2 100644 --- a/source/hotspotfd/include/hotspotfd.h +++ b/source/hotspotfd/include/hotspotfd.h @@ -138,6 +138,8 @@ void hotspot_start(); #ifdef UNIT_TEST_DOCKER_SUPPORT //bool set_tunnelstatus(char* status); +rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts); +rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusSetHandlerOptions_t* opts); void notify_tunnel_status(char *status); bool set_validatessid(); bool get_validate_ssid(); diff --git a/source/test/HotspotFdTest/HotspotFdTest.cpp b/source/test/HotspotFdTest/HotspotFdTest.cpp index 852d40b..300526c 100755 --- a/source/test/HotspotFdTest/HotspotFdTest.cpp +++ b/source/test/HotspotFdTest/HotspotFdTest.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "test/mocks/mock_hotspotApi.h" extern "C" { @@ -69,6 +70,7 @@ SecureWrapperMock * g_securewrapperMock = nullptr; HotspotApiMock * g_hotspotApiMock = nullptr; NfQueueMock * g_nfQueueMock = nullptr; SocketMock * g_socketMock = nullptr; +rbusMock *g_rbusMock = nullptr; class HotspotFdTestFixture : public ::testing::Test { protected: @@ -85,6 +87,7 @@ class HotspotFdTestFixture : public ::testing::Test { HotspotApiMock mockedHotspotApi; NfQueueMock mockedNfQueue; SocketMock mockedSocket; + rbusMock mockedRbus; HotspotFdTestFixture() { @@ -104,6 +107,7 @@ class HotspotFdTestFixture : public ::testing::Test { g_hotspotApiMock = &mockedHotspotApi; g_nfQueueMock = &mockedNfQueue; g_socketMock = &mockedSocket; + g_rbusMock = &mockedRbus; } virtual ~HotspotFdTestFixture() { @@ -120,6 +124,7 @@ class HotspotFdTestFixture : public ::testing::Test { g_hotspotApiMock = nullptr; g_nfQueueMock = nullptr; g_socketMock = nullptr; + g_rbusMock = nullptr; } virtual void SetUp() @@ -149,6 +154,8 @@ class HotspotFdTestFixture : public ::testing::Test { } }; +extern char TunnelStatus[128]; + void createFile(const char* fname) { if ((file = fopen(fname, "r"))) { fclose(file); @@ -432,157 +439,139 @@ TEST_F(HotspotFdTestFixture, deleteSharedMem_CASE_2) { EXPECT_EQ(true, result); }*/ -/*STATIC void notify_tunnel_status(char *status) -{ - int ret; - strncpy(TunnelStatus, status, strlen(status)); - TunnelStatus[strlen(status)] = '\0'; // Ensure null termination - CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); - - ret = CcspBaseIf_SendSignal_WithData_rbus(handle, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", status); - if ( ret != CCSP_SUCCESS ) - { - CcspTraceError(("%s : TunnelStatus send rbus data failed, ret value is %d\n", - __FUNCTION__ ,ret)); - } - else{ - CcspTraceInfo(("%s : TunnelStatus send rbus data success\n", __FUNCTION__)); - } - if(strcmp("Down",status) == 0) - { - gVapIsUp = false; - } - else if(strcmp("Up",status) == 0) - { - gVapIsUp = true; - } -}*/ - -//give gtest for notify_tunnel_status function - -TEST_F(HotspotFdTestFixture, notify_tunnel_status_SUCCESS) { +TEST_F(HotspotFdTestFixture, notify_tunnel_status) { char status[] = "Up"; - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq(status))) - .Times(1) - .WillOnce(Return(CCSP_SUCCESS)); + EXPECT_CALL(*g_rbusMock, rbusValue_Init(_)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusValue_SetString(_, StrEq(status))).Times(1); + EXPECT_CALL(*g_rbusMock, rbusObject_Init(_, nullptr)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusObject_SetValue(_, StrEq("TunnelStatus"), _)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusEvent_Publish(_, _)).Times(1).WillOnce(Return(RBUS_ERROR_SUCCESS)); + EXPECT_CALL(*g_rbusMock, rbusValue_Release(_)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusObject_Release(_)).Times(1); notify_tunnel_status(status); + + EXPECT_STREQ("Up", TunnelStatus); + EXPECT_EQ(true, gVapIsUp); } -TEST_F(HotspotFdTestFixture, notify_tunnel_status_FAIL) { +TEST_F(HotspotFdTestFixture, notify_tunnel_status_Down) { char status[] = "Down"; - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq(status))) - .Times(1) - .WillOnce(Return(1)); + EXPECT_CALL(*g_rbusMock, rbusValue_Init(_)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusValue_SetString(_, StrEq(status))).Times(1); + EXPECT_CALL(*g_rbusMock, rbusObject_Init(_, nullptr)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusObject_SetValue(_, StrEq("TunnelStatus"), _)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusEvent_Publish(_, _)).Times(1).WillOnce(Return(RBUS_ERROR_SUCCESS)); + EXPECT_CALL(*g_rbusMock, rbusValue_Release(_)).Times(1); + EXPECT_CALL(*g_rbusMock, rbusObject_Release(_)).Times(1); notify_tunnel_status(status); -} -/*rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts) -{ - (void)handle; - (void)opts; - - CcspTraceInfo(("In %s\n", __FUNCTION__)); - - //set value - rbusValue_t val; - rbusValue_Init(&val); - rbusValue_SetString(val, TunnelStatus); - rbusProperty_SetValue(property, val); - rbusValue_Release(val); - - CcspTraceInfo(("Out %s\n", __FUNCTION__)); - return RBUS_ERROR_SUCCESS; -}*/ - -//give gtest for TunnelStatus_GetStringHandler function + EXPECT_STREQ("Down", TunnelStatus); + EXPECT_EQ(false, gVapIsUp); +} TEST_F(HotspotFdTestFixture, TunnelStatus_GetStringHandler) { rbusHandle_t handle = nullptr; - rbusProperty_t property; + rbusProperty_t property = reinterpret_cast(0x1); // dummy non-null rbusGetHandlerOptions_t* opts = nullptr; - // Initialize property - rbusProperty_Init(&property, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"); + strncpy(TunnelStatus, "Up", sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; - // Set TunnelStatus to a mock value - strncpy(TunnelStatus, "Up", sizeof(TunnelStatus)); + EXPECT_CALL(*g_rbusMock, rbusValue_Init(_)) + .Times(1); + + EXPECT_CALL(*g_rbusMock, rbusValue_SetString(_, StrEq("Up"))) + .Times(1); + + EXPECT_CALL(*g_rbusMock, rbusProperty_SetValue(property, _)) + .Times(1); + + EXPECT_CALL(*g_rbusMock, rbusValue_Release(_)) + .Times(1); rbusError_t result = TunnelStatus_GetStringHandler(handle, property, opts); - // Verify the result EXPECT_EQ(RBUS_ERROR_SUCCESS, result); +} + +TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_ValidChange) { + rbusHandle_t handle = nullptr; + rbusProperty_t property = reinterpret_cast(0x1); + rbusSetHandlerOptions_t* opts = nullptr; + + strncpy(TunnelStatus, "Down", sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; + + rbusValue_t val = reinterpret_cast(0x2); + + EXPECT_CALL(*g_rbusMock, rbusProperty_GetValue(property)) + .Times(1) + .WillOnce(Return(val)); + + EXPECT_CALL(*g_rbusMock, rbusValue_GetString(val, _)) + .Times(1) + .WillOnce(Return("Up")); - // Verify the value set in the property - rbusValue_t val = rbusProperty_GetValue(property); - const char* strValue = rbusValue_GetString(val, NULL); - EXPECT_STREQ("Up", strValue); + rbusError_t result = TunnelStatus_SetStringHandler(handle, property, opts); - // Release property - rbusProperty_Release(property); + EXPECT_EQ(RBUS_ERROR_SUCCESS, result); + EXPECT_STREQ("Up", TunnelStatus); } -TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_SUCCESS) { +TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_InvalidValue) { rbusHandle_t handle = nullptr; - rbusProperty_t property; + rbusProperty_t property = reinterpret_cast(0x1); rbusSetHandlerOptions_t* opts = nullptr; - // Initialize property with new status "Up" - rbusProperty_Init(&property, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"); - rbusValue_t val; - rbusValue_Init(&val); - rbusValue_SetString(val, "Up"); - rbusProperty_SetValue(property, val); - rbusValue_Release(val); + strncpy(TunnelStatus, "Down", sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; - // Set initial TunnelStatus to "Down" - strncpy(TunnelStatus, "Down", sizeof(TunnelStatus)); + rbusValue_t val = reinterpret_cast(0x2); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq("Up"))) - .Times(1) - .WillOnce(Return(CCSP_SUCCESS)); + EXPECT_CALL(*g_rbusMock, rbusProperty_GetValue(property)) + .Times(1) + .WillOnce(Return(val)); + + EXPECT_CALL(*g_rbusMock, rbusValue_GetString(val, _)) + .Times(1) + .WillOnce(Return("InvalidStatus")); rbusError_t result = TunnelStatus_SetStringHandler(handle, property, opts); - // Verify the result - EXPECT_EQ(RBUS_ERROR_SUCCESS, result); + EXPECT_EQ(RBUS_ERROR_INVALID_INPUT, result); + EXPECT_STREQ("Down", TunnelStatus); - // Release property - rbusProperty_Release(property); } -TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_FAIL) { +TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_NoChange) { rbusHandle_t handle = nullptr; - rbusProperty_t property; + rbusProperty_t property = reinterpret_cast(0x1); rbusSetHandlerOptions_t* opts = nullptr; - // Initialize property with new status "Down" - rbusProperty_Init(&property, "Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"); - rbusValue_t val; - rbusValue_Init(&val); - rbusValue_SetString(val, "Down"); - rbusProperty_SetValue(property, val); - rbusValue_Release(val); + strncpy(TunnelStatus, "Up", sizeof(TunnelStatus) - 1); + TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; - // Set initial TunnelStatus to "Up" - strncpy(TunnelStatus, "Up", sizeof(TunnelStatus)); + rbusValue_t val = reinterpret_cast(0x2); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_SendSignal_WithData_rbus(_, StrEq("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"), StrEq("Down"))) - .Times(1) - .WillOnce(Return(1)); + EXPECT_CALL(*g_rbusMock, rbusProperty_GetValue(property)) + .Times(1) + .WillOnce(Return(val)); - rbusError_t result = TunnelStatus_SetStringHandler(handle, property, opts); + EXPECT_CALL(*g_rbusMock, rbusValue_GetString(val, _)) + .Times(1) + .WillOnce(Return("Up")); - // Verify the result - EXPECT_EQ(RBUS_ERROR_BUS_ERROR, result); + rbusError_t result = TunnelStatus_SetStringHandler(handle, property, opts); - // Release property - rbusProperty_Release(property); + EXPECT_EQ(RBUS_ERROR_SUCCESS, result); + EXPECT_STREQ("Up", TunnelStatus); } + TEST_F(HotspotFdTestFixture, set_validatessid_CASE1) { bool result; char mockValue[] = "false"; diff --git a/source/test/HotspotFdTest/Makefile.am b/source/test/HotspotFdTest/Makefile.am index 2eee3cc..7701090 100755 --- a/source/test/HotspotFdTest/Makefile.am +++ b/source/test/HotspotFdTest/Makefile.am @@ -32,7 +32,8 @@ HotspotFd_gtest_bin_CPPFLAGS = -I$(PKG_CONFIG_SYSROOT_DIR)$(includedir)/gtest \ -I${top_srcdir}/source/util \ -I${top_srcdir}/source/hotspotfd/include \ -I$(PKG_CONFIG_SYSROOT_DIR)$(includedir)/ccsp \ - -DUNIT_TEST_DOCKER_SUPPORT + -DUNIT_TEST_DOCKER_SUPPORT \ + -DWAN_FAILOVER_SUPPORTED HotspotFd_gtest_bin_SOURCES = ${top_builddir}/source/hotspotfd/cosa_hotspot_dml.c \ ${top_builddir}/source/hotspotfd/dhcpsnooper.c \ @@ -52,7 +53,8 @@ HotspotFd_gtest_bin_LDADD = $(HOME)/usr/local/lib/libmock_ccsp_common.la \ $(HOME)/usr/local/lib/libmock_file_io.la \ $(HOME)/usr/local/lib/libmock_secure_wrapper.la \ $(HOME)/usr/local/lib/libmock_nfqueue.la \ - $(HOME)/usr/local/lib/libmock_socket.la + $(HOME)/usr/local/lib/libmock_socket.la \ + $(HOME)/usr/local/lib/libmock_rbus.la #Code Coverage Flags AM_CFLAGS += -fprofile-arcs -ftest-coverage diff --git a/source/test/mocks/mock_hotspotApi.cpp b/source/test/mocks/mock_hotspotApi.cpp index e2686a2..72f1544 100644 --- a/source/test/mocks/mock_hotspotApi.cpp +++ b/source/test/mocks/mock_hotspotApi.cpp @@ -37,4 +37,20 @@ extern "C" void recreate_tunnel() { return; } return g_hotspotApiMock->recreate_tunnel(); +} + +extern "C" int PsmGet(const char *param, char *value, int size) { + if (!g_hotspotApiMock) + { + return -1; + } + return g_hotspotApiMock->PsmGet(param, value, size); +} + +extern "C" int hotspot_wan_failover(bool remote_wan_enabled) { + if (!g_hotspotApiMock) + { + return -1; + } + return g_hotspotApiMock->hotspot_wan_failover(remote_wan_enabled); } \ No newline at end of file diff --git a/source/test/mocks/mock_hotspotApi.h b/source/test/mocks/mock_hotspotApi.h index 930fc3b..647234b 100644 --- a/source/test/mocks/mock_hotspotApi.h +++ b/source/test/mocks/mock_hotspotApi.h @@ -25,6 +25,8 @@ class HotspotApiInterface { virtual ~HotspotApiInterface() {} virtual int ipAddress_version(char*) = 0; virtual void recreate_tunnel() = 0; + virtual int PsmGet(const char *param, char *value, int size) = 0; + virtual int hotspot_wan_failover(bool) = 0; }; class HotspotApiMock: public HotspotApiInterface { @@ -32,4 +34,6 @@ class HotspotApiMock: public HotspotApiInterface { virtual ~HotspotApiMock() {} MOCK_METHOD1(ipAddress_version, int(char*)); MOCK_METHOD0(recreate_tunnel, void()); + MOCK_METHOD3(PsmGet, int(const char *param, char *value, int size)); + MOCK_METHOD1(hotspot_wan_failover, int(bool)); }; \ No newline at end of file From aabc40ffc9078c48a839fce37b6ae5c89c80de6f Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Thu, 13 Nov 2025 02:32:24 +0000 Subject: [PATCH 18/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 92 +++++---------------- source/hotspotfd/include/hotspotfd.h | 1 - source/test/HotspotFdTest/HotspotFdTest.cpp | 18 ---- 3 files changed, 19 insertions(+), 92 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index f2a7360..7426ad2 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -195,7 +195,7 @@ rbusHandle_t handle; STATIC pthread_t dhcp_snooper_tid; -char TunnelStatus[128] = {0}; +char TunnelStatus[8] = {0}; int gSnoopNumberOfClients = 0; //shared variable across hotspotfd and dhcp_snooperd @@ -310,60 +310,6 @@ HotspotfdType Get_HotspotfdType(char * name) return HOTSPOTFD_ERROR; } -#if 0 -STATIC bool set_tunnelstatus(char* status) { - - CCSP_MESSAGE_BUS_INFO *bus_info = (CCSP_MESSAGE_BUS_INFO *)bus_handle; - parameterValStruct_t *param_val = NULL; - char component[256] = "eRT.com.cisco.spvtg.ccsp.pam"; - char dstPath[64]="/com/cisco/spvtg/ccsp/pam"; - const char tunparam[]="Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus"; - char* faultParam = NULL; - int ret = 0; - - param_val = (parameterValStruct_t*)malloc(sizeof(parameterValStruct_t)); - if (NULL == param_val) - { - CcspTraceError(("Memory allocation failed in hotspot \n")); - return FALSE; - } - - param_val->parameterName = (char*)tunparam; - param_val->parameterValue=AnscCloneString(status); - CcspTraceInfo(("Setting tunnel status to %s\n", status)); - param_val->type = ccsp_string; - - ret = CcspBaseIf_setParameterValues( - bus_handle, - component, - dstPath, - 0, - 0, - param_val, - 1, - TRUE, - &faultParam - ); - - if( ( ret != CCSP_SUCCESS ) && ( faultParam!=NULL )) { - CcspTraceError(("TunnelStatus set bus failed\n")); - bus_info->freefunc( faultParam ); - if(param_val) - { - free(param_val); - param_val = NULL; - } - return FALSE; - } - if(param_val) - { - free(param_val); - param_val = NULL; - } - return TRUE; -} -#endif - STATIC void notify_tunnel_status(char *status) { rbusEvent_t event; @@ -373,7 +319,7 @@ STATIC void notify_tunnel_status(char *status) strncpy(TunnelStatus, status, sizeof(TunnelStatus) - 1); TunnelStatus[sizeof(TunnelStatus) - 1] = '\0'; - CcspTraceInfo(("TunnelStatus is set to %s\n", TunnelStatus)); + CcspTraceInfo(("%s:%d : TunnelStatus set to %s\n", __FUNCTION__, __LINE__, TunnelStatus)); rbusValue_Init(&value); rbusValue_SetString(value, status); @@ -385,11 +331,12 @@ STATIC void notify_tunnel_status(char *status) event.data = data; ret = rbusEvent_Publish(handle, &event); + if(ret != RBUS_ERROR_SUCCESS) { - CcspTraceError(("rbusEvent_Publish failed: %d\n", ret)); - } + CcspTraceError(("%s:%d : rbusEvent_Publish failed: %d\n", __FUNCTION__, __LINE__, ret)); + } else { - CcspTraceInfo(("rbusEvent_Publish success\n")); + CcspTraceInfo(("%s:%d : rbusEvent_Publish success\n", __FUNCTION__, __LINE__)); } rbusValue_Release(value); @@ -409,8 +356,6 @@ rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t pr { (void)handle; (void)opts; - - CcspTraceInfo(("In %s\n", __FUNCTION__)); //set value rbusValue_t val; @@ -419,7 +364,6 @@ rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t pr rbusProperty_SetValue(property, val); rbusValue_Release(val); - CcspTraceInfo(("Out %s\n", __FUNCTION__)); return RBUS_ERROR_SUCCESS; } @@ -427,29 +371,31 @@ rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t pr { (void)handle; (void)opts; - - CcspTraceInfo(("In %s\n", __FUNCTION__)); + + int ret = RBUS_ERROR_SUCCESS; rbusValue_t value = rbusProperty_GetValue(property); const char* newStatus = rbusValue_GetString(value, NULL); + if(newStatus && (strcmp(newStatus, "Up") == 0 || strcmp(newStatus, "Down") == 0)) { if(strcmp(TunnelStatus, newStatus) != 0){ - CcspTraceInfo(("Calling notify_tunnel_status\n")); + + CcspTraceInfo(("%s:%d : Calling notify_tunnel_status with %s\n", __FUNCTION__, __LINE__, newStatus)); + notify_tunnel_status((char *)newStatus); } else{ - CcspTraceInfo(("TunnelStatus is already %s, no change needed\n", TunnelStatus)); + CcspTraceInfo(("%s:%d : TunnelStatus is already %s, no change\n", __FUNCTION__, __LINE__, TunnelStatus)); } } else { - CcspTraceError(("Invalid TunnelStatus value: %s\n", newStatus? newStatus : "NULL")); - return RBUS_ERROR_INVALID_INPUT; + CcspTraceError(("%s:%d : Invalid TunnelStatus value: %s\n", __FUNCTION__, __LINE__, newStatus ? newStatus : "NULL")); + ret = RBUS_ERROR_INVALID_INPUT; } - CcspTraceInfo(("Out %s\n", __FUNCTION__)); - return RBUS_ERROR_SUCCESS; + return ret; } STATIC bool set_validatessid() { @@ -2122,13 +2068,13 @@ void hotspot_start() ret = rbus_regDataElements(handle, 1, dataElements); if(ret != RBUS_ERROR_SUCCESS) { - CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", ret)); + CcspTraceError(("%d : Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", __LINE__, ret)); return; } else{ - CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); + CcspTraceInfo(("%d : Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus", __LINE__)); } - sleep(1); + pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); #endif diff --git a/source/hotspotfd/include/hotspotfd.h b/source/hotspotfd/include/hotspotfd.h index 36b18a2..53f46e3 100644 --- a/source/hotspotfd/include/hotspotfd.h +++ b/source/hotspotfd/include/hotspotfd.h @@ -137,7 +137,6 @@ bool deleteSharedMem(int key, bool snooper); void hotspot_start(); #ifdef UNIT_TEST_DOCKER_SUPPORT -//bool set_tunnelstatus(char* status); rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts); rbusError_t TunnelStatus_SetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusSetHandlerOptions_t* opts); void notify_tunnel_status(char *status); diff --git a/source/test/HotspotFdTest/HotspotFdTest.cpp b/source/test/HotspotFdTest/HotspotFdTest.cpp index 300526c..6e6fc92 100755 --- a/source/test/HotspotFdTest/HotspotFdTest.cpp +++ b/source/test/HotspotFdTest/HotspotFdTest.cpp @@ -421,24 +421,6 @@ TEST_F(HotspotFdTestFixture, deleteSharedMem_CASE_2) { EXPECT_EQ(true, result); } -/*TEST_F(HotspotFdTestFixture, set_tunnelstatus) { - bool result; - char status[] = "Up"; - char mockFaultParam[] = "TRUE"; - - EXPECT_CALL(*g_anscWrapperApiMock, AnscCloneString(status)).Times(1).WillOnce(Return(status)); - EXPECT_CALL(*g_baseapiMock, CcspBaseIf_setParameterValues(_, _, _, _, _, _, _, _, _)) - .Times(1) - .WillOnce(testing::DoAll( - testing::WithArg<8>([&](char** faultParam){ - *faultParam = mockFaultParam; - }), - Return(CCSP_SUCCESS))); - - result = set_tunnelstatus(status); - EXPECT_EQ(true, result); -}*/ - TEST_F(HotspotFdTestFixture, notify_tunnel_status) { char status[] = "Up"; From 2c504b64b800fd5fc053ff3a02d3d65c55e3d3f7 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Tue, 18 Nov 2025 10:34:22 +0000 Subject: [PATCH 19/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 23 +++++++++++++++++++++ source/test/HotspotFdTest/HotspotFdTest.cpp | 1 - 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 7426ad2..ecff5d9 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -2027,6 +2027,29 @@ void hotspot_start() CcspTraceError(("Error while getting startup parameters\n")); hotspotfd_SignalHandler(0); } +#endif +#ifdef WAN_FAILOVER_SUPPORTED + rbusDataElement_t dataElements[1] = { + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} + }; + ret = rbus_open(&handle, "HotspotTunnelEvent"); + if(ret != RBUS_ERROR_SUCCESS) + { + CcspTraceError(("HotspotTunnelEvent : rbus_open failed: %d\n", ret)); + return; + } + ret = rbus_regDataElements(handle, 1, dataElements); + if(ret != RBUS_ERROR_SUCCESS) + { + CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", ret)); + return; + } + else{ + CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); + } + sleep(1); + pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); + #endif pthread_create(&sysevent_tid, NULL, hotspotfd_sysevent_handler, NULL); } else { diff --git a/source/test/HotspotFdTest/HotspotFdTest.cpp b/source/test/HotspotFdTest/HotspotFdTest.cpp index 6e6fc92..8c32df3 100755 --- a/source/test/HotspotFdTest/HotspotFdTest.cpp +++ b/source/test/HotspotFdTest/HotspotFdTest.cpp @@ -553,7 +553,6 @@ TEST_F(HotspotFdTestFixture, TunnelStatus_SetStringHandler_NoChange) { EXPECT_STREQ("Up", TunnelStatus); } - TEST_F(HotspotFdTestFixture, set_validatessid_CASE1) { bool result; char mockValue[] = "false"; From d70236f8e2fc5f56c19e80c8c77692daced13122 Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Fri, 21 Nov 2025 08:55:36 +0000 Subject: [PATCH 20/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified Risks: Low Priority: P2 Signed-off-by:SupriyaShree_SS@comcast.com --- source/hotspotfd/hotspotfd.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index ecff5d9..59e55bf 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -2027,29 +2027,6 @@ void hotspot_start() CcspTraceError(("Error while getting startup parameters\n")); hotspotfd_SignalHandler(0); } -#endif -#ifdef WAN_FAILOVER_SUPPORTED - rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} - }; - ret = rbus_open(&handle, "HotspotTunnelEvent"); - if(ret != RBUS_ERROR_SUCCESS) - { - CcspTraceError(("HotspotTunnelEvent : rbus_open failed: %d\n", ret)); - return; - } - ret = rbus_regDataElements(handle, 1, dataElements); - if(ret != RBUS_ERROR_SUCCESS) - { - CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", ret)); - return; - } - else{ - CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); - } - sleep(1); - pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); - #endif pthread_create(&sysevent_tid, NULL, hotspotfd_sysevent_handler, NULL); } else { @@ -2091,17 +2068,15 @@ void hotspot_start() ret = rbus_regDataElements(handle, 1, dataElements); if(ret != RBUS_ERROR_SUCCESS) { - CcspTraceError(("%d : Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", __LINE__, ret)); + CcspTraceError(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus rbus_regDataElements failed: %d\n", ret)); return; } else{ - CcspTraceInfo(("%d : Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus", __LINE__)); + CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); } - pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); #endif - if (sysevent_set(sysevent_fd_gs, sysevent_token_gs, kHotspotfd_tunnelEP, kDefault_DummyEP, 0)) { CcspTraceError(("sysevent set %s failed for %s\n", kHotspotfd_tunnelEP, kDefault_DummyEP)); From df2800f5889c830810fe46e6b5eee453626b1ddc Mon Sep 17 00:00:00 2001 From: Supriya Shree Date: Mon, 15 Dec 2025 07:18:03 +0000 Subject: [PATCH 21/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: notify_tunnel_status fails in hotspot Test Procedure: TunnelStatus should get notified successfully Risks: Low Priority: P2 --- source/test/HotspotFdTest/HotspotFdTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/test/HotspotFdTest/HotspotFdTest.cpp b/source/test/HotspotFdTest/HotspotFdTest.cpp index 8c32df3..17417a6 100755 --- a/source/test/HotspotFdTest/HotspotFdTest.cpp +++ b/source/test/HotspotFdTest/HotspotFdTest.cpp @@ -154,7 +154,7 @@ class HotspotFdTestFixture : public ::testing::Test { } }; -extern char TunnelStatus[128]; +extern char TunnelStatus[8]; void createFile(const char* fname) { if ((file = fopen(fname, "r"))) { From 46848245d121dd64d14a7af3d0929208f1d2f61a Mon Sep 17 00:00:00 2001 From: Rajkamal CV Date: Mon, 12 Jan 2026 10:18:18 +0530 Subject: [PATCH 22/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: TunnelStatus_EventSubHandler has been added. autoPublish set to false. Test Procedure: TunnelStatus should get notified successfully Risks: Low Priority: P2 --- source/hotspotfd/hotspotfd.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 59e55bf..2c6677d 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -352,6 +352,20 @@ STATIC void notify_tunnel_status(char *status) } } +rbusError_t TunnelStatus_EventSubHandler(rbusHandle_t handle, rbusEventSubAction_t action, const char* eventName, + rbusFilter_t filter, int32_t interval, bool* autoPublish) +{ + (void)handle; + (void)filter; + (void)interval; + + CcspTraceInfo(("%d: %s %s\n", __LINE__, eventName, + action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribed" : "unsubscribed")); + + *autoPublish = false; + return RBUS_ERROR_SUCCESS; +} + rbusError_t TunnelStatus_GetStringHandler(rbusHandle_t handle, rbusProperty_t property, rbusGetHandlerOptions_t* opts) { (void)handle; @@ -2057,7 +2071,7 @@ void hotspot_start() #ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { - {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, NULL, NULL}} + {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, TunnelStatus_EventSubHandler, NULL}} }; ret = rbus_open(&handle, "HotspotTunnelEvent"); if(ret != RBUS_ERROR_SUCCESS) @@ -2426,4 +2440,4 @@ void hotspot_start() } goto keep_it_alive; -} \ No newline at end of file +} From 4828add9fde392e0bd06fc61378ca7382db729dd Mon Sep 17 00:00:00 2001 From: Rajkamal CV Date: Mon, 12 Jan 2026 15:28:17 +0530 Subject: [PATCH 23/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: Remove WAN_FAILOVER_SUPPORTED macro to address the review comment Test Procedure: TunnelStatus should get notified successfully Risks: Low Priority: P2 --- source/hotspotfd/hotspotfd.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 2c6677d..f6dccc0 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -61,9 +61,7 @@ #include "ansc_platform.h" #include "libHotspot.h" #include "libHotspotApi.h" -#ifdef WAN_FAILOVER_SUPPORTED #include -#endif #ifdef __HAVE_SYSEVENT_STARTUP_PARAMS__ #include @@ -189,9 +187,9 @@ STATIC char old_wan_ipv6[kMax_IPAddressLength]; #ifdef WAN_FAILOVER_SUPPORTED extern int hotspot_wan_failover(bool isRemoteWANEnabled); extern int PsmGet(const char *param, char *value, int size); +#endif STATIC pthread_t rbus_tid; rbusHandle_t handle; -#endif STATIC pthread_t dhcp_snooper_tid; @@ -1957,8 +1955,6 @@ STATIC int hotspotfd_getStartupParameters(void) } #endif -#ifdef WAN_FAILOVER_SUPPORTED - STATIC void HotspotTunnelEventHandler( rbusHandle_t handle, rbusEvent_t const* event, @@ -1985,9 +1981,7 @@ STATIC void HotspotTunnelEventHandler( } } } -#endif -#ifdef WAN_FAILOVER_SUPPORTED void *handle_rbusSubscribe() { int ret = 0; bool retry_again = true; @@ -2011,7 +2005,6 @@ void *handle_rbusSubscribe() { } return NULL; } -#endif void hotspot_start() { @@ -2069,7 +2062,6 @@ void hotspot_start() v_secure_system("touch /tmp/hotspotfd_up"); hotspotfd_log(); -#ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, TunnelStatus_EventSubHandler, NULL}} }; @@ -2090,7 +2082,6 @@ void hotspot_start() } pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); -#endif if (sysevent_set(sysevent_fd_gs, sysevent_token_gs, kHotspotfd_tunnelEP, kDefault_DummyEP, 0)) { CcspTraceError(("sysevent set %s failed for %s\n", kHotspotfd_tunnelEP, kDefault_DummyEP)); From 87dcfcd4610746e371c2923af50459d9b02fc0c0 Mon Sep 17 00:00:00 2001 From: Rajkamal CV Date: Wed, 14 Jan 2026 07:02:43 +0530 Subject: [PATCH 24/25] Revert "RDKB-60325 : notify_tunnel_status failure in hotspot" This reverts commit 4828add9fde392e0bd06fc61378ca7382db729dd. --- source/hotspotfd/hotspotfd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index f6dccc0..2c6677d 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -61,7 +61,9 @@ #include "ansc_platform.h" #include "libHotspot.h" #include "libHotspotApi.h" +#ifdef WAN_FAILOVER_SUPPORTED #include +#endif #ifdef __HAVE_SYSEVENT_STARTUP_PARAMS__ #include @@ -187,9 +189,9 @@ STATIC char old_wan_ipv6[kMax_IPAddressLength]; #ifdef WAN_FAILOVER_SUPPORTED extern int hotspot_wan_failover(bool isRemoteWANEnabled); extern int PsmGet(const char *param, char *value, int size); -#endif STATIC pthread_t rbus_tid; rbusHandle_t handle; +#endif STATIC pthread_t dhcp_snooper_tid; @@ -1955,6 +1957,8 @@ STATIC int hotspotfd_getStartupParameters(void) } #endif +#ifdef WAN_FAILOVER_SUPPORTED + STATIC void HotspotTunnelEventHandler( rbusHandle_t handle, rbusEvent_t const* event, @@ -1981,7 +1985,9 @@ STATIC void HotspotTunnelEventHandler( } } } +#endif +#ifdef WAN_FAILOVER_SUPPORTED void *handle_rbusSubscribe() { int ret = 0; bool retry_again = true; @@ -2005,6 +2011,7 @@ void *handle_rbusSubscribe() { } return NULL; } +#endif void hotspot_start() { @@ -2062,6 +2069,7 @@ void hotspot_start() v_secure_system("touch /tmp/hotspotfd_up"); hotspotfd_log(); +#ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, TunnelStatus_EventSubHandler, NULL}} }; @@ -2082,6 +2090,7 @@ void hotspot_start() } pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); +#endif if (sysevent_set(sysevent_fd_gs, sysevent_token_gs, kHotspotfd_tunnelEP, kDefault_DummyEP, 0)) { CcspTraceError(("sysevent set %s failed for %s\n", kHotspotfd_tunnelEP, kDefault_DummyEP)); From 7176717bd7963d9c104ec8f4c0814fc9563f11ba Mon Sep 17 00:00:00 2001 From: Rajkamal CV Date: Wed, 14 Jan 2026 01:22:12 +0000 Subject: [PATCH 25/25] RDKB-60325 : notify_tunnel_status failure in hotspot Reason for change: 1. Modify WAN_FAILOVER_SUPPORTED macro to address the review comment 2. Ensure rbus is linked even when WAN_FAILOVER_SUPPORTED macro is not defined Test Procedure: TunnelStatus should get notified successfully Risks: Low Priority: P2 --- source/hotspotfd/Makefile.am | 5 ++--- source/hotspotfd/hotspotfd.c | 9 ++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/source/hotspotfd/Makefile.am b/source/hotspotfd/Makefile.am index 4c286bb..8e1f70a 100644 --- a/source/hotspotfd/Makefile.am +++ b/source/hotspotfd/Makefile.am @@ -23,14 +23,13 @@ AM_CFLAGS += -I$(top_srcdir)/source/include AM_CFLAGS += -I$(top_srcdir)/source/util AM_CFLAGS += -I$(top_srcdir)/source/hotspotfd/include AM_CFLAGS += -I$(top_srcdir)/source/HotspotApi +AM_CFLAGS += -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/rbus -AM_LDFLAGS = -lpthread -lz -lsysevent -lsyscfg -lulog -llmapi -lnetfilter_queue -lnfnetlink -lccsp_common -ltelemetry_msgsender -lsecure_wrapper -lprivilege +AM_LDFLAGS = -lpthread -lz -lsysevent -lsyscfg -lulog -llmapi -lnetfilter_queue -lnfnetlink -lccsp_common -ltelemetry_msgsender -lsecure_wrapper -lprivilege -lrbus CcspHotspot_SOURCES = hotspotfd.c dhcpsnooper.c ssp_messagebus_interface.c ssp_main.c ssp_action.c cosa_hotspot_dml.c plugin_main.c dm_pack_datamodel.c if FEATURE_WAN_FAIL_OVER -AM_CFLAGS += -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/rbus AM_CFLAGS += -DWAN_FAILOVER_SUPPORTED -AM_LDFLAGS += -lrbus endif CcspHotspot_LDADD = ${top_builddir}/source/HotspotApi/libHotspotApi.la diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 2c6677d..836682b 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -61,9 +61,7 @@ #include "ansc_platform.h" #include "libHotspot.h" #include "libHotspotApi.h" -#ifdef WAN_FAILOVER_SUPPORTED #include -#endif #ifdef __HAVE_SYSEVENT_STARTUP_PARAMS__ #include @@ -190,8 +188,8 @@ STATIC char old_wan_ipv6[kMax_IPAddressLength]; extern int hotspot_wan_failover(bool isRemoteWANEnabled); extern int PsmGet(const char *param, char *value, int size); STATIC pthread_t rbus_tid; -rbusHandle_t handle; #endif +rbusHandle_t handle; STATIC pthread_t dhcp_snooper_tid; @@ -1985,9 +1983,7 @@ STATIC void HotspotTunnelEventHandler( } } } -#endif -#ifdef WAN_FAILOVER_SUPPORTED void *handle_rbusSubscribe() { int ret = 0; bool retry_again = true; @@ -2069,7 +2065,6 @@ void hotspot_start() v_secure_system("touch /tmp/hotspotfd_up"); hotspotfd_log(); -#ifdef WAN_FAILOVER_SUPPORTED rbusDataElement_t dataElements[1] = { {"Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus", RBUS_ELEMENT_TYPE_EVENT | RBUS_ELEMENT_TYPE_PROPERTY, {TunnelStatus_GetStringHandler, TunnelStatus_SetStringHandler, NULL, NULL, TunnelStatus_EventSubHandler, NULL}} }; @@ -2088,8 +2083,8 @@ void hotspot_start() else{ CcspTraceInfo(("Device.X_COMCAST-COM_GRE.Tunnel.1.TunnelStatus is registered in rbus")); } +#ifdef WAN_FAILOVER_SUPPORTED pthread_create(&rbus_tid, NULL, handle_rbusSubscribe, NULL); - #endif if (sysevent_set(sysevent_fd_gs, sysevent_token_gs, kHotspotfd_tunnelEP, kDefault_DummyEP, 0)) {