13ff40c12SJohn Marino /* 23ff40c12SJohn Marino * Wi-Fi Direct - P2P module 33ff40c12SJohn Marino * Copyright (c) 2009-2010, Atheros Communications 43ff40c12SJohn Marino * 53ff40c12SJohn Marino * This software may be distributed under the terms of the BSD license. 63ff40c12SJohn Marino * See README for more details. 73ff40c12SJohn Marino */ 83ff40c12SJohn Marino 93ff40c12SJohn Marino #ifndef P2P_H 103ff40c12SJohn Marino #define P2P_H 113ff40c12SJohn Marino 12*a1157835SDaniel Fojt #include "common/ieee802_11_defs.h" 13*a1157835SDaniel Fojt #include "wps/wps.h" 14*a1157835SDaniel Fojt 15*a1157835SDaniel Fojt /* P2P ASP Setup Capability */ 16*a1157835SDaniel Fojt #define P2PS_SETUP_NONE 0 17*a1157835SDaniel Fojt #define P2PS_SETUP_NEW BIT(0) 18*a1157835SDaniel Fojt #define P2PS_SETUP_CLIENT BIT(1) 19*a1157835SDaniel Fojt #define P2PS_SETUP_GROUP_OWNER BIT(2) 20*a1157835SDaniel Fojt 21*a1157835SDaniel Fojt #define P2PS_WILD_HASH_STR "org.wi-fi.wfds" 22*a1157835SDaniel Fojt #define P2PS_HASH_LEN 6 23*a1157835SDaniel Fojt #define P2P_MAX_QUERY_HASH 6 24*a1157835SDaniel Fojt #define P2PS_FEATURE_CAPAB_CPT_MAX 2 25*a1157835SDaniel Fojt 26*a1157835SDaniel Fojt /** 27*a1157835SDaniel Fojt * P2P_MAX_PREF_CHANNELS - Maximum number of preferred channels 28*a1157835SDaniel Fojt */ 29*a1157835SDaniel Fojt #define P2P_MAX_PREF_CHANNELS 100 303ff40c12SJohn Marino 313ff40c12SJohn Marino /** 323ff40c12SJohn Marino * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes 333ff40c12SJohn Marino */ 34*a1157835SDaniel Fojt #define P2P_MAX_REG_CLASSES 15 353ff40c12SJohn Marino 363ff40c12SJohn Marino /** 373ff40c12SJohn Marino * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class 383ff40c12SJohn Marino */ 393ff40c12SJohn Marino #define P2P_MAX_REG_CLASS_CHANNELS 20 403ff40c12SJohn Marino 413ff40c12SJohn Marino /** 423ff40c12SJohn Marino * struct p2p_channels - List of supported channels 433ff40c12SJohn Marino */ 443ff40c12SJohn Marino struct p2p_channels { 453ff40c12SJohn Marino /** 463ff40c12SJohn Marino * struct p2p_reg_class - Supported regulatory class 473ff40c12SJohn Marino */ 483ff40c12SJohn Marino struct p2p_reg_class { 493ff40c12SJohn Marino /** 503ff40c12SJohn Marino * reg_class - Regulatory class (IEEE 802.11-2007, Annex J) 513ff40c12SJohn Marino */ 523ff40c12SJohn Marino u8 reg_class; 533ff40c12SJohn Marino 543ff40c12SJohn Marino /** 553ff40c12SJohn Marino * channel - Supported channels 563ff40c12SJohn Marino */ 573ff40c12SJohn Marino u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; 583ff40c12SJohn Marino 593ff40c12SJohn Marino /** 603ff40c12SJohn Marino * channels - Number of channel entries in use 613ff40c12SJohn Marino */ 623ff40c12SJohn Marino size_t channels; 633ff40c12SJohn Marino } reg_class[P2P_MAX_REG_CLASSES]; 643ff40c12SJohn Marino 653ff40c12SJohn Marino /** 663ff40c12SJohn Marino * reg_classes - Number of reg_class entries in use 673ff40c12SJohn Marino */ 683ff40c12SJohn Marino size_t reg_classes; 693ff40c12SJohn Marino }; 703ff40c12SJohn Marino 713ff40c12SJohn Marino enum p2p_wps_method { 72*a1157835SDaniel Fojt WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC, 73*a1157835SDaniel Fojt WPS_P2PS 743ff40c12SJohn Marino }; 753ff40c12SJohn Marino 763ff40c12SJohn Marino /** 773ff40c12SJohn Marino * struct p2p_go_neg_results - P2P Group Owner Negotiation results 783ff40c12SJohn Marino */ 793ff40c12SJohn Marino struct p2p_go_neg_results { 803ff40c12SJohn Marino /** 813ff40c12SJohn Marino * status - Negotiation result (Status Code) 823ff40c12SJohn Marino * 833ff40c12SJohn Marino * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate 843ff40c12SJohn Marino * failed negotiation. 853ff40c12SJohn Marino */ 863ff40c12SJohn Marino int status; 873ff40c12SJohn Marino 883ff40c12SJohn Marino /** 893ff40c12SJohn Marino * role_go - Whether local end is Group Owner 903ff40c12SJohn Marino */ 913ff40c12SJohn Marino int role_go; 923ff40c12SJohn Marino 933ff40c12SJohn Marino /** 943ff40c12SJohn Marino * freq - Frequency of the group operational channel in MHz 953ff40c12SJohn Marino */ 963ff40c12SJohn Marino int freq; 973ff40c12SJohn Marino 983ff40c12SJohn Marino int ht40; 993ff40c12SJohn Marino 1003ff40c12SJohn Marino int vht; 1013ff40c12SJohn Marino 102*a1157835SDaniel Fojt u8 max_oper_chwidth; 103*a1157835SDaniel Fojt 104*a1157835SDaniel Fojt unsigned int vht_center_freq2; 105*a1157835SDaniel Fojt 106*a1157835SDaniel Fojt /** 107*a1157835SDaniel Fojt * he - Indicates if IEEE 802.11ax HE is enabled 108*a1157835SDaniel Fojt */ 109*a1157835SDaniel Fojt int he; 110*a1157835SDaniel Fojt 1113ff40c12SJohn Marino /** 1123ff40c12SJohn Marino * ssid - SSID of the group 1133ff40c12SJohn Marino */ 114*a1157835SDaniel Fojt u8 ssid[SSID_MAX_LEN]; 1153ff40c12SJohn Marino 1163ff40c12SJohn Marino /** 1173ff40c12SJohn Marino * ssid_len - Length of SSID in octets 1183ff40c12SJohn Marino */ 1193ff40c12SJohn Marino size_t ssid_len; 1203ff40c12SJohn Marino 1213ff40c12SJohn Marino /** 1223ff40c12SJohn Marino * psk - WPA pre-shared key (256 bits) (GO only) 1233ff40c12SJohn Marino */ 1243ff40c12SJohn Marino u8 psk[32]; 1253ff40c12SJohn Marino 1263ff40c12SJohn Marino /** 1273ff40c12SJohn Marino * psk_set - Whether PSK field is configured (GO only) 1283ff40c12SJohn Marino */ 1293ff40c12SJohn Marino int psk_set; 1303ff40c12SJohn Marino 1313ff40c12SJohn Marino /** 1323ff40c12SJohn Marino * passphrase - WPA2-Personal passphrase for the group (GO only) 1333ff40c12SJohn Marino */ 1343ff40c12SJohn Marino char passphrase[64]; 1353ff40c12SJohn Marino 1363ff40c12SJohn Marino /** 1373ff40c12SJohn Marino * peer_device_addr - P2P Device Address of the peer 1383ff40c12SJohn Marino */ 1393ff40c12SJohn Marino u8 peer_device_addr[ETH_ALEN]; 1403ff40c12SJohn Marino 1413ff40c12SJohn Marino /** 1423ff40c12SJohn Marino * peer_interface_addr - P2P Interface Address of the peer 1433ff40c12SJohn Marino */ 1443ff40c12SJohn Marino u8 peer_interface_addr[ETH_ALEN]; 1453ff40c12SJohn Marino 1463ff40c12SJohn Marino /** 1473ff40c12SJohn Marino * wps_method - WPS method to be used during provisioning 1483ff40c12SJohn Marino */ 1493ff40c12SJohn Marino enum p2p_wps_method wps_method; 1503ff40c12SJohn Marino 1513ff40c12SJohn Marino #define P2P_MAX_CHANNELS 50 1523ff40c12SJohn Marino 1533ff40c12SJohn Marino /** 1543ff40c12SJohn Marino * freq_list - Zero-terminated list of possible operational channels 1553ff40c12SJohn Marino */ 1563ff40c12SJohn Marino int freq_list[P2P_MAX_CHANNELS]; 1573ff40c12SJohn Marino 1583ff40c12SJohn Marino /** 1593ff40c12SJohn Marino * persistent_group - Whether the group should be made persistent 1603ff40c12SJohn Marino * 0 = not persistent 1613ff40c12SJohn Marino * 1 = persistent group without persistent reconnect 1623ff40c12SJohn Marino * 2 = persistent group with persistent reconnect 1633ff40c12SJohn Marino */ 1643ff40c12SJohn Marino int persistent_group; 1653ff40c12SJohn Marino 1663ff40c12SJohn Marino /** 1673ff40c12SJohn Marino * peer_config_timeout - Peer configuration timeout (in 10 msec units) 1683ff40c12SJohn Marino */ 1693ff40c12SJohn Marino unsigned int peer_config_timeout; 1703ff40c12SJohn Marino }; 1713ff40c12SJohn Marino 172*a1157835SDaniel Fojt struct p2ps_provision { 173*a1157835SDaniel Fojt /** 174*a1157835SDaniel Fojt * pd_seeker - P2PS provision discovery seeker role 175*a1157835SDaniel Fojt */ 176*a1157835SDaniel Fojt unsigned int pd_seeker:1; 177*a1157835SDaniel Fojt 178*a1157835SDaniel Fojt /** 179*a1157835SDaniel Fojt * status - Remote returned provisioning status code 180*a1157835SDaniel Fojt */ 181*a1157835SDaniel Fojt int status; 182*a1157835SDaniel Fojt 183*a1157835SDaniel Fojt /** 184*a1157835SDaniel Fojt * adv_id - P2PS Advertisement ID 185*a1157835SDaniel Fojt */ 186*a1157835SDaniel Fojt u32 adv_id; 187*a1157835SDaniel Fojt 188*a1157835SDaniel Fojt /** 189*a1157835SDaniel Fojt * session_id - P2PS Session ID 190*a1157835SDaniel Fojt */ 191*a1157835SDaniel Fojt u32 session_id; 192*a1157835SDaniel Fojt 193*a1157835SDaniel Fojt /** 194*a1157835SDaniel Fojt * method - WPS Method (to be) used to establish session 195*a1157835SDaniel Fojt */ 196*a1157835SDaniel Fojt u16 method; 197*a1157835SDaniel Fojt 198*a1157835SDaniel Fojt /** 199*a1157835SDaniel Fojt * conncap - Connection Capabilities negotiated between P2P peers 200*a1157835SDaniel Fojt */ 201*a1157835SDaniel Fojt u8 conncap; 202*a1157835SDaniel Fojt 203*a1157835SDaniel Fojt /** 204*a1157835SDaniel Fojt * role - Info about the roles to be used for this connection 205*a1157835SDaniel Fojt */ 206*a1157835SDaniel Fojt u8 role; 207*a1157835SDaniel Fojt 208*a1157835SDaniel Fojt /** 209*a1157835SDaniel Fojt * session_mac - MAC address of the peer that started the session 210*a1157835SDaniel Fojt */ 211*a1157835SDaniel Fojt u8 session_mac[ETH_ALEN]; 212*a1157835SDaniel Fojt 213*a1157835SDaniel Fojt /** 214*a1157835SDaniel Fojt * adv_mac - MAC address of the peer advertised the service 215*a1157835SDaniel Fojt */ 216*a1157835SDaniel Fojt u8 adv_mac[ETH_ALEN]; 217*a1157835SDaniel Fojt 218*a1157835SDaniel Fojt /** 219*a1157835SDaniel Fojt * cpt_mask - Supported Coordination Protocol Transport mask 220*a1157835SDaniel Fojt * 221*a1157835SDaniel Fojt * A bitwise mask of supported ASP Coordination Protocol Transports. 222*a1157835SDaniel Fojt * This property is set together and corresponds with cpt_priority. 223*a1157835SDaniel Fojt */ 224*a1157835SDaniel Fojt u8 cpt_mask; 225*a1157835SDaniel Fojt 226*a1157835SDaniel Fojt /** 227*a1157835SDaniel Fojt * cpt_priority - Coordination Protocol Transport priority list 228*a1157835SDaniel Fojt * 229*a1157835SDaniel Fojt * Priorities of supported ASP Coordination Protocol Transports. 230*a1157835SDaniel Fojt * This property is set together and corresponds with cpt_mask. 231*a1157835SDaniel Fojt * The CPT priority list is 0 terminated. 232*a1157835SDaniel Fojt */ 233*a1157835SDaniel Fojt u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; 234*a1157835SDaniel Fojt 235*a1157835SDaniel Fojt /** 236*a1157835SDaniel Fojt * force_freq - The only allowed channel frequency in MHz or 0. 237*a1157835SDaniel Fojt */ 238*a1157835SDaniel Fojt unsigned int force_freq; 239*a1157835SDaniel Fojt 240*a1157835SDaniel Fojt /** 241*a1157835SDaniel Fojt * pref_freq - Preferred operating frequency in MHz or 0. 242*a1157835SDaniel Fojt */ 243*a1157835SDaniel Fojt unsigned int pref_freq; 244*a1157835SDaniel Fojt 245*a1157835SDaniel Fojt /** 246*a1157835SDaniel Fojt * info - Vendor defined extra Provisioning information 247*a1157835SDaniel Fojt */ 248*a1157835SDaniel Fojt char info[0]; 249*a1157835SDaniel Fojt }; 250*a1157835SDaniel Fojt 251*a1157835SDaniel Fojt struct p2ps_advertisement { 252*a1157835SDaniel Fojt struct p2ps_advertisement *next; 253*a1157835SDaniel Fojt 254*a1157835SDaniel Fojt /** 255*a1157835SDaniel Fojt * svc_info - Pointer to (internal) Service defined information 256*a1157835SDaniel Fojt */ 257*a1157835SDaniel Fojt char *svc_info; 258*a1157835SDaniel Fojt 259*a1157835SDaniel Fojt /** 260*a1157835SDaniel Fojt * id - P2PS Advertisement ID 261*a1157835SDaniel Fojt */ 262*a1157835SDaniel Fojt u32 id; 263*a1157835SDaniel Fojt 264*a1157835SDaniel Fojt /** 265*a1157835SDaniel Fojt * config_methods - WPS Methods which are allowed for this service 266*a1157835SDaniel Fojt */ 267*a1157835SDaniel Fojt u16 config_methods; 268*a1157835SDaniel Fojt 269*a1157835SDaniel Fojt /** 270*a1157835SDaniel Fojt * state - Current state of the service: 0 - Out Of Service, 1-255 Vendor defined 271*a1157835SDaniel Fojt */ 272*a1157835SDaniel Fojt u8 state; 273*a1157835SDaniel Fojt 274*a1157835SDaniel Fojt /** 275*a1157835SDaniel Fojt * auto_accept - Automatically Accept provisioning request if possible. 276*a1157835SDaniel Fojt */ 277*a1157835SDaniel Fojt u8 auto_accept; 278*a1157835SDaniel Fojt 279*a1157835SDaniel Fojt /** 280*a1157835SDaniel Fojt * hash - 6 octet Service Name has to match against incoming Probe Requests 281*a1157835SDaniel Fojt */ 282*a1157835SDaniel Fojt u8 hash[P2PS_HASH_LEN]; 283*a1157835SDaniel Fojt 284*a1157835SDaniel Fojt /** 285*a1157835SDaniel Fojt * cpt_mask - supported Coordination Protocol Transport mask 286*a1157835SDaniel Fojt * 287*a1157835SDaniel Fojt * A bitwise mask of supported ASP Coordination Protocol Transports. 288*a1157835SDaniel Fojt * This property is set together and corresponds with cpt_priority. 289*a1157835SDaniel Fojt */ 290*a1157835SDaniel Fojt u8 cpt_mask; 291*a1157835SDaniel Fojt 292*a1157835SDaniel Fojt /** 293*a1157835SDaniel Fojt * cpt_priority - Coordination Protocol Transport priority list 294*a1157835SDaniel Fojt * 295*a1157835SDaniel Fojt * Priorities of supported ASP Coordinatin Protocol Transports. 296*a1157835SDaniel Fojt * This property is set together and corresponds with cpt_mask. 297*a1157835SDaniel Fojt * The CPT priority list is 0 terminated. 298*a1157835SDaniel Fojt */ 299*a1157835SDaniel Fojt u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1]; 300*a1157835SDaniel Fojt 301*a1157835SDaniel Fojt /** 302*a1157835SDaniel Fojt * svc_name - NULL Terminated UTF-8 Service Name, and svc_info storage 303*a1157835SDaniel Fojt */ 304*a1157835SDaniel Fojt char svc_name[0]; 305*a1157835SDaniel Fojt }; 306*a1157835SDaniel Fojt 307*a1157835SDaniel Fojt 3083ff40c12SJohn Marino struct p2p_data; 3093ff40c12SJohn Marino 3103ff40c12SJohn Marino enum p2p_scan_type { 3113ff40c12SJohn Marino P2P_SCAN_SOCIAL, 3123ff40c12SJohn Marino P2P_SCAN_FULL, 313*a1157835SDaniel Fojt P2P_SCAN_SPECIFIC, 3143ff40c12SJohn Marino P2P_SCAN_SOCIAL_PLUS_ONE 3153ff40c12SJohn Marino }; 3163ff40c12SJohn Marino 3173ff40c12SJohn Marino #define P2P_MAX_WPS_VENDOR_EXT 10 3183ff40c12SJohn Marino 3193ff40c12SJohn Marino /** 3203ff40c12SJohn Marino * struct p2p_peer_info - P2P peer information 3213ff40c12SJohn Marino */ 3223ff40c12SJohn Marino struct p2p_peer_info { 3233ff40c12SJohn Marino /** 3243ff40c12SJohn Marino * p2p_device_addr - P2P Device Address of the peer 3253ff40c12SJohn Marino */ 3263ff40c12SJohn Marino u8 p2p_device_addr[ETH_ALEN]; 3273ff40c12SJohn Marino 3283ff40c12SJohn Marino /** 3293ff40c12SJohn Marino * pri_dev_type - Primary Device Type 3303ff40c12SJohn Marino */ 3313ff40c12SJohn Marino u8 pri_dev_type[8]; 3323ff40c12SJohn Marino 3333ff40c12SJohn Marino /** 3343ff40c12SJohn Marino * device_name - Device Name (0..32 octets encoded in UTF-8) 3353ff40c12SJohn Marino */ 336*a1157835SDaniel Fojt char device_name[WPS_DEV_NAME_MAX_LEN + 1]; 3373ff40c12SJohn Marino 3383ff40c12SJohn Marino /** 3393ff40c12SJohn Marino * manufacturer - Manufacturer (0..64 octets encoded in UTF-8) 3403ff40c12SJohn Marino */ 341*a1157835SDaniel Fojt char manufacturer[WPS_MANUFACTURER_MAX_LEN + 1]; 3423ff40c12SJohn Marino 3433ff40c12SJohn Marino /** 3443ff40c12SJohn Marino * model_name - Model Name (0..32 octets encoded in UTF-8) 3453ff40c12SJohn Marino */ 346*a1157835SDaniel Fojt char model_name[WPS_MODEL_NAME_MAX_LEN + 1]; 3473ff40c12SJohn Marino 3483ff40c12SJohn Marino /** 3493ff40c12SJohn Marino * model_number - Model Number (0..32 octets encoded in UTF-8) 3503ff40c12SJohn Marino */ 351*a1157835SDaniel Fojt char model_number[WPS_MODEL_NUMBER_MAX_LEN + 1]; 3523ff40c12SJohn Marino 3533ff40c12SJohn Marino /** 3543ff40c12SJohn Marino * serial_number - Serial Number (0..32 octets encoded in UTF-8) 3553ff40c12SJohn Marino */ 356*a1157835SDaniel Fojt char serial_number[WPS_SERIAL_NUMBER_MAX_LEN + 1]; 3573ff40c12SJohn Marino 3583ff40c12SJohn Marino /** 3593ff40c12SJohn Marino * level - Signal level 3603ff40c12SJohn Marino */ 3613ff40c12SJohn Marino int level; 3623ff40c12SJohn Marino 3633ff40c12SJohn Marino /** 3643ff40c12SJohn Marino * config_methods - WPS Configuration Methods 3653ff40c12SJohn Marino */ 3663ff40c12SJohn Marino u16 config_methods; 3673ff40c12SJohn Marino 3683ff40c12SJohn Marino /** 3693ff40c12SJohn Marino * dev_capab - Device Capabilities 3703ff40c12SJohn Marino */ 3713ff40c12SJohn Marino u8 dev_capab; 3723ff40c12SJohn Marino 3733ff40c12SJohn Marino /** 3743ff40c12SJohn Marino * group_capab - Group Capabilities 3753ff40c12SJohn Marino */ 3763ff40c12SJohn Marino u8 group_capab; 3773ff40c12SJohn Marino 3783ff40c12SJohn Marino /** 3793ff40c12SJohn Marino * wps_sec_dev_type_list - WPS secondary device type list 3803ff40c12SJohn Marino * 3813ff40c12SJohn Marino * This list includes from 0 to 16 Secondary Device Types as indicated 3823ff40c12SJohn Marino * by wps_sec_dev_type_list_len (8 * number of types). 3833ff40c12SJohn Marino */ 384*a1157835SDaniel Fojt u8 wps_sec_dev_type_list[WPS_SEC_DEV_TYPE_MAX_LEN]; 3853ff40c12SJohn Marino 3863ff40c12SJohn Marino /** 3873ff40c12SJohn Marino * wps_sec_dev_type_list_len - Length of secondary device type list 3883ff40c12SJohn Marino */ 3893ff40c12SJohn Marino size_t wps_sec_dev_type_list_len; 3903ff40c12SJohn Marino 3913ff40c12SJohn Marino struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; 3923ff40c12SJohn Marino 3933ff40c12SJohn Marino /** 3943ff40c12SJohn Marino * wfd_subelems - Wi-Fi Display subelements from WFD IE(s) 3953ff40c12SJohn Marino */ 3963ff40c12SJohn Marino struct wpabuf *wfd_subelems; 397*a1157835SDaniel Fojt 398*a1157835SDaniel Fojt /** 399*a1157835SDaniel Fojt * vendor_elems - Unrecognized vendor elements 400*a1157835SDaniel Fojt * 401*a1157835SDaniel Fojt * This buffer includes any other vendor element than P2P, WPS, and WFD 402*a1157835SDaniel Fojt * IE(s) from the frame that was used to discover the peer. 403*a1157835SDaniel Fojt */ 404*a1157835SDaniel Fojt struct wpabuf *vendor_elems; 405*a1157835SDaniel Fojt 406*a1157835SDaniel Fojt /** 407*a1157835SDaniel Fojt * p2ps_instance - P2PS Application Service Info 408*a1157835SDaniel Fojt */ 409*a1157835SDaniel Fojt struct wpabuf *p2ps_instance; 4103ff40c12SJohn Marino }; 4113ff40c12SJohn Marino 4123ff40c12SJohn Marino enum p2p_prov_disc_status { 4133ff40c12SJohn Marino P2P_PROV_DISC_SUCCESS, 4143ff40c12SJohn Marino P2P_PROV_DISC_TIMEOUT, 4153ff40c12SJohn Marino P2P_PROV_DISC_REJECTED, 4163ff40c12SJohn Marino P2P_PROV_DISC_TIMEOUT_JOIN, 417*a1157835SDaniel Fojt P2P_PROV_DISC_INFO_UNAVAILABLE, 4183ff40c12SJohn Marino }; 4193ff40c12SJohn Marino 4203ff40c12SJohn Marino struct p2p_channel { 4213ff40c12SJohn Marino u8 op_class; 4223ff40c12SJohn Marino u8 chan; 4233ff40c12SJohn Marino }; 4243ff40c12SJohn Marino 4253ff40c12SJohn Marino /** 4263ff40c12SJohn Marino * struct p2p_config - P2P configuration 4273ff40c12SJohn Marino * 4283ff40c12SJohn Marino * This configuration is provided to the P2P module during initialization with 4293ff40c12SJohn Marino * p2p_init(). 4303ff40c12SJohn Marino */ 4313ff40c12SJohn Marino struct p2p_config { 4323ff40c12SJohn Marino /** 4333ff40c12SJohn Marino * country - Country code to use in P2P operations 4343ff40c12SJohn Marino */ 4353ff40c12SJohn Marino char country[3]; 4363ff40c12SJohn Marino 4373ff40c12SJohn Marino /** 4383ff40c12SJohn Marino * reg_class - Regulatory class for own listen channel 4393ff40c12SJohn Marino */ 4403ff40c12SJohn Marino u8 reg_class; 4413ff40c12SJohn Marino 4423ff40c12SJohn Marino /** 4433ff40c12SJohn Marino * channel - Own listen channel 4443ff40c12SJohn Marino */ 4453ff40c12SJohn Marino u8 channel; 4463ff40c12SJohn Marino 4473ff40c12SJohn Marino /** 448*a1157835SDaniel Fojt * channel_forced - the listen channel was forced by configuration 449*a1157835SDaniel Fojt * or by control interface and cannot be overridden 450*a1157835SDaniel Fojt */ 451*a1157835SDaniel Fojt u8 channel_forced; 452*a1157835SDaniel Fojt 453*a1157835SDaniel Fojt /** 4543ff40c12SJohn Marino * Regulatory class for own operational channel 4553ff40c12SJohn Marino */ 4563ff40c12SJohn Marino u8 op_reg_class; 4573ff40c12SJohn Marino 4583ff40c12SJohn Marino /** 4593ff40c12SJohn Marino * op_channel - Own operational channel 4603ff40c12SJohn Marino */ 4613ff40c12SJohn Marino u8 op_channel; 4623ff40c12SJohn Marino 4633ff40c12SJohn Marino /** 4643ff40c12SJohn Marino * cfg_op_channel - Whether op_channel is hardcoded in configuration 4653ff40c12SJohn Marino */ 4663ff40c12SJohn Marino u8 cfg_op_channel; 4673ff40c12SJohn Marino 4683ff40c12SJohn Marino /** 4693ff40c12SJohn Marino * channels - Own supported regulatory classes and channels 4703ff40c12SJohn Marino * 4713ff40c12SJohn Marino * List of supposerted channels per regulatory class. The regulatory 4723ff40c12SJohn Marino * classes are defined in IEEE Std 802.11-2007 Annex J and the 4733ff40c12SJohn Marino * numbering of the clases depends on the configured country code. 4743ff40c12SJohn Marino */ 4753ff40c12SJohn Marino struct p2p_channels channels; 4763ff40c12SJohn Marino 4773ff40c12SJohn Marino /** 4783ff40c12SJohn Marino * cli_channels - Additional client channels 4793ff40c12SJohn Marino * 4803ff40c12SJohn Marino * This list of channels (if any) will be used when advertising local 4813ff40c12SJohn Marino * channels during GO Negotiation or Invitation for the cases where the 4823ff40c12SJohn Marino * local end may become the client. This may allow the peer to become a 4833ff40c12SJohn Marino * GO on additional channels if it supports these options. The main use 4843ff40c12SJohn Marino * case for this is to include passive-scan channels on devices that may 4853ff40c12SJohn Marino * not know their current location and have configured most channels to 4863ff40c12SJohn Marino * not allow initiation of radition (i.e., another device needs to take 4873ff40c12SJohn Marino * master responsibilities). 4883ff40c12SJohn Marino */ 4893ff40c12SJohn Marino struct p2p_channels cli_channels; 4903ff40c12SJohn Marino 4913ff40c12SJohn Marino /** 4923ff40c12SJohn Marino * num_pref_chan - Number of pref_chan entries 4933ff40c12SJohn Marino */ 4943ff40c12SJohn Marino unsigned int num_pref_chan; 4953ff40c12SJohn Marino 4963ff40c12SJohn Marino /** 4973ff40c12SJohn Marino * pref_chan - Preferred channels for GO Negotiation 4983ff40c12SJohn Marino */ 4993ff40c12SJohn Marino struct p2p_channel *pref_chan; 5003ff40c12SJohn Marino 5013ff40c12SJohn Marino /** 5023ff40c12SJohn Marino * pri_dev_type - Primary Device Type (see WPS) 5033ff40c12SJohn Marino */ 5043ff40c12SJohn Marino u8 pri_dev_type[8]; 5053ff40c12SJohn Marino 5063ff40c12SJohn Marino /** 5073ff40c12SJohn Marino * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types 5083ff40c12SJohn Marino */ 5093ff40c12SJohn Marino #define P2P_SEC_DEVICE_TYPES 5 5103ff40c12SJohn Marino 5113ff40c12SJohn Marino /** 5123ff40c12SJohn Marino * sec_dev_type - Optional secondary device types 5133ff40c12SJohn Marino */ 5143ff40c12SJohn Marino u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8]; 5153ff40c12SJohn Marino 5163ff40c12SJohn Marino /** 5173ff40c12SJohn Marino * num_sec_dev_types - Number of sec_dev_type entries 5183ff40c12SJohn Marino */ 5193ff40c12SJohn Marino size_t num_sec_dev_types; 5203ff40c12SJohn Marino 5213ff40c12SJohn Marino /** 5223ff40c12SJohn Marino * dev_addr - P2P Device Address 5233ff40c12SJohn Marino */ 5243ff40c12SJohn Marino u8 dev_addr[ETH_ALEN]; 5253ff40c12SJohn Marino 5263ff40c12SJohn Marino /** 5273ff40c12SJohn Marino * dev_name - Device Name 5283ff40c12SJohn Marino */ 5293ff40c12SJohn Marino char *dev_name; 5303ff40c12SJohn Marino 5313ff40c12SJohn Marino char *manufacturer; 5323ff40c12SJohn Marino char *model_name; 5333ff40c12SJohn Marino char *model_number; 5343ff40c12SJohn Marino char *serial_number; 5353ff40c12SJohn Marino 5363ff40c12SJohn Marino u8 uuid[16]; 5373ff40c12SJohn Marino u16 config_methods; 5383ff40c12SJohn Marino 5393ff40c12SJohn Marino /** 5403ff40c12SJohn Marino * concurrent_operations - Whether concurrent operations are supported 5413ff40c12SJohn Marino */ 5423ff40c12SJohn Marino int concurrent_operations; 5433ff40c12SJohn Marino 5443ff40c12SJohn Marino /** 5453ff40c12SJohn Marino * max_peers - Maximum number of discovered peers to remember 5463ff40c12SJohn Marino * 5473ff40c12SJohn Marino * If more peers are discovered, older entries will be removed to make 5483ff40c12SJohn Marino * room for the new ones. 5493ff40c12SJohn Marino */ 5503ff40c12SJohn Marino size_t max_peers; 5513ff40c12SJohn Marino 5523ff40c12SJohn Marino /** 5533ff40c12SJohn Marino * p2p_intra_bss - Intra BSS communication is supported 5543ff40c12SJohn Marino */ 5553ff40c12SJohn Marino int p2p_intra_bss; 5563ff40c12SJohn Marino 5573ff40c12SJohn Marino /** 5583ff40c12SJohn Marino * ssid_postfix - Postfix data to add to the SSID 5593ff40c12SJohn Marino * 5603ff40c12SJohn Marino * This data will be added to the end of the SSID after the 5613ff40c12SJohn Marino * DIRECT-<random two octets> prefix. 5623ff40c12SJohn Marino */ 563*a1157835SDaniel Fojt u8 ssid_postfix[SSID_MAX_LEN - 9]; 5643ff40c12SJohn Marino 5653ff40c12SJohn Marino /** 5663ff40c12SJohn Marino * ssid_postfix_len - Length of the ssid_postfix data 5673ff40c12SJohn Marino */ 5683ff40c12SJohn Marino size_t ssid_postfix_len; 5693ff40c12SJohn Marino 5703ff40c12SJohn Marino /** 5713ff40c12SJohn Marino * max_listen - Maximum listen duration in ms 5723ff40c12SJohn Marino */ 5733ff40c12SJohn Marino unsigned int max_listen; 5743ff40c12SJohn Marino 5753ff40c12SJohn Marino /** 576*a1157835SDaniel Fojt * passphrase_len - Passphrase length (8..63) 577*a1157835SDaniel Fojt * 578*a1157835SDaniel Fojt * This parameter controls the length of the random passphrase that is 579*a1157835SDaniel Fojt * generated at the GO. 580*a1157835SDaniel Fojt */ 581*a1157835SDaniel Fojt unsigned int passphrase_len; 582*a1157835SDaniel Fojt 583*a1157835SDaniel Fojt /** 5843ff40c12SJohn Marino * cb_ctx - Context to use with callback functions 5853ff40c12SJohn Marino */ 5863ff40c12SJohn Marino void *cb_ctx; 5873ff40c12SJohn Marino 5883ff40c12SJohn Marino /** 5893ff40c12SJohn Marino * debug_print - Debug print 5903ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 5913ff40c12SJohn Marino * @level: Debug verbosity level (MSG_*) 5923ff40c12SJohn Marino * @msg: Debug message 5933ff40c12SJohn Marino */ 5943ff40c12SJohn Marino void (*debug_print)(void *ctx, int level, const char *msg); 5953ff40c12SJohn Marino 5963ff40c12SJohn Marino 5973ff40c12SJohn Marino /* Callbacks to request lower layer driver operations */ 5983ff40c12SJohn Marino 5993ff40c12SJohn Marino /** 6003ff40c12SJohn Marino * p2p_scan - Request a P2P scan/search 6013ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 6023ff40c12SJohn Marino * @type: Scan type 6033ff40c12SJohn Marino * @freq: Specific frequency (MHz) to scan or 0 for no restriction 6043ff40c12SJohn Marino * @num_req_dev_types: Number of requested device types 6053ff40c12SJohn Marino * @req_dev_types: Array containing requested device types 6063ff40c12SJohn Marino * @dev_id: Device ID to search for or %NULL to find all devices 6073ff40c12SJohn Marino * @pw_id: Device Password ID 6083ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 6093ff40c12SJohn Marino * 6103ff40c12SJohn Marino * This callback function is used to request a P2P scan or search 6113ff40c12SJohn Marino * operation to be completed. Type type argument specifies which type 6123ff40c12SJohn Marino * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the 6133ff40c12SJohn Marino * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL 614*a1157835SDaniel Fojt * indicates that all channels are to be scanned. @P2P_SCAN_SPECIFIC 615*a1157835SDaniel Fojt * request a scan of a single channel specified by freq. 6163ff40c12SJohn Marino * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels 6173ff40c12SJohn Marino * plus one extra channel specified by freq. 6183ff40c12SJohn Marino * 6193ff40c12SJohn Marino * The full scan is used for the initial scan to find group owners from 6203ff40c12SJohn Marino * all. The other types are used during search phase scan of the social 6213ff40c12SJohn Marino * channels (with potential variation if the Listen channel of the 6223ff40c12SJohn Marino * target peer is known or if other channels are scanned in steps). 6233ff40c12SJohn Marino * 6243ff40c12SJohn Marino * The scan results are returned after this call by calling 6253ff40c12SJohn Marino * p2p_scan_res_handler() for each scan result that has a P2P IE and 6263ff40c12SJohn Marino * then calling p2p_scan_res_handled() to indicate that all scan 6273ff40c12SJohn Marino * results have been indicated. 6283ff40c12SJohn Marino */ 6293ff40c12SJohn Marino int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq, 6303ff40c12SJohn Marino unsigned int num_req_dev_types, 6313ff40c12SJohn Marino const u8 *req_dev_types, const u8 *dev_id, u16 pw_id); 6323ff40c12SJohn Marino 6333ff40c12SJohn Marino /** 6343ff40c12SJohn Marino * send_probe_resp - Transmit a Probe Response frame 6353ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 6363ff40c12SJohn Marino * @buf: Probe Response frame (including the header and body) 637*a1157835SDaniel Fojt * @freq: Forced frequency (in MHz) to use or 0. 6383ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 6393ff40c12SJohn Marino * 6403ff40c12SJohn Marino * This function is used to reply to Probe Request frames that were 6413ff40c12SJohn Marino * indicated with a call to p2p_probe_req_rx(). The response is to be 642*a1157835SDaniel Fojt * sent on the same channel, unless otherwise specified, or to be 643*a1157835SDaniel Fojt * dropped if the driver is not listening to Probe Request frames 644*a1157835SDaniel Fojt * anymore. 6453ff40c12SJohn Marino * 6463ff40c12SJohn Marino * Alternatively, the responsibility for building the Probe Response 6473ff40c12SJohn Marino * frames in Listen state may be in another system component in which 6483ff40c12SJohn Marino * case this function need to be implemented (i.e., the function 6493ff40c12SJohn Marino * pointer can be %NULL). The WPS and P2P IEs to be added for Probe 6503ff40c12SJohn Marino * Response frames in such a case are available from the 6513ff40c12SJohn Marino * start_listen() callback. It should be noted that the received Probe 6523ff40c12SJohn Marino * Request frames must be indicated by calling p2p_probe_req_rx() even 6533ff40c12SJohn Marino * if this send_probe_resp() is not used. 6543ff40c12SJohn Marino */ 655*a1157835SDaniel Fojt int (*send_probe_resp)(void *ctx, const struct wpabuf *buf, 656*a1157835SDaniel Fojt unsigned int freq); 6573ff40c12SJohn Marino 6583ff40c12SJohn Marino /** 6593ff40c12SJohn Marino * send_action - Transmit an Action frame 6603ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 6613ff40c12SJohn Marino * @freq: Frequency in MHz for the channel on which to transmit 6623ff40c12SJohn Marino * @dst: Destination MAC address (Address 1) 6633ff40c12SJohn Marino * @src: Source MAC address (Address 2) 6643ff40c12SJohn Marino * @bssid: BSSID (Address 3) 6653ff40c12SJohn Marino * @buf: Frame body (starting from Category field) 6663ff40c12SJohn Marino * @len: Length of buf in octets 6673ff40c12SJohn Marino * @wait_time: How many msec to wait for a response frame 668*a1157835SDaniel Fojt * @scheduled: Return value indicating whether the transmissions was 669*a1157835SDaniel Fojt * scheduled to happen once the radio is available 6703ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 6713ff40c12SJohn Marino * 6723ff40c12SJohn Marino * The Action frame may not be transmitted immediately and the status 6733ff40c12SJohn Marino * of the transmission must be reported by calling 6743ff40c12SJohn Marino * p2p_send_action_cb() once the frame has either been transmitted or 6753ff40c12SJohn Marino * it has been dropped due to excessive retries or other failure to 6763ff40c12SJohn Marino * transmit. 6773ff40c12SJohn Marino */ 6783ff40c12SJohn Marino int (*send_action)(void *ctx, unsigned int freq, const u8 *dst, 6793ff40c12SJohn Marino const u8 *src, const u8 *bssid, const u8 *buf, 680*a1157835SDaniel Fojt size_t len, unsigned int wait_time, int *scheduled); 6813ff40c12SJohn Marino 6823ff40c12SJohn Marino /** 6833ff40c12SJohn Marino * send_action_done - Notify that Action frame sequence was completed 6843ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 6853ff40c12SJohn Marino * 6863ff40c12SJohn Marino * This function is called when the Action frame sequence that was 6873ff40c12SJohn Marino * started with send_action() has been completed, i.e., when there is 6883ff40c12SJohn Marino * no need to wait for a response from the destination peer anymore. 6893ff40c12SJohn Marino */ 6903ff40c12SJohn Marino void (*send_action_done)(void *ctx); 6913ff40c12SJohn Marino 6923ff40c12SJohn Marino /** 6933ff40c12SJohn Marino * start_listen - Start Listen state 6943ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 6953ff40c12SJohn Marino * @freq: Frequency of the listen channel in MHz 6963ff40c12SJohn Marino * @duration: Duration for the Listen state in milliseconds 6973ff40c12SJohn Marino * @probe_resp_ie: IE(s) to be added to Probe Response frames 6983ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 6993ff40c12SJohn Marino * 7003ff40c12SJohn Marino * This Listen state may not start immediately since the driver may 7013ff40c12SJohn Marino * have other pending operations to complete first. Once the Listen 7023ff40c12SJohn Marino * state has started, p2p_listen_cb() must be called to notify the P2P 7033ff40c12SJohn Marino * module. Once the Listen state is stopped, p2p_listen_end() must be 7043ff40c12SJohn Marino * called to notify the P2P module that the driver is not in the Listen 7053ff40c12SJohn Marino * state anymore. 7063ff40c12SJohn Marino * 7073ff40c12SJohn Marino * If the send_probe_resp() is not used for generating the response, 7083ff40c12SJohn Marino * the IEs from probe_resp_ie need to be added to the end of the Probe 7093ff40c12SJohn Marino * Response frame body. If send_probe_resp() is used, the probe_resp_ie 7103ff40c12SJohn Marino * information can be ignored. 7113ff40c12SJohn Marino */ 7123ff40c12SJohn Marino int (*start_listen)(void *ctx, unsigned int freq, 7133ff40c12SJohn Marino unsigned int duration, 7143ff40c12SJohn Marino const struct wpabuf *probe_resp_ie); 7153ff40c12SJohn Marino /** 7163ff40c12SJohn Marino * stop_listen - Stop Listen state 7173ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7183ff40c12SJohn Marino * 7193ff40c12SJohn Marino * This callback can be used to stop a Listen state operation that was 7203ff40c12SJohn Marino * previously requested with start_listen(). 7213ff40c12SJohn Marino */ 7223ff40c12SJohn Marino void (*stop_listen)(void *ctx); 7233ff40c12SJohn Marino 7243ff40c12SJohn Marino /** 7253ff40c12SJohn Marino * get_noa - Get current Notice of Absence attribute payload 7263ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7273ff40c12SJohn Marino * @interface_addr: P2P Interface Address of the GO 7283ff40c12SJohn Marino * @buf: Buffer for returning NoA 7293ff40c12SJohn Marino * @buf_len: Buffer length in octets 7303ff40c12SJohn Marino * Returns: Number of octets used in buf, 0 to indicate no NoA is being 7313ff40c12SJohn Marino * advertized, or -1 on failure 7323ff40c12SJohn Marino * 7333ff40c12SJohn Marino * This function is used to fetch the current Notice of Absence 7343ff40c12SJohn Marino * attribute value from GO. 7353ff40c12SJohn Marino */ 7363ff40c12SJohn Marino int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf, 7373ff40c12SJohn Marino size_t buf_len); 7383ff40c12SJohn Marino 7393ff40c12SJohn Marino /* Callbacks to notify events to upper layer management entity */ 7403ff40c12SJohn Marino 7413ff40c12SJohn Marino /** 7423ff40c12SJohn Marino * dev_found - Notification of a found P2P Device 7433ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7443ff40c12SJohn Marino * @addr: Source address of the message triggering this notification 7453ff40c12SJohn Marino * @info: P2P peer information 7463ff40c12SJohn Marino * @new_device: Inform if the peer is newly found 7473ff40c12SJohn Marino * 7483ff40c12SJohn Marino * This callback is used to notify that a new P2P Device has been 7493ff40c12SJohn Marino * found. This may happen, e.g., during Search state based on scan 7503ff40c12SJohn Marino * results or during Listen state based on receive Probe Request and 7513ff40c12SJohn Marino * Group Owner Negotiation Request. 7523ff40c12SJohn Marino */ 7533ff40c12SJohn Marino void (*dev_found)(void *ctx, const u8 *addr, 7543ff40c12SJohn Marino const struct p2p_peer_info *info, 7553ff40c12SJohn Marino int new_device); 7563ff40c12SJohn Marino 7573ff40c12SJohn Marino /** 7583ff40c12SJohn Marino * dev_lost - Notification of a lost P2P Device 7593ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7603ff40c12SJohn Marino * @dev_addr: P2P Device Address of the lost P2P Device 7613ff40c12SJohn Marino * 7623ff40c12SJohn Marino * This callback is used to notify that a P2P Device has been deleted. 7633ff40c12SJohn Marino */ 7643ff40c12SJohn Marino void (*dev_lost)(void *ctx, const u8 *dev_addr); 7653ff40c12SJohn Marino 7663ff40c12SJohn Marino /** 7673ff40c12SJohn Marino * find_stopped - Notification of a p2p_find operation stopping 7683ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7693ff40c12SJohn Marino */ 7703ff40c12SJohn Marino void (*find_stopped)(void *ctx); 7713ff40c12SJohn Marino 7723ff40c12SJohn Marino /** 7733ff40c12SJohn Marino * go_neg_req_rx - Notification of a receive GO Negotiation Request 7743ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7753ff40c12SJohn Marino * @src: Source address of the message triggering this notification 7763ff40c12SJohn Marino * @dev_passwd_id: WPS Device Password ID 777*a1157835SDaniel Fojt * @go_intent: Peer's GO Intent 7783ff40c12SJohn Marino * 7793ff40c12SJohn Marino * This callback is used to notify that a P2P Device is requesting 7803ff40c12SJohn Marino * group owner negotiation with us, but we do not have all the 7813ff40c12SJohn Marino * necessary information to start GO Negotiation. This indicates that 7823ff40c12SJohn Marino * the local user has not authorized the connection yet by providing a 7833ff40c12SJohn Marino * PIN or PBC button press. This information can be provided with a 7843ff40c12SJohn Marino * call to p2p_connect(). 7853ff40c12SJohn Marino */ 786*a1157835SDaniel Fojt void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id, 787*a1157835SDaniel Fojt u8 go_intent); 7883ff40c12SJohn Marino 7893ff40c12SJohn Marino /** 7903ff40c12SJohn Marino * go_neg_completed - Notification of GO Negotiation results 7913ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 7923ff40c12SJohn Marino * @res: GO Negotiation results 7933ff40c12SJohn Marino * 7943ff40c12SJohn Marino * This callback is used to notify that Group Owner Negotiation has 7953ff40c12SJohn Marino * been completed. Non-zero struct p2p_go_neg_results::status indicates 7963ff40c12SJohn Marino * failed negotiation. In case of success, this function is responsible 7973ff40c12SJohn Marino * for creating a new group interface (or using the existing interface 7983ff40c12SJohn Marino * depending on driver features), setting up the group interface in 7993ff40c12SJohn Marino * proper mode based on struct p2p_go_neg_results::role_go and 8003ff40c12SJohn Marino * initializing WPS provisioning either as a Registrar (if GO) or as an 8013ff40c12SJohn Marino * Enrollee. Successful WPS provisioning must be indicated by calling 8023ff40c12SJohn Marino * p2p_wps_success_cb(). The callee is responsible for timing out group 8033ff40c12SJohn Marino * formation if WPS provisioning cannot be completed successfully 8043ff40c12SJohn Marino * within 15 seconds. 8053ff40c12SJohn Marino */ 8063ff40c12SJohn Marino void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res); 8073ff40c12SJohn Marino 8083ff40c12SJohn Marino /** 8093ff40c12SJohn Marino * sd_request - Callback on Service Discovery Request 8103ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 8113ff40c12SJohn Marino * @freq: Frequency (in MHz) of the channel 8123ff40c12SJohn Marino * @sa: Source address of the request 8133ff40c12SJohn Marino * @dialog_token: Dialog token 8143ff40c12SJohn Marino * @update_indic: Service Update Indicator from the source of request 8153ff40c12SJohn Marino * @tlvs: P2P Service Request TLV(s) 8163ff40c12SJohn Marino * @tlvs_len: Length of tlvs buffer in octets 8173ff40c12SJohn Marino * 8183ff40c12SJohn Marino * This callback is used to indicate reception of a service discovery 8193ff40c12SJohn Marino * request. Response to the query must be indicated by calling 8203ff40c12SJohn Marino * p2p_sd_response() with the context information from the arguments to 8213ff40c12SJohn Marino * this callback function. 8223ff40c12SJohn Marino * 8233ff40c12SJohn Marino * This callback handler can be set to %NULL to indicate that service 8243ff40c12SJohn Marino * discovery is not supported. 8253ff40c12SJohn Marino */ 8263ff40c12SJohn Marino void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token, 8273ff40c12SJohn Marino u16 update_indic, const u8 *tlvs, size_t tlvs_len); 8283ff40c12SJohn Marino 8293ff40c12SJohn Marino /** 8303ff40c12SJohn Marino * sd_response - Callback on Service Discovery Response 8313ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 8323ff40c12SJohn Marino * @sa: Source address of the request 8333ff40c12SJohn Marino * @update_indic: Service Update Indicator from the source of response 8343ff40c12SJohn Marino * @tlvs: P2P Service Response TLV(s) 8353ff40c12SJohn Marino * @tlvs_len: Length of tlvs buffer in octets 8363ff40c12SJohn Marino * 8373ff40c12SJohn Marino * This callback is used to indicate reception of a service discovery 8383ff40c12SJohn Marino * response. This callback handler can be set to %NULL if no service 8393ff40c12SJohn Marino * discovery requests are used. The information provided with this call 8403ff40c12SJohn Marino * is replies to the queries scheduled with p2p_sd_request(). 8413ff40c12SJohn Marino */ 8423ff40c12SJohn Marino void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic, 8433ff40c12SJohn Marino const u8 *tlvs, size_t tlvs_len); 8443ff40c12SJohn Marino 8453ff40c12SJohn Marino /** 8463ff40c12SJohn Marino * prov_disc_req - Callback on Provisiong Discovery Request 8473ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 8483ff40c12SJohn Marino * @peer: Source address of the request 8493ff40c12SJohn Marino * @config_methods: Requested WPS Config Method 8503ff40c12SJohn Marino * @dev_addr: P2P Device Address of the found P2P Device 8513ff40c12SJohn Marino * @pri_dev_type: Primary Device Type 8523ff40c12SJohn Marino * @dev_name: Device Name 8533ff40c12SJohn Marino * @supp_config_methods: Supported configuration Methods 8543ff40c12SJohn Marino * @dev_capab: Device Capabilities 8553ff40c12SJohn Marino * @group_capab: Group Capabilities 8563ff40c12SJohn Marino * @group_id: P2P Group ID (or %NULL if not included) 8573ff40c12SJohn Marino * @group_id_len: Length of P2P Group ID 8583ff40c12SJohn Marino * 8593ff40c12SJohn Marino * This callback is used to indicate reception of a Provision Discovery 8603ff40c12SJohn Marino * Request frame that the P2P module accepted. 8613ff40c12SJohn Marino */ 8623ff40c12SJohn Marino void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods, 8633ff40c12SJohn Marino const u8 *dev_addr, const u8 *pri_dev_type, 8643ff40c12SJohn Marino const char *dev_name, u16 supp_config_methods, 8653ff40c12SJohn Marino u8 dev_capab, u8 group_capab, 8663ff40c12SJohn Marino const u8 *group_id, size_t group_id_len); 8673ff40c12SJohn Marino 8683ff40c12SJohn Marino /** 8693ff40c12SJohn Marino * prov_disc_resp - Callback on Provisiong Discovery Response 8703ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 8713ff40c12SJohn Marino * @peer: Source address of the response 8723ff40c12SJohn Marino * @config_methods: Value from p2p_prov_disc_req() or 0 on failure 8733ff40c12SJohn Marino * 8743ff40c12SJohn Marino * This callback is used to indicate reception of a Provision Discovery 8753ff40c12SJohn Marino * Response frame for a pending request scheduled with 8763ff40c12SJohn Marino * p2p_prov_disc_req(). This callback handler can be set to %NULL if 8773ff40c12SJohn Marino * provision discovery is not used. 8783ff40c12SJohn Marino */ 8793ff40c12SJohn Marino void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods); 8803ff40c12SJohn Marino 8813ff40c12SJohn Marino /** 8823ff40c12SJohn Marino * prov_disc_fail - Callback on Provision Discovery failure 8833ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 8843ff40c12SJohn Marino * @peer: Source address of the response 8853ff40c12SJohn Marino * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS 886*a1157835SDaniel Fojt * @adv_id: If non-zero, then the adv_id of the PD Request 887*a1157835SDaniel Fojt * @adv_mac: P2P Device Address of the advertizer 888*a1157835SDaniel Fojt * @deferred_session_resp: Deferred session response sent by advertizer 8893ff40c12SJohn Marino * 8903ff40c12SJohn Marino * This callback is used to indicate either a failure or no response 8913ff40c12SJohn Marino * to an earlier provision discovery request. 8923ff40c12SJohn Marino * 8933ff40c12SJohn Marino * This callback handler can be set to %NULL if provision discovery 8943ff40c12SJohn Marino * is not used or failures do not need to be indicated. 8953ff40c12SJohn Marino */ 8963ff40c12SJohn Marino void (*prov_disc_fail)(void *ctx, const u8 *peer, 897*a1157835SDaniel Fojt enum p2p_prov_disc_status status, 898*a1157835SDaniel Fojt u32 adv_id, const u8 *adv_mac, 899*a1157835SDaniel Fojt const char *deferred_session_resp); 9003ff40c12SJohn Marino 9013ff40c12SJohn Marino /** 9023ff40c12SJohn Marino * invitation_process - Optional callback for processing Invitations 9033ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 9043ff40c12SJohn Marino * @sa: Source address of the Invitation Request 9053ff40c12SJohn Marino * @bssid: P2P Group BSSID from the request or %NULL if not included 9063ff40c12SJohn Marino * @go_dev_addr: GO Device Address from P2P Group ID 9073ff40c12SJohn Marino * @ssid: SSID from P2P Group ID 9083ff40c12SJohn Marino * @ssid_len: Length of ssid buffer in octets 9093ff40c12SJohn Marino * @go: Variable for returning whether the local end is GO in the group 9103ff40c12SJohn Marino * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO) 9113ff40c12SJohn Marino * @force_freq: Variable for returning forced frequency for the group 9123ff40c12SJohn Marino * @persistent_group: Whether this is an invitation to reinvoke a 9133ff40c12SJohn Marino * persistent group (instead of invitation to join an active 9143ff40c12SJohn Marino * group) 9153ff40c12SJohn Marino * @channels: Available operating channels for the group 9163ff40c12SJohn Marino * @dev_pw_id: Device Password ID for NFC static handover or -1 if not 9173ff40c12SJohn Marino * used 9183ff40c12SJohn Marino * Returns: Status code (P2P_SC_*) 9193ff40c12SJohn Marino * 9203ff40c12SJohn Marino * This optional callback can be used to implement persistent reconnect 9213ff40c12SJohn Marino * by allowing automatic restarting of persistent groups without user 9223ff40c12SJohn Marino * interaction. If this callback is not implemented (i.e., is %NULL), 9233ff40c12SJohn Marino * the received Invitation Request frames are replied with 9243ff40c12SJohn Marino * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the 9253ff40c12SJohn Marino * invitation_result() callback. 9263ff40c12SJohn Marino * 9273ff40c12SJohn Marino * If the requested parameters are acceptable and the group is known, 9283ff40c12SJohn Marino * %P2P_SC_SUCCESS may be returned. If the requested group is unknown, 9293ff40c12SJohn Marino * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED 9303ff40c12SJohn Marino * can be returned if there is not enough data to provide immediate 9313ff40c12SJohn Marino * response, i.e., if some sort of user interaction is needed. The 9323ff40c12SJohn Marino * invitation_received() callback will be called in that case 9333ff40c12SJohn Marino * immediately after this call. 9343ff40c12SJohn Marino */ 9353ff40c12SJohn Marino u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid, 9363ff40c12SJohn Marino const u8 *go_dev_addr, const u8 *ssid, 9373ff40c12SJohn Marino size_t ssid_len, int *go, u8 *group_bssid, 9383ff40c12SJohn Marino int *force_freq, int persistent_group, 9393ff40c12SJohn Marino const struct p2p_channels *channels, 9403ff40c12SJohn Marino int dev_pw_id); 9413ff40c12SJohn Marino 9423ff40c12SJohn Marino /** 9433ff40c12SJohn Marino * invitation_received - Callback on Invitation Request RX 9443ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 9453ff40c12SJohn Marino * @sa: Source address of the Invitation Request 9463ff40c12SJohn Marino * @bssid: P2P Group BSSID or %NULL if not received 9473ff40c12SJohn Marino * @ssid: SSID of the group 9483ff40c12SJohn Marino * @ssid_len: Length of ssid in octets 9493ff40c12SJohn Marino * @go_dev_addr: GO Device Address 9503ff40c12SJohn Marino * @status: Response Status 9513ff40c12SJohn Marino * @op_freq: Operational frequency for the group 9523ff40c12SJohn Marino * 9533ff40c12SJohn Marino * This callback is used to indicate sending of an Invitation Response 9543ff40c12SJohn Marino * for a received Invitation Request. If status == 0 (success), the 9553ff40c12SJohn Marino * upper layer code is responsible for starting the group. status == 1 9563ff40c12SJohn Marino * indicates need to get user authorization for the group. Other status 9573ff40c12SJohn Marino * values indicate that the invitation request was rejected. 9583ff40c12SJohn Marino */ 9593ff40c12SJohn Marino void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid, 9603ff40c12SJohn Marino const u8 *ssid, size_t ssid_len, 9613ff40c12SJohn Marino const u8 *go_dev_addr, u8 status, 9623ff40c12SJohn Marino int op_freq); 9633ff40c12SJohn Marino 9643ff40c12SJohn Marino /** 9653ff40c12SJohn Marino * invitation_result - Callback on Invitation result 9663ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 9673ff40c12SJohn Marino * @status: Negotiation result (Status Code) 9683ff40c12SJohn Marino * @bssid: P2P Group BSSID or %NULL if not received 9693ff40c12SJohn Marino * @channels: Available operating channels for the group 9703ff40c12SJohn Marino * @addr: Peer address 9713ff40c12SJohn Marino * @freq: Frequency (in MHz) indicated during invitation or 0 972*a1157835SDaniel Fojt * @peer_oper_freq: Operating frequency (in MHz) advertized by the peer 973*a1157835SDaniel Fojt * during invitation or 0 9743ff40c12SJohn Marino * 9753ff40c12SJohn Marino * This callback is used to indicate result of an Invitation procedure 9763ff40c12SJohn Marino * started with a call to p2p_invite(). The indicated status code is 9773ff40c12SJohn Marino * the value received from the peer in Invitation Response with 0 9783ff40c12SJohn Marino * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a 9793ff40c12SJohn Marino * local failure in transmitting the Invitation Request. 9803ff40c12SJohn Marino */ 9813ff40c12SJohn Marino void (*invitation_result)(void *ctx, int status, const u8 *bssid, 9823ff40c12SJohn Marino const struct p2p_channels *channels, 983*a1157835SDaniel Fojt const u8 *addr, int freq, int peer_oper_freq); 9843ff40c12SJohn Marino 9853ff40c12SJohn Marino /** 9863ff40c12SJohn Marino * go_connected - Check whether we are connected to a GO 9873ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 9883ff40c12SJohn Marino * @dev_addr: P2P Device Address of a GO 9893ff40c12SJohn Marino * Returns: 1 if we are connected as a P2P client to the specified GO 9903ff40c12SJohn Marino * or 0 if not. 9913ff40c12SJohn Marino */ 9923ff40c12SJohn Marino int (*go_connected)(void *ctx, const u8 *dev_addr); 9933ff40c12SJohn Marino 9943ff40c12SJohn Marino /** 9953ff40c12SJohn Marino * presence_resp - Callback on Presence Response 9963ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 9973ff40c12SJohn Marino * @src: Source address (GO's P2P Interface Address) 9983ff40c12SJohn Marino * @status: Result of the request (P2P_SC_*) 9993ff40c12SJohn Marino * @noa: Returned NoA value 10003ff40c12SJohn Marino * @noa_len: Length of the NoA buffer in octets 10013ff40c12SJohn Marino */ 10023ff40c12SJohn Marino void (*presence_resp)(void *ctx, const u8 *src, u8 status, 10033ff40c12SJohn Marino const u8 *noa, size_t noa_len); 10043ff40c12SJohn Marino 10053ff40c12SJohn Marino /** 10063ff40c12SJohn Marino * is_concurrent_session_active - Check whether concurrent session is 10073ff40c12SJohn Marino * active on other virtual interfaces 10083ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 10093ff40c12SJohn Marino * Returns: 1 if concurrent session is active on other virtual interface 10103ff40c12SJohn Marino * or 0 if not. 10113ff40c12SJohn Marino */ 10123ff40c12SJohn Marino int (*is_concurrent_session_active)(void *ctx); 1013*a1157835SDaniel Fojt 1014*a1157835SDaniel Fojt /** 1015*a1157835SDaniel Fojt * is_p2p_in_progress - Check whether P2P operation is in progress 1016*a1157835SDaniel Fojt * @ctx: Callback context from cb_ctx 1017*a1157835SDaniel Fojt * Returns: 1 if P2P operation (e.g., group formation) is in progress 1018*a1157835SDaniel Fojt * or 0 if not. 1019*a1157835SDaniel Fojt */ 1020*a1157835SDaniel Fojt int (*is_p2p_in_progress)(void *ctx); 1021*a1157835SDaniel Fojt 1022*a1157835SDaniel Fojt /** 1023*a1157835SDaniel Fojt * Determine if we have a persistent group we share with remote peer 1024*a1157835SDaniel Fojt * and allocate interface for this group if needed 1025*a1157835SDaniel Fojt * @ctx: Callback context from cb_ctx 1026*a1157835SDaniel Fojt * @addr: Peer device address to search for 1027*a1157835SDaniel Fojt * @ssid: Persistent group SSID or %NULL if any 1028*a1157835SDaniel Fojt * @ssid_len: Length of @ssid 1029*a1157835SDaniel Fojt * @go_dev_addr: Buffer for returning GO P2P Device Address 1030*a1157835SDaniel Fojt * @ret_ssid: Buffer for returning group SSID 1031*a1157835SDaniel Fojt * @ret_ssid_len: Buffer for returning length of @ssid 1032*a1157835SDaniel Fojt * @intended_iface_addr: Buffer for returning intended iface address 1033*a1157835SDaniel Fojt * Returns: 1 if a matching persistent group was found, 0 otherwise 1034*a1157835SDaniel Fojt */ 1035*a1157835SDaniel Fojt int (*get_persistent_group)(void *ctx, const u8 *addr, const u8 *ssid, 1036*a1157835SDaniel Fojt size_t ssid_len, u8 *go_dev_addr, 1037*a1157835SDaniel Fojt u8 *ret_ssid, size_t *ret_ssid_len, 1038*a1157835SDaniel Fojt u8 *intended_iface_addr); 1039*a1157835SDaniel Fojt 1040*a1157835SDaniel Fojt /** 1041*a1157835SDaniel Fojt * Get information about a possible local GO role 1042*a1157835SDaniel Fojt * @ctx: Callback context from cb_ctx 1043*a1157835SDaniel Fojt * @intended_addr: Buffer for returning intended GO interface address 1044*a1157835SDaniel Fojt * @ssid: Buffer for returning group SSID 1045*a1157835SDaniel Fojt * @ssid_len: Buffer for returning length of @ssid 1046*a1157835SDaniel Fojt * @group_iface: Buffer for returning whether a separate group interface 1047*a1157835SDaniel Fojt * would be used 1048*a1157835SDaniel Fojt * @freq: Variable for returning the current operating frequency of a 1049*a1157835SDaniel Fojt * currently running P2P GO. 1050*a1157835SDaniel Fojt * Returns: 1 if GO info found, 0 otherwise 1051*a1157835SDaniel Fojt * 1052*a1157835SDaniel Fojt * This is used to compose New Group settings (SSID, and intended 1053*a1157835SDaniel Fojt * address) during P2PS provisioning if results of provisioning *might* 1054*a1157835SDaniel Fojt * result in our being an autonomous GO. 1055*a1157835SDaniel Fojt */ 1056*a1157835SDaniel Fojt int (*get_go_info)(void *ctx, u8 *intended_addr, 1057*a1157835SDaniel Fojt u8 *ssid, size_t *ssid_len, int *group_iface, 1058*a1157835SDaniel Fojt unsigned int *freq); 1059*a1157835SDaniel Fojt 1060*a1157835SDaniel Fojt /** 1061*a1157835SDaniel Fojt * remove_stale_groups - Remove stale P2PS groups 1062*a1157835SDaniel Fojt * 1063*a1157835SDaniel Fojt * Because P2PS stages *potential* GOs, and remote devices can remove 1064*a1157835SDaniel Fojt * credentials unilaterally, we need to make sure we don't let stale 1065*a1157835SDaniel Fojt * unusable groups build up. 1066*a1157835SDaniel Fojt */ 1067*a1157835SDaniel Fojt int (*remove_stale_groups)(void *ctx, const u8 *peer, const u8 *go, 1068*a1157835SDaniel Fojt const u8 *ssid, size_t ssid_len); 1069*a1157835SDaniel Fojt 1070*a1157835SDaniel Fojt /** 1071*a1157835SDaniel Fojt * p2ps_prov_complete - P2PS provisioning complete 1072*a1157835SDaniel Fojt * 1073*a1157835SDaniel Fojt * When P2PS provisioning completes (successfully or not) we must 1074*a1157835SDaniel Fojt * transmit all of the results to the upper layers. 1075*a1157835SDaniel Fojt */ 1076*a1157835SDaniel Fojt void (*p2ps_prov_complete)(void *ctx, u8 status, const u8 *dev, 1077*a1157835SDaniel Fojt const u8 *adv_mac, const u8 *ses_mac, 1078*a1157835SDaniel Fojt const u8 *grp_mac, u32 adv_id, u32 ses_id, 1079*a1157835SDaniel Fojt u8 conncap, int passwd_id, 1080*a1157835SDaniel Fojt const u8 *persist_ssid, 1081*a1157835SDaniel Fojt size_t persist_ssid_size, int response_done, 1082*a1157835SDaniel Fojt int prov_start, const char *session_info, 1083*a1157835SDaniel Fojt const u8 *feat_cap, size_t feat_cap_len, 1084*a1157835SDaniel Fojt unsigned int freq, const u8 *group_ssid, 1085*a1157835SDaniel Fojt size_t group_ssid_len); 1086*a1157835SDaniel Fojt 1087*a1157835SDaniel Fojt /** 1088*a1157835SDaniel Fojt * prov_disc_resp_cb - Callback for indicating completion of PD Response 1089*a1157835SDaniel Fojt * @ctx: Callback context from cb_ctx 1090*a1157835SDaniel Fojt * Returns: 1 if operation was started, 0 otherwise 1091*a1157835SDaniel Fojt * 1092*a1157835SDaniel Fojt * This callback can be used to perform any pending actions after 1093*a1157835SDaniel Fojt * provisioning. It is mainly used for P2PS pending group creation. 1094*a1157835SDaniel Fojt */ 1095*a1157835SDaniel Fojt int (*prov_disc_resp_cb)(void *ctx); 1096*a1157835SDaniel Fojt 1097*a1157835SDaniel Fojt /** 1098*a1157835SDaniel Fojt * p2ps_group_capability - Determine group capability 1099*a1157835SDaniel Fojt * @ctx: Callback context from cb_ctx 1100*a1157835SDaniel Fojt * @incoming: Peer requested roles, expressed with P2PS_SETUP_* bitmap. 1101*a1157835SDaniel Fojt * @role: Local roles, expressed with P2PS_SETUP_* bitmap. 1102*a1157835SDaniel Fojt * @force_freq: Variable for returning forced frequency for the group. 1103*a1157835SDaniel Fojt * @pref_freq: Variable for returning preferred frequency for the group. 1104*a1157835SDaniel Fojt * Returns: P2PS_SETUP_* bitmap of group capability result. 1105*a1157835SDaniel Fojt * 1106*a1157835SDaniel Fojt * This function can be used to determine group capability and 1107*a1157835SDaniel Fojt * frequencies based on information from P2PS PD exchange and the 1108*a1157835SDaniel Fojt * current state of ongoing groups and driver capabilities. 1109*a1157835SDaniel Fojt */ 1110*a1157835SDaniel Fojt u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role, 1111*a1157835SDaniel Fojt unsigned int *force_freq, 1112*a1157835SDaniel Fojt unsigned int *pref_freq); 1113*a1157835SDaniel Fojt 1114*a1157835SDaniel Fojt /** 1115*a1157835SDaniel Fojt * get_pref_freq_list - Get preferred frequency list for an interface 1116*a1157835SDaniel Fojt * @ctx: Callback context from cb_ctx 1117*a1157835SDaniel Fojt * @go: Whether the use if for GO role 1118*a1157835SDaniel Fojt * @len: Length of freq_list in entries (both IN and OUT) 1119*a1157835SDaniel Fojt * @freq_list: Buffer for returning the preferred frequencies (MHz) 1120*a1157835SDaniel Fojt * Returns: 0 on success, -1 on failure 1121*a1157835SDaniel Fojt * 1122*a1157835SDaniel Fojt * This function can be used to query the preferred frequency list from 1123*a1157835SDaniel Fojt * the driver specific to a particular interface type. 1124*a1157835SDaniel Fojt */ 1125*a1157835SDaniel Fojt int (*get_pref_freq_list)(void *ctx, int go, 1126*a1157835SDaniel Fojt unsigned int *len, unsigned int *freq_list); 11273ff40c12SJohn Marino }; 11283ff40c12SJohn Marino 11293ff40c12SJohn Marino 11303ff40c12SJohn Marino /* P2P module initialization/deinitialization */ 11313ff40c12SJohn Marino 11323ff40c12SJohn Marino /** 11333ff40c12SJohn Marino * p2p_init - Initialize P2P module 11343ff40c12SJohn Marino * @cfg: P2P module configuration 11353ff40c12SJohn Marino * Returns: Pointer to private data or %NULL on failure 11363ff40c12SJohn Marino * 11373ff40c12SJohn Marino * This function is used to initialize global P2P module context (one per 11383ff40c12SJohn Marino * device). The P2P module will keep a copy of the configuration data, so the 11393ff40c12SJohn Marino * caller does not need to maintain this structure. However, the callback 11403ff40c12SJohn Marino * functions and the context parameters to them must be kept available until 11413ff40c12SJohn Marino * the P2P module is deinitialized with p2p_deinit(). 11423ff40c12SJohn Marino */ 11433ff40c12SJohn Marino struct p2p_data * p2p_init(const struct p2p_config *cfg); 11443ff40c12SJohn Marino 11453ff40c12SJohn Marino /** 11463ff40c12SJohn Marino * p2p_deinit - Deinitialize P2P module 11473ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 11483ff40c12SJohn Marino */ 11493ff40c12SJohn Marino void p2p_deinit(struct p2p_data *p2p); 11503ff40c12SJohn Marino 11513ff40c12SJohn Marino /** 11523ff40c12SJohn Marino * p2p_flush - Flush P2P module state 11533ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 11543ff40c12SJohn Marino * 11553ff40c12SJohn Marino * This command removes the P2P module state like peer device entries. 11563ff40c12SJohn Marino */ 11573ff40c12SJohn Marino void p2p_flush(struct p2p_data *p2p); 11583ff40c12SJohn Marino 11593ff40c12SJohn Marino /** 11603ff40c12SJohn Marino * p2p_unauthorize - Unauthorize the specified peer device 11613ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 11623ff40c12SJohn Marino * @addr: P2P peer entry to be unauthorized 11633ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 11643ff40c12SJohn Marino * 11653ff40c12SJohn Marino * This command removes any connection authorization from the specified P2P 11663ff40c12SJohn Marino * peer device address. This can be used, e.g., to cancel effect of a previous 11673ff40c12SJohn Marino * p2p_authorize() or p2p_connect() call that has not yet resulted in completed 11683ff40c12SJohn Marino * GO Negotiation. 11693ff40c12SJohn Marino */ 11703ff40c12SJohn Marino int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr); 11713ff40c12SJohn Marino 11723ff40c12SJohn Marino /** 11733ff40c12SJohn Marino * p2p_set_dev_name - Set device name 11743ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 11753ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 11763ff40c12SJohn Marino * 11773ff40c12SJohn Marino * This function can be used to update the P2P module configuration with 11783ff40c12SJohn Marino * information that was not available at the time of the p2p_init() call. 11793ff40c12SJohn Marino */ 11803ff40c12SJohn Marino int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name); 11813ff40c12SJohn Marino 11823ff40c12SJohn Marino int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer); 11833ff40c12SJohn Marino int p2p_set_model_name(struct p2p_data *p2p, const char *model_name); 11843ff40c12SJohn Marino int p2p_set_model_number(struct p2p_data *p2p, const char *model_number); 11853ff40c12SJohn Marino int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number); 11863ff40c12SJohn Marino 11873ff40c12SJohn Marino void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods); 11883ff40c12SJohn Marino void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid); 11893ff40c12SJohn Marino 11903ff40c12SJohn Marino /** 11913ff40c12SJohn Marino * p2p_set_pri_dev_type - Set primary device type 11923ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 11933ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 11943ff40c12SJohn Marino * 11953ff40c12SJohn Marino * This function can be used to update the P2P module configuration with 11963ff40c12SJohn Marino * information that was not available at the time of the p2p_init() call. 11973ff40c12SJohn Marino */ 11983ff40c12SJohn Marino int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type); 11993ff40c12SJohn Marino 12003ff40c12SJohn Marino /** 12013ff40c12SJohn Marino * p2p_set_sec_dev_types - Set secondary device types 12023ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12033ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 12043ff40c12SJohn Marino * 12053ff40c12SJohn Marino * This function can be used to update the P2P module configuration with 12063ff40c12SJohn Marino * information that was not available at the time of the p2p_init() call. 12073ff40c12SJohn Marino */ 12083ff40c12SJohn Marino int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8], 12093ff40c12SJohn Marino size_t num_dev_types); 12103ff40c12SJohn Marino 12113ff40c12SJohn Marino int p2p_set_country(struct p2p_data *p2p, const char *country); 12123ff40c12SJohn Marino 12133ff40c12SJohn Marino 12143ff40c12SJohn Marino /* Commands from upper layer management entity */ 12153ff40c12SJohn Marino 12163ff40c12SJohn Marino enum p2p_discovery_type { 12173ff40c12SJohn Marino P2P_FIND_START_WITH_FULL, 12183ff40c12SJohn Marino P2P_FIND_ONLY_SOCIAL, 12193ff40c12SJohn Marino P2P_FIND_PROGRESSIVE 12203ff40c12SJohn Marino }; 12213ff40c12SJohn Marino 12223ff40c12SJohn Marino /** 12233ff40c12SJohn Marino * p2p_find - Start P2P Find (Device Discovery) 12243ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12253ff40c12SJohn Marino * @timeout: Timeout for find operation in seconds or 0 for no timeout 12263ff40c12SJohn Marino * @type: Device Discovery type 12273ff40c12SJohn Marino * @num_req_dev_types: Number of requested device types 12283ff40c12SJohn Marino * @req_dev_types: Requested device types array, must be an array 12293ff40c12SJohn Marino * containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no 12303ff40c12SJohn Marino * requested device types. 12313ff40c12SJohn Marino * @dev_id: Device ID to search for or %NULL to find all devices 12323ff40c12SJohn Marino * @search_delay: Extra delay in milliseconds between search iterations 1233*a1157835SDaniel Fojt * @seek_count: Number of ASP Service Strings in the seek_string array 1234*a1157835SDaniel Fojt * @seek_string: ASP Service Strings to query for in Probe Requests 1235*a1157835SDaniel Fojt * @freq: Requested first scan frequency (in MHz) to modify type == 1236*a1157835SDaniel Fojt * P2P_FIND_START_WITH_FULL behavior. 0 = Use normal full scan. 1237*a1157835SDaniel Fojt * If p2p_find is already in progress, this parameter is ignored and full 1238*a1157835SDaniel Fojt * scan will be executed. 12393ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 12403ff40c12SJohn Marino */ 12413ff40c12SJohn Marino int p2p_find(struct p2p_data *p2p, unsigned int timeout, 12423ff40c12SJohn Marino enum p2p_discovery_type type, 12433ff40c12SJohn Marino unsigned int num_req_dev_types, const u8 *req_dev_types, 1244*a1157835SDaniel Fojt const u8 *dev_id, unsigned int search_delay, 1245*a1157835SDaniel Fojt u8 seek_count, const char **seek_string, int freq); 1246*a1157835SDaniel Fojt 1247*a1157835SDaniel Fojt /** 1248*a1157835SDaniel Fojt * p2p_notify_scan_trigger_status - Indicate scan trigger status 1249*a1157835SDaniel Fojt * @p2p: P2P module context from p2p_init() 1250*a1157835SDaniel Fojt * @status: 0 on success, -1 on failure 1251*a1157835SDaniel Fojt */ 1252*a1157835SDaniel Fojt void p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status); 12533ff40c12SJohn Marino 12543ff40c12SJohn Marino /** 12553ff40c12SJohn Marino * p2p_stop_find - Stop P2P Find (Device Discovery) 12563ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12573ff40c12SJohn Marino */ 12583ff40c12SJohn Marino void p2p_stop_find(struct p2p_data *p2p); 12593ff40c12SJohn Marino 12603ff40c12SJohn Marino /** 12613ff40c12SJohn Marino * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq 12623ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12633ff40c12SJohn Marino * @freq: Frequency in MHz for next operation 12643ff40c12SJohn Marino * 12653ff40c12SJohn Marino * This is like p2p_stop_find(), but Listen state is not stopped if we are 12663ff40c12SJohn Marino * already on the same frequency. 12673ff40c12SJohn Marino */ 12683ff40c12SJohn Marino void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq); 12693ff40c12SJohn Marino 12703ff40c12SJohn Marino /** 12713ff40c12SJohn Marino * p2p_listen - Start P2P Listen state for specified duration 12723ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12733ff40c12SJohn Marino * @timeout: Listen state duration in milliseconds 12743ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 12753ff40c12SJohn Marino * 12763ff40c12SJohn Marino * This function can be used to request the P2P module to keep the device 12773ff40c12SJohn Marino * discoverable on the listen channel for an extended set of time. At least in 12783ff40c12SJohn Marino * its current form, this is mainly used for testing purposes and may not be of 12793ff40c12SJohn Marino * much use for normal P2P operations. 12803ff40c12SJohn Marino */ 12813ff40c12SJohn Marino int p2p_listen(struct p2p_data *p2p, unsigned int timeout); 12823ff40c12SJohn Marino 12833ff40c12SJohn Marino /** 12843ff40c12SJohn Marino * p2p_stop_listen - Stop P2P Listen 12853ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12863ff40c12SJohn Marino */ 12873ff40c12SJohn Marino void p2p_stop_listen(struct p2p_data *p2p); 12883ff40c12SJohn Marino 12893ff40c12SJohn Marino /** 12903ff40c12SJohn Marino * p2p_connect - Start P2P group formation (GO negotiation) 12913ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 12923ff40c12SJohn Marino * @peer_addr: MAC address of the peer P2P client 12933ff40c12SJohn Marino * @wps_method: WPS method to be used in provisioning 12943ff40c12SJohn Marino * @go_intent: Local GO intent value (1..15) 12953ff40c12SJohn Marino * @own_interface_addr: Intended interface address to use with the group 12963ff40c12SJohn Marino * @force_freq: The only allowed channel frequency in MHz or 0 12973ff40c12SJohn Marino * @persistent_group: Whether to create a persistent group (0 = no, 1 = 12983ff40c12SJohn Marino * persistent group without persistent reconnect, 2 = persistent group with 12993ff40c12SJohn Marino * persistent reconnect) 13003ff40c12SJohn Marino * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate 13013ff40c12SJohn Marino * a new SSID 13023ff40c12SJohn Marino * @force_ssid_len: Length of $force_ssid buffer 13033ff40c12SJohn Marino * @pd_before_go_neg: Whether to send Provision Discovery prior to GO 13043ff40c12SJohn Marino * Negotiation as an interoperability workaround when initiating group 13053ff40c12SJohn Marino * formation 13063ff40c12SJohn Marino * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 13073ff40c12SJohn Marino * force_freq == 0) 13083ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 13093ff40c12SJohn Marino */ 13103ff40c12SJohn Marino int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr, 13113ff40c12SJohn Marino enum p2p_wps_method wps_method, 13123ff40c12SJohn Marino int go_intent, const u8 *own_interface_addr, 13133ff40c12SJohn Marino unsigned int force_freq, int persistent_group, 13143ff40c12SJohn Marino const u8 *force_ssid, size_t force_ssid_len, 13153ff40c12SJohn Marino int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id); 13163ff40c12SJohn Marino 13173ff40c12SJohn Marino /** 13183ff40c12SJohn Marino * p2p_authorize - Authorize P2P group formation (GO negotiation) 13193ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 13203ff40c12SJohn Marino * @peer_addr: MAC address of the peer P2P client 13213ff40c12SJohn Marino * @wps_method: WPS method to be used in provisioning 13223ff40c12SJohn Marino * @go_intent: Local GO intent value (1..15) 13233ff40c12SJohn Marino * @own_interface_addr: Intended interface address to use with the group 13243ff40c12SJohn Marino * @force_freq: The only allowed channel frequency in MHz or 0 13253ff40c12SJohn Marino * @persistent_group: Whether to create a persistent group (0 = no, 1 = 13263ff40c12SJohn Marino * persistent group without persistent reconnect, 2 = persistent group with 13273ff40c12SJohn Marino * persistent reconnect) 13283ff40c12SJohn Marino * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate 13293ff40c12SJohn Marino * a new SSID 13303ff40c12SJohn Marino * @force_ssid_len: Length of $force_ssid buffer 13313ff40c12SJohn Marino * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 13323ff40c12SJohn Marino * force_freq == 0) 13333ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 13343ff40c12SJohn Marino * 13353ff40c12SJohn Marino * This is like p2p_connect(), but the actual group negotiation is not 13363ff40c12SJohn Marino * initiated automatically, i.e., the other end is expected to do that. 13373ff40c12SJohn Marino */ 13383ff40c12SJohn Marino int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr, 13393ff40c12SJohn Marino enum p2p_wps_method wps_method, 13403ff40c12SJohn Marino int go_intent, const u8 *own_interface_addr, 13413ff40c12SJohn Marino unsigned int force_freq, int persistent_group, 13423ff40c12SJohn Marino const u8 *force_ssid, size_t force_ssid_len, 13433ff40c12SJohn Marino unsigned int pref_freq, u16 oob_pw_id); 13443ff40c12SJohn Marino 13453ff40c12SJohn Marino /** 13463ff40c12SJohn Marino * p2p_reject - Reject peer device (explicitly block connection attempts) 13473ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 13483ff40c12SJohn Marino * @peer_addr: MAC address of the peer P2P client 13493ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 13503ff40c12SJohn Marino */ 13513ff40c12SJohn Marino int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr); 13523ff40c12SJohn Marino 13533ff40c12SJohn Marino /** 13543ff40c12SJohn Marino * p2p_prov_disc_req - Send Provision Discovery Request 13553ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 13563ff40c12SJohn Marino * @peer_addr: MAC address of the peer P2P client 1357*a1157835SDaniel Fojt * @p2ps_prov: Provisioning info for P2PS 13583ff40c12SJohn Marino * @config_methods: WPS Config Methods value (only one bit set) 13593ff40c12SJohn Marino * @join: Whether this is used by a client joining an active group 13603ff40c12SJohn Marino * @force_freq: Forced TX frequency for the frame (mainly for the join case) 13613ff40c12SJohn Marino * @user_initiated_pd: Flag to indicate if initiated by user or not 13623ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 13633ff40c12SJohn Marino * 13643ff40c12SJohn Marino * This function can be used to request a discovered P2P peer to display a PIN 13653ff40c12SJohn Marino * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us 13663ff40c12SJohn Marino * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame 13673ff40c12SJohn Marino * is transmitted once immediately and if no response is received, the frame 13683ff40c12SJohn Marino * will be sent again whenever the target device is discovered during device 13693ff40c12SJohn Marino * dsicovery (start with a p2p_find() call). Response from the peer is 13703ff40c12SJohn Marino * indicated with the p2p_config::prov_disc_resp() callback. 13713ff40c12SJohn Marino */ 13723ff40c12SJohn Marino int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, 1373*a1157835SDaniel Fojt struct p2ps_provision *p2ps_prov, u16 config_methods, 1374*a1157835SDaniel Fojt int join, int force_freq, 13753ff40c12SJohn Marino int user_initiated_pd); 13763ff40c12SJohn Marino 13773ff40c12SJohn Marino /** 13783ff40c12SJohn Marino * p2p_sd_request - Schedule a service discovery query 13793ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 13803ff40c12SJohn Marino * @dst: Destination peer or %NULL to apply for all peers 13813ff40c12SJohn Marino * @tlvs: P2P Service Query TLV(s) 13823ff40c12SJohn Marino * Returns: Reference to the query or %NULL on failure 13833ff40c12SJohn Marino * 13843ff40c12SJohn Marino * Response to the query is indicated with the p2p_config::sd_response() 13853ff40c12SJohn Marino * callback. 13863ff40c12SJohn Marino */ 13873ff40c12SJohn Marino void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst, 13883ff40c12SJohn Marino const struct wpabuf *tlvs); 13893ff40c12SJohn Marino 13903ff40c12SJohn Marino #ifdef CONFIG_WIFI_DISPLAY 13913ff40c12SJohn Marino void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst, 13923ff40c12SJohn Marino const struct wpabuf *tlvs); 13933ff40c12SJohn Marino #endif /* CONFIG_WIFI_DISPLAY */ 13943ff40c12SJohn Marino 13953ff40c12SJohn Marino /** 13963ff40c12SJohn Marino * p2p_sd_cancel_request - Cancel a pending service discovery query 13973ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 13983ff40c12SJohn Marino * @req: Query reference from p2p_sd_request() 13993ff40c12SJohn Marino * Returns: 0 if request for cancelled; -1 if not found 14003ff40c12SJohn Marino */ 14013ff40c12SJohn Marino int p2p_sd_cancel_request(struct p2p_data *p2p, void *req); 14023ff40c12SJohn Marino 14033ff40c12SJohn Marino /** 14043ff40c12SJohn Marino * p2p_sd_response - Send response to a service discovery query 14053ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 14063ff40c12SJohn Marino * @freq: Frequency from p2p_config::sd_request() callback 14073ff40c12SJohn Marino * @dst: Destination address from p2p_config::sd_request() callback 14083ff40c12SJohn Marino * @dialog_token: Dialog token from p2p_config::sd_request() callback 14093ff40c12SJohn Marino * @resp_tlvs: P2P Service Response TLV(s) 14103ff40c12SJohn Marino * 14113ff40c12SJohn Marino * This function is called as a response to the request indicated with 14123ff40c12SJohn Marino * p2p_config::sd_request() callback. 14133ff40c12SJohn Marino */ 14143ff40c12SJohn Marino void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst, 14153ff40c12SJohn Marino u8 dialog_token, const struct wpabuf *resp_tlvs); 14163ff40c12SJohn Marino 14173ff40c12SJohn Marino /** 14183ff40c12SJohn Marino * p2p_sd_service_update - Indicate a change in local services 14193ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 14203ff40c12SJohn Marino * 14213ff40c12SJohn Marino * This function needs to be called whenever there is a change in availability 14223ff40c12SJohn Marino * of the local services. This will increment the Service Update Indicator 14233ff40c12SJohn Marino * value which will be used in SD Request and Response frames. 14243ff40c12SJohn Marino */ 14253ff40c12SJohn Marino void p2p_sd_service_update(struct p2p_data *p2p); 14263ff40c12SJohn Marino 14273ff40c12SJohn Marino 14283ff40c12SJohn Marino enum p2p_invite_role { 14293ff40c12SJohn Marino P2P_INVITE_ROLE_GO, 14303ff40c12SJohn Marino P2P_INVITE_ROLE_ACTIVE_GO, 14313ff40c12SJohn Marino P2P_INVITE_ROLE_CLIENT 14323ff40c12SJohn Marino }; 14333ff40c12SJohn Marino 14343ff40c12SJohn Marino /** 14353ff40c12SJohn Marino * p2p_invite - Invite a P2P Device into a group 14363ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 14373ff40c12SJohn Marino * @peer: Device Address of the peer P2P Device 14383ff40c12SJohn Marino * @role: Local role in the group 14393ff40c12SJohn Marino * @bssid: Group BSSID or %NULL if not known 14403ff40c12SJohn Marino * @ssid: Group SSID 14413ff40c12SJohn Marino * @ssid_len: Length of ssid in octets 14423ff40c12SJohn Marino * @force_freq: The only allowed channel frequency in MHz or 0 14433ff40c12SJohn Marino * @go_dev_addr: Forced GO Device Address or %NULL if none 14443ff40c12SJohn Marino * @persistent_group: Whether this is to reinvoke a persistent group 14453ff40c12SJohn Marino * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if 14463ff40c12SJohn Marino * force_freq == 0) 14473ff40c12SJohn Marino * @dev_pw_id: Device Password ID from OOB Device Password (NFC) static handover 14483ff40c12SJohn Marino * case or -1 if not used 14493ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 14503ff40c12SJohn Marino */ 14513ff40c12SJohn Marino int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role, 14523ff40c12SJohn Marino const u8 *bssid, const u8 *ssid, size_t ssid_len, 14533ff40c12SJohn Marino unsigned int force_freq, const u8 *go_dev_addr, 14543ff40c12SJohn Marino int persistent_group, unsigned int pref_freq, int dev_pw_id); 14553ff40c12SJohn Marino 14563ff40c12SJohn Marino /** 14573ff40c12SJohn Marino * p2p_presence_req - Request GO presence 14583ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 14593ff40c12SJohn Marino * @go_interface_addr: GO P2P Interface Address 14603ff40c12SJohn Marino * @own_interface_addr: Own P2P Interface Address for this group 14613ff40c12SJohn Marino * @freq: Group operating frequence (in MHz) 14623ff40c12SJohn Marino * @duration1: Preferred presence duration in microseconds 14633ff40c12SJohn Marino * @interval1: Preferred presence interval in microseconds 14643ff40c12SJohn Marino * @duration2: Acceptable presence duration in microseconds 14653ff40c12SJohn Marino * @interval2: Acceptable presence interval in microseconds 14663ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 14673ff40c12SJohn Marino * 14683ff40c12SJohn Marino * If both duration and interval values are zero, the parameter pair is not 14693ff40c12SJohn Marino * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0). 14703ff40c12SJohn Marino */ 14713ff40c12SJohn Marino int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr, 14723ff40c12SJohn Marino const u8 *own_interface_addr, unsigned int freq, 14733ff40c12SJohn Marino u32 duration1, u32 interval1, u32 duration2, 14743ff40c12SJohn Marino u32 interval2); 14753ff40c12SJohn Marino 14763ff40c12SJohn Marino /** 14773ff40c12SJohn Marino * p2p_ext_listen - Set Extended Listen Timing 14783ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 14793ff40c12SJohn Marino * @freq: Group operating frequence (in MHz) 14803ff40c12SJohn Marino * @period: Availability period in milliseconds (1-65535; 0 to disable) 14813ff40c12SJohn Marino * @interval: Availability interval in milliseconds (1-65535; 0 to disable) 14823ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 14833ff40c12SJohn Marino * 14843ff40c12SJohn Marino * This function can be used to enable or disable (period = interval = 0) 14853ff40c12SJohn Marino * Extended Listen Timing. When enabled, the P2P Device will become 14863ff40c12SJohn Marino * discoverable (go into Listen State) every @interval milliseconds for at 14873ff40c12SJohn Marino * least @period milliseconds. 14883ff40c12SJohn Marino */ 14893ff40c12SJohn Marino int p2p_ext_listen(struct p2p_data *p2p, unsigned int period, 14903ff40c12SJohn Marino unsigned int interval); 14913ff40c12SJohn Marino 14923ff40c12SJohn Marino /* Event notifications from upper layer management operations */ 14933ff40c12SJohn Marino 14943ff40c12SJohn Marino /** 14953ff40c12SJohn Marino * p2p_wps_success_cb - Report successfully completed WPS provisioning 14963ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 14973ff40c12SJohn Marino * @mac_addr: Peer address 14983ff40c12SJohn Marino * 14993ff40c12SJohn Marino * This function is used to report successfully completed WPS provisioning 15003ff40c12SJohn Marino * during group formation in both GO/Registrar and client/Enrollee roles. 15013ff40c12SJohn Marino */ 15023ff40c12SJohn Marino void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr); 15033ff40c12SJohn Marino 15043ff40c12SJohn Marino /** 15053ff40c12SJohn Marino * p2p_group_formation_failed - Report failed WPS provisioning 15063ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 15073ff40c12SJohn Marino * 15083ff40c12SJohn Marino * This function is used to report failed group formation. This can happen 15093ff40c12SJohn Marino * either due to failed WPS provisioning or due to 15 second timeout during 15103ff40c12SJohn Marino * the provisioning phase. 15113ff40c12SJohn Marino */ 15123ff40c12SJohn Marino void p2p_group_formation_failed(struct p2p_data *p2p); 15133ff40c12SJohn Marino 15143ff40c12SJohn Marino /** 15153ff40c12SJohn Marino * p2p_get_provisioning_info - Get any stored provisioning info 15163ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 15173ff40c12SJohn Marino * @addr: Peer P2P Device Address 15183ff40c12SJohn Marino * Returns: WPS provisioning information (WPS config method) or 0 if no 15193ff40c12SJohn Marino * information is available 15203ff40c12SJohn Marino * 15213ff40c12SJohn Marino * This function is used to retrieve stored WPS provisioning info for the given 15223ff40c12SJohn Marino * peer. 15233ff40c12SJohn Marino */ 15243ff40c12SJohn Marino u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr); 15253ff40c12SJohn Marino 15263ff40c12SJohn Marino /** 15273ff40c12SJohn Marino * p2p_clear_provisioning_info - Clear any stored provisioning info 15283ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 15293ff40c12SJohn Marino * @iface_addr: Peer P2P Device Address 15303ff40c12SJohn Marino * 15313ff40c12SJohn Marino * This function is used to clear stored WPS provisioning info for the given 15323ff40c12SJohn Marino * peer. 15333ff40c12SJohn Marino */ 15343ff40c12SJohn Marino void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr); 15353ff40c12SJohn Marino 15363ff40c12SJohn Marino 15373ff40c12SJohn Marino /* Event notifications from lower layer driver operations */ 15383ff40c12SJohn Marino 15393ff40c12SJohn Marino /** 15403ff40c12SJohn Marino * enum p2p_probe_req_status 15413ff40c12SJohn Marino * 15423ff40c12SJohn Marino * @P2P_PREQ_MALFORMED: frame was not well-formed 15433ff40c12SJohn Marino * @P2P_PREQ_NOT_LISTEN: device isn't in listen state, frame ignored 15443ff40c12SJohn Marino * @P2P_PREQ_NOT_P2P: frame was not a P2P probe request 15453ff40c12SJohn Marino * @P2P_PREQ_P2P_NOT_PROCESSED: frame was P2P but wasn't processed 15463ff40c12SJohn Marino * @P2P_PREQ_P2P_PROCESSED: frame has been processed by P2P 15473ff40c12SJohn Marino */ 15483ff40c12SJohn Marino enum p2p_probe_req_status { 15493ff40c12SJohn Marino P2P_PREQ_MALFORMED, 15503ff40c12SJohn Marino P2P_PREQ_NOT_LISTEN, 15513ff40c12SJohn Marino P2P_PREQ_NOT_P2P, 15523ff40c12SJohn Marino P2P_PREQ_NOT_PROCESSED, 15533ff40c12SJohn Marino P2P_PREQ_PROCESSED 15543ff40c12SJohn Marino }; 15553ff40c12SJohn Marino 15563ff40c12SJohn Marino /** 15573ff40c12SJohn Marino * p2p_probe_req_rx - Report reception of a Probe Request frame 15583ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 15593ff40c12SJohn Marino * @addr: Source MAC address 15603ff40c12SJohn Marino * @dst: Destination MAC address if available or %NULL 15613ff40c12SJohn Marino * @bssid: BSSID if available or %NULL 15623ff40c12SJohn Marino * @ie: Information elements from the Probe Request frame body 15633ff40c12SJohn Marino * @ie_len: Length of ie buffer in octets 1564*a1157835SDaniel Fojt * @rx_freq: Probe Request frame RX frequency 1565*a1157835SDaniel Fojt * @p2p_lo_started: Whether P2P Listen Offload is started 15663ff40c12SJohn Marino * Returns: value indicating the type and status of the probe request 15673ff40c12SJohn Marino */ 15683ff40c12SJohn Marino enum p2p_probe_req_status 15693ff40c12SJohn Marino p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, 1570*a1157835SDaniel Fojt const u8 *bssid, const u8 *ie, size_t ie_len, 1571*a1157835SDaniel Fojt unsigned int rx_freq, int p2p_lo_started); 15723ff40c12SJohn Marino 15733ff40c12SJohn Marino /** 15743ff40c12SJohn Marino * p2p_rx_action - Report received Action frame 15753ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 15763ff40c12SJohn Marino * @da: Destination address of the received Action frame 15773ff40c12SJohn Marino * @sa: Source address of the received Action frame 15783ff40c12SJohn Marino * @bssid: Address 3 of the received Action frame 15793ff40c12SJohn Marino * @category: Category of the received Action frame 15803ff40c12SJohn Marino * @data: Action frame body after the Category field 15813ff40c12SJohn Marino * @len: Length of the data buffer in octets 15823ff40c12SJohn Marino * @freq: Frequency (in MHz) on which the frame was received 15833ff40c12SJohn Marino */ 15843ff40c12SJohn Marino void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa, 15853ff40c12SJohn Marino const u8 *bssid, u8 category, 15863ff40c12SJohn Marino const u8 *data, size_t len, int freq); 15873ff40c12SJohn Marino 15883ff40c12SJohn Marino /** 15893ff40c12SJohn Marino * p2p_scan_res_handler - Indicate a P2P scan results 15903ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 15913ff40c12SJohn Marino * @bssid: BSSID of the scan result 15923ff40c12SJohn Marino * @freq: Frequency of the channel on which the device was found in MHz 15933ff40c12SJohn Marino * @rx_time: Time when the result was received 15943ff40c12SJohn Marino * @level: Signal level (signal strength of the received Beacon/Probe Response 15953ff40c12SJohn Marino * frame) 15963ff40c12SJohn Marino * @ies: Pointer to IEs from the scan result 15973ff40c12SJohn Marino * @ies_len: Length of the ies buffer 15983ff40c12SJohn Marino * Returns: 0 to continue or 1 to stop scan result indication 15993ff40c12SJohn Marino * 16003ff40c12SJohn Marino * This function is called to indicate a scan result entry with P2P IE from a 16013ff40c12SJohn Marino * scan requested with struct p2p_config::p2p_scan(). This can be called during 16023ff40c12SJohn Marino * the actual scan process (i.e., whenever a new device is found) or as a 16033ff40c12SJohn Marino * sequence of calls after the full scan has been completed. The former option 16043ff40c12SJohn Marino * can result in optimized operations, but may not be supported by all 16053ff40c12SJohn Marino * driver/firmware designs. The ies buffer need to include at least the P2P IE, 16063ff40c12SJohn Marino * but it is recommended to include all IEs received from the device. The 16073ff40c12SJohn Marino * caller does not need to check that the IEs contain a P2P IE before calling 16083ff40c12SJohn Marino * this function since frames will be filtered internally if needed. 16093ff40c12SJohn Marino * 16103ff40c12SJohn Marino * This function will return 1 if it wants to stop scan result iteration (and 16113ff40c12SJohn Marino * scan in general if it is still in progress). This is used to allow faster 16123ff40c12SJohn Marino * start of a pending operation, e.g., to start a pending GO negotiation. 16133ff40c12SJohn Marino */ 16143ff40c12SJohn Marino int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, 16153ff40c12SJohn Marino struct os_reltime *rx_time, int level, const u8 *ies, 16163ff40c12SJohn Marino size_t ies_len); 16173ff40c12SJohn Marino 16183ff40c12SJohn Marino /** 16193ff40c12SJohn Marino * p2p_scan_res_handled - Indicate end of scan results 16203ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 16213ff40c12SJohn Marino * 16223ff40c12SJohn Marino * This function is called to indicate that all P2P scan results from a scan 16233ff40c12SJohn Marino * have been reported with zero or more calls to p2p_scan_res_handler(). This 16243ff40c12SJohn Marino * function must be called as a response to successful 16253ff40c12SJohn Marino * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler() 16263ff40c12SJohn Marino * calls stopped iteration. 16273ff40c12SJohn Marino */ 16283ff40c12SJohn Marino void p2p_scan_res_handled(struct p2p_data *p2p); 16293ff40c12SJohn Marino 16303ff40c12SJohn Marino enum p2p_send_action_result { 16313ff40c12SJohn Marino P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */, 16323ff40c12SJohn Marino P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */, 16333ff40c12SJohn Marino P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */ 16343ff40c12SJohn Marino }; 16353ff40c12SJohn Marino 16363ff40c12SJohn Marino /** 16373ff40c12SJohn Marino * p2p_send_action_cb - Notify TX status of an Action frame 16383ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 16393ff40c12SJohn Marino * @freq: Channel frequency in MHz 16403ff40c12SJohn Marino * @dst: Destination MAC address (Address 1) 16413ff40c12SJohn Marino * @src: Source MAC address (Address 2) 16423ff40c12SJohn Marino * @bssid: BSSID (Address 3) 16433ff40c12SJohn Marino * @result: Result of the transmission attempt 16443ff40c12SJohn Marino * 16453ff40c12SJohn Marino * This function is used to indicate the result of an Action frame transmission 16463ff40c12SJohn Marino * that was requested with struct p2p_config::send_action() callback. 16473ff40c12SJohn Marino */ 16483ff40c12SJohn Marino void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, 16493ff40c12SJohn Marino const u8 *src, const u8 *bssid, 16503ff40c12SJohn Marino enum p2p_send_action_result result); 16513ff40c12SJohn Marino 16523ff40c12SJohn Marino /** 16533ff40c12SJohn Marino * p2p_listen_cb - Indicate the start of a requested Listen state 16543ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 16553ff40c12SJohn Marino * @freq: Listen channel frequency in MHz 16563ff40c12SJohn Marino * @duration: Duration for the Listen state in milliseconds 16573ff40c12SJohn Marino * 16583ff40c12SJohn Marino * This function is used to indicate that a Listen state requested with 16593ff40c12SJohn Marino * struct p2p_config::start_listen() callback has started. 16603ff40c12SJohn Marino */ 16613ff40c12SJohn Marino void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq, 16623ff40c12SJohn Marino unsigned int duration); 16633ff40c12SJohn Marino 16643ff40c12SJohn Marino /** 16653ff40c12SJohn Marino * p2p_listen_end - Indicate the end of a requested Listen state 16663ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 16673ff40c12SJohn Marino * @freq: Listen channel frequency in MHz 16683ff40c12SJohn Marino * Returns: 0 if no operations were started, 1 if an operation was started 16693ff40c12SJohn Marino * 16703ff40c12SJohn Marino * This function is used to indicate that a Listen state requested with 16713ff40c12SJohn Marino * struct p2p_config::start_listen() callback has ended. 16723ff40c12SJohn Marino */ 16733ff40c12SJohn Marino int p2p_listen_end(struct p2p_data *p2p, unsigned int freq); 16743ff40c12SJohn Marino 16753ff40c12SJohn Marino void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, 16763ff40c12SJohn Marino const u8 *ie, size_t ie_len); 16773ff40c12SJohn Marino 16783ff40c12SJohn Marino void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, 16793ff40c12SJohn Marino const u8 *ie, size_t ie_len); 16803ff40c12SJohn Marino 16813ff40c12SJohn Marino 16823ff40c12SJohn Marino /* Per-group P2P state for GO */ 16833ff40c12SJohn Marino 16843ff40c12SJohn Marino struct p2p_group; 16853ff40c12SJohn Marino 16863ff40c12SJohn Marino /** 16873ff40c12SJohn Marino * struct p2p_group_config - P2P group configuration 16883ff40c12SJohn Marino * 16893ff40c12SJohn Marino * This configuration is provided to the P2P module during initialization of 16903ff40c12SJohn Marino * the per-group information with p2p_group_init(). 16913ff40c12SJohn Marino */ 16923ff40c12SJohn Marino struct p2p_group_config { 16933ff40c12SJohn Marino /** 16943ff40c12SJohn Marino * persistent_group - Whether the group is persistent 16953ff40c12SJohn Marino * 0 = not a persistent group 16963ff40c12SJohn Marino * 1 = persistent group without persistent reconnect 16973ff40c12SJohn Marino * 2 = persistent group with persistent reconnect 16983ff40c12SJohn Marino */ 16993ff40c12SJohn Marino int persistent_group; 17003ff40c12SJohn Marino 17013ff40c12SJohn Marino /** 17023ff40c12SJohn Marino * interface_addr - P2P Interface Address of the group 17033ff40c12SJohn Marino */ 17043ff40c12SJohn Marino u8 interface_addr[ETH_ALEN]; 17053ff40c12SJohn Marino 17063ff40c12SJohn Marino /** 17073ff40c12SJohn Marino * max_clients - Maximum number of clients in the group 17083ff40c12SJohn Marino */ 17093ff40c12SJohn Marino unsigned int max_clients; 17103ff40c12SJohn Marino 17113ff40c12SJohn Marino /** 17123ff40c12SJohn Marino * ssid - Group SSID 17133ff40c12SJohn Marino */ 1714*a1157835SDaniel Fojt u8 ssid[SSID_MAX_LEN]; 17153ff40c12SJohn Marino 17163ff40c12SJohn Marino /** 17173ff40c12SJohn Marino * ssid_len - Length of SSID 17183ff40c12SJohn Marino */ 17193ff40c12SJohn Marino size_t ssid_len; 17203ff40c12SJohn Marino 17213ff40c12SJohn Marino /** 17223ff40c12SJohn Marino * freq - Operating channel of the group 17233ff40c12SJohn Marino */ 17243ff40c12SJohn Marino int freq; 17253ff40c12SJohn Marino 17263ff40c12SJohn Marino /** 1727*a1157835SDaniel Fojt * ip_addr_alloc - Whether IP address allocation within 4-way handshake 1728*a1157835SDaniel Fojt * is supported 1729*a1157835SDaniel Fojt */ 1730*a1157835SDaniel Fojt int ip_addr_alloc; 1731*a1157835SDaniel Fojt 1732*a1157835SDaniel Fojt /** 17333ff40c12SJohn Marino * cb_ctx - Context to use with callback functions 17343ff40c12SJohn Marino */ 17353ff40c12SJohn Marino void *cb_ctx; 17363ff40c12SJohn Marino 17373ff40c12SJohn Marino /** 17383ff40c12SJohn Marino * ie_update - Notification of IE update 17393ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 17403ff40c12SJohn Marino * @beacon_ies: P2P IE for Beacon frames or %NULL if no change 17413ff40c12SJohn Marino * @proberesp_ies: P2P Ie for Probe Response frames 17423ff40c12SJohn Marino * 17433ff40c12SJohn Marino * P2P module uses this callback function to notify whenever the P2P IE 17443ff40c12SJohn Marino * in Beacon or Probe Response frames should be updated based on group 17453ff40c12SJohn Marino * events. 17463ff40c12SJohn Marino * 17473ff40c12SJohn Marino * The callee is responsible for freeing the returned buffer(s) with 17483ff40c12SJohn Marino * wpabuf_free(). 17493ff40c12SJohn Marino */ 17503ff40c12SJohn Marino void (*ie_update)(void *ctx, struct wpabuf *beacon_ies, 17513ff40c12SJohn Marino struct wpabuf *proberesp_ies); 17523ff40c12SJohn Marino 17533ff40c12SJohn Marino /** 17543ff40c12SJohn Marino * idle_update - Notification of changes in group idle state 17553ff40c12SJohn Marino * @ctx: Callback context from cb_ctx 17563ff40c12SJohn Marino * @idle: Whether the group is idle (no associated stations) 17573ff40c12SJohn Marino */ 17583ff40c12SJohn Marino void (*idle_update)(void *ctx, int idle); 17593ff40c12SJohn Marino }; 17603ff40c12SJohn Marino 17613ff40c12SJohn Marino /** 17623ff40c12SJohn Marino * p2p_group_init - Initialize P2P group 17633ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 17643ff40c12SJohn Marino * @config: P2P group configuration (will be freed by p2p_group_deinit()) 17653ff40c12SJohn Marino * Returns: Pointer to private data or %NULL on failure 17663ff40c12SJohn Marino * 17673ff40c12SJohn Marino * This function is used to initialize per-group P2P module context. Currently, 17683ff40c12SJohn Marino * this is only used to manage GO functionality and P2P clients do not need to 17693ff40c12SJohn Marino * create an instance of this per-group information. 17703ff40c12SJohn Marino */ 17713ff40c12SJohn Marino struct p2p_group * p2p_group_init(struct p2p_data *p2p, 17723ff40c12SJohn Marino struct p2p_group_config *config); 17733ff40c12SJohn Marino 17743ff40c12SJohn Marino /** 17753ff40c12SJohn Marino * p2p_group_deinit - Deinitialize P2P group 17763ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 17773ff40c12SJohn Marino */ 17783ff40c12SJohn Marino void p2p_group_deinit(struct p2p_group *group); 17793ff40c12SJohn Marino 17803ff40c12SJohn Marino /** 17813ff40c12SJohn Marino * p2p_group_notif_assoc - Notification of P2P client association with GO 17823ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 17833ff40c12SJohn Marino * @addr: Interface address of the P2P client 17843ff40c12SJohn Marino * @ie: IEs from the (Re)association Request frame 17853ff40c12SJohn Marino * @len: Length of the ie buffer in octets 17863ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 17873ff40c12SJohn Marino */ 17883ff40c12SJohn Marino int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr, 17893ff40c12SJohn Marino const u8 *ie, size_t len); 17903ff40c12SJohn Marino 17913ff40c12SJohn Marino /** 17923ff40c12SJohn Marino * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response 17933ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 17943ff40c12SJohn Marino * @status: Status value (P2P_SC_SUCCESS if association succeeded) 17953ff40c12SJohn Marino * Returns: P2P IE for (Re)association Response or %NULL on failure 17963ff40c12SJohn Marino * 17973ff40c12SJohn Marino * The caller is responsible for freeing the returned buffer with 17983ff40c12SJohn Marino * wpabuf_free(). 17993ff40c12SJohn Marino */ 18003ff40c12SJohn Marino struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status); 18013ff40c12SJohn Marino 18023ff40c12SJohn Marino /** 18033ff40c12SJohn Marino * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO 18043ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 18053ff40c12SJohn Marino * @addr: Interface address of the P2P client 18063ff40c12SJohn Marino */ 18073ff40c12SJohn Marino void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr); 18083ff40c12SJohn Marino 18093ff40c12SJohn Marino /** 18103ff40c12SJohn Marino * p2p_group_notif_formation_done - Notification of completed group formation 18113ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 18123ff40c12SJohn Marino */ 18133ff40c12SJohn Marino void p2p_group_notif_formation_done(struct p2p_group *group); 18143ff40c12SJohn Marino 18153ff40c12SJohn Marino /** 18163ff40c12SJohn Marino * p2p_group_notif_noa - Notification of NoA change 18173ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 18183ff40c12SJohn Marino * @noa: Notice of Absence attribute payload, %NULL if none 18193ff40c12SJohn Marino * @noa_len: Length of noa buffer in octets 18203ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 18213ff40c12SJohn Marino * 18223ff40c12SJohn Marino * Notify the P2P group management about a new NoA contents. This will be 18233ff40c12SJohn Marino * inserted into the P2P IEs in Beacon and Probe Response frames with rest of 18243ff40c12SJohn Marino * the group information. 18253ff40c12SJohn Marino */ 18263ff40c12SJohn Marino int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, 18273ff40c12SJohn Marino size_t noa_len); 18283ff40c12SJohn Marino 18293ff40c12SJohn Marino /** 18303ff40c12SJohn Marino * p2p_group_match_dev_type - Match device types in group with requested type 18313ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 18323ff40c12SJohn Marino * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs) 18333ff40c12SJohn Marino * Returns: 1 on match, 0 on mismatch 18343ff40c12SJohn Marino * 18353ff40c12SJohn Marino * This function can be used to match the Requested Device Type attribute in 18363ff40c12SJohn Marino * WPS IE with the device types of a group member for deciding whether a GO 18373ff40c12SJohn Marino * should reply to a Probe Request frame. Match will be reported if the WPS IE 18383ff40c12SJohn Marino * is not requested any specific device type. 18393ff40c12SJohn Marino */ 18403ff40c12SJohn Marino int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps); 18413ff40c12SJohn Marino 18423ff40c12SJohn Marino /** 18433ff40c12SJohn Marino * p2p_group_match_dev_id - Match P2P Device Address in group with requested device id 18443ff40c12SJohn Marino */ 18453ff40c12SJohn Marino int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p); 18463ff40c12SJohn Marino 18473ff40c12SJohn Marino /** 18483ff40c12SJohn Marino * p2p_group_go_discover - Send GO Discoverability Request to a group client 18493ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 18503ff40c12SJohn Marino * Returns: 0 on success (frame scheduled); -1 if client was not found 18513ff40c12SJohn Marino */ 18523ff40c12SJohn Marino int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id, 18533ff40c12SJohn Marino const u8 *searching_dev, int rx_freq); 18543ff40c12SJohn Marino 18553ff40c12SJohn Marino 18563ff40c12SJohn Marino /* Generic helper functions */ 18573ff40c12SJohn Marino 18583ff40c12SJohn Marino /** 18593ff40c12SJohn Marino * p2p_ie_text - Build text format description of P2P IE 18603ff40c12SJohn Marino * @p2p_ie: P2P IE 18613ff40c12SJohn Marino * @buf: Buffer for returning text 18623ff40c12SJohn Marino * @end: Pointer to the end of the buf area 18633ff40c12SJohn Marino * Returns: Number of octets written to the buffer or -1 on failure 18643ff40c12SJohn Marino * 18653ff40c12SJohn Marino * This function can be used to parse P2P IE contents into text format 18663ff40c12SJohn Marino * field=value lines. 18673ff40c12SJohn Marino */ 18683ff40c12SJohn Marino int p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end); 18693ff40c12SJohn Marino 18703ff40c12SJohn Marino /** 18713ff40c12SJohn Marino * p2p_scan_result_text - Build text format description of P2P IE 18723ff40c12SJohn Marino * @ies: Information elements from scan results 18733ff40c12SJohn Marino * @ies_len: ies buffer length in octets 18743ff40c12SJohn Marino * @buf: Buffer for returning text 18753ff40c12SJohn Marino * @end: Pointer to the end of the buf area 18763ff40c12SJohn Marino * Returns: Number of octets written to the buffer or -1 on failure 18773ff40c12SJohn Marino * 18783ff40c12SJohn Marino * This function can be used to parse P2P IE contents into text format 18793ff40c12SJohn Marino * field=value lines. 18803ff40c12SJohn Marino */ 18813ff40c12SJohn Marino int p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end); 18823ff40c12SJohn Marino 18833ff40c12SJohn Marino /** 18843ff40c12SJohn Marino * p2p_parse_dev_addr_in_p2p_ie - Parse P2P Device Address from a concatenated 18853ff40c12SJohn Marino * P2P IE 18863ff40c12SJohn Marino * @p2p_ie: P2P IE 18873ff40c12SJohn Marino * @dev_addr: Buffer for returning P2P Device Address 18883ff40c12SJohn Marino * Returns: 0 on success or -1 if P2P Device Address could not be parsed 18893ff40c12SJohn Marino */ 18903ff40c12SJohn Marino int p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr); 18913ff40c12SJohn Marino 18923ff40c12SJohn Marino /** 18933ff40c12SJohn Marino * p2p_parse_dev_addr - Parse P2P Device Address from P2P IE(s) 18943ff40c12SJohn Marino * @ies: Information elements from scan results 18953ff40c12SJohn Marino * @ies_len: ies buffer length in octets 18963ff40c12SJohn Marino * @dev_addr: Buffer for returning P2P Device Address 18973ff40c12SJohn Marino * Returns: 0 on success or -1 if P2P Device Address could not be parsed 18983ff40c12SJohn Marino */ 18993ff40c12SJohn Marino int p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr); 19003ff40c12SJohn Marino 19013ff40c12SJohn Marino /** 19023ff40c12SJohn Marino * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame 19033ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19043ff40c12SJohn Marino * @bssid: BSSID 19053ff40c12SJohn Marino * @buf: Buffer for writing the P2P IE 19063ff40c12SJohn Marino * @len: Maximum buf length in octets 19073ff40c12SJohn Marino * @p2p_group: Whether this is for association with a P2P GO 19083ff40c12SJohn Marino * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none 19093ff40c12SJohn Marino * Returns: Number of octets written into buf or -1 on failure 19103ff40c12SJohn Marino */ 19113ff40c12SJohn Marino int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf, 19123ff40c12SJohn Marino size_t len, int p2p_group, struct wpabuf *p2p_ie); 19133ff40c12SJohn Marino 19143ff40c12SJohn Marino /** 19153ff40c12SJohn Marino * p2p_scan_ie - Build P2P IE for Probe Request 19163ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19173ff40c12SJohn Marino * @ies: Buffer for writing P2P IE 19183ff40c12SJohn Marino * @dev_id: Device ID to search for or %NULL for any 1919*a1157835SDaniel Fojt * @bands: Frequency bands used in the scan (enum wpa_radio_work_band bitmap) 19203ff40c12SJohn Marino */ 1921*a1157835SDaniel Fojt void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id, 1922*a1157835SDaniel Fojt unsigned int bands); 19233ff40c12SJohn Marino 19243ff40c12SJohn Marino /** 19253ff40c12SJohn Marino * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie 19263ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19273ff40c12SJohn Marino * Returns: Number of octets that p2p_scan_ie() may add to the buffer 19283ff40c12SJohn Marino */ 19293ff40c12SJohn Marino size_t p2p_scan_ie_buf_len(struct p2p_data *p2p); 19303ff40c12SJohn Marino 19313ff40c12SJohn Marino /** 19323ff40c12SJohn Marino * p2p_go_params - Generate random P2P group parameters 19333ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19343ff40c12SJohn Marino * @params: Buffer for parameters 19353ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 19363ff40c12SJohn Marino */ 19373ff40c12SJohn Marino int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params); 19383ff40c12SJohn Marino 19393ff40c12SJohn Marino /** 19403ff40c12SJohn Marino * p2p_get_group_capab - Get Group Capability from P2P IE data 19413ff40c12SJohn Marino * @p2p_ie: P2P IE(s) contents 19423ff40c12SJohn Marino * Returns: Group Capability 19433ff40c12SJohn Marino */ 19443ff40c12SJohn Marino u8 p2p_get_group_capab(const struct wpabuf *p2p_ie); 19453ff40c12SJohn Marino 19463ff40c12SJohn Marino /** 19473ff40c12SJohn Marino * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection 19483ff40c12SJohn Marino * @p2p_ie: P2P IE(s) contents 19493ff40c12SJohn Marino * Returns: 0 if cross connection is allow, 1 if not 19503ff40c12SJohn Marino */ 19513ff40c12SJohn Marino int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie); 19523ff40c12SJohn Marino 19533ff40c12SJohn Marino /** 19543ff40c12SJohn Marino * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data 19553ff40c12SJohn Marino * @p2p_ie: P2P IE(s) contents 19563ff40c12SJohn Marino * Returns: Pointer to P2P Device Address or %NULL if not included 19573ff40c12SJohn Marino */ 19583ff40c12SJohn Marino const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie); 19593ff40c12SJohn Marino 19603ff40c12SJohn Marino /** 19613ff40c12SJohn Marino * p2p_get_peer_info - Get P2P peer information 19623ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19633ff40c12SJohn Marino * @addr: P2P Device Address of the peer or %NULL to indicate the first peer 19643ff40c12SJohn Marino * @next: Whether to select the peer entry following the one indicated by addr 19653ff40c12SJohn Marino * Returns: Pointer to peer info or %NULL if not found 19663ff40c12SJohn Marino */ 19673ff40c12SJohn Marino const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p, 19683ff40c12SJohn Marino const u8 *addr, int next); 19693ff40c12SJohn Marino 19703ff40c12SJohn Marino /** 19713ff40c12SJohn Marino * p2p_get_peer_info_txt - Get internal P2P peer information in text format 19723ff40c12SJohn Marino * @info: Pointer to P2P peer info from p2p_get_peer_info() 19733ff40c12SJohn Marino * @buf: Buffer for returning text 19743ff40c12SJohn Marino * @buflen: Maximum buffer length 19753ff40c12SJohn Marino * Returns: Number of octets written to the buffer or -1 on failure 19763ff40c12SJohn Marino * 19773ff40c12SJohn Marino * Note: This information is internal to the P2P module and subject to change. 19783ff40c12SJohn Marino * As such, this should not really be used by external programs for purposes 19793ff40c12SJohn Marino * other than debugging. 19803ff40c12SJohn Marino */ 19813ff40c12SJohn Marino int p2p_get_peer_info_txt(const struct p2p_peer_info *info, 19823ff40c12SJohn Marino char *buf, size_t buflen); 19833ff40c12SJohn Marino 19843ff40c12SJohn Marino /** 19853ff40c12SJohn Marino * p2p_peer_known - Check whether P2P peer is known 19863ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19873ff40c12SJohn Marino * @addr: P2P Device Address of the peer 19883ff40c12SJohn Marino * Returns: 1 if the specified device is in the P2P peer table or 0 if not 19893ff40c12SJohn Marino */ 19903ff40c12SJohn Marino int p2p_peer_known(struct p2p_data *p2p, const u8 *addr); 19913ff40c12SJohn Marino 19923ff40c12SJohn Marino /** 19933ff40c12SJohn Marino * p2p_set_client_discoverability - Set client discoverability capability 19943ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 19953ff40c12SJohn Marino * @enabled: Whether client discoverability will be enabled 19963ff40c12SJohn Marino * 19973ff40c12SJohn Marino * This function can be used to disable (and re-enable) client discoverability. 19983ff40c12SJohn Marino * This capability is enabled by default and should not be disabled in normal 19993ff40c12SJohn Marino * use cases, i.e., this is mainly for testing purposes. 20003ff40c12SJohn Marino */ 20013ff40c12SJohn Marino void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled); 20023ff40c12SJohn Marino 20033ff40c12SJohn Marino /** 20043ff40c12SJohn Marino * p2p_set_managed_oper - Set managed P2P Device operations capability 20053ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20063ff40c12SJohn Marino * @enabled: Whether managed P2P Device operations will be enabled 20073ff40c12SJohn Marino */ 20083ff40c12SJohn Marino void p2p_set_managed_oper(struct p2p_data *p2p, int enabled); 20093ff40c12SJohn Marino 2010*a1157835SDaniel Fojt /** 2011*a1157835SDaniel Fojt * p2p_config_get_random_social - Return a random social channel 2012*a1157835SDaniel Fojt * @p2p: P2P config 2013*a1157835SDaniel Fojt * @op_class: Selected operating class 2014*a1157835SDaniel Fojt * @op_channel: Selected social channel 2015*a1157835SDaniel Fojt * @avoid_list: Channel ranges to try to avoid or %NULL 2016*a1157835SDaniel Fojt * @disallow_list: Channel ranges to discard or %NULL 2017*a1157835SDaniel Fojt * Returns: 0 on success, -1 on failure 2018*a1157835SDaniel Fojt * 2019*a1157835SDaniel Fojt * This function is used before p2p_init is called. A random social channel 2020*a1157835SDaniel Fojt * from supports bands 2.4 GHz (channels 1,6,11) and 60 GHz (channel 2) is 2021*a1157835SDaniel Fojt * returned on success. 2022*a1157835SDaniel Fojt */ 2023*a1157835SDaniel Fojt int p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class, 2024*a1157835SDaniel Fojt u8 *op_channel, 2025*a1157835SDaniel Fojt struct wpa_freq_range_list *avoid_list, 2026*a1157835SDaniel Fojt struct wpa_freq_range_list *disallow_list); 2027*a1157835SDaniel Fojt 2028*a1157835SDaniel Fojt int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel, 2029*a1157835SDaniel Fojt u8 forced); 2030*a1157835SDaniel Fojt 2031*a1157835SDaniel Fojt u8 p2p_get_listen_channel(struct p2p_data *p2p); 20323ff40c12SJohn Marino 20333ff40c12SJohn Marino int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len); 20343ff40c12SJohn Marino 20353ff40c12SJohn Marino int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, 20363ff40c12SJohn Marino u8 *iface_addr); 20373ff40c12SJohn Marino int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, 20383ff40c12SJohn Marino u8 *dev_addr); 20393ff40c12SJohn Marino 20403ff40c12SJohn Marino void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr); 20413ff40c12SJohn Marino 20423ff40c12SJohn Marino /** 20433ff40c12SJohn Marino * p2p_set_cross_connect - Set cross connection capability 20443ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20453ff40c12SJohn Marino * @enabled: Whether cross connection will be enabled 20463ff40c12SJohn Marino */ 20473ff40c12SJohn Marino void p2p_set_cross_connect(struct p2p_data *p2p, int enabled); 20483ff40c12SJohn Marino 20493ff40c12SJohn Marino int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr); 20503ff40c12SJohn Marino 20513ff40c12SJohn Marino /** 20523ff40c12SJohn Marino * p2p_set_intra_bss_dist - Set intra BSS distribution 20533ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20543ff40c12SJohn Marino * @enabled: Whether intra BSS distribution will be enabled 20553ff40c12SJohn Marino */ 20563ff40c12SJohn Marino void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled); 20573ff40c12SJohn Marino 20583ff40c12SJohn Marino int p2p_channels_includes_freq(const struct p2p_channels *channels, 20593ff40c12SJohn Marino unsigned int freq); 20603ff40c12SJohn Marino 2061*a1157835SDaniel Fojt int p2p_channels_to_freqs(const struct p2p_channels *channels, 2062*a1157835SDaniel Fojt int *freq_list, unsigned int max_len); 2063*a1157835SDaniel Fojt 20643ff40c12SJohn Marino /** 20653ff40c12SJohn Marino * p2p_supported_freq - Check whether channel is supported for P2P 20663ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20673ff40c12SJohn Marino * @freq: Channel frequency in MHz 20683ff40c12SJohn Marino * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 20693ff40c12SJohn Marino */ 20703ff40c12SJohn Marino int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq); 20713ff40c12SJohn Marino 20723ff40c12SJohn Marino /** 20733ff40c12SJohn Marino * p2p_supported_freq_go - Check whether channel is supported for P2P GO operation 20743ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20753ff40c12SJohn Marino * @freq: Channel frequency in MHz 20763ff40c12SJohn Marino * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 20773ff40c12SJohn Marino */ 20783ff40c12SJohn Marino int p2p_supported_freq_go(struct p2p_data *p2p, unsigned int freq); 20793ff40c12SJohn Marino 20803ff40c12SJohn Marino /** 20813ff40c12SJohn Marino * p2p_supported_freq_cli - Check whether channel is supported for P2P client operation 20823ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20833ff40c12SJohn Marino * @freq: Channel frequency in MHz 20843ff40c12SJohn Marino * Returns: 0 if channel not usable for P2P, 1 if usable for P2P 20853ff40c12SJohn Marino */ 20863ff40c12SJohn Marino int p2p_supported_freq_cli(struct p2p_data *p2p, unsigned int freq); 20873ff40c12SJohn Marino 20883ff40c12SJohn Marino /** 20893ff40c12SJohn Marino * p2p_get_pref_freq - Get channel from preferred channel list 20903ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 20913ff40c12SJohn Marino * @channels: List of channels 20923ff40c12SJohn Marino * Returns: Preferred channel 20933ff40c12SJohn Marino */ 20943ff40c12SJohn Marino unsigned int p2p_get_pref_freq(struct p2p_data *p2p, 20953ff40c12SJohn Marino const struct p2p_channels *channels); 20963ff40c12SJohn Marino 20973ff40c12SJohn Marino void p2p_update_channel_list(struct p2p_data *p2p, 20983ff40c12SJohn Marino const struct p2p_channels *chan, 20993ff40c12SJohn Marino const struct p2p_channels *cli_chan); 21003ff40c12SJohn Marino 21013ff40c12SJohn Marino /** 21023ff40c12SJohn Marino * p2p_set_best_channels - Update best channel information 21033ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 21043ff40c12SJohn Marino * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band 21053ff40c12SJohn Marino * @freq_5: Frequency (MHz) of best channel in 5 GHz band 21063ff40c12SJohn Marino * @freq_overall: Frequency (MHz) of best channel overall 21073ff40c12SJohn Marino */ 21083ff40c12SJohn Marino void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5, 21093ff40c12SJohn Marino int freq_overall); 21103ff40c12SJohn Marino 21113ff40c12SJohn Marino /** 21123ff40c12SJohn Marino * p2p_set_own_freq_preference - Set own preference for channel 21133ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 21143ff40c12SJohn Marino * @freq: Frequency (MHz) of the preferred channel or 0 if no preference 21153ff40c12SJohn Marino * 21163ff40c12SJohn Marino * This function can be used to set a preference on the operating channel based 21173ff40c12SJohn Marino * on frequencies used on the other virtual interfaces that share the same 21183ff40c12SJohn Marino * radio. If non-zero, this is used to try to avoid multi-channel concurrency. 21193ff40c12SJohn Marino */ 21203ff40c12SJohn Marino void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq); 21213ff40c12SJohn Marino 21223ff40c12SJohn Marino const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p); 21233ff40c12SJohn Marino 21243ff40c12SJohn Marino /** 21253ff40c12SJohn Marino * p2p_get_group_num_members - Get number of members in group 21263ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 21273ff40c12SJohn Marino * Returns: Number of members in the group 21283ff40c12SJohn Marino */ 21293ff40c12SJohn Marino unsigned int p2p_get_group_num_members(struct p2p_group *group); 21303ff40c12SJohn Marino 21313ff40c12SJohn Marino /** 2132*a1157835SDaniel Fojt * p2p_client_limit_reached - Check if client limit is reached 2133*a1157835SDaniel Fojt * @group: P2P group context from p2p_group_init() 2134*a1157835SDaniel Fojt * Returns: 1 if no of clients limit reached 2135*a1157835SDaniel Fojt */ 2136*a1157835SDaniel Fojt int p2p_client_limit_reached(struct p2p_group *group); 2137*a1157835SDaniel Fojt 2138*a1157835SDaniel Fojt /** 21393ff40c12SJohn Marino * p2p_iterate_group_members - Iterate group members 21403ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 21413ff40c12SJohn Marino * @next: iteration pointer, must be a pointer to a void * that is set to %NULL 21423ff40c12SJohn Marino * on the first call and not modified later 2143*a1157835SDaniel Fojt * Returns: A P2P Device Address for each call and %NULL for no more members 21443ff40c12SJohn Marino */ 21453ff40c12SJohn Marino const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next); 21463ff40c12SJohn Marino 21473ff40c12SJohn Marino /** 2148*a1157835SDaniel Fojt * p2p_group_get_client_interface_addr - Get P2P Interface Address of a client in a group 2149*a1157835SDaniel Fojt * @group: P2P group context from p2p_group_init() 2150*a1157835SDaniel Fojt * @dev_addr: P2P Device Address of the client 2151*a1157835SDaniel Fojt * Returns: P2P Interface Address of the client if found or %NULL if no match 2152*a1157835SDaniel Fojt * found 2153*a1157835SDaniel Fojt */ 2154*a1157835SDaniel Fojt const u8 * p2p_group_get_client_interface_addr(struct p2p_group *group, 2155*a1157835SDaniel Fojt const u8 *dev_addr); 2156*a1157835SDaniel Fojt 2157*a1157835SDaniel Fojt /** 21583ff40c12SJohn Marino * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group 21593ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 21603ff40c12SJohn Marino * @addr: P2P Interface Address of the client 21613ff40c12SJohn Marino * Returns: P2P Device Address of the client if found or %NULL if no match 21623ff40c12SJohn Marino * found 21633ff40c12SJohn Marino */ 21643ff40c12SJohn Marino const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr); 21653ff40c12SJohn Marino 21663ff40c12SJohn Marino /** 21673ff40c12SJohn Marino * p2p_group_is_client_connected - Check whether a specific client is connected 21683ff40c12SJohn Marino * @group: P2P group context from p2p_group_init() 21693ff40c12SJohn Marino * @addr: P2P Device Address of the client 21703ff40c12SJohn Marino * Returns: 1 if client is connected or 0 if not 21713ff40c12SJohn Marino */ 21723ff40c12SJohn Marino int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr); 21733ff40c12SJohn Marino 21743ff40c12SJohn Marino /** 2175*a1157835SDaniel Fojt * p2p_group_get_config - Get the group configuration 2176*a1157835SDaniel Fojt * @group: P2P group context from p2p_group_init() 2177*a1157835SDaniel Fojt * Returns: The group configuration pointer 2178*a1157835SDaniel Fojt */ 2179*a1157835SDaniel Fojt const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group); 2180*a1157835SDaniel Fojt 2181*a1157835SDaniel Fojt /** 2182*a1157835SDaniel Fojt * p2p_loop_on_all_groups - Run the given callback on all groups 2183*a1157835SDaniel Fojt * @p2p: P2P module context from p2p_init() 2184*a1157835SDaniel Fojt * @group_callback: The callback function pointer 2185*a1157835SDaniel Fojt * @user_data: Some user data pointer which can be %NULL 2186*a1157835SDaniel Fojt * 2187*a1157835SDaniel Fojt * The group_callback function can stop the iteration by returning 0. 2188*a1157835SDaniel Fojt */ 2189*a1157835SDaniel Fojt void p2p_loop_on_all_groups(struct p2p_data *p2p, 2190*a1157835SDaniel Fojt int (*group_callback)(struct p2p_group *group, 2191*a1157835SDaniel Fojt void *user_data), 2192*a1157835SDaniel Fojt void *user_data); 2193*a1157835SDaniel Fojt 2194*a1157835SDaniel Fojt /** 21953ff40c12SJohn Marino * p2p_get_peer_found - Get P2P peer info structure of a found peer 21963ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 21973ff40c12SJohn Marino * @addr: P2P Device Address of the peer or %NULL to indicate the first peer 21983ff40c12SJohn Marino * @next: Whether to select the peer entry following the one indicated by addr 21993ff40c12SJohn Marino * Returns: The first P2P peer info available or %NULL if no such peer exists 22003ff40c12SJohn Marino */ 22013ff40c12SJohn Marino const struct p2p_peer_info * 22023ff40c12SJohn Marino p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next); 22033ff40c12SJohn Marino 22043ff40c12SJohn Marino /** 22053ff40c12SJohn Marino * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions 22063ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22073ff40c12SJohn Marino */ 22083ff40c12SJohn Marino void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p); 22093ff40c12SJohn Marino 22103ff40c12SJohn Marino /** 22113ff40c12SJohn Marino * p2p_add_wps_vendor_extension - Add a WPS vendor extension 22123ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22133ff40c12SJohn Marino * @vendor_ext: The vendor extensions to add 22143ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 22153ff40c12SJohn Marino * 22163ff40c12SJohn Marino * The wpabuf structures in the array are owned by the P2P 22173ff40c12SJohn Marino * module after this call. 22183ff40c12SJohn Marino */ 22193ff40c12SJohn Marino int p2p_add_wps_vendor_extension(struct p2p_data *p2p, 22203ff40c12SJohn Marino const struct wpabuf *vendor_ext); 22213ff40c12SJohn Marino 22223ff40c12SJohn Marino /** 22233ff40c12SJohn Marino * p2p_set_oper_channel - Set the P2P operating channel 22243ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22253ff40c12SJohn Marino * @op_reg_class: Operating regulatory class to set 22263ff40c12SJohn Marino * @op_channel: operating channel to set 22273ff40c12SJohn Marino * @cfg_op_channel : Whether op_channel is hardcoded in configuration 22283ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 22293ff40c12SJohn Marino */ 22303ff40c12SJohn Marino int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel, 22313ff40c12SJohn Marino int cfg_op_channel); 22323ff40c12SJohn Marino 22333ff40c12SJohn Marino /** 22343ff40c12SJohn Marino * p2p_set_pref_chan - Set P2P preferred channel list 22353ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22363ff40c12SJohn Marino * @num_pref_chan: Number of entries in pref_chan list 22373ff40c12SJohn Marino * @pref_chan: Preferred channels or %NULL to remove preferences 22383ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 22393ff40c12SJohn Marino */ 22403ff40c12SJohn Marino int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan, 22413ff40c12SJohn Marino const struct p2p_channel *pref_chan); 22423ff40c12SJohn Marino 22433ff40c12SJohn Marino /** 22443ff40c12SJohn Marino * p2p_set_no_go_freq - Set no GO channel ranges 22453ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22463ff40c12SJohn Marino * @list: Channel ranges or %NULL to remove restriction 22473ff40c12SJohn Marino * Returns: 0 on success, -1 on failure 22483ff40c12SJohn Marino */ 22493ff40c12SJohn Marino int p2p_set_no_go_freq(struct p2p_data *p2p, 22503ff40c12SJohn Marino const struct wpa_freq_range_list *list); 22513ff40c12SJohn Marino 22523ff40c12SJohn Marino /** 22533ff40c12SJohn Marino * p2p_in_progress - Check whether a P2P operation is progress 22543ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 2255*a1157835SDaniel Fojt * Returns: 0 if P2P module is idle, 1 if an operation is in progress but not 2256*a1157835SDaniel Fojt * in search state, or 2 if search state operation is in progress 22573ff40c12SJohn Marino */ 22583ff40c12SJohn Marino int p2p_in_progress(struct p2p_data *p2p); 22593ff40c12SJohn Marino 22603ff40c12SJohn Marino const char * p2p_wps_method_text(enum p2p_wps_method method); 22613ff40c12SJohn Marino 22623ff40c12SJohn Marino /** 22633ff40c12SJohn Marino * p2p_set_config_timeout - Set local config timeouts 22643ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22653ff40c12SJohn Marino * @go_timeout: Time in 10 ms units it takes to start the GO mode 22663ff40c12SJohn Marino * @client_timeout: Time in 10 ms units it takes to start the client mode 22673ff40c12SJohn Marino */ 22683ff40c12SJohn Marino void p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout, 22693ff40c12SJohn Marino u8 client_timeout); 22703ff40c12SJohn Marino 22713ff40c12SJohn Marino int p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie); 22723ff40c12SJohn Marino int p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie); 22733ff40c12SJohn Marino int p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie); 22743ff40c12SJohn Marino int p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie); 22753ff40c12SJohn Marino int p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie); 22763ff40c12SJohn Marino int p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie); 22773ff40c12SJohn Marino int p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie); 22783ff40c12SJohn Marino int p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie); 22793ff40c12SJohn Marino int p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem); 2280*a1157835SDaniel Fojt int p2p_set_wfd_r2_dev_info(struct p2p_data *p2p, const struct wpabuf *elem); 22813ff40c12SJohn Marino int p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem); 22823ff40c12SJohn Marino int p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p, 22833ff40c12SJohn Marino const struct wpabuf *elem); 22843ff40c12SJohn Marino struct wpabuf * wifi_display_encaps(struct wpabuf *subelems); 22853ff40c12SJohn Marino 22863ff40c12SJohn Marino /** 22873ff40c12SJohn Marino * p2p_set_disc_int - Set min/max discoverable interval for p2p_find 22883ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 22893ff40c12SJohn Marino * @min_disc_int: minDiscoverableInterval (in units of 100 TU); default 1 22903ff40c12SJohn Marino * @max_disc_int: maxDiscoverableInterval (in units of 100 TU); default 3 22913ff40c12SJohn Marino * @max_disc_tu: Maximum number of TUs (1.024 ms) for discoverable interval; or 22923ff40c12SJohn Marino * -1 not to limit 22933ff40c12SJohn Marino * Returns: 0 on success, or -1 on failure 22943ff40c12SJohn Marino * 22953ff40c12SJohn Marino * This function can be used to configure minDiscoverableInterval and 22963ff40c12SJohn Marino * maxDiscoverableInterval parameters for the Listen state during device 22973ff40c12SJohn Marino * discovery (p2p_find). A random number of 100 TU units is picked for each 22983ff40c12SJohn Marino * Listen state iteration from [min_disc_int,max_disc_int] range. 22993ff40c12SJohn Marino * 2300*a1157835SDaniel Fojt * max_disc_tu can be used to further limit the discoverable duration. However, 23013ff40c12SJohn Marino * it should be noted that use of this parameter is not recommended since it 23023ff40c12SJohn Marino * would not be compliant with the P2P specification. 23033ff40c12SJohn Marino */ 23043ff40c12SJohn Marino int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int, 23053ff40c12SJohn Marino int max_disc_tu); 23063ff40c12SJohn Marino 23073ff40c12SJohn Marino /** 23083ff40c12SJohn Marino * p2p_get_state_txt - Get current P2P state for debug purposes 23093ff40c12SJohn Marino * @p2p: P2P module context from p2p_init() 23103ff40c12SJohn Marino * Returns: Name of the current P2P module state 23113ff40c12SJohn Marino * 23123ff40c12SJohn Marino * It should be noted that the P2P module state names are internal information 23133ff40c12SJohn Marino * and subject to change at any point, i.e., this information should be used 23143ff40c12SJohn Marino * mainly for debugging purposes. 23153ff40c12SJohn Marino */ 23163ff40c12SJohn Marino const char * p2p_get_state_txt(struct p2p_data *p2p); 23173ff40c12SJohn Marino 23183ff40c12SJohn Marino struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p, 23193ff40c12SJohn Marino int client_freq, 23203ff40c12SJohn Marino const u8 *go_dev_addr, 23213ff40c12SJohn Marino const u8 *ssid, size_t ssid_len); 23223ff40c12SJohn Marino struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p, 23233ff40c12SJohn Marino int client_freq, 23243ff40c12SJohn Marino const u8 *go_dev_addr, 23253ff40c12SJohn Marino const u8 *ssid, size_t ssid_len); 23263ff40c12SJohn Marino 23273ff40c12SJohn Marino struct p2p_nfc_params { 23283ff40c12SJohn Marino int sel; 23293ff40c12SJohn Marino const u8 *wsc_attr; 23303ff40c12SJohn Marino size_t wsc_len; 23313ff40c12SJohn Marino const u8 *p2p_attr; 23323ff40c12SJohn Marino size_t p2p_len; 23333ff40c12SJohn Marino 23343ff40c12SJohn Marino enum { 23353ff40c12SJohn Marino NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG, 23363ff40c12SJohn Marino BOTH_GO, PEER_CLIENT 23373ff40c12SJohn Marino } next_step; 23383ff40c12SJohn Marino struct p2p_peer_info *peer; 23393ff40c12SJohn Marino u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 + 23403ff40c12SJohn Marino WPS_OOB_DEVICE_PASSWORD_LEN]; 23413ff40c12SJohn Marino size_t oob_dev_pw_len; 23423ff40c12SJohn Marino int go_freq; 23433ff40c12SJohn Marino u8 go_dev_addr[ETH_ALEN]; 2344*a1157835SDaniel Fojt u8 go_ssid[SSID_MAX_LEN]; 23453ff40c12SJohn Marino size_t go_ssid_len; 23463ff40c12SJohn Marino }; 23473ff40c12SJohn Marino 23483ff40c12SJohn Marino int p2p_process_nfc_connection_handover(struct p2p_data *p2p, 23493ff40c12SJohn Marino struct p2p_nfc_params *params); 23503ff40c12SJohn Marino 23513ff40c12SJohn Marino void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id, 23523ff40c12SJohn Marino int go_intent, 23533ff40c12SJohn Marino const u8 *own_interface_addr); 23543ff40c12SJohn Marino 2355*a1157835SDaniel Fojt int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len); 2356*a1157835SDaniel Fojt 2357*a1157835SDaniel Fojt void p2p_loop_on_known_peers(struct p2p_data *p2p, 2358*a1157835SDaniel Fojt void (*peer_callback)(struct p2p_peer_info *peer, 2359*a1157835SDaniel Fojt void *user_data), 2360*a1157835SDaniel Fojt void *user_data); 2361*a1157835SDaniel Fojt 2362*a1157835SDaniel Fojt void p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem); 2363*a1157835SDaniel Fojt 2364*a1157835SDaniel Fojt void p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr); 2365*a1157835SDaniel Fojt 2366*a1157835SDaniel Fojt struct p2ps_advertisement * 2367*a1157835SDaniel Fojt p2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id); 2368*a1157835SDaniel Fojt int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id, 2369*a1157835SDaniel Fojt const char *adv_str, u8 svc_state, 2370*a1157835SDaniel Fojt u16 config_methods, const char *svc_info, 2371*a1157835SDaniel Fojt const u8 *cpt_priority); 2372*a1157835SDaniel Fojt int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id); 2373*a1157835SDaniel Fojt void p2p_service_flush_asp(struct p2p_data *p2p); 2374*a1157835SDaniel Fojt struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p); 2375*a1157835SDaniel Fojt 2376*a1157835SDaniel Fojt /** 2377*a1157835SDaniel Fojt * p2p_expire_peers - Periodic cleanup function to expire peers 2378*a1157835SDaniel Fojt * @p2p: P2P module context from p2p_init() 2379*a1157835SDaniel Fojt * 2380*a1157835SDaniel Fojt * This is a cleanup function that the entity calling p2p_init() is 2381*a1157835SDaniel Fojt * expected to call periodically to clean up expired peer entries. 2382*a1157835SDaniel Fojt */ 2383*a1157835SDaniel Fojt void p2p_expire_peers(struct p2p_data *p2p); 2384*a1157835SDaniel Fojt 2385*a1157835SDaniel Fojt void p2p_set_own_pref_freq_list(struct p2p_data *p2p, 2386*a1157835SDaniel Fojt const unsigned int *pref_freq_list, 2387*a1157835SDaniel Fojt unsigned int size); 2388*a1157835SDaniel Fojt void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class, 2389*a1157835SDaniel Fojt u8 chan); 2390*a1157835SDaniel Fojt 2391*a1157835SDaniel Fojt /** 2392*a1157835SDaniel Fojt * p2p_group_get_common_freqs - Get the group common frequencies 2393*a1157835SDaniel Fojt * @group: P2P group context from p2p_group_init() 2394*a1157835SDaniel Fojt * @common_freqs: On return will hold the group common frequencies 2395*a1157835SDaniel Fojt * @num: On return will hold the number of group common frequencies 2396*a1157835SDaniel Fojt * Returns: 0 on success, -1 otherwise 2397*a1157835SDaniel Fojt */ 2398*a1157835SDaniel Fojt int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs, 2399*a1157835SDaniel Fojt unsigned int *num); 2400*a1157835SDaniel Fojt 2401*a1157835SDaniel Fojt struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p, 2402*a1157835SDaniel Fojt unsigned int freq); 2403*a1157835SDaniel Fojt 24043ff40c12SJohn Marino #endif /* P2P_H */ 2405