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,
63 for (q = p2p->sd_queries; q; q = q->next) {
79 static int p2p_unlink_sd_query(struct p2p_data *p2p,
83 q = p2p->sd_queries;
90 p2p->sd_queries = q->next;
91 if (p2p->sd_query == query)
92 p2p->sd_query = NULL;
111 void p2p_free_sd_queries(struct p2p_data *p2p)
114 q = p2p->sd_queries;
115 p2p->sd_queries = NULL;
148 static void p2p_send_gas_comeback_req(struct p2p_data *p2p, const u8 *dst,
157 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
158 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr, dst,
160 p2p_dbg(p2p, "Failed to send Action frame");
228 int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
237 p2p_dbg(p2p, "No Listen/Operating frequency known for the peer "
243 query = p2p_pending_sd_req(p2p, dev);
247 p2p_dbg(p2p, "Start Service Discovery with " MACSTR,
250 req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
254 p2p->sd_peer = dev;
255 p2p->sd_query = query;
256 p2p->pending_action_state = P2P_PENDING_SD;
258 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
259 p2p->cfg->dev_addr, dev->info.p2p_device_addr,
261 p2p_dbg(p2p, "Failed to send Action frame");
271 void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
283 if (p2p->cfg->sd_request == NULL)
289 freq = p2p_channel_to_freq(p2p->cfg->reg_class,
290 p2p->cfg->channel);
298 p2p_dbg(p2p, "GAS Initial Request from " MACSTR
303 p2p_dbg(p2p, "Unexpected IE in GAS Initial Request: %u", *pos);
311 p2p_dbg(p2p, "Invalid IE in GAS Initial Request");
317 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
336 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
344 p2p_dbg(p2p, "Invalid ANQP Query Request length");
349 p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
355 p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
363 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
366 p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
372 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
379 p2p_dbg(p2p, "SD response long enough to require fragmentation");
380 if (p2p->sd_resp) {
388 p2p_dbg(p2p, "Drop previous SD response");
389 wpabuf_free(p2p->sd_resp);
391 p2p->sd_resp = wpabuf_dup(resp_tlvs);
392 if (p2p->sd_resp == NULL) {
393 p2p_err(p2p, "Failed to allocate SD response fragmentation area");
396 os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN);
397 p2p->sd_resp_dialog_token = dialog_token;
398 p2p->sd_resp_pos = 0;
399 p2p->sd_frag_id = 0;
401 1, p2p->srv_update_indic, NULL);
403 p2p_dbg(p2p, "SD response fits in initial response");
406 p2p->srv_update_indic, resp_tlvs);
411 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
412 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr,
413 p2p->cfg->dev_addr,
415 p2p_dbg(p2p, "Failed to send Action frame");
421 void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
434 if (p2p->state != P2P_SD_DURING_FIND) {
435 p2p_dbg(p2p, "P2P: #### Not ignoring unexpected GAS Initial Response from "
436 MACSTR " state %d", MAC2STR(sa), p2p->state);
438 if (p2p->sd_peer == NULL ||
440 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
442 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
443 p2p_dbg(p2p, "Ignore unexpected GAS Initial Response from "
447 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
448 p2p_clear_timeout(p2p);
450 p2p_dbg(p2p, "Received GAS Initial Response from " MACSTR " (len=%d)",
454 p2p_dbg(p2p, "Too short GAS Initial Response frame");
464 p2p_dbg(p2p, "dialog_token=%u status_code=%u comeback_delay=%u",
467 p2p_dbg(p2p, "Service Discovery failed: status code %u",
473 p2p_dbg(p2p, "Unexpected IE in GAS Initial Response: %u", *pos);
481 p2p_dbg(p2p, "Invalid IE in GAS Initial Response");
487 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
495 p2p_dbg(p2p, "Too short Query Response");
500 p2p_dbg(p2p, "Query Response Length: %d", slen);
502 p2p_dbg(p2p, "Not enough Query Response data");
508 p2p_dbg(p2p, "Fragmented response - request fragments");
509 if (p2p->sd_rx_resp) {
510 p2p_dbg(p2p, "Drop old SD reassembly buffer");
511 wpabuf_free(p2p->sd_rx_resp);
512 p2p->sd_rx_resp = NULL;
514 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
522 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
530 p2p_dbg(p2p, "Invalid ANQP Query Response length");
535 p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
541 p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
549 p2p_dbg(p2p, "Service Update Indicator: %u", update_indic);
552 p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
553 p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
554 p2p->sd_peer = NULL;
556 if (p2p->sd_query) {
557 if (!p2p->sd_query->for_all_peers) {
559 p2p_dbg(p2p, "Remove completed SD query %p",
560 p2p->sd_query);
561 q = p2p->sd_query;
562 p2p_unlink_sd_query(p2p, p2p->sd_query);
565 p2p->sd_query = NULL;
568 if (p2p->cfg->sd_response)
569 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, update_indic,
571 p2p_continue_find(p2p);
575 void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
583 wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Request", data, len);
587 p2p_dbg(p2p, "Dialog Token: %u", dialog_token);
588 if (dialog_token != p2p->sd_resp_dialog_token) {
589 p2p_dbg(p2p, "No pending SD response fragment for dialog token %u",
594 if (p2p->sd_resp == NULL) {
595 p2p_dbg(p2p, "No pending SD response fragment available");
598 if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) {
599 p2p_dbg(p2p, "No pending SD response fragment for " MACSTR,
604 frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos;
610 p2p->srv_update_indic,
611 wpabuf_head_u8(p2p->sd_resp) +
612 p2p->sd_resp_pos, frag_len,
613 p2p->sd_frag_id, more,
614 wpabuf_len(p2p->sd_resp));
617 p2p_dbg(p2p, "Send GAS Comeback Response (frag_id %d more=%d frag_len=%d)",
618 p2p->sd_frag_id, more, (int) frag_len);
619 p2p->sd_frag_id++;
620 p2p->sd_resp_pos += frag_len;
623 p2p_dbg(p2p, "%d more bytes remain to be sent",
624 (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
626 p2p_dbg(p2p, "All fragments of SD response sent");
627 wpabuf_free(p2p->sd_resp);
628 p2p->sd_resp = NULL;
631 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
632 if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
633 p2p->cfg->dev_addr,
635 p2p_dbg(p2p, "Failed to send Action frame");
641 void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
654 wpa_hexdump(MSG_DEBUG, "P2P: RX GAS Comeback Response", data, len);
657 if (p2p->state != P2P_SD_DURING_FIND) {
658 p2p_dbg(p2p, "P2P: #### Not ignoring unexpected GAS Comeback Response from "
659 MACSTR " state %d", MAC2STR(sa), p2p->state);
661 if (p2p->sd_peer == NULL ||
663 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
665 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
666 p2p_dbg(p2p, "Ignore unexpected GAS Comeback Response from "
670 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
671 p2p_clear_timeout(p2p);
673 p2p_dbg(p2p, "Received GAS Comeback Response from " MACSTR " (len=%d)",
677 p2p_dbg(p2p, "Too short GAS Comeback Response frame");
690 p2p_dbg(p2p, "dialog_token=%u status_code=%u frag_id=%d more_frags=%d "
696 p2p_dbg(p2p, "Service Discovery failed: status code %u",
702 p2p_dbg(p2p, "Unexpected IE in GAS Comeback Response: %u",
711 p2p_dbg(p2p, "Invalid IE in GAS Comeback Response");
717 p2p_dbg(p2p, "Unsupported GAS advertisement protocol id %u",
725 p2p_dbg(p2p, "Too short Query Response");
730 p2p_dbg(p2p, "Query Response Length: %d", slen);
732 p2p_dbg(p2p, "Not enough Query Response data");
736 p2p_dbg(p2p, "No Query Response data");
741 if (p2p->sd_rx_resp) {
753 p2p_dbg(p2p, "Unsupported ANQP Info ID %u", WPA_GET_LE16(pos));
760 p2p_dbg(p2p, "ANQP Query Response length: %u", slen);
762 p2p_dbg(p2p, "Invalid ANQP Query Response length");
769 p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos));
775 p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
782 p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
783 p2p_dbg(p2p, "Service Update Indicator: %u", p2p->sd_rx_update_indic);
787 if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
789 wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
790 p2p_dbg(p2p, "Current SD reassembly buffer length: %u",
791 (unsigned int) wpabuf_len(p2p->sd_rx_resp));
794 p2p_dbg(p2p, "More fragments remains");
796 if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
797 wpabuf_free(p2p->sd_rx_resp);
798 p2p->sd_rx_resp = NULL;
799 p2p_dbg(p2p, "Too long SD response - drop it");
802 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
806 p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
807 p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
808 p2p->sd_peer = NULL;
810 if (p2p->sd_query) {
811 if (!p2p->sd_query->for_all_peers) {
813 p2p_dbg(p2p, "Remove completed SD query %p",
814 p2p->sd_query);
815 q = p2p->sd_query;
816 p2p_unlink_sd_query(p2p, p2p->sd_query);
819 p2p->sd_query = NULL;
822 if (p2p->cfg->sd_response)
823 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa,
824 p2p->sd_rx_update_indic,
825 wpabuf_head(p2p->sd_rx_resp),
826 wpabuf_len(p2p->sd_rx_resp));
827 wpabuf_free(p2p->sd_rx_resp);
828 p2p->sd_rx_resp = NULL;
830 p2p_continue_find(p2p);
834 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
842 for (q = p2p->sd_queries; q; q = q->next) {
844 wpa_printf(MSG_ERROR, "P2P: Already one pending"
867 q->next = p2p->sd_queries;
868 p2p->sd_queries = q;
869 p2p_dbg(p2p, "Added SD Query %p", q);
873 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list)
882 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
886 q = p2p_sd_request(p2p, dst, tlvs);
894 void p2p_sd_service_update(struct p2p_data *p2p)
896 p2p->srv_update_indic++;
900 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
902 if (p2p_unlink_sd_query(p2p, req)) {
903 p2p_dbg(p2p, "Cancel pending SD query %p", req);
905 p2p->sd_dev_list = NULL;