Renamed package name from bmx6-qmp to bmx6 and bmx6-luci to luci-app-bmx6
[feed/routing.git] / packages / luci-app-bmx6 / files / usr / lib / lua / luci / model / cbi / bmx6 / tunnels.lua
1 --[[
2 Copyright (C) 2011 Pau Escrich <pau@dabax.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 The full GNU General Public License is included in this distribution in
19 the file called "COPYING".
20 --]]
21
22 local sys = require("luci.sys")
23 local bmx6json = require("luci.model.bmx6json")
24
25 m = Map("bmx6", "bmx6")
26
27 -- tunOut
28 local tunnelsOut = m:section(TypedSection,"tunOut",translate("Networks to fetch"),translate("Tunnel announcements to fetch if possible"))
29 tunnelsOut.addremove = true
30 tunnelsOut.anonymous = true
31 tunnelsOut:option(Value,"tunOut","Name")
32 tunnelsOut:option(Value,"network", translate("Network to fetch"))
33
34 local tunoptions = bmx6json.getOptions("tunOut")
35 local _,o
36 for _,o in ipairs(tunoptions) do
37 if o.name ~= nil and o.name ~= "network" then
38 help = bmx6json.getHtmlHelp(o)
39 value = tunnelsOut:option(Value,o.name,o.name,help)
40 value.optional = true
41 end
42 end
43
44
45 --tunIn
46 local tunnelsIn = m:section(TypedSection,"tunInNet",translate("Networks to offer"),translate("Tunnels to announce in the network"))
47 tunnelsIn.addremove = true
48 tunnelsIn.anonymous = true
49
50 local net = tunnelsIn:option(Value,"tunInNet", translate("Network to offer"))
51 net.default = "10.0.0.0/8"
52
53 local bwd = tunnelsIn:option(Value,"bandwidth",translate("Bandwidth (Bytes)"))
54 bwd.default = "1000000"
55
56 local tuninoptions = bmx6json.getOptions("tunInNet")
57 local _,o
58 for _,o in ipairs(tuninoptions) do
59 if o.name ~= nil and o.name ~= "tunInNet" and o.name ~= "bandwidth" then
60 help = bmx6json.getHtmlHelp(o)
61 value = tunnelsIn:option(Value,o.name,o.name,help)
62 value.optional = true
63 end
64 end
65
66 function m.on_commit(self,map)
67 --Not working. If test returns error the changes are still commited
68 local msg = bmx6json.testandreload()
69 if msg ~= nil then
70 m.message = msg
71 end
72 end
73
74 return m
75