Fabian Bläse
9444aaa959
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>
117 lines
2.3 KiB
Plaintext
117 lines
2.3 KiB
Plaintext
|
|
implementation=$(uci -q get babelimpl.impl.impl)
|
|
[ -z "$implementation" ] && implementation=babeld
|
|
|
|
. /lib/functions/fff/babeldaemon/$implementation
|
|
|
|
babel_add_iifrules() {
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
local name="$1"
|
|
local table='10'
|
|
local prio='31'
|
|
|
|
uci set network.${name}_rule=rule
|
|
uci set network.${name}_rule.in="$name"
|
|
uci set network.${name}_rule.lookup="$table"
|
|
uci set network.${name}_rule.priority="$prio"
|
|
|
|
uci set network.${name}_rule6=rule6
|
|
uci set network.${name}_rule6.in="$name"
|
|
uci set network.${name}_rule6.lookup="$table"
|
|
uci set network.${name}_rule6.priority="$prio"
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_delete_iifrules() {
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
local name="$1"
|
|
|
|
uci -q del network.${name}_rule
|
|
uci -q del network.${name}_rule6
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_add_peeraddr() {
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
local option="$1"
|
|
|
|
if peer_ip=$(uci -q get gateway.@gateway[0].peer_ip); then
|
|
uci add_list "$option"="$peer_ip"
|
|
elif router_ip=$(uci -q get gateway.meta.router_ip); then
|
|
# use router_ip if no peer_ip is set
|
|
ip=$router_ip
|
|
|
|
# use only first ip
|
|
ip=${ip%% *}
|
|
|
|
# remove CIDR mask
|
|
ip=${ip%%/*}
|
|
|
|
uci add_list "$option"="$ip"
|
|
elif ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
|
|
# use client interface address (without subnet) if no router_ip is set
|
|
uci add_list "$option"=${ipaddr%%/*}
|
|
else
|
|
echo "WARNING: No peer_ip, router_ip or client interface ipaddr set! IPv4 routing is not possible."
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_add_peer6addr() {
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
local option="$1"
|
|
|
|
if peer_ip6=$(uci -q get gateway.@gateway[0].peer_ip6); then
|
|
uci add_list "$option"="$peer_ip6"
|
|
else
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_reload() {
|
|
# switch implementation temporarily
|
|
case $implementation in
|
|
bird2)
|
|
/etc/init.d/babeld stop 2>/dev/null
|
|
/etc/init.d/fff-bird start
|
|
;;
|
|
babeld)
|
|
/etc/init.d/fff-bird stop 2>/dev/null
|
|
/etc/init.d/babeld start
|
|
;;
|
|
esac
|
|
|
|
# call implementation-specific reload commands
|
|
babel_reload_implementation
|
|
|
|
return 0
|
|
}
|
|
|
|
babel_apply() {
|
|
# switch implementation persistently
|
|
case $implementation in
|
|
bird2)
|
|
/etc/init.d/babeld disable
|
|
/etc/init.d/fff-bird enable
|
|
;;
|
|
babeld)
|
|
/etc/init.d/fff-bird disable
|
|
/etc/init.d/babeld enable
|
|
;;
|
|
esac
|
|
|
|
babel_apply_implementation
|
|
|
|
return 0
|
|
}
|