From 0eed2a8d11f9d4b801d5d41771711545014917a1 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Sun, 5 Aug 2012 20:12:16 +0300 Subject: [PATCH] wpa_cli: Add IFNAME command This command will return wpa_s->ifname that can be used for a nice prompt in wpa_cli. Signed-hostap: Janusz Dziedzic --- wpa_supplicant/ctrl_iface.c | 3 +++ wpa_supplicant/wpa_cli.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 7fe969427..77f9ee1d1 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -4120,6 +4120,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, if (os_strcmp(buf, "PING") == 0) { os_memcpy(reply, "PONG\n", 5); reply_len = 5; + } else if (os_strcmp(buf, "IFNAME") == 0) { + reply_len = os_strlen(wpa_s->ifname); + os_memcpy(reply, wpa_s->ifname, reply_len); } else if (os_strncmp(buf, "RELOG", 5) == 0) { if (wpa_debug_reopen_file() < 0) reply_len = -1; diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index ae67fda00..880aa1381 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -430,6 +430,12 @@ static int wpa_ctrl_command(struct wpa_ctrl *ctrl, char *cmd) } +static int wpa_cli_cmd_ifname(struct wpa_ctrl *ctrl, int argc, char *argv[]) +{ + return wpa_ctrl_command(ctrl, "IFNAME"); +} + + static int wpa_cli_cmd_status(struct wpa_ctrl *ctrl, int argc, char *argv[]) { if (argc > 0 && os_strcmp(argv[0], "verbose") == 0) @@ -2947,6 +2953,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { { "status", wpa_cli_cmd_status, cli_cmd_flag_none, "[verbose] = get current WPA/EAPOL/EAP status" }, + { "ifname", wpa_cli_cmd_ifname, + cli_cmd_flag_none, + "= get current interface name" }, { "ping", wpa_cli_cmd_ping, cli_cmd_flag_none, "= pings wpa_supplicant" },