aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/interworking.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2012-08-27 15:13:10 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-27 15:13:10 (GMT)
commitb1f122964e862bcb15d0237b4b852429957b7ebc (patch)
tree4ffd1a53ed8c6d3f677a1fc4bb8c007c0165dec7 /wpa_supplicant/interworking.c
parentb52f084cfaae5a10bf5886cfa159d2df0dfc350a (diff)
downloadhostap-b1f122964e862bcb15d0237b4b852429957b7ebc.zip
hostap-b1f122964e862bcb15d0237b4b852429957b7ebc.tar.gz
hostap-b1f122964e862bcb15d0237b4b852429957b7ebc.tar.bz2
Add generic GAS request mechanism
The new gas_request and gas_response_get commands can be used to request arbitary GAS queries to be performed. These can be used with ANQP or with other (including vendor specific) advertisement protocols. gas_request <BSSID> <AdvProtoID> [Query] gas_response_get <addr> <dialog token> [offset,length] For example, ANQP query for Capability list in interactive wpa_cli session: > gas_request 02:00:00:00:01:00 00 000102000101 <3>GAS-RESPONSE-INFO addr=02:00:00:00:01:00 dialog_token=0 status_code=0 resp_len=32 > gas_response_get 02:00:00:00:01:00 00 01011c00010102010501070108010c01dddd0c00506f9a110200020304050607 > gas_response_get 02:00:00:00:01:00 00 0,10 01011c00010102010501 > gas_response_get 02:00:00:00:01:00 00 10,10 070108010c01dddd0c00 > gas_response_get 02:00:00:00:01:00 00 20,10 506f9a11020002030405 > gas_response_get 02:00:00:00:01:00 00 30,2 0607 It should be noted that the maximum length of the response buffer is currently 4096 bytes which allows about 2000 bytes of the response data to be fetched with a single gas_response_get command. If the response is longer, it can be fetched in pieces as shown in the example above. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'wpa_supplicant/interworking.c')
-rw-r--r--wpa_supplicant/interworking.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index 29ff809..11c57b4 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -1757,3 +1757,84 @@ int interworking_select(struct wpa_supplicant *wpa_s, int auto_select)
return 0;
}
+
+
+static void gas_resp_cb(void *ctx, const u8 *addr, u8 dialog_token,
+ enum gas_query_result result,
+ const struct wpabuf *adv_proto,
+ const struct wpabuf *resp, u16 status_code)
+{
+ struct wpa_supplicant *wpa_s = ctx;
+
+ wpa_msg(wpa_s, MSG_INFO, GAS_RESPONSE_INFO "addr=" MACSTR
+ " dialog_token=%d status_code=%d resp_len=%d",
+ MAC2STR(addr), dialog_token, status_code,
+ resp ? (int) wpabuf_len(resp) : -1);
+ if (!resp)
+ return;
+
+ wpabuf_free(wpa_s->last_gas_resp);
+ wpa_s->last_gas_resp = wpabuf_dup(resp);
+ if (wpa_s->last_gas_resp == NULL)
+ return;
+ os_memcpy(wpa_s->last_gas_addr, addr, ETH_ALEN);
+ wpa_s->last_gas_dialog_token = dialog_token;
+}
+
+
+int gas_send_request(struct wpa_supplicant *wpa_s, const u8 *dst,
+ const struct wpabuf *adv_proto,
+ const struct wpabuf *query)
+{
+ struct wpabuf *buf;
+ int ret = 0;
+ int freq;
+ struct wpa_bss *bss;
+ int res;
+ size_t len;
+ u8 query_resp_len_limit = 0, pame_bi = 0;
+
+ freq = wpa_s->assoc_freq;
+ bss = wpa_bss_get_bssid(wpa_s, dst);
+ if (bss)
+ freq = bss->freq;
+ if (freq <= 0)
+ return -1;
+
+ wpa_printf(MSG_DEBUG, "GAS request to " MACSTR " (freq %d MHz)",
+ MAC2STR(dst), freq);
+ wpa_hexdump_buf(MSG_DEBUG, "Advertisement Protocol ID", adv_proto);
+ wpa_hexdump_buf(MSG_DEBUG, "GAS Query", query);
+
+ len = 3 + wpabuf_len(adv_proto) + 2;
+ if (query)
+ len += wpabuf_len(query);
+ buf = gas_build_initial_req(0, len);
+ if (buf == NULL)
+ return -1;
+
+ /* Advertisement Protocol IE */
+ wpabuf_put_u8(buf, WLAN_EID_ADV_PROTO);
+ wpabuf_put_u8(buf, 1 + wpabuf_len(adv_proto)); /* Length */
+ wpabuf_put_u8(buf, (query_resp_len_limit & 0x7f) |
+ (pame_bi ? 0x80 : 0));
+ wpabuf_put_buf(buf, adv_proto);
+
+ /* GAS Query */
+ if (query) {
+ wpabuf_put_le16(buf, wpabuf_len(query));
+ wpabuf_put_buf(buf, query);
+ } else
+ wpabuf_put_le16(buf, 0);
+
+ res = gas_query_req(wpa_s->gas, dst, freq, buf, gas_resp_cb, wpa_s);
+ if (res < 0) {
+ wpa_printf(MSG_DEBUG, "GAS: Failed to send Query Request");
+ ret = -1;
+ } else
+ wpa_printf(MSG_DEBUG, "GAS: Query started with dialog token "
+ "%u", res);
+
+ wpabuf_free(buf);
+ return ret;
+}