Make hostapd_for_each_interface() take context pointer as argument
[libeap.git] / hostapd / hostapd.h
1 /*
2  * hostapd / Initialization and configuration
3  * Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
4  *
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.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef HOSTAPD_H
16 #define HOSTAPD_H
17
18 #define MAX_VLAN_ID 4094
19
20 struct wpa_driver_ops;
21 struct wpa_ctrl_dst;
22 struct radius_server_data;
23 struct upnp_wps_device_sm;
24 struct hapd_interfaces;
25
26 #ifdef CONFIG_FULL_DYNAMIC_VLAN
27 struct full_dynamic_vlan;
28 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
29
30 struct hostapd_probereq_cb {
31         void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
32         void *ctx;
33 };
34
35 #define HOSTAPD_RATE_BASIC 0x00000001
36
37 struct hostapd_rate_data {
38         int rate; /* rate in 100 kbps */
39         int flags; /* HOSTAPD_RATE_ flags */
40 };
41
42
43 /**
44  * struct hostapd_data - hostapd per-BSS data structure
45  */
46 struct hostapd_data {
47         struct hostapd_iface *iface;
48         struct hostapd_config *iconf;
49         struct hostapd_bss_config *conf;
50         int interface_added; /* virtual interface added for this BSS */
51
52         u8 own_addr[ETH_ALEN];
53
54         int num_sta; /* number of entries in sta_list */
55         struct sta_info *sta_list; /* STA info list head */
56 #define STA_HASH_SIZE 256
57 #define STA_HASH(sta) (sta[5])
58         struct sta_info *sta_hash[STA_HASH_SIZE];
59
60         /*
61          * Bitfield for indicating which AIDs are allocated. Only AID values
62          * 1-2007 are used and as such, the bit at index 0 corresponds to AID
63          * 1.
64          */
65 #define AID_WORDS ((2008 + 31) / 32)
66         u32 sta_aid[AID_WORDS];
67
68         const struct wpa_driver_ops *driver;
69         void *drv_priv;
70
71         void *msg_ctx; /* ctx for wpa_msg() calls */
72
73         struct radius_client_data *radius;
74         u32 acct_session_id_hi, acct_session_id_lo;
75
76         struct iapp_data *iapp;
77
78         struct hostapd_cached_radius_acl *acl_cache;
79         struct hostapd_acl_query_data *acl_queries;
80
81         struct wpa_authenticator *wpa_auth;
82         struct eapol_authenticator *eapol_auth;
83
84         struct rsn_preauth_interface *preauth_iface;
85         time_t michael_mic_failure;
86         int michael_mic_failures;
87         int tkip_countermeasures;
88
89         int ctrl_sock;
90         struct wpa_ctrl_dst *ctrl_dst;
91
92         void *ssl_ctx;
93         void *eap_sim_db_priv;
94         struct radius_server_data *radius_srv;
95
96         int parameter_set_count;
97
98 #ifdef CONFIG_FULL_DYNAMIC_VLAN
99         struct full_dynamic_vlan *full_dynamic_vlan;
100 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
101
102         struct l2_packet_data *l2;
103         struct wps_context *wps;
104
105 #ifdef CONFIG_WPS
106         u8 *wps_beacon_ie;
107         size_t wps_beacon_ie_len;
108         u8 *wps_probe_resp_ie;
109         size_t wps_probe_resp_ie_len;
110         unsigned int ap_pin_failures;
111         struct upnp_wps_device_sm *wps_upnp;
112 #endif /* CONFIG_WPS */
113
114         struct hostapd_probereq_cb *probereq_cb;
115         size_t num_probereq_cb;
116 };
117
118
119 /**
120  * struct hostapd_iface - hostapd per-interface data structure
121  */
122 struct hostapd_iface {
123         struct hapd_interfaces *interfaces;
124         void *owner;
125         char *config_fname;
126         struct hostapd_config *conf;
127
128         size_t num_bss;
129         struct hostapd_data **bss;
130
131         int num_ap; /* number of entries in ap_list */
132         struct ap_info *ap_list; /* AP info list head */
133         struct ap_info *ap_hash[STA_HASH_SIZE];
134         struct ap_info *ap_iter_list;
135
136         struct hostapd_hw_modes *hw_features;
137         int num_hw_features;
138         struct hostapd_hw_modes *current_mode;
139         /* Rates that are currently used (i.e., filtered copy of
140          * current_mode->channels */
141         int num_rates;
142         struct hostapd_rate_data *current_rates;
143
144         u16 hw_flags;
145
146         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
147          * in 802.11g BSS) */
148         int num_sta_non_erp;
149
150         /* Number of associated stations that do not support Short Slot Time */
151         int num_sta_no_short_slot_time;
152
153         /* Number of associated stations that do not support Short Preamble */
154         int num_sta_no_short_preamble;
155
156         int olbc; /* Overlapping Legacy BSS Condition */
157
158         /* Number of HT associated stations that do not support greenfield */
159         int num_sta_ht_no_gf;
160
161         /* Number of associated non-HT stations */
162         int num_sta_no_ht;
163
164         /* Number of HT associated stations 20 MHz */
165         int num_sta_ht_20mhz;
166
167         /* Overlapping BSS information */
168         int olbc_ht;
169
170         u16 ht_op_mode;
171         void (*scan_cb)(struct hostapd_iface *iface);
172 };
173
174 int hostapd_reload_config(struct hostapd_iface *iface);
175 struct hostapd_data *
176 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
177                        struct hostapd_config *conf,
178                        struct hostapd_bss_config *bss);
179 int hostapd_setup_interface(struct hostapd_iface *iface);
180 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
181 void hostapd_interface_deinit(struct hostapd_iface *iface);
182 int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
183 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
184
185 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
186                                int (*cb)(struct hostapd_iface *iface,
187                                          void *ctx), void *ctx);
188
189 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
190                                  void (*cb)(void *ctx, const u8 *sa,
191                                             const u8 *ie, size_t ie_len),
192                                  void *ctx);
193 int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
194                               int enabled);
195 int hostapd_sta_flags_to_drv(int flags);
196
197 int eap_server_register_methods(void);
198
199 #endif /* HOSTAPD_H */