From cec3b44ad7c4f03d7ee8fcd9d35eca083f5d1fe4 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 16 Apr 2008 00:01:29 +0000 Subject: anytun-nosync builds on OpenBSD now --- src/Makefile | 34 ++++++++++++++++++++++------------ src/anytun.cpp | 12 ++++++++++-- src/networkAddress.cpp | 29 +++++++++++++++++++++++++++++ src/networkAddress.h | 7 +++++++ src/networkPrefix.cpp | 7 +++++++ src/plainPacket.cpp | 7 ++++++- 6 files changed, 81 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 902d2a0..a1f102e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,6 @@ +TARGET=$(shell uname -s) C = gcc -CFLAGS = -g -Wall +CFLAGS = -g CFLAGS += -DSOCKETS_NAMESPACE=sockets CFLAGS += -DSOCKETS_NAMESPACE_STR='"sockets"' C++ = g++ @@ -7,7 +8,16 @@ CCFLAGS = -g -Wall CCFLAGS += -DSOCKETS_NAMESPACE=sockets CCFLAGS += -DSOCKETS_NAMESPACE_STR='"sockets"' LD = g++ -LDFLAGS = -g -Wall -O2 -ldl -lpthread -lgcrypt -lboost_serialization +LDFLAGS = -g -Wall -O2 -lpthread -lgcrypt -lgpg-error -lboost_serialization + +ifeq ($(TARGET),Linux) + LDFLAGS += -ldl +endif +ifeq ($(TARGET),OpenBSD) + CCFLAGS += -I/usr/local/include + LDFLAGS += -L/usr/local/lib +endif + OPENVPNDEPS = openvpn/tun.o \ openvpn/error.o \ @@ -141,7 +151,7 @@ tunDevice.o: tunDevice.cpp tunDevice.h $(C++) $(CCFLAGS) $< -c Sockets/libSockets.a: - make --directory=./Sockets + $(MAKE) --directory=./Sockets packetSource.o: packetSource.cpp packetSource.h $(C++) $(CCFLAGS) $< -c @@ -255,7 +265,7 @@ anytun.o: anytun.cpp $(C++) $(CCFLAGS) $< -c anytun-nosync.o: anytun.cpp - $(C++) -g -Wall -DANYTUN_NOSYNC $< -c -o anytun-nosync.o + $(C++) $(CCFLAGS) -DANYTUN_NOSYNC $< -c -o anytun-nosync.o anytun-showtables.o: anytun-showtables.cpp $(C++) $(CCFLAGS) $< -c @@ -274,17 +284,17 @@ libAnysync.a: $(OBJS) ranlib $@ anyrtpproxy: anytun - @cd anyrtpproxy ; make + @cd anyrtpproxy ; $(MAKE) distclean: cleanall - make --directory=$(CURDIR)/openvpn distclean - find -name *.o -exec rm -f {}\; + $(MAKE) --directory=$(CURDIR)/openvpn distclean + find . -name *.o -exec rm -f {} \; rm -f config.sub config.guess cleanall: clean - make --directory=$(CURDIR)/man clean - make --directory=$(CURDIR)/Sockets clean - make --directory=$(CURDIR)/openvpn clean + $(MAKE) --directory=$(CURDIR)/man clean + $(MAKE) --directory=$(CURDIR)/Sockets clean + $(MAKE) --directory=$(CURDIR)/openvpn clean rm -f Sockets/libSockets.a Sockets/Sockets-config clean: @@ -294,10 +304,10 @@ clean: rm -f -r doc/html/* rm -f -r doc/latex/* rm -f libAnysync.a - make --directory=$(CURDIR)/anyrtpproxy clean + $(MAKE) --directory=$(CURDIR)/anyrtpproxy clean manpage: - @cd man ; make + @cd man ; $(MAKE) doxygen: doxygen Doxyfile diff --git a/src/anytun.cpp b/src/anytun.cpp index 37e21e6..e8bfb13 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -35,7 +35,10 @@ #include #include #include +#include +#include +#include #include #include // for ENOMEM @@ -312,16 +315,20 @@ void* receiver(void* p) } #define MIN_GCRYPT_VERSION "1.2.0" +#if defined(__GNUC__) && !defined(__OpenBSD__) // TODO: thread-safety on OpenBSD // make libgcrypt thread safe extern "C" { GCRY_THREAD_OPTION_PTHREAD_IMPL; } +#endif bool initLibGCrypt() { // make libgcrypt thread safe // this must be called before any other libgcrypt call +#if defined(__GNUC__) && !defined(__OpenBSD__) // TODO: thread-safety on OpenBSD gcry_control( GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread ); +#endif // this must be called right after the GCRYCTL_SET_THREAD_CBS command // no other function must be called till now @@ -425,7 +432,7 @@ int main(int argc, char* argv[]) gOpt.printUsage(); exit(-1); } - + cLog.msg(Log::PRIO_NOTICE) << "anytun started..."; std::ofstream pidFile; @@ -467,7 +474,7 @@ int main(int argc, char* argv[]) src = new UDPPacketSource(gOpt.getLocalPort()); else src = new UDPPacketSource(gOpt.getLocalAddr(), gOpt.getLocalPort()); - + ConnectionList cl; ConnectToList connect_to = gOpt.getConnectTo(); SyncQueue queue; @@ -497,6 +504,7 @@ int main(int argc, char* argv[]) pthread_create(& connectThreads.back(), NULL, syncConnector, point); } #endif + int ret = sig.run(); pthread_cancel(senderThread); diff --git a/src/networkAddress.cpp b/src/networkAddress.cpp index cd93576..dce8054 100644 --- a/src/networkAddress.cpp +++ b/src/networkAddress.cpp @@ -125,7 +125,13 @@ bool NetworkAddress::operator<(const NetworkAddress &right) const return (ipv4_address_.s_addr < right.ipv4_address_.s_addr); } else if (network_address_type_==ipv6) { for(int i=0;i<4;i++) +#if defined(__GNUC__) && defined(__linux__) if (ipv6_address_.s6_addr32[i] #include #include -#include +#include +#include +#include #include #include +#include +#include +#include #include "datatypes.h" #include "plainPacket.h" -- cgit v1.2.3