+++ /dev/null
-From 7c053fe7584b7b4fe4effc09624ae620304d6717 Mon Sep 17 00:00:00 2001
-From: Juliusz Chroboczek <jch@irif.fr>
-Date: Tue, 29 Mar 2022 19:26:50 +0200
-Subject: [PATCH] Export add_filters and simplify interface.
-
----
- configuration.c | 32 +++++++++++++++++++++++++-------
- configuration.h | 6 ++++++
- 2 files changed, 31 insertions(+), 7 deletions(-)
-
---- a/configuration.c
-+++ b/configuration.c
-@@ -693,9 +693,26 @@ parse_ifconf(int c, gnc_t gnc, void *clo
- return -2;
- }
-
--static void
--add_filter(struct filter *filter, struct filter **filters)
-+int
-+add_filter(struct filter *filter, int type)
- {
-+ struct filter **filters;
-+ switch(type) {
-+ case FILTER_TYPE_INPUT:
-+ filters = &input_filters;
-+ break;
-+ case FILTER_TYPE_OUTPUT:
-+ filters = &output_filters;
-+ break;
-+ case FILTER_TYPE_REDISTRIBUTE:
-+ filters = &redistribute_filters;
-+ break;
-+ case FILTER_TYPE_INSTALL:
-+ filters = &install_filters;
-+ break;
-+ default:
-+ return -1;
-+ }
- if(*filters == NULL) {
- filter->next = NULL;
- *filters = filter;
-@@ -707,6 +724,7 @@ add_filter(struct filter *filter, struct
- filter->next = NULL;
- f->next = filter;
- }
-+ return 1;
- }
-
- static void
-@@ -1012,7 +1030,7 @@ parse_config_line(int c, gnc_t gnc, void
- c = parse_filter(c, gnc, closure, &filter);
- if(c < -1)
- goto fail;
-- add_filter(filter, &input_filters);
-+ add_filter(filter, FILTER_TYPE_INPUT);
- } else if(strcmp(token, "out") == 0) {
- struct filter *filter;
- if(config_finalised)
-@@ -1020,7 +1038,7 @@ parse_config_line(int c, gnc_t gnc, void
- c = parse_filter(c, gnc, closure, &filter);
- if(c < -1)
- goto fail;
-- add_filter(filter, &output_filters);
-+ add_filter(filter, FILTER_TYPE_OUTPUT);
- } else if(strcmp(token, "redistribute") == 0) {
- struct filter *filter;
- if(config_finalised)
-@@ -1028,7 +1046,7 @@ parse_config_line(int c, gnc_t gnc, void
- c = parse_filter(c, gnc, closure, &filter);
- if(c < -1)
- goto fail;
-- add_filter(filter, &redistribute_filters);
-+ add_filter(filter, FILTER_TYPE_REDISTRIBUTE);
- } else if(strcmp(token, "install") == 0) {
- struct filter *filter;
- if(config_finalised)
-@@ -1036,7 +1054,7 @@ parse_config_line(int c, gnc_t gnc, void
- c = parse_filter(c, gnc, closure, &filter);
- if(c < -1)
- goto fail;
-- add_filter(filter, &install_filters);
-+ add_filter(filter, FILTER_TYPE_INSTALL);
- } else if(strcmp(token, "interface") == 0) {
- struct interface_conf *if_conf;
- c = parse_ifconf(c, gnc, closure, &if_conf);
-@@ -1360,7 +1378,7 @@ finalise_config()
- filter->proto = RTPROT_BABEL_LOCAL;
- filter->plen_le = 128;
- filter->src_plen_le = 128;
-- add_filter(filter, &redistribute_filters);
-+ add_filter(filter, FILTER_TYPE_REDISTRIBUTE);
-
- while(interface_confs) {
- struct interface_conf *if_conf;
---- a/configuration.h
-+++ b/configuration.h
-@@ -29,6 +29,11 @@ THE SOFTWARE.
- #define CONFIG_ACTION_UNMONITOR 4
- #define CONFIG_ACTION_NO 5
-
-+#define FILTER_TYPE_INPUT 0
-+#define FILTER_TYPE_OUTPUT 1
-+#define FILTER_TYPE_REDISTRIBUTE 2
-+#define FILTER_TYPE_INSTALL 3
-+
- struct filter_result {
- unsigned int add_metric; /* allow = 0, deny = INF, metric = <0..INF> */
- unsigned char *src_prefix;
-@@ -60,6 +65,7 @@ void flush_ifconf(struct interface_conf
-
- int parse_config_from_file(const char *filename, int *line_return);
- int parse_config_from_string(char *string, int n, const char **message_return);
-+int add_filter(struct filter *filter, int type);
- void renumber_filters(void);
-
- int input_filter(const unsigned char *id,
rc = select(maxfd + 1, &readfds, NULL, NULL, &tv);
if(rc < 0) {
if(errno != EINTR) {
-@@ -680,6 +687,9 @@ main(int argc, char **argv)
+@@ -681,6 +688,9 @@ main(int argc, char **argv)
i++;
}
+echo "#define BABELD_VERSION \"$version-ubus-mod\""
--- a/configuration.c
+++ b/configuration.c
-@@ -41,6 +41,8 @@ THE SOFTWARE.
- #include "kernel.h"
+@@ -42,6 +42,8 @@ THE SOFTWARE.
+ #include "hmac.h"
#include "configuration.h"
+#include "ubus.h"
static struct filter *input_filters = NULL;
static struct filter *output_filters = NULL;
static struct filter *redistribute_filters = NULL;
-@@ -867,7 +869,8 @@ parse_option(int c, gnc_t gnc, void *clo
+@@ -1029,7 +1031,8 @@ parse_option(int c, gnc_t gnc, void *clo
strcmp(token, "daemonise") == 0 ||
strcmp(token, "skip-kernel-setup") == 0 ||
strcmp(token, "ipv6-subtrees") == 0 ||
int b;
c = getbool(c, &b, gnc, closure);
if(c < -1)
-@@ -885,6 +888,8 @@ parse_option(int c, gnc_t gnc, void *clo
+@@ -1047,6 +1050,8 @@ parse_option(int c, gnc_t gnc, void *clo
has_ipv6_subtrees = b;
else if(strcmp(token, "reflect-kernel-metric") == 0)
reflect_kernel_metric = b;
static void
--- a/Makefile
+++ b/Makefile
-@@ -10,10 +10,10 @@ CFLAGS = $(CDEBUGFLAGS) $(DEFINES) $(EXT
- LDLIBS = -lrt
+@@ -11,11 +11,11 @@ LDLIBS = -lrt
SRCS = babeld.c net.c kernel.c util.c interface.c source.c neighbour.c \
-- route.c xroute.c message.c resend.c configuration.c local.c
-+ route.c xroute.c message.c resend.c configuration.c local.c ubus.c
+ route.c xroute.c message.c resend.c configuration.c local.c \
+- hmac.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
++ hmac.c ubus.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \
-- route.o xroute.o message.o resend.o configuration.o local.o
-+ route.o xroute.o message.o resend.o configuration.o local.o ubus.o
+ route.o xroute.o message.o resend.o configuration.o local.o \
+- hmac.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
++ hmac.o ubus.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
babeld: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS)