]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Use Device ID attribute to filter Probe Request frames as GO
authorJouni Malinen <j@w1.fi>
Sun, 8 Jan 2012 17:35:33 +0000 (09:35 -0800)
committerJouni Malinen <j@w1.fi>
Sun, 8 Jan 2012 17:35:33 +0000 (09:35 -0800)
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>

src/ap/beacon.c
src/p2p/p2p.h
src/p2p/p2p_group.c

index 4d8b27769a52bb0be7552fb7945d3fb8e2ec9e33..4ea8684487de02054858265731210d0b9a2e0d6c 100644 (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) {
index 762499abfac7ef8b7739194e73587348aece35e3..ce41ca801cc0eba0846881583733017c94499fd0 100644 (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()
index 59d1507b3a288331363780a18c331cfa18e781fe..6fa3e21d87c00290d5e5336322fbf6be34a16bea 100644 (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)