2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __WIFI_HAL_H__
18 #define __WIFI_HAL_H__
23 WIFI_ERROR_UNKNOWN = -1,
24 WIFI_ERROR_UNINITIALIZED = -2,
25 WIFI_ERROR_NOT_SUPPORTED = -3,
26 WIFI_ERROR_NOT_AVAILABLE = -4, // Not available right now, but try later
27 WIFI_ERROR_INVALID_ARGS = -5,
28 WIFI_ERROR_INVALID_REQUEST_ID = -6,
29 WIFI_ERROR_TIMED_OUT = -7,
30 WIFI_ERROR_TOO_MANY_REQUESTS = -8, // Too many instances of this request
31 WIFI_ERROR_OUT_OF_MEMORY = -9
34 typedef unsigned char byte;
35 typedef unsigned char u8;
36 typedef signed char s8;
40 typedef int wifi_request_id;
41 typedef int wifi_channel; // indicates channel frequency in MHz
42 typedef int wifi_rssi;
43 typedef byte mac_addr[6];
44 typedef int64_t wifi_timestamp; // In microseconds (us)
45 typedef int64_t wifi_timespan; // In nanoseconds (ns)
48 typedef wifi_info *wifi_handle;
49 struct wifi_interface_info;
50 typedef wifi_interface_info *wifi_interface_handle;
52 /* Initialize/Cleanup */
54 wifi_error wifi_initialize(wifi_handle *handle);
55 typedef void (*wifi_cleaned_up_handler) (wifi_handle handle);
56 void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler);
57 void wifi_event_loop(wifi_handle handle);
60 void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string
63 #define WIFI_FEATURE_INFRA 0x0001 // Basic infrastructure mode
64 #define WIFI_FEATURE_INFRA_5G 0x0002 // Support for 5 GHz Band
65 #define WIFI_FEATURE_HOTSPOT 0x0004 // Support for GAS/ANQP
66 #define WIFI_FEATURE_P2P 0x0008 // Wifi-Direct
67 #define WIFI_FEATURE_SOFT_AP 0x0010 // Soft AP
68 #define WIFI_FEATURE_GSCAN 0x0020 // Google-Scan APIs
69 #define WIFI_FEATURE_NAN 0x0040 // Neighbor Awareness Networking
70 #define WIFI_FEATURE_D2D_RTT 0x0080 // Device-to-device RTT
71 #define WIFI_FEATURE_D2AP_RTT 0x0100 // Device-to-AP RTT
72 #define WIFI_FEATURE_BATCH_SCAN 0x0200 // Batched Scan (legacy)
73 #define WIFI_FEATURE_PNO 0x0400 // Preferred network offload
74 #define WIFI_FEATURE_ADDITIONAL_STA 0x0800 // Support for two STAs
75 #define WIFI_FEATURE_TDLS 0x1000 // Tunnel directed link setup
76 #define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 // Support for TDLS off channel
77 #define WIFI_FEATURE_EPR 0x4000 // Enhanced power reporting
78 #define WIFI_FEATURE_AP_STA 0x8000 // Support for AP STA Concurrency
79 // Add more features here
81 typedef int feature_set;
83 #define IS_MASK_SET(mask, flags) ((flags & mask) == mask)
84 #define IS_MASK_RESET(mask, flags) ((flags & mask) == 0)
86 #define IS_SUPPORTED_FEATURE(feature, featureSet) IS_MASK_SET(feature, fetureSet)
87 #define IS_UNSUPPORTED_FEATURE(feature, featureSet) IS_MASK_RESET(feature, fetureSet)
90 wifi_error wifi_get_supported_feature_set(wifi_handle handle, feature_set *set);
93 * Each row represents a valid feature combination;
94 * all other combinations are invalid!
96 wifi_error wifi_get_concurrency_matrix(wifi_handle handle, int *size, feature_set **matrix);
98 /* multiple interface support */
100 wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces);
101 wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
103 /* Configuration events */
106 void (*on_country_code_changed)(char code[2]); // We can get this from supplicant too
108 // More event handlers
109 } wifi_event_handler;
111 wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
112 wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
114 /* include various feature headers */
117 #include "link_layer_stats.h"