summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 12e4f9f)
raw | patch | inline | side by side (parent: 12e4f9f)
author | Daniel Collins <daniel.collins@smoothwall.net> | |
Thu, 9 Jan 2014 11:38:54 +0000 (11:38 +0000) | ||
committer | Florian Forster <ff@octo.it> | |
Fri, 13 Feb 2015 11:57:25 +0000 (12:57 +0100) |
src/oping.c | patch | blob | history |
diff --git a/src/oping.c b/src/oping.c
index 28f761cfffaad55418d7103eb7f9e69de835971d..08423eac3887118443b83e87e347284d54ac405b 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
} ping_context_t;
static double opt_interval = 1.0;
+static double opt_timeout = PING_DEF_TIMEOUT;
static int opt_addrfamily = PING_DEF_AF;
static char *opt_srcaddr = NULL;
static char *opt_device = NULL;
" -4|-6 force the use of IPv4 or IPv6\n"
" -c count number of ICMP packets to send\n"
" -i interval interval with which to send ICMP packets\n"
+ " -w timeout time to wait for replies, in seconds\n"
" -t ttl time to live for each ICMP packet\n"
" -Q qos Quality of Service (QoS) of outgoing packets\n"
" Use \"-Q help\" for a list of valid options.\n"
while (1)
{
- optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:P:"
+ optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:P:w:"
#if USE_NCURSES
"uUg:"
#endif
}
break;
+ case 'w':
+ {
+ char *endp;
+ double t = strtod(optarg, &endp);
+ if(optarg[0] != '\0' && *endp == '\0')
+ {
+ opt_timeout = t;
+ }
+ else{
+ fprintf (stderr, "Ignoring invalid timeout: %s\n",
+ optarg);
+ }
+
+ break;
+ }
+
case 'I':
{
if (opt_srcaddr != NULL)
/* printf ("ts_int = %i.%09li\n", (int) ts_int.tv_sec, ts_int.tv_nsec); */
}
+ if (ping_setopt (ping, PING_OPT_TIMEOUT, (void*)(&opt_timeout)) != 0)
+ {
+ fprintf (stderr, "Setting timeout failed: %s\n",
+ ping_get_error (ping));
+ }
+
if (opt_addrfamily != PING_DEF_AF)
ping_setopt (ping, PING_OPT_AF, (void *) &opt_addrfamily);