Home | History | Annotate | Download | only in p2p

Lines Matching refs:p2p

2  * Wi-Fi Direct - P2P service discovery
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);
291 if (p2p->state == P2P_SEARCH &&
292 os_memcmp(p2p->sd_query_no_ack, dev->info.p2p_device_addr,
294 p2p_dbg(p2p, "Do not start Service Discovery with " MACSTR
300 p2p_dbg(p2p, "Start Service Discovery with " MACSTR,
303 req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
308 p2p->sd_peer = dev;
309 p2p->sd_query = query;
310 p2p->pending_action_state = P2P_PENDING_SD;
313 if (p2p->cfg->max_listen && wait_time > p2p->cfg->max_listen)
314 wait_time = p2p->cfg->max_listen;
315 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
316 p2p->cfg->dev_addr, dev->info.p2p_device_addr,
318 p2p_dbg(p2p, "Failed to send Action frame");
328 void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
340 if (p2p->cfg->sd_request == NULL)
346 freq = p2p_channel_to_freq(p2p->cfg->reg_class,
347 p2p->cfg->channel);
355 p2p_dbg(p2p, "GAS Initial Request from " MACSTR
360 p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
367 p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
374 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
393 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
401 p2p_dbg(p2p, "Invalid ANQP Query Request length");
406 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
415 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
418 p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
424 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
438 p2p_dbg(p2p, "SD response long enough to require fragmentation");
439 if (p2p->sd_resp) {
447 p2p_dbg(p2p, "Drop previous SD response");
448 wpabuf_free(p2p->sd_resp);
450 p2p->sd_resp = wpabuf_dup(resp_tlvs);
451 if (p2p->sd_resp == NULL) {
452 p2p_err(p2p, "Failed to allocate SD response fragmentation area");
455 os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN);
456 p2p->sd_resp_dialog_token = dialog_token;
457 p2p->sd_resp_pos = 0;
458 p2p->sd_frag_id = 0;
460 1, p2p->srv_update_indic, NULL);
462 p2p_dbg(p2p, "SD response fits in initial response");
465 p2p->srv_update_indic, resp_tlvs);
470 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
471 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr,
472 p2p->cfg->dev_addr,
474 p2p_dbg(p2p, "Failed to send Action frame");
480 void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
492 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
493 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
494 p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
498 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
499 p2p_clear_timeout(p2p);
501 p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
505 p2p_dbg(p2p, "Too short GAS Initial Response frame");
515 p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
518 p2p_dbg(p2p, "Service Discovery failed: status code %u",
524 p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
531 p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
538 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
546 p2p_dbg(p2p, "Too short Query Response");
551 p2p_dbg(p2p, "Query Response Length: %d", slen);
553 p2p_dbg(p2p, "Not enough Query Response data");
559 p2p_dbg(p2p, "Fragmented response - request fragments");
560 if (p2p->sd_rx_resp) {
561 p2p_dbg(p2p, "Drop old SD reassembly buffer");
562 wpabuf_free(p2p->sd_rx_resp);
563 p2p->sd_rx_resp = NULL;
565 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
573 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
581 p2p_dbg(p2p, "Invalid ANQP Query Response length");
586 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
595 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
598 p2p->sd_peer = NULL;
600 if (p2p->sd_query) {
601 if (!p2p->sd_query->for_all_peers) {
603 p2p_dbg(p2p, "Remove completed SD query %p",
604 p2p->sd_query);
605 q = p2p->sd_query;
606 p2p_unlink_sd_query(p2p, p2p->sd_query);
609 p2p->sd_query = NULL;
612 if (p2p->cfg->sd_response)
613 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, update_indic,
615 p2p_continue_find(p2p);
619 void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
627 wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Request", data, len);
631 p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
632 if (dialog_token != p2p->sd_resp_dialog_token) {
633 p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
638 if (p2p->sd_resp == NULL) {
639 p2p_dbg(p2p, "No pending SD response fragment available");
642 if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) {
643 p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
653 frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos;
659 p2p->srv_update_indic,
660 wpabuf_head_u8(p2p->sd_resp) +
661 p2p->sd_resp_pos, frag_len,
662 p2p->sd_frag_id, more,
663 wpabuf_len(p2p->sd_resp));
666 p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
667 p2p->sd_frag_id, more, (int) frag_len);
668 p2p->sd_frag_id++;
669 p2p->sd_resp_pos += frag_len;
672 p2p_dbg(p2p, "%d more bytes remain to be sent",
673 (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
675 p2p_dbg(p2p, "All fragments of SD response sent");
676 wpabuf_free(p2p->sd_resp);
677 p2p->sd_resp = NULL;
680 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
681 if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
682 p2p->cfg->dev_addr,
684 p2p_dbg(p2p, "Failed to send Action frame");
690 void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
703 wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Response", data, len);
705 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
706 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
707 p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
711 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
712 p2p_clear_timeout(p2p);
714 p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
718 p2p_dbg(p2p, "Too short GAS Comeback Response frame");
731 p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
737 p2p_dbg(p2p, "Service Discovery failed: status code %u",
743 p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
751 p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
758 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
766 p2p_dbg(p2p, "Too short Query Response");
771 p2p_dbg(p2p, "Query Response Length: %d", slen);
773 p2p_dbg(p2p, "Not enough Query Response data");
777 p2p_dbg(p2p, "No Query Response data");
782 if (p2p->sd_rx_resp) {
794 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
801 p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
803 p2p_dbg(p2p, "Invalid ANQP Query Response length");
810 p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
818 p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
819 p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic);
823 if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
825 wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
826 p2p_dbg(p2p, "Current SD reassembly buffer length: %u",
827 (unsigned int) wpabuf_len(p2p->sd_rx_resp));
830 p2p_dbg(p2p, "More fragments remains");
832 if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
833 wpabuf_free(p2p->sd_rx_resp);
834 p2p->sd_rx_resp = NULL;
835 p2p_dbg(p2p, "Too long SD response - drop it");
838 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
842 p2p->sd_peer = NULL;
844 if (p2p->sd_query) {
845 if (!p2p->sd_query->for_all_peers) {
847 p2p_dbg(p2p, "Remove completed SD query %p",
848 p2p->sd_query);
849 q = p2p->sd_query;
850 p2p_unlink_sd_query(p2p, p2p->sd_query);
853 p2p->sd_query = NULL;
856 if (p2p->cfg->sd_response)
857 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa,
858 p2p->sd_rx_update_indic,
859 wpabuf_head(p2p->sd_rx_resp),
860 wpabuf_len(p2p->sd_rx_resp));
861 wpabuf_free(p2p->sd_rx_resp);
862 p2p->sd_rx_resp = NULL;
864 p2p_continue_find(p2p);
868 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
888 q->next = p2p->sd_queries;
889 p2p->sd_queries = q;
890 p2p_dbg(p2p, "Added SD Query %p", q);
895 p2p->num_p2p_sd_queries++;
898 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
911 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
915 q = p2p_sd_request(p2p, dst, tlvs);
923 void p2p_sd_service_update(struct p2p_data *p2p)
925 p2p->srv_update_indic++;
929 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
931 if (p2p_unlink_sd_query(p2p, req)) {
932 p2p_dbg(p2p, "Cancel pending SD query %p", req);