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