Rework LuCI build system
[project/luci.git] / modules / luci-mod-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
15 require("luci.tools.webadmin")
16 m = Map("network",
17         translate("Routes"),
18         translate("Routes specify over which interface and gateway a certain host or network " ..
19                 "can be reached."))
20
21 local routes6 = luci.sys.net.routes6()
22 local bit = require "bit"
23
24 s = m:section(TypedSection, "route", translate("Static IPv4 Routes"))
25 s.addremove = true
26 s.anonymous = true
27
28 s.template  = "cbi/tblsection"
29
30 iface = s:option(ListValue, "interface", translate("Interface"))
31 luci.tools.webadmin.cbi_add_networks(iface)
32
33 t = s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network"))
34 t.datatype = "ip4addr"
35 t.rmempty = false
36
37 n = s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), translate("if target is a network"))
38 n.placeholder = "255.255.255.255"
39 n.datatype = "ip4addr"
40 n.rmempty = true
41
42 g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
43 g.datatype = "ip4addr"
44 g.rmempty = true
45
46 metric = s:option(Value, "metric", translate("Metric"))
47 metric.placeholder = 0
48 metric.datatype = "range(0,255)"
49 metric.rmempty = true
50
51 mtu = s:option(Value, "mtu", translate("MTU"))
52 mtu.placeholder = 1500
53 mtu.datatype = "range(64,9000)"
54 mtu.rmempty = true
55
56 if routes6 then
57         s = m:section(TypedSection, "route6", translate("Static IPv6 Routes"))
58         s.addremove = true
59         s.anonymous = true
60
61         s.template  = "cbi/tblsection"
62
63         iface = s:option(ListValue, "interface", translate("Interface"))
64         luci.tools.webadmin.cbi_add_networks(iface)
65
66         t = s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)"))
67         t.datatype = "ip6addr"
68         t.rmempty = false
69
70         g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
71         g.datatype = "ip6addr"
72         g.rmempty = true
73
74         metric = s:option(Value, "metric", translate("Metric"))
75         metric.placeholder = 0
76         metric.datatype = "range(0,65535)" -- XXX: not sure
77         metric.rmempty = true
78
79         mtu = s:option(Value, "mtu", translate("MTU"))
80         mtu.placeholder = 1500
81         mtu.datatype = "range(64,9000)"
82         mtu.rmempty = true
83 end
84
85
86 return m