Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 1 | #ifndef HOSTAP_AP_H |
| 2 | #define HOSTAP_AP_H |
| 3 | |
| 4 | /* AP data structures for STAs */ |
| 5 | |
| 6 | /* maximum number of frames to buffer per STA */ |
| 7 | #define STA_MAX_TX_BUFFER 32 |
| 8 | |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 9 | /* STA flags */ |
| 10 | #define WLAN_STA_AUTH BIT(0) |
| 11 | #define WLAN_STA_ASSOC BIT(1) |
| 12 | #define WLAN_STA_PS BIT(2) |
| 13 | #define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */ |
| 14 | #define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */ |
| 15 | #define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is |
| 16 | * controlling whether STA is authorized to |
| 17 | * send and receive non-IEEE 802.1X frames |
| 18 | */ |
| 19 | #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */ |
| 20 | |
| 21 | #define WLAN_RATE_1M BIT(0) |
| 22 | #define WLAN_RATE_2M BIT(1) |
| 23 | #define WLAN_RATE_5M5 BIT(2) |
| 24 | #define WLAN_RATE_11M BIT(3) |
| 25 | #define WLAN_RATE_COUNT 4 |
| 26 | |
| 27 | /* Maximum size of Supported Rates info element. IEEE 802.11 has a limit of 8, |
| 28 | * but some pre-standard IEEE 802.11g products use longer elements. */ |
| 29 | #define WLAN_SUPP_RATES_MAX 32 |
| 30 | |
| 31 | /* Try to increase TX rate after # successfully sent consecutive packets */ |
| 32 | #define WLAN_RATE_UPDATE_COUNT 50 |
| 33 | |
| 34 | /* Decrease TX rate after # consecutive dropped packets */ |
| 35 | #define WLAN_RATE_DECREASE_THRESHOLD 2 |
| 36 | |
| 37 | struct sta_info { |
| 38 | struct list_head list; |
| 39 | struct sta_info *hnext; /* next entry in hash table list */ |
| 40 | atomic_t users; /* number of users (do not remove if > 0) */ |
| 41 | struct proc_dir_entry *proc; |
| 42 | |
| 43 | u8 addr[6]; |
| 44 | u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */ |
| 45 | u32 flags; |
| 46 | u16 capability; |
| 47 | u16 listen_interval; /* or beacon_int for APs */ |
| 48 | u8 supported_rates[WLAN_SUPP_RATES_MAX]; |
| 49 | |
| 50 | unsigned long last_auth; |
| 51 | unsigned long last_assoc; |
| 52 | unsigned long last_rx; |
| 53 | unsigned long last_tx; |
| 54 | unsigned long rx_packets, tx_packets; |
| 55 | unsigned long rx_bytes, tx_bytes; |
| 56 | struct sk_buff_head tx_buf; |
| 57 | /* FIX: timeout buffers with an expiry time somehow derived from |
| 58 | * listen_interval */ |
| 59 | |
| 60 | s8 last_rx_silence; /* Noise in dBm */ |
| 61 | s8 last_rx_signal; /* Signal strength in dBm */ |
| 62 | u8 last_rx_rate; /* TX rate in 0.1 Mbps */ |
| 63 | u8 last_rx_updated; /* IWSPY's struct iw_quality::updated */ |
| 64 | |
| 65 | u8 tx_supp_rates; /* bit field of supported TX rates */ |
| 66 | u8 tx_rate; /* current TX rate (in 0.1 Mbps) */ |
| 67 | u8 tx_rate_idx; /* current TX rate (WLAN_RATE_*) */ |
| 68 | u8 tx_max_rate; /* max TX rate (WLAN_RATE_*) */ |
| 69 | u32 tx_count[WLAN_RATE_COUNT]; /* number of frames sent (per rate) */ |
| 70 | u32 rx_count[WLAN_RATE_COUNT]; /* number of frames received (per rate) |
| 71 | */ |
| 72 | u32 tx_since_last_failure; |
| 73 | u32 tx_consecutive_exc; |
| 74 | |
Jouni Malinen | 62fe7e3 | 2005-07-30 20:43:20 -0700 | [diff] [blame] | 75 | struct ieee80211_crypt_data *crypt; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 76 | |
| 77 | int ap; /* whether this station is an AP */ |
| 78 | |
| 79 | local_info_t *local; |
| 80 | |
| 81 | #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT |
| 82 | union { |
| 83 | struct { |
| 84 | char *challenge; /* shared key authentication |
| 85 | * challenge */ |
| 86 | } sta; |
| 87 | struct { |
| 88 | int ssid_len; |
| 89 | unsigned char ssid[MAX_SSID_LEN + 1]; /* AP's ssid */ |
| 90 | int channel; |
| 91 | unsigned long last_beacon; /* last RX beacon time */ |
| 92 | } ap; |
| 93 | } u; |
| 94 | |
| 95 | struct timer_list timer; |
| 96 | enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next; |
| 97 | #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ |
| 98 | }; |
| 99 | |
| 100 | |
| 101 | #define MAX_STA_COUNT 1024 |
| 102 | |
| 103 | /* Maximum number of AIDs to use for STAs; must be 2007 or lower |
| 104 | * (8802.11 limitation) */ |
| 105 | #define MAX_AID_TABLE_SIZE 128 |
| 106 | |
| 107 | #define STA_HASH_SIZE 256 |
| 108 | #define STA_HASH(sta) (sta[5]) |
| 109 | |
| 110 | |
| 111 | /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY_SEC |
| 112 | * has passed since last received frame from the station, a nullfunc data |
| 113 | * frame is sent to the station. If this frame is not acknowledged and no other |
| 114 | * frames have been received, the station will be disassociated after |
| 115 | * AP_DISASSOC_DELAY. Similarily, a the station will be deauthenticated after |
| 116 | * AP_DEAUTH_DELAY. AP_TIMEOUT_RESOLUTION is the resolution that is used with |
| 117 | * max inactivity timer. */ |
| 118 | #define AP_MAX_INACTIVITY_SEC (5 * 60) |
| 119 | #define AP_DISASSOC_DELAY (HZ) |
| 120 | #define AP_DEAUTH_DELAY (HZ) |
| 121 | |
| 122 | /* ap_policy: whether to accept frames to/from other APs/IBSS */ |
| 123 | typedef enum { |
| 124 | AP_OTHER_AP_SKIP_ALL = 0, |
| 125 | AP_OTHER_AP_SAME_SSID = 1, |
| 126 | AP_OTHER_AP_ALL = 2, |
| 127 | AP_OTHER_AP_EVEN_IBSS = 3 |
| 128 | } ap_policy_enum; |
| 129 | |
| 130 | #define PRISM2_AUTH_OPEN BIT(0) |
| 131 | #define PRISM2_AUTH_SHARED_KEY BIT(1) |
| 132 | |
| 133 | |
| 134 | /* MAC address-based restrictions */ |
| 135 | struct mac_entry { |
| 136 | struct list_head list; |
| 137 | u8 addr[6]; |
| 138 | }; |
| 139 | |
| 140 | struct mac_restrictions { |
| 141 | enum { MAC_POLICY_OPEN = 0, MAC_POLICY_ALLOW, MAC_POLICY_DENY } policy; |
| 142 | unsigned int entries; |
| 143 | struct list_head mac_list; |
| 144 | spinlock_t lock; |
| 145 | }; |
| 146 | |
| 147 | |
| 148 | struct add_sta_proc_data { |
| 149 | u8 addr[ETH_ALEN]; |
| 150 | struct add_sta_proc_data *next; |
| 151 | }; |
| 152 | |
| 153 | |
| 154 | typedef enum { WDS_ADD, WDS_DEL } wds_oper_type; |
| 155 | struct wds_oper_data { |
| 156 | wds_oper_type type; |
| 157 | u8 addr[ETH_ALEN]; |
| 158 | struct wds_oper_data *next; |
| 159 | }; |
| 160 | |
| 161 | |
| 162 | struct ap_data { |
| 163 | int initialized; /* whether ap_data has been initialized */ |
| 164 | local_info_t *local; |
| 165 | int bridge_packets; /* send packet to associated STAs directly to the |
| 166 | * wireless media instead of higher layers in the |
| 167 | * kernel */ |
| 168 | unsigned int bridged_unicast; /* number of unicast frames bridged on |
| 169 | * wireless media */ |
| 170 | unsigned int bridged_multicast; /* number of non-unicast frames |
| 171 | * bridged on wireless media */ |
| 172 | unsigned int tx_drop_nonassoc; /* number of unicast TX packets dropped |
| 173 | * because they were to an address that |
| 174 | * was not associated */ |
| 175 | int nullfunc_ack; /* use workaround for nullfunc frame ACKs */ |
| 176 | |
| 177 | spinlock_t sta_table_lock; |
| 178 | int num_sta; /* number of entries in sta_list */ |
| 179 | struct list_head sta_list; /* STA info list head */ |
| 180 | struct sta_info *sta_hash[STA_HASH_SIZE]; |
| 181 | |
| 182 | struct proc_dir_entry *proc; |
| 183 | |
| 184 | ap_policy_enum ap_policy; |
| 185 | unsigned int max_inactivity; |
| 186 | int autom_ap_wds; |
| 187 | |
| 188 | struct mac_restrictions mac_restrictions; /* MAC-based auth */ |
| 189 | int last_tx_rate; |
| 190 | |
| 191 | struct work_struct add_sta_proc_queue; |
| 192 | struct add_sta_proc_data *add_sta_proc_entries; |
| 193 | |
| 194 | struct work_struct wds_oper_queue; |
| 195 | struct wds_oper_data *wds_oper_entries; |
| 196 | |
| 197 | u16 tx_callback_idx; |
| 198 | |
| 199 | #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT |
| 200 | /* pointers to STA info; based on allocated AID or NULL if AID free |
| 201 | * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1 |
| 202 | * and so on |
| 203 | */ |
| 204 | struct sta_info *sta_aid[MAX_AID_TABLE_SIZE]; |
| 205 | |
| 206 | u16 tx_callback_auth, tx_callback_assoc, tx_callback_poll; |
| 207 | |
| 208 | /* WEP operations for generating challenges to be used with shared key |
| 209 | * authentication */ |
Jouni Malinen | 62fe7e3 | 2005-07-30 20:43:20 -0700 | [diff] [blame] | 210 | struct ieee80211_crypto_ops *crypt; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 211 | void *crypt_priv; |
| 212 | #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ |
| 213 | }; |
| 214 | |
| 215 | |
| 216 | void hostap_rx(struct net_device *dev, struct sk_buff *skb, |
| 217 | struct hostap_80211_rx_status *rx_stats); |
| 218 | void hostap_init_data(local_info_t *local); |
| 219 | void hostap_init_ap_proc(local_info_t *local); |
| 220 | void hostap_free_data(struct ap_data *ap); |
| 221 | void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver); |
| 222 | |
| 223 | typedef enum { |
| 224 | AP_TX_CONTINUE, AP_TX_DROP, AP_TX_RETRY, AP_TX_BUFFERED, |
| 225 | AP_TX_CONTINUE_NOT_AUTHORIZED |
| 226 | } ap_tx_ret; |
| 227 | struct hostap_tx_data { |
| 228 | struct sk_buff *skb; |
| 229 | int host_encrypt; |
Jouni Malinen | 62fe7e3 | 2005-07-30 20:43:20 -0700 | [diff] [blame] | 230 | struct ieee80211_crypt_data *crypt; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 231 | void *sta_ptr; |
| 232 | }; |
| 233 | ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx); |
| 234 | void hostap_handle_sta_release(void *ptr); |
| 235 | void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb); |
James Ketrenos | d041674 | 2005-09-21 12:23:49 -0500 | [diff] [blame] | 236 | int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr_4addr *hdr); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 237 | typedef enum { |
| 238 | AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED |
| 239 | } ap_rx_ret; |
| 240 | ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev, |
| 241 | struct sk_buff *skb, |
| 242 | struct hostap_80211_rx_status *rx_stats, |
| 243 | int wds); |
James Ketrenos | d041674 | 2005-09-21 12:23:49 -0500 | [diff] [blame] | 244 | int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr_4addr *hdr, |
Jouni Malinen | 62fe7e3 | 2005-07-30 20:43:20 -0700 | [diff] [blame] | 245 | struct ieee80211_crypt_data **crypt, |
| 246 | void **sta_ptr); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 247 | int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr); |
| 248 | int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr); |
| 249 | int hostap_add_sta(struct ap_data *ap, u8 *sta_addr); |
James Ketrenos | d041674 | 2005-09-21 12:23:49 -0500 | [diff] [blame] | 250 | int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr_4addr *hdr, |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 251 | struct hostap_80211_rx_status *rx_stats); |
| 252 | void hostap_update_rates(local_info_t *local); |
| 253 | void hostap_add_wds_links(local_info_t *local); |
| 254 | void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type); |
| 255 | |
| 256 | #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT |
| 257 | void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap, |
| 258 | int resend); |
| 259 | #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ |
| 260 | |
| 261 | #endif /* HOSTAP_AP_H */ |