This commit is contained in:
Luca Deri 2018-08-17 14:27:11 +02:00
parent b877f2dd1c
commit 1888a0c55a
6 changed files with 53 additions and 13 deletions

View File

@ -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})

View File

@ -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
View File

@ -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*/

View File

@ -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;

View File

@ -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)

View File

@ -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)