hostapd.h 5.9 KB

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