aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wpa_cli.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-05-23 17:04:17 (GMT)
committerJouni Malinen <j@w1.fi>2013-05-23 17:04:17 (GMT)
commit13b11ba70260d99de5015e06142b6168d645c169 (patch)
treedab88e562af33761cb2d9f92540758bb65ded3d6 /wpa_supplicant/wpa_cli.c
parentae8535b6e1a98ca40ce87650a4179851e7cd13a7 (diff)
downloadhostap-13b11ba70260d99de5015e06142b6168d645c169.zip
hostap-13b11ba70260d99de5015e06142b6168d645c169.tar.gz
hostap-13b11ba70260d99de5015e06142b6168d645c169.tar.bz2
wpa_cli: Allow IFNAME= prefix to be used
Strip out the IFNAME=<ifname> prefix from commands before parsing them through the normal processing and then add the prefix back to the beginning of the actual control interface command to make per-interface commands work through the global control interface without having to use the 'raw' command. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/wpa_cli.c')
-rw-r--r--wpa_supplicant/wpa_cli.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 9a17b84..20b699c 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-2012, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -81,6 +81,7 @@ static const char *pid_file = NULL;
static const char *action_file = NULL;
static int ping_interval = 5;
static int interactive = 0;
+static char *ifname_prefix = NULL;
struct cli_txt_entry {
struct dl_list list;
@@ -404,6 +405,12 @@ static int _wpa_ctrl_command(struct wpa_ctrl *ctrl, char *cmd, int print)
printf("Not connected to wpa_supplicant - command dropped.\n");
return -1;
}
+ if (ifname_prefix) {
+ os_snprintf(buf, sizeof(buf), "IFNAME=%s %s",
+ ifname_prefix, cmd);
+ buf[sizeof(buf) - 1] = '\0';
+ cmd = buf;
+ }
len = sizeof(buf) - 1;
ret = wpa_ctrl_request(ctrl, cmd, os_strlen(cmd), buf, &len,
wpa_cli_msg_cb);
@@ -2889,6 +2896,16 @@ static int wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[])
int count;
int ret = 0;
+ if (argc > 1 && os_strncasecmp(argv[0], "IFNAME=", 7) == 0) {
+ ifname_prefix = argv[0] + 7;
+ argv = &argv[1];
+ argc--;
+ } else
+ ifname_prefix = NULL;
+
+ if (argc == 0)
+ return -1;
+
count = 0;
cmd = wpa_cli_commands;
while (cmd->cmd) {