1 /* 2 * P2P - Internal definitions for P2P module 3 * Copyright (c) 2009-2010, Atheros Communications 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef P2P_I_H 10 #define P2P_I_H 11 12 #include "utils/list.h" 13 #include "drivers/driver.h" 14 #ifdef CONFIG_OPEN_HARMONY_PATCH 15 #include "ap/ap_config.h" 16 #endif /* CONFIG_OPEN_HARMONY_PATCH */ 17 #include "p2p.h" 18 19 #define P2P_GO_NEG_CNF_MAX_RETRY_COUNT 1 20 21 /* 22 * A threshold (in seconds) to prefer a direct Probe Response frame from a P2P 23 * Device over the P2P Client Info received from a GO. 24 */ 25 #define P2P_DEV_GROUP_CLIENT_RESP_THRESHOLD 1 26 27 enum p2p_role_indication; 28 29 /* 30 * To force Service Instances to fit within a single P2P Tag, MAX_SVC_ADV_LEN 31 * must equal 248 or less. Must have a minimum size of 19. 32 */ 33 #define MAX_SVC_ADV_LEN 600 34 #define MAX_SVC_ADV_IE_LEN (9 + MAX_SVC_ADV_LEN + (5 * (MAX_SVC_ADV_LEN / 240))) 35 36 enum p2p_go_state { 37 UNKNOWN_GO, 38 LOCAL_GO, 39 REMOTE_GO 40 }; 41 42 /** 43 * struct p2p_device - P2P Device data (internal to P2P module) 44 */ 45 struct p2p_device { 46 struct dl_list list; 47 struct os_reltime last_seen; 48 int listen_freq; 49 int oob_go_neg_freq; 50 enum p2p_wps_method wps_method; 51 u16 oob_pw_id; 52 53 struct p2p_peer_info info; 54 55 /* 56 * If the peer was discovered based on an interface address (e.g., GO 57 * from Beacon/Probe Response), the interface address is stored here. 58 * p2p_device_addr must still be set in such a case to the unique 59 * identifier for the P2P Device. 60 * 61 * This field is also used during P2PS PD to store the intended GO 62 * address of the peer. 63 */ 64 u8 interface_addr[ETH_ALEN]; 65 66 /* 67 * P2P Device Address of the GO in whose group this P2P Device is a 68 * client. 69 */ 70 u8 member_in_go_dev[ETH_ALEN]; 71 72 /* 73 * P2P Interface Address of the GO in whose group this P2P Device is a 74 * client. 75 */ 76 u8 member_in_go_iface[ETH_ALEN]; 77 78 int go_neg_req_sent; 79 enum p2p_go_state go_state; 80 u8 dialog_token; 81 u8 tie_breaker; 82 u8 intended_addr[ETH_ALEN]; 83 84 char country[3]; 85 struct p2p_channels channels; 86 int oper_freq; 87 u8 oper_ssid[SSID_MAX_LEN]; 88 size_t oper_ssid_len; 89 90 /** 91 * req_config_methods - Pending provision discovery methods 92 */ 93 u16 req_config_methods; 94 95 /** 96 * wps_prov_info - Stored provisioning WPS config method 97 * 98 * This is used to store pending WPS config method between Provisioning 99 * Discovery and connection to a running group. 100 */ 101 u16 wps_prov_info; 102 103 #define P2P_DEV_PROBE_REQ_ONLY BIT(0) 104 #define P2P_DEV_REPORTED BIT(1) 105 #define P2P_DEV_NOT_YET_READY BIT(2) 106 #define P2P_DEV_PD_PEER_DISPLAY BIT(5) 107 #define P2P_DEV_PD_PEER_KEYPAD BIT(6) 108 #define P2P_DEV_USER_REJECTED BIT(7) 109 #define P2P_DEV_PEER_WAITING_RESPONSE BIT(8) 110 #define P2P_DEV_PREFER_PERSISTENT_GROUP BIT(9) 111 #define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10) 112 #define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11) 113 #define P2P_DEV_GROUP_CLIENT_ONLY BIT(12) 114 #define P2P_DEV_FORCE_FREQ BIT(13) 115 #define P2P_DEV_PD_FOR_JOIN BIT(14) 116 #define P2P_DEV_REPORTED_ONCE BIT(15) 117 #define P2P_DEV_PREFER_PERSISTENT_RECONN BIT(16) 118 #define P2P_DEV_PD_BEFORE_GO_NEG BIT(17) 119 #define P2P_DEV_NO_PREF_CHAN BIT(18) 120 #define P2P_DEV_WAIT_INV_REQ_ACK BIT(19) 121 #define P2P_DEV_P2PS_REPORTED BIT(20) 122 #define P2P_DEV_PD_PEER_P2PS BIT(21) 123 #define P2P_DEV_LAST_SEEN_AS_GROUP_CLIENT BIT(22) 124 125 unsigned int flags; 126 127 int status; /* enum p2p_status_code */ 128 unsigned int wait_count; 129 unsigned int connect_reqs; 130 unsigned int invitation_reqs; 131 unsigned int sd_reqs; 132 133 u16 ext_listen_period; 134 u16 ext_listen_interval; 135 136 u8 go_timeout; 137 u8 client_timeout; 138 139 /** 140 * go_neg_conf_sent - Number of GO Negotiation Confirmation retries 141 */ 142 u8 go_neg_conf_sent; 143 144 /** 145 * freq - Frquency on which the GO Negotiation Confirmation is sent 146 */ 147 int go_neg_conf_freq; 148 149 /** 150 * go_neg_conf - GO Negotiation Confirmation frame 151 */ 152 struct wpabuf *go_neg_conf; 153 154 int sd_pending_bcast_queries; 155 bool support_6ghz; 156 }; 157 158 struct p2p_sd_query { 159 struct p2p_sd_query *next; 160 u8 peer[ETH_ALEN]; 161 int for_all_peers; 162 int wsd; /* Wi-Fi Display Service Discovery Request */ 163 struct wpabuf *tlvs; 164 }; 165 166 /** 167 * struct p2p_data - P2P module data (internal to P2P module) 168 */ 169 struct p2p_data { 170 /** 171 * cfg - P2P module configuration 172 * 173 * This is included in the same memory allocation with the 174 * struct p2p_data and as such, must not be freed separately. 175 */ 176 struct p2p_config *cfg; 177 178 /** 179 * state - The current P2P state 180 */ 181 enum p2p_state { 182 /** 183 * P2P_IDLE - Idle 184 */ 185 P2P_IDLE, 186 187 /** 188 * P2P_SEARCH - Search (Device Discovery) 189 */ 190 P2P_SEARCH, 191 192 /** 193 * P2P_CONNECT - Trying to start GO Negotiation 194 */ 195 P2P_CONNECT, 196 197 /** 198 * P2P_CONNECT_LISTEN - Listen during GO Negotiation start 199 */ 200 P2P_CONNECT_LISTEN, 201 202 /** 203 * P2P_GO_NEG - In GO Negotiation 204 */ 205 P2P_GO_NEG, 206 207 /** 208 * P2P_LISTEN_ONLY - Listen only 209 */ 210 P2P_LISTEN_ONLY, 211 212 /** 213 * P2P_WAIT_PEER_CONNECT - Waiting peer in List for GO Neg 214 */ 215 P2P_WAIT_PEER_CONNECT, 216 217 /** 218 * P2P_WAIT_PEER_IDLE - Waiting peer idle for GO Neg 219 */ 220 P2P_WAIT_PEER_IDLE, 221 222 /** 223 * P2P_SD_DURING_FIND - Service Discovery during find 224 */ 225 P2P_SD_DURING_FIND, 226 227 /** 228 * P2P_PROVISIONING - Provisioning (during group formation) 229 */ 230 P2P_PROVISIONING, 231 232 /** 233 * P2P_PD_DURING_FIND - Provision Discovery during find 234 */ 235 P2P_PD_DURING_FIND, 236 237 /** 238 * P2P_INVITE - Trying to start Invite 239 */ 240 P2P_INVITE, 241 242 /** 243 * P2P_INVITE_LISTEN - Listen during Invite 244 */ 245 P2P_INVITE_LISTEN, 246 } state; 247 248 /** 249 * min_disc_int - minDiscoverableInterval 250 */ 251 int min_disc_int; 252 253 /** 254 * max_disc_int - maxDiscoverableInterval 255 */ 256 int max_disc_int; 257 258 /** 259 * max_disc_tu - Maximum number of TUs for discoverable interval 260 */ 261 int max_disc_tu; 262 263 /** 264 * devices - List of known P2P Device peers 265 */ 266 struct dl_list devices; 267 268 /** 269 * go_neg_peer - Pointer to GO Negotiation peer 270 */ 271 struct p2p_device *go_neg_peer; 272 273 /** 274 * invite_peer - Pointer to Invite peer 275 */ 276 struct p2p_device *invite_peer; 277 278 /** 279 * last_p2p_find_oper - Pointer to last pre-find operation peer 280 */ 281 struct p2p_device *last_p2p_find_oper; 282 283 const u8 *invite_go_dev_addr; 284 u8 invite_go_dev_addr_buf[ETH_ALEN]; 285 int invite_dev_pw_id; 286 287 unsigned int retry_invite_req:1; 288 unsigned int retry_invite_req_sent:1; 289 290 /** 291 * sd_peer - Pointer to Service Discovery peer 292 */ 293 struct p2p_device *sd_peer; 294 295 /** 296 * sd_query - Pointer to Service Discovery query 297 */ 298 struct p2p_sd_query *sd_query; 299 300 /** 301 * num_p2p_sd_queries - Total number of broadcast SD queries present in 302 * the list 303 */ 304 int num_p2p_sd_queries; 305 306 /** 307 * sd_query_no_ack - The first peer (Dev Addr) that did not ACK SD Query 308 * 309 * This is used to track the first peer that did not ACK an SD Query 310 * within a single P2P Search iteration. All zeros address means no such 311 * peer was yet seen. This information is used to allow a new Listen and 312 * Search phases to be once every pending SD Query has been sent once to 313 * each peer instead of looping all pending attempts continuously until 314 * running out of retry maximums. 315 */ 316 u8 sd_query_no_ack[ETH_ALEN]; 317 318 /* GO Negotiation data */ 319 320 /** 321 * intended_addr - Local Intended P2P Interface Address 322 * 323 * This address is used during group owner negotiation as the Intended 324 * P2P Interface Address and the group interface will be created with 325 * address as the local address in case of successfully completed 326 * negotiation. 327 */ 328 u8 intended_addr[ETH_ALEN]; 329 330 /** 331 * go_intent - Local GO Intent to be used during GO Negotiation 332 */ 333 u8 go_intent; 334 335 /** 336 * next_tie_breaker - Next tie-breaker value to use in GO Negotiation 337 */ 338 u8 next_tie_breaker; 339 340 /** 341 * ssid - Selected SSID for GO Negotiation (if local end will be GO) 342 */ 343 u8 ssid[SSID_MAX_LEN]; 344 345 /** 346 * ssid_len - ssid length in octets 347 */ 348 size_t ssid_len; 349 350 /** 351 * ssid_set - Whether SSID is already set for GO Negotiation 352 */ 353 int ssid_set; 354 355 #ifdef CONFIG_WIFI_RPT 356 /** 357 * p2p_rpt_net_id - net id of rpt 358 */ 359 int p2p_rpt_net_id; 360 361 /** 362 * p2p_rpt - whether p2p is rpt 363 */ 364 int p2p_rpt; 365 366 /** 367 * p2p_rpt_freq - wifi rpt freq 368 */ 369 int p2p_rpt_freq; 370 371 /** 372 * ssid_preconfigured - wifi rpt ssid 373 */ 374 char ssid_preconfigured[32]; 375 376 /** 377 * passphrase_preconfigured - wifi rpt psk 378 */ 379 char passphrase_preconfigured[64]; 380 #endif /* CONFIG_WIFI_RPT */ 381 382 /** 383 * Regulatory class for own operational channel 384 */ 385 u8 op_reg_class; 386 387 /** 388 * op_channel - Own operational channel 389 */ 390 u8 op_channel; 391 392 /** 393 * channels - Own supported regulatory classes and channels 394 * 395 * List of supposerted channels per regulatory class. The regulatory 396 * classes are defined in IEEE Std 802.11-2007 Annex J and the 397 * numbering of the clases depends on the configured country code. 398 */ 399 struct p2p_channels channels; 400 401 struct wpa_freq_range_list no_go_freq; 402 403 enum p2p_pending_action_state { 404 P2P_NO_PENDING_ACTION, 405 P2P_PENDING_GO_NEG_REQUEST, 406 P2P_PENDING_GO_NEG_RESPONSE, 407 P2P_PENDING_GO_NEG_RESPONSE_FAILURE, 408 P2P_PENDING_GO_NEG_CONFIRM, 409 P2P_PENDING_SD, 410 P2P_PENDING_PD, 411 P2P_PENDING_PD_RESPONSE, 412 P2P_PENDING_INVITATION_REQUEST, 413 P2P_PENDING_INVITATION_RESPONSE, 414 P2P_PENDING_DEV_DISC_REQUEST, 415 P2P_PENDING_DEV_DISC_RESPONSE, 416 P2P_PENDING_GO_DISC_REQ 417 } pending_action_state; 418 419 unsigned int pending_listen_freq; 420 unsigned int pending_listen_sec; 421 unsigned int pending_listen_usec; 422 bool pending_listen_wait_drv; 423 424 u8 dev_capab; 425 426 int in_listen; 427 int drv_in_listen; 428 429 /** 430 * sd_queries - Pending service discovery queries 431 */ 432 struct p2p_sd_query *sd_queries; 433 434 /** 435 * srv_update_indic - Service Update Indicator for local services 436 */ 437 u16 srv_update_indic; 438 439 struct wpabuf *sd_resp; /* Fragmented SD response */ 440 u8 sd_resp_addr[ETH_ALEN]; 441 u8 sd_resp_dialog_token; 442 size_t sd_resp_pos; /* Offset in sd_resp */ 443 u8 sd_frag_id; 444 445 struct wpabuf *sd_rx_resp; /* Reassembled SD response */ 446 u16 sd_rx_update_indic; 447 448 /* P2P Invitation data */ 449 enum p2p_invite_role inv_role; 450 u8 inv_bssid[ETH_ALEN]; 451 int inv_bssid_set; 452 u8 inv_ssid[SSID_MAX_LEN]; 453 size_t inv_ssid_len; 454 u8 inv_sa[ETH_ALEN]; 455 u8 inv_group_bssid[ETH_ALEN]; 456 u8 *inv_group_bssid_ptr; 457 u8 inv_go_dev_addr[ETH_ALEN]; 458 u8 inv_status; 459 int inv_op_freq; 460 int inv_persistent; 461 462 enum p2p_discovery_type find_type; 463 int find_specified_freq; 464 unsigned int last_p2p_find_timeout; 465 u8 last_prog_scan_class; 466 u8 last_prog_scan_chan; 467 unsigned int find_pending_full:1; 468 int p2p_scan_running; 469 enum p2p_after_scan { 470 P2P_AFTER_SCAN_NOTHING, 471 P2P_AFTER_SCAN_LISTEN, 472 P2P_AFTER_SCAN_CONNECT, 473 #ifdef CONFIG_OPEN_HARMONY_SPECIFIC_P2P_FIND 474 P2P_AFTER_SCAN_FULL_SCAN, 475 #endif 476 } start_after_scan; 477 u8 after_scan_peer[ETH_ALEN]; 478 unsigned int send_action_in_progress:1; 479 480 /* Requested device types for find/search */ 481 unsigned int num_req_dev_types; 482 u8 *req_dev_types; 483 u8 *find_dev_id; 484 u8 find_dev_id_buf[ETH_ALEN]; 485 486 struct os_reltime find_start; /* time of last p2p_find start */ 487 488 struct p2p_group **groups; 489 size_t num_groups; 490 491 struct p2p_device *pending_client_disc_go; 492 u8 pending_client_disc_addr[ETH_ALEN]; 493 u8 pending_dev_disc_dialog_token; 494 u8 pending_dev_disc_addr[ETH_ALEN]; 495 int pending_dev_disc_freq; 496 unsigned int pending_client_disc_freq; 497 498 int ext_listen_only; 499 unsigned int ext_listen_period; 500 unsigned int ext_listen_interval; 501 unsigned int ext_listen_interval_sec; 502 unsigned int ext_listen_interval_usec; 503 504 u8 peer_filter[ETH_ALEN]; 505 506 int cross_connect; 507 508 int best_freq_24; 509 int best_freq_5; 510 int best_freq_overall; 511 int own_freq_preference; 512 513 /** 514 * wps_vendor_ext - WPS Vendor Extensions to add 515 */ 516 struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; 517 518 /* 519 * user_initiated_pd - Whether a PD request is user initiated or not. 520 */ 521 u8 user_initiated_pd; 522 523 /* 524 * Keep track of which peer a given PD request was sent to. 525 * Used to raise a timeout alert in case there is no response. 526 */ 527 u8 pending_pd_devaddr[ETH_ALEN]; 528 529 /* 530 * Retry counter for provision discovery requests when issued 531 * in IDLE state. 532 */ 533 int pd_retries; 534 535 /** 536 * pd_force_freq - Forced frequency for PD retries or 0 to auto-select 537 * 538 * This is is used during PD retries for join-a-group case to use the 539 * correct operating frequency determined from a BSS entry for the GO. 540 */ 541 int pd_force_freq; 542 543 u8 go_timeout; 544 u8 client_timeout; 545 546 /* Extra delay in milliseconds between search iterations */ 547 unsigned int search_delay; 548 int in_search_delay; 549 550 u8 pending_reg_class; 551 u8 pending_channel; 552 u8 pending_channel_forced; 553 554 /* ASP Support */ 555 struct p2ps_advertisement *p2ps_adv_list; 556 struct p2ps_provision *p2ps_prov; 557 u8 wild_card_hash[P2PS_HASH_LEN]; 558 u8 p2ps_seek; 559 u8 p2ps_seek_hash[P2P_MAX_QUERY_HASH * P2PS_HASH_LEN]; 560 u8 p2ps_seek_count; 561 562 #ifdef CONFIG_WIFI_DISPLAY 563 struct wpabuf *wfd_ie_beacon; 564 struct wpabuf *wfd_ie_probe_req; 565 struct wpabuf *wfd_ie_probe_resp; 566 struct wpabuf *wfd_ie_assoc_req; 567 struct wpabuf *wfd_ie_invitation; 568 struct wpabuf *wfd_ie_prov_disc_req; 569 struct wpabuf *wfd_ie_prov_disc_resp; 570 struct wpabuf *wfd_ie_go_neg; 571 struct wpabuf *wfd_dev_info; 572 struct wpabuf *wfd_assoc_bssid; 573 struct wpabuf *wfd_coupled_sink_info; 574 struct wpabuf *wfd_r2_dev_info; 575 #endif /* CONFIG_WIFI_DISPLAY */ 576 577 u16 authorized_oob_dev_pw_id; 578 579 struct wpabuf **vendor_elem; 580 581 struct weighted_pcl pref_freq_list[P2P_MAX_PREF_CHANNELS]; 582 unsigned int num_pref_freq; 583 584 /* Override option for preferred operating channel in GO Negotiation */ 585 u8 override_pref_op_class; 586 u8 override_pref_channel; 587 #ifdef HARMONY_P2P_CONNECTIVITY_PATCH 588 /** 589 * process_go_neg_opt - go negotiation optimization flag, allow to modify intent 590 * 0 - disallow to process, 1- allow to process 591 */ 592 int process_go_neg_opt; 593 594 /** 595 * enable_go_neg_opt - enable go negotiation optimization or not 596 * 0 - disable, 1- enable 597 */ 598 int enable_go_neg_opt; 599 #endif 600 bool p2p_6ghz_capable; 601 bool include_6ghz; 602 bool allow_6ghz; 603 #ifdef CONFIG_OPEN_HARMONY_PATCH 604 u8 ltecoex_flag; 605 #ifdef CONFIG_MIRACAST_SINK_OPT 606 u8 calculated_go_intent; 607 unsigned int original_ext_listen_period; 608 u8 original_reg_class; 609 u8 original_listen_channel; 610 u8 enable_ext_listen:1; 611 u8 on_op_channel_listen:1; 612 #endif /* CONFIG_MIRACAST_SINK_OPT */ 613 #ifdef OPEN_HARMONY_MIRACAST_SINK_OPT 614 u8 invite_resp_callback_result; 615 #endif /* OPEN_HARMONY_MIRACAST_SINK_OPT */ 616 #endif /* CONFIG_OPEN_HARMONY_PATCH */ 617 #ifdef HARMONY_CONNECTIVITY_PATCH 618 int persistent_group_need_remove; 619 u8 pvt_p2p_service; 620 #endif 621 #ifdef CONFIG_OPEN_HARMONY_PATCH 622 char passphrase[MAX_PASSPHRASE_LEN + 1]; 623 int passphrase_set; 624 #endif /* CONFIG_OPEN_HARMONY_PATCH */ 625 }; 626 627 enum p2p_pvt_service { 628 P2P_NORMAL_FIND, 629 #ifdef OPEN_HARMONY_P2P_ONEHOP_FIND 630 P2P_ONEHOP_FIND 631 #endif 632 }; 633 634 /** 635 * struct p2p_message - Parsed P2P message (or P2P IE) 636 */ 637 struct p2p_message { 638 struct wpabuf *p2p_attributes; 639 struct wpabuf *wps_attributes; 640 struct wpabuf *wfd_subelems; 641 642 u8 dialog_token; 643 644 const u8 *capability; 645 const u8 *go_intent; 646 const u8 *status; 647 const u8 *listen_channel; 648 const u8 *operating_channel; 649 const u8 *channel_list; 650 u8 channel_list_len; 651 const u8 *config_timeout; 652 const u8 *intended_addr; 653 const u8 *group_bssid; 654 const u8 *invitation_flags; 655 656 const u8 *group_info; 657 size_t group_info_len; 658 659 const u8 *group_id; 660 size_t group_id_len; 661 662 const u8 *device_id; 663 664 const u8 *manageability; 665 666 const u8 *noa; 667 size_t noa_len; 668 669 const u8 *ext_listen_timing; 670 671 const u8 *minor_reason_code; 672 673 const u8 *oob_go_neg_channel; 674 675 /* P2P Device Info */ 676 const u8 *p2p_device_info; 677 size_t p2p_device_info_len; 678 const u8 *p2p_device_addr; 679 const u8 *pri_dev_type; 680 u8 num_sec_dev_types; 681 char device_name[WPS_DEV_NAME_MAX_LEN + 1]; 682 u16 config_methods; 683 684 /* WPS IE */ 685 u16 dev_password_id; 686 int dev_password_id_present; 687 u16 wps_config_methods; 688 const u8 *wps_pri_dev_type; 689 const u8 *wps_sec_dev_type_list; 690 size_t wps_sec_dev_type_list_len; 691 const u8 *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; 692 size_t wps_vendor_ext_len[P2P_MAX_WPS_VENDOR_EXT]; 693 const u8 *manufacturer; 694 size_t manufacturer_len; 695 const u8 *model_name; 696 size_t model_name_len; 697 const u8 *model_number; 698 size_t model_number_len; 699 const u8 *serial_number; 700 size_t serial_number_len; 701 const u8 *oob_dev_password; 702 size_t oob_dev_password_len; 703 704 /* DS Parameter Set IE */ 705 const u8 *ds_params; 706 707 /* SSID IE */ 708 const u8 *ssid; 709 710 /* P2PS */ 711 u8 service_hash_count; 712 const u8 *service_hash; 713 714 const u8 *session_info; 715 size_t session_info_len; 716 717 const u8 *conn_cap; 718 719 const u8 *adv_id; 720 const u8 *adv_mac; 721 722 const u8 *adv_service_instance; 723 size_t adv_service_instance_len; 724 725 const u8 *session_id; 726 const u8 *session_mac; 727 728 const u8 *feature_cap; 729 size_t feature_cap_len; 730 731 const u8 *persistent_dev; 732 const u8 *persistent_ssid; 733 size_t persistent_ssid_len; 734 735 const u8 *pref_freq_list; 736 size_t pref_freq_list_len; 737 }; 738 739 740 #define P2P_MAX_GROUP_ENTRIES 50 741 742 struct p2p_group_info { 743 unsigned int num_clients; 744 struct p2p_client_info { 745 const u8 *p2p_device_addr; 746 const u8 *p2p_interface_addr; 747 u8 dev_capab; 748 u16 config_methods; 749 const u8 *pri_dev_type; 750 u8 num_sec_dev_types; 751 const u8 *sec_dev_types; 752 const char *dev_name; 753 size_t dev_name_len; 754 } client[P2P_MAX_GROUP_ENTRIES]; 755 }; 756 757 758 /* p2p_utils.c */ 759 int p2p_random(char *buf, size_t len); 760 int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel); 761 void p2p_channels_intersect(const struct p2p_channels *a, 762 const struct p2p_channels *b, 763 struct p2p_channels *res); 764 void p2p_channels_union_inplace(struct p2p_channels *res, 765 const struct p2p_channels *b); 766 void p2p_channels_union(const struct p2p_channels *a, 767 const struct p2p_channels *b, 768 struct p2p_channels *res); 769 void p2p_channels_remove_freqs(struct p2p_channels *chan, 770 const struct wpa_freq_range_list *list); 771 int p2p_channels_includes(const struct p2p_channels *channels, u8 reg_class, 772 u8 channel); 773 void p2p_channels_dump(struct p2p_data *p2p, const char *title, 774 const struct p2p_channels *chan); 775 int p2p_channel_select(struct p2p_channels *chans, const int *classes, 776 u8 *op_class, u8 *op_channel); 777 int p2p_channel_random_social(struct p2p_channels *chans, u8 *op_class, 778 u8 *op_channel, 779 struct wpa_freq_range_list *avoid_list, 780 struct wpa_freq_range_list *disallow_list); 781 void p2p_copy_channels(struct p2p_channels *dst, const struct p2p_channels *src, 782 bool allow_6ghz); 783 784 /* p2p_parse.c */ 785 void p2p_copy_filter_devname(char *dst, size_t dst_len, 786 const void *src, size_t src_len); 787 int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg); 788 int p2p_parse_ies(const u8 *data, size_t len, struct p2p_message *msg); 789 int p2p_parse(const u8 *data, size_t len, struct p2p_message *msg); 790 int p2p_parse_ies_separate(const u8 *wsc, size_t wsc_len, const u8 *p2p, 791 size_t p2p_len, struct p2p_message *msg); 792 void p2p_parse_free(struct p2p_message *msg); 793 int p2p_attr_text(struct wpabuf *data, char *buf, char *end); 794 int p2p_group_info_parse(const u8 *gi, size_t gi_len, 795 struct p2p_group_info *info); 796 797 /* p2p_build.c */ 798 799 struct p2p_noa_desc { 800 u8 count_type; 801 u32 duration; 802 u32 interval; 803 u32 start_time; 804 }; 805 806 /* p2p_group.c */ 807 const u8 * p2p_group_get_interface_addr(struct p2p_group *group); 808 u8 p2p_group_presence_req(struct p2p_group *group, 809 const u8 *client_interface_addr, 810 const u8 *noa, size_t noa_len); 811 int p2p_group_is_group_id_match(struct p2p_group *group, const u8 *group_id, 812 size_t group_id_len); 813 void p2p_group_update_ies(struct p2p_group *group); 814 void p2p_group_force_beacon_update_ies(struct p2p_group *group); 815 struct wpabuf * p2p_group_get_wfd_ie(struct p2p_group *g); 816 void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf, 817 int max_clients); 818 void p2p_group_buf_add_id(struct p2p_group *group, struct wpabuf *buf); 819 int p2p_group_get_freq(struct p2p_group *group); 820 821 822 void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token); 823 void p2p_buf_add_public_action_hdr(struct wpabuf *buf, u8 subtype, 824 u8 dialog_token); 825 u8 * p2p_buf_add_ie_hdr(struct wpabuf *buf); 826 void p2p_buf_add_status(struct wpabuf *buf, u8 status); 827 void p2p_buf_add_device_info(struct wpabuf *buf, struct p2p_data *p2p, 828 struct p2p_device *peer); 829 void p2p_buf_add_device_id(struct wpabuf *buf, const u8 *dev_addr); 830 void p2p_buf_update_ie_hdr(struct wpabuf *buf, u8 *len); 831 void p2p_buf_add_capability(struct wpabuf *buf, u8 dev_capab, u8 group_capab); 832 void p2p_buf_add_go_intent(struct wpabuf *buf, u8 go_intent); 833 void p2p_buf_add_listen_channel(struct wpabuf *buf, const char *country, 834 u8 reg_class, u8 channel); 835 void p2p_buf_add_operating_channel(struct wpabuf *buf, const char *country, 836 u8 reg_class, u8 channel); 837 void p2p_buf_add_channel_list(struct wpabuf *buf, const char *country, 838 struct p2p_channels *chan, bool is_6ghz_capab); 839 void p2p_buf_add_config_timeout(struct wpabuf *buf, u8 go_timeout, 840 u8 client_timeout); 841 void p2p_buf_add_intended_addr(struct wpabuf *buf, const u8 *interface_addr); 842 void p2p_buf_add_group_bssid(struct wpabuf *buf, const u8 *bssid); 843 void p2p_buf_add_group_id(struct wpabuf *buf, const u8 *dev_addr, 844 const u8 *ssid, size_t ssid_len); 845 void p2p_buf_add_invitation_flags(struct wpabuf *buf, u8 flags); 846 void p2p_buf_add_noa(struct wpabuf *buf, u8 noa_index, u8 opp_ps, u8 ctwindow, 847 struct p2p_noa_desc *desc1, struct p2p_noa_desc *desc2); 848 void p2p_buf_add_ext_listen_timing(struct wpabuf *buf, u16 period, 849 u16 interval); 850 void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p); 851 void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country, 852 u8 oper_class, u8 channel, 853 enum p2p_role_indication role); 854 void p2p_buf_add_service_hash(struct wpabuf *buf, struct p2p_data *p2p); 855 void p2p_buf_add_session_info(struct wpabuf *buf, const char *info); 856 void p2p_buf_add_connection_capability(struct wpabuf *buf, u8 connection_cap); 857 void p2p_buf_add_advertisement_id(struct wpabuf *buf, u32 id, const u8 *mac); 858 void p2p_buf_add_service_instance(struct wpabuf *buf, struct p2p_data *p2p, 859 u8 count, const u8 *hash, 860 struct p2ps_advertisement *adv_list); 861 void p2p_buf_add_session_id(struct wpabuf *buf, u32 id, const u8 *mac); 862 void p2p_buf_add_feature_capability(struct wpabuf *buf, u16 len, 863 const u8 *mask); 864 void p2p_buf_add_persistent_group_info(struct wpabuf *buf, const u8 *dev_addr, 865 const u8 *ssid, size_t ssid_len); 866 int p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id, 867 int all_attr); 868 void p2p_buf_add_pref_channel_list(struct wpabuf *buf, 869 const struct weighted_pcl *pref_freq_list, 870 unsigned int size); 871 872 /* p2p_sd.c */ 873 struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p, 874 struct p2p_device *dev); 875 void p2p_free_sd_queries(struct p2p_data *p2p); 876 void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa, 877 const u8 *data, size_t len, int rx_freq); 878 void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa, 879 const u8 *data, size_t len, int rx_freq); 880 void p2p_rx_gas_comeback_req(struct p2p_data *p2p, const u8 *sa, 881 const u8 *data, size_t len, int rx_freq); 882 void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa, 883 const u8 *data, size_t len, int rx_freq); 884 int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev); 885 886 /* p2p_go_neg.c */ 887 int p2p_peer_channels_check(struct p2p_data *p2p, struct p2p_channels *own, 888 struct p2p_device *dev, 889 const u8 *channel_list, size_t channel_list_len); 890 void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa, 891 const u8 *data, size_t len, int rx_freq); 892 void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, 893 const u8 *data, size_t len, int rx_freq); 894 void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa, 895 const u8 *data, size_t len); 896 int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev); 897 u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method); 898 void p2p_reselect_channel(struct p2p_data *p2p, 899 struct p2p_channels *intersection); 900 void p2p_check_pref_chan(struct p2p_data *p2p, int go, 901 struct p2p_device *dev, struct p2p_message *msg); 902 903 /* p2p_pd.c */ 904 void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa, 905 const u8 *data, size_t len, int rx_freq); 906 void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa, 907 const u8 *data, size_t len); 908 int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev, 909 int join, int force_freq); 910 void p2p_reset_pending_pd(struct p2p_data *p2p); 911 void p2ps_prov_free(struct p2p_data *p2p); 912 913 /* p2p_invitation.c */ 914 void p2p_process_invitation_req(struct p2p_data *p2p, const u8 *sa, 915 const u8 *data, size_t len, int rx_freq); 916 void p2p_process_invitation_resp(struct p2p_data *p2p, const u8 *sa, 917 const u8 *data, size_t len); 918 int p2p_invite_send(struct p2p_data *p2p, struct p2p_device *dev, 919 const u8 *go_dev_addr, int dev_pw_id); 920 void p2p_invitation_req_cb(struct p2p_data *p2p, int success); 921 void p2p_invitation_resp_cb(struct p2p_data *p2p, int success); 922 923 /* p2p_dev_disc.c */ 924 void p2p_process_dev_disc_req(struct p2p_data *p2p, const u8 *sa, 925 const u8 *data, size_t len, int rx_freq); 926 void p2p_dev_disc_req_cb(struct p2p_data *p2p, int success); 927 int p2p_send_dev_disc_req(struct p2p_data *p2p, struct p2p_device *dev); 928 void p2p_dev_disc_resp_cb(struct p2p_data *p2p, int success); 929 void p2p_process_dev_disc_resp(struct p2p_data *p2p, const u8 *sa, 930 const u8 *data, size_t len); 931 void p2p_go_disc_req_cb(struct p2p_data *p2p, int success); 932 void p2p_process_go_disc_req(struct p2p_data *p2p, const u8 *da, const u8 *sa, 933 const u8 *data, size_t len, int rx_freq); 934 935 /* p2p.c */ 936 void p2p_set_state(struct p2p_data *p2p, int new_state); 937 void p2p_set_timeout(struct p2p_data *p2p, unsigned int sec, 938 unsigned int usec); 939 void p2p_clear_timeout(struct p2p_data *p2p); 940 void p2p_continue_find(struct p2p_data *p2p); 941 struct p2p_device * p2p_add_dev_from_go_neg_req(struct p2p_data *p2p, 942 const u8 *addr, 943 struct p2p_message *msg); 944 void p2p_update_peer_6ghz_capab(struct p2p_device *dev, 945 const struct p2p_message *msg); 946 void p2p_add_dev_info(struct p2p_data *p2p, const u8 *addr, 947 struct p2p_device *dev, struct p2p_message *msg); 948 int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, 949 struct os_reltime *rx_time, int level, const u8 *ies, 950 size_t ies_len, int scan_res); 951 struct p2p_device * p2p_get_device(struct p2p_data *p2p, const u8 *addr); 952 struct p2p_device * p2p_get_device_interface(struct p2p_data *p2p, 953 const u8 *addr); 954 void p2p_go_neg_failed(struct p2p_data *p2p, int status); 955 void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer); 956 int p2p_match_dev_type(struct p2p_data *p2p, struct wpabuf *wps); 957 int dev_type_list_match(const u8 *dev_type, const u8 *req_dev_type[], 958 size_t num_req_dev_type); 959 struct wpabuf * p2p_build_probe_resp_ies(struct p2p_data *p2p, 960 const u8 *query_hash, 961 u8 query_count); 962 void p2p_build_ssid(struct p2p_data *p2p, u8 *ssid, size_t *ssid_len); 963 int p2p_send_action(struct p2p_data *p2p, unsigned int freq, const u8 *dst, 964 const u8 *src, const u8 *bssid, const u8 *buf, 965 size_t len, unsigned int wait_time); 966 void p2p_stop_listen_for_freq(struct p2p_data *p2p, int freq); 967 int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev, 968 unsigned int force_freq, unsigned int pref_freq, 969 int go); 970 void p2p_go_neg_wait_timeout(void *eloop_ctx, void *timeout_ctx); 971 int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev, 972 u8 *status); 973 void p2p_pref_channel_filter(const struct p2p_channels *a, 974 const struct weighted_pcl *freq_list, 975 unsigned int num_channels, 976 struct p2p_channels *res, bool go); 977 978 void p2p_sd_query_cb(struct p2p_data *p2p, int success); 979 980 void p2p_dbg(struct p2p_data *p2p, const char *fmt, ...) 981 PRINTF_FORMAT(2, 3); 982 void p2p_info(struct p2p_data *p2p, const char *fmt, ...) 983 PRINTF_FORMAT(2, 3); 984 void p2p_err(struct p2p_data *p2p, const char *fmt, ...) 985 PRINTF_FORMAT(2, 3); 986 void p2p_warning(struct p2p_data *p2p, const char *fmt, ...) 987 PRINTF_FORMAT(2, 3); 988 #endif /* P2P_I_H */ 989