summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/bcmdhd_1363/include/proto/p2p.h
blob: 747265b9a2c27e7fc017dc710e2a699def069ce5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
/*
 * Fundamental types and constants relating to WFA P2P (aka WiFi Direct)
 *
 * Copyright (C) 1999-2017, Broadcom Corporation
 * 
 *      Unless you and Broadcom execute a separate written software license
 * agreement governing use of this software, this software is licensed to you
 * under the terms of the GNU General Public License version 2 (the "GPL"),
 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
 * following added to such license:
 * 
 *      As a special exception, the copyright holders of this software give you
 * permission to link this software with independent modules, and to copy and
 * distribute the resulting executable under terms of your choice, provided that
 * you also meet, for each linked independent module, the terms and conditions of
 * the license of that module.  An independent module is a module which is not
 * derived from this software.  The special exception does not apply to any
 * modifications of the software.
 * 
 *      Notwithstanding the above, under no circumstances may you combine this
 * software in any way with any other Broadcom software provided under a license
 * other than the GPL, without Broadcom's express prior written consent.
 *
 *
 * <<Broadcom-WL-IPTag/Open:>>
 *
 * $Id: p2p.h 536785 2015-02-24 08:35:00Z $
 */

#ifndef _P2P_H_
#define _P2P_H_

#ifndef _TYPEDEFS_H_
#include <typedefs.h>
#endif
#include <wlioctl.h>
#include <proto/802.11.h>

/* This marks the start of a packed structure section. */
#include <packed_section_start.h>


/* WiFi P2P OUI values */
#define P2P_OUI			WFA_OUI			/* WiFi P2P OUI */
#define P2P_VER			WFA_OUI_TYPE_P2P	/* P2P version: 9=WiFi P2P v1.0 */

#define P2P_IE_ID		0xdd			/* P2P IE element ID */

