aboutsummaryrefslogtreecommitdiffstats
path: root/src/p2p/p2p_sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p/p2p_sd.c')
-rw-r--r--src/p2p/p2p_sd.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/p2p/p2p_sd.c b/src/p2p/p2p_sd.c
index 0e0c7f1..8aeb3c9 100644
--- a/src/p2p/p2p_sd.c
+++ b/src/p2p/p2p_sd.c
@@ -819,6 +819,20 @@ void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
const struct wpabuf *tlvs)
{
struct p2p_sd_query *q;
+#ifdef ANDROID_P2P
+ /* Currently, supplicant doesn't support more than one pending
+ * broadcast SD request. So reject if application is registering
+ * another one before cancelling the existing one.
+ */
+ for (q = p2p->sd_queries; q; q = q->next) {
+ if ((q->for_all_peers == 1) && !dst) {
+ wpa_printf(MSG_ERROR, "P2P: Already one pending "
+ "Broadcast request. Please cancel the "
+ "current one before adding a new one");
+ return NULL;
+ }
+ }
+#endif /* ANDROID_P2P */
q = os_zalloc(sizeof(*q));
if (q == NULL)
@@ -837,7 +851,7 @@ void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
q->next = p2p->sd_queries;
p2p->sd_queries = q;
- p2p_dbg(p2p, "Added SD Query %p", q);
+ p2p_dbg(p2p, "Added SD Query %p for_all_peers %d", q, q->for_all_peers);
if (dst == NULL) {
struct p2p_device *dev;
@@ -871,7 +885,24 @@ void p2p_sd_service_update(struct p2p_data *p2p)
int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
{
if (p2p_unlink_sd_query(p2p, req)) {
+#ifdef ANDROID_P2P
+ struct p2p_device *dev;
+ struct p2p_sd_query *q = req;
+#endif /* ANDROID_P2P */
p2p_dbg(p2p, "Cancel pending SD query %p", req);
+#ifdef ANDROID_P2P
+ /* If the request is a bcast query, then clear the
+ * P2P_DEV_SD_INFO flag so that when new sd query is
+ * registered,* we will send the SD request frames to peer
+ * devices.
+ */
+ if (q->for_all_peers) {
+ p2p->sd_dev_list = NULL;
+ dl_list_for_each(dev, &p2p->devices,
+ struct p2p_device, list)
+ dev->flags &= ~P2P_DEV_SD_INFO;
+ }
+#endif /* ANDROID_P2P */
p2p_free_sd_query(req);
return 0;
}