977f815fd56581136be8749f78d8b6069dd88cd0
[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
23 #ifndef IFNAMSIZ
24 #define IFNAMSIZ 16
25 #endif
26
27 typedef u8 macaddr[ETH_ALEN];
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_wme_ac_params {
134         int cwmin;
135         int cwmax;
136         int aifs;
137         int txopLimit; /* 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
170         struct hostapd_ssid ssid;
171
172         char *eap_req_id_text; /* optional displayable message sent with
173                                 * EAP Request-Identity */
174         size_t eap_req_id_text_len;
175         int eapol_key_index_workaround;
176
177         size_t default_wep_key_len;
178         int individual_wep_key_len;
179         int wep_rekeying_period;
180         int broadcast_key_idx_min, broadcast_key_idx_max;
181         int eap_reauth_period;
182
183         int ieee802_11f; /* use IEEE 802.11f (IAPP) */
184         char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
185                                         * frames */
186
187         u8 assoc_ap_addr[ETH_ALEN];
188         int assoc_ap; /* whether assoc_ap_addr is set */
189
190         enum {
191                 ACCEPT_UNLESS_DENIED = 0,
192                 DENY_UNLESS_ACCEPTED = 1,
193                 USE_EXTERNAL_RADIUS_AUTH = 2
194         } macaddr_acl;
195         macaddr *accept_mac;
196         int num_accept_mac;
197         macaddr *deny_mac;
198         int num_deny_mac;
199
200         int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
201                         * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
202
203         int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
204         int wpa_key_mgmt;
205 #ifdef CONFIG_IEEE80211W
206         enum {
207                 NO_IEEE80211W = 0,
208                 IEEE80211W_OPTIONAL = 1,
209                 IEEE80211W_REQUIRED = 2
210         } ieee80211w;
211 #endif /* CONFIG_IEEE80211W */
212         int wpa_pairwise;
213         int wpa_group;
214         int wpa_group_rekey;
215         int wpa_strict_rekey;
216         int wpa_gmk_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         char *eap_fast_a_id;
245         int eap_sim_aka_result_ind;
246         int tnc;
247
248         char *radius_server_clients;
249         int radius_server_auth_port;
250         int radius_server_ipv6;
251
252         char *test_socket; /* UNIX domain socket path for driver_test */
253
254         int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
255                                  * address instead of individual address
256                                  * (for driver_wired.c).
257                                  */
258
259         int ap_max_inactivity;
260         int ignore_broadcast_ssid;
261
262         int wme_enabled;
263
264         struct hostapd_vlan *vlan, *vlan_tail;
265
266         macaddr bssid;
267
268         /*
269          * Maximum listen interval that STAs can use when associating with this
270          * BSS. If a STA tries to use larger value, the association will be
271          * denied with status code 51.
272          */
273         u16 max_listen_interval;
274
275         int okc; /* Opportunistic Key Caching */
276
277 #ifdef CONFIG_IEEE80211N
278         int ieee80211n;
279         int ht_op_mode_fixed;
280         u16 ht_capab;
281 #endif /* CONFIG_IEEE80211N */
282 };
283
284
285 typedef enum {
286         HOSTAPD_MODE_IEEE80211B,
287         HOSTAPD_MODE_IEEE80211G,
288         HOSTAPD_MODE_IEEE80211A,
289         NUM_HOSTAPD_MODES
290 } hostapd_hw_mode;
291
292
293 /**
294  * struct hostapd_config - Per-radio interface configuration
295  */
296 struct hostapd_config {
297         struct hostapd_bss_config *bss, *last_bss;
298         struct hostapd_radius_servers *radius;
299         size_t num_bss;
300
301         u16 beacon_int;
302         int rts_threshold;
303         int fragm_threshold;
304         u8 send_probe_response;
305         u8 channel;
306         hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
307         enum {
308                 LONG_PREAMBLE = 0,
309                 SHORT_PREAMBLE = 1
310         } preamble;
311         enum {
312                 CTS_PROTECTION_AUTOMATIC = 0,
313                 CTS_PROTECTION_FORCE_ENABLED = 1,
314                 CTS_PROTECTION_FORCE_DISABLED = 2,
315                 CTS_PROTECTION_AUTOMATIC_NO_OLBC = 3,
316         } cts_protection_type;
317
318         int *supported_rates;
319         int *basic_rates;
320
321         const struct wpa_driver_ops *driver;
322
323         int passive_scan_interval; /* seconds, 0 = disabled */
324         int passive_scan_listen; /* usec */
325         int passive_scan_mode;
326         int ap_table_max_size;
327         int ap_table_expiration_time;
328
329         char country[3]; /* first two octets: country code as described in
330                           * ISO/IEC 3166-1. Third octet:
331                           * ' ' (ascii 32): all environments
332                           * 'O': Outdoor environemnt only
333                           * 'I': Indoor environment only
334                           */
335
336         int ieee80211d;
337         unsigned int ieee80211h; /* Enable/Disable 80211h */
338
339         struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
340
341         /*
342          * WME AC parameters, in same order as 802.1D, i.e.
343          * 0 = BE (best effort)
344          * 1 = BK (background)
345          * 2 = VI (video)
346          * 3 = VO (voice)
347          */
348         struct hostapd_wme_ac_params wme_ac_params[4];
349
350         enum {
351                 INTERNAL_BRIDGE_DO_NOT_CONTROL = -1,
352                 INTERNAL_BRIDGE_DISABLED = 0,
353                 INTERNAL_BRIDGE_ENABLED = 1
354         } bridge_packets;
355 };
356
357
358 int hostapd_mac_comp(const void *a, const void *b);
359 int hostapd_mac_comp_empty(const void *a);
360 struct hostapd_config * hostapd_config_read(const char *fname);
361 void hostapd_config_free(struct hostapd_config *conf);
362 int hostapd_maclist_found(macaddr *list, int num_entries, const u8 *addr);
363 int hostapd_rate_found(int *list, int rate);
364 int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
365                         struct hostapd_wep_keys *b);
366 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
367                            const u8 *addr, const u8 *prev_psk);
368 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
369 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
370                                         int vlan_id);
371 const struct hostapd_eap_user *
372 hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
373                      size_t identity_len, int phase2);
374
375 #endif /* CONFIG_H */