ap_config.h 12 KB

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