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