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 #define MAX_VLAN_ID 4094
22 struct wpa_driver_ops;
24 struct radius_server_data;
25 struct upnp_wps_device_sm;
26 struct hapd_interfaces;
30 #ifdef CONFIG_FULL_DYNAMIC_VLAN
31 struct full_dynamic_vlan;
32 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
34 struct hostapd_probereq_cb {
35 void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
39 #define HOSTAPD_RATE_BASIC 0x00000001
41 struct hostapd_rate_data {
42 int rate; /* rate in 100 kbps */
43 int flags; /* HOSTAPD_RATE_ flags */
47 struct hostapd_driver_ops {
48 int (*set_ap_wps_ie)(struct hostapd_data *hapd,
49 const struct wpabuf *beacon,
50 const struct wpabuf *probe);
51 int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
53 int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
54 const u8 *data, size_t data_len, int encrypt);
55 int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
57 int (*set_key)(const char *ifname, struct hostapd_data *hapd,
58 wpa_alg alg, const u8 *addr, int key_idx,
59 int set_tx, const u8 *seq, size_t seq_len,
60 const u8 *key, size_t key_len);
64 * struct hostapd_data - hostapd per-BSS data structure
67 struct hostapd_iface *iface;
68 struct hostapd_config *iconf;
69 struct hostapd_bss_config *conf;
70 int interface_added; /* virtual interface added for this BSS */
72 u8 own_addr[ETH_ALEN];
74 int num_sta; /* number of entries in sta_list */
75 struct sta_info *sta_list; /* STA info list head */
76 #define STA_HASH_SIZE 256
77 #define STA_HASH(sta) (sta[5])
78 struct sta_info *sta_hash[STA_HASH_SIZE];
81 * Bitfield for indicating which AIDs are allocated. Only AID values
82 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
85 #define AID_WORDS ((2008 + 31) / 32)
86 u32 sta_aid[AID_WORDS];
88 const struct wpa_driver_ops *driver;
90 struct hostapd_driver_ops drv;
92 void *msg_ctx; /* ctx for wpa_msg() calls */
94 struct radius_client_data *radius;
95 u32 acct_session_id_hi, acct_session_id_lo;
97 struct iapp_data *iapp;
99 struct hostapd_cached_radius_acl *acl_cache;
100 struct hostapd_acl_query_data *acl_queries;
102 struct wpa_authenticator *wpa_auth;
103 struct eapol_authenticator *eapol_auth;
105 struct rsn_preauth_interface *preauth_iface;
106 time_t michael_mic_failure;
107 int michael_mic_failures;
108 int tkip_countermeasures;
111 struct wpa_ctrl_dst *ctrl_dst;
114 void *eap_sim_db_priv;
115 struct radius_server_data *radius_srv;
117 int parameter_set_count;
119 #ifdef CONFIG_FULL_DYNAMIC_VLAN
120 struct full_dynamic_vlan *full_dynamic_vlan;
121 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
123 struct l2_packet_data *l2;
124 struct wps_context *wps;
127 struct wpabuf *wps_beacon_ie;
128 struct wpabuf *wps_probe_resp_ie;
129 unsigned int ap_pin_failures;
130 struct upnp_wps_device_sm *wps_upnp;
131 #endif /* CONFIG_WPS */
133 struct hostapd_probereq_cb *probereq_cb;
134 size_t num_probereq_cb;
139 * struct hostapd_iface - hostapd per-interface data structure
141 struct hostapd_iface {
142 struct hapd_interfaces *interfaces;
145 struct hostapd_config *conf;
148 struct hostapd_data **bss;
150 int num_ap; /* number of entries in ap_list */
151 struct ap_info *ap_list; /* AP info list head */
152 struct ap_info *ap_hash[STA_HASH_SIZE];
153 struct ap_info *ap_iter_list;
155 struct hostapd_hw_modes *hw_features;
157 struct hostapd_hw_modes *current_mode;
158 /* Rates that are currently used (i.e., filtered copy of
159 * current_mode->channels */
161 struct hostapd_rate_data *current_rates;
165 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
169 /* Number of associated stations that do not support Short Slot Time */
170 int num_sta_no_short_slot_time;
172 /* Number of associated stations that do not support Short Preamble */
173 int num_sta_no_short_preamble;
175 int olbc; /* Overlapping Legacy BSS Condition */
177 /* Number of HT associated stations that do not support greenfield */
178 int num_sta_ht_no_gf;
180 /* Number of associated non-HT stations */
183 /* Number of HT associated stations 20 MHz */
184 int num_sta_ht_20mhz;
186 /* Overlapping BSS information */
190 void (*scan_cb)(struct hostapd_iface *iface);
193 int hostapd_reload_config(struct hostapd_iface *iface);
194 struct hostapd_data *
195 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
196 struct hostapd_config *conf,
197 struct hostapd_bss_config *bss);
198 int hostapd_setup_interface(struct hostapd_iface *iface);
199 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
200 void hostapd_interface_deinit(struct hostapd_iface *iface);
201 int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
202 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
204 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
205 int (*cb)(struct hostapd_iface *iface,
206 void *ctx), void *ctx);
208 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
209 void (*cb)(void *ctx, const u8 *sa,
210 const u8 *ie, size_t ie_len),
212 int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
214 int hostapd_sta_flags_to_drv(int flags);
216 int eap_server_register_methods(void);
217 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
219 #endif /* HOSTAPD_H */