gluon-status-page: rework package to not depend on batman, introduce babel mesh protocol, move neighbors-batadv from statuspage-api to gluon-mesh-batmand-adv

This commit is contained in:
Christof Schulze 2017-12-29 23:00:43 +01:00
parent 4911da56e1
commit f213485917
11 changed files with 107 additions and 79 deletions

View File

@ -13,7 +13,7 @@ define Package/gluon-mesh-batman-adv/common
SECTION:=gluon SECTION:=gluon
CATEGORY:=Gluon CATEGORY:=Gluon
PROVIDES:=gluon-mesh-batman-adv PROVIDES:=gluon-mesh-batman-adv
DEPENDS:=+gluon-core +libgluonutil +gluon-client-bridge +gluon-ebtables +firewall +libiwinfo +kmod-dummy +libnl-tiny +libbatadv DEPENDS:=+gluon-core +libgluonutil +gluon-client-bridge +gluon-ebtables +firewall +libiwinfo +kmod-dummy +libnl-tiny +libbatadv +libjson-c
endef endef
define Package/gluon-mesh-batman-adv-14 define Package/gluon-mesh-batman-adv-14
@ -43,6 +43,8 @@ define Package/gluon-mesh-batman-adv/common/install
$(CP) ./files/* $(1)/ $(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/ $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
$(INSTALL_DIR) $(1)/lib/gluon/respondd $(INSTALL_DIR) $(1)/lib/gluon/respondd
$(INSTALL_DIR) $(1)/lib/gluon/status-page/providers
$(INSTALL_BIN) $(PKG_BUILD_DIR)/neighbours-batadv $(1)/lib/gluon/status-page/providers/
$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/mesh-batman-adv.so $(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/mesh-batman-adv.so
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv $(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv

View File

@ -1,4 +1,4 @@
all: respondd.so all: neighbours-batadv respondd.so
CFLAGS += -Wall CFLAGS += -Wall
@ -9,6 +9,17 @@ ifeq ($(origin PKG_CONFIG), undefined)
endif endif
endif endif
ifeq ($(origin LIBJSONC_CFLAGS) $(origin LIBJSONC_LDLIBS), undefined undefined)
LIBJSONC_NAME ?= json-c
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBJSONC_NAME) 2>/dev/null),)
$(error No $(LIBJSONC_NAME) development libraries found!)
endif
LIBJSONC_CFLAGS += $(shell $(PkG_CONFIG) --cflags $(LIBJSONC_NAME))
LIBJSONC_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBJSONC_NAME))
endif
CFLAGS += $(LIBJSONC_CFLAGS)
LDLIBS += $(LIBJSONC_LDLIBS)
ifeq ($(origin LIBNL_CFLAGS) $(origin LIBNL_LDLIBS), undefined undefined) ifeq ($(origin LIBNL_CFLAGS) $(origin LIBNL_LDLIBS), undefined undefined)
LIBNL_NAME ?= libnl-tiny LIBNL_NAME ?= libnl-tiny
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBNL_NAME) 2>/dev/null),) ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBNL_NAME) 2>/dev/null),)
@ -33,3 +44,7 @@ LDLIBS += $(LIBBATADV_LDLIBS)
respondd.so: respondd.c respondd.so: respondd.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -liwinfo -luci $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -liwinfo -luci
neighbours-batadv: neighbours-batadv.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -D_GNU_SOURCE -o $@ $^ $(LDLIBS)

View File

@ -29,7 +29,6 @@ endef
define Package/gluon-status-page-api/install define Package/gluon-status-page-api/install
$(INSTALL_DIR) $(1)/lib/gluon/status-page/providers $(INSTALL_DIR) $(1)/lib/gluon/status-page/providers
$(INSTALL_BIN) $(PKG_BUILD_DIR)/neighbours-batadv $(1)/lib/gluon/status-page/providers/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/stations $(1)/lib/gluon/status-page/providers/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/stations $(1)/lib/gluon/status-page/providers/
$(INSTALL_DIR) $(1)/lib/gluon/respondd $(INSTALL_DIR) $(1)/lib/gluon/respondd

View File

@ -8,6 +8,6 @@ badrequest() {
echo 'Access-Control-Allow-Origin: *' echo 'Access-Control-Allow-Origin: *'
batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" || badrequest
exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo

View File

@ -8,7 +8,7 @@ badrequest() {
echo 'Access-Control-Allow-Origin: *' echo 'Access-Control-Allow-Origin: *'
batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" || badrequest
CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'" CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'"

View File

@ -29,10 +29,7 @@ ifeq ($(origin LIBBATADV_CFLAGS) $(origin LIBBATADV_LDLIBS), undefined undefined
LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME)) LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME))
endif endif
all: neighbours-batadv stations respondd.so all: stations respondd.so
neighbours-batadv: neighbours-batadv.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LIBNL_CFLAGS) $(LIBBATADV_CFLAGS) $(LDFLAGS) $(LDFLAGS_JSONC) $(LIBNL_LDLIBS) $(LIBBATADV_LDLIBS) -Wall -o $@ $^ $(LDLIBS)
stations: stations.c stations: stations.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -Wall -o $@ $^ $(LDLIBS) -liwinfo $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -Wall -o $@ $^ $(LDLIBS) -liwinfo

View File

@ -77,11 +77,15 @@ function (Helper, SignalGraph, Signal) {
tdSignal.textContent = signal tdSignal.textContent = signal
tdInactive.textContent = Math.round(inactive / 1000) + " s" tdInactive.textContent = Math.round(inactive / 1000) + " s"
} }
if (d.routingMetrics.protocol == "batadv") {
if ("batadv" in d) tdTQ.textContent = "TQ: " + Math.round(d.routingMetrics.tq / 2.55) + " %"
tdTQ.textContent = Math.round(d.batadv.tq / 2.55) + " %" }
else else if (d.routingMetrics.protocol == "babel") {
tdTQ.textContent = "" tdTQ.textContent = "Cost: " + Math.round(d.routingMetrics.cost / 653.53) + " %"
}
else {
tdTQ.textContent = "?PROTO? (" + d.routingMetrics.protocol + ")"
}
if (infoSet) if (infoSet)
return return
@ -111,10 +115,11 @@ function (Helper, SignalGraph, Signal) {
} catch (e) { } catch (e) {
tdDistance.textContent = "" tdDistance.textContent = ""
} }
} else } else {
hostname.textContent = d.id hostname.textContent = d.id
} }
} }
}
function Interface(parent, nodeInfo, iface, stream, mgmtBus) { function Interface(parent, nodeInfo, iface, stream, mgmtBus) {
var colors = graphColors.slice(0) var colors = graphColors.slice(0)
@ -136,7 +141,7 @@ function (Helper, SignalGraph, Signal) {
tr.appendChild(th) tr.appendChild(th)
th = document.createElement("th") th = document.createElement("th")
th.textContent = "TQ" th.textContent = "Metrik"
tr.appendChild(th) tr.appendChild(th)
th = document.createElement("th") th = document.createElement("th")

View File

@ -64,15 +64,16 @@ define([ "bacon"
}) })
var batadvStream = new Streams.Batadv(ip).toProperty({}) var batadvStream = new Streams.Batadv(ip).toProperty({})
var babelStream = new Streams.Babel(ip).toProperty({})
return Bacon.combineWith(combine, wifiStream return Bacon.combineWith(combine, wifiStream
, batadvStream.map(extractIfname) , Bacon.combineWith(Object.assign, batadvStream, babelStream).map(extractIfname)
, nodesBus.map(".macs") , nodesBus.map(".macs")
) )
} }
function combine(wifi, batadv, macs) { function combine(wifi, routingMetrics, macs) {
var interfaces = combineWithIfnames(wifi, batadv) var interfaces = combineWithIfnames(wifi, routingMetrics)
for (var ifname in interfaces) { for (var ifname in interfaces) {
var stations = interfaces[ifname] var stations = interfaces[ifname]
@ -89,8 +90,8 @@ define([ "bacon"
return interfaces return interfaces
} }
function combineWithIfnames(wifi, batadv) { function combineWithIfnames(wifi, routingMetrics) {
var ifnames = Object.keys(wifi).concat(Object.keys(batadv)) var ifnames = Object.keys(wifi).concat(Object.keys(routingMetrics))
// remove duplicates // remove duplicates
ifnames.filter(function(e, i) { ifnames.filter(function(e, i) {
@ -100,21 +101,21 @@ define([ "bacon"
var out = {} var out = {}
ifnames.forEach(function (ifname) { ifnames.forEach(function (ifname) {
out[ifname] = combineWifiBatadv(wifi[ifname], batadv[ifname]) out[ifname] = combineWifiRoutingMetrics(wifi[ifname], routingMetrics[ifname])
}) })
return out return out
} }
function combineWifiBatadv(wifi, batadv) { function combineWifiRoutingMetrics(wifi, routingMetrics) {
var station var station
var out = {} var out = {}
for (station in batadv) { for (station in routingMetrics) {
if (!(station in out)) if (!(station in out))
out[station] = {} out[station] = {}
out[station].batadv = batadv[station] out[station].routingMetrics = routingMetrics[station]
} }
for (station in wifi) { for (station in wifi) {

View File

@ -1,4 +1,7 @@
"use strict" "use strict"
define(["bacon", "lib/helper"], function(Bacon, Helper) { define(["bacon", "lib/helper"], function(Bacon, Helper) {
function nodeInfo(ip, ifname) { function nodeInfo(ip, ifname) {
return Bacon.fromBinder(function (sink) { return Bacon.fromBinder(function (sink) {
@ -43,6 +46,11 @@ define(["bacon", "lib/helper"], function(Bacon, Helper) {
}) })
} }
function babel(ip) {
var url = Helper.buildUrl(ip, "dyn/neighbours-babel")
return simpleStream(url)
}
function batadv(ip) { function batadv(ip) {
var url = Helper.buildUrl(ip, "dyn/neighbours-batadv") var url = Helper.buildUrl(ip, "dyn/neighbours-batadv")
return simpleStream(url) return simpleStream(url)
@ -59,8 +67,9 @@ define(["bacon", "lib/helper"], function(Bacon, Helper) {
} }
return { nodeInfo: nodeInfo return { nodeInfo: nodeInfo
, Batadv: batadv
, Stations: stations , Stations: stations
, Batadv: batadv
, Babel: babel
, Statistics: statistics , Statistics: statistics
} }
}) })