#define MODULE_NAME "ping"
#include <netinet/in.h>
-#include "liboping/liboping.h"
+#include "liboping/oping.h"
static pingobj_t *pingobj = NULL;
{
pingobj_iter_t *iter;
- char *host;
- double latency;
+ char host[512];
+ double latency;
+ size_t buf_len;
if (pingobj == NULL)
return;
return;
}
- for (iter = ping_iterator_get (pingobj); iter != NULL; iter = ping_iterator_next (iter))
+ for (iter = ping_iterator_get (pingobj);
+ iter != NULL;
+ iter = ping_iterator_next (iter))
{
- const char *tmp;
-
- if ((tmp = ping_iterator_get_host (iter)) == NULL)
- continue;
- if ((host = strdup (tmp)) == NULL)
+ buf_len = sizeof (host);
+ if (ping_iterator_get_info (iter, PING_INFO_HOSTNAME,
+ host, &buf_len))
continue;
- latency = ping_iterator_get_latency (iter);
+ buf_len = sizeof (latency);
+ if (ping_iterator_get_info (iter, PING_INFO_LATENCY,
+ &latency, &buf_len))
+ continue;
DBG ("host = %s, latency = %f", host, latency);
ping_submit (host, latency);
-
- free (host); host = NULL;
}
}