.dbtemplate = "niu/network"
entry({"niu", "network", "lan"},
- cbi("niu/network/lan", {on_success_to={"niu"}}), "Configure LAN")
+ cbi("niu/network/lan", {on_success_to={"niu"}}), "Configure LAN", 10)
entry({"niu", "network", "wan"},
- cbi("niu/network/wan", {on_success_to={"niu"}}), "Configure Internet")
+ cbi("niu/network/wan", {on_success_to={"niu"}}), "Configure Internet", 20)
+
+ entry({"niu", "network", "assign"}, cbi("niu/network/assign",
+ {on_success_to={"niu"}}), "Address Assignment", 30)
+
+ entry({"niu", "network", "routes"}, cbi("niu/network/routes",
+ {on_success_to={"niu"}}), "Custom Routing", 40)
end
--- /dev/null
+local cursor = require "luci.model.uci".cursor()
+local d = Delegator()
+d.allow_finish = true
+d.allow_back = true
+d.allow_cancel = true
+
+d:add("assign1", load("niu/network/assign1"))
+
+function d.on_cancel()
+ cursor:revert("dhcp")
+end
+
+function d.on_done()
+ cursor:commit("dhcp")
+end
+
+return d
\ No newline at end of file
--- /dev/null
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local uci = require "luci.model.uci".cursor()
+local sys = require "luci.sys"
+local wa = require "luci.tools.webadmin"
+local fs = require "nixio.fs"
+
+m2 = Map("dhcp", "Address Assignment")
+
+local leasefn, leasefp, leases
+uci:foreach("dhcp", "dnsmasq",
+ function(section)
+ leasefn = section.leasefile
+ end
+)
+local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
+if leasefp then
+ leases = {}
+ for lease in leasefp do
+ table.insert(leases, luci.util.split(lease, " "))
+ end
+end
+
+if leases then
+ v = m2:section(Table, leases, translate("dhcp_leases_active"))
+ ip = v:option(DummyValue, 3, translate("ipaddress"))
+
+ mac = v:option(DummyValue, 2, translate("macaddress"))
+
+ ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
+ function ltime.cfgvalue(self, ...)
+ local value = DummyValue.cfgvalue(self, ...)
+ return wa.date_format(os.difftime(tonumber(value), os.time()))
+ end
+end
+
+s = m2:section(TypedSection, "host")
+s.addremove = true
+s.anonymous = true
+s.template = "cbi/tblsection"
+
+hn = s:option(Value, "name", translate("hostnames_hostname"))
+mac = s:option(Value, "mac", translate("macaddress"))
+ip = s:option(Value, "ip", translate("ipaddress"))
+sys.net.arptable(function(entry)
+ ip:value(entry["IP address"])
+ mac:value(
+ entry["HW address"],
+ entry["HW address"] .. " (" .. entry["IP address"] .. ")"
+ )
+end)
+
+
+return m2
--- /dev/null
+local cursor = require "luci.model.uci".cursor()
+local d = Delegator()
+d.allow_finish = true
+d.allow_back = true
+d.allow_cancel = true
+
+d:add("routes1", load("niu/network/routes1"))
+
+function d.on_cancel()
+ cursor:revert("network")
+end
+
+function d.on_done()
+ cursor:commit("network")
+end
+
+return d
\ No newline at end of file
--- /dev/null
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+m = Map("network", translate("a_n_routes"), translate("a_n_routes1"))
+
+local routes6 = luci.sys.net.routes6()
+local bit = require "bit"
+
+s = m:section(TypedSection, "route", translate("a_n_routes_static4"))
+s.addremove = true
+s.anonymous = true
+
+s.template = "cbi/tblsection"
+
+iface1 = s:option(ListValue, "interface", translate("interface"))
+
+s:option(Value, "target", translate("target"), translate("a_n_r_target1"))
+s:option(Value, "netmask", translate("netmask"), translate("a_n_r_netmask1")).rmemepty = true
+s:option(Value, "gateway", translate("gateway"))
+
+if routes6 then
+ s = m:section(TypedSection, "route6", translate("a_n_routes_static6"))
+ s.addremove = true
+ s.anonymous = true
+
+ s.template = "cbi/tblsection"
+
+ iface2 = s:option(ListValue, "interface", translate("interface"))
+
+ s:option(Value, "target", translate("target"), translate("a_n_r_target6"))
+ s:option(Value, "gateway", translate("gateway6")).rmempty = true
+end
+
+m.uci:foreach("network", "interface", function(s)
+ if s[".name"] ~= "loopback" then
+ iface:value(s[".name"])
+ if iface2 then
+ iface2:value(s[".name"])
+ end
+ end
+end)
+
+
+return m
str.uci_state:foreach("network", "interface", function(s)
nws[#nws+1] = s
end)
-
-local function cmp(a, b)
- return (a.order or 100) < (b.order or 100)
-end
%>
<div>Status:</div>
<table>
<br />
<ul>
<%
-for k, v in utl.spairs(dsp.node("niu", "network").nodes, cmp) do
+local nodes = dsp.node("niu", "network").nodes
+local function cmp(a, b)
+ return (nodes[a].order or 100) < (nodes[b].order or 100)
+end
+for k, v in utl.spairs(nodes, cmp) do
%>
<li><a href="<%=dsp.build_url("niu", "network", k)%>"><%=v.title%></a></li>
<%