2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 require("luci.tools.webadmin")
15 m = Map("network", translate("a_n_routes"), translate("a_n_routes1"))
17 if not arg or not arg[1] then
18 local routes = luci.sys.net.routes()
20 v = m:section(TypedSection, "_virtual", translate("a_n_routes_kernel4"))
23 v.template = "cbi/tblsection"
25 function v.cfgsections(self)
28 table.insert(sections, i)
33 net = v:option(DummyValue, "iface", translate("network"))
34 function net.cfgvalue(self, section)
35 return luci.tools.webadmin.iface_get_network(routes[section].Iface)
36 or routes[section].Iface
39 target = v:option(DummyValue, "target", translate("target"))
40 function target.cfgvalue(self, section)
41 return luci.ip.Hex(routes[section].Destination, 32):string()
44 netmask = v:option(DummyValue, "netmask", translate("netmask"))
45 function netmask.cfgvalue(self, section)
46 return luci.ip.Hex(routes[section].Mask, 32):string()
49 gateway = v:option(DummyValue, "gateway", translate("gateway"))
50 function gateway.cfgvalue(self, section)
51 return luci.ip.Hex(routes[section].Gateway, 32):string()
54 metric = v:option(DummyValue, "metric", translate("metric"))
55 function metric.cfgvalue(self, section)
56 return routes[section].Metric
61 s = m:section(TypedSection, "route", translate("a_n_routes_static"))
64 s.template = "cbi/tblsection"
66 iface = s:option(ListValue, "interface", translate("interface"))
67 luci.tools.webadmin.cbi_add_networks(iface)
69 if not arg or not arg[1] then
70 net.titleref = iface.titleref
73 s:option(Value, "target", translate("target"), translate("a_n_r_target1"))
75 s:option(Value, "netmask", translate("netmask"), translate("a_n_r_netmask1")).rmemepty = true
77 s:option(Value, "gateway", translate("gateway"))