diff options
Diffstat (limited to 'eperd/tcputil.h')
-rw-r--r-- | eperd/tcputil.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/eperd/tcputil.h b/eperd/tcputil.h new file mode 100644 index 0000000..d2b11ec --- /dev/null +++ b/eperd/tcputil.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013 RIPE NCC <atlas@ripe.net> + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * tcputil.h + */ + +#include <event2/event_struct.h> + +enum tu_err { TU_DNS_ERR, TU_READ_ERR, TU_CONNECT_ERR, TU_OUT_OF_ADDRS }; +struct tu_env +{ + char dnsip; + char connecting; + struct evutil_addrinfo *dns_res; + struct evutil_addrinfo *dns_curr; + struct bufferevent *bev; + struct timeval interval; + struct event timer; + void (*reporterr)(struct tu_env *env, enum tu_err cause, + const char *str); + void (*reportcount)(struct tu_env *env, int count); + void (*beforeconnect)(struct tu_env *env, + struct sockaddr *addr, socklen_t addrlen); + void (*connected)(struct tu_env *env, struct bufferevent *bev); + void (*readcb)(struct bufferevent *bev, void *env); + void (*writecb)(struct bufferevent *bev, void *env); +}; + +void tu_connect_to_name(struct tu_env *env, char *host, char *port, + struct timeval *timeout, + struct evutil_addrinfo *hints, + void (*timeout_callback)(int unused, const short event, void *env), + void (*reporterr)(struct tu_env *env, enum tu_err cause, + const char *err), + void (*reportcount)(struct tu_env *env, int count), + void (*beforeconnect)(struct tu_env *env, + struct sockaddr *addr, socklen_t addrlen), + void (*connected)(struct tu_env *env, struct bufferevent *bev), + void (*readcb)(struct bufferevent *bev, void *env), + void (*writecb)(struct bufferevent *bev, void *env)); +void tu_restart_connect(struct tu_env *env); +void tu_cleanup(struct tu_env *env); |