2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "common/defs.h"
20 struct wpa_driver_ops;
22 struct radius_server_data;
23 struct upnp_wps_device_sm;
24 struct hapd_interfaces;
28 #ifdef CONFIG_FULL_DYNAMIC_VLAN
29 struct full_dynamic_vlan;
30 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
32 struct hostapd_probereq_cb {
33 void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
37 #define HOSTAPD_RATE_BASIC 0x00000001
39 struct hostapd_rate_data {
40 int rate; /* rate in 100 kbps */
41 int flags; /* HOSTAPD_RATE_ flags */
45 struct hostapd_driver_ops {
46 int (*set_ap_wps_ie)(struct hostapd_data *hapd,
47 const struct wpabuf *beacon,
48 const struct wpabuf *probe);
49 int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
51 int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
52 const u8 *data, size_t data_len, int encrypt);
53 int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
55 int (*set_key)(const char *ifname, struct hostapd_data *hapd,
56 wpa_alg alg, const u8 *addr, int key_idx,
57 int set_tx, const u8 *seq, size_t seq_len,
58 const u8 *key, size_t key_len);
62 * struct hostapd_data - hostapd per-BSS data structure
65 struct hostapd_iface *iface;
66 struct hostapd_config *iconf;
67 struct hostapd_bss_config *conf;
68 int interface_added; /* virtual interface added for this BSS */
70 u8 own_addr[ETH_ALEN];
72 int num_sta; /* number of entries in sta_list */
73 struct sta_info *sta_list; /* STA info list head */
74 #define STA_HASH_SIZE 256
75 #define STA_HASH(sta) (sta[5])
76 struct sta_info *sta_hash[STA_HASH_SIZE];
79 * Bitfield for indicating which AIDs are allocated. Only AID values
80 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
83 #define AID_WORDS ((2008 + 31) / 32)
84 u32 sta_aid[AID_WORDS];
86 const struct wpa_driver_ops *driver;
88 struct hostapd_driver_ops drv;
90 void *msg_ctx; /* ctx for wpa_msg() calls */
92 struct radius_client_data *radius;
93 u32 acct_session_id_hi, acct_session_id_lo;
95 struct iapp_data *iapp;
97 struct hostapd_cached_radius_acl *acl_cache;
98 struct hostapd_acl_query_data *acl_queries;
100 struct wpa_authenticator *wpa_auth;
101 struct eapol_authenticator *eapol_auth;
103 struct rsn_preauth_interface *preauth_iface;
104 time_t michael_mic_failure;
105 int michael_mic_failures;
106 int tkip_countermeasures;
109 struct wpa_ctrl_dst *ctrl_dst;
112 void *eap_sim_db_priv;
113 struct radius_server_data *radius_srv;
115 int parameter_set_count;
117 #ifdef CONFIG_FULL_DYNAMIC_VLAN
118 struct full_dynamic_vlan *full_dynamic_vlan;
119 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
121 struct l2_packet_data *l2;
122 struct wps_context *wps;
125 struct wpabuf *wps_beacon_ie;
126 struct wpabuf *wps_probe_resp_ie;
127 unsigned int ap_pin_failures;
128 struct upnp_wps_device_sm *wps_upnp;
129 #endif /* CONFIG_WPS */
131 struct hostapd_probereq_cb *probereq_cb;
132 size_t num_probereq_cb;
137 * struct hostapd_iface - hostapd per-interface data structure
139 struct hostapd_iface {
140 struct hapd_interfaces *interfaces;
142 struct hostapd_config * (*config_read_cb)(const char *config_fname);
144 struct hostapd_config *conf;
147 struct hostapd_data **bss;
149 int num_ap; /* number of entries in ap_list */
150 struct ap_info *ap_list; /* AP info list head */
151 struct ap_info *ap_hash[STA_HASH_SIZE];
152 struct ap_info *ap_iter_list;
154 struct hostapd_hw_modes *hw_features;
156 struct hostapd_hw_modes *current_mode;
157 /* Rates that are currently used (i.e., filtered copy of
158 * current_mode->channels */
160 struct hostapd_rate_data *current_rates;
164 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
168 /* Number of associated stations that do not support Short Slot Time */
169 int num_sta_no_short_slot_time;
171 /* Number of associated stations that do not support Short Preamble */
172 int num_sta_no_short_preamble;
174 int olbc; /* Overlapping Legacy BSS Condition */
176 /* Number of HT associated stations that do not support greenfield */
177 int num_sta_ht_no_gf;
179 /* Number of associated non-HT stations */
182 /* Number of HT associated stations 20 MHz */
183 int num_sta_ht_20mhz;
185 /* Overlapping BSS information */
189 void (*scan_cb)(struct hostapd_iface *iface);
192 int hostapd_reload_config(struct hostapd_iface *iface);
193 struct hostapd_data *
194 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
195 struct hostapd_config *conf,
196 struct hostapd_bss_config *bss);
197 int hostapd_setup_interface(struct hostapd_iface *iface);
198 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
199 void hostapd_interface_deinit(struct hostapd_iface *iface);
200 int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
201 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
203 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
204 int (*cb)(struct hostapd_iface *iface,
205 void *ctx), void *ctx);
207 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
208 void (*cb)(void *ctx, const u8 *sa,
209 const u8 *ie, size_t ie_len),
211 int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
213 int hostapd_sta_flags_to_drv(int flags);
215 int eap_server_register_methods(void);
216 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
218 #endif /* HOSTAPD_H */