Commit 60e20d98 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Generate babeld's version automatically, display in control interface.

parent 0e4611f9
*.o *.o
babeld babeld
babeld.html babeld.html
version.h
...@@ -20,6 +20,15 @@ OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \ ...@@ -20,6 +20,15 @@ OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \
babeld: $(OBJS) babeld: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS) $(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS)
babeld.o: babeld.c version.h
local.o: local.c version.h
kernel.o: kernel_netlink.c kernel_socket.c
version.h:
./generate-version.sh > version.h
.SUFFIXES: .man .html .SUFFIXES: .man .html
.man.html: .man.html:
...@@ -49,6 +58,4 @@ uninstall: ...@@ -49,6 +58,4 @@ uninstall:
-rm -f $(TARGET)$(MANDIR)/man8/babeld.8 -rm -f $(TARGET)$(MANDIR)/man8/babeld.8
clean: clean:
-rm -f babeld babeld.html *.o *~ core TAGS gmon.out -rm -f babeld babeld.html version.h *.o *~ core TAGS gmon.out
kernel.o: kernel_netlink.c kernel_socket.c
...@@ -53,6 +53,7 @@ THE SOFTWARE. ...@@ -53,6 +53,7 @@ THE SOFTWARE.
#include "configuration.h" #include "configuration.h"
#include "local.h" #include "local.h"
#include "rule.h" #include "rule.h"
#include "version.h"
struct timeval now; struct timeval now;
...@@ -172,7 +173,7 @@ main(int argc, char **argv) ...@@ -172,7 +173,7 @@ main(int argc, char **argv)
while(1) { while(1) {
opt = getopt(argc, argv, opt = getopt(argc, argv,
"m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:"); "m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:V");
if(opt < 0) if(opt < 0)
break; break;
...@@ -307,6 +308,10 @@ main(int argc, char **argv) ...@@ -307,6 +308,10 @@ main(int argc, char **argv)
case 'I': case 'I':
pidfile = optarg; pidfile = optarg;
break; break;
case 'V':
fprintf(stderr, "%s\n", BABELD_VERSION);
exit(0);
break;
default: default:
goto usage; goto usage;
} }
...@@ -842,19 +847,20 @@ main(int argc, char **argv) ...@@ -842,19 +847,20 @@ main(int argc, char **argv)
usage: usage:
fprintf(stderr, fprintf(stderr,
"Syntax: %s " "%s\n"
"[-m multicast_address] [-p port] [-S state-file]\n" "Syntax: babeld "
" " "[-V] [-m multicast_address] [-p port] [-S state-file]\n"
" "
"[-h hello] [-H wired_hello] [-z kind[,factor]]\n" "[-h hello] [-H wired_hello] [-z kind[,factor]]\n"
" " " "
"[-k metric] [-A metric] [-s] [-l] [-w] [-r] [-u] [-g port]\n" "[-k metric] [-A metric] [-s] [-l] [-w] [-r] [-u] [-g port]\n"
" " " "
"[-t table] [-T table] [-c file] [-C statement]\n" "[-t table] [-T table] [-c file] [-C statement]\n"
" " " "
"[-d level] [-D] [-L logfile] [-I pidfile]\n" "[-d level] [-D] [-L logfile] [-I pidfile]\n"
" " " "
"[id] interface...\n", "[id] interface...\n",
argv[0]); BABELD_VERSION);
exit(1); exit(1);
fail: fail:
......
...@@ -17,6 +17,9 @@ While it is optimised for wireless mesh networks, Babel will also work ...@@ -17,6 +17,9 @@ While it is optimised for wireless mesh networks, Babel will also work
efficiently on wired networks. efficiently on wired networks.
.SH OPTIONS .SH OPTIONS
.TP .TP
.BI \-V
Display babeld's version and quit.
.TP
.BI \-m " multicast-address" .BI \-m " multicast-address"
Specify the link-local multicast address to be used by the protocol. Specify the link-local multicast address to be used by the protocol.
The default is The default is
......
#!/bin/sh
set -e
if [ -d .git ] ; then
version="$(git describe)"
elif [ -f version ] ; then
version="$(cat version)"
else
version="(unknown version)"
fi
echo "#define BABELD_VERSION \"$version\""
...@@ -36,6 +36,7 @@ THE SOFTWARE. ...@@ -36,6 +36,7 @@ THE SOFTWARE.
#include "route.h" #include "route.h"
#include "util.h" #include "util.h"
#include "local.h" #include "local.h"
#include "version.h"
#ifdef NO_LOCAL_INTERFACE #ifdef NO_LOCAL_INTERFACE
...@@ -266,6 +267,7 @@ local_notify_all_1(int s) ...@@ -266,6 +267,7 @@ local_notify_all_1(int s)
int rc; int rc;
struct neighbour *neigh; struct neighbour *neigh;
const char *header = "BABEL 0.0\n"; const char *header = "BABEL 0.0\n";
char buf[512];
struct xroute_stream *xroutes; struct xroute_stream *xroutes;
struct route_stream *routes; struct route_stream *routes;
...@@ -273,6 +275,13 @@ local_notify_all_1(int s) ...@@ -273,6 +275,13 @@ local_notify_all_1(int s)
if(rc < 0) if(rc < 0)
goto fail; goto fail;
rc = snprintf(buf, 512, "version %s\n", BABELD_VERSION);
if(rc < 0 || rc >= 512)
goto fail;
rc = write_timeout(s, buf, rc);
if(rc < 0)
goto fail;
local_notify_self_1(s); local_notify_self_1(s);
FOR_ALL_NEIGHBOURS(neigh) { FOR_ALL_NEIGHBOURS(neigh) {
local_notify_neighbour_1(s, neigh, LOCAL_ADD); local_notify_neighbour_1(s, neigh, LOCAL_ADD);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment