Developing lightweight computation at the DSG edge

Commit 84aaef62 authored by p4u's avatar p4u
Browse files

Change ID/IP functions from qmp_functions to qmp_common

ULA/LAN autogenerated address now uses the crc16 hash
Fix issue with gateways offer (translation was not done properly)
parent c51bf00f
......@@ -251,9 +251,8 @@ qmp_hooks_exec() {
}
}
#########################
# Other kind of commands
# ID/IP commands
#########################
# Returns the crc16 from the mac of the primary mac device
......@@ -267,6 +266,25 @@ qmp_get_crc16() {
echo -e "$crc16" | awk NR==1
}
# qmp_get_id [8bit]
qmp_get_id() {
local community_node_id="$(qmp_uci_get node.community_node_id)"
[ -z "$community_node_id" ] && \
community_node_id="$(qmp_get_crc16)"
[ "$1" == "8bit" ] && echo "$(( 0x$community_node_id % 0x100 ))" || echo "$community_node_id"
}
# qmp_get_id_ip <1,2>
qmp_get_id_ip() {
[ "$1" == "1" ] && echo "$(qmp_get_crc16 1)"
[ "$1" == "2" ] && echo "$(qmp_get_crc16 2)"
}
#########################
# Other kind of commands
#########################
# Print the content of the parameters in reverse order (separed by spaces)
qmp_reverse_order() {
echo "$@" | awk '{for (i=NF; i>0; i--) printf("%s ",$i);print ""}'
......
......@@ -62,20 +62,7 @@ qmp_get_primary_device() {
echo "$primary_mesh_device"
}
# qmp_get_id [8bit]
qmp_get_id() {
local community_node_id="$(qmp_uci_get node.community_node_id)"
[ -z "$community_node_id" ] && \
community_node_id="$(qmp_get_crc16)"
[ "$1" == "8bit" ] && echo "$(( 0x$community_node_id % 0x100 ))" || echo "$community_node_id"
}
# qmp_get_id_ip <1,2>
qmp_get_id_ip() {
[ "$1" == "1" ] && echo "$(qmp_get_crc16 1)"
[ "$1" == "2" ] && echo "$(qmp_get_crc16 2)"
}
# check if a device exists
qmp_check_device() {
ip link show $1 1> /dev/null 2>/dev/null
return $?
......@@ -907,17 +894,19 @@ qmp_add_qmp_bmx6_tunnels()
[ "$ignore" = "1" ] && return
local type="$(qmp_uci_get_raw gateways.$name.type)"
qmp_log Configuring gateway $name of type $type
[ -z "$name" ] && name="qmp_$gateway" || name="qmp_$name"
qmp_log Configuring gateway $name
local type="$(qmp_uci_get_raw gateways.$name)"
if [ "$type" = "offer" ]
if [ "$type" == "offer" ]
then
bmx6_type=tunIn
uci set $config.$name="$bmx6_type"
uci set $config.$name.$bmx6_type="$name"
qmp_translate_configuration gateways $section network $config $name
for t in network address bandwidth
do
qmp_translate_configuration gateways $section $t $config $name
done
else
bmx6_type=tunOut
uci set $config.$name="$bmx6_type"
......
......@@ -224,7 +224,7 @@ qmp_radvd_enable_route() {
}
qmp_configure_lan_v6() {
echo "Starting ULA LAN configuration"
qmp_log "Starting ULA LAN configuration"
local prefix="$(qmp_uci_get networks.lan_ula_prefix48)"
[ -z "$prefix" ] && { echo "No lan ULA prefix configured, skiping LAN IPv6 ULA configuration"; return; }
......@@ -234,7 +234,7 @@ qmp_configure_lan_v6() {
if [ -z "$dev" ]; then
lanid="$(cat /var/log/*.log | md5sum | awk '{print $1}' | cut -c1-4)"
else
lanid="$(qmp_get_mac_for_dev $dev | tr -d : | cut -c9-12)"
lanid="$(qmp_get_id)"
fi
if [ $(echo $prefix | grep :: -c) -eq 0 ]; then
......
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