mirror of
https://github.com/ntop/n2n.git
synced 2024-04-21 16:31:34 +00:00
Simplify build system by using standard macro
Most environments have predefined macros that identify the environment
to the source code. If we use these macros instead of defining our own
then there is one less parameter difference to keep track of with
different builds
cf:
http://web.archive.org/web/20191012035921/http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
https://sourceforge.net/p/predef/wiki/OperatingSystems/
This commit is contained in:
+7
-7
@@ -42,12 +42,12 @@
|
||||
#include "config.h" /* Visual C++ */
|
||||
|
||||
/* Moved here to define _CRT_SECURE_NO_WARNINGS before all the including takes place */
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#define N2N_CAN_NAME_IFACE 1
|
||||
#undef N2N_HAVE_DAEMON
|
||||
#undef N2N_HAVE_TCP /* as explained on https://github.com/ntop/n2n/pull/627#issuecomment-782093706 */
|
||||
#undef N2N_HAVE_SETUID
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "n2n_define.h"
|
||||
#include "n2n_typedefs.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h> /* for tcp */
|
||||
#include <lmaccess.h> /* for privilege check in tools/n2n-route */
|
||||
#include <lmapibuf.h> /* for privilege check in tools/n2n-route */
|
||||
@@ -63,9 +63,9 @@
|
||||
#include <windows.h> /* for privilege check in tools/n2n-route */
|
||||
#include "wintap.h"
|
||||
#define SHUT_RDWR SD_BOTH /* for tcp */
|
||||
#endif /* #ifdef WIN32 */
|
||||
#endif /* #ifdef _WIN32 */
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h> // for in_addr (ptr only), in_addr_t
|
||||
#include <pwd.h>
|
||||
#include <stdint.h> // for uint8_t, uint64_t, uint32_t, uint16_t
|
||||
@@ -89,7 +89,7 @@
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
#endif
|
||||
#endif /* #ifndef WIN32 */
|
||||
#endif /* #ifndef _WIN32 */
|
||||
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ void _traceEvent (int eventTraceLevel, char* file, int line, char * format, ...)
|
||||
/* Tuntap API */
|
||||
int tuntap_open (struct tuntap_dev *device, char *dev, const char *address_mode, char *device_ip,
|
||||
char *device_mask, const char * device_mac, int mtu
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
, int metric
|
||||
#endif
|
||||
);
|
||||
|
||||
@@ -190,7 +190,7 @@ enum skip_add {SN_ADD = 0, SN_ADD_SKIP = 1, SN_ADD_ADDED = 2};
|
||||
#define N2N_MULTICAST_PORT 1968
|
||||
#define N2N_MULTICAST_GROUP "224.0.0.68"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#define N2N_IFNAMSIZ 64
|
||||
#else
|
||||
#define N2N_IFNAMSIZ 16 /* 15 chars * NULL */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h> // for uint8_t and friends
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h> // for in_addr_t
|
||||
#include <sys/socket.h> // for sockaddr
|
||||
#endif
|
||||
@@ -84,7 +84,7 @@ typedef unsigned long in_addr_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
@@ -231,7 +231,7 @@ typedef char dec_ip_bit_str_t[N2N_NETMASK_STR_SIZE + 4];
|
||||
typedef char devstr_t[N2N_IFNAMSIZ];
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
typedef struct tuntap_dev {
|
||||
int fd;
|
||||
int if_idx;
|
||||
@@ -243,9 +243,9 @@ typedef struct tuntap_dev {
|
||||
} tuntap_dev;
|
||||
|
||||
#define SOCKET int
|
||||
#else /* #ifndef WIN32 */
|
||||
#else /* #ifndef _WIN32 */
|
||||
typedef u_short sa_family_t;
|
||||
#endif /* #ifndef WIN32 */
|
||||
#endif /* #ifndef _WIN32 */
|
||||
|
||||
|
||||
typedef struct speck_context_t he_context_t;
|
||||
@@ -574,7 +574,7 @@ typedef struct n2n_tuntap_priv_config {
|
||||
int mtu;
|
||||
int metric;
|
||||
uint8_t daemon;
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
uid_t userid;
|
||||
gid_t groupid;
|
||||
#endif
|
||||
@@ -849,7 +849,7 @@ typedef struct n2n_sn {
|
||||
int mgmt_sock; /* management socket. */
|
||||
n2n_ip_subnet_t min_auto_ip_net; /* Address range of auto_ip service. */
|
||||
n2n_ip_subnet_t max_auto_ip_net; /* Address range of auto_ip service. */
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
uid_t userid;
|
||||
gid_t groupid;
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -25,12 +25,12 @@
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
#ifdef _WIN32
|
||||
#include "n2n_win32.h"
|
||||
#else /* #if defined(WIN32) */
|
||||
#else /* #ifdef _WIN32 */
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h> /* AF_INET and AF_INET6 */
|
||||
#endif /* #if defined(WIN32) */
|
||||
#endif /* #ifdef _WIN32 */
|
||||
|
||||
#include "sn_selection.h"
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <immintrin.h> /* _rdrand64_step, rdseed4_step */
|
||||
#endif
|
||||
|
||||
#if defined (WIN32)
|
||||
#ifdef _WIN32
|
||||
#include <wincrypt.h> // HCTYPTPROV, Crypt*-functions
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user