aboutsummaryrefslogtreecommitdiffstats
path: root/icmp.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-01-31 12:50:08 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-01-31 12:50:08 +0000
commitc9fe03878b1808e9c33e3f9b16964a142331253b (patch)
treed8ab10ddfac0de0f9f67e8eca4da84a22a1d2a77 /icmp.c
parent0392773d57e3fca5efade2298d641c22202d624a (diff)
downloadpingu-c9fe03878b1808e9c33e3f9b16964a142331253b.tar.bz2
pingu-c9fe03878b1808e9c33e3f9b16964a142331253b.tar.xz
pingu: cofigurable timeout/retry. default values. invert -d
- make timeout and retry configurable - possible to set default action, timeout and retry values - the -d option means "daemonize" rather than "debug mode".
Diffstat (limited to 'icmp.c')
-rw-r--r--icmp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/icmp.c b/icmp.c
index 7135254..eb1ec5c 100644
--- a/icmp.c
+++ b/icmp.c
@@ -316,7 +316,7 @@ int icmp_read_reply(int fd, struct sockaddr *from, int fromlen,
return len;
}
-int icmp_open(void)
+int icmp_open(float timeout)
{
const int pmtudisc = IP_PMTUDISC_DO, yes = 1;
struct timeval tv;
@@ -334,12 +334,12 @@ int icmp_open(void)
goto err_close;
}
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv.tv_sec = (time_t) timeout;
+ tv.tv_usec = (timeout - tv.tv_sec) * 1000000;
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&tv, sizeof(tv));
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv.tv_sec = (time_t) timeout;
+ tv.tv_usec = (timeout - tv.tv_sec) * 1000000;
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,
(char*)&tv, sizeof(tv)) == -1)
goto err_close;