OSDN Git Service

Include hal link_layer_stats.h
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / wifi_hal.h
1
2 #ifndef __WIFI_HAL_H__
3 #define __WIFI_HAL_H__
4
5 typedef enum {
6     WIFI_SUCCESS = 0,
7     WIFI_ERROR_NONE = 0,
8     WIFI_ERROR_UNKNOWN = -1,
9     WIFI_ERROR_UNINITIALIZED = -2,
10     WIFI_ERROR_NOT_SUPPORTED = -3,
11     WIFI_ERROR_NOT_AVAILABLE = -4,              // Not available right now, but try later
12     WIFI_ERROR_INVALID_ARGS = -5,
13     WIFI_ERROR_INVALID_REQUEST_ID = -6,
14     WIFI_ERROR_TIMED_OUT = -7,
15     WIFI_ERROR_TOO_MANY_REQUESTS = -8,          // Too many instances of this request
16     WIFI_ERROR_OUT_OF_MEMORY = -9
17 } wifi_error;
18
19 typedef unsigned char byte;
20 typedef unsigned char u8;
21 typedef uint16_t u16;
22 typedef uint32_t u32;
23 typedef uint64_t u64;
24 typedef int wifi_request_id;
25 typedef int wifi_channel;                       // indicates channel frequency in MHz
26 typedef int wifi_rssi;
27 typedef byte mac_addr[6];
28 typedef int64_t wifi_timestamp;                 // In microseconds (us)
29 typedef int64_t wifi_timespan;                  // In nanoseconds  (ns)
30
31 struct wifi_info;
32 typedef wifi_info *wifi_handle;
33 struct wifi_interface_info;
34 typedef wifi_interface_info *wifi_interface_handle;
35
36 /* Initialize/Cleanup */
37
38 wifi_error wifi_initialize(wifi_handle *handle);
39 typedef void (*wifi_cleaned_up_handler) (wifi_handle handle);
40 void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler);
41 void wifi_event_loop(wifi_handle handle);
42
43 /* Error handling */
44 void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string
45
46 /* Feature enums */
47 #define WIFI_FEATURE_INFRA          0x0001      // Basic infrastructure mode
48 #define WIFI_FEATURE_INFRA_5G       0x0002      // Support for 5 GHz Band
49 #define WIFI_FEATURE_HOTSPOT        0x0004      // Support for GAS/ANQP
50 #define WIFI_FEATURE_P2P            0x0008      // Wifi-Direct
51 #define WIFI_FEATURE_SOFT_AP        0x0010      // Soft AP
52 #define WIFI_FEATURE_GSCAN          0x0020      // Google-Scan APIs
53 #define WIFI_FEATURE_NBD            0x0040      // NearBy discovery
54 #define WIFI_FEATURE_D2D_RTT        0x0080      // Device-to-device RTT
55 #define WIFI_FEATURE_D2AP_RTT       0x0100      // Device-to-AP RTT
56 #define WIFI_FEATURE_BATCH_GSCAN    0x0200      // Batched G-Scan
57 #define WIFI_FEATURE_PNO            0x0400      // Preferred network offload
58 #define WIFI_FEATURE_ADDITIONAL_STA 0x0800      // Support for two STAs
59 #define WIFI_FEATURE_TDLS           0x1000      // Tunnel directed link setup
60
61 // Add more features here
62
63 typedef int feature_set;
64
65 #define IS_MASK_SET(mask, flags)        ((flags & mask) == mask)
66 #define IS_MASK_RESET(mask, flags)      ((flags & mask) == 0)
67
68 #define IS_SUPPORTED_FEATURE(feature, featureSet)       IS_MASK_SET(feature, fetureSet)
69 #define IS_UNSUPPORTED_FEATURE(feature, featureSet)     IS_MASK_RESET(feature, fetureSet)
70
71 /* Feature set */
72 wifi_error wifi_get_supported_feature_set(wifi_handle handle, feature_set *set);
73
74 /*
75  * Each row represents a valid feature combination;
76  * all other combinations are invalid!
77  */
78 wifi_error wifi_get_concurrency_matrix(wifi_handle handle, int *size, feature_set **matrix);
79
80 /* List of all supported channels, including 5GHz channels */
81 wifi_error wifi_get_supported_channels(wifi_handle handle, int *size, wifi_channel *list);
82
83 /* Enhanced power reporting */
84 wifi_error wifi_is_epr_supported(wifi_handle handle);
85
86 /* multiple interface support */
87
88 wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces);
89 wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
90
91 /* Configuration events */
92
93 typedef struct {
94     void (*on_country_code_changed)(char code[2]);      // We can get this from supplicant too
95
96     // More event handlers
97 } wifi_event_handler;
98
99 wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
100 wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
101
102 /* include various feature headers */
103
104 #include "gscan.h"
105 #include "rtt.h"
106 #include "link_layer_stats.h"
107
108 #endif
109