Home | History | Annotate | Download | only in wpa_supplicant

Lines Matching defs:gas

2  * Generic advertisement service (GAS) query
16 #include "common/gas.h"
25 /** GAS query timeout in seconds */
28 /* GAS query wait-time / duration in ms */
33 * struct gas_query_pending - Pending GAS query
37 struct gas_query *gas;
58 * struct gas_query - Internal GAS query data
71 static void gas_query_tx_initial_req(struct gas_query *gas,
73 static int gas_query_new_dialog_token(struct gas_query *gas, const u8 *dst);
87 * gas_query_init - Initialize GAS query component
89 * Returns: Pointer to GAS query data or %NULL on failure
93 struct gas_query *gas;
95 gas = os_zalloc(sizeof(*gas));
96 if (gas == NULL)
99 gas->wpa_s = wpa_s;
100 dl_list_init(&gas->pending);
102 return gas;
131 struct gas_query *gas = query->gas;
136 if (gas->work && gas->work->ctx == query) {
137 radio_work_done(gas->work);
138 gas->work = NULL;
148 static void gas_query_done(struct gas_query *gas,
152 wpa_msg(gas->wpa_s, MSG_INFO, GAS_QUERY_DONE "addr=" MACSTR
156 if (gas->current == query)
157 gas->current = NULL;
159 offchannel_send_action_done(gas->wpa_s);
160 eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
161 eloop_cancel_timeout(gas_query_timeout, gas, query);
162 eloop_cancel_timeout(gas_query_rx_comeback_timeout, gas, query);
171 * gas_query_deinit - Deinitialize GAS query component
172 * @gas: GAS query data from gas_query_init()
174 void gas_query_deinit(struct gas_query *gas)
178 if (gas == NULL)
181 dl_list_for_each_safe(query, next, &gas->pending,
183 gas_query_done(gas, query, GAS_QUERY_DELETED_AT_DEINIT);
185 os_free(gas);
190 gas_query_get_pending(struct gas_query *gas, const u8 *addr, u8 dialog_token)
193 dl_list_for_each(q, &gas->pending, struct gas_query_pending, list) {
206 wpa_printf(MSG_DEBUG, "GAS: No memory to store the response");
221 struct gas_query *gas = wpa_s->gas;
224 if (gas->current == NULL) {
225 wpa_printf(MSG_DEBUG, "GAS: Unexpected TX status: freq=%u dst="
231 query = gas->current;
234 wpa_printf(MSG_DEBUG, "GAS: TX status: freq=%u dst=" MACSTR
238 wpa_printf(MSG_DEBUG, "GAS: TX status for unexpected destination");
244 eloop_cancel_timeout(gas_query_timeout, gas, query);
246 gas_query_timeout, gas, query);
249 gas, query);
252 gas_query_rx_comeback_timeout, gas, query);
256 eloop_cancel_timeout(gas_query_timeout, gas, query);
257 eloop_register_timeout(0, 0, gas_query_timeout, gas, query);
272 static int gas_query_tx(struct gas_query *gas, struct gas_query_pending *query,
275 int res, prot = pmf_in_use(gas->wpa_s, query->addr);
277 wpa_printf(MSG_DEBUG, "GAS: Send action frame to " MACSTR " len=%u "
285 if (gas->wpa_s->max_remain_on_chan &&
286 wait_time > gas->wpa_s->max_remain_on_chan)
287 wait_time = gas->wpa_s->max_remain_on_chan;
288 res = offchannel_send_action(gas->wpa_s, query->freq, query->addr,
289 gas->wpa_s->own_addr, query->addr,
298 static void gas_query_tx_comeback_req(struct gas_query *gas,
306 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
313 if (gas_query_tx(gas, query, req, wait_time) < 0) {
314 wpa_printf(MSG_DEBUG, "GAS: Failed to send Action frame to "
316 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
325 struct gas_query *gas = eloop_data;
330 "GAS: No response to comeback request received (retry=%u)",
332 if (gas->current != query || query->retry)
334 dialog_token = gas_query_new_dialog_token(gas, query->addr);
338 "GAS: Retry GAS query due to comeback response timeout");
346 eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
347 eloop_cancel_timeout(gas_query_timeout, gas, query);
348 gas_query_tx_initial_req(gas, query);
354 struct gas_query *gas = eloop_data;
357 wpa_printf(MSG_DEBUG, "GAS: Comeback timeout for request to " MACSTR,
359 gas_query_tx_comeback_req(gas, query);
363 static void gas_query_tx_comeback_req_delay(struct gas_query *gas,
370 offchannel_send_action_done(gas->wpa_s);
376 wpa_printf(MSG_DEBUG, "GAS: Send comeback request to " MACSTR
378 eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
380 gas, query);
384 static void gas_query_rx_initial(struct gas_query *gas,
389 wpa_printf(MSG_DEBUG, "GAS: Received initial response from "
395 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
401 gas_query_tx_comeback_req_delay(gas, query, comeback_delay);
407 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
411 gas_query_done(gas, query, GAS_QUERY_SUCCESS);
415 static void gas_query_rx_comeback(struct gas_query *gas,
421 wpa_printf(MSG_DEBUG, "GAS: Received comeback response from "
426 eloop_cancel_timeout(gas_query_rx_comeback_timeout, gas, query);
431 wpa_printf(MSG_DEBUG, "GAS: Advertisement Protocol changed "
434 gas_query_done(gas, query, GAS_QUERY_PEER_ERROR);
440 wpa_printf(MSG_DEBUG, "GAS: Invalid comeback response "
443 gas_query_done(gas, query, GAS_QUERY_PEER_ERROR);
446 gas_query_tx_comeback_req_delay(gas, query, comeback_delay);
451 wpa_printf(MSG_DEBUG, "GAS: Unexpected frag_id in response "
454 wpa_printf(MSG_DEBUG, "GAS: Drop frame as possible "
458 gas_query_done(gas, query, GAS_QUERY_PEER_ERROR);
464 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
469 gas_query_tx_comeback_req(gas, query);
473 gas_query_done(gas, query, GAS_QUERY_SUCCESS);
479 * @gas: GAS query data from gas_query_init()
487 * Returns: 0 if the Public Action frame was a GAS frame or -1 if not
489 int gas_query_rx(struct gas_query *gas, const u8 *da, const u8 *sa,
500 if (gas == NULL || len < 4)
504 pmf = pmf_in_use(gas->wpa_s, sa);
506 wpa_printf(MSG_DEBUG, "GAS: Drop unexpected protected GAS frame when PMF is disabled");
510 wpa_printf(MSG_DEBUG, "GAS: Drop unexpected unprotected GAS frame when PMF is enabled");
520 return -1; /* Not a GAS response */
522 query = gas_query_get_pending(gas, sa, dialog_token);
524 wpa_printf(MSG_DEBUG, "GAS: No pending query found for " MACSTR
529 wpa_printf(MSG_DEBUG, "GAS: Response in %d ms from " MACSTR,
533 wpa_printf(MSG_DEBUG, "GAS: Unexpected initial response from "
540 wpa_printf(MSG_DEBUG, "GAS: Unexpected comeback response from "
551 wpa_printf(MSG_DEBUG, "GAS: Allow non-zero status for outstanding comeback response");
553 wpa_printf(MSG_DEBUG, "GAS: Query to " MACSTR " dialog token "
556 gas_query_done(gas, query, GAS_QUERY_FAILURE);
576 wpa_printf(MSG_DEBUG, "GAS: No room for Advertisement "
583 wpa_printf(MSG_DEBUG, "GAS: Unexpected Advertisement "
594 wpa_printf(MSG_DEBUG, "GAS: No room for GAS Response Length");
602 wpa_printf(MSG_DEBUG, "GAS: Truncated Query Response in "
608 wpa_printf(MSG_DEBUG, "GAS: Ignore %u octets of extra data "
614 gas_query_rx_comeback(gas, query, adv_proto, pos, resp_len,
617 gas_query_rx_initial(gas, query, adv_proto, pos, resp_len,
626 struct gas_query *gas = eloop_data;
629 wpa_printf(MSG_DEBUG, "GAS: No response received for query to " MACSTR
632 gas_query_done(gas, query, GAS_QUERY_TIMEOUT);
636 static int gas_query_dialog_token_available(struct gas_query *gas,
640 dl_list_for_each(q, &gas->pending, struct gas_query_pending, list) {
653 struct gas_query *gas = query->gas;
654 struct wpa_supplicant *wpa_s = gas->wpa_s;
658 gas->work = NULL;
659 gas_query_done(gas, query, GAS_QUERY_DELETED_AT_DEINIT);
669 "Failed to assign random MAC address for GAS");
675 gas->work = work;
676 gas_query_tx_initial_req(gas, query);
680 static void gas_query_tx_initial_req(struct gas_query *gas,
683 if (gas_query_tx(gas, query, query->req,
685 wpa_printf(MSG_DEBUG, "GAS: Failed to send Action frame to "
690 gas->current = query;
692 wpa_printf(MSG_DEBUG, "GAS: Starting query timeout for dialog token %u",
695 gas_query_timeout, gas, query);
699 static int gas_query_new_dialog_token(struct gas_query *gas, const u8 *dst)
706 gas, dst, (next_start + dialog_token) % 256))
718 * gas_query_req - Request a GAS query
719 * @gas: GAS query data from gas_query_init()
722 * @req: GAS query payload (to be freed by gas_query module in case of success
724 * @cb: Callback function for reporting GAS query result and response
728 int gas_query_req(struct gas_query *gas, const u8 *dst, int freq,
742 dialog_token = gas_query_new_dialog_token(gas, dst);
750 query->gas = gas;
757 dl_list_add(&gas->pending, &query->list);
761 wpa_msg(gas->wpa_s, MSG_INFO, GAS_QUERY_START "addr=" MACSTR
765 if (radio_add_work(gas->wpa_s, freq, "gas-query", 0, gas_query_start_cb,
776 * gas_query_cancel - Cancel a pending GAS query
777 * @gas: GAS query data from gas_query_init()
781 void gas_query_cancel(struct gas_query *gas, const u8 *dst, u8 dialog_token)
785 query = gas_query_get_pending(gas, dst, dialog_token);
787 gas_query_done(gas, query, GAS_QUERY_CANCELLED);