2 * Driver interaction with Linux nl80211/cfg80211 - definitions
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
9 * This software may be distributed under the terms of the BSD license.
10 * See README for more details.
13 #ifndef DRIVER_NL80211_H
14 #define DRIVER_NL80211_H
16 #include "nl80211_copy.h"
17 #include "utils/list.h"
21 /* libnl 2.0 compatibility code */
22 #define nl_handle nl_sock
23 #define nl80211_handle_alloc nl_socket_alloc_cb
24 #define nl80211_handle_destroy nl_socket_free
25 #endif /* CONFIG_LIBNL20 */
27 struct nl80211_global {
28 struct dl_list interfaces;
31 int if_add_wdevid_set;
32 struct netlink_data *netlink;
36 int ioctl_sock; /* socket for ioctl() use */
38 struct nl_handle *nl_event;
41 struct nl80211_wiphy_data {
46 struct nl_handle *nl_beacons;
53 struct wpa_driver_nl80211_data *drv;
54 struct i802_bss *next;
57 char ifname[IFNAMSIZ + 1];
58 char brname[IFNAMSIZ];
59 unsigned int beacon_set:1;
60 unsigned int added_if_into_bridge:1;
61 unsigned int added_bridge:1;
62 unsigned int in_deinit:1;
63 unsigned int wdev_id_set:1;
64 unsigned int added_if:1;
65 unsigned int static_ap:1;
74 struct nl_handle *nl_preq, *nl_mgmt;
77 struct nl80211_wiphy_data *wiphy_data;
78 struct dl_list wiphy_list;
81 struct wpa_driver_nl80211_data {
82 struct nl80211_global *global;
84 struct dl_list wiphy_list;
86 u8 perm_addr[ETH_ALEN];
91 int ignore_if_down_event;
92 struct rfkill_data *rfkill;
93 struct wpa_driver_capa capa;
94 u8 *extended_capa, *extended_capa_mask;
95 unsigned int extended_capa_len;
100 int scan_complete_events;
102 NO_SCAN, SCAN_REQUESTED, SCAN_STARTED, SCAN_COMPLETED,
103 SCAN_ABORTED, SCHED_SCAN_STARTED, SCHED_SCAN_STOPPED,
109 u8 auth_bssid[ETH_ALEN];
110 u8 auth_attempt_bssid[ETH_ALEN];
112 u8 prev_bssid[ETH_ALEN];
116 enum nl80211_iftype nlmode;
117 enum nl80211_iftype ap_scan_as_station;
118 unsigned int assoc_freq;
122 int monitor_refcount;
124 unsigned int disabled_11b_rates:1;
125 unsigned int pending_remain_on_chan:1;
126 unsigned int in_interface_list:1;
127 unsigned int device_ap_sme:1;
128 unsigned int poll_command_supported:1;
129 unsigned int data_tx_status:1;
130 unsigned int scan_for_auth:1;
131 unsigned int retry_auth:1;
132 unsigned int use_monitor:1;
133 unsigned int ignore_next_local_disconnect:1;
134 unsigned int ignore_next_local_deauth:1;
135 unsigned int hostapd:1;
136 unsigned int start_mode_ap:1;
137 unsigned int start_iface_up:1;
138 unsigned int test_use_roc_tx:1;
139 unsigned int ignore_deauth_event:1;
140 unsigned int roaming_vendor_cmd_avail:1;
141 unsigned int dfs_vendor_cmd_avail:1;
142 unsigned int have_low_prio_scan:1;
143 unsigned int force_connect_cmd:1;
144 unsigned int addr_changed:1;
145 unsigned int key_mgmt_set_key_vendor_cmd_avail:1;
146 unsigned int roam_auth_vendor_event_avail:1;
148 u64 remain_on_chan_cookie;
149 u64 send_action_cookie;
151 unsigned int last_mgmt_freq;
153 struct wpa_driver_scan_filter *filter_ssids;
154 size_t num_filter_ssids;
156 struct i802_bss *first_bss;
160 int eapol_sock; /* socket for EAPOL frames */
162 struct nl_handle *rtnl_sk; /* nl_sock for NETLINK_ROUTE */
164 int default_if_indices[16];
168 /* From failed authentication command */
170 u8 auth_bssid_[ETH_ALEN];
172 size_t auth_ssid_len;
176 u8 auth_wep_key[4][16];
177 size_t auth_wep_key_len[4];
178 int auth_wep_tx_keyidx;
179 int auth_local_state_change;
185 int nl80211_set_iface_id(struct nl_msg *msg, struct i802_bss *bss);
186 void * nl80211_cmd(struct wpa_driver_nl80211_data *drv,
187 struct nl_msg *msg, int flags, uint8_t cmd);
188 int send_and_recv_msgs(struct wpa_driver_nl80211_data *drv, struct nl_msg *msg,
189 int (*valid_handler)(struct nl_msg *, void *),
191 int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
192 const char *ifname, enum nl80211_iftype iftype,
193 const u8 *addr, int wds,
194 int (*handler)(struct nl_msg *, void *),
195 void *arg, int use_existing);
196 void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv, int ifidx);
197 unsigned int nl80211_get_assoc_freq(struct wpa_driver_nl80211_data *drv);
198 enum chan_width convert2width(int width);
199 void nl80211_mark_disconnected(struct wpa_driver_nl80211_data *drv);
200 struct i802_bss * get_bss_ifindex(struct wpa_driver_nl80211_data *drv,
202 int is_ap_interface(enum nl80211_iftype nlmode);
203 int wpa_driver_nl80211_authenticate_retry(struct wpa_driver_nl80211_data *drv);
204 int nl80211_get_link_signal(struct wpa_driver_nl80211_data *drv,
205 struct wpa_signal_info *sig);
206 int nl80211_get_link_noise(struct wpa_driver_nl80211_data *drv,
207 struct wpa_signal_info *sig_change);
208 int nl80211_get_wiphy_index(struct i802_bss *bss);
209 int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
210 enum nl80211_iftype nlmode);
211 void wpa_driver_nl80211_scan_timeout(void *eloop_ctx, void *timeout_ctx);
213 int nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv);
214 void nl80211_remove_monitor_interface(struct wpa_driver_nl80211_data *drv);
215 int nl80211_send_monitor(struct wpa_driver_nl80211_data *drv,
216 const void *data, size_t len,
217 int encrypt, int noack);
219 int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv);
220 struct hostapd_hw_modes *
221 nl80211_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags);
224 int android_nl_socket_set_nonblocking(struct nl_handle *handle);
225 int android_genl_ctrl_resolve(struct nl_handle *handle, const char *name);
226 int android_pno_start(struct i802_bss *bss,
227 struct wpa_driver_scan_params *params);
228 int android_pno_stop(struct i802_bss *bss);
229 extern int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
233 int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration);
234 int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len);
235 int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow);
236 int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
237 const struct wpabuf *proberesp,
238 const struct wpabuf *assocresp);
239 #endif /* ANDROID_P2P */
242 #endif /* DRIVER_NL80211_H */