hostapd.h 5.6 KB

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