nodewatcher: Fix bugs in gateway list creation

Changes:
- Remove first line (headline) previously parsed as gateway
- Delete leading whitespaces for netif correctly (regex
  "\\[" changed to "\\[ *")
- Remove netif whitespaces first, so they are not changed to
  "false"
- Include trailing whitespace in regex for selection marker
- Remove useless replacement "  " to " "

This is designed to support BATMAN compatibility version 14 AND 15

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Tim Niemeyer <tim@tn-x.org>
This commit is contained in:
Adrian Schmutzler 2018-01-13 15:28:54 +01:00 committed by Tim Niemeyer
parent 90c8526873
commit bef333c43b
2 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-nodewatcher
PKG_VERSION:=44
PKG_VERSION:=45
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

View File

@ -2,7 +2,7 @@
# Netmon Nodewatcher (C) 2010-2012 Freifunk Oldenburg
# License; GPL v3
SCRIPT_VERSION="44"
SCRIPT_VERSION="45"
test -f /tmp/started || exit
@ -243,15 +243,15 @@ crawl() {
batman_adv_gateway_list=$(awk \
'BEGIN { FS=" "; i=0 }
/B.A.T.M.A.N./ { next }
/Gateway/ { next }
/No gateways/ { next }
{ sub("=>", "true", $0)
sub(" ", "false", $0)
sub("\\(", "", $0)
{ sub("\\(", "", $0)
sub("\\)", "", $0)
sub("\\[", "", $0)
sub("\\[ *", "", $0)
sub("\\]:", "", $0)
sub(" ", " ", $0)
sub("=> ", "true ", $0)
sub(" ", "false ", $0)
printf "<gateway_"i"><selected>"$1"</selected><gateway>"$2"</gateway><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><outgoing_interface>"$5"</outgoing_interface><gw_class>"$6" "$7" "$8"</gw_class></gateway_"i">"
i++
}' /sys/kernel/debug/batman_adv/bat0/gateways)