hostapd.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * hostapd / Initialization and configuration
  3. * Host AP kernel driver
  4. * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
  5. * Copyright (c) 2007-2008, Intel Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * Alternatively, this software may be distributed under the terms of BSD
  12. * license.
  13. *
  14. * See README and COPYING for more details.
  15. */
  16. #ifndef HOSTAPD_H
  17. #define HOSTAPD_H
  18. #include "common.h"
  19. #include "ap.h"
  20. #ifndef ETH_ALEN
  21. #define ETH_ALEN 6
  22. #endif
  23. #ifndef IFNAMSIZ
  24. #define IFNAMSIZ 16
  25. #endif
  26. #ifndef ETH_P_ALL
  27. #define ETH_P_ALL 0x0003
  28. #endif
  29. #ifndef ETH_P_PAE
  30. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  31. #endif /* ETH_P_PAE */
  32. #ifndef ETH_P_EAPOL
  33. #define ETH_P_EAPOL ETH_P_PAE
  34. #endif /* ETH_P_EAPOL */
  35. #ifndef ETH_P_RRB
  36. #define ETH_P_RRB 0x890D
  37. #endif /* ETH_P_RRB */
  38. #include "config.h"
  39. #ifdef _MSC_VER
  40. #pragma pack(push, 1)
  41. #endif /* _MSC_VER */
  42. #define MAX_VLAN_ID 4094
  43. struct ieee8023_hdr {
  44. u8 dest[6];
  45. u8 src[6];
  46. u16 ethertype;
  47. } STRUCT_PACKED;
  48. struct ieee80211_hdr {
  49. le16 frame_control;
  50. le16 duration_id;
  51. u8 addr1[6];
  52. u8 addr2[6];
  53. u8 addr3[6];
  54. le16 seq_ctrl;
  55. /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
  56. */
  57. } STRUCT_PACKED;
  58. #ifdef _MSC_VER
  59. #pragma pack(pop)
  60. #endif /* _MSC_VER */
  61. #define IEEE80211_DA_FROMDS addr1
  62. #define IEEE80211_BSSID_FROMDS addr2
  63. #define IEEE80211_SA_FROMDS addr3
  64. #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
  65. #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
  66. /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
  67. * frames that might be longer than normal default MTU and they are not
  68. * fragmented */
  69. #define HOSTAPD_MTU 2290
  70. extern unsigned char rfc1042_header[6];
  71. struct hostap_sta_driver_data {
  72. unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
  73. unsigned long current_tx_rate;
  74. unsigned long inactive_msec;
  75. unsigned long flags;
  76. unsigned long num_ps_buf_frames;
  77. unsigned long tx_retry_failed;
  78. unsigned long tx_retry_count;
  79. int last_rssi;
  80. int last_ack_rssi;
  81. };
  82. struct wpa_driver_ops;
  83. struct wpa_ctrl_dst;
  84. struct radius_server_data;
  85. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  86. struct full_dynamic_vlan;
  87. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  88. /**
  89. * struct hostapd_data - hostapd per-BSS data structure
  90. */
  91. struct hostapd_data {
  92. struct hostapd_iface *iface;
  93. struct hostapd_config *iconf;
  94. struct hostapd_bss_config *conf;
  95. int interface_added; /* virtual interface added for this BSS */
  96. u8 own_addr[ETH_ALEN];
  97. int num_sta; /* number of entries in sta_list */
  98. struct sta_info *sta_list; /* STA info list head */
  99. struct sta_info *sta_hash[STA_HASH_SIZE];
  100. /* pointers to STA info; based on allocated AID or NULL if AID free
  101. * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
  102. * and so on
  103. */
  104. struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
  105. const struct wpa_driver_ops *driver;
  106. void *drv_priv;
  107. u8 *default_wep_key;
  108. u8 default_wep_key_idx;
  109. struct radius_client_data *radius;
  110. int radius_client_reconfigured;
  111. u32 acct_session_id_hi, acct_session_id_lo;
  112. struct iapp_data *iapp;
  113. enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
  114. ASSOCIATED } assoc_ap_state;
  115. char assoc_ap_ssid[33];
  116. int assoc_ap_ssid_len;
  117. u16 assoc_ap_aid;
  118. struct hostapd_cached_radius_acl *acl_cache;
  119. struct hostapd_acl_query_data *acl_queries;
  120. struct wpa_authenticator *wpa_auth;
  121. struct eapol_authenticator *eapol_auth;
  122. struct rsn_preauth_interface *preauth_iface;
  123. time_t michael_mic_failure;
  124. int michael_mic_failures;
  125. int tkip_countermeasures;
  126. int ctrl_sock;
  127. struct wpa_ctrl_dst *ctrl_dst;
  128. void *ssl_ctx;
  129. void *eap_sim_db_priv;
  130. struct radius_server_data *radius_srv;
  131. int parameter_set_count;
  132. #ifdef CONFIG_FULL_DYNAMIC_VLAN
  133. struct full_dynamic_vlan *full_dynamic_vlan;
  134. #endif /* CONFIG_FULL_DYNAMIC_VLAN */
  135. struct l2_packet_data *l2;
  136. };
  137. /**
  138. * hostapd_iface_cb - Generic callback type for per-iface asynchronous requests
  139. * @iface: the interface the event occured on.
  140. * @status: 0 if the request succeeded; -1 if the request failed.
  141. */
  142. typedef void (*hostapd_iface_cb)(struct hostapd_iface *iface, int status);
  143. struct hostapd_config_change;
  144. /**
  145. * struct hostapd_iface - hostapd per-interface data structure
  146. */
  147. struct hostapd_iface {
  148. char *config_fname;
  149. struct hostapd_config *conf;
  150. hostapd_iface_cb setup_cb;
  151. size_t num_bss;
  152. struct hostapd_data **bss;
  153. int num_ap; /* number of entries in ap_list */
  154. struct ap_info *ap_list; /* AP info list head */
  155. struct ap_info *ap_hash[STA_HASH_SIZE];
  156. struct ap_info *ap_iter_list;
  157. struct hostapd_hw_modes *hw_features;
  158. int num_hw_features;
  159. struct hostapd_hw_modes *current_mode;
  160. /* Rates that are currently used (i.e., filtered copy of
  161. * current_mode->channels */
  162. int num_rates;
  163. struct hostapd_rate_data *current_rates;
  164. hostapd_iface_cb hw_mode_sel_cb;
  165. u16 hw_flags;
  166. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  167. * in 802.11g BSS) */
  168. int num_sta_non_erp;
  169. /* Number of associated stations that do not support Short Slot Time */
  170. int num_sta_no_short_slot_time;
  171. /* Number of associated stations that do not support Short Preamble */
  172. int num_sta_no_short_preamble;
  173. int olbc; /* Overlapping Legacy BSS Condition */
  174. /* Number of HT associated stations that do not support greenfield */
  175. int num_sta_ht_no_gf;
  176. /* Number of associated non-HT stations */
  177. int num_sta_no_ht;
  178. /* Number of HT associated stations 20 MHz */
  179. int num_sta_ht_20mhz;
  180. /* Overlapping BSS information */
  181. int olbc_ht;
  182. int dfs_enable;
  183. u8 pwr_const;
  184. unsigned int tx_power;
  185. unsigned int sta_max_power;
  186. unsigned int channel_switch;
  187. struct hostapd_config_change *change;
  188. hostapd_iface_cb reload_iface_cb;
  189. hostapd_iface_cb config_reload_cb;
  190. #ifdef CONFIG_IEEE80211N
  191. u16 ht_op_mode;
  192. #endif /* CONFIG_IEEE80211N */
  193. };
  194. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  195. int reassoc);
  196. #endif /* HOSTAPD_H */