ab8f1ed8c5afb8c9744a6cd78e4543a193bf29fc
[libeap.git] / hostapd / hostapd.h
1 /*
2  * hostapd / Initialization and configuration
3  * Host AP kernel driver
4  * Copyright (c) 2002-2007, 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 "ap.h"
22
23 #ifndef ETH_ALEN
24 #define ETH_ALEN 6
25 #endif
26 #ifndef IFNAMSIZ
27 #define IFNAMSIZ 16
28 #endif
29 #ifndef ETH_P_ALL
30 #define ETH_P_ALL 0x0003
31 #endif
32 #ifndef ETH_P_PAE
33 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
34 #endif /* ETH_P_PAE */
35 #ifndef ETH_P_EAPOL
36 #define ETH_P_EAPOL ETH_P_PAE
37 #endif /* ETH_P_EAPOL */
38
39 #ifndef ETH_P_RRB
40 #define ETH_P_RRB 0x890D
41 #endif /* ETH_P_RRB */
42
43 #include "config.h"
44
45 #ifdef _MSC_VER
46 #pragma pack(push, 1)
47 #endif /* _MSC_VER */
48
49 #define MAX_VLAN_ID 4094
50
51 struct ieee8023_hdr {
52         u8 dest[6];
53         u8 src[6];
54         u16 ethertype;
55 } STRUCT_PACKED;
56
57
58 struct ieee80211_hdr {
59         le16 frame_control;
60         le16 duration_id;
61         u8 addr1[6];
62         u8 addr2[6];
63         u8 addr3[6];
64         le16 seq_ctrl;
65         /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
66          */
67 } STRUCT_PACKED;
68
69 #ifdef _MSC_VER
70 #pragma pack(pop)
71 #endif /* _MSC_VER */
72
73 #define IEEE80211_DA_FROMDS addr1
74 #define IEEE80211_BSSID_FROMDS addr2
75 #define IEEE80211_SA_FROMDS addr3
76
77 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
78
79 #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
80
81 /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
82  * frames that might be longer than normal default MTU and they are not
83  * fragmented */
84 #define HOSTAPD_MTU 2290
85
86 extern unsigned char rfc1042_header[6];
87
88 struct hostap_sta_driver_data {
89         unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
90         unsigned long current_tx_rate;
91         unsigned long inactive_msec;
92         unsigned long flags;
93         unsigned long num_ps_buf_frames;
94         unsigned long tx_retry_failed;
95         unsigned long tx_retry_count;
96         int last_rssi;
97         int last_ack_rssi;
98 };
99
100 struct wpa_driver_ops;
101 struct wpa_ctrl_dst;
102 struct radius_server_data;
103
104 #ifdef CONFIG_FULL_DYNAMIC_VLAN
105 struct full_dynamic_vlan;
106 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
107
108 /**
109  * struct hostapd_data - hostapd per-BSS data structure
110  */
111 struct hostapd_data {
112         struct hostapd_iface *iface;
113         struct hostapd_config *iconf;
114         struct hostapd_bss_config *conf;
115         int interface_added; /* virtual interface added for this BSS */
116
117         u8 own_addr[ETH_ALEN];
118
119         int num_sta; /* number of entries in sta_list */
120         struct sta_info *sta_list; /* STA info list head */
121         struct sta_info *sta_hash[STA_HASH_SIZE];
122
123         /* pointers to STA info; based on allocated AID or NULL if AID free
124          * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
125          * and so on
126          */
127         struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
128
129         const struct wpa_driver_ops *driver;
130         void *drv_priv;
131
132         u8 *default_wep_key;
133         u8 default_wep_key_idx;
134
135         struct radius_client_data *radius;
136         int radius_client_reconfigured;
137         u32 acct_session_id_hi, acct_session_id_lo;
138
139         struct iapp_data *iapp;
140
141         enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
142                ASSOCIATED } assoc_ap_state;
143         char assoc_ap_ssid[33];
144         int assoc_ap_ssid_len;
145         u16 assoc_ap_aid;
146
147         struct hostapd_cached_radius_acl *acl_cache;
148         struct hostapd_acl_query_data *acl_queries;
149
150         struct wpa_authenticator *wpa_auth;
151         struct eapol_authenticator *eapol_auth;
152
153         struct rsn_preauth_interface *preauth_iface;
154         time_t michael_mic_failure;
155         int michael_mic_failures;
156         int tkip_countermeasures;
157
158         int ctrl_sock;
159         struct wpa_ctrl_dst *ctrl_dst;
160
161         void *ssl_ctx;
162         void *eap_sim_db_priv;
163         struct radius_server_data *radius_srv;
164
165         int parameter_set_count;
166
167 #ifdef CONFIG_FULL_DYNAMIC_VLAN
168         struct full_dynamic_vlan *full_dynamic_vlan;
169 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
170
171         struct l2_packet_data *l2;
172 };
173
174
175 /**
176  * hostapd_iface_cb - Generic callback type for per-iface asynchronous requests
177  * @iface: the interface the event occured on.
178  * @status: 0 if the request succeeded; -1 if the request failed.
179  */
180 typedef void (*hostapd_iface_cb)(struct hostapd_iface *iface, int status);
181
182
183 struct hostapd_config_change;
184
185 /**
186  * struct hostapd_iface - hostapd per-interface data structure
187  */
188 struct hostapd_iface {
189         char *config_fname;
190         struct hostapd_config *conf;
191
192         hostapd_iface_cb setup_cb;
193
194         size_t num_bss;
195         struct hostapd_data **bss;
196
197         int num_ap; /* number of entries in ap_list */
198         struct ap_info *ap_list; /* AP info list head */
199         struct ap_info *ap_hash[STA_HASH_SIZE];
200         struct ap_info *ap_iter_list;
201
202         struct hostapd_hw_modes *hw_features;
203         int num_hw_features;
204         struct hostapd_hw_modes *current_mode;
205         /* Rates that are currently used (i.e., filtered copy of
206          * current_mode->channels */
207         int num_rates;
208         struct hostapd_rate_data *current_rates;
209         hostapd_iface_cb hw_mode_sel_cb;
210
211         u16 hw_flags;
212
213         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
214          * in 802.11g BSS) */
215         int num_sta_non_erp;
216
217         /* Number of associated stations that do not support Short Slot Time */
218         int num_sta_no_short_slot_time;
219
220         /* Number of associated stations that do not support Short Preamble */
221         int num_sta_no_short_preamble;
222
223         int olbc; /* Overlapping Legacy BSS Condition */
224
225         /* Number of HT associated stations that do not support greenfield */
226         int num_sta_ht_no_gf;
227
228         /* Number of associated non-HT stations */
229         int num_sta_no_ht;
230
231         /* Number of HT associated stations 20 MHz */
232         int num_sta_ht_20mhz;
233
234         /* Overlapping BSS information */
235         int olbc_ht;
236
237         int dfs_enable;
238         u8 pwr_const;
239         unsigned int tx_power;
240         unsigned int sta_max_power;
241
242         unsigned int channel_switch;
243
244 #ifdef CONFIG_IEEE80211N
245         u16 ht_op_mode;
246 #endif /* CONFIG_IEEE80211N */
247 };
248
249 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
250                            int reassoc);
251
252 #endif /* HOSTAPD_H */