2 * hostapd / Initialization and configuration
3 * Host AP kernel driver
4 * Copyright (c) 2002-2006, Jouni Malinen <j@w1.fi>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Alternatively, this software may be distributed under the terms of BSD
13 * See README and COPYING for more details.
29 #define ETH_P_ALL 0x0003
32 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
33 #endif /* ETH_P_PAE */
36 #define BIT(x) (1 << (x))
40 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
41 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
50 #define MAX_VLAN_ID 4094
59 struct ieee80211_hdr {
66 /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
74 #define IEEE80211_DA_FROMDS addr1
75 #define IEEE80211_BSSID_FROMDS addr2
76 #define IEEE80211_SA_FROMDS addr3
78 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
80 #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
82 /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
83 * frames that might be longer than normal default MTU and they are not
85 #define HOSTAPD_MTU 2290
87 extern unsigned char rfc1042_header[6];
89 struct hostap_sta_driver_data {
90 unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
91 unsigned long current_tx_rate;
92 unsigned long inactive_msec;
94 unsigned long num_ps_buf_frames;
95 unsigned long tx_retry_failed;
96 unsigned long tx_retry_count;
103 struct radius_server_data;
105 #ifdef CONFIG_FULL_DYNAMIC_VLAN
106 struct full_dynamic_vlan;
107 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
110 * struct hostapd_data - hostapd per-BSS data structure
112 struct hostapd_data {
113 struct hostapd_iface *iface;
114 struct hostapd_config *iconf;
115 struct hostapd_bss_config *conf;
116 int interface_added; /* virtual interface added for this BSS */
118 u8 own_addr[ETH_ALEN];
120 int num_sta; /* number of entries in sta_list */
121 struct sta_info *sta_list; /* STA info list head */
122 struct sta_info *sta_hash[STA_HASH_SIZE];
124 /* pointers to STA info; based on allocated AID or NULL if AID free
125 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
128 struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
130 struct driver_ops *driver;
133 u8 default_wep_key_idx;
135 struct radius_client_data *radius;
136 int radius_client_reconfigured;
137 u32 acct_session_id_hi, acct_session_id_lo;
139 struct iapp_data *iapp;
141 enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
142 ASSOCIATED } assoc_ap_state;
143 char assoc_ap_ssid[33];
144 int assoc_ap_ssid_len;
147 struct hostapd_cached_radius_acl *acl_cache;
148 struct hostapd_acl_query_data *acl_queries;
150 struct wpa_authenticator *wpa_auth;
152 struct rsn_preauth_interface *preauth_iface;
153 time_t michael_mic_failure;
154 int michael_mic_failures;
155 int tkip_countermeasures;
158 struct wpa_ctrl_dst *ctrl_dst;
161 void *eap_sim_db_priv;
162 struct radius_server_data *radius_srv;
164 int parameter_set_count;
166 #ifdef CONFIG_FULL_DYNAMIC_VLAN
167 struct full_dynamic_vlan *full_dynamic_vlan;
168 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
173 * hostapd_iface_cb - Generic callback type for per-iface asynchronous requests
174 * @iface: the interface the event occured on.
175 * @status: 0 if the request succeeded; -1 if the request failed.
177 typedef void (*hostapd_iface_cb)(struct hostapd_iface *iface, int status);
180 struct hostapd_config_change;
183 * struct hostapd_iface - hostapd per-interface data structure
185 struct hostapd_iface {
187 struct hostapd_config *conf;
189 hostapd_iface_cb setup_cb;
192 struct hostapd_data **bss;
194 int num_ap; /* number of entries in ap_list */
195 struct ap_info *ap_list; /* AP info list head */
196 struct ap_info *ap_hash[STA_HASH_SIZE];
197 struct ap_info *ap_iter_list;
199 struct hostapd_hw_modes *hw_features;
201 struct hostapd_hw_modes *current_mode;
202 /* Rates that are currently used (i.e., filtered copy of
203 * current_mode->channels */
205 struct hostapd_rate_data *current_rates;
206 hostapd_iface_cb hw_mode_sel_cb;
210 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
214 /* Number of associated stations that do not support Short Slot Time */
215 int num_sta_no_short_slot_time;
217 /* Number of associated stations that do not support Short Preamble */
218 int num_sta_no_short_preamble;
220 int olbc; /* Overlapping Legacy BSS Condition */
224 unsigned int tx_power;
225 unsigned int sta_max_power;
227 unsigned int channel_switch;
229 struct hostapd_config_change *change;
230 hostapd_iface_cb reload_iface_cb;
231 hostapd_iface_cb config_reload_cb;
234 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
236 void hostapd_logger(struct hostapd_data *hapd, const u8 *addr,
237 unsigned int module, int level, const char *fmt,
238 ...) PRINTF_FORMAT(5, 6);
242 #define HOSTAPD_DEBUG(level, args...) \
244 if (hapd->conf == NULL || hapd->conf->debug >= (level)) \
247 #endif /* _MSC_VER */
249 #define HOSTAPD_DEBUG_COND(level) (hapd->conf->debug >= (level))
251 const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
253 int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b);
255 #endif /* HOSTAPD_H */