update luci feed url to use http due to certificate issues
[openwrt.git] / package / madwifi / patches-testing / 315-scanlist.patch
1 --- a/net80211/ieee80211_scan_sta.c
2 +++ b/net80211/ieee80211_scan_sta.c
3 @@ -318,147 +318,6 @@
4 #undef ISPROBE
5 }
6
7 -static struct ieee80211_channel *
8 -find11gchannel(struct ieee80211com *ic, int i, int freq)
9 -{
10 - struct ieee80211_channel *c;
11 - int j;
12 -
13 - /*
14 - * The normal ordering in the channel list is b channel
15 - * immediately followed by g so optimize the search for
16 - * this. We'll still do a full search just in case.
17 - */
18 - for (j = i+1; j < ic->ic_nchans; j++) {
19 - c = &ic->ic_channels[j];
20 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
21 - return c;
22 - }
23 - for (j = 0; j < i; j++) {
24 - c = &ic->ic_channels[j];
25 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
26 - return c;
27 - }
28 - return NULL;
29 -}
30 -static const u_int chanflags[] = {
31 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
32 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
33 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
34 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
35 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
36 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
37 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
38 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
39 -};
40 -
41 -static void
42 -add_channels(struct ieee80211com *ic,
43 - struct ieee80211_scan_state *ss,
44 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
45 -{
46 - struct ieee80211_channel *c, *cg;
47 - u_int modeflags;
48 - int i;
49 -
50 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
51 - modeflags = chanflags[mode];
52 - for (i = 0; i < nfreq; i++) {
53 - c = ieee80211_find_channel(ic, freq[i], modeflags);
54 - if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
55 - continue;
56 - if (mode == IEEE80211_MODE_AUTO) {
57 - /*
58 - * XXX special-case 11b/g channels so we select
59 - * the g channel if both are present.
60 - */
61 - if (IEEE80211_IS_CHAN_B(c) &&
62 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
63 - c = cg;
64 - }
65 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
66 - break;
67 - ss->ss_chans[ss->ss_last++] = c;
68 - }
69 -}
70 -
71 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64, 36, 40, 44, 48 */
72 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
73 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
74 -{ 5170, 5190, 5210, 5230 };
75 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
76 -{ 2412, 2437, 2462, 2442, 2472 };
77 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
78 -{ 5745, 5765, 5785, 5805, 5825 };
79 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100,104,108,112,116,120,124,128,132,136,140 */
80 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
81 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
82 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
83 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
84 -{ 2484 };
85 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
86 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
87 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
88 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
89 -#ifdef ATH_TURBO_SCAN
90 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
91 -{ 5210, 5250, 5290 };
92 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
93 -{ 5760, 5800 };
94 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
95 -{ 5540, 5580, 5620, 5660 };
96 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
97 -{ 2437 };
98 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
99 -{ 5200, 5240, 5280, 5765, 5805 };
100 -#endif /* ATH_TURBO_SCAN */
101 -
102 -struct scanlist {
103 - u_int16_t mode;
104 - u_int16_t count;
105 - const u_int16_t *list;
106 -};
107 -
108 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
109 -#define X(a) .count = sizeof(a)/sizeof(a[0]), .list = a
110 -
111 -static const struct scanlist staScanTable[] = {
112 - { IEEE80211_MODE_11B, X(rcl3) },
113 - { IEEE80211_MODE_11A, X(rcl1) },
114 - { IEEE80211_MODE_11A, X(rcl2) },
115 - { IEEE80211_MODE_11B, X(rcl8) },
116 - { IEEE80211_MODE_11B, X(rcl9) },
117 - { IEEE80211_MODE_11A, X(rcl4) },
118 -#ifdef ATH_TURBO_SCAN
119 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
120 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
121 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
122 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
123 -#endif /* ATH_TURBO_SCAN */
124 - { IEEE80211_MODE_11A, X(rcl7) },
125 - { IEEE80211_MODE_11B, X(rcl10) },
126 - { IEEE80211_MODE_11A, X(rcl11) },
127 -#ifdef ATH_TURBO_SCAN
128 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
129 -#endif /* ATH_TURBO_SCAN */
130 - { .list = NULL }
131 -};
132 -
133 -#undef X
134 -
135 -static int
136 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
137 -{
138 - int i;
139 -
140 - for (; scan->list != NULL; scan++) {
141 - for (i = 0; i < scan->count; i++)
142 - if (scan->list[i] == c->ic_freq)
143 - return 1;
144 - }
145 - return 0;
146 -}
147 -
148 /*
149 * Start a station-mode scan by populating the channel list.
150 */
151 @@ -467,81 +326,11 @@
152 {
153 struct ieee80211com *ic = vap->iv_ic;
154 struct sta_table *st = ss->ss_priv;
155 - const struct scanlist *scan;
156 - enum ieee80211_phymode mode;
157 - struct ieee80211_channel *c;
158 - int i;
159
160 ss->ss_last = 0;
161 - /*
162 - * Use the table of ordered channels to construct the list
163 - * of channels for scanning. Any channels in the ordered
164 - * list not in the master list will be discarded.
165 - */
166 - for (scan = staScanTable; scan->list != NULL; scan++) {
167 - mode = scan->mode;
168 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
169 - /*
170 - * If a desired mode was specified, scan only
171 - * channels that satisfy that constraint.
172 - */
173 - if (vap->iv_des_mode != mode) {
174 - /*
175 - * The scan table marks 2.4Ghz channels as b
176 - * so if the desired mode is 11g, then use
177 - * the 11b channel list but upgrade the mode.
178 - */
179 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
180 - mode != IEEE80211_MODE_11B)
181 - continue;
182 - mode = IEEE80211_MODE_11G; /* upgrade */
183 - }
184 - } else {
185 - /*
186 - * This lets ieee80211_scan_add_channels
187 - * upgrade an 11b channel to 11g if available.
188 - */
189 - if (mode == IEEE80211_MODE_11B)
190 - mode = IEEE80211_MODE_AUTO;
191 - }
192 - /* XR does not operate on turbo channels */
193 - if ((vap->iv_flags & IEEE80211_F_XR) &&
194 - (mode == IEEE80211_MODE_TURBO_A ||
195 - mode == IEEE80211_MODE_TURBO_G))
196 - continue;
197 - /*
198 - * Add the list of the channels; any that are not
199 - * in the master channel list will be discarded.
200 - */
201 - add_channels(ic, ss, mode, scan->list, scan->count);
202 - }
203 -
204 - /*
205 - * Add the channels from the ic (from HAL) that are not present
206 - * in the staScanTable.
207 - */
208 - for (i = 0; i < ic->ic_nchans; i++) {
209 - c = &ic->ic_channels[i];
210 - /*
211 - * scan dynamic turbo channels in normal mode.
212 - */
213 - if (IEEE80211_IS_CHAN_DTURBO(c))
214 - continue;
215 - mode = ieee80211_chan2mode(c);
216 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
217 - /*
218 - * If a desired mode was specified, scan only
219 - * channels that satisfy that constraint.
220 - */
221 - if (vap->iv_des_mode != mode)
222 - continue;
223 -
224 - }
225 - if (!checktable(staScanTable, c))
226 - ss->ss_chans[ss->ss_last++] = c;
227 - }
228 -
229 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
230 ss->ss_next = 0;
231 +
232 /* XXX tunables */
233 /*
234 * The scanner will stay on station for ss_maxdwell ms (using a
235 @@ -750,17 +539,7 @@
236 fail = 0;
237 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan)))
238 fail |= 0x01;
239 - /*
240 - * NB: normally the desired mode is used to construct
241 - * the channel list, but it's possible for the scan
242 - * cache to include entries for stations outside this
243 - * list so we check the desired mode here to weed them
244 - * out.
245 - */
246 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
247 - (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
248 - chanflags[vap->iv_des_mode])
249 - fail |= 0x01;
250 +
251 if (vap->iv_opmode == IEEE80211_M_IBSS) {
252 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
253 fail |= 0x02;
254 @@ -1175,78 +954,6 @@
255 .scan_default = ieee80211_sta_join,
256 };
257
258 -/*
259 - * Start an adhoc-mode scan by populating the channel list.
260 - */
261 -static int
262 -adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
263 -{
264 - struct ieee80211com *ic = vap->iv_ic;
265 - struct sta_table *st = ss->ss_priv;
266 - const struct scanlist *scan;
267 - enum ieee80211_phymode mode;
268 -
269 - ss->ss_last = 0;
270 - /*
271 - * Use the table of ordered channels to construct the list
272 - * of channels for scanning. Any channels in the ordered
273 - * list not in the master list will be discarded.
274 - */
275 - for (scan = staScanTable; scan->list != NULL; scan++) {
276 - mode = scan->mode;
277 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
278 - /*
279 - * If a desired mode was specified, scan only
280 - * channels that satisfy that constraint.
281 - */
282 - if (vap->iv_des_mode != mode) {
283 - /*
284 - * The scan table marks 2.4Ghz channels as b
285 - * so if the desired mode is 11g, then use
286 - * the 11b channel list but upgrade the mode.
287 - */
288 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
289 - mode != IEEE80211_MODE_11B)
290 - continue;
291 - mode = IEEE80211_MODE_11G; /* upgrade */
292 - }
293 - } else {
294 - /*
295 - * This lets ieee80211_scan_add_channels
296 - * upgrade an 11b channel to 11g if available.
297 - */
298 - if (mode == IEEE80211_MODE_11B)
299 - mode = IEEE80211_MODE_AUTO;
300 - }
301 - /* XR does not operate on turbo channels */
302 - if ((vap->iv_flags & IEEE80211_F_XR) &&
303 - (mode == IEEE80211_MODE_TURBO_A ||
304 - mode == IEEE80211_MODE_TURBO_G))
305 - continue;
306 - /*
307 - * Add the list of the channels; any that are not
308 - * in the master channel list will be discarded.
309 - */
310 - add_channels(ic, ss, mode, scan->list, scan->count);
311 - }
312 - ss->ss_next = 0;
313 - /* XXX tunables */
314 - ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
315 - ss->ss_maxdwell = msecs_to_jiffies(200); /* 200ms */
316 -
317 -#ifdef IEEE80211_DEBUG
318 - if (ieee80211_msg_scan(vap)) {
319 - printk("%s: scan set ", vap->iv_dev->name);
320 - ieee80211_scan_dump_channels(ss);
321 - printk(" dwell min %ld max %ld\n",
322 - ss->ss_mindwell, ss->ss_maxdwell);
323 - }
324 -#endif /* IEEE80211_DEBUG */
325 -
326 - st->st_newscan = 1;
327 -
328 - return 0;
329 -}
330
331 /*
332 * Select a channel to start an adhoc network on.
333 @@ -1412,7 +1119,7 @@
334 .scan_name = "default",
335 .scan_attach = sta_attach,
336 .scan_detach = sta_detach,
337 - .scan_start = adhoc_start,
338 + .scan_start = sta_start,
339 .scan_restart = sta_restart,
340 .scan_cancel = sta_cancel,
341 .scan_end = adhoc_pick_bss,
342 --- a/net80211/ieee80211.c
343 +++ b/net80211/ieee80211.c
344 @@ -292,6 +292,11 @@
345 ("channel with bogus ieee number %u", c->ic_ieee));
346 setbit(ic->ic_chan_avail, c->ic_ieee);
347
348 + if (c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT)
349 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
350 + else
351 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
352 +
353 /* Identify mode capabilities. */
354 if (IEEE80211_IS_CHAN_A(c))
355 ic->ic_modecaps |= 1 << IEEE80211_MODE_11A;
356 --- a/net80211/_ieee80211.h
357 +++ b/net80211/_ieee80211.h
358 @@ -132,6 +132,11 @@
359 IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
360 };
361
362 +enum ieee80211_scanflags {
363 + IEEE80211_NOSCAN_DEFAULT = (1 << 0),
364 + IEEE80211_NOSCAN_SET = (1 << 1),
365 +};
366 +
367 /*
368 * Channels are specified by frequency and attributes.
369 */
370 @@ -142,6 +147,7 @@
371 int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
372 int8_t ic_maxpower; /* maximum tx power in dBm */
373 int8_t ic_minpower; /* minimum tx power in dBm */
374 + u_int8_t ic_scanflags;
375 };
376
377 #define IEEE80211_CHAN_MAX 255
378 --- a/net80211/ieee80211_ioctl.h
379 +++ b/net80211/ieee80211_ioctl.h
380 @@ -556,6 +556,7 @@
381 #define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+26)
382 #define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+28)
383 #define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
384 +#define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
385
386 enum {
387 IEEE80211_WMMPARAMS_CWMIN = 1,
388 --- a/net80211/ieee80211_scan_ap.c
389 +++ b/net80211/ieee80211_scan_ap.c
390 @@ -200,131 +200,7 @@
391
392 static int ap_flush(struct ieee80211_scan_state *);
393 static void action_tasklet(IEEE80211_TQUEUE_ARG);
394 -static struct ieee80211_channel *find11gchannel(struct ieee80211com *ic,
395 - int i, int freq);
396
397 -static const u_int chanflags[] = {
398 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
399 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
400 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
401 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
402 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
403 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode
404 - * look for AP in
405 - * normal channel
406 - */
407 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
408 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
409 -};
410 -
411 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64,
412 - * 36, 40, 44, 48 */
413 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
414 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
415 -{ 5170, 5190, 5210, 5230 };
416 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
417 -{ 2412, 2437, 2462, 2442, 2472 };
418 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
419 -{ 5745, 5765, 5785, 5805, 5825 };
420 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100, 104, 108, 112,
421 - * 116, 120, 124, 128,
422 - * 132, 136, 140 */
423 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
424 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
425 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
426 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
427 -{ 2484 };
428 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
429 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
430 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
431 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
432 -#ifdef ATH_TURBO_SCAN
433 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
434 -{ 5210, 5250, 5290 };
435 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
436 -{ 5760, 5800 };
437 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
438 -{ 5540, 5580, 5620, 5660 };
439 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
440 -{ 2437 };
441 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
442 -{ 5200, 5240, 5280, 5765, 5805 };
443 -#endif /* ATH_TURBO_SCAN */
444 -
445 -struct scanlist {
446 - u_int16_t mode;
447 - u_int16_t count;
448 - const u_int16_t *list;
449 -};
450 -
451 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
452 -#define X(a) .count = ARRAY_SIZE(a), .list = a
453 -
454 -static const struct scanlist staScanTable[] = {
455 - { IEEE80211_MODE_11B, X(rcl3) },
456 - { IEEE80211_MODE_11A, X(rcl1) },
457 - { IEEE80211_MODE_11A, X(rcl2) },
458 - { IEEE80211_MODE_11B, X(rcl8) },
459 - { IEEE80211_MODE_11B, X(rcl9) },
460 - { IEEE80211_MODE_11A, X(rcl4) },
461 -#ifdef ATH_TURBO_SCAN
462 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
463 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
464 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
465 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
466 -#endif /* ATH_TURBO_SCAN */
467 - { IEEE80211_MODE_11A, X(rcl7) },
468 - { IEEE80211_MODE_11B, X(rcl10) },
469 - { IEEE80211_MODE_11A, X(rcl11) },
470 -#ifdef ATH_TURBO_SCAN
471 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
472 -#endif /* ATH_TURBO_SCAN */
473 - { .list = NULL }
474 -};
475 -
476 -#undef X
477 -/* This function must be invoked with locks acquired */
478 -static void
479 -add_channels(struct ieee80211com *ic,
480 - struct ieee80211_scan_state *ss,
481 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
482 -{
483 - struct ieee80211_channel *c, *cg;
484 - u_int modeflags;
485 - int i;
486 -
487 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
488 - modeflags = chanflags[mode];
489 - for (i = 0; i < nfreq; i++) {
490 - c = ieee80211_find_channel(ic, freq[i], modeflags);
491 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
492 - continue;
493 - if (mode == IEEE80211_MODE_AUTO) {
494 - /* XXX special-case 11b/g channels so we select
495 - * the g channel if both are present. */
496 - if (IEEE80211_IS_CHAN_B(c) &&
497 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
498 - c = cg;
499 - }
500 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
501 - break;
502 - ss->ss_chans[ss->ss_last++] = c;
503 - }
504 -}
505 -
506 -/* This function must be invoked with locks acquired */
507 -static int
508 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
509 -{
510 - int i;
511 -
512 - for (; scan->list != NULL; scan++) {
513 - for (i = 0; i < scan->count; i++)
514 - if (scan->list[i] == c->ic_freq)
515 - return 1;
516 - }
517 - return 0;
518 -}
519
520 /*
521 * Attach prior to any scanning work.
522 @@ -398,29 +274,6 @@
523 ieee80211_saveie(iep, ie);
524 }
525
526 -/* This function must be invoked with locks acquired */
527 -static struct ieee80211_channel *
528 -find11gchannel(struct ieee80211com *ic, int i, int freq)
529 -{
530 - struct ieee80211_channel *c;
531 - int j;
532 -
533 - /* The normal ordering in the channel list is b channel
534 - * immediately followed by g so optimize the search for
535 - * this. We'll still do a full search just in case. */
536 - for (j = i + 1; j < ic->ic_nchans; j++) {
537 - c = &ic->ic_channels[j];
538 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
539 - return c;
540 - }
541 - for (j = 0; j < i; j++) {
542 - c = &ic->ic_channels[j];
543 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
544 - return c;
545 - }
546 - return NULL;
547 -}
548 -
549 /*
550 * Start an ap scan by populating the channel list.
551 */
552 @@ -429,90 +282,14 @@
553 {
554 struct ap_state *as = ss->ss_priv;
555 struct ieee80211com *ic = NULL;
556 - const struct scanlist *sl = NULL;
557 - struct ieee80211_channel *c = NULL;
558 - int i;
559 - unsigned int mode = 0;
560
561 SCAN_AP_LOCK_IRQ(as);
562 ic = vap->iv_ic;
563 /* Determine mode flags to match, or leave zero for auto mode */
564 as->as_vap_desired_mode = vap->iv_des_mode;
565 as->as_required_mode = 0;
566 - if (as->as_vap_desired_mode != IEEE80211_MODE_AUTO) {
567 - as->as_required_mode = chanflags[as->as_vap_desired_mode];
568 - if ((vap->iv_ath_cap & IEEE80211_ATHC_TURBOP) &&
569 - (as->as_required_mode != IEEE80211_CHAN_ST)) {
570 - /* Fixup for dynamic turbo flags */
571 - if (as->as_vap_desired_mode == IEEE80211_MODE_11G)
572 - as->as_required_mode = IEEE80211_CHAN_108G;
573 - else
574 - as->as_required_mode = IEEE80211_CHAN_108A;
575 - }
576 - }
577 -
578 - ss->ss_last = 0;
579 - /* Use the table of ordered channels to construct the list
580 - * of channels for scanning. Any channels in the ordered
581 - * list not in the master list will be discarded. */
582 - for (sl = staScanTable; sl->list != NULL; sl++) {
583 - mode = sl->mode;
584 -
585 - /* The scan table marks 2.4Ghz channels as b
586 - * so if the desired mode is 11g, then use
587 - * the 11b channel list but upgrade the mode. */
588 - if (as->as_vap_desired_mode &&
589 - (as->as_vap_desired_mode != mode) &&
590 - (as->as_vap_desired_mode == IEEE80211_MODE_11G) &&
591 - (mode == IEEE80211_MODE_11B))
592 - mode = IEEE80211_MODE_11G;
593 -
594 - /* If we are in "AUTO" mode, upgrade the mode to auto.
595 - * This lets add_channels upgrade an 11b channel to
596 - * 11g if available. */
597 - if (!as->as_vap_desired_mode && (mode == IEEE80211_MODE_11B))
598 - mode = IEEE80211_MODE_AUTO;
599 -
600 - /* Add the list of the channels; any that are not
601 - * in the master channel list will be discarded. */
602 - add_channels(ic, ss, mode, sl->list, sl->count);
603 - }
604 -
605 - /* Add the channels from the ic (from HAL) that are not present
606 - * in the staScanTable, assuming they pass the sanity checks... */
607 - for (i = 0; i < ic->ic_nchans; i++) {
608 - c = &ic->ic_channels[i];
609 -
610 - /* XR is not supported on turbo channels */
611 - if (IEEE80211_IS_CHAN_TURBO(c) && vap->iv_flags & IEEE80211_F_XR)
612 - continue;
613 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
614
615 - /* Dynamic channels are scanned in base mode */
616 - if (!as->as_required_mode && !IEEE80211_IS_CHAN_ST(c))
617 - continue;
618 -
619 - /* Use any 11g channel instead of 11b one. */
620 - if (vap->iv_des_mode == IEEE80211_MODE_AUTO &&
621 - IEEE80211_IS_CHAN_B(c) &&
622 - find11gchannel(ic, i, c->ic_freq))
623 - continue;
624 -
625 - /* Do not add channels already put into the scan list by the
626 - * scan table - these have already been filtered by mode
627 - * and for whether they are in the active channel list. */
628 - if (checktable(staScanTable, c))
629 - continue;
630 -
631 - /* Make sure the channel is active */
632 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
633 - continue;
634 -
635 - /* Don't overrun */
636 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
637 - break;
638 -
639 - ss->ss_chans[ss->ss_last++] = c;
640 - }
641 ss->ss_next = 0;
642 /* XXX tunables */
643 ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
644 @@ -831,13 +608,6 @@
645 if (IEEE80211_IS_CHAN_RADAR(c->chan))
646 continue;
647
648 - /* Do not select 802.11a ST if mode is specified and is not
649 - * 802.11a ST */
650 - if (as->as_required_mode &&
651 - IEEE80211_IS_CHAN_STURBO(c->chan) &&
652 - (as->as_vap_desired_mode != IEEE80211_MODE_TURBO_STATIC_A))
653 - continue;
654 -
655 /* Verify mode matches any fixed mode specified */
656 if ((c->chan->ic_flags & as->as_required_mode) !=
657 as->as_required_mode)
658 --- a/net80211/ieee80211_scan.c
659 +++ b/net80211/ieee80211_scan.c
660 @@ -969,6 +969,80 @@
661 }
662 }
663
664 +static const u_int chanflags[] = {
665 + 0, /* IEEE80211_MODE_AUTO */
666 + IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
667 + IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
668 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
669 + IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
670 + IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
671 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
672 + IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
673 +};
674 +
675 +static struct ieee80211_channel *
676 +find11gchannel(struct ieee80211com *ic, int i, int freq)
677 +{
678 + struct ieee80211_channel *c;
679 + int j;
680 +
681 + /*
682 + * The normal ordering in the channel list is b channel
683 + * immediately followed by g so optimize the search for
684 + * this. We'll still do a full search just in case.
685 + */
686 + for (j = i+1; j < ic->ic_nchans; j++) {
687 + c = &ic->ic_channels[j];
688 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
689 + return c;
690 + }
691 + for (j = 0; j < i; j++) {
692 + c = &ic->ic_channels[j];
693 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
694 + return c;
695 + }
696 + return NULL;
697 +}
698 +
699 +
700 +void
701 +ieee80211_scan_add_channels(struct ieee80211com *ic,
702 + struct ieee80211_scan_state *ss,
703 + enum ieee80211_phymode mode)
704 +{
705 + struct ieee80211_channel *c, *cg;
706 + u_int modeflags;
707 + int i;
708 +
709 + KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
710 + modeflags = chanflags[mode];
711 + for (i = 0; i < ic->ic_nchans; i++) {
712 + c = &ic->ic_channels[i];
713 + if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
714 + continue;
715 + if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
716 + continue;
717 + if (modeflags &&
718 + ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
719 + (modeflags & IEEE80211_CHAN_ALLTURBO)))
720 + continue;
721 + if (mode == IEEE80211_MODE_AUTO) {
722 + /*
723 + * XXX special-case 11b/g channels so we select
724 + * the g channel if both are present.
725 + */
726 + if (IEEE80211_IS_CHAN_B(c) &&
727 + (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
728 + continue;
729 + }
730 + if (ss->ss_last >= IEEE80211_SCAN_MAX)
731 + break;
732 + ss->ss_chans[ss->ss_last++] = c;
733 + }
734 +}
735 +EXPORT_SYMBOL(ieee80211_scan_add_channels);
736 +
737 +
738 /*
739 * Execute radar channel change. This is called when a radar/dfs
740 * signal is detected. AP mode only. Return 1 on success, 0 on
741 --- a/net80211/ieee80211_scan.h
742 +++ b/net80211/ieee80211_scan.h
743 @@ -219,4 +219,7 @@
744 void ieee80211_scanner_unregister(enum ieee80211_opmode,
745 const struct ieee80211_scanner *);
746 void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *);
747 +void ieee80211_scan_add_channels(struct ieee80211com *ic,
748 + struct ieee80211_scan_state *ss,
749 + enum ieee80211_phymode mode);
750 #endif /* _NET80211_IEEE80211_SCAN_H_ */
751 --- a/net80211/ieee80211_wireless.c
752 +++ b/net80211/ieee80211_wireless.c
753 @@ -3911,6 +3911,106 @@
754 return ieee80211_ioctl_setmlme(dev, info, w, (char *)&mlme);
755 }
756
757 +static inline void setflag(struct ieee80211_channel *c, int flag)
758 +{
759 + if (flag)
760 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
761 + else
762 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
763 +}
764 +
765 +static void setscanflag(struct ieee80211com *ic, int min, int max, int set)
766 +{
767 + int i;
768 +
769 + for (i = 0; i < ic->ic_nchans; i++) {
770 + struct ieee80211_channel *c = &ic->ic_channels[i];
771 +
772 + if (min == -1) {
773 + if (!(c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT))
774 + setflag(c, set);
775 + } else if ((c->ic_freq >= min) && (c->ic_freq <= max)) {
776 + setflag(c, set);
777 + }
778 + }
779 +}
780 +
781 +static int
782 +ieee80211_ioctl_setscanlist(struct net_device *dev,
783 + struct iw_request_info *info,
784 + struct iw_point *data, char *extra)
785 +{
786 + struct ieee80211vap *vap = dev->priv;
787 + struct ieee80211com *ic = vap->iv_ic;
788 + char *s, *next;
789 + int val = 1;
790 +
791 + if (data->length <= 0)
792 + return -EINVAL;
793 +
794 + s = kmalloc(data->length + 1, GFP_KERNEL);
795 + if (!s)
796 + return -ENOMEM;
797 +
798 + memset(s, 0, data->length + 1);
799 + if (copy_from_user(s, data->pointer, data->length))
800 + return -EFAULT;
801 +
802 + s[data->length - 1] = '\0'; /* ensure null termination */
803 +
804 + switch(*s) {
805 + case '-':
806 + val = 1;
807 + break;
808 + case '+':
809 + val = 0;
810 + break;
811 + default:
812 + goto error;
813 + }
814 + s++;
815 + next = s;
816 + do {
817 + next = strchr(s, ',');
818 + if (next) {
819 + *next = 0;
820 + next++;
821 + }
822 + if (!strcmp(s, "ALL")) {
823 + setscanflag(ic, 0, 10000, val);
824 + } else if (!strcmp(s, "REG")) {
825 + setscanflag(ic, -1, -1, val);
826 + } else {
827 + int min, max;
828 + char *n, *end = NULL;
829 +
830 + n = strchr(s, '-');
831 + if (n) {
832 + *n = 0;
833 + n++;
834 + }
835 + min = simple_strtoul(s, &end, 10);
836 + if (end && *end)
837 + goto error;
838 + if (n) {
839 + max = simple_strtoul(n, &end, 10);
840 + if (end && *end)
841 + goto error;
842 + } else {
843 + max = min;
844 + }
845 + setscanflag(ic, min, max, val);
846 + }
847 + s = next;
848 + } while (next);
849 + return 0;
850 +
851 +error:
852 + if (s)
853 + kfree(s);
854 + return -EINVAL;
855 +}
856 +
857 static int
858 ieee80211_ioctl_addmac(struct net_device *dev, struct iw_request_info *info,
859 void *w, char *extra)
860 @@ -5712,6 +5812,8 @@
861 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "minrate"},
862 {IEEE80211_PARAM_MINRATE,
863 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_minrate"},
864 + { IEEE80211_IOCTL_SETSCANLIST,
865 + IW_PRIV_TYPE_CHAR | 255, 0, "setscanlist"},
866
867 #ifdef ATH_REVERSE_ENGINEERING
868 /*
869 @@ -5809,6 +5911,7 @@
870 set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
871 set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
872 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
873 + set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
874 #ifdef ATH_REVERSE_ENGINEERING
875 set_priv(IEEE80211_IOCTL_READREG, ieee80211_ioctl_readreg),
876 set_priv(IEEE80211_IOCTL_WRITEREG, ieee80211_ioctl_writereg),
This page took 0.071458 seconds and 5 git commands to generate.