hostapd.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. int (*set_bss_params)(struct hostapd_data *hapd, int use_protection);
  64. int (*set_beacon)(const char *ifname, struct hostapd_data *hapd,
  65. const u8 *head, size_t head_len,
  66. const u8 *tail, size_t tail_len, int dtim_period,
  67. int beacon_int);
  68. int (*vlan_if_add)(struct hostapd_data *hapd, const char *ifname);
  69. int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname);
  70. };
  71. /**
  72. * struct hostapd_data - hostapd per-BSS data structure
  73. */
  74. struct hostapd_data {
  75. struct hostapd_iface *iface;
  76. struct hostapd_config *iconf;
  77. struct hostapd_bss_config *conf;
  78. int interface_added; /* virtual interface added for this BSS */
  79. u8 own_addr[ETH_ALEN];
  80. int num_sta; /* number of entries in sta_list */
  81. struct sta_info *sta_list; /* STA info list head */
  82. #define STA_HASH_SIZE 256
  83. #define STA_HASH(sta) (sta[5])
  84. struct sta_info *sta_hash[STA_HASH_SIZE];
  85. /*
  86. * Bitfield for indicating which AIDs are allocated. Only AID values
  87. * 1-2007 are used and as such, the bit at index 0 corresponds to AID
  88. * 1.
  89. */
  90. #define AID_WORDS ((2008 + 31) / 32)
  91. u32 sta_aid[AID_WORDS];
  92. const struct wpa_driver_ops *driver;
  93. void *drv_priv;
  94. struct hostapd_driver_ops drv;
  95. void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
  96. struct sta_info *sta, int reassoc);
  97. void *msg_ctx; /* ctx for wpa_msg() calls */
  98. struct radius_client_data *radius;
  99. u32 acct_session_id_hi, acct_session_id_lo;
  100. struct iapp_data *iapp;
  101. struct hostapd_cached_radius_acl *acl_cache;
  102. struct hostapd_acl_query_data *acl_queries;
  103. struct wpa_authenticator *wpa_auth;
  104. struct eapol_authenticator *eapol_auth;
  105. struct rsn_preauth_interface *preauth_iface;
  106. time_t michael_mic_failure;
  107. int michael_mic_failures;
  108. int tkip_countermeasures;
  109. int ctrl_sock;
  110. struct wpa_ctrl_dst *ctrl_dst;
  111. void *ssl_ctx;
  112. void *eap_sim_db_priv;
  113. struct radius_server_data *radius_srv;
  114. int parameter_set_count;
  115. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  116. struct full_dynamic_vlan *full_dynamic_vlan;
  117. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  118. struct l2_packet_data *l2;
  119. struct wps_context *wps;
  120. #ifdef CONFIG_WPS
  121. struct wpabuf *wps_beacon_ie;
  122. struct wpabuf *wps_probe_resp_ie;
  123. unsigned int ap_pin_failures;
  124. struct upnp_wps_device_sm *wps_upnp;
  125. #endif /* CONFIG_WPS */
  126. struct hostapd_probereq_cb *probereq_cb;
  127. size_t num_probereq_cb;
  128. };
  129. /**
  130. * struct hostapd_iface - hostapd per-interface data structure
  131. */
  132. struct hostapd_iface {
  133. struct hapd_interfaces *interfaces;
  134. void *owner;
  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. u16 hw_flags;
  152. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  153. * in 802.11g BSS) */
  154. int num_sta_non_erp;
  155. /* Number of associated stations that do not support Short Slot Time */
  156. int num_sta_no_short_slot_time;
  157. /* Number of associated stations that do not support Short Preamble */
  158. int num_sta_no_short_preamble;
  159. int olbc; /* Overlapping Legacy BSS Condition */
  160. /* Number of HT associated stations that do not support greenfield */
  161. int num_sta_ht_no_gf;
  162. /* Number of associated non-HT stations */
  163. int num_sta_no_ht;
  164. /* Number of HT associated stations 20 MHz */
  165. int num_sta_ht_20mhz;
  166. /* Overlapping BSS information */
  167. int olbc_ht;
  168. u16 ht_op_mode;
  169. void (*scan_cb)(struct hostapd_iface *iface);
  170. };
  171. int hostapd_reload_config(struct hostapd_iface *iface);
  172. struct hostapd_data *
  173. hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
  174. struct hostapd_config *conf,
  175. struct hostapd_bss_config *bss);
  176. int hostapd_setup_interface(struct hostapd_iface *iface);
  177. int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
  178. void hostapd_interface_deinit(struct hostapd_iface *iface);
  179. int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
  180. int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
  181. int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
  182. int (*cb)(struct hostapd_iface *iface,
  183. void *ctx), void *ctx);
  184. int hostapd_register_probereq_cb(struct hostapd_data *hapd,
  185. void (*cb)(void *ctx, const u8 *sa,
  186. const u8 *ie, size_t ie_len),
  187. void *ctx);
  188. int eap_server_register_methods(void);
  189. void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
  190. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  191. int reassoc);
  192. #endif /* HOSTAPD_H */