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