From 9ff405092509b8274b929469403980e117af0f1a Mon Sep 17 00:00:00 2001 From: Kasalehlia <kasalehlia@clonejo.de> Date: Sun, 30 May 2021 13:14:51 +0200 Subject: [PATCH] gluon-radvd-filterd: Do not write respondd info if batman server --- package/gluon-radv-filterd/src/respondd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/package/gluon-radv-filterd/src/respondd.c b/package/gluon-radv-filterd/src/respondd.c index bfa9257ae..9a2a9fc0e 100644 --- a/package/gluon-radv-filterd/src/respondd.c +++ b/package/gluon-radv-filterd/src/respondd.c @@ -5,6 +5,8 @@ #include <net/ethernet.h> #include <stdio.h> #include <string.h> +#include <unistd.h> +#include <fcntl.h> #include "mac.h" @@ -37,6 +39,19 @@ static struct json_object * get_radv_filter() { } static struct json_object * respondd_provider_statistics() { + char buf[6]; + int fd = open("/sys/class/net/bat0/mesh/gw_mode", O_RDONLY); + if (fd == -1) { + perror("error opening gateway info file"); + return NULL; + } + memset(buf, 0, sizeof(buf)); + read(fd, buf, sizeof(buf)); + close(fd); + if (strncmp(buf, "server", 6) == 0) { + // We are a batman gateway, do not write gateway6 + return NULL; + } struct json_object *ret = json_object_new_object(); json_object_object_add(ret, "gateway6", get_radv_filter()); -- GitLab