00001
00017 #ifndef HOSTAPD_H
00018 #define HOSTAPD_H
00019
00020 #include "common.h"
00021 #include "ap.h"
00022
00023 #ifndef ETH_ALEN
00024 #define ETH_ALEN 6
00025 #endif
00026 #ifndef IFNAMSIZ
00027 #define IFNAMSIZ 16
00028 #endif
00029 #ifndef ETH_P_ALL
00030 #define ETH_P_ALL 0x0003
00031 #endif
00032 #ifndef ETH_P_PAE
00033 #define ETH_P_PAE 0x888E
00034 #endif
00035
00036 #ifndef BIT
00037 #define BIT(x) (1 << (x))
00038 #endif
00039
00040 #ifndef MAC2STR
00041 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
00042 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
00043 #endif
00044
00045 #include "config.h"
00046
00047 #ifdef _MSC_VER
00048 #pragma pack(push, 1)
00049 #endif
00050
00051 #define MAX_VLAN_ID 4094
00052
00053 struct ieee8023_hdr {
00054 u8 dest[6];
00055 u8 src[6];
00056 u16 ethertype;
00057 } STRUCT_PACKED;
00058
00059
00060 struct ieee80211_hdr {
00061 u16 frame_control;
00062 u16 duration_id;
00063 u8 addr1[6];
00064 u8 addr2[6];
00065 u8 addr3[6];
00066 u16 seq_ctrl;
00067
00068
00069 } STRUCT_PACKED;
00070
00071 #ifdef _MSC_VER
00072 #pragma pack(pop)
00073 #endif
00074
00075 #define IEEE80211_DA_FROMDS addr1
00076 #define IEEE80211_BSSID_FROMDS addr2
00077 #define IEEE80211_SA_FROMDS addr3
00078
00079 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
00080
00081 #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
00082
00083
00084
00085
00086 #define HOSTAPD_MTU 2290
00087
00088 extern unsigned char rfc1042_header[6];
00089
00090 struct hostap_sta_driver_data {
00091 unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
00092 unsigned long current_tx_rate;
00093 unsigned long inactive_msec;
00094 unsigned long flags;
00095 unsigned long num_ps_buf_frames;
00096 unsigned long tx_retry_failed;
00097 unsigned long tx_retry_count;
00098 int last_rssi;
00099 int last_ack_rssi;
00100 };
00101
00102 struct driver_ops;
00103 struct wpa_ctrl_dst;
00104 struct radius_server_data;
00105
00106 #ifdef CONFIG_FULL_DYNAMIC_VLAN
00107 struct full_dynamic_vlan;
00108 #endif
00109
00114 struct hostapd_data {
00115 struct hostapd_iface *iface;
00116 struct hostapd_config *iconf;
00117 struct hostapd_bss_config *conf;
00118 int interface_added;
00119
00120 u8 own_addr[ETH_ALEN];
00121
00122 int num_sta;
00123 struct sta_info *sta_list;
00124 struct sta_info *sta_hash[STA_HASH_SIZE];
00125
00126
00127
00128
00129
00130 struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
00131
00132 struct driver_ops *driver;
00133
00134 u8 *default_wep_key;
00135 u8 default_wep_key_idx;
00136
00137 struct radius_client_data *radius;
00138 int radius_client_reconfigured;
00139 u32 acct_session_id_hi, acct_session_id_lo;
00140
00141 struct iapp_data *iapp;
00142
00143 enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
00144 ASSOCIATED } assoc_ap_state;
00145 char assoc_ap_ssid[33];
00146 int assoc_ap_ssid_len;
00147 u16 assoc_ap_aid;
00148
00149 struct hostapd_cached_radius_acl *acl_cache;
00150 struct hostapd_acl_query_data *acl_queries;
00151
00152 struct wpa_authenticator *wpa_auth;
00153
00154 struct rsn_preauth_interface *preauth_iface;
00155 time_t michael_mic_failure;
00156 int michael_mic_failures;
00157 int tkip_countermeasures;
00158
00159 int ctrl_sock;
00160 struct wpa_ctrl_dst *ctrl_dst;
00161
00162 void *ssl_ctx;
00163 void *eap_sim_db_priv;
00164 struct radius_server_data *radius_srv;
00165
00166 int parameter_set_count;
00167
00168 #ifdef CONFIG_FULL_DYNAMIC_VLAN
00169 struct full_dynamic_vlan *full_dynamic_vlan;
00170 #endif
00171 };
00172
00173
00180 typedef void (*hostapd_iface_cb)(struct hostapd_iface *iface, int status);
00181
00182
00183 struct hostapd_config_change;
00184
00189 struct hostapd_iface {
00190 char *config_fname;
00191 struct hostapd_config *conf;
00192
00193 hostapd_iface_cb setup_cb;
00194
00195 size_t num_bss;
00196 struct hostapd_data **bss;
00197
00198 int num_ap;
00199 struct ap_info *ap_list;
00200 struct ap_info *ap_hash[STA_HASH_SIZE];
00201 struct ap_info *ap_iter_list;
00202
00203 struct hostapd_hw_modes *hw_features;
00204 int num_hw_features;
00205 struct hostapd_hw_modes *current_mode;
00206
00207
00208 int num_rates;
00209 struct hostapd_rate_data *current_rates;
00210 hostapd_iface_cb hw_mode_sel_cb;
00211
00212 u16 hw_flags;
00213
00214
00215
00216 int num_sta_non_erp;
00217
00218
00219 int num_sta_no_short_slot_time;
00220
00221
00222 int num_sta_no_short_preamble;
00223
00224 int olbc;
00225
00226 int dfs_enable;
00227 u8 pwr_const;
00228 unsigned int tx_power;
00229 unsigned int sta_max_power;
00230
00231 unsigned int channel_switch;
00232
00233 struct hostapd_config_change *change;
00234 hostapd_iface_cb reload_iface_cb;
00235 hostapd_iface_cb config_reload_cb;
00236 };
00237
00238 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
00239 int reassoc);
00240 void hostapd_logger(struct hostapd_data *hapd, const u8 *addr,
00241 unsigned int module, int level, const char *fmt,
00242 ...) PRINTF_FORMAT(5, 6);
00243
00244
00245 #ifndef _MSC_VER
00246 #define HOSTAPD_DEBUG(level, args...) \
00247 do { \
00248 if (hapd->conf == NULL || hapd->conf->debug >= (level)) \
00249 printf(args); \
00250 } while (0)
00251 #endif
00252
00253 #define HOSTAPD_DEBUG_COND(level) (hapd->conf->debug >= (level))
00254
00255 const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
00256 size_t buflen);
00257 int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b);
00258
00259 #endif
00260