From: Daniel Drake Date: Mon, 3 Sep 2007 22:21:55 +0000 (-0700) Subject: Add wpa_cli reconnect command X-Git-Url: http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=commitdiff_plain;h=35d01272085bddb82965177ca958cb0f60f045de Add wpa_cli reconnect command Reconnect is like reassociate but it only actually performs reassociation if the interface is in disconnected state. This is useful for the environment where we want to disable/enable wireless at various times but would prefer not to wait for each up/down operation to complete. There is a possibility of harmless "races" here, where a disconnect command would be recieved when the interface is already disconnected -- nothing happens (this is what we want - great!). However, if we were to use "reassociate" and we were to send that command when the system was already connected, we'd prefer for it not to actually reassociate. IOW, reconnect is effectively "reassociate only if disconnected" I'll happily take suggestions for better command naming here. Semantically I would expect a reconnect command to be unconditional (like reassociate is), but at the same time, "reconnect" is nice because it pairs nicely with "disconnect". jm: Updated doxygen documentation for the new ctrl_iface command. --- diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 30ca369..ae17511 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -1225,6 +1225,12 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *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) { + if (wpa_s->disconnected) { + wpa_s->disconnected = 0; + wpa_s->reassociate = 1; + wpa_supplicant_req_scan(wpa_s, 0, 0); + } } else if (os_strncmp(buf, "PREAUTH ", 8) == 0) { if (wpa_supplicant_ctrl_iface_preauth(wpa_s, buf + 8)) reply_len = -1; diff --git a/wpa_supplicant/doc/ctrl_iface.doxygen b/wpa_supplicant/doc/ctrl_iface.doxygen index f9e7d0e..d649786 100644 --- a/wpa_supplicant/doc/ctrl_iface.doxygen +++ b/wpa_supplicant/doc/ctrl_iface.doxygen @@ -203,6 +203,12 @@ IEEE 802.1X EAPOL state machine logoff. Force reassociation. +\subsection ctrl_iface_RECONNECT RECONNECT + +Connect if disconnected (i.e., like \c REASSOCIATE, but only connect +if in disconnected state). + + \subsection ctrl_iface_PREAUTH PREAUTH Start pre-authentication with the given BSSID. @@ -255,7 +261,8 @@ network id / ssid / bssid / flags \subsection ctrl_iface_DISCONNECT DISCONNECT -Disconnect and wait for \c REASSOCIATE command before connecting. +Disconnect and wait for \c REASSOCIATE or \c RECONNECT command before +connecting. \subsection ctrl_iface_SCAN SCAN diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index a0e226a..4779a4c 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -120,8 +120,10 @@ static const char *commands_help = " list of variables when run without arguments)\n" " get_network = get network variables\n" " save_config = save the current configuration\n" -" disconnect = disconnect and wait for reassociate command before " -"connecting\n" +" disconnect = disconnect and wait for reassociate/reconnect command before\n " +" connecting\n" +" reconnect = like reassociate, but only takes effect if already " +"disconnected\n" " scan = request new BSS scan\n" " scan_results = get latest scan results\n" " get_capability = " @@ -865,6 +867,13 @@ static int wpa_cli_cmd_disconnect(struct wpa_ctrl *ctrl, int argc, } +static int wpa_cli_cmd_reconnect(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_ctrl_command(ctrl, "RECONNECT"); +} + + static int wpa_cli_cmd_save_config(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -1049,6 +1058,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { { "get_network", wpa_cli_cmd_get_network }, { "save_config", wpa_cli_cmd_save_config }, { "disconnect", wpa_cli_cmd_disconnect }, + { "reconnect", wpa_cli_cmd_reconnect }, { "scan", wpa_cli_cmd_scan }, { "scan_results", wpa_cli_cmd_scan_results }, { "get_capability", wpa_cli_cmd_get_capability },