--- traceroute.c.orig Mon Sep 2 14:45:19 2002 +++ traceroute.c Sun Sep 1 10:37:47 2002 @@ -319,7 +319,7 @@ int verbose; int waittime = 5; /* time to wait for response (in seconds) */ int nflag; /* print addresses numerically */ - +int incport = 1; /* increment dest port number after each hop */ extern int optind; extern int opterr; extern char *optarg; @@ -441,7 +441,7 @@ prog = argv[0]; opterr = 0; - while ((op = getopt(argc, argv, "Sdnrvg:M:m:P:p:q:s:t:w:")) != EOF) + while ((op = getopt(argc, argv, "Sdnrvg:M:m:P:p:q:s:t:w:0")) != EOF) switch (op) { case 'S': @@ -566,6 +566,10 @@ } break; + case '0': + incport = 0; + break; + default: usage(); } @@ -1064,7 +1068,10 @@ struct udphdr *const udp = (struct udphdr *) outprot; udp->uh_sport = htons(ident); + if (incport) udp->uh_dport = htons(port + outdata->seq); + else + udp->uh_dport = htons(port); udp->uh_ulen = htons((u_short)protlen); } @@ -1073,8 +1080,12 @@ { struct udphdr *const udp = (struct udphdr *) data; + if (incport) return (ntohs(udp->uh_sport) == ident && ntohs(udp->uh_dport) == port + seq); + else + return (ntohs(udp->uh_sport) == ident + && ntohs(udp->uh_dport) == port); } void @@ -1083,7 +1094,10 @@ struct tcphdr *const tcp = (struct tcphdr *) outprot; tcp->th_sport = htons(ident); + if (incport) tcp->th_dport = htons(port + outdata->seq); + else + tcp->th_dport = htons(port); tcp->th_seq = (tcp->th_sport << 16) | tcp->th_dport; tcp->th_ack = 0; tcp->th_off = 5; @@ -1095,8 +1109,12 @@ { struct tcphdr *const tcp = (struct tcphdr *) data; + if (incport) return (ntohs(tcp->th_sport) == ident && ntohs(tcp->th_dport) == port + seq); + else + return (ntohs(tcp->th_sport) == ident + && ntohs(tcp->th_dport) == port); } void @@ -1115,6 +1133,10 @@ { struct grehdr *const gre = (struct grehdr *) data; + if (incport) + return(ntohs(gre->proto) == port + && ntohs(gre->callId) == ident + seq); + else return(ntohs(gre->proto) == port && ntohs(gre->callId) == ident + seq); } @@ -1125,7 +1147,10 @@ u_int16_t *const ptr; ptr[0] = htons(ident); + if (incport) ptr[1] = htons(port + outdata->seq); + else + ptr[1] = htons(port); } int @@ -1133,8 +1158,12 @@ { u_int16_t *const ptr = (u_int16_t *) data; + if (incport) return(ntohs(ptr[0]) == ident && ntohs(ptr[1]) == port + seq); + else + return(ntohs(ptr[0]) == ident + && ntohs(ptr[1]) == port); } void