From 4b5455194dfb73a2d7d225ba410850049a6faf72 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Mon, 14 Oct 2024 00:36:52 +0200 Subject: [PATCH] glon-core: fixup imports after rebase --- .../lib/gluon/upgrade/320-gluon-client-bridge-wireless | 8 ++++---- .../gluon-core/luasrc/lib/gluon/upgrade/200-wireless | 4 ++-- package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua | 10 ---------- .../gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua | 10 ++++++++++ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless index 0a5b614876..8542c35118 100755 --- a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless +++ b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless @@ -4,7 +4,6 @@ local wireless = require 'gluon.wireless' local uci = require('simple-uci').cursor() local sysconfig = require 'gluon.sysconfig' -local iwinfo = require 'iwinfo' local function is_disabled(config, name) @@ -24,7 +23,7 @@ local function configure_ap(radio, index, config, radio_name) local ap = config.ap local disabled = is_disabled(ap, name) - if not util.supports_channel(radio, config.channel()) then + if not wireless.supports_channel(radio, config.channel()) then has_client_radio = true end @@ -121,12 +120,13 @@ wireless.foreach_radio(uci, function(radio, index, config) end) if not sysconfig.gluon_version and has_client_radio then - util.foreach_radio(uci, function(radio, index, config) + wireless.foreach_radio(uci, function(radio, _, config) local radio_name = radio['.name'] local name = 'client_' .. radio_name - if util.supports_channel(radio, config.channel()) and (radio.hwmode == '11a' or radio.hwmode == '11na') then + -- disable client radio on the 5GHz band which supports the mesh channel + if wireless.supports_channel(radio, config.channel()) and radio.band == '5g' then uci:set('wireless', name, 'disabled', true) end end) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index 535d4b8c57..7669d6616d 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -53,7 +53,7 @@ local function is_outdoor() end local function get_channel(radio, config) - if radio.band == '5g' and (is_outdoor() or not util.supports_channel(radio, config.channel())) then + if radio.band == '5g' and (is_outdoor() or not wireless.supports_channel(radio, config.channel())) then -- actual channel will be picked and probed from chanlist return 'auto' end @@ -227,7 +227,7 @@ wireless.foreach_radio(uci, function(radio, index, config) util.remove_from_set(hostapd_options, 'country3=0x4f') uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options) - if is_outdoor() or not util.supports_channel(radio, config.channel()) then + if is_outdoor() or not wireless.supports_channel(radio, config.channel()) then -- enforce outdoor channels by filtering the regdom for outdoor channels uci:set('wireless', radio_name, 'country3', '0x4f') configure_mesh_wireless(radio, index, config, true) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua index da8b795f01..354e94bd07 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua @@ -167,16 +167,6 @@ function M.get_role_interfaces(uci, role, exclusive) return ret end -local function supports_channel(radio, channel) - local phy = M.find_phy(radio) - for i, chan in ipairs(iwinfo.nl80211.freqlist(phy)) do - if channel == chan.channel then - return true - end - end - return false -end - -- Safe glob: returns an empty table when the glob fails because of -- a non-existing path function M.glob(pattern) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua index 01379a1d11..85db6d15a9 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua @@ -39,6 +39,16 @@ local function get_wlan_mac_from_driver(radio, vif) return addresses[vif] end +function M.supports_channel(radio, channel) + local phy = M.find_phy(radio) + for _, chan in ipairs(iwinfo.nl80211.freqlist(phy)) do + if channel == chan.channel then + return true + end + end + return false +end + function M.get_wlan_mac(_, radio, index, vif) local addr = get_wlan_mac_from_driver(radio, vif) if addr then