batman-adv: upgrade package to latest release 2012.0.0
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@30272 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
8e5ca76e99
commit
80bad1bd5f
@ -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))
|
||||
|
@ -12,3 +12,6 @@ config 'mesh' 'bat0'
|
||||
option 'orig_interval'
|
||||
option 'vis_mode'
|
||||
|
||||
# yet another batX instance
|
||||
# config 'mesh' 'bat5'
|
||||
# option 'interfaces' 'second_mesh'
|
||||
|
15
net/batman-adv/files/etc/hotplug.d/net/99-batman-adv
Normal file
15
net/batman-adv/files/etc/hotplug.d/net/99-batman-adv
Normal file
@ -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
|
@ -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
|
||||
}
|
@ -1,103 +1,61 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011 OpenWrt.org
|
||||
|
||||
is_module_loaded() {
|
||||
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
|
||||
|
||||
if [ ! -d "/sys/module/batman_adv" ]; then
|
||||
echo "batman-adv module directory not found - was the kernel module loaded ?" >&2
|
||||
return 0
|
||||
fi
|
||||
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
|
||||
|
||||
return 1
|
||||
[ -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
|
||||
bat_add_interface(){
|
||||
local mesh="$1"
|
||||
local interface="$2"
|
||||
local interfaces
|
||||
|
||||
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
|
||||
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"
|
||||
bat_del_interface(){
|
||||
local mesh="$1"
|
||||
local interface="$2"
|
||||
local interfaces
|
||||
|
||||
is_module_loaded
|
||||
[ $? -ne 1 ] && return
|
||||
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 iface in $(ls /sys/class/net/*)
|
||||
do
|
||||
[ ! -f "$iface/batman_adv/mesh_iface" ] && continue
|
||||
[ "$(head -1 $iface/batman_adv/mesh_iface)" != "$meshif" ] && continue
|
||||
|
||||
echo "none" > $iface/batman_adv/mesh_iface
|
||||
done
|
||||
[ "$iface" = "$interface" ] && echo none > /sys/class/net/$iface/batman_adv/mesh_iface
|
||||
done
|
||||
}
|
||||
|
46
net/batman-adv/files/usr/sbin/batman-adv
Normal file
46
net/batman-adv/files/usr/sbin/batman-adv
Normal file
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user