summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijia <[email protected]>2024-08-09 18:42:11 +0800
committerlijia <[email protected]>2024-08-09 18:52:09 +0800
commitd27dc94f3d64f698c06bcb671364d923a878b7ed (patch)
treead5e0dd86068d53b08391d18574ab1a63ae38b7d
parentc4c7aa89bf01b321f5b582d84b684171e6dbcf66 (diff)
adapt native stellar platform
-rw-r--r--.gitlab-ci.yml8
-rw-r--r--cmake/PreInstall.sh18
-rw-r--r--cmake/PreUninstall.sh2
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/http_decoder.cpp455
-rw-r--r--src/http_decoder_half.cpp6
-rw-r--r--src/http_decoder_inc.h8
-rw-r--r--src/http_decoder_tunnel.cpp4
-rw-r--r--src/http_decoder_utils.cpp10
-rw-r--r--src/http_decoder_utils.h6
-rw-r--r--test/CMakeLists.txt8
-rw-r--r--test/http_decoder_gtest.h4
-rw-r--r--test/http_decoder_perf_main.cpp54
-rw-r--r--test/http_decoder_perf_plug.cpp6
-rw-r--r--test/http_decoder_test_plug.cpp20
-rw-r--r--test/http_stellar_mock.cpp35
-rw-r--r--test/http_stellar_mock.h50
-rw-r--r--test/test_result_json/http_chn_encode_url.json2
-rw-r--r--test/test_result_json/http_chunked_res_gzip.json2
-rw-r--r--test/test_result_json/http_get_encoded_uri.json2
-rw-r--r--test/test_result_json/http_get_long_cookie.json2
-rw-r--r--test/test_result_json/http_get_multi_trans.json2
-rw-r--r--test/test_result_json/http_get_req_pipeline.json2
-rw-r--r--test/test_result_json/http_get_single_trans.json2
-rw-r--r--test/test_result_json/http_hdrs_exceed_maximum.json2
-rw-r--r--test/test_result_json/http_multi_parse_error.json2
-rw-r--r--test/test_result_json/http_no_content_length.json2
-rw-r--r--test/test_result_json/http_over_pppoe.json2
-rw-r--r--test/test_result_json/http_over_tcp_keepalive.json2
-rw-r--r--test/test_result_json/http_post_multipart_form_data.json2
-rw-r--r--test/test_result_json/http_req_1byte_sliding_window.json2
-rw-r--r--test/test_result_json/http_res_1byte_sliding_window.json2
-rw-r--r--test/test_result_json/http_res_gzip.json2
-rw-r--r--test/test_result_json/http_trans_pipeline.json2
-rw-r--r--test/test_result_json/http_upgrade_websocket.json2
-rw-r--r--test_based_on_stellar/CMakeLists.txt195
-rw-r--r--test_based_on_stellar/env/conflist.inf7
-rw-r--r--test_based_on_stellar/env/defer_loader.inf14
-rw-r--r--test_based_on_stellar/env/log.toml4
-rw-r--r--test_based_on_stellar/env/spec.toml4
-rw-r--r--test_based_on_stellar/env/start_loader.inf30
-rw-r--r--test_based_on_stellar/env/stellar.toml57
-rw-r--r--test_based_on_stellar/plugin_test_main.cpp48
43 files changed, 540 insertions, 554 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5203986..92f6c5c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,11 +2,9 @@ variables:
GIT_STRATEGY: "clone"
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
- INSTALL_DEPENDENCY_LIBRARY: sapp-devel framework_env libMESA_prof_load-devel libasan
- libMESA_htable-devel libMESA_jump_layer libMESA_jump_layer-devel
- libMESA_handle_logger-devel libfieldstat4-devel libfieldstat4 libbreakpad_mini-devel
- zlib-devel brotli brotli-devel stellar-on-sapp-devel systemd-devel
- libMESA_field_stat2-devel libfieldstat3-devel libMESA_field_stat2 libfieldstat3
+ INSTALL_DEPENDENCY_LIBRARY: framework_env libMESA_prof_load-devel libasan
+ libMESA_handle_logger-devel libfieldstat4-devel libfieldstat4
+ zlib-devel brotli brotli-devel stellar-devel systemd-devel
SYMBOL_TARGET: http_decoder
TEST_NAME: gtest_http_decoder
INSTALL_PREFIX: "/opt/tsg/"
diff --git a/cmake/PreInstall.sh b/cmake/PreInstall.sh
index db2b917..94f8c5f 100644
--- a/cmake/PreInstall.sh
+++ b/cmake/PreInstall.sh
@@ -1,13 +1,13 @@
DST=${RPM_INSTALL_PREFIX}/sapp/
-mkdir -p ${DST}/stellar_plugin
-touch ${DST}/stellar_plugin/spec.toml
+mkdir -p ${DST}/plugin
+touch ${DST}/plugin/spec.toml
-if ! grep -q '^\./plug/stellar_plugin/http_decoder.so' "${DST}/stellar_plugin/spec.toml"; then
- echo -e "\n" >> "${DST}/stellar_plugin/spec.toml"
- echo -e "[[plugin]]" >> "${DST}/stellar_plugin/spec.toml"
- echo -e "path = \"./stellar_plugin/http_decoder/http_decoder.so\"" >> "${DST}/stellar_plugin/spec.toml"
- echo -e "init = \"http_decoder_init\"" >> "${DST}/stellar_plugin/spec.toml"
- echo -e "exit = \"http_decoder_exit\"" >> "${DST}/stellar_plugin/spec.toml"
- echo -e "\n" >> "${DST}/stellar_plugin/spec.toml"
+if ! grep -q '^\./plug/plugin/http_decoder.so' "${DST}/plugin/spec.toml"; then
+ echo -e "\n" >> "${DST}/plugin/spec.toml"
+ echo -e "[[plugin]]" >> "${DST}/plugin/spec.toml"
+ echo -e "path = \"./plugin/http_decoder/http_decoder.so\"" >> "${DST}/plugin/spec.toml"
+ echo -e "init = \"http_decoder_init\"" >> "${DST}/plugin/spec.toml"
+ echo -e "exit = \"http_decoder_exit\"" >> "${DST}/plugin/spec.toml"
+ echo -e "\n" >> "${DST}/plugin/spec.toml"
fi
diff --git a/cmake/PreUninstall.sh b/cmake/PreUninstall.sh
index a704de5..e694083 100644
--- a/cmake/PreUninstall.sh
+++ b/cmake/PreUninstall.sh
@@ -1,5 +1,5 @@
if [ $1 == 0 ]; then
- DST=${RPM_INSTALL_PREFIX}/sapp/stellar_plugin
+ DST=${RPM_INSTALL_PREFIX}/sapp/plugin
sed -i -n '$!N;/http_decoder.so/!P;D' ${DST}/spec.toml
sed -i '/http_decoder_init/d' ${DST}/spec.toml
sed -i '/http_decoder_exit/d' ${DST}/spec.toml
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 469591b..76d8603 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,6 +2,7 @@ add_definitions(-fPIC)
include_directories(/opt/MESA/include/)
include_directories(/opt/tsg/framework/include/)
+include_directories(/opt/tsg/stellar/include/)
include_directories(${PROJECT_SOURCE_DIR}/deps/)
include_directories(${CMAKE_BINARY_DIR}/vendor/vbuild/include)
@@ -14,7 +15,7 @@ set(HTTP_SRC ${DEPS_SRC} http_decoder.cpp http_decoder_utils.cpp http_decoder_ha
add_library(http_decoder SHARED ${HTTP_SRC})
set_target_properties(http_decoder PROPERTIES LINK_FLAGS "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/version.map")
-target_link_libraries(http_decoder z brotlidec llhttp-static fieldstat4)
+target_link_libraries(http_decoder z brotlidec llhttp-static fieldstat4 stellar_devel)
set_target_properties(http_decoder PROPERTIES PREFIX "")
-install(TARGETS http_decoder LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/sapp/stellar_plugin/${lib_name} COMPONENT LIBRARIES) \ No newline at end of file
+install(TARGETS http_decoder LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/sapp/plugin/${lib_name} COMPONENT LIBRARIES) \ No newline at end of file
diff --git a/src/http_decoder.cpp b/src/http_decoder.cpp
index 6be2550..1b177d9 100644
--- a/src/http_decoder.cpp
+++ b/src/http_decoder.cpp
@@ -6,7 +6,7 @@
#include "http_decoder_inc.h"
struct http_message *http_message_new(enum http_message_type type, struct http_decoder_result_queue *queue,
- int queue_index, uint8_t flow_type)
+ int queue_index, uint8_t flow_type)
{
struct http_message *msg = CALLOC(struct http_message, 1);
msg->type = type;
@@ -16,7 +16,7 @@ struct http_message *http_message_new(enum http_message_type type, struct http_d
return msg;
}
-static void http_message_free(struct session *sess, void *http_msg, void *cb_arg)
+static void http_message_free(void *http_msg, void *cb_arg)
{
if (http_msg)
{
@@ -39,12 +39,15 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
u_int8_t flow_flag = 0;
struct http_decoder_exdata *exdata = ev_ctx->ref_httpd_ctx;
- int thread_id = stellar_get_current_thread_id(httpd_env->st);
+ int thread_id = stellar_get_current_thread_index();
- if(http_event_is_req(event)){
+ if (http_event_is_req(event))
+ {
queue_idx = http_decoder_result_queue_req_index(queue);
half_data = http_decoder_result_queue_peek_req(queue);
- }else{
+ }
+ else
+ {
queue_idx = http_decoder_result_queue_res_index(queue);
half_data = http_decoder_result_queue_peek_res(queue);
}
@@ -75,41 +78,44 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
half_data = NULL;
}
*data = half_data;
- queue_idx = http_decoder_result_queue_req_index(queue); //get the index after inc
+ queue_idx = http_decoder_result_queue_req_index(queue); // get the index after inc
/* llhttp always call on_message_begin() even if llhttp_execute() error!!! */
msg = http_message_new(HTTP_TRANSACTION_START, queue, queue_idx, HTTP_REQUEST);
- session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TRANSACTION_NEW, 1);
+ session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TRANSACTION_NEW, 1);
break;
case HTTP_EVENT_REQ_LINE:
msg = http_message_new(HTTP_MESSAGE_REQ_LINE, queue, queue_idx, HTTP_REQUEST);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- if(httpd_tunnel_identify(httpd_env, PACKET_DIRECTION_C2S, half_data)){
+ if (httpd_tunnel_identify(httpd_env, FLOW_DIRECTION_C2S, half_data))
+ {
exdata->tunnel_state = HTTP_TUN_C2S_HDR_START;
- http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TUNNEL, 1);
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TUNNEL, 1);
}
- if(httpd_is_tunnel_session(exdata)){
+ if (httpd_is_tunnel_session(exdata))
+ {
http_decoder_get_url(half_data, mempool);
}
break;
case HTTP_EVENT_REQ_HDR:
msg = http_message_new(HTTP_MESSAGE_REQ_HEADER, queue, queue_idx, HTTP_REQUEST);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- break;
+ break;
case HTTP_EVENT_REQ_HDR_END:
{
http_decoder_join_url_finally(ev_ctx, half_data, mempool);
/* maybe some parsed headers in buffer, but has not pushed to plugins yet */
-
- if(http_decoder_half_data_has_parsed_header(half_data)){
+
+ if (http_decoder_half_data_has_parsed_header(half_data))
+ {
msg = http_message_new(HTTP_MESSAGE_REQ_HEADER, queue, queue_idx, HTTP_REQUEST);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
}
http_half_data_update_commit_index(half_data);
msg = http_message_new(HTTP_MESSAGE_REQ_HEADER_END, queue, queue_idx, HTTP_REQUEST);
- session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
+ session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- int tot_c2s_headers = http_half_data_get_total_parsed_header_count(half_data);
+ int tot_c2s_headers = http_half_data_get_total_parsed_header_count(half_data);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_HEADERS_C2S, tot_c2s_headers);
hstring tmp_url = {};
@@ -133,17 +139,22 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
{
session_is_symmetric(ev_ctx->ref_session, &flow_flag);
- if(SESSION_SEEN_C2S_FLOW == flow_flag){
+ if (SESSION_SEEN_C2S_FLOW == flow_flag)
+ {
msg = http_message_new(HTTP_TRANSACTION_END, queue, queue_idx, HTTP_REQUEST);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TRANSACTION_FREE, 1);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_ASYMMETRY_TRANSACTION_C2S, 1);
}
- if(httpd_is_tunnel_session(exdata)){
- if(SESSION_SEEN_C2S_FLOW == flow_flag){
+ if (httpd_is_tunnel_session(exdata))
+ {
+ if (SESSION_SEEN_C2S_FLOW == flow_flag)
+ {
exdata->tunnel_state = HTTP_TUN_INNER_STARTING;
exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].sub_topic_id;
- }else{
+ }
+ else
+ {
exdata->tunnel_state = HTTP_TUN_C2S_END;
}
}
@@ -156,7 +167,7 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
half_data = NULL;
}
}
- break;
+ break;
case HTTP_EVENT_RES_INIT:
half_data = http_decoder_result_queue_peek_res(queue);
@@ -181,22 +192,27 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
http_decoder_half_data_free(mempool, half_data);
half_data = NULL;
}
- queue_idx = http_decoder_result_queue_res_index(queue); //get the index after inc
+ queue_idx = http_decoder_result_queue_res_index(queue); // get the index after inc
*data = half_data;
- if(0 == session_is_symmetric(ev_ctx->ref_session, &flow_flag)){
- if(SESSION_SEEN_S2C_FLOW == flow_flag){
+ if (0 == session_is_symmetric(ev_ctx->ref_session, &flow_flag))
+ {
+ if (SESSION_SEEN_S2C_FLOW == flow_flag)
+ {
msg = http_message_new(HTTP_TRANSACTION_START, queue, queue_idx, HTTP_RESPONSE);
- session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
+ session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
}
}
break;
case HTTP_EVENT_RES_LINE:
msg = http_message_new(HTTP_MESSAGE_RES_LINE, queue, queue_idx, HTTP_RESPONSE);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- if(httpd_tunnel_identify(httpd_env,PACKET_DIRECTION_S2C, half_data)){
+ if (httpd_tunnel_identify(httpd_env, FLOW_DIRECTION_S2C, half_data))
+ {
exdata->tunnel_state = HTTP_TUN_S2C_START;
- }else{
- //connect response fail, reset tunnel_state
+ }
+ else
+ {
+ // connect response fail, reset tunnel_state
exdata->tunnel_state = HTTP_TUN_NON;
}
break;
@@ -208,27 +224,29 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
{
/* maybe some header in table buffer but has not pushed to plugins */
half_data = http_decoder_result_queue_peek_res(queue);
- if(http_decoder_half_data_has_parsed_header(half_data)){
+ if (http_decoder_half_data_has_parsed_header(half_data))
+ {
msg = http_message_new(HTTP_MESSAGE_RES_HEADER, queue, queue_idx, HTTP_RESPONSE);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
}
http_half_data_update_commit_index(half_data);
msg = http_message_new(HTTP_MESSAGE_RES_HEADER_END, queue, queue_idx, HTTP_RESPONSE);
- session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
+ session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- int tot_s2c_headers = http_half_data_get_total_parsed_header_count(half_data);
+ int tot_s2c_headers = http_half_data_get_total_parsed_header_count(half_data);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_HEADERS_S2C, tot_s2c_headers);
-
- if(httpd_is_tunnel_session(exdata)){
+
+ if (httpd_is_tunnel_session(exdata))
+ {
exdata->tunnel_state = HTTP_TUN_INNER_STARTING;
http_half_pre_context_free(ev_ctx->ref_session, exdata);
exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].sub_topic_id;
- }
+ }
}
- break;
+ break;
case HTTP_EVENT_RES_BODY_BEGIN:
msg = http_message_new(HTTP_MESSAGE_RES_BODY_START, queue, queue_idx, HTTP_RESPONSE);
- session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
+ session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
break;
case HTTP_EVENT_RES_BODY_DATA:
msg = http_message_new(HTTP_MESSAGE_RES_BODY, queue, queue_idx, HTTP_RESPONSE);
@@ -236,14 +254,15 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
break;
case HTTP_EVENT_RES_BODY_END:
msg = http_message_new(HTTP_MESSAGE_RES_BODY_END, queue, queue_idx, HTTP_RESPONSE);
- session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
+ session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
break;
case HTTP_EVENT_RES_END:
msg = http_message_new(HTTP_TRANSACTION_END, queue, queue_idx, HTTP_RESPONSE);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
- http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TRANSACTION_FREE, 1);
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TRANSACTION_FREE, 1);
session_is_symmetric(ev_ctx->ref_session, &flow_flag);
- if(SESSION_SEEN_S2C_FLOW == flow_flag){
+ if (SESSION_SEEN_S2C_FLOW == flow_flag)
+ {
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_ASYMMETRY_TRANSACTION_S2C, 1);
}
@@ -260,18 +279,19 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
assert(0);
break;
}
- if(half_data){
+ if (half_data)
+ {
http_half_update_state(half_data, event);
}
}
-static struct http_decoder *http_decoder_new(struct http_decoder_exdata *hd_ctx, nmx_pool_t *mempool,
- http_event_cb *ev_cb, int decompress_switch, struct http_decoder_env *httpd_env,
- long long req_start_seq, long long res_start_seq)
+static struct http_decoder *http_decoder_new(struct http_decoder_exdata *hd_ctx, nmx_pool_t *mempool,
+ http_event_cb *ev_cb, int decompress_switch, struct http_decoder_env *httpd_env,
+ long long req_start_seq, long long res_start_seq)
{
struct http_decoder *decoder = MEMPOOL_CALLOC(mempool, struct http_decoder, 1);
assert(decoder);
- decoder->c2s_half = http_decoder_half_new(hd_ctx, mempool, ev_cb, HTTP_REQUEST, decompress_switch, httpd_env, req_start_seq);
+ decoder->c2s_half = http_decoder_half_new(hd_ctx, mempool, ev_cb, HTTP_REQUEST, decompress_switch, httpd_env, req_start_seq);
decoder->s2c_half = http_decoder_half_new(hd_ctx, mempool, ev_cb, HTTP_RESPONSE, decompress_switch, httpd_env, res_start_seq);
return decoder;
}
@@ -296,13 +316,13 @@ static void http_decoder_free(nmx_pool_t *mempool, struct http_decoder *decoder)
}
static struct http_decoder_exdata *http_decoder_exdata_new(size_t mempool_size, size_t queue_size,
- int decompress_switch, struct http_decoder_env *httpd_env,
- long long req_start_seq, long long res_start_seq)
+ int decompress_switch, struct http_decoder_env *httpd_env,
+ long long req_start_seq, long long res_start_seq)
{
struct http_decoder_exdata *hd_ctx = CALLOC(struct http_decoder_exdata, 1);
hd_ctx->mempool = nmx_create_pool(mempool_size);
- hd_ctx->decoder = http_decoder_new(hd_ctx, hd_ctx->mempool, http_event_handler, decompress_switch,
- httpd_env, req_start_seq, res_start_seq);
+ hd_ctx->decoder = http_decoder_new(hd_ctx, hd_ctx->mempool, http_event_handler, decompress_switch,
+ httpd_env, req_start_seq, res_start_seq);
hd_ctx->queue = http_decoder_result_queue_new(hd_ctx->mempool, queue_size);
return hd_ctx;
}
@@ -323,7 +343,8 @@ static void http_decoder_exdata_free(struct http_decoder_exdata *ex_data)
http_decoder_result_queue_free(ex_data->mempool, ex_data->queue);
ex_data->queue = NULL;
}
- if(ex_data->mempool){
+ if (ex_data->mempool)
+ {
nmx_destroy_pool(ex_data->mempool);
}
FREE(ex_data);
@@ -355,9 +376,11 @@ static void _http_decoder_context_free(struct http_decoder_env *env)
http_decoder_stat_free(&env->hd_stat);
- for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
- if(env->topic_exdata_compose[i].msg_free_cb){
- stellar_session_mq_destroy_topic(env->st, env->topic_exdata_compose[i].sub_topic_id);
+ for (int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++)
+ {
+ if (env->topic_exdata_compose[i].msg_free_cb)
+ {
+ stellar_mq_destroy_topic(env->st, env->topic_exdata_compose[i].sub_topic_id);
}
}
@@ -451,7 +474,7 @@ static int load_http_decoder_config(const char *cfg_path,
}
static int http_msg_get_request_header(const struct http_message *msg, const hstring *key,
- struct http_header *hdr_result)
+ struct http_header *hdr_result)
{
const struct http_decoder_half_data *req_data =
msg->ref_queue->array[msg->queue_index].req_data;
@@ -475,7 +498,7 @@ static int http_msg_request_header_next(const struct http_message *msg,
}
static int http_msg_response_header_next(const struct http_message *msg,
- struct http_header *hdr)
+ struct http_header *hdr)
{
const struct http_decoder_half_data *res_data =
msg->ref_queue->array[msg->queue_index].res_data;
@@ -483,7 +506,7 @@ static int http_msg_response_header_next(const struct http_message *msg,
}
static int http_msg_get_request_raw_body(const struct http_message *msg,
- hstring *body)
+ hstring *body)
{
const struct http_decoder_half_data *req_data =
msg->ref_queue->array[msg->queue_index].req_data;
@@ -491,7 +514,7 @@ static int http_msg_get_request_raw_body(const struct http_message *msg,
}
static int http_msg_get_response_raw_body(const struct http_message *msg,
- hstring *body)
+ hstring *body)
{
const struct http_decoder_half_data *res_data =
msg->ref_queue->array[msg->queue_index].res_data;
@@ -499,7 +522,7 @@ static int http_msg_get_response_raw_body(const struct http_message *msg,
}
static int http_msg_get_request_decompress_body(const struct http_message *msg,
- hstring *body)
+ hstring *body)
{
const struct http_decoder_half_data *req_data =
msg->ref_queue->array[msg->queue_index].req_data;
@@ -507,23 +530,23 @@ static int http_msg_get_request_decompress_body(const struct http_message *msg,
}
static int http_msg_get_response_decompress_body(const struct http_message *msg,
- hstring *body)
+ hstring *body)
{
const struct http_decoder_half_data *res_data =
msg->ref_queue->array[msg->queue_index].res_data;
return http_decoder_half_data_get_decompress_body(res_data, body);
}
-static struct http_decoder_exdata *httpd_session_exdata_new(struct session *sess, struct http_decoder_env *httpd_env,
+static struct http_decoder_exdata *httpd_session_exdata_new(struct session *sess, struct http_decoder_env *httpd_env,
long long req_start_seq, long long res_start_seq)
{
struct http_decoder_exdata *exdata = http_decoder_exdata_new(httpd_env->hd_cfg.mempool_size,
- httpd_env->hd_cfg.result_queue_len,
- httpd_env->hd_cfg.decompress_switch,
- httpd_env,req_start_seq,res_start_seq);
+ httpd_env->hd_cfg.result_queue_len,
+ httpd_env->hd_cfg.decompress_switch,
+ httpd_env, req_start_seq, res_start_seq);
// exdata->sub_topic_id = sub_topic_id;
- int thread_id = stellar_get_current_thread_id(httpd_env->st);
- http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_SESSION_NEW, 1);
+ int thread_id = stellar_get_current_thread_index();
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_SESSION_NEW, 1);
return exdata;
}
@@ -532,7 +555,7 @@ extern "C"
{
#endif
- void httpd_ex_data_free_cb(struct session *s, int idx, void *ex_data, void *arg)
+ void httpd_ex_data_free_cb(int idx, void *ex_data, void *arg)
{
if (NULL == ex_data)
{
@@ -545,7 +568,7 @@ extern "C"
void *httpd_session_ctx_new_cb(struct session *sess, void *plugin_env)
{
// If not http, ignore this session
- size_t payload_len;
+ uint16_t payload_len;
struct http_decoder_env *httpd_env = (struct http_decoder_env *)plugin_env;
const char *payload = session_get0_current_payload(sess, &payload_len);
if (payload != NULL && payload_len > 0)
@@ -557,6 +580,10 @@ extern "C"
stellar_session_plugin_dettach_current_session(sess);
return (void *)HTTP_CTX_NOT_HTTP;
}
+
+ struct http_decoder_exdata *exdata = httpd_session_exdata_new(sess, httpd_env, 0, 0);
+ exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
+ session_exdata_set(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_TCP_STREAM_INDEX].exdata_id, exdata);
}
return (void *)HTTP_CTX_IS_HTTP;
@@ -564,45 +591,53 @@ extern "C"
void httpd_session_ctx_free_cb(struct session *sess, void *session_ctx, void *plugin_env)
{
- if(NULL == plugin_env || NULL == session_ctx){
+ if (NULL == plugin_env || NULL == session_ctx)
+ {
return;
}
- if(strncmp((const char *)session_ctx, HTTP_CTX_NOT_HTTP, strlen(HTTP_CTX_NOT_HTTP)) == 0){
+ if (strncmp((const char *)session_ctx, HTTP_CTX_NOT_HTTP, strlen(HTTP_CTX_NOT_HTTP)) == 0)
+ {
return;
}
struct http_decoder_env *httpd_env = (struct http_decoder_env *)plugin_env;
- int thread_id = session_get_current_thread_id(sess);
+ int thread_id = stellar_get_current_thread_index();
unsigned char flow_flag = 0;
session_is_symmetric(sess, &flow_flag);
- if(SESSION_SEEN_C2S_FLOW == flow_flag){
+ if (SESSION_SEEN_C2S_FLOW == flow_flag)
+ {
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_ASYMMETRY_SESSION_C2S, 1);
- }else if(SESSION_SEEN_S2C_FLOW == flow_flag){
+ }
+ else if (SESSION_SEEN_S2C_FLOW == flow_flag)
+ {
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_ASYMMETRY_SESSION_S2C, 1);
- }else{
- http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_SESSION_FREE, 1);
+ }
+ else
+ {
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_SESSION_FREE, 1);
}
}
static void http_decoder_execute(struct session *sess, struct http_decoder_env *httpd_env, http_decoder_exdata *exdata)
{
- size_t payload_len;
+ uint16_t payload_len;
const char *payload = session_get0_current_payload(sess, &payload_len);
if (unlikely(0 == payload_len || NULL == payload))
{
return;
}
- if(httpd_in_tunnel_transmitting(exdata)){
+ if (httpd_in_tunnel_transmitting(exdata))
+ {
http_decoder_push_tunnel_data(sess, exdata, httpd_tunnel_state_to_msg(exdata));
httpd_tunnel_state_update(exdata);
return;
}
- int thread_id = session_get_current_thread_id(sess);
- struct http_decoder_half *cur_half = NULL;
- int sess_dir = packet_get_direction(session_get0_current_packet(sess));
- if (PACKET_DIRECTION_C2S == sess_dir)
+ int thread_id = stellar_get_current_thread_index();
+ struct http_decoder_half *cur_half = NULL;
+ enum flow_direction sess_dir = session_get_current_flow_direction(sess);
+ if (FLOW_DIRECTION_C2S == sess_dir)
{
cur_half = exdata->decoder->c2s_half;
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_BYTES_C2S, payload_len);
@@ -612,7 +647,7 @@ extern "C"
{
cur_half = exdata->decoder->s2c_half;
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_BYTES_S2C, payload_len);
- http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TCP_SEG_S2C, 1);
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TCP_SEG_S2C, 1);
}
http_decoder_half_reinit(cur_half, exdata->queue, exdata->mempool, sess);
@@ -627,7 +662,8 @@ extern "C"
void http_decoder_tunnel_msg_cb(struct session *sess, int topic_id, const void *tmsg, void *per_session_ctx, void *plugin_env)
{
struct http_decoder_env *httpd_env = (struct http_decoder_env *)plugin_env;
- if(0 == httpd_env->hd_cfg.proxy_enable){
+ if (0 == httpd_env->hd_cfg.proxy_enable)
+ {
return;
}
@@ -635,56 +671,64 @@ extern "C"
enum http_tunnel_message_type tmsg_type = http_tunnel_message_type_get((const struct http_tunnel_message *)tmsg);
switch (tmsg_type)
{
- case HTTP_TUNNEL_OPENING:
+ case HTTP_TUNNEL_OPENING:
+ {
+ if (NULL != exdata)
{
- if(NULL != exdata){
- //not support nested http tunnel
- session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
- return;
- }
- size_t payload_len;
- const char *payload = session_get0_current_payload(sess, &payload_len);
- size_t http_identify_len = payload_len > HTTP_IDENTIFY_LEN ? HTTP_IDENTIFY_LEN : payload_len;
- int is_http = http_protocol_identify(payload, http_identify_len);
- if(is_http){
- long long max_req_seq = 0, max_res_seq = 0;
- struct http_decoder_exdata *tcp_stream_exdata = (struct http_decoder_exdata *)session_exdata_get(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_TCP_STREAM_INDEX].exdata_id);
- http_half_get_max_transaction_seq(tcp_stream_exdata, &max_req_seq, &max_res_seq);
- exdata = httpd_session_exdata_new(sess, httpd_env, max_req_seq, max_res_seq);
- session_exdata_set(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].exdata_id, exdata);
- exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
- exdata->in_tunnel_is_http = 1;
- }else{
- //inner tunnel is not http, do nothing, do not push this message again !!!
- session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
- return;
- }
+ // not support nested http tunnel
+ session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
+ return;
}
- break;
+ uint16_t payload_len;
+ const char *payload = session_get0_current_payload(sess, &payload_len);
+ size_t http_identify_len = payload_len > HTTP_IDENTIFY_LEN ? HTTP_IDENTIFY_LEN : payload_len;
+ int is_http = http_protocol_identify(payload, http_identify_len);
+ if (is_http)
+ {
+ long long max_req_seq = 0, max_res_seq = 0;
+ struct http_decoder_exdata *tcp_stream_exdata = (struct http_decoder_exdata *)session_exdata_get(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_TCP_STREAM_INDEX].exdata_id);
+ http_half_get_max_transaction_seq(tcp_stream_exdata, &max_req_seq, &max_res_seq);
+ exdata = httpd_session_exdata_new(sess, httpd_env, max_req_seq, max_res_seq);
+ session_exdata_set(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].exdata_id, exdata);
+ exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
+ exdata->in_tunnel_is_http = 1;
+ }
+ else
+ {
+ // inner tunnel is not http, do nothing, do not push this message again !!!
+ session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
+ return;
+ }
+ }
+ break;
- case HTTP_TUNNEL_ACTIVE:
- if(NULL == exdata){
- session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
- http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
- return;
- }
+ case HTTP_TUNNEL_ACTIVE:
+ if (NULL == exdata)
+ {
+ session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
+ http_decoder_stat_update(&httpd_env->hd_stat, stellar_get_current_thread_index(), HTTPD_STAT_PARSE_ERR, 1);
+ return;
+ }
break;
- case HTTP_TUNNEL_CLOSING:
- if(NULL == exdata){
- http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
- return;
- }
- if(exdata->in_tunnel_is_http){
- http_half_pre_context_free(sess, exdata);
- }
+ case HTTP_TUNNEL_CLOSING:
+ if (NULL == exdata)
+ {
+ http_decoder_stat_update(&httpd_env->hd_stat, stellar_get_current_thread_index(), HTTPD_STAT_PARSE_ERR, 1);
return;
+ }
+ if (exdata->in_tunnel_is_http)
+ {
+ http_half_pre_context_free(sess, exdata);
+ }
+ return;
+ break;
+
+ default:
break;
-
- default:
- break;
}
- if(exdata->in_tunnel_is_http){
+ if (exdata->in_tunnel_is_http)
+ {
http_decoder_execute(sess, httpd_env, exdata);
}
return;
@@ -696,86 +740,67 @@ extern "C"
enum session_state sess_state = session_get_current_state(sess);
struct http_decoder_exdata *exdata = (struct http_decoder_exdata *)session_exdata_get(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_TCP_STREAM_INDEX].exdata_id);
- switch(sess_state){
- case SESSION_STATE_OPENING:
- {
- exdata = httpd_session_exdata_new(sess, httpd_env, 0, 0);
- exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
- session_exdata_set(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_TCP_STREAM_INDEX].exdata_id, exdata);
- //go on
- }
- break;
+ assert (NULL != exdata);
- case SESSION_STATE_ACTIVE:
- if(NULL == exdata){
- session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
- http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
- return;
+ if(SESSION_STATE_CLOSED == sess_state)
+ {
+ if (httpd_in_tunnel_transmitting(exdata))
+ {
+ http_decoder_push_tunnel_data(sess, exdata, HTTP_TUNNEL_CLOSING);
}
- //go on
- break;
-
- case SESSION_STATE_CLOSING:
+ else
{
- if(NULL == exdata){
- http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
- return;
- }
- if(httpd_in_tunnel_transmitting(exdata)){
- http_decoder_push_tunnel_data(sess, exdata, HTTP_TUNNEL_CLOSING);
- }else{
- http_half_pre_context_free(sess, exdata);
- }
- return;
+ http_half_pre_context_free(sess, exdata);
}
- break;
-
- default:
- return;
- break;
+ return;
}
http_decoder_execute(sess, httpd_env, exdata);
-
+
return;
}
-static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC_INDEX_MAX] =
-{
- {HTTPD_TOPIC_TCP_STREAM_INDEX, TOPIC_TCP_STREAM, http_decoder_tcp_stream_msg_cb, NULL, "HTTP_DECODER_EXDATA_BASEON_TCP_STREAM", httpd_ex_data_free_cb, -1, -1},
- {HTTPD_TOPIC_HTTP_MSG_INDEX, HTTP_DECODER_TOPIC, NULL, http_message_free, NULL, NULL, -1, -1},
- {HTTPD_TOPIC_HTTP_TUNNEL_INDEX, HTTP_DECODER_TUNNEL_TOPIC, http_decoder_tunnel_msg_cb, http_message_free, "HTTP_DECODER_EXDATA_BASEON_HTTP_TUNNEL", httpd_ex_data_free_cb, -1, -1},
-};
+ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC_INDEX_MAX] =
+ {
+ {HTTPD_TOPIC_TCP_STREAM_INDEX, TOPIC_TCP_STREAM, http_decoder_tcp_stream_msg_cb, NULL, "HTTP_DECODER_EXDATA_BASEON_TCP_STREAM", httpd_ex_data_free_cb, -1, -1},
+ {HTTPD_TOPIC_HTTP_MSG_INDEX, HTTP_DECODER_TOPIC, NULL, http_message_free, NULL, NULL, -1, -1},
+ {HTTPD_TOPIC_HTTP_TUNNEL_INDEX, HTTP_DECODER_TUNNEL_TOPIC, http_decoder_tunnel_msg_cb, http_message_free, "HTTP_DECODER_EXDATA_BASEON_HTTP_TUNNEL", httpd_ex_data_free_cb, -1, -1},
+ };
static void http_decoder_topic_exdata_compose_init(struct http_decoder_env *httpd_env)
{
memcpy(httpd_env->topic_exdata_compose, g_topic_exdata_compose, sizeof(g_topic_exdata_compose));
- for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
- httpd_env->topic_exdata_compose[i].sub_topic_id = stellar_session_mq_get_topic_id_reliable(httpd_env->st,
- httpd_env->topic_exdata_compose[i].topic_name,
- httpd_env->topic_exdata_compose[i].msg_free_cb,
- NULL);
+ for (int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++)
+ {
+ httpd_env->topic_exdata_compose[i].sub_topic_id = stellar_session_mq_get_topic_id_reliable(httpd_env->st,
+ httpd_env->topic_exdata_compose[i].topic_name,
+ httpd_env->topic_exdata_compose[i].msg_free_cb,
+ NULL);
assert(httpd_env->topic_exdata_compose[i].sub_topic_id >= 0);
- if(httpd_env->topic_exdata_compose[i].exdata_name){
- httpd_env->topic_exdata_compose[i].exdata_id = stellar_session_exdata_new_index(httpd_env->st,
- httpd_env->topic_exdata_compose[i].exdata_name,
- httpd_env->topic_exdata_compose[i].exdata_free_cb,
- NULL);
+ if (httpd_env->topic_exdata_compose[i].exdata_name)
+ {
+ httpd_env->topic_exdata_compose[i].exdata_id = stellar_exdata_new_index(httpd_env->st,
+ httpd_env->topic_exdata_compose[i].exdata_name,
+ httpd_env->topic_exdata_compose[i].exdata_free_cb,
+ NULL);
assert(httpd_env->topic_exdata_compose[i].exdata_id >= 0);
}
- if(httpd_env->topic_exdata_compose[i].on_msg_cb){
- stellar_session_mq_subscribe(httpd_env->st, httpd_env->topic_exdata_compose[i].sub_topic_id,
- httpd_env->topic_exdata_compose[i].on_msg_cb, httpd_env->plugin_id);
+ if (httpd_env->topic_exdata_compose[i].on_msg_cb)
+ {
+ stellar_session_mq_subscribe(httpd_env->st, httpd_env->topic_exdata_compose[i].sub_topic_id,
+ httpd_env->topic_exdata_compose[i].on_msg_cb, httpd_env->plugin_id);
}
}
}
int http_topic_exdata_compose_get_index(const struct http_decoder_env *httpd_env, int by_topic_id)
{
- for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
- if(httpd_env->topic_exdata_compose[i].sub_topic_id == by_topic_id){
+ for (int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++)
+ {
+ if (httpd_env->topic_exdata_compose[i].sub_topic_id == by_topic_id)
+ {
return i;
}
}
@@ -804,12 +829,12 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
thread_num = stellar_get_worker_thread_num(st);
assert(thread_num >= 1);
- if (http_decoder_stat_init( &httpd_env->hd_stat, thread_num,
- httpd_env->hd_cfg.stat_interval_pkts, httpd_env->hd_cfg.stat_output_interval) < 0)
+ if (http_decoder_stat_init(&httpd_env->hd_stat, thread_num,
+ httpd_env->hd_cfg.stat_interval_pkts, httpd_env->hd_cfg.stat_output_interval) < 0)
{
goto failed;
}
-
+
return httpd_env;
failed:
@@ -838,11 +863,12 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
}
void http_message_request_line_get0(const struct http_message *msg,
- struct http_request_line *line)
+ struct http_request_line *line)
{
if (unlikely(NULL == msg || msg->type != HTTP_MESSAGE_REQ_LINE))
{
- if(line){
+ if (line)
+ {
line->method.iov_base = NULL;
line->uri.iov_base = NULL;
line->version.iov_base = NULL;
@@ -859,11 +885,12 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
}
void http_message_response_line_get0(const struct http_message *msg,
- struct http_response_line *line)
+ struct http_response_line *line)
{
if (unlikely(NULL == msg || msg->type != HTTP_MESSAGE_RES_LINE))
{
- if(line){
+ if (line)
+ {
line->version.iov_base = NULL;
line->status.iov_base = NULL;
}
@@ -879,7 +906,7 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
}
void http_message_header_get0(const struct http_message *msg, const hstring *key,
- struct http_header *hdr_result)
+ struct http_header *hdr_result)
{
int ret = -1;
if (unlikely(NULL == msg || NULL == key))
@@ -896,11 +923,13 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
{
ret = http_msg_get_response_header(msg, key, hdr_result);
}
- if(ret >= 0){
+ if (ret >= 0)
+ {
return;
}
fail:
- if(hdr_result){
+ if (hdr_result)
+ {
hdr_result->key.iov_base = NULL;
hdr_result->val.iov_base = NULL;
}
@@ -910,7 +939,7 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
int http_message_header_next(const struct http_message *msg,
struct http_header *header)
{
- int ret =1;
+ int ret = 1;
if (unlikely(NULL == msg))
{
goto fail;
@@ -925,12 +954,14 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
{
ret = http_msg_response_header_next(msg, header);
}
- if(ret < 0){
+ if (ret < 0)
+ {
goto fail;
}
return 0;
fail:
- if(header){
+ if (header)
+ {
header->key.iov_base = NULL;
header->val.iov_base = NULL;
}
@@ -961,7 +992,7 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
}
void http_message_raw_body_get0(const struct http_message *msg,
- hstring *body)
+ hstring *body)
{
int ret = -1;
if (unlikely(NULL == msg))
@@ -978,12 +1009,14 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
{
ret = http_msg_get_response_raw_body(msg, body);
}
- if(ret < 0){
+ if (ret < 0)
+ {
goto fail;
}
return;
fail:
- if(body){
+ if (body)
+ {
body->iov_base = NULL;
body->iov_len = 0;
}
@@ -991,7 +1024,7 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
}
void http_message_decompress_body_get0(const struct http_message *msg,
- hstring *body)
+ hstring *body)
{
int ret = -1;
if (unlikely(NULL == msg))
@@ -1008,23 +1041,26 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
{
ret = http_msg_get_response_decompress_body(msg, body);
}
- if(ret < 0){
+ if (ret < 0)
+ {
goto fail;
}
return;
fail:
- if(body){
+ if (body)
+ {
body->iov_base = NULL;
body->iov_len = 0;
}
- return;
+ return;
}
void http_message_raw_url_get0(const struct http_message *msg, hstring *url)
{
if (unlikely(NULL == msg))
{
- if(url){
+ if (url)
+ {
url->iov_base = NULL;
url->iov_len = 0;
}
@@ -1036,24 +1072,27 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
struct http_decoder_half_data *req_data =
msg->ref_queue->array[msg->queue_index].req_data;
- if(http_half_data_get_url(req_data, url) < 0){
+ if (http_half_data_get_url(req_data, url) < 0)
+ {
goto fail;
}
return;
fail:
- if(url){
+ if (url)
+ {
url->iov_base = NULL;
url->iov_len = 0;
}
- return;
+ return;
}
void http_message_decoded_url_get0(const struct http_message *msg, struct iovec *url)
{
if (unlikely(NULL == msg))
{
- if(url){
+ if (url)
+ {
url->iov_base = NULL;
url->iov_len = 0;
}
@@ -1065,17 +1104,19 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
struct http_decoder_half_data *req_data =
msg->ref_queue->array[msg->queue_index].req_data;
- if(http_half_data_get_decode_url(req_data, url) < 0){
+ if (http_half_data_get_decode_url(req_data, url) < 0)
+ {
goto fail;
}
return;
fail:
- if(url){
+ if (url)
+ {
url->iov_base = NULL;
url->iov_len = 0;
}
- return;
+ return;
}
int http_message_get_transaction_seq(const struct http_message *msg)
@@ -1087,7 +1128,7 @@ static const struct http_topic_exdata_compose g_topic_exdata_compose[HTTPD_TOPIC
assert(msg->ref_queue);
assert(msg->queue_index < HD_RESULT_QUEUE_LEN);
struct http_decoder_half_data *hf_data = NULL;
- if(HTTP_REQUEST == msg->flow_type)
+ if (HTTP_REQUEST == msg->flow_type)
{
hf_data = msg->ref_queue->array[msg->queue_index].req_data;
}
diff --git a/src/http_decoder_half.cpp b/src/http_decoder_half.cpp
index 67fdb02..a522ba6 100644
--- a/src/http_decoder_half.cpp
+++ b/src/http_decoder_half.cpp
@@ -915,6 +915,7 @@ void http_decoder_half_data_dump(struct http_decoder_half *half)
static void using_session_addr_as_host(struct session *ref_session,
struct http_header *host_result, nmx_pool_t *mempool)
{
+#if 0 //todo, in native steallar, can't get the tuple4 from the session yet!!!
const struct session_addr *ssaddr;
enum session_addr_type ssaddr_type;
ssaddr = session_get0_addr(ref_session, &ssaddr_type);
@@ -942,6 +943,11 @@ static void using_session_addr_as_host(struct session *ref_session,
{
assert(0);
}
+#else
+ host_result->val.iov_base = MEMPOOL_CALLOC(mempool, char, 32);
+ sprintf((char *)host_result->val.iov_base, "%s", "todo:get_tuple4");
+ host_result->val.iov_len = strlen((char *)host_result->val.iov_base);
+#endif
}
void http_decoder_join_url(struct http_decoder_half_data *hfdata, nmx_pool_t *mempool, const struct http_header *host_hdr)
diff --git a/src/http_decoder_inc.h b/src/http_decoder_inc.h
index aa213c3..3f5247a 100644
--- a/src/http_decoder_inc.h
+++ b/src/http_decoder_inc.h
@@ -20,8 +20,8 @@ extern "C"
#include "stellar/stellar.h"
#include "stellar/utils.h"
#include "stellar/session.h"
-#include "stellar/session_mq.h"
-#include "stellar/session_exdata.h"
+#include "stellar/stellar_mq.h"
+#include "stellar/stellar_exdata.h"
#include "mempool/nmx_palloc.h"
#include "stellar/utils.h"
@@ -124,9 +124,9 @@ struct http_topic_exdata_compose{
enum httpd_topic_index index;
const char *topic_name;
on_session_msg_cb_func *on_msg_cb;
- session_msg_free_cb_func *msg_free_cb;
+ stellar_msg_free_cb_func *msg_free_cb;
const char *exdata_name;
- session_exdata_free *exdata_free_cb;
+ stellar_exdata_free *exdata_free_cb;
int sub_topic_id; //as consumer
int exdata_id;
};
diff --git a/src/http_decoder_tunnel.cpp b/src/http_decoder_tunnel.cpp
index 9cf477d..6f23195 100644
--- a/src/http_decoder_tunnel.cpp
+++ b/src/http_decoder_tunnel.cpp
@@ -19,7 +19,7 @@ int httpd_tunnel_identify(struct http_decoder_env *httpd_env, int curdir, struct
return 0;
}
- if(PACKET_DIRECTION_C2S == curdir){
+ if(FLOW_DIRECTION_C2S == curdir){
struct http_request_line reqline = {};
http_decoder_half_data_get_request_line(hfdata, &reqline);
if(0 == strncasecmp_safe("CONNECT", (char *)reqline.method.iov_base,
@@ -71,7 +71,7 @@ void http_decoder_push_tunnel_data(struct session *sess, const struct http_decod
{
struct http_tunnel_message *tmsg = (struct http_tunnel_message *)CALLOC(struct http_tunnel_message, 1);
tmsg->type = type;
- size_t payload_len;
+ uint16_t payload_len;
const char *payload = session_get0_current_payload(sess, &payload_len);
tmsg->tunnel_payload.iov_base = (char *)payload;
tmsg->tunnel_payload.iov_len = payload_len;
diff --git a/src/http_decoder_utils.cpp b/src/http_decoder_utils.cpp
index b2af0fc..55aba66 100644
--- a/src/http_decoder_utils.cpp
+++ b/src/http_decoder_utils.cpp
@@ -106,8 +106,8 @@ int http_message_type_is_req(struct session *sess, enum http_message_type msg_ty
case HTTP_TRANSACTION_START:
case HTTP_TRANSACTION_END:
{
- int cur_dir = packet_get_direction(session_get0_current_packet(sess));
- if(PACKET_DIRECTION_C2S == cur_dir){
+ enum flow_direction cur_dir = session_get_current_flow_direction(sess);
+ if(FLOW_DIRECTION_C2S == cur_dir){
is_req_msg = 1;
}else{
is_req_msg = 0;
@@ -156,11 +156,11 @@ int http_event_is_req(enum http_event event)
return -1;
}
-int stellar_session_mq_get_topic_id_reliable(struct stellar *st, const char *topic_name, session_msg_free_cb_func *msg_free_cb, void *msg_free_arg)
+int stellar_session_mq_get_topic_id_reliable(struct stellar *st, const char *topic_name, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg)
{
- int topic_id = stellar_session_mq_get_topic_id(st, topic_name);
+ int topic_id = stellar_mq_get_topic_id(st, topic_name);
if(topic_id < 0){
- topic_id = stellar_session_mq_create_topic(st, topic_name, msg_free_cb, msg_free_arg);
+ topic_id = stellar_mq_create_topic(st, topic_name, msg_free_cb, msg_free_arg);
}
return topic_id;
}
diff --git a/src/http_decoder_utils.h b/src/http_decoder_utils.h
index b3df52d..e500a60 100644
--- a/src/http_decoder_utils.h
+++ b/src/http_decoder_utils.h
@@ -11,8 +11,8 @@ extern "C"
#include "stellar/stellar.h"
#include "stellar/utils.h"
#include "stellar/session.h"
-#include "stellar/session_mq.h"
-#include "stellar/session_exdata.h"
+#include "stellar/stellar_mq.h"
+#include "stellar/stellar_exdata.h"
#ifdef __cplusplus
}
#endif
@@ -22,7 +22,7 @@ int strncasecmp_safe(const char *fix_s1, const char *dyn_s2, size_t fix_n1, size
const char *http_message_type_to_string(enum http_message_type type);
int http_message_type_is_req(struct session *sess, enum http_message_type msg_type);
int http_event_is_req(enum http_event event);
-int stellar_session_mq_get_topic_id_reliable(struct stellar *st, const char *topic_name, session_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
+int stellar_session_mq_get_topic_id_reliable(struct stellar *st, const char *topic_name, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
void httpd_url_decode(const char *string, size_t length, char *ostring, size_t *olen);
int httpd_url_is_encoded(const char *url, size_t len);
/******************************************************************************
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d41aac2..98d06d3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -16,6 +16,7 @@ set(TEST_RUN_DIR /home/mesasoft/sapp_run)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/deps)
+include_directories(/opt/tsg/stellar/include/)
include_directories(/opt/tsg/framework/include/)
include_directories(/opt/MESA/include/MESA)
include_directories(${CMAKE_BINARY_DIR}/vendor/vbuild/include)
@@ -25,9 +26,8 @@ aux_source_directory(${PROJECT_SOURCE_DIR}/deps/mempool PERF_TEST_DEP_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/deps/toml PERF_TEST_DEP_SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/src PERF_TEST_DEP_SRC)
-add_executable(httpd_perf_test ${PERF_TEST_DEP_SRC} http_decoder_perf_main.cpp http_decoder_perf_plug.cpp http_stellar_mock.cpp)
-target_link_libraries(httpd_perf_test z brotlidec llhttp-static fieldstat4 pthread)
-
+# add_executable(httpd_perf_test ${PERF_TEST_DEP_SRC} http_decoder_perf_main.cpp http_decoder_perf_plug.cpp http_stellar_mock.cpp)
+# target_link_libraries(httpd_perf_test z brotlidec llhttp-static fieldstat4 pthread)
add_executable(httpd_gtest http_decoder_gtest.cpp http_stellar_mock.cpp ${PROJECT_SOURCE_DIR}/src/http_decoder_utils.cpp)
-target_link_libraries(httpd_gtest gtest)
+target_link_libraries(httpd_gtest gtest stellar_devel)
diff --git a/test/http_decoder_gtest.h b/test/http_decoder_gtest.h
index d620972..7ce8b0d 100644
--- a/test/http_decoder_gtest.h
+++ b/test/http_decoder_gtest.h
@@ -4,8 +4,8 @@ extern "C"
{
#endif
#include <stellar/session.h>
-#include <stellar/session_mq.h>
-#include <stellar/session_exdata.h>
+#include <stellar/stellar_mq.h>
+#include <stellar/stellar_exdata.h>
#include <stellar/stellar.h>
#ifdef __cplusplus
}
diff --git a/test/http_decoder_perf_main.cpp b/test/http_decoder_perf_main.cpp
index c567d5a..7d314e9 100644
--- a/test/http_decoder_perf_main.cpp
+++ b/test/http_decoder_perf_main.cpp
@@ -3,8 +3,8 @@ extern "C"
{
#endif
#include <stellar/session.h>
-#include <stellar/session_mq.h>
-#include <stellar/session_exdata.h>
+#include <stellar/stellar_mq.h>
+#include <stellar/stellar_exdata.h>
#include <stellar/stellar.h>
#ifdef __cplusplus
}
@@ -87,14 +87,14 @@ static void init_test_data_simple(struct test_packet *test_payload, int *index)
{
int tmp_index = 0;
const char *c2s_payload = strdup("GET / HTTP/1.1\r\nHost: www.simple.com\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: zh-CN,zh;q=0.9\r\n\r\n");
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], c2s_payload, PACKET_DIRECTION_C2S, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], c2s_payload, FLOW_DIRECTION_C2S , tmp_index);
const char *content = "Hello, http decoder perf test simple!!!";
int content_length = strlen(content);
char *s2c_payload = (char *)malloc(1024);
snprintf(s2c_payload, 1024, "HTTP/1.1 200 OK\r\nServer: Apache-Coyote/1.1\r\nConnection: keep-alive\r\nDate: Sat, 01 May 2024 01:36:57 GMT\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Length: %d\r\n\r\n%s", content_length, content);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], s2c_payload, PACKET_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], s2c_payload, FLOW_DIRECTION_S2C, tmp_index);
*index = tmp_index;
}
@@ -102,32 +102,32 @@ static void init_test_data_frag(struct test_packet *test_payload, int *index)
{
int tmp_index = 0;
/* c2s */
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("GET / HTTP/1.1\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Host: www.fragment.com\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Cache-Control: max-age=0\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Connection: keep-alive\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Referer: http://fragment.com/register.jsp?redirect:http://aa.bb.cc.dd.com/?\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Cookie: JSESSIONID=385C79E211D561C0CA13D90F150F603D34875GH87FSHG8S7RTHG74875GHS8R7THG87SRTH\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Accept: */*\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Accept-Encoding: gzip, deflate\r\n"), PACKET_DIRECTION_C2S, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("\r\n"), PACKET_DIRECTION_C2S, tmp_index); //header EOF
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("GET / HTTP/1.1\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Host: www.fragment.com\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Cache-Control: max-age=0\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Connection: keep-alive\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Referer: http://fragment.com/register.jsp?redirect:http://aa.bb.cc.dd.com/?\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Cookie: JSESSIONID=385C79E211D561C0CA13D90F150F603D34875GH87FSHG8S7RTHG74875GHS8R7THG87SRTH\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Accept: */*\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Accept-Encoding: gzip, deflate\r\n"), FLOW_DIRECTION_C2S , tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("\r\n"), FLOW_DIRECTION_C2S , tmp_index); //header EOF
/* s2c */
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("HTTP/1.1 200 OK\r\n"), PACKET_DIRECTION_S2C, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Server: Apache-Coyote/1.1\r\n"), PACKET_DIRECTION_S2C, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Connection: keep-alive\r\n"), PACKET_DIRECTION_S2C, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Content-Type: text/html;charset=UTF-8\r\n"), PACKET_DIRECTION_S2C, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Date: Sat, 01 May 2024 01:36:57 GMT\r\n"), PACKET_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("HTTP/1.1 200 OK\r\n"), FLOW_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Server: Apache-Coyote/1.1\r\n"), FLOW_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Connection: keep-alive\r\n"), FLOW_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Content-Type: text/html;charset=UTF-8\r\n"), FLOW_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("Date: Sat, 01 May 2024 01:36:57 GMT\r\n"), FLOW_DIRECTION_S2C, tmp_index);
char *cont_len_buf = (char *)malloc(1024);
const char *s2c_payload = strdup("Hello, http decoder perf test fragment!!!");
int content_length = strlen(s2c_payload);
snprintf(cont_len_buf, 1024, "Content-Length: %d\r\n", content_length);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], cont_len_buf, PACKET_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], cont_len_buf, FLOW_DIRECTION_S2C, tmp_index);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("\r\n"), PACKET_DIRECTION_S2C, tmp_index); //header EOF
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], s2c_payload, PACKET_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], strdup("\r\n"), FLOW_DIRECTION_S2C, tmp_index); //header EOF
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], s2c_payload, FLOW_DIRECTION_S2C, tmp_index);
*index = tmp_index;
}
@@ -143,22 +143,22 @@ static void init_test_data_long_long_url(struct test_packet *test_payload, int *
/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/\
/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/\
/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/");
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], request_line_frag1, PACKET_DIRECTION_C2S, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], request_line_frag1, FLOW_DIRECTION_C2S , tmp_index);
const char *request_line_frag2 = strdup("long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/\
/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/\
/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long.index.html HTTP/1.1\r\n");
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], request_line_frag2, PACKET_DIRECTION_C2S, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], request_line_frag2, FLOW_DIRECTION_C2S , tmp_index);
const char *request_line_frag3 = strdup("Host: www.long-long-url.com\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: zh-CN,zh;q=0.9\r\n\r\n");
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], request_line_frag3, PACKET_DIRECTION_C2S, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], request_line_frag3, FLOW_DIRECTION_C2S , tmp_index);
const char *content = "Hello, http decoder perf test long long url!!!";
int content_length = strlen(content);
char *s2c_payload = (char *)malloc(1024);
snprintf(s2c_payload, 1024, "HTTP/1.1 200 OK\r\nServer: Apache-Coyote/1.1\r\nConnection: keep-alive\r\nDate: Sat, 01 May 2024 01:36:57 GMT\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Length: %d\r\n\r\n%s", content_length, content);
- SET_DATA_LENGTH_DIR(test_payload[tmp_index], s2c_payload, PACKET_DIRECTION_S2C, tmp_index);
+ SET_DATA_LENGTH_DIR(test_payload[tmp_index], s2c_payload, FLOW_DIRECTION_S2C, tmp_index);
*index = tmp_index;
}
@@ -192,7 +192,7 @@ int main(int argc, char const *argv[])
struct stellar *st = stellar_init();
- int tcp_stream_topic_id = stellar_session_mq_get_topic_id(st, TOPIC_TCP_STREAM);
+ int tcp_stream_topic_id = stellar_mq_get_topic_id(st, TOPIC_TCP_STREAM);
if(stellar_load_plugin(st, http_decoder_init) < 0){
fprintf(stderr, "load plugin 'http_decoder_init' failed\n");
diff --git a/test/http_decoder_perf_plug.cpp b/test/http_decoder_perf_plug.cpp
index 3a3d14a..739e70f 100644
--- a/test/http_decoder_perf_plug.cpp
+++ b/test/http_decoder_perf_plug.cpp
@@ -103,7 +103,7 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
static on_session_msg_cb_func*g_entry_fun = &http_decoder_perf_entry;
-static void http_decoder_test_exdata_free(struct session *sess, int idx, void *ex_ptr, void *arg)
+static void http_decoder_test_exdata_free(int idx, void *ex_ptr, void *arg)
{
return;
}
@@ -111,7 +111,7 @@ static void http_decoder_test_exdata_free(struct session *sess, int idx, void *e
extern "C" void *http_decoder_perf_plug_init(struct stellar *st)
{
g_plugin_id = stellar_session_plugin_register(st, NULL, NULL, NULL);
- g_exdata_idx = stellar_session_exdata_new_index(st, "HTTP_DECODER_REQ_TEST",
+ g_exdata_idx = stellar_exdata_new_index(st, "HTTP_DECODER_REQ_TEST",
http_decoder_test_exdata_free,
NULL);
if (g_exdata_idx < 0)
@@ -120,7 +120,7 @@ extern "C" void *http_decoder_perf_plug_init(struct stellar *st)
exit(-1);
}
- g_topic_id = stellar_session_mq_get_topic_id(st, "HTTP_DECODER_MESSAGE");
+ g_topic_id = stellar_mq_get_topic_id(st, "HTTP_DECODER_MESSAGE");
if (g_topic_id < 0)
{
printf("[%s:%d]: can't get http_decoder topic id !!!\n", __FUNCTION__, __LINE__);
diff --git a/test/http_decoder_test_plug.cpp b/test/http_decoder_test_plug.cpp
index 1ae9e51..50206a3 100644
--- a/test/http_decoder_test_plug.cpp
+++ b/test/http_decoder_test_plug.cpp
@@ -240,7 +240,7 @@ void http_url_add_to_json(cJSON *ctx, struct http_message *msg)
}
// Full duplex
-static void commit_last_half_flow_data(struct session *sess, struct gtest_plug_exdata_t *gtest_plug_exdata,
+static void commit_last_half_flow_data(struct gtest_plug_exdata_t *gtest_plug_exdata,
struct http_message *msg, enum http_transaction_type type, int final)
{
char result_name[MAX_KEY_STR_LEN] = {0};
@@ -393,7 +393,7 @@ extern "C" void http_decoder_test_entry(struct session *sess, int topic_id, cons
switch (msg_type)
{
case HTTP_MESSAGE_REQ_LINE:
- commit_last_half_flow_data(sess, gtest_plug_exdata, msg, HTTP_TRANSACTION_REQ, 0);
+ commit_last_half_flow_data(gtest_plug_exdata, msg, HTTP_TRANSACTION_REQ, 0);
http_message_request_line_get0(msg, &req_line);
req_line_to_json(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_REQ], &req_line);
break;
@@ -416,7 +416,7 @@ extern "C" void http_decoder_test_entry(struct session *sess, int topic_id, cons
append_http_payload(sess, gtest_plug_exdata, &body, HTTP_TRANSACTION_REQ);
break;
case HTTP_MESSAGE_RES_LINE:
- commit_last_half_flow_data(sess, gtest_plug_exdata, msg, HTTP_TRANSACTION_RES, 0);
+ commit_last_half_flow_data(gtest_plug_exdata, msg, HTTP_TRANSACTION_RES, 0);
http_message_response_line_get0(msg, &res_line);
res_line_to_json(gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_RES], &res_line);
break;
@@ -444,18 +444,18 @@ extern "C" void http_decoder_test_entry(struct session *sess, int topic_id, cons
return;
}
-void http_decoder_test_exdata_free(struct session *sess, int idx, void *ex_ptr, void *arg)
+void http_decoder_test_exdata_free(int idx, void *ex_ptr, void *arg)
{
if (ex_ptr != NULL)
{
struct gtest_plug_exdata_t *gtest_plug_exdata = (struct gtest_plug_exdata_t *)ex_ptr;
if (gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_REQ])
{
- commit_last_half_flow_data(sess, gtest_plug_exdata, NULL, HTTP_TRANSACTION_REQ, 1);
+ commit_last_half_flow_data(gtest_plug_exdata, NULL, HTTP_TRANSACTION_REQ, 1);
}
if (gtest_plug_exdata->result_jnode[HTTP_TRANSACTION_RES])
{
- commit_last_half_flow_data(sess, gtest_plug_exdata, NULL, HTTP_TRANSACTION_RES, 1);
+ commit_last_half_flow_data(gtest_plug_exdata, NULL, HTTP_TRANSACTION_RES, 1);
}
free(ex_ptr);
}
@@ -543,10 +543,10 @@ extern "C" void http_decoder_tunnel_entry(struct session *sess, int topic_id, co
case HTTP_TUNNEL_ACTIVE:
{
- int curdir = packet_get_direction(session_get0_current_packet(sess));
+ enum flow_direction curdir = session_get_current_flow_direction(sess);
hstring tunnel_payload = {};
http_tunnel_message_get_payload((const struct http_tunnel_message *)raw_msg, &tunnel_payload);
- if(PACKET_DIRECTION_C2S == curdir){
+ if(FLOW_DIRECTION_C2S == curdir){
req_payload_block++;
req_payload_size += tunnel_payload.iov_len;
}else{
@@ -574,7 +574,7 @@ extern "C" void http_decoder_tunnel_entry(struct session *sess, int topic_id, co
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_GTEST_EXDATA",http_decoder_test_exdata_free, NULL);
+ g_exdata_idx = stellar_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__);
@@ -585,7 +585,7 @@ extern "C" void *http_decoder_test_init(struct stellar *st)
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);
+ g_topic_id = stellar_mq_get_topic_id(st, topic_name);
if (g_topic_id < 0)
{
printf("[%s:%d]: can't get http_decoder topic:%s id !!!\n", __FUNCTION__, __LINE__, topic_name);
diff --git a/test/http_stellar_mock.cpp b/test/http_stellar_mock.cpp
index b0897d6..4769613 100644
--- a/test/http_stellar_mock.cpp
+++ b/test/http_stellar_mock.cpp
@@ -8,26 +8,26 @@ static struct stellar *G_STELLAR;
static struct plugin_mgr *g_plugin_mgr_list_head = NULL;
static struct stellar *g_st;
-static void stellar_internal_msg_free_cb_func(struct session *sess, void *msg, void *msg_free_arg) {/* do nothing*/}
+static void stellar_internal_msg_free_cb_func(void *msg, void *msg_free_arg) {/* do nothing*/}
static void stellar_register_internal_topic(struct stellar *st)
{
- G_TCP_STREAM_TOPIC_ID = stellar_session_mq_get_topic_id(st, TOPIC_TCP_STREAM);
+ G_TCP_STREAM_TOPIC_ID = stellar_mq_get_topic_id(st, TOPIC_TCP_STREAM);
if(G_TCP_STREAM_TOPIC_ID < 0){
- G_TCP_STREAM_TOPIC_ID = stellar_session_mq_create_topic(st, TOPIC_TCP_STREAM, stellar_internal_msg_free_cb_func, NULL);
+ G_TCP_STREAM_TOPIC_ID = stellar_mq_create_topic(st, TOPIC_TCP_STREAM, stellar_internal_msg_free_cb_func, NULL);
}
- G_UDP_TOPIC_ID = stellar_session_mq_get_topic_id(st, TOPIC_UDP);
+ G_UDP_TOPIC_ID = stellar_mq_get_topic_id(st, TOPIC_UDP);
if(G_UDP_TOPIC_ID < 0){
- G_UDP_TOPIC_ID = stellar_session_mq_create_topic(st, TOPIC_UDP, stellar_internal_msg_free_cb_func, NULL);
+ G_UDP_TOPIC_ID = stellar_mq_create_topic(st, TOPIC_UDP, stellar_internal_msg_free_cb_func, NULL);
}
}
void stellar_session_plugin_dettach_current_session(struct session *sess) { return; }
-int stellar_session_mq_destroy_topic(struct stellar *st, int topic_id) { return 0; }
+int stellar_mq_destroy_topic(struct stellar *st, int topic_id) { return 0; }
int stellar_get_worker_thread_num(struct stellar *st) { return 1; }
-int stellar_get_current_thread_id(struct stellar *st) { return 0; }
-int session_get_current_thread_id(struct session *sess) { return 0; }
+uint16_t stellar_get_current_thread_index(void) { return 0; }
+int stellar_get_current_thread_index(struct session *sess) { return 0; }
int session_mq_ignore_message(struct session *sess, int topic_id, int plugin_id) { return 0; }
int session_mq_unignore_message(struct session *sess, int topic_id, int plugin_id) { return 0; }
-int stellar_session_exdata_new_index(struct stellar *st, const char *name, session_exdata_free *free_func,void *arg)
+int stellar_session_exdata_new_index(struct stellar *st, const char *name, stellar_exdata_free *free_func,void *arg)
{
int list_count = 0;
struct exdata_mgr *tmp, *new_exdata = (struct exdata_mgr *)calloc(1, sizeof(struct exdata_mgr));
@@ -73,7 +73,7 @@ enum session_state session_get_current_state(struct session *sess)
{
return sess->sess_state;
}
-const char *session_get0_current_payload(struct session *sess, size_t *payload_len)
+const char *session_get0_current_payload(struct session *sess, uint16_t *payload_len)
{
const struct packet *test_payload = &sess->pkt;
*payload_len = test_payload->payload_len;
@@ -84,10 +84,7 @@ struct session_addr *session_get0_addr(struct session *sess, enum session_addr_t
*addr_type = SESSION_ADDR_TYPE_IPV4_TCP;
return &sess->addr;
}
-int packet_get_direction(const struct packet *pkt)
-{
- return pkt->dir;
-}
+
const struct packet *session_get0_current_packet(struct session *sess)
{
return &sess->pkt;
@@ -126,7 +123,7 @@ int stellar_session_mq_subscribe(struct stellar *st, int topic_id, on_session_ms
DL_APPEND(topic_el->sub_free_cb_list_head, sub_cb_list);
return 0;
}
-int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name)
+int stellar_mq_get_topic_id(struct stellar *st, const char *topic_name)
{
struct topic_mgr *el = NULL;
DL_FOREACH(st->topic_mgr_head, el){
@@ -136,9 +133,9 @@ int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name)
}
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)
+int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg)
{
- int topic_id = stellar_session_mq_get_topic_id(st, topic_name);
+ int topic_id = stellar_mq_get_topic_id(st, topic_name);
if(topic_id >= 0){
return topic_id;//already exist
}
@@ -181,7 +178,7 @@ int session_mq_publish_message(struct session *sess, int topic_id, void *msg)
DL_FOREACH(el->sub_free_cb_list_head, sub_cb_node){
(*sub_cb_node->sub_cb)(sess, topic_id, msg, NULL, sub_cb_node->plugin_env); //todo
}
- el->pub_free_cb(sess, msg, el->pub_free_arg);
+ el->pub_free_cb(msg, el->pub_free_arg);
return 0;
}
int stellar_load_plugin(struct stellar *st, void *(plugin_init_cb)(struct stellar *st))
@@ -225,7 +222,7 @@ static void session_plugin_exdata_free(struct stellar *st, struct session *sess,
struct exdata_mgr *el = NULL;
DL_FOREACH(st->exdata_mgr_head, el){
if(el->exdata_id == exdata_idx){
- el->free_func(sess, exdata_idx, user_ptr, el->arg);
+ el->free_func(exdata_idx, user_ptr, el->arg);
}
}
}
diff --git a/test/http_stellar_mock.h b/test/http_stellar_mock.h
index d3c2dc5..8192a98 100644
--- a/test/http_stellar_mock.h
+++ b/test/http_stellar_mock.h
@@ -10,8 +10,8 @@ extern "C"
{
#endif
#include <stellar/session.h>
-#include <stellar/session_mq.h>
-#include <stellar/session_exdata.h>
+#include <stellar/stellar_mq.h>
+#include <stellar/stellar_exdata.h>
#include <stellar/stellar.h>
#ifdef __cplusplus
}
@@ -20,7 +20,7 @@ extern "C"
struct packet{
const char *payload;
size_t payload_len;
- u_int8_t dir; //PACKET_DIRECTION_C2S PACKET_DIRECTION_S2C
+ u_int8_t dir; //FLOW_DIRECTION_C2S FLOW_DIRECTION_S2C
};
typedef struct packet stellar_message;
struct exdata_mgr{
@@ -28,7 +28,7 @@ struct exdata_mgr{
int exdata_id;
void *arg;
void *user_ptr;
- session_exdata_free *free_func;
+ stellar_exdata_free *free_func;
struct exdata_mgr *next, *prev;
};
struct sub_topic_mgr{
@@ -40,7 +40,7 @@ struct topic_mgr{
struct topic_mgr *next, *prev;
const char *topic_name;
int topic_id;
- session_msg_free_cb_func *pub_free_cb;
+ stellar_msg_free_cb_func *pub_free_cb;
void *pub_free_arg;
struct sub_topic_cb_list *sub_free_cb_list_head;
};
@@ -48,6 +48,46 @@ struct stellar{
struct topic_mgr *topic_mgr_head;
struct exdata_mgr *exdata_mgr_head;
};
+
+//todo, native stellar can't get addr
+enum session_addr_type
+{
+ SESSION_ADDR_TYPE_IPV4_TCP,
+ SESSION_ADDR_TYPE_IPV4_UDP,
+ SESSION_ADDR_TYPE_IPV6_TCP,
+ SESSION_ADDR_TYPE_IPV6_UDP,
+ SESSION_ADDR_TYPE_UNKNOWN,
+ __SESSION_ADDR_TYPE_MAX,
+};
+struct session_addr_ipv4{
+ uint32_t saddr; /* network order */
+ uint32_t daddr; /* network order */
+ uint16_t sport; /* network order */
+ uint16_t dport; /* network order */
+};
+
+#include <netinet/in.h>
+#ifndef IPV6_ADDR_LEN
+#define IPV6_ADDR_LEN (sizeof(struct in6_addr))
+#endif
+struct session_addr_ipv6
+{
+ uint8_t saddr[IPV6_ADDR_LEN] ;
+ uint8_t daddr[IPV6_ADDR_LEN] ;
+ uint16_t sport; /* network order */
+ uint16_t dport; /* network order */
+};
+
+struct session_addr
+{
+ union
+ {
+ struct session_addr_ipv4 ipv4;
+ struct session_addr_ipv6 ipv6;
+ };
+};
+
+
struct session{
struct stellar *st;
enum session_state sess_state;
diff --git a/test/test_result_json/http_chn_encode_url.json b/test/test_result_json/http_chn_encode_url.json
index 642aaa5..5453415 100644
--- a/test/test_result_json/http_chn_encode_url.json
+++ b/test/test_result_json/http_chn_encode_url.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "2607:5d00:2:2::38:2.56343>240e:928:101:80::80.80"
+ "__X_HTTP_TUPLE4": "2607:5d00:2:2::38:2:56343-240e:928:101:80::80:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_chunked_res_gzip.json b/test/test_result_json/http_chunked_res_gzip.json
index 0889c3c..5d2b3d6 100644
--- a/test/test_result_json/http_chunked_res_gzip.json
+++ b/test/test_result_json/http_chunked_res_gzip.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "127.0.0.1.33412>127.0.0.1.8080"
+ "__X_HTTP_TUPLE4": "127.0.0.1:33412-127.0.0.1:8080-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_get_encoded_uri.json b/test/test_result_json/http_get_encoded_uri.json
index d999063..b84c051 100644
--- a/test/test_result_json/http_get_encoded_uri.json
+++ b/test/test_result_json/http_get_encoded_uri.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.117.60.39655>58.16.70.122.80"
+ "__X_HTTP_TUPLE4": "192.168.117.60:39655-58.16.70.122:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_get_long_cookie.json b/test/test_result_json/http_get_long_cookie.json
index 125e42a..118022d 100644
--- a/test/test_result_json/http_get_long_cookie.json
+++ b/test/test_result_json/http_get_long_cookie.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "202.127.156.91.27282>14.17.32.203.80"
+ "__X_HTTP_TUPLE4": "202.127.156.91:27282-14.17.32.203:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_get_multi_trans.json b/test/test_result_json/http_get_multi_trans.json
index 4ac91bc..dfdca17 100644
--- a/test/test_result_json/http_get_multi_trans.json
+++ b/test/test_result_json/http_get_multi_trans.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.50.18.60400>192.168.42.1.80"
+ "__X_HTTP_TUPLE4": "192.168.50.18:60400-192.168.42.1:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_get_req_pipeline.json b/test/test_result_json/http_get_req_pipeline.json
index cf41888..e69ba8c 100644
--- a/test/test_result_json/http_get_req_pipeline.json
+++ b/test/test_result_json/http_get_req_pipeline.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.40.81.52802>192.168.40.137.80"
+ "__X_HTTP_TUPLE4": "192.168.40.81:52802-192.168.40.137:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_get_single_trans.json b/test/test_result_json/http_get_single_trans.json
index 4fa6181..4c6f6d8 100644
--- a/test/test_result_json/http_get_single_trans.json
+++ b/test/test_result_json/http_get_single_trans.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.38.73.50806>192.168.40.137.80"
+ "__X_HTTP_TUPLE4": "192.168.38.73:50806-192.168.40.137:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_hdrs_exceed_maximum.json b/test/test_result_json/http_hdrs_exceed_maximum.json
index 56513ae..d6068ed 100644
--- a/test/test_result_json/http_hdrs_exceed_maximum.json
+++ b/test/test_result_json/http_hdrs_exceed_maximum.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "10.0.0.1.61462>10.0.0.2.80"
+ "__X_HTTP_TUPLE4": "10.0.0.1:61462-10.0.0.2:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_multi_parse_error.json b/test/test_result_json/http_multi_parse_error.json
index b74de5b..db830bb 100644
--- a/test/test_result_json/http_multi_parse_error.json
+++ b/test/test_result_json/http_multi_parse_error.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.131.33.47172>192.168.204.67.4445"
+ "__X_HTTP_TUPLE4": "192.168.131.33:47172-192.168.204.67:4445-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_no_content_length.json b/test/test_result_json/http_no_content_length.json
index 46fcf75..03449dc 100644
--- a/test/test_result_json/http_no_content_length.json
+++ b/test/test_result_json/http_no_content_length.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "10.0.0.1.50384>10.0.0.2.80"
+ "__X_HTTP_TUPLE4": "10.0.0.1:50384-10.0.0.2:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_over_pppoe.json b/test/test_result_json/http_over_pppoe.json
index c99b034..579679a 100644
--- a/test/test_result_json/http_over_pppoe.json
+++ b/test/test_result_json/http_over_pppoe.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "2a00:5e80:101:212d:504:7b1:2572:db22.37034>2606:f200:0:7:bad:f00d:d00d:1.80"
+ "__X_HTTP_TUPLE4": "2a00:5e80:101:212d:504:7b1:2572:db22:37034-2606:f200:0:7:bad:f00d:d00d:1:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_over_tcp_keepalive.json b/test/test_result_json/http_over_tcp_keepalive.json
index bfe9744..3928510 100644
--- a/test/test_result_json/http_over_tcp_keepalive.json
+++ b/test/test_result_json/http_over_tcp_keepalive.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.56.66.55356>60.190.243.167.80"
+ "__X_HTTP_TUPLE4": "192.168.56.66:55356-60.190.243.167:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_post_multipart_form_data.json b/test/test_result_json/http_post_multipart_form_data.json
index d65bd6c..874dbbe 100644
--- a/test/test_result_json/http_post_multipart_form_data.json
+++ b/test/test_result_json/http_post_multipart_form_data.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.8.97.11371>192.168.57.14.8080"
+ "__X_HTTP_TUPLE4": "192.168.8.97:11371-192.168.57.14:8080-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_req_1byte_sliding_window.json b/test/test_result_json/http_req_1byte_sliding_window.json
index b2aafcc..d69b234 100644
--- a/test/test_result_json/http_req_1byte_sliding_window.json
+++ b/test/test_result_json/http_req_1byte_sliding_window.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.40.137.46180>192.168.42.40.80"
+ "__X_HTTP_TUPLE4": "192.168.40.137:46180-192.168.42.40:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_res_1byte_sliding_window.json b/test/test_result_json/http_res_1byte_sliding_window.json
index cc1f50b..35860bb 100644
--- a/test/test_result_json/http_res_1byte_sliding_window.json
+++ b/test/test_result_json/http_res_1byte_sliding_window.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.42.40.36338>192.168.40.137.80"
+ "__X_HTTP_TUPLE4": "192.168.42.40:36338-192.168.40.137:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_res_gzip.json b/test/test_result_json/http_res_gzip.json
index 58b0bb7..ca86532 100644
--- a/test/test_result_json/http_res_gzip.json
+++ b/test/test_result_json/http_res_gzip.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "192.168.69.2.34059>192.168.69.1.80"
+ "__X_HTTP_TUPLE4": "192.168.69.2:34059-192.168.69.1:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_trans_pipeline.json b/test/test_result_json/http_trans_pipeline.json
index aadf9ca..d979863 100644
--- a/test/test_result_json/http_trans_pipeline.json
+++ b/test/test_result_json/http_trans_pipeline.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "223.72.39.14.2545>192.168.182.147.80"
+ "__X_HTTP_TUPLE4": "223.72.39.14:2545-192.168.182.147:80-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test/test_result_json/http_upgrade_websocket.json b/test/test_result_json/http_upgrade_websocket.json
index 650a0ca..6a7dfc3 100644
--- a/test/test_result_json/http_upgrade_websocket.json
+++ b/test/test_result_json/http_upgrade_websocket.json
@@ -1,6 +1,6 @@
[
{
- "__X_HTTP_TUPLE4": "131.179.196.220.59631>131.179.196.46.9696"
+ "__X_HTTP_TUPLE4": "131.179.196.220:59631-131.179.196.46:9696-6-0"
},
{
"__X_HTTP_TRANSACTION": "request",
diff --git a/test_based_on_stellar/CMakeLists.txt b/test_based_on_stellar/CMakeLists.txt
index e00c43e..61fe798 100644
--- a/test_based_on_stellar/CMakeLists.txt
+++ b/test_based_on_stellar/CMakeLists.txt
@@ -1,6 +1,6 @@
set(DECODER_NAME http_decoder)
-set(TEST_RUN_DIR ${CMAKE_INSTALL_PREFIX}/sapp)
+set(TEST_RUN_DIR ${CMAKE_INSTALL_PREFIX}/stellar)
set(SAPP_DEVEL_DIR ${TEST_RUN_DIR}/lib)
set(TEST_MAIN plugin_test_main)
@@ -9,10 +9,12 @@ include_directories(${CMAKE_SOURCE_DIR}/test)
include_directories(/usr/local/include/cjson)
include_directories(/opt/tsg/framework/include/stellar)
include_directories(/opt/MESA/include/MESA)
+include_directories(/opt/tsg/stellar/include/)
#various ways to add -rdynamic for centos7, centos8, and different cmake version
add_definitions(-rdynamic)
link_directories(${SAPP_DEVEL_DIR})
+
add_executable(plugin_test_main plugin_test_main.cpp)
set_target_properties(plugin_test_main
PROPERTIES
@@ -25,127 +27,64 @@ set_target_properties(plugin_test_main
"-rdynamic"
)
set(LINK_FLAGS "-rdynamic")
-target_link_libraries(plugin_test_main gtest cjson-static sapp_devel pthread pcap MESA_htable MESA_field_stat2 MESA_htable MESA_prof_load MESA_handle_logger MESA_jump_layer breakpad_mini fieldstat3 fieldstat4 systemd )
+target_link_libraries(plugin_test_main gtest cjson-static stellar_devel)
# assemble test env
+add_test(NAME STELLAR_MKDIR_METRIC COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/metrics; mkdir -p ${TEST_RUN_DIR}/plugin; mkdir -p ${TEST_RUN_DIR}/log; mkdir -p ${TEST_RUN_DIR}/pcap")
add_test(NAME STELLAR_INSTALL_TEST_MAIN COMMAND sh -c "cp ${CMAKE_CURRENT_BINARY_DIR}/${TEST_MAIN} ${TEST_RUN_DIR}/${TEST_MAIN}")
-add_test(NAME STELLAR_MKDIR_METRIC COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/metrics")
-add_test(NAME STELLAR_COPY_SPEC COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/stellar_plugin/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/spec.toml ${TEST_RUN_DIR}/stellar_plugin/spec.toml")
-add_test(NAME STELLAR_COPY_CONFLIST COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/conflist.inf ${TEST_RUN_DIR}/plug/conflist.inf")
-add_test(NAME STELLAR_COPY_START_LOADER_INF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/stellar_on_sapp && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/start_loader.inf ${TEST_RUN_DIR}/plug/stellar_on_sapp/start_loader.inf")
-add_test(NAME STELLAR_COPY_DEFER_LOADER_INF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/stellar_on_sapp && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/defer_loader.inf ${TEST_RUN_DIR}/plug/stellar_on_sapp/defer_loader.inf")
+add_test(NAME STELLAR_COPY_SPEC COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plugin/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/spec.toml ${TEST_RUN_DIR}/plugin/spec.toml")
+add_test(NAME STELLAR_COPY_STELLAR_CONF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/conf/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/stellar.toml ${TEST_RUN_DIR}/conf/stellar.toml")
+add_test(NAME STELLAR_COPY_STELLAR_LOG_CONF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/conf/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/env/log.toml ${TEST_RUN_DIR}/conf/log.toml")
add_test(NAME STELLAR_COPY_HTTP_DECODER_CONF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/etc/http && cp ${PROJECT_SOURCE_DIR}/conf/http_decoder.toml ${TEST_RUN_DIR}/etc/http/")
add_test(NAME STELLAR_COPY_HTTP_GTEST_ENTRY_CONF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/etc/http && cp ${PROJECT_SOURCE_DIR}/conf/gtest_entry.toml ${TEST_RUN_DIR}/etc/http/")
# update config files
-add_test(NAME STELLAR_UPDATE_SAPP_LOG_LEVEL COMMAND bash -c "sed -i 's/sapp_log.fatal/sapp_log.info/' ${TEST_RUN_DIR}/etc/sapp_log.conf")
-add_test(NAME STELLAR_UPDATE_SAPP_SYN_MODE COMMAND bash -c "sed -i 's/syn_mandatory=1/syn_mandatory=0/' ${TEST_RUN_DIR}/etc/sapp.toml")
-add_test(NAME STELLAR_ENABLE_SAPP_MONITOR COMMAND bash -c "sed -i 's/monitor_thread_enabled=0/monitor_thread_enabled=1/' ${TEST_RUN_DIR}/etc/sapp.toml")
add_test(NAME UPDATE_GTEST_PLUG_ENTRY COMMAND bash -c "sed -i 's/name=.*/name=\\x22http_decoder_test_entry\\x22/' ${TEST_RUN_DIR}/etc/http/gtest_entry.toml")
add_test(NAME UPDATE_GTEST_PLUG_TOPIC COMMAND bash -c "sed -i 's/topic=.*/topic=\\x22HTTP_DECODER_MESSAGE\\x22/' ${TEST_RUN_DIR}/etc/http/gtest_entry.toml")
# update plugin to be tested
-add_test(NAME STELLAR_HTTP_DECODER_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/src/${DECODER_NAME}.so ${TEST_RUN_DIR}/stellar_plugin/${DECODER_NAME}.so")
-add_test(NAME STELLAR_HTTP_DECODER_GTEST_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/test/${DECODER_NAME}_test.so ${TEST_RUN_DIR}/stellar_plugin/${DECODER_NAME}_test.so")
+add_test(NAME STELLAR_HTTP_DECODER_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/src/${DECODER_NAME}.so ${TEST_RUN_DIR}/plugin/${DECODER_NAME}.so")
+add_test(NAME STELLAR_HTTP_DECODER_GTEST_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/test/${DECODER_NAME}_test.so ${TEST_RUN_DIR}/plugin/${DECODER_NAME}_test.so")
-set_tests_properties(STELLAR_INSTALL_TEST_MAIN STELLAR_MKDIR_METRIC STELLAR_COPY_SPEC STELLAR_COPY_CONFLIST STELLAR_COPY_START_LOADER_INF STELLAR_COPY_DEFER_LOADER_INF STELLAR_COPY_HTTP_DECODER_CONF STELLAR_COPY_HTTP_GTEST_ENTRY_CONF
- STELLAR_HTTP_DECODER_SO STELLAR_HTTP_DECODER_GTEST_SO STELLAR_UPDATE_SAPP_LOG_LEVEL STELLAR_UPDATE_SAPP_SYN_MODE STELLAR_ENABLE_SAPP_MONITOR
- UPDATE_GTEST_PLUG_ENTRY UPDATE_GTEST_PLUG_TOPIC
+set_tests_properties(STELLAR_MKDIR_METRIC STELLAR_INSTALL_TEST_MAIN STELLAR_COPY_SPEC STELLAR_COPY_HTTP_DECODER_CONF STELLAR_COPY_HTTP_GTEST_ENTRY_CONF
+ STELLAR_COPY_STELLAR_CONF STELLAR_COPY_STELLAR_LOG_CONF
+ STELLAR_HTTP_DECODER_SO STELLAR_HTTP_DECODER_GTEST_SO
+ UPDATE_GTEST_PLUG_ENTRY UPDATE_GTEST_PLUG_TOPIC
PROPERTIES FIXTURES_SETUP TestFixture)
set(TEST_JSON_DIR ${PROJECT_SOURCE_DIR}/test/test_result_json)
set(TEST_PCAP_DIR ${PROJECT_SOURCE_DIR}/test/http_pcap)
# run tests
-add_test(NAME STELLAR_HTTP_GET_SINGLE_TRANS_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_single_trans.json
- -r ${TEST_PCAP_DIR}/http_get_single_trans.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_GET_MULTI_TRANS_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_multi_trans.json
- -r ${TEST_PCAP_DIR}/http_get_multi_trans.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_GET_LONG_COOKIE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_long_cookie.json
- -r ${TEST_PCAP_DIR}/http_get_long_cookie.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_GET_ENCODED_URI_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_encoded_uri.json
- -r ${TEST_PCAP_DIR}/http_get_encoded_uri.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_RES_GZIP_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_res_gzip.json
- -r ${TEST_PCAP_DIR}/http_res_gzip.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_CHUNKED_RES_GZIP_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_chunked_res_gzip.json
- -r ${TEST_PCAP_DIR}/http_chunked_res_gzip.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_OVER_TCP_KEEPALIVE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_tcp_keepalive.json
- -r ${TEST_PCAP_DIR}/http_over_tcp_keepalive.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-# add_test(NAME STELLAR_HTTP_TUNNEL_FOR_POP3_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_pop3.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_pop3.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_TUNNEL_FOR_HTTP_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_http.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_TUNNEL_FOR_HTTP_C2S_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_http_c2s.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http_C2S.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_TUNNEL_FOR_HTTP_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_http_s2c.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http_S2C.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_OVER_PPPOE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_pppoe.json
- -r ${TEST_PCAP_DIR}/http_over_pppoe.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_OVER_TLS_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_tls.json
- -r ${TEST_PCAP_DIR}/http_over_tls.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_NON_HTTP_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/non_http.json
- -r ${TEST_PCAP_DIR}/non_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_REQ_1BYTE_SLIDING_WINDOW_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_req_1byte_sliding_window.json
- -r ${TEST_PCAP_DIR}/http_req_1byte_sliding_window.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_RES_1BYTE_SLIDING_WINDOW_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_res_1byte_sliding_window.json
- -r ${TEST_PCAP_DIR}/http_res_1byte_sliding_window.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_NO_CONTENT_LENGTH_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_no_content_length.json
- -r ${TEST_PCAP_DIR}/http_no_content_length.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_POST_MULTIPART_FORM_DATA_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_post_multipart_form_data.json
- -r ${TEST_PCAP_DIR}/http_post_multipart_form_data.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_HEADERS_EXCEED_MAXIMUM_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdrs_exceed_maximum.json
- -r ${TEST_PCAP_DIR}/http_hdrs_exceed_maximum.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_GET_MALFORMED_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_malformed.json
- -r ${TEST_PCAP_DIR}/http_get_malformed.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_HEADER_VALUE_EMPTY_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_value_empty.json
- -r ${TEST_PCAP_DIR}/http_hdr_value_empty.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_UPGRADE_WEBSOCKET_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_upgrade_websocket.json
- -r ${TEST_PCAP_DIR}/http_upgrade_websocket.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-# add_test(NAME STELLAR_HTTP_UPGRADE_HTTP2_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_upgrade_http2.json
-# -r ${TEST_PCAP_DIR}/http_upgrade_http2.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_MULTI_PARSE_ERROR_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_multi_parse_error.json
- -r ${TEST_PCAP_DIR}/http_multi_parse_error.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_GET_REQ_PIPELINE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_req_pipeline.json
- -r ${TEST_PCAP_DIR}/http_get_req_pipeline.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_TRANS_PIPELINE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_trans_pipeline.json
- -r ${TEST_PCAP_DIR}/http_trans_pipeline.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_HEADER_TRUNCATED_IN_KV_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_truncated_in_kv.json
- -r ${TEST_PCAP_DIR}/http_hdr_truncated_in_kv.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_HEADER_TRUNCATED_AFTER_KV_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_truncated_after_kv.json
- -r ${TEST_PCAP_DIR}/http_hdr_truncated_after_kv.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_FIN_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/non_http.json
- -r ${TEST_PCAP_DIR}/http_fin.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
+add_test(NAME STELLAR_HTTP_GET_SINGLE_TRANS_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_single_trans.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_single_trans.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_GET_MULTI_TRANS_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_multi_trans.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_multi_trans.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_GET_LONG_COOKIE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_long_cookie.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_long_cookie.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_GET_ENCODED_URI_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_encoded_uri.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_encoded_uri.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_RES_GZIP_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_res_gzip.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_res_gzip.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_CHUNKED_RES_GZIP_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_chunked_res_gzip.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_chunked_res_gzip.json"WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_OVER_TCP_KEEPALIVE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_over_tcp_keepalive.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_tcp_keepalive.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_OVER_PPPOE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_over_pppoe.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_pppoe.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_OVER_TLS_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_over_tls.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_tls.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_NON_HTTP_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/non_http.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/non_http.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_REQ_1BYTE_SLIDING_WINDOW_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_req_1byte_sliding_window.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_req_1byte_sliding_window.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_RES_1BYTE_SLIDING_WINDOW_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_res_1byte_sliding_window.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_res_1byte_sliding_window.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_NO_CONTENT_LENGTH_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_no_content_length.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_no_content_length.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_POST_MULTIPART_FORM_DATA_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_post_multipart_form_data.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_post_multipart_form_data.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_HEADERS_EXCEED_MAXIMUM_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_hdrs_exceed_maximum.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdrs_exceed_maximum.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_GET_MALFORMED_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_malformed.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_malformed.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+#no SYN, steallar not support !
+# add_test(NAME STELLAR_HTTP_HEADER_VALUE_EMPTY_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_hdr_value_empty.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_value_empty.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_UPGRADE_WEBSOCKET_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_upgrade_websocket.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_upgrade_websocket.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MULTI_PARSE_ERROR_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_multi_parse_error.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_multi_parse_error.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_GET_REQ_PIPELINE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_req_pipeline.pcap ${TEST_RUN_DIR}/pcap/test.pcap;./${TEST_MAIN} ${TEST_JSON_DIR}/http_get_req_pipeline.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_TRANS_PIPELINE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_trans_pipeline.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_trans_pipeline.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+#no SYN, steallar not support !
+# add_test(NAME STELLAR_HTTP_HEADER_TRUNCATED_IN_KV_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_hdr_truncated_in_kv.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_truncated_in_kv.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+# add_test(NAME STELLAR_HTTP_HEADER_TRUNCATED_AFTER_KV_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_truncated_after_kv.json -r ${TEST_PCAP_DIR}/http_hdr_truncated_after_kv.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_FIN_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_fin.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/non_http.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
# add_test(NAME STELLAR_HTTP_TUNNEL_ONLY_HDR_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_s2c_only_hdr.json
# -r ${TEST_PCAP_DIR}/http_tunnel_s2c_only_hdr.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-add_test(NAME STELLAR_HTTP_CHN_ENCODE_URL COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_chn_encode_url.json
- -r ${TEST_PCAP_DIR}/http_chn_encode_url.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_CHN_ENCODE_URL COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_chn_encode_url.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_chn_encode_url.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
set_tests_properties(STELLAR_HTTP_GET_SINGLE_TRANS_TEST
STELLAR_HTTP_GET_MULTI_TRANS_TEST
@@ -154,10 +93,6 @@ set_tests_properties(STELLAR_HTTP_GET_SINGLE_TRANS_TEST
STELLAR_HTTP_RES_GZIP_TEST
STELLAR_HTTP_CHUNKED_RES_GZIP_TEST
STELLAR_HTTP_OVER_TCP_KEEPALIVE_TEST
- # STELLAR_HTTP_TUNNEL_FOR_POP3_TEST
- # STELLAR_HTTP_TUNNEL_FOR_HTTP_TEST
- # STELLAR_HTTP_TUNNEL_FOR_HTTP_C2S_TEST
- # STELLAR_HTTP_TUNNEL_FOR_HTTP_S2C_TEST
STELLAR_HTTP_OVER_PPPOE_TEST
STELLAR_HTTP_OVER_TLS_TEST
STELLAR_NON_HTTP_TEST
@@ -168,15 +103,10 @@ set_tests_properties(STELLAR_HTTP_GET_SINGLE_TRANS_TEST
STELLAR_HTTP_HEADERS_EXCEED_MAXIMUM_TEST
STELLAR_HTTP_GET_MALFORMED_TEST
STELLAR_HTTP_MULTI_PARSE_ERROR_TEST
- STELLAR_HTTP_HEADER_VALUE_EMPTY_TEST
STELLAR_HTTP_UPGRADE_WEBSOCKET_TEST
- # STELLAR_HTTP_UPGRADE_HTTP2_TEST
STELLAR_HTTP_GET_REQ_PIPELINE_TEST
STELLAR_HTTP_TRANS_PIPELINE_TEST
- STELLAR_HTTP_HEADER_TRUNCATED_IN_KV_TEST
- STELLAR_HTTP_HEADER_TRUNCATED_AFTER_KV_TEST
STELLAR_HTTP_FIN_TEST
- # STELLAR_HTTP_TUNNEL_ONLY_HDR_TEST
STELLAR_HTTP_CHN_ENCODE_URL
PROPERTIES FIXTURES_REQUIRED TestFixture)
@@ -186,24 +116,12 @@ add_test(NAME UPDATE_STATE_PLUG_TOPIC COMMAND bash -c "sed -i 's/topic=.*/topic=
set_tests_properties(UPDATE_STATE_PLUG_ENTRY UPDATE_STATE_PLUG_TOPIC STELLAR_HTTP_DECODER_SO STELLAR_HTTP_DECODER_GTEST_SO STELLAR_MKDIR_METRIC
PROPERTIES FIXTURES_SETUP TestState)
-add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state.json
- -r ${TEST_PCAP_DIR}/http_post.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_C2S_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_c2s.json
- -r ${TEST_PCAP_DIR}/http_post_c2s.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_s2c.json
- -r ${TEST_PCAP_DIR}/http_post_s2c.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_PIPELINE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_pipeline.json
- -r ${TEST_PCAP_DIR}/http_get_multi_trans.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_C2S_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_exception_c2s.json
- -r ${TEST_PCAP_DIR}/http_session_exception_c2s.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_exception_s2c.json
- -r ${TEST_PCAP_DIR}/http_session_exception_s2c.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_tunnel.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_C2S_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_tunnel_c2s.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http_C2S.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_tunnel_s2c.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http_S2C.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_post.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_C2S_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_post_c2s.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_c2s.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_S2C_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_post_s2c.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_s2c.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_PIPELINE_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_get_multi_trans.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_pipeline.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_C2S_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_session_exception_c2s.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_exception_c2s.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_S2C_TEST COMMAND sh -c "ln -sf ${TEST_PCAP_DIR}/http_session_exception_s2c.pcap ${TEST_RUN_DIR}/pcap/test.pcap; ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_exception_s2c.json" WORKING_DIRECTORY ${TEST_RUN_DIR})
set_tests_properties(STELLAR_HTTP_MSG_TYPE_STATE_TEST
STELLAR_HTTP_MSG_TYPE_STATE_C2S_TEST
@@ -211,23 +129,4 @@ set_tests_properties(STELLAR_HTTP_MSG_TYPE_STATE_TEST
STELLAR_HTTP_MSG_TYPE_STATE_PIPELINE_TEST
STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_C2S_TEST
STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_S2C_TEST
- # STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_TEST
- # STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_C2S_TEST
- # STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_S2C_TEST
PROPERTIES FIXTURES_REQUIRED TestState)
-
-# add_test(NAME UPDATE_TUNNEL_PLUG_ENTRY COMMAND bash -c "sed -i 's/name=.*/name=\\x22http_decoder_tunnel_entry\\x22/' ${TEST_RUN_DIR}/etc/http/gtest_entry.toml")
-# add_test(NAME UPDATE_TUNNEL_PLUG_TOPIC COMMAND bash -c "sed -i 's/topic=.*/topic=\\x22HTTP_DECODER_TUNNEL_MESSAGE\\x22/' ${TEST_RUN_DIR}/etc/http/gtest_entry.toml")
-
-# set_tests_properties(UPDATE_TUNNEL_PLUG_ENTRY UPDATE_TUNNEL_PLUG_TOPIC
-# STELLAR_HTTP_DECODER_SO STELLAR_HTTP_DECODER_GTEST_SO
-# PROPERTIES FIXTURES_SETUP TestTunnel)
-
-# add_test(NAME STELLAR_HTTP_MSG_TYPE_TUNNEL_POP3_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_inner_tunnel_for_pop3.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_pop3.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-# add_test(NAME STELLAR_HTTP_MSG_TYPE_TUNNEL_HTTP_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_inner_tunnel_for_http.json
-# -r ${TEST_PCAP_DIR}/http_tunnel_for_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
-
-# set_tests_properties(STELLAR_HTTP_MSG_TYPE_TUNNEL_POP3_TEST
-# STELLAR_HTTP_MSG_TYPE_TUNNEL_HTTP_TEST
-# PROPERTIES FIXTURES_REQUIRED TestTunnel) \ No newline at end of file
diff --git a/test_based_on_stellar/env/conflist.inf b/test_based_on_stellar/env/conflist.inf
deleted file mode 100644
index 5449f7d..0000000
--- a/test_based_on_stellar/env/conflist.inf
+++ /dev/null
@@ -1,7 +0,0 @@
-[platform]
-./plug/stellar_on_sapp/start_loader.inf
-
-[protocol]
-
-[business]
-./plug/stellar_on_sapp/defer_loader.inf
diff --git a/test_based_on_stellar/env/defer_loader.inf b/test_based_on_stellar/env/defer_loader.inf
deleted file mode 100644
index f31e043..0000000
--- a/test_based_on_stellar/env/defer_loader.inf
+++ /dev/null
@@ -1,14 +0,0 @@
-[PLUGINFO]
-PLUGNAME=stellar_defer_loader
-SO_PATH=./plug/stellar_on_sapp/stellar_on_sapp.so
-INIT_FUNC=STELLAR_DEFER_LOADER_INIT
-DESTROY_FUNC=STELLAR_DEFER_LOADER_EXIT
-
-[TCP_ALL]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_defer_entry
-
-[UDP]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_defer_entry
-
diff --git a/test_based_on_stellar/env/log.toml b/test_based_on_stellar/env/log.toml
new file mode 100644
index 0000000..0246ed1
--- /dev/null
+++ b/test_based_on_stellar/env/log.toml
@@ -0,0 +1,4 @@
+[log]
+output = file # stderr, file
+file = "log/stellar.log"
+level = DEBUG # TRACE, DEBUG, INFO, WARN, ERROR, FATAL
diff --git a/test_based_on_stellar/env/spec.toml b/test_based_on_stellar/env/spec.toml
index 237abc5..9bc3474 100644
--- a/test_based_on_stellar/env/spec.toml
+++ b/test_based_on_stellar/env/spec.toml
@@ -1,9 +1,9 @@
[[plugin]]
-path = "./stellar_plugin/http_decoder.so"
+path = "./plugin/http_decoder.so"
init = "http_decoder_init"
exit = "http_decoder_exit"
[[plugin]]
-path = "./stellar_plugin/http_decoder_test.so"
+path = "./plugin/http_decoder_test.so"
init = "http_decoder_test_init"
exit = "http_decoder_test_exit"
diff --git a/test_based_on_stellar/env/start_loader.inf b/test_based_on_stellar/env/start_loader.inf
deleted file mode 100644
index ce1dc1b..0000000
--- a/test_based_on_stellar/env/start_loader.inf
+++ /dev/null
@@ -1,30 +0,0 @@
-[PLUGINFO]
-PLUGNAME=stellar_start_loader
-SO_PATH=./plug/stellar_on_sapp/stellar_on_sapp.so
-INIT_FUNC=STELLAR_START_LOADER_INIT
-DESTROY_FUNC=STELLAR_START_LOADER_EXIT
-
-[TCP_ALL]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_tcpall_entry
-
-[TCP]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_tcp_entry
-
-
-[UDP]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_udp_entry
-
-[IP]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_ip4_entry
-
-[IPV6]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_ip6_entry
-
-[POLLING]
-FUNC_FLAG=ALL
-FUNC_NAME=stellar_on_sapp_polling_entry
diff --git a/test_based_on_stellar/env/stellar.toml b/test_based_on_stellar/env/stellar.toml
new file mode 100644
index 0000000..dbb4bd1
--- /dev/null
+++ b/test_based_on_stellar/env/stellar.toml
@@ -0,0 +1,57 @@
+[id_generator]
+snowflake_worker_id_base = 1 # [0, 31]
+snowflake_worker_id_offset = 2 # [0, 127]
+
+[packet_io]
+mode = dumpfile # dumpfile, marsio
+app_symbol = stellar
+dev_symbol = nf_0_fw
+
+dumpfile_dir = "./pcap"
+nr_threads = 1 # [1, 256]
+#cpu_mask = [5, 6, 7, 8, 9, 10, 11, 12]
+cpu_mask = [5]
+
+[ip_reassembly]
+enable = 1
+timeout = 10000 # range: [1, 60000] (ms)
+bucket_entries = 256 # range: [1, 4294967295] (must be power of 2)
+bucket_num = 4096 # range: [1, 4294967295]
+
+[session_manager]
+# max session number
+max_tcp_session_num = 1000
+max_udp_session_num = 1000
+
+# session overload evict
+tcp_overload_evict_old_sess = 1 # 1: evict old session, 0: bypass new session
+udp_overload_evict_old_sess = 1 # 1: evict old session, 0: bypass new session
+
+# TCP timeout
+tcp_init_timeout = 5000 # range: [1, 60000] (ms)
+tcp_handshake_timeout = 5000 # range: [1, 60000] (ms)
+tcp_data_timeout = 5000 # range: [1, 15999999000] (ms)
+tcp_half_closed_timeout = 2000 # range: [1, 604800000] (ms)
+tcp_time_wait_timeout = 1000 # range: [1, 600000] (ms)
+tcp_discard_timeout = 1000 # range: [1, 15999999000] (ms)
+tcp_unverified_rst_timeout = 1000 # range: [1, 600000] (ms)
+# UDP timeout
+udp_data_timeout = 5000 # range: [1, 15999999000] (ms)
+udp_discard_timeout = 5000 # range: [1, 15999999000] (ms)
+
+# duplicate packet filter
+duplicated_packet_filter_enable = 0
+duplicated_packet_filter_capacity = 1000000 # range: [1, 4294967295]
+duplicated_packet_filter_timeout = 10000 # range: [1, 60000] (ms)
+duplicated_packet_filter_error_rate = 0.00001 # range: [0.0, 1.0]
+
+# evicted session filter
+evicted_session_filter_enable = 0
+evicted_session_filter_capacity = 1000000 # range: [1, 4294967295]
+evicted_session_filter_timeout = 10000 # range: [1, 60000] (ms)
+evicted_session_filter_error_rate = 0.00001 # range: [0.0, 1.0]
+
+# TCP reassembly (Per direction)
+tcp_reassembly_enable = 1
+tcp_reassembly_max_timeout = 10000 # range: [1, 60000] (ms)
+tcp_reassembly_max_segments = 256 # range: [2, 4096]
diff --git a/test_based_on_stellar/plugin_test_main.cpp b/test_based_on_stellar/plugin_test_main.cpp
index c26a5d5..37d6f4e 100644
--- a/test_based_on_stellar/plugin_test_main.cpp
+++ b/test_based_on_stellar/plugin_test_main.cpp
@@ -6,6 +6,15 @@
#include <assert.h>
#include "http_decoder_gtest.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#include "stellar/stellar.h"
+#ifdef __cplusplus
+}
+#endif
+
// #define IGNORE_PRINTF
#ifdef IGNORE_PRINTF
#define printf(fmt, ...) (0)
@@ -15,13 +24,6 @@ cJSON *g_test_result_root = NULL;
cJSON *g_load_result_root = NULL;
int g_ret = 0;
-extern "C" int get_current_worker_thread_id(void)
-{
- return 0;
-}
-
-extern "C" int libsapp_setup_env(int argc, char *argv[]);
-
extern "C" int commit_test_result_json(cJSON *node, const char *name)
{
if (g_test_result_root)
@@ -36,13 +38,13 @@ extern "C" int commit_test_result_json(cJSON *node, const char *name)
static void hdgt_prune_non_result_item(cJSON *benchmark_json_root)
{
- int array_size = cJSON_GetArraySize(benchmark_json_root);
+ int array_size = cJSON_GetArraySize(benchmark_json_root);
- for (int i = 0; i < array_size; i++)
- {
- cJSON *object_root = cJSON_GetArrayItem(benchmark_json_root, i);
- cJSON_DeleteItemFromObject(object_root, GTEST_HTTP_PAYLOAD_NAME);
- }
+ for (int i = 0; i < array_size; i++)
+ {
+ cJSON *object_root = cJSON_GetArrayItem(benchmark_json_root, i);
+ cJSON_DeleteItemFromObject(object_root, GTEST_HTTP_PAYLOAD_NAME);
+ }
}
static cJSON *load_result_from_jsonfile(const char *json_path)
@@ -118,20 +120,14 @@ TEST(PROTOCOL, compare_result_json)
fail:
cJSON_Delete(g_load_result_root);
cJSON_Delete(g_test_result_root);
- return;
-}
-
-void run_gtest_main()
-{
- g_ret = RUN_ALL_TESTS();
- exit(g_ret);
+ return;
}
int main(int argc, char *argv[])
{
- if (argc < 3)
+ if (argc < 2)
{
- printf("Invalid Argument!!!\n Usage: ./test_protocol_plug_main [/path/to/result_json] [sapp_args...]\n");
+ printf("Usage: %s <result_json_path>\n", argv[0]);
return -1;
}
const char *result_json_path = argv[1];
@@ -140,12 +136,10 @@ int main(int argc, char *argv[])
assert(g_load_result_root != NULL && g_test_result_root != NULL);
::testing::InitGoogleTest(&argc, argv);
- if (libsapp_setup_env(argc - 1, argv + 1) < 0)
+ if (stellar_run(argc - 1, argv + 1) < 0)
{
return -1;
}
- atexit(run_gtest_main);
- while (1)
- pause();
- return 0;
+
+ return RUN_ALL_TESTS();
}