From 4f59ad0699c3dec5a215266ec78c3b9bc9525f2f Mon Sep 17 00:00:00 2001 From: Mikael Kanstrup Date: Wed, 21 Dec 2016 11:27:17 +0100 Subject: [PATCH] hostapd_cli: Use common completion for commands that use stations More than one command takes STA address as the only parameter. Make use of a common completion routine. Signed-off-by: Mikael Kanstrup --- hostapd/hostapd_cli.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index cb43b869c..afa7e23a6 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -320,7 +320,7 @@ static int hostapd_cli_cmd_sta(struct wpa_ctrl *ctrl, int argc, char *argv[]) } -static char ** hostapd_complete_sta(const char *str, int pos) +static char ** hostapd_complete_stations(const char *str, int pos) { int arg = get_cmd_arg_num(str, pos); char **res = NULL; @@ -367,21 +367,6 @@ static int hostapd_cli_cmd_deauthenticate(struct wpa_ctrl *ctrl, int argc, } -static char ** hostapd_complete_deauthenticate(const char *str, int pos) -{ - int arg = get_cmd_arg_num(str, pos); - char **res = NULL; - - switch (arg) { - case 1: - res = cli_txt_list_array(&stations); - break; - } - - return res; -} - - static int hostapd_cli_cmd_disassociate(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -400,21 +385,6 @@ static int hostapd_cli_cmd_disassociate(struct wpa_ctrl *ctrl, int argc, } -static char ** hostapd_complete_disassociate(const char *str, int pos) -{ - int arg = get_cmd_arg_num(str, pos); - char **res = NULL; - - switch (arg) { - case 1: - res = cli_txt_list_array(&stations); - break; - } - - return res; -} - - #ifdef CONFIG_TAXONOMY static int hostapd_cli_cmd_signature(struct wpa_ctrl *ctrl, int argc, char *argv[]) @@ -1347,7 +1317,7 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { "= reload/truncate debug log output file" }, { "status", hostapd_cli_cmd_status, NULL, "= show interface status info" }, - { "sta", hostapd_cli_cmd_sta, hostapd_complete_sta, + { "sta", hostapd_cli_cmd_sta, hostapd_complete_stations, " = get MIB variables for one station" }, { "all_sta", hostapd_cli_cmd_all_sta, NULL, "= get MIB variables for all stations" }, @@ -1356,10 +1326,10 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { { "new_sta", hostapd_cli_cmd_new_sta, NULL, " = add a new station" }, { "deauthenticate", hostapd_cli_cmd_deauthenticate, - hostapd_complete_deauthenticate, + hostapd_complete_stations, " = deauthenticate a station" }, { "disassociate", hostapd_cli_cmd_disassociate, - hostapd_complete_disassociate, + hostapd_complete_stations, " = disassociate a station" }, #ifdef CONFIG_TAXONOMY { "signature", hostapd_cli_cmd_signature, NULL,