From c9fe03878b1808e9c33e3f9b16964a142331253b Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Sat, 31 Jan 2009 12:50:08 +0000 Subject: 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". --- icmp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'icmp.c') 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; -- cgit v1.2.3