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 <janusz.dziedzic@tieto.com>
This commit is contained in:
Janusz Dziedzic 2012-08-05 20:12:16 +03:00 committed by Jouni Malinen
parent d302edd3c4
commit 0eed2a8d11
2 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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" },