OSDN Git Service

am "small fixes to gscan interface"
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / wifi_hal.h
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 __WIFI_HAL_H__
18 #define __WIFI_HAL_H__
19
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 #include <stdint.h>
25
26 typedef enum {
27     WIFI_SUCCESS = 0,
28     WIFI_ERROR_NONE = 0,
29     WIFI_ERROR_UNKNOWN = -1,
30     WIFI_ERROR_UNINITIALIZED = -2,
31     WIFI_ERROR_NOT_SUPPORTED = -3,
32     WIFI_ERROR_NOT_AVAILABLE = -4,              // Not available right now, but try later
33     WIFI_ERROR_INVALID_ARGS = -5,
34     WIFI_ERROR_INVALID_REQUEST_ID = -6,
35     WIFI_ERROR_TIMED_OUT = -7,
36     WIFI_ERROR_TOO_MANY_REQUESTS = -8,          // Too many instances of this request
37     WIFI_ERROR_OUT_OF_MEMORY = -9
38 } wifi_error;
39
40 typedef unsigned char byte;
41 typedef unsigned char u8;
42 typedef signed char s8;
43 typedef uint16_t u16;
44 typedef uint32_t u32;
45 typedef uint64_t u64;
46 typedef int wifi_request_id;
47 typedef int wifi_channel;                       // indicates channel frequency in MHz
48 typedef int wifi_rssi;
49 typedef byte mac_addr[6];
50 typedef byte oui[3];
51 typedef int64_t wifi_timestamp;                 // In microseconds (us)
52 typedef int64_t wifi_timespan;                  // In nanoseconds  (ns)
53
54 typedef struct wifi_info *wifi_handle;
55 typedef struct wifi_interface_info *wifi_interface_handle;
56
57 /* Initialize/Cleanup */
58
59 wifi_error wifi_initialize(wifi_handle *handle);
60 typedef void (*wifi_cleaned_up_handler) (wifi_handle handle);
61 void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler);
62 void wifi_event_loop(wifi_handle handle);
63
64 /* Error handling */
65 void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string
66
67 /* Feature enums */
68 #define WIFI_FEATURE_INFRA              0x0001      // Basic infrastructure mode
69 #define WIFI_FEATURE_INFRA_5G           0x0002      // Support for 5 GHz Band
70 #define WIFI_FEATURE_HOTSPOT            0x0004      // Support for GAS/ANQP
71 #define WIFI_FEATURE_P2P                0x0008      // Wifi-Direct
72 #define WIFI_FEATURE_SOFT_AP            0x0010      // Soft AP
73 #define WIFI_FEATURE_GSCAN              0x0020      // Google-Scan APIs
74 #define WIFI_FEATURE_NAN                0x0040      // Neighbor Awareness Networking
75 #define WIFI_FEATURE_D2D_RTT            0x0080      // Device-to-device RTT
76 #define WIFI_FEATURE_D2AP_RTT           0x0100      // Device-to-AP RTT
77 #define WIFI_FEATURE_BATCH_SCAN         0x0200      // Batched Scan (legacy)
78 #define WIFI_FEATURE_PNO                0x0400      // Preferred network offload
79 #define WIFI_FEATURE_ADDITIONAL_STA     0x0800      // Support for two STAs
80 #define WIFI_FEATURE_TDLS               0x1000      // Tunnel directed link setup
81 #define WIFI_FEATURE_TDLS_OFFCHANNEL    0x2000      // Support for TDLS off channel
82 #define WIFI_FEATURE_EPR                0x4000      // Enhanced power reporting
83 #define WIFI_FEATURE_AP_STA             0x8000      // Support for AP STA Concurrency
84 #define WIFI_FEATURE_LINK_LAYER_STATS  0x10000      // Link layer stats collection
85 #define WIFI_FEATURE_LOGGER            0x20000      // WiFi Logger
86 #define WIFI_FEATURE_HAL_EPNO          0x40000      // WiFi PNO enhanced
87
88 // Add more features here
89
90 typedef int feature_set;
91
92 #define IS_MASK_SET(mask, flags)        ((flags & mask) == mask)
93 #define IS_MASK_RESET(mask, flags)      ((flags & mask) == 0)
94
95 #define IS_SUPPORTED_FEATURE(feature, featureSet)       IS_MASK_SET(feature, fetureSet)
96 #define IS_UNSUPPORTED_FEATURE(feature, featureSet)     IS_MASK_RESET(feature, fetureSet)
97
98 /* Feature set */
99 wifi_error wifi_get_supported_feature_set(wifi_interface_handle handle, feature_set *set);
100
101 /*
102  * Each row represents a valid feature combination;
103  * all other combinations are invalid!
104  */
105 wifi_error wifi_get_concurrency_matrix(wifi_interface_handle handle, int set_size_max,
106        feature_set set[], int *set_size);
107
108 /* multiple interface support */
109
110 wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces);
111 wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
112
113 /* Configuration events */
114
115 typedef struct {
116     void (*on_country_code_changed)(char code[2]);      // We can get this from supplicant too
117
118     // More event handlers
119 } wifi_event_handler;
120
121 wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
122 wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
123
124 wifi_error wifi_set_nodfs_flag(wifi_interface_handle handle, u32 nodfs);
125
126 /* include various feature headers */
127
128 #include "gscan.h"
129 #include "link_layer_stats.h"
130 #include "rtt.h"
131 #include "tdls.h"
132 #include "wifi_logger.h"
133 #include "wifi_config.h"
134 #include "wifi_nan.h"
135
136 #ifdef __cplusplus
137 }
138 #endif
139