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