aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/hostapd_cli.c
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@sonymobile.com>2016-07-07 12:04:36 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-06 09:29:19 (GMT)
commit8b73c6aa11e191696fb1e89d344fe6366a1af18c (patch)
tree791f99b9d4570e29420c7e0f1b99c0903aaeb024 /hostapd/hostapd_cli.c
parent1cef253aab80a97e98cd546c8097ca75bd9a59d3 (diff)
downloadhostap-8b73c6aa11e191696fb1e89d344fe6366a1af18c.zip
hostap-8b73c6aa11e191696fb1e89d344fe6366a1af18c.tar.gz
hostap-8b73c6aa11e191696fb1e89d344fe6366a1af18c.tar.bz2
hostapd_cli: Completion for disassociate and deauthenticate
Command completion routine for disassociate and deauthenticate commands implemented. Tracks AP-STA-CONNECTED/AP-STA-DISCONNECTED events for easy station MAC address lookup. Signed-off-by: Mikael Kanstrup <mikael.kanstrup@sonymobile.com>
Diffstat (limited to 'hostapd/hostapd_cli.c')
-rw-r--r--hostapd/hostapd_cli.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 7f3da00..28cd080 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -76,6 +76,8 @@ static int ping_interval = 5;
static int interactive = 0;
static int event_handler_registered = 0;
+static DEFINE_DL_LIST(stations); /* struct cli_txt_entry */
+
static void print_help(FILE *stream, const char *cmd);
static char ** list_cmd_list(void);
static void hostapd_cli_receive(int sock, void *eloop_ctx, void *sock_ctx);
@@ -406,6 +408,21 @@ 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[])
{
@@ -424,6 +441,21 @@ 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_IEEE80211W
static int hostapd_cli_cmd_sa_query(struct wpa_ctrl *ctrl, int argc,
char *argv[])
@@ -1283,9 +1315,11 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
"= get MIB variables for all stations" },
{ "new_sta", hostapd_cli_cmd_new_sta, NULL,
"<addr> = add a new station" },
- { "deauthenticate", hostapd_cli_cmd_deauthenticate, NULL,
+ { "deauthenticate", hostapd_cli_cmd_deauthenticate,
+ hostapd_complete_deauthenticate,
"<addr> = deauthenticate a station" },
- { "disassociate", hostapd_cli_cmd_disassociate, NULL,
+ { "disassociate", hostapd_cli_cmd_disassociate,
+ hostapd_complete_disassociate,
"<addr> = disassociate a station" },
#ifdef CONFIG_IEEE80211W
{ "sa_query", hostapd_cli_cmd_sa_query, NULL,
@@ -1434,6 +1468,29 @@ static void wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[])
static void cli_event(const char *str)
{
+ const char *start, *s;
+
+ start = os_strchr(str, '>');
+ if (start == NULL)
+ return;
+
+ start++;
+
+ if (str_starts(start, AP_STA_CONNECTED)) {
+ s = os_strchr(start, ' ');
+ if (s == NULL)
+ return;
+ cli_txt_list_add(&stations, s + 1);
+ return;
+ }
+
+ if (str_starts(start, AP_STA_DISCONNECTED)) {
+ s = os_strchr(start, ' ');
+ if (s == NULL)
+ return;
+ cli_txt_list_del_addr(&stations, s + 1);
+ return;
+ }
}
@@ -1625,6 +1682,7 @@ static void hostapd_cli_interactive(void)
eloop_run();
+ cli_txt_list_flush(&stations);
edit_deinit(NULL, NULL);
eloop_cancel_timeout(hostapd_cli_ping, NULL, NULL);
}