f650abb0dabd18c3d01b9217769ad5eb1f10b48b
[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 #ifndef AI_ADDRCONFIG
24 #define AI_ADDRCONFIG 0
25 #endif
26
27 #include <stdlib.h>
28 #include <sys/types.h>
29
30 /* FIXME BEGIN */
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <unistd.h>
34
35 #include <assert.h>
36
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <netdb.h>
40 #include <netinet/ip_icmp.h>
41 #include <netinet/icmp6.h>
42
43 #include <sys/time.h>
44 #include <time.h>
45 /* FIXME END */
46
47 /*
48  * Type definitions
49  */
50 typedef struct pinghost
51 {
52         char                    *hostname;
53         struct sockaddr_storage *addr;
54         socklen_t                addrlen;
55         int                      addrfamily;
56         int                      fd;
57         int                      ident;
58         int                      sequence;
59         struct timeval          *timer;
60         double                   latency;
61         struct pinghost         *next;
62 } pinghost_t;
63
64 typedef struct
65 {
66         int         flags;
67         pinghost_t *head;
68 } pingobj_t;
69
70 typedef pinghost_t pingobj_iter_t;
71
72 /*
73  * Method definitions
74  */
75 pingobj_t *ping_construct (int flags);
76 void ping_destroy (pingobj_t *obj);
77
78 int ping_send (pingobj_t *obj);
79
80 int ping_host_add (pingobj_t *obj, const char *host);
81 int ping_host_remove (pingobj_t *obj, const char *host);
82
83 pingobj_iter_t *ping_iterator_get (pingobj_t *obj);
84 pingobj_iter_t *ping_iterator_next (pingobj_iter_t *iter);
85
86 const char *ping_iterator_get_host (pingobj_iter_t *iter);
87 double ping_iterator_get_latency (pingobj_iter_t *iter);
88
89 #endif /* OCTO_PING_H */