hostapd.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * hostapd / Initialization and configuration
  3. * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef HOSTAPD_H
  15. #define HOSTAPD_H
  16. #include "common/defs.h"
  17. struct wpa_driver_ops;
  18. struct wpa_ctrl_dst;
  19. struct radius_server_data;
  20. struct upnp_wps_device_sm;
  21. struct hapd_interfaces;
  22. struct hostapd_data;
  23. struct sta_info;
  24. struct hostap_sta_driver_data;
  25. struct ieee80211_ht_capabilities;
  26. struct full_dynamic_vlan;
  27. struct hostapd_probereq_cb {
  28. void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
  29. void *ctx;
  30. };
  31. #define HOSTAPD_RATE_BASIC 0x00000001
  32. struct hostapd_rate_data {
  33. int rate; /* rate in 100 kbps */
  34. int flags; /* HOSTAPD_RATE_ flags */
  35. };
  36. struct hostapd_driver_ops {
  37. int (*set_ap_wps_ie)(struct hostapd_data *hapd,
  38. const struct wpabuf *beacon,
  39. const struct wpabuf *probe);
  40. int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
  41. size_t len);
  42. int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
  43. const u8 *data, size_t data_len, int encrypt);
  44. int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
  45. int authorized);
  46. int (*set_key)(const char *ifname, struct hostapd_data *hapd,
  47. wpa_alg alg, const u8 *addr, int key_idx,
  48. int set_tx, const u8 *seq, size_t seq_len,
  49. const u8 *key, size_t key_len);
  50. int (*read_sta_data)(struct hostapd_data *hapd,
  51. struct hostap_sta_driver_data *data,
  52. const u8 *addr);
  53. int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr);
  54. int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta);
  55. int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname,
  56. int enabled);
  57. int (*set_radius_acl_auth)(struct hostapd_data *hapd,
  58. const u8 *mac, int accepted,
  59. u32 session_timeout);
  60. int (*set_radius_acl_expire)(struct hostapd_data *hapd,
  61. const u8 *mac);
  62. int (*set_bss_params)(struct hostapd_data *hapd, int use_protection);
  63. int (*set_beacon)(const char *ifname, struct hostapd_data *hapd,
  64. const u8 *head, size_t head_len,
  65. const u8 *tail, size_t tail_len, int dtim_period,
  66. int beacon_int);
  67. int (*vlan_if_add)(struct hostapd_data *hapd, const char *ifname);
  68. int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname);
  69. int (*set_wds_sta)(struct hostapd_data *hapd, const u8 *addr, int aid,
  70. int val);
  71. int (*set_sta_vlan)(const char *ifname, struct hostapd_data *hapd,
  72. const u8 *addr, int vlan_id);
  73. int (*get_inact_sec)(struct hostapd_data *hapd, const u8 *addr);
  74. int (*sta_deauth)(struct hostapd_data *hapd, const u8 *addr,
  75. int reason);
  76. int (*sta_disassoc)(struct hostapd_data *hapd, const u8 *addr,
  77. int reason);
  78. int (*sta_add)(const char *ifname, struct hostapd_data *hapd,
  79. const u8 *addr, u16 aid, u16 capability,
  80. const u8 *supp_rates, size_t supp_rates_len,
  81. u16 listen_interval,
  82. const struct ieee80211_ht_capabilities *ht_capab);
  83. int (*sta_remove)(struct hostapd_data *hapd, const u8 *addr);
  84. };
  85. /**
  86. * struct hostapd_data - hostapd per-BSS data structure
  87. */
  88. struct hostapd_data {
  89. struct hostapd_iface *iface;
  90. struct hostapd_config *iconf;
  91. struct hostapd_bss_config *conf;
  92. int interface_added; /* virtual interface added for this BSS */
  93. u8 own_addr[ETH_ALEN];
  94. int num_sta; /* number of entries in sta_list */
  95. struct sta_info *sta_list; /* STA info list head */
  96. #define STA_HASH_SIZE 256
  97. #define STA_HASH(sta) (sta[5])
  98. struct sta_info *sta_hash[STA_HASH_SIZE];
  99. /*
  100. * Bitfield for indicating which AIDs are allocated. Only AID values
  101. * 1-2007 are used and as such, the bit at index 0 corresponds to AID
  102. * 1.
  103. */
  104. #define AID_WORDS ((2008 + 31) / 32)
  105. u32 sta_aid[AID_WORDS];
  106. const struct wpa_driver_ops *driver;
  107. void *drv_priv;
  108. struct hostapd_driver_ops drv;
  109. void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
  110. struct sta_info *sta, int reassoc);
  111. void *msg_ctx; /* ctx for wpa_msg() calls */
  112. struct radius_client_data *radius;
  113. u32 acct_session_id_hi, acct_session_id_lo;
  114. struct iapp_data *iapp;
  115. struct hostapd_cached_radius_acl *acl_cache;
  116. struct hostapd_acl_query_data *acl_queries;
  117. struct wpa_authenticator *wpa_auth;
  118. struct eapol_authenticator *eapol_auth;
  119. struct rsn_preauth_interface *preauth_iface;
  120. time_t michael_mic_failure;
  121. int michael_mic_failures;
  122. int tkip_countermeasures;
  123. int ctrl_sock;
  124. struct wpa_ctrl_dst *ctrl_dst;
  125. void *ssl_ctx;
  126. void *eap_sim_db_priv;
  127. struct radius_server_data *radius_srv;
  128. int parameter_set_count;
  129. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  130. struct full_dynamic_vlan *full_dynamic_vlan;
  131. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  132. struct l2_packet_data *l2;
  133. struct wps_context *wps;
  134. #ifdef CONFIG_WPS
  135. struct wpabuf *wps_beacon_ie;
  136. struct wpabuf *wps_probe_resp_ie;
  137. unsigned int ap_pin_failures;
  138. struct upnp_wps_device_sm *wps_upnp;
  139. #endif /* CONFIG_WPS */
  140. struct hostapd_probereq_cb *probereq_cb;
  141. size_t num_probereq_cb;
  142. };
  143. /**
  144. * struct hostapd_iface - hostapd per-interface data structure
  145. */
  146. struct hostapd_iface {
  147. struct hapd_interfaces *interfaces;
  148. void *owner;
  149. struct hostapd_config * (*config_read_cb)(const char *config_fname);
  150. char *config_fname;
  151. struct hostapd_config *conf;
  152. size_t num_bss;
  153. struct hostapd_data **bss;
  154. int num_ap; /* number of entries in ap_list */
  155. struct ap_info *ap_list; /* AP info list head */
  156. struct ap_info *ap_hash[STA_HASH_SIZE];
  157. struct ap_info *ap_iter_list;
  158. struct hostapd_hw_modes *hw_features;
  159. int num_hw_features;
  160. struct hostapd_hw_modes *current_mode;
  161. /* Rates that are currently used (i.e., filtered copy of
  162. * current_mode->channels */
  163. int num_rates;
  164. struct hostapd_rate_data *current_rates;
  165. u16 hw_flags;
  166. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  167. * in 802.11g BSS) */
  168. int num_sta_non_erp;
  169. /* Number of associated stations that do not support Short Slot Time */
  170. int num_sta_no_short_slot_time;
  171. /* Number of associated stations that do not support Short Preamble */
  172. int num_sta_no_short_preamble;
  173. int olbc; /* Overlapping Legacy BSS Condition */
  174. /* Number of HT associated stations that do not support greenfield */
  175. int num_sta_ht_no_gf;
  176. /* Number of associated non-HT stations */
  177. int num_sta_no_ht;
  178. /* Number of HT associated stations 20 MHz */
  179. int num_sta_ht_20mhz;
  180. /* Overlapping BSS information */
  181. int olbc_ht;
  182. u16 ht_op_mode;
  183. void (*scan_cb)(struct hostapd_iface *iface);
  184. };
  185. int hostapd_reload_config(struct hostapd_iface *iface);
  186. struct hostapd_data *
  187. hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
  188. struct hostapd_config *conf,
  189. struct hostapd_bss_config *bss);
  190. int hostapd_setup_interface(struct hostapd_iface *iface);
  191. int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
  192. void hostapd_interface_deinit(struct hostapd_iface *iface);
  193. int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
  194. int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
  195. int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
  196. int (*cb)(struct hostapd_iface *iface,
  197. void *ctx), void *ctx);
  198. int hostapd_register_probereq_cb(struct hostapd_data *hapd,
  199. void (*cb)(void *ctx, const u8 *sa,
  200. const u8 *ie, size_t ie_len),
  201. void *ctx);
  202. int eap_server_register_methods(void);
  203. void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
  204. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  205. int reassoc);
  206. #endif /* HOSTAPD_H */