P2P: Set Invitation Type to 1 for GO inviting to a persistent group

When a GO is operating a persistent group and invites a peer that has
been a P2P client in that persistent group, the Invitation Type in the
Invitation Request frame can be set to 1 to indicate that this is a
reinvocation of a persistent group. Do this based on the maintained
list of P2P clients that have been provided the credentials to this
group.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-02-06 21:54:36 +02:00
parent f63b854215
commit c427ac9211
3 changed files with 16 additions and 5 deletions

View file

@ -3053,7 +3053,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
return pos - buf; return pos - buf;
pos += res; pos += res;
ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr); ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr, NULL, 0);
if (ssid) { if (ssid) {
res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id); res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id);
if (res < 0 || res >= end - pos) if (res < 0 || res >= end - pos)

View file

@ -3736,6 +3736,7 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
enum p2p_invite_role role; enum p2p_invite_role role;
u8 *bssid = NULL; u8 *bssid = NULL;
struct wpa_ssid *ssid; struct wpa_ssid *ssid;
int persistent;
for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
if (os_strcmp(wpa_s->ifname, ifname) == 0) if (os_strcmp(wpa_s->ifname, ifname) == 0)
@ -3753,6 +3754,10 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
return -1; return -1;
} }
persistent = ssid->p2p_persistent_group &&
wpas_p2p_get_persistent(wpa_s->parent, peer_addr,
ssid->ssid, ssid->ssid_len);
if (ssid->mode == WPAS_MODE_P2P_GO) { if (ssid->mode == WPAS_MODE_P2P_GO) {
role = P2P_INVITE_ROLE_ACTIVE_GO; role = P2P_INVITE_ROLE_ACTIVE_GO;
bssid = wpa_s->own_addr; bssid = wpa_s->own_addr;
@ -3775,14 +3780,14 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname,
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
return wpa_drv_p2p_invite(wpa_s, peer_addr, role, bssid, return wpa_drv_p2p_invite(wpa_s, peer_addr, role, bssid,
ssid->ssid, ssid->ssid_len, ssid->ssid, ssid->ssid_len,
go_dev_addr, 0); go_dev_addr, persistent);
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return -1; return -1;
return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid, return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid,
ssid->ssid, ssid->ssid_len, wpa_s->assoc_freq, ssid->ssid, ssid->ssid_len, wpa_s->assoc_freq,
go_dev_addr, 0); go_dev_addr, persistent);
} }
@ -4382,7 +4387,8 @@ void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
const u8 *addr) const u8 *addr, const u8 *ssid,
size_t ssid_len)
{ {
struct wpa_ssid *s; struct wpa_ssid *s;
size_t i; size_t i;
@ -4390,6 +4396,10 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
for (s = wpa_s->conf->ssid; s; s = s->next) { for (s = wpa_s->conf->ssid; s; s = s->next) {
if (s->disabled != 2) if (s->disabled != 2)
continue; continue;
if (ssid &&
(ssid_len != s->ssid_len ||
os_memcmp(ssid, s->ssid, ssid_len) != 0))
continue;
if (os_memcmp(s->bssid, addr, ETH_ALEN) == 0) if (os_memcmp(s->bssid, addr, ETH_ALEN) == 0)
return s; /* peer is GO in the persistent group */ return s; /* peer is GO in the persistent group */
if (s->mode != WPAS_MODE_P2P_GO || s->p2p_client_list == NULL) if (s->mode != WPAS_MODE_P2P_GO || s->p2p_client_list == NULL)

View file

@ -133,7 +133,8 @@ int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s);
void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s, void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid); struct wpa_ssid *ssid);
struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
const u8 *addr); const u8 *addr, const u8 *ssid,
size_t ssid_len);
void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
const u8 *addr); const u8 *addr);