00001 #ifndef HOSTAP_AP_H
00002 #define HOSTAP_AP_H
00003
00004
00005
00006
00007 #define STA_MAX_TX_BUFFER 32
00008
00009
00010
00011
00012 #define AP_SKB_CB_MAGIC "hostap"
00013 #define AP_SKB_CB_MAGIC_LEN 6
00014 #define AP_SKB_CB_BUFFERED_FRAME BIT(0)
00015 #define AP_SKB_CB_ADD_MOREDATA BIT(1)
00016
00017
00018
00019 #define WLAN_STA_AUTH BIT(0)
00020 #define WLAN_STA_ASSOC BIT(1)
00021 #define WLAN_STA_PS BIT(2)
00022 #define WLAN_STA_TIM BIT(3)
00023 #define WLAN_STA_PERM BIT(4)
00024 #define WLAN_STA_AUTHORIZED BIT(5)
00025
00026
00027
00028 #define WLAN_STA_PENDING_POLL BIT(6)
00029
00030 #define WLAN_RATE_1M BIT(0)
00031 #define WLAN_RATE_2M BIT(1)
00032 #define WLAN_RATE_5M5 BIT(2)
00033 #define WLAN_RATE_11M BIT(3)
00034 #define WLAN_RATE_COUNT 4
00035
00036
00037
00038 #define WLAN_SUPP_RATES_MAX 32
00039
00040
00041 #define WLAN_RATE_UPDATE_COUNT 50
00042
00043
00044 #define WLAN_RATE_DECREASE_THRESHOLD 2
00045
00046 struct sta_info {
00047 struct list_head list;
00048 struct sta_info *hnext;
00049 atomic_t users;
00050 struct proc_dir_entry *proc;
00051
00052 u8 addr[6];
00053 u16 aid;
00054 u32 flags;
00055 u16 capability;
00056 u16 listen_interval;
00057 u8 supported_rates[WLAN_SUPP_RATES_MAX];
00058
00059 unsigned long last_auth;
00060 unsigned long last_assoc;
00061 unsigned long last_rx;
00062 unsigned long last_tx;
00063 unsigned long rx_packets, tx_packets;
00064 unsigned long rx_bytes, tx_bytes;
00065 struct sk_buff_head tx_buf;
00066
00067
00068
00069 u8 last_rx_silence;
00070 u8 last_rx_signal;
00071 u8 last_rx_rate;
00072 u8 last_rx_updated;
00073
00074 u8 tx_supp_rates;
00075 u8 tx_rate;
00076 u8 tx_rate_idx;
00077 u8 tx_max_rate;
00078 u32 tx_count[WLAN_RATE_COUNT];
00079 u32 rx_count[WLAN_RATE_COUNT];
00080
00081 u32 tx_since_last_failure;
00082 u32 tx_consecutive_exc;
00083
00084 struct prism2_crypt_data *crypt;
00085
00086 int ap;
00087
00088 local_info_t *local;
00089
00090 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
00091 union {
00092 struct {
00093 char *challenge;
00094
00095 } sta;
00096 struct {
00097 int ssid_len;
00098 unsigned char ssid[MAX_SSID_LEN + 1];
00099 int channel;
00100 unsigned long last_beacon;
00101 } ap;
00102 } u;
00103
00104 struct timer_list timer;
00105 enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next;
00106 #endif
00107 };
00108
00109
00110 #define MAX_STA_COUNT 1024
00111
00112
00113
00114 #define MAX_AID_TABLE_SIZE 128
00115
00116 #define STA_HASH_SIZE 256
00117 #define STA_HASH(sta) (sta[5])
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 #define AP_MAX_INACTIVITY_SEC (5 * 60)
00128 #define AP_DISASSOC_DELAY (HZ)
00129 #define AP_DEAUTH_DELAY (HZ)
00130
00131
00132 typedef enum {
00133 AP_OTHER_AP_SKIP_ALL = 0,
00134 AP_OTHER_AP_SAME_SSID = 1,
00135 AP_OTHER_AP_ALL = 2,
00136 AP_OTHER_AP_EVEN_IBSS = 3
00137 } ap_policy_enum;
00138
00139 #define PRISM2_AUTH_OPEN BIT(0)
00140 #define PRISM2_AUTH_SHARED_KEY BIT(1)
00141
00142
00143
00144 struct mac_entry {
00145 struct list_head list;
00146 u8 addr[6];
00147 };
00148
00149 struct mac_restrictions {
00150 enum { MAC_POLICY_OPEN = 0, MAC_POLICY_ALLOW, MAC_POLICY_DENY } policy;
00151 unsigned int entries;
00152 struct list_head mac_list;
00153 spinlock_t lock;
00154 };
00155
00156
00157 struct add_sta_proc_data {
00158 u8 addr[ETH_ALEN];
00159 struct add_sta_proc_data *next;
00160 };
00161
00162
00163 typedef enum { WDS_ADD, WDS_DEL } wds_oper_type;
00164 struct wds_oper_data {
00165 wds_oper_type type;
00166 u8 addr[ETH_ALEN];
00167 struct wds_oper_data *next;
00168 };
00169
00170
00171 struct ap_data {
00172 int initialized;
00173 local_info_t *local;
00174 int bridge_packets;
00175
00176
00177 unsigned int bridged_unicast;
00178
00179 unsigned int bridged_multicast;
00180
00181 int nullfunc_ack;
00182
00183 spinlock_t sta_table_lock;
00184 int num_sta;
00185 struct list_head sta_list;
00186 struct sta_info *sta_hash[STA_HASH_SIZE];
00187
00188 struct proc_dir_entry *proc;
00189
00190 ap_policy_enum ap_policy;
00191 unsigned int max_inactivity;
00192 int autom_ap_wds;
00193
00194 struct mac_restrictions mac_restrictions;
00195 int last_tx_rate;
00196
00197 HOSTAP_QUEUE set_tim_queue;
00198 struct list_head set_tim_list;
00199 spinlock_t set_tim_lock;
00200
00201 HOSTAP_QUEUE add_sta_proc_queue;
00202 struct add_sta_proc_data *add_sta_proc_entries;
00203
00204 HOSTAP_QUEUE wds_oper_queue;
00205 struct wds_oper_data *wds_oper_entries;
00206
00207 u16 tx_callback_idx;
00208
00209 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
00210
00211
00212
00213
00214 struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
00215
00216 u16 tx_callback_auth, tx_callback_assoc, tx_callback_poll;
00217
00218
00219
00220 struct hostap_crypto_ops *crypt;
00221 void *crypt_priv;
00222 #endif
00223 };
00224
00225
00226 void hostap_rx(struct net_device *dev, struct sk_buff *skb,
00227 struct hostap_80211_rx_status *rx_stats);
00228 void hostap_init_data(local_info_t *local);
00229 void hostap_free_data(struct ap_data *ap);
00230 void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver);
00231
00232 typedef enum {
00233 AP_TX_CONTINUE, AP_TX_DROP, AP_TX_RETRY, AP_TX_BUFFERED,
00234 AP_TX_CONTINUE_NOT_AUTHORIZED
00235 } ap_tx_ret;
00236 ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct sk_buff *skb,
00237 struct hfa384x_tx_frame *txdesc, int wds,
00238 int host_encrypt,
00239 struct prism2_crypt_data **crypt,
00240 void **sta_ptr);
00241 void hostap_handle_sta_release(void *ptr);
00242 void hostap_handle_sta_tx_exc(local_info_t *local,
00243 struct hfa384x_tx_frame *txdesc);
00244 int hostap_update_sta_ps(local_info_t *local,
00245 struct hostap_ieee80211_hdr *hdr);
00246 typedef enum {
00247 AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED
00248 } ap_rx_ret;
00249 ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
00250 struct sk_buff *skb,
00251 struct hostap_80211_rx_status *rx_stats,
00252 int wds);
00253 int hostap_handle_sta_crypto(local_info_t *local,
00254 struct hostap_ieee80211_hdr *hdr,
00255 struct prism2_crypt_data **crypt, void **sta_ptr);
00256 int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
00257 int hostap_add_sta(struct ap_data *ap, u8 *sta_addr);
00258 int hostap_update_rx_stats(struct ap_data *ap,
00259 struct hostap_ieee80211_hdr *hdr,
00260 struct hostap_80211_rx_status *rx_stats);
00261 void hostap_update_rates(local_info_t *local);
00262 void hostap_add_wds_links(local_info_t *local);
00263 void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type);
00264 void hostap_ap_update_sq(struct sta_info *sta,
00265 struct hostap_80211_rx_status *rx_stats);
00266
00267 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
00268 void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
00269 int resend);
00270 #endif
00271
00272 #endif