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 }; 71 72 struct i802_bss { 73 struct wpa_driver_nl80211_data *drv; 74 struct i802_bss *next; 75 int ifindex; 76 char ifname[IFNAMSIZ + 1]; 77 char brname[IFNAMSIZ]; 78 unsigned int beacon_set:1; 79 unsigned int added_if_into_bridge:1; 80 unsigned int added_bridge:1; 81 }; 82 83 struct wpa_driver_nl80211_data { 84 struct nl80211_global *global; 85 struct dl_list list; 86 u8 addr[ETH_ALEN]; 87 char phyname[32]; 88 void *ctx; 89 struct netlink_data *netlink; 90 int ioctl_sock; /* socket for ioctl() use */ 91 int ifindex; 92 int if_removed; 93 int if_disabled; 94 struct rfkill_data *rfkill; 95 struct wpa_driver_capa capa; 96 int has_capability; 97 98 int operstate; 99 100 int scan_complete_events; 101 102 struct nl_handle *nl_handle; 103 struct nl_handle *nl_handle_event; 104 struct nl_handle *nl_handle_preq; 105 struct nl_cache *nl_cache; 106 struct nl_cache *nl_cache_event; 107 struct nl_cache *nl_cache_preq; 108 struct nl_cb *nl_cb; 109 struct genl_family *nl80211; 110 111 u8 auth_bssid[ETH_ALEN]; 112 u8 bssid[ETH_ALEN]; 113 int associated; 114 u8 ssid[32]; 115 size_t ssid_len; 116 int nlmode; 117 int ap_scan_as_station; 118 unsigned int assoc_freq; 119 120 int monitor_sock; 121 int monitor_ifidx; 122 int no_monitor_iface_capab; 123 int disable_11b_rates; 124 125 unsigned int pending_remain_on_chan:1; 126 127 u64 remain_on_chan_cookie; 128 u64 send_action_cookie; 129 130 unsigned int last_mgmt_freq; 131 132 struct wpa_driver_scan_filter *filter_ssids; 133 size_t num_filter_ssids; 134 135 struct i802_bss first_bss; 136 137 #ifdef HOSTAPD 138 int eapol_sock; /* socket for EAPOL frames */ 139 140 int default_if_indices[16]; 141 int *if_indices; 142 int num_if_indices; 143 144 int last_freq; 145 int last_freq_ht; 146 #endif /* HOSTAPD */ 147 }; 148 149 #endif 150