diff options
| -rw-r--r-- | decoders/qdpi_detector/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | decoders/qdpi_detector/qdpi_detector.cpp | 8 | ||||
| -rw-r--r-- | decoders/qdpi_detector/qdpi_detector.h | 12 | ||||
| -rw-r--r-- | decoders/qdpi_detector/qdpi_detector_module.c (renamed from decoders/qdpi_detector/qdpi_detector_module.cpp) | 10 | ||||
| -rw-r--r-- | decoders/qdpi_detector/qdpi_detector_utils.c (renamed from decoders/qdpi_detector/qdpi_detector_utils.cpp) | 0 | ||||
| -rw-r--r-- | decoders/qdpi_detector/qdpi_detector_utils.h | 9 | ||||
| -rw-r--r-- | test/decoders/qdpi_detector/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/decoders/qdpi_detector/gtest_qdpi_detector.h | 10 | ||||
| -rw-r--r-- | test/decoders/qdpi_detector/gtest_qdpi_detector_main.cpp | 29 | ||||
| -rw-r--r-- | test/decoders/qdpi_detector/gtest_qdpi_detector_module.c (renamed from test/decoders/qdpi_detector/gtest_qdpi_detector_module.cpp) | 46 | ||||
| -rw-r--r-- | vendors/CMakeLists.txt | 36 | ||||
| -rw-r--r-- | vendors/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz | bin | 525014 -> 493978 bytes |
12 files changed, 80 insertions, 88 deletions
diff --git a/decoders/qdpi_detector/CMakeLists.txt b/decoders/qdpi_detector/CMakeLists.txt index fa16082..79d9e88 100644 --- a/decoders/qdpi_detector/CMakeLists.txt +++ b/decoders/qdpi_detector/CMakeLists.txt @@ -1,8 +1,8 @@ add_definitions(-fPIC) include_directories(${CMAKE_SOURCE_DIR}/deps/) -include_directories(${CMAKE_BINARY_DIR}/vendors/tsgengine/include/) +#include_directories(${CMAKE_BINARY_DIR}/vendors/tsgengine/include/) include_directories(${CMAKE_SOURCE_DIR}/decoders/) -add_library(qdpi_detector qdpi_detector.cpp qdpi_detector_module.cpp qdpi_detector_utils.cpp) -target_link_libraries(qdpi_detector appid maatframe qmengine cjson-static -Wl,--no-whole-archive openssl-crypto-static -Wl,--no-whole-archive openssl-ssl-static) +add_library(qdpi_detector qdpi_detector_module.c qdpi_detector.cpp qdpi_detector_utils.c) +target_link_libraries(qdpi_detector appid maatframe libqmengine-shared cjson-static -Wl,--no-whole-archive openssl-crypto-static -Wl,--no-whole-archive openssl-ssl-static) set_target_properties(qdpi_detector PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version.map") diff --git a/decoders/qdpi_detector/qdpi_detector.cpp b/decoders/qdpi_detector/qdpi_detector.cpp index b63342c..98fe194 100644 --- a/decoders/qdpi_detector/qdpi_detector.cpp +++ b/decoders/qdpi_detector/qdpi_detector.cpp @@ -1,9 +1,3 @@ -/************************************************************************* - > File Name: qdpi_detector.cpp - > Author: - > Mail: - > Created Time: - ************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -11,8 +5,8 @@ #include "stellar/utils.h" #include "stellar/session.h" -#include "appid/appid_internal.h" #include "stellar/log.h" +#include "appid/appid_internal.h" #include <qmdpi.h> #include <qmdpi_bundle_api.h> diff --git a/decoders/qdpi_detector/qdpi_detector.h b/decoders/qdpi_detector/qdpi_detector.h index 11d6b4a..9a51c1f 100644 --- a/decoders/qdpi_detector/qdpi_detector.h +++ b/decoders/qdpi_detector/qdpi_detector.h @@ -3,6 +3,11 @@ #include "stellar/log.h" #include <stdint.h> +#ifdef __cplusplus +extern "C" +{ +#endif + #define APP_PATH_MAX 256 #define STRING_MAX 2048 #define MAX_WORKER 512 @@ -62,15 +67,16 @@ struct qdpi_detector_module_env struct qmdpi_worker *worker[MAX_WORKER]; }; -void qdpi_detector_destroy_engine(struct qdpi_detector_module_env *plugin_env); int qdpi_detector_create_engine(struct qdpi_detector_module_env *plugin_env, int num_workers); - int qdpi_detector_update_pb(struct qdpi_detector_module_env *plugin_env, struct qdpi_detector_bundle **old_bundle, const char *filename, struct qmdpi_bundle **qmdpi_bundle, int tid); int qdpi_detector_update_pdb(struct qdpi_detector_module_env *plugin_env, int tid, const char *path, char *uuid_string); - int qdpi_detector(struct session *sess, struct qdpi_detector_context *context, const char *payload, int payloadlen); +void qdpi_detector_destroy_engine(struct qdpi_detector_module_env *plugin_env); void qdpi_detector_context_free(struct qdpi_detector_context **context); void qdpi_detector_context_update(struct session *sess, struct qdpi_detector_context *context); struct qdpi_detector_context *qdpi_detector_context_new(struct qdpi_detector_config *lqd_config, struct qmdpi_worker *worker, int thread_id, int topic_id, struct module_manager *mod_mgr, struct logger *log_handle); +#ifdef __cplusplus +} +#endif
\ No newline at end of file diff --git a/decoders/qdpi_detector/qdpi_detector_module.cpp b/decoders/qdpi_detector/qdpi_detector_module.c index 2123d64..26d39eb 100644 --- a/decoders/qdpi_detector/qdpi_detector_module.cpp +++ b/decoders/qdpi_detector/qdpi_detector_module.c @@ -411,6 +411,7 @@ void app_signature_update_cb(const char *table_name __unused, const char* table_ qdpi_detector_create_features(qdpi_env, license, pb_path, pdb_path, uuid_string); } + cJSON_Delete(data); return; } @@ -430,14 +431,12 @@ void qdpi_detector_exdata_free(int idx __unused, void *ex_ptr, void *arg __unuse struct qdpi_detector_context *context = (struct qdpi_detector_context *)ex_ptr; if(context != NULL) { - //struct qmdpi_result *result=NULL; - //qmdpi_flow_destroy(context->worker, context->qmdpi_flow, &result); qdpi_detector_context_free(&context); } return; } -extern "C" void qdpi_detector_module_exit(struct module_manager *mod_mgr, struct module *mod) +void qdpi_detector_module_exit(struct module_manager *mod_mgr, struct module *mod) { if(mod_mgr == NULL || mod == NULL) { @@ -457,7 +456,7 @@ extern "C" void qdpi_detector_module_exit(struct module_manager *mod_mgr, struct return; } -extern "C" struct module *qdpi_detector_module_init(struct module_manager *mod_mgr) +struct module *qdpi_detector_module_init(struct module_manager *mod_mgr) { if(mod_mgr == NULL) { @@ -471,7 +470,8 @@ extern "C" struct module *qdpi_detector_module_init(struct module_manager *mod_m qdpi_env->nb_workers = module_manager_get_max_thread_num(qdpi_env->mod_mgr); struct module *mod=module_new("QDPI_MODULE", qdpi_env); - struct session_manager *sess_mgr=module_to_session_manager(mod); + struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME); + struct session_manager *sess_mgr=module_to_session_manager(sess_mgr_mod); struct mq_schema *mq_s=module_manager_get_mq_schema(mod_mgr); if(sess_mgr==NULL || mq_s==NULL) { diff --git a/decoders/qdpi_detector/qdpi_detector_utils.cpp b/decoders/qdpi_detector/qdpi_detector_utils.c index 03ae23e..03ae23e 100644 --- a/decoders/qdpi_detector/qdpi_detector_utils.cpp +++ b/decoders/qdpi_detector/qdpi_detector_utils.c diff --git a/decoders/qdpi_detector/qdpi_detector_utils.h b/decoders/qdpi_detector/qdpi_detector_utils.h index 1e155ba..9dd0dc7 100644 --- a/decoders/qdpi_detector/qdpi_detector_utils.h +++ b/decoders/qdpi_detector/qdpi_detector_utils.h @@ -1,5 +1,10 @@ #pragma once +#ifdef __cplusplus +extern "C" +{ +#endif + int lqd_file_exsit(const char *load_path); int lqd_file_remove(const char *realpath, const char *filename); int lqd_file_write(char *filename, char *buffer, int buffer_len); @@ -10,3 +15,7 @@ int lqd_ecb_decrypt_string(char *aes_ecb_data, int aes_ecb_data_len, char *data, char *lqd_parse_config(const char *config); void lqd_get_clock_time(struct timeval *ts); + +#ifdef __cplusplus +} +#endif
\ No newline at end of file diff --git a/test/decoders/qdpi_detector/CMakeLists.txt b/test/decoders/qdpi_detector/CMakeLists.txt index a59189c..b0f1967 100644 --- a/test/decoders/qdpi_detector/CMakeLists.txt +++ b/test/decoders/qdpi_detector/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable(gtest_qdpi_detector gtest_qdpi_detector_module.cpp gtest_qdpi_detector_main.cpp) +add_executable(gtest_qdpi_detector gtest_qdpi_detector_module.c gtest_qdpi_detector_main.cpp) target_include_directories(gtest_qdpi_detector PRIVATE ${CMAKE_SOURCE_DIR}/deps/) target_include_directories(gtest_qdpi_detector PRIVATE ${CMAKE_SOURCE_DIR}/decoders/) diff --git a/test/decoders/qdpi_detector/gtest_qdpi_detector.h b/test/decoders/qdpi_detector/gtest_qdpi_detector.h index 03a9dcc..8e6f87e 100644 --- a/test/decoders/qdpi_detector/gtest_qdpi_detector.h +++ b/test/decoders/qdpi_detector/gtest_qdpi_detector.h @@ -1,8 +1,12 @@ #pragma once - -int stellar_test_result_setup(); +#ifdef __cplusplus +extern "C" +{ +#endif char *gtest_qdpi_result_json_export(); -void gtest_qdpi_result_cleanup(); +#ifdef __cplusplus +} +#endif
\ No newline at end of file diff --git a/test/decoders/qdpi_detector/gtest_qdpi_detector_main.cpp b/test/decoders/qdpi_detector/gtest_qdpi_detector_main.cpp index ab04576..6648917 100644 --- a/test/decoders/qdpi_detector/gtest_qdpi_detector_main.cpp +++ b/test/decoders/qdpi_detector/gtest_qdpi_detector_main.cpp @@ -28,12 +28,6 @@ struct gtest_json_result static struct gtest_json_result *gtest_result_new(const char *expect_json_path) { struct gtest_json_result *para = (struct gtest_json_result *)calloc(1, sizeof(struct gtest_json_result)); - if(expect_json_path==NULL) - { - para->expect_json_root=cJSON_CreateArray(); - return para; - } - para->test_json_root = cJSON_CreateArray(); FILE *file = fopen(expect_json_path, "rb"); if(file) @@ -108,22 +102,6 @@ static void gtest_result_free(struct gtest_json_result *para) return; } -void gtest_on_session_msg_expect_json(int topic_id, void *msg, void *on_msg_arg) -{ - struct gtest_json_result *g_test_para = (struct gtest_json_result *)on_msg_arg; - - cJSON *per_session_json = cJSON_Parse((const char *)msg); - - if (g_test_para->test_json_root) - { - char result_name[128] = ""; - sprintf(result_name, "app_session_%d", g_test_para->result_count); - cJSON_AddStringToObject(per_session_json, "name", result_name); - cJSON_AddItemToArray(g_test_para->test_json_root, per_session_json); - } - g_test_para->result_count += 1; -} - /********************************************** * GTEST MAIN * **********************************************/ @@ -140,11 +118,6 @@ int main(int argc, char ** argv) struct stellar *st=stellar_new("./conf/stellar.toml"); EXPECT_TRUE(st!=NULL); - //struct module_manager * mod_mgr = stellar_get_module_manager(st); - //int expect_json_topic_id = mq_schema_get_topic_id(module_manager_get_mq_schema(st->mod_mgr), "EXPECT_JSON"); - //EXPECT_TRUE(expect_json_topic_id>=0); - //mq_schema_subscribe(module_manager_get_mq_schema(mod_mgr), expect_json_topic_id, gtest_on_session_msg_expect_json, g_test_para); - stellar_run(st); stellar_free(st); @@ -157,6 +130,6 @@ int main(int argc, char ** argv) EXPECT_EQ(gtest_result_compare(g_test_para), 1); gtest_result_free(g_test_para); - + return ::testing::Test::HasFailure() ? 1 : 0; }
\ No newline at end of file diff --git a/test/decoders/qdpi_detector/gtest_qdpi_detector_module.cpp b/test/decoders/qdpi_detector/gtest_qdpi_detector_module.c index 412492d..859da23 100644 --- a/test/decoders/qdpi_detector/gtest_qdpi_detector_module.cpp +++ b/test/decoders/qdpi_detector/gtest_qdpi_detector_module.c @@ -1,5 +1,4 @@ #include <stdio.h> -#include <cstdlib> #include <time.h> #include <unistd.h> #include <assert.h> @@ -17,12 +16,8 @@ struct gtest_qdpi_detector_module_env { - int topic_id; int exdata_idx; - int plugin_id; int session_id; - int expect_json_topic_id; - struct module_manager *mod_mgr; }; struct gtest_qdpi_detector_context @@ -37,6 +32,14 @@ struct gtest_qdpi_detector_map const char *name; }; +struct gtest_qdpi_detector_result +{ + int n_result_jsoon; + cJSON *result_json[16]; +}; + +struct gtest_qdpi_detector_result gtest_result_json; + struct gtest_qdpi_detector_map __str_std_app_id_map[]= { {Q_PROTO_HTTP, "http"}, {Q_PROTO_HTTPS, "https"}, @@ -114,11 +117,19 @@ error_out: } #endif -cJSON *g_result_json=NULL; char *gtest_qdpi_result_json_export() { - if(g_result_json==NULL)return NULL; - return cJSON_Print(g_result_json); + cJSON *test_json_root=cJSON_CreateArray(); + for(int i=1; i<=gtest_result_json.n_result_jsoon; i++) + { + char result_name[128] = ""; + sprintf(result_name, "app_session_%d", i); + cJSON_AddStringToObject(gtest_result_json.result_json[i], "name", result_name); + cJSON_AddItemToArray(test_json_root, gtest_result_json.result_json[i]); + } + char *data=cJSON_Print(test_json_root); + cJSON_Delete(test_json_root); + return data; } static void gtest_qdpi_stellar_exdata_free(int idx __unused, void *ex_ptr, void *arg __unused) @@ -126,11 +137,6 @@ static void gtest_qdpi_stellar_exdata_free(int idx __unused, void *ex_ptr, void if(ex_ptr)FREE(ex_ptr); } -static void gtest_qdpi_stellar_msg_free(void *msg, void *msg_free_arg __unused) -{ - if(msg)FREE(msg); -} - static void gtest_qdpi_detector_on_session_msg(struct session *sess, enum session_state state, struct packet *pkt, void *args) { struct gtest_qdpi_detector_module_env *gtest_qdpi_env = (struct gtest_qdpi_detector_module_env *)args; @@ -162,8 +168,8 @@ static void gtest_qdpi_detector_on_session_msg(struct session *sess, enum sessio { char app[64] = {0}; sprintf(app, "app_session_%d", gtest_qdpi_env->session_id); - g_result_json=cJSON_Duplicate(context_gtest->result, 1); - //mq_runtime_publish_message(module_manager_get_mq_runtime(gtest_qdpi_env->mod_mgr), gtest_qdpi_env->expect_json_topic_id, cJSON_Print(context_gtest->result)); + gtest_result_json.n_result_jsoon++; + gtest_result_json.result_json[gtest_result_json.n_result_jsoon]=cJSON_Duplicate(context_gtest->result, 1); cJSON_Delete(context_gtest->result); } @@ -261,7 +267,7 @@ void *gtest_qdpi_detector_context_new(struct session *sess, void *plugin_env) return context_gtest; } -extern "C" void gtest_qdpi_detector_module_exit(struct module_manager *mod_mgr __unused, struct module *mod) +void gtest_qdpi_detector_module_exit(struct module_manager *mod_mgr __unused, struct module *mod) { assert(mod_mgr!=NULL); assert(mod!=NULL); @@ -275,20 +281,20 @@ extern "C" void gtest_qdpi_detector_module_exit(struct module_manager *mod_mgr _ return; } -extern "C" struct module *gtest_qdpi_detector_module_init(struct module_manager *mod_mgr) +struct module *gtest_qdpi_detector_module_init(struct module_manager *mod_mgr) { //firewall_maat = create_maat_feather(stellar_get_worker_thread_num(st)); struct gtest_qdpi_detector_module_env *gtest_qdpi_env = ALLOC(struct gtest_qdpi_detector_module_env, 1); struct module *mod=module_new("QDPI_GTEST_MODULE", gtest_qdpi_env); - struct session_manager *sess_mgr=module_to_session_manager(mod); + struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME); + struct session_manager *sess_mgr=module_to_session_manager(sess_mgr_mod); struct mq_schema *mq_s=module_manager_get_mq_schema(mod_mgr); if(sess_mgr==NULL || mq_s==NULL) { perror("gtest_qdpi_detector_module_init:module_to_session_manager failed !!!\n"); goto finish; } - gtest_qdpi_env->mod_mgr=mod_mgr; session_manager_subscribe_udp(sess_mgr, gtest_qdpi_detector_on_session_msg, gtest_qdpi_env); session_manager_subscribe_tcp(sess_mgr, gtest_qdpi_detector_on_session_msg, gtest_qdpi_env); @@ -302,8 +308,6 @@ extern "C" struct module *gtest_qdpi_detector_module_init(struct module_manager stellar_appid_subscribe(mod_mgr, gtest_qdpi_detector_plugin_on_session_msg, gtest_qdpi_env); printf("gtest_qdpi_detector_module_init OK!\n"); - gtest_qdpi_env->expect_json_topic_id = mq_schema_create_topic(module_manager_get_mq_schema(gtest_qdpi_env->mod_mgr), "EXPECT_JSON", NULL, NULL, gtest_qdpi_stellar_msg_free, NULL); - return mod; finish: diff --git a/vendors/CMakeLists.txt b/vendors/CMakeLists.txt index 4af3155..bf5d731 100644 --- a/vendors/CMakeLists.txt +++ b/vendors/CMakeLists.txt @@ -99,22 +99,6 @@ set_property(TARGET libevent-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/li set_property(TARGET libevent-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) set_property(TARGET libevent-static PROPERTY INTERFACE_LINK_LIBRARIES pthread) -###libqmengine -ExternalProject_Add(tsgengine PREFIX tsgengine - URL ${CMAKE_CURRENT_SOURCE_DIR}/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz - URL_MD5 335262f6ac0726fee75e4efcb449be24 - CONFIGURE_COMMAND "" - BUILD_COMMAND make - BUILD_IN_SOURCE 1) - -ExternalProject_Get_Property(tsgengine INSTALL_DIR) -file(MAKE_DIRECTORY ${INSTALL_DIR}/include) - -add_library(tsgengine-static STATIC IMPORTED GLOBAL) -add_dependencies(tsgengine-static tsgengine) -set_property(TARGET tsgengine-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libqmengine.a.5.7.0-43) -set_property(TARGET tsgengine-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) - ### OpenSSL 1.1.1m ExternalProject_Add(openssl PREFIX openssl URL ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1m.tar.gz @@ -138,4 +122,22 @@ set_property(TARGET openssl-crypto-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES add_library(openssl-ssl-static STATIC IMPORTED GLOBAL) add_dependencies(openssl-ssl-static openssl) set_property(TARGET openssl-ssl-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libssl.a) -set_property(TARGET openssl-ssl-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
\ No newline at end of file +set_property(TARGET openssl-ssl-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) + +###libqmengine +ExternalProject_Add(tsgengine PREFIX tsgengine + URL ${CMAKE_CURRENT_SOURCE_DIR}/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz + URL_MD5 885142d147d804fb83941151c6ead689 + CONFIGURE_COMMAND "" + BUILD_COMMAND make + BUILD_IN_SOURCE 1) + +ExternalProject_Get_Property(tsgengine INSTALL_DIR) +file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + +add_library(libqmengine-shared SHARED IMPORTED GLOBAL) +add_dependencies(libqmengine-shared tsgengine) +set_property(TARGET libqmengine-shared PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libqmengine.so.5) +set_property(TARGET libqmengine-shared PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) +add_custom_target(libqmengine_install ALL COMMAND ${CMAKE_COMMAND} -E copy ${INSTALL_DIR}/lib/libqmengine.so.5 /opt/MESA/lib DEPENDS tsgengine) +add_dependencies(libqmengine-shared libqmengine_install)
\ No newline at end of file diff --git a/vendors/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz b/vendors/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz Binary files differindex ab3ddc7..7ea8831 100644 --- a/vendors/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz +++ b/vendors/libqmengine-5.7.0-43-LSB-SMP-NG.tar.gz |
