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