summaryrefslogtreecommitdiff
path: root/files/common/etc/fsm/inetable/trans/queen.enter
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2011-12-09 19:52:15 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2011-12-09 19:52:15 (GMT)
commitcd9f7aca64327e29cc8acb55d94f21a2da03330e (patch)
treee6aafe13e28045fad9cad192dd14c4b7a419d2f9 /files/common/etc/fsm/inetable/trans/queen.enter
parentef0ab9ba3f0042f59c0a8f155fcb61187585303e (diff)
add FSM inetable
- implemented according to documentation - almost no tests so far
Diffstat (limited to 'files/common/etc/fsm/inetable/trans/queen.enter')
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/queen.enter45
1 files changed, 45 insertions, 0 deletions
diff --git a/files/common/etc/fsm/inetable/trans/queen.enter b/files/common/etc/fsm/inetable/trans/queen.enter
new file mode 100755
index 0000000..a8a1a8e
--- /dev/null
+++ b/files/common/etc/fsm/inetable/trans/queen.enter
@@ -0,0 +1,45 @@
+#!/bin/sh -e
+
+gwiptbl=/tmp/p2ptbl/gwip
+
+# determine gw IP from p2ptable
+getoct () {
+ p2ptbl show $gwiptbl \
+ | cut -f1,2 \
+ | egrep "[0-9]*"$'\t'"$1" \
+ | $2 \
+ | head -n1
+}
+# get the lowest free addr
+oct3=$(getoct free "sort -n")
+# no free addrs? -> steal an addr from a random ghost
+if [ -z "$oct3" ]; then
+ oct3=$(getoct ghost "shuf")
+ # no ghost addrs? -> steal an addr from a random queen
+ if [ -z "$oct3" ]; then
+ oct3=$(getoct queen "shuf")
+ fi
+ # TODO: log warning about IPv4 addr space exhaustion
+fi
+[ -n "$oct3" ]
+p2ptbl update $gwiptbl $oct3 "queen\t$NodeId" br-mesh
+
+# activate gw mode
+batctl gw server
+
+# set up gw IP
+ifconfig br-mesh 10.17.$oct3.1
+
+# TODO: load splash status
+
+# setup DHCP
+echo "
+set dhcp.mesh=dhcp
+set dhcp.mesh.start=2
+set dhcp.mesh.limit=254
+set dhcp.mesh.leasetime=$DHCPLeaseTime
+set dhcp.mesh.interface=mesh
+set dhcp.mesh.start_ip=10.17.$oct3.2
+set dhcp.mesh.end_ip=10.17.$oct3.254
+" | uci batch
+/etc/init.d/dnsmasq restart \ No newline at end of file
contact: Jan Huwald // Impressum