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