Add support for different babel implementations
To be able to swap out babeld for a different babel implementation in the future, this splits all fff-specific configuration into a seperate fff-babel package. Implementation specific configuration is done in /lib/functions/fff/babeldaemon, which is included with every selectable babel implementation. It contains functions, which are called by the fff-specific code, and therefore allows to configure the implementation specific parts. The babel implementation is provided by implementation-specific fff-packages, which provide 'fff-babel-implementation'. At the moment, only fff-babeld is supported for use as babel implementation. Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
parent
55d03264d0
commit
ccc4bf823c
|
@ -0,0 +1,28 @@
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=fff-babel
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/fff-babel
|
||||||
|
SECTION:=base
|
||||||
|
CATEGORY:=Freifunk
|
||||||
|
TITLE:=Freifunk-Franken babel
|
||||||
|
URL:=https://www.freifunk-franken.de
|
||||||
|
DEPENDS:=+fff-babel-implementation
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/fff-babel/description
|
||||||
|
This is the Freifunk Franken Firmware babel package.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
# nothing
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/fff-babel/install
|
||||||
|
$(CP) ./files/* $(1)/
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,fff-babel))
|
|
@ -26,7 +26,7 @@ configure() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
config_load babeld
|
config_load network
|
||||||
config_foreach remove_babelpeer interface
|
config_foreach remove_babelpeer interface
|
||||||
|
|
||||||
#add new peers
|
#add new peers
|
||||||
|
@ -75,14 +75,14 @@ configure() {
|
||||||
babel_add_peer6addr "network.$prefixname.ip6addr"
|
babel_add_peer6addr "network.$prefixname.ip6addr"
|
||||||
|
|
||||||
# add babel interface
|
# add babel interface
|
||||||
babel_add_interface "$prefixname" "$iface" "$type" "$rxcost" || { echo "Could not add babeld interface for babelpeer $name"; exit 1; }
|
babel_add_interface "$prefixname" "$iface" "$type" "$rxcost" || { echo "Could not add babel interface for babelpeer $name"; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
config_load gateway
|
config_load gateway
|
||||||
config_foreach add_babelpeer babelpeer
|
config_foreach add_babelpeer babelpeer
|
||||||
|
|
||||||
|
|
||||||
# configure babeld filters for custom ipv6 addresses
|
# configure babel filters for custom ipv6 addresses
|
||||||
## remove old filters
|
## remove old filters
|
||||||
babel_remove_custom_redistribute_filters
|
babel_remove_custom_redistribute_filters
|
||||||
|
|
||||||
|
@ -94,10 +94,14 @@ configure() {
|
||||||
|
|
||||||
apply() {
|
apply() {
|
||||||
uci commit network
|
uci commit network
|
||||||
uci commit babeld
|
babel_apply
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
babel_reload
|
||||||
}
|
}
|
||||||
|
|
||||||
revert() {
|
revert() {
|
||||||
uci revert network
|
uci revert network
|
||||||
uci revert babeld
|
babel_revert
|
||||||
}
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
. /lib/functions/fff/babeldaemon
|
||||||
|
|
||||||
babel_add_iifrules() {
|
babel_add_iifrules() {
|
||||||
[ "$#" -ne "1" ] && return 1
|
[ "$#" -ne "1" ] && return 1
|
||||||
|
|
||||||
|
@ -60,62 +62,3 @@ babel_add_peer6addr() {
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
|
@ -11,6 +11,7 @@ define Package/fff-babeld
|
||||||
TITLE:=Freifunk-Franken babeld configuration example
|
TITLE:=Freifunk-Franken babeld configuration example
|
||||||
URL:=http://www.freifunk-franken.de
|
URL:=http://www.freifunk-franken.de
|
||||||
DEPENDS:=+babeld
|
DEPENDS:=+babeld
|
||||||
|
PROVIDES:=fff-babel-implementation
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/fff-babeld/description
|
define Package/fff-babeld/description
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
babel_apply() {
|
||||||
|
uci commit babeld
|
||||||
|
}
|
||||||
|
|
||||||
|
babel_reload() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
babel_revert() {
|
||||||
|
uci revert babeld
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ define Package/fff-layer3
|
||||||
TITLE:=Freifunk-Franken gateway configuration
|
TITLE:=Freifunk-Franken gateway configuration
|
||||||
URL:=https://www.freifunk-franken.de
|
URL:=https://www.freifunk-franken.de
|
||||||
DEPENDS:=+fff-alfred-monitoring-proxy \
|
DEPENDS:=+fff-alfred-monitoring-proxy \
|
||||||
|
+fff-babel \
|
||||||
+fff-babeld \
|
+fff-babeld \
|
||||||
+fff-boardname \
|
+fff-boardname \
|
||||||
+fff-dhcp \
|
+fff-dhcp \
|
||||||
|
|
|
@ -14,7 +14,7 @@ define Package/fff-wireguard
|
||||||
+kmod-wireguard \
|
+kmod-wireguard \
|
||||||
+owipcalc \
|
+owipcalc \
|
||||||
+wireguard-tools \
|
+wireguard-tools \
|
||||||
+fff-babeld \
|
+fff-babel \
|
||||||
+fff-network
|
+fff-network
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ configure() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
config_load babeld
|
config_load network
|
||||||
config_foreach remove_wgpeer interface
|
config_foreach remove_wgpeer interface
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ configure() {
|
||||||
babel_add_iifrules "$prefixname" || { echo "ERROR: Could not add iif-rules for wgpeer $name"; exit 1; }
|
babel_add_iifrules "$prefixname" || { echo "ERROR: Could not add iif-rules for wgpeer $name"; exit 1; }
|
||||||
|
|
||||||
# add babel interface
|
# add babel interface
|
||||||
babel_add_interface "$prefixname" "$prefixname" 'wired' "$rxcost" || { echo "ERROR: Could not add babeld interface for wgpeer $name"; exit 1; }
|
babel_add_interface "$prefixname" "$prefixname" 'wired' "$rxcost" || { echo "ERROR: Could not add babel interface for wgpeer $name"; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
config_load gateway
|
config_load gateway
|
||||||
|
@ -136,12 +136,16 @@ configure() {
|
||||||
|
|
||||||
apply() {
|
apply() {
|
||||||
uci commit network
|
uci commit network
|
||||||
uci commit babeld
|
|
||||||
uci commit gateway
|
uci commit gateway
|
||||||
|
babel_apply
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
babel_reload
|
||||||
}
|
}
|
||||||
|
|
||||||
revert() {
|
revert() {
|
||||||
uci revert network
|
uci revert network
|
||||||
uci revert babeld
|
|
||||||
uci revert gateway
|
uci revert gateway
|
||||||
|
babel_revert
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue