hostapd.h

Go to the documentation of this file.
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 /* Port Access Entity (IEEE 802.1X) */
00034 #endif /* ETH_P_PAE */
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 /* _MSC_VER */
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         /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
00068          */
00069 } STRUCT_PACKED;
00070 
00071 #ifdef _MSC_VER
00072 #pragma pack(pop)
00073 #endif /* _MSC_VER */
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 /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
00084  * frames that might be longer than normal default MTU and they are not
00085  * fragmented */
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 /* CONFIG_FULL_DYNAMIC_VLAN */
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; /* virtual interface added for this BSS */
00119 
00120         u8 own_addr[ETH_ALEN];
00121 
00122         int num_sta; /* number of entries in sta_list */
00123         struct sta_info *sta_list; /* STA info list head */
00124         struct sta_info *sta_hash[STA_HASH_SIZE];
00125 
00126         /* pointers to STA info; based on allocated AID or NULL if AID free
00127          * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
00128          * and so on
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 /* CONFIG_FULL_DYNAMIC_VLAN */
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; /* number of entries in ap_list */
00199         struct ap_info *ap_list; /* AP info list head */
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         /* Rates that are currently used (i.e., filtered copy of
00207          * current_mode->channels */
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         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
00215          * in 802.11g BSS) */
00216         int num_sta_non_erp;
00217 
00218         /* Number of associated stations that do not support Short Slot Time */
00219         int num_sta_no_short_slot_time;
00220 
00221         /* Number of associated stations that do not support Short Preamble */
00222         int num_sta_no_short_preamble;
00223 
00224         int olbc; /* Overlapping Legacy BSS Condition */
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 /* _MSC_VER */
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 /* HOSTAPD_H */
00260 

Generated on Sun Dec 31 13:43:27 2006 for hostapd by  doxygen 1.4.2