1 /* 2 * Wi-Fi Direct - 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_H 10 #define P2P_H 11 12 #include "common/ieee802_11_defs.h" 13 #include "wps/wps.h" 14 15 struct weighted_pcl; 16 17 /* P2P ASP Setup Capability */ 18 #define P2PS_SETUP_NONE 0 19 #define P2PS_SETUP_NEW BIT(0) 20 #define P2PS_SETUP_CLIENT BIT(1) 21 #define P2PS_SETUP_GROUP_OWNER BIT(2) 22 23 #define P2PS_WILD_HASH_STR "org.wi-fi.wfds" 24 #define P2PS_HASH_LEN 6 25 #define P2P_MAX_QUERY_HASH 6 26 #define P2PS_FEATURE_CAPAB_CPT_MAX 2 27 28 /** 29 * P2P_MAX_PREF_CHANNELS - Maximum number of preferred channels 30 */ 31 #define P2P_MAX_PREF_CHANNELS 100 32 33 /** 34 * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes 35 */ 36 #define P2P_MAX_REG_CLASSES 15 37 38 /** 39 * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class 40 */ 41 #define P2P_MAX_REG_CLASS_CHANNELS 60 42 43 #ifdef HARMONY_P2P_CONNECTIVITY_PATCH 44 /** 45 * P2P_GO_NEG_OPT_INTENT - p2p go negotiation optimization intent value 46 */ 47 #define P2P_GO_NEG_OPT_INTENT 14 48 #endif 49 50 /** 51 * struct p2p_channels - List of supported channels 52 */ 53 struct p2p_channels { 54 /** 55 * struct p2p_reg_class - Supported regulatory class 56 */ 57 struct p2p_reg_class { 58 /** 59 * reg_class - Regulatory class (IEEE 802.11-2007, Annex J) 60 */ 61 u8 reg_class; 62 63 /** 64 * channel - Supported channels 65 */ 66 u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; 67 68 /** 69 * channels - Number of channel entries in use 70 */ 71 size_t channels; 72 } reg_class[P2P_MAX_REG_CLASSES]; 73 74 /** 75 * reg_classes - Number of reg_class entries in use 76 */ 77 size_t reg_classes; 78 }; 79 80 enum p2p_wps_method { 81 WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC, 82 WPS_P2PS 83 }; 84 85 /** 86 * struct p2p_go_neg_results - P2P Group Owner Negotiation results 87 */ 88 struct p2p_go_neg_results { 89 /** 90 * status - Negotiation result (Status Code) 91 * 92 * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate 93 * failed negotiation. 94 */ 95 int status; 96 97 /** 98 * role_go - Whether local end is Group Owner 99 */ 100 int role_go; 101 102 /** 103 * freq - Frequency of the group operational channel in MHz 104 */ 105 int freq; 106 107 int ht40; 108 109 int vht; 110 111 int edmg; 112 113 u8 max_oper_chwidth; 114 115 unsigned int vht_center_freq2; 116 117 /** 118 * he - Indicates if IEEE 802.11ax HE is enabled 119 */ 120 int he; 121 122 /** 123 * ssid - SSID of the group 124 */ 125 u8 ssid[SSID_MAX_LEN]; 126 127 /** 128 * ssid_len - Length of SSID in octets 129 */ 130 size_t ssid_len; 131 132 /** 133 * psk - WPA pre-shared key (256 bits) (GO only) 134 */ 135 u8 psk[32]; 136 137 /** 138 * psk_set - Whether PSK field is configured (GO only) 139 */ 140 int psk_set; 141 142 /** 143 * passphrase - WPA2-Personal passphrase for the group (GO only) 144 */ 145 char passphrase[64]; 146 147 /** 148 * peer_device_addr - P2P Device Address of the peer 149 */ 150 u8 peer_device_addr[ETH_ALEN]; 151 152 /** 153 * peer_interface_addr - P2P Interface Address of the peer 154 */ 155 u8 peer_interface_addr[ETH_ALEN]; 156 157 /** 158 * wps_method - WPS method to be used during provisioning 159 */ 160 enum p2p_wps_method wps_method; 161 162 #define P2P_MAX_CHANNELS 50 163 164 /** 165 * freq_list - Zero-terminated list of possible operational channels 166 */ 167 int freq_list[P2P_MAX_CHANNELS]; 168 169 /** 170 * persistent_group - Whether the group should be made persistent 171 * 0 = not persistent 172 * 1 = persistent group without persistent reconnect 173 * 2 = persistent group with persistent reconnect 174 */ 175 int persistent_group; 176 177 /** 178 * peer_config_timeout - Peer configuration timeout (in 10 msec units) 179 */ 180 unsigned int peer_config_timeout; 181 }; 182 183 struct p2ps_provision { 184 /** 185 * pd_seeker - P2PS provision discovery seeker role 186 */ 187 unsigned int pd_seeker:1; 188 189 /** 190 * status - Remote returned provisioning status code 191 */ 192 int status; 193 194 /** 195 * adv_id - P2PS Advertisement ID 196 */ 197 u32 adv_id; 198 199 /** 200 * session_id - P2PS Session ID 201 */ 202 u32 session_id; 203 204 /** 205 * method - WPS Method (to be) used to establish session 206 */ 207 u16 method; 208 209 /** 210 * conncap - Connection Capabilities negotiated between P2P peers 211 */ 212 u8 conncap; 213 214 /** 215 * role - Info about the roles to be used for this connection 216 */ 217 u8 role; 218 219 /** 220 * session_mac - MAC address of the peer that started the session 221 */ 222 u8 session_mac[ETH_ALEN]; 223 224 /** 225 * adv_mac - MAC address of the peer advertised the service 226 */ 227 u8 adv_mac[ETH_ALEN]; 228 229 /** 230 * cpt_mask - Supported Coordination Protocol Transport mask 231 * 232 * A bitwise mask of supported ASP Coordination Protocol Transports. 233 * This property is set together and corresponds with cpt_priority. 234 */ 235 u8 cpt_mask; 236 237 /** 238 * cpt_priority - Coordination Protocol Transport priority list 239 * 240 * Priorities of supported ASP Coordination Protocol Transports. 241 * This property is set together and corresponds with cpt_mask. 242 * The CPT priority list is 0 terminated. 243 */ 244 u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; 245 246 /** 247 * force_freq - The only allowed channel frequency in MHz or 0. 248 */ 249 unsigned int force_freq; 250 251 /** 252 * pref_freq - Preferred operating frequency in MHz or 0. 253 */ 254 unsigned int pref_freq; 255 256 /** 257 * info - Vendor defined extra Provisioning information 258 */ 259 char info[0]; 260 }; 261 262 struct p2ps_advertisement { 263 struct p2ps_advertisement *next; 264 265 /** 266 * svc_info - Pointer to (internal) Service defined information 267 */ 268 char *svc_info; 269 270 /** 271 * id - P2PS Advertisement ID 272 */ 273 u32 id; 274 275 /** 276 * config_methods - WPS Methods which are allowed for this service 277 */ 278 u16 config_methods; 279 280 /** 281 * state - Current state of the service: 0 - Out Of Service, 1-255 Vendor defined 282 */ 283 u8 state; 284 285 /** 286 * auto_accept - Automatically Accept provisioning request if possible. 287 */ 288 u8 auto_accept; 289 290 /** 291 * hash - 6 octet Service Name has to match against incoming Probe Requests 292 */ 293 u8 hash[P2PS_HASH_LEN]; 294 295 /** 296 * cpt_mask - supported Coordination Protocol Transport mask 297 * 298 * A bitwise mask of supported ASP Coordination Protocol Transports. 299 * This property is set together and corresponds with cpt_priority. 300 */ 301 u8 cpt_mask; 302 303 /** 304 * cpt_priority - Coordination Protocol Transport priority list 305 * 306 * Priorities of supported ASP Coordinatin Protocol Transports. 307 * This property is set together and corresponds with cpt_mask. 308 * The CPT priority list is 0 terminated. 309 */ 310 u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; 311 312 /** 313 * svc_name - NULL Terminated UTF-8 Service Name, and svc_info storage 314 */ 315 char svc_name[0]; 316 }; 317 318 319 struct p2p_data; 320 321 enum p2p_scan_type { 322 P2P_SCAN_SOCIAL, 323 P2P_SCAN_FULL, 324 P2P_SCAN_SPECIFIC, 325 P2P_SCAN_SOCIAL_PLUS_ONE, 326 #ifdef OPEN_HARMONY_P2P_ONEHOP_FIND 327 P2P_SCAN_POSSIBLE_CHANNEL 328 #endif 329 }; 330 331 enum CmdType { 332 GET = 1, 333 SET = 2 334 }; 335 336 enum DataType { 337 P2P_RANDOM_MAC_TYPE = 1, 338 SET_ONENINE_SCAN_STATE = 4, 339 }; 340 341 #define P2P_MAX_WPS_VENDOR_EXT 10 342 343 /** 344 * struct p2p_peer_info - P2P peer information 345 */ 346 struct p2p_peer_info { 347 /** 348 * p2p_device_addr - P2P Device Address of the peer 349 */ 350 u8 p2p_device_addr[ETH_ALEN]; 351 352 /** 353 * pri_dev_type - Primary Device Type 354 */ 355 u8 pri_dev_type[8]; 356 357 /** 358 * device_name - Device Name (0..32 octets encoded in UTF-8) 359 */ 360 char device_name[WPS_DEV_NAME_MAX_LEN + 1]; 361 362 /** 363 * manufacturer - Manufacturer (0..64 octets encoded in UTF-8) 364 */ 365 char manufacturer[WPS_MANUFACTURER_MAX_LEN + 1]; 366 367 /** 368 * model_name - Model Name (0..32 octets encoded in UTF-8) 369 */ 370 char model_name[WPS_MODEL_NAME_MAX_LEN + 1]; 371 372 /** 373 * model_number - Model Number (0..32 octets encoded in UTF-8) 374 */ 375 char model_number[WPS_MODEL_NUMBER_MAX_LEN + 1]; 376 377 /** 378 * serial_number - Serial Number (0..32 octets encoded in UTF-8) 379 */ 380 char serial_number[WPS_SERIAL_NUMBER_MAX_LEN + 1]; 381 382 /** 383 * level - Signal level 384 */ 385 int level; 386 387 /** 388 * config_methods - WPS Configuration Methods 389 */ 390 u16 config_methods; 391 392 /** 393 * dev_capab - Device Capabilities 394 */ 395 u8 dev_capab; 396 397 /** 398 * group_capab - Group Capabilities 399 */ 400 u8 group_capab; 401 402 /** 403 * wps_sec_dev_type_list - WPS secondary device type list 404 * 405 * This list includes from 0 to 16 Secondary Device Types as indicated 406 * by wps_sec_dev_type_list_len (8 * number of types). 407 */ 408 u8 wps_sec_dev_type_list[WPS_SEC_DEV_TYPE_MAX_LEN]; 409 410 /** 411 * wps_sec_dev_type_list_len - Length of secondary device type list 412 */ 413 size_t wps_sec_dev_type_list_len; 414 415 struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; 416 417 /** 418 * wfd_subelems - Wi-Fi Display subelements from WFD IE(s) 419 */ 420 struct wpabuf *wfd_subelems; 421 422 /** 423 * vendor_elems - Unrecognized vendor elements 424 * 425 * This buffer includes any other vendor element than P2P, WPS, and WFD 426 * IE(s) from the frame that was used to discover the peer. 427 */ 428 struct wpabuf *vendor_elems; 429 430 /** 431 * p2ps_instance - P2PS Application Service Info 432 */ 433 struct wpabuf *p2ps_instance; 434 }; 435 436 enum p2p_prov_disc_status { 437 P2P_PROV_DISC_SUCCESS, 438 P2P_PROV_DISC_TIMEOUT, 439 P2P_PROV_DISC_REJECTED, 440 P2P_PROV_DISC_TIMEOUT_JOIN, 441 P2P_PROV_DISC_INFO_UNAVAILABLE, 442 }; 443 444 struct p2p_channel { 445 u8 op_class; 446 u8 chan; 447 }; 448 449 /** 450 * struct p2p_config - P2P configuration 451 * 452 * This configuration is provided to the P2P module during initialization with 453 * p2p_init(). 454 */ 455 struct p2p_config { 456 /** 457 * country - Country code to use in P2P operations 458 */ 459 char country[3]; 460 461 /** 462 * reg_class - Regulatory class for own listen channel 463 */ 464 u8 reg_class; 465 466 /** 467 * channel - Own listen channel 468 */ 469 u8 channel; 470 471 /** 472 * channel_forced - the listen channel was forced by configuration 473 * or by control interface and cannot be overridden 474 */ 475 u8 channel_forced; 476 477 /** 478 * Regulatory class for own operational channel 479 */ 480 u8 op_reg_class; 481 482 /** 483 * op_channel - Own operational channel 484 */ 485 u8 op_channel; 486 487 /** 488 * cfg_op_channel - Whether op_channel is hardcoded in configuration 489 */ 490 u8 cfg_op_channel; 491 492 /** 493 * channels - Own supported regulatory classes and channels 494 * 495 * List of supposerted channels per regulatory class. The regulatory 496 * classes are defined in IEEE Std 802.11-2007 Annex J and the 497 * numbering of the clases depends on the configured country code. 498 */ 499 struct p2p_channels channels; 500 501 /** 502 * cli_channels - Additional client channels 503 * 504 * This list of channels (if any) will be used when advertising local 505 * channels during GO Negotiation or Invitation for the cases where the 506 * local end may become the client. This may allow the peer to become a 507 * GO on additional channels if it supports these options. The main use 508 * case for this is to include passive-scan channels on devices that may 509 * not know their current location and have configured most channels to 510 * not allow initiation of radition (i.e., another device needs to take 511 * master responsibilities). 512 */ 513 struct p2p_channels cli_channels; 514 515 /** 516 * num_pref_chan - Number of pref_chan entries 517 */ 518 unsigned int num_pref_chan; 519 520 /** 521 * pref_chan - Preferred channels for GO Negotiation 522 */ 523 struct p2p_channel *pref_chan; 524 525 /** 526 * p2p_6ghz_disable - Disable 6GHz for P2P operations 527 */ 528 bool p2p_6ghz_disable; 529 530 /** 531 * pri_dev_type - Primary Device Type (see WPS) 532 */ 533 u8 pri_dev_type[8]; 534 535 /** 536 * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types 537 */ 538 #define P2P_SEC_DEVICE_TYPES 5 539 540 /** 541 * sec_dev_type - Optional secondary device types 542 */ 543 u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8]; 544 545 /** 546 * num_sec_dev_types - Number of sec_dev_type entries 547 */ 548 size_t num_sec_dev_types; 549 550 /** 551 * dev_addr - P2P Device Address 552 */ 553 u8 dev_addr[ETH_ALEN]; 554 555 /** 556 * dev_name - Device Name 557 */ 558 char *dev_name; 559 560 char *manufacturer; 561 char *model_name; 562 char *model_number; 563 char *serial_number; 564 565 u8 uuid[16]; 566 u16 config_methods; 567 568 /** 569 * concurrent_operations - Whether concurrent operations are supported 570 */ 571 int concurrent_operations; 572 573 /** 574 * max_peers - Maximum number of discovered peers to remember 575 * 576 * If more peers are discovered, older entries will be removed to make 577 * room for the new ones. 578 */ 579 size_t max_peers; 580 581 /** 582 * p2p_intra_bss - Intra BSS communication is supported 583 */ 584 int p2p_intra_bss; 585 586 /** 587 * ssid_postfix - Postfix data to add to the SSID 588 * 589 * This data will be added to the end of the SSID after the 590 * DIRECT-<random two octets> prefix. 591 */ 592 u8 ssid_postfix[SSID_MAX_LEN - 9]; 593 594 /** 595 * ssid_postfix_len - Length of the ssid_postfix data 596 */ 597 size_t ssid_postfix_len; 598 599 /** 600 * max_listen - Maximum listen duration in ms 601 */ 602 unsigned int max_listen; 603 604 /** 605 * passphrase_len - Passphrase length (8..63) 606 * 607 * This parameter controls the length of the random passphrase that is 608 * generated at the GO. 609 */ 610 unsigned int passphrase_len; 611 612 /** 613 * cb_ctx - Context to use with callback functions 614 */ 615 void *cb_ctx; 616 617 /** 618 * debug_print - Debug print 619 * @ctx: Callback context from cb_ctx 620 * @level: Debug verbosity level (MSG_*) 621 * @msg: Debug message 622 */ 623 void (*debug_print)(void *ctx, int level, const char *msg); 624 625 626 /* Callbacks to request lower layer driver operations */ 627 628 /** 629 * p2p_scan - Request a P2P scan/search 630 * @ctx: Callback context from cb_ctx 631 * @type: Scan type 632 * @freq: Specific frequency (MHz) to scan or 0 for no restriction 633 * @num_req_dev_types: Number of requested device types 634 * @req_dev_types: Array containing requested device types 635 * @dev_id: Device ID to search for or %NULL to find all devices 636 * @pw_id: Device Password ID 637 * @include_6ghz: Include 6 GHz channels in P2P scan 638 * Returns: 0 on success, -1 on failure 639 * 640 * This callback function is used to request a P2P scan or search 641 * operation to be completed. Type type argument specifies which type 642 * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the 643 * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL 644 * indicates that all channels are to be scanned. @P2P_SCAN_SPECIFIC 645 * request a scan of a single channel specified by freq. 646 * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels 647 * plus one extra channel specified by freq. 648 * 649 * The full scan is used for the initial scan to find group owners from 650 * all. The other types are used during search phase scan of the social 651 * channels (with potential variation if the Listen channel of the 652 * target peer is known or if other channels are scanned in steps). 653 * 654 * The scan results are returned after this call by calling 655 * p2p_scan_res_handler() for each scan result that has a P2P IE and 656 * then calling p2p_scan_res_handled() to indicate that all scan 657 * results have been indicated. 658 */ 659 int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq, 660 unsigned int num_req_dev_types, 661 const u8 *req_dev_types, const u8 *dev_id, u16 pw_id, 662 bool include_6ghz); 663 664 /** 665 * send_probe_resp - Transmit a Probe Response frame 666 * @ctx: Callback context from cb_ctx 667 * @buf: Probe Response frame (including the header and body) 668 * @freq: Forced frequency (in MHz) to use or 0. 669 * Returns: 0 on success, -1 on failure 670 * 671 * This function is used to reply to Probe Request frames that were 672 * indicated with a call to p2p_probe_req_rx(). The response is to be 673 * sent on the same channel, unless otherwise specified, or to be 674 * dropped if the driver is not listening to Probe Request frames 675 * anymore. 676 * 677 * Alternatively, the responsibility for building the Probe Response 678 * frames in Listen state may be in another system component in which 679 * case this function need to be implemented (i.e., the function 680 * pointer can be %NULL). The WPS and P2P IEs to be added for Probe 681 * Response frames in such a case are available from the 682 * start_listen() callback. It should be noted that the received Probe 683 * Request frames must be indicated by calling p2p_probe_req_rx() even 684 * if this send_probe_resp() is not used. 685 */ 686 int (*send_probe_resp)(void *ctx, const struct wpabuf *buf, 687 unsigned int freq); 688 689 /** 690 * send_action - Transmit an Action frame 691 * @ctx: Callback context from cb_ctx 692 * @freq: Frequency in MHz for the channel on which to transmit 693 * @dst: Destination MAC address (Address 1) 694 * @src: Source MAC address (Address 2) 695 * @bssid: BSSID (Address 3) 696 * @buf: Frame body (starting from Category field) 697 * @len: Length of buf in octets 698 * @wait_time: How many msec to wait for a response frame 699 * @scheduled: Return value indicating whether the transmissions was 700 * scheduled to happen once the radio is available 701 * Returns: 0 on success, -1 on failure 702 * 703 * The Action frame may not be transmitted immediately and the status 704 * of the transmission must be reported by calling 705 * p2p_send_action_cb() once the frame has either been transmitted or 706 * it has been dropped due to excessive retries or other failure to 707 * transmit. 708 */ 709 int (*send_action)(void *ctx, unsigned int freq, const u8 *dst, 710 const u8 *src, const u8 *bssid, const u8 *buf, 711 size_t len, unsigned int wait_time, int *scheduled); 712 713 /** 714 * send_action_done - Notify that Action frame sequence was completed 715 * @ctx: Callback context from cb_ctx 716 * 717 * This function is called when the Action frame sequence that was 718 * started with send_action() has been completed, i.e., when there is 719 * no need to wait for a response from the destination peer anymore. 720 */ 721 void (*send_action_done)(void *ctx); 722 723 /** 724 * start_listen - Start Listen state 725 * @ctx: Callback context from cb_ctx 726 * @freq: Frequency of the listen channel in MHz 727 * @duration: Duration for the Listen state in milliseconds 728 * @probe_resp_ie: IE(s) to be added to Probe Response frames 729 * Returns: 0 on success, -1 on failure 730 * 731 * This Listen state may not start immediately since the driver may 732 * have other pending operations to complete first. Once the Listen 733 * state has started, p2p_listen_cb() must be called to notify the P2P 734 * module. Once the Listen state is stopped, p2p_listen_end() must be 735 * called to notify the P2P module that the driver is not in the Listen 736 * state anymore. 737 * 738 * If the send_probe_resp() is not used for generating the response, 739 * the IEs from probe_resp_ie need to be added to the end of the Probe 740 * Response frame body. If send_probe_resp() is used, the probe_resp_ie 741 * information can be ignored. 742 */ 743 int (*start_listen)(void *ctx, unsigned int freq, 744 unsigned int duration, 745 const struct wpabuf *probe_resp_ie); 746 /** 747 * stop_listen - Stop Listen state 748 * @ctx: Callback context from cb_ctx 749 * 750 * This callback can be used to stop a Listen state operation that was 751 * previously requested with start_listen(). 752 */ 753 void (*stop_listen)(void *ctx); 754 755 /** 756 * get_noa - Get current Notice of Absence attribute payload 757 * @ctx: Callback context from cb_ctx 758 * @interface_addr: P2P Interface Address of the GO 759 * @buf: Buffer for returning NoA 760 * @buf_len: Buffer length in octets 761 * Returns: Number of octets used in buf, 0 to indicate no NoA is being 762 * advertized, or -1 on failure 763 * 764 * This function is used to fetch the current Notice of Absence 765 * attribute value from GO. 766 */ 767 int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf, 768 size_t buf_len); 769 770 /* Callbacks to notify events to upper layer management entity */ 771 772 /** 773 * dev_found - Notification of a found P2P Device 774 * @ctx: Callback context from cb_ctx 775 * @addr: Source address of the message triggering this notification 776 * @info: P2P peer information 777 * @new_device: Inform if the peer is newly found 778 * 779 * This callback is used to notify that a new P2P Device has been 780 * found. This may happen, e.g., during Search state based on scan 781 * results or during Listen state based on receive Probe Request and 782 * Group Owner Negotiation Request. 783 */ 784 void (*dev_found)(void *ctx, const u8 *addr, 785 const struct p2p_peer_info *info, 786 int new_device); 787 788 /** 789 * dev_lost - Notification of a lost P2P Device 790 * @ctx: Callback context from cb_ctx 791 * @dev_addr: P2P Device Address of the lost P2P Device 792 * 793 * This callback is used to notify that a P2P Device has been deleted. 794 */ 795 void (*dev_lost)(void *ctx, const u8 *dev_addr); 796 797 /** 798 * find_stopped - Notification of a p2p_find operation stopping 799 * @ctx: Callback context from cb_ctx 800 */ 801 void (*find_stopped)(void *ctx); 802 803 /** 804 * go_neg_req_rx - Notification of a receive GO Negotiation Request 805 * @ctx: Callback context from cb_ctx 806 * @src: Source address of the message triggering this notification 807 * @dev_passwd_id: WPS Device Password ID 808 * @go_intent: Peer's GO Intent 809 * 810 * This callback is used to notify that a P2P Device is requesting 811 * group owner negotiation with us, but we do not have all the 812 * necessary information to start GO Negotiation. This indicates that 813 * the local user has not authorized the connection yet by providing a 814 * PIN or PBC button press. This information can be provided with a 815 * call to p2p_connect(). 816 */ 817 void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id, 818 u8 go_intent); 819 820 /** 821 * go_neg_completed - Notification of GO Negotiation results 822 * @ctx: Callback context from cb_ctx 823 * @res: GO Negotiation results 824 * 825 * This callback is used to notify that Group Owner Negotiation has 826 * been completed. Non-zero struct p2p_go_neg_results::status indicates 827 * failed negotiation. In case of success, this function is responsible 828 * for creating a new group interface (or using the existing interface 829 * depending on driver features), setting up the group interface in 830 * proper mode based on struct p2p_go_neg_results::role_go and 831 * initializing WPS provisioning either as a Registrar (if GO) or as an 832 * Enrollee. Successful WPS provisioning must be indicated by calling 833 * p2p_wps_success_cb(). The callee is responsible for timing out group 834 * formation if WPS provisioning cannot be completed successfully 835 * within 15 seconds. 836 */ 837 void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res); 838 839 /** 840 * sd_request - Callback on Service Discovery Request 841 * @ctx: Callback context from cb_ctx 842 * @freq: Frequency (in MHz) of the channel 843 * @sa: Source address of the request 844 * @dialog_token: Dialog token 845 * @update_indic: Service Update Indicator from the source of request 846 * @tlvs: P2P Service Request TLV(s) 847 * @tlvs_len: Length of tlvs buffer in octets 848 * 849 * This callback is used to indicate reception of a service discovery 850 * request. Response to the query must be indicated by calling 851 * p2p_sd_response() with the context information from the arguments to 852 * this callback function. 853 * 854 * This callback handler can be set to %NULL to indicate that service 855 * discovery is not supported. 856 */ 857 void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token, 858 u16 update_indic, const u8 *tlvs, size_t tlvs_len); 859 860 /** 861 * sd_response - Callback on Service Discovery Response 862 * @ctx: Callback context from cb_ctx 863 * @sa: Source address of the request 864 * @update_indic: Service Update Indicator from the source of response 865 * @tlvs: P2P Service Response TLV(s) 866 * @tlvs_len: Length of tlvs buffer in octets 867 * 868 * This callback is used to indicate reception of a service discovery 869 * response. This callback handler can be set to %NULL if no service 870 * discovery requests are used. The information provided with this call 871 * is replies to the queries scheduled with p2p_sd_request(). 872 */ 873 void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic, 874 const u8 *tlvs, size_t tlvs_len); 875 876 /** 877 * prov_disc_req - Callback on Provisiong Discovery Request 878 * @ctx: Callback context from cb_ctx 879 * @peer: Source address of the request 880 * @config_methods: Requested WPS Config Method 881 * @dev_addr: P2P Device Address of the found P2P Device 882 * @pri_dev_type: Primary Device Type 883 * @dev_name: Device Name 884 * @supp_config_methods: Supported configuration Methods 885 * @dev_capab: Device Capabilities 886 * @group_capab: Group Capabilities 887 * @group_id: P2P Group ID (or %NULL if not included) 888 * @group_id_len: Length of P2P Group ID 889 * 890 * This callback is used to indicate reception of a Provision Discovery 891 * Request frame that the P2P module accepted. 892 */ 893 void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods, 894 const u8 *dev_addr, const u8 *pri_dev_type, 895 const char *dev_name, u16 supp_config_methods, 896 u8 dev_capab, u8 group_capab, 897 const u8 *group_id, size_t group_id_len); 898 899 /** 900 * prov_disc_resp - Callback on Provisiong Discovery Response 901 * @ctx: Callback context from cb_ctx 902 * @peer: Source address of the response 903 * @config_methods: Value from p2p_prov_disc_req() or 0 on failure 904 * 905 * This callback is used to indicate reception of a Provision Discovery 906 * Response frame for a pending request scheduled with 907 * p2p_prov_disc_req(). This callback handler can be set to %NULL if 908 * provision discovery is not used. 909 */ 910 void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods); 911 912 /** 913 * prov_disc_fail - Callback on Provision Discovery failure 914 * @ctx: Callback context from cb_ctx 915 * @peer: Source address of the response 916 * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS 917 * @adv_id: If non-zero, then the adv_id of the PD Request 918 * @adv_mac: P2P Device Address of the advertizer 919 * @deferred_session_resp: Deferred session response sent by advertizer 920 * 921 * This callback is used to indicate either a failure or no response 922 * to an earlier provision discovery request. 923 * 924 * This callback handler can be set to %NULL if provision discovery 925 * is not used or failures do not need to be indicated. 926 */ 927 void (*prov_disc_fail)(void *ctx, const u8 *peer, 928 enum p2p_prov_disc_status status, 929 u32 adv_id, const u8 *adv_mac, 930 const char *deferred_session_resp); 931 932 /** 933 * invitation_process - Optional callback for processing Invitations 934 * @ctx: Callback context from cb_ctx 935 * @sa: Source address of the Invitation Request 936 * @bssid: P2P Group BSSID from the request or %NULL if not included 937 * @go_dev_addr: GO Device Address from P2P Group ID 938 * @ssid: SSID from P2P Group ID 939 * @ssid_len: Length of ssid buffer in octets 940 * @go: Variable for returning whether the local end is GO in the group 941 * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO) 942 * @force_freq: Variable for returning forced frequency for the group 943 * @persistent_group: Whether this is an invitation to reinvoke a 944 * persistent group (instead of invitation to join an active 945 * group) 946 * @channels: Available operating channels for the group 947 * @dev_pw_id: Device Password ID for NFC static handover or -1 if not 948 * used 949 * Returns: Status code (P2P_SC_*) 950 * 951 * This optional callback can be used to implement persistent reconnect 952 * by allowing automatic restarting of persistent groups without user 953 * interaction. If this callback is not implemented (i.e., is %NULL), 954 * the received Invitation Request frames are replied with 955 * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the 956 * invitation_result() callback. 957 * 958 * If the requested parameters are acceptable and the group is known, 959 * %P2P_SC_SUCCESS may be returned. If the requested group is unknown, 960 * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED 961 * can be returned if there is not enough data to provide immediate 962 * response, i.e., if some sort of user interaction is needed. The 963 * invitation_received() callback will be called in that case 964 * immediately after this call. 965 */ 966 u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid, 967 const u8 *go_dev_addr, const u8 *ssid, 968 size_t ssid_len, int *go, u8 *group_bssid, 969 int *force_freq, int persistent_group, 970 const struct p2p_channels *channels, 971 int dev_pw_id); 972 973 /** 974 * invitation_received - Callback on Invitation Request RX 975 * @ctx: Callback context from cb_ctx 976 * @sa: Source address of the Invitation Request 977 * @bssid: P2P Group BSSID or %NULL if not received 978 * @ssid: SSID of the group 979 * @ssid_len: Length of ssid in octets 980 * @go_dev_addr: GO Device Address 981 * @status: Response Status 982 * @op_freq: Operational frequency for the group 983 * 984 * This callback is used to indicate sending of an Invitation Response 985 * for a received Invitation Request. If status == 0 (success), the 986 * upper layer code is responsible for starting the group. status == 1 987 * indicates need to get user authorization for the group. Other status 988 * values indicate that the invitation request was rejected. 989 */ 990 void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid, 991 const u8 *ssid, size_t ssid_len, 992 const u8 *go_dev_addr, u8 status, 993 int op_freq); 994 995 /** 996 * invitation_result - Callback on Invitation result 997 * @ctx: Callback context from cb_ctx 998 * @status: Negotiation result (Status Code) 999 * @bssid: P2P Group BSSID or %NULL if not received 1000 * @channels: Available operating channels for the group 1001 * @addr: Peer address 1002 * @freq: Frequency (in MHz) indicated during invitation or 0 1003 * @peer_oper_freq: Operating frequency (in MHz) advertized by the peer 1004 * during invitation or 0 1005 * 1006 * This callback is used to indicate result of an Invitation procedure 1007 * started with a call to p2p_invite(). The indicated status code is 1008 * the value received from the peer in Invitation Response with 0 1009 * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a 1010 * local failure in transmitting the Invitation Request. 1011 */ 1012 void (*invitation_result)(void *ctx, int status, const u8 *bssid, 1013 const struct p2p_channels *channels, 1014 const u8 *addr, int freq, int peer_oper_freq); 1015 1016 /** 1017 * go_connected - Check whether we are connected to a GO 1018 * @ctx: Callback context from cb_ctx 1019 * @dev_addr: P2P Device Address of a GO 1020 * Returns: 1 if we are connected as a P2P client to the specified GO 1021 * or 0 if not. 1022 */ 1023 int (*go_connected)(void *ctx, const u8 *dev_addr); 1024 1025 /** 1026 * presence_resp - Callback on Presence Response 1027 * @ctx: Callback context from cb_ctx 1028 * @src: Source address (GO's P2P Interface Address) 1029 * @status: Result of the request (P2P_SC_*) 1030 * @noa: Returned NoA value 1031 * @noa_len: Length of the NoA buffer in octets 1032 */ 1033 void (*presence_resp)(void *ctx, const u8 *src, u8 status, 1034 const u8 *noa, size_t noa_len); 1035 1036 /** 1037 * is_concurrent_session_active - Check whether concurrent session is 1038 * active on other virtual interfaces 1039 * @ctx: Callback context from cb_ctx 1040 * Returns: 1 if concurrent session is active on other virtual interface 1041 * or 0 if not. 1042 */ 1043 int (*is_concurrent_session_active)(void *ctx); 1044 1045 /** 1046 * is_p2p_in_progress - Check whether P2P operation is in progress 1047 * @ctx: Callback context from cb_ctx 1048 * Returns: 1 if P2P operation (e.g., group formation) is in progress 1049 * or 0 if not. 1050 */ 1051 int (*is_p2p_in_progress)(void *ctx); 1052 1053 /** 1054 * Determine if we have a persistent group we share with remote peer 1055 * and allocate interface for this group if needed 1056 * @ctx: Callback context from cb_ctx 1057 * @addr: Peer device address to search for 1058 * @ssid: Persistent group SSID or %NULL if any 1059 * @ssid_len: Length of @ssid 1060 * @go_dev_addr: Buffer for returning GO P2P Device Address 1061 * @ret_ssid: Buffer for returning group SSID 1062 * @ret_ssid_len: Buffer for returning length of @ssid 1063 * @intended_iface_addr: Buffer for returning intended iface address 1064 * Returns: 1 if a matching persistent group was found, 0 otherwise 1065 */ 1066 int (*get_persistent_group)(void *ctx, const u8 *addr, const u8 *ssid, 1067 size_t ssid_len, u8 *go_dev_addr, 1068 u8 *ret_ssid, size_t *ret_ssid_len, 1069 u8 *intended_iface_addr); 1070 1071 /** 1072 * Get information about a possible local GO role 1073 * @ctx: Callback context from cb_ctx 1074 * @intended_addr: Buffer for returning intended GO interface address 1075 * @ssid: Buffer for returning group SSID 1076 * @ssid_len: Buffer for returning length of @ssid 1077 * @group_iface: Buffer for returning whether a separate group interface 1078 * would be used 1079 * @freq: Variable for returning the current operating frequency of a 1080 * currently running P2P GO. 1081 * Returns: 1 if GO info found, 0 otherwise 1082 * 1083 * This is used to compose New Group settings (SSID, and intended 1084 * address) during P2PS provisioning if results of provisioning *might* 1085 * result in our being an autonomous GO. 1086 */ 1087 int (*get_go_info)(void *ctx, u8 *intended_addr, 1088 u8 *ssid, size_t *ssid_len, int *group_iface, 1089 unsigned int *freq); 1090 1091 /** 1092 * remove_stale_groups - Remove stale P2PS groups 1093 * 1094 * Because P2PS stages *potential* GOs, and remote devices can remove 1095 * credentials unilaterally, we need to make sure we don't let stale 1096 * unusable groups build up. 1097 */ 1098 int (*remove_stale_groups)(void *ctx, const u8 *peer, const u8 *go, 1099 const u8 *ssid, size_t ssid_len); 1100 1101 /** 1102 * p2ps_prov_complete - P2PS provisioning complete 1103 * 1104 * When P2PS provisioning completes (successfully or not) we must 1105 * transmit all of the results to the upper layers. 1106 */ 1107 void (*p2ps_prov_complete)(void *ctx, u8 status, const u8 *dev, 1108 const u8 *adv_mac, const u8 *ses_mac, 1109 const u8 *grp_mac, u32 adv_id, u32 ses_id, 1110 u8 conncap, int passwd_id, 1111 const u8 *persist_ssid, 1112 size_t persist_ssid_size, int response_done, 1113 int prov_start, const char *session_info, 1114 const u8 *feat_cap, size_t feat_cap_len, 1115 unsigned int freq, const u8 *group_ssid, 1116 size_t group_ssid_len); 1117 1118 /** 1119 * prov_disc_resp_cb - Callback for indicating completion of PD Response 1120 * @ctx: Callback context from cb_ctx 1121 * Returns: 1 if operation was started, 0 otherwise 1122 * 1123 * This callback can be used to perform any pending actions after 1124 * provisioning. It is mainly used for P2PS pending group creation. 1125 */ 1126 int (*prov_disc_resp_cb)(void *ctx); 1127 1128 /** 1129 * p2ps_group_capability - Determine group capability 1130 * @ctx: Callback context from cb_ctx 1131 * @incoming: Peer requested roles, expressed with P2PS_SETUP_* bitmap. 1132 * @role: Local roles, expressed with P2PS_SETUP_* bitmap. 1133 * @force_freq: Variable for returning forced frequency for the group. 1134 * @pref_freq: Variable for returning preferred frequency for the group. 1135 * Returns: P2PS_SETUP_* bitmap of group capability result. 1136 * 1137 * This function can be used to determine group capability and 1138 * frequencies based on information from P2PS PD exchange and the 1139 * current state of ongoing groups and driver capabilities. 1140 */ 1141 u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role, 1142 unsigned int *force_freq, 1143 unsigned int *pref_freq); 1144 1145 /** 1146 * get_pref_freq_list - Get preferred frequency list for an interface 1147 * @ctx: Callback context from cb_ctx 1148 * @go: Whether the use if for GO role 1149 * @len: Length of freq_list in entries (both IN and OUT) 1150 * @freq_list: Buffer for returning the preferred frequencies (MHz) 1151 * Returns: 0 on success, -1 on failure 1152 * 1153 * This function can be used to query the preferred frequency list from 1154 * the driver specific to a particular interface type. 1155 */ 1156 int (*get_pref_freq_list)(void *ctx, int go, 1157 unsigned int *len, 1158 struct weighted_pcl *freq_list); 1159 }; 1160 1161 1162 /* P2P module initialization/deinitialization */ 1163 1164 /** 1165 * p2p_init - Initialize P2P module 1166 * @cfg: P2P module configuration 1167 * Returns: Pointer to private data or %NULL on failure 1168 * 1169 * This function is used to initialize global P2P module context (one per 1170 * device). The P2P module will keep a copy of the configuration data, so the 1171 * caller does not need to maintain this structure. However, the callback 1172 * functions and the context parameters to them must be kept available until 1173 * the P2P module is deinitialized with p2p_deinit(). 1174 */ 1175 struct p2p_data * p2p_init(const struct p2p_config *cfg); 1176 1177 /** 1178 * p2p_deinit - Deinitialize P2P module 1179 * @p2p: P2P module context from p2p_init() 1180 */ 1181 void p2p_deinit(struct p2p_data *p2p); 1182 1183 /** 1184 * p2p_flush - Flush P2P module state 1185 * @p2p: P2P module context from p2p_init() 1186 * 1187 * This command removes the P2P module state like peer device entries. 1188 */ 1189 void p2p_flush(struct p2p_data *p2p); 1190 1191 /** 1192 * p2p_unauthorize - Unauthorize the specified peer device 1193 * @p2p: P2P module context from p2p_init() 1194 * @addr: P2P peer entry to be unauthorized 1195 * Returns: 0 on success, -1 on failure 1196 * 1197 * This command removes any connection authorization from the specified P2P 1198 * peer device address. This can be used, e.g., to cancel effect of a previous 1199 * p2p_authorize() or p2p_connect() call that has not yet resulted in completed 1200 * GO Negotiation. 1201 */ 1202 int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr); 1203 1204 /** 1205 * p2p_set_dev_name - Set device name 1206 * @p2p: P2P module context from p2p_init() 1207 * Returns: 0 on success, -1 on failure 1208 * 1209 * This function can be used to update the P2P module configuration with 1210 * information that was not available at the time of the p2p_init() call. 1211 */ 1212 int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name); 1213 1214 int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer); 1215 int p2p_set_model_name(struct p2p_data *p2p, const char *model_name); 1216 int p2p_set_model_number(struct p2p_data *p2p, const char *model_number); 1217 int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number); 1218 1219 void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods); 1220 void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid); 1221 1222 /** 1223 * p2p_set_pri_dev_type - Set primary device type 1224 * @p2p: P2P module context from p2p_init() 1225 * Returns: 0 on success, -1 on failure 1226 * 1227 * This function can be used to update the P2P module configuration with 1228 * information that was not available at the time of the p2p_init() call. 1229 */ 1230 int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type); 1231 1232 /** 1233 * p2p_set_sec_dev_types - Set secondary device types 1234 * @p2p: P2P module context from p2p_init() 1235 * Returns: 0 on success, -1 on failure 1236 * 1237 * This function can be used to update the P2P module configuration with 1238 * information that was not available at the time of the p2p_init() call. 1239 */ 1240 int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8], 1241 size_t num_dev_types); 1242 1243 int p2p_set_country(struct p2p_data *p2p, const char *country); 1244 1245 1246 /* Commands from upper layer management entity */ 1247 1248 enum p2p_discovery_type { 1249 P2P_FIND_START_WITH_FULL, 1250 P2P_FIND_ONLY_SOCIAL, 1251 P2P_FIND_PROGRESSIVE, 1252 #ifdef CONFIG_OPEN_HARMONY_SPECIFIC_P2P_FIND 1253 P2P_FIND_SPECIFIC_FREQ, 1254 #endif 1255 }; 1256 1257 /** 1258 * p2p_find - Start P2P Find (Device Discovery) 1259 * @p2p: P2P module context from p2p_init() 1260 * @timeout: Timeout for find operation in seconds or 0 for no timeout 1261 * @type: Device Discovery type 1262 * @num_req_dev_types: Number of requested device types 1263 * @req_dev_types: Requested device types array, must be an array 1264 * containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no 1265 * requested device types. 1266 * @dev_id: Device ID to search for or %NULL to find all devices 1267 * @search_delay: Extra delay in milliseconds between search iterations 1268 * @seek_count: Number of ASP Service Strings in the seek_string array 1269 * @seek_string: ASP Service Strings to query for in Probe Requests 1270 * @freq: Requested first scan frequency (in MHz) to modify type == 1271 * P2P_FIND_START_WITH_FULL behavior. 0 = Use normal full scan. 1272 * If p2p_find is already in progress, this parameter is ignored and full 1273 * scan will be executed. 1274 * @include_6ghz: Include 6 GHz channels in P2P find 1275 * Returns: 0 on success, -1 on failure 1276 */ 1277 int p2p_find(struct p2p_data *p2p, unsigned int timeout, 1278 enum p2p_discovery_type type, 1279 unsigned int num_req_dev_types, const u8 *req_dev_types, 1280 const u8 *dev_id, unsigned int search_delay, 1281 u8 seek_count, const char **seek_string, int freq, 1282 bool include_6ghz); 1283 1284 /** 1285 * p2p_notify_scan_trigger_status - Indicate scan trigger status 1286 * @p2p: P2P module context from p2p_init() 1287 * @status: 0 on success, -1 on failure 1288 */ 1289 void p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status); 1290 1291 /** 1292 * p2p_stop_find - Stop P2P Find (Device Discovery) 1293 * @p2p: P2P module context from p2p_init() 1294 */ 1295 void p2p_stop_find(struct p2p_data *p2p); 1296 1297 /** 1298 * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq 1299 * @p2p: P2P module context from p2p_init() 1300 * @freq: Frequency in MHz for next operation 1301 * 1302 * This is like p2p_stop_find(), but Listen state is not stopped if we are 1303 * already on the same frequency. 1304 */ 1305 void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq); 1306 1307 /** 1308 * p2p_listen - Start P2P Listen state for specified duration 1309 * @p2p: P2P module context from p2p_init() 1310 * @timeout: Listen state duration in milliseconds 1311 * Returns: 0 on success, -1 on failure 1312 * 1313 * This function can be used to request the P2P module to keep the device 1314 * discoverable on the listen channel for an extended set of time. At least in 1315 * its current form, this is mainly used for testing purposes and may not be of 1316 * much use for normal P2P operations. 1317 */ 1318 int p2p_listen(struct p2p_data *p2p, unsigned int timeout); 1319 1320 /** 1321 * p2p_stop_listen - Stop P2P Listen 1322 * @p2p: P2P module context from p2p_init() 1323 */ 1324 void p2p_stop_listen(struct p2p_data *p2p); 1325 1326 /** 1327 * p2p_connect - Start P2P group formation (GO negotiation) 1328 * @p2p: P2P module context from p2p_init() 1329 * @peer_addr: MAC address of the peer P2P client 1330 * @wps_method: WPS method to be used in provisioning 1331 * @go_intent: Local GO intent value (1..15) 1332 * @own_interface_addr: Intended interface address to use with the group 1333 * @force_freq: The only allowed channel frequency in MHz or 0 1334 * @persistent_group: Whether to create a persistent group (0 = no, 1 = 1335 * persistent group without persistent reconnect, 2 = persistent group with 1336 * persistent reconnect) 1337 * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate 1338 * a new SSID 1339 * @force_ssid_len: Length of $force_ssid buffer 1340 * @pd_before_go_neg: Whether to send Provision Discovery prior to GO 1341 * Negotiation as an interoperability workaround when initiating group 1342 * formation 1343 * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 1344 * force_freq == 0) 1345 * Returns: 0 on success, -1 on failure 1346 */ 1347 int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr, 1348 enum p2p_wps_method wps_method, 1349 int go_intent, const u8 *own_interface_addr, 1350 unsigned int force_freq, int persistent_group, 1351 const u8 *force_ssid, size_t force_ssid_len, 1352 int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id); 1353 1354 /** 1355 * p2p_authorize - Authorize P2P group formation (GO negotiation) 1356 * @p2p: P2P module context from p2p_init() 1357 * @peer_addr: MAC address of the peer P2P client 1358 * @wps_method: WPS method to be used in provisioning 1359 * @go_intent: Local GO intent value (1..15) 1360 * @own_interface_addr: Intended interface address to use with the group 1361 * @force_freq: The only allowed channel frequency in MHz or 0 1362 * @persistent_group: Whether to create a persistent group (0 = no, 1 = 1363 * persistent group without persistent reconnect, 2 = persistent group with 1364 * persistent reconnect) 1365 * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate 1366 * a new SSID 1367 * @force_ssid_len: Length of $force_ssid buffer 1368 * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 1369 * force_freq == 0) 1370 * Returns: 0 on success, -1 on failure 1371 * 1372 * This is like p2p_connect(), but the actual group negotiation is not 1373 * initiated automatically, i.e., the other end is expected to do that. 1374 */ 1375 int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr, 1376 enum p2p_wps_method wps_method, 1377 int go_intent, const u8 *own_interface_addr, 1378 unsigned int force_freq, int persistent_group, 1379 const u8 *force_ssid, size_t force_ssid_len, 1380 unsigned int pref_freq, u16 oob_pw_id); 1381 1382 /** 1383 * p2p_reject - Reject peer device (explicitly block connection attempts) 1384 * @p2p: P2P module context from p2p_init() 1385 * @peer_addr: MAC address of the peer P2P client 1386 * Returns: 0 on success, -1 on failure 1387 */ 1388 int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr); 1389 1390 /** 1391 * p2p_prov_disc_req - Send Provision Discovery Request 1392 * @p2p: P2P module context from p2p_init() 1393 * @peer_addr: MAC address of the peer P2P client 1394 * @p2ps_prov: Provisioning info for P2PS 1395 * @config_methods: WPS Config Methods value (only one bit set) 1396 * @join: Whether this is used by a client joining an active group 1397 * @force_freq: Forced TX frequency for the frame (mainly for the join case) 1398 * @user_initiated_pd: Flag to indicate if initiated by user or not 1399 * Returns: 0 on success, -1 on failure 1400 * 1401 * This function can be used to request a discovered P2P peer to display a PIN 1402 * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us 1403 * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame 1404 * is transmitted once immediately and if no response is received, the frame 1405 * will be sent again whenever the target device is discovered during device 1406 * dsicovery (start with a p2p_find() call). Response from the peer is 1407 * indicated with the p2p_config::prov_disc_resp() callback. 1408 */ 1409 int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, 1410 struct p2ps_provision *p2ps_prov, u16 config_methods, 1411 int join, int force_freq, 1412 int user_initiated_pd); 1413 1414 /** 1415 * p2p_sd_request - Schedule a service discovery query 1416 * @p2p: P2P module context from p2p_init() 1417 * @dst: Destination peer or %NULL to apply for all peers 1418 * @tlvs: P2P Service Query TLV(s) 1419 * Returns: Reference to the query or %NULL on failure 1420 * 1421 * Response to the query is indicated with the p2p_config::sd_response() 1422 * callback. 1423 */ 1424 void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst, 1425 const struct wpabuf *tlvs); 1426 1427 #ifdef CONFIG_WIFI_DISPLAY 1428 void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst, 1429 const struct wpabuf *tlvs); 1430 #endif /* CONFIG_WIFI_DISPLAY */ 1431 1432 /** 1433 * p2p_sd_cancel_request - Cancel a pending service discovery query 1434 * @p2p: P2P module context from p2p_init() 1435 * @req: Query reference from p2p_sd_request() 1436 * Returns: 0 if request for cancelled; -1 if not found 1437 */ 1438 int p2p_sd_cancel_request(struct p2p_data *p2p, void *req); 1439 1440 /** 1441 * p2p_sd_response - Send response to a service discovery query 1442 * @p2p: P2P module context from p2p_init() 1443 * @freq: Frequency from p2p_config::sd_request() callback 1444 * @dst: Destination address from p2p_config::sd_request() callback 1445 * @dialog_token: Dialog token from p2p_config::sd_request() callback 1446 * @resp_tlvs: P2P Service Response TLV(s) 1447 * 1448 * This function is called as a response to the request indicated with 1449 * p2p_config::sd_request() callback. 1450 */ 1451 void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst, 1452 u8 dialog_token, const struct wpabuf *resp_tlvs); 1453 1454 /** 1455 * p2p_sd_service_update - Indicate a change in local services 1456 * @p2p: P2P module context from p2p_init() 1457 * 1458 * This function needs to be called whenever there is a change in availability 1459 * of the local services. This will increment the Service Update Indicator 1460 * value which will be used in SD Request and Response frames. 1461 */ 1462 void p2p_sd_service_update(struct p2p_data *p2p); 1463 1464 1465 enum p2p_invite_role { 1466 P2P_INVITE_ROLE_GO, 1467 P2P_INVITE_ROLE_ACTIVE_GO, 1468 P2P_INVITE_ROLE_CLIENT 1469 }; 1470 1471 /** 1472 * p2p_invite - Invite a P2P Device into a group 1473 * @p2p: P2P module context from p2p_init() 1474 * @peer: Device Address of the peer P2P Device 1475 * @role: Local role in the group 1476 * @bssid: Group BSSID or %NULL if not known 1477 * @ssid: Group SSID 1478 * @ssid_len: Length of ssid in octets 1479 * @force_freq: The only allowed channel frequency in MHz or 0 1480 * @go_dev_addr: Forced GO Device Address or %NULL if none 1481 * @persistent_group: Whether this is to reinvoke a persistent group 1482 * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 1483 * force_freq == 0) 1484 * @dev_pw_id: Device Password ID from OOB Device Password (NFC) static handover 1485 * case or -1 if not used 1486 * Returns: 0 on success, -1 on failure 1487 */ 1488 int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role, 1489 const u8 *bssid, const u8 *ssid, size_t ssid_len, 1490 unsigned int force_freq, const u8 *go_dev_addr, 1491 int persistent_group, unsigned int pref_freq, int dev_pw_id); 1492 1493 /** 1494 * p2p_presence_req - Request GO presence 1495 * @p2p: P2P module context from p2p_init() 1496 * @go_interface_addr: GO P2P Interface Address 1497 * @own_interface_addr: Own P2P Interface Address for this group 1498 * @freq: Group operating frequence (in MHz) 1499 * @duration1: Preferred presence duration in microseconds 1500 * @interval1: Preferred presence interval in microseconds 1501 * @duration2: Acceptable presence duration in microseconds 1502 * @interval2: Acceptable presence interval in microseconds 1503 * Returns: 0 on success, -1 on failure 1504 * 1505 * If both duration and interval values are zero, the parameter pair is not 1506 * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0). 1507 */ 1508 int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr, 1509 const u8 *own_interface_addr, unsigned int freq, 1510 u32 duration1, u32 interval1, u32 duration2, 1511 u32 interval2); 1512 1513 /** 1514 * p2p_ext_listen - Set Extended Listen Timing 1515 * @p2p: P2P module context from p2p_init() 1516 * @freq: Group operating frequence (in MHz) 1517 * @period: Availability period in milliseconds (1-65535; 0 to disable) 1518 * @interval: Availability interval in milliseconds (1-65535; 0 to disable) 1519 * Returns: 0 on success, -1 on failure 1520 * 1521 * This function can be used to enable or disable (period = interval = 0) 1522 * Extended Listen Timing. When enabled, the P2P Device will become 1523 * discoverable (go into Listen State) every @interval milliseconds for at 1524 * least @period milliseconds. 1525 */ 1526 int p2p_ext_listen(struct p2p_data *p2p, unsigned int period, 1527 unsigned int interval); 1528 1529 /* Event notifications from upper layer management operations */ 1530 1531 /** 1532 * p2p_wps_success_cb - Report successfully completed WPS provisioning 1533 * @p2p: P2P module context from p2p_init() 1534 * @mac_addr: Peer address 1535 * 1536 * This function is used to report successfully completed WPS provisioning 1537 * during group formation in both GO/Registrar and client/Enrollee roles. 1538 */ 1539 void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr); 1540 1541 /** 1542 * p2p_group_formation_failed - Report failed WPS provisioning 1543 * @p2p: P2P module context from p2p_init() 1544 * 1545 * This function is used to report failed group formation. This can happen 1546 * either due to failed WPS provisioning or due to 15 second timeout during 1547 * the provisioning phase. 1548 */ 1549 void p2p_group_formation_failed(struct p2p_data *p2p); 1550 1551 /** 1552 * p2p_get_provisioning_info - Get any stored provisioning info 1553 * @p2p: P2P module context from p2p_init() 1554 * @addr: Peer P2P Device Address 1555 * Returns: WPS provisioning information (WPS config method) or 0 if no 1556 * information is available 1557 * 1558 * This function is used to retrieve stored WPS provisioning info for the given 1559 * peer. 1560 */ 1561 u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr); 1562 1563 /** 1564 * p2p_clear_provisioning_info - Clear any stored provisioning info 1565 * @p2p: P2P module context from p2p_init() 1566 * @iface_addr: Peer P2P Device Address 1567 * 1568 * This function is used to clear stored WPS provisioning info for the given 1569 * peer. 1570 */ 1571 void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr); 1572 1573 1574 /* Event notifications from lower layer driver operations */ 1575 1576 /** 1577 * enum p2p_probe_req_status 1578 * 1579 * @P2P_PREQ_MALFORMED: frame was not well-formed 1580 * @P2P_PREQ_NOT_LISTEN: device isn't in listen state, frame ignored 1581 * @P2P_PREQ_NOT_P2P: frame was not a P2P probe request 1582 * @P2P_PREQ_P2P_NOT_PROCESSED: frame was P2P but wasn't processed 1583 * @P2P_PREQ_P2P_PROCESSED: frame has been processed by P2P 1584 */ 1585 enum p2p_probe_req_status { 1586 P2P_PREQ_MALFORMED, 1587 P2P_PREQ_NOT_LISTEN, 1588 P2P_PREQ_NOT_P2P, 1589 P2P_PREQ_NOT_PROCESSED, 1590 P2P_PREQ_PROCESSED 1591 }; 1592 1593 /** 1594 * p2p_probe_req_rx - Report reception of a Probe Request frame 1595 * @p2p: P2P module context from p2p_init() 1596 * @addr: Source MAC address 1597 * @dst: Destination MAC address if available or %NULL 1598 * @bssid: BSSID if available or %NULL 1599 * @ie: Information elements from the Probe Request frame body 1600 * @ie_len: Length of ie buffer in octets 1601 * @rx_freq: Probe Request frame RX frequency 1602 * @p2p_lo_started: Whether P2P Listen Offload is started 1603 * Returns: value indicating the type and status of the probe request 1604 */ 1605 enum p2p_probe_req_status 1606 p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, 1607 const u8 *bssid, const u8 *ie, size_t ie_len, 1608 unsigned int rx_freq, int p2p_lo_started); 1609 1610 /** 1611 * p2p_rx_action - Report received Action frame 1612 * @p2p: P2P module context from p2p_init() 1613 * @da: Destination address of the received Action frame 1614 * @sa: Source address of the received Action frame 1615 * @bssid: Address 3 of the received Action frame 1616 * @category: Category of the received Action frame 1617 * @data: Action frame body after the Category field 1618 * @len: Length of the data buffer in octets 1619 * @freq: Frequency (in MHz) on which the frame was received 1620 */ 1621 void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa, 1622 const u8 *bssid, u8 category, 1623 const u8 *data, size_t len, int freq); 1624 1625 /** 1626 * p2p_scan_res_handler - Indicate a P2P scan results 1627 * @p2p: P2P module context from p2p_init() 1628 * @bssid: BSSID of the scan result 1629 * @freq: Frequency of the channel on which the device was found in MHz 1630 * @rx_time: Time when the result was received 1631 * @level: Signal level (signal strength of the received Beacon/Probe Response 1632 * frame) 1633 * @ies: Pointer to IEs from the scan result 1634 * @ies_len: Length of the ies buffer 1635 * Returns: 0 to continue or 1 to stop scan result indication 1636 * 1637 * This function is called to indicate a scan result entry with P2P IE from a 1638 * scan requested with struct p2p_config::p2p_scan(). This can be called during 1639 * the actual scan process (i.e., whenever a new device is found) or as a 1640 * sequence of calls after the full scan has been completed. The former option 1641 * can result in optimized operations, but may not be supported by all 1642 * driver/firmware designs. The ies buffer need to include at least the P2P IE, 1643 * but it is recommended to include all IEs received from the device. The 1644 * caller does not need to check that the IEs contain a P2P IE before calling 1645 * this function since frames will be filtered internally if needed. 1646 * 1647 * This function will return 1 if it wants to stop scan result iteration (and 1648 * scan in general if it is still in progress). This is used to allow faster 1649 * start of a pending operation, e.g., to start a pending GO negotiation. 1650 */ 1651 int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, 1652 struct os_reltime *rx_time, int level, const u8 *ies, 1653 size_t ies_len); 1654 1655 /** 1656 * p2p_scan_res_handled - Indicate end of scan results 1657 * @p2p: P2P module context from p2p_init() 1658 * @delay: Search delay for next scan in ms 1659 * 1660 * This function is called to indicate that all P2P scan results from a scan 1661 * have been reported with zero or more calls to p2p_scan_res_handler(). This 1662 * function must be called as a response to successful 1663 * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler() 1664 * calls stopped iteration. 1665 */ 1666 void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay); 1667 1668 enum p2p_send_action_result { 1669 P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */, 1670 P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */, 1671 P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */ 1672 }; 1673 1674 /** 1675 * p2p_send_action_cb - Notify TX status of an Action frame 1676 * @p2p: P2P module context from p2p_init() 1677 * @freq: Channel frequency in MHz 1678 * @dst: Destination MAC address (Address 1) 1679 * @src: Source MAC address (Address 2) 1680 * @bssid: BSSID (Address 3) 1681 * @result: Result of the transmission attempt 1682 * 1683 * This function is used to indicate the result of an Action frame transmission 1684 * that was requested with struct p2p_config::send_action() callback. 1685 */ 1686 void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, 1687 const u8 *src, const u8 *bssid, 1688 enum p2p_send_action_result result); 1689 1690 /** 1691 * p2p_listen_cb - Indicate the start of a requested Listen state 1692 * @p2p: P2P module context from p2p_init() 1693 * @freq: Listen channel frequency in MHz 1694 * @duration: Duration for the Listen state in milliseconds 1695 * 1696 * This function is used to indicate that a Listen state requested with 1697 * struct p2p_config::start_listen() callback has started. 1698 */ 1699 void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq, 1700 unsigned int duration); 1701 1702 /** 1703 * p2p_listen_end - Indicate the end of a requested Listen state 1704 * @p2p: P2P module context from p2p_init() 1705 * @freq: Listen channel frequency in MHz 1706 * Returns: 0 if no operations were started, 1 if an operation was started 1707 * 1708 * This function is used to indicate that a Listen state requested with 1709 * struct p2p_config::start_listen() callback has ended. 1710 */ 1711 int p2p_listen_end(struct p2p_data *p2p, unsigned int freq); 1712 1713 void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, 1714 const u8 *ie, size_t ie_len); 1715 1716 void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, 1717 const u8 *ie, size_t ie_len); 1718 1719 1720 /* Per-group P2P state for GO */ 1721 1722 struct p2p_group; 1723 1724 /** 1725 * struct p2p_group_config - P2P group configuration 1726 * 1727 * This configuration is provided to the P2P module during initialization of 1728 * the per-group information with p2p_group_init(). 1729 */ 1730 struct p2p_group_config { 1731 /** 1732 * persistent_group - Whether the group is persistent 1733 * 0 = not a persistent group 1734 * 1 = persistent group without persistent reconnect 1735 * 2 = persistent group with persistent reconnect 1736 */ 1737 int persistent_group; 1738 1739 /** 1740 * interface_addr - P2P Interface Address of the group 1741 */ 1742 u8 interface_addr[ETH_ALEN]; 1743 1744 /** 1745 * max_clients - Maximum number of clients in the group 1746 */ 1747 unsigned int max_clients; 1748 1749 /** 1750 * ssid - Group SSID 1751 */ 1752 u8 ssid[SSID_MAX_LEN]; 1753 1754 /** 1755 * ssid_len - Length of SSID 1756 */ 1757 size_t ssid_len; 1758 1759 /** 1760 * freq - Operating channel of the group 1761 */ 1762 int freq; 1763 1764 /** 1765 * ip_addr_alloc - Whether IP address allocation within 4-way handshake 1766 * is supported 1767 */ 1768 int ip_addr_alloc; 1769 1770 /** 1771 * cb_ctx - Context to use with callback functions 1772 */ 1773 void *cb_ctx; 1774 1775 /** 1776 * ie_update - Notification of IE update 1777 * @ctx: Callback context from cb_ctx 1778 * @beacon_ies: P2P IE for Beacon frames or %NULL if no change 1779 * @proberesp_ies: P2P Ie for Probe Response frames 1780 * 1781 * P2P module uses this callback function to notify whenever the P2P IE 1782 * in Beacon or Probe Response frames should be updated based on group 1783 * events. 1784 * 1785 * The callee is responsible for freeing the returned buffer(s) with 1786 * wpabuf_free(). 1787 */ 1788 void (*ie_update)(void *ctx, struct wpabuf *beacon_ies, 1789 struct wpabuf *proberesp_ies); 1790 1791 /** 1792 * idle_update - Notification of changes in group idle state 1793 * @ctx: Callback context from cb_ctx 1794 * @idle: Whether the group is idle (no associated stations) 1795 */ 1796 void (*idle_update)(void *ctx, int idle); 1797 }; 1798 1799 /** 1800 * p2p_group_init - Initialize P2P group 1801 * @p2p: P2P module context from p2p_init() 1802 * @config: P2P group configuration (will be freed by p2p_group_deinit()) 1803 * Returns: Pointer to private data or %NULL on failure 1804 * 1805 * This function is used to initialize per-group P2P module context. Currently, 1806 * this is only used to manage GO functionality and P2P clients do not need to 1807 * create an instance of this per-group information. 1808 */ 1809 struct p2p_group * p2p_group_init(struct p2p_data *p2p, 1810 struct p2p_group_config *config); 1811 1812 /** 1813 * p2p_group_deinit - Deinitialize P2P group 1814 * @group: P2P group context from p2p_group_init() 1815 */ 1816 void p2p_group_deinit(struct p2p_group *group); 1817 1818 /** 1819 * p2p_group_notif_assoc - Notification of P2P client association with GO 1820 * @group: P2P group context from p2p_group_init() 1821 * @addr: Interface address of the P2P client 1822 * @ie: IEs from the (Re)association Request frame 1823 * @len: Length of the ie buffer in octets 1824 * Returns: 0 on success, -1 on failure 1825 */ 1826 int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr, 1827 const u8 *ie, size_t len); 1828 1829 /** 1830 * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response 1831 * @group: P2P group context from p2p_group_init() 1832 * @status: Status value (P2P_SC_SUCCESS if association succeeded) 1833 * Returns: P2P IE for (Re)association Response or %NULL on failure 1834 * 1835 * The caller is responsible for freeing the returned buffer with 1836 * wpabuf_free(). 1837 */ 1838 struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status); 1839 1840 /** 1841 * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO 1842 * @group: P2P group context from p2p_group_init() 1843 * @addr: Interface address of the P2P client 1844 */ 1845 void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr); 1846 1847 /** 1848 * p2p_group_notif_formation_done - Notification of completed group formation 1849 * @group: P2P group context from p2p_group_init() 1850 */ 1851 void p2p_group_notif_formation_done(struct p2p_group *group); 1852 1853 /** 1854 * p2p_group_notif_noa - Notification of NoA change 1855 * @group: P2P group context from p2p_group_init() 1856 * @noa: Notice of Absence attribute payload, %NULL if none 1857 * @noa_len: Length of noa buffer in octets 1858 * Returns: 0 on success, -1 on failure 1859 * 1860 * Notify the P2P group management about a new NoA contents. This will be 1861 * inserted into the P2P IEs in Beacon and Probe Response frames with rest of 1862 * the group information. 1863 */ 1864 int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, 1865 size_t noa_len); 1866 1867 /** 1868 * p2p_group_match_dev_type - Match device types in group with requested type 1869 * @group: P2P group context from p2p_group_init() 1870 * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs) 1871 * Returns: 1 on match, 0 on mismatch 1872 * 1873 * This function can be used to match the Requested Device Type attribute in 1874 * WPS IE with the device types of a group member for deciding whether a GO 1875 * should reply to a Probe Request frame. Match will be reported if the WPS IE 1876 * is not requested any specific device type. 1877 */ 1878 int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps); 1879 1880 /** 1881 * p2p_group_match_dev_id - Match P2P Device Address in group with requested device id 1882 */ 1883 int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p); 1884 1885 /** 1886 * p2p_group_go_discover - Send GO Discoverability Request to a group client 1887 * @group: P2P group context from p2p_group_init() 1888 * Returns: 0 on success (frame scheduled); -1 if client was not found 1889 */ 1890 int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id, 1891 const u8 *searching_dev, int rx_freq); 1892 1893 1894 /* Generic helper functions */ 1895 1896 /** 1897 * p2p_ie_text - Build text format description of P2P IE 1898 * @p2p_ie: P2P IE 1899 * @buf: Buffer for returning text 1900 * @end: Pointer to the end of the buf area 1901 * Returns: Number of octets written to the buffer or -1 on failure 1902 * 1903 * This function can be used to parse P2P IE contents into text format 1904 * field=value lines. 1905 */ 1906 int p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end); 1907 1908 /** 1909 * p2p_scan_result_text - Build text format description of P2P IE 1910 * @ies: Information elements from scan results 1911 * @ies_len: ies buffer length in octets 1912 * @buf: Buffer for returning text 1913 * @end: Pointer to the end of the buf area 1914 * Returns: Number of octets written to the buffer or -1 on failure 1915 * 1916 * This function can be used to parse P2P IE contents into text format 1917 * field=value lines. 1918 */ 1919 int p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end); 1920 1921 /** 1922 * p2p_parse_dev_addr_in_p2p_ie - Parse P2P Device Address from a concatenated 1923 * P2P IE 1924 * @p2p_ie: P2P IE 1925 * @dev_addr: Buffer for returning P2P Device Address 1926 * Returns: 0 on success or -1 if P2P Device Address could not be parsed 1927 */ 1928 int p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr); 1929 1930 /** 1931 * p2p_parse_dev_addr - Parse P2P Device Address from P2P IE(s) 1932 * @ies: Information elements from scan results 1933 * @ies_len: ies buffer length in octets 1934 * @dev_addr: Buffer for returning P2P Device Address 1935 * Returns: 0 on success or -1 if P2P Device Address could not be parsed 1936 */ 1937 int p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr); 1938 1939 /** 1940 * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame 1941 * @p2p: P2P module context from p2p_init() 1942 * @bssid: BSSID 1943 * @buf: Buffer for writing the P2P IE 1944 * @len: Maximum buf length in octets 1945 * @p2p_group: Whether this is for association with a P2P GO 1946 * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none 1947 * Returns: Number of octets written into buf or -1 on failure 1948 */ 1949 int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf, 1950 size_t len, int p2p_group, struct wpabuf *p2p_ie); 1951 1952 /** 1953 * p2p_scan_ie - Build P2P IE for Probe Request 1954 * @p2p: P2P module context from p2p_init() 1955 * @ies: Buffer for writing P2P IE 1956 * @dev_id: Device ID to search for or %NULL for any 1957 * @bands: Frequency bands used in the scan (enum wpa_radio_work_band bitmap) 1958 */ 1959 void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id, 1960 unsigned int bands); 1961 1962 /** 1963 * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie 1964 * @p2p: P2P module context from p2p_init() 1965 * Returns: Number of octets that p2p_scan_ie() may add to the buffer 1966 */ 1967 size_t p2p_scan_ie_buf_len(struct p2p_data *p2p); 1968 1969 /** 1970 * p2p_go_params - Generate random P2P group parameters 1971 * @p2p: P2P module context from p2p_init() 1972 * @params: Buffer for parameters 1973 * Returns: 0 on success, -1 on failure 1974 */ 1975 int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params); 1976 1977 /** 1978 * p2p_get_group_capab - Get Group Capability from P2P IE data 1979 * @p2p_ie: P2P IE(s) contents 1980 * Returns: Group Capability 1981 */ 1982 u8 p2p_get_group_capab(const struct wpabuf *p2p_ie); 1983 1984 /** 1985 * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection 1986 * @p2p_ie: P2P IE(s) contents 1987 * Returns: 0 if cross connection is allow, 1 if not 1988 */ 1989 int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie); 1990 1991 /** 1992 * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data 1993 * @p2p_ie: P2P IE(s) contents 1994 * Returns: Pointer to P2P Device Address or %NULL if not included 1995 */ 1996 const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie); 1997 1998 /** 1999 * p2p_get_peer_info - Get P2P peer information 2000 * @p2p: P2P module context from p2p_init() 2001 * @addr: P2P Device Address of the peer or %NULL to indicate the first peer 2002 * @next: Whether to select the peer entry following the one indicated by addr 2003 * Returns: Pointer to peer info or %NULL if not found 2004 */ 2005 const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p, 2006 const u8 *addr, int next); 2007 2008 /** 2009 * p2p_get_peer_info_txt - Get internal P2P peer information in text format 2010 * @info: Pointer to P2P peer info from p2p_get_peer_info() 2011 * @buf: Buffer for returning text 2012 * @buflen: Maximum buffer length 2013 * Returns: Number of octets written to the buffer or -1 on failure 2014 * 2015 * Note: This information is internal to the P2P module and subject to change. 2016 * As such, this should not really be used by external programs for purposes 2017 * other than debugging. 2018 */ 2019 int p2p_get_peer_info_txt(const struct p2p_peer_info *info, 2020 char *buf, size_t buflen); 2021 2022 /** 2023 * p2p_peer_known - Check whether P2P peer is known 2024 * @p2p: P2P module context from p2p_init() 2025 * @addr: P2P Device Address of the peer 2026 * Returns: 1 if the specified device is in the P2P peer table or 0 if not 2027 */ 2028 int p2p_peer_known(struct p2p_data *p2p, const u8 *addr); 2029 2030 /** 2031 * p2p_set_client_discoverability - Set client discoverability capability 2032 * @p2p: P2P module context from p2p_init() 2033 * @enabled: Whether client discoverability will be enabled 2034 * 2035 * This function can be used to disable (and re-enable) client discoverability. 2036 * This capability is enabled by default and should not be disabled in normal 2037 * use cases, i.e., this is mainly for testing purposes. 2038 */ 2039 void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled); 2040 2041 /** 2042 * p2p_set_managed_oper - Set managed P2P Device operations capability 2043 * @p2p: P2P module context from p2p_init() 2044 * @enabled: Whether managed P2P Device operations will be enabled 2045 */ 2046 void p2p_set_managed_oper(struct p2p_data *p2p, int enabled); 2047 2048 /** 2049 * p2p_config_get_random_social - Return a random social channel 2050 * @p2p: P2P config 2051 * @op_class: Selected operating class 2052 * @op_channel: Selected social channel 2053 * @avoid_list: Channel ranges to try to avoid or %NULL 2054 * @disallow_list: Channel ranges to discard or %NULL 2055 * Returns: 0 on success, -1 on failure 2056 * 2057 * This function is used before p2p_init is called. A random social channel 2058 * from supports bands 2.4 GHz (channels 1,6,11) and 60 GHz (channel 2) is 2059 * returned on success. 2060 */ 2061 int p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class, 2062 u8 *op_channel, 2063 struct wpa_freq_range_list *avoid_list, 2064 struct wpa_freq_range_list *disallow_list); 2065 2066 int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel, 2067 u8 forced); 2068 2069 u8 p2p_get_listen_channel(struct p2p_data *p2p); 2070 2071 int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len); 2072 2073 int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, 2074 u8 *iface_addr); 2075 int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, 2076 u8 *dev_addr); 2077 2078 void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr); 2079 2080 /** 2081 * p2p_set_cross_connect - Set cross connection capability 2082 * @p2p: P2P module context from p2p_init() 2083 * @enabled: Whether cross connection will be enabled 2084 */ 2085 void p2p_set_cross_connect(struct p2p_data *p2p, int enabled); 2086 2087 int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr); 2088 2089 /** 2090 * p2p_set_intra_bss_dist - Set intra BSS distribution 2091 * @p2p: P2P module context from p2p_init() 2092 * @enabled: Whether intra BSS distribution will be enabled 2093 */ 2094 void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled); 2095 2096 int p2p_channels_includes_freq(const struct p2p_channels *channels, 2097 unsigned int freq); 2098 2099 int p2p_channels_to_freqs(const struct p2p_channels *channels, 2100 int *freq_list, unsigned int max_len); 2101 2102 /** 2103 * p2p_supported_freq - Check whether channel is supported for P2P 2104 * @p2p: P2P module context from p2p_init() 2105 * @freq: Channel frequency in MHz 2106 * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 2107 */ 2108 int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq); 2109 2110 /** 2111 * p2p_supported_freq_go - Check whether channel is supported for P2P GO operation 2112 * @p2p: P2P module context from p2p_init() 2113 * @freq: Channel frequency in MHz 2114 * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 2115 */ 2116 int p2p_supported_freq_go(struct p2p_data *p2p, unsigned int freq); 2117 2118 /** 2119 * p2p_supported_freq_cli - Check whether channel is supported for P2P client operation 2120 * @p2p: P2P module context from p2p_init() 2121 * @freq: Channel frequency in MHz 2122 * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 2123 */ 2124 int p2p_supported_freq_cli(struct p2p_data *p2p, unsigned int freq); 2125 2126 /** 2127 * p2p_get_pref_freq - Get channel from preferred channel list 2128 * @p2p: P2P module context from p2p_init() 2129 * @channels: List of channels 2130 * Returns: Preferred channel 2131 */ 2132 unsigned int p2p_get_pref_freq(struct p2p_data *p2p, 2133 const struct p2p_channels *channels); 2134 2135 void p2p_update_channel_list(struct p2p_data *p2p, 2136 const struct p2p_channels *chan, 2137 const struct p2p_channels *cli_chan); 2138 2139 bool is_p2p_6ghz_disabled(struct p2p_data *p2p); 2140 2141 /** 2142 * p2p_set_best_channels - Update best channel information 2143 * @p2p: P2P module context from p2p_init() 2144 * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band 2145 * @freq_5: Frequency (MHz) of best channel in 5 GHz band 2146 * @freq_overall: Frequency (MHz) of best channel overall 2147 */ 2148 void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5, 2149 int freq_overall); 2150 2151 /** 2152 * p2p_set_own_freq_preference - Set own preference for channel 2153 * @p2p: P2P module context from p2p_init() 2154 * @freq: Frequency (MHz) of the preferred channel or 0 if no preference 2155 * 2156 * This function can be used to set a preference on the operating channel based 2157 * on frequencies used on the other virtual interfaces that share the same 2158 * radio. If non-zero, this is used to try to avoid multi-channel concurrency. 2159 */ 2160 void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq); 2161 2162 const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p); 2163 2164 /** 2165 * p2p_get_group_num_members - Get number of members in group 2166 * @group: P2P group context from p2p_group_init() 2167 * Returns: Number of members in the group 2168 */ 2169 unsigned int p2p_get_group_num_members(struct p2p_group *group); 2170 2171 /** 2172 * p2p_client_limit_reached - Check if client limit is reached 2173 * @group: P2P group context from p2p_group_init() 2174 * Returns: 1 if no of clients limit reached 2175 */ 2176 int p2p_client_limit_reached(struct p2p_group *group); 2177 2178 /** 2179 * p2p_iterate_group_members - Iterate group members 2180 * @group: P2P group context from p2p_group_init() 2181 * @next: iteration pointer, must be a pointer to a void * that is set to %NULL 2182 * on the first call and not modified later 2183 * Returns: A P2P Device Address for each call and %NULL for no more members 2184 */ 2185 const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next); 2186 2187 /** 2188 * p2p_group_get_client_interface_addr - Get P2P Interface Address of a client in a group 2189 * @group: P2P group context from p2p_group_init() 2190 * @dev_addr: P2P Device Address of the client 2191 * Returns: P2P Interface Address of the client if found or %NULL if no match 2192 * found 2193 */ 2194 const u8 * p2p_group_get_client_interface_addr(struct p2p_group *group, 2195 const u8 *dev_addr); 2196 2197 /** 2198 * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group 2199 * @group: P2P group context from p2p_group_init() 2200 * @addr: P2P Interface Address of the client 2201 * Returns: P2P Device Address of the client if found or %NULL if no match 2202 * found 2203 */ 2204 const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr); 2205 2206 /** 2207 * p2p_group_is_client_connected - Check whether a specific client is connected 2208 * @group: P2P group context from p2p_group_init() 2209 * @addr: P2P Device Address of the client 2210 * Returns: 1 if client is connected or 0 if not 2211 */ 2212 int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr); 2213 2214 /** 2215 * p2p_group_get_config - Get the group configuration 2216 * @group: P2P group context from p2p_group_init() 2217 * Returns: The group configuration pointer 2218 */ 2219 const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group); 2220 2221 /** 2222 * p2p_loop_on_all_groups - Run the given callback on all groups 2223 * @p2p: P2P module context from p2p_init() 2224 * @group_callback: The callback function pointer 2225 * @user_data: Some user data pointer which can be %NULL 2226 * 2227 * The group_callback function can stop the iteration by returning 0. 2228 */ 2229 void p2p_loop_on_all_groups(struct p2p_data *p2p, 2230 int (*group_callback)(struct p2p_group *group, 2231 void *user_data), 2232 void *user_data); 2233 2234 /** 2235 * p2p_get_peer_found - Get P2P peer info structure of a found peer 2236 * @p2p: P2P module context from p2p_init() 2237 * @addr: P2P Device Address of the peer or %NULL to indicate the first peer 2238 * @next: Whether to select the peer entry following the one indicated by addr 2239 * Returns: The first P2P peer info available or %NULL if no such peer exists 2240 */ 2241 const struct p2p_peer_info * 2242 p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next); 2243 2244 /** 2245 * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions 2246 * @p2p: P2P module context from p2p_init() 2247 */ 2248 void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p); 2249 2250 /** 2251 * p2p_add_wps_vendor_extension - Add a WPS vendor extension 2252 * @p2p: P2P module context from p2p_init() 2253 * @vendor_ext: The vendor extensions to add 2254 * Returns: 0 on success, -1 on failure 2255 * 2256 * The wpabuf structures in the array are owned by the P2P 2257 * module after this call. 2258 */ 2259 int p2p_add_wps_vendor_extension(struct p2p_data *p2p, 2260 const struct wpabuf *vendor_ext); 2261 2262 /** 2263 * p2p_set_oper_channel - Set the P2P operating channel 2264 * @p2p: P2P module context from p2p_init() 2265 * @op_reg_class: Operating regulatory class to set 2266 * @op_channel: operating channel to set 2267 * @cfg_op_channel : Whether op_channel is hardcoded in configuration 2268 * Returns: 0 on success, -1 on failure 2269 */ 2270 int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel, 2271 int cfg_op_channel); 2272 2273 /** 2274 * p2p_set_pref_chan - Set P2P preferred channel list 2275 * @p2p: P2P module context from p2p_init() 2276 * @num_pref_chan: Number of entries in pref_chan list 2277 * @pref_chan: Preferred channels or %NULL to remove preferences 2278 * Returns: 0 on success, -1 on failure 2279 */ 2280 int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan, 2281 const struct p2p_channel *pref_chan); 2282 2283 /** 2284 * p2p_set_no_go_freq - Set no GO channel ranges 2285 * @p2p: P2P module context from p2p_init() 2286 * @list: Channel ranges or %NULL to remove restriction 2287 * Returns: 0 on success, -1 on failure 2288 */ 2289 int p2p_set_no_go_freq(struct p2p_data *p2p, 2290 const struct wpa_freq_range_list *list); 2291 2292 /** 2293 * p2p_in_progress - Check whether a P2P operation is progress 2294 * @p2p: P2P module context from p2p_init() 2295 * Returns: 0 if P2P module is idle, 1 if an operation is in progress but not 2296 * in search state, or 2 if search state operation is in progress 2297 */ 2298 int p2p_in_progress(struct p2p_data *p2p); 2299 2300 const char * p2p_wps_method_text(enum p2p_wps_method method); 2301 2302 /** 2303 * p2p_set_config_timeout - Set local config timeouts 2304 * @p2p: P2P module context from p2p_init() 2305 * @go_timeout: Time in 10 ms units it takes to start the GO mode 2306 * @client_timeout: Time in 10 ms units it takes to start the client mode 2307 */ 2308 void p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout, 2309 u8 client_timeout); 2310 2311 int p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie); 2312 int p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie); 2313 int p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie); 2314 int p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie); 2315 int p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie); 2316 int p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie); 2317 int p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie); 2318 int p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie); 2319 int p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem); 2320 int p2p_set_wfd_r2_dev_info(struct p2p_data *p2p, const struct wpabuf *elem); 2321 int p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem); 2322 int p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p, 2323 const struct wpabuf *elem); 2324 struct wpabuf * wifi_display_encaps(struct wpabuf *subelems); 2325 2326 #ifdef CONFIG_OPEN_HARMONY_P2P_DEV_NOTIFY 2327 int is_pvt_wfd_elems_valid(); 2328 void wfd_add_pvt_elem_hex(char **wfd_dev_info_hex); 2329 #endif 2330 /** 2331 * p2p_set_disc_int - Set min/max discoverable interval for p2p_find 2332 * @p2p: P2P module context from p2p_init() 2333 * @min_disc_int: minDiscoverableInterval (in units of 100 TU); default 1 2334 * @max_disc_int: maxDiscoverableInterval (in units of 100 TU); default 3 2335 * @max_disc_tu: Maximum number of TUs (1.024 ms) for discoverable interval; or 2336 * -1 not to limit 2337 * Returns: 0 on success, or -1 on failure 2338 * 2339 * This function can be used to configure minDiscoverableInterval and 2340 * maxDiscoverableInterval parameters for the Listen state during device 2341 * discovery (p2p_find). A random number of 100 TU units is picked for each 2342 * Listen state iteration from [min_disc_int,max_disc_int] range. 2343 * 2344 * max_disc_tu can be used to further limit the discoverable duration. However, 2345 * it should be noted that use of this parameter is not recommended since it 2346 * would not be compliant with the P2P specification. 2347 */ 2348 int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int, 2349 int max_disc_tu); 2350 2351 /** 2352 * p2p_get_state_txt - Get current P2P state for debug purposes 2353 * @p2p: P2P module context from p2p_init() 2354 * Returns: Name of the current P2P module state 2355 * 2356 * It should be noted that the P2P module state names are internal information 2357 * and subject to change at any point, i.e., this information should be used 2358 * mainly for debugging purposes. 2359 */ 2360 const char * p2p_get_state_txt(struct p2p_data *p2p); 2361 2362 struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p, 2363 int client_freq, 2364 const u8 *go_dev_addr, 2365 const u8 *ssid, size_t ssid_len); 2366 struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p, 2367 int client_freq, 2368 const u8 *go_dev_addr, 2369 const u8 *ssid, size_t ssid_len); 2370 2371 bool p2p_pref_freq_allowed(const struct weighted_pcl *freq_list, bool go); 2372 2373 struct p2p_nfc_params { 2374 int sel; 2375 const u8 *wsc_attr; 2376 size_t wsc_len; 2377 const u8 *p2p_attr; 2378 size_t p2p_len; 2379 2380 enum { 2381 NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG, 2382 BOTH_GO, PEER_CLIENT 2383 } next_step; 2384 struct p2p_peer_info *peer; 2385 u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 + 2386 WPS_OOB_DEVICE_PASSWORD_LEN]; 2387 size_t oob_dev_pw_len; 2388 int go_freq; 2389 u8 go_dev_addr[ETH_ALEN]; 2390 u8 go_ssid[SSID_MAX_LEN]; 2391 size_t go_ssid_len; 2392 }; 2393 2394 int p2p_process_nfc_connection_handover(struct p2p_data *p2p, 2395 struct p2p_nfc_params *params); 2396 2397 void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id, 2398 int go_intent, 2399 const u8 *own_interface_addr); 2400 2401 int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len); 2402 2403 void p2p_loop_on_known_peers(struct p2p_data *p2p, 2404 void (*peer_callback)(struct p2p_peer_info *peer, 2405 void *user_data), 2406 void *user_data); 2407 2408 void p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem); 2409 2410 #ifdef HARMONY_P2P_CONNECTIVITY_PATCH 2411 int p2p_is_concurrents(struct p2p_data *p2p); 2412 int p2p_get_process_go_neg_opt(struct p2p_data * p2p); 2413 int p2p_get_enable_go_neg_opt(struct p2p_data * p2p); 2414 void p2p_set_process_go_neg_opt(struct p2p_data * p2p, int status); 2415 void p2p_set_enable_go_neg_opt(struct p2p_data * p2p, int status); 2416 #endif 2417 2418 2419 #ifdef HARMONY_CONNECTIVITY_PATCH 2420 #ifndef OPEN_HARMONY_MIRACAST_SINK_OPT 2421 int p2p_get_persistent_group_need_remove_flag(struct p2p_data *p2p); 2422 void p2p_set_persistent_group_need_remove_flag(struct p2p_data *p2p, int value); 2423 #endif 2424 #endif 2425 2426 void p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr); 2427 2428 struct p2ps_advertisement * 2429 p2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id); 2430 int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id, 2431 const char *adv_str, u8 svc_state, 2432 u16 config_methods, const char *svc_info, 2433 const u8 *cpt_priority); 2434 int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id); 2435 void p2p_service_flush_asp(struct p2p_data *p2p); 2436 struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p); 2437 2438 /** 2439 * p2p_expire_peers - Periodic cleanup function to expire peers 2440 * @p2p: P2P module context from p2p_init() 2441 * 2442 * This is a cleanup function that the entity calling p2p_init() is 2443 * expected to call periodically to clean up expired peer entries. 2444 */ 2445 void p2p_expire_peers(struct p2p_data *p2p); 2446 2447 void p2p_set_own_pref_freq_list(struct p2p_data *p2p, 2448 const struct weighted_pcl *pref_freq_list, 2449 unsigned int size); 2450 void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class, 2451 u8 chan); 2452 2453 /** 2454 * p2p_group_get_common_freqs - Get the group common frequencies 2455 * @group: P2P group context from p2p_group_init() 2456 * @common_freqs: On return will hold the group common frequencies 2457 * @num: On return will hold the number of group common frequencies 2458 * Returns: 0 on success, -1 otherwise 2459 */ 2460 int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs, 2461 unsigned int *num); 2462 2463 struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p, 2464 unsigned int freq); 2465 2466 void p2p_set_6ghz_dev_capab(struct p2p_data *p2p, bool allow_6ghz); 2467 bool is_p2p_6ghz_capable(struct p2p_data *p2p); 2468 bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr); 2469 bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr); 2470 bool p2p_wfd_enabled(struct p2p_data *p2p); 2471 bool is_p2p_allow_6ghz(struct p2p_data *p2p); 2472 void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value); 2473 int p2p_remove_6ghz_channels(struct weighted_pcl *pref_freq_list, int size); 2474 int p2p_channel_to_freq(int op_class, int channel); 2475 2476 #if defined(CONFIG_OPEN_HARMONY_PATCH) && defined(OPEN_HARMONY_MIRACAST_SINK_OPT) 2477 void p2p_ext_listen_timeout(void *eloop_ctx, void *timeout_ctx); 2478 #endif 2479 2480 #endif /* P2P_H */ 2481