469b6e8134b81209b085044d284a1a94613b4dc3
[feed/routing.git] / babeld / patches / 600-add-ubus.patch
1 --- a/babeld.c
2 +++ b/babeld.c
3 @@ -54,6 +54,8 @@ THE SOFTWARE.
4 #include "local.h"
5 #include "version.h"
6
7 +#include "ubus.h"
8 +
9 struct timeval now;
10
11 unsigned char myid[8];
12 @@ -521,6 +523,9 @@ main(int argc, char **argv)
13 }
14 }
15
16 + if(ubus_bindings)
17 + babeld_add_ubus();
18 +
19 init_signals();
20 rc = resize_receive_buffer(1500);
21 if(rc < 0)
22 @@ -616,6 +621,8 @@ main(int argc, char **argv)
23 FD_SET(local_sockets[i].fd, &readfds);
24 maxfd = MAX(maxfd, local_sockets[i].fd);
25 }
26 + if(ubus_bindings)
27 + maxfd = babeld_ubus_add_read_sock(&readfds, maxfd);
28 rc = select(maxfd + 1, &readfds, NULL, NULL, &tv);
29 if(rc < 0) {
30 if(errno != EINTR) {
31 @@ -684,6 +691,9 @@ main(int argc, char **argv)
32 i++;
33 }
34
35 + if(ubus_bindings)
36 + babeld_ubus_receive(&readfds);
37 +
38 if(reopening) {
39 kernel_dump_time = now.tv_sec;
40 check_neighbours_timeout = now;
41 --- a/generate-version.sh
42 +++ b/generate-version.sh
43 @@ -10,4 +10,4 @@ else
44 version="unknown"
45 fi
46
47 -echo "#define BABELD_VERSION \"$version\""
48 +echo "#define BABELD_VERSION \"$version-ubus-mod\""
49 --- a/configuration.c
50 +++ b/configuration.c
51 @@ -42,6 +42,8 @@ THE SOFTWARE.
52 #include "hmac.h"
53 #include "configuration.h"
54
55 +#include "ubus.h"
56 +
57 static struct filter *input_filters = NULL;
58 static struct filter *output_filters = NULL;
59 static struct filter *redistribute_filters = NULL;
60 @@ -1036,7 +1038,8 @@ parse_option(int c, gnc_t gnc, void *clo
61 strcmp(token, "daemonise") == 0 ||
62 strcmp(token, "skip-kernel-setup") == 0 ||
63 strcmp(token, "ipv6-subtrees") == 0 ||
64 - strcmp(token, "reflect-kernel-metric") == 0) {
65 + strcmp(token, "reflect-kernel-metric") == 0 ||
66 + strcmp(token, "ubus-bindings") == 0) {
67 int b;
68 c = getbool(c, &b, gnc, closure);
69 if(c < -1)
70 @@ -1054,6 +1057,8 @@ parse_option(int c, gnc_t gnc, void *clo
71 has_ipv6_subtrees = b;
72 else if(strcmp(token, "reflect-kernel-metric") == 0)
73 reflect_kernel_metric = b;
74 + else if(strcmp(token, "ubus-bindings") == 0)
75 + ubus_bindings = b;
76 else
77 abort();
78 } else if(strcmp(token, "protocol-group") == 0) {
79 --- a/local.c
80 +++ b/local.c
81 @@ -42,6 +42,8 @@ THE SOFTWARE.
82 #include "local.h"
83 #include "version.h"
84
85 +#include "ubus.h"
86 +
87 int local_server_socket = -1;
88 struct local_socket local_sockets[MAX_LOCAL_SOCKETS];
89 int num_local_sockets = 0;
90 @@ -191,6 +193,8 @@ local_notify_neighbour(struct neighbour
91 if(local_sockets[i].monitor)
92 local_notify_neighbour_1(&local_sockets[i], neigh, kind);
93 }
94 + if(ubus_bindings)
95 + ubus_notify_neighbour(neigh, kind);
96 }
97
98 static void
99 @@ -228,6 +232,8 @@ local_notify_xroute(struct xroute *xrout
100 if(local_sockets[i].monitor)
101 local_notify_xroute_1(&local_sockets[i], xroute, kind);
102 }
103 + if(ubus_bindings)
104 + ubus_notify_xroute(xroute, kind);
105 }
106
107 static void
108 @@ -273,6 +279,8 @@ local_notify_route(struct babel_route *r
109 if(local_sockets[i].monitor)
110 local_notify_route_1(&local_sockets[i], route, kind);
111 }
112 + if(ubus_bindings)
113 + ubus_notify_route(route, kind);
114 }
115
116 static void
117 --- a/Makefile
118 +++ b/Makefile
119 @@ -11,11 +11,11 @@ LDLIBS = -lrt
120
121 SRCS = babeld.c net.c kernel.c util.c interface.c source.c neighbour.c \
122 route.c xroute.c message.c resend.c configuration.c local.c \
123 - hmac.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
124 + hmac.c ubus.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
125
126 OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \
127 route.o xroute.o message.o resend.o configuration.o local.o \
128 - hmac.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
129 + hmac.o ubus.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
130
131 babeld: $(OBJS)
132 $(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS)