batman-adv: upgrade package to latest release 2012.0.0
authorMarek Lindner <lindner_marek@yahoo.de>
Sun, 5 Feb 2012 16:21:26 +0000 (16:21 +0000)
committerMarek Lindner <lindner_marek@yahoo.de>
Sun, 5 Feb 2012 16:21:26 +0000 (16:21 +0000)
Also replace init script with hotplug based set of scripts.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
git-svn-id: svn://svn.openwrt.org/openwrt/packages/net/batman-adv@30272 3c298f89-4303-0410-b956-a3cf2f4a3e73

Makefile
files/etc/config/batman-adv
files/etc/hotplug.d/net/99-batman-adv [new file with mode: 0644]
files/etc/init.d/batman-adv [deleted file]
files/lib/batman-adv/config.sh
files/usr/sbin/batman-adv [new file with mode: 0644]

index 5154862464573fb31467ee841cf2f8313d79a10c..8a409949d7f42c99465f04abae0a6e2b857c4406 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,10 +10,10 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=batman-adv
 
-PKG_VERSION:=2011.4.0
-BATCTL_VERSION:=2011.4.0
-PKG_MD5SUM:=3987d693bd26d8057506b542c3635910
-BATCTL_MD5SUM:=325b25dbb8261f7fa19c6e1d9bfba6e1
+PKG_VERSION:=2012.0.0
+BATCTL_VERSION:=2012.0.0
+PKG_MD5SUM:=f1de23457a47ca4369ee1f0e0b7fc405
+BATCTL_MD5SUM:=27991c2921e18657c7262e917d45106a
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
@@ -74,9 +74,10 @@ define Download/batctl
 endef
 $(eval $(call Download,batctl))
 
-EXTRACT_BATCTL = tar xzf "$(DL_DIR)/batctl-$(BATCTL_VERSION).tar.gz" -C "$(BUILD_DIR)/$(PKG_NAME)"
-PATCH_BATCTL = $(call Build/DoPatch,"$(PKG_BATCTL_BUILD_DIR)","$(PATCH_DIR)","*batctl*")
-BUILD_BATCTL = $(MAKE) -C $(PKG_BATCTL_BUILD_DIR) $(MAKE_BATCTL_ARGS)
+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)
@@ -90,36 +91,27 @@ endef
 
 define Build/Patch
        $(call Build/DoPatch,"$(PKG_BUILD_DIR)","$(PATCH_DIR)","*batman*")
-       $(EXTRACT_BATCTL)
-       $(PATCH_BATCTL)
+       $(BATCTL_EXTRACT)
+       $(BATCTL_PATCH)
 endef
 
 define Build/Compile
        cp $(PKG_BUILD_DIR)/Makefile.kbuild $(PKG_BUILD_DIR)/Makefile
        $(MAKE) -C "$(LINUX_DIR)" $(MAKE_BATMAN_ADV_ARGS)
-       $(BUILD_BATCTL)
+       $(BATCTL_BUILD)
 endef
 
 define Build/Clean
         rm -rf $(BUILD_DIR)/$(PKG_NAME)/
 endef
 
-ifneq ($(DEVELOPER)$(CONFIG_KMOD_BATMAN_ADV_BATCTL),)
 define KernelPackage/batman-adv/install
