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
12289549Srpaulo#include "common/ieee802_11_defs.h"
13289549Srpaulo#include "wps/wps.h"
14281806Srpaulo
15281806Srpaulo/* P2P ASP Setup Capability */
16281806Srpaulo#define P2PS_SETUP_NONE 0
17281806Srpaulo#define P2PS_SETUP_NEW BIT(0)
18281806Srpaulo#define P2PS_SETUP_CLIENT BIT(1)
19281806Srpaulo#define P2PS_SETUP_GROUP_OWNER BIT(2)
20281806Srpaulo
21281806Srpaulo#define P2PS_WILD_HASH_STR "org.wi-fi.wfds"
22281806Srpaulo#define P2PS_HASH_LEN 6
23281806Srpaulo#define P2P_MAX_QUERY_HASH 6
24289549Srpaulo#define P2PS_FEATURE_CAPAB_CPT_MAX 2
25281806Srpaulo
26252190Srpaulo/**
27289549Srpaulo * P2P_MAX_PREF_CHANNELS - Maximum number of preferred channels
28289549Srpaulo */
29289549Srpaulo#define P2P_MAX_PREF_CHANNELS 100
30289549Srpaulo
31289549Srpaulo/**
32252190Srpaulo * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes
33252190Srpaulo */
34337817Scy#define P2P_MAX_REG_CLASSES 15
35252190Srpaulo
36252190Srpaulo/**
37252190Srpaulo * P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class
38252190Srpaulo */
39252190Srpaulo#define P2P_MAX_REG_CLASS_CHANNELS 20
40252190Srpaulo
41252190Srpaulo/**
42252190Srpaulo * struct p2p_channels - List of supported channels
43252190Srpaulo */
44252190Srpaulostruct p2p_channels {
45252190Srpaulo	/**
46252190Srpaulo	 * struct p2p_reg_class - Supported regulatory class
47252190Srpaulo	 */
48252190Srpaulo	struct p2p_reg_class {
49252190Srpaulo		/**
50252190Srpaulo		 * reg_class - Regulatory class (IEEE 802.11-2007, Annex J)
51252190Srpaulo		 */
52252190Srpaulo		u8 reg_class;
53252190Srpaulo
54252190Srpaulo		/**
55252190Srpaulo		 * channel - Supported channels
56252190Srpaulo		 */
57252190Srpaulo		u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
58252190Srpaulo
59252190Srpaulo		/**
60252190Srpaulo		 * channels - Number of channel entries in use
61252190Srpaulo		 */
62252190Srpaulo		size_t channels;
63252190Srpaulo	} reg_class[P2P_MAX_REG_CLASSES];
64252190Srpaulo
65252190Srpaulo	/**
66252190Srpaulo	 * reg_classes - Number of reg_class entries in use
67252190Srpaulo	 */
68252190Srpaulo	size_t reg_classes;
69252190Srpaulo};
70252190Srpaulo
71252190Srpauloenum p2p_wps_method {
72281806Srpaulo	WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC,
73281806Srpaulo	WPS_P2PS
74252190Srpaulo};
75252190Srpaulo
76252190Srpaulo/**
77252190Srpaulo * struct p2p_go_neg_results - P2P Group Owner Negotiation results
78252190Srpaulo */
79252190Srpaulostruct p2p_go_neg_results {
80252190Srpaulo	/**
81252190Srpaulo	 * status - Negotiation result (Status Code)
82252190Srpaulo	 *
83252190Srpaulo	 * 0 (P2P_SC_SUCCESS) indicates success. Non-zero values indicate
84252190Srpaulo	 * failed negotiation.
85252190Srpaulo	 */
86252190Srpaulo	int status;
87252190Srpaulo
88252190Srpaulo	/**
89252190Srpaulo	 * role_go - Whether local end is Group Owner
90252190Srpaulo	 */
91252190Srpaulo	int role_go;
92252190Srpaulo
93252190Srpaulo	/**
94252190Srpaulo	 * freq - Frequency of the group operational channel in MHz
95252190Srpaulo	 */
96252190Srpaulo	int freq;
97252190Srpaulo
98252190Srpaulo	int ht40;
99252190Srpaulo
100281806Srpaulo	int vht;
101281806Srpaulo
102337817Scy	u8 max_oper_chwidth;
103337817Scy
104337817Scy	unsigned int vht_center_freq2;
105337817Scy
106252190Srpaulo	/**
107346981Scy	 * he - Indicates if IEEE 802.11ax HE is enabled
108346981Scy	 */
109346981Scy	int he;
110346981Scy
111346981Scy	/**
112252190Srpaulo	 * ssid - SSID of the group
113252190Srpaulo	 */
114289549Srpaulo	u8 ssid[SSID_MAX_LEN];
115252190Srpaulo
116252190Srpaulo	/**
117252190Srpaulo	 * ssid_len - Length of SSID in octets
118252190Srpaulo	 */
119252190Srpaulo	size_t ssid_len;
120252190Srpaulo
121252190Srpaulo	/**
122252190Srpaulo	 * psk - WPA pre-shared key (256 bits) (GO only)
123252190Srpaulo	 */
124252190Srpaulo	u8 psk[32];
125252190Srpaulo
126252190Srpaulo	/**
127252190Srpaulo	 * psk_set - Whether PSK field is configured (GO only)
128252190Srpaulo	 */
129252190Srpaulo	int psk_set;
130252190Srpaulo
131252190Srpaulo	/**
132252190Srpaulo	 * passphrase - WPA2-Personal passphrase for the group (GO only)
133252190Srpaulo	 */
134252190Srpaulo	char passphrase[64];
135252190Srpaulo
136252190Srpaulo	/**
137252190Srpaulo	 * peer_device_addr - P2P Device Address of the peer
138252190Srpaulo	 */
139252190Srpaulo	u8 peer_device_addr[ETH_ALEN];
140252190Srpaulo
141252190Srpaulo	/**
142252190Srpaulo	 * peer_interface_addr - P2P Interface Address of the peer
143252190Srpaulo	 */
144252190Srpaulo	u8 peer_interface_addr[ETH_ALEN];
145252190Srpaulo
146252190Srpaulo	/**
147252190Srpaulo	 * wps_method - WPS method to be used during provisioning
148252190Srpaulo	 */
149252190Srpaulo	enum p2p_wps_method wps_method;
150252190Srpaulo
151252190Srpaulo#define P2P_MAX_CHANNELS 50
152252190Srpaulo
153252190Srpaulo	/**
154252190Srpaulo	 * freq_list - Zero-terminated list of possible operational channels
155252190Srpaulo	 */
156252190Srpaulo	int freq_list[P2P_MAX_CHANNELS];
157252190Srpaulo
158252190Srpaulo	/**
159252190Srpaulo	 * persistent_group - Whether the group should be made persistent
160252190Srpaulo	 * 0 = not persistent
161252190Srpaulo	 * 1 = persistent group without persistent reconnect
162252190Srpaulo	 * 2 = persistent group with persistent reconnect
163252190Srpaulo	 */
164252190Srpaulo	int persistent_group;
165252190Srpaulo
166252190Srpaulo	/**
167252190Srpaulo	 * peer_config_timeout - Peer configuration timeout (in 10 msec units)
168252190Srpaulo	 */
169252190Srpaulo	unsigned int peer_config_timeout;
170252190Srpaulo};
171252190Srpaulo
172281806Srpaulostruct p2ps_provision {
173281806Srpaulo	/**
174289549Srpaulo	 * pd_seeker - P2PS provision discovery seeker role
175289549Srpaulo	 */
176289549Srpaulo	unsigned int pd_seeker:1;
177289549Srpaulo
178289549Srpaulo	/**
179281806Srpaulo	 * status - Remote returned provisioning status code
180281806Srpaulo	 */
181281806Srpaulo	int status;
182281806Srpaulo
183281806Srpaulo	/**
184281806Srpaulo	 * adv_id - P2PS Advertisement ID
185281806Srpaulo	 */
186281806Srpaulo	u32 adv_id;
187281806Srpaulo
188281806Srpaulo	/**
189281806Srpaulo	 * session_id - P2PS Session ID
190281806Srpaulo	 */
191281806Srpaulo	u32 session_id;
192281806Srpaulo
193281806Srpaulo	/**
194281806Srpaulo	 * method - WPS Method (to be) used to establish session
195281806Srpaulo	 */
196281806Srpaulo	u16 method;
197281806Srpaulo
198281806Srpaulo	/**
199281806Srpaulo	 * conncap - Connection Capabilities negotiated between P2P peers
200281806Srpaulo	 */
201281806Srpaulo	u8 conncap;
202281806Srpaulo
203281806Srpaulo	/**
204281806Srpaulo	 * role - Info about the roles to be used for this connection
205281806Srpaulo	 */
206281806Srpaulo	u8 role;
207281806Srpaulo
208281806Srpaulo	/**
209281806Srpaulo	 * session_mac - MAC address of the peer that started the session
210281806Srpaulo	 */
211281806Srpaulo	u8 session_mac[ETH_ALEN];
212281806Srpaulo
213281806Srpaulo	/**
214281806Srpaulo	 * adv_mac - MAC address of the peer advertised the service
215281806Srpaulo	 */
216281806Srpaulo	u8 adv_mac[ETH_ALEN];
217281806Srpaulo
218281806Srpaulo	/**
219289549Srpaulo	 * cpt_mask - Supported Coordination Protocol Transport mask
220289549Srpaulo	 *
221289549Srpaulo	 * A bitwise mask of supported ASP Coordination Protocol Transports.
222289549Srpaulo	 * This property is set together and corresponds with cpt_priority.
223289549Srpaulo	 */
224289549Srpaulo	u8 cpt_mask;
225289549Srpaulo
226289549Srpaulo	/**
227289549Srpaulo	 * cpt_priority - Coordination Protocol Transport priority list
228289549Srpaulo	 *
229289549Srpaulo	 * Priorities of supported ASP Coordination Protocol Transports.
230289549Srpaulo	 * This property is set together and corresponds with cpt_mask.
231289549Srpaulo	 * The CPT priority list is 0 terminated.
232289549Srpaulo	 */
233289549Srpaulo	u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
234289549Srpaulo
235289549Srpaulo	/**
236337817Scy	 * force_freq - The only allowed channel frequency in MHz or 0.
237337817Scy	 */
238337817Scy	unsigned int force_freq;
239337817Scy
240337817Scy	/**
241337817Scy	 * pref_freq - Preferred operating frequency in MHz or 0.
242337817Scy	 */
243337817Scy	unsigned int pref_freq;
244337817Scy
245337817Scy	/**
246281806Srpaulo	 * info - Vendor defined extra Provisioning information
247281806Srpaulo	 */
248281806Srpaulo	char info[0];
249281806Srpaulo};
250281806Srpaulo
251281806Srpaulostruct p2ps_advertisement {
252281806Srpaulo	struct p2ps_advertisement *next;
253281806Srpaulo
254281806Srpaulo	/**
255281806Srpaulo	 * svc_info - Pointer to (internal) Service defined information
256281806Srpaulo	 */
257281806Srpaulo	char *svc_info;
258281806Srpaulo
259281806Srpaulo	/**
260281806Srpaulo	 * id - P2PS Advertisement ID
261281806Srpaulo	 */
262281806Srpaulo	u32 id;
263281806Srpaulo
264281806Srpaulo	/**
265281806Srpaulo	 * config_methods - WPS Methods which are allowed for this service
266281806Srpaulo	 */
267281806Srpaulo	u16 config_methods;
268281806Srpaulo
269281806Srpaulo	/**
270281806Srpaulo	 * state - Current state of the service: 0 - Out Of Service, 1-255 Vendor defined
271281806Srpaulo	 */
272281806Srpaulo	u8 state;
273281806Srpaulo
274281806Srpaulo	/**
275281806Srpaulo	 * auto_accept - Automatically Accept provisioning request if possible.
276281806Srpaulo	 */
277281806Srpaulo	u8 auto_accept;
278281806Srpaulo
279281806Srpaulo	/**
280281806Srpaulo	 * hash - 6 octet Service Name has to match against incoming Probe Requests
281281806Srpaulo	 */
282281806Srpaulo	u8 hash[P2PS_HASH_LEN];
283281806Srpaulo
284281806Srpaulo	/**
285289549Srpaulo	 * cpt_mask - supported Coordination Protocol Transport mask
286289549Srpaulo	 *
287289549Srpaulo	 * A bitwise mask of supported ASP Coordination Protocol Transports.
288289549Srpaulo	 * This property is set together and corresponds with cpt_priority.
289289549Srpaulo	 */
290289549Srpaulo	u8 cpt_mask;
291289549Srpaulo
292289549Srpaulo	/**
293289549Srpaulo	 * cpt_priority - Coordination Protocol Transport priority list
294289549Srpaulo	 *
295289549Srpaulo	 * Priorities of supported ASP Coordinatin Protocol Transports.
296289549Srpaulo	 * This property is set together and corresponds with cpt_mask.
297289549Srpaulo	 * The CPT priority list is 0 terminated.
298289549Srpaulo	 */
299289549Srpaulo	u8 cpt_priority[P2PS_FEATURE_CAPAB_CPT_MAX + 1];
300289549Srpaulo
301289549Srpaulo	/**
302281806Srpaulo	 * svc_name - NULL Terminated UTF-8 Service Name, and svc_info storage
303281806Srpaulo	 */
304281806Srpaulo	char svc_name[0];
305281806Srpaulo};
306281806Srpaulo
307281806Srpaulo
308252190Srpaulostruct p2p_data;
309252190Srpaulo
310252190Srpauloenum p2p_scan_type {
311252190Srpaulo	P2P_SCAN_SOCIAL,
312252190Srpaulo	P2P_SCAN_FULL,
313281806Srpaulo	P2P_SCAN_SPECIFIC,
314252190Srpaulo	P2P_SCAN_SOCIAL_PLUS_ONE
315252190Srpaulo};
316252190Srpaulo
317252190Srpaulo#define P2P_MAX_WPS_VENDOR_EXT 10
318252190Srpaulo
319252190Srpaulo/**
320252190Srpaulo * struct p2p_peer_info - P2P peer information
321252190Srpaulo */
322252190Srpaulostruct p2p_peer_info {
323252190Srpaulo	/**
324252190Srpaulo	 * p2p_device_addr - P2P Device Address of the peer
325252190Srpaulo	 */
326252190Srpaulo	u8 p2p_device_addr[ETH_ALEN];
327252190Srpaulo
328252190Srpaulo	/**
329252190Srpaulo	 * pri_dev_type - Primary Device Type
330252190Srpaulo	 */
331252190Srpaulo	u8 pri_dev_type[8];
332252190Srpaulo
333252190Srpaulo	/**
334252190Srpaulo	 * device_name - Device Name (0..32 octets encoded in UTF-8)
335252190Srpaulo	 */
336289549Srpaulo	char device_name[WPS_DEV_NAME_MAX_LEN + 1];
337252190Srpaulo
338252190Srpaulo	/**
339252190Srpaulo	 * manufacturer - Manufacturer (0..64 octets encoded in UTF-8)
340252190Srpaulo	 */
341289549Srpaulo	char manufacturer[WPS_MANUFACTURER_MAX_LEN + 1];
342252190Srpaulo
343252190Srpaulo	/**
344252190Srpaulo	 * model_name - Model Name (0..32 octets encoded in UTF-8)
345252190Srpaulo	 */
346289549Srpaulo	char model_name[WPS_MODEL_NAME_MAX_LEN + 1];
347252190Srpaulo
348252190Srpaulo	/**
349252190Srpaulo	 * model_number - Model Number (0..32 octets encoded in UTF-8)
350252190Srpaulo	 */
351289549Srpaulo	char model_number[WPS_MODEL_NUMBER_MAX_LEN + 1];
352252190Srpaulo
353252190Srpaulo	/**
354252190Srpaulo	 * serial_number - Serial Number (0..32 octets encoded in UTF-8)
355252190Srpaulo	 */
356289549Srpaulo	char serial_number[WPS_SERIAL_NUMBER_MAX_LEN + 1];
357252190Srpaulo
358252190Srpaulo	/**
359252190Srpaulo	 * level - Signal level
360252190Srpaulo	 */
361252190Srpaulo	int level;
362252190Srpaulo
363252190Srpaulo	/**
364252190Srpaulo	 * config_methods - WPS Configuration Methods
365252190Srpaulo	 */
366252190Srpaulo	u16 config_methods;
367252190Srpaulo
368252190Srpaulo	/**
369252190Srpaulo	 * dev_capab - Device Capabilities
370252190Srpaulo	 */
371252190Srpaulo	u8 dev_capab;
372252190Srpaulo
373252190Srpaulo	/**
374252190Srpaulo	 * group_capab - Group Capabilities
375252190Srpaulo	 */
376252190Srpaulo	u8 group_capab;
377252190Srpaulo
378252190Srpaulo	/**
379252190Srpaulo	 * wps_sec_dev_type_list - WPS secondary device type list
380252190Srpaulo	 *
381252190Srpaulo	 * This list includes from 0 to 16 Secondary Device Types as indicated
382252190Srpaulo	 * by wps_sec_dev_type_list_len (8 * number of types).
383252190Srpaulo	 */
384289549Srpaulo	u8 wps_sec_dev_type_list[WPS_SEC_DEV_TYPE_MAX_LEN];
385252190Srpaulo
386252190Srpaulo	/**
387252190Srpaulo	 * wps_sec_dev_type_list_len - Length of secondary device type list
388252190Srpaulo	 */
389252190Srpaulo	size_t wps_sec_dev_type_list_len;
390252190Srpaulo
391252190Srpaulo	struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
392252190Srpaulo
393252190Srpaulo	/**
394252190Srpaulo	 * wfd_subelems - Wi-Fi Display subelements from WFD IE(s)
395252190Srpaulo	 */
396252190Srpaulo	struct wpabuf *wfd_subelems;
397281806Srpaulo
398281806Srpaulo	/**
399281806Srpaulo	 * vendor_elems - Unrecognized vendor elements
400281806Srpaulo	 *
401281806Srpaulo	 * This buffer includes any other vendor element than P2P, WPS, and WFD
402281806Srpaulo	 * IE(s) from the frame that was used to discover the peer.
403281806Srpaulo	 */
404281806Srpaulo	struct wpabuf *vendor_elems;
405281806Srpaulo
406281806Srpaulo	/**
407281806Srpaulo	 * p2ps_instance - P2PS Application Service Info
408281806Srpaulo	 */
409281806Srpaulo	struct wpabuf *p2ps_instance;
410252190Srpaulo};
411252190Srpaulo
412252190Srpauloenum p2p_prov_disc_status {
413252190Srpaulo	P2P_PROV_DISC_SUCCESS,
414252190Srpaulo	P2P_PROV_DISC_TIMEOUT,
415252190Srpaulo	P2P_PROV_DISC_REJECTED,
416252190Srpaulo	P2P_PROV_DISC_TIMEOUT_JOIN,
417281806Srpaulo	P2P_PROV_DISC_INFO_UNAVAILABLE,
418252190Srpaulo};
419252190Srpaulo
420252190Srpaulostruct p2p_channel {
421252190Srpaulo	u8 op_class;
422252190Srpaulo	u8 chan;
423252190Srpaulo};
424252190Srpaulo
425252190Srpaulo/**
426252190Srpaulo * struct p2p_config - P2P configuration
427252190Srpaulo *
428252190Srpaulo * This configuration is provided to the P2P module during initialization with
429252190Srpaulo * p2p_init().
430252190Srpaulo */
431252190Srpaulostruct p2p_config {
432252190Srpaulo	/**
433252190Srpaulo	 * country - Country code to use in P2P operations
434252190Srpaulo	 */
435252190Srpaulo	char country[3];
436252190Srpaulo
437252190Srpaulo	/**
438252190Srpaulo	 * reg_class - Regulatory class for own listen channel
439252190Srpaulo	 */
440252190Srpaulo	u8 reg_class;
441252190Srpaulo
442252190Srpaulo	/**
443252190Srpaulo	 * channel - Own listen channel
444252190Srpaulo	 */
445252190Srpaulo	u8 channel;
446252190Srpaulo
447252190Srpaulo	/**
448281806Srpaulo	 * channel_forced - the listen channel was forced by configuration
449281806Srpaulo	 *                  or by control interface and cannot be overridden
450281806Srpaulo	 */
451281806Srpaulo	u8 channel_forced;
452281806Srpaulo
453281806Srpaulo	/**
454252190Srpaulo	 * Regulatory class for own operational channel
455252190Srpaulo	 */
456252190Srpaulo	u8 op_reg_class;
457252190Srpaulo
458252190Srpaulo	/**
459252190Srpaulo	 * op_channel - Own operational channel
460252190Srpaulo	 */
461252190Srpaulo	u8 op_channel;
462252190Srpaulo
463252190Srpaulo	/**
464252190Srpaulo	 * cfg_op_channel - Whether op_channel is hardcoded in configuration
465252190Srpaulo	 */
466252190Srpaulo	u8 cfg_op_channel;
467252190Srpaulo
468252190Srpaulo	/**
469252190Srpaulo	 * channels - Own supported regulatory classes and channels
470252190Srpaulo	 *
471252190Srpaulo	 * List of supposerted channels per regulatory class. The regulatory
472252190Srpaulo	 * classes are defined in IEEE Std 802.11-2007 Annex J and the
473252190Srpaulo	 * numbering of the clases depends on the configured country code.
474252190Srpaulo	 */
475252190Srpaulo	struct p2p_channels channels;
476252190Srpaulo
477252190Srpaulo	/**
478281806Srpaulo	 * cli_channels - Additional client channels
479281806Srpaulo	 *
480281806Srpaulo	 * This list of channels (if any) will be used when advertising local
481281806Srpaulo	 * channels during GO Negotiation or Invitation for the cases where the
482281806Srpaulo	 * local end may become the client. This may allow the peer to become a
483281806Srpaulo	 * GO on additional channels if it supports these options. The main use
484281806Srpaulo	 * case for this is to include passive-scan channels on devices that may
485281806Srpaulo	 * not know their current location and have configured most channels to
486281806Srpaulo	 * not allow initiation of radition (i.e., another device needs to take
487281806Srpaulo	 * master responsibilities).
488281806Srpaulo	 */
489281806Srpaulo	struct p2p_channels cli_channels;
490281806Srpaulo
491281806Srpaulo	/**
492252190Srpaulo	 * num_pref_chan - Number of pref_chan entries
493252190Srpaulo	 */
494252190Srpaulo	unsigned int num_pref_chan;
495252190Srpaulo
496252190Srpaulo	/**
497252190Srpaulo	 * pref_chan - Preferred channels for GO Negotiation
498252190Srpaulo	 */
499252190Srpaulo	struct p2p_channel *pref_chan;
500252190Srpaulo
501252190Srpaulo	/**
502252190Srpaulo	 * pri_dev_type - Primary Device Type (see WPS)
503252190Srpaulo	 */
504252190Srpaulo	u8 pri_dev_type[8];
505252190Srpaulo
506252190Srpaulo	/**
507252190Srpaulo	 * P2P_SEC_DEVICE_TYPES - Maximum number of secondary device types
508252190Srpaulo	 */
509252190Srpaulo#define P2P_SEC_DEVICE_TYPES 5
510252190Srpaulo
511252190Srpaulo	/**
512252190Srpaulo	 * sec_dev_type - Optional secondary device types
513252190Srpaulo	 */
514252190Srpaulo	u8 sec_dev_type[P2P_SEC_DEVICE_TYPES][8];
515252190Srpaulo
516252190Srpaulo	/**
517252190Srpaulo	 * num_sec_dev_types - Number of sec_dev_type entries
518252190Srpaulo	 */
519252190Srpaulo	size_t num_sec_dev_types;
520252190Srpaulo
521252190Srpaulo	/**
522252190Srpaulo	 * dev_addr - P2P Device Address
523252190Srpaulo	 */
524252190Srpaulo	u8 dev_addr[ETH_ALEN];
525252190Srpaulo
526252190Srpaulo	/**
527252190Srpaulo	 * dev_name - Device Name
528252190Srpaulo	 */
529252190Srpaulo	char *dev_name;
530252190Srpaulo
531252190Srpaulo	char *manufacturer;
532252190Srpaulo	char *model_name;
533252190Srpaulo	char *model_number;
534252190Srpaulo	char *serial_number;
535252190Srpaulo
536252190Srpaulo	u8 uuid[16];
537252190Srpaulo	u16 config_methods;
538252190Srpaulo
539252190Srpaulo	/**
540252190Srpaulo	 * concurrent_operations - Whether concurrent operations are supported
541252190Srpaulo	 */
542252190Srpaulo	int concurrent_operations;
543252190Srpaulo
544252190Srpaulo	/**
545252190Srpaulo	 * max_peers - Maximum number of discovered peers to remember
546252190Srpaulo	 *
547252190Srpaulo	 * If more peers are discovered, older entries will be removed to make
548252190Srpaulo	 * room for the new ones.
549252190Srpaulo	 */
550252190Srpaulo	size_t max_peers;
551252190Srpaulo
552252190Srpaulo	/**
553252190Srpaulo	 * p2p_intra_bss - Intra BSS communication is supported
554252190Srpaulo	 */
555252190Srpaulo	int p2p_intra_bss;
556252190Srpaulo
557252190Srpaulo	/**
558252190Srpaulo	 * ssid_postfix - Postfix data to add to the SSID
559252190Srpaulo	 *
560252190Srpaulo	 * This data will be added to the end of the SSID after the
561252190Srpaulo	 * DIRECT-<random two octets> prefix.
562252190Srpaulo	 */
563289549Srpaulo	u8 ssid_postfix[SSID_MAX_LEN - 9];
564252190Srpaulo
565252190Srpaulo	/**
566252190Srpaulo	 * ssid_postfix_len - Length of the ssid_postfix data
567252190Srpaulo	 */
568252190Srpaulo	size_t ssid_postfix_len;
569252190Srpaulo
570252190Srpaulo	/**
571252190Srpaulo	 * max_listen - Maximum listen duration in ms
572252190Srpaulo	 */
573252190Srpaulo	unsigned int max_listen;
574252190Srpaulo
575252190Srpaulo	/**
576281806Srpaulo	 * passphrase_len - Passphrase length (8..63)
577281806Srpaulo	 *
578281806Srpaulo	 * This parameter controls the length of the random passphrase that is
579281806Srpaulo	 * generated at the GO.
580252190Srpaulo	 */
581281806Srpaulo	unsigned int passphrase_len;
582252190Srpaulo
583252190Srpaulo	/**
584252190Srpaulo	 * cb_ctx - Context to use with callback functions
585252190Srpaulo	 */
586252190Srpaulo	void *cb_ctx;
587252190Srpaulo
588281806Srpaulo	/**
589281806Srpaulo	 * debug_print - Debug print
590281806Srpaulo	 * @ctx: Callback context from cb_ctx
591281806Srpaulo	 * @level: Debug verbosity level (MSG_*)
592281806Srpaulo	 * @msg: Debug message
593281806Srpaulo	 */
594281806Srpaulo	void (*debug_print)(void *ctx, int level, const char *msg);
595252190Srpaulo
596281806Srpaulo
597252190Srpaulo	/* Callbacks to request lower layer driver operations */
598252190Srpaulo
599252190Srpaulo	/**
600252190Srpaulo	 * p2p_scan - Request a P2P scan/search
601252190Srpaulo	 * @ctx: Callback context from cb_ctx
602252190Srpaulo	 * @type: Scan type
603252190Srpaulo	 * @freq: Specific frequency (MHz) to scan or 0 for no restriction
604252190Srpaulo	 * @num_req_dev_types: Number of requested device types
605252190Srpaulo	 * @req_dev_types: Array containing requested device types
606252190Srpaulo	 * @dev_id: Device ID to search for or %NULL to find all devices
607252190Srpaulo	 * @pw_id: Device Password ID
608252190Srpaulo	 * Returns: 0 on success, -1 on failure
609252190Srpaulo	 *
610252190Srpaulo	 * This callback function is used to request a P2P scan or search
611252190Srpaulo	 * operation to be completed. Type type argument specifies which type
612252190Srpaulo	 * of scan is to be done. @P2P_SCAN_SOCIAL indicates that only the
613252190Srpaulo	 * social channels (1, 6, 11) should be scanned. @P2P_SCAN_FULL
614281806Srpaulo	 * indicates that all channels are to be scanned. @P2P_SCAN_SPECIFIC
615281806Srpaulo	 * request a scan of a single channel specified by freq.
616252190Srpaulo	 * @P2P_SCAN_SOCIAL_PLUS_ONE request scan of all the social channels
617252190Srpaulo	 * plus one extra channel specified by freq.
618252190Srpaulo	 *
619252190Srpaulo	 * The full scan is used for the initial scan to find group owners from
620252190Srpaulo	 * all. The other types are used during search phase scan of the social
621252190Srpaulo	 * channels (with potential variation if the Listen channel of the
622252190Srpaulo	 * target peer is known or if other channels are scanned in steps).
623252190Srpaulo	 *
624252190Srpaulo	 * The scan results are returned after this call by calling
625252190Srpaulo	 * p2p_scan_res_handler() for each scan result that has a P2P IE and
626252190Srpaulo	 * then calling p2p_scan_res_handled() to indicate that all scan
627252190Srpaulo	 * results have been indicated.
628252190Srpaulo	 */
629252190Srpaulo	int (*p2p_scan)(void *ctx, enum p2p_scan_type type, int freq,
630252190Srpaulo			unsigned int num_req_dev_types,
631252190Srpaulo			const u8 *req_dev_types, const u8 *dev_id, u16 pw_id);
632252190Srpaulo
633252190Srpaulo	/**
634252190Srpaulo	 * send_probe_resp - Transmit a Probe Response frame
635252190Srpaulo	 * @ctx: Callback context from cb_ctx
636252190Srpaulo	 * @buf: Probe Response frame (including the header and body)
637289549Srpaulo	 * @freq: Forced frequency (in MHz) to use or 0.
638252190Srpaulo	 * Returns: 0 on success, -1 on failure
639252190Srpaulo	 *
640252190Srpaulo	 * This function is used to reply to Probe Request frames that were
641252190Srpaulo	 * indicated with a call to p2p_probe_req_rx(). The response is to be
642289549Srpaulo	 * sent on the same channel, unless otherwise specified, or to be
643289549Srpaulo	 * dropped if the driver is not listening to Probe Request frames
644289549Srpaulo	 * anymore.
645252190Srpaulo	 *
646252190Srpaulo	 * Alternatively, the responsibility for building the Probe Response
647252190Srpaulo	 * frames in Listen state may be in another system component in which
648252190Srpaulo	 * case this function need to be implemented (i.e., the function
649252190Srpaulo	 * pointer can be %NULL). The WPS and P2P IEs to be added for Probe
650252190Srpaulo	 * Response frames in such a case are available from the
651252190Srpaulo	 * start_listen() callback. It should be noted that the received Probe
652252190Srpaulo	 * Request frames must be indicated by calling p2p_probe_req_rx() even
653252190Srpaulo	 * if this send_probe_resp() is not used.
654252190Srpaulo	 */
655289549Srpaulo	int (*send_probe_resp)(void *ctx, const struct wpabuf *buf,
656289549Srpaulo			       unsigned int freq);
657252190Srpaulo
658252190Srpaulo	/**
659252190Srpaulo	 * send_action - Transmit an Action frame
660252190Srpaulo	 * @ctx: Callback context from cb_ctx
661252190Srpaulo	 * @freq: Frequency in MHz for the channel on which to transmit
662252190Srpaulo	 * @dst: Destination MAC address (Address 1)
663252190Srpaulo	 * @src: Source MAC address (Address 2)
664252190Srpaulo	 * @bssid: BSSID (Address 3)
665252190Srpaulo	 * @buf: Frame body (starting from Category field)
666252190Srpaulo	 * @len: Length of buf in octets
667252190Srpaulo	 * @wait_time: How many msec to wait for a response frame
668346981Scy	 * @scheduled: Return value indicating whether the transmissions was
669346981Scy	 *	scheduled to happen once the radio is available
670252190Srpaulo	 * Returns: 0 on success, -1 on failure
671252190Srpaulo	 *
672252190Srpaulo	 * The Action frame may not be transmitted immediately and the status
673252190Srpaulo	 * of the transmission must be reported by calling
674252190Srpaulo	 * p2p_send_action_cb() once the frame has either been transmitted or
675252190Srpaulo	 * it has been dropped due to excessive retries or other failure to
676252190Srpaulo	 * transmit.
677252190Srpaulo	 */
678252190Srpaulo	int (*send_action)(void *ctx, unsigned int freq, const u8 *dst,
679252190Srpaulo			   const u8 *src, const u8 *bssid, const u8 *buf,
680346981Scy			   size_t len, unsigned int wait_time, int *scheduled);
681252190Srpaulo
682252190Srpaulo	/**
683252190Srpaulo	 * send_action_done - Notify that Action frame sequence was completed
684252190Srpaulo	 * @ctx: Callback context from cb_ctx
685252190Srpaulo	 *
686252190Srpaulo	 * This function is called when the Action frame sequence that was
687252190Srpaulo	 * started with send_action() has been completed, i.e., when there is
688252190Srpaulo	 * no need to wait for a response from the destination peer anymore.
689252190Srpaulo	 */
690252190Srpaulo	void (*send_action_done)(void *ctx);
691252190Srpaulo
692252190Srpaulo	/**
693252190Srpaulo	 * start_listen - Start Listen state
694252190Srpaulo	 * @ctx: Callback context from cb_ctx
695252190Srpaulo	 * @freq: Frequency of the listen channel in MHz
696252190Srpaulo	 * @duration: Duration for the Listen state in milliseconds
697252190Srpaulo	 * @probe_resp_ie: IE(s) to be added to Probe Response frames
698252190Srpaulo	 * Returns: 0 on success, -1 on failure
699252190Srpaulo	 *
700252190Srpaulo	 * This Listen state may not start immediately since the driver may
701252190Srpaulo	 * have other pending operations to complete first. Once the Listen
702252190Srpaulo	 * state has started, p2p_listen_cb() must be called to notify the P2P
703252190Srpaulo	 * module. Once the Listen state is stopped, p2p_listen_end() must be
704252190Srpaulo	 * called to notify the P2P module that the driver is not in the Listen
705252190Srpaulo	 * state anymore.
706252190Srpaulo	 *
707252190Srpaulo	 * If the send_probe_resp() is not used for generating the response,
708252190Srpaulo	 * the IEs from probe_resp_ie need to be added to the end of the Probe
709252190Srpaulo	 * Response frame body. If send_probe_resp() is used, the probe_resp_ie
710252190Srpaulo	 * information can be ignored.
711252190Srpaulo	 */
712252190Srpaulo	int (*start_listen)(void *ctx, unsigned int freq,
713252190Srpaulo			    unsigned int duration,
714252190Srpaulo			    const struct wpabuf *probe_resp_ie);
715252190Srpaulo	/**
716252190Srpaulo	 * stop_listen - Stop Listen state
717252190Srpaulo	 * @ctx: Callback context from cb_ctx
718252190Srpaulo	 *
719252190Srpaulo	 * This callback can be used to stop a Listen state operation that was
720252190Srpaulo	 * previously requested with start_listen().
721252190Srpaulo	 */
722252190Srpaulo	void (*stop_listen)(void *ctx);
723252190Srpaulo
724252190Srpaulo	/**
725252190Srpaulo	 * get_noa - Get current Notice of Absence attribute payload
726252190Srpaulo	 * @ctx: Callback context from cb_ctx
727252190Srpaulo	 * @interface_addr: P2P Interface Address of the GO
728252190Srpaulo	 * @buf: Buffer for returning NoA
729252190Srpaulo	 * @buf_len: Buffer length in octets
730252190Srpaulo	 * Returns: Number of octets used in buf, 0 to indicate no NoA is being
731252190Srpaulo	 * advertized, or -1 on failure
732252190Srpaulo	 *
733252190Srpaulo	 * This function is used to fetch the current Notice of Absence
734252190Srpaulo	 * attribute value from GO.
735252190Srpaulo	 */
736252190Srpaulo	int (*get_noa)(void *ctx, const u8 *interface_addr, u8 *buf,
737252190Srpaulo		       size_t buf_len);
738252190Srpaulo
739252190Srpaulo	/* Callbacks to notify events to upper layer management entity */
740252190Srpaulo
741252190Srpaulo	/**
742252190Srpaulo	 * dev_found - Notification of a found P2P Device
743252190Srpaulo	 * @ctx: Callback context from cb_ctx
744252190Srpaulo	 * @addr: Source address of the message triggering this notification
745252190Srpaulo	 * @info: P2P peer information
746252190Srpaulo	 * @new_device: Inform if the peer is newly found
747252190Srpaulo	 *
748252190Srpaulo	 * This callback is used to notify that a new P2P Device has been
749252190Srpaulo	 * found. This may happen, e.g., during Search state based on scan
750252190Srpaulo	 * results or during Listen state based on receive Probe Request and
751252190Srpaulo	 * Group Owner Negotiation Request.
752252190Srpaulo	 */
753252190Srpaulo	void (*dev_found)(void *ctx, const u8 *addr,
754252190Srpaulo			  const struct p2p_peer_info *info,
755252190Srpaulo			  int new_device);
756252190Srpaulo
757252190Srpaulo	/**
758252190Srpaulo	 * dev_lost - Notification of a lost P2P Device
759252190Srpaulo	 * @ctx: Callback context from cb_ctx
760252190Srpaulo	 * @dev_addr: P2P Device Address of the lost P2P Device
761252190Srpaulo	 *
762252190Srpaulo	 * This callback is used to notify that a P2P Device has been deleted.
763252190Srpaulo	 */
764252190Srpaulo	void (*dev_lost)(void *ctx, const u8 *dev_addr);
765252190Srpaulo
766252190Srpaulo	/**
767281806Srpaulo	 * find_stopped - Notification of a p2p_find operation stopping
768281806Srpaulo	 * @ctx: Callback context from cb_ctx
769281806Srpaulo	 */
770281806Srpaulo	void (*find_stopped)(void *ctx);
771281806Srpaulo
772281806Srpaulo	/**
773252190Srpaulo	 * go_neg_req_rx - Notification of a receive GO Negotiation Request
774252190Srpaulo	 * @ctx: Callback context from cb_ctx
775252190Srpaulo	 * @src: Source address of the message triggering this notification
776252190Srpaulo	 * @dev_passwd_id: WPS Device Password ID
777289549Srpaulo	 * @go_intent: Peer's GO Intent
778252190Srpaulo	 *
779252190Srpaulo	 * This callback is used to notify that a P2P Device is requesting
780252190Srpaulo	 * group owner negotiation with us, but we do not have all the
781252190Srpaulo	 * necessary information to start GO Negotiation. This indicates that
782252190Srpaulo	 * the local user has not authorized the connection yet by providing a
783252190Srpaulo	 * PIN or PBC button press. This information can be provided with a
784252190Srpaulo	 * call to p2p_connect().
785252190Srpaulo	 */
786289549Srpaulo	void (*go_neg_req_rx)(void *ctx, const u8 *src, u16 dev_passwd_id,
787289549Srpaulo			      u8 go_intent);
788252190Srpaulo
789252190Srpaulo	/**
790252190Srpaulo	 * go_neg_completed - Notification of GO Negotiation results
791252190Srpaulo	 * @ctx: Callback context from cb_ctx
792252190Srpaulo	 * @res: GO Negotiation results
793252190Srpaulo	 *
794252190Srpaulo	 * This callback is used to notify that Group Owner Negotiation has
795252190Srpaulo	 * been completed. Non-zero struct p2p_go_neg_results::status indicates
796252190Srpaulo	 * failed negotiation. In case of success, this function is responsible
797252190Srpaulo	 * for creating a new group interface (or using the existing interface
798252190Srpaulo	 * depending on driver features), setting up the group interface in
799252190Srpaulo	 * proper mode based on struct p2p_go_neg_results::role_go and
800252190Srpaulo	 * initializing WPS provisioning either as a Registrar (if GO) or as an
801252190Srpaulo	 * Enrollee. Successful WPS provisioning must be indicated by calling
802252190Srpaulo	 * p2p_wps_success_cb(). The callee is responsible for timing out group
803252190Srpaulo	 * formation if WPS provisioning cannot be completed successfully
804252190Srpaulo	 * within 15 seconds.
805252190Srpaulo	 */
806252190Srpaulo	void (*go_neg_completed)(void *ctx, struct p2p_go_neg_results *res);
807252190Srpaulo
808252190Srpaulo	/**
809252190Srpaulo	 * sd_request - Callback on Service Discovery Request
810252190Srpaulo	 * @ctx: Callback context from cb_ctx
811252190Srpaulo	 * @freq: Frequency (in MHz) of the channel
812252190Srpaulo	 * @sa: Source address of the request
813252190Srpaulo	 * @dialog_token: Dialog token
814252190Srpaulo	 * @update_indic: Service Update Indicator from the source of request
815252190Srpaulo	 * @tlvs: P2P Service Request TLV(s)
816252190Srpaulo	 * @tlvs_len: Length of tlvs buffer in octets
817252190Srpaulo	 *
818252190Srpaulo	 * This callback is used to indicate reception of a service discovery
819252190Srpaulo	 * request. Response to the query must be indicated by calling
820252190Srpaulo	 * p2p_sd_response() with the context information from the arguments to
821252190Srpaulo	 * this callback function.
822252190Srpaulo	 *
823252190Srpaulo	 * This callback handler can be set to %NULL to indicate that service
824252190Srpaulo	 * discovery is not supported.
825252190Srpaulo	 */
826252190Srpaulo	void (*sd_request)(void *ctx, int freq, const u8 *sa, u8 dialog_token,
827252190Srpaulo			   u16 update_indic, const u8 *tlvs, size_t tlvs_len);
828252190Srpaulo
829252190Srpaulo	/**
830252190Srpaulo	 * sd_response - Callback on Service Discovery Response
831252190Srpaulo	 * @ctx: Callback context from cb_ctx
832252190Srpaulo	 * @sa: Source address of the request
833252190Srpaulo	 * @update_indic: Service Update Indicator from the source of response
834252190Srpaulo	 * @tlvs: P2P Service Response TLV(s)
835252190Srpaulo	 * @tlvs_len: Length of tlvs buffer in octets
836252190Srpaulo	 *
837252190Srpaulo	 * This callback is used to indicate reception of a service discovery
838252190Srpaulo	 * response. This callback handler can be set to %NULL if no service
839252190Srpaulo	 * discovery requests are used. The information provided with this call
840252190Srpaulo	 * is replies to the queries scheduled with p2p_sd_request().
841252190Srpaulo	 */
842252190Srpaulo	void (*sd_response)(void *ctx, const u8 *sa, u16 update_indic,
843252190Srpaulo			    const u8 *tlvs, size_t tlvs_len);
844252190Srpaulo
845252190Srpaulo	/**
846252190Srpaulo	 * prov_disc_req - Callback on Provisiong Discovery Request
847252190Srpaulo	 * @ctx: Callback context from cb_ctx
848252190Srpaulo	 * @peer: Source address of the request
849252190Srpaulo	 * @config_methods: Requested WPS Config Method
850252190Srpaulo	 * @dev_addr: P2P Device Address of the found P2P Device
851252190Srpaulo	 * @pri_dev_type: Primary Device Type
852252190Srpaulo	 * @dev_name: Device Name
853252190Srpaulo	 * @supp_config_methods: Supported configuration Methods
854252190Srpaulo	 * @dev_capab: Device Capabilities
855252190Srpaulo	 * @group_capab: Group Capabilities
856252190Srpaulo	 * @group_id: P2P Group ID (or %NULL if not included)
857252190Srpaulo	 * @group_id_len: Length of P2P Group ID
858252190Srpaulo	 *
859252190Srpaulo	 * This callback is used to indicate reception of a Provision Discovery
860252190Srpaulo	 * Request frame that the P2P module accepted.
861252190Srpaulo	 */
862252190Srpaulo	void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods,
863252190Srpaulo			      const u8 *dev_addr, const u8 *pri_dev_type,
864252190Srpaulo			      const char *dev_name, u16 supp_config_methods,
865252190Srpaulo			      u8 dev_capab, u8 group_capab,
866252190Srpaulo			      const u8 *group_id, size_t group_id_len);
867252190Srpaulo
868252190Srpaulo	/**
869252190Srpaulo	 * prov_disc_resp - Callback on Provisiong Discovery Response
870252190Srpaulo	 * @ctx: Callback context from cb_ctx
871252190Srpaulo	 * @peer: Source address of the response
872252190Srpaulo	 * @config_methods: Value from p2p_prov_disc_req() or 0 on failure
873252190Srpaulo	 *
874252190Srpaulo	 * This callback is used to indicate reception of a Provision Discovery
875252190Srpaulo	 * Response frame for a pending request scheduled with
876252190Srpaulo	 * p2p_prov_disc_req(). This callback handler can be set to %NULL if
877252190Srpaulo	 * provision discovery is not used.
878252190Srpaulo	 */
879252190Srpaulo	void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods);
880252190Srpaulo
881252190Srpaulo	/**
882252190Srpaulo	 * prov_disc_fail - Callback on Provision Discovery failure
883252190Srpaulo	 * @ctx: Callback context from cb_ctx
884252190Srpaulo	 * @peer: Source address of the response
885252190Srpaulo	 * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS
886281806Srpaulo	 * @adv_id: If non-zero, then the adv_id of the PD Request
887281806Srpaulo	 * @adv_mac: P2P Device Address of the advertizer
888281806Srpaulo	 * @deferred_session_resp: Deferred session response sent by advertizer
889252190Srpaulo	 *
890252190Srpaulo	 * This callback is used to indicate either a failure or no response
891252190Srpaulo	 * to an earlier provision discovery request.
892252190Srpaulo	 *
893252190Srpaulo	 * This callback handler can be set to %NULL if provision discovery
894252190Srpaulo	 * is not used or failures do not need to be indicated.
895252190Srpaulo	 */
896252190Srpaulo	void (*prov_disc_fail)(void *ctx, const u8 *peer,
897281806Srpaulo			       enum p2p_prov_disc_status status,
898281806Srpaulo			       u32 adv_id, const u8 *adv_mac,
899281806Srpaulo			       const char *deferred_session_resp);
900252190Srpaulo
901252190Srpaulo	/**
902252190Srpaulo	 * invitation_process - Optional callback for processing Invitations
903252190Srpaulo	 * @ctx: Callback context from cb_ctx
904252190Srpaulo	 * @sa: Source address of the Invitation Request
905252190Srpaulo	 * @bssid: P2P Group BSSID from the request or %NULL if not included
906252190Srpaulo	 * @go_dev_addr: GO Device Address from P2P Group ID
907252190Srpaulo	 * @ssid: SSID from P2P Group ID
908252190Srpaulo	 * @ssid_len: Length of ssid buffer in octets
909252190Srpaulo	 * @go: Variable for returning whether the local end is GO in the group
910252190Srpaulo	 * @group_bssid: Buffer for returning P2P Group BSSID (if local end GO)
911252190Srpaulo	 * @force_freq: Variable for returning forced frequency for the group
912252190Srpaulo	 * @persistent_group: Whether this is an invitation to reinvoke a
913252190Srpaulo	 *	persistent group (instead of invitation to join an active
914252190Srpaulo	 *	group)
915281806Srpaulo	 * @channels: Available operating channels for the group
916281806Srpaulo	 * @dev_pw_id: Device Password ID for NFC static handover or -1 if not
917281806Srpaulo	 *	used
918252190Srpaulo	 * Returns: Status code (P2P_SC_*)
919252190Srpaulo	 *
920252190Srpaulo	 * This optional callback can be used to implement persistent reconnect
921252190Srpaulo	 * by allowing automatic restarting of persistent groups without user
922252190Srpaulo	 * interaction. If this callback is not implemented (i.e., is %NULL),
923252190Srpaulo	 * the received Invitation Request frames are replied with
924252190Srpaulo	 * %P2P_SC_REQ_RECEIVED status and indicated to upper layer with the
925252190Srpaulo	 * invitation_result() callback.
926252190Srpaulo	 *
927252190Srpaulo	 * If the requested parameters are acceptable and the group is known,
928252190Srpaulo	 * %P2P_SC_SUCCESS may be returned. If the requested group is unknown,
929252190Srpaulo	 * %P2P_SC_FAIL_UNKNOWN_GROUP should be returned. %P2P_SC_REQ_RECEIVED
930252190Srpaulo	 * can be returned if there is not enough data to provide immediate
931252190Srpaulo	 * response, i.e., if some sort of user interaction is needed. The
932252190Srpaulo	 * invitation_received() callback will be called in that case
933252190Srpaulo	 * immediately after this call.
934252190Srpaulo	 */
935252190Srpaulo	u8 (*invitation_process)(void *ctx, const u8 *sa, const u8 *bssid,
936252190Srpaulo				 const u8 *go_dev_addr, const u8 *ssid,
937252190Srpaulo				 size_t ssid_len, int *go, u8 *group_bssid,
938281806Srpaulo				 int *force_freq, int persistent_group,
939281806Srpaulo				 const struct p2p_channels *channels,
940281806Srpaulo				 int dev_pw_id);
941252190Srpaulo
942252190Srpaulo	/**
943252190Srpaulo	 * invitation_received - Callback on Invitation Request RX
944252190Srpaulo	 * @ctx: Callback context from cb_ctx
945252190Srpaulo	 * @sa: Source address of the Invitation Request
946252190Srpaulo	 * @bssid: P2P Group BSSID or %NULL if not received
947252190Srpaulo	 * @ssid: SSID of the group
948252190Srpaulo	 * @ssid_len: Length of ssid in octets
949252190Srpaulo	 * @go_dev_addr: GO Device Address
950252190Srpaulo	 * @status: Response Status
951252190Srpaulo	 * @op_freq: Operational frequency for the group
952252190Srpaulo	 *
953252190Srpaulo	 * This callback is used to indicate sending of an Invitation Response
954252190Srpaulo	 * for a received Invitation Request. If status == 0 (success), the
955252190Srpaulo	 * upper layer code is responsible for starting the group. status == 1
956252190Srpaulo	 * indicates need to get user authorization for the group. Other status
957252190Srpaulo	 * values indicate that the invitation request was rejected.
958252190Srpaulo	 */
959252190Srpaulo	void (*invitation_received)(void *ctx, const u8 *sa, const u8 *bssid,
960252190Srpaulo				    const u8 *ssid, size_t ssid_len,
961252190Srpaulo				    const u8 *go_dev_addr, u8 status,
962252190Srpaulo				    int op_freq);
963252190Srpaulo
964252190Srpaulo	/**
965252190Srpaulo	 * invitation_result - Callback on Invitation result
966252190Srpaulo	 * @ctx: Callback context from cb_ctx
967252190Srpaulo	 * @status: Negotiation result (Status Code)
968252190Srpaulo	 * @bssid: P2P Group BSSID or %NULL if not received
969281806Srpaulo	 * @channels: Available operating channels for the group
970281806Srpaulo	 * @addr: Peer address
971281806Srpaulo	 * @freq: Frequency (in MHz) indicated during invitation or 0
972281806Srpaulo	 * @peer_oper_freq: Operating frequency (in MHz) advertized by the peer
973281806Srpaulo	 * during invitation or 0
974252190Srpaulo	 *
975252190Srpaulo	 * This callback is used to indicate result of an Invitation procedure
976252190Srpaulo	 * started with a call to p2p_invite(). The indicated status code is
977252190Srpaulo	 * the value received from the peer in Invitation Response with 0
978252190Srpaulo	 * (P2P_SC_SUCCESS) indicating success or -1 to indicate a timeout or a
979252190Srpaulo	 * local failure in transmitting the Invitation Request.
980252190Srpaulo	 */
981281806Srpaulo	void (*invitation_result)(void *ctx, int status, const u8 *bssid,
982281806Srpaulo				  const struct p2p_channels *channels,
983281806Srpaulo				  const u8 *addr, int freq, int peer_oper_freq);
984252190Srpaulo
985252190Srpaulo	/**
986252190Srpaulo	 * go_connected - Check whether we are connected to a GO
987252190Srpaulo	 * @ctx: Callback context from cb_ctx
988252190Srpaulo	 * @dev_addr: P2P Device Address of a GO
989252190Srpaulo	 * Returns: 1 if we are connected as a P2P client to the specified GO
990252190Srpaulo	 * or 0 if not.
991252190Srpaulo	 */
992252190Srpaulo	int (*go_connected)(void *ctx, const u8 *dev_addr);
993281806Srpaulo
994281806Srpaulo	/**
995281806Srpaulo	 * presence_resp - Callback on Presence Response
996281806Srpaulo	 * @ctx: Callback context from cb_ctx
997281806Srpaulo	 * @src: Source address (GO's P2P Interface Address)
998281806Srpaulo	 * @status: Result of the request (P2P_SC_*)
999281806Srpaulo	 * @noa: Returned NoA value
1000281806Srpaulo	 * @noa_len: Length of the NoA buffer in octets
1001281806Srpaulo	 */
1002281806Srpaulo	void (*presence_resp)(void *ctx, const u8 *src, u8 status,
1003281806Srpaulo			      const u8 *noa, size_t noa_len);
1004281806Srpaulo
1005281806Srpaulo	/**
1006281806Srpaulo	 * is_concurrent_session_active - Check whether concurrent session is
1007281806Srpaulo	 * active on other virtual interfaces
1008281806Srpaulo	 * @ctx: Callback context from cb_ctx
1009281806Srpaulo	 * Returns: 1 if concurrent session is active on other virtual interface
1010281806Srpaulo	 * or 0 if not.
1011281806Srpaulo	 */
1012281806Srpaulo	int (*is_concurrent_session_active)(void *ctx);
1013281806Srpaulo
1014281806Srpaulo	/**
1015281806Srpaulo	 * is_p2p_in_progress - Check whether P2P operation is in progress
1016281806Srpaulo	 * @ctx: Callback context from cb_ctx
1017281806Srpaulo	 * Returns: 1 if P2P operation (e.g., group formation) is in progress
1018281806Srpaulo	 * or 0 if not.
1019281806Srpaulo	 */
1020281806Srpaulo	int (*is_p2p_in_progress)(void *ctx);
1021281806Srpaulo
1022281806Srpaulo	/**
1023281806Srpaulo	 * Determine if we have a persistent group we share with remote peer
1024289549Srpaulo	 * and allocate interface for this group if needed
1025281806Srpaulo	 * @ctx: Callback context from cb_ctx
1026281806Srpaulo	 * @addr: Peer device address to search for
1027281806Srpaulo	 * @ssid: Persistent group SSID or %NULL if any
1028281806Srpaulo	 * @ssid_len: Length of @ssid
1029289549Srpaulo	 * @go_dev_addr: Buffer for returning GO P2P Device Address
1030281806Srpaulo	 * @ret_ssid: Buffer for returning group SSID
1031281806Srpaulo	 * @ret_ssid_len: Buffer for returning length of @ssid
1032289549Srpaulo	 * @intended_iface_addr: Buffer for returning intended iface address
1033281806Srpaulo	 * Returns: 1 if a matching persistent group was found, 0 otherwise
1034281806Srpaulo	 */
1035281806Srpaulo	int (*get_persistent_group)(void *ctx, const u8 *addr, const u8 *ssid,
1036281806Srpaulo				    size_t ssid_len, u8 *go_dev_addr,
1037289549Srpaulo				    u8 *ret_ssid, size_t *ret_ssid_len,
1038289549Srpaulo				    u8 *intended_iface_addr);
1039281806Srpaulo
1040281806Srpaulo	/**
1041281806Srpaulo	 * Get information about a possible local GO role
1042281806Srpaulo	 * @ctx: Callback context from cb_ctx
1043281806Srpaulo	 * @intended_addr: Buffer for returning intended GO interface address
1044281806Srpaulo	 * @ssid: Buffer for returning group SSID
1045281806Srpaulo	 * @ssid_len: Buffer for returning length of @ssid
1046281806Srpaulo	 * @group_iface: Buffer for returning whether a separate group interface
1047281806Srpaulo	 *	would be used
1048337817Scy	 * @freq: Variable for returning the current operating frequency of a
1049337817Scy	 *	currently running P2P GO.
1050281806Srpaulo	 * Returns: 1 if GO info found, 0 otherwise
1051281806Srpaulo	 *
1052281806Srpaulo	 * This is used to compose New Group settings (SSID, and intended
1053281806Srpaulo	 * address) during P2PS provisioning if results of provisioning *might*
1054281806Srpaulo	 * result in our being an autonomous GO.
1055281806Srpaulo	 */
1056281806Srpaulo	int (*get_go_info)(void *ctx, u8 *intended_addr,
1057337817Scy			   u8 *ssid, size_t *ssid_len, int *group_iface,
1058337817Scy			   unsigned int *freq);
1059281806Srpaulo
1060281806Srpaulo	/**
1061281806Srpaulo	 * remove_stale_groups - Remove stale P2PS groups
1062281806Srpaulo	 *
1063281806Srpaulo	 * Because P2PS stages *potential* GOs, and remote devices can remove
1064281806Srpaulo	 * credentials unilaterally, we need to make sure we don't let stale
1065281806Srpaulo	 * unusable groups build up.
1066281806Srpaulo	 */
1067281806Srpaulo	int (*remove_stale_groups)(void *ctx, const u8 *peer, const u8 *go,
1068281806Srpaulo				   const u8 *ssid, size_t ssid_len);
1069281806Srpaulo
1070281806Srpaulo	/**
1071281806Srpaulo	 * p2ps_prov_complete - P2PS provisioning complete
1072281806Srpaulo	 *
1073281806Srpaulo	 * When P2PS provisioning completes (successfully or not) we must
1074281806Srpaulo	 * transmit all of the results to the upper layers.
1075281806Srpaulo	 */
1076281806Srpaulo	void (*p2ps_prov_complete)(void *ctx, u8 status, const u8 *dev,
1077281806Srpaulo				   const u8 *adv_mac, const u8 *ses_mac,
1078281806Srpaulo				   const u8 *grp_mac, u32 adv_id, u32 ses_id,
1079281806Srpaulo				   u8 conncap, int passwd_id,
1080281806Srpaulo				   const u8 *persist_ssid,
1081281806Srpaulo				   size_t persist_ssid_size, int response_done,
1082289549Srpaulo				   int prov_start, const char *session_info,
1083337817Scy				   const u8 *feat_cap, size_t feat_cap_len,
1084337817Scy				   unsigned int freq, const u8 *group_ssid,
1085337817Scy				   size_t group_ssid_len);
1086281806Srpaulo
1087281806Srpaulo	/**
1088281806Srpaulo	 * prov_disc_resp_cb - Callback for indicating completion of PD Response
1089281806Srpaulo	 * @ctx: Callback context from cb_ctx
1090281806Srpaulo	 * Returns: 1 if operation was started, 0 otherwise
1091281806Srpaulo	 *
1092281806Srpaulo	 * This callback can be used to perform any pending actions after
1093281806Srpaulo	 * provisioning. It is mainly used for P2PS pending group creation.
1094281806Srpaulo	 */
1095281806Srpaulo	int (*prov_disc_resp_cb)(void *ctx);
1096281806Srpaulo
1097281806Srpaulo	/**
1098281806Srpaulo	 * p2ps_group_capability - Determine group capability
1099337817Scy	 * @ctx: Callback context from cb_ctx
1100337817Scy	 * @incoming: Peer requested roles, expressed with P2PS_SETUP_* bitmap.
1101337817Scy	 * @role: Local roles, expressed with P2PS_SETUP_* bitmap.
1102337817Scy	 * @force_freq: Variable for returning forced frequency for the group.
1103337817Scy	 * @pref_freq: Variable for returning preferred frequency for the group.
1104337817Scy	 * Returns: P2PS_SETUP_* bitmap of group capability result.
1105281806Srpaulo	 *
1106337817Scy	 * This function can be used to determine group capability and
1107337817Scy	 * frequencies based on information from P2PS PD exchange and the
1108337817Scy	 * current state of ongoing groups and driver capabilities.
1109281806Srpaulo	 */
1110337817Scy	u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role,
1111337817Scy				    unsigned int *force_freq,
1112337817Scy				    unsigned int *pref_freq);
1113289549Srpaulo
1114289549Srpaulo	/**
1115289549Srpaulo	 * get_pref_freq_list - Get preferred frequency list for an interface
1116289549Srpaulo	 * @ctx: Callback context from cb_ctx
1117289549Srpaulo	 * @go: Whether the use if for GO role
1118289549Srpaulo	 * @len: Length of freq_list in entries (both IN and OUT)
1119289549Srpaulo	 * @freq_list: Buffer for returning the preferred frequencies (MHz)
1120289549Srpaulo	 * Returns: 0 on success, -1 on failure
1121289549Srpaulo	 *
1122289549Srpaulo	 * This function can be used to query the preferred frequency list from
1123289549Srpaulo	 * the driver specific to a particular interface type.
1124289549Srpaulo	 */
1125289549Srpaulo	int (*get_pref_freq_list)(void *ctx, int go,
1126289549Srpaulo				  unsigned int *len, unsigned int *freq_list);
1127252190Srpaulo};
1128252190Srpaulo
1129252190Srpaulo
1130252190Srpaulo/* P2P module initialization/deinitialization */
1131252190Srpaulo
1132252190Srpaulo/**
1133252190Srpaulo * p2p_init - Initialize P2P module
1134252190Srpaulo * @cfg: P2P module configuration
1135252190Srpaulo * Returns: Pointer to private data or %NULL on failure
1136252190Srpaulo *
1137252190Srpaulo * This function is used to initialize global P2P module context (one per
1138252190Srpaulo * device). The P2P module will keep a copy of the configuration data, so the
1139252190Srpaulo * caller does not need to maintain this structure. However, the callback
1140252190Srpaulo * functions and the context parameters to them must be kept available until
1141252190Srpaulo * the P2P module is deinitialized with p2p_deinit().
1142252190Srpaulo */
1143252190Srpaulostruct p2p_data * p2p_init(const struct p2p_config *cfg);
1144252190Srpaulo
1145252190Srpaulo/**
1146252190Srpaulo * p2p_deinit - Deinitialize P2P module
1147252190Srpaulo * @p2p: P2P module context from p2p_init()
1148252190Srpaulo */
1149252190Srpaulovoid p2p_deinit(struct p2p_data *p2p);
1150252190Srpaulo
1151252190Srpaulo/**
1152252190Srpaulo * p2p_flush - Flush P2P module state
1153252190Srpaulo * @p2p: P2P module context from p2p_init()
1154252190Srpaulo *
1155252190Srpaulo * This command removes the P2P module state like peer device entries.
1156252190Srpaulo */
1157252190Srpaulovoid p2p_flush(struct p2p_data *p2p);
1158252190Srpaulo
1159252190Srpaulo/**
1160252190Srpaulo * p2p_unauthorize - Unauthorize the specified peer device
1161252190Srpaulo * @p2p: P2P module context from p2p_init()
1162252190Srpaulo * @addr: P2P peer entry to be unauthorized
1163252190Srpaulo * Returns: 0 on success, -1 on failure
1164252190Srpaulo *
1165252190Srpaulo * This command removes any connection authorization from the specified P2P
1166252190Srpaulo * peer device address. This can be used, e.g., to cancel effect of a previous
1167252190Srpaulo * p2p_authorize() or p2p_connect() call that has not yet resulted in completed
1168252190Srpaulo * GO Negotiation.
1169252190Srpaulo */
1170252190Srpauloint p2p_unauthorize(struct p2p_data *p2p, const u8 *addr);
1171252190Srpaulo
1172252190Srpaulo/**
1173252190Srpaulo * p2p_set_dev_name - Set device name
1174252190Srpaulo * @p2p: P2P module context from p2p_init()
1175252190Srpaulo * Returns: 0 on success, -1 on failure
1176252190Srpaulo *
1177252190Srpaulo * This function can be used to update the P2P module configuration with
1178252190Srpaulo * information that was not available at the time of the p2p_init() call.
1179252190Srpaulo */
1180252190Srpauloint p2p_set_dev_name(struct p2p_data *p2p, const char *dev_name);
1181252190Srpaulo
1182252190Srpauloint p2p_set_manufacturer(struct p2p_data *p2p, const char *manufacturer);
1183252190Srpauloint p2p_set_model_name(struct p2p_data *p2p, const char *model_name);
1184252190Srpauloint p2p_set_model_number(struct p2p_data *p2p, const char *model_number);
1185252190Srpauloint p2p_set_serial_number(struct p2p_data *p2p, const char *serial_number);
1186252190Srpaulo
1187252190Srpaulovoid p2p_set_config_methods(struct p2p_data *p2p, u16 config_methods);
1188252190Srpaulovoid p2p_set_uuid(struct p2p_data *p2p, const u8 *uuid);
1189252190Srpaulo
1190252190Srpaulo/**
1191252190Srpaulo * p2p_set_pri_dev_type - Set primary device type
1192252190Srpaulo * @p2p: P2P module context from p2p_init()
1193252190Srpaulo * Returns: 0 on success, -1 on failure
1194252190Srpaulo *
1195252190Srpaulo * This function can be used to update the P2P module configuration with
1196252190Srpaulo * information that was not available at the time of the p2p_init() call.
1197252190Srpaulo */
1198252190Srpauloint p2p_set_pri_dev_type(struct p2p_data *p2p, const u8 *pri_dev_type);
1199252190Srpaulo
1200252190Srpaulo/**
1201252190Srpaulo * p2p_set_sec_dev_types - Set secondary device types
1202252190Srpaulo * @p2p: P2P module context from p2p_init()
1203252190Srpaulo * Returns: 0 on success, -1 on failure
1204252190Srpaulo *
1205252190Srpaulo * This function can be used to update the P2P module configuration with
1206252190Srpaulo * information that was not available at the time of the p2p_init() call.
1207252190Srpaulo */
1208252190Srpauloint p2p_set_sec_dev_types(struct p2p_data *p2p, const u8 dev_types[][8],
1209252190Srpaulo			  size_t num_dev_types);
1210252190Srpaulo
1211252190Srpauloint p2p_set_country(struct p2p_data *p2p, const char *country);
1212252190Srpaulo
1213252190Srpaulo
1214252190Srpaulo/* Commands from upper layer management entity */
1215252190Srpaulo
1216252190Srpauloenum p2p_discovery_type {
1217252190Srpaulo	P2P_FIND_START_WITH_FULL,
1218252190Srpaulo	P2P_FIND_ONLY_SOCIAL,
1219252190Srpaulo	P2P_FIND_PROGRESSIVE
1220252190Srpaulo};
1221252190Srpaulo
1222252190Srpaulo/**
1223252190Srpaulo * p2p_find - Start P2P Find (Device Discovery)
1224252190Srpaulo * @p2p: P2P module context from p2p_init()
1225252190Srpaulo * @timeout: Timeout for find operation in seconds or 0 for no timeout
1226252190Srpaulo * @type: Device Discovery type
1227252190Srpaulo * @num_req_dev_types: Number of requested device types
1228252190Srpaulo * @req_dev_types: Requested device types array, must be an array
1229252190Srpaulo *	containing num_req_dev_types * WPS_DEV_TYPE_LEN bytes; %NULL if no
1230252190Srpaulo *	requested device types.
1231252190Srpaulo * @dev_id: Device ID to search for or %NULL to find all devices
1232252190Srpaulo * @search_delay: Extra delay in milliseconds between search iterations
1233281806Srpaulo * @seek_count: Number of ASP Service Strings in the seek_string array
1234281806Srpaulo * @seek_string: ASP Service Strings to query for in Probe Requests
1235281806Srpaulo * @freq: Requested first scan frequency (in MHz) to modify type ==
1236281806Srpaulo *	P2P_FIND_START_WITH_FULL behavior. 0 = Use normal full scan.
1237281806Srpaulo *	If p2p_find is already in progress, this parameter is ignored and full
1238281806Srpaulo *	scan will be executed.
1239252190Srpaulo * Returns: 0 on success, -1 on failure
1240252190Srpaulo */
1241252190Srpauloint p2p_find(struct p2p_data *p2p, unsigned int timeout,
1242252190Srpaulo	     enum p2p_discovery_type type,
1243252190Srpaulo	     unsigned int num_req_dev_types, const u8 *req_dev_types,
1244281806Srpaulo	     const u8 *dev_id, unsigned int search_delay,
1245281806Srpaulo	     u8 seek_count, const char **seek_string, int freq);
1246252190Srpaulo
1247252190Srpaulo/**
1248281806Srpaulo * p2p_notify_scan_trigger_status - Indicate scan trigger status
1249281806Srpaulo * @p2p: P2P module context from p2p_init()
1250281806Srpaulo * @status: 0 on success, -1 on failure
1251281806Srpaulo */
1252281806Srpaulovoid p2p_notify_scan_trigger_status(struct p2p_data *p2p, int status);
1253281806Srpaulo
1254281806Srpaulo/**
1255252190Srpaulo * p2p_stop_find - Stop P2P Find (Device Discovery)
1256252190Srpaulo * @p2p: P2P module context from p2p_init()
1257252190Srpaulo */
1258252190Srpaulovoid p2p_stop_find(struct p2p_data *p2p);
1259252190Srpaulo
1260252190Srpaulo/**
1261252190Srpaulo * p2p_stop_find_for_freq - Stop P2P Find for next oper on specific freq
1262252190Srpaulo * @p2p: P2P module context from p2p_init()
1263252190Srpaulo * @freq: Frequency in MHz for next operation
1264252190Srpaulo *
1265252190Srpaulo * This is like p2p_stop_find(), but Listen state is not stopped if we are
1266252190Srpaulo * already on the same frequency.
1267252190Srpaulo */
1268252190Srpaulovoid p2p_stop_find_for_freq(struct p2p_data *p2p, int freq);
1269252190Srpaulo
1270252190Srpaulo/**
1271252190Srpaulo * p2p_listen - Start P2P Listen state for specified duration
1272252190Srpaulo * @p2p: P2P module context from p2p_init()
1273252190Srpaulo * @timeout: Listen state duration in milliseconds
1274252190Srpaulo * Returns: 0 on success, -1 on failure
1275252190Srpaulo *
1276252190Srpaulo * This function can be used to request the P2P module to keep the device
1277252190Srpaulo * discoverable on the listen channel for an extended set of time. At least in
1278252190Srpaulo * its current form, this is mainly used for testing purposes and may not be of
1279252190Srpaulo * much use for normal P2P operations.
1280252190Srpaulo */
1281252190Srpauloint p2p_listen(struct p2p_data *p2p, unsigned int timeout);
1282252190Srpaulo
1283252190Srpaulo/**
1284281806Srpaulo * p2p_stop_listen - Stop P2P Listen
1285281806Srpaulo * @p2p: P2P module context from p2p_init()
1286281806Srpaulo */
1287281806Srpaulovoid p2p_stop_listen(struct p2p_data *p2p);
1288281806Srpaulo
1289281806Srpaulo/**
1290252190Srpaulo * p2p_connect - Start P2P group formation (GO negotiation)
1291252190Srpaulo * @p2p: P2P module context from p2p_init()
1292252190Srpaulo * @peer_addr: MAC address of the peer P2P client
1293252190Srpaulo * @wps_method: WPS method to be used in provisioning
1294252190Srpaulo * @go_intent: Local GO intent value (1..15)
1295252190Srpaulo * @own_interface_addr: Intended interface address to use with the group
1296252190Srpaulo * @force_freq: The only allowed channel frequency in MHz or 0
1297252190Srpaulo * @persistent_group: Whether to create a persistent group (0 = no, 1 =
1298252190Srpaulo * persistent group without persistent reconnect, 2 = persistent group with
1299252190Srpaulo * persistent reconnect)
1300252190Srpaulo * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
1301252190Srpaulo *	a new SSID
1302252190Srpaulo * @force_ssid_len: Length of $force_ssid buffer
1303252190Srpaulo * @pd_before_go_neg: Whether to send Provision Discovery prior to GO
1304252190Srpaulo *	Negotiation as an interoperability workaround when initiating group
1305252190Srpaulo *	formation
1306252190Srpaulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
1307252190Srpaulo *	force_freq == 0)
1308252190Srpaulo * Returns: 0 on success, -1 on failure
1309252190Srpaulo */
1310252190Srpauloint p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
1311252190Srpaulo		enum p2p_wps_method wps_method,
1312252190Srpaulo		int go_intent, const u8 *own_interface_addr,
1313252190Srpaulo		unsigned int force_freq, int persistent_group,
1314252190Srpaulo		const u8 *force_ssid, size_t force_ssid_len,
1315281806Srpaulo		int pd_before_go_neg, unsigned int pref_freq, u16 oob_pw_id);
1316252190Srpaulo
1317252190Srpaulo/**
1318252190Srpaulo * p2p_authorize - Authorize P2P group formation (GO negotiation)
1319252190Srpaulo * @p2p: P2P module context from p2p_init()
1320252190Srpaulo * @peer_addr: MAC address of the peer P2P client
1321252190Srpaulo * @wps_method: WPS method to be used in provisioning
1322252190Srpaulo * @go_intent: Local GO intent value (1..15)
1323252190Srpaulo * @own_interface_addr: Intended interface address to use with the group
1324252190Srpaulo * @force_freq: The only allowed channel frequency in MHz or 0
1325252190Srpaulo * @persistent_group: Whether to create a persistent group (0 = no, 1 =
1326252190Srpaulo * persistent group without persistent reconnect, 2 = persistent group with
1327252190Srpaulo * persistent reconnect)
1328252190Srpaulo * @force_ssid: Forced SSID for the group if we become GO or %NULL to generate
1329252190Srpaulo *	a new SSID
1330252190Srpaulo * @force_ssid_len: Length of $force_ssid buffer
1331252190Srpaulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
1332252190Srpaulo *	force_freq == 0)
1333252190Srpaulo * Returns: 0 on success, -1 on failure
1334252190Srpaulo *
1335252190Srpaulo * This is like p2p_connect(), but the actual group negotiation is not
1336252190Srpaulo * initiated automatically, i.e., the other end is expected to do that.
1337252190Srpaulo */
1338252190Srpauloint p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
1339252190Srpaulo		  enum p2p_wps_method wps_method,
1340252190Srpaulo		  int go_intent, const u8 *own_interface_addr,
1341252190Srpaulo		  unsigned int force_freq, int persistent_group,
1342252190Srpaulo		  const u8 *force_ssid, size_t force_ssid_len,
1343281806Srpaulo		  unsigned int pref_freq, u16 oob_pw_id);
1344252190Srpaulo
1345252190Srpaulo/**
1346252190Srpaulo * p2p_reject - Reject peer device (explicitly block connection attempts)
1347252190Srpaulo * @p2p: P2P module context from p2p_init()
1348252190Srpaulo * @peer_addr: MAC address of the peer P2P client
1349252190Srpaulo * Returns: 0 on success, -1 on failure
1350252190Srpaulo */
1351252190Srpauloint p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
1352252190Srpaulo
1353252190Srpaulo/**
1354252190Srpaulo * p2p_prov_disc_req - Send Provision Discovery Request
1355252190Srpaulo * @p2p: P2P module context from p2p_init()
1356252190Srpaulo * @peer_addr: MAC address of the peer P2P client
1357281806Srpaulo * @p2ps_prov: Provisioning info for P2PS
1358252190Srpaulo * @config_methods: WPS Config Methods value (only one bit set)
1359252190Srpaulo * @join: Whether this is used by a client joining an active group
1360252190Srpaulo * @force_freq: Forced TX frequency for the frame (mainly for the join case)
1361252190Srpaulo * @user_initiated_pd: Flag to indicate if initiated by user or not
1362252190Srpaulo * Returns: 0 on success, -1 on failure
1363252190Srpaulo *
1364252190Srpaulo * This function can be used to request a discovered P2P peer to display a PIN
1365252190Srpaulo * (config_methods = WPS_CONFIG_DISPLAY) or be prepared to enter a PIN from us
1366252190Srpaulo * (config_methods = WPS_CONFIG_KEYPAD). The Provision Discovery Request frame
1367252190Srpaulo * is transmitted once immediately and if no response is received, the frame
1368252190Srpaulo * will be sent again whenever the target device is discovered during device
1369252190Srpaulo * dsicovery (start with a p2p_find() call). Response from the peer is
1370252190Srpaulo * indicated with the p2p_config::prov_disc_resp() callback.
1371252190Srpaulo */
1372252190Srpauloint p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
1373281806Srpaulo		      struct p2ps_provision *p2ps_prov, u16 config_methods,
1374281806Srpaulo		      int join, int force_freq,
1375252190Srpaulo		      int user_initiated_pd);
1376252190Srpaulo
1377252190Srpaulo/**
1378252190Srpaulo * p2p_sd_request - Schedule a service discovery query
1379252190Srpaulo * @p2p: P2P module context from p2p_init()
1380252190Srpaulo * @dst: Destination peer or %NULL to apply for all peers
1381252190Srpaulo * @tlvs: P2P Service Query TLV(s)
1382252190Srpaulo * Returns: Reference to the query or %NULL on failure
1383252190Srpaulo *
1384252190Srpaulo * Response to the query is indicated with the p2p_config::sd_response()
1385252190Srpaulo * callback.
1386252190Srpaulo */
1387252190Srpaulovoid * p2p_sd_request(struct p2p_data *p2p, const u8 *dst,
1388252190Srpaulo		      const struct wpabuf *tlvs);
1389252190Srpaulo
1390252190Srpaulo#ifdef CONFIG_WIFI_DISPLAY
1391252190Srpaulovoid * p2p_sd_request_wfd(struct p2p_data *p2p, const u8 *dst,
1392252190Srpaulo			  const struct wpabuf *tlvs);
1393252190Srpaulo#endif /* CONFIG_WIFI_DISPLAY */
1394252190Srpaulo
1395252190Srpaulo/**
1396252190Srpaulo * p2p_sd_cancel_request - Cancel a pending service discovery query
1397252190Srpaulo * @p2p: P2P module context from p2p_init()
1398252190Srpaulo * @req: Query reference from p2p_sd_request()
1399252190Srpaulo * Returns: 0 if request for cancelled; -1 if not found
1400252190Srpaulo */
1401252190Srpauloint p2p_sd_cancel_request(struct p2p_data *p2p, void *req);
1402252190Srpaulo
1403252190Srpaulo/**
1404252190Srpaulo * p2p_sd_response - Send response to a service discovery query
1405252190Srpaulo * @p2p: P2P module context from p2p_init()
1406252190Srpaulo * @freq: Frequency from p2p_config::sd_request() callback
1407252190Srpaulo * @dst: Destination address from p2p_config::sd_request() callback
1408252190Srpaulo * @dialog_token: Dialog token from p2p_config::sd_request() callback
1409252190Srpaulo * @resp_tlvs: P2P Service Response TLV(s)
1410252190Srpaulo *
1411252190Srpaulo * This function is called as a response to the request indicated with
1412252190Srpaulo * p2p_config::sd_request() callback.
1413252190Srpaulo */
1414252190Srpaulovoid p2p_sd_response(struct p2p_data *p2p, int freq, const u8 *dst,
1415252190Srpaulo		     u8 dialog_token, const struct wpabuf *resp_tlvs);
1416252190Srpaulo
1417252190Srpaulo/**
1418252190Srpaulo * p2p_sd_service_update - Indicate a change in local services
1419252190Srpaulo * @p2p: P2P module context from p2p_init()
1420252190Srpaulo *
1421252190Srpaulo * This function needs to be called whenever there is a change in availability
1422252190Srpaulo * of the local services. This will increment the Service Update Indicator
1423252190Srpaulo * value which will be used in SD Request and Response frames.
1424252190Srpaulo */
1425252190Srpaulovoid p2p_sd_service_update(struct p2p_data *p2p);
1426252190Srpaulo
1427252190Srpaulo
1428252190Srpauloenum p2p_invite_role {
1429252190Srpaulo	P2P_INVITE_ROLE_GO,
1430252190Srpaulo	P2P_INVITE_ROLE_ACTIVE_GO,
1431252190Srpaulo	P2P_INVITE_ROLE_CLIENT
1432252190Srpaulo};
1433252190Srpaulo
1434252190Srpaulo/**
1435252190Srpaulo * p2p_invite - Invite a P2P Device into a group
1436252190Srpaulo * @p2p: P2P module context from p2p_init()
1437252190Srpaulo * @peer: Device Address of the peer P2P Device
1438252190Srpaulo * @role: Local role in the group
1439252190Srpaulo * @bssid: Group BSSID or %NULL if not known
1440252190Srpaulo * @ssid: Group SSID
1441252190Srpaulo * @ssid_len: Length of ssid in octets
1442252190Srpaulo * @force_freq: The only allowed channel frequency in MHz or 0
1443252190Srpaulo * @go_dev_addr: Forced GO Device Address or %NULL if none
1444252190Srpaulo * @persistent_group: Whether this is to reinvoke a persistent group
1445281806Srpaulo * @pref_freq: Preferred operating frequency in MHz or 0 (this is only used if
1446281806Srpaulo *	force_freq == 0)
1447281806Srpaulo * @dev_pw_id: Device Password ID from OOB Device Password (NFC) static handover
1448281806Srpaulo *	case or -1 if not used
1449252190Srpaulo * Returns: 0 on success, -1 on failure
1450252190Srpaulo */
1451252190Srpauloint p2p_invite(struct p2p_data *p2p, const u8 *peer, enum p2p_invite_role role,
1452252190Srpaulo	       const u8 *bssid, const u8 *ssid, size_t ssid_len,
1453252190Srpaulo	       unsigned int force_freq, const u8 *go_dev_addr,
1454281806Srpaulo	       int persistent_group, unsigned int pref_freq, int dev_pw_id);
1455252190Srpaulo
1456252190Srpaulo/**
1457252190Srpaulo * p2p_presence_req - Request GO presence
1458252190Srpaulo * @p2p: P2P module context from p2p_init()
1459252190Srpaulo * @go_interface_addr: GO P2P Interface Address
1460252190Srpaulo * @own_interface_addr: Own P2P Interface Address for this group
1461252190Srpaulo * @freq: Group operating frequence (in MHz)
1462252190Srpaulo * @duration1: Preferred presence duration in microseconds
1463252190Srpaulo * @interval1: Preferred presence interval in microseconds
1464252190Srpaulo * @duration2: Acceptable presence duration in microseconds
1465252190Srpaulo * @interval2: Acceptable presence interval in microseconds
1466252190Srpaulo * Returns: 0 on success, -1 on failure
1467252190Srpaulo *
1468252190Srpaulo * If both duration and interval values are zero, the parameter pair is not
1469252190Srpaulo * specified (i.e., to remove Presence Request, use duration1 = interval1 = 0).
1470252190Srpaulo */
1471252190Srpauloint p2p_presence_req(struct p2p_data *p2p, const u8 *go_interface_addr,
1472252190Srpaulo		     const u8 *own_interface_addr, unsigned int freq,
1473252190Srpaulo		     u32 duration1, u32 interval1, u32 duration2,
1474252190Srpaulo		     u32 interval2);
1475252190Srpaulo
1476252190Srpaulo/**
1477252190Srpaulo * p2p_ext_listen - Set Extended Listen Timing
1478252190Srpaulo * @p2p: P2P module context from p2p_init()
1479252190Srpaulo * @freq: Group operating frequence (in MHz)
1480252190Srpaulo * @period: Availability period in milliseconds (1-65535; 0 to disable)
1481252190Srpaulo * @interval: Availability interval in milliseconds (1-65535; 0 to disable)
1482252190Srpaulo * Returns: 0 on success, -1 on failure
1483252190Srpaulo *
1484252190Srpaulo * This function can be used to enable or disable (period = interval = 0)
1485252190Srpaulo * Extended Listen Timing. When enabled, the P2P Device will become
1486252190Srpaulo * discoverable (go into Listen State) every @interval milliseconds for at
1487252190Srpaulo * least @period milliseconds.
1488252190Srpaulo */
1489252190Srpauloint p2p_ext_listen(struct p2p_data *p2p, unsigned int period,
1490252190Srpaulo		   unsigned int interval);
1491252190Srpaulo
1492252190Srpaulo/* Event notifications from upper layer management operations */
1493252190Srpaulo
1494252190Srpaulo/**
1495252190Srpaulo * p2p_wps_success_cb - Report successfully completed WPS provisioning
1496252190Srpaulo * @p2p: P2P module context from p2p_init()
1497252190Srpaulo * @mac_addr: Peer address
1498252190Srpaulo *
1499252190Srpaulo * This function is used to report successfully completed WPS provisioning
1500252190Srpaulo * during group formation in both GO/Registrar and client/Enrollee roles.
1501252190Srpaulo */
1502252190Srpaulovoid p2p_wps_success_cb(struct p2p_data *p2p, const u8 *mac_addr);
1503252190Srpaulo
1504252190Srpaulo/**
1505252190Srpaulo * p2p_group_formation_failed - Report failed WPS provisioning
1506252190Srpaulo * @p2p: P2P module context from p2p_init()
1507252190Srpaulo *
1508252190Srpaulo * This function is used to report failed group formation. This can happen
1509252190Srpaulo * either due to failed WPS provisioning or due to 15 second timeout during
1510252190Srpaulo * the provisioning phase.
1511252190Srpaulo */
1512252190Srpaulovoid p2p_group_formation_failed(struct p2p_data *p2p);
1513252190Srpaulo
1514252190Srpaulo/**
1515252190Srpaulo * p2p_get_provisioning_info - Get any stored provisioning info
1516252190Srpaulo * @p2p: P2P module context from p2p_init()
1517252190Srpaulo * @addr: Peer P2P Device Address
1518252190Srpaulo * Returns: WPS provisioning information (WPS config method) or 0 if no
1519252190Srpaulo * information is available
1520252190Srpaulo *
1521252190Srpaulo * This function is used to retrieve stored WPS provisioning info for the given
1522252190Srpaulo * peer.
1523252190Srpaulo */
1524252190Srpaulou16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1525252190Srpaulo
1526252190Srpaulo/**
1527252190Srpaulo * p2p_clear_provisioning_info - Clear any stored provisioning info
1528252190Srpaulo * @p2p: P2P module context from p2p_init()
1529252190Srpaulo * @iface_addr: Peer P2P Device Address
1530252190Srpaulo *
1531252190Srpaulo * This function is used to clear stored WPS provisioning info for the given
1532252190Srpaulo * peer.
1533252190Srpaulo */
1534252190Srpaulovoid p2p_clear_provisioning_info(struct p2p_data *p2p, const u8 *addr);
1535252190Srpaulo
1536252190Srpaulo
1537252190Srpaulo/* Event notifications from lower layer driver operations */
1538252190Srpaulo
1539252190Srpaulo/**
1540252190Srpaulo * enum p2p_probe_req_status
1541252190Srpaulo *
1542252190Srpaulo * @P2P_PREQ_MALFORMED: frame was not well-formed
1543252190Srpaulo * @P2P_PREQ_NOT_LISTEN: device isn't in listen state, frame ignored
1544252190Srpaulo * @P2P_PREQ_NOT_P2P: frame was not a P2P probe request
1545252190Srpaulo * @P2P_PREQ_P2P_NOT_PROCESSED: frame was P2P but wasn't processed
1546252190Srpaulo * @P2P_PREQ_P2P_PROCESSED: frame has been processed by P2P
1547252190Srpaulo */
1548252190Srpauloenum p2p_probe_req_status {
1549252190Srpaulo	P2P_PREQ_MALFORMED,
1550252190Srpaulo	P2P_PREQ_NOT_LISTEN,
1551252190Srpaulo	P2P_PREQ_NOT_P2P,
1552252190Srpaulo	P2P_PREQ_NOT_PROCESSED,
1553252190Srpaulo	P2P_PREQ_PROCESSED
1554252190Srpaulo};
1555252190Srpaulo
1556252190Srpaulo/**
1557252190Srpaulo * p2p_probe_req_rx - Report reception of a Probe Request frame
1558252190Srpaulo * @p2p: P2P module context from p2p_init()
1559252190Srpaulo * @addr: Source MAC address
1560252190Srpaulo * @dst: Destination MAC address if available or %NULL
1561252190Srpaulo * @bssid: BSSID if available or %NULL
1562252190Srpaulo * @ie: Information elements from the Probe Request frame body
1563252190Srpaulo * @ie_len: Length of ie buffer in octets
1564289549Srpaulo * @rx_freq: Probe Request frame RX frequency
1565337817Scy * @p2p_lo_started: Whether P2P Listen Offload is started
1566252190Srpaulo * Returns: value indicating the type and status of the probe request
1567252190Srpaulo */
1568252190Srpauloenum p2p_probe_req_status
1569252190Srpaulop2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst,
1570289549Srpaulo		 const u8 *bssid, const u8 *ie, size_t ie_len,
1571337817Scy		 unsigned int rx_freq, int p2p_lo_started);
1572252190Srpaulo
1573252190Srpaulo/**
1574252190Srpaulo * p2p_rx_action - Report received Action frame
1575252190Srpaulo * @p2p: P2P module context from p2p_init()
1576252190Srpaulo * @da: Destination address of the received Action frame
1577252190Srpaulo * @sa: Source address of the received Action frame
1578252190Srpaulo * @bssid: Address 3 of the received Action frame
1579252190Srpaulo * @category: Category of the received Action frame
1580252190Srpaulo * @data: Action frame body after the Category field
1581252190Srpaulo * @len: Length of the data buffer in octets
1582252190Srpaulo * @freq: Frequency (in MHz) on which the frame was received
1583252190Srpaulo */
1584252190Srpaulovoid p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
1585252190Srpaulo		   const u8 *bssid, u8 category,
1586252190Srpaulo		   const u8 *data, size_t len, int freq);
1587252190Srpaulo
1588252190Srpaulo/**
1589252190Srpaulo * p2p_scan_res_handler - Indicate a P2P scan results
1590252190Srpaulo * @p2p: P2P module context from p2p_init()
1591252190Srpaulo * @bssid: BSSID of the scan result
1592252190Srpaulo * @freq: Frequency of the channel on which the device was found in MHz
1593281806Srpaulo * @rx_time: Time when the result was received
1594252190Srpaulo * @level: Signal level (signal strength of the received Beacon/Probe Response
1595252190Srpaulo *	frame)
1596252190Srpaulo * @ies: Pointer to IEs from the scan result
1597252190Srpaulo * @ies_len: Length of the ies buffer
1598252190Srpaulo * Returns: 0 to continue or 1 to stop scan result indication
1599252190Srpaulo *
1600252190Srpaulo * This function is called to indicate a scan result entry with P2P IE from a
1601252190Srpaulo * scan requested with struct p2p_config::p2p_scan(). This can be called during
1602252190Srpaulo * the actual scan process (i.e., whenever a new device is found) or as a
1603252190Srpaulo * sequence of calls after the full scan has been completed. The former option
1604252190Srpaulo * can result in optimized operations, but may not be supported by all
1605252190Srpaulo * driver/firmware designs. The ies buffer need to include at least the P2P IE,
1606252190Srpaulo * but it is recommended to include all IEs received from the device. The
1607252190Srpaulo * caller does not need to check that the IEs contain a P2P IE before calling
1608252190Srpaulo * this function since frames will be filtered internally if needed.
1609252190Srpaulo *
1610252190Srpaulo * This function will return 1 if it wants to stop scan result iteration (and
1611252190Srpaulo * scan in general if it is still in progress). This is used to allow faster
1612252190Srpaulo * start of a pending operation, e.g., to start a pending GO negotiation.
1613252190Srpaulo */
1614252190Srpauloint p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
1615281806Srpaulo			 struct os_reltime *rx_time, int level, const u8 *ies,
1616252190Srpaulo			 size_t ies_len);
1617252190Srpaulo
1618252190Srpaulo/**
1619252190Srpaulo * p2p_scan_res_handled - Indicate end of scan results
1620252190Srpaulo * @p2p: P2P module context from p2p_init()
1621252190Srpaulo *
1622252190Srpaulo * This function is called to indicate that all P2P scan results from a scan
1623252190Srpaulo * have been reported with zero or more calls to p2p_scan_res_handler(). This
1624252190Srpaulo * function must be called as a response to successful
1625252190Srpaulo * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler()
1626252190Srpaulo * calls stopped iteration.
1627252190Srpaulo */
1628252190Srpaulovoid p2p_scan_res_handled(struct p2p_data *p2p);
1629252190Srpaulo
1630252190Srpauloenum p2p_send_action_result {
1631252190Srpaulo	P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
1632252190Srpaulo	P2P_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged */,
1633252190Srpaulo	P2P_SEND_ACTION_FAILED /* Frame was not sent due to a failure */
1634252190Srpaulo};
1635252190Srpaulo
1636252190Srpaulo/**
1637252190Srpaulo * p2p_send_action_cb - Notify TX status of an Action frame
1638252190Srpaulo * @p2p: P2P module context from p2p_init()
1639252190Srpaulo * @freq: Channel frequency in MHz
1640252190Srpaulo * @dst: Destination MAC address (Address 1)
1641252190Srpaulo * @src: Source MAC address (Address 2)
1642252190Srpaulo * @bssid: BSSID (Address 3)
1643252190Srpaulo * @result: Result of the transmission attempt
1644252190Srpaulo *
1645252190Srpaulo * This function is used to indicate the result of an Action frame transmission
1646252190Srpaulo * that was requested with struct p2p_config::send_action() callback.
1647252190Srpaulo */
1648252190Srpaulovoid p2p_send_action_cb(struct p2p_data *p2p, unsigned int freq, const u8 *dst,
1649252190Srpaulo			const u8 *src, const u8 *bssid,
1650252190Srpaulo			enum p2p_send_action_result result);
1651252190Srpaulo
1652252190Srpaulo/**
1653252190Srpaulo * p2p_listen_cb - Indicate the start of a requested Listen state
1654252190Srpaulo * @p2p: P2P module context from p2p_init()
1655252190Srpaulo * @freq: Listen channel frequency in MHz
1656252190Srpaulo * @duration: Duration for the Listen state in milliseconds
1657252190Srpaulo *
1658252190Srpaulo * This function is used to indicate that a Listen state requested with
1659252190Srpaulo * struct p2p_config::start_listen() callback has started.
1660252190Srpaulo */
1661252190Srpaulovoid p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
1662252190Srpaulo		   unsigned int duration);
1663252190Srpaulo
1664252190Srpaulo/**
1665252190Srpaulo * p2p_listen_end - Indicate the end of a requested Listen state
1666252190Srpaulo * @p2p: P2P module context from p2p_init()
1667252190Srpaulo * @freq: Listen channel frequency in MHz
1668252190Srpaulo * Returns: 0 if no operations were started, 1 if an operation was started
1669252190Srpaulo *
1670252190Srpaulo * This function is used to indicate that a Listen state requested with
1671252190Srpaulo * struct p2p_config::start_listen() callback has ended.
1672252190Srpaulo */
1673252190Srpauloint p2p_listen_end(struct p2p_data *p2p, unsigned int freq);
1674252190Srpaulo
1675252190Srpaulovoid p2p_deauth_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1676252190Srpaulo		      const u8 *ie, size_t ie_len);
1677252190Srpaulo
1678252190Srpaulovoid p2p_disassoc_notif(struct p2p_data *p2p, const u8 *bssid, u16 reason_code,
1679252190Srpaulo			const u8 *ie, size_t ie_len);
1680252190Srpaulo
1681252190Srpaulo
1682252190Srpaulo/* Per-group P2P state for GO */
1683252190Srpaulo
1684252190Srpaulostruct p2p_group;
1685252190Srpaulo
1686252190Srpaulo/**
1687252190Srpaulo * struct p2p_group_config - P2P group configuration
1688252190Srpaulo *
1689252190Srpaulo * This configuration is provided to the P2P module during initialization of
1690252190Srpaulo * the per-group information with p2p_group_init().
1691252190Srpaulo */
1692252190Srpaulostruct p2p_group_config {
1693252190Srpaulo	/**
1694252190Srpaulo	 * persistent_group - Whether the group is persistent
1695252190Srpaulo	 * 0 = not a persistent group
1696252190Srpaulo	 * 1 = persistent group without persistent reconnect
1697252190Srpaulo	 * 2 = persistent group with persistent reconnect
1698252190Srpaulo	 */
1699252190Srpaulo	int persistent_group;
1700252190Srpaulo
1701252190Srpaulo	/**
1702252190Srpaulo	 * interface_addr - P2P Interface Address of the group
1703252190Srpaulo	 */
1704252190Srpaulo	u8 interface_addr[ETH_ALEN];
1705252190Srpaulo
1706252190Srpaulo	/**
1707252190Srpaulo	 * max_clients - Maximum number of clients in the group
1708252190Srpaulo	 */
1709252190Srpaulo	unsigned int max_clients;
1710252190Srpaulo
1711252190Srpaulo	/**
1712252190Srpaulo	 * ssid - Group SSID
1713252190Srpaulo	 */
1714289549Srpaulo	u8 ssid[SSID_MAX_LEN];
1715252190Srpaulo
1716252190Srpaulo	/**
1717252190Srpaulo	 * ssid_len - Length of SSID
1718252190Srpaulo	 */
1719252190Srpaulo	size_t ssid_len;
1720252190Srpaulo
1721252190Srpaulo	/**
1722281806Srpaulo	 * freq - Operating channel of the group
1723281806Srpaulo	 */
1724281806Srpaulo	int freq;
1725281806Srpaulo
1726281806Srpaulo	/**
1727337817Scy	 * ip_addr_alloc - Whether IP address allocation within 4-way handshake
1728337817Scy	 *	is supported
1729337817Scy	 */
1730337817Scy	int ip_addr_alloc;
1731337817Scy
1732337817Scy	/**
1733252190Srpaulo	 * cb_ctx - Context to use with callback functions
1734252190Srpaulo	 */
1735252190Srpaulo	void *cb_ctx;
1736252190Srpaulo
1737252190Srpaulo	/**
1738252190Srpaulo	 * ie_update - Notification of IE update
1739252190Srpaulo	 * @ctx: Callback context from cb_ctx
1740252190Srpaulo	 * @beacon_ies: P2P IE for Beacon frames or %NULL if no change
1741252190Srpaulo	 * @proberesp_ies: P2P Ie for Probe Response frames
1742252190Srpaulo	 *
1743252190Srpaulo	 * P2P module uses this callback function to notify whenever the P2P IE
1744252190Srpaulo	 * in Beacon or Probe Response frames should be updated based on group
1745252190Srpaulo	 * events.
1746252190Srpaulo	 *
1747252190Srpaulo	 * The callee is responsible for freeing the returned buffer(s) with
1748252190Srpaulo	 * wpabuf_free().
1749252190Srpaulo	 */
1750252190Srpaulo	void (*ie_update)(void *ctx, struct wpabuf *beacon_ies,
1751252190Srpaulo			  struct wpabuf *proberesp_ies);
1752252190Srpaulo
1753252190Srpaulo	/**
1754252190Srpaulo	 * idle_update - Notification of changes in group idle state
1755252190Srpaulo	 * @ctx: Callback context from cb_ctx
1756252190Srpaulo	 * @idle: Whether the group is idle (no associated stations)
1757252190Srpaulo	 */
1758252190Srpaulo	void (*idle_update)(void *ctx, int idle);
1759252190Srpaulo};
1760252190Srpaulo
1761252190Srpaulo/**
1762252190Srpaulo * p2p_group_init - Initialize P2P group
1763252190Srpaulo * @p2p: P2P module context from p2p_init()
1764252190Srpaulo * @config: P2P group configuration (will be freed by p2p_group_deinit())
1765252190Srpaulo * Returns: Pointer to private data or %NULL on failure
1766252190Srpaulo *
1767252190Srpaulo * This function is used to initialize per-group P2P module context. Currently,
1768252190Srpaulo * this is only used to manage GO functionality and P2P clients do not need to
1769252190Srpaulo * create an instance of this per-group information.
1770252190Srpaulo */
1771252190Srpaulostruct p2p_group * p2p_group_init(struct p2p_data *p2p,
1772252190Srpaulo				  struct p2p_group_config *config);
1773252190Srpaulo
1774252190Srpaulo/**
1775252190Srpaulo * p2p_group_deinit - Deinitialize P2P group
1776252190Srpaulo * @group: P2P group context from p2p_group_init()
1777252190Srpaulo */
1778252190Srpaulovoid p2p_group_deinit(struct p2p_group *group);
1779252190Srpaulo
1780252190Srpaulo/**
1781252190Srpaulo * p2p_group_notif_assoc - Notification of P2P client association with GO
1782252190Srpaulo * @group: P2P group context from p2p_group_init()
1783252190Srpaulo * @addr: Interface address of the P2P client
1784252190Srpaulo * @ie: IEs from the (Re)association Request frame
1785252190Srpaulo * @len: Length of the ie buffer in octets
1786252190Srpaulo * Returns: 0 on success, -1 on failure
1787252190Srpaulo */
1788252190Srpauloint p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
1789252190Srpaulo			  const u8 *ie, size_t len);
1790252190Srpaulo
1791252190Srpaulo/**
1792252190Srpaulo * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response
1793252190Srpaulo * @group: P2P group context from p2p_group_init()
1794252190Srpaulo * @status: Status value (P2P_SC_SUCCESS if association succeeded)
1795252190Srpaulo * Returns: P2P IE for (Re)association Response or %NULL on failure
1796252190Srpaulo *
1797252190Srpaulo * The caller is responsible for freeing the returned buffer with
1798252190Srpaulo * wpabuf_free().
1799252190Srpaulo */
1800252190Srpaulostruct wpabuf * p2p_group_assoc_resp_ie(struct p2p_group *group, u8 status);
1801252190Srpaulo
1802252190Srpaulo/**
1803252190Srpaulo * p2p_group_notif_disassoc - Notification of P2P client disassociation from GO
1804252190Srpaulo * @group: P2P group context from p2p_group_init()
1805252190Srpaulo * @addr: Interface address of the P2P client
1806252190Srpaulo */
1807252190Srpaulovoid p2p_group_notif_disassoc(struct p2p_group *group, const u8 *addr);
1808252190Srpaulo
1809252190Srpaulo/**
1810252190Srpaulo * p2p_group_notif_formation_done - Notification of completed group formation
1811252190Srpaulo * @group: P2P group context from p2p_group_init()
1812252190Srpaulo */
1813252190Srpaulovoid p2p_group_notif_formation_done(struct p2p_group *group);
1814252190Srpaulo
1815252190Srpaulo/**
1816252190Srpaulo * p2p_group_notif_noa - Notification of NoA change
1817252190Srpaulo * @group: P2P group context from p2p_group_init()
1818252190Srpaulo * @noa: Notice of Absence attribute payload, %NULL if none
1819252190Srpaulo * @noa_len: Length of noa buffer in octets
1820252190Srpaulo * Returns: 0 on success, -1 on failure
1821252190Srpaulo *
1822252190Srpaulo * Notify the P2P group management about a new NoA contents. This will be
1823252190Srpaulo * inserted into the P2P IEs in Beacon and Probe Response frames with rest of
1824252190Srpaulo * the group information.
1825252190Srpaulo */
1826252190Srpauloint p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
1827252190Srpaulo			size_t noa_len);
1828252190Srpaulo
1829252190Srpaulo/**
1830252190Srpaulo * p2p_group_match_dev_type - Match device types in group with requested type
1831252190Srpaulo * @group: P2P group context from p2p_group_init()
1832252190Srpaulo * @wps: WPS TLVs from Probe Request frame (concatenated WPS IEs)
1833252190Srpaulo * Returns: 1 on match, 0 on mismatch
1834252190Srpaulo *
1835252190Srpaulo * This function can be used to match the Requested Device Type attribute in
1836252190Srpaulo * WPS IE with the device types of a group member for deciding whether a GO
1837252190Srpaulo * should reply to a Probe Request frame. Match will be reported if the WPS IE
1838252190Srpaulo * is not requested any specific device type.
1839252190Srpaulo */
1840252190Srpauloint p2p_group_match_dev_type(struct p2p_group *group, struct wpabuf *wps);
1841252190Srpaulo
1842252190Srpaulo/**
1843252190Srpaulo * p2p_group_match_dev_id - Match P2P Device Address in group with requested device id
1844252190Srpaulo */
1845252190Srpauloint p2p_group_match_dev_id(struct p2p_group *group, struct wpabuf *p2p);
1846252190Srpaulo
1847252190Srpaulo/**
1848252190Srpaulo * p2p_group_go_discover - Send GO Discoverability Request to a group client
1849252190Srpaulo * @group: P2P group context from p2p_group_init()
1850252190Srpaulo * Returns: 0 on success (frame scheduled); -1 if client was not found
1851252190Srpaulo */
1852252190Srpauloint p2p_group_go_discover(struct p2p_group *group, const u8 *dev_id,
1853252190Srpaulo			  const u8 *searching_dev, int rx_freq);
1854252190Srpaulo
1855252190Srpaulo
1856252190Srpaulo/* Generic helper functions */
1857252190Srpaulo
1858252190Srpaulo/**
1859252190Srpaulo * p2p_ie_text - Build text format description of P2P IE
1860252190Srpaulo * @p2p_ie: P2P IE
1861252190Srpaulo * @buf: Buffer for returning text
1862252190Srpaulo * @end: Pointer to the end of the buf area
1863252190Srpaulo * Returns: Number of octets written to the buffer or -1 on failure
1864252190Srpaulo *
1865252190Srpaulo * This function can be used to parse P2P IE contents into text format
1866252190Srpaulo * field=value lines.
1867252190Srpaulo */
1868252190Srpauloint p2p_ie_text(struct wpabuf *p2p_ie, char *buf, char *end);
1869252190Srpaulo
1870252190Srpaulo/**
1871252190Srpaulo * p2p_scan_result_text - Build text format description of P2P IE
1872252190Srpaulo * @ies: Information elements from scan results
1873252190Srpaulo * @ies_len: ies buffer length in octets
1874252190Srpaulo * @buf: Buffer for returning text
1875252190Srpaulo * @end: Pointer to the end of the buf area
1876252190Srpaulo * Returns: Number of octets written to the buffer or -1 on failure
1877252190Srpaulo *
1878252190Srpaulo * This function can be used to parse P2P IE contents into text format
1879252190Srpaulo * field=value lines.
1880252190Srpaulo */
1881252190Srpauloint p2p_scan_result_text(const u8 *ies, size_t ies_len, char *buf, char *end);
1882252190Srpaulo
1883252190Srpaulo/**
1884252190Srpaulo * p2p_parse_dev_addr_in_p2p_ie - Parse P2P Device Address from a concatenated
1885252190Srpaulo * P2P IE
1886252190Srpaulo * @p2p_ie: P2P IE
1887252190Srpaulo * @dev_addr: Buffer for returning P2P Device Address
1888252190Srpaulo * Returns: 0 on success or -1 if P2P Device Address could not be parsed
1889252190Srpaulo */
1890252190Srpauloint p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr);
1891252190Srpaulo
1892252190Srpaulo/**
1893252190Srpaulo * p2p_parse_dev_addr - Parse P2P Device Address from P2P IE(s)
1894252190Srpaulo * @ies: Information elements from scan results
1895252190Srpaulo * @ies_len: ies buffer length in octets
1896252190Srpaulo * @dev_addr: Buffer for returning P2P Device Address
1897252190Srpaulo * Returns: 0 on success or -1 if P2P Device Address could not be parsed
1898252190Srpaulo */
1899252190Srpauloint p2p_parse_dev_addr(const u8 *ies, size_t ies_len, u8 *dev_addr);
1900252190Srpaulo
1901252190Srpaulo/**
1902252190Srpaulo * p2p_assoc_req_ie - Build P2P IE for (Re)Association Request frame
1903252190Srpaulo * @p2p: P2P module context from p2p_init()
1904252190Srpaulo * @bssid: BSSID
1905252190Srpaulo * @buf: Buffer for writing the P2P IE
1906252190Srpaulo * @len: Maximum buf length in octets
1907252190Srpaulo * @p2p_group: Whether this is for association with a P2P GO
1908252190Srpaulo * @p2p_ie: Reassembled P2P IE data from scan results or %NULL if none
1909252190Srpaulo * Returns: Number of octets written into buf or -1 on failure
1910252190Srpaulo */
1911252190Srpauloint p2p_assoc_req_ie(struct p2p_data *p2p, const u8 *bssid, u8 *buf,
1912252190Srpaulo		     size_t len, int p2p_group, struct wpabuf *p2p_ie);
1913252190Srpaulo
1914252190Srpaulo/**
1915252190Srpaulo * p2p_scan_ie - Build P2P IE for Probe Request
1916252190Srpaulo * @p2p: P2P module context from p2p_init()
1917252190Srpaulo * @ies: Buffer for writing P2P IE
1918252190Srpaulo * @dev_id: Device ID to search for or %NULL for any
1919337817Scy * @bands: Frequency bands used in the scan (enum wpa_radio_work_band bitmap)
1920252190Srpaulo */
1921337817Scyvoid p2p_scan_ie(struct p2p_data *p2p, struct wpabuf *ies, const u8 *dev_id,
1922337817Scy		 unsigned int bands);
1923252190Srpaulo
1924252190Srpaulo/**
1925252190Srpaulo * p2p_scan_ie_buf_len - Get maximum buffer length needed for p2p_scan_ie
1926252190Srpaulo * @p2p: P2P module context from p2p_init()
1927252190Srpaulo * Returns: Number of octets that p2p_scan_ie() may add to the buffer
1928252190Srpaulo */
1929252190Srpaulosize_t p2p_scan_ie_buf_len(struct p2p_data *p2p);
1930252190Srpaulo
1931252190Srpaulo/**
1932252190Srpaulo * p2p_go_params - Generate random P2P group parameters
1933252190Srpaulo * @p2p: P2P module context from p2p_init()
1934252190Srpaulo * @params: Buffer for parameters
1935252190Srpaulo * Returns: 0 on success, -1 on failure
1936252190Srpaulo */
1937252190Srpauloint p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params);
1938252190Srpaulo
1939252190Srpaulo/**
1940252190Srpaulo * p2p_get_group_capab - Get Group Capability from P2P IE data
1941252190Srpaulo * @p2p_ie: P2P IE(s) contents
1942252190Srpaulo * Returns: Group Capability
1943252190Srpaulo */
1944252190Srpaulou8 p2p_get_group_capab(const struct wpabuf *p2p_ie);
1945252190Srpaulo
1946252190Srpaulo/**
1947252190Srpaulo * p2p_get_cross_connect_disallowed - Does WLAN AP disallows cross connection
1948252190Srpaulo * @p2p_ie: P2P IE(s) contents
1949252190Srpaulo * Returns: 0 if cross connection is allow, 1 if not
1950252190Srpaulo */
1951252190Srpauloint p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie);
1952252190Srpaulo
1953252190Srpaulo/**
1954252190Srpaulo * p2p_get_go_dev_addr - Get P2P Device Address from P2P IE data
1955252190Srpaulo * @p2p_ie: P2P IE(s) contents
1956252190Srpaulo * Returns: Pointer to P2P Device Address or %NULL if not included
1957252190Srpaulo */
1958252190Srpauloconst u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie);
1959252190Srpaulo
1960252190Srpaulo/**
1961252190Srpaulo * p2p_get_peer_info - Get P2P peer information
1962252190Srpaulo * @p2p: P2P module context from p2p_init()
1963252190Srpaulo * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
1964252190Srpaulo * @next: Whether to select the peer entry following the one indicated by addr
1965252190Srpaulo * Returns: Pointer to peer info or %NULL if not found
1966252190Srpaulo */
1967252190Srpauloconst struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p,
1968252190Srpaulo					       const u8 *addr, int next);
1969252190Srpaulo
1970252190Srpaulo/**
1971252190Srpaulo * p2p_get_peer_info_txt - Get internal P2P peer information in text format
1972252190Srpaulo * @info: Pointer to P2P peer info from p2p_get_peer_info()
1973252190Srpaulo * @buf: Buffer for returning text
1974252190Srpaulo * @buflen: Maximum buffer length
1975252190Srpaulo * Returns: Number of octets written to the buffer or -1 on failure
1976252190Srpaulo *
1977252190Srpaulo * Note: This information is internal to the P2P module and subject to change.
1978252190Srpaulo * As such, this should not really be used by external programs for purposes
1979252190Srpaulo * other than debugging.
1980252190Srpaulo */
1981252190Srpauloint p2p_get_peer_info_txt(const struct p2p_peer_info *info,
1982252190Srpaulo			  char *buf, size_t buflen);
1983252190Srpaulo
1984252190Srpaulo/**
1985252190Srpaulo * p2p_peer_known - Check whether P2P peer is known
1986252190Srpaulo * @p2p: P2P module context from p2p_init()
1987252190Srpaulo * @addr: P2P Device Address of the peer
1988252190Srpaulo * Returns: 1 if the specified device is in the P2P peer table or 0 if not
1989252190Srpaulo */
1990252190Srpauloint p2p_peer_known(struct p2p_data *p2p, const u8 *addr);
1991252190Srpaulo
1992252190Srpaulo/**
1993252190Srpaulo * p2p_set_client_discoverability - Set client discoverability capability
1994252190Srpaulo * @p2p: P2P module context from p2p_init()
1995252190Srpaulo * @enabled: Whether client discoverability will be enabled
1996252190Srpaulo *
1997252190Srpaulo * This function can be used to disable (and re-enable) client discoverability.
1998252190Srpaulo * This capability is enabled by default and should not be disabled in normal
1999252190Srpaulo * use cases, i.e., this is mainly for testing purposes.
2000252190Srpaulo */
2001252190Srpaulovoid p2p_set_client_discoverability(struct p2p_data *p2p, int enabled);
2002252190Srpaulo
2003252190Srpaulo/**
2004252190Srpaulo * p2p_set_managed_oper - Set managed P2P Device operations capability
2005252190Srpaulo * @p2p: P2P module context from p2p_init()
2006252190Srpaulo * @enabled: Whether managed P2P Device operations will be enabled
2007252190Srpaulo */
2008252190Srpaulovoid p2p_set_managed_oper(struct p2p_data *p2p, int enabled);
2009252190Srpaulo
2010281806Srpaulo/**
2011281806Srpaulo * p2p_config_get_random_social - Return a random social channel
2012281806Srpaulo * @p2p: P2P config
2013281806Srpaulo * @op_class: Selected operating class
2014281806Srpaulo * @op_channel: Selected social channel
2015346981Scy * @avoid_list: Channel ranges to try to avoid or %NULL
2016346981Scy * @disallow_list: Channel ranges to discard or %NULL
2017281806Srpaulo * Returns: 0 on success, -1 on failure
2018281806Srpaulo *
2019281806Srpaulo * This function is used before p2p_init is called. A random social channel
2020281806Srpaulo * from supports bands 2.4 GHz (channels 1,6,11) and 60 GHz (channel 2) is
2021281806Srpaulo * returned on success.
2022281806Srpaulo */
2023281806Srpauloint p2p_config_get_random_social(struct p2p_config *p2p, u8 *op_class,
2024346981Scy				 u8 *op_channel,
2025346981Scy				 struct wpa_freq_range_list *avoid_list,
2026346981Scy				 struct wpa_freq_range_list *disallow_list);
2027252190Srpaulo
2028281806Srpauloint p2p_set_listen_channel(struct p2p_data *p2p, u8 reg_class, u8 channel,
2029281806Srpaulo			   u8 forced);
2030281806Srpaulo
2031281806Srpaulou8 p2p_get_listen_channel(struct p2p_data *p2p);
2032281806Srpaulo
2033252190Srpauloint p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len);
2034252190Srpaulo
2035252190Srpauloint p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
2036252190Srpaulo			   u8 *iface_addr);
2037252190Srpauloint p2p_get_dev_addr(struct p2p_data *p2p, const u8 *iface_addr,
2038252190Srpaulo			   u8 *dev_addr);
2039252190Srpaulo
2040252190Srpaulovoid p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
2041252190Srpaulo
2042252190Srpaulo/**
2043252190Srpaulo * p2p_set_cross_connect - Set cross connection capability
2044252190Srpaulo * @p2p: P2P module context from p2p_init()
2045252190Srpaulo * @enabled: Whether cross connection will be enabled
2046252190Srpaulo */
2047252190Srpaulovoid p2p_set_cross_connect(struct p2p_data *p2p, int enabled);
2048252190Srpaulo
2049252190Srpauloint p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr);
2050252190Srpaulo
2051252190Srpaulo/**
2052252190Srpaulo * p2p_set_intra_bss_dist - Set intra BSS distribution
2053252190Srpaulo * @p2p: P2P module context from p2p_init()
2054252190Srpaulo * @enabled: Whether intra BSS distribution will be enabled
2055252190Srpaulo */
2056252190Srpaulovoid p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled);
2057252190Srpaulo
2058281806Srpauloint p2p_channels_includes_freq(const struct p2p_channels *channels,
2059281806Srpaulo			       unsigned int freq);
2060281806Srpaulo
2061281806Srpauloint p2p_channels_to_freqs(const struct p2p_channels *channels,
2062281806Srpaulo			  int *freq_list, unsigned int max_len);
2063281806Srpaulo
2064252190Srpaulo/**
2065252190Srpaulo * p2p_supported_freq - Check whether channel is supported for P2P
2066252190Srpaulo * @p2p: P2P module context from p2p_init()
2067252190Srpaulo * @freq: Channel frequency in MHz
2068252190Srpaulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
2069252190Srpaulo */
2070252190Srpauloint p2p_supported_freq(struct p2p_data *p2p, unsigned int freq);
2071252190Srpaulo
2072281806Srpaulo/**
2073281806Srpaulo * p2p_supported_freq_go - Check whether channel is supported for P2P GO operation
2074281806Srpaulo * @p2p: P2P module context from p2p_init()
2075281806Srpaulo * @freq: Channel frequency in MHz
2076281806Srpaulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
2077281806Srpaulo */
2078281806Srpauloint p2p_supported_freq_go(struct p2p_data *p2p, unsigned int freq);
2079252190Srpaulo
2080252190Srpaulo/**
2081281806Srpaulo * p2p_supported_freq_cli - Check whether channel is supported for P2P client operation
2082281806Srpaulo * @p2p: P2P module context from p2p_init()
2083281806Srpaulo * @freq: Channel frequency in MHz
2084281806Srpaulo * Returns: 0 if channel not usable for P2P, 1 if usable for P2P
2085281806Srpaulo */
2086281806Srpauloint p2p_supported_freq_cli(struct p2p_data *p2p, unsigned int freq);
2087281806Srpaulo
2088281806Srpaulo/**
2089281806Srpaulo * p2p_get_pref_freq - Get channel from preferred channel list
2090281806Srpaulo * @p2p: P2P module context from p2p_init()
2091281806Srpaulo * @channels: List of channels
2092281806Srpaulo * Returns: Preferred channel
2093281806Srpaulo */
2094281806Srpaulounsigned int p2p_get_pref_freq(struct p2p_data *p2p,
2095281806Srpaulo			       const struct p2p_channels *channels);
2096281806Srpaulo
2097281806Srpaulovoid p2p_update_channel_list(struct p2p_data *p2p,
2098281806Srpaulo			     const struct p2p_channels *chan,
2099281806Srpaulo			     const struct p2p_channels *cli_chan);
2100281806Srpaulo
2101281806Srpaulo/**
2102252190Srpaulo * p2p_set_best_channels - Update best channel information
2103252190Srpaulo * @p2p: P2P module context from p2p_init()
2104252190Srpaulo * @freq_24: Frequency (MHz) of best channel in 2.4 GHz band
2105252190Srpaulo * @freq_5: Frequency (MHz) of best channel in 5 GHz band
2106252190Srpaulo * @freq_overall: Frequency (MHz) of best channel overall
2107252190Srpaulo */
2108252190Srpaulovoid p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
2109252190Srpaulo			   int freq_overall);
2110252190Srpaulo
2111281806Srpaulo/**
2112281806Srpaulo * p2p_set_own_freq_preference - Set own preference for channel
2113281806Srpaulo * @p2p: P2P module context from p2p_init()
2114281806Srpaulo * @freq: Frequency (MHz) of the preferred channel or 0 if no preference
2115281806Srpaulo *
2116281806Srpaulo * This function can be used to set a preference on the operating channel based
2117281806Srpaulo * on frequencies used on the other virtual interfaces that share the same
2118281806Srpaulo * radio. If non-zero, this is used to try to avoid multi-channel concurrency.
2119281806Srpaulo */
2120281806Srpaulovoid p2p_set_own_freq_preference(struct p2p_data *p2p, int freq);
2121281806Srpaulo
2122252190Srpauloconst u8 * p2p_get_go_neg_peer(struct p2p_data *p2p);
2123252190Srpaulo
2124252190Srpaulo/**
2125252190Srpaulo * p2p_get_group_num_members - Get number of members in group
2126252190Srpaulo * @group: P2P group context from p2p_group_init()
2127252190Srpaulo * Returns: Number of members in the group
2128252190Srpaulo */
2129252190Srpaulounsigned int p2p_get_group_num_members(struct p2p_group *group);
2130252190Srpaulo
2131252190Srpaulo/**
2132281806Srpaulo * p2p_client_limit_reached - Check if client limit is reached
2133281806Srpaulo * @group: P2P group context from p2p_group_init()
2134281806Srpaulo * Returns: 1 if no of clients limit reached
2135281806Srpaulo */
2136281806Srpauloint p2p_client_limit_reached(struct p2p_group *group);
2137281806Srpaulo
2138281806Srpaulo/**
2139252190Srpaulo * p2p_iterate_group_members - Iterate group members
2140252190Srpaulo * @group: P2P group context from p2p_group_init()
2141252190Srpaulo * @next: iteration pointer, must be a pointer to a void * that is set to %NULL
2142252190Srpaulo *	on the first call and not modified later
2143281806Srpaulo * Returns: A P2P Device Address for each call and %NULL for no more members
2144252190Srpaulo */
2145252190Srpauloconst u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
2146252190Srpaulo
2147252190Srpaulo/**
2148337817Scy * p2p_group_get_client_interface_addr - Get P2P Interface Address of a client in a group
2149337817Scy * @group: P2P group context from p2p_group_init()
2150337817Scy * @dev_addr: P2P Device Address of the client
2151337817Scy * Returns: P2P Interface Address of the client if found or %NULL if no match
2152337817Scy * found
2153337817Scy */
2154337817Scyconst u8 * p2p_group_get_client_interface_addr(struct p2p_group *group,
2155337817Scy					       const u8 *dev_addr);
2156337817Scy
2157337817Scy/**
2158252190Srpaulo * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group
2159252190Srpaulo * @group: P2P group context from p2p_group_init()
2160252190Srpaulo * @addr: P2P Interface Address of the client
2161252190Srpaulo * Returns: P2P Device Address of the client if found or %NULL if no match
2162252190Srpaulo * found
2163252190Srpaulo */
2164252190Srpauloconst u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
2165252190Srpaulo
2166252190Srpaulo/**
2167252190Srpaulo * p2p_group_is_client_connected - Check whether a specific client is connected
2168252190Srpaulo * @group: P2P group context from p2p_group_init()
2169252190Srpaulo * @addr: P2P Device Address of the client
2170252190Srpaulo * Returns: 1 if client is connected or 0 if not
2171252190Srpaulo */
2172252190Srpauloint p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr);
2173252190Srpaulo
2174252190Srpaulo/**
2175281806Srpaulo * p2p_group_get_config - Get the group configuration
2176281806Srpaulo * @group: P2P group context from p2p_group_init()
2177281806Srpaulo * Returns: The group configuration pointer
2178281806Srpaulo */
2179281806Srpauloconst struct p2p_group_config * p2p_group_get_config(struct p2p_group *group);
2180281806Srpaulo
2181281806Srpaulo/**
2182281806Srpaulo * p2p_loop_on_all_groups - Run the given callback on all groups
2183281806Srpaulo * @p2p: P2P module context from p2p_init()
2184281806Srpaulo * @group_callback: The callback function pointer
2185281806Srpaulo * @user_data: Some user data pointer which can be %NULL
2186281806Srpaulo *
2187281806Srpaulo * The group_callback function can stop the iteration by returning 0.
2188281806Srpaulo */
2189281806Srpaulovoid p2p_loop_on_all_groups(struct p2p_data *p2p,
2190281806Srpaulo			    int (*group_callback)(struct p2p_group *group,
2191281806Srpaulo						  void *user_data),
2192281806Srpaulo			    void *user_data);
2193281806Srpaulo
2194281806Srpaulo/**
2195252190Srpaulo * p2p_get_peer_found - Get P2P peer info structure of a found peer
2196252190Srpaulo * @p2p: P2P module context from p2p_init()
2197252190Srpaulo * @addr: P2P Device Address of the peer or %NULL to indicate the first peer
2198252190Srpaulo * @next: Whether to select the peer entry following the one indicated by addr
2199252190Srpaulo * Returns: The first P2P peer info available or %NULL if no such peer exists
2200252190Srpaulo */
2201252190Srpauloconst struct p2p_peer_info *
2202252190Srpaulop2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
2203252190Srpaulo
2204252190Srpaulo/**
2205252190Srpaulo * p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions
2206252190Srpaulo * @p2p: P2P module context from p2p_init()
2207252190Srpaulo */
2208252190Srpaulovoid p2p_remove_wps_vendor_extensions(struct p2p_data *p2p);
2209252190Srpaulo
2210252190Srpaulo/**
2211252190Srpaulo * p2p_add_wps_vendor_extension - Add a WPS vendor extension
2212252190Srpaulo * @p2p: P2P module context from p2p_init()
2213252190Srpaulo * @vendor_ext: The vendor extensions to add
2214252190Srpaulo * Returns: 0 on success, -1 on failure
2215252190Srpaulo *
2216252190Srpaulo * The wpabuf structures in the array are owned by the P2P
2217252190Srpaulo * module after this call.
2218252190Srpaulo */
2219252190Srpauloint p2p_add_wps_vendor_extension(struct p2p_data *p2p,
2220252190Srpaulo				 const struct wpabuf *vendor_ext);
2221252190Srpaulo
2222252190Srpaulo/**
2223252190Srpaulo * p2p_set_oper_channel - Set the P2P operating channel
2224252190Srpaulo * @p2p: P2P module context from p2p_init()
2225252190Srpaulo * @op_reg_class: Operating regulatory class to set
2226252190Srpaulo * @op_channel: operating channel to set
2227252190Srpaulo * @cfg_op_channel : Whether op_channel is hardcoded in configuration
2228252190Srpaulo * Returns: 0 on success, -1 on failure
2229252190Srpaulo */
2230252190Srpauloint p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
2231252190Srpaulo			 int cfg_op_channel);
2232252190Srpaulo
2233252190Srpaulo/**
2234252190Srpaulo * p2p_set_pref_chan - Set P2P preferred channel list
2235252190Srpaulo * @p2p: P2P module context from p2p_init()
2236252190Srpaulo * @num_pref_chan: Number of entries in pref_chan list
2237252190Srpaulo * @pref_chan: Preferred channels or %NULL to remove preferences
2238252190Srpaulo * Returns: 0 on success, -1 on failure
2239252190Srpaulo */
2240252190Srpauloint p2p_set_pref_chan(struct p2p_data *p2p, unsigned int num_pref_chan,
2241252190Srpaulo		      const struct p2p_channel *pref_chan);
2242252190Srpaulo
2243252190Srpaulo/**
2244281806Srpaulo * p2p_set_no_go_freq - Set no GO channel ranges
2245252190Srpaulo * @p2p: P2P module context from p2p_init()
2246281806Srpaulo * @list: Channel ranges or %NULL to remove restriction
2247281806Srpaulo * Returns: 0 on success, -1 on failure
2248252190Srpaulo */
2249281806Srpauloint p2p_set_no_go_freq(struct p2p_data *p2p,
2250281806Srpaulo		       const struct wpa_freq_range_list *list);
2251252190Srpaulo
2252252190Srpaulo/**
2253281806Srpaulo * p2p_in_progress - Check whether a P2P operation is progress
2254252190Srpaulo * @p2p: P2P module context from p2p_init()
2255281806Srpaulo * Returns: 0 if P2P module is idle, 1 if an operation is in progress but not
2256281806Srpaulo * in search state, or 2 if search state operation is in progress
2257252190Srpaulo */
2258281806Srpauloint p2p_in_progress(struct p2p_data *p2p);
2259252190Srpaulo
2260252190Srpauloconst char * p2p_wps_method_text(enum p2p_wps_method method);
2261252190Srpaulo
2262252190Srpaulo/**
2263252190Srpaulo * p2p_set_config_timeout - Set local config timeouts
2264252190Srpaulo * @p2p: P2P module context from p2p_init()
2265252190Srpaulo * @go_timeout: Time in 10 ms units it takes to start the GO mode
2266252190Srpaulo * @client_timeout: Time in 10 ms units it takes to start the client mode
2267252190Srpaulo */
2268252190Srpaulovoid p2p_set_config_timeout(struct p2p_data *p2p, u8 go_timeout,
2269252190Srpaulo			    u8 client_timeout);
2270252190Srpaulo
2271252190Srpauloint p2p_set_wfd_ie_beacon(struct p2p_data *p2p, struct wpabuf *ie);
2272252190Srpauloint p2p_set_wfd_ie_probe_req(struct p2p_data *p2p, struct wpabuf *ie);
2273252190Srpauloint p2p_set_wfd_ie_probe_resp(struct p2p_data *p2p, struct wpabuf *ie);
2274252190Srpauloint p2p_set_wfd_ie_assoc_req(struct p2p_data *p2p, struct wpabuf *ie);
2275252190Srpauloint p2p_set_wfd_ie_invitation(struct p2p_data *p2p, struct wpabuf *ie);
2276252190Srpauloint p2p_set_wfd_ie_prov_disc_req(struct p2p_data *p2p, struct wpabuf *ie);
2277252190Srpauloint p2p_set_wfd_ie_prov_disc_resp(struct p2p_data *p2p, struct wpabuf *ie);
2278252190Srpauloint p2p_set_wfd_ie_go_neg(struct p2p_data *p2p, struct wpabuf *ie);
2279252190Srpauloint p2p_set_wfd_dev_info(struct p2p_data *p2p, const struct wpabuf *elem);
2280346981Scyint p2p_set_wfd_r2_dev_info(struct p2p_data *p2p, const struct wpabuf *elem);
2281252190Srpauloint p2p_set_wfd_assoc_bssid(struct p2p_data *p2p, const struct wpabuf *elem);
2282252190Srpauloint p2p_set_wfd_coupled_sink_info(struct p2p_data *p2p,
2283252190Srpaulo				  const struct wpabuf *elem);
2284252190Srpaulostruct wpabuf * wifi_display_encaps(struct wpabuf *subelems);
2285252190Srpaulo
2286252190Srpaulo/**
2287252190Srpaulo * p2p_set_disc_int - Set min/max discoverable interval for p2p_find
2288252190Srpaulo * @p2p: P2P module context from p2p_init()
2289252190Srpaulo * @min_disc_int: minDiscoverableInterval (in units of 100 TU); default 1
2290252190Srpaulo * @max_disc_int: maxDiscoverableInterval (in units of 100 TU); default 3
2291252190Srpaulo * @max_disc_tu: Maximum number of TUs (1.024 ms) for discoverable interval; or
2292252190Srpaulo *	-1 not to limit
2293252190Srpaulo * Returns: 0 on success, or -1 on failure
2294252190Srpaulo *
2295252190Srpaulo * This function can be used to configure minDiscoverableInterval and
2296252190Srpaulo * maxDiscoverableInterval parameters for the Listen state during device
2297252190Srpaulo * discovery (p2p_find). A random number of 100 TU units is picked for each
2298252190Srpaulo * Listen state iteration from [min_disc_int,max_disc_int] range.
2299252190Srpaulo *
2300337817Scy * max_disc_tu can be used to further limit the discoverable duration. However,
2301252190Srpaulo * it should be noted that use of this parameter is not recommended since it
2302252190Srpaulo * would not be compliant with the P2P specification.
2303252190Srpaulo */
2304252190Srpauloint p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int,
2305252190Srpaulo		     int max_disc_tu);
2306252190Srpaulo
2307281806Srpaulo/**
2308281806Srpaulo * p2p_get_state_txt - Get current P2P state for debug purposes
2309281806Srpaulo * @p2p: P2P module context from p2p_init()
2310281806Srpaulo * Returns: Name of the current P2P module state
2311281806Srpaulo *
2312281806Srpaulo * It should be noted that the P2P module state names are internal information
2313281806Srpaulo * and subject to change at any point, i.e., this information should be used
2314281806Srpaulo * mainly for debugging purposes.
2315281806Srpaulo */
2316281806Srpauloconst char * p2p_get_state_txt(struct p2p_data *p2p);
2317281806Srpaulo
2318281806Srpaulostruct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p,
2319281806Srpaulo					   int client_freq,
2320281806Srpaulo					   const u8 *go_dev_addr,
2321281806Srpaulo					   const u8 *ssid, size_t ssid_len);
2322281806Srpaulostruct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p,
2323281806Srpaulo					   int client_freq,
2324281806Srpaulo					   const u8 *go_dev_addr,
2325281806Srpaulo					   const u8 *ssid, size_t ssid_len);
2326281806Srpaulo
2327281806Srpaulostruct p2p_nfc_params {
2328281806Srpaulo	int sel;
2329281806Srpaulo	const u8 *wsc_attr;
2330281806Srpaulo	size_t wsc_len;
2331281806Srpaulo	const u8 *p2p_attr;
2332281806Srpaulo	size_t p2p_len;
2333281806Srpaulo
2334281806Srpaulo	enum {
2335281806Srpaulo		NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG,
2336281806Srpaulo		BOTH_GO, PEER_CLIENT
2337281806Srpaulo	} next_step;
2338281806Srpaulo	struct p2p_peer_info *peer;
2339281806Srpaulo	u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 +
2340281806Srpaulo		      WPS_OOB_DEVICE_PASSWORD_LEN];
2341281806Srpaulo	size_t oob_dev_pw_len;
2342281806Srpaulo	int go_freq;
2343281806Srpaulo	u8 go_dev_addr[ETH_ALEN];
2344289549Srpaulo	u8 go_ssid[SSID_MAX_LEN];
2345281806Srpaulo	size_t go_ssid_len;
2346281806Srpaulo};
2347281806Srpaulo
2348281806Srpauloint p2p_process_nfc_connection_handover(struct p2p_data *p2p,
2349281806Srpaulo					struct p2p_nfc_params *params);
2350281806Srpaulo
2351281806Srpaulovoid p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id,
2352281806Srpaulo				      int go_intent,
2353281806Srpaulo				      const u8 *own_interface_addr);
2354281806Srpaulo
2355281806Srpauloint p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len);
2356281806Srpaulo
2357281806Srpaulovoid p2p_loop_on_known_peers(struct p2p_data *p2p,
2358281806Srpaulo			     void (*peer_callback)(struct p2p_peer_info *peer,
2359281806Srpaulo						   void *user_data),
2360281806Srpaulo			     void *user_data);
2361281806Srpaulo
2362281806Srpaulovoid p2p_set_vendor_elems(struct p2p_data *p2p, struct wpabuf **vendor_elem);
2363281806Srpaulo
2364281806Srpaulovoid p2p_set_intended_addr(struct p2p_data *p2p, const u8 *intended_addr);
2365281806Srpaulo
2366281806Srpaulostruct p2ps_advertisement *
2367281806Srpaulop2p_service_p2ps_id(struct p2p_data *p2p, u32 adv_id);
2368281806Srpauloint p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id,
2369281806Srpaulo			const char *adv_str, u8 svc_state,
2370289549Srpaulo			u16 config_methods, const char *svc_info,
2371289549Srpaulo			const u8 *cpt_priority);
2372281806Srpauloint p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id);
2373289549Srpaulovoid p2p_service_flush_asp(struct p2p_data *p2p);
2374281806Srpaulostruct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p);
2375281806Srpaulo
2376289549Srpaulo/**
2377289549Srpaulo * p2p_expire_peers - Periodic cleanup function to expire peers
2378289549Srpaulo * @p2p: P2P module context from p2p_init()
2379289549Srpaulo *
2380289549Srpaulo * This is a cleanup function that the entity calling p2p_init() is
2381289549Srpaulo * expected to call periodically to clean up expired peer entries.
2382289549Srpaulo */
2383289549Srpaulovoid p2p_expire_peers(struct p2p_data *p2p);
2384289549Srpaulo
2385289549Srpaulovoid p2p_set_own_pref_freq_list(struct p2p_data *p2p,
2386289549Srpaulo				const unsigned int *pref_freq_list,
2387289549Srpaulo				unsigned int size);
2388346981Scyvoid p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class,
2389346981Scy				   u8 chan);
2390289549Srpaulo
2391289549Srpaulo/**
2392289549Srpaulo * p2p_group_get_common_freqs - Get the group common frequencies
2393289549Srpaulo * @group: P2P group context from p2p_group_init()
2394289549Srpaulo * @common_freqs: On return will hold the group common frequencies
2395289549Srpaulo * @num: On return will hold the number of group common frequencies
2396289549Srpaulo * Returns: 0 on success, -1 otherwise
2397289549Srpaulo */
2398289549Srpauloint p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
2399289549Srpaulo			       unsigned int *num);
2400289549Srpaulo
2401337817Scystruct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p,
2402337817Scy					      unsigned int freq);
2403337817Scy
2404252190Srpaulo#endif /* P2P_H */
2405