From: Guus Sliepen <guus@tinc-vpn.org>
Date: Wed, 13 Jun 2018 20:23:27 +0000 (+0200)
Subject: Merge remote-tracking branch 'volth/release-1.1pre16-rtt' into 1.1
X-Git-Tag: release-1.1pre17~15
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=22ae0c3549628739ca7c40e48ce1a276469ded92;p=oweals%2Ftinc.git

Merge remote-tracking branch 'volth/release-1.1pre16-rtt' into 1.1

Also, reformat the code and fix a compiler warning.
---

22ae0c3549628739ca7c40e48ce1a276469ded92
diff --cc src/info.c
index 09e6580,4ca67ec..f0dce8c
--- a/src/info.c
+++ b/src/info.c
@@@ -143,6 -145,8 +145,10 @@@ static int info_node(int fd, const cha
  
  	if(status.udp_confirmed) {
  		printf(" udp_confirmed");
 -		if(udp_ping_rtt != -1)
 -			printf(" (rtt %ld.%03ld)", udp_ping_rtt / 1000, udp_ping_rtt % 1000);
++
++		if(udp_ping_rtt != -1) {
++			printf(" (rtt %d.%03d)", udp_ping_rtt / 1000, udp_ping_rtt % 1000);
++		}
  	}
  
  	printf("\n");
diff --cc src/net_packet.c
index 8ade057,ee2b316..ebf2938
--- a/src/net_packet.c
+++ b/src/net_packet.c
@@@ -151,7 -152,15 +152,15 @@@ static void udp_probe_h(node_t *n, vpn_
  		len = ntohs(len16);
  	}
  
- 	logger(DEBUG_TRAFFIC, LOG_INFO, "Got type %d UDP probe reply %d from %s (%s)", DATA(packet)[0], len, n->name, n->hostname);
 -	if (n->udp_ping_sent.tv_sec != 0) { // a probe in flight
++	if(n->udp_ping_sent.tv_sec != 0) {  // a probe in flight
+ 		gettimeofday(&now, NULL);
+ 		struct timeval rtt;
+ 		timersub(&now, &n->udp_ping_sent, &rtt);
 -		n->udp_ping_rtt = rtt.tv_sec*1000000 + rtt.tv_usec;
++		n->udp_ping_rtt = rtt.tv_sec * 1000000 + rtt.tv_usec;
+ 		logger(DEBUG_TRAFFIC, LOG_INFO, "Got type %d UDP probe reply %d from %s (%s) rtt=%d.%03d", DATA(packet)[0], len, n->name, n->hostname, n->udp_ping_rtt / 1000, n->udp_ping_rtt % 1000);
+ 	} else {
+ 		logger(DEBUG_TRAFFIC, LOG_INFO, "Got type %d UDP probe reply %d from %s (%s)", DATA(packet)[0], len, n->name, n->hostname);
+ 	}
  
  	/* It's a valid reply: now we know bidirectional communication
  	   is possible using the address and socket that the reply
diff --cc src/tincctl.c
index cf19d48,d8df67c..12e5ead
--- a/src/tincctl.c
+++ b/src/tincctl.c
@@@ -1331,8 -1333,11 +1333,14 @@@ static int cmd_dump(int argc, char *arg
  					continue;
  				}
  
- 				printf("%s id %s at %s port %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %d (min %d max %d)\n",
- 				       node, id, host, port, cipher, digest, maclength, compression, options, status_int, nexthop, via, distance, pmtu, minmtu, maxmtu);
+ 				printf("%s id %s at %s port %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %d (min %d max %d) rx %"PRIu64" %"PRIu64" tx %"PRIu64" %"PRIu64,
+ 				       node, id, host, port, cipher, digest, maclength, compression, options, status_int, nexthop, via, distance, pmtu, minmtu, maxmtu, in_packets, in_bytes, out_packets, out_bytes);
 -				if (udp_ping_rtt != -1)
++
++				if(udp_ping_rtt != -1) {
+ 					printf(" rtt %d.%03d", udp_ping_rtt / 1000, udp_ping_rtt % 1000);
++				}
++
+ 				printf("\n");
  			}
  		}
  		break;