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