Move disconnect command handling to a common place

Move out the disconnect command handling from |ctrl_iface.c| to
|wpa_supplicant.c| so that it can be reused across the different
control interfaces (socket, dbus & binder).

Signed-off-by: Roshan Pius <rpius@google.com>
This commit is contained in:
Roshan Pius 2016-08-10 09:35:34 -07:00 committed by Jouni Malinen
parent 478441bf81
commit 5f040be4ff
5 changed files with 25 additions and 16 deletions

View file

@ -9127,16 +9127,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
reply_len = wpa_supplicant_ctrl_iface_list_networks( reply_len = wpa_supplicant_ctrl_iface_list_networks(
wpa_s, NULL, reply, reply_size); wpa_s, NULL, reply, reply_size);
} else if (os_strcmp(buf, "DISCONNECT") == 0) { } else if (os_strcmp(buf, "DISCONNECT") == 0) {
#ifdef CONFIG_SME wpas_request_disconnection(wpa_s);
wpa_s->sme.prev_bssid_set = 0;
#endif /* CONFIG_SME */
wpa_s->reassociate = 0;
wpa_s->disconnected = 1;
wpa_supplicant_cancel_sched_scan(wpa_s);
wpa_supplicant_cancel_scan(wpa_s);
wpa_supplicant_deauthenticate(wpa_s,
WLAN_REASON_DEAUTH_LEAVING);
eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
} else if (os_strcmp(buf, "SCAN") == 0) { } else if (os_strcmp(buf, "SCAN") == 0) {
wpas_ctrl_scan(wpa_s, NULL, reply, reply_size, &reply_len); wpas_ctrl_scan(wpa_s, NULL, reply, reply_size, &reply_len);
} else if (os_strncmp(buf, "SCAN ", 5) == 0) { } else if (os_strncmp(buf, "SCAN ", 5) == 0) {

View file

@ -1475,10 +1475,7 @@ DBusMessage * wpas_dbus_handler_disconnect(DBusMessage *message,
struct wpa_supplicant *wpa_s) struct wpa_supplicant *wpa_s)
{ {
if (wpa_s->current_ssid != NULL) { if (wpa_s->current_ssid != NULL) {
wpa_s->disconnected = 1; wpas_request_disconnection(wpa_s);
wpa_supplicant_deauthenticate(wpa_s,
WLAN_REASON_DEAUTH_LEAVING);
return NULL; return NULL;
} }

View file

@ -1069,8 +1069,7 @@ out:
DBusMessage * wpas_dbus_iface_disconnect(DBusMessage *message, DBusMessage * wpas_dbus_iface_disconnect(DBusMessage *message,
struct wpa_supplicant *wpa_s) struct wpa_supplicant *wpa_s)
{ {
wpa_s->disconnected = 1; wpas_request_disconnection(wpa_s);
wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
return wpas_dbus_new_success_reply(message); return wpas_dbus_new_success_reply(message);
} }

View file

@ -6024,6 +6024,27 @@ void wpas_request_connection(struct wpa_supplicant *wpa_s)
} }
/**
* wpas_request_disconnection - Request disconnection
* @wpa_s: Pointer to the network interface
*
* This function is used to request disconnection from the currently connected
* network. This will stop any ongoing scans and initiate deauthentication.
*/
void wpas_request_disconnection(struct wpa_supplicant *wpa_s)
{
#ifdef CONFIG_SME
wpa_s->sme.prev_bssid_set = 0;
#endif /* CONFIG_SME */
wpa_s->reassociate = 0;
wpa_s->disconnected = 1;
wpa_supplicant_cancel_sched_scan(wpa_s);
wpa_supplicant_cancel_scan(wpa_s);
wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
}
void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title, void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title,
struct wpa_used_freq_data *freqs_data, struct wpa_used_freq_data *freqs_data,
unsigned int len) unsigned int len)

View file

@ -1162,6 +1162,7 @@ int disallowed_bssid(struct wpa_supplicant *wpa_s, const u8 *bssid);
int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid, int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid,
size_t ssid_len); size_t ssid_len);
void wpas_request_connection(struct wpa_supplicant *wpa_s); void wpas_request_connection(struct wpa_supplicant *wpa_s);
void wpas_request_disconnection(struct wpa_supplicant *wpa_s);
int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen); int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen);
int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style); int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style);
int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s); int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s);