Code

b17e65920773985a0c232fdb0fe38a32b98b1658
[liboping.git] / src / oping.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; only version 2 of the License is
8  * applicable.
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  */
20 #ifndef OCTO_PING_H
21 #define OCTO_PING_H 1
23 #if HAVE_CONFIG_H
24 # include <config.h>
25 #endif
27 #if HAVE_STDLIB_H
28 # include <stdlib.h>
29 #endif
30 #if HAVE_UNISTD_H
31 # include <unistd.h>
32 #endif
33 #if HAVE_SYS_TYPES_H
34 # include <sys/types.h>
35 #endif
36 #if HAVE_SYS_SOCKET_H
37 # include <sys/socket.h>
38 #endif
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /*
45  * Type definitions
46  */
47 struct pinghost;
48 typedef struct pinghost pinghost_t;
50 typedef pinghost_t pingobj_iter_t;
52 struct pingobj;
53 typedef struct pingobj pingobj_t;
55 #define PING_OPT_TIMEOUT 0x01
56 #define PING_OPT_TTL     0x02
57 #define PING_OPT_AF      0x04
58 #define PING_OPT_DATA    0x08
59 #define PING_OPT_SOURCE  0x10
61 #define PING_DEF_TIMEOUT 1.0
62 #define PING_DEF_TTL     255
63 #define PING_DEF_AF      AF_UNSPEC
64 #define PING_DEF_DATA    "Florian Forster <octo@verplant.org> http://verplant.org/"
66 /*
67  * Method definitions
68  */
69 pingobj_t *ping_construct (void);
70 void ping_destroy (pingobj_t *obj);
72 int ping_setopt (pingobj_t *obj, int option, void *value);
74 int ping_send (pingobj_t *obj);
76 int ping_host_add (pingobj_t *obj, const char *host);
77 int ping_host_remove (pingobj_t *obj, const char *host);
79 pingobj_iter_t *ping_iterator_get (pingobj_t *obj);
80 pingobj_iter_t *ping_iterator_next (pingobj_iter_t *iter);
82 #define PING_INFO_HOSTNAME 1
83 #define PING_INFO_ADDRESS  2
84 #define PING_INFO_FAMILY   3
85 #define PING_INFO_LATENCY  4
86 #define PING_INFO_SEQUENCE 5
87 #define PING_INFO_IDENT    6
88 #define PING_INFO_DATA     7
89 int ping_iterator_get_info (pingobj_iter_t *iter, int info,
90                 void *buffer, size_t *buffer_len);
92 const char *ping_get_error (pingobj_t *obj);
94 void *ping_iterator_get_context (pingobj_iter_t *iter);
95 void  ping_iterator_set_context (pingobj_iter_t *iter, void *context);
97 #ifdef __cplusplus
98 }
99 #endif
101 #endif /* OCTO_PING_H */