[PATCH 4/5] wpa_cli: Completion for remove, select, disable, enable network
Mikael Kanstrup
mikael.kanstrup
Tue Mar 24 09:10:39 PDT 2015
Add command completion routines for remove_network, select_network,
disable_network and enable_network commands
Signed-off-by: Mikael Kanstrup <mikael.kanstrup at sonymobile.com>
---
wpa_supplicant/wpa_cli.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 57039b9..fe29b77 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -1615,6 +1615,13 @@ static char ** wpa_cli_complete_network(const char *str, int pos)
return res;
}
+static char ** wpa_cli_complete_network_id(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ if (arg == 1)
+ return cli_txt_list_array(&networks);
+ return NULL;
+}
static int wpa_cli_cmd_dup_network(struct wpa_ctrl *ctrl, int argc,
char *argv[])
@@ -2873,19 +2880,19 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "list_networks", wpa_cli_cmd_list_networks, NULL,
cli_cmd_flag_none,
"= list configured networks" },
- { "select_network", wpa_cli_cmd_select_network, NULL,
+ { "select_network", wpa_cli_cmd_select_network, wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = select a network (disable others)" },
- { "enable_network", wpa_cli_cmd_enable_network, NULL,
+ { "enable_network", wpa_cli_cmd_enable_network, wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = enable a network" },
- { "disable_network", wpa_cli_cmd_disable_network, NULL,
+ { "disable_network", wpa_cli_cmd_disable_network, wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = disable a network" },
{ "add_network", wpa_cli_cmd_add_network, NULL,
cli_cmd_flag_none,
"= add a network" },
- { "remove_network", wpa_cli_cmd_remove_network, NULL,
+ { "remove_network", wpa_cli_cmd_remove_network, wpa_cli_complete_network_id,
cli_cmd_flag_none,
"<network id> = remove a network" },
{ "set_network", wpa_cli_cmd_set_network, wpa_cli_complete_network,
--
1.8.2.2
More information about the Hostap
mailing list