OSDN Git Service

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