From: Ben Greear <greearb@xxxxxxxxxxxxxxx> Old code would just re-connect to a particular interface, even if user had started wpa_cli with the '-g' option. This duplicates some code, but appears to work. Signed-off-by: Ben Greear <greearb@xxxxxxxxxxxxxxx> --- wpa_supplicant/wpa_cli.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 1680c54..4cdc4fb 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -49,6 +49,7 @@ static int wpa_cli_last_id = 0; static const char *ctrl_iface_dir = CONFIG_CTRL_IFACE_DIR; static const char *client_socket_dir = NULL; static char *ctrl_ifname = NULL; +static char *global = NULL; static const char *pid_file = NULL; static const char *action_file = NULL; static int ping_interval = 5; @@ -3798,16 +3799,52 @@ static void wpa_cli_action_cb(char *msg, size_t len) } #endif /* CONFIG_ANSI_C_EXTRA */ +static void update_ifnames(struct wpa_ctrl *ctrl); static void wpa_cli_reconnect(void) { wpa_cli_close_connection(); - if (wpa_cli_open_connection(ctrl_ifname, 1) < 0) - return; + + if (global) { +#ifdef CONFIG_CTRL_IFACE_NAMED_PIPE + ctrl_conn = wpa_ctrl_open(NULL); +#else /* CONFIG_CTRL_IFACE_NAMED_PIPE */ + ctrl_conn = wpa_ctrl_open(global); +#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */ + if (ctrl_conn == NULL) { + fprintf(stderr, "Failed to re-connect to wpa_supplicant " + "global interface: %s error: %s\n", + global, strerror(errno)); + return; + } + + if (interactive) { + update_ifnames(ctrl_conn); + mon_conn = wpa_ctrl_open(global); + if (mon_conn) { + if (wpa_ctrl_attach(mon_conn) == 0) { + wpa_cli_attached = 1; + eloop_register_read_sock( + wpa_ctrl_get_fd(mon_conn), + wpa_cli_mon_receive, + NULL, NULL); + } else { + printf("Failed to re-open monitor " + "connection through global " + "control interface\n"); + } + } + } + printf("\rConnection to wpa_supplicant re-established, global: %s\n", global); + } + else { + if (wpa_cli_open_connection(ctrl_ifname, 1) < 0) + return; + printf("\rConnection to wpa_supplicant re-established, ctrl-ifname: %s\n", ctrl_ifname); + } if (interactive) { edit_clear_line(); - printf("\rConnection to wpa_supplicant re-established\n"); edit_redraw(); update_stations(ctrl_conn); } @@ -4327,7 +4364,6 @@ int main(int argc, char *argv[]) int c; int daemonize = 0; int ret = 0; - const char *global = NULL; if (os_program_init()) return -1; @@ -4344,7 +4380,7 @@ int main(int argc, char *argv[]) daemonize = 1; break; case 'g': - global = optarg; + global = os_strdup(optarg); break; case 'G': ping_interval = atoi(optarg); -- 2.7.5 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap