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