Move hostapd configuration parser into separate file
[libeap.git] / hostapd / hostapd.h
1 /*
2  * hostapd / Initialization and configuration
3  * Copyright (c) 2002-2009, 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 #include "common/defs.h"
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 struct hostapd_data;
26 struct sta_info;
27
28 #ifdef CONFIG_FULL_DYNAMIC_VLAN
29 struct full_dynamic_vlan;
30 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
31
32 struct hostapd_probereq_cb {
33         void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
34         void *ctx;
35 };
36
37 #define HOSTAPD_RATE_BASIC 0x00000001
38
39 struct hostapd_rate_data {
40         int rate; /* rate in 100 kbps */
41         int flags; /* HOSTAPD_RATE_ flags */
42 };
43
44
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,
50                                size_t len);
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,
54                               int authorized);
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);
59 };
60
61 /**
62  * struct hostapd_data - hostapd per-BSS data structure
63  */
64 struct hostapd_data {
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 */
69
70         u8 own_addr[ETH_ALEN];
71
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];
77
78         /*
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
81          * 1.
82          */
83 #define AID_WORDS ((2008 + 31) / 32)
84         u32 sta_aid[AID_WORDS];
85
86         const struct wpa_driver_ops *driver;
87         void *drv_priv;
88         struct hostapd_driver_ops drv;
89
90         void *msg_ctx; /* ctx for wpa_msg() calls */
91
92         struct radius_client_data *radius;
93         u32 acct_session_id_hi, acct_session_id_lo;
94
95         struct iapp_data *iapp;
96
97         struct hostapd_cached_radius_acl *acl_cache;
98         struct hostapd_acl_query_data *acl_queries;
99
100         struct wpa_authenticator *wpa_auth;
101         struct eapol_authenticator *eapol_auth;
102
103         struct rsn_preauth_interface *preauth_iface;
104         time_t michael_mic_failure;
105         int michael_mic_failures;
106         int tkip_countermeasures;
107
108         int ctrl_sock;
109         struct wpa_ctrl_dst *ctrl_dst;
110
111         void *ssl_ctx;
112         void *eap_sim_db_priv;
113         struct radius_server_data *radius_srv;
114
115         int parameter_set_count;
116
117 #ifdef CONFIG_FULL_DYNAMIC_VLAN
118         struct full_dynamic_vlan *full_dynamic_vlan;
119 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
120
121         struct l2_packet_data *l2;
122         struct wps_context *wps;
123
124 #ifdef CONFIG_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 */
130
131         struct hostapd_probereq_cb *probereq_cb;
132         size_t num_probereq_cb;
133 };
134
135
136 /**
137  * struct hostapd_iface - hostapd per-interface data structure
138  */
139 struct hostapd_iface {
140         struct hapd_interfaces *interfaces;
141         void *owner;
142         struct hostapd_config * (*config_read_cb)(const char *config_fname);
143         char *config_fname;
144         struct hostapd_config *conf;
145
146         size_t num_bss;
147         struct hostapd_data **bss;
148
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;
153
154         struct hostapd_hw_modes *hw_features;
155         int num_hw_features;
156         struct hostapd_hw_modes *current_mode;
157         /* Rates that are currently used (i.e., filtered copy of
158          * current_mode->channels */
159         int num_rates;
160         struct hostapd_rate_data *current_rates;
161
162         u16 hw_flags;
163
164         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
165          * in 802.11g BSS) */
166         int num_sta_non_erp;
167
168         /* Number of associated stations that do not support Short Slot Time */
169         int num_sta_no_short_slot_time;
170
171         /* Number of associated stations that do not support Short Preamble */
172         int num_sta_no_short_preamble;
173
174         int olbc; /* Overlapping Legacy BSS Condition */
175
176         /* Number of HT associated stations that do not support greenfield */
177         int num_sta_ht_no_gf;
178
179         /* Number of associated non-HT stations */
180         int num_sta_no_ht;
181
182         /* Number of HT associated stations 20 MHz */
183         int num_sta_ht_20mhz;
184
185         /* Overlapping BSS information */
186         int olbc_ht;
187
188         u16 ht_op_mode;
189         void (*scan_cb)(struct hostapd_iface *iface);
190 };
191
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);
202
203 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
204                                int (*cb)(struct hostapd_iface *iface,
205                                          void *ctx), void *ctx);
206
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),
210                                  void *ctx);
211 int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
212                               int enabled);
213 int hostapd_sta_flags_to_drv(int flags);
214
215 int eap_server_register_methods(void);
216 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
217
218 #endif /* HOSTAPD_H */