-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefs.h
180 lines (139 loc) · 2.96 KB
/
defs.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <unistd.h>
#include <math.h>
#include <fcntl.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/inotify.h>
#include <limits.h>
#include <errno.h>
#include <sys/time.h>
#include <pthread.h>
#include <zmq.h>
#include <sys/stat.h>
#include <dirent.h>
#include <poll.h>
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/stringbuffer.h"
#include "hmac.h"
#include "ecc/uECC.h"
#include "khash.h"
#include "log.h"
#define DEBUG 1
#define EMPTY ""
#define DENY "DENY"
#define CTR_IP "127.0.0.1"
// #define CTR_IP "18.217.190.226"
#define GUARD_IP "127.0.0.1"
#define CTR_PORT 5000
#define GUARD_PORT 6000
#define INOTIFY_EVENT_BUF_LEN (10 * (sizeof(struct inotify_event) + NAME_MAX + 1))
#define MAX_LEN_SIZE 8
#define MAX_BODY_LEN 4294967295
#define MAX_POLICY_LEN 10737418
#define MSG_HDR_LEN 10
#define MSG_SIG_LEN 64
#define MAX_KEY_LEN 16
#define MAX_ID_LEN 16
#define TYPE_TEST 0x01
#define TYPE_POLICY 0x02
#define TYPE_INIT 0x03
#define TYPE_KEY_DIST 0x04
#define TYPE_DISK 0x05
#define TYPE_EVENT 0x06
#define TYPE_USER_POLICY 0x07
#define TYPE_CHECK_STATUS 0x08
#define TYPE_CHECK_EVENT 0x09
#define TYPE_CHECK_RESP 0x10
#define TYPE_INFO 0x11
#define ACTION_NOOP 0x01
#define ACTION_TEST 0x02
#define ACTION_CTR_REQ 0x03
#define ACTION_GD_RESP 0x04
#define ACTION_USER 0x05
#define ACTION_POLICY_ADD 0x06
#define ACTION_POLICY_DEL 0x07
#define ACTION_POLICY_UPDATE 0x08
#define ACTION_POLICY_INIT 0x09
#define ACTION_KEY_DIST 0x10
#define STATE_REQ_RECIVED 0
#define STATE_REQ_VERIFIED 1
#define STATE_PASS 2
#define STATE_FAILED 3
#define EVENT_GET "GETE"
#define EVENT_SEND "SEND"
#define EVENT_RESP "RESP"
#define EVENT_END "ENDE"
#define EVENT_DONE "DONE"
#define EVENT_CHECK "CHCK"
#define EVENT_LEN 4
#define POLICY_TABLE_INIT 0
#define POLICY_TABLE_UPDATE 1
#define POLICY_TABLE_DONE 2
#define POLICY_TABLE_NOOP 3
typedef struct header
{
char type;
char action;
char len[MAX_LEN_SIZE + 1];
}header_t;
typedef struct msg
{
header_t header;
char signature[64];
char* body;
}msg_t;
typedef struct msg_str
{
char header[10];
char signature[64];
char* body;
}msg_str_t;
typedef struct msg_str_buff
{
int msg_len;
char* msg_str;
}msg_str_buff_t;
typedef struct keys
{
unsigned char key_priv[32];
unsigned char key_pub[64];
}keys_t;
typedef struct node_info
{
char id[MAX_ID_LEN];
}node_info_t;
typedef struct event
{
char ename[5];
char* res;
}event_t;
typedef struct guard_state
{
/*
* Can be extended to record No.of GETs
* No. of POSTs, etc.
*/
int request_no;
int io_no;
unsigned long start_time;
unsigned long running_time;
}state_t;
typedef struct para_state_check
{
void* table;
char key[MAX_KEY_LEN];
}para_state_check_t;
typedef struct path_info
{
int wd;
char* name;
} path_info_t;