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 101 u8 addr[ETH_ALEN]; 102 103 int freq; 104 105 struct nl_handle *nl_preq, *nl_mgmt; 106 struct nl_cb *nl_cb; 107 108 struct nl80211_wiphy_data *wiphy_data; 109 struct dl_list wiphy_list; 110 }; 111 112 struct wpa_driver_nl80211_data { 113 struct nl80211_global *global; 114 struct dl_list list; 115 struct dl_list wiphy_list; 116 char phyname[32]; 117 void *ctx; 118 int ifindex; 119 int if_removed; 120 int if_disabled; 121 int ignore_if_down_event; 122 struct rfkill_data *rfkill; 123 struct wpa_driver_capa capa; 124 int has_capability; 125 126 int operstate; 127 128 int scan_complete_events; 129 130 struct nl_cb *nl_cb; 131 132 u8 auth_bssid[ETH_ALEN]; 133 u8 bssid[ETH_ALEN]; 134 int associated; 135 u8 ssid[32]; 136 size_t ssid_len; 137 enum nl80211_iftype nlmode; 138 enum nl80211_iftype ap_scan_as_station; 139 unsigned int assoc_freq; 140 141 int monitor_sock; 142 int monitor_ifidx; 143 int monitor_refcount; 144 145 unsigned int disabled_11b_rates:1; 146 unsigned int pending_remain_on_chan:1; 147 unsigned int in_interface_list:1; 148 unsigned int device_ap_sme:1; 149 unsigned int poll_command_supported:1; 150 unsigned int data_tx_status:1; 151 unsigned int scan_for_auth:1; 152 unsigned int retry_auth:1; 153 unsigned int use_monitor: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