Use a shared function for requesting a new connection

Both the ctrl_iface and D-Bus interface use similar functionality to
request a new connection. Combine these to a single function to avoid
need to maintain duplicated implementation.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-11-25 16:30:30 +02:00
parent c27a94f765
commit 9796a86c23
4 changed files with 25 additions and 23 deletions

View file

@ -4781,27 +4781,15 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
} else if (os_strcmp(buf, "LOGOFF") == 0) { } else if (os_strcmp(buf, "LOGOFF") == 0) {
eapol_sm_notify_logoff(wpa_s->eapol, TRUE); eapol_sm_notify_logoff(wpa_s->eapol, TRUE);
} else if (os_strcmp(buf, "REASSOCIATE") == 0) { } else if (os_strcmp(buf, "REASSOCIATE") == 0) {
wpa_s->normal_scans = 0;
wpa_supplicant_reinit_autoscan(wpa_s);
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
reply_len = -1; reply_len = -1;
else { else
wpa_s->extra_blacklist_count = 0; wpas_request_connection(wpa_s);
wpa_s->disconnected = 0;
wpa_s->reassociate = 1;
wpa_supplicant_req_scan(wpa_s, 0, 0);
}
} else if (os_strcmp(buf, "RECONNECT") == 0) { } else if (os_strcmp(buf, "RECONNECT") == 0) {
wpa_s->normal_scans = 0;
wpa_supplicant_reinit_autoscan(wpa_s);
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
reply_len = -1; reply_len = -1;
else if (wpa_s->disconnected) { else if (wpa_s->disconnected)
wpa_s->extra_blacklist_count = 0; wpas_request_connection(wpa_s);
wpa_s->disconnected = 0;
wpa_s->reassociate = 1;
wpa_supplicant_req_scan(wpa_s, 0, 0);
}
#ifdef IEEE8021X_EAPOL #ifdef IEEE8021X_EAPOL
} else if (os_strncmp(buf, "PREAUTH ", 8) == 0) { } else if (os_strncmp(buf, "PREAUTH ", 8) == 0) {
if (wpa_supplicant_ctrl_iface_preauth(wpa_s, buf + 8)) if (wpa_supplicant_ctrl_iface_preauth(wpa_s, buf + 8))

View file

@ -1455,13 +1455,7 @@ DBusMessage * wpas_dbus_handler_reassociate(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->extra_blacklist_count = 0; wpas_request_connection(wpa_s);
wpa_s->normal_scans = 0;
wpa_supplicant_reinit_autoscan(wpa_s);
wpa_s->disconnected = 0;
wpa_s->reassociate = 1;
wpa_supplicant_req_scan(wpa_s, 0, 0);
return NULL; return NULL;
} }

View file

@ -3716,3 +3716,22 @@ int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid,
return 0; return 0;
} }
/**
* wpas_request_connection - Request a new connection
* @wpa_s: Pointer to the network interface
*
* This function is used to request a new connection to be found. It will mark
* the interface to allow reassociation and request a new scan to find a
* suitable network to connect to.
*/
void wpas_request_connection(struct wpa_supplicant *wpa_s)
{
wpa_s->normal_scans = 0;
wpa_supplicant_reinit_autoscan(wpa_s);
wpa_s->extra_blacklist_count = 0;
wpa_s->disconnected = 0;
wpa_s->reassociate = 1;
wpa_supplicant_req_scan(wpa_s, 0, 0);
}

View file

@ -754,6 +754,7 @@ void wpas_clear_temp_disabled(struct wpa_supplicant *wpa_s,
int disallowed_bssid(struct wpa_supplicant *wpa_s, const u8 *bssid); 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);
/** /**
* wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response