From: Florian Forster Date: Fri, 22 Aug 2008 07:00:24 +0000 (+0200) Subject: ping_iterator_get_info: Provide the number of timed out packets. X-Git-Tag: Net-Oping-1.02~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ec9ecd4bfd91e64c9851de556c4d3d1a884011f3;p=liboping.git ping_iterator_get_info: Provide the number of timed out packets. --- diff --git a/src/liboping.c b/src/liboping.c index 22ab3a8..c93633c 100644 --- a/src/liboping.c +++ b/src/liboping.c @@ -25,6 +25,8 @@ # include # include # include +# include +# include # include # include #else @@ -109,6 +111,7 @@ struct pinghost int sequence; struct timeval *timer; double latency; + uint32_t dropped; char *data; void *context; @@ -523,6 +526,9 @@ static int ping_receive_all (pingobj_t *obj) else if (status == 0) { dprintf ("select timed out\n"); + for (ptr = ph; ptr != NULL; ptr = ptr->next) + if (ptr->latency < 0.0) + ptr->dropped++; break; } @@ -799,6 +805,7 @@ static pinghost_t *ping_alloc (void) ph->addrlen = sizeof (struct sockaddr_storage); ph->fd = -1; ph->latency = -1.0; + ph->dropped = 0; ph->ident = ping_get_ident () & 0xFFFF; return (ph); @@ -1337,6 +1344,15 @@ int ping_iterator_get_info (pingobj_iter_t *iter, int info, ret = 0; break; + case PING_INFO_DROPPED: + ret = ENOMEM; + *buffer_len = sizeof (uint32_t); + if (orig_buffer_len < sizeof (uint32_t)) + break; + *((uint32_t *) buffer) = iter->dropped; + ret = 0; + break; + case PING_INFO_SEQUENCE: ret = ENOMEM; *buffer_len = sizeof (unsigned int); @@ -1366,7 +1382,7 @@ int ping_iterator_get_info (pingobj_iter_t *iter, int info, } return (ret); -} +} /* ping_iterator_get_info */ void *ping_iterator_get_context (pingobj_iter_t *iter) { diff --git a/src/mans/ping_iterator_get_info.pod b/src/mans/ping_iterator_get_info.pod index 57322bb..55c9ec9 100644 --- a/src/mans/ping_iterator_get_info.pod +++ b/src/mans/ping_iterator_get_info.pod @@ -58,6 +58,13 @@ Return the last measured latency or less than zero if the timeout occured before a echo response was received. The buffer should be big enough to hold a double value. +=item B + +Return the number of times that no response was received within the timeout. +This value is only increased but may wrap around at the 32Ebit boundary. +The buffer should be big enough to hold a 32Ebit integer, e.Eg. an +C. + =item B Return the last sequence number sent. This number is increased regardless of diff --git a/src/oping.h b/src/oping.h index d450d6c..4655d39 100644 --- a/src/oping.h +++ b/src/oping.h @@ -41,6 +41,8 @@ extern "C" { #endif +#define OPING_VERSION 3005 + /* * Type definitions */ @@ -79,7 +81,6 @@ int ping_host_remove (pingobj_t *obj, const char *host); pingobj_iter_t *ping_iterator_get (pingobj_t *obj); pingobj_iter_t *ping_iterator_next (pingobj_iter_t *iter); -#define PING_INFO_USERNAME 8 #define PING_INFO_HOSTNAME 1 #define PING_INFO_ADDRESS 2 #define PING_INFO_FAMILY 3 @@ -87,6 +88,8 @@ pingobj_iter_t *ping_iterator_next (pingobj_iter_t *iter); #define PING_INFO_SEQUENCE 5 #define PING_INFO_IDENT 6 #define PING_INFO_DATA 7 +#define PING_INFO_USERNAME 8 +#define PING_INFO_DROPPED 9 int ping_iterator_get_info (pingobj_iter_t *iter, int info, void *buffer, size_t *buffer_len);