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)
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)
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))
#!/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
}