1 /* 2 * Driver interaction with Linux nl80211/cfg80211 3 * Copyright (c) 2002-2010, 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 program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 * 13 * Alternatively, this software may be distributed under the terms of BSD 14 * license. 15 * 16 * See README and COPYING for more details. 17 */ 18 19 #ifndef _DRIVER_NL80211_H_ 20 #define _DRIVER_NL80211_H_ 21 22 #include "includes.h" 23 #include <sys/ioctl.h> 24 #include <sys/types.h> 25 #include <sys/stat.h> 26 #include <fcntl.h> 27 #include <net/if.h> 28 #include <netlink/genl/genl.h> 29 #include <netlink/genl/family.h> 30 #include <netlink/genl/ctrl.h> 31 #include <linux/rtnetlink.h> 32 #include <netpacket/packet.h> 33 #include <linux/filter.h> 34 #include "nl80211_copy.h" 35 36 #include "common.h" 37 #include "eloop.h" 38 #include "utils/list.h" 39 #include "common/ieee802_11_defs.h" 40 #include "netlink.h" 41 #include "linux_ioctl.h" 42 #include "radiotap.h" 43 #include "radiotap_iter.h" 44 #include "rfkill.h" 45 #include "driver.h" 46 47 #ifdef CONFIG_LIBNL20 48 /* libnl 2.0 compatibility code */ 49 #define nl_handle nl_sock 50 #define nl80211_handle_alloc nl_socket_alloc_cb 51 #define nl80211_handle_destroy nl_socket_free 52 #endif /* CONFIG_LIBNL20 */ 53 54 #ifndef IFF_LOWER_UP 55 #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ 56 #endif 57 #ifndef IFF_DORMANT 58 #define IFF_DORMANT 0x20000 /* driver signals dormant */ 59 #endif 60 61 #ifndef IF_OPER_DORMANT 62 #define IF_OPER_DORMANT 5 63 #endif 64 #ifndef IF_OPER_UP 65 #define IF_OPER_UP 6 66 #endif 67 68 struct nl80211_global { 69 struct dl_list interfaces; 70 int if_add_ifindex; 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 char ifname[IFNAMSIZ + 1]; 96 char brname[IFNAMSIZ]; 97 unsigned int beacon_set:1; 98 unsigned int added_if_into_bridge:1; 99 unsigned int added_bridge:1; 100 unsigned int in_deinit:1; 101 102 u8 addr[ETH_ALEN]; 103 104 int freq; 105 106 struct nl_handle *nl_preq, *nl_mgmt; 107 struct nl_cb *nl_cb; 108 109 struct nl80211_wiphy_data *wiphy_data; 110 struct dl_list wiphy_list; 111 }; 112 113 struct wpa_driver_nl80211_data { 114 struct nl80211_global *global; 115 struct dl_list list; 116 struct dl_list wiphy_list; 117 char phyname[32]; 118 void *ctx; 119 int ifindex; 120 int if_removed; 121 int if_disabled; 122 int ignore_if_down_event; 123 struct rfkill_data *rfkill; 124 struct wpa_driver_capa capa; 125 int has_capability; 126 127 int operstate; 128 129 int scan_complete_events; 130 131 struct nl_cb *nl_cb; 132 133 u8 auth_bssid[ETH_ALEN]; 134 u8 bssid[ETH_ALEN]; 135 int associated; 136 u8 ssid[32]; 137 size_t ssid_len; 138 enum nl80211_iftype nlmode; 139 enum nl80211_iftype ap_scan_as_station; 140 unsigned int assoc_freq; 141 142 int monitor_sock; 143 int monitor_ifidx; 144 int monitor_refcount; 145 146 unsigned int disabled_11b_rates:1; 147 unsigned int pending_remain_on_chan:1; 148 unsigned int in_interface_list:1; 149 unsigned int device_ap_sme:1; 150 unsigned int poll_command_supported:1; 151 unsigned int data_tx_status:1; 152 unsigned int scan_for_auth:1; 153 unsigned int retry_auth:1; 154 unsigned int use_monitor:1; 155 156 u64 remain_on_chan_cookie; 157 u64 send_action_cookie; 158 159 unsigned int last_mgmt_freq; 160 161 struct wpa_driver_scan_filter *filter_ssids; 162 size_t num_filter_ssids; 163 164 struct i802_bss first_bss; 165 166 int eapol_tx_sock; 167 168 #ifdef HOSTAPD 169 int eapol_sock; /* socket for EAPOL frames */ 170 171 int default_if_indices[16]; 172 int *if_indices; 173 int num_if_indices; 174 175 int last_freq; 176 int last_freq_ht; 177 #endif /* HOSTAPD */ 178 179 /* From failed authentication command */ 180 int auth_freq; 181 u8 auth_bssid_[ETH_ALEN]; 182 u8 auth_ssid[32]; 183 size_t auth_ssid_len; 184 int auth_alg; 185 u8 *auth_ie; 186 size_t auth_ie_len; 187 u8 auth_wep_key[4][16]; 188 size_t auth_wep_key_len[4]; 189 int auth_wep_tx_keyidx; 190 int auth_local_state_change; 191 int auth_p2p; 192 }; 193 194 #endif 195