diff options
Diffstat (limited to 'wpa_supplicant/wpa_cli.c')
-rw-r--r-- | wpa_supplicant/wpa_cli.c | 131 |
1 files changed, 94 insertions, 37 deletions
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 779355440a01..695fcbe04995 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -1,6 +1,6 @@ /* * WPA Supplicant - command line interface for wpa_supplicant daemon - * Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi> + * Copyright (c) 2004-2019, Jouni Malinen <j@w1.fi> * * This software may be distributed under the terms of the BSD license. * See README for more details. @@ -29,7 +29,7 @@ static const char *const wpa_cli_version = "wpa_cli v" VERSION_STR "\n" -"Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi> and contributors"; +"Copyright (c) 2004-2019, Jouni Malinen <j@w1.fi> and contributors"; #define VENDOR_ELEM_FRAME_ID \ " 0: Probe Req (P2P), 1: Probe Resp (P2P) , 2: Probe Resp (GO), " \ @@ -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 const char *global = NULL; static const char *pid_file = NULL; static const char *action_file = NULL; static int ping_interval = 5; @@ -74,6 +75,7 @@ static char ** wpa_list_cmd_list(void); static void update_creds(struct wpa_ctrl *ctrl); static void update_networks(struct wpa_ctrl *ctrl); static void update_stations(struct wpa_ctrl *ctrl); +static void update_ifnames(struct wpa_ctrl *ctrl); static void usage(void) @@ -1203,6 +1205,39 @@ static int wpa_cli_cmd_sim(struct wpa_ctrl *ctrl, int argc, char *argv[]) } +static int wpa_cli_cmd_psk_passphrase(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + char cmd[256], *pos, *end; + int i, ret; + + if (argc < 2) { + printf("Invalid PSK_PASSPHRASE command: needs two arguments (network id and PSK/passphrase)\n"); + return -1; + } + + end = cmd + sizeof(cmd); + pos = cmd; + ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PSK_PASSPHRASE-%s:%s", + argv[0], argv[1]); + if (os_snprintf_error(end - pos, ret)) { + printf("Too long PSK_PASSPHRASE command.\n"); + return -1; + } + pos += ret; + for (i = 2; i < argc; i++) { + ret = os_snprintf(pos, end - pos, " %s", argv[i]); + if (os_snprintf_error(end - pos, ret)) { + printf("Too long PSK_PASSPHRASE command.\n"); + return -1; + } + pos += ret; + } + + return wpa_ctrl_command(ctrl, cmd); +} + + static int wpa_cli_cmd_passphrase(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -1376,9 +1411,11 @@ static const char *network_fields[] = { "eap", "identity", "anonymous_identity", "password", "ca_cert", "ca_path", "client_cert", "private_key", "private_key_passwd", "dh_file", "subject_match", "altsubject_match", + "check_cert_subject", "domain_suffix_match", "domain_match", "ca_cert2", "ca_path2", "client_cert2", "private_key2", "private_key2_passwd", "dh_file2", "subject_match2", "altsubject_match2", + "check_cert_subject2", "domain_suffix_match2", "domain_match2", "phase1", "phase2", "pcsc", "pin", "engine_id", "key_id", "cert_id", "ca_cert_id", "pin2", "engine2_id", "key2_id", "cert2_id", "ca_cert2_id", @@ -1412,7 +1449,7 @@ static const char *network_fields[] = { #ifdef CONFIG_HT_OVERRIDES "disable_ht", "disable_ht40", "disable_sgi", "disable_ldpc", "ht40_intolerant", "disable_max_amsdu", "ampdu_factor", - "ampdu_density", "ht_mcs", + "ampdu_density", "ht_mcs", "rx_stbc", "tx_stbc", #endif /* CONFIG_HT_OVERRIDES */ #ifdef CONFIG_VHT_OVERRIDES "disable_vht", "vht_capa", "vht_capa_mask", "vht_rx_mcs_nss_1", @@ -1426,6 +1463,8 @@ static const char *network_fields[] = { #ifdef CONFIG_MACSEC "macsec_policy", "macsec_integ_only", + "macsec_replay_protect", + "macsec_replay_window", "macsec_port", "mka_priority", #endif /* CONFIG_MACSEC */ @@ -2955,6 +2994,13 @@ static int wpa_cli_cmd_dpp_configurator_get_key(struct wpa_ctrl *ctrl, int argc, } +static int wpa_cli_cmd_dpp_configurator_sign(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_cli_cmd(ctrl, "DPP_CONFIGURATOR_SIGN", 1, argc, argv); +} + + static int wpa_cli_cmd_dpp_pkex_add(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -3084,6 +3130,9 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = { cli_cmd_flag_sensitive, "<network id> <password> = configure one-time-password for an SSID" }, + { "psk_passphrase", wpa_cli_cmd_psk_passphrase, + wpa_cli_complete_network_id, cli_cmd_flag_sensitive, + "<network id> <PSK/passphrase> = configure PSK/passphrase for an SSID" }, { "passphrase", wpa_cli_cmd_passphrase, wpa_cli_complete_network_id, cli_cmd_flag_sensitive, "<network id> <passphrase> = configure private key passphrase\n" @@ -3614,6 +3663,9 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = { { "dpp_configurator_get_key", wpa_cli_cmd_dpp_configurator_get_key, NULL, cli_cmd_flag_none, "<id> = Get DPP configurator's private key" }, + { "dpp_configurator_sign", wpa_cli_cmd_dpp_configurator_sign, NULL, + cli_cmd_flag_none, + "conf=<role> configurator=<id> = generate self DPP configuration" }, { "dpp_pkex_add", wpa_cli_cmd_dpp_pkex_add, NULL, cli_cmd_flag_sensitive, "add PKEX code" }, @@ -3972,10 +4024,46 @@ static void wpa_cli_action_cb(char *msg, size_t len) #endif /* CONFIG_ANSI_C_EXTRA */ +static int wpa_cli_open_global_ctrl(void) +{ +#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) { + fprintf(stderr, + "Failed to connect to wpa_supplicant global interface: %s error: %s\n", + global, strerror(errno)); + return -1; + } + + 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 open monitor connection through global control interface\n"); + } + } + update_stations(ctrl_conn); + } + + return 0; +} + + static void wpa_cli_reconnect(void) { wpa_cli_close_connection(); - if (wpa_cli_open_connection(ctrl_ifname, 1) < 0) + if ((global && wpa_cli_open_global_ctrl() < 0) || + (!global && wpa_cli_open_connection(ctrl_ifname, 1) < 0)) return; if (interactive) { @@ -4534,7 +4622,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; @@ -4589,38 +4676,8 @@ int main(int argc, char *argv[]) if (eloop_init()) return -1; - 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 connect to wpa_supplicant " - "global interface: %s error: %s\n", - global, strerror(errno)); - return -1; - } - - 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 open monitor " - "connection through global " - "control interface\n"); - } - } - update_stations(ctrl_conn); - } - } + if (global && wpa_cli_open_global_ctrl() < 0) + return -1; eloop_register_signal_terminate(wpa_cli_terminate, NULL); |