Developing lightweight computation at the DSG edge

Commit 399f4295 authored by p4u's avatar p4u
Browse files

Added new function qmp_get_devices. Now it is possible to define a LAN device...

Added new function qmp_get_devices. Now it is possible to define a LAN device also as Mesh, br-lan will be used in such case
parent e41b5169
......@@ -40,6 +40,45 @@ qmp_get_llocal_for_dev() {
}
# arg1=<mesh|lan|wan>, returns the devices which have to be configured in such mode
qmp_get_devices() {
local devices=""
if [ "$1" == "mesh" ]; then
local brlan_enabled=0
for dev in $(uci get qmp.interfaces.mesh_devices 2>/dev/null); do
# Lookging if device is defined as LAN, in such case dev=br-lan, but only once
for landev in $(uci get qmp.interfaces.lan_devices 2>/dev/null); do
if [ "$landev" == "$dev" ]; then
if [ $brlan_enabled -eq 0 ]; then
dev="br-lan"
brlan_enabled=1
break
else
dev=""
break
fi
fi
done
[ -n "$dev" ] && devices="$devices $dev"
done
fi
if [ "$1" == "lan" ]; then
devices="$(uci get qmp.interfaces.lan_devices 2>/dev/null)"
fi
if [ "$1" == "wan" ]; then
devices="$(uci get qmp.interfaces.wan_devices 2>/dev/null)"
fi
echo "$devices"
}
qmp_get_ip6_slow() {
local addr_prefix="$1"
......@@ -399,7 +438,7 @@ qmp_configure_network() {
uci set $conf.loopback.netmask="255.0.0.0"
wan_offset=0
for i in $(uci get qmp.interfaces.wan_devices) ; do
for i in $(qmp_get_devices wan) ; do
uci set $conf.wan${wan_offset}="interface"
uci set $conf.wan${wan_offset}.ifname="$i"
uci set $conf.wan${wan_offset}.proto="dhcp"
......@@ -407,7 +446,7 @@ qmp_configure_network() {
done
local primary_mesh_device="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
local primary_mesh_device="$(qmp_get_devices mesh | awk '{print $1}')"
local community_node_id
local LSB_PRIM_MAC="$( qmp_get_mac_for_dev $primary_mesh_device | awk -F':' '{print $6}' )"
......@@ -449,7 +488,7 @@ qmp_configure_network() {
uci commit dhcp
uci set $conf.lan="interface"
uci set $conf.lan.ifname="$(uci get qmp.interfaces.lan_devices)"
uci set $conf.lan.ifname="$(qmp_get_devices lan)"
uci set $conf.lan.type="bridge"
uci set $conf.lan.proto="static"
uci set $conf.lan.ipaddr=$LAN_ADDR
......@@ -461,9 +500,14 @@ qmp_configure_network() {
local counter=1
if uci get qmp.interfaces.mesh_devices && uci get qmp.networks.mesh_protocol_vids && uci get qmp.networks.mesh_vid_offset; then
for dev in $(qmp_get_devices mesh); do
for dev in $(uci get qmp.interfaces.mesh_devices); do
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
# If dev is empty, nothing to do
[ -z "$dev" ] && continue
#Let's configure the mesh device
echo "Configuring "$dev" for Meshing"
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')"
local vid_suffix="$(echo $protocol_vid | awk -F':' '{print $2}')"
......@@ -528,7 +572,7 @@ qmp_configure_bmx6() {
fi
local primary_mesh_device="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
local primary_mesh_device="$(qmp_get_devices mesh | awk '{print $1}')"
local community_node_id
if qmp_uci_test qmp.node.community_node_id; then
community_node_id="$(uci get qmp.node.community_node_id)"
......@@ -540,7 +584,7 @@ qmp_configure_bmx6() {
local counter=1
for dev in $(uci get qmp.interfaces.mesh_devices); do
for dev in $(qmp_get_devices mesh); do
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')"
......@@ -636,7 +680,7 @@ LoadPlugin "olsrd_txtinfo.so.0.1"
EOF
local primary_mesh_device="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
local primary_mesh_device="$(qmp_get_devices mesh | awk '{print $1}')"
local community_node_id
if qmp_uci_test qmp.node.community_node_id; then
community_node_id="$(uci get qmp.node.community_node_id)"
......@@ -649,7 +693,7 @@ EOF
local counter=1
for dev in $(uci get qmp.interfaces.mesh_devices); do
for dev in $(qmp_get_devices mesh); do
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')"
......@@ -718,69 +762,6 @@ EOF
}
qmp_configure_olsr6_uci_unused() {
local conf="olsrd_uci"
qmp_configure_prepare $conf
uci set $conf.networks="olsrd"
uci set $conf.networks.IpVersion="6"
uci set $conf.arprefresh="LoadPlugin"
uci set $conf.arprefresh.library="olsrd_arprefresh.so.0.1"
uci set $conf.httpinfo="LoadPlugin"
uci set $conf.httpinfo.library="olsrd_httpinfo.so.0.1"
uci set $conf.httpinfo.port="1978"
uci add_list $conf.httpinfo.Net="0::/0"
uci set $conf.nameservice="LoadPlugin"
uci set $conf.nameservice.library="olsrd_nameservice.so.0.3"
uci set $conf.txtinfo="LoadPlugin"
uci set $conf.txtinfo.library="olsrd_txtinfo.so.0.1"
uci set $conf.txtinfo.accept="0::"
if qmp_uci_test qmp.interfaces.mesh_devices && qmp_uci_test qmp.networks.mesh_protocol_vids && qmp_uci_test qmp.networks.mesh_vid_offset; then
local counter=1
local interface_list=""
for dev in $(uci get qmp.interfaces.mesh_devices); do
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')"
echo "qmp_configure_olsr6 dev=$dev protocol_vid=$protocol_vid protocol_name=$protocol_name"
if [ "$protocol_name" = "olsr6" ] ; then
local vid_suffix="$(echo $protocol_vid | awk -F':' '{print $2}')"
local vid_offset="$(uci get qmp.networks.mesh_vid_offset)"
local interface="olsr6_${counter}"
local ifname="$dev.$(( $vid_offset + $vid_suffix ))"
echo "adding ifname=$ifname interface=$interface"
interface_list="$interface_list $interface"
fi
done
done
uci set $conf.interface="Interface"
uci add_list $conf.interface.interface="$interface_list"
fi
uci commit $conf
# /etc/init.d/$conf restart
}
qmp_set_hosts() {
echo "Configuring /etc/hosts file with qmpadmin entry"
......
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