diff --git a/.gitignore b/.gitignore index f264a83..f2c5bee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,27 @@ -/bin/ *.o +.deps/ +.dirstamp +/aclocal.m4 +/autom4te.cache/ +/autotools/ +/compile +/config.h +/config.h.in +/config.log +/config.status +/configure +/depcomp +/install-sh +/iodine +/iodined +/missing /src/base64u.c /src/base64u.h -/tests/test +/stamp-h1 +/test-driver +/test-iodine +/test-iodine.log +/test-iodine.trs +/test-suite.log +Makefile +Makefile.in diff --git a/.travis.yml b/.travis.yml index 57f7a67..19ef5df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ language: objective-c os: osx before_install: brew update -install: brew install check - -script: make && make test +install: brew install check autoconf-archive +script: autoreconf --install && ./configure && make && make test diff --git a/Makefile b/Makefile deleted file mode 100644 index fa7dec2..0000000 --- a/Makefile +++ /dev/null @@ -1,112 +0,0 @@ -prefix?=/usr/local -sbindir=$(prefix)/sbin -datadir=$(prefix)/share -mandir=$(datadir)/man - -DESTDIR= - -INSTALL=install -INSTALL_FLAGS= - -MKDIR=mkdir -MKDIR_FLAGS=-p - -RM=rm -RM_FLAGS=-f - -TARGETOS = `uname` - -all: - @(cd src; $(MAKE) TARGETOS=$(TARGETOS) all) - -debug: - @(cd src; $(MAKE) TARGETOS=$(TARGETOS) debug) - -install: all - $(MKDIR) $(MKDIR_FLAGS) $(DESTDIR)$(sbindir) - $(INSTALL) $(INSTALL_FLAGS) bin/iodine $(DESTDIR)$(sbindir)/iodine - chmod 755 $(DESTDIR)$(sbindir)/iodine - $(INSTALL) $(INSTALL_FLAGS) bin/iodined $(DESTDIR)$(sbindir)/iodined - chmod 755 $(DESTDIR)$(sbindir)/iodined - $(MKDIR) $(MKDIR_FLAGS) $(DESTDIR)$(mandir)/man8 - $(INSTALL) $(INSTALL_FLAGS) man/iodine.8 $(DESTDIR)$(mandir)/man8/iodine.8 - chmod 644 $(DESTDIR)$(mandir)/man8/iodine.8 - -uninstall: - $(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodine - $(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodined - $(RM) $(RM_FLAGS) $(DESTDIR)$(mandir)/man8/iodine.8 - -test: all - @echo "!! The check library is required for compiling and running the tests" - @echo "!! Get it at http://check.sf.net" - @(cd tests; $(MAKE) TARGETOS=$(TARGETOS) all) - -clean: - @echo "Cleaning..." - @(cd src; $(MAKE) clean) - @(cd tests; $(MAKE) clean) - @rm -rf bin iodine-latest* - -#Helper target for windows/android zipfiles -iodine-latest: - @rm -rf iodine-latest* - @mkdir -p iodine-latest - @echo "Create date: " > iodine-latest/VERSION.txt - @LANG=en_US date >> iodine-latest/VERSION.txt - @echo "Git version: " >> iodine-latest/VERSION.txt - @git rev-parse HEAD >> iodine-latest/VERSION.txt - @for i in README.md CHANGELOG TODO; do cp $$i iodine-latest/$$i.txt; done - @unix2dos iodine-latest/* - -#non-PIE build for old android -cross-android-old: - @(cd src; $(MAKE) base64u.c base64u.h) - @(cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_PLATFORM=android-3) - -#Position-indepedent build for modern android -cross-android: - @(cd src; $(MAKE) base64u.c base64u.h) - @(cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_PLATFORM=android-16) - -iodine-latest-android.zip: iodine-latest - @mv iodine-latest iodine-latest-android - @mkdir -p iodine-latest-android/pre-kitkat/armeabi - @mkdir -p iodine-latest-android/pre-kitkat/x86 - @$(MAKE) cross-android-old TARGET_ARCH_ABI=armeabi - @cp src/libs/armeabi/* iodine-latest-android/pre-kitkat/armeabi - @$(MAKE) cross-android-old TARGET_ARCH_ABI=x86 - @cp src/libs/x86/* iodine-latest-android/pre-kitkat/x86 - @rm -rf src/libs src/obj - @mkdir -p iodine-latest-android/armeabi - @mkdir -p iodine-latest-android/arm64-v8a - @mkdir -p iodine-latest-android/x86 - @$(MAKE) cross-android TARGET_ARCH_ABI=armeabi - @cp src/libs/armeabi/* iodine-latest-android/armeabi - @$(MAKE) cross-android TARGET_ARCH_ABI=arm64-v8a - @cp src/libs/arm64-v8a/* iodine-latest-android/arm64-v8a - @$(MAKE) cross-android TARGET_ARCH_ABI=x86 - @cp src/libs/x86/* iodine-latest-android/x86 - @cp README-android.txt iodine-latest-android - @zip -r iodine-latest-android.zip iodine-latest-android - -cross-mingw32: - @(cd src; $(MAKE) TARGETOS=windows32 CC=i686-w64-mingw32-gcc all) - -cross-mingw64: - @(cd src; $(MAKE) TARGETOS=windows32 CC=x86_64-w64-mingw32-gcc all) - -iodine-latest-windows.zip: iodine-latest - @mv iodine-latest iodine-latest-windows - @mkdir -p iodine-latest-windows/64bit iodine-latest-windows/32bit - @(cd src; $(MAKE) TARGETOS=windows32 CC=i686-w64-mingw32-gcc clean all) - @i686-w64-mingw32-strip bin/iodine* - @for i in `ls bin`; do cp bin/$$i iodine-latest-windows/32bit/$$i.exe; done - @cp /usr/i686-w64-mingw32/bin/zlib1.dll iodine-latest-windows/32bit - @(cd src; $(MAKE) TARGETOS=windows32 CC=x86_64-w64-mingw32-gcc clean all) - @x86_64-w64-mingw32-strip bin/iodine* - @for i in `ls bin`; do cp bin/$$i iodine-latest-windows/64bit/$$i.exe; done - @cp /usr/x86_64-w64-mingw32/bin/zlib1.dll iodine-latest-windows/64bit - @cp README-win32.txt iodine-latest-windows - @zip -r iodine-latest-windows.zip iodine-latest-windows - diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..4a0849c --- /dev/null +++ b/Makefile.am @@ -0,0 +1,153 @@ +## Process this file with automake to produce Makefile.in + +################################################################ +## shared ## +################################################################ + +AM_CPPFLAGS = -D$(OS) +AM_CFLAGS = -pedantic + + +################################################################ +## docs ## +################################################################ + +dist_man_MANS = man/iodine.8 +dist_doc_DATA = CHANGELOG README.md README-android.txt README-win32.txt \ + TODO doc/proto_00000402.txt doc/proto_00000500.txt \ + doc/proto_00000502.txt doc/proto_00000800.txt + + +################################################################ +## misc ## +################################################################ + +EXTRA_DIST = .travis.yml doc/iodine-server.service \ + doc/iodine-server.socket doc/iodine.te src/Android.mk + + +################################################################ +## src/ ## +################################################################ + +sbin_PROGRAMS = iodine iodined + +COMMONSRC0 = src/base32.c src/base64.c src/common.c src/dns.c \ + src/encoding.c src/login.c src/md5.c src/read.c src/window.c \ + src/util.c + +COMMONSRC = $(COMMONSRC0) src/base128.c src/tun.c src/base64u.c \ + src/base64u.h src/android_dns.h src/base128.h src/base32.h \ + src/base64.h src/common.h src/dns.h src/encoding.h src/login.h \ + src/md5.h src/read.h src/tun.h src/version.h src/windows.h \ + src/util.h src/window.h + +iodine_SOURCES = $(COMMONSRC) src/iodine.c src/client.c \ + src/client.h + +iodined_SOURCES = $(COMMONSRC) src/iodined.c src/server.c \ + src/server.h src/user.c src/fw_query.c src/fw_query.h src/user.h + +EXTRA_DIST += src/android_dns.h src/base128.h src/base32.h \ + src/base64.h src/client.h src/common.h src/dns.h src/encoding.h \ + src/fw_query.h src/login.h src/md5.h src/read.h src/tun.h src/user.h \ + src/util.h src/version.h src/windows.h + +src/base64u.c: src/base64.c + @echo Making $@ + @echo '/* No use in editing, produced by Makefile! */' > $@ + sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/\([Bb]64\)/\1u/g ; s/0123456789+/0123456789_/' < $< >> $@ + +src/base64u.h: src/base64.h + @echo Making $@ + @echo '/* No use in editing, produced by Makefile! */' > $@ + sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/\([Bb]64\)/\1u/g ; s/0123456789+/0123456789_/' < $< >> $@ + +BUILT_SOURCES = src/base64u.c src/base64u.h + +MOSTLYCLEANFILES = src/base64u.c src/base64u.h + +clean-local: + @echo Clean Android Stuff + -rm -rf src/obj src/libs + + +################################################################ +## tests/ ## +################################################################ + +if HAVE_CHECK +TESTS = test-iodine +noinst_PROGRAMS = test-iodine + +test_iodine_SOURCES = tests/test.c tests/base32.c tests/base64.c \ + tests/common.c tests/read.c tests/dns.c tests/encoding.c \ + tests/login.c tests/user.c tests/fw_query.c tests/window.c $(COMMONSRC0) \ + src/user.c src/fw_query.c + +EXTRA_DIST += tests/test.h + +test_iodine_LDADD = $(CHECK_LIBS) +test_iodine_CFLAGS = $(AM_CFLAGS) $(CHECK_CFLAGS) +test_iodine_CPPFLAGS = $(AM_CPPFLAGS) -I src +endif + + +################################################################ +## Ancient History ## +################################################################ + +# retain compatibility with former target "test" + +.PHONY: test +test: check + +# Compile for Android. + +# It is likely possible to tweak autotools into supporting this +# configuration, once that is tested the below should be removed. + +.PHONY: cross-android +cross-android: src/base64u.c src/base64u.h + (cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk) + +.PHONY: cross-android-dist +cross-android-dist: + rm -rf iodine-latest-android* + mkdir -p iodine-latest-android/armeabi iodine-latest-android/x86 + $(MAKE) cross-android TARGET_ARCH_ABI=armeabi + cp src/libs/armeabi/* iodine-latest-android/armeabi + $(MAKE) cross-android TARGET_ARCH_ABI=x86 + cp src/libs/x86/* iodine-latest-android/x86 + cp README.md README-android.txt CH* TO* iodine-latest-android/ + echo "Create date: " > iodine-latest-android/VERSION + date >> iodine-latest-android/VERSION + echo "Git version: " >> iodine-latest-android/VERSION + echo $(GITREVISION) >> iodine-latest-android/VERSION + zip -r iodine-latest-android.zip iodine-latest-android + +# Compile for MS Windows. + +# This platform is supported by autotools, so the below should be removed once +# autotools is tested in that configuration. + +.PHONY: cross-mingw +cross-mingw: + echo "WARNING:" + echo "This make target is unlikely to work properly." + echo "Cross compilation is supported by autotools." + echo " ./configure --build=turingmachine-unknown-linux-gnu --host=mingw32" + $(MAKE) OS=WINDOWS32 CC=i686-mingw32-gcc all + +.PHONY: cross-mingw-dist +cross-mingw-dist: cross-mingw + rm -rf iodine-latest-win32* + mkdir -p iodine-latest-win32/bin + for i in `ls bin`; do cp bin/$$i iodine-latest-win32/bin/$$i.exe; done + cp /usr/i686-mingw32/usr/bin/zlib1.dll iodine-latest-win32/bin/ + cp README.md README-win32.txt CH* TO* iodine-latest-win32/ + echo "Create date: " > iodine-latest-win32/VERSION + date >> iodine-latest-win32/VERSION + echo "Git version: " >> iodine-latest-win32/VERSION + echo $(GITREVISION) >> iodine-latest-win32/VERSION + zip -r iodine-latest-win32.zip iodine-latest-win32 diff --git a/README.md b/README.md index b396946..50dfe84 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,7 @@ firewalled, but DNS queries are allowed. COMPILING --------- -Iodine has no configure script. There are two optional features for Linux -(SELinux and systemd support) that will be enabled automatically if the -relevant header files are found in `/usr/include`. -(See script at `./src/osflags`) - -Run `make` to compile the server and client binaries. -Run `make debug` to compile the binaries with extra debugging enabled. -Run `make install` to copy binaries and manpage to the destination directory. -Run `make test` to compile and run the unit tests. (Requires the `check` library) +Standard `autotools` build scripts, so a simple `autoreconf --install && ./configure && make`, followed by an optional `make check`, and a `make install`, should do it. All the usual build options for cross-compilation etc should be available, such as `./configure --help=short` to find package-specific configuration options. QUICKSTART diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..e1bada3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,191 @@ +# Process this file with autoconf to produce a configure script. + +# Prologue + +AC_PREREQ([2.69]) +AC_INIT([iodine],[0.7.0],[erik@kryo.se],[],[http://dev.kryo.se/iodine/]) +AC_CONFIG_SRCDIR([src/iodine.c]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([autotools]) +AC_CONFIG_AUX_DIR([autotools]) +AM_INIT_AUTOMAKE([subdir-objects foreign -Wall]) + +# Misc + +# Define OS to upcased "uname --kernel-name", i.e., LINUX, DARWIN, etc. +# Used by Makefile.am as cpp symbol to define. +# We use autotools canonical designation to allow cross compilation. +# It would be reasonable to, at some point, update the C sources to +# use these more canonical designations. +# But for now, we must adjust some of them. + +AC_MSG_CHECKING([environment to compile for]) +AC_CANONICAL_HOST + +# No need to adjust these: FREEBSD, NETBSD, OPENBSD, BEOS +AS_CASE([${host_os}], + [linux-gnu], [OS=LINUX], + [mingw32], [OS=WINDOWS32], + [macos], [OS=DARWIN], + [linux-android], [OS=ANDROID], + [OS="$(echo ${host_os}|tr "a-z" "A-Z")"]) + +uname_os="$(uname | tr "a-z" "A-Z")" + +# Avoid, e.g., OS=DARWIN15.6.0 +AS_CASE([${uname_os}], + [DARWIN], [OS=DARWIN]) + +AC_MSG_NOTICE([host_os: ${host_os}]) +AC_MSG_NOTICE([uname_os: ${uname_os}]) +AC_MSG_NOTICE([adjusted OS: ${OS}]) + +AC_SUBST([OS]) + +AS_CASE([${OS}], + [WINDOWS32], + AC_DEFINE([WINVER],[0x0501], + [Define appropriately on MS Windows 32])) + +# The AC_SUBST for GITREVISION is used only in legacy stanza; remove +# when unused in Makefile.am, leaving only the config.h #define. + +AC_SUBST([GITREVISION],[$(git describe --tags --always --dirty || echo not-in-git)]) +AC_DEFINE_UNQUOTED([GITREVISION],["${GITREVISION}"], + [Precise git commit checked out when building]) + +# Checks for programs + +AC_PROG_CC +AC_PROG_CC_STDC +AS_IF([test "x${ac_cv_prog_cc_stdc}" = xno], + [AC_MSG_WARN([Unable to engage Standard C (C99) option])],) +# This is to avoid +# error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’ +# whose definition is guarded by _GNU_SOURCE +AC_USE_SYSTEM_EXTENSIONS +AX_CFLAGS_WARN_ALL +AC_PROG_INSTALL + +# Process options + +AC_ARG_ENABLE([systemd], + [AS_HELP_STRING([--enable-systemd], + [enable systemd support @<:@default=check@:>@])],, + [enable_systemd=check]) + +AC_ARG_ENABLE([selinux], + [AS_HELP_STRING([--enable-selinux], + [enable selinux support @<:@default=check@:>@])],, + [enable_selinux=check]) + +# Checks for libraries + +# Unclear why pthread is needed. +# Uncomment and replace ? by called procedure requiring -lpthread. +#AC_SEARCH_LIBS([?], [pthread]) + +AC_SEARCH_LIBS([uncompress], [z]) + +# Enable systemd per option by setting HAVE_SYSTEMD + +AS_CASE([${enable_systemd}], + [yes|check], + [AC_MSG_CHECKING([systemd]) + AC_SEARCH_LIBS([sd_listen_fds], [systemd-daemon]) + AC_CHECK_FUNC([sd_listen_fds], + [AC_MSG_RESULT([enabled: systemd]) + AC_DEFINE([HAVE_SYSTEMD],[1], + [Define to 1 to enable systemd support])], + AS_CASE([${enable_systemd}], + [yes], + AC_MSG_ERROR([systemd support not available]), + AC_MSG_RESULT([disabled: systemd])))], + [no],, + [AC_MSG_ERROR([invalid argument, --enable-systemd=${enable_systemd}])]) + +# Enable selinux per option by setting HAVE_SETCON + +AS_CASE([${enable_selinux}], + [yes|check], + [AC_SEARCH_LIBS([setcon], [selinux]) + AC_CHECK_FUNCS([setcon], + AC_MSG_RESULT([enabled: selinux]), + AS_CASE([${enable_selinux}], + [yes], + AC_MSG_ERROR([selinux support not available]), + [check], + AC_MSG_RESULT([disabled: selinux])))], + [no], + AC_MSG_RESULT([disabled: selinux]), + [AC_MSG_ERROR([invalid argument, --enable-selinux=${enable_selinux}])]) + +# The check library is used for the unit testing. Not bothering to +# implement an --enable-tests option, as they are only run by "make +# check" so there is no user-level difference. If the unit tests +# won't even *compile* there is probably a better solution than just +# turning them off, and build time is minimal. + +PKG_CHECK_MODULES(CHECK,[check], + AC_MSG_RESULT([enabled: unit testing]), + AC_MSG_RESULT([disabled: unit testing])) + +AM_CONDITIONAL([HAVE_CHECK],[test -z "${CHECK_PKG_ERRORS}"]) + +# For each commented AC_SEARCH_LIBS below, uncomment and replace ? by +# called procedure provided only by that library on the platform(s) in +# question. + +# for SunOS / solaris: +#AC_SEARCH_LIBS([?], [nsl]) + +# for BeOS: +#AC_SEARCH_LIBS([?], [bind]) +#AC_SEARCH_LIBS([?], [bsd]) + +# for SunOS / solaris / BeOS: +#AC_SEARCH_LIBS([?], [socket]) + +# for Haiku: +#AC_SEARCH_LIBS([?], [network]) + +# for MS windows32: +#AC_SEARCH_LIBS([?], [ws2_32]) +#AC_SEARCH_LIBS([?], [iphlpapi]) + +# Checks for headers + +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h systemd/sd-daemon.h selinux/selinux.h]) + +# Checks for typedefs, structures, and compiler characteristics + +AC_CHECK_TYPES([socklen_t],, + AC_DEFINE([socklen_t],[int], + [define to int if type socklen_t not found]), + [ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +]) + +AC_TYPE_UID_T +AC_C_INLINE +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT8_T + +# Checks for library functions + +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_CHECK_FUNCS([alarm dup2 inet_ntoa memset select socket strcasecmp strchr strdup strerror strrchr strstr]) + +# Epilogue + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 7bfe8d4..0000000 --- a/src/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -COMMONOBJS = tun.o dns.o read.o encoding.o login.o base32.o base64.o base64u.o base128.o md5.o window.o common.o util.o -CLIENTOBJS = iodine.o client.o -CLIENT = ../bin/iodine -SERVEROBJS = iodined.o user.o fw_query.o server.o -SERVER = ../bin/iodined - -OS = `echo $(TARGETOS) | tr "a-z" "A-Z"` -ARCH = `uname -m` -HEAD_COMMIT = `git rev-parse --short HEAD` - -LIBPATH = -L. -LDFLAGS += -lz `sh osflags $(TARGETOS) link` $(LIBPATH) -CFLAGS += -std=c99 -c -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags` -DGITREVISION=\"$(HEAD_COMMIT)\" - -CFLAGS_RELEASE = -O3 -fno-strict-aliasing -CFLAGS_DEBUG = -g -O0 -DDEBUG_BUILD - -all: CFLAGS += $(CFLAGS_RELEASE) -all: executables - -debug: CFLAGS += $(CFLAGS_DEBUG) -debug: executables - -executables: stateos $(CLIENT) $(SERVER) - -stateos: - @echo OS is $(OS), arch is $(ARCH) - -$(CLIENT): $(COMMONOBJS) $(CLIENTOBJS) - @echo LD $@ - @mkdir -p ../bin - @$(CC) $(COMMONOBJS) $(CLIENTOBJS) -o $(CLIENT) $(LDFLAGS) - -$(SERVER): $(COMMONOBJS) $(SERVEROBJS) - @echo LD $@ - @mkdir -p ../bin - @$(CC) $(COMMONOBJS) $(SERVEROBJS) -o $(SERVER) $(LDFLAGS) - -.c.o: - @echo CC $< - @$(CC) $(CFLAGS) $< -o $@ - -base64u.o client.o iodined.o: base64u.h -base64u.c: base64.c - @echo Making $@ - @echo '/* No use in editing, produced by Makefile! */' > $@ - @sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/\([Bb]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.c >> $@ -base64u.h: base64.h - @echo Making $@ - @echo '/* No use in editing, produced by Makefile! */' > $@ - @sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/\([Bb]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.h >> $@ - -clean: - @echo "Cleaning src/" - @rm -f $(CLIENT){,.exe} $(SERVER){,.exe} *~ *.o *.core base64u.* - @rm -rf obj libs #android stuff - diff --git a/src/base128.c b/src/base128.c index 7255c0f..2bfba26 100644 --- a/src/base128.c +++ b/src/base128.c @@ -28,6 +28,10 @@ * 1000 8 */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/base32.c b/src/base32.c index 86191ac..787dae9 100644 --- a/src/base32.c +++ b/src/base32.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/base64.c b/src/base64.c index 570120b..3926e9c 100644 --- a/src/base64.c +++ b/src/base64.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/client.c b/src/client.c index 8d0e642..0c4b01d 100644 --- a/src/client.c +++ b/src/client.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/client.h b/src/client.h index f6750a1..e43a20f 100644 --- a/src/client.h +++ b/src/client.h @@ -114,13 +114,6 @@ struct client_instance { uint16_t chunkid; - /* Base32 encoder used for non-data packets and replies */ - struct encoder *b32; - /* Base64 etc encoders for replies */ - struct encoder *b64; - struct encoder *b64u; - struct encoder *b128; - /* The encoder used for data packets * Defaults to Base32, can be changed after handshake */ struct encoder *dataenc; diff --git a/src/common.c b/src/common.c index 4d70ab1..c809853 100644 --- a/src/common.c +++ b/src/common.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/common.h b/src/common.h index 81716f2..a4aa8fb 100644 --- a/src/common.h +++ b/src/common.h @@ -18,6 +18,12 @@ #ifndef __COMMON_H__ #define __COMMON_H__ +#ifdef DARWIN +#ifndef __APPLE_USE_RFC_3542 +#define __APPLE_USE_RFC_2292 +#endif +#endif + /* Last byte of raw header is the command */ #define RAW_HDR_LEN 4 #define RAW_HDR_IDENT_LEN 3 diff --git a/src/dns.c b/src/dns.c index b7fa269..4ce57b5 100644 --- a/src/dns.c +++ b/src/dns.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/encoding.c b/src/encoding.c index 3ebfa8b..f85ed95 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "common.h" #include "encoding.h" diff --git a/src/fw_query.c b/src/fw_query.c index 873307a..aafa99e 100644 --- a/src/fw_query.c +++ b/src/fw_query.c @@ -14,6 +14,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "fw_query.h" diff --git a/src/iodine.c b/src/iodine.c index de55af4..24b68a5 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/iodined.c b/src/iodined.c index 9525116..1d50f45 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/login.c b/src/login.c index aa817c0..19e3f58 100644 --- a/src/login.c +++ b/src/login.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/osflags b/src/osflags deleted file mode 100644 index eb01101..0000000 --- a/src/osflags +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -case $2 in -link) - - case $1 in - SunOS | solaris) - echo '-lsocket -lnsl'; - ;; - BeOS) - echo '-lsocket -lbind -lbsd'; - ;; - Haiku) - echo '-lnetwork'; - ;; - windows32) - echo '-lws2_32 -liphlpapi'; - ;; - Linux) - FLAGS=""; - [ -e /usr/include/selinux/selinux.h ] && FLAGS="$FLAGS -lselinux"; - [ -e /usr/include/systemd/sd-daemon.h ] && FLAGS="$FLAGS $(pkg-config --libs libsystemd-daemon)"; - [ -e /usr/include/systemd/sd-daemon.h ] && FLAGS="$FLAGS $(pkg-config --libs libsystemd)"; - echo $FLAGS; - ;; - esac - ;; -cflags) - case $1 in - windows32) - echo '-DWINVER=0x0501'; - ;; - BeOS) - echo '-Dsocklen_t=int'; - ;; - Darwin) - echo '-D__APPLE_USE_RFC_3542'; - ;; - Linux) - FLAGS="-D_GNU_SOURCE" - [ -e /usr/include/selinux/selinux.h ] && FLAGS="$FLAGS -DHAVE_SETCON"; - [ -e /usr/include/systemd/sd-daemon.h ] && FLAGS="$FLAGS -DHAVE_SYSTEMD"; - echo $FLAGS; - ;; - GNU/kFreeBSD|GNU) - echo '-D_GNU_SOURCE' - ;; - esac -;; -*) -;; -esac diff --git a/src/read.c b/src/read.c index 2c26584..bb7192a 100644 --- a/src/read.c +++ b/src/read.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/server.c b/src/server.c index 3433a4f..ee78b2c 100644 --- a/src/server.c +++ b/src/server.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/tun.c b/src/tun.c index 47d36fa..769039e 100644 --- a/src/tun.c +++ b/src/tun.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/user.c b/src/user.c index 9606356..bcd1fb2 100644 --- a/src/user.c +++ b/src/user.c @@ -16,6 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/util.c b/src/util.c index 3bd162c..66dd768 100644 --- a/src/util.c +++ b/src/util.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "common.h" diff --git a/src/window.c b/src/window.c index a3bd346..8037358 100644 --- a/src/window.c +++ b/src/window.c @@ -14,6 +14,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 7977947..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -TEST = test -OBJS = test.o base32.o base64.o common.o read.o dns.o encoding.o login.o user.o fw_query.o window.o -SRCOBJS = ../src/base32.o ../src/base64.o ../src/window.o ../src/common.o ../src/read.o ../src/dns.o ../src/encoding.o ../src/login.o ../src/md5.o ../src/user.o ../src/fw_query.o ../src/util.o - -OS = `uname | tr "a-z" "A-Z"` - -CHECK_PATH = /usr/local -LDFLAGS = -L$(CHECK_PATH)/lib `pkg-config check --libs` -lpthread `sh ../src/osflags $(TARGETOS) link` -CFLAGS = -std=c99 -g -Wall -D$(OS) `pkg-config check --cflags` -I../src -I$(CHECK_PATH)/include -pedantic `sh ../src/osflags $(TARGETOS) cflags` - -all: $(TEST) - @LD_LIBRARY_PATH=${CHECK_PATH}/lib ./$(TEST) - -$(TEST): $(OBJS) $(SRCOBJS) - @echo LD $(TEST) - @$(CC) -o $@ $(SRCOBJS) $(OBJS) $(LDFLAGS) - -.c.o: - @echo CC $< - @$(CC) $(CFLAGS) -c $< - -clean: - @echo "Cleaning tests/" - @rm -f *~ *.core $(TEST) $(OBJS) - diff --git a/tests/base32.c b/tests/base32.c index 9c9fdff..86898ce 100644 --- a/tests/base32.c +++ b/tests/base32.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/base64.c b/tests/base64.c index e0d828f..19246ac 100644 --- a/tests/base64.c +++ b/tests/base64.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/common.c b/tests/common.c index 742c04a..2214800 100644 --- a/tests/common.c +++ b/tests/common.c @@ -15,6 +15,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include diff --git a/tests/dns.c b/tests/dns.c index 206df1f..b15e6e5 100644 --- a/tests/dns.c +++ b/tests/dns.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/encoding.c b/tests/encoding.c index 70b348c..1215aff 100644 --- a/tests/encoding.c +++ b/tests/encoding.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/fw_query.c b/tests/fw_query.c index be8ce10..e5f46d7 100644 --- a/tests/fw_query.c +++ b/tests/fw_query.c @@ -14,6 +14,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "fw_query.h" diff --git a/tests/login.c b/tests/login.c index c814cee..17c2ff8 100644 --- a/tests/login.c +++ b/tests/login.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/tests/read.c b/tests/read.c index 764e635..c1d0ab6 100644 --- a/tests/read.c +++ b/tests/read.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/test.c b/tests/test.c index 73c04b5..9624a13 100644 --- a/tests/test.c +++ b/tests/test.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/user.c b/tests/user.c index d8118fe..97d95c7 100644 --- a/tests/user.c +++ b/tests/user.c @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tests/window.c b/tests/window.c index 6920d33..9cc143e 100644 --- a/tests/window.c +++ b/tests/window.c @@ -13,6 +13,11 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include