blob: c0dbe070e548f2faef2eb0b089ee2740b7f18a57 [file] [log] [blame]
Johannes Berg4855d252006-01-12 21:12:59 +01001/*
2 * Internal softmac API definitions.
3 *
Johannes Berg79859052006-01-31 19:31:41 +01004 * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
5 * Joseph Jezak <josejx@gentoo.org>
6 * Larry Finger <Larry.Finger@lwfinger.net>
7 * Danny van Dyk <kugelfang@gentoo.org>
8 * Michael Buesch <mbuesch@freenet.de>
Johannes Berg4855d252006-01-12 21:12:59 +01009 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * The full GNU General Public License is included in this distribution in the
24 * file called COPYING.
25 */
26
Johannes Berg370121e2006-01-04 16:32:16 +010027#ifndef IEEE80211SOFTMAC_PRIV_H_
28#define IEEE80211SOFTMAC_PRIV_H_
29
30#include <net/ieee80211softmac.h>
31#include <net/ieee80211softmac_wx.h>
32#include <linux/kernel.h>
33#include <linux/stringify.h>
34
35
36#define PFX "SoftMAC: "
37
38#ifdef assert
39# undef assert
40#endif
41#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
42#define assert(expr) \
43 do { \
44 if (unlikely(!(expr))) { \
45 printkl(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", #expr, \
46 __FILE__, __LINE__, __FUNCTION__); \
47 } \
48 } while (0)
49#else
50#define assert(expr) do {} while (0)
51#endif
52
53/* rate limited printk(). */
54#ifdef printkl
55# undef printkl
56#endif
57#define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
58/* rate limited printk() for debugging */
59#ifdef dprintkl
60# undef dprintkl
61#endif
62#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
63# define dprintkl printkl
64#else
65# define dprintkl(f, x...) do { /* nothing */ } while (0)
66#endif
67
68/* debugging printk() */
69#ifdef dprintk
70# undef dprintk
71#endif
72#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
73# define dprintk(f, x...) do { printk(f ,##x); } while (0)
74#else
75# define dprintk(f, x...) do { /* nothing */ } while (0)
76#endif
77
Johannes Berg370121e2006-01-04 16:32:16 +010078/* private definitions and prototypes */
79
80/*** prototypes from _scan.c */
David Howellsc4028952006-11-22 14:57:56 +000081void ieee80211softmac_scan(struct work_struct *work);
Johannes Berg370121e2006-01-04 16:32:16 +010082/* for internal use if scanning is needed */
83int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
84void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
85void ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *mac);
86
87/* for use by _module.c to assign to the callbacks */
88int ieee80211softmac_start_scan_implementation(struct net_device *dev);
89void ieee80211softmac_stop_scan_implementation(struct net_device *dev);
90void ieee80211softmac_wait_for_scan_implementation(struct net_device *dev);
91
92/*** Network prototypes from _module.c */
93struct ieee80211softmac_network * ieee80211softmac_create_network(
94 struct ieee80211softmac_device *mac, struct ieee80211_network *net);
95void ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
96 struct ieee80211softmac_network *net);
97void ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
98 struct ieee80211softmac_network *net);
99void ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
100 struct ieee80211softmac_network *net);
101void ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
102 struct ieee80211softmac_network *net);
103struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid_locked(
104 struct ieee80211softmac_device *mac, u8 *ea);
105struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid(
106 struct ieee80211softmac_device *mac, u8 *ea);
107struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid_locked(
108 struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
109struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid(
110 struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
Johannes Berg714e1a52006-01-04 21:06:28 +0100111struct ieee80211softmac_network *
112ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
113 struct ieee80211softmac_essid *essid);
114struct ieee80211softmac_network *
115ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
116 struct ieee80211softmac_essid *essid);
Johannes Berg370121e2006-01-04 16:32:16 +0100117
118/* Rates related */
Daniel Drake5acd0c412006-07-18 21:33:27 +0100119void ieee80211softmac_process_erp(struct ieee80211softmac_device *mac,
120 u8 erp_value);
Daniel Drake8462fe32006-05-01 22:45:50 +0100121int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo *ri, u8 rate);
Johannes Berg370121e2006-01-04 16:32:16 +0100122u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
Daniel Drake5acd0c412006-07-18 21:33:27 +0100123void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac);
Daniel Drake8462fe32006-05-01 22:45:50 +0100124void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac);
Johannes Berg370121e2006-01-04 16:32:16 +0100125static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
126 return ieee80211softmac_lower_rate_delta(mac, rate, 1);
127}
128
129static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
130{
131 return ieee80211softmac_lower_rate_delta(mac, rate, 2);
132}
133
134
135/*** prototypes from _io.c */
136int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
137 void* ptrarg, u32 type, u32 arg);
Daniel Drake5acd0c412006-07-18 21:33:27 +0100138int ieee80211softmac_handle_beacon(struct net_device *dev,
139 struct ieee80211_beacon *beacon,
140 struct ieee80211_network *network);
Johannes Berg370121e2006-01-04 16:32:16 +0100141
142/*** prototypes from _auth.c */
143/* do these have to go into the public header? */
144int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
145int ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, int reason);
146
147/* for use by _module.c to assign to the callbacks */
148int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth);
Johannes Bergb10c9912006-01-31 19:48:06 +0100149int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth);
Johannes Berg370121e2006-01-04 16:32:16 +0100150
151/*** prototypes from _assoc.c */
David Howellsc4028952006-11-22 14:57:56 +0000152void ieee80211softmac_assoc_work(struct work_struct *work);
Johannes Berg370121e2006-01-04 16:32:16 +0100153int ieee80211softmac_handle_assoc_response(struct net_device * dev,
154 struct ieee80211_assoc_response * resp,
155 struct ieee80211_network * network);
156int ieee80211softmac_handle_disassoc(struct net_device * dev,
157 struct ieee80211_disassoc * disassoc);
Johannes Bergb6c76582006-01-31 19:49:42 +0100158int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
159 struct ieee80211_reassoc_request * reassoc);
David Howellsc4028952006-11-22 14:57:56 +0000160void ieee80211softmac_assoc_timeout(struct work_struct *work);
Daniel Drake6d92f832006-05-01 22:23:27 +0100161void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason);
162void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
Johannes Berg370121e2006-01-04 16:32:16 +0100163
164/* some helper functions */
165static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
166{
167 return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
168 (sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
169 (sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
170}
171
172static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
173{
174 return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
175 (sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
176 (sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
177 ) || ieee80211softmac_scan_handlers_check_self(sm);
178}
179
David Woodhouse16f43522006-03-23 14:00:02 +0000180#define IEEE80211SOFTMAC_PROBE_DELAY HZ/50
Johannes Berg370121e2006-01-04 16:32:16 +0100181#define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
182
183struct ieee80211softmac_network {
184 struct list_head list; /* List */
185 /* Network information copied from ieee80211_network */
186 u8 bssid[ETH_ALEN];
187 u8 channel;
188 struct ieee80211softmac_essid essid;
189
190 struct ieee80211softmac_ratesinfo supported_rates;
191
192 /* SoftMAC specific */
193 u16 authenticating:1, /* Status Flags */
194 authenticated:1,
195 auth_desynced_once:1;
196
Daniel Drake5acd0c412006-07-18 21:33:27 +0100197 u8 erp_value; /* Saved ERP value */
Johannes Berg370121e2006-01-04 16:32:16 +0100198 u16 capabilities; /* Capabilities bitfield */
199 u8 challenge_len; /* Auth Challenge length */
200 char *challenge; /* Challenge Text */
201};
202
203/* structure used to keep track of networks we're auth'ing to */
204struct ieee80211softmac_auth_queue_item {
205 struct list_head list; /* List head */
206 struct ieee80211softmac_network *net; /* Network to auth */
207 struct ieee80211softmac_device *mac; /* SoftMAC device */
208 u8 retry; /* Retry limit */
209 u8 state; /* Auth State */
David Howellsc4028952006-11-22 14:57:56 +0000210 struct delayed_work work; /* Work queue */
Johannes Berg370121e2006-01-04 16:32:16 +0100211};
212
213/* scanning information */
214struct ieee80211softmac_scaninfo {
215 u8 current_channel_idx,
216 number_channels;
217 struct ieee80211_channel *channels;
218 u8 started:1,
219 stop:1;
220 u8 skip_flags;
221 struct completion finished;
David Howellsc4028952006-11-22 14:57:56 +0000222 struct delayed_work softmac_scan;
223 struct ieee80211softmac_device *mac;
Johannes Berg370121e2006-01-04 16:32:16 +0100224};
225
226/* private event struct */
227struct ieee80211softmac_event {
228 struct list_head list;
229 int event_type;
230 void *event_context;
David Howellsc4028952006-11-22 14:57:56 +0000231 struct delayed_work work;
Johannes Berg370121e2006-01-04 16:32:16 +0100232 notify_function_ptr fun;
233 void *context;
234 struct ieee80211softmac_device *mac;
235};
236
237void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
238void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
239int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
240 int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
241
242#endif /* IEEE80211SOFTMAC_PRIV_H_ */