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