ap_config.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. } secpolicy;
  41. struct hostapd_ssid {
  42. u8 ssid[HOSTAPD_MAX_SSID_LEN];
  43. size_t ssid_len;
  44. unsigned int ssid_set:1;
  45. unsigned int utf8_ssid:1;
  46. char vlan[IFNAMSIZ + 1];
  47. secpolicy security_policy;
  48. struct hostapd_wpa_psk *wpa_psk;
  49. char *wpa_passphrase;
  50. char *wpa_psk_file;
  51. struct hostapd_wep_keys wep;
  52. #define DYNAMIC_VLAN_DISABLED 0
  53. #define DYNAMIC_VLAN_OPTIONAL 1
  54. #define DYNAMIC_VLAN_REQUIRED 2
  55. int dynamic_vlan;
  56. #define DYNAMIC_VLAN_NAMING_WITHOUT_DEVICE 0
  57. #define DYNAMIC_VLAN_NAMING_WITH_DEVICE 1
  58. #define DYNAMIC_VLAN_NAMING_END 2
  59. int vlan_naming;
  60. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  61. char *vlan_tagged_interface;
  62. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  63. struct hostapd_wep_keys **dyn_vlan_keys;
  64. size_t max_dyn_vlan_keys;
  65. };
  66. #define VLAN_ID_WILDCARD -1
  67. struct hostapd_vlan {
  68. struct hostapd_vlan *next;
  69. int vlan_id; /* VLAN ID or -1 (VLAN_ID_WILDCARD) for wildcard entry */
  70. char ifname[IFNAMSIZ + 1];
  71. int dynamic_vlan;
  72. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  73. #define DVLAN_CLEAN_BR 0x1
  74. #define DVLAN_CLEAN_VLAN 0x2
  75. #define DVLAN_CLEAN_VLAN_PORT 0x4
  76. #define DVLAN_CLEAN_WLAN_PORT 0x8
  77. int clean;
  78. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  79. };
  80. #define PMK_LEN 32
  81. struct hostapd_sta_wpa_psk_short {
  82. struct hostapd_sta_wpa_psk_short *next;
  83. u8 psk[PMK_LEN];
  84. };
  85. struct hostapd_wpa_psk {
  86. struct hostapd_wpa_psk *next;
  87. int group;
  88. u8 psk[PMK_LEN];
  89. u8 addr[ETH_ALEN];
  90. };
  91. struct hostapd_eap_user {
  92. struct hostapd_eap_user *next;
  93. u8 *identity;
  94. size_t identity_len;
  95. struct {
  96. int vendor;
  97. u32 method;
  98. } methods[EAP_MAX_METHODS];
  99. u8 *password;
  100. size_t password_len;
  101. int phase2;
  102. int force_version;
  103. unsigned int wildcard_prefix:1;
  104. unsigned int password_hash:1; /* whether password is hashed with
  105. * nt_password_hash() */
  106. int ttls_auth; /* EAP_TTLS_AUTH_* bitfield */
  107. };
  108. struct hostapd_radius_attr {
  109. u8 type;
  110. struct wpabuf *val;
  111. struct hostapd_radius_attr *next;
  112. };
  113. #define NUM_TX_QUEUES 4
  114. struct hostapd_tx_queue_params {
  115. int aifs;
  116. int cwmin;
  117. int cwmax;
  118. int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
  119. };
  120. #define MAX_ROAMING_CONSORTIUM_LEN 15
  121. struct hostapd_roaming_consortium {
  122. u8 len;
  123. u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
  124. };
  125. struct hostapd_lang_string {
  126. u8 lang[3];
  127. u8 name_len;
  128. u8 name[252];
  129. };
  130. #define MAX_NAI_REALMS 10
  131. #define MAX_NAI_REALMLEN 255
  132. #define MAX_NAI_EAP_METHODS 5
  133. #define MAX_NAI_AUTH_TYPES 4
  134. struct hostapd_nai_realm_data {
  135. u8 encoding;
  136. char realm_buf[MAX_NAI_REALMLEN + 1];
  137. char *realm[MAX_NAI_REALMS];
  138. u8 eap_method_count;
  139. struct hostapd_nai_realm_eap {
  140. u8 eap_method;
  141. u8 num_auths;
  142. u8 auth_id[MAX_NAI_AUTH_TYPES];
  143. u8 auth_val[MAX_NAI_AUTH_TYPES];
  144. } eap_method[MAX_NAI_EAP_METHODS];
  145. };
  146. /**
  147. * struct hostapd_bss_config - Per-BSS configuration
  148. */
  149. struct hostapd_bss_config {
  150. char iface[IFNAMSIZ + 1];
  151. char bridge[IFNAMSIZ + 1];
  152. char wds_bridge[IFNAMSIZ + 1];
  153. enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
  154. unsigned int logger_syslog; /* module bitfield */
  155. unsigned int logger_stdout; /* module bitfield */
  156. char *dump_log_name; /* file name for state dump (SIGUSR1) */
  157. int max_num_sta; /* maximum number of STAs in station table */
  158. int dtim_period;
  159. int ieee802_1x; /* use IEEE 802.1X */
  160. int eapol_version;
  161. int eap_server; /* Use internal EAP server instead of external
  162. * RADIUS server */
  163. struct hostapd_eap_user *eap_user;
  164. char *eap_user_sqlite;
  165. char *eap_sim_db;
  166. struct hostapd_ip_addr own_ip_addr;
  167. char *nas_identifier;
  168. struct hostapd_radius_servers *radius;
  169. int acct_interim_interval;
  170. int radius_request_cui;
  171. struct hostapd_radius_attr *radius_auth_req_attr;
  172. struct hostapd_radius_attr *radius_acct_req_attr;
  173. int radius_das_port;
  174. unsigned int radius_das_time_window;
  175. int radius_das_require_event_timestamp;
  176. struct hostapd_ip_addr radius_das_client_addr;
  177. u8 *radius_das_shared_secret;
  178. size_t radius_das_shared_secret_len;
  179. struct hostapd_ssid ssid;
  180. char *eap_req_id_text; /* optional displayable message sent with
  181. * EAP Request-Identity */
  182. size_t eap_req_id_text_len;
  183. int eapol_key_index_workaround;
  184. size_t default_wep_key_len;
  185. int individual_wep_key_len;
  186. int wep_rekeying_period;
  187. int broadcast_key_idx_min, broadcast_key_idx_max;
  188. int eap_reauth_period;
  189. int ieee802_11f; /* use IEEE 802.11f (IAPP) */
  190. char iapp_iface[IFNAMSIZ + 1]; /* interface used with IAPP broadcast
  191. * frames */
  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. int wds_sta;
  202. int isolate;
  203. int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
  204. * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
  205. int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
  206. int wpa_key_mgmt;
  207. #ifdef CONFIG_IEEE80211W
  208. enum mfp_options ieee80211w;
  209. /* dot11AssociationSAQueryMaximumTimeout (in TUs) */
  210. unsigned int assoc_sa_query_max_timeout;
  211. /* dot11AssociationSAQueryRetryTimeout (in TUs) */
  212. int assoc_sa_query_retry_timeout;
  213. #endif /* CONFIG_IEEE80211W */
  214. enum {
  215. PSK_RADIUS_IGNORED = 0,
  216. PSK_RADIUS_ACCEPTED = 1,
  217. PSK_RADIUS_REQUIRED = 2
  218. } wpa_psk_radius;
  219. int wpa_pairwise;
  220. int wpa_group;
  221. int wpa_group_rekey;
  222. int wpa_strict_rekey;
  223. int wpa_gmk_rekey;
  224. int wpa_ptk_rekey;
  225. int rsn_pairwise;
  226. int rsn_preauth;
  227. char *rsn_preauth_interfaces;
  228. int peerkey;
  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. int ft_over_ds;
  239. #endif /* CONFIG_IEEE80211R */
  240. char *ctrl_interface; /* directory for UNIX domain sockets */
  241. #ifndef CONFIG_NATIVE_WINDOWS
  242. gid_t ctrl_interface_gid;
  243. #endif /* CONFIG_NATIVE_WINDOWS */
  244. int ctrl_interface_gid_set;
  245. char *ca_cert;
  246. char *server_cert;
  247. char *private_key;
  248. char *private_key_passwd;
  249. int check_crl;
  250. char *dh_file;
  251. u8 *pac_opaque_encr_key;
  252. u8 *eap_fast_a_id;
  253. size_t eap_fast_a_id_len;
  254. char *eap_fast_a_id_info;
  255. int eap_fast_prov;
  256. int pac_key_lifetime;
  257. int pac_key_refresh_time;
  258. int eap_sim_aka_result_ind;
  259. int tnc;
  260. int fragment_size;
  261. u16 pwd_group;
  262. char *radius_server_clients;
  263. int radius_server_auth_port;
  264. int radius_server_ipv6;
  265. char *test_socket; /* UNIX domain socket path for driver_test */
  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. int ap_max_inactivity;
  271. int ignore_broadcast_ssid;
  272. int wmm_enabled;
  273. int wmm_uapsd;
  274. struct hostapd_vlan *vlan, *vlan_tail;
  275. macaddr bssid;
  276. /*
  277. * Maximum listen interval that STAs can use when associating with this
  278. * BSS. If a STA tries to use larger value, the association will be
  279. * denied with status code 51.
  280. */
  281. u16 max_listen_interval;
  282. int disable_pmksa_caching;
  283. int okc; /* Opportunistic Key Caching */
  284. int wps_state;
  285. #ifdef CONFIG_WPS
  286. int wps_independent;
  287. int ap_setup_locked;
  288. u8 uuid[16];
  289. char *wps_pin_requests;
  290. char *device_name;
  291. char *manufacturer;
  292. char *model_name;
  293. char *model_number;
  294. char *serial_number;
  295. u8 device_type[WPS_DEV_TYPE_LEN];
  296. char *config_methods;
  297. u8 os_version[4];
  298. char *ap_pin;
  299. int skip_cred_build;
  300. u8 *extra_cred;
  301. size_t extra_cred_len;
  302. int wps_cred_processing;
  303. u8 *ap_settings;
  304. size_t ap_settings_len;
  305. char *upnp_iface;
  306. char *friendly_name;
  307. char *manufacturer_url;
  308. char *model_description;
  309. char *model_url;
  310. char *upc;
  311. struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
  312. int wps_nfc_pw_from_config;
  313. int wps_nfc_dev_pw_id;
  314. struct wpabuf *wps_nfc_dh_pubkey;
  315. struct wpabuf *wps_nfc_dh_privkey;
  316. struct wpabuf *wps_nfc_dev_pw;
  317. #endif /* CONFIG_WPS */
  318. int pbc_in_m1;
  319. #define P2P_ENABLED BIT(0)
  320. #define P2P_GROUP_OWNER BIT(1)
  321. #define P2P_GROUP_FORMATION BIT(2)
  322. #define P2P_MANAGE BIT(3)
  323. #define P2P_ALLOW_CROSS_CONNECTION BIT(4)
  324. int p2p;
  325. int disassoc_low_ack;
  326. int skip_inactivity_poll;
  327. #define TDLS_PROHIBIT BIT(0)
  328. #define TDLS_PROHIBIT_CHAN_SWITCH BIT(1)
  329. int tdls;
  330. int disable_11n;
  331. int disable_11ac;
  332. /* IEEE 802.11v */
  333. int time_advertisement;
  334. char *time_zone;
  335. int wnm_sleep_mode;
  336. int bss_transition;
  337. /* IEEE 802.11u - Interworking */
  338. int interworking;
  339. int access_network_type;
  340. int internet;
  341. int asra;
  342. int esr;
  343. int uesa;
  344. int venue_info_set;
  345. u8 venue_group;
  346. u8 venue_type;
  347. u8 hessid[ETH_ALEN];
  348. /* IEEE 802.11u - Roaming Consortium list */
  349. unsigned int roaming_consortium_count;
  350. struct hostapd_roaming_consortium *roaming_consortium;
  351. /* IEEE 802.11u - Venue Name duples */
  352. unsigned int venue_name_count;
  353. struct hostapd_lang_string *venue_name;
  354. /* IEEE 802.11u - Network Authentication Type */
  355. u8 *network_auth_type;
  356. size_t network_auth_type_len;
  357. /* IEEE 802.11u - IP Address Type Availability */
  358. u8 ipaddr_type_availability;
  359. u8 ipaddr_type_configured;
  360. /* IEEE 802.11u - 3GPP Cellular Network */
  361. u8 *anqp_3gpp_cell_net;
  362. size_t anqp_3gpp_cell_net_len;
  363. /* IEEE 802.11u - Domain Name */
  364. u8 *domain_name;
  365. size_t domain_name_len;
  366. unsigned int nai_realm_count;
  367. struct hostapd_nai_realm_data *nai_realm_data;
  368. u16 gas_comeback_delay;
  369. int gas_frag_limit;
  370. #ifdef CONFIG_HS20
  371. int hs20;
  372. int disable_dgaf;
  373. unsigned int hs20_oper_friendly_name_count;
  374. struct hostapd_lang_string *hs20_oper_friendly_name;
  375. u8 *hs20_wan_metrics;
  376. u8 *hs20_connection_capability;
  377. size_t hs20_connection_capability_len;
  378. u8 *hs20_operating_class;
  379. u8 hs20_operating_class_len;
  380. #endif /* CONFIG_HS20 */
  381. u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
  382. #ifdef CONFIG_RADIUS_TEST
  383. char *dump_msk_file;
  384. #endif /* CONFIG_RADIUS_TEST */
  385. struct wpabuf *vendor_elements;
  386. unsigned int sae_anti_clogging_threshold;
  387. int *sae_groups;
  388. };
  389. /**
  390. * struct hostapd_config - Per-radio interface configuration
  391. */
  392. struct hostapd_config {
  393. struct hostapd_bss_config *bss, *last_bss;
  394. size_t num_bss;
  395. u16 beacon_int;
  396. int rts_threshold;
  397. int fragm_threshold;
  398. u8 send_probe_response;
  399. u8 channel;
  400. enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
  401. enum {
  402. LONG_PREAMBLE = 0,
  403. SHORT_PREAMBLE = 1
  404. } preamble;
  405. int *supported_rates;
  406. int *basic_rates;
  407. const struct wpa_driver_ops *driver;
  408. int ap_table_max_size;
  409. int ap_table_expiration_time;
  410. char country[3]; /* first two octets: country code as described in
  411. * ISO/IEC 3166-1. Third octet:
  412. * ' ' (ascii 32): all environments
  413. * 'O': Outdoor environemnt only
  414. * 'I': Indoor environment only
  415. */
  416. int ieee80211d;
  417. struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES];
  418. /*
  419. * WMM AC parameters, in same order as 802.1D, i.e.
  420. * 0 = BE (best effort)
  421. * 1 = BK (background)
  422. * 2 = VI (video)
  423. * 3 = VO (voice)
  424. */
  425. struct hostapd_wmm_ac_params wmm_ac_params[4];
  426. int ht_op_mode_fixed;
  427. u16 ht_capab;
  428. int ieee80211n;
  429. int secondary_channel;
  430. int require_ht;
  431. u32 vht_capab;
  432. int ieee80211ac;
  433. int require_vht;
  434. u8 vht_oper_chwidth;
  435. u8 vht_oper_centr_freq_seg0_idx;
  436. u8 vht_oper_centr_freq_seg1_idx;
  437. #ifdef CONFIG_TESTING_OPTIONS
  438. double ignore_probe_probability;
  439. double ignore_auth_probability;
  440. double ignore_assoc_probability;
  441. double ignore_reassoc_probability;
  442. #endif /* CONFIG_TESTING_OPTIONS */
  443. };
  444. int hostapd_mac_comp(const void *a, const void *b);
  445. int hostapd_mac_comp_empty(const void *a);
  446. struct hostapd_config * hostapd_config_defaults(void);
  447. void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);
  448. void hostapd_config_free(struct hostapd_config *conf);
  449. int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
  450. const u8 *addr, int *vlan_id);
  451. int hostapd_rate_found(int *list, int rate);
  452. int hostapd_wep_key_cmp(struct hostapd_wep_keys *a,
  453. struct hostapd_wep_keys *b);
  454. const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
  455. const u8 *addr, const u8 *prev_psk);
  456. int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf);
  457. const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
  458. int vlan_id);
  459. struct hostapd_radius_attr *
  460. hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type);
  461. #endif /* HOSTAPD_CONFIG_H */