aboutsummaryrefslogtreecommitdiff
path: root/networking/traceroute.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--networking/traceroute.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 82bb0118c..96f9d3472 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -210,6 +210,51 @@
210 * Tue Dec 20 03:50:13 PST 1988 210 * Tue Dec 20 03:50:13 PST 1988
211 */ 211 */
212 212
213//usage:#define traceroute_trivial_usage
214//usage: "[-"IF_TRACEROUTE6("46")"FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]\n"
215//usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]\n"
216//usage: " [-z PAUSE_MSEC] HOST [BYTES]"
217//usage:#define traceroute_full_usage "\n\n"
218//usage: "Trace the route to HOST\n"
219//usage: "\nOptions:"
220//usage: IF_TRACEROUTE6(
221//usage: "\n -4,-6 Force IP or IPv6 name resolution"
222//usage: )
223//usage: "\n -F Set the don't fragment bit"
224//usage: "\n -I Use ICMP ECHO instead of UDP datagrams"
225//usage: "\n -l Display the TTL value of the returned packet"
226//usage: "\n -d Set SO_DEBUG options to socket"
227//usage: "\n -n Print numeric addresses"
228//usage: "\n -r Bypass routing tables, send directly to HOST"
229//usage: "\n -v Verbose"
230//usage: "\n -m Max time-to-live (max number of hops)"
231//usage: "\n -p Base UDP port number used in probes"
232//usage: "\n (default 33434)"
233//usage: "\n -q Number of probes per TTL (default 3)"
234//usage: "\n -s IP address to use as the source address"
235//usage: "\n -t Type-of-service in probe packets (default 0)"
236//usage: "\n -w Time in seconds to wait for a response (default 3)"
237//usage: "\n -g Loose source route gateway (8 max)"
238//usage:
239//usage:#define traceroute6_trivial_usage
240//usage: "[-dnrv] [-m MAXTTL] [-p PORT] [-q PROBES]\n"
241//usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-i IFACE]\n"
242//usage: " HOST [BYTES]"
243//usage:#define traceroute6_full_usage "\n\n"
244//usage: "Trace the route to HOST\n"
245//usage: "\nOptions:"
246//usage: "\n -d Set SO_DEBUG options to socket"
247//usage: "\n -n Print numeric addresses"
248//usage: "\n -r Bypass routing tables, send directly to HOST"
249//usage: "\n -v Verbose"
250//usage: "\n -m Max time-to-live (max number of hops)"
251//usage: "\n -p Base UDP port number used in probes"
252//usage: "\n (default is 33434)"
253//usage: "\n -q Number of probes per TTL (default 3)"
254//usage: "\n -s IP address to use as the source address"
255//usage: "\n -t Type-of-service in probe packets (default 0)"
256//usage: "\n -w Time in seconds to wait for a response (default 3)"
257
213#define TRACEROUTE_SO_DEBUG 0 258#define TRACEROUTE_SO_DEBUG 0
214 259
215/* TODO: undefs were uncommented - ??! we have config system for that! */ 260/* TODO: undefs were uncommented - ??! we have config system for that! */
@@ -482,7 +527,7 @@ send_probe(int seq, int ttl)
482 if (!(option_mask32 & OPT_USE_ICMP)) { 527 if (!(option_mask32 & OPT_USE_ICMP)) {
483 out = outdata; 528 out = outdata;
484 len -= sizeof(*outudp); 529 len -= sizeof(*outudp);
485 set_nport(dest_lsa, htons(port + seq)); 530 set_nport(&dest_lsa->u.sa, htons(port + seq));
486 } 531 }
487 } 532 }
488 533
@@ -1018,10 +1063,10 @@ common_traceroute_main(int op, char **argv)
1018 int probe_fd = xsocket(af, SOCK_DGRAM, 0); 1063 int probe_fd = xsocket(af, SOCK_DGRAM, 0);
1019 if (op & OPT_DEVICE) 1064 if (op & OPT_DEVICE)
1020 setsockopt_bindtodevice(probe_fd, device); 1065 setsockopt_bindtodevice(probe_fd, device);
1021 set_nport(dest_lsa, htons(1025)); 1066 set_nport(&dest_lsa->u.sa, htons(1025));
1022 /* dummy connect. makes kernel pick source IP (and port) */ 1067 /* dummy connect. makes kernel pick source IP (and port) */
1023 xconnect(probe_fd, &dest_lsa->u.sa, dest_lsa->len); 1068 xconnect(probe_fd, &dest_lsa->u.sa, dest_lsa->len);
1024 set_nport(dest_lsa, htons(port)); 1069 set_nport(&dest_lsa->u.sa, htons(port));
1025 1070
1026 /* read IP and port */ 1071 /* read IP and port */
1027 source_lsa = get_sock_lsa(probe_fd); 1072 source_lsa = get_sock_lsa(probe_fd);
@@ -1031,7 +1076,7 @@ common_traceroute_main(int op, char **argv)
1031 close(probe_fd); 1076 close(probe_fd);
1032 1077
1033 /* bind our sockets to this IP (but not port) */ 1078 /* bind our sockets to this IP (but not port) */
1034 set_nport(source_lsa, 0); 1079 set_nport(&source_lsa->u.sa, 0);
1035 xbind(sndsock, &source_lsa->u.sa, source_lsa->len); 1080 xbind(sndsock, &source_lsa->u.sa, source_lsa->len);
1036 xbind(rcvsock, &source_lsa->u.sa, source_lsa->len); 1081 xbind(rcvsock, &source_lsa->u.sa, source_lsa->len);
1037 1082