diff --git a/include/wifi_base.h b/include/wifi_base.h index 274c30259..d259746c8 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 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 8c22807fb..b1ae7dcdd 100644 --- a/source/core/wifi_ctrl.h +++ b/source/core/wifi_ctrl.h @@ -267,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 c88dde0be..c029ff8a6 100644 --- a/source/core/wifi_ctrl_rbus_handlers.c +++ b/source/core/wifi_ctrl_rbus_handlers.c @@ -1694,6 +1694,48 @@ static void wifi_sta_5g_status_handler(char *event_name, raw_data_t *p_data, voi } #endif +/** +* 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[18] = {0}; + int index = 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); + + pTmp = (char *)p_data->raw_data.bytes; + + 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 + 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; + + } + 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) { @@ -2074,6 +2116,17 @@ void bus_subscribe_events(wifi_ctrl_t *ctrl) } } #endif + 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_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); + } + } } bus_error_t get_sta_connection_timeout(char *name, raw_data_t *p_data, bus_user_data_t *user_data)