P2P: Use Device ID attribute to filter Probe Request frames as GO

The Device ID attribute was already used in Listen state, but it was
ignored in GO role. Verify that there is a match with Device ID in
GO rule, too, before replying to the Probe Request frame.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-01-08 09:35:33 -08:00
parent 6d92fa6e92
commit 8017b538e7
3 changed files with 42 additions and 0 deletions

View file

@ -343,6 +343,18 @@ void handle_probe_req(struct hostapd_data *hapd,
}
wpabuf_free(wps);
}
if (hapd->p2p && elems.p2p) {
struct wpabuf *p2p;
p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE);
if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) {
wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
"due to mismatch with Device ID");
wpabuf_free(p2p);
return;
}
wpabuf_free(p2p);
}
#endif /* CONFIG_P2P */
if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0) {

View file

@ -1326,6 +1326,11 @@ int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
*/
int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps);
/**
* p2p_group_match_dev_id - Match P2P Device Address in group with requested device id
*/
int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p);
/**
* p2p_group_go_discover - Send GO Discoverability Request to a group client
* @group: P2P group context from p2p_group_init()

View file

@ -490,6 +490,31 @@ int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps)
}
int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p)
{
struct p2p_group_member *m;
struct p2p_message msg;
os_memset(&msg, 0, sizeof(msg));
if (p2p_parse_p2p_ie(p2p, &msg))
return 1; /* Failed to parse - assume no filter on Device ID */
if (!msg.device_id)
return 1; /* No filter on Device ID */
if (os_memcmp(msg.device_id, group->p2p->cfg->dev_addr, ETH_ALEN) == 0)
return 1; /* Match with our P2P Device Address */
for (m = group->members; m; m = m->next) {
if (os_memcmp(msg.device_id, m->dev_addr, ETH_ALEN) == 0)
return 1; /* Match with group client P2P Device Address */
}
/* No match with Device ID */
return 0;
}
void p2p_group_notif_formation_done(struct p2p_group *group)
{
if (group == NULL)