]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/ap/ap_config.h
mesh: Add mesh mode routines
[thirdparty/hostap.git] / src / ap / ap_config.h
1 /*
2 * hostapd / Configuration definitions and helpers functions
3 * Copyright (c) 2003-2012, 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 "common/ieee802_11_common.h"
16 #include "wps/wps.h"
17
18 /**
19 * mesh_conf - local MBSS state and settings
20 */
21 struct mesh_conf {
22 u8 meshid[32];
23 u8 meshid_len;
24 /* Active Path Selection Protocol Identifier */
25 u8 mesh_pp_id;
26 /* Active Path Selection Metric Identifier */
27 u8 mesh_pm_id;
28 /* Congestion Control Mode Identifier */
29 u8 mesh_cc_id;
30 /* Synchronization Protocol Identifier */
31 u8 mesh_sp_id;
32 /* Authentication Protocol Identifier */
33 u8 mesh_auth_id;
34 u8 *ies;
35 int ie_len;
36 #define MESH_CONF_SEC_NONE BIT(0)
37 #define MESH_CONF_SEC_AUTH BIT(1)
38 #define MESH_CONF_SEC_AMPE BIT(2)
39 unsigned int security;
40 };
41
42 #define MAX_STA_COUNT 2007
43 #define MAX_VLAN_ID 4094
44
45 typedef u8 macaddr[ETH_ALEN];
46
47 struct mac_acl_entry {
48 macaddr addr;
49 int vlan_id;
50 };
51
52 struct hostapd_radius_servers;
53 struct ft_remote_r0kh;
54 struct ft_remote_r1kh;
55
56 #define HOSTAPD_MAX_SSID_LEN 32
57
58 #define NUM_WEP_KEYS 4
59 struct hostapd_wep_keys {
60 u8 idx;
61 u8 *key[NUM_WEP_KEYS];
62 size_t len[NUM_WEP_KEYS];
63 int keys_set;
64 size_t default_len; /* key length used for dynamic key generation */
65 };
66
67 typedef enum hostap_security_policy {
68 SECURITY_PLAINTEXT = 0,
69 SECURITY_STATIC_WEP = 1,
70 SECURITY_IEEE_802_1X = 2,
71 SECURITY_WPA_PSK = 3,
72 SECURITY_WPA = 4,
73 SECURITY_OSEN = 5
74 } secpolicy;
75
76 struct hostapd_ssid {
77 u8 ssid[HOSTAPD_MAX_SSID_LEN];
78 size_t ssid_len;
79 unsigned int ssid_set:1;
80 unsigned int utf8_ssid:1;
81 unsigned int wpa_passphrase_set:1;
82 unsigned int wpa_psk_set:1;
83
84 char vlan[IFNAMSIZ + 1];
85 secpolicy security_policy;
86
87 struct hostapd_wpa_psk *wpa_psk;
88 char *wpa_passphrase;
89 char *wpa_psk_file;
90
91 struct hostapd_wep_keys wep;
92
93 #define DYNAMIC_VLAN_DISABLED 0
94 #define DYNAMIC_VLAN_OPTIONAL 1
95 #define DYNAMIC_VLAN_REQUIRED 2
96 int dynamic_vlan;
97 #define DYNAMIC_VLAN_NAMING_WITHOUT_DEVICE 0
98 #define DYNAMIC_VLAN_NAMING_WITH_DEVICE 1
99 #define DYNAMIC_VLAN_NAMING_END 2
100 int vlan_naming;
101 #ifdef CONFIG_FULL_DYNAMIC_VLAN
102 char *vlan_tagged_interface;
103 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
104 };
105
106
107 #define VLAN_ID_WILDCARD -1
108
109 struct hostapd_vlan {
110 struct hostapd_vlan *next;
111 int vlan_id; /* VLAN ID or -1 (VLAN_ID_WILDCARD) for wildcard entry */
112 char ifname[IFNAMSIZ + 1];
113 int dynamic_vlan;
114 #ifdef CONFIG_FULL_DYNAMIC_VLAN
115
116 #define DVLAN_CLEAN_BR 0x1
117 #define DVLAN_CLEAN_VLAN 0x2
118 #define DVLAN_CLEAN_VLAN_PORT 0x4
119 #define DVLAN_CLEAN_WLAN_PORT 0x8
120 int clean;
121 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
122 };
123
124 #define PMK_LEN 32
125 struct hostapd_sta_wpa_psk_short {
126 struct hostapd_sta_wpa_psk_short *next;
127 u8 psk[PMK_LEN];
128 };
129
130 struct hostapd_wpa_psk {
131 struct hostapd_wpa_psk *next;
132 int group;
133 u8 psk[PMK_LEN];
134 u8 addr[ETH_ALEN];
135 u8 p2p_dev_addr[ETH_ALEN];
136 };
137
138 struct hostapd_eap_user {
139 struct hostapd_eap_user *next;
140 u8 *identity;
141 size_t identity_len;
142 struct {
143 int vendor;
144 u32 method;
145 } methods[EAP_MAX_METHODS];
146 u8 *password;
147 size_t password_len;
148 int phase2;
149 int force_version;
150 unsigned int wildcard_prefix:1;
151 unsigned int password_hash:1; /* whether password is hashed with
152 * nt_password_hash() */
153 unsigned int remediation:1;
154 unsigned int macacl:1;
155 int ttls_auth; /* EAP_TTLS_AUTH_* bitfield */
156 struct hostapd_radius_attr *accept_attr;
157 };
158
159 struct hostapd_radius_attr {
160 u8 type;
161 struct wpabuf *val;
162 struct hostapd_radius_attr *next;
163 };
164
165
166 #define NUM_TX_QUEUES 4
167
168 struct hostapd_tx_queue_params {
169 int aifs;
170 int cwmin;
171 int cwmax;
172 int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
173 };
174
175
176 #define MAX_ROAMING_CONSORTIUM_LEN 15
177
178 struct hostapd_roaming_consortium {
179 u8 len;
180 u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
181 };
182
183 struct hostapd_lang_string {
184 u8 lang[3];
185 u8 name_len;
186 u8 name[252];
187 };
188
189 #define MAX_NAI_REALMS 10
190 #define MAX_NAI_REALMLEN 255
191 #define MAX_NAI_EAP_METHODS 5
192 #define MAX_NAI_AUTH_TYPES 4
193 struct hostapd_nai_realm_data {
194 u8 encoding;
195 char realm_buf[MAX_NAI_REALMLEN + 1];
196 char *realm[MAX_NAI_REALMS];
197 u8 eap_method_count;
198 struct hostapd_nai_realm_eap {
199 u8 eap_method;
200 u8 num_auths;
201 u8 auth_id[MAX_NAI_AUTH_TYPES];
202 u8 auth_val[MAX_NAI_AUTH_TYPES];
203 } eap_method[MAX_NAI_EAP_METHODS];
204 };
205
206 /**
207 * struct hostapd_bss_config - Per-BSS configuration
208 */
209 struct hostapd_bss_config {
210 char iface[IFNAMSIZ + 1];
211 char bridge[IFNAMSIZ + 1];
212 char vlan_bridge[IFNAMSIZ + 1];
213 char wds_bridge[IFNAMSIZ + 1];
214
215 enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
216
217 unsigned int logger_syslog; /* module bitfield */
218 unsigned int logger_stdout; /* module bitfield */
219
220 int max_num_sta; /* maximum number of STAs in station table */
221
222 int dtim_period;
223 int bss_load_update_period;
224
225 int ieee802_1x; /* use IEEE 802.1X */
226 int eapol_version;
227 int eap_server; /* Use internal EAP server instead of external
228 * RADIUS server */
229 struct hostapd_eap_user *eap_user;
230 char *eap_user_sqlite;
231 char *eap_sim_db;
232 struct hostapd_ip_addr own_ip_addr;
233 char *nas_identifier;
234 struct hostapd_radius_servers *radius;
235 int acct_interim_interval;
236 int radius_request_cui;
237 struct hostapd_radius_attr *radius_auth_req_attr;
238 struct hostapd_radius_attr *radius_acct_req_attr;
239 int radius_das_port;
240 unsigned int radius_das_time_window;
241 int radius_das_require_event_timestamp;
242 struct hostapd_ip_addr radius_das_client_addr;
243 u8 *radius_das_shared_secret;
244 size_t radius_das_shared_secret_len;
245
246 struct hostapd_ssid ssid;
247
248 char *eap_req_id_text; /* optional displayable message sent with
249 * EAP Request-Identity */
250 size_t eap_req_id_text_len;
251 int eapol_key_index_workaround;
252
253 size_t default_wep_key_len;
254 int individual_wep_key_len;
255 int wep_rekeying_period;
256 int broadcast_key_idx_min, broadcast_key_idx_max;
257 int eap_reauth_period;
258
259 int ieee802_11f; /* use IEEE 802.11f (IAPP) */
260 char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
261 * frames */
262
263 enum {
264 ACCEPT_UNLESS_DENIED = 0,
265 DENY_UNLESS_ACCEPTED = 1,
266 USE_EXTERNAL_RADIUS_AUTH = 2
267 } macaddr_acl;
268 struct mac_acl_entry *accept_mac;
269 int num_accept_mac;
270 struct mac_acl_entry *deny_mac;
271 int num_deny_mac;
272 int wds_sta;
273 int isolate;
274 int start_disabled;
275
276 int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
277 * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
278
279 int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
280 int wpa_key_mgmt;
281 #ifdef CONFIG_IEEE80211W
282 enum mfp_options ieee80211w;
283 int group_mgmt_cipher;
284 /* dot11AssociationSAQueryMaximumTimeout (in TUs) */
285 unsigned int assoc_sa_query_max_timeout;
286 /* dot11AssociationSAQueryRetryTimeout (in TUs) */
287 int assoc_sa_query_retry_timeout;
288 #endif /* CONFIG_IEEE80211W */
289 enum {
290 PSK_RADIUS_IGNORED = 0,
291 PSK_RADIUS_ACCEPTED = 1,
292 PSK_RADIUS_REQUIRED = 2
293 } wpa_psk_radius;
294 int wpa_pairwise;
295 int wpa_group;
296 int wpa_group_rekey;
297 int wpa_strict_rekey;
298 int wpa_gmk_rekey;
299 int wpa_ptk_rekey;
300 int rsn_pairwise;
301 int rsn_preauth;
302 char *rsn_preauth_interfaces;
303 int peerkey;
304
305 #ifdef CONFIG_IEEE80211R
306 /* IEEE 802.11r - Fast BSS Transition */
307 u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
308 u8 r1_key_holder[FT_R1KH_ID_LEN];
309 u32 r0_key_lifetime;
310 u32 reassociation_deadline;
311 struct ft_remote_r0kh *r0kh_list;
312 struct ft_remote_r1kh *r1kh_list;
313 int pmk_r1_push;
314 int ft_over_ds;
315 #endif /* CONFIG_IEEE80211R */
316
317 char *ctrl_interface; /* directory for UNIX domain sockets */
318 #ifndef CONFIG_NATIVE_WINDOWS
319 gid_t ctrl_interface_gid;
320 #endif /* CONFIG_NATIVE_WINDOWS */
321 int ctrl_interface_gid_set;
322
323 char *ca_cert;
324 char *server_cert;
325 char *private_key;
326 char *private_key_passwd;
327 int check_crl;
328 char *ocsp_stapling_response;
329 char *dh_file;
330 char *openssl_ciphers;
331 u8 *pac_opaque_encr_key;
332 u8 *eap_fast_a_id;
333 size_t eap_fast_a_id_len;
334 char *eap_fast_a_id_info;
335 int eap_fast_prov;
336 int pac_key_lifetime;
337 int pac_key_refresh_time;
338 int eap_sim_aka_result_ind;
339 int tnc;
340 int fragment_size;
341 u16 pwd_group;
342
343 char *radius_server_clients;
344 int radius_server_auth_port;
345 int radius_server_acct_port;
346 int radius_server_ipv6;
347
348 char *test_socket; /* UNIX domain socket path for driver_test */
349
350 int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
351 * address instead of individual address
352 * (for driver_wired.c).
353 */
354
355 int ap_max_inactivity;
356 int ignore_broadcast_ssid;
357
358 int wmm_enabled;
359 int wmm_uapsd;
360
361 struct hostapd_vlan *vlan;
362
363 macaddr bssid;
364
365 /*
366 * Maximum listen interval that STAs can use when associating with this
367 * BSS. If a STA tries to use larger value, the association will be
368 * denied with status code 51.
369 */
370 u16 max_listen_interval;
371
372 int disable_pmksa_caching;
373 int okc; /* Opportunistic Key Caching */
374
375 int wps_state;
376 #ifdef CONFIG_WPS
377 int wps_independent;
378 int ap_setup_locked;
379 u8 uuid[16];
380 char *wps_pin_requests;
381 char *device_name;
382 char *manufacturer;
383 char *model_name;
384 char *model_number;
385 char *serial_number;
386 u8 device_type[WPS_DEV_TYPE_LEN];
387 char *config_methods;
388 u8 os_version[4];
389 char *ap_pin;
390 int skip_cred_build;
391 u8 *extra_cred;
392 size_t extra_cred_len;
393 int wps_cred_processing;
394 int force_per_enrollee_psk;
395 u8 *ap_settings;
396 size_t ap_settings_len;
397 char *upnp_iface;
398 char *friendly_name;
399 char *manufacturer_url;
400 char *model_description;
401 char *model_url;
402 char *upc;
403 struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
404 int wps_nfc_pw_from_config;
405 int wps_nfc_dev_pw_id;
406 struct wpabuf *wps_nfc_dh_pubkey;
407 struct wpabuf *wps_nfc_dh_privkey;
408 struct wpabuf *wps_nfc_dev_pw;
409 #endif /* CONFIG_WPS */
410 int pbc_in_m1;
411 char *server_id;
412
413 #define P2P_ENABLED BIT(0)
414 #define P2P_GROUP_OWNER BIT(1)
415 #define P2P_GROUP_FORMATION BIT(2)
416 #define P2P_MANAGE BIT(3)
417 #define P2P_ALLOW_CROSS_CONNECTION BIT(4)
418 int p2p;
419 #ifdef CONFIG_P2P
420 u8 ip_addr_go[4];
421 u8 ip_addr_mask[4];
422 u8 ip_addr_start[4];
423 u8 ip_addr_end[4];
424 #endif /* CONFIG_P2P */
425
426 int disassoc_low_ack;
427 int skip_inactivity_poll;
428
429 #define TDLS_PROHIBIT BIT(0)
430 #define TDLS_PROHIBIT_CHAN_SWITCH BIT(1)
431 int tdls;
432 int disable_11n;
433 int disable_11ac;
434
435 /* IEEE 802.11v */
436 int time_advertisement;
437 char *time_zone;
438 int wnm_sleep_mode;
439 int bss_transition;
440
441 /* IEEE 802.11u - Interworking */
442 int interworking;
443 int access_network_type;
444 int internet;
445 int asra;
446 int esr;
447 int uesa;
448 int venue_info_set;
449 u8 venue_group;
450 u8 venue_type;
451 u8 hessid[ETH_ALEN];
452
453 /* IEEE 802.11u - Roaming Consortium list */
454 unsigned int roaming_consortium_count;
455 struct hostapd_roaming_consortium *roaming_consortium;
456
457 /* IEEE 802.11u - Venue Name duples */
458 unsigned int venue_name_count;
459 struct hostapd_lang_string *venue_name;
460
461 /* IEEE 802.11u - Network Authentication Type */
462 u8 *network_auth_type;
463 size_t network_auth_type_len;
464
465 /* IEEE 802.11u - IP Address Type Availability */
466 u8 ipaddr_type_availability;
467 u8 ipaddr_type_configured;
468
469 /* IEEE 802.11u - 3GPP Cellular Network */
470 u8 *anqp_3gpp_cell_net;
471 size_t anqp_3gpp_cell_net_len;
472
473 /* IEEE 802.11u - Domain Name */
474 u8 *domain_name;
475 size_t domain_name_len;
476
477 unsigned int nai_realm_count;
478 struct hostapd_nai_realm_data *nai_realm_data;
479
480 u16 gas_comeback_delay;
481 int gas_frag_limit;
482
483 u8 qos_map_set[16 + 2 * 21];
484 unsigned int qos_map_set_len;
485
486 int osen;
487 #ifdef CONFIG_HS20
488 int hs20;
489 int disable_dgaf;
490 u16 anqp_domain_id;
491 unsigned int hs20_oper_friendly_name_count;
492 struct hostapd_lang_string *hs20_oper_friendly_name;
493 u8 *hs20_wan_metrics;
494 u8 *hs20_connection_capability;
495 size_t hs20_connection_capability_len;
496 u8 *hs20_operating_class;
497 u8 hs20_operating_class_len;
498 struct hs20_icon {
499 u16 width;
500 u16 height;
501 char language[3];
502 char type[256];
503 char name[256];
504 char file[256];
505 } *hs20_icons;
506 size_t hs20_icons_count;
507 u8 osu_ssid[HOSTAPD_MAX_SSID_LEN];
508 size_t osu_ssid_len;
509 struct hs20_osu_provider {
510 unsigned int friendly_name_count;
511 struct hostapd_lang_string *friendly_name;
512 char *server_uri;
513 int *method_list;
514 char **icons;
515 size_t icons_count;
516 char *osu_nai;
517 unsigned int service_desc_count;
518 struct hostapd_lang_string *service_desc;
519 } *hs20_osu_providers, *last_osu;
520 size_t hs20_osu_providers_count;
521 unsigned int hs20_deauth_req_timeout;
522 char *subscr_remediation_url;
523 u8 subscr_remediation_method;
524 #endif /* CONFIG_HS20 */
525
526 u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
527
528 #ifdef CONFIG_RADIUS_TEST
529 char *dump_msk_file;
530 #endif /* CONFIG_RADIUS_TEST */
531
532 struct wpabuf *vendor_elements;
533
534 unsigned int sae_anti_clogging_threshold;
535 int *sae_groups;
536
537 #ifdef CONFIG_TESTING_OPTIONS
538 u8 bss_load_test[5];
539 u8 bss_load_test_set;
540 #endif /* CONFIG_TESTING_OPTIONS */
541
542 #define MESH_ENABLED BIT(0)
543 int mesh;
544 };
545
546
547 /**
548 * struct hostapd_config - Per-radio interface configuration
549 */
550 struct hostapd_config {
551 struct hostapd_bss_config **bss, *last_bss;
552 size_t num_bss;
553
554 u16 beacon_int;
555 int rts_threshold;
556 int fragm_threshold;
557 u8 send_probe_response;
558 u8 channel;
559 int *chanlist;
560 enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
561 enum {
562 LONG_PREAMBLE = 0,
563 SHORT_PREAMBLE = 1
564 } preamble;
565
566 int *supported_rates;
567 int *basic_rates;
568
569 const struct wpa_driver_ops *driver;
570
571 int ap_table_max_size;
572 int ap_table_expiration_time;
573
574 char country[3]; /* first two octets: country code as described in
575 * ISO/IEC 3166-1. Third octet:
576 * ' ' (ascii 32): all environments
577 * 'O': Outdoor environemnt only
578 * 'I': Indoor environment only
579 */
580
581 int ieee80211d;
582
583 int ieee80211h; /* DFS */
584
585 /*
586 * Local power constraint is an octet encoded as an unsigned integer in
587 * units of decibels. Invalid value -1 indicates that Power Constraint
588 * element will not be added.
589 */
590 int local_pwr_constraint;
591
592 /* Control Spectrum Management bit */
593 int spectrum_mgmt_required;
594
595 struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
596
597 /*
598 * WMM AC parameters, in same order as 802.1D, i.e.
599 * 0 = BE (best effort)
600 * 1 = BK (background)
601 * 2 = VI (video)
602 * 3 = VO (voice)
603 */
604 struct hostapd_wmm_ac_params wmm_ac_params[4];
605
606 int ht_op_mode_fixed;
607 u16 ht_capab;
608 int ieee80211n;
609 int secondary_channel;
610 int require_ht;
611 int obss_interval;
612 u32 vht_capab;
613 int ieee80211ac;
614 int require_vht;
615 u8 vht_oper_chwidth;
616 u8 vht_oper_centr_freq_seg0_idx;
617 u8 vht_oper_centr_freq_seg1_idx;
618
619 #ifdef CONFIG_TESTING_OPTIONS
620 double ignore_probe_probability;
621 double ignore_auth_probability;
622 double ignore_assoc_probability;
623 double ignore_reassoc_probability;
624 double corrupt_gtk_rekey_mic_probability;
625 #endif /* CONFIG_TESTING_OPTIONS */
626
627 #ifdef CONFIG_ACS
628 unsigned int acs_num_scans;
629 #endif /* CONFIG_ACS */
630 };
631
632
633 int hostapd_mac_comp(const void *a, const void *b);
634 int hostapd_mac_comp_empty(const void *a);
635 struct hostapd_config * hostapd_config_defaults(void);
636 void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);
637 void hostapd_config_free_eap_user(struct hostapd_eap_user *user);
638 void hostapd_config_free_bss(struct hostapd_bss_config *conf);
639 void hostapd_config_free(struct hostapd_config *conf);
640 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
641 const u8 *addr, int *vlan_id);
642 int hostapd_rate_found(int *list, int rate);
643 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
644 const u8 *addr, const u8 *p2p_dev_addr,
645 const u8 *prev_psk);
646 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
647 int hostapd_vlan_id_valid(struct hostapd_vlan *vlan, int vlan_id);
648 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
649 int vlan_id);
650 struct hostapd_radius_attr *
651 hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type);
652 int hostapd_config_check(struct hostapd_config *conf, int full_config);
653 void hostapd_set_security_params(struct hostapd_bss_config *bss,
654 int full_config);
655
656 #endif /* HOSTAPD_CONFIG_H */