]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ANQP: Add support to specify frequency in ANQP_GET command
authorVeerendranath Jakkam <vjakkam@codeaurora.org>
Tue, 11 Aug 2020 12:23:17 +0000 (17:53 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 13 Aug 2020 14:51:00 +0000 (17:51 +0300)
Previously, wpa_supplicant fetched BSS channel info from scan results to
send ANQP Query frames. If the scan results for the specified BSS are
not available, the ANQP_GET command request was getting rejected.

Add support to send ANQP Query frame on the specified frequency without
requiring the scan results to be available.

The control interface command format:
- ANQP_GET <dst_addr> [freq=<freq in MHz>] <Query ID1>[,<Query ID2>,..]

Signed-off-by: Veerendranath Jakkam <vjakkam@codeaurora.org>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/interworking.c
wpa_supplicant/interworking.h

index 4b669b057abea940028f702cab8387ff1a7c9048..0dcb0398ca0fbfa249cca3e933df83cc93036c43 100644 (file)
@@ -7466,7 +7466,7 @@ static int ctrl_interworking_connect(struct wpa_supplicant *wpa_s, char *dst,
 static int get_anqp(struct wpa_supplicant *wpa_s, char *dst)
 {
        u8 dst_addr[ETH_ALEN];
-       int used;
+       int used, freq = 0;
        char *pos;
 #define MAX_ANQP_INFO_ID 100
        u16 id[MAX_ANQP_INFO_ID];
@@ -7480,6 +7480,15 @@ static int get_anqp(struct wpa_supplicant *wpa_s, char *dst)
        pos = dst + used;
        if (*pos == ' ')
                pos++;
+
+       if (os_strncmp(pos, "freq=", 5) == 0) {
+               freq = atoi(pos + 5);
+               pos = os_strchr(pos, ' ');
+               if (!pos)
+                       return -1;
+               pos++;
+       }
+
        while (num_id < MAX_ANQP_INFO_ID) {
                if (os_strncmp(pos, "hs20:", 5) == 0) {
 #ifdef CONFIG_HS20
@@ -7514,7 +7523,7 @@ static int get_anqp(struct wpa_supplicant *wpa_s, char *dst)
        if (num_id == 0 && !subtypes && !mbo_subtypes)
                return -1;
 
-       return anqp_send_req(wpa_s, dst_addr, id, num_id, subtypes,
+       return anqp_send_req(wpa_s, dst_addr, freq, id, num_id, subtypes,
                             mbo_subtypes);
 }
 
index b1ddd0925fd198618ca3487581f52d0754124798..00e1492c6a2668e514492904644a7541049eca2d 100644 (file)
@@ -2750,27 +2750,27 @@ void interworking_stop_fetch_anqp(struct wpa_supplicant *wpa_s)
 }
 
 
-int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst,
+int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, int freq,
                  u16 info_ids[], size_t num_ids, u32 subtypes,
                  u32 mbo_subtypes)
 {
        struct wpabuf *buf;
        struct wpabuf *extra_buf = NULL;
        int ret = 0;
-       int freq;
        struct wpa_bss *bss;
        int res;
 
        bss = wpa_bss_get_bssid(wpa_s, dst);
-       if (!bss) {
+       if (!bss && !freq) {
                wpa_printf(MSG_WARNING,
-                          "ANQP: Cannot send query to unknown BSS "
-                          MACSTR, MAC2STR(dst));
+                          "ANQP: Cannot send query without BSS freq info");
                return -1;
        }
 
-       wpa_bss_anqp_unshare_alloc(bss);
-       freq = bss->freq;
+       if (bss)
+               wpa_bss_anqp_unshare_alloc(bss);
+       if (bss && !freq)
+               freq = bss->freq;
 
        wpa_msg(wpa_s, MSG_DEBUG,
                "ANQP: Query Request to " MACSTR " for %u id(s)",
@@ -2789,6 +2789,13 @@ int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst,
        if (mbo_subtypes) {
                struct wpabuf *mbo;
 
+               if (!bss) {
+                       wpa_printf(MSG_WARNING,
+                                  "ANQP: Cannot send MBO query to unknown BSS "
+                                  MACSTR, MAC2STR(dst));
+                       return -1;
+               }
+
                mbo = mbo_build_anqp_buf(wpa_s, bss, mbo_subtypes);
                if (mbo) {
                        if (wpabuf_resize(&extra_buf, wpabuf_len(mbo))) {
index 37ee2e904e48ef9f1084a88763f71d30641d24d3..77b2c91bda52fca4385bc54a4f1dac3fc46bea73 100644 (file)
@@ -11,7 +11,7 @@
 
 enum gas_query_result;
 
-int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst,
+int anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, int freq,
                  u16 info_ids[], size_t num_ids, u32 subtypes,
                  u32 mbo_subtypes);
 void anqp_resp_cb(void *ctx, const u8 *dst, u8 dialog_token,