Browse Source

Merge pull request #66 from csheely/windows-cmake-build

Submit minor changes to enable Windows CMake builds w/o requiring additional local mods.
pull/76/head
Emanuele Faranda 6 years ago
committed by GitHub
parent
commit
d7b3b2c06b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 5
      CMakeLists.txt
  3. 2
      edge.c
  4. 10
      edge_utils.c
  5. 4
      n2n.h
  6. 8
      sn.c
  7. 4
      version.c
  8. 7
      win32/winconfig.h

1
.gitignore

@ -9,3 +9,4 @@ benchmark
edge
example_edge_embed
supernode
build

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

2
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);

10
edge_utils.c

@ -19,6 +19,10 @@
#include "n2n.h"
#include "lzoconf.h"
#ifdef WIN32
#include <process.h>
#endif
#ifdef __ANDROID_NDK__
#include "android/edge_android.h"
#include <tun2tap/tun2tap.h>
@ -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,7 +1747,9 @@ 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));
#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);

4
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 <time.h>
#include <ctype.h>

8
sn.c

@ -20,6 +20,10 @@
#include "n2n.h"
#ifdef WIN32
#include <signal.h>
#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);
}

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

7
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
Loading…
Cancel
Save