summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac4b351)
raw | patch | inline | side by side (parent: ac4b351)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 17 Feb 2009 12:14:58 +0000 (13:14 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 17 Feb 2009 12:14:58 +0000 (13:14 +0100) |
Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
bindings/perl/Oping.xs | patch | blob | history | |
bindings/perl/lib/Net/Oping.pm | patch | blob | history |
diff --git a/bindings/perl/Oping.xs b/bindings/perl/Oping.xs
index 19da01c5c14405e5ba5ec2de8d15b81ab6498fee..c42374fc57fd2ece3c2da9877a7e511c61d3f311 100644 (file)
--- a/bindings/perl/Oping.xs
+++ b/bindings/perl/Oping.xs
#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
index 838fb589fc41e582c9e633390fc0a6532798b89c..b14cc52a21e29a8a2d7ffea85a2026e0dfdde30f 100644 (file)
}
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> ();