Send one ICMP packet (per host) each I<interval> seconds. This can be a
floating-point number to specify sub-second precision.
+=item B<-t> I<ttl>
+
+Set the IP Time to Live to I<ttl>. This must be a number between (and
+including) 1E<nbsp>andE<nbsp>255. If omitted, the value B<64> is used.
+
=item B<-I> I<address>
Set the source address to use. You B<cannot> pass the interface name, as you
=back
-=head1 BUGS
-
-=over 4
-
-=item The TTL cannot be set
-
-=back
-
=head1 SEE ALSO
L<ping(8)>, L<http://www.fping.com/>, L<liboping(3)>
static int opt_addrfamily = PING_DEF_AF;
static char *opt_srcaddr = NULL;
static int opt_count = -1;
+static int opt_send_ttl = 64;
static void sigint_handler (int signal)
{
static void usage_exit (const char *name)
{
- fprintf (stderr, "Usage: %s [-46] [-c count] [-i interval] host [host [host ...]]\n",
- name);
+ int name_length;
+
+ name_length = (int) strlen (name);
+
+ fprintf (stderr, "Usage: %s [-46] [-c count] [-i interval]\n"
+ "%*s[-t ttl] [-I srcaddr]\n"
+ "%*shost [host [host ...]]\n",
+ name,
+ 8 + name_length, "",
+ 8 + name_length, "");
exit (1);
}
while (1)
{
- optchar = getopt (argc, argv, "46c:hi:I:");
+ optchar = getopt (argc, argv, "46c:hi:I:t:");
if (optchar == -1)
break;
}
break;
+ case 't':
+ {
+ int new_send_ttl;
+ new_send_ttl = atoi (optarg);
+ if ((new_send_ttl > 0) && (new_send_ttl < 256))
+ opt_send_ttl = new_send_ttl;
+ else
+ fprintf (stderr, "Invalid TTL argument: %s\n",
+ optarg);
+ break;
+ }
+
case 'h':
default:
usage_exit (argv[0]);
return (1);
}
+ if (ping_setopt (ping, PING_OPT_TTL, &opt_send_ttl) != 0)
+ {
+ fprintf (stderr, "Setting TTL to %i failed: %s\n",
+ opt_send_ttl, ping_get_error (ping));
+ }
+
{
double temp_sec;
double temp_nsec;