From e40f7bf92dbd3d51a1a767e2787b6686fa0e9192 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Fri, 13 Apr 2018 20:44:52 +0200 Subject: [PATCH 1/3] gluon-status-page, gluon-mesh-batman-adv: make statuspage mesh-protocol-agnostic --- .../Makefile | 20 ++++++++++ .../src/Makefile | 40 +++++++++++++++++++ .../src/neighbours-batadv.c | 0 package/gluon-status-page/Makefile | 4 +- .../www/cgi-bin/dyn/neighbours-nodeinfo | 2 +- .../status-page/www/cgi-bin/dyn/stations | 2 +- package/gluon-status-page/src/Makefile | 14 +------ 7 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 package/gluon-status-page-mesh-batman-adv/Makefile create mode 100644 package/gluon-status-page-mesh-batman-adv/src/Makefile rename package/{gluon-status-page => gluon-status-page-mesh-batman-adv}/src/neighbours-batadv.c (100%) diff --git a/package/gluon-status-page-mesh-batman-adv/Makefile b/package/gluon-status-page-mesh-batman-adv/Makefile new file mode 100644 index 00000000..4d2ed8f0 --- /dev/null +++ b/package/gluon-status-page-mesh-batman-adv/Makefile @@ -0,0 +1,20 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-status-page-mesh-batman-adv +PKG_VERSION:=1 + +include ../gluon.mk + +define Package/gluon-status-page-mesh-batman-adv + TITLE:=Batman-data provider for gluon-status-page + DEPENDS:=+gluon-status-page gluon-mesh-batman-adv +libnl-tiny +libbatadv +libjson-c +endef + +define Package/gluon-status-page-mesh-batman-adv/install + $(Gluon/Build/Install) + + $(INSTALL_DIR) $(1)/lib/gluon/status-page/providers + $(INSTALL_BIN) $(PKG_BUILD_DIR)/neighbours-batadv $(1)/lib/gluon/status-page/providers/ +endef + +$(eval $(call BuildPackageGluon,gluon-status-page-mesh-batman-adv)) diff --git a/package/gluon-status-page-mesh-batman-adv/src/Makefile b/package/gluon-status-page-mesh-batman-adv/src/Makefile new file mode 100644 index 00000000..5fb4ef4f --- /dev/null +++ b/package/gluon-status-page-mesh-batman-adv/src/Makefile @@ -0,0 +1,40 @@ +all: neighbours-batadv + +CFLAGS += -Wall -D_GNU_SOURCE + +ifeq ($(origin PKG_CONFIG), undefined) + PKG_CONFIG = pkg-config + ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),) + $(error $(PKG_CONFIG) not found) + endif +endif + +ifeq ($(origin LIBNL_CFLAGS) $(origin LIBNL_LDLIBS), undefined undefined) + LIBNL_NAME ?= libnl-tiny + ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBNL_NAME) 2>/dev/null),) + $(error No $(LIBNL_NAME) development libraries found!) + endif + LIBNL_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBNL_NAME)) + LIBNL_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBNL_NAME)) +endif +CFLAGS += $(LIBNL_CFLAGS) +LDLIBS += $(LIBNL_LDLIBS) + +CFLAGS_JSONC = $(shell pkg-config --cflags json-c) +LDFLAGS_JSONC = $(shell pkg-config --libs json-c) + + +ifeq ($(origin LIBBATADV_CFLAGS) $(origin LIBBATADV_LDLIBS), undefined undefined) + LIBBATADV_NAME ?= libbatadv + ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBBATADV_NAME) 2>/dev/null),) + $(error No $(LIBBATADV_NAME) development libraries found!) + endif + LIBBATADV_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBBATADV_NAME)) + LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME)) +endif +CFLAGS += $(LIBBATADV_CFLAGS) +LDLIBS += $(LIBBATADV_LDLIBS) + +neighbours-batadv: neighbours-batadv.c + $(CC) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -o $@ $^ $(LDLIBS) + diff --git a/package/gluon-status-page/src/neighbours-batadv.c b/package/gluon-status-page-mesh-batman-adv/src/neighbours-batadv.c similarity index 100% rename from package/gluon-status-page/src/neighbours-batadv.c rename to package/gluon-status-page-mesh-batman-adv/src/neighbours-batadv.c diff --git a/package/gluon-status-page/Makefile b/package/gluon-status-page/Makefile index d17ce2da..923f68c7 100644 --- a/package/gluon-status-page/Makefile +++ b/package/gluon-status-page/Makefile @@ -7,14 +7,14 @@ include ../gluon.mk define Package/gluon-status-page TITLE:=Status page showing information about the node - DEPENDS:=+gluon-web +gluon-neighbour-info +gluon-respondd +uhttpd +sse-multiplex +libiwinfo +libjson-c +libnl-tiny +libubus-lua +libbatadv + DEPENDS:=+gluon-web +gluon-neighbour-info +gluon-respondd +uhttpd +sse-multiplex +libiwinfo +libjson-c +libnl-tiny +libubus-lua endef define Package/gluon-status-page/install $(Gluon/Build/Install) $(INSTALL_DIR) $(1)/lib/gluon/status-page/providers - $(INSTALL_BIN) $(PKG_BUILD_DIR)/{neighbours-batadv,stations} $(1)/lib/gluon/status-page/providers/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/stations $(1)/lib/gluon/status-page/providers/ $(INSTALL_DIR) $(1)/lib/gluon/status-page/view/ $(LN) /lib/gluon/web/i18n $(1)/lib/gluon/status-page/ diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo index 55c46fa6..5b85bfca 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo @@ -6,6 +6,6 @@ badrequest() { exit 1 } -( batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest +( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations index 32669b4a..e905d75e 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations @@ -6,7 +6,7 @@ badrequest() { exit 1 } -( batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest +( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'" diff --git a/package/gluon-status-page/src/Makefile b/package/gluon-status-page/src/Makefile index bf5141a7..a0a14e16 100644 --- a/package/gluon-status-page/src/Makefile +++ b/package/gluon-status-page/src/Makefile @@ -20,19 +20,7 @@ endif CFLAGS_JSONC = $(shell pkg-config --cflags json-c) LDFLAGS_JSONC = $(shell pkg-config --libs json-c) -ifeq ($(origin LIBBATADV_CFLAGS) $(origin LIBBATADV_LDLIBS), undefined undefined) - LIBBATADV_NAME ?= libbatadv - ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBBATADV_NAME) 2>/dev/null),) - $(error No $(LIBBATADV_NAME) development libraries found!) - endif - LIBBATADV_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBBATADV_NAME)) - LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME)) -endif - -all: neighbours-batadv stations - -neighbours-batadv: neighbours-batadv.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LIBNL_CFLAGS) $(LIBBATADV_CFLAGS) $(LDFLAGS) $(LDFLAGS_JSONC) $(LIBNL_LDLIBS) $(LIBBATADV_LDLIBS) -Wall -o $@ $^ $(LDLIBS) +all: stations stations: stations.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -Wall -o $@ $^ $(LDLIBS) -liwinfo From e015999da03689ae538b1935bdee8553f097ad37 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Sat, 14 Apr 2018 23:44:39 +0200 Subject: [PATCH 2/3] gluon-core, gluon-status-page, gluon-l3roamd: introduce script gluon-list-mesh-ifs that lists all currently active mesh interfaces --- package/gluon-core/files/usr/bin/gluon-list-mesh-interfaces | 2 ++ package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd | 2 +- .../lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo | 2 +- .../files/lib/gluon/status-page/www/cgi-bin/dyn/stations | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100755 package/gluon-core/files/usr/bin/gluon-list-mesh-interfaces diff --git a/package/gluon-core/files/usr/bin/gluon-list-mesh-interfaces b/package/gluon-core/files/usr/bin/gluon-list-mesh-interfaces new file mode 100755 index 00000000..9b450f90 --- /dev/null +++ b/package/gluon-core/files/usr/bin/gluon-list-mesh-interfaces @@ -0,0 +1,2 @@ +#!/bin/sh +ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device" diff --git a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd index 0a51bde9..9fe597b9 100755 --- a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd +++ b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd @@ -10,7 +10,7 @@ start_service () { procd_set_param stdout 1 procd_set_param stderr 1 procd_set_param respawn ${respawn_threshold:-3660} ${respawn_timeout:-5} ${respawn_retry:-0} - interfaces=$(for dev in $( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device");do echo " -m $dev"; done; + interfaces=$(for dev in $(gluon-list-mesh-interfaces);do echo " -m $dev"; done; [ "$(ifstatus client | jsonfilter -e "@.up")" = "true" ] && echo " -i local-node") procd_set_param command "$PROG" -s /var/run/l3roamd.sock -p $(lua -e 'print(require("gluon.site").prefix6())') $interfaces -t 254 -a $(uci get network.loopback.ip6addr | cut -d/ -f1) -4 0:0:0:0:0:ffff::/96 -b br-client procd_close_instance diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo index 5b85bfca..43ece633 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo @@ -6,6 +6,6 @@ badrequest() { exit 1 } -( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest +( gluon-list-mesh-interfaces | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations index e905d75e..afb3f6fe 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations @@ -6,7 +6,7 @@ badrequest() { exit 1 } -( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest +( gluon-list-mesh-interfaces | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'" From fa57e2ae7b569acb190267eccb133de4463d2d5a Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Sun, 15 Apr 2018 12:32:22 +0200 Subject: [PATCH 3/3] gluon-status-page: reduce usage of absolute paths in cgi-bin scripts neighbours-nodeinfo and stations --- .../lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo | 2 +- .../files/lib/gluon/status-page/www/cgi-bin/dyn/stations | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo index 43ece633..3f149100 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-nodeinfo @@ -8,4 +8,4 @@ badrequest() { ( gluon-list-mesh-interfaces | grep -qxF "$QUERY_STRING" ) 2>/dev/null || badrequest -exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo +exec gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations index afb3f6fe..5ff1f125 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/dyn/stations @@ -10,4 +10,4 @@ badrequest() { CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'" -exec /usr/sbin/sse-multiplex "$CMD" +exec sse-multiplex "$CMD"