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