hostapd.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  26. struct full_dynamic_vlan;
  27. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  28. struct hostapd_probereq_cb {
  29. void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
  30. void *ctx;
  31. };
  32. #define HOSTAPD_RATE_BASIC 0x00000001
  33. struct hostapd_rate_data {
  34. int rate; /* rate in 100 kbps */
  35. int flags; /* HOSTAPD_RATE_ flags */
  36. };
  37. struct hostapd_driver_ops {
  38. int (*set_ap_wps_ie)(struct hostapd_data *hapd,
  39. const struct wpabuf *beacon,
  40. const struct wpabuf *probe);
  41. int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
  42. size_t len);
  43. int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
  44. const u8 *data, size_t data_len, int encrypt);
  45. int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
  46. int authorized);
  47. int (*set_key)(const char *ifname, struct hostapd_data *hapd,
  48. wpa_alg alg, const u8 *addr, int key_idx,
  49. int set_tx, const u8 *seq, size_t seq_len,
  50. const u8 *key, size_t key_len);
  51. int (*read_sta_data)(struct hostapd_data *hapd,
  52. struct hostap_sta_driver_data *data,
  53. const u8 *addr);
  54. int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr);
  55. int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta);
  56. int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname,
  57. int enabled);
  58. int (*set_radius_acl_auth)(struct hostapd_data *hapd,
  59. const u8 *mac, int accepted,
  60. u32 session_timeout);
  61. int (*set_radius_acl_expire)(struct hostapd_data *hapd,
  62. const u8 *mac);
  63. };
  64. /**
  65. * struct hostapd_data - hostapd per-BSS data structure
  66. */
  67. struct hostapd_data {
  68. struct hostapd_iface *iface;
  69. struct hostapd_config *iconf;
  70. struct hostapd_bss_config *conf;
  71. int interface_added; /* virtual interface added for this BSS */
  72. u8 own_addr[ETH_ALEN];
  73. int num_sta; /* number of entries in sta_list */
  74. struct sta_info *sta_list; /* STA info list head */
  75. #define STA_HASH_SIZE 256
  76. #define STA_HASH(sta) (sta[5])
  77. struct sta_info *sta_hash[STA_HASH_SIZE];
  78. /*
  79. * Bitfield for indicating which AIDs are allocated. Only AID values
  80. * 1-2007 are used and as such, the bit at index 0 corresponds to AID
  81. * 1.
  82. */
  83. #define AID_WORDS ((2008 + 31) / 32)
  84. u32 sta_aid[AID_WORDS];
  85. const struct wpa_driver_ops *driver;
  86. void *drv_priv;
  87. struct hostapd_driver_ops drv;
  88. void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
  89. struct sta_info *sta, int reassoc);
  90. void *msg_ctx; /* ctx for wpa_msg() calls */
  91. struct radius_client_data *radius;
  92. u32 acct_session_id_hi, acct_session_id_lo;
  93. struct iapp_data *iapp;
  94. struct hostapd_cached_radius_acl *acl_cache;
  95. struct hostapd_acl_query_data *acl_queries;
  96. struct wpa_authenticator *wpa_auth;
  97. struct eapol_authenticator *eapol_auth;
  98. struct rsn_preauth_interface *preauth_iface;
  99. time_t michael_mic_failure;
  100. int michael_mic_failures;
  101. int tkip_countermeasures;
  102. int ctrl_sock;
  103. struct wpa_ctrl_dst *ctrl_dst;
  104. void *ssl_ctx;
  105. void *eap_sim_db_priv;
  106. struct radius_server_data *radius_srv;
  107. int parameter_set_count;
  108. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  109. struct full_dynamic_vlan *full_dynamic_vlan;
  110. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  111. struct l2_packet_data *l2;
  112. struct wps_context *wps;
  113. #ifdef CONFIG_WPS
  114. struct wpabuf *wps_beacon_ie;
  115. struct wpabuf *wps_probe_resp_ie;
  116. unsigned int ap_pin_failures;
  117. struct upnp_wps_device_sm *wps_upnp;
  118. #endif /* CONFIG_WPS */
  119. struct hostapd_probereq_cb *probereq_cb;
  120. size_t num_probereq_cb;
  121. };
  122. /**
  123. * struct hostapd_iface - hostapd per-interface data structure
  124. */
  125. struct hostapd_iface {
  126. struct hapd_interfaces *interfaces;
  127. void *owner;
  128. struct hostapd_config * (*config_read_cb)(const char *config_fname);
  129. char *config_fname;
  130. struct hostapd_config *conf;
  131. size_t num_bss;
  132. struct hostapd_data **bss;
  133. int num_ap; /* number of entries in ap_list */
  134. struct ap_info *ap_list; /* AP info list head */
  135. struct ap_info *ap_hash[STA_HASH_SIZE];
  136. struct ap_info *ap_iter_list;
  137. struct hostapd_hw_modes *hw_features;
  138. int num_hw_features;
  139. struct hostapd_hw_modes *current_mode;
  140. /* Rates that are currently used (i.e., filtered copy of
  141. * current_mode->channels */
  142. int num_rates;
  143. struct hostapd_rate_data *current_rates;
  144. u16 hw_flags;
  145. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  146. * in 802.11g BSS) */
  147. int num_sta_non_erp;
  148. /* Number of associated stations that do not support Short Slot Time */
  149. int num_sta_no_short_slot_time;
  150. /* Number of associated stations that do not support Short Preamble */
  151. int num_sta_no_short_preamble;
  152. int olbc; /* Overlapping Legacy BSS Condition */
  153. /* Number of HT associated stations that do not support greenfield */
  154. int num_sta_ht_no_gf;
  155. /* Number of associated non-HT stations */
  156. int num_sta_no_ht;
  157. /* Number of HT associated stations 20 MHz */
  158. int num_sta_ht_20mhz;
  159. /* Overlapping BSS information */
  160. int olbc_ht;
  161. u16 ht_op_mode;
  162. void (*scan_cb)(struct hostapd_iface *iface);
  163. };
  164. int hostapd_reload_config(struct hostapd_iface *iface);
  165. struct hostapd_data *
  166. hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
  167. struct hostapd_config *conf,
  168. struct hostapd_bss_config *bss);
  169. int hostapd_setup_interface(struct hostapd_iface *iface);
  170. int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
  171. void hostapd_interface_deinit(struct hostapd_iface *iface);
  172. int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
  173. int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
  174. int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
  175. int (*cb)(struct hostapd_iface *iface,
  176. void *ctx), void *ctx);
  177. int hostapd_register_probereq_cb(struct hostapd_data *hapd,
  178. void (*cb)(void *ctx, const u8 *sa,
  179. const u8 *ie, size_t ie_len),
  180. void *ctx);
  181. int eap_server_register_methods(void);
  182. void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
  183. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  184. int reassoc);
  185. #endif /* HOSTAPD_H */