Developing lightweight computation at the DSG edge

Commit c02639db authored by Simó Albert i Beltran's avatar Simó Albert i Beltran
Browse files

Adapt to OpenWRT 12.09 Attitude Adjustment.

Conflicts:
	packages/qmp-system/files/etc/qmp/qmp_control.sh
parents 6a8c3a22 4c984d89
......@@ -32,12 +32,12 @@ Public Sources:
#PKG_SOURCE_URL:=git://git.bmx6.net/bmx6.git
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
PKG_REV:=6073f94f1c127926f290f3ab619d92cb39aea54c
PKG_REV:=7219010098ea67f8ea08a06a68e7a765b114ca16
Private Sources:
#PKG_SOURCE_URL:=file:///usr/src/bmx6/bmx6-private.git
PKG_VERSION:=r2012120204
PKG_VERSION:=r2013022001
PKG_RELEASE:=4
#PKG_INSTALL:=1 # this tries to install straight to /usr/sbin/bmx6
......
......@@ -18,6 +18,7 @@
# the file called "COPYING".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
......@@ -33,28 +34,25 @@ include $(INCLUDE_DIR)/package.mk
define Package/qmp-big-node
SECTION:=net
CATEGORY:=qMp
TITLE:=Required addons for big qmp mesh nodes (8MByte flash or more)
TITLE:=Addons for big qMp mesh node (8MByte flash or more)
URL:=http://qmp.cat
DEPENDS:= \
+qmp-small-node \
+qmp-tinyproxy \
+qmp-tinyproxy +tinymce \
+babeld \
+openvpn \
+openssl-util \
+tcptraceroute6 \
+openssl-util +luci-ssl \
+tcptraceroute6 \
+iperf +mtr +netcat \
+tcpdump \
+lsof \
+hostapd \
+wget +horst \
+bmon +bwm +ebtables +pv \
+b6m \
+qmp-quagga +qmp-quagga-bgpd +qmp-quagga-ospfd +qmp-quagga-zebra \
+bmx6-qmp-quagga \
+wide-dhcpv6-client +wide-dhcpv6-control +wide-dhcpv6-server \
+ndisc6 +rdisc6 +rdnssd \
+ipv6calc +iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath \
+cgi-bin-zero
+ipv6calc +iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath
endef
define Package/qmp-big-node/description
......
......@@ -4,6 +4,9 @@
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# Contributors:
# Simó Albert i Beltran
#
include $(TOPDIR)/rules.mk
......@@ -39,8 +42,8 @@ PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/qmp-quagga/Default
SECTION:=net
CATEGORY:=Network
SECTION:=qMp
CATEGORY:=qMp
SUBMENU:=Routing and Redirection
DEPENDS:=qmp-quagga
TITLE:=The Quagga Software Routing Suite
......@@ -50,7 +53,7 @@ endef
define Package/qmp-quagga
$(call Package/qmp-quagga/Default)
DEPENDS:=+librt
DEPENDS:=+qmp-quagga-vtysh +qmp-quagga-bgpd
MENU:=1
endef
......@@ -76,6 +79,7 @@ endef
define Package/qmp-quagga-libzebra
$(call Package/qmp-quagga/Default)
DEPENDS+=+librt
TITLE:=zebra library
endef
......
......@@ -18,6 +18,7 @@
# the file called "COPYING".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
......@@ -25,10 +26,10 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qmp-small-node
PKG_RELEASE:=8
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
QMP_CODENAME:=Ratafia
QMP_RELEASE:=1.0beta
QMP_RELEASE:=2.0beta
QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
include $(INCLUDE_DIR)/package.mk
......@@ -36,29 +37,18 @@ include $(INCLUDE_DIR)/package.mk
define Package/qmp-small-node
SECTION:=net
CATEGORY:=qMp
TITLE:=Required addons for small qmp mesh nodes ( 4MByte )
TITLE:=Required addons for small qMp mesh node
URL:=http://qmp.cat
DEPENDS:= \
+uhttpd +luci +luci-lib-nixio \
+luci-ssl +iwinfo \
+qmp-tiny-node \
+ahcpd \
+radvd \
+hostapd-mini +wpa-supplicant-mini \
+wireless-tools +iw +netperf \
+bmx6-qmp +bmx6-qmp-uci-config +bmx6-qmp-json +bmx6-qmp-sms +bmx6-luci \
+olsrd +olsrd-mod-txtinfo +olsrd-mod-httpinfo +olsrd-mod-watchdog +olsrd-mod-arprefresh \
+gwck-qmp +luci-theme-qmp \
+firewall \
+ip \
+6in4 +6to4 \
+ip6tables +ip6tables-utils \
+firewall +synctincvpn \
+kmod-ipip \
+kmod-ip6-tunnel +kmod-iptunnel6 \
+cgi-bin-zero \
+kmod-tun \
+kmod-dummy \
+gwck-qmp \
+b6m-spread \
+b6m +b6m-spread
endef
......@@ -67,11 +57,9 @@ define Package/qmp-small-node/description
endef
define Package/qmp-small-node/conffiles
/etc/config/qmp
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
......@@ -81,24 +69,6 @@ define Build/Compile
endef
define Package/qmp-small-node/install
$(CP) ./files/* $(1)/
$(CP) ./files/etc/config/qmp $(1)/etc/config/qmp.orig
$(SED) 's,$$$$BRANCH,$(BRANCH_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REV,$(REV_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$COD,$(QMP_CODENAME),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REL,$(QMP_RELEASE),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$DATE,$(QMP_BUILDDATE),g' $(1)/etc/uci-defaults/qmp_banner
chmod 755 $(1)/etc/init.d/qmp_autoconf
date +%Y%m%d > $(1)/etc/qmp/qmp.version
echo "QMP_ID=qMp" > $(1)/etc/qmp/qmp.release
echo "QMP_CODENAME=$(QMP_CODENAME)" >> $(1)/etc/qmp/qmp.release
echo "QMP_RELEASE=$(QMP_RELEASE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BRANCH=$(BRANCH_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_REVISION=$(REV_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BUILDDATE=$(QMP_BUILDDATE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_DESCRIPTION=\"qMp $(QMP_CODENAME) $(QMP_RELEASE), $(BRANCH_GIT) rev.$(REV_GIT)-$(QMP_BUILDDATE)\"" >> $(1)/etc/qmp/qmp.release
endef
$(eval $(call BuildPackage,qmp-small-node))
#!/bin/sh
# Temporal script to re-enable wifi after the boot
# this is to fix a temporaly issue when you are using non-standard wifi chanels
if [ $(cat /etc/rc.local | grep -c ^wifi) -lt 1 ]; then
sed -i -e "/^exit 0/d" /etc/rc.local
echo "wifi" >> /etc/rc.local
fi
# 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".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qmp-system
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
QMP_CODENAME:=Ratafia
QMP_RELEASE:=2.0beta
QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
include $(INCLUDE_DIR)/package.mk
define Package/qmp-system
TITLE:=Quick Mesh Project system files
SECTION:=net
CATEGORY:=qMp
URL:=http://qmp.cat
DEPENDS:=
endef
define Package/qmp-system/description
System files for qMp node
endef
define Package/qmp-system/conffiles
/etc/config/qmp
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/qmp-system/install
$(CP) ./files/* $(1)/
$(CP) ./files/etc/config/qmp $(1)/etc/config/qmp.orig
$(SED) 's,$$$$BRANCH,$(BRANCH_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REV,$(REV_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$COD,$(QMP_CODENAME),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REL,$(QMP_RELEASE),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$DATE,$(QMP_BUILDDATE),g' $(1)/etc/uci-defaults/qmp_banner
chmod 755 $(1)/etc/init.d/qmp_autoconf
date +%Y%m%d > $(1)/etc/qmp/qmp.version
echo "QMP_ID=qMp" > $(1)/etc/qmp/qmp.release
echo "QMP_CODENAME=$(QMP_CODENAME)" >> $(1)/etc/qmp/qmp.release
echo "QMP_RELEASE=$(QMP_RELEASE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BRANCH=$(BRANCH_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_REVISION=$(REV_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BUILDDATE=$(QMP_BUILDDATE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_DESCRIPTION=\"qMp $(QMP_CODENAME) $(QMP_RELEASE), $(BRANCH_GIT) rev.$(REV_GIT)-$(QMP_BUILDDATE)\"" >> $(1)/etc/qmp/qmp.release
endef
$(eval $(call BuildPackage,qmp-system))
......@@ -19,44 +19,54 @@
# the file called "COPYING".
START=99
STOP=99
SERVICE_DAEMONIZE=1
CONTROL_FILE="/qmp_configured"
QMP_DIR="/etc/qmp"
QMP_KEY="/tmp/qmp_key"
log() {
echo "$@" > /dev/console
echo "$@"
echo "$@" > /tmp/qmp_autoconf.log
}
configure() {
echo "Starting qmp configuration..."
echo "Starting qmp configuration..." > /dev/console
log Starting qmp configuration...
echo "[Configuring wireless]"
log Waiting 10 seconds to be sure all is configured
sleep 10
log [Configuring wireless]
#Generating default wifi configuration
iw reg set $(uci get qmp.wireless.country) || iw reg set 00
sleep 1
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
mv /etc/config/wireless /tmp/wireless.old
wifi detect | grep -v disabled > /etc/config/wireless
wifi
wifi detect | sed s/"disabled 1"/"country $country"/g > /etc/config/wireless
/etc/init.d/network reload
#To be sure channel is set...
iw reg set $country || iw reg set 00
#Configuring wifi using QMP
. $QMP_DIR/qmp_wireless.sh
qmp_configure_wifi_initial
qmp_configure_wifi
wifi
#Reloading network to avoid problems with next functions
/etc/init.d/network reload
#Configuring networking
echo "[Configuring networking]"
. $QMP_DIR/qmp_functions.sh
qmp_configure
#/etc/init.d/network restart
#sleep 3
#QMP_HOSTNAME=$(uci get system.@system[0].hostname)
#echo "Update hostname for: '$QMP_HOSTNAME'"
#echo "$QMP_HOSTNAME" > /proc/sys/kernel/hostname
#/etc/init.d/olsrd restart
#/etc/init.d/bmx6 restart
#ifup -a
#/etc/init.d/dnsmasq restart
touch "$CONTROL_FILE"
reboot
[ -f "$CONTROL_FILE" ] && reboot || log CRITICAL, cannot write file $CONTROL_FILE
}
#This function is executed in each boot
......@@ -70,22 +80,20 @@ startup() {
# Generate current qmp key
logread | md5sum | awk '{print $1}' > $QMP_KEY
# Hack to enable wifi when channel is not standar
wifi
}
start() {
startup
if [ ! -f "$CONTROL_FILE" ]; then
configure
else
echo "QMP configured. Remove $CONTROL_FILE to force reconfiguration"
log QMP configured. Remove $CONTROL_FILE to force reconfiguration
fi
startup
}
stop() {
echo "Nothing to do"
log Nothing to do
}
restart() {
......
......@@ -188,7 +188,7 @@ qmp_get_wifi_mac_devices() {
# Returns the device name that corresponds to the MAC address
# qmp_get_dev_from_mac 00:22:11:33:44:55
qmp_get_dev_from_mac() {
echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|br|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)"
echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)"
}
# Returns the mac address of the device
......@@ -199,6 +199,14 @@ qmp_get_mac_for_dev() {
echo "$mac"
}
# Returns the mac addres for specific device,, only wifi devs are allowed. Useful when eth and wlan have same MAC
# qmp_get_dev_from_wifi_mac 00:22:11:33:44:55
qmp_get_dev_from_wifi_mac() {
mac="$(ip link | grep -A1 -E ": (wifi|wlan|wl).: " | grep -i $1 -B1 | cut -d' ' -f2 | tr -d "\n",:)"
[ -z "$mac" ] && mac="00:00:00:00:00:00"
echo "$mac"
}
#########################
# Other kind of commands
#########################
......
......@@ -18,6 +18,7 @@
# the file called "COPYING".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
......@@ -48,7 +49,7 @@ disable_default_gw() {
configure_wifi() {
qmp_configure_wifi_initial
qmp_configure_wifi
wifi
/etc/init.d/network reload
}
apply_netserver() {
......@@ -56,19 +57,15 @@ apply_netserver() {
}
configure_network() {
sleep 1
qmp_configure
/etc/init.d/network restart
#qmp_publish_lan
[ -f "/etc/init.d/olsrd" ] && /etc/init.d/olsrd restart
bmx6 -c --configReload || /etc/init.d/bmx6 restart
/etc/init.d/network reload
/etc/init.d/dnsmasq restart
apply_netserver
wifi
}
configure_system() {
sleep 1
qmp_configure_system
/etc/init.d/uhttpd restart
}
......
......@@ -24,13 +24,14 @@
#
QMP_PATH="/etc/qmp"
SOURCE_NETWORK=1
SOURCE_FUNCTIONS=1
#######################
# Importing files
######################
. $QMP_PATH/qmp_common.sh
[ -z "$SOURCE_GW" ] && . $QMP_PATH/qmp_gw.sh
[ -z "$SOURCE_NET" ] && . $QMP_PATH/qmp_network.sh
# requires ip ipv6calc awk sed grep
......@@ -54,6 +55,72 @@ qmp_get_primary_device() {
echo "$primary_mesh_device"
}
qmp_check_device() {
ip link show $1 1> /dev/null 2>/dev/null
return $?
}
qmp_set_vlan() {
local viface="$1" # lan/wan/meshX
local vid=$2 # 11/12
[ -z "$viface" ] || [ -z "$vid" ] && return
uci set network.${viface}_$vid=interface
uci set network.${viface}_$vid.proto=none
uci set network.${viface}_$vid.ifname=@$viface.$vid
uci commit network
}
qmp_get_virtual_iface() {
local device="$1"
local viface=""
if [ "$device" == "eth1" ] && qmp_is_routerstationpro ; then
echo "rsp_e1"
return
fi
# is lan?
if [ "$device" == "br-lan" ]; then
viface="lan"
echo $viface
return
fi
for l in $(qmp_get_devices lan); do
if [ "$l" == "$device" ]; then
viface="lan"
echo $viface
return
fi
done
[ -n "$viface" ] && { echo $viface; return; }
# id is the first and char and the numbers of the device [e]th[0] [w]lan[1]
local id_num=$(echo $device | tr -d "[A-z]")
local id_char=$(echo $device | cut -c 1)
# is wan
for w in $(qmp_get_devices wan); do
if [ "$w" == "$device" ]; then
viface="wan_${id_char}${id_num}"
echo $viface
return
fi
done
# is mesh
for w in $(qmp_get_devices mesh); do
if [ "$w" == "$device" ]; then
viface="mesh_${id_char}${id_num}"
break
fi
done
echo "$viface"
}
# arg1=<mesh|lan|wan>, returns the devices which have to be configured in such mode
qmp_get_devices() {
local devices=""
......@@ -101,6 +168,11 @@ qmp_get_rescue_ip() {
local rprefix=$(uci get qmp.networks.rescue_prefix24 2>/dev/null)
[ -z "$rprefix" ] && return 0
# if device is virtual, get the ifname
if qmp_uci_test network.$device.ifname; then
device="$(uci get network.$device.ifname | tr -d @)"
fi
local mac=$(ip addr show dev $device | grep -m 1 "link/ether" | awk '{print $2}')
[ -z "$mac" ] && return 2
......@@ -115,35 +187,42 @@ qmp_attach_device_to_interface() {
local device=$1
local conf=$2
local interface=$3
local intype="$(uci -qX get network.$interface.type)"
echo "Attaching device $device to interface $interface"
local wifi_config="$(uci -qX show wireless | sed -n -e "s/wireless\.\([^\.]\+\)\.device=$device/\1/p")"
if [ -n "$wifi_config" -a "wifi-iface" = "$(uci -q get wireless.$wifi_config)" ] ; then
uci set wireless.$wifi_config.network="$interface"
uci commit wireless
else
if [[ "$device" == "eth1" ]] && qmp_is_routerstationpro
then
device="eth1.1"
if [ "$intype" == "bridge" ]; then
uci add_list $conf.$interface.ifname="$device"
else
uci set $conf.$interface.ifname="$device"
fi
uci add_list $conf.$interface.ifname="$device"
fi
}
qmp_configure_rescue_ip() {
local device=$1
[ -z "$device" ] && return 1
local rip="$(qmp_get_rescue_ip $device)"
[ -z "$rip" ] && { echo "Cannot get rescue IP for device $device"; return 1; }
local viface="${2:-$(qmp_get_virtual_iface $device)}"
echo "Rescue IP for device $device is $rip"
echo "Rescue IP for device $device/$viface is $rip"
local conf="network"
uci set $conf.${device}_rescue="interface"
qmp_attach_device_to_interface $device $conf ${device}_rescue
uci set $conf.${device}_rescue.proto="static"
uci set $conf.${device}_rescue.ipaddr="$rip"
uci set $conf.${device}_rescue.netmask="255.255.255.248"
uci set $conf.${viface}="interface"
#qmp_attach_viface_to_interface $viface $conf ${viface}
uci set $conf.${viface}.proto="static"
uci set $conf.${viface}.ipaddr="$rip"
uci set $conf.${viface}.netmask="255.255.255.248"
uci commit $conf
}
......@@ -173,6 +252,12 @@ qmp_configure_routerstationpro_switch() {
uci set network.mesh_ports_vid$vid.device="eth1"
uci set network.mesh_ports_vid$vid.ports="0t 2t 3t"
done
local viface="$(qmp_get_virtual_iface eth1)"
uci set network.$viface="interface"
uci set network.$viface.proto="static"
uci set network.$viface.ifname="eth1"
uci commit network
}
qmp_get_ip6_slow() {
......@@ -359,13 +444,6 @@ qmp_get_ip6_fast() {
# echo "qmp_get_ip6_fast: return addr_prefix=$addr_prefix addr_long=$addr_long addr=$fake_long mask=$mask" 1>&2
}