Luca Deri 6 years ago
parent
commit
1888a0c55a
  1. 13
      CMakeLists.txt
  2. 27
      benchmark.c
  3. 3
      edge.c
  4. 12
      edge_utils.c
  5. 7
      win32/CMakeLists.txt
  6. 2
      win32/n2n_win32.h

13
CMakeLists.txt

@ -6,6 +6,12 @@ set(N2N_VERSION 2.3.0)
set(N2N_OSNAME ${CMAKE_SYSTEM}) set(N2N_OSNAME ${CMAKE_SYSTEM})
# N2n specific params # N2n specific params
OPTION(N2N_OPTION_AES "USE AES" ON)
# Build information
OPTION(BUILD_SHARED_LIBS "BUILD Shared Library" OFF)
if(NOT DEFINED N2N_OPTION_AES) if(NOT DEFINED N2N_OPTION_AES)
set(N2N_OPTION_AES ON) set(N2N_OPTION_AES ON)
endif(NOT DEFINED N2N_OPTION_AES) endif(NOT DEFINED N2N_OPTION_AES)
@ -17,17 +23,13 @@ find_package(OpenSSL REQUIRED)
add_definitions(-DN2N_HAVE_AES) add_definitions(-DN2N_HAVE_AES)
endif(N2N_OPTION_AES) endif(N2N_OPTION_AES)
# Build information
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS OFF)
endif(NOT DEFINED BUILD_SHARED_LIBS)
if(NOT DEFINED CMAKE_BUILD_TYPE) if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE None) set(CMAKE_BUILD_TYPE None)
endif(NOT DEFINED CMAKE_BUILD_TYPE) endif(NOT DEFINED CMAKE_BUILD_TYPE)
#set(CMAKE_BUILD_TYPE Debug) #set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE Release) #set(CMAKE_BUILD_TYPE Release)
if (DEFINED UNIX)
# None # None
set(CMAKE_C_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs") set(CMAKE_C_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs")
set(CMAKE_CXX_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs") set(CMAKE_CXX_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs")
@ -37,6 +39,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g")
# Release # Release
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
endif()
## DEBUG FOR CMAKE ## DEBUG FOR CMAKE
#message(${N2N_VERSION}) #message(${N2N_VERSION})

27
benchmark.c

@ -19,12 +19,37 @@
#include "n2n_wire.h" #include "n2n_wire.h"
#include "n2n_transforms.h" #include "n2n_transforms.h"
#include "n2n.h" #include "n2n.h"
#ifdef __GNUC__
#include <sys/time.h> #include <sys/time.h>
#endif
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#if defined(WIN32) && !defined(__GNUC__)
#include <windows.h>
static int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm.tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
#endif
uint8_t PKT_CONTENT[]={ uint8_t PKT_CONTENT[]={
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,

3
edge.c

@ -17,6 +17,9 @@
*/ */
#include "n2n.h" #include "n2n.h"
#ifdef WIN32
#include <sys/stat.h>
#endif
#define N2N_NETMASK_STR_SIZE 16 /* dotted decimal 12 numbers + 3 dots */ #define N2N_NETMASK_STR_SIZE 16 /* dotted decimal 12 numbers + 3 dots */
#define N2N_MACNAMSIZ 18 /* AA:BB:CC:DD:EE:FF + NULL*/ #define N2N_MACNAMSIZ 18 /* AA:BB:CC:DD:EE:FF + NULL*/

12
edge_utils.c

@ -17,6 +17,7 @@
*/ */
#include "n2n.h" #include "n2n.h"
#include "lzoconf.h"
#ifdef __ANDROID_NDK__ #ifdef __ANDROID_NDK__
#include "android/edge_android.h" #include "android/edge_android.h"
@ -920,8 +921,9 @@ static void readFromMgmtSocket(n2n_edge_t * eee, int * keep_running) {
(unsigned int)peer_list_size(eee->known_peers)); (unsigned int)peer_list_size(eee->known_peers));
msg_len += snprintf((char *)(udp_buf+msg_len), (N2N_PKT_BUF_SIZE-msg_len), msg_len += snprintf((char *)(udp_buf+msg_len), (N2N_PKT_BUF_SIZE-msg_len),
"last super:%lu(%ld sec ago) p2p:%lu(%ld sec ago)\n", "last super:%lu(%ld sec ago) p2p:%lu(%lD sec ago)\n",
eee->last_sup, (now-eee->last_sup), eee->last_p2p, (now-eee->last_p2p)); eee->last_sup, (now-eee->last_sup), eee->last_p2p,
(now-eee->last_p2p));
traceEvent(TRACE_DEBUG, "mgmt status sending: %s", udp_buf); traceEvent(TRACE_DEBUG, "mgmt status sending: %s", udp_buf);
@ -1629,7 +1631,13 @@ const char *random_device_mac(void)
mac[i] = ':'; mac[i] = ':';
continue; continue;
} }
#ifdef WIN32
#define random() rand()
#endif
mac[i] = key[random() % sizeof(key)]; mac[i] = key[random() % sizeof(key)];
#ifdef WIN32
#undef random()
#endif
} }
mac[sizeof(mac) - 1] = '\0'; mac[sizeof(mac) - 1] = '\0';
return mac; return mac;

7
win32/CMakeLists.txt

@ -1,4 +1,5 @@
add_library(n2n_win32 add_library(n2n_win32
win32/getopt1.c getopt1.c
win32/getopt.c getopt.c
win32/wintap.c) wintap.c)
target_link_libraries(n2n_win32 PUBLIC ws2_32.lib)

2
win32/n2n_win32.h

@ -44,7 +44,7 @@ typedef int ssize_t;
typedef unsigned long in_addr_t; typedef unsigned long in_addr_t;
#undef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT #define EAFNOSUPPORT WSAEAFNOSUPPORT
#define MAX(a,b) (a > b ? a : b) #define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b) #define MIN(a,b) (a < b ? a : b)

Loading…
Cancel
Save