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