From 682b8cbc535c96420c3ec57dd1b7c8adb584b300 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 16 Nov 2009 19:38:37 +0000 Subject: [PATCH] Include the reason why a host is down with --reason. It looks like this: Nmap scan report for 1.2.3.4 [host down, received time-exceeded] Nmap scan report for 1.2.3.5 [host down, received no-response] --- output.cc | 10 +++++++--- portreasons.cc | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/output.cc b/output.cc index b7384a30c..2a1af742f 100644 --- a/output.cc +++ b/output.cc @@ -1425,10 +1425,14 @@ static char *num_to_string_sigdigits(double d, int digits) { including host status and DNS records. */ void write_host_header(Target *currenths) { if ((currenths->flags & HOST_UP) || o.verbose || o.resolve_all) { - if (currenths->flags & HOST_UP) + if (currenths->flags & HOST_UP) { log_write(LOG_PLAIN, "Nmap scan report for %s\n", currenths->NameIP()); - else if (currenths->flags & HOST_DOWN) - log_write(LOG_PLAIN, "Nmap scan report for %s [host down]\n", currenths->NameIP()); + } else if (currenths->flags & HOST_DOWN) { + log_write(LOG_PLAIN, "Nmap scan report for %s [host down", currenths->NameIP()); + if (o.reason) + log_write(LOG_PLAIN, ", %s", target_reason_str(currenths)); + log_write(LOG_PLAIN, "]\n"); + } } write_host_status(currenths, o.resolve_all); if (currenths->TargetName() != NULL diff --git a/portreasons.cc b/portreasons.cc index 495b19d16..496f2c893 100644 --- a/portreasons.cc +++ b/portreasons.cc @@ -357,7 +357,6 @@ void print_xml_state_summary(PortList *Ports, int state) { char *target_reason_str(Target *t) { static char reason[128]; memset(reason,'\0', 128); - assert(t->reason.reason_id != ER_NORESPONSE); Snprintf(reason, 128, "received %s", reason_str(t->reason.reason_id, SINGULAR)); return reason; }