1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __NAN_H__ 18 #define __NAN_H__ 19 20 #include "wifi_hal.h" 21 22 #ifdef __cplusplus 23 extern "C" 24 { 25 #endif /* __cplusplus */ 26 27 /***************************************************************************** 28 * Neighbour Aware Network Service Structures and Functions 29 *****************************************************************************/ 30 31 #ifndef PACKED 32 #define PACKED __attribute__((packed)) 33 #endif 34 35 /* 36 Definitions 37 All multi-byte fields within all NAN protocol stack messages are assumed to be in Little Endian order. 38 */ 39 40 typedef int NanVersion; 41 42 #define NAN_MAC_ADDR_LEN 6 43 #define NAN_COUNTRY_STRING_LEN 3 44 #define NAN_MAJOR_VERSION 2 45 #define NAN_MINOR_VERSION 0 46 #define NAN_MICRO_VERSION 0 47 #define NAN_MAX_SOCIAL_CHANNEL 3 48 49 /* NAN Maximum Lengths */ 50 #define NAN_MAX_SERVICE_NAME_LEN 255 51 #define NAN_MAX_MATCH_FILTER_LEN 255 52 #define NAN_MAX_SERVICE_SPECIFIC_INFO_LEN 1024 53 #define NAN_MAX_VSA_DATA_LEN 1024 54 #define NAN_MAX_MESH_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 59 /* 60 Definition of various NanRequestType 61 */ 62 typedef enum { 63 NAN_REQUEST_ENABLE =0, 64 NAN_REQUEST_DISABLE =1, 65 NAN_REQUEST_PUBLISH =2, 66 NAN_REQUEST_PUBLISH_CANCEL =3, 67 NAN_REQUEST_TRANSMIT_FOLLOWUP =4, 68 NAN_REQUEST_SUBSCRIBE =5, 69 NAN_REQUEST_SUBSCRIBE_CANCEL =6, 70 NAN_REQUEST_STATS =7, 71 NAN_REQUEST_CONFIG =8, 72 NAN_REQUEST_TCA =9, 73 NAN_REQUEST_BEACON_SDF_PAYLOAD =10, 74 NAN_REQUEST_LAST =0xFFFF 75 } NanRequestType; 76 77 /* 78 Definition of various NanResponseType 79 */ 80 typedef enum { 81 NAN_RESPONSE_ENABLED =0, 82 NAN_RESPONSE_DISABLED =1, 83 NAN_RESPONSE_PUBLISH =2, 84 NAN_RESPONSE_PUBLISH_CANCEL =3, 85 NAN_RESPONSE_TRANSMIT_FOLLOWUP =4, 86 NAN_RESPONSE_SUBSCRIBE =5, 87 NAN_RESPONSE_SUBSCRIBE_CANCEL =6, 88 NAN_RESPONSE_STATS =7, 89 NAN_RESPONSE_CONFIG =8, 90 NAN_RESPONSE_TCA =9, 91 NAN_RESPONSE_ERROR =10, 92 NAN_RESPONSE_BEACON_SDF_PAYLOAD =11, 93 NAN_RESPONSE_UNKNOWN =0xFFFF 94 } NanResponseType; 95 96 /* 97 Definition of various NanIndication(events) 98 */ 99 typedef enum { 100 NAN_INDICATION_PUBLISH_REPLIED =0, 101 NAN_INDICATION_PUBLISH_TERMINATED =1, 102 NAN_INDICATION_MATCH =2, 103 NAN_INDICATION_UNMATCH =3, 104 NAN_INDICATION_SUBSCRIBE_TERMINATED =4, 105 NAN_INDICATION_DE_EVENT =5, 106 NAN_INDICATION_FOLLOWUP =6, 107 NAN_INDICATION_DISABLED =7, 108 NAN_INDICATION_TCA =8, 109 NAN_INDICATION_BEACON_SDF_PAYLOAD =9, 110 NAN_INDICATION_UNKNOWN =0xFFFF 111 } NanIndicationType; 112 113 114 /* NAN Publish Types */ 115 typedef enum { 116 NAN_PUBLISH_TYPE_UNSOLICITED = 0, 117 NAN_PUBLISH_TYPE_SOLICITED, 118 NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED, 119 NAN_PUBLISH_TYPE_LAST, 120 } NanPublishType; 121 122 /* NAN Transmit Priorities */ 123 typedef enum { 124 NAN_TX_PRIORITY_LOW = 0, 125 NAN_TX_PRIORITY_NORMAL, 126 NAN_TX_PRIORITY_HIGH, 127 NAN_TX_PRIORITY_LAST 128 } NanTxPriority; 129 130 /* NAN Statistics Request ID Codes */ 131 typedef enum 132 { 133 NAN_STATS_ID_FIRST = 0, 134 NAN_STATS_ID_DE_PUBLISH = NAN_STATS_ID_FIRST, 135 NAN_STATS_ID_DE_SUBSCRIBE, 136 NAN_STATS_ID_DE_MAC, 137 NAN_STATS_ID_DE_TIMING_SYNC, 138 NAN_STATS_ID_DE_DW, 139 NAN_STATS_ID_DE, 140 NAN_STATS_ID_LAST 141 } NanStatsId; 142 143 /* NAN Protocol Event ID Codes */ 144 typedef enum 145 { 146 NAN_EVENT_ID_FIRST = 0, 147 NAN_EVENT_ID_STA_MAC_ADDR = NAN_EVENT_ID_FIRST, 148 NAN_EVENT_ID_STARTED_CLUSTER, 149 NAN_EVENT_ID_JOINED_CLUSTER, 150 NAN_EVENT_ID_LAST 151 } NanEventId; 152 153 /* TCA IDs */ 154 typedef enum 155 { 156 NAN_TCA_ID_FIRST = 0, 157 NAN_TCA_ID_CLUSTER_SIZE = NAN_TCA_ID_FIRST, 158 NAN_TCA_ID_LAST 159 } NanTcaId; 160 161 /* 162 Various NAN Protocol Response code 163 */ 164 #ifndef NAN_2_0 165 typedef enum 166 { 167 /* NAN Protocol Response Codes */ 168 NAN_STATUS_SUCCESS = 0, 169 NAN_STATUS_TIMEOUT, 170 NAN_STATUS_DE_FAILURE, 171 NAN_STATUS_INVALID_MSG_VERSION, 172 NAN_STATUS_INVALID_MSG_LEN, 173 NAN_STATUS_INVALID_MSG_ID, 174 NAN_STATUS_INVALID_HANDLE, 175 NAN_STATUS_NO_SPACE_AVAILABLE, 176 NAN_STATUS_INVALID_PUBLISH_TYPE, 177 NAN_STATUS_INVALID_TX_TYPE, 178 NAN_STATUS_INVALID_MATCH_ALGORITHM, 179 NAN_STATUS_DISABLE_IN_PROGRESS, 180 NAN_STATUS_INVALID_TLV_LEN, 181 NAN_STATUS_INVALID_TLV_TYPE, 182 NAN_STATUS_MISSING_TLV_TYPE, 183 NAN_STATUS_INVALID_TOTAL_TLVS_LEN, 184 NAN_STATUS_INVALID_MATCH_HANDLE, 185 NAN_STATUS_INVALID_TLV_VALUE, 186 NAN_STATUS_INVALID_TX_PRIORITY, 187 NAN_STATUS_INVALID_TCA_ID, 188 NAN_STATUS_INVALID_STATS_ID, 189 190 /* NAN Configuration Response codes */ 191 NAN_STATUS_INVALID_RSSI_CLOSE_VALUE = 128, 192 NAN_STATUS_INVALID_RSSI_MEDIUM_VALUE, 193 NAN_STATUS_INVALID_HOP_COUNT_LIMIT, 194 NAN_STATUS_INVALID_CLUSTER_JOIN_COUNT, 195 NAN_STATUS_INVALID_MIN_WAKE_DW_DURATION_VALUE, 196 NAN_STATUS_INVALID_OFDM_DATA_RATE_VALUE, 197 NAN_STATUS_INVALID_RANDOM_FACTOR_UPDATE_TIME_VALUE, 198 NAN_STATUS_INVALID_MASTER_PREFERENCE_VALUE, 199 NAN_STATUS_INVALID_EARLY_DW_WAKE_INTERVAL_VALUE, 200 NAN_STATUS_INVALID_LOW_CLUSTER_ID_VALUE, 201 NAN_STATUS_INVALID_HIGH_CLUSTER_ID_VALUE, 202 NAN_STATUS_INVALID_INITIAL_SCAN_PERIOD, 203 NAN_STATUS_INVALID_ONGOING_SCAN_PERIOD, 204 NAN_STATUS_INVALID_RSSI_PROXIMITY_VALUE, 205 NAN_STATUS_INVALID_BACKGROUND_SCAN_PERIOD, 206 NAN_STATUS_INVALID_SCAN_CHANNEL 207 } NanStatusType; 208 #else /* NAN_2_0 */ 209 typedef enum 210 { 211 /* NAN Protocol Response Codes */ 212 NAN_STATUS_SUCCESS = 0, 213 NAN_STATUS_TIMEOUT = 1, 214 NAN_STATUS_DE_FAILURE = 2, 215 NAN_STATUS_INVALID_MSG_VERSION = 3, 216 NAN_STATUS_INVALID_MSG_LEN = 4, 217 NAN_STATUS_INVALID_MSG_ID = 5, 218 NAN_STATUS_INVALID_HANDLE = 6, 219 NAN_STATUS_NO_SPACE_AVAILABLE = 7, 220 NAN_STATUS_INVALID_PUBLISH_TYPE = 8, 221 NAN_STATUS_INVALID_TX_TYPE = 9, 222 NAN_STATUS_INVALID_MATCH_ALGORITHM = 10, 223 NAN_STATUS_DISABLE_IN_PROGRESS = 11, 224 NAN_STATUS_INVALID_TLV_LEN = 12, 225 NAN_STATUS_INVALID_TLV_TYPE = 13, 226 NAN_STATUS_MISSING_TLV_TYPE = 14, 227 NAN_STATUS_INVALID_TOTAL_TLVS_LEN = 15, 228 NAN_STATUS_INVALID_MATCH_HANDLE= 16, 229 NAN_STATUS_INVALID_TLV_VALUE = 17, 230 NAN_STATUS_INVALID_TX_PRIORITY = 18, 231 NAN_STATUS_INVALID_CONNECTION_MAP = 19, 232 /* 20-4095 Reserved */ 233 234 /* NAN Configuration Response codes */ 235 NAN_STATUS_INVALID_RSSI_CLOSE_VALUE = 4096, 236 NAN_STATUS_INVALID_RSSI_MIDDLE_VALUE = 4097, 237 NAN_STATUS_INVALID_HOP_COUNT_LIMIT = 4098, 238 NAN_STATUS_INVALID_MASTER_PREFERENCE_VALUE = 4099, 239 NAN_STATUS_INVALID_LOW_CLUSTER_ID_VALUE = 4100, 240 NAN_STATUS_INVALID_HIGH_CLUSTER_ID_VALUE = 4101, 241 NAN_STATUS_INVALID_BACKGROUND_SCAN_PERIOD = 4102, 242 NAN_STATUS_INVALID_RSSI_PROXIMITY_VALUE = 4103, 243 NAN_STATUS_INVALID_SCAN_CHANNEL = 4104, 244 NAN_STATUS_INVALID_POST_NAN_CONNECTIVITY_CAPABILITIES_BITMAP = 4105, 245 NAN_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_NUMCHAN_VALUE = 4106, 246 NAN_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_DURATION_VALUE = 4107, 247 NAN_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_CLASS_VALUE = 4108, 248 NAN_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_CHANNEL_VALUE = 4109, 249 NAN_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_AVAILABILITY_INTERVAL_BITMAP_VALUE = 4110, 250 NAN_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_MAP_ID = 4111, 251 NAN_STATUS_INVALID_POST_NAN_DISCOVERY_CONN_TYPE_VALUE = 4112, 252 NAN_STATUS_INVALID_POST_NAN_DISCOVERY_DEVICE_ROLE_VALUE = 4113, 253 NAN_STATUS_INVALID_POST_NAN_DISCOVERY_DURATION_VALUE = 4114, 254 NAN_STATUS_INVALID_POST_NAN_DISCOVERY_BITMAP_VALUE = 4115, 255 NAN_STATUS_MISSING_FUTHER_AVAILABILITY_MAP = 4116, 256 NAN_STATUS_INVALID_BAND_CONFIG_FLAGS = 4117, 257 /* 4118 RESERVED */ 258 } NanStatusType; 259 #endif /* NAN_2_0 */ 260 /* 261 Various NAN Terminated Indication Code 262 */ 263 typedef enum 264 { 265 NAN_TERMINATED_REASON_INVALID = 0, 266 NAN_TERMINATED_REASON_TIMEOUT, 267 NAN_TERMINATED_REASON_USER_REQUEST, 268 NAN_TERMINATED_REASON_FAILURE, 269 NAN_TERMINATED_REASON_COUNT_REACHED, 270 NAN_TERMINATED_REASON_DE_SHUTDOWN, 271 NAN_TERMINATED_REASON_DISABLE_IN_PROGRESS, 272 NAN_TERMINATED_REASON_POST_DISC_ATTR_EXPIRED, 273 NAN_TERMINATED_REASON_POST_DISC_LEN_EXCEEDED, 274 NAN_TERMINATED_REASON_FURTHER_AVAIL_MAP_EMPTY 275 } NanTerminatedStatus; 276 277 /* NAN Transmit Types */ 278 typedef enum 279 { 280 NAN_TX_TYPE_BROADCAST = 0, 281 NAN_TX_TYPE_UNICAST, 282 NAN_TX_TYPE_LAST 283 } NanTxType; 284 285 /* NAN Subscribe Type Bit */ 286 #define NAN_SUBSCRIBE_TYPE_PASSIVE 0 287 #define NAN_SUBSCRIBE_TYPE_ACTIVE 1 288 289 /* NAN Service Response Filter Attribute Bit */ 290 #define NAN_SRF_ATTR_BLOOM_FILTER 0 291 #define NAN_SRF_ATTR_PARTIAL_MAC_ADDR 1 292 293 /* NAN Service Response Filter Include Bit */ 294 #define NAN_SRF_INCLUDE_DO_NOT_RESPOND 0 295 #define NAN_SRF_INCLUDE_RESPOND 1 296 297 /* NAN Match Algorithms */ 298 typedef enum 299 { 300 NAN_MATCH_ALG_FIRST = 0, 301 NAN_MATCH_ALG_MATCH_ONCE = NAN_MATCH_ALG_FIRST, 302 NAN_MATCH_ALG_MATCH_CONTINUOUS, 303 NAN_MATCH_ALG_MATCH_NEVER, 304 NAN_MATCH_ALG_LAST 305 } NanMatchAlg; 306 307 /* NAN Header */ 308 typedef struct { 309 /* 310 16-bit quantity which is allocated by the FW. 311 Pass the Handle as 0xFFFF if the Host would like to set up a new 312 Publish/Subscribe and the FW will pass back a valid handle in response msg. 313 To update an already opened Publish/Subscribe Host can pass a Handle 314 which has already been allocated by the FW. 315 */ 316 u16 handle; 317 318 /* 319 16-bit quantity which is allocated in 2 contexts. For all Request 320 messages the TransactionId is allocated by the Service Layer and 321 passed down to the DE. In all Indication messages the TransactionId 322 field is allocated by the DE. There is no correlation between the 323 TransactionIds allocated by the Service Layer and those allocated by the DE 324 */ 325 u16 transaction_id; 326 } NanHeader; 327 328 /* 329 Host can send Vendor specific attributes which the Discovery Engine can 330 enclose in Beacons and/or Service Discovery frames transmitted. 331 Below structure is used to populate that. 332 */ 333 typedef struct { 334 /* 335 0 = transmit only in the next discovery window 336 1 = transmit in next 16 discovery window 337 */ 338 u8 payload_transmit_flag; 339 /* 340 Below flags will determine in which all frames 341 the vendor specific attributes should be included 342 */ 343 u8 tx_in_discovery_beacon; 344 u8 tx_in_sync_beacon; 345 u8 tx_in_service_discovery; 346 /* Organizationally Unique Identifier */ 347 u32 vendor_oui; 348 /* 349 vendor specific attribute to be transmitted 350 vsa_len : Length of the vsa data. 351 */ 352 u32 vsa_len; 353 u8 vsa[NAN_MAX_VSA_DATA_LEN]; 354 } NanTransmitVendorSpecificAttribute; 355 356 357 /* 358 Discovery Engine will forward any Vendor Specific Attributes 359 which it received as part of this structure. 360 */ 361 /* Mask to determine on which frames attribute was received */ 362 #define RX_DISCOVERY_BEACON_MASK 0x00 363 #define RX_SYNC_BEACON_MASK 0x01 364 #define RX_SERVICE_DISCOVERY_MASK 0x02 365 typedef struct { 366 /* 367 Frames on which this vendor specific attribute 368 was received. Mask defined above 369 */ 370 u8 vsa_received_on; 371 /* Organizationally Unique Identifier */ 372 u32 vendor_oui; 373 /* vendor specific attribute */ 374 u32 attr_len; 375 u8 vsa[NAN_MAX_VSA_DATA_LEN]; 376 } NanReceiveVendorSpecificAttribute; 377 378 /* Discovery engine cluster state*/ 379 typedef enum { 380 NAN_NORMAL_OPERATION = 0, 381 NAN_NON_MASTER_NON_SYNC = 1, 382 NAN_NON_MASTER_SYNC = 2, 383 NAN_MASTER = 3, 384 NAN_ANCHOR_MASTER = 4 385 } NanDebugDEClusterState; 386 387 /* 388 NAN Beacon SDF Payload Received structure 389 Discovery engine sends the details of received Beacon or 390 Service Discovery Frames as part of this structure. 391 */ 392 typedef struct { 393 /* Frame data */ 394 u32 frame_len; 395 u8 frame_data[NAN_MAX_VSA_DATA_LEN]; 396 } NanBeaconSdfPayloadReceive; 397 398 /* 399 Host can set the Periodic scan parameters for each of the 400 3(6, 44, 149) Social channels. Only these channels are allowed 401 any other channels are rejected 402 */ 403 #define MAX_SOCIAL_CHANNELS 3 404 typedef enum 405 { 406 NAN_CHANNEL_6 = 0, 407 NAN_CHANNEL_44 = 1, 408 NAN_CHANNEL_149 = 2 409 } NanChannelIndex; 410 411 /* 412 Structure to set the Social Channel Scan parameters 413 passed as part of NanEnableRequest/NanConfigRequest 414 */ 415 typedef struct { 416 /* 417 Dwell time of each social channel in milliseconds 418 NanChannelIndex corresponds to the respective channel 419 If time set to 0 then the FW default time will be used. 420 */ 421 u8 dwell_time[MAX_SOCIAL_CHANNELS]; 422 423 /* 424 Scan period of each social channel in seconds 425 NanChannelIndex corresponds to the respective channel 426 If time set to 0 then the FW default time will be used. 427 */ 428 u16 scan_period[MAX_SOCIAL_CHANNELS]; 429 } NanSocialChannelScanParams; 430 431 /* 432 Host can send Post Connectivity Capability attributes 433 to be included in Service Discovery frames transmitted 434 as part of this structure. 435 */ 436 typedef struct { 437 /* 438 0 = transmit only in the next discovery window 439 1 = transmit in next 16 discovery window 440 */ 441 u8 payload_transmit_flag; 442 /* 1 - Wifi Direct supported 0 - Not supported */ 443 u8 is_wfd_supported; 444 /* 1 - Wifi Direct Services supported 0 - Not supported */ 445 u8 is_wfds_supported; 446 /* 1 - TDLS supported 0 - Not supported */ 447 u8 is_tdls_supported; 448 /* 1 - IBSS supported 0 - Not supported */ 449 u8 is_ibss_supported; 450 /* 1 - Mesh supported 0 - Not supported */ 451 u8 is_mesh_supported; 452 /* 453 1 - NAN Device currently connect to WLAN Infra AP 454 0 - otherwise 455 */ 456 u8 wlan_infra_field; 457 } NanTransmitPostConnectivityCapability; 458 459 /* 460 Discovery engine providing the post connectivity capability 461 received. 462 */ 463 typedef struct { 464 /* 1 - Wifi Direct supported 0 - Not supported */ 465 u8 is_wfd_supported; 466 /* 1 - Wifi Direct Services supported 0 - Not supported */ 467 u8 is_wfds_supported; 468 /* 1 - TDLS supported 0 - Not supported */ 469 u8 is_tdls_supported; 470 /* 1 - IBSS supported 0 - Not supported */ 471 u8 is_ibss_supported; 472 /* 1 - Mesh supported 0 - Not supported */ 473 u8 is_mesh_supported; 474 /* 475 1 - NAN Device currently connect to WLAN Infra AP 476 0 - otherwise 477 */ 478 u8 wlan_infra_field; 479 } NanReceivePostConnectivityCapability; 480 481 /* 482 Indicates the availability interval duration associated with the 483 Availability Intervals Bitmap field 484 */ 485 typedef enum { 486 NAN_DURATION_16MS = 0, 487 NAN_DURATION_32MS = 1, 488 NAN_DURATION_64MS = 2 489 } NanAvailDuration; 490 491 /* Further availability per channel information */ 492 typedef struct { 493 /* Defined above */ 494 NanAvailDuration entry_control; 495 /* 496 1 byte field indicating the frequency band the NAN Device 497 will be available as defined in IEEE Std. 802.11-2012 498 Annex E Table E-4 Global Operating Classes 499 */ 500 u8 class_val; 501 /* 502 1 byte field indicating the channel the NAN Device 503 will be available. 504 */ 505 u8 channel; 506 /* 507 Map Id - 4 bit field which identifies the Further 508 availability map attribute. 509 */ 510 u8 mapid; 511 /* 512 divides the time between the beginnings of consecutive Discovery 513 Windows of a given NAN cluster into consecutive time intervals 514 of equal durations. The time interval duration is specified by 515 the Availability Interval Duration subfield of the Entry Control 516 field. 517 518 A Nan device that sets the i-th bit of the Availability 519 Intervals Bitmap to 1 shall be present during the corresponding 520 i-th time interval in the operation channel indicated by the 521 Operating Class and Channel Number fields in the same Availability Entry. 522 523 A Nan device that sets the i-th bit of the Availability Intervals Bitmap to 524 0 may be present during the corresponding i-th time interval in the operation 525 channel indicated by the Operating Class and Channel Number fields in the same 526 Availability Entry. 527 528 The size of the Bitmap is dependent upon the Availability Interval Duration 529 chosen in the Entry Control Field. The size can be either 1, 2 or 4 bytes long 530 531 - Duration field is equal to 0, only AIB[0] is valid 532 - Duration field is equal to 1, only AIB [0] and AIB [1] is valid 533 - Duration field is equal to 2, AIB [0], AIB [1], AIB [2] and AIB [3] are valid 534 */ 535 u32 avail_interval_bitmap; 536 } NanFurtherAvailabilityChannel; 537 538 /* 539 Further availability map which can be sent and received from 540 Discovery engine 541 */ 542 typedef struct { 543 /* 544 Number of channels indicates the number of channel 545 entries which is part of fam 546 */ 547 u8 numchans; 548 NanFurtherAvailabilityChannel famchan[NAN_MAX_FAM_CHANNELS]; 549 } NanFurtherAvailabilityMap; 550 551 /* 552 Host can send Post-Nan Discovery attributes which the Discovery Engine can 553 enclose in Service Discovery frames 554 */ 555 /* Possible connection types in Post NAN Discovery attributes */ 556 typedef enum { 557 NAN_CONN_WLAN_INFRA = 0, 558 NAN_CONN_P2P_OPER = 1, 559 NAN_CONN_WLAN_IBSS = 2, 560 NAN_CONN_WLAN_MESH = 3, 561 NAN_CONN_FURTHER_SERVICE_AVAILABILITY = 4, 562 NAN_CONN_WLAN_RANGING = 5 563 } NanConnectionType; 564 565 /* Possible device roles in Post NAN Discovery attributes */ 566 typedef enum { 567 NAN_WLAN_INFRA_AP = 0, 568 NAN_WLAN_INFRA_STA = 1, 569 NAN_P2P_OPER_GO = 2, 570 NAN_P2P_OPER_DEV = 3, 571 NAN_P2P_OPER_CLI = 4 572 } NanDeviceRole; 573 574 /* Structure of Post NAN Discovery attribute */ 575 typedef struct { 576 /* Connection type of the host */ 577 NanConnectionType type; 578 /* 579 Device role of the host based on 580 the connection type 581 */ 582 NanDeviceRole role; 583 /* 584 Flag to send the information as a single shot or repeated 585 for next 16 discovery windows 586 0 - Single_shot 587 1 - next 16 discovery windows 588 */ 589 u8 transmit_freq; 590 /* Duration of the availability bitmask */ 591 NanAvailDuration duration; 592 /* Availability interval bitmap based on duration */ 593 u32 avail_interval_bitmap; 594 /* 595 Mac address depending on the conn type and device role 596 -------------------------------------------------- 597 | Conn Type | Device Role | Mac address Usage | 598 -------------------------------------------------- 599 | WLAN_INFRA | AP/STA | BSSID of the AP | 600 -------------------------------------------------- 601 | P2P_OPER | GO | GO's address | 602 -------------------------------------------------- 603 | P2P_OPER | P2P_DEVICE | Address of who | 604 | | | would become GO | 605 -------------------------------------------------- 606 | WLAN_IBSS | NA | BSSID | 607 -------------------------------------------------- 608 | WLAN_MESH | NA | BSSID | 609 -------------------------------------------------- 610 */ 611 u8 addr[NAN_MAC_ADDR_LEN]; 612 /* 613 Mandatory mesh id value if connection type is WLAN_MESH 614 Mesh id contains 0-32 octet identifier and should be 615 as per IEEE Std.802.11-2012 spec. 616 */ 617 u16 mesh_id_len; 618 u8 mesh_id[NAN_MAX_MESH_DATA_LEN]; 619 /* 620 Optional infrastructure SSID if conn_type is set to 621 NAN_CONN_WLAN_INFRA 622 */ 623 u16 infrastructure_ssid_len; 624 u8 infrastructure_ssid_val[NAN_MAX_MESH_DATA_LEN]; 625 } NanTransmitPostDiscovery; 626 627 /* 628 Discovery engine providing the structure of Post NAN 629 Discovery 630 */ 631 typedef struct { 632 /* Connection type of the host */ 633 NanConnectionType type; 634 /* 635 Device role of the host based on 636 the connection type 637 */ 638 NanDeviceRole role; 639 /* Duration of the availability bitmask */ 640 NanAvailDuration duration; 641 /* Availability interval bitmap based on duration */ 642 u32 avail_interval_bitmap; 643 /* 644 Map Id - 4 bit field which identifies the Further 645 availability map attribute. 646 */ 647 u8 mapid; 648 /* 649 Mac address depending on the conn type and device role 650 -------------------------------------------------- 651 | Conn Type | Device Role | Mac address Usage | 652 -------------------------------------------------- 653 | WLAN_INFRA | AP/STA | BSSID of the AP | 654 -------------------------------------------------- 655 | P2P_OPER | GO | GO's address | 656 -------------------------------------------------- 657 | P2P_OPER | P2P_DEVICE | Address of who | 658 | | | would become GO | 659 -------------------------------------------------- 660 | WLAN_IBSS | NA | BSSID | 661 -------------------------------------------------- 662 | WLAN_MESH | NA | BSSID | 663 -------------------------------------------------- 664 */ 665 u8 addr[NAN_MAC_ADDR_LEN]; 666 /* 667 Mandatory mesh id value if connection type is WLAN_MESH 668 Mesh id contains 0-32 octet identifier and should be 669 as per IEEE Std.802.11-2012 spec. 670 */ 671 u16 mesh_id_len; 672 u8 mesh_id[NAN_MAX_MESH_DATA_LEN]; 673 /* 674 Optional infrastructure SSID if conn_type is set to 675 NAN_CONN_WLAN_INFRA 676 */ 677 u16 infrastructure_ssid_len; 678 u8 infrastructure_ssid_val[NAN_MAX_MESH_DATA_LEN]; 679 } NanReceivePostDiscovery; 680 681 /* 682 Enable Request Message Structure 683 The NanEnableReq message instructs the Discovery Engine to enter an operational state 684 */ 685 typedef struct { 686 NanHeader header; 687 /* Mandatory parameters below */ 688 u8 support_5g; /* default = 0 */ 689 u16 cluster_low; /* default = 0 */ 690 u16 cluster_high; /* default = 0 */ 691 /* 692 BIT 0 is used to specify to include Service IDs in Sync/Discovery beacons 693 0 - Do not include SIDs in any beacons 694 1 - Include SIDs in all beacons. 695 Rest 7 bits are count field which allows control over the number of SIDs 696 included in the Beacon. 0 means to include as many SIDs that fit into 697 the maximum allow Beacon frame size 698 */ 699 u8 sid_beacon; /* default = 0x01*/ 700 u8 rssi_close; /* default = 60 (-60 dBm) */ 701 u8 rssi_middle; /* default = 70 (-70 dBm) */ 702 u8 rssi_proximity; /* default = 70 (-70 dBm) */ 703 u8 hop_count_limit; /* default = 2 */ 704 u8 random_time; /* default = 120 (DWs) */ 705 u8 master_pref; /* default = 0 */ 706 u8 periodic_scan_interval; /* default = 20 seconds */ 707 /* TBD: Google specific IE */ 708 709 /* 710 Optional configuration of Enable request. 711 Each of the optional parameters have configure flag which 712 determine whether configuration is to be passed or not. 713 */ 714 /* 715 Defines 2.4G channel access support 716 0 - No Support 717 1 - Supported 718 If not configured, default value = 1 719 */ 720 u8 config_2dot4g_support; 721 u8 support_2dot4g_val; 722 /* 723 Defines 2.4G channels will be used for sync/discovery beacons 724 0 - 2.4G channels not used for beacons 725 1 - 2.4G channels used for beacons 726 If not configured, default value = 1 727 */ 728 u8 config_2dot4g_beacons; 729 u8 beacon_2dot4g_val; 730 /* 731 Defines 2.4G channels will be used for discovery frames 732 0 - 2.4G channels not used for discovery frames 733 1 - 2.4G channels used for discovery frames 734 If not configured, default value = 1 735 */ 736 u8 config_2dot4g_discovery; 737 u8 discovery_2dot4g_val; 738 /* 739 Defines 5G channels will be used for sync/discovery beacons 740 0 - 5G channels not used for beacons 741 1 - 5G channels used for beacons 742 If not configured, default value = 1 743 */ 744 u8 config_5g_beacons; 745 u8 beacon_5g_val; 746 /* 747 Defines 5G channels will be used for discovery frames 748 0 - 5G channels not used for discovery frames 749 1 - 5G channels used for discovery frames 750 If not configured, default value = 0 751 */ 752 u8 config_5g_discovery; 753 u8 discovery_5g_val; 754 /* 755 1 byte signed quantity which defines the RSSI value in 756 dBm for a close by Peer in 5 Ghz channels. 757 */ 758 u8 config_5g_rssi_close; 759 u8 rssi_close_5g_val; 760 /* 761 1 byte signed quantity which defines the RSSI value in 762 dBm for a close by Peer in 5 Ghz channels. 763 */ 764 u8 config_5g_rssi_middle; 765 u8 rssi_middle_5g_val; 766 /* 767 1 byte signed quantity which defines the RSSI filter 768 threshold. Any Service Descriptors received above this 769 value that are configured for RSSI filtering will be dropped. 770 */ 771 u8 config_5g_rssi_close_proximity; 772 u8 rssi_close_proximity_5g_val; 773 /* 774 2 byte quantity which defines the window size over 775 which the �average RSSI� will be calculated over. 776 */ 777 u8 config_rssi_window_size; 778 u16 rssi_window_size_val; 779 /* 780 The 24 bit Organizationally Unique ID + the 8 bit Network Id. 781 */ 782 u8 config_oui; 783 u32 oui_val; 784 /* 785 NAN Interface Address, If not configured the Discovery Engine 786 will generate a 6 byte Random MAC. 787 */ 788 u8 config_intf_addr; 789 u8 intf_addr_val[NAN_MAC_ADDR_LEN]; 790 /* 791 If set to 1, the Discovery Engine will enclose the Cluster 792 Attribute only sent in Beacons in a Vendor Specific Attribute 793 and transmit in a Service Descriptor Frame. 794 */ 795 u8 config_cluster_attribute_val; 796 /* 797 The periodicity in seconds between full scan�s to find any new 798 clusters available in the area. A Full scan should not be done 799 more than every 10 seconds and should not be done less than every 800 30 seconds. 801 */ 802 u8 config_scan_params; 803 NanSocialChannelScanParams scan_params_val; 804 /* 805 Debugging mode for Discovery engine 806 */ 807 u8 config_debug_flags; 808 u64 debug_flags_val; 809 /* 810 1 byte quantity which forces the Random Factor to a particular 811 value for all transmitted Sync/Discovery beacons 812 */ 813 u8 config_random_factor_force; 814 u8 random_factor_force_val; 815 /* 816 1 byte quantity which forces the HC for all transmitted Sync and 817 Discovery Beacon NO matter the real HC being received over the 818 air. 819 */ 820 u8 config_hop_count_force; 821 u8 hop_count_force_val; 822 } NanEnableRequest; 823 824 /* 825 Disable Request Message Structure 826 The NanDisableReq message instructs the Discovery Engine to exit an operational state. 827 */ 828 typedef struct { 829 NanHeader header; 830 } NanDisableRequest; 831 832 /* 833 Publish Msg Structure 834 Message is used to request the DE to publish the Service Name 835 using the parameters passed into the Discovery Window 836 */ 837 typedef struct { 838 NanHeader header; 839 u16 ttl; /* how many seconds to run for. 0 means forever until canceled */ 840 u16 period; /* periodicity of OTA unsolicited publish. Specified in increments of 500 ms */ 841 u8 replied_event_flag; /* 1= RepliedEventInd needed, 0 = Not needed */ 842 NanPublishType publish_type;/* 0= unsolicited, solicited = 1, 2= both */ 843 NanTxType tx_type; /* 0 = broadcast, 1= unicast if solicited publish */ 844 u8 publish_count; /* number of OTA Publish, 0 means forever until canceled */ 845 u16 service_name_len; /* length of service name */ 846 u8 service_name[NAN_MAX_SERVICE_NAME_LEN];/* UTF-8 encoded string identifying the service */ 847 /* 848 Field which allows the matching behavior to be controlled. 849 0 - Match Once 850 1 - Match continuous 851 2 - Match never 852 3 - Reserved 853 */ 854 NanMatchAlg publish_match; 855 856 /* 857 Sequence of values which should be conveyed to the Discovery Engine of a 858 NAN Device that has invoked a Subscribe method corresponding to this Publish method 859 */ 860 u16 service_specific_info_len; 861 u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN]; 862 863 /* 864 Ordered sequence of <length, value> pairs which specify further response conditions 865 beyond the service name used to filter subscribe messages to respond to. 866 This is only needed when the PT is set to NAN_SOLICITED or NAN_SOLICITED_UNSOLICITED. 867 */ 868 u16 rx_match_filter_len; 869 u8 rx_match_filter[NAN_MAX_MATCH_FILTER_LEN]; 870 871 /* 872 Ordered sequence of <length, value> pairs to be included in the Discovery Frame. 873 If present it is always sent in a Discovery Frame 874 */ 875 u16 tx_match_filter_len; 876 u8 tx_match_filter[NAN_MAX_MATCH_FILTER_LEN]; 877 878 /* 879 flag which specifies that the Publish should use the configured RSSI 880 threshold and the received RSSI in order to filter requests 881 0 � ignore the configured RSSI threshold when running a Service 882 Descriptor attribute or Service ID List Attribute through the DE matching logic. 883 1 � use the configured RSSI threshold when running a Service 884 Descriptor attribute or Service ID List Attribute through the DE matching logic. 885 886 */ 887 u8 rssi_threshold_flag; 888 889 /* 890 flag which control whether or not the Service is sent over the air 891 in order to filter requests 892 0 � Send the Publish Service ID over the air in both Service 893 Discovery Frames, as well as, in the Service ID List Attribute 894 in Sync/Discovery Beacons(assuming we are not NM-NS role). 895 1 � Do not send the Publish Service ID over the air 896 897 */ 898 u8 ota_flag; 899 900 /* 901 8-bit bitmap which allows the Host to associate this publish 902 with a particular Post-NAN Connectivity attribute 903 which has been sent down in a NanConfigureRequest/NanEnableRequest 904 message. If the DE fails to find a configured Post-NAN 905 connectivity attributes referenced by the bitmap, 906 the DE will return an error code to the Host. 907 If the Publish is configured to use a Post-NAN Connectivity 908 attribute and the Host does not refresh the Post-NAN Connectivity 909 attribute the Publish will be canceled and the Host will be sent 910 a PublishTerminatedIndication message. 911 */ 912 u8 connmap; 913 } NanPublishRequest; 914 915 /* 916 Publish Cancel Msg Structure 917 The PublishServiceCancelReq Message is used to request the DE to stop publishing 918 the Service Name identified by the handle in the message. 919 */ 920 typedef struct { 921 NanHeader header; 922 } NanPublishCancelRequest; 923 924 /* 925 NAN Subscribe Structure 926 The SubscribeServiceReq message is sent to the Discovery Engine 927 whenever the Upper layers would like to listen for a Service Name 928 */ 929 typedef struct { 930 NanHeader header; 931 u16 ttl; /* how many seconds to run for. 0 means forever until canceled */ 932 u16 period;/* periodicity of OTA Active Subscribe. Units in increments of 500 ms , 0 = attempt every DW*/ 933 934 /* Flag which specifies how the Subscribe request shall be processed. */ 935 u8 subscribe_type; /* 0 - PASSIVE , 1- ACTIVE */ 936 937 /* Flag which specifies on Active Subscribes how the Service Response Filter attribute is populated.*/ 938 u8 serviceResponseFilter; /* 0 - Bloom Filter, 1 - MAC Addr */ 939 940 /* Flag which specifies how the Service Response Filter Include bit is populated.*/ 941 u8 serviceResponseInclude; /* 0=Do not respond if in the Address Set, 1= Respond */ 942 943 /* Flag which specifies if the Service Response Filter should be used when creating Subscribes.*/ 944 u8 useServiceResponseFilter; /* 0=Do not send the Service Response Filter,1= send */ 945 946 /* 947 Flag which specifies if the Service Specific Info is needed in 948 the Publish message before creating the MatchIndication 949 */ 950 u8 ssiRequiredForMatchIndication; /* 0=Not needed, 1= Required */ 951 952 /* 953 Field which allows the matching behavior to be controlled. 954 0 - Match Once 955 1 - Match continuous 956 2 - Match never 957 3 - Reserved 958 */ 959 NanMatchAlg subscribe_match; 960 961 /* 962 The number of Subscribe Matches which should occur 963 before the Subscribe request is automatically terminated. 964 */ 965 u8 subscribe_count; /* If this value is 0 this field is not used by the DE.*/ 966 967 u16 service_name_len;/* length of service name */ 968 u8 service_name[NAN_MAX_SERVICE_NAME_LEN]; /* UTF-8 encoded string identifying the service */ 969 970 /* Sequence of values which further specify the published service beyond the service name*/ 971 u16 service_specific_info_len; 972 u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN]; 973 974 /* 975 Ordered sequence of <length, value> pairs used to filter out received publish discovery messages. 976 This can be sent both for a Passive or an Active Subscribe 977 */ 978 u16 rx_match_filter_len; 979 u8 rx_match_filter[NAN_MAX_MATCH_FILTER_LEN]; 980 981 /* 982 Ordered sequence of <length, value> pairs included in the 983 Discovery Frame when an Active Subscribe is used. 984 */ 985 u16 tx_match_filter_len; 986 u8 tx_match_filter[NAN_MAX_MATCH_FILTER_LEN]; 987 988 /* 989 Flag which specifies that the Subscribe should use the configured RSSI 990 threshold and the received RSSI in order to filter requests 991 0 � ignore the configured RSSI threshold when running a Service 992 Descriptor attribute or Service ID List Attribute through the DE matching logic. 993 1 � use the configured RSSI threshold when running a Service 994 Descriptor attribute or Service ID List Attribute through the DE matching logic. 995 996 */ 997 u8 rssi_threshold_flag; 998 999 /* 1000 flag which control whether or not the Service is sent over the air 1001 in order to filter requests 1002 0 � Send the Publish Service ID over the air in both Service 1003 Discovery Frames, as well as, in the Service ID List Attribute 1004 in Sync/Discovery Beacons(assuming we are not NM-NS role). 1005 1 � Do not send the Publish Service ID over the air 1006 */ 1007 u8 ota_flag; 1008 1009 /* 1010 8-bit bitmap which allows the Host to associate this Active 1011 Subscribe with a particular Post-NAN Connectivity attribute 1012 which has been sent down in a NanConfigureRequest/NanEnableRequest 1013 message. If the DE fails to find a configured Post-NAN 1014 connectivity attributes referenced by the bitmap, 1015 the DE will return an error code to the Host. 1016 If the Subscribe is configured to use a Post-NAN Connectivity 1017 attribute and the Host does not refresh the Post-NAN Connectivity 1018 attribute the Subscribe will be canceled and the Host will be sent 1019 a SubscribeTerminatedIndication message. 1020 */ 1021 u8 connmap; 1022 /* 1023 NAN Interface Address, conforming to the format as described in 1024 8.2.4.3.2 of IEEE Std. 802.11-2012. 1025 */ 1026 u8 num_intf_addr_present; 1027 u8 intf_addr[NAN_MAX_SUBSCRIBE_MAX_ADDRESS][NAN_MAC_ADDR_LEN]; 1028 } NanSubscribeRequest; 1029 1030 1031 /* 1032 NAN Subscribe Cancel Structure 1033 The SubscribeCancelReq Message is used to request the DE to stop looking for the Service Name. 1034 */ 1035 typedef struct { 1036 NanHeader header; 1037 } NanSubscribeCancelRequest; 1038 1039 1040 /* 1041 Transmit follow up Structure 1042 The TransmitFollowupReq message is sent to the DE to allow the sending of the Service_Specific_Info 1043 to a particular MAC address. 1044 */ 1045 typedef struct { 1046 NanHeader header; 1047 /* 1048 A 32 bit Handle which is sent to the Application. This handle will be 1049 sent in any subsequent UnmatchInd/FollowupInd messages 1050 */ 1051 u32 match_handle; 1052 u8 addr[NAN_MAC_ADDR_LEN]; /* Can be a broadcast/multicast or unicast address */ 1053 NanTxPriority priority; /* priority of the request 0 = low, 1=normal, 2=high */ 1054 u8 dw_or_faw; /* 0= send in a DW, 1=send in FAW */ 1055 1056 /* 1057 Sequence of values which further specify the published service beyond the service name 1058 Treated as service specific info in case dw_or_faw is set to 0 1059 Treated as extended service specific info in case dw_or_faw is set to non-zero 1060 */ 1061 u16 service_specific_info_len; 1062 u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN]; 1063 } NanTransmitFollowupRequest; 1064 1065 /* 1066 Stats Request structure 1067 The Discovery Engine can be queried at runtime by the Host processor for statistics 1068 concerning various parts of the Discovery Engine. 1069 */ 1070 typedef struct { 1071 NanHeader header; 1072 NanStatsId stats_id; /* NAN Statistics Request ID Codes */ 1073 u8 clear; /* 0= Do not clear the stats and return the current contents , 1= Clear the associated stats */ 1074 } NanStatsRequest; 1075 1076 /* 1077 Config Structure 1078 The NanConfigurationReq message is sent by the Host to the 1079 Discovery Engine in order to configure the Discovery Engine during runtime. 1080 */ 1081 typedef struct { 1082 NanHeader header; 1083 u8 config_sid_beacon; 1084 u8 sid_beacon; /* default = 0x01 */ 1085 u8 config_rssi_proximity; 1086 u8 rssi_proximity; /* default = 70 (-70 dBm) */ 1087 u8 config_random_time; 1088 u8 random_time; /* default = 120 (DWs) */ 1089 u8 config_master_pref; 1090 u8 master_pref; /* default = 0 */ 1091 u8 config_periodic_scan_interval; 1092 u8 periodic_scan_interval; /* default = 20 seconds */ 1093 /* 1094 The number of Additional Discovery Window slots in 1095 increments of 16 ms. Since each DW is 512 TUs apart 1096 and the DW takes up 1 slot, the maximum number of additional 1097 slots which can be specified is 31. This is a hint to the 1098 scheduler and there is no guarantee that all 31 slots will 1099 be available because of MCC and BT Coexistence channel usage 1100 */ 1101 u8 additional_disc_window_slots; /* default = 0.*/ 1102 1103 /* 1104 1 byte signed quantity which defines the RSSI filter 1105 threshold. Any Service Descriptors received above this 1106 value that are configured for RSSI filtering will be dropped. 1107 */ 1108 u8 config_5g_rssi_close_proximity; 1109 u8 rssi_close_proximity_5g_val; 1110 /* 1111 Optional configuration of Configure request. 1112 Each of the optional parameters have configure flag which 1113 determine whether configuration is to be passed or not. 1114 */ 1115 /* 1116 2 byte quantity which defines the window size over 1117 which the �average RSSI� will be calculated over. 1118 */ 1119 u8 config_rssi_window_size; 1120 u16 rssi_window_size_val; 1121 /* 1122 If set to 1, the Discovery Engine will enclose the Cluster 1123 Attribute only sent in Beacons in a Vendor Specific Attribute 1124 and transmit in a Service Descriptor Frame. 1125 */ 1126 u8 config_cluster_attribute_val; 1127 /* 1128 The periodicity in seconds between full scan�s to find any new 1129 clusters available in the area. A Full scan should not be done 1130 more than every 10 seconds and should not be done less than every 1131 30 seconds. 1132 */ 1133 u8 config_scan_params; 1134 NanSocialChannelScanParams scan_params_val; 1135 /* 1136 Debugging mode for Discovery engine 1137 */ 1138 u8 config_debug_flags; 1139 u64 debug_flags_val; 1140 /* 1141 1 byte quantity which forces the Random Factor to a particular 1142 value for all transmitted Sync/Discovery beacons 1143 */ 1144 u8 config_random_factor_force; 1145 u8 random_factor_force_val; 1146 /* 1147 1 byte quantity which forces the HC for all transmitted Sync and 1148 Discovery Beacon NO matter the real HC being received over the 1149 air. 1150 */ 1151 u8 config_hop_count_force; 1152 u8 hop_count_force_val; 1153 /* NAN Post Connectivity Capability */ 1154 u8 config_conn_capability; 1155 NanTransmitPostConnectivityCapability conn_capability_val; 1156 /* NAN Post Discover Capability */ 1157 u8 config_discovery_attr; 1158 NanTransmitPostDiscovery discovery_attr_val; 1159 /* NAN Further availability Map */ 1160 u8 config_fam; 1161 NanFurtherAvailabilityMap fam_val; 1162 } NanConfigRequest; 1163 1164 /* 1165 TCA Structure 1166 The Discovery Engine can be configured to send up Events whenever a configured 1167 Threshold Crossing Alert (TCA) Id crosses an integral threshold in a particular direction. 1168 */ 1169 typedef struct { 1170 NanHeader header; 1171 NanTcaId tca_id; /* Nan Protocol Threshold Crossing Alert (TCA) Codes */ 1172 1173 /* flag which control whether or not an event is generated for the Rising direction */ 1174 u8 rising_direction_evt_flag; /* 0 - no event, 1 - event */ 1175 1176 /* flag which control whether or not an event is generated for the Falling direction */ 1177 u8 falling_direction_evt_flag;/* 0 - no event, 1 - event */ 1178 1179 /* flag which requests a previous TCA request to be cleared from the DE */ 1180 u8 clear;/*0= Do not clear the TCA, 1=Clear the TCA */ 1181 1182 /* 32 bit value which represents the threshold to be used.*/ 1183 u32 threshold; 1184 } NanTCARequest; 1185 1186 1187 /* 1188 Beacon Sdf Payload Structure 1189 The Discovery Engine can be configured to publish vendor specific attributes as part of 1190 beacon or service discovery frame transmitted as part of this request.. 1191 */ 1192 typedef struct { 1193 NanHeader header; 1194 /* 1195 NanVendorAttribute will have the Vendor Specific Attribute which the 1196 vendor wants to publish as part of Discovery or Sync or Service discovery frame 1197 */ 1198 NanTransmitVendorSpecificAttribute vsa; 1199 } NanBeaconSdfPayloadRequest; 1200 1201 /* Publish statistics. */ 1202 typedef struct PACKED 1203 { 1204 u32 validPublishServiceReqMsgs; 1205 u32 validPublishServiceRspMsgs; 1206 u32 validPublishServiceCancelReqMsgs; 1207 u32 validPublishServiceCancelRspMsgs; 1208 u32 validPublishRepliedIndMsgs; 1209 u32 validPublishTerminatedIndMsgs; 1210 u32 validActiveSubscribes; 1211 u32 validMatches; 1212 u32 validFollowups; 1213 u32 invalidPublishServiceReqMsgs; 1214 u32 invalidPublishServiceCancelReqMsgs; 1215 u32 invalidActiveSubscribes; 1216 u32 invalidMatches; 1217 u32 invalidFollowups; 1218 u32 publishCount; 1219 } NanPublishStats; 1220 1221 /* Subscribe statistics. */ 1222 typedef struct PACKED 1223 { 1224 u32 validSubscribeServiceReqMsgs; 1225 u32 validSubscribeServiceRspMsgs; 1226 u32 validSubscribeServiceCancelReqMsgs; 1227 u32 validSubscribeServiceCancelRspMsgs; 1228 u32 validSubscribeTerminatedIndMsgs; 1229 u32 validSubscribeMatchIndMsgs; 1230 u32 validSubscribeUnmatchIndMsgs; 1231 u32 validSolicitedPublishes; 1232 u32 validMatches; 1233 u32 validFollowups; 1234 u32 invalidSubscribeServiceReqMsgs; 1235 u32 invalidSubscribeServiceCancelReqMsgs; 1236 u32 invalidSubscribeFollowupReqMsgs; 1237 u32 invalidSolicitedPublishes; 1238 u32 invalidMatches; 1239 u32 invalidFollowups; 1240 u32 subscribeCount; 1241 u32 bloomFilterIndex; 1242 } NanSubscribeStats; 1243 1244 /* NAN MAC Statistics. Used for MAC and DW statistics. */ 1245 typedef struct PACKED 1246 { 1247 /* RX stats */ 1248 u32 validFrames; 1249 u32 validActionFrames; 1250 u32 validBeaconFrames; 1251 u32 ignoredActionFrames; 1252 u32 ignoredBeaconFrames; 1253 u32 invalidFrames; 1254 u32 invalidActionFrames; 1255 u32 invalidBeaconFrames; 1256 u32 invalidMacHeaders; 1257 u32 invalidPafHeaders; 1258 u32 nonNanBeaconFrames; 1259 1260 u32 earlyActionFrames; 1261 u32 inDwActionFrames; 1262 u32 lateActionFrames; 1263 1264 /* TX stats */ 1265 u32 framesQueued; 1266 u32 totalTRSpUpdates; 1267 u32 completeByTRSp; 1268 u32 completeByTp75DW; 1269 u32 completeByTendDW; 1270 u32 lateActionFramesTx; 1271 1272 /* Misc stats - ignored for DW. */ 1273 u32 twIncreases; 1274 u32 twDecreases; 1275 u32 twChanges; 1276 u32 twHighwater; 1277 u32 bloomFilterIndex; 1278 } NanMacStats; 1279 1280 /* NAN Sync Statistics*/ 1281 typedef struct PACKED 1282 { 1283 u64 currTsf; 1284 u64 myRank; 1285 u64 currAmRank; 1286 u64 lastAmRank; 1287 u32 currAmBTT; 1288 u32 lastAmBTT; 1289 u8 currAmHopCount; 1290 u8 currRole; 1291 u16 currClusterId; 1292 u32 reserved1; 1293 1294 u64 timeSpentInCurrRole; 1295 u64 totalTimeSpentAsMaster; 1296 u64 totalTimeSpentAsNonMasterSync; 1297 u64 totalTimeSpentAsNonMasterNonSync; 1298 u32 transitionsToAnchorMaster; 1299 u32 transitionsToMaster; 1300 u32 transitionsToNonMasterSync; 1301 u32 transitionsToNonMasterNonSync; 1302 u32 amrUpdateCount; 1303 u32 amrUpdateRankChangedCount; 1304 u32 amrUpdateBTTChangedCount; 1305 u32 amrUpdateHcChangedCount; 1306 u32 amrUpdateNewDeviceCount; 1307 u32 amrExpireCount; 1308 u32 mergeCount; 1309 u32 beaconsAboveHcLimit; 1310 u32 beaconsBelowRssiThresh; 1311 u32 beaconsIgnoredNoSpace; 1312 u32 beaconsForOurCluster; 1313 u32 beaconsForOtherCluster; 1314 u32 beaconCancelRequests; 1315 u32 beaconCancelFailures; 1316 u32 beaconUpdateRequests; 1317 u32 beaconUpdateFailures; 1318 u32 syncBeaconTxAttempts; 1319 u32 syncBeaconTxFailures; 1320 u32 discBeaconTxAttempts; 1321 u32 discBeaconTxFailures; 1322 u32 amHopCountExpireCount; 1323 } NanSyncStats; 1324 1325 /* NAN Misc DE Statistics */ 1326 typedef struct PACKED 1327 { 1328 u32 validErrorRspMsgs; 1329 u32 validTransmitFollowupReqMsgs; 1330 u32 validTransmitFollowupRspMsgs; 1331 u32 validFollowupIndMsgs; 1332 u32 validConfigurationReqMsgs; 1333 u32 validConfigurationRspMsgs; 1334 u32 validStatsReqMsgs; 1335 u32 validStatsRspMsgs; 1336 u32 validEnableReqMsgs; 1337 u32 validEnableRspMsgs; 1338 u32 validDisableReqMsgs; 1339 u32 validDisableRspMsgs; 1340 u32 validDisableIndMsgs; 1341 u32 validEventIndMsgs; 1342 u32 validTcaReqMsgs; 1343 u32 validTcaRspMsgs; 1344 u32 validTcaIndMsgs; 1345 u32 invalidTransmitFollowupReqMsgs; 1346 u32 invalidConfigurationReqMsgs; 1347 u32 invalidStatsReqMsgs; 1348 u32 invalidEnableReqMsgs; 1349 u32 invalidDisableReqMsgs; 1350 u32 invalidTcaReqMsgs; 1351 } NanDeStats; 1352 1353 /* 1354 Stats Response Message structure 1355 The Discovery Engine response to a request by the Host for statistics. 1356 */ 1357 typedef struct { 1358 NanStatsId stats_id; 1359 union { 1360 NanPublishStats publish_stats; 1361 NanSubscribeStats subscribe_stats; 1362 NanMacStats mac_stats; 1363 NanSyncStats sync_stats; 1364 NanDeStats de_stats; 1365 } data; 1366 } NanStatsResponse; 1367 1368 /* 1369 NAN Response messages 1370 */ 1371 typedef struct { 1372 NanHeader header; 1373 u16 status; /* contains the result code */ 1374 u16 value; /* For error returns the value is returned which was in error */ 1375 NanResponseType response_type; /* NanResponseType Definitions */ 1376 union { 1377 NanStatsResponse stats_response; 1378 } body; 1379 } NanResponseMsg; 1380 1381 1382 /* 1383 Publish Replied Indication 1384 The PublishRepliedInd Message is sent by the DE when an Active Subscribe is 1385 received over the air and it matches a Solicited PublishServiceReq which had 1386 been created with the replied_event_flag set. 1387 */ 1388 typedef struct { 1389 NanHeader header; 1390 u8 addr[NAN_MAC_ADDR_LEN]; 1391 /* 1392 If RSSI filtering was configured in NanPublishRequest then this 1393 field will contain the received RSSI value. 0 if not 1394 */ 1395 u8 rssi_value; 1396 /* 1397 optional attributes. Each optional attribute is associated with a flag 1398 which specifies whether the attribute is valid or not 1399 */ 1400 /* NAN Post Connectivity Capability received */ 1401 u8 is_conn_capability_valid; 1402 NanReceivePostConnectivityCapability conn_capability; 1403 1404 /* NAN Post Discover Capability */ 1405 u8 is_discovery_attr_valid; 1406 NanReceivePostDiscovery discovery_attr; 1407 1408 /* NAN Further availability Map */ 1409 u8 is_fam_valid; 1410 NanFurtherAvailabilityMap fam; 1411 1412 /* NAN Cluster Attribute */ 1413 u8 cluster_attribute_len; 1414 u8 cluster_attribute[NAN_MAX_CLUSTER_ATTRIBUTE_LEN]; 1415 } NanPublishRepliedInd; 1416 1417 /* 1418 Publish Terminated 1419 The PublishTerminatedInd message is sent by the DE whenever a Publish 1420 terminates from a user-specified timeout or a unrecoverable error in the DE. 1421 */ 1422 typedef struct { 1423 NanHeader header; 1424 NanTerminatedStatus reason; 1425 } NanPublishTerminatedInd; 1426 1427 /* 1428 Match Indication 1429 The MatchInd message is sent once per responding MAC address whenever 1430 the Discovery Engine detects a match for a previous SubscribeServiceReq 1431 or PublishServiceReq. 1432 */ 1433 typedef struct { 1434 NanHeader header; 1435 1436 /* 1437 A 32 bit Handle which is sent to the Application. This handle will be 1438 sent in any subsequent UnmatchInd/FollowupInd messages 1439 */ 1440 u32 match_handle; 1441 u8 addr[NAN_MAC_ADDR_LEN]; 1442 1443 /* 1444 Sequence of octets which were received in a Discovery Frame matching the 1445 Subscribe Request. 1446 */ 1447 u16 service_specific_info_len; 1448 u8 service_specific_info[NAN_MAX_SERVICE_NAME_LEN]; 1449 1450 /* 1451 Ordered sequence of <length, value> pairs received in the Discovery Frame 1452 matching the Subscribe Request. 1453 */ 1454 u16 sdf_match_filter_len; 1455 u8 sdf_match_filter[NAN_MAX_MATCH_FILTER_LEN]; 1456 1457 /* 1458 flag to indicate if the Match occurred in a Beacon Frame or in a 1459 Service Discovery Frame. 1460 0 - Match occured in a Service Discovery Frame 1461 1 - Match occured in a Beacon Frame 1462 */ 1463 u8 match_occured_flag; 1464 1465 /* 1466 flag to indicate FW is out of resource and that it can no longer 1467 track this Service Name. The Host still need to send the received 1468 Match_Handle but duplicate MatchInd messages may be received on 1469 this Handle until the resource frees up. 1470 0 - FW is caching this match 1471 1 - FW is unable to cache this match 1472 */ 1473 u8 out_of_resource_flag; 1474 1475 /* 1476 If RSSI filtering was configured in NanSubscribeRequest then this 1477 field will contain the received RSSI value. 0 if not. 1478 */ 1479 u8 rssi_value; 1480 1481 /* 1482 optional attributes. Each optional attribute is associated with a flag 1483 which specifies whether the attribute is valid or not 1484 */ 1485 /* NAN Post Connectivity Capability received */ 1486 u8 is_conn_capability_valid; 1487 NanReceivePostConnectivityCapability conn_capability; 1488 1489 /* NAN Post Discover Capability */ 1490 u8 is_discovery_attr_valid; 1491 NanReceivePostDiscovery discovery_attr; 1492 1493 /* NAN Further availability Map */ 1494 u8 is_fam_valid; 1495 NanFurtherAvailabilityMap fam; 1496 1497 /* NAN Cluster Attribute */ 1498 u8 cluster_attribute_len; 1499 u8 cluster_attribute[NAN_MAX_CLUSTER_ATTRIBUTE_LEN]; 1500 } NanMatchInd; 1501 1502 /* 1503 UnMatch Indication 1504 The UnmatchInd message is sent whenever the Discovery Engine detects that 1505 a previously Matched Service has been gone for too long. If the previous 1506 MatchInd message for this Handle had the out_of_resource_flag set then 1507 this message will not be received 1508 */ 1509 typedef struct { 1510 NanHeader header; 1511 /* 1512 32 bit value sent by the DE in a previous 1513 MatchInd/FollowupInd to the application. 1514 */ 1515 u32 match_handle; 1516 } NanUnmatchInd; 1517 1518 /* 1519 Subscribe Terminated 1520 The SubscribeTerminatedInd message is sent by the DE whenever a 1521 Subscribe terminates from a user-specified timeout or a unrecoverable error in the DE. 1522 */ 1523 typedef struct { 1524 NanHeader header; 1525 NanTerminatedStatus reason; 1526 } NanSubscribeTerminatedInd; 1527 1528 /* 1529 Followup Indication Message 1530 The FollowupInd message is sent by the DE to the Host whenever it receives a 1531 Followup message from another peer. 1532 */ 1533 typedef struct { 1534 NanHeader header; 1535 /* 1536 A 32 bit Handle which is sent to the Application. This handle will be 1537 sent in any subsequent UnmatchInd/FollowupInd messages 1538 */ 1539 u32 match_handle; 1540 u8 addr[NAN_MAC_ADDR_LEN]; 1541 1542 /* Flag which the DE uses to decide if received in a DW or a FAW*/ 1543 u8 dw_or_faw; /* 0=Received in a DW, 1 = Received in a FAW*/ 1544 1545 /* 1546 Sequence of values which further specify the published service beyond the service name 1547 Service specific info in case dw_or_faw is set to 0 1548 Extended service specific info in case dw_or_faw is set to non-zero 1549 */ 1550 u16 service_specific_info_len; 1551 u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN]; 1552 } NanFollowupInd; 1553 1554 /* 1555 Event data notifying the Mac address of the Discovery engine. 1556 which is reported as one of the Discovery engine event 1557 */ 1558 typedef struct { 1559 u8 addr[NAN_MAC_ADDR_LEN]; 1560 } NanMacAddressEvent; 1561 1562 /* 1563 Event data notifying the Cluster address of the cluster 1564 which is reported as one of the Discovery engine event 1565 */ 1566 typedef struct { 1567 u8 addr[NAN_MAC_ADDR_LEN]; 1568 } NanClusterEvent; 1569 1570 /* 1571 Discovery Engine Event Indication 1572 The Discovery Engine can inform the Host when significant events occur 1573 The data following the EventId is dependent upon the EventId type. 1574 In other words, each new event defined will carry a different 1575 structure of information back to the host. 1576 */ 1577 typedef struct { 1578 NanHeader header; 1579 NanEventId event_id; /* NAN Protocol Event Codes */ 1580 union { 1581 /* 1582 MacAddressEvent which will have 6 byte mac address 1583 of the Discovery engine. 1584 */ 1585 NanMacAddressEvent mac_addr; 1586 /* 1587 Cluster Event Data which will be obtained when the 1588 device starts a new cluster or joins a cluster. 1589 The event data will have 6 byte octet string of the 1590 cluster started or joined. 1591 */ 1592 NanClusterEvent cluster; 1593 } data; 1594 } NanDiscEngEventInd; 1595 1596 /* Cluster size TCA event*/ 1597 typedef struct { 1598 /* size of the cluster*/ 1599 u32 cluster_size; 1600 } NanTcaClusterEvent; 1601 1602 /* 1603 NAN TCA Indication 1604 The Discovery Engine can inform the Host when significant events occur. 1605 The data following the TcaId is dependent upon the TcaId type. 1606 In other words, each new event defined will carry a different structure 1607 of information back to the host. 1608 */ 1609 typedef struct { 1610 NanHeader header; 1611 NanTcaId tca_id; 1612 /* flag which defines if the configured Threshold has risen above the threshold */ 1613 u8 rising_direction_evt_flag; /* 0 - no event, 1 - event */ 1614 1615 /* flag which defines if the configured Threshold has fallen below the threshold */ 1616 u8 falling_direction_evt_flag;/* 0 - no event, 1 - event */ 1617 union { 1618 /* 1619 This event in obtained when the cluser size threshold 1620 is crossed. Event will have the cluster size 1621 */ 1622 NanTcaClusterEvent cluster; 1623 } data; 1624 } NanTCAInd; 1625 1626 /* 1627 NAN Disabled Indication 1628 The NanDisableInd message indicates to the upper layers that the Discovery 1629 Engine has flushed all state and has been shutdown. When this message is received 1630 the DE is guaranteed to have left the NAN cluster it was part of and will have terminated 1631 any in progress Publishes or Subscribes. 1632 */ 1633 typedef struct { 1634 NanHeader header; 1635 NanStatusType reason; 1636 } NanDisabledInd; 1637 1638 /* 1639 NAN Beacon SDF Payload Indication 1640 The NanBeaconSdfPayloadInd message indicates to the upper layers that information 1641 elements were received either in a Beacon or SDF which needs to be delivered 1642 outside of a Publish/Subscribe Handle. 1643 */ 1644 typedef struct { 1645 NanHeader header; 1646 /* The MAC address of the peer which sent the attributes.*/ 1647 u8 addr[NAN_MAC_ADDR_LEN]; 1648 /* 1649 Optional attributes. Each optional attribute is associated with a flag 1650 which specifies whether the attribute is valid or not 1651 */ 1652 /* NAN Receive Vendor Specific Attribute*/ 1653 u8 is_vsa_received; 1654 NanReceiveVendorSpecificAttribute vsa; 1655 1656 /* NAN Beacon SDF Payload Received*/ 1657 u8 is_beacon_sdf_payload_received; 1658 NanBeaconSdfPayloadReceive data; 1659 } NanBeaconSdfPayloadInd; 1660 1661 typedef struct { 1662 u64 master_rank; 1663 u8 master_pref; 1664 u8 random_factor; 1665 u8 hop_count; 1666 u32 beacon_transmit_time; 1667 } NanStaParameter; 1668 1669 /* Response and Event Callbacks */ 1670 typedef struct { 1671 /* NotifyResponse invoked to notify the status of the Request */ 1672 void (*NotifyResponse)(NanResponseMsg* rsp_data, 1673 void* userdata); 1674 /* Various Events Callback */ 1675 void (*EventPublishReplied)(NanPublishRepliedInd* event, 1676 void* userdata); 1677 void (*EventPublishTerminated)(NanPublishTerminatedInd* event, 1678 void* userdata); 1679 void (*EventMatch) (NanMatchInd* event, 1680 void* userdata); 1681 void (*EventUnMatch) (NanUnmatchInd* event, 1682 void* userdata); 1683 void (*EventSubscribeTerminated) (NanSubscribeTerminatedInd* event, 1684 void* userdata); 1685 void (*EventFollowup) (NanFollowupInd* event, 1686 void* userdata); 1687 void (*EventDiscEngEvent) (NanDiscEngEventInd* event, 1688 void* userdata); 1689 void (*EventDisabled) (NanDisabledInd* event, 1690 void* userdata); 1691 void (*EventTca) (NanTCAInd* event, 1692 void* userdata); 1693 void (*EventSdfPayload) (NanBeaconSdfPayloadInd* event, 1694 void* userdata); 1695 } NanCallbackHandler; 1696 1697 1698 /* Function to send NAN request to the wifi driver.*/ 1699 wifi_error nan_enable_request(wifi_request_id id, 1700 wifi_handle handle, 1701 NanEnableRequest* msg); 1702 1703 /* Function to send NAN request to the wifi driver.*/ 1704 wifi_error nan_disable_request(wifi_request_id id, 1705 wifi_handle handle, 1706 NanDisableRequest* msg); 1707 1708 /* Function to send NAN request to the wifi driver.*/ 1709 wifi_error nan_publish_request(wifi_request_id id, 1710 wifi_handle handle, 1711 NanPublishRequest* msg); 1712 1713 /* Function to send NAN request to the wifi driver.*/ 1714 wifi_error nan_publish_cancel_request(wifi_request_id id, 1715 wifi_handle handle, 1716 NanPublishCancelRequest* msg); 1717 1718 /* Function to send NAN request to the wifi driver.*/ 1719 wifi_error nan_subscribe_request(wifi_request_id id, 1720 wifi_handle handle, 1721 NanSubscribeRequest* msg); 1722 1723 /* Function to send NAN request to the wifi driver.*/ 1724 wifi_error nan_subscribe_cancel_request(wifi_request_id id, 1725 wifi_handle handle, 1726 NanSubscribeCancelRequest* msg); 1727 1728 /* Function to send NAN request to the wifi driver.*/ 1729 wifi_error nan_transmit_followup_request(wifi_request_id id, 1730 wifi_handle handle, 1731 NanTransmitFollowupRequest* msg); 1732 1733 /* Function to send NAN statistics request to the wifi driver.*/ 1734 wifi_error nan_stats_request(wifi_request_id id, 1735 wifi_handle handle, 1736 NanStatsRequest* msg); 1737 1738 /* Function to send NAN configuration request to the wifi driver.*/ 1739 wifi_error nan_config_request(wifi_request_id id, 1740 wifi_handle handle, 1741 NanConfigRequest* msg); 1742 1743 /* Function to send NAN request to the wifi driver.*/ 1744 wifi_error nan_tca_request(wifi_request_id id, 1745 wifi_handle handle, 1746 NanTCARequest* msg); 1747 1748 /* 1749 Function to send NAN Beacon sdf payload to the wifi driver. 1750 This instructs the Discovery Engine to begin publishing the 1751 received payload in any Beacon or Service Discovery Frame 1752 transmitted 1753 */ 1754 wifi_error nan_beacon_sdf_payload_request(wifi_request_id id, 1755 wifi_handle handle, 1756 NanBeaconSdfPayloadRequest* msg); 1757 /* 1758 Function to get the sta_parameter expected by Sigma 1759 as per CAPI spec. 1760 */ 1761 wifi_error nan_get_sta_parameter(wifi_request_id id, 1762 wifi_handle handle, 1763 NanStaParameter* msg); 1764 1765 /* Function to register NAN callback */ 1766 wifi_error nan_register_handler(wifi_handle handle, 1767 NanCallbackHandler handlers, 1768 void* userdata); 1769 1770 /* Function to get version of the NAN HAL */ 1771 wifi_error nan_get_version(wifi_handle handle, 1772 NanVersion* version); 1773 1774 #ifdef __cplusplus 1775 } 1776 #endif /* __cplusplus */ 1777 1778 #endif /* __NAN_H__ */ 1779