From a7ca6dac440230b6ec9a49b022d734e99355754d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 15 Apr 2014 13:22:48 +0300 Subject: [PATCH] Fix P2P redirection of global ctrl_iface SET command The previous version prevented all use of wpas_global_ctrl_iface_set(). That's not desirable since there may be more global parameters added in the future. Instead, try to use the global version first and redirect to P2P interface only if the global version returns an error. Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 377098052..b8b6d951b 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -6821,7 +6821,6 @@ static char * wpas_global_ctrl_iface_redir_p2p(struct wpa_global *global, #endif /* ANDROID */ "GET_NETWORK ", "REMOVE_NETWORK ", - "SET ", "P2P_FIND ", "P2P_CONNECT ", "P2P_LISTEN ", @@ -6921,6 +6920,9 @@ static int wpas_global_ctrl_iface_set(struct wpa_global *global, char *cmd) } #endif /* CONFIG_WIFI_DISPLAY */ + /* Restore cmd to its original value to allow redirection */ + value[-1] = ' '; + return -1; } @@ -7064,8 +7066,19 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global, } else if (os_strcmp(buf, "RESUME") == 0) { wpas_notify_resume(global); } else if (os_strncmp(buf, "SET ", 4) == 0) { - if (wpas_global_ctrl_iface_set(global, buf + 4)) + if (wpas_global_ctrl_iface_set(global, buf + 4)) { +#ifdef CONFIG_P2P + if (global->p2p_init_wpa_s) { + os_free(reply); + /* Check if P2P redirection would work for this + * command. */ + return wpa_supplicant_ctrl_iface_process( + global->p2p_init_wpa_s, + buf, resp_len); + } +#endif /* CONFIG_P2P */ reply_len = -1; + } #ifndef CONFIG_NO_CONFIG_WRITE } else if (os_strcmp(buf, "SAVE_CONFIG") == 0) { if (wpas_global_ctrl_iface_save_config(global))