From 300e038aa6096023d2c73187668668b7193cdbb6 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 16 Nov 2009 08:36:58 +0000 Subject: [PATCH] Print host timing information ("Final times for host" and the times element in XML) even when doing only a ping scan. Don't print the information if it was never set; i.e., we never measured an RTT to the target. --- nmap.cc | 8 +++----- output.cc | 11 +++++++++++ output.h | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/nmap.cc b/nmap.cc index e8f5953fc..f3e0c2f1e 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1732,6 +1732,7 @@ int nmap_main(int argc, char *argv[]) { printmacinfo(currenths); // if (currenths->flags & HOST_UP) // log_write(LOG_PLAIN,"\n"); + printtimes(currenths); log_write(LOG_XML, "\n"); log_flush_all(); delete currenths; @@ -1915,11 +1916,8 @@ int nmap_main(int argc, char *argv[]) { if (o.traceroute) printtraceroute(currenths); - if (o.debugging) - log_write(LOG_STDOUT, "Final times for host: srtt: %d rttvar: %d to: %d\n", - currenths->to.srtt, currenths->to.rttvar, currenths->to.timeout); - log_write(LOG_XML, "\n", - currenths->to.srtt, currenths->to.rttvar, currenths->to.timeout); + printtimes(currenths); + log_write(LOG_PLAIN|LOG_MACHINE,"\n"); log_write(LOG_XML, "\n"); } diff --git a/output.cc b/output.cc index 3550eaf6b..b7384a30c 100644 --- a/output.cc +++ b/output.cc @@ -2201,6 +2201,17 @@ void printtraceroute(Target * currenths) { printtraceroute_xml(currenths); } +void printtimes(Target *currenths) { + if (currenths->to.srtt != -1 || currenths->to.rttvar != -1) { + if (o.debugging) { + log_write(LOG_STDOUT, "Final times for host: srtt: %d rttvar: %d to: %d\n", + currenths->to.srtt, currenths->to.rttvar, currenths->to.timeout); + } + log_write(LOG_XML, "\n", + currenths->to.srtt, currenths->to.rttvar, currenths->to.timeout); + } +} + /* Prints a status message while the program is running */ void printStatusMessage() { // Pre-computations diff --git a/output.h b/output.h index 404b333d0..05ea6ca6d 100644 --- a/output.h +++ b/output.h @@ -201,6 +201,9 @@ void printhostscriptresults(Target *currenths); /* Print a table with traceroute hops. */ void printtraceroute(Target *currenths); +/* Print "times for host" output with latency. */ +void printtimes(Target *currenths); + /* Print a detailed list of Nmap interfaces and routes to normal/skiddy/stdout output */ int print_iflist(void);