]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AOSP: P2P SD changes
authorJouni Malinen <j@w1.fi>
Fri, 1 Nov 2013 09:55:58 +0000 (11:55 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 26 Oct 2014 16:08:58 +0000 (18:08 +0200)
This is rebased version (with couple of changes removed) of this AOSP
commit:

 From f44b9c4a18d17fbd39901f76a014c32006570fb8 Mon Sep 17 00:00:00 2001
 From: Irfan Sheriff <isheriff@google.com>
 Date: Wed, 13 Jun 2012 11:09:23 -0700
 Subject: [PATCH] Fix p2p service discovery

- Fix listen timing to improve SD reliability
- Fix SD packet scheduling

Bug: 6629112
Change-Id: I01365279439116256372d019bdbfd4b2113bf2ce

src/p2p/p2p.c
src/p2p/p2p_i.h
src/p2p/p2p_sd.c

index 394a00d10eb558227eb9ab723279617baf5584c9..654e0104a056b5c2065f0c0b55e60101dbb25966 100644 (file)
@@ -95,6 +95,12 @@ static void p2p_expire_peers(struct p2p_data *p2p)
 
                p2p_dbg(p2p, "Expiring old peer entry " MACSTR,
                        MAC2STR(dev->info.p2p_device_addr));
+
+#ifdef ANDROID_P2P
+               /* SD_FAIR_POLICY: Update the current sd_dev_list pointer to next device */
+               if(&dev->list == p2p->sd_dev_list)
+                       p2p->sd_dev_list = dev->list.next;
+#endif
                dl_list_del(&dev->list);
                p2p_device_free(p2p, dev);
        }
@@ -417,6 +423,11 @@ static struct p2p_device * p2p_create_device(struct p2p_data *p2p,
        }
        if (count + 1 > p2p->cfg->max_peers && oldest) {
                p2p_dbg(p2p, "Remove oldest peer entry to make room for a new peer");
+#ifdef ANDROID_P2P
+               /* SD_FAIR_POLICY: Update the current sd_dev_list pointer to next device */
+               if(&oldest->list == p2p->sd_dev_list)
+                       p2p->sd_dev_list = oldest->list.next;
+#endif
                dl_list_del(&oldest->list);
                p2p_device_free(p2p, oldest);
        }
@@ -1017,7 +1028,15 @@ static int p2p_run_after_scan(struct p2p_data *p2p)
                                      p2p->after_scan_tx->wait_time);
                os_free(p2p->after_scan_tx);
                p2p->after_scan_tx = NULL;
+#ifdef ANDROID_P2P
+               /* For SD frames, there is a scenario, where we can receive a SD request frame during p2p_scan.
+                * At that moment, we will send the SD response from this context. After sending the SD response,
+                * we need to continue p2p_find. But if we return 1 from here, p2p_find is going to be stopped.
+                */
+               return 0;
+#else
                return 1;
+#endif
        }
 
        op = p2p->start_after_scan;
@@ -2500,7 +2519,16 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg)
                        p2p->cfg->num_pref_chan = 0;
        }
 
+#ifdef ANDROID_P2P
+       /* 100ms listen time is too less to receive the response frames in some scenarios
+        * increasing min listen time to 200ms.
+        */
+       p2p->min_disc_int = 2;
+       /* SD_FAIR_POLICY: Initializing the SD current serviced pointer to NULL */
+       p2p->sd_dev_list = NULL;
+#else
        p2p->min_disc_int = 1;
+#endif
        p2p->max_disc_int = 3;
        p2p->max_disc_tu = -1;
 
@@ -2577,6 +2605,10 @@ void p2p_flush(struct p2p_data *p2p)
                dl_list_del(&dev->list);
                p2p_device_free(p2p, dev);
        }
+#ifdef ANDROID_P2P
+       /* SD_FAIR_POLICY: Initializing the SD current serviced pointer to NULL */
+       p2p->sd_dev_list = NULL;
+#endif
        p2p_free_sd_queries(p2p);
        os_free(p2p->after_scan_tx);
        p2p->after_scan_tx = NULL;
@@ -2782,6 +2814,9 @@ void p2p_continue_find(struct p2p_data *p2p)
        struct p2p_device *dev;
        int found;
 
+#ifdef ANDROID_P2P
+       int skip=1;
+#endif
        p2p_set_state(p2p, P2P_SEARCH);
 
        /* Continue from the device following the last iteration */
index bb8952d1e28a189129bb02d8e345882390a6c1c6..26f2272dd8b5ec5807548040ab11287f2c89bb90 100644 (file)
@@ -251,6 +251,14 @@ struct p2p_data {
         */
        struct dl_list devices;
 
+#ifdef ANDROID_P2P
+       /**
+        * sd_dev_list - device pointer to be serviced next
+        * for service discovery
+        */
+       struct dl_list *sd_dev_list;
+#endif
+
        /**
         * go_neg_peer - Pointer to GO Negotiation peer
         */
index 1a2af04b8004393b362275a791acb78c9452f2ea..88feec1bb47628f2b83742544523a854d8a14866 100644 (file)
@@ -849,6 +849,19 @@ 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
 
        q = os_zalloc(sizeof(*q));
        if (q == NULL)