1/*
2 * Copyright (C) 2015, Broadcom Corporation. All Rights Reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 *
16 * Fundamental types and constants relating to WFA P2P (aka WiFi Direct)
17 *
18 * $Id: p2p.h 448413 2014-01-14 07:22:25Z $
19 */
20
21#ifndef _P2P_H_
22#define _P2P_H_
23
24#ifndef _TYPEDEFS_H_
25#include <typedefs.h>
26#endif
27#include <wlioctl.h>
28#include <proto/802.11.h>
29
30/* This marks the start of a packed structure section. */
31#include <packed_section_start.h>
32
33
34/* WiFi P2P OUI values */
35#define P2P_OUI			WFA_OUI			/* WiFi P2P OUI */
36#define P2P_VER			WFA_OUI_TYPE_P2P	/* P2P version: 9=WiFi P2P v1.0 */
37
38#define P2P_IE_ID		0xdd			/* P2P IE element ID */
39
40/* WiFi P2P IE */
41BWL_PRE_PACKED_STRUCT struct wifi_p2p_ie {
42	uint8	id;		/* IE ID: 0xDD */
43	uint8	len;		/* IE length */
44	uint8	OUI[3];		/* WiFi P2P specific OUI: P2P_OUI */
45	uint8	oui_type;	/* Identifies P2P version: P2P_VER */
46	uint8	subelts[1];	/* variable length subelements */
47} BWL_POST_PACKED_STRUCT;
48typedef struct wifi_p2p_ie wifi_p2p_ie_t;
49
50#define P2P_IE_FIXED_LEN	6
51
52#define P2P_ATTR_ID_OFF		0
53#define P2P_ATTR_LEN_OFF	1
54#define P2P_ATTR_DATA_OFF	3
55
56#define P2P_ATTR_ID_LEN		1	/* ID filed length */
57#define P2P_ATTR_LEN_LEN	2	/* length field length */
58#define P2P_ATTR_HDR_LEN	3 /* ID + 2-byte length field spec 1.02 */
59
60#ifdef WLWFDS
61#define P2P_WFDS_HASH_LEN		6
62#define P2P_WFDS_MAX_SVC_NAME_LEN	32
63#endif
64
65/* P2P IE Subelement IDs from WiFi P2P Technical Spec 1.00 */
66#define P2P_SEID_STATUS			0	/* Status */
67#define P2P_SEID_MINOR_RC		1	/* Minor Reason Code */
68#define P2P_SEID_P2P_INFO		2	/* P2P Capability (capabilities info) */
69#define P2P_SEID_DEV_ID			3	/* P2P Device ID */
70#define P2P_SEID_INTENT			4	/* Group Owner Intent */
71#define P2P_SEID_CFG_TIMEOUT		5	/* Configuration Timeout */
72#define P2P_SEID_CHANNEL		6	/* Listen channel */
73#define P2P_SEID_GRP_BSSID		7	/* P2P Group BSSID */
74#define P2P_SEID_XT_TIMING		8	/* Extended Listen Timing */
75#define P2P_SEID_INTINTADDR		9	/* Intended P2P Interface Address */
76#define P2P_SEID_P2P_MGBTY		10	/* P2P Manageability */
77#define P2P_SEID_CHAN_LIST		11	/* Channel List */
78#define P2P_SEID_ABSENCE		12	/* Notice of Absence */
79#define P2P_SEID_DEV_INFO		13	/* Device Info */
80#define P2P_SEID_GROUP_INFO		14	/* Group Info */
81#define P2P_SEID_GROUP_ID		15	/* Group ID */
82#define P2P_SEID_P2P_IF			16	/* P2P Interface */
83#define P2P_SEID_OP_CHANNEL		17	/* Operating Channel */
84#define P2P_SEID_INVITE_FLAGS		18	/* Invitation Flags */
85#ifdef WLWFDS
86#define P2P_SEID_SERV_HASH			21	/* service hash */
87#define P2P_SEID_SSN_INST_DATA	22	/* service instance data */
88#define P2P_SEID_CONN_CAP			23	/* connection capability */
89#define P2P_SEID_ADV_ID			24	/* Advertisement ID */
90#define P2P_SEID_ADV_SERV			25	/*  service information from advertiser */
91#define P2P_SEID_SSN_ID				26	/*  Session ID */
92#define P2P_SEID_FEATURE_CAP		27	/*  feauture capability */
93#define P2P_SEID_PERSIST_GRP_INFO 28	/*  persistant group info if both indicate the group */
94#define P2P_SEID_SSN_INFO_RESP	29	/*  Session Info Response for deffered case */
95#endif /* WLWFDS */
96#define P2P_SEID_VNDR			221	/* Vendor-specific subelement */
97
98#define P2P_SE_VS_ID_SERVICES	0x1b
99
100
101/* WiFi P2P IE subelement: P2P Capability (capabilities info) */
102BWL_PRE_PACKED_STRUCT struct wifi_p2p_info_se_s {
103	uint8	eltId;		/* SE ID: P2P_SEID_P2P_INFO */
104	uint8	len[2];		/* SE length not including eltId, len fields */
105	uint8	dev;		/* Device Capability Bitmap */
106	uint8	group;		/* Group Capability Bitmap */
107} BWL_POST_PACKED_STRUCT;
108typedef struct wifi_p2p_info_se_s wifi_p2p_info_se_t;
109
110/* P2P Capability subelement's Device Capability Bitmap bit values */
111#define P2P_CAPSE_DEV_SERVICE_DIS	0x1 /* Service Discovery */
112#define P2P_CAPSE_DEV_CLIENT_DIS	0x2 /* Client Discoverability */
113#define P2P_CAPSE_DEV_CONCURRENT	0x4 /* Concurrent Operation */
114#define P2P_CAPSE_DEV_INFRA_MAN		0x8 /* P2P Infrastructure Managed */
115#define P2P_CAPSE_DEV_LIMIT			0x10 /* P2P Device Limit */
116#define P2P_CAPSE_INVITE_PROC		0x20 /* P2P Invitation Procedure */
117
118/* P2P Capability subelement's Group Capability Bitmap bit values */
119#define P2P_CAPSE_GRP_OWNER			0x1 /* P2P Group Owner */
120#define P2P_CAPSE_PERSIST_GRP		0x2 /* Persistent P2P Group */
121#define P2P_CAPSE_GRP_LIMIT			0x4 /* P2P Group Limit */
122#define P2P_CAPSE_GRP_INTRA_BSS		0x8 /* Intra-BSS Distribution */
123#define P2P_CAPSE_GRP_X_CONNECT		0x10 /* Cross Connection */
124#define P2P_CAPSE_GRP_PERSISTENT	0x20 /* Persistent Reconnect */
125#define P2P_CAPSE_GRP_FORMATION		0x40 /* Group Formation */
126
127
128/* WiFi P2P IE subelement: Group Owner Intent */
129BWL_PRE_PACKED_STRUCT struct wifi_p2p_intent_se_s {
130	uint8	eltId;		/* SE ID: P2P_SEID_INTENT */
131	uint8	len[2];		/* SE length not including eltId, len fields */
132	uint8	intent;		/* Intent Value 0...15 (0=legacy 15=master only) */
133} BWL_POST_PACKED_STRUCT;
134typedef struct wifi_p2p_intent_se_s wifi_p2p_intent_se_t;
135
136/* WiFi P2P IE subelement: Configuration Timeout */
137BWL_PRE_PACKED_STRUCT struct wifi_p2p_cfg_tmo_se_s {
138	uint8	eltId;		/* SE ID: P2P_SEID_CFG_TIMEOUT */
139	uint8	len[2];		/* SE length not including eltId, len fields */
140	uint8	go_tmo;		/* GO config timeout in units of 10 ms */
141	uint8	client_tmo;	/* Client config timeout in units of 10 ms */
142} BWL_POST_PACKED_STRUCT;
143typedef struct wifi_p2p_cfg_tmo_se_s wifi_p2p_cfg_tmo_se_t;
144
145/* WiFi P2P IE subelement: Listen Channel */
146BWL_PRE_PACKED_STRUCT struct wifi_p2p_listen_channel_se_s {
147	uint8	eltId;		/* SE ID: P2P_SEID_CHANNEL */
148	uint8	len[2];		/* SE length not including eltId, len fields */
149	uint8	country[3];	/* Country String */
150	uint8	op_class;	/* Operating Class */
151	uint8	channel;	/* Channel */
152} BWL_POST_PACKED_STRUCT;
153typedef struct wifi_p2p_listen_channel_se_s wifi_p2p_listen_channel_se_t;
154
155/* WiFi P2P IE subelement: P2P Group BSSID */
156BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_bssid_se_s {
157	uint8	eltId;		/* SE ID: P2P_SEID_GRP_BSSID */
158	uint8	len[2];		/* SE length not including eltId, len fields */
159	uint8	mac[6];		/* P2P group bssid */
160} BWL_POST_PACKED_STRUCT;
161typedef struct wifi_p2p_grp_bssid_se_s wifi_p2p_grp_bssid_se_t;
162
163/* WiFi P2P IE subelement: P2P Group ID */
164BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_id_se_s {
165	uint8	eltId;		/* SE ID: P2P_SEID_GROUP_ID */
166	uint8	len[2];		/* SE length not including eltId, len fields */
167	uint8	mac[6];		/* P2P device address */
168	uint8	ssid[1];	/* ssid. device id. variable length */
169} BWL_POST_PACKED_STRUCT;
170typedef struct wifi_p2p_grp_id_se_s wifi_p2p_grp_id_se_t;
171
172/* WiFi P2P IE subelement: P2P Interface */
173BWL_PRE_PACKED_STRUCT struct wifi_p2p_intf_se_s {
174	uint8	eltId;		/* SE ID: P2P_SEID_P2P_IF */
175	uint8	len[2];		/* SE length not including eltId, len fields */
176	uint8	mac[6];		/* P2P device address */
177	uint8	ifaddrs;	/* P2P Interface Address count */
178	uint8	ifaddr[1][6];	/* P2P Interface Address list */
179} BWL_POST_PACKED_STRUCT;
180typedef struct wifi_p2p_intf_se_s wifi_p2p_intf_se_t;
181
182/* WiFi P2P IE subelement: Status */
183BWL_PRE_PACKED_STRUCT struct wifi_p2p_status_se_s {
184	uint8	eltId;		/* SE ID: P2P_SEID_STATUS */
185	uint8	len[2];		/* SE length not including eltId, len fields */
186	uint8	status;		/* Status Code: P2P_STATSE_* */
187} BWL_POST_PACKED_STRUCT;
188typedef struct wifi_p2p_status_se_s wifi_p2p_status_se_t;
189
190/* Status subelement Status Code definitions */
191#define P2P_STATSE_SUCCESS			0
192				/* Success */
193#define P2P_STATSE_FAIL_INFO_CURR_UNAVAIL	1
194				/* Failed, information currently unavailable */
195#define P2P_STATSE_PASSED_UP			P2P_STATSE_FAIL_INFO_CURR_UNAVAIL
196				/* Old name for above in P2P spec 1.08 and older */
197#define P2P_STATSE_FAIL_INCOMPAT_PARAMS		2
198				/* Failed, incompatible parameters */
199#define P2P_STATSE_FAIL_LIMIT_REACHED		3
200				/* Failed, limit reached */
201#define P2P_STATSE_FAIL_INVALID_PARAMS		4
202				/* Failed, invalid parameters */
203#define P2P_STATSE_FAIL_UNABLE_TO_ACCOM		5
204				/* Failed, unable to accomodate request */
205#define P2P_STATSE_FAIL_PROTO_ERROR		6
206				/* Failed, previous protocol error or disruptive behaviour */
207#define P2P_STATSE_FAIL_NO_COMMON_CHAN		7
208				/* Failed, no common channels */
209#define P2P_STATSE_FAIL_UNKNOWN_GROUP		8
210				/* Failed, unknown P2P Group */
211#define P2P_STATSE_FAIL_INTENT			9
212				/* Failed, both peers indicated Intent 15 in GO Negotiation */
213#define P2P_STATSE_FAIL_INCOMPAT_PROVIS		10
214				/* Failed, incompatible provisioning method */
215#define P2P_STATSE_FAIL_USER_REJECT		11
216				/* Failed, rejected by user */
217#ifdef WLWFDS
218#define P2P_STATSE_SUCCESS_USER_ACCEPT		12
219				/* Success, accepted by user */
220#endif /* WLWFDS */
221
222/* WiFi P2P IE attribute: Extended Listen Timing */
223BWL_PRE_PACKED_STRUCT struct wifi_p2p_ext_se_s {
224	uint8	eltId;		/* ID: P2P_SEID_EXT_TIMING */
225	uint8	len[2];		/* length not including eltId, len fields */
226	uint8	avail[2];	/* availibility period */
227	uint8	interval[2];	/* availibility interval */
228} BWL_POST_PACKED_STRUCT;
229typedef struct wifi_p2p_ext_se_s wifi_p2p_ext_se_t;
230
231#define P2P_EXT_MIN	10	/* minimum 10ms */
232
233/* WiFi P2P IE subelement: Intended P2P Interface Address */
234BWL_PRE_PACKED_STRUCT struct wifi_p2p_intintad_se_s {
235	uint8	eltId;		/* SE ID: P2P_SEID_INTINTADDR */
236	uint8	len[2];		/* SE length not including eltId, len fields */
237	uint8	mac[6];		/* intended P2P interface MAC address */
238} BWL_POST_PACKED_STRUCT;
239typedef struct wifi_p2p_intintad_se_s wifi_p2p_intintad_se_t;
240
241/* WiFi P2P IE subelement: Channel */
242BWL_PRE_PACKED_STRUCT struct wifi_p2p_channel_se_s {
243	uint8	eltId;		/* SE ID: P2P_SEID_STATUS */
244	uint8	len[2];		/* SE length not including eltId, len fields */
245	uint8	band;		/* Regulatory Class (band) */
246	uint8	channel;	/* Channel */
247} BWL_POST_PACKED_STRUCT;
248typedef struct wifi_p2p_channel_se_s wifi_p2p_channel_se_t;
249
250
251/* Channel Entry structure within the Channel List SE */
252BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_entry_s {
253	uint8	band;						/* Regulatory Class (band) */
254	uint8	num_channels;				/* # of channels in the channel list */
255	uint8	channels[WL_NUMCHANNELS];	/* Channel List */
256} BWL_POST_PACKED_STRUCT;
257typedef struct wifi_p2p_chanlist_entry_s wifi_p2p_chanlist_entry_t;
258#define WIFI_P2P_CHANLIST_SE_MAX_ENTRIES 2
259
260/* WiFi P2P IE subelement: Channel List */
261BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_se_s {
262	uint8	eltId;		/* SE ID: P2P_SEID_CHAN_LIST */
263	uint8	len[2];		/* SE length not including eltId, len fields */
264	uint8	country[3];	/* Country String */
265	uint8	num_entries;	/* # of channel entries */
266	wifi_p2p_chanlist_entry_t	entries[WIFI_P2P_CHANLIST_SE_MAX_ENTRIES];
267						/* Channel Entry List */
268} BWL_POST_PACKED_STRUCT;
269typedef struct wifi_p2p_chanlist_se_s wifi_p2p_chanlist_se_t;
270
271/* WiFi Primary Device Type structure */
272BWL_PRE_PACKED_STRUCT struct wifi_p2p_pri_devtype_s {
273	uint16	cat_id;		/* Category ID */
274	uint8	OUI[3];		/* WFA OUI: 0x0050F2 */
275	uint8	oui_type;	/* WPS_OUI_TYPE */
276	uint16	sub_cat_id;	/* Sub Category ID */
277} BWL_POST_PACKED_STRUCT;
278typedef struct wifi_p2p_pri_devtype_s wifi_p2p_pri_devtype_t;
279
280/* WiFi P2P Device Info Sub Element Primary Device Type Sub Category
281 * maximum values for each category
282 */
283#define P2P_DISE_SUBCATEGORY_MINVAL		1
284#define P2P_DISE_CATEGORY_COMPUTER		1
285#define P2P_DISE_SUBCATEGORY_COMPUTER_MAXVAL		8
286#define P2P_DISE_CATEGORY_INPUT_DEVICE		2
287#define P2P_DISE_SUBCATEGORY_INPUT_DEVICE_MAXVAL	9
288#define P2P_DISE_CATEGORY_PRINTER		3
289#define P2P_DISE_SUBCATEGORY_PRINTER_MAXVAL		5
290#define P2P_DISE_CATEGORY_CAMERA		4
291#define P2P_DISE_SUBCATEGORY_CAMERA_MAXVAL		4
292#define P2P_DISE_CATEGORY_STORAGE		5
293#define P2P_DISE_SUBCATEGORY_STORAGE_MAXVAL		1
294#define P2P_DISE_CATEGORY_NETWORK_INFRA		6
295#define P2P_DISE_SUBCATEGORY_NETWORK_INFRA_MAXVAL	4
296#define P2P_DISE_CATEGORY_DISPLAY		7
297#define P2P_DISE_SUBCATEGORY_DISPLAY_MAXVAL		4
298#define P2P_DISE_CATEGORY_MULTIMEDIA		8
299#define P2P_DISE_SUBCATEGORY_MULTIMEDIA_MAXVAL		6
300#define P2P_DISE_CATEGORY_GAMING		9
301#define P2P_DISE_SUBCATEGORY_GAMING_MAXVAL		5
302#define P2P_DISE_CATEGORY_TELEPHONE		10
303#define P2P_DISE_SUBCATEGORY_TELEPHONE_MAXVAL		5
304#define P2P_DISE_CATEGORY_AUDIO			11
305#define P2P_DISE_SUBCATEGORY_AUDIO_MAXVAL		6
306
307/* WiFi P2P IE's Device Info subelement */
308BWL_PRE_PACKED_STRUCT struct wifi_p2p_devinfo_se_s {
309	uint8	eltId;			/* SE ID: P2P_SEID_DEVINFO */
310	uint8	len[2];			/* SE length not including eltId, len fields */
311	uint8	mac[6];			/* P2P Device MAC address */
312	uint16	wps_cfg_meths;		/* Config Methods: reg_prototlv.h WPS_CONFMET_* */
313	uint8	pri_devtype[8];		/* Primary Device Type */
314} BWL_POST_PACKED_STRUCT;
315typedef struct wifi_p2p_devinfo_se_s wifi_p2p_devinfo_se_t;
316
317#define P2P_DEV_TYPE_LEN	8
318
319/* WiFi P2P IE's Group Info subelement Client Info Descriptor */
320BWL_PRE_PACKED_STRUCT struct wifi_p2p_cid_fixed_s {
321	uint8	len;
322	uint8	devaddr[ETHER_ADDR_LEN];	/* P2P Device Address */
323	uint8	ifaddr[ETHER_ADDR_LEN];		/* P2P Interface Address */
324	uint8	devcap;				/* Device Capability */
325	uint8	cfg_meths[2];			/* Config Methods: reg_prototlv.h WPS_CONFMET_* */
326	uint8	pridt[P2P_DEV_TYPE_LEN];	/* Primary Device Type */
327	uint8	secdts;				/* Number of Secondary Device Types */
328} BWL_POST_PACKED_STRUCT;
329typedef struct wifi_p2p_cid_fixed_s wifi_p2p_cid_fixed_t;
330
331/* WiFi P2P IE's Device ID subelement */
332BWL_PRE_PACKED_STRUCT struct wifi_p2p_devid_se_s {
333	uint8	eltId;
334	uint8	len[2];
335	struct ether_addr	addr;			/* P2P Device MAC address */
336} BWL_POST_PACKED_STRUCT;
337typedef struct wifi_p2p_devid_se_s wifi_p2p_devid_se_t;
338
339/* WiFi P2P IE subelement: P2P Manageability */
340BWL_PRE_PACKED_STRUCT struct wifi_p2p_mgbt_se_s {
341	uint8	eltId;		/* SE ID: P2P_SEID_P2P_MGBTY */
342	uint8	len[2];		/* SE length not including eltId, len fields */
343	uint8	mg_bitmap;	/* manageability bitmap */
344} BWL_POST_PACKED_STRUCT;
345typedef struct wifi_p2p_mgbt_se_s wifi_p2p_mgbt_se_t;
346/* mg_bitmap field bit values */
347#define P2P_MGBTSE_P2PDEVMGMT_FLAG   0x1 /* AP supports Managed P2P Device */
348
349/* WiFi P2P IE subelement: Group Info */
350BWL_PRE_PACKED_STRUCT struct wifi_p2p_grpinfo_se_s {
351	uint8	eltId;			/* SE ID: P2P_SEID_GROUP_INFO */
352	uint8	len[2];			/* SE length not including eltId, len fields */
353} BWL_POST_PACKED_STRUCT;
354typedef struct wifi_p2p_grpinfo_se_s wifi_p2p_grpinfo_se_t;
355
356/* WiFi IE subelement: Operating Channel */
357BWL_PRE_PACKED_STRUCT struct wifi_p2p_op_channel_se_s {
358	uint8	eltId;		/* SE ID: P2P_SEID_OP_CHANNEL */
359	uint8	len[2];		/* SE length not including eltId, len fields */
360	uint8	country[3];	/* Country String */
361	uint8	op_class;	/* Operating Class */
362	uint8	channel;	/* Channel */
363} BWL_POST_PACKED_STRUCT;
364typedef struct wifi_p2p_op_channel_se_s wifi_p2p_op_channel_se_t;
365
366/* WiFi IE subelement: INVITATION FLAGS */
367BWL_PRE_PACKED_STRUCT struct wifi_p2p_invite_flags_se_s {
368	uint8	eltId;		/* SE ID: P2P_SEID_INVITE_FLAGS */
369	uint8	len[2];		/* SE length not including eltId, len fields */
370	uint8	flags;		/* Flags */
371} BWL_POST_PACKED_STRUCT;
372typedef struct wifi_p2p_invite_flags_se_s wifi_p2p_invite_flags_se_t;
373
374#ifdef WLWFDS
375/* WiFi P2P IE subelement: Service Hash */
376BWL_PRE_PACKED_STRUCT struct wifi_p2p_serv_hash_se_s {
377	uint8	eltId;			/* SE ID: P2P_SEID_SERV_HASH */
378	uint8	len[2];			/* SE length not including eltId, len fields
379					   in multiple of 6 Bytes
380					*/
381	uint8	hash[1];		/* Variable length - SHA256 hash of
382					   service names (can be more than one hashes)
383					*/
384} BWL_POST_PACKED_STRUCT;
385typedef struct wifi_p2p_serv_hash_se_s wifi_p2p_serv_hash_se_t;
386
387/* WiFi P2P IE subelement: Service Instance Data */
388BWL_PRE_PACKED_STRUCT struct wifi_p2p_serv_inst_data_se_s {
389	uint8	eltId;			/* SE ID: P2P_SEID_SSN_INST_DATA */
390	uint8	len[2];			/* SE length not including eltId, len */
391	uint8	ssn_info[1];		/* Variable length - Session information as specified by
392					   the service layer, type matches serv. name
393					*/
394} BWL_POST_PACKED_STRUCT;
395typedef struct wifi_p2p_serv_inst_data_se_s wifi_p2p_serv_inst_data_se_t;
396
397
398/* WiFi P2P IE subelement: Connection capability */
399BWL_PRE_PACKED_STRUCT struct wifi_p2p_conn_cap_data_se_s {
400	uint8	eltId;			/* SE ID: P2P_SEID_CONN_CAP */
401	uint8	len[2];			/* SE length not including eltId, len */
402	uint8	conn_cap;		/* 1byte capability as specified by the
403					   service layer, valid bitmask/values
404					*/
405} BWL_POST_PACKED_STRUCT;
406typedef struct wifi_p2p_conn_cap_data_se_s wifi_p2p_conn_cap_data_se_t;
407
408
409/* WiFi P2P IE subelement: Advertisement ID */
410BWL_PRE_PACKED_STRUCT struct wifi_p2p_advt_id_se_s {
411	uint8	eltId;			/* SE ID: P2P_SEID_ADV_ID */
412	uint8	len[2];			/* SE length not including eltId, len fixed 4 Bytes */
413	uint8	advt_id[4];		/* 4byte Advertisement ID of the peer device sent in
414					   PROV Disc in Network byte order
415					*/
416	uint8	advt_mac[6];			/* P2P device address of the service advertiser */
417} BWL_POST_PACKED_STRUCT;
418typedef struct wifi_p2p_advt_id_se_s wifi_p2p_advt_id_se_t;
419
420
421/* WiFi P2P IE subelement: Advertise Service Hash */
422BWL_PRE_PACKED_STRUCT struct wifi_p2p_adv_serv_info_s {
423	uint8	advt_id[4];		/* SE Advertise ID for the service */
424	uint16	nw_cfg_method;	/* SE Network Config method for the service */
425	uint8	serv_name_len;	/* SE length of the service name */
426	uint8	serv_name[1];	/* Variable length service name field */
427} BWL_POST_PACKED_STRUCT;
428typedef struct wifi_p2p_adv_serv_info_s wifi_p2p_adv_serv_info_t;
429
430
431/* WiFi P2P IE subelement: Advertise Service Hash */
432BWL_PRE_PACKED_STRUCT struct wifi_p2p_advt_serv_se_s {
433	uint8	eltId;			/* SE ID: P2P_SEID_ADV_SERV */
434	uint8	len[2];			/* SE length not including eltId, len fields mutiple len of
435					   wifi_p2p_adv_serv_info_t entries
436					*/
437	wifi_p2p_adv_serv_info_t	p_advt_serv_info[1]; /* Variable length
438								of multiple instances
439								of the advertise service info
440								*/
441} BWL_POST_PACKED_STRUCT;
442typedef struct wifi_p2p_advt_serv_se_s wifi_p2p_advt_serv_se_t;
443
444
445/* WiFi P2P IE subelement: Session ID */
446BWL_PRE_PACKED_STRUCT struct wifi_p2p_ssn_id_se_s {
447	uint8	eltId;			/* SE ID: P2P_SEID_SSN_ID */
448	uint8	len[2];			/* SE length not including eltId, len fixed 4 Bytes */
449	uint8	ssn_id[4];		/* 4byte Session ID of the peer device sent in
450							 * PROV Disc in Network byte order
451							 */
452	uint8	ssn_mac[6];		/* P2P device address of the seeker - session mac */
453} BWL_POST_PACKED_STRUCT;
454typedef struct wifi_p2p_ssn_id_se_s wifi_p2p_ssn_id_se_t;
455
456
457#define P2P_ADVT_SERV_SE_FIXED_LEN	3
458#define P2P_ADVT_SERV_INFO_FIXED_LEN  7
459#endif /* WLWFDS */
460
461
462/* WiFi P2P Action Frame */
463BWL_PRE_PACKED_STRUCT struct wifi_p2p_action_frame {
464	uint8	category;	/* P2P_AF_CATEGORY */
465	uint8	OUI[3];		/* OUI - P2P_OUI */
466	uint8	type;		/* OUI Type - P2P_VER */
467	uint8	subtype;	/* OUI Subtype - P2P_AF_* */
468	uint8	dialog_token;	/* nonzero, identifies req/resp tranaction */
469	uint8	elts[1];	/* Variable length information elements.  Max size =
470				 * ACTION_FRAME_SIZE - sizeof(this structure) - 1
471				 */
472} BWL_POST_PACKED_STRUCT;
473typedef struct wifi_p2p_action_frame wifi_p2p_action_frame_t;
474#define P2P_AF_CATEGORY		0x7f
475
476#define P2P_AF_FIXED_LEN	7
477
478/* WiFi P2P Action Frame OUI Subtypes */
479#define P2P_AF_NOTICE_OF_ABSENCE	0	/* Notice of Absence */
480#define P2P_AF_PRESENCE_REQ		1	/* P2P Presence Request */
481#define P2P_AF_PRESENCE_RSP		2	/* P2P Presence Response */
482#define P2P_AF_GO_DISC_REQ		3	/* GO Discoverability Request */
483
484
485/* WiFi P2P Public Action Frame */
486BWL_PRE_PACKED_STRUCT struct wifi_p2p_pub_act_frame {
487	uint8	category;	/* P2P_PUB_AF_CATEGORY */
488	uint8	action;		/* P2P_PUB_AF_ACTION */
489	uint8	oui[3];		/* P2P_OUI */
490	uint8	oui_type;	/* OUI type - P2P_VER */
491	uint8	subtype;	/* OUI subtype - P2P_TYPE_* */
492	uint8	dialog_token;	/* nonzero, identifies req/rsp transaction */
493	uint8	elts[1];	/* Variable length information elements.  Max size =
494				 * ACTION_FRAME_SIZE - sizeof(this structure) - 1
495				 */
496} BWL_POST_PACKED_STRUCT;
497typedef struct wifi_p2p_pub_act_frame wifi_p2p_pub_act_frame_t;
498#define P2P_PUB_AF_FIXED_LEN	8
499#define P2P_PUB_AF_CATEGORY	0x04
500#define P2P_PUB_AF_ACTION	0x09
501
502/* WiFi P2P Public Action Frame OUI Subtypes */
503#define P2P_PAF_GON_REQ		0	/* Group Owner Negotiation Req */
504#define P2P_PAF_GON_RSP		1	/* Group Owner Negotiation Rsp */
505#define P2P_PAF_GON_CONF	2	/* Group Owner Negotiation Confirm */
506#define P2P_PAF_INVITE_REQ	3	/* P2P Invitation Request */
507#define P2P_PAF_INVITE_RSP	4	/* P2P Invitation Response */
508#define P2P_PAF_DEVDIS_REQ	5	/* Device Discoverability Request */
509#define P2P_PAF_DEVDIS_RSP	6	/* Device Discoverability Response */
510#define P2P_PAF_PROVDIS_REQ	7	/* Provision Discovery Request */
511#define P2P_PAF_PROVDIS_RSP	8	/* Provision Discovery Response */
512#define P2P_PAF_SUBTYPE_INVALID	255	/* Invalid Subtype */
513
514/* TODO: Stop using these obsolete aliases for P2P_PAF_GON_* */
515#define P2P_TYPE_MNREQ		P2P_PAF_GON_REQ
516#define P2P_TYPE_MNRSP		P2P_PAF_GON_RSP
517#define P2P_TYPE_MNCONF		P2P_PAF_GON_CONF
518
519/* WiFi P2P IE subelement: Notice of Absence */
520BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_desc {
521	uint8	cnt_type;	/* Count/Type */
522	uint32	duration;	/* Duration */
523	uint32	interval;	/* Interval */
524	uint32	start;		/* Start Time */
525} BWL_POST_PACKED_STRUCT;
526typedef struct wifi_p2p_noa_desc wifi_p2p_noa_desc_t;
527
528BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_se {
529	uint8	eltId;		/* Subelement ID */
530	uint8	len[2];		/* Length */
531	uint8	index;		/* Index */
532	uint8	ops_ctw_parms;	/* CTWindow and OppPS Parameters */
533	wifi_p2p_noa_desc_t	desc[1];	/* Notice of Absence Descriptor(s) */
534} BWL_POST_PACKED_STRUCT;
535typedef struct wifi_p2p_noa_se wifi_p2p_noa_se_t;
536
537#define P2P_NOA_SE_FIXED_LEN	5
538
539#define P2P_NOA_SE_MAX_DESC	2	/* max NoA descriptors in presence request */
540
541/* cnt_type field values */
542#define P2P_NOA_DESC_CNT_RESERVED	0	/* reserved and should not be used */
543#define P2P_NOA_DESC_CNT_REPEAT		255	/* continuous schedule */
544#define P2P_NOA_DESC_TYPE_PREFERRED	1	/* preferred values */
545#define P2P_NOA_DESC_TYPE_ACCEPTABLE	2	/* acceptable limits */
546
547/* ctw_ops_parms field values */
548#define P2P_NOA_CTW_MASK	0x7f
549#define P2P_NOA_OPS_MASK	0x80
550#define P2P_NOA_OPS_SHIFT	7
551
552#define P2P_CTW_MIN	10	/* minimum 10TU */
553
554/*
555 * P2P Service Discovery related
556 */
557#define	P2PSD_ACTION_CATEGORY		0x04
558				/* Public action frame */
559#define	P2PSD_ACTION_ID_GAS_IREQ	0x0a
560				/* Action value for GAS Initial Request AF */
561#define	P2PSD_ACTION_ID_GAS_IRESP	0x0b
562				/* Action value for GAS Initial Response AF */
563#define	P2PSD_ACTION_ID_GAS_CREQ	0x0c
564				/* Action value for GAS Comback Request AF */
565#define	P2PSD_ACTION_ID_GAS_CRESP	0x0d
566				/* Action value for GAS Comback Response AF */
567#define P2PSD_AD_EID				0x6c
568				/* Advertisement Protocol IE ID */
569#define P2PSD_ADP_TUPLE_QLMT_PAMEBI	0x00
570				/* Query Response Length Limit 7 bits plus PAME-BI 1 bit */
571#define P2PSD_ADP_PROTO_ID			0x00
572				/* Advertisement Protocol ID. Always 0 for P2P SD */
573#define P2PSD_GAS_OUI				P2P_OUI
574				/* WFA OUI */
575#define P2PSD_GAS_OUI_SUBTYPE		P2P_VER
576				/* OUI Subtype for GAS IE */
577#define P2PSD_GAS_NQP_INFOID		0xDDDD
578				/* NQP Query Info ID: 56797 */
579#define P2PSD_GAS_COMEBACKDEALY		0x00
580				/* Not used in the Native GAS protocol */
581
582/* Service Protocol Type */
583typedef enum p2psd_svc_protype {
584	SVC_RPOTYPE_ALL = 0,
585	SVC_RPOTYPE_BONJOUR = 1,
586	SVC_RPOTYPE_UPNP = 2,
587	SVC_RPOTYPE_WSD = 3,
588	SVC_RPOTYPE_VENDOR = 255
589} p2psd_svc_protype_t;
590
591/* Service Discovery response status code */
592typedef enum {
593	P2PSD_RESP_STATUS_SUCCESS = 0,
594	P2PSD_RESP_STATUS_PROTYPE_NA = 1,
595	P2PSD_RESP_STATUS_DATA_NA = 2,
596	P2PSD_RESP_STATUS_BAD_REQUEST = 3
597} p2psd_resp_status_t;
598
599/* Advertisement Protocol IE tuple field */
600BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_tpl {
601	uint8	llm_pamebi;	/* Query Response Length Limit bit 0-6, set to 0 plus
602				* Pre-Associated Message Exchange BSSID Independent bit 7, set to 0
603				*/
604	uint8	adp_id;		/* Advertisement Protocol ID: 0 for NQP Native Query Protocol */
605} BWL_POST_PACKED_STRUCT;
606typedef struct wifi_p2psd_adp_tpl wifi_p2psd_adp_tpl_t;
607
608/* Advertisement Protocol IE */
609BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_ie {
610	uint8	id;		/* IE ID: 0x6c - 108 */
611	uint8	len;	/* IE length */
612	wifi_p2psd_adp_tpl_t adp_tpl;  /* Advertisement Protocol Tuple field. Only one
613				* tuple is defined for P2P Service Discovery
614				*/
615} BWL_POST_PACKED_STRUCT;
616typedef struct wifi_p2psd_adp_ie wifi_p2psd_adp_ie_t;
617
618/* NQP Vendor-specific Content */
619BWL_PRE_PACKED_STRUCT struct wifi_p2psd_nqp_query_vsc {
620	uint8	oui_subtype;	/* OUI Subtype: 0x09 */
621	uint16	svc_updi;		/* Service Update Indicator */
622	uint8	svc_tlvs[1];	/* wifi_p2psd_qreq_tlv_t type for service request,
623				* wifi_p2psd_qresp_tlv_t type for service response
624				*/
625} BWL_POST_PACKED_STRUCT;
626typedef struct wifi_p2psd_nqp_query_vsc wifi_p2psd_nqp_query_vsc_t;
627
628/* Service Request TLV */
629BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_tlv {
630	uint16	len;			/* Length: 5 plus size of Query Data */
631	uint8	svc_prot;		/* Service Protocol Type */
632	uint8	svc_tscid;		/* Service Transaction ID */
633	uint8	query_data[1];	/* Query Data, passed in from above Layer 2 */
634} BWL_POST_PACKED_STRUCT;
635typedef struct wifi_p2psd_qreq_tlv wifi_p2psd_qreq_tlv_t;
636
637/* Query Request Frame, defined in generic format, instead of NQP specific */
638BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_frame {
639	uint16	info_id;	/* Info ID: 0xDDDD */
640	uint16	len;		/* Length of service request TLV, 5 plus the size of request data */
641	uint8	oui[3];		/* WFA OUI: 0x0050F2 */
642	uint8	qreq_vsc[1]; /* Vendor-specific Content: wifi_p2psd_nqp_query_vsc_t type for NQP */
643
644} BWL_POST_PACKED_STRUCT;
645typedef struct wifi_p2psd_qreq_frame wifi_p2psd_qreq_frame_t;
646
647/* GAS Initial Request AF body, "elts" in wifi_p2p_pub_act_frame */
648BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_ireq_frame {
649	wifi_p2psd_adp_ie_t		adp_ie;		/* Advertisement Protocol IE */
650	uint16					qreq_len;	/* Query Request Length */
651	uint8	qreq_frm[1];	/* Query Request Frame wifi_p2psd_qreq_frame_t */
652} BWL_POST_PACKED_STRUCT;
653typedef struct wifi_p2psd_gas_ireq_frame wifi_p2psd_gas_ireq_frame_t;
654
655/* Service Response TLV */
656BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_tlv {
657	uint16	len;				/* Length: 5 plus size of Query Data */
658	uint8	svc_prot;			/* Service Protocol Type */
659	uint8	svc_tscid;			/* Service Transaction ID */
660	uint8	status;				/* Value defined in Table 57 of P2P spec. */
661	uint8	query_data[1];		/* Response Data, passed in from above Layer 2 */
662} BWL_POST_PACKED_STRUCT;
663typedef struct wifi_p2psd_qresp_tlv wifi_p2psd_qresp_tlv_t;
664
665/* Query Response Frame, defined in generic format, instead of NQP specific */
666BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_frame {
667	uint16	info_id;	/* Info ID: 0xDDDD */
668	uint16	len;		/* Lenth of service response TLV, 6 plus the size of resp data */
669	uint8	oui[3];		/* WFA OUI: 0x0050F2 */
670	uint8	qresp_vsc[1]; /* Vendor-specific Content: wifi_p2psd_qresp_tlv_t type for NQP */
671
672} BWL_POST_PACKED_STRUCT;
673typedef struct wifi_p2psd_qresp_frame wifi_p2psd_qresp_frame_t;
674
675/* GAS Initial Response AF body, "elts" in wifi_p2p_pub_act_frame */
676BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_iresp_frame {
677	uint16	status;			/* Value defined in Table 7-23 of IEEE P802.11u */
678	uint16	cb_delay;		/* GAS Comeback Delay */
679	wifi_p2psd_adp_ie_t	adp_ie;		/* Advertisement Protocol IE */
680	uint16		qresp_len;	/* Query Response Length */
681	uint8	qresp_frm[1];	/* Query Response Frame wifi_p2psd_qresp_frame_t */
682} BWL_POST_PACKED_STRUCT;
683typedef struct wifi_p2psd_gas_iresp_frame wifi_p2psd_gas_iresp_frame_t;
684
685/* GAS Comeback Response AF body, "elts" in wifi_p2p_pub_act_frame */
686BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_cresp_frame {
687	uint16	status;			/* Value defined in Table 7-23 of IEEE P802.11u */
688	uint8	fragment_id;	/* Fragmentation ID */
689	uint16	cb_delay;		/* GAS Comeback Delay */
690	wifi_p2psd_adp_ie_t	adp_ie;		/* Advertisement Protocol IE */
691	uint16	qresp_len;		/* Query Response Length */
692	uint8	qresp_frm[1];	/* Query Response Frame wifi_p2psd_qresp_frame_t */
693} BWL_POST_PACKED_STRUCT;
694typedef struct wifi_p2psd_gas_cresp_frame wifi_p2psd_gas_cresp_frame_t;
695
696/* Wi-Fi GAS Public Action Frame */
697BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_pub_act_frame {
698	uint8	category;		/* 0x04 Public Action Frame */
699	uint8	action;			/* 0x6c Advertisement Protocol */
700	uint8	dialog_token;	/* nonzero, identifies req/rsp transaction */
701	uint8	query_data[1];	/* Query Data. wifi_p2psd_gas_ireq_frame_t
702					 * or wifi_p2psd_gas_iresp_frame_t format
703					 */
704} BWL_POST_PACKED_STRUCT;
705typedef struct wifi_p2psd_gas_pub_act_frame wifi_p2psd_gas_pub_act_frame_t;
706
707/* This marks the end of a packed structure section. */
708#include <packed_section_end.h>
709
710#endif /* _P2P_H_ */
711