Cumulative patch from commit 3eaaca1a0b372f31ddc43d152c3681dce48889bb
3eaaca1 P2P: Allow GO Negotiation Request to update peer entry after PD
443427e P2P: Add missing direct global ctrl_iface commands for P2P
37b4198 P2P: Use GO's operating channel to optimize scan during join
a691d99 P2P: Don't expire the peer, if GO Negotiation is in progress
a0e9d89 Use minimal scan delay upon EVENT_INTERFACE_ADDED
5ddd07c Reset normal_scans counter upon entering INTERFACE_DISABLED state
Change-Id: I07ea029ba6d473af39c74c10b7058de0056695da
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 2b3b182..138ba16 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -41,40 +41,10 @@
* P2P_PEER_EXPIRATION_AGE - Number of seconds after which inactive peer
* entries will be removed
*/
-#ifdef ANDROID_P2P
-#define P2P_PEER_EXPIRATION_AGE 30
-#else
#define P2P_PEER_EXPIRATION_AGE 300
-#endif
#define P2P_PEER_EXPIRATION_INTERVAL (P2P_PEER_EXPIRATION_AGE / 2)
-#ifdef ANDROID_P2P
-int p2p_connection_in_progress(struct p2p_data *p2p)
-{
- int ret = 0;
-
- switch (p2p->state) {
- case P2P_CONNECT:
- case P2P_CONNECT_LISTEN:
- case P2P_GO_NEG:
- case P2P_WAIT_PEER_CONNECT:
- case P2P_WAIT_PEER_IDLE:
- case P2P_PROVISIONING:
- case P2P_INVITE:
- case P2P_INVITE_LISTEN:
- ret = 1;
- break;
-
- default:
- wpa_printf(MSG_DEBUG, "p2p_connection_in_progress state %d", p2p->state);
- ret = 0;
- }
-
- return ret;
-}
-#endif
-
static void p2p_expire_peers(struct p2p_data *p2p)
{
struct p2p_device *dev, *n;
@@ -86,6 +56,15 @@
if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec)
continue;
+ if (dev == p2p->go_neg_peer) {
+ /*
+ * GO Negotiation is in progress with the peer, so
+ * don't expire the peer entry until GO Negotiation
+ * fails or times out.
+ */
+ continue;
+ }
+
if (p2p->cfg->go_connected &&
p2p->cfg->go_connected(p2p->cfg->cb_ctx,
dev->info.p2p_device_addr)) {
@@ -111,13 +90,6 @@
continue;
}
-#ifdef ANDROID_P2P
- /* If Connection is in progress, don't expire the peer
- */
- if (p2p_connection_in_progress(p2p))
- continue;
-#endif
-
p2p_dbg(p2p, "Expiring old peer entry " MACSTR,
MAC2STR(dev->info.p2p_device_addr));
dl_list_del(&dev->list);
diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 874f434..a887a5e 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -590,6 +590,18 @@
dev = p2p_add_dev_from_go_neg_req(p2p, sa, &msg);
else if (dev->flags & P2P_DEV_PROBE_REQ_ONLY)
p2p_add_dev_info(p2p, sa, dev, &msg);
+ else if (!dev->listen_freq && !dev->oper_freq) {
+ /*
+ * This may happen if the peer entry was added based on PD
+ * Request and no Probe Request/Response frame has been received
+ * from this peer (or that information has timed out).
+ */
+ p2p_dbg(p2p, "Update peer " MACSTR
+ " based on GO Neg Req since listen/oper freq not known",
+ MAC2STR(dev->info.p2p_device_addr));
+ p2p_add_dev_info(p2p, sa, dev, &msg);
+ }
+
if (dev && dev->flags & P2P_DEV_USER_REJECTED) {
p2p_dbg(p2p, "User has rejected this peer");
status = P2P_SC_FAIL_REJECTED_BY_USER;
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index de97368..f7ee6e3 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -6345,10 +6345,8 @@
{
#ifdef CONFIG_P2P
static const char * cmd[] = {
-#ifdef ANDROID_P2P
"LIST_NETWORKS",
"SAVE_CONFIG",
-#endif
"P2P_FIND",
"P2P_STOP_FIND",
"P2P_LISTEN",
@@ -6363,12 +6361,12 @@
NULL
};
static const char * prefix[] = {
-#ifdef ANDROID_P2P
+#ifdef ANDROID
"DRIVER ",
+#endif /* ANDROID */
"GET_NETWORK ",
"REMOVE_NETWORK ",
"SET ",
-#endif
"P2P_FIND ",
"P2P_CONNECT ",
"P2P_LISTEN ",
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index fa265bc..f5834d4 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2315,7 +2315,6 @@
wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
"driver after interface was added");
}
- wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
break;
case EVENT_INTERFACE_REMOVED:
wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index c36b65f..91ed508 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -4239,17 +4239,7 @@
struct wpabuf *wps_ie, *ies;
size_t ielen;
int freqs[2] = { 0, 0 };
-#ifdef ANDROID_P2P
- int oper_freq;
- /* If freq is not provided, check the operating freq of the GO and do a
- * a directed scan to save time
- */
- if(!freq) {
- freq = (oper_freq = p2p_get_oper_freq(wpa_s->global->p2p,
- wpa_s->pending_join_iface_addr) == -1) ? 0 : oper_freq;
- }
-#endif
os_memset(¶ms, 0, sizeof(params));
/* P2P Wildcard SSID */
@@ -4289,6 +4279,18 @@
params.p2p_probe = 1;
params.extra_ies = wpabuf_head(ies);
params.extra_ies_len = wpabuf_len(ies);
+
+ if (!freq) {
+ int oper_freq;
+ /*
+ * If freq is not provided, check the operating freq of the GO
+ * and use a single channel scan on if possible.
+ */
+ oper_freq = p2p_get_oper_freq(wpa_s->global->p2p,
+ wpa_s->pending_join_iface_addr);
+ if (oper_freq > 0)
+ freq = oper_freq;
+ }
if (freq > 0) {
freqs[0] = freq;
params.freqs = freqs;
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 78e2749..aa9c32d 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -652,6 +652,11 @@
wpa_supplicant_state_txt(wpa_s->wpa_state),
wpa_supplicant_state_txt(state));
+ if (state == WPA_INTERFACE_DISABLED) {
+ /* Assure normal scan when interface is restored */
+ wpa_s->normal_scans = 0;
+ }
+
if (state == WPA_COMPLETED)
wpas_connect_work_done(wpa_s);
@@ -2618,6 +2623,10 @@
wpa_s->prev_scan_wildcard = 0;
if (wpa_supplicant_enabled_networks(wpa_s)) {
+ if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
+ wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
+ interface_count = 0;
+ }
if (wpa_supplicant_delayed_sched_scan(wpa_s, interface_count,
100000))
wpa_supplicant_req_scan(wpa_s, interface_count,