diff --git a/net/olsrd/files/olsrd.init b/net/olsrd/files/olsrd.init index 6ed369fc4..aab85eb15 100644 --- a/net/olsrd/files/olsrd.init +++ b/net/olsrd/files/olsrd.init @@ -225,6 +225,7 @@ config_update_schema() { } config_write_options() { + local funcname="config_write_options" unset IFS local schema="$1" local cfg="$2" @@ -244,6 +245,8 @@ config_write_options() { 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() { @@ -262,12 +265,90 @@ config_write_options() { [ "$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='+'