1252190Srpaulo/*
2252190Srpaulo * Wi-Fi Direct - P2P module
3252190Srpaulo * Copyright (c) 2009-2010, Atheros Communications
4252190Srpaulo *
5252190Srpaulo * This software may be distributed under the terms of the BSD license.
6252190Srpaulo * See README for more details.
7252190Srpaulo */
8252190Srpaulo
9252190Srpaulo#ifndef P2P_H
10252190Srpaulo#define P2P_H
11252190Srpaulo
12252190Srpaulo/**
13252190Srpaulo * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes
14252190Srpaulo */
15252190Srpaulo#define P2P_MAX_REG_CLASSES 10
16252190Srpaulo
17252190Srpaulo/**
18252190Srpaulo * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class
19252190Srpaulo */
20252190Srpaulo#define P2P_MAX_REG_CLASS_CHANNELS 20
21252190Srpaulo
22252190Srpaulo/**
23252190Srpaulo * struct p2p_channels - List of supported channels
24252190Srpaulo */
25252190Srpaulostruct p2p_channels {
26252190Srpaulo	/**
27252190Srpaulo	 * struct p2p_reg_class - Supported regulatory class
28252190Srpaulo	 */
29252190Srpaulo	struct p2p_reg_class {
30252190Srpaulo		/**
31252190Srpaulo		 * reg_class - Regulatory class (IEEE 802.11-2007, Annex J)
32252190Srpaulo		 */
33252190Srpaulo		u8 reg_class;
34252190Srpaulo
35252190Srpaulo		/**
36252190Srpaulo		 * channel - Supported channels
37252190Srpaulo		 */
38252190Srpaulo		u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
39252190Srpaulo
40252190Srpaulo		/**
41252190Srpaulo		 * channels - Number of channel entries in use
42252190Srpaulo		 */
43252190Srpaulo		size_t channels;
44252190Srpaulo	} reg_class[P2P_MAX_REG_CLASSES];
45252190Srpaulo
46252190Srpaulo	/**
47252190Srpaulo	 * reg_classes - Number of reg_class entries in use
48252190Srpaulo	 */
49252190Srpaulo	size_t reg_classes;
50252190Srpaulo};
51252190Srpaulo
52252190Srpauloenum p2p_wps_method {
53252190Srpaulo	WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC
54252190Srpaulo};
55252190Srpaulo
56252190Srpaulo/**
57252190Srpaulo * struct p2p_go_neg_results - P2P Group Owner Negotiation results
58252190Srpaulo */
59252190Srpaulostruct p2p_go_neg_results {
60252190Srpaulo	/**
61252190Srpaulo	 * status - Negotiation result (Status Code)
62252190Srpaulo	 *
63252190Srpaulo	 * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate
64252190Srpaulo	 * failed negotiation.
65252190Srpaulo	 */
66252190Srpaulo	int status;
67252190Srpaulo
68252190Srpaulo	/**
69252190Srpaulo	 * role_go - Whether local end is Group Owner
70252190Srpaulo	 */
71252190Srpaulo	int role_go;
72252190Srpaulo
73252190Srpaulo	/**
74252190Srpaulo	 * freq - Frequency of the group operational channel in MHz
75252190Srpaulo	 */
76252190Srpaulo	int freq;
77252190Srpaulo
78252190Srpaulo	int ht40;
79252190Srpaulo
80252190Srpaulo	/**
81252190Srpaulo	 * ssid - SSID of the group
82252190Srpaulo	 */
83252190Srpaulo	u8 ssid[32];
84252190Srpaulo
85252190Srpaulo	/**
86252190Srpaulo	 * ssid_len - Length of SSID in octets
87252190Srpaulo	 */
88252190Srpaulo	size_t ssid_len;
89252190Srpaulo
90252190Srpaulo	/**
91252190Srpaulo	 * psk - WPA pre-shared key (256 bits) (GO only)
92252190Srpaulo	 */
93252190Srpaulo	u8 psk[32];
94252190Srpaulo
95252190Srpaulo	/**
96252190Srpaulo	 * psk_set - Whether PSK field is configured (GO only)
97252190Srpaulo	 */
98252190Srpaulo	int psk_set;
99252190Srpaulo
100252190Srpaulo	/**
101252190Srpaulo	 * passphrase - WPA2-Personal passphrase for the group (GO only)
102252190Srpaulo	 */
103252190Srpaulo	char passphrase[64];
104252190Srpaulo
105252190Srpaulo	/**
106252190Srpaulo	 * peer_device_addr - P2P Device Address of the peer
107252190Srpaulo	 */
108252190Srpaulo	u8 peer_device_addr[ETH_ALEN];
109252190Srpaulo
110252190Srpaulo	/**
111252190Srpaulo	 * peer_interface_addr - P2P Interface Address of the peer
112252190Srpaulo	 */
113252190Srpaulo	u8 peer_interface_addr[ETH_ALEN];
114252190Srpaulo
115252190Srpaulo	/**
116252190Srpaulo	 * wps_method - WPS method to be used during provisioning
117252190Srpaulo	 */
118252190Srpaulo	enum p2p_wps_method wps_method;
119252190Srpaulo
120252190Srpaulo#define P2P_MAX_CHANNELS 50
121252190Srpaulo
122252190Srpaulo	/**
123252190Srpaulo	 * freq_list - Zero-terminated list of possible operational channels
124252190Srpaulo	 */
125252190Srpaulo	int freq_list[P2P_MAX_CHANNELS];
126252190Srpaulo
127252190Srpaulo	/**
128252190Srpaulo	 * persistent_group - Whether the group should be made persistent
129252190Srpaulo	 * 0 = not persistent
130252190Srpaulo	 * 1 = persistent group without persistent reconnect
131252190Srpaulo	 * 2 = persistent group with persistent reconnect
132252190Srpaulo	 */
133252190Srpaulo	int persistent_group;
134252190Srpaulo
135252190Srpaulo	/**
136252190Srpaulo	 * peer_config_timeout - Peer configuration timeout (in 10 msec units)
137252190Srpaulo	 */
138252190Srpaulo	unsigned int peer_config_timeout;
139252190Srpaulo};
140252190Srpaulo
141252190Srpaulostruct p2p_data;
142252190Srpaulo
143252190Srpauloenum p2p_scan_type {
144252190Srpaulo	P2P_SCAN_SOCIAL,
145252190Srpaulo	P2P_SCAN_FULL,
146252190Srpaulo	P2P_SCAN_SOCIAL_PLUS_ONE
147252190Srpaulo};
148252190Srpaulo
149252190Srpaulo#define P2P_MAX_WPS_VENDOR_EXT 10
150252190Srpaulo
151252190Srpaulo/**
152252190Srpaulo * struct p2p_peer_info - P2P peer information
153252190Srpaulo */
154252190Srpaulostruct p2p_peer_info {
155252190Srpaulo	/**
156252190Srpaulo	 * p2p_device_addr - P2P Device Address of the peer
157252190Srpaulo	 */
158252190Srpaulo	u8 p2p_device_addr[ETH_ALEN];
159252190Srpaulo
160252190Srpaulo	/**
161252190Srpaulo	 * pri_dev_type - Primary Device Type
162252190Srpaulo	 */
163252190Srpaulo	u8 pri_dev_type[8];
164252190Srpaulo
165252190Srpaulo	/**
166252190Srpaulo	 * device_name - Device Name (0..32 octets encoded in UTF-8)
167252190Srpaulo	 */
168252190Srpaulo	char device_name[33];
169252190Srpaulo
170252190Srpaulo	/**
171252190Srpaulo	 * manufacturer - Manufacturer (0..64 octets encoded in UTF-8)
172252190Srpaulo	 */
173252190Srpaulo	char manufacturer[65];
174252190Srpaulo
175252190Srpaulo	/**
176252190Srpaulo	 * model_name - Model Name (0..32 octets encoded in UTF-8)
177252190Srpaulo	 */
178252190Srpaulo	char model_name[33];
179252190Srpaulo
180252190Srpaulo	/**
181252190Srpaulo	 * model_number - Model Number (0..32 octets encoded in UTF-8)
182252190Srpaulo	 */
183252190Srpaulo	char model_number[33];
184252190Srpaulo
185252190Srpaulo	/**
186252190Srpaulo	 * serial_number - Serial Number (0..32 octets encoded in UTF-8)
187252190Srpaulo	 */
188252190Srpaulo	char serial_number[33];
189252190Srpaulo
190252190Srpaulo	/**
191252190Srpaulo	 * level - Signal level
192252190Srpaulo	 */
193252190Srpaulo	int level;
194252190Srpaulo
195252190Srpaulo	/**
196252190Srpaulo	 * config_methods - WPS Configuration Methods
197252190Srpaulo	 */
198252190Srpaulo	u16 config_methods;
199252190Srpaulo
200252190Srpaulo	/**
201252190Srpaulo	 * dev_capab - Device Capabilities
202252190Srpaulo	 */
203252190Srpaulo	u8 dev_capab;
204252190Srpaulo
205252190Srpaulo	/**
206252190Srpaulo	 * group_capab - Group Capabilities
207252190Srpaulo	 */
208252190Srpaulo	u8 group_capab;
209252190Srpaulo
210252190Srpaulo	/**
211252190Srpaulo	 * wps_sec_dev_type_list - WPS secondary device type list
212252190Srpaulo	 *
213252190Srpaulo	 * This list includes from 0 to 16 Secondary Device Types as indicated
214252190Srpaulo	 * by wps_sec_dev_type_list_len (8 * number of types).
215252190Srpaulo	 */
216252190Srpaulo	u8 wps_sec_dev_type_list[128];
217252190Srpaulo
218252190Srpaulo	/**
219252190Srpaulo	 * wps_sec_dev_type_list_len - Length of secondary device type list
220252190Srpaulo	 */
221252190Srpaulo	size_t wps_sec_dev_type_list_len;
222252190Srpaulo
223252190Srpaulo	struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
224252190Srpaulo
225252190Srpaulo	/**
226252190Srpaulo	 * wfd_subelems - Wi-Fi Display subelements from WFD IE(s)
227252190Srpaulo	 */
228252190Srpaulo	struct wpabuf *wfd_subelems;
229252190Srpaulo};
230252190Srpaulo
231252190Srpauloenum p2p_prov_disc_status {
232252190Srpaulo	P2P_PROV_DISC_SUCCESS,
233252190Srpaulo	P2P_PROV_DISC_TIMEOUT,
234252190Srpaulo	P2P_PROV_DISC_REJECTED,
235252190Srpaulo	P2P_PROV_DISC_TIMEOUT_JOIN,
236252190Srpaulo};
237252190Srpaulo
238252190Srpaulostruct p2p_channel {
239252190Srpaulo	u8 op_class;
240252190Srpaulo	u8 chan;
241252190Srpaulo};
242252190Srpaulo
243252190Srpaulo/**
244252190Srpaulo * struct p2p_config - P2P configuration
245252190Srpaulo *
246252190Srpaulo * This configuration is provided to the P2P module during initialization with
247252190Srpaulo * p2p_init().
248252190Srpaulo */
249252190Srpaulostruct p2p_config {
250252190Srpaulo	/**
251252190Srpaulo	 * country - Country code to use in P2P operations
252252190Srpaulo	 */
253252190Srpaulo	char country[3];
254252190Srpaulo
255252190Srpaulo	/**
256252190Srpaulo	 * reg_class - Regulatory class for own listen channel
257252190Srpaulo	 */
258252190Srpaulo	u8 reg_class;
259252190Srpaulo
260252190Srpaulo	/**
261252190Srpaulo	 * channel - Own listen channel
262252190Srpaulo	 */
263252190Srpaulo	u8 channel;
264252190Srpaulo
265252190Srpaulo	/**
266252190Srpaulo	 * Regulatory class for own operational channel
267252190Srpaulo	 */
268252190Srpaulo	u8 op_reg_class;
269252190Srpaulo
270252190Srpaulo	/**
271252190Srpaulo	 * op_channel - Own operational channel
272252190Srpaulo	 */
273252190Srpaulo	u8 op_channel;
274252190Srpaulo
275252190Srpaulo	/**
276252190Srpaulo	 * cfg_op_channel - Whether op_channel is hardcoded in configuration
277252190Srpaulo	 */
278252190Srpaulo	u8 cfg_op_channel;
279252190Srpaulo
280252190Srpaulo	/**
281252190Srpaulo	 * channels - Own supported regulatory classes and channels
282252190Srpaulo	 *
283252190Srpaulo	 * List of supposerted channels per regulatory class. The regulatory
284252190Srpaulo	 * classes are defined in IEEE Std 802.11-2007 Annex J and the
285252190Srpaulo	 * numbering of the clases depends on the configured country code.
286252190Srpaulo	 */
287252190Srpaulo	struct p2p_channels channels;
288252190Srpaulo
289252190Srpaulo	/**
290252190Srpaulo	 * num_pref_chan - Number of pref_chan entries
291252190Srpaulo	 */
292252190Srpaulo	unsigned int num_pref_chan;
293252190Srpaulo
294252190Srpaulo	/**
295252190Srpaulo	 * pref_chan - Preferred channels for GO Negotiation
296252190Srpaulo	 */
297252190Srpaulo	struct p2p_channel *pref_chan;
298252190Srpaulo
299252190Srpaulo	/**
300252190Srpaulo	 * pri_dev_type - Primary Device Type (see WPS)
301252190Srpaulo	 */
302252190Srpaulo	u8 pri_dev_type[8];
303252190Srpaulo
304252190Srpaulo	/**
305252190Srpaulo	 * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types
306252190Srpaulo	 */
307252190Srpaulo#define P2P_SEC_DEVICE_TYPES 5
308252190Srpaulo
309252190Srpaulo	/**
310252190Srpaulo	 * sec_dev_type - Optional secondary device types
311252190Srpaulo	 */
312252190Srpaulo	u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8];
313252190Srpaulo
314252190Srpaulo	/**
315252190Srpaulo	 * num_sec_dev_types - Number of sec_dev_type entries
316252190Srpaulo	 */
317252190Srpaulo	size_t num_sec_dev_types;
318252190Srpaulo
319252190Srpaulo	/**
320252190Srpaulo	 * dev_addr - P2P Device Address
321252190Srpaulo	 */
322252190Srpaulo	u8 dev_addr[ETH_ALEN];
323252190Srpaulo
324252190Srpaulo	/**
325252190Srpaulo	 * dev_name - Device Name
326252190Srpaulo	 */
327252190Srpaulo	char *dev_name;
328252190Srpaulo
329252190Srpaulo	char *manufacturer;
330252190Srpaulo	char *model_name;
331252190Srpaulo	char *model_number;
332252190Srpaulo	char *serial_number;
333252190Srpaulo
334252190Srpaulo	u8 uuid[16];
335252190Srpaulo	u16 config_methods;
336252190Srpaulo
337252190Srpaulo	/**
338252190Srpaulo	 * concurrent_operations - Whether concurrent operations are supported
339252190Srpaulo	 */
340252190Srpaulo	int concurrent_operations;
341252190Srpaulo
342252190Srpaulo	/**
343252190Srpaulo	 * max_peers - Maximum number of discovered peers to remember
344252190Srpaulo	 *
345252190Srpaulo	 * If more peers are discovered, older entries will be removed to make
346252190Srpaulo	 * room for the new ones.
347252190Srpaulo	 */
348252190Srpaulo	size_t max_peers;
349252190Srpaulo
350252190Srpaulo	/**
351252190Srpaulo	 * p2p_intra_bss - Intra BSS communication is supported
352252190Srpaulo	 */
353252190Srpaulo	int p2p_intra_bss;
354252190Srpaulo
355252190Srpaulo	/**
356252190Srpaulo	 * ssid_postfix - Postfix data to add to the SSID
357252190Srpaulo	 *
358252190Srpaulo	 * This data will be added to the end of the SSID after the
359252190Srpaulo	 * DIRECT-<random two octets> prefix.
360252190Srpaulo	 */
361252190Srpaulo	u8 ssid_postfix[32 - 9];
362252190Srpaulo
363252190Srpaulo	/**
364252190Srpaulo	 * ssid_postfix_len - Length of the ssid_postfix data
365252190Srpaulo	 */
366252190Srpaulo	size_t ssid_postfix_len;
367252190Srpaulo
368252190Srpaulo	/**
369252190Srpaulo	 * max_listen - Maximum listen duration in ms
370252190Srpaulo	 */
371252190Srpaulo	unsigned int max_listen;
372252190Srpaulo
373252190Srpaulo	/**
374252190Srpaulo	 * msg_ctx - Context to use with wpa_msg() calls
375252190Srpaulo	 */
376252190Srpaulo	void *msg_ctx;
377252190Srpaulo
378252190Srpaulo	/**
379252190Srpaulo	 * cb_ctx - Context to use with callback functions
380252190Srpaulo	 */
381252190Srpaulo	void *cb_ctx;
382252190Srpaulo
383252190Srpaulo
384252190Srpaulo	/* Callbacks to request lower layer driver operations */
385252190Srpaulo
386252190Srpaulo	/**
387252190Srpaulo	 * p2p_scan - Request a P2P scan/search
388252190Srpaulo	 * @ctx: Callback context from cb_ctx
389252190Srpaulo	 * @type: Scan type
390252190Srpaulo	 * @freq: Specific frequency (MHz) to scan or 0 for no restriction
391252190Srpaulo	 * @num_req_dev_types: Number of requested device types
392252190Srpaulo	 * @req_dev_types: Array containing requested device types
393252190Srpaulo	 * @dev_id: Device ID to search for or %NULL to find all devices
394252190Srpaulo	 * @pw_id: Device Password ID
395252190Srpaulo	 * Returns: 0 on success, -1 on failure
396252190Srpaulo	 *
397252190Srpaulo	 * This callback function is used to request a P2P scan or search
398252190Srpaulo	 * operation to be completed. Type type argument specifies which type
399252190Srpaulo	 * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the
400252190Srpaulo	 * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL
401252190Srpaulo	 * indicates that all channels are to be scanned.
402252190Srpaulo	 * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels
403252190Srpaulo	 * plus one extra channel specified by freq.
404252190Srpaulo	 *
405252190Srpaulo	 * The full scan is used for the initial scan to find group owners from
406252190Srpaulo	 * all. The other types are used during search phase scan of the social
407252190Srpaulo	 * channels (with potential variation if the Listen channel of the
408252190Srpaulo	 * target peer is known or if other channels are scanned in steps).
409252190Srpaulo	 *
410252190Srpaulo	 * The scan results are returned after this call by calling
411252190Srpaulo	 * p2p_scan_res_handler() for each scan result that has a P2P IE and
412252190Srpaulo	 * then calling p2p_scan_res_handled() to indicate that all scan
413252190Srpaulo	 * results have been indicated.
414252190Srpaulo	 */
415252190Srpaulo	int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq,
416252190Srpaulo			unsigned int num_req_dev_types,
417252190Srpaulo			const u8 *req_dev_types, const u8 *dev_id, u16 pw_id);
418252190Srpaulo
419252190Srpaulo	/**
420252190Srpaulo	 * send_probe_resp - Transmit a Probe Response frame
421252190Srpaulo	 * @ctx: Callback context from cb_ctx
422252190Srpaulo	 * @buf: Probe Response frame (including the header and body)
423252190Srpaulo	 * Returns: 0 on success, -1 on failure
424252190Srpaulo	 *
425252190Srpaulo	 * This function is used to reply to Probe Request frames that were
426252190Srpaulo	 * indicated with a call to p2p_probe_req_rx(). The response is to be
427252190Srpaulo	 * sent on the same channel or to be dropped if the driver is not
428252190Srpaulo	 * anymore listening to Probe Request frames.
429252190Srpaulo	 *
430252190Srpaulo	 * Alternatively, the responsibility for building the Probe Response
431252190Srpaulo	 * frames in Listen state may be in another system component in which
432252190Srpaulo	 * case this function need to be implemented (i.e., the function
433252190Srpaulo	 * pointer can be %NULL). The WPS and P2P IEs to be added for Probe
434252190Srpaulo	 * Response frames in such a case are available from the
435252190Srpaulo	 * start_listen() callback. It should be noted that the received Probe
436252190Srpaulo	 * Request frames must be indicated by calling p2p_probe_req_rx() even
437252190Srpaulo	 * if this send_probe_resp() is not used.
438252190Srpaulo	 */
439252190Srpaulo	int (*send_probe_resp)(void *ctx, const struct wpabuf *buf);
440252190Srpaulo
441252190Srpaulo	/**
442252190Srpaulo	 * send_action - Transmit an Action frame
443252190Srpaulo	 * @ctx: Callback context from cb_ctx
444252190Srpaulo	 * @freq: Frequency in MHz for the channel on which to transmit
445252190Srpaulo	 * @dst: Destination MAC address (Address 1)
446252190Srpaulo	 * @src: Source MAC address (Address 2)
447252190Srpaulo	 * @bssid: BSSID (Address 3)
448252190Srpaulo	 * @buf: Frame body (starting from Category field)
449252190Srpaulo	 * @len: Length of buf in octets
450252190Srpaulo	 * @wait_time: How many msec to wait for a response frame
451252190Srpaulo	 * Returns: 0 on success, -1 on failure
452252190Srpaulo	 *
453252190Srpaulo	 * The Action frame may not be transmitted immediately and the status
454252190Srpaulo	 * of the transmission must be reported by calling
455252190Srpaulo	 * p2p_send_action_cb() once the frame has either been transmitted or
456252190Srpaulo	 * it has been dropped due to excessive retries or other failure to
457252190Srpaulo	 * transmit.
458252190Srpaulo	 */
459252190Srpaulo	int (*send_action)(void *ctx, unsigned int freq, const u8 *dst,
460252190Srpaulo			   const u8 *src, const u8 *bssid, const u8 *buf,
461252190Srpaulo			   size_t len, unsigned int wait_time);
462252190Srpaulo
463252190Srpaulo	/**
464252190Srpaulo	 * send_action_done - Notify that Action frame sequence was completed
465252190Srpaulo	 * @ctx: Callback context from cb_ctx
466252190Srpaulo	 *
467252190Srpaulo	 * This function is called when the Action frame sequence that was
468252190Srpaulo	 * started with send_action() has been completed, i.e., when there is
469252190Srpaulo	 * no need to wait for a response from the destination peer anymore.
470252190Srpaulo	 */
471252190Srpaulo	void (*send_action_done)(void *ctx);
472252190Srpaulo
473252190Srpaulo	/**
474252190Srpaulo	 * start_listen - Start Listen state
475252190Srpaulo	 * @ctx: Callback context from cb_ctx
476252190Srpaulo	 * @freq: Frequency of the listen channel in MHz
477252190Srpaulo	 * @duration: Duration for the Listen state in milliseconds
478252190Srpaulo	 * @probe_resp_ie: IE(s) to be added to Probe Response frames
479252190Srpaulo	 * Returns: 0 on success, -1 on failure
480252190Srpaulo	 *
481252190Srpaulo	 * This Listen state may not start immediately since the driver may
482252190Srpaulo	 * have other pending operations to complete first. Once the Listen
483252190Srpaulo	 * state has started, p2p_listen_cb() must be called to notify the P2P
484252190Srpaulo	 * module. Once the Listen state is stopped, p2p_listen_end() must be
485252190Srpaulo	 * called to notify the P2P module that the driver is not in the Listen
486252190Srpaulo	 * state anymore.
487252190Srpaulo	 *
488252190Srpaulo	 * If the send_probe_resp() is not used for generating the response,
489252190Srpaulo	 * the IEs from probe_resp_ie need to be added to the end of the Probe
490252190Srpaulo	 * Response frame body. If send_probe_resp() is used, the probe_resp_ie
491252190Srpaulo	 * information can be ignored.
492252190Srpaulo	 */
493252190Srpaulo	int (*start_listen)(void *ctx, unsigned int freq,
494252190Srpaulo			    unsigned int duration,
495252190Srpaulo			    const struct wpabuf *probe_resp_ie);
496252190Srpaulo	/**
497252190Srpaulo	 * stop_listen - Stop Listen state
498252190Srpaulo	 * @ctx: Callback context from cb_ctx
499252190Srpaulo	 *
500252190Srpaulo	 * This callback can be used to stop a Listen state operation that was
501252190Srpaulo	 * previously requested with start_listen().
502252190Srpaulo	 */
503252190Srpaulo	void (*stop_listen)(void *ctx);
504252190Srpaulo
505252190Srpaulo	/**
506252190Srpaulo	 * get_noa - Get current Notice of Absence attribute payload
507252190Srpaulo	 * @ctx: Callback context from cb_ctx
508252190Srpaulo	 * @interface_addr: P2P Interface Address of the GO
509252190Srpaulo	 * @buf: Buffer for returning NoA
510252190Srpaulo	 * @buf_len: Buffer length in octets
511252190Srpaulo	 * Returns: Number of octets used in buf, 0 to indicate no NoA is being
512252190Srpaulo	 * advertized, or -1 on failure
513252190Srpaulo	 *
514252190Srpaulo	 * This function is used to fetch the current Notice of Absence
515252190Srpaulo	 * attribute value from GO.
516252190Srpaulo	 */
517252190Srpaulo	int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf,
518252190Srpaulo		       size_t buf_len);
519252190Srpaulo
520252190Srpaulo	/* Callbacks to notify events to upper layer management entity */
521252190Srpaulo
522252190Srpaulo	/**
523252190Srpaulo	 * dev_found - Notification of a found P2P Device
524252190Srpaulo	 * @ctx: Callback context from cb_ctx
525252190Srpaulo	 * @addr: Source address of the message triggering this notification
526252190Srpaulo	 * @info: P2P peer information
527252190Srpaulo	 * @new_device: Inform if the peer is newly found
528252190Srpaulo	 *
529252190Srpaulo	 * This callback is used to notify that a new P2P Device has been
530252190Srpaulo	 * found. This may happen, e.g., during Search state based on scan
531252190Srpaulo	 * results or during Listen state based on receive Probe Request and
532252190Srpaulo	 * Group Owner Negotiation Request.
533252190Srpaulo	 */
534252190Srpaulo	void (*dev_found)(void *ctx, const u8 *addr,
535252190Srpaulo			  const struct p2p_peer_info *info,
536252190Srpaulo			  int new_device);
537252190Srpaulo
538252190Srpaulo	/**
539252190Srpaulo	 * dev_lost - Notification of a lost P2P Device
540252190Srpaulo	 * @ctx: Callback context from cb_ctx
541252190Srpaulo	 * @dev_addr: P2P Device Address of the lost P2P Device
542252190Srpaulo	 *
543252190Srpaulo	 * This callback is used to notify that a P2P Device has been deleted.
544252190Srpaulo	 */
545252190Srpaulo	void (*dev_lost)(void *ctx, const u8 *dev_addr);
546252190Srpaulo
547252190Srpaulo	/**
548252190Srpaulo	 * go_neg_req_rx - Notification of a receive GO Negotiation Request
549252190Srpaulo	 * @ctx: Callback context from cb_ctx
550252190Srpaulo	 * @src: Source address of the message triggering this notification
551252190Srpaulo	 * @dev_passwd_id: WPS Device Password ID
552252190Srpaulo	 *
553252190Srpaulo	 * This callback is used to notify that a P2P Device is requesting
554252190Srpaulo	 * group owner negotiation with us, but we do not have all the
555252190Srpaulo	 * necessary information to start GO Negotiation. This indicates that
556252190Srpaulo	 * the local user has not authorized the connection yet by providing a
557252190Srpaulo	 * PIN or PBC button press. This information can be provided with a
558252190Srpaulo	 * call to p2p_connect().
559252190Srpaulo	 */
560252190Srpaulo	void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id);
561252190Srpaulo
562252190Srpaulo	/**
563252190Srpaulo	 * go_neg_completed - Notification of GO Negotiation results
564252190Srpaulo	 * @ctx: Callback context from cb_ctx
565252190Srpaulo	 * @res: GO Negotiation results
566252190Srpaulo	 *
567252190Srpaulo	 * This callback is used to notify that Group Owner Negotiation has
568252190Srpaulo	 * been completed. Non-zero struct p2p_go_neg_results::status indicates
569252190Srpaulo	 * failed negotiation. In case of success, this function is responsible
570252190Srpaulo	 * for creating a new group interface (or using the existing interface
571252190Srpaulo	 * depending on driver features), setting up the group interface in
572252190Srpaulo	 * proper mode based on struct p2p_go_neg_results::role_go and
573252190Srpaulo	 * initializing WPS provisioning either as a Registrar (if GO) or as an
574252190Srpaulo	 * Enrollee. Successful WPS provisioning must be indicated by calling
575252190Srpaulo	 * p2p_wps_success_cb(). The callee is responsible for timing out group
576252190Srpaulo	 * formation if WPS provisioning cannot be completed successfully
577252190Srpaulo	 * within 15 seconds.
578252190Srpaulo	 */
579252190Srpaulo	void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res);
580252190Srpaulo
581252190Srpaulo	/**
582252190Srpaulo	 * sd_request - Callback on Service Discovery Request
583252190Srpaulo	 * @ctx: Callback context from cb_ctx
584252190Srpaulo	 * @freq: Frequency (in MHz) of the channel
585252190Srpaulo	 * @sa: Source address of the request
586252190Srpaulo	 * @dialog_token: Dialog token
587252190Srpaulo	 * @update_indic: Service Update Indicator from the source of request
588252190Srpaulo	 * @tlvs: P2P Service Request TLV(s)
589252190Srpaulo	 * @tlvs_len: Length of tlvs buffer in octets
590252190Srpaulo	 *
591252190Srpaulo	 * This callback is used to indicate reception of a service discovery
592252190Srpaulo	 * request. Response to the query must be indicated by calling
593252190Srpaulo	 * p2p_sd_response() with the context information from the arguments to
594252190Srpaulo	 * this callback function.
595252190Srpaulo	 *
596252190Srpaulo	 * This callback handler can be set to %NULL to indicate that service
597252190Srpaulo	 * discovery is not supported.
598252190Srpaulo	 */
599252190Srpaulo	void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token,
600252190Srpaulo			   u16 update_indic, const u8 *tlvs, size_t tlvs_len);
601252190Srpaulo
602252190Srpaulo	/**
603252190Srpaulo	 * sd_response - Callback on Service Discovery Response
604252190Srpaulo	 * @ctx: Callback context from cb_ctx
605252190Srpaulo	 * @sa: Source address of the request
606252190Srpaulo	 * @update_indic: Service Update Indicator from the source of response
607252190Srpaulo	 * @tlvs: P2P Service Response TLV(s)
608252190Srpaulo	 * @tlvs_len: Length of tlvs buffer in octets
609252190Srpaulo	 *
610252190Srpaulo	 * This callback is used to indicate reception of a service discovery
611252190Srpaulo	 * response. This callback handler can be set to %NULL if no service
612252190Srpaulo	 * discovery requests are used. The information provided with this call
613252190Srpaulo	 * is replies to the queries scheduled with p2p_sd_request().
614252190Srpaulo	 */
615252190Srpaulo	void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic,
616252190Srpaulo			    const u8 *tlvs, size_t tlvs_len);
617252190Srpaulo
618252190Srpaulo	/**
619252190Srpaulo	 * prov_disc_req - Callback on Provisiong Discovery Request
620252190Srpaulo	 * @ctx: Callback context from cb_ctx
621252190Srpaulo	 * @peer: Source address of the request
622252190Srpaulo	 * @config_methods: Requested WPS Config Method
623252190Srpaulo	 * @dev_addr: P2P Device Address of the found P2P Device
624252190Srpaulo	 * @pri_dev_type: Primary Device Type
625252190Srpaulo	 * @dev_name: Device Name
626252190Srpaulo	 * @supp_config_methods: Supported configuration Methods
627252190Srpaulo	 * @dev_capab: Device Capabilities
628252190Srpaulo	 * @group_capab: Group Capabilities
629252190Srpaulo	 * @group_id: P2P Group ID (or %NULL if not included)
630252190Srpaulo	 * @group_id_len: Length of P2P Group ID
631252190Srpaulo	 *
632252190Srpaulo	 * This callback is used to indicate reception of a Provision Discovery
633252190Srpaulo	 * Request frame that the P2P module accepted.
634252190Srpaulo	 */
635252190Srpaulo	void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods,
636252190Srpaulo			      const u8 *dev_addr, const u8 *pri_dev_type,
637252190Srpaulo			      const char *dev_name, u16 supp_config_methods,
638252190Srpaulo			      u8 dev_capab, u8 group_capab,
639252190Srpaulo			      const u8 *group_id, size_t group_id_len);
640252190Srpaulo
641252190Srpaulo	/**
642252190Srpaulo	 * prov_disc_resp - Callback on Provisiong Discovery Response
643252190Srpaulo	 * @ctx: Callback context from cb_ctx
644252190Srpaulo	 * @peer: Source address of the response
645252190Srpaulo	 * @config_methods: Value from p2p_prov_disc_req() or 0 on failure
646252190Srpaulo	 *
647252190Srpaulo	 * This callback is used to indicate reception of a Provision Discovery
648252190Srpaulo	 * Response frame for a pending request scheduled with
649252190Srpaulo	 * p2p_prov_disc_req(). This callback handler can be set to %NULL if
650252190Srpaulo	 * provision discovery is not used.
651252190Srpaulo	 */
652252190Srpaulo	void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods);
653252190Srpaulo
654252190Srpaulo	/**
655252190Srpaulo	 * prov_disc_fail - Callback on Provision Discovery failure
656252190Srpaulo	 * @ctx: Callback context from cb_ctx
657252190Srpaulo	 * @peer: Source address of the response
658252190Srpaulo	 * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS
659252190Srpaulo	 *
660252190Srpaulo	 * This callback is used to indicate either a failure or no response
661252190Srpaulo	 * to an earlier provision discovery request.
662252190Srpaulo	 *
663252190Srpaulo	 * This callback handler can be set to %NULL if provision discovery
664252190Srpaulo	 * is not used or failures do not need to be indicated.
665252190Srpaulo	 */
666252190Srpaulo	void (*prov_disc_fail)(void *ctx, const u8 *peer,
667252190Srpaulo			       enum p2p_prov_disc_status status);
668252190Srpaulo
669252190Srpaulo	/**
670252190Srpaulo	 * invitation_process - Optional callback for processing Invitations
671252190Srpaulo	 * @ctx: Callback context from cb_ctx
672252190Srpaulo	 * @sa: Source address of the Invitation Request
673252190Srpaulo	 * @bssid: P2P Group BSSID from the request or %NULL if not included
674252190Srpaulo	 * @go_dev_addr: GO Device Address from P2P Group ID
675252190Srpaulo	 * @ssid: SSID from P2P Group ID
676252190Srpaulo	 * @ssid_len: Length of ssid buffer in octets
677252190Srpaulo	 * @go: Variable for returning whether the local end is GO in the group
678252190Srpaulo	 * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO)
679252190Srpaulo	 * @force_freq: Variable for returning forced frequency for the group
680252190Srpaulo	 * @persistent_group: Whether this is an invitation to reinvoke a
681252190Srpaulo	 *	persistent group (instead of invitation to join an active
682252190Srpaulo	 *	group)
683252190Srpaulo	 * Returns: Status code (P2P_SC_*)
684252190Srpaulo	 *
685252190Srpaulo	 * This optional callback can be used to implement persistent reconnect
686252190Srpaulo	 * by allowing automatic restarting of persistent groups without user
687252190Srpaulo	 * interaction. If this callback is not implemented (i.e., is %NULL),
688252190Srpaulo	 * the received Invitation Request frames are replied with
689252190Srpaulo	 * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the
690252190Srpaulo	 * invitation_result() callback.
691252190Srpaulo	 *
692252190Srpaulo	 * If the requested parameters are acceptable and the group is known,
693252190Srpaulo	 * %P2P_SC_SUCCESS may be returned. If the requested group is unknown,
694252190Srpaulo	 * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED
695252190Srpaulo	 * can be returned if there is not enough data to provide immediate
696252190Srpaulo	 * response, i.e., if some sort of user interaction is needed. The
697252190Srpaulo	 * invitation_received() callback will be called in that case
698252190Srpaulo	 * immediately after this call.
699252190Srpaulo	 */
700252190Srpaulo	u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid,
701252190Srpaulo				 const u8 *go_dev_addr, const u8 *ssid,
702252190Srpaulo				 size_t ssid_len, int *go, u8 *group_bssid,
703252190Srpaulo				 int *force_freq, int persistent_group);
704252190Srpaulo
705252190Srpaulo	/**
706252190Srpaulo	 * invitation_received - Callback on Invitation Request RX
707252190Srpaulo	 * @ctx: Callback context from cb_ctx
708252190Srpaulo	 * @sa: Source address of the Invitation Request
709252190Srpaulo	 * @bssid: P2P Group BSSID or %NULL if not received
710252190Srpaulo	 * @ssid: SSID of the group
711252190Srpaulo	 * @ssid_len: Length of ssid in octets
712252190Srpaulo	 * @go_dev_addr: GO Device Address
713252190Srpaulo	 * @status: Response Status
714252190Srpaulo	 * @op_freq: Operational frequency for the group
715252190Srpaulo	 *
716252190Srpaulo	 * This callback is used to indicate sending of an Invitation Response
717252190Srpaulo	 * for a received Invitation Request. If status == 0 (success), the
718252190Srpaulo	 * upper layer code is responsible for starting the group. status == 1
719252190Srpaulo	 * indicates need to get user authorization for the group. Other status
720252190Srpaulo	 * values indicate that the invitation request was rejected.
721252190Srpaulo	 */
722252190Srpaulo	void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid,
723252190Srpaulo				    const u8 *ssid, size_t ssid_len,
724252190Srpaulo				    const u8 *go_dev_addr, u8 status,
725252190Srpaulo				    int op_freq);
726252190Srpaulo
727252190Srpaulo	/**
728252190Srpaulo	 * invitation_result - Callback on Invitation result
729252190Srpaulo	 * @ctx: Callback context from cb_ctx
730252190Srpaulo	 * @status: Negotiation result (Status Code)
731252190Srpaulo	 * @bssid: P2P Group BSSID or %NULL if not received
732252190Srpaulo	 *
733252190Srpaulo	 * This callback is used to indicate result of an Invitation procedure
734252190Srpaulo	 * started with a call to p2p_invite(). The indicated status code is
735252190Srpaulo	 * the value received from the peer in Invitation Response with 0
736252190Srpaulo	 * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a
737252190Srpaulo	 * local failure in transmitting the Invitation Request.
738252190Srpaulo	 */
739252190Srpaulo	void (*invitation_result)(void *ctx, int status, const u8 *bssid);
740252190Srpaulo
741252190Srpaulo	/**
742252190Srpaulo	 * go_connected - Check whether we are connected to a GO
743252190Srpaulo	 * @ctx: Callback context from cb_ctx
744252190Srpaulo	 * @dev_addr: P2P Device Address of a GO
745252190Srpaulo	 * Returns: 1 if we are connected as a P2P client to the specified GO
746252190Srpaulo	 * or 0 if not.
747252190Srpaulo	 */
748252190Srpaulo	int (*go_connected)(void *ctx, const u8 *dev_addr);
749252190Srpaulo};
750252190Srpaulo
751252190Srpaulo
752252190Srpaulo/* P2P module initialization/deinitialization */
753252190Srpaulo
754252190Srpaulo/**
755252190Srpaulo * p2p_init - Initialize P2P module
756252190Srpaulo * @cfg: P2P module configuration
757252190Srpaulo * Returns: Pointer to private data or %NULL on failure
758252190Srpaulo *
759252190Srpaulo * This function is used to initialize global P2P module context (one per
760252190Srpaulo * device). The P2P module will keep a copy of the configuration data, so the
761252190Srpaulo * caller does not need to maintain this structure. However, the callback
762252190Srpaulo * functions and the context parameters to them must be kept available until
763252190Srpaulo * the P2P module is deinitialized with p2p_deinit().
764252190Srpaulo */
765252190Srpaulostruct p2p_data * p2p_init(const struct p2p_config *cfg);
766252190Srpaulo
767252190Srpaulo/**
768252190Srpaulo * p2p_deinit - Deinitialize P2P module
769252190Srpaulo * @p2p: P2P module context from p2p_init()
770252190Srpaulo */
771252190Srpaulovoid p2p_deinit(struct p2p_data *p2p);
772252190Srpaulo
773252190Srpaulo/**
774252190Srpaulo * p2p_flush - Flush P2P module state
775252190Srpaulo * @p2p: P2P module context from p2p_init()
776252190Srpaulo *
777252190Srpaulo * This command removes the P2P module state like peer device entries.
778252190Srpaulo */
779252190Srpaulovoid p2p_flush(struct p2p_data *p2p);
780252190Srpaulo
781252190Srpaulo/**
782252190Srpaulo * p2p_unauthorize - Unauthorize the specified peer device
783252190Srpaulo * @p2p: P2P module context from p2p_init()
784252190Srpaulo * @addr: P2P peer entry to be unauthorized
785252190Srpaulo * Returns: 0 on success, -1 on failure
786252190Srpaulo *
787252190Srpaulo * This command removes any connection authorization from the specified P2P
788252190Srpaulo * peer device address. This can be used, e.g., to cancel effect of a previous
789252190Srpaulo * p2p_authorize() or p2p_connect() call that has not yet resulted in completed
790252190Srpaulo * GO Negotiation.
791252190Srpaulo */
792252190Srpauloint p2p_unauthorize(struct p2p_data *p2p, const u8 *addr);
793252190Srpaulo
794252190Srpaulo/**
795252190Srpaulo * p2p_set_dev_name - Set device name
796252190Srpaulo * @p2p: P2P module context from p2p_init()
797252190Srpaulo * Returns: 0 on success, -1 on failure
798252190Srpaulo *
799252190Srpaulo * This function can be used to update the P2P module configuration with
800252190Srpaulo * information that was not available at the time of the p2p_init() call.
801252190Srpaulo */
802252190Srpauloint p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name);
803252190Srpaulo
804252190Srpauloint p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer);
805252190Srpauloint p2p_set_model_name(struct p2p_data *p2p, const char *model_name);
806252190Srpauloint p2p_set_model_number(struct p2p_data *p2p, const char *model_number);
807252190Srpauloint p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number);
808252190Srpaulo
809252190Srpaulovoid p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods);
810252190Srpaulovoid p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid);
811252190Srpaulo
812252190Srpaulo/**
813252190Srpaulo * p2p_set_pri_dev_type - Set primary device type
814252190Srpaulo * @p2p: P2P module context from p2p_init()
815252190Srpaulo * Returns: 0 on success, -1 on failure
816252190Srpaulo *
817252190Srpaulo * This function can be used to update the P2P module configuration with
818252190Srpaulo * information that was not available at the time of the p2p_init() call.
819252190Srpaulo */
820252190Srpauloint p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type);
821252190Srpaulo
822252190Srpaulo/**
823252190Srpaulo * p2p_set_sec_dev_types - Set secondary device types
824252190Srpaulo * @p2p: P2P module context from p2p_init()
825252190Srpaulo * Returns: 0 on success, -1 on failure
826252190Srpaulo *
827252190Srpaulo * This function can be used to update the P2P module configuration with
828252190Srpaulo * information that was not available at the time of the p2p_init() call.
829252190Srpaulo */
830252190Srpauloint p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8],
831252190Srpaulo			  size_t num_dev_types);
832252190Srpaulo
833252190Srpauloint p2p_set_country(struct p2p_data *p2p, const char *country);
834252190Srpaulo
835252190Srpaulo
836252190Srpaulo/* Commands from upper layer management entity */
837252190Srpaulo
838252190Srpauloenum p2p_discovery_type {
839252190Srpaulo	P2P_FIND_START_WITH_FULL,
840252190Srpaulo	P2P_FIND_ONLY_SOCIAL,
841252190Srpaulo	P2P_FIND_PROGRESSIVE
842252190Srpaulo};
843252190Srpaulo
844252190Srpaulo/**
845252190Srpaulo * p2p_find - Start P2P Find (Device Discovery)
846252190Srpaulo * @p2p: P2P module context from p2p_init()
847252190Srpaulo * @timeout: Timeout for find operation in seconds or 0 for no timeout
848252190Srpaulo * @type: Device Discovery type
849252190Srpaulo * @num_req_dev_types: Number of requested device types
850252190Srpaulo * @req_dev_types: Requested device types array, must be an array
851252190Srpaulo *	containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no
852252190Srpaulo *	requested device types.
853252190Srpaulo * @dev_id: Device ID to search for or %NULL to find all devices
854252190Srpaulo * @search_delay: Extra delay in milliseconds between search iterations
855252190Srpaulo * Returns: 0 on success, -1 on failure
856252190Srpaulo */
857252190Srpauloint p2p_find(struct p2p_data *p2p, unsigned int timeout,
858252190Srpaulo	     enum p2p_discovery_type type,
859252190Srpaulo	     unsigned int num_req_dev_types, const u8 *req_dev_types,
860252190Srpaulo	     const u8 *dev_id, unsigned int search_delay);
861252190Srpaulo
862252190Srpaulo/**
863252190Srpaulo * p2p_stop_find - Stop P2P Find (Device Discovery)
864252190Srpaulo * @p2p: P2P module context from p2p_init()
865252190Srpaulo */
866252190Srpaulovoid p2p_stop_find(struct p2p_data *p2p);
867252190Srpaulo
868252190Srpaulo/**
869252190Srpaulo * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq
870252190Srpaulo * @p2p: P2P module context from p2p_init()
871252190Srpaulo * @freq: Frequency in MHz for next operation
872252190Srpaulo *
873252190Srpaulo * This is like p2p_stop_find(), but Listen state is not stopped if we are
874252190Srpaulo * already on the same frequency.
875252190Srpaulo */
876252190Srpaulovoid p2p_stop_find_for_freq(struct p2p_data *p2p, int freq);
877252190Srpaulo
878252190Srpaulo/**
879252190Srpaulo * p2p_listen - Start P2P Listen state for specified duration
880252190Srpaulo * @p2p: P2P module context from p2p_init()
881252190Srpaulo * @timeout: Listen state duration in milliseconds
882252190Srpaulo * Returns: 0 on success, -1 on failure
883252190Srpaulo *
884252190Srpaulo * This function can be used to request the P2P module to keep the device
885252190Srpaulo * discoverable on the listen channel for an extended set of time. At least in
886252190Srpaulo * its current form, this is mainly used for testing purposes and may not be of
887252190Srpaulo * much use for normal P2P operations.
888252190Srpaulo */
889252190Srpauloint p2p_listen(struct p2p_data *p2p, unsigned int timeout);
890252190Srpaulo
891252190Srpaulo/**
892252190Srpaulo * p2p_connect - Start P2P group formation (GO negotiation)
893252190Srpaulo * @p2p: P2P module context from p2p_init()
894252190Srpaulo * @peer_addr: MAC address of the peer P2P client
895252190Srpaulo * @wps_method: WPS method to be used in provisioning
896252190Srpaulo * @go_intent: Local GO intent value (1..15)
897252190Srpaulo * @own_interface_addr: Intended interface address to use with the group
898252190Srpaulo * @force_freq: The only allowed channel frequency in MHz or 0
899252190Srpaulo * @persistent_group: Whether to create a persistent group (0 = no, 1 =
900252190Srpaulo * persistent group without persistent reconnect, 2 = persistent group with
901252190Srpaulo * persistent reconnect)
902252190Srpaulo * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
903252190Srpaulo *	a new SSID
904252190Srpaulo * @force_ssid_len: Length of $force_ssid buffer
905252190Srpaulo * @pd_before_go_neg: Whether to send Provision Discovery prior to GO
906252190Srpaulo *	Negotiation as an interoperability workaround when initiating group
907252190Srpaulo *	formation
908252190Srpaulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
909252190Srpaulo *	force_freq == 0)
910252190Srpaulo * Returns: 0 on success, -1 on failure
911252190Srpaulo */
912252190Srpauloint p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
913252190Srpaulo		enum p2p_wps_method wps_method,
914252190Srpaulo		int go_intent, const u8 *own_interface_addr,
915252190Srpaulo		unsigned int force_freq, int persistent_group,
916252190Srpaulo		const u8 *force_ssid, size_t force_ssid_len,
917252190Srpaulo		int pd_before_go_neg, unsigned int pref_freq);
918252190Srpaulo
919252190Srpaulo/**
920252190Srpaulo * p2p_authorize - Authorize P2P group formation (GO negotiation)
921252190Srpaulo * @p2p: P2P module context from p2p_init()
922252190Srpaulo * @peer_addr: MAC address of the peer P2P client
923252190Srpaulo * @wps_method: WPS method to be used in provisioning
924252190Srpaulo * @go_intent: Local GO intent value (1..15)
925252190Srpaulo * @own_interface_addr: Intended interface address to use with the group
926252190Srpaulo * @force_freq: The only allowed channel frequency in MHz or 0
927252190Srpaulo * @persistent_group: Whether to create a persistent group (0 = no, 1 =
928252190Srpaulo * persistent group without persistent reconnect, 2 = persistent group with
929252190Srpaulo * persistent reconnect)
930252190Srpaulo * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
931252190Srpaulo *	a new SSID
932252190Srpaulo * @force_ssid_len: Length of $force_ssid buffer
933252190Srpaulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
934252190Srpaulo *	force_freq == 0)
935252190Srpaulo * Returns: 0 on success, -1 on failure
936252190Srpaulo *
937252190Srpaulo * This is like p2p_connect(), but the actual group negotiation is not
938252190Srpaulo * initiated automatically, i.e., the other end is expected to do that.
939252190Srpaulo */
940252190Srpauloint p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
941252190Srpaulo		  enum p2p_wps_method wps_method,
942252190Srpaulo		  int go_intent, const u8 *own_interface_addr,
943252190Srpaulo		  unsigned int force_freq, int persistent_group,
944252190Srpaulo		  const u8 *force_ssid, size_t force_ssid_len,
945252190Srpaulo		  unsigned int pref_freq);
946252190Srpaulo
947252190Srpaulo/**
948252190Srpaulo * p2p_reject - Reject peer device (explicitly block connection attempts)
949252190Srpaulo * @p2p: P2P module context from p2p_init()
950252190Srpaulo * @peer_addr: MAC address of the peer P2P client
951252190Srpaulo * Returns: 0 on success, -1 on failure
952252190Srpaulo */
953252190Srpauloint p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
954252190Srpaulo
955252190Srpaulo/**
956252190Srpaulo * p2p_prov_disc_req - Send Provision Discovery Request
957252190Srpaulo * @p2p: P2P module context from p2p_init()
958252190Srpaulo * @peer_addr: MAC address of the peer P2P client
959252190Srpaulo * @config_methods: WPS Config Methods value (only one bit set)
960252190Srpaulo * @join: Whether this is used by a client joining an active group
961252190Srpaulo * @force_freq: Forced TX frequency for the frame (mainly for the join case)
962252190Srpaulo * @user_initiated_pd: Flag to indicate if initiated by user or not
963252190Srpaulo * Returns: 0 on success, -1 on failure
964252190Srpaulo *
965252190Srpaulo * This function can be used to request a discovered P2P peer to display a PIN
966252190Srpaulo * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us
967252190Srpaulo * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame
968252190Srpaulo * is transmitted once immediately and if no response is received, the frame
969252190Srpaulo * will be sent again whenever the target device is discovered during device
970252190Srpaulo * dsicovery (start with a p2p_find() call). Response from the peer is
971252190Srpaulo * indicated with the p2p_config::prov_disc_resp() callback.
972252190Srpaulo */
973252190Srpauloint p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
974252190Srpaulo		      u16 config_methods, int join, int force_freq,
975252190Srpaulo		      int user_initiated_pd);
976252190Srpaulo
977252190Srpaulo/**
978252190Srpaulo * p2p_sd_request - Schedule a service discovery query
979252190Srpaulo * @p2p: P2P module context from p2p_init()
980252190Srpaulo * @dst: Destination peer or %NULL to apply for all peers
981252190Srpaulo * @tlvs: P2P Service Query TLV(s)
982252190Srpaulo * Returns: Reference to the query or %NULL on failure
983252190Srpaulo *
984252190Srpaulo * Response to the query is indicated with the p2p_config::sd_response()
985252190Srpaulo * callback.
986252190Srpaulo */
987252190Srpaulovoid * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
988252190Srpaulo		      const struct wpabuf *tlvs);
989252190Srpaulo
990252190Srpaulo#ifdef CONFIG_WIFI_DISPLAY
991252190Srpaulovoid * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
992252190Srpaulo			  const struct wpabuf *tlvs);
993252190Srpaulo#endif /* CONFIG_WIFI_DISPLAY */
994252190Srpaulo
995252190Srpaulo/**
996252190Srpaulo * p2p_sd_cancel_request - Cancel a pending service discovery query
997252190Srpaulo * @p2p: P2P module context from p2p_init()
998252190Srpaulo * @req: Query reference from p2p_sd_request()
999252190Srpaulo * Returns: 0 if request for cancelled; -1 if not found
1000252190Srpaulo */
1001252190Srpauloint p2p_sd_cancel_request(struct p2p_data *p2p, void *req);
1002252190Srpaulo
1003252190Srpaulo/**
1004252190Srpaulo * p2p_sd_response - Send response to a service discovery query
1005252190Srpaulo * @p2p: P2P module context from p2p_init()
1006252190Srpaulo * @freq: Frequency from p2p_config::sd_request() callback
1007252190Srpaulo * @dst: Destination address from p2p_config::sd_request() callback
1008252190Srpaulo * @dialog_token: Dialog token from p2p_config::sd_request() callback
1009252190Srpaulo * @resp_tlvs: P2P Service Response TLV(s)
1010252190Srpaulo *
1011252190Srpaulo * This function is called as a response to the request indicated with
1012252190Srpaulo * p2p_config::sd_request() callback.
1013252190Srpaulo */
1014252190Srpaulovoid p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
1015252190Srpaulo		     u8 dialog_token, const struct wpabuf *resp_tlvs);
1016252190Srpaulo
1017252190Srpaulo/**
1018252190Srpaulo * p2p_sd_service_update - Indicate a change in local services
1019252190Srpaulo * @p2p: P2P module context from p2p_init()
1020252190Srpaulo *
1021252190Srpaulo * This function needs to be called whenever there is a change in availability
1022252190Srpaulo * of the local services. This will increment the Service Update Indicator
1023252190Srpaulo * value which will be used in SD Request and Response frames.
1024252190Srpaulo */
1025252190Srpaulovoid p2p_sd_service_update(struct p2p_data *p2p);
1026252190Srpaulo
1027252190Srpaulo
1028252190Srpauloenum p2p_invite_role {
1029252190Srpaulo	P2P_INVITE_ROLE_GO,
1030252190Srpaulo	P2P_INVITE_ROLE_ACTIVE_GO,
1031252190Srpaulo	P2P_INVITE_ROLE_CLIENT
1032252190Srpaulo};
1033252190Srpaulo
1034252190Srpaulo/**
1035252190Srpaulo * p2p_invite - Invite a P2P Device into a group
1036252190Srpaulo * @p2p: P2P module context from p2p_init()
1037252190Srpaulo * @peer: Device Address of the peer P2P Device
1038252190Srpaulo * @role: Local role in the group
1039252190Srpaulo * @bssid: Group BSSID or %NULL if not known
1040252190Srpaulo * @ssid: Group SSID
1041252190Srpaulo * @ssid_len: Length of ssid in octets
1042252190Srpaulo * @force_freq: The only allowed channel frequency in MHz or 0
1043252190Srpaulo * @go_dev_addr: Forced GO Device Address or %NULL if none
1044252190Srpaulo * @persistent_group: Whether this is to reinvoke a persistent group
1045252190Srpaulo * Returns: 0 on success, -1 on failure
1046252190Srpaulo */
1047252190Srpauloint p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
1048252190Srpaulo	       const u8 *bssid, const u8 *ssid, size_t ssid_len,
1049252190Srpaulo	       unsigned int force_freq, const u8 *go_dev_addr,
1050252190Srpaulo	       int persistent_group);
1051252190Srpaulo
1052252190Srpaulo/**
1053252190Srpaulo * p2p_presence_req - Request GO presence
1054252190Srpaulo * @p2p: P2P module context from p2p_init()
1055252190Srpaulo * @go_interface_addr: GO P2P Interface Address
1056252190Srpaulo * @own_interface_addr: Own P2P Interface Address for this group
1057252190Srpaulo * @freq: Group operating frequence (in MHz)
1058252190Srpaulo * @duration1: Preferred presence duration in microseconds
1059252190Srpaulo * @interval1: Preferred presence interval in microseconds
1060252190Srpaulo * @duration2: Acceptable presence duration in microseconds
1061252190Srpaulo * @interval2: Acceptable presence interval in microseconds
1062252190Srpaulo * Returns: 0 on success, -1 on failure
1063252190Srpaulo *
1064252190Srpaulo * If both duration and interval values are zero, the parameter pair is not
1065252190Srpaulo * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0).
1066252190Srpaulo */
1067252190Srpauloint p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr,
1068252190Srpaulo		     const u8 *own_interface_addr, unsigned int freq,
1069252190Srpaulo		     u32 duration1, u32 interval1, u32 duration2,
1070252190Srpaulo		     u32 interval2);
1071252190Srpaulo
1072252190Srpaulo/**
1073252190Srpaulo * p2p_ext_listen - Set Extended Listen Timing
1074252190Srpaulo * @p2p: P2P module context from p2p_init()
1075252190Srpaulo * @freq: Group operating frequence (in MHz)
1076252190Srpaulo * @period: Availability period in milliseconds (1-65535; 0 to disable)
1077252190Srpaulo * @interval: Availability interval in milliseconds (1-65535; 0 to disable)
1078252190Srpaulo * Returns: 0 on success, -1 on failure
1079252190Srpaulo *
1080252190Srpaulo * This function can be used to enable or disable (period = interval = 0)
1081252190Srpaulo * Extended Listen Timing. When enabled, the P2P Device will become
1082252190Srpaulo * discoverable (go into Listen State) every @interval milliseconds for at
1083252190Srpaulo * least @period milliseconds.
1084252190Srpaulo */
1085252190Srpauloint p2p_ext_listen(struct p2p_data *p2p, unsigned int period,
1086252190Srpaulo		   unsigned int interval);
1087252190Srpaulo
1088252190Srpaulo/* Event notifications from upper layer management operations */
1089252190Srpaulo
1090252190Srpaulo/**
1091252190Srpaulo * p2p_wps_success_cb - Report successfully completed WPS provisioning
1092252190Srpaulo * @p2p: P2P module context from p2p_init()
1093252190Srpaulo * @mac_addr: Peer address
1094252190Srpaulo *
1095252190Srpaulo * This function is used to report successfully completed WPS provisioning
1096252190Srpaulo * during group formation in both GO/Registrar and client/Enrollee roles.
1097252190Srpaulo */
1098252190Srpaulovoid p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr);
1099252190Srpaulo
1100252190Srpaulo/**
1101252190Srpaulo * p2p_group_formation_failed - Report failed WPS provisioning
1102252190Srpaulo * @p2p: P2P module context from p2p_init()
1103252190Srpaulo *
1104252190Srpaulo * This function is used to report failed group formation. This can happen
1105252190Srpaulo * either due to failed WPS provisioning or due to 15 second timeout during
1106252190Srpaulo * the provisioning phase.
1107252190Srpaulo */
1108252190Srpaulovoid p2p_group_formation_failed(struct p2p_data *p2p);
1109252190Srpaulo
1110252190Srpaulo/**
1111252190Srpaulo * p2p_get_provisioning_info - Get any stored provisioning info
1112252190Srpaulo * @p2p: P2P module context from p2p_init()
1113252190Srpaulo * @addr: Peer P2P Device Address
1114252190Srpaulo * Returns: WPS provisioning information (WPS config method) or 0 if no
1115252190Srpaulo * information is available
1116252190Srpaulo *
1117252190Srpaulo * This function is used to retrieve stored WPS provisioning info for the given
1118252190Srpaulo * peer.
1119252190Srpaulo */
1120252190Srpaulou16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1121252190Srpaulo
1122252190Srpaulo/**
1123252190Srpaulo * p2p_clear_provisioning_info - Clear any stored provisioning info
1124252190Srpaulo * @p2p: P2P module context from p2p_init()
1125252190Srpaulo * @iface_addr: Peer P2P Device Address
1126252190Srpaulo *
1127252190Srpaulo * This function is used to clear stored WPS provisioning info for the given
1128252190Srpaulo * peer.
1129252190Srpaulo */
1130252190Srpaulovoid p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1131252190Srpaulo
1132252190Srpaulo
1133252190Srpaulo/* Event notifications from lower layer driver operations */
1134252190Srpaulo
1135252190Srpaulo/**
1136252190Srpaulo * enum p2p_probe_req_status
1137252190Srpaulo *
1138252190Srpaulo * @P2P_PREQ_MALFORMED: frame was not well-formed
1139252190Srpaulo * @P2P_PREQ_NOT_LISTEN: device isn't in listen state, frame ignored
1140252190Srpaulo * @P2P_PREQ_NOT_P2P: frame was not a P2P probe request
1141252190Srpaulo * @P2P_PREQ_P2P_NOT_PROCESSED: frame was P2P but wasn't processed
1142252190Srpaulo * @P2P_PREQ_P2P_PROCESSED: frame has been processed by P2P
1143252190Srpaulo */
1144252190Srpauloenum p2p_probe_req_status {
1145252190Srpaulo	P2P_PREQ_MALFORMED,
1146252190Srpaulo	P2P_PREQ_NOT_LISTEN,
1147252190Srpaulo	P2P_PREQ_NOT_P2P,
1148252190Srpaulo	P2P_PREQ_NOT_PROCESSED,
1149252190Srpaulo	P2P_PREQ_PROCESSED
1150252190Srpaulo};
1151252190Srpaulo
1152252190Srpaulo/**
1153252190Srpaulo * p2p_probe_req_rx - Report reception of a Probe Request frame
1154252190Srpaulo * @p2p: P2P module context from p2p_init()
1155252190Srpaulo * @addr: Source MAC address
1156252190Srpaulo * @dst: Destination MAC address if available or %NULL
1157252190Srpaulo * @bssid: BSSID if available or %NULL
1158252190Srpaulo * @ie: Information elements from the Probe Request frame body
1159252190Srpaulo * @ie_len: Length of ie buffer in octets
1160252190Srpaulo * Returns: value indicating the type and status of the probe request
1161252190Srpaulo */
1162252190Srpauloenum p2p_probe_req_status
1163252190Srpaulop2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
1164252190Srpaulo		 const u8 *bssid, const u8 *ie, size_t ie_len);
1165252190Srpaulo
1166252190Srpaulo/**
1167252190Srpaulo * p2p_rx_action - Report received Action frame
1168252190Srpaulo * @p2p: P2P module context from p2p_init()
1169252190Srpaulo * @da: Destination address of the received Action frame
1170252190Srpaulo * @sa: Source address of the received Action frame
1171252190Srpaulo * @bssid: Address 3 of the received Action frame
1172252190Srpaulo * @category: Category of the received Action frame
1173252190Srpaulo * @data: Action frame body after the Category field
1174252190Srpaulo * @len: Length of the data buffer in octets
1175252190Srpaulo * @freq: Frequency (in MHz) on which the frame was received
1176252190Srpaulo */
1177252190Srpaulovoid p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
1178252190Srpaulo		   const u8 *bssid, u8 category,
1179252190Srpaulo		   const u8 *data, size_t len, int freq);
1180252190Srpaulo
1181252190Srpaulo/**
1182252190Srpaulo * p2p_scan_res_handler - Indicate a P2P scan results
1183252190Srpaulo * @p2p: P2P module context from p2p_init()
1184252190Srpaulo * @bssid: BSSID of the scan result
1185252190Srpaulo * @freq: Frequency of the channel on which the device was found in MHz
1186252190Srpaulo * @age: Age of the scan result in milliseconds
1187252190Srpaulo * @level: Signal level (signal strength of the received Beacon/Probe Response
1188252190Srpaulo *	frame)
1189252190Srpaulo * @ies: Pointer to IEs from the scan result
1190252190Srpaulo * @ies_len: Length of the ies buffer
1191252190Srpaulo * Returns: 0 to continue or 1 to stop scan result indication
1192252190Srpaulo *
1193252190Srpaulo * This function is called to indicate a scan result entry with P2P IE from a
1194252190Srpaulo * scan requested with struct p2p_config::p2p_scan(). This can be called during
1195252190Srpaulo * the actual scan process (i.e., whenever a new device is found) or as a
1196252190Srpaulo * sequence of calls after the full scan has been completed. The former option
1197252190Srpaulo * can result in optimized operations, but may not be supported by all
1198252190Srpaulo * driver/firmware designs. The ies buffer need to include at least the P2P IE,
1199252190Srpaulo * but it is recommended to include all IEs received from the device. The
1200252190Srpaulo * caller does not need to check that the IEs contain a P2P IE before calling
1201252190Srpaulo * this function since frames will be filtered internally if needed.
1202252190Srpaulo *
1203252190Srpaulo * This function will return 1 if it wants to stop scan result iteration (and
1204252190Srpaulo * scan in general if it is still in progress). This is used to allow faster
1205252190Srpaulo * start of a pending operation, e.g., to start a pending GO negotiation.
1206252190Srpaulo */
1207252190Srpauloint p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
1208252190Srpaulo			 unsigned int age, int level, const u8 *ies,
1209252190Srpaulo			 size_t ies_len);
1210252190Srpaulo
1211252190Srpaulo/**
1212252190Srpaulo * p2p_scan_res_handled - Indicate end of scan results
1213252190Srpaulo * @p2p: P2P module context from p2p_init()
1214252190Srpaulo *
1215252190Srpaulo * This function is called to indicate that all P2P scan results from a scan
1216252190Srpaulo * have been reported with zero or more calls to p2p_scan_res_handler(). This
1217252190Srpaulo * function must be called as a response to successful
1218252190Srpaulo * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler()
1219252190Srpaulo * calls stopped iteration.
1220252190Srpaulo */
1221252190Srpaulovoid p2p_scan_res_handled(struct p2p_data *p2p);
1222252190Srpaulo
1223252190Srpauloenum p2p_send_action_result {
1224252190Srpaulo	P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
1225252190Srpaulo	P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */,
1226252190Srpaulo	P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */
1227252190Srpaulo};
1228252190Srpaulo
1229252190Srpaulo/**
1230252190Srpaulo * p2p_send_action_cb - Notify TX status of an Action frame
1231252190Srpaulo * @p2p: P2P module context from p2p_init()
1232252190Srpaulo * @freq: Channel frequency in MHz
1233252190Srpaulo * @dst: Destination MAC address (Address 1)
1234252190Srpaulo * @src: Source MAC address (Address 2)
1235252190Srpaulo * @bssid: BSSID (Address 3)
1236252190Srpaulo * @result: Result of the transmission attempt
1237252190Srpaulo *
1238252190Srpaulo * This function is used to indicate the result of an Action frame transmission
1239252190Srpaulo * that was requested with struct p2p_config::send_action() callback.
1240252190Srpaulo */
1241252190Srpaulovoid p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
1242252190Srpaulo			const u8 *src, const u8 *bssid,
1243252190Srpaulo			enum p2p_send_action_result result);
1244252190Srpaulo
1245252190Srpaulo/**
1246252190Srpaulo * p2p_listen_cb - Indicate the start of a requested Listen state
1247252190Srpaulo * @p2p: P2P module context from p2p_init()
1248252190Srpaulo * @freq: Listen channel frequency in MHz
1249252190Srpaulo * @duration: Duration for the Listen state in milliseconds
1250252190Srpaulo *
1251252190Srpaulo * This function is used to indicate that a Listen state requested with
1252252190Srpaulo * struct p2p_config::start_listen() callback has started.
1253252190Srpaulo */
1254252190Srpaulovoid p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
1255252190Srpaulo		   unsigned int duration);
1256252190Srpaulo
1257252190Srpaulo/**
1258252190Srpaulo * p2p_listen_end - Indicate the end of a requested Listen state
1259252190Srpaulo * @p2p: P2P module context from p2p_init()
1260252190Srpaulo * @freq: Listen channel frequency in MHz
1261252190Srpaulo * Returns: 0 if no operations were started, 1 if an operation was started
1262252190Srpaulo *
1263252190Srpaulo * This function is used to indicate that a Listen state requested with
1264252190Srpaulo * struct p2p_config::start_listen() callback has ended.
1265252190Srpaulo */
1266252190Srpauloint p2p_listen_end(struct p2p_data *p2p, unsigned int freq);
1267252190Srpaulo
1268252190Srpaulovoid p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1269252190Srpaulo		      const u8 *ie, size_t ie_len);
1270252190Srpaulo
1271252190Srpaulovoid p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1272252190Srpaulo			const u8 *ie, size_t ie_len);
1273252190Srpaulo
1274252190Srpaulo
1275252190Srpaulo/* Per-group P2P state for GO */
1276252190Srpaulo
1277252190Srpaulostruct p2p_group;
1278252190Srpaulo
1279252190Srpaulo/**
1280252190Srpaulo * struct p2p_group_config - P2P group configuration
1281252190Srpaulo *
1282252190Srpaulo * This configuration is provided to the P2P module during initialization of
1283252190Srpaulo * the per-group information with p2p_group_init().
1284252190Srpaulo */
1285252190Srpaulostruct p2p_group_config {
1286252190Srpaulo	/**
1287252190Srpaulo	 * persistent_group - Whether the group is persistent
1288252190Srpaulo	 * 0 = not a persistent group
1289252190Srpaulo	 * 1 = persistent group without persistent reconnect
1290252190Srpaulo	 * 2 = persistent group with persistent reconnect
1291252190Srpaulo	 */
1292252190Srpaulo	int persistent_group;
1293252190Srpaulo
1294252190Srpaulo	/**
1295252190Srpaulo	 * interface_addr - P2P Interface Address of the group
1296252190Srpaulo	 */
1297252190Srpaulo	u8 interface_addr[ETH_ALEN];
1298252190Srpaulo
1299252190Srpaulo	/**
1300252190Srpaulo	 * max_clients - Maximum number of clients in the group
1301252190Srpaulo	 */
1302252190Srpaulo	unsigned int max_clients;
1303252190Srpaulo
1304252190Srpaulo	/**
1305252190Srpaulo	 * ssid - Group SSID
1306252190Srpaulo	 */
1307252190Srpaulo	u8 ssid[32];
1308252190Srpaulo
1309252190Srpaulo	/**
1310252190Srpaulo	 * ssid_len - Length of SSID
1311252190Srpaulo	 */
1312252190Srpaulo	size_t ssid_len;
1313252190Srpaulo
1314252190Srpaulo	/**
1315252190Srpaulo	 * cb_ctx - Context to use with callback functions
1316252190Srpaulo	 */
1317252190Srpaulo	void *cb_ctx;
1318252190Srpaulo
1319252190Srpaulo	/**
1320252190Srpaulo	 * ie_update - Notification of IE update
1321252190Srpaulo	 * @ctx: Callback context from cb_ctx
1322252190Srpaulo	 * @beacon_ies: P2P IE for Beacon frames or %NULL if no change
1323252190Srpaulo	 * @proberesp_ies: P2P Ie for Probe Response frames
1324252190Srpaulo	 *
1325252190Srpaulo	 * P2P module uses this callback function to notify whenever the P2P IE
1326252190Srpaulo	 * in Beacon or Probe Response frames should be updated based on group
1327252190Srpaulo	 * events.
1328252190Srpaulo	 *
1329252190Srpaulo	 * The callee is responsible for freeing the returned buffer(s) with
1330252190Srpaulo	 * wpabuf_free().
1331252190Srpaulo	 */
1332252190Srpaulo	void (*ie_update)(void *ctx, struct wpabuf *beacon_ies,
1333252190Srpaulo			  struct wpabuf *proberesp_ies);
1334252190Srpaulo
1335252190Srpaulo	/**
1336252190Srpaulo	 * idle_update - Notification of changes in group idle state
1337252190Srpaulo	 * @ctx: Callback context from cb_ctx
1338252190Srpaulo	 * @idle: Whether the group is idle (no associated stations)
1339252190Srpaulo	 */
1340252190Srpaulo	void (*idle_update)(void *ctx, int idle);
1341252190Srpaulo};
1342252190Srpaulo
1343252190Srpaulo/**
1344252190Srpaulo * p2p_group_init - Initialize P2P group
1345252190Srpaulo * @p2p: P2P module context from p2p_init()
1346252190Srpaulo * @config: P2P group configuration (will be freed by p2p_group_deinit())
1347252190Srpaulo * Returns: Pointer to private data or %NULL on failure
1348252190Srpaulo *
1349252190Srpaulo * This function is used to initialize per-group P2P module context. Currently,
1350252190Srpaulo * this is only used to manage GO functionality and P2P clients do not need to
1351252190Srpaulo * create an instance of this per-group information.
1352252190Srpaulo */
1353252190Srpaulostruct p2p_group * p2p_group_init(struct p2p_data *p2p,
1354252190Srpaulo				  struct p2p_group_config *config);
1355252190Srpaulo
1356252190Srpaulo/**
1357252190Srpaulo * p2p_group_deinit - Deinitialize P2P group
1358252190Srpaulo * @group: P2P group context from p2p_group_init()
1359252190Srpaulo */
1360252190Srpaulovoid p2p_group_deinit(struct p2p_group *group);
1361252190Srpaulo
1362252190Srpaulo/**
1363252190Srpaulo * p2p_group_notif_assoc - Notification of P2P client association with GO
1364252190Srpaulo * @group: P2P group context from p2p_group_init()
1365252190Srpaulo * @addr: Interface address of the P2P client
1366252190Srpaulo * @ie: IEs from the (Re)association Request frame
1367252190Srpaulo * @len: Length of the ie buffer in octets
1368252190Srpaulo * Returns: 0 on success, -1 on failure
1369252190Srpaulo */
1370252190Srpauloint p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
1371252190Srpaulo			  const u8 *ie, size_t len);
1372252190Srpaulo
1373252190Srpaulo/**
1374252190Srpaulo * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response
1375252190Srpaulo * @group: P2P group context from p2p_group_init()
1376252190Srpaulo * @status: Status value (P2P_SC_SUCCESS if association succeeded)
1377252190Srpaulo * Returns: P2P IE for (Re)association Response or %NULL on failure
1378252190Srpaulo *
1379252190Srpaulo * The caller is responsible for freeing the returned buffer with
1380252190Srpaulo * wpabuf_free().
1381252190Srpaulo */
1382252190Srpaulostruct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status);
1383252190Srpaulo
1384252190Srpaulo/**
1385252190Srpaulo * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO
1386252190Srpaulo * @group: P2P group context from p2p_group_init()
1387252190Srpaulo * @addr: Interface address of the P2P client
1388252190Srpaulo */
1389252190Srpaulovoid p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr);
1390252190Srpaulo
1391252190Srpaulo/**
1392252190Srpaulo * p2p_group_notif_formation_done - Notification of completed group formation
1393252190Srpaulo * @group: P2P group context from p2p_group_init()
1394252190Srpaulo */
1395252190Srpaulovoid p2p_group_notif_formation_done(struct p2p_group *group);
1396252190Srpaulo
1397252190Srpaulo/**
1398252190Srpaulo * p2p_group_notif_noa - Notification of NoA change
1399252190Srpaulo * @group: P2P group context from p2p_group_init()
1400252190Srpaulo * @noa: Notice of Absence attribute payload, %NULL if none
1401252190Srpaulo * @noa_len: Length of noa buffer in octets
1402252190Srpaulo * Returns: 0 on success, -1 on failure
1403252190Srpaulo *
1404252190Srpaulo * Notify the P2P group management about a new NoA contents. This will be
1405252190Srpaulo * inserted into the P2P IEs in Beacon and Probe Response frames with rest of
1406252190Srpaulo * the group information.
1407252190Srpaulo */
1408252190Srpauloint p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
1409252190Srpaulo			size_t noa_len);
1410252190Srpaulo
1411252190Srpaulo/**
1412252190Srpaulo * p2p_group_match_dev_type - Match device types in group with requested type
1413252190Srpaulo * @group: P2P group context from p2p_group_init()
1414252190Srpaulo * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs)
1415252190Srpaulo * Returns: 1 on match, 0 on mismatch
1416252190Srpaulo *
1417252190Srpaulo * This function can be used to match the Requested Device Type attribute in
1418252190Srpaulo * WPS IE with the device types of a group member for deciding whether a GO
1419252190Srpaulo * should reply to a Probe Request frame. Match will be reported if the WPS IE
1420252190Srpaulo * is not requested any specific device type.
1421252190Srpaulo */
1422252190Srpauloint p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps);
1423252190Srpaulo
1424252190Srpaulo/**
1425252190Srpaulo * p2p_group_match_dev_id - Match P2P Device Address in group with requested device id
1426252190Srpaulo */
1427252190Srpauloint p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p);
1428252190Srpaulo
1429252190Srpaulo/**
1430252190Srpaulo * p2p_group_go_discover - Send GO Discoverability Request to a group client
1431252190Srpaulo * @group: P2P group context from p2p_group_init()
1432252190Srpaulo * Returns: 0 on success (frame scheduled); -1 if client was not found
1433252190Srpaulo */
1434252190Srpauloint p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
1435252190Srpaulo			  const u8 *searching_dev, int rx_freq);
1436252190Srpaulo
1437252190Srpaulo
1438252190Srpaulo/* Generic helper functions */
1439252190Srpaulo
1440252190Srpaulo/**
1441252190Srpaulo * p2p_ie_text - Build text format description of P2P IE
1442252190Srpaulo * @p2p_ie: P2P IE
1443252190Srpaulo * @buf: Buffer for returning text
1444252190Srpaulo * @end: Pointer to the end of the buf area
1445252190Srpaulo * Returns: Number of octets written to the buffer or -1 on failure
1446252190Srpaulo *
1447252190Srpaulo * This function can be used to parse P2P IE contents into text format
1448252190Srpaulo * field=value lines.
1449252190Srpaulo */
1450252190Srpauloint p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end);
1451252190Srpaulo
1452252190Srpaulo/**
1453252190Srpaulo * p2p_scan_result_text - Build text format description of P2P IE
1454252190Srpaulo * @ies: Information elements from scan results
1455252190Srpaulo * @ies_len: ies buffer length in octets
1456252190Srpaulo * @buf: Buffer for returning text
1457252190Srpaulo * @end: Pointer to the end of the buf area
1458252190Srpaulo * Returns: Number of octets written to the buffer or -1 on failure
1459252190Srpaulo *
1460252190Srpaulo * This function can be used to parse P2P IE contents into text format
1461252190Srpaulo * field=value lines.
1462252190Srpaulo */
1463252190Srpauloint p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end);
1464252190Srpaulo
1465252190Srpaulo/**
1466252190Srpaulo * p2p_parse_dev_addr_in_p2p_ie - Parse P2P Device Address from a concatenated
1467252190Srpaulo * P2P IE
1468252190Srpaulo * @p2p_ie: P2P IE
1469252190Srpaulo * @dev_addr: Buffer for returning P2P Device Address
1470252190Srpaulo * Returns: 0 on success or -1 if P2P Device Address could not be parsed
1471252190Srpaulo */
1472252190Srpauloint p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr);
1473252190Srpaulo
1474252190Srpaulo/**
1475252190Srpaulo * p2p_parse_dev_addr - Parse P2P Device Address from P2P IE(s)
1476252190Srpaulo * @ies: Information elements from scan results
1477252190Srpaulo * @ies_len: ies buffer length in octets
1478252190Srpaulo * @dev_addr: Buffer for returning P2P Device Address
1479252190Srpaulo * Returns: 0 on success or -1 if P2P Device Address could not be parsed
1480252190Srpaulo */
1481252190Srpauloint p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr);
1482252190Srpaulo
1483252190Srpaulo/**
1484252190Srpaulo * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame
1485252190Srpaulo * @p2p: P2P module context from p2p_init()
1486252190Srpaulo * @bssid: BSSID
1487252190Srpaulo * @buf: Buffer for writing the P2P IE
1488252190Srpaulo * @len: Maximum buf length in octets
1489252190Srpaulo * @p2p_group: Whether this is for association with a P2P GO
1490252190Srpaulo * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none
1491252190Srpaulo * Returns: Number of octets written into buf or -1 on failure
1492252190Srpaulo */
1493252190Srpauloint p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf,
1494252190Srpaulo		     size_t len, int p2p_group, struct wpabuf *p2p_ie);
1495252190Srpaulo
1496252190Srpaulo/**
1497252190Srpaulo * p2p_scan_ie - Build P2P IE for Probe Request
1498252190Srpaulo * @p2p: P2P module context from p2p_init()
1499252190Srpaulo * @ies: Buffer for writing P2P IE
1500252190Srpaulo * @dev_id: Device ID to search for or %NULL for any
1501252190Srpaulo */
1502252190Srpaulovoid p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id);
1503252190Srpaulo
1504252190Srpaulo/**
1505252190Srpaulo * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie
1506252190Srpaulo * @p2p: P2P module context from p2p_init()
1507252190Srpaulo * Returns: Number of octets that p2p_scan_ie() may add to the buffer
1508252190Srpaulo */
1509252190Srpaulosize_t p2p_scan_ie_buf_len(struct p2p_data *p2p);
1510252190Srpaulo
1511252190Srpaulo/**
1512252190Srpaulo * p2p_go_params - Generate random P2P group parameters
1513252190Srpaulo * @p2p: P2P module context from p2p_init()
1514252190Srpaulo * @params: Buffer for parameters
1515252190Srpaulo * Returns: 0 on success, -1 on failure
1516252190Srpaulo */
1517252190Srpauloint p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params);
1518252190Srpaulo
1519252190Srpaulo/**
1520252190Srpaulo * p2p_get_group_capab - Get Group Capability from P2P IE data
1521252190Srpaulo * @p2p_ie: P2P IE(s) contents
1522252190Srpaulo * Returns: Group Capability
1523252190Srpaulo */
1524252190Srpaulou8 p2p_get_group_capab(const struct wpabuf *p2p_ie);
1525252190Srpaulo
1526252190Srpaulo/**
1527252190Srpaulo * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection
1528252190Srpaulo * @p2p_ie: P2P IE(s) contents
1529252190Srpaulo * Returns: 0 if cross connection is allow, 1 if not
1530252190Srpaulo */
1531252190Srpauloint p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie);
1532252190Srpaulo
1533252190Srpaulo/**
1534252190Srpaulo * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data
1535252190Srpaulo * @p2p_ie: P2P IE(s) contents
1536252190Srpaulo * Returns: Pointer to P2P Device Address or %NULL if not included
1537252190Srpaulo */
1538252190Srpauloconst u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie);
1539252190Srpaulo
1540252190Srpaulo/**
1541252190Srpaulo * p2p_get_peer_info - Get P2P peer information
1542252190Srpaulo * @p2p: P2P module context from p2p_init()
1543252190Srpaulo * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
1544252190Srpaulo * @next: Whether to select the peer entry following the one indicated by addr
1545252190Srpaulo * Returns: Pointer to peer info or %NULL if not found
1546252190Srpaulo */
1547252190Srpauloconst struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p,
1548252190Srpaulo					       const u8 *addr, int next);
1549252190Srpaulo
1550252190Srpaulo/**
1551252190Srpaulo * p2p_get_peer_info_txt - Get internal P2P peer information in text format
1552252190Srpaulo * @info: Pointer to P2P peer info from p2p_get_peer_info()
1553252190Srpaulo * @buf: Buffer for returning text
1554252190Srpaulo * @buflen: Maximum buffer length
1555252190Srpaulo * Returns: Number of octets written to the buffer or -1 on failure
1556252190Srpaulo *
1557252190Srpaulo * Note: This information is internal to the P2P module and subject to change.
1558252190Srpaulo * As such, this should not really be used by external programs for purposes
1559252190Srpaulo * other than debugging.
1560252190Srpaulo */
1561252190Srpauloint p2p_get_peer_info_txt(const struct p2p_peer_info *info,
1562252190Srpaulo			  char *buf, size_t buflen);
1563252190Srpaulo
1564252190Srpaulo/**
1565252190Srpaulo * p2p_peer_known - Check whether P2P peer is known
1566252190Srpaulo * @p2p: P2P module context from p2p_init()
1567252190Srpaulo * @addr: P2P Device Address of the peer
1568252190Srpaulo * Returns: 1 if the specified device is in the P2P peer table or 0 if not
1569252190Srpaulo */
1570252190Srpauloint p2p_peer_known(struct p2p_data *p2p, const u8 *addr);
1571252190Srpaulo
1572252190Srpaulo/**
1573252190Srpaulo * p2p_set_client_discoverability - Set client discoverability capability
1574252190Srpaulo * @p2p: P2P module context from p2p_init()
1575252190Srpaulo * @enabled: Whether client discoverability will be enabled
1576252190Srpaulo *
1577252190Srpaulo * This function can be used to disable (and re-enable) client discoverability.
1578252190Srpaulo * This capability is enabled by default and should not be disabled in normal
1579252190Srpaulo * use cases, i.e., this is mainly for testing purposes.
1580252190Srpaulo */
1581252190Srpaulovoid p2p_set_client_discoverability(struct p2p_data *p2p, int enabled);
1582252190Srpaulo
1583252190Srpaulo/**
1584252190Srpaulo * p2p_set_managed_oper - Set managed P2P Device operations capability
1585252190Srpaulo * @p2p: P2P module context from p2p_init()
1586252190Srpaulo * @enabled: Whether managed P2P Device operations will be enabled
1587252190Srpaulo */
1588252190Srpaulovoid p2p_set_managed_oper(struct p2p_data *p2p, int enabled);
1589252190Srpaulo
1590252190Srpauloint p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel);
1591252190Srpaulo
1592252190Srpauloint p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len);
1593252190Srpaulo
1594252190Srpauloint p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
1595252190Srpaulo			   u8 *iface_addr);
1596252190Srpauloint p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
1597252190Srpaulo			   u8 *dev_addr);
1598252190Srpaulo
1599252190Srpaulovoid p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
1600252190Srpaulo
1601252190Srpaulo/**
1602252190Srpaulo * p2p_set_cross_connect - Set cross connection capability
1603252190Srpaulo * @p2p: P2P module context from p2p_init()
1604252190Srpaulo * @enabled: Whether cross connection will be enabled
1605252190Srpaulo */
1606252190Srpaulovoid p2p_set_cross_connect(struct p2p_data *p2p, int enabled);
1607252190Srpaulo
1608252190Srpauloint p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr);
1609252190Srpaulo
1610252190Srpaulo/**
1611252190Srpaulo * p2p_set_intra_bss_dist - Set intra BSS distribution
1612252190Srpaulo * @p2p: P2P module context from p2p_init()
1613252190Srpaulo * @enabled: Whether intra BSS distribution will be enabled
1614252190Srpaulo */
1615252190Srpaulovoid p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled);
1616252190Srpaulo
1617252190Srpaulo/**
1618252190Srpaulo * p2p_supported_freq - Check whether channel is supported for P2P
1619252190Srpaulo * @p2p: P2P module context from p2p_init()
1620252190Srpaulo * @freq: Channel frequency in MHz
1621252190Srpaulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
1622252190Srpaulo */
1623252190Srpauloint p2p_supported_freq(struct p2p_data *p2p, unsigned int freq);
1624252190Srpaulo
1625252190Srpaulovoid p2p_update_channel_list(struct p2p_data *p2p, struct p2p_channels *chan);
1626252190Srpaulo
1627252190Srpaulo/**
1628252190Srpaulo * p2p_set_best_channels - Update best channel information
1629252190Srpaulo * @p2p: P2P module context from p2p_init()
1630252190Srpaulo * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band
1631252190Srpaulo * @freq_5: Frequency (MHz) of best channel in 5 GHz band
1632252190Srpaulo * @freq_overall: Frequency (MHz) of best channel overall
1633252190Srpaulo */
1634252190Srpaulovoid p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
1635252190Srpaulo			   int freq_overall);
1636252190Srpaulo
1637252190Srpauloconst u8 * p2p_get_go_neg_peer(struct p2p_data *p2p);
1638252190Srpaulo
1639252190Srpaulo/**
1640252190Srpaulo * p2p_get_group_num_members - Get number of members in group
1641252190Srpaulo * @group: P2P group context from p2p_group_init()
1642252190Srpaulo * Returns: Number of members in the group
1643252190Srpaulo */
1644252190Srpaulounsigned int p2p_get_group_num_members(struct p2p_group *group);
1645252190Srpaulo
1646252190Srpaulo/**
1647252190Srpaulo * p2p_iterate_group_members - Iterate group members
1648252190Srpaulo * @group: P2P group context from p2p_group_init()
1649252190Srpaulo * @next: iteration pointer, must be a pointer to a void * that is set to %NULL
1650252190Srpaulo *	on the first call and not modified later
1651252190Srpaulo * Returns: A P2P Interface Address for each call and %NULL for no more members
1652252190Srpaulo */
1653252190Srpauloconst u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
1654252190Srpaulo
1655252190Srpaulo/**
1656252190Srpaulo * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group
1657252190Srpaulo * @group: P2P group context from p2p_group_init()
1658252190Srpaulo * @addr: P2P Interface Address of the client
1659252190Srpaulo * Returns: P2P Device Address of the client if found or %NULL if no match
1660252190Srpaulo * found
1661252190Srpaulo */
1662252190Srpauloconst u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
1663252190Srpaulo
1664252190Srpaulo/**
1665252190Srpaulo * p2p_group_is_client_connected - Check whether a specific client is connected
1666252190Srpaulo * @group: P2P group context from p2p_group_init()
1667252190Srpaulo * @addr: P2P Device Address of the client
1668252190Srpaulo * Returns: 1 if client is connected or 0 if not
1669252190Srpaulo */
1670252190Srpauloint p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr);
1671252190Srpaulo
1672252190Srpaulo/**
1673252190Srpaulo * p2p_get_peer_found - Get P2P peer info structure of a found peer
1674252190Srpaulo * @p2p: P2P module context from p2p_init()
1675252190Srpaulo * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
1676252190Srpaulo * @next: Whether to select the peer entry following the one indicated by addr
1677252190Srpaulo * Returns: The first P2P peer info available or %NULL if no such peer exists
1678252190Srpaulo */
1679252190Srpauloconst struct p2p_peer_info *
1680252190Srpaulop2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
1681252190Srpaulo
1682252190Srpaulo/**
1683252190Srpaulo * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions
1684252190Srpaulo * @p2p: P2P module context from p2p_init()
1685252190Srpaulo */
1686252190Srpaulovoid p2p_remove_wps_vendor_extensions(struct p2p_data *p2p);
1687252190Srpaulo
1688252190Srpaulo/**
1689252190Srpaulo * p2p_add_wps_vendor_extension - Add a WPS vendor extension
1690252190Srpaulo * @p2p: P2P module context from p2p_init()
1691252190Srpaulo * @vendor_ext: The vendor extensions to add
1692252190Srpaulo * Returns: 0 on success, -1 on failure
1693252190Srpaulo *
1694252190Srpaulo * The wpabuf structures in the array are owned by the P2P
1695252190Srpaulo * module after this call.
1696252190Srpaulo */
1697252190Srpauloint p2p_add_wps_vendor_extension(struct p2p_data *p2p,
1698252190Srpaulo				 const struct wpabuf *vendor_ext);
1699252190Srpaulo
1700252190Srpaulo/**
1701252190Srpaulo * p2p_set_oper_channel - Set the P2P operating channel
1702252190Srpaulo * @p2p: P2P module context from p2p_init()
1703252190Srpaulo * @op_reg_class: Operating regulatory class to set
1704252190Srpaulo * @op_channel: operating channel to set
1705252190Srpaulo * @cfg_op_channel : Whether op_channel is hardcoded in configuration
1706252190Srpaulo * Returns: 0 on success, -1 on failure
1707252190Srpaulo */
1708252190Srpauloint p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
1709252190Srpaulo			 int cfg_op_channel);
1710252190Srpaulo
1711252190Srpaulo/**
1712252190Srpaulo * p2p_set_pref_chan - Set P2P preferred channel list
1713252190Srpaulo * @p2p: P2P module context from p2p_init()
1714252190Srpaulo * @num_pref_chan: Number of entries in pref_chan list
1715252190Srpaulo * @pref_chan: Preferred channels or %NULL to remove preferences
1716252190Srpaulo * Returns: 0 on success, -1 on failure
1717252190Srpaulo */
1718252190Srpauloint p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan,
1719252190Srpaulo		      const struct p2p_channel *pref_chan);
1720252190Srpaulo
1721252190Srpaulo/**
1722252190Srpaulo * p2p_in_progress - Check whether a P2P operation is progress
1723252190Srpaulo * @p2p: P2P module context from p2p_init()
1724252190Srpaulo * Returns: 0 if P2P module is idle or 1 if an operation is in progress
1725252190Srpaulo */
1726252190Srpauloint p2p_in_progress(struct p2p_data *p2p);
1727252190Srpaulo
1728252190Srpaulo/**
1729252190Srpaulo * p2p_other_scan_completed - Notify completion of non-P2P scan
1730252190Srpaulo * @p2p: P2P module context from p2p_init()
1731252190Srpaulo * Returns: 0 if P2P module is idle or 1 if an operation was started
1732252190Srpaulo */
1733252190Srpauloint p2p_other_scan_completed(struct p2p_data *p2p);
1734252190Srpaulo
1735252190Srpauloconst char * p2p_wps_method_text(enum p2p_wps_method method);
1736252190Srpaulo
1737252190Srpaulo/**
1738252190Srpaulo * p2p_set_config_timeout - Set local config timeouts
1739252190Srpaulo * @p2p: P2P module context from p2p_init()
1740252190Srpaulo * @go_timeout: Time in 10 ms units it takes to start the GO mode
1741252190Srpaulo * @client_timeout: Time in 10 ms units it takes to start the client mode
1742252190Srpaulo */
1743252190Srpaulovoid p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout,
1744252190Srpaulo			    u8 client_timeout);
1745252190Srpaulo
1746252190Srpaulovoid p2p_increase_search_delay(struct p2p_data *p2p, unsigned int delay);
1747252190Srpaulo
1748252190Srpauloint p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie);
1749252190Srpauloint p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie);
1750252190Srpauloint p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie);
1751252190Srpauloint p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie);
1752252190Srpauloint p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie);
1753252190Srpauloint p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie);
1754252190Srpauloint p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie);
1755252190Srpauloint p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie);
1756252190Srpauloint p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem);
1757252190Srpauloint p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem);
1758252190Srpauloint p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p,
1759252190Srpaulo				  const struct wpabuf *elem);
1760252190Srpaulostruct wpabuf * wifi_display_encaps(struct wpabuf *subelems);
1761252190Srpaulo
1762252190Srpaulo/**
1763252190Srpaulo * p2p_set_disc_int - Set min/max discoverable interval for p2p_find
1764252190Srpaulo * @p2p: P2P module context from p2p_init()
1765252190Srpaulo * @min_disc_int: minDiscoverableInterval (in units of 100 TU); default 1
1766252190Srpaulo * @max_disc_int: maxDiscoverableInterval (in units of 100 TU); default 3
1767252190Srpaulo * @max_disc_tu: Maximum number of TUs (1.024 ms) for discoverable interval; or
1768252190Srpaulo *	-1 not to limit
1769252190Srpaulo * Returns: 0 on success, or -1 on failure
1770252190Srpaulo *
1771252190Srpaulo * This function can be used to configure minDiscoverableInterval and
1772252190Srpaulo * maxDiscoverableInterval parameters for the Listen state during device
1773252190Srpaulo * discovery (p2p_find). A random number of 100 TU units is picked for each
1774252190Srpaulo * Listen state iteration from [min_disc_int,max_disc_int] range.
1775252190Srpaulo *
1776252190Srpaulo * max_disc_tu can be used to futher limit the discoverable duration. However,
1777252190Srpaulo * it should be noted that use of this parameter is not recommended since it
1778252190Srpaulo * would not be compliant with the P2P specification.
1779252190Srpaulo */
1780252190Srpauloint p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int,
1781252190Srpaulo		     int max_disc_tu);
1782252190Srpaulo
1783252190Srpaulo#endif /* P2P_H */
1784