diff options
Diffstat (limited to 'bird1-openwrt/bird1-ipv4-openwrt/src')
14 files changed, 0 insertions, 1828 deletions
diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/config/bird4 b/bird1-openwrt/bird1-ipv4-openwrt/src/config/bird4 deleted file mode 100644 index f822f99..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/config/bird4 +++ /dev/null @@ -1,33 +0,0 @@ -config bird 'bird' - option use_UCI_config '1' - #Caution! Enabling this option, Bird will translate this - #UCI file and use it instead of /etc/bird4.conf - option UCI_config_file '/tmp/bird4.conf' - #If you enable useUCIconfig, UCIconfigFile will be Bird's - #configuration file location. - -config global 'global' - option log_file '/tmp/bird4.log' - option log 'all' - option debug 'off' - -config table - option name 'aux' - -config kernel kernel1 - option table 'aux' - option import 'all' - option export 'all' - option kernel_table '100' - option scan_time '10' - option learn '1' - option persist '0' - option disabled '0' - -config device device1 - option scan_time '10' - option disabled '0' - -config static static1 - option table 'aux' - option disabled '0' diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/controller/bird4.lua b/bird1-openwrt/bird1-ipv4-openwrt/src/controller/bird4.lua deleted file mode 100644 index 07d0dd2..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/controller/bird4.lua +++ /dev/null @@ -1,52 +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/>. ---]] - -module("luci.controller.bird4", package.seeall) - -function index() - entry({"admin", "network", "bird4",}, - alias("admin", "network", "bird4", "status"), - _("Bird4"), 0) - - entry({"admin", "network", "bird4", "status"}, - form("bird4/status"), - _("Status"), 0).leaf = true - - entry({"admin","network","bird4","log"}, - template("bird4/log"), - _("Log"), 1).leaf = true - - entry({"admin", "network", "bird4", "overview"}, - cbi("bird4/overview"), - _("Overview"), 2).leaf = true - - entry({"admin","network","bird4","proto_general"}, - cbi("bird4/gen_proto"), - _("General protocols"), 3).leaf = true - - entry({"admin","network","bird4","proto_bgp"}, - cbi("bird4/bgp_proto"), - _("BGP Protocol"), 4).leaf = true - - entry({"admin","network","bird4","filters"}, - form("bird4/filters"), - _("Filters"), 5).leaf = true - - entry({"admin","network","bird4","functions"}, - form("bird4/functions"), - _("Functions"), 6).leaf = true -end diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/init.d/bird4 b/bird1-openwrt/bird1-ipv4-openwrt/src/init.d/bird4 deleted file mode 100755 index e5fe473..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/init.d/bird4 +++ /dev/null @@ -1,233 +0,0 @@ -#!/bin/sh /etc/rc.common - -# 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/>. -# - -# Extra Service Function to get the Status of the Service -# This complements /etc/rc.common functions -# Commands ending with *_quiet are meant to be ran in Luci. These -# scripts' return minimal output. -EXTRA_COMMANDS="status start_quiet stop_quiet restart_quiet status_quiet" -EXTRA_HELP=" status Returns service status" - -BIRD="bird4" -BIRD_CONFIG="/etc/${BIRD}.conf" -BIRD_LOG="/var/log/${BIRD}.log" -BIRD_ERR="/tmp/${BIRD}.err" - -START=99 -STOP=10 - -SERVICE_DAEMONIZE=1 -SERVICE_USE_PID=1 -SERVICE_PID_FILE="/var/run/${BIRD}.pid" - -BIRD_BIN="/usr/sbin/${BIRD}" -# Special non-terminal-rich output for Luci calls -LUCI="false" - -. /etc/${BIRD}/init.d/${BIRD}-lib.sh - -start() { - config_load ${BIRD} - local use_UCI_config - get use_UCI_config 'bird' - - #Start the service - if [ "${LUCI}" == "false" ]; then - echo "Starting ${BIRD} Service [ ... ]" - fi - if [ -f ${BIRD_ERR} ]; then - echo -n "" > ${BIRD_ERR} - else - touch ${BIRD_ERR} - fi - - if [ -z "${use_UCI_config}" -o "${use_UCI_config}" = "0" ]; then - # Disable Custom bird-openwrt settings. - # Use default behaviour and files - ${BIRD_BIN} -d -c ${BIRD_CONFIG} -P ${SERVICE_PID_FILE} -D ${BIRD_LOG} &> ${BIRD_ERR} & - else - #Set Bird4 configuration location: - local UCI_config_file - local log_file - get UCI_config_file 'bird' - get log_file 'global' - BIRD_CONFIG="${UCI_config_file:-$BIRD_CONFIG}" - BIRD_LOG="${log_file:-$BIRD_LOG}" - #Backup previous configuration - [ -f ${BIRD_CONFIG} ] && cp ${BIRD_CONFIG} ${BIRD_CONFIG}.bak - #Setup the basic configuration - prepare_global 'global' - - # Gather and set all Functions - gather_functions - # Gather and set all Filters - gather_filters - - # Setup Main Protocols - config_foreach prepare_kernel 'kernel' - config_foreach prepare_static 'static' - config_foreach prepare_device 'device' - config_foreach prepare_direct 'direct' - config_foreach prepare_pipe 'pipe' - - #Setup protocol's configuration: BGP - config_foreach prepare_bgp_template 'bgp_template' - config_foreach prepare_bgp 'bgp' - - #Setup protocol's configuration: OSPF - config_foreach prepare_ospf_instance 'ospf' - - #Start the service - ${BIRD_BIN} -d -c ${BIRD_CONFIG} -P ${SERVICE_PID_FILE} -D ${BIRD_LOG} &>${BIRD_ERR} & - fi - while [ ! -s ${SERVICE_PID_FILE} ]; do - sleep 1 - if [ -s ${BIRD_ERR} ]; then - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} Daemon Start Status: \033[0;31m[ FAILED ]\e[m" - cat ${BIRD_ERR} - cat ${BIRD_ERR} >> ${BIRD_LOG} - else - echo "${BIRD} - Failed: $(cat ${BIRD_ERR})" - cat ${BIRD_ERR} >> ${BIRD_LOG} - fi - break - fi - done - - # PID & ERROR contents are read from their files to avoid an issue - # where if [ -s ${SERVICE_PID_FILE} ] and if [ -s ${BIRD_ERR} ] - # fails unless a previous command reads its contents making its - # behaviour unreliable. - SVC_PID="$(cat ${SERVICE_PID_FILE})" - BRDERR_TXT="$(cat ${BIRD_ERR})" - if [ -n "${SVC_PID}" ]; then - if [ -n "${BRDERR_TXT}" ]; then - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} Daemon already started. Status \033[0;32m[ RUNNING ]\e[m" - else - echo "${BIRD} already started" - fi - else - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} Daemon Start Status: \033[0;32m[ STARTED ]\e[m" - else - echo "${BIRD} - Started" - fi - fi - # PID File found (service started correctly) - return 0 - fi - - # PID File not found (error while starting service) - return 1 -} - -stop() { - if [ -s ${SERVICE_PID_FILE} ]; then - config_load ${BIRD} - local log_file - get log_file 'global' - BIRD_LOG="${log_file:-$BIRD_LOG}" - start-stop-daemon -p ${SERVICE_PID_FILE} -K 2>&1 >> ${BIRD_LOG} - if [ $? -eq 0 ]; then - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} Daemon Stop Status: \033[0;32m[ OK ]\e[m" - else - echo "${BIRD} - Stopped" - fi - echo -n "" > ${BIRD_ERR} - else - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} Daemon Stop Status: \033[0;31m[ FAILED ]\e[m" - echo "Check ${BIRD_LOG} file for more information." - else - echo "${BIRD} Failed to Stop. See Log file: ${BIRD_LOG}" - fi - fi - else - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} Daemon Service already stopped. \033[0;31m[ FAILED ]\e[m" - else - echo "${BIRD} already stopped" - fi - fi - return 0 -} - -restart() { - stop - sleep 1 - if [ "${LUCI}" == "true" ]; then - echo " ... " - fi - start -} - -reload() { - service_reload ${BIRD_BIN} -} - -status() { - if [ -s ${SERVICE_PID_FILE} ]; then - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} start status: \033[0;32m[ RUNNING ]\e[m" - else - echo "${BIRD}: Running" - fi - return 0 - else - if [ -s ${BIRD_ERR} ]; then - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} service status: \033[0;31m[ STOPPED ]\e[m" - cat ${BIRD_ERR} - else - echo "${BIRD}: Failed - $(cat ${BIRD_ERR})" - fi - return 2 - else - if [ "${LUCI}" == "false" ]; then - echo -e "${BIRD} service status: \033[0;31m[ STOPPED ]\e[m" - else - echo "${BIRD}: Stopped" - fi - return 1 - fi - fi -} - - -# Luci-specific calls (stripped output). -# The following scripts are not meant to be ran using Ash Terminal -# Used in: LUCI/model/cbi/bird4/status.lua -start_quiet() { - LUCI="true" - start -} -stop_quiet() { - LUCI="true" - stop -} -restart_quiet() { - LUCI="true" - restart -} -status_quiet() { - LUCI="true" - status -} diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/init.d/bird4-lib.sh b/bird1-openwrt/bird1-ipv4-openwrt/src/init.d/bird4-lib.sh deleted file mode 100644 index f2a5719..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/init.d/bird4-lib.sh +++ /dev/null @@ -1,590 +0,0 @@ -# Bird4-OpenWRT Library - Functions used in /etc/init.d/bird4 script. -# -# -# 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/>. -# - - -# Function: writeToConfig $1 -# $1 string. -# Allows to write in the $BIRD_CONFIG file, the string $1. This function does not check the $1 string. -# Example: writeToConfig "value: $N" -writeToConfig() { - echo "$1" >> ${BIRD_CONFIG} -} - - -# Function: write $1 $2 -# $1 string. $2 string. -# This function checks if $2 is empty. If not, it writes the string $1 in the $BIRD_CONFIG file. -# Use write function to check if $1, value found inside $2, is not empty and can be written in the configuration file. -# Example: N=""; write "value: $N" $N; -write() { - [ -n "$2" ] && writeToConfig "$1" -} - - -#Function: write_bool $1 $2 -# $1 string; $2 boolean -# This function checks if $2 is true and write the $1 string into $BIRD_CONFIG file. -# Example: local N=0; write_bool $N -write_bool() { - [ "$2" == 1 ] && writeToConfig " $1;" -} - - -# Function: get $1 $2 -# $1 string. $2 string -# This function uses the external UCI function "config_get $result $section $option" to obtain a string value from UCI config file. -# To use this function, use the same name of the UCI option for the variable. -# Example: UCI (option id 'abcd'); local id; get id $section -get() { - config_get $1 $2 $1 -} - - -# Function: get_a_bool $1 $2 -# $1 boolean. $2 string -# This function uses the external UCI function "config_get_bool $result $section $option" to obtain a boolean value from UCI config file. -# To use this function, use the same name of the UCI option for the variable $1. -# Example: UCI (option use_ipv6 '1'); local use_ipv6; get use_ipv6 $section -# Note: this function was originally called get_bool(), but it collided with -# the get_bool() function provided by /lib/functions.sh. Read more at -# https://github.com/openwrt/routing/issues/920. -get_a_bool() { - config_get_bool $1 $2 $1 -} - - -# Function: multipath_list $1 -# $1 string -# This function writes the $1 string in the multipath routes. -multipath_list() { - write " via $1" $1 -} - - -# Function: range_list $1 -# $1 string -# This function writes the $1 string in the OSPF networks. -range_list(){ - write " $1;" $1 -} - - -# Function: hidden_range_list $1 -# $1 string -# This function writes the $1 string in the OSPF networks as hidden. -hidden_range_list(){ - write " $1 hidden;" $1 -} - - -# Function: prepare_tables $1 -# $1 string -# This function gets each "table" section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI table section -prepare_tables() { - local section="$1"; local name - - get name ${section} - - write "table ${name};" ${name} -} - - -# Function: prepare_global $1 -# $1 string -# This function gets each "global" section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI global section. prepare_global is the first configuration set in the bird4.conf and removes the old file. -prepare_global () { - local section="$1" - local log_file; local log; local debug; local router_id; local table - - # Remove old configuration file - rm -f "${BIRD_CONFIG}" - - get log_file ${section} - get log ${section} - get debug ${section} - get router_id ${section} - get table ${section} - - # First line of the NEW configuration file - echo "#Bird4 configuration using UCI:" > ${BIRD_CONFIG} - writeToConfig " " - #TODO: Set Syslog as receiver if empty - # LOGF="${log_file:-syslog]}" - #TODO: If $log/$debug are empty, set to off - if [ -n "${log_file}" -a -n "${log}" ]; then - firstEntry="${log:0:3}" - if [ "${firstEntry}" = "all" -o "${firstEntry}" = "off" ]; then - writeToConfig 'log "'${log_file}'" '${firstEntry}';' - else - logEntries=$(echo ${log} | tr " " ",") - writeToConfig "log \"${log_file}\" { ${logEntries} };" - fi - fi - - if [ -n "${debug}" ]; then - firstEntry="${debug:0:3}" - if [ "${firstEntry}" = "all" -o "${firstEntry}" = "off" ]; then - writeToConfig "debug protocols ${firstEntry};" - else - debugEntries=$(echo ${debug} | tr " " ",") - writeToConfig "debug protocols { ${debugEntries} };" - fi - fi - writeToConfig " " - writeToConfig "#Router ID" - write "router id ${router_id};" ${router_id} - writeToConfig " " - writeToConfig "#Secondary tables" - config_foreach prepare_tables 'table' - writeToConfig " " -} - - -# Function: prepare_routes $1 -# $1 string -# This function gets each "route" section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI route section. Each type of route has its own treatment. -prepare_routes() { - local instance; local prefix; local via; local type; local attribute; local iface - local section="$1" - local protoInstance="$2" - - get instance ${section} - get type ${section} - get prefix ${section} - - if [ "${instance}" = "${protoInstance}" ]; then - case "${type}" in - "router") - get via ${section} - [ -n "${prefix}" -a -n "${via}" ] && writeToConfig " route ${prefix} via ${via};" - ;; - "special") - get attribute ${section} - [ -n "${prefix}" -a -n "${attribute}" ] && writeToConfig " route ${prefix} ${attribute};" - ;; - "iface") - get iface ${section} - [ -n "${prefix}" -a -n "${iface}" ] && writeToConfig ' route '${prefix}' via "'${iface}'";' - ;; - "multipath") - write " route ${prefix} multipath" ${prefix} - config_list_foreach ${section} l_via multipath_list - writeToConfig " ;" - ;; - esac - fi -} - - -# Function: prepare_kernel $1 -# $1 string -# This function gets each "kernel" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI kernel section. -prepare_kernel() { - local section="$1" - local disabled; local table; local kernel_table; local import; local export - local scan_time; local persist; local learn - - get_a_bool disabled ${section} - get table ${section} - get import ${section} - get export ${section} - get scan_time ${section} - get kernel_table ${section} - get learn ${section} - get persist ${section} - - write "#${section} configuration:" ${section} - writeToConfig "protocol kernel ${section} {" ${section} - write_bool disabled ${disabled} - write " table ${table};" ${table} - write " kernel table ${kernel_table};" ${kernel_table} - write_bool learn ${learn} - write_bool persist ${persist} - write " scan time ${scan_time};" ${scan_time} - write " import ${import};" ${import} - write " export ${export};" ${export} - writeToConfig "}" - writeToConfig " " -} - - -# Function: prepare_static $1 -# $1 string -# This function gets each "static" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI static section. -prepare_static() { - local section="$1" - local disabled; local table - - get disabled ${section} - get table ${section} - - if [ "${disabled}" -eq 0 ]; then - writeToConfig "#${section} configration:" ${section} - writeToConfig "protocol static {" - write " table ${table};" ${table} - config_foreach prepare_routes 'route' ${section} - writeToConfig "}" - writeToConfig " " - fi -} - - -# Function: prepare_direct $1 -# $1 string -# This function gets each "direct" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI direct section. -prepare_direct() { - local section="$1" - local disabled; local interface - - get disabled ${section} - get interface ${section} - - write "#${section} configuration:" ${section} - writeToConfig "protocol direct {" - write_bool disabled ${disabled} - write " interface ${interface};" ${interface} - writeToConfig "}" - writeToConfig " " -} - - -# Function: prepare_pipe $1 -# $1 string -# This function gets each "pipe" protocol section in the UCI configuration an -# $1 is set as the ID of the current UCI direct section. -prepare_pipe() { - local section="$1" - local disabled; local table; local peer_table; local mode; local import; local export - - get disabled $section - get peer_table $section - get mode $section - get table $section - get import $section - get export $section - - write "#$section configuration:" $section - writeToConfig "protocol pipe $section {" $section - write_bool disabled $disabled - write " table $table;" $table - write " peer table $peer_table;" $peer_table - write " mode $mode;" $mode - write " import $import;" $import - write " export $export;" $export - writeToConfig "}" - writeToConfig " " -} - - -# Function: prepare_device $1 -# $1 string -# This function gets each "device" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI device section. -prepare_device() { - local section="$1" - local disabled; local scan_time - - get disabled ${section} - get scan_time ${section} - - write "#${section} configuration:" ${section} - writeToConfig "protocol device {" - write_bool disabled ${disabled} - write " scan time ${scan_time};" ${scan_time} - writeToConfig "}" - writeToConfig " " -} - - -# Function: prepare_bgp_template $1 -# $1 string -# This function gets each "bgp_template" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI bgp_template section. -# Careful! Template options will be replaced by "instance" options if there is any match. -prepare_bgp_template() { - local section="$1" - local disabled; local table; local import; local export - local local_as; local neighbor_address; local neighbor_as; local source_address - local next_hop_self; local next_hop_keep; local rr_client; local rr_cluster_id - local import_limit; local import_limit_action; local export_limit; local export_limit_action - local receive_limit; local receive_limit_action; local igp_table - - get_a_bool disabled ${section} - get table ${section} - get import ${section} - get export ${section} - get source_address ${section} - - get local_as ${section} - get neighbor_address ${section} - get neighbor_as ${section} - - get_a_bool next_hop_self ${section} - get_a_bool next_hop_keep ${section} - get rr_client ${section} - get rr_cluster_id ${section} - - get import_limit ${section} - get import_limit_action ${section} - get export_limit ${section} - get export_limit_action ${section} - - get receive_limit ${section} - get receive_limit_action ${section} - get igp_table ${section} - - writeToConfig "#${section} template:" - writeToConfig "template bgp ${section} {" - [ -n "${disabled}" ] && write_bool disabled ${disabled} - [ -n "${table}" ] && writeToConfig " table ${table};" - [ -n "${igp_table}" ] && writeToConfig " igp table ${igp_table};" - [ -n "${local_as}" ] && writeToConfig " local as ${local_as};" - [ -n "${source_address}" ] && writeToConfig " source address ${source_address};" - [ -n "${import}" ] && writeToConfig " import ${import};" - [ -n "${export}" ] && writeToConfig " export ${export};" - [ -n "${neighbor_address}" -a -n "${neighbor_as}" ] && writeToConfig " neighbor ${neighbor_address} as ${neighbor_as};" - if [ -n "${import_limit}" -a "${import_limit}" > "0" ]; then - [ -z "${import_limit_action}" ] && ${import_limit_action} = "warn" - writeToConfig " import limit ${import_limit} action ${import_limit_action};" - fi - if [ -n "${export_limit}" -a "${export_limit}" > "0" ]; then - [ -z "${export_limit_action}" ] && ${export_limit_action} = "warn" - writeToConfig " export limit ${export_limit} action ${export_limit_action};" - fi - if [ -n "${receive_limit}" -a "${receive_limit}" > "0" ]; then - [ -z "${receive_limit_action}" ] && ${receive_limit_action} = "warn" - writeToConfig " receive limit ${receive_limit} action ${receive_limit_action};" - fi - [ -n "${next_hop_self}" ] && write_bool " next hop self;" ${next_hop_self} - [ -n "${next_hop_keep}" ] && write_bool " next hop keep;" ${next_hop_keep} - [ -n "${rr_client}" ] && write_bool " rr client;" ${rr_client} - [ -n "${rr_cluster_id}" ] && writeToConfig " rr cluster id ${rr_cluster_id};" - writeToConfig "}" - writeToConfig " " -} - - -# Function: prepare_bgp $1 -# $1 string -# This function gets each "bgp" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI bgp section. -# Careful! The options set in bgp instances overlap bgp_template ones. -prepare_bgp() { - local section="$1" - local disabled; local table; local template; local description; local igp_table; local passive - local import; local export; local source_address; local local_as; local neighbor_address - local neighbor_as; local rr_client; local rr_cluster_id; local import_limit - local import_limit_action; local export_limit; local export_limit_action - local receive_limit; local receive_limit_action; local igp_table - - get disabled ${section} - get table ${section} - get igp_table ${section} - get template ${section} - get description ${section} - get passive ${section} - - get import ${section} - get export ${section} - get source_address ${section} - get local_as ${section} - get neighbor_address ${section} - - get neighbor_as ${section} - get import_limit ${section} - get import_limit_action ${section} - get export_limit ${section} - get export_limit_action ${section} - - get receive_limit ${section} - get receive_limit_action ${section} - get_a_bool next_hop_self ${section} - get_a_bool next_hop_keep ${section} - get rr_client ${section} - get rr_cluster_id ${section} - - writeToConfig "#${section} configuration:" - [ -n "${template}" ] && writeToConfig "protocol bgp ${section} from ${template} {" \ - || writeToConfig "protocol bgp ${section} {" - [ -n "${disabled}" ] && write_bool disabled ${disabled} - [ -n "${table}" ] && writeToConfig " table ${table};" - [ -n "${igp_table}" ] && writeToConfig " igp table ${igp_table};" - [ -n "${passive}" ] && writeToConfig " passive;" ${passive} - [ -n "${local_as}" ] && writeToConfig " local as ${local_as};" - [ -n "${source_address}" ] && writeToConfig " source address ${source_address};" - [ -n "${import}" ] && writeToConfig " import ${import};" - [ -n "${export}" ] && writeToConfig " export ${export};" - [ -n "${neighbor_address}" -a -n "${neighbor_as}" ] && writeToConfig " neighbor ${neighbor_address} as ${neighbor_as};" - if [ -n "${import_limit}" -a "${import_limit}" > "0" ]; then - [ -z "${import_limit_action}" ] && ${import_limit_action} = "warn" - writeToConfig " import limit ${import_limit} action ${import_limit_action};" - fi - if [ -n "${export_limit}" -a "${export_limit}" > "0" ]; then - [ -z "${export_limit_action}" ] && ${export_limit_action} = "warn" - writeToConfig " export limit ${export_limit} action ${export_limit_action};" - fi - if [ -n "${receive_limit}" -a "${receive_limit}" > "0" ]; then - [ -z "${receive_limit_action}" ] && ${receive_limit_action} = "warn" - writeToConfig " receive limit ${receive_limit} action ${receive_limit_action};" - fi - [ -n "${next_hop_self}" ] && write_bool " next hop self;" ${next_hop_self} - [ -n "${next_hop_keep}" ] && write_bool " next hop keep;" ${next_hop_keep} - [ -n "${rr_client}" ] && write_bool " rr client;" ${rr_client} - [ -n "${rr_cluster_id}" ] && writeToConfig " rr cluster id ${rr_cluster_id};" - writeToConfig "}" - writeToConfig " " -} - - -#Function: prepare_ospf_network $1 -# $1 string $2 string -# This function gets each "ospf_network" protocol section in the UCI configuration, checks if its Area ID is the same as the one -# being configurated and finally sets the list of network ranges to be propagated, or not, by the OSPF protocol -# $1 is set as the ID of the action area of the internal networks. -# $2 is set as the ID of the current area being configurated. -prepare_ospf_networks() { - local section="$1" - local current_area="$2" - - if [ "${section}" = "${current_area}" ]; then - writeToConfig " networks {" - config_list_foreach ${section} range range_list - config_list_foreach ${section} hidden_range hidden_range_list - writeToConfig " };" - fi -} - - -# Function: prepare_ospf_password $1 $2 -prepare_ospf_passwords() { - local section="$1" - local current_interface="$2" - local interface; local passphrase - - get interface $section - get passphrase $section - - [ "current_interface" = "${interface}" ] && write ' password "$passphrase";' ${passphrase} -} - - -# Function: prepare_ospf_neighbors $1 $2 -#prepare_ospf_neighbors() { -#} - - -# Function: prepare_ospf_interface $1 $2 -prepare_ospf_interface() { - local section="$1" - local current_area="$2" - local area; local cost; local type; local hello; local priority; local retransmit; local authentication - - get area ${section} - get cost ${section} - get type ${section} - get hello ${section} - get priority ${section} - get retransmit ${section} - - if [ "${current_area}" = "${area}" ]; then - writeToConfig ' interface "$section" {' - write " cost ${cost};" ${cost} - write " hello ${hello};" ${hello} - write " type ${type};" ${type} - write " retransmit ${retransmit};" ${retransmit} - write " authentication ${authentication};" ${authentication} - config_foreach prepare_ospf_passwords "ospf_password" ${section} - # config_foreach prepare_ospf_neighbors "ospf_neighbor" $section - writeToConfig " };" - fi -} - - -# Function: prepare_ospf_area $1 -prepare_ospf_area() { - local section="$1" - local instance; local stub; local default_cost - - get instance ${section} - get stub ${section} - get default_cost ${section} - - writeToConfig " area ${section} {" - if [ -n "${instance}" -a "${instance}" = "${section}" ]; then - [ -n "${stub}" -a "${stub}" = "1" ] && writeToConfig " stub yes;" - [ -n "${default_cost}" ] && writeToConfig " default cost ${default_cost};" - config_foreach prepare_ospf_networks "ospf_networks" ${section} - config_foreach prepare_ospf_interface "ospf_interface" ${section} - writeToConfig " };" - fi -} - - -# Function: prepare_ospf_instance $1 -# $1 string -# This function gets each "ospf_area" protocol section in the UCI configuration and sets each option in the bird4.conf file. -# $1 is set as the ID of the current UCI ospf_area section. -prepare_ospf_instance() { - local section="$1" - local cfg1583compat; local tick - - get cfg1583compat ${section} - get tick ${section} - - writeToConfig "protocol ospf ${section} {" - [ -n "${cfg1583compat}" ] && cfg1583State="yes" || cfg1583State="no" - writeToConfig " rfc1583compat ${cfg1583State};" - [ -n "${tick}" ] && writeToConfig " tick ${tick};" - config_foreach prepare_ospf_area 'ospf_area' - writeToConfig "}" -} - - -# Function: gather_filters -# This function gets all the FILES under /filters folder and adds -# them into the config as %include elements on top of the file -# If there are no filters, the section will remain empty. -gather_filters() { - writeToConfig "#Filters Section:" - for filter in $(find /etc/${BIRD}/filters -type f); do - writeToConfig "include \"${filter}\";" - done - writeToConfig "#End of Filters --" - writeToConfig " " -} - - -# Function: gather_functions -# This function gets all the FILES under /functions folder and adds -# them into the config as %include elements on top of the file -# If there are no filters, the section will remain empty. -gather_functions() { - writeToConfig "#Functions Section:" - for func in $(find /etc/${BIRD}/functions -type f); do - writeToConfig "include \"${func}\";" - done - writeToConfig "#End of Functions --" - writeToConfig " " -} 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 diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/uci-defaults/99-relocate-filters b/bird1-openwrt/bird1-ipv4-openwrt/src/uci-defaults/99-relocate-filters deleted file mode 100644 index 97be5eb..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/uci-defaults/99-relocate-filters +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -# This UCI-Defaults script will MOVE any pre-existing filter -# stored in a file and configured as an UCI item (deprecated) -# The script will try to match any "filter" Section, get its -# "file_path" property and move the file (if exists) to the -# new (v0.3+) default location: /etc/bird{4|6}/filters - -[ $# -ne 1 ] && exit 1 -BIRD="$1" - -. /lib/functions.sh - -# This function will move an existing folder configured on -# Bird as a "filter" to filters' folder. -mv_filter() { - local section="$1" - local file_path - config_get file_path ${section} file_path - - if [ -f ${file_path} ]; then - mv ${file_path} /etc/${BIRD}/filters/ - fi - uci delete ${BIRD}.${section} -} - -if [ -f /etc/config/${BIRD} ]; then - config_load ${BIRD} - config_foreach mv_filter 'filter' - uci commit ${BIRD} -fi - -exit 0 diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/uci-defaults/bird-uci-install-init.d b/bird1-openwrt/bird1-ipv4-openwrt/src/uci-defaults/bird-uci-install-init.d deleted file mode 100644 index 28f64d2..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/uci-defaults/bird-uci-install-init.d +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -[ $# -ne 1 ] && exit 1 - -BIRD=$1 - -EXC=`mount -t overlayfs | grep overlayfs -c` - -[ $EXC > 0 ] && rm -r /etc/init.d/${BIRD} || mv /etc/init.d/${BIRD} /etc/${BIRD}/init.d/${BIRD}.orig - -ln -s /etc/${BIRD}/init.d/${BIRD} /etc/init.d/${BIRD} - -exit 0 diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/view/log.htm b/bird1-openwrt/bird1-ipv4-openwrt/src/view/log.htm deleted file mode 100644 index 2a85e9f..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/view/log.htm +++ /dev/null @@ -1,41 +0,0 @@ -<%- - -- Only populate textarea through XHR.poll - -- "refresh" is present in the URL (.../log?refresh=1) - if luci.http.formvalue("refresh") then - - -- Force HTTP Contents to be "text/plain" - luci.http.prepare_content("text/plain") - - local sys = require("luci.sys") - local uci = require "luci.model.uci".cursor() - - -- Get Log File from Bird's configuration or leave it empty. - local log_file = uci:get("bird4", "global", "log_file") or "" - local log_size = "" - if log_file then - log_size = sys.exec("du -h " .. log_file .. " | awk '{print $1}'") - -- Gathering last 30 lines of the Log File. - lf = sys.exec("tail -n30 " .. log_file):gsub("\r\n?", "\n") - end - - -- Write File used and its contents. - luci.http.write("Using Log File: " .. log_file .. " - File Size: " .. log_size .. "\n" .. lf) - - -- Avoid printing the rest of the page (return only text log data) - return - end --%> - -<%+header%> -<script type="text/javascript" src="<%=resource%>/cbi.js"></script> -<script type="text/javascript">//<![CDATA[ - // Refresh page each second. Use "refresh=1" as trigger. - XHR.poll(1, '<%=url('admin/network/bird4/log')%>', { refresh: 1 }, function(xhrInstance) { - var area = document.getElementById('log') - area.value = xhrInstance.responseText; - }); -//]]></script> - - -<textarea readonly="readonly" style="width: 100%" wrap="on" rows="32" id="log"><%=lf:pcdata()%></textarea> -<%+footer%> diff --git a/bird1-openwrt/bird1-ipv4-openwrt/src/view/tvalue.htm b/bird1-openwrt/bird1-ipv4-openwrt/src/view/tvalue.htm deleted file mode 100644 index 7eba122..0000000 --- a/bird1-openwrt/bird1-ipv4-openwrt/src/view/tvalue.htm +++ /dev/null @@ -1,5 +0,0 @@ -<%+cbi/valueheader%> - <textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%; font: normal 11pt 'Courier New'"<% else %> cols="<%=self.size%>"<% end %> data-update="change"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") .. ifattr(self.readonly, "readonly") %>> - <%-=pcdata(self:cfgvalue(section))-%> - </textarea> -<%+cbi/valuefooter%> |
