P2P: Direct global ctrl_iface commands automatically for P2P

The P2P management operations like P2P_FIND and P2P_CONNECT are not
really specific to any network interface. These are P2P Device level
operations that are in more global device context. Allow those to be
sent through the global control interface without IFNAME parameter.

For now, these commands are directed within wpa_supplicant to the
network interface that initialized the global P2P context. This may
change in the future if a special context is added for P2P operations.
Anyway, such changes can now be done internally within wpa_supplicant
without affecting this global control interface design from external
view point.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-05-18 19:41:08 +03:00
parent c4bf83a723
commit 576bce9c86

View file

@ -5822,6 +5822,102 @@ static char * wpas_global_ctrl_iface_ifname(struct wpa_global *global,
}
static char * wpas_global_ctrl_iface_redir_p2p(struct wpa_global *global,
char *buf, size_t *resp_len)
{
#ifdef CONFIG_P2P
static const char * cmd[] = {
"P2P_FIND",
"P2P_STOP_FIND",
"P2P_LISTEN",
"P2P_GROUP_ADD",
"P2P_GET_PASSPHRASE",
"P2P_SERVICE_UPDATE",
"P2P_SERVICE_FLUSH",
"P2P_FLUSH",
"P2P_CANCEL",
"P2P_PRESENCE_REQ",
"P2P_EXT_LISTEN",
NULL
};
static const char * prefix[] = {
"P2P_FIND ",
"P2P_CONNECT ",
"P2P_LISTEN ",
"P2P_GROUP_REMOVE ",
"P2P_GROUP_ADD ",
"P2P_PROV_DISC ",
"P2P_SERV_DISC_REQ ",
"P2P_SERV_DISC_CANCEL_REQ ",
"P2P_SERV_DISC_RESP ",
"P2P_SERV_DISC_EXTERNAL ",
"P2P_SERVICE_ADD ",
"P2P_SERVICE_DEL ",
"P2P_REJECT ",
"P2P_INVITE ",
"P2P_PEER ",
"P2P_SET ",
"P2P_UNAUTHORIZE ",
"P2P_PRESENCE_REQ ",
"P2P_EXT_LISTEN ",
NULL
};
int found = 0;
int i;
if (global->p2p_init_wpa_s == NULL)
return NULL;
for (i = 0; !found && cmd[i]; i++) {
if (os_strcmp(buf, cmd[i]) == 0)
found = 1;
}
for (i = 0; !found && prefix[i]; i++) {
if (os_strncmp(buf, prefix[i], os_strlen(prefix[i])) == 0)
found = 1;
}
if (found)
return wpa_supplicant_ctrl_iface_process(global->p2p_init_wpa_s,
buf, resp_len);
#endif /* CONFIG_P2P */
return NULL;
}
static char * wpas_global_ctrl_iface_redir_wfd(struct wpa_global *global,
char *buf, size_t *resp_len)
{
#ifdef CONFIG_WIFI_DISPLAY
if (global->p2p_init_wpa_s == NULL)
return NULL;
if (os_strncmp(buf, "WFD_SUBELEM_SET ", 16) == 0 ||
os_strncmp(buf, "WFD_SUBELEM_GET ", 16) == 0)
return wpa_supplicant_ctrl_iface_process(global->p2p_init_wpa_s,
buf, resp_len);
#endif /* CONFIG_WIFI_DISPLAY */
return NULL;
}
static char * wpas_global_ctrl_iface_redir(struct wpa_global *global,
char *buf, size_t *resp_len)
{
char *ret;
ret = wpas_global_ctrl_iface_redir_p2p(global, buf, resp_len);
if (ret)
return ret;
ret = wpas_global_ctrl_iface_redir_wfd(global, buf, resp_len);
if (ret)
return ret;
return NULL;
}
char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
char *buf, size_t *resp_len)
{
@ -5840,6 +5936,10 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
}
}
reply = wpas_global_ctrl_iface_redir(global, buf, resp_len);
if (reply)
return reply;
if (os_strcmp(buf, "PING") == 0)
level = MSG_EXCESSIVE;
wpa_hexdump_ascii(level, "RX global ctrl_iface",