1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 19:39:07 +00:00

The previous method of calculating the true hop distance from traceroute

was incorrect; the hopDistance member can be much higher than the actual
number of hops recorded. It was 33 when the real distance was 17.
Instead, enumerate and count all the probes that got a response.
This commit is contained in:
david
2009-08-21 01:05:41 +00:00
parent 5d29abaf05
commit a4ea6d2f7c

View File

@@ -1290,11 +1290,23 @@ TraceGroup::setHopDistance(u8 hop_distance, u8 ttl) {
* reading hopDistance, which despite its name does not contain the final hop
* count. */
int TraceGroup::getDistance() {
map < u8, TraceProbe * >ttlProbes;
int i;
if (this->getState() != G_FINISH)
return -1;
/* After a successful trace, hopDistance is 1 greater than the number of
* hops. */
return this->hopDistance - 1;
for (i = 1; i < consolidation_start; i++) {
if (commonPath[i] == 0)
return i - 1;
}
ttlProbes = consolidateHops();
for ( ; i < MAX_TTL; i++) {
if (ttlProbes.find(i) == ttlProbes.end())
break;
}
return i - 1;
}
TraceProbe::TraceProbe(u32 dip, u32 sip, u16 sport, struct probespec& probe) {