[OpenWRT]判斷WDS是否開啓

OpenWRT的WDS和TP-LINK的私有WDS協議以及BCM的硬件WDS協議有所不一樣,經過判斷無線網絡接口的狀態來肯定WDS是否打開:網絡

#!/usr/bin/lua
--判斷當前WDS是否鏈接上了
require ("luci.fs")
local wifistatus = require("luci.tools.wifistatus")

--獲取wireless網絡信息
wifinets   = wifistatus.wifi_networks();

--默認wds未開啓
iswds = 0;

for i,v in ipairs(wifinets) do
    for j,w in ipairs(v.networks) do
--            print("quality",w.quality);
        if (w.mode == 'Client' and w.bssid ~= nil and w.bssid ~= '00:00:00:00:00:00' and w.channel ~= nil and w.quality > 0 ) then
--            print("bssid",w.bssid);
--            print("channel",w.channel);
--            print("mode",w.mode);
--            print("quality",w.quality);
            iswds = 1;
        end
    end

end


print(iswds);

if ( iswds == 0) then
    return -1;
else
    return 0;
end
相關文章
相關標籤/搜索