Lines Matching refs:p2p

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 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
229 int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
238 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
245 query = p2p_pending_sd_req(p2p, dev);
249 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
253 req = p2p_build_sd_query(p2p->srv_update_indic, query->tlvs);
257 p2p->sd_peer = dev;
258 p2p->sd_query = query;
259 p2p->pending_action_state = P2P_PENDING_SD;
261 if (p2p_send_action(p2p, freq, dev->info.p2p_device_addr,
262 p2p->cfg->dev_addr, dev->info.p2p_device_addr,
264 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
275 void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
287 if (p2p->cfg->sd_request == NULL)
293 freq = p2p_channel_to_freq(p2p->cfg->country,
294 p2p->cfg->reg_class,
295 p2p->cfg->channel);
303 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
309 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
318 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
325 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
345 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
354 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
360 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
367 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
376 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
380 p2p->cfg->sd_request(p2p->cfg->cb_ctx, freq, sa, dialog_token,
386 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
393 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: SD response long "
395 if (p2p->sd_resp) {
403 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Drop "
405 wpabuf_free(p2p->sd_resp);
407 p2p->sd_resp = wpabuf_dup(resp_tlvs);
408 if (p2p->sd_resp == NULL) {
409 wpa_msg(p2p->cfg->msg_ctx, MSG_ERROR, "P2P: Failed to "
413 os_memcpy(p2p->sd_resp_addr, dst, ETH_ALEN);
414 p2p->sd_resp_dialog_token = dialog_token;
415 p2p->sd_resp_pos = 0;
416 p2p->sd_frag_id = 0;
418 1, p2p->srv_update_indic, NULL);
420 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: SD response fits "
424 p2p->srv_update_indic, resp_tlvs);
429 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
430 if (p2p_send_action(p2p, freq, dst, p2p->cfg->dev_addr,
431 p2p->cfg->dev_addr,
433 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
440 void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
452 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
453 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
454 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
459 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
460 p2p_clear_timeout(p2p);
462 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
467 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
478 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
482 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
489 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
499 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
506 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
515 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too short Query "
521 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Query Response Length: %d",
524 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Not enough Query "
531 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Fragmented "
533 if (p2p->sd_rx_resp) {
534 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Drop "
536 wpabuf_free(p2p->sd_rx_resp);
537 p2p->sd_rx_resp = NULL;
539 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
547 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
556 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
562 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
569 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
578 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
582 p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
583 p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
584 p2p->sd_peer = NULL;
586 if (p2p->sd_query) {
587 if (!p2p->sd_query->for_all_peers) {
589 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
591 p2p->sd_query);
592 q = p2p->sd_query;
593 p2p_unlink_sd_query(p2p, p2p->sd_query);
596 p2p->sd_query = NULL;
599 if (p2p->cfg->sd_response)
600 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa, update_indic,
602 p2p_continue_find(p2p);
606 void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa,
618 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Dialog Token: %u",
620 if (dialog_token != p2p->sd_resp_dialog_token) {
621 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD "
626 if (p2p->sd_resp == NULL) {
627 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD "
631 if (os_memcmp(sa, p2p->sd_resp_addr, ETH_ALEN) != 0) {
632 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No pending SD "
637 frag_len = wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos;
643 p2p->srv_update_indic,
644 wpabuf_head_u8(p2p->sd_resp) +
645 p2p->sd_resp_pos, frag_len,
646 p2p->sd_frag_id, more,
647 wpabuf_len(p2p->sd_resp));
650 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Send GAS Comeback "
652 p2p->sd_frag_id, more, (int) frag_len);
653 p2p->sd_frag_id++;
654 p2p->sd_resp_pos += frag_len;
657 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: %d more bytes "
659 (int) (wpabuf_len(p2p->sd_resp) - p2p->sd_resp_pos));
661 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: All fragments of "
663 wpabuf_free(p2p->sd_resp);
664 p2p->sd_resp = NULL;
667 p2p->pending_action_state = P2P_NO_PENDING_ACTION;
668 if (p2p_send_action(p2p, rx_freq, sa, p2p->cfg->dev_addr,
669 p2p->cfg->dev_addr,
671 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
678 void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
693 if (p2p->state != P2P_SD_DURING_FIND || p2p->sd_peer == NULL ||
694 os_memcmp(sa, p2p->sd_peer->info.p2p_device_addr, ETH_ALEN) != 0) {
695 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
700 p2p->cfg->send_action_done(p2p->cfg->cb_ctx);
701 p2p_clear_timeout(p2p);
703 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
708 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
722 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
729 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
736 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
746 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
753 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
762 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too short Query "
768 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Query Response Length: %d",
771 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Not enough Query "
776 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: No Query Response "
782 if (p2p->sd_rx_resp) {
794 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
802 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: ANQP Query Response "
805 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
813 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
820 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
828 p2p->sd_rx_update_indic = WPA_GET_LE16(pos);
829 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
830 "P2P: Service Update Indicator: %u", p2p->sd_rx_update_indic);
834 if (wpabuf_resize(&p2p->sd_rx_resp, end - pos) < 0)
836 wpabuf_put_data(p2p->sd_rx_resp, pos, end - pos);
837 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Current SD reassembly "
839 (unsigned int) wpabuf_len(p2p->sd_rx_resp));
842 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: More fragments "
845 if (wpabuf_len(p2p->sd_rx_resp) > 64000) {
846 wpabuf_free(p2p->sd_rx_resp);
847 p2p->sd_rx_resp = NULL;
848 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Too long "
852 p2p_send_gas_comeback_req(p2p, sa, dialog_token, rx_freq);
856 p2p->sd_peer->flags |= P2P_DEV_SD_INFO;
857 p2p->sd_peer->flags &= ~P2P_DEV_SD_SCHEDULE;
858 p2p->sd_peer = NULL;
860 if (p2p->sd_query) {
861 if (!p2p->sd_query->for_all_peers) {
863 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
865 p2p->sd_query);
866 q = p2p->sd_query;
867 p2p_unlink_sd_query(p2p, p2p->sd_query);
870 p2p->sd_query = NULL;
873 if (p2p->cfg->sd_response)
874 p2p->cfg->sd_response(p2p->cfg->cb_ctx, sa,
875 p2p->sd_rx_update_indic,
876 wpabuf_head(p2p->sd_rx_resp),
877 wpabuf_len(p2p->sd_rx_resp));
878 wpabuf_free(p2p->sd_rx_resp);
879 p2p->sd_rx_resp = NULL;
881 p2p_continue_find(p2p);
885 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
905 q->next = p2p->sd_queries;
906 p2p->sd_queries = q;
907 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Added SD Query %p", q);
911 dl_list_for_each(dev, &p2p->devices, struct p2p_device, list)
920 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
924 q = p2p_sd_request(p2p, dst, tlvs);
932 void p2p_sd_service_update(struct p2p_data *p2p)
934 p2p->srv_update_indic++;
938 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req)
940 if (p2p_unlink_sd_query(p2p, req)) {
941 wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,