From bd49b4e3a378e48e266df5dcf488dc34e549a875 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Sun, 7 Jun 2020 13:51:48 +0200 Subject: [PATCH] Compilation fixes --- edge_utils.c | 30 +++++++++++++++++++++++++----- tools/benchmark.c | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/edge_utils.c b/edge_utils.c index 47c0fd3..72ff8ab 100644 --- a/edge_utils.c +++ b/edge_utils.c @@ -18,7 +18,10 @@ #include "n2n.h" #include "lzoconf.h" + +#ifdef HAVE_LIBZSTD #include +#endif #ifdef WIN32 #include @@ -163,7 +166,10 @@ const char* compression_str(uint8_t cmpr) { switch(cmpr) { case N2N_COMPRESSION_ID_NONE: return("none"); case N2N_COMPRESSION_ID_LZO: return("lzo1x"); + +#ifdef HAVE_LIBZSTD case N2N_COMPRESSION_ID_ZSTD: return("zstd"); +#endif default: return("invalid"); }; } @@ -334,9 +340,21 @@ static uint8_t localhost_v6[IPV6_SIZE] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; * in the same supernode host. */ static int is_valid_peer_sock(const n2n_sock_t *sock) { - if(((sock->family == AF_INET) && (*((uint32_t*)sock->addr.v4) != htonl(localhost_v4))) - || ((sock->family == AF_INET6) && memcmp(sock->addr.v6, localhost_v6, IPV6_SIZE))) - return(1); + switch(sock->family) { + case AF_INET: + { + uint32_t *a = (uint32_t*)sock->addr.v4; + + if(*a != htonl(localhost_v4)) + return(1); + } + break; + + case AF_INET6: + if(memcmp(sock->addr.v6, localhost_v6, IPV6_SIZE)) + return(1); + break; + } return(0); } @@ -2313,7 +2331,8 @@ static int edge_init_routes(n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_r */ n2n_sock_t sn; n2n_route_t custom_route; - + uint32_t *a; + if(eee->sn_route_to_clean) { traceEvent(TRACE_ERROR, "Only one default gateway route allowed"); return(-1); @@ -2332,7 +2351,8 @@ static int edge_init_routes(n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_r return(-1); } - custom_route.net_addr = *((u_int32_t*)sn.addr.v4); + a = (u_int32_t*)sn.addr.v4; + custom_route.net_addr = *a; custom_route.net_bitlen = 32; custom_route.gateway = get_gateway_ip(); diff --git a/tools/benchmark.c b/tools/benchmark.c index a74765f..748b0e7 100644 --- a/tools/benchmark.c +++ b/tools/benchmark.c @@ -128,7 +128,7 @@ int main(int argc, char * argv[]) { #ifdef N2N_HAVE_AES run_transop_benchmark("transop_aes", &transop_aes_cbc, &conf, pktbuf); #endif -#ifdef N2N_HAVE_AES +#ifdef HAVE_OPENSSL_1_1 run_transop_benchmark("transop_cc20", &transop_cc20, &conf, pktbuf); #endif run_transop_benchmark("transop_speck", &transop_speck, &conf, pktbuf);