ap_config.h 12 KB

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