3 * Copyright (C) 2007 Olivier Fredj
4 * Copyright (C) 2008,2009 Florian octo Forster
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; only version 2 of the License is
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Olivier Fredj <ofredj at proxad.net>
22 * Florian octo Forster <octo at verplant.org>
33 #include <netdb.h> /* NI_MAXHOST */
36 MODULE = Net::Oping PACKAGE = Net::Oping
43 RETVAL = ping_construct ();
54 _ping_setopt_timeout (obj, timeout)
58 RETVAL = ping_setopt (obj, PING_OPT_TIMEOUT, &timeout);
63 _ping_setopt_source (obj, addr)
67 RETVAL = ping_setopt (obj, PING_OPT_SOURCE, addr);
72 _ping_host_add (obj, host);
76 RETVAL = ping_host_add (obj, host);
81 _ping_host_remove (obj, host)
85 RETVAL = ping_host_remove (obj, host);
93 RETVAL=ping_send (obj);
98 _ping_iterator_get (obj)
101 RETVAL = ping_iterator_get (obj);
106 _ping_iterator_next (iter)
109 RETVAL = ping_iterator_next (iter);
114 _ping_iterator_get_latency (iter)
123 tmp_size = sizeof (tmp);
124 status = ping_iterator_get_info (iter, PING_INFO_LATENCY,
125 (void *) &tmp, &tmp_size);
132 _ping_iterator_get_hostname (iter)
142 status = ping_iterator_get_info (iter, PING_INFO_HOSTNAME,
143 (void *) buffer, &buffer_size);
144 if (status != ENOMEM)
146 #if !defined(OPING_VERSION) || (OPING_VERSION <= 3005)
147 /* This is a workaround for a bug in 0.3.5. */
151 buffer = (char *) malloc (buffer_size);
155 status = ping_iterator_get_info (iter, PING_INFO_HOSTNAME,
156 (void *) buffer, &buffer_size);
163 XPUSHs (sv_2mortal (newSVpvn(buffer,buffer_size)));
168 _ping_get_error (obj)
171 RETVAL = ping_get_error(obj);