aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/hostapd_cli.c
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@sonymobile.com>2016-07-07 12:04:37 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-06 09:33:23 (GMT)
commitb90c13d934dd1cfe9415e8df0c9bb1490b0ccddc (patch)
tree64fc417c52f1628cb3a724d62d8948f04d5895bf /hostapd/hostapd_cli.c
parent8b73c6aa11e191696fb1e89d344fe6366a1af18c (diff)
downloadhostap-b90c13d934dd1cfe9415e8df0c9bb1490b0ccddc.zip
hostap-b90c13d934dd1cfe9415e8df0c9bb1490b0ccddc.tar.gz
hostap-b90c13d934dd1cfe9415e8df0c9bb1490b0ccddc.tar.bz2
hostapd_cli: Completion for interface command
Implement command completion for interface command Signed-off-by: Mikael Kanstrup <mikael.kanstrup@sonymobile.com>
Diffstat (limited to 'hostapd/hostapd_cli.c')
-rw-r--r--hostapd/hostapd_cli.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 28cd080..1e4125f 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -962,6 +962,28 @@ static int hostapd_cli_cmd_level(struct wpa_ctrl *ctrl, int argc, char *argv[])
}
+static void hostapd_cli_get_interfaces(struct wpa_ctrl *ctrl,
+ struct dl_list *interfaces)
+{
+ struct dirent *dent;
+ DIR *dir;
+
+ if (!ctrl || !interfaces)
+ return;
+ dir = opendir(ctrl_iface_dir);
+ if (dir == NULL)
+ return;
+
+ while ((dent = readdir(dir))) {
+ if (strcmp(dent->d_name, ".") == 0 ||
+ strcmp(dent->d_name, "..") == 0)
+ continue;
+ cli_txt_list_add(interfaces, dent->d_name);
+ }
+ closedir(dir);
+}
+
+
static void hostapd_cli_list_interfaces(struct wpa_ctrl *ctrl)
{
struct dirent *dent;
@@ -1016,6 +1038,24 @@ static int hostapd_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc,
}
+static char ** hostapd_complete_interface(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ char **res = NULL;
+ DEFINE_DL_LIST(interfaces);
+
+ switch (arg) {
+ case 1:
+ hostapd_cli_get_interfaces(ctrl_conn, &interfaces);
+ res = cli_txt_list_array(&interfaces);
+ cli_txt_list_flush(&interfaces);
+ break;
+ }
+
+ return res;
+}
+
+
static int hostapd_cli_cmd_set(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
char cmd[256];
@@ -1358,7 +1398,7 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
"= show current configuration" },
{ "help", hostapd_cli_cmd_help, hostapd_cli_complete_help,
"= show this usage help" },
- { "interface", hostapd_cli_cmd_interface, NULL,
+ { "interface", hostapd_cli_cmd_interface, hostapd_complete_interface,
"[ifname] = show interfaces/select interface" },
#ifdef CONFIG_FST
{ "fst", hostapd_cli_cmd_fst, NULL, NULL },