len = ntohs(len16);
}
- if(n->udp_ping_sent.tv_sec != 0) { // a probe in flight
+ if(n->status.ping_sent) { // 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->status.ping_sent = false;
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);
reset_address_cache(n->address_cache, &n->address);
}
- // Reset the UDP ping timer. (no probe in flight)
- n->udp_ping_sent.tv_sec = 0;
+ // Reset the UDP ping timer.
if(udp_discovery) {
timeout_del(&n->udp_ping_timeout);
if(ping_tx_elapsed.tv_sec >= interval) {
gettimeofday(&now, NULL);
n->udp_ping_sent = now; // a probe in flight
+ n->status.ping_sent = true;
send_udp_probe_packet(n, MIN_PROBE_SIZE);
if(localdiscovery && !n->status.udp_confirmed && n->prevedge) {
unsigned int udppacket: 1; /* 1 if the most recently received packet was UDP */
unsigned int validkey_in: 1; /* 1 if we have sent a valid key to him */
unsigned int has_address: 1; /* 1 if we know an external address for this node */
- unsigned int unused: 20;
+ unsigned int ping_sent: 1; /* 1 if we sent a UDP probe but haven't received the reply yet */
+ unsigned int unused: 19;
} node_status_t;
typedef struct node_t {