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()
18 local bit = require "bit"
20 if not arg or not arg[1] then
21 local routes = luci.sys.net.routes()
23 v = m:section(Table, routes, translate("a_n_routes_kernel4"))
25 net = v:option(DummyValue, "iface", translate("network"))
26 function net.cfgvalue(self, section)
27 return luci.tools.webadmin.iface_get_network(routes[section].device)
28 or routes[section].device
31 target = v:option(DummyValue, "target", translate("target"))
32 function target.cfgvalue(self, section)
33 return routes[section].dest:network():string()
36 netmask = v:option(DummyValue, "netmask", translate("netmask"))
37 function netmask.cfgvalue(self, section)
38 return routes[section].dest:mask():string()
41 gateway = v:option(DummyValue, "gateway", translate("gateway"))
42 function gateway.cfgvalue(self, section)
43 return routes[section].gateway:string()
46 metric = v:option(DummyValue, "metric", translate("metric"))
47 function metric.cfgvalue(self, section)
48 return routes[section].metric
52 v = m:section(Table, routes6, translate("a_n_routes_kernel6"))
54 net = v:option(DummyValue, "iface", translate("network"))
55 function net.cfgvalue(self, section)
56 return luci.tools.webadmin.iface_get_network(routes6[section].device)
57 or routes6[section].device
60 target = v:option(DummyValue, "target", translate("target"))
61 function target.cfgvalue(self, section)
62 return routes6[section].dest:string()
65 gateway = v:option(DummyValue, "gateway", translate("gateway6"))
66 function gateway.cfgvalue(self, section)
67 return routes6[section].source:string()
70 metric = v:option(DummyValue, "metric", translate("metric"))
71 function metric.cfgvalue(self, section)
72 local metr = routes6[section].metric
73 local lower = bit.band(metr, 0xffff)
74 local higher = bit.rshift(bit.band(metr, 0xffff0000), 16)
75 return "%04X%04X" % {higher, lower}
81 s = m:section(TypedSection, "route", translate("a_n_routes_static4"))
85 s.template = "cbi/tblsection"
87 iface = s:option(ListValue, "interface", translate("interface"))
88 luci.tools.webadmin.cbi_add_networks(iface)
90 if not arg or not arg[1] then
91 net.titleref = iface.titleref
94 s:option(Value, "target", translate("target"), translate("a_n_r_target1"))
96 s:option(Value, "netmask", translate("netmask"), translate("a_n_r_netmask1")).rmemepty = true
98 s:option(Value, "gateway", translate("gateway"))
101 s = m:section(TypedSection, "route6", translate("a_n_routes_static6"))
105 s.template = "cbi/tblsection"
107 iface = s:option(ListValue, "interface", translate("interface"))
108 luci.tools.webadmin.cbi_add_networks(iface)
110 if not arg or not arg[1] then
111 net.titleref = iface.titleref
114 s:option(Value, "target", translate("target"), translate("a_n_r_target6"))
116 s:option(Value, "gateway", translate("gateway6")).rmempty = true