]>
Commit | Line | Data |
---|---|---|
4b5acd73 | 1 | Only in clink.1.0a: .collect.c.swp |
2 | Only in clink.1.0a: clink | |
3 | diff -ru clink.1.0/collect.c clink.1.0a/collect.c | |
4 | --- clink.1.0/collect.c Sat Aug 14 22:47:04 1999 | |
5 | +++ clink.1.0a/collect.c Sat Jun 24 16:50:19 2000 | |
6 | @@ -95,13 +95,22 @@ | |
7 | the header of the packet that caused the error */ | |
8 | ||
9 | hip = (struct ip *) (recvbuf + hlen1 + 8); | |
10 | - if (hip->ip_p != IPPROTO_UDP) return 0; | |
11 | + if (hip->ip_p != IPPROTO_UDP) { | |
12 | + if (verbose) printf("Wrong protocol %d != %d\n", hip->ip_p, IPPROTO_UDP); | |
13 | + return 0; | |
14 | + } | |
15 | ||
16 | hlen2 = hip->ip_hl << 2; | |
17 | udp = (struct udphdr *) (recvbuf + hlen1 + 8 + hlen2); | |
18 | ||
19 | - if (udp->source != htons (sport)) return 0; | |
20 | - if (udp->dest != htons (dport)) return 0; | |
21 | + if (udp->source != htons (sport)) { | |
22 | + if (verbose) printf("Wrong source port %d != %d\n", ntohs(udp->source), (sport)); | |
23 | + return 0; | |
24 | + } | |
25 | + if (udp->dest != htons (dport)) { | |
26 | + if (verbose) printf("Wrong destination port %d != %d\n", ntohs(udp->dest), (dport)); | |
27 | + return 0; | |
28 | + } | |
29 | ||
30 | /* now we know it's an ICMP packet caused by a UDP | |
31 | datagram sent by us and sent to the port we happen to | |
32 | @@ -118,7 +127,7 @@ | |
33 | } | |
34 | ||
35 | if (icmp->icmp_type == ICMP_DEST_UNREACH) { | |
36 | - if (icmp->icmp_code == ICMP_PORT_UNREACH) { | |
37 | + if ( (icmp->icmp_code == ICMP_PORT_UNREACH) || (icmp->icmp_code == ICMP_PKT_FILTERED) ) { | |
38 | return -1; | |
39 | } else { | |
40 | return 0; | |
41 | @@ -344,7 +353,7 @@ | |
42 | fill in the timestamps. I am assuming that they don't have | |
43 | any actual effect. */ | |
44 | ||
45 | -void clink_init (char *host, int tos) | |
46 | +void clink_init (char *host, int sport0, int tos) | |
47 | { | |
48 | int n; | |
49 | struct addrinfo *ai = NULL; | |
50 | @@ -403,6 +412,8 @@ | |
51 | ||
52 | sabind->sa_family = sasend->sa_family; | |
53 | sport = (getpid() & 0xffff) | 0x8000; /* source UDP port # */ | |
54 | +if (sport>=61000) sport -= 10000; | |
55 | + if (sport0>0) sport = sport0; | |
56 | sock_set_port (sabind, salen, htons(sport)); | |
57 | Bind (sendfd, sabind, salen); | |
58 | ||
59 | Only in clink.1.0a: collect.o | |
60 | diff -ru clink.1.0/process.c clink.1.0a/process.c | |
61 | --- clink.1.0/process.c Sat Aug 14 22:47:04 1999 | |
62 | +++ clink.1.0a/process.c Thu Jun 22 19:21:52 2000 | |
63 | @@ -21,6 +21,8 @@ | |
64 | int wait_time = 2; /* how many seconds to wait before timeout */ | |
65 | int dns_resolve = 1; /* flag: should we use DNS to resolve addrs? */ | |
66 | int verbose = 0; /* flag: should we print verbose output */ | |
67 | +int quiet = 0; /* flag: no messages for each packet */ | |
68 | +int sport0 = 0; /* source port */ | |
69 | /* how long should we wait between probes */ | |
70 | double inter_sample_ratio = 10.0; /* a multiple of the previous rtt? */ | |
71 | double inter_sample_time = 0.0; /* or a fixed interval in microsecs */ | |
72 | @@ -1073,11 +1075,15 @@ | |
73 | printf ("ttl=%d\t%s\tsize= %4d B\trtt= %.3lf ms\n", | |
74 | ttl, Sock_ntop_host (datum->addr, salen), size, datum->rtt); | |
75 | } else { | |
76 | - printf (" \r"); | |
77 | - printf ("n=%5d\t%s\tsize= %4d B\trtt= %.3lf ms\r", | |
78 | - probe_count, Sock_ntop_host (datum->addr, salen), size, datum->rtt); | |
79 | + if (!quiet) { | |
80 | + printf (" \r"); | |
81 | + printf ("n=%5d\t%s\tsize= %4d B\trtt= %.3lf ms\r", | |
82 | + probe_count, Sock_ntop_host (datum->addr, salen), size, datum->rtt); | |
83 | + } | |
84 | + } | |
85 | + if (!quiet) { | |
86 | + fflush(stdout); | |
87 | } | |
88 | - fflush(stdout); | |
89 | ||
90 | add_datum (ttl, size, datum); | |
91 | ||
92 | @@ -1282,7 +1288,7 @@ | |
93 | tos = IPTOS_LOWDELAY | IPTOS_THROUGHPUT | IPTOS_MINCOST; | |
94 | } | |
95 | ||
96 | - clink_init (host, tos); | |
97 | + clink_init (host, sport0, tos); | |
98 | ||
99 | sizes = make_sizes (low, high, step); | |
100 | ||
101 | @@ -1325,7 +1331,7 @@ | |
102 | int i, c; | |
103 | ||
104 | opterr = 0; | |
105 | - while ( (c = getopt (argc, argv, "knvMD:I:f:h:i:l:m:q:r:s:t:w:")) != -1) { | |
106 | + while ( (c = getopt (argc, argv, "knvMD:I:f:h:i:l:m:p:q:Qr:s:t:w:")) != -1) { | |
107 | switch (c) { | |
108 | case 'k': | |
109 | kernel_timestamps = 1; | |
110 | @@ -1396,6 +1402,15 @@ | |
111 | case 'q': | |
112 | if ( (num_probes = atoi(optarg)) < 2) { | |
113 | err_quit ("invalid -q value (num_probes); must be at least 2"); | |
114 | + } | |
115 | + break; | |
116 | + case 'Q': | |
117 | + quiet = 1; | |
118 | + break; | |
119 | + case 'p': | |
120 | + sport0 = atoi(optarg); | |
121 | + if ( (sport0<= 0) || (sport0>=65536) ) { | |
122 | + err_quit ("invalid -p (source port); must be in 1..65535 range"); | |
123 | } | |
124 | break; | |
125 | case 'w': | |
126 | Only in clink.1.0a: process.o | |
127 | Only in clink.1.0a: util.o |