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