diff options
Diffstat (limited to 'bird1-openwrt/bird1-ipv4-openwrt/src/model')
6 files changed, 0 insertions, 828 deletions
diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/model/bgp_proto.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/model/bgp_proto.lua deleted file mode 100644 index 4c2b951..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/model/bgp_proto.lua +++ /dev/null @@ -1,282 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. ---]] - -require("luci.sys") -local http = require "luci.http" -local uci = luci.model.uci.cursor() - --- Repeated Strings -local common_string = "Valid options are:<br />" .. "1. all (All the routes)<br />" .. "2. none (No routes)<br />" .. "3. filter <b>Your_Filter_Name</b> (Call a specific filter from any of the available in the filters files)" -local imp_string = "Set if the protocol must import routes.<br />" .. common_string -local exp_string = "Set if the protocol must export routes.<br />" .. common_string - -m=Map("bird4", "Bird4 BGP protocol's configuration") - -tab_templates = {} -uci:foreach('bird4', 'bgp_template', function (s) - local name = s[".name"] - if (name ~= nil) then - table.insert(tab_templates, name) - end -end) - --- --- BGP TEMPLATES --- -sect_templates = m:section(TypedSection, "bgp_template", "BGP Templates", "Configuration of the templates used in BGP instances.") -sect_templates.addremove = true -sect_templates.anonymous = false - -disabled = sect_templates:option(Flag, "disabled", "Disabled", "Enable/Disable BGP Protocol") -disabled.optional=true - -table = sect_templates:option(ListValue, "table", "Table", "Set the table used for BGP Routing") -table.optional=true -uci:foreach("bird4", "table", - function (s) - table:value(s.name) - end) -table:value("") -table.default = "" - -igp_table = sect_templates:option(ListValue, "igp_table", "IGP Table", "Select the IGP Routing Table to use. Hint: usually the same table as BGP.") -igp_table.optional = true -uci:foreach("bird4", "table", -function(s) - igp_table:value(s.name) -end) -igp_table:value("") -igp_table.default = "" - -import = sect_templates:option(Value, "import", "Import", imp_string) -import.optional=true - -export = sect_templates:option(Value, "export", "Export", exp_string) -export.optional=true - -source_addr = sect_templates:option(Value, "source_address", "Source Address", "Source address for BGP routing. By default uses Router ID") -source_addr.optional = true - -local_as = sect_templates:option(Value, "local_as", "Local AS", "") -local_as.optional = false - -next_hop_self = sect_templates:option(Flag, "next_hop_self", "Next hop self", "Avoid next hop calculation and advertise own source address as next hop") -next_hop_self.default = nil -next_hop_self.optional = true - -next_hop_keep = sect_templates:option(Flag, "next_hop_keep", "Next hop keep", "Forward the received Next Hop attribute event in situations where the local address should be used instead, like subneting") -next_hop_keep.default = nil -next_hop_keep.optional = true - -rr_client = sect_templates:option(Flag, "rr_client", "Route Reflector server", "This router serves as a Route Reflector server and treats neighbors as clients") -rr_client.default = nil -rr_client.optional = true - -rr_cluster_id = sect_templates:option(Value, "rr_cluster_id", "Route Reflector Cluster ID", "Identificator of the RR cluster. By default uses the Router ID") -rr_cluster_id.optional = true - -import_trigger = sect_templates:option(Flag, "import_trigger", "Import Limit", "Enable Routes Import limit settings") -import_trigger.default = 0 -import_trigger.rmempty = false -import_trigger.optional = false - -import_limit = sect_templates:option(Value, "import_limit", "Routes import limit", "Specify an import route limit.") -import_limit:depends({import_trigger = "1"}) -import_limit.rmempty = true - -import_limit_action = sect_templates:option(ListValue, "import_limit_action", "Routes import limit action", "Action to take when import routes limit ir reached") -import_limit_action:depends({import_trigger = "1"}) -import_limit_action:value("warn") -import_limit_action:value("block") -import_limit_action:value("disable") -import_limit_action:value("restart") -import_limit_action.default = "warn" -import_limit_action.rmempty = true - -export_trigger = sect_templates:option(Flag, "export_trigger", "Export Limit", "Enable Routes Export limit settings") -export_trigger.default = 0 -export_trigger.rmempty = false -export_trigger.optional = false - -export_limit = sect_templates:option(Value, "export_limit", "Routes export limit", "Specify an export route limit.") -export_limit:depends({export_trigger = "1"}) -export_limit.rmempty = true - -export_limit_action = sect_templates:option(ListValue, "export_limit_action", "Routes export limit action", "Action to take when export routes limit is reached") -export_limit_action:depends({export_trigger = "1"}) -export_limit_action.rmempty = true -export_limit_action:value("warn") -export_limit_action:value("block") -export_limit_action:value("disable") -export_limit_action:value("restart") -export_limit_action.default = "warn" - -receive_trigger = sect_templates:option(Flag, "receive_trigger", "Received Limit", "Enable Routes Received Limit settings") -receive_trigger.default = 0 -receive_trigger.rmempty = false -receive_trigger.optional = false - -receive_limit = sect_templates:option(Value, "receive_limit", "Routes received limit", "Specify a received route limit.") -receive_limit:depends({receive_trigger = "1"}) -receive_limit.rmempty = true - -receive_limit_action = sect_templates:option(ListValue, "receive_limit_action", "Routes received limit action", "Action to take when received routes limit is reached") -receive_limit_action:depends({receive_trigger = "1"}) -receive_limit_action:value("warn") -receive_limit_action:value("block") -receive_limit_action:value("disable") -receive_limit_action:value("restart") -receive_limit_action.default = "warn" -receive_limit_action.rmempty= true - --- --- BGP INSTANCES --- -sect_instances = m:section(TypedSection, "bgp", "BGP Instances", "Configuration of the BGP protocol instances") -sect_instances.addremove = true -sect_instances.anonymous = false - -disabled = sect_instances:option(Flag, "disabled", "Disabled", "Enable/Disable BGP Protocol") -disabled.optional = false -disabled.rmempty = false -disabled.default = nil - -templates = sect_instances:option(ListValue, "template", "Templates", "Available BGP templates") -uci:foreach("bird4", "bgp_template", - function(s) - templates:value(s[".name"]) - end) -templates:value("") - -description = sect_instances:option(TextValue, "description", "Description", "Description of the current BGP instance") -description.optional = true - -table = sect_instances:option(ListValue, "table", "Table", "Set the table used for BGP Routing") -table.optional=true -uci:foreach("bird4", "table", - function (s) - table:value(s.name) - end) -table:value("") -table.default = "" - -igp_table = sect_instances:option(ListValue, "igp_table", "IGP Table", "Select the IGP Routing Table to use. Hint: usually the same table as BGP.") -igp_table.optional = true -uci:foreach("bird4", "table", -function(s) - igp_table:value(s.name) -end) -igp_table:value("") -igp_table.default = "" - -passive = sect_instances:option(Flag, "passive", "Passive", "Disable automatic initialization of outgoing connections.") -passive.optional=true -passive.rmempty = false -passive.default = nil - -import = sect_instances:option(Value, "import", "Import", imp_string) -import.optional=true - -export = sect_instances:option(Value, "export", "Export", exp_string) -export.optional=true - -source_address = sect_instances:option(Value, "source_address", "Source Address", "Source address for BGP routing. By default uses Router ID") -source_address.optional = true - -local_as = sect_instances:option(Value, "local_as", "Local AS", "") -local_as.optional=true - -neighbor_address = sect_instances:option(Value, "neighbor_address", "Neighbor IP Address", "") -neighbor_address.optional = false - -neighbor_as = sect_instances:option(Value, "neighbor_as", "Neighbor AS", "") -neighbor_as.optional = false - -next_hop_self = sect_instances:option(Flag, "next_hop_self", "Next hop self", "Avoid next hop calculation and advertise own source address as next hop") -next_hop_self.default = nil -next_hop_self.optional = true - -next_hop_keep = sect_instances:option(Flag, "next_hop_keep", "Next hop keep", "Forward the received Next Hop attribute event in situations where the local address should be used instead, like subneting") -next_hop_keep.default = nil -next_hop_keep.optional = true - -rr_client = sect_instances:option(Flag, "rr_client", "Route Reflector server", "This router serves as a Route Reflector server and treats neighbors as clients") -rr_client.default = nil -rr_client.optional = true - -rr_cluster_id = sect_instances:option(Value, "rr_cluster_id", "Route Reflector Cluster ID", "Identificator of the RR cluster. By default uses the Router ID") -rr_cluster_id.optional = true - -import_trigger = sect_instances:option(Flag, "import_trigger", "Import Limit", "Enable Routes Import limit settings") -import_trigger.default = 0 -import_trigger.rmempty = false -import_trigger.optional = false - -import_limit = sect_instances:option(Value, "import_limit", "Routes import limit", "Specify an import route limit.") -import_limit:depends({import_trigger = "1"}) -import_limit.rmempty = true - -import_limit_action = sect_instances:option(ListValue, "import_limit_action", "Routes import limit action", "Action to take when import routes limit ir reached") -import_limit_action:depends({import_trigger = "1"}) -import_limit_action:value("warn") -import_limit_action:value("block") -import_limit_action:value("disable") -import_limit_action:value("restart") -import_limit_action.default = "warn" -import_limit_action.rmempty = true - -export_trigger = sect_instances:option(Flag, "export_trigger", "Export Limit", "Enable Routes Export limit settings") -export_trigger.default = 0 -export_trigger.rmempty = false -export_trigger.optional = false - -export_limit = sect_instances:option(Value, "export_limit", "Routes export limit", "Specify an export route limit.") -export_limit:depends({export_trigger = "1"}) -export_limit.rmempty = true - -export_limit_action = sect_instances:option(ListValue, "export_limit_action", "Routes export limit action", "Action to take when export routes limit is reached") -export_limit_action:depends({export_trigger = "1"}) -export_limit_action:value("warn") -export_limit_action:value("block") -export_limit_action:value("disable") -export_limit_action:value("restart") -export_limit_action.default = "warn" -export_limit_action.rmempty= true - -receive_trigger = sect_instances:option(Flag, "receive_trigger", "Received Limit", "Enable Routes Received Limit settings") -receive_trigger.default = 0 -receive_trigger.rmempty = false -receive_trigger.optional = false - -receive_limit = sect_instances:option(Value, "receive_limit", "Routes received limit", "Specify a received route limit.") -receive_limit:depends({receive_trigger = "1"}) -receive_limit.rmempty = true - -receive_limit_action = sect_instances:option(ListValue, "receive_limit_action", "Routes received limit action", "Action to take when received routes limit is reached") -receive_limit_action:depends({receive_trigger = "1"}) -receive_limit_action:value("warn") -receive_limit_action:value("block") -receive_limit_action:value("disable") -receive_limit_action:value("restart") -receive_limit_action.default = "warn" -receive_limit_action.rmempty= true - - -function m.on_commit(self,map) - luci.sys.exec('/etc/init.d/bird4 restart') -end -return m diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/model/filters.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/model/filters.lua deleted file mode 100644 index 6f352b2..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/model/filters.lua +++ /dev/null @@ -1,77 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -]]-- - -local fs = require "nixio.fs" -local filters_dir = "/etc/bird4/filters/" -local lock_file = "/etc/bird4/filter_lock" - -m = SimpleForm("bird4", "Bird4 Filters", "<b>INFO:</b> New files are created using Timestamps.<br />In order to make it easier to handle, use SSH to connect to your terminal and rename those files.<br />If your file is not correctly shown in the list, please, refresh your browser.") - -s = m:section(SimpleSection) -files = s:option(ListValue, "Files", "Filter Files:") -local new_filter = filters_dir .. os.date("filter-%Y%m%d-%H%M") - --- New File Entry -files:value(new_filter, "New File (".. new_filter .. ")") -files.default = new_filter - -local i, file_list = 0, { } -for filename in io.popen("find " .. filters_dir .. " -type f"):lines() do - i = i + 1 - files:value(filename, filename) -end - -ld = s:option(Button, "_load", "Load File") -ld.inputstyle = "reload" - -st_file = s:option(DummyValue, "_stfile", "Editing file:") -function st_file.cfgvalue(self, section) - if ld:formvalue(section) then - fs.writefile(lock_file, files:formvalue(section)) - return files:formvalue(section) - else - fs.writefile(lock_file, "") - return "" - end -end - -area = s:option(Value, "_filters") -area.template = "bird4/tvalue" -area.rows = 30 -function area.cfgvalue(self,section) - if ld:formvalue(section) then - local contents = fs.readfile(files:formvalue(section)) - if contents then - return contents - else - return "" - end - else - return "" - end -end - -function area.write(self, section) - local locked_file = fs.readfile(lock_file) - if locked_file and not ld:formvalue(section) then - local text = self:formvalue(section):gsub("\r\n?", "\n") - fs.writefile(locked_file, text) - fs.writefile(lock_file, "") - end -end - -return m diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/model/functions.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/model/functions.lua deleted file mode 100644 index 86d8e9b..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/model/functions.lua +++ /dev/null @@ -1,77 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -]]-- - -local fs = require "nixio.fs" -local functions_dir = "/etc/bird4/functions/" -local lock_file = "/etc/bird4/function_lock" - -m = SimpleForm("bird4", "Bird4 Functions", "<b>INFO:</b> New files are created using Timestamps.<br />In order to make it easier to handle, use SSH to connect to your terminal and rename those files.<br />If your file is not correctly shown in the list, please, refresh your browser.") - -s = m:section(SimpleSection) -files = s:option(ListValue, "Files", "Function Files:") -local new_function = functions_dir .. os.date("function-%Y%m%d-%H%M") - --- New File Entry -files:value(new_function, "New File (".. new_function .. ")") -files.default = new_function - -local i, file_list = 0, { } -for filename in io.popen("find " .. functions_dir .. " -type f"):lines() do - i = i + 1 - files:value(filename, filename) -end - -ld = s:option(Button, "_load", "Load File") -ld.inputstyle = "reload" - -st_file = s:option(DummyValue, "_stfile", "Editing file:") -function st_file.cfgvalue(self, section) - if ld:formvalue(section) then - fs.writefile(lock_file, files:formvalue(section)) - return files:formvalue(section) - else - fs.writefile(lock_file, "") - return "" - end -end - -area = s:option(Value, "_functions") -area.template = "bird4/tvalue" -area.rows = 30 -function area.cfgvalue(self,section) - if ld:formvalue(section) then - local contents = fs.readfile(files:formvalue(section)) - if contents then - return contents - else - return "" - end - else - return "" - end -end - -function area.write(self, section) - local locked_file = fs.readfile(lock_file) - if locked_file and not ld:formvalue(section) then - local text = self:formvalue(section):gsub("\r\n?", "\n") - fs.writefile(locked_file, text) - fs.writefile(lock_file, "") - end -end - -return m diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/model/gen_proto.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/model/gen_proto.lua deleted file mode 100644 index 1544d18..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/model/gen_proto.lua +++ /dev/null @@ -1,263 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. ---]] - -require("luci.sys") -local http = require "luci.http" -local uci = luci.model.uci.cursor() - --- Repeated Strings -local common_string = "Valid options are:<br />" .. "1. all (All the routes)<br />" .. "2. none (No routes)<br />" .. "3. filter <b>Your_Filter_Name</b> (Call a specific filter from any of the available in the filters files)" -local imp_string = "Set if the protocol must import routes.<br />" .. common_string -local exp_string = "Set if the protocol must export routes.<br />" .. common_string - -m=Map("bird4", "Bird4 general protocol's configuration.") - --- Optional parameters lists -local protoptions = { - {["name"]="table", ["help"]="Auxiliar table for routing", ["depends"]={"static","kernel"}}, - {["name"]="import", ["help"]=imp_string, ["depends"]={"kernel"}}, - {["name"]="export", ["help"]=exp_string, ["depends"]={"kernel"}}, - {["name"]="scan_time", ["help"]="Time between scans", ["depends"]={"kernel","device"}}, - {["name"]="kernel_table", ["help"]="Set which table must be used as auxiliar kernel table", ["depends"]={"kernel"}}, - {["name"]="learn", ["help"]="Learn routes", ["depends"]={"kernel"}}, - {["name"]="persist", ["help"]="Store routes. After a restart, routes willstill be configured", ["depends"]={"kernel"}} -} - -local routeroptions = { - {["name"]="prefix",["help"]="",["depends"]={"router","special","iface","multipath","recursive"}}, - {["name"]="via",["help"]="",["depends"]={"router","multipath"}}, - {["name"]="attribute",["help"]="",["depends"]={"special"}}, - {["name"]="iface",["help"]="",["depends"]={"iface"}}, - {["name"]="ip",["help"]="",["depends"]={"recursive"}} -} - - --- --- KERNEL PROTOCOL --- -sect_kernel_protos = m:section(TypedSection, "kernel", "Kernel options", "Configuration of the kernel protocols. First Instance MUST be Primary table (no table or kernel_table fields).") -sect_kernel_protos.addremove = true -sect_kernel_protos.anonymous = false - --- Default kernel parameters -disabled = sect_kernel_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.") -disabled.default=0 - --- Optional parameters -for _,o in ipairs(protoptions) do - if o.name ~= nil then - for _, d in ipairs(o.depends) do - if d == "kernel" then - if o.name == "learn" or o.name == "persist" then - value = sect_kernel_protos:option(Flag, o.name, translate(o.name), translate(o.help)) - elseif o.name == "table" then - value = sect_kernel_protos:option(ListValue, o.name, translate(o.name), translate(o.help)) - uci:foreach("bird4", "table", - function (s) - value:value(s.name) - end) - value:value("") - value.default = "" - else - value = sect_kernel_protos:option(Value, o.name, translate(o.name), translate(o.help)) - end - value.optional = true - value.rmempty = true - end - end - - end -end - - --- --- DEVICE PROTOCOL --- -sect_device_protos = m:section(TypedSection, "device", "Device options", "Configuration of the device protocols.") -sect_device_protos.addremove = true -sect_device_protos.anonymous = false - --- Default kernel parameters - -disabled = sect_device_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.") -disabled.default=0 - --- Optional parameters -for _,o in ipairs(protoptions) do - if o.name ~= nil then - for _, d in ipairs(o.depends) do - if d == "device" then - value = sect_device_protos:option(Value, o.name, translate(o.name), translate(o.help)) - value.optional = true - value.rmempty = true - end - end - end -end - - --- --- PIPE PROTOCOL --- -sect_pipe_protos = m:section(TypedSection, "pipe", "Pipe options", "Configuration of the Pipe protocols.") -sect_pipe_protos.addremove = true -sect_pipe_protos.anonymous = false - --- Default Pipe parameters -disabled = sect_pipe_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured. This protocol will connect the configured 'Table' to the 'Peer Table'.") -disabled.default=0 - -table = sect_pipe_protos:option(ListValue, "table", "Table", "Select the Primary Table to connect.") -table.optional = false -uci:foreach("bird4", "table", - function (s) - table:value(s.name) - end) -table:value("") -table.default = "" - -peer_table = sect_pipe_protos:option(ListValue, "peer_table", "Peer Table", "Select the Secondary Table to connect.") -table.optional = false -uci:foreach("bird4", "table", - function (s) - peer_table:value(s.name) - end) -peer_table:value("") -peer_table.default = "" - -mode = sect_pipe_protos:option(ListValue, "mode", "Mode", "Select <b>transparent</b> to retransmit all routes and their attributes<br />Select <b>opaque</b> to retransmit optimal routes (similar to what other protocols do)") -mode.optional = false -mode:value("transparent") -mode:value("opaque") -mode.default = "transparent" - -import = sect_pipe_protos:option(Value, "import", "Import",imp_string) -import.optional=true - -export = sect_pipe_protos:option(Value, "export", "Export", exp_string) -export.optional=true - - --- --- DIRECT PROTOCOL --- -sect_direct_protos = m:section(TypedSection, "direct", "Direct options", "Configuration of the Direct protocols.") -sect_direct_protos.addremove = true -sect_direct_protos.anonymous = false - --- Default Direct parameters -disabled = sect_direct_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured. This protocol will connect the configured 'Table' to the 'Peer Table'.") -disabled.optional = false -disabled.default = 0 - -interface = sect_direct_protos:option(Value, "interface", "Interfaces", "By default Direct will generate device routes for all the interfaces. To restrict this behaviour, select a number of patterns to match your desired interfaces:" .. "<br />" .. "1. All the strings <b>MUST</b> be quoted: \"pattern\"" .. "<br />" .. "2. Use * (star) to match patterns: \"eth*\" (<b>include</b> all eth... interfaces)" .. "<br />" .. "3. You can add \"-\" (minus) to exclude patterns: \"-em*\" (<b>exclude</b> all em... interfaces)." .. "<br />" .. "4. Separate several patterns using , (coma): \"-em*\", \"eth*\" (<b>exclude</b> em... and <b>include</b> all eth... interfaces).") -interface.optional = false -interface.default = "\"*\"" - - --- --- STATIC PROTOCOL --- -sect_static_protos = m:section(TypedSection, "static", "Static options", "Configuration of the static protocols.") -sect_static_protos.addremove = true -sect_static_protos.anonymous = false - --- Default kernel parameters -disabled = sect_static_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.") -disabled.default=0 - --- Optional parameters -for _,o in ipairs(protoptions) do - if o.name ~= nil then - for _, d in ipairs(o.depends) do - if d == "static" then - if o.name == "table" then - value = sect_static_protos:option(ListValue, o.name, translate(o.name), translate(o.help)) - uci:foreach("bird4", "table", - function (s) - value:value(s.name) - end) - value:value("") - value.default = "" - else - value = sect_static_protos:option(Value, o.name, translate(o.name), translate(o.help)) - end - value.optional = true - value.rmempty = true - end - end - end -end - - --- --- ROUTES FOR STATIC PROTOCOL --- -sect_routes = m:section(TypedSection, "route", "Routes configuration", "Configuration of the routes used in static protocols.") -sect_routes.addremove = true -sect_routes.anonymous = true - -instance = sect_routes:option(ListValue, "instance", "Route instance", "") -i = 0 -uci:foreach("bird4", "static", - function (s) - instance:value(s[".name"]) - end) - -prefix = sect_routes:option(Value, "prefix", "Route prefix", "") - -type = sect_routes:option(ListValue, "type", "Type of route", "") -type:value("router") -type:value("special") -type:value("iface") -type:value("recursive") -type:value("multipath") - -valueVia = sect_routes:option(Value, "via", "Via", "") -valueVia.optional = false -valueVia:depends("type", "router") -valueVia.datatype = "ip4addr" - -listVia = sect_routes:option(DynamicList, "l_via", "Via", "") -listVia:depends("type", "multipath") -listVia.optional=false -listVia.datatype = "ip4addr" - -attribute = sect_routes:option(ListValue, "attribute", "Attribute", "") -attribute:depends("type", "special") -attribute:value("unreachable") -attribute:value("prohibit") -attribute:value("blackhole") - -iface = sect_routes:option(ListValue, "iface", "Interface", "") -iface:depends("type", "iface") -uci:foreach("network", "interface", - function(section) - if section[".name"] ~= "loopback" then - iface:value(section[".name"]) - end - end) - -ip = sect_routes:option(Value, "ip", "IP address", "") -ip:depends("type", "ip") -ip.datatype = [[ or"ip4addr", "ip6addr" ]] - -function m.on_commit(self,map) - luci.sys.exec('/etc/init.d/bird4 restart') -end - -return m diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/model/overview.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/model/overview.lua deleted file mode 100644 index 7ebfb55..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/model/overview.lua +++ /dev/null @@ -1,76 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -]]-- - -require("luci.sys") -local http = require "luci.http" -local uci = require "luci.model.uci" -local uciout = uci.cursor() - -m=Map("bird4", "Bird4 UCI configuration helper", "") - --- Named section: "bird" - -s_bird_uci = m:section(NamedSection, "bird", "bird", "Bird4 file settings", "") -s_bird_uci.addremove = False - -uuc = s_bird_uci:option(Flag, "use_UCI_config", "Use UCI configuration", "Use UCI configuration instead of the /etc/bird4.conf file") - -ucf = s_bird_uci:option(Value, "UCI_config_file", "UCI File", "Specify the file to place the UCI-translated configuration") -ucf.default = "/tmp/bird4.conf" - --- Named Section: "table" - -s_bird_table = m:section(TypedSection, "table", "Tables configuration", "Configuration of the tables used in the protocols") -s_bird_table.addremove = true -s_bird_table.anonymous = true - -name = s_bird_table:option(Value, "name", "Table name", "Descriptor ID of the table") - --- Named section: "global" - -s_bird_global = m:section(NamedSection, "global", "global", "Global options", "Basic Bird4 settings") -s_bird_global.addremove = False - -id = s_bird_global:option(Value, "router_id", "Router ID", "Identification number of the router. By default, is the router's IP.") - -lf = s_bird_global:option(Value, "log_file", "Log File", "File used to store log related data.") - -l = s_bird_global:option(MultiValue, "log", "Log", "Set which elements do you want to log.") -l:value("all", "All") -l:value("info", "Info") -l:value("warning","Warning") -l:value("error","Error") -l:value("fatal","Fatal") -l:value("debug","Debug") -l:value("trace","Trace") -l:value("remote","Remote") -l:value("auth","Auth") - -d = s_bird_global:option(MultiValue, "debug", "Debug", "Set which elements do you want to debug.") -d:value("all", "All") -d:value("states","States") -d:value("routes","Routes") -d:value("filters","Filters") -d:value("interfaces","Interfaces") -d:value("events","Events") -d:value("packets","Packets") - -function m.on_commit(self,map) - luci.sys.exec('/etc/init.d/bird4 restart') -end - -return m diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/model/status.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/model/status.lua deleted file mode 100644 index 187bba3..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/model/status.lua +++ /dev/null @@ -1,53 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -]]-- - -local sys = require "luci.sys" - -m = SimpleForm("bird4", "Bird4 Daemon Status Page", "This page let you Start, Stop, Restart and check Bird4 Service Status.") -m.reset = false -m.submit = false - -s = m:section(SimpleSection) - -start = s:option(Button, "_start", "Start Bird4 Daemon:") -start.inputtitle = " Start " -start.inputstyle = "apply" - -stop = s:option(Button, "_stop", "Stop Bird4 Daemon:") -stop.inputtitle = " Stop " -stop.inputstyle = "remove" - -restart = s:option(Button, "_restart", "Restart Bird4 Daemon:") -restart.inputtitle = "Restart" -restart.inputstyle = "reload" - -output = s:option(DummyValue, "_value", "Service Status") -function output.cfgvalue(self, section) - local ret = "" - if start:formvalue(section) then - ret = sys.exec("/etc/init.d/bird4 start_quiet") - elseif stop:formvalue(section) then - ret = sys.exec("/etc/init.d/bird4 stop_quiet") - elseif restart:formvalue(section) then - ret = sys.exec("/etc/init.d/bird4 restart_quiet") - else - ret = sys.exec("/etc/init.d/bird4 status_quiet") - end - return ret -end - -return m |
