-local netstate = luci.model.uci.cursor_state():get_all("network")
-m = Map("network", translate("interfaces"))
-
-local created
-local netstat = luci.sys.net.deviceinfo()
-
-s = m:section(TypedSection, "interface", "")
-s.addremove = true
-s.extedit = luci.dispatcher.build_url("admin", "network", "network") .. "/%s"
-s.template = "cbi/tblsection"
-s.override_scheme = true
-
-function s.filter(self, section)
- return section ~= "loopback" and section
-end
-
-function s.create(self, section)
- if TypedSection.create(self, section) then
- created = section
- else
- self.invalid_cts = true
- end
-end
-
-function s.parse(self, ...)
- TypedSection.parse(self, ...)
- if created then
- m.uci:save("network")
- luci.http.redirect(luci.dispatcher.build_url("admin", "network", "network")
- .. "/" .. created)
- end
-end
-
-up = s:option(Flag, "up")
-function up.cfgvalue(self, section)
- return netstate[section] and netstate[section].up or "0"
-end
-
-function up.write(self, section, value)
- local call
- if value == "1" then
- call = "ifup"
- elseif value == "0" then
- call = "ifdown"
- end
- os.execute(call .. " " .. section .. " >/dev/null 2>&1")
-end
-
-ifname = s:option(DummyValue, "ifname", translate("device"))
-function ifname.cfgvalue(self, section)
- return netstate[section] and netstate[section].ifname
-end
-
-ifname.titleref = luci.dispatcher.build_url("admin", "network", "vlan")
-
-
-if luci.model.uci.cursor():load("firewall") then
- zone = s:option(DummyValue, "_zone", translate("zone"))
- zone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
-
- function zone.cfgvalue(self, section)
- local zones = luci.tools.webadmin.network_get_zones(section)
- return zones and table.concat(zones, ", ") or "-"
+local fs = require "nixio.fs"
+
+m = Map("network", translate("Interfaces"))
+m:section(SimpleSection).template = "admin_network/iface_overview"
+
+-- Show ATM bridge section if we have the capabilities
+if fs.access("/usr/sbin/br2684ctl") then
+ atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"),
+ translate("ATM bridges expose encapsulated ethernet in AAL5 " ..
+ "connections as virtual Linux network interfaces which can " ..
+ "be used in conjunction with DHCP or PPP to dial into the " ..
+ "provider network."))
+
+ atm.addremove = true
+ atm.anonymous = true
+
+ atm.create = function(self, section)
+ local sid = TypedSection.create(self, section)
+ local max_unit = -1
+
+ m.uci:foreach("network", "atm-bridge",
+ function(s)
+ local u = tonumber(s.unit)
+ if u ~= nil and u > max_unit then
+ max_unit = u
+ end
+ end)
+
+ m.uci:set("network", sid, "unit", max_unit + 1)
+ m.uci:set("network", sid, "atmdev", 0)
+ m.uci:set("network", sid, "encaps", "llc")
+ m.uci:set("network", sid, "payload", "bridged")
+ m.uci:set("network", sid, "vci", 35)
+ m.uci:set("network", sid, "vpi", 8)
+
+ return sid