blob: f98d331189fd2ff4cc781421d6a51f0a5385d491 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|