[PATCH v2] fff-hoods: Provide support for more than one gateway
Adrian Schmutzler
freifunk at adrianschmutzler.de
Do Nov 2 14:56:31 CET 2017
This patch uses the information accessible through batctl.
This has the advantage that no additional data sources are
required (hood file, ...) and thus no one has to put additional
information anywhere.
Semi-tested: Tested via console, but not in connection with
configurehood.
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
Changes in v2:
- Filter multicast addresses
---
src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange | 11 +++++++++++
src/packages/fff/fff-hoods/files/usr/sbin/configurehood | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange b/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange
index 9aeb434..d7851b5 100644
--- a/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange
+++ b/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange
@@ -31,3 +31,14 @@ getUpgradePath() {
fi
return 0
}
+
+getJsonGateway() {
+ regex='s/^\s*[^ ]*\s*\([^ ]*\)\s.*/\1/p'
+ batctl gwl | grep "Bit" | sed -n -e "$regex" | while read -r line ; do
+ gwmac="$(batctl tg | grep -v -e " 0[01]:00:5e" -e " 01:80:c2" -e " 33:33" | grep -m 1 "$line" | sed -n -e "$regex")"
+ # remove reserved Multicast MAC adresses (https://en.wikipedia.org/wiki/Multicast_address#Ethernet)
+ eui="$(echo "$gwmac" | awk -F: '{ printf("%02x%s:%sff:fe%s:%s%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }')"
+ gwaddr="fe80::${eui}%br-mesh"
+ wget -T15 -t5 "http://[$gwaddr]:2342/keyxchangev2data" -O "$hoodfile" && break
+ done
+}
\ No newline at end of file
diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index 8ffaced..762aede 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -115,8 +115,8 @@ else
wget -T15 -t5 "http://[fe80::1%w2sta]:2342/sectorfile" -O "$sectortmp" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/sectorfile" -O "$sectortmp"
fi
else
- echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
- wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" -O "$hoodfile"
+ echo "We have a Gateway in Range, we load the keyxchangev2data based on batctl"
+ getJsonGateway
#UPLINK: Do nothing
fi
fi
--
2.7.4
Mehr Informationen über die Mailingliste franken-dev