-       $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d $(1)/lib/batman-adv
-       $(INSTALL_BIN) ./files/etc/init.d/batman-adv $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/lib/batman-adv/config.sh $(1)/lib/batman-adv
+       $(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/net $(1)/lib/batman-adv $(1)/usr/sbin
        $(INSTALL_DATA) ./files/etc/config/batman-adv $(1)/etc/config
-       $(INSTALL_DIR) $(1)/usr/sbin
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/sbin/batctl $(1)/usr/sbin/
+       $(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/usr/sbin/batman-adv $(1)/usr/sbin
+       $(BATCTL_INSTALL)
 endef
-else
-define KernelPackage/batman-adv/install
-       $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d $(1)/lib/batman-adv
-       $(INSTALL_BIN) ./files/etc/init.d/batman-adv $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/lib/batman-adv/config.sh $(1)/lib/batman-adv
-       $(INSTALL_DATA) ./files/etc/config/batman-adv $(1)/etc/config
-endef
-endif
 
 $(eval $(call KernelPackage,batman-adv))
index 414b119663dd338cc4104e62c746723d274f44cb..519782042238e049523b502d9542c6272b2b6f66 100644 (file)
@@ -12,3 +12,6 @@ config 'mesh' 'bat0'
        option 'orig_interval'
        option 'vis_mode'
 
+# yet another batX instance
+# config 'mesh' 'bat5'
+#      option 'interfaces' 'second_mesh'
diff --git a/files/etc/hotplug.d/net/99-batman-adv b/files/etc/hotplug.d/net/99-batman-adv
new file mode 100644 (file)
index 0000000..2ad83cf
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. /lib/batman-adv/config.sh
+
+config_load batman-adv
+
+case "$ACTION" in
+       add)
+               [ -d /sys/class/net/$INTERFACE/mesh/ ] && config_bat "$INTERFACE"
+               [ -d /sys/class/net/$INTERFACE/batman_adv/ ] && config_foreach bat_add_interface mesh "$INTERFACE"
+               ;;
+       remove)
+               [ -d /sys/class/net/$INTERFACE/batman_adv/ ] && config_foreach bat_del_interface mesh "$INTERFACE"
+               ;;
+esac
diff --git a/files/etc/init.d/batman-adv b/files/etc/init.d/batman-adv
deleted file mode 100644 (file)
index f0f6789..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2011 OpenWrt.org
-
-START=90
-
-. /lib/batman-adv/config.sh
-
-# can also be used with "batman-adv start bat0"
-start() {
-       config_load batman-adv
-
-       if [ -n "$1" ]; then
-               start_mesh $1
-       else
-               config_foreach start_mesh mesh
-       fi
-}
-
-# can also be used with "batman-adv stop bat0"
-stop () {
-       config_load batman-adv
-
-       if [ -n "$1" ]; then
-               stop_mesh $1
-       else
-               config_foreach stop_mesh mesh
-       fi
-}
index 58a01d2bc1a5da462f458cc72cc6d0a30ac02bfa..d0569bc77dfed0a25ff3e43de590d58c8a9aa053 100644 (file)
 #!/bin/sh
-# Copyright (C) 2011 OpenWrt.org
 
