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