Developing lightweight computation at the DSG edge

Commit 801fb650 authored by Victor Oncins's avatar Victor Oncins
Browse files

=Implemented non-overlapping channel mechanism, for AP interfaces

parent 2ad3e8e2
......@@ -131,6 +131,14 @@ qmp_uci_import() {
return $?
}
qmp_uci_test() {
option=$1
if uci get $option > /dev/null 2>&1 ; then
return 0
fi
return 1
}
##################################
# Log and errors related commnads
##################################
......@@ -182,3 +190,20 @@ qmp_tac() {
$@ | awk '{a[NR]=$0} END {for(i=NR;i>0;i--)print a[i]}'
}
qmp_get_mac_for_dev() {
dev=$1
ip addr show dev $dev | grep -m 1 "link/ether" | awk '{print $2}'
}
qmp_get_dec_node_id() {
PRIMARY_MESH_DEVICE="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
LSB_PRIM_MAC="$( qmp_get_mac_for_dev $PRIMARY_MESH_DEVICE | awk -F':' '{print $6}' )"
if qmp_uci_test qmp.node.community_node_id; then
COMMUNITY_NODE_ID="$(uci get qmp.node.community_node_id)"
elif ! [ -z "$PRIMARY_MESH_DEVICE" ] ; then
COMMUNITY_NODE_ID=$LSB_PRIM_MAC
fi
echo $(printf %d 0x$COMMUNITY_NODE_ID)
}
......@@ -19,29 +19,18 @@
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
QMP_PATH="/etc/qmp"
SOURCE_NETWORK=1
#######################
# Importing files
######################
. $QMP_PATH/qmp_common.sh
[ -z "$SOURCE_GW" ] && . $QMP_PATH/qmp_gw.sh
# requires ip ipv6calc awk sed grep
qmp_uci_test() {
option=$1
if uci get $option > /dev/null 2>&1 ; then
return 0
fi
return 1
}
qmp_get_mac_for_dev() {
local dev=$1
ip addr show dev $dev | grep -m 1 "link/ether" | awk '{print $2}'
}
qmp_get_llocal_for_dev() {
local dev=$1
ip a show dev $dev | grep inet6 | awk '{print $2}'
......@@ -452,7 +441,7 @@ qmp_configure_network() {
OFFSET=$UCI_OFFSET
fi
START=$(( $(printf %d 0x$LSB_PRIM_MAC) * $NUM_GRP + $OFFSET ))
START=$(( $(printf %d 0x$community_node_id) * $NUM_GRP + $OFFSET ))
LIMIT=$(( $NUM_GRP - $OFFSET - 2))
uci set dhcp.lan.start=$START
......
#!/bin/sh
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
##############################
# Global variables definition
##############################
QMP_PATH="/etc/qmp"
OWRT_WIRELESS_CONFIG="/etc/config/wireless"
TEMPLATE_BASE="$QMP_PATH/templates/wireless" # followed by .driver.mode (wireless.mac80211.adhoc)
WIFI_DEFAULT_CONFIG="$QMP_PATH/templates/wireless.default.config"
TMP="/tmp"
QMPINFO="/etc/qmp/qmpinfo"
#######################
# Importing files
######################
SOURCE_WIRELESS=1
. $QMP_PATH/qmp_common.sh
index=2
$QMPINFO channels wlan1
channel_info="$($QMPINFO channels wlan1 | awk NR==$(qmp_get_dec_node_id)%10+$index+1)"
echo $channel_info
......@@ -267,7 +267,7 @@ qmp_wifi_get_default() {
# QMPINFO returns a list of avaiable channels in this format: 130 ht40+ adhoc
[ "$mode" == "adhoc" ] || [ -z "$mode" ] && channel_info="$(qmp_tac $QMPINFO channels $device | grep adhoc | awk NR==$index+1)"
[ "$mode" == "ap" ] && channel_info="$($QMPINFO channels $device | awk NR==$index+1)"
[ "$mode" == "ap" ] && channel_info="$($QMPINFO channels $device | awk NR==$(qmp_get_dec_node_id)%10+$index+1)"
# if there is some problem, channel 6 is used
if [ -z "$channel_info" ]; 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