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>
This commit is contained in:
Jouni Malinen 2013-05-18 10:19:38 +03:00
parent 058c8636a7
commit cf3bebf28c

View File

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