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