hostapd.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. enum wps_event;
  28. union wps_event_data;
  29. struct hostapd_probereq_cb {
  30. int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
  31. void *ctx;
  32. };
  33. #define HOSTAPD_RATE_BASIC 0x00000001
  34. struct hostapd_rate_data {
  35. int rate; /* rate in 100 kbps */
  36. int flags; /* HOSTAPD_RATE_ flags */
  37. };
  38. struct hostapd_frame_info {
  39. u32 channel;
  40. u32 datarate;
  41. u32 ssi_signal;
  42. };
  43. /**
  44. * struct hostapd_data - hostapd per-BSS data structure
  45. */
  46. struct hostapd_data {
  47. struct hostapd_iface *iface;
  48. struct hostapd_config *iconf;
  49. struct hostapd_bss_config *conf;
  50. int interface_added; /* virtual interface added for this BSS */
  51. u8 own_addr[ETH_ALEN];
  52. int num_sta; /* number of entries in sta_list */
  53. struct sta_info *sta_list; /* STA info list head */
  54. #define STA_HASH_SIZE 256
  55. #define STA_HASH(sta) (sta[5])
  56. struct sta_info *sta_hash[STA_HASH_SIZE];
  57. /*
  58. * Bitfield for indicating which AIDs are allocated. Only AID values
  59. * 1-2007 are used and as such, the bit at index 0 corresponds to AID
  60. * 1.
  61. */
  62. #define AID_WORDS ((2008 + 31) / 32)
  63. u32 sta_aid[AID_WORDS];
  64. const struct wpa_driver_ops *driver;
  65. void *drv_priv;
  66. void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
  67. struct sta_info *sta, int reassoc);
  68. void *msg_ctx; /* ctx for wpa_msg() calls */
  69. struct radius_client_data *radius;
  70. u32 acct_session_id_hi, acct_session_id_lo;
  71. struct iapp_data *iapp;
  72. struct hostapd_cached_radius_acl *acl_cache;
  73. struct hostapd_acl_query_data *acl_queries;
  74. struct wpa_authenticator *wpa_auth;
  75. struct eapol_authenticator *eapol_auth;
  76. struct rsn_preauth_interface *preauth_iface;
  77. time_t michael_mic_failure;
  78. int michael_mic_failures;
  79. int tkip_countermeasures;
  80. int ctrl_sock;
  81. struct wpa_ctrl_dst *ctrl_dst;
  82. void *ssl_ctx;
  83. void *eap_sim_db_priv;
  84. struct radius_server_data *radius_srv;
  85. int parameter_set_count;
  86. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  87. struct full_dynamic_vlan *full_dynamic_vlan;
  88. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  89. struct l2_packet_data *l2;
  90. struct wps_context *wps;
  91. struct wpabuf *wps_beacon_ie;
  92. struct wpabuf *wps_probe_resp_ie;
  93. #ifdef CONFIG_WPS
  94. unsigned int ap_pin_failures;
  95. struct upnp_wps_device_sm *wps_upnp;
  96. unsigned int ap_pin_lockout_time;
  97. #endif /* CONFIG_WPS */
  98. struct hostapd_probereq_cb *probereq_cb;
  99. size_t num_probereq_cb;
  100. void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
  101. int freq);
  102. void *public_action_cb_ctx;
  103. int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
  104. int freq);
  105. void *vendor_action_cb_ctx;
  106. void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
  107. const u8 *uuid_e);
  108. void *wps_reg_success_cb_ctx;
  109. void (*wps_event_cb)(void *ctx, enum wps_event event,
  110. union wps_event_data *data);
  111. void *wps_event_cb_ctx;
  112. void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
  113. int authorized);
  114. void *sta_authorized_cb_ctx;
  115. #ifdef CONFIG_P2P
  116. struct p2p_data *p2p;
  117. struct p2p_group *p2p_group;
  118. struct wpabuf *p2p_beacon_ie;
  119. struct wpabuf *p2p_probe_resp_ie;
  120. /* Number of non-P2P association stations */
  121. int num_sta_no_p2p;
  122. /* Periodic NoA (used only when no non-P2P clients in the group) */
  123. int noa_enabled;
  124. int noa_start;
  125. int noa_duration;
  126. #endif /* CONFIG_P2P */
  127. };
  128. /**
  129. * struct hostapd_iface - hostapd per-interface data structure
  130. */
  131. struct hostapd_iface {
  132. struct hapd_interfaces *interfaces;
  133. void *owner;
  134. int (*reload_config)(struct hostapd_iface *iface);
  135. struct hostapd_config * (*config_read_cb)(const char *config_fname);
  136. char *config_fname;
  137. struct hostapd_config *conf;
  138. size_t num_bss;
  139. struct hostapd_data **bss;
  140. int num_ap; /* number of entries in ap_list */
  141. struct ap_info *ap_list; /* AP info list head */
  142. struct ap_info *ap_hash[STA_HASH_SIZE];
  143. struct ap_info *ap_iter_list;
  144. struct hostapd_hw_modes *hw_features;
  145. int num_hw_features;
  146. struct hostapd_hw_modes *current_mode;
  147. /* Rates that are currently used (i.e., filtered copy of
  148. * current_mode->channels */
  149. int num_rates;
  150. struct hostapd_rate_data *current_rates;
  151. int freq;
  152. u16 hw_flags;
  153. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  154. * in 802.11g BSS) */
  155. int num_sta_non_erp;
  156. /* Number of associated stations that do not support Short Slot Time */
  157. int num_sta_no_short_slot_time;
  158. /* Number of associated stations that do not support Short Preamble */
  159. int num_sta_no_short_preamble;
  160. int olbc; /* Overlapping Legacy BSS Condition */
  161. /* Number of HT associated stations that do not support greenfield */
  162. int num_sta_ht_no_gf;
  163. /* Number of associated non-HT stations */
  164. int num_sta_no_ht;
  165. /* Number of HT associated stations 20 MHz */
  166. int num_sta_ht_20mhz;
  167. /* Overlapping BSS information */
  168. int olbc_ht;
  169. u16 ht_op_mode;
  170. void (*scan_cb)(struct hostapd_iface *iface);
  171. int (*ctrl_iface_init)(struct hostapd_data *hapd);
  172. void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
  173. int (*for_each_interface)(struct hapd_interfaces *interfaces,
  174. int (*cb)(struct hostapd_iface *iface,
  175. void *ctx), void *ctx);
  176. };
  177. /* hostapd.c */
  178. int hostapd_reload_config(struct hostapd_iface *iface);
  179. struct hostapd_data *
  180. hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
  181. struct hostapd_config *conf,
  182. struct hostapd_bss_config *bss);
  183. int hostapd_setup_interface(struct hostapd_iface *iface);
  184. int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
  185. void hostapd_interface_deinit(struct hostapd_iface *iface);
  186. void hostapd_interface_free(struct hostapd_iface *iface);
  187. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  188. int reassoc);
  189. /* utils.c */
  190. int hostapd_register_probereq_cb(struct hostapd_data *hapd,
  191. int (*cb)(void *ctx, const u8 *sa,
  192. const u8 *ie, size_t ie_len),
  193. void *ctx);
  194. void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
  195. /* drv_callbacks.c (TODO: move to somewhere else?) */
  196. int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
  197. const u8 *ie, size_t ielen);
  198. void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
  199. void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
  200. int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
  201. const u8 *ie, size_t ie_len);
  202. #endif /* HOSTAPD_H */