From 45b783c57395b2a37adfb345b46986e393e28d25 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 17 Sep 2009 15:11:20 +0000 Subject: [PATCH] Print "--" for the RTT of traceroute hops if the RTT is unknown. This can only happen in the case of a directly connected target with no ping or port scan responses, like nmap -PN -sP --send-ip --traceroute --- output.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/output.cc b/output.cc index 6b4b59542..d79dfac40 100644 --- a/output.cc +++ b/output.cc @@ -1986,7 +1986,10 @@ static void printtraceroute_normal(Target *currenths) { /* Normal hop output. */ it->display_name(namebuf, sizeof(namebuf)); - Tbl.addItemFormatted(row, RTT_COL, false, "%.2f ms", it->rtt); + if (it->rtt < 0) + Tbl.addItem(row, RTT_COL, false, "--"); + else + Tbl.addItemFormatted(row, RTT_COL, false, "%.2f ms", it->rtt); Tbl.addItemFormatted(row, HOST_COL, false, "%s", namebuf); row++; it++; @@ -2029,8 +2032,12 @@ static void printtraceroute_xml(Target *currenths) { it++) { if (it->timedout) continue; - log_write(LOG_XML, "ttl, it->rtt, inet_ntop_ez(&it->addr, sizeof(it->addr))); + log_write(LOG_XML, "ttl, inet_ntop_ez(&it->addr, sizeof(it->addr))); + if (it->rtt < 0) + log_write(LOG_XML, " rtt=\"--\""); + else + log_write(LOG_XML, " rtt=\"%.2f\"", it->rtt); if (!it->name.empty()) log_write(LOG_XML, " host=\"%s\"", it->name.c_str()); log_write(LOG_XML, "/>\n");