Imported Upstream version 0.3.6 upstream/0.3.6
authorDarshaka Pathirana <dpat@syn-net.org>
Thu, 26 Jan 2017 01:45:45 +0000 (02:45 +0100)
committerDarshaka Pathirana <dpat@syn-net.org>
Thu, 26 Jan 2017 01:45:45 +0000 (02:45 +0100)
12 files changed:
.gitignore [new file with mode: 0644]
ChangeLog
README
doc/uanytun.8
src/bsd/tun.c
src/configure
src/options.c
src/seq_window.c
src/sig_handler.c
src/uanytun.c
src/udp.c
version

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..5efe091
--- /dev/null
@@ -0,0 +1,8 @@
+doc/uanytun.8.xml
+src/*.o
+src/*.d
+src/*.d.*
+src/tun.c
+src/include.mk
+src/version.h
+src/uanytun
index 8b9c45a..e295fc0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017.01.04 -- Version 0.3.6
+
+* moved to GIT
+* make build reproducible
+* the return code after receiving a signal now correctly contains
+  the signal number which caused the shutdown.
+
 2014.06.21 -- Version 0.3.5
 
 * added support for libnettle as crypt library
 2014.06.21 -- Version 0.3.5
 
 * added support for libnettle as crypt library
diff --git a/README b/README
index dc07a11..2cc3ad8 100644 (file)
--- a/README
+++ b/README
@@ -59,13 +59,12 @@ if you want to rebuild the manpage:
 Installation
 ============
 
 Installation
 ============
 
-Getting the source via subversion:
-----------------------------------
+Getting the source via GIT:
+---------------------------
 
 
-svn co https://svn.anytun.org/uanytun/trunk uanytun
+git clone https://git.spreadspace.org/anytun/uanytun.git
 cd uanytun
 
 cd uanytun
 
-
 Building from source
 --------------------
 
 Building from source
 --------------------
 
@@ -81,6 +80,7 @@ using ssl crypto library:
 # ./configure --use-ssl-crypto
 # make
 
 # ./configure --use-ssl-crypto
 # make
 
+
 Notes:
   - try './configure --help' for further information
   - if using openssl pre 0.9.8 you have to disable passphrase
 Notes:
   - try './configure --help' for further information
   - if using openssl pre 0.9.8 you have to disable passphrase
index 299c742..941cdaa 100644 (file)
@@ -1,13 +1,13 @@
 '\" t
 .\"     Title: uanytun
 .\"    Author: [see the "AUTHORS" section]
 '\" t
 .\"     Title: uanytun
 .\"    Author: [see the "AUTHORS" section]
-.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      Date: 06/21/2014
+.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
+.\"      Date: 01/04/2017
 .\"    Manual: \ \&
 .\"    Source: \ \&
 .\"  Language: English
 .\"
 .\"    Manual: \ \&
 .\"    Source: \ \&
 .\"  Language: English
 .\"
-.TH "UANYTUN" "8" "06/21/2014" "\ \&" "\ \&"
+.TH "UANYTUN" "8" "01/04/2017" "\ \&" "\ \&"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
index a469c58..ceb54a1 100644 (file)
  *  files in the program, then also delete it here.
  */
 
  *  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 "datatypes.h"
 
 #include "tun.h"
 
 #include "tun_helper.h"
 
-#include "log.h"
-
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -69,6 +70,9 @@
 #include <netinet/ip.h>
 #define DEVICE_FILE_MAX 255
 
 #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)
 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)
index 16d5cc7..8044552 100755 (executable)
@@ -153,12 +153,12 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
 fi
 
 if [ $USE_CLANG -eq 0 ]; then
 fi
 
 if [ $USE_CLANG -eq 0 ]; then
-  CFLAGS='-g -Wall -O2'
-  LDFLAGS='-g -Wall -O2'
+  CFLAGS=$CFLAGS'-g -Wall -O2'
+  LDFLAGS=$LDFLAGS'-g -Wall -O2'
   COMPILER='gcc'
 else
   COMPILER='gcc'
 else
-  CFLAGS='-g -O2'
-  LDFLAGS='-g -O2'
+  CFLAGS=$CFLAGS'-g -O2'
+  LDFLAGS=$LDFLAGS'-g -O2'
   COMPILER='clang'
 fi
 
   COMPILER='clang'
 fi
 
@@ -183,28 +183,33 @@ case $TARGET in
   ;;
 esac
 
   ;;
 esac
 
-
+CRYPTO_LIB_NAME=""
 case $CRYPTO_LIB in
   gcrypt)
     CFLAGS=$CFLAGS' -DUSE_GCRYPT'
     LDFLAGS=$LDFLAGS' -lgcrypt'
 case $CRYPTO_LIB in
   gcrypt)
     CFLAGS=$CFLAGS' -DUSE_GCRYPT'
     LDFLAGS=$LDFLAGS' -lgcrypt'
-    echo "using gcrypt library"
+    CRYPTO_LIB_NAME="libgcrypt"
   ;;
   nettle)
     CFLAGS=$CFLAGS' -DUSE_NETTLE'
     LDFLAGS=$LDFLAGS' -lnettle'
   ;;
   nettle)
     CFLAGS=$CFLAGS' -DUSE_NETTLE'
     LDFLAGS=$LDFLAGS' -lnettle'
