diff --git a/Target.h b/Target.h index c302c76c9..7c75f511c 100644 --- a/Target.h +++ b/Target.h @@ -254,10 +254,8 @@ class Target { FingerPrintResults *FPR; /* FP results get by the OS scan system. */ PortList ports; - // unsigned int up; - // unsigned int down; int weird_responses; /* echo responses from other addresses, Ie a network broadcast address */ - unsigned int flags; /* HOST_UP, HOST_DOWN, HOST_FIREWALLED, HOST_BROADCAST (instead of HOST_BROADCAST use weird_responses */ + unsigned int flags; /* HOST_UNKNOWN, HOST_UP, or HOST_DOWN. */ struct timeout_info to; char *hostname; // Null if unable to resolve or unset char * targetname; // The name of the target host given on the commmand line if it is a named host diff --git a/nmap.h b/nmap.h index 74b26cae3..02611c7d9 100644 --- a/nmap.h +++ b/nmap.h @@ -332,8 +332,6 @@ void *realloc(); #define HOST_UNKNOWN 0 #define HOST_UP 1 #define HOST_DOWN 2 -#define HOST_FIREWALLED 4 -#define HOST_BROADCAST 8 /* use the weird_responses member of hoststruct instead */ #define PINGTYPE_UNKNOWN 0 #define PINGTYPE_NONE 1 diff --git a/scan_engine.cc b/scan_engine.cc index 4f006e0a1..846583c0e 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2560,8 +2560,6 @@ static const char *readhoststate(int state) { return "HOST_UP"; case HOST_DOWN: return "HOST_DOWN"; - case HOST_FIREWALLED: - return "HOST_FIREWALLED"; default: return "COMBO"; } @@ -2572,16 +2570,10 @@ static const char *readhoststate(int state) { /* Update state of the host in hss based on its current state and newstate. */ static void ultrascan_host_pspec_update(UltraScanInfo *USI, HostScanStats *hss, const probespec *pspec, int newstate) { - /* Adjust the target flags to note the new state. */ - if ((hss->target->flags & HOST_UP) == 0) { - if (newstate == HOST_UP) { - /* Clear any HOST_DOWN or HOST_FIREWALLED flags */ - hss->target->flags &= ~(HOST_DOWN|HOST_FIREWALLED); - hss->target->flags |= HOST_UP; - } else if (newstate == HOST_DOWN) { - hss->target->flags &= ~HOST_FIREWALLED; - hss->target->flags |= HOST_DOWN; - } else assert(0); + /* If the host is already up, ignore any further updates. */ + if (hss->target->flags != HOST_UP) { + assert(newstate == HOST_UP || newstate == HOST_DOWN); + hss->target->flags = newstate; } } diff --git a/targets.cc b/targets.cc index 78d6ce281..caae07749 100644 --- a/targets.cc +++ b/targets.cc @@ -130,20 +130,6 @@ static inline int gethostnum(Target *hostbatch[], Target *target) { return 0; // Unreached } -const char *readhoststate(int state) { - switch(state) { - case HOST_UP: - return "HOST_UP"; - case HOST_DOWN: - return "HOST_DOWN"; - case HOST_FIREWALLED: - return "HOST_FIREWALLED"; - default: - return "UNKNOWN/COMBO"; - } - return NULL; -} - /* Conducts an ARP ping sweep of the given hosts to determine which ones are up on a local ethernet network */ static void arpping(Target *hostbatch[], int num_hosts) { @@ -163,15 +149,13 @@ static void arpping(Target *hostbatch[], int num_hosts) { log_write(LOG_STDOUT|LOG_NORMAL, "ARP ping: Considering %s UP because it is a local IP, despite no MAC address for device %s\n", hostbatch[targetno]->NameIP(), hostbatch[targetno]->deviceName()); - hostbatch[targetno]->flags &= ~(HOST_DOWN|HOST_FIREWALLED); - hostbatch[targetno]->flags |= HOST_UP; + hostbatch[targetno]->flags = HOST_UP; } else { log_write(LOG_STDOUT|LOG_NORMAL, "ARP ping: Considering %s DOWN because no MAC address found for device %s.\n", hostbatch[targetno]->NameIP(), hostbatch[targetno]->deviceName()); - hostbatch[targetno]->flags &= ~HOST_FIREWALLED; - hostbatch[targetno]->flags |= HOST_DOWN; + hostbatch[targetno]->flags = HOST_DOWN; } continue; }