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