Skip to content
Snippets Groups Projects
Commit b385c9ca authored by Pavel Martynov's avatar Pavel Martynov Committed by Janusz Dziedzic
Browse files

airoha: re-connect wpa_supplicant to hostapd if connectivity is lost

parent bf6e8e95
No related branches found
No related tags found
1 merge request!541airoha: re-connect wpa_supplicant to hostapd if connectivity is lost
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index b9ebd22..f6d8b11 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -5015,7 +5015,8 @@ supplicant_ch_switch_started(struct wpa_supplicant *wpa_s,
data->ch_switch.cf1,
data->ch_switch.cf2,
width);
- ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
+
+ ret = wpa_supplicant_ctrl_request(wpa_s, cmd, os_strlen(cmd), buf, &len, NULL);
free(cmd);
if (ret < 0)
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 0f81873..e1dc976 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -139,7 +139,7 @@ int hostapd_stop(struct wpa_supplicant *wpa_s)
wpa_msg(wpa_s, MSG_ERROR, "stop hostapd AP interfaces");
- if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
+ if (wpa_supplicant_ctrl_request(wpa_s, cmd, os_strlen(cmd), buf, &len, NULL) < 0) {
wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n");
return -1;
}
@@ -185,7 +185,7 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
hw_mode, op_class) < 0)
return -1;
- ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
+ ret = wpa_supplicant_ctrl_request(wpa_s, cmd, os_strlen(cmd), buf, &len, NULL);
free(cmd);
if (ret < 0) {
@@ -5799,6 +5799,28 @@ void wpa_supplicant_apply_ht_overrides(
#endif /* CONFIG_HT_OVERRIDES */
+#define WPAS_REQUEST_ATTEMPTS 16
+int wpa_supplicant_ctrl_request(struct wpa_supplicant *wpa_s,
+ const char *cmd, size_t cmd_len,
+ char *reply, size_t *reply_len,
+ void (*msg_cb)(char *msg, size_t len))
+{
+ int i;
+
+ for (i = 0; i < WPAS_REQUEST_ATTEMPTS; i++)
+ {
+ int ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), reply, reply_len, NULL);
+ if (!ret)
+ return ret;
+
+ wpa_printf(MSG_ERROR, "Command (\"%s\") failed - Retry", cmd);
+ wpa_ctrl_close(wpa_s->hostapd);
+ wpa_s->hostapd = wpa_ctrl_open(wpa_s->hostapd_ctrl_path);
+ }
+
+ return -1;
+}
+#undef WPAS_REQUEST_ATTEMPTS
#ifdef CONFIG_VHT_OVERRIDES
void wpa_supplicant_apply_vht_overrides(
@@ -6777,6 +6799,7 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
}
if (iface->hostapd_ctrl) {
+ wpa_s->hostapd_ctrl_path = os_strdup(iface->hostapd_ctrl);
wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl);
if (!wpa_s->hostapd) {
wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n");
@@ -7146,6 +7169,7 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
os_free(wpa_s->ssids_from_scan_req);
os_free(wpa_s->last_scan_freqs);
+ os_free(wpa_s->hostapd_ctrl_path);
os_free(wpa_s);
}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index e11b454..6c3288f 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1564,6 +1564,8 @@ struct wpa_supplicant {
unsigned int enable_dscp_policy_capa:1;
unsigned int connection_dscp:1;
unsigned int wait_for_dscp_req:1;
+
+ const char *hostapd_ctrl_path;
};
@@ -1935,4 +1937,8 @@ int wpas_pasn_auth_rx(struct wpa_supplicant *wpa_s,
int wpas_pasn_deauthenticate(struct wpa_supplicant *wpa_s, const u8 *bssid);
+int wpa_supplicant_ctrl_request(struct wpa_supplicant *wpa_s, const char *cmd,
+ size_t cmd_len, char *reply, size_t *reply_len,
+ void (*msg_cb)(char *msg, size_t len));
+
#endif /* WPA_SUPPLICANT_I_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment