summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b8f964)
raw | patch | inline | side by side (parent: 0b8f964)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 15 Mar 2009 10:47:43 +0000 (11:47 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 15 Mar 2009 10:47:43 +0000 (11:47 +0100) |
src/mans/oping.pod | patch | blob | history | |
src/oping.c | patch | blob | history |
diff --git a/src/mans/oping.pod b/src/mans/oping.pod
index c4e3e6386164c5e3c24c8e96761ccf7b8e961315..fba2f568bd8396f36bc2780b7d107413296d224e 100644 (file)
--- a/src/mans/oping.pod
+++ b/src/mans/oping.pod
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)>
diff --git a/src/oping.c b/src/oping.c
index bc33c27157d221e8d339d34245459658347e06cd..0f39dc5b4d884005dd12bb4658f2bbc0d9ef2c81 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
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;