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 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * Alternatively, this software may be distributed under the terms of BSD |
| 10 | * license. |
| 11 | * |
| 12 | * See README and COPYING for more details. |
| 13 | */ |
| 14 | |
| 15 | #ifndef P2P_H |
| 16 | #define P2P_H |
| 17 | |
| 18 | /** |
| 19 | * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes |
| 20 | */ |
| 21 | #define P2P_MAX_REG_CLASSES 10 |
| 22 | |
| 23 | /** |
| 24 | * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class |
| 25 | */ |
| 26 | #define P2P_MAX_REG_CLASS_CHANNELS 20 |
| 27 | |
| 28 | /** |
| 29 | * struct p2p_channels - List of supported channels |
| 30 | */ |
| 31 | struct p2p_channels { |
| 32 | /** |
| 33 | * struct p2p_reg_class - Supported regulatory class |
| 34 | */ |
| 35 | struct p2p_reg_class { |
| 36 | /** |
| 37 | * reg_class - Regulatory class (IEEE 802.11-2007, Annex J) |
| 38 | */ |
| 39 | u8 reg_class; |
| 40 | |
| 41 | /** |
| 42 | * channel - Supported channels |
| 43 | */ |
| 44 | u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; |
| 45 | |
| 46 | /** |
| 47 | * channels - Number of channel entries in use |
| 48 | */ |
| 49 | size_t channels; |
| 50 | } reg_class[P2P_MAX_REG_CLASSES]; |
| 51 | |
| 52 | /** |
| 53 | * reg_classes - Number of reg_class entries in use |
| 54 | */ |
| 55 | size_t reg_classes; |
| 56 | }; |
| 57 | |
| 58 | enum p2p_wps_method { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 59 | WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | /** |
| 63 | * struct p2p_go_neg_results - P2P Group Owner Negotiation results |
| 64 | */ |
| 65 | struct p2p_go_neg_results { |
| 66 | /** |
| 67 | * status - Negotiation result (Status Code) |
| 68 | * |
| 69 | * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate |
| 70 | * failed negotiation. |
| 71 | */ |
| 72 | int status; |
| 73 | |
| 74 | /** |
| 75 | * role_go - Whether local end is Group Owner |
| 76 | */ |
| 77 | int role_go; |
| 78 | |
| 79 | /** |
| 80 | * freq - Frequency of the group operational channel in MHz |
| 81 | */ |
| 82 | int freq; |
| 83 | |
| 84 | /** |
| 85 | * ssid - SSID of the group |
| 86 | */ |
| 87 | u8 ssid[32]; |
| 88 | |
| 89 | /** |
| 90 | * ssid_len - Length of SSID in octets |
| 91 | */ |
| 92 | size_t ssid_len; |
| 93 | |
| 94 | /** |
| 95 | * passphrase - WPA2-Personal passphrase for the group (GO only) |
| 96 | */ |
| 97 | char passphrase[64]; |
| 98 | |
| 99 | /** |
| 100 | * peer_device_addr - P2P Device Address of the peer |
| 101 | */ |
| 102 | u8 peer_device_addr[ETH_ALEN]; |
| 103 | |
| 104 | /** |
| 105 | * peer_interface_addr - P2P Interface Address of the peer |
| 106 | */ |
| 107 | u8 peer_interface_addr[ETH_ALEN]; |
| 108 | |
| 109 | /** |
| 110 | * wps_method - WPS method to be used during provisioning |
| 111 | */ |
| 112 | enum p2p_wps_method wps_method; |
| 113 | |
| 114 | #define P2P_MAX_CHANNELS 50 |
| 115 | |
| 116 | /** |
| 117 | * freq_list - Zero-terminated list of possible operational channels |
| 118 | */ |
| 119 | int freq_list[P2P_MAX_CHANNELS]; |
| 120 | |
| 121 | /** |
| 122 | * persistent_group - Whether the group should be made persistent |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 123 | * 0 = not persistent |
| 124 | * 1 = persistent group without persistent reconnect |
| 125 | * 2 = persistent group with persistent reconnect |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 126 | */ |
| 127 | int persistent_group; |
| 128 | |
| 129 | /** |
| 130 | * peer_config_timeout - Peer configuration timeout (in 10 msec units) |
| 131 | */ |
| 132 | unsigned int peer_config_timeout; |
| 133 | }; |
| 134 | |
| 135 | struct p2p_data; |
| 136 | |
| 137 | enum p2p_scan_type { |
| 138 | P2P_SCAN_SOCIAL, |
| 139 | P2P_SCAN_FULL, |
| 140 | P2P_SCAN_SPECIFIC, |
| 141 | P2P_SCAN_SOCIAL_PLUS_ONE |
| 142 | }; |
| 143 | |
| 144 | #define P2P_MAX_WPS_VENDOR_EXT 10 |
| 145 | |
| 146 | /** |
| 147 | * struct p2p_peer_info - P2P peer information |
| 148 | */ |
| 149 | struct p2p_peer_info { |
| 150 | /** |
| 151 | * p2p_device_addr - P2P Device Address of the peer |
| 152 | */ |
| 153 | u8 p2p_device_addr[ETH_ALEN]; |
| 154 | |
| 155 | /** |
| 156 | * pri_dev_type - Primary Device Type |
| 157 | */ |
| 158 | u8 pri_dev_type[8]; |
| 159 | |
| 160 | /** |
| 161 | * device_name - Device Name (0..32 octets encoded in UTF-8) |
| 162 | */ |
| 163 | char device_name[33]; |
| 164 | |
| 165 | /** |
| 166 | * manufacturer - Manufacturer (0..64 octets encoded in UTF-8) |
| 167 | */ |
| 168 | char manufacturer[65]; |
| 169 | |
| 170 | /** |
| 171 | * model_name - Model Name (0..32 octets encoded in UTF-8) |
| 172 | */ |
| 173 | char model_name[33]; |
| 174 | |
| 175 | /** |
| 176 | * model_number - Model Number (0..32 octets encoded in UTF-8) |
| 177 | */ |
| 178 | char model_number[33]; |
| 179 | |
| 180 | /** |
| 181 | * serial_number - Serial Number (0..32 octets encoded in UTF-8) |
| 182 | */ |
| 183 | char serial_number[33]; |
| 184 | |
| 185 | /** |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 186 | * level - Signal level |
| 187 | */ |
| 188 | int level; |
| 189 | |
| 190 | /** |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 191 | * config_methods - WPS Configuration Methods |
| 192 | */ |
| 193 | u16 config_methods; |
| 194 | |
| 195 | /** |
| 196 | * dev_capab - Device Capabilities |
| 197 | */ |
| 198 | u8 dev_capab; |
| 199 | |
| 200 | /** |
| 201 | * group_capab - Group Capabilities |
| 202 | */ |
| 203 | u8 group_capab; |
| 204 | |
| 205 | /** |
| 206 | * wps_sec_dev_type_list - WPS secondary device type list |
| 207 | * |
| 208 | * This list includes from 0 to 16 Secondary Device Types as indicated |
| 209 | * by wps_sec_dev_type_list_len (8 * number of types). |
| 210 | */ |
| 211 | u8 wps_sec_dev_type_list[128]; |
| 212 | |
| 213 | /** |
| 214 | * wps_sec_dev_type_list_len - Length of secondary device type list |
| 215 | */ |
| 216 | size_t wps_sec_dev_type_list_len; |
| 217 | |
| 218 | struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; |
| 219 | }; |
| 220 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 221 | enum p2p_prov_disc_status { |
| 222 | P2P_PROV_DISC_SUCCESS, |
| 223 | P2P_PROV_DISC_TIMEOUT, |
| 224 | P2P_PROV_DISC_REJECTED, |
| 225 | }; |
| 226 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 227 | /** |
| 228 | * struct p2p_config - P2P configuration |
| 229 | * |
| 230 | * This configuration is provided to the P2P module during initialization with |
| 231 | * p2p_init(). |
| 232 | */ |
| 233 | struct p2p_config { |
| 234 | /** |
| 235 | * country - Country code to use in P2P operations |
| 236 | */ |
| 237 | char country[3]; |
| 238 | |
| 239 | /** |
| 240 | * reg_class - Regulatory class for own listen channel |
| 241 | */ |
| 242 | u8 reg_class; |
| 243 | |
| 244 | /** |
| 245 | * channel - Own listen channel |
| 246 | */ |
| 247 | u8 channel; |
| 248 | |
| 249 | /** |
| 250 | * Regulatory class for own operational channel |
| 251 | */ |
| 252 | u8 op_reg_class; |
| 253 | |
| 254 | /** |
| 255 | * op_channel - Own operational channel |
| 256 | */ |
| 257 | u8 op_channel; |
| 258 | |
| 259 | /** |
| 260 | * cfg_op_channel - Whether op_channel is hardcoded in configuration |
| 261 | */ |
| 262 | u8 cfg_op_channel; |
| 263 | |
| 264 | /** |
| 265 | * channels - Own supported regulatory classes and channels |
| 266 | * |
| 267 | * List of supposerted channels per regulatory class. The regulatory |
| 268 | * classes are defined in IEEE Std 802.11-2007 Annex J and the |
| 269 | * numbering of the clases depends on the configured country code. |
| 270 | */ |
| 271 | struct p2p_channels channels; |
| 272 | |
| 273 | /** |
| 274 | * pri_dev_type - Primary Device Type (see WPS) |
| 275 | */ |
| 276 | u8 pri_dev_type[8]; |
| 277 | |
| 278 | /** |
| 279 | * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types |
| 280 | */ |
| 281 | #define P2P_SEC_DEVICE_TYPES 5 |
| 282 | |
| 283 | /** |
| 284 | * sec_dev_type - Optional secondary device types |
| 285 | */ |
| 286 | u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8]; |
| 287 | |
| 288 | /** |
| 289 | * num_sec_dev_types - Number of sec_dev_type entries |
| 290 | */ |
| 291 | size_t num_sec_dev_types; |
| 292 | |
| 293 | /** |
| 294 | * dev_addr - P2P Device Address |
| 295 | */ |
| 296 | u8 dev_addr[ETH_ALEN]; |
| 297 | |
| 298 | /** |
| 299 | * dev_name - Device Name |
| 300 | */ |
| 301 | char *dev_name; |
| 302 | |
| 303 | char *manufacturer; |
| 304 | char *model_name; |
| 305 | char *model_number; |
| 306 | char *serial_number; |
| 307 | |
| 308 | u8 uuid[16]; |
| 309 | u16 config_methods; |
| 310 | |
| 311 | /** |
| 312 | * concurrent_operations - Whether concurrent operations are supported |
| 313 | */ |
| 314 | int concurrent_operations; |
| 315 | |
| 316 | /** |
| 317 | * max_peers - Maximum number of discovered peers to remember |
| 318 | * |
| 319 | * If more peers are discovered, older entries will be removed to make |
| 320 | * room for the new ones. |
| 321 | */ |
| 322 | size_t max_peers; |
| 323 | |
| 324 | /** |
| 325 | * p2p_intra_bss - Intra BSS communication is supported |
| 326 | */ |
| 327 | int p2p_intra_bss; |
| 328 | |
| 329 | /** |
| 330 | * ssid_postfix - Postfix data to add to the SSID |
| 331 | * |
| 332 | * This data will be added to the end of the SSID after the |
| 333 | * DIRECT-<random two octets> prefix. |
| 334 | */ |
| 335 | u8 ssid_postfix[32 - 9]; |
| 336 | |
| 337 | /** |
| 338 | * ssid_postfix_len - Length of the ssid_postfix data |
| 339 | */ |
| 340 | size_t ssid_postfix_len; |
| 341 | |
| 342 | /** |
| 343 | * msg_ctx - Context to use with wpa_msg() calls |
| 344 | */ |
| 345 | void *msg_ctx; |
| 346 | |
| 347 | /** |
| 348 | * cb_ctx - Context to use with callback functions |
| 349 | */ |
| 350 | void *cb_ctx; |
| 351 | |
| 352 | |
| 353 | /* Callbacks to request lower layer driver operations */ |
| 354 | |
| 355 | /** |
| 356 | * p2p_scan - Request a P2P scan/search |
| 357 | * @ctx: Callback context from cb_ctx |
| 358 | * @type: Scan type |
| 359 | * @freq: Specific frequency (MHz) to scan or 0 for no restriction |
| 360 | * @num_req_dev_types: Number of requested device types |
| 361 | * @req_dev_types: Array containing requested device types |
| 362 | * Returns: 0 on success, -1 on failure |
| 363 | * |
| 364 | * This callback function is used to request a P2P scan or search |
| 365 | * operation to be completed. Type type argument specifies which type |
| 366 | * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the |
| 367 | * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL |
| 368 | * indicates that all channels are to be scanned. @P2P_SCAN_SPECIFIC |
| 369 | * request a scan of a single channel specified by freq. |
| 370 | * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels |
| 371 | * plus one extra channel specified by freq. |
| 372 | * |
| 373 | * The full scan is used for the initial scan to find group owners from |
| 374 | * all. The other types are used during search phase scan of the social |
| 375 | * channels (with potential variation if the Listen channel of the |
| 376 | * target peer is known or if other channels are scanned in steps). |
| 377 | * |
| 378 | * The scan results are returned after this call by calling |
| 379 | * p2p_scan_res_handler() for each scan result that has a P2P IE and |
| 380 | * then calling p2p_scan_res_handled() to indicate that all scan |
| 381 | * results have been indicated. |
| 382 | */ |
| 383 | int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq, |
| 384 | unsigned int num_req_dev_types, |
| 385 | const u8 *req_dev_types); |
| 386 | |
| 387 | /** |
| 388 | * send_probe_resp - Transmit a Probe Response frame |
| 389 | * @ctx: Callback context from cb_ctx |
| 390 | * @buf: Probe Response frame (including the header and body) |
| 391 | * Returns: 0 on success, -1 on failure |
| 392 | * |
| 393 | * This function is used to reply to Probe Request frames that were |
| 394 | * indicated with a call to p2p_probe_req_rx(). The response is to be |
| 395 | * sent on the same channel or to be dropped if the driver is not |
| 396 | * anymore listening to Probe Request frames. |
| 397 | * |
| 398 | * Alternatively, the responsibility for building the Probe Response |
| 399 | * frames in Listen state may be in another system component in which |
| 400 | * case this function need to be implemented (i.e., the function |
| 401 | * pointer can be %NULL). The WPS and P2P IEs to be added for Probe |
| 402 | * Response frames in such a case are available from the |
| 403 | * start_listen() callback. It should be noted that the received Probe |
| 404 | * Request frames must be indicated by calling p2p_probe_req_rx() even |
| 405 | * if this send_probe_resp() is not used. |
| 406 | */ |
| 407 | int (*send_probe_resp)(void *ctx, const struct wpabuf *buf); |
| 408 | |
| 409 | /** |
| 410 | * send_action - Transmit an Action frame |
| 411 | * @ctx: Callback context from cb_ctx |
| 412 | * @freq: Frequency in MHz for the channel on which to transmit |
| 413 | * @dst: Destination MAC address (Address 1) |
| 414 | * @src: Source MAC address (Address 2) |
| 415 | * @bssid: BSSID (Address 3) |
| 416 | * @buf: Frame body (starting from Category field) |
| 417 | * @len: Length of buf in octets |
| 418 | * @wait_time: How many msec to wait for a response frame |
| 419 | * Returns: 0 on success, -1 on failure |
| 420 | * |
| 421 | * The Action frame may not be transmitted immediately and the status |
| 422 | * of the transmission must be reported by calling |
| 423 | * p2p_send_action_cb() once the frame has either been transmitted or |
| 424 | * it has been dropped due to excessive retries or other failure to |
| 425 | * transmit. |
| 426 | */ |
| 427 | int (*send_action)(void *ctx, unsigned int freq, const u8 *dst, |
| 428 | const u8 *src, const u8 *bssid, const u8 *buf, |
| 429 | size_t len, unsigned int wait_time); |
| 430 | |
| 431 | /** |
| 432 | * send_action_done - Notify that Action frame sequence was completed |
| 433 | * @ctx: Callback context from cb_ctx |
| 434 | * |
| 435 | * This function is called when the Action frame sequence that was |
| 436 | * started with send_action() has been completed, i.e., when there is |
| 437 | * no need to wait for a response from the destination peer anymore. |
| 438 | */ |
| 439 | void (*send_action_done)(void *ctx); |
| 440 | |
| 441 | /** |
| 442 | * start_listen - Start Listen state |
| 443 | * @ctx: Callback context from cb_ctx |
| 444 | * @freq: Frequency of the listen channel in MHz |
| 445 | * @duration: Duration for the Listen state in milliseconds |
| 446 | * @probe_resp_ie: IE(s) to be added to Probe Response frames |
| 447 | * Returns: 0 on success, -1 on failure |
| 448 | * |
| 449 | * This Listen state may not start immediately since the driver may |
| 450 | * have other pending operations to complete first. Once the Listen |
| 451 | * state has started, p2p_listen_cb() must be called to notify the P2P |
| 452 | * module. Once the Listen state is stopped, p2p_listen_end() must be |
| 453 | * called to notify the P2P module that the driver is not in the Listen |
| 454 | * state anymore. |
| 455 | * |
| 456 | * If the send_probe_resp() is not used for generating the response, |
| 457 | * the IEs from probe_resp_ie need to be added to the end of the Probe |
| 458 | * Response frame body. If send_probe_resp() is used, the probe_resp_ie |
| 459 | * information can be ignored. |
| 460 | */ |
| 461 | int (*start_listen)(void *ctx, unsigned int freq, |
| 462 | unsigned int duration, |
| 463 | const struct wpabuf *probe_resp_ie); |
| 464 | /** |
| 465 | * stop_listen - Stop Listen state |
| 466 | * @ctx: Callback context from cb_ctx |
| 467 | * |
| 468 | * This callback can be used to stop a Listen state operation that was |
| 469 | * previously requested with start_listen(). |
| 470 | */ |
| 471 | void (*stop_listen)(void *ctx); |
| 472 | |
| 473 | /** |
| 474 | * get_noa - Get current Notice of Absence attribute payload |
| 475 | * @ctx: Callback context from cb_ctx |
| 476 | * @interface_addr: P2P Interface Address of the GO |
| 477 | * @buf: Buffer for returning NoA |
| 478 | * @buf_len: Buffer length in octets |
| 479 | * Returns: Number of octets used in buf, 0 to indicate no NoA is being |
| 480 | * advertized, or -1 on failure |
| 481 | * |
| 482 | * This function is used to fetch the current Notice of Absence |
| 483 | * attribute value from GO. |
| 484 | */ |
| 485 | int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf, |
| 486 | size_t buf_len); |
| 487 | |
| 488 | /* Callbacks to notify events to upper layer management entity */ |
| 489 | |
| 490 | /** |
| 491 | * dev_found - Notification of a found P2P Device |
| 492 | * @ctx: Callback context from cb_ctx |
| 493 | * @addr: Source address of the message triggering this notification |
| 494 | * @info: P2P peer information |
| 495 | * @new_device: Inform if the peer is newly found |
| 496 | * |
| 497 | * This callback is used to notify that a new P2P Device has been |
| 498 | * found. This may happen, e.g., during Search state based on scan |
| 499 | * results or during Listen state based on receive Probe Request and |
| 500 | * Group Owner Negotiation Request. |
| 501 | */ |
| 502 | void (*dev_found)(void *ctx, const u8 *addr, |
| 503 | const struct p2p_peer_info *info, |
| 504 | int new_device); |
| 505 | |
| 506 | /** |
| 507 | * dev_lost - Notification of a lost P2P Device |
| 508 | * @ctx: Callback context from cb_ctx |
| 509 | * @dev_addr: P2P Device Address of the lost P2P Device |
| 510 | * |
| 511 | * This callback is used to notify that a P2P Device has been deleted. |
| 512 | */ |
| 513 | void (*dev_lost)(void *ctx, const u8 *dev_addr); |
| 514 | |
| 515 | /** |
| 516 | * go_neg_req_rx - Notification of a receive GO Negotiation Request |
| 517 | * @ctx: Callback context from cb_ctx |
| 518 | * @src: Source address of the message triggering this notification |
| 519 | * @dev_passwd_id: WPS Device Password ID |
| 520 | * |
| 521 | * This callback is used to notify that a P2P Device is requesting |
| 522 | * group owner negotiation with us, but we do not have all the |
| 523 | * necessary information to start GO Negotiation. This indicates that |
| 524 | * the local user has not authorized the connection yet by providing a |
| 525 | * PIN or PBC button press. This information can be provided with a |
| 526 | * call to p2p_connect(). |
| 527 | */ |
| 528 | void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id); |
| 529 | |
| 530 | /** |
| 531 | * go_neg_completed - Notification of GO Negotiation results |
| 532 | * @ctx: Callback context from cb_ctx |
| 533 | * @res: GO Negotiation results |
| 534 | * |
| 535 | * This callback is used to notify that Group Owner Negotiation has |
| 536 | * been completed. Non-zero struct p2p_go_neg_results::status indicates |
| 537 | * failed negotiation. In case of success, this function is responsible |
| 538 | * for creating a new group interface (or using the existing interface |
| 539 | * depending on driver features), setting up the group interface in |
| 540 | * proper mode based on struct p2p_go_neg_results::role_go and |
| 541 | * initializing WPS provisioning either as a Registrar (if GO) or as an |
| 542 | * Enrollee. Successful WPS provisioning must be indicated by calling |
| 543 | * p2p_wps_success_cb(). The callee is responsible for timing out group |
| 544 | * formation if WPS provisioning cannot be completed successfully |
| 545 | * within 15 seconds. |
| 546 | */ |
| 547 | void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res); |
| 548 | |
| 549 | /** |
| 550 | * sd_request - Callback on Service Discovery Request |
| 551 | * @ctx: Callback context from cb_ctx |
| 552 | * @freq: Frequency (in MHz) of the channel |
| 553 | * @sa: Source address of the request |
| 554 | * @dialog_token: Dialog token |
| 555 | * @update_indic: Service Update Indicator from the source of request |
| 556 | * @tlvs: P2P Service Request TLV(s) |
| 557 | * @tlvs_len: Length of tlvs buffer in octets |
| 558 | * |
| 559 | * This callback is used to indicate reception of a service discovery |
| 560 | * request. Response to the query must be indicated by calling |
| 561 | * p2p_sd_response() with the context information from the arguments to |
| 562 | * this callback function. |
| 563 | * |
| 564 | * This callback handler can be set to %NULL to indicate that service |
| 565 | * discovery is not supported. |
| 566 | */ |
| 567 | void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token, |
| 568 | u16 update_indic, const u8 *tlvs, size_t tlvs_len); |
| 569 | |
| 570 | /** |
| 571 | * sd_response - Callback on Service Discovery Response |
| 572 | * @ctx: Callback context from cb_ctx |
| 573 | * @sa: Source address of the request |
| 574 | * @update_indic: Service Update Indicator from the source of response |
| 575 | * @tlvs: P2P Service Response TLV(s) |
| 576 | * @tlvs_len: Length of tlvs buffer in octets |
| 577 | * |
| 578 | * This callback is used to indicate reception of a service discovery |
| 579 | * response. This callback handler can be set to %NULL if no service |
| 580 | * discovery requests are used. The information provided with this call |
| 581 | * is replies to the queries scheduled with p2p_sd_request(). |
| 582 | */ |
| 583 | void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic, |
| 584 | const u8 *tlvs, size_t tlvs_len); |
| 585 | |
| 586 | /** |
| 587 | * prov_disc_req - Callback on Provisiong Discovery Request |
| 588 | * @ctx: Callback context from cb_ctx |
| 589 | * @peer: Source address of the request |
| 590 | * @config_methods: Requested WPS Config Method |
| 591 | * @dev_addr: P2P Device Address of the found P2P Device |
| 592 | * @pri_dev_type: Primary Device Type |
| 593 | * @dev_name: Device Name |
| 594 | * @supp_config_methods: Supported configuration Methods |
| 595 | * @dev_capab: Device Capabilities |
| 596 | * @group_capab: Group Capabilities |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 597 | * @group_id: P2P Group ID (or %NULL if not included) |
| 598 | * @group_id_len: Length of P2P Group ID |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 599 | * |
| 600 | * This callback is used to indicate reception of a Provision Discovery |
| 601 | * Request frame that the P2P module accepted. |
| 602 | */ |
| 603 | void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods, |
| 604 | const u8 *dev_addr, const u8 *pri_dev_type, |
| 605 | const char *dev_name, u16 supp_config_methods, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 606 | u8 dev_capab, u8 group_capab, |
| 607 | const u8 *group_id, size_t group_id_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 608 | |
| 609 | /** |
| 610 | * prov_disc_resp - Callback on Provisiong Discovery Response |
| 611 | * @ctx: Callback context from cb_ctx |
| 612 | * @peer: Source address of the response |
| 613 | * @config_methods: Value from p2p_prov_disc_req() or 0 on failure |
| 614 | * |
| 615 | * This callback is used to indicate reception of a Provision Discovery |
| 616 | * Response frame for a pending request scheduled with |
| 617 | * p2p_prov_disc_req(). This callback handler can be set to %NULL if |
| 618 | * provision discovery is not used. |
| 619 | */ |
| 620 | void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods); |
| 621 | |
| 622 | /** |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 623 | * prov_disc_fail - Callback on Provision Discovery failure |
| 624 | * @ctx: Callback context from cb_ctx |
| 625 | * @peer: Source address of the response |
| 626 | * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS |
| 627 | * |
| 628 | * This callback is used to indicate either a failure or no response |
| 629 | * to an earlier provision discovery request. |
| 630 | * |
| 631 | * This callback handler can be set to %NULL if provision discovery |
| 632 | * is not used or failures do not need to be indicated. |
| 633 | */ |
| 634 | void (*prov_disc_fail)(void *ctx, const u8 *peer, |
| 635 | enum p2p_prov_disc_status status); |
| 636 | |
| 637 | /** |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 638 | * invitation_process - Optional callback for processing Invitations |
| 639 | * @ctx: Callback context from cb_ctx |
| 640 | * @sa: Source address of the Invitation Request |
| 641 | * @bssid: P2P Group BSSID from the request or %NULL if not included |
| 642 | * @go_dev_addr: GO Device Address from P2P Group ID |
| 643 | * @ssid: SSID from P2P Group ID |
| 644 | * @ssid_len: Length of ssid buffer in octets |
| 645 | * @go: Variable for returning whether the local end is GO in the group |
| 646 | * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO) |
| 647 | * @force_freq: Variable for returning forced frequency for the group |
| 648 | * @persistent_group: Whether this is an invitation to reinvoke a |
| 649 | * persistent group (instead of invitation to join an active |
| 650 | * group) |
| 651 | * Returns: Status code (P2P_SC_*) |
| 652 | * |
| 653 | * This optional callback can be used to implement persistent reconnect |
| 654 | * by allowing automatic restarting of persistent groups without user |
| 655 | * interaction. If this callback is not implemented (i.e., is %NULL), |
| 656 | * the received Invitation Request frames are replied with |
| 657 | * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the |
| 658 | * invitation_result() callback. |
| 659 | * |
| 660 | * If the requested parameters are acceptable and the group is known, |
| 661 | * %P2P_SC_SUCCESS may be returned. If the requested group is unknown, |
| 662 | * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED |
| 663 | * can be returned if there is not enough data to provide immediate |
| 664 | * response, i.e., if some sort of user interaction is needed. The |
| 665 | * invitation_received() callback will be called in that case |
| 666 | * immediately after this call. |
| 667 | */ |
| 668 | u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid, |
| 669 | const u8 *go_dev_addr, const u8 *ssid, |
| 670 | size_t ssid_len, int *go, u8 *group_bssid, |
| 671 | int *force_freq, int persistent_group); |
| 672 | |
| 673 | /** |
| 674 | * invitation_received - Callback on Invitation Request RX |
| 675 | * @ctx: Callback context from cb_ctx |
| 676 | * @sa: Source address of the Invitation Request |
| 677 | * @bssid: P2P Group BSSID or %NULL if not received |
| 678 | * @ssid: SSID of the group |
| 679 | * @ssid_len: Length of ssid in octets |
| 680 | * @go_dev_addr: GO Device Address |
| 681 | * @status: Response Status |
| 682 | * @op_freq: Operational frequency for the group |
| 683 | * |
| 684 | * This callback is used to indicate sending of an Invitation Response |
| 685 | * for a received Invitation Request. If status == 0 (success), the |
| 686 | * upper layer code is responsible for starting the group. status == 1 |
| 687 | * indicates need to get user authorization for the group. Other status |
| 688 | * values indicate that the invitation request was rejected. |
| 689 | */ |
| 690 | void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid, |
| 691 | const u8 *ssid, size_t ssid_len, |
| 692 | const u8 *go_dev_addr, u8 status, |
| 693 | int op_freq); |
| 694 | |
| 695 | /** |
| 696 | * invitation_result - Callback on Invitation result |
| 697 | * @ctx: Callback context from cb_ctx |
| 698 | * @status: Negotiation result (Status Code) |
| 699 | * @bssid: P2P Group BSSID or %NULL if not received |
| 700 | * |
| 701 | * This callback is used to indicate result of an Invitation procedure |
| 702 | * started with a call to p2p_invite(). The indicated status code is |
| 703 | * the value received from the peer in Invitation Response with 0 |
| 704 | * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a |
| 705 | * local failure in transmitting the Invitation Request. |
| 706 | */ |
| 707 | void (*invitation_result)(void *ctx, int status, const u8 *bssid); |
| 708 | }; |
| 709 | |
| 710 | |
| 711 | /* P2P module initialization/deinitialization */ |
| 712 | |
| 713 | /** |
| 714 | * p2p_init - Initialize P2P module |
| 715 | * @cfg: P2P module configuration |
| 716 | * Returns: Pointer to private data or %NULL on failure |
| 717 | * |
| 718 | * This function is used to initialize global P2P module context (one per |
| 719 | * device). The P2P module will keep a copy of the configuration data, so the |
| 720 | * caller does not need to maintain this structure. However, the callback |
| 721 | * functions and the context parameters to them must be kept available until |
| 722 | * the P2P module is deinitialized with p2p_deinit(). |
| 723 | */ |
| 724 | struct p2p_data * p2p_init(const struct p2p_config *cfg); |
| 725 | |
| 726 | /** |
| 727 | * p2p_deinit - Deinitialize P2P module |
| 728 | * @p2p: P2P module context from p2p_init() |
| 729 | */ |
| 730 | void p2p_deinit(struct p2p_data *p2p); |
| 731 | |
| 732 | /** |
| 733 | * p2p_flush - Flush P2P module state |
| 734 | * @p2p: P2P module context from p2p_init() |
| 735 | * |
| 736 | * This command removes the P2P module state like peer device entries. |
| 737 | */ |
| 738 | void p2p_flush(struct p2p_data *p2p); |
| 739 | |
| 740 | /** |
| 741 | * p2p_unauthorize - Unauthorize the specified peer device |
| 742 | * @p2p: P2P module context from p2p_init() |
| 743 | * @addr: P2P peer entry to be unauthorized |
| 744 | * Returns: 0 on success, -1 on failure |
| 745 | * |
| 746 | * This command removes any connection authorization from the specified P2P |
| 747 | * peer device address. This can be used, e.g., to cancel effect of a previous |
| 748 | * p2p_authorize() or p2p_connect() call that has not yet resulted in completed |
| 749 | * GO Negotiation. |
| 750 | */ |
| 751 | int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr); |
| 752 | |
| 753 | /** |
| 754 | * p2p_set_dev_name - Set device name |
| 755 | * @p2p: P2P module context from p2p_init() |
| 756 | * Returns: 0 on success, -1 on failure |
| 757 | * |
| 758 | * This function can be used to update the P2P module configuration with |
| 759 | * information that was not available at the time of the p2p_init() call. |
| 760 | */ |
| 761 | int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name); |
| 762 | |
| 763 | int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer); |
| 764 | int p2p_set_model_name(struct p2p_data *p2p, const char *model_name); |
| 765 | int p2p_set_model_number(struct p2p_data *p2p, const char *model_number); |
| 766 | int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number); |
| 767 | |
| 768 | void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods); |
| 769 | void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid); |
| 770 | |
| 771 | /** |
| 772 | * p2p_set_pri_dev_type - Set primary device type |
| 773 | * @p2p: P2P module context from p2p_init() |
| 774 | * Returns: 0 on success, -1 on failure |
| 775 | * |
| 776 | * This function can be used to update the P2P module configuration with |
| 777 | * information that was not available at the time of the p2p_init() call. |
| 778 | */ |
| 779 | int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type); |
| 780 | |
| 781 | /** |
| 782 | * p2p_set_sec_dev_types - Set secondary device types |
| 783 | * @p2p: P2P module context from p2p_init() |
| 784 | * Returns: 0 on success, -1 on failure |
| 785 | * |
| 786 | * This function can be used to update the P2P module configuration with |
| 787 | * information that was not available at the time of the p2p_init() call. |
| 788 | */ |
| 789 | int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8], |
| 790 | size_t num_dev_types); |
| 791 | |
| 792 | int p2p_set_country(struct p2p_data *p2p, const char *country); |
| 793 | |
| 794 | |
| 795 | /* Commands from upper layer management entity */ |
| 796 | |
| 797 | enum p2p_discovery_type { |
| 798 | P2P_FIND_START_WITH_FULL, |
| 799 | P2P_FIND_ONLY_SOCIAL, |
| 800 | P2P_FIND_PROGRESSIVE |
| 801 | }; |
| 802 | |
| 803 | /** |
| 804 | * p2p_find - Start P2P Find (Device Discovery) |
| 805 | * @p2p: P2P module context from p2p_init() |
| 806 | * @timeout: Timeout for find operation in seconds or 0 for no timeout |
| 807 | * @type: Device Discovery type |
| 808 | * @num_req_dev_types: Number of requested device types |
| 809 | * @req_dev_types: Requested device types array, must be an array |
| 810 | * containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no |
| 811 | * requested device types. |
| 812 | * Returns: 0 on success, -1 on failure |
| 813 | */ |
| 814 | int p2p_find(struct p2p_data *p2p, unsigned int timeout, |
| 815 | enum p2p_discovery_type type, |
| 816 | unsigned int num_req_dev_types, const u8 *req_dev_types); |
| 817 | |
| 818 | /** |
| 819 | * p2p_stop_find - Stop P2P Find (Device Discovery) |
| 820 | * @p2p: P2P module context from p2p_init() |
| 821 | */ |
| 822 | void p2p_stop_find(struct p2p_data *p2p); |
| 823 | |
| 824 | /** |
| 825 | * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq |
| 826 | * @p2p: P2P module context from p2p_init() |
| 827 | * @freq: Frequency in MHz for next operation |
| 828 | * |
| 829 | * This is like p2p_stop_find(), but Listen state is not stopped if we are |
| 830 | * already on the same frequency. |
| 831 | */ |
| 832 | void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq); |
| 833 | |
| 834 | /** |
| 835 | * p2p_listen - Start P2P Listen state for specified duration |
| 836 | * @p2p: P2P module context from p2p_init() |
| 837 | * @timeout: Listen state duration in milliseconds |
| 838 | * Returns: 0 on success, -1 on failure |
| 839 | * |
| 840 | * This function can be used to request the P2P module to keep the device |
| 841 | * discoverable on the listen channel for an extended set of time. At least in |
| 842 | * its current form, this is mainly used for testing purposes and may not be of |
| 843 | * much use for normal P2P operations. |
| 844 | */ |
| 845 | int p2p_listen(struct p2p_data *p2p, unsigned int timeout); |
| 846 | |
| 847 | /** |
| 848 | * p2p_connect - Start P2P group formation (GO negotiation) |
| 849 | * @p2p: P2P module context from p2p_init() |
| 850 | * @peer_addr: MAC address of the peer P2P client |
| 851 | * @wps_method: WPS method to be used in provisioning |
| 852 | * @go_intent: Local GO intent value (1..15) |
| 853 | * @own_interface_addr: Intended interface address to use with the group |
| 854 | * @force_freq: The only allowed channel frequency in MHz or 0 |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 855 | * @persistent_group: Whether to create a persistent group (0 = no, 1 = |
| 856 | * persistent group without persistent reconnect, 2 = persistent group with |
| 857 | * persistent reconnect) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 858 | * Returns: 0 on success, -1 on failure |
| 859 | */ |
| 860 | int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr, |
| 861 | enum p2p_wps_method wps_method, |
| 862 | int go_intent, const u8 *own_interface_addr, |
| 863 | unsigned int force_freq, int persistent_group); |
| 864 | |
| 865 | /** |
| 866 | * p2p_authorize - Authorize P2P group formation (GO negotiation) |
| 867 | * @p2p: P2P module context from p2p_init() |
| 868 | * @peer_addr: MAC address of the peer P2P client |
| 869 | * @wps_method: WPS method to be used in provisioning |
| 870 | * @go_intent: Local GO intent value (1..15) |
| 871 | * @own_interface_addr: Intended interface address to use with the group |
| 872 | * @force_freq: The only allowed channel frequency in MHz or 0 |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 873 | * @persistent_group: Whether to create a persistent group (0 = no, 1 = |
| 874 | * persistent group without persistent reconnect, 2 = persistent group with |
| 875 | * persistent reconnect) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 876 | * Returns: 0 on success, -1 on failure |
| 877 | * |
| 878 | * This is like p2p_connect(), but the actual group negotiation is not |
| 879 | * initiated automatically, i.e., the other end is expected to do that. |
| 880 | */ |
| 881 | int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr, |
| 882 | enum p2p_wps_method wps_method, |
| 883 | int go_intent, const u8 *own_interface_addr, |
| 884 | unsigned int force_freq, int persistent_group); |
| 885 | |
| 886 | /** |
| 887 | * p2p_reject - Reject peer device (explicitly block connection attempts) |
| 888 | * @p2p: P2P module context from p2p_init() |
| 889 | * @peer_addr: MAC address of the peer P2P client |
| 890 | * Returns: 0 on success, -1 on failure |
| 891 | */ |
| 892 | int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr); |
| 893 | |
| 894 | /** |
| 895 | * p2p_prov_disc_req - Send Provision Discovery Request |
| 896 | * @p2p: P2P module context from p2p_init() |
| 897 | * @peer_addr: MAC address of the peer P2P client |
| 898 | * @config_methods: WPS Config Methods value (only one bit set) |
| 899 | * @join: Whether this is used by a client joining an active group |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 900 | * @force_freq: Forced TX frequency for the frame (mainly for the join case) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 901 | * Returns: 0 on success, -1 on failure |
| 902 | * |
| 903 | * This function can be used to request a discovered P2P peer to display a PIN |
| 904 | * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us |
| 905 | * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame |
| 906 | * is transmitted once immediately and if no response is received, the frame |
| 907 | * will be sent again whenever the target device is discovered during device |
| 908 | * dsicovery (start with a p2p_find() call). Response from the peer is |
| 909 | * indicated with the p2p_config::prov_disc_resp() callback. |
| 910 | */ |
| 911 | int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 912 | u16 config_methods, int join, int force_freq); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 913 | |
| 914 | /** |
| 915 | * p2p_sd_request - Schedule a service discovery query |
| 916 | * @p2p: P2P module context from p2p_init() |
| 917 | * @dst: Destination peer or %NULL to apply for all peers |
| 918 | * @tlvs: P2P Service Query TLV(s) |
| 919 | * Returns: Reference to the query or %NULL on failure |
| 920 | * |
| 921 | * Response to the query is indicated with the p2p_config::sd_response() |
| 922 | * callback. |
| 923 | */ |
| 924 | void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst, |
| 925 | const struct wpabuf *tlvs); |
| 926 | |
| 927 | /** |
| 928 | * p2p_sd_cancel_request - Cancel a pending service discovery query |
| 929 | * @p2p: P2P module context from p2p_init() |
| 930 | * @req: Query reference from p2p_sd_request() |
| 931 | * Returns: 0 if request for cancelled; -1 if not found |
| 932 | */ |
| 933 | int p2p_sd_cancel_request(struct p2p_data *p2p, void *req); |
| 934 | |
| 935 | /** |
| 936 | * p2p_sd_response - Send response to a service discovery query |
| 937 | * @p2p: P2P module context from p2p_init() |
| 938 | * @freq: Frequency from p2p_config::sd_request() callback |
| 939 | * @dst: Destination address from p2p_config::sd_request() callback |
| 940 | * @dialog_token: Dialog token from p2p_config::sd_request() callback |
| 941 | * @resp_tlvs: P2P Service Response TLV(s) |
| 942 | * |
| 943 | * This function is called as a response to the request indicated with |
| 944 | * p2p_config::sd_request() callback. |
| 945 | */ |
| 946 | void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst, |
| 947 | u8 dialog_token, const struct wpabuf *resp_tlvs); |
| 948 | |
| 949 | /** |
| 950 | * p2p_sd_service_update - Indicate a change in local services |
| 951 | * @p2p: P2P module context from p2p_init() |
| 952 | * |
| 953 | * This function needs to be called whenever there is a change in availability |
| 954 | * of the local services. This will increment the Service Update Indicator |
| 955 | * value which will be used in SD Request and Response frames. |
| 956 | */ |
| 957 | void p2p_sd_service_update(struct p2p_data *p2p); |
| 958 | |
| 959 | |
| 960 | enum p2p_invite_role { |
| 961 | P2P_INVITE_ROLE_GO, |
| 962 | P2P_INVITE_ROLE_ACTIVE_GO, |
| 963 | P2P_INVITE_ROLE_CLIENT |
| 964 | }; |
| 965 | |
| 966 | /** |
| 967 | * p2p_invite - Invite a P2P Device into a group |
| 968 | * @p2p: P2P module context from p2p_init() |
| 969 | * @peer: Device Address of the peer P2P Device |
| 970 | * @role: Local role in the group |
| 971 | * @bssid: Group BSSID or %NULL if not known |
| 972 | * @ssid: Group SSID |
| 973 | * @ssid_len: Length of ssid in octets |
| 974 | * @force_freq: The only allowed channel frequency in MHz or 0 |
| 975 | * @go_dev_addr: Forced GO Device Address or %NULL if none |
| 976 | * @persistent_group: Whether this is to reinvoke a persistent group |
| 977 | * Returns: 0 on success, -1 on failure |
| 978 | */ |
| 979 | int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role, |
| 980 | const u8 *bssid, const u8 *ssid, size_t ssid_len, |
| 981 | unsigned int force_freq, const u8 *go_dev_addr, |
| 982 | int persistent_group); |
| 983 | |
| 984 | /** |
| 985 | * p2p_presence_req - Request GO presence |
| 986 | * @p2p: P2P module context from p2p_init() |
| 987 | * @go_interface_addr: GO P2P Interface Address |
| 988 | * @own_interface_addr: Own P2P Interface Address for this group |
| 989 | * @freq: Group operating frequence (in MHz) |
| 990 | * @duration1: Preferred presence duration in microseconds |
| 991 | * @interval1: Preferred presence interval in microseconds |
| 992 | * @duration2: Acceptable presence duration in microseconds |
| 993 | * @interval2: Acceptable presence interval in microseconds |
| 994 | * Returns: 0 on success, -1 on failure |
| 995 | * |
| 996 | * If both duration and interval values are zero, the parameter pair is not |
| 997 | * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0). |
| 998 | */ |
| 999 | int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr, |
| 1000 | const u8 *own_interface_addr, unsigned int freq, |
| 1001 | u32 duration1, u32 interval1, u32 duration2, |
| 1002 | u32 interval2); |
| 1003 | |
| 1004 | /** |
| 1005 | * p2p_ext_listen - Set Extended Listen Timing |
| 1006 | * @p2p: P2P module context from p2p_init() |
| 1007 | * @freq: Group operating frequence (in MHz) |
| 1008 | * @period: Availability period in milliseconds (1-65535; 0 to disable) |
| 1009 | * @interval: Availability interval in milliseconds (1-65535; 0 to disable) |
| 1010 | * Returns: 0 on success, -1 on failure |
| 1011 | * |
| 1012 | * This function can be used to enable or disable (period = interval = 0) |
| 1013 | * Extended Listen Timing. When enabled, the P2P Device will become |
| 1014 | * discoverable (go into Listen State) every @interval milliseconds for at |
| 1015 | * least @period milliseconds. |
| 1016 | */ |
| 1017 | int p2p_ext_listen(struct p2p_data *p2p, unsigned int period, |
| 1018 | unsigned int interval); |
| 1019 | |
| 1020 | /* Event notifications from upper layer management operations */ |
| 1021 | |
| 1022 | /** |
| 1023 | * p2p_wps_success_cb - Report successfully completed WPS provisioning |
| 1024 | * @p2p: P2P module context from p2p_init() |
| 1025 | * @mac_addr: Peer address |
| 1026 | * |
| 1027 | * This function is used to report successfully completed WPS provisioning |
| 1028 | * during group formation in both GO/Registrar and client/Enrollee roles. |
| 1029 | */ |
| 1030 | void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr); |
| 1031 | |
| 1032 | /** |
| 1033 | * p2p_group_formation_failed - Report failed WPS provisioning |
| 1034 | * @p2p: P2P module context from p2p_init() |
| 1035 | * |
| 1036 | * This function is used to report failed group formation. This can happen |
| 1037 | * either due to failed WPS provisioning or due to 15 second timeout during |
| 1038 | * the provisioning phase. |
| 1039 | */ |
| 1040 | void p2p_group_formation_failed(struct p2p_data *p2p); |
| 1041 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1042 | /** |
| 1043 | * p2p_get_provisioning_info - Get any stored provisioning info |
| 1044 | * @p2p: P2P module context from p2p_init() |
| 1045 | * @addr: Peer P2P Device Address |
| 1046 | * Returns: WPS provisioning information (WPS config method) or 0 if no |
| 1047 | * information is available |
| 1048 | * |
| 1049 | * This function is used to retrieve stored WPS provisioning info for the given |
| 1050 | * peer. |
| 1051 | */ |
| 1052 | u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr); |
| 1053 | |
| 1054 | /** |
| 1055 | * p2p_clear_provisioning_info - Clear any stored provisioning info |
| 1056 | * @p2p: P2P module context from p2p_init() |
| 1057 | * @iface_addr: Peer P2P Interface Address |
| 1058 | * |
| 1059 | * This function is used to clear stored WPS provisioning info for the given |
| 1060 | * peer. |
| 1061 | */ |
| 1062 | void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *iface_addr); |
| 1063 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1064 | |
| 1065 | /* Event notifications from lower layer driver operations */ |
| 1066 | |
| 1067 | /** |
| 1068 | * p2p_probe_req_rx - Report reception of a Probe Request frame |
| 1069 | * @p2p: P2P module context from p2p_init() |
| 1070 | * @addr: Source MAC address |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1071 | * @dst: Destination MAC address if available or %NULL |
| 1072 | * @bssid: BSSID if available or %NULL |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1073 | * @ie: Information elements from the Probe Request frame body |
| 1074 | * @ie_len: Length of ie buffer in octets |
| 1075 | * Returns: 0 to indicate the frame was not processed or 1 if it was |
| 1076 | */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1077 | int p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, |
| 1078 | const u8 *bssid, const u8 *ie, size_t ie_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1079 | |
| 1080 | /** |
| 1081 | * p2p_rx_action - Report received Action frame |
| 1082 | * @p2p: P2P module context from p2p_init() |
| 1083 | * @da: Destination address of the received Action frame |
| 1084 | * @sa: Source address of the received Action frame |
| 1085 | * @bssid: Address 3 of the received Action frame |
| 1086 | * @category: Category of the received Action frame |
| 1087 | * @data: Action frame body after the Category field |
| 1088 | * @len: Length of the data buffer in octets |
| 1089 | * @freq: Frequency (in MHz) on which the frame was received |
| 1090 | */ |
| 1091 | void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa, |
| 1092 | const u8 *bssid, u8 category, |
| 1093 | const u8 *data, size_t len, int freq); |
| 1094 | |
| 1095 | /** |
| 1096 | * p2p_scan_res_handler - Indicate a P2P scan results |
| 1097 | * @p2p: P2P module context from p2p_init() |
| 1098 | * @bssid: BSSID of the scan result |
| 1099 | * @freq: Frequency of the channel on which the device was found in MHz |
| 1100 | * @level: Signal level (signal strength of the received Beacon/Probe Response |
| 1101 | * frame) |
| 1102 | * @ies: Pointer to IEs from the scan result |
| 1103 | * @ies_len: Length of the ies buffer |
| 1104 | * Returns: 0 to continue or 1 to stop scan result indication |
| 1105 | * |
| 1106 | * This function is called to indicate a scan result entry with P2P IE from a |
| 1107 | * scan requested with struct p2p_config::p2p_scan(). This can be called during |
| 1108 | * the actual scan process (i.e., whenever a new device is found) or as a |
| 1109 | * sequence of calls after the full scan has been completed. The former option |
| 1110 | * can result in optimized operations, but may not be supported by all |
| 1111 | * driver/firmware designs. The ies buffer need to include at least the P2P IE, |
| 1112 | * but it is recommended to include all IEs received from the device. The |
| 1113 | * caller does not need to check that the IEs contain a P2P IE before calling |
| 1114 | * this function since frames will be filtered internally if needed. |
| 1115 | * |
| 1116 | * This function will return 1 if it wants to stop scan result iteration (and |
| 1117 | * scan in general if it is still in progress). This is used to allow faster |
| 1118 | * start of a pending operation, e.g., to start a pending GO negotiation. |
| 1119 | */ |
| 1120 | int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq, |
| 1121 | int level, const u8 *ies, size_t ies_len); |
| 1122 | |
| 1123 | /** |
| 1124 | * p2p_scan_res_handled - Indicate end of scan results |
| 1125 | * @p2p: P2P module context from p2p_init() |
| 1126 | * |
| 1127 | * This function is called to indicate that all P2P scan results from a scan |
| 1128 | * have been reported with zero or more calls to p2p_scan_res_handler(). This |
| 1129 | * function must be called as a response to successful |
| 1130 | * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler() |
| 1131 | * calls stopped iteration. |
| 1132 | */ |
| 1133 | void p2p_scan_res_handled(struct p2p_data *p2p); |
| 1134 | |
| 1135 | enum p2p_send_action_result { |
| 1136 | P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */, |
| 1137 | P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */, |
| 1138 | P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */ |
| 1139 | }; |
| 1140 | |
| 1141 | /** |
| 1142 | * p2p_send_action_cb - Notify TX status of an Action frame |
| 1143 | * @p2p: P2P module context from p2p_init() |
| 1144 | * @freq: Channel frequency in MHz |
| 1145 | * @dst: Destination MAC address (Address 1) |
| 1146 | * @src: Source MAC address (Address 2) |
| 1147 | * @bssid: BSSID (Address 3) |
| 1148 | * @result: Result of the transmission attempt |
| 1149 | * |
| 1150 | * This function is used to indicate the result of an Action frame transmission |
| 1151 | * that was requested with struct p2p_config::send_action() callback. |
| 1152 | */ |
| 1153 | void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst, |
| 1154 | const u8 *src, const u8 *bssid, |
| 1155 | enum p2p_send_action_result result); |
| 1156 | |
| 1157 | /** |
| 1158 | * p2p_listen_cb - Indicate the start of a requested Listen state |
| 1159 | * @p2p: P2P module context from p2p_init() |
| 1160 | * @freq: Listen channel frequency in MHz |
| 1161 | * @duration: Duration for the Listen state in milliseconds |
| 1162 | * |
| 1163 | * This function is used to indicate that a Listen state requested with |
| 1164 | * struct p2p_config::start_listen() callback has started. |
| 1165 | */ |
| 1166 | void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq, |
| 1167 | unsigned int duration); |
| 1168 | |
| 1169 | /** |
| 1170 | * p2p_listen_end - Indicate the end of a requested Listen state |
| 1171 | * @p2p: P2P module context from p2p_init() |
| 1172 | * @freq: Listen channel frequency in MHz |
| 1173 | * Returns: 0 if no operations were started, 1 if an operation was started |
| 1174 | * |
| 1175 | * This function is used to indicate that a Listen state requested with |
| 1176 | * struct p2p_config::start_listen() callback has ended. |
| 1177 | */ |
| 1178 | int p2p_listen_end(struct p2p_data *p2p, unsigned int freq); |
| 1179 | |
| 1180 | void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, |
| 1181 | const u8 *ie, size_t ie_len); |
| 1182 | |
| 1183 | void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code, |
| 1184 | const u8 *ie, size_t ie_len); |
| 1185 | |
| 1186 | |
| 1187 | /* Per-group P2P state for GO */ |
| 1188 | |
| 1189 | struct p2p_group; |
| 1190 | |
| 1191 | /** |
| 1192 | * struct p2p_group_config - P2P group configuration |
| 1193 | * |
| 1194 | * This configuration is provided to the P2P module during initialization of |
| 1195 | * the per-group information with p2p_group_init(). |
| 1196 | */ |
| 1197 | struct p2p_group_config { |
| 1198 | /** |
| 1199 | * persistent_group - Whether the group is persistent |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1200 | * 0 = not a persistent group |
| 1201 | * 1 = persistent group without persistent reconnect |
| 1202 | * 2 = persistent group with persistent reconnect |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1203 | */ |
| 1204 | int persistent_group; |
| 1205 | |
| 1206 | /** |
| 1207 | * interface_addr - P2P Interface Address of the group |
| 1208 | */ |
| 1209 | u8 interface_addr[ETH_ALEN]; |
| 1210 | |
| 1211 | /** |
| 1212 | * max_clients - Maximum number of clients in the group |
| 1213 | */ |
| 1214 | unsigned int max_clients; |
| 1215 | |
| 1216 | /** |
| 1217 | * cb_ctx - Context to use with callback functions |
| 1218 | */ |
| 1219 | void *cb_ctx; |
| 1220 | |
| 1221 | /** |
| 1222 | * ie_update - Notification of IE update |
| 1223 | * @ctx: Callback context from cb_ctx |
| 1224 | * @beacon_ies: P2P IE for Beacon frames or %NULL if no change |
| 1225 | * @proberesp_ies: P2P Ie for Probe Response frames |
| 1226 | * |
| 1227 | * P2P module uses this callback function to notify whenever the P2P IE |
| 1228 | * in Beacon or Probe Response frames should be updated based on group |
| 1229 | * events. |
| 1230 | * |
| 1231 | * The callee is responsible for freeing the returned buffer(s) with |
| 1232 | * wpabuf_free(). |
| 1233 | */ |
| 1234 | void (*ie_update)(void *ctx, struct wpabuf *beacon_ies, |
| 1235 | struct wpabuf *proberesp_ies); |
| 1236 | |
| 1237 | /** |
| 1238 | * idle_update - Notification of changes in group idle state |
| 1239 | * @ctx: Callback context from cb_ctx |
| 1240 | * @idle: Whether the group is idle (no associated stations) |
| 1241 | */ |
| 1242 | void (*idle_update)(void *ctx, int idle); |
| 1243 | }; |
| 1244 | |
| 1245 | /** |
| 1246 | * p2p_group_init - Initialize P2P group |
| 1247 | * @p2p: P2P module context from p2p_init() |
| 1248 | * @config: P2P group configuration (will be freed by p2p_group_deinit()) |
| 1249 | * Returns: Pointer to private data or %NULL on failure |
| 1250 | * |
| 1251 | * This function is used to initialize per-group P2P module context. Currently, |
| 1252 | * this is only used to manage GO functionality and P2P clients do not need to |
| 1253 | * create an instance of this per-group information. |
| 1254 | */ |
| 1255 | struct p2p_group * p2p_group_init(struct p2p_data *p2p, |
| 1256 | struct p2p_group_config *config); |
| 1257 | |
| 1258 | /** |
| 1259 | * p2p_group_deinit - Deinitialize P2P group |
| 1260 | * @group: P2P group context from p2p_group_init() |
| 1261 | */ |
| 1262 | void p2p_group_deinit(struct p2p_group *group); |
| 1263 | |
| 1264 | /** |
| 1265 | * p2p_group_notif_assoc - Notification of P2P client association with GO |
| 1266 | * @group: P2P group context from p2p_group_init() |
| 1267 | * @addr: Interface address of the P2P client |
| 1268 | * @ie: IEs from the (Re)association Request frame |
| 1269 | * @len: Length of the ie buffer in octets |
| 1270 | * Returns: 0 on success, -1 on failure |
| 1271 | */ |
| 1272 | int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr, |
| 1273 | const u8 *ie, size_t len); |
| 1274 | |
| 1275 | /** |
| 1276 | * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response |
| 1277 | * @group: P2P group context from p2p_group_init() |
| 1278 | * @status: Status value (P2P_SC_SUCCESS if association succeeded) |
| 1279 | * Returns: P2P IE for (Re)association Response or %NULL on failure |
| 1280 | * |
| 1281 | * The caller is responsible for freeing the returned buffer with |
| 1282 | * wpabuf_free(). |
| 1283 | */ |
| 1284 | struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status); |
| 1285 | |
| 1286 | /** |
| 1287 | * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO |
| 1288 | * @group: P2P group context from p2p_group_init() |
| 1289 | * @addr: Interface address of the P2P client |
| 1290 | */ |
| 1291 | void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr); |
| 1292 | |
| 1293 | /** |
| 1294 | * p2p_group_notif_formation_done - Notification of completed group formation |
| 1295 | * @group: P2P group context from p2p_group_init() |
| 1296 | */ |
| 1297 | void p2p_group_notif_formation_done(struct p2p_group *group); |
| 1298 | |
| 1299 | /** |
| 1300 | * p2p_group_notif_noa - Notification of NoA change |
| 1301 | * @group: P2P group context from p2p_group_init() |
| 1302 | * @noa: Notice of Absence attribute payload, %NULL if none |
| 1303 | * @noa_len: Length of noa buffer in octets |
| 1304 | * Returns: 0 on success, -1 on failure |
| 1305 | * |
| 1306 | * Notify the P2P group management about a new NoA contents. This will be |
| 1307 | * inserted into the P2P IEs in Beacon and Probe Response frames with rest of |
| 1308 | * the group information. |
| 1309 | */ |
| 1310 | int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, |
| 1311 | size_t noa_len); |
| 1312 | |
| 1313 | /** |
| 1314 | * p2p_group_match_dev_type - Match device types in group with requested type |
| 1315 | * @group: P2P group context from p2p_group_init() |
| 1316 | * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs) |
| 1317 | * Returns: 1 on match, 0 on mismatch |
| 1318 | * |
| 1319 | * This function can be used to match the Requested Device Type attribute in |
| 1320 | * WPS IE with the device types of a group member for deciding whether a GO |
| 1321 | * should reply to a Probe Request frame. Match will be reported if the WPS IE |
| 1322 | * is not requested any specific device type. |
| 1323 | */ |
| 1324 | int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps); |
| 1325 | |
| 1326 | /** |
| 1327 | * p2p_group_go_discover - Send GO Discoverability Request to a group client |
| 1328 | * @group: P2P group context from p2p_group_init() |
| 1329 | * Returns: 0 on success (frame scheduled); -1 if client was not found |
| 1330 | */ |
| 1331 | int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id, |
| 1332 | const u8 *searching_dev, int rx_freq); |
| 1333 | |
| 1334 | |
| 1335 | /* Generic helper functions */ |
| 1336 | |
| 1337 | /** |
| 1338 | * p2p_ie_text - Build text format description of P2P IE |
| 1339 | * @p2p_ie: P2P IE |
| 1340 | * @buf: Buffer for returning text |
| 1341 | * @end: Pointer to the end of the buf area |
| 1342 | * Returns: Number of octets written to the buffer or -1 on failure |
| 1343 | * |
| 1344 | * This function can be used to parse P2P IE contents into text format |
| 1345 | * field=value lines. |
| 1346 | */ |
| 1347 | int p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end); |
| 1348 | |
| 1349 | /** |
| 1350 | * p2p_scan_result_text - Build text format description of P2P IE |
| 1351 | * @ies: Information elements from scan results |
| 1352 | * @ies_len: ies buffer length in octets |
| 1353 | * @buf: Buffer for returning text |
| 1354 | * @end: Pointer to the end of the buf area |
| 1355 | * Returns: Number of octets written to the buffer or -1 on failure |
| 1356 | * |
| 1357 | * This function can be used to parse P2P IE contents into text format |
| 1358 | * field=value lines. |
| 1359 | */ |
| 1360 | int p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end); |
| 1361 | |
| 1362 | /** |
| 1363 | * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame |
| 1364 | * @p2p: P2P module context from p2p_init() |
| 1365 | * @bssid: BSSID |
| 1366 | * @buf: Buffer for writing the P2P IE |
| 1367 | * @len: Maximum buf length in octets |
| 1368 | * @p2p_group: Whether this is for association with a P2P GO |
| 1369 | * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none |
| 1370 | * Returns: Number of octets written into buf or -1 on failure |
| 1371 | */ |
| 1372 | int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf, |
| 1373 | size_t len, int p2p_group, struct wpabuf *p2p_ie); |
| 1374 | |
| 1375 | /** |
| 1376 | * p2p_scan_ie - Build P2P IE for Probe Request |
| 1377 | * @p2p: P2P module context from p2p_init() |
| 1378 | * @ies: Buffer for writing P2P IE |
| 1379 | */ |
| 1380 | void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies); |
| 1381 | |
| 1382 | /** |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1383 | * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie |
| 1384 | * @p2p: P2P module context from p2p_init() |
| 1385 | * Returns: Number of octets that p2p_scan_ie() may add to the buffer |
| 1386 | */ |
| 1387 | size_t p2p_scan_ie_buf_len(struct p2p_data *p2p); |
| 1388 | |
| 1389 | /** |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1390 | * p2p_go_params - Generate random P2P group parameters |
| 1391 | * @p2p: P2P module context from p2p_init() |
| 1392 | * @params: Buffer for parameters |
| 1393 | * Returns: 0 on success, -1 on failure |
| 1394 | */ |
| 1395 | int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params); |
| 1396 | |
| 1397 | /** |
| 1398 | * p2p_get_group_capab - Get Group Capability from P2P IE data |
| 1399 | * @p2p_ie: P2P IE(s) contents |
| 1400 | * Returns: Group Capability |
| 1401 | */ |
| 1402 | u8 p2p_get_group_capab(const struct wpabuf *p2p_ie); |
| 1403 | |
| 1404 | /** |
| 1405 | * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection |
| 1406 | * @p2p_ie: P2P IE(s) contents |
| 1407 | * Returns: 0 if cross connection is allow, 1 if not |
| 1408 | */ |
| 1409 | int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie); |
| 1410 | |
| 1411 | /** |
| 1412 | * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data |
| 1413 | * @p2p_ie: P2P IE(s) contents |
| 1414 | * Returns: Pointer to P2P Device Address or %NULL if not included |
| 1415 | */ |
| 1416 | const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie); |
| 1417 | |
| 1418 | /** |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1419 | * p2p_get_peer_info - Get P2P peer information |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1420 | * @p2p: P2P module context from p2p_init() |
| 1421 | * @addr: P2P Device Address of the peer or %NULL to indicate the first peer |
| 1422 | * @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] | 1423 | * Returns: Pointer to peer info or %NULL if not found |
| 1424 | */ |
| 1425 | const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p, |
| 1426 | const u8 *addr, int next); |
| 1427 | |
| 1428 | /** |
| 1429 | * p2p_get_peer_info_txt - Get internal P2P peer information in text format |
| 1430 | * @info: Pointer to P2P peer info from p2p_get_peer_info() |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1431 | * @buf: Buffer for returning text |
| 1432 | * @buflen: Maximum buffer length |
| 1433 | * Returns: Number of octets written to the buffer or -1 on failure |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1434 | * |
| 1435 | * Note: This information is internal to the P2P module and subject to change. |
| 1436 | * As such, this should not really be used by external programs for purposes |
| 1437 | * other than debugging. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1438 | */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1439 | int p2p_get_peer_info_txt(const struct p2p_peer_info *info, |
| 1440 | char *buf, size_t buflen); |
| 1441 | |
| 1442 | /** |
| 1443 | * p2p_peer_known - Check whether P2P peer is known |
| 1444 | * @p2p: P2P module context from p2p_init() |
| 1445 | * @addr: P2P Device Address of the peer |
| 1446 | * Returns: 1 if the specified device is in the P2P peer table or 0 if not |
| 1447 | */ |
| 1448 | int p2p_peer_known(struct p2p_data *p2p, const u8 *addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1449 | |
| 1450 | /** |
| 1451 | * p2p_set_client_discoverability - Set client discoverability capability |
| 1452 | * @p2p: P2P module context from p2p_init() |
| 1453 | * @enabled: Whether client discoverability will be enabled |
| 1454 | * |
| 1455 | * This function can be used to disable (and re-enable) client discoverability. |
| 1456 | * This capability is enabled by default and should not be disabled in normal |
| 1457 | * use cases, i.e., this is mainly for testing purposes. |
| 1458 | */ |
| 1459 | void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled); |
| 1460 | |
| 1461 | /** |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1462 | * p2p_set_managed_oper - Set managed P2P Device operations capability |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1463 | * @p2p: P2P module context from p2p_init() |
| 1464 | * @enabled: Whether managed P2P Device operations will be enabled |
| 1465 | */ |
| 1466 | void p2p_set_managed_oper(struct p2p_data *p2p, int enabled); |
| 1467 | |
| 1468 | int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel); |
| 1469 | |
| 1470 | int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len); |
| 1471 | |
| 1472 | int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr, |
| 1473 | u8 *iface_addr); |
| 1474 | int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr, |
| 1475 | u8 *dev_addr); |
| 1476 | |
| 1477 | void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr); |
| 1478 | |
| 1479 | /** |
| 1480 | * p2p_set_cross_connect - Set cross connection capability |
| 1481 | * @p2p: P2P module context from p2p_init() |
| 1482 | * @enabled: Whether cross connection will be enabled |
| 1483 | */ |
| 1484 | void p2p_set_cross_connect(struct p2p_data *p2p, int enabled); |
| 1485 | |
| 1486 | int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr); |
| 1487 | |
| 1488 | int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq, int level, |
| 1489 | const u8 *ies, size_t ies_len); |
| 1490 | |
| 1491 | /** |
| 1492 | * p2p_set_intra_bss_dist - Set intra BSS distribution |
| 1493 | * @p2p: P2P module context from p2p_init() |
| 1494 | * @enabled: Whether intra BSS distribution will be enabled |
| 1495 | */ |
| 1496 | void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled); |
| 1497 | |
| 1498 | /** |
| 1499 | * p2p_supported_freq - Check whether channel is supported for P2P |
| 1500 | * @p2p: P2P module context from p2p_init() |
| 1501 | * @freq: Channel frequency in MHz |
| 1502 | * Returns: 0 if channel not usable for P2P, 1 if usable for P2P |
| 1503 | */ |
| 1504 | int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq); |
| 1505 | |
| 1506 | void p2p_update_channel_list(struct p2p_data *p2p, struct p2p_channels *chan); |
| 1507 | |
| 1508 | /** |
| 1509 | * p2p_set_best_channels - Update best channel information |
| 1510 | * @p2p: P2P module context from p2p_init() |
| 1511 | * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band |
| 1512 | * @freq_5: Frequency (MHz) of best channel in 5 GHz band |
| 1513 | * @freq_overall: Frequency (MHz) of best channel overall |
| 1514 | */ |
| 1515 | void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5, |
| 1516 | int freq_overall); |
| 1517 | |
| 1518 | const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p); |
| 1519 | |
| 1520 | /** |
| 1521 | * p2p_get_group_num_members - Get number of members in group |
| 1522 | * @group: P2P group context from p2p_group_init() |
| 1523 | * Returns: Number of members in the group |
| 1524 | */ |
| 1525 | unsigned int p2p_get_group_num_members(struct p2p_group *group); |
| 1526 | |
| 1527 | /** |
| 1528 | * p2p_iterate_group_members - Iterate group members |
| 1529 | * @group: P2P group context from p2p_group_init() |
| 1530 | * @next: iteration pointer, must be a pointer to a void * that is set to %NULL |
| 1531 | * on the first call and not modified later |
| 1532 | * Returns: A P2P Interface Address for each call and %NULL for no more members |
| 1533 | */ |
| 1534 | const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next); |
| 1535 | |
| 1536 | /** |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1537 | * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group |
| 1538 | * @group: P2P group context from p2p_group_init() |
| 1539 | * @addr: P2P Interface Address of the client |
| 1540 | * Returns: P2P Device Address of the client if found or %NULL if no match |
| 1541 | * found |
| 1542 | */ |
| 1543 | const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr); |
| 1544 | |
| 1545 | /** |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1546 | * p2p_get_peer_found - Get P2P peer info structure of a found peer |
| 1547 | * @p2p: P2P module context from p2p_init() |
| 1548 | * @addr: P2P Device Address of the peer or %NULL to indicate the first peer |
| 1549 | * @next: Whether to select the peer entry following the one indicated by addr |
| 1550 | * Returns: The first P2P peer info available or %NULL if no such peer exists |
| 1551 | */ |
| 1552 | const struct p2p_peer_info * |
| 1553 | p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next); |
| 1554 | |
| 1555 | /** |
| 1556 | * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions |
| 1557 | * @p2p: P2P module context from p2p_init() |
| 1558 | */ |
| 1559 | void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p); |
| 1560 | |
| 1561 | /** |
| 1562 | * p2p_add_wps_vendor_extension - Add a WPS vendor extension |
| 1563 | * @p2p: P2P module context from p2p_init() |
| 1564 | * @vendor_ext: The vendor extensions to add |
| 1565 | * Returns: 0 on success, -1 on failure |
| 1566 | * |
| 1567 | * The wpabuf structures in the array are owned by the P2P |
| 1568 | * module after this call. |
| 1569 | */ |
| 1570 | int p2p_add_wps_vendor_extension(struct p2p_data *p2p, |
| 1571 | const struct wpabuf *vendor_ext); |
| 1572 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 1573 | /** |
| 1574 | * p2p_set_oper_channel - Set the P2P operating channel |
| 1575 | * @p2p: P2P module context from p2p_init() |
| 1576 | * @op_reg_class: Operating regulatory class to set |
| 1577 | * @op_channel: operating channel to set |
| 1578 | * @cfg_op_channel : Whether op_channel is hardcoded in configuration |
| 1579 | * Returns: 0 on success, -1 on failure |
| 1580 | */ |
| 1581 | int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel, |
| 1582 | int cfg_op_channel); |
| 1583 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1584 | /** |
| 1585 | * p2p_in_progress - Check whether a P2P operation is progress |
| 1586 | * @p2p: P2P module context from p2p_init() |
| 1587 | * Returns: 0 if P2P module is idle or 1 if an operation is in progress |
| 1588 | */ |
| 1589 | int p2p_in_progress(struct p2p_data *p2p); |
| 1590 | |
| 1591 | #ifdef ANDROID_P2P |
| 1592 | /** |
| 1593 | * p2p_in_progress - Check whether a P2P SEARCH is in progress |
| 1594 | * @p2p: P2P module context from p2p_init() |
| 1595 | * Returns: 0 if P2P module is idle or 1 if an operation is in progress |
| 1596 | */ |
| 1597 | int p2p_search_in_progress(struct p2p_data *p2p); |
| 1598 | #endif |
| 1599 | |
| 1600 | /** |
| 1601 | * p2p_other_scan_completed - Notify completion of non-P2P scan |
| 1602 | * @p2p: P2P module context from p2p_init() |
| 1603 | * Returns: 0 if P2P module is idle or 1 if an operation was started |
| 1604 | */ |
| 1605 | int p2p_other_scan_completed(struct p2p_data *p2p); |
| 1606 | |
| 1607 | const char * p2p_wps_method_text(enum p2p_wps_method method); |
| 1608 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1609 | #endif /* P2P_H */ |