Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/wifi_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/core/wifi_ctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
53 changes: 53 additions & 0 deletions source/core/wifi_ctrl_rbus_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mac>_<vap_index>
*/

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';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mac[mac_len] = '\0';
mac[sizeof(mac)] = '\0';

Copy link
Contributor

Choose a reason for hiding this comment

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

uchm this one would be dependent on chancing char mac[64] = {0}; to char mac[18], so might be safer to leave it as is - otherwise it will crash some strcpy down the line..

Copy link
Author

Choose a reason for hiding this comment

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

I am keeping the original changes as mac is declared as char Mac[18], so valid indices are 0 to 17. Writing to Mac[18] is undefined behavior (out of bounds).

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, you are correct. Just add -1, so that it would be sizeof(mac) - 1 and it should be fine.


// 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)
{
Expand Down Expand Up @@ -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)
Expand Down
Loading