01580f1016ad607026155cf6753d1787637fbcb0
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / routes.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 require("luci.tools.webadmin")
5 m = Map("network",
6         translate("Routes"),
7         translate("Routes specify over which interface and gateway a certain host or network " ..
8                 "can be reached."))
9
10 local routes6 = luci.sys.net.routes6()
11
12 s = m:section(TypedSection, "route", translate("Static IPv4 Routes"))
13 s.addremove = true
14 s.anonymous = true
15
16 s.template  = "cbi/tblsection"
17
18 iface = s:option(ListValue, "interface", translate("Interface"))
19 luci.tools.webadmin.cbi_add_networks(iface)
20
21 t = s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network"))
22 t.datatype = "ip4addr"
23 t.rmempty = false
24
25 n = s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), translate("if target is a network"))
26 n.placeholder = "255.255.255.255"
27 n.datatype = "ip4addr"
28 n.rmempty = true
29
30 g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
31 g.datatype = "ip4addr"
32 g.rmempty = true
33
34 metric = s:option(Value, "metric", translate("Metric"))
35 metric.placeholder = 0
36 metric.datatype = "range(0,255)"
37 metric.rmempty = true
38
39 mtu = s:option(Value, "mtu", translate("MTU"))
40 mtu.placeholder = 1500
41 mtu.datatype = "range(64,9000)"
42 mtu.rmempty = true
43
44 if routes6 then
45         s = m:section(TypedSection, "route6", translate("Static IPv6 Routes"))
46         s.addremove = true
47         s.anonymous = true
48
49         s.template  = "cbi/tblsection"
50
51         iface = s:option(ListValue, "interface", translate("Interface"))
52         luci.tools.webadmin.cbi_add_networks(iface)
53
54         t = s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)"))
55         t.datatype = "ip6addr"
56         t.rmempty = false
57
58         g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
59         g.datatype = "ip6addr"
60         g.rmempty = true
61
62         metric = s:option(Value, "metric", translate("Metric"))
63         metric.placeholder = 0
64         metric.datatype = "range(0,65535)" -- XXX: not sure
65         metric.rmempty = true
66
67         mtu = s:option(Value, "mtu", translate("MTU"))
68         mtu.placeholder = 1500
69         mtu.datatype = "range(64,9000)"
70         mtu.rmempty = true
71 end
72
73
74 return m