From: Saverio Proto
Date: Mon, 1 Jul 2013 13:36:26 +0000 (+0200)
Subject: ndppd: importing ndppd package in openwrt-routing feed
X-Git-Url: http://git.openwrt.org/?p=feed%2Frouting.git;a=commitdiff_plain;h=ae1617f296c64b92d8fee75504efbdcc08c1b003;hp=1fb0f3bcfeaafbd1631e769837fb26e3c86669cf
ndppd: importing ndppd package in openwrt-routing feed
---
diff --git a/README b/README
new file mode 100644
index 0000000..72b7fcc
--- /dev/null
+++ b/README
@@ -0,0 +1,18 @@
+This is an OpenWrt package feed containing community maintained routing packages.
+
+To use these packages, add the following line to the feeds.conf
+in the OpenWrt buildroot:
+
+ src-git routing git://github.com/openwrt-routing/packages.git
+
+Update the feed:
+
+ ./scripts/feeds update routing
+
+Activate the package:
+
+ ./scripts/feeds install -a -p routing
+
+The routing packages should now appear in menuconfig.
+
+
diff --git a/batman-adv/Config.in b/batman-adv/Config.in
new file mode 100644
index 0000000..1330525
--- /dev/null
+++ b/batman-adv/Config.in
@@ -0,0 +1,29 @@
+
+config KMOD_BATMAN_ADV_DEBUG_LOG
+ bool "enable verbose debug logging"
+ depends on PACKAGE_kmod-batman-adv
+ default n
+
+config KMOD_BATMAN_ADV_BLA
+ bool "enable bridge loop avoidance"
+ depends on PACKAGE_kmod-batman-adv
+ default y
+
+config KMOD_BATMAN_ADV_DAT
+ bool "enable distributed arp table"
+ depends on PACKAGE_kmod-batman-adv
+ default y
+
+config KMOD_BATMAN_ADV_NC
+ bool "enable network coding [requires promisc mode support]"
+ depends on PACKAGE_kmod-batman-adv
+ default n
+
+config KMOD_BATMAN_ADV_BATCTL
+ bool "enable batctl"
+ depends on PACKAGE_kmod-batman-adv
+ default y
+ help
+ batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
+ It is an easier method for configuring batman-adv and
+ provides some additional tools for debugging as well.
diff --git a/batman-adv/Makefile b/batman-adv/Makefile
new file mode 100644
index 0000000..1e77051
--- /dev/null
+++ b/batman-adv/Makefile
@@ -0,0 +1,122 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: Makefile 5624 2006-11-23 00:29:07Z nbd $
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=batman-adv
+
+PKG_VERSION:=2013.2.0
+BATCTL_VERSION:=2013.2.0
+PKG_RELEASE:=3
+PKG_MD5SUM:=9ec18300b96df22f0ed21c9f51e4ccef
+BATCTL_MD5SUM:=712f86cdd0f9076503fc48acf37e109e
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_BATCTL_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/batctl-$(BATCTL_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define KernelPackage/batman-adv
+ URL:=http://www.open-mesh.org/
+ MAINTAINER:=Marek Lindner
+ SUBMENU:=Network Support
+ DEPENDS:=+kmod-lib-crc16 +kmod-crypto-core +kmod-crypto-crc32c +kmod-lib-crc32c +libc
+ TITLE:=B.A.T.M.A.N. Adv
+ FILES:=$(PKG_BUILD_DIR)/batman-adv.$(LINUX_KMOD_SUFFIX)
+ AUTOLOAD:=$(call AutoLoad,50,batman-adv)
+endef
+
+define KernelPackage/batman-adv/description
+B.A.T.M.A.N. advanced is a kernel module which allows to
+build layer 2 mesh networks. This package contains the
+version $(PKG_VERSION) of the kernel module plus its user space
+configuration & managerment tool batctl.
+endef
+
+define KernelPackage/batman-adv/config
+ source "$(SOURCE)/Config.in"
+endef
+
+MAKE_BATMAN_ADV_ARGS += \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ KERNELPATH="$(LINUX_DIR)" \
+ ARCH="$(LINUX_KARCH)" \
+ PATH="$(TARGET_PATH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ PWD="$(PKG_BUILD_DIR)" \
+ LINUX_VERSION="$(LINUX_VERSION)" \
+ CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),y,n) \
+ CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_KMOD_BATMAN_ADV_BLA),y,n) \
+ CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_KMOD_BATMAN_ADV_DAT),y,n) \
+ CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_KMOD_BATMAN_ADV_NC),y,n) \
+ REVISION="" all
+
+MAKE_BATCTL_ARGS += \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ CCFLAGS="$(TARGET_CFLAGS)" \
+ OFLAGS="$(TARGET_CFLAGS)" \
+ REVISION="" \
+ CC="$(TARGET_CC)" \
+ NODEBUG=1 \
+ UNAME="Linux" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ STRIP="/bin/true" \
+ batctl install
+
+ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
+define Download/batctl
+ FILE:=batctl-$(BATCTL_VERSION).tar.gz
+ URL:=$(PKG_SOURCE_URL)
+ MD5SUM:=$(BATCTL_MD5SUM)
+endef
+$(eval $(call Download,batctl))
+
+BATCTL_EXTRACT = tar xzf "$(DL_DIR)/batctl-$(BATCTL_VERSION).tar.gz" -C "$(BUILD_DIR)/$(PKG_NAME)"
+BATCTL_PATCH = $(call Build/DoPatch,"$(PKG_BATCTL_BUILD_DIR)","$(PATCH_DIR)","*batctl*")
+BATCTL_BUILD = $(MAKE) -C $(PKG_BATCTL_BUILD_DIR) $(MAKE_BATCTL_ARGS)
+BATCTL_INSTALL = $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/sbin/batctl $(1)/usr/sbin/
+endif
+
+KPATCH ?= $(PATCH)
+define Build/DoPatch
+ @if [ -d "$(2)" ]; then \
+ if [ "$$$$(ls $(2) | grep -Ec $(3))" -gt 0 ]; then \
+ $(KPATCH) "$(1)" "$(2)" "$(3)"; \
+ fi; \
+ fi
+endef
+
+define Build/Patch
+ $(call Build/DoPatch,"$(PKG_BUILD_DIR)","$(PATCH_DIR)","*batman*")
+ $(BATCTL_EXTRACT)
+ $(BATCTL_PATCH)
+endef
+
+define Build/Compile
+ $(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATMAN_ADV_ARGS)
+ $(BATCTL_BUILD)
+endef
+
+define Build/Clean
+ rm -rf $(BUILD_DIR)/$(PKG_NAME)/
+endef
+
+define KernelPackage/batman-adv/install
+ $(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/net $(1)/etc/hotplug.d/iface $(1)/lib/batman-adv $(1)/usr/sbin $(1)/lib/netifd/proto
+ $(INSTALL_DATA) ./files/etc/config/batman-adv $(1)/etc/config
+ $(INSTALL_DATA) ./files/lib/batman-adv/config.sh $(1)/lib/batman-adv
+ $(INSTALL_BIN) ./files/etc/hotplug.d/net/99-batman-adv $(1)/etc/hotplug.d/net
+ $(INSTALL_BIN) ./files/lib/netifd/proto/batadv.sh $(1)/lib/netifd/proto
+ $(BATCTL_INSTALL)
+endef
+
+$(eval $(call KernelPackage,batman-adv))
diff --git a/batman-adv/files/etc/config/batman-adv b/batman-adv/files/etc/config/batman-adv
new file mode 100644
index 0000000..79d660d
--- /dev/null
+++ b/batman-adv/files/etc/config/batman-adv
@@ -0,0 +1,20 @@
+
+config 'mesh' 'bat0'
+ option 'aggregated_ogms'
+ option 'ap_isolation'
+ option 'bonding'
+ option 'fragmentation'
+ option 'gw_bandwidth'
+ option 'gw_mode'
+ option 'gw_sel_class'
+ option 'log_level'
+ option 'orig_interval'
+ option 'vis_mode'
+ option 'bridge_loop_avoidance'
+ option 'distributed_arp_table'
+ option 'network_coding'
+ option 'hop_penalty'
+
+# yet another batX instance
+# config 'mesh' 'bat5'
+# option 'interfaces' 'second_mesh'
diff --git a/batman-adv/files/etc/hotplug.d/net/99-batman-adv b/batman-adv/files/etc/hotplug.d/net/99-batman-adv
new file mode 100644
index 0000000..f0c391f
--- /dev/null
+++ b/batman-adv/files/etc/hotplug.d/net/99-batman-adv
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. /lib/batman-adv/config.sh
+
+bat_load_module
+config_load batman-adv
+
+case "$ACTION" in
+ add)
+ [ -d /sys/class/net/$INTERFACE/mesh/ ] && bat_config "$INTERFACE"
+ ;;
+esac
diff --git a/batman-adv/files/lib/batman-adv/config.sh b/batman-adv/files/lib/batman-adv/config.sh
new file mode 100644
index 0000000..471c1f2
--- /dev/null
+++ b/batman-adv/files/lib/batman-adv/config.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+bat_load_module()
+{
+ [ -d "/sys/module/batman_adv/" ] && return
+
+ . /lib/functions.sh
+ load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv*
+}
+
+bat_config()
+{
+ local mesh="$1"
+ local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation
+ local gw_bandwidth gw_mode gw_sel_class hop_penalty network_coding log_level orig_interval vis_mode
+
+ config_get aggregated_ogms "$mesh" aggregated_ogms
+ config_get ap_isolation "$mesh" ap_isolation
+ config_get bonding "$mesh" bonding
+ config_get bridge_loop_avoidance "$mesh" bridge_loop_avoidance
+ config_get distributed_arp_table "$mesh" distributed_arp_table
+ config_get fragmentation "$mesh" fragmentation
+ config_get gw_bandwidth "$mesh" gw_bandwidth
+ config_get gw_mode "$mesh" gw_mode
+ config_get gw_sel_class "$mesh" gw_sel_class
+ config_get hop_penalty "$mesh" hop_penalty
+ config_get network_coding "$mesh" network_coding
+ config_get log_level "$mesh" log_level
+ config_get orig_interval "$mesh" orig_interval
+ config_get vis_mode "$mesh" vis_mode
+
+ [ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1
+
+ [ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms
+ [ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation
+ [ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding
+ [ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$mesh/mesh/bridge_loop_avoidance 2>&-
+ [ -n "$distributed_arp_table" ] && echo $distributed_arp_table > /sys/class/net/$mesh/mesh/distributed_arp_table 2>&-
+ [ -n "$fragmentation" ] && echo $fragmentation > /sys/class/net/$mesh/mesh/fragmentation
+ [ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$mesh/mesh/gw_bandwidth
+ [ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$mesh/mesh/gw_mode
+ [ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$mesh/mesh/gw_sel_class
+ [ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
+ [ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$mesh/mesh/network_coding 2>&-
+ [ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&-
+ [ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval
+ [ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode
+}
diff --git a/batman-adv/files/lib/netifd/proto/batadv.sh b/batman-adv/files/lib/netifd/proto/batadv.sh
new file mode 100644
index 0000000..632a209
--- /dev/null
+++ b/batman-adv/files/lib/netifd/proto/batadv.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_batadv_init_config() {
+ proto_config_add_string "mesh"
+}
+
+proto_batadv_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local mesh
+ json_get_vars mesh
+
+ echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
+ proto_init_update "$iface" 1
+ proto_send_update "$config"
+}
+
+proto_batadv_teardown() {
+ local config="$1"
+ local iface="$2"
+
+ echo "none" > "/sys/class/net/$iface/batman_adv/mesh_iface" || true
+}
+
+add_protocol batadv
diff --git a/batman-adv/patches/0001-batman-adv-use-the-proper-header-len-when-checking-t.patch b/batman-adv/patches/0001-batman-adv-use-the-proper-header-len-when-checking-t.patch
new file mode 100644
index 0000000..525dbac
--- /dev/null
+++ b/batman-adv/patches/0001-batman-adv-use-the-proper-header-len-when-checking-t.patch
@@ -0,0 +1,74 @@
+From 9b96ecbae7295269aaa0320667f646870de65661 Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli
+Date: Wed, 3 Apr 2013 10:14:20 +0200
+Subject: [PATCH 01/10] batman-adv: use the proper header len when checking
+ the TTVN
+
+Unicast packet might be of type either UNICAST or
+UNICAST4ADDR.
+In the two cases the header size is different, but the
+mechanism checking the TTVN field was assuming it to be
+always of the same type (UNICAST), so failing to access the
+inner Ethernet header in case of UNICAST4ADDR.
+
+Fix this by passing the real header length as argument.
+
+Signed-off-by: Antonio Quartulli
+Signed-off-by: Marek Lindner
+---
+ routing.c | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/routing.c b/routing.c
+index 2f1f889..b27a4d7 100644
+--- a/routing.c
++++ b/routing.c
+@@ -939,7 +939,7 @@ out:
+ }
+
+ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
+- struct sk_buff *skb) {
++ struct sk_buff *skb, int hdr_len) {
+ uint8_t curr_ttvn, old_ttvn;
+ struct batadv_orig_node *orig_node;
+ struct ethhdr *ethhdr;
+@@ -948,7 +948,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
+ int is_old_ttvn;
+
+ /* check if there is enough data before accessing it */
+- if (pskb_may_pull(skb, sizeof(*unicast_packet) + ETH_HLEN) < 0)
++ if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0)
+ return 0;
+
+ /* create a copy of the skb (in case of for re-routing) to modify it. */
+@@ -956,7 +956,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
+ return 0;
+
+ unicast_packet = (struct batadv_unicast_packet *)skb->data;
+- ethhdr = (struct ethhdr *)(skb->data + sizeof(*unicast_packet));
++ ethhdr = (struct ethhdr *)(skb->data + hdr_len);
+
+ /* check if the destination client was served by this node and it is now
+ * roaming. In this case, it means that the node has got a ROAM_ADV
+@@ -1072,8 +1072,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
+
+ if (check < 0)
+ return NET_RX_DROP;
+-
+- if (!batadv_check_unicast_ttvn(bat_priv, skb))
++ if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
+ return NET_RX_DROP;
+
+ /* packet for me */
+@@ -1117,7 +1116,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
+ if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0)
+ return NET_RX_DROP;
+
+- if (!batadv_check_unicast_ttvn(bat_priv, skb))
++ if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
+ return NET_RX_DROP;
+
+ unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0002-batman-adv-vlan-add-protocol-argument-to-packet-tagging-fun.patch b/batman-adv/patches/0002-batman-adv-vlan-add-protocol-argument-to-packet-tagging-fun.patch
new file mode 100644
index 0000000..608bd43
--- /dev/null
+++ b/batman-adv/patches/0002-batman-adv-vlan-add-protocol-argument-to-packet-tagging-fun.patch
@@ -0,0 +1,69 @@
+From 82d1a8ebf19a1b9841ee44ce7b2448114be3e772 Mon Sep 17 00:00:00 2001
+From: Patrick McHardy
+Date: Wed, 24 Apr 2013 17:42:56 +0200
+Subject: [PATCH 02/10] net: vlan: add protocol argument to packet tagging
+ functions
+
+Add a protocol argument to the VLAN packet tagging functions. In case of HW
+tagging, we need that protocol available in the ndo_start_xmit functions,
+so it is stored in a new field in the skb. The new field fits into a hole
+(on 64 bit) and doesn't increase the sks's size.
+
+Signed-off-by: Patrick McHardy
+Signed-off-by: David S. Miller
+[siwu@hrz.tu-chemnitz.de: added compat code]
+Signed-off-by: Simon Wunderlich
+Signed-off-by: Marek Lindner
+---
+ bridge_loop_avoidance.c | 2 +-
+ compat.h | 16 +++++++++++++++-
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
+index 6a4f728..379061c 100644
+--- a/bridge_loop_avoidance.c
++++ b/bridge_loop_avoidance.c
+@@ -341,7 +341,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
+ }
+
+ if (vid != -1)
+- skb = vlan_insert_tag(skb, vid);
++ skb = vlan_insert_tag(skb, htons(ETH_P_8021Q), vid);
+
+ skb_reset_mac_header(skb);
+ skb->protocol = eth_type_trans(skb, soft_iface);
+diff --git a/compat.h b/compat.h
+index 0663df5..c1dadac 100644
+--- a/compat.h
++++ b/compat.h
+@@ -170,7 +170,7 @@ static const struct { \
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
+
+ #define kfree_rcu(ptr, rcu_head) call_rcu(&ptr->rcu_head, batadv_free_rcu_##ptr)
+-#define vlan_insert_tag(skb, vid) __vlan_put_tag(skb, vid)
++#define vlan_insert_tag(skb, proto, vid) __vlan_put_tag(skb, vid)
+
+ void batadv_free_rcu_gw_node(struct rcu_head *rcu);
+ void batadv_free_rcu_neigh_node(struct rcu_head *rcu);
+@@ -278,4 +278,18 @@ static int __batadv_interface_set_mac_addr(x, y)
+
+ #endif /* < KERNEL_VERSION(3, 9, 0) */
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
++
++#ifndef vlan_insert_tag
++
++/* include this header early to let the following define
++ * not mess up the original function prototype.
++ */
++#include
++#define vlan_insert_tag(skb, proto, vid) vlan_insert_tag(skb, vid)
++
++#endif /* vlan_insert_tag */
++
++#endif /* < KERNEL_VERSION(3, 10, 0) */
++
+ #endif /* _NET_BATMAN_ADV_COMPAT_H_ */
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0003-batman-adv-check-proto-length-before-accessing-proto.patch b/batman-adv/patches/0003-batman-adv-check-proto-length-before-accessing-proto.patch
new file mode 100644
index 0000000..f6270fa
--- /dev/null
+++ b/batman-adv/patches/0003-batman-adv-check-proto-length-before-accessing-proto.patch
@@ -0,0 +1,33 @@
+From aa7d19a5b97fe48657e075e8e4d130bd6916551e Mon Sep 17 00:00:00 2001
+From: Marek Lindner
+Date: Sat, 27 Apr 2013 16:22:28 +0800
+Subject: [PATCH 03/10] batman-adv: check proto length before accessing proto
+ string buffer
+
+batadv_param_set_ra() strips the trailing '\n' from the supplied
+string buffer without checking the length of the buffer first. This
+patches avoids random memory access and associated potential
+crashes.
+
+Reported-by: Sasha Levin
+Signed-off-by: Marek Lindner
+---
+ main.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/main.c b/main.c
+index 3e30a0f..9c620cd 100644
+--- a/main.c
++++ b/main.c
+@@ -475,7 +475,7 @@ static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
+ char *algo_name = (char *)val;
+ size_t name_len = strlen(algo_name);
+
+- if (algo_name[name_len - 1] == '\n')
++ if (name_len > 0 && algo_name[name_len - 1] == '\n')
+ algo_name[name_len - 1] = '\0';
+
+ bat_algo_ops = batadv_algo_get(algo_name);
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0004-batman-adv-check-return-value-of-pskb_trim_rcsum.patch b/batman-adv/patches/0004-batman-adv-check-return-value-of-pskb_trim_rcsum.patch
new file mode 100644
index 0000000..e38596b
--- /dev/null
+++ b/batman-adv/patches/0004-batman-adv-check-return-value-of-pskb_trim_rcsum.patch
@@ -0,0 +1,44 @@
+From d22ebef1431aab13099370b89afa4ba55eb95c35 Mon Sep 17 00:00:00 2001
+From: Marek Lindner
+Date: Tue, 7 May 2013 19:25:02 +0800
+Subject: [PATCH 04/10] batman-adv: check return value of pskb_trim_rcsum()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Reported-by: Sven Eckelmann
+Signed-off-by: Marek Lindner
+Acked-by: Martin Hundebøll
+---
+ network-coding.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/network-coding.c b/network-coding.c
+index f7c5430..e84629e 100644
+--- a/network-coding.c
++++ b/network-coding.c
+@@ -1514,6 +1514,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
+ struct ethhdr *ethhdr, ethhdr_tmp;
+ uint8_t *orig_dest, ttl, ttvn;
+ unsigned int coding_len;
++ int err;
+
+ /* Save headers temporarily */
+ memcpy(&coded_packet_tmp, skb->data, sizeof(coded_packet_tmp));
+@@ -1568,8 +1569,11 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
+ coding_len);
+
+ /* Resize decoded skb if decoded with larger packet */
+- if (nc_packet->skb->len > coding_len + h_size)
+- pskb_trim_rcsum(skb, coding_len + h_size);
++ if (nc_packet->skb->len > coding_len + h_size) {
++ err = pskb_trim_rcsum(skb, coding_len + h_size);
++ if (err)
++ return NULL;
++ }
+
+ /* Create decoded unicast packet */
+ unicast_packet = (struct batadv_unicast_packet *)skb->data;
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0005-batman-adv-make-DAT-drop-ARP-requests-targeting-loca.patch b/batman-adv/patches/0005-batman-adv-make-DAT-drop-ARP-requests-targeting-loca.patch
new file mode 100644
index 0000000..e617ad3
--- /dev/null
+++ b/batman-adv/patches/0005-batman-adv-make-DAT-drop-ARP-requests-targeting-loca.patch
@@ -0,0 +1,48 @@
+From d6bd8b36fa1f3d72a6fd5942a6e9bde6ddafcd0d Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli
+Date: Thu, 9 May 2013 09:35:45 +0200
+Subject: [PATCH 05/10] batman-adv: make DAT drop ARP requests targeting local
+ clients
+
+In the outgoing ARP request snooping routine in DAT, ARP
+Request sent by local clients which are supposed to be
+replied by other local clients can be silently dropped.
+
+The destination host will reply by itself through the LAN
+and therefore there is no need to involve DAT.
+
+Reported-by: Carlos Quijano
+Signed-off-by: Antonio Quartulli
+Tested-by: Carlos Quijano
+Signed-off-by: Marek Lindner
+---
+ distributed-arp-table.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/distributed-arp-table.c b/distributed-arp-table.c
+index 8e15d96..2399920 100644
+--- a/distributed-arp-table.c
++++ b/distributed-arp-table.c
+@@ -837,6 +837,19 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
+
+ dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst);
+ if (dat_entry) {
++ /* If the ARP request is destined for a local client the local
++ * client will answer itself. DAT would only generate a
++ * duplicate packet.
++ *
++ * Moreover, if the soft-interface is enslaved into a bridge, an
++ * additional DAT answer may trigger kernel warnings about
++ * a packet coming from the wrong port.
++ */
++ if (batadv_is_my_client(bat_priv, dat_entry->mac_addr)) {
++ ret = true;
++ goto out;
++ }
++
+ skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src,
+ bat_priv->soft_iface, ip_dst, hw_src,
+ dat_entry->mac_addr, hw_src);
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0006-batman-adv-reorder-clean-up-routine-in-order-to-avoi.patch b/batman-adv/patches/0006-batman-adv-reorder-clean-up-routine-in-order-to-avoi.patch
new file mode 100644
index 0000000..967fb31
--- /dev/null
+++ b/batman-adv/patches/0006-batman-adv-reorder-clean-up-routine-in-order-to-avoi.patch
@@ -0,0 +1,57 @@
+From 763f413b9c74ccb25cb066408f49f07e5dd78f9b Mon Sep 17 00:00:00 2001
+From: Antonio Quartulli
+Date: Tue, 7 May 2013 01:06:18 +0200
+Subject: [PATCH 06/10] batman-adv: reorder clean up routine in order to avoid
+ race conditions
+
+nc_worker accesses the originator table during its periodic
+work, but since the originator table is freed before
+stopping the worker this leads to a global protection fault.
+
+Fix this by killing the worker (in nc_free) before freeing
+the originator table.
+
+Moreover tidy up the entire clean up routine by running all
+the subcomponents freeing procedures first and then killing
+the TT and the originator tables at the end.
+
+Signed-off-by: Antonio Quartulli
+Signed-off-by: Marek Lindner
+---
+ main.c | 16 ++++++++++++----
+ 1 file changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/main.c b/main.c
+index 9c620cd..1240f07 100644
+--- a/main.c
++++ b/main.c
+@@ -163,14 +163,22 @@ void batadv_mesh_free(struct net_device *soft_iface)
+ batadv_vis_quit(bat_priv);
+
+ batadv_gw_node_purge(bat_priv);
+- batadv_originator_free(bat_priv);
+ batadv_nc_free(bat_priv);
++ batadv_dat_free(bat_priv);
++ batadv_bla_free(bat_priv);
+
++ /* Free the TT and the originator tables only after having terminated
++ * all the other depending components which may use these structures for
++ * their purposes.
++ */
+ batadv_tt_free(bat_priv);
+
+- batadv_bla_free(bat_priv);
+-
+- batadv_dat_free(bat_priv);
++ /* Since the originator table clean up routine is accessing the TT
++ * tables as well, it has to be invoked after the TT tables have been
++ * freed and marked as empty. This ensures that no cleanup RCU callbacks
++ * accessing the TT data are scheduled for later execution.
++ */
++ batadv_originator_free(bat_priv);
+
+ free_percpu(bat_priv->bat_counters);
+
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0007-batman-adv-Avoid-double-freeing-of-bat_counters.patch b/batman-adv/patches/0007-batman-adv-Avoid-double-freeing-of-bat_counters.patch
new file mode 100644
index 0000000..d4f3806
--- /dev/null
+++ b/batman-adv/patches/0007-batman-adv-Avoid-double-freeing-of-bat_counters.patch
@@ -0,0 +1,47 @@
+From a5d79639a76d7a71116abbc369a246bd1fcbf947 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?=
+Date: Wed, 17 Apr 2013 21:13:16 +0200
+Subject: [PATCH 07/10] batman-adv: Avoid double freeing of bat_counters
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On errors in batadv_mesh_init(), bat_counters will be freed in both
+batadv_mesh_free() and batadv_softif_init_late(). This patch fixes this
+by returning earlier from batadv_softif_init_late() in case of errors in
+batadv_mesh_init() and by setting bat_counters to NULL after freeing.
+
+Signed-off-by: Martin Hundebøll
+Signed-off-by: Marek Lindner
+---
+ main.c | 1 +
+ soft-interface.c | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/main.c b/main.c
+index 1240f07..51aafd6 100644
+--- a/main.c
++++ b/main.c
+@@ -181,6 +181,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
+ batadv_originator_free(bat_priv);
+
+ free_percpu(bat_priv->bat_counters);
++ bat_priv->bat_counters = NULL;
+
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
+ }
+diff --git a/soft-interface.c b/soft-interface.c
+index 6f20d33..819dfb0 100644
+--- a/soft-interface.c
++++ b/soft-interface.c
+@@ -505,6 +505,7 @@ unreg_debugfs:
+ batadv_debugfs_del_meshif(dev);
+ free_bat_counters:
+ free_percpu(bat_priv->bat_counters);
++ bat_priv->bat_counters = NULL;
+
+ return ret;
+ }
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0008-batman-adv-wait-for-rtnl-in-batadv_store_mesh_iface-.patch b/batman-adv/patches/0008-batman-adv-wait-for-rtnl-in-batadv_store_mesh_iface-.patch
new file mode 100644
index 0000000..87a2940
--- /dev/null
+++ b/batman-adv/patches/0008-batman-adv-wait-for-rtnl-in-batadv_store_mesh_iface-.patch
@@ -0,0 +1,42 @@
+From 96cd7725540f4dccdd6fbb4fde59243e1cc1ad80 Mon Sep 17 00:00:00 2001
+From: Matthias Schiffer
+Date: Tue, 28 May 2013 17:32:32 +0200
+Subject: [PATCH 08/10] batman-adv: wait for rtnl in batadv_store_mesh_iface
+ instead of failing if it is taken
+
+The rtnl_lock in batadv_store_mesh_iface has been converted to a rtnl_trylock
+some time ago to avoid a possible deadlock between rtnl and s_active on removal
+of the sysfs nodes.
+
+The behaviour introduced by that was quite confusing as it could lead to the
+sysfs store to fail, making batman-adv setup scripts unreliable. As recently the
+sysfs removal was postponed to a worker not running with the rtnl taken, the
+deadlock can't occur any more and it is safe to change the trylock back to a
+lock to make the sysfs store reliable again.
+
+Signed-off-by: Matthias Schiffer
+Reviewed-by: Simon Wunderlich
+Signed-off-by: Marek Lindner
+---
+ sysfs.c | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/sysfs.c b/sysfs.c
+index 15a22ef..929e304 100644
+--- a/sysfs.c
++++ b/sysfs.c
+@@ -582,10 +582,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
+ (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
+ goto out;
+
+- if (!rtnl_trylock()) {
+- ret = -ERESTARTSYS;
+- goto out;
+- }
++ rtnl_lock();
+
+ if (status_tmp == BATADV_IF_NOT_IN_USE) {
+ batadv_hardif_disable_interface(hard_iface,
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0009-batman-adv-Don-t-handle-address-updates-when-bla-is-.patch b/batman-adv/patches/0009-batman-adv-Don-t-handle-address-updates-when-bla-is-.patch
new file mode 100644
index 0000000..52e1acd
--- /dev/null
+++ b/batman-adv/patches/0009-batman-adv-Don-t-handle-address-updates-when-bla-is-.patch
@@ -0,0 +1,35 @@
+From 518fba156ed911c6183cf5cb34955a6fdf1b4637 Mon Sep 17 00:00:00 2001
+From: Simon Wunderlich
+Date: Fri, 7 Jun 2013 16:52:05 +0200
+Subject: [PATCH 09/10] batman-adv: Don't handle address updates when bla is
+ disabled
+
+The bridge loop avoidance has a hook to handle address updates of the
+originator. These should not be handled when bridge loop avoidance is
+disabled - it might send some bridge loop avoidance packets which should
+not appear if bla is disabled.
+
+Signed-off-by: Simon Wunderlich
+Signed-off-by: Marek Lindner
+---
+ bridge_loop_avoidance.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
+index 379061c..de27b31 100644
+--- a/bridge_loop_avoidance.c
++++ b/bridge_loop_avoidance.c
+@@ -1067,6 +1067,10 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
+ group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
+ bat_priv->bla.claim_dest.group = group;
+
++ /* purge everything when bridge loop avoidance is turned off */
++ if (!atomic_read(&bat_priv->bridge_loop_avoidance))
++ oldif = NULL;
++
+ if (!oldif) {
+ batadv_bla_purge_claims(bat_priv, NULL, 1);
+ batadv_bla_purge_backbone_gw(bat_priv, 1);
+--
+1.7.10.4
+
diff --git a/batman-adv/patches/0010-batman-adv-forward-late-OGMs-from-best-next-hop.patch b/batman-adv/patches/0010-batman-adv-forward-late-OGMs-from-best-next-hop.patch
new file mode 100644
index 0000000..843ee89
--- /dev/null
+++ b/batman-adv/patches/0010-batman-adv-forward-late-OGMs-from-best-next-hop.patch
@@ -0,0 +1,226 @@
+From 3d999e5116f44b47c742aa16d6382721c360a6d0 Mon Sep 17 00:00:00 2001
+From: Simon Wunderlich
+Date: Thu, 23 May 2013 13:07:42 +0200
+Subject: [PATCH 10/10] batman-adv: forward late OGMs from best next hop
+
+When a packet is received from another node first and later from the
+best next hop, this packet is dropped. However the first OGM was sent
+with the BATADV_NOT_BEST_NEXT_HOP flag and thus dropped by neighbors.
+The late OGM from the best neighbor is then dropped because it is a
+duplicate.
+
+If this situation happens constantly, a node might end up not forwarding
+the "valid" OGMs anymore, and nodes behind will starve from not getting
+valid OGMs.
+
+Fix this by refining the duplicate checking behaviour: The actions
+should depend on whether it was a duplicate for a neighbor only or for
+the originator. OGMs which are not duplicates for a specific neighbor
+will now be considered in batadv_iv_ogm_forward(), but only actually
+forwarded for the best next hop. Therefore, late OGMs from the best
+next hop are forwarded now and not dropped as duplicates anymore.
+
+Signed-off-by: Simon Wunderlich
+Signed-off-by: Marek Lindner
+---
+ bat_iv_ogm.c | 86 +++++++++++++++++++++++++++++++++++++---------------------
+ 1 file changed, 55 insertions(+), 31 deletions(-)
+
+diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
+index 071f288..f680ee1 100644
+--- a/bat_iv_ogm.c
++++ b/bat_iv_ogm.c
+@@ -29,6 +29,21 @@
+ #include "bat_algo.h"
+ #include "network-coding.h"
+
++/**
++ * batadv_dup_status - duplicate status
++ * @BATADV_NO_DUP: the packet is a duplicate
++ * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
++ * neighbor)
++ * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
++ * @BATADV_PROTECTED: originator is currently protected (after reboot)
++ */
++enum batadv_dup_status {
++ BATADV_NO_DUP = 0,
++ BATADV_ORIG_DUP,
++ BATADV_NEIGH_DUP,
++ BATADV_PROTECTED,
++};
++
+ static struct batadv_neigh_node *
+ batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
+ const uint8_t *neigh_addr,
+@@ -650,7 +665,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
+ const struct batadv_ogm_packet *batadv_ogm_packet,
+ struct batadv_hard_iface *if_incoming,
+ const unsigned char *tt_buff,
+- int is_duplicate)
++ enum batadv_dup_status dup_status)
+ {
+ struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
+ struct batadv_neigh_node *router = NULL;
+@@ -676,7 +691,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
+ continue;
+ }
+
+- if (is_duplicate)
++ if (dup_status != BATADV_NO_DUP)
+ continue;
+
+ spin_lock_bh(&tmp_neigh_node->lq_update_lock);
+@@ -718,7 +733,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
+ neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
+ spin_unlock_bh(&neigh_node->lq_update_lock);
+
+- if (!is_duplicate) {
++ if (dup_status == BATADV_NO_DUP) {
+ orig_node->last_ttl = batadv_ogm_packet->header.ttl;
+ neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
+ }
+@@ -902,15 +917,16 @@ out:
+ return ret;
+ }
+
+-/* processes a batman packet for all interfaces, adjusts the sequence number and
+- * finds out whether it is a duplicate.
+- * returns:
+- * 1 the packet is a duplicate
+- * 0 the packet has not yet been received
+- * -1 the packet is old and has been received while the seqno window
+- * was protected. Caller should drop it.
++/**
++ * batadv_iv_ogm_update_seqnos - process a batman packet for all interfaces,
++ * adjust the sequence number and find out whether it is a duplicate
++ * @ethhdr: ethernet header of the packet
++ * @batadv_ogm_packet: OGM packet to be considered
++ * @if_incoming: interface on which the OGM packet was received
++ *
++ * Returns duplicate status as enum batadv_dup_status
+ */
+-static int
++static enum batadv_dup_status
+ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+ const struct batadv_ogm_packet *batadv_ogm_packet,
+ const struct batadv_hard_iface *if_incoming)
+@@ -918,17 +934,18 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+ struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
+ struct batadv_orig_node *orig_node;
+ struct batadv_neigh_node *tmp_neigh_node;
+- int is_duplicate = 0;
++ int is_dup;
+ int32_t seq_diff;
+ int need_update = 0;
+- int set_mark, ret = -1;
++ int set_mark;
++ enum batadv_dup_status ret = BATADV_NO_DUP;
+ uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
+ uint8_t *neigh_addr;
+ uint8_t packet_count;
+
+ orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
+ if (!orig_node)
+- return 0;
++ return BATADV_NO_DUP;
+
+ spin_lock_bh(&orig_node->ogm_cnt_lock);
+ seq_diff = seqno - orig_node->last_real_seqno;
+@@ -936,22 +953,29 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+ /* signalize caller that the packet is to be dropped. */
+ if (!hlist_empty(&orig_node->neigh_list) &&
+ batadv_window_protected(bat_priv, seq_diff,
+- &orig_node->batman_seqno_reset))
++ &orig_node->batman_seqno_reset)) {
++ ret = BATADV_PROTECTED;
+ goto out;
++ }
+
+ rcu_read_lock();
+ hlist_for_each_entry_rcu(tmp_neigh_node,
+ &orig_node->neigh_list, list) {
+- is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
+- orig_node->last_real_seqno,
+- seqno);
+-
+ neigh_addr = tmp_neigh_node->addr;
++ is_dup = batadv_test_bit(tmp_neigh_node->real_bits,
++ orig_node->last_real_seqno,
++ seqno);
++
+ if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
+- tmp_neigh_node->if_incoming == if_incoming)
++ tmp_neigh_node->if_incoming == if_incoming) {
+ set_mark = 1;
+- else
++ if (is_dup)
++ ret = BATADV_NEIGH_DUP;
++ } else {
+ set_mark = 0;
++ if (is_dup && (ret != BATADV_NEIGH_DUP))
++ ret = BATADV_ORIG_DUP;
++ }
+
+ /* if the window moved, set the update flag. */
+ need_update |= batadv_bit_get_packet(bat_priv,
+@@ -971,8 +995,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+ orig_node->last_real_seqno = seqno;
+ }
+
+- ret = is_duplicate;
+-
+ out:
+ spin_unlock_bh(&orig_node->ogm_cnt_lock);
+ batadv_orig_node_free_ref(orig_node);
+@@ -994,7 +1016,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+ int is_broadcast = 0, is_bidirect;
+ bool is_single_hop_neigh = false;
+ bool is_from_best_next_hop = false;
+- int is_duplicate, sameseq, simlar_ttl;
++ int sameseq, similar_ttl;
++ enum batadv_dup_status dup_status;
+ uint32_t if_incoming_seqno;
+ uint8_t *prev_sender;
+
+@@ -1138,10 +1161,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+ if (!orig_node)
+ return;
+
+- is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
+- if_incoming);
++ dup_status = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
++ if_incoming);
+
+- if (is_duplicate == -1) {
++ if (dup_status == BATADV_PROTECTED) {
+ batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+ "Drop packet: packet within seqno protection time (sender: %pM)\n",
+ ethhdr->h_source);
+@@ -1211,11 +1234,12 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+ * seqno and similar ttl as the non-duplicate
+ */
+ sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
+- simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
+- if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl)))
++ similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
++ if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
++ (sameseq && similar_ttl)))
+ batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
+ batadv_ogm_packet, if_incoming,
+- tt_buff, is_duplicate);
++ tt_buff, dup_status);
+
+ /* is single hop (direct) neighbor */
+ if (is_single_hop_neigh) {
+@@ -1236,7 +1260,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+ goto out_neigh;
+ }
+
+- if (is_duplicate) {
++ if (dup_status == BATADV_NEIGH_DUP) {
+ batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+ "Drop packet: duplicate packet received\n");
+ goto out_neigh;
+--
+1.7.10.4
+
diff --git a/batmand/Makefile b/batmand/Makefile
new file mode 100644
index 0000000..4026496
--- /dev/null
+++ b/batmand/Makefile
@@ -0,0 +1,152 @@
+#
+# Copyright (C) 2008-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=batmand
+PKG_REV:=1439
+PKG_VERSION:=r$(PKG_REV)
+PKG_RELEASE:=2
+PKG_EXTRA_CFLAGS=-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\"
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=$(if $(PKG_BRANCH),$(PKG_BRANCH),$(PKG_NAME))-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://downloads.open-mesh.org/svn/batman/trunk/
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
+
+PKG_KMOD_BUILD_DIR:=$(PKG_BUILD_DIR)/batman/linux/modules
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/batmand/Default
+ URL:=http://www.open-mesh.org/
+ MAINTAINER:=Marek Lindner
+endef
+
+define Package/batmand
+$(call Package/batmand/Default)
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ DEPENDS:=+libpthread +kmod-tun
+ TITLE:=B.A.T.M.A.N. layer 3 routing daemon
+endef
+
+define Package/batmand/description
+B.A.T.M.A.N. layer 3 routing daemon
+endef
+
+define Package/vis
+$(call Package/batmand/Default)
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ DEPENDS:=+libpthread
+ TITLE:=visualization server for B.A.T.M.A.N. layer 3
+endef
+
+define Package/vis/description
+visualization server for B.A.T.M.A.N. layer 3
+endef
+
+define KernelPackage/batgat
+$(call Package/batmand/Default)
+ SUBMENU:=Network Support
+ DEPENDS:=+batmand @BROKEN
+ TITLE:=B.A.T.M.A.N. gateway module
+ FILES:=$(PKG_KMOD_BUILD_DIR)/batgat.$(LINUX_KMOD_SUFFIX)
+ AUTOLOAD:=$(call AutoLoad,50,batgat)
+endef
+
+
+define KernelPackage/batgat/description
+Kernel gateway module for B.A.T.M.A.N. for better tunnel performance
+endef
+
+MAKE_BATMAND_ARGS += \
+ EXTRA_CFLAGS='$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)' \
+ CCFLAGS="$(TARGET_CFLAGS)" \
+ OFLAGS="$(TARGET_CFLAGS)" \
+ REVISION="$(PKG_REV)" \
+ CC="$(TARGET_CC)" \
+ NODEBUG=1 \
+ UNAME="Linux" \
+ INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
+ STRIP="/bin/true" \
+ batmand install
+
+MAKE_VIS_ARGS += \
+ EXTRA_CFLAGS='$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)' \
+ CCFLAGS="$(TARGET_CFLAGS)" \
+ OFLAGS="$(TARGET_CFLAGS)" \
+ REVISION="$(PKG_REV)" \
+ CC="$(TARGET_CC)" \
+ NODEBUG=1 \
+ UNAME="Linux" \
+ INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
+ STRIP="/bin/true" \
+ vis install
+
+MAKE_BATGAT_ARGS += \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ PATH="$(TARGET_PATH)" \
+ SUBDIRS="$(PKG_KMOD_BUILD_DIR)" \
+ LINUX_VERSION="$(LINUX_VERSION)" \
+ REVISION="$(PKG_REV)" modules
+
+
+define Build/Configure
+endef
+
+ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_batmand),)
+ BUILD_BATMAND := $(MAKE) -C $(PKG_BUILD_DIR)/batman $(MAKE_BATMAND_ARGS)
+endif
+
+ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_vis),)
+ BUILD_VIS := $(MAKE) -C $(PKG_BUILD_DIR)/vis $(MAKE_VIS_ARGS)
+endif
+
+ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_kmod-batgat),)
+ BUILD_BATGAT := $(MAKE) -C "$(LINUX_DIR)" $(MAKE_BATGAT_ARGS)
+endif
+
+define Build/Compile
+ $(BUILD_BATMAND)
+ $(BUILD_VIS)
+ cp $(PKG_KMOD_BUILD_DIR)/Makefile.kbuild $(PKG_KMOD_BUILD_DIR)/Makefile
+ $(BUILD_BATGAT)
+endef
+
+define Package/batmand/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/batmand $(1)/usr/sbin/
+ $(INSTALL_BIN) ./files/etc/init.d/batmand $(1)/etc/init.d
+ $(INSTALL_DATA) ./files/etc/config/batmand $(1)/etc/config
+endef
+
+define Package/batmand/conffiles
+/etc/config/batmand
+endef
+
+define Package/vis/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vis $(1)/usr/sbin/
+ $(INSTALL_BIN) ./files/etc/init.d/vis $(1)/etc/init.d
+ $(INSTALL_DATA) ./files/etc/config/vis $(1)/etc/config
+endef
+
+define Package/vis/conffiles
+/etc/config/vis
+endef
+
+$(eval $(call BuildPackage,batmand))
+$(eval $(call BuildPackage,vis))
+$(eval $(call KernelPackage,batgat))
diff --git a/batmand/files/etc/config/batmand b/batmand/files/etc/config/batmand
new file mode 100644
index 0000000..6d1f3be
--- /dev/null
+++ b/batmand/files/etc/config/batmand
@@ -0,0 +1,12 @@
+config batmand general
+ option interface ath0
+ option hna
+ option gateway_class
+ option originator_interval
+ option preferred_gateway
+ option routing_class
+ option visualisation_srv
+ option policy_routing_script
+ option disable_client_nat
+ option disable_aggregation
+
diff --git a/batmand/files/etc/config/vis b/batmand/files/etc/config/vis
new file mode 100644
index 0000000..6d30023
--- /dev/null
+++ b/batmand/files/etc/config/vis
@@ -0,0 +1,3 @@
+config vis general
+ option interface ath0
+
diff --git a/batmand/files/etc/init.d/batmand b/batmand/files/etc/init.d/batmand
new file mode 100644
index 0000000..403e9f3
--- /dev/null
+++ b/batmand/files/etc/init.d/batmand
@@ -0,0 +1,66 @@
+#!/bin/sh /etc/rc.common
+START=90
+
+start () {
+ interface=$(uci get batmand.general.interface)
+ if [ "$interface" = "" ]; then
+ echo $1 Error, you must specify at least a network interface
+ exit
+ fi
+ hnas=$(uci get batmand.general.hna)
+ gateway_class=$(uci get batmand.general.gateway_class)
+ originator_interval=$(uci get batmand.general.originator_interval)
+ preferred_gateway=$(uci get batmand.general.preferred_gateway)
+ routing_class=$(uci get batmand.general.routing_class)
+ visualisation_srv=$(uci get batmand.general.visualisation_srv)
+ policy_routing_script=$(uci get batmand.general.policy_routing_script)
+ disable_client_nat=$(uci get batmand.general.disable_client_nat)
+ disable_aggregation=$(uci get batmand.general.disable_aggregation)
+ batman_args=""
+
+ for hna in $hnas
+ do
+ batman_args=${batman_args}'-a '$hna' '
+ done
+
+ if [ $gateway_class ]; then
+ batman_args=${batman_args}'-g '$gateway_class' '
+ fi
+
+ if [ $originator_interval ]; then
+ batman_args=${batman_args}'-o '$originator_interval' '
+ fi
+
+ if [ $preferred_gateway ]; then
+ batman_args=${batman_args}'-p '$preferred_gateway' '
+ fi
+
+ if [ $routing_class ]; then
+ batman_args=${batman_args}'-r '$routing_class' '
+ fi
+
+ if [ $visualisation_srv ]; then
+ batman_args=${batman_args}'-s '$visualisation_srv' '
+ fi
+
+ if [ $policy_routing_script ]; then
+ batman_args=${batman_args}'--policy-routing-script '$policy_routing_script' '
+ fi
+
+ if [ $disable_client_nat ]; then
+ batman_args=${batman_args}'--disable-client-nat '
+ fi
+
+ if [ $disable_aggregation ]; then
+ batman_args=${batman_args}'--disable-aggregation '
+ fi
+
+ batman_args=${batman_args}$interface
+ batmand $batman_args >/dev/null 2>&1
+}
+
+stop () {
+ killall batmand
+}
+
+
diff --git a/batmand/files/etc/init.d/vis b/batmand/files/etc/init.d/vis
new file mode 100644
index 0000000..ef18eb7
--- /dev/null
+++ b/batmand/files/etc/init.d/vis
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+START=90
+
+start () {
+ interface=$(uci get vis.general.interface)
+ if [ "$interface" = "" ]; then
+ echo $1 Error, you must specify at least a network interface
+ exit
+ fi
+ vis_args=$interface
+
+ vis $vis_args >/dev/null 2>&1
+}
+
+stop () {
+ killall vis
+}
+
+
diff --git a/batmand/patches/100-2.6.36.patch b/batmand/patches/100-2.6.36.patch
new file mode 100644
index 0000000..566c23b
--- /dev/null
+++ b/batmand/patches/100-2.6.36.patch
@@ -0,0 +1,47 @@
+---
+ batman/linux/modules/gateway.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+--- batmand-r1439.orig/batman/linux/modules/gateway.c
++++ batmand-r1439/batman/linux/modules/gateway.c
+@@ -29,6 +29,7 @@ static struct class *batman_class;
+ static int batgat_open(struct inode *inode, struct file *filp);
+ static int batgat_release(struct inode *inode, struct file *file);
+ static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg );
++static long batgat_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg );
+
+
+ static void udp_data_ready(struct sock *sk, int len);
+@@ -53,7 +54,11 @@ static int proc_clients_read(char *buf,
+ static struct file_operations fops = {
+ .open = batgat_open,
+ .release = batgat_release,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
++ .unlocked_ioctl = batgat_ioctl_unlocked,
++#else
+ .ioctl = batgat_ioctl,
++#endif
+ };
+
+
+@@ -166,6 +171,20 @@ static int batgat_release(struct inode *
+ }
+
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
++#include
++static long batgat_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg )
++{
++ int ret;
++
++ lock_kernel();
++ ret = batgat_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
++ unlock_kernel();
++
++ return ret;
++}
++#endif
++
+ static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg )
+ {
+ uint8_t tmp_ip[4];
diff --git a/bmx6/Makefile b/bmx6/Makefile
new file mode 100644
index 0000000..8786a3f
--- /dev/null
+++ b/bmx6/Makefile
@@ -0,0 +1,148 @@
+# 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".
+#
+# Contibutors:
+# Axel Neumann, Simó Albert i Beltran, Pau Escrich
+#
+
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=bmx6
+
+PKG_SOURCE_PROTO:=git
+
+PKG_SOURCE_URL:=git://bmx6.net/bmx6.git
+#PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
+
+PKG_REV:=60adcbd4655ccf36a407bae58d66914e33f05a41
+PKG_VERSION:=r2013060803
+PKG_RELEASE:=4
+
+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
+
+
+TARGET_CFLAGS += $(FPIC)
+
+MAKE_ARGS += \
+ EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DNO_DEBUG_ALL -DNO_DEBUG_DUMP" \
+ EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib " \
+ REVISION_VERSION="$(PKG_REV)" \
+ CC="$(TARGET_CC)" \
+ INSTALL_DIR="$(PKG_INSTALL_DIR)" \
+ STRIP="/bin/false" \
+ build_all
+
+define Package/bmx6/Default
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ TITLE:=BMX6 layer 3 routing daemon
+ URL:=http://bmx6.net/
+ MAINTAINER:=Axel Neumann
+ DEPENDS:=+kmod-ip6-tunnel +kmod-iptunnel6 +kmod-tun
+endef
+
+define Package/bmx6/description
+BMX6 layer 3 routing daemon supporting IPv4, IPv6, and IPv4 over IPv6
+endef
+
+define Package/bmx6
+ $(call Package/bmx6/Default)
+ MENU:=1
+endef
+
+define Package/bmx6-uci-config
+ $(call Package/bmx6/Default)
+ DEPENDS:=bmx6 +libuci
+ TITLE:=configuration plugin based on uci (recommended!)
+endef
+
+
+define Package/bmx6-json
+ $(call Package/bmx6/Default)
+ DEPENDS:=bmx6 +libjson
+ TITLE:=json plugin based on jsonc
+endef
+
+define Package/bmx6-sms
+ $(call Package/bmx6/Default)
+ DEPENDS:=bmx6
+ TITLE:=sms plugin
+endef
+
+define Package/bmx6-quagga
+ $(call Package/bmx6/Default)
+ DEPENDS:=bmx6 +qmp-quagga @BROKEN
+ TITLE:=bmx6 quagga plugin to redistribute/export routes (needs manet/bmx6 patched quagga 0.99.21)
+endef
+
+define Build/Configure
+ mkdir -p $(PKG_INSTALL_DIR)
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS)
+endef
+
+
+define Package/bmx6/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bmx6 $(1)/usr/sbin/bmx6
+endef
+
+
+define Package/bmx6-uci-config/conffiles
+/etc/config/bmx6
+endef
+
+
+define Package/bmx6-uci-config/install
+ $(INSTALL_DIR) $(1)/usr/lib $(1)/etc/config $(1)/etc/init.d
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_uci_config/bmx6_config.so $(1)/usr/lib/bmx6_config.so
+ $(INSTALL_BIN) ./files/etc/init.d/bmx6 $(1)/etc/init.d/bmx6
+ $(INSTALL_DATA) ./files/etc/config/bmx6 $(1)/etc/config/bmx6
+endef
+
+define Package/bmx6-json/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_json/bmx6_json.so $(1)/usr/lib/bmx6_json.so
+endef
+
+define Package/bmx6-sms/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_sms/bmx6_sms.so $(1)/usr/lib/bmx6_sms.so
+endef
+
+define Package/bmx6-quagga/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_quagga/bmx6_quagga.so $(1)/usr/lib/bmx6_quagga.so
+endef
+
+$(eval $(call BuildPackage,bmx6))
+$(eval $(call BuildPackage,bmx6-uci-config))
+$(eval $(call BuildPackage,bmx6-json))
+$(eval $(call BuildPackage,bmx6-sms))
+$(eval $(call BuildPackage,bmx6-quagga))
+
diff --git a/bmx6/files/etc/config/bmx6 b/bmx6/files/etc/config/bmx6
new file mode 100644
index 0000000..884fd12
--- /dev/null
+++ b/bmx6/files/etc/config/bmx6
@@ -0,0 +1,82 @@
+
+# for more information:
+# http://bmx6.net/projects/bmx6/wiki
+# options execute: bmx6 --help
+
+config 'bmx6' 'general'
+# option 'runtimeDir' '/var/run/bmx6'
+# option 'tun4Address' '10.202.0.116/32'
+# option 'tun4Address' '10.254.10.0/32'
+# option 'tun6Address' '2012:0:0:1000::1/64'
+
+#config 'ipVersion' 'ipVersion'
+# option 'ipVersion' '6' # default is 4
+# option 'throwRules' '0'
+
+
+#config 'plugin'
+# option 'plugin' 'bmx6_config.so'
+
+
+
+#config 'plugin'
+# option 'plugin' 'bmx6_json.so'
+
+
+
+#config 'plugin'
+# option 'plugin' 'bmx6_sms.so'
+
+
+config 'dev' 'mesh_1'
+ option 'dev' 'eth0.12'
+
+config 'dev' 'mesh_2'
+ option 'dev' 'ath0.12'
+
+
+
+#config 'hna' 'my_global_prefix'
+# option 'hna' '2012:0:0:74:0:0:0:0/64'
+
+
+#config 'tunOut'
+# option 'tunOut' 'ip6'
+# option 'network' '2012::/16'
+# option 'exportDistance' '0'
+
+#config 'tunOut'
+# option 'tunOut' 'ip4'
+# option 'network' '10.254.0.0/16'
+# option 'exportDistance' '0' # requires quagga plugin !
+# option 'minPrefixLen' '27'
+
+
+
+#config 'plugin'
+# option 'plugin' 'bmx6_quagga.so'
+
+
+
+#config 'redistribute'
+# option 'redistribute' 'ospf6'
+# option 'network' '10.0.0.0/8'
+# option 'minPrefixLen' '10'
+# option 'bandwidth' '10000000'
+# option 'ospf6' '1'
+# option 'aggregatePrefixLen' '16'
+
+#config 'redistribute'
+# option 'redistribute' 'bgp'
+# option 'network' '0.0.0.0/0'
+# option 'minPrefixLen' '0'
+# option 'maxPrefixLen' '24'
+# option 'bandwidth' '10000000'
+# option 'bgp' '1'
+# option 'aggregatePrefixLen' '8'
+
+
+
+
+
+
diff --git a/bmx6/files/etc/init.d/bmx6 b/bmx6/files/etc/init.d/bmx6
new file mode 100755
index 0000000..4926e2b
--- /dev/null
+++ b/bmx6/files/etc/init.d/bmx6
@@ -0,0 +1,40 @@
+#!/bin/sh /etc/rc.common
+# 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".
+
+START=91
+
+BIN=/usr/sbin/bmx6
+CONF=/etc/config/bmx6
+PID=/var/run/bmx6/pid
+
+
+start() {
+ cd /root/
+ ulimit -c 20000
+ $BIN -f $CONF -d0 > /dev/null &
+}
+
+stop() {
+ start-stop-daemon -p $PID -K
+}
+
+restart() {
+ stop; sleep 3; start
+}
diff --git a/bmxd/Makefile b/bmxd/Makefile
new file mode 100644
index 0000000..5dfd7f9
--- /dev/null
+++ b/bmxd/Makefile
@@ -0,0 +1,75 @@
+#
+# Copyright (C) 2008 Freifunk Leipzig
+# Copyright (C) 2008-2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=bmxd
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/axn/bmxd.git
+PKG_REV:=9c1d12b554dccd2efde249f5e44a7d4de59ce1a8
+PKG_VERSION:=r2012011001
+#PKG_RELEASE:=1
+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)
+
+PKG_EXTRA_CFLAGS:=-DNODEBUGALL
+
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/bmxd/Default
+ URL:=http://www.bmx6.net/
+ MAINTAINER:=Axel Neumann
+endef
+
+define Package/bmxd
+$(call Package/bmxd/Default)
+ SECTION:=net
+ CATEGORY:=Network
+ SUBMENU:=Routing and Redirection
+ DEPENDS:=+kmod-tun
+ TITLE:=B.a.t.M.a.n. eXperimental (BMX) layer 3 routing daemon
+endef
+
+define Package/bmxd/conffiles
+/etc/config/bmxd
+endef
+
+
+define Package/bmxd/description
+B.a.t.M.a.n. eXperimental (BMX) layer 3 routing daemon
+endef
+
+MAKE_ARGS += \
+ EXTRA_CFLAGS="$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)" \
+ CCFLAGS="$(TARGET_CFLAGS)" \
+ OFLAGS="$(TARGET_CFLAGS)" \
+ REVISION="$(PKG_REV)" \
+ CC="$(TARGET_CC)" \
+ NODEBUG=1 \
+ UNAME="Linux" \
+ INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
+ STRIP="/bin/true" \
+ bmxd install
+
+define Build/Compile
+ mkdir -p $(PKG_INSTALL_DIR)/usr/sbin
+ $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS)
+endef
+
+define Package/bmxd/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bmxd $(1)/usr/sbin/bmxd
+ $(INSTALL_BIN) ./files/etc/init.d/bmxd $(1)/etc/init.d
+ $(INSTALL_DATA) ./files/etc/config/bmxd $(1)/etc/config
+endef
+
+$(eval $(call BuildPackage,bmxd))
diff --git a/bmxd/files/etc/config/bmxd b/bmxd/files/etc/config/bmxd
new file mode 100644
index 0000000..c8619e9
--- /dev/null
+++ b/bmxd/files/etc/config/bmxd
@@ -0,0 +1,9 @@
+config bmxd general
+ option interface 'ath0'
+# option announce
+# option gateway_class
+# option originator_interval
+# option preferred_gateway
+# option routing_class
+# option visualisation_srv
+# option misc 'base-port=14305'
diff --git a/bmxd/files/etc/init.d/bmxd b/bmxd/files/etc/init.d/bmxd
new file mode 100644
index 0000000..d23b4c8
--- /dev/null
+++ b/bmxd/files/etc/init.d/bmxd
@@ -0,0 +1,51 @@
+#!/bin/sh /etc/rc.common
+START=91
+. /lib/config/uci.sh
+uci_load bmxd
+start () {
+ interface="$(uci get bmxd.general.interface)"
+ if [ "$interface" = "" ]; then
+ echo $1 Error, you must specify at least a network interface
+ exit
+ fi
+ announce=$(uci get bmxd.general.announce)
+ gateway_class=$(uci get bmxd.general.gateway_class)
+ originator_interval=$(uci get bmxd.general.originator_interval)
+ preferred_gateway=$(uci get bmxd.general.preferred_gateway)
+ routing_class=$(uci get bmxd.general.routing_class)
+ visualisation_srv=$(uci get bmxd.general.visualisation_srv)
+ misc="$(uci get bmxd.general.misc)"
+ bmx_args=""
+
+ if [ $announce ]; then
+ bmx_args=${bmx_args}'-a '$announce' '
+ fi
+
+ if [ $gateway_class ]; then
+ bmx_args=${bmx_args}'-g '$gateway_class' '
+ fi
+
+ if [ $originator_interval ]; then
+ bmx_args=${bmx_args}'-o '$originator_interval' '
+ fi
+
+ if [ $preferred_gateway ]; then
+ bmx_args=${bmx_args}'-p '$preferred_gateway' '
+ fi
+
+ if [ $routing_class ]; then
+ bmx_args=${bmx_args}'-r '$routing_class' '
+ fi
+
+ if [ $visualisation_srv ]; then
+ bmx_args=${bmx_args}'-s '$visualisation_srv' '
+ fi
+
+
+ bmx_args="$misc ${bmx_args} $interface"
+ bmxd $bmx_args >/dev/null 2>&1
+}
+
+stop () {
+ killall bmxd
+}
diff --git a/luci-app-bmx6/COPYING b/luci-app-bmx6/COPYING
new file mode 100644
index 0000000..d511905
--- /dev/null
+++ b/luci-app-bmx6/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/luci-app-bmx6/Makefile b/luci-app-bmx6/Makefile
new file mode 100644
index 0000000..4e8ce1b
--- /dev/null
+++ b/luci-app-bmx6/Makefile
@@ -0,0 +1,61 @@
+# Copyright (C) 2011 Pau Escrich
+#
+# 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".
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luci-app-bmx6
+PKG_RELEASE:=2
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luci-app-bmx6
+ SECTION:=luci
+ CATEGORY:=LuCI
+ SUBMENU:=3. Applications
+ TITLE:= bmx6 configuration, status and visualization module
+ DEPENDS:=+luci-lib-json +luci-mod-admin-core +luci-lib-httpclient +bmx6
+ MAINTAINER:= Pau Escrich
+endef
+
+define Package/luci-app-bmx6/description
+ bmx6 web module for LuCi web interface
+endef
+
+define Package/luci-app-bmx6/conffiles
+ /etc/config/luci-bmx6
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/luci-app-bmx6/install
+ $(CP) ./files/* $(1)/
+ chmod 755 $(1)/www/cgi-bin/bmx6-info
+endef
+
+$(eval $(call BuildPackage,luci-app-bmx6))
+
diff --git a/luci-app-bmx6/files/etc/config/luci-bmx6 b/luci-app-bmx6/files/etc/config/luci-bmx6
new file mode 100644
index 0000000..df1e715
--- /dev/null
+++ b/luci-app-bmx6/files/etc/config/luci-bmx6
@@ -0,0 +1,7 @@
+config 'bmx6' 'luci'
+ option ignore '0'
+ option place 'admin network BMX6'
+ #option place 'qmp Mesh'
+ option position '3'
+ #option json 'http://127.0.0.1/cgi-bin/bmx6-info?'
+ option json 'exec:/www/cgi-bin/bmx6-info -s'
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua b/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua
new file mode 100644
index 0000000..cb5642e
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/controller/bmx6.lua
@@ -0,0 +1,329 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+ Contributors Jo-Philipp Wich
+
+ 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".
+--]]
+
+local bmx6json = require("luci.model.bmx6json")
+
+module("luci.controller.bmx6", package.seeall)
+
+function index()
+ local place = {}
+ local ucim = require "luci.model.uci"
+ local uci = ucim.cursor()
+
+ -- checking if ignore is on
+ if uci:get("luci-bmx6","luci","ignore") == "1" then
+ return nil
+ end
+
+ -- getting value from uci database
+ local uci_place = uci:get("luci-bmx6","luci","place")
+
+ -- default values
+ if uci_place == nil then
+ place = {"bmx6"}
+ else
+ local util = require "luci.util"
+ place = util.split(uci_place," ")
+ end
+
+ -- getting position of menu
+ local uci_position = uci:get("luci-bmx6","luci","position")
+
+ ---------------------------
+ -- Starting with the pages
+ ---------------------------
+
+ --- status (default)
+ entry(place,call("action_nodes_j"),place[#place],tonumber(uci_position))
+
+ table.insert(place,"Status")
+ entry(place,call("action_status_j"),"Status",0)
+ table.remove(place)
+
+ -- not visible
+ table.insert(place,"nodes_nojs")
+ entry(place, call("action_nodes"), nil)
+ table.remove(place)
+
+ --- nodes
+ table.insert(place,"Nodes")
+ entry(place,call("action_nodes_j"),"Nodes",1)
+ table.remove(place)
+
+ --- links
+ table.insert(place,"Links")
+ entry(place,call("action_links"),"Links",2).leaf = true
+ table.remove(place)
+
+ -- Tunnels
+ table.insert(place,"Tunnels")
+ entry(place,call("action_tunnels_j"), "Tunnels", 3).leaf = true
+ table.remove(place)
+
+ -- Gateways (deprecated)
+ --table.insert(place,"Gateways")
+ --entry(place,call("action_gateways_j"),"Gateways").leaf = true
+ --table.remove(place)
+
+ --- Chat
+ table.insert(place,"Chat")
+ entry(place,call("action_chat"),"Chat",5)
+ table.remove(place)
+
+ --- Graph
+ table.insert(place,"Graph")
+ entry(place, template("bmx6/graph"), "Graph",4)
+ table.remove(place)
+
+ --- Topology (hidden)
+ table.insert(place,"topology")
+ entry(place, call("action_topology"), nil)
+ table.remove(place)
+
+ --- configuration (CBI)
+ table.insert(place,"Configuration")
+ entry(place, cbi("bmx6/main"), "Configuration",6).dependent=false
+
+ table.insert(place,"General")
+ entry(place, cbi("bmx6/main"), "General",1)
+ table.remove(place)
+
+ table.insert(place,"Advanced")
+ entry(place, cbi("bmx6/advanced"), "Advanced",5)
+ table.remove(place)
+
+ table.insert(place,"Interfaces")
+ entry(place, cbi("bmx6/interfaces"), "Interfaces",2)
+ table.remove(place)
+
+ table.insert(place,"Tunnels")
+ entry(place, cbi("bmx6/tunnels"), "Tunnels",3)
+ table.remove(place)
+
+ table.insert(place,"Plugins")
+ entry(place, cbi("bmx6/plugins"), "Plugins",6)
+ table.remove(place)
+
+ table.insert(place,"HNAv6")
+ entry(place, cbi("bmx6/hna"), "HNAv6",4)
+ table.remove(place)
+
+ table.remove(place)
+
+end
+
+function action_status()
+ local status = bmx6json.get("status").status or nil
+ local interfaces = bmx6json.get("interfaces").interfaces or nil
+
+ if status == nil or interfaces == nil then
+ luci.template.render("bmx6/error", {txt="Cannot fetch data from bmx6 json"})
+ else
+ luci.template.render("bmx6/status", {status=status,interfaces=interfaces})
+ end
+end
+
+function action_status_j()
+ luci.template.render("bmx6/status_j", {})
+end
+
+
+function action_nodes()
+ local orig_list = bmx6json.get("originators").originators or nil
+
+ if orig_list == nil then
+ luci.template.render("bmx6/error", {txt="Cannot fetch data from bmx6 json"})
+ return nil
+ end
+
+ local originators = {}
+ local desc = nil
+ local orig = nil
+ local name = ""
+ local ipv4 = ""
+
+ for _,o in ipairs(orig_list) do
+ orig = bmx6json.get("originators/"..o.name) or {}
+ desc = bmx6json.get("descriptions/"..o.name) or {}
+
+ if string.find(o.name,'.') then
+ name = luci.util.split(o.name,'.')[1]
+ else
+ name = o.name
+ end
+
+ table.insert(originators,{name=name,orig=orig,desc=desc})
+ end
+
+ luci.template.render("bmx6/nodes", {originators=originators})
+end
+
+function action_nodes_j()
+ local http = require "luci.http"
+ local link_non_js = "/cgi-bin/luci" .. http.getenv("PATH_INFO") .. '/nodes_nojs'
+
+ luci.template.render("bmx6/nodes_j", {link_non_js=link_non_js})
+end
+
+function action_gateways_j()
+ luci.template.render("bmx6/gateways_j", {})
+end
+
+function action_tunnels_j()
+ luci.template.render("bmx6/tunnels_j", {})
+end
+
+
+function action_links(host)
+ local links = bmx6json.get("links", host)
+ local devlinks = {}
+ local _,l
+
+ if links ~= nil then
+ links = links.links
+ for _,l in ipairs(links) do
+ devlinks[l.viaDev] = {}
+ end
+ for _,l in ipairs(links) do
+ l.globalId = luci.util.split(l.globalId,'.')[1]
+ table.insert(devlinks[l.viaDev],l)
+ end
+ end
+
+ luci.template.render("bmx6/links", {links=devlinks})
+end
+
+function action_topology()
+ local originators = bmx6json.get("originators/all")
+ local o,i,l,i2
+ local first = true
+ local topology = '[ '
+ local cache = '/tmp/bmx6-topology.json'
+ local offset = 60
+
+ local cachefd = io.open(cache,r)
+ local update = false
+
+ if cachefd ~= nil then
+ local lastupdate = tonumber(cachefd:read("*line")) or 0
+ if os.time() >= lastupdate + offset then
+ update = true
+ else
+ topology = cachefd:read("*all")
+ end
+ cachefd:close()
+ end
+
+ if cachefd == nil or update then
+ for i,o in ipairs(originators) do
+ local links = bmx6json.get("links",o.primaryIp)
+ if links then
+ if first then
+ first = false
+ else
+ topology = topology .. ', '
+ end
+
+ topology = topology .. '{ "globalId": "%s", "links": [' %o.globalId:match("^[^%.]+")
+
+ local first2 = true
+
+ for i2,l in ipairs(links.links) do
+ if first2 then
+ first2 = false
+ else
+ topology = topology .. ', '
+ end
+
+ topology = topology .. '{ "globalId": "%s", "rxRate": %s, "txRate": %s }'
+ %{ l.globalId:match("^[^%.]+"), l.rxRate, l.txRate }
+
+ end
+
+ topology = topology .. ']}'
+ end
+
+ end
+
+ topology = topology .. ' ]'
+
+ -- Upgrading the content of the cache file
+ cachefd = io.open(cache,'w+')
+ cachefd:write(os.time()..'\n')
+ cachefd:write(topology)
+ cachefd:close()
+ end
+
+ luci.http.prepare_content("application/json")
+ luci.http.write(topology)
+end
+
+
+function action_chat()
+ local sms_dir = "/var/run/bmx6/sms"
+ local rcvd_dir = sms_dir .. "/rcvdSms"
+ local send_file = sms_dir .. "/sendSms/chat"
+ local sms_list = bmx6json.get("rcvdSms")
+ local sender = ""
+ local sms_file = ""
+ local chat = {}
+ local to_send = nil
+ local sent = ""
+ local fd = nil
+
+ if luci.sys.call("test -d " .. sms_dir) ~= 0 then
+ luci.template.render("bmx6/error", {txt="sms plugin disabled or some problem with directory " .. sms_dir})
+ return nil
+ end
+
+ sms_list = luci.util.split(luci.util.exec("ls "..rcvd_dir.."/*:chat"))
+
+ for _,sms_path in ipairs(sms_list) do
+ if #sms_path > #rcvd_dir then
+ sms_file = luci.util.split(sms_path,'/')
+ sms_file = sms_file[#sms_file]
+ sender = luci.util.split(sms_file,':')[1]
+
+ -- Trying to clean the name
+ if string.find(sender,".") ~= nil then
+ sender = luci.util.split(sender,".")[1]
+ end
+
+ fd = io.open(sms_path,"r")
+ chat[sender] = fd:read()
+ fd:close()
+ end
+ end
+
+ to_send = luci.http.formvalue("toSend")
+ if to_send ~= nil and #to_send > 1 then
+ fd = io.open(send_file,"w")
+ fd:write(to_send)
+ fd:close()
+ sent = to_send
+ else
+ sent = luci.util.exec("cat "..send_file)
+ end
+
+ luci.template.render("bmx6/chat", {chat=chat,sent=sent})
+end
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/bmx6json.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/bmx6json.lua
new file mode 100644
index 0000000..dfe9ab1
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/bmx6json.lua
@@ -0,0 +1,219 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+ Contributors Jo-Philipp Wich
+
+ 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".
+--]]
+
+local ltn12 = require("luci.ltn12")
+local json = require("luci.json")
+local util = require("luci.util")
+local uci = require("luci.model.uci")
+local sys = require("luci.sys")
+local template = require("luci.template")
+local http = require("luci.http")
+local string = require("string")
+local table = require("table")
+local nixio = require("nixio")
+local nixiofs = require("nixio.fs")
+local ipairs = ipairs
+
+module "luci.model.bmx6json"
+
+-- Returns a LUA object from bmx6 JSON daemon
+
+function get(field, host)
+ local url
+ if host ~= nil then
+ if host:match(":") then
+ url = 'http://[%s]/cgi-bin/bmx6-info?' % host
+ else
+ url = 'http://%s/cgi-bin/bmx6-info?' % host
+ end
+ else
+ url = uci.cursor():get("luci-bmx6","luci","json")
+ end
+
+ if url == nil then
+ print_error("bmx6 json url not configured, cannot fetch bmx6 daemon data",true)
+ return nil
+ end
+
+ local json_url = util.split(url,":")
+ local raw = ""
+
+ if json_url[1] == "http" then
+ raw,err = wget(url..field,1000)
+ else
+
+ if json_url[1] == "exec" then
+ raw = sys.exec(json_url[2]..' '..field)
+ else
+ print_error("bmx6 json url not recognized, cannot fetch bmx6 daemon data. Use http: or exec:",true)
+ return nil
+ end
+
+ end
+
+ local data = nil
+
+ if raw and raw:len() > 10 then
+ local decoder = json.Decoder()
+ ltn12.pump.all(ltn12.source.string(raw), decoder:sink())
+ data = decoder:get()
+-- else
+-- print_error("Cannot get data from bmx6 daemon",true)
+-- return nil
+ end
+
+ return data
+end
+
+function print_error(txt,popup)
+ util.perror(txt)
+ sys.call("logger -t bmx6json " .. txt)
+
+ if popup then
+ http.write('')
+ else
+ http.write("
')
+ end
+
+end
+
+function text2html(txt)
+ txt = string.gsub(txt,"<","{")
+ txt = string.gsub(txt,">","}")
+ txt = util.striptags(txt)
+ return txt
+end
+
+
+function wget(url, timeout)
+ local rfd, wfd = nixio.pipe()
+ local pid = nixio.fork()
+ if pid == 0 then
+ rfd:close()
+ nixio.dup(wfd, nixio.stdout)
+
+ local candidates = { "/usr/bin/wget", "/bin/wget" }
+ local _, bin
+ for _, bin in ipairs(candidates) do
+ if nixiofs.access(bin, "x") then
+ nixio.exec(bin, "-q", "-O", "-", url)
+ end
+ end
+ return
+ else
+ wfd:close()
+ rfd:setblocking(false)
+
+ local buffer = { }
+ local err1, err2
+
+ while true do
+ local ready = nixio.poll({{ fd = rfd, events = nixio.poll_flags("in") }}, timeout)
+ if not ready then
+ nixio.kill(pid, nixio.const.SIGKILL)
+ err1 = "timeout"
+ break
+ end
+
+ local rv = rfd:read(4096)
+ if rv then
+ -- eof
+ if #rv == 0 then
+ break
+ end
+
+ buffer[#buffer+1] = rv
+ else
+ -- error
+ if nixio.errno() ~= nixio.const.EAGAIN and
+ nixio.errno() ~= nixio.const.EWOULDBLOCK then
+ err1 = "error"
+ err2 = nixio.errno()
+ end
+ end
+ end
+
+ nixio.waitpid(pid, "nohang")
+ if not err1 then
+ return table.concat(buffer)
+ else
+ return nil, err1, err2
+ end
+ end
+end
+
+function getOptions(name)
+ -- Getting json and Checking if bmx6-json is avaiable
+ local options = get("options")
+ if options == nil or options.OPTIONS == nil then
+ m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
+ return nil
+ else
+ options = options.OPTIONS
+ end
+
+ -- Filtering by the option name
+ local i,_
+ local namedopt = nil
+ if name ~= nil then
+ for _,i in ipairs(options) do
+ if i.name == name and i.CHILD_OPTIONS ~= nil then
+ namedopt = i.CHILD_OPTIONS
+ break
+ end
+ end
+ end
+
+ return namedopt
+end
+
+-- Rturns a help string formated to be used in HTML scope
+function getHtmlHelp(opt)
+ if opt == nil then return nil end
+
+ local help = ""
+ if opt.help ~= nil then
+ help = text2html(opt.help)
+ end
+ if opt.syntax ~= nil then
+ help = help .. " Syntax: " .. text2html(opt.syntax)
+ end
+
+ return help
+end
+
+function testandreload()
+ local test = sys.call('bmx6 -c --test > /tmp/bmx6-luci.err.tmp')
+ if test ~= 0 then
+ return sys.exec("cat /tmp/bmx6-luci.err.tmp")
+ end
+
+ local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp')
+ if err ~= 0 then
+ return sys.exec("cat /tmp/bmx6-luci.err.tmp")
+ end
+
+ return nil
+end
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/advanced.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/advanced.lua
new file mode 100644
index 0000000..9510214
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/advanced.lua
@@ -0,0 +1,74 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+
+ 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".
+--]]
+
+m = Map("bmx6", "bmx6")
+
+local bmx6json = require("luci.model.bmx6json")
+local util = require("luci.util")
+local http = require("luci.http")
+local sys = require("luci.sys")
+
+local options = bmx6json.get("options")
+if options == nil or options.OPTIONS == nil then
+ m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
+ options = {}
+else
+ options = options.OPTIONS
+end
+
+local general = m:section(NamedSection,"general","general","General Options")
+
+local name = ""
+local help = ""
+local value = nil
+local _,o
+
+for _,o in ipairs(options) do
+ if o.name ~= nil and o.CHILD_OPTIONS == nil and o.configurable == 1 then
+ help = ""
+ name = o.name
+
+ if o.help ~= nil then
+ help = bmx6json.text2html(o.help)
+ end
+
+ if o.syntax ~= nil then
+ help = help .. " Syntax: " .. bmx6json.text2html(o.syntax)
+ end
+
+ if o.def ~= nil then
+ help = help .. " Default: " .. o.def
+ end
+
+ value = general:option(Value,name,name,help)
+
+ end
+end
+
+function m.on_commit(self,map)
+ local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp')
+ if err ~= 0 then
+ m.message = sys.exec("cat /tmp/bmx6-luci.err.tmp")
+ end
+end
+
+return m
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua
new file mode 100644
index 0000000..db98ae6
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua
@@ -0,0 +1,47 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+
+ 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".
+--]]
+
+local sys = require("luci.sys")
+
+m = Map("bmx6", "bmx6")
+
+local hna = m:section(TypedSection,"unicastHna","IPv6 HNA")
+hna.addremove = true
+hna.anonymous = true
+local hna_option = hna:option(Value,"unicastHna", "IPv6 Host Network Announcement. Syntax /")
+
+--function hna_option:validate(value)
+-- local err = sys.call('bmx6 -c --test -a ' .. value)
+-- if err ~= 0 then
+-- return nil
+-- end
+-- return value
+--end
+
+function m.on_commit(self,map)
+ local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp')
+ if err ~= 0 then
+ m.message = sys.exec("cat /tmp/bmx6-luci.err.tmp")
+ end
+end
+
+return m
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/interfaces.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/interfaces.lua
new file mode 100644
index 0000000..fb1261b
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/interfaces.lua
@@ -0,0 +1,77 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+
+ 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".
+--]]
+
+local sys = require("luci.sys")
+local bmx6json = require("luci.model.bmx6json")
+local m = Map("bmx6", "bmx6")
+
+local eth_int = sys.net.devices()
+local interfaces = m:section(TypedSection,"dev","Devices","")
+interfaces.addremove = true
+interfaces.anonymous = true
+
+local intlv = interfaces:option(ListValue,"dev","Device")
+
+for _,i in ipairs(eth_int) do
+ intlv:value(i,i)
+end
+
+-- Getting json and looking for device section
+local json = bmx6json.get("options")
+
+if json == nil or json.OPTIONS == nil then
+ m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
+ json = {}
+else
+ json = json.OPTIONS
+end
+
+local dev = {}
+for _,j in ipairs(json) do
+ if j.name == "dev" and j.CHILD_OPTIONS ~= nil then
+ dev = j.CHILD_OPTIONS
+ break
+ end
+end
+
+local help = ""
+local name = ""
+
+for _,o in ipairs(dev) do
+ if o.name ~= nil then
+ help = ""
+ name = o.name
+ if o.help ~= nil then
+ help = bmx6json.text2html(o.help)
+ end
+
+ if o.syntax ~= nil then
+ help = help .. " Syntax: " .. bmx6json.text2html(o.syntax)
+ end
+
+ value = interfaces:option(Value,name,name,help)
+ value.optional = true
+ end
+end
+
+
+return m
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua
new file mode 100644
index 0000000..8c114bf
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua
@@ -0,0 +1,108 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+
+ 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".
+--]]
+
+local sys = require("luci.sys")
+local bmx6json = require("luci.model.bmx6json")
+
+m = Map("bmx6", "bmx6")
+
+-- Getting json and Checking if bmx6-json is avaiable
+local options = bmx6json.get("options")
+if options == nil or options.OPTIONS == nil then
+ m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
+else
+ options = options.OPTIONS
+end
+
+-- Getting a list of interfaces
+local eth_int = luci.sys.net.devices()
+
+-- Getting the most important options from general
+local general = m:section(NamedSection,"general","general","General")
+general.addremove = false
+general:option(Value,"globalPrefix","Global ip prefix","Specify global prefix for interfaces: NETADDR/LENGTH. If you are using IPv6 leave blank to let bmx6 autoassign an ULA IPv6 address.")
+
+if m:get("ipVersion","ipVersion") == "6" then
+ general:option(Value,"tun4Address","IPv4 address or range","specify default IPv4 tunnel address and announced range")
+end
+
+-- IP section
+-- ipVersion section is important, we are allways showing it
+local ipV = m:section(NamedSection,"ipVersion","ipVersion","IP options")
+ipV.addremove = false
+local lipv = ipV:option(ListValue,"ipVersion","IP version")
+lipv:value("4","4")
+lipv:value("6","6")
+lipv.default = "6"
+
+-- rest of ip options are optional, getting them from json
+local ipoptions = {}
+for _,o in ipairs(options) do
+ if o.name == "ipVersion" and o.CHILD_OPTIONS ~= nil then
+ ipoptions = o.CHILD_OPTIONS
+ break
+ end
+end
+
+local help = ""
+local name = ""
+local value = nil
+
+for _,o in ipairs(ipoptions) do
+ if o.name ~= nil then
+ help = ""
+ name = o.name
+ if o.help ~= nil then
+ help = bmx6json.text2html(o.help)
+ end
+
+ if o.syntax ~= nil then
+ help = help .. " Syntax: " .. bmx6json.text2html(o.syntax)
+ end
+
+ if o.def ~= nil then
+ help = help .. " Default: " .. bmx6json.text2html(o.def)
+ end
+
+ value = ipV:option(Value,name,name,help)
+ value.optional = true
+ end
+end
+
+-- Interfaces section
+local interfaces = m:section(TypedSection,"dev","Devices","")
+interfaces.addremove = true
+interfaces.anonymous = true
+local intlv = interfaces:option(ListValue,"dev","Device")
+
+for _,i in ipairs(eth_int) do
+ intlv:value(i,i)
+end
+
+function m.on_commit(self,map)
+ local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp')
+ if err ~= 0 then
+ m.message = sys.exec("cat /tmp/bmx6-luci.err.tmp")
+ end
+end
+
+return m
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua
new file mode 100644
index 0000000..518864e
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua
@@ -0,0 +1,50 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+
+ 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".
+--]]
+local sys = require("luci.sys")
+
+m = Map("bmx6", "bmx6")
+plugins_dir = {"/usr/lib/","/var/lib","/lib"}
+
+plugin = m:section(TypedSection,"plugin","Plugin")
+plugin.addremove = true
+plugin.anonymous = true
+plv = plugin:option(ListValue,"plugin", "Plugin")
+
+for _,d in ipairs(plugins_dir) do
+ pl = luci.sys.exec("cd "..d..";ls bmx6_*")
+ if #pl > 6 then
+ for _,v in ipairs(luci.util.split(pl,"\n")) do
+ plv:value(v,v)
+ end
+ end
+end
+
+
+function m.on_commit(self,map)
+ local err = sys.call('/etc/init.d/bmx6 restart')
+ if err ~= 0 then
+ m.message = sys.exec("Cannot restart bmx6")
+ end
+end
+
+
+return m
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/tunnels.lua b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/tunnels.lua
new file mode 100644
index 0000000..7a6bfd3
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/model/cbi/bmx6/tunnels.lua
@@ -0,0 +1,75 @@
+--[[
+ Copyright (C) 2011 Pau Escrich
+
+ 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".
+--]]
+
+local sys = require("luci.sys")
+local bmx6json = require("luci.model.bmx6json")
+
+m = Map("bmx6", "bmx6")
+
+-- tunOut
+local tunnelsOut = m:section(TypedSection,"tunOut",translate("Networks to fetch"),translate("Tunnel announcements to fetch if possible"))
+tunnelsOut.addremove = true
+tunnelsOut.anonymous = true
+tunnelsOut:option(Value,"tunOut","Name")
+tunnelsOut:option(Value,"network", translate("Network to fetch"))
+
+local tunoptions = bmx6json.getOptions("tunOut")
+local _,o
+for _,o in ipairs(tunoptions) do
+ if o.name ~= nil and o.name ~= "network" then
+ help = bmx6json.getHtmlHelp(o)
+ value = tunnelsOut:option(Value,o.name,o.name,help)
+ value.optional = true
+ end
+end
+
+
+--tunIn
+local tunnelsIn = m:section(TypedSection,"tunInNet",translate("Networks to offer"),translate("Tunnels to announce in the network"))
+tunnelsIn.addremove = true
+tunnelsIn.anonymous = true
+
+local net = tunnelsIn:option(Value,"tunInNet", translate("Network to offer"))
+net.default = "10.0.0.0/8"
+
+local bwd = tunnelsIn:option(Value,"bandwidth",translate("Bandwidth (Bytes)"))
+bwd.default = "1000000"
+
+local tuninoptions = bmx6json.getOptions("tunInNet")
+local _,o
+for _,o in ipairs(tuninoptions) do
+ if o.name ~= nil and o.name ~= "tunInNet" and o.name ~= "bandwidth" then
+ help = bmx6json.getHtmlHelp(o)
+ value = tunnelsIn:option(Value,o.name,o.name,help)
+ value.optional = true
+ end
+end
+
+function m.on_commit(self,map)
+ --Not working. If test returns error the changes are still commited
+ local msg = bmx6json.testandreload()
+ if msg ~= nil then
+ m.message = msg
+ end
+end
+
+return m
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/view/admin_status/index/neighbours_simple.htm b/luci-app-bmx6/files/usr/lib/lua/luci/view/admin_status/index/neighbours_simple.htm
new file mode 100644
index 0000000..97d6e0e
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/view/admin_status/index/neighbours_simple.htm
@@ -0,0 +1,108 @@
+
+
+
This is sms a chat where all bmx6 nodes can participate. The data is replayed using routing packets, so there is a limit of 2040 bytes. Use it only to send short messages.
+
Each participant can only send one sms at same time.
+
+
+Received SMS
+
+
+<% for orig,sms in pairs(chat) do %>
+ <%=orig%>:<%=sms%>
+<% end %>
+
+
+<%+footer%>
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm
new file mode 100644
index 0000000..a4dabb7
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/graph.htm
@@ -0,0 +1,110 @@
+<%#
+Copyright (C) 2011 Pau Escrich
+Contributors Jo-Philip
+
+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".
+-%>
+
+<%
+ luci.http.prepare_content("text/html")
+
+ local location = { unpack(luci.dispatcher.context.path) }
+ location[#location] = "topology"
+%>
+
+<%+header%>
+
+
+
+
+
+
+
+
+
+ <% if o.desc.DESC_ADV ~= nil then %>
+ <% for j,h in ipairs(o.desc.DESC_ADV.extensions[2].HNA6_EXTENSION) do %>
+ <%=h.address%>
+ <% end %>
+ <% end %>
+
+ <% if o.desc.DESC_ADV ~= nil then %>
+ <% for j,h in ipairs(o.desc.DESC_ADV.extensions[2].HNA6_EXTENSION) do %>
+ <%=h.address%>
+ <% end %>
+ <% end %>
+
+
+<% end %>
+
+
+
+<%+footer%>
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/nodes_j.htm b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/nodes_j.htm
new file mode 100644
index 0000000..0435655
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/nodes_j.htm
@@ -0,0 +1,193 @@
+<%#
+ Copyright (C) 2011 Pau Escrich
+ Contributors Lluis Esquerda
+
+ 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".
+-%>
+
+<%+header%>
+
+
+
+
+
+
+
+
Node originators
+
+
+
+
+ Click icon to see individual node information
+
+
+
+
+
+
+Go to non JavaScript view
+
+
+
+<%+footer%>
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/status.htm b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/status.htm
new file mode 100644
index 0000000..11e9682
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/status.htm
@@ -0,0 +1,69 @@
+<%+header%>
+
+
+
+
+Bmx6 is a routing protocol for Linux based operating systems. Visit bmx6.net for more info.
+
+
+
+
+
+
+
+
+a mesh routing protocol for Linux devices.
+Visit bmx6.net for more info.
+
+
+
+
+
status
+
+
+
+
+
+
+
+
+
+
+<%+footer%>
+
diff --git a/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/tunnels_j.htm b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/tunnels_j.htm
new file mode 100644
index 0000000..1b7ce42
--- /dev/null
+++ b/luci-app-bmx6/files/usr/lib/lua/luci/view/bmx6/tunnels_j.htm
@@ -0,0 +1,107 @@
+<%#
+ Copyright (C) 2011 Pau Escrich
+ Contributors Lluis Esquerda
+
+ 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".
+-%>
+
+
+<%+header%>
+
+
+
+
+
+