forked from freifunk-franken/firmware
Some users might want to prefer one babel implementation over another for various reasons. Having to compile the firmware from scratch can be quite tedious in that case. Instead, make the babel implementation switchable at runtime. The implementation can be switched manually using the uci option `babelimpl.impl.impl`, which currently is not upgrade-safe. Signed-off-by: Fabian Bläse <fabian@blaese.de> Acked-by: Christian Dresel <freifunk@dresel.systems>
73 lines
1.4 KiB
Plaintext
73 lines
1.4 KiB
Plaintext
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
babel_get_version() {
|
|
/usr/sbin/bird --version 2>&1 | sed "s/BIRD version /bird-/"
|
|
}
|
|
|
|
babel_add_interface() {
|
|
[ "$#" -ne "4" ] && return 1
|
|
|
|
local name="$1"
|
|
local interface="$2"
|
|
local type="$3"
|
|
local rxcost="$4"
|
|
|
|
mkdir -p /tmp/bird/fff/babelpeers
|
|
echo "interface \"$interface\" { type $type; rxcost $rxcost; };" > /tmp/bird/fff/babelpeers/$name.conf
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_delete_interface() {
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
local name="$1"
|
|
|
|
# Removing peers from /etc is not necessary, as all peers are generated into /tmp on every configuration run,
|
|
# which completely overwrites existing peers in /etc in the apply step.
|
|
rm -f /tmp/bird/fff/babelpeers/$name.conf
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_add_redistribute_filter() {
|
|
return 0
|
|
}
|
|
|
|
babel_add_private_prefix_filter() {
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
local prefix="$1"
|
|
prefix=$(owipcalc "$prefix" network prefix "$prefix")
|
|
|
|
mkdir -p /tmp/bird/fff
|
|
echo "if net ~ $prefix then reject;" > /tmp/bird/fff/nat-filter.conf
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_remove_custom_redistribute_filters() {
|
|
mkdir -p /tmp/bird/fff
|
|
> /tmp/bird/fff/nat-filter.conf
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_apply_implementation() {
|
|
# error output hidden because apply might be executed without a preceding configure step.
|
|
if [ -d /tmp/bird/fff ]; then
|
|
rm -rf /etc/bird/fff
|
|
mv /tmp/bird/fff /etc/bird/fff
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_reload_implementation() {
|
|
/etc/init.d/fff-bird reload
|
|
}
|
|
|
|
babel_revert() {
|
|
rm -r /tmp/bird/fff
|
|
}
|