hostapd: Add WDS (4-address frame) mode with per-station interfaces
[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 HOSTAPD_CONFIG_H
16 #define HOSTAPD_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         int wds_sta;
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         int ht_op_mode_fixed;
365         u16 ht_capab;
366         int ieee80211n;
367         int secondary_channel;
368 };
369
370
371 int hostapd_mac_comp(const void *a, const void *b);
372 int hostapd_mac_comp_empty(const void *a);
373 struct hostapd_config * hostapd_config_defaults(void);
374 struct hostapd_config * hostapd_config_read(const char *fname);
375 void hostapd_config_free(struct hostapd_config *conf);
376 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
377                           const u8 *addr, int *vlan_id);
378 int hostapd_rate_found(int *list, int rate);
379 int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
380                         struct hostapd_wep_keys *b);
381 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
382                            const u8 *addr, const u8 *prev_psk);
383 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
384 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
385                                         int vlan_id);
386 const struct hostapd_eap_user *
387 hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
388                      size_t identity_len, int phase2);
389
390 #endif /* HOSTAPD_CONFIG_H */