Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Quick Mesh Project
qMp packages
Commits
ec2fb9f9
Commit
ec2fb9f9
authored
Mar 14, 2013
by
Simó Albert i Beltran
Browse files
Add support to configure arbitrary gateways, closes #225 and references #210.
parent
fd61329b
Changes
4
Hide whitespace changes
Inline
Side-by-side
packages/qmp-system/files/etc/config/qmp
View file @
ec2fb9f9
...
@@ -59,12 +59,54 @@ config 'qmp' 'networks'
...
@@ -59,12 +59,54 @@ config 'qmp' 'networks'
option 'babel_mesh_prefix48' 'fd03:0:0'
option 'babel_mesh_prefix48' 'fd03:0:0'
option 'netserver' '1'
option 'netserver' '1'
config 'qmp' 'tunnels'
config 'gateway'
option 'search_ipv4_tunnel' '0.0.0.0/0'
option 'type' 'search'
option 'search_ipv6_tunnel' '::/0'
option 'network' '::/0'
# option 'offer_ipv4_tunnel' '0.0.0.0/0'
# option 'offer_ipv6_tunnel' '::/0'
config 'gateway'
option 'ignore' '1'
option 'type' 'offer'
option 'network' '::/0'
option 'bandwidth' '100000'
config 'gateway'
option 'type' 'search'
option 'network' '0.0.0.0/0'
option 'maxPrefixLen' '0'
config 'gateway'
option 'ignore' '1'
option 'type' 'offer'
option 'network' '0.0.0.0/0'
option 'bandwidth' '100000'
config 'gateway'
option 'type' 'search'
option 'network' '10.0.0.0/8'
option 'maxPrefixLen' '8'
config 'gateway'
option 'type' 'search'
option 'network' '10.0.0.0/8'
option 'minPrefixLen' '16'
config 'gateway'
option 'ignore' '1'
option 'type' 'search'
option 'network' '::/0'
option 'gwName' 'qMp-d6'
config 'gateway'
option 'ignore' '1'
option 'type' 'search'
option 'gwName' 'qMp-ab'
option 'network' '10.1.0.0/16'
option 'address' '10.2.2.2/32'
option 'minPrefixLen' '16'
option 'maxPrefixLen' '24'
option 'hysteresis' '20'
option 'bonus' '10'
option 'exportDistance' '10'
config 'qmp' 'wireless'
config 'qmp' 'wireless'
option 'driver' 'mac80211'
option 'driver' 'mac80211'
...
...
packages/qmp-system/files/etc/qmp/qmp_functions.sh
View file @
ec2fb9f9
...
@@ -29,6 +29,11 @@ SOURCE_FUNCTIONS=1
...
@@ -29,6 +29,11 @@ SOURCE_FUNCTIONS=1
#######################
#######################
# Importing files
# Importing files
######################
######################
if
[
-z
"
$SOURCE_OPENWRT_FUNCTIONS
"
]
then
.
/lib/functions.sh
SOURCE_OPENWRT_FUNCTIONS
=
1
fi
.
$QMP_PATH
/qmp_common.sh
.
$QMP_PATH
/qmp_common.sh
[
-z
"
$SOURCE_GW
"
]
&&
.
$QMP_PATH
/qmp_gw.sh
[
-z
"
$SOURCE_GW
"
]
&&
.
$QMP_PATH
/qmp_gw.sh
[
-z
"
$SOURCE_NET
"
]
&&
.
$QMP_PATH
/qmp_network.sh
[
-z
"
$SOURCE_NET
"
]
&&
.
$QMP_PATH
/qmp_network.sh
...
@@ -791,6 +796,84 @@ qmp_configure_network() {
...
@@ -791,6 +796,84 @@ qmp_configure_network() {
}
}
qmp_remove_qmp_bmx6_tunnels
()
{
if
echo
"
$1
"
|
grep
-q
"^qmp-[0-9]*$"
then
uci delete bmx6.
$1
fi
}
qmp_unconfigure_bmx6_gateways
()
{
config_load bmx6
config_foreach qmp_remove_qmp_bmx6_tunnels tunInNet
config_foreach qmp_remove_qmp_bmx6_tunnels tunOut
}
qmp_translate_configuration
()
{
orig_config
=
$1
orig_section
=
$2
orig_option
=
$3
dest_config
=
$4
dest_section
=
$5
dest_option
=
${
6
:-
$orig_option
}
value
=
"
$(
uci
-q
get
$orig_config
.
$orig_section
.
$orig_option
)
"
if
[
-n
"
$value
"
]
then
uci
set
$dest_config
.
$dest_section
.
$dest_option
=
"
$value
"
fi
}
qmp_add_qmp_bmx6_tunnels
()
{
local
section
=
$1
local
config
=
bmx6
local
name
=
"qmp_
$gateway
"
local
ignore
config_get ignore
"
$section
"
ignore
if
[
"
$ignore
"
=
"1"
]
then
return
fi
local type
config_get
type
"
$section
"
type
if
[
"
$type
"
=
"offer"
]
then
bmx6_type
=
tunInNet
uci
set
$config
.
$name
=
"
$bmx6_type
"
qmp_translate_configuration qmp
$section
network
$config
$name
$bmx6_type
qmp_translate_configuration qmp
$section
bandwidth
$config
$name
else
# if [ "$type" = "search" ]
bmx6_type
=
tunOut
uci
set
$config
.
$name
=
"
$bmx6_type
"
uci
set
$config
.
$name
.
$bmx6_type
=
"
$name
"
qmp_translate_configuration qmp
$section
network
$config
$name
qmp_translate_configuration qmp
$section
gwName
$config
$name
qmp_translate_configuration qmp
$section
address
$config
$name
qmp_translate_configuration qmp
$section
minPrefixLen
$config
$name
qmp_translate_configuration qmp
$section
maxPrefixLen
$config
$name
qmp_translate_configuration qmp
$section
hysteresis
$config
$name
qmp_translate_configuration qmp
$section
bonus
$config
$name
qmp_translate_configuration qmp
$section
exportDistance
$config
$name
fi
gateway
=
"
$((
$gateway
+
1
))
"
}
qmp_configure_bmx6_gateways
()
{
qmp_unconfigure_bmx6_gateways
config_load qmp
gateway
=
0
config_foreach qmp_add_qmp_bmx6_tunnels gateway
}
qmp_configure_bmx6
()
{
qmp_configure_bmx6
()
{
# set -x
# set -x
...
@@ -890,34 +973,7 @@ qmp_configure_bmx6() {
...
@@ -890,34 +973,7 @@ qmp_configure_bmx6() {
uci
set
$conf
.general.tun6Address
=
"
$(
uci get qmp.networks.bmx6_ripe_prefix48
)
:
$community_node_id
:0:0:0:1/64"
uci
set
$conf
.general.tun6Address
=
"
$(
uci get qmp.networks.bmx6_ripe_prefix48
)
:
$community_node_id
:0:0:0:1/64"
fi
fi
qmp_configure_bmx6_gateways
if
qmp_uci_test qmp.tunnels.search_ipv6_tunnel
;
then
uci
set
$conf
.tun6Out
=
"tunOut"
uci
set
$conf
.tun6Out.tunOut
=
"tun6Out"
uci
set
$conf
.tun6Out.network
=
"
$(
uci get qmp.tunnels.search_ipv6_tunnel
)
"
uci
set
$conf
.tun6Out.mtu
=
1360
fi
if
qmp_uci_test qmp.tunnels.search_ipv4_tunnel
;
then
uci
set
$conf
.tun4Out
=
"tunOut"
uci
set
$conf
.tun4Out.tunOut
=
"tun4Out"
uci
set
$conf
.tun4Out.network
=
"
$(
uci get qmp.tunnels.search_ipv4_tunnel
)
"
uci
set
$conf
.tun4Out.mtu
=
1360
elif
qmp_uci_test qmp.tunnels.offer_ipv4_tunnel
;
then
uci
set
$conf
.tunInRemote
=
"tunInRemote"
uci
set
$conf
.tunInRemote.tunInRemote
=
"
$(
qmp_get_ula96
$(
uci get qmp.networks.bmx6_mesh_prefix48
)
::
$primary_mesh_device
2002::ffff
)
"
uci
set
$conf
.tun4InNet
=
"tunInNet"
uci
set
$conf
.tun4InNet.tunInNet
=
"
$(
uci get qmp.tunnels.offer_ipv4_tunnel
)
"
uci
set
$conf
.tun4InNet.bandwidth
=
"1000000"
fi
#Configuring the tunnel to search 10/8 networks
uci
set
$conf
.nodes10
=
"tunOut"
uci
set
$conf
.nodes10.tunOut
=
"nodes10"
uci
set
$conf
.nodes10.network
=
"10.0.0.0/8"
uci
set
$conf
.nodes10.mtu
=
1360
uci commit
$conf
uci commit
$conf
# /etc/init.d/$conf restart
# /etc/init.d/$conf restart
...
...
packages/qmp-system/files/etc/qmp/qmp_gw.sh
View file @
ec2fb9f9
...
@@ -25,46 +25,108 @@
...
@@ -25,46 +25,108 @@
QMP_PATH
=
"/etc/qmp"
QMP_PATH
=
"/etc/qmp"
SOURCE_GW
=
1
SOURCE_GW
=
1
if
[
-z
"
$SOURCE_OPENWRT_FUNCTIONS
"
]
then
.
/lib/functions.sh
SOURCE_OPENWRT_FUNCTIONS
=
1
fi
[
-z
"
$SOURCE_COMMON
"
]
&&
.
$QMP_PATH
/qmp_common.sh
[
-z
"
$SOURCE_COMMON
"
]
&&
.
$QMP_PATH
/qmp_common.sh
[
-z
"
$SOURCE_NETWORK
"
]
&&
.
$QMP_PATH
/qmp_functions.sh
[
-z
"
$SOURCE_NETWORK
"
]
&&
.
$QMP_PATH
/qmp_functions.sh
qmp_exists_gateway
()
{
local
config
=
$1
shift
local
ignore
=
0
local
exists
args_key_values
=
"
$(
echo
$@
|
awk
-v
RS
=
' '
'NR % 2 == 1 && $0 !~ "(ignore|bandwidth)" {a+=1} END {print a}'
)
"
uci_key_values
=
$(
env
|
grep
-v
-e
"^CONFIG_
${
config
}
_
\(
TYPE
\|
ignore
\|
bandwidth
\)
="
|
grep
-c
"^CONFIG_
${
config
}
_"
)
if
[
"
$args_key_values
"
!=
"
$uci_key_values
"
]
then
return
fi
while
[
$#
-ge
2
]
do
if
[
"
$1
"
=
"ignore"
]
then
ignore
=
"
$2
"
else
config_get exists
"
$config
"
$1
if
[
"
$1
"
=
"bandwidth"
]
then
if
[
-z
"
$exists
"
]
then
return
fi
elif
[
"
$exists
"
!=
"
$2
"
]
then
return
fi
fi
shift
shift
done
uci_set qmp
"
$config
"
ignore
"
$ignore
"
uci_commit
qmp_gateway_found
=
true
}
qmp_set_gateway
()
{
config_load qmp
qmp_gateway_found
=
false
config_foreach qmp_exists_gateway gateway
$@
if
!
$qmp_gateway_found
then
local
config
config
=
"
$(
uci add qmp gateway
)
"
while
[
$#
-ge
2
]
do
uci_set qmp
"
$config
"
"
$1
"
"
$2
"
shift
shift
done
uci_commit
fi
}
qmp_gw_search_default_ipv4
()
{
qmp_gw_search_default_ipv4
()
{
qmp_
uci_set tunnels qmp
qmp_
set_gateway ignore 1
type
offer network 0.0.0.0/0 bandwidth 100000
qmp_
uci_set tunnels.search_ipv4_tunnel 0.0.0.0/
0
qmp_
set_gateway ignore 0
type
search network 0.0.0.0/0 maxPrefixLen
0
qmp_gw_masq_wan 0
qmp_gw_masq_wan 0
qmp_uci_del tunnels.offer_ipv4_tunnel
}
}
qmp_gw_search_default_ipv6
()
{
qmp_gw_search_default_ipv6
()
{
qmp_
uci_set tunnels qmp
qmp_
set_gateway ignore 1
type
offer network ::/0 bandwidth 100000
qmp_
uci_set tunnels.search_ipv6_tunnel
::/0
qmp_
set_gateway ignore 0
type
search network
::/0
qmp_gw_masq_wan 0
qmp_gw_masq_wan 0
qmp_uci_del tunnels.offer_ipv6_tunnel
}
}
qmp_gw_offer_default_ipv4
()
{
qmp_gw_offer_default_ipv4
()
{
qmp_
uci_set tunnels qmp
qmp_
set_gateway ignore 1
type
search network 0.0.0.0/0 maxPrefixLen 0
qmp_
uci_set tunnels.offer_ipv4_tunnel 0.0.0.0/
0
qmp_
set_gateway ignore 0
type
offer network 0.0.0.0/0 bandwidth 10000
0
qmp_gw_masq_wan 1
qmp_gw_masq_wan 1
qmp_uci_del tunnels.search_ipv4_tunnel
}
}
qmp_gw_offer_default_ipv6
()
{
qmp_gw_offer_default_ipv6
()
{
qmp_
uci_set tunnels qmp
qmp_
set_gateway ignore 1
type
search network ::/0
qmp_
uci_set tunnels.offer_ipv6_tunnel ::/
0
qmp_
set_gateway ignore 0
type
offer network ::/0 bandwidth 10000
0
qmp_gw_masq_wan 1
qmp_gw_masq_wan 1
qmp_uci_del tunnels.search_ipv6_tunnel
}
}
qmp_gw_disable_default_ipv4
()
{
qmp_gw_disable_default_ipv4
()
{
qmp_
uci_del tunnels.offer_ipv4_tunnel
qmp_
set_gateway ignore 1
type
search network 0.0.0.0/0 maxPrefixLen 0
qmp_
uci_del tunnels.search_ipv4_tunnel
qmp_
set_gateway ignore 1
type
offer network 0.0.0.0/0 bandwidth 100000
qmp_gw_masq_wan 0
qmp_gw_masq_wan 0
}
}
qmp_gw_disable_default_ipv6
()
{
qmp_gw_disable_default_ipv6
()
{
qmp_
uci_del tunnels.offer_ipv6_tunnel
qmp_
set_gateway ignore 1
type
search network ::/0
qmp_
uci_del tunnels.search_ipv6_tunnel
qmp_
set_gateway ignore 1
type
offer network ::/0 bandwidth 100000
qmp_gw_masq_wan 0
qmp_gw_masq_wan 0
}
}
...
@@ -127,7 +189,7 @@ qmp_gw_masq_wan() {
...
@@ -127,7 +189,7 @@ qmp_gw_masq_wan() {
qmp_gw_apply
()
{
qmp_gw_apply
()
{
qmp_configure_bmx6
qmp_configure_bmx6
bmx6
-c
--configReload
bmx6
-c
--configReload
||
/etc/init.d/bmx6 restart
/etc/init.d/firewall restart
/etc/init.d/firewall restart
}
}
packages/qmp-system/files/etc/uci-defaults/qmp_update_config_gateways
0 → 100644
View file @
ec2fb9f9
#
# Update gateways configuration
#
# Copyright (C) 2013 Simó Albert i Beltran
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Change gateways configuration on /etc/config/qmp from:
#
# config 'qmp' 'tunnels'
# option 'search_ipv4_tunnel' '0.0.0.0/0'
# # option 'offer_ipv4_tunnel' '0.0.0.0/0'
# option 'search_ipv6_tunnel' '::/0'
# # option 'offer_ipv6_tunnel' '::/0'
#
# to:
#
# config 'gateway'
# option 'ignore' '0'
# # option 'ignore' '1'
# option 'type' 'search'
# option 'network' '::/0'
#
# config 'gateway'
# option 'ignore' '1'
# # option 'ignore' '0'
# option 'type' 'offer'
# option 'network' '::/0'
# option 'bandwidth' '100000'
#
# config 'gateway'
# option 'ignore' '0'
# # option 'ignore' '1'
# option 'type' 'search'
# option 'network' '0.0.0.0/0'
# option 'maxPrefixLen' '0'
#
# config 'gateway'
# option 'ignore' '1'
# # option 'ignore' '0'
# option 'type' 'offer'
# option 'network' '0.0.0.0/0'
# option 'bandwidth' '100000'
#
# config 'gateway'
# option 'type' 'search'
# option 'network' '10.0.0.0/8'
# option 'maxPrefixLen' '8'
#
# config 'gateway'
# option 'type' 'search'
# option 'network' '10.0.0.0/8'
# option 'minPrefixLen' '16'
#
# See also: http://qmp.cat/issues/210
[ -z "$SOURCE_GW" ] && . /etc/qmp/qmp_gw.sh
translate_tunnel()
{
local ipv="$1"
local extra_args_ignore=""
local extra_args_no_ignore=""
local tunnel_network
config_get tunnel_network tunnels search_ipv${ipv}_tunnel
if [ -n "$tunnel_network" ]
then
type_ignore="offer"
type_no_ignore="search"
extra_args_ignore="bandwidth 100000"
if [ "$ipv" = 4 ] && [ "$tunnel_network" = "0.0.0.0/0" ]
then
extra_args_no_ignore="maxPrefixLen 0"
fi
else
config_get tunnel_network tunnels offer_ipv${ipv}_tunnel
if [ -n "$tunnel_network" ]
then
type_ignore="search"
type_no_ignore="offer"
extra_args_no_ignore="bandwidth 100000"
if [ "$ipv" = 4 ] && [ "$tunnel_network" = "0.0.0.0/0" ]
then
extra_args_ignore="maxPrefixLen 0"
fi
fi
fi
if [ -n "$tunnel_network" ]
then
qmp_set_gateway ignore 1 type $type_ignore network $tunnel_network $extra_args_ignore
qmp_set_gateway ignore 0 type $type_no_ignore network $tunnel_network $extra_args_no_ignore
fi
}
if uci -q get qmp.tunnels > /dev/null
then
config_load qmp
translate_tunnel 6
translate_tunnel 4
qmp_set_gateway type search network 10.0.0.0/8 maxPrefixLen 8
qmp_set_gateway type search network 10.0.0.0/8 minPrefixLen 16
uci delete qmp.tunnels
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment