mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
mtwifi-cfg: fix l1util
This commit is contained in:
parent
8ff4cfb0e5
commit
f289bbe415
@ -35,6 +35,7 @@ define Package/mtwifi-cfg/install
|
|||||||
$(INSTALL_BIN) ./files/mtwifi-cfg/mtwifi_defs.lua $(1)/usr/lib/lua/
|
$(INSTALL_BIN) ./files/mtwifi-cfg/mtwifi_defs.lua $(1)/usr/lib/lua/
|
||||||
$(INSTALL_BIN) ./files/mtwifi-cfg/mtwifi_utils.lua $(1)/usr/lib/lua/
|
$(INSTALL_BIN) ./files/mtwifi-cfg/mtwifi_utils.lua $(1)/usr/lib/lua/
|
||||||
$(INSTALL_BIN) ./files/l1util/l1util $(1)/sbin/
|
$(INSTALL_BIN) ./files/l1util/l1util $(1)/sbin/
|
||||||
|
$(LN) l1util $(1)/sbin/l1dat
|
||||||
$(INSTALL_BIN) ./files/l1util/l1dat_parser.lua $(1)/usr/lib/lua/
|
$(INSTALL_BIN) ./files/l1util/l1dat_parser.lua $(1)/usr/lib/lua/
|
||||||
$(INSTALL_DATA) ./files/hotplug/10-mtwifi-detect $(1)/etc/hotplug.d/net/
|
$(INSTALL_DATA) ./files/hotplug/10-mtwifi-detect $(1)/etc/hotplug.d/net/
|
||||||
endef
|
endef
|
||||||
|
@ -98,6 +98,36 @@ function l1dat_parser.l1_ifname_to_datpath(ifname)
|
|||||||
return devs[ridx][ifname] and devs[ridx][ifname].profile_path
|
return devs[ridx][ifname] and devs[ridx][ifname].profile_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function l1dat_parser.l1_ifname_to_zone(ifname)
|
||||||
|
if not ifname then return end
|
||||||
|
|
||||||
|
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||||
|
if not devs then return end
|
||||||
|
|
||||||
|
local ridx = l1dat_parser.IF_RINDEX
|
||||||
|
return devs[ridx][ifname] and devs[ridx][ifname].nvram_zone
|
||||||
|
end
|
||||||
|
|
||||||
|
function l1dat_parser.l1_zone_to_ifname(zone)
|
||||||
|
if not zone then return end
|
||||||
|
|
||||||
|
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||||
|
if not devs then return end
|
||||||
|
|
||||||
|
local zone_dev
|
||||||
|
for _, dev in pairs(devs[l1dat_parser.DEV_RINDEX]) do
|
||||||
|
if dev.nvram_zone == zone then
|
||||||
|
zone_dev = dev
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not zone_dev then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return zone_dev.main_ifname, zone_dev.ext_ifname, zone_dev.apcli_ifname, zone_dev.wds_ifname, zone_dev.mesh_ifname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- input: L1 profile path.
|
-- input: L1 profile path.
|
||||||
-- output A table, devs, contains
|
-- output A table, devs, contains
|
||||||
-- 1. devs[%d] = table of each INDEX# in the L1 profile
|
-- 1. devs[%d] = table of each INDEX# in the L1 profile
|
||||||
|
@ -21,6 +21,10 @@ if not l1dat then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function show_usage()
|
||||||
|
print("Usage: l1util list | get <dev> <prop> | idx2if <idx> | if2zone <ifname> | if2dat <ifname> | zone2if <zone> | if2dbdcidx <ifname>")
|
||||||
|
end
|
||||||
|
|
||||||
function show_devs()
|
function show_devs()
|
||||||
local ret = ""
|
local ret = ""
|
||||||
for k, _ in pairs(l1dat.devname_ridx) do
|
for k, _ in pairs(l1dat.devname_ridx) do
|
||||||
@ -46,11 +50,82 @@ local action = {
|
|||||||
|
|
||||||
["get"] = function(dev, prop)
|
["get"] = function(dev, prop)
|
||||||
get_dev_prop(dev, prop)
|
get_dev_prop(dev, prop)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["if2zone"] = function(ifname)
|
||||||
|
if not ifname then return end
|
||||||
|
|
||||||
|
local zone = l1parser.l1_ifname_to_zone(ifname) or ""
|
||||||
|
print(zone);
|
||||||
|
end,
|
||||||
|
|
||||||
|
["if2dat"] = function(ifname)
|
||||||
|
if not ifname then return end
|
||||||
|
|
||||||
|
local dat_path = l1parser.l1_ifname_to_datpath(ifname) or ""
|
||||||
|
print(dat_path)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["zone2if"] = function(zone)
|
||||||
|
if not zone then return end
|
||||||
|
|
||||||
|
local main_if, ext_if, apcli, wds, mesh = l1parser.l1_zone_to_ifname(zone)
|
||||||
|
|
||||||
|
if main_if then
|
||||||
|
print(main_if.." "..ext_if.." "..apcli.." "..wds.." "..mesh)
|
||||||
end
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
["idx2if"] = function(idx)
|
||||||
|
if not idx then return end
|
||||||
|
|
||||||
|
idx = tonumber(idx)
|
||||||
|
|
||||||
|
local band_num = l1parser.MAX_NUM_DBDC_BAND
|
||||||
|
local dbdc_if
|
||||||
|
local count = 0
|
||||||
|
for k, v in pairs(l1dat) do
|
||||||
|
-- check if last dbdc exists
|
||||||
|
dbdc_if = l1parser.token_get(v.main_ifname, band_num, nil)
|
||||||
|
if dbdc_if then
|
||||||
|
count = count + band_num;
|
||||||
|
else
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if not dbdc_if and count == idx then
|
||||||
|
print(v.main_ifname)
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
if count >= idx then -- dbdc case
|
||||||
|
local token_num = band_num - ( count - idx )
|
||||||
|
print(l1parser.token_get(v.main_ifname, token_num, nil))
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
["if2dbdcidx"] = function(ifname)
|
||||||
|
if not ifname then return end
|
||||||
|
|
||||||
|
local ridx = l1parser.IF_RINDEX
|
||||||
|
|
||||||
|
if not l1dat[ridx][ifname] then return end
|
||||||
|
|
||||||
|
print(l1dat[ridx][ifname]["subidx"] or "0")
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
if #arg == 1 then
|
|
||||||
|
if #arg == 0 then
|
||||||
|
show_usage()
|
||||||
|
elseif #arg == 1 then
|
||||||
action[arg[1]]()
|
action[arg[1]]()
|
||||||
|
elseif #arg == 2 then
|
||||||
|
action[arg[1]](arg[2])
|
||||||
elseif #arg == 3 then
|
elseif #arg == 3 then
|
||||||
action[arg[1]](arg[2], arg[3])
|
action[arg[1]](arg[2], arg[3])
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user