1 --- a/net80211/ieee80211_scan_sta.c
2 +++ b/net80211/ieee80211_scan_sta.c
3 @@ -317,147 +317,6 @@ found:
7 -static struct ieee80211_channel *
8 -find11gchannel(struct ieee80211com *ic, int i, int freq)
10 - struct ieee80211_channel *c;
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.
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))
23 - for (j = 0; j < i; j++) {
24 - c = &ic->ic_channels[j];
25 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
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 */
42 -add_channels(struct ieee80211com *ic,
43 - struct ieee80211_scan_state *ss,
44 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
46 - struct ieee80211_channel *c, *cg;
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))
56 - if (mode == IEEE80211_MODE_AUTO) {
58 - * XXX special-case 11b/g channels so we select
59 - * the g channel if both are present.
61 - if (IEEE80211_IS_CHAN_B(c) &&
62 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
65 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
67 - ss->ss_chans[ss->ss_last++] = c;
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 */
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 */
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 */
98 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
99 -{ 5200, 5240, 5280, 5765, 5805 };
100 -#endif /* ATH_TURBO_SCAN */
105 - const u_int16_t *list;
108 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
109 -#define X(a) .count = sizeof(a)/sizeof(a[0]), .list = a
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 */
136 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
140 - for (; scan->list != NULL; scan++) {
141 - for (i = 0; i < scan->count; i++)
142 - if (scan->list[i] == c->ic_freq)
149 * Start a station-mode scan by populating the channel list.
151 @@ -466,81 +325,14 @@ sta_start(struct ieee80211_scan_state *s
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;
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.
166 - for (scan = staScanTable; scan->list != NULL; scan++) {
168 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
170 - * If a desired mode was specified, scan only
171 - * channels that satisfy that constraint.
173 - if (vap->iv_des_mode != mode) {
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.
179 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
180 - mode != IEEE80211_MODE_11B)
182 - mode = IEEE80211_MODE_11G; /* upgrade */
186 - * This lets ieee80211_scan_add_channels
187 - * upgrade an 11b channel to 11g if available.
189 - if (mode == IEEE80211_MODE_11B)
190 - mode = IEEE80211_MODE_AUTO;
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))
198 - * Add the list of the channels; any that are not
199 - * in the master channel list will be discarded.
201 - add_channels(ic, ss, mode, scan->list, scan->count);
205 - * Add the channels from the ic (from HAL) that are not present
206 - * in the staScanTable.
208 - for (i = 0; i < ic->ic_nchans; i++) {
209 - c = &ic->ic_channels[i];
211 - * scan dynamic turbo channels in normal mode.
213 - if (IEEE80211_IS_CHAN_DTURBO(c))
215 - mode = ieee80211_chan2mode(c);
216 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
218 - * If a desired mode was specified, scan only
219 - * channels that satisfy that constraint.
221 - if (vap->iv_des_mode != mode)
225 - if (!checktable(staScanTable, c))
226 - ss->ss_chans[ss->ss_last++] = c;
229 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
234 * The scanner will stay on station for ss_maxdwell ms (using a
235 @@ -749,17 +541,7 @@ match_bss(struct ieee80211vap *vap,
237 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan)))
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
246 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
247 - (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
248 - chanflags[vap->iv_des_mode])
251 if (vap->iv_opmode == IEEE80211_M_IBSS) {
252 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
254 @@ -1168,78 +950,6 @@ static const struct ieee80211_scanner st
255 .scan_default = ieee80211_sta_join,
259 - * Start an adhoc-mode scan by populating the channel list.
262 -adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
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;
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.
275 - for (scan = staScanTable; scan->list != NULL; scan++) {
277 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
279 - * If a desired mode was specified, scan only
280 - * channels that satisfy that constraint.
282 - if (vap->iv_des_mode != mode) {
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.
288 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
289 - mode != IEEE80211_MODE_11B)
291 - mode = IEEE80211_MODE_11G; /* upgrade */
295 - * This lets ieee80211_scan_add_channels
296 - * upgrade an 11b channel to 11g if available.
298 - if (mode == IEEE80211_MODE_11B)
299 - mode = IEEE80211_MODE_AUTO;
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))
307 - * Add the list of the channels; any that are not
308 - * in the master channel list will be discarded.
310 - add_channels(ic, ss, mode, scan->list, scan->count);
314 - ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
315 - ss->ss_maxdwell = msecs_to_jiffies(200); /* 200ms */
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);
324 -#endif /* IEEE80211_DEBUG */
326 - st->st_newscan = 1;
332 * Select a channel to start an adhoc network on.
333 @@ -1405,7 +1115,7 @@ static const struct ieee80211_scanner ad
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 @@ -278,6 +278,11 @@ ieee80211_ifattach(struct ieee80211com *
345 ("channel with bogus ieee number %u", c->ic_ieee));
346 setbit(ic->ic_chan_avail, c->ic_ieee);
348 + if (c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT)
349 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
351 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
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 @@ enum ieee80211_scanmode {
359 IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
362 +enum ieee80211_scanflags {
363 + IEEE80211_NOSCAN_DEFAULT = (1 << 0),
364 + IEEE80211_NOSCAN_SET = (1 << 1),
368 * Channels are specified by frequency and attributes.
370 @@ -142,6 +147,7 @@ struct ieee80211_channel {
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;
377 #define IEEE80211_CHAN_MAX 255
378 --- a/net80211/ieee80211_ioctl.h
379 +++ b/net80211/ieee80211_ioctl.h
380 @@ -555,6 +555,7 @@ struct ieee80211req_scan_result {
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)
387 IEEE80211_WMMPARAMS_CWMIN = 1,
388 --- a/net80211/ieee80211_scan_ap.c
389 +++ b/net80211/ieee80211_scan_ap.c
390 @@ -129,131 +129,7 @@ struct ap_state {
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,
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
407 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
408 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
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,
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 */
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 */
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 */
441 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
442 -{ 5200, 5240, 5280, 5765, 5805 };
443 -#endif /* ATH_TURBO_SCAN */
448 - const u_int16_t *list;
451 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
452 -#define X(a) .count = ARRAY_SIZE(a), .list = a
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 */
477 -/* This function must be invoked with locks acquired */
479 -add_channels(struct ieee80211com *ic,
480 - struct ieee80211_scan_state *ss,
481 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
483 - struct ieee80211_channel *c, *cg;
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))
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)
500 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
502 - ss->ss_chans[ss->ss_last++] = c;
506 -/* This function must be invoked with locks acquired */
508 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
512 - for (; scan->list != NULL; scan++) {
513 - for (i = 0; i < scan->count; i++)
514 - if (scan->list[i] == c->ic_freq)
521 * Attach prior to any scanning work.
522 @@ -327,29 +203,6 @@ saveie(u_int8_t **iep, const u_int8_t *i
523 ieee80211_saveie(iep, ie);
526 -/* This function must be invoked with locks acquired */
527 -static struct ieee80211_channel *
528 -find11gchannel(struct ieee80211com *ic, int i, int freq)
530 - struct ieee80211_channel *c;
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))
541 - for (j = 0; j < i; j++) {
542 - c = &ic->ic_channels[j];
543 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
550 * Start an ap scan by populating the channel list.
552 @@ -358,8 +211,6 @@ ap_start(struct ieee80211_scan_state *ss
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;
559 unsigned int mode = 0;
561 @@ -368,80 +219,8 @@ ap_start(struct ieee80211_scan_state *ss
562 /* Determine mode flags to match, or leave zero for auto mode */
563 as->as_vap_desired_mode = vap->iv_des_mode;
564 as->as_required_mode = 0;
565 - if (as->as_vap_desired_mode != IEEE80211_MODE_AUTO) {
566 - as->as_required_mode = chanflags[as->as_vap_desired_mode];
567 - if ((vap->iv_ath_cap & IEEE80211_ATHC_TURBOP) &&
568 - (as->as_required_mode != IEEE80211_CHAN_ST)) {
569 - /* Fixup for dynamic turbo flags */
570 - if (as->as_vap_desired_mode == IEEE80211_MODE_11G)
571 - as->as_required_mode = IEEE80211_CHAN_108G;
573 - as->as_required_mode = IEEE80211_CHAN_108A;
578 - /* Use the table of ordered channels to construct the list
579 - * of channels for scanning. Any channels in the ordered
580 - * list not in the master list will be discarded. */
581 - for (sl = staScanTable; sl->list != NULL; sl++) {
584 - /* The scan table marks 2.4Ghz channels as b
585 - * so if the desired mode is 11g, then use
586 - * the 11b channel list but upgrade the mode. */
587 - if (as->as_vap_desired_mode &&
588 - (as->as_vap_desired_mode != mode) &&
589 - (as->as_vap_desired_mode == IEEE80211_MODE_11G) &&
590 - (mode == IEEE80211_MODE_11B))
591 - mode = IEEE80211_MODE_11G;
593 - /* If we are in "AUTO" mode, upgrade the mode to auto.
594 - * This lets add_channels upgrade an 11b channel to
595 - * 11g if available. */
596 - if (!as->as_vap_desired_mode && (mode == IEEE80211_MODE_11B))
597 - mode = IEEE80211_MODE_AUTO;
599 - /* Add the list of the channels; any that are not
600 - * in the master channel list will be discarded. */
601 - add_channels(ic, ss, mode, sl->list, sl->count);
604 - /* Add the channels from the ic (from HAL) that are not present
605 - * in the staScanTable, assuming they pass the sanity checks... */
606 - for (i = 0; i < ic->ic_nchans; i++) {
607 - c = &ic->ic_channels[i];
609 - /* XR is not supported on turbo channels */
610 - if (IEEE80211_IS_CHAN_TURBO(c) && vap->iv_flags & IEEE80211_F_XR)
612 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
614 - /* Dynamic channels are scanned in base mode */
615 - if (!as->as_required_mode && !IEEE80211_IS_CHAN_ST(c))
618 - /* Use any 11g channel instead of 11b one. */
619 - if (vap->iv_des_mode == IEEE80211_MODE_AUTO &&
620 - IEEE80211_IS_CHAN_B(c) &&
621 - find11gchannel(ic, i, c->ic_freq))
624 - /* Do not add channels already put into the scan list by the
625 - * scan table - these have already been filtered by mode
626 - * and for whether they are in the active channel list. */
627 - if (checktable(staScanTable, c))
630 - /* Make sure the channel is active */
631 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
634 - /* Don't overrun */
635 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
638 - ss->ss_chans[ss->ss_last++] = c;
642 ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
643 @@ -761,13 +540,6 @@ pick_channel(struct ieee80211_scan_state
644 if (IEEE80211_IS_CHAN_RADAR(c->chan))
647 - /* Do not select 802.11a ST if mode is specified and is not
649 - if (as->as_required_mode &&
650 - IEEE80211_IS_CHAN_STURBO(c->chan) &&
651 - (as->as_vap_desired_mode != IEEE80211_MODE_TURBO_STATIC_A))
654 /* Verify mode matches any fixed mode specified */
655 if((c->chan->ic_flags & as->as_required_mode) !=
656 as->as_required_mode)
657 --- a/net80211/ieee80211_scan.c
658 +++ b/net80211/ieee80211_scan.c
659 @@ -958,6 +958,80 @@ ieee80211_scan_flush(struct ieee80211com
663 +static const u_int chanflags[] = {
664 + 0, /* IEEE80211_MODE_AUTO */
665 + IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
666 + IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
667 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
668 + IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
669 + IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
670 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
671 + IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
674 +static struct ieee80211_channel *
675 +find11gchannel(struct ieee80211com *ic, int i, int freq)
677 + struct ieee80211_channel *c;
681 + * The normal ordering in the channel list is b channel
682 + * immediately followed by g so optimize the search for
683 + * this. We'll still do a full search just in case.
685 + for (j = i+1; j < ic->ic_nchans; j++) {
686 + c = &ic->ic_channels[j];
687 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
690 + for (j = 0; j < i; j++) {
691 + c = &ic->ic_channels[j];
692 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
700 +ieee80211_scan_add_channels(struct ieee80211com *ic,
701 + struct ieee80211_scan_state *ss,
702 + enum ieee80211_phymode mode)
704 + struct ieee80211_channel *c, *cg;
708 + KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
709 + modeflags = chanflags[mode];
710 + for (i = 0; i < ic->ic_nchans; i++) {
711 + c = &ic->ic_channels[i];
712 + if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
714 + if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
717 + ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
718 + (modeflags & IEEE80211_CHAN_ALLTURBO)))
720 + if (mode == IEEE80211_MODE_AUTO) {
722 + * XXX special-case 11b/g channels so we select
723 + * the g channel if both are present.
725 + if (IEEE80211_IS_CHAN_B(c) &&
726 + (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
729 + if (ss->ss_last >= IEEE80211_SCAN_MAX)
731 + ss->ss_chans[ss->ss_last++] = c;
734 +EXPORT_SYMBOL(ieee80211_scan_add_channels);
738 * Execute radar channel change. This is called when a radar/dfs
739 * signal is detected. AP mode only. Return 1 on success, 0 on
740 --- a/net80211/ieee80211_scan.h
741 +++ b/net80211/ieee80211_scan.h
742 @@ -219,4 +219,7 @@ void ieee80211_scanner_register(enum iee
743 void ieee80211_scanner_unregister(enum ieee80211_opmode,
744 const struct ieee80211_scanner *);
745 void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *);
746 +void ieee80211_scan_add_channels(struct ieee80211com *ic,
747 + struct ieee80211_scan_state *ss,
748 + enum ieee80211_phymode mode);
749 #endif /* _NET80211_IEEE80211_SCAN_H_ */
750 --- a/net80211/ieee80211_wireless.c
751 +++ b/net80211/ieee80211_wireless.c
752 @@ -3873,6 +3873,106 @@ ieee80211_ioctl_kickmac(struct net_devic
753 return ieee80211_ioctl_setmlme(dev, info, w, (char *)&mlme);
756 +static inline void setflag(struct ieee80211_channel *c, int flag)
759 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
761 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
764 +static void setscanflag(struct ieee80211com *ic, int min, int max, int set)
768 + for (i = 0; i < ic->ic_nchans; i++) {
769 + struct ieee80211_channel *c = &ic->ic_channels[i];
772 + if (!(c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT))
774 + } else if ((c->ic_freq >= min) && (c->ic_freq <= max)) {
781 +ieee80211_ioctl_setscanlist(struct net_device *dev,
782 + struct iw_request_info *info,
783 + struct iw_point *data, char *extra)
785 + struct ieee80211vap *vap = dev->priv;
786 + struct ieee80211com *ic = vap->iv_ic;
790 + if (data->length <= 0)
793 + s = kmalloc(data->length + 1, GFP_KERNEL);
797 + memset(s, 0, data->length + 1);
798 + if (copy_from_user(s, data->pointer, data->length))
801 + s[data->length - 1] = '\0'; /* ensure null termination */
816 + next = strchr(s, ',');
821 + if (!strcmp(s, "ALL")) {
822 + setscanflag(ic, 0, 10000, val);
823 + } else if (!strcmp(s, "REG")) {
824 + setscanflag(ic, -1, -1, val);
827 + char *n, *end = NULL;
829 + n = strchr(s, '-');
834 + min = simple_strtoul(s, &end, 10);
838 + max = simple_strtoul(n, &end, 10);
844 + setscanflag(ic, min, max, val);
857 ieee80211_ioctl_addmac(struct net_device *dev, struct iw_request_info *info,
858 void *w, char *extra)
859 @@ -5656,6 +5756,8 @@ static const struct iw_priv_args ieee802
860 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "minrate"},
861 {IEEE80211_PARAM_MINRATE,
862 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_minrate"},
863 + { IEEE80211_IOCTL_SETSCANLIST,
864 + IW_PRIV_TYPE_CHAR | 255, 0, "setscanlist"},
866 #ifdef ATH_REVERSE_ENGINEERING
868 @@ -5753,6 +5855,7 @@ static const iw_handler ieee80211_priv_h
869 set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
870 set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
871 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
872 + set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
873 #ifdef ATH_REVERSE_ENGINEERING
874 set_priv(IEEE80211_IOCTL_READREG, ieee80211_ioctl_readreg),
875 set_priv(IEEE80211_IOCTL_WRITEREG, ieee80211_ioctl_writereg),