#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <stdint.h>
+#include <inttypes.h>
#include <errno.h>
#include <assert.h>
#include <netdb.h> /* NI_MAXHOST */
free(buffer);
} while (0);
+int
+_ping_iterator_get_dropped (iter)
+ pingobj_iter_t *iter
+ CODE:
+#if defined(PING_INFO_DROPPED)
+ uint32_t tmp;
+ size_t tmp_size;
+ int status;
+
+ RETVAL = -1;
+
+ tmp_size = sizeof (tmp);
+ status = ping_iterator_get_info (iter, PING_INFO_DROPPED,
+ (void *) &tmp, &tmp_size);
+ if (status == 0)
+ RETVAL = (int) tmp;
+#else
+ RETVAL = -1;
+#endif
+ OUTPUT:
+ RETVAL
+
const char *
_ping_get_error (obj)
pingobj_t *obj
}
return ($data);
-}
+} # ping
+
+=item my I<$dropped> = I<$obj>-E<gt>B<get_dropped> ()
+
+Returns a hash reference holding the number of "drops" (echo requests which
+were not answered in time) for each host. An example return
+values would be:
+
+ $droprate = { host1 => 0, host2 => 3, host3 => undef, ... };
+
+Hosts to which no data has been sent yet will return C<undef> ("host3" in thie
+example).
+
+=cut
+
+sub get_dropped
+{
+ my $obj = shift;
+ my $iter;
+ my $data = {};
+
+ $iter = _ping_iterator_get ($obj->{'c_obj'});
+ if (!$iter)
+ {
+ $obj->{'err_msg'} = "" . _ping_get_error ($obj->{'c_obj'});
+ return;
+ }
+
+ while ($iter)
+ {
+ my $host = _ping_iterator_get_hostname ($iter);
+ if (!$host)
+ {
+ $iter = _ping_iterator_next ($iter);
+ next;
+ }
+
+ my $dropped = _ping_iterator_get_dropped ($iter);
+ if ($dropped < 0)
+ {
+ $dropped = undef;
+ }
+
+ $data->{$host} = $dropped;
+
+ $iter = _ping_iterator_next ($iter);
+ }
+
+ return ($data);
+} # get_dropped
=item my I<$errmsg> = I<$obj>-E<gt>B<get_error> ();