NIU: Allow automatic unbridging of LAN ethernet for WAN use
[project/luci.git] / modules / niu / luasrc / niulib.lua
index 2a46355..dc3df5e 100644 (file)
@@ -15,7 +15,9 @@ $Id$
 local ipairs, pairs, require = ipairs, pairs, require
 local os = require "os"
 
 local ipairs, pairs, require = ipairs, pairs, require
 local os = require "os"
 
-local cursor = require "luci.model.uci".inst
+local uci = require "luci.model.uci"
+local cursor = uci.inst
+local state = uci.inst_state
 
 
 module "luci.niulib"
 
 
 module "luci.niulib"
@@ -36,6 +38,20 @@ function eth_get_available(except)
        return ifs
 end
 
        return ifs
 end
 
+function eth_get_bridged(except)
+       local devs = state:get("network", except, "device")
+       
+       local ifs = {}
+       local cnt = 0
+       for x in devs:gmatch("[^ ]+") do
+               cnt = cnt + 1
+               if x:find("eth") == 1 then
+                       ifs[#ifs+1] = x
+               end
+       end
+       return cnt > 1 and ifs or {}
+end
+
 function wifi_get_available(except)
        cursor:unload("wireless")
 
 function wifi_get_available(except)
        cursor:unload("wireless")
 
@@ -50,7 +66,7 @@ function wifi_get_available(except)
        for k in pairs(used) do
                local t = iwinfo.type(k)
                if t and iwinfo[t] then
        for k in pairs(used) do
                local t = iwinfo.type(k)
                if t and iwinfo[t] then
-                       used[k] = (iwinfo[t].mbssid_support() < 1)
+                       used[k] = (iwinfo[t].mbssid_support(k) < 1)
                end
        end
 
                end
        end