xref: /freebsd/contrib/wpa/src/p2p/p2p.h (revision c1d255d3)
1f05cddf9SRui Paulo /*
2f05cddf9SRui Paulo  * Wi-Fi Direct - P2P module
3f05cddf9SRui Paulo  * Copyright (c) 2009-2010, Atheros Communications
4f05cddf9SRui Paulo  *
5f05cddf9SRui Paulo  * This software may be distributed under the terms of the BSD license.
6f05cddf9SRui Paulo  * See README for more details.
7f05cddf9SRui Paulo  */
8f05cddf9SRui Paulo 
9f05cddf9SRui Paulo #ifndef P2P_H
10f05cddf9SRui Paulo #define P2P_H
11f05cddf9SRui Paulo 
12325151a3SRui Paulo #include "common/ieee802_11_defs.h"
13325151a3SRui Paulo #include "wps/wps.h"
145b9c547cSRui Paulo 
155b9c547cSRui Paulo /* P2P ASP Setup Capability */
165b9c547cSRui Paulo #define P2PS_SETUP_NONE 0
175b9c547cSRui Paulo #define P2PS_SETUP_NEW BIT(0)
185b9c547cSRui Paulo #define P2PS_SETUP_CLIENT BIT(1)
195b9c547cSRui Paulo #define P2PS_SETUP_GROUP_OWNER BIT(2)
205b9c547cSRui Paulo 
215b9c547cSRui Paulo #define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
225b9c547cSRui Paulo #define P2PS_HASH_LEN 6
235b9c547cSRui Paulo #define P2P_MAX_QUERY_HASH 6
24325151a3SRui Paulo #define P2PS_FEATURE_CAPAB_CPT_MAX 2
25325151a3SRui Paulo 
26325151a3SRui Paulo /**
27325151a3SRui Paulo  * P2P_MAX_PREF_CHANNELS - Maximum number of preferred channels
28325151a3SRui Paulo  */
29325151a3SRui Paulo #define P2P_MAX_PREF_CHANNELS 100
305b9c547cSRui Paulo 
31f05cddf9SRui Paulo /**
32f05cddf9SRui Paulo  * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes
33f05cddf9SRui Paulo  */
34780fb4a2SCy Schubert #define P2P_MAX_REG_CLASSES 15
35f05cddf9SRui Paulo 
36f05cddf9SRui Paulo /**
37f05cddf9SRui Paulo  * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class
38f05cddf9SRui Paulo  */
39*c1d255d3SCy Schubert #define P2P_MAX_REG_CLASS_CHANNELS 60
40f05cddf9SRui Paulo 
41f05cddf9SRui Paulo /**
42f05cddf9SRui Paulo  * struct p2p_channels - List of supported channels
43f05cddf9SRui Paulo  */
44f05cddf9SRui Paulo struct p2p_channels {
45f05cddf9SRui Paulo 	/**
46f05cddf9SRui Paulo 	 * struct p2p_reg_class - Supported regulatory class
47f05cddf9SRui Paulo 	 */
48f05cddf9SRui Paulo 	struct p2p_reg_class {
49f05cddf9SRui Paulo 		/**
50f05cddf9SRui Paulo 		 * reg_class - Regulatory class (IEEE 802.11-2007, Annex J)
51f05cddf9SRui Paulo 		 */
52f05cddf9SRui Paulo 		u8 reg_class;
53f05cddf9SRui Paulo 
54f05cddf9SRui Paulo 		/**
55f05cddf9SRui Paulo 		 * channel - Supported channels
56f05cddf9SRui Paulo 		 */
57f05cddf9SRui Paulo 		u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
58f05cddf9SRui Paulo 
59f05cddf9SRui Paulo 		/**
60f05cddf9SRui Paulo 		 * channels - Number of channel entries in use
61f05cddf9SRui Paulo 		 */
62f05cddf9SRui Paulo 		size_t channels;
63f05cddf9SRui Paulo 	} reg_class[P2P_MAX_REG_CLASSES];
64f05cddf9SRui Paulo 
65f05cddf9SRui Paulo 	/**
66f05cddf9SRui Paulo 	 * reg_classes - Number of reg_class entries in use
67f05cddf9SRui Paulo 	 */
68f05cddf9SRui Paulo 	size_t reg_classes;
69f05cddf9SRui Paulo };
70f05cddf9SRui Paulo 
71f05cddf9SRui Paulo enum p2p_wps_method {
725b9c547cSRui Paulo 	WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC,
735b9c547cSRui Paulo 	WPS_P2PS
74f05cddf9SRui Paulo };
75f05cddf9SRui Paulo 
76f05cddf9SRui Paulo /**
77f05cddf9SRui Paulo  * struct p2p_go_neg_results - P2P Group Owner Negotiation results
78f05cddf9SRui Paulo  */
79f05cddf9SRui Paulo struct p2p_go_neg_results {
80f05cddf9SRui Paulo 	/**
81f05cddf9SRui Paulo 	 * status - Negotiation result (Status Code)
82f05cddf9SRui Paulo 	 *
83f05cddf9SRui Paulo 	 * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate
84f05cddf9SRui Paulo 	 * failed negotiation.
85f05cddf9SRui Paulo 	 */
86f05cddf9SRui Paulo 	int status;
87f05cddf9SRui Paulo 
88f05cddf9SRui Paulo 	/**
89f05cddf9SRui Paulo 	 * role_go - Whether local end is Group Owner
90f05cddf9SRui Paulo 	 */
91f05cddf9SRui Paulo 	int role_go;
92f05cddf9SRui Paulo 
93f05cddf9SRui Paulo 	/**
94f05cddf9SRui Paulo 	 * freq - Frequency of the group operational channel in MHz
95f05cddf9SRui Paulo 	 */
96f05cddf9SRui Paulo 	int freq;
97f05cddf9SRui Paulo 
98f05cddf9SRui Paulo 	int ht40;
99f05cddf9SRui Paulo 
1005b9c547cSRui Paulo 	int vht;
1015b9c547cSRui Paulo 
102*c1d255d3SCy Schubert 	int edmg;
103*c1d255d3SCy Schubert 
104780fb4a2SCy Schubert 	u8 max_oper_chwidth;
105780fb4a2SCy Schubert 
106780fb4a2SCy Schubert 	unsigned int vht_center_freq2;
107780fb4a2SCy Schubert 
108f05cddf9SRui Paulo 	/**
1094bc52338SCy Schubert 	 * he - Indicates if IEEE 802.11ax HE is enabled
1104bc52338SCy Schubert 	 */
1114bc52338SCy Schubert 	int he;
1124bc52338SCy Schubert 
1134bc52338SCy Schubert 	/**
114f05cddf9SRui Paulo 	 * ssid - SSID of the group
115f05cddf9SRui Paulo 	 */
116325151a3SRui Paulo 	u8 ssid[SSID_MAX_LEN];
117f05cddf9SRui Paulo 
118f05cddf9SRui Paulo 	/**
119f05cddf9SRui Paulo 	 * ssid_len - Length of SSID in octets
120f05cddf9SRui Paulo 	 */
121f05cddf9SRui Paulo 	size_t ssid_len;
122f05cddf9SRui Paulo 
123f05cddf9SRui Paulo 	/**
124f05cddf9SRui Paulo 	 * psk - WPA pre-shared key (256 bits) (GO only)
125f05cddf9SRui Paulo 	 */
126f05cddf9SRui Paulo 	u8 psk[32];
127f05cddf9SRui Paulo 
128f05cddf9SRui Paulo 	/**
129f05cddf9SRui Paulo 	 * psk_set - Whether PSK field is configured (GO only)
130f05cddf9SRui Paulo 	 */
131f05cddf9SRui Paulo 	int psk_set;
132f05cddf9SRui Paulo 
133f05cddf9SRui Paulo 	/**
134f05cddf9SRui Paulo 	 * passphrase - WPA2-Personal passphrase for the group (GO only)
135f05cddf9SRui Paulo 	 */
136f05cddf9SRui Paulo 	char passphrase[64];
137f05cddf9SRui Paulo 
138f05cddf9SRui Paulo 	/**
139f05cddf9SRui Paulo 	 * peer_device_addr - P2P Device Address of the peer
140f05cddf9SRui Paulo 	 */
141f05cddf9SRui Paulo 	u8 peer_device_addr[ETH_ALEN];
142f05cddf9SRui Paulo 
143f05cddf9SRui Paulo 	/**
144f05cddf9SRui Paulo 	 * peer_interface_addr - P2P Interface Address of the peer
145f05cddf9SRui Paulo 	 */
146f05cddf9SRui Paulo 	u8 peer_interface_addr[ETH_ALEN];
147f05cddf9SRui Paulo 
148f05cddf9SRui Paulo 	/**
149f05cddf9SRui Paulo 	 * wps_method - WPS method to be used during provisioning
150f05cddf9SRui Paulo 	 */
151f05cddf9SRui Paulo 	enum p2p_wps_method wps_method;
152f05cddf9SRui Paulo 
153f05cddf9SRui Paulo #define P2P_MAX_CHANNELS 50
154f05cddf9SRui Paulo 
155f05cddf9SRui Paulo 	/**
156f05cddf9SRui Paulo 	 * freq_list - Zero-terminated list of possible operational channels
157f05cddf9SRui Paulo 	 */
158f05cddf9SRui Paulo 	int freq_list[P2P_MAX_CHANNELS];
159f05cddf9SRui Paulo 
160f05cddf9SRui Paulo 	/**
161f05cddf9SRui Paulo 	 * persistent_group - Whether the group should be made persistent
162f05cddf9SRui Paulo 	 * 0 = not persistent
163f05cddf9SRui Paulo 	 * 1 = persistent group without persistent reconnect
164f05cddf9SRui Paulo 	 * 2 = persistent group with persistent reconnect
165f05cddf9SRui Paulo 	 */
166f05cddf9SRui Paulo 	int persistent_group;
167f05cddf9SRui Paulo 
168f05cddf9SRui Paulo 	/**
169f05cddf9SRui Paulo 	 * peer_config_timeout - Peer configuration timeout (in 10 msec units)
170f05cddf9SRui Paulo 	 */
171f05cddf9SRui Paulo 	unsigned int peer_config_timeout;
172f05cddf9SRui Paulo };
173f05cddf9SRui Paulo 
1745b9c547cSRui Paulo struct p2ps_provision {
1755b9c547cSRui Paulo 	/**
176325151a3SRui Paulo 	 * pd_seeker - P2PS provision discovery seeker role
177325151a3SRui Paulo 	 */
178325151a3SRui Paulo 	unsigned int pd_seeker:1;
179325151a3SRui Paulo 
180325151a3SRui Paulo 	/**
1815b9c547cSRui Paulo 	 * status - Remote returned provisioning status code
1825b9c547cSRui Paulo 	 */
1835b9c547cSRui Paulo 	int status;
1845b9c547cSRui Paulo 
1855b9c547cSRui Paulo 	/**
1865b9c547cSRui Paulo 	 * adv_id - P2PS Advertisement ID
1875b9c547cSRui Paulo 	 */
1885b9c547cSRui Paulo 	u32 adv_id;
1895b9c547cSRui Paulo 
1905b9c547cSRui Paulo 	/**
1915b9c547cSRui Paulo 	 * session_id - P2PS Session ID
1925b9c547cSRui Paulo 	 */
1935b9c547cSRui Paulo 	u32 session_id;
1945b9c547cSRui Paulo 
1955b9c547cSRui Paulo 	/**
1965b9c547cSRui Paulo 	 * method - WPS Method (to be) used to establish session
1975b9c547cSRui Paulo 	 */
1985b9c547cSRui Paulo 	u16 method;
1995b9c547cSRui Paulo 
2005b9c547cSRui Paulo 	/**
2015b9c547cSRui Paulo 	 * conncap - Connection Capabilities negotiated between P2P peers
2025b9c547cSRui Paulo 	 */
2035b9c547cSRui Paulo 	u8 conncap;
2045b9c547cSRui Paulo 
2055b9c547cSRui Paulo 	/**
2065b9c547cSRui Paulo 	 * role - Info about the roles to be used for this connection
2075b9c547cSRui Paulo 	 */
2085b9c547cSRui Paulo 	u8 role;
2095b9c547cSRui Paulo 
2105b9c547cSRui Paulo 	/**
2115b9c547cSRui Paulo 	 * session_mac - MAC address of the peer that started the session
2125b9c547cSRui Paulo 	 */
2135b9c547cSRui Paulo 	u8 session_mac[ETH_ALEN];
2145b9c547cSRui Paulo 
2155b9c547cSRui Paulo 	/**
2165b9c547cSRui Paulo 	 * adv_mac - MAC address of the peer advertised the service
2175b9c547cSRui Paulo 	 */
2185b9c547cSRui Paulo 	u8 adv_mac[ETH_ALEN];
2195b9c547cSRui Paulo 
2205b9c547cSRui Paulo 	/**
221325151a3SRui Paulo 	 * cpt_mask - Supported Coordination Protocol Transport mask
222325151a3SRui Paulo 	 *
223325151a3SRui Paulo 	 * A bitwise mask of supported ASP Coordination Protocol Transports.
224325151a3SRui Paulo 	 * This property is set together and corresponds with cpt_priority.
225325151a3SRui Paulo 	 */
226325151a3SRui Paulo 	u8 cpt_mask;
227325151a3SRui Paulo 
228325151a3SRui Paulo 	/**
229325151a3SRui Paulo 	 * cpt_priority - Coordination Protocol Transport priority list
230325151a3SRui Paulo 	 *
231325151a3SRui Paulo 	 * Priorities of supported ASP Coordination Protocol Transports.
232325151a3SRui Paulo 	 * This property is set together and corresponds with cpt_mask.
233325151a3SRui Paulo 	 * The CPT priority list is 0 terminated.
234325151a3SRui Paulo 	 */
235325151a3SRui Paulo 	u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
236325151a3SRui Paulo 
237325151a3SRui Paulo 	/**
238780fb4a2SCy Schubert 	 * force_freq - The only allowed channel frequency in MHz or 0.
239780fb4a2SCy Schubert 	 */
240780fb4a2SCy Schubert 	unsigned int force_freq;
241780fb4a2SCy Schubert 
242780fb4a2SCy Schubert 	/**
243780fb4a2SCy Schubert 	 * pref_freq - Preferred operating frequency in MHz or 0.
244780fb4a2SCy Schubert 	 */
245780fb4a2SCy Schubert 	unsigned int pref_freq;
246780fb4a2SCy Schubert 
247780fb4a2SCy Schubert 	/**
2485b9c547cSRui Paulo 	 * info - Vendor defined extra Provisioning information
2495b9c547cSRui Paulo 	 */
2505b9c547cSRui Paulo 	char info[0];
2515b9c547cSRui Paulo };
2525b9c547cSRui Paulo 
2535b9c547cSRui Paulo struct p2ps_advertisement {
2545b9c547cSRui Paulo 	struct p2ps_advertisement *next;
2555b9c547cSRui Paulo 
2565b9c547cSRui Paulo 	/**
2575b9c547cSRui Paulo 	 * svc_info - Pointer to (internal) Service defined information
2585b9c547cSRui Paulo 	 */
2595b9c547cSRui Paulo 	char *svc_info;
2605b9c547cSRui Paulo 
2615b9c547cSRui Paulo 	/**
2625b9c547cSRui Paulo 	 * id - P2PS Advertisement ID
2635b9c547cSRui Paulo 	 */
2645b9c547cSRui Paulo 	u32 id;
2655b9c547cSRui Paulo 
2665b9c547cSRui Paulo 	/**
2675b9c547cSRui Paulo 	 * config_methods - WPS Methods which are allowed for this service
2685b9c547cSRui Paulo 	 */
2695b9c547cSRui Paulo 	u16 config_methods;
2705b9c547cSRui Paulo 
2715b9c547cSRui Paulo 	/**
2725b9c547cSRui Paulo 	 * state - Current state of the service: 0 - Out Of Service, 1-255 Vendor defined
2735b9c547cSRui Paulo 	 */
2745b9c547cSRui Paulo 	u8 state;
2755b9c547cSRui Paulo 
2765b9c547cSRui Paulo 	/**
2775b9c547cSRui Paulo 	 * auto_accept - Automatically Accept provisioning request if possible.
2785b9c547cSRui Paulo 	 */
2795b9c547cSRui Paulo 	u8 auto_accept;
2805b9c547cSRui Paulo 
2815b9c547cSRui Paulo 	/**
2825b9c547cSRui Paulo 	 * hash - 6 octet Service Name has to match against incoming Probe Requests
2835b9c547cSRui Paulo 	 */
2845b9c547cSRui Paulo 	u8 hash[P2PS_HASH_LEN];
2855b9c547cSRui Paulo 
2865b9c547cSRui Paulo 	/**
287325151a3SRui Paulo 	 * cpt_mask - supported Coordination Protocol Transport mask
288325151a3SRui Paulo 	 *
289325151a3SRui Paulo 	 * A bitwise mask of supported ASP Coordination Protocol Transports.
290325151a3SRui Paulo 	 * This property is set together and corresponds with cpt_priority.
291325151a3SRui Paulo 	 */
292325151a3SRui Paulo 	u8 cpt_mask;
293325151a3SRui Paulo 
294325151a3SRui Paulo 	/**
295325151a3SRui Paulo 	 * cpt_priority - Coordination Protocol Transport priority list
296325151a3SRui Paulo 	 *
297325151a3SRui Paulo 	 * Priorities of supported ASP Coordinatin Protocol Transports.
298325151a3SRui Paulo 	 * This property is set together and corresponds with cpt_mask.
299325151a3SRui Paulo 	 * The CPT priority list is 0 terminated.
300325151a3SRui Paulo 	 */
301325151a3SRui Paulo 	u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
302325151a3SRui Paulo 
303325151a3SRui Paulo 	/**
3045b9c547cSRui Paulo 	 * svc_name - NULL Terminated UTF-8 Service Name, and svc_info storage
3055b9c547cSRui Paulo 	 */
3065b9c547cSRui Paulo 	char svc_name[0];
3075b9c547cSRui Paulo };
3085b9c547cSRui Paulo 
3095b9c547cSRui Paulo 
310f05cddf9SRui Paulo struct p2p_data;
311f05cddf9SRui Paulo 
312f05cddf9SRui Paulo enum p2p_scan_type {
313f05cddf9SRui Paulo 	P2P_SCAN_SOCIAL,
314f05cddf9SRui Paulo 	P2P_SCAN_FULL,
3155b9c547cSRui Paulo 	P2P_SCAN_SPECIFIC,
316f05cddf9SRui Paulo 	P2P_SCAN_SOCIAL_PLUS_ONE
317f05cddf9SRui Paulo };
318f05cddf9SRui Paulo 
319f05cddf9SRui Paulo #define P2P_MAX_WPS_VENDOR_EXT 10
320f05cddf9SRui Paulo 
321f05cddf9SRui Paulo /**
322f05cddf9SRui Paulo  * struct p2p_peer_info - P2P peer information
323f05cddf9SRui Paulo  */
324f05cddf9SRui Paulo struct p2p_peer_info {
325f05cddf9SRui Paulo 	/**
326f05cddf9SRui Paulo 	 * p2p_device_addr - P2P Device Address of the peer
327f05cddf9SRui Paulo 	 */
328f05cddf9SRui Paulo 	u8 p2p_device_addr[ETH_ALEN];
329f05cddf9SRui Paulo 
330f05cddf9SRui Paulo 	/**
331f05cddf9SRui Paulo 	 * pri_dev_type - Primary Device Type
332f05cddf9SRui Paulo 	 */
333f05cddf9SRui Paulo 	u8 pri_dev_type[8];
334f05cddf9SRui Paulo 
335f05cddf9SRui Paulo 	/**
336f05cddf9SRui Paulo 	 * device_name - Device Name (0..32 octets encoded in UTF-8)
337f05cddf9SRui Paulo 	 */
338325151a3SRui Paulo 	char device_name[WPS_DEV_NAME_MAX_LEN + 1];
339f05cddf9SRui Paulo 
340f05cddf9SRui Paulo 	/**
341f05cddf9SRui Paulo 	 * manufacturer - Manufacturer (0..64 octets encoded in UTF-8)
342f05cddf9SRui Paulo 	 */
343325151a3SRui Paulo 	char manufacturer[WPS_MANUFACTURER_MAX_LEN + 1];
344f05cddf9SRui Paulo 
345f05cddf9SRui Paulo 	/**
346f05cddf9SRui Paulo 	 * model_name - Model Name (0..32 octets encoded in UTF-8)
347f05cddf9SRui Paulo 	 */
348325151a3SRui Paulo 	char model_name[WPS_MODEL_NAME_MAX_LEN + 1];
349f05cddf9SRui Paulo 
350f05cddf9SRui Paulo 	/**
351f05cddf9SRui Paulo 	 * model_number - Model Number (0..32 octets encoded in UTF-8)
352f05cddf9SRui Paulo 	 */
353325151a3SRui Paulo 	char model_number[WPS_MODEL_NUMBER_MAX_LEN + 1];
354f05cddf9SRui Paulo 
355f05cddf9SRui Paulo 	/**
356f05cddf9SRui Paulo 	 * serial_number - Serial Number (0..32 octets encoded in UTF-8)
357f05cddf9SRui Paulo 	 */
358325151a3SRui Paulo 	char serial_number[WPS_SERIAL_NUMBER_MAX_LEN + 1];
359f05cddf9SRui Paulo 
360f05cddf9SRui Paulo 	/**
361f05cddf9SRui Paulo 	 * level - Signal level
362f05cddf9SRui Paulo 	 */
363f05cddf9SRui Paulo 	int level;
364f05cddf9SRui Paulo 
365f05cddf9SRui Paulo 	/**
366f05cddf9SRui Paulo 	 * config_methods - WPS Configuration Methods
367f05cddf9SRui Paulo 	 */
368f05cddf9SRui Paulo 	u16 config_methods;
369f05cddf9SRui Paulo 
370f05cddf9SRui Paulo 	/**
371f05cddf9SRui Paulo 	 * dev_capab - Device Capabilities
372f05cddf9SRui Paulo 	 */
373f05cddf9SRui Paulo 	u8 dev_capab;
374f05cddf9SRui Paulo 
375f05cddf9SRui Paulo 	/**
376f05cddf9SRui Paulo 	 * group_capab - Group Capabilities
377f05cddf9SRui Paulo 	 */
378f05cddf9SRui Paulo 	u8 group_capab;
379f05cddf9SRui Paulo 
380f05cddf9SRui Paulo 	/**
381f05cddf9SRui Paulo 	 * wps_sec_dev_type_list - WPS secondary device type list
382f05cddf9SRui Paulo 	 *
383f05cddf9SRui Paulo 	 * This list includes from 0 to 16 Secondary Device Types as indicated
384f05cddf9SRui Paulo 	 * by wps_sec_dev_type_list_len (8 * number of types).
385f05cddf9SRui Paulo 	 */
386325151a3SRui Paulo 	u8 wps_sec_dev_type_list[WPS_SEC_DEV_TYPE_MAX_LEN];
387f05cddf9SRui Paulo 
388f05cddf9SRui Paulo 	/**
389f05cddf9SRui Paulo 	 * wps_sec_dev_type_list_len - Length of secondary device type list
390f05cddf9SRui Paulo 	 */
391f05cddf9SRui Paulo 	size_t wps_sec_dev_type_list_len;
392f05cddf9SRui Paulo 
393f05cddf9SRui Paulo 	struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
394f05cddf9SRui Paulo 
395f05cddf9SRui Paulo 	/**
396f05cddf9SRui Paulo 	 * wfd_subelems - Wi-Fi Display subelements from WFD IE(s)
397f05cddf9SRui Paulo 	 */
398f05cddf9SRui Paulo 	struct wpabuf *wfd_subelems;
3995b9c547cSRui Paulo 
4005b9c547cSRui Paulo 	/**
4015b9c547cSRui Paulo 	 * vendor_elems - Unrecognized vendor elements
4025b9c547cSRui Paulo 	 *
4035b9c547cSRui Paulo 	 * This buffer includes any other vendor element than P2P, WPS, and WFD
4045b9c547cSRui Paulo 	 * IE(s) from the frame that was used to discover the peer.
4055b9c547cSRui Paulo 	 */
4065b9c547cSRui Paulo 	struct wpabuf *vendor_elems;
4075b9c547cSRui Paulo 
4085b9c547cSRui Paulo 	/**
4095b9c547cSRui Paulo 	 * p2ps_instance - P2PS Application Service Info
4105b9c547cSRui Paulo 	 */
4115b9c547cSRui Paulo 	struct wpabuf *p2ps_instance;
412f05cddf9SRui Paulo };
413f05cddf9SRui Paulo 
414f05cddf9SRui Paulo enum p2p_prov_disc_status {
415f05cddf9SRui Paulo 	P2P_PROV_DISC_SUCCESS,
416f05cddf9SRui Paulo 	P2P_PROV_DISC_TIMEOUT,
417f05cddf9SRui Paulo 	P2P_PROV_DISC_REJECTED,
418f05cddf9SRui Paulo 	P2P_PROV_DISC_TIMEOUT_JOIN,
4195b9c547cSRui Paulo 	P2P_PROV_DISC_INFO_UNAVAILABLE,
420f05cddf9SRui Paulo };
421f05cddf9SRui Paulo 
422f05cddf9SRui Paulo struct p2p_channel {
423f05cddf9SRui Paulo 	u8 op_class;
424f05cddf9SRui Paulo 	u8 chan;
425f05cddf9SRui Paulo };
426f05cddf9SRui Paulo 
427f05cddf9SRui Paulo /**
428f05cddf9SRui Paulo  * struct p2p_config - P2P configuration
429f05cddf9SRui Paulo  *
430f05cddf9SRui Paulo  * This configuration is provided to the P2P module during initialization with
431f05cddf9SRui Paulo  * p2p_init().
432f05cddf9SRui Paulo  */
433f05cddf9SRui Paulo struct p2p_config {
434f05cddf9SRui Paulo 	/**
435f05cddf9SRui Paulo 	 * country - Country code to use in P2P operations
436f05cddf9SRui Paulo 	 */
437f05cddf9SRui Paulo 	char country[3];
438f05cddf9SRui Paulo 
439f05cddf9SRui Paulo 	/**
440f05cddf9SRui Paulo 	 * reg_class - Regulatory class for own listen channel
441f05cddf9SRui Paulo 	 */
442f05cddf9SRui Paulo 	u8 reg_class;
443f05cddf9SRui Paulo 
444f05cddf9SRui Paulo 	/**
445f05cddf9SRui Paulo 	 * channel - Own listen channel
446f05cddf9SRui Paulo 	 */
447f05cddf9SRui Paulo 	u8 channel;
448f05cddf9SRui Paulo 
449f05cddf9SRui Paulo 	/**
4505b9c547cSRui Paulo 	 * channel_forced - the listen channel was forced by configuration
4515b9c547cSRui Paulo 	 *                  or by control interface and cannot be overridden
4525b9c547cSRui Paulo 	 */
4535b9c547cSRui Paulo 	u8 channel_forced;
4545b9c547cSRui Paulo 
4555b9c547cSRui Paulo 	/**
456f05cddf9SRui Paulo 	 * Regulatory class for own operational channel
457f05cddf9SRui Paulo 	 */
458f05cddf9SRui Paulo 	u8 op_reg_class;
459f05cddf9SRui Paulo 
460f05cddf9SRui Paulo 	/**
461f05cddf9SRui Paulo 	 * op_channel - Own operational channel
462f05cddf9SRui Paulo 	 */
463f05cddf9SRui Paulo 	u8 op_channel;
464f05cddf9SRui Paulo 
465f05cddf9SRui Paulo 	/**
466f05cddf9SRui Paulo 	 * cfg_op_channel - Whether op_channel is hardcoded in configuration
467f05cddf9SRui Paulo 	 */
468f05cddf9SRui Paulo 	u8 cfg_op_channel;
469f05cddf9SRui Paulo 
470f05cddf9SRui Paulo 	/**
471f05cddf9SRui Paulo 	 * channels - Own supported regulatory classes and channels
472f05cddf9SRui Paulo 	 *
473f05cddf9SRui Paulo 	 * List of supposerted channels per regulatory class. The regulatory
474f05cddf9SRui Paulo 	 * classes are defined in IEEE Std 802.11-2007 Annex J and the
475f05cddf9SRui Paulo 	 * numbering of the clases depends on the configured country code.
476f05cddf9SRui Paulo 	 */
477f05cddf9SRui Paulo 	struct p2p_channels channels;
478f05cddf9SRui Paulo 
479f05cddf9SRui Paulo 	/**
4805b9c547cSRui Paulo 	 * cli_channels - Additional client channels
4815b9c547cSRui Paulo 	 *
4825b9c547cSRui Paulo 	 * This list of channels (if any) will be used when advertising local
4835b9c547cSRui Paulo 	 * channels during GO Negotiation or Invitation for the cases where the
4845b9c547cSRui Paulo 	 * local end may become the client. This may allow the peer to become a
4855b9c547cSRui Paulo 	 * GO on additional channels if it supports these options. The main use
4865b9c547cSRui Paulo 	 * case for this is to include passive-scan channels on devices that may
4875b9c547cSRui Paulo 	 * not know their current location and have configured most channels to
4885b9c547cSRui Paulo 	 * not allow initiation of radition (i.e., another device needs to take
4895b9c547cSRui Paulo 	 * master responsibilities).
4905b9c547cSRui Paulo 	 */
4915b9c547cSRui Paulo 	struct p2p_channels cli_channels;
4925b9c547cSRui Paulo 
4935b9c547cSRui Paulo 	/**
494f05cddf9SRui Paulo 	 * num_pref_chan - Number of pref_chan entries
495f05cddf9SRui Paulo 	 */
496f05cddf9SRui Paulo 	unsigned int num_pref_chan;
497f05cddf9SRui Paulo 
498f05cddf9SRui Paulo 	/**
499f05cddf9SRui Paulo 	 * pref_chan - Preferred channels for GO Negotiation
500f05cddf9SRui Paulo 	 */
501f05cddf9SRui Paulo 	struct p2p_channel *pref_chan;
502f05cddf9SRui Paulo 
503f05cddf9SRui Paulo 	/**
504*c1d255d3SCy Schubert 	 * p2p_6ghz_disable - Disable 6GHz for P2P operations
505*c1d255d3SCy Schubert 	 */
506*c1d255d3SCy Schubert 	bool p2p_6ghz_disable;
507*c1d255d3SCy Schubert 
508*c1d255d3SCy Schubert 	/**
509f05cddf9SRui Paulo 	 * pri_dev_type - Primary Device Type (see WPS)
510f05cddf9SRui Paulo 	 */
511f05cddf9SRui Paulo 	u8 pri_dev_type[8];
512f05cddf9SRui Paulo 
513f05cddf9SRui Paulo 	/**
514f05cddf9SRui Paulo 	 * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types
515f05cddf9SRui Paulo 	 */
516f05cddf9SRui Paulo #define P2P_SEC_DEVICE_TYPES 5
517f05cddf9SRui Paulo 
518f05cddf9SRui Paulo 	/**
519f05cddf9SRui Paulo 	 * sec_dev_type - Optional secondary device types
520f05cddf9SRui Paulo 	 */
521f05cddf9SRui Paulo 	u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8];
522f05cddf9SRui Paulo 
523f05cddf9SRui Paulo 	/**
524f05cddf9SRui Paulo 	 * num_sec_dev_types - Number of sec_dev_type entries
525f05cddf9SRui Paulo 	 */
526f05cddf9SRui Paulo 	size_t num_sec_dev_types;
527f05cddf9SRui Paulo 
528f05cddf9SRui Paulo 	/**
529f05cddf9SRui Paulo 	 * dev_addr - P2P Device Address
530f05cddf9SRui Paulo 	 */
531f05cddf9SRui Paulo 	u8 dev_addr[ETH_ALEN];
532f05cddf9SRui Paulo 
533f05cddf9SRui Paulo 	/**
534f05cddf9SRui Paulo 	 * dev_name - Device Name
535f05cddf9SRui Paulo 	 */
536f05cddf9SRui Paulo 	char *dev_name;
537f05cddf9SRui Paulo 
538f05cddf9SRui Paulo 	char *manufacturer;
539f05cddf9SRui Paulo 	char *model_name;
540f05cddf9SRui Paulo 	char *model_number;
541f05cddf9SRui Paulo 	char *serial_number;
542f05cddf9SRui Paulo 
543f05cddf9SRui Paulo 	u8 uuid[16];
544f05cddf9SRui Paulo 	u16 config_methods;
545f05cddf9SRui Paulo 
546f05cddf9SRui Paulo 	/**
547f05cddf9SRui Paulo 	 * concurrent_operations - Whether concurrent operations are supported
548f05cddf9SRui Paulo 	 */
549f05cddf9SRui Paulo 	int concurrent_operations;
550f05cddf9SRui Paulo 
551f05cddf9SRui Paulo 	/**
552f05cddf9SRui Paulo 	 * max_peers - Maximum number of discovered peers to remember
553f05cddf9SRui Paulo 	 *
554f05cddf9SRui Paulo 	 * If more peers are discovered, older entries will be removed to make
555f05cddf9SRui Paulo 	 * room for the new ones.
556f05cddf9SRui Paulo 	 */
557f05cddf9SRui Paulo 	size_t max_peers;
558f05cddf9SRui Paulo 
559f05cddf9SRui Paulo 	/**
560f05cddf9SRui Paulo 	 * p2p_intra_bss - Intra BSS communication is supported
561f05cddf9SRui Paulo 	 */
562f05cddf9SRui Paulo 	int p2p_intra_bss;
563f05cddf9SRui Paulo 
564f05cddf9SRui Paulo 	/**
565f05cddf9SRui Paulo 	 * ssid_postfix - Postfix data to add to the SSID
566f05cddf9SRui Paulo 	 *
567f05cddf9SRui Paulo 	 * This data will be added to the end of the SSID after the
568f05cddf9SRui Paulo 	 * DIRECT-<random two octets> prefix.
569f05cddf9SRui Paulo 	 */
570325151a3SRui Paulo 	u8 ssid_postfix[SSID_MAX_LEN - 9];
571f05cddf9SRui Paulo 
572f05cddf9SRui Paulo 	/**
573f05cddf9SRui Paulo 	 * ssid_postfix_len - Length of the ssid_postfix data
574f05cddf9SRui Paulo 	 */
575f05cddf9SRui Paulo 	size_t ssid_postfix_len;
576f05cddf9SRui Paulo 
577f05cddf9SRui Paulo 	/**
578f05cddf9SRui Paulo 	 * max_listen - Maximum listen duration in ms
579f05cddf9SRui Paulo 	 */
580f05cddf9SRui Paulo 	unsigned int max_listen;
581f05cddf9SRui Paulo 
582f05cddf9SRui Paulo 	/**
5835b9c547cSRui Paulo 	 * passphrase_len - Passphrase length (8..63)
5845b9c547cSRui Paulo 	 *
5855b9c547cSRui Paulo 	 * This parameter controls the length of the random passphrase that is
5865b9c547cSRui Paulo 	 * generated at the GO.
587f05cddf9SRui Paulo 	 */
5885b9c547cSRui Paulo 	unsigned int passphrase_len;
589f05cddf9SRui Paulo 
590f05cddf9SRui Paulo 	/**
591f05cddf9SRui Paulo 	 * cb_ctx - Context to use with callback functions
592f05cddf9SRui Paulo 	 */
593f05cddf9SRui Paulo 	void *cb_ctx;
594f05cddf9SRui Paulo 
5955b9c547cSRui Paulo 	/**
5965b9c547cSRui Paulo 	 * debug_print - Debug print
5975b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
5985b9c547cSRui Paulo 	 * @level: Debug verbosity level (MSG_*)
5995b9c547cSRui Paulo 	 * @msg: Debug message
6005b9c547cSRui Paulo 	 */
6015b9c547cSRui Paulo 	void (*debug_print)(void *ctx, int level, const char *msg);
6025b9c547cSRui Paulo 
603f05cddf9SRui Paulo 
604f05cddf9SRui Paulo 	/* Callbacks to request lower layer driver operations */
605f05cddf9SRui Paulo 
606f05cddf9SRui Paulo 	/**
607f05cddf9SRui Paulo 	 * p2p_scan - Request a P2P scan/search
608f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
609f05cddf9SRui Paulo 	 * @type: Scan type
610f05cddf9SRui Paulo 	 * @freq: Specific frequency (MHz) to scan or 0 for no restriction
611f05cddf9SRui Paulo 	 * @num_req_dev_types: Number of requested device types
612f05cddf9SRui Paulo 	 * @req_dev_types: Array containing requested device types
613f05cddf9SRui Paulo 	 * @dev_id: Device ID to search for or %NULL to find all devices
614f05cddf9SRui Paulo 	 * @pw_id: Device Password ID
615*c1d255d3SCy Schubert 	 * @include_6ghz: Include 6 GHz channels in P2P scan
616f05cddf9SRui Paulo 	 * Returns: 0 on success, -1 on failure
617f05cddf9SRui Paulo 	 *
618f05cddf9SRui Paulo 	 * This callback function is used to request a P2P scan or search
619f05cddf9SRui Paulo 	 * operation to be completed. Type type argument specifies which type
620f05cddf9SRui Paulo 	 * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the
621f05cddf9SRui Paulo 	 * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL
6225b9c547cSRui Paulo 	 * indicates that all channels are to be scanned. @P2P_SCAN_SPECIFIC
6235b9c547cSRui Paulo 	 * request a scan of a single channel specified by freq.
624f05cddf9SRui Paulo 	 * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels
625f05cddf9SRui Paulo 	 * plus one extra channel specified by freq.
626f05cddf9SRui Paulo 	 *
627f05cddf9SRui Paulo 	 * The full scan is used for the initial scan to find group owners from
628f05cddf9SRui Paulo 	 * all. The other types are used during search phase scan of the social
629f05cddf9SRui Paulo 	 * channels (with potential variation if the Listen channel of the
630f05cddf9SRui Paulo 	 * target peer is known or if other channels are scanned in steps).
631f05cddf9SRui Paulo 	 *
632f05cddf9SRui Paulo 	 * The scan results are returned after this call by calling
633f05cddf9SRui Paulo 	 * p2p_scan_res_handler() for each scan result that has a P2P IE and
634f05cddf9SRui Paulo 	 * then calling p2p_scan_res_handled() to indicate that all scan
635f05cddf9SRui Paulo 	 * results have been indicated.
636f05cddf9SRui Paulo 	 */
637f05cddf9SRui Paulo 	int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq,
638f05cddf9SRui Paulo 			unsigned int num_req_dev_types,
639*c1d255d3SCy Schubert 			const u8 *req_dev_types, const u8 *dev_id, u16 pw_id,
640*c1d255d3SCy Schubert 			bool include_6ghz);
641f05cddf9SRui Paulo 
642f05cddf9SRui Paulo 	/**
643f05cddf9SRui Paulo 	 * send_probe_resp - Transmit a Probe Response frame
644f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
645f05cddf9SRui Paulo 	 * @buf: Probe Response frame (including the header and body)
646325151a3SRui Paulo 	 * @freq: Forced frequency (in MHz) to use or 0.
647f05cddf9SRui Paulo 	 * Returns: 0 on success, -1 on failure
648f05cddf9SRui Paulo 	 *
649f05cddf9SRui Paulo 	 * This function is used to reply to Probe Request frames that were
650f05cddf9SRui Paulo 	 * indicated with a call to p2p_probe_req_rx(). The response is to be
651325151a3SRui Paulo 	 * sent on the same channel, unless otherwise specified, or to be
652325151a3SRui Paulo 	 * dropped if the driver is not listening to Probe Request frames
653325151a3SRui Paulo 	 * anymore.
654f05cddf9SRui Paulo 	 *
655f05cddf9SRui Paulo 	 * Alternatively, the responsibility for building the Probe Response
656f05cddf9SRui Paulo 	 * frames in Listen state may be in another system component in which
657f05cddf9SRui Paulo 	 * case this function need to be implemented (i.e., the function
658f05cddf9SRui Paulo 	 * pointer can be %NULL). The WPS and P2P IEs to be added for Probe
659f05cddf9SRui Paulo 	 * Response frames in such a case are available from the
660f05cddf9SRui Paulo 	 * start_listen() callback. It should be noted that the received Probe
661f05cddf9SRui Paulo 	 * Request frames must be indicated by calling p2p_probe_req_rx() even
662f05cddf9SRui Paulo 	 * if this send_probe_resp() is not used.
663f05cddf9SRui Paulo 	 */
664325151a3SRui Paulo 	int (*send_probe_resp)(void *ctx, const struct wpabuf *buf,
665325151a3SRui Paulo 			       unsigned int freq);
666f05cddf9SRui Paulo 
667f05cddf9SRui Paulo 	/**
668f05cddf9SRui Paulo 	 * send_action - Transmit an Action frame
669f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
670f05cddf9SRui Paulo 	 * @freq: Frequency in MHz for the channel on which to transmit
671f05cddf9SRui Paulo 	 * @dst: Destination MAC address (Address 1)
672f05cddf9SRui Paulo 	 * @src: Source MAC address (Address 2)
673f05cddf9SRui Paulo 	 * @bssid: BSSID (Address 3)
674f05cddf9SRui Paulo 	 * @buf: Frame body (starting from Category field)
675f05cddf9SRui Paulo 	 * @len: Length of buf in octets
676f05cddf9SRui Paulo 	 * @wait_time: How many msec to wait for a response frame
6774bc52338SCy Schubert 	 * @scheduled: Return value indicating whether the transmissions was
6784bc52338SCy Schubert 	 *	scheduled to happen once the radio is available
679f05cddf9SRui Paulo 	 * Returns: 0 on success, -1 on failure
680f05cddf9SRui Paulo 	 *
681f05cddf9SRui Paulo 	 * The Action frame may not be transmitted immediately and the status
682f05cddf9SRui Paulo 	 * of the transmission must be reported by calling
683f05cddf9SRui Paulo 	 * p2p_send_action_cb() once the frame has either been transmitted or
684f05cddf9SRui Paulo 	 * it has been dropped due to excessive retries or other failure to
685f05cddf9SRui Paulo 	 * transmit.
686f05cddf9SRui Paulo 	 */
687f05cddf9SRui Paulo 	int (*send_action)(void *ctx, unsigned int freq, const u8 *dst,
688f05cddf9SRui Paulo 			   const u8 *src, const u8 *bssid, const u8 *buf,
6894bc52338SCy Schubert 			   size_t len, unsigned int wait_time, int *scheduled);
690f05cddf9SRui Paulo 
691f05cddf9SRui Paulo 	/**
692f05cddf9SRui Paulo 	 * send_action_done - Notify that Action frame sequence was completed
693f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
694f05cddf9SRui Paulo 	 *
695f05cddf9SRui Paulo 	 * This function is called when the Action frame sequence that was
696f05cddf9SRui Paulo 	 * started with send_action() has been completed, i.e., when there is
697f05cddf9SRui Paulo 	 * no need to wait for a response from the destination peer anymore.
698f05cddf9SRui Paulo 	 */
699f05cddf9SRui Paulo 	void (*send_action_done)(void *ctx);
700f05cddf9SRui Paulo 
701f05cddf9SRui Paulo 	/**
702f05cddf9SRui Paulo 	 * start_listen - Start Listen state
703f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
704f05cddf9SRui Paulo 	 * @freq: Frequency of the listen channel in MHz
705f05cddf9SRui Paulo 	 * @duration: Duration for the Listen state in milliseconds
706f05cddf9SRui Paulo 	 * @probe_resp_ie: IE(s) to be added to Probe Response frames
707f05cddf9SRui Paulo 	 * Returns: 0 on success, -1 on failure
708f05cddf9SRui Paulo 	 *
709f05cddf9SRui Paulo 	 * This Listen state may not start immediately since the driver may
710f05cddf9SRui Paulo 	 * have other pending operations to complete first. Once the Listen
711f05cddf9SRui Paulo 	 * state has started, p2p_listen_cb() must be called to notify the P2P
712f05cddf9SRui Paulo 	 * module. Once the Listen state is stopped, p2p_listen_end() must be
713f05cddf9SRui Paulo 	 * called to notify the P2P module that the driver is not in the Listen
714f05cddf9SRui Paulo 	 * state anymore.
715f05cddf9SRui Paulo 	 *
716f05cddf9SRui Paulo 	 * If the send_probe_resp() is not used for generating the response,
717f05cddf9SRui Paulo 	 * the IEs from probe_resp_ie need to be added to the end of the Probe
718f05cddf9SRui Paulo 	 * Response frame body. If send_probe_resp() is used, the probe_resp_ie
719f05cddf9SRui Paulo 	 * information can be ignored.
720f05cddf9SRui Paulo 	 */
721f05cddf9SRui Paulo 	int (*start_listen)(void *ctx, unsigned int freq,
722f05cddf9SRui Paulo 			    unsigned int duration,
723f05cddf9SRui Paulo 			    const struct wpabuf *probe_resp_ie);
724f05cddf9SRui Paulo 	/**
725f05cddf9SRui Paulo 	 * stop_listen - Stop Listen state
726f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
727f05cddf9SRui Paulo 	 *
728f05cddf9SRui Paulo 	 * This callback can be used to stop a Listen state operation that was
729f05cddf9SRui Paulo 	 * previously requested with start_listen().
730f05cddf9SRui Paulo 	 */
731f05cddf9SRui Paulo 	void (*stop_listen)(void *ctx);
732f05cddf9SRui Paulo 
733f05cddf9SRui Paulo 	/**
734f05cddf9SRui Paulo 	 * get_noa - Get current Notice of Absence attribute payload
735f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
736f05cddf9SRui Paulo 	 * @interface_addr: P2P Interface Address of the GO
737f05cddf9SRui Paulo 	 * @buf: Buffer for returning NoA
738f05cddf9SRui Paulo 	 * @buf_len: Buffer length in octets
739f05cddf9SRui Paulo 	 * Returns: Number of octets used in buf, 0 to indicate no NoA is being
740f05cddf9SRui Paulo 	 * advertized, or -1 on failure
741f05cddf9SRui Paulo 	 *
742f05cddf9SRui Paulo 	 * This function is used to fetch the current Notice of Absence
743f05cddf9SRui Paulo 	 * attribute value from GO.
744f05cddf9SRui Paulo 	 */
745f05cddf9SRui Paulo 	int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf,
746f05cddf9SRui Paulo 		       size_t buf_len);
747f05cddf9SRui Paulo 
748f05cddf9SRui Paulo 	/* Callbacks to notify events to upper layer management entity */
749f05cddf9SRui Paulo 
750f05cddf9SRui Paulo 	/**
751f05cddf9SRui Paulo 	 * dev_found - Notification of a found P2P Device
752f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
753f05cddf9SRui Paulo 	 * @addr: Source address of the message triggering this notification
754f05cddf9SRui Paulo 	 * @info: P2P peer information
755f05cddf9SRui Paulo 	 * @new_device: Inform if the peer is newly found
756f05cddf9SRui Paulo 	 *
757f05cddf9SRui Paulo 	 * This callback is used to notify that a new P2P Device has been
758f05cddf9SRui Paulo 	 * found. This may happen, e.g., during Search state based on scan
759f05cddf9SRui Paulo 	 * results or during Listen state based on receive Probe Request and
760f05cddf9SRui Paulo 	 * Group Owner Negotiation Request.
761f05cddf9SRui Paulo 	 */
762f05cddf9SRui Paulo 	void (*dev_found)(void *ctx, const u8 *addr,
763f05cddf9SRui Paulo 			  const struct p2p_peer_info *info,
764f05cddf9SRui Paulo 			  int new_device);
765f05cddf9SRui Paulo 
766f05cddf9SRui Paulo 	/**
767f05cddf9SRui Paulo 	 * dev_lost - Notification of a lost P2P Device
768f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
769f05cddf9SRui Paulo 	 * @dev_addr: P2P Device Address of the lost P2P Device
770f05cddf9SRui Paulo 	 *
771f05cddf9SRui Paulo 	 * This callback is used to notify that a P2P Device has been deleted.
772f05cddf9SRui Paulo 	 */
773f05cddf9SRui Paulo 	void (*dev_lost)(void *ctx, const u8 *dev_addr);
774f05cddf9SRui Paulo 
775f05cddf9SRui Paulo 	/**
7765b9c547cSRui Paulo 	 * find_stopped - Notification of a p2p_find operation stopping
7775b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
7785b9c547cSRui Paulo 	 */
7795b9c547cSRui Paulo 	void (*find_stopped)(void *ctx);
7805b9c547cSRui Paulo 
7815b9c547cSRui Paulo 	/**
782f05cddf9SRui Paulo 	 * go_neg_req_rx - Notification of a receive GO Negotiation Request
783f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
784f05cddf9SRui Paulo 	 * @src: Source address of the message triggering this notification
785f05cddf9SRui Paulo 	 * @dev_passwd_id: WPS Device Password ID
786325151a3SRui Paulo 	 * @go_intent: Peer's GO Intent
787f05cddf9SRui Paulo 	 *
788f05cddf9SRui Paulo 	 * This callback is used to notify that a P2P Device is requesting
789f05cddf9SRui Paulo 	 * group owner negotiation with us, but we do not have all the
790f05cddf9SRui Paulo 	 * necessary information to start GO Negotiation. This indicates that
791f05cddf9SRui Paulo 	 * the local user has not authorized the connection yet by providing a
792f05cddf9SRui Paulo 	 * PIN or PBC button press. This information can be provided with a
793f05cddf9SRui Paulo 	 * call to p2p_connect().
794f05cddf9SRui Paulo 	 */
795325151a3SRui Paulo 	void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id,
796325151a3SRui Paulo 			      u8 go_intent);
797f05cddf9SRui Paulo 
798f05cddf9SRui Paulo 	/**
799f05cddf9SRui Paulo 	 * go_neg_completed - Notification of GO Negotiation results
800f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
801f05cddf9SRui Paulo 	 * @res: GO Negotiation results
802f05cddf9SRui Paulo 	 *
803f05cddf9SRui Paulo 	 * This callback is used to notify that Group Owner Negotiation has
804f05cddf9SRui Paulo 	 * been completed. Non-zero struct p2p_go_neg_results::status indicates
805f05cddf9SRui Paulo 	 * failed negotiation. In case of success, this function is responsible
806f05cddf9SRui Paulo 	 * for creating a new group interface (or using the existing interface
807f05cddf9SRui Paulo 	 * depending on driver features), setting up the group interface in
808f05cddf9SRui Paulo 	 * proper mode based on struct p2p_go_neg_results::role_go and
809f05cddf9SRui Paulo 	 * initializing WPS provisioning either as a Registrar (if GO) or as an
810f05cddf9SRui Paulo 	 * Enrollee. Successful WPS provisioning must be indicated by calling
811f05cddf9SRui Paulo 	 * p2p_wps_success_cb(). The callee is responsible for timing out group
812f05cddf9SRui Paulo 	 * formation if WPS provisioning cannot be completed successfully
813f05cddf9SRui Paulo 	 * within 15 seconds.
814f05cddf9SRui Paulo 	 */
815f05cddf9SRui Paulo 	void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res);
816f05cddf9SRui Paulo 
817f05cddf9SRui Paulo 	/**
818f05cddf9SRui Paulo 	 * sd_request - Callback on Service Discovery Request
819f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
820f05cddf9SRui Paulo 	 * @freq: Frequency (in MHz) of the channel
821f05cddf9SRui Paulo 	 * @sa: Source address of the request
822f05cddf9SRui Paulo 	 * @dialog_token: Dialog token
823f05cddf9SRui Paulo 	 * @update_indic: Service Update Indicator from the source of request
824f05cddf9SRui Paulo 	 * @tlvs: P2P Service Request TLV(s)
825f05cddf9SRui Paulo 	 * @tlvs_len: Length of tlvs buffer in octets
826f05cddf9SRui Paulo 	 *
827f05cddf9SRui Paulo 	 * This callback is used to indicate reception of a service discovery
828f05cddf9SRui Paulo 	 * request. Response to the query must be indicated by calling
829f05cddf9SRui Paulo 	 * p2p_sd_response() with the context information from the arguments to
830f05cddf9SRui Paulo 	 * this callback function.
831f05cddf9SRui Paulo 	 *
832f05cddf9SRui Paulo 	 * This callback handler can be set to %NULL to indicate that service
833f05cddf9SRui Paulo 	 * discovery is not supported.
834f05cddf9SRui Paulo 	 */
835f05cddf9SRui Paulo 	void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token,
836f05cddf9SRui Paulo 			   u16 update_indic, const u8 *tlvs, size_t tlvs_len);
837f05cddf9SRui Paulo 
838f05cddf9SRui Paulo 	/**
839f05cddf9SRui Paulo 	 * sd_response - Callback on Service Discovery Response
840f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
841f05cddf9SRui Paulo 	 * @sa: Source address of the request
842f05cddf9SRui Paulo 	 * @update_indic: Service Update Indicator from the source of response
843f05cddf9SRui Paulo 	 * @tlvs: P2P Service Response TLV(s)
844f05cddf9SRui Paulo 	 * @tlvs_len: Length of tlvs buffer in octets
845f05cddf9SRui Paulo 	 *
846f05cddf9SRui Paulo 	 * This callback is used to indicate reception of a service discovery
847f05cddf9SRui Paulo 	 * response. This callback handler can be set to %NULL if no service
848f05cddf9SRui Paulo 	 * discovery requests are used. The information provided with this call
849f05cddf9SRui Paulo 	 * is replies to the queries scheduled with p2p_sd_request().
850f05cddf9SRui Paulo 	 */
851f05cddf9SRui Paulo 	void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic,
852f05cddf9SRui Paulo 			    const u8 *tlvs, size_t tlvs_len);
853f05cddf9SRui Paulo 
854f05cddf9SRui Paulo 	/**
855f05cddf9SRui Paulo 	 * prov_disc_req - Callback on Provisiong Discovery Request
856f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
857f05cddf9SRui Paulo 	 * @peer: Source address of the request
858f05cddf9SRui Paulo 	 * @config_methods: Requested WPS Config Method
859f05cddf9SRui Paulo 	 * @dev_addr: P2P Device Address of the found P2P Device
860f05cddf9SRui Paulo 	 * @pri_dev_type: Primary Device Type
861f05cddf9SRui Paulo 	 * @dev_name: Device Name
862f05cddf9SRui Paulo 	 * @supp_config_methods: Supported configuration Methods
863f05cddf9SRui Paulo 	 * @dev_capab: Device Capabilities
864f05cddf9SRui Paulo 	 * @group_capab: Group Capabilities
865f05cddf9SRui Paulo 	 * @group_id: P2P Group ID (or %NULL if not included)
866f05cddf9SRui Paulo 	 * @group_id_len: Length of P2P Group ID
867f05cddf9SRui Paulo 	 *
868f05cddf9SRui Paulo 	 * This callback is used to indicate reception of a Provision Discovery
869f05cddf9SRui Paulo 	 * Request frame that the P2P module accepted.
870f05cddf9SRui Paulo 	 */
871f05cddf9SRui Paulo 	void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods,
872f05cddf9SRui Paulo 			      const u8 *dev_addr, const u8 *pri_dev_type,
873f05cddf9SRui Paulo 			      const char *dev_name, u16 supp_config_methods,
874f05cddf9SRui Paulo 			      u8 dev_capab, u8 group_capab,
875f05cddf9SRui Paulo 			      const u8 *group_id, size_t group_id_len);
876f05cddf9SRui Paulo 
877f05cddf9SRui Paulo 	/**
878f05cddf9SRui Paulo 	 * prov_disc_resp - Callback on Provisiong Discovery Response
879f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
880f05cddf9SRui Paulo 	 * @peer: Source address of the response
881f05cddf9SRui Paulo 	 * @config_methods: Value from p2p_prov_disc_req() or 0 on failure
882f05cddf9SRui Paulo 	 *
883f05cddf9SRui Paulo 	 * This callback is used to indicate reception of a Provision Discovery
884f05cddf9SRui Paulo 	 * Response frame for a pending request scheduled with
885f05cddf9SRui Paulo 	 * p2p_prov_disc_req(). This callback handler can be set to %NULL if
886f05cddf9SRui Paulo 	 * provision discovery is not used.
887f05cddf9SRui Paulo 	 */
888f05cddf9SRui Paulo 	void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods);
889f05cddf9SRui Paulo 
890f05cddf9SRui Paulo 	/**
891f05cddf9SRui Paulo 	 * prov_disc_fail - Callback on Provision Discovery failure
892f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
893f05cddf9SRui Paulo 	 * @peer: Source address of the response
894f05cddf9SRui Paulo 	 * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS
8955b9c547cSRui Paulo 	 * @adv_id: If non-zero, then the adv_id of the PD Request
8965b9c547cSRui Paulo 	 * @adv_mac: P2P Device Address of the advertizer
8975b9c547cSRui Paulo 	 * @deferred_session_resp: Deferred session response sent by advertizer
898f05cddf9SRui Paulo 	 *
899f05cddf9SRui Paulo 	 * This callback is used to indicate either a failure or no response
900f05cddf9SRui Paulo 	 * to an earlier provision discovery request.
901f05cddf9SRui Paulo 	 *
902f05cddf9SRui Paulo 	 * This callback handler can be set to %NULL if provision discovery
903f05cddf9SRui Paulo 	 * is not used or failures do not need to be indicated.
904f05cddf9SRui Paulo 	 */
905f05cddf9SRui Paulo 	void (*prov_disc_fail)(void *ctx, const u8 *peer,
9065b9c547cSRui Paulo 			       enum p2p_prov_disc_status status,
9075b9c547cSRui Paulo 			       u32 adv_id, const u8 *adv_mac,
9085b9c547cSRui Paulo 			       const char *deferred_session_resp);
909f05cddf9SRui Paulo 
910f05cddf9SRui Paulo 	/**
911f05cddf9SRui Paulo 	 * invitation_process - Optional callback for processing Invitations
912f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
913f05cddf9SRui Paulo 	 * @sa: Source address of the Invitation Request
914f05cddf9SRui Paulo 	 * @bssid: P2P Group BSSID from the request or %NULL if not included
915f05cddf9SRui Paulo 	 * @go_dev_addr: GO Device Address from P2P Group ID
916f05cddf9SRui Paulo 	 * @ssid: SSID from P2P Group ID
917f05cddf9SRui Paulo 	 * @ssid_len: Length of ssid buffer in octets
918f05cddf9SRui Paulo 	 * @go: Variable for returning whether the local end is GO in the group
919f05cddf9SRui Paulo 	 * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO)
920f05cddf9SRui Paulo 	 * @force_freq: Variable for returning forced frequency for the group
921f05cddf9SRui Paulo 	 * @persistent_group: Whether this is an invitation to reinvoke a
922f05cddf9SRui Paulo 	 *	persistent group (instead of invitation to join an active
923f05cddf9SRui Paulo 	 *	group)
9245b9c547cSRui Paulo 	 * @channels: Available operating channels for the group
9255b9c547cSRui Paulo 	 * @dev_pw_id: Device Password ID for NFC static handover or -1 if not
9265b9c547cSRui Paulo 	 *	used
927f05cddf9SRui Paulo 	 * Returns: Status code (P2P_SC_*)
928f05cddf9SRui Paulo 	 *
929f05cddf9SRui Paulo 	 * This optional callback can be used to implement persistent reconnect
930f05cddf9SRui Paulo 	 * by allowing automatic restarting of persistent groups without user
931f05cddf9SRui Paulo 	 * interaction. If this callback is not implemented (i.e., is %NULL),
932f05cddf9SRui Paulo 	 * the received Invitation Request frames are replied with
933f05cddf9SRui Paulo 	 * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the
934f05cddf9SRui Paulo 	 * invitation_result() callback.
935f05cddf9SRui Paulo 	 *
936f05cddf9SRui Paulo 	 * If the requested parameters are acceptable and the group is known,
937f05cddf9SRui Paulo 	 * %P2P_SC_SUCCESS may be returned. If the requested group is unknown,
938f05cddf9SRui Paulo 	 * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED
939f05cddf9SRui Paulo 	 * can be returned if there is not enough data to provide immediate
940f05cddf9SRui Paulo 	 * response, i.e., if some sort of user interaction is needed. The
941f05cddf9SRui Paulo 	 * invitation_received() callback will be called in that case
942f05cddf9SRui Paulo 	 * immediately after this call.
943f05cddf9SRui Paulo 	 */
944f05cddf9SRui Paulo 	u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid,
945f05cddf9SRui Paulo 				 const u8 *go_dev_addr, const u8 *ssid,
946f05cddf9SRui Paulo 				 size_t ssid_len, int *go, u8 *group_bssid,
9475b9c547cSRui Paulo 				 int *force_freq, int persistent_group,
9485b9c547cSRui Paulo 				 const struct p2p_channels *channels,
9495b9c547cSRui Paulo 				 int dev_pw_id);
950f05cddf9SRui Paulo 
951f05cddf9SRui Paulo 	/**
952f05cddf9SRui Paulo 	 * invitation_received - Callback on Invitation Request RX
953f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
954f05cddf9SRui Paulo 	 * @sa: Source address of the Invitation Request
955f05cddf9SRui Paulo 	 * @bssid: P2P Group BSSID or %NULL if not received
956f05cddf9SRui Paulo 	 * @ssid: SSID of the group
957f05cddf9SRui Paulo 	 * @ssid_len: Length of ssid in octets
958f05cddf9SRui Paulo 	 * @go_dev_addr: GO Device Address
959f05cddf9SRui Paulo 	 * @status: Response Status
960f05cddf9SRui Paulo 	 * @op_freq: Operational frequency for the group
961f05cddf9SRui Paulo 	 *
962f05cddf9SRui Paulo 	 * This callback is used to indicate sending of an Invitation Response
963f05cddf9SRui Paulo 	 * for a received Invitation Request. If status == 0 (success), the
964f05cddf9SRui Paulo 	 * upper layer code is responsible for starting the group. status == 1
965f05cddf9SRui Paulo 	 * indicates need to get user authorization for the group. Other status
966f05cddf9SRui Paulo 	 * values indicate that the invitation request was rejected.
967f05cddf9SRui Paulo 	 */
968f05cddf9SRui Paulo 	void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid,
969f05cddf9SRui Paulo 				    const u8 *ssid, size_t ssid_len,
970f05cddf9SRui Paulo 				    const u8 *go_dev_addr, u8 status,
971f05cddf9SRui Paulo 				    int op_freq);
972f05cddf9SRui Paulo 
973f05cddf9SRui Paulo 	/**
974f05cddf9SRui Paulo 	 * invitation_result - Callback on Invitation result
975f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
976f05cddf9SRui Paulo 	 * @status: Negotiation result (Status Code)
977f05cddf9SRui Paulo 	 * @bssid: P2P Group BSSID or %NULL if not received
9785b9c547cSRui Paulo 	 * @channels: Available operating channels for the group
9795b9c547cSRui Paulo 	 * @addr: Peer address
9805b9c547cSRui Paulo 	 * @freq: Frequency (in MHz) indicated during invitation or 0
9815b9c547cSRui Paulo 	 * @peer_oper_freq: Operating frequency (in MHz) advertized by the peer
9825b9c547cSRui Paulo 	 * during invitation or 0
983f05cddf9SRui Paulo 	 *
984f05cddf9SRui Paulo 	 * This callback is used to indicate result of an Invitation procedure
985f05cddf9SRui Paulo 	 * started with a call to p2p_invite(). The indicated status code is
986f05cddf9SRui Paulo 	 * the value received from the peer in Invitation Response with 0
987f05cddf9SRui Paulo 	 * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a
988f05cddf9SRui Paulo 	 * local failure in transmitting the Invitation Request.
989f05cddf9SRui Paulo 	 */
9905b9c547cSRui Paulo 	void (*invitation_result)(void *ctx, int status, const u8 *bssid,
9915b9c547cSRui Paulo 				  const struct p2p_channels *channels,
9925b9c547cSRui Paulo 				  const u8 *addr, int freq, int peer_oper_freq);
993f05cddf9SRui Paulo 
994f05cddf9SRui Paulo 	/**
995f05cddf9SRui Paulo 	 * go_connected - Check whether we are connected to a GO
996f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
997f05cddf9SRui Paulo 	 * @dev_addr: P2P Device Address of a GO
998f05cddf9SRui Paulo 	 * Returns: 1 if we are connected as a P2P client to the specified GO
999f05cddf9SRui Paulo 	 * or 0 if not.
1000f05cddf9SRui Paulo 	 */
1001f05cddf9SRui Paulo 	int (*go_connected)(void *ctx, const u8 *dev_addr);
10025b9c547cSRui Paulo 
10035b9c547cSRui Paulo 	/**
10045b9c547cSRui Paulo 	 * presence_resp - Callback on Presence Response
10055b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
10065b9c547cSRui Paulo 	 * @src: Source address (GO's P2P Interface Address)
10075b9c547cSRui Paulo 	 * @status: Result of the request (P2P_SC_*)
10085b9c547cSRui Paulo 	 * @noa: Returned NoA value
10095b9c547cSRui Paulo 	 * @noa_len: Length of the NoA buffer in octets
10105b9c547cSRui Paulo 	 */
10115b9c547cSRui Paulo 	void (*presence_resp)(void *ctx, const u8 *src, u8 status,
10125b9c547cSRui Paulo 			      const u8 *noa, size_t noa_len);
10135b9c547cSRui Paulo 
10145b9c547cSRui Paulo 	/**
10155b9c547cSRui Paulo 	 * is_concurrent_session_active - Check whether concurrent session is
10165b9c547cSRui Paulo 	 * active on other virtual interfaces
10175b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
10185b9c547cSRui Paulo 	 * Returns: 1 if concurrent session is active on other virtual interface
10195b9c547cSRui Paulo 	 * or 0 if not.
10205b9c547cSRui Paulo 	 */
10215b9c547cSRui Paulo 	int (*is_concurrent_session_active)(void *ctx);
10225b9c547cSRui Paulo 
10235b9c547cSRui Paulo 	/**
10245b9c547cSRui Paulo 	 * is_p2p_in_progress - Check whether P2P operation is in progress
10255b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
10265b9c547cSRui Paulo 	 * Returns: 1 if P2P operation (e.g., group formation) is in progress
10275b9c547cSRui Paulo 	 * or 0 if not.
10285b9c547cSRui Paulo 	 */
10295b9c547cSRui Paulo 	int (*is_p2p_in_progress)(void *ctx);
10305b9c547cSRui Paulo 
10315b9c547cSRui Paulo 	/**
10325b9c547cSRui Paulo 	 * Determine if we have a persistent group we share with remote peer
1033325151a3SRui Paulo 	 * and allocate interface for this group if needed
10345b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
10355b9c547cSRui Paulo 	 * @addr: Peer device address to search for
10365b9c547cSRui Paulo 	 * @ssid: Persistent group SSID or %NULL if any
10375b9c547cSRui Paulo 	 * @ssid_len: Length of @ssid
1038325151a3SRui Paulo 	 * @go_dev_addr: Buffer for returning GO P2P Device Address
10395b9c547cSRui Paulo 	 * @ret_ssid: Buffer for returning group SSID
10405b9c547cSRui Paulo 	 * @ret_ssid_len: Buffer for returning length of @ssid
1041325151a3SRui Paulo 	 * @intended_iface_addr: Buffer for returning intended iface address
10425b9c547cSRui Paulo 	 * Returns: 1 if a matching persistent group was found, 0 otherwise
10435b9c547cSRui Paulo 	 */
10445b9c547cSRui Paulo 	int (*get_persistent_group)(void *ctx, const u8 *addr, const u8 *ssid,
10455b9c547cSRui Paulo 				    size_t ssid_len, u8 *go_dev_addr,
1046325151a3SRui Paulo 				    u8 *ret_ssid, size_t *ret_ssid_len,
1047325151a3SRui Paulo 				    u8 *intended_iface_addr);
10485b9c547cSRui Paulo 
10495b9c547cSRui Paulo 	/**
10505b9c547cSRui Paulo 	 * Get information about a possible local GO role
10515b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
10525b9c547cSRui Paulo 	 * @intended_addr: Buffer for returning intended GO interface address
10535b9c547cSRui Paulo 	 * @ssid: Buffer for returning group SSID
10545b9c547cSRui Paulo 	 * @ssid_len: Buffer for returning length of @ssid
10555b9c547cSRui Paulo 	 * @group_iface: Buffer for returning whether a separate group interface
10565b9c547cSRui Paulo 	 *	would be used
1057780fb4a2SCy Schubert 	 * @freq: Variable for returning the current operating frequency of a
1058780fb4a2SCy Schubert 	 *	currently running P2P GO.
10595b9c547cSRui Paulo 	 * Returns: 1 if GO info found, 0 otherwise
10605b9c547cSRui Paulo 	 *
10615b9c547cSRui Paulo 	 * This is used to compose New Group settings (SSID, and intended
10625b9c547cSRui Paulo 	 * address) during P2PS provisioning if results of provisioning *might*
10635b9c547cSRui Paulo 	 * result in our being an autonomous GO.
10645b9c547cSRui Paulo 	 */
10655b9c547cSRui Paulo 	int (*get_go_info)(void *ctx, u8 *intended_addr,
1066780fb4a2SCy Schubert 			   u8 *ssid, size_t *ssid_len, int *group_iface,
1067780fb4a2SCy Schubert 			   unsigned int *freq);
10685b9c547cSRui Paulo 
10695b9c547cSRui Paulo 	/**
10705b9c547cSRui Paulo 	 * remove_stale_groups - Remove stale P2PS groups
10715b9c547cSRui Paulo 	 *
10725b9c547cSRui Paulo 	 * Because P2PS stages *potential* GOs, and remote devices can remove
10735b9c547cSRui Paulo 	 * credentials unilaterally, we need to make sure we don't let stale
10745b9c547cSRui Paulo 	 * unusable groups build up.
10755b9c547cSRui Paulo 	 */
10765b9c547cSRui Paulo 	int (*remove_stale_groups)(void *ctx, const u8 *peer, const u8 *go,
10775b9c547cSRui Paulo 				   const u8 *ssid, size_t ssid_len);
10785b9c547cSRui Paulo 
10795b9c547cSRui Paulo 	/**
10805b9c547cSRui Paulo 	 * p2ps_prov_complete - P2PS provisioning complete
10815b9c547cSRui Paulo 	 *
10825b9c547cSRui Paulo 	 * When P2PS provisioning completes (successfully or not) we must
10835b9c547cSRui Paulo 	 * transmit all of the results to the upper layers.
10845b9c547cSRui Paulo 	 */
10855b9c547cSRui Paulo 	void (*p2ps_prov_complete)(void *ctx, u8 status, const u8 *dev,
10865b9c547cSRui Paulo 				   const u8 *adv_mac, const u8 *ses_mac,
10875b9c547cSRui Paulo 				   const u8 *grp_mac, u32 adv_id, u32 ses_id,
10885b9c547cSRui Paulo 				   u8 conncap, int passwd_id,
10895b9c547cSRui Paulo 				   const u8 *persist_ssid,
10905b9c547cSRui Paulo 				   size_t persist_ssid_size, int response_done,
1091325151a3SRui Paulo 				   int prov_start, const char *session_info,
1092780fb4a2SCy Schubert 				   const u8 *feat_cap, size_t feat_cap_len,
1093780fb4a2SCy Schubert 				   unsigned int freq, const u8 *group_ssid,
1094780fb4a2SCy Schubert 				   size_t group_ssid_len);
10955b9c547cSRui Paulo 
10965b9c547cSRui Paulo 	/**
10975b9c547cSRui Paulo 	 * prov_disc_resp_cb - Callback for indicating completion of PD Response
10985b9c547cSRui Paulo 	 * @ctx: Callback context from cb_ctx
10995b9c547cSRui Paulo 	 * Returns: 1 if operation was started, 0 otherwise
11005b9c547cSRui Paulo 	 *
11015b9c547cSRui Paulo 	 * This callback can be used to perform any pending actions after
11025b9c547cSRui Paulo 	 * provisioning. It is mainly used for P2PS pending group creation.
11035b9c547cSRui Paulo 	 */
11045b9c547cSRui Paulo 	int (*prov_disc_resp_cb)(void *ctx);
11055b9c547cSRui Paulo 
11065b9c547cSRui Paulo 	/**
11075b9c547cSRui Paulo 	 * p2ps_group_capability - Determine group capability
1108780fb4a2SCy Schubert 	 * @ctx: Callback context from cb_ctx
1109780fb4a2SCy Schubert 	 * @incoming: Peer requested roles, expressed with P2PS_SETUP_* bitmap.
1110780fb4a2SCy Schubert 	 * @role: Local roles, expressed with P2PS_SETUP_* bitmap.
1111780fb4a2SCy Schubert 	 * @force_freq: Variable for returning forced frequency for the group.
1112780fb4a2SCy Schubert 	 * @pref_freq: Variable for returning preferred frequency for the group.
1113780fb4a2SCy Schubert 	 * Returns: P2PS_SETUP_* bitmap of group capability result.
11145b9c547cSRui Paulo 	 *
1115780fb4a2SCy Schubert 	 * This function can be used to determine group capability and
1116780fb4a2SCy Schubert 	 * frequencies based on information from P2PS PD exchange and the
1117780fb4a2SCy Schubert 	 * current state of ongoing groups and driver capabilities.
11185b9c547cSRui Paulo 	 */
1119780fb4a2SCy Schubert 	u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role,
1120780fb4a2SCy Schubert 				    unsigned int *force_freq,
1121780fb4a2SCy Schubert 				    unsigned int *pref_freq);
1122325151a3SRui Paulo 
1123325151a3SRui Paulo 	/**
1124325151a3SRui Paulo 	 * get_pref_freq_list - Get preferred frequency list for an interface
1125325151a3SRui Paulo 	 * @ctx: Callback context from cb_ctx
1126325151a3SRui Paulo 	 * @go: Whether the use if for GO role
1127325151a3SRui Paulo 	 * @len: Length of freq_list in entries (both IN and OUT)
1128325151a3SRui Paulo 	 * @freq_list: Buffer for returning the preferred frequencies (MHz)
1129325151a3SRui Paulo 	 * Returns: 0 on success, -1 on failure
1130325151a3SRui Paulo 	 *
1131325151a3SRui Paulo 	 * This function can be used to query the preferred frequency list from
1132325151a3SRui Paulo 	 * the driver specific to a particular interface type.
1133325151a3SRui Paulo 	 */
1134325151a3SRui Paulo 	int (*get_pref_freq_list)(void *ctx, int go,
1135325151a3SRui Paulo 				  unsigned int *len, unsigned int *freq_list);
1136f05cddf9SRui Paulo };
1137f05cddf9SRui Paulo 
1138f05cddf9SRui Paulo 
1139f05cddf9SRui Paulo /* P2P module initialization/deinitialization */
1140f05cddf9SRui Paulo 
1141f05cddf9SRui Paulo /**
1142f05cddf9SRui Paulo  * p2p_init - Initialize P2P module
1143f05cddf9SRui Paulo  * @cfg: P2P module configuration
1144f05cddf9SRui Paulo  * Returns: Pointer to private data or %NULL on failure
1145f05cddf9SRui Paulo  *
1146f05cddf9SRui Paulo  * This function is used to initialize global P2P module context (one per
1147f05cddf9SRui Paulo  * device). The P2P module will keep a copy of the configuration data, so the
1148f05cddf9SRui Paulo  * caller does not need to maintain this structure. However, the callback
1149f05cddf9SRui Paulo  * functions and the context parameters to them must be kept available until
1150f05cddf9SRui Paulo  * the P2P module is deinitialized with p2p_deinit().
1151f05cddf9SRui Paulo  */
1152f05cddf9SRui Paulo struct p2p_data * p2p_init(const struct p2p_config *cfg);
1153f05cddf9SRui Paulo 
1154f05cddf9SRui Paulo /**
1155f05cddf9SRui Paulo  * p2p_deinit - Deinitialize P2P module
1156f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1157f05cddf9SRui Paulo  */
1158f05cddf9SRui Paulo void p2p_deinit(struct p2p_data *p2p);
1159f05cddf9SRui Paulo 
1160f05cddf9SRui Paulo /**
1161f05cddf9SRui Paulo  * p2p_flush - Flush P2P module state
1162f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1163f05cddf9SRui Paulo  *
1164f05cddf9SRui Paulo  * This command removes the P2P module state like peer device entries.
1165f05cddf9SRui Paulo  */
1166f05cddf9SRui Paulo void p2p_flush(struct p2p_data *p2p);
1167f05cddf9SRui Paulo 
1168f05cddf9SRui Paulo /**
1169f05cddf9SRui Paulo  * p2p_unauthorize - Unauthorize the specified peer device
1170f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1171f05cddf9SRui Paulo  * @addr: P2P peer entry to be unauthorized
1172f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1173f05cddf9SRui Paulo  *
1174f05cddf9SRui Paulo  * This command removes any connection authorization from the specified P2P
1175f05cddf9SRui Paulo  * peer device address. This can be used, e.g., to cancel effect of a previous
1176f05cddf9SRui Paulo  * p2p_authorize() or p2p_connect() call that has not yet resulted in completed
1177f05cddf9SRui Paulo  * GO Negotiation.
1178f05cddf9SRui Paulo  */
1179f05cddf9SRui Paulo int p2p_unauthorize(struct p2p_data *p2p, const u8 *addr);
1180f05cddf9SRui Paulo 
1181f05cddf9SRui Paulo /**
1182f05cddf9SRui Paulo  * p2p_set_dev_name - Set device name
1183f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1184f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1185f05cddf9SRui Paulo  *
1186f05cddf9SRui Paulo  * This function can be used to update the P2P module configuration with
1187f05cddf9SRui Paulo  * information that was not available at the time of the p2p_init() call.
1188f05cddf9SRui Paulo  */
1189f05cddf9SRui Paulo int p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name);
1190f05cddf9SRui Paulo 
1191f05cddf9SRui Paulo int p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer);
1192f05cddf9SRui Paulo int p2p_set_model_name(struct p2p_data *p2p, const char *model_name);
1193f05cddf9SRui Paulo int p2p_set_model_number(struct p2p_data *p2p, const char *model_number);
1194f05cddf9SRui Paulo int p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number);
1195f05cddf9SRui Paulo 
1196f05cddf9SRui Paulo void p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods);
1197f05cddf9SRui Paulo void p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid);
1198f05cddf9SRui Paulo 
1199f05cddf9SRui Paulo /**
1200f05cddf9SRui Paulo  * p2p_set_pri_dev_type - Set primary device type
1201f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1202f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1203f05cddf9SRui Paulo  *
1204f05cddf9SRui Paulo  * This function can be used to update the P2P module configuration with
1205f05cddf9SRui Paulo  * information that was not available at the time of the p2p_init() call.
1206f05cddf9SRui Paulo  */
1207f05cddf9SRui Paulo int p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type);
1208f05cddf9SRui Paulo 
1209f05cddf9SRui Paulo /**
1210f05cddf9SRui Paulo  * p2p_set_sec_dev_types - Set secondary device types
1211f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1212f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1213f05cddf9SRui Paulo  *
1214f05cddf9SRui Paulo  * This function can be used to update the P2P module configuration with
1215f05cddf9SRui Paulo  * information that was not available at the time of the p2p_init() call.
1216f05cddf9SRui Paulo  */
1217f05cddf9SRui Paulo int p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8],
1218f05cddf9SRui Paulo 			  size_t num_dev_types);
1219f05cddf9SRui Paulo 
1220f05cddf9SRui Paulo int p2p_set_country(struct p2p_data *p2p, const char *country);
1221f05cddf9SRui Paulo 
1222f05cddf9SRui Paulo 
1223f05cddf9SRui Paulo /* Commands from upper layer management entity */
1224f05cddf9SRui Paulo 
1225f05cddf9SRui Paulo enum p2p_discovery_type {
1226f05cddf9SRui Paulo 	P2P_FIND_START_WITH_FULL,
1227f05cddf9SRui Paulo 	P2P_FIND_ONLY_SOCIAL,
1228f05cddf9SRui Paulo 	P2P_FIND_PROGRESSIVE
1229f05cddf9SRui Paulo };
1230f05cddf9SRui Paulo 
1231f05cddf9SRui Paulo /**
1232f05cddf9SRui Paulo  * p2p_find - Start P2P Find (Device Discovery)
1233f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1234f05cddf9SRui Paulo  * @timeout: Timeout for find operation in seconds or 0 for no timeout
1235f05cddf9SRui Paulo  * @type: Device Discovery type
1236f05cddf9SRui Paulo  * @num_req_dev_types: Number of requested device types
1237f05cddf9SRui Paulo  * @req_dev_types: Requested device types array, must be an array
1238f05cddf9SRui Paulo  *	containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no
1239f05cddf9SRui Paulo  *	requested device types.
1240f05cddf9SRui Paulo  * @dev_id: Device ID to search for or %NULL to find all devices
1241f05cddf9SRui Paulo  * @search_delay: Extra delay in milliseconds between search iterations
12425b9c547cSRui Paulo  * @seek_count: Number of ASP Service Strings in the seek_string array
12435b9c547cSRui Paulo  * @seek_string: ASP Service Strings to query for in Probe Requests
12445b9c547cSRui Paulo  * @freq: Requested first scan frequency (in MHz) to modify type ==
12455b9c547cSRui Paulo  *	P2P_FIND_START_WITH_FULL behavior. 0 = Use normal full scan.
12465b9c547cSRui Paulo  *	If p2p_find is already in progress, this parameter is ignored and full
12475b9c547cSRui Paulo  *	scan will be executed.
1248*c1d255d3SCy Schubert  * @include_6ghz: Include 6 GHz channels in P2P find
1249f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1250f05cddf9SRui Paulo  */
1251f05cddf9SRui Paulo int p2p_find(struct p2p_data *p2p, unsigned int timeout,
1252f05cddf9SRui Paulo 	     enum p2p_discovery_type type,
1253f05cddf9SRui Paulo 	     unsigned int num_req_dev_types, const u8 *req_dev_types,
12545b9c547cSRui Paulo 	     const u8 *dev_id, unsigned int search_delay,
1255*c1d255d3SCy Schubert 	     u8 seek_count, const char **seek_string, int freq,
1256*c1d255d3SCy Schubert 	     bool include_6ghz);
12575b9c547cSRui Paulo 
12585b9c547cSRui Paulo /**
12595b9c547cSRui Paulo  * p2p_notify_scan_trigger_status - Indicate scan trigger status
12605b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
12615b9c547cSRui Paulo  * @status: 0 on success, -1 on failure
12625b9c547cSRui Paulo  */
12635b9c547cSRui Paulo void p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status);
1264f05cddf9SRui Paulo 
1265f05cddf9SRui Paulo /**
1266f05cddf9SRui Paulo  * p2p_stop_find - Stop P2P Find (Device Discovery)
1267f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1268f05cddf9SRui Paulo  */
1269f05cddf9SRui Paulo void p2p_stop_find(struct p2p_data *p2p);
1270f05cddf9SRui Paulo 
1271f05cddf9SRui Paulo /**
1272f05cddf9SRui Paulo  * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq
1273f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1274f05cddf9SRui Paulo  * @freq: Frequency in MHz for next operation
1275f05cddf9SRui Paulo  *
1276f05cddf9SRui Paulo  * This is like p2p_stop_find(), but Listen state is not stopped if we are
1277f05cddf9SRui Paulo  * already on the same frequency.
1278f05cddf9SRui Paulo  */
1279f05cddf9SRui Paulo void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq);
1280f05cddf9SRui Paulo 
1281f05cddf9SRui Paulo /**
1282f05cddf9SRui Paulo  * p2p_listen - Start P2P Listen state for specified duration
1283f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1284f05cddf9SRui Paulo  * @timeout: Listen state duration in milliseconds
1285f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1286f05cddf9SRui Paulo  *
1287f05cddf9SRui Paulo  * This function can be used to request the P2P module to keep the device
1288f05cddf9SRui Paulo  * discoverable on the listen channel for an extended set of time. At least in
1289f05cddf9SRui Paulo  * its current form, this is mainly used for testing purposes and may not be of
1290f05cddf9SRui Paulo  * much use for normal P2P operations.
1291f05cddf9SRui Paulo  */
1292f05cddf9SRui Paulo int p2p_listen(struct p2p_data *p2p, unsigned int timeout);
1293f05cddf9SRui Paulo 
1294f05cddf9SRui Paulo /**
12955b9c547cSRui Paulo  * p2p_stop_listen - Stop P2P Listen
12965b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
12975b9c547cSRui Paulo  */
12985b9c547cSRui Paulo void p2p_stop_listen(struct p2p_data *p2p);
12995b9c547cSRui Paulo 
13005b9c547cSRui Paulo /**
1301f05cddf9SRui Paulo  * p2p_connect - Start P2P group formation (GO negotiation)
1302f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1303f05cddf9SRui Paulo  * @peer_addr: MAC address of the peer P2P client
1304f05cddf9SRui Paulo  * @wps_method: WPS method to be used in provisioning
1305f05cddf9SRui Paulo  * @go_intent: Local GO intent value (1..15)
1306f05cddf9SRui Paulo  * @own_interface_addr: Intended interface address to use with the group
1307f05cddf9SRui Paulo  * @force_freq: The only allowed channel frequency in MHz or 0
1308f05cddf9SRui Paulo  * @persistent_group: Whether to create a persistent group (0 = no, 1 =
1309f05cddf9SRui Paulo  * persistent group without persistent reconnect, 2 = persistent group with
1310f05cddf9SRui Paulo  * persistent reconnect)
1311f05cddf9SRui Paulo  * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
1312f05cddf9SRui Paulo  *	a new SSID
1313f05cddf9SRui Paulo  * @force_ssid_len: Length of $force_ssid buffer
1314f05cddf9SRui Paulo  * @pd_before_go_neg: Whether to send Provision Discovery prior to GO
1315f05cddf9SRui Paulo  *	Negotiation as an interoperability workaround when initiating group
1316f05cddf9SRui Paulo  *	formation
1317f05cddf9SRui Paulo  * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
1318f05cddf9SRui Paulo  *	force_freq == 0)
1319f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1320f05cddf9SRui Paulo  */
1321f05cddf9SRui Paulo int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
1322f05cddf9SRui Paulo 		enum p2p_wps_method wps_method,
1323f05cddf9SRui Paulo 		int go_intent, const u8 *own_interface_addr,
1324f05cddf9SRui Paulo 		unsigned int force_freq, int persistent_group,
1325f05cddf9SRui Paulo 		const u8 *force_ssid, size_t force_ssid_len,
13265b9c547cSRui Paulo 		int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id);
1327f05cddf9SRui Paulo 
1328f05cddf9SRui Paulo /**
1329f05cddf9SRui Paulo  * p2p_authorize - Authorize P2P group formation (GO negotiation)
1330f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1331f05cddf9SRui Paulo  * @peer_addr: MAC address of the peer P2P client
1332f05cddf9SRui Paulo  * @wps_method: WPS method to be used in provisioning
1333f05cddf9SRui Paulo  * @go_intent: Local GO intent value (1..15)
1334f05cddf9SRui Paulo  * @own_interface_addr: Intended interface address to use with the group
1335f05cddf9SRui Paulo  * @force_freq: The only allowed channel frequency in MHz or 0
1336f05cddf9SRui Paulo  * @persistent_group: Whether to create a persistent group (0 = no, 1 =
1337f05cddf9SRui Paulo  * persistent group without persistent reconnect, 2 = persistent group with
1338f05cddf9SRui Paulo  * persistent reconnect)
1339f05cddf9SRui Paulo  * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
1340f05cddf9SRui Paulo  *	a new SSID
1341f05cddf9SRui Paulo  * @force_ssid_len: Length of $force_ssid buffer
1342f05cddf9SRui Paulo  * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
1343f05cddf9SRui Paulo  *	force_freq == 0)
1344f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1345f05cddf9SRui Paulo  *
1346f05cddf9SRui Paulo  * This is like p2p_connect(), but the actual group negotiation is not
1347f05cddf9SRui Paulo  * initiated automatically, i.e., the other end is expected to do that.
1348f05cddf9SRui Paulo  */
1349f05cddf9SRui Paulo int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
1350f05cddf9SRui Paulo 		  enum p2p_wps_method wps_method,
1351f05cddf9SRui Paulo 		  int go_intent, const u8 *own_interface_addr,
1352f05cddf9SRui Paulo 		  unsigned int force_freq, int persistent_group,
1353f05cddf9SRui Paulo 		  const u8 *force_ssid, size_t force_ssid_len,
13545b9c547cSRui Paulo 		  unsigned int pref_freq, u16 oob_pw_id);
1355f05cddf9SRui Paulo 
1356f05cddf9SRui Paulo /**
1357f05cddf9SRui Paulo  * p2p_reject - Reject peer device (explicitly block connection attempts)
1358f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1359f05cddf9SRui Paulo  * @peer_addr: MAC address of the peer P2P client
1360f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1361f05cddf9SRui Paulo  */
1362f05cddf9SRui Paulo int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
1363f05cddf9SRui Paulo 
1364f05cddf9SRui Paulo /**
1365f05cddf9SRui Paulo  * p2p_prov_disc_req - Send Provision Discovery Request
1366f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1367f05cddf9SRui Paulo  * @peer_addr: MAC address of the peer P2P client
13685b9c547cSRui Paulo  * @p2ps_prov: Provisioning info for P2PS
1369f05cddf9SRui Paulo  * @config_methods: WPS Config Methods value (only one bit set)
1370f05cddf9SRui Paulo  * @join: Whether this is used by a client joining an active group
1371f05cddf9SRui Paulo  * @force_freq: Forced TX frequency for the frame (mainly for the join case)
1372f05cddf9SRui Paulo  * @user_initiated_pd: Flag to indicate if initiated by user or not
1373f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1374f05cddf9SRui Paulo  *
1375f05cddf9SRui Paulo  * This function can be used to request a discovered P2P peer to display a PIN
1376f05cddf9SRui Paulo  * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us
1377f05cddf9SRui Paulo  * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame
1378f05cddf9SRui Paulo  * is transmitted once immediately and if no response is received, the frame
1379f05cddf9SRui Paulo  * will be sent again whenever the target device is discovered during device
1380f05cddf9SRui Paulo  * dsicovery (start with a p2p_find() call). Response from the peer is
1381f05cddf9SRui Paulo  * indicated with the p2p_config::prov_disc_resp() callback.
1382f05cddf9SRui Paulo  */
1383f05cddf9SRui Paulo int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
13845b9c547cSRui Paulo 		      struct p2ps_provision *p2ps_prov, u16 config_methods,
13855b9c547cSRui Paulo 		      int join, int force_freq,
1386f05cddf9SRui Paulo 		      int user_initiated_pd);
1387f05cddf9SRui Paulo 
1388f05cddf9SRui Paulo /**
1389f05cddf9SRui Paulo  * p2p_sd_request - Schedule a service discovery query
1390f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1391f05cddf9SRui Paulo  * @dst: Destination peer or %NULL to apply for all peers
1392f05cddf9SRui Paulo  * @tlvs: P2P Service Query TLV(s)
1393f05cddf9SRui Paulo  * Returns: Reference to the query or %NULL on failure
1394f05cddf9SRui Paulo  *
1395f05cddf9SRui Paulo  * Response to the query is indicated with the p2p_config::sd_response()
1396f05cddf9SRui Paulo  * callback.
1397f05cddf9SRui Paulo  */
1398f05cddf9SRui Paulo void * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
1399f05cddf9SRui Paulo 		      const struct wpabuf *tlvs);
1400f05cddf9SRui Paulo 
1401f05cddf9SRui Paulo #ifdef CONFIG_WIFI_DISPLAY
1402f05cddf9SRui Paulo void * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
1403f05cddf9SRui Paulo 			  const struct wpabuf *tlvs);
1404f05cddf9SRui Paulo #endif /* CONFIG_WIFI_DISPLAY */
1405f05cddf9SRui Paulo 
1406f05cddf9SRui Paulo /**
1407f05cddf9SRui Paulo  * p2p_sd_cancel_request - Cancel a pending service discovery query
1408f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1409f05cddf9SRui Paulo  * @req: Query reference from p2p_sd_request()
1410f05cddf9SRui Paulo  * Returns: 0 if request for cancelled; -1 if not found
1411f05cddf9SRui Paulo  */
1412f05cddf9SRui Paulo int p2p_sd_cancel_request(struct p2p_data *p2p, void *req);
1413f05cddf9SRui Paulo 
1414f05cddf9SRui Paulo /**
1415f05cddf9SRui Paulo  * p2p_sd_response - Send response to a service discovery query
1416f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1417f05cddf9SRui Paulo  * @freq: Frequency from p2p_config::sd_request() callback
1418f05cddf9SRui Paulo  * @dst: Destination address from p2p_config::sd_request() callback
1419f05cddf9SRui Paulo  * @dialog_token: Dialog token from p2p_config::sd_request() callback
1420f05cddf9SRui Paulo  * @resp_tlvs: P2P Service Response TLV(s)
1421f05cddf9SRui Paulo  *
1422f05cddf9SRui Paulo  * This function is called as a response to the request indicated with
1423f05cddf9SRui Paulo  * p2p_config::sd_request() callback.
1424f05cddf9SRui Paulo  */
1425f05cddf9SRui Paulo void p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
1426f05cddf9SRui Paulo 		     u8 dialog_token, const struct wpabuf *resp_tlvs);
1427f05cddf9SRui Paulo 
1428f05cddf9SRui Paulo /**
1429f05cddf9SRui Paulo  * p2p_sd_service_update - Indicate a change in local services
1430f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1431f05cddf9SRui Paulo  *
1432f05cddf9SRui Paulo  * This function needs to be called whenever there is a change in availability
1433f05cddf9SRui Paulo  * of the local services. This will increment the Service Update Indicator
1434f05cddf9SRui Paulo  * value which will be used in SD Request and Response frames.
1435f05cddf9SRui Paulo  */
1436f05cddf9SRui Paulo void p2p_sd_service_update(struct p2p_data *p2p);
1437f05cddf9SRui Paulo 
1438f05cddf9SRui Paulo 
1439f05cddf9SRui Paulo enum p2p_invite_role {
1440f05cddf9SRui Paulo 	P2P_INVITE_ROLE_GO,
1441f05cddf9SRui Paulo 	P2P_INVITE_ROLE_ACTIVE_GO,
1442f05cddf9SRui Paulo 	P2P_INVITE_ROLE_CLIENT
1443f05cddf9SRui Paulo };
1444f05cddf9SRui Paulo 
1445f05cddf9SRui Paulo /**
1446f05cddf9SRui Paulo  * p2p_invite - Invite a P2P Device into a group
1447f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1448f05cddf9SRui Paulo  * @peer: Device Address of the peer P2P Device
1449f05cddf9SRui Paulo  * @role: Local role in the group
1450f05cddf9SRui Paulo  * @bssid: Group BSSID or %NULL if not known
1451f05cddf9SRui Paulo  * @ssid: Group SSID
1452f05cddf9SRui Paulo  * @ssid_len: Length of ssid in octets
1453f05cddf9SRui Paulo  * @force_freq: The only allowed channel frequency in MHz or 0
1454f05cddf9SRui Paulo  * @go_dev_addr: Forced GO Device Address or %NULL if none
1455f05cddf9SRui Paulo  * @persistent_group: Whether this is to reinvoke a persistent group
14565b9c547cSRui Paulo  * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
14575b9c547cSRui Paulo  *	force_freq == 0)
14585b9c547cSRui Paulo  * @dev_pw_id: Device Password ID from OOB Device Password (NFC) static handover
14595b9c547cSRui Paulo  *	case or -1 if not used
1460f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1461f05cddf9SRui Paulo  */
1462f05cddf9SRui Paulo int p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
1463f05cddf9SRui Paulo 	       const u8 *bssid, const u8 *ssid, size_t ssid_len,
1464f05cddf9SRui Paulo 	       unsigned int force_freq, const u8 *go_dev_addr,
14655b9c547cSRui Paulo 	       int persistent_group, unsigned int pref_freq, int dev_pw_id);
1466f05cddf9SRui Paulo 
1467f05cddf9SRui Paulo /**
1468f05cddf9SRui Paulo  * p2p_presence_req - Request GO presence
1469f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1470f05cddf9SRui Paulo  * @go_interface_addr: GO P2P Interface Address
1471f05cddf9SRui Paulo  * @own_interface_addr: Own P2P Interface Address for this group
1472f05cddf9SRui Paulo  * @freq: Group operating frequence (in MHz)
1473f05cddf9SRui Paulo  * @duration1: Preferred presence duration in microseconds
1474f05cddf9SRui Paulo  * @interval1: Preferred presence interval in microseconds
1475f05cddf9SRui Paulo  * @duration2: Acceptable presence duration in microseconds
1476f05cddf9SRui Paulo  * @interval2: Acceptable presence interval in microseconds
1477f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1478f05cddf9SRui Paulo  *
1479f05cddf9SRui Paulo  * If both duration and interval values are zero, the parameter pair is not
1480f05cddf9SRui Paulo  * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0).
1481f05cddf9SRui Paulo  */
1482f05cddf9SRui Paulo int p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr,
1483f05cddf9SRui Paulo 		     const u8 *own_interface_addr, unsigned int freq,
1484f05cddf9SRui Paulo 		     u32 duration1, u32 interval1, u32 duration2,
1485f05cddf9SRui Paulo 		     u32 interval2);
1486f05cddf9SRui Paulo 
1487f05cddf9SRui Paulo /**
1488f05cddf9SRui Paulo  * p2p_ext_listen - Set Extended Listen Timing
1489f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1490f05cddf9SRui Paulo  * @freq: Group operating frequence (in MHz)
1491f05cddf9SRui Paulo  * @period: Availability period in milliseconds (1-65535; 0 to disable)
1492f05cddf9SRui Paulo  * @interval: Availability interval in milliseconds (1-65535; 0 to disable)
1493f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1494f05cddf9SRui Paulo  *
1495f05cddf9SRui Paulo  * This function can be used to enable or disable (period = interval = 0)
1496f05cddf9SRui Paulo  * Extended Listen Timing. When enabled, the P2P Device will become
1497f05cddf9SRui Paulo  * discoverable (go into Listen State) every @interval milliseconds for at
1498f05cddf9SRui Paulo  * least @period milliseconds.
1499f05cddf9SRui Paulo  */
1500f05cddf9SRui Paulo int p2p_ext_listen(struct p2p_data *p2p, unsigned int period,
1501f05cddf9SRui Paulo 		   unsigned int interval);
1502f05cddf9SRui Paulo 
1503f05cddf9SRui Paulo /* Event notifications from upper layer management operations */
1504f05cddf9SRui Paulo 
1505f05cddf9SRui Paulo /**
1506f05cddf9SRui Paulo  * p2p_wps_success_cb - Report successfully completed WPS provisioning
1507f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1508f05cddf9SRui Paulo  * @mac_addr: Peer address
1509f05cddf9SRui Paulo  *
1510f05cddf9SRui Paulo  * This function is used to report successfully completed WPS provisioning
1511f05cddf9SRui Paulo  * during group formation in both GO/Registrar and client/Enrollee roles.
1512f05cddf9SRui Paulo  */
1513f05cddf9SRui Paulo void p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr);
1514f05cddf9SRui Paulo 
1515f05cddf9SRui Paulo /**
1516f05cddf9SRui Paulo  * p2p_group_formation_failed - Report failed WPS provisioning
1517f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1518f05cddf9SRui Paulo  *
1519f05cddf9SRui Paulo  * This function is used to report failed group formation. This can happen
1520f05cddf9SRui Paulo  * either due to failed WPS provisioning or due to 15 second timeout during
1521f05cddf9SRui Paulo  * the provisioning phase.
1522f05cddf9SRui Paulo  */
1523f05cddf9SRui Paulo void p2p_group_formation_failed(struct p2p_data *p2p);
1524f05cddf9SRui Paulo 
1525f05cddf9SRui Paulo /**
1526f05cddf9SRui Paulo  * p2p_get_provisioning_info - Get any stored provisioning info
1527f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1528f05cddf9SRui Paulo  * @addr: Peer P2P Device Address
1529f05cddf9SRui Paulo  * Returns: WPS provisioning information (WPS config method) or 0 if no
1530f05cddf9SRui Paulo  * information is available
1531f05cddf9SRui Paulo  *
1532f05cddf9SRui Paulo  * This function is used to retrieve stored WPS provisioning info for the given
1533f05cddf9SRui Paulo  * peer.
1534f05cddf9SRui Paulo  */
1535f05cddf9SRui Paulo u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1536f05cddf9SRui Paulo 
1537f05cddf9SRui Paulo /**
1538f05cddf9SRui Paulo  * p2p_clear_provisioning_info - Clear any stored provisioning info
1539f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1540f05cddf9SRui Paulo  * @iface_addr: Peer P2P Device Address
1541f05cddf9SRui Paulo  *
1542f05cddf9SRui Paulo  * This function is used to clear stored WPS provisioning info for the given
1543f05cddf9SRui Paulo  * peer.
1544f05cddf9SRui Paulo  */
1545f05cddf9SRui Paulo void p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1546f05cddf9SRui Paulo 
1547f05cddf9SRui Paulo 
1548f05cddf9SRui Paulo /* Event notifications from lower layer driver operations */
1549f05cddf9SRui Paulo 
1550f05cddf9SRui Paulo /**
1551f05cddf9SRui Paulo  * enum p2p_probe_req_status
1552f05cddf9SRui Paulo  *
1553f05cddf9SRui Paulo  * @P2P_PREQ_MALFORMED: frame was not well-formed
1554f05cddf9SRui Paulo  * @P2P_PREQ_NOT_LISTEN: device isn't in listen state, frame ignored
1555f05cddf9SRui Paulo  * @P2P_PREQ_NOT_P2P: frame was not a P2P probe request
1556f05cddf9SRui Paulo  * @P2P_PREQ_P2P_NOT_PROCESSED: frame was P2P but wasn't processed
1557f05cddf9SRui Paulo  * @P2P_PREQ_P2P_PROCESSED: frame has been processed by P2P
1558f05cddf9SRui Paulo  */
1559f05cddf9SRui Paulo enum p2p_probe_req_status {
1560f05cddf9SRui Paulo 	P2P_PREQ_MALFORMED,
1561f05cddf9SRui Paulo 	P2P_PREQ_NOT_LISTEN,
1562f05cddf9SRui Paulo 	P2P_PREQ_NOT_P2P,
1563f05cddf9SRui Paulo 	P2P_PREQ_NOT_PROCESSED,
1564f05cddf9SRui Paulo 	P2P_PREQ_PROCESSED
1565f05cddf9SRui Paulo };
1566f05cddf9SRui Paulo 
1567f05cddf9SRui Paulo /**
1568f05cddf9SRui Paulo  * p2p_probe_req_rx - Report reception of a Probe Request frame
1569f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1570f05cddf9SRui Paulo  * @addr: Source MAC address
1571f05cddf9SRui Paulo  * @dst: Destination MAC address if available or %NULL
1572f05cddf9SRui Paulo  * @bssid: BSSID if available or %NULL
1573f05cddf9SRui Paulo  * @ie: Information elements from the Probe Request frame body
1574f05cddf9SRui Paulo  * @ie_len: Length of ie buffer in octets
1575325151a3SRui Paulo  * @rx_freq: Probe Request frame RX frequency
1576780fb4a2SCy Schubert  * @p2p_lo_started: Whether P2P Listen Offload is started
1577f05cddf9SRui Paulo  * Returns: value indicating the type and status of the probe request
1578f05cddf9SRui Paulo  */
1579f05cddf9SRui Paulo enum p2p_probe_req_status
1580f05cddf9SRui Paulo p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
1581325151a3SRui Paulo 		 const u8 *bssid, const u8 *ie, size_t ie_len,
1582780fb4a2SCy Schubert 		 unsigned int rx_freq, int p2p_lo_started);
1583f05cddf9SRui Paulo 
1584f05cddf9SRui Paulo /**
1585f05cddf9SRui Paulo  * p2p_rx_action - Report received Action frame
1586f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1587f05cddf9SRui Paulo  * @da: Destination address of the received Action frame
1588f05cddf9SRui Paulo  * @sa: Source address of the received Action frame
1589f05cddf9SRui Paulo  * @bssid: Address 3 of the received Action frame
1590f05cddf9SRui Paulo  * @category: Category of the received Action frame
1591f05cddf9SRui Paulo  * @data: Action frame body after the Category field
1592f05cddf9SRui Paulo  * @len: Length of the data buffer in octets
1593f05cddf9SRui Paulo  * @freq: Frequency (in MHz) on which the frame was received
1594f05cddf9SRui Paulo  */
1595f05cddf9SRui Paulo void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
1596f05cddf9SRui Paulo 		   const u8 *bssid, u8 category,
1597f05cddf9SRui Paulo 		   const u8 *data, size_t len, int freq);
1598f05cddf9SRui Paulo 
1599f05cddf9SRui Paulo /**
1600f05cddf9SRui Paulo  * p2p_scan_res_handler - Indicate a P2P scan results
1601f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1602f05cddf9SRui Paulo  * @bssid: BSSID of the scan result
1603f05cddf9SRui Paulo  * @freq: Frequency of the channel on which the device was found in MHz
16045b9c547cSRui Paulo  * @rx_time: Time when the result was received
1605f05cddf9SRui Paulo  * @level: Signal level (signal strength of the received Beacon/Probe Response
1606f05cddf9SRui Paulo  *	frame)
1607f05cddf9SRui Paulo  * @ies: Pointer to IEs from the scan result
1608f05cddf9SRui Paulo  * @ies_len: Length of the ies buffer
1609f05cddf9SRui Paulo  * Returns: 0 to continue or 1 to stop scan result indication
1610f05cddf9SRui Paulo  *
1611f05cddf9SRui Paulo  * This function is called to indicate a scan result entry with P2P IE from a
1612f05cddf9SRui Paulo  * scan requested with struct p2p_config::p2p_scan(). This can be called during
1613f05cddf9SRui Paulo  * the actual scan process (i.e., whenever a new device is found) or as a
1614f05cddf9SRui Paulo  * sequence of calls after the full scan has been completed. The former option
1615f05cddf9SRui Paulo  * can result in optimized operations, but may not be supported by all
1616f05cddf9SRui Paulo  * driver/firmware designs. The ies buffer need to include at least the P2P IE,
1617f05cddf9SRui Paulo  * but it is recommended to include all IEs received from the device. The
1618f05cddf9SRui Paulo  * caller does not need to check that the IEs contain a P2P IE before calling
1619f05cddf9SRui Paulo  * this function since frames will be filtered internally if needed.
1620f05cddf9SRui Paulo  *
1621f05cddf9SRui Paulo  * This function will return 1 if it wants to stop scan result iteration (and
1622f05cddf9SRui Paulo  * scan in general if it is still in progress). This is used to allow faster
1623f05cddf9SRui Paulo  * start of a pending operation, e.g., to start a pending GO negotiation.
1624f05cddf9SRui Paulo  */
1625f05cddf9SRui Paulo int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
16265b9c547cSRui Paulo 			 struct os_reltime *rx_time, int level, const u8 *ies,
1627f05cddf9SRui Paulo 			 size_t ies_len);
1628f05cddf9SRui Paulo 
1629f05cddf9SRui Paulo /**
1630f05cddf9SRui Paulo  * p2p_scan_res_handled - Indicate end of scan results
1631f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1632*c1d255d3SCy Schubert  * @delay: Search delay for next scan in ms
1633f05cddf9SRui Paulo  *
1634f05cddf9SRui Paulo  * This function is called to indicate that all P2P scan results from a scan
1635f05cddf9SRui Paulo  * have been reported with zero or more calls to p2p_scan_res_handler(). This
1636f05cddf9SRui Paulo  * function must be called as a response to successful
1637f05cddf9SRui Paulo  * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler()
1638f05cddf9SRui Paulo  * calls stopped iteration.
1639f05cddf9SRui Paulo  */
1640*c1d255d3SCy Schubert void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay);
1641f05cddf9SRui Paulo 
1642f05cddf9SRui Paulo enum p2p_send_action_result {
1643f05cddf9SRui Paulo 	P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
1644f05cddf9SRui Paulo 	P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */,
1645f05cddf9SRui Paulo 	P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */
1646f05cddf9SRui Paulo };
1647f05cddf9SRui Paulo 
1648f05cddf9SRui Paulo /**
1649f05cddf9SRui Paulo  * p2p_send_action_cb - Notify TX status of an Action frame
1650f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1651f05cddf9SRui Paulo  * @freq: Channel frequency in MHz
1652f05cddf9SRui Paulo  * @dst: Destination MAC address (Address 1)
1653f05cddf9SRui Paulo  * @src: Source MAC address (Address 2)
1654f05cddf9SRui Paulo  * @bssid: BSSID (Address 3)
1655f05cddf9SRui Paulo  * @result: Result of the transmission attempt
1656f05cddf9SRui Paulo  *
1657f05cddf9SRui Paulo  * This function is used to indicate the result of an Action frame transmission
1658f05cddf9SRui Paulo  * that was requested with struct p2p_config::send_action() callback.
1659f05cddf9SRui Paulo  */
1660f05cddf9SRui Paulo void p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
1661f05cddf9SRui Paulo 			const u8 *src, const u8 *bssid,
1662f05cddf9SRui Paulo 			enum p2p_send_action_result result);
1663f05cddf9SRui Paulo 
1664f05cddf9SRui Paulo /**
1665f05cddf9SRui Paulo  * p2p_listen_cb - Indicate the start of a requested Listen state
1666f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1667f05cddf9SRui Paulo  * @freq: Listen channel frequency in MHz
1668f05cddf9SRui Paulo  * @duration: Duration for the Listen state in milliseconds
1669f05cddf9SRui Paulo  *
1670f05cddf9SRui Paulo  * This function is used to indicate that a Listen state requested with
1671f05cddf9SRui Paulo  * struct p2p_config::start_listen() callback has started.
1672f05cddf9SRui Paulo  */
1673f05cddf9SRui Paulo void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
1674f05cddf9SRui Paulo 		   unsigned int duration);
1675f05cddf9SRui Paulo 
1676f05cddf9SRui Paulo /**
1677f05cddf9SRui Paulo  * p2p_listen_end - Indicate the end of a requested Listen state
1678f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1679f05cddf9SRui Paulo  * @freq: Listen channel frequency in MHz
1680f05cddf9SRui Paulo  * Returns: 0 if no operations were started, 1 if an operation was started
1681f05cddf9SRui Paulo  *
1682f05cddf9SRui Paulo  * This function is used to indicate that a Listen state requested with
1683f05cddf9SRui Paulo  * struct p2p_config::start_listen() callback has ended.
1684f05cddf9SRui Paulo  */
1685f05cddf9SRui Paulo int p2p_listen_end(struct p2p_data *p2p, unsigned int freq);
1686f05cddf9SRui Paulo 
1687f05cddf9SRui Paulo void p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1688f05cddf9SRui Paulo 		      const u8 *ie, size_t ie_len);
1689f05cddf9SRui Paulo 
1690f05cddf9SRui Paulo void p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1691f05cddf9SRui Paulo 			const u8 *ie, size_t ie_len);
1692f05cddf9SRui Paulo 
1693f05cddf9SRui Paulo 
1694f05cddf9SRui Paulo /* Per-group P2P state for GO */
1695f05cddf9SRui Paulo 
1696f05cddf9SRui Paulo struct p2p_group;
1697f05cddf9SRui Paulo 
1698f05cddf9SRui Paulo /**
1699f05cddf9SRui Paulo  * struct p2p_group_config - P2P group configuration
1700f05cddf9SRui Paulo  *
1701f05cddf9SRui Paulo  * This configuration is provided to the P2P module during initialization of
1702f05cddf9SRui Paulo  * the per-group information with p2p_group_init().
1703f05cddf9SRui Paulo  */
1704f05cddf9SRui Paulo struct p2p_group_config {
1705f05cddf9SRui Paulo 	/**
1706f05cddf9SRui Paulo 	 * persistent_group - Whether the group is persistent
1707f05cddf9SRui Paulo 	 * 0 = not a persistent group
1708f05cddf9SRui Paulo 	 * 1 = persistent group without persistent reconnect
1709f05cddf9SRui Paulo 	 * 2 = persistent group with persistent reconnect
1710f05cddf9SRui Paulo 	 */
1711f05cddf9SRui Paulo 	int persistent_group;
1712f05cddf9SRui Paulo 
1713f05cddf9SRui Paulo 	/**
1714f05cddf9SRui Paulo 	 * interface_addr - P2P Interface Address of the group
1715f05cddf9SRui Paulo 	 */
1716f05cddf9SRui Paulo 	u8 interface_addr[ETH_ALEN];
1717f05cddf9SRui Paulo 
1718f05cddf9SRui Paulo 	/**
1719f05cddf9SRui Paulo 	 * max_clients - Maximum number of clients in the group
1720f05cddf9SRui Paulo 	 */
1721f05cddf9SRui Paulo 	unsigned int max_clients;
1722f05cddf9SRui Paulo 
1723f05cddf9SRui Paulo 	/**
1724f05cddf9SRui Paulo 	 * ssid - Group SSID
1725f05cddf9SRui Paulo 	 */
1726325151a3SRui Paulo 	u8 ssid[SSID_MAX_LEN];
1727f05cddf9SRui Paulo 
1728f05cddf9SRui Paulo 	/**
1729f05cddf9SRui Paulo 	 * ssid_len - Length of SSID
1730f05cddf9SRui Paulo 	 */
1731f05cddf9SRui Paulo 	size_t ssid_len;
1732f05cddf9SRui Paulo 
1733f05cddf9SRui Paulo 	/**
17345b9c547cSRui Paulo 	 * freq - Operating channel of the group
17355b9c547cSRui Paulo 	 */
17365b9c547cSRui Paulo 	int freq;
17375b9c547cSRui Paulo 
17385b9c547cSRui Paulo 	/**
1739780fb4a2SCy Schubert 	 * ip_addr_alloc - Whether IP address allocation within 4-way handshake
1740780fb4a2SCy Schubert 	 *	is supported
1741780fb4a2SCy Schubert 	 */
1742780fb4a2SCy Schubert 	int ip_addr_alloc;
1743780fb4a2SCy Schubert 
1744780fb4a2SCy Schubert 	/**
1745f05cddf9SRui Paulo 	 * cb_ctx - Context to use with callback functions
1746f05cddf9SRui Paulo 	 */
1747f05cddf9SRui Paulo 	void *cb_ctx;
1748f05cddf9SRui Paulo 
1749f05cddf9SRui Paulo 	/**
1750f05cddf9SRui Paulo 	 * ie_update - Notification of IE update
1751f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
1752f05cddf9SRui Paulo 	 * @beacon_ies: P2P IE for Beacon frames or %NULL if no change
1753f05cddf9SRui Paulo 	 * @proberesp_ies: P2P Ie for Probe Response frames
1754f05cddf9SRui Paulo 	 *
1755f05cddf9SRui Paulo 	 * P2P module uses this callback function to notify whenever the P2P IE
1756f05cddf9SRui Paulo 	 * in Beacon or Probe Response frames should be updated based on group
1757f05cddf9SRui Paulo 	 * events.
1758f05cddf9SRui Paulo 	 *
1759f05cddf9SRui Paulo 	 * The callee is responsible for freeing the returned buffer(s) with
1760f05cddf9SRui Paulo 	 * wpabuf_free().
1761f05cddf9SRui Paulo 	 */
1762f05cddf9SRui Paulo 	void (*ie_update)(void *ctx, struct wpabuf *beacon_ies,
1763f05cddf9SRui Paulo 			  struct wpabuf *proberesp_ies);
1764f05cddf9SRui Paulo 
1765f05cddf9SRui Paulo 	/**
1766f05cddf9SRui Paulo 	 * idle_update - Notification of changes in group idle state
1767f05cddf9SRui Paulo 	 * @ctx: Callback context from cb_ctx
1768f05cddf9SRui Paulo 	 * @idle: Whether the group is idle (no associated stations)
1769f05cddf9SRui Paulo 	 */
1770f05cddf9SRui Paulo 	void (*idle_update)(void *ctx, int idle);
1771f05cddf9SRui Paulo };
1772f05cddf9SRui Paulo 
1773f05cddf9SRui Paulo /**
1774f05cddf9SRui Paulo  * p2p_group_init - Initialize P2P group
1775f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1776f05cddf9SRui Paulo  * @config: P2P group configuration (will be freed by p2p_group_deinit())
1777f05cddf9SRui Paulo  * Returns: Pointer to private data or %NULL on failure
1778f05cddf9SRui Paulo  *
1779f05cddf9SRui Paulo  * This function is used to initialize per-group P2P module context. Currently,
1780f05cddf9SRui Paulo  * this is only used to manage GO functionality and P2P clients do not need to
1781f05cddf9SRui Paulo  * create an instance of this per-group information.
1782f05cddf9SRui Paulo  */
1783f05cddf9SRui Paulo struct p2p_group * p2p_group_init(struct p2p_data *p2p,
1784f05cddf9SRui Paulo 				  struct p2p_group_config *config);
1785f05cddf9SRui Paulo 
1786f05cddf9SRui Paulo /**
1787f05cddf9SRui Paulo  * p2p_group_deinit - Deinitialize P2P group
1788f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1789f05cddf9SRui Paulo  */
1790f05cddf9SRui Paulo void p2p_group_deinit(struct p2p_group *group);
1791f05cddf9SRui Paulo 
1792f05cddf9SRui Paulo /**
1793f05cddf9SRui Paulo  * p2p_group_notif_assoc - Notification of P2P client association with GO
1794f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1795f05cddf9SRui Paulo  * @addr: Interface address of the P2P client
1796f05cddf9SRui Paulo  * @ie: IEs from the (Re)association Request frame
1797f05cddf9SRui Paulo  * @len: Length of the ie buffer in octets
1798f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1799f05cddf9SRui Paulo  */
1800f05cddf9SRui Paulo int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
1801f05cddf9SRui Paulo 			  const u8 *ie, size_t len);
1802f05cddf9SRui Paulo 
1803f05cddf9SRui Paulo /**
1804f05cddf9SRui Paulo  * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response
1805f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1806f05cddf9SRui Paulo  * @status: Status value (P2P_SC_SUCCESS if association succeeded)
1807f05cddf9SRui Paulo  * Returns: P2P IE for (Re)association Response or %NULL on failure
1808f05cddf9SRui Paulo  *
1809f05cddf9SRui Paulo  * The caller is responsible for freeing the returned buffer with
1810f05cddf9SRui Paulo  * wpabuf_free().
1811f05cddf9SRui Paulo  */
1812f05cddf9SRui Paulo struct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status);
1813f05cddf9SRui Paulo 
1814f05cddf9SRui Paulo /**
1815f05cddf9SRui Paulo  * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO
1816f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1817f05cddf9SRui Paulo  * @addr: Interface address of the P2P client
1818f05cddf9SRui Paulo  */
1819f05cddf9SRui Paulo void p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr);
1820f05cddf9SRui Paulo 
1821f05cddf9SRui Paulo /**
1822f05cddf9SRui Paulo  * p2p_group_notif_formation_done - Notification of completed group formation
1823f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1824f05cddf9SRui Paulo  */
1825f05cddf9SRui Paulo void p2p_group_notif_formation_done(struct p2p_group *group);
1826f05cddf9SRui Paulo 
1827f05cddf9SRui Paulo /**
1828f05cddf9SRui Paulo  * p2p_group_notif_noa - Notification of NoA change
1829f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1830f05cddf9SRui Paulo  * @noa: Notice of Absence attribute payload, %NULL if none
1831f05cddf9SRui Paulo  * @noa_len: Length of noa buffer in octets
1832f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1833f05cddf9SRui Paulo  *
1834f05cddf9SRui Paulo  * Notify the P2P group management about a new NoA contents. This will be
1835f05cddf9SRui Paulo  * inserted into the P2P IEs in Beacon and Probe Response frames with rest of
1836f05cddf9SRui Paulo  * the group information.
1837f05cddf9SRui Paulo  */
1838f05cddf9SRui Paulo int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
1839f05cddf9SRui Paulo 			size_t noa_len);
1840f05cddf9SRui Paulo 
1841f05cddf9SRui Paulo /**
1842f05cddf9SRui Paulo  * p2p_group_match_dev_type - Match device types in group with requested type
1843f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1844f05cddf9SRui Paulo  * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs)
1845f05cddf9SRui Paulo  * Returns: 1 on match, 0 on mismatch
1846f05cddf9SRui Paulo  *
1847f05cddf9SRui Paulo  * This function can be used to match the Requested Device Type attribute in
1848f05cddf9SRui Paulo  * WPS IE with the device types of a group member for deciding whether a GO
1849f05cddf9SRui Paulo  * should reply to a Probe Request frame. Match will be reported if the WPS IE
1850f05cddf9SRui Paulo  * is not requested any specific device type.
1851f05cddf9SRui Paulo  */
1852f05cddf9SRui Paulo int p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps);
1853f05cddf9SRui Paulo 
1854f05cddf9SRui Paulo /**
1855f05cddf9SRui Paulo  * p2p_group_match_dev_id - Match P2P Device Address in group with requested device id
1856f05cddf9SRui Paulo  */
1857f05cddf9SRui Paulo int p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p);
1858f05cddf9SRui Paulo 
1859f05cddf9SRui Paulo /**
1860f05cddf9SRui Paulo  * p2p_group_go_discover - Send GO Discoverability Request to a group client
1861f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
1862f05cddf9SRui Paulo  * Returns: 0 on success (frame scheduled); -1 if client was not found
1863f05cddf9SRui Paulo  */
1864f05cddf9SRui Paulo int p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
1865f05cddf9SRui Paulo 			  const u8 *searching_dev, int rx_freq);
1866f05cddf9SRui Paulo 
1867f05cddf9SRui Paulo 
1868f05cddf9SRui Paulo /* Generic helper functions */
1869f05cddf9SRui Paulo 
1870f05cddf9SRui Paulo /**
1871f05cddf9SRui Paulo  * p2p_ie_text - Build text format description of P2P IE
1872f05cddf9SRui Paulo  * @p2p_ie: P2P IE
1873f05cddf9SRui Paulo  * @buf: Buffer for returning text
1874f05cddf9SRui Paulo  * @end: Pointer to the end of the buf area
1875f05cddf9SRui Paulo  * Returns: Number of octets written to the buffer or -1 on failure
1876f05cddf9SRui Paulo  *
1877f05cddf9SRui Paulo  * This function can be used to parse P2P IE contents into text format
1878f05cddf9SRui Paulo  * field=value lines.
1879f05cddf9SRui Paulo  */
1880f05cddf9SRui Paulo int p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end);
1881f05cddf9SRui Paulo 
1882f05cddf9SRui Paulo /**
1883f05cddf9SRui Paulo  * p2p_scan_result_text - Build text format description of P2P IE
1884f05cddf9SRui Paulo  * @ies: Information elements from scan results
1885f05cddf9SRui Paulo  * @ies_len: ies buffer length in octets
1886f05cddf9SRui Paulo  * @buf: Buffer for returning text
1887f05cddf9SRui Paulo  * @end: Pointer to the end of the buf area
1888f05cddf9SRui Paulo  * Returns: Number of octets written to the buffer or -1 on failure
1889f05cddf9SRui Paulo  *
1890f05cddf9SRui Paulo  * This function can be used to parse P2P IE contents into text format
1891f05cddf9SRui Paulo  * field=value lines.
1892f05cddf9SRui Paulo  */
1893f05cddf9SRui Paulo int p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end);
1894f05cddf9SRui Paulo 
1895f05cddf9SRui Paulo /**
1896f05cddf9SRui Paulo  * p2p_parse_dev_addr_in_p2p_ie - Parse P2P Device Address from a concatenated
1897f05cddf9SRui Paulo  * P2P IE
1898f05cddf9SRui Paulo  * @p2p_ie: P2P IE
1899f05cddf9SRui Paulo  * @dev_addr: Buffer for returning P2P Device Address
1900f05cddf9SRui Paulo  * Returns: 0 on success or -1 if P2P Device Address could not be parsed
1901f05cddf9SRui Paulo  */
1902f05cddf9SRui Paulo int p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr);
1903f05cddf9SRui Paulo 
1904f05cddf9SRui Paulo /**
1905f05cddf9SRui Paulo  * p2p_parse_dev_addr - Parse P2P Device Address from P2P IE(s)
1906f05cddf9SRui Paulo  * @ies: Information elements from scan results
1907f05cddf9SRui Paulo  * @ies_len: ies buffer length in octets
1908f05cddf9SRui Paulo  * @dev_addr: Buffer for returning P2P Device Address
1909f05cddf9SRui Paulo  * Returns: 0 on success or -1 if P2P Device Address could not be parsed
1910f05cddf9SRui Paulo  */
1911f05cddf9SRui Paulo int p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr);
1912f05cddf9SRui Paulo 
1913f05cddf9SRui Paulo /**
1914f05cddf9SRui Paulo  * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame
1915f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1916f05cddf9SRui Paulo  * @bssid: BSSID
1917f05cddf9SRui Paulo  * @buf: Buffer for writing the P2P IE
1918f05cddf9SRui Paulo  * @len: Maximum buf length in octets
1919f05cddf9SRui Paulo  * @p2p_group: Whether this is for association with a P2P GO
1920f05cddf9SRui Paulo  * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none
1921f05cddf9SRui Paulo  * Returns: Number of octets written into buf or -1 on failure
1922f05cddf9SRui Paulo  */
1923f05cddf9SRui Paulo int p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf,
1924f05cddf9SRui Paulo 		     size_t len, int p2p_group, struct wpabuf *p2p_ie);
1925f05cddf9SRui Paulo 
1926f05cddf9SRui Paulo /**
1927f05cddf9SRui Paulo  * p2p_scan_ie - Build P2P IE for Probe Request
1928f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1929f05cddf9SRui Paulo  * @ies: Buffer for writing P2P IE
1930f05cddf9SRui Paulo  * @dev_id: Device ID to search for or %NULL for any
1931780fb4a2SCy Schubert  * @bands: Frequency bands used in the scan (enum wpa_radio_work_band bitmap)
1932f05cddf9SRui Paulo  */
1933780fb4a2SCy Schubert void p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id,
1934780fb4a2SCy Schubert 		 unsigned int bands);
1935f05cddf9SRui Paulo 
1936f05cddf9SRui Paulo /**
1937f05cddf9SRui Paulo  * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie
1938f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1939f05cddf9SRui Paulo  * Returns: Number of octets that p2p_scan_ie() may add to the buffer
1940f05cddf9SRui Paulo  */
1941f05cddf9SRui Paulo size_t p2p_scan_ie_buf_len(struct p2p_data *p2p);
1942f05cddf9SRui Paulo 
1943f05cddf9SRui Paulo /**
1944f05cddf9SRui Paulo  * p2p_go_params - Generate random P2P group parameters
1945f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1946f05cddf9SRui Paulo  * @params: Buffer for parameters
1947f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
1948f05cddf9SRui Paulo  */
1949f05cddf9SRui Paulo int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params);
1950f05cddf9SRui Paulo 
1951f05cddf9SRui Paulo /**
1952f05cddf9SRui Paulo  * p2p_get_group_capab - Get Group Capability from P2P IE data
1953f05cddf9SRui Paulo  * @p2p_ie: P2P IE(s) contents
1954f05cddf9SRui Paulo  * Returns: Group Capability
1955f05cddf9SRui Paulo  */
1956f05cddf9SRui Paulo u8 p2p_get_group_capab(const struct wpabuf *p2p_ie);
1957f05cddf9SRui Paulo 
1958f05cddf9SRui Paulo /**
1959f05cddf9SRui Paulo  * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection
1960f05cddf9SRui Paulo  * @p2p_ie: P2P IE(s) contents
1961f05cddf9SRui Paulo  * Returns: 0 if cross connection is allow, 1 if not
1962f05cddf9SRui Paulo  */
1963f05cddf9SRui Paulo int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie);
1964f05cddf9SRui Paulo 
1965f05cddf9SRui Paulo /**
1966f05cddf9SRui Paulo  * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data
1967f05cddf9SRui Paulo  * @p2p_ie: P2P IE(s) contents
1968f05cddf9SRui Paulo  * Returns: Pointer to P2P Device Address or %NULL if not included
1969f05cddf9SRui Paulo  */
1970f05cddf9SRui Paulo const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie);
1971f05cddf9SRui Paulo 
1972f05cddf9SRui Paulo /**
1973f05cddf9SRui Paulo  * p2p_get_peer_info - Get P2P peer information
1974f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1975f05cddf9SRui Paulo  * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
1976f05cddf9SRui Paulo  * @next: Whether to select the peer entry following the one indicated by addr
1977f05cddf9SRui Paulo  * Returns: Pointer to peer info or %NULL if not found
1978f05cddf9SRui Paulo  */
1979f05cddf9SRui Paulo const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p,
1980f05cddf9SRui Paulo 					       const u8 *addr, int next);
1981f05cddf9SRui Paulo 
1982f05cddf9SRui Paulo /**
1983f05cddf9SRui Paulo  * p2p_get_peer_info_txt - Get internal P2P peer information in text format
1984f05cddf9SRui Paulo  * @info: Pointer to P2P peer info from p2p_get_peer_info()
1985f05cddf9SRui Paulo  * @buf: Buffer for returning text
1986f05cddf9SRui Paulo  * @buflen: Maximum buffer length
1987f05cddf9SRui Paulo  * Returns: Number of octets written to the buffer or -1 on failure
1988f05cddf9SRui Paulo  *
1989f05cddf9SRui Paulo  * Note: This information is internal to the P2P module and subject to change.
1990f05cddf9SRui Paulo  * As such, this should not really be used by external programs for purposes
1991f05cddf9SRui Paulo  * other than debugging.
1992f05cddf9SRui Paulo  */
1993f05cddf9SRui Paulo int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
1994f05cddf9SRui Paulo 			  char *buf, size_t buflen);
1995f05cddf9SRui Paulo 
1996f05cddf9SRui Paulo /**
1997f05cddf9SRui Paulo  * p2p_peer_known - Check whether P2P peer is known
1998f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
1999f05cddf9SRui Paulo  * @addr: P2P Device Address of the peer
2000f05cddf9SRui Paulo  * Returns: 1 if the specified device is in the P2P peer table or 0 if not
2001f05cddf9SRui Paulo  */
2002f05cddf9SRui Paulo int p2p_peer_known(struct p2p_data *p2p, const u8 *addr);
2003f05cddf9SRui Paulo 
2004f05cddf9SRui Paulo /**
2005f05cddf9SRui Paulo  * p2p_set_client_discoverability - Set client discoverability capability
2006f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2007f05cddf9SRui Paulo  * @enabled: Whether client discoverability will be enabled
2008f05cddf9SRui Paulo  *
2009f05cddf9SRui Paulo  * This function can be used to disable (and re-enable) client discoverability.
2010f05cddf9SRui Paulo  * This capability is enabled by default and should not be disabled in normal
2011f05cddf9SRui Paulo  * use cases, i.e., this is mainly for testing purposes.
2012f05cddf9SRui Paulo  */
2013f05cddf9SRui Paulo void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled);
2014f05cddf9SRui Paulo 
2015f05cddf9SRui Paulo /**
2016f05cddf9SRui Paulo  * p2p_set_managed_oper - Set managed P2P Device operations capability
2017f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2018f05cddf9SRui Paulo  * @enabled: Whether managed P2P Device operations will be enabled
2019f05cddf9SRui Paulo  */
2020f05cddf9SRui Paulo void p2p_set_managed_oper(struct p2p_data *p2p, int enabled);
2021f05cddf9SRui Paulo 
20225b9c547cSRui Paulo /**
20235b9c547cSRui Paulo  * p2p_config_get_random_social - Return a random social channel
20245b9c547cSRui Paulo  * @p2p: P2P config
20255b9c547cSRui Paulo  * @op_class: Selected operating class
20265b9c547cSRui Paulo  * @op_channel: Selected social channel
20274bc52338SCy Schubert  * @avoid_list: Channel ranges to try to avoid or %NULL
20284bc52338SCy Schubert  * @disallow_list: Channel ranges to discard or %NULL
20295b9c547cSRui Paulo  * Returns: 0 on success, -1 on failure
20305b9c547cSRui Paulo  *
20315b9c547cSRui Paulo  * This function is used before p2p_init is called. A random social channel
20325b9c547cSRui Paulo  * from supports bands 2.4 GHz (channels 1,6,11) and 60 GHz (channel 2) is
20335b9c547cSRui Paulo  * returned on success.
20345b9c547cSRui Paulo  */
20355b9c547cSRui Paulo int p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class,
20364bc52338SCy Schubert 				 u8 *op_channel,
20374bc52338SCy Schubert 				 struct wpa_freq_range_list *avoid_list,
20384bc52338SCy Schubert 				 struct wpa_freq_range_list *disallow_list);
20395b9c547cSRui Paulo 
20405b9c547cSRui Paulo int p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel,
20415b9c547cSRui Paulo 			   u8 forced);
20425b9c547cSRui Paulo 
20435b9c547cSRui Paulo u8 p2p_get_listen_channel(struct p2p_data *p2p);
2044f05cddf9SRui Paulo 
2045f05cddf9SRui Paulo int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len);
2046f05cddf9SRui Paulo 
2047f05cddf9SRui Paulo int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
2048f05cddf9SRui Paulo 			   u8 *iface_addr);
2049f05cddf9SRui Paulo int p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
2050f05cddf9SRui Paulo 			   u8 *dev_addr);
2051f05cddf9SRui Paulo 
2052f05cddf9SRui Paulo void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
2053f05cddf9SRui Paulo 
2054f05cddf9SRui Paulo /**
2055f05cddf9SRui Paulo  * p2p_set_cross_connect - Set cross connection capability
2056f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2057f05cddf9SRui Paulo  * @enabled: Whether cross connection will be enabled
2058f05cddf9SRui Paulo  */
2059f05cddf9SRui Paulo void p2p_set_cross_connect(struct p2p_data *p2p, int enabled);
2060f05cddf9SRui Paulo 
2061f05cddf9SRui Paulo int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr);
2062f05cddf9SRui Paulo 
2063f05cddf9SRui Paulo /**
2064f05cddf9SRui Paulo  * p2p_set_intra_bss_dist - Set intra BSS distribution
2065f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2066f05cddf9SRui Paulo  * @enabled: Whether intra BSS distribution will be enabled
2067f05cddf9SRui Paulo  */
2068f05cddf9SRui Paulo void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled);
2069f05cddf9SRui Paulo 
20705b9c547cSRui Paulo int p2p_channels_includes_freq(const struct p2p_channels *channels,
20715b9c547cSRui Paulo 			       unsigned int freq);
20725b9c547cSRui Paulo 
20735b9c547cSRui Paulo int p2p_channels_to_freqs(const struct p2p_channels *channels,
20745b9c547cSRui Paulo 			  int *freq_list, unsigned int max_len);
20755b9c547cSRui Paulo 
2076f05cddf9SRui Paulo /**
2077f05cddf9SRui Paulo  * p2p_supported_freq - Check whether channel is supported for P2P
2078f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2079f05cddf9SRui Paulo  * @freq: Channel frequency in MHz
2080f05cddf9SRui Paulo  * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
2081f05cddf9SRui Paulo  */
2082f05cddf9SRui Paulo int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq);
2083f05cddf9SRui Paulo 
20845b9c547cSRui Paulo /**
20855b9c547cSRui Paulo  * p2p_supported_freq_go - Check whether channel is supported for P2P GO operation
20865b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
20875b9c547cSRui Paulo  * @freq: Channel frequency in MHz
20885b9c547cSRui Paulo  * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
20895b9c547cSRui Paulo  */
20905b9c547cSRui Paulo int p2p_supported_freq_go(struct p2p_data *p2p, unsigned int freq);
20915b9c547cSRui Paulo 
20925b9c547cSRui Paulo /**
20935b9c547cSRui Paulo  * p2p_supported_freq_cli - Check whether channel is supported for P2P client operation
20945b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
20955b9c547cSRui Paulo  * @freq: Channel frequency in MHz
20965b9c547cSRui Paulo  * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
20975b9c547cSRui Paulo  */
20985b9c547cSRui Paulo int p2p_supported_freq_cli(struct p2p_data *p2p, unsigned int freq);
20995b9c547cSRui Paulo 
21005b9c547cSRui Paulo /**
21015b9c547cSRui Paulo  * p2p_get_pref_freq - Get channel from preferred channel list
21025b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
21035b9c547cSRui Paulo  * @channels: List of channels
21045b9c547cSRui Paulo  * Returns: Preferred channel
21055b9c547cSRui Paulo  */
21065b9c547cSRui Paulo unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
21075b9c547cSRui Paulo 			       const struct p2p_channels *channels);
21085b9c547cSRui Paulo 
21095b9c547cSRui Paulo void p2p_update_channel_list(struct p2p_data *p2p,
21105b9c547cSRui Paulo 			     const struct p2p_channels *chan,
21115b9c547cSRui Paulo 			     const struct p2p_channels *cli_chan);
2112f05cddf9SRui Paulo 
2113*c1d255d3SCy Schubert bool is_p2p_6ghz_disabled(struct p2p_data *p2p);
2114*c1d255d3SCy Schubert 
2115f05cddf9SRui Paulo /**
2116f05cddf9SRui Paulo  * p2p_set_best_channels - Update best channel information
2117f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2118f05cddf9SRui Paulo  * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band
2119f05cddf9SRui Paulo  * @freq_5: Frequency (MHz) of best channel in 5 GHz band
2120f05cddf9SRui Paulo  * @freq_overall: Frequency (MHz) of best channel overall
2121f05cddf9SRui Paulo  */
2122f05cddf9SRui Paulo void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
2123f05cddf9SRui Paulo 			   int freq_overall);
2124f05cddf9SRui Paulo 
21255b9c547cSRui Paulo /**
21265b9c547cSRui Paulo  * p2p_set_own_freq_preference - Set own preference for channel
21275b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
21285b9c547cSRui Paulo  * @freq: Frequency (MHz) of the preferred channel or 0 if no preference
21295b9c547cSRui Paulo  *
21305b9c547cSRui Paulo  * This function can be used to set a preference on the operating channel based
21315b9c547cSRui Paulo  * on frequencies used on the other virtual interfaces that share the same
21325b9c547cSRui Paulo  * radio. If non-zero, this is used to try to avoid multi-channel concurrency.
21335b9c547cSRui Paulo  */
21345b9c547cSRui Paulo void p2p_set_own_freq_preference(struct p2p_data *p2p, int freq);
21355b9c547cSRui Paulo 
2136f05cddf9SRui Paulo const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p);
2137f05cddf9SRui Paulo 
2138f05cddf9SRui Paulo /**
2139f05cddf9SRui Paulo  * p2p_get_group_num_members - Get number of members in group
2140f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
2141f05cddf9SRui Paulo  * Returns: Number of members in the group
2142f05cddf9SRui Paulo  */
2143f05cddf9SRui Paulo unsigned int p2p_get_group_num_members(struct p2p_group *group);
2144f05cddf9SRui Paulo 
2145f05cddf9SRui Paulo /**
21465b9c547cSRui Paulo  * p2p_client_limit_reached - Check if client limit is reached
21475b9c547cSRui Paulo  * @group: P2P group context from p2p_group_init()
21485b9c547cSRui Paulo  * Returns: 1 if no of clients limit reached
21495b9c547cSRui Paulo  */
21505b9c547cSRui Paulo int p2p_client_limit_reached(struct p2p_group *group);
21515b9c547cSRui Paulo 
21525b9c547cSRui Paulo /**
2153f05cddf9SRui Paulo  * p2p_iterate_group_members - Iterate group members
2154f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
2155f05cddf9SRui Paulo  * @next: iteration pointer, must be a pointer to a void * that is set to %NULL
2156f05cddf9SRui Paulo  *	on the first call and not modified later
21575b9c547cSRui Paulo  * Returns: A P2P Device Address for each call and %NULL for no more members
2158f05cddf9SRui Paulo  */
2159f05cddf9SRui Paulo const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
2160f05cddf9SRui Paulo 
2161f05cddf9SRui Paulo /**
2162780fb4a2SCy Schubert  * p2p_group_get_client_interface_addr - Get P2P Interface Address of a client in a group
2163780fb4a2SCy Schubert  * @group: P2P group context from p2p_group_init()
2164780fb4a2SCy Schubert  * @dev_addr: P2P Device Address of the client
2165780fb4a2SCy Schubert  * Returns: P2P Interface Address of the client if found or %NULL if no match
2166780fb4a2SCy Schubert  * found
2167780fb4a2SCy Schubert  */
2168780fb4a2SCy Schubert const u8 * p2p_group_get_client_interface_addr(struct p2p_group *group,
2169780fb4a2SCy Schubert 					       const u8 *dev_addr);
2170780fb4a2SCy Schubert 
2171780fb4a2SCy Schubert /**
2172f05cddf9SRui Paulo  * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group
2173f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
2174f05cddf9SRui Paulo  * @addr: P2P Interface Address of the client
2175f05cddf9SRui Paulo  * Returns: P2P Device Address of the client if found or %NULL if no match
2176f05cddf9SRui Paulo  * found
2177f05cddf9SRui Paulo  */
2178f05cddf9SRui Paulo const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
2179f05cddf9SRui Paulo 
2180f05cddf9SRui Paulo /**
2181f05cddf9SRui Paulo  * p2p_group_is_client_connected - Check whether a specific client is connected
2182f05cddf9SRui Paulo  * @group: P2P group context from p2p_group_init()
2183f05cddf9SRui Paulo  * @addr: P2P Device Address of the client
2184f05cddf9SRui Paulo  * Returns: 1 if client is connected or 0 if not
2185f05cddf9SRui Paulo  */
2186f05cddf9SRui Paulo int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr);
2187f05cddf9SRui Paulo 
2188f05cddf9SRui Paulo /**
21895b9c547cSRui Paulo  * p2p_group_get_config - Get the group configuration
21905b9c547cSRui Paulo  * @group: P2P group context from p2p_group_init()
21915b9c547cSRui Paulo  * Returns: The group configuration pointer
21925b9c547cSRui Paulo  */
21935b9c547cSRui Paulo const struct p2p_group_config * p2p_group_get_config(struct p2p_group *group);
21945b9c547cSRui Paulo 
21955b9c547cSRui Paulo /**
21965b9c547cSRui Paulo  * p2p_loop_on_all_groups - Run the given callback on all groups
21975b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
21985b9c547cSRui Paulo  * @group_callback: The callback function pointer
21995b9c547cSRui Paulo  * @user_data: Some user data pointer which can be %NULL
22005b9c547cSRui Paulo  *
22015b9c547cSRui Paulo  * The group_callback function can stop the iteration by returning 0.
22025b9c547cSRui Paulo  */
22035b9c547cSRui Paulo void p2p_loop_on_all_groups(struct p2p_data *p2p,
22045b9c547cSRui Paulo 			    int (*group_callback)(struct p2p_group *group,
22055b9c547cSRui Paulo 						  void *user_data),
22065b9c547cSRui Paulo 			    void *user_data);
22075b9c547cSRui Paulo 
22085b9c547cSRui Paulo /**
2209f05cddf9SRui Paulo  * p2p_get_peer_found - Get P2P peer info structure of a found peer
2210f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2211f05cddf9SRui Paulo  * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
2212f05cddf9SRui Paulo  * @next: Whether to select the peer entry following the one indicated by addr
2213f05cddf9SRui Paulo  * Returns: The first P2P peer info available or %NULL if no such peer exists
2214f05cddf9SRui Paulo  */
2215f05cddf9SRui Paulo const struct p2p_peer_info *
2216f05cddf9SRui Paulo p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
2217f05cddf9SRui Paulo 
2218f05cddf9SRui Paulo /**
2219f05cddf9SRui Paulo  * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions
2220f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2221f05cddf9SRui Paulo  */
2222f05cddf9SRui Paulo void p2p_remove_wps_vendor_extensions(struct p2p_data *p2p);
2223f05cddf9SRui Paulo 
2224f05cddf9SRui Paulo /**
2225f05cddf9SRui Paulo  * p2p_add_wps_vendor_extension - Add a WPS vendor extension
2226f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2227f05cddf9SRui Paulo  * @vendor_ext: The vendor extensions to add
2228f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
2229f05cddf9SRui Paulo  *
2230f05cddf9SRui Paulo  * The wpabuf structures in the array are owned by the P2P
2231f05cddf9SRui Paulo  * module after this call.
2232f05cddf9SRui Paulo  */
2233f05cddf9SRui Paulo int p2p_add_wps_vendor_extension(struct p2p_data *p2p,
2234f05cddf9SRui Paulo 				 const struct wpabuf *vendor_ext);
2235f05cddf9SRui Paulo 
2236f05cddf9SRui Paulo /**
2237f05cddf9SRui Paulo  * p2p_set_oper_channel - Set the P2P operating channel
2238f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2239f05cddf9SRui Paulo  * @op_reg_class: Operating regulatory class to set
2240f05cddf9SRui Paulo  * @op_channel: operating channel to set
2241f05cddf9SRui Paulo  * @cfg_op_channel : Whether op_channel is hardcoded in configuration
2242f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
2243f05cddf9SRui Paulo  */
2244f05cddf9SRui Paulo int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
2245f05cddf9SRui Paulo 			 int cfg_op_channel);
2246f05cddf9SRui Paulo 
2247f05cddf9SRui Paulo /**
2248f05cddf9SRui Paulo  * p2p_set_pref_chan - Set P2P preferred channel list
2249f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2250f05cddf9SRui Paulo  * @num_pref_chan: Number of entries in pref_chan list
2251f05cddf9SRui Paulo  * @pref_chan: Preferred channels or %NULL to remove preferences
2252f05cddf9SRui Paulo  * Returns: 0 on success, -1 on failure
2253f05cddf9SRui Paulo  */
2254f05cddf9SRui Paulo int p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan,
2255f05cddf9SRui Paulo 		      const struct p2p_channel *pref_chan);
2256f05cddf9SRui Paulo 
2257f05cddf9SRui Paulo /**
22585b9c547cSRui Paulo  * p2p_set_no_go_freq - Set no GO channel ranges
2259f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
22605b9c547cSRui Paulo  * @list: Channel ranges or %NULL to remove restriction
22615b9c547cSRui Paulo  * Returns: 0 on success, -1 on failure
2262f05cddf9SRui Paulo  */
22635b9c547cSRui Paulo int p2p_set_no_go_freq(struct p2p_data *p2p,
22645b9c547cSRui Paulo 		       const struct wpa_freq_range_list *list);
2265f05cddf9SRui Paulo 
2266f05cddf9SRui Paulo /**
22675b9c547cSRui Paulo  * p2p_in_progress - Check whether a P2P operation is progress
2268f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
22695b9c547cSRui Paulo  * Returns: 0 if P2P module is idle, 1 if an operation is in progress but not
22705b9c547cSRui Paulo  * in search state, or 2 if search state operation is in progress
2271f05cddf9SRui Paulo  */
22725b9c547cSRui Paulo int p2p_in_progress(struct p2p_data *p2p);
2273f05cddf9SRui Paulo 
2274f05cddf9SRui Paulo const char * p2p_wps_method_text(enum p2p_wps_method method);
2275f05cddf9SRui Paulo 
2276f05cddf9SRui Paulo /**
2277f05cddf9SRui Paulo  * p2p_set_config_timeout - Set local config timeouts
2278f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2279f05cddf9SRui Paulo  * @go_timeout: Time in 10 ms units it takes to start the GO mode
2280f05cddf9SRui Paulo  * @client_timeout: Time in 10 ms units it takes to start the client mode
2281f05cddf9SRui Paulo  */
2282f05cddf9SRui Paulo void p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout,
2283f05cddf9SRui Paulo 			    u8 client_timeout);
2284f05cddf9SRui Paulo 
2285f05cddf9SRui Paulo int p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie);
2286f05cddf9SRui Paulo int p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie);
2287f05cddf9SRui Paulo int p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie);
2288f05cddf9SRui Paulo int p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie);
2289f05cddf9SRui Paulo int p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie);
2290f05cddf9SRui Paulo int p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie);
2291f05cddf9SRui Paulo int p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie);
2292f05cddf9SRui Paulo int p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie);
2293f05cddf9SRui Paulo int p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem);
229485732ac8SCy Schubert int p2p_set_wfd_r2_dev_info(struct p2p_data *p2p, const struct wpabuf *elem);
2295f05cddf9SRui Paulo int p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem);
2296f05cddf9SRui Paulo int p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p,
2297f05cddf9SRui Paulo 				  const struct wpabuf *elem);
2298f05cddf9SRui Paulo struct wpabuf * wifi_display_encaps(struct wpabuf *subelems);
2299f05cddf9SRui Paulo 
2300f05cddf9SRui Paulo /**
2301f05cddf9SRui Paulo  * p2p_set_disc_int - Set min/max discoverable interval for p2p_find
2302f05cddf9SRui Paulo  * @p2p: P2P module context from p2p_init()
2303f05cddf9SRui Paulo  * @min_disc_int: minDiscoverableInterval (in units of 100 TU); default 1
2304f05cddf9SRui Paulo  * @max_disc_int: maxDiscoverableInterval (in units of 100 TU); default 3
2305f05cddf9SRui Paulo  * @max_disc_tu: Maximum number of TUs (1.024 ms) for discoverable interval; or
2306f05cddf9SRui Paulo  *	-1 not to limit
2307f05cddf9SRui Paulo  * Returns: 0 on success, or -1 on failure
2308f05cddf9SRui Paulo  *
2309f05cddf9SRui Paulo  * This function can be used to configure minDiscoverableInterval and
2310f05cddf9SRui Paulo  * maxDiscoverableInterval parameters for the Listen state during device
2311f05cddf9SRui Paulo  * discovery (p2p_find). A random number of 100 TU units is picked for each
2312f05cddf9SRui Paulo  * Listen state iteration from [min_disc_int,max_disc_int] range.
2313f05cddf9SRui Paulo  *
2314780fb4a2SCy Schubert  * max_disc_tu can be used to further limit the discoverable duration. However,
2315f05cddf9SRui Paulo  * it should be noted that use of this parameter is not recommended since it
2316f05cddf9SRui Paulo  * would not be compliant with the P2P specification.
2317f05cddf9SRui Paulo  */
2318f05cddf9SRui Paulo int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int,
2319f05cddf9SRui Paulo 		     int max_disc_tu);
2320f05cddf9SRui Paulo 
23215b9c547cSRui Paulo /**
23225b9c547cSRui Paulo  * p2p_get_state_txt - Get current P2P state for debug purposes
23235b9c547cSRui Paulo  * @p2p: P2P module context from p2p_init()
23245b9c547cSRui Paulo  * Returns: Name of the current P2P module state
23255b9c547cSRui Paulo  *
23265b9c547cSRui Paulo  * It should be noted that the P2P module state names are internal information
23275b9c547cSRui Paulo  * and subject to change at any point, i.e., this information should be used
23285b9c547cSRui Paulo  * mainly for debugging purposes.
23295b9c547cSRui Paulo  */
23305b9c547cSRui Paulo const char * p2p_get_state_txt(struct p2p_data *p2p);
23315b9c547cSRui Paulo 
23325b9c547cSRui Paulo struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p,
23335b9c547cSRui Paulo 					   int client_freq,
23345b9c547cSRui Paulo 					   const u8 *go_dev_addr,
23355b9c547cSRui Paulo 					   const u8 *ssid, size_t ssid_len);
23365b9c547cSRui Paulo struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p,
23375b9c547cSRui Paulo 					   int client_freq,
23385b9c547cSRui Paulo 					   const u8 *go_dev_addr,
23395b9c547cSRui Paulo 					   const u8 *ssid, size_t ssid_len);
23405b9c547cSRui Paulo 
23415b9c547cSRui Paulo struct p2p_nfc_params {
23425b9c547cSRui Paulo 	int sel;
23435b9c547cSRui Paulo 	const u8 *wsc_attr;
23445b9c547cSRui Paulo 	size_t wsc_len;
23455b9c547cSRui Paulo 	const u8 *p2p_attr;
23465b9c547cSRui Paulo 	size_t p2p_len;
23475b9c547cSRui Paulo 
23485b9c547cSRui Paulo 	enum {
23495b9c547cSRui Paulo 		NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG,
23505b9c547cSRui Paulo 		BOTH_GO, PEER_CLIENT
23515b9c547cSRui Paulo 	} next_step;
23525b9c547cSRui Paulo 	struct p2p_peer_info *peer;
23535b9c547cSRui Paulo 	u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 +
23545b9c547cSRui Paulo 		      WPS_OOB_DEVICE_PASSWORD_LEN];
23555b9c547cSRui Paulo 	size_t oob_dev_pw_len;
23565b9c547cSRui Paulo 	int go_freq;
23575b9c547cSRui Paulo 	u8 go_dev_addr[ETH_ALEN];
2358325151a3SRui Paulo 	u8 go_ssid[SSID_MAX_LEN];
23595b9c547cSRui Paulo 	size_t go_ssid_len;
23605b9c547cSRui Paulo };
23615b9c547cSRui Paulo 
23625b9c547cSRui Paulo int p2p_process_nfc_connection_handover(struct p2p_data *p2p,
23635b9c547cSRui Paulo 					struct p2p_nfc_params *params);
23645b9c547cSRui Paulo 
23655b9c547cSRui Paulo void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id,
23665b9c547cSRui Paulo 				      int go_intent,
23675b9c547cSRui Paulo 				      const u8 *own_interface_addr);
23685b9c547cSRui Paulo 
23695b9c547cSRui Paulo int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len);
23705b9c547cSRui Paulo 
23715b9c547cSRui Paulo void p2p_loop_on_known_peers(struct p2p_data *p2p,
23725b9c547cSRui Paulo 			     void (*peer_callback)(struct p2p_peer_info *peer,
23735b9c547cSRui Paulo 						   void *user_data),
23745b9c547cSRui Paulo 			     void *user_data);
23755b9c547cSRui Paulo 
23765b9c547cSRui Paulo void p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem);
23775b9c547cSRui Paulo 
23785b9c547cSRui Paulo void p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr);
23795b9c547cSRui Paulo 
23805b9c547cSRui Paulo struct p2ps_advertisement *
23815b9c547cSRui Paulo p2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id);
23825b9c547cSRui Paulo int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id,
23835b9c547cSRui Paulo 			const char *adv_str, u8 svc_state,
2384325151a3SRui Paulo 			u16 config_methods, const char *svc_info,
2385325151a3SRui Paulo 			const u8 *cpt_priority);
23865b9c547cSRui Paulo int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id);
2387325151a3SRui Paulo void p2p_service_flush_asp(struct p2p_data *p2p);
23885b9c547cSRui Paulo struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p);
23895b9c547cSRui Paulo 
2390325151a3SRui Paulo /**
2391325151a3SRui Paulo  * p2p_expire_peers - Periodic cleanup function to expire peers
2392325151a3SRui Paulo  * @p2p: P2P module context from p2p_init()
2393325151a3SRui Paulo  *
2394325151a3SRui Paulo  * This is a cleanup function that the entity calling p2p_init() is
2395325151a3SRui Paulo  * expected to call periodically to clean up expired peer entries.
2396325151a3SRui Paulo  */
2397325151a3SRui Paulo void p2p_expire_peers(struct p2p_data *p2p);
2398325151a3SRui Paulo 
2399325151a3SRui Paulo void p2p_set_own_pref_freq_list(struct p2p_data *p2p,
2400325151a3SRui Paulo 				const unsigned int *pref_freq_list,
2401325151a3SRui Paulo 				unsigned int size);
240285732ac8SCy Schubert void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class,
240385732ac8SCy Schubert 				   u8 chan);
2404325151a3SRui Paulo 
2405325151a3SRui Paulo /**
2406325151a3SRui Paulo  * p2p_group_get_common_freqs - Get the group common frequencies
2407325151a3SRui Paulo  * @group: P2P group context from p2p_group_init()
2408325151a3SRui Paulo  * @common_freqs: On return will hold the group common frequencies
2409325151a3SRui Paulo  * @num: On return will hold the number of group common frequencies
2410325151a3SRui Paulo  * Returns: 0 on success, -1 otherwise
2411325151a3SRui Paulo  */
2412325151a3SRui Paulo int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
2413325151a3SRui Paulo 			       unsigned int *num);
2414325151a3SRui Paulo 
2415780fb4a2SCy Schubert struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p,
2416780fb4a2SCy Schubert 					      unsigned int freq);
2417780fb4a2SCy Schubert 
2418*c1d255d3SCy Schubert void p2p_set_6ghz_dev_capab(struct p2p_data *p2p, bool allow_6ghz);
2419*c1d255d3SCy Schubert bool is_p2p_6ghz_capable(struct p2p_data *p2p);
2420*c1d255d3SCy Schubert bool p2p_is_peer_6ghz_capab(struct p2p_data *p2p, const u8 *addr);
2421*c1d255d3SCy Schubert bool p2p_peer_wfd_enabled(struct p2p_data *p2p, const u8 *peer_addr);
2422*c1d255d3SCy Schubert bool p2p_wfd_enabled(struct p2p_data *p2p);
2423*c1d255d3SCy Schubert bool is_p2p_allow_6ghz(struct p2p_data *p2p);
2424*c1d255d3SCy Schubert void set_p2p_allow_6ghz(struct p2p_data *p2p, bool value);
2425*c1d255d3SCy Schubert int p2p_remove_6ghz_channels(unsigned int *pref_freq_list, int size);
2426*c1d255d3SCy Schubert 
2427f05cddf9SRui Paulo #endif /* P2P_H */
2428