X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=eb438b0878b325603a15e00d7369a39385e6dd09;hb=df716df33af8e9a5b93d573a023ecd7fc24d9a03;hp=89172670e43766adb0b6822fb1218a4c6bd3e995;hpb=0912276c6467aa3ee6f570b31245367319da572a;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index 89172670..eb438b08 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1,7 +1,7 @@ /* net_packet.c -- Handles in- and outgoing VPN packets Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2021 Guus Sliepen + 2000-2022 Guus Sliepen 2010 Timothy Redaelli 2010 Brandon Black @@ -25,7 +25,6 @@ #ifdef HAVE_ZLIB #define ZLIB_CONST #include -#include #endif @@ -33,8 +32,8 @@ #include LZO1X_H #endif -#ifdef LZ4_H -#include LZ4_H +#ifdef HAVE_LZ4 +#include #endif #include "address_cache.h" @@ -65,11 +64,15 @@ int keylifetime = 0; static char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS]; #endif +#ifdef HAVE_LZ4 + #ifdef HAVE_LZ4_BUILTIN static LZ4_stream_t lz4_stream; #else static void *lz4_state = NULL; -#endif /* HAVE_LZ4_BUILTIN */ +#endif // HAVE_LZ4_BUILTIN + +#endif // HAVE_LZ4 static void send_udppacket(node_t *, vpn_packet_t *); @@ -252,8 +255,6 @@ static length_t compress_packet_lz4(uint8_t *dest, const uint8_t *source, length #ifdef HAVE_LZO static length_t compress_packet_lzo(uint8_t *dest, const uint8_t *source, length_t len, compression_level_t level) { - assert(level == COMPRESS_LZO_LO || level == COMPRESS_LZO_HI); - lzo_uint lzolen = MAXSIZE; int result; @@ -992,8 +993,8 @@ bool send_sptps_data(node_t *to, node_t *from, int type, const void *data, size_ overhead += sizeof(to->id) + sizeof(from->id); } - uint8_t buf[len + overhead]; - uint8_t *buf_ptr = buf; + char buf[len + overhead]; + char *buf_ptr = buf; if(relay_supported) { if(direct) { @@ -1165,7 +1166,7 @@ static void send_udp_probe_packet(node_t *n, size_t len) { vpn_packet_t packet; if(len > sizeof(packet.data)) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Truncating probe length %zu to %s (%s)", len, n->name, n->hostname); + logger(DEBUG_TRAFFIC, LOG_INFO, "Truncating probe length %lu to %s (%s)", (unsigned long)len, n->name, n->hostname); len = sizeof(packet.data); } @@ -1175,7 +1176,7 @@ static void send_udp_probe_packet(node_t *n, size_t len) { packet.len = len; packet.priority = 0; - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending UDP probe length %zu to %s (%s)", len, n->name, n->hostname); + logger(DEBUG_TRAFFIC, LOG_INFO, "Sending UDP probe length %lu to %s (%s)", (unsigned long)len, n->name, n->hostname); send_udppacket(n, &packet); } @@ -1261,7 +1262,7 @@ static length_t choose_initial_maxmtu(node_t *n) { int ip_mtu; socklen_t ip_mtu_len = sizeof(ip_mtu); - if(getsockopt(sock, IPPROTO_IP, IP_MTU, &ip_mtu, &ip_mtu_len)) { + if(getsockopt(sock, IPPROTO_IP, IP_MTU, (void *)&ip_mtu, &ip_mtu_len)) { logger(DEBUG_TRAFFIC, LOG_ERR, "getsockopt(IP_MTU) on %s (%s) failed: %s", n->name, n->hostname, sockstrerror(sockerrno)); close(sock); return MTU; @@ -1424,7 +1425,7 @@ static void try_mtu(node_t *n) { on the precise MTU as we are approaching it. The last probe of the cycle is always 1 byte in size - this is to make sure we'll get at least one reply per cycle so that we can make progress. */ - offset = (length_t) powf(interval, multiplier * cycle_position / ((float) probes_per_cycle - 1.0f)); + offset = lrintf(powf(interval, multiplier * cycle_position / (float)(probes_per_cycle - 1))); } length_t maxmtu = n->maxmtu;