hostapd.h 5.4 KB

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