]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix BSS RANGE command for no exact id match cases
authorAmar Singhal <asinghal@qca.qualcomm.com>
Thu, 7 Feb 2013 10:27:52 +0000 (12:27 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 7 Feb 2013 10:27:52 +0000 (12:27 +0200)
The RANGE=N1-N2 command did not return any entries in some cases where
N1 does not match with any BSS entry. Fix this by allow entries to be
fetched even without knowing the exact id values.

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

wpa_supplicant/bss.c
wpa_supplicant/bss.h
wpa_supplicant/ctrl_iface.c

index 87b7db89a76cf704e479441c7a1957e08e4325c7..9dc0be24da6a20f207a4e8db59f932cde9ff884a 100644 (file)
@@ -864,6 +864,29 @@ struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id)
 }
 
 
+/**
+ * wpa_bss_get_id_range - Fetch a BSS table entry based on identifier range
+ * @wpa_s: Pointer to wpa_supplicant data
+ * @idf: Smallest allowed identifier assigned for the entry
+ * @idf: Largest allowed identifier assigned for the entry
+ * Returns: Pointer to the BSS entry or %NULL if not found
+ *
+ * This function is similar to wpa_bss_get_id() but allows a BSS entry with the
+ * smallest id value to be fetched within the specified range without the
+ * caller having to know the exact id.
+ */
+struct wpa_bss * wpa_bss_get_id_range(struct wpa_supplicant *wpa_s,
+                                     unsigned int idf, unsigned int idl)
+{
+       struct wpa_bss *bss;
+       dl_list_for_each(bss, &wpa_s->bss_id, struct wpa_bss, list_id) {
+               if (bss->id >= idf && bss->id <= idl)
+                       return bss;
+       }
+       return NULL;
+}
+
+
 /**
  * wpa_bss_get_ie - Fetch a specified information element from a BSS entry
  * @bss: BSS table entry
index 01f6c59d2388b6570c54286574c53558ed506833..ab2c47e3c0a35f12e13aa4cb2cf1ed3481cdabf7 100644 (file)
@@ -111,6 +111,8 @@ struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
 struct wpa_bss * wpa_bss_get_p2p_dev_addr(struct wpa_supplicant *wpa_s,
                                          const u8 *dev_addr);
 struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id);
+struct wpa_bss * wpa_bss_get_id_range(struct wpa_supplicant *wpa_s,
+                                     unsigned int idf, unsigned int idl);
 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie);
 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
 struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
index 10c21f6e44ddfdb7dd6961558e0ac58fd6f78e2d..4e5e169e24a72ba57b3b61c4eeb3c979e101be79 100644 (file)
@@ -3148,10 +3148,17 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
                                return 0;
                        }
 
-                       id1 = atoi(cmd + 6);
-                       bss = wpa_bss_get_id(wpa_s, id1);
-                       id2 = atoi(ctmp + 1);
-                       if (id2 == 0)
+                       if (*(cmd + 6) == '-')
+                               id1 = 0;
+                       else
+                               id1 = atoi(cmd + 6);
+                       ctmp++;
+                       if (*ctmp >= '0' && *ctmp <= '9')
+                               id2 = atoi(ctmp);
+                       else
+                               id2 = (unsigned int) -1;
+                       bss = wpa_bss_get_id_range(wpa_s, id1, id2);
+                       if (id2 == (unsigned int) -1)
                                bsslast = dl_list_last(&wpa_s->bss_id,
                                                       struct wpa_bss,
                                                       list_id);