summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--llmnr-query.c16
-rw-r--r--llmnrd.c21
3 files changed, 37 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 14c93cb..3b06b95 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
#
# Copyright (C) 2014-2015 Tobias Klauser <tklauser@distanz.ch>
+VERSION = 0.1-rc1
+
# llmnrd binary
D_P = llmnrd
D_OBJS = llmnr.o iface.o socket.o util.o llmnrd.o
@@ -18,12 +20,15 @@ INSTALL = install
CFLAGS ?= -W -Wall -O2
LDFLAGS ?=
+CFLAGS += -DVERSION_STRING=\"v$(VERSION)\"
+
ifeq ($(DEBUG), 1)
CFLAGS += -g -DDEBUG
endif
-CCQ = @echo " CC $<" && $(CC)
-LDQ = @echo " LD $@" && $(CC)
+Q ?= @
+CCQ = $(Q)echo " CC $<" && $(CC)
+LDQ = $(Q)echo " LD $@" && $(CC)
prefix ?= /usr/local
diff --git a/llmnr-query.c b/llmnr-query.c
index 5ee07ec..e3565e6 100644
--- a/llmnr-query.c
+++ b/llmnr-query.c
@@ -35,12 +35,13 @@
#include "log.h"
#include "pkt.h"
-static const char *short_ops = "c:i:p:T:h";
+static const char *short_ops = "c:i:p:T:hV";
static const struct option long_opts[] = {
{ "count", required_argument, NULL, 'c' },
{ "interval", required_argument, NULL, 'i' },
{ "type", required_argument, NULL, 'T' },
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 },
};
@@ -51,10 +52,19 @@ static void __noreturn usage_and_exit(int status)
" -c, --count number of queries to send (default: 1)\n"
" -i, --interval interval between queries in ms (default: 500)\n"
" -T, --type LLMNR query type, must be one of A, AAAA, ANY (default: A)\n"
- " -h, --help show this help and exit");
+ " -h, --help show this help and exit\n"
+ " -V, --version show version information and exit\n");
exit(status);
}
+static void __noreturn version_and_exit(void)
+{
+ fprintf(stdout, "llmnr-query %s\n"
+ "Copyright (C) 2015 Tobias Klauser <tklauser@distanz.ch>\n"
+ "Licensed unter the GNU General Public License, version 2\n", VERSION_STRING);
+ exit(EXIT_SUCCESS);
+}
+
static const char *query_type(uint16_t qtype)
{
switch (qtype) {
@@ -98,6 +108,8 @@ int main(int argc, char **argv)
usage_and_exit(EXIT_FAILURE);
}
break;
+ case 'V':
+ version_and_exit();
case 'h':
usage_and_exit(EXIT_SUCCESS);
default:
diff --git a/llmnrd.c b/llmnrd.c
index 80cf6cc..79a237d 100644
--- a/llmnrd.c
+++ b/llmnrd.c
@@ -37,12 +37,13 @@
#include "llmnr.h"
#include "llmnr-packet.h"
-static const char *short_opts = "H:p:dh";
+static const char *short_opts = "H:p:dhV";
static const struct option long_opts[] = {
{ "hostname", required_argument, NULL, 'H' },
{ "port", required_argument, NULL, 'p' },
{ "daemonize", no_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 },
};
@@ -53,11 +54,20 @@ static void __noreturn usage_and_exit(int status)
" -H, --hostname <name> set hostname to respond with (default: system hostname)\n"
" -p, --port <number> set port number to listen on (default: %d)\n"
" -d, --daemonize run as daemon in the background\n"
- " -h, --help show this help and exit\n",
+ " -h, --help show this help and exit\n"
+ " -V, --version show version information and exit\n",
LLMNR_UDP_PORT);
exit(status);
}
+static void __noreturn version_and_exit(void)
+{
+ fprintf(stdout, "llmnrd %s\n"
+ "Copyright (C) 2014-2015 Tobias Klauser <tklauser@distanz.ch>\n"
+ "Licensed unter the GNU General Public License, version 2\n", VERSION_STRING);
+ exit(EXIT_SUCCESS);
+}
+
static void signal_handler(int sig)
{
switch (sig) {
@@ -114,11 +124,12 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
port = num_arg;
+ case 'V':
+ version_and_exit();
case 'h':
- ret = EXIT_SUCCESS;
- /* fall through */
+ usage_and_exit(EXIT_SUCCESS);
default:
- usage_and_exit(ret);
+ usage_and_exit(EXIT_FAILURE);
}
}