diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-04-16 17:25:09 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-04-16 17:25:09 +0200 |
commit | c9b3ea785346546948afcf685c80c460f3b1317a (patch) | |
tree | e5e43c24167f8e0a4d66e776ea71219e6e3d4adc /src/forward.h | |
parent | 914f8f335d73c4dd69b72f6f2d8c53257bce497d (diff) |
POTD skeleton #10.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
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 |