OSDN Git Service

am e5a16307: am c32be36f: Merge "wifi: check if supplicant is running before starting it"
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / driver_nl80211.h
1 /*
2  * Driver interaction with Linux nl80211/cfg80211
3  * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2003-2004, Instant802 Networks, Inc.
5  * Copyright (c) 2005-2006, Devicescape Software, Inc.
6  * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net>
7  * Copyright (c) 2009-2010, Atheros Communications
8  *
9  * This software may be distributed under the terms of the BSD license.
10  * See README for more details.
11  */
12
13 #ifndef _DRIVER_NL80211_H_
14 #define _DRIVER_NL80211_H_
15
16 #include "includes.h"
17 #include <sys/ioctl.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <fcntl.h>
21 #include <net/if.h>
22 #include <netlink/genl/genl.h>
23 #include <netlink/genl/family.h>
24 #include <netlink/genl/ctrl.h>
25 #include <linux/rtnetlink.h>
26 #include <netpacket/packet.h>
27 #include <linux/filter.h>
28 #include <linux/errqueue.h>
29 #include "nl80211_copy.h"
30
31 #include "common.h"
32 #include "eloop.h"
33 #include "utils/list.h"
34 #include "common/qca-vendor.h"
35 #include "common/ieee802_11_defs.h"
36 #include "common/ieee802_11_common.h"
37 #include "l2_packet/l2_packet.h"
38 #include "netlink.h"
39 #include "linux_ioctl.h"
40 #include "radiotap.h"
41 #include "radiotap_iter.h"
42 #include "rfkill.h"
43 #include "driver.h"
44
45 #ifdef CONFIG_LIBNL20
46 /* libnl 2.0 compatibility code */
47 #define nl_handle nl_sock
48 #define nl80211_handle_alloc nl_socket_alloc_cb
49 #define nl80211_handle_destroy nl_socket_free
50 #endif /* CONFIG_LIBNL20 */
51
52 #ifndef IFF_LOWER_UP
53 #define IFF_LOWER_UP   0x10000         /* driver signals L1 up         */
54 #endif
55 #ifndef IFF_DORMANT
56 #define IFF_DORMANT    0x20000         /* driver signals dormant       */
57 #endif
58
59 #ifndef IF_OPER_DORMANT
60 #define IF_OPER_DORMANT 5
61 #endif
62 #ifndef IF_OPER_UP
63 #define IF_OPER_UP 6
64 #endif
65
66 struct nl80211_global {
67         struct dl_list interfaces;
68         int if_add_ifindex;
69         u64 if_add_wdevid;
70         int if_add_wdevid_set;
71         struct netlink_data *netlink;
72         struct nl_cb *nl_cb;
73         struct nl_handle *nl;
74         int nl80211_id;
75         int ioctl_sock; /* socket for ioctl() use */
76
77         struct nl_handle *nl_event;
78 };
79
80 struct nl80211_wiphy_data {
81         struct dl_list list;
82         struct dl_list bsss;
83         struct dl_list drvs;
84
85         struct nl_handle *nl_beacons;
86         struct nl_cb *nl_cb;
87
88         int wiphy_idx;
89 };
90
91 struct i802_bss {
92         struct wpa_driver_nl80211_data *drv;
93         struct i802_bss *next;
94         int ifindex;
95         u64 wdev_id;
96         char ifname[IFNAMSIZ + 1];
97         char brname[IFNAMSIZ];
98         unsigned int beacon_set:1;
99         unsigned int added_if_into_bridge:1;
100         unsigned int added_bridge:1;
101         unsigned int in_deinit:1;
102         unsigned int wdev_id_set:1;
103         unsigned int added_if:1;
104
105         u8 addr[ETH_ALEN];
106
107         int freq;
108         int if_dynamic;
109
110         void *ctx;
111         struct nl_handle *nl_preq, *nl_mgmt;
112         struct nl_cb *nl_cb;
113
114         struct nl80211_wiphy_data *wiphy_data;
115         struct dl_list wiphy_list;
116 };
117
118 struct wpa_driver_nl80211_data {
119         struct nl80211_global *global;
120         struct dl_list list;
121         struct dl_list wiphy_list;
122         char phyname[32];
123         void *ctx;
124         int ifindex;
125         int if_removed;
126         int if_disabled;
127         int ignore_if_down_event;
128         struct rfkill_data *rfkill;
129         struct wpa_driver_capa capa;
130         u8 *extended_capa, *extended_capa_mask;
131         unsigned int extended_capa_len;
132         int has_capability;
133
134         int operstate;
135
136         int scan_complete_events;
137         enum scan_states {
138                 NO_SCAN, SCAN_REQUESTED, SCAN_STARTED, SCAN_COMPLETED,
139                 SCAN_ABORTED, SCHED_SCAN_STARTED, SCHED_SCAN_STOPPED,
140                 SCHED_SCAN_RESULTS
141         } scan_state;
142
143         struct nl_cb *nl_cb;
144
145         u8 auth_bssid[ETH_ALEN];
146         u8 auth_attempt_bssid[ETH_ALEN];
147         u8 bssid[ETH_ALEN];
148         u8 prev_bssid[ETH_ALEN];
149         int associated;
150         u8 ssid[32];
151         size_t ssid_len;
152         enum nl80211_iftype nlmode;
153         enum nl80211_iftype ap_scan_as_station;
154         unsigned int assoc_freq;
155
156         int monitor_sock;
157         int monitor_ifidx;
158         int monitor_refcount;
159
160         unsigned int disabled_11b_rates:1;
161         unsigned int pending_remain_on_chan:1;
162         unsigned int in_interface_list:1;
163         unsigned int device_ap_sme:1;
164         unsigned int poll_command_supported:1;
165         unsigned int data_tx_status:1;
166         unsigned int scan_for_auth:1;
167         unsigned int retry_auth:1;
168         unsigned int use_monitor:1;
169         unsigned int ignore_next_local_disconnect:1;
170         unsigned int allow_p2p_device:1;
171         unsigned int hostapd:1;
172         unsigned int start_mode_ap:1;
173         unsigned int start_iface_up:1;
174
175         u64 remain_on_chan_cookie;
176         u64 send_action_cookie;
177
178         unsigned int last_mgmt_freq;
179
180         struct wpa_driver_scan_filter *filter_ssids;
181         size_t num_filter_ssids;
182
183         struct i802_bss *first_bss;
184
185         int eapol_tx_sock;
186
187         int eapol_sock; /* socket for EAPOL frames */
188
189         int default_if_indices[16];
190         int *if_indices;
191         int num_if_indices;
192
193         /* From failed authentication command */
194         int auth_freq;
195         u8 auth_bssid_[ETH_ALEN];
196         u8 auth_ssid[32];
197         size_t auth_ssid_len;
198         int auth_alg;
199         u8 *auth_ie;
200         size_t auth_ie_len;
201         u8 auth_wep_key[4][16];
202         size_t auth_wep_key_len[4];
203         int auth_wep_tx_keyidx;
204         int auth_local_state_change;
205         int auth_p2p;
206 };
207
208 #endif