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
;
27 struct hostap_sta_driver_data
;
28 struct ieee80211_ht_capabilities
;
29 struct full_dynamic_vlan
;
31 struct hostapd_probereq_cb
{
32 int (*cb
)(void *ctx
, const u8
*sa
, const u8
*ie
, size_t ie_len
);
36 #define HOSTAPD_RATE_BASIC 0x00000001
38 struct hostapd_rate_data
{
39 int rate
; /* rate in 100 kbps */
40 int flags
; /* HOSTAPD_RATE_ flags */
43 struct hostapd_frame_info
{
50 struct hostapd_driver_ops
{
51 int (*set_ap_wps_ie
)(struct hostapd_data
*hapd
,
52 const struct wpabuf
*beacon
,
53 const struct wpabuf
*probe
);
54 int (*send_mgmt_frame
)(struct hostapd_data
*hapd
, const void *msg
,
56 int (*send_eapol
)(struct hostapd_data
*hapd
, const u8
*addr
,
57 const u8
*data
, size_t data_len
, int encrypt
);
58 int (*set_authorized
)(struct hostapd_data
*hapd
, struct sta_info
*sta
,
60 int (*set_key
)(const char *ifname
, struct hostapd_data
*hapd
,
61 enum wpa_alg alg
, const u8
*addr
, int key_idx
,
62 int set_tx
, const u8
*seq
, size_t seq_len
,
63 const u8
*key
, size_t key_len
);
64 int (*read_sta_data
)(struct hostapd_data
*hapd
,
65 struct hostap_sta_driver_data
*data
,
67 int (*sta_clear_stats
)(struct hostapd_data
*hapd
, const u8
*addr
);
68 int (*set_sta_flags
)(struct hostapd_data
*hapd
, struct sta_info
*sta
);
69 int (*set_drv_ieee8021x
)(struct hostapd_data
*hapd
, const char *ifname
,
71 int (*set_radius_acl_auth
)(struct hostapd_data
*hapd
,
72 const u8
*mac
, int accepted
,
74 int (*set_radius_acl_expire
)(struct hostapd_data
*hapd
,
76 int (*set_bss_params
)(struct hostapd_data
*hapd
, int use_protection
);
77 int (*set_beacon
)(const char *ifname
, struct hostapd_data
*hapd
,
78 const u8
*head
, size_t head_len
,
79 const u8
*tail
, size_t tail_len
, int dtim_period
,
81 int (*vlan_if_add
)(struct hostapd_data
*hapd
, const char *ifname
);
82 int (*vlan_if_remove
)(struct hostapd_data
*hapd
, const char *ifname
);
83 int (*set_wds_sta
)(struct hostapd_data
*hapd
, const u8
*addr
, int aid
,
85 int (*set_sta_vlan
)(const char *ifname
, struct hostapd_data
*hapd
,
86 const u8
*addr
, int vlan_id
);
87 int (*get_inact_sec
)(struct hostapd_data
*hapd
, const u8
*addr
);
88 int (*sta_deauth
)(struct hostapd_data
*hapd
, const u8
*addr
,
90 int (*sta_disassoc
)(struct hostapd_data
*hapd
, const u8
*addr
,
92 int (*sta_add
)(const char *ifname
, struct hostapd_data
*hapd
,
93 const u8
*addr
, u16 aid
, u16 capability
,
94 const u8
*supp_rates
, size_t supp_rates_len
,
96 const struct ieee80211_ht_capabilities
*ht_capab
);
97 int (*sta_remove
)(struct hostapd_data
*hapd
, const u8
*addr
);
98 int (*set_countermeasures
)(struct hostapd_data
*hapd
, int enabled
);
102 * struct hostapd_data - hostapd per-BSS data structure
104 struct hostapd_data
{
105 struct hostapd_iface
*iface
;
106 struct hostapd_config
*iconf
;
107 struct hostapd_bss_config
*conf
;
108 int interface_added
; /* virtual interface added for this BSS */
110 u8 own_addr
[ETH_ALEN
];
112 int num_sta
; /* number of entries in sta_list */
113 struct sta_info
*sta_list
; /* STA info list head */
114 #define STA_HASH_SIZE 256
115 #define STA_HASH(sta) (sta[5])
116 struct sta_info
*sta_hash
[STA_HASH_SIZE
];
119 * Bitfield for indicating which AIDs are allocated. Only AID values
120 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
123 #define AID_WORDS ((2008 + 31) / 32)
124 u32 sta_aid
[AID_WORDS
];
126 const struct wpa_driver_ops
*driver
;
128 struct hostapd_driver_ops drv
;
130 void (*new_assoc_sta_cb
)(struct hostapd_data
*hapd
,
131 struct sta_info
*sta
, int reassoc
);
133 void *msg_ctx
; /* ctx for wpa_msg() calls */
135 struct radius_client_data
*radius
;
136 u32 acct_session_id_hi
, acct_session_id_lo
;
138 struct iapp_data
*iapp
;
140 struct hostapd_cached_radius_acl
*acl_cache
;
141 struct hostapd_acl_query_data
*acl_queries
;
143 struct wpa_authenticator
*wpa_auth
;
144 struct eapol_authenticator
*eapol_auth
;
146 struct rsn_preauth_interface
*preauth_iface
;
147 time_t michael_mic_failure
;
148 int michael_mic_failures
;
149 int tkip_countermeasures
;
152 struct wpa_ctrl_dst
*ctrl_dst
;
155 void *eap_sim_db_priv
;
156 struct radius_server_data
*radius_srv
;
158 int parameter_set_count
;
160 #ifdef CONFIG_FULL_DYNAMIC_VLAN
161 struct full_dynamic_vlan
*full_dynamic_vlan
;
162 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
164 struct l2_packet_data
*l2
;
165 struct wps_context
*wps
;
168 struct wpabuf
*wps_beacon_ie
;
169 struct wpabuf
*wps_probe_resp_ie
;
170 unsigned int ap_pin_failures
;
171 struct upnp_wps_device_sm
*wps_upnp
;
172 #endif /* CONFIG_WPS */
174 struct hostapd_probereq_cb
*probereq_cb
;
175 size_t num_probereq_cb
;
180 * struct hostapd_iface - hostapd per-interface data structure
182 struct hostapd_iface
{
183 struct hapd_interfaces
*interfaces
;
185 int (*reload_config
)(struct hostapd_iface
*iface
);
186 struct hostapd_config
* (*config_read_cb
)(const char *config_fname
);
188 struct hostapd_config
*conf
;
191 struct hostapd_data
**bss
;
193 int num_ap
; /* number of entries in ap_list */
194 struct ap_info
*ap_list
; /* AP info list head */
195 struct ap_info
*ap_hash
[STA_HASH_SIZE
];
196 struct ap_info
*ap_iter_list
;
198 struct hostapd_hw_modes
*hw_features
;
200 struct hostapd_hw_modes
*current_mode
;
201 /* Rates that are currently used (i.e., filtered copy of
202 * current_mode->channels */
204 struct hostapd_rate_data
*current_rates
;
208 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
212 /* Number of associated stations that do not support Short Slot Time */
213 int num_sta_no_short_slot_time
;
215 /* Number of associated stations that do not support Short Preamble */
216 int num_sta_no_short_preamble
;
218 int olbc
; /* Overlapping Legacy BSS Condition */
220 /* Number of HT associated stations that do not support greenfield */
221 int num_sta_ht_no_gf
;
223 /* Number of associated non-HT stations */
226 /* Number of HT associated stations 20 MHz */
227 int num_sta_ht_20mhz
;
229 /* Overlapping BSS information */
233 void (*scan_cb
)(struct hostapd_iface
*iface
);
235 int (*ctrl_iface_init
)(struct hostapd_data
*hapd
);
236 void (*ctrl_iface_deinit
)(struct hostapd_data
*hapd
);
238 int (*for_each_interface
)(struct hapd_interfaces
*interfaces
,
239 int (*cb
)(struct hostapd_iface
*iface
,
240 void *ctx
), void *ctx
);
244 int hostapd_reload_config(struct hostapd_iface
*iface
);
245 struct hostapd_data
*
246 hostapd_alloc_bss_data(struct hostapd_iface
*hapd_iface
,
247 struct hostapd_config
*conf
,
248 struct hostapd_bss_config
*bss
);
249 int hostapd_setup_interface(struct hostapd_iface
*iface
);
250 int hostapd_setup_interface_complete(struct hostapd_iface
*iface
, int err
);
251 void hostapd_interface_deinit(struct hostapd_iface
*iface
);
252 void hostapd_interface_free(struct hostapd_iface
*iface
);
253 void hostapd_new_assoc_sta(struct hostapd_data
*hapd
, struct sta_info
*sta
,
257 int hostapd_register_probereq_cb(struct hostapd_data
*hapd
,
258 int (*cb
)(void *ctx
, const u8
*sa
,
259 const u8
*ie
, size_t ie_len
),
261 void hostapd_prune_associations(struct hostapd_data
*hapd
, const u8
*addr
);
263 /* drv_callbacks.c (TODO: move to somewhere else?) */
264 int hostapd_notif_assoc(struct hostapd_data
*hapd
, const u8
*addr
,
265 const u8
*ie
, size_t ielen
);
266 void hostapd_notif_disassoc(struct hostapd_data
*hapd
, const u8
*addr
);
268 #endif /* HOSTAPD_H */