• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hostapd / Configuration definitions and helpers functions
3  * Copyright (c) 2003-2015, 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 "utils/list.h"
14 #include "ip_addr.h"
15 #include "common/wpa_common.h"
16 #include "common/ieee802_11_defs.h"
17 #include "common/ieee802_11_common.h"
18 #include "crypto/sha256.h"
19 #include "wps/wps.h"
20 #include "fst/fst.h"
21 #ifndef LOS_CONFIG_NO_VLAN
22 #include "vlan.h"
23 #endif
24 /**
25  * mesh_conf - local MBSS state and settings
26  */
27 struct mesh_conf {
28 	u8 meshid[32];
29 	u8 meshid_len;
30 	/* Active Path Selection Protocol Identifier */
31 	u8 mesh_pp_id;
32 	/* Active Path Selection Metric Identifier */
33 	u8 mesh_pm_id;
34 	/* Congestion Control Mode Identifier */
35 	u8 mesh_cc_id;
36 	/* Synchronization Protocol Identifier */
37 	u8 mesh_sp_id;
38 	/* Authentication Protocol Identifier */
39 	u8 mesh_auth_id;
40 	u8 *rsn_ie;
41 	int rsn_ie_len;
42 #define MESH_CONF_SEC_NONE BIT(0)
43 #define MESH_CONF_SEC_AUTH BIT(1)
44 #define MESH_CONF_SEC_AMPE BIT(2)
45 	unsigned int security;
46 	enum mfp_options ieee80211w;
47 	int ocv;
48 	unsigned int pairwise_cipher;
49 	unsigned int group_cipher;
50 	unsigned int mgmt_group_cipher;
51 	int dot11MeshMaxRetries;
52 	int dot11MeshRetryTimeout; /* msec */
53 	int dot11MeshConfirmTimeout; /* msec */
54 	int dot11MeshHoldingTimeout; /* msec */
55 	int mesh_fwding;
56 };
57 
58 #ifdef CONFIG_LITEOS_WPA
59 #ifdef CONFIG_DRIVER_AR6003
60 extern const size_t MAX_STA_COUNT;
61 #else
62 #define MAX_STA_COUNT 2007
63 #endif
64 #endif
65 #define MAX_VLAN_ID 4094
66 
67 typedef u8 macaddr[ETH_ALEN];
68 #ifndef EXT_CODE_CROP
69 struct mac_acl_entry {
70 	macaddr addr;
71 	struct vlan_description vlan_id;
72 };
73 
74 struct hostapd_radius_servers;
75 #endif /* EXT_CODE_CROP */
76 struct ft_remote_r0kh;
77 struct ft_remote_r1kh;
78 
79 #ifdef CONFIG_WEP
80 #define NUM_WEP_KEYS 4
81 struct hostapd_wep_keys {
82 	u8 idx;
83 	u8 *key[NUM_WEP_KEYS];
84 	size_t len[NUM_WEP_KEYS];
85 	int keys_set;
86 	size_t default_len; /* key length used for dynamic key generation */
87 };
88 #endif /* CONFIG_WEP */
89 
90 typedef enum hostap_security_policy {
91 	SECURITY_PLAINTEXT = 0,
92 #ifdef CONFIG_WEP
93 	SECURITY_STATIC_WEP = 1,
94 #endif /* CONFIG_WEP */
95 	SECURITY_IEEE_802_1X = 2,
96 	SECURITY_WPA_PSK = 3,
97 	SECURITY_WPA = 4,
98 	SECURITY_OSEN = 5
99 } secpolicy;
100 
101 struct hostapd_ssid {
102 	u8 ssid[SSID_MAX_LEN];
103 	size_t ssid_len;
104 	u32 short_ssid;
105 	unsigned int ssid_set:1;
106 	unsigned int utf8_ssid:1;
107 	unsigned int wpa_passphrase_set:1;
108 	unsigned int wpa_psk_set:1;
109 
110 	char vlan[IFNAMSIZ + 1];
111 	secpolicy security_policy;
112 
113 	struct hostapd_wpa_psk *wpa_psk;
114 	char *wpa_passphrase;
115 	char *wpa_psk_file;
116 	struct sae_pt *pt;
117 
118 #ifdef CONFIG_WEP
119 	struct hostapd_wep_keys wep;
120 #endif /* CONFIG_WEP */
121 
122 #define DYNAMIC_VLAN_DISABLED 0
123 #define DYNAMIC_VLAN_OPTIONAL 1
124 #define DYNAMIC_VLAN_REQUIRED 2
125 	int dynamic_vlan;
126 #define DYNAMIC_VLAN_NAMING_WITHOUT_DEVICE 0
127 #define DYNAMIC_VLAN_NAMING_WITH_DEVICE 1
128 #define DYNAMIC_VLAN_NAMING_END 2
129 	int vlan_naming;
130 	int per_sta_vif;
131 #ifdef CONFIG_FULL_DYNAMIC_VLAN
132 	char *vlan_tagged_interface;
133 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
134 };
135 #ifndef LOS_CONFIG_NO_VLAN
136 
137 #define VLAN_ID_WILDCARD -1
138 
139 struct hostapd_vlan {
140 	struct hostapd_vlan *next;
141 	int vlan_id; /* VLAN ID or -1 (VLAN_ID_WILDCARD) for wildcard entry */
142 	struct vlan_description vlan_desc;
143 	char ifname[IFNAMSIZ + 1];
144 	char bridge[IFNAMSIZ + 1];
145 	int configured;
146 	int dynamic_vlan;
147 #ifdef CONFIG_FULL_DYNAMIC_VLAN
148 
149 #define DVLAN_CLEAN_WLAN_PORT	0x8
150 	int clean;
151 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
152 };
153 #endif /* LOS_CONFIG_NO_VLAN */
154 #define PMK_LEN 32
155 #define KEYID_LEN 32
156 #define MIN_PASSPHRASE_LEN 8
157 #define MAX_PASSPHRASE_LEN 63
158 struct hostapd_sta_wpa_psk_short {
159 	struct hostapd_sta_wpa_psk_short *next;
160 	unsigned int is_passphrase:1;
161 	u8 psk[PMK_LEN];
162 	char passphrase[MAX_PASSPHRASE_LEN + 1];
163 	int ref; /* (number of references held) - 1 */
164 };
165 
166 struct hostapd_wpa_psk {
167 	struct hostapd_wpa_psk *next;
168 	int group;
169 	char keyid[KEYID_LEN];
170 	int wps;
171 	u8 psk[PMK_LEN];
172 	u8 addr[ETH_ALEN];
173 	u8 p2p_dev_addr[ETH_ALEN];
174 	int vlan_id;
175 };
176 
177 struct hostapd_eap_user {
178 	struct hostapd_eap_user *next;
179 	u8 *identity;
180 	size_t identity_len;
181 	struct {
182 		int vendor;
183 		u32 method;
184 	} methods[EAP_MAX_METHODS];
185 	u8 *password;
186 	size_t password_len;
187 	u8 *salt;
188 	size_t salt_len; /* non-zero when password is salted */
189 	int phase2;
190 	int force_version;
191 	unsigned int wildcard_prefix:1;
192 	unsigned int password_hash:1; /* whether password is hashed with
193 				       * nt_password_hash() */
194 	unsigned int remediation:1;
195 	unsigned int macacl:1;
196 	int ttls_auth; /* EAP_TTLS_AUTH_* bitfield */
197 	struct hostapd_radius_attr *accept_attr;
198 	u32 t_c_timestamp;
199 };
200 
201 struct hostapd_radius_attr {
202 	u8 type;
203 	struct wpabuf *val;
204 	struct hostapd_radius_attr *next;
205 };
206 
207 
208 #define NUM_TX_QUEUES 4
209 #define MAX_ROAMING_CONSORTIUM_LEN 15
210 
211 struct hostapd_roaming_consortium {
212 	u8 len;
213 	u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
214 };
215 
216 struct hostapd_lang_string {
217 	u8 lang[3];
218 	u8 name_len;
219 	u8 name[252];
220 };
221 
222 struct hostapd_venue_url {
223 	u8 venue_number;
224 	u8 url_len;
225 	u8 url[254];
226 };
227 
228 #define MAX_NAI_REALMS 10
229 #define MAX_NAI_REALMLEN 255
230 #define MAX_NAI_EAP_METHODS 5
231 #define MAX_NAI_AUTH_TYPES 4
232 struct hostapd_nai_realm_data {
233 	u8 encoding;
234 	char realm_buf[MAX_NAI_REALMLEN + 1];
235 	char *realm[MAX_NAI_REALMS];
236 	u8 eap_method_count;
237 	struct hostapd_nai_realm_eap {
238 		u8 eap_method;
239 		u8 num_auths;
240 		u8 auth_id[MAX_NAI_AUTH_TYPES];
241 		u8 auth_val[MAX_NAI_AUTH_TYPES];
242 	} eap_method[MAX_NAI_EAP_METHODS];
243 };
244 
245 struct anqp_element {
246 	struct dl_list list;
247 	u16 infoid;
248 	struct wpabuf *payload;
249 };
250 
251 struct fils_realm {
252 	struct dl_list list;
253 	u8 hash[2];
254 	char realm[];
255 };
256 
257 struct sae_password_entry {
258 	struct sae_password_entry *next;
259 	char *password;
260 	char *identifier;
261 	u8 peer_addr[ETH_ALEN];
262 #ifndef LOS_CONFIG_NO_VLAN
263 	int vlan_id;
264 #endif /* LOS_CONFIG_NO_VLAN */
265 	struct sae_pt *pt;
266 	struct sae_pk *pk;
267 };
268 
269 struct dpp_controller_conf {
270 	struct dpp_controller_conf *next;
271 	u8 pkhash[SHA256_MAC_LEN];
272 	struct hostapd_ip_addr ipaddr;
273 };
274 
275 struct airtime_sta_weight {
276 	struct airtime_sta_weight *next;
277 	unsigned int weight;
278 	u8 addr[ETH_ALEN];
279 };
280 
281 #define EXT_CAPA_MAX_LEN 15
282 
283 /**
284  * struct hostapd_bss_config - Per-BSS configuration
285  */
286 struct hostapd_bss_config {
287 	char iface[IFNAMSIZ + 1];
288 	char bridge[IFNAMSIZ + 1];
289 	char vlan_bridge[IFNAMSIZ + 1];
290 	char wds_bridge[IFNAMSIZ + 1];
291 
292 	enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
293 
294 	unsigned int logger_syslog; /* module bitfield */
295 	unsigned int logger_stdout; /* module bitfield */
296 
297 	int max_num_sta; /* maximum number of STAs in station table */
298 
299 	int dtim_period;
300 	unsigned int bss_load_update_period;
301 	unsigned int chan_util_avg_period;
302 
303 	int ieee802_1x; /* use IEEE 802.1X */
304 	int eapol_version;
305 	int eap_server; /* Use internal EAP server instead of external
306 			 * RADIUS server */
307 	struct hostapd_eap_user *eap_user;
308 	char *eap_user_sqlite;
309 	char *eap_sim_db;
310 	unsigned int eap_sim_db_timeout;
311 	int eap_server_erp; /* Whether ERP is enabled on internal EAP server */
312 	struct hostapd_ip_addr own_ip_addr;
313 	char *nas_identifier;
314 	struct hostapd_radius_servers *radius;
315 	int acct_interim_interval;
316 	int radius_request_cui;
317 	struct hostapd_radius_attr *radius_auth_req_attr;
318 	struct hostapd_radius_attr *radius_acct_req_attr;
319 	char *radius_req_attr_sqlite;
320 	int radius_das_port;
321 	unsigned int radius_das_time_window;
322 	int radius_das_require_event_timestamp;
323 	int radius_das_require_message_authenticator;
324 	struct hostapd_ip_addr radius_das_client_addr;
325 	u8 *radius_das_shared_secret;
326 	size_t radius_das_shared_secret_len;
327 
328 	struct hostapd_ssid ssid;
329 
330 	char *eap_req_id_text; /* optional displayable message sent with
331 				* EAP Request-Identity */
332 	size_t eap_req_id_text_len;
333 	int eapol_key_index_workaround;
334 
335 #ifdef CONFIG_WEP
336 	size_t default_wep_key_len;
337 	int individual_wep_key_len;
338 	int wep_rekeying_period;
339 	int broadcast_key_idx_min, broadcast_key_idx_max;
340 #endif /* CONFIG_WEP */
341 	int eap_reauth_period;
342 	int erp_send_reauth_start;
343 	char *erp_domain;
344 
345 	enum macaddr_acl {
346 		ACCEPT_UNLESS_DENIED = 0,
347 		DENY_UNLESS_ACCEPTED = 1,
348 		USE_EXTERNAL_RADIUS_AUTH = 2
349 	} macaddr_acl;
350 	struct mac_acl_entry *accept_mac;
351 	int num_accept_mac;
352 	struct mac_acl_entry *deny_mac;
353 	int num_deny_mac;
354 	int wds_sta;
355 	int isolate;
356 	int start_disabled;
357 
358 	int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
359 			* algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
360 
361 	int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
362 	int extended_key_id;
363 	int wpa_key_mgmt;
364 	enum mfp_options ieee80211w;
365 	int group_mgmt_cipher;
366 	int beacon_prot;
367 	/* dot11AssociationSAQueryMaximumTimeout (in TUs) */
368 	unsigned int assoc_sa_query_max_timeout;
369 	/* dot11AssociationSAQueryRetryTimeout (in TUs) */
370 	int assoc_sa_query_retry_timeout;
371 #ifdef CONFIG_OCV
372 	int ocv; /* Operating Channel Validation */
373 #endif /* CONFIG_OCV */
374 	enum {
375 		PSK_RADIUS_IGNORED = 0,
376 		PSK_RADIUS_ACCEPTED = 1,
377 		PSK_RADIUS_REQUIRED = 2
378 	} wpa_psk_radius;
379 	int wpa_pairwise;
380 	int group_cipher; /* wpa_group value override from configuation */
381 	int wpa_group;
382 	int wpa_group_rekey;
383 	int wpa_group_rekey_set;
384 	int wpa_strict_rekey;
385 	int wpa_gmk_rekey;
386 	int wpa_ptk_rekey;
387 	enum ptk0_rekey_handling wpa_deny_ptk0_rekey;
388 	u32 wpa_group_update_count;
389 	u32 wpa_pairwise_update_count;
390 	int wpa_disable_eapol_key_retries;
391 	int rsn_pairwise;
392 	int rsn_preauth;
393 	char *rsn_preauth_interfaces;
394 
395 #ifdef CONFIG_IEEE80211R_AP
396 	/* IEEE 802.11r - Fast BSS Transition */
397 	u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
398 	u8 r1_key_holder[FT_R1KH_ID_LEN];
399 	u32 r0_key_lifetime; /* PMK-R0 lifetime seconds */
400 	int rkh_pos_timeout;
401 	int rkh_neg_timeout;
402 	int rkh_pull_timeout; /* ms */
403 	int rkh_pull_retries;
404 	u32 reassociation_deadline;
405 	struct ft_remote_r0kh *r0kh_list;
406 	struct ft_remote_r1kh *r1kh_list;
407 	int pmk_r1_push;
408 	int ft_over_ds;
409 	int ft_psk_generate_local;
410 	int r1_max_key_lifetime;
411 #endif /* CONFIG_IEEE80211R_AP */
412 
413 	char *ctrl_interface; /* directory for UNIX domain sockets */
414 #ifndef CONFIG_NATIVE_WINDOWS
415 	gid_t ctrl_interface_gid;
416 #endif /* CONFIG_NATIVE_WINDOWS */
417 	int ctrl_interface_gid_set;
418 
419 	char *ca_cert;
420 	char *server_cert;
421 	char *server_cert2;
422 	char *private_key;
423 	char *private_key2;
424 	char *private_key_passwd;
425 	char *private_key_passwd2;
426 	char *check_cert_subject;
427 	int check_crl;
428 	int check_crl_strict;
429 	unsigned int crl_reload_interval;
430 	unsigned int tls_session_lifetime;
431 	unsigned int tls_flags;
432 	unsigned int max_auth_rounds;
433 	unsigned int max_auth_rounds_short;
434 	char *ocsp_stapling_response;
435 	char *ocsp_stapling_response_multi;
436 	char *dh_file;
437 	char *openssl_ciphers;
438 	char *openssl_ecdh_curves;
439 	u8 *pac_opaque_encr_key;
440 	u8 *eap_fast_a_id;
441 	size_t eap_fast_a_id_len;
442 	char *eap_fast_a_id_info;
443 	int eap_fast_prov;
444 	int pac_key_lifetime;
445 	int pac_key_refresh_time;
446 	int eap_teap_auth;
447 	int eap_teap_pac_no_inner;
448 	int eap_teap_separate_result;
449 	int eap_teap_id;
450 	int eap_sim_aka_result_ind;
451 	int eap_sim_id;
452 	int tnc;
453 	int fragment_size;
454 	u16 pwd_group;
455 
456 	char *radius_server_clients;
457 	int radius_server_auth_port;
458 	int radius_server_acct_port;
459 	int radius_server_ipv6;
460 
461 	int use_pae_group_addr; /* Whether to send EAPOL frames to PAE group
462 				 * address instead of individual address
463 				 * (for driver_wired.c).
464 				 */
465 
466 	int ap_max_inactivity;
467 	int ignore_broadcast_ssid;
468 	int no_probe_resp_if_max_sta;
469 
470 	int wmm_enabled;
471 	int wmm_uapsd;
472 
473 	struct hostapd_vlan *vlan;
474 
475 	macaddr bssid;
476 
477 	/*
478 	 * Maximum listen interval that STAs can use when associating with this
479 	 * BSS. If a STA tries to use larger value, the association will be
480 	 * denied with status code 51.
481 	 */
482 	u16 max_listen_interval;
483 
484 	int disable_pmksa_caching;
485 	int okc; /* Opportunistic Key Caching */
486 
487 	int wps_state;
488 #ifdef CONFIG_WPS
489 	int wps_independent;
490 	int ap_setup_locked;
491 	u8 uuid[16];
492 	char *wps_pin_requests;
493 	char *device_name;
494 	char *manufacturer;
495 	char *model_name;
496 	char *model_number;
497 	char *serial_number;
498 	u8 device_type[WPS_DEV_TYPE_LEN];
499 	char *config_methods;
500 	u8 os_version[4];
501 	char *ap_pin;
502 	int skip_cred_build;
503 	u8 *extra_cred;
504 	size_t extra_cred_len;
505 	int wps_cred_processing;
506 	int wps_cred_add_sae;
507 	int force_per_enrollee_psk;
508 	u8 *ap_settings;
509 	size_t ap_settings_len;
510 	struct hostapd_ssid multi_ap_backhaul_ssid;
511 	char *upnp_iface;
512 	char *friendly_name;
513 	char *manufacturer_url;
514 	char *model_description;
515 	char *model_url;
516 	char *upc;
517 	struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
518 	struct wpabuf *wps_application_ext;
519 	int wps_nfc_pw_from_config;
520 	int wps_nfc_dev_pw_id;
521 	struct wpabuf *wps_nfc_dh_pubkey;
522 	struct wpabuf *wps_nfc_dh_privkey;
523 	struct wpabuf *wps_nfc_dev_pw;
524 #endif /* CONFIG_WPS */
525 	int pbc_in_m1;
526 	char *server_id;
527 
528 #define P2P_ENABLED BIT(0)
529 #define P2P_GROUP_OWNER BIT(1)
530 #define P2P_GROUP_FORMATION BIT(2)
531 #define P2P_MANAGE BIT(3)
532 #define P2P_ALLOW_CROSS_CONNECTION BIT(4)
533 	int p2p;
534 #ifdef CONFIG_P2P
535 	u8 ip_addr_go[4];
536 	u8 ip_addr_mask[4];
537 	u8 ip_addr_start[4];
538 	u8 ip_addr_end[4];
539 #endif /* CONFIG_P2P */
540 
541 	int disassoc_low_ack;
542 	int skip_inactivity_poll;
543 
544 #define TDLS_PROHIBIT BIT(0)
545 #define TDLS_PROHIBIT_CHAN_SWITCH BIT(1)
546 	int tdls;
547 	bool disable_11n;
548 	bool disable_11ac;
549 	bool disable_11ax;
550 
551 	/* IEEE 802.11v */
552 	int time_advertisement;
553 	char *time_zone;
554 	int wnm_sleep_mode;
555 	int wnm_sleep_mode_no_keys;
556 	int bss_transition;
557 
558 	/* IEEE 802.11u - Interworking */
559 	int interworking;
560 	int access_network_type;
561 	int internet;
562 	int asra;
563 	int esr;
564 	int uesa;
565 	int venue_info_set;
566 	u8 venue_group;
567 	u8 venue_type;
568 	u8 hessid[ETH_ALEN];
569 
570 	/* IEEE 802.11u - Roaming Consortium list */
571 	unsigned int roaming_consortium_count;
572 	struct hostapd_roaming_consortium *roaming_consortium;
573 
574 	/* IEEE 802.11u - Venue Name duples */
575 	unsigned int venue_name_count;
576 	struct hostapd_lang_string *venue_name;
577 
578 	/* Venue URL duples */
579 	unsigned int venue_url_count;
580 	struct hostapd_venue_url *venue_url;
581 
582 	/* IEEE 802.11u - Network Authentication Type */
583 	u8 *network_auth_type;
584 	size_t network_auth_type_len;
585 
586 	/* IEEE 802.11u - IP Address Type Availability */
587 	u8 ipaddr_type_availability;
588 	u8 ipaddr_type_configured;
589 
590 	/* IEEE 802.11u - 3GPP Cellular Network */
591 	u8 *anqp_3gpp_cell_net;
592 	size_t anqp_3gpp_cell_net_len;
593 
594 	/* IEEE 802.11u - Domain Name */
595 	u8 *domain_name;
596 	size_t domain_name_len;
597 
598 	unsigned int nai_realm_count;
599 	struct hostapd_nai_realm_data *nai_realm_data;
600 
601 	struct dl_list anqp_elem; /* list of struct anqp_element */
602 
603 	u16 gas_comeback_delay;
604 	size_t gas_frag_limit;
605 	int gas_address3;
606 
607 	u8 qos_map_set[16 + 2 * 21];
608 	unsigned int qos_map_set_len;
609 
610 	int osen;
611 	int proxy_arp;
612 	int na_mcast_to_ucast;
613 
614 #ifdef CONFIG_HS20
615 	int hs20;
616 	int hs20_release;
617 	int disable_dgaf;
618 	u16 anqp_domain_id;
619 	unsigned int hs20_oper_friendly_name_count;
620 	struct hostapd_lang_string *hs20_oper_friendly_name;
621 	u8 *hs20_wan_metrics;
622 	u8 *hs20_connection_capability;
623 	size_t hs20_connection_capability_len;
624 	u8 *hs20_operating_class;
625 	u8 hs20_operating_class_len;
626 	struct hs20_icon {
627 		u16 width;
628 		u16 height;
629 		char language[3];
630 		char type[256];
631 		char name[256];
632 		char file[256];
633 	} *hs20_icons;
634 	size_t hs20_icons_count;
635 	u8 osu_ssid[SSID_MAX_LEN];
636 	size_t osu_ssid_len;
637 	struct hs20_osu_provider {
638 		unsigned int friendly_name_count;
639 		struct hostapd_lang_string *friendly_name;
640 		char *server_uri;
641 		int *method_list;
642 		char **icons;
643 		size_t icons_count;
644 		char *osu_nai;
645 		char *osu_nai2;
646 		unsigned int service_desc_count;
647 		struct hostapd_lang_string *service_desc;
648 	} *hs20_osu_providers, *last_osu;
649 	size_t hs20_osu_providers_count;
650 	size_t hs20_osu_providers_nai_count;
651 	char **hs20_operator_icon;
652 	size_t hs20_operator_icon_count;
653 	unsigned int hs20_deauth_req_timeout;
654 	char *subscr_remediation_url;
655 	u8 subscr_remediation_method;
656 	char *hs20_sim_provisioning_url;
657 	char *t_c_filename;
658 	u32 t_c_timestamp;
659 	char *t_c_server_url;
660 #endif /* CONFIG_HS20 */
661 
662 	u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
663 
664 #ifdef CONFIG_RADIUS_TEST
665 	char *dump_msk_file;
666 #endif /* CONFIG_RADIUS_TEST */
667 
668 	struct wpabuf *vendor_elements;
669 	struct wpabuf *assocresp_elements;
670 
671 	unsigned int anti_clogging_threshold;
672 	unsigned int sae_sync;
673 	int sae_require_mfp;
674 	int sae_confirm_immediate;
675 	int sae_pwe;
676 	int *sae_groups;
677 	struct sae_password_entry *sae_passwords;
678 
679 	char *wowlan_triggers; /* Wake-on-WLAN triggers */
680 
681 #ifdef CONFIG_TESTING_OPTIONS
682 	u8 bss_load_test[5];
683 	u8 bss_load_test_set;
684 	struct wpabuf *own_ie_override;
685 	int sae_reflection_attack;
686 	int sae_commit_status;
687 	int sae_pk_omit;
688 	int sae_pk_password_check_skip;
689 	struct wpabuf *sae_commit_override;
690 	struct wpabuf *rsne_override_eapol;
691 	struct wpabuf *rsnxe_override_eapol;
692 	struct wpabuf *rsne_override_ft;
693 	struct wpabuf *rsnxe_override_ft;
694 	struct wpabuf *gtk_rsc_override;
695 	struct wpabuf *igtk_rsc_override;
696 	int no_beacon_rsnxe;
697 	int skip_prune_assoc;
698 	int ft_rsnxe_used;
699 	unsigned int oci_freq_override_eapol_m3;
700 	unsigned int oci_freq_override_eapol_g1;
701 	unsigned int oci_freq_override_saquery_req;
702 	unsigned int oci_freq_override_saquery_resp;
703 	unsigned int oci_freq_override_ft_assoc;
704 	unsigned int oci_freq_override_fils_assoc;
705 	unsigned int oci_freq_override_wnm_sleep;
706 #endif /* CONFIG_TESTING_OPTIONS */
707 
708 #define MESH_ENABLED BIT(0)
709 	int mesh;
710 	int mesh_fwding;
711 
712 	u8 radio_measurements[RRM_CAPABILITIES_IE_LEN];
713 
714 	int vendor_vht;
715 	int use_sta_nsts;
716 
717 	char *no_probe_resp_if_seen_on;
718 	char *no_auth_if_seen_on;
719 
720 	int pbss;
721 
722 #ifdef CONFIG_MBO
723 	int mbo_enabled;
724 	/**
725 	 * oce - Enable OCE in AP and/or STA-CFON mode
726 	 *  - BIT(0) is Reserved
727 	 *  - Set BIT(1) to enable OCE in STA-CFON mode
728 	 *  - Set BIT(2) to enable OCE in AP mode
729 	 */
730 	unsigned int oce;
731 	int mbo_cell_data_conn_pref;
732 #endif /* CONFIG_MBO */
733 
734 	int ftm_responder;
735 	int ftm_initiator;
736 
737 #ifdef CONFIG_FILS
738 	u8 fils_cache_id[FILS_CACHE_ID_LEN];
739 	int fils_cache_id_set;
740 	struct dl_list fils_realms; /* list of struct fils_realm */
741 	int fils_dh_group;
742 	struct hostapd_ip_addr dhcp_server;
743 	int dhcp_rapid_commit_proxy;
744 	unsigned int fils_hlp_wait_time;
745 	u16 dhcp_server_port;
746 	u16 dhcp_relay_port;
747 	u32 fils_discovery_min_int;
748 	u32 fils_discovery_max_int;
749 #endif /* CONFIG_FILS */
750 
751 	int multicast_to_unicast;
752 
753 	int broadcast_deauth;
754 
755 	int notify_mgmt_frames;
756 
757 #ifdef CONFIG_DPP
758 	char *dpp_name;
759 	char *dpp_mud_url;
760 	char *dpp_connector;
761 	struct wpabuf *dpp_netaccesskey;
762 	unsigned int dpp_netaccesskey_expiry;
763 	struct wpabuf *dpp_csign;
764 #ifdef CONFIG_DPP2
765 	struct dpp_controller_conf *dpp_controller;
766 	int dpp_configurator_connectivity;
767 	int dpp_pfs;
768 #endif /* CONFIG_DPP2 */
769 #endif /* CONFIG_DPP */
770 
771 #ifdef CONFIG_OWE
772 	macaddr owe_transition_bssid;
773 	u8 owe_transition_ssid[SSID_MAX_LEN];
774 	size_t owe_transition_ssid_len;
775 	char owe_transition_ifname[IFNAMSIZ + 1];
776 	int *owe_groups;
777 	int owe_ptk_workaround;
778 #endif /* CONFIG_OWE */
779 
780 	int coloc_intf_reporting;
781 
782 	u8 send_probe_response;
783 
784 	u8 transition_disable;
785 
786 #define BACKHAUL_BSS 1
787 #define FRONTHAUL_BSS 2
788 	int multi_ap; /* bitmap of BACKHAUL_BSS, FRONTHAUL_BSS */
789 
790 #ifdef CONFIG_AIRTIME_POLICY
791 	unsigned int airtime_weight;
792 	int airtime_limit;
793 	struct airtime_sta_weight *airtime_weight_list;
794 #endif /* CONFIG_AIRTIME_POLICY */
795 
796 #ifdef CONFIG_MACSEC
797 	/**
798 	 * macsec_policy - Determines the policy for MACsec secure session
799 	 *
800 	 * 0: MACsec not in use (default)
801 	 * 1: MACsec enabled - Should secure, accept key server's advice to
802 	 *    determine whether to use a secure session or not.
803 	 */
804 	int macsec_policy;
805 
806 	/**
807 	 * macsec_integ_only - Determines how MACsec are transmitted
808 	 *
809 	 * This setting applies only when MACsec is in use, i.e.,
810 	 *  - macsec_policy is enabled
811 	 *  - the key server has decided to enable MACsec
812 	 *
813 	 * 0: Encrypt traffic (default)
814 	 * 1: Integrity only
815 	 */
816 	int macsec_integ_only;
817 
818 	/**
819 	 * macsec_replay_protect - Enable MACsec replay protection
820 	 *
821 	 * This setting applies only when MACsec is in use, i.e.,
822 	 *  - macsec_policy is enabled
823 	 *  - the key server has decided to enable MACsec
824 	 *
825 	 * 0: Replay protection disabled (default)
826 	 * 1: Replay protection enabled
827 	 */
828 	int macsec_replay_protect;
829 
830 	/**
831 	 * macsec_replay_window - MACsec replay protection window
832 	 *
833 	 * A window in which replay is tolerated, to allow receipt of frames
834 	 * that have been misordered by the network.
835 	 *
836 	 * This setting applies only when MACsec replay protection active, i.e.,
837 	 *  - macsec_replay_protect is enabled
838 	 *  - the key server has decided to enable MACsec
839 	 *
840 	 * 0: No replay window, strict check (default)
841 	 * 1..2^32-1: number of packets that could be misordered
842 	 */
843 	u32 macsec_replay_window;
844 
845 	/**
846 	 * macsec_port - MACsec port (in SCI)
847 	 *
848 	 * Port component of the SCI.
849 	 *
850 	 * Range: 1-65534 (default: 1)
851 	 */
852 	int macsec_port;
853 
854 	/**
855 	 * mka_priority - Priority of MKA Actor
856 	 *
857 	 * Range: 0-255 (default: 255)
858 	 */
859 	int mka_priority;
860 
861 	/**
862 	 * mka_ckn - MKA pre-shared CKN
863 	 */
864 #define MACSEC_CKN_MAX_LEN 32
865 	size_t mka_ckn_len;
866 	u8 mka_ckn[MACSEC_CKN_MAX_LEN];
867 
868 	/**
869 	 * mka_cak - MKA pre-shared CAK
870 	 */
871 #define MACSEC_CAK_MAX_LEN 32
872 	size_t mka_cak_len;
873 	u8 mka_cak[MACSEC_CAK_MAX_LEN];
874 
875 #define MKA_PSK_SET_CKN BIT(0)
876 #define MKA_PSK_SET_CAK BIT(1)
877 #define MKA_PSK_SET (MKA_PSK_SET_CKN | MKA_PSK_SET_CAK)
878 	/**
879 	 * mka_psk_set - Whether mka_ckn and mka_cak are set
880 	 */
881 	u8 mka_psk_set;
882 #endif /* CONFIG_MACSEC */
883 
884 #ifdef CONFIG_PASN
885 #ifdef CONFIG_TESTING_OPTIONS
886 	/*
887 	 * Normally, KDK should be derived if and only if both sides support
888 	 * secure LTF. Allow forcing KDK derivation for testing purposes.
889 	 */
890 	int force_kdk_derivation;
891 
892 	/* If set, corrupt the MIC in the 2nd Authentication frame of PASN */
893 	int pasn_corrupt_mic;
894 #endif /* CONFIG_TESTING_OPTIONS */
895 
896 	int *pasn_groups;
897 
898 	/*
899 	 * The time in TUs after which the non-AP STA is requested to retry the
900 	 * PASN authentication in case there are too many parallel operations.
901 	 */
902 	u16 pasn_comeback_after;
903 #endif /* CONFIG_PASN */
904 
905 	unsigned int unsol_bcast_probe_resp_interval;
906 
907 	u8 ext_capa_mask[EXT_CAPA_MAX_LEN];
908 	u8 ext_capa[EXT_CAPA_MAX_LEN];
909 
910 	u8 rnr;
911 };
912 
913 /**
914  * struct he_phy_capabilities_info - HE PHY capabilities
915  */
916 struct he_phy_capabilities_info {
917 	bool he_su_beamformer;
918 	bool he_su_beamformee;
919 	bool he_mu_beamformer;
920 };
921 
922 /**
923  * struct he_operation - HE operation
924  */
925 struct he_operation {
926 	u8 he_bss_color;
927 	u8 he_bss_color_disabled;
928 	u8 he_bss_color_partial;
929 	u8 he_default_pe_duration;
930 	u8 he_twt_required;
931 	u8 he_twt_responder;
932 	u16 he_rts_threshold;
933 	u8 he_er_su_disable;
934 	u16 he_basic_mcs_nss_set;
935 };
936 
937 /**
938  * struct spatial_reuse - Spatial reuse
939  */
940 struct spatial_reuse {
941 	u8 sr_control;
942 	u8 non_srg_obss_pd_max_offset;
943 	u8 srg_obss_pd_min_offset;
944 	u8 srg_obss_pd_max_offset;
945 	u8 srg_bss_color_bitmap[8];
946 	u8 srg_partial_bssid_bitmap[8];
947 };
948 
949 /**
950  * struct hostapd_config - Per-radio interface configuration
951  */
952 struct hostapd_config {
953 	struct hostapd_bss_config **bss, *last_bss;
954 	size_t num_bss;
955 
956 	u16 beacon_int;
957 	int rts_threshold;
958 	int fragm_threshold;
959 	u8 op_class;
960 	u8 channel;
961 	int enable_edmg;
962 	u8 edmg_channel;
963 	u8 acs;
964 	struct wpa_freq_range_list acs_ch_list;
965 	struct wpa_freq_range_list acs_freq_list;
966 	u8 acs_freq_list_present;
967 	int acs_exclude_dfs;
968 	u8 min_tx_power;
969 	enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
970 	int acs_exclude_6ghz_non_psc;
971 	enum {
972 		LONG_PREAMBLE = 0,
973 		SHORT_PREAMBLE = 1
974 	} preamble;
975 
976 	int *supported_rates;
977 	int *basic_rates;
978 	unsigned int beacon_rate;
979 	enum beacon_rate_type rate_type;
980 
981 	const struct wpa_driver_ops *driver;
982 	char *driver_params;
983 
984 	int ap_table_max_size;
985 	int ap_table_expiration_time;
986 
987 	unsigned int track_sta_max_num;
988 	unsigned int track_sta_max_age;
989 
990 	char country[3]; /* first two octets: country code as described in
991 			  * ISO/IEC 3166-1. Third octet:
992 			  * ' ' (ascii 32): all environments
993 			  * 'O': Outdoor environemnt only
994 			  * 'I': Indoor environment only
995 			  * 'X': Used with noncountry entity ("XXX")
996 			  * 0x00..0x31: identifying IEEE 802.11 standard
997 			  *	Annex E table (0x04 = global table)
998 			  */
999 
1000 	int ieee80211d;
1001 
1002 	int ieee80211h; /* DFS */
1003 
1004 	/*
1005 	 * Local power constraint is an octet encoded as an unsigned integer in
1006 	 * units of decibels. Invalid value -1 indicates that Power Constraint
1007 	 * element will not be added.
1008 	 */
1009 	int local_pwr_constraint;
1010 
1011 	/* Control Spectrum Management bit */
1012 	int spectrum_mgmt_required;
1013 
1014 	struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
1015 
1016 	/*
1017 	 * WMM AC parameters, in same order as 802.1D, i.e.
1018 	 * 0 = BE (best effort)
1019 	 * 1 = BK (background)
1020 	 * 2 = VI (video)
1021 	 * 3 = VO (voice)
1022 	 */
1023 	struct hostapd_wmm_ac_params wmm_ac_params[4];
1024 
1025 	int ht_op_mode_fixed;
1026 	u16 ht_capab;
1027 	int ieee80211n;
1028 	int secondary_channel;
1029 	int no_pri_sec_switch;
1030 	int require_ht;
1031 	int obss_interval;
1032 	u32 vht_capab;
1033 	int ieee80211ac;
1034 	int require_vht;
1035 	u8 vht_oper_chwidth;
1036 	u8 vht_oper_centr_freq_seg0_idx;
1037 	u8 vht_oper_centr_freq_seg1_idx;
1038 	u8 ht40_plus_minus_allowed;
1039 
1040 	/* Use driver-generated interface addresses when adding multiple BSSs */
1041 	u8 use_driver_iface_addr;
1042 
1043 #ifdef CONFIG_FST
1044 	struct fst_iface_cfg fst_cfg;
1045 #endif /* CONFIG_FST */
1046 
1047 #ifdef CONFIG_P2P
1048 	u8 p2p_go_ctwindow;
1049 #endif /* CONFIG_P2P */
1050 
1051 #ifdef CONFIG_TESTING_OPTIONS
1052 	double ignore_probe_probability;
1053 	double ignore_auth_probability;
1054 	double ignore_assoc_probability;
1055 	double ignore_reassoc_probability;
1056 	double corrupt_gtk_rekey_mic_probability;
1057 	int ecsa_ie_only;
1058 #endif /* CONFIG_TESTING_OPTIONS */
1059 
1060 #ifdef CONFIG_ACS
1061 	unsigned int acs_num_scans;
1062 	struct acs_bias {
1063 		int channel;
1064 		float bias;
1065 	} *acs_chan_bias;
1066 	unsigned int num_acs_chan_bias;
1067 #endif /* CONFIG_ACS */
1068 
1069 	struct wpabuf *lci;
1070 	struct wpabuf *civic;
1071 	int stationary_ap;
1072 
1073 	int ieee80211ax;
1074 #ifdef CONFIG_IEEE80211AX
1075 	struct he_phy_capabilities_info he_phy_capab;
1076 	struct he_operation he_op;
1077 	struct ieee80211_he_mu_edca_parameter_set he_mu_edca;
1078 	struct spatial_reuse spr;
1079 	u8 he_oper_chwidth;
1080 	u8 he_oper_centr_freq_seg0_idx;
1081 	u8 he_oper_centr_freq_seg1_idx;
1082 	u8 he_6ghz_max_mpdu;
1083 	u8 he_6ghz_max_ampdu_len_exp;
1084 	u8 he_6ghz_rx_ant_pat;
1085 	u8 he_6ghz_tx_ant_pat;
1086 #endif /* CONFIG_IEEE80211AX */
1087 
1088 	/* VHT enable/disable config from CHAN_SWITCH */
1089 #define CH_SWITCH_VHT_ENABLED BIT(0)
1090 #define CH_SWITCH_VHT_DISABLED BIT(1)
1091 	unsigned int ch_switch_vht_config;
1092 
1093 	/* HE enable/disable config from CHAN_SWITCH */
1094 #define CH_SWITCH_HE_ENABLED BIT(0)
1095 #define CH_SWITCH_HE_DISABLED BIT(1)
1096 	unsigned int ch_switch_he_config;
1097 
1098 	int rssi_reject_assoc_rssi;
1099 	int rssi_reject_assoc_timeout;
1100 	int rssi_ignore_probe_request;
1101 
1102 #ifdef CONFIG_AIRTIME_POLICY
1103 	enum {
1104 		AIRTIME_MODE_OFF = 0,
1105 		AIRTIME_MODE_STATIC = 1,
1106 		AIRTIME_MODE_DYNAMIC = 2,
1107 		AIRTIME_MODE_LIMIT = 3,
1108 		__AIRTIME_MODE_MAX,
1109 	} airtime_mode;
1110 	unsigned int airtime_update_interval;
1111 #define AIRTIME_MODE_MAX (__AIRTIME_MODE_MAX - 1)
1112 #endif /* CONFIG_AIRTIME_POLICY */
1113 };
1114 
1115 
hostapd_get_oper_chwidth(struct hostapd_config * conf)1116 static inline u8 hostapd_get_oper_chwidth(struct hostapd_config *conf)
1117 {
1118 #ifdef CONFIG_IEEE80211AX
1119 	if (conf->ieee80211ax)
1120 		return conf->he_oper_chwidth;
1121 #endif /* CONFIG_IEEE80211AX */
1122 	return conf->vht_oper_chwidth;
1123 }
1124 
1125 static inline void
hostapd_set_oper_chwidth(struct hostapd_config * conf,u8 oper_chwidth)1126 hostapd_set_oper_chwidth(struct hostapd_config *conf, u8 oper_chwidth)
1127 {
1128 #ifdef CONFIG_IEEE80211AX
1129 	if (conf->ieee80211ax)
1130 		conf->he_oper_chwidth = oper_chwidth;
1131 #endif /* CONFIG_IEEE80211AX */
1132 	conf->vht_oper_chwidth = oper_chwidth;
1133 }
1134 
1135 static inline u8
hostapd_get_oper_centr_freq_seg0_idx(struct hostapd_config * conf)1136 hostapd_get_oper_centr_freq_seg0_idx(struct hostapd_config *conf)
1137 {
1138 #ifdef CONFIG_IEEE80211AX
1139 	if (conf->ieee80211ax)
1140 		return conf->he_oper_centr_freq_seg0_idx;
1141 #endif /* CONFIG_IEEE80211AX */
1142 	return conf->vht_oper_centr_freq_seg0_idx;
1143 }
1144 
1145 static inline void
hostapd_set_oper_centr_freq_seg0_idx(struct hostapd_config * conf,u8 oper_centr_freq_seg0_idx)1146 hostapd_set_oper_centr_freq_seg0_idx(struct hostapd_config *conf,
1147 				     u8 oper_centr_freq_seg0_idx)
1148 {
1149 #ifdef CONFIG_IEEE80211AX
1150 	if (conf->ieee80211ax)
1151 		conf->he_oper_centr_freq_seg0_idx = oper_centr_freq_seg0_idx;
1152 #endif /* CONFIG_IEEE80211AX */
1153 	conf->vht_oper_centr_freq_seg0_idx = oper_centr_freq_seg0_idx;
1154 }
1155 
1156 static inline u8
hostapd_get_oper_centr_freq_seg1_idx(struct hostapd_config * conf)1157 hostapd_get_oper_centr_freq_seg1_idx(struct hostapd_config *conf)
1158 {
1159 #ifdef CONFIG_IEEE80211AX
1160 	if (conf->ieee80211ax)
1161 		return conf->he_oper_centr_freq_seg1_idx;
1162 #endif /* CONFIG_IEEE80211AX */
1163 	return conf->vht_oper_centr_freq_seg1_idx;
1164 }
1165 
1166 static inline void
hostapd_set_oper_centr_freq_seg1_idx(struct hostapd_config * conf,u8 oper_centr_freq_seg1_idx)1167 hostapd_set_oper_centr_freq_seg1_idx(struct hostapd_config *conf,
1168 				     u8 oper_centr_freq_seg1_idx)
1169 {
1170 #ifdef CONFIG_IEEE80211AX
1171 	if (conf->ieee80211ax)
1172 		conf->he_oper_centr_freq_seg1_idx = oper_centr_freq_seg1_idx;
1173 #endif /* CONFIG_IEEE80211AX */
1174 	conf->vht_oper_centr_freq_seg1_idx = oper_centr_freq_seg1_idx;
1175 }
1176 
1177 
1178 int hostapd_mac_comp(const void *a, const void *b);
1179 struct hostapd_config * hostapd_config_defaults(void);
1180 void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);
1181 void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr);
1182 void hostapd_config_free_eap_user(struct hostapd_eap_user *user);
1183 void hostapd_config_free_eap_users(struct hostapd_eap_user *user);
1184 void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **p);
1185 void hostapd_config_free_bss(struct hostapd_bss_config *conf);
1186 void hostapd_config_free(struct hostapd_config *conf);
1187 #ifndef EXT_CODE_CROP
1188 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
1189 			  const u8 *addr, struct vlan_description *vlan_id);
1190 #endif /* EXT_CODE_CROP */
1191 int hostapd_rate_found(int *list, int rate);
1192 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
1193 			   const u8 *addr, const u8 *p2p_dev_addr,
1194 #ifndef LOS_CONFIG_NO_VLAN
1195 			   const u8 *prev_psk, int *vlan_id);
1196 #else
1197 			   const u8 *prev_psk);
1198 #endif /* LOS_CONFIG_NO_VLAN */
1199 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
1200 #ifndef LOS_CONFIG_NO_VLAN
1201 int hostapd_vlan_valid(struct hostapd_vlan *vlan,
1202 		       struct vlan_description *vlan_desc);
1203 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
1204 					int vlan_id);
1205 #endif /* LOS_CONFIG_NO_VLAN */
1206 struct hostapd_radius_attr *
1207 hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type);
1208 struct hostapd_radius_attr * hostapd_parse_radius_attr(const char *value);
1209 int hostapd_config_check(struct hostapd_config *conf, int full_config);
1210 void hostapd_set_security_params(struct hostapd_bss_config *bss,
1211 				 int full_config);
1212 int hostapd_sae_pw_id_in_use(struct hostapd_bss_config *conf);
1213 bool hostapd_sae_pk_in_use(struct hostapd_bss_config *conf);
1214 bool hostapd_sae_pk_exclusively(struct hostapd_bss_config *conf);
1215 int hostapd_setup_sae_pt(struct hostapd_bss_config *conf);
1216 
1217 #endif /* HOSTAPD_CONFIG_H */
1218