-
Notifications
You must be signed in to change notification settings - Fork 31
/
test_module.c
325 lines (278 loc) · 6.79 KB
/
test_module.c
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "common.h"
#include "module.h"
module_driver_t *a_load();
int a_init();
int a_deinit();
int a_volume_create(phase_context_t *ctx);
int a_volume_destroy(phase_context_t *ctx);
int a_accept_policy(phase_context_t *ctx);
int a_uri_parse(phase_context_t *ctx);
int a_header_parse(phase_context_t *ctx);
int a_host_rewrite(phase_context_t *ctx);
int a_volume_lookup(phase_context_t *ctx);
int a_client_request(phase_context_t *ctx);
int a_content_verify(phase_context_t *ctx);
int a_build_response(phase_context_t *ctx);
int a_client_response(phase_context_t *ctx);
int a_complete(phase_context_t *ctx);
int b_init();
int b_deinit();
int b_volume_create(phase_context_t *ctx);
int b_volume_destroy(phase_context_t *ctx);
int b_accept_policy(phase_context_t *ctx);
int b_uri_parse(phase_context_t *ctx);
int b_header_parse(phase_context_t *ctx);
int b_host_rewrite(phase_context_t *ctx);
int b_volume_lookup(phase_context_t *ctx);
int b_client_request(phase_context_t *ctx);
int b_content_verify(phase_context_t *ctx);
int b_build_response(phase_context_t *ctx);
int b_client_response(phase_context_t *ctx);
int b_complete(phase_context_t *ctx);
module_driver_t gscx__a_module = {
.name = "a_module", /* name */
.desc = "test a module description",
.version = 1, /* version */
.init = a_init, /* init func */
.deinit = a_deinit, /* deinit func */
.index = -1,
.callback = NULL,
};
module_driver_t gscx__b_module = {
.name = "b_module", /* name */
.desc = "test b module description",
.version = 1, /* version */
.init = b_init, /* init func */
.deinit = b_deinit, /* deinit func */
.index = -1,
.callback = NULL,
};
int
a_init()
{
printf("call %s\n", __func__);
scx_reg_phase_func(PHASE_VOLUME_CREATE, a_volume_create);
scx_reg_phase_func(PHASE_VOLUME_DESTROY, a_volume_destroy);
scx_reg_phase_func(PHASE_ACCEPT_POLICY, a_accept_policy);
scx_reg_phase_func(PHASE_URI_PARSE, a_uri_parse);
scx_reg_phase_func(PHASE_HEADER_PARSE, a_header_parse);
scx_reg_phase_func(PHASE_HOST_REWRITE, a_host_rewrite);
scx_reg_phase_func(PHASE_VOLUME_LOOKUP, a_volume_lookup);
scx_reg_phase_func(PHASE_CLIENT_REQUEST, a_client_request);
scx_reg_phase_func(PHASE_CONTENT_VERIFY, a_content_verify);
scx_reg_phase_func(PHASE_BUILD_RESPONSE, a_client_response);
scx_reg_phase_func(PHASE_CLIENT_RESPONSE, a_client_response);
scx_reg_phase_func(PHASE_COMPLETE, a_complete);
return SCX_YES;
}
int
a_deinit()
{
printf("call %s\n", __func__);
return SCX_YES;
}
int
a_volume_create(phase_context_t *ctx)
{
service_info_t *service = ctx->service;
printf("call %s\n", __func__);
printf("volume name = %s\n", vs_data(service->name));
return SCX_YES;
}
int
a_volume_destroy(phase_context_t *ctx)
{
service_info_t *service = ctx->service;
printf("call %s\n", __func__);
printf("volume name = %s\n", vs_data(service->name));
return SCX_YES;
}
int
a_accept_policy(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
a_uri_parse(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_header_parse(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_host_rewrite(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_volume_lookup(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_client_request(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_content_verify(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_build_response(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_client_response(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
a_complete(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("url path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
b_init()
{
printf("call %s\n", __func__);
scx_reg_phase_func(PHASE_ACCEPT_POLICY, b_accept_policy);
scx_reg_phase_func(PHASE_URI_PARSE, b_uri_parse);
scx_reg_phase_func(PHASE_HEADER_PARSE, b_header_parse);
scx_reg_phase_func(PHASE_HOST_REWRITE, b_host_rewrite);
scx_reg_phase_func(PHASE_VOLUME_LOOKUP, b_volume_lookup);
scx_reg_phase_func(PHASE_CLIENT_REQUEST, b_client_request);
scx_reg_phase_func(PHASE_CONTENT_VERIFY, b_content_verify);
scx_reg_phase_func(PHASE_BUILD_RESPONSE, b_client_response);
scx_reg_phase_func(PHASE_CLIENT_RESPONSE, b_client_response);
scx_reg_phase_func(PHASE_COMPLETE, b_complete);
return SCX_YES;
}
int
b_deinit()
{
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_volume_create(phase_context_t *ctx)
{
service_info_t *service = ctx->service;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_volume_destroy(phase_context_t *ctx)
{
service_info_t *service = ctx->service;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_accept_policy(phase_context_t *ctx)
{
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_uri_parse(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
printf("path = %s\n", vs_data(req->url));
return SCX_YES;
}
int
b_header_parse(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_host_rewrite(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_volume_lookup(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_client_request(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_content_verify(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_build_response(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_client_response(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}
int
b_complete(phase_context_t *ctx)
{
nc_request_t *req = ctx->req;
printf("call %s\n", __func__);
return SCX_YES;
}