firmware/src/packages/fff/fff-babel/files/lib/functions/fff/babel

90 lines
1.8 KiB
Plaintext

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 ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
# use ipaddr (without subnet) if no peer_ip set
uci add_list "$option"=$(echo $ipaddr | cut -d / -f1)
else
echo "WARNING: Neither peer_ip nor 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
case $implementation in
bird2)
/etc/init.d/babeld stop 2>/dev/null
/etc/init.d/babeld disable
/etc/init.d/bird enable
/etc/init.d/bird start
;;
babeld)
/etc/init.d/bird stop 2>/dev/null
/etc/init.d/bird disable
/etc/init.d/babeld enable
/etc/init.d/babeld start
;;
esac
# call implementation-specific reload commands
babel_reload_implementation
return 0
}