diff options
author | Arik Nemtsov <arik@wizery.com> | 2012-08-01 11:23:15 +0300 |
---|---|---|
committer | Arik Nemtsov <arik@wizery.com> | 2012-08-02 13:04:02 +0300 |
commit | a888e95ffa9686ee6a505d1e918e301e9f7f0c52 (patch) | |
tree | cbf83a2a34a4c8a1389da6844849a0ba6f897c91 | |
parent | 0172b9bb527a29d6ab3aceec1521ba0eafe64a19 (diff) | |
download | external_wpa_supplicant_8_ti-a888e95ffa9686ee6a505d1e918e301e9f7f0c52.zip external_wpa_supplicant_8_ti-a888e95ffa9686ee6a505d1e918e301e9f7f0c52.tar.gz external_wpa_supplicant_8_ti-a888e95ffa9686ee6a505d1e918e301e9f7f0c52.tar.bz2 |
wpa_s: support p2p concurrency modes when connecting P2P
Prevent P2P connection when STA concurrency requirements do not allow
it. The behavior is determined according to the p2p_conc_mode
config file parameter.
We force go_intent=15 if only GO is allowed and abort the connection
if join is attempted with go_intent=15.
Also manipulate go_intent in our favor (go_intent=14) to minimize the
chances of a concurrency conflict in p2p_conc_mode=2. This supersedes a
similar previous patch by Eyal S.
Signed-off-by: Arik Nemtsov <arik@wizery.com>
-rw-r--r-- | wpa_supplicant/ctrl_iface.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 76eb424..4c21833 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2968,6 +2968,72 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd) } +#ifdef ANDROID_P2P +int p2p_handle_concurrency_conflicts(struct wpa_supplicant *wpa_s, int *go_intent) +{ + struct wpa_supplicant *iface = NULL; + struct p2p_data *p2p = wpa_s->global->p2p; + + wpa_printf(MSG_INFO, "p2p: handling concurrency conflicts"); + + /* we only fear frequency conflicts */ + if (wpa_s->conf->p2p_conc_mode == 0) + return 0; + + /* + * Default GO intent is 14, so we don't interfere with a potential + * later STA connection. As we don't support P2P CL + STA, this + * would minimize our changes for conflict. + */ + if (wpa_s->conf->p2p_conc_mode == 2) { + wpa_printf(MSG_INFO, "p2p: initializing go intent to 14 " + "to minimize concurrent mode conflicts"); + *go_intent = 14; + } + + for (iface = wpa_s->global->ifaces; iface; iface = iface->next) { + /* existing STA connection */ + if(iface->current_ssid && + iface->current_ssid->mode == WPAS_MODE_INFRA) { + + /* we only support P2P GO + STA in same frequency */ + if (wpa_s->conf->p2p_conc_mode == 2) { + wpa_printf(MSG_INFO, "p2p: forcing go intent 15 " + "in connection due to concurrent mode " + "requirements"); + *go_intent = 15; + break; + } + + /* we don't support dual interfaces */ + if (wpa_s->conf->p2p_conc_mode != 1) + continue; + + /* + * In p2p_conc_mode=1 we don't support P2P + STA. + * in this constellation - one of them has to go. + * Remove depending on connection priority. + */ + if(!wpas_is_p2p_prioritized(wpa_s)) { + wpa_printf(MSG_INFO, "P2P: Disallowing p2p " + "connection due to concurrent mode " + "conflict"); + return -1; + } else { + /* Existing connection has the priority. Disable the newly + * selected network and let the application know about it. + */ + wpa_printf(MSG_INFO, "P2P: Disallow STA due to " + "STA + P2P concurrent mode conflict"); + /* TODO: something like "wpa_cli disconnect"? */ + } + } + } + return 0; +} +#endif + + static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, char *buf, size_t buflen) { @@ -3052,6 +3118,20 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, } } +#ifdef ANDROID_P2P + if (p2p_handle_concurrency_conflicts(wpa_s, &go_intent) != 0) { + wpa_printf(MSG_INFO, "P2P: Canceling p2p connect due to " + "single channel concurrency conflicts."); + return -1; + } + + if (join && go_intent == 15) { + wpa_printf(MSG_INFO, "P2P: Canceling p2p join due to " + "single channel concurrency conflicts."); + return -1; + } +#endif + new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method, persistent_group, automatic, join, auth, go_intent, freq, persistent_id, pd); |