/
local.h
76 lines (62 loc) · 1.36 KB
/
local.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
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef LOCAL_H_
#define LOCAL_H_
#define INT_MAX 2147483647
#define BUF_SIZE 2048
#define CTL_CLOSE 0x04
#define CTL_INIT 0x01
#define CTL_NORMAL 0
#define LOCALHOST "127.0.0.1"
// packet related MACROs
#define MAX_PKT_SIZE 8192
#define ID_LEN 4
#define PKT_LEN 2
#define RSV_LEN 1
#define DATALEN_LEN 2
#define ATYP_LEN 1
#define ADDRLEN_LEN 1
#define PORT_LEN 2
#define HDR_LEN (ID_LEN + RSV_LEN + DATALEN_LEN)
#define EXP_TO_RECV_LEN (ID_LEN + RSV_LEN + DATALEN_LEN)
// remote connection status MACROs
#define RC_OFF 0
#define RC_ESTABLISHING 1
#define RC_OK 2
#define MAX_RC_NUM 32
// PF sockopt
#define PROXIMAC_ON 1
#define HOOK_PID 2
#define PIDLIST_STATUS 3
#define PROXIMAC_OFF 4
#define NOT_TO_HOOK 5
#include "tree.h"
struct pid {
RB_ENTRY(pid) rb_link;
int pid;
char* name;
};
RB_HEAD(pid_tree, pid);
RB_PROTOTYPE(pid_tree, pid, rb_link, pid_cmp);
extern struct pid_tree pid_list;
int tell_kernel_to_hook();
typedef struct {
uv_write_t req;
uv_buf_t buf;
} write_req_t;
typedef struct {
uv_tcp_t handle;
} listener_t;
struct remote_ctx;
typedef struct server_ctx {
uv_tcp_t server_handle;
uv_tcp_t remote_handle;
int server_stage;
int remote_stage;
int remote_auth_stage;
char remote_addr[256];
char addrlen;
uint16_t port;
char* buf;
int buf_len;
struct remote_ctx* remote_ctx;
} server_ctx_t;
#endif