Developing lightweight computation at the DSG edge

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

Merge branch 'master' into b6m to fixing unclosed sms files of bmx6.

parents 974a5244 69eff133
......@@ -112,6 +112,7 @@ function action_neighbours()
local desc = nil
local orig = nil
local name = ""
local ipv4 = ""
for _,o in ipairs(orig_list) do
orig = bmx6json.get("originators/"..o.name) or {}
......@@ -123,7 +124,15 @@ function action_neighbours()
name = o.name
end
table.insert(originators,{name=name,orig=orig,desc=desc})
for _,h in ipairs(desc.DESC_ADV.extensions[2].HNA6_EXTENSION) do
if h ~= nil and string.find(h.address,"::ffff:") then
ipv4=string.gsub(h.address,"::ffff:","")
end
end
table.insert(originators,{name=name,ipv4=ipv4,orig=orig,desc=desc})
end
luci.template.render("bmx6/neighbours", {originators=originators})
......
......@@ -40,7 +40,8 @@
<table>
<tr>
<th scope="col">Name</th>
<th scope="col">IP</th>
<th scope="col">IPv4</th>
<th scope="col">IPv6</th>
<th scope="col">Via Dev</th>
<th scope="col">Via IP</th>
<th scope="col">Routes</th>
......@@ -50,10 +51,10 @@
</tr>
<% for i,o in ipairs(originators) do %>
<% if #o.orig.viaIp > 2 then %>
<tr>
<td><%=o.name%></td>
<td><%=o.orig.primaryIp%></td>
<td><a href="http://<%=o.ipv4%>"><%=o.ipv4%></a></td>
<td><a href="http://[<%=o.orig.primaryIp%>]"><%=o.orig.primaryIp%></a></td>
<td><%=o.orig.viaDev%></td>
<td><%=o.orig.viaIp%></td>
<td><%=o.orig.routes%></td>
......@@ -61,9 +62,26 @@
<td><%=o.orig.lastDesc%></td>
<td><%=o.orig.lastRef%></td>
</tr>
<%end%>
<%end%>
</table>
<table>
<tr>
<th scope="col">Node</th>
<th scope="col">Announced networks</th>
</tr>
<% for i,o in ipairs(originators) do %>
<tr>
<td><%=o.name%></td>
<td>
<% for j,h in ipairs(o.desc.DESC_ADV.extensions[2].HNA6_EXTENSION) do %>
<%=h.address%>&nbsp;&nbsp;&nbsp;&nbsp;
<% end %>
</td>
</tr>
<% end %>
</table>
<br />
<%+footer%>
......@@ -25,13 +25,13 @@ PKG_SOURCE_PROTO:=git
Public Sources:
PKG_SOURCE_URL:=git://git.bmx6.net/bmx6.git
PKG_REV:=873eed6c331476bbdcbe2e7766907aa2a54371f3
PKG_REV:=2d3f49dd318d05b46ccd12f8990867334ddd5373
Private Sources:
#PKG_SOURCE_URL:=file:///usr/src/bmx6/bmx6-private.git
#PKG_REV:=873eed6c331476bbdcbe2e7766907aa2a54371f3
PKG_VERSION:=r2011101906
PKG_VERSION:=r2011111101
#PKG_RELEASE:=1
#PKG_INSTALL:=1 # this tries to install straight to /usr/sbin/bmx6
......
# gwck-qmp openwrt package
#
# Copyright (C) 2011 Simó Albert i Beltran
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Version 0.1.20111107.1.0
include $(TOPDIR)/rules.mk
PKG_NAME:=gwck-qmp
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://qmp.cat/gwck.git
PKG_REV:=9133f42ffc40d34e04a48c2a7fa07a024cff5b36
PKG_VERSION:=r2011110701
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
include $(INCLUDE_DIR)/package.mk
define Package/gwck-qmp
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=Check gateway and control bmx6 tunnels.
URL:=http://qmp.net/projects/gwck
MAINTAINER:=Simó Albert i Beltran <sim6@graciasensefils.net>
MENU:=1
DEPENDS:=+fping +bmx6-qmp
endef
define Package/gwck-qmp/description
gwck is a tool to check gateway connectivity and perform actions in consequence.
This package runs gwck to control bmx6 tunnels.
endef
define Build/Compile
endef
define Package/gwck-qmp/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/gwck $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/gwck $(1)/etc/gwck/module
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/gwck $(1)/usr/bin/gwck
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gwck/gwck_conf $(1)/etc/gwck/gwck_conf
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gwck/gwck_conf_qmp $(1)/etc/gwck/gwck_conf_qmp
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gwck/gwck_conf_qmp_ipv4 $(1)/etc/gwck/gwck_conf_qmp_ipv4
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gwck/gwck_conf_qmp_ipv6 $(1)/etc/gwck/gwck_conf_qmp_ipv6
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gwck/module/specific_routes $(1)/etc/gwck/module/specific_routes
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gwck/module/bmx6 $(1)/etc/gwck/module/bmx6
endef
define Package/gwck-qmp/conffiles
/etc/gwck/gwck_conf
/etc/gwck/gwck_conf_qmp
/etc/gwck/gwck_conf_qmp_ipv4
/etc/gwck/gwck_conf_qmp_ipv6
endef
$(eval $(call BuildPackage,gwck-qmp))
#!/bin/sh /etc/rc.common
#
# gwck qmp init script
#
# Copyright (C) 2011 Simó Albert i Beltran
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Version 0.1.20111107.0
START=99
BIN=/usr/bin/gwck
start()
{
$BIN -l -f /etc/gwck/gwck_conf_qmp > /dev/null 2> /dev/null &
}
stop()
{
$BIN -k
}
restart()
{
stop
start
}
......@@ -59,6 +59,7 @@ define Package/qmp-small-node
+kmod-madwifi \
+kmod-ath9k \
+kmod-ath5k \
+gwck-qmp \
+b6m-spread
endef
......@@ -85,6 +86,8 @@ 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
chmod 755 $(1)/etc/init.d/qmp_autoconf
endef
......
......@@ -606,6 +606,7 @@ qmp_configure_bmx6() {
uci set $conf.tun6Out="tunOut"
uci set $conf.tun6Out.tunOut="tun6Out"
uci set $conf.tun6Out.network="$(uci get qmp.tunnels.search_ipv6_tunnel)"
uci set $conf.tun6Out.mtu=1400
fi
......@@ -613,6 +614,7 @@ qmp_configure_bmx6() {
uci set $conf.tun4Out="tunOut"
uci set $conf.tun4Out.tunOut="tun4Out"
uci set $conf.tun4Out.network="$(uci get qmp.tunnels.search_ipv4_tunnel)"
uci set $conf.tun4Out.mtu=1400
elif qmp_uci_test qmp.tunnels.offer_ipv4_tunnel ; then
uci set $conf.tunInRemote="tunInRemote"
......
#!/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
......@@ -30,6 +30,7 @@ function print_help()
print("Possible questions:")
print(" modes: supported modes by the wireless card")
print(" channels: supported channels and supported HT40 type (+/-) ")
print(" ipv4: print all ipv4 from this computer (excluding localhost)")
print("")
end
......@@ -62,22 +63,30 @@ function print_txpower()
print(v)
end
end
function print_ipv4()
local ipv4 = qmp.get_ipv4()
for _,v in pairs(ipv4) do
print(v)
end
end
if #arg ~= 2 then
if #arg ~= 1 then
print_help()
os.exit(1)
end
local question = arg[1]
dev = arg[2]
dev = arg[2]
if question == "modes" then
print_modes()
elseif question == "channels" then
print_channels()
elseif question == "txpower" then
print_txpower()
elseif question == "ipv4" then
print_ipv4()
else
print_help()
end
......
......@@ -21,6 +21,8 @@
--]]
iwinfo = require "iwinfo"
util = require "luci.util"
sys = require "luci.sys"
qmpinfo = {}
......@@ -125,4 +127,26 @@ function qmpinfo.get_channels(dev)
return clist
end
function qmpinfo.get_ipv4()
local ipv4 = {}
local ipv4_raw = util.exec("ip -4 a | grep inet | awk '{print $2}' | awk -F/ '{print $1}' | grep -v 127.0.0.1")
for _,v in ipairs(util.split(ipv4_raw)) do
if #util.trim(v) > 1 then
table.insert(ipv4,util.trim(v))
end
end
return ipv4
end
function qmpinfo.get_hostname()
local hostname = util.exec("cat /proc/sys/kernel/hostname")
return hostname
end
function qmpinfo.get_uname()
local uname = util.exec("uname -a")
return uname
end
return qmpinfo
......@@ -3,6 +3,8 @@
cat /etc/qmp/qmp.banner >> /etc/banner
echo "Versio ratafia 1.0 (Sat Oct 29 2011) ---------------" >> /etc/banner
echo "Ratafia Recipe: http://en.wikipedia.org/wiki/Ratafia" >> /etc/banner
[ $BRANCH ] && [ $REV ] && echo "Version: http://qmp.cat/projects/qmp/repository/show?branch=$BRANCH&rev=$REV" >> /etc/banner
echo "----------------------------------------------------" >> /etc/banner
......@@ -5,4 +5,5 @@ IPLOCAL="\$(uci get qmp.networks.lan_address)"
/usr/sbin/iptables -t nat -N captive-portal
/usr/sbin/iptables -t nat -I PREROUTING -i br-lan ! -d \${IPLOCAL} -j captive-portal
/usr/sbin/iptables -t nat -A captive-portal -p tcp --destination-port 80 -j DNAT --to-destination \${IPLOCAL}:8888
/usr/sbin/iptables -t nat -A POSTROUTING -j MASQUERADE
QMP
......@@ -29,17 +29,23 @@ function index()
root.index = true
-- Main window with auth enabled
overview = entry({"qmp"}, template("qmp/overview"), "qMp", 1)
overview = entry({"qmp"}, call("action_status"), "qMp", 1)
overview.dependent = false
overview.sysauth = "root"
overview.sysauth_authenticator = "htmlauth"
-- Rest of entries
entry({"qmp","info"}, call("action_status"), "Info", 1).dependent=false
entry({"qmp","network"}, cbi("qmp/config"), "Network", 5).dependent=false
entry({"qmp","wireless"}, cbi("qmp/wireless"), "Wireless", 6).dependent=false
end
function action_status()
luci.http.prepare_content("text/plain")
luci.http.write("Quick Mesh Project [qMp]")
package.path = package.path .. ";/etc/qmp/?.lua"
local qmp = require "qmpinfo"
local ipv4 = qmp.get_ipv4()
local hostname = qmp.get_hostname()
local uname = qmp.get_uname()
luci.template.render("qmp/overview",{ipv4=ipv4,hostname=hostname,uname=uname})
end
......@@ -2,7 +2,7 @@
<div align="center">
<img src="/luci-static/resources/qmp/logo.png" width="180px" />
<img src="/luci-static/resources/qmp/logo.png" />
</div>
<h2>About qMp</h2>
......@@ -14,4 +14,22 @@
<br />
<p>Visit our web page for more information: <a href="http://qmp.cat" target="_blank">qmp.cat</a> </p>
<h2>About this device</h2>
<p>
<strong>Hostname:</strong> <%=hostname%>
</p>
<p>
<strong>System:</strong> <%=uname%>
</p>
<p>
<strong>IPv4 addresses</strong>
<ul>
<% for i,v in ipairs(ipv4) do %>
<li><%=v%></li>
<% end %>
</ul>
</p>
<%+footer%>
......@@ -31,10 +31,10 @@ Principalment amb dues finalitats:
Amb el suport de:
<table width=100%>
<tr>
<td><a href="http://{splashhost}{splashcontinue}http://qmp.cat" title="Quick Mesh Project"><img src="http://{splashhost}/qmp.png" /></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://www.domini.cat/" title="Punt CAT"><img src="http://{splashhost}/puntcat.png" /></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://graciasensefils.net/" title="GraciaSenseFils"><img src="http://{splashhost}/gsf.png" /></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://guifi.net/" title="Guifi.net"><img src="http://{splashhost}/guifinet.jpg" /></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://qmp.cat" title="Quick Mesh Project"><img src="http://{splashhost}/qmp.png" border="0"/></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://www.domini.cat/" title="Punt CAT"><img src="http://{splashhost}/puntcat.png" border="0"/></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://graciasensefils.net/" title="GraciaSenseFils"><img src="http://{splashhost}/gsf.png" border="0"/></a></td>
<td><a href="http://{splashhost}{splashcontinue}http://guifi.net/" title="Guifi.net"><img src="http://{splashhost}/guifinet.jpg" border="0"/></a></td>
</tr>
</table>
......
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