mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Merge of https://github.com/ntop/n2n/pull/26
This commit is contained in:
parent
b877f2dd1c
commit
1888a0c55a
|
@ -6,6 +6,12 @@ set(N2N_VERSION 2.3.0)
|
|||
set(N2N_OSNAME ${CMAKE_SYSTEM})
|
||||
|
||||
# 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)
|
||||
set(N2N_OPTION_AES ON)
|
||||
endif(NOT DEFINED N2N_OPTION_AES)
|
||||
|
@ -17,17 +23,13 @@ find_package(OpenSSL REQUIRED)
|
|||
add_definitions(-DN2N_HAVE_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)
|
||||
set(CMAKE_BUILD_TYPE None)
|
||||
endif(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
#set(CMAKE_BUILD_TYPE Debug)
|
||||
#set(CMAKE_BUILD_TYPE Release)
|
||||
|
||||
if (DEFINED UNIX)
|
||||
# None
|
||||
set(CMAKE_C_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
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
endif()
|
||||
|
||||
## DEBUG FOR CMAKE
|
||||
#message(${N2N_VERSION})
|
||||
|
@ -47,7 +50,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
|||
|
||||
add_library(n2n n2n.c
|
||||
n2n_keyfile.c
|
||||
edge_utils.c
|
||||
edge_utils.c
|
||||
wire.c
|
||||
minilzo.c
|
||||
twofish.c
|
||||
|
|
27
benchmark.c
27
benchmark.c
|
@ -19,12 +19,37 @@
|
|||
#include "n2n_wire.h"
|
||||
#include "n2n_transforms.h"
|
||||
#include "n2n.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <string.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[]={
|
||||
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
3
edge.c
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
|
||||
#include "n2n.h"
|
||||
#ifdef WIN32
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#define N2N_NETMASK_STR_SIZE 16 /* dotted decimal 12 numbers + 3 dots */
|
||||
#define N2N_MACNAMSIZ 18 /* AA:BB:CC:DD:EE:FF + NULL*/
|
||||
|
|
12
edge_utils.c
12
edge_utils.c
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "n2n.h"
|
||||
#include "lzoconf.h"
|
||||
|
||||
#ifdef __ANDROID_NDK__
|
||||
#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));
|
||||
|
||||
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",
|
||||
eee->last_sup, (now-eee->last_sup), eee->last_p2p, (now-eee->last_p2p));
|
||||
"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));
|
||||
|
||||
traceEvent(TRACE_DEBUG, "mgmt status sending: %s", udp_buf);
|
||||
|
||||
|
@ -1629,7 +1631,13 @@ const char *random_device_mac(void)
|
|||
mac[i] = ':';
|
||||
continue;
|
||||
}
|
||||
#ifdef WIN32
|
||||
#define random() rand()
|
||||
#endif
|
||||
mac[i] = key[random() % sizeof(key)];
|
||||
#ifdef WIN32
|
||||
#undef random()
|
||||
#endif
|
||||
}
|
||||
mac[sizeof(mac) - 1] = '\0';
|
||||
return mac;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
add_library(n2n_win32
|
||||
win32/getopt1.c
|
||||
win32/getopt.c
|
||||
win32/wintap.c)
|
||||
getopt1.c
|
||||
getopt.c
|
||||
wintap.c)
|
||||
target_link_libraries(n2n_win32 PUBLIC ws2_32.lib)
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef int ssize_t;
|
|||
|
||||
typedef unsigned long in_addr_t;
|
||||
|
||||
|
||||
#undef EAFNOSUPPORT
|
||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
#define MAX(a,b) (a > b ? a : b)
|
||||
#define MIN(a,b) (a < b ? a : b)
|
||||
|
|
Loading…
Reference in New Issue
Block a user