--- /dev/null
+doc/uanytun.8.xml
+src/*.o
+src/*.d
+src/*.d.*
+src/tun.c
+src/include.mk
+src/version.h
+src/uanytun
+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
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
-
Building from source
--------------------
# ./configure --use-ssl-crypto
# make
+
Notes:
- try './configure --help' for further information
- if using openssl pre 0.9.8 you have to disable passphrase
'\" 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
.\"
-.TH "UANYTUN" "8" "06/21/2014" "\ \&" "\ \&"
+.TH "UANYTUN" "8" "01/04/2017" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
* 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>
#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)
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
- CFLAGS='-g -O2'
- LDFLAGS='-g -O2'
+ CFLAGS=$CFLAGS'-g -O2'
+ LDFLAGS=$LDFLAGS'-g -O2'
COMPILER='clang'
fi
;;
esac
-
+CRYPTO_LIB_NAME=""
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'
- echo "using nettle library"
+ CRYPTO_LIB_NAME="Nettle"
;;
ssl)
CFLAGS=$CFLAGS' -DUSE_SSL_CRYPTO'
LDFLAGS=$LDFLAGS' -lcrypto'
- echo "using ssl crypto library"
+ CRYPTO_LIB_NAME="OpenSSL"
;;
none)
CFLAGS=$CFLAGS' -DNO_CRYPT'
- echo "disabling crypto"
+ CRYPTO_LIB_NAME="none"
+ ;;
+ *)
+ echo "unknown crypto library: $$CRYPTO_LIB"
+ exit 1
;;
esac
+echo "crypto-library: $CRYPTO_LIB_NAME"
if [ $PASSPHRASE -eq 0 ]; then
CFLAGS=$CFLAGS' -DNO_PASSPHRASE'
STRIP := strip
INSTALL := install
-PREFIX := $PREFIX
+prefix := $PREFIX
SBINDIR := $SBINDIR
ETCDIR := $ETCDIR
EOF
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"`
cat > version.h <<EOF
/*
#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
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)
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
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;
#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"
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");
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();
#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;