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
15 require("luci.tools.webadmin")
16 m = Map("network", translate("a_n_routes"), translate("a_n_routes1"))
18 local routes = luci.sys.net.routes()
19 local routes6 = luci.sys.net.routes6()
20 local bit = require "bit"
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 local metr = routes6[section].metric
72 local lower = bit.band(metr, 0xffff)
73 local higher = bit.rshift(bit.band(metr, 0xffff0000), 16)
74 return "%04X%04X" % {higher, lower}