aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliad Peller2013-04-02 11:57:01 -0500
committerEliad Peller2013-04-18 10:23:16 -0500
commit5b1478d0bf49bea4142b815025549f62de535026 (patch)
tree9a446a29c6caacadabc93fc779c11ab0d63e55c6
parenta27941bd84bc1418940d3e221c7fdbbdfbb67b7b (diff)
downloadhostap-smart_config.tar.gz
hostap-smart_config.tar.xz
hostap-smart_config.zip
smart_config: scan social channels firstsmart_config
scan on channels 1/6/11 first (that is the current requirement. it doesn't seem very useful, though...) we can also simplify the code by letting the driver check whether the channel is disabled. however, the rest of the scan code checks it in userspace as well, so do it also here. Signed-off-by: Eliad Peller <eliad@wizery.com>
-rw-r--r--wpa_supplicant/scan.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 63763e6c..6995c5ce 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -515,6 +515,75 @@ static void wpa_setband_scan_freqs_list(struct wpa_supplicant *wpa_s,
515} 515}
516 516
517 517
518static void wpa_smart_config_setband_freqs_list(struct wpa_supplicant *wpa_s,
519 enum hostapd_hw_mode band,
520 struct wpa_driver_scan_params *params,
521 int *count)
522{
523 /* Include only supported channels for the specified band */
524 struct hostapd_hw_modes *mode;
525 int i;
526
527 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, band);
528 if (mode == NULL)
529 return;
530
531 /* write channel 1/6/11 first */
532 if (band == HOSTAPD_MODE_IEEE80211G) {
533 for (i = 0; i < mode->num_channels; i++) {
534 struct hostapd_channel_data *chan = &mode->channels[i];
535
536 if (chan->flag & HOSTAPD_CHAN_DISABLED)
537 continue;
538
539 if (chan->chan != 1 && chan->chan != 6 &&
540 chan->chan != 11)
541 continue;
542
543 params->freqs[(*count)++] = chan->freq;
544 }
545 }
546
547 for (i = 0; i < mode->num_channels; i++) {
548 struct hostapd_channel_data *chan = &mode->channels[i];
549
550 if (chan->flag & HOSTAPD_CHAN_DISABLED)
551 continue;
552 if (band == HOSTAPD_MODE_IEEE80211G &&
553 (chan->chan == 1 || chan->chan == 6 || chan->chan == 11))
554 continue;
555 params->freqs[(*count)++] = chan->freq;
556 }
557 return;
558}
559
560static void wpa_smart_config_scan_freqs_list(struct wpa_supplicant *wpa_s,
561 struct wpa_driver_scan_params *params)
562{
563 int num_channels = 0;
564 int count = 0;
565 struct hostapd_hw_modes *mode;
566
567 wpa_dbg(wpa_s, MSG_DEBUG, "Creating freqs list for smart config sched scan");
568 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
569 HOSTAPD_MODE_IEEE80211G);
570 if (mode)
571 num_channels += mode->num_channels;
572
573 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
574 HOSTAPD_MODE_IEEE80211A);
575 if (mode)
576 num_channels += mode->num_channels;
577
578 params->freqs = os_zalloc((num_channels + 1) * sizeof(int));
579 if (params->freqs == NULL)
580 return;
581
582 wpa_smart_config_setband_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G,
583 params, &count);
584 wpa_smart_config_setband_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
585 params, &count);
586}
518static void wpa_setband_scan_freqs(struct wpa_supplicant *wpa_s, 587static void wpa_setband_scan_freqs(struct wpa_supplicant *wpa_s,
519 struct wpa_driver_scan_params *params) 588 struct wpa_driver_scan_params *params)
520{ 589{
@@ -522,6 +591,10 @@ static void wpa_setband_scan_freqs(struct wpa_supplicant *wpa_s,
522 return; /* unknown what channels the driver supports */ 591 return; /* unknown what channels the driver supports */
523 if (params->freqs) 592 if (params->freqs)
524 return; /* already using a limited channel set */ 593 return; /* already using a limited channel set */
594 if (wpa_s->smart_config_in_sync) {
595 wpa_smart_config_scan_freqs_list(wpa_s, params);
596 return;
597 }
525 if (wpa_s->setband == WPA_SETBAND_5G) 598 if (wpa_s->setband == WPA_SETBAND_5G)
526 wpa_setband_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, 599 wpa_setband_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
527 params); 600 params);