From 188442662dc5c3c8d140d5b87685ab6ca486d430 Mon Sep 17 00:00:00 2001 From: ejlbell Date: Mon, 7 Jan 2008 14:39:40 +0000 Subject: [PATCH] =?UTF-8?q?Traceroute=20bugfix=20for=20when=20the=20first?= =?UTF-8?q?=20hop=20of=20the=20first=20host=20in=20a=20tracegroup=20(refer?= =?UTF-8?q?ence=20trace)=20times=20out.=20The=20previous=20patch=20did=20n?= =?UTF-8?q?ot=20completely=20solve=20the=20issue=20due=20to=20an=20erronou?= =?UTF-8?q?s=20check=20on=20the=20ttl,=20now=20we=20use=20a=20dedicated=20?= =?UTF-8?q?boolean=20flag.=20Thanks=20to=20Sebasti=C3=A1n=20Garc=C3=ADa=20?= =?UTF-8?q?for=20the=20bug=20report=20and=20testing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- traceroute.cc | 8 ++++++-- traceroute.h | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) 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 */