batman-adv-visdata: remove package
batman-adv-visdata is not used anymore.
This commit is contained in:
parent
fd06c7d67d
commit
93bbd165ee
|
@ -1,40 +0,0 @@
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=batman-adv-visdata
|
|
||||||
PKG_VERSION:=1
|
|
||||||
|
|
||||||
PKG_LICENSE:=BSD-2-Clause
|
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define Package/batman-adv-visdata
|
|
||||||
SECTION:=net
|
|
||||||
CATEGORY:=Network
|
|
||||||
DEPENDS:=
|
|
||||||
TITLE:=Pulls the batman-adv originators and transtable_global tables out of the kernel periodically
|
|
||||||
endef
|
|
||||||
|
|
||||||
|
|
||||||
define Build/Prepare
|
|
||||||
mkdir -p $(PKG_BUILD_DIR)
|
|
||||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
CFLAGS="$(TARGET_CFLAGS)" CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/batman-adv-visdata/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batman-adv-visdata $(1)/usr/sbin/
|
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
|
||||||
$(INSTALL_BIN) ./files/batman-adv-visdata.init $(1)/etc/init.d/batman-adv-visdata
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,batman-adv-visdata))
|
|
|
@ -1,22 +0,0 @@
|
||||||
#!/bin/sh /etc/rc.common
|
|
||||||
|
|
||||||
START=98
|
|
||||||
USE_PROCD=1
|
|
||||||
|
|
||||||
start_service() {
|
|
||||||
include /lib/functions
|
|
||||||
|
|
||||||
local meshes
|
|
||||||
|
|
||||||
add_mesh() {
|
|
||||||
meshes="$meshes $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
config_load batman-adv
|
|
||||||
config_foreach add_mesh 'mesh'
|
|
||||||
|
|
||||||
procd_open_instance
|
|
||||||
procd_set_param command /usr/sbin/batman-adv-visdata $meshes
|
|
||||||
procd_set_param respawn ${threshold:-20} ${timeout:-5} ${retry:-3}
|
|
||||||
procd_close_instance
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
all: batman-adv-visdata
|
|
||||||
|
|
||||||
batman-adv-visdata: batman-adv-visdata.c
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Wall -o $@ $^ $(LDLIBS)
|
|
|
@ -1,99 +0,0 @@
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* batadv-vis updates its originators every 10s
|
|
||||||
* We choose a bigger interval to make reboots even more unlikely,
|
|
||||||
* and make our interval coprime with batadv-vis's
|
|
||||||
*/
|
|
||||||
#define UPDATE_INTERVAL 19
|
|
||||||
|
|
||||||
#define INPUT_DIR "/sys/kernel/debug/batman_adv"
|
|
||||||
#define OUTPUT_DIR "/tmp/batman-adv-visdata"
|
|
||||||
|
|
||||||
#define ORIGINATORS "originators"
|
|
||||||
#define TRANSTABLE_GLOBAL "transtable_global"
|
|
||||||
|
|
||||||
|
|
||||||
static bool copy_file(const char *src, const char *dst) {
|
|
||||||
FILE *input = NULL, *output = NULL;
|
|
||||||
|
|
||||||
input = fopen(src, "r");
|
|
||||||
if (!input)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
output = fopen(dst, "w");
|
|
||||||
if (!output)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
while (!feof(input)) {
|
|
||||||
if (ferror(input))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
char buf[1024];
|
|
||||||
size_t r = fread(buf, 1, sizeof(buf), input);
|
|
||||||
if (!r)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!fwrite(buf, r, 1, output))
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(input);
|
|
||||||
fclose(output);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (input)
|
|
||||||
fclose(input);
|
|
||||||
if (output)
|
|
||||||
fclose(output);
|
|
||||||
|
|
||||||
unlink(dst);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_file(const char *mesh, const char *file) {
|
|
||||||
char src[strlen(INPUT_DIR) + 1 + strlen(mesh) + 1 + strlen(file) + 1];
|
|
||||||
char dst[strlen(OUTPUT_DIR) + 1 + strlen(mesh) + 1 + strlen(file) + 1];
|
|
||||||
char tmp[sizeof(dst) + 4];
|
|
||||||
|
|
||||||
snprintf(src, sizeof(src), "%s/%s/%s", INPUT_DIR, mesh, file);
|
|
||||||
snprintf(dst, sizeof(dst), "%s/%s/%s", OUTPUT_DIR, mesh, file);
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s.new", dst);
|
|
||||||
|
|
||||||
if (copy_file(src, tmp))
|
|
||||||
rename(tmp, dst);
|
|
||||||
else
|
|
||||||
unlink(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_mesh(const char *mesh) {
|
|
||||||
char dir[strlen(OUTPUT_DIR) + 1 + strlen(mesh) + 1];
|
|
||||||
|
|
||||||
snprintf(dir, sizeof(dir), "%s/%s", OUTPUT_DIR, mesh);
|
|
||||||
mkdir(dir, 0777);
|
|
||||||
|
|
||||||
handle_file(mesh, ORIGINATORS);
|
|
||||||
handle_file(mesh, TRANSTABLE_GLOBAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
system("rm -rf " OUTPUT_DIR "; mkdir -p " OUTPUT_DIR);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
int i;
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
handle_mesh(argv[i]);
|
|
||||||
|
|
||||||
sleep(UPDATE_INTERVAL);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue