diff --git a/traceroute.cc b/traceroute.cc index 1fe2f42a4..9ab3ec1a8 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -202,6 +202,7 @@ Traceroute::Traceroute (const char *device_name, devtype type) { pd = NULL; total_size = 0; memset(&ref_ipaddr, '\0', sizeof(struct in_addr)); + cp_flag = 0; if(type == devt_loopback) return; @@ -500,12 +501,15 @@ Traceroute::readTraceResponses () { tp->ttl > 1 && tg->gotReply && tg->getState () != G_FINISH) { tg->setState (G_FINISH); tg->consolidation_start = tp->ttl+1; + cp_flag = 1; break; } else if (commonPath[tp->ttl] == 0) { commonPath[tp->ttl] = tp->ipreplysrc.s_addr; /* remember which host is the reference trace */ - if(tp->ttl == 1) - ref_ipaddr.s_addr = tg->ipdst; + if(!cp_flag) { + ref_ipaddr.s_addr = tg->ipdst; + cp_flag = 1; + } } break; case IPPROTO_TCP: diff --git a/traceroute.h b/traceroute.h index 2661d2904..6fe03183b 100644 --- a/traceroute.h +++ b/traceroute.h @@ -344,12 +344,11 @@ class Traceroute { * the groups destination IP address */ std::map < u32, TraceGroup * >TraceGroups; - struct scan_info scaninfo; Target **hops; pcap_t *pd; eth_t *ethsd; - int fd, total_size; + int fd, total_size, cp_flag; struct in_addr ref_ipaddr; /* called by outputTarget to log XML data */