blob: 13d5549c7ab62fbc1c23338875885b9287ad3495 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / Configuration definitions and helpers functions
Dmitry Shmidt04949592012-07-19 12:16:46 -07003 * Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07004 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef HOSTAPD_CONFIG_H
10#define HOSTAPD_CONFIG_H
11
12#include "common/defs.h"
13#include "ip_addr.h"
14#include "common/wpa_common.h"
15#include "wps/wps.h"
16
17#define MAX_STA_COUNT 2007
18#define MAX_VLAN_ID 4094
19
20typedef u8 macaddr[ETH_ALEN];
21
22struct mac_acl_entry {
23 macaddr addr;
24 int vlan_id;
25};
26
27struct hostapd_radius_servers;
28struct ft_remote_r0kh;
29struct ft_remote_r1kh;
30
31#define HOSTAPD_MAX_SSID_LEN 32
32
33#define NUM_WEP_KEYS 4
34struct hostapd_wep_keys {
35 u8 idx;
36 u8 *key[NUM_WEP_KEYS];
37 size_t len[NUM_WEP_KEYS];
38 int keys_set;
39 size_t default_len; /* key length used for dynamic key generation */
40};
41
42typedef enum hostap_security_policy {
43 SECURITY_PLAINTEXT = 0,
44 SECURITY_STATIC_WEP = 1,
45 SECURITY_IEEE_802_1X = 2,
46 SECURITY_WPA_PSK = 3,
47 SECURITY_WPA = 4
48} secpolicy;
49
50struct hostapd_ssid {
51 char ssid[HOSTAPD_MAX_SSID_LEN + 1];
52 size_t ssid_len;
53 int ssid_set;
54
55 char vlan[IFNAMSIZ + 1];
56 secpolicy security_policy;
57
58 struct hostapd_wpa_psk *wpa_psk;
59 char *wpa_passphrase;
60 char *wpa_psk_file;
61
62 struct hostapd_wep_keys wep;
63
64#define DYNAMIC_VLAN_DISABLED 0
65#define DYNAMIC_VLAN_OPTIONAL 1
66#define DYNAMIC_VLAN_REQUIRED 2
67 int dynamic_vlan;
68#ifdef CONFIG_FULL_DYNAMIC_VLAN
69 char *vlan_tagged_interface;
70#endif /* CONFIG_FULL_DYNAMIC_VLAN */
71 struct hostapd_wep_keys **dyn_vlan_keys;
72 size_t max_dyn_vlan_keys;
73};
74
75
76#define VLAN_ID_WILDCARD -1
77
78struct hostapd_vlan {
79 struct hostapd_vlan *next;
80 int vlan_id; /* VLAN ID or -1 (VLAN_ID_WILDCARD) for wildcard entry */
81 char ifname[IFNAMSIZ + 1];
82 int dynamic_vlan;
83#ifdef CONFIG_FULL_DYNAMIC_VLAN
84
85#define DVLAN_CLEAN_BR 0x1
86#define DVLAN_CLEAN_VLAN 0x2
87#define DVLAN_CLEAN_VLAN_PORT 0x4
88#define DVLAN_CLEAN_WLAN_PORT 0x8
89 int clean;
90#endif /* CONFIG_FULL_DYNAMIC_VLAN */
91};
92
93#define PMK_LEN 32
94struct hostapd_wpa_psk {
95 struct hostapd_wpa_psk *next;
96 int group;
97 u8 psk[PMK_LEN];
98 u8 addr[ETH_ALEN];
99};
100
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700101struct hostapd_eap_user {
102 struct hostapd_eap_user *next;
103 u8 *identity;
104 size_t identity_len;
105 struct {
106 int vendor;
107 u32 method;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800108 } methods[EAP_MAX_METHODS];
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700109 u8 *password;
110 size_t password_len;
111 int phase2;
112 int force_version;
113 unsigned int wildcard_prefix:1;
114 unsigned int password_hash:1; /* whether password is hashed with
115 * nt_password_hash() */
116 int ttls_auth; /* EAP_TTLS_AUTH_* bitfield */
117};
118
Dmitry Shmidt04949592012-07-19 12:16:46 -0700119struct hostapd_radius_attr {
120 u8 type;
121 struct wpabuf *val;
122 struct hostapd_radius_attr *next;
123};
124
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700125
126#define NUM_TX_QUEUES 4
127
128struct 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};
134
135struct hostapd_wmm_ac_params {
136 int cwmin;
137 int cwmax;
138 int aifs;
139 int txop_limit; /* in units of 32us */
140 int admission_control_mandatory;
141};
142
143
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800144#define MAX_ROAMING_CONSORTIUM_LEN 15
145
146struct hostapd_roaming_consortium {
147 u8 len;
148 u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
149};
150
Dmitry Shmidt04949592012-07-19 12:16:46 -0700151struct hostapd_venue_name {
152 u8 lang[3];
153 u8 name_len;
154 u8 name[252];
155};
156
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157/**
158 * struct hostapd_bss_config - Per-BSS configuration
159 */
160struct hostapd_bss_config {
161 char iface[IFNAMSIZ + 1];
162 char bridge[IFNAMSIZ + 1];
163 char wds_bridge[IFNAMSIZ + 1];
164
165 enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
166
167 unsigned int logger_syslog; /* module bitfield */
168 unsigned int logger_stdout; /* module bitfield */
169
170 char *dump_log_name; /* file name for state dump (SIGUSR1) */
171
172 int max_num_sta; /* maximum number of STAs in station table */
173
174 int dtim_period;
175
176 int ieee802_1x; /* use IEEE 802.1X */
177 int eapol_version;
178 int eap_server; /* Use internal EAP server instead of external
179 * RADIUS server */
180 struct hostapd_eap_user *eap_user;
181 char *eap_sim_db;
182 struct hostapd_ip_addr own_ip_addr;
183 char *nas_identifier;
184 struct hostapd_radius_servers *radius;
185 int acct_interim_interval;
Dmitry Shmidt04949592012-07-19 12:16:46 -0700186 int radius_request_cui;
187 struct hostapd_radius_attr *radius_auth_req_attr;
188 struct hostapd_radius_attr *radius_acct_req_attr;
189 int radius_das_port;
190 unsigned int radius_das_time_window;
191 int radius_das_require_event_timestamp;
192 struct hostapd_ip_addr radius_das_client_addr;
193 u8 *radius_das_shared_secret;
194 size_t radius_das_shared_secret_len;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700195
196 struct hostapd_ssid ssid;
197
198 char *eap_req_id_text; /* optional displayable message sent with
199 * EAP Request-Identity */
200 size_t eap_req_id_text_len;
201 int eapol_key_index_workaround;
202
203 size_t default_wep_key_len;
204 int individual_wep_key_len;
205 int wep_rekeying_period;
206 int broadcast_key_idx_min, broadcast_key_idx_max;
207 int eap_reauth_period;
208
209 int ieee802_11f; /* use IEEE 802.11f (IAPP) */
210 char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
211 * frames */
212
213 enum {
214 ACCEPT_UNLESS_DENIED = 0,
215 DENY_UNLESS_ACCEPTED = 1,
216 USE_EXTERNAL_RADIUS_AUTH = 2
217 } macaddr_acl;
218 struct mac_acl_entry *accept_mac;
219 int num_accept_mac;
220 struct mac_acl_entry *deny_mac;
221 int num_deny_mac;
222 int wds_sta;
223 int isolate;
224
225 int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
226 * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
227
228 int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
229 int wpa_key_mgmt;
230#ifdef CONFIG_IEEE80211W
231 enum mfp_options ieee80211w;
232 /* dot11AssociationSAQueryMaximumTimeout (in TUs) */
233 unsigned int assoc_sa_query_max_timeout;
234 /* dot11AssociationSAQueryRetryTimeout (in TUs) */
235 int assoc_sa_query_retry_timeout;
236#endif /* CONFIG_IEEE80211W */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800237 enum {
238 PSK_RADIUS_IGNORED = 0,
239 PSK_RADIUS_ACCEPTED = 1,
240 PSK_RADIUS_REQUIRED = 2
241 } wpa_psk_radius;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700242 int wpa_pairwise;
243 int wpa_group;
244 int wpa_group_rekey;
245 int wpa_strict_rekey;
246 int wpa_gmk_rekey;
247 int wpa_ptk_rekey;
248 int rsn_pairwise;
249 int rsn_preauth;
250 char *rsn_preauth_interfaces;
251 int peerkey;
252
253#ifdef CONFIG_IEEE80211R
254 /* IEEE 802.11r - Fast BSS Transition */
255 u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
256 u8 r1_key_holder[FT_R1KH_ID_LEN];
257 u32 r0_key_lifetime;
258 u32 reassociation_deadline;
259 struct ft_remote_r0kh *r0kh_list;
260 struct ft_remote_r1kh *r1kh_list;
261 int pmk_r1_push;
262 int ft_over_ds;
263#endif /* CONFIG_IEEE80211R */
264
265 char *ctrl_interface; /* directory for UNIX domain sockets */
266#ifndef CONFIG_NATIVE_WINDOWS
267 gid_t ctrl_interface_gid;
268#endif /* CONFIG_NATIVE_WINDOWS */
269 int ctrl_interface_gid_set;
270
271 char *ca_cert;
272 char *server_cert;
273 char *private_key;
274 char *private_key_passwd;
275 int check_crl;
276 char *dh_file;
277 u8 *pac_opaque_encr_key;
278 u8 *eap_fast_a_id;
279 size_t eap_fast_a_id_len;
280 char *eap_fast_a_id_info;
281 int eap_fast_prov;
282 int pac_key_lifetime;
283 int pac_key_refresh_time;
284 int eap_sim_aka_result_ind;
285 int tnc;
286 int fragment_size;
287 u16 pwd_group;
288
289 char *radius_server_clients;
290 int radius_server_auth_port;
291 int radius_server_ipv6;
292
293 char *test_socket; /* UNIX domain socket path for driver_test */
294
295 int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
296 * address instead of individual address
297 * (for driver_wired.c).
298 */
299
300 int ap_max_inactivity;
301 int ignore_broadcast_ssid;
302
303 int wmm_enabled;
304 int wmm_uapsd;
305
306 struct hostapd_vlan *vlan, *vlan_tail;
307
308 macaddr bssid;
309
310 /*
311 * Maximum listen interval that STAs can use when associating with this
312 * BSS. If a STA tries to use larger value, the association will be
313 * denied with status code 51.
314 */
315 u16 max_listen_interval;
316
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700317 int disable_pmksa_caching;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700318 int okc; /* Opportunistic Key Caching */
319
320 int wps_state;
321#ifdef CONFIG_WPS
322 int ap_setup_locked;
323 u8 uuid[16];
324 char *wps_pin_requests;
325 char *device_name;
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800326#ifdef ANDROID_P2P
327 char *prioritize;
328#endif
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700329 char *manufacturer;
330 char *model_name;
331 char *model_number;
332 char *serial_number;
333 u8 device_type[WPS_DEV_TYPE_LEN];
334 char *config_methods;
335 u8 os_version[4];
336 char *ap_pin;
337 int skip_cred_build;
338 u8 *extra_cred;
339 size_t extra_cred_len;
340 int wps_cred_processing;
341 u8 *ap_settings;
342 size_t ap_settings_len;
343 char *upnp_iface;
344 char *friendly_name;
345 char *manufacturer_url;
346 char *model_description;
347 char *model_url;
348 char *upc;
349 struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
Dmitry Shmidt04949592012-07-19 12:16:46 -0700350 int wps_nfc_dev_pw_id;
351 struct wpabuf *wps_nfc_dh_pubkey;
352 struct wpabuf *wps_nfc_dh_privkey;
353 struct wpabuf *wps_nfc_dev_pw;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700354#endif /* CONFIG_WPS */
Jouni Malinen87fd2792011-05-16 18:35:42 +0300355 int pbc_in_m1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700356
357#define P2P_ENABLED BIT(0)
358#define P2P_GROUP_OWNER BIT(1)
359#define P2P_GROUP_FORMATION BIT(2)
360#define P2P_MANAGE BIT(3)
361#define P2P_ALLOW_CROSS_CONNECTION BIT(4)
362 int p2p;
363
364 int disassoc_low_ack;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800365 int skip_inactivity_poll;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700366
367#define TDLS_PROHIBIT BIT(0)
368#define TDLS_PROHIBIT_CHAN_SWITCH BIT(1)
369 int tdls;
370 int disable_11n;
Dmitry Shmidt04949592012-07-19 12:16:46 -0700371 int disable_11ac;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800372
373 /* IEEE 802.11v */
374 int time_advertisement;
375 char *time_zone;
376
377 /* IEEE 802.11u - Interworking */
378 int interworking;
379 int access_network_type;
380 int internet;
381 int asra;
382 int esr;
383 int uesa;
384 int venue_info_set;
385 u8 venue_group;
386 u8 venue_type;
387 u8 hessid[ETH_ALEN];
388
389 /* IEEE 802.11u - Roaming Consortium list */
390 unsigned int roaming_consortium_count;
391 struct hostapd_roaming_consortium *roaming_consortium;
392
Dmitry Shmidt04949592012-07-19 12:16:46 -0700393 /* IEEE 802.11u - Venue Name duples */
394 unsigned int venue_name_count;
395 struct hostapd_venue_name *venue_name;
396
397 u16 gas_comeback_delay;
398 int gas_frag_limit;
399
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800400 u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
401
402#ifdef CONFIG_RADIUS_TEST
403 char *dump_msk_file;
404#endif /* CONFIG_RADIUS_TEST */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700405};
406
407
408/**
409 * struct hostapd_config - Per-radio interface configuration
410 */
411struct hostapd_config {
412 struct hostapd_bss_config *bss, *last_bss;
413 size_t num_bss;
414
415 u16 beacon_int;
416 int rts_threshold;
417 int fragm_threshold;
418 u8 send_probe_response;
419 u8 channel;
420 enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
421 enum {
422 LONG_PREAMBLE = 0,
423 SHORT_PREAMBLE = 1
424 } preamble;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700425
426 int *supported_rates;
427 int *basic_rates;
428
429 const struct wpa_driver_ops *driver;
430
431 int ap_table_max_size;
432 int ap_table_expiration_time;
433
434 char country[3]; /* first two octets: country code as described in
435 * ISO/IEC 3166-1. Third octet:
436 * ' ' (ascii 32): all environments
437 * 'O': Outdoor environemnt only
438 * 'I': Indoor environment only
439 */
440
441 int ieee80211d;
442
443 struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
444
445 /*
446 * WMM AC parameters, in same order as 802.1D, i.e.
447 * 0 = BE (best effort)
448 * 1 = BK (background)
449 * 2 = VI (video)
450 * 3 = VO (voice)
451 */
452 struct hostapd_wmm_ac_params wmm_ac_params[4];
453
454 int ht_op_mode_fixed;
455 u16 ht_capab;
456 int ieee80211n;
457 int secondary_channel;
458 int require_ht;
Dmitry Shmidt04949592012-07-19 12:16:46 -0700459 u32 vht_capab;
460 int ieee80211ac;
461 u8 vht_oper_chwidth;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700462};
463
464
465int hostapd_mac_comp(const void *a, const void *b);
466int hostapd_mac_comp_empty(const void *a);
467struct hostapd_config * hostapd_config_defaults(void);
468void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);
469void hostapd_config_free(struct hostapd_config *conf);
470int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
471 const u8 *addr, int *vlan_id);
472int hostapd_rate_found(int *list, int rate);
473int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
474 struct hostapd_wep_keys *b);
475const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
476 const u8 *addr, const u8 *prev_psk);
477int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
478const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
479 int vlan_id);
480const struct hostapd_eap_user *
481hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
482 size_t identity_len, int phase2);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700483struct hostapd_radius_attr *
484hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700485
486#endif /* HOSTAPD_CONFIG_H */