Skip to content

Commit e8bd4b4

Browse files
committed
modules: hostap: Update WPA supplicant to use per-VIF control channel
Update WPA supplicant functions to pass the control channel (socket) as a parameter instead of relying on a global socket. This change aligns with the PR 80 modifications in hostap repo and ensures that each Virtual Interface (VIF) uses its dedicated control channel for communication. Signed-off-by: Hanan Arshad <hananarshad619@gmail.com>
1 parent a4cb872 commit e8bd4b4

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

modules/hostap/src/supp_api.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,19 @@ static void supp_shell_connect_status(struct k_work *work);
8080
static K_WORK_DELAYABLE_DEFINE(wpa_supp_status_work,
8181
supp_shell_connect_status);
8282

83-
#define wpa_cli_cmd_v(cmd, ...) ({ \
84-
bool status; \
85-
\
86-
if (zephyr_wpa_cli_cmd_v(cmd, ##__VA_ARGS__) < 0) { \
87-
wpa_printf(MSG_ERROR, \
88-
"Failed to execute wpa_cli command: %s", \
89-
cmd); \
90-
status = false; \
91-
} else { \
92-
status = true; \
93-
} \
94-
\
95-
status; \
96-
})
83+
#define wpa_cli_cmd_v(cmd, ...) \
84+
({ \
85+
bool status; \
86+
\
87+
if (zephyr_wpa_cli_cmd_v(wpa_s->ctrl_conn, cmd, ##__VA_ARGS__) < 0) { \
88+
wpa_printf(MSG_ERROR, "Failed to execute wpa_cli command: %s", cmd); \
89+
status = false; \
90+
} else { \
91+
status = true; \
92+
} \
93+
\
94+
status; \
95+
})
9796

9897
static struct wpa_supplicant *get_wpa_s_handle(const struct device *dev)
9998
{
@@ -620,7 +619,7 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
620619
goto out;
621620
}
622621

623-
ret = z_wpa_ctrl_add_network(&resp);
622+
ret = z_wpa_ctrl_add_network(wpa_s->ctrl_conn, &resp);
624623
if (ret) {
625624
wpa_printf(MSG_ERROR, "Failed to add network");
626625
goto out;
@@ -1311,7 +1310,7 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status
13111310
status->channel = channel;
13121311

13131312
if (ssid_len == 0) {
1314-
int _res = z_wpa_ctrl_status(&cli_status);
1313+
int _res = z_wpa_ctrl_status(wpa_s->ctrl_conn, &cli_status);
13151314

13161315
if (_res < 0) {
13171316
ssid_len = 0;
@@ -1340,7 +1339,7 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status
13401339

13411340
status->rssi = -WPA_INVALID_NOISE;
13421341
if (status->iface_mode == WIFI_MODE_INFRA) {
1343-
ret = z_wpa_ctrl_signal_poll(&signal_poll);
1342+
ret = z_wpa_ctrl_signal_poll(wpa_s->ctrl_conn, &signal_poll);
13441343
if (!ret) {
13451344
status->rssi = signal_poll.rssi;
13461345
status->current_phy_tx_rate = signal_poll.current_txrate;
@@ -1490,6 +1489,7 @@ int supplicant_11k_cfg(const struct device *dev, struct wifi_11k_params *params)
14901489
int supplicant_11k_neighbor_request(const struct device *dev, struct wifi_11k_params *params)
14911490
{
14921491
int ssid_len = strlen(params->ssid);
1492+
struct wpa_supplicant *wpa_s = get_wpa_s_handle(dev);
14931493

14941494
if (params != NULL && ssid_len > 0) {
14951495
if (ssid_len > WIFI_SSID_MAX_LEN) {
@@ -1756,6 +1756,7 @@ int supplicant_bss_ext_capab(const struct device *dev, int capab)
17561756
int supplicant_legacy_roam(const struct device *dev)
17571757
{
17581758
int ret = -1;
1759+
struct wpa_supplicant *wpa_s = get_wpa_s_handle(dev);
17591760

17601761
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);
17611762
if (!wpa_cli_cmd_v("scan")) {
@@ -1864,7 +1865,7 @@ static int supplicant_wps_pin(const struct device *dev, struct wifi_wps_config_p
18641865
}
18651866

18661867
if (params->oper == WIFI_WPS_PIN_GET) {
1867-
if (zephyr_wpa_cli_cmd_resp(get_pin_cmd, params->pin)) {
1868+
if (zephyr_wpa_cli_cmd_resp(wpa_s->ctrl_conn, get_pin_cmd, params->pin)) {
18681869
goto out;
18691870
}
18701871
} else if (params->oper == WIFI_WPS_PIN_SET) {
@@ -2297,6 +2298,7 @@ int supplicant_dpp_dispatch(const struct device *dev, struct wifi_dpp_params *pa
22972298
{
22982299
int ret;
22992300
char *cmd = NULL;
2301+
struct wpa_supplicant *wpa_s = get_wpa_s_handle(dev);
23002302

23012303
if (params == NULL) {
23022304
return -EINVAL;
@@ -2315,7 +2317,7 @@ int supplicant_dpp_dispatch(const struct device *dev, struct wifi_dpp_params *pa
23152317
}
23162318

23172319
wpa_printf(MSG_DEBUG, "wpa_cli %s", cmd);
2318-
if (zephyr_wpa_cli_cmd_resp(cmd, params->resp)) {
2320+
if (zephyr_wpa_cli_cmd_resp(wpa_s->ctrl_conn, cmd, params->resp)) {
23192321
os_free(cmd);
23202322
return -ENOEXEC;
23212323
}

0 commit comments

Comments
 (0)