#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