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