--- ping.c Tue May 19 11:16:15 1998 +++ newping.c Tue Nov 24 09:42:39 1998 @@ -180,6 +180,7 @@ char DOT = '.'; static char *hostname; static int ident; /* process id to identify our packets */ +static struct in_addr dest_addr_store; /* counters */ static long npackets; /* max packets to transmit */ @@ -393,6 +394,8 @@ hostname = hnamebuf; } + dest_addr_store = to->sin_addr; + if (options & F_FLOOD && options & F_INTERVAL) { (void)fprintf(stderr, "ping: -f and -i incompatible options.\n"); @@ -716,6 +719,14 @@ if (options & F_QUIET) return; + /* Check reply is from pinged host */ + if (memcmp(&dest_addr_store, &ip->saddr, sizeof(struct in_addr))) { + printf("Reply not from target. Source %s",inet_ntoa(*(struct in_addr *)&from->sin_addr.s_addr)); + (void)printf(" ttl=%d", ip->ip_ttl); + if (timing) + (void)printf(" time=%ld.%ld ms", triptime/10, triptime%10); + } + else if (options & F_FLOOD) (void)write(STDOUT_FILENO, &BSPACE, 1); else {