summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author刘学利 <[email protected]>2023-09-27 09:52:39 +0000
committer刘学利 <[email protected]>2023-09-27 09:52:39 +0000
commitfb1fb4d3671ebf3bbc049f247410732e3d4080e7 (patch)
tree8dc10376e14584528d966269ed5dc2477404d99d
parent19656a626a600b5b265eb6b21f5aab5e55f5c537 (diff)
TSG-17219: 支持从动态库表中获取IP/Port到Subscriber ID的映射关系v6.0.51
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--CMakeLists.txt4
-rw-r--r--bin/maat.conf27
-rw-r--r--bin/main.conf1
-rw-r--r--bin/tsg_dynamic_maat.json12
-rw-r--r--bin/tsg_dynamic_mapping_maat.json12
-rw-r--r--bin/tsg_dynamic_mapping_tableinfo.json15
-rw-r--r--ctest/CMakeLists.txt3
-rw-r--r--src/tsg_rule.cpp118
-rw-r--r--src/tsg_rule_internal.h3
-rw-r--r--src/tsg_send_log.cpp9
-rw-r--r--test/bin/gtest_dyn_mapping_maat.json14
-rw-r--r--test/src/gtest_master.cpp26
-rw-r--r--test/src/gtest_rule.cpp88
-rw-r--r--test/src/gtest_sendlog.cpp20
15 files changed, 298 insertions, 56 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 199759a..90cd2b9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,7 +4,7 @@ variables:
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
INSTALL_PREFIX: "/home/mesasoft/sapp_run/"
- INSTALL_DEPENDENCY_LIBRARY: systemd-devel libbreakpad_mini numactl-devel zlib-devel vim-common libMESA_handle_logger-devel libcjson-devel libMESA_field_stat2-devel sapp sapp-devel framework_env libMESA_prof_load-devel http-devel dns-devel ftp-devel mail-devel ssl-devel librdkafka-devel libmaat4-4.0.31.73887d5 libmaat4-devel-4.0.31.73887d5 quic-devel mesa_sip-devel gtp-devel libMESA_htable-devel libasan mrzcpd rapidjson-devel libMESA_jump_layer-devel stratum-devel rdp-devel dtls-devel-1.0.10.ab7166e libfieldstat3-devel openssl-devel
+ INSTALL_DEPENDENCY_LIBRARY: systemd-devel libbreakpad_mini numactl-devel zlib-devel vim-common libMESA_handle_logger-devel libcjson-devel libMESA_field_stat2-devel sapp sapp-devel framework_env libMESA_prof_load-devel http-devel dns-devel ftp-devel mail-devel ssl-devel librdkafka-devel libmaat4 libmaat4-devel quic-devel mesa_sip-devel gtp-devel libMESA_htable-devel libasan mrzcpd rapidjson-devel libMESA_jump_layer-devel stratum-devel rdp-devel dtls-devel-1.0.10.ab7166e libfieldstat3-devel openssl-devel
stages:
- analysis
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6a2582..24d4eb5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,12 +78,14 @@ install(FILES bin/main.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONEN
install(FILES bin/maat.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/tsg_static_tableinfo.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/tsg_static_tableinfo.json DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
-install(FILES bin/tsg_dynamic_tableinfo.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/tsg_log_field.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/app_l7_proto_id.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/tsg_l7_protocol.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/tsg_maat.json DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
+install(FILES bin/tsg_dynamic_mapping_tableinfo.json DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
+install(FILES bin/tsg_dynamic_mapping_maat.json DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
+
install(FILES bin/HTTP200.html DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/HTTP204.html DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
install(FILES bin/HTTP303.html DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf COMPONENT PROFILE)
diff --git a/bin/maat.conf b/bin/maat.conf
index 4e826f0..41a8f0d 100644
--- a/bin/maat.conf
+++ b/bin/maat.conf
@@ -10,15 +10,16 @@ RULE_UPDATE_CHECK_INTERVAL_MS=1000
REDIS_IP=127.0.0.1
REDIS_PORT_NUM=1
REDIS_PORT=7002
-REDIS_INDEX=0
+REDIS_INDEX=1
JSON_CFG_FILE=tsgconf/tsg_maat.json
INC_CFG_DIR=tsgrule/inc/index/
FULL_CFG_DIR=tsgrule/full/index/
EFFECTIVE_RANGE_FILE=/opt/tsg/etc/tsg_device_tag.json
LOG_LEVEL=0
+LOG_PATH="log/master.maat"
[APP_SIGNATURE_MAAT]
-MAAT_MODE=1
+MAAT_MODE=json
STAT_SWITCH=1
PERF_SWITCH=1
TABLE_INFO=tsgconf/app_sketch_tableinfo.conf
@@ -27,11 +28,31 @@ EFFECT_INTERVAL_S=1
REDIS_IP=127.0.0.1
REDIS_PORT_NUM=1
REDIS_PORT=7002
-REDIS_INDEX=0
+REDIS_INDEX=1
JSON_CFG_FILE=tsgconf/app_sketch_maat.json
INC_CFG_DIR=tsgrule/inc/index/
FULL_CFG_DIR=tsgrule/full/index/
EFFECTIVE_RANGE_FILE=/opt/tsg/etc/tsg_device_tag.json
+LOG_LEVEL=0
+LOG_PATH="log/app_sketch.maat"
+
+[DYNAMIC_MAPPING_MAAT]
+MAAT_MODE=json
+STAT_SWITCH=1
+PERF_SWITCH=1
+TABLE_INFO=tsgconf/tsg_dynamic_mapping_tableinfo.json
+STAT_FILE=log/dynamic.mapping.maat.status
+EFFECT_INTERVAL_S=1
+REDIS_IP=127.0.0.1
+REDIS_PORT_NUM=1
+REDIS_PORT=7002
+REDIS_INDEX=1
+JSON_CFG_FILE=tsgconf/tsg_dynamic_mapping_maat.json
+INC_CFG_DIR=tsgrule/inc/index/
+FULL_CFG_DIR=tsgrule/full/index/
+EFFECTIVE_RANGE_FILE=/opt/tsg/etc/tsg_device_tag.json
+LOG_LEVEL=0
+LOG_PATH="log/dynamic.mapping.maat"
[CAPTURE]
MAAT_MODE=1
diff --git a/bin/main.conf b/bin/main.conf
index 6f949bb..6904ccc 100644
--- a/bin/main.conf
+++ b/bin/main.conf
@@ -2,6 +2,7 @@
LOG_LEVEL=10
LOG_PATH="log/master.maat.log"
PROFILE="./tsgconf/maat.conf"
+DYNAMIC_MAPPING_MAAT_SWITCH=1
[TSG_LOG]
MODE=1
diff --git a/bin/tsg_dynamic_maat.json b/bin/tsg_dynamic_maat.json
deleted file mode 100644
index 9faafdb..0000000
--- a/bin/tsg_dynamic_maat.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "plugin_table":
- [
- {
- "table_name": "TSG_DYN_SUBSCRIBER_IP",
- "table_content": [
- "1052\t4\t192.168.50.52\ttest52\t1",
- "1037\t4\t192.168.50.37\test37\t1"
- ]
- }
- ]
-} \ No newline at end of file
diff --git a/bin/tsg_dynamic_mapping_maat.json b/bin/tsg_dynamic_mapping_maat.json
new file mode 100644
index 0000000..eead3e1
--- /dev/null
+++ b/bin/tsg_dynamic_mapping_maat.json
@@ -0,0 +1,12 @@
+{
+ "plugin_table":
+ [
+ {
+ "table_name": "TSG_DYN_IPPORT_SUBSCRIBER_MAPPING",
+ "table_content": [
+ "1052\t4\t192.168.50.52\ttest52\t0\t255\t1",
+ "1037\t4\t192.168.50.37\ttest37\t40001\t40255\t1"
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/bin/tsg_dynamic_mapping_tableinfo.json b/bin/tsg_dynamic_mapping_tableinfo.json
new file mode 100644
index 0000000..b04014d
--- /dev/null
+++ b/bin/tsg_dynamic_mapping_tableinfo.json
@@ -0,0 +1,15 @@
+[
+ {
+ "table_id":0,
+ "table_name":"TSG_DYN_IPPORT_SUBSCRIBER_MAPPING",
+ "table_type":"ipport_plugin",
+ "valid_column":7,
+ "custom": {
+ "item_id":1,
+ "ip_type":2,
+ "ip_addr":3,
+ "port1":5,
+ "port2":6
+ }
+ }
+] \ No newline at end of file
diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt
index 5f482e9..a7329fc 100644
--- a/ctest/CMakeLists.txt
+++ b/ctest/CMakeLists.txt
@@ -12,6 +12,9 @@ add_test(NAME COPY_GTEST_MAAT_RULE COMMAND sh -c "cp -r ${CMAKE_SOURCE_DIR}/test
add_test(NAME COPY_GTEST_PROFILE_RESPONSE_PAGES COMMAND sh -c "cp -r ${CMAKE_SOURCE_DIR}/test/bin/foreign_files ${CMAKE_BINARY_DIR}/testing/")
add_test(NAME COPY_GTEST_PROXY_PCAP COMMAND sh -c "cp -r ${CMAKE_SOURCE_DIR}/test/pcap ${CMAKE_BINARY_DIR}/testing/")
+add_test(NAME COPY_GTEST_DYN_TABLEINFO COMMAND sh -c "cp -r ${CMAKE_SOURCE_DIR}/bin/tsg_dynamic_mapping_tableinfo.json ${CMAKE_BINARY_DIR}/testing/tsgconf/")
+add_test(NAME COPY_GTEST_DYN_MAAT_RULE COMMAND sh -c "cp -r ${CMAKE_SOURCE_DIR}/test/bin/gtest_dyn_mapping_maat.json ${CMAKE_BINARY_DIR}/testing/tsgconf/tsg_dynamic_mapping_maat.json")
+
add_test(NAME COPY_GTEST_TABLEINFO_BIN COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/test/src/gtest_tableinfo ${CMAKE_BINARY_DIR}/testing/")
add_test(NAME COPY_GTEST_RULE_BIN COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/test/src/gtest_rule ${CMAKE_BINARY_DIR}/testing/")
add_test(NAME COPY_GTEST_BRIDGE_BIN COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/test/src/gtest_bridge ${CMAKE_BINARY_DIR}/testing/")
diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp
index 4f1068d..5d330a1 100644
--- a/src/tsg_rule.cpp
+++ b/src/tsg_rule.cpp
@@ -28,6 +28,7 @@ struct str2index
};
struct maat *g_tsg_maat_feather;
+struct maat *g_tsg_dyn_mapping_maat_feather;
struct maat_runtime_para g_tsg_maat_rt_para;
const struct str2index method2index[TSG_METHOD_TYPE_MAX]={ {TSG_METHOD_TYPE_UNKNOWN, 7, (char *)"unknown"},
@@ -423,7 +424,7 @@ void ex_data_gtp_c_dup(int table_id, void **to, void **from, long argl, void* ar
if((*from)!=NULL)
{
struct umts_user_info *user_info=(struct umts_user_info *)(*from);
- atomic_inc(&user_info->ref_cnt);
+ __sync_add_and_fetch(&user_info->ref_cnt, 1);
*to=*from;
}
@@ -445,7 +446,7 @@ void ex_data_gtp_c_new(const char *table_name, int table_id, const char* key, co
tsg_str_unescape(user_info->apn);
tsg_str_unescape(user_info->imei);
- atomic_inc(&user_info->ref_cnt);
+ __sync_add_and_fetch(&user_info->ref_cnt, 1);
*ad=(void *)user_info;
tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_GTPC, 1);
@@ -484,7 +485,7 @@ void ex_data_asn_number_dup(int table_id, void **to, void **from, long argl, voi
if((*from)!=NULL)
{
struct asn_info *asn=(struct asn_info *)(*from);
- atomic_inc(&asn->ref_cnt);
+ __sync_add_and_fetch(&asn->ref_cnt, 1);
*to=*from;
}
@@ -511,7 +512,7 @@ void ex_data_asn_number_new(const char *table_name, int table_id, const char* ke
tsg_str_unescape(asn->asn_id);
tsg_str_unescape(asn->organization);
- atomic_inc(&asn->ref_cnt);
+ __sync_add_and_fetch(&asn->ref_cnt, 1);
*ad=(void *)asn;
tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_ASN, 1);
@@ -547,7 +548,7 @@ void ex_data_location_dup(int table_id, void **to, void **from, long argl, void*
if((*from)!=NULL)
{
struct location_info *location=(struct location_info *)(*from);
- atomic_inc(&location->ref_cnt);
+ __sync_add_and_fetch(&location->ref_cnt, 1);
*to=*from;
}
@@ -584,7 +585,7 @@ void ex_data_location_new(const char *table_name, int table_id, const char* key,
location->full_location[location->full_location_len]='\0';
}
- atomic_inc(&location->ref_cnt);
+ __sync_add_and_fetch(&location->ref_cnt, 1);
*ad=(void *)location;
tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_LOCATION, 1);
@@ -658,8 +659,8 @@ void ex_data_subscriber_id_dup(int table_id, void **to, void **from, long argl,
{
if((*from)!=NULL)
{
- struct subscribe_id_info *subscribe_id=(struct subscribe_id_info *)(*from);
- atomic_inc(&subscribe_id->ref_cnt);
+ struct subscribe_id_info *subscriber=(struct subscribe_id_info *)(*from);
+ __sync_add_and_fetch(&subscriber->ref_cnt, 1);
*to=*from;
}
@@ -680,7 +681,7 @@ void ex_data_subscriber_id_new(const char *table_name, int table_id, const char*
return;
}
- atomic_inc(&subscriber->ref_cnt);
+ __sync_add_and_fetch(&subscriber->ref_cnt, 1);
*ad=(void *)subscriber;
tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_SUBSCRIBER, 1);
@@ -707,7 +708,7 @@ void ex_data_subscriber_id_free(int table_id, void **ad, long argl, void* argp)
void plugin_ex_data_subscriber_id_free(struct subscribe_id_info *subscriber)
{
- ex_data_subscriber_id_free(g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, (void **)&subscriber, 0, NULL);
+ ex_data_subscriber_id_free(-1, (void **)&subscriber, 0, NULL);
}
static int parse_security_deny_action(char *deny_action_str, struct deny_user_region *deny_app_para)
@@ -1690,7 +1691,7 @@ void ex_data_tunnel_endpoint_new(const char *table_name, int table_id, const cha
t_endpoint->id=column_integer_get_value(table_line, 1);
t_endpoint->description=column_string_get_value(table_line, 5);
- atomic_inc(&t_endpoint->ref_cnt);
+ __sync_add_and_fetch(&t_endpoint->ref_cnt, 1);
*ad=(void *)t_endpoint;
tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_TUNNEL_ENDPOINT, 1);
@@ -1703,7 +1704,7 @@ void ex_data_tunnel_endpoint_dup(int table_id, void **to, void **from, long argl
if((*from)!=NULL)
{
struct tunnel_endpoint *t_endpoint=(struct tunnel_endpoint *)(*from);
- atomic_inc(&t_endpoint->ref_cnt);
+ __sync_add_and_fetch(&t_endpoint->ref_cnt, 1);
(*to)=(*from);
}
@@ -1839,6 +1840,7 @@ int init_plugin_table(struct maat *feather, const char *conffile)
g_tsg_maat_rt_para.plugin_tb[i].id=maat_get_table_id(feather, g_tsg_maat_rt_para.plugin_tb[i].name);
if(g_tsg_maat_rt_para.plugin_tb[i].id<0)
{
+ MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, LOG_MODULE_MAAT, "maat_table_get_id failed, table_name: %s", g_tsg_maat_rt_para.plugin_tb[i].name);
return -1;
}
@@ -1852,6 +1854,7 @@ int init_plugin_table(struct maat *feather, const char *conffile)
);
if(ret<0)
{
+ MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, LOG_MODULE_MAAT, "maat_plugin_table_ex_schema_register failed, table_name: %s", g_tsg_maat_rt_para.plugin_tb[i].name);
return -1;
}
}
@@ -1859,6 +1862,34 @@ int init_plugin_table(struct maat *feather, const char *conffile)
return 0;
}
+int init_dynamic_mapping_plugin_table(struct maat *feather, const char *conffile)
+{
+ MESA_load_profile_string_def(conffile, "MAAT", "DYN_MAPPING_SUBSCRIBER", g_tsg_maat_rt_para.plugin_dyn_mapping_tb.name, MAX_TABLE_NAME_LEN, (char *)"TSG_DYN_IPPORT_SUBSCRIBER_MAPPING");
+
+ g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id=maat_get_table_id(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.name);
+ if(g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id<0)
+ {
+ MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, LOG_MODULE_MAAT, "maat_table_get_id failed, table_name: %s", g_tsg_maat_rt_para.plugin_dyn_mapping_tb.name);
+ return -1;
+ }
+
+ int ret=maat_plugin_table_ex_schema_register(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.name,
+ ex_data_subscriber_id_new,
+ ex_data_subscriber_id_free,
+ ex_data_subscriber_id_dup,
+ 0,
+ NULL
+ );
+
+ if(ret<0)
+ {
+ MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, LOG_MODULE_MAAT, "maat_plugin_table_ex_schema_register failed, table_name: %s", g_tsg_maat_rt_para.plugin_dyn_mapping_tb.name);
+ return -1;
+ }
+
+ return 0;
+}
+
struct maat *init_maat_feather(const char* conffile, char* instance_name, char *module)
{
int deferred_load=0;
@@ -2025,6 +2056,25 @@ int tsg_maat_rule_init(const char* conffile)
return -1;
}
+ MESA_load_profile_int_def(conffile, "MAAT", "DYNAMIC_MAPPING_MAAT_SWITCH", &g_tsg_maat_rt_para.dynamic_mapping_maat_switch, 0);
+ if(g_tsg_maat_rt_para.dynamic_mapping_maat_switch==0)
+ {
+ MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, LOG_MODULE_MAAT, "Disable DYNAMIC_MAPPING_MAAT, Check tsgconf/main.conf -> [MAAT] -> DYNAMIC_MAPPING_MAAT_SWITCH");
+ return 0;
+ }
+
+ g_tsg_dyn_mapping_maat_feather=init_maat_feather(maat_conffile, (char *)"DYNAMIC_MAPPING_MAAT", (char *)"DYNAMIC_MAPPING_MAAT");
+ if(g_tsg_dyn_mapping_maat_feather==NULL)
+ {
+ return -1;
+ }
+
+ ret=init_dynamic_mapping_plugin_table(g_tsg_dyn_mapping_maat_feather, conffile);
+ if(ret<0)
+ {
+ return -1;
+ }
+
return 0;
}
@@ -2206,6 +2256,43 @@ int srt_attribute_set_subscriber_id(const struct streaminfo *a_stream, struct ma
return 0;
}
+int srt_attribute_set_dyn_mapping_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **source_subscribe_id, struct subscribe_id_info **dest_subscribe_id)
+{
+ struct ip_addr dest_ip={0}, source_ip={0};
+ int ret=ip_address_convert(a_stream, &source_ip, &dest_ip);
+ if(ret==0)
+ {
+ return 0;
+ }
+
+ unsigned int dest_port=0, source_port=0;
+ switch(a_stream->addr.addrtype)
+ {
+ case ADDR_TYPE_IPV4:
+ dest_port=a_stream->addr.tuple4_v4->dest;
+ source_port=a_stream->addr.tuple4_v4->source;
+ break;
+ case ADDR_TYPE_IPV6:
+ dest_port=a_stream->addr.tuple4_v6->dest;
+ source_port=a_stream->addr.tuple4_v6->source;
+ break;
+ default:
+ return 0;
+ }
+
+ if(*dest_subscribe_id==NULL)
+ {
+ maat_ipport_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id, &dest_ip, dest_port, (void **)dest_subscribe_id, 1);
+ }
+
+ if(*source_subscribe_id==NULL)
+ {
+ maat_ipport_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id, &source_ip, source_port, (void **)source_subscribe_id, 1);
+ }
+
+ return 0;
+}
+
size_t matche_rules_convert(struct maat *feather,long long *rules, size_t n_rules, struct maat_rule *matched_rules, size_t n_matched_rules)
{
size_t offset=0;
@@ -2878,6 +2965,13 @@ size_t tsg_scan_nesting_addr(const struct streaminfo *a_stream, struct maat *fea
matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->server_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
}
+ if(matched_cnt<n_matched_rules && g_tsg_maat_rt_para.dynamic_mapping_maat_switch==1)
+ {
+ srt_attribute_set_dyn_mapping_subscriber_id(a_stream, g_tsg_dyn_mapping_maat_feather, &srt_attribute->client_subscribe_id, &srt_attribute->server_subscribe_id);
+ matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->client_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->server_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ }
+
if(matched_cnt<n_matched_rules)
{
int ret=session_runtine_attribute_get_umts_user_info(a_stream, &(srt_attribute->user_info));
diff --git a/src/tsg_rule_internal.h b/src/tsg_rule_internal.h
index d3f83be..8fd2926 100644
--- a/src/tsg_rule_internal.h
+++ b/src/tsg_rule_internal.h
@@ -106,11 +106,13 @@ struct maat_runtime_para
int level;
int default_compile_id;
int session_record_switch;
+ int dynamic_mapping_maat_switch;
char data_center[MAX_STRING_LEN128];
char device_tag[MAX_STRING_LEN128];
struct mirrored_vlan default_vlan;
struct maat_scan_table scan_tb[MAAT_SCAN_MAX];
struct maat_plugin_table plugin_tb[MAAT_PLUGIN_MAX];
+ struct maat_plugin_table plugin_dyn_mapping_tb;
void *logger;
};
@@ -139,6 +141,7 @@ void tsg_maat_state_free(struct maat_state *state);
int srt_attribute_set_ip_asn(const struct streaminfo *a_stream, struct maat *feather, struct asn_info **client_asn, struct asn_info **server_asn);
int srt_attribute_set_ip_location(const struct streaminfo *a_stream, struct maat *feather, struct location_info **client_location, struct location_info **server_location);
int srt_attribute_set_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **client_subscriber_id, struct subscribe_id_info **server_subscriber_id);
+int srt_attribute_set_dyn_mapping_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **source_subscribe_id, struct subscribe_id_info **dest_subscribe_id);
int session_runtine_attribute_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_info **user_info);
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index 25dabf9..198ea53 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -430,13 +430,13 @@ static int set_duraction(struct tsg_log_instance_t *_instance, struct TLD_handle
{
time_t cur_time=time(NULL);
TLD_append(_handle, _instance->id2field[LOG_COMMON_START_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
- TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
- TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(0), TLD_TYPE_LONG);
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_END_TIME].name, (void *)cur_time, TLD_TYPE_LONG);
}
int ret=MESA_get_stream_opt(a_stream, MSO_STREAM_CREATE_TIMESTAMP_MS, (void *)&create_time_ms, &size);
if(ret<0)
{
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(0), TLD_TYPE_LONG);
return 0;
}
@@ -445,6 +445,7 @@ static int set_duraction(struct tsg_log_instance_t *_instance, struct TLD_handle
ret=MESA_get_stream_opt(a_stream, MSO_STREAM_LASTUPDATE_TIMESTAMP_MS, (void *)&last_time_ms, &size);
if(ret<0)
{
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(0), TLD_TYPE_LONG);
return 0;
}
@@ -455,6 +456,10 @@ static int set_duraction(struct tsg_log_instance_t *_instance, struct TLD_handle
unsigned long long common_con_duration_ms=last_time_ms-create_time_ms;
TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(common_con_duration_ms), TLD_TYPE_LONG);
}
+ else
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_CON_DURATION_MS].name, (void *)(0), TLD_TYPE_LONG);
+ }
return 1;
}
diff --git a/test/bin/gtest_dyn_mapping_maat.json b/test/bin/gtest_dyn_mapping_maat.json
new file mode 100644
index 0000000..91157e2
--- /dev/null
+++ b/test/bin/gtest_dyn_mapping_maat.json
@@ -0,0 +1,14 @@
+{
+ "plugin_table":
+ [
+ {
+ "table_name": "TSG_DYN_IPPORT_SUBSCRIBER_MAPPING",
+ "table_content": [
+ "1052\t4\t192.168.50.52\ttest52\t0\t255\t1",
+ "1037\t4\t192.168.50.37\ttest37\t40001\t40255\t1",
+ "1040\t6\t1030::C9B4:FF12:48AA:1040\ttest1040\t10240\t12800\t1",
+ "1041\t6\t1030::C9B4:FF12:3799:1041\ttest1041\t25600\t25856\t1"
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/src/gtest_master.cpp b/test/src/gtest_master.cpp
index d760d01..294faf7 100644
--- a/test/src/gtest_master.cpp
+++ b/test/src/gtest_master.cpp
@@ -303,15 +303,15 @@ TEST(TSGMaster, SecurityPolicySendlog)
int sendlog_cnt=rd_kafka_get_sendlog_cnt();
EXPECT_EQ(9, sendlog_cnt);
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":8,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(0));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":7,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(1));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":6,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(2));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":5,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(3));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":4,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(4));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":3,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(5));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":2,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(6));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":1,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(7));
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}", rd_kafka_get_sendlog_payload(8));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":8,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":7,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(1));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":6,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(2));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":5,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(3));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":4,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(4));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":3,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(5));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":2,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(6));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_policy_id\":1,\"common_service\":0,\"common_vsys_id\":0,\"common_action\":1}", rd_kafka_get_sendlog_payload(7));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}", rd_kafka_get_sendlog_payload(8));
rd_kafka_clean_sendlog_cnt();
@@ -857,9 +857,9 @@ TEST(TSGMaster, InterceptPolicySendLog)
int sendlog_cnt=rd_kafka_get_sendlog_cnt();
EXPECT_EQ(2, sendlog_cnt);
// intercept
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"intercept_pinning_status\":0,\"intercept_cert_verify\":1,\"intercept_status\":1,\"intercept_server_side_latency\":10,\"intercept_client_side_latency\":20,\"intercept_server_side_version\":\"upstream_version\",\"intercept_client_side_version\":\"downstream_version\",\"intercept_error\":\"error\",\"intercept_passthrough_reason\":\"passthrough_reason\",\"common_vsys_id\":1}", rd_kafka_get_sendlog_payload(1));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"intercept_pinning_status\":0,\"intercept_cert_verify\":1,\"intercept_status\":1,\"intercept_server_side_latency\":10,\"intercept_client_side_latency\":20,\"intercept_server_side_version\":\"upstream_version\",\"intercept_client_side_version\":\"downstream_version\",\"intercept_error\":\"error\",\"intercept_passthrough_reason\":\"passthrough_reason\",\"common_vsys_id\":1}", rd_kafka_get_sendlog_payload(1));
// session record
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"intercept_pinning_status\":0,\"intercept_cert_verify\":1,\"intercept_status\":1,\"intercept_server_side_latency\":10,\"intercept_client_side_latency\":20,\"intercept_server_side_version\":\"upstream_version\",\"intercept_client_side_version\":\"downstream_version\",\"intercept_error\":\"error\",\"intercept_passthrough_reason\":\"passthrough_reason\",\"common_policy_id\":2,\"common_service\":3,\"common_vsys_id\":0,\"common_action\":2}", rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"intercept_pinning_status\":0,\"intercept_cert_verify\":1,\"intercept_status\":1,\"intercept_server_side_latency\":10,\"intercept_client_side_latency\":20,\"intercept_server_side_version\":\"upstream_version\",\"intercept_client_side_version\":\"downstream_version\",\"intercept_error\":\"error\",\"intercept_passthrough_reason\":\"passthrough_reason\",\"common_policy_id\":2,\"common_service\":3,\"common_vsys_id\":0,\"common_action\":2}", rd_kafka_get_sendlog_payload(0));
session_log_update_data_put(&a_stream, TSG_SERVICE_INTERCEPT, NULL);
rd_kafka_clean_sendlog_cnt();
@@ -907,7 +907,7 @@ TEST(TSGMaster, ServiceChainingPolicySendLog)
int sendlog_cnt=rd_kafka_get_sendlog_cnt();
EXPECT_EQ(1, sendlog_cnt);
// session record
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_vsys_id\":1,\"sce_profile_ids\":[1,2,3,4,5,6,7,8]}", rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_vsys_id\":1,\"sce_profile_ids\":[1,2,3,4,5,6,7,8]}", rd_kafka_get_sendlog_payload(0));
session_log_update_data_put(&a_stream, TSG_SERVICE_CHAINING, NULL);
rd_kafka_clean_sendlog_cnt();
@@ -959,7 +959,7 @@ TEST(TSGMaster, ShapingPolicySendLog)
int sendlog_cnt=rd_kafka_get_sendlog_cnt();
EXPECT_EQ(1, sendlog_cnt);
// session record
- EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_vsys_id\":1,\"shaping_profile_ids\":[{\"rule_id\":32,\"profile_ids\":[1,2,3,4,5,6,7,8]}],\"common_shaping_rule_ids\":[32]}", rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_app_full_path\":\"unknown\",\"common_app_label\":\"unknown\",\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_device_tag\":\"{\\\"tags\\\":[{\\\"tag\\\":\\\"device_id\\\",\\\"value\\\":\\\"device_1\\\"}]}\",\"common_t_vsys_id\":1,\"common_vsys_id\":1,\"shaping_profile_ids\":[{\"rule_id\":32,\"profile_ids\":[1,2,3,4,5,6,7,8]}],\"common_shaping_rule_ids\":[32]}", rd_kafka_get_sendlog_payload(0));
session_log_update_data_put(&a_stream, TSG_SERVICE_SHAPING, NULL);
rd_kafka_clean_sendlog_cnt();
diff --git a/test/src/gtest_rule.cpp b/test/src/gtest_rule.cpp
index 751da0f..cf392ff 100644
--- a/test/src/gtest_rule.cpp
+++ b/test/src/gtest_rule.cpp
@@ -14,6 +14,7 @@
#include <gtest/gtest.h>
extern struct maat_runtime_para g_tsg_maat_rt_para;
+extern struct maat *g_tsg_dyn_mapping_maat_feather;
const struct session_runtime_attribute *session_runtime_attribute_new(const struct streaminfo * a_stream)
{
@@ -392,13 +393,96 @@ TEST(TM, ExDataSubscriberID)
source_subscribe_id = NULL;
struct stream_tuple4_v6 tuple4_v6 = {0};
a_stream.addr.tuple4_v6 = &tuple4_v6;
- inet_pton(AF_INET6, "1030::C9B4:FF12:48AA:1A2B", &tuple4_v6.daddr);
- inet_pton(AF_INET6, "1030::C9B4:FF12:3799:1A2B", &tuple4_v6.saddr);
+ inet_pton(AF_INET6, "1030::C9B4:FF12:48AA:1A2B", tuple4_v6.daddr);
+ inet_pton(AF_INET6, "1030::C9B4:FF12:3799:1A2B", tuple4_v6.saddr);
srt_attribute_set_subscriber_id(&a_stream, g_tsg_maat_feather, &source_subscribe_id, &dest_subscribe_id);
EXPECT_STREQ("test5630", dest_subscribe_id->subscribe_id);
EXPECT_STREQ("test5629", source_subscribe_id->subscribe_id);
}
+TEST(TM, ExDataDynamicIPPortMappingSubscriberID)
+{
+ /*************************************************************************************************************************
+ table name: TSG_DYN_IPPORT_SUBSCRIBER_MAPPING
+ id addr_type ip subscriber_id port_start port_end is_valid
+ "1052\t4\t192.168.50.52\ttest52\t0\t255\t1",
+ "1037\t4\t192.168.50.37\test37\t40001\t40255\t1",
+ "1040\t6\t1030::C9B4:FF12:48AA:1040\ttest1040\t10240\t12800\t1",
+ "1041\t6\t1030::C9B4:FF12:3799:1041\ttest1041\t25600\t25856\t1"
+ **************************************************************************************************************************/
+ struct streaminfo a_stream = {0};
+ struct subscribe_id_info *dest_subscribe_id = NULL;
+ struct subscribe_id_info *source_subscribe_id = NULL;
+ // ipv4
+ a_stream.addr.addrtype = ADDR_TYPE_IPV4;
+ struct stream_tuple4_v4 tuple4_v4 = {0};
+ a_stream.addr.tuple4_v4 = &tuple4_v4;
+ inet_pton(AF_INET, "192.168.50.52", &tuple4_v4.daddr);
+ inet_pton(AF_INET, "192.168.50.37", &tuple4_v4.saddr);
+
+ tuple4_v4.dest = htons(255); //port end
+ tuple4_v4.source = htons(40001); //port start
+ srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
+ EXPECT_STREQ("test52", dest_subscribe_id->subscribe_id);
+ EXPECT_STREQ("test37", source_subscribe_id->subscribe_id);
+
+ plugin_ex_data_subscriber_id_free(dest_subscribe_id);
+ plugin_ex_data_subscriber_id_free(source_subscribe_id);
+ dest_subscribe_id = NULL;
+ source_subscribe_id = NULL;
+
+ tuple4_v4.dest = htons(250); //port in range
+ tuple4_v4.source = htons(40025); //port in range
+ srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
+ EXPECT_STREQ("test52", dest_subscribe_id->subscribe_id);
+ EXPECT_STREQ("test37", source_subscribe_id->subscribe_id);
+
+ plugin_ex_data_subscriber_id_free(dest_subscribe_id);
+ plugin_ex_data_subscriber_id_free(source_subscribe_id);
+ dest_subscribe_id = NULL;
+ source_subscribe_id = NULL;
+
+ tuple4_v4.dest = htons(256); //port not in range
+ tuple4_v4.source = htons(40000); //port not in range
+ srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
+ EXPECT_EQ(nullptr, dest_subscribe_id);
+ EXPECT_EQ(nullptr, source_subscribe_id);
+
+ // ipv6
+ a_stream.addr.addrtype = ADDR_TYPE_IPV6;
+ struct stream_tuple4_v6 tuple4_v6 = {0};
+ a_stream.addr.tuple4_v6 = &tuple4_v6;
+ inet_pton(AF_INET6, "1030::C9B4:FF12:48AA:1040", tuple4_v6.daddr);
+ inet_pton(AF_INET6, "1030::C9B4:FF12:3799:1041", tuple4_v6.saddr);
+ tuple4_v6.dest = htons(12800); //port end
+ tuple4_v6.source = htons(25600); //port start
+ srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
+ EXPECT_STREQ("test1040", dest_subscribe_id->subscribe_id);
+ EXPECT_STREQ("test1041", source_subscribe_id->subscribe_id);
+
+ plugin_ex_data_subscriber_id_free(dest_subscribe_id);
+ plugin_ex_data_subscriber_id_free(source_subscribe_id);
+ dest_subscribe_id = NULL;
+ source_subscribe_id = NULL;
+
+ tuple4_v6.dest = htons(10244); //port in range
+ tuple4_v6.source = htons(25620); //port in range
+ srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
+ EXPECT_STREQ("test1040", dest_subscribe_id->subscribe_id);
+ EXPECT_STREQ("test1041", source_subscribe_id->subscribe_id);
+
+ plugin_ex_data_subscriber_id_free(dest_subscribe_id);
+ plugin_ex_data_subscriber_id_free(source_subscribe_id);
+ dest_subscribe_id = NULL;
+ source_subscribe_id = NULL;
+
+ tuple4_v6.dest = htons(10144); //port not in range
+ tuple4_v6.source = htons(15620); //port not in range
+ srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
+ EXPECT_EQ(nullptr, dest_subscribe_id);
+ EXPECT_EQ(nullptr, source_subscribe_id);
+}
+
TEST(TM, ExDataDNSRecordsProfileA)
{
/*************************************************************************************************************************
diff --git a/test/src/gtest_sendlog.cpp b/test/src/gtest_sendlog.cpp
index 9f3da60..3e7b293 100644
--- a/test/src/gtest_sendlog.cpp
+++ b/test/src/gtest_sendlog.cpp
@@ -176,7 +176,7 @@ TEST(Master, SendInterimRecord)
struct TLD_handle_t * handle=TLD_create(0);
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_INTERIM_SESSION_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
@@ -198,7 +198,7 @@ TEST(Master, SendTranscationRecord)
struct TLD_handle_t * handle=TLD_create(0);
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_TRANSACTION_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
@@ -220,7 +220,7 @@ TEST(Master, SendSessionRecord)
struct TLD_handle_t * handle=TLD_create(0);
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_SESSION_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
@@ -253,7 +253,7 @@ TEST(Master, SendSessionRecordWithHittedShunt)
struct TLD_handle_t * handle=TLD_create(0);
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_SESSION_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_vsys_id\":1}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
@@ -277,7 +277,7 @@ TEST(Master, SendInternalRtpRecord)
g_tsg_log_instance->vsystem_id=23;
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_INTERNAL_RTP_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":23,\"common_vsys_id\":23}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":23,\"common_vsys_id\":23}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
g_tsg_log_instance->vsystem_id=1;
@@ -295,7 +295,7 @@ TEST(Master, SendSecurityEvent)
struct TLD_handle_t * handle=TLD_create(0);
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_SECURITY_EVENT, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_policy_id\":25,\"common_service\":2,\"common_vsys_id\":25,\"common_action\":1}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_policy_id\":25,\"common_service\":2,\"common_vsys_id\":25,\"common_action\":1}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
}
@@ -312,7 +312,7 @@ TEST(Master, SendInterceptEvent)
struct TLD_handle_t * handle=TLD_create(0);
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_INTERCEPT_EVENT, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_policy_id\":26,\"common_service\":3,\"common_vsys_id\":26,\"common_action\":2}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":1,\"common_policy_id\":26,\"common_service\":3,\"common_vsys_id\":26,\"common_action\":2}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
}
@@ -330,7 +330,7 @@ TEST(Master, SendVoipRecord)
g_tsg_log_instance->vsystem_id=27;
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_VOIP_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":27,\"common_vsys_id\":27}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":27,\"common_vsys_id\":27}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
g_tsg_log_instance->vsystem_id=1;
@@ -349,7 +349,7 @@ TEST(Master, SendGtpCRecord)
g_tsg_log_instance->vsystem_id=28;
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_GTPC_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":28,\"common_vsys_id\":28}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":28,\"common_vsys_id\":28}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
g_tsg_log_instance->vsystem_id=1;
@@ -368,7 +368,7 @@ TEST(Master, SendBgpRecord)
g_tsg_log_instance->vsystem_id=29;
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_BGP_RECORD, &rules, 1, 0);
EXPECT_EQ(1, rd_kafka_get_sendlog_cnt());
- EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":29,\"common_vsys_id\":29}",rd_kafka_get_sendlog_payload(0));
+ EXPECT_STREQ("{\"common_server_port\":0,\"common_client_port\":0,\"common_stream_dir\":0,\"common_address_type\":0,\"common_start_timestamp_ms\":5,\"common_end_timestamp_ms\":5,\"common_con_duration_ms\":0,\"common_stream_trace_id\":\"5\",\"common_sled_ip\":\"0.0.0.0\",\"common_t_vsys_id\":29,\"common_vsys_id\":29}",rd_kafka_get_sendlog_payload(0));
rd_kafka_clean_sendlog_cnt();
EXPECT_EQ(0, rd_kafka_get_sendlog_cnt());
g_tsg_log_instance->vsystem_id=1;