76 lines
1.5 KiB
Plaintext
76 lines
1.5 KiB
Plaintext
|
. /lib/functions/fff/babeldaemon
|
||
|
|
||
|
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
|
||
|
}
|