ap_config.h revision c5ec7f57ead87efa365800228aa0b09a12d9e6c4
1/*
2 * hostapd / Configuration definitions and helpers functions
3 * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
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
101struct 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;
108	} methods[EAP_MAX_METHODS];
109	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
119
120#define NUM_TX_QUEUES 4
121
122struct hostapd_tx_queue_params {
123	int aifs;
124	int cwmin;
125	int cwmax;
126	int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
127};
128
129struct hostapd_wmm_ac_params {
130	int cwmin;
131	int cwmax;
132	int aifs;
133	int txop_limit; /* in units of 32us */
134	int admission_control_mandatory;
135};
136
137
138#define MAX_ROAMING_CONSORTIUM_LEN 15
139
140struct hostapd_roaming_consortium {
141	u8 len;
142	u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
143};
144
145/**
146 * struct hostapd_bss_config - Per-BSS configuration
147 */
148struct hostapd_bss_config {
149	char iface[IFNAMSIZ + 1];
150	char bridge[IFNAMSIZ + 1];
151	char wds_bridge[IFNAMSIZ + 1];
152
153	enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
154
155	unsigned int logger_syslog; /* module bitfield */
156	unsigned int logger_stdout; /* module bitfield */
157
158	char *dump_log_name; /* file name for state dump (SIGUSR1) */
159
160	int max_num_sta; /* maximum number of STAs in station table */
161
162	int dtim_period;
163
164	int ieee802_1x; /* use IEEE 802.1X */
165	int eapol_version;
166	int eap_server; /* Use internal EAP server instead of external
167			 * RADIUS server */
168	struct hostapd_eap_user *eap_user;
169	char *eap_sim_db;
170	struct hostapd_ip_addr own_ip_addr;
171	char *nas_identifier;
172	struct hostapd_radius_servers *radius;
173	int acct_interim_interval;
174
175	struct hostapd_ssid ssid;
176
177	char *eap_req_id_text; /* optional displayable message sent with
178				* EAP Request-Identity */
179	size_t eap_req_id_text_len;
180	int eapol_key_index_workaround;
181
182	size_t default_wep_key_len;
183	int individual_wep_key_len;
184	int wep_rekeying_period;
185	int broadcast_key_idx_min, broadcast_key_idx_max;
186	int eap_reauth_period;
187
188	int ieee802_11f; /* use IEEE 802.11f (IAPP) */
189	char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
190					* frames */
191
192	enum {
193		ACCEPT_UNLESS_DENIED = 0,
194		DENY_UNLESS_ACCEPTED = 1,
195		USE_EXTERNAL_RADIUS_AUTH = 2
196	} macaddr_acl;
197	struct mac_acl_entry *accept_mac;
198	int num_accept_mac;
199	struct mac_acl_entry *deny_mac;
200	int num_deny_mac;
201	int wds_sta;
202	int isolate;
203
204	int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
205			* algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
206
207	int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
208	int wpa_key_mgmt;
209#ifdef CONFIG_IEEE80211W
210	enum mfp_options ieee80211w;
211	/* dot11AssociationSAQueryMaximumTimeout (in TUs) */
212	unsigned int assoc_sa_query_max_timeout;
213	/* dot11AssociationSAQueryRetryTimeout (in TUs) */
214	int assoc_sa_query_retry_timeout;
215#endif /* CONFIG_IEEE80211W */
216	enum {
217		PSK_RADIUS_IGNORED = 0,
218		PSK_RADIUS_ACCEPTED = 1,
219		PSK_RADIUS_REQUIRED = 2
220	} wpa_psk_radius;
221	int wpa_pairwise;
222	int wpa_group;
223	int wpa_group_rekey;
224	int wpa_strict_rekey;
225	int wpa_gmk_rekey;
226	int wpa_ptk_rekey;
227	int rsn_pairwise;
228	int rsn_preauth;
229	char *rsn_preauth_interfaces;
230	int peerkey;
231
232#ifdef CONFIG_IEEE80211R
233	/* IEEE 802.11r - Fast BSS Transition */
234	u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
235	u8 r1_key_holder[FT_R1KH_ID_LEN];
236	u32 r0_key_lifetime;
237	u32 reassociation_deadline;
238	struct ft_remote_r0kh *r0kh_list;
239	struct ft_remote_r1kh *r1kh_list;
240	int pmk_r1_push;
241	int ft_over_ds;
242#endif /* CONFIG_IEEE80211R */
243
244	char *ctrl_interface; /* directory for UNIX domain sockets */
245#ifndef CONFIG_NATIVE_WINDOWS
246	gid_t ctrl_interface_gid;
247#endif /* CONFIG_NATIVE_WINDOWS */
248	int ctrl_interface_gid_set;
249
250	char *ca_cert;
251	char *server_cert;
252	char *private_key;
253	char *private_key_passwd;
254	int check_crl;
255	char *dh_file;
256	u8 *pac_opaque_encr_key;
257	u8 *eap_fast_a_id;
258	size_t eap_fast_a_id_len;
259	char *eap_fast_a_id_info;
260	int eap_fast_prov;
261	int pac_key_lifetime;
262	int pac_key_refresh_time;
263	int eap_sim_aka_result_ind;
264	int tnc;
265	int fragment_size;
266	u16 pwd_group;
267
268	char *radius_server_clients;
269	int radius_server_auth_port;
270	int radius_server_ipv6;
271
272	char *test_socket; /* UNIX domain socket path for driver_test */
273
274	int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
275				 * address instead of individual address
276				 * (for driver_wired.c).
277				 */
278
279	int ap_max_inactivity;
280	int ignore_broadcast_ssid;
281
282	int wmm_enabled;
283	int wmm_uapsd;
284
285	struct hostapd_vlan *vlan, *vlan_tail;
286
287	macaddr bssid;
288
289	/*
290	 * Maximum listen interval that STAs can use when associating with this
291	 * BSS. If a STA tries to use larger value, the association will be
292	 * denied with status code 51.
293	 */
294	u16 max_listen_interval;
295
296	int disable_pmksa_caching;
297	int okc; /* Opportunistic Key Caching */
298
299	int wps_state;
300#ifdef CONFIG_WPS
301	int ap_setup_locked;
302	u8 uuid[16];
303	char *wps_pin_requests;
304	char *device_name;
305#ifdef ANDROID_P2P
306	char *prioritize;
307#endif
308	char *manufacturer;
309	char *model_name;
310	char *model_number;
311	char *serial_number;
312	u8 device_type[WPS_DEV_TYPE_LEN];
313	char *config_methods;
314	u8 os_version[4];
315	char *ap_pin;
316	int skip_cred_build;
317	u8 *extra_cred;
318	size_t extra_cred_len;
319	int wps_cred_processing;
320	u8 *ap_settings;
321	size_t ap_settings_len;
322	char *upnp_iface;
323	char *friendly_name;
324	char *manufacturer_url;
325	char *model_description;
326	char *model_url;
327	char *upc;
328	struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
329#endif /* CONFIG_WPS */
330	int pbc_in_m1;
331
332#define P2P_ENABLED BIT(0)
333#define P2P_GROUP_OWNER BIT(1)
334#define P2P_GROUP_FORMATION BIT(2)
335#define P2P_MANAGE BIT(3)
336#define P2P_ALLOW_CROSS_CONNECTION BIT(4)
337	int p2p;
338
339	int disassoc_low_ack;
340	int skip_inactivity_poll;
341
342#define TDLS_PROHIBIT BIT(0)
343#define TDLS_PROHIBIT_CHAN_SWITCH BIT(1)
344	int tdls;
345	int disable_11n;
346
347	/* IEEE 802.11v */
348	int time_advertisement;
349	char *time_zone;
350
351	/* IEEE 802.11u - Interworking */
352	int interworking;
353	int access_network_type;
354	int internet;
355	int asra;
356	int esr;
357	int uesa;
358	int venue_info_set;
359	u8 venue_group;
360	u8 venue_type;
361	u8 hessid[ETH_ALEN];
362
363	/* IEEE 802.11u - Roaming Consortium list */
364	unsigned int roaming_consortium_count;
365	struct hostapd_roaming_consortium *roaming_consortium;
366
367	u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
368
369#ifdef CONFIG_RADIUS_TEST
370	char *dump_msk_file;
371#endif /* CONFIG_RADIUS_TEST */
372};
373
374
375/**
376 * struct hostapd_config - Per-radio interface configuration
377 */
378struct hostapd_config {
379	struct hostapd_bss_config *bss, *last_bss;
380	size_t num_bss;
381
382	u16 beacon_int;
383	int rts_threshold;
384	int fragm_threshold;
385	u8 send_probe_response;
386	u8 channel;
387	enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
388	enum {
389		LONG_PREAMBLE = 0,
390		SHORT_PREAMBLE = 1
391	} preamble;
392
393	int *supported_rates;
394	int *basic_rates;
395
396	const struct wpa_driver_ops *driver;
397
398	int ap_table_max_size;
399	int ap_table_expiration_time;
400
401	char country[3]; /* first two octets: country code as described in
402			  * ISO/IEC 3166-1. Third octet:
403			  * ' ' (ascii 32): all environments
404			  * 'O': Outdoor environemnt only
405			  * 'I': Indoor environment only
406			  */
407
408	int ieee80211d;
409
410	struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
411
412	/*
413	 * WMM AC parameters, in same order as 802.1D, i.e.
414	 * 0 = BE (best effort)
415	 * 1 = BK (background)
416	 * 2 = VI (video)
417	 * 3 = VO (voice)
418	 */
419	struct hostapd_wmm_ac_params wmm_ac_params[4];
420
421	int ht_op_mode_fixed;
422	u16 ht_capab;
423	int ieee80211n;
424	int secondary_channel;
425	int require_ht;
426};
427
428
429int hostapd_mac_comp(const void *a, const void *b);
430int hostapd_mac_comp_empty(const void *a);
431struct hostapd_config * hostapd_config_defaults(void);
432void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);
433void hostapd_config_free(struct hostapd_config *conf);
434int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
435			  const u8 *addr, int *vlan_id);
436int hostapd_rate_found(int *list, int rate);
437int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
438			struct hostapd_wep_keys *b);
439const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
440			   const u8 *addr, const u8 *prev_psk);
441int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
442const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
443					int vlan_id);
444const struct hostapd_eap_user *
445hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
446		     size_t identity_len, int phase2);
447
448#endif /* HOSTAPD_CONFIG_H */
449