* modules/admin-full: adept wifi model to cover new broadcom options
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / routes.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
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
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 require("luci.tools.webadmin")
15 m = Map("network", translate("a_n_routes"), translate("a_n_routes1"))
16
17 if not arg or not arg[1] then
18 local routes = luci.sys.net.routes()
19
20 v = m:section(Table, routes, translate("a_n_routes_kernel4"))
21
22 net = v:option(DummyValue, "iface", translate("network"))
23 function net.cfgvalue(self, section)
24 return luci.tools.webadmin.iface_get_network(routes[section].Iface)
25 or routes[section].Iface
26 end
27
28 target = v:option(DummyValue, "target", translate("target"))
29 function target.cfgvalue(self, section)
30 return luci.ip.Hex(routes[section].Destination, 32):string()
31 end
32
33 netmask = v:option(DummyValue, "netmask", translate("netmask"))
34 function netmask.cfgvalue(self, section)
35 return luci.ip.Hex(routes[section].Mask, 32):string()
36 end
37
38 gateway = v:option(DummyValue, "gateway", translate("gateway"))
39 function gateway.cfgvalue(self, section)
40 return luci.ip.Hex(routes[section].Gateway, 32):string()
41 end
42
43 metric = v:option(DummyValue, "Metric", translate("metric"))
44 end
45
46
47 s = m:section(TypedSection, "route", translate("a_n_routes_static"))
48 s.addremove = true
49 s.anonymous = true
50
51 s.template = "cbi/tblsection"
52
53 iface = s:option(ListValue, "interface", translate("interface"))
54 luci.tools.webadmin.cbi_add_networks(iface)
55
56 if not arg or not arg[1] then
57 net.titleref = iface.titleref
58 end
59
60 s:option(Value, "target", translate("target"), translate("a_n_r_target1"))
61
62 s:option(Value, "netmask", translate("netmask"), translate("a_n_r_netmask1")).rmemepty = true
63
64 s:option(Value, "gateway", translate("gateway"))
65
66 return m