]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Do not update peer Listen channel based on PD/Invitation
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 26 Apr 2012 13:11:17 +0000 (16:11 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 26 Apr 2012 13:11:17 +0000 (16:11 +0300)
Commits 17bef1e97a5061a8b5443dc24166e28439911f0b and
ffe98dfb88a19b66418184955ef272789e3abb68 started using p2p_add_device()
with other frames than just Probe Response frames from scan results.
However, these changes did not take into account that the PD Request
and Invitation Request frames are normally received on the our own
Listen channel, not on the Listen channel of the peer. As such, these
frames must not be used to update Listen channel information for the
peer.

Fix this by letting p2p_add_device() know whether the results are from
scan results and if not, skip the peer table updates that are specific
to Probe Response frames.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
intended-for: hostap-1

src/p2p/p2p.c
src/p2p/p2p_i.h
src/p2p/p2p_invitation.c
src/p2p/p2p_pd.c

index a23ccafe082b140d6b834acf2764fd7fac5a67c9..474dd73cea03b0e2e424074c8ff6f81fd8f7b4c7 100644 (file)
@@ -544,7 +544,7 @@ static void p2p_copy_wps_info(struct p2p_device *dev, int probe_req,
 
 
 /**
- * p2p_add_device - Add peer entries based on scan results
+ * p2p_add_device - Add peer entries based on scan results or P2P frames
  * @p2p: P2P module context from p2p_init()
  * @addr: Source address of Beacon or Probe Response frame (may be either
  *     P2P Device Address or P2P Interface Address)
@@ -552,6 +552,7 @@ static void p2p_copy_wps_info(struct p2p_device *dev, int probe_req,
  * @freq: Frequency on which the Beacon or Probe Response frame was received
  * @ies: IEs from the Beacon or Probe Response frame
  * @ies_len: Length of ies buffer in octets
+ * @scan_res: Whether this was based on scan results
  * Returns: 0 on success, -1 on failure
  *
  * If the scan result is for a GO, the clients in the group will also be added
@@ -560,7 +561,7 @@ static void p2p_copy_wps_info(struct p2p_device *dev, int probe_req,
  * Info attributes.
  */
 int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
-                  const u8 *ies, size_t ies_len)
+                  const u8 *ies, size_t ies_len, int scan_res)
 {
        struct p2p_device *dev;
        struct p2p_message msg;
@@ -629,16 +630,18 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
                }
        }
 
-       if (dev->listen_freq && dev->listen_freq != freq) {
+       if (dev->listen_freq && dev->listen_freq != freq && scan_res) {
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                        "P2P: Update Listen frequency based on scan "
                        "results (" MACSTR " %d -> %d MHz (DS param %d)",
                        MAC2STR(dev->info.p2p_device_addr), dev->listen_freq,
                        freq, msg.ds_params ? *msg.ds_params : -1);
        }
-       dev->listen_freq = freq;
-       if (msg.group_info)
-               dev->oper_freq = freq;
+       if (scan_res) {
+               dev->listen_freq = freq;
+               if (msg.group_info)
+                       dev->oper_freq = freq;
+       }
        dev->info.level = level;
 
        p2p_copy_wps_info(dev, 0, &msg);
@@ -657,8 +660,10 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
                        break;
        }
 
-       p2p_add_group_clients(p2p, p2p_dev_addr, addr, freq, msg.group_info,
-                             msg.group_info_len);
+       if (scan_res) {
+               p2p_add_group_clients(p2p, p2p_dev_addr, addr, freq,
+                                     msg.group_info, msg.group_info_len);
+       }
 
        p2p_parse_free(&msg);
 
@@ -2598,7 +2603,7 @@ static void p2p_prov_disc_cb(struct p2p_data *p2p, int success)
 int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
                         int level, const u8 *ies, size_t ies_len)
 {
-       p2p_add_device(p2p, bssid, freq, level, ies, ies_len);
+       p2p_add_device(p2p, bssid, freq, level, ies, ies_len, 1);
 
        if (p2p->go_neg_peer && p2p->state == P2P_SEARCH &&
            os_memcmp(p2p->go_neg_peer->info.p2p_device_addr, bssid, ETH_ALEN)
index 30a83d5060df297da8eaf3757ffa6b3791d05d17..3a764caeb795e24fa73fda8dbe5111178c85d054 100644 (file)
@@ -653,7 +653,7 @@ struct p2p_device * p2p_add_dev_from_go_neg_req(struct p2p_data *p2p,
 void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr,
                      struct p2p_device *dev, struct p2p_message *msg);
 int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level,
-                  const u8 *ies, size_t ies_len);
+                  const u8 *ies, size_t ies_len, int scan_res);
 struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr);
 struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p,
                                             const u8 *addr);
index 1e6ed7d715188c953e8217c6a8fc8a466098802d..592554958499a1b86fa3bc5fa114038b14e0d0bb 100644 (file)
@@ -121,7 +121,8 @@ void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa,
                        "P2P: Invitation Request from unknown peer "
                        MACSTR, MAC2STR(sa));
 
-               if (p2p_add_device(p2p, sa, rx_freq, 0, data + 1, len - 1)) {
+               if (p2p_add_device(p2p, sa, rx_freq, 0, data + 1, len - 1, 0))
+               {
                        wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                                "P2P: Invitation Request add device failed "
                                MACSTR, MAC2STR(sa));
index ca248aed642e36892f4caf6a90ab669ecdeb598b..7f18766dd72d30d89dc97d6d68299ad9a6b6dcbc 100644 (file)
@@ -110,7 +110,8 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
                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)) {
+               if (p2p_add_device(p2p, sa, rx_freq, 0, data + 1, len - 1, 0))
+               {
                        wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                                "P2P: Provision Discovery Request add device "
                                "failed " MACSTR, MAC2STR(sa));