summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkeye <postfach@martinmichel.info>2011-01-21 18:38:41 (GMT)
committerDarkeye <postfach@martinmichel.info>2011-01-21 18:38:41 (GMT)
commitad9f2144b7cc4b1328fb721da4cf98e07fe65525 (patch)
tree98bf5172021b1441909406dab0b9c57eb351e7d0
parent2ade89a3e11d8a3d26319ae2f410fcc7b2c14e95 (diff)
moved batman-adv gw_mode to uci
-rw-r--r--files/etc/config/batman-adv1
-rwxr-xr-xfiles/etc/init.d/batman-adv103
-rwxr-xr-xfiles/sbin/setup_router8
3 files changed, 109 insertions, 3 deletions
diff --git a/files/etc/config/batman-adv b/files/etc/config/batman-adv
index 383e31f..cc8db5f 100644
--- a/files/etc/config/batman-adv
+++ b/files/etc/config/batman-adv
@@ -6,4 +6,5 @@ config 'mesh' 'bat0'
option 'bonding'
option 'fragmentation'
option 'vis_mode'
+ option 'gw_mode' 'client'
diff --git a/files/etc/init.d/batman-adv b/files/etc/init.d/batman-adv
new file mode 100755
index 0000000..6ecb7ea
--- /dev/null
+++ b/files/etc/init.d/batman-adv
@@ -0,0 +1,103 @@
+#!/bin/sh /etc/rc.common
+START=90
+
+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
+}
+
+start_mesh () {
+ local meshif="$1"
+ local interfaces orig_interval log_level aggregated_ogms bonding vis_mode
+
+ is_module_loaded
+ [ $? -ne 1 ] && return
+
+ config_get interfaces "$meshif" interfaces
+ config_get orig_interval "$meshif" orig_interval
+ config_get log_level "$meshif" log_level
+ config_get aggregated_ogms "$meshif" aggregated_ogms
+ config_get bonding "$meshif" bonding
+ config_get gw_mode "$meshif" gw_mode
+
+ config_get vis_mode "$meshif" vis_mode
+
+ if [ "$interfaces" = "" ]; then
+ echo Error, you must specify at least a network interface
+ return
+ fi
+
+ for interface in $interfaces
+ do
+ [ ! -f "/sys/class/net/$interface/batman_adv/mesh_iface" ] && echo "Can't add interface $interface - ignoring" && continue
+ echo $meshif > /sys/class/net/$interface/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 [ $bonding ]; then
+ echo $bonding > /sys/class/net/$meshif/mesh/bonding
+ fi
+
+ if [ $vis_mode ]; then
+ echo $vis_mode > /sys/class/net/$meshif/mesh/vis_mode
+ fi
+
+ if [ $gw_mode ]; then
+ echo $gw_mode > /sys/class/net/$meshif/mesh/gw_mode
+ fi
+}
+
+stop_mesh() {
+ local meshif="$1"
+
+ is_module_loaded
+ [ $? -ne 1 ] && return
+
+ for iface in $(ls /sys/class/net/*)
+ do
+ [ ! -f "$iface/batman_adv/mesh_iface" ] && continue
+ [ "$(head -1 $iface/batman_adv/mesh_iface)" != "status: $meshif" ] && continue
+
+ echo "none" > $iface/batman_adv/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
+}
+
+
diff --git a/files/sbin/setup_router b/files/sbin/setup_router
index 84457a1..5e990d6 100755
--- a/files/sbin/setup_router
+++ b/files/sbin/setup_router
@@ -25,7 +25,8 @@ if [[ $router = "j" ]]
uci set dhcp.mesh.end_ip=10.17.$oct3.254
uci commit dhcp
# Batman Server Mode
- batctl gw server
+ uci set batman-adv.bat0.gw_mode=server
+ uci commit batman-adv
else
# Act as a node only
uci del dhcp.mesh
@@ -36,8 +37,9 @@ if [[ $router = "j" ]]
uci commit network
echo "Der Router wird als normaler Node konfiguriert"
echo
- # Batman Server Mode
- batctl gw client
+ # Batman Clientr Mode
+ uci set batman-adv.bat0.gw_mode=client
+ uci commit batman-adv
fi
uci commit
#TODO: Generate Subnet
contact: Jan Huwald // Impressum