1f05cddf9SRui Paulo /* 2f05cddf9SRui Paulo * Wi-Fi Direct - P2P module 3f05cddf9SRui Paulo * Copyright (c) 2009-2010, Atheros Communications 4f05cddf9SRui Paulo * 5f05cddf9SRui Paulo * This software may be distributed under the terms of the BSD license. 6f05cddf9SRui Paulo * See README for more details. 7f05cddf9SRui Paulo */ 8f05cddf9SRui Paulo 9f05cddf9SRui Paulo #ifndef P2P_H 10f05cddf9SRui Paulo #define P2P_H 11f05cddf9SRui Paulo 12325151a3SRui Paulo #include "common/ieee802_11_defs.h" 13325151a3SRui Paulo #include "wps/wps.h" 145b9c547cSRui Paulo 15*a90b9d01SCy Schubert struct weighted_pcl; 16*a90b9d01SCy Schubert 175b9c547cSRui Paulo /* P2P ASP Setup Capability */ 185b9c547cSRui Paulo #define P2PS_SETUP_NONE 0 195b9c547cSRui Paulo #define P2PS_SETUP_NEW BIT(0) 205b9c547cSRui Paulo #define P2PS_SETUP_CLIENT BIT(1) 215b9c547cSRui Paulo #define P2PS_SETUP_GROUP_OWNER BIT(2) 225b9c547cSRui Paulo 235b9c547cSRui Paulo #define P2PS_WILD_HASH_STR "org.wi-fi.wfds" 245b9c547cSRui Paulo #define P2PS_HASH_LEN 6 255b9c547cSRui Paulo #define P2P_MAX_QUERY_HASH 6 26325151a3SRui Paulo #define P2PS_FEATURE_CAPAB_CPT_MAX 2 27325151a3SRui Paulo 28325151a3SRui Paulo /** 29325151a3SRui Paulo * P2P_MAX_PREF_CHANNELS - Maximum number of preferred channels 30325151a3SRui Paulo */ 31325151a3SRui Paulo #define P2P_MAX_PREF_CHANNELS 100 325b9c547cSRui Paulo 33f05cddf9SRui Paulo /** 34f05cddf9SRui Paulo * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes 35f05cddf9SRui Paulo */ 36780fb4a2SCy Schubert #define P2P_MAX_REG_CLASSES 15 37f05cddf9SRui Paulo 38f05cddf9SRui Paulo /** 39f05cddf9SRui Paulo * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class 40f05cddf9SRui Paulo */ 41c1d255d3SCy Schubert #define P2P_MAX_REG_CLASS_CHANNELS 60 42f05cddf9SRui Paulo 43f05cddf9SRui Paulo /** 44f05cddf9SRui Paulo * struct p2p_channels - List of supported channels 45f05cddf9SRui Paulo */ 46f05cddf9SRui Paulo struct p2p_channels { 47f05cddf9SRui Paulo /** 48f05cddf9SRui Paulo * struct p2p_reg_class - Supported regulatory class 49f05cddf9SRui Paulo */ 50f05cddf9SRui Paulo struct p2p_reg_class { 51f05cddf9SRui Paulo /** 52f05cddf9SRui Paulo * reg_class - Regulatory class (IEEE 802.11-2007, Annex J) 53f05cddf9SRui Paulo */ 54f05cddf9SRui Paulo u8 reg_class; 55f05cddf9SRui Paulo 56f05cddf9SRui Paulo /** 57f05cddf9SRui Paulo * channel - Supported channels 58f05cddf9SRui Paulo */ 59f05cddf9SRui Paulo u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; 60f05cddf9SRui Paulo 61f05cddf9SRui Paulo /** 62f05cddf9SRui Paulo * channels - Number of channel entries in use 63f05cddf9SRui Paulo */ 64f05cddf9SRui Paulo size_t channels; 65f05cddf9SRui Paulo } reg_class[P2P_MAX_REG_CLASSES]; 66f05cddf9SRui Paulo 67f05cddf9SRui Paulo /** 68f05cddf9SRui Paulo * reg_classes - Number of reg_class entries in use 69f05cddf9SRui Paulo */ 70f05cddf9SRui Paulo size_t reg_classes; 71f05cddf9SRui Paulo }; 72f05cddf9SRui Paulo 73f05cddf9SRui Paulo enum p2p_wps_method { 745b9c547cSRui Paulo WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC, 755b9c547cSRui Paulo WPS_P2PS 76f05cddf9SRui Paulo }; 77f05cddf9SRui Paulo 78f05cddf9SRui Paulo /** 79f05cddf9SRui Paulo * struct p2p_go_neg_results - P2P Group Owner Negotiation results 80f05cddf9SRui Paulo */ 81f05cddf9SRui Paulo struct p2p_go_neg_results { 82f05cddf9SRui Paulo /** 83f05cddf9SRui Paulo * status - Negotiation result (Status Code) 84f05cddf9SRui Paulo * 85f05cddf9SRui Paulo * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate 86f05cddf9SRui Paulo * failed negotiation. 87f05cddf9SRui Paulo */ 88f05cddf9SRui Paulo int status; 89f05cddf9SRui Paulo 90f05cddf9SRui Paulo /** 91f05cddf9SRui Paulo * role_go - Whether local end is Group Owner 92f05cddf9SRui Paulo */ 93f05cddf9SRui Paulo int role_go; 94f05cddf9SRui Paulo 95f05cddf9SRui Paulo /** 96f05cddf9SRui Paulo * freq - Frequency of the group operational channel in MHz 97f05cddf9SRui Paulo */ 98f05cddf9SRui Paulo int freq; 99f05cddf9SRui Paulo 100f05cddf9SRui Paulo int ht40; 101f05cddf9SRui Paulo 1025b9c547cSRui Paulo int vht; 1035b9c547cSRui Paulo 104c1d255d3SCy Schubert int edmg; 105c1d255d3SCy Schubert 106780fb4a2SCy Schubert u8 max_oper_chwidth; 107780fb4a2SCy Schubert 108780fb4a2SCy Schubert unsigned int vht_center_freq2; 109780fb4a2SCy Schubert 110f05cddf9SRui Paulo /** 1114bc52338SCy Schubert * he - Indicates if IEEE 802.11ax HE is enabled 1124bc52338SCy Schubert */ 1134bc52338SCy Schubert int he; 1144bc52338SCy Schubert 1154bc52338SCy Schubert /** 116f05cddf9SRui Paulo * ssid - SSID of the group 117f05cddf9SRui Paulo */ 118325151a3SRui Paulo u8 ssid[SSID_MAX_LEN]; 119f05cddf9SRui Paulo 120f05cddf9SRui Paulo /** 121f05cddf9SRui Paulo * ssid_len - Length of SSID in octets 122f05cddf9SRui Paulo */ 123f05cddf9SRui Paulo size_t ssid_len; 124f05cddf9SRui Paulo 125f05cddf9SRui Paulo /** 126f05cddf9SRui Paulo * psk - WPA pre-shared key (256 bits) (GO only) 127f05cddf9SRui Paulo */ 128f05cddf9SRui Paulo u8 psk[32]; 129f05cddf9SRui Paulo 130f05cddf9SRui Paulo /** 131f05cddf9SRui Paulo * psk_set - Whether PSK field is configured (GO only) 132f05cddf9SRui Paulo */ 133f05cddf9SRui Paulo int psk_set; 134f05cddf9SRui Paulo 135f05cddf9SRui Paulo /** 136f05cddf9SRui Paulo * passphrase - WPA2-Personal passphrase for the group (GO only) 137f05cddf9SRui Paulo */ 138f05cddf9SRui Paulo char passphrase[64]; 139f05cddf9SRui Paulo 140f05cddf9SRui Paulo /** 141f05cddf9SRui Paulo * peer_device_addr - P2P Device Address of the peer 142f05cddf9SRui Paulo */ 143f05cddf9SRui Paulo u8 peer_device_addr[ETH_ALEN]; 144f05cddf9SRui Paulo 145f05cddf9SRui Paulo /** 146f05cddf9SRui Paulo * peer_interface_addr - P2P Interface Address of the peer 147f05cddf9SRui Paulo */ 148f05cddf9SRui Paulo u8 peer_interface_addr[ETH_ALEN]; 149f05cddf9SRui Paulo 150f05cddf9SRui Paulo /** 151f05cddf9SRui Paulo * wps_method - WPS method to be used during provisioning 152f05cddf9SRui Paulo */ 153f05cddf9SRui Paulo enum p2p_wps_method wps_method; 154f05cddf9SRui Paulo 155f05cddf9SRui Paulo #define P2P_MAX_CHANNELS 50 156f05cddf9SRui Paulo 157f05cddf9SRui Paulo /** 158f05cddf9SRui Paulo * freq_list - Zero-terminated list of possible operational channels 159f05cddf9SRui Paulo */ 160f05cddf9SRui Paulo int freq_list[P2P_MAX_CHANNELS]; 161f05cddf9SRui Paulo 162f05cddf9SRui Paulo /** 163f05cddf9SRui Paulo * persistent_group - Whether the group should be made persistent 164f05cddf9SRui Paulo * 0 = not persistent 165f05cddf9SRui Paulo * 1 = persistent group without persistent reconnect 166f05cddf9SRui Paulo * 2 = persistent group with persistent reconnect 167f05cddf9SRui Paulo */ 168f05cddf9SRui Paulo int persistent_group; 169f05cddf9SRui Paulo 170f05cddf9SRui Paulo /** 171f05cddf9SRui Paulo * peer_config_timeout - Peer configuration timeout (in 10 msec units) 172f05cddf9SRui Paulo */ 173f05cddf9SRui Paulo unsigned int peer_config_timeout; 174f05cddf9SRui Paulo }; 175f05cddf9SRui Paulo 1765b9c547cSRui Paulo struct p2ps_provision { 1775b9c547cSRui Paulo /** 178325151a3SRui Paulo * pd_seeker - P2PS provision discovery seeker role 179325151a3SRui Paulo */ 180325151a3SRui Paulo unsigned int pd_seeker:1; 181325151a3SRui Paulo 182325151a3SRui Paulo /** 1835b9c547cSRui Paulo * status - Remote returned provisioning status code 1845b9c547cSRui Paulo */ 1855b9c547cSRui Paulo int status; 1865b9c547cSRui Paulo 1875b9c547cSRui Paulo /** 1885b9c547cSRui Paulo * adv_id - P2PS Advertisement ID 1895b9c547cSRui Paulo */ 1905b9c547cSRui Paulo u32 adv_id; 1915b9c547cSRui Paulo 1925b9c547cSRui Paulo /** 1935b9c547cSRui Paulo * session_id - P2PS Session ID 1945b9c547cSRui Paulo */ 1955b9c547cSRui Paulo u32 session_id; 1965b9c547cSRui Paulo 1975b9c547cSRui Paulo /** 1985b9c547cSRui Paulo * method - WPS Method (to be) used to establish session 1995b9c547cSRui Paulo */ 2005b9c547cSRui Paulo u16 method; 2015b9c547cSRui Paulo 2025b9c547cSRui Paulo /** 2035b9c547cSRui Paulo * conncap - Connection Capabilities negotiated between P2P peers 2045b9c547cSRui Paulo */ 2055b9c547cSRui Paulo u8 conncap; 2065b9c547cSRui Paulo 2075b9c547cSRui Paulo /** 2085b9c547cSRui Paulo * role - Info about the roles to be used for this connection 2095b9c547cSRui Paulo */ 2105b9c547cSRui Paulo u8 role; 2115b9c547cSRui Paulo 2125b9c547cSRui Paulo /** 2135b9c547cSRui Paulo * session_mac - MAC address of the peer that started the session 2145b9c547cSRui Paulo */ 2155b9c547cSRui Paulo u8 session_mac[ETH_ALEN]; 2165b9c547cSRui Paulo 2175b9c547cSRui Paulo /** 2185b9c547cSRui Paulo * adv_mac - MAC address of the peer advertised the service 2195b9c547cSRui Paulo */ 2205b9c547cSRui Paulo u8 adv_mac[ETH_ALEN]; 2215b9c547cSRui Paulo 2225b9c547cSRui Paulo /** 223325151a3SRui Paulo * cpt_mask - Supported Coordination Protocol Transport mask 224325151a3SRui Paulo * 225325151a3SRui Paulo * A bitwise mask of supported ASP Coordination Protocol Transports. 226325151a3SRui Paulo * This property is set together and corresponds with cpt_priority. 227325151a3SRui Paulo */ 228325151a3SRui Paulo u8 cpt_mask; 229325151a3SRui Paulo 230325151a3SRui Paulo /** 231325151a3SRui Paulo * cpt_priority - Coordination Protocol Transport priority list 232325151a3SRui Paulo * 233325151a3SRui Paulo * Priorities of supported ASP Coordination Protocol Transports. 234325151a3SRui Paulo * This property is set together and corresponds with cpt_mask. 235325151a3SRui Paulo * The CPT priority list is 0 terminated. 236325151a3SRui Paulo */ 237325151a3SRui Paulo u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; 238325151a3SRui Paulo 239325151a3SRui Paulo /** 240780fb4a2SCy Schubert * force_freq - The only allowed channel frequency in MHz or 0. 241780fb4a2SCy Schubert */ 242780fb4a2SCy Schubert unsigned int force_freq; 243780fb4a2SCy Schubert 244780fb4a2SCy Schubert /** 245780fb4a2SCy Schubert * pref_freq - Preferred operating frequency in MHz or 0. 246780fb4a2SCy Schubert */ 247780fb4a2SCy Schubert unsigned int pref_freq; 248780fb4a2SCy Schubert 249780fb4a2SCy Schubert /** 2505b9c547cSRui Paulo * info - Vendor defined extra Provisioning information 2515b9c547cSRui Paulo */ 2525b9c547cSRui Paulo char info[0]; 2535b9c547cSRui Paulo }; 2545b9c547cSRui Paulo 2555b9c547cSRui Paulo struct p2ps_advertisement { 2565b9c547cSRui Paulo struct p2ps_advertisement *next; 2575b9c547cSRui Paulo 2585b9c547cSRui Paulo /** 2595b9c547cSRui Paulo * svc_info - Pointer to (internal) Service defined information 2605b9c547cSRui Paulo */ 2615b9c547cSRui Paulo char *svc_info; 2625b9c547cSRui Paulo 2635b9c547cSRui Paulo /** 2645b9c547cSRui Paulo * id - P2PS Advertisement ID 2655b9c547cSRui Paulo */ 2665b9c547cSRui Paulo u32 id; 2675b9c547cSRui Paulo 2685b9c547cSRui Paulo /** 2695b9c547cSRui Paulo * config_methods - WPS Methods which are allowed for this service 2705b9c547cSRui Paulo */ 2715b9c547cSRui Paulo u16 config_methods; 2725b9c547cSRui Paulo 2735b9c547cSRui Paulo /** 2745b9c547cSRui Paulo * state - Current state of the service: 0 - Out Of Service, 1-255 Vendor defined 2755b9c547cSRui Paulo */ 2765b9c547cSRui Paulo u8 state; 2775b9c547cSRui Paulo 2785b9c547cSRui Paulo /** 2795b9c547cSRui Paulo * auto_accept - Automatically Accept provisioning request if possible. 2805b9c547cSRui Paulo */ 2815b9c547cSRui Paulo u8 auto_accept; 2825b9c547cSRui Paulo 2835b9c547cSRui Paulo /** 2845b9c547cSRui Paulo * hash - 6 octet Service Name has to match against incoming Probe Requests 2855b9c547cSRui Paulo */ 2865b9c547cSRui Paulo u8 hash[P2PS_HASH_LEN]; 2875b9c547cSRui Paulo 2885b9c547cSRui Paulo /** 289325151a3SRui Paulo * cpt_mask - supported Coordination Protocol Transport mask 290325151a3SRui Paulo * 291325151a3SRui Paulo * A bitwise mask of supported ASP Coordination Protocol Transports. 292325151a3SRui Paulo * This property is set together and corresponds with cpt_priority. 293325151a3SRui Paulo */ 294325151a3SRui Paulo u8 cpt_mask; 295325151a3SRui Paulo 296325151a3SRui Paulo /** 297325151a3SRui Paulo * cpt_priority - Coordination Protocol Transport priority list 298325151a3SRui Paulo * 299325151a3SRui Paulo * Priorities of supported ASP Coordinatin Protocol Transports. 300325151a3SRui Paulo * This property is set together and corresponds with cpt_mask. 301325151a3SRui Paulo * The CPT priority list is 0 terminated. 302325151a3SRui Paulo */ 303325151a3SRui Paulo u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; 304325151a3SRui Paulo 305325151a3SRui Paulo /** 3065b9c547cSRui Paulo * svc_name - NULL Terminated UTF-8 Service Name, and svc_info storage 3075b9c547cSRui Paulo */ 3085b9c547cSRui Paulo char svc_name[0]; 3095b9c547cSRui Paulo }; 3105b9c547cSRui Paulo 3115b9c547cSRui Paulo 312f05cddf9SRui Paulo struct p2p_data; 313f05cddf9SRui Paulo 314f05cddf9SRui Paulo enum p2p_scan_type { 315f05cddf9SRui Paulo P2P_SCAN_SOCIAL, 316f05cddf9SRui Paulo P2P_SCAN_FULL, 3175b9c547cSRui Paulo P2P_SCAN_SPECIFIC, 318f05cddf9SRui Paulo P2P_SCAN_SOCIAL_PLUS_ONE 319f05cddf9SRui Paulo }; 320f05cddf9SRui Paulo 321f05cddf9SRui Paulo #define P2P_MAX_WPS_VENDOR_EXT 10 322f05cddf9SRui Paulo 323f05cddf9SRui Paulo /** 324f05cddf9SRui Paulo * struct p2p_peer_info - P2P peer information 325f05cddf9SRui Paulo */ 326f05cddf9SRui Paulo struct p2p_peer_info { 327f05cddf9SRui Paulo /** 328f05cddf9SRui Paulo * p2p_device_addr - P2P Device Address of the peer 329f05cddf9SRui Paulo */ 330f05cddf9SRui Paulo u8 p2p_device_addr[ETH_ALEN]; 331f05cddf9SRui Paulo 332f05cddf9SRui Paulo /** 333f05cddf9SRui Paulo * pri_dev_type - Primary Device Type 334f05cddf9SRui Paulo */ 335f05cddf9SRui Paulo u8 pri_dev_type[8]; 336f05cddf9SRui Paulo 337f05cddf9SRui Paulo /** 338f05cddf9SRui Paulo * device_name - Device Name (0..32 octets encoded in UTF-8) 339f05cddf9SRui Paulo */ 340325151a3SRui Paulo char device_name[WPS_DEV_NAME_MAX_LEN + 1]; 341f05cddf9SRui Paulo 342f05cddf9SRui Paulo /** 343f05cddf9SRui Paulo * manufacturer - Manufacturer (0..64 octets encoded in UTF-8) 344f05cddf9SRui Paulo */ 345325151a3SRui Paulo char manufacturer[WPS_MANUFACTURER_MAX_LEN + 1]; 346f05cddf9SRui Paulo 347f05cddf9SRui Paulo /** 348f05cddf9SRui Paulo * model_name - Model Name (0..32 octets encoded in UTF-8) 349f05cddf9SRui Paulo */ 350325151a3SRui Paulo char model_name[WPS_MODEL_NAME_MAX_LEN + 1]; 351f05cddf9SRui Paulo 352f05cddf9SRui Paulo /** 353f05cddf9SRui Paulo * model_number - Model Number (0..32 octets encoded in UTF-8) 354f05cddf9SRui Paulo */ 355325151a3SRui Paulo char model_number[WPS_MODEL_NUMBER_MAX_LEN + 1]; 356f05cddf9SRui Paulo 357f05cddf9SRui Paulo /** 358f05cddf9SRui Paulo * serial_number - Serial Number (0..32 octets encoded in UTF-8) 359f05cddf9SRui Paulo */ 360325151a3SRui Paulo char serial_number[WPS_SERIAL_NUMBER_MAX_LEN + 1]; 361f05cddf9SRui Paulo 362f05cddf9SRui Paulo /** 363f05cddf9SRui Paulo * level - Signal level 364f05cddf9SRui Paulo */ 365f05cddf9SRui Paulo int level; 366f05cddf9SRui Paulo 367f05cddf9SRui Paulo /** 368f05cddf9SRui Paulo * config_methods - WPS Configuration Methods 369f05cddf9SRui Paulo */ 370f05cddf9SRui Paulo u16 config_methods; 371f05cddf9SRui Paulo 372f05cddf9SRui Paulo /** 373f05cddf9SRui Paulo * dev_capab - Device Capabilities 374f05cddf9SRui Paulo */ 375f05cddf9SRui Paulo u8 dev_capab; 376f05cddf9SRui Paulo 377f05cddf9SRui Paulo /** 378f05cddf9SRui Paulo * group_capab - Group Capabilities 379f05cddf9SRui Paulo */ 380f05cddf9SRui Paulo u8 group_capab; 381f05cddf9SRui Paulo 382f05cddf9SRui Paulo /** 383f05cddf9SRui Paulo * wps_sec_dev_type_list - WPS secondary device type list 384f05cddf9SRui Paulo * 385f05cddf9SRui Paulo * This list includes from 0 to 16 Secondary Device Types as indicated 386f05cddf9SRui Paulo * by wps_sec_dev_type_list_len (8 * number of types). 387f05cddf9SRui Paulo */ 388325151a3SRui Paulo u8 wps_sec_dev_type_list[WPS_SEC_DEV_TYPE_MAX_LEN]; 389f05cddf9SRui Paulo 390f05cddf9SRui Paulo /** 391f05cddf9SRui Paulo * wps_sec_dev_type_list_len - Length of secondary device type list 392f05cddf9SRui Paulo */ 393f05cddf9SRui Paulo size_t wps_sec_dev_type_list_len; 394f05cddf9SRui Paulo 395f05cddf9SRui Paulo struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; 396f05cddf9SRui Paulo 397f05cddf9SRui Paulo /** 398f05cddf9SRui Paulo * wfd_subelems - Wi-Fi Display subelements from WFD IE(s) 399f05cddf9SRui Paulo */ 400f05cddf9SRui Paulo struct wpabuf *wfd_subelems; 4015b9c547cSRui Paulo 4025b9c547cSRui Paulo /** 4035b9c547cSRui Paulo * vendor_elems - Unrecognized vendor elements 4045b9c547cSRui Paulo * 4055b9c547cSRui Paulo * This buffer includes any other vendor element than P2P, WPS, and WFD 4065b9c547cSRui Paulo * IE(s) from the frame that was used to discover the peer. 4075b9c547cSRui Paulo */ 4085b9c547cSRui Paulo struct wpabuf *vendor_elems; 4095b9c547cSRui Paulo 4105b9c547cSRui Paulo /** 4115b9c547cSRui Paulo * p2ps_instance - P2PS Application Service Info 4125b9c547cSRui Paulo */ 4135b9c547cSRui Paulo struct wpabuf *p2ps_instance; 414f05cddf9SRui Paulo }; 415f05cddf9SRui Paulo 416f05cddf9SRui Paulo enum p2p_prov_disc_status { 417f05cddf9SRui Paulo P2P_PROV_DISC_SUCCESS, 418f05cddf9SRui Paulo P2P_PROV_DISC_TIMEOUT, 419f05cddf9SRui Paulo P2P_PROV_DISC_REJECTED, 420f05cddf9SRui Paulo P2P_PROV_DISC_TIMEOUT_JOIN, 4215b9c547cSRui Paulo P2P_PROV_DISC_INFO_UNAVAILABLE, 422f05cddf9SRui Paulo }; 423f05cddf9SRui Paulo 424f05cddf9SRui Paulo struct p2p_channel { 425f05cddf9SRui Paulo u8 op_class; 426f05cddf9SRui Paulo u8 chan; 427f05cddf9SRui Paulo }; 428f05cddf9SRui Paulo 429f05cddf9SRui Paulo /** 430f05cddf9SRui Paulo * struct p2p_config - P2P configuration 431f05cddf9SRui Paulo * 432f05cddf9SRui Paulo * This configuration is provided to the P2P module during initialization with 433f05cddf9SRui Paulo * p2p_init(). 434f05cddf9SRui Paulo */ 435f05cddf9SRui Paulo struct p2p_config { 436f05cddf9SRui Paulo /** 437f05cddf9SRui Paulo * country - Country code to use in P2P operations 438f05cddf9SRui Paulo */ 439f05cddf9SRui Paulo char country[3]; 440f05cddf9SRui Paulo 441f05cddf9SRui Paulo /** 442f05cddf9SRui Paulo * reg_class - Regulatory class for own listen channel 443f05cddf9SRui Paulo */ 444f05cddf9SRui Paulo u8 reg_class; 445f05cddf9SRui Paulo 446f05cddf9SRui Paulo /** 447f05cddf9SRui Paulo * channel - Own listen channel 448f05cddf9SRui Paulo */ 449f05cddf9SRui Paulo u8 channel; 450f05cddf9SRui Paulo 451f05cddf9SRui Paulo /** 4525b9c547cSRui Paulo * channel_forced - the listen channel was forced by configuration 4535b9c547cSRui Paulo * or by control interface and cannot be overridden 4545b9c547cSRui Paulo */ 4555b9c547cSRui Paulo u8 channel_forced; 4565b9c547cSRui Paulo 4575b9c547cSRui Paulo /** 458f05cddf9SRui Paulo * Regulatory class for own operational channel 459f05cddf9SRui Paulo */ 460f05cddf9SRui Paulo u8 op_reg_class; 461f05cddf9SRui Paulo 462f05cddf9SRui Paulo /** 463f05cddf9SRui Paulo * op_channel - Own operational channel 464f05cddf9SRui Paulo */ 465f05cddf9SRui Paulo u8 op_channel; 466f05cddf9SRui Paulo 467f05cddf9SRui Paulo /** 468f05cddf9SRui Paulo * cfg_op_channel - Whether op_channel is hardcoded in configuration 469f05cddf9SRui Paulo */ 470f05cddf9SRui Paulo u8 cfg_op_channel; 471f05cddf9SRui Paulo 472f05cddf9SRui Paulo /** 473f05cddf9SRui Paulo * channels - Own supported regulatory classes and channels 474f05cddf9SRui Paulo * 475f05cddf9SRui Paulo * List of supposerted channels per regulatory class. The regulatory 476f05cddf9SRui Paulo * classes are defined in IEEE Std 802.11-2007 Annex J and the 477f05cddf9SRui Paulo * numbering of the clases depends on the configured country code. 478f05cddf9SRui Paulo */ 479f05cddf9SRui Paulo struct p2p_channels channels; 480f05cddf9SRui Paulo 481f05cddf9SRui Paulo /** 4825b9c547cSRui Paulo * cli_channels - Additional client channels 4835b9c547cSRui Paulo * 4845b9c547cSRui Paulo * This list of channels (if any) will be used when advertising local 4855b9c547cSRui Paulo * channels during GO Negotiation or Invitation for the cases where the 4865b9c547cSRui Paulo * local end may become the client. This may allow the peer to become a 4875b9c547cSRui Paulo * GO on additional channels if it supports these options. The main use 4885b9c547cSRui Paulo * case for this is to include passive-scan channels on devices that may 4895b9c547cSRui Paulo * not know their current location and have configured most channels to 4905b9c547cSRui Paulo * not allow initiation of radition (i.e., another device needs to take 4915b9c547cSRui Paulo * master responsibilities). 4925b9c547cSRui Paulo */ 4935b9c547cSRui Paulo struct p2p_channels cli_channels; 4945b9c547cSRui Paulo 4955b9c547cSRui Paulo /** 496f05cddf9SRui Paulo * num_pref_chan - Number of pref_chan entries 497f05cddf9SRui Paulo */ 498f05cddf9SRui Paulo unsigned int num_pref_chan; 499f05cddf9SRui Paulo 500f05cddf9SRui Paulo /** 501f05cddf9SRui Paulo * pref_chan - Preferred channels for GO Negotiation 502f05cddf9SRui Paulo */ 503f05cddf9SRui Paulo struct p2p_channel *pref_chan; 504f05cddf9SRui Paulo 505f05cddf9SRui Paulo /** 506c1d255d3SCy Schubert * p2p_6ghz_disable - Disable 6GHz for P2P operations 507c1d255d3SCy Schubert */ 508c1d255d3SCy Schubert bool p2p_6ghz_disable; 509c1d255d3SCy Schubert 510c1d255d3SCy Schubert /** 511f05cddf9SRui Paulo * pri_dev_type - Primary Device Type (see WPS) 512f05cddf9SRui Paulo */ 513f05cddf9SRui Paulo u8 pri_dev_type[8]; 514f05cddf9SRui Paulo 515f05cddf9SRui Paulo /** 516f05cddf9SRui Paulo * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types 517f05cddf9SRui Paulo */ 518f05cddf9SRui Paulo #define P2P_SEC_DEVICE_TYPES 5 519f05cddf9SRui Paulo 520f05cddf9SRui Paulo /** 521f05cddf9SRui Paulo * sec_dev_type - Optional secondary device types 522f05cddf9SRui Paulo */ 523f05cddf9SRui Paulo u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8]; 524f05cddf9SRui Paulo 525f05cddf9SRui Paulo /** 526f05cddf9SRui Paulo * num_sec_dev_types - Number of sec_dev_type entries 527f05cddf9SRui Paulo */ 528f05cddf9SRui Paulo size_t num_sec_dev_types; 529f05cddf9SRui Paulo 530f05cddf9SRui Paulo /** 531f05cddf9SRui Paulo * dev_addr - P2P Device Address 532f05cddf9SRui Paulo */ 533f05cddf9SRui Paulo u8 dev_addr[ETH_ALEN]; 534f05cddf9SRui Paulo 535f05cddf9SRui Paulo /** 536f05cddf9SRui Paulo * dev_name - Device Name 537f05cddf9SRui Paulo */ 538f05cddf9SRui Paulo char *dev_name; 539f05cddf9SRui Paulo 540f05cddf9SRui Paulo char *manufacturer; 541f05cddf9SRui Paulo char *model_name; 542f05cddf9SRui Paulo char *model_number; 543f05cddf9SRui Paulo char *serial_number; 544f05cddf9SRui Paulo 545f05cddf9SRui Paulo u8 uuid[16]; 546f05cddf9SRui Paulo u16 config_methods; 547f05cddf9SRui Paulo 548f05cddf9SRui Paulo /** 549f05cddf9SRui Paulo * concurrent_operations - Whether concurrent operations are supported 550f05cddf9SRui Paulo */ 551f05cddf9SRui Paulo int concurrent_operations; 552f05cddf9SRui Paulo 553f05cddf9SRui Paulo /** 554f05cddf9SRui Paulo * max_peers - Maximum number of discovered peers to remember 555f05cddf9SRui Paulo * 556f05cddf9SRui Paulo * If more peers are discovered, older entries will be removed to make 557f05cddf9SRui Paulo * room for the new ones. 558f05cddf9SRui Paulo */ 559f05cddf9SRui Paulo size_t max_peers; 560f05cddf9SRui Paulo 561f05cddf9SRui Paulo /** 562f05cddf9SRui Paulo * p2p_intra_bss - Intra BSS communication is supported 563f05cddf9SRui Paulo */ 564f05cddf9SRui Paulo int p2p_intra_bss; 565f05cddf9SRui Paulo 566f05cddf9SRui Paulo /** 567f05cddf9SRui Paulo * ssid_postfix - Postfix data to add to the SSID 568f05cddf9SRui Paulo * 569f05cddf9SRui Paulo * This data will be added to the end of the SSID after the 570f05cddf9SRui Paulo * DIRECT-<random two octets> prefix. 571f05cddf9SRui Paulo */ 572325151a3SRui Paulo u8 ssid_postfix[SSID_MAX_LEN - 9]; 573f05cddf9SRui Paulo 574f05cddf9SRui Paulo /** 575f05cddf9SRui Paulo * ssid_postfix_len - Length of the ssid_postfix data 576f05cddf9SRui Paulo */ 577f05cddf9SRui Paulo size_t ssid_postfix_len; 578f05cddf9SRui Paulo 579f05cddf9SRui Paulo /** 580f05cddf9SRui Paulo * max_listen - Maximum listen duration in ms 581f05cddf9SRui Paulo */ 582f05cddf9SRui Paulo unsigned int max_listen; 583f05cddf9SRui Paulo 584f05cddf9SRui Paulo /** 5855b9c547cSRui Paulo * passphrase_len - Passphrase length (8..63) 5865b9c547cSRui Paulo * 5875b9c547cSRui Paulo * This parameter controls the length of the random passphrase that is 5885b9c547cSRui Paulo * generated at the GO. 589f05cddf9SRui Paulo */ 5905b9c547cSRui Paulo unsigned int passphrase_len; 591f05cddf9SRui Paulo 592f05cddf9SRui Paulo /** 593f05cddf9SRui Paulo * cb_ctx - Context to use with callback functions 594f05cddf9SRui Paulo */ 595f05cddf9SRui Paulo void *cb_ctx; 596f05cddf9SRui Paulo 5975b9c547cSRui Paulo /** 5985b9c547cSRui Paulo * debug_print - Debug print 5995b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 6005b9c547cSRui Paulo * @level: Debug verbosity level (MSG_*) 6015b9c547cSRui Paulo * @msg: Debug message 6025b9c547cSRui Paulo */ 6035b9c547cSRui Paulo void (*debug_print)(void *ctx, int level, const char *msg); 6045b9c547cSRui Paulo 605f05cddf9SRui Paulo 606f05cddf9SRui Paulo /* Callbacks to request lower layer driver operations */ 607f05cddf9SRui Paulo 608f05cddf9SRui Paulo /** 609f05cddf9SRui Paulo * p2p_scan - Request a P2P scan/search 610f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 611f05cddf9SRui Paulo * @type: Scan type 612f05cddf9SRui Paulo * @freq: Specific frequency (MHz) to scan or 0 for no restriction 613f05cddf9SRui Paulo * @num_req_dev_types: Number of requested device types 614f05cddf9SRui Paulo * @req_dev_types: Array containing requested device types 615f05cddf9SRui Paulo * @dev_id: Device ID to search for or %NULL to find all devices 616f05cddf9SRui Paulo * @pw_id: Device Password ID 617c1d255d3SCy Schubert * @include_6ghz: Include 6 GHz channels in P2P scan 618f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 619f05cddf9SRui Paulo * 620f05cddf9SRui Paulo * This callback function is used to request a P2P scan or search 621f05cddf9SRui Paulo * operation to be completed. Type type argument specifies which type 622f05cddf9SRui Paulo * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the 623f05cddf9SRui Paulo * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL 6245b9c547cSRui Paulo * indicates that all channels are to be scanned. @P2P_SCAN_SPECIFIC 6255b9c547cSRui Paulo * request a scan of a single channel specified by freq. 626f05cddf9SRui Paulo * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels 627f05cddf9SRui Paulo * plus one extra channel specified by freq. 628f05cddf9SRui Paulo * 629f05cddf9SRui Paulo * The full scan is used for the initial scan to find group owners from 630f05cddf9SRui Paulo * all. The other types are used during search phase scan of the social 631f05cddf9SRui Paulo * channels (with potential variation if the Listen channel of the 632f05cddf9SRui Paulo * target peer is known or if other channels are scanned in steps). 633f05cddf9SRui Paulo * 634f05cddf9SRui Paulo * The scan results are returned after this call by calling 635f05cddf9SRui Paulo * p2p_scan_res_handler() for each scan result that has a P2P IE and 636f05cddf9SRui Paulo * then calling p2p_scan_res_handled() to indicate that all scan 637f05cddf9SRui Paulo * results have been indicated. 638f05cddf9SRui Paulo */ 639f05cddf9SRui Paulo int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq, 640f05cddf9SRui Paulo unsigned int num_req_dev_types, 641c1d255d3SCy Schubert const u8 *req_dev_types, const u8 *dev_id, u16 pw_id, 642c1d255d3SCy Schubert bool include_6ghz); 643f05cddf9SRui Paulo 644f05cddf9SRui Paulo /** 645f05cddf9SRui Paulo * send_probe_resp - Transmit a Probe Response frame 646f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 647f05cddf9SRui Paulo * @buf: Probe Response frame (including the header and body) 648325151a3SRui Paulo * @freq: Forced frequency (in MHz) to use or 0. 649f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 650f05cddf9SRui Paulo * 651f05cddf9SRui Paulo * This function is used to reply to Probe Request frames that were 652f05cddf9SRui Paulo * indicated with a call to p2p_probe_req_rx(). The response is to be 653325151a3SRui Paulo * sent on the same channel, unless otherwise specified, or to be 654325151a3SRui Paulo * dropped if the driver is not listening to Probe Request frames 655325151a3SRui Paulo * anymore. 656f05cddf9SRui Paulo * 657f05cddf9SRui Paulo * Alternatively, the responsibility for building the Probe Response 658f05cddf9SRui Paulo * frames in Listen state may be in another system component in which 659f05cddf9SRui Paulo * case this function need to be implemented (i.e., the function 660f05cddf9SRui Paulo * pointer can be %NULL). The WPS and P2P IEs to be added for Probe 661f05cddf9SRui Paulo * Response frames in such a case are available from the 662f05cddf9SRui Paulo * start_listen() callback. It should be noted that the received Probe 663f05cddf9SRui Paulo * Request frames must be indicated by calling p2p_probe_req_rx() even 664f05cddf9SRui Paulo * if this send_probe_resp() is not used. 665f05cddf9SRui Paulo */ 666325151a3SRui Paulo int (*send_probe_resp)(void *ctx, const struct wpabuf *buf, 667325151a3SRui Paulo unsigned int freq); 668f05cddf9SRui Paulo 669f05cddf9SRui Paulo /** 670f05cddf9SRui Paulo * send_action - Transmit an Action frame 671f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 672f05cddf9SRui Paulo * @freq: Frequency in MHz for the channel on which to transmit 673f05cddf9SRui Paulo * @dst: Destination MAC address (Address 1) 674f05cddf9SRui Paulo * @src: Source MAC address (Address 2) 675f05cddf9SRui Paulo * @bssid: BSSID (Address 3) 676f05cddf9SRui Paulo * @buf: Frame body (starting from Category field) 677f05cddf9SRui Paulo * @len: Length of buf in octets 678f05cddf9SRui Paulo * @wait_time: How many msec to wait for a response frame 6794bc52338SCy Schubert * @scheduled: Return value indicating whether the transmissions was 6804bc52338SCy Schubert * scheduled to happen once the radio is available 681f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 682f05cddf9SRui Paulo * 683f05cddf9SRui Paulo * The Action frame may not be transmitted immediately and the status 684f05cddf9SRui Paulo * of the transmission must be reported by calling 685f05cddf9SRui Paulo * p2p_send_action_cb() once the frame has either been transmitted or 686f05cddf9SRui Paulo * it has been dropped due to excessive retries or other failure to 687f05cddf9SRui Paulo * transmit. 688f05cddf9SRui Paulo */ 689f05cddf9SRui Paulo int (*send_action)(void *ctx, unsigned int freq, const u8 *dst, 690f05cddf9SRui Paulo const u8 *src, const u8 *bssid, const u8 *buf, 6914bc52338SCy Schubert size_t len, unsigned int wait_time, int *scheduled); 692f05cddf9SRui Paulo 693f05cddf9SRui Paulo /** 694f05cddf9SRui Paulo * send_action_done - Notify that Action frame sequence was completed 695f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 696f05cddf9SRui Paulo * 697f05cddf9SRui Paulo * This function is called when the Action frame sequence that was 698f05cddf9SRui Paulo * started with send_action() has been completed, i.e., when there is 699f05cddf9SRui Paulo * no need to wait for a response from the destination peer anymore. 700f05cddf9SRui Paulo */ 701f05cddf9SRui Paulo void (*send_action_done)(void *ctx); 702f05cddf9SRui Paulo 703f05cddf9SRui Paulo /** 704f05cddf9SRui Paulo * start_listen - Start Listen state 705f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 706f05cddf9SRui Paulo * @freq: Frequency of the listen channel in MHz 707f05cddf9SRui Paulo * @duration: Duration for the Listen state in milliseconds 708f05cddf9SRui Paulo * @probe_resp_ie: IE(s) to be added to Probe Response frames 709f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 710f05cddf9SRui Paulo * 711f05cddf9SRui Paulo * This Listen state may not start immediately since the driver may 712f05cddf9SRui Paulo * have other pending operations to complete first. Once the Listen 713f05cddf9SRui Paulo * state has started, p2p_listen_cb() must be called to notify the P2P 714f05cddf9SRui Paulo * module. Once the Listen state is stopped, p2p_listen_end() must be 715f05cddf9SRui Paulo * called to notify the P2P module that the driver is not in the Listen 716f05cddf9SRui Paulo * state anymore. 717f05cddf9SRui Paulo * 718f05cddf9SRui Paulo * If the send_probe_resp() is not used for generating the response, 719f05cddf9SRui Paulo * the IEs from probe_resp_ie need to be added to the end of the Probe 720f05cddf9SRui Paulo * Response frame body. If send_probe_resp() is used, the probe_resp_ie 721f05cddf9SRui Paulo * information can be ignored. 722f05cddf9SRui Paulo */ 723f05cddf9SRui Paulo int (*start_listen)(void *ctx, unsigned int freq, 724f05cddf9SRui Paulo unsigned int duration, 725f05cddf9SRui Paulo const struct wpabuf *probe_resp_ie); 726f05cddf9SRui Paulo /** 727f05cddf9SRui Paulo * stop_listen - Stop Listen state 728f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 729f05cddf9SRui Paulo * 730f05cddf9SRui Paulo * This callback can be used to stop a Listen state operation that was 731f05cddf9SRui Paulo * previously requested with start_listen(). 732f05cddf9SRui Paulo */ 733f05cddf9SRui Paulo void (*stop_listen)(void *ctx); 734f05cddf9SRui Paulo 735f05cddf9SRui Paulo /** 736f05cddf9SRui Paulo * get_noa - Get current Notice of Absence attribute payload 737f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 738f05cddf9SRui Paulo * @interface_addr: P2P Interface Address of the GO 739f05cddf9SRui Paulo * @buf: Buffer for returning NoA 740f05cddf9SRui Paulo * @buf_len: Buffer length in octets 741f05cddf9SRui Paulo * Returns: Number of octets used in buf, 0 to indicate no NoA is being 742f05cddf9SRui Paulo * advertized, or -1 on failure 743f05cddf9SRui Paulo * 744f05cddf9SRui Paulo * This function is used to fetch the current Notice of Absence 745f05cddf9SRui Paulo * attribute value from GO. 746f05cddf9SRui Paulo */ 747f05cddf9SRui Paulo int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf, 748f05cddf9SRui Paulo size_t buf_len); 749f05cddf9SRui Paulo 750f05cddf9SRui Paulo /* Callbacks to notify events to upper layer management entity */ 751f05cddf9SRui Paulo 752f05cddf9SRui Paulo /** 753f05cddf9SRui Paulo * dev_found - Notification of a found P2P Device 754f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 755f05cddf9SRui Paulo * @addr: Source address of the message triggering this notification 756f05cddf9SRui Paulo * @info: P2P peer information 757f05cddf9SRui Paulo * @new_device: Inform if the peer is newly found 758f05cddf9SRui Paulo * 759f05cddf9SRui Paulo * This callback is used to notify that a new P2P Device has been 760f05cddf9SRui Paulo * found. This may happen, e.g., during Search state based on scan 761f05cddf9SRui Paulo * results or during Listen state based on receive Probe Request and 762f05cddf9SRui Paulo * Group Owner Negotiation Request. 763f05cddf9SRui Paulo */ 764f05cddf9SRui Paulo void (*dev_found)(void *ctx, const u8 *addr, 765f05cddf9SRui Paulo const struct p2p_peer_info *info, 766f05cddf9SRui Paulo int new_device); 767f05cddf9SRui Paulo 768f05cddf9SRui Paulo /** 769f05cddf9SRui Paulo * dev_lost - Notification of a lost P2P Device 770f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 771f05cddf9SRui Paulo * @dev_addr: P2P Device Address of the lost P2P Device 772f05cddf9SRui Paulo * 773f05cddf9SRui Paulo * This callback is used to notify that a P2P Device has been deleted. 774f05cddf9SRui Paulo */ 775f05cddf9SRui Paulo void (*dev_lost)(void *ctx, const u8 *dev_addr); 776f05cddf9SRui Paulo 777f05cddf9SRui Paulo /** 7785b9c547cSRui Paulo * find_stopped - Notification of a p2p_find operation stopping 7795b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 7805b9c547cSRui Paulo */ 7815b9c547cSRui Paulo void (*find_stopped)(void *ctx); 7825b9c547cSRui Paulo 7835b9c547cSRui Paulo /** 784f05cddf9SRui Paulo * go_neg_req_rx - Notification of a receive GO Negotiation Request 785f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 786f05cddf9SRui Paulo * @src: Source address of the message triggering this notification 787f05cddf9SRui Paulo * @dev_passwd_id: WPS Device Password ID 788325151a3SRui Paulo * @go_intent: Peer's GO Intent 789f05cddf9SRui Paulo * 790f05cddf9SRui Paulo * This callback is used to notify that a P2P Device is requesting 791f05cddf9SRui Paulo * group owner negotiation with us, but we do not have all the 792f05cddf9SRui Paulo * necessary information to start GO Negotiation. This indicates that 793f05cddf9SRui Paulo * the local user has not authorized the connection yet by providing a 794f05cddf9SRui Paulo * PIN or PBC button press. This information can be provided with a 795f05cddf9SRui Paulo * call to p2p_connect(). 796f05cddf9SRui Paulo */ 797325151a3SRui Paulo void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id, 798325151a3SRui Paulo u8 go_intent); 799f05cddf9SRui Paulo 800f05cddf9SRui Paulo /** 801f05cddf9SRui Paulo * go_neg_completed - Notification of GO Negotiation results 802f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 803f05cddf9SRui Paulo * @res: GO Negotiation results 804f05cddf9SRui Paulo * 805f05cddf9SRui Paulo * This callback is used to notify that Group Owner Negotiation has 806f05cddf9SRui Paulo * been completed. Non-zero struct p2p_go_neg_results::status indicates 807f05cddf9SRui Paulo * failed negotiation. In case of success, this function is responsible 808f05cddf9SRui Paulo * for creating a new group interface (or using the existing interface 809f05cddf9SRui Paulo * depending on driver features), setting up the group interface in 810f05cddf9SRui Paulo * proper mode based on struct p2p_go_neg_results::role_go and 811f05cddf9SRui Paulo * initializing WPS provisioning either as a Registrar (if GO) or as an 812f05cddf9SRui Paulo * Enrollee. Successful WPS provisioning must be indicated by calling 813f05cddf9SRui Paulo * p2p_wps_success_cb(). The callee is responsible for timing out group 814f05cddf9SRui Paulo * formation if WPS provisioning cannot be completed successfully 815f05cddf9SRui Paulo * within 15 seconds. 816f05cddf9SRui Paulo */ 817f05cddf9SRui Paulo void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res); 818f05cddf9SRui Paulo 819f05cddf9SRui Paulo /** 820f05cddf9SRui Paulo * sd_request - Callback on Service Discovery Request 821f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 822f05cddf9SRui Paulo * @freq: Frequency (in MHz) of the channel 823f05cddf9SRui Paulo * @sa: Source address of the request 824f05cddf9SRui Paulo * @dialog_token: Dialog token 825f05cddf9SRui Paulo * @update_indic: Service Update Indicator from the source of request 826f05cddf9SRui Paulo * @tlvs: P2P Service Request TLV(s) 827f05cddf9SRui Paulo * @tlvs_len: Length of tlvs buffer in octets 828f05cddf9SRui Paulo * 829f05cddf9SRui Paulo * This callback is used to indicate reception of a service discovery 830f05cddf9SRui Paulo * request. Response to the query must be indicated by calling 831f05cddf9SRui Paulo * p2p_sd_response() with the context information from the arguments to 832f05cddf9SRui Paulo * this callback function. 833f05cddf9SRui Paulo * 834f05cddf9SRui Paulo * This callback handler can be set to %NULL to indicate that service 835f05cddf9SRui Paulo * discovery is not supported. 836f05cddf9SRui Paulo */ 837f05cddf9SRui Paulo void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token, 838f05cddf9SRui Paulo u16 update_indic, const u8 *tlvs, size_t tlvs_len); 839f05cddf9SRui Paulo 840f05cddf9SRui Paulo /** 841f05cddf9SRui Paulo * sd_response - Callback on Service Discovery Response 842f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 843f05cddf9SRui Paulo * @sa: Source address of the request 844f05cddf9SRui Paulo * @update_indic: Service Update Indicator from the source of response 845f05cddf9SRui Paulo * @tlvs: P2P Service Response TLV(s) 846f05cddf9SRui Paulo * @tlvs_len: Length of tlvs buffer in octets 847f05cddf9SRui Paulo * 848f05cddf9SRui Paulo * This callback is used to indicate reception of a service discovery 849f05cddf9SRui Paulo * response. This callback handler can be set to %NULL if no service 850f05cddf9SRui Paulo * discovery requests are used. The information provided with this call 851f05cddf9SRui Paulo * is replies to the queries scheduled with p2p_sd_request(). 852f05cddf9SRui Paulo */ 853f05cddf9SRui Paulo void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic, 854f05cddf9SRui Paulo const u8 *tlvs, size_t tlvs_len); 855f05cddf9SRui Paulo 856f05cddf9SRui Paulo /** 857f05cddf9SRui Paulo * prov_disc_req - Callback on Provisiong Discovery Request 858f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 859f05cddf9SRui Paulo * @peer: Source address of the request 860f05cddf9SRui Paulo * @config_methods: Requested WPS Config Method 861f05cddf9SRui Paulo * @dev_addr: P2P Device Address of the found P2P Device 862f05cddf9SRui Paulo * @pri_dev_type: Primary Device Type 863f05cddf9SRui Paulo * @dev_name: Device Name 864f05cddf9SRui Paulo * @supp_config_methods: Supported configuration Methods 865f05cddf9SRui Paulo * @dev_capab: Device Capabilities 866f05cddf9SRui Paulo * @group_capab: Group Capabilities 867f05cddf9SRui Paulo * @group_id: P2P Group ID (or %NULL if not included) 868f05cddf9SRui Paulo * @group_id_len: Length of P2P Group ID 869f05cddf9SRui Paulo * 870f05cddf9SRui Paulo * This callback is used to indicate reception of a Provision Discovery 871f05cddf9SRui Paulo * Request frame that the P2P module accepted. 872f05cddf9SRui Paulo */ 873f05cddf9SRui Paulo void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods, 874f05cddf9SRui Paulo const u8 *dev_addr, const u8 *pri_dev_type, 875f05cddf9SRui Paulo const char *dev_name, u16 supp_config_methods, 876f05cddf9SRui Paulo u8 dev_capab, u8 group_capab, 877f05cddf9SRui Paulo const u8 *group_id, size_t group_id_len); 878f05cddf9SRui Paulo 879f05cddf9SRui Paulo /** 880f05cddf9SRui Paulo * prov_disc_resp - Callback on Provisiong Discovery Response 881f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 882f05cddf9SRui Paulo * @peer: Source address of the response 883f05cddf9SRui Paulo * @config_methods: Value from p2p_prov_disc_req() or 0 on failure 884f05cddf9SRui Paulo * 885f05cddf9SRui Paulo * This callback is used to indicate reception of a Provision Discovery 886f05cddf9SRui Paulo * Response frame for a pending request scheduled with 887f05cddf9SRui Paulo * p2p_prov_disc_req(). This callback handler can be set to %NULL if 888f05cddf9SRui Paulo * provision discovery is not used. 889f05cddf9SRui Paulo */ 890f05cddf9SRui Paulo void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods); 891f05cddf9SRui Paulo 892f05cddf9SRui Paulo /** 893f05cddf9SRui Paulo * prov_disc_fail - Callback on Provision Discovery failure 894f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 895f05cddf9SRui Paulo * @peer: Source address of the response 896f05cddf9SRui Paulo * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS 8975b9c547cSRui Paulo * @adv_id: If non-zero, then the adv_id of the PD Request 8985b9c547cSRui Paulo * @adv_mac: P2P Device Address of the advertizer 8995b9c547cSRui Paulo * @deferred_session_resp: Deferred session response sent by advertizer 900f05cddf9SRui Paulo * 901f05cddf9SRui Paulo * This callback is used to indicate either a failure or no response 902f05cddf9SRui Paulo * to an earlier provision discovery request. 903f05cddf9SRui Paulo * 904f05cddf9SRui Paulo * This callback handler can be set to %NULL if provision discovery 905f05cddf9SRui Paulo * is not used or failures do not need to be indicated. 906f05cddf9SRui Paulo */ 907f05cddf9SRui Paulo void (*prov_disc_fail)(void *ctx, const u8 *peer, 9085b9c547cSRui Paulo enum p2p_prov_disc_status status, 9095b9c547cSRui Paulo u32 adv_id, const u8 *adv_mac, 9105b9c547cSRui Paulo const char *deferred_session_resp); 911f05cddf9SRui Paulo 912f05cddf9SRui Paulo /** 913f05cddf9SRui Paulo * invitation_process - Optional callback for processing Invitations 914f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 915f05cddf9SRui Paulo * @sa: Source address of the Invitation Request 916f05cddf9SRui Paulo * @bssid: P2P Group BSSID from the request or %NULL if not included 917f05cddf9SRui Paulo * @go_dev_addr: GO Device Address from P2P Group ID 918f05cddf9SRui Paulo * @ssid: SSID from P2P Group ID 919f05cddf9SRui Paulo * @ssid_len: Length of ssid buffer in octets 920f05cddf9SRui Paulo * @go: Variable for returning whether the local end is GO in the group 921f05cddf9SRui Paulo * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO) 922f05cddf9SRui Paulo * @force_freq: Variable for returning forced frequency for the group 923f05cddf9SRui Paulo * @persistent_group: Whether this is an invitation to reinvoke a 924f05cddf9SRui Paulo * persistent group (instead of invitation to join an active 925f05cddf9SRui Paulo * group) 9265b9c547cSRui Paulo * @channels: Available operating channels for the group 9275b9c547cSRui Paulo * @dev_pw_id: Device Password ID for NFC static handover or -1 if not 9285b9c547cSRui Paulo * used 929f05cddf9SRui Paulo * Returns: Status code (P2P_SC_*) 930f05cddf9SRui Paulo * 931f05cddf9SRui Paulo * This optional callback can be used to implement persistent reconnect 932f05cddf9SRui Paulo * by allowing automatic restarting of persistent groups without user 933f05cddf9SRui Paulo * interaction. If this callback is not implemented (i.e., is %NULL), 934f05cddf9SRui Paulo * the received Invitation Request frames are replied with 935f05cddf9SRui Paulo * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the 936f05cddf9SRui Paulo * invitation_result() callback. 937f05cddf9SRui Paulo * 938f05cddf9SRui Paulo * If the requested parameters are acceptable and the group is known, 939f05cddf9SRui Paulo * %P2P_SC_SUCCESS may be returned. If the requested group is unknown, 940f05cddf9SRui Paulo * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED 941f05cddf9SRui Paulo * can be returned if there is not enough data to provide immediate 942f05cddf9SRui Paulo * response, i.e., if some sort of user interaction is needed. The 943f05cddf9SRui Paulo * invitation_received() callback will be called in that case 944f05cddf9SRui Paulo * immediately after this call. 945f05cddf9SRui Paulo */ 946f05cddf9SRui Paulo u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid, 947f05cddf9SRui Paulo const u8 *go_dev_addr, const u8 *ssid, 948f05cddf9SRui Paulo size_t ssid_len, int *go, u8 *group_bssid, 9495b9c547cSRui Paulo int *force_freq, int persistent_group, 9505b9c547cSRui Paulo const struct p2p_channels *channels, 9515b9c547cSRui Paulo int dev_pw_id); 952f05cddf9SRui Paulo 953f05cddf9SRui Paulo /** 954f05cddf9SRui Paulo * invitation_received - Callback on Invitation Request RX 955f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 956f05cddf9SRui Paulo * @sa: Source address of the Invitation Request 957f05cddf9SRui Paulo * @bssid: P2P Group BSSID or %NULL if not received 958f05cddf9SRui Paulo * @ssid: SSID of the group 959f05cddf9SRui Paulo * @ssid_len: Length of ssid in octets 960f05cddf9SRui Paulo * @go_dev_addr: GO Device Address 961f05cddf9SRui Paulo * @status: Response Status 962f05cddf9SRui Paulo * @op_freq: Operational frequency for the group 963f05cddf9SRui Paulo * 964f05cddf9SRui Paulo * This callback is used to indicate sending of an Invitation Response 965f05cddf9SRui Paulo * for a received Invitation Request. If status == 0 (success), the 966f05cddf9SRui Paulo * upper layer code is responsible for starting the group. status == 1 967f05cddf9SRui Paulo * indicates need to get user authorization for the group. Other status 968f05cddf9SRui Paulo * values indicate that the invitation request was rejected. 969f05cddf9SRui Paulo */ 970f05cddf9SRui Paulo void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid, 971f05cddf9SRui Paulo const u8 *ssid, size_t ssid_len, 972f05cddf9SRui Paulo const u8 *go_dev_addr, u8 status, 973f05cddf9SRui Paulo int op_freq); 974f05cddf9SRui Paulo 975f05cddf9SRui Paulo /** 976f05cddf9SRui Paulo * invitation_result - Callback on Invitation result 977f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 978f05cddf9SRui Paulo * @status: Negotiation result (Status Code) 979f05cddf9SRui Paulo * @bssid: P2P Group BSSID or %NULL if not received 9805b9c547cSRui Paulo * @channels: Available operating channels for the group 9815b9c547cSRui Paulo * @addr: Peer address 9825b9c547cSRui Paulo * @freq: Frequency (in MHz) indicated during invitation or 0 9835b9c547cSRui Paulo * @peer_oper_freq: Operating frequency (in MHz) advertized by the peer 9845b9c547cSRui Paulo * during invitation or 0 985f05cddf9SRui Paulo * 986f05cddf9SRui Paulo * This callback is used to indicate result of an Invitation procedure 987f05cddf9SRui Paulo * started with a call to p2p_invite(). The indicated status code is 988f05cddf9SRui Paulo * the value received from the peer in Invitation Response with 0 989f05cddf9SRui Paulo * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a 990f05cddf9SRui Paulo * local failure in transmitting the Invitation Request. 991f05cddf9SRui Paulo */ 9925b9c547cSRui Paulo void (*invitation_result)(void *ctx, int status, const u8 *bssid, 9935b9c547cSRui Paulo const struct p2p_channels *channels, 9945b9c547cSRui Paulo const u8 *addr, int freq, int peer_oper_freq); 995f05cddf9SRui Paulo 996f05cddf9SRui Paulo /** 997f05cddf9SRui Paulo * go_connected - Check whether we are connected to a GO 998f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 999f05cddf9SRui Paulo * @dev_addr: P2P Device Address of a GO 1000f05cddf9SRui Paulo * Returns: 1 if we are connected as a P2P client to the specified GO 1001f05cddf9SRui Paulo * or 0 if not. 1002f05cddf9SRui Paulo */ 1003f05cddf9SRui Paulo int (*go_connected)(void *ctx, const u8 *dev_addr); 10045b9c547cSRui Paulo 10055b9c547cSRui Paulo /** 10065b9c547cSRui Paulo * presence_resp - Callback on Presence Response 10075b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 10085b9c547cSRui Paulo * @src: Source address (GO's P2P Interface Address) 10095b9c547cSRui Paulo * @status: Result of the request (P2P_SC_*) 10105b9c547cSRui Paulo * @noa: Returned NoA value 10115b9c547cSRui Paulo * @noa_len: Length of the NoA buffer in octets 10125b9c547cSRui Paulo */ 10135b9c547cSRui Paulo void (*presence_resp)(void *ctx, const u8 *src, u8 status, 10145b9c547cSRui Paulo const u8 *noa, size_t noa_len); 10155b9c547cSRui Paulo 10165b9c547cSRui Paulo /** 10175b9c547cSRui Paulo * is_concurrent_session_active - Check whether concurrent session is 10185b9c547cSRui Paulo * active on other virtual interfaces 10195b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 10205b9c547cSRui Paulo * Returns: 1 if concurrent session is active on other virtual interface 10215b9c547cSRui Paulo * or 0 if not. 10225b9c547cSRui Paulo */ 10235b9c547cSRui Paulo int (*is_concurrent_session_active)(void *ctx); 10245b9c547cSRui Paulo 10255b9c547cSRui Paulo /** 10265b9c547cSRui Paulo * is_p2p_in_progress - Check whether P2P operation is in progress 10275b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 10285b9c547cSRui Paulo * Returns: 1 if P2P operation (e.g., group formation) is in progress 10295b9c547cSRui Paulo * or 0 if not. 10305b9c547cSRui Paulo */ 10315b9c547cSRui Paulo int (*is_p2p_in_progress)(void *ctx); 10325b9c547cSRui Paulo 10335b9c547cSRui Paulo /** 10345b9c547cSRui Paulo * Determine if we have a persistent group we share with remote peer 1035325151a3SRui Paulo * and allocate interface for this group if needed 10365b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 10375b9c547cSRui Paulo * @addr: Peer device address to search for 10385b9c547cSRui Paulo * @ssid: Persistent group SSID or %NULL if any 10395b9c547cSRui Paulo * @ssid_len: Length of @ssid 1040325151a3SRui Paulo * @go_dev_addr: Buffer for returning GO P2P Device Address 10415b9c547cSRui Paulo * @ret_ssid: Buffer for returning group SSID 10425b9c547cSRui Paulo * @ret_ssid_len: Buffer for returning length of @ssid 1043325151a3SRui Paulo * @intended_iface_addr: Buffer for returning intended iface address 10445b9c547cSRui Paulo * Returns: 1 if a matching persistent group was found, 0 otherwise 10455b9c547cSRui Paulo */ 10465b9c547cSRui Paulo int (*get_persistent_group)(void *ctx, const u8 *addr, const u8 *ssid, 10475b9c547cSRui Paulo size_t ssid_len, u8 *go_dev_addr, 1048325151a3SRui Paulo u8 *ret_ssid, size_t *ret_ssid_len, 1049325151a3SRui Paulo u8 *intended_iface_addr); 10505b9c547cSRui Paulo 10515b9c547cSRui Paulo /** 10525b9c547cSRui Paulo * Get information about a possible local GO role 10535b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 10545b9c547cSRui Paulo * @intended_addr: Buffer for returning intended GO interface address 10555b9c547cSRui Paulo * @ssid: Buffer for returning group SSID 10565b9c547cSRui Paulo * @ssid_len: Buffer for returning length of @ssid 10575b9c547cSRui Paulo * @group_iface: Buffer for returning whether a separate group interface 10585b9c547cSRui Paulo * would be used 1059780fb4a2SCy Schubert * @freq: Variable for returning the current operating frequency of a 1060780fb4a2SCy Schubert * currently running P2P GO. 10615b9c547cSRui Paulo * Returns: 1 if GO info found, 0 otherwise 10625b9c547cSRui Paulo * 10635b9c547cSRui Paulo * This is used to compose New Group settings (SSID, and intended 10645b9c547cSRui Paulo * address) during P2PS provisioning if results of provisioning *might* 10655b9c547cSRui Paulo * result in our being an autonomous GO. 10665b9c547cSRui Paulo */ 10675b9c547cSRui Paulo int (*get_go_info)(void *ctx, u8 *intended_addr, 1068780fb4a2SCy Schubert u8 *ssid, size_t *ssid_len, int *group_iface, 1069780fb4a2SCy Schubert unsigned int *freq); 10705b9c547cSRui Paulo 10715b9c547cSRui Paulo /** 10725b9c547cSRui Paulo * remove_stale_groups - Remove stale P2PS groups 10735b9c547cSRui Paulo * 10745b9c547cSRui Paulo * Because P2PS stages *potential* GOs, and remote devices can remove 10755b9c547cSRui Paulo * credentials unilaterally, we need to make sure we don't let stale 10765b9c547cSRui Paulo * unusable groups build up. 10775b9c547cSRui Paulo */ 10785b9c547cSRui Paulo int (*remove_stale_groups)(void *ctx, const u8 *peer, const u8 *go, 10795b9c547cSRui Paulo const u8 *ssid, size_t ssid_len); 10805b9c547cSRui Paulo 10815b9c547cSRui Paulo /** 10825b9c547cSRui Paulo * p2ps_prov_complete - P2PS provisioning complete 10835b9c547cSRui Paulo * 10845b9c547cSRui Paulo * When P2PS provisioning completes (successfully or not) we must 10855b9c547cSRui Paulo * transmit all of the results to the upper layers. 10865b9c547cSRui Paulo */ 10875b9c547cSRui Paulo void (*p2ps_prov_complete)(void *ctx, u8 status, const u8 *dev, 10885b9c547cSRui Paulo const u8 *adv_mac, const u8 *ses_mac, 10895b9c547cSRui Paulo const u8 *grp_mac, u32 adv_id, u32 ses_id, 10905b9c547cSRui Paulo u8 conncap, int passwd_id, 10915b9c547cSRui Paulo const u8 *persist_ssid, 10925b9c547cSRui Paulo size_t persist_ssid_size, int response_done, 1093325151a3SRui Paulo int prov_start, const char *session_info, 1094780fb4a2SCy Schubert const u8 *feat_cap, size_t feat_cap_len, 1095780fb4a2SCy Schubert unsigned int freq, const u8 *group_ssid, 1096780fb4a2SCy Schubert size_t group_ssid_len); 10975b9c547cSRui Paulo 10985b9c547cSRui Paulo /** 10995b9c547cSRui Paulo * prov_disc_resp_cb - Callback for indicating completion of PD Response 11005b9c547cSRui Paulo * @ctx: Callback context from cb_ctx 11015b9c547cSRui Paulo * Returns: 1 if operation was started, 0 otherwise 11025b9c547cSRui Paulo * 11035b9c547cSRui Paulo * This callback can be used to perform any pending actions after 11045b9c547cSRui Paulo * provisioning. It is mainly used for P2PS pending group creation. 11055b9c547cSRui Paulo */ 11065b9c547cSRui Paulo int (*prov_disc_resp_cb)(void *ctx); 11075b9c547cSRui Paulo 11085b9c547cSRui Paulo /** 11095b9c547cSRui Paulo * p2ps_group_capability - Determine group capability 1110780fb4a2SCy Schubert * @ctx: Callback context from cb_ctx 1111780fb4a2SCy Schubert * @incoming: Peer requested roles, expressed with P2PS_SETUP_* bitmap. 1112780fb4a2SCy Schubert * @role: Local roles, expressed with P2PS_SETUP_* bitmap. 1113780fb4a2SCy Schubert * @force_freq: Variable for returning forced frequency for the group. 1114780fb4a2SCy Schubert * @pref_freq: Variable for returning preferred frequency for the group. 1115780fb4a2SCy Schubert * Returns: P2PS_SETUP_* bitmap of group capability result. 11165b9c547cSRui Paulo * 1117780fb4a2SCy Schubert * This function can be used to determine group capability and 1118780fb4a2SCy Schubert * frequencies based on information from P2PS PD exchange and the 1119780fb4a2SCy Schubert * current state of ongoing groups and driver capabilities. 11205b9c547cSRui Paulo */ 1121780fb4a2SCy Schubert u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role, 1122780fb4a2SCy Schubert unsigned int *force_freq, 1123780fb4a2SCy Schubert unsigned int *pref_freq); 1124325151a3SRui Paulo 1125325151a3SRui Paulo /** 1126325151a3SRui Paulo * get_pref_freq_list - Get preferred frequency list for an interface 1127325151a3SRui Paulo * @ctx: Callback context from cb_ctx 1128325151a3SRui Paulo * @go: Whether the use if for GO role 1129325151a3SRui Paulo * @len: Length of freq_list in entries (both IN and OUT) 1130325151a3SRui Paulo * @freq_list: Buffer for returning the preferred frequencies (MHz) 1131325151a3SRui Paulo * Returns: 0 on success, -1 on failure 1132325151a3SRui Paulo * 1133325151a3SRui Paulo * This function can be used to query the preferred frequency list from 1134325151a3SRui Paulo * the driver specific to a particular interface type. 1135325151a3SRui Paulo */ 1136325151a3SRui Paulo int (*get_pref_freq_list)(void *ctx, int go, 1137*a90b9d01SCy Schubert unsigned int *len, 1138*a90b9d01SCy Schubert struct weighted_pcl *freq_list); 1139f05cddf9SRui Paulo }; 1140f05cddf9SRui Paulo 1141f05cddf9SRui Paulo 1142f05cddf9SRui Paulo /* P2P module initialization/deinitialization */ 1143f05cddf9SRui Paulo 1144f05cddf9SRui Paulo /** 1145f05cddf9SRui Paulo * p2p_init - Initialize P2P module 1146f05cddf9SRui Paulo * @cfg: P2P module configuration 1147f05cddf9SRui Paulo * Returns: Pointer to private data or %NULL on failure 1148f05cddf9SRui Paulo * 1149f05cddf9SRui Paulo * This function is used to initialize global P2P module context (one per 1150f05cddf9SRui Paulo * device). The P2P module will keep a copy of the configuration data, so the 1151f05cddf9SRui Paulo * caller does not need to maintain this structure. However, the callback 1152f05cddf9SRui Paulo * functions and the context parameters to them must be kept available until 1153f05cddf9SRui Paulo * the P2P module is deinitialized with p2p_deinit(). 1154f05cddf9SRui Paulo */ 1155f05cddf9SRui Paulo struct p2p_data * p2p_init(const struct p2p_config *cfg); 1156f05cddf9SRui Paulo 1157f05cddf9SRui Paulo /** 1158f05cddf9SRui Paulo * p2p_deinit - Deinitialize P2P module 1159f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1160f05cddf9SRui Paulo */ 1161f05cddf9SRui Paulo void p2p_deinit(struct p2p_data *p2p); 1162f05cddf9SRui Paulo 1163f05cddf9SRui Paulo /** 1164f05cddf9SRui Paulo * p2p_flush - Flush P2P module state 1165f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1166f05cddf9SRui Paulo * 1167f05cddf9SRui Paulo * This command removes the P2P module state like peer device entries. 1168f05cddf9SRui Paulo */ 1169f05cddf9SRui Paulo void p2p_flush(struct p2p_data *p2p); 1170f05cddf9SRui Paulo 1171f05cddf9SRui Paulo /** 1172f05cddf9SRui Paulo * p2p_unauthorize - Unauthorize the specified peer device 1173f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1174f05cddf9SRui Paulo * @addr: P2P peer entry to be unauthorized 1175f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1176f05cddf9SRui Paulo * 1177f05cddf9SRui Paulo * This command removes any connection authorization from the specified P2P 1178f05cddf9SRui Paulo * peer device address. This can be used, e.g., to cancel effect of a previous 1179f05cddf9SRui Paulo * p2p_authorize() or p2p_connect() call that has not yet resulted in completed 1180f05cddf9SRui Paulo * GO Negotiation. 1181f05cddf9SRui Paulo */ 1182f05cddf9SRui Paulo int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr); 1183f05cddf9SRui Paulo 1184f05cddf9SRui Paulo /** 1185f05cddf9SRui Paulo * p2p_set_dev_name - Set device name 1186f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1187f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1188f05cddf9SRui Paulo * 1189f05cddf9SRui Paulo * This function can be used to update the P2P module configuration with 1190f05cddf9SRui Paulo * information that was not available at the time of the p2p_init() call. 1191f05cddf9SRui Paulo */ 1192f05cddf9SRui Paulo int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name); 1193f05cddf9SRui Paulo 1194f05cddf9SRui Paulo int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer); 1195f05cddf9SRui Paulo int p2p_set_model_name(struct p2p_data *p2p, const char *model_name); 1196f05cddf9SRui Paulo int p2p_set_model_number(struct p2p_data *p2p, const char *model_number); 1197f05cddf9SRui Paulo int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number); 1198f05cddf9SRui Paulo 1199f05cddf9SRui Paulo void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods); 1200f05cddf9SRui Paulo void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid); 1201f05cddf9SRui Paulo 1202f05cddf9SRui Paulo /** 1203f05cddf9SRui Paulo * p2p_set_pri_dev_type - Set primary device type 1204f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1205f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1206f05cddf9SRui Paulo * 1207f05cddf9SRui Paulo * This function can be used to update the P2P module configuration with 1208f05cddf9SRui Paulo * information that was not available at the time of the p2p_init() call. 1209f05cddf9SRui Paulo */ 1210f05cddf9SRui Paulo int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type); 1211f05cddf9SRui Paulo 1212f05cddf9SRui Paulo /** 1213f05cddf9SRui Paulo * p2p_set_sec_dev_types - Set secondary device types 1214f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1215f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1216f05cddf9SRui Paulo * 1217f05cddf9SRui Paulo * This function can be used to update the P2P module configuration with 1218f05cddf9SRui Paulo * information that was not available at the time of the p2p_init() call. 1219f05cddf9SRui Paulo */ 1220f05cddf9SRui Paulo int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8], 1221f05cddf9SRui Paulo size_t num_dev_types); 1222f05cddf9SRui Paulo 1223f05cddf9SRui Paulo int p2p_set_country(struct p2p_data *p2p, const char *country); 1224f05cddf9SRui Paulo 1225f05cddf9SRui Paulo 1226f05cddf9SRui Paulo /* Commands from upper layer management entity */ 1227f05cddf9SRui Paulo 1228f05cddf9SRui Paulo enum p2p_discovery_type { 1229f05cddf9SRui Paulo P2P_FIND_START_WITH_FULL, 1230f05cddf9SRui Paulo P2P_FIND_ONLY_SOCIAL, 1231f05cddf9SRui Paulo P2P_FIND_PROGRESSIVE 1232f05cddf9SRui Paulo }; 1233f05cddf9SRui Paulo 1234f05cddf9SRui Paulo /** 1235f05cddf9SRui Paulo * p2p_find - Start P2P Find (Device Discovery) 1236f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1237f05cddf9SRui Paulo * @timeout: Timeout for find operation in seconds or 0 for no timeout 1238f05cddf9SRui Paulo * @type: Device Discovery type 1239f05cddf9SRui Paulo * @num_req_dev_types: Number of requested device types 1240f05cddf9SRui Paulo * @req_dev_types: Requested device types array, must be an array 1241f05cddf9SRui Paulo * containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no 1242f05cddf9SRui Paulo * requested device types. 1243f05cddf9SRui Paulo * @dev_id: Device ID to search for or %NULL to find all devices 1244f05cddf9SRui Paulo * @search_delay: Extra delay in milliseconds between search iterations 12455b9c547cSRui Paulo * @seek_count: Number of ASP Service Strings in the seek_string array 12465b9c547cSRui Paulo * @seek_string: ASP Service Strings to query for in Probe Requests 12475b9c547cSRui Paulo * @freq: Requested first scan frequency (in MHz) to modify type == 12485b9c547cSRui Paulo * P2P_FIND_START_WITH_FULL behavior. 0 = Use normal full scan. 12495b9c547cSRui Paulo * If p2p_find is already in progress, this parameter is ignored and full 12505b9c547cSRui Paulo * scan will be executed. 1251c1d255d3SCy Schubert * @include_6ghz: Include 6 GHz channels in P2P find 1252f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1253f05cddf9SRui Paulo */ 1254f05cddf9SRui Paulo int p2p_find(struct p2p_data *p2p, unsigned int timeout, 1255f05cddf9SRui Paulo enum p2p_discovery_type type, 1256f05cddf9SRui Paulo unsigned int num_req_dev_types, const u8 *req_dev_types, 12575b9c547cSRui Paulo const u8 *dev_id, unsigned int search_delay, 1258c1d255d3SCy Schubert u8 seek_count, const char **seek_string, int freq, 1259c1d255d3SCy Schubert bool include_6ghz); 12605b9c547cSRui Paulo 12615b9c547cSRui Paulo /** 12625b9c547cSRui Paulo * p2p_notify_scan_trigger_status - Indicate scan trigger status 12635b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 12645b9c547cSRui Paulo * @status: 0 on success, -1 on failure 12655b9c547cSRui Paulo */ 12665b9c547cSRui Paulo void p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status); 1267f05cddf9SRui Paulo 1268f05cddf9SRui Paulo /** 1269f05cddf9SRui Paulo * p2p_stop_find - Stop P2P Find (Device Discovery) 1270f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1271f05cddf9SRui Paulo */ 1272f05cddf9SRui Paulo void p2p_stop_find(struct p2p_data *p2p); 1273f05cddf9SRui Paulo 1274f05cddf9SRui Paulo /** 1275f05cddf9SRui Paulo * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq 1276f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1277f05cddf9SRui Paulo * @freq: Frequency in MHz for next operation 1278f05cddf9SRui Paulo * 1279f05cddf9SRui Paulo * This is like p2p_stop_find(), but Listen state is not stopped if we are 1280f05cddf9SRui Paulo * already on the same frequency. 1281f05cddf9SRui Paulo */ 1282f05cddf9SRui Paulo void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq); 1283f05cddf9SRui Paulo 1284f05cddf9SRui Paulo /** 1285f05cddf9SRui Paulo * p2p_listen - Start P2P Listen state for specified duration 1286f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1287f05cddf9SRui Paulo * @timeout: Listen state duration in milliseconds 1288f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1289f05cddf9SRui Paulo * 1290f05cddf9SRui Paulo * This function can be used to request the P2P module to keep the device 1291f05cddf9SRui Paulo * discoverable on the listen channel for an extended set of time. At least in 1292f05cddf9SRui Paulo * its current form, this is mainly used for testing purposes and may not be of 1293f05cddf9SRui Paulo * much use for normal P2P operations. 1294f05cddf9SRui Paulo */ 1295f05cddf9SRui Paulo int p2p_listen(struct p2p_data *p2p, unsigned int timeout); 1296f05cddf9SRui Paulo 1297f05cddf9SRui Paulo /** 12985b9c547cSRui Paulo * p2p_stop_listen - Stop P2P Listen 12995b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 13005b9c547cSRui Paulo */ 13015b9c547cSRui Paulo void p2p_stop_listen(struct p2p_data *p2p); 13025b9c547cSRui Paulo 13035b9c547cSRui Paulo /** 1304f05cddf9SRui Paulo * p2p_connect - Start P2P group formation (GO negotiation) 1305f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1306f05cddf9SRui Paulo * @peer_addr: MAC address of the peer P2P client 1307f05cddf9SRui Paulo * @wps_method: WPS method to be used in provisioning 1308f05cddf9SRui Paulo * @go_intent: Local GO intent value (1..15) 1309f05cddf9SRui Paulo * @own_interface_addr: Intended interface address to use with the group 1310f05cddf9SRui Paulo * @force_freq: The only allowed channel frequency in MHz or 0 1311f05cddf9SRui Paulo * @persistent_group: Whether to create a persistent group (0 = no, 1 = 1312f05cddf9SRui Paulo * persistent group without persistent reconnect, 2 = persistent group with 1313f05cddf9SRui Paulo * persistent reconnect) 1314f05cddf9SRui Paulo * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate 1315f05cddf9SRui Paulo * a new SSID 1316f05cddf9SRui Paulo * @force_ssid_len: Length of $force_ssid buffer 1317f05cddf9SRui Paulo * @pd_before_go_neg: Whether to send Provision Discovery prior to GO 1318f05cddf9SRui Paulo * Negotiation as an interoperability workaround when initiating group 1319f05cddf9SRui Paulo * formation 1320f05cddf9SRui Paulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 1321f05cddf9SRui Paulo * force_freq == 0) 1322f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1323f05cddf9SRui Paulo */ 1324f05cddf9SRui Paulo int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr, 1325f05cddf9SRui Paulo enum p2p_wps_method wps_method, 1326f05cddf9SRui Paulo int go_intent, const u8 *own_interface_addr, 1327f05cddf9SRui Paulo unsigned int force_freq, int persistent_group, 1328f05cddf9SRui Paulo const u8 *force_ssid, size_t force_ssid_len, 13295b9c547cSRui Paulo int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id); 1330f05cddf9SRui Paulo 1331f05cddf9SRui Paulo /** 1332f05cddf9SRui Paulo * p2p_authorize - Authorize P2P group formation (GO negotiation) 1333f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1334f05cddf9SRui Paulo * @peer_addr: MAC address of the peer P2P client 1335f05cddf9SRui Paulo * @wps_method: WPS method to be used in provisioning 1336f05cddf9SRui Paulo * @go_intent: Local GO intent value (1..15) 1337f05cddf9SRui Paulo * @own_interface_addr: Intended interface address to use with the group 1338f05cddf9SRui Paulo * @force_freq: The only allowed channel frequency in MHz or 0 1339f05cddf9SRui Paulo * @persistent_group: Whether to create a persistent group (0 = no, 1 = 1340f05cddf9SRui Paulo * persistent group without persistent reconnect, 2 = persistent group with 1341f05cddf9SRui Paulo * persistent reconnect) 1342f05cddf9SRui Paulo * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate 1343f05cddf9SRui Paulo * a new SSID 1344f05cddf9SRui Paulo * @force_ssid_len: Length of $force_ssid buffer 1345f05cddf9SRui Paulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 1346f05cddf9SRui Paulo * force_freq == 0) 1347f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1348f05cddf9SRui Paulo * 1349f05cddf9SRui Paulo * This is like p2p_connect(), but the actual group negotiation is not 1350f05cddf9SRui Paulo * initiated automatically, i.e., the other end is expected to do that. 1351f05cddf9SRui Paulo */ 1352f05cddf9SRui Paulo int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr, 1353f05cddf9SRui Paulo enum p2p_wps_method wps_method, 1354f05cddf9SRui Paulo int go_intent, const u8 *own_interface_addr, 1355f05cddf9SRui Paulo unsigned int force_freq, int persistent_group, 1356f05cddf9SRui Paulo const u8 *force_ssid, size_t force_ssid_len, 13575b9c547cSRui Paulo unsigned int pref_freq, u16 oob_pw_id); 1358f05cddf9SRui Paulo 1359f05cddf9SRui Paulo /** 1360f05cddf9SRui Paulo * p2p_reject - Reject peer device (explicitly block connection attempts) 1361f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1362f05cddf9SRui Paulo * @peer_addr: MAC address of the peer P2P client 1363f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1364f05cddf9SRui Paulo */ 1365f05cddf9SRui Paulo int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr); 1366f05cddf9SRui Paulo 1367f05cddf9SRui Paulo /** 1368f05cddf9SRui Paulo * p2p_prov_disc_req - Send Provision Discovery Request 1369f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1370f05cddf9SRui Paulo * @peer_addr: MAC address of the peer P2P client 13715b9c547cSRui Paulo * @p2ps_prov: Provisioning info for P2PS 1372f05cddf9SRui Paulo * @config_methods: WPS Config Methods value (only one bit set) 1373f05cddf9SRui Paulo * @join: Whether this is used by a client joining an active group 1374f05cddf9SRui Paulo * @force_freq: Forced TX frequency for the frame (mainly for the join case) 1375f05cddf9SRui Paulo * @user_initiated_pd: Flag to indicate if initiated by user or not 1376f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1377f05cddf9SRui Paulo * 1378f05cddf9SRui Paulo * This function can be used to request a discovered P2P peer to display a PIN 1379f05cddf9SRui Paulo * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us 1380f05cddf9SRui Paulo * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame 1381f05cddf9SRui Paulo * is transmitted once immediately and if no response is received, the frame 1382f05cddf9SRui Paulo * will be sent again whenever the target device is discovered during device 1383f05cddf9SRui Paulo * dsicovery (start with a p2p_find() call). Response from the peer is 1384f05cddf9SRui Paulo * indicated with the p2p_config::prov_disc_resp() callback. 1385f05cddf9SRui Paulo */ 1386f05cddf9SRui Paulo int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, 13875b9c547cSRui Paulo struct p2ps_provision *p2ps_prov, u16 config_methods, 13885b9c547cSRui Paulo int join, int force_freq, 1389f05cddf9SRui Paulo int user_initiated_pd); 1390f05cddf9SRui Paulo 1391f05cddf9SRui Paulo /** 1392f05cddf9SRui Paulo * p2p_sd_request - Schedule a service discovery query 1393f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1394f05cddf9SRui Paulo * @dst: Destination peer or %NULL to apply for all peers 1395f05cddf9SRui Paulo * @tlvs: P2P Service Query TLV(s) 1396f05cddf9SRui Paulo * Returns: Reference to the query or %NULL on failure 1397f05cddf9SRui Paulo * 1398f05cddf9SRui Paulo * Response to the query is indicated with the p2p_config::sd_response() 1399f05cddf9SRui Paulo * callback. 1400f05cddf9SRui Paulo */ 1401f05cddf9SRui Paulo void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst, 1402f05cddf9SRui Paulo const struct wpabuf *tlvs); 1403f05cddf9SRui Paulo 1404f05cddf9SRui Paulo #ifdef CONFIG_WIFI_DISPLAY 1405f05cddf9SRui Paulo void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst, 1406f05cddf9SRui Paulo const struct wpabuf *tlvs); 1407f05cddf9SRui Paulo #endif /* CONFIG_WIFI_DISPLAY */ 1408f05cddf9SRui Paulo 1409f05cddf9SRui Paulo /** 1410f05cddf9SRui Paulo * p2p_sd_cancel_request - Cancel a pending service discovery query 1411f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1412f05cddf9SRui Paulo * @req: Query reference from p2p_sd_request() 1413f05cddf9SRui Paulo * Returns: 0 if request for cancelled; -1 if not found 1414f05cddf9SRui Paulo */ 1415f05cddf9SRui Paulo int p2p_sd_cancel_request(struct p2p_data *p2p, void *req); 1416f05cddf9SRui Paulo 1417f05cddf9SRui Paulo /** 1418f05cddf9SRui Paulo * p2p_sd_response - Send response to a service discovery query 1419f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1420f05cddf9SRui Paulo * @freq: Frequency from p2p_config::sd_request() callback 1421f05cddf9SRui Paulo * @dst: Destination address from p2p_config::sd_request() callback 1422f05cddf9SRui Paulo * @dialog_token: Dialog token from p2p_config::sd_request() callback 1423f05cddf9SRui Paulo * @resp_tlvs: P2P Service Response TLV(s) 1424f05cddf9SRui Paulo * 1425f05cddf9SRui Paulo * This function is called as a response to the request indicated with 1426f05cddf9SRui Paulo * p2p_config::sd_request() callback. 1427f05cddf9SRui Paulo */ 1428f05cddf9SRui Paulo void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst, 1429f05cddf9SRui Paulo u8 dialog_token, const struct wpabuf *resp_tlvs); 1430f05cddf9SRui Paulo 1431f05cddf9SRui Paulo /** 1432f05cddf9SRui Paulo * p2p_sd_service_update - Indicate a change in local services 1433f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1434f05cddf9SRui Paulo * 1435f05cddf9SRui Paulo * This function needs to be called whenever there is a change in availability 1436f05cddf9SRui Paulo * of the local services. This will increment the Service Update Indicator 1437f05cddf9SRui Paulo * value which will be used in SD Request and Response frames. 1438f05cddf9SRui Paulo */ 1439f05cddf9SRui Paulo void p2p_sd_service_update(struct p2p_data *p2p); 1440f05cddf9SRui Paulo 1441f05cddf9SRui Paulo 1442f05cddf9SRui Paulo enum p2p_invite_role { 1443f05cddf9SRui Paulo P2P_INVITE_ROLE_GO, 1444f05cddf9SRui Paulo P2P_INVITE_ROLE_ACTIVE_GO, 1445f05cddf9SRui Paulo P2P_INVITE_ROLE_CLIENT 1446f05cddf9SRui Paulo }; 1447f05cddf9SRui Paulo 1448f05cddf9SRui Paulo /** 1449f05cddf9SRui Paulo * p2p_invite - Invite a P2P Device into a group 1450f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1451f05cddf9SRui Paulo * @peer: Device Address of the peer P2P Device 1452f05cddf9SRui Paulo * @role: Local role in the group 1453f05cddf9SRui Paulo * @bssid: Group BSSID or %NULL if not known 1454f05cddf9SRui Paulo * @ssid: Group SSID 1455f05cddf9SRui Paulo * @ssid_len: Length of ssid in octets 1456f05cddf9SRui Paulo * @force_freq: The only allowed channel frequency in MHz or 0 1457f05cddf9SRui Paulo * @go_dev_addr: Forced GO Device Address or %NULL if none 1458f05cddf9SRui Paulo * @persistent_group: Whether this is to reinvoke a persistent group 14595b9c547cSRui Paulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 14605b9c547cSRui Paulo * force_freq == 0) 14615b9c547cSRui Paulo * @dev_pw_id: Device Password ID from OOB Device Password (NFC) static handover 14625b9c547cSRui Paulo * case or -1 if not used 1463f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1464f05cddf9SRui Paulo */ 1465f05cddf9SRui Paulo int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role, 1466f05cddf9SRui Paulo const u8 *bssid, const u8 *ssid, size_t ssid_len, 1467f05cddf9SRui Paulo unsigned int force_freq, const u8 *go_dev_addr, 14685b9c547cSRui Paulo int persistent_group, unsigned int pref_freq, int dev_pw_id); 1469f05cddf9SRui Paulo 1470f05cddf9SRui Paulo /** 1471f05cddf9SRui Paulo * p2p_presence_req - Request GO presence 1472f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1473f05cddf9SRui Paulo * @go_interface_addr: GO P2P Interface Address 1474f05cddf9SRui Paulo * @own_interface_addr: Own P2P Interface Address for this group 1475f05cddf9SRui Paulo * @freq: Group operating frequence (in MHz) 1476f05cddf9SRui Paulo * @duration1: Preferred presence duration in microseconds 1477f05cddf9SRui Paulo * @interval1: Preferred presence interval in microseconds 1478f05cddf9SRui Paulo * @duration2: Acceptable presence duration in microseconds 1479f05cddf9SRui Paulo * @interval2: Acceptable presence interval in microseconds 1480f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1481f05cddf9SRui Paulo * 1482f05cddf9SRui Paulo * If both duration and interval values are zero, the parameter pair is not 1483f05cddf9SRui Paulo * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0). 1484f05cddf9SRui Paulo */ 1485f05cddf9SRui Paulo int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr, 1486f05cddf9SRui Paulo const u8 *own_interface_addr, unsigned int freq, 1487f05cddf9SRui Paulo u32 duration1, u32 interval1, u32 duration2, 1488f05cddf9SRui Paulo u32 interval2); 1489f05cddf9SRui Paulo 1490f05cddf9SRui Paulo /** 1491f05cddf9SRui Paulo * p2p_ext_listen - Set Extended Listen Timing 1492f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1493f05cddf9SRui Paulo * @freq: Group operating frequence (in MHz) 1494f05cddf9SRui Paulo * @period: Availability period in milliseconds (1-65535; 0 to disable) 1495f05cddf9SRui Paulo * @interval: Availability interval in milliseconds (1-65535; 0 to disable) 1496f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1497f05cddf9SRui Paulo * 1498f05cddf9SRui Paulo * This function can be used to enable or disable (period = interval = 0) 1499f05cddf9SRui Paulo * Extended Listen Timing. When enabled, the P2P Device will become 1500f05cddf9SRui Paulo * discoverable (go into Listen State) every @interval milliseconds for at 1501f05cddf9SRui Paulo * least @period milliseconds. 1502f05cddf9SRui Paulo */ 1503f05cddf9SRui Paulo int p2p_ext_listen(struct p2p_data *p2p, unsigned int period, 1504f05cddf9SRui Paulo unsigned int interval); 1505f05cddf9SRui Paulo 1506f05cddf9SRui Paulo /* Event notifications from upper layer management operations */ 1507f05cddf9SRui Paulo 1508f05cddf9SRui Paulo /** 1509f05cddf9SRui Paulo * p2p_wps_success_cb - Report successfully completed WPS provisioning 1510f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1511f05cddf9SRui Paulo * @mac_addr: Peer address 1512f05cddf9SRui Paulo * 1513f05cddf9SRui Paulo * This function is used to report successfully completed WPS provisioning 1514f05cddf9SRui Paulo * during group formation in both GO/Registrar and client/Enrollee roles. 1515f05cddf9SRui Paulo */ 1516f05cddf9SRui Paulo void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr); 1517f05cddf9SRui Paulo 1518f05cddf9SRui Paulo /** 1519f05cddf9SRui Paulo * p2p_group_formation_failed - Report failed WPS provisioning 1520f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1521f05cddf9SRui Paulo * 1522f05cddf9SRui Paulo * This function is used to report failed group formation. This can happen 1523f05cddf9SRui Paulo * either due to failed WPS provisioning or due to 15 second timeout during 1524f05cddf9SRui Paulo * the provisioning phase. 1525f05cddf9SRui Paulo */ 1526f05cddf9SRui Paulo void p2p_group_formation_failed(struct p2p_data *p2p); 1527f05cddf9SRui Paulo 1528f05cddf9SRui Paulo /** 1529f05cddf9SRui Paulo * p2p_get_provisioning_info - Get any stored provisioning info 1530f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1531f05cddf9SRui Paulo * @addr: Peer P2P Device Address 1532f05cddf9SRui Paulo * Returns: WPS provisioning information (WPS config method) or 0 if no 1533f05cddf9SRui Paulo * information is available 1534f05cddf9SRui Paulo * 1535f05cddf9SRui Paulo * This function is used to retrieve stored WPS provisioning info for the given 1536f05cddf9SRui Paulo * peer. 1537f05cddf9SRui Paulo */ 1538f05cddf9SRui Paulo u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr); 1539f05cddf9SRui Paulo 1540f05cddf9SRui Paulo /** 1541f05cddf9SRui Paulo * p2p_clear_provisioning_info - Clear any stored provisioning info 1542f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1543f05cddf9SRui Paulo * @iface_addr: Peer P2P Device Address 1544f05cddf9SRui Paulo * 1545f05cddf9SRui Paulo * This function is used to clear stored WPS provisioning info for the given 1546f05cddf9SRui Paulo * peer. 1547f05cddf9SRui Paulo */ 1548f05cddf9SRui Paulo void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr); 1549f05cddf9SRui Paulo 1550f05cddf9SRui Paulo 1551f05cddf9SRui Paulo /* Event notifications from lower layer driver operations */ 1552f05cddf9SRui Paulo 1553f05cddf9SRui Paulo /** 1554f05cddf9SRui Paulo * enum p2p_probe_req_status 1555f05cddf9SRui Paulo * 1556f05cddf9SRui Paulo * @P2P_PREQ_MALFORMED: frame was not well-formed 1557f05cddf9SRui Paulo * @P2P_PREQ_NOT_LISTEN: device isn't in listen state, frame ignored 1558f05cddf9SRui Paulo * @P2P_PREQ_NOT_P2P: frame was not a P2P probe request 1559f05cddf9SRui Paulo * @P2P_PREQ_P2P_NOT_PROCESSED: frame was P2P but wasn't processed 1560f05cddf9SRui Paulo * @P2P_PREQ_P2P_PROCESSED: frame has been processed by P2P 1561f05cddf9SRui Paulo */ 1562f05cddf9SRui Paulo enum p2p_probe_req_status { 1563f05cddf9SRui Paulo P2P_PREQ_MALFORMED, 1564f05cddf9SRui Paulo P2P_PREQ_NOT_LISTEN, 1565f05cddf9SRui Paulo P2P_PREQ_NOT_P2P, 1566f05cddf9SRui Paulo P2P_PREQ_NOT_PROCESSED, 1567f05cddf9SRui Paulo P2P_PREQ_PROCESSED 1568f05cddf9SRui Paulo }; 1569f05cddf9SRui Paulo 1570f05cddf9SRui Paulo /** 1571f05cddf9SRui Paulo * p2p_probe_req_rx - Report reception of a Probe Request frame 1572f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1573f05cddf9SRui Paulo * @addr: Source MAC address 1574f05cddf9SRui Paulo * @dst: Destination MAC address if available or %NULL 1575f05cddf9SRui Paulo * @bssid: BSSID if available or %NULL 1576f05cddf9SRui Paulo * @ie: Information elements from the Probe Request frame body 1577f05cddf9SRui Paulo * @ie_len: Length of ie buffer in octets 1578325151a3SRui Paulo * @rx_freq: Probe Request frame RX frequency 1579780fb4a2SCy Schubert * @p2p_lo_started: Whether P2P Listen Offload is started 1580f05cddf9SRui Paulo * Returns: value indicating the type and status of the probe request 1581f05cddf9SRui Paulo */ 1582f05cddf9SRui Paulo enum p2p_probe_req_status 1583f05cddf9SRui Paulo p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, 1584325151a3SRui Paulo const u8 *bssid, const u8 *ie, size_t ie_len, 1585780fb4a2SCy Schubert unsigned int rx_freq, int p2p_lo_started); 1586f05cddf9SRui Paulo 1587f05cddf9SRui Paulo /** 1588f05cddf9SRui Paulo * p2p_rx_action - Report received Action frame 1589f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1590f05cddf9SRui Paulo * @da: Destination address of the received Action frame 1591f05cddf9SRui Paulo * @sa: Source address of the received Action frame 1592f05cddf9SRui Paulo * @bssid: Address 3 of the received Action frame 1593f05cddf9SRui Paulo * @category: Category of the received Action frame 1594f05cddf9SRui Paulo * @data: Action frame body after the Category field 1595f05cddf9SRui Paulo * @len: Length of the data buffer in octets 1596f05cddf9SRui Paulo * @freq: Frequency (in MHz) on which the frame was received 1597f05cddf9SRui Paulo */ 1598f05cddf9SRui Paulo void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa, 1599f05cddf9SRui Paulo const u8 *bssid, u8 category, 1600f05cddf9SRui Paulo const u8 *data, size_t len, int freq); 1601f05cddf9SRui Paulo 1602f05cddf9SRui Paulo /** 1603f05cddf9SRui Paulo * p2p_scan_res_handler - Indicate a P2P scan results 1604f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1605f05cddf9SRui Paulo * @bssid: BSSID of the scan result 1606f05cddf9SRui Paulo * @freq: Frequency of the channel on which the device was found in MHz 16075b9c547cSRui Paulo * @rx_time: Time when the result was received 1608f05cddf9SRui Paulo * @level: Signal level (signal strength of the received Beacon/Probe Response 1609f05cddf9SRui Paulo * frame) 1610f05cddf9SRui Paulo * @ies: Pointer to IEs from the scan result 1611f05cddf9SRui Paulo * @ies_len: Length of the ies buffer 1612f05cddf9SRui Paulo * Returns: 0 to continue or 1 to stop scan result indication 1613f05cddf9SRui Paulo * 1614f05cddf9SRui Paulo * This function is called to indicate a scan result entry with P2P IE from a 1615f05cddf9SRui Paulo * scan requested with struct p2p_config::p2p_scan(). This can be called during 1616f05cddf9SRui Paulo * the actual scan process (i.e., whenever a new device is found) or as a 1617f05cddf9SRui Paulo * sequence of calls after the full scan has been completed. The former option 1618f05cddf9SRui Paulo * can result in optimized operations, but may not be supported by all 1619f05cddf9SRui Paulo * driver/firmware designs. The ies buffer need to include at least the P2P IE, 1620f05cddf9SRui Paulo * but it is recommended to include all IEs received from the device. The 1621f05cddf9SRui Paulo * caller does not need to check that the IEs contain a P2P IE before calling 1622f05cddf9SRui Paulo * this function since frames will be filtered internally if needed. 1623f05cddf9SRui Paulo * 1624f05cddf9SRui Paulo * This function will return 1 if it wants to stop scan result iteration (and 1625f05cddf9SRui Paulo * scan in general if it is still in progress). This is used to allow faster 1626f05cddf9SRui Paulo * start of a pending operation, e.g., to start a pending GO negotiation. 1627f05cddf9SRui Paulo */ 1628f05cddf9SRui Paulo int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, 16295b9c547cSRui Paulo struct os_reltime *rx_time, int level, const u8 *ies, 1630f05cddf9SRui Paulo size_t ies_len); 1631f05cddf9SRui Paulo 1632f05cddf9SRui Paulo /** 1633f05cddf9SRui Paulo * p2p_scan_res_handled - Indicate end of scan results 1634f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1635c1d255d3SCy Schubert * @delay: Search delay for next scan in ms 1636f05cddf9SRui Paulo * 1637f05cddf9SRui Paulo * This function is called to indicate that all P2P scan results from a scan 1638f05cddf9SRui Paulo * have been reported with zero or more calls to p2p_scan_res_handler(). This 1639f05cddf9SRui Paulo * function must be called as a response to successful 1640f05cddf9SRui Paulo * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler() 1641f05cddf9SRui Paulo * calls stopped iteration. 1642f05cddf9SRui Paulo */ 1643c1d255d3SCy Schubert void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay); 1644f05cddf9SRui Paulo 1645f05cddf9SRui Paulo enum p2p_send_action_result { 1646f05cddf9SRui Paulo P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */, 1647f05cddf9SRui Paulo P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */, 1648f05cddf9SRui Paulo P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */ 1649f05cddf9SRui Paulo }; 1650f05cddf9SRui Paulo 1651f05cddf9SRui Paulo /** 1652f05cddf9SRui Paulo * p2p_send_action_cb - Notify TX status of an Action frame 1653f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1654f05cddf9SRui Paulo * @freq: Channel frequency in MHz 1655f05cddf9SRui Paulo * @dst: Destination MAC address (Address 1) 1656f05cddf9SRui Paulo * @src: Source MAC address (Address 2) 1657f05cddf9SRui Paulo * @bssid: BSSID (Address 3) 1658f05cddf9SRui Paulo * @result: Result of the transmission attempt 1659f05cddf9SRui Paulo * 1660f05cddf9SRui Paulo * This function is used to indicate the result of an Action frame transmission 1661f05cddf9SRui Paulo * that was requested with struct p2p_config::send_action() callback. 1662f05cddf9SRui Paulo */ 1663f05cddf9SRui Paulo void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, 1664f05cddf9SRui Paulo const u8 *src, const u8 *bssid, 1665f05cddf9SRui Paulo enum p2p_send_action_result result); 1666f05cddf9SRui Paulo 1667f05cddf9SRui Paulo /** 1668f05cddf9SRui Paulo * p2p_listen_cb - Indicate the start of a requested Listen state 1669f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1670f05cddf9SRui Paulo * @freq: Listen channel frequency in MHz 1671f05cddf9SRui Paulo * @duration: Duration for the Listen state in milliseconds 1672f05cddf9SRui Paulo * 1673f05cddf9SRui Paulo * This function is used to indicate that a Listen state requested with 1674f05cddf9SRui Paulo * struct p2p_config::start_listen() callback has started. 1675f05cddf9SRui Paulo */ 1676f05cddf9SRui Paulo void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq, 1677f05cddf9SRui Paulo unsigned int duration); 1678f05cddf9SRui Paulo 1679f05cddf9SRui Paulo /** 1680f05cddf9SRui Paulo * p2p_listen_end - Indicate the end of a requested Listen state 1681f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1682f05cddf9SRui Paulo * @freq: Listen channel frequency in MHz 1683f05cddf9SRui Paulo * Returns: 0 if no operations were started, 1 if an operation was started 1684f05cddf9SRui Paulo * 1685f05cddf9SRui Paulo * This function is used to indicate that a Listen state requested with 1686f05cddf9SRui Paulo * struct p2p_config::start_listen() callback has ended. 1687f05cddf9SRui Paulo */ 1688f05cddf9SRui Paulo int p2p_listen_end(struct p2p_data *p2p, unsigned int freq); 1689f05cddf9SRui Paulo 1690f05cddf9SRui Paulo void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, 1691f05cddf9SRui Paulo const u8 *ie, size_t ie_len); 1692f05cddf9SRui Paulo 1693f05cddf9SRui Paulo void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, 1694f05cddf9SRui Paulo const u8 *ie, size_t ie_len); 1695f05cddf9SRui Paulo 1696f05cddf9SRui Paulo 1697f05cddf9SRui Paulo /* Per-group P2P state for GO */ 1698f05cddf9SRui Paulo 1699f05cddf9SRui Paulo struct p2p_group; 1700f05cddf9SRui Paulo 1701f05cddf9SRui Paulo /** 1702f05cddf9SRui Paulo * struct p2p_group_config - P2P group configuration 1703f05cddf9SRui Paulo * 1704f05cddf9SRui Paulo * This configuration is provided to the P2P module during initialization of 1705f05cddf9SRui Paulo * the per-group information with p2p_group_init(). 1706f05cddf9SRui Paulo */ 1707f05cddf9SRui Paulo struct p2p_group_config { 1708f05cddf9SRui Paulo /** 1709f05cddf9SRui Paulo * persistent_group - Whether the group is persistent 1710f05cddf9SRui Paulo * 0 = not a persistent group 1711f05cddf9SRui Paulo * 1 = persistent group without persistent reconnect 1712f05cddf9SRui Paulo * 2 = persistent group with persistent reconnect 1713f05cddf9SRui Paulo */ 1714f05cddf9SRui Paulo int persistent_group; 1715f05cddf9SRui Paulo 1716f05cddf9SRui Paulo /** 1717f05cddf9SRui Paulo * interface_addr - P2P Interface Address of the group 1718f05cddf9SRui Paulo */ 1719f05cddf9SRui Paulo u8 interface_addr[ETH_ALEN]; 1720f05cddf9SRui Paulo 1721f05cddf9SRui Paulo /** 1722f05cddf9SRui Paulo * max_clients - Maximum number of clients in the group 1723f05cddf9SRui Paulo */ 1724f05cddf9SRui Paulo unsigned int max_clients; 1725f05cddf9SRui Paulo 1726f05cddf9SRui Paulo /** 1727f05cddf9SRui Paulo * ssid - Group SSID 1728f05cddf9SRui Paulo */ 1729325151a3SRui Paulo u8 ssid[SSID_MAX_LEN]; 1730f05cddf9SRui Paulo 1731f05cddf9SRui Paulo /** 1732f05cddf9SRui Paulo * ssid_len - Length of SSID 1733f05cddf9SRui Paulo */ 1734f05cddf9SRui Paulo size_t ssid_len; 1735f05cddf9SRui Paulo 1736f05cddf9SRui Paulo /** 17375b9c547cSRui Paulo * freq - Operating channel of the group 17385b9c547cSRui Paulo */ 17395b9c547cSRui Paulo int freq; 17405b9c547cSRui Paulo 17415b9c547cSRui Paulo /** 1742780fb4a2SCy Schubert * ip_addr_alloc - Whether IP address allocation within 4-way handshake 1743780fb4a2SCy Schubert * is supported 1744780fb4a2SCy Schubert */ 1745780fb4a2SCy Schubert int ip_addr_alloc; 1746780fb4a2SCy Schubert 1747780fb4a2SCy Schubert /** 1748f05cddf9SRui Paulo * cb_ctx - Context to use with callback functions 1749f05cddf9SRui Paulo */ 1750f05cddf9SRui Paulo void *cb_ctx; 1751f05cddf9SRui Paulo 1752f05cddf9SRui Paulo /** 1753f05cddf9SRui Paulo * ie_update - Notification of IE update 1754f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 1755f05cddf9SRui Paulo * @beacon_ies: P2P IE for Beacon frames or %NULL if no change 1756f05cddf9SRui Paulo * @proberesp_ies: P2P Ie for Probe Response frames 1757f05cddf9SRui Paulo * 1758f05cddf9SRui Paulo * P2P module uses this callback function to notify whenever the P2P IE 1759f05cddf9SRui Paulo * in Beacon or Probe Response frames should be updated based on group 1760f05cddf9SRui Paulo * events. 1761f05cddf9SRui Paulo * 1762f05cddf9SRui Paulo * The callee is responsible for freeing the returned buffer(s) with 1763f05cddf9SRui Paulo * wpabuf_free(). 1764f05cddf9SRui Paulo */ 1765f05cddf9SRui Paulo void (*ie_update)(void *ctx, struct wpabuf *beacon_ies, 1766f05cddf9SRui Paulo struct wpabuf *proberesp_ies); 1767f05cddf9SRui Paulo 1768f05cddf9SRui Paulo /** 1769f05cddf9SRui Paulo * idle_update - Notification of changes in group idle state 1770f05cddf9SRui Paulo * @ctx: Callback context from cb_ctx 1771f05cddf9SRui Paulo * @idle: Whether the group is idle (no associated stations) 1772f05cddf9SRui Paulo */ 1773f05cddf9SRui Paulo void (*idle_update)(void *ctx, int idle); 1774f05cddf9SRui Paulo }; 1775f05cddf9SRui Paulo 1776f05cddf9SRui Paulo /** 1777f05cddf9SRui Paulo * p2p_group_init - Initialize P2P group 1778f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1779f05cddf9SRui Paulo * @config: P2P group configuration (will be freed by p2p_group_deinit()) 1780f05cddf9SRui Paulo * Returns: Pointer to private data or %NULL on failure 1781f05cddf9SRui Paulo * 1782f05cddf9SRui Paulo * This function is used to initialize per-group P2P module context. Currently, 1783f05cddf9SRui Paulo * this is only used to manage GO functionality and P2P clients do not need to 1784f05cddf9SRui Paulo * create an instance of this per-group information. 1785f05cddf9SRui Paulo */ 1786f05cddf9SRui Paulo struct p2p_group * p2p_group_init(struct p2p_data *p2p, 1787f05cddf9SRui Paulo struct p2p_group_config *config); 1788f05cddf9SRui Paulo 1789f05cddf9SRui Paulo /** 1790f05cddf9SRui Paulo * p2p_group_deinit - Deinitialize P2P group 1791f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1792f05cddf9SRui Paulo */ 1793f05cddf9SRui Paulo void p2p_group_deinit(struct p2p_group *group); 1794f05cddf9SRui Paulo 1795f05cddf9SRui Paulo /** 1796f05cddf9SRui Paulo * p2p_group_notif_assoc - Notification of P2P client association with GO 1797f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1798f05cddf9SRui Paulo * @addr: Interface address of the P2P client 1799f05cddf9SRui Paulo * @ie: IEs from the (Re)association Request frame 1800f05cddf9SRui Paulo * @len: Length of the ie buffer in octets 1801f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1802f05cddf9SRui Paulo */ 1803f05cddf9SRui Paulo int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr, 1804f05cddf9SRui Paulo const u8 *ie, size_t len); 1805f05cddf9SRui Paulo 1806f05cddf9SRui Paulo /** 1807f05cddf9SRui Paulo * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response 1808f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1809f05cddf9SRui Paulo * @status: Status value (P2P_SC_SUCCESS if association succeeded) 1810f05cddf9SRui Paulo * Returns: P2P IE for (Re)association Response or %NULL on failure 1811f05cddf9SRui Paulo * 1812f05cddf9SRui Paulo * The caller is responsible for freeing the returned buffer with 1813f05cddf9SRui Paulo * wpabuf_free(). 1814f05cddf9SRui Paulo */ 1815f05cddf9SRui Paulo struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status); 1816f05cddf9SRui Paulo 1817f05cddf9SRui Paulo /** 1818f05cddf9SRui Paulo * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO 1819f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1820f05cddf9SRui Paulo * @addr: Interface address of the P2P client 1821f05cddf9SRui Paulo */ 1822f05cddf9SRui Paulo void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr); 1823f05cddf9SRui Paulo 1824f05cddf9SRui Paulo /** 1825f05cddf9SRui Paulo * p2p_group_notif_formation_done - Notification of completed group formation 1826f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1827f05cddf9SRui Paulo */ 1828f05cddf9SRui Paulo void p2p_group_notif_formation_done(struct p2p_group *group); 1829f05cddf9SRui Paulo 1830f05cddf9SRui Paulo /** 1831f05cddf9SRui Paulo * p2p_group_notif_noa - Notification of NoA change 1832f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1833f05cddf9SRui Paulo * @noa: Notice of Absence attribute payload, %NULL if none 1834f05cddf9SRui Paulo * @noa_len: Length of noa buffer in octets 1835f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1836f05cddf9SRui Paulo * 1837f05cddf9SRui Paulo * Notify the P2P group management about a new NoA contents. This will be 1838f05cddf9SRui Paulo * inserted into the P2P IEs in Beacon and Probe Response frames with rest of 1839f05cddf9SRui Paulo * the group information. 1840f05cddf9SRui Paulo */ 1841f05cddf9SRui Paulo int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, 1842f05cddf9SRui Paulo size_t noa_len); 1843f05cddf9SRui Paulo 1844f05cddf9SRui Paulo /** 1845f05cddf9SRui Paulo * p2p_group_match_dev_type - Match device types in group with requested type 1846f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1847f05cddf9SRui Paulo * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs) 1848f05cddf9SRui Paulo * Returns: 1 on match, 0 on mismatch 1849f05cddf9SRui Paulo * 1850f05cddf9SRui Paulo * This function can be used to match the Requested Device Type attribute in 1851f05cddf9SRui Paulo * WPS IE with the device types of a group member for deciding whether a GO 1852f05cddf9SRui Paulo * should reply to a Probe Request frame. Match will be reported if the WPS IE 1853f05cddf9SRui Paulo * is not requested any specific device type. 1854f05cddf9SRui Paulo */ 1855f05cddf9SRui Paulo int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps); 1856f05cddf9SRui Paulo 1857f05cddf9SRui Paulo /** 1858f05cddf9SRui Paulo * p2p_group_match_dev_id - Match P2P Device Address in group with requested device id 1859f05cddf9SRui Paulo */ 1860f05cddf9SRui Paulo int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p); 1861f05cddf9SRui Paulo 1862f05cddf9SRui Paulo /** 1863f05cddf9SRui Paulo * p2p_group_go_discover - Send GO Discoverability Request to a group client 1864f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 1865f05cddf9SRui Paulo * Returns: 0 on success (frame scheduled); -1 if client was not found 1866f05cddf9SRui Paulo */ 1867f05cddf9SRui Paulo int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id, 1868f05cddf9SRui Paulo const u8 *searching_dev, int rx_freq); 1869f05cddf9SRui Paulo 1870f05cddf9SRui Paulo 1871f05cddf9SRui Paulo /* Generic helper functions */ 1872f05cddf9SRui Paulo 1873f05cddf9SRui Paulo /** 1874f05cddf9SRui Paulo * p2p_ie_text - Build text format description of P2P IE 1875f05cddf9SRui Paulo * @p2p_ie: P2P IE 1876f05cddf9SRui Paulo * @buf: Buffer for returning text 1877f05cddf9SRui Paulo * @end: Pointer to the end of the buf area 1878f05cddf9SRui Paulo * Returns: Number of octets written to the buffer or -1 on failure 1879f05cddf9SRui Paulo * 1880f05cddf9SRui Paulo * This function can be used to parse P2P IE contents into text format 1881f05cddf9SRui Paulo * field=value lines. 1882f05cddf9SRui Paulo */ 1883f05cddf9SRui Paulo int p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end); 1884f05cddf9SRui Paulo 1885f05cddf9SRui Paulo /** 1886f05cddf9SRui Paulo * p2p_scan_result_text - Build text format description of P2P IE 1887f05cddf9SRui Paulo * @ies: Information elements from scan results 1888f05cddf9SRui Paulo * @ies_len: ies buffer length in octets 1889f05cddf9SRui Paulo * @buf: Buffer for returning text 1890f05cddf9SRui Paulo * @end: Pointer to the end of the buf area 1891f05cddf9SRui Paulo * Returns: Number of octets written to the buffer or -1 on failure 1892f05cddf9SRui Paulo * 1893f05cddf9SRui Paulo * This function can be used to parse P2P IE contents into text format 1894f05cddf9SRui Paulo * field=value lines. 1895f05cddf9SRui Paulo */ 1896f05cddf9SRui Paulo int p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end); 1897f05cddf9SRui Paulo 1898f05cddf9SRui Paulo /** 1899f05cddf9SRui Paulo * p2p_parse_dev_addr_in_p2p_ie - Parse P2P Device Address from a concatenated 1900f05cddf9SRui Paulo * P2P IE 1901f05cddf9SRui Paulo * @p2p_ie: P2P IE 1902f05cddf9SRui Paulo * @dev_addr: Buffer for returning P2P Device Address 1903f05cddf9SRui Paulo * Returns: 0 on success or -1 if P2P Device Address could not be parsed 1904f05cddf9SRui Paulo */ 1905f05cddf9SRui Paulo int p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr); 1906f05cddf9SRui Paulo 1907f05cddf9SRui Paulo /** 1908f05cddf9SRui Paulo * p2p_parse_dev_addr - Parse P2P Device Address from P2P IE(s) 1909f05cddf9SRui Paulo * @ies: Information elements from scan results 1910f05cddf9SRui Paulo * @ies_len: ies buffer length in octets 1911f05cddf9SRui Paulo * @dev_addr: Buffer for returning P2P Device Address 1912f05cddf9SRui Paulo * Returns: 0 on success or -1 if P2P Device Address could not be parsed 1913f05cddf9SRui Paulo */ 1914f05cddf9SRui Paulo int p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr); 1915f05cddf9SRui Paulo 1916f05cddf9SRui Paulo /** 1917f05cddf9SRui Paulo * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame 1918f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1919f05cddf9SRui Paulo * @bssid: BSSID 1920f05cddf9SRui Paulo * @buf: Buffer for writing the P2P IE 1921f05cddf9SRui Paulo * @len: Maximum buf length in octets 1922f05cddf9SRui Paulo * @p2p_group: Whether this is for association with a P2P GO 1923f05cddf9SRui Paulo * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none 1924f05cddf9SRui Paulo * Returns: Number of octets written into buf or -1 on failure 1925f05cddf9SRui Paulo */ 1926f05cddf9SRui Paulo int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf, 1927f05cddf9SRui Paulo size_t len, int p2p_group, struct wpabuf *p2p_ie); 1928f05cddf9SRui Paulo 1929f05cddf9SRui Paulo /** 1930f05cddf9SRui Paulo * p2p_scan_ie - Build P2P IE for Probe Request 1931f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1932f05cddf9SRui Paulo * @ies: Buffer for writing P2P IE 1933f05cddf9SRui Paulo * @dev_id: Device ID to search for or %NULL for any 1934780fb4a2SCy Schubert * @bands: Frequency bands used in the scan (enum wpa_radio_work_band bitmap) 1935f05cddf9SRui Paulo */ 1936780fb4a2SCy Schubert void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id, 1937780fb4a2SCy Schubert unsigned int bands); 1938f05cddf9SRui Paulo 1939f05cddf9SRui Paulo /** 1940f05cddf9SRui Paulo * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie 1941f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1942f05cddf9SRui Paulo * Returns: Number of octets that p2p_scan_ie() may add to the buffer 1943f05cddf9SRui Paulo */ 1944f05cddf9SRui Paulo size_t p2p_scan_ie_buf_len(struct p2p_data *p2p); 1945f05cddf9SRui Paulo 1946f05cddf9SRui Paulo /** 1947f05cddf9SRui Paulo * p2p_go_params - Generate random P2P group parameters 1948f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1949f05cddf9SRui Paulo * @params: Buffer for parameters 1950f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 1951f05cddf9SRui Paulo */ 1952f05cddf9SRui Paulo int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params); 1953f05cddf9SRui Paulo 1954f05cddf9SRui Paulo /** 1955f05cddf9SRui Paulo * p2p_get_group_capab - Get Group Capability from P2P IE data 1956f05cddf9SRui Paulo * @p2p_ie: P2P IE(s) contents 1957f05cddf9SRui Paulo * Returns: Group Capability 1958f05cddf9SRui Paulo */ 1959f05cddf9SRui Paulo u8 p2p_get_group_capab(const struct wpabuf *p2p_ie); 1960f05cddf9SRui Paulo 1961f05cddf9SRui Paulo /** 1962f05cddf9SRui Paulo * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection 1963f05cddf9SRui Paulo * @p2p_ie: P2P IE(s) contents 1964f05cddf9SRui Paulo * Returns: 0 if cross connection is allow, 1 if not 1965f05cddf9SRui Paulo */ 1966f05cddf9SRui Paulo int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie); 1967f05cddf9SRui Paulo 1968f05cddf9SRui Paulo /** 1969f05cddf9SRui Paulo * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data 1970f05cddf9SRui Paulo * @p2p_ie: P2P IE(s) contents 1971f05cddf9SRui Paulo * Returns: Pointer to P2P Device Address or %NULL if not included 1972f05cddf9SRui Paulo */ 1973f05cddf9SRui Paulo const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie); 1974f05cddf9SRui Paulo 1975f05cddf9SRui Paulo /** 1976f05cddf9SRui Paulo * p2p_get_peer_info - Get P2P peer information 1977f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 1978f05cddf9SRui Paulo * @addr: P2P Device Address of the peer or %NULL to indicate the first peer 1979f05cddf9SRui Paulo * @next: Whether to select the peer entry following the one indicated by addr 1980f05cddf9SRui Paulo * Returns: Pointer to peer info or %NULL if not found 1981f05cddf9SRui Paulo */ 1982f05cddf9SRui Paulo const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p, 1983f05cddf9SRui Paulo const u8 *addr, int next); 1984f05cddf9SRui Paulo 1985f05cddf9SRui Paulo /** 1986f05cddf9SRui Paulo * p2p_get_peer_info_txt - Get internal P2P peer information in text format 1987f05cddf9SRui Paulo * @info: Pointer to P2P peer info from p2p_get_peer_info() 1988f05cddf9SRui Paulo * @buf: Buffer for returning text 1989f05cddf9SRui Paulo * @buflen: Maximum buffer length 1990f05cddf9SRui Paulo * Returns: Number of octets written to the buffer or -1 on failure 1991f05cddf9SRui Paulo * 1992f05cddf9SRui Paulo * Note: This information is internal to the P2P module and subject to change. 1993f05cddf9SRui Paulo * As such, this should not really be used by external programs for purposes 1994f05cddf9SRui Paulo * other than debugging. 1995f05cddf9SRui Paulo */ 1996f05cddf9SRui Paulo int p2p_get_peer_info_txt(const struct p2p_peer_info *info, 1997f05cddf9SRui Paulo char *buf, size_t buflen); 1998f05cddf9SRui Paulo 1999f05cddf9SRui Paulo /** 2000f05cddf9SRui Paulo * p2p_peer_known - Check whether P2P peer is known 2001f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2002f05cddf9SRui Paulo * @addr: P2P Device Address of the peer 2003f05cddf9SRui Paulo * Returns: 1 if the specified device is in the P2P peer table or 0 if not 2004f05cddf9SRui Paulo */ 2005f05cddf9SRui Paulo int p2p_peer_known(struct p2p_data *p2p, const u8 *addr); 2006f05cddf9SRui Paulo 2007f05cddf9SRui Paulo /** 2008f05cddf9SRui Paulo * p2p_set_client_discoverability - Set client discoverability capability 2009f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2010f05cddf9SRui Paulo * @enabled: Whether client discoverability will be enabled 2011f05cddf9SRui Paulo * 2012f05cddf9SRui Paulo * This function can be used to disable (and re-enable) client discoverability. 2013f05cddf9SRui Paulo * This capability is enabled by default and should not be disabled in normal 2014f05cddf9SRui Paulo * use cases, i.e., this is mainly for testing purposes. 2015f05cddf9SRui Paulo */ 2016f05cddf9SRui Paulo void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled); 2017f05cddf9SRui Paulo 2018f05cddf9SRui Paulo /** 2019f05cddf9SRui Paulo * p2p_set_managed_oper - Set managed P2P Device operations capability 2020f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2021f05cddf9SRui Paulo * @enabled: Whether managed P2P Device operations will be enabled 2022f05cddf9SRui Paulo */ 2023f05cddf9SRui Paulo void p2p_set_managed_oper(struct p2p_data *p2p, int enabled); 2024f05cddf9SRui Paulo 20255b9c547cSRui Paulo /** 20265b9c547cSRui Paulo * p2p_config_get_random_social - Return a random social channel 20275b9c547cSRui Paulo * @p2p: P2P config 20285b9c547cSRui Paulo * @op_class: Selected operating class 20295b9c547cSRui Paulo * @op_channel: Selected social channel 20304bc52338SCy Schubert * @avoid_list: Channel ranges to try to avoid or %NULL 20314bc52338SCy Schubert * @disallow_list: Channel ranges to discard or %NULL 20325b9c547cSRui Paulo * Returns: 0 on success, -1 on failure 20335b9c547cSRui Paulo * 20345b9c547cSRui Paulo * This function is used before p2p_init is called. A random social channel 20355b9c547cSRui Paulo * from supports bands 2.4 GHz (channels 1,6,11) and 60 GHz (channel 2) is 20365b9c547cSRui Paulo * returned on success. 20375b9c547cSRui Paulo */ 20385b9c547cSRui Paulo int p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class, 20394bc52338SCy Schubert u8 *op_channel, 20404bc52338SCy Schubert struct wpa_freq_range_list *avoid_list, 20414bc52338SCy Schubert struct wpa_freq_range_list *disallow_list); 20425b9c547cSRui Paulo 20435b9c547cSRui Paulo int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel, 20445b9c547cSRui Paulo u8 forced); 20455b9c547cSRui Paulo 20465b9c547cSRui Paulo u8 p2p_get_listen_channel(struct p2p_data *p2p); 2047f05cddf9SRui Paulo 2048f05cddf9SRui Paulo int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len); 2049f05cddf9SRui Paulo 2050f05cddf9SRui Paulo int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, 2051f05cddf9SRui Paulo u8 *iface_addr); 2052f05cddf9SRui Paulo int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, 2053f05cddf9SRui Paulo u8 *dev_addr); 2054f05cddf9SRui Paulo 2055f05cddf9SRui Paulo void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr); 2056f05cddf9SRui Paulo 2057f05cddf9SRui Paulo /** 2058f05cddf9SRui Paulo * p2p_set_cross_connect - Set cross connection capability 2059f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2060f05cddf9SRui Paulo * @enabled: Whether cross connection will be enabled 2061f05cddf9SRui Paulo */ 2062f05cddf9SRui Paulo void p2p_set_cross_connect(struct p2p_data *p2p, int enabled); 2063f05cddf9SRui Paulo 2064f05cddf9SRui Paulo int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr); 2065f05cddf9SRui Paulo 2066f05cddf9SRui Paulo /** 2067f05cddf9SRui Paulo * p2p_set_intra_bss_dist - Set intra BSS distribution 2068f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2069f05cddf9SRui Paulo * @enabled: Whether intra BSS distribution will be enabled 2070f05cddf9SRui Paulo */ 2071f05cddf9SRui Paulo void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled); 2072f05cddf9SRui Paulo 20735b9c547cSRui Paulo int p2p_channels_includes_freq(const struct p2p_channels *channels, 20745b9c547cSRui Paulo unsigned int freq); 20755b9c547cSRui Paulo 20765b9c547cSRui Paulo int p2p_channels_to_freqs(const struct p2p_channels *channels, 20775b9c547cSRui Paulo int *freq_list, unsigned int max_len); 20785b9c547cSRui Paulo 2079f05cddf9SRui Paulo /** 2080f05cddf9SRui Paulo * p2p_supported_freq - Check whether channel is supported for P2P 2081f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2082f05cddf9SRui Paulo * @freq: Channel frequency in MHz 2083f05cddf9SRui Paulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 2084f05cddf9SRui Paulo */ 2085f05cddf9SRui Paulo int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq); 2086f05cddf9SRui Paulo 20875b9c547cSRui Paulo /** 20885b9c547cSRui Paulo * p2p_supported_freq_go - Check whether channel is supported for P2P GO operation 20895b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 20905b9c547cSRui Paulo * @freq: Channel frequency in MHz 20915b9c547cSRui Paulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 20925b9c547cSRui Paulo */ 20935b9c547cSRui Paulo int p2p_supported_freq_go(struct p2p_data *p2p, unsigned int freq); 20945b9c547cSRui Paulo 20955b9c547cSRui Paulo /** 20965b9c547cSRui Paulo * p2p_supported_freq_cli - Check whether channel is supported for P2P client operation 20975b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 20985b9c547cSRui Paulo * @freq: Channel frequency in MHz 20995b9c547cSRui Paulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 21005b9c547cSRui Paulo */ 21015b9c547cSRui Paulo int p2p_supported_freq_cli(struct p2p_data *p2p, unsigned int freq); 21025b9c547cSRui Paulo 21035b9c547cSRui Paulo /** 21045b9c547cSRui Paulo * p2p_get_pref_freq - Get channel from preferred channel list 21055b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 21065b9c547cSRui Paulo * @channels: List of channels 21075b9c547cSRui Paulo * Returns: Preferred channel 21085b9c547cSRui Paulo */ 21095b9c547cSRui Paulo unsigned int p2p_get_pref_freq(struct p2p_data *p2p, 21105b9c547cSRui Paulo const struct p2p_channels *channels); 21115b9c547cSRui Paulo 21125b9c547cSRui Paulo void p2p_update_channel_list(struct p2p_data *p2p, 21135b9c547cSRui Paulo const struct p2p_channels *chan, 21145b9c547cSRui Paulo const struct p2p_channels *cli_chan); 2115f05cddf9SRui Paulo 2116c1d255d3SCy Schubert bool is_p2p_6ghz_disabled(struct p2p_data *p2p); 2117c1d255d3SCy Schubert 2118f05cddf9SRui Paulo /** 2119f05cddf9SRui Paulo * p2p_set_best_channels - Update best channel information 2120f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2121f05cddf9SRui Paulo * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band 2122f05cddf9SRui Paulo * @freq_5: Frequency (MHz) of best channel in 5 GHz band 2123f05cddf9SRui Paulo * @freq_overall: Frequency (MHz) of best channel overall 2124f05cddf9SRui Paulo */ 2125f05cddf9SRui Paulo void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5, 2126f05cddf9SRui Paulo int freq_overall); 2127f05cddf9SRui Paulo 21285b9c547cSRui Paulo /** 21295b9c547cSRui Paulo * p2p_set_own_freq_preference - Set own preference for channel 21305b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 21315b9c547cSRui Paulo * @freq: Frequency (MHz) of the preferred channel or 0 if no preference 21325b9c547cSRui Paulo * 21335b9c547cSRui Paulo * This function can be used to set a preference on the operating channel based 21345b9c547cSRui Paulo * on frequencies used on the other virtual interfaces that share the same 21355b9c547cSRui Paulo * radio. If non-zero, this is used to try to avoid multi-channel concurrency. 21365b9c547cSRui Paulo */ 21375b9c547cSRui Paulo void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq); 21385b9c547cSRui Paulo 2139f05cddf9SRui Paulo const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p); 2140f05cddf9SRui Paulo 2141f05cddf9SRui Paulo /** 2142f05cddf9SRui Paulo * p2p_get_group_num_members - Get number of members in group 2143f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 2144f05cddf9SRui Paulo * Returns: Number of members in the group 2145f05cddf9SRui Paulo */ 2146f05cddf9SRui Paulo unsigned int p2p_get_group_num_members(struct p2p_group *group); 2147f05cddf9SRui Paulo 2148f05cddf9SRui Paulo /** 21495b9c547cSRui Paulo * p2p_client_limit_reached - Check if client limit is reached 21505b9c547cSRui Paulo * @group: P2P group context from p2p_group_init() 21515b9c547cSRui Paulo * Returns: 1 if no of clients limit reached 21525b9c547cSRui Paulo */ 21535b9c547cSRui Paulo int p2p_client_limit_reached(struct p2p_group *group); 21545b9c547cSRui Paulo 21555b9c547cSRui Paulo /** 2156f05cddf9SRui Paulo * p2p_iterate_group_members - Iterate group members 2157f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 2158f05cddf9SRui Paulo * @next: iteration pointer, must be a pointer to a void * that is set to %NULL 2159f05cddf9SRui Paulo * on the first call and not modified later 21605b9c547cSRui Paulo * Returns: A P2P Device Address for each call and %NULL for no more members 2161f05cddf9SRui Paulo */ 2162f05cddf9SRui Paulo const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next); 2163f05cddf9SRui Paulo 2164f05cddf9SRui Paulo /** 2165780fb4a2SCy Schubert * p2p_group_get_client_interface_addr - Get P2P Interface Address of a client in a group 2166780fb4a2SCy Schubert * @group: P2P group context from p2p_group_init() 2167780fb4a2SCy Schubert * @dev_addr: P2P Device Address of the client 2168780fb4a2SCy Schubert * Returns: P2P Interface Address of the client if found or %NULL if no match 2169780fb4a2SCy Schubert * found 2170780fb4a2SCy Schubert */ 2171780fb4a2SCy Schubert const u8 * p2p_group_get_client_interface_addr(struct p2p_group *group, 2172780fb4a2SCy Schubert const u8 *dev_addr); 2173780fb4a2SCy Schubert 2174780fb4a2SCy Schubert /** 2175f05cddf9SRui Paulo * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group 2176f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 2177f05cddf9SRui Paulo * @addr: P2P Interface Address of the client 2178f05cddf9SRui Paulo * Returns: P2P Device Address of the client if found or %NULL if no match 2179f05cddf9SRui Paulo * found 2180f05cddf9SRui Paulo */ 2181f05cddf9SRui Paulo const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr); 2182f05cddf9SRui Paulo 2183f05cddf9SRui Paulo /** 2184f05cddf9SRui Paulo * p2p_group_is_client_connected - Check whether a specific client is connected 2185f05cddf9SRui Paulo * @group: P2P group context from p2p_group_init() 2186f05cddf9SRui Paulo * @addr: P2P Device Address of the client 2187f05cddf9SRui Paulo * Returns: 1 if client is connected or 0 if not 2188f05cddf9SRui Paulo */ 2189f05cddf9SRui Paulo int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr); 2190f05cddf9SRui Paulo 2191f05cddf9SRui Paulo /** 21925b9c547cSRui Paulo * p2p_group_get_config - Get the group configuration 21935b9c547cSRui Paulo * @group: P2P group context from p2p_group_init() 21945b9c547cSRui Paulo * Returns: The group configuration pointer 21955b9c547cSRui Paulo */ 21965b9c547cSRui Paulo const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group); 21975b9c547cSRui Paulo 21985b9c547cSRui Paulo /** 21995b9c547cSRui Paulo * p2p_loop_on_all_groups - Run the given callback on all groups 22005b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 22015b9c547cSRui Paulo * @group_callback: The callback function pointer 22025b9c547cSRui Paulo * @user_data: Some user data pointer which can be %NULL 22035b9c547cSRui Paulo * 22045b9c547cSRui Paulo * The group_callback function can stop the iteration by returning 0. 22055b9c547cSRui Paulo */ 22065b9c547cSRui Paulo void p2p_loop_on_all_groups(struct p2p_data *p2p, 22075b9c547cSRui Paulo int (*group_callback)(struct p2p_group *group, 22085b9c547cSRui Paulo void *user_data), 22095b9c547cSRui Paulo void *user_data); 22105b9c547cSRui Paulo 22115b9c547cSRui Paulo /** 2212f05cddf9SRui Paulo * p2p_get_peer_found - Get P2P peer info structure of a found peer 2213f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2214f05cddf9SRui Paulo * @addr: P2P Device Address of the peer or %NULL to indicate the first peer 2215f05cddf9SRui Paulo * @next: Whether to select the peer entry following the one indicated by addr 2216f05cddf9SRui Paulo * Returns: The first P2P peer info available or %NULL if no such peer exists 2217f05cddf9SRui Paulo */ 2218f05cddf9SRui Paulo const struct p2p_peer_info * 2219f05cddf9SRui Paulo p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next); 2220f05cddf9SRui Paulo 2221f05cddf9SRui Paulo /** 2222f05cddf9SRui Paulo * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions 2223f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2224f05cddf9SRui Paulo */ 2225f05cddf9SRui Paulo void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p); 2226f05cddf9SRui Paulo 2227f05cddf9SRui Paulo /** 2228f05cddf9SRui Paulo * p2p_add_wps_vendor_extension - Add a WPS vendor extension 2229f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2230f05cddf9SRui Paulo * @vendor_ext: The vendor extensions to add 2231f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 2232f05cddf9SRui Paulo * 2233f05cddf9SRui Paulo * The wpabuf structures in the array are owned by the P2P 2234f05cddf9SRui Paulo * module after this call. 2235f05cddf9SRui Paulo */ 2236f05cddf9SRui Paulo int p2p_add_wps_vendor_extension(struct p2p_data *p2p, 2237f05cddf9SRui Paulo const struct wpabuf *vendor_ext); 2238f05cddf9SRui Paulo 2239f05cddf9SRui Paulo /** 2240f05cddf9SRui Paulo * p2p_set_oper_channel - Set the P2P operating channel 2241f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2242f05cddf9SRui Paulo * @op_reg_class: Operating regulatory class to set 2243f05cddf9SRui Paulo * @op_channel: operating channel to set 2244f05cddf9SRui Paulo * @cfg_op_channel : Whether op_channel is hardcoded in configuration 2245f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 2246f05cddf9SRui Paulo */ 2247f05cddf9SRui Paulo int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel, 2248f05cddf9SRui Paulo int cfg_op_channel); 2249f05cddf9SRui Paulo 2250f05cddf9SRui Paulo /** 2251f05cddf9SRui Paulo * p2p_set_pref_chan - Set P2P preferred channel list 2252f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2253f05cddf9SRui Paulo * @num_pref_chan: Number of entries in pref_chan list 2254f05cddf9SRui Paulo * @pref_chan: Preferred channels or %NULL to remove preferences 2255f05cddf9SRui Paulo * Returns: 0 on success, -1 on failure 2256f05cddf9SRui Paulo */ 2257f05cddf9SRui Paulo int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan, 2258f05cddf9SRui Paulo const struct p2p_channel *pref_chan); 2259f05cddf9SRui Paulo 2260f05cddf9SRui Paulo /** 22615b9c547cSRui Paulo * p2p_set_no_go_freq - Set no GO channel ranges 2262f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 22635b9c547cSRui Paulo * @list: Channel ranges or %NULL to remove restriction 22645b9c547cSRui Paulo * Returns: 0 on success, -1 on failure 2265f05cddf9SRui Paulo */ 22665b9c547cSRui Paulo int p2p_set_no_go_freq(struct p2p_data *p2p, 22675b9c547cSRui Paulo const struct wpa_freq_range_list *list); 2268f05cddf9SRui Paulo 2269f05cddf9SRui Paulo /** 22705b9c547cSRui Paulo * p2p_in_progress - Check whether a P2P operation is progress 2271f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 22725b9c547cSRui Paulo * Returns: 0 if P2P module is idle, 1 if an operation is in progress but not 22735b9c547cSRui Paulo * in search state, or 2 if search state operation is in progress 2274f05cddf9SRui Paulo */ 22755b9c547cSRui Paulo int p2p_in_progress(struct p2p_data *p2p); 2276f05cddf9SRui Paulo 2277f05cddf9SRui Paulo const char * p2p_wps_method_text(enum p2p_wps_method method); 2278f05cddf9SRui Paulo 2279f05cddf9SRui Paulo /** 2280f05cddf9SRui Paulo * p2p_set_config_timeout - Set local config timeouts 2281f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2282f05cddf9SRui Paulo * @go_timeout: Time in 10 ms units it takes to start the GO mode 2283f05cddf9SRui Paulo * @client_timeout: Time in 10 ms units it takes to start the client mode 2284f05cddf9SRui Paulo */ 2285f05cddf9SRui Paulo void p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout, 2286f05cddf9SRui Paulo u8 client_timeout); 2287f05cddf9SRui Paulo 2288f05cddf9SRui Paulo int p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie); 2289f05cddf9SRui Paulo int p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie); 2290f05cddf9SRui Paulo int p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie); 2291f05cddf9SRui Paulo int p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie); 2292f05cddf9SRui Paulo int p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie); 2293f05cddf9SRui Paulo int p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie); 2294f05cddf9SRui Paulo int p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie); 2295f05cddf9SRui Paulo int p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie); 2296f05cddf9SRui Paulo int p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem); 229785732ac8SCy Schubert int p2p_set_wfd_r2_dev_info(struct p2p_data *p2p, const struct wpabuf *elem); 2298f05cddf9SRui Paulo int p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem); 2299f05cddf9SRui Paulo int p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p, 2300f05cddf9SRui Paulo const struct wpabuf *elem); 2301f05cddf9SRui Paulo struct wpabuf * wifi_display_encaps(struct wpabuf *subelems); 2302f05cddf9SRui Paulo 2303f05cddf9SRui Paulo /** 2304f05cddf9SRui Paulo * p2p_set_disc_int - Set min/max discoverable interval for p2p_find 2305f05cddf9SRui Paulo * @p2p: P2P module context from p2p_init() 2306f05cddf9SRui Paulo * @min_disc_int: minDiscoverableInterval (in units of 100 TU); default 1 2307f05cddf9SRui Paulo * @max_disc_int: maxDiscoverableInterval (in units of 100 TU); default 3 2308f05cddf9SRui Paulo * @max_disc_tu: Maximum number of TUs (1.024 ms) for discoverable interval; or 2309f05cddf9SRui Paulo * -1 not to limit 2310f05cddf9SRui Paulo * Returns: 0 on success, or -1 on failure 2311f05cddf9SRui Paulo * 2312f05cddf9SRui Paulo * This function can be used to configure minDiscoverableInterval and 2313f05cddf9SRui Paulo * maxDiscoverableInterval parameters for the Listen state during device 2314f05cddf9SRui Paulo * discovery (p2p_find). A random number of 100 TU units is picked for each 2315f05cddf9SRui Paulo * Listen state iteration from [min_disc_int,max_disc_int] range. 2316f05cddf9SRui Paulo * 2317780fb4a2SCy Schubert * max_disc_tu can be used to further limit the discoverable duration. However, 2318f05cddf9SRui Paulo * it should be noted that use of this parameter is not recommended since it 2319f05cddf9SRui Paulo * would not be compliant with the P2P specification. 2320f05cddf9SRui Paulo */ 2321f05cddf9SRui Paulo int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int, 2322f05cddf9SRui Paulo int max_disc_tu); 2323f05cddf9SRui Paulo 23245b9c547cSRui Paulo /** 23255b9c547cSRui Paulo * p2p_get_state_txt - Get current P2P state for debug purposes 23265b9c547cSRui Paulo * @p2p: P2P module context from p2p_init() 23275b9c547cSRui Paulo * Returns: Name of the current P2P module state 23285b9c547cSRui Paulo * 23295b9c547cSRui Paulo * It should be noted that the P2P module state names are internal information 23305b9c547cSRui Paulo * and subject to change at any point, i.e., this information should be used 23315b9c547cSRui Paulo * mainly for debugging purposes. 23325b9c547cSRui Paulo */ 23335b9c547cSRui Paulo const char * p2p_get_state_txt(struct p2p_data *p2p); 23345b9c547cSRui Paulo 23355b9c547cSRui Paulo struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p, 23365b9c547cSRui Paulo int client_freq, 23375b9c547cSRui Paulo const u8 *go_dev_addr, 23385b9c547cSRui Paulo const u8 *ssid, size_t ssid_len); 23395b9c547cSRui Paulo struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p, 23405b9c547cSRui Paulo int client_freq, 23415b9c547cSRui Paulo const u8 *go_dev_addr, 23425b9c547cSRui Paulo const u8 *ssid, size_t ssid_len); 23435b9c547cSRui Paulo 2344*a90b9d01SCy Schubert bool p2p_pref_freq_allowed(const struct weighted_pcl *freq_list, bool go); 2345*a90b9d01SCy Schubert 23465b9c547cSRui Paulo struct p2p_nfc_params { 23475b9c547cSRui Paulo int sel; 23485b9c547cSRui Paulo const u8 *wsc_attr; 23495b9c547cSRui Paulo size_t wsc_len; 23505b9c547cSRui Paulo const u8 *p2p_attr; 23515b9c547cSRui Paulo size_t p2p_len; 23525b9c547cSRui Paulo 23535b9c547cSRui Paulo enum { 23545b9c547cSRui Paulo NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG, 23555b9c547cSRui Paulo BOTH_GO, PEER_CLIENT 23565b9c547cSRui Paulo } next_step; 23575b9c547cSRui Paulo struct p2p_peer_info *peer; 23585b9c547cSRui Paulo u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 + 23595b9c547cSRui Paulo WPS_OOB_DEVICE_PASSWORD_LEN]; 23605b9c547cSRui Paulo size_t oob_dev_pw_len; 23615b9c547cSRui Paulo int go_freq; 23625b9c547cSRui Paulo u8 go_dev_addr[ETH_ALEN]; 2363325151a3SRui Paulo u8 go_ssid[SSID_MAX_LEN]; 23645b9c547cSRui Paulo size_t go_ssid_len; 23655b9c547cSRui Paulo }; 23665b9c547cSRui Paulo 23675b9c547cSRui Paulo int p2p_process_nfc_connection_handover(struct p2p_data *p2p, 23685b9c547cSRui Paulo struct p2p_nfc_params *params); 23695b9c547cSRui Paulo 23705b9c547cSRui Paulo void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id, 23715b9c547cSRui Paulo int go_intent, 23725b9c547cSRui Paulo const u8 *own_interface_addr); 23735b9c547cSRui Paulo 23745b9c547cSRui Paulo int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len); 23755b9c547cSRui Paulo 23765b9c547cSRui Paulo void p2p_loop_on_known_peers(struct p2p_data *p2p, 23775b9c547cSRui Paulo void (*peer_callback)(struct p2p_peer_info *peer, 23785b9c547cSRui Paulo void *user_data), 23795b9c547cSRui Paulo void *user_data); 23805b9c547cSRui Paulo 23815b9c547cSRui Paulo void p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem); 23825b9c547cSRui Paulo 23835b9c547cSRui Paulo void p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr); 23845b9c547cSRui Paulo 23855b9c547cSRui Paulo struct p2ps_advertisement * 23865b9c547cSRui Paulo p2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id); 23875b9c547cSRui Paulo int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id, 23885b9c547cSRui Paulo const char *adv_str, u8 svc_state, 2389325151a3SRui Paulo u16 config_methods, const char *svc_info, 2390325151a3SRui Paulo const u8 *cpt_priority); 23915b9c547cSRui Paulo int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id); 2392325151a3SRui Paulo void p2p_service_flush_asp(struct p2p_data *p2p); 23935b9c547cSRui Paulo struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p); 23945b9c547cSRui Paulo 2395325151a3SRui Paulo /** 2396325151a3SRui Paulo * p2p_expire_peers - Periodic cleanup function to expire peers 2397325151a3SRui Paulo * @p2p: P2P module context from p2p_init() 2398325151a3SRui Paulo * 2399325151a3SRui Paulo * This is a cleanup function that the entity calling p2p_init() is 2400325151a3SRui Paulo * expected to call periodically to clean up expired peer entries. 2401325151a3SRui Paulo */ 2402325151a3SRui Paulo void p2p_expire_peers(struct p2p_data *p2p); 2403325151a3SRui Paulo 2404325151a3SRui Paulo void p2p_set_own_pref_freq_list(struct p2p_data *p2p, 2405*a90b9d01SCy Schubert const struct weighted_pcl *pref_freq_list, 2406325151a3SRui Paulo unsigned int size); 240785732ac8SCy Schubert void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class, 240885732ac8SCy Schubert u8 chan); 2409325151a3SRui Paulo 2410325151a3SRui Paulo /** 2411325151a3SRui Paulo * p2p_group_get_common_freqs - Get the group common frequencies 2412325151a3SRui Paulo * @group: P2P group context from p2p_group_init() 2413325151a3SRui Paulo * @common_freqs: On return will hold the group common frequencies 2414325151a3SRui Paulo * @num: On return will hold the number of group common frequencies 2415325151a3SRui Paulo * Returns: 0 on success, -1 otherwise 2416325151a3SRui Paulo */ 2417325151a3SRui Paulo int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs, 2418325151a3SRui Paulo unsigned int *num); 2419325151a3SRui Paulo 2420780fb4a2SCy Schubert struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p, 2421780fb4a2SCy Schubert unsigned int freq); 2422780fb4a2SCy Schubert 2423c1d255d3SCy Schubert void p2p_set_6ghz_dev_capab(struct p2p_data *p2p, bool allow_6ghz); 2424c1d255d3SCy Schubert bool is_p2p_6ghz_capable(struct p2p_data *p2p); 2425c1d255d3SCy Schubert bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr); 2426c1d255d3SCy Schubert bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr); 2427c1d255d3SCy Schubert bool p2p_wfd_enabled(struct p2p_data *p2p); 2428c1d255d3SCy Schubert bool is_p2p_allow_6ghz(struct p2p_data *p2p); 2429c1d255d3SCy Schubert void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value); 2430*a90b9d01SCy Schubert int p2p_remove_6ghz_channels(struct weighted_pcl *pref_freq_list, int size); 2431*a90b9d01SCy Schubert int p2p_channel_to_freq(int op_class, int channel); 2432c1d255d3SCy Schubert 2433f05cddf9SRui Paulo #endif /* P2P_H */ 2434