Developing lightweight computation at the DSG edge

Commit 6ff41393 authored by p4u's avatar p4u
Browse files

Change UCI config syntax for gateways (type=<search|offer>)

Adapt some functions for work with this approach
parent 25c265fa
config gateway inet6 config search 'inet6'
option type 'search'
option network '::/0' option network '::/0'
option maxPrefixLen '0' option maxPrefixLen '0'
config gateway inet4 config search 'inet4'
option type 'search'
option network '0.0.0.0/0' option network '0.0.0.0/0'
option maxPrefixLen '0' option maxPrefixLen '0'
option ignore '1' option ignore '1'
config gateway inet4of config offer 'inet4'
option ignore '1' option ignore '1'
option type 'offer'
option network '0.0.0.0/0' option network '0.0.0.0/0'
option bandwidth '100000' option bandwidth '100000'
config gateway community6 config search 'community6'
option type 'search'
option network '::/0' option network '::/0'
option minPrefixLen '32' option minPrefixLen '32'
option maxPrefixLen '48' option maxPrefixLen '48'
config gateway cloud6 config search 'cloud6'
option type 'search'
option network '::/0' option network '::/0'
option minPrefixLen '48' option minPrefixLen '48'
config gateway community config search 'community'
option type 'search'
option network '10.0.0.0/8' option network '10.0.0.0/8'
option maxPrefixLen '8' option maxPrefixLen '8'
option ignore '1' option ignore '1'
config gateway communityof config offer 'community'
option type 'offer'
option network '10.0.0.0/8' option network '10.0.0.0/8'
option bandwidth '100000' option bandwidth '100000'
option ignore '0' option ignore '1'
config gateway cloud config search 'cloud'
option type 'search'
option network '10.0.0.0/8' option network '10.0.0.0/8'
option minPrefixLen '24' option minPrefixLen '24'
config gateway example config search 'example'
option ignore '1' option ignore '1'
option type 'search'
option gwName 'qMp-example' option gwName 'qMp-example'
option network '10.1.0.0/16' option network '10.1.0.0/16'
option address '10.2.2.2/32' option address '10.2.2.2/32'
...@@ -57,7 +48,7 @@ config gateway example ...@@ -57,7 +48,7 @@ config gateway example
option minBandwidth '10000' option minBandwidth '10000'
option exportDistance '10' option exportDistance '10'
config gateway inet6of config offer 'inet6'
option type 'offer'
option network '::/0' option network '::/0'
option ignore '1' option ignore '1'
...@@ -918,18 +918,13 @@ qmp_add_qmp_bmx6_tunnels() ...@@ -918,18 +918,13 @@ qmp_add_qmp_bmx6_tunnels()
qmp_log Configuring gateway $name qmp_log Configuring gateway $name
local type local type="$(qmp_uci_get_raw gateways.$name)"
config_get type "$section" type
if [ "$type" = "offer" ] if [ "$type" = "offer" ]
then then
bmx6_type=tunInNet bmx6_type=tunIn
# Future configuration
#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="$name"
qmp_translate_configuration gateways $section network $config $name $bmx6_type qmp_translate_configuration gateways $section network $config $name
# Future configuration
#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" ]
......
...@@ -35,87 +35,61 @@ fi ...@@ -35,87 +35,61 @@ fi
qmp_exists_gateway() qmp_exists_gateway()
{ {
local config=$1 qmp_uci_test gateways.$1
shift return $?
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 ] # set a gateway with given name and values
do # <name> <search|offer> [arg1name arg1value] [arg2name arg2value] ...
if [ "$1" = "ignore" ] qmp_set_gateway()
then {
ignore="$2" local name="$1"
else
config_get exists "$config" $1
if [ "$exists" != "$2" ]
then
return
fi
fi
shift shift
local type="$1"
shift shift
done
uci_set gateways "$config" ignore "$ignore" qmp_uci_set_raw gateways.$name=$type
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 ] while [ $# -ge 2 ]
do do
uci_set gateways "$config" "$1" "$2" qmp_uci_set_raw gateways.$name.$1="$2"
shift shift
shift shift
done done
uci_commit qmp_uci_commit gateways
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 inet4 offer ignore 1 network 0.0.0.0/0
qmp_set_gateway ignore 0 type search network 0.0.0.0/0 maxPrefixLen 0 qmp_set_gateway inet4 search ignore 0 network 0.0.0.0/0 maxPrefixLen 0
qmp_gw_masq_wan 0 qmp_gw_masq_wan 0
} }
qmp_gw_search_default_ipv6() { qmp_gw_search_default_ipv6() {
qmp_set_gateway ignore 1 type offer network ::/0 qmp_set_gateway inet6 offer ignore 1 network ::/0
qmp_set_gateway ignore 0 type search network ::/0 maxPrefixLen 0 qmp_set_gateway inet6 search ignore 0 network ::/0 maxPrefixLen 0
} }
qmp_gw_offer_default_ipv4() { qmp_gw_offer_default_ipv4() {
qmp_set_gateway ignore 1 type search network 0.0.0.0/0 maxPrefixLen 0 qmp_set_gateway inet4 search ignore 1 network 0.0.0.0/0 maxPrefixLen 0
qmp_set_gateway ignore 0 type offer network 0.0.0.0/0 qmp_set_gateway inet4 offer ignore 0 network 0.0.0.0/0
qmp_gw_masq_wan 1 qmp_gw_masq_wan 1
} }
qmp_gw_offer_default_ipv6() { qmp_gw_offer_default_ipv6() {
qmp_set_gateway ignore 1 type search network ::/0 maxPrefixLen 0 qmp_set_gateway inet6 search ignore 1 network ::/0 maxPrefixLen 0
qmp_set_gateway ignore 0 type offer network ::/0 qmp_set_gateway inet6 offer ignore 0 network ::/0
} }
qmp_gw_disable_default_ipv4() { qmp_gw_disable_default_ipv4() {
qmp_set_gateway ignore 1 type search network 0.0.0.0/0 maxPrefixLen 0 qmp_set_gateway inet4 search ignore 1 network 0.0.0.0/0 maxPrefixLen 0
qmp_set_gateway ignore 1 type offer network 0.0.0.0/0 qmp_set_gateway inet4 offer ignore 1 network 0.0.0.0/0
qmp_gw_masq_wan 0 qmp_gw_masq_wan 0
} }
qmp_gw_disable_default_ipv6() { qmp_gw_disable_default_ipv6() {
qmp_set_gateway ignore 1 type search network ::/0 maxPrefixLen 0 qmp_set_gateway inet6 search ignore 1 network ::/0 maxPrefixLen 0
qmp_set_gateway ignore 1 type offer network ::/0 qmp_set_gateway inet6 offer ignore 1 network ::/0
} }
qmp_gw_default() { qmp_gw_default() {
......
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