2021-02-15 00:32:53 +01:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
2019-06-27 19:48:25 +02:00
|
|
|
|
|
|
|
babel_add_interface() {
|
|
|
|
[ "$#" -ne "4" ] && return 1
|
|
|
|
|
|
|
|
local name="$1"
|
|
|
|
local interface="$2"
|
|
|
|
local type="$3"
|
|
|
|
local rxcost="$4"
|
|
|
|
|
|
|
|
uci set babeld.$name=interface
|
|
|
|
uci set babeld.$name.ifname="$interface"
|
|
|
|
uci set babeld.$name.type="$type"
|
|
|
|
uci set babeld.$name.rxcost="$rxcost"
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
babel_delete_interface() {
|
|
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
|
|
|
|
local name="$1"
|
|
|
|
|
|
|
|
uci -q del babeld.$name
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2019-08-14 01:00:42 +02:00
|
|
|
|
|
|
|
babel_add_redistribute_filter() {
|
|
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
|
|
|
|
local prefix="$1"
|
|
|
|
|
|
|
|
config=$(uci add babeld filter)
|
|
|
|
uci set babeld.$config.type='redistribute'
|
|
|
|
uci set babeld.$config.ip="$prefix"
|
|
|
|
uci set babeld.$config.addedbyautoconfig='true'
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2022-03-06 10:26:11 +01:00
|
|
|
babel_add_private_prefix_filter() {
|
|
|
|
[ "$#" -ne "1" ] && return 1
|
|
|
|
|
|
|
|
local prefix="$1"
|
|
|
|
|
|
|
|
config=$(uci add babeld filter)
|
|
|
|
uci set babeld.$config.type='redistribute'
|
|
|
|
uci set babeld.$config.ip="$prefix"
|
|
|
|
uci set babeld.$config.addedbyautoconfig='true'
|
|
|
|
uci set babeld.$config.action='deny'
|
|
|
|
|
|
|
|
# move to top, so filter rule has precedence over all other rules
|
|
|
|
uci reorder babeld.$config=0
|
|
|
|
|
|
|
|
config=$(uci add babeld filter)
|
|
|
|
uci set babeld.$config.type='redistribute'
|
|
|
|
uci set babeld.$config.ip="$prefix"
|
|
|
|
uci set babeld.$config.addedbyautoconfig='true'
|
|
|
|
uci set babeld.$config.local='true'
|
|
|
|
uci set babeld.$config.action='deny'
|
|
|
|
|
|
|
|
# move to top, so filter rule has precedence over all other rules
|
|
|
|
uci reorder babeld.$config=0
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-08-14 01:00:42 +02:00
|
|
|
babel_remove_custom_redistribute_filters() {
|
|
|
|
[ "$#" -ne "0" ] && return 1
|
|
|
|
|
|
|
|
remove_filters() {
|
|
|
|
local name="$1"
|
|
|
|
|
|
|
|
# check if filter was added by configuregateway
|
|
|
|
if ! [ "$(uci -q get babeld.$name.addedbyautoconfig)" = 'true' ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
uci -q del babeld.$name
|
|
|
|
}
|
|
|
|
|
|
|
|
config_load babeld
|
|
|
|
config_foreach remove_filters filter
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2021-02-15 00:32:53 +01:00
|
|
|
|
|
|
|
babel_apply() {
|
|
|
|
uci commit babeld
|
|
|
|
}
|
|
|
|
|
|
|
|
babel_reload() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
babel_revert() {
|
|
|
|
uci revert babeld
|
|
|
|
}
|