]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - wilink8-wlan/hostap.git/commitdiff
hostapd: sync channel on interface setup
authorEliad Peller <eliad@wizery.com>
Thu, 19 Dec 2013 11:22:10 +0000 (13:22 +0200)
committerEliad Peller <eliad@wizery.com>
Thu, 19 Dec 2013 13:20:22 +0000 (15:20 +0200)
If another ap iface is enabled, sync to its channel
(if ap_channel_sync is set).

Signed-off-by: Eliad Peller <eliad@wizery.com>
src/ap/hostapd.c

index f731581f5ae572de0335db893dcbd41d41d01ab0..1a7ff6bcbd3c888061410ce211fa20a877f0f1a0 100644 (file)
@@ -1079,6 +1079,35 @@ static int setup_interface2(struct hostapd_iface *iface)
        return hostapd_setup_interface_complete(iface, 0);
 }
 
+static int hostapd_sync_channel(struct hostapd_iface *hapd_iface)
+{
+       int i;
+
+       if (!hapd_iface->interfaces)
+               return -1;
+
+       wpa_printf(MSG_DEBUG, "Syncing AP channel");
+
+       for (i = 0; i < hapd_iface->interfaces->count; i++) {
+               struct hostapd_iface *iface = hapd_iface->interfaces->iface[i];
+
+               if (iface->state != HAPD_IFACE_ENABLED)
+                       continue;
+
+               hapd_iface->conf->hw_mode = iface->conf->hw_mode;
+               hapd_iface->conf->channel = iface->conf->channel;
+               hapd_iface->conf->secondary_channel =
+                               iface->conf->secondary_channel;
+               wpa_printf(MSG_DEBUG, "Channel automatically synced to "
+                          "existing AP: %d (secondary: %d) (mode: %s)",
+                          iface->conf->channel,
+                          iface->conf->secondary_channel,
+                          hostapd_hw_mode_txt(iface->conf->hw_mode));
+               return 1;
+       }
+
+       return 0;
+}
 
 /**
  * hostapd_setup_interface_complete - Complete interface setup
@@ -1103,6 +1132,10 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
        }
 
        wpa_printf(MSG_DEBUG, "Completing interface initialization");
+
+       if (iface->conf->ap_channel_sync)
+               hostapd_sync_channel(iface);
+
        if (iface->conf->channel) {
 #ifdef NEED_AP_MLME
                int res;