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 local routes6 = luci.sys.net.routes6()
19 if not arg or not arg[1] then
20 local routes = luci.sys.net.routes()
22 v = m:section(Table, routes, translate("a_n_routes_kernel4"))
24 net = v:option(DummyValue, "iface", translate("network"))
25 function net.cfgvalue(self, section)
26 return luci.tools.webadmin.iface_get_network(routes[section].device)
27 or routes[section].device
30 target = v:option(DummyValue, "target", translate("target"))
31 function target.cfgvalue(self, section)
32 return routes[section].dest:network():string()
35 netmask = v:option(DummyValue, "netmask", translate("netmask"))
36 function netmask.cfgvalue(self, section)
37 return routes[section].dest:mask():string()
40 gateway = v:option(DummyValue, "gateway", translate("gateway"))
41 function gateway.cfgvalue(self, section)
42 return routes[section].gateway:string()
45 metric = v:option(DummyValue, "metric", translate("metric"))
46 function metric.cfgvalue(self, section)
47 return routes[section].metric
51 v = m:section(Table, routes6, translate("a_n_routes_kernel6"))
53 net = v:option(DummyValue, "iface", translate("network"))
54 function net.cfgvalue(self, section)
55 return luci.tools.webadmin.iface_get_network(routes6[section].device)
56 or routes6[section].device
59 target = v:option(DummyValue, "target", translate("target"))
60 function target.cfgvalue(self, section)
61 return routes6[section].dest:string()
64 gateway = v:option(DummyValue, "gateway", translate("gateway6"))
65 function gateway.cfgvalue(self, section)
66 return routes6[section].source:string()
69 metric = v:option(DummyValue, "metric", translate("metric"))
70 function metric.cfgvalue(self, section)
71 return string.format( "%08X", routes6[section].metric )
77 s = m:section(TypedSection, "route", translate("a_n_routes_static4"))
81 s.template = "cbi/tblsection"
83 iface = s:option(ListValue, "interface", translate("interface"))
84 luci.tools.webadmin.cbi_add_networks(iface)
86 if not arg or not arg[1] then
87 net.titleref = iface.titleref
90 s:option(Value, "target", translate("target"), translate("a_n_r_target1"))
92 s:option(Value, "netmask", translate("netmask"), translate("a_n_r_netmask1")).rmemepty = true
94 s:option(Value, "gateway", translate("gateway"))
97 s = m:section(TypedSection, "route6", translate("a_n_routes_static6"))
101 s.template = "cbi/tblsection"
103 iface = s:option(ListValue, "interface", translate("interface"))
104 luci.tools.webadmin.cbi_add_networks(iface)
106 if not arg or not arg[1] then
107 net.titleref = iface.titleref
110 s:option(Value, "target", translate("target"), translate("a_n_r_target6"))
112 s:option(Value, "gateway", translate("gateway6")).rmempty = true