Developing lightweight computation at the DSG edge

Commit f20965ac authored by p4u's avatar p4u
Browse files

Adapt more functions to the new gateway configuration syntax

parent 61adbd3f
...@@ -61,6 +61,10 @@ configure_wifi() { ...@@ -61,6 +61,10 @@ configure_wifi() {
fi fi
} }
configure_gw() {
qmp_gw_apply
}
apply_netserver() { apply_netserver() {
[ "$(qmp_uci_get networks.netserver)" == "1" ] && qmp_enable_netserver || qmp_disable_netserver [ "$(qmp_uci_get networks.netserver)" == "1" ] && qmp_enable_netserver || qmp_disable_netserver
} }
...@@ -168,6 +172,7 @@ help() { ...@@ -168,6 +172,7 @@ help() {
echo " configure_system : Configure and apply system settings (qmp.node section and so on)" echo " configure_system : Configure and apply system settings (qmp.node section and so on)"
echo " configure_wifi : Configure all WiFi devices" echo " configure_wifi : Configure all WiFi devices"
echo " reset_wifi : Reset, rescan and configure all the WiFi devices" echo " reset_wifi : Reset, rescan and configure all the WiFi devices"
echo " configure_gw : Configure and apply gateways settings"
echo "" echo ""
echo "Safe configuration:" echo "Safe configuration:"
......
...@@ -922,15 +922,13 @@ qmp_add_qmp_bmx6_tunnels() ...@@ -922,15 +922,13 @@ qmp_add_qmp_bmx6_tunnels()
config_get type "$section" type config_get type "$section" type
if [ "$type" = "offer" ] if [ "$type" = "offer" ]
then then
bmx6_type=tunInNet
# Future configuration bmx6_type=tunIn
#bmx6_type=tunIn
uci set $config.$name="$bmx6_type" uci set $config.$name="$bmx6_type"
uci set $config.$name.$bmx6_type="$section" uci set $config.$name.$bmx6_type="$section"
qmp_translate_configuration gateways $section network $config $name $bmx6_type qmp_translate_configuration gateways $section network $config $name $bmx6_type
# Future configuration qmp_translate_configuration gateways $section network $config $name
#qmp_translate_configuration gateways $section network $config $name #qmp_translate_configuration gateways $section bandwidth $config $name
qmp_translate_configuration gateways $section bandwidth $config $name
else else
# if [ "$type" = "search" ] # if [ "$type" = "search" ]
bmx6_type=tunOut bmx6_type=tunOut
......
...@@ -33,57 +33,27 @@ fi ...@@ -33,57 +33,27 @@ fi
[ -z "$SOURCE_COMMON" ] && . $QMP_PATH/qmp_common.sh [ -z "$SOURCE_COMMON" ] && . $QMP_PATH/qmp_common.sh
[ -z "$SOURCE_FUNCTIONS" ] && . $QMP_PATH/qmp_functions.sh [ -z "$SOURCE_FUNCTIONS" ] && . $QMP_PATH/qmp_functions.sh
qmp_exists_gateway() qmp_exists_gateway() {
qmp_uci_test gateways.$1
return $?
}
# set a gateway with given name and values
# <name> [arg1name arg1value] [arg2name arg2value] ...
qmp_set_gateway()
{ {
local config=$1 local name="$1"
shift shift
local ignore=0
local exists
args_key_values="$(echo $@ | awk -v RS=' ' 'NR % 2 == 1 && $0 !~ "^(ignore|(minB|b)andwidth)$" {a+=1} END {print a}')"
uci_key_values=$(env | grep -v -e "^CONFIG_${config}_\(TYPE\|ignore\|\(minB\|b\)andwidth\)=" | grep -c "^CONFIG_${config}_")
[ "$args_key_values" != "$uci_key_values" ] && return
while [ $# -ge 2 ] while [ $# -ge 2 ]
do do
if [ "$1" = "ignore" ] qmp_uci_set_raw gateways.$name.$1="$2"
then
ignore="$2"
else
config_get exists "$config" $1
if [ "$exists" != "$2" ]
then
return
fi
fi
shift shift
shift shift
done done
qmp_uci_commit gateways
uci_set gateways "$config" ignore "$ignore"
uci_commit
qmp_gateway_found=true
} }
qmp_set_gateway()
{
config_load gateways
qmp_gateway_found=false
config_foreach qmp_exists_gateway gateway $@
if ! $qmp_gateway_found
then
local config
config="$(uci add gateways gateway)"
while [ $# -ge 2 ]
do
uci_set gateways "$config" "$1" "$2"
shift
shift
done
uci_commit
fi
}
qmp_gw_search_default_ipv4() { qmp_gw_search_default_ipv4() {
qmp_set_gateway ignore 1 type offer network 0.0.0.0/0 qmp_set_gateway ignore 1 type offer network 0.0.0.0/0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment