Use radio work for GAS requests
[mech_eap.git] / wpa_supplicant / gas_query.c
1 /*
2  * Generic advertisement service (GAS) query
3  * Copyright (c) 2009, Atheros Communications
4  * Copyright (c) 2011-2013, Qualcomm Atheros, Inc.
5  * Copyright (c) 2011-2014, Jouni Malinen <j@w1.fi>
6  *
7  * This software may be distributed under the terms of the BSD license.
8  * See README for more details.
9  */
10
11 #include "includes.h"
12
13 #include "common.h"
14 #include "utils/eloop.h"
15 #include "common/ieee802_11_defs.h"
16 #include "common/gas.h"
17 #include "common/wpa_ctrl.h"
18 #include "wpa_supplicant_i.h"
19 #include "driver_i.h"
20 #include "offchannel.h"
21 #include "gas_query.h"
22
23
24 /** GAS query timeout in seconds */
25 #define GAS_QUERY_TIMEOUT_PERIOD 2
26 /** Retry period for GAS query requests in milliseconds */
27 #define GAS_SERVICE_RETRY_PERIOD_MS 500
28
29
30 /**
31  * struct gas_query_pending - Pending GAS query
32  */
33 struct gas_query_pending {
34         struct dl_list list;
35         struct gas_query *gas;
36         u8 addr[ETH_ALEN];
37         u8 dialog_token;
38         u8 next_frag_id;
39         unsigned int wait_comeback:1;
40         unsigned int offchannel_tx_started:1;
41         int freq;
42         u16 status_code;
43         struct wpabuf *req;
44         struct wpabuf *adv_proto;
45         struct wpabuf *resp;
46         void (*cb)(void *ctx, const u8 *dst, u8 dialog_token,
47                    enum gas_query_result result,
48                    const struct wpabuf *adv_proto,
49                    const struct wpabuf *resp, u16 status_code);
50         void *ctx;
51 };
52
53 /**
54  * struct gas_query - Internal GAS query data
55  */
56 struct gas_query {
57         struct wpa_supplicant *wpa_s;
58         struct dl_list pending; /* struct gas_query_pending */
59         struct gas_query_pending *current;
60         struct wpa_radio_work *work;
61 };
62
63
64 static void gas_query_tx_comeback_timeout(void *eloop_data, void *user_ctx);
65 static void gas_query_timeout(void *eloop_data, void *user_ctx);
66 static void gas_service_timeout(void *eloop_data, void *user_ctx);
67
68
69 /**
70  * gas_query_init - Initialize GAS query component
71  * @wpa_s: Pointer to wpa_supplicant data
72  * Returns: Pointer to GAS query data or %NULL on failure
73  */
74 struct gas_query * gas_query_init(struct wpa_supplicant *wpa_s)
75 {
76         struct gas_query *gas;
77
78         gas = os_zalloc(sizeof(*gas));
79         if (gas == NULL)
80                 return NULL;
81
82         gas->wpa_s = wpa_s;
83         dl_list_init(&gas->pending);
84
85         return gas;
86 }
87
88
89 static const char * gas_result_txt(enum gas_query_result result)
90 {
91         switch (result) {
92         case GAS_QUERY_SUCCESS:
93                 return "SUCCESS";
94         case GAS_QUERY_FAILURE:
95                 return "FAILURE";
96         case GAS_QUERY_TIMEOUT:
97                 return "TIMEOUT";
98         case GAS_QUERY_PEER_ERROR:
99                 return "PEER_ERROR";
100         case GAS_QUERY_INTERNAL_ERROR:
101                 return "INTERNAL_ERROR";
102         case GAS_QUERY_CANCELLED:
103                 return "CANCELLED";
104         case GAS_QUERY_DELETED_AT_DEINIT:
105                 return "DELETED_AT_DEINIT";
106         }
107
108         return "N/A";
109 }
110
111
112 static void gas_query_free(struct gas_query_pending *query, int del_list)
113 {
114         struct gas_query *gas = query->gas;
115
116         if (del_list)
117                 dl_list_del(&query->list);
118
119         if (gas->work && gas->work->ctx == query) {
120                 radio_work_done(gas->work);
121                 gas->work = NULL;
122         }
123
124         wpabuf_free(query->req);
125         wpabuf_free(query->adv_proto);
126         wpabuf_free(query->resp);
127         os_free(query);
128 }
129
130
131 static void gas_query_done(struct gas_query *gas,
132                            struct gas_query_pending *query,
133                            enum gas_query_result result)
134 {
135         wpa_msg(gas->wpa_s, MSG_INFO, GAS_QUERY_DONE "addr=" MACSTR
136                 " dialog_token=%u freq=%d status_code=%u result=%s",
137                 MAC2STR(query->addr), query->dialog_token, query->freq,
138                 query->status_code, gas_result_txt(result));
139         if (gas->current == query)
140                 gas->current = NULL;
141         if (query->offchannel_tx_started)
142                 offchannel_send_action_done(gas->wpa_s);
143         eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
144         eloop_cancel_timeout(gas_query_timeout, gas, query);
145         eloop_cancel_timeout(gas_service_timeout, gas, query);
146         dl_list_del(&query->list);
147         query->cb(query->ctx, query->addr, query->dialog_token, result,
148                   query->adv_proto, query->resp, query->status_code);
149         gas_query_free(query, 0);
150 }
151
152
153 /**
154  * gas_query_deinit - Deinitialize GAS query component
155  * @gas: GAS query data from gas_query_init()
156  */
157 void gas_query_deinit(struct gas_query *gas)
158 {
159         struct gas_query_pending *query, *next;
160
161         if (gas == NULL)
162                 return;
163
164         dl_list_for_each_safe(query, next, &gas->pending,
165                               struct gas_query_pending, list)
166                 gas_query_done(gas, query, GAS_QUERY_DELETED_AT_DEINIT);
167
168         os_free(gas);
169 }
170
171
172 static struct gas_query_pending *
173 gas_query_get_pending(struct gas_query *gas, const u8 *addr, u8 dialog_token)
174 {
175         struct gas_query_pending *q;
176         dl_list_for_each(q, &gas->pending, struct gas_query_pending, list) {
177                 if (os_memcmp(q->addr, addr, ETH_ALEN) == 0 &&
178                     q->dialog_token == dialog_token)
179                         return q;
180         }
181         return NULL;
182 }
183
184
185 static int gas_query_append(struct gas_query_pending *query, const u8 *data,
186                             size_t len)
187 {
188         if (wpabuf_resize(&query->resp, len) < 0) {
189                 wpa_printf(MSG_DEBUG, "GAS: No memory to store the response");
190                 return -1;
191         }
192         wpabuf_put_data(query->resp, data, len);
193         return 0;
194 }
195
196
197 static void gas_query_tx_status(struct wpa_supplicant *wpa_s,
198                                 unsigned int freq, const u8 *dst,
199                                 const u8 *src, const u8 *bssid,
200                                 const u8 *data, size_t data_len,
201                                 enum offchannel_send_action_result result)
202 {
203         struct gas_query_pending *query;
204         struct gas_query *gas = wpa_s->gas;
205
206         if (gas->current == NULL) {
207                 wpa_printf(MSG_DEBUG, "GAS: Unexpected TX status: freq=%u dst="
208                            MACSTR " result=%d - no query in progress",
209                            freq, MAC2STR(dst), result);
210                 return;
211         }
212
213         query = gas->current;
214
215         wpa_printf(MSG_DEBUG, "GAS: TX status: freq=%u dst=" MACSTR
216                    " result=%d query=%p dialog_token=%u",
217                    freq, MAC2STR(dst), result, query, query->dialog_token);
218         if (os_memcmp(dst, query->addr, ETH_ALEN) != 0) {
219                 wpa_printf(MSG_DEBUG, "GAS: TX status for unexpected destination");
220                 return;
221         }
222
223         if (result == OFFCHANNEL_SEND_ACTION_SUCCESS) {
224                 eloop_cancel_timeout(gas_query_timeout, gas, query);
225                 eloop_register_timeout(GAS_QUERY_TIMEOUT_PERIOD, 0,
226                                        gas_query_timeout, gas, query);
227         }
228         if (result == OFFCHANNEL_SEND_ACTION_FAILED) {
229                 eloop_cancel_timeout(gas_query_timeout, gas, query);
230                 eloop_register_timeout(0, 0, gas_query_timeout, gas, query);
231         }
232 }
233
234
235 static int gas_query_tx(struct gas_query *gas, struct gas_query_pending *query,
236                         struct wpabuf *req)
237 {
238         int res;
239         wpa_printf(MSG_DEBUG, "GAS: Send action frame to " MACSTR " len=%u "
240                    "freq=%d", MAC2STR(query->addr),
241                    (unsigned int) wpabuf_len(req), query->freq);
242         res = offchannel_send_action(gas->wpa_s, query->freq, query->addr,
243                                      gas->wpa_s->own_addr, query->addr,
244                                      wpabuf_head(req), wpabuf_len(req), 1000,
245                                      gas_query_tx_status, 0);
246         if (res == 0)
247                 query->offchannel_tx_started = 1;
248         return res;
249 }
250
251
252 static void gas_query_tx_comeback_req(struct gas_query *gas,
253                                       struct gas_query_pending *query)
254 {
255         struct wpabuf *req;
256
257         req = gas_build_comeback_req(query->dialog_token);
258         if (req == NULL) {
259                 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
260                 return;
261         }
262
263         if (gas_query_tx(gas, query, req) < 0) {
264                 wpa_printf(MSG_DEBUG, "GAS: Failed to send Action frame to "
265                            MACSTR, MAC2STR(query->addr));
266                 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
267         }
268
269         wpabuf_free(req);
270 }
271
272
273 static void gas_query_tx_comeback_timeout(void *eloop_data, void *user_ctx)
274 {
275         struct gas_query *gas = eloop_data;
276         struct gas_query_pending *query = user_ctx;
277
278         wpa_printf(MSG_DEBUG, "GAS: Comeback timeout for request to " MACSTR,
279                    MAC2STR(query->addr));
280         gas_query_tx_comeback_req(gas, query);
281 }
282
283
284 static void gas_query_tx_comeback_req_delay(struct gas_query *gas,
285                                             struct gas_query_pending *query,
286                                             u16 comeback_delay)
287 {
288         unsigned int secs, usecs;
289
290         secs = (comeback_delay * 1024) / 1000000;
291         usecs = comeback_delay * 1024 - secs * 1000000;
292         wpa_printf(MSG_DEBUG, "GAS: Send comeback request to " MACSTR
293                    " in %u secs %u usecs", MAC2STR(query->addr), secs, usecs);
294         eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query);
295         eloop_register_timeout(secs, usecs, gas_query_tx_comeback_timeout,
296                                gas, query);
297 }
298
299
300 static void gas_query_rx_initial(struct gas_query *gas,
301                                  struct gas_query_pending *query,
302                                  const u8 *adv_proto, const u8 *resp,
303                                  size_t len, u16 comeback_delay)
304 {
305         wpa_printf(MSG_DEBUG, "GAS: Received initial response from "
306                    MACSTR " (dialog_token=%u comeback_delay=%u)",
307                    MAC2STR(query->addr), query->dialog_token, comeback_delay);
308
309         query->adv_proto = wpabuf_alloc_copy(adv_proto, 2 + adv_proto[1]);
310         if (query->adv_proto == NULL) {
311                 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
312                 return;
313         }
314
315         if (comeback_delay) {
316                 query->wait_comeback = 1;
317                 gas_query_tx_comeback_req_delay(gas, query, comeback_delay);
318                 return;
319         }
320
321         /* Query was completed without comeback mechanism */
322         if (gas_query_append(query, resp, len) < 0) {
323                 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
324                 return;
325         }
326
327         gas_query_done(gas, query, GAS_QUERY_SUCCESS);
328 }
329
330
331 static void gas_query_rx_comeback(struct gas_query *gas,
332                                   struct gas_query_pending *query,
333                                   const u8 *adv_proto, const u8 *resp,
334                                   size_t len, u8 frag_id, u8 more_frags,
335                                   u16 comeback_delay)
336 {
337         wpa_printf(MSG_DEBUG, "GAS: Received comeback response from "
338                    MACSTR " (dialog_token=%u frag_id=%u more_frags=%u "
339                    "comeback_delay=%u)",
340                    MAC2STR(query->addr), query->dialog_token, frag_id,
341                    more_frags, comeback_delay);
342
343         if ((size_t) 2 + adv_proto[1] != wpabuf_len(query->adv_proto) ||
344             os_memcmp(adv_proto, wpabuf_head(query->adv_proto),
345                       wpabuf_len(query->adv_proto)) != 0) {
346                 wpa_printf(MSG_DEBUG, "GAS: Advertisement Protocol changed "
347                            "between initial and comeback response from "
348                            MACSTR, MAC2STR(query->addr));
349                 gas_query_done(gas, query, GAS_QUERY_PEER_ERROR);
350                 return;
351         }
352
353         if (comeback_delay) {
354                 if (frag_id) {
355                         wpa_printf(MSG_DEBUG, "GAS: Invalid comeback response "
356                                    "with non-zero frag_id and comeback_delay "
357                                    "from " MACSTR, MAC2STR(query->addr));
358                         gas_query_done(gas, query, GAS_QUERY_PEER_ERROR);
359                         return;
360                 }
361                 gas_query_tx_comeback_req_delay(gas, query, comeback_delay);
362                 return;
363         }
364
365         if (frag_id != query->next_frag_id) {
366                 wpa_printf(MSG_DEBUG, "GAS: Unexpected frag_id in response "
367                            "from " MACSTR, MAC2STR(query->addr));
368                 if (frag_id + 1 == query->next_frag_id) {
369                         wpa_printf(MSG_DEBUG, "GAS: Drop frame as possible "
370                                    "retry of previous fragment");
371                         return;
372                 }
373                 gas_query_done(gas, query, GAS_QUERY_PEER_ERROR);
374                 return;
375         }
376         query->next_frag_id++;
377
378         if (gas_query_append(query, resp, len) < 0) {
379                 gas_query_done(gas, query, GAS_QUERY_INTERNAL_ERROR);
380                 return;
381         }
382
383         if (more_frags) {
384                 gas_query_tx_comeback_req(gas, query);
385                 return;
386         }
387
388         gas_query_done(gas, query, GAS_QUERY_SUCCESS);
389 }
390
391
392 /**
393  * gas_query_rx - Indicate reception of a Public Action frame
394  * @gas: GAS query data from gas_query_init()
395  * @da: Destination MAC address of the Action frame
396  * @sa: Source MAC address of the Action frame
397  * @bssid: BSSID of the Action frame
398  * @data: Payload of the Action frame
399  * @len: Length of @data
400  * @freq: Frequency (in MHz) on which the frame was received
401  * Returns: 0 if the Public Action frame was a GAS frame or -1 if not
402  */
403 int gas_query_rx(struct gas_query *gas, const u8 *da, const u8 *sa,
404                  const u8 *bssid, const u8 *data, size_t len, int freq)
405 {
406         struct gas_query_pending *query;
407         u8 action, dialog_token, frag_id = 0, more_frags = 0;
408         u16 comeback_delay, resp_len;
409         const u8 *pos, *adv_proto;
410
411         if (gas == NULL || len < 4)
412                 return -1;
413
414         pos = data;
415         action = *pos++;
416         dialog_token = *pos++;
417
418         if (action != WLAN_PA_GAS_INITIAL_RESP &&
419             action != WLAN_PA_GAS_COMEBACK_RESP)
420                 return -1; /* Not a GAS response */
421
422         query = gas_query_get_pending(gas, sa, dialog_token);
423         if (query == NULL) {
424                 wpa_printf(MSG_DEBUG, "GAS: No pending query found for " MACSTR
425                            " dialog token %u", MAC2STR(sa), dialog_token);
426                 return -1;
427         }
428
429         if (query->wait_comeback && action == WLAN_PA_GAS_INITIAL_RESP) {
430                 wpa_printf(MSG_DEBUG, "GAS: Unexpected initial response from "
431                            MACSTR " dialog token %u when waiting for comeback "
432                            "response", MAC2STR(sa), dialog_token);
433                 return 0;
434         }
435
436         if (!query->wait_comeback && action == WLAN_PA_GAS_COMEBACK_RESP) {
437                 wpa_printf(MSG_DEBUG, "GAS: Unexpected comeback response from "
438                            MACSTR " dialog token %u when waiting for initial "
439                            "response", MAC2STR(sa), dialog_token);
440                 return 0;
441         }
442
443         query->status_code = WPA_GET_LE16(pos);
444         pos += 2;
445
446         if (query->status_code != WLAN_STATUS_SUCCESS) {
447                 wpa_printf(MSG_DEBUG, "GAS: Query to " MACSTR " dialog token "
448                            "%u failed - status code %u",
449                            MAC2STR(sa), dialog_token, query->status_code);
450                 gas_query_done(gas, query, GAS_QUERY_FAILURE);
451                 return 0;
452         }
453
454         if (action == WLAN_PA_GAS_COMEBACK_RESP) {
455                 if (pos + 1 > data + len)
456                         return 0;
457                 frag_id = *pos & 0x7f;
458                 more_frags = (*pos & 0x80) >> 7;
459                 pos++;
460         }
461
462         /* Comeback Delay */
463         if (pos + 2 > data + len)
464                 return 0;
465         comeback_delay = WPA_GET_LE16(pos);
466         pos += 2;
467
468         /* Advertisement Protocol element */
469         if (pos + 2 > data + len || pos + 2 + pos[1] > data + len) {
470                 wpa_printf(MSG_DEBUG, "GAS: No room for Advertisement "
471                            "Protocol element in the response from " MACSTR,
472                            MAC2STR(sa));
473                 return 0;
474         }
475
476         if (*pos != WLAN_EID_ADV_PROTO) {
477                 wpa_printf(MSG_DEBUG, "GAS: Unexpected Advertisement "
478                            "Protocol element ID %u in response from " MACSTR,
479                            *pos, MAC2STR(sa));
480                 return 0;
481         }
482
483         adv_proto = pos;
484         pos += 2 + pos[1];
485
486         /* Query Response Length */
487         if (pos + 2 > data + len) {
488                 wpa_printf(MSG_DEBUG, "GAS: No room for GAS Response Length");
489                 return 0;
490         }
491         resp_len = WPA_GET_LE16(pos);
492         pos += 2;
493
494         if (pos + resp_len > data + len) {
495                 wpa_printf(MSG_DEBUG, "GAS: Truncated Query Response in "
496                            "response from " MACSTR, MAC2STR(sa));
497                 return 0;
498         }
499
500         if (pos + resp_len < data + len) {
501                 wpa_printf(MSG_DEBUG, "GAS: Ignore %u octets of extra data "
502                            "after Query Response from " MACSTR,
503                            (unsigned int) (data + len - pos - resp_len),
504                            MAC2STR(sa));
505         }
506
507         if (action == WLAN_PA_GAS_COMEBACK_RESP)
508                 gas_query_rx_comeback(gas, query, adv_proto, pos, resp_len,
509                                       frag_id, more_frags, comeback_delay);
510         else
511                 gas_query_rx_initial(gas, query, adv_proto, pos, resp_len,
512                                      comeback_delay);
513
514         return 0;
515 }
516
517
518 static void gas_query_timeout(void *eloop_data, void *user_ctx)
519 {
520         struct gas_query *gas = eloop_data;
521         struct gas_query_pending *query = user_ctx;
522
523         wpa_printf(MSG_DEBUG, "GAS: No response received for query to " MACSTR
524                    " dialog token %u",
525                    MAC2STR(query->addr), query->dialog_token);
526         gas_query_done(gas, query, GAS_QUERY_TIMEOUT);
527 }
528
529
530 static void gas_service_timeout(void *eloop_data, void *user_ctx)
531 {
532         struct gas_query *gas = eloop_data;
533         struct wpa_supplicant *wpa_s = gas->wpa_s;
534         struct gas_query_pending *query = user_ctx;
535         int conn;
536
537         conn = wpas_wpa_is_in_progress(wpa_s, 1);
538         if (conn) {
539                 wpa_printf(MSG_DEBUG, "GAS: Delaying GAS query Tx while connection operation is in progress");
540                 eloop_register_timeout(
541                         GAS_SERVICE_RETRY_PERIOD_MS / 1000,
542                         (GAS_SERVICE_RETRY_PERIOD_MS % 1000) * 1000,
543                         gas_service_timeout, gas, query);
544                 return;
545         }
546
547         if (gas_query_tx(gas, query, query->req) < 0) {
548                 wpa_printf(MSG_DEBUG, "GAS: Failed to send Action frame to "
549                            MACSTR, MAC2STR(query->addr));
550                 gas_query_free(query, 1);
551                 return;
552         }
553         gas->current = query;
554
555         wpa_printf(MSG_DEBUG, "GAS: Starting query timeout for dialog token %u",
556                    query->dialog_token);
557         eloop_register_timeout(GAS_QUERY_TIMEOUT_PERIOD, 0,
558                                gas_query_timeout, gas, query);
559 }
560
561
562 static int gas_query_dialog_token_available(struct gas_query *gas,
563                                             const u8 *dst, u8 dialog_token)
564 {
565         struct gas_query_pending *q;
566         dl_list_for_each(q, &gas->pending, struct gas_query_pending, list) {
567                 if (os_memcmp(dst, q->addr, ETH_ALEN) == 0 &&
568                     dialog_token == q->dialog_token)
569                         return 0;
570         }
571
572         return 1;
573 }
574
575
576 static void gas_query_start_cb(struct wpa_radio_work *work, int deinit)
577 {
578         struct gas_query_pending *query = work->ctx;
579
580         if (deinit) {
581                 gas_query_free(query, 1);
582                 return;
583         }
584
585         query->gas->work = work;
586         gas_service_timeout(query->gas, query);
587 }
588
589
590 /**
591  * gas_query_req - Request a GAS query
592  * @gas: GAS query data from gas_query_init()
593  * @dst: Destination MAC address for the query
594  * @freq: Frequency (in MHz) for the channel on which to send the query
595  * @req: GAS query payload (to be freed by gas_query module in case of success
596  *      return)
597  * @cb: Callback function for reporting GAS query result and response
598  * @ctx: Context pointer to use with the @cb call
599  * Returns: dialog token (>= 0) on success or -1 on failure
600  */
601 int gas_query_req(struct gas_query *gas, const u8 *dst, int freq,
602                   struct wpabuf *req,
603                   void (*cb)(void *ctx, const u8 *dst, u8 dialog_token,
604                              enum gas_query_result result,
605                              const struct wpabuf *adv_proto,
606                              const struct wpabuf *resp, u16 status_code),
607                   void *ctx)
608 {
609         struct gas_query_pending *query;
610         int dialog_token;
611         static int next_start = 0;
612
613         if (wpabuf_len(req) < 3)
614                 return -1;
615
616         for (dialog_token = 0; dialog_token < 256; dialog_token++) {
617                 if (gas_query_dialog_token_available(
618                             gas, dst, (next_start + dialog_token) % 256))
619                         break;
620         }
621         if (dialog_token == 256)
622                 return -1; /* Too many pending queries */
623         dialog_token = (next_start + dialog_token) % 256;
624         next_start = (dialog_token + 1) % 256;
625
626         query = os_zalloc(sizeof(*query));
627         if (query == NULL)
628                 return -1;
629
630         query->gas = gas;
631         os_memcpy(query->addr, dst, ETH_ALEN);
632         query->dialog_token = dialog_token;
633         query->freq = freq;
634         query->cb = cb;
635         query->ctx = ctx;
636         query->req = req;
637         dl_list_add(&gas->pending, &query->list);
638
639         *(wpabuf_mhead_u8(req) + 2) = dialog_token;
640
641         wpa_msg(gas->wpa_s, MSG_INFO, GAS_QUERY_START "addr=" MACSTR
642                 " dialog_token=%u freq=%d",
643                 MAC2STR(query->addr), query->dialog_token, query->freq);
644
645         if (radio_add_work(gas->wpa_s, freq, "gas-query", 0, gas_query_start_cb,
646                            query) < 0) {
647                 gas_query_free(query, 1);
648                 return -1;
649         }
650
651         return dialog_token;
652 }
653
654
655 /**
656  * gas_query_cancel - Cancel a pending GAS query
657  * @gas: GAS query data from gas_query_init()
658  * @dst: Destination MAC address for the query
659  * @dialog_token: Dialog token from gas_query_req()
660  */
661 void gas_query_cancel(struct gas_query *gas, const u8 *dst, u8 dialog_token)
662 {
663         struct gas_query_pending *query;
664
665         query = gas_query_get_pending(gas, dst, dialog_token);
666         if (query)
667                 gas_query_done(gas, query, GAS_QUERY_CANCELLED);
668
669 }