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

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

parent 0e4611f9
*.o
babeld
babeld.html
version.h
......@@ -20,6 +20,15 @@ OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \
babeld: $(OBJS)
$(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
.man.html:
......@@ -49,6 +58,4 @@ uninstall:
-rm -f $(TARGET)$(MANDIR)/man8/babeld.8
clean:
-rm -f babeld babeld.html *.o *~ core TAGS gmon.out
kernel.o: kernel_netlink.c kernel_socket.c
-rm -f babeld babeld.html version.h *.o *~ core TAGS gmon.out
......@@ -53,6 +53,7 @@ THE SOFTWARE.
#include "configuration.h"
#include "local.h"
#include "rule.h"
#include "version.h"
struct timeval now;
......@@ -172,7 +173,7 @@ main(int argc, char **argv)
while(1) {
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)
break;
......@@ -307,6 +308,10 @@ main(int argc, char **argv)
case 'I':
pidfile = optarg;
break;
case 'V':
fprintf(stderr, "%s\n", BABELD_VERSION);
exit(0);
break;
default:
goto usage;
}
......@@ -842,19 +847,20 @@ main(int argc, char **argv)
usage:
fprintf(stderr,
"Syntax: %s "
"[-m multicast_address] [-p port] [-S state-file]\n"
" "
"%s\n"
"Syntax: babeld "
"[-V] [-m multicast_address] [-p port] [-S state-file]\n"
" "
"[-h hello] [-H wired_hello] [-z kind[,factor]]\n"
" "
" "
"[-k metric] [-A metric] [-s] [-l] [-w] [-r] [-u] [-g port]\n"
" "
" "
"[-t table] [-T table] [-c file] [-C statement]\n"
" "
" "
"[-d level] [-D] [-L logfile] [-I pidfile]\n"
" "
" "
"[id] interface...\n",
argv[0]);
BABELD_VERSION);
exit(1);
fail:
......
......@@ -17,6 +17,9 @@ While it is optimised for wireless mesh networks, Babel will also work
efficiently on wired networks.
.SH OPTIONS
.TP
.BI \-V
Display babeld's version and quit.
.TP
.BI \-m " multicast-address"
Specify the link-local multicast address to be used by the protocol.
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.
#include "route.h"
#include "util.h"
#include "local.h"
#include "version.h"
#ifdef NO_LOCAL_INTERFACE
......@@ -266,6 +267,7 @@ local_notify_all_1(int s)
int rc;
struct neighbour *neigh;
const char *header = "BABEL 0.0\n";
char buf[512];
struct xroute_stream *xroutes;
struct route_stream *routes;
......@@ -273,6 +275,13 @@ local_notify_all_1(int s)
if(rc < 0)
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);
FOR_ALL_NEIGHBOURS(neigh) {
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