summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bsd/tun.c8
-rwxr-xr-xsrc/configure13
-rw-r--r--src/options.c6
-rw-r--r--src/sig_handler.c8
-rw-r--r--src/uanytun.c14
-rw-r--r--src/udp.c4
6 files changed, 37 insertions, 16 deletions
diff --git a/src/bsd/tun.c b/src/bsd/tun.c
index a469c58..ceb54a1 100644
--- a/src/bsd/tun.c
+++ b/src/bsd/tun.c
@@ -46,14 +46,15 @@
* files in the program, then also delete it here.
*/
+#define _GNU_SOURCE
+#include <stdio.h>
+
#include "datatypes.h"
#include "tun.h"
#include "tun_helper.h"
-#include "log.h"
-
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
@@ -69,6 +70,9 @@
#include <netinet/ip.h>
#define DEVICE_FILE_MAX 255
+#include "log.h"
+#include "sysexec.h"
+
int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, const char* ifcfg_addr, u_int16_t ifcfg_prefix)
{
if(!dev)
diff --git a/src/configure b/src/configure
index 16d5cc7..3b7b1b4 100755
--- a/src/configure
+++ b/src/configure
@@ -239,7 +239,7 @@ LDFLAGS := $LDFLAGS
STRIP := strip
INSTALL := install
-PREFIX := $PREFIX
+prefix := $PREFIX
SBINDIR := $SBINDIR
ETCDIR := $ETCDIR
EOF
@@ -263,12 +263,13 @@ else
fi
VERSION=`cat ../version`
-if which svn >/dev/null; then
- SVN_REV=`svn info 2> /dev/null | grep "^Revision: " | awk '{print($2)}'`
- if [ -n "$SVN_REV" ]; then
- VERSION="$VERSION (svn$SVN_REV)"
- fi
+if which git >/dev/null; then
+ GIT_HASH=`git rev-parse HEAD 2> /dev/null`
+ if [ -n "$GIT_HASH" ]; then
+ VERSION="$VERSION (git $GIT_HASH)"
+ fi
fi
+
HOSTNAME=`hostname`
DATE=`date +"%d.%m.%Y %H:%M:%S %Z"`
diff --git a/src/options.c b/src/options.c
index f12eb1b..015a9a5 100644
--- a/src/options.c
+++ b/src/options.c
@@ -484,7 +484,13 @@ void options_print_usage()
void options_print_version()
{
printf("%s\n", VERSION_STRING_0);
+#if defined(__clang__)
+ printf("%s, using CLANG %s\n", VERSION_STRING_1, __clang_version__);
+#elif defined(__GNUC__)
+ printf("%s, using GCC %d.%d.%d\n", VERSION_STRING_1, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
+#else
printf("%s\n", VERSION_STRING_1);
+#endif
}
void options_print(options_t* opt)
diff --git a/src/sig_handler.c b/src/sig_handler.c
index 5de168e..f23d070 100644
--- a/src/sig_handler.c
+++ b/src/sig_handler.c
@@ -139,10 +139,10 @@ int signal_handle()
for(sig=1; sig < NSIG; ++sig) {
if(sigismember(&set, sig)) {
switch(sig) {
- case SIGINT: log_printf(NOTICE, "SIG-Int caught, exitting"); return_value = 1; break;
- case SIGQUIT: log_printf(NOTICE, "SIG-Quit caught, exitting"); return_value = 1; break;
- case SIGTERM: log_printf(NOTICE, "SIG-Term caught, exitting"); return_value = 1; break;
- case SIGHUP: log_printf(NOTICE, "SIG-Hup caught"); return_value = 2; break;
+ case SIGINT: log_printf(NOTICE, "SIG-Int caught, exitting"); return_value = SIGINT; break;
+ case SIGQUIT: log_printf(NOTICE, "SIG-Quit caught, exitting"); return_value = SIGQUIT; break;
+ case SIGTERM: log_printf(NOTICE, "SIG-Term caught, exitting"); return_value = SIGTERM; break;
+ case SIGHUP: log_printf(NOTICE, "SIG-Hup caught"); return_value = SIGHUP; break;
case SIGUSR1: log_printf(NOTICE, "SIG-Usr1 caught"); break;
case SIGUSR2: log_printf(NOTICE, "SIG-Usr2 caught"); break;
default: log_printf(WARNING, "unknown signal %d caught, ignoring", sig); break;
diff --git a/src/uanytun.c b/src/uanytun.c
index 93ddf63..c5d6291 100644
--- a/src/uanytun.c
+++ b/src/uanytun.c
@@ -52,6 +52,10 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <sys/select.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <signal.h>
#include "log.h"
#include "sig_handler.h"
@@ -263,9 +267,8 @@ int main_loop(tun_device_t* dev, udp_t* sock, options_t* opt)
if(FD_ISSET(sig_fd, &readyfds)) {
return_value = signal_handle();
- if(return_value == 1)
- break;
- else if(return_value == 2) {
+ if(return_value == SIGINT || return_value == SIGQUIT || return_value == SIGTERM) break;
+ else if(return_value == SIGHUP) {
seq_win_clear(&seq_win);
seq_nr = 0;
log_printf(NOTICE, "sequence window cleared");
@@ -452,8 +455,11 @@ int main(int argc, char* argv[])
log_printf(NOTICE, "normal shutdown");
else if(ret < 0)
log_printf(NOTICE, "shutdown after error");
- else
+ else {
log_printf(NOTICE, "shutdown after signal");
+ log_close();
+ kill(getpid(), ret);
+ }
log_close();
diff --git a/src/udp.c b/src/udp.c
index 75ee6ab..568f738 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -65,6 +65,10 @@
#include <arpa/inet.h>
#include <netinet/in.h>
+#ifndef AI_ADDRCONFIG
+#define AI_ADDRCONFIG 0
+#endif
+
static int udp_resolv_local(udp_t* sock, const char* local_addr, const char* port, resolv_addr_type_t resolv_type, unsigned int* idx)
{
struct addrinfo hints, *res;