From patchwork Tue Oct 15 12:10:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 283618 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BFD602C00AC for ; Tue, 15 Oct 2013 23:11:52 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B79FB9C0F3; Tue, 15 Oct 2013 08:11:50 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03G8Rg5pykmS; Tue, 15 Oct 2013 08:11:50 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 76EA69C13E; Tue, 15 Oct 2013 08:10:45 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 034849C13D for ; Tue, 15 Oct 2013 08:10:44 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NmpgGsj+j42Q for ; Tue, 15 Oct 2013 08:10:39 -0400 (EDT) Received: from mail-ea0-f180.google.com (mail-ea0-f180.google.com [209.85.215.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id E01BC9C0DD for ; Tue, 15 Oct 2013 08:10:23 -0400 (EDT) Received: by mail-ea0-f180.google.com with SMTP id h10so3905186eaj.39 for ; Tue, 15 Oct 2013 05:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fa5HQLb/2w9IdYUL8TmRwoHh1UDIEo2+ogaChFwheQc=; b=hbPsRRhIGGr0ILjUVB8Os+23zTCt/DIB2NdSmevAYKnVPjGcA4eN+PEF+WX6bi40lX 1lc0DZjJHmsBZTBoUOEY31F2mLx3H4C7fNmCsyi61xHE25p3l5vlTdnOuP+k6fVXgHeK MOgXB5UVmjFMn9kA+8pbzZAEJrFAldbDRe4q+M004b6Oz5Iru4u7YLsvFtqhLpK0OOdU CHnWuBBNiF6qC4bH2ZK8hOgf4BrLijVMxXXSeqtsfR+VUzyBLrbg/KLNR9LFpxP3lI7T fKv+Q3/P7H1shOxB4prU9j9pDu0vrHOMiZQ8mb0fhaxQ+qztFTvos0R0AnGnXzvCOlZd mkOw== X-Received: by 10.14.208.194 with SMTP id q42mr313892eeo.31.1381839022884; Tue, 15 Oct 2013 05:10:22 -0700 (PDT) Received: from hschaa-desktop.site ([217.8.58.223]) by mx.google.com with ESMTPSA id bn13sm165888530eeb.11.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 05:10:22 -0700 (PDT) From: Helmut Schaa To: hostap@lists.shmoo.com Subject: [PATCH 4/4] hostapd: Select any supported channel if ACS fails Date: Tue, 15 Oct 2013 14:10:10 +0200 Message-Id: <1381839010-30681-4-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1381839010-30681-3-git-send-email-helmut.schaa@googlemail.com> References: <1381839010-30681-1-git-send-email-helmut.schaa@googlemail.com> <1381839010-30681-2-git-send-email-helmut.schaa@googlemail.com> <1381839010-30681-3-git-send-email-helmut.schaa@googlemail.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Signed-off-by: Helmut Schaa --- src/ap/acs.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/ap/acs.c b/src/ap/acs.c index e18c3d7..be9b2ca 100644 --- a/src/ap/acs.c +++ b/src/ap/acs.c @@ -470,7 +470,7 @@ static struct hostapd_channel_data *acs_find_chan(struct hostapd_iface *iface, for (i = 0; i < iface->current_mode->num_channels; i++) { chan = &iface->current_mode->channels[i]; - if (!acs_usable_chan(chan)) + if (chan->flag & HOSTAPD_CHAN_DISABLED) continue; if (chan->freq == freq) @@ -490,7 +490,7 @@ static struct hostapd_channel_data *acs_find_chan(struct hostapd_iface *iface, static struct hostapd_channel_data * acs_find_ideal_chan(struct hostapd_iface *iface) { - struct hostapd_channel_data *chan, *adj_chan, *ideal_chan = NULL; + struct hostapd_channel_data *chan, *adj_chan, *ideal_chan = NULL, *rand_chan = NULL; long double factor, ideal_factor = 0; int i, j; int n_chans = 1; @@ -522,9 +522,10 @@ acs_find_ideal_chan(struct hostapd_iface *iface) for (i = 0; i < iface->current_mode->num_channels; i++) { chan = &iface->current_mode->channels[i]; - if (!acs_usable_chan(chan)) + if (chan->flag & HOSTAPD_CHAN_DISABLED) continue; + /* HT40 on 5 GHz has a limited set of primary channels as per * 11n Annex J */ if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && @@ -536,14 +537,17 @@ acs_find_ideal_chan(struct hostapd_iface *iface) continue; } - factor = chan->interference_factor; + factor = 0; + if (acs_usable_chan(chan)) + factor = chan->interference_factor; for (j = 1; j < n_chans; j++) { adj_chan = acs_find_chan(iface, chan->freq + (j * 20)); if (!adj_chan) break; - factor += adj_chan->interference_factor; + if (acs_usable_chan(adj_chan)) + factor += adj_chan->interference_factor; } if (j != n_chans) { @@ -562,22 +566,22 @@ acs_find_ideal_chan(struct hostapd_iface *iface) adj_chan = acs_find_chan(iface, chan->freq + (j * 20) - 5); - if (adj_chan) + if (adj_chan && acs_usable_chan(adj_chan)) factor += adj_chan->interference_factor; adj_chan = acs_find_chan(iface, chan->freq + (j * 20) - 10); - if (adj_chan) + if (adj_chan && acs_usable_chan(adj_chan)) factor += adj_chan->interference_factor; adj_chan = acs_find_chan(iface, chan->freq + (j * 20) + 5); - if (adj_chan) + if (adj_chan && acs_usable_chan(adj_chan)) factor += adj_chan->interference_factor; adj_chan = acs_find_chan(iface, chan->freq + (j * 20) + 10); - if (adj_chan) + if (adj_chan && acs_usable_chan(adj_chan)) factor += adj_chan->interference_factor; } } @@ -585,17 +589,25 @@ acs_find_ideal_chan(struct hostapd_iface *iface) wpa_printf(MSG_DEBUG, "ACS: * channel %d: total interference = %Lg", chan->chan, factor); - if (!ideal_chan || factor < ideal_factor) { - ideal_factor = factor; - ideal_chan = chan; + if (acs_usable_chan(chan)) { + if (!ideal_chan || factor < ideal_factor) { + ideal_factor = factor; + ideal_chan = chan; + } } + + /* This channel would at least be usable */ + if (!rand_chan) + rand_chan = chan; } - if (ideal_chan) + if (ideal_chan) { wpa_printf(MSG_DEBUG, "ACS: Ideal channel is %d (%d MHz) with total interference factor of %Lg", ideal_chan->chan, ideal_chan->freq, ideal_factor); + return ideal_chan; + } - return ideal_chan; + return rand_chan; }