• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __NAN_I_H__
18 #define __NAN_I_H__
19 
20 #include "common.h"
21 #include "cpp_bindings.h"
22 #include "nan.h"
23 #include "wifi_hal.h"
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif /* __cplusplus */
29 
30 #ifndef PACKED
31 #define PACKED  __attribute__((packed))
32 #endif
33 
34 typedef u8 SirMacAddr[NAN_MAC_ADDR_LEN];
35 /*---------------------------------------------------------------------------
36 * WLAN NAN CONSTANTS
37 *--------------------------------------------------------------------------*/
38 
39 typedef enum
40 {
41     NAN_MSG_ID_ERROR_RSP                    = 0,
42     NAN_MSG_ID_CONFIGURATION_REQ            = 1,
43     NAN_MSG_ID_CONFIGURATION_RSP            = 2,
44     NAN_MSG_ID_PUBLISH_SERVICE_REQ          = 3,
45     NAN_MSG_ID_PUBLISH_SERVICE_RSP          = 4,
46     NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_REQ   = 5,
47     NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_RSP   = 6,
48     NAN_MSG_ID_PUBLISH_REPLIED_IND          = 7,
49     NAN_MSG_ID_PUBLISH_TERMINATED_IND       = 8,
50     NAN_MSG_ID_SUBSCRIBE_SERVICE_REQ        = 9,
51     NAN_MSG_ID_SUBSCRIBE_SERVICE_RSP        = 10,
52     NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_REQ = 11,
53     NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_RSP = 12,
54     NAN_MSG_ID_MATCH_IND                    = 13,
55     NAN_MSG_ID_UNMATCH_IND                  = 14,
56     NAN_MSG_ID_SUBSCRIBE_TERMINATED_IND     = 15,
57     NAN_MSG_ID_DE_EVENT_IND                 = 16,
58     NAN_MSG_ID_TRANSMIT_FOLLOWUP_REQ        = 17,
59     NAN_MSG_ID_TRANSMIT_FOLLOWUP_RSP        = 18,
60     NAN_MSG_ID_FOLLOWUP_IND                 = 19,
61     NAN_MSG_ID_STATS_REQ                    = 20,
62     NAN_MSG_ID_STATS_RSP                    = 21,
63     NAN_MSG_ID_ENABLE_REQ                   = 22,
64     NAN_MSG_ID_ENABLE_RSP                   = 23,
65     NAN_MSG_ID_DISABLE_REQ                  = 24,
66     NAN_MSG_ID_DISABLE_RSP                  = 25,
67     NAN_MSG_ID_DISABLE_IND                  = 26,
68     NAN_MSG_ID_TCA_REQ                      = 27,
69     NAN_MSG_ID_TCA_RSP                      = 28,
70     NAN_MSG_ID_TCA_IND                      = 29,
71 #ifdef NAN_2_0
72     NAN_MSG_ID_BEACON_SDF_REQ                = 30,
73     NAN_MSG_ID_BEACON_SDF_RSP                = 31,
74     NAN_MSG_ID_BEACON_SDF_IND                = 32
75 #endif /* NAN_2_0 */
76 } NanMsgId;
77 
78 /*
79   Various TLV Type ID sent as part of NAN Stats Response
80   or NAN TCA Indication
81 */
82 typedef enum
83 {
84     NAN_TLV_TYPE_FIRST = 0,
85 
86     /* Service Discovery Frame types */
87     NAN_TLV_TYPE_SDF_FIRST = NAN_TLV_TYPE_FIRST,
88     NAN_TLV_TYPE_SERVICE_NAME = NAN_TLV_TYPE_SDF_FIRST,
89     NAN_TLV_TYPE_SDF_MATCH_FILTER,
90     NAN_TLV_TYPE_TX_MATCH_FILTER,
91     NAN_TLV_TYPE_RX_MATCH_FILTER,
92     NAN_TLV_TYPE_SERVICE_SPECIFIC_INFO,
93     NAN_TLV_TYPE_GROUP_KEY,
94     NAN_TLV_TYPE_EXT_SERVICE_SPECIFIC_INFO,
95     NAN_TLV_TYPE_SDF_LAST = 4095,
96 
97     /* Configuration types */
98     NAN_TLV_TYPE_CONFIG_FIRST = 4096,
99     NAN_TLV_TYPE_5G_SUPPORT = NAN_TLV_TYPE_CONFIG_FIRST,
100     NAN_TLV_TYPE_SID_BEACON,
101     NAN_TLV_TYPE_5G_SYNC_DISC,
102     NAN_TLV_TYPE_RSSI_CLOSE,
103     NAN_TLV_TYPE_RSSI_MEDIUM,
104     NAN_TLV_TYPE_HOP_COUNT_LIMIT,
105     NAN_TLV_TYPE_RANDOM_UPDATE_TIME,
106     NAN_TLV_TYPE_MASTER_PREFERENCE,
107     NAN_TLV_TYPE_EARLY_WAKEUP,
108     NAN_TLV_TYPE_PERIODIC_SCAN_INTERVAL,
109     NAN_TLV_TYPE_CLUSTER_ID_LOW,
110     NAN_TLV_TYPE_CLUSTER_ID_HIGH,
111     NAN_TLV_TYPE_RSSI_CLOSE_PROXIMITY,
112     NAN_TLV_TYPE_FURTHER_AVAILABILITY,
113     NAN_TLV_TYPE_CONFIG_LAST = 8191,
114 
115     /* Statistics types */
116     NAN_TLV_TYPE_STATS_FIRST = 8192,
117     NAN_TLV_TYPE_DE_PUBLISH_STATS = NAN_TLV_TYPE_STATS_FIRST,
118     NAN_TLV_TYPE_DE_SUBSCRIBE_STATS,
119     NAN_TLV_TYPE_DE_MAC_STATS,
120     NAN_TLV_TYPE_DE_TIMING_SYNC_STATS,
121     NAN_TLV_TYPE_DE_DW_STATS,
122     NAN_TLV_TYPE_DE_STATS,
123     NAN_TLV_TYPE_STATS_LAST = 12287,
124 
125     /* Attributes types */
126     NAN_TLV_TYPE_ATTRS_FIRST = 12288,
127     NAN_TLV_TYPE_WLAN_INFRA_ATTR = NAN_TLV_TYPE_ATTRS_FIRST,
128     NAN_TLV_TYPE_P2P_OPERATION_ATTR,
129     NAN_TLV_TYPE_WLAN_IBSS_ATTR,
130     NAN_TLV_TYPE_WLAN_MESH_ATTR,
131     NAN_TLV_TYPE_WLAN_MESH_ID,
132     NAN_TLV_TYPE_SELF_MAC_ADDR,
133     NAN_TLV_TYPE_CLUSTER_SIZE,
134     NAN_TLV_TYPE_ATTRS_LAST = 16383,
135 
136 #ifdef NAN_2_0
137     NAN_TLV_TYPE_VENDOR_SPECIFIC_ATTRIBUTE_TRANSMIT = 30000,
138     NAN_TLV_TYPE_VENDOR_SPECIFIC_ATTRIBUTE_RECEIVE,
139     NAN_TLV_TYPE_POST_NAN_CONNECTIVITY_CAPABILITIES_RECEIVE,
140     NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_RECEIVE,
141     NAN_TLV_TYPE_BEACON_SDF_PAYLOAD_RECEIVE,
142 
143     NAN_TLV_TYPE_2DOT4G_SUPPORT = 30100,
144     NAN_TLV_TYPE_2DOT4G_BEACONS,
145     NAN_TLV_TYPE_2DOT4G_SDF,
146     NAN_TLV_TYPE_5G_BEACON,
147     NAN_TLV_TYPE_5G_SDF,
148     NAN_TLV_TYPE_5G_RSSI_CLOSE,
149     NAN_TLV_TYPE_5G_RSSI_MEDIUM,
150     NAN_TLV_TYPE_5G_RSSI_CLOSE_PROXIMITY,
151     NAN_TLV_TYPE_RSSI_AVERAGING_WINDOW_SIZE,
152     NAN_TLV_TYPE_CLUSTER_OUI_NETWORK_ID,
153     NAN_TLV_TYPE_SOURCE_MAC_ADDRESS,
154     NAN_TLV_TYPE_CLUSTER_ATTRIBUTE_IN_SDF,
155     NAN_TLV_TYPE_SOCIAL_CHANNEL_SCAN_PARAMETERS,
156     NAN_TLV_TYPE_DEBUGGING_FLAGS,
157     NAN_TLV_TYPE_POST_NAN_CONNECTIVITY_CAPABILITIES_TRANSMIT,
158     NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_TRANSMIT,
159     NAN_TLV_TYPE_FURTHER_AVAILABILITY_MAP,
160     NAN_TLV_TYPE_HOP_COUNT_FORCE,
161     NAN_TLV_TYPE_RANDOM_FACTOR_FORCE,
162 
163     NAN_TLV_TYPE_MAC_ADDRESS = 30200,
164     NAN_TLV_TYPE_RECEIVED_RSSI_VALUE,
165     NAN_TLV_TYPE_CLUSTER_ATTIBUTE,
166     NAN_TLV_TYPE_WLAN_INFRASTRUCTURE_SSID,
167 
168     NAN_TLV_TYPE_TCA_CLUSTER_SIZE_REQ = 30300,
169 #endif /* NAN_2_0 */
170     NAN_TLV_TYPE_LAST = 65535
171 } NanTlvType;
172 
173 /* 8-byte control message header used by NAN*/
174 typedef struct PACKED
175 {
176    u16 msgVersion:4;
177    u16 msgId:12;
178    u16 msgLen;
179    u16 handle;
180    u16 transactionId;
181 } NanMsgHeader, *pNanMsgHeader;
182 
183 /* Enumeration for Version */
184 typedef enum
185 {
186    NAN_MSG_VERSION1 = 1,
187 }NanMsgVersion;
188 
189 typedef struct PACKED
190 {
191     u16 type;
192     u16 length;
193     u8* value;
194 } NanTlv, *pNanTlv;
195 
196 #define SIZEOF_TLV_HDR (sizeof(NanTlv::type) + sizeof(NanTlv::length))
197 /* NAN TLV Groups and Types */
198 typedef enum
199 {
200     NAN_TLV_GROUP_FIRST = 0,
201     NAN_TLV_GROUP_SDF = NAN_TLV_GROUP_FIRST,
202     NAN_TLV_GROUP_CONFIG,
203     NAN_TLV_GROUP_STATS,
204     NAN_TLV_GROUP_ATTRS,
205     NAN_TLV_NUM_GROUPS,
206     NAN_TLV_GROUP_LAST = NAN_TLV_NUM_GROUPS
207 } NanTlvGroup;
208 
209 /* NAN Miscellaneous Constants */
210 #define NAN_TTL_INFINITE            0
211 #define NAN_REPLY_COUNT_INFINITE    0
212 
213 /* NAN Confguration 5G Channel Access Bit */
214 #define NAN_5G_CHANNEL_ACCESS_UNSUPPORTED   0
215 #define NAN_5G_CHANNEL_ACCESS_SUPPORTED     1
216 
217 /* NAN Configuration Service IDs Enclosure Bit */
218 #define NAN_SIDS_NOT_ENCLOSED_IN_BEACONS    0
219 #define NAN_SIBS_ENCLOSED_IN_BEACONS        1
220 
221 /* NAN Configuration Priority */
222 #define NAN_CFG_PRIORITY_SERVICE_DISCOVERY  0
223 #define NAN_CFG_PRIORITY_DATA_CONNECTION    1
224 
225 /* NAN Configuration 5G Channel Usage */
226 #define NAN_5G_CHANNEL_USAGE_SYNC_AND_DISCOVERY 0
227 #define NAN_5G_CHANNEL_USAGE_DISCOVERY_ONLY     1
228 
229 /* NAN Configuration TX_Beacon Content */
230 #define NAN_TX_BEACON_CONTENT_OLD_AM_INFO       0
231 #define NAN_TX_BEACON_CONTENT_UPDATED_AM_INFO   1
232 
233 /* NAN Configuration Miscellaneous Constants */
234 #define NAN_MAC_INTERFACE_PERIODICITY_MIN   30
235 #define NAN_MAC_INTERFACE_PERIODICITY_MAX   255
236 
237 #define NAN_DW_RANDOM_TIME_MIN  120
238 #define NAN_DW_RANDOM_TIME_MAX  240
239 
240 #define NAN_INITIAL_SCAN_MIN_IDEAL_PERIOD   200
241 #define NAN_INITIAL_SCAN_MAX_IDEAL_PERIOD   300
242 
243 #define NAN_ONGOING_SCAN_MIN_PERIOD 10
244 #define NAN_ONGOING_SCAN_MAX_PERIOD 30
245 
246 #define NAN_HOP_COUNT_LIMIT 5
247 
248 #define NAN_WINDOW_DW   0
249 #define NAN_WINDOW_FAW  1
250 
251 /* NAN Error Rsp */
252 typedef struct PACKED
253 {
254     NanMsgHeader fwHeader;
255     u16 status;
256     u16 value;
257 } NanErrorRspMsg, *pNanErrorRspMsg;
258 
259 //* NAN Publish Service Req */
260 typedef struct PACKED
261 {
262     u16 ttl;
263     u16 period;
264     u32 replyIndFlag:1;
265     u32 publishType:2;
266     u32 txType:1;
267 #ifdef NAN_2_0
268     u32 rssiThresholdFlag:1;
269     u32 ota_flag:1;
270     u32 matchAlg:2;
271 #else /* NAN_2_0 */
272     u32 reserved1:4;
273 #endif /* NAN_2_0 */
274     u32 count:8;
275 #ifdef NAN_2_0
276     u32 connmap:8;
277     u32 reserved2:8;
278 #else /* NAN_2_0 */
279     u32 reserved2:16;
280 #endif /* NAN_2_0 */
281     /*
282      * Excludes TLVs
283      *
284      * Required: Service Name,
285      * Optional: Tx Match Filter, Rx Match Filter, Service Specific Info,
286      */
287 } NanPublishServiceReqParams, *pNanPublishServiceReqParams;
288 
289 typedef struct PACKED
290 {
291     NanMsgHeader fwHeader;
292     NanPublishServiceReqParams publishServiceReqParams;
293     u8 ptlv[];
294 } NanPublishServiceReqMsg, *pNanPublishServiceReqMsg;
295 
296 /* NAN Publish Service Rsp */
297 typedef struct PACKED
298 {
299     NanMsgHeader fwHeader;
300     /* status of the request */
301     u16 status;
302     u16 value;
303 } NanPublishServiceRspMsg, *pNanPublishServiceRspMsg;
304 
305 /* NAN Publish Service Cancel Req */
306 typedef struct PACKED
307 {
308     NanMsgHeader fwHeader;
309 } NanPublishServiceCancelReqMsg, *pNanPublishServiceCancelReqMsg;
310 
311 /* NAN Publish Service Cancel Rsp */
312 typedef struct PACKED
313 {
314     NanMsgHeader fwHeader;
315     /* status of the request */
316     u16 status;
317     u16 value;
318 } NanPublishServiceCancelRspMsg, *pNanPublishServiceCancelRspMsg;
319 
320 /* NAN Publish Replied Ind */
321 typedef struct PACKED
322 {
323     SirMacAddr macAddr;
324     u16 reserved;
325 } NanPublishRepliedIndParams;
326 
327 typedef struct PACKED
328 {
329     NanMsgHeader fwHeader;
330 #ifndef NAN_2_0
331     NanPublishRepliedIndParams publishRepliedIndParams;
332 #else /* NAN_2_0 */
333     u8 ptlv[];
334 #endif /* NAN_2_0 */
335 } NanPublishRepliedIndMsg, *pNanPublishRepliedIndMsg;
336 
337 /* NAN Publish Terminated Ind */
338 typedef struct PACKED
339 {
340     NanMsgHeader fwHeader;
341     /* reason for the termination */
342     u16 reason;
343     u16 reserved;
344 } NanPublishTerminatedIndMsg, *pNanPublishTerminatedIndMsg;
345 
346 /* NAN Subscribe Service Req */
347 typedef struct PACKED
348 {
349     u16 ttl;
350     u16 period;
351     u32 subscribeType:1;
352     u32 srfAttr:1;
353     u32 srfInclude:1;
354     u32 srfSend:1;
355     u32 ssiRequired:1;
356 #ifndef NAN_2_0
357     u32 matchAlg:3;
358 #else /* NAN_2_0 */
359     u32 matchAlg:2;
360     u32 xbit:1;
361 #endif
362     u32 count:8;
363 #ifdef NAN_2_0
364     u32 rssiThresholdFlag:1;
365     u32 ota_flag:1;
366     u32 reserved:6;
367     u32 connmap:8;
368 #else /* NAN_2_0 */
369     u32 reserved:16;
370 #endif/* NAN_2_0 */
371     /*
372      * Excludes TLVs
373      *
374      * Required: Service Name
375      * Optional: Rx Match Filter, Tx Match Filter, Service Specific Info,
376      */
377 } NanSubscribeServiceReqParams, *pNanSubscribeServiceReqParams;
378 
379 typedef struct PACKED
380 {
381     NanMsgHeader fwHeader;
382     NanSubscribeServiceReqParams subscribeServiceReqParams;
383     u8 ptlv[];
384 } NanSubscribeServiceReqMsg, *pNanSubscribeServiceReqMsg;
385 
386 /* NAN Subscribe Service Rsp */
387 typedef struct PACKED
388 {
389     NanMsgHeader fwHeader;
390     /* status of the request */
391     u16 status;
392     u16 value;
393 } NanSubscribeServiceRspMsg, *pNanSubscribeServiceRspMsg;
394 
395 /* NAN Subscribe Service Cancel Req */
396 typedef struct PACKED
397 {
398     NanMsgHeader fwHeader;
399 } NanSubscribeServiceCancelReqMsg, *pNanSubscribeServiceCancelReqMsg;
400 
401 /* NAN Subscribe Service Cancel Rsp */
402 typedef struct PACKED
403 {
404     NanMsgHeader fwHeader;
405     /* status of the request */
406     u16 status;
407     u16 value;
408 } NanSubscribeServiceCancelRspMsg, *pNanSubscribeServiceCancelRspMsg;
409 
410 /* NAN Subscribe Match Ind */
411 typedef struct PACKED
412 {
413 #ifndef NAN_2_0
414     u16 matchHandle;
415     SirMacAddr macAddr;
416     /*
417      * Excludes TLVs
418      *
419      * Required: Service Name
420      * Optional: SDF Match Filter, Service Specific Info
421      */
422 #else /* NAN_2_0 */
423     u32 matchHandle;
424     u32 matchOccuredFlag:1;
425     u32 outOfResourceFlag:1;
426     u32 reserved:30;
427 #endif /* NAN_2_0 */
428 } NanMatchIndParams;
429 
430 typedef struct PACKED
431 {
432     NanMsgHeader fwHeader;
433     NanMatchIndParams matchIndParams;
434     u8 ptlv[];
435 } NanMatchIndMsg, *pNanMatchIndMsg;
436 
437 /* NAN Subscribe Unmatch Ind */
438 typedef struct PACKED
439 {
440 #ifndef NAN_2_0
441     u16 matchHandle;
442     u16 reserved;
443 #else
444     u32 matchHandle;
445 #endif
446 } NanUnmatchIndParams;
447 
448 typedef struct PACKED
449 {
450     NanMsgHeader fwHeader;
451     NanUnmatchIndParams unmatchIndParams;
452 } NanUnmatchIndMsg, *pNanUnmatchIndMsg;
453 
454 /* NAN Subscribe Terminated Ind */
455 typedef struct PACKED
456 {
457     NanMsgHeader fwHeader;
458     /* reason for the termination */
459     u16 reason;
460     u16 reserved;
461 } NanSubscribeTerminatedIndMsg, *pNanSubscribeTerminatedIndMsg;
462 
463 /* Event Ind */
464 typedef struct PACKED
465 {
466     u32 eventId:8;
467     u32 reserved:24;
468 } NanEventIndParams;
469 
470 typedef struct PACKED
471 {
472     NanMsgHeader fwHeader;
473 #ifndef NAN_2_0
474     NanEventIndParams eventIndParams;
475 #endif
476     u8 ptlv[];
477 } NanEventIndMsg, *pNanEventIndMsg;
478 
479 /* NAN Transmit Followup Req */
480 typedef struct PACKED
481 {
482 #ifndef NAN_2_0
483     SirMacAddr macAddr;
484     u16 priority:4;
485     u16 window:1;
486     u16 reserved:11;
487 #else /* NAN_2_0 */
488     u32 matchHandle;
489     u32 priority:4;
490     u32 window:1;
491     u32 reserved:27;
492 #endif /* NAN_2_0 */
493     /*
494      * Excludes TLVs
495      *
496      * Required: Service Specific Info or Extended Service Specific Info
497      */
498 } NanTransmitFollowupReqParams;
499 
500 typedef struct PACKED
501 {
502     NanMsgHeader fwHeader;
503     NanTransmitFollowupReqParams transmitFollowupReqParams;
504     u8 ptlv[];
505 } NanTransmitFollowupReqMsg, *pNanTransmitFollowupReqMsg;
506 
507 /* NAN Transmit Followup Rsp */
508 typedef struct PACKED
509 {
510     NanMsgHeader fwHeader;
511     /* status of the request */
512     u16 status;
513     u16 value;
514 } NanTransmitFollowupRspMsg, *pNanTransmitFollowupRspMsg;
515 
516 /* NAN Publish Followup Ind */
517 typedef struct PACKED
518 {
519 #ifndef NAN_2_0
520     SirMacAddr macAddr;
521     u16 window:1;
522     u16 reserved:15;
523 #else /* NAN_2_0 */
524     u32 matchHandle;
525     u32 window:1;
526     u32 reserved:31;
527 #endif /* NAN_2_0 */
528     /*
529      * Excludes TLVs
530      *
531      * Required: Service Specific Info or Extended Service Specific Info
532      */
533 } NanFollowupIndParams;
534 
535 typedef struct PACKED
536 {
537     NanMsgHeader fwHeader;
538     NanFollowupIndParams followupIndParams;
539     u8 ptlv[];
540 } NanFollowupIndMsg, *pNanFollowupIndMsg;
541 
542 /* NAN Statistics Req */
543 typedef struct PACKED
544 {
545     u32 statsId:8;
546     u32 clear:1;
547     u32 reserved:23;
548 } NanStatsReqParams, *pNanStatsReqParams;
549 
550 typedef struct PACKED
551 {
552     NanMsgHeader fwHeader;
553     NanStatsReqParams statsReqParams;
554 } NanStatsReqMsg, *pNanStatsReqMsg;
555 
556 /* NAN Statistics Rsp */
557 typedef struct PACKED
558 {
559     /* status of the request */
560     u16 status;
561     u16 value;
562     u8 statsId;
563     u8 reserved;
564 } NanStatsRspParams, *pNanStatsRspParams;
565 
566 typedef struct PACKED
567 {
568     NanMsgHeader fwHeader;
569     NanStatsRspParams statsRspParams;
570     u8 ptlv[];
571 } NanStatsRspMsg, *pNanStatsRspMsg;
572 
573 typedef struct PACKED
574 {
575     u8 count:7;
576     u8 s:1;
577 } NanSidAttr, *pSidAttr;
578 
579 
580 /* NAN Configuration Req */
581 typedef struct PACKED
582 {
583     NanMsgHeader fwHeader;
584     /*
585      * TLVs:
586      *
587      * Required: None.
588      * Optional: SID, Random Time, Master Preference, WLAN Intra Attr,
589      *           P2P Operation Attr, WLAN IBSS Attr, WLAN Mesh Attr
590      */
591     u8 ptlv[];
592 } NanConfigurationReqMsg, *pNanConfigurationReqMsg;
593 
594 /*
595  * Because the Configuration Req message has TLVs in it use the macro below
596  * for the size argument to buffer allocation functions (vs. sizeof(msg)).
597  */
598 #define NAN_MAX_CONFIGURATION_REQ_SIZE                       \
599     (                                                        \
600         sizeof(NanMsgHeader)                             +   \
601         SIZEOF_TLV_HDR + sizeof(u8)  /* SID Beacon    */ +   \
602         SIZEOF_TLV_HDR + sizeof(u8)  /* Random Time   */ +   \
603         SIZEOF_TLV_HDR + sizeof(u8)  /* Master Pref   */     \
604     )
605 
606 /* NAN Configuration Rsp */
607 typedef struct PACKED
608 {
609     NanMsgHeader fwHeader;
610     /* status of the request */
611     u16 status;
612     u16 value;
613 } NanConfigurationRspMsg, *pNanConfigurationRspMsg;
614 
615 /*
616  * Because the Enable Req message has TLVs in it use the macro below for
617  * the size argument to buffer allocation functions (vs. sizeof(msg)).
618  */
619 #define NAN_MAX_ENABLE_REQ_SIZE                                 \
620     (                                                           \
621         sizeof(NanMsgHeader)                                +   \
622         SIZEOF_TLV_HDR + sizeof(u8)  /* 5G            */    +   \
623         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster Low   */    +   \
624         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster High  */    +   \
625         SIZEOF_TLV_HDR + sizeof(u8)  /* SID Beacon    */    +   \
626         SIZEOF_TLV_HDR + sizeof(u8)  /* RSSI Close    */    +   \
627         SIZEOF_TLV_HDR + sizeof(u8)  /* RSSI Medium   */    +   \
628         SIZEOF_TLV_HDR + sizeof(u8)  /* HC Limit      */    +   \
629         SIZEOF_TLV_HDR + sizeof(u8)  /* Random Time   */    +   \
630         SIZEOF_TLV_HDR + sizeof(u8)  /* Master Pref   */    +   \
631         SIZEOF_TLV_HDR + sizeof(u8)  /* Full Scan Int */        \
632     )
633 
634 /* NAN Enable Req */
635 typedef struct PACKED
636 {
637     NanMsgHeader fwHeader;
638     /*
639      * TLVs:
640      *
641      * Required: Cluster Low, Cluster High, Master Preference,
642      * Optional: 5G Support, SID, 5G Sync Disc, RSSI Close, RSSI Medium,
643      *           Hop Count Limit, Random Time, Master Preference,
644      *           WLAN Intra Attr, P2P Operation Attr, WLAN IBSS Attr,
645      *           WLAN Mesh Attr
646      */
647     u8 ptlv[];
648 } NanEnableReqMsg, *pNanEnableReqMsg;
649 
650 /* NAN Enable Rsp */
651 typedef struct PACKED
652 {
653     NanMsgHeader fwHeader;
654     /* status of the request */
655     u16 status;
656     u16 value;
657 } NanEnableRspMsg, *pNanEnableRspMsg;
658 
659 /* NAN Disable Req */
660 typedef struct PACKED
661 {
662     NanMsgHeader fwHeader;
663 } NanDisableReqMsg, *pNanDisableReqMsg;
664 
665 /* NAN Disable Rsp */
666 typedef struct PACKED
667 {
668     NanMsgHeader fwHeader;
669     /* status of the request */
670     u16 status;
671     u16 reserved;
672 } NanDisableRspMsg, *pNanDisableRspMsg;
673 
674 /* NAN Disable Ind */
675 typedef struct PACKED
676 {
677     NanMsgHeader fwHeader;
678     /* reason for the termination */
679     u16 reason;
680     u16 reserved;
681 } NanDisableIndMsg, *pNanDisableIndMsg;
682 
683 /* NAN TCA Req */
684 typedef struct PACKED
685 {
686     u32 tcaId:8;
687     u32 rising:1;
688     u32 falling:1;
689     u32 clear:1;
690     u32 reserved:21;
691     u32 threshold;
692 } NanTcaReqParams, *pNanTcaReqParams;
693 
694 typedef struct PACKED
695 {
696     NanMsgHeader fwHeader;
697 #ifndef NAN_2_0
698     NanTcaReqParams tcaReqParams;
699 #else /* NAN_2_0 */
700     u8 ptlv[];
701 #endif
702 } NanTcaReqMsg, *pNanTcaReqMsg;
703 
704 /* NAN TCA Rsp */
705 typedef struct PACKED
706 {
707     NanMsgHeader   fwHeader;
708     /* status of the request */
709     u16 status;
710     u16 value;
711 } NanTcaRspMsg, *pNanTcaRspMsg;
712 
713 /* NAN TCA Ind */
714 typedef struct PACKED
715 {
716     u32 tcaId:8;
717     u32 reserved:24;
718 } NanTcaIndParams, *pNanTcaIndParams;
719 
720 typedef struct PACKED
721 {
722     NanMsgHeader fwHeader;
723 #ifndef NAN_2_0
724     NanTcaIndParams tcaIndParams;
725 #endif /* NAN_2_0 */
726     /*
727      * TLVs:
728      *
729      * Optional: Cluster size.
730      */
731     u8 ptlv[];
732 } NanTcaIndMsg, *pNanTcaIndMsg;
733 
734 /*
735  * Because the TCA Ind message has TLVs in it use the macro below for the
736  * size argument to buffer allocation functions (vs. sizeof(msg)).
737  */
738 #define NAN_MAX_TCA_IND_SIZE                                 \
739     (                                                        \
740         sizeof(NanMsgHeader)                             +   \
741         sizeof(NanTcaIndParams)                          +   \
742         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster Size */      \
743     )
744 
745 /* Function Declarations */
746 u8* addTlv(u16 type, u16 length, const u8* value, u8* pOutTlv);
747 u16 NANTLV_ReadTlv(u8 *pInTlv, pNanTlv pOutTlv);
748 u16 NANTLV_WriteTlv(pNanTlv pInTlv, u8 *pOutTlv);
749 
750 u16 getNanTlvtypeFromFWTlvtype(u16 fwTlvtype);
751 u16 getFWTlvtypeFromNanTlvtype(u16 nanTlvtype);
752 
753 #ifdef NAN_2_0
754 /* NAN Beacon Sdf Payload Req */
755 typedef struct PACKED
756 {
757     NanMsgHeader fwHeader;
758     /*
759      * TLVs:
760      *
761      * Optional: Vendor specific attribute
762      */
763     u8 ptlv[];
764 } NanBeaconSdfPayloadReqMsg, *pNanBeaconSdfPayloadReqMsg;
765 
766 /* NAN Beacon Sdf Payload Rsp */
767 typedef struct PACKED
768 {
769     NanMsgHeader   fwHeader;
770     /* status of the request */
771     u16 status;
772     u16 reserved;
773 } NanBeaconSdfPayloadRspMsg, *pNanBeaconSdfPayloadRspMsg;
774 
775 /* NAN Beacon Sdf Payload Ind */
776 typedef struct PACKED
777 {
778     NanMsgHeader fwHeader;
779     /*
780      * TLVs:
781      *
782      * Required: Mac address
783      * Optional: Vendor specific attribute, sdf payload
784      * receive
785      */
786     u8 ptlv[];
787 } NanBeaconSdfPayloadIndMsg, *pNanBeaconSdfPayloadIndMsg;
788 
789 
790 typedef enum
791 {
792     NAN_TLV_TYPE_FW_FIRST = 0,
793 
794     /* Service Discovery Frame types */
795     NAN_TLV_TYPE_FW_SDF_FIRST = NAN_TLV_TYPE_FW_FIRST,
796     NAN_TLV_TYPE_FW_SERVICE_NAME = NAN_TLV_TYPE_FW_SDF_FIRST,
797     NAN_TLV_TYPE_FW_SDF_MATCH_FILTER,
798     NAN_TLV_TYPE_FW_TX_MATCH_FILTER,
799     NAN_TLV_TYPE_FW_RX_MATCH_FILTER,
800     NAN_TLV_TYPE_FW_SERVICE_SPECIFIC_INFO,
801     NAN_TLV_TYPE_FW_EXT_SERVICE_SPECIFIC_INFO =5,
802     NAN_TLV_TYPE_FW_VENDOR_SPECIFIC_ATTRIBUTE_TRANSMIT = 6,
803     NAN_TLV_TYPE_FW_VENDOR_SPECIFIC_ATTRIBUTE_RECEIVE = 7,
804     NAN_TLV_TYPE_FW_POST_NAN_CONNECTIVITY_CAPABILITIES_RECEIVE = 8,
805     NAN_TLV_TYPE_FW_POST_NAN_DISCOVERY_ATTRIBUTE_RECEIVE = 9,
806     NAN_TLV_TYPE_FW_BEACON_SDF_PAYLOAD_RECEIVE = 10,
807     NAN_TLV_TYPE_FW_SDF_LAST = 4095,
808 
809     /* Configuration types */
810     NAN_TLV_TYPE_FW_CONFIG_FIRST = 4096,
811     NAN_TLV_TYPE_FW_24G_SUPPORT = NAN_TLV_TYPE_FW_CONFIG_FIRST,
812     NAN_TLV_TYPE_FW_24G_BEACON,
813     NAN_TLV_TYPE_FW_24G_SDF,
814     NAN_TLV_TYPE_FW_24G_RSSI_CLOSE,
815     NAN_TLV_TYPE_FW_24G_RSSI_MIDDLE,
816     NAN_TLV_TYPE_FW_24G_RSSI_CLOSE_PROXIMITY,
817     NAN_TLV_TYPE_FW_5G_SUPPORT,
818     NAN_TLV_TYPE_FW_5G_BEACON,
819     NAN_TLV_TYPE_FW_5G_SDF,
820     NAN_TLV_TYPE_FW_5G_RSSI_CLOSE,
821     NAN_TLV_TYPE_FW_5G_RSSI_MIDDLE,
822     NAN_TLV_TYPE_FW_5G_RSSI_CLOSE_PROXIMITY,
823     NAN_TLV_TYPE_FW_SID_BEACON,
824     NAN_TLV_TYPE_FW_HOP_COUNT_LIMIT,
825     NAN_TLV_TYPE_FW_MASTER_PREFERENCE,
826     NAN_TLV_TYPE_FW_CLUSTER_ID_LOW,
827     NAN_TLV_TYPE_FW_CLUSTER_ID_HIGH,
828     NAN_TLV_TYPE_FW_RSSI_AVERAGING_WINDOW_SIZE,
829     NAN_TLV_TYPE_FW_CLUSTER_OUI_NETWORK_ID,
830     NAN_TLV_TYPE_FW_SOURCE_MAC_ADDRESS,
831     NAN_TLV_TYPE_FW_CLUSTER_ATTRIBUTE_IN_SDF,
832     NAN_TLV_TYPE_FW_SOCIAL_CHANNEL_SCAN_PARAMS,
833     NAN_TLV_TYPE_FW_DEBUGGING_FLAGS,
834     NAN_TLV_TYPE_FW_POST_NAN_CONNECTIVITY_CAPABILITIES_TRANSMIT,
835     NAN_TLV_TYPE_FW_POST_NAN_DISCOVERY_ATTRIBUTE_TRANSMIT,
836     NAN_TLV_TYPE_FW_FURTHER_AVAILABILITY_MAP,
837     NAN_TLV_TYPE_FW_HOP_COUNT_FORCE,
838     NAN_TLV_TYPE_FW_RANDOM_FACTOR_FORCE,
839     NAN_TLV_TYPE_FW_CONFIG_LAST = 8191,
840 
841     /* Attributes types */
842     NAN_TLV_TYPE_FW_ATTRS_FIRST = 8192,
843     NAN_TLV_TYPE_FW_AVAILABILITY_INTERVALS_MAP = NAN_TLV_TYPE_FW_ATTRS_FIRST,
844     NAN_TLV_TYPE_FW_WLAN_MESH_ID,
845     NAN_TLV_TYPE_FW_MAC_ADDRESS,
846     NAN_TLV_TYPE_FW_RECEIVED_RSSI_VALUE,
847     NAN_TLV_TYPE_FW_CLUSTER_ATTRIBUTE,
848     NAN_TLV_TYPE_FW_WLAN_INFRASTRUCTURE_SSID,
849     NAN_TLV_TYPE_FW_ATTRS_LAST = 12287,
850 
851     /* Events Type */
852     NAN_TLV_TYPE_FW_EVENTS_FIRST = 12288,
853     NAN_TLV_TYPE_FW_EVENT_SELF_STATION_MAC_ADDRESS = NAN_TLV_TYPE_FW_EVENTS_FIRST,
854     NAN_TLV_TYPE_FW_EVENT_STARTED_CLUSTER,
855     NAN_TLV_TYPE_FW_EVENT_JOINED_CLUSTER,
856     NAN_TLV_TYPE_FW_EVENT_CLUSTER_SCAN_RESULTS,
857     NAN_TLV_TYPE_FW_EVENTS_LAST = 16383,
858 
859     /* TCA Type */
860     NAN_TLV_TYPE_FW_TCA_FIRST = 16384,
861     NAN_TLV_TYPE_FW_TCA_CLUSTER_SIZE_REQ = NAN_TLV_TYPE_FW_TCA_FIRST,
862     NAN_TLV_TYPE_FW_TCA_CLUSTER_SIZE_RSP,
863     NAN_TLV_TYPE_FW_TCA_LAST = 16385,
864     /* Reserved 16386 - 20479*/
865     /* Reserved 20480 - 65535*/
866     NAN_TLV_TYPE_FW_LAST = 65535
867 } NanFwTlvType;
868 
869 typedef struct PACKED
870 {
871     u8 availIntDuration:2;
872     u8 mapId:4;
873     u8 reserved:2;
874 } NanApiEntryCtrl;
875 
876 /*
877  * Valid Operating Classes were derived from IEEE Std. 802.11-2012 Annex E
878  * Table E-4 Global Operating Classe and, filtered by channel, are: 81, 83,
879  * 84, 103, 114, 115, 116, 124, 125.
880  */
881 typedef struct PACKED
882 {
883     NanApiEntryCtrl entryCtrl;
884     u8 opClass;
885     u8 channel;
886     u8 availIntBitmap[4];
887 } NanFurtherAvailabilityChan, *pNanFurtherAvailabilityChan;
888 
889 typedef struct PACKED
890 {
891     u8 numChan;
892     u8 pFaChan[];
893 } NanFurtherAvailabilityMapAttrTlv, *pNanFurtherAvailabilityMapAttrTlv;
894 #endif /* NAN_2_0 */
895 
896 #ifdef __cplusplus
897 }
898 #endif /* __cplusplus */
899 
900 #endif /* __NAN_I_H__ */
901 
902