From 89ad84637588378a68b77d035e91234d229d7f26 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Sun, 4 Feb 2018 21:51:37 +0100 Subject: [PATCH] routertools: Use float for neighbor and gateway quality This enables support for BATMAN V. This requires changes to the MySQL database! Signed-off-by: Adrian Schmutzler --- ffmap/db/routers.py | 8 ++++---- ffmap/routertools.py | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ffmap/db/routers.py b/ffmap/db/routers.py index 5bd4aba..fcb45d3 100755 --- a/ffmap/db/routers.py +++ b/ffmap/db/routers.py @@ -135,7 +135,7 @@ mysql.execute(""" CREATE TABLE router_gw ( `router` mediumint(8) UNSIGNED NOT NULL, `mac` char(17) COLLATE utf8_unicode_ci NOT NULL, - `quality` smallint(6) NOT NULL, + `quality` float NOT NULL, `nexthop` char(17) COLLATE utf8_unicode_ci DEFAULT NULL, `netif` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `gw_class` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -166,7 +166,7 @@ mysql.execute(""" `router` mediumint(8) UNSIGNED NOT NULL, `mac` char(17) COLLATE utf8_unicode_ci NOT NULL, `netif` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `quality` smallint(6) NOT NULL, + `quality` float NOT NULL, `type` varchar(10) COLLATE utf8_unicode_ci DEFAULT 'l2' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci """) @@ -232,7 +232,7 @@ mysql.execute(""" `time` int(11) NOT NULL, `router` mediumint(8) UNSIGNED NOT NULL, `mac` char(17) COLLATE utf8_unicode_ci NOT NULL, - `quality` smallint(6) NOT NULL + `quality` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci """) @@ -247,7 +247,7 @@ mysql.execute(""" `time` int(11) NOT NULL, `router` mediumint(8) UNSIGNED NOT NULL, `mac` char(17) COLLATE utf8_unicode_ci NOT NULL, - `quality` smallint(6) NOT NULL + `quality` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci """) diff --git a/ffmap/routertools.py b/ffmap/routertools.py index 7c19843..22b0520 100644 --- a/ffmap/routertools.py +++ b/ffmap/routertools.py @@ -780,7 +780,6 @@ def parse_nodewatcher_xml(xml): o_nexthop = evalxpath(originator,"nexthop/text()") # mac is the mac of the neighbour w2/5mesh if # (which might also be called wlan0-1) - o_link_quality = evalxpath(originator,"link_quality/text()") o_out_if = evalxpath(originator,"outgoing_interface/text()") if o_mac.upper() == o_nexthop.upper(): # skip vpn server @@ -793,7 +792,7 @@ def parse_nodewatcher_xml(xml): neighbour = { "mac": o_mac.lower(), "netif": o_out_if, - "quality": int(o_link_quality), + "quality": evalxpathfloat(originator,"link_quality/text()"), "type": "l2" } router_update["neighbours"].append(neighbour) @@ -817,7 +816,7 @@ def parse_nodewatcher_xml(xml): if gw["quality"].startswith("false"): gw["quality"] = gw["quality"][5:] if gw["quality"]: - gw["quality"] = int(gw["quality"]) + gw["quality"] = float(gw["quality"]) else: gw["quality"] = 0 if gw["netif"]=="false":