diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 423765713..2f4c1147c 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -62,6 +62,18 @@ static void p2p_expire_peers(struct p2p_data *p2p) dl_list_for_each_safe(dev, n, &p2p->devices, struct p2p_device, list) { if (dev->last_seen.sec + P2P_PEER_EXPIRATION_AGE >= now.sec) continue; + + if (p2p->cfg->go_connected && + p2p->cfg->go_connected(p2p->cfg->cb_ctx, + dev->info.p2p_device_addr)) { + /* + * We are connected as a client to a group in which the + * peer is the GO, so do not expire the peer entry. + */ + os_get_time(&dev->last_seen); + continue; + } + for (i = 0; i < p2p->num_groups; i++) { if (p2p_group_is_client_connected( p2p->groups[i], dev->info.p2p_device_addr)) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index d929c5084..0924db5cc 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -706,6 +706,15 @@ struct p2p_config { * local failure in transmitting the Invitation Request. */ void (*invitation_result)(void *ctx, int status, const u8 *bssid); + + /** + * go_connected - Check whether we are connected to a GO + * @ctx: Callback context from cb_ctx + * @dev_addr: P2P Device Address of a GO + * Returns: 1 if we are connected as a P2P client to the specified GO + * or 0 if not. + */ + int (*go_connected)(void *ctx, const u8 *dev_addr); }; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 523a2467d..9bc298a1c 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -125,6 +125,9 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s) bssid_changed = !is_zero_ether_addr(wpa_s->bssid); os_memset(wpa_s->bssid, 0, ETH_ALEN); os_memset(wpa_s->pending_bssid, 0, ETH_ALEN); +#ifdef CONFIG_P2P + os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN); +#endif /* CONFIG_P2P */ wpa_s->current_bss = NULL; wpa_s->assoc_freq = 0; #ifdef CONFIG_IEEE80211R diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index e8834ef07..4c271e1e4 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -2207,6 +2207,26 @@ static int wpas_get_noa(void *ctx, const u8 *interface_addr, u8 *buf, } +static int wpas_go_connected(void *ctx, const u8 *dev_addr) +{ + struct wpa_supplicant *wpa_s = ctx; + + for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { + struct wpa_ssid *ssid = wpa_s->current_ssid; + if (ssid == NULL) + continue; + if (ssid->mode != WPAS_MODE_INFRA) + continue; + if (wpa_s->wpa_state != WPA_COMPLETED) + continue; + if (os_memcmp(wpa_s->go_dev_addr, dev_addr, ETH_ALEN) == 0) + return 1; + } + + return 0; +} + + /** * wpas_p2p_init - Initialize P2P module for %wpa_supplicant * @global: Pointer to global data from wpa_supplicant_init() @@ -2266,6 +2286,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s) p2p.invitation_received = wpas_invitation_received; p2p.invitation_result = wpas_invitation_result; p2p.get_noa = wpas_get_noa; + p2p.go_connected = wpas_go_connected; os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN); os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN);