From f6ea8fc4a27df6992d317b9bee942af9c02edaf1 Mon Sep 17 00:00:00 2001 From: rhegde114 Date: Thu, 4 Dec 2025 13:40:32 -0800 Subject: [PATCH 1/5] Description: Deauth hotspot client when client gets private ip address due to DHCP failure Changes: 1. Added Rbus event handler to moniter event from hotspot component in case of DHCP failure 2. push the event to queue to kick associated client when event is received --- include/wifi_base.h | 1 + source/core/wifi_ctrl.h | 1 + source/core/wifi_ctrl_rbus_handlers.c | 48 +++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/wifi_base.h b/include/wifi_base.h index f3a397649..675f851b2 100644 --- a/include/wifi_base.h +++ b/include/wifi_base.h @@ -79,6 +79,7 @@ extern "C" { #define WIFI_COLLECT_STATS_ASSOC_DEVICE_STATS "Device.WiFi.CollectStats.AccessPoint.{i}.AssociatedDeviceStats" #define WIFI_NOTIFY_DENY_TCM_ASSOCIATION "Device.WiFi.ConnectionControl.TcmClientDenyAssociation" #define WIFI_CSA_BEACON_FRAME_RECEIVED "Device.WiFi.CSABeaconFrameRecieved" +#define WIFI_PRIVATE_HOTSPOT_CLIENT_IP "Device.VAP.X_RDK_IpAddr" //added only for poc purpose #define WIFI_STUCK_DETECT_FILE_NAME "/nvram/wifi_stuck_detect" #ifdef CONFIG_IEEE80211BE diff --git a/source/core/wifi_ctrl.h b/source/core/wifi_ctrl.h index 8c22807fb..cf3e6355b 100644 --- a/source/core/wifi_ctrl.h +++ b/source/core/wifi_ctrl.h @@ -245,6 +245,7 @@ typedef struct wifi_ctrl { bool marker_list_config_subscribed; bool wifi_sta_2g_status_subscribed; bool wifi_sta_5g_status_subscribed; + bool privateHotspotIPSubscribed; bool eth_bh_status_subscribed; bool mesh_keep_out_chans_subscribed; wifiapi_t wifiapi; diff --git a/source/core/wifi_ctrl_rbus_handlers.c b/source/core/wifi_ctrl_rbus_handlers.c index 569c73ec3..98a8ae220 100644 --- a/source/core/wifi_ctrl_rbus_handlers.c +++ b/source/core/wifi_ctrl_rbus_handlers.c @@ -1623,6 +1623,43 @@ static void wifi_sta_5g_status_handler(char *event_name, raw_data_t *p_data, voi } #endif +static void handlePrivateHotspotClientDisconnect(char *event_name, raw_data_t *p_data, void *userData) +{ + (void)userData; + char *pTmp = NULL; + char mac[64] = {0}; + int index = 0; + char tmp_str[120]; + + wifi_util_dbg_print(WIFI_CTRL, "%s:%d Received event:%s with data type:%x\n", __func__, __LINE__, + event_name, p_data->data_type); + + pTmp = (char *)p_data->raw_data.bytes; + + if((strcmp(event_name, WIFI_PRIVATE_HOTSPOT_CLIENT_IP) != 0) || (pTmp == NULL)) { + wifi_util_info_print(WIFI_CTRL,"%s:%d Invalid event received,%s:%x\n", __func__, __LINE__, event_name, p_data->data_type); + return; + } + // Find the position of the underscore + char *tmp = strchr(pTmp, '_'); + if (tmp != NULL) { + // Copy MAC (characters before '_') + size_t mac_len = tmp - pTmp; + strncpy(mac, pTmp, mac_len); + mac[mac_len] = '\0'; + + // Convert index (characters after '_') to integer + index = atoi(tmp + 1); + } else { + wifi_util_error_print(WIFI_CTRL, "%s:%d Invalid format:\n", __func__, __LINE__); + return; + + } + memset(tmp_str, 0, sizeof(tmp_str)); + snprintf(tmp_str, sizeof(tmp_str), "%d-%s-0", (index-1),mac); + push_event_to_ctrl_queue(tmp_str, (strlen(tmp_str) + 1), wifi_event_type_command, wifi_event_type_command_kick_assoc_devices, NULL); +} + #if defined(RDKB_EXTENDER_ENABLED) static void eth_bh_status_handler(char *event_name, raw_data_t *p_data, void *userData) { @@ -2003,6 +2040,17 @@ void bus_subscribe_events(wifi_ctrl_t *ctrl) } } #endif + if(ctrl->privateHotspotIPSubscribed == false) { + if (bus_desc->bus_event_subs_fn(&ctrl->handle, WIFI_PRIVATE_HOTSPOT_CLIENT_IP,handlePrivateHotspotClientDisconnect, NULL, + 0) != bus_error_success) { + wifi_util_info_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe fail\n", + __FUNCTION__, __LINE__, WIFI_PRIVATE_HOTSPOT_CLIENT_IP); + } else { + ctrl->privateHotspotIPSubscribed = true; + wifi_util_info_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe success\n", + __FUNCTION__, __LINE__, WIFI_PRIVATE_HOTSPOT_CLIENT_IP); + } + } } bus_error_t get_sta_connection_timeout(char *name, raw_data_t *p_data, bus_user_data_t *user_data) From 2e12713bd1ddcb837124c6c206eef14259992c33 Mon Sep 17 00:00:00 2001 From: rhegde114 Date: Mon, 29 Dec 2025 15:21:44 -0800 Subject: [PATCH 2/5] Description: Deauth hotspot client when client gets private ip address due to DHCP failure Changes: 1. Added Rbus event handler to moniter event from hotspot component in case of DHCP failure 2. push the event to queue to kick associated client when event is received --- include/wifi_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wifi_base.h b/include/wifi_base.h index 675f851b2..d8d38706c 100644 --- a/include/wifi_base.h +++ b/include/wifi_base.h @@ -79,7 +79,7 @@ extern "C" { #define WIFI_COLLECT_STATS_ASSOC_DEVICE_STATS "Device.WiFi.CollectStats.AccessPoint.{i}.AssociatedDeviceStats" #define WIFI_NOTIFY_DENY_TCM_ASSOCIATION "Device.WiFi.ConnectionControl.TcmClientDenyAssociation" #define WIFI_CSA_BEACON_FRAME_RECEIVED "Device.WiFi.CSABeaconFrameRecieved" -#define WIFI_PRIVATE_HOTSPOT_CLIENT_IP "Device.VAP.X_RDK_IpAddr" //added only for poc purpose +#define WIFI_PRIVATE_HOTSPOT_CLIENT_IP "Device.X_COMCAST-COM_GRE.Hotspot.RejectAssociatedClient" #define WIFI_STUCK_DETECT_FILE_NAME "/nvram/wifi_stuck_detect" #ifdef CONFIG_IEEE80211BE From 3c5715fc38f73df3be4537423cb7c1f6a9120fb9 Mon Sep 17 00:00:00 2001 From: Raghavendra Hegde <92532009+rhegde114@users.noreply.github.com> Date: Thu, 29 Jan 2026 10:40:10 -0800 Subject: [PATCH 3/5] Description: Deauth hotspot client when client gets private ip address due to DHCP failure Changes: 1. Added Rbus event handler to moniter event from hotspot component in case of DHCP failure 2. push the event to queue to kick associated client when event is received --- include/wifi_base.h | 2 +- source/core/wifi_ctrl.h | 2 +- source/core/wifi_ctrl_rbus_handlers.c | 29 ++++++++++++++++----------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/wifi_base.h b/include/wifi_base.h index 2d27ed825..d259746c8 100644 --- a/include/wifi_base.h +++ b/include/wifi_base.h @@ -79,7 +79,7 @@ extern "C" { #define WIFI_COLLECT_STATS_ASSOC_DEVICE_STATS "Device.WiFi.CollectStats.AccessPoint.{i}.AssociatedDeviceStats" #define WIFI_NOTIFY_DENY_TCM_ASSOCIATION "Device.WiFi.ConnectionControl.TcmClientDenyAssociation" #define WIFI_CSA_BEACON_FRAME_RECEIVED "Device.WiFi.CSABeaconFrameRecieved" -#define WIFI_PRIVATE_HOTSPOT_CLIENT_IP "Device.X_COMCAST-COM_GRE.Hotspot.RejectAssociatedClient" +#define HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED "Device.X_COMCAST-COM_GRE.Hotspot.RejectAssociatedClient" #define WIFI_STUCK_DETECT_FILE_NAME "/nvram/wifi_stuck_detect" #ifdef CONFIG_IEEE80211BE diff --git a/source/core/wifi_ctrl.h b/source/core/wifi_ctrl.h index cf3e6355b..b1ae7dcdd 100644 --- a/source/core/wifi_ctrl.h +++ b/source/core/wifi_ctrl.h @@ -245,7 +245,6 @@ typedef struct wifi_ctrl { bool marker_list_config_subscribed; bool wifi_sta_2g_status_subscribed; bool wifi_sta_5g_status_subscribed; - bool privateHotspotIPSubscribed; bool eth_bh_status_subscribed; bool mesh_keep_out_chans_subscribed; wifiapi_t wifiapi; @@ -268,6 +267,7 @@ typedef struct wifi_ctrl { events_bus_data_t events_bus_data; hotspot_cfg_sem_param_t hotspot_sem_param; bool rf_status_down; + bool hotspot_client_dhcp_failure_subscribed; } wifi_ctrl_t; diff --git a/source/core/wifi_ctrl_rbus_handlers.c b/source/core/wifi_ctrl_rbus_handlers.c index fbf10c754..42ad8bf79 100644 --- a/source/core/wifi_ctrl_rbus_handlers.c +++ b/source/core/wifi_ctrl_rbus_handlers.c @@ -1694,21 +1694,27 @@ static void wifi_sta_5g_status_handler(char *event_name, raw_data_t *p_data, voi } #endif -static void handlePrivateHotspotClientDisconnect(char *event_name, raw_data_t *p_data, void *userData) +/** +* Hotspot app use this to kick stations which won't complete DHCP in time. +* Expected command from hotspot app: +* Device.X_COMCAST-COM_GRE.Hotspot.RejectAssociatedClient _ +*/ + +static void hotspot_client_dhcp_failure_disconnect(char *event_name, raw_data_t *p_data, void *userData) { (void)userData; char *pTmp = NULL; - char mac[64] = {0}; + char mac[18] = {0}; int index = 0; - char tmp_str[120]; + char tmp_str[124] = {0}; wifi_util_dbg_print(WIFI_CTRL, "%s:%d Received event:%s with data type:%x\n", __func__, __LINE__, event_name, p_data->data_type); pTmp = (char *)p_data->raw_data.bytes; - if((strcmp(event_name, WIFI_PRIVATE_HOTSPOT_CLIENT_IP) != 0) || (pTmp == NULL)) { - wifi_util_info_print(WIFI_CTRL,"%s:%d Invalid event received,%s:%x\n", __func__, __LINE__, event_name, p_data->data_type); + if((strcmp(event_name, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED) != 0) || (pTmp == NULL)) { + wifi_util_error_print(WIFI_CTRL,"%s:%d Invalid event received,%s:%x\n", __func__, __LINE__, event_name, p_data->data_type); return; } // Find the position of the underscore @@ -1726,7 +1732,6 @@ static void handlePrivateHotspotClientDisconnect(char *event_name, raw_data_t *p return; } - memset(tmp_str, 0, sizeof(tmp_str)); snprintf(tmp_str, sizeof(tmp_str), "%d-%s-0", (index-1),mac); push_event_to_ctrl_queue(tmp_str, (strlen(tmp_str) + 1), wifi_event_type_command, wifi_event_type_command_kick_assoc_devices, NULL); } @@ -2111,15 +2116,15 @@ void bus_subscribe_events(wifi_ctrl_t *ctrl) } } #endif - if(ctrl->privateHotspotIPSubscribed == false) { - if (bus_desc->bus_event_subs_fn(&ctrl->handle, WIFI_PRIVATE_HOTSPOT_CLIENT_IP,handlePrivateHotspotClientDisconnect, NULL, + if(!ctrl->hotspot_client_private_ip_status_subscribed) { + if (bus_desc->bus_event_subs_fn(&ctrl->handle, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED, hotspot_client_dhcp_failure_disconnect, NULL, 0) != bus_error_success) { - wifi_util_info_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe fail\n", - __FUNCTION__, __LINE__, WIFI_PRIVATE_HOTSPOT_CLIENT_IP); + wifi_util_error_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe fail\n", + __FUNCTION__, __LINE__, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED); } else { - ctrl->privateHotspotIPSubscribed = true; + ctrl->hotspot_client_private_ip_status_subscribed = true; wifi_util_info_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe success\n", - __FUNCTION__, __LINE__, WIFI_PRIVATE_HOTSPOT_CLIENT_IP); + __FUNCTION__, __LINE__, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED); } } } From c5e778a1700bfca2f2c78bb363d669df7b38ad1f Mon Sep 17 00:00:00 2001 From: Raghavendra Hegde <92532009+rhegde114@users.noreply.github.com> Date: Thu, 29 Jan 2026 10:40:10 -0800 Subject: [PATCH 4/5] Description: Deauth hotspot client when client gets private ip address due to DHCP failure Changes: 1. Added Rbus event handler to moniter event from hotspot component in case of DHCP failure 2. push the event to queue to kick associated client when event is received --- source/core/wifi_ctrl_rbus_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/wifi_ctrl_rbus_handlers.c b/source/core/wifi_ctrl_rbus_handlers.c index 42ad8bf79..a5737172d 100644 --- a/source/core/wifi_ctrl_rbus_handlers.c +++ b/source/core/wifi_ctrl_rbus_handlers.c @@ -1706,7 +1706,7 @@ static void hotspot_client_dhcp_failure_disconnect(char *event_name, raw_data_t char *pTmp = NULL; char mac[18] = {0}; int index = 0; - char tmp_str[124] = {0}; + char tmp_str[128] = {0}; wifi_util_dbg_print(WIFI_CTRL, "%s:%d Received event:%s with data type:%x\n", __func__, __LINE__, event_name, p_data->data_type); From b5068390febe29aa6bbdca1a01de1fad0cadf975 Mon Sep 17 00:00:00 2001 From: Raghavendra Hegde <92532009+rhegde114@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:14:49 -0800 Subject: [PATCH 5/5] Description: Deauth hotspot client when client gets private ip address due to DHCP failure Changes: 1. Added Rbus event handler to moniter event from hotspot component in case of DHCP failure 2. push the event to queue to kick associated client when event is received --- source/core/wifi_ctrl_rbus_handlers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/core/wifi_ctrl_rbus_handlers.c b/source/core/wifi_ctrl_rbus_handlers.c index a5737172d..c029ff8a6 100644 --- a/source/core/wifi_ctrl_rbus_handlers.c +++ b/source/core/wifi_ctrl_rbus_handlers.c @@ -2116,13 +2116,13 @@ void bus_subscribe_events(wifi_ctrl_t *ctrl) } } #endif - if(!ctrl->hotspot_client_private_ip_status_subscribed) { + if(!ctrl->hotspot_client_dhcp_failure_subscribed) { if (bus_desc->bus_event_subs_fn(&ctrl->handle, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED, hotspot_client_dhcp_failure_disconnect, NULL, 0) != bus_error_success) { wifi_util_error_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe fail\n", __FUNCTION__, __LINE__, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED); } else { - ctrl->hotspot_client_private_ip_status_subscribed = true; + ctrl->hotspot_client_dhcp_failure_subscribed = true; wifi_util_info_print(WIFI_CTRL, "%s:%d bus: bus event:%s subscribe success\n", __FUNCTION__, __LINE__, HOTSPOT_CLIENT_DHCP_FAILURE_DISCONNECTED); }