gluon-core: gluon.util: pass UCI cursor to get_wlan_mac(), get rid of local UCI context
This commit is contained in:
parent
f48d10bdde
commit
c4613c4e8d
@ -27,7 +27,7 @@ local function configure_client(config, radio, index, suffix)
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 1)
|
||||
local macaddr = util.get_wlan_mac(uci, radio, index, 1)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
|
@ -48,7 +48,7 @@ local function configure_ibss(config, radio, index, suffix, disabled)
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 3)
|
||||
local macaddr = util.get_wlan_mac(uci, radio, index, 3)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
@ -102,7 +102,7 @@ local function configure_mesh(config, radio, index, suffix, disabled)
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 2)
|
||||
local macaddr = util.get_wlan_mac(uci, radio, index, 2)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
@ -137,7 +137,7 @@ local function fixup_wan(radio, index)
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 4)
|
||||
local macaddr = util.get_wlan_mac(uci, radio, index, 4)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
|
@ -36,7 +36,6 @@ local nixio = require 'nixio'
|
||||
local hash = require 'hash'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require('simple-uci').cursor()
|
||||
local fs = require 'nixio.fs'
|
||||
|
||||
|
||||
@ -165,7 +164,7 @@ function find_phy(config)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_addresses(radio)
|
||||
local function get_addresses(uci, radio)
|
||||
local phy = find_phy(uci:get_all('wireless', radio))
|
||||
if not phy then
|
||||
return function() end
|
||||
@ -208,11 +207,11 @@ function generate_mac(i)
|
||||
return string.format('%02x:%s:%s:%s:%s:%02x', m1, m2, m3, m4, m5, m6)
|
||||
end
|
||||
|
||||
local function get_wlan_mac_from_driver(radio, vif)
|
||||
local function get_wlan_mac_from_driver(uci, radio, vif)
|
||||
local primary = sysconfig.primary_mac:lower()
|
||||
|
||||
local i = 1
|
||||
for addr in get_addresses(radio) do
|
||||
for addr in get_addresses(uci, radio) do
|
||||
if addr:lower() ~= primary then
|
||||
if i == vif then
|
||||
return addr
|
||||
@ -223,8 +222,8 @@ local function get_wlan_mac_from_driver(radio, vif)
|
||||
end
|
||||
end
|
||||
|
||||
function get_wlan_mac(radio, index, vif)
|
||||
local addr = get_wlan_mac_from_driver(radio, vif)
|
||||
function get_wlan_mac(uci, radio, index, vif)
|
||||
local addr = get_wlan_mac_from_driver(uci, radio, vif)
|
||||
if addr then
|
||||
return addr
|
||||
end
|
||||
|
@ -31,7 +31,7 @@ function f:write()
|
||||
local name = "wan_" .. radio
|
||||
|
||||
if enabled.data then
|
||||
local macaddr = util.get_wlan_mac(radio, index, 4)
|
||||
local macaddr = util.get_wlan_mac(uci, radio, index, 4)
|
||||
|
||||
uci:section('wireless', "wifi-iface", name, {
|
||||
device = radio,
|
||||
|
Loading…
Reference in New Issue
Block a user