ypto API development for Linux
summaryrefslogtreecommitdiffstats
path: root/include/net/ieee80211softmac.h
blob: 1ef6282fdded66520c5a15956848a77dfaaecbfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/*
 * ieee80211softmac.h - public interface to the softmac
 *
 * Copyright (c) 2005 Johannes Berg <johannes@sipsolutions.net>
 *                    Joseph Jezak <josejx@gentoo.org>
 *                    Larry Finger <Larry.Finger@lwfinger.net>
 *                    Danny van Dyk <kugelfang@gentoo.org>
 *                    Michael Buesch <mbuesch@freenet.de>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called COPYING.
 */

#ifndef IEEE80211SOFTMAC_H_
#define IEEE80211SOFTMAC_H_

#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/list.h>
#include <net/ieee80211.h>

/* Once the API is considered more or less stable,
 * this should be incremented on API incompatible changes.
 */
#define IEEE80211SOFTMAC_API	0

#define IEEE80211SOFTMAC_MAX_RATES_LEN		8
#define IEEE80211SOFTMAC_MAX_EX_RATES_LEN	255

struct ieee80211softmac_ratesinfo {
	u8 count;
	u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN];
};

/* internal structures */
struct ieee80211softmac_network;
struct ieee80211softmac_scaninfo;

struct ieee80211softmac_essid {
	u8 len;
	char data[IW_ESSID_MAX_SIZE+1];
};

struct ieee80211softmac_wpa {
	char *IE;
	int IElen;
	int IEbuflen;
};

/*
 * Information about association
 */
struct ieee80211softmac_assoc_info {

	struct mutex mutex;

	/*
	 * This is the requested ESSID. It is written
	 * only by the WX handlers.
	 *
	 */
	struct ieee80211softmac_essid req_essid;
	/*
	 * the ESSID of the network we're currently
	 * associated (or trying) to. This is
	 * updated to the network's actual ESSID
	 * even if the requested ESSID was 'ANY'
	 */
	struct ieee80211softmac_essid associate_essid;
	
	/* BSSID we're trying to associate to */
	char bssid[ETH_ALEN];
	
	/* some flags.
	 * static_essid is valid if the essid is constant,
	 * this is for use by the wx handlers only.
	 *
	 * associating is true, if the network has been
	 * auth'ed on and we are in the process of associating.
	 *
	 * bssvalid is true if we found a matching network
	 * and saved it's BSSID into the bssid above.
	 *
	 * bssfixed is used for SIOCSIWAP.
	 */
	u8 static_essid;
	u8 short_preamble_available;
	u8 associating;
	u8 associated;
	u8 assoc_wait;
	u8 bssvalid;
	u8 bssfixed;

	/* Scan retries remaining */
	int scan_retry;

	struct delayed_work work;
	struct delayed_work timeout;
};

struct ieee80211softmac_bss_info {
	/* Rates supported by the network */
	struct ieee80211softmac_ratesinfo supported_rates;

	/* This indicates whether frames can currently be transmitted with
	 * short preamble (only use this variable during TX at CCK rates) */
	u8 short_preamble:1;

	/* This indicates whether protection (e.g. self-CTS) should be used
	 * when transmitting with OFDM modulation */
	u8 use_protection:1;
};

enum {
	IEEE80211SOFTMAC_AUTH_OPEN_REQUEST	= 1,
	IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE	= 2,
};

enum {
	IEEE80211SOFTMAC_AUTH_SHARED_REQUEST	= 1,
	IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2,
	IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE	= 3,
	IEEE80211SOFTMAC_AUTH_SHARED_PASS	= 4,
};

/* We should make these tunable
 * AUTH_TIMEOUT seems really long, but that's what it is in BSD */
#define IEEE80211SOFTMAC_AUTH_TIMEOUT		(12 * HZ)
#define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT	5
#define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT	3

struct ieee80211softmac_txrates {
	/* The Bit-Rate to be used for multicast frames. */
	u8 mcast_rate;

	/* The Bit-Rate to be used for multicast management frames. */
	u8 mgt_mcast_rate;

	/* The Bit-Rate to be used for any other (normal) data packet. */
	u8 default_rate;
	/* The Bit-Rate to be used for default fallback
	 * (If the device supports fallback and hardware-retry)
	 */
	u8 default_fallback;

	/* This is the rate that the user asked for */
	u8 user_rate;
};

/* Bits for txrates_change callback. */
#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT		(1 << 0) /* default_rate */
#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK	(1 << 1) /* default_fallback */
#define IEEE80211SOFTMAC_TXRATECHG_MCAST		(1 << 2) /* mcast_rate */
#define IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST		(1 << 3) /* mgt_mcast_rate */

#define IEEE80211SOFTMAC_BSSINFOCHG_RATES		(1 << 0) /* supported_rates */
#define IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE	(1 << 1) /* short_preamble */
#define IEEE80211SOFTMAC_BSSINFOCHG_PROTECTION		(1 << 2) /* use_protection */

struct ieee80211softmac_device {
	/* 802.11 structure for data stuff */
	struct ieee80211_device *ieee;
	struct net_device *dev;

	/* only valid if associated, then holds the Association ID */
	u16 association_id;
	
	/* the following methods are callbacks that the driver
	 * using this framework has to assign
	 */

	/* always assign these */
	void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid);
	void (*set_channel)(struct net_device *dev, u8 channel);

	/* assign if you need it, informational only */
	void (*link_change)(struct net_device *dev);

	/* If the hardware can do scanning, assign _all_ three of these callbacks.
	 * When the scan finishes, call ieee80211softmac_scan_finished().
	 */
	
	/* when called, start_scan is guaranteed to not be called again
	 * until you call ieee80211softmac_scan_finished.
	 * Return 0 if scanning could start, error otherwise.
	 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */
	int (*start_scan)(struct net_device *dev);
	/* this should block until after ieee80211softmac_scan_finished was called
	 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */
	void (*wait_for_scan)(struct net_device *dev);
	/* stop_scan aborts a scan, but is asynchronous.
	 * if you want to wait for it too, use wait_for_scan
	 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */
	void (*stop_scan)(struct net_device *dev);

	/* we'll need something about beacons here too, for AP or ad-hoc modes */

	/* Transmission rates to be used by the driver.
	 * The SoftMAC figures out the best possible rates.
	 * The driver just needs to read them.
	 */
	struct ieee80211softmac_txrates txrates;

	/* If the driver needs to do stuff on TX rate changes, assign this
	 * callback. See IEEE80211SOFTMAC_TXRATECHG for change flags. */
	void (*txrates_change)(struct net_device *dev,
			       u32 changes);

	/* If the driver needs to do stuff when BSS properties change, assign
	 * this callback. see IEEE80211SOFTMAC_BSSINFOCHG for change flags. */
	void (*bssinfo_change)(struct net_device *dev,
			       u32 changes);

	/* private stuff follows */
	/* this lock protects this structure */