OSDN Git Service

Merge "[AWARE]: Add range report in SDEA params" am: 1da29541bc
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / wifi_nan.h
1 /*
2  * Copyright (C) 2016 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_H__
18 #define __NAN_H__
19
20 #include <net/if.h>
21 #include "wifi_hal.h"
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif /* __cplusplus */
27
28 /*****************************************************************************
29  * Neighbour Aware Network Service Structures and Functions
30  *****************************************************************************/
31
32 /*
33   Definitions
34   All multi-byte fields within all NAN protocol stack messages are assumed to be in Little Endian order.
35 */
36
37 typedef int NanVersion;
38 typedef u16 transaction_id;
39 typedef u32 NanDataPathId;
40
41 #define NAN_MAC_ADDR_LEN                6
42 #define NAN_MAJOR_VERSION               2
43 #define NAN_MINOR_VERSION               0
44 #define NAN_MICRO_VERSION               0
45 #define NAN_MAX_SOCIAL_CHANNELS         3
46
47 /* NAN Maximum Lengths */
48 #define NAN_MAX_SERVICE_NAME_LEN                255
49 #define NAN_MAX_MATCH_FILTER_LEN                255
50 #define NAN_MAX_SERVICE_SPECIFIC_INFO_LEN       1024
51 #define NAN_MAX_VSA_DATA_LEN                    1024
52 #define NAN_MAX_MESH_DATA_LEN                   32
53 #define NAN_MAX_INFRA_DATA_LEN                  32
54 #define NAN_MAX_CLUSTER_ATTRIBUTE_LEN           255
55 #define NAN_MAX_SUBSCRIBE_MAX_ADDRESS           42
56 #define NAN_MAX_FAM_CHANNELS                    32
57 #define NAN_MAX_POSTDISCOVERY_LEN               5
58 #define NAN_MAX_FRAME_DATA_LEN                  504
59 #define NAN_DP_MAX_APP_INFO_LEN                 512
60 #define NAN_ERROR_STR_LEN                       255
61 #define NAN_PMK_INFO_LEN                        32
62 #define NAN_MAX_SCID_BUF_LEN                    1024
63 #define NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN  1024
64
65 /*
66   Definition of various NanResponseType
67 */
68 typedef enum {
69     NAN_RESPONSE_ENABLED                = 0,
70     NAN_RESPONSE_DISABLED               = 1,
71     NAN_RESPONSE_PUBLISH                = 2,
72     NAN_RESPONSE_PUBLISH_CANCEL         = 3,
73     NAN_RESPONSE_TRANSMIT_FOLLOWUP      = 4,
74     NAN_RESPONSE_SUBSCRIBE              = 5,
75     NAN_RESPONSE_SUBSCRIBE_CANCEL       = 6,
76     NAN_RESPONSE_STATS                  = 7,
77     NAN_RESPONSE_CONFIG                 = 8,
78     NAN_RESPONSE_TCA                    = 9,
79     NAN_RESPONSE_ERROR                  = 10,
80     NAN_RESPONSE_BEACON_SDF_PAYLOAD     = 11,
81     NAN_GET_CAPABILITIES                = 12,
82     NAN_DP_INTERFACE_CREATE             = 13,
83     NAN_DP_INTERFACE_DELETE             = 14,
84     NAN_DP_INITIATOR_RESPONSE           = 15,
85     NAN_DP_RESPONDER_RESPONSE           = 16,
86     NAN_DP_END                          = 17
87 } NanResponseType;
88
89 /* NAN Publish Types */
90 typedef enum {
91     NAN_PUBLISH_TYPE_UNSOLICITED = 0,
92     NAN_PUBLISH_TYPE_SOLICITED,
93     NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED
94 } NanPublishType;
95
96 /* NAN Transmit Priorities */
97 typedef enum {
98     NAN_TX_PRIORITY_NORMAL = 0,
99     NAN_TX_PRIORITY_HIGH
100 } NanTxPriority;
101
102 /* NAN Statistics Request ID Codes */
103 typedef enum {
104     NAN_STATS_ID_DE_PUBLISH = 0,
105     NAN_STATS_ID_DE_SUBSCRIBE,
106     NAN_STATS_ID_DE_MAC,
107     NAN_STATS_ID_DE_TIMING_SYNC,
108     NAN_STATS_ID_DE_DW,
109     NAN_STATS_ID_DE
110 } NanStatsType;
111
112 /* NAN Protocol Event ID Codes */
113 typedef enum {
114     NAN_EVENT_ID_DISC_MAC_ADDR = 0,
115     NAN_EVENT_ID_STARTED_CLUSTER,
116     NAN_EVENT_ID_JOINED_CLUSTER
117 } NanDiscEngEventType;
118
119 /* NAN Data Path type */
120 typedef enum {
121     NAN_DATA_PATH_UNICAST_MSG = 0,
122     NAN_DATA_PATH_MULTICAST_MSG
123 } NdpType;
124
125 /* NAN Ranging Configuration */
126 typedef enum {
127     NAN_RANGING_DISABLE = 0,
128     NAN_RANGING_ENABLE
129 } NanRangingState;
130
131 /* TCA Type */
132 typedef enum {
133     NAN_TCA_ID_CLUSTER_SIZE = 0
134 } NanTcaType;
135
136 /*
137   Various NAN Protocol Response code
138 */
139 typedef enum {
140     /* NAN Protocol Response Codes */
141     NAN_STATUS_SUCCESS = 0,
142     /*  NAN Discovery Engine/Host driver failures */
143     NAN_STATUS_INTERNAL_FAILURE = 1,
144     /*  NAN OTA failures */
145     NAN_STATUS_PROTOCOL_FAILURE = 2,
146     /* if the publish/subscribe id is invalid */
147     NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID = 3,
148     /* If we run out of resources allocated */
149     NAN_STATUS_NO_RESOURCE_AVAILABLE = 4,
150     /* if invalid params are passed */
151     NAN_STATUS_INVALID_PARAM = 5,
152     /*  if the requestor instance id is invalid */
153     NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID = 6,
154     /*  if the ndp id is invalid */
155     NAN_STATUS_INVALID_NDP_ID = 7,
156     /* if NAN is enabled when wifi is turned off */
157     NAN_STATUS_NAN_NOT_ALLOWED = 8,
158     /* if over the air ack is not received */
159     NAN_STATUS_NO_OTA_ACK = 9,
160     /* If NAN is already enabled and we are try to re-enable the same */
161     NAN_STATUS_ALREADY_ENABLED = 10,
162     /* If followup message internal queue is full */
163     NAN_STATUS_FOLLOWUP_QUEUE_FULL = 11,
164     /* Unsupported concurrency session enabled, NAN disabled notified */
165     NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED = 12
166 } NanStatusType;
167
168 /* NAN Transmit Types */
169 typedef enum {
170     NAN_TX_TYPE_BROADCAST = 0,
171     NAN_TX_TYPE_UNICAST
172 } NanTxType;
173
174 /* NAN Subscribe Type */
175 typedef enum {
176     NAN_SUBSCRIBE_TYPE_PASSIVE = 0,
177     NAN_SUBSCRIBE_TYPE_ACTIVE
178 } NanSubscribeType;
179
180 /* NAN Service Response Filter Attribute Bit */
181 typedef enum {
182     NAN_SRF_ATTR_BLOOM_FILTER = 0,
183     NAN_SRF_ATTR_PARTIAL_MAC_ADDR
184 } NanSRFType;
185
186 /* NAN Service Response Filter Include Bit */
187 typedef enum {
188     NAN_SRF_INCLUDE_DO_NOT_RESPOND = 0,
189     NAN_SRF_INCLUDE_RESPOND
190 } NanSRFIncludeType;
191
192 /* NAN Match indication type */
193 typedef enum {
194     NAN_MATCH_ALG_MATCH_ONCE = 0,
195     NAN_MATCH_ALG_MATCH_CONTINUOUS,
196     NAN_MATCH_ALG_MATCH_NEVER
197 } NanMatchAlg;
198
199 /* NAN Transmit Window Type */
200 typedef enum {
201     NAN_TRANSMIT_IN_DW = 0,
202     NAN_TRANSMIT_IN_FAW
203 } NanTransmitWindowType;
204
205 /* NAN SRF State in Subscribe */
206 typedef enum {
207     NAN_DO_NOT_USE_SRF = 0,
208     NAN_USE_SRF
209 } NanSRFState;
210
211 /* NAN Include SSI in MatchInd */
212 typedef enum {
213     NAN_SSI_NOT_REQUIRED_IN_MATCH_IND = 0,
214     NAN_SSI_REQUIRED_IN_MATCH_IND
215 } NanSsiInMatchInd;
216
217 /* NAN DP security Configuration */
218 typedef enum {
219     NAN_DP_CONFIG_NO_SECURITY = 0,
220     NAN_DP_CONFIG_SECURITY
221 } NanDataPathSecurityCfgStatus;
222
223 /* Data request Responder's response */
224 typedef enum {
225     NAN_DP_REQUEST_ACCEPT = 0,
226     NAN_DP_REQUEST_REJECT
227 } NanDataPathResponseCode;
228
229 /* NAN DP channel config options */
230 typedef enum {
231     NAN_DP_CHANNEL_NOT_REQUESTED = 0,
232     NAN_DP_REQUEST_CHANNEL_SETUP,
233     NAN_DP_FORCE_CHANNEL_SETUP
234 } NanDataPathChannelCfg;
235
236 /* Enable/Disable NAN Ranging Auto response */
237 typedef enum {
238     NAN_RANGING_AUTO_RESPONSE_ENABLE = 1,
239     NAN_RANGING_AUTO_RESPONSE_DISABLE
240 } NanRangingAutoResponse;
241
242 /* Enable/Disable NAN service range report */
243 typedef enum {
244     NAN_DISABLE_RANGE_REPORT = 1,
245     NAN_ENABLE_RANGE_REPORT
246 } NanRangeReport;
247
248 /* NAN Range Response */
249 typedef enum {
250     NAN_RANGE_REQUEST_ACCEPT = 1,
251     NAN_RANGE_REQUEST_REJECT,
252     NAN_RANGE_REQUEST_CANCEL
253 } NanRangeResponse;
254
255 /* NAN Shared Key Security Cipher Suites Mask */
256 #define NAN_CIPHER_SUITE_SHARED_KEY_NONE 0x00
257 #define NAN_CIPHER_SUITE_SHARED_KEY_128_MASK  0x01
258 #define NAN_CIPHER_SUITE_SHARED_KEY_256_MASK  0x02
259
260 /* NAN ranging indication condition MASKS */
261 #define NAN_RANGING_INDICATE_CONTINUOUS_MASK   0x01
262 #define NAN_RANGING_INDICATE_INGRESS_MET_MASK  0x02
263 #define NAN_RANGING_INDICATE_EGRESS_MET_MASK   0x04
264
265 /*
266    Structure to set the Service Descriptor Extension
267    Attribute (SDEA) passed as part of NanPublishRequest/
268    NanSubscribeRequest/NanMatchInd.
269 */
270 typedef struct {
271     /*
272        Optional configuration of Data Path Enable request.
273        configure flag determines whether configuration needs
274        to be passed or not.
275     */
276     u8 config_nan_data_path;
277     NdpType ndp_type;
278     /*
279        NAN secuirty required flag to indicate
280        if the security is enabled or disabled
281     */
282     NanDataPathSecurityCfgStatus security_cfg;
283     /*
284        NAN ranging required flag to indicate
285        if ranging is enabled on disabled
286     */
287     NanRangingState ranging_state;
288     /*
289       Enable/Disable Ranging report,
290       when configured NanRangeReportInd received
291     */
292     NanRangeReport range_report;
293 } NanSdeaCtrlParams;
294
295 /*
296    Nan Ranging Peer Info in MatchInd
297 */
298 typedef struct {
299     /*
300        Distance to the NAN device with the MAC address indicated
301        with ranged mac address.
302     */
303     u32 range_measurement_cm;
304     /* Ranging event matching the configuration of continuous/ingress/egress. */
305     u32 ranging_event_type;
306 } NanRangeInfo;
307
308 /* Nan/NDP Capabilites info */
309 typedef struct {
310     u32 max_concurrent_nan_clusters;
311     u32 max_publishes;
312     u32 max_subscribes;
313     u32 max_service_name_len;
314     u32 max_match_filter_len;
315     u32 max_total_match_filter_len;
316     u32 max_service_specific_info_len;
317     u32 max_vsa_data_len;
318     u32 max_mesh_data_len;
319     u32 max_ndi_interfaces;
320     u32 max_ndp_sessions;
321     u32 max_app_info_len;
322     u32 max_queued_transmit_followup_msgs;
323     u32 cipher_suites_supported;
324     u32 max_subscribe_address;
325     u32 max_sdea_service_specific_info_len;
326 } NanCapabilities;
327
328 /*
329   Nan accept policy: Per service basis policy
330   Based on this policy(ALL/NONE), responder side
331   will send ACCEPT/REJECT
332 */
333 typedef enum {
334     NAN_SERVICE_ACCEPT_POLICY_NONE = 0,
335     /* Default value */
336     NAN_SERVICE_ACCEPT_POLICY_ALL
337 } NanServiceAcceptPolicy;
338
339 /*
340   Host can send Vendor specific attributes which the Discovery Engine can
341   enclose in Beacons and/or Service Discovery frames transmitted.
342   Below structure is used to populate that.
343 */
344 typedef struct {
345     /*
346        0 = transmit only in the next discovery window
347        1 = transmit in next 16 discovery window
348     */
349     u8 payload_transmit_flag;
350     /*
351        Below flags will determine in which all frames
352        the vendor specific attributes should be included
353     */
354     u8 tx_in_discovery_beacon;
355     u8 tx_in_sync_beacon;
356     u8 tx_in_service_discovery;
357     /* Organizationally Unique Identifier */
358     u32 vendor_oui;
359     /*
360        vendor specific attribute to be transmitted
361        vsa_len : Length of the vsa data.
362      */
363     u32 vsa_len;
364     u8 vsa[NAN_MAX_VSA_DATA_LEN];
365 } NanTransmitVendorSpecificAttribute;
366
367
368 /*
369   Discovery Engine will forward any Vendor Specific Attributes
370   which it received as part of this structure.
371 */
372 /* Mask to determine on which frames attribute was received */
373 #define RX_DISCOVERY_BEACON_MASK  0x01
374 #define RX_SYNC_BEACON_MASK       0x02
375 #define RX_SERVICE_DISCOVERY_MASK 0x04
376 typedef struct {
377     /*
378        Frames on which this vendor specific attribute
379        was received. Mask defined above
380     */
381     u8 vsa_received_on;
382     /* Organizationally Unique Identifier */
383     u32 vendor_oui;
384     /* vendor specific attribute */
385     u32 attr_len;
386     u8 vsa[NAN_MAX_VSA_DATA_LEN];
387 } NanReceiveVendorSpecificAttribute;
388
389 /*
390    NAN Beacon SDF Payload Received structure
391    Discovery engine sends the details of received Beacon or
392    Service Discovery Frames as part of this structure.
393 */
394 typedef struct {
395     /* Frame data */
396     u32 frame_len;
397     u8 frame_data[NAN_MAX_FRAME_DATA_LEN];
398 } NanBeaconSdfPayloadReceive;
399
400 /*
401   Host can set the Periodic scan parameters for each of the
402   3(6, 44, 149) Social channels. Only these channels are allowed
403   any other channels are rejected
404 */
405 typedef enum {
406     NAN_CHANNEL_24G_BAND = 0,
407     NAN_CHANNEL_5G_BAND_LOW,
408     NAN_CHANNEL_5G_BAND_HIGH
409 } NanChannelIndex;
410
411 /*
412    Structure to set the Social Channel Scan parameters
413    passed as part of NanEnableRequest/NanConfigRequest
414 */
415 typedef struct {
416     /*
417        Dwell time of each social channel in milliseconds
418        NanChannelIndex corresponds to the respective channel
419        If time set to 0 then the FW default time will be used.
420     */
421     u8 dwell_time[NAN_MAX_SOCIAL_CHANNELS]; // default value 200 msec
422
423     /*
424        Scan period of each social channel in seconds
425        NanChannelIndex corresponds to the respective channel
426        If time set to 0 then the FW default time will be used.
427     */
428     u16 scan_period[NAN_MAX_SOCIAL_CHANNELS]; // default value 20 sec
429 } NanSocialChannelScanParams;
430
431 /*
432   Host can send Post Connectivity Capability attributes
433   to be included in Service Discovery frames transmitted
434   as part of this structure.
435 */
436 typedef struct {
437     /*
438        0 = transmit only in the next discovery window
439        1 = transmit in next 16 discovery window
440     */
441     u8 payload_transmit_flag;
442     /* 1 - Wifi Direct supported 0 - Not supported */
443     u8 is_wfd_supported;
444     /* 1 - Wifi Direct Services supported 0 - Not supported */
445     u8 is_wfds_supported;
446     /* 1 - TDLS supported 0 - Not supported */
447     u8 is_tdls_supported;
448     /* 1 - IBSS supported 0 - Not supported */
449     u8 is_ibss_supported;
450     /* 1 - Mesh supported 0 - Not supported */
451     u8 is_mesh_supported;
452     /*
453        1 - NAN Device currently connect to WLAN Infra AP
454        0 - otherwise
455     */
456     u8 wlan_infra_field;
457 } NanTransmitPostConnectivityCapability;
458
459 /*
460   Discovery engine providing the post connectivity capability
461   received.
462 */
463 typedef struct {
464     /* 1 - Wifi Direct supported 0 - Not supported */
465     u8 is_wfd_supported;
466     /* 1 - Wifi Direct Services supported 0 - Not supported */
467     u8 is_wfds_supported;
468     /* 1 - TDLS supported 0 - Not supported */
469     u8 is_tdls_supported;
470     /* 1 - IBSS supported 0 - Not supported */
471     u8 is_ibss_supported;
472     /* 1 - Mesh supported 0 - Not supported */
473     u8 is_mesh_supported;
474     /*
475        1 - NAN Device currently connect to WLAN Infra AP
476        0 - otherwise
477     */
478     u8 wlan_infra_field;
479 } NanReceivePostConnectivityCapability;
480
481 /*
482   Indicates the availability interval duration associated with the
483   Availability Intervals Bitmap field
484 */
485 typedef enum {
486     NAN_DURATION_16MS = 0,
487     NAN_DURATION_32MS = 1,
488     NAN_DURATION_64MS = 2
489 } NanAvailDuration;
490
491 /* Further availability per channel information */
492 typedef struct {
493     /* Defined above */
494     NanAvailDuration entry_control;
495     /*
496        1 byte field indicating the frequency band the NAN Device
497        will be available as defined in IEEE Std. 802.11-2012
498        Annex E Table E-4 Global Operating Classes
499     */
500     u8 class_val;
501     /*
502        1 byte field indicating the channel the NAN Device
503        will be available.
504     */
505     u8 channel;
506     /*
507         Map Id - 4 bit field which identifies the Further
508         availability map attribute.
509     */
510     u8 mapid;
511     /*
512        divides the time between the beginnings of consecutive Discovery
513        Windows of a given NAN cluster into consecutive time intervals
514        of equal durations. The time interval duration is specified by
515        the Availability Interval Duration subfield of the Entry Control
516        field.
517
518        A Nan device that sets the i-th bit of the Availability
519        Intervals Bitmap to 1 shall be present during the corresponding
520        i-th time interval in the operation channel indicated by the
521        Operating Class and Channel Number fields in the same Availability Entry.
522
523        A Nan device that sets the i-th bit of the Availability Intervals Bitmap to
524        0 may be present during the corresponding i-th time interval in the operation
525        channel indicated by the Operating Class and Channel Number fields in the same
526        Availability Entry.
527
528        The size of the Bitmap is dependent upon the Availability Interval Duration
529        chosen in the Entry Control Field.  The size can be either 1, 2 or 4 bytes long
530
531        - Duration field is equal to 0, only AIB[0] is valid
532        - Duration field is equal to 1, only AIB [0] and AIB [1] is valid
533        - Duration field is equal to 2, AIB [0], AIB [1], AIB [2] and AIB [3] are valid
534     */
535     u32 avail_interval_bitmap;
536 } NanFurtherAvailabilityChannel;
537
538 /*
539   Further availability map which can be sent and received from
540   Discovery engine
541 */
542 typedef struct {
543     /*
544        Number of channels indicates the number of channel
545        entries which is part of fam
546     */
547     u8 numchans;
548     NanFurtherAvailabilityChannel famchan[NAN_MAX_FAM_CHANNELS];
549 } NanFurtherAvailabilityMap;
550
551 /*
552   Host can send Post-Nan Discovery attributes which the Discovery Engine can
553   enclose in Service Discovery frames
554 */
555 /* Possible connection types in Post NAN Discovery attributes */
556 typedef enum {
557     NAN_CONN_WLAN_INFRA = 0,
558     NAN_CONN_P2P_OPER = 1,
559     NAN_CONN_WLAN_IBSS = 2,
560     NAN_CONN_WLAN_MESH = 3,
561     NAN_CONN_FURTHER_SERVICE_AVAILABILITY = 4,
562     NAN_CONN_WLAN_RANGING = 5
563 } NanConnectionType;
564
565 /* Possible device roles in Post NAN Discovery attributes */
566 typedef enum {
567     NAN_WLAN_INFRA_AP = 0,
568     NAN_WLAN_INFRA_STA = 1,
569     NAN_P2P_OPER_GO = 2,
570     NAN_P2P_OPER_DEV = 3,
571     NAN_P2P_OPER_CLI = 4
572 } NanDeviceRole;
573
574 /* Configuration params of NAN Ranging */
575 typedef struct {
576     /*
577       Interval in milli sec between two ranging measurements.
578       If the Awake DW intervals in NanEnable/Config are larger
579       than the ranging intervals priority is given to Awake DW
580       Intervals. Only on a match the ranging is initiated for the
581       peer
582     */
583     u32 ranging_interval_msec;
584     /*
585       Flags indicating the type of ranging event to be notified
586       NAN_RANGING_INDICATE_ MASKS are used to set these.
587       BIT0 - Continuous Ranging event notification.
588       BIT1 - Ingress distance is <=.
589       BIT2 - Egress distance is >=.
590     */
591     u32 config_ranging_indications;
592     /* Ingress distance in centimeters (optional) */
593     u32 distance_ingress_cm;
594     /* Egress distance in centimeters (optional) */
595     u32 distance_egress_cm;
596 } NanRangingCfg;
597
598 /* NAN Ranging request's response */
599 typedef struct {
600     /* Publish Id of an earlier Publisher */
601     u16 publish_id;
602     /*
603        A 32 bit Requestor instance Id which is sent to the Application.
604        This Id will be used in subsequent RangeResponse on Subscribe side.
605     */
606     u32 requestor_instance_id;
607     /* Peer MAC addr of Range Requestor */
608     u8 peer_addr[NAN_MAC_ADDR_LEN];
609     /* Response indicating ACCEPT/REJECT/CANCEL of Range Request */
610     NanRangeResponse ranging_response;
611 } NanRangeResponseCfg;
612
613 /* Structure of Post NAN Discovery attribute */
614 typedef struct {
615     /* Connection type of the host */
616     NanConnectionType  type;
617     /*
618        Device role of the host based on
619        the connection type
620     */
621     NanDeviceRole role;
622     /*
623        Flag to send the information as a single shot or repeated
624        for next 16 discovery windows
625        0 - Single_shot
626        1 - next 16 discovery windows
627     */
628     u8 transmit_freq;
629     /* Duration of the availability bitmask */
630     NanAvailDuration duration;
631     /* Availability interval bitmap based on duration */
632     u32 avail_interval_bitmap;
633     /*
634        Mac address depending on the conn type and device role
635        --------------------------------------------------
636        | Conn Type  |  Device Role |  Mac address Usage  |
637        --------------------------------------------------
638        | WLAN_INFRA |  AP/STA      |   BSSID of the AP   |
639        --------------------------------------------------
640        | P2P_OPER   |  GO          |   GO's address      |
641        --------------------------------------------------
642        | P2P_OPER   |  P2P_DEVICE  |   Address of who    |
643        |            |              |   would become GO   |
644        --------------------------------------------------
645        | WLAN_IBSS  |  NA          |   BSSID             |
646        --------------------------------------------------
647        | WLAN_MESH  |  NA          |   BSSID             |
648        --------------------------------------------------
649     */
650     u8 addr[NAN_MAC_ADDR_LEN];
651     /*
652        Mandatory mesh id value if connection type is WLAN_MESH
653        Mesh id contains 0-32 octet identifier and should be
654        as per IEEE Std.802.11-2012 spec.
655     */
656     u16 mesh_id_len;
657     u8 mesh_id[NAN_MAX_MESH_DATA_LEN];
658     /*
659        Optional infrastructure SSID if conn_type is set to
660        NAN_CONN_WLAN_INFRA
661     */
662     u16 infrastructure_ssid_len;
663     u8 infrastructure_ssid_val[NAN_MAX_INFRA_DATA_LEN];
664 } NanTransmitPostDiscovery;
665
666 /*
667    Discovery engine providing the structure of Post NAN
668    Discovery
669 */
670 typedef struct {
671     /* Connection type of the host */
672     NanConnectionType  type;
673     /*
674        Device role of the host based on
675        the connection type
676     */
677     NanDeviceRole role;
678     /* Duration of the availability bitmask */
679     NanAvailDuration duration;
680     /* Availability interval bitmap based on duration */
681     u32 avail_interval_bitmap;
682     /*
683        Map Id - 4 bit field which identifies the Further
684        availability map attribute.
685     */
686     u8 mapid;
687     /*
688        Mac address depending on the conn type and device role
689        --------------------------------------------------
690        | Conn Type  |  Device Role |  Mac address Usage  |
691        --------------------------------------------------
692        | WLAN_INFRA |  AP/STA      |   BSSID of the AP   |
693        --------------------------------------------------
694        | P2P_OPER   |  GO          |   GO's address      |
695        --------------------------------------------------
696        | P2P_OPER   |  P2P_DEVICE  |   Address of who    |
697        |            |              |   would become GO   |
698        --------------------------------------------------
699        | WLAN_IBSS  |  NA          |   BSSID             |
700        --------------------------------------------------
701        | WLAN_MESH  |  NA          |   BSSID             |
702        --------------------------------------------------
703     */
704     u8 addr[NAN_MAC_ADDR_LEN];
705     /*
706        Mandatory mesh id value if connection type is WLAN_MESH
707        Mesh id contains 0-32 octet identifier and should be
708        as per IEEE Std.802.11-2012 spec.
709     */
710     u16 mesh_id_len;
711     u8 mesh_id[NAN_MAX_MESH_DATA_LEN];
712     /*
713        Optional infrastructure SSID if conn_type is set to
714        NAN_CONN_WLAN_INFRA
715     */
716     u16 infrastructure_ssid_len;
717     u8 infrastructure_ssid_val[NAN_MAX_INFRA_DATA_LEN];
718 } NanReceivePostDiscovery;
719
720 /*
721    NAN device level configuration of SDF and Sync beacons in both
722    2.4/5GHz bands
723 */
724 typedef struct {
725     /* Configure 2.4GHz DW Band */
726     u8 config_2dot4g_dw_band;
727     /*
728        Indicates the interval for Sync beacons and SDF's in 2.4GHz band.
729        Valid values of DW Interval are: 1, 2, 3, 4 and 5, 0 is reserved.
730        The SDF includes in OTA when enabled. The publish/subscribe period
731        values don't override the device level configurations.
732     */
733     u32 dw_2dot4g_interval_val; // default value 1
734     /* Configure 5GHz DW Band */
735     u8 config_5g_dw_band;
736     /*
737        Indicates the interval for Sync beacons and SDF's in 5GHz band
738        Valid values of DW Interval are: 1, 2, 3, 4 and 5, 0 no wake up for
739        any interval. The SDF includes in OTA when enabled. The publish/subscribe
740        period values don't override the device level configurations.
741     */
742     u32 dw_5g_interval_val; // default value 1 when 5G is enabled
743 } NanConfigDW;
744
745 /*
746   Enable Request Message Structure
747   The NanEnableReq message instructs the Discovery Engine to enter an operational state
748 */
749 typedef struct {
750     /* Mandatory parameters below */
751     u8 master_pref; // default value 0x02
752     /*
753       A cluster_low value matching cluster_high indicates a request to join
754       a cluster with that value. If the requested cluster is not found the
755       device will start its own cluster.
756     */
757     u16 cluster_low; // default value 0
758     u16 cluster_high; // default value 0xFFFF
759
760     /*
761       Optional configuration of Enable request.
762       Each of the optional parameters have configure flag which
763       determine whether configuration is to be passed or not.
764     */
765     u8 config_support_5g;
766     u8 support_5g_val; // default value 0; turned off by default
767     /*
768        BIT 0 is used to specify to include Service IDs in Sync/Discovery beacons
769        0 - Do not include SIDs in any beacons
770        1 - Include SIDs in all beacons.
771        Rest 7 bits are count field which allows control over the number of SIDs
772        included in the Beacon.  0 means to include as many SIDs that fit into
773        the maximum allow Beacon frame size
774     */
775     u8 config_sid_beacon;
776     u8 sid_beacon_val; // default value 0x01
777     /*
778        The rssi values below should be specified without sign.
779        For eg: -70dBm should be specified as 70.
780     */
781     u8 config_2dot4g_rssi_close;
782     u8 rssi_close_2dot4g_val;    // default value -60 dBm
783
784     u8 config_2dot4g_rssi_middle;
785     u8 rssi_middle_2dot4g_val;    // default value -70 dBm
786
787     u8 config_2dot4g_rssi_proximity;
788     u8 rssi_proximity_2dot4g_val;//  default value -60dBm
789
790     u8 config_hop_count_limit;
791     u8 hop_count_limit_val; //  default value 0x02
792
793     /*
794        Defines 2.4G channel access support
795        0 - No Support
796        1 - Supported
797     */
798     u8 config_2dot4g_support;
799     u8 support_2dot4g_val; // default value 0x01
800     /*
801        Defines 2.4G channels will be used for sync/discovery beacons
802        0 - 2.4G channels not used for beacons
803        1 - 2.4G channels used for beacons
804     */
805     u8 config_2dot4g_beacons;
806     u8 beacon_2dot4g_val; // default value 1
807     /*
808        Defines 2.4G channels will be used for Service Discovery frames
809        0 - 2.4G channels not used for Service Discovery frames
810        1 - 2.4G channels used for Service Discovery frames
811     */
812     u8 config_2dot4g_sdf;
813     u8 sdf_2dot4g_val; // default value 1
814     /*
815        Defines 5G channels will be used for sync/discovery beacons
816        0 - 5G channels not used for beacons
817        1 - 5G channels used for beacons
818     */
819     u8 config_5g_beacons;
820     u8 beacon_5g_val; // default value 1 when 5G is enabled
821     /*
822        Defines 5G channels will be used for Service Discovery frames
823        0 - 5G channels not used for Service Discovery frames
824        1 - 5G channels used for Service Discovery frames
825     */
826     u8 config_5g_sdf;
827     u8 sdf_5g_val; // default value is 0 when 5G is enabled
828     /*
829        1 byte value which defines the RSSI in
830        dBm for a close by Peer in 5 Ghz channels.
831        The rssi values should be specified without sign.
832        For eg: -70dBm should be specified as 70.
833     */
834     u8 config_5g_rssi_close;
835     u8 rssi_close_5g_val; // default value -60dBm when 5G is enabled
836     /*
837        1 byte value which defines the RSSI value in
838        dBm for a close by Peer in 5 Ghz channels.
839        The rssi values should be specified without sign.
840        For eg: -70dBm should be specified as 70.
841     */
842     u8 config_5g_rssi_middle;
843     u8 rssi_middle_5g_val; // default value -75dBm when 5G is enabled
844     /*
845        1 byte value which defines the RSSI filter
846        threshold.  Any Service Descriptors received above this
847        value that are configured for RSSI filtering will be dropped.
848        The rssi values should be specified without sign.
849        For eg: -70dBm should be specified as 70.
850     */
851     u8 config_5g_rssi_close_proximity;
852     u8 rssi_close_proximity_5g_val; // default value -60dBm when 5G is enabled
853     /*
854        1 byte quantity which defines the window size over
855        which the “average RSSI” will be calculated over.
856     */
857     u8 config_rssi_window_size;
858     u8 rssi_window_size_val; // default value 0x08
859     /*
860        The 24 bit Organizationally Unique ID + the 8 bit Network Id.
861     */
862     u8 config_oui;
863     u32 oui_val; // default value {0x51, 0x6F, 0x9A, 0x01, 0x00, 0x00}
864     /*
865        NAN Interface Address, If not configured the Discovery Engine
866        will generate a 6 byte Random MAC.
867     */
868     u8 config_intf_addr;
869     u8 intf_addr_val[NAN_MAC_ADDR_LEN];
870     /*
871        If set to 1, the Discovery Engine will enclose the Cluster
872        Attribute only sent in Beacons in a Vendor Specific Attribute
873        and transmit in a Service Descriptor Frame.
874     */
875     u8 config_cluster_attribute_val;
876     /*
877        The periodicity in seconds between full scan’s to find any new
878        clusters available in the area.  A Full scan should not be done
879        more than every 10 seconds and should not be done less than every
880        30 seconds.
881     */
882     u8 config_scan_params;
883     NanSocialChannelScanParams scan_params_val;
884     /*
885        1 byte quantity which forces the Random Factor to a particular
886        value for all transmitted Sync/Discovery beacons
887     */
888     u8 config_random_factor_force;
889     u8 random_factor_force_val; // default value off and set to 0x00
890     /*
891        1 byte quantity which forces the HC for all transmitted Sync and
892        Discovery Beacon NO matter the real HC being received over the
893        air.
894     */
895     u8 config_hop_count_force;
896     u8 hop_count_force_val; // default value 0x00
897
898     /* channel frequency in MHz to enable Nan on */
899     u8 config_24g_channel;
900     wifi_channel channel_24g_val; // default value channel 0x6
901
902     u8 config_5g_channel;
903     wifi_channel channel_5g_val; // default value channel 44 or 149 regulatory
904                                  // domain
905     /* Configure 2.4/5GHz DW */
906     NanConfigDW config_dw;
907
908     /*
909        By default discovery MAC address randomization is enabled
910        and default interval value is 30 minutes i.e. 1800 seconds.
911        The value 0 is used to disable MAC addr randomization.
912     */
913     u8 config_disc_mac_addr_randomization;
914     u32 disc_mac_addr_rand_interval_sec; // default value 1800 sec
915
916     /*
917       Set/Enable corresponding bits to disable Discovery indications:
918       BIT0 - Disable Discovery MAC Address Event.
919       BIT1 - Disable Started Cluster Event.
920       BIT2 - Disable Joined Cluster Event.
921     */
922     u8 discovery_indication_cfg;  // default value 0x0
923 } NanEnableRequest;
924
925 /*
926   Publish Msg Structure
927   Message is used to request the DE to publish the Service Name
928   using the parameters passed into the Discovery Window
929 */
930 typedef struct {
931     u16 publish_id;/* id  0 means new publish, any other id is existing publish */
932     u16 ttl; /* how many seconds to run for. 0 means forever until canceled */
933     /*
934        period: Awake DW Interval for publish(service)
935        Indicates the interval between two Discovery Windows in which
936        the device supporting the service is awake to transmit or
937        receive the Service Discovery frames.
938        Valid values of Awake DW Interval are: 1, 2, 4, 8 and 16, value 0 will
939        default to 1.
940     */
941     u16 period;
942     NanPublishType publish_type;/* 0= unsolicited, solicited = 1, 2= both */
943     NanTxType tx_type; /* 0 = broadcast, 1= unicast  if solicited publish */
944     u8 publish_count; /* number of OTA Publish, 0 means forever until canceled */
945     u16 service_name_len; /* length of service name */
946     u8 service_name[NAN_MAX_SERVICE_NAME_LEN];/* UTF-8 encoded string identifying the service */
947     /*
948        Field which specifies how the matching indication to host is controlled.
949        0 - Match and Indicate Once
950        1 - Match and Indicate continuous
951        2 - Match and Indicate never. This means don't indicate the match to the host.
952        3 - Reserved
953     */
954     NanMatchAlg publish_match_indicator;
955
956     /*
957        Sequence of values
958        NAN Device that has invoked a Subscribe method corresponding to this Publish method
959     */
960     u16 service_specific_info_len;
961     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
962
963     /*
964        Ordered sequence of <length, value> pairs which specify further response conditions
965        beyond the service name used to filter subscribe messages to respond to.
966        This is only needed when the PT is set to NAN_SOLICITED or NAN_SOLICITED_UNSOLICITED.
967     */
968     u16 rx_match_filter_len;
969     u8 rx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
970
971     /*
972        Ordered sequence of <length, value> pairs to be included in the Discovery Frame.
973        If present it is always sent in a Discovery Frame
974     */
975     u16 tx_match_filter_len;
976     u8 tx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
977
978     /*
979        flag which specifies that the Publish should use the configured RSSI
980        threshold and the received RSSI in order to filter requests
981        0 – ignore the configured RSSI threshold when running a Service
982            Descriptor attribute or Service ID List Attribute through the DE matching logic.
983        1 – use the configured RSSI threshold when running a Service
984            Descriptor attribute or Service ID List Attribute through the DE matching logic.
985
986     */
987     u8 rssi_threshold_flag;
988
989     /*
990        8-bit bitmap which allows the Host to associate this publish
991        with a particular Post-NAN Connectivity attribute
992        which has been sent down in a NanConfigureRequest/NanEnableRequest
993        message.  If the DE fails to find a configured Post-NAN
994        connectivity attributes referenced by the bitmap,
995        the DE will return an error code to the Host.
996        If the Publish is configured to use a Post-NAN Connectivity
997        attribute and the Host does not refresh the Post-NAN Connectivity
998        attribute the Publish will be canceled and the Host will be sent
999        a PublishTerminatedIndication message.
1000     */
1001     u8 connmap;
1002     /*
1003       Set/Enable corresponding bits to disable any indications that follow a publish.
1004       BIT0 - Disable publish termination indication.
1005       BIT1 - Disable match expired indication.
1006       BIT2 - Disable followUp indication received (OTA).
1007     */
1008     u8 recv_indication_cfg;
1009     /*
1010       Nan accept policy for the specific service(publish)
1011     */
1012     NanServiceAcceptPolicy service_responder_policy;
1013     /* NAN Cipher Suite Type */
1014     u32 cipher_type;
1015     /* pmk length */
1016     u8 pmk_len;
1017     /*
1018        PMK: Info is optional in Discovery phase. PMK info can be passed during
1019        the NDP session.
1020      */
1021     u8 pmk[NAN_PMK_INFO_LEN];
1022
1023     /* Security Context Identifiers length */
1024     u32 scid_len;
1025     /*
1026        Security Context Identifier attribute contains PMKID
1027        shall be included in NDP setup and response messages.
1028        Security Context Identifier, Identifies the Security
1029        Context. For NAN Shared Key Cipher Suite, this field
1030        contains the 16 octet PMKID identifying the PMK used
1031        for setting up the Secure Data Path.
1032     */
1033     u8 scid[NAN_MAX_SCID_BUF_LEN];
1034
1035     /* NAN configure service discovery extended attributes */
1036     NanSdeaCtrlParams sdea_params;
1037
1038     /* NAN Ranging configuration */
1039     NanRangingCfg ranging_cfg;
1040
1041     /* Enable/disable NAN serivce Ranging auto response mode */
1042     NanRangingAutoResponse ranging_auto_response;
1043
1044     /*
1045       When the ranging_auto_response_cfg is not set, NanRangeRequestInd is
1046       received. Nan Range Response to Peer MAC Addr is notified to indicate
1047       ACCEPT/REJECT/CANCEL to the requestor.
1048     */
1049     NanRangeResponseCfg range_response_cfg;
1050
1051     /*
1052        Sequence of values indicating the service specific info in SDEA
1053     */
1054     u16 sdea_service_specific_info_len;
1055     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
1056 } NanPublishRequest;
1057
1058 /*
1059   Publish Cancel Msg Structure
1060   The PublishServiceCancelReq Message is used to request the DE to stop publishing
1061   the Service Name identified by the Publish Id in the message.
1062 */
1063 typedef struct {
1064     u16 publish_id;
1065 } NanPublishCancelRequest;
1066
1067 /*
1068   NAN Subscribe Structure
1069   The SubscribeServiceReq message is sent to the Discovery Engine
1070   whenever the Upper layers would like to listen for a Service Name
1071 */
1072 typedef struct {
1073     u16 subscribe_id; /* id 0 means new subscribe, non zero is existing subscribe */
1074     u16 ttl; /* how many seconds to run for. 0 means forever until canceled */
1075     /*
1076        period: Awake DW Interval for subscribe(service)
1077        Indicates the interval between two Discovery Windows in which
1078        the device supporting the service is awake to transmit or
1079        receive the Service Discovery frames.
1080        Valid values of Awake DW Interval are: 1, 2, 4, 8 and 16, value 0 will
1081        default to 1.
1082     */
1083     u16 period;
1084
1085     /* Flag which specifies how the Subscribe request shall be processed. */
1086     NanSubscribeType subscribe_type; /* 0 - PASSIVE , 1- ACTIVE */
1087
1088     /* Flag which specifies on Active Subscribes how the Service Response Filter attribute is populated.*/
1089     NanSRFType serviceResponseFilter; /* 0 - Bloom Filter, 1 - MAC Addr */
1090
1091     /* Flag which specifies how the Service Response Filter Include bit is populated.*/
1092     NanSRFIncludeType serviceResponseInclude; /* 0=Do not respond if in the Address Set, 1= Respond */
1093
1094     /* Flag which specifies if the Service Response Filter should be used when creating Subscribes.*/
1095     NanSRFState useServiceResponseFilter; /* 0=Do not send the Service Response Filter,1= send */
1096
1097     /*
1098        Flag which specifies if the Service Specific Info is needed in
1099        the Publish message before creating the MatchIndication
1100     */
1101     NanSsiInMatchInd ssiRequiredForMatchIndication; /* 0=Not needed, 1= Required */
1102
1103     /*
1104        Field which specifies how the matching indication to host is controlled.
1105        0 - Match and Indicate Once
1106        1 - Match and Indicate continuous
1107        2 - Match and Indicate never. This means don't indicate the match to the host.
1108        3 - Reserved
1109     */
1110     NanMatchAlg subscribe_match_indicator;
1111
1112     /*
1113        The number of Subscribe Matches which should occur
1114        before the Subscribe request is automatically terminated.
1115     */
1116     u8 subscribe_count; /* If this value is 0 this field is not used by the DE.*/
1117
1118     u16 service_name_len;/* length of service name */
1119     u8 service_name[NAN_MAX_SERVICE_NAME_LEN]; /* UTF-8 encoded string identifying the service */
1120
1121     /* Sequence of values which further specify the published service beyond the service name*/
1122     u16 service_specific_info_len;
1123     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
1124
1125     /*
1126        Ordered sequence of <length, value> pairs used to filter out received publish discovery messages.
1127        This can be sent both for a Passive or an Active Subscribe
1128     */
1129     u16 rx_match_filter_len;
1130     u8 rx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
1131
1132     /*
1133        Ordered sequence of <length, value> pairs  included in the
1134        Discovery Frame when an Active Subscribe is used.
1135     */
1136     u16 tx_match_filter_len;
1137     u8 tx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
1138
1139     /*
1140        Flag which specifies that the Subscribe should use the configured RSSI
1141        threshold and the received RSSI in order to filter requests
1142        0 – ignore the configured RSSI threshold when running a Service
1143            Descriptor attribute or Service ID List Attribute through the DE matching logic.
1144        1 – use the configured RSSI threshold when running a Service
1145            Descriptor attribute or Service ID List Attribute through the DE matching logic.
1146
1147     */
1148     u8 rssi_threshold_flag;
1149
1150     /*
1151        8-bit bitmap which allows the Host to associate this Active
1152        Subscribe with a particular Post-NAN Connectivity attribute
1153        which has been sent down in a NanConfigureRequest/NanEnableRequest
1154        message.  If the DE fails to find a configured Post-NAN
1155        connectivity attributes referenced by the bitmap,
1156        the DE will return an error code to the Host.
1157        If the Subscribe is configured to use a Post-NAN Connectivity
1158        attribute and the Host does not refresh the Post-NAN Connectivity
1159        attribute the Subscribe will be canceled and the Host will be sent
1160        a SubscribeTerminatedIndication message.
1161     */
1162     u8 connmap;
1163     /*
1164        NAN Interface Address, conforming to the format as described in
1165        8.2.4.3.2 of IEEE Std. 802.11-2012.
1166     */
1167     u8 num_intf_addr_present;
1168     u8 intf_addr[NAN_MAX_SUBSCRIBE_MAX_ADDRESS][NAN_MAC_ADDR_LEN];
1169     /*
1170       Set/Enable corresponding bits to disable indications that follow a subscribe.
1171       BIT0 - Disable subscribe termination indication.
1172       BIT1 - Disable match expired indication.
1173       BIT2 - Disable followUp indication received (OTA).
1174     */
1175     u8 recv_indication_cfg;
1176
1177     /* NAN Cipher Suite Type */
1178     u32 cipher_type;
1179     /* pmk length */
1180     u8 pmk_len;
1181     /*
1182        PMK: Info is optional in Discovery phase. PMK info can be passed during
1183        the NDP session.
1184     */
1185     u8 pmk[NAN_PMK_INFO_LEN];
1186
1187     /* Security Context Identifiers length */
1188     u32 scid_len;
1189     /*
1190        Security Context Identifier attribute contains PMKID
1191        shall be included in NDP setup and response messages.
1192        Security Context Identifier, Identifies the Security
1193        Context. For NAN Shared Key Cipher Suite, this field
1194        contains the 16 octet PMKID identifying the PMK used
1195        for setting up the Secure Data Path.
1196     */
1197     u8 scid[NAN_MAX_SCID_BUF_LEN];
1198
1199     /* NAN configure service discovery extended attributes */
1200     NanSdeaCtrlParams sdea_params;
1201
1202     /* NAN Ranging configuration */
1203     NanRangingCfg ranging_cfg;
1204
1205     /* Enable/disable NAN serivce Ranging auto response mode */
1206     NanRangingAutoResponse ranging_auto_response;
1207
1208     /*
1209       When the ranging_auto_response_cfg is not set, NanRangeRequestInd is
1210       received. Nan Range Response to Peer MAC Addr is notified to indicate
1211       ACCEPT/REJECT/CANCEL to the requestor.
1212     */
1213     NanRangeResponseCfg range_response_cfg;
1214
1215     /*
1216        Sequence of values indicating the service specific info in SDEA
1217     */
1218     u16 sdea_service_specific_info_len;
1219     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
1220 } NanSubscribeRequest;
1221
1222 /*
1223   NAN Subscribe Cancel Structure
1224   The SubscribeCancelReq Message is used to request the DE to stop looking for the Service Name.
1225 */
1226 typedef struct {
1227     u16 subscribe_id;
1228 } NanSubscribeCancelRequest;
1229
1230 /*
1231   Transmit follow up Structure
1232   The TransmitFollowupReq message is sent to the DE to allow the sending of the Service_Specific_Info
1233   to a particular MAC address.
1234 */
1235 typedef struct {
1236     /* Publish or Subscribe Id of an earlier Publish/Subscribe */
1237     u16 publish_subscribe_id;
1238
1239     /*
1240        This Id is the Requestor Instance that is passed as
1241        part of earlier MatchInd/FollowupInd message.
1242     */
1243     u32 requestor_instance_id;
1244     u8 addr[NAN_MAC_ADDR_LEN]; /* Unicast address */
1245     NanTxPriority priority; /* priority of the request 2=high */
1246     NanTransmitWindowType dw_or_faw; /* 0= send in a DW, 1=send in FAW */
1247
1248     /*
1249        Sequence of values which further specify the published service beyond
1250        the service name.
1251     */
1252     u16 service_specific_info_len;
1253     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
1254     /*
1255       Set/Enable corresponding bits to disable responses after followUp.
1256       BIT0 - Disable followUp response from FW.
1257     */
1258     u8 recv_indication_cfg;
1259
1260     /*
1261        Sequence of values indicating the service specific info in SDEA
1262     */
1263     u16 sdea_service_specific_info_len;
1264     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
1265 } NanTransmitFollowupRequest;
1266
1267 /*
1268   Stats Request structure
1269   The Discovery Engine can be queried at runtime by the Host processor for statistics
1270   concerning various parts of the Discovery Engine.
1271 */
1272 typedef struct {
1273     NanStatsType stats_type; /* NAN Statistics Request Type */
1274     u8 clear; /* 0= Do not clear the stats and return the current contents , 1= Clear the associated stats  */
1275 } NanStatsRequest;
1276
1277 /*
1278   Config Structure
1279   The NanConfigurationReq message is sent by the Host to the
1280   Discovery Engine in order to configure the Discovery Engine during runtime.
1281 */
1282 typedef struct {
1283     u8 config_sid_beacon;
1284     u8 sid_beacon;
1285     u8 config_rssi_proximity;
1286     u8 rssi_proximity; // default value -60dBm
1287     u8 config_master_pref;
1288     u8 master_pref; // default value 0x02
1289     /*
1290        1 byte value which defines the RSSI filter threshold.
1291        Any Service Descriptors received above this value
1292        that are configured for RSSI filtering will be dropped.
1293        The rssi values should be specified without sign.
1294        For eg: -70dBm should be specified as 70.
1295     */
1296     u8 config_5g_rssi_close_proximity;
1297     u8 rssi_close_proximity_5g_val;  // default value -60dBm
1298     /*
1299       Optional configuration of Configure request.
1300       Each of the optional parameters have configure flag which
1301       determine whether configuration is to be passed or not.
1302     */
1303     /*
1304        2 byte quantity which defines the window size over
1305        which the “average RSSI” will be calculated over.
1306     */
1307     u8 config_rssi_window_size;
1308     u16 rssi_window_size_val; // default value 0x08
1309     /*
1310        If set to 1, the Discovery Engine will enclose the Cluster
1311        Attribute only sent in Beacons in a Vendor Specific Attribute
1312        and transmit in a Service Descriptor Frame.
1313     */
1314     u8 config_cluster_attribute_val;
1315     /*
1316       The periodicity in seconds between full scan’s to find any new
1317       clusters available in the area.  A Full scan should not be done
1318       more than every 10 seconds and should not be done less than every
1319       30 seconds.
1320     */
1321     u8 config_scan_params;
1322     NanSocialChannelScanParams scan_params_val;
1323     /*
1324        1 byte quantity which forces the Random Factor to a particular
1325        value for all transmitted Sync/Discovery beacons
1326     */
1327     u8 config_random_factor_force;
1328     u8 random_factor_force_val; // default value 0x00
1329     /*
1330        1 byte quantity which forces the HC for all transmitted Sync and
1331        Discovery Beacon NO matter the real HC being received over the
1332        air.
1333     */
1334     u8 config_hop_count_force;
1335     u8 hop_count_force_val; // default value of 0
1336     /* NAN Post Connectivity Capability */
1337     u8 config_conn_capability;
1338     NanTransmitPostConnectivityCapability conn_capability_val;
1339     /* NAN Post Discover Capability */
1340     u8 num_config_discovery_attr;
1341     NanTransmitPostDiscovery discovery_attr_val[NAN_MAX_POSTDISCOVERY_LEN];
1342     /* NAN Further availability Map */
1343     u8 config_fam;
1344     NanFurtherAvailabilityMap fam_val;
1345     /* Configure 2.4/5GHz DW */
1346     NanConfigDW config_dw;
1347     /*
1348        By default discovery MAC address randomization is enabled
1349        and default interval value is 30 minutes i.e. 1800 seconds.
1350        The value 0 is used to disable MAC addr randomization.
1351     */
1352     u8 config_disc_mac_addr_randomization;
1353     u32 disc_mac_addr_rand_interval_sec; // default value of 30 minutes
1354
1355     /*
1356       Set/Enable corresponding bits to disable Discovery indications:
1357       BIT0 - Disable Discovery MAC Address Event.
1358       BIT1 - Disable Started Cluster Event.
1359       BIT2 - Disable Joined Cluster Event.
1360     */
1361     u8 discovery_indication_cfg; // default value of 0
1362 } NanConfigRequest;
1363
1364 /*
1365   TCA Structure
1366   The Discovery Engine can be configured to send up Events whenever a configured
1367   Threshold Crossing Alert (TCA) Type crosses an integral threshold in a particular direction.
1368 */
1369 typedef struct {
1370     NanTcaType tca_type; /* Nan Protocol Threshold Crossing Alert (TCA) Codes */
1371
1372     /* flag which control whether or not an event is generated for the Rising direction */
1373     u8 rising_direction_evt_flag; /* 0 - no event, 1 - event */
1374
1375     /* flag which control whether or not an event is generated for the Falling direction */
1376     u8 falling_direction_evt_flag;/* 0 - no event, 1 - event */
1377
1378     /* flag which requests a previous TCA request to be cleared from the DE */
1379     u8 clear;/*0= Do not clear the TCA, 1=Clear the TCA */
1380
1381     /* 32 bit value which represents the threshold to be used.*/
1382     u32 threshold;
1383 } NanTCARequest;
1384
1385 /*
1386   Beacon Sdf Payload Structure
1387   The Discovery Engine can be configured to publish vendor specific attributes as part of
1388   beacon or service discovery frame transmitted as part of this request..
1389 */
1390 typedef struct {
1391     /*
1392        NanVendorAttribute will have the Vendor Specific Attribute which the
1393        vendor wants to publish as part of Discovery or Sync or Service discovery frame
1394     */
1395     NanTransmitVendorSpecificAttribute vsa;
1396 } NanBeaconSdfPayloadRequest;
1397
1398 /* Publish statistics. */
1399 typedef struct
1400 {
1401     u32 validPublishServiceReqMsgs;
1402     u32 validPublishServiceRspMsgs;
1403     u32 validPublishServiceCancelReqMsgs;
1404     u32 validPublishServiceCancelRspMsgs;
1405     u32 validPublishRepliedIndMsgs;
1406     u32 validPublishTerminatedIndMsgs;
1407     u32 validActiveSubscribes;
1408     u32 validMatches;
1409     u32 validFollowups;
1410     u32 invalidPublishServiceReqMsgs;
1411     u32 invalidPublishServiceCancelReqMsgs;
1412     u32 invalidActiveSubscribes;
1413     u32 invalidMatches;
1414     u32 invalidFollowups;
1415     u32 publishCount;
1416     u32 publishNewMatchCount;
1417     u32 pubsubGlobalNewMatchCount;
1418 } NanPublishStats;
1419
1420 /* Subscribe statistics. */
1421 typedef struct
1422 {
1423     u32 validSubscribeServiceReqMsgs;
1424     u32 validSubscribeServiceRspMsgs;
1425     u32 validSubscribeServiceCancelReqMsgs;
1426     u32 validSubscribeServiceCancelRspMsgs;
1427     u32 validSubscribeTerminatedIndMsgs;
1428     u32 validSubscribeMatchIndMsgs;
1429     u32 validSubscribeUnmatchIndMsgs;
1430     u32 validSolicitedPublishes;
1431     u32 validMatches;
1432     u32 validFollowups;
1433     u32 invalidSubscribeServiceReqMsgs;
1434     u32 invalidSubscribeServiceCancelReqMsgs;
1435     u32 invalidSubscribeFollowupReqMsgs;
1436     u32 invalidSolicitedPublishes;
1437     u32 invalidMatches;
1438     u32 invalidFollowups;
1439     u32 subscribeCount;
1440     u32 bloomFilterIndex;
1441     u32 subscribeNewMatchCount;
1442     u32 pubsubGlobalNewMatchCount;
1443 } NanSubscribeStats;
1444
1445 /* NAN DW Statistics*/
1446 typedef struct
1447 {
1448     /* RX stats */
1449     u32 validFrames;
1450     u32 validActionFrames;
1451     u32 validBeaconFrames;
1452     u32 ignoredActionFrames;
1453     u32 ignoredBeaconFrames;
1454     u32 invalidFrames;
1455     u32 invalidActionFrames;
1456     u32 invalidBeaconFrames;
1457     u32 invalidMacHeaders;
1458     u32 invalidPafHeaders;
1459     u32 nonNanBeaconFrames;
1460
1461     u32 earlyActionFrames;
1462     u32 inDwActionFrames;
1463     u32 lateActionFrames;
1464
1465     /* TX stats */
1466     u32 framesQueued;
1467     u32 totalTRSpUpdates;
1468     u32 completeByTRSp;
1469     u32 completeByTp75DW;
1470     u32 completeByTendDW;
1471     u32 lateActionFramesTx;
1472 } NanDWStats;
1473
1474 /* NAN MAC Statistics. */
1475 typedef struct
1476 {
1477     /* RX stats */
1478     u32 validFrames;
1479     u32 validActionFrames;
1480     u32 validBeaconFrames;
1481     u32 ignoredActionFrames;
1482     u32 ignoredBeaconFrames;
1483     u32 invalidFrames;
1484     u32 invalidActionFrames;
1485     u32 invalidBeaconFrames;
1486     u32 invalidMacHeaders;
1487     u32 invalidPafHeaders;
1488     u32 nonNanBeaconFrames;
1489
1490     u32 earlyActionFrames;
1491     u32 inDwActionFrames;
1492     u32 lateActionFrames;
1493
1494     /* TX stats */
1495     u32 framesQueued;
1496     u32 totalTRSpUpdates;
1497     u32 completeByTRSp;
1498     u32 completeByTp75DW;
1499     u32 completeByTendDW;
1500     u32 lateActionFramesTx;
1501
1502     u32 twIncreases;
1503     u32 twDecreases;
1504     u32 twChanges;
1505     u32 twHighwater;
1506     u32 bloomFilterIndex;
1507 } NanMacStats;
1508
1509 /* NAN Sync Statistics*/
1510 typedef struct
1511 {
1512     u64 currTsf;
1513     u64 myRank;
1514     u64 currAmRank;
1515     u64 lastAmRank;
1516     u32 currAmBTT;
1517     u32 lastAmBTT;
1518     u8  currAmHopCount;
1519     u8  currRole;
1520     u16 currClusterId;
1521
1522     u64 timeSpentInCurrRole;
1523     u64 totalTimeSpentAsMaster;
1524     u64 totalTimeSpentAsNonMasterSync;
1525     u64 totalTimeSpentAsNonMasterNonSync;
1526     u32 transitionsToAnchorMaster;
1527     u32 transitionsToMaster;
1528     u32 transitionsToNonMasterSync;
1529     u32 transitionsToNonMasterNonSync;
1530     u32 amrUpdateCount;
1531     u32 amrUpdateRankChangedCount;
1532     u32 amrUpdateBTTChangedCount;
1533     u32 amrUpdateHcChangedCount;
1534     u32 amrUpdateNewDeviceCount;
1535     u32 amrExpireCount;
1536     u32 mergeCount;
1537     u32 beaconsAboveHcLimit;
1538     u32 beaconsBelowRssiThresh;
1539     u32 beaconsIgnoredNoSpace;
1540     u32 beaconsForOurCluster;
1541     u32 beaconsForOtherCluster;
1542     u32 beaconCancelRequests;
1543     u32 beaconCancelFailures;
1544     u32 beaconUpdateRequests;
1545     u32 beaconUpdateFailures;
1546     u32 syncBeaconTxAttempts;
1547     u32 syncBeaconTxFailures;
1548     u32 discBeaconTxAttempts;
1549     u32 discBeaconTxFailures;
1550     u32 amHopCountExpireCount;
1551     u32 ndpChannelFreq;
1552 } NanSyncStats;
1553
1554 /* NAN Misc DE Statistics */
1555 typedef struct
1556 {
1557     u32 validErrorRspMsgs;
1558     u32 validTransmitFollowupReqMsgs;
1559     u32 validTransmitFollowupRspMsgs;
1560     u32 validFollowupIndMsgs;
1561     u32 validConfigurationReqMsgs;
1562     u32 validConfigurationRspMsgs;
1563     u32 validStatsReqMsgs;
1564     u32 validStatsRspMsgs;
1565     u32 validEnableReqMsgs;
1566     u32 validEnableRspMsgs;
1567     u32 validDisableReqMsgs;
1568     u32 validDisableRspMsgs;
1569     u32 validDisableIndMsgs;
1570     u32 validEventIndMsgs;
1571     u32 validTcaReqMsgs;
1572     u32 validTcaRspMsgs;
1573     u32 validTcaIndMsgs;
1574     u32 invalidTransmitFollowupReqMsgs;
1575     u32 invalidConfigurationReqMsgs;
1576     u32 invalidStatsReqMsgs;
1577     u32 invalidEnableReqMsgs;
1578     u32 invalidDisableReqMsgs;
1579     u32 invalidTcaReqMsgs;
1580 } NanDeStats;
1581
1582 /* Publish Response Message structure */
1583 typedef struct {
1584     u16 publish_id;
1585 } NanPublishResponse;
1586
1587 /* Subscribe Response Message structure */
1588 typedef struct {
1589     u16 subscribe_id;
1590 } NanSubscribeResponse;
1591
1592 /*
1593   Stats Response Message structure
1594   The Discovery Engine response to a request by the Host for statistics.
1595 */
1596 typedef struct {
1597     NanStatsType stats_type;
1598     union {
1599         NanPublishStats publish_stats;
1600         NanSubscribeStats subscribe_stats;
1601         NanMacStats mac_stats;
1602         NanSyncStats sync_stats;
1603         NanDeStats de_stats;
1604         NanDWStats dw_stats;
1605     } data;
1606 } NanStatsResponse;
1607
1608 /* Response returned for Initiators Data request */
1609 typedef struct {
1610     /*
1611       Unique token Id generated on the initiator
1612       side used for a NDP session between two NAN devices
1613     */
1614     NanDataPathId ndp_instance_id;
1615 } NanDataPathRequestResponse;
1616
1617 /*
1618   NAN Response messages
1619 */
1620 typedef struct {
1621     NanStatusType status; /* contains the result code */
1622     char nan_error[NAN_ERROR_STR_LEN]; /* Describe the NAN error type */
1623     NanResponseType response_type; /* NanResponseType Definitions */
1624     union {
1625         NanPublishResponse publish_response;
1626         NanSubscribeResponse subscribe_response;
1627         NanStatsResponse stats_response;
1628         NanDataPathRequestResponse data_request_response;
1629         NanCapabilities nan_capabilities;
1630     } body;
1631 } NanResponseMsg;
1632
1633 /*
1634   Publish Terminated
1635   The PublishTerminatedInd message is sent by the DE whenever a Publish
1636   terminates from a user-specified timeout or a unrecoverable error in the DE.
1637 */
1638 typedef struct {
1639     /* Id returned during the initial Publish */
1640     u16 publish_id;
1641     /*
1642       For all user configured termination NAN_STATUS_SUCCESS
1643       and no other reasons expected from firmware.
1644     */
1645     NanStatusType reason;
1646     char nan_reason[NAN_ERROR_STR_LEN]; /* Describe the NAN reason type */
1647 } NanPublishTerminatedInd;
1648
1649 /*
1650   Match Indication
1651   The MatchInd message is sent once per responding MAC address whenever
1652   the Discovery Engine detects a match for a previous SubscribeServiceReq
1653   or PublishServiceReq.
1654 */
1655 typedef struct {
1656     /* Publish or Subscribe Id of an earlier Publish/Subscribe */
1657     u16 publish_subscribe_id;
1658     /*
1659        A 32 bit Requestor Instance Id which is sent to the Application.
1660        This Id will be sent in any subsequent UnmatchInd/FollowupInd
1661        messages
1662     */
1663     u32 requestor_instance_id;
1664     u8 addr[NAN_MAC_ADDR_LEN];
1665
1666     /*
1667        Sequence of octets which were received in a Discovery Frame matching the
1668        Subscribe Request.
1669     */
1670     u16 service_specific_info_len;
1671     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
1672
1673     /*
1674        Ordered sequence of <length, value> pairs received in the Discovery Frame
1675        matching the Subscribe Request.
1676     */
1677     u16 sdf_match_filter_len;
1678     u8 sdf_match_filter[NAN_MAX_MATCH_FILTER_LEN];
1679
1680     /*
1681        flag to indicate if the Match occurred in a Beacon Frame or in a
1682        Service Discovery Frame.
1683          0 - Match occured in a Service Discovery Frame
1684          1 - Match occured in a Beacon Frame
1685     */
1686     u8 match_occured_flag;
1687
1688     /*
1689        flag to indicate FW is out of resource and that it can no longer
1690        track this Service Name. The Host still need to send the received
1691        Match_Handle but duplicate MatchInd messages may be received on
1692        this Handle until the resource frees up.
1693          0 - FW is caching this match
1694          1 - FW is unable to cache this match
1695     */
1696     u8 out_of_resource_flag;
1697
1698     /*
1699        If RSSI filtering was configured in NanSubscribeRequest then this
1700        field will contain the received RSSI value. 0 if not.
1701        All rssi values should be specified without sign.
1702        For eg: -70dBm should be specified as 70.
1703     */
1704     u8 rssi_value;
1705
1706     /*
1707        optional attributes. Each optional attribute is associated with a flag
1708        which specifies whether the attribute is valid or not
1709     */
1710     /* NAN Post Connectivity Capability received */
1711     u8 is_conn_capability_valid;
1712     NanReceivePostConnectivityCapability conn_capability;
1713
1714     /* NAN Post Discover Capability */
1715     u8 num_rx_discovery_attr;
1716     NanReceivePostDiscovery discovery_attr[NAN_MAX_POSTDISCOVERY_LEN];
1717
1718     /* NAN Further availability Map */
1719     u8 num_chans;
1720     NanFurtherAvailabilityChannel famchan[NAN_MAX_FAM_CHANNELS];
1721
1722     /* NAN Cluster Attribute */
1723     u8 cluster_attribute_len;
1724     u8 cluster_attribute[NAN_MAX_CLUSTER_ATTRIBUTE_LEN];
1725
1726     /* NAN Cipher Suite */
1727     u32 peer_cipher_type;
1728
1729     /* Security Context Identifiers length */
1730     u32 scid_len;
1731     /*
1732        Security Context Identifier attribute contains PMKID
1733        shall be included in NDP setup and response messages.
1734        Security Context Identifier, Identifies the Security
1735        Context. For NAN Shared Key Cipher Suite, this field
1736        contains the 16 octet PMKID identifying the PMK used
1737        for setting up the Secure Data Path.
1738     */
1739     u8 scid[NAN_MAX_SCID_BUF_LEN];
1740
1741     /* Peer service discovery extended attributes */
1742     NanSdeaCtrlParams peer_sdea_params;
1743
1744     /*
1745       Ranging indication and NanMatchAlg are not tied.
1746       Ex: NanMatchAlg can indicate Match_ONCE, but ranging
1747       indications can be continuous. All ranging indications
1748       depend on SDEA control parameters of ranging required for
1749       continuous, and ingress/egress values in the ranging config.
1750       Ranging indication data is notified if:
1751       1) Ranging required is enabled in SDEA.
1752          range info notified continuous.
1753       2) if range_limit ingress/egress MASKS are enabled
1754          notify once for ingress >= ingress_distance
1755          and egress <= egress_distance, same for ingress_egress_both
1756       3) if the Awake DW intervals are higher than the ranging intervals,
1757          priority is given to the device DW intervalsi.
1758     */
1759     /*
1760       Range Info includes:
1761       1) distance to the NAN device with the MAC address indicated
1762          with ranged mac address.
1763       2) Ranging event matching the configuration of continuous/ingress/egress.
1764     */
1765     NanRangeInfo range_info;
1766
1767     /*
1768        Sequence of values indicating the service specific info in SDEA
1769     */
1770     u16 sdea_service_specific_info_len;
1771     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
1772 } NanMatchInd;
1773
1774 /*
1775   MatchExpired Indication
1776   The MatchExpiredInd message is sent whenever the Discovery Engine detects that
1777   a previously Matched Service has been gone for too long. If the previous
1778   MatchInd message for this Publish/Subscribe Id had the out_of_resource_flag
1779   set then this message will not be received
1780 */
1781 typedef struct {
1782     /* Publish or Subscribe Id of an earlier Publish/Subscribe */
1783     u16 publish_subscribe_id;
1784     /*
1785        32 bit value sent by the DE in a previous
1786        MatchInd/FollowupInd to the application.
1787     */
1788     u32 requestor_instance_id;
1789 } NanMatchExpiredInd;
1790
1791 /*
1792   Subscribe Terminated
1793   The SubscribeTerminatedInd message is sent by the DE whenever a
1794   Subscribe terminates from a user-specified timeout or a unrecoverable error in the DE.
1795 */
1796 typedef struct {
1797     /* Id returned during initial Subscribe */
1798     u16 subscribe_id;
1799     /*
1800       For all user configured termination NAN_STATUS_SUCCESS
1801       and no other reasons expected from firmware.
1802     */
1803     NanStatusType reason;
1804     char nan_reason[NAN_ERROR_STR_LEN]; /* Describe the NAN reason type */
1805 } NanSubscribeTerminatedInd;
1806
1807 /*
1808   Followup Indication Message
1809   The FollowupInd message is sent by the DE to the Host whenever it receives a
1810   Followup message from another peer.
1811 */
1812 typedef struct {
1813     /* Publish or Subscribe Id of an earlier Publish/Subscribe */
1814     u16 publish_subscribe_id;
1815     /*
1816        A 32 bit Requestor instance Id which is sent to the Application.
1817        This Id will be used in subsequent UnmatchInd/FollowupInd messages.
1818     */
1819     u32 requestor_instance_id;
1820     u8 addr[NAN_MAC_ADDR_LEN];
1821
1822     /* Flag which the DE uses to decide if received in a DW or a FAW*/
1823     u8 dw_or_faw; /* 0=Received  in a DW, 1 = Received in a FAW*/
1824
1825     /*
1826        Sequence of values which further specify the published service beyond
1827        the service name
1828     */
1829     u16 service_specific_info_len;
1830     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
1831
1832     /*
1833        Sequence of values indicating the service specific info in SDEA
1834     */
1835     u16 sdea_service_specific_info_len;
1836     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
1837 } NanFollowupInd;
1838
1839 /*
1840    Event data notifying the Mac address of the Discovery engine.
1841    which is reported as one of the Discovery engine event
1842 */
1843 typedef struct {
1844     u8 addr[NAN_MAC_ADDR_LEN];
1845 } NanMacAddressEvent;
1846
1847 /*
1848    Event data notifying the Cluster address of the cluster
1849    which is reported as one of the Discovery engine event
1850 */
1851 typedef struct {
1852     u8 addr[NAN_MAC_ADDR_LEN];
1853 } NanClusterEvent;
1854
1855 /*
1856   Discovery Engine Event Indication
1857   The Discovery Engine can inform the Host when significant events occur
1858   The data following the EventId is dependent upon the EventId type.
1859   In other words, each new event defined will carry a different
1860   structure of information back to the host.
1861 */
1862 typedef struct {
1863     NanDiscEngEventType event_type; /* NAN Protocol Event Codes */
1864     union {
1865         /*
1866            MacAddressEvent which will have 6 byte mac address
1867            of the Discovery engine.
1868         */
1869         NanMacAddressEvent mac_addr;
1870         /*
1871            Cluster Event Data which will be obtained when the
1872            device starts a new cluster or joins a cluster.
1873            The event data will have 6 byte octet string of the
1874            cluster started or joined.
1875         */
1876         NanClusterEvent cluster;
1877     } data;
1878 } NanDiscEngEventInd;
1879
1880 /* Cluster size TCA event*/
1881 typedef struct {
1882     /* size of the cluster*/
1883     u32 cluster_size;
1884 } NanTcaClusterEvent;
1885
1886 /*
1887   NAN TCA Indication
1888   The Discovery Engine can inform the Host when significant events occur.
1889   The data following the TcaId is dependent upon the TcaId type.
1890   In other words, each new event defined will carry a different structure
1891   of information back to the host.
1892 */
1893 typedef struct {
1894     NanTcaType tca_type;
1895     /* flag which defines if the configured Threshold has risen above the threshold */
1896     u8 rising_direction_evt_flag; /* 0 - no event, 1 - event */
1897
1898     /* flag which defines if the configured Threshold has fallen below the threshold */
1899     u8 falling_direction_evt_flag;/* 0 - no event, 1 - event */
1900     union {
1901         /*
1902            This event in obtained when the cluser size threshold
1903            is crossed. Event will have the cluster size
1904         */
1905         NanTcaClusterEvent cluster;
1906     } data;
1907 } NanTCAInd;
1908
1909 /*
1910   NAN Disabled Indication
1911   The NanDisableInd message indicates to the upper layers that the Discovery
1912   Engine has flushed all state and has been shutdown.  When this message is received
1913   the DE is guaranteed to have left the NAN cluster it was part of and will have terminated
1914   any in progress Publishes or Subscribes.
1915 */
1916 typedef struct {
1917     /*
1918       Following reasons expected:
1919       NAN_STATUS_SUCCESS
1920       NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED
1921     */
1922     NanStatusType reason;
1923     char nan_reason[NAN_ERROR_STR_LEN]; /* Describe the NAN reason type */
1924 } NanDisabledInd;
1925
1926 /*
1927   NAN Beacon or SDF Payload Indication
1928   The NanBeaconSdfPayloadInd message indicates to the upper layers that information
1929   elements were received either in a Beacon or SDF which needs to be delivered
1930   outside of a Publish/Subscribe Handle.
1931 */
1932 typedef struct {
1933     /* The MAC address of the peer which sent the attributes.*/
1934     u8 addr[NAN_MAC_ADDR_LEN];
1935     /*
1936        Optional attributes. Each optional attribute is associated with a flag
1937        which specifies whether the attribute is valid or not
1938     */
1939     /* NAN Receive Vendor Specific Attribute*/
1940     u8 is_vsa_received;
1941     NanReceiveVendorSpecificAttribute vsa;
1942
1943     /* NAN Beacon or SDF Payload Received*/
1944     u8 is_beacon_sdf_payload_received;
1945     NanBeaconSdfPayloadReceive data;
1946 } NanBeaconSdfPayloadInd;
1947
1948 /*
1949   Event Indication notifying the
1950   transmit followup in progress
1951 */
1952 typedef struct {
1953    transaction_id id;
1954    /*
1955      Following reason codes returned:
1956      NAN_STATUS_SUCCESS
1957      NAN_STATUS_NO_OTA_ACK
1958      NAN_STATUS_PROTOCOL_FAILURE
1959    */
1960    NanStatusType reason;
1961    char nan_reason[NAN_ERROR_STR_LEN]; /* Describe the NAN reason type */
1962 } NanTransmitFollowupInd;
1963
1964 /*
1965   Data request Initiator/Responder
1966   app/service related info
1967 */
1968 typedef struct {
1969     u16 ndp_app_info_len;
1970     u8 ndp_app_info[NAN_DP_MAX_APP_INFO_LEN];
1971 } NanDataPathAppInfo;
1972
1973 /* QoS configuration */
1974 typedef enum {
1975     NAN_DP_CONFIG_NO_QOS = 0,
1976     NAN_DP_CONFIG_QOS
1977 } NanDataPathQosCfg;
1978
1979 /* Configuration params of Data request Initiator/Responder */
1980 typedef struct {
1981     /* Status Indicating Security/No Security */
1982     NanDataPathSecurityCfgStatus security_cfg;
1983     NanDataPathQosCfg qos_cfg;
1984 } NanDataPathCfg;
1985
1986 /* Nan Data Path Initiator requesting a data session */
1987 typedef struct {
1988     /*
1989      Unique Instance Id identifying the Responder's service.
1990      This is same as publish_id notified on the subscribe side
1991      in a publish/subscribe scenario
1992     */
1993     u32 requestor_instance_id; /* Value 0 for no publish/subscribe */
1994
1995     /* Config flag for channel request */
1996     NanDataPathChannelCfg channel_request_type;
1997     /* Channel frequency in MHz to start data-path */
1998     wifi_channel channel;
1999     /*
2000       Discovery MAC addr of the publisher/peer
2001     */
2002     u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
2003     /*
2004      Interface name on which this NDP session is to be started.
2005      This will be the same interface name provided during interface
2006      create.
2007     */
2008     char ndp_iface[IFNAMSIZ+1];
2009     /* Initiator/Responder Security/QoS configuration */
2010     NanDataPathCfg ndp_cfg;
2011     /* App/Service information of the Initiator */
2012     NanDataPathAppInfo app_info;
2013
2014     /* NAN Cipher Suite Type */
2015     u32 cipher_type;
2016     /* pmk length */
2017     u8 pmk_len;
2018     /* PMK */
2019     u8 pmk[NAN_PMK_INFO_LEN];
2020 } NanDataPathInitiatorRequest;
2021
2022 /*
2023   Data struct to initiate a data response on the responder side
2024   for an indication received with a data request
2025 */
2026 typedef struct {
2027     /*
2028       Unique token Id generated on the initiator/responder
2029       side used for a NDP session between two NAN devices
2030     */
2031     NanDataPathId ndp_instance_id;
2032     /*
2033      Interface name on which this NDP session is to be started.
2034      This will be the same interface name provided during interface
2035      create.
2036     */
2037     char ndp_iface[IFNAMSIZ+1];
2038     /* Initiator/Responder Security/QoS configuration */
2039     NanDataPathCfg ndp_cfg;
2040     /* App/Service information of the responder */
2041     NanDataPathAppInfo app_info;
2042     /* Response Code indicating ACCEPT/REJECT/DEFER */
2043     NanDataPathResponseCode rsp_code;
2044
2045     /* NAN Cipher Suite Type */
2046     u32 cipher_type;
2047     /* pmk length */
2048     u8 pmk_len;
2049     /* PMK */
2050     u8 pmk[NAN_PMK_INFO_LEN];
2051 } NanDataPathIndicationResponse;
2052
2053 /* NDP termination info */
2054 typedef struct {
2055     u8 num_ndp_instances;
2056     /*
2057       Unique token Id generated on the initiator/responder side
2058       used for a NDP session between two NAN devices
2059     */
2060     NanDataPathId ndp_instance_id[];
2061 } NanDataPathEndRequest;
2062
2063 /*
2064   Event indication received on the
2065   responder side when a Nan Data request or
2066   NDP session is initiated on the Initiator side
2067 */
2068 typedef struct {
2069     /*
2070       Unique Instance Id corresponding to a service/session.
2071       This is similar to the publish_id generated on the
2072       publisher side
2073     */
2074     u16 service_instance_id;
2075     /* Discovery MAC addr of the peer/initiator */
2076     u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
2077     /*
2078       Unique token Id generated on the initiator/responder side
2079       used for a NDP session between two NAN devices
2080     */
2081     NanDataPathId ndp_instance_id;
2082     /* Initiator/Responder Security/QoS configuration */
2083     NanDataPathCfg ndp_cfg;
2084     /* App/Service information of the initiator */
2085     NanDataPathAppInfo app_info;
2086 } NanDataPathRequestInd;
2087
2088 /*
2089  Event indication of data confirm is received on both
2090  initiator and responder side confirming a NDP session
2091 */
2092 typedef struct {
2093     /*
2094       Unique token Id generated on the initiator/responder side
2095       used for a NDP session between two NAN devices
2096     */
2097     NanDataPathId ndp_instance_id;
2098     /*
2099       NDI mac address of the peer
2100       (required to derive target ipv6 address)
2101     */
2102     u8 peer_ndi_mac_addr[NAN_MAC_ADDR_LEN];
2103     /* App/Service information of Initiator/Responder */
2104     NanDataPathAppInfo app_info;
2105     /* Response code indicating ACCEPT/REJECT/DEFER */
2106     NanDataPathResponseCode rsp_code;
2107     /*
2108       Reason code indicating the cause for REJECT.
2109       NAN_STATUS_SUCCESS and NAN_STATUS_PROTOCOL_FAILURE are
2110       expected reason codes.
2111     */
2112     NanStatusType reason_code;
2113 } NanDataPathConfirmInd;
2114
2115 /*
2116   Event indication received on the
2117   initiator/responder side terminating
2118   a NDP session
2119 */
2120 typedef struct {
2121     u8 num_ndp_instances;
2122     /*
2123       Unique token Id generated on the initiator/responder side
2124       used for a NDP session between two NAN devices
2125     */
2126     NanDataPathId ndp_instance_id[];
2127 } NanDataPathEndInd;
2128
2129 /*
2130   Event indicating Range Request received on the
2131   Published side.
2132 */
2133 typedef struct {
2134     u16 publish_id;/* id is existing publish */
2135     /* Range Requestor's MAC address */
2136     u8 range_req_intf_addr[NAN_MAC_ADDR_LEN];
2137 } NanRangeRequestInd;
2138
2139 /*
2140   Event indicating Range report on the
2141   Published side.
2142 */
2143 typedef struct {
2144     u16 publish_id;/* id is existing publish */
2145     /* Range Requestor's MAC address */
2146     u8 range_req_intf_addr[NAN_MAC_ADDR_LEN];
2147     /*
2148        Distance to the NAN device with the MAC address indicated
2149        with ranged mac address.
2150     */
2151     u32 range_measurement_cm;
2152 } NanRangeReportInd;
2153
2154 /* Response and Event Callbacks */
2155 typedef struct {
2156     /* NotifyResponse invoked to notify the status of the Request */
2157     void (*NotifyResponse)(transaction_id id, NanResponseMsg* rsp_data);
2158     /* Callbacks for various Events */
2159     void (*EventPublishTerminated)(NanPublishTerminatedInd* event);
2160     void (*EventMatch) (NanMatchInd* event);
2161     void (*EventMatchExpired) (NanMatchExpiredInd* event);
2162     void (*EventSubscribeTerminated) (NanSubscribeTerminatedInd* event);
2163     void (*EventFollowup) (NanFollowupInd* event);
2164     void (*EventDiscEngEvent) (NanDiscEngEventInd* event);
2165     void (*EventDisabled) (NanDisabledInd* event);
2166     void (*EventTca) (NanTCAInd* event);
2167     void (*EventBeaconSdfPayload) (NanBeaconSdfPayloadInd* event);
2168     void (*EventDataRequest)(NanDataPathRequestInd* event);
2169     void (*EventDataConfirm)(NanDataPathConfirmInd* event);
2170     void (*EventDataEnd)(NanDataPathEndInd* event);
2171     void (*EventTransmitFollowup) (NanTransmitFollowupInd* event);
2172     void (*EventRangeRequest) (NanRangeRequestInd* event);
2173     void (*EventRangeReport) (NanRangeReportInd* event);
2174 } NanCallbackHandler;
2175
2176 /**@brief nan_enable_request
2177  *        Enable NAN functionality
2178  *
2179  * @param transaction_id:
2180  * @param wifi_interface_handle:
2181  * @param NanEnableRequest:
2182  * @return Synchronous wifi_error
2183  * @return Asynchronous NotifyResponse CB return
2184  *                      NAN_STATUS_SUCCESS
2185  *                      NAN_STATUS_ALREADY_ENABLED
2186  *                      NAN_STATUS_INVALID_PARAM
2187  *                      NAN_STATUS_INTERNAL_FAILURE
2188  *                      NAN_STATUS_PROTOCOL_FAILURE
2189  *                      NAN_STATUS_NAN_NOT_ALLOWED
2190  */
2191 wifi_error nan_enable_request(transaction_id id,
2192                               wifi_interface_handle iface,
2193                               NanEnableRequest* msg);
2194
2195 /**@brief nan_disbale_request
2196  *        Disable NAN functionality.
2197  *
2198  * @param transaction_id:
2199  * @param wifi_interface_handle:
2200  * @param NanDisableRequest:
2201  * @return Synchronous wifi_error
2202  * @return Asynchronous NotifyResponse CB return
2203  *                      NAN_STATUS_SUCCESS
2204  *                      NAN_STATUS_PROTOCOL_FAILURE
2205  *
2206  */
2207 wifi_error nan_disable_request(transaction_id id,
2208                                wifi_interface_handle iface);
2209
2210 /**@brief nan_publish_request
2211  *        Publish request to advertize a service
2212  *
2213  * @param transaction_id:
2214  * @param wifi_interface_handle:
2215  * @param NanPublishRequest:
2216  * @return Synchronous wifi_error
2217  * @return Asynchronous NotifyResponse CB return
2218  *                      NAN_STATUS_SUCCESS
2219  *                      NAN_STATUS_INVALID_PARAM
2220  *                      NAN_STATUS_PROTOCOL_FAILURE
2221  *                      NAN_STATUS_NO_RESOURCE_AVAILABLE
2222  *                      NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID
2223  */
2224 wifi_error nan_publish_request(transaction_id id,
2225                                wifi_interface_handle iface,
2226                                NanPublishRequest* msg);
2227
2228 /**@brief nan_publish_cancel_request
2229  *        Cancel previous publish request
2230  *
2231  * @param transaction_id:
2232  * @param wifi_interface_handle:
2233  * @param NanPublishCancelRequest:
2234  * @return Synchronous wifi_error
2235  * @return Asynchronous NotifyResponse CB return
2236  *                      NAN_STATUS_SUCCESS
2237  *                      NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID
2238  *                      NAN_STATUS_INTERNAL_FAILURE
2239  */
2240 wifi_error nan_publish_cancel_request(transaction_id id,
2241                                       wifi_interface_handle iface,
2242                                       NanPublishCancelRequest* msg);
2243
2244 /**@brief nan_subscribe_request
2245  *        Subscribe request to search for a service
2246  *
2247  * @param transaction_id:
2248  * @param wifi_interface_handle:
2249  * @param NanSubscribeRequest:
2250  * @return Synchronous wifi_error
2251  * @return Asynchronous NotifyResponse CB return
2252  *                      NAN_STATUS_SUCCESS
2253  *                      NAN_STATUS_INVALID_PARAM
2254  *                      NAN_STATUS_PROTOCOL_FAILURE
2255  *                      NAN_STATUS_INTERNAL_FAILURE
2256  *                      NAN_STATUS_NO_SPACE_AVAILABLE
2257  *                      NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID
2258  */
2259 wifi_error nan_subscribe_request(transaction_id id,
2260                                  wifi_interface_handle iface,
2261                                  NanSubscribeRequest* msg);
2262
2263 /**@brief nan_subscribe_cancel_request
2264  *         Cancel previous subscribe requests.
2265  *
2266  * @param transaction_id:
2267  * @param wifi_interface_handle:
2268  * @param NanSubscribeRequest:
2269  * @return Synchronous wifi_error
2270  * @return Asynchronous NotifyResponse CB return
2271  *                      NAN_STATUS_SUCCESS
2272  *                      NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID
2273  *                      NAN_STATUS_INTERNAL_FAILURE
2274  */
2275 wifi_error nan_subscribe_cancel_request(transaction_id id,
2276                                         wifi_interface_handle iface,
2277                                         NanSubscribeCancelRequest* msg);
2278
2279 /**@brief nan_transmit_followup_request
2280  *         NAN transmit follow up request
2281  *
2282  * @param transaction_id:
2283  * @param wifi_interface_handle:
2284  * @param NanTransmitFollowupRequest:
2285  * @return Synchronous wifi_error
2286  * @return Asynchronous NotifyResponse CB return
2287  *                      NAN_STATUS_SUCCESS
2288  *                      NAN_STATUS_INVALID_PARAM
2289  *                      NAN_STATUS_INTERNAL_FAILURE
2290  *                      NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID
2291  *                      NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID
2292  *                      NAN_STATUS_FOLLOWUP_QUEUE_FULL
2293  * @return Asynchronous TransmitFollowupInd CB return
2294  *                      NAN_STATUS_SUCCESS
2295  *                      NAN_STATUS_PROTOCOL_FAILURE
2296  *                      NAN_STATUS_NO_OTA_ACK
2297  */
2298 wifi_error nan_transmit_followup_request(transaction_id id,
2299                                          wifi_interface_handle iface,
2300                                          NanTransmitFollowupRequest* msg);
2301
2302 /**@brief nan_stats_request
2303  *        Request NAN statistics from Discovery Engine.
2304  *
2305  * @param transaction_id:
2306  * @param wifi_interface_handle:
2307  * @param NanStatsRequest:
2308  * @return Synchronous wifi_error
2309  * @return Asynchronous NotifyResponse CB return
2310  *                      NAN_STATUS_SUCCESS
2311  *                      NAN_STATUS_INTERNAL_FAILURE
2312  *                      NAN_STATUS_INVALID_PARAM
2313  */
2314 wifi_error nan_stats_request(transaction_id id,
2315                              wifi_interface_handle iface,
2316                              NanStatsRequest* msg);
2317
2318 /**@brief nan_config_request
2319  *        NAN configuration request.
2320  *
2321  * @param transaction_id:
2322  * @param wifi_interface_handle:
2323  * @param NanConfigRequest:
2324  * @return Synchronous wifi_error
2325  * @return Asynchronous NotifyResponse CB return
2326  *                      NAN_STATUS_SUCCESS
2327  *                      NAN_STATUS_INVALID_PARAM
2328  *                      NAN_STATUS_PROTOCOL_FAILURE
2329  *                      NAN_STATUS_INTERNAL_FAILURE
2330  */
2331 wifi_error nan_config_request(transaction_id id,
2332                               wifi_interface_handle iface,
2333                               NanConfigRequest* msg);
2334
2335 /**@brief nan_tca_request
2336  *        Configure the various Threshold crossing alerts
2337  *
2338  * @param transaction_id:
2339  * @param wifi_interface_handle:
2340  * @param NanStatsRequest:
2341  * @return Synchronous wifi_error
2342  * @return Asynchronous NotifyResponse CB return
2343  *                      NAN_STATUS_SUCCESS
2344  *                      NAN_STATUS_INVALID_PARAM
2345  *                      NAN_STATUS_INTERNAL_FAILURE
2346  */
2347 wifi_error nan_tca_request(transaction_id id,
2348                            wifi_interface_handle iface,
2349                            NanTCARequest* msg);
2350
2351 /**@brief nan_beacon_sdf_payload_request
2352  *        Set NAN Beacon or sdf payload to discovery engine.
2353  *          This instructs the Discovery Engine to begin publishing the
2354  *        received payload in any Beacon or Service Discovery Frame transmitted
2355  *
2356  * @param transaction_id:
2357  * @param wifi_interface_handle:
2358  * @param NanStatsRequest:
2359  * @return Synchronous wifi_error
2360  * @return Asynchronous NotifyResponse CB return
2361  *                      NAN_STATUS_SUCCESS
2362  *                      NAN_STATUS_INVALID_PARAM
2363  *                      NAN_STATUS_INTERNAL_FAILURE
2364  */
2365 wifi_error nan_beacon_sdf_payload_request(transaction_id id,
2366                                          wifi_interface_handle iface,
2367                                          NanBeaconSdfPayloadRequest* msg);
2368
2369 /* Register NAN callbacks. */
2370 wifi_error nan_register_handler(wifi_interface_handle iface,
2371                                 NanCallbackHandler handlers);
2372
2373 /*  Get NAN HAL version. */
2374 wifi_error nan_get_version(wifi_handle handle,
2375                            NanVersion* version);
2376
2377 /**@brief nan_get_capabilities
2378  *        Get NAN Capabilities
2379  *
2380  * @param transaction_id:
2381  * @param wifi_interface_handle:
2382  * @return Synchronous wifi_error
2383  * @return Asynchronous NotifyResponse CB return
2384  *                      NAN_STATUS_SUCCESS
2385  */
2386 /*  Get NAN capabilities. */
2387 wifi_error nan_get_capabilities(transaction_id id,
2388                                 wifi_interface_handle iface);
2389
2390 /* ========== Nan Data Path APIs ================ */
2391 /**@brief nan_data_interface_create
2392  *        Create NAN Data Interface.
2393  *
2394  * @param transaction_id:
2395  * @param wifi_interface_handle:
2396  * @param iface_name:
2397  * @return Synchronous wifi_error
2398  * @return Asynchronous NotifyResponse CB return
2399  *                      NAN_STATUS_SUCCESS
2400  *                      NAN_STATUS_INVALID_PARAM
2401  *                      NAN_STATUS_INTERNAL_FAILURE
2402  */
2403 wifi_error nan_data_interface_create(transaction_id id,
2404                                      wifi_interface_handle iface,
2405                                      char* iface_name);
2406
2407 /**@brief nan_data_interface_delete
2408  *        Delete NAN Data Interface.
2409  *
2410  * @param transaction_id:
2411  * @param wifi_interface_handle:
2412  * @param iface_name:
2413  * @return Synchronous wifi_error
2414  * @return Asynchronous NotifyResponse CB return
2415  *                      NAN_STATUS_SUCCESS
2416  *                      NAN_STATUS_INVALID_PARAM
2417  *                      NAN_STATUS_INTERNAL_FAILURE
2418  */
2419 wifi_error nan_data_interface_delete(transaction_id id,
2420                                      wifi_interface_handle iface,
2421                                      char* iface_name);
2422
2423 /**@brief nan_data_request_initiator
2424  *        Initiate a NAN Data Path session.
2425  *
2426  * @param transaction_id:
2427  * @param wifi_interface_handle:
2428  * @param NanDataPathInitiatorRequest:
2429  * @return Synchronous wifi_error
2430  * @return Asynchronous NotifyResponse CB return
2431  *                      NAN_STATUS_SUCCESS
2432  *                      NAN_STATUS_INVALID_PARAM
2433  *                      NAN_STATUS_INTERNAL_FAILURE
2434  *                      NAN_STATUS_PROTOCOL_FAILURE
2435  *                      NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID
2436  */
2437 wifi_error nan_data_request_initiator(transaction_id id,
2438                                       wifi_interface_handle iface,
2439                                       NanDataPathInitiatorRequest* msg);
2440
2441 /**@brief nan_data_indication_response
2442  *         Response to a data indication received
2443  *         corresponding to a NDP session. An indication
2444  *         is received with a data request and the responder
2445  *         will send a data response
2446  *
2447  * @param transaction_id:
2448  * @param wifi_interface_handle:
2449  * @param NanDataPathIndicationResponse:
2450  * @return Synchronous wifi_error
2451  * @return Asynchronous NotifyResponse CB return
2452  *                      NAN_STATUS_SUCCESS
2453  *                      NAN_STATUS_INVALID_PARAM
2454  *                      NAN_STATUS_INTERNAL_FAILURE
2455  *                      NAN_STATUS_PROTOCOL_FAILURE
2456  *                      NAN_STATUS_INVALID_NDP_ID
2457  */
2458 wifi_error nan_data_indication_response(transaction_id id,
2459                                         wifi_interface_handle iface,
2460                                         NanDataPathIndicationResponse* msg);
2461
2462 /**@brief nan_data_end
2463  *         NDL termination request: from either Initiator/Responder
2464  *
2465  * @param transaction_id:
2466  * @param wifi_interface_handle:
2467  * @param NanDataPathEndRequest:
2468  * @return Synchronous wifi_error
2469  * @return Asynchronous NotifyResponse CB return
2470  *                      NAN_STATUS_SUCCESS
2471  *                      NAN_STATUS_INVALID_PARAM
2472  *                      NAN_STATUS_INTERNAL_FAILURE
2473  *                      NAN_STATUS_PROTOCOL_FAILURE
2474  *                      NAN_STATUS_INVALID_NDP_ID
2475  */
2476 wifi_error nan_data_end(transaction_id id,
2477                         wifi_interface_handle iface,
2478                         NanDataPathEndRequest* msg);
2479 #ifdef __cplusplus
2480 }
2481 #endif /* __cplusplus */
2482
2483 #endif /* __NAN_H__ */