4 #ifndef __WIFI_HAL_COMMON_H__
5 #define __WIFI_HAL_COMMON_H__
10 #define LOG_TAG "WifiHAL"
12 #include <utils/Log.h>
13 #include "nl80211_copy.h"
16 #define SOCKET_BUFFER_SIZE (32768U)
17 #define RECV_BUF_SIZE (4096)
18 #define DEFAULT_EVENT_CB_SIZE (64)
19 #define DEFAULT_CMD_SIZE (64)
20 #define DOT11_OUI_LEN 3
24 mac_addr bssids
[MAX_BLACKLIST_BSSID
];
28 Vendor OUI - This is a unique identifier that identifies organization. Lets
29 code Android specific functions with Google OUI; although vendors can do more
30 with their own OUI's as well.
33 const uint32_t GOOGLE_OUI
= 0x001A11;
34 /* TODO: define vendor OUI here */
38 GSCAN_ATTRIBUTE_NUM_BUCKETS
= 10,
39 GSCAN_ATTRIBUTE_BASE_PERIOD
,
40 GSCAN_ATTRIBUTE_BUCKETS_BAND
,
41 GSCAN_ATTRIBUTE_BUCKET_ID
,
42 GSCAN_ATTRIBUTE_BUCKET_PERIOD
,
43 GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS
,
44 GSCAN_ATTRIBUTE_BUCKET_CHANNELS
,
45 GSCAN_ATTRIBUTE_NUM_AP_PER_SCAN
,
46 GSCAN_ATTRIBUTE_REPORT_THRESHOLD
,
47 GSCAN_ATTRIBUTE_NUM_SCANS_TO_CACHE
,
48 GSCAN_ATTRIBUTE_REPORT_THRESHOLD_NUM_SCANS
,
49 GSCAN_ATTRIBUTE_BAND
= GSCAN_ATTRIBUTE_BUCKETS_BAND
,
51 GSCAN_ATTRIBUTE_ENABLE_FEATURE
= 20,
52 GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE
, /* indicates no more results */
53 GSCAN_ATTRIBUTE_REPORT_EVENTS
,
55 /* remaining reserved for additional attributes */
56 GSCAN_ATTRIBUTE_NUM_OF_RESULTS
= 30,
57 GSCAN_ATTRIBUTE_SCAN_RESULTS
, /* flat array of wifi_scan_result */
58 GSCAN_ATTRIBUTE_NUM_CHANNELS
,
59 GSCAN_ATTRIBUTE_CHANNEL_LIST
,
60 GSCAN_ATTRIBUTE_SCAN_ID
,
61 GSCAN_ATTRIBUTE_SCAN_FLAGS
,
62 GSCAN_ATTRIBUTE_SCAN_BUCKET_BIT
,
64 /* remaining reserved for additional attributes */
65 GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE
= 60,
66 GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE
,
67 GSCAN_ATTRIBUTE_MIN_BREACHING
,
68 GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS
,
70 GSCAN_ATTRIBUTE_BUCKET_STEP_COUNT
= 70,
71 GSCAN_ATTRIBUTE_BUCKET_EXPONENT
,
72 GSCAN_ATTRIBUTE_BUCKET_MAX_PERIOD
,
74 GSCAN_ATTRIBUTE_NUM_BSSID
,
75 GSCAN_ATTRIBUTE_BLACKLIST_BSSID
,
82 This enum defines ranges for various commands; commands themselves
83 can be defined in respective feature headers; i.e. find gscan command
84 definitions in gscan.cpp
88 /* don't use 0 as a valid subcommand */
89 VENDOR_NL80211_SUBCMD_UNSPECIFIED
,
91 /* define all vendor startup commands between 0x0 and 0x0FFF */
92 VENDOR_NL80211_SUBCMD_RANGE_START
= 0x0001,
93 VENDOR_NL80211_SUBCMD_RANGE_END
= 0x0FFF,
95 /* define all GScan related commands between 0x1000 and 0x10FF */
96 ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START
= 0x1000,
97 ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END
= 0x10FF,
99 /* define all NearbyDiscovery related commands between 0x1100 and 0x11FF */
100 ANDROID_NL80211_SUBCMD_NBD_RANGE_START
= 0x1100,
101 ANDROID_NL80211_SUBCMD_NBD_RANGE_END
= 0x11FF,
103 /* define all RTT related commands between 0x1100 and 0x11FF */
104 ANDROID_NL80211_SUBCMD_RTT_RANGE_START
= 0x1100,
105 ANDROID_NL80211_SUBCMD_RTT_RANGE_END
= 0x11FF,
107 ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START
= 0x1200,
108 ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END
= 0x12FF,
110 /* define all Logger related commands between 0x1400 and 0x14FF */
111 ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START
= 0x1400,
112 ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END
= 0x14FF,
114 /* define all wifi offload related commands between 0x1400 and 0x14FF */
115 ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START
= 0x1400,
116 ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END
= 0x14FF,
118 /* Range for NAN commands */
119 ANDROID_NL80211_SUBCMD_NAN_RANGE_START
= 0x1500,
120 ANDROID_NL80211_SUBCMD_NAN_RANGE_END
= 0x15FF,
121 /* This is reserved for future usage */
123 } ANDROID_VENDOR_SUB_COMMAND
;
126 SLSI_NL80211_VENDOR_SUBCMD_GET_CAPABILITIES
= ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START
,
127 SLSI_NL80211_VENDOR_SUBCMD_GET_VALID_CHANNELS
,
128 SLSI_NL80211_VENDOR_SUBCMD_ADD_GSCAN
,
129 SLSI_NL80211_VENDOR_SUBCMD_DEL_GSCAN
,
130 SLSI_NL80211_VENDOR_SUBCMD_GET_SCAN_RESULTS
,
131 /**********Deprecated now due to fapi updates.Do not remove*/
132 SLSI_NL80211_VENDOR_SUBCMD_SET_BSSID_HOTLIST
,
133 SLSI_NL80211_VENDOR_SUBCMD_RESET_BSSID_HOTLIST
,
134 SLSI_NL80211_VENDOR_SUBCMD_GET_HOTLIST_RESULTS
,
135 SLSI_NL80211_VENDOR_SUBCMD_SET_SIGNIFICANT_CHANGE
,
136 SLSI_NL80211_VENDOR_SUBCMD_RESET_SIGNIFICANT_CHANGE
,
137 /******************************************/
138 SLSI_NL80211_VENDOR_SUBCMD_SET_GSCAN_OUI
,
139 SLSI_NL80211_VENDOR_SUBCMD_SET_NODFS
,
140 SLSI_NL80211_VENDOR_SUBCMD_START_KEEP_ALIVE_OFFLOAD
,
141 SLSI_NL80211_VENDOR_SUBCMD_STOP_KEEP_ALIVE_OFFLOAD
,
142 SLSI_NL80211_VENDOR_SUBCMD_SET_BSSID_BLACKLIST
,
143 SLSI_NL80211_VENDOR_SUBCMD_SET_EPNO_LIST
,
144 SLSI_NL80211_VENDOR_SUBCMD_SET_HS_LIST
,
145 SLSI_NL80211_VENDOR_SUBCMD_RESET_HS_LIST
,
146 SLSI_NL80211_VENDOR_SUBCMD_SET_RSSI_MONITOR
,
147 SLSI_NL80211_VENDOR_SUBCMD_LLS_SET_INFO
,
148 SLSI_NL80211_VENDOR_SUBCMD_LLS_GET_INFO
,
149 SLSI_NL80211_VENDOR_SUBCMD_LLS_CLEAR_INFO
,
150 SLSI_NL80211_VENDOR_SUBCMD_GET_FEATURE_SET
,
151 SLSI_NL80211_VENDOR_SUBCMD_SET_COUNTRY_CODE
,
152 SLSI_NL80211_VENDOR_SUBCMD_CONFIGURE_ND_OFFLOAD
,
153 SLSI_NL80211_VENDOR_SUBCMD_GET_ROAMING_CAPABILITIES
,
154 SLSI_NL80211_VENDOR_SUBCMD_SET_ROAMING_STATE
,
156 SLSI_NL80211_VENDOR_SUBCMD_NAN_ENABLE
= ANDROID_NL80211_SUBCMD_NAN_RANGE_START
,
157 SLSI_NL80211_VENDOR_SUBCMD_NAN_DISABLE
,
158 SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISH
,
159 SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISHCANCEL
,
160 SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBE
,
161 SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBECANCEL
,
162 SLSI_NL80211_VENDOR_SUBCMD_NAN_TXFOLLOWUP
,
163 SLSI_NL80211_VENDOR_SUBCMD_NAN_CONFIG
,
164 SLSI_NL80211_VENDOR_SUBCMD_NAN_CAPABILITIES
,
165 SLSI_NL80211_VENDOR_SUBCMD_RTT_GET_CAPABILITIES
= ANDROID_NL80211_SUBCMD_RTT_RANGE_START
,
166 SLSI_NL80211_VENDOR_SUBCMD_RTT_RANGE_START
,
167 SLSI_NL80211_VENDOR_SUBCMD_RTT_RANGE_CANCEL
171 /**********Deprecated now due to fapi updates.Do not remove*/
172 GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS
,
173 GSCAN_EVENT_HOTLIST_RESULTS_FOUND
,
174 /******************************************/
175 GSCAN_EVENT_SCAN_RESULTS_AVAILABLE
,
176 GSCAN_EVENT_FULL_SCAN_RESULTS
,
177 GSCAN_EVENT_COMPLETE_SCAN
,
178 /**********Deprecated now due to fapi updates.Do not remove*/
179 GSCAN_EVENT_HOTLIST_RESULTS_LOST
,
180 /******************************************/
181 WIFI_SUBCMD_KEY_MGMT_ROAM_AUTH
, /* Handled by supplicant. not in Wifi-HAL */
185 WIFI_RSSI_REPORT_EVENT
,
186 ENHANCE_LOGGER_RING_EVENT
,
187 ENHANCE_LOGGER_MEM_DUMP_EVENT
,
188 /* NAN events start */
189 SLSI_NAN_EVENT_RESPONSE
,
190 SLSI_NAN_EVENT_PUBLISH_TERMINATED
,
191 SLSI_NAN_EVENT_MATCH
,
192 SLSI_NAN_EVENT_MATCH_EXPIRED
,
193 SLSI_NAN_EVENT_SUBSCRIBE_TERMINATED
,
194 SLSI_NAN_EVENT_FOLLOWUP
,
195 SLSI_NAN_EVENT_DISCOVERY_ENGINE
,
196 SLSI_NAN_EVENT_DISABLED
,
198 SLSI_RTT_RESULT_EVENT
,
199 SLSI_RTT_EVENT_COMPLETE
,
200 WIFI_ACS_EVENT
/* Handled by supplicant. not in Wifi-HAL */
204 typedef void (*wifi_internal_event_handler
) (wifi_handle handle
, int events
);
212 nl_recvmsg_msg_cb_t cb_func
;
222 wifi_handle handle
; // handle to wifi data
223 char name
[8+1]; // interface name + trailing null
224 int id
; // id to use when talking to driver
229 struct nl_sock
*cmd_sock
; // command socket object
230 struct nl_sock
*event_sock
; // event socket object
231 int nl80211_family_id
; // family id for 80211 driver
232 int cleanup_socks
[2]; // sockets used to implement wifi_cleanup
234 bool in_event_loop
; // Indicates that event loop is active
235 bool clean_up
; // Indication to clean up the socket
237 wifi_internal_event_handler event_handler
; // default event handler
238 wifi_cleaned_up_handler cleaned_up_handler
; // socket cleaned up handler
240 cb_info
*event_cb
; // event callbacks
241 int num_event_cb
; // number of event callbacks
242 int alloc_event_cb
; // number of allocated callback objects
243 pthread_mutex_t cb_lock
; // mutex for the event_cb access
245 cmd_info
*cmd
; // Outstanding commands
246 int num_cmd
; // number of commands
247 int alloc_cmd
; // number of commands allocated
249 interface_info
**interfaces
; // array of interfaces
250 int num_interfaces
; // number of interfaces
256 wifi_error
wifi_register_handler(wifi_handle handle
, int cmd
, nl_recvmsg_msg_cb_t func
, void *arg
);
257 wifi_error
wifi_register_vendor_handler(wifi_handle handle
,
258 uint32_t id
, int subcmd
, nl_recvmsg_msg_cb_t func
, void *arg
);
260 void wifi_unregister_handler(wifi_handle handle
, int cmd
);
261 void wifi_unregister_vendor_handler(wifi_handle handle
, uint32_t id
, int subcmd
);
263 wifi_error
wifi_register_cmd(wifi_handle handle
, int id
, WifiCommand
*cmd
);
264 WifiCommand
*wifi_unregister_cmd(wifi_handle handle
, int id
);
265 WifiCommand
*wifi_get_cmd(wifi_handle handle
, int id
);
266 void wifi_unregister_cmd(wifi_handle handle
, WifiCommand
*cmd
);
267 wifi_error
wifi_cancel_cmd(wifi_request_id id
, wifi_interface_handle iface
);
269 interface_info
*getIfaceInfo(wifi_interface_handle
);
270 wifi_handle
getWifiHandle(wifi_interface_handle handle
);
271 hal_info
*getHalInfo(wifi_handle handle
);
272 hal_info
*getHalInfo(wifi_interface_handle handle
);
273 wifi_handle
getWifiHandle(hal_info
*info
);
274 wifi_interface_handle
getIfaceHandle(interface_info
*info
);
277 // some common macros
279 #define min(x, y) ((x) < (y) ? (x) : (y))
280 #define max(x, y) ((x) > (y) ? (x) : (y))
282 #define NULL_CHECK_RETURN(ptr, str, ret) \
285 ALOGE("%s(): null pointer - #ptr (%s)\n", __FUNCTION__, str); \