094831e72f18e48ac11de34edaa83531905589c9
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / network / routes1.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
15 m = Map("network", translate("Display and Customize Routing"),
16 translate("With additional static routes you allow computers on your network to reach unannounced remote hosts or networks."))
17
18 local routes6 = luci.sys.net.routes6()
19 local bit = require "bit"
20
21 m:append(Template("niu/network/rtable"))
22
23 s = m:section(TypedSection, "route", "Static IPv4 Routes")
24 s.addremove = true
25 s.anonymous = true
26
27 s.template  = "cbi/tblsection"
28
29 iface1 = s:option(ListValue, "interface", translate("Interface"))
30
31 s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network"))
32 s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), translate("if target is a network")).rmemepty = true
33 s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
34
35 if routes6 then
36         s = m:section(TypedSection, "route6", "Static IPv6 Routes")
37         s.addremove = true
38         s.anonymous = true
39
40         s.template  = "cbi/tblsection"
41
42         iface2 = s:option(ListValue, "interface", translate("Interface"))
43
44         s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)"))
45         s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway")).rmempty = true
46 end
47
48 m.uci:foreach("network", "interface", function(s)
49         if s[".name"] ~= "loopback" then
50                 iface:value(s[".name"])
51                 if iface2 then
52                         iface2:value(s[".name"])
53                 end
54         end
55 end)
56
57 return m