Add preliminary IEEE 802.11n support into hostapd
[wpasupplicant] / hostapd / config.h
1 /*
2  * hostapd / Configuration file
3  * Copyright (c) 2003-2007, 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 CONFIG_H
16 #define CONFIG_H
17
18 #include "defs.h"
19 #include "ip_addr.h"
20 #include "wpa_common.h"
21 #ifdef CONFIG_IEEE80211N
22 #include "ieee802_11_defs.h"
23 #endif /* CONFIG_IEEE80211N */
24
25 #ifndef IFNAMSIZ
26 #define IFNAMSIZ 16
27 #endif
28
29 typedef u8 macaddr[ETH_ALEN];
30
31 struct hostapd_radius_servers;
32 struct ft_remote_r0kh;
33 struct ft_remote_r1kh;
34
35 #define HOSTAPD_MAX_SSID_LEN 32
36
37 #define NUM_WEP_KEYS 4
38 struct hostapd_wep_keys {
39         u8 idx;
40         u8 *key[NUM_WEP_KEYS];
41         size_t len[NUM_WEP_KEYS];
42         int keys_set;
43         size_t default_len; /* key length used for dynamic key generation */
44 };
45
46 typedef enum hostap_security_policy {
47         SECURITY_PLAINTEXT = 0,
48         SECURITY_STATIC_WEP = 1,
49         SECURITY_IEEE_802_1X = 2,
50         SECURITY_WPA_PSK = 3,
51         SECURITY_WPA = 4
52 } secpolicy;
53
54 struct hostapd_ssid {
55         char ssid[HOSTAPD_MAX_SSID_LEN + 1];
56         size_t ssid_len;
57         int ssid_set;
58
59         char vlan[IFNAMSIZ + 1];
60         secpolicy security_policy;
61
62         struct hostapd_wpa_psk *wpa_psk;
63         char *wpa_passphrase;
64         char *wpa_psk_file;
65
66         struct hostapd_wep_keys wep;
67
68 #define DYNAMIC_VLAN_DISABLED 0
69 #define DYNAMIC_VLAN_OPTIONAL 1
70 #define DYNAMIC_VLAN_REQUIRED 2
71         int dynamic_vlan;
72 #ifdef CONFIG_FULL_DYNAMIC_VLAN
73         char *vlan_tagged_interface;
74 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
75         struct hostapd_wep_keys **dyn_vlan_keys;
76         size_t max_dyn_vlan_keys;
77 };
78
79
80 #define VLAN_ID_WILDCARD -1
81
82 struct hostapd_vlan {
83         struct hostapd_vlan *next;
84         int vlan_id; /* VLAN ID or -1 (VLAN_ID_WILDCARD) for wildcard entry */
85         char ifname[IFNAMSIZ + 1];
86         int dynamic_vlan;
87 #ifdef CONFIG_FULL_DYNAMIC_VLAN
88
89 #define DVLAN_CLEAN_BR  0x1
90 #define DVLAN_CLEAN_VLAN        0x2
91 #define DVLAN_CLEAN_VLAN_PORT   0x4
92 #define DVLAN_CLEAN_WLAN_PORT   0x8
93         int clean;
94 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
95 };
96
97 #define PMK_LEN 32
98 struct hostapd_wpa_psk {
99         struct hostapd_wpa_psk *next;
100         int group;
101         u8 psk[PMK_LEN];
102         u8 addr[ETH_ALEN];
103 };
104
105 #define EAP_USER_MAX_METHODS 8
106 struct hostapd_eap_user {
107         struct hostapd_eap_user *next;
108         u8 *identity;
109         size_t identity_len;
110         struct {
111                 int vendor;
112                 u32 method;
113         } methods[EAP_USER_MAX_METHODS];
114         u8 *password;
115         size_t password_len;
116         int phase2;
117         int force_version;
118         unsigned int wildcard_prefix:1;
119         unsigned int password_hash:1; /* whether password is hashed with
120                                        * nt_password_hash() */
121         int ttls_auth; /* EAP_TTLS_AUTH_* bitfield */
122 };
123
124
125 #define NUM_TX_QUEUES 8
126
127 struct hostapd_tx_queue_params {
128         int aifs;
129         int cwmin;
130         int cwmax;
131         int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
132         int configured;
133 };
134
135 struct hostapd_wme_ac_params {
136         int cwmin;
137         int cwmax;
138         int aifs;
139         int txopLimit; /* in units of 32us */
140         int admission_control_mandatory;
141 };
142
143
144 /**
145  * struct hostapd_bss_config - Per-BSS configuration
146  */
147 struct hostapd_bss_config {
148         char iface[IFNAMSIZ + 1];
149         char bridge[IFNAMSIZ + 1];
150
151         enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
152
153         unsigned int logger_syslog; /* module bitfield */
154         unsigned int logger_stdout; /* module bitfield */
155
156         char *dump_log_name; /* file name for state dump (SIGUSR1) */
157
158         int max_num_sta; /* maximum number of STAs in station table */
159
160         int dtim_period;
161
162         int ieee802_1x; /* use IEEE 802.1X */
163         int eapol_version;
164         int eap_server; /* Use internal EAP server instead of external
165                          * RADIUS server */
166         struct hostapd_eap_user *eap_user;
167         char *eap_sim_db;
168         struct hostapd_ip_addr own_ip_addr;
169         char *nas_identifier;
170         struct hostapd_radius_servers *radius;
171
172         struct hostapd_ssid ssid;
173
174         char *eap_req_id_text; /* optional displayable message sent with
175                                 * EAP Request-Identity */
176         size_t eap_req_id_text_len;
177         int eapol_key_index_workaround;
178
179         size_t default_wep_key_len;
180         int individual_wep_key_len;
181         int wep_rekeying_period;
182         int broadcast_key_idx_min, broadcast_key_idx_max;
183         int eap_reauth_period;
184
185         int ieee802_11f; /* use IEEE 802.11f (IAPP) */
186         char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
187                                         * frames */
188
189         u8 assoc_ap_addr[ETH_ALEN];
190         int assoc_ap; /* whether assoc_ap_addr is set */
191
192         enum {
193                 ACCEPT_UNLESS_DENIED = 0,
194                 DENY_UNLESS_ACCEPTED = 1,
195                 USE_EXTERNAL_RADIUS_AUTH = 2
196         } macaddr_acl;
197         macaddr *accept_mac;
198         int num_accept_mac;
199         macaddr *deny_mac;
200         int num_deny_mac;
201
202         int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
203                         * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
204
205         int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
206         int wpa_key_mgmt;
207 #ifdef CONFIG_IEEE80211W
208         enum {
209                 NO_IEEE80211W = 0,
210                 IEEE80211W_OPTIONAL = 1,
211                 IEEE80211W_REQUIRED = 2
212         } ieee80211w;
213 #endif /* CONFIG_IEEE80211W */
214         int wpa_pairwise;
215         int wpa_group;
216         int wpa_group_rekey;
217         int wpa_strict_rekey;
218         int wpa_gmk_rekey;
219         int rsn_pairwise;
220         int rsn_preauth;
221         char *rsn_preauth_interfaces;
222         int peerkey;
223
224 #ifdef CONFIG_IEEE80211R
225         /* IEEE 802.11r - Fast BSS Transition */
226         u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
227         u8 r1_key_holder[FT_R1KH_ID_LEN];
228         u32 r0_key_lifetime;
229         u32 reassociation_deadline;
230         struct ft_remote_r0kh *r0kh_list;
231         struct ft_remote_r1kh *r1kh_list;
232         int pmk_r1_push;
233 #endif /* CONFIG_IEEE80211R */
234
235         char *ctrl_interface; /* directory for UNIX domain sockets */
236         gid_t ctrl_interface_gid;
237         int ctrl_interface_gid_set;
238
239         char *ca_cert;
240         char *server_cert;
241         char *private_key;
242         char *private_key_passwd;
243         int check_crl;
244         char *dh_file;
245         u8 *pac_opaque_encr_key;
246         char *eap_fast_a_id;
247         int eap_sim_aka_result_ind;
248         int tnc;
249
250         char *radius_server_clients;
251         int radius_server_auth_port;
252         int radius_server_ipv6;
253
254         char *test_socket; /* UNIX domain socket path for driver_test */
255
256         int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
257                                  * address instead of individual address
258                                  * (for driver_wired.c).
259                                  */
260
261         int ap_max_inactivity;
262         int ignore_broadcast_ssid;
263
264         int wme_enabled;
265
266         struct hostapd_vlan *vlan, *vlan_tail;
267
268         macaddr bssid;
269
270         /*
271          * Maximum listen interval that STAs can use when associating with this
272          * BSS. If a STA tries to use larger value, the association will be
273          * denied with status code 51.
274          */
275         u16 max_listen_interval;
276
277         int okc; /* Opportunistic Key Caching */
278
279 #ifdef CONFIG_IEEE80211N
280         int ieee80211n;
281         /* TODO: these structures should not really be used here; move to
282          * struct hostapd_data or struct hostapd_iface and just include the
283          * needed values here for generating IEs elsewhere */
284         struct ht_cap_ie ht_capabilities;
285         struct ht_operation_ie ht_operation;
286         int ht_op_mode_fixed;
287 #endif /* CONFIG_IEEE80211N */
288 };
289
290
291 typedef enum {
292         HOSTAPD_MODE_IEEE80211B,
293         HOSTAPD_MODE_IEEE80211G,
294         HOSTAPD_MODE_IEEE80211A,
295         NUM_HOSTAPD_MODES
296 } hostapd_hw_mode;
297
298
299 /**
300  * struct hostapd_config - Per-radio interface configuration
301  */
302 struct hostapd_config {
303         struct hostapd_bss_config *bss, *last_bss;
304         struct hostapd_radius_servers *radius;
305         size_t num_bss;
306
307         u16 beacon_int;
308         int rts_threshold;
309         int fragm_threshold;
310         u8 send_probe_response;
311         u8 channel;
312         hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
313         enum {
314                 LONG_PREAMBLE = 0,
315                 SHORT_PREAMBLE = 1
316         } preamble;
317         enum {
318                 CTS_PROTECTION_AUTOMATIC = 0,
319                 CTS_PROTECTION_FORCE_ENABLED = 1,
320                 CTS_PROTECTION_FORCE_DISABLED = 2,
321                 CTS_PROTECTION_AUTOMATIC_NO_OLBC = 3,
322         } cts_protection_type;
323
324         int *supported_rates;
325         int *basic_rates;
326
327         const struct wpa_driver_ops *driver;
328
329         int passive_scan_interval; /* seconds, 0 = disabled */
330         int passive_scan_listen; /* usec */
331         int passive_scan_mode;
332         int ap_table_max_size;
333         int ap_table_expiration_time;
334
335         char country[3]; /* first two octets: country code as described in
336                           * ISO/IEC 3166-1. Third octet:
337                           * ' ' (ascii 32): all environments
338                           * 'O': Outdoor environemnt only
339                           * 'I': Indoor environment only
340                           */
341
342         int ieee80211d;
343         unsigned int ieee80211h; /* Enable/Disable 80211h */
344
345         struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
346
347         /*
348          * WME AC parameters, in same order as 802.1D, i.e.
349          * 0 = BE (best effort)
350          * 1 = BK (background)
351          * 2 = VI (video)
352          * 3 = VO (voice)
353          */
354         struct hostapd_wme_ac_params wme_ac_params[4];
355
356         enum {
357                 INTERNAL_BRIDGE_DO_NOT_CONTROL = -1,
358                 INTERNAL_BRIDGE_DISABLED = 0,
359                 INTERNAL_BRIDGE_ENABLED = 1
360         } bridge_packets;
361 };
362
363
364 int hostapd_mac_comp(const void *a, const void *b);
365 int hostapd_mac_comp_empty(const void *a);
366 struct hostapd_config * hostapd_config_read(const char *fname);
367 void hostapd_config_free(struct hostapd_config *conf);
368 int hostapd_maclist_found(macaddr *list, int num_entries, const u8 *addr);
369 int hostapd_rate_found(int *list, int rate);
370 int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
371                         struct hostapd_wep_keys *b);
372 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
373                            const u8 *addr, const u8 *prev_psk);
374 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
375 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
376                                         int vlan_id);
377 const struct hostapd_eap_user *
378 hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
379                      size_t identity_len, int phase2);
380
381 #endif /* CONFIG_H */