-is_module_loaded() {
-
-       if [ ! -d "/sys/module/batman_adv" ]; then
-               echo "batman-adv module directory not found - was the kernel module loaded ?" >&2
-               return 0
-       fi
-
-       return 1
+bat_config(){
+       local mesh="$1"
+       local aggregated_ogms bonding fragmentation gw_bandwidth gw_mode gw_sel_class log_level orig_interval hop_penalty vis_mode
+
+       config_get aggregated_ogms "$mesh" aggregated_ogms
+       config_get bonding "$mesh" bonding
+       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 log_level "$mesh" log_level
+       config_get orig_interval "$mesh" orig_interval
+       config_get hop_penalty "$mesh" hop_penalty
+       config_get vis_mode "$mesh" vis_mode
+
+       [ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval
+       [ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
+       [ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&-
+       [ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms
+       [ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding
+       [ -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 "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode
 }
 
-start_mesh () {
-       local meshif="$1"
-       local interfaces aggregated_ogms ap_isolation bonding fragmentation gw_bandwidth gw_mode gw_sel_class log_level orig_interval vis_mode
-
-       is_module_loaded
-       [ $? -ne 1 ] && return
-
-       config_get interfaces "$meshif" interfaces
-       config_get aggregated_ogms "$meshif" aggregated_ogms
-       config_get ap_isolation "$meshif" ap_isolation
-       config_get bonding "$meshif" bonding
-       config_get fragmentation "$meshif" fragmentation
-       config_get gw_bandwidth "$meshif" gw_bandwidth
-       config_get gw_mode "$meshif" gw_mode
-       config_get gw_sel_class "$meshif" gw_sel_class
-       config_get log_level "$meshif" log_level
-       config_get orig_interval "$meshif" orig_interval
-       config_get vis_mode "$meshif" vis_mode
-
-       if [ "$interfaces" = "" ]; then
-               echo Error, you must specify at least a network interface
-               return
-       fi
+bat_add_interface(){
+       local mesh="$1"
+       local interface="$2"
+       local interfaces
+
+       sleep 3s # some device (ath) is very lazy to start
+       config_get interfaces $mesh interfaces
+       for iface in $interfaces; do
+               [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || {
+                       iface=$(uci -q -P/var/state get network.$iface.ifname)
+                       [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || continue
+               }
        
-       for interface in $interfaces
-          do
-             ifname=$(uci -P /var/state get network.$interface.ifname 2>&-)
-             [ ! -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] && {
-                ifname=${interface}
-                [ ! -f "/sys/class/net/$ifname/batman_adv/mesh_iface" ] && echo "Can't add interface $ifname - ignoring" && continue
-             }
-
-             echo $meshif > /sys/class/net/$ifname/batman_adv/mesh_iface
-          done
-
-       if [ $orig_interval ]; then
-               echo $orig_interval > /sys/class/net/$meshif/mesh/orig_interval
-       fi
-
-       if [ $log_level ]; then
-               echo $log_level > /sys/class/net/$meshif/mesh/log_level 2>&-
-       fi
-
-       if [ $aggregated_ogms ]; then
-               echo $aggregated_ogms > /sys/class/net/$meshif/mesh/aggregated_ogms
-       fi
-       
-       if [ $ap_isolation ]; then
-               echo $ap_isolation > /sys/class/net/$meshif/mesh/ap_isolation
-       fi
-       
-       if [ $bonding ]; then
-               echo $bonding > /sys/class/net/$meshif/mesh/bonding
-       fi
-       
-       if [ $fragmentation ]; then
-               echo $fragmentation > /sys/class/net/$meshif/mesh/fragmentation
-       fi
-       
-       if [ $gw_bandwidth ]; then
-               echo $gw_bandwidth > /sys/class/net/$meshif/mesh/gw_bandwidth
-       fi
-       
-       if [ $gw_mode ]; then 
-               echo $gw_mode > /sys/class/net/$meshif/mesh/gw_mode
-       fi
-       
-       if [ $gw_sel_class ]; then
-               echo $gw_sel_class > /sys/class/net/$meshif/mesh/gw_sel_class
-       fi
-
-       if [ $vis_mode ]; then
-               echo $vis_mode > /sys/class/net/$meshif/mesh/vis_mode
-       fi
+               [ "$iface" = "$interface" ] && echo $mesh > /sys/class/net/$iface/batman_adv/mesh_iface
+       done
 }
 
-stop_mesh() {
-       local meshif="$1"
-
-       is_module_loaded
-       [ $? -ne 1 ] && return
+bat_del_interface(){
+       local mesh="$1"
+       local interface="$2"
+       local interfaces
 
-       for iface in $(ls /sys/class/net/*)
-          do
-                [ ! -f "$iface/batman_adv/mesh_iface" ] && continue
-                [ "$(head -1 $iface/batman_adv/mesh_iface)" != "$meshif" ] && continue
+       config_get interfaces $mesh interfaces
+       for iface in $interfaces; do
+               [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || {
+                       iface=$(uci -q -P/var/state get network.$iface.ifname)
+                       [ -f "/sys/class/net/$iface/batman_adv/mesh_iface" ] || continue
+               }
 
-                echo "none" > $iface/batman_adv/mesh_iface
-          done
+               [ "$iface" = "$interface" ] && echo none > /sys/class/net/$iface/batman_adv/mesh_iface
+       done
 }
diff --git a/files/usr/sbin/batman-adv b/files/usr/sbin/batman-adv
new file mode 100644 (file)
index 0000000..4f17991
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2011 OpenWrt.org
+
+. /lib/batman-adv/config.sh
+
+start_mesh() {
+       local mesh="$1"
+       local ifaces=$(awk -F':' '{if (NR > 2) print $1}' /proc/net/dev)
+
+       for iface in $ifaces; do
+               [ -d /sys/class/net/$iface/batman_adv/ ] && bat_add_interface "$mesh" "$iface"
+       done
+
+       bat_config "$mesh"
+}
+
+stop_mesh() {
+       local mesh="$1"
+       local ifaces=$(awk -F':' '{if (NR > 2) print $1}' /proc/net/dev)
+
+       for iface in $ifaces; do
+               [ -d /sys/class/net/$iface/batman_adv/ ] && bat_del_interface "$mesh" "$iface"
+       done
+}
+
+# can also be used with "batman-adv start bat0"
+start() {
+       config_load batman-adv
+
+       if [ -n "$1" ]; then
+               start_mesh $1
+       else
+               config_foreach start_mesh mesh
+       fi
+}
+
+# can also be used with "batman-adv stop bat0"
+stop () {
+       config_load batman-adv
+
+       if [ -n "$1" ]; then
+               stop_mesh $1
+       else
+               config_foreach stop_mesh mesh
+       fi
+}