gluon-core: move a few WLAN-specific functions from gluon.platform to gluon.wireless
Avoid requiring gluon.wireless from gluon.platform, and requiring gluon.platform from various other scripts.
This commit is contained in:
parent
077439de46
commit
7a2cd66cb9
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local platform = require 'gluon.platform'
|
||||
local wireless = require 'gluon.wireless'
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
@ -52,7 +51,7 @@ local function configure_owe(radio, index, config, radio_name)
|
||||
|
||||
-- Don't configure OWE in case our device
|
||||
-- can't do MFP, as it's mandatory for OWE.
|
||||
if not platform.device_supports_mfp(uci) then
|
||||
if not wireless.device_supports_mfp(uci) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -80,7 +79,7 @@ local function configure_owe_transition_mode(config, radio_name)
|
||||
|
||||
-- Don't configure OWE in case our device
|
||||
-- can't do MFP, as it's mandatory for OWE.
|
||||
if not platform.device_supports_mfp(uci) then
|
||||
if not wireless.device_supports_mfp(uci) then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ return function(form, uci)
|
||||
local platform = require 'gluon.platform'
|
||||
local wireless = require 'gluon.wireless'
|
||||
|
||||
if not (platform.is_outdoor_device() and platform.device_uses_11a(uci)) then
|
||||
if not (platform.is_outdoor_device() and wireless.device_uses_11a(uci)) then
|
||||
-- only visible on wizard for outdoor devices
|
||||
return
|
||||
end
|
||||
|
@ -13,6 +13,7 @@ end
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local platform = require 'gluon.platform'
|
||||
local wireless = require 'gluon.wireless'
|
||||
|
||||
local config = site.wifi5.outdoors('preset')
|
||||
local outdoor
|
||||
@ -22,7 +23,7 @@ if sysconfig.gluon_version then
|
||||
outdoor = false
|
||||
elseif config == 'preset' then
|
||||
-- enable outdoor mode through presets on new installs
|
||||
outdoor = platform.is_outdoor_device() and platform.device_uses_11a(uci)
|
||||
outdoor = platform.is_outdoor_device() and wireless.device_uses_11a(uci)
|
||||
else
|
||||
-- enable/disable outdoor mode unconditionally on new installs
|
||||
outdoor = config
|
||||
|
@ -1,7 +1,5 @@
|
||||
local platform_info = require 'platform_info'
|
||||
local util = require 'gluon.util'
|
||||
local wireless = require 'gluon.wireless'
|
||||
local unistd = require 'posix.unistd'
|
||||
|
||||
|
||||
local M = setmetatable({}, {
|
||||
@ -48,41 +46,4 @@ function M.is_outdoor_device()
|
||||
return false
|
||||
end
|
||||
|
||||
function M.device_supports_wpa3()
|
||||
return unistd.access('/lib/gluon/features/wpa3')
|
||||
end
|
||||
|
||||
function M.device_supports_mfp(uci)
|
||||
local supports_mfp = true
|
||||
|
||||
if not M.device_supports_wpa3() then
|
||||
return false
|
||||
end
|
||||
|
||||
uci:foreach('wireless', 'wifi-device', function(radio)
|
||||
local phy = wireless.find_phy(radio)
|
||||
local phypath = '/sys/kernel/debug/ieee80211/' .. phy .. '/'
|
||||
|
||||
if not util.file_contains_line(phypath .. 'hwflags', 'MFP_CAPABLE') then
|
||||
supports_mfp = false
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
return supports_mfp
|
||||
end
|
||||
|
||||
function M.device_uses_11a(uci)
|
||||
local ret = false
|
||||
|
||||
uci:foreach('wireless', 'wifi-device', function(radio)
|
||||
if radio.hwmode == '11a' or radio.hwmode == '11na' then
|
||||
ret = true
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -126,4 +126,41 @@ function M.preserve_channels(uci)
|
||||
return uci:get_first('gluon-core', 'wireless', 'preserve_channels')
|
||||
end
|
||||
|
||||
function M.device_supports_wpa3()
|
||||
return unistd.access('/lib/gluon/features/wpa3')
|
||||
end
|
||||
|
||||
function M.device_supports_mfp(uci)
|
||||
local supports_mfp = true
|
||||
|
||||
if not M.device_supports_wpa3() then
|
||||
return false
|
||||
end
|
||||
|
||||
uci:foreach('wireless', 'wifi-device', function(radio)
|
||||
local phy = M.find_phy(radio)
|
||||
local phypath = '/sys/kernel/debug/ieee80211/' .. phy .. '/'
|
||||
|
||||
if not util.file_contains_line(phypath .. 'hwflags', 'MFP_CAPABLE') then
|
||||
supports_mfp = false
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
return supports_mfp
|
||||
end
|
||||
|
||||
function M.device_uses_11a(uci)
|
||||
local ret = false
|
||||
|
||||
uci:foreach('wireless', 'wifi-device', function(radio)
|
||||
if radio.hwmode == '11a' or radio.hwmode == '11na' then
|
||||
ret = true
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,5 +1,4 @@
|
||||
local uci = require("simple-uci").cursor()
|
||||
local platform = require 'gluon.platform'
|
||||
local wireless = require 'gluon.wireless'
|
||||
|
||||
-- where to read the configuration from
|
||||
@ -30,7 +29,7 @@ key.default = uci:get('wireless', primary_iface, "key")
|
||||
local encryption = s:option(ListValue, "encryption", translate("Encryption"))
|
||||
encryption:depends(enabled, true)
|
||||
encryption:value("psk2", translate("WPA2"))
|
||||
if platform.device_supports_wpa3() then
|
||||
if wireless.device_supports_wpa3() then
|
||||
encryption:value("psk3-mixed", translate("WPA2 / WPA3"))
|
||||
encryption:value("psk3", translate("WPA3"))
|
||||
end
|
||||
@ -39,7 +38,7 @@ encryption.default = uci:get('wireless', primary_iface, 'encryption') or "psk2"
|
||||
local mfp = s:option(ListValue, "mfp", translate("Management Frame Protection"))
|
||||
mfp:depends(enabled, true)
|
||||
mfp:value("0", translate("Disabled"))
|
||||
if platform.device_supports_mfp(uci) then
|
||||
if wireless.device_supports_mfp(uci) then
|
||||
mfp:value("1", translate("Optional"))
|
||||
mfp:value("2", translate("Required"))
|
||||
end
|
||||
@ -68,7 +67,7 @@ function f:write()
|
||||
})
|
||||
|
||||
-- hostapd-mini won't start in case 802.11w is configured
|
||||
if platform.device_supports_mfp(uci) then
|
||||
if wireless.device_supports_mfp(uci) then
|
||||
uci:set('wireless', name, 'ieee80211w', mfp.data)
|
||||
else
|
||||
uci:delete('wireless', name, 'ieee80211w')
|
||||
|
Loading…
Reference in New Issue
Block a user