diff options
-rw-r--r-- | pingu_burst.h | 23 | ||||
-rw-r--r-- | pingu_host.h | 10 | ||||
-rw-r--r-- | pingu_iface.h | 20 | ||||
-rw-r--r-- | pingu_ping.h | 19 |
4 files changed, 71 insertions, 1 deletions
diff --git a/pingu_burst.h b/pingu_burst.h new file mode 100644 index 0000000..c42ddfa --- /dev/null +++ b/pingu_burst.h @@ -0,0 +1,23 @@ +#ifndef PINGU_BURST_H +#define PINGU_BURST_H + +#include <sys/types.h> +#include <sys/socket.h> + +#include <ev.h> + +#include "list.h" + +struct pingu_burst { + struct sockaddr saddr; + size_t saddrlen; + int pings_sent; + int pings_replied; + int active; + struct list_head ping_burst_entry; +}; + +void pingu_burst_timeout_cb(struct ev_loop *loop, struct ev_timer *w, + int revents); + +#endif diff --git a/pingu_host.h b/pingu_host.h index 1599aa4..060137b 100644 --- a/pingu_host.h +++ b/pingu_host.h @@ -3,6 +3,8 @@ #include <ev.h> +#include "pingu_burst.h" + struct pingu_host { struct list_head host_list_entry; char *host; @@ -15,10 +17,16 @@ struct pingu_host { int status; int max_retries; int required_replies; - float timeout; + ev_tstamp timeout; ev_tstamp burst_interval; struct ev_timer burst_timeout_watcher; + struct pingu_burst burst; + struct pingu_iface *iface; }; +void pingu_host_set_status(struct pingu_host *host, int status); +int pingu_host_init(struct ev_loop *loop, struct list_head *host_list); +int pingu_host_verify_status(struct ev_loop *loop, struct pingu_host *host); + #endif diff --git a/pingu_iface.h b/pingu_iface.h new file mode 100644 index 0000000..99d7362 --- /dev/null +++ b/pingu_iface.h @@ -0,0 +1,20 @@ +#ifndef PINGU_IFACE_H +#define PINGU_IFACE_H + +#include <ev.h> +#include "list.h" + +struct pingu_iface { + char name[32]; + int fd; + struct list_head iface_list_entry; +// struct list_head burst_list; + struct list_head ping_list; + struct ev_io socket_watcher; +}; + +struct pingu_iface *pingu_iface_find(const char *name); +struct pingu_iface *pingu_iface_find_or_create(struct ev_loop *loop, const char *name); +int pingu_iface_init(struct ev_loop *loop, struct list_head *host_list); + +#endif diff --git a/pingu_ping.h b/pingu_ping.h new file mode 100644 index 0000000..d8f129a --- /dev/null +++ b/pingu_ping.h @@ -0,0 +1,19 @@ +#ifndef PINGU_PING_H +#define PINGU_PING_H + +#include <ev.h> + +#include "list.h" +#include "pingu_host.h" + +struct pingu_ping { + int seq; + struct pingu_host *host; + struct list_head ping_list_entry; + struct ev_timer timeout_watcher; +}; + +int pingu_ping_send(struct ev_loop *loop, struct pingu_host *host); +void pingu_ping_read_reply(struct ev_loop *loop, struct pingu_iface *iface); + +#endif |