Main Page | Data Structures | Directories | File List | Data Fields | Globals

hostap_ap.h

Go to the documentation of this file.
00001 #ifndef HOSTAP_AP_H
00002 #define HOSTAP_AP_H
00003 
00004 /* AP data structures for STAs */
00005 
00006 /* maximum number of frames to buffer per STA */
00007 #define STA_MAX_TX_BUFFER 32
00008 
00009 /* Flags used in skb->cb[6] to control how the packet is handled in TX path.
00010  * skb->cb[0..5] must contain magic value 'hostap' to indicate that cb[6] is
00011  * used. */
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 /* STA flags */
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) /* TIM bit is on for PS stations */
00023 #define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
00024 #define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
00025                                     * controlling whether STA is authorized to
00026                                     * send and receive non-IEEE 802.1X frames
00027                                     */
00028 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
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 /* Maximum size of Supported Rates info element. IEEE 802.11 has a limit of 8,
00037  * but some pre-standard IEEE 802.11g products use longer elements. */
00038 #define WLAN_SUPP_RATES_MAX 32
00039 
00040 /* Try to increase TX rate after # successfully sent consecutive packets */
00041 #define WLAN_RATE_UPDATE_COUNT 50
00042 
00043 /* Decrease TX rate after # consecutive dropped packets */
00044 #define WLAN_RATE_DECREASE_THRESHOLD 2
00045 
00046 struct sta_info {
00047         struct list_head list;
00048         struct sta_info *hnext; /* next entry in hash table list */
00049         atomic_t users; /* number of users (do not remove if > 0) */
00050         struct proc_dir_entry *proc;
00051 
00052         u8 addr[6];
00053         u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
00054         u32 flags;
00055         u16 capability;
00056         u16 listen_interval; /* or beacon_int for APs */
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         /* FIX: timeout buffers with an expiry time somehow derived from
00067          * listen_interval */
00068 
00069         u8 last_rx_silence;
00070         u8 last_rx_signal;
00071         u8 last_rx_rate;
00072         u8 last_rx_updated; /* IWSPY's struct iw_quality::updated */
00073 
00074         u8 tx_supp_rates; /* bit field of supported TX rates */
00075         u8 tx_rate; /* current TX rate (in 0.1 Mbps) */
00076         u8 tx_rate_idx; /* current TX rate (WLAN_RATE_*) */
00077         u8 tx_max_rate; /* max TX rate (WLAN_RATE_*) */
00078         u32 tx_count[WLAN_RATE_COUNT]; /* number of frames sent (per rate) */
00079         u32 rx_count[WLAN_RATE_COUNT]; /* number of frames received (per rate)
00080                                         */
00081         u32 tx_since_last_failure;
00082         u32 tx_consecutive_exc;
00083 
00084         struct prism2_crypt_data *crypt;
00085 
00086         int ap; /* whether this station is an AP */
00087 
00088         local_info_t *local;
00089 
00090 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
00091         union {
00092                 struct {
00093                         char *challenge; /* shared key authentication
00094                                           * challenge */
00095                 } sta;
00096                 struct {
00097                         int ssid_len;
00098                         unsigned char ssid[MAX_SSID_LEN + 1]; /* AP's ssid */
00099                         int channel;
00100                         unsigned long last_beacon; /* last RX beacon time */
00101                 } ap;
00102         } u;
00103 
00104         struct timer_list timer;
00105         enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next;
00106 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
00107 };
00108 
00109 
00110 #define MAX_STA_COUNT 1024
00111 
00112 /* Maximum number of AIDs to use for STAs; must be 2007 or lower
00113  * (8802.11 limitation) */
00114 #define MAX_AID_TABLE_SIZE 128
00115 
00116 #define STA_HASH_SIZE 256
00117 #define STA_HASH(sta) (sta[5])
00118 
00119 
00120 /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY_SEC
00121  * has passed since last received frame from the station, a nullfunc data
00122  * frame is sent to the station. If this frame is not acknowledged and no other
00123  * frames have been received, the station will be disassociated after
00124  * AP_DISASSOC_DELAY. Similarily, a the station will be deauthenticated after
00125  * AP_DEAUTH_DELAY. AP_TIMEOUT_RESOLUTION is the resolution that is used with
00126  * max inactivity timer. */
00127 #define AP_MAX_INACTIVITY_SEC (5 * 60)
00128 #define AP_DISASSOC_DELAY (HZ)
00129 #define AP_DEAUTH_DELAY (HZ)
00130 
00131 /* ap_policy: whether to accept frames to/from other APs/IBSS */
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 /* MAC address-based restrictions */
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; /* whether ap_data has been initialized */
00173         local_info_t *local;
00174         int bridge_packets; /* send packet to associated STAs directly to the
00175                              * wireless media instead of higher layers in the
00176                              * kernel */
00177         unsigned int bridged_unicast; /* number of unicast frames bridged on
00178                                        * wireless media */
00179         unsigned int bridged_multicast; /* number of non-unicast frames
00180                                          * bridged on wireless media */
00181         int nullfunc_ack; /* use workaround for nullfunc frame ACKs */
00182 
00183         spinlock_t sta_table_lock;
00184         int num_sta; /* number of entries in sta_list */
00185         struct list_head sta_list; /* STA info list head */
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; /* MAC-based auth */
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         /* pointers to STA info; based on allocated AID or NULL if AID free
00211          * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
00212          * and so on
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         /* WEP operations for generating challenges to be used with shared key
00219          * authentication */
00220         struct hostap_crypto_ops *crypt;
00221         void *crypt_priv;
00222 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
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 /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
00271 
00272 #endif /* HOSTAP_AP_H */

Generated on Mon Nov 21 15:58:09 2005 for openwifi by  doxygen 1.4.1