-    echo "using nettle library"
+    CRYPTO_LIB_NAME="Nettle"
   ;;
   ssl)
     CFLAGS=$CFLAGS' -DUSE_SSL_CRYPTO'
     LDFLAGS=$LDFLAGS' -lcrypto'
   ;;
   ssl)
     CFLAGS=$CFLAGS' -DUSE_SSL_CRYPTO'
     LDFLAGS=$LDFLAGS' -lcrypto'
-    echo "using ssl crypto library"
+    CRYPTO_LIB_NAME="OpenSSL"
   ;;
   none)
     CFLAGS=$CFLAGS' -DNO_CRYPT'
   ;;
   none)
     CFLAGS=$CFLAGS' -DNO_CRYPT'
-    echo "disabling crypto"
+    CRYPTO_LIB_NAME="none"
+  ;;
+  *)
+    echo "unknown crypto library: $$CRYPTO_LIB"
+    exit 1
   ;;
 esac
   ;;
 esac
+echo "crypto-library: $CRYPTO_LIB_NAME"
 
 if [ $PASSPHRASE -eq 0 ]; then
   CFLAGS=$CFLAGS' -DNO_PASSPHRASE'
 
 if [ $PASSPHRASE -eq 0 ]; then
   CFLAGS=$CFLAGS' -DNO_PASSPHRASE'
@@ -239,7 +244,7 @@ LDFLAGS := $LDFLAGS
 STRIP := strip
 INSTALL := install
 
 STRIP := strip
 INSTALL := install
 
-PREFIX := $PREFIX
+prefix := $PREFIX
 SBINDIR := $SBINDIR
 ETCDIR := $ETCDIR
 EOF
 SBINDIR := $SBINDIR
 ETCDIR := $ETCDIR
 EOF
@@ -263,14 +268,12 @@ else
 fi
 
 VERSION=`cat ../version`
 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
 fi
-HOSTNAME=`hostname`
-DATE=`date +"%d.%m.%Y %H:%M:%S %Z"`
 
 cat > version.h <<EOF
 /*
 
 cat > version.h <<EOF
 /*
@@ -284,8 +287,8 @@ cat > version.h <<EOF
 #ifndef UANYTUN_version_h_INCLUDED
 #define UANYTUN_version_h_INCLUDED
 
 #ifndef UANYTUN_version_h_INCLUDED
 #define UANYTUN_version_h_INCLUDED
 
-#define VERSION_STRING_0 "uanytun version $VERSION"
-#define VERSION_STRING_1 "built on $HOSTNAME, $DATE"
+#define VERSION_STRING "uanytun version $VERSION"
+#define CRYPTO_LIB_NAME "$CRYPTO_LIB_NAME"
 
 #endif
 
 
 #endif
 
index df32b1b..8f75b8d 100644 (file)
@@ -480,8 +480,14 @@ void options_print_usage()
 
 void options_print_version()
 {
 
 void options_print_version()
 {
-  printf("%s\n", VERSION_STRING_0);
-  printf("%s\n", VERSION_STRING_1);
+  printf("%s\n", VERSION_STRING);
+#if defined(__clang__)
+  printf("built using CLANG %s with %s crypto library.\n", __clang_version__, CRYPTO_LIB_NAME);
+#elif defined(__GNUC__)
+  printf("built using GCC %d.%d.%d with %s crypto library\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__, CRYPTO_LIB_NAME);
+#else
+  printf("built using an unknown compiler with %s crypto library\n", CRYPTO_LIB_NAME, CRYPTO_LIB_NAME);
+#endif
 }
 
 void options_print(options_t* opt)
 }
 
 void options_print(options_t* opt)
index fbeb3eb..2d225a4 100644 (file)
@@ -214,7 +214,7 @@ void seq_win_print(seq_win_t* win)
   while(ptr) {
     printf(" [%u]: (%u)-", ptr->sender_id_, ptr->max_);
     window_size_t i = ptr->pos_;
   while(ptr) {
     printf(" [%u]: (%u)-", ptr->sender_id_, ptr->max_);
     window_size_t i = ptr->pos_;
-    while(1) {
+    for(;;) {
       if(ptr->window_[i])
         printf("O");
       else
       if(ptr->window_[i])
         printf("O");
       else
index 5de168e..f23d070 100644 (file)
@@ -139,10 +139,10 @@ int signal_handle()
   for(sig=1; sig < NSIG; ++sig) {
     if(sigismember(&set, sig)) {
       switch(sig) {
   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;
       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;
index 159f773..da90eda 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #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"
 
 #include "log.h"
 #include "sig_handler.h"
@@ -258,9 +262,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(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");
         seq_win_clear(&seq_win);
         seq_nr = 0;
         log_printf(NOTICE, "sequence window cleared");
@@ -447,8 +450,11 @@ int main(int argc, char* argv[])
     log_printf(NOTICE, "normal shutdown");
   else if(ret < 0)
     log_printf(NOTICE, "shutdown after error");
     log_printf(NOTICE, "normal shutdown");
   else if(ret < 0)
     log_printf(NOTICE, "shutdown after error");
-  else
+  else {
     log_printf(NOTICE, "shutdown after signal");
     log_printf(NOTICE, "shutdown after signal");
+    log_close();
+    kill(getpid(), ret);
+  }
 
   log_close();
 
 
   log_close();
 
index 9217688..239e074 100644 (file)
--- a/src/udp.c
+++ b/src/udp.c
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
 #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;
 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;
diff --git a/version b/version
index c2c0004..449d7e7 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-0.3.5
+0.3.6