Patchwork [RFC,3/4] wpa_cli: add IFNAME command

login
register
mail settings
Submitter Janusz.Dziedzic@tieto.com
Date Aug. 2, 2012, 11:01 a.m.
Message ID <3078A9B976EF864C8DDD0C499FFD07912150C655E5@EXMB01.eu.tieto.com>
Download mbox | patch
Permalink /patch/174730/
State Accepted
Headers show

Comments

Janusz.Dziedzic@tieto.com - Aug. 2, 2012, 11:01 a.m.
This command will return wpa_s->ifname.
Could be used as a nice prompt in wpa_cli.

Signed-hostap: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 wpa_supplicant/ctrl_iface.c |    3 +++
 wpa_supplicant/wpa_cli.c    |    8 ++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

Patch

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 82dbf86..06e315c 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4070,6 +4070,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) {
+		os_memcpy(reply, wpa_s->ifname, os_strlen(wpa_s->ifname));
+		reply_len = os_strlen(wpa_s->ifname);
 	} 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 b159ad3..7a06f09 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -430,6 +430,11 @@  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 +2952,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" },