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