From 8017b538e70f2c27feefb8746ae1f876d2c42f37 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 8 Jan 2012 09:35:33 -0800 Subject: [PATCH] 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 --- src/ap/beacon.c | 12 ++++++++++++ src/p2p/p2p.h | 5 +++++ src/p2p/p2p_group.c | 25 +++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 4d8b27769..4ea868448 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -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) { diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 762499abf..ce41ca801 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -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() diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c index 59d1507b3..6fa3e21d8 100644 --- a/src/p2p/p2p_group.c +++ b/src/p2p/p2p_group.c @@ -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)