-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsocks5_bind_processor.h
63 lines (49 loc) · 2.85 KB
/
socks5_bind_processor.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef SOCKS5_BIND_PROCESSOR_H
#define SOCKS5_BIND_PROCESSOR_H
#include <event2/bufferevent.h>
#include <event2/listener.h>
/* forward declarations */
struct socks5tunnel;
/* The processor that handles socks5 BIND command */
struct s5bind_processor;
struct s5bind_processor *s5bind_processor_new(struct event_base *evbase,
struct socks5tunnel *tunnel, long tunnel_id);
void s5bind_processor_free(struct s5bind_processor *processor);
void s5bind_processor_start(struct s5bind_processor *processor);
int s5bind_processor_write(struct s5bind_processor *processor, struct evbuffer *buffer);
void s5bind_processor_shutdown_write(struct s5bind_processor *processor);
/* callbacks:
* listen success/fail
* accept success/fail
* data_received/write_completed
* eof/read_error/write_error
*/
typedef void (*s5bind_processor_on_bind_success_cb)(struct socks5tunnel *tunnel, const struct sockaddr *addr, socklen_t addrlen);
typedef void (*s5bind_processor_on_bind_error_cb)(struct socks5tunnel *tunnel);
typedef void (*s5bind_processor_on_connection_success_cb)(struct socks5tunnel *tunnel, const struct sockaddr *addr, socklen_t addrlen);
typedef void (*s5bind_processor_on_connection_error_cb)(struct socks5tunnel *tunnel);
typedef void (*s5bind_processor_on_data_received_cb)(struct socks5tunnel *tunnel, struct evbuffer *buffer);
typedef void (*s5bind_processor_on_data_write_completed_cb)(struct socks5tunnel *tunnel);
typedef void (*s5bind_processor_on_eof_cb)(struct socks5tunnel *tunnel);
typedef void (*s5bind_processor_on_read_error_cb)(struct socks5tunnel *tunnel);
typedef void (*s5bind_processor_on_write_error_cb)(struct socks5tunnel *tunnel);
/* callback setters */
void s5bind_processor_set_on_bind_success_cb(struct s5bind_processor *processor,
s5bind_processor_on_bind_success_cb cb);
void s5bind_processor_set_on_bind_error_cb(struct s5bind_processor *processor,
s5bind_processor_on_bind_error_cb cb);
void s5bind_processor_set_on_connection_success_cb(struct s5bind_processor *processor,
s5bind_processor_on_connection_success_cb cb);
void s5bind_processor_set_on_connection_error_cb(struct s5bind_processor *processor,
s5bind_processor_on_connection_error_cb cb);
void s5bind_processor_set_on_data_received_cb(struct s5bind_processor *processor,
s5bind_processor_on_data_received_cb cb);
void s5bind_processor_set_on_data_write_completed_cb(struct s5bind_processor *processor,
s5bind_processor_on_data_write_completed_cb cb);
void s5bind_processor_set_on_eof_cb(struct s5bind_processor *processor,
s5bind_processor_on_eof_cb cb);
void s5bind_processor_set_on_read_error_cb(struct s5bind_processor *processor,
s5bind_processor_on_read_error_cb cb);
void s5bind_processor_set_on_write_error_cb(struct s5bind_processor *processor,
s5bind_processor_on_write_error_cb cb);
#endif /* ifndef SOCKS5_BIND_PROCESSOR_H */