diff --git a/.gitignore b/.gitignore index 29c968e..49cb78b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ benchmark edge example_edge_embed supernode +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e351df..1ccbe9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ project(n2n) cmake_minimum_required(VERSION 2.6) # N2n information -set(N2N_VERSION 2.3.0) +set(N2N_VERSION 2.5.0) set(N2N_OSNAME ${CMAKE_SYSTEM}) # N2n specific params @@ -70,7 +70,8 @@ target_link_libraries(n2n n2n_win32) endif(DEFINED WIN32) if(N2N_OPTION_AES) -target_link_libraries(n2n crypto) +target_link_libraries(n2n ${OPENSSL_LIBRARIES}) +include_directories(${OPENSSL_INCLUDE_DIR}) endif(N2N_OPTION_AES) add_executable(edge edge.c) diff --git a/edge.c b/edge.c index d92472c..c8f729c 100644 --- a/edge.c +++ b/edge.c @@ -730,7 +730,9 @@ int main(int argc, char* argv[]) { /* allow multiple sockets to use the same PORT number */ setsockopt(eee.udp_multicast_sock, SOL_SOCKET, SO_REUSEADDR, &enable_reuse, sizeof(enable_reuse)); +#ifndef WIN32 /* no SO_REUSEPORT in Windows */ setsockopt(eee.udp_multicast_sock, SOL_SOCKET, SO_REUSEPORT, &enable_reuse, sizeof(enable_reuse)); +#endif mreq.imr_multiaddr.s_addr = inet_addr(N2N_MULTICAST_GROUP); mreq.imr_interface.s_addr = htonl(INADDR_ANY); diff --git a/edge_utils.c b/edge_utils.c index 8c72ca4..3e77818 100644 --- a/edge_utils.c +++ b/edge_utils.c @@ -19,6 +19,10 @@ #include "n2n.h" #include "lzoconf.h" +#ifdef WIN32 +#include +#endif + #ifdef __ANDROID_NDK__ #include "android/edge_android.h" #include @@ -1690,11 +1694,11 @@ const char *random_device_mac(void) continue; } #ifdef WIN32 -#define random() rand() +#define random rand #endif mac[i] = key[random() % sizeof(key)]; #ifdef WIN32 -#undef random() +#undef random #endif } mac[sizeof(mac) - 1] = '\0'; @@ -1743,8 +1747,10 @@ int quick_edge_init(char *device_name, char *community_name, /* allow multiple sockets to use the same PORT number */ setsockopt(eee.udp_multicast_sock, SOL_SOCKET, SO_REUSEADDR, &enable_reuse, sizeof(enable_reuse)); - setsockopt(eee.udp_multicast_sock, SOL_SOCKET, SO_REUSEPORT, &enable_reuse, sizeof(enable_reuse)); - +#ifndef WIN32 /* no SO_REUSEPORT in Windows */ + setsockopt(eee.udp_multicast_sock, SOL_SOCKET, SO_REUSEPORT, &enable_reuse, sizeof(enable_reuse)); +#endif + mreq.imr_multiaddr.s_addr = inet_addr(N2N_MULTICAST_GROUP); mreq.imr_interface.s_addr = htonl(INADDR_ANY); if (setsockopt(eee.udp_multicast_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { diff --git a/n2n.h b/n2n.h index 914df23..2a9126b 100644 --- a/n2n.h +++ b/n2n.h @@ -37,11 +37,13 @@ /* Moved here to define _CRT_SECURE_NO_WARNINGS before all the including takes place */ #ifdef WIN32 #include "win32/n2n_win32.h" +#include "win32/winconfig.h" #undef N2N_HAVE_DAEMON #undef N2N_HAVE_SETUID +#else +#include "config.h" #endif -#include "config.h" #include #include diff --git a/sn.c b/sn.c index 906c45a..b859c82 100644 --- a/sn.c +++ b/sn.c @@ -20,6 +20,10 @@ #include "n2n.h" +#ifdef WIN32 +#include +#endif + #define N2N_SN_LPORT_DEFAULT 7654 #define N2N_SN_PKTBUF_SIZE 2048 @@ -920,7 +924,11 @@ int main(int argc, char * const argv[]) { traceEvent(TRACE_NORMAL, "supernode started"); +#ifndef WIN32 signal(SIGHUP, dump_registrations); +#else + signal(SIGINT, dump_registrations); +#endif return run_loop(&sss_node); } diff --git a/version.c b/version.c index f542c4b..f14ddaa 100644 --- a/version.c +++ b/version.c @@ -1,4 +1,8 @@ +#ifndef WIN32 #include "config.h" +#else +#include "win32/winconfig.h" +#endif const char * n2n_sw_version = PACKAGE_VERSION; const char * n2n_sw_osName = PACKAGE_OSNAME; diff --git a/win32/winconfig.h b/win32/winconfig.h new file mode 100644 index 0000000..edc6498 --- /dev/null +++ b/win32/winconfig.h @@ -0,0 +1,7 @@ +/* winconfig.h. Win32 replacement for file generated from config.h.in by configure. */ + +/* OS name */ +#define PACKAGE_OSNAME N2N_OSNAME + +/* Define to the version of this package. */ +#define PACKAGE_VERSION N2N_VERSION