• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Driver interaction with Linux nl80211/cfg80211
3  * Copyright (c) 2002-2014, 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/qca-vendor-attr.h"
36 #include "common/ieee802_11_defs.h"
37 #include "common/ieee802_11_common.h"
38 #include "l2_packet/l2_packet.h"
39 #include "netlink.h"
40 #include "linux_ioctl.h"
41 #include "radiotap.h"
42 #include "radiotap_iter.h"
43 #include "rfkill.h"
44 #include "driver.h"
45 
46 #ifdef CONFIG_LIBNL20
47 /* libnl 2.0 compatibility code */
48 #define nl_handle nl_sock
49 #define nl80211_handle_alloc nl_socket_alloc_cb
50 #define nl80211_handle_destroy nl_socket_free
51 #endif /* CONFIG_LIBNL20 */
52 
53 #ifndef IFF_LOWER_UP
54 #define IFF_LOWER_UP   0x10000         /* driver signals L1 up         */
55 #endif
56 #ifndef IFF_DORMANT
57 #define IFF_DORMANT    0x20000         /* driver signals dormant       */
58 #endif
59 
60 #ifndef IF_OPER_DORMANT
61 #define IF_OPER_DORMANT 5
62 #endif
63 #ifndef IF_OPER_UP
64 #define IF_OPER_UP 6
65 #endif
66 
67 struct nl80211_global {
68 	struct dl_list interfaces;
69 	int if_add_ifindex;
70 	u64 if_add_wdevid;
71 	int if_add_wdevid_set;
72 	struct netlink_data *netlink;
73 	struct nl_cb *nl_cb;
74 	struct nl_handle *nl;
75 	int nl80211_id;
76 	int ioctl_sock; /* socket for ioctl() use */
77 
78 	struct nl_handle *nl_event;
79 };
80 
81 struct nl80211_wiphy_data {
82 	struct dl_list list;
83 	struct dl_list bsss;
84 	struct dl_list drvs;
85 
86 	struct nl_handle *nl_beacons;
87 	struct nl_cb *nl_cb;
88 
89 	int wiphy_idx;
90 };
91 
92 struct i802_bss {
93 	struct wpa_driver_nl80211_data *drv;
94 	struct i802_bss *next;
95 	int ifindex;
96 	u64 wdev_id;
97 	char ifname[IFNAMSIZ + 1];
98 	char brname[IFNAMSIZ];
99 	unsigned int beacon_set:1;
100 	unsigned int added_if_into_bridge:1;
101 	unsigned int added_bridge:1;
102 	unsigned int in_deinit:1;
103 	unsigned int wdev_id_set:1;
104 	unsigned int added_if:1;
105 	unsigned int static_ap:1;
106 
107 	u8 addr[ETH_ALEN];
108 
109 	int freq;
110 	int bandwidth;
111 	int if_dynamic;
112 
113 	void *ctx;
114 	struct nl_handle *nl_preq, *nl_mgmt;
115 	struct nl_cb *nl_cb;
116 
117 	struct nl80211_wiphy_data *wiphy_data;
118 	struct dl_list wiphy_list;
119 };
120 
121 struct wpa_driver_nl80211_data {
122 	struct nl80211_global *global;
123 	struct dl_list list;
124 	struct dl_list wiphy_list;
125 	char phyname[32];
126 	void *ctx;
127 	int ifindex;
128 	int if_removed;
129 	int if_disabled;
130 	int ignore_if_down_event;
131 	struct rfkill_data *rfkill;
132 	struct wpa_driver_capa capa;
133 	u8 *extended_capa, *extended_capa_mask;
134 	unsigned int extended_capa_len;
135 	int has_capability;
136 
137 	int operstate;
138 
139 	int scan_complete_events;
140 	enum scan_states {
141 		NO_SCAN, SCAN_REQUESTED, SCAN_STARTED, SCAN_COMPLETED,
142 		SCAN_ABORTED, SCHED_SCAN_STARTED, SCHED_SCAN_STOPPED,
143 		SCHED_SCAN_RESULTS
144 	} scan_state;
145 
146 	struct nl_cb *nl_cb;
147 
148 	u8 auth_bssid[ETH_ALEN];
149 	u8 auth_attempt_bssid[ETH_ALEN];
150 	u8 bssid[ETH_ALEN];
151 	u8 prev_bssid[ETH_ALEN];
152 	int associated;
153 	u8 ssid[32];
154 	size_t ssid_len;
155 	enum nl80211_iftype nlmode;
156 	enum nl80211_iftype ap_scan_as_station;
157 	unsigned int assoc_freq;
158 
159 	int monitor_sock;
160 	int monitor_ifidx;
161 	int monitor_refcount;
162 
163 	unsigned int disabled_11b_rates:1;
164 	unsigned int pending_remain_on_chan:1;
165 	unsigned int in_interface_list:1;
166 	unsigned int device_ap_sme:1;
167 	unsigned int poll_command_supported:1;
168 	unsigned int data_tx_status:1;
169 	unsigned int scan_for_auth:1;
170 	unsigned int retry_auth:1;
171 	unsigned int use_monitor:1;
172 	unsigned int ignore_next_local_disconnect:1;
173 	unsigned int ignore_next_local_deauth:1;
174 	unsigned int allow_p2p_device:1;
175 	unsigned int hostapd:1;
176 	unsigned int start_mode_ap:1;
177 	unsigned int start_iface_up:1;
178 	unsigned int test_use_roc_tx:1;
179 	unsigned int ignore_deauth_event:1;
180 	unsigned int dfs_vendor_cmd_avail:1;
181 	unsigned int have_low_prio_scan:1;
182 
183 	u64 remain_on_chan_cookie;
184 	u64 send_action_cookie;
185 
186 	unsigned int last_mgmt_freq;
187 
188 	struct wpa_driver_scan_filter *filter_ssids;
189 	size_t num_filter_ssids;
190 
191 	struct i802_bss *first_bss;
192 
193 	int eapol_tx_sock;
194 
195 	int eapol_sock; /* socket for EAPOL frames */
196 
197 	int default_if_indices[16];
198 	int *if_indices;
199 	int num_if_indices;
200 
201 	/* From failed authentication command */
202 	int auth_freq;
203 	u8 auth_bssid_[ETH_ALEN];
204 	u8 auth_ssid[32];
205 	size_t auth_ssid_len;
206 	int auth_alg;
207 	u8 *auth_ie;
208 	size_t auth_ie_len;
209 	u8 auth_wep_key[4][16];
210 	size_t auth_wep_key_len[4];
211 	int auth_wep_tx_keyidx;
212 	int auth_local_state_change;
213 	int auth_p2p;
214 };
215 
216 #endif
217