ap_config.h revision b5e8f06e18446918f6d801566e5709a8c87f1780
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 "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 119struct hostapd_radius_attr { 120 u8 type; 121 struct wpabuf *val; 122 struct hostapd_radius_attr *next; 123}; 124 125 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 144#define MAX_ROAMING_CONSORTIUM_LEN 15 145 146struct hostapd_roaming_consortium { 147 u8 len; 148 u8 oi[MAX_ROAMING_CONSORTIUM_LEN]; 149}; 150 151struct hostapd_venue_name { 152 u8 lang[3]; 153 u8 name_len; 154 u8 name[252]; 155}; 156 157/** 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; 186 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; 195 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 */ 237 enum { 238 PSK_RADIUS_IGNORED = 0, 239 PSK_RADIUS_ACCEPTED = 1, 240 PSK_RADIUS_REQUIRED = 2 241 } wpa_psk_radius; 242 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 317 int disable_pmksa_caching; 318 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; 326 char *manufacturer; 327 char *model_name; 328 char *model_number; 329 char *serial_number; 330 u8 device_type[WPS_DEV_TYPE_LEN]; 331 char *config_methods; 332 u8 os_version[4]; 333 char *ap_pin; 334 int skip_cred_build; 335 u8 *extra_cred; 336 size_t extra_cred_len; 337 int wps_cred_processing; 338 u8 *ap_settings; 339 size_t ap_settings_len; 340 char *upnp_iface; 341 char *friendly_name; 342 char *manufacturer_url; 343 char *model_description; 344 char *model_url; 345 char *upc; 346 struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS]; 347 int wps_nfc_dev_pw_id; 348 struct wpabuf *wps_nfc_dh_pubkey; 349 struct wpabuf *wps_nfc_dh_privkey; 350 struct wpabuf *wps_nfc_dev_pw; 351#endif /* CONFIG_WPS */ 352 int pbc_in_m1; 353 354#define P2P_ENABLED BIT(0) 355#define P2P_GROUP_OWNER BIT(1) 356#define P2P_GROUP_FORMATION BIT(2) 357#define P2P_MANAGE BIT(3) 358#define P2P_ALLOW_CROSS_CONNECTION BIT(4) 359 int p2p; 360 361 int disassoc_low_ack; 362 int skip_inactivity_poll; 363 364#define TDLS_PROHIBIT BIT(0) 365#define TDLS_PROHIBIT_CHAN_SWITCH BIT(1) 366 int tdls; 367 int disable_11n; 368 int disable_11ac; 369 370 /* IEEE 802.11v */ 371 int time_advertisement; 372 char *time_zone; 373 374 /* IEEE 802.11u - Interworking */ 375 int interworking; 376 int access_network_type; 377 int internet; 378 int asra; 379 int esr; 380 int uesa; 381 int venue_info_set; 382 u8 venue_group; 383 u8 venue_type; 384 u8 hessid[ETH_ALEN]; 385 386 /* IEEE 802.11u - Roaming Consortium list */ 387 unsigned int roaming_consortium_count; 388 struct hostapd_roaming_consortium *roaming_consortium; 389 390 /* IEEE 802.11u - Venue Name duples */ 391 unsigned int venue_name_count; 392 struct hostapd_venue_name *venue_name; 393 394 u16 gas_comeback_delay; 395 int gas_frag_limit; 396 397 u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */ 398 399#ifdef CONFIG_RADIUS_TEST 400 char *dump_msk_file; 401#endif /* CONFIG_RADIUS_TEST */ 402}; 403 404 405/** 406 * struct hostapd_config - Per-radio interface configuration 407 */ 408struct hostapd_config { 409 struct hostapd_bss_config *bss, *last_bss; 410 size_t num_bss; 411 412 u16 beacon_int; 413 int rts_threshold; 414 int fragm_threshold; 415 u8 send_probe_response; 416 u8 channel; 417 enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */ 418 enum { 419 LONG_PREAMBLE = 0, 420 SHORT_PREAMBLE = 1 421 } preamble; 422 423 int *supported_rates; 424 int *basic_rates; 425 426 const struct wpa_driver_ops *driver; 427 428 int ap_table_max_size; 429 int ap_table_expiration_time; 430 431 char country[3]; /* first two octets: country code as described in 432 * ISO/IEC 3166-1. Third octet: 433 * ' ' (ascii 32): all environments 434 * 'O': Outdoor environemnt only 435 * 'I': Indoor environment only 436 */ 437 438 int ieee80211d; 439 440 struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES]; 441 442 /* 443 * WMM AC parameters, in same order as 802.1D, i.e. 444 * 0 = BE (best effort) 445 * 1 = BK (background) 446 * 2 = VI (video) 447 * 3 = VO (voice) 448 */ 449 struct hostapd_wmm_ac_params wmm_ac_params[4]; 450 451 int ht_op_mode_fixed; 452 u16 ht_capab; 453 int ieee80211n; 454 int secondary_channel; 455 int require_ht; 456 u32 vht_capab; 457 int ieee80211ac; 458 u8 vht_oper_chwidth; 459}; 460 461 462int hostapd_mac_comp(const void *a, const void *b); 463int hostapd_mac_comp_empty(const void *a); 464struct hostapd_config * hostapd_config_defaults(void); 465void hostapd_config_defaults_bss(struct hostapd_bss_config *bss); 466void hostapd_config_free(struct hostapd_config *conf); 467int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries, 468 const u8 *addr, int *vlan_id); 469int hostapd_rate_found(int *list, int rate); 470int hostapd_wep_key_cmp(struct hostapd_wep_keys *a, 471 struct hostapd_wep_keys *b); 472const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf, 473 const u8 *addr, const u8 *prev_psk); 474int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf); 475const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, 476 int vlan_id); 477const struct hostapd_eap_user * 478hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity, 479 size_t identity_len, int phase2); 480struct hostapd_radius_attr * 481hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type); 482 483#endif /* HOSTAPD_CONFIG_H */ 484