Lines Matching refs:p2p

50 struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,  in p2p_pending_sd_req()  argument
64 for (q = p2p->sd_queries; q; q = q->next) { in p2p_pending_sd_req()
91 p2p_dbg(p2p, "Too many SD request attempts to " MACSTR in p2p_pending_sd_req()
100 static void p2p_decrease_sd_bc_queries(struct p2p_data *p2p, int query_number) in p2p_decrease_sd_bc_queries() argument
104 p2p->num_p2p_sd_queries--; in p2p_decrease_sd_bc_queries()
105 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_decrease_sd_bc_queries()
117 static int p2p_unlink_sd_query(struct p2p_data *p2p, in p2p_unlink_sd_query() argument
123 q = p2p->sd_queries; in p2p_unlink_sd_query()
130 p2p_decrease_sd_bc_queries(p2p, query_number); in p2p_unlink_sd_query()
134 p2p->sd_queries = q->next; in p2p_unlink_sd_query()
135 if (p2p->sd_query == query) in p2p_unlink_sd_query()
136 p2p->sd_query = NULL; in p2p_unlink_sd_query()
157 void p2p_free_sd_queries(struct p2p_data *p2p) in p2p_free_sd_queries() argument
160 q = p2p->sd_queries; in p2p_free_sd_queries()
161 p2p->sd_queries = NULL; in p2p_free_sd_queries()
167 p2p->num_p2p_sd_queries = 0; in p2p_free_sd_queries()
194 static void p2p_send_gas_comeback_req(struct p2p_data *p2p, const u8 *dst, in p2p_send_gas_comeback_req() argument
203 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_send_gas_comeback_req()
204 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, dst, in p2p_send_gas_comeback_req()
206 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_send_gas_comeback_req()
272 int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev) in p2p_start_sd() argument
282 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer " in p2p_start_sd()
288 query = p2p_pending_sd_req(p2p, dev); in p2p_start_sd()
291 if (p2p->state == P2P_SEARCH && in p2p_start_sd()
292 os_memcmp(p2p->sd_query_no_ack, dev->info.p2p_device_addr, in p2p_start_sd()
294 p2p_dbg(p2p, "Do not start Service Discovery with " MACSTR in p2p_start_sd()
300 p2p_dbg(p2p, "Start Service Discovery with " MACSTR, in p2p_start_sd()
303 req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs); in p2p_start_sd()
308 p2p->sd_peer = dev; in p2p_start_sd()
309 p2p->sd_query = query; in p2p_start_sd()
310 p2p->pending_action_state = P2P_PENDING_SD; in p2p_start_sd()
313 if (p2p->cfg->max_listen && wait_time > p2p->cfg->max_listen) in p2p_start_sd()
314 wait_time = p2p->cfg->max_listen; in p2p_start_sd()
315 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr, in p2p_start_sd()
316 p2p->cfg->dev_addr, dev->info.p2p_device_addr, in p2p_start_sd()
318 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_start_sd()
328 void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa, in p2p_rx_gas_initial_req() argument
340 if (p2p->cfg->sd_request == NULL) in p2p_rx_gas_initial_req()
346 freq = p2p_channel_to_freq(p2p->cfg->reg_class, in p2p_rx_gas_initial_req()
347 p2p->cfg->channel); in p2p_rx_gas_initial_req()
355 p2p_dbg(p2p, "GAS Initial Request from " MACSTR in p2p_rx_gas_initial_req()
360 p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos); in p2p_rx_gas_initial_req()
367 p2p_dbg(p2p, "Invalid IE in GAS Initial Request"); in p2p_rx_gas_initial_req()
374 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u", in p2p_rx_gas_initial_req()
393 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos)); in p2p_rx_gas_initial_req()
401 p2p_dbg(p2p, "Invalid ANQP Query Request length"); in p2p_rx_gas_initial_req()
406 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x", in p2p_rx_gas_initial_req()
415 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic); in p2p_rx_gas_initial_req()
418 p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token, in p2p_rx_gas_initial_req()
424 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst, in p2p_sd_response() argument
439 p2p_dbg(p2p, "SD response long enough to require fragmentation"); in p2p_sd_response()
440 if (p2p->sd_resp) { in p2p_sd_response()
448 p2p_dbg(p2p, "Drop previous SD response"); in p2p_sd_response()
449 wpabuf_free(p2p->sd_resp); in p2p_sd_response()
451 p2p->sd_resp = wpabuf_dup(resp_tlvs); in p2p_sd_response()
452 if (p2p->sd_resp == NULL) { in p2p_sd_response()
453 p2p_err(p2p, "Failed to allocate SD response fragmentation area"); in p2p_sd_response()
456 os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN); in p2p_sd_response()
457 p2p->sd_resp_dialog_token = dialog_token; in p2p_sd_response()
458 p2p->sd_resp_pos = 0; in p2p_sd_response()
459 p2p->sd_frag_id = 0; in p2p_sd_response()
461 1, p2p->srv_update_indic, NULL); in p2p_sd_response()
463 p2p_dbg(p2p, "SD response fits in initial response"); in p2p_sd_response()
467 p2p->srv_update_indic, resp_tlvs); in p2p_sd_response()
472 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_sd_response()
473 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, in p2p_sd_response()
474 p2p->cfg->dev_addr, in p2p_sd_response()
476 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_sd_response()
482 void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa, in p2p_rx_gas_initial_resp() argument
494 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL || in p2p_rx_gas_initial_resp()
495 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) { in p2p_rx_gas_initial_resp()
496 p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from " in p2p_rx_gas_initial_resp()
500 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_rx_gas_initial_resp()
501 p2p_clear_timeout(p2p); in p2p_rx_gas_initial_resp()
503 p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)", in p2p_rx_gas_initial_resp()
507 p2p_dbg(p2p, "Too short GAS Initial Response frame"); in p2p_rx_gas_initial_resp()
517 p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u", in p2p_rx_gas_initial_resp()
520 p2p_dbg(p2p, "Service Discovery failed: status code %u", in p2p_rx_gas_initial_resp()
526 p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos); in p2p_rx_gas_initial_resp()
533 p2p_dbg(p2p, "Invalid IE in GAS Initial Response"); in p2p_rx_gas_initial_resp()
540 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u", in p2p_rx_gas_initial_resp()
548 p2p_dbg(p2p, "Too short Query Response"); in p2p_rx_gas_initial_resp()
553 p2p_dbg(p2p, "Query Response Length: %d", slen); in p2p_rx_gas_initial_resp()
555 p2p_dbg(p2p, "Not enough Query Response data"); in p2p_rx_gas_initial_resp()
561 p2p_dbg(p2p, "Fragmented response - request fragments"); in p2p_rx_gas_initial_resp()
562 if (p2p->sd_rx_resp) { in p2p_rx_gas_initial_resp()
563 p2p_dbg(p2p, "Drop old SD reassembly buffer"); in p2p_rx_gas_initial_resp()
564 wpabuf_free(p2p->sd_rx_resp); in p2p_rx_gas_initial_resp()
565 p2p->sd_rx_resp = NULL; in p2p_rx_gas_initial_resp()
567 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq); in p2p_rx_gas_initial_resp()
575 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos)); in p2p_rx_gas_initial_resp()
583 p2p_dbg(p2p, "Invalid ANQP Query Response length"); in p2p_rx_gas_initial_resp()
588 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x", in p2p_rx_gas_initial_resp()
597 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic); in p2p_rx_gas_initial_resp()
600 p2p->sd_peer = NULL; in p2p_rx_gas_initial_resp()
602 if (p2p->sd_query) { in p2p_rx_gas_initial_resp()
603 if (!p2p->sd_query->for_all_peers) { in p2p_rx_gas_initial_resp()
605 p2p_dbg(p2p, "Remove completed SD query %p", in p2p_rx_gas_initial_resp()
606 p2p->sd_query); in p2p_rx_gas_initial_resp()
607 q = p2p->sd_query; in p2p_rx_gas_initial_resp()
608 p2p_unlink_sd_query(p2p, p2p->sd_query); in p2p_rx_gas_initial_resp()
611 p2p->sd_query = NULL; in p2p_rx_gas_initial_resp()
614 if (p2p->cfg->sd_response) in p2p_rx_gas_initial_resp()
615 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, update_indic, in p2p_rx_gas_initial_resp()
617 p2p_continue_find(p2p); in p2p_rx_gas_initial_resp()
621 void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa, in p2p_rx_gas_comeback_req() argument
634 p2p_dbg(p2p, "Dialog Token: %u", dialog_token); in p2p_rx_gas_comeback_req()
635 if (dialog_token != p2p->sd_resp_dialog_token) { in p2p_rx_gas_comeback_req()
636 p2p_dbg(p2p, "No pending SD response fragment for dialog token %u", in p2p_rx_gas_comeback_req()
641 if (p2p->sd_resp == NULL) { in p2p_rx_gas_comeback_req()
642 p2p_dbg(p2p, "No pending SD response fragment available"); in p2p_rx_gas_comeback_req()
645 if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) { in p2p_rx_gas_comeback_req()
646 p2p_dbg(p2p, "No pending SD response fragment for " MACSTR, in p2p_rx_gas_comeback_req()
656 frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos; in p2p_rx_gas_comeback_req()
662 p2p->srv_update_indic, in p2p_rx_gas_comeback_req()
663 wpabuf_head_u8(p2p->sd_resp) + in p2p_rx_gas_comeback_req()
664 p2p->sd_resp_pos, frag_len, in p2p_rx_gas_comeback_req()
665 p2p->sd_frag_id, more, in p2p_rx_gas_comeback_req()
666 wpabuf_len(p2p->sd_resp)); in p2p_rx_gas_comeback_req()
669 p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)", in p2p_rx_gas_comeback_req()
670 p2p->sd_frag_id, more, (int) frag_len); in p2p_rx_gas_comeback_req()
671 p2p->sd_frag_id++; in p2p_rx_gas_comeback_req()
672 p2p->sd_resp_pos += frag_len; in p2p_rx_gas_comeback_req()
675 p2p_dbg(p2p, "%d more bytes remain to be sent", in p2p_rx_gas_comeback_req()
676 (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos)); in p2p_rx_gas_comeback_req()
678 p2p_dbg(p2p, "All fragments of SD response sent"); in p2p_rx_gas_comeback_req()
679 wpabuf_free(p2p->sd_resp); in p2p_rx_gas_comeback_req()
680 p2p->sd_resp = NULL; in p2p_rx_gas_comeback_req()
684 p2p->pending_action_state = P2P_NO_PENDING_ACTION; in p2p_rx_gas_comeback_req()
685 if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr, in p2p_rx_gas_comeback_req()
686 p2p->cfg->dev_addr, in p2p_rx_gas_comeback_req()
688 p2p_dbg(p2p, "Failed to send Action frame"); in p2p_rx_gas_comeback_req()
694 void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa, in p2p_rx_gas_comeback_resp() argument
709 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL || in p2p_rx_gas_comeback_resp()
710 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) { in p2p_rx_gas_comeback_resp()
711 p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from " in p2p_rx_gas_comeback_resp()
715 p2p->cfg->send_action_done(p2p->cfg->cb_ctx); in p2p_rx_gas_comeback_resp()
716 p2p_clear_timeout(p2p); in p2p_rx_gas_comeback_resp()
718 p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)", in p2p_rx_gas_comeback_resp()
722 p2p_dbg(p2p, "Too short GAS Comeback Response frame"); in p2p_rx_gas_comeback_resp()
735 p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d " in p2p_rx_gas_comeback_resp()
741 p2p_dbg(p2p, "Service Discovery failed: status code %u", in p2p_rx_gas_comeback_resp()
747 p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u", in p2p_rx_gas_comeback_resp()
755 p2p_dbg(p2p, "Invalid IE in GAS Comeback Response"); in p2p_rx_gas_comeback_resp()
762 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u", in p2p_rx_gas_comeback_resp()
770 p2p_dbg(p2p, "Too short Query Response"); in p2p_rx_gas_comeback_resp()
775 p2p_dbg(p2p, "Query Response Length: %d", slen); in p2p_rx_gas_comeback_resp()
777 p2p_dbg(p2p, "Not enough Query Response data"); in p2p_rx_gas_comeback_resp()
781 p2p_dbg(p2p, "No Query Response data"); in p2p_rx_gas_comeback_resp()
786 if (p2p->sd_rx_resp) { in p2p_rx_gas_comeback_resp()
798 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos)); in p2p_rx_gas_comeback_resp()
805 p2p_dbg(p2p, "ANQP Query Response length: %u", slen); in p2p_rx_gas_comeback_resp()
807 p2p_dbg(p2p, "Invalid ANQP Query Response length"); in p2p_rx_gas_comeback_resp()
814 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x", in p2p_rx_gas_comeback_resp()
822 p2p->sd_rx_update_indic = WPA_GET_LE16(pos); in p2p_rx_gas_comeback_resp()
823 p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic); in p2p_rx_gas_comeback_resp()
827 if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0) in p2p_rx_gas_comeback_resp()
829 wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos); in p2p_rx_gas_comeback_resp()
830 p2p_dbg(p2p, "Current SD reassembly buffer length: %u", in p2p_rx_gas_comeback_resp()
831 (unsigned int) wpabuf_len(p2p->sd_rx_resp)); in p2p_rx_gas_comeback_resp()
834 p2p_dbg(p2p, "More fragments remains"); in p2p_rx_gas_comeback_resp()
836 if (wpabuf_len(p2p->sd_rx_resp) > 64000) { in p2p_rx_gas_comeback_resp()
837 wpabuf_free(p2p->sd_rx_resp); in p2p_rx_gas_comeback_resp()
838 p2p->sd_rx_resp = NULL; in p2p_rx_gas_comeback_resp()
839 p2p_dbg(p2p, "Too long SD response - drop it"); in p2p_rx_gas_comeback_resp()
842 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq); in p2p_rx_gas_comeback_resp()
846 p2p->sd_peer = NULL; in p2p_rx_gas_comeback_resp()
848 if (p2p->sd_query) { in p2p_rx_gas_comeback_resp()
849 if (!p2p->sd_query->for_all_peers) { in p2p_rx_gas_comeback_resp()
851 p2p_dbg(p2p, "Remove completed SD query %p", in p2p_rx_gas_comeback_resp()
852 p2p->sd_query); in p2p_rx_gas_comeback_resp()
853 q = p2p->sd_query; in p2p_rx_gas_comeback_resp()
854 p2p_unlink_sd_query(p2p, p2p->sd_query); in p2p_rx_gas_comeback_resp()
857 p2p->sd_query = NULL; in p2p_rx_gas_comeback_resp()
860 if (p2p->cfg->sd_response) in p2p_rx_gas_comeback_resp()
861 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, in p2p_rx_gas_comeback_resp()
862 p2p->sd_rx_update_indic, in p2p_rx_gas_comeback_resp()
863 wpabuf_head(p2p->sd_rx_resp), in p2p_rx_gas_comeback_resp()
864 wpabuf_len(p2p->sd_rx_resp)); in p2p_rx_gas_comeback_resp()
865 wpabuf_free(p2p->sd_rx_resp); in p2p_rx_gas_comeback_resp()
866 p2p->sd_rx_resp = NULL; in p2p_rx_gas_comeback_resp()
868 p2p_continue_find(p2p); in p2p_rx_gas_comeback_resp()
872 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst, in p2p_sd_request() argument
892 q->next = p2p->sd_queries; in p2p_sd_request()
893 p2p->sd_queries = q; in p2p_sd_request()
894 p2p_dbg(p2p, "Added SD Query %p", q); in p2p_sd_request()
899 p2p->num_p2p_sd_queries++; in p2p_sd_request()
902 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) { in p2p_sd_request()
915 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst, in p2p_sd_request_wfd() argument
919 q = p2p_sd_request(p2p, dst, tlvs); in p2p_sd_request_wfd()
927 void p2p_sd_service_update(struct p2p_data *p2p) in p2p_sd_service_update() argument
929 p2p->srv_update_indic++; in p2p_sd_service_update()
933 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req) in p2p_sd_cancel_request() argument
935 if (p2p_unlink_sd_query(p2p, req)) { in p2p_sd_cancel_request()
936 p2p_dbg(p2p, "Cancel pending SD query %p", req); in p2p_sd_cancel_request()