aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-05-18 07:19:38 (GMT)
committerJouni Malinen <j@w1.fi>2013-05-18 07:19:38 (GMT)
commitcf3bebf28cdac99e888b3bda1a3ad7e333d5f962 (patch)
tree71d6d01d4450b196c648dbbc6b0bd33119254e16 /wpa_supplicant/ctrl_iface.c
parent058c8636a7d2f258dc4268089f66fc90895e5737 (diff)
downloadhostap-cf3bebf28cdac99e888b3bda1a3ad7e333d5f962.zip
hostap-cf3bebf28cdac99e888b3bda1a3ad7e333d5f962.tar.gz
hostap-cf3bebf28cdac99e888b3bda1a3ad7e333d5f962.tar.bz2
Allow global ctrl_iface to be used for per-interface commands
"IFNAME=<ifname> " prefix can now be used on the wpa_supplicant global control interface to direct a command to a specific interface instead of having to use an interface specific control interface for this. This allows a single socket to be used for controlling multiple virtual interfaces. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/ctrl_iface.c')
-rw-r--r--wpa_supplicant/ctrl_iface.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 1bfdb02..465d3ff 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -5798,6 +5798,30 @@ static int wpa_supplicant_global_iface_interfaces(struct wpa_global *global,
}
+static char * wpas_global_ctrl_iface_ifname(struct wpa_global *global,
+ const char *ifname,
+ char *cmd, size_t *resp_len)
+{
+ struct wpa_supplicant *wpa_s;
+
+ for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
+ if (os_strcmp(ifname, wpa_s->ifname) == 0)
+ break;
+ }
+
+ if (wpa_s == NULL) {
+ char *resp = os_strdup("FAIL-NO-IFNAME-MATCH\n");
+ if (resp)
+ *resp_len = os_strlen(resp);
+ else
+ *resp_len = 1;
+ return resp;
+ }
+
+ return wpa_supplicant_ctrl_iface_process(wpa_s, cmd, resp_len);
+}
+
+
char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
char *buf, size_t *resp_len)
{
@@ -5806,6 +5830,16 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
int reply_len;
int level = MSG_DEBUG;
+ if (os_strncmp(buf, "IFNAME=", 7) == 0) {
+ char *pos = os_strchr(buf + 7, ' ');
+ if (pos) {
+ *pos++ = '\0';
+ return wpas_global_ctrl_iface_ifname(global,
+ buf + 7, pos,
+ resp_len);
+ }
+ }
+
if (os_strcmp(buf, "PING") == 0)
level = MSG_EXCESSIVE;
wpa_hexdump_ascii(level, "RX global ctrl_iface",