ap_config.h 15 KB

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