}
config_write_options() {
+ local funcname="config_write_options"
unset IFS
local schema="$1"
local cfg="$2"
local list_value
local i
local position
+ local speed
+ local list_speed_vars="HelloInterval HelloValidityTime TcInterval TcValidityTime MidInterval MidValidityTime HnaInterval HnaValidityTime"
get_value_for_entry()
{
[ "$option_type" = internal ] && return 1
config_get value "$cfg" "$option"
+ [ "$option" = "speed" ] && return 1
return 0
}
+ case " $schema " in
+ *" speed "*)
+ get_value_for_entry "speed"
+
+ if [ 2>/dev/null $value -gt 0 -a $value -le 20 ]; then
+ speed="$value"
+ else
+ log "$funcname() Warning: invalid speed-value: '$value' - allowed integers: 1...20, fallback to 6"
+ speed=6
+ fi
+
+ already_in_schema()
+ {
+ case " $schema " in
+ *" $1 "*)
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ }
+
+ for schema_entry in $list_speed_vars; do {
+ already_in_schema "$schema_entry" || schema="$schema $schema_entry"
+ } done
+ ;;
+ esac
+
for schema_entry in $schema; do
- get_value_for_entry "$schema_entry" || continue
+ if [ -n "$speed" ]; then # like sven-ola freifunk firmware fff-1.7.4
+ case "$schema_entry" in
+ HelloInterval)
+ value="$(( $speed / 2 + 1 )).0"
+ ;;
+ HelloValidityTime)
+ value="$(( $speed * 25 )).0"
+ ;;
+ TcInterval) # todo: not fisheye? -> $(( $speed * 2 ))
+ value=$(( $speed / 2 ))
+ [ $value -eq 0 ] && value=1
+ value="$value.0"
+ ;;
+ TcValidityTime)
+ value="$(( $speed * 100 )).0"
+ ;;
+ MidInterval)
+ value="$(( $speed * 5 )).0"
+ ;;
+ MidValidityTime)
+ value="$(( $speed * 100 )).0"
+ ;;
+ HnaInterval)
+ value="$(( $speed * 2 )).0"
+ ;;
+ HnaValidityTime)
+ value="$(( $speed * 25 )).0"
+ ;;
+ *)
+ get_value_for_entry "$schema_entry" || continue
+ ;;
+ esac
+
+ is_speed_var()
+ {
+ case " $list_speed_vars " in
+ *" $1 "*)
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ }
+
+ is_speed_var "$schema_entry" && option="$schema_entry"
+ else
+ get_value_for_entry "$schema_entry" || continue
+ fi
if [ -z "$value" ]; then
IFS='+'