fputs("\n", out);
fputs(" -F, --filename FILE read hostname(s) from a file\n", out);
fputs(" -4 use IPv4 only\n", out);
+ #ifdef ENABLE_IPV6
fputs(" -6 use IPv6 only\n", out);
- fputs(" -u, --udp use udp instead of icmp echo\n", out);
- fputs(" -T, --tcp use tcp instead of icmp echo\n", out);
+ #endif
+ fputs(" -u, --udp use UDP instead of ICMP echo\n", out);
+ fputs(" -T, --tcp use TCP instead of ICMP echo\n", out);
fputs(" -a, --address ADDRESS bind the outgoing socket to ADDRESS\n", out);
fputs(" -f, --first-ttl NUMBER set what TTL to start\n", out);
fputs(" -m, --max-ttl NUMBER maximum number of hops\n", out);
fputs(" -G, --gracetime SECONDS number of seconds to wait for responses\n", out);
fputs(" -Q, --tos NUMBER type of service field in IP header\n", out);
fputs(" -e, --mpls display information from ICMP extensions\n", out);
- fputs(" -Z, --timeout SECONDS seconds to keep the TCP socket open\n", out);
+ fputs(" -Z, --timeout SECONDS seconds to keep probe sockets open\n", out);
+ #ifdef SO_MARK
fputs(" -M, --mark MARK mark each sent packet\n", out);
+ #endif
fputs(" -r, --report output using report mode\n", out);
fputs(" -w, --report-wide output wide report\n", out);
fputs(" -c, --report-cycles COUNT set the number of pings sent\n", out);
{ "max-unknown", 1, NULL, 'U' },
{ "udp", 0, NULL, 'u' }, /* UDP (default is ICMP) */
{ "tcp", 0, NULL, 'T' }, /* TCP (default is ICMP) */
+ #ifdef HAS_SCTP
{ "sctp", 0, NULL, 'S' }, /* SCTP (default is ICMP) */
+ #endif
{ "port", 1, NULL, 'P' }, /* target port number for TCP/SCTP/UDP */
{ "localport", 1, NULL, 'L' }, /* source port number for UDP */
- { "timeout", 1, NULL, 'Z' }, /* timeout for TCP sockets */
+ { "timeout", 1, NULL, 'Z' }, /* timeout for probe sockets */
{ "gracetime", 1, NULL, 'G' }, /* gracetime for replies after last probe */
#ifdef SO_MARK
{ "mark", 1, NULL, 'M' }, /* use SO_MARK */
#ifdef ENABLE_IPV6
struct sockaddr_in6 * sa6;
#endif
- names_t *names_root = NULL;
- names_t **names_head = &names_root;
- time_t now;
+ names_t *names_head = NULL;
+ names_t *names_walk;
struct mtr_ctl ctl;
memset(&ctl, 0, sizeof(ctl));
while (optind < argc) {
char* name = argv[optind++];
- append_to_names(names_head, name);
+ append_to_names(&names_head, name);
}
- if (!names_root) append_to_names (names_head, "localhost"); /* default: localhost. */
- /* Now that we know mtrtype we can select which socket to use */
- if (net_selectsocket(&ctl) != 0) {
- error(EXIT_FAILURE, 0, "Couldn't determine raw socket type");
- }
-
+ /* default: localhost. */
+ if (!names_head) append_to_names(&names_head, "localhost");
- names_head = &names_root;
- while (*names_head != NULL) {
+ names_walk = names_head;
+ while (names_walk != NULL) {
- ctl.Hostname = names_root->name;
+ ctl.Hostname = names_walk->name;
if (gethostname(ctl.LocalHostname, sizeof(ctl.LocalHostname))) {
xstrncpy(ctl.LocalHostname, "UNKNOWNHOST", sizeof(ctl.LocalHostname));
}
}
}
- if (net_set_interfaceaddress (&ctl) != 0) {
- error(0, 0, "Couldn't set interface address: %s", ctl.InterfaceAddress);
- if (ctl.Interactive)
- exit(EXIT_FAILURE);
- else {
- names_walk = names_walk->next;
- continue;
- }
- }
-
--
lock(stdout);
dns_open(&ctl);
display_open(&ctl);
display_loop(&ctl);
net_end_transit();
- now = time(NULL);
- display_close(&ctl, now);
+ display_close(&ctl);
unlock(stdout);
- if (ctl.DisplayMode != DisplayCSV)
+ if (ctl.Interactive)
break;
else
- names_root = names_root->next;
+ names_walk = names_walk->next;
}