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