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