2 Copyright (C) 2011 Pau Escrich <pau@dabax.net>
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.
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.
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.
18 The full GNU General Public License is included in this distribution in
19 the file called "COPYING".
22 local sys = require("luci.sys")
23 local bmx6json = require("luci.model.bmx6json")
25 m = Map("bmx6", "bmx6")
27 -- Getting json and Checking if bmx6-json is avaiable
28 local options = bmx6json.get("options")
29 if options == nil or options.OPTIONS == nil then
30 m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
32 options = options.OPTIONS
35 -- Getting a list of interfaces
36 local eth_int = luci.sys.net.devices()
38 -- Getting the most important options from general
39 local general = m:section(NamedSection,"general","general","General")
40 general.addremove = false
41 general:option(Value,"globalPrefix","Global ip prefix","Specify global prefix for interfaces: NETADDR/LENGTH. If you are using IPv6 leave blank to let bmx6 autoassign an ULA IPv6 address.")
43 if m:get("ipVersion","ipVersion") == "6" then
44 general:option(Value,"tun4Address","IPv4 address or range","specify default IPv4 tunnel address and announced range")
48 -- ipVersion section is important, we are allways showing it
49 local ipV = m:section(NamedSection,"ipVersion","ipVersion","IP options")
51 local lipv = ipV:option(ListValue,"ipVersion","IP version")
56 -- rest of ip options are optional, getting them from json
58 for _,o in ipairs(options) do
59 if o.name == "ipVersion" and o.CHILD_OPTIONS ~= nil then
60 ipoptions = o.CHILD_OPTIONS
69 for _,o in ipairs(ipoptions) do
74 help = bmx6json.text2html(o.help)
77 if o.syntax ~= nil then
78 help = help .. "<br/><strong>Syntax: </strong>" .. bmx6json.text2html(o.syntax)
82 help = help .. "<br/><strong> Default: </strong>" .. bmx6json.text2html(o.def)
85 value = ipV:option(Value,name,name,help)
91 local interfaces = m:section(TypedSection,"dev","Devices","")
92 interfaces.addremove = true
93 interfaces.anonymous = true
94 local intlv = interfaces:option(ListValue,"dev","Device")
96 for _,i in ipairs(eth_int) do
100 function m.on_commit(self,map)
101 local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp')
103 m.message = sys.exec("cat /tmp/bmx6-luci.err.tmp")