]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add p2p_get_peer_found to get peer info
authorJohannes Berg <johannes.berg@intel.com>
Thu, 24 Feb 2011 20:05:22 +0000 (22:05 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Feb 2011 20:05:22 +0000 (22:05 +0200)
This will only retrieve information about peers that have been fully
discovered, not peers that are only half-discovered based on their Probe
Request frames.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
src/p2p/p2p.c
src/p2p/p2p.h

index d422499008ad5cf0f6a5658e515daa99cca45cc1..76cdf277a0b62b8166c1825bff1d8069bfe9a774 100644 (file)
@@ -3239,3 +3239,44 @@ const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p)
                return NULL;
        return p2p->go_neg_peer->info.p2p_device_addr;
 }
+
+
+const struct p2p_peer_info *
+p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next)
+{
+       struct p2p_device *dev;
+
+       if (addr) {
+               dev = p2p_get_device(p2p, addr);
+               if (!dev)
+                       return NULL;
+
+               if (!next) {
+                       if (dev->flags & P2P_DEV_PROBE_REQ_ONLY)
+                               return NULL;
+
+                       return &dev->info;
+               } else {
+                       do {
+                               dev = dl_list_first(&dev->list,
+                                                   struct p2p_device,
+                                                   list);
+                               if (&dev->list == &p2p->devices)
+                                       return NULL;
+                       } while (dev->flags & P2P_DEV_PROBE_REQ_ONLY);
+               }
+       } else {
+               dev = dl_list_first(&p2p->devices, struct p2p_device, list);
+               if (!dev)
+                       return NULL;
+               while (dev->flags & P2P_DEV_PROBE_REQ_ONLY) {
+                       dev = dl_list_first(&dev->list,
+                                           struct p2p_device,
+                                           list);
+                       if (&dev->list == &p2p->devices)
+                               return NULL;
+               }
+       }
+
+       return &dev->info;
+}
index baf51d8bb79ec9f8b7b0a0ab6cc00eff01e2b2b1..0d09d1e941b82a69c32e91ed434dd94afaed3fea 100644 (file)
@@ -1372,4 +1372,14 @@ unsigned int p2p_get_group_num_members(struct p2p_group *group);
  */
 const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
 
+/**
+ * p2p_get_peer_found - Get P2P peer info structure of a found peer
+ * @p2p: P2P module context from p2p_init()
+ * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
+ * @next: Whether to select the peer entry following the one indicated by addr
+ * Returns: The first P2P peer info available or %NULL if no such peer exists
+ */
+const struct p2p_peer_info *
+p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
+
 #endif /* P2P_H */