Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. void (*setup_complete_cb)(void *ctx);
  116. void *setup_complete_cb_ctx;
  117. #ifdef CONFIG_P2P
  118. struct p2p_data *p2p;
  119. struct p2p_group *p2p_group;
  120. struct wpabuf *p2p_beacon_ie;
  121. struct wpabuf *p2p_probe_resp_ie;
  122. /* Number of non-P2P association stations */
  123. int num_sta_no_p2p;
  124. /* Periodic NoA (used only when no non-P2P clients in the group) */
  125. int noa_enabled;
  126. int noa_start;
  127. int noa_duration;
  128. #endif /* CONFIG_P2P */
  129. };
  130. /**
  131. * struct hostapd_iface - hostapd per-interface data structure
  132. */
  133. struct hostapd_iface {
  134. struct hapd_interfaces *interfaces;
  135. void *owner;
  136. int (*reload_config)(struct hostapd_iface *iface);
  137. struct hostapd_config * (*config_read_cb)(const char *config_fname);
  138. char *config_fname;
  139. struct hostapd_config *conf;
  140. size_t num_bss;
  141. struct hostapd_data **bss;
  142. int num_ap; /* number of entries in ap_list */
  143. struct ap_info *ap_list; /* AP info list head */
  144. struct ap_info *ap_hash[STA_HASH_SIZE];
  145. struct ap_info *ap_iter_list;
  146. unsigned int drv_flags;
  147. struct hostapd_hw_modes *hw_features;
  148. int num_hw_features;
  149. struct hostapd_hw_modes *current_mode;
  150. /* Rates that are currently used (i.e., filtered copy of
  151. * current_mode->channels */
  152. int num_rates;
  153. struct hostapd_rate_data *current_rates;
  154. int freq;
  155. u16 hw_flags;
  156. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  157. * in 802.11g BSS) */
  158. int num_sta_non_erp;
  159. /* Number of associated stations that do not support Short Slot Time */
  160. int num_sta_no_short_slot_time;
  161. /* Number of associated stations that do not support Short Preamble */
  162. int num_sta_no_short_preamble;
  163. int olbc; /* Overlapping Legacy BSS Condition */
  164. /* Number of HT associated stations that do not support greenfield */
  165. int num_sta_ht_no_gf;
  166. /* Number of associated non-HT stations */
  167. int num_sta_no_ht;
  168. /* Number of HT associated stations 20 MHz */
  169. int num_sta_ht_20mhz;
  170. /* Overlapping BSS information */
  171. int olbc_ht;
  172. u16 ht_op_mode;
  173. void (*scan_cb)(struct hostapd_iface *iface);
  174. int (*ctrl_iface_init)(struct hostapd_data *hapd);
  175. void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
  176. int (*for_each_interface)(struct hapd_interfaces *interfaces,
  177. int (*cb)(struct hostapd_iface *iface,
  178. void *ctx), void *ctx);
  179. };
  180. /* hostapd.c */
  181. int hostapd_reload_config(struct hostapd_iface *iface);
  182. struct hostapd_data *
  183. hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
  184. struct hostapd_config *conf,
  185. struct hostapd_bss_config *bss);
  186. int hostapd_setup_interface(struct hostapd_iface *iface);
  187. int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
  188. void hostapd_interface_deinit(struct hostapd_iface *iface);
  189. void hostapd_interface_free(struct hostapd_iface *iface);
  190. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  191. int reassoc);
  192. /* utils.c */
  193. int hostapd_register_probereq_cb(struct hostapd_data *hapd,
  194. int (*cb)(void *ctx, const u8 *sa,
  195. const u8 *ie, size_t ie_len),
  196. void *ctx);
  197. void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
  198. /* drv_callbacks.c (TODO: move to somewhere else?) */
  199. int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
  200. const u8 *ie, size_t ielen, int reassoc);
  201. void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
  202. void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
  203. int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
  204. const u8 *ie, size_t ie_len);
  205. #endif /* HOSTAPD_H */