73d878c711aa714b9e3c111519e07b8a69fad440
[collectd.git] / src / liboping / liboping.h
1 /**
2  * Object oriented C module to send ICMP and ICMPv6 `echo's.
3  * Copyright (C) 2006  Florian octo Forster <octo at verplant.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #ifndef OCTO_PING_H
21 #define OCTO_PING_H 1
22
23 #include <stdlib.h>
24 #include <unistd.h>
25
26 /*
27  * Type definitions
28  */
29 typedef struct pinghost
30 {
31         char                    *hostname;
32         struct sockaddr_storage *addr;
33         socklen_t                addrlen;
34         int                      addrfamily;
35         int                      fd;
36         int                      ident;
37         int                      sequence;
38         struct timeval          *timer;
39         double                   latency;
40
41         struct pinghost         *next;
42 } pinghost_t;
43
44 typedef pinghost_t pingobj_iter_t;
45
46 typedef struct pingobj
47 {
48         double      timeout;
49         int         ttl;
50         int         addrfamily;
51
52         pinghost_t *head;
53 } pingobj_t;
54
55 #define PING_OPT_TIMEOUT 0x01
56 #define PING_OPT_TTL     0x02
57 #define PING_OPT_AF      0x04
58
59 #define PING_DEF_TIMEOUT 1.0
60 #define PING_DEF_TTL     255
61 #define PING_DEF_AF      AF_UNSPEC
62
63 /*
64  * Method definitions
65  */
66 pingobj_t *ping_construct (void);
67 void ping_destroy (pingobj_t *obj);
68
69 int ping_setopt (pingobj_t *obj, int option, void *value);
70
71 int ping_send (pingobj_t *obj);
72
73 int ping_host_add (pingobj_t *obj, const char *host);
74 int ping_host_remove (pingobj_t *obj, const char *host);
75
76 pingobj_iter_t *ping_iterator_get (pingobj_t *obj);
77 pingobj_iter_t *ping_iterator_next (pingobj_iter_t *iter);
78
79 const char *ping_iterator_get_host (pingobj_iter_t *iter);
80 double ping_iterator_get_latency (pingobj_iter_t *iter);
81
82 #endif /* OCTO_PING_H */