/* WiFi P2P IE */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_ie {
	uint8	id;		/* IE ID: 0xDD */
	uint8	len;		/* IE length */
	uint8	OUI[3];		/* WiFi P2P specific OUI: P2P_OUI */
	uint8	oui_type;	/* Identifies P2P version: P2P_VER */
	uint8	subelts[1];	/* variable length subelements */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_ie wifi_p2p_ie_t;

#define P2P_IE_FIXED_LEN	6

#define P2P_ATTR_ID_OFF		0
#define P2P_ATTR_LEN_OFF	1
#define P2P_ATTR_DATA_OFF	3

#define P2P_ATTR_ID_LEN		1	/* ID filed length */
#define P2P_ATTR_LEN_LEN	2	/* length field length */
#define P2P_ATTR_HDR_LEN	3 /* ID + 2-byte length field spec 1.02 */

#define P2P_WFDS_HASH_LEN		6
#define P2P_WFDS_MAX_SVC_NAME_LEN	32

/* P2P IE Subelement IDs from WiFi P2P Technical Spec 1.00 */
#define P2P_SEID_STATUS			0	/* Status */
#define P2P_SEID_MINOR_RC		1	/* Minor Reason Code */
#define P2P_SEID_P2P_INFO		2	/* P2P Capability (capabilities info) */
#define P2P_SEID_DEV_ID			3	/* P2P Device ID */
#define P2P_SEID_INTENT			4	/* Group Owner Intent */
#define P2P_SEID_CFG_TIMEOUT		5	/* Configuration Timeout */
#define P2P_SEID_CHANNEL		6	/* Listen channel */
#define P2P_SEID_GRP_BSSID		7	/* P2P Group BSSID */
#define P2P_SEID_XT_TIMING		8	/* Extended Listen Timing */
#define P2P_SEID_INTINTADDR		9	/* Intended P2P Interface Address */
#define P2P_SEID_P2P_MGBTY		10	/* P2P Manageability */
#define P2P_SEID_CHAN_LIST		11	/* Channel List */
#define P2P_SEID_ABSENCE		12	/* Notice of Absence */
#define P2P_SEID_DEV_INFO		13	/* Device Info */
#define P2P_SEID_GROUP_INFO		14	/* Group Info */
#define P2P_SEID_GROUP_ID		15	/* Group ID */
#define P2P_SEID_P2P_IF			16	/* P2P Interface */
#define P2P_SEID_OP_CHANNEL		17	/* Operating Channel */
#define P2P_SEID_INVITE_FLAGS		18	/* Invitation Flags */
#define P2P_SEID_SERVICE_HASH		21	/* Service hash */
#define P2P_SEID_SESSION		22	/* Session information */
#define P2P_SEID_CONNECT_CAP		23	/* Connection capability */
#define P2P_SEID_ADVERTISE_ID		24	/* Advertisement ID */
#define P2P_SEID_ADVERTISE_SERVICE	25	/* Advertised service */
#define P2P_SEID_SESSION_ID		26	/* Session ID */
#define P2P_SEID_FEATURE_CAP		27	/* Feature capability */
#define	P2P_SEID_PERSISTENT_GROUP	28	/* Persistent group */
#define P2P_SEID_SESSION_INFO_RESP	29	/* Session Information Response */
#define P2P_SEID_VNDR			221	/* Vendor-specific subelement */

#define P2P_SE_VS_ID_SERVICES	0x1b


/* WiFi P2P IE subelement: P2P Capability (capabilities info) */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_info_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_P2P_INFO */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	dev;		/* Device Capability Bitmap */
	uint8	group;		/* Group Capability Bitmap */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_info_se_s wifi_p2p_info_se_t;

/* P2P Capability subelement's Device Capability Bitmap bit values */
#define P2P_CAPSE_DEV_SERVICE_DIS	0x1 /* Service Discovery */
#define P2P_CAPSE_DEV_CLIENT_DIS	0x2 /* Client Discoverability */
#define P2P_CAPSE_DEV_CONCURRENT	0x4 /* Concurrent Operation */
#define P2P_CAPSE_DEV_INFRA_MAN		0x8 /* P2P Infrastructure Managed */
#define P2P_CAPSE_DEV_LIMIT			0x10 /* P2P Device Limit */
#define P2P_CAPSE_INVITE_PROC		0x20 /* P2P Invitation Procedure */

/* P2P Capability subelement's Group Capability Bitmap bit values */
#define P2P_CAPSE_GRP_OWNER			0x1 /* P2P Group Owner */
#define P2P_CAPSE_PERSIST_GRP		0x2 /* Persistent P2P Group */
#define P2P_CAPSE_GRP_LIMIT			0x4 /* P2P Group Limit */
#define P2P_CAPSE_GRP_INTRA_BSS		0x8 /* Intra-BSS Distribution */
#define P2P_CAPSE_GRP_X_CONNECT		0x10 /* Cross Connection */
#define P2P_CAPSE_GRP_PERSISTENT	0x20 /* Persistent Reconnect */
#define P2P_CAPSE_GRP_FORMATION		0x40 /* Group Formation */


/* WiFi P2P IE subelement: Group Owner Intent */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_intent_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_INTENT */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	intent;		/* Intent Value 0...15 (0=legacy 15=master only) */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_intent_se_s wifi_p2p_intent_se_t;

/* WiFi P2P IE subelement: Configuration Timeout */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_cfg_tmo_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_CFG_TIMEOUT */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	go_tmo;		/* GO config timeout in units of 10 ms */
	uint8	client_tmo;	/* Client config timeout in units of 10 ms */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_cfg_tmo_se_s wifi_p2p_cfg_tmo_se_t;

/* WiFi P2P IE subelement: Listen Channel */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_listen_channel_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_CHANNEL */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	country[3];	/* Country String */
	uint8	op_class;	/* Operating Class */
	uint8	channel;	/* Channel */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_listen_channel_se_s wifi_p2p_listen_channel_se_t;

/* WiFi P2P IE subelement: P2P Group BSSID */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_bssid_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_GRP_BSSID */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	mac[6];		/* P2P group bssid */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_grp_bssid_se_s wifi_p2p_grp_bssid_se_t;

/* WiFi P2P IE subelement: P2P Group ID */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_id_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_GROUP_ID */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	mac[6];		/* P2P device address */
	uint8	ssid[1];	/* ssid. device id. variable length */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_grp_id_se_s wifi_p2p_grp_id_se_t;

/* WiFi P2P IE subelement: P2P Interface */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_intf_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_P2P_IF */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	mac[6];		/* P2P device address */
	uint8	ifaddrs;	/* P2P Interface Address count */
	uint8	ifaddr[1][6];	/* P2P Interface Address list */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_intf_se_s wifi_p2p_intf_se_t;

/* WiFi P2P IE subelement: Status */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_status_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_STATUS */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	status;		/* Status Code: P2P_STATSE_* */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_status_se_s wifi_p2p_status_se_t;

/* Status subelement Status Code definitions */
#define P2P_STATSE_SUCCESS			0
				/* Success */
#define P2P_STATSE_FAIL_INFO_CURR_UNAVAIL	1
				/* Failed, information currently unavailable */
#define P2P_STATSE_PASSED_UP			P2P_STATSE_FAIL_INFO_CURR_UNAVAIL
				/* Old name for above in P2P spec 1.08 and older */
#define P2P_STATSE_FAIL_INCOMPAT_PARAMS		2
				/* Failed, incompatible parameters */
#define P2P_STATSE_FAIL_LIMIT_REACHED		3
				/* Failed, limit reached */
#define P2P_STATSE_FAIL_INVALID_PARAMS		4
				/* Failed, invalid parameters */
#define P2P_STATSE_FAIL_UNABLE_TO_ACCOM		5
				/* Failed, unable to accomodate request */
#define P2P_STATSE_FAIL_PROTO_ERROR		6
				/* Failed, previous protocol error or disruptive behaviour */
#define P2P_STATSE_FAIL_NO_COMMON_CHAN		7
				/* Failed, no common channels */
#define P2P_STATSE_FAIL_UNKNOWN_GROUP		8
				/* Failed, unknown P2P Group */
#define P2P_STATSE_FAIL_INTENT			9
				/* Failed, both peers indicated Intent 15 in GO Negotiation */
#define P2P_STATSE_FAIL_INCOMPAT_PROVIS		10
				/* Failed, incompatible provisioning method */
#define P2P_STATSE_FAIL_USER_REJECT		11
				/* Failed, rejected by user */
#define P2P_STATSE_SUCCESS_USER_ACCEPT		12
				/* Success, accepted by user */

/* WiFi P2P IE attribute: Extended Listen Timing */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_ext_se_s {
	uint8	eltId;		/* ID: P2P_SEID_EXT_TIMING */
	uint8	len[2];		/* length not including eltId, len fields */
	uint8	avail[2];	/* availibility period */
	uint8	interval[2];	/* availibility interval */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_ext_se_s wifi_p2p_ext_se_t;

#define P2P_EXT_MIN	10	/* minimum 10ms */

/* WiFi P2P IE subelement: Intended P2P Interface Address */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_intintad_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_INTINTADDR */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	mac[6];		/* intended P2P interface MAC address */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_intintad_se_s wifi_p2p_intintad_se_t;

/* WiFi P2P IE subelement: Channel */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_channel_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_STATUS */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	band;		/* Regulatory Class (band) */
	uint8	channel;	/* Channel */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_channel_se_s wifi_p2p_channel_se_t;


/* Channel Entry structure within the Channel List SE */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_entry_s {
	uint8	band;						/* Regulatory Class (band) */
	uint8	num_channels;				/* # of channels in the channel list */
	uint8	channels[WL_NUMCHANNELS];	/* Channel List */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_chanlist_entry_s wifi_p2p_chanlist_entry_t;
#define WIFI_P2P_CHANLIST_SE_MAX_ENTRIES 2

/* WiFi P2P IE subelement: Channel List */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_CHAN_LIST */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	country[3];	/* Country String */
	uint8	num_entries;	/* # of channel entries */
	wifi_p2p_chanlist_entry_t	entries[WIFI_P2P_CHANLIST_SE_MAX_ENTRIES];
						/* Channel Entry List */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_chanlist_se_s wifi_p2p_chanlist_se_t;

/* WiFi Primary Device Type structure */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_pri_devtype_s {
	uint16	cat_id;		/* Category ID */
	uint8	OUI[3];		/* WFA OUI: 0x0050F2 */
	uint8	oui_type;	/* WPS_OUI_TYPE */
	uint16	sub_cat_id;	/* Sub Category ID */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_pri_devtype_s wifi_p2p_pri_devtype_t;

/* WiFi P2P Device Info Sub Element Primary Device Type Sub Category
 * maximum values for each category
 */
#define P2P_DISE_SUBCATEGORY_MINVAL		1
#define P2P_DISE_CATEGORY_COMPUTER		1
#define P2P_DISE_SUBCATEGORY_COMPUTER_MAXVAL		8
#define P2P_DISE_CATEGORY_INPUT_DEVICE		2
#define P2P_DISE_SUBCATEGORY_INPUT_DEVICE_MAXVAL	9
#define P2P_DISE_CATEGORY_PRINTER		3
#define P2P_DISE_SUBCATEGORY_PRINTER_MAXVAL		5
#define P2P_DISE_CATEGORY_CAMERA		4
#define P2P_DISE_SUBCATEGORY_CAMERA_MAXVAL		4
#define P2P_DISE_CATEGORY_STORAGE		5
#define P2P_DISE_SUBCATEGORY_STORAGE_MAXVAL		1
#define P2P_DISE_CATEGORY_NETWORK_INFRA		6
#define P2P_DISE_SUBCATEGORY_NETWORK_INFRA_MAXVAL	4
#define P2P_DISE_CATEGORY_DISPLAY		7
#define P2P_DISE_SUBCATEGORY_DISPLAY_MAXVAL		4
#define P2P_DISE_CATEGORY_MULTIMEDIA		8
#define P2P_DISE_SUBCATEGORY_MULTIMEDIA_MAXVAL		6
#define P2P_DISE_CATEGORY_GAMING		9
#define P2P_DISE_SUBCATEGORY_GAMING_MAXVAL		5
#define P2P_DISE_CATEGORY_TELEPHONE		10
#define P2P_DISE_SUBCATEGORY_TELEPHONE_MAXVAL		5
#define P2P_DISE_CATEGORY_AUDIO			11
#define P2P_DISE_SUBCATEGORY_AUDIO_MAXVAL		6

/* WiFi P2P IE's Device Info subelement */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_devinfo_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_DEVINFO */
	uint8	len[2];			/* SE length not including eltId, len fields */
	uint8	mac[6];			/* P2P Device MAC address */
	uint16	wps_cfg_meths;		/* Config Methods: reg_prototlv.h WPS_CONFMET_* */
	uint8	pri_devtype[8];		/* Primary Device Type */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_devinfo_se_s wifi_p2p_devinfo_se_t;

#define P2P_DEV_TYPE_LEN	8

/* WiFi P2P IE's Group Info subelement Client Info Descriptor */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_cid_fixed_s {
	uint8	len;
	uint8	devaddr[ETHER_ADDR_LEN];	/* P2P Device Address */
	uint8	ifaddr[ETHER_ADDR_LEN];		/* P2P Interface Address */
	uint8	devcap;				/* Device Capability */
	uint8	cfg_meths[2];			/* Config Methods: reg_prototlv.h WPS_CONFMET_* */
	uint8	pridt[P2P_DEV_TYPE_LEN];	/* Primary Device Type */
	uint8	secdts;				/* Number of Secondary Device Types */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_cid_fixed_s wifi_p2p_cid_fixed_t;

/* WiFi P2P IE's Device ID subelement */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_devid_se_s {
	uint8	eltId;
	uint8	len[2];
	struct ether_addr	addr;			/* P2P Device MAC address */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_devid_se_s wifi_p2p_devid_se_t;

/* WiFi P2P IE subelement: P2P Manageability */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_mgbt_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_P2P_MGBTY */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	mg_bitmap;	/* manageability bitmap */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_mgbt_se_s wifi_p2p_mgbt_se_t;
/* mg_bitmap field bit values */
#define P2P_MGBTSE_P2PDEVMGMT_FLAG   0x1 /* AP supports Managed P2P Device */

/* WiFi P2P IE subelement: Group Info */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_grpinfo_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_GROUP_INFO */
	uint8	len[2];			/* SE length not including eltId, len fields */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_grpinfo_se_s wifi_p2p_grpinfo_se_t;

/* WiFi IE subelement: Operating Channel */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_op_channel_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_OP_CHANNEL */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	country[3];	/* Country String */
	uint8	op_class;	/* Operating Class */
	uint8	channel;	/* Channel */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_op_channel_se_s wifi_p2p_op_channel_se_t;

/* WiFi IE subelement: INVITATION FLAGS */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_invite_flags_se_s {
	uint8	eltId;		/* SE ID: P2P_SEID_INVITE_FLAGS */
	uint8	len[2];		/* SE length not including eltId, len fields */
	uint8	flags;		/* Flags */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_invite_flags_se_s wifi_p2p_invite_flags_se_t;

/* WiFi P2P IE subelement: Service Hash */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_serv_hash_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_SERVICE_HASH */
	uint8	len[2];			/* SE length not including eltId, len fields
					 * in multiple of 6 Bytes
					*/
	uint8	hash[1];		/* Variable length - SHA256 hash of
					 * service names (can be more than one hashes)
					*/
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_serv_hash_se_s wifi_p2p_serv_hash_se_t;

/* WiFi P2P IE subelement: Service Instance Data */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_serv_inst_data_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_SESSION */
	uint8	len[2];			/* SE length not including eltId, len */
	uint8	ssn_info[1];		/* Variable length - Session information as specified by
					 * the service layer, type matches serv. name
					*/
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_serv_inst_data_se_s wifi_p2p_serv_inst_data_se_t;


/* WiFi P2P IE subelement: Connection capability */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_conn_cap_data_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_CONNECT_CAP */
	uint8	len[2];			/* SE length not including eltId, len */
	uint8	conn_cap;		/* 1byte capability as specified by the
					 * service layer, valid bitmask/values
					*/
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_conn_cap_data_se_s wifi_p2p_conn_cap_data_se_t;


/* WiFi P2P IE subelement: Advertisement ID */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_advt_id_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_ADVERTISE_ID */
	uint8	len[2];			/* SE length not including eltId, len fixed 4 Bytes */
	uint8	advt_id[4];		/* 4byte Advertisement ID of the peer device sent in
					 * PROV Disc in Network byte order
					*/
	uint8	advt_mac[6];			/* P2P device address of the service advertiser */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_advt_id_se_s wifi_p2p_advt_id_se_t;


/* WiFi P2P IE subelement: Advertise Service Hash */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_adv_serv_info_s {
	uint8	advt_id[4];		/* SE Advertise ID for the service */
	uint16	nw_cfg_method;	/* SE Network Config method for the service */
	uint8	serv_name_len;	/* SE length of the service name */
	uint8	serv_name[1];	/* Variable length service name field */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_adv_serv_info_s wifi_p2p_adv_serv_info_t;


/* WiFi P2P IE subelement: Advertise Service Hash */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_advt_serv_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_ADVERTISE_SERVICE */
	uint8	len[2];			/* SE length not including eltId, len fields mutiple len of
					 * wifi_p2p_adv_serv_info_t entries
					*/
	wifi_p2p_adv_serv_info_t	p_advt_serv_info[1]; /* Variable length
								of multiple instances
								of the advertise service info
								*/
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_advt_serv_se_s wifi_p2p_advt_serv_se_t;


/* WiFi P2P IE subelement: Session ID */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_ssn_id_se_s {
	uint8	eltId;			/* SE ID: P2P_SEID_SESSION_ID */
	uint8	len[2];			/* SE length not including eltId, len fixed 4 Bytes */
	uint8	ssn_id[4];		/* 4byte Session ID of the peer device sent in
							 * PROV Disc in Network byte order
							 */
	uint8	ssn_mac[6];		/* P2P device address of the seeker - session mac */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_ssn_id_se_s wifi_p2p_ssn_id_se_t;


#define P2P_ADVT_SERV_SE_FIXED_LEN	3	/* Includes only the element ID and len */
#define P2P_ADVT_SERV_INFO_FIXED_LEN	7	/* Per ADV Service Instance advt_id +
						 * nw_config_method + serv_name_len
						 */

/* WiFi P2P Action Frame */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_action_frame {
	uint8	category;	/* P2P_AF_CATEGORY */
	uint8	OUI[3];		/* OUI - P2P_OUI */
	uint8	type;		/* OUI Type - P2P_VER */
	uint8	subtype;	/* OUI Subtype - P2P_AF_* */
	uint8	dialog_token;	/* nonzero, identifies req/resp tranaction */
	uint8	elts[1];	/* Variable length information elements.  Max size =
				 * ACTION_FRAME_SIZE - sizeof(this structure) - 1
				 */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_action_frame wifi_p2p_action_frame_t;
#define P2P_AF_CATEGORY		0x7f

#define P2P_AF_FIXED_LEN	7

/* WiFi P2P Action Frame OUI Subtypes */
#define P2P_AF_NOTICE_OF_ABSENCE	0	/* Notice of Absence */
#define P2P_AF_PRESENCE_REQ		1	/* P2P Presence Request */
#define P2P_AF_PRESENCE_RSP		2	/* P2P Presence Response */
#define P2P_AF_GO_DISC_REQ		3	/* GO Discoverability Request */


/* WiFi P2P Public Action Frame */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_pub_act_frame {
	uint8	category;	/* P2P_PUB_AF_CATEGORY */
	uint8	action;		/* P2P_PUB_AF_ACTION */
	uint8	oui[3];		/* P2P_OUI */
	uint8	oui_type;	/* OUI type - P2P_VER */
	uint8	subtype;	/* OUI subtype - P2P_TYPE_* */
	uint8	dialog_token;	/* nonzero, identifies req/rsp transaction */
	uint8	elts[1];	/* Variable length information elements.  Max size =
				 * ACTION_FRAME_SIZE - sizeof(this structure) - 1
				 */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_pub_act_frame wifi_p2p_pub_act_frame_t;
#define P2P_PUB_AF_FIXED_LEN	8
#define P2P_PUB_AF_CATEGORY	0x04
#define P2P_PUB_AF_ACTION	0x09

/* WiFi P2P Public Action Frame OUI Subtypes */
#define P2P_PAF_GON_REQ		0	/* Group Owner Negotiation Req */
#define P2P_PAF_GON_RSP		1	/* Group Owner Negotiation Rsp */
#define P2P_PAF_GON_CONF	2	/* Group Owner Negotiation Confirm */
#define P2P_PAF_INVITE_REQ	3	/* P2P Invitation Request */
#define P2P_PAF_INVITE_RSP	4	/* P2P Invitation Response */
#define P2P_PAF_DEVDIS_REQ	5	/* Device Discoverability Request */
#define P2P_PAF_DEVDIS_RSP	6	/* Device Discoverability Response */
#define P2P_PAF_PROVDIS_REQ	7	/* Provision Discovery Request */
#define P2P_PAF_PROVDIS_RSP	8	/* Provision Discovery Response */
#define P2P_PAF_SUBTYPE_INVALID	255	/* Invalid Subtype */

/* TODO: Stop using these obsolete aliases for P2P_PAF_GON_* */
#define P2P_TYPE_MNREQ		P2P_PAF_GON_REQ
#define P2P_TYPE_MNRSP		P2P_PAF_GON_RSP
#define P2P_TYPE_MNCONF		P2P_PAF_GON_CONF

/* WiFi P2P IE subelement: Notice of Absence */
BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_desc {
	uint8	cnt_type;	/* Count/Type */
	uint32	duration;	/* Duration */
	uint32	interval;	/* Interval */
	uint32	start;		/* Start Time */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_noa_desc wifi_p2p_noa_desc_t;

BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_se {
	uint8	eltId;		/* Subelement ID */
	uint8	len[2];		/* Length */
	uint8	index;		/* Index */
	uint8	ops_ctw_parms;	/* CTWindow and OppPS Parameters */
	wifi_p2p_noa_desc_t	desc[1];	/* Notice of Absence Descriptor(s) */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2p_noa_se wifi_p2p_noa_se_t;

#define P2P_NOA_SE_FIXED_LEN	5

#define P2P_NOA_SE_MAX_DESC	2	/* max NoA descriptors in presence request */

/* cnt_type field values */
#define P2P_NOA_DESC_CNT_RESERVED	0	/* reserved and should not be used */
#define P2P_NOA_DESC_CNT_REPEAT		255	/* continuous schedule */
#define P2P_NOA_DESC_TYPE_PREFERRED	1	/* preferred values */
#define P2P_NOA_DESC_TYPE_ACCEPTABLE	2	/* acceptable limits */

/* ctw_ops_parms field values */
#define P2P_NOA_CTW_MASK	0x7f
#define P2P_NOA_OPS_MASK	0x80
#define P2P_NOA_OPS_SHIFT	7

#define P2P_CTW_MIN	10	/* minimum 10TU */

/*
 * P2P Service Discovery related
 */
#define	P2PSD_ACTION_CATEGORY		0x04
				/* Public action frame */
#define	P2PSD_ACTION_ID_GAS_IREQ	0x0a
				/* Action value for GAS Initial Request AF */
#define	P2PSD_ACTION_ID_GAS_IRESP	0x0b
				/* Action value for GAS Initial Response AF */
#define	P2PSD_ACTION_ID_GAS_CREQ	0x0c
				/* Action value for GAS Comeback Request AF */
#define	P2PSD_ACTION_ID_GAS_CRESP	0x0d
				/* Action value for GAS Comeback Response AF */
#define P2PSD_AD_EID				0x6c
				/* Advertisement Protocol IE ID */
#define P2PSD_ADP_TUPLE_QLMT_PAMEBI	0x00
				/* Query Response Length Limit 7 bits plus PAME-BI 1 bit */
#define P2PSD_ADP_PROTO_ID			0x00
				/* Advertisement Protocol ID. Always 0 for P2P SD */
#define P2PSD_GAS_OUI				P2P_OUI
				/* WFA OUI */
#define P2PSD_GAS_OUI_SUBTYPE		P2P_VER
				/* OUI Subtype for GAS IE */
#define P2PSD_GAS_NQP_INFOID		0xDDDD
				/* NQP Query Info ID: 56797 */
#define P2PSD_GAS_COMEBACKDEALY		0x00
				/* Not used in the Native GAS protocol */

/* Service Protocol Type */
typedef enum p2psd_svc_protype {
	SVC_RPOTYPE_ALL = 0,
	SVC_RPOTYPE_BONJOUR = 1,
	SVC_RPOTYPE_UPNP = 2,
	SVC_RPOTYPE_WSD = 3,
	SVC_RPOTYPE_WFDS = 11,
	SVC_RPOTYPE_VENDOR = 255
} p2psd_svc_protype_t;

/* Service Discovery response status code */
typedef enum {
	P2PSD_RESP_STATUS_SUCCESS = 0,
	P2PSD_RESP_STATUS_PROTYPE_NA = 1,
	P2PSD_RESP_STATUS_DATA_NA = 2,
	P2PSD_RESP_STATUS_BAD_REQUEST = 3
} p2psd_resp_status_t;

/* Advertisement Protocol IE tuple field */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_tpl {
	uint8	llm_pamebi;	/* Query Response Length Limit bit 0-6, set to 0 plus
				* Pre-Associated Message Exchange BSSID Independent bit 7, set to 0
				*/
	uint8	adp_id;		/* Advertisement Protocol ID: 0 for NQP Native Query Protocol */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_adp_tpl wifi_p2psd_adp_tpl_t;

/* Advertisement Protocol IE */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_ie {
	uint8	id;		/* IE ID: 0x6c - 108 */
	uint8	len;	/* IE length */
	wifi_p2psd_adp_tpl_t adp_tpl;  /* Advertisement Protocol Tuple field. Only one
				* tuple is defined for P2P Service Discovery
				*/
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_adp_ie wifi_p2psd_adp_ie_t;

/* NQP Vendor-specific Content */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_nqp_query_vsc {
	uint8	oui_subtype;	/* OUI Subtype: 0x09 */
	uint16	svc_updi;		/* Service Update Indicator */
	uint8	svc_tlvs[1];	/* wifi_p2psd_qreq_tlv_t type for service request,
				* wifi_p2psd_qresp_tlv_t type for service response
				*/
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_nqp_query_vsc wifi_p2psd_nqp_query_vsc_t;

/* Service Request TLV */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_tlv {
	uint16	len;			/* Length: 5 plus size of Query Data */
	uint8	svc_prot;		/* Service Protocol Type */
	uint8	svc_tscid;		/* Service Transaction ID */
	uint8	query_data[1];	/* Query Data, passed in from above Layer 2 */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_qreq_tlv wifi_p2psd_qreq_tlv_t;

/* Query Request Frame, defined in generic format, instead of NQP specific */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_frame {
	uint16	info_id;	/* Info ID: 0xDDDD */
	uint16	len;		/* Length of service request TLV, 5 plus the size of request data */
	uint8	oui[3];		/* WFA OUI: 0x0050F2 */
	uint8	qreq_vsc[1]; /* Vendor-specific Content: wifi_p2psd_nqp_query_vsc_t type for NQP */

} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_qreq_frame wifi_p2psd_qreq_frame_t;

/* GAS Initial Request AF body, "elts" in wifi_p2p_pub_act_frame */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_ireq_frame {
	wifi_p2psd_adp_ie_t		adp_ie;		/* Advertisement Protocol IE */
	uint16					qreq_len;	/* Query Request Length */
	uint8	qreq_frm[1];	/* Query Request Frame wifi_p2psd_qreq_frame_t */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_gas_ireq_frame wifi_p2psd_gas_ireq_frame_t;

/* Service Response TLV */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_tlv {
	uint16	len;				/* Length: 5 plus size of Query Data */
	uint8	svc_prot;			/* Service Protocol Type */
	uint8	svc_tscid;			/* Service Transaction ID */
	uint8	status;				/* Value defined in Table 57 of P2P spec. */
	uint8	query_data[1];		/* Response Data, passed in from above Layer 2 */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_qresp_tlv wifi_p2psd_qresp_tlv_t;

/* Query Response Frame, defined in generic format, instead of NQP specific */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_frame {
	uint16	info_id;	/* Info ID: 0xDDDD */
	uint16	len;		/* Lenth of service response TLV, 6 plus the size of resp data */
	uint8	oui[3];		/* WFA OUI: 0x0050F2 */
	uint8	qresp_vsc[1]; /* Vendor-specific Content: wifi_p2psd_qresp_tlv_t type for NQP */

} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_qresp_frame wifi_p2psd_qresp_frame_t;

/* GAS Initial Response AF body, "elts" in wifi_p2p_pub_act_frame */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_iresp_frame {
	uint16	status;			/* Value defined in Table 7-23 of IEEE P802.11u */
	uint16	cb_delay;		/* GAS Comeback Delay */
	wifi_p2psd_adp_ie_t	adp_ie;		/* Advertisement Protocol IE */
	uint16		qresp_len;	/* Query Response Length */
	uint8	qresp_frm[1];	/* Query Response Frame wifi_p2psd_qresp_frame_t */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_gas_iresp_frame wifi_p2psd_gas_iresp_frame_t;

/* GAS Comeback Response AF body, "elts" in wifi_p2p_pub_act_frame */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_cresp_frame {
	uint16	status;			/* Value defined in Table 7-23 of IEEE P802.11u */
	uint8	fragment_id;	/* Fragmentation ID */
	uint16	cb_delay;		/* GAS Comeback Delay */
	wifi_p2psd_adp_ie_t	adp_ie;		/* Advertisement Protocol IE */
	uint16	qresp_len;		/* Query Response Length */
	uint8	qresp_frm[1];	/* Query Response Frame wifi_p2psd_qresp_frame_t */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_gas_cresp_frame wifi_p2psd_gas_cresp_frame_t;

/* Wi-Fi GAS Public Action Frame */
BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_pub_act_frame {
	uint8	category;		/* 0x04 Public Action Frame */
	uint8	action;			/* 0x6c Advertisement Protocol */
	uint8	dialog_token;	/* nonzero, identifies req/rsp transaction */
	uint8	query_data[1];	/* Query Data. wifi_p2psd_gas_ireq_frame_t
					 * or wifi_p2psd_gas_iresp_frame_t format
					 */
} BWL_POST_PACKED_STRUCT;
typedef struct wifi_p2psd_gas_pub_act_frame wifi_p2psd_gas_pub_act_frame_t;

/* This marks the end of a packed structure section. */
#include <packed_section_end.h>

#endif /* _P2P_H_ */