diff options
Diffstat (limited to 'src/forward.h')
-rw-r--r-- | src/forward.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/forward.h b/src/forward.h new file mode 100644 index 0000000..f98d331 --- /dev/null +++ b/src/forward.h @@ -0,0 +1,32 @@ +#ifndef POTD_FORWARD_H +#define POTD_FORWARD_H 1 + +#include "socket.h" + +struct forward_ctx; + +typedef int (*init_cb) (struct forward_ctx *ctx); +typedef int (*on_listen_cb) (struct forward_ctx *ctx); +typedef int (*on_shutdown_cb) (struct forward_ctx *ctx); + +typedef struct fwd_callbacks { + on_listen_cb on_listen; + on_shutdown_cb on_shutdown; +} fwd_callbacks; + +typedef struct forward_ctx { + pthread_t self; + fwd_callbacks fwd_cbs; + psocket sock; + char host_buf[NI_MAXHOST], service_buf[NI_MAXSERV]; + void *data; +} forward_ctx; + + +int fwd_init_ctx(forward_ctx **ctx, init_cb init_fn); + +int fwd_setup(forward_ctx *ctx, const char *host, const char *port); + +int fwd_validate_ctx(const forward_ctx *ctx); + +#endif |