summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/http_decoder_gtest.cpp156
-rw-r--r--test/http_decoder_perf_main.cpp56
-rw-r--r--test/http_decoder_perf_plug.cpp40
-rw-r--r--test/http_pcap/http_tunnel_for_http.pcapbin0 -> 4233 bytes
-rw-r--r--test/test_result_json/http_inner_tunnel_for_http.json15
-rw-r--r--test/test_result_json/http_inner_tunnel_for_pop3.json15
-rw-r--r--test/test_result_json/http_msg_type_state_tunnel.json26
-rw-r--r--test/test_result_json/http_tunnel_for_http.json62
-rw-r--r--test/test_result_json/http_tunnel_for_pop3.json5
9 files changed, 288 insertions, 87 deletions
diff --git a/test/http_decoder_gtest.cpp b/test/http_decoder_gtest.cpp
index b2677fc..27fb0e6 100644
--- a/test/http_decoder_gtest.cpp
+++ b/test/http_decoder_gtest.cpp
@@ -17,6 +17,7 @@ extern "C"
int commit_test_result_json(cJSON *node, const char *name);
extern void http_decoder_test_entry(struct session *sess, int topic_id, const void *raw_msg, void *no_use_ctx, void *plugin_env);
extern void http_decoder_test_state_entry(struct session *sess, int topic_id, const void *raw_msg, void *no_use_ctx, void *plugin_env);
+ extern void http_decoder_tunnel_entry(struct session *sess, int topic_id, const void *raw_msg, void *no_use_ctx, void *plugin_env);
static on_session_msg_cb_func *g_entry_fun = http_decoder_test_entry;
}
#endif
@@ -32,6 +33,7 @@ struct plug_entry_t{
static struct plug_entry_t g_entry_tbl[] = {
{"http_decoder_test_entry", http_decoder_test_entry},
{"http_decoder_test_state_entry", http_decoder_test_state_entry},
+ {"http_decoder_tunnel_entry", http_decoder_tunnel_entry},
{NULL, NULL}
};
@@ -61,26 +63,26 @@ static int g_topic_id = -1;
void output_http_req_line(struct http_request_line *req_line)
{
char tmp_str[MAX_KEY_STR_LEN] = {0};
- memcpy(tmp_str, req_line->method.str, req_line->method.str_len);
+ memcpy(tmp_str, req_line->method.iov_base, req_line->method.iov_len);
printf("req_method:%s\n", tmp_str);
memset(tmp_str, 0, sizeof(tmp_str));
- memcpy(tmp_str, req_line->uri.str, req_line->uri.str_len);
+ memcpy(tmp_str, req_line->uri.iov_base, req_line->uri.iov_len);
printf("req_uri:%s\n", tmp_str);
memset(tmp_str, 0, sizeof(tmp_str));
- memcpy(tmp_str, req_line->version.str, req_line->version.str_len);
+ memcpy(tmp_str, req_line->version.iov_base, req_line->version.iov_len);
printf("req_version:%s\n", tmp_str);
}
void output_http_res_line(struct http_response_line *res_line)
{
char tmp_str[MAX_KEY_STR_LEN] = {0};
- memcpy(tmp_str, res_line->version.str, res_line->version.str_len);
+ memcpy(tmp_str, res_line->version.iov_base, res_line->version.iov_len);
printf("res_version:%s\n", tmp_str);
memset(tmp_str, 0, sizeof(tmp_str));
- memcpy(tmp_str, res_line->status.str, res_line->status.str_len);
+ memcpy(tmp_str, res_line->status.iov_base, res_line->status.iov_len);
printf("res_status:%s\n", tmp_str);
}
@@ -89,42 +91,42 @@ void output_http_header(struct http_header *header)
char tmp_key[MAX_KEY_STR_LEN] = {0};
char tmp_val[MAX_KEY_STR_LEN] = {0};
- memcpy(tmp_key, header->key.str, header->key.str_len);
- memcpy(tmp_val, header->val.str, header->val.str_len);
+ memcpy(tmp_key, header->key.iov_base, header->key.iov_len);
+ memcpy(tmp_val, header->val.iov_base, header->val.iov_len);
printf("<%s:%s>\n", tmp_key, tmp_val);
}
-void output_http_body(struct hstring *body, int decompress_flag)
+void output_http_body(hstring *body, int decompress_flag)
{
int counter = 0;
if (1 == decompress_flag)
{
printf("\n\n----------------decompress body len:%zu---------------\n",
- body->str_len);
+ body->iov_len);
}
else
{
printf("\n\n----------------raw body len:%zu---------------\n",
- body->str_len);
+ body->iov_len);
}
- for (size_t i = 0; i < body->str_len; i++)
+ for (size_t i = 0; i < body->iov_len; i++)
{
if (counter % 16 == 0)
{
printf("\n");
}
- printf("%02x ", (unsigned char)body->str[i]);
+ printf("%02x ", (unsigned char)body->iov_base[i]);
counter++;
}
printf("\n");
}
#endif
-static void append_http_payload(struct session *sess, struct gtest_plug_exdata_t *gtest_plug_exdata, const struct hstring *body, enum http_transaction_type type)
+static void append_http_payload(struct session *sess, struct gtest_plug_exdata_t *gtest_plug_exdata, const hstring *body, enum http_transaction_type type)
{
- if (NULL == body->str || 0 == body->str_len)
+ if (NULL == body->iov_base || 0 == body->iov_len)
{
return;
}
@@ -133,7 +135,7 @@ static void append_http_payload(struct session *sess, struct gtest_plug_exdata_t
gtest_plug_exdata->md5ctx[type] = MMALLOC(MD5_CTX, sizeof(MD5_CTX));
MD5Init(gtest_plug_exdata->md5ctx[type]);
}
- MD5Update(gtest_plug_exdata->md5ctx[type], (unsigned char *)body->str, body->str_len);
+ MD5Update(gtest_plug_exdata->md5ctx[type], (unsigned char *)body->iov_base, body->iov_len);
}
int http_field_to_json(cJSON *object, const char *key, char *val, size_t val_len)
@@ -158,11 +160,11 @@ void transaction_index_to_json(cJSON *ctx, int transaction_index)
void req_line_to_json(cJSON *ctx, struct http_request_line *req_line)
{
- http_field_to_json(ctx, "method", req_line->method.str,
- req_line->method.str_len);
- http_field_to_json(ctx, "uri", req_line->uri.str, req_line->uri.str_len);
- http_field_to_json(ctx, "req_version", req_line->version.str,
- req_line->version.str_len);
+ http_field_to_json(ctx, "method", (char *)req_line->method.iov_base,
+ req_line->method.iov_len);
+ http_field_to_json(ctx, "uri", (char *)req_line->uri.iov_base, req_line->uri.iov_len);
+ http_field_to_json(ctx, "req_version", (char *)req_line->version.iov_base,
+ req_line->version.iov_len);
cJSON_AddNumberToObject(ctx, "major_version", req_line->major_version);
cJSON_AddNumberToObject(ctx, "minor_version", req_line->minor_version);
@@ -170,10 +172,10 @@ void req_line_to_json(cJSON *ctx, struct http_request_line *req_line)
void res_line_to_json(cJSON *ctx, struct http_response_line *res_line)
{
- http_field_to_json(ctx, "res_version", res_line->version.str,
- res_line->version.str_len);
- http_field_to_json(ctx, "res_status", res_line->status.str,
- res_line->status.str_len);
+ http_field_to_json(ctx, "res_version", (char *)res_line->version.iov_base,
+ res_line->version.iov_len);
+ http_field_to_json(ctx, "res_status", (char *)res_line->status.iov_base,
+ res_line->status.iov_len);
cJSON_AddNumberToObject(ctx, "major_version", res_line->major_version);
cJSON_AddNumberToObject(ctx, "minor_version", res_line->minor_version);
@@ -183,25 +185,27 @@ void res_line_to_json(cJSON *ctx, struct http_response_line *res_line)
void http_header_to_json(cJSON *ctx, struct http_header *header)
{
char key[MAX_KEY_STR_LEN] = {0};
+ assert(header->key.iov_base);
+ assert(header->val.iov_base);
- memcpy(key, header->key.str, header->key.str_len);
+ memcpy(key, header->key.iov_base, header->key.iov_len);
if (cJSON_HasObjectItem(ctx, key) == FALSE)
{
- http_field_to_json(ctx, key, header->val.str, header->val.str_len);
+ http_field_to_json(ctx, key, (char *)header->val.iov_base, header->val.iov_len);
}
else
{
// ctx already has the key, so rename key by key%d
char new_key[MAX_KEY_STR_LEN] = {0};
sprintf(new_key, "%s%d", key, g_header_count++);
- http_field_to_json(ctx, new_key, header->val.str, header->val.str_len);
+ http_field_to_json(ctx, new_key, (char *)header->val.iov_base, header->val.iov_len);
}
}
void http_url_add_to_json(cJSON *ctx, struct http_message *msg)
{
- struct hstring url_result = {};
+ hstring url_result = {};
if (cJSON_GetObjectItem(ctx, GTEST_HTTP_URL_NAME))
{
@@ -209,16 +213,16 @@ void http_url_add_to_json(cJSON *ctx, struct http_message *msg)
}
http_message_get_url(msg, &url_result);
- if(url_result.str == NULL)
+ if(url_result.iov_base == NULL)
{
- // printf("url:%s\n", url_result.str);
+ // printf("url:%s\n", url_result.iov_base);
return;
}
struct http_header url_header_result = {};
- url_header_result.key.str = (char *)GTEST_HTTP_URL_NAME;
- url_header_result.key.str_len = strlen(GTEST_HTTP_URL_NAME);
+ url_header_result.key.iov_base = (char *)GTEST_HTTP_URL_NAME;
+ url_header_result.key.iov_len = strlen(GTEST_HTTP_URL_NAME);
url_header_result.val = url_result;
http_header_to_json(ctx, &url_header_result);
@@ -289,7 +293,7 @@ static void http_decoder_test_update_session_tuple4(struct session *sess, struct
}
}
-static int get_gtest_plug_entry(const char *cfg_path, char *entry_name, int max_len)
+static int get_gtest_plug_entry(const char *cfg_path, char *entry_name, int max_len, char *topic_name, int topic_max_len)
{
FILE *fp = fopen(cfg_path, "r");
if (NULL == fp)
@@ -320,6 +324,14 @@ static int get_gtest_plug_entry(const char *cfg_path, char *entry_name, int max_
strncpy(entry_name, str_val.u.s, max_len);
free(str_val.u.s);
}
+
+ toml_datum_t topic_str_val = toml_string_in(basic_sec_tbl, "topic");
+ if (str_val.ok != 0)
+ {
+ strncpy(topic_name, topic_str_val.u.s, topic_max_len);
+ free(topic_str_val.u.s);
+ }
+
toml_free(root);
return 0;
}
@@ -345,7 +357,7 @@ extern "C" void http_decoder_test_entry(struct session *sess, int topic_id, cons
struct http_request_line req_line = {0};
struct http_response_line res_line = {0};
struct http_header header = {0};
- struct hstring body = {0};
+ hstring body = {0};
struct http_message *msg = (struct http_message *)raw_msg;
enum http_message_type msg_type = http_message_type_get(msg);
@@ -489,30 +501,83 @@ extern "C" void http_decoder_test_state_entry(struct session *sess, int topic_id
return;
}
+extern "C" void http_decoder_tunnel_entry(struct session *sess, int topic_id, const void *raw_msg, void *no_use_ctx, void *plugin_env)
+{
+ struct gtest_plug_exdata_t *gtest_plug_exdata;
+ enum http_tunnel_message_type tmsg_type = http_tunnel_message_type_get((const struct http_tunnel_message *)raw_msg);
+ static size_t req_payload_block = 0, req_payload_size = 0;
+ static size_t res_payload_block = 0, res_payload_size = 0;
+ gtest_plug_exdata = (struct gtest_plug_exdata_t *)session_exdata_get(sess, g_exdata_idx);
+
+ switch(tmsg_type){
+ case HTTP_TUNNEL_OPENING:
+ {
+ if (NULL == gtest_plug_exdata)
+ {
+ gtest_plug_exdata = (struct gtest_plug_exdata_t *)calloc(1, sizeof(struct gtest_plug_exdata_t));
+ session_exdata_set(sess, g_exdata_idx, gtest_plug_exdata);
+ }
+ const char *human_addr_cstr = session_get0_readable_addr(sess);
+ gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_REQ] = cJSON_CreateObject();
+ gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_RES] = cJSON_CreateObject();
+ gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_SESSION] = cJSON_CreateObject();
+ cJSON_AddStringToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_SESSION], GTEST_HTTP_TUPLE4_NAME, human_addr_cstr);
+ commit_test_result_json(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_SESSION], "TUNNEL_NEW");
+ }
+ // OPENING state has payload, go on
+
+ case HTTP_TUNNEL_ACTIVE:
+ {
+ int curdir = packet_get_direction(session_get0_current_packet(sess));
+ hstring tunnel_payload = {};
+ http_tunnel_message_get_payload((const struct http_tunnel_message *)raw_msg, &tunnel_payload);
+ if(PACKET_DIRECTION_C2S == curdir){
+ req_payload_block++;
+ req_payload_size += tunnel_payload.iov_len;
+ }else{
+ res_payload_block++;
+ res_payload_size += tunnel_payload.iov_len;
+ }
+ }
+ break;
+ case HTTP_TUNNEL_CLOSING:
+ {
+ cJSON_AddStringToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_REQ], "flow", "C2S");
+ cJSON_AddStringToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_RES], "flow", "S2C");
+ cJSON_AddNumberToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_REQ], "payload_block", req_payload_block);
+ cJSON_AddNumberToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_REQ], "payload_size", req_payload_size);
+ cJSON_AddNumberToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_RES], "payload_block", res_payload_block);
+ cJSON_AddNumberToObject(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_RES], "payload_size", res_payload_size);
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
extern "C" void *http_decoder_test_init(struct stellar *st)
{
g_http_gtest_plugin_id = stellar_session_plugin_register(st, NULL, NULL, NULL);
- g_exdata_idx = stellar_session_exdata_new_index(st, "HTTP_DECODER_REQ_TEST",
- http_decoder_test_exdata_free,
- NULL);
+ g_exdata_idx = stellar_session_exdata_new_index(st, "HTTP_DECODER_GTEST_EXDATA",http_decoder_test_exdata_free, NULL);
if (g_exdata_idx < 0)
{
printf("[%s:%d]: can't get http_decoder exdata index !!!\n", __FUNCTION__, __LINE__);
return NULL;
}
- g_topic_id = stellar_session_mq_get_topic_id(st, HTTP_DECODER_TOPIC);
+ char entry_name[64] = "";
+ char topic_name[64] = "";
+ get_gtest_plug_entry(GTEST_PLUG_ENTRY_CFG, entry_name, sizeof(entry_name)-1, topic_name, sizeof(topic_name)-1);
+ set_gtest_plug_entry(entry_name);
+ g_topic_id = stellar_session_mq_get_topic_id(st, topic_name);
if (g_topic_id < 0)
{
- printf("[%s:%d]: can't get http_decoder topic id !!!\n", __FUNCTION__, __LINE__);
+ printf("[%s:%d]: can't get http_decoder topic:%s id !!!\n", __FUNCTION__, __LINE__, topic_name);
return NULL;
- }
-
- char entry_name[64] = "";
- get_gtest_plug_entry(GTEST_PLUG_ENTRY_CFG, entry_name, sizeof(entry_name)-1);
- set_gtest_plug_entry(entry_name);
+ }
stellar_session_mq_subscribe(st, g_topic_id, g_entry_fun, g_http_gtest_plugin_id);
- printf("http_decoder_test_init succ, plugin_id:%d, topic_id:%d\n", g_http_gtest_plugin_id, g_topic_id);
+ printf("http_decoder_gtest_init succ, plugin_id:%d, sub_topic_id:%d\n", g_http_gtest_plugin_id, g_topic_id);
return (void *)strdup("http_decoder_test_ctx");
}
@@ -523,6 +588,5 @@ extern "C" void http_decoder_test_exit(void *test_ctx)
{
FREE(test_ctx);
}
- // update_config_file(GTEST_PLUG_ENTRY_CFG, "name", "\\x22http_decoder_test_entry\\x22");
printf("http_decoder_test_exit OK!\n");
} \ No newline at end of file
diff --git a/test/http_decoder_perf_main.cpp b/test/http_decoder_perf_main.cpp
index 5cfcf2c..5d1b0f2 100644
--- a/test/http_decoder_perf_main.cpp
+++ b/test/http_decoder_perf_main.cpp
@@ -24,6 +24,13 @@
#define TIME_DIFF()
#endif
+static struct http_topic_exdata_compose g_topic_exdata_set[] =
+{
+ {HTTPD_TOPIC_TCP_STREAM_INDEX, TOPIC_TCP_STREAM, NULL, NULL, "HTTP_DECODER_EXDATA_BASEON_TCP_STREAM", NULL, 0, 0},
+ {HTTPD_TOPIC_HTTP_MSG_INDEX, HTTP_DECODER_TOPIC, NULL, NULL, NULL, NULL, 1, 1},
+ {HTTPD_TOPIC_HTTP_TUNNEL_INDEX, HTTP_DECODER_TUNNEL_TOPIC, NULL, NULL, "HTTP_DECODER_EXDATA_BASEON_HTTP_TUNNEL", NULL, 2, 2},
+};
+
struct packet{
const char *payload;
size_t payload_len;
@@ -43,6 +50,7 @@ struct stellar{
struct session{
struct stellar *st;
+ enum session_state sess_state;
struct session_addr addr;
void *context;
void *exdata;
@@ -52,7 +60,7 @@ struct session{
extern "C" void *http_decoder_init(struct stellar *st);
extern "C" void http_decoder_exit(void *plugin_env);
-extern "C" void *_httpd_session_ctx_new_cb(struct session *sess, void *plugin_env);
+extern "C" void *httpd_session_ctx_new_cb(struct session *sess, void *plugin_env);
extern "C" void _httpd_ex_data_free_cb(struct session *s, int idx,void *ex_data, void *arg);
extern "C" void http_decoder_tcp_stream_msg_cb(struct session *sess, int topic_id, const void *msg, void *no_use_ctx, void *plugin_env);
extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, const void *raw_msg, void *per_session_ctx, void *plugin_env);
@@ -84,6 +92,10 @@ int stellar_get_current_thread_id(struct stellar *st)
{
return 0;
}
+int session_get_current_thread_id(struct session *sess)
+{
+ return 0;
+}
int stellar_session_plugin_register(struct stellar *st,
session_ctx_new_func session_ctx_new,
session_ctx_free_func session_ctx_free,
@@ -108,31 +120,31 @@ void *session_exdata_get(struct session *sess, int idx)
enum session_state session_get_current_state(struct session *sess)
{
- return SESSION_STATE_ACTIVE;
+ return sess->sess_state;
}
int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name)
{
- if(strcmp(topic_name, "HTTP_DECODER_MESSAGE") == 0){
- return st->publish_topic_id;
- }
- if(strcmp(topic_name, "TCP_STREAM") == 0){
- return st->consumer_topid_id;
+ for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
+ if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){
+ return st->consumer_topid_id;
+ }
}
- assert(0);
return -1;
}
int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name, session_msg_free_cb_func *msg_free_cb, void *msg_free_arg)
{
- if(strcmp(topic_name, "HTTP_DECODER_MESSAGE") == 0){
- st->publish_topic_id = 1;
- st->publish_msg_free_cb = msg_free_cb;
- return 1;
- }
- if(strcmp(topic_name, "TCP_STREAM") == 0){
- st->consumer_topid_id = 2;
- return 2;
+
+ for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
+ if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){
+ st->consumer_topid_id = g_topic_exdata_set[i].sub_topic_id;
+ st->publish_msg_free_cb = msg_free_cb;
+ if(strcmp(topic_name, "TCP_STREAM") == 0){
+ st->publish_topic_id = g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
+ }
+ return st->consumer_topid_id;
+ }
}
return -1;
}
@@ -179,9 +191,14 @@ int session_is_symmetric(struct session *sess, unsigned char *flag)
return 1;
}
+int session_mq_ignore_message(struct session *sess, int topic_id, int plugin_id)
+{
+ return 0;
+}
+
static void perf_test_init_per_session(struct session *sess)
{
- sess->context = _httpd_session_ctx_new_cb(sess, sess->st->plugin_env);
+ sess->context = httpd_session_ctx_new_cb(sess, sess->st->plugin_env);
}
static void perf_test_free_per_session(struct session *sess)
@@ -194,6 +211,7 @@ static void perf_test_loop(struct session *sess, struct packet *test_payload, in
TIME_START();
sess->current_payload_st = &test_payload[0];
perf_test_init_per_session(sess);
+ sess->sess_state = SESSION_STATE_OPENING;
for(int i = 0; i < test_payload_index_max; i++)
{
@@ -201,7 +219,9 @@ static void perf_test_loop(struct session *sess, struct packet *test_payload, in
http_decoder_tcp_stream_msg_cb(sess, sess->st->consumer_topid_id, test_payload[i].payload, NULL, sess->st->plugin_env);
TIME_DIFF();
fieldstat_easy_histogram_record(fs4_instance, 0, fs4_metric_id, tag, 1, time_diff_ns);
+ sess->sess_state = SESSION_STATE_ACTIVE;
}
+ sess->sess_state = SESSION_STATE_CLOSING;
perf_test_free_per_session(sess);
}
@@ -321,7 +341,7 @@ static void init_test_data_long_long_url(struct packet *test_payload, int *index
static void perf_stat_init(void)
{
fs4_instance = fieldstat_easy_new(1, "http_decoder_test", NULL, 0);
- fieldstat_easy_enable_auto_output(fs4_instance, "./httpd_fs4.json", 1);
+ fieldstat_easy_enable_auto_output(fs4_instance, "./httpd_hisgram.json", 1);
FS4_SIMPLE_HISGRAM_TAG.key = "simple";
FS4_SIMPLE_HISGRAM_TAG.type = TAG_DOUBLE;
diff --git a/test/http_decoder_perf_plug.cpp b/test/http_decoder_perf_plug.cpp
index f588683..c8c8771 100644
--- a/test/http_decoder_perf_plug.cpp
+++ b/test/http_decoder_perf_plug.cpp
@@ -28,8 +28,8 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
struct http_request_line req_line = {0};
struct http_response_line res_line = {0};
struct http_header header = {0};
- struct hstring url = {0};
- struct hstring body = {0};
+ hstring url = {0};
+ hstring body = {0};
struct http_message *msg = (struct http_message *)raw_msg;
enum http_message_type msg_type = http_message_type_get(msg);
void *ret1, *ret2;
@@ -39,23 +39,23 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
case HTTP_MESSAGE_REQ_LINE:
DEBUG_PRINT("---------------------------------------------------------------\n");
http_message_get_request_line(msg, &req_line);
- if (req_line.uri.str)
+ if (req_line.uri.iov_base)
{
- DEBUG_PRINT("req_line.method.str: %.*s\n", req_line.method.str_len, req_line.method.str);
- ret1 = memmem(req_line.method.str, req_line.method.str_len, "PUT", 3);
- DEBUG_PRINT("req_line.version.str: %.*s\n", req_line.version.str_len, req_line.version.str);
+ DEBUG_PRINT("req_line.method.iov_base: %.*s\n", req_line.method.iov_len, req_line.method.iov_base);
+ ret1 = memmem(req_line.method.iov_base, req_line.method.iov_len, "PUT", 3);
+ DEBUG_PRINT("req_line.version.iov_base: %.*s\n", req_line.version.iov_len, req_line.version.iov_base);
}
break;
case HTTP_MESSAGE_REQ_HEADER:
while (http_message_header_next(msg, &header) >= 0)
{
- ret1 = memmem(header.key.str, header.key.str_len, "key", 3);
- ret2 = memmem(header.val.str, header.val.str_len, "val", 3);
- DEBUG_PRINT("REQ header: %.*s : %.*s\n", (int)header.key.str_len, header.key.str, (int)header.val.str_len, header.val.str);
+ ret1 = memmem(header.key.iov_base, header.key.iov_len, "key", 3);
+ ret2 = memmem(header.val.iov_base, header.val.iov_len, "val", 3);
+ DEBUG_PRINT("REQ header: %.*s : %.*s\n", (int)header.key.iov_len, header.key.iov_base, (int)header.val.iov_len, header.val.iov_base);
}
http_message_get_url(msg, &url);
- if(url.str && url.str_len){
- DEBUG_PRINT("URL: %.*s\n", url.str_len, url.str);
+ if(url.iov_base && url.iov_len){
+ DEBUG_PRINT("URL: %.*s\n", url.iov_len, url.iov_base);
}
break;
case HTTP_MESSAGE_REQ_BODY:
@@ -63,29 +63,29 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
// output_http_body(&body, 0);
http_message_get_decompress_body(msg, &body);
// output_http_body(&body, 1);
- ret1 = memmem(body.str, body.str_len, "</html>", 7);
+ ret1 = memmem(body.iov_base, body.iov_len, "</html>", 7);
break;
case HTTP_MESSAGE_RES_LINE:
http_message_get_response_line(msg, &res_line);
- ret1 = memmem(res_line.status.str, res_line.status.str_len, "OK", 2);
- DEBUG_PRINT("res_line.status.str: %.*s\n", (int)res_line.status.str_len, res_line.status.str);
+ ret1 = memmem(res_line.status.iov_base, res_line.status.iov_len, "OK", 2);
+ DEBUG_PRINT("res_line.status.iov_base: %.*s\n", (int)res_line.status.iov_len, res_line.status.iov_base);
break;
case HTTP_MESSAGE_RES_HEADER:
while (http_message_header_next(msg, &header) >= 0)
{
- ret1 = memmem(header.key.str, header.key.str_len, "key", 3);
- ret2 = memmem(header.val.str, header.val.str_len, "val", 3);
- DEBUG_PRINT("RES header: %.*s : %.*s\n", (int)header.key.str_len, header.key.str, (int)header.val.str_len, header.val.str);
+ ret1 = memmem(header.key.iov_base, header.key.iov_len, "key", 3);
+ ret2 = memmem(header.val.iov_base, header.val.iov_len, "val", 3);
+ DEBUG_PRINT("RES header: %.*s : %.*s\n", (int)header.key.iov_len, header.key.iov_base, (int)header.val.iov_len, header.val.iov_base);
}
break;
case HTTP_MESSAGE_RES_BODY:
http_message_get_raw_body(msg, &body);
- DEBUG_PRINT("res raw body: %.*s\n", body.str_len, body.str);
+ DEBUG_PRINT("res raw body: %.*s\n", body.iov_len, body.iov_base);
// output_http_body(&body, 0);
http_message_get_decompress_body(msg, &body);
// output_http_body(&body, 1);
- ret1 = memmem(body.str, body.str_len, "</html>", 7);
- DEBUG_PRINT("res unzip body: %.*s\n", body.str_len, body.str);
+ ret1 = memmem(body.iov_base, body.iov_len, "</html>", 7);
+ DEBUG_PRINT("res unzip body: %.*s\n", body.iov_len, body.iov_base);
DEBUG_PRINT("---------------------------------------------------------------\n");
break;
diff --git a/test/http_pcap/http_tunnel_for_http.pcap b/test/http_pcap/http_tunnel_for_http.pcap
new file mode 100644
index 0000000..0654576
--- /dev/null
+++ b/test/http_pcap/http_tunnel_for_http.pcap
Binary files differ
diff --git a/test/test_result_json/http_inner_tunnel_for_http.json b/test/test_result_json/http_inner_tunnel_for_http.json
new file mode 100644
index 0000000..973556a
--- /dev/null
+++ b/test/test_result_json/http_inner_tunnel_for_http.json
@@ -0,0 +1,15 @@
+[
+ {
+ "__X_HTTP_TUPLE4": "192.168.40.139.59234>192.168.38.83.8080"
+ },
+ {
+ "flow": "C2S",
+ "payload_block": 1,
+ "payload_size": 77
+ },
+ {
+ "flow": "S2C",
+ "payload_block": 3,
+ "payload_size": 2781
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_inner_tunnel_for_pop3.json b/test/test_result_json/http_inner_tunnel_for_pop3.json
new file mode 100644
index 0000000..b4f9784
--- /dev/null
+++ b/test/test_result_json/http_inner_tunnel_for_pop3.json
@@ -0,0 +1,15 @@
+[
+ {
+ "__X_HTTP_TUPLE4": "192.168.10.58.51798>192.168.10.144.808"
+ },
+ {
+ "flow": "C2S",
+ "payload_block": 6,
+ "payload_size": 68
+ },
+ {
+ "flow": "S2C",
+ "payload_block": 7,
+ "payload_size": 1737
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_msg_type_state_tunnel.json b/test/test_result_json/http_msg_type_state_tunnel.json
new file mode 100644
index 0000000..cdbad4e
--- /dev/null
+++ b/test/test_result_json/http_msg_type_state_tunnel.json
@@ -0,0 +1,26 @@
+[
+ {
+ "msg_0": "HTTP_TRANSACTION_NEW_transaction_0",
+ "msg_1": "HTTP_MESSAGE_REQ_LINE",
+ "msg_2": "HTTP_MESSAGE_REQ_HEADER",
+ "msg_3": "HTTP_MESSAGE_REQ_HEADER_END",
+ "msg_8": "HTTP_TRANSACTION_NEW_transaction_1",
+ "msg_9": "HTTP_MESSAGE_REQ_LINE",
+ "msg_10": "HTTP_MESSAGE_REQ_HEADER",
+ "msg_11": "HTTP_MESSAGE_REQ_HEADER_END"
+ },
+ {
+ "msg_4": "HTTP_MESSAGE_RES_LINE",
+ "msg_5": "HTTP_MESSAGE_RES_HEADER",
+ "msg_6": "HTTP_MESSAGE_RES_HEADER_END",
+ "msg_7": "HTTP_TRANSACTION_FREE_transaction_0",
+ "msg_12": "HTTP_MESSAGE_RES_LINE",
+ "msg_13": "HTTP_MESSAGE_RES_HEADER",
+ "msg_14": "HTTP_MESSAGE_RES_HEADER_END",
+ "msg_15": "HTTP_MESSAGE_RES_BODY",
+ "msg_16": "HTTP_MESSAGE_RES_BODY",
+ "msg_17": "HTTP_MESSAGE_RES_BODY",
+ "msg_18": "HTTP_MESSAGE_RES_BODY_END",
+ "msg_19": "HTTP_TRANSACTION_FREE_transaction_1"
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_tunnel_for_http.json b/test/test_result_json/http_tunnel_for_http.json
new file mode 100644
index 0000000..acc5828
--- /dev/null
+++ b/test/test_result_json/http_tunnel_for_http.json
@@ -0,0 +1,62 @@
+[
+ {
+ "__X_HTTP_TUPLE4": "192.168.40.139.59234>192.168.38.83.8080"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "request",
+ "__X_HTTP_TRANSACTION_SEQ": 0,
+ "method": "CONNECT",
+ "uri": "www.baidu.com:80",
+ "req_version": "1.1",
+ "major_version": 1,
+ "minor_version": 1,
+ "Host": "www.baidu.com:80",
+ "User-Agent": "curl/7.29.0",
+ "Proxy-Connection": "Keep-Alive",
+ "__X_HTTP_URL": "www.baidu.com:80"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "response",
+ "__X_HTTP_TRANSACTION_SEQ": 0,
+ "res_version": "1.1",
+ "res_status": "Connection established",
+ "major_version": 1,
+ "minor_version": 1,
+ "status_code": 200,
+ "Proxy-agent": "CCProxy"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "request",
+ "__X_HTTP_TRANSACTION_SEQ": 1,
+ "method": "GET",
+ "uri": "/",
+ "req_version": "1.1",
+ "major_version": 1,
+ "minor_version": 1,
+ "User-Agent": "curl/7.29.0",
+ "Host": "www.baidu.com",
+ "Accept": "*/*",
+ "__X_HTTP_URL": "www.baidu.com/"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "response",
+ "__X_HTTP_TRANSACTION_SEQ": 1,
+ "res_version": "1.1",
+ "res_status": "OK",
+ "major_version": 1,
+ "minor_version": 1,
+ "status_code": 200,
+ "Accept-Ranges": "bytes",
+ "Cache-Control": "private, no-cache, no-store, proxy-revalidate, no-transform",
+ "Connection": "keep-alive",
+ "Content-Length": "2381",
+ "Content-Type": "text/html",
+ "Date": "Mon, 08 Apr 2024 09:45:51 GMT",
+ "Etag": "\"588604c1-94d\"",
+ "Last-Modified": "Mon, 23 Jan 2017 13:27:29 GMT",
+ "Pragma": "no-cache",
+ "Server": "bfe/1.0.8.18",
+ "Set-Cookie": "BDORZ=27315; max-age=86400; domain=.baidu.com; path=/",
+ "__X_HTTP_PAYLOAD_MD5": "090fe607a5be1228362614ccaa088577"
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_tunnel_for_pop3.json b/test/test_result_json/http_tunnel_for_pop3.json
index 9bf2f41..a69ac7b 100644
--- a/test/test_result_json/http_tunnel_for_pop3.json
+++ b/test/test_result_json/http_tunnel_for_pop3.json
@@ -17,7 +17,7 @@
"Proxy-Connection": "Keep-Alive",
"Connection": "Keep-Alive",
"Host": "192.168.10.144",
- "__X_HTTP_URL": "192.168.10.144/pop.163.com:110"
+ "__X_HTTP_URL": "pop.163.com:110"
},
{
"__X_HTTP_TRANSACTION": "response",
@@ -27,7 +27,6 @@
"major_version": 1,
"minor_version": 1,
"status_code": 200,
- "Proxy-agent": "CCProxy",
- "__X_HTTP_PAYLOAD_MD5": "8a9716c4f06c88bb9482f50c25b39032"
+ "Proxy-agent": "CCProxy"
}
] \ No newline at end of file