Lines Matching refs:p2p

15 #include "p2p.h"
50 struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
64 for (q = p2p->sd_queries; q; q = q->next) {
91 p2p_dbg(p2p, "Too many SD request attempts to " MACSTR
100 static void p2p_decrease_sd_bc_queries(struct p2p_data *p2p, int query_number)
104 p2p->num_p2p_sd_queries--;
105 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
117 static int p2p_unlink_sd_query(struct p2p_data *p2p,
123 q = p2p->sd_queries;
130 p2p_decrease_sd_bc_queries(p2p, query_number);
134 p2p->sd_queries = q->next;
135 if (p2p->sd_query == query)
136 p2p->sd_query = NULL;
157 void p2p_free_sd_queries(struct p2p_data *p2p)
160 q = p2p->sd_queries;
161 p2p->sd_queries = NULL;
167 p2p->num_p2p_sd_queries = 0;
194 static void p2p_send_gas_comeback_req(struct p2p_data *p2p, const u8 *dst,
203 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
204 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, dst,
206 p2p_dbg(p2p, "Failed to send Action frame");
272 int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
282 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
288 query = p2p_pending_sd_req(p2p, dev);
292 p2p_dbg(p2p, "Start Service Discovery with " MACSTR,
295 req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
300 p2p->sd_peer = dev;
301 p2p->sd_query = query;
302 p2p->pending_action_state = P2P_PENDING_SD;
305 if (p2p->cfg->max_listen && wait_time > p2p->cfg->max_listen)
306 wait_time = p2p->cfg->max_listen;
307 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
308 p2p->cfg->dev_addr, dev->info.p2p_device_addr,
310 p2p_dbg(p2p, "Failed to send Action frame");
320 void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
332 if (p2p->cfg->sd_request == NULL)
338 freq = p2p_channel_to_freq(p2p->cfg->reg_class,
339 p2p->cfg->channel);
347 p2p_dbg(p2p, "GAS Initial Request from " MACSTR
352 p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
360 p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
366 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
385 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
393 p2p_dbg(p2p, "Invalid ANQP Query Request length");
398 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
407 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
410 p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
416 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
423 p2p_dbg(p2p, "SD response long enough to require fragmentation");
424 if (p2p->sd_resp) {
432 p2p_dbg(p2p, "Drop previous SD response");
433 wpabuf_free(p2p->sd_resp);
435 p2p->sd_resp = wpabuf_dup(resp_tlvs);
436 if (p2p->sd_resp == NULL) {
437 p2p_err(p2p, "Failed to allocate SD response fragmentation area");
440 os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN);
441 p2p->sd_resp_dialog_token = dialog_token;
442 p2p->sd_resp_pos = 0;
443 p2p->sd_frag_id = 0;
445 1, p2p->srv_update_indic, NULL);
447 p2p_dbg(p2p, "SD response fits in initial response");
450 p2p->srv_update_indic, resp_tlvs);
455 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
456 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr,
457 p2p->cfg->dev_addr,
459 p2p_dbg(p2p, "Failed to send Action frame");
465 void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
477 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
478 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
479 p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
483 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
484 p2p_clear_timeout(p2p);
486 p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
490 p2p_dbg(p2p, "Too short GAS Initial Response frame");
500 p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
503 p2p_dbg(p2p, "Service Discovery failed: status code %u",
509 p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
517 p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
523 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
531 p2p_dbg(p2p, "Too short Query Response");
536 p2p_dbg(p2p, "Query Response Length: %d", slen);
538 p2p_dbg(p2p, "Not enough Query Response data");
544 p2p_dbg(p2p, "Fragmented response - request fragments");
545 if (p2p->sd_rx_resp) {
546 p2p_dbg(p2p, "Drop old SD reassembly buffer");
547 wpabuf_free(p2p->sd_rx_resp);
548 p2p->sd_rx_resp = NULL;
550 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
558 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
566 p2p_dbg(p2p, "Invalid ANQP Query Response length");
571 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
580 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
583 p2p->sd_peer = NULL;
585 if (p2p->sd_query) {
586 if (!p2p->sd_query->for_all_peers) {
588 p2p_dbg(p2p, "Remove completed SD query %p",
589 p2p->sd_query);
590 q = p2p->sd_query;
591 p2p_unlink_sd_query(p2p, p2p->sd_query);
594 p2p->sd_query = NULL;
597 if (p2p->cfg->sd_response)
598 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, update_indic,
600 p2p_continue_find(p2p);
604 void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
616 p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
617 if (dialog_token != p2p->sd_resp_dialog_token) {
618 p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
623 if (p2p->sd_resp == NULL) {
624 p2p_dbg(p2p, "No pending SD response fragment available");
627 if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) {
628 p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
633 frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos;
639 p2p->srv_update_indic,
640 wpabuf_head_u8(p2p->sd_resp) +
641 p2p->sd_resp_pos, frag_len,
642 p2p->sd_frag_id, more,
643 wpabuf_len(p2p->sd_resp));
646 p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
647 p2p->sd_frag_id, more, (int) frag_len);
648 p2p->sd_frag_id++;
649 p2p->sd_resp_pos += frag_len;
652 p2p_dbg(p2p, "%d more bytes remain to be sent",
653 (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
655 p2p_dbg(p2p, "All fragments of SD response sent");
656 wpabuf_free(p2p->sd_resp);
657 p2p->sd_resp = NULL;
660 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
661 if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
662 p2p->cfg->dev_addr,
664 p2p_dbg(p2p, "Failed to send Action frame");
670 void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
685 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
686 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
687 p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
691 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
692 p2p_clear_timeout(p2p);
694 p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
698 p2p_dbg(p2p, "Too short GAS Comeback Response frame");
711 p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
717 p2p_dbg(p2p, "Service Discovery failed: status code %u",
723 p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
732 p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
738 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
746 p2p_dbg(p2p, "Too short Query Response");
751 p2p_dbg(p2p, "Query Response Length: %d", slen);
753 p2p_dbg(p2p, "Not enough Query Response data");
757 p2p_dbg(p2p, "No Query Response data");
762 if (p2p->sd_rx_resp) {
774 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
781 p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
783 p2p_dbg(p2p, "Invalid ANQP Query Response length");
790 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
798 p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
799 p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic);
803 if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
805 wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
806 p2p_dbg(p2p, "Current SD reassembly buffer length: %u",
807 (unsigned int) wpabuf_len(p2p->sd_rx_resp));
810 p2p_dbg(p2p, "More fragments remains");
812 if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
813 wpabuf_free(p2p->sd_rx_resp);
814 p2p->sd_rx_resp = NULL;
815 p2p_dbg(p2p, "Too long SD response - drop it");
818 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
822 p2p->sd_peer = NULL;
824 if (p2p->sd_query) {
825 if (!p2p->sd_query->for_all_peers) {
827 p2p_dbg(p2p, "Remove completed SD query %p",
828 p2p->sd_query);
829 q = p2p->sd_query;
830 p2p_unlink_sd_query(p2p, p2p->sd_query);
833 p2p->sd_query = NULL;
836 if (p2p->cfg->sd_response)
837 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa,
838 p2p->sd_rx_update_indic,
839 wpabuf_head(p2p->sd_rx_resp),
840 wpabuf_len(p2p->sd_rx_resp));
841 wpabuf_free(p2p->sd_rx_resp);
842 p2p->sd_rx_resp = NULL;
844 p2p_continue_find(p2p);
848 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
868 q->next = p2p->sd_queries;
869 p2p->sd_queries = q;
870 p2p_dbg(p2p, "Added SD Query %p", q);
875 p2p->num_p2p_sd_queries++;
878 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
891 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
895 q = p2p_sd_request(p2p, dst, tlvs);
903 void p2p_sd_service_update(struct p2p_data *p2p)
905 p2p->srv_update_indic++;
909 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
911 if (p2p_unlink_sd_query(p2p, req)) {
912 p2p_dbg(p2p, "Cancel pending SD query %p", req);