P2P: Add peer entry based on Provision Discovery Request
authorArdong Chen <ardongchen@atheros.com>
Mon, 6 Sep 2010 13:51:46 +0000 (16:51 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 10 Sep 2010 17:30:25 +0000 (10:30 -0700)
Add (or complete Probe Request only) P2P peer entry when receiving
Provision Discovery Request from a previously unknown peer. This is
especially of use for a GO when a P2P client is requesting to join
a running group.

src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_pd.c

index 7a1a315..1247678 100644 (file)
@@ -419,10 +419,12 @@ static int p2p_add_group_clients(struct p2p_data *p2p, const u8 *go_dev_addr,
  * Returns: 0 on success, -1 on failure
  *
  * If the scan result is for a GO, the clients in the group will also be added
- * to the peer table.
+ * to the peer table. This function can also be used with some other frames
+ * like Provision Discovery Request that contains P2P Capability and P2P Device
+ * Info attributes.
  */
-static int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
-                         int level, const u8 *ies, size_t ies_len)
+int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
+                  const u8 *ies, size_t ies_len)
 {
        struct p2p_device *dev;
        struct p2p_message msg;
index c34c97b..46a4e29 100644 (file)
@@ -1235,4 +1235,7 @@ void p2p_set_cross_connect(struct p2p_data *p2p, int enabled);
 
 int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr);
 
+int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
+                  const u8 *ies, size_t ies_len);
+
 #endif /* P2P_H */
index 2a16315..b942ab8 100644 (file)
@@ -105,10 +105,15 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
                MAC2STR(sa), msg.wps_config_methods, rx_freq);
 
        dev = p2p_get_device(p2p, sa);
-       if (dev == NULL) {
+       if (dev == NULL || !(dev->flags & P2P_DEV_PROBE_REQ_ONLY)) {
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                        "P2P: Provision Discovery Request from "
                        "unknown peer " MACSTR, MAC2STR(sa));
+               if (p2p_add_device(p2p, sa, rx_freq, 0, data + 1, len - 1)) {
+                       wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+                               "P2P: Provision Discovery Request add device "
+                               "failed " MACSTR, MAC2STR(sa));
+               }
        }
 
        if (!(msg.wps_config_methods &