TSG-15457: 通过流标签获取subscriber_id,将结构体强转为字符串导致proxy不生效

This commit is contained in:
liuxueli
2023-06-12 16:19:09 +08:00
parent 03b39fc314
commit 1d47ee19ad
3 changed files with 370 additions and 184 deletions

View File

@@ -24,7 +24,7 @@ struct bridge_info
stream_bridge_sync_cb_t *sync_cb; stream_bridge_sync_cb_t *sync_cb;
}; };
struct bridge_info g_tm_bridge_para[BRIDGE_TYPE_MAX]; struct bridge_info g_tsg_bridge_para[BRIDGE_TYPE_MAX];
void session_sce_log_update_free(const struct streaminfo *a_stream, int bridge_id, void *data) void session_sce_log_update_free(const struct streaminfo *a_stream, int bridge_id, void *data)
{ {
@@ -269,16 +269,16 @@ void *session_async_bridge_get_data(const struct streaminfo *a_stream, int bridg
const struct session_runtime_attribute *session_runtime_attribute_new(const struct streaminfo *a_stream) const struct session_runtime_attribute *session_runtime_attribute_new(const struct streaminfo *a_stream)
{ {
struct session_runtime_attribute *srt_attribute=(struct session_runtime_attribute *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id); struct session_runtime_attribute *srt_attribute=(struct session_runtime_attribute *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id);
if(srt_attribute==NULL) if(srt_attribute==NULL)
{ {
srt_attribute=(struct session_runtime_attribute *)dictator_malloc(a_stream->threadnum, sizeof(struct session_runtime_attribute)); srt_attribute=(struct session_runtime_attribute *)dictator_malloc(a_stream->threadnum, sizeof(struct session_runtime_attribute));
memset(srt_attribute, 0, sizeof(struct session_runtime_attribute)); memset(srt_attribute, 0, sizeof(struct session_runtime_attribute));
int ret=session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)srt_attribute); int ret=session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)srt_attribute);
if(ret<0) if(ret<0)
{ {
session_runtime_attribute_free(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)srt_attribute); session_runtime_attribute_free(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)srt_attribute);
srt_attribute=NULL; srt_attribute=NULL;
return NULL; return NULL;
} }
@@ -289,7 +289,7 @@ const struct session_runtime_attribute *session_runtime_attribute_new(const stru
const struct session_runtime_attribute *session_runtime_attribute_get(const struct streaminfo *a_stream) const struct session_runtime_attribute *session_runtime_attribute_get(const struct streaminfo *a_stream)
{ {
return (struct session_runtime_attribute *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id); return (struct session_runtime_attribute *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id);
} }
void srt_attribute_free_proxy_tcp_option(const struct streaminfo *a_stream) void srt_attribute_free_proxy_tcp_option(const struct streaminfo *a_stream)
@@ -459,18 +459,18 @@ const char *srt_attribute_get_ja3_fingerprint(const struct session_runtime_attri
} }
const char *srt_attribute_get_client_subscriber_id(const struct session_runtime_attribute *srt_attribute) const char *srt_attribute_get_client_subscriber_id(const struct session_runtime_attribute *srt_attribute)
{ {
if(srt_attribute) if(srt_attribute!=NULL && srt_attribute->client_subscribe_id!=NULL)
{ {
return (const char *)(srt_attribute->client_subscribe_id); return (const char *)(srt_attribute->client_subscribe_id->subscribe_id);
} }
return NULL; return NULL;
} }
const char *srt_attribute_get_server_subscriber_id(const struct session_runtime_attribute *srt_attribute) const char *srt_attribute_get_server_subscriber_id(const struct session_runtime_attribute *srt_attribute)
{ {
if(srt_attribute) if(srt_attribute!=NULL && srt_attribute->client_subscribe_id!=NULL)
{ {
return (const char *)(srt_attribute->server_subscribe_id); return (const char *)(srt_attribute->server_subscribe_id->subscribe_id);
} }
return NULL; return NULL;
@@ -531,21 +531,21 @@ size_t srt_attribute_get_category_ids(const struct session_runtime_attribute *sr
int session_runtime_process_context_async(const struct streaminfo *a_stream, void *data) int session_runtime_process_context_async(const struct streaminfo *a_stream, void *data)
{ {
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, data);
} }
const struct session_runtime_process_context *session_runtime_process_context_new(const struct streaminfo *a_stream) const struct session_runtime_process_context *session_runtime_process_context_new(const struct streaminfo *a_stream)
{ {
struct session_runtime_process_context *srt_attribute=(struct session_runtime_process_context *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id); struct session_runtime_process_context *srt_attribute=(struct session_runtime_process_context *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id);
if(srt_attribute==NULL) if(srt_attribute==NULL)
{ {
srt_attribute=(struct session_runtime_process_context *)dictator_malloc(a_stream->threadnum, sizeof(struct session_runtime_process_context)); srt_attribute=(struct session_runtime_process_context *)dictator_malloc(a_stream->threadnum, sizeof(struct session_runtime_process_context));
memset(srt_attribute, 0, sizeof(struct session_runtime_process_context)); memset(srt_attribute, 0, sizeof(struct session_runtime_process_context));
int ret=session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)srt_attribute); int ret=session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)srt_attribute);
if(ret<0) if(ret<0)
{ {
session_runtime_process_context_free_cb(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)srt_attribute); session_runtime_process_context_free_cb(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)srt_attribute);
srt_attribute=NULL; srt_attribute=NULL;
return NULL; return NULL;
} }
@@ -556,7 +556,7 @@ const struct session_runtime_process_context *session_runtime_process_context_ne
const struct session_runtime_process_context *session_runtime_process_context_get(const struct streaminfo *a_stream) const struct session_runtime_process_context *session_runtime_process_context_get(const struct streaminfo *a_stream)
{ {
return (struct session_runtime_process_context *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id); return (struct session_runtime_process_context *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id);
} }
void session_runtime_process_context_free(const struct streaminfo *a_stream) void session_runtime_process_context_free(const struct streaminfo *a_stream)
@@ -564,7 +564,7 @@ void session_runtime_process_context_free(const struct streaminfo *a_stream)
const struct session_runtime_process_context *srt_process_context=session_runtime_process_context_get(a_stream); const struct session_runtime_process_context *srt_process_context=session_runtime_process_context_get(a_stream);
if(srt_process_context!=NULL) if(srt_process_context!=NULL)
{ {
session_runtime_process_context_free_cb(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)srt_process_context); session_runtime_process_context_free_cb(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)srt_process_context);
session_runtime_process_context_async(a_stream, NULL); session_runtime_process_context_async(a_stream, NULL);
} }
} }
@@ -621,21 +621,21 @@ unsigned char srt_process_context_get_hitted_allow_flag(const struct session_run
int session_runtime_action_context_async(const struct streaminfo *a_stream, void *data) int session_runtime_action_context_async(const struct streaminfo *a_stream, void *data)
{ {
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, data);
} }
const struct session_runtime_action_context *session_runtime_action_context_new(const struct streaminfo *a_stream) const struct session_runtime_action_context *session_runtime_action_context_new(const struct streaminfo *a_stream)
{ {
struct session_runtime_action_context *srt_action_context=(struct session_runtime_action_context *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id); struct session_runtime_action_context *srt_action_context=(struct session_runtime_action_context *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id);
if(srt_action_context==NULL) if(srt_action_context==NULL)
{ {
srt_action_context=(struct session_runtime_action_context *)dictator_malloc(a_stream->threadnum, sizeof(struct session_runtime_action_context)); srt_action_context=(struct session_runtime_action_context *)dictator_malloc(a_stream->threadnum, sizeof(struct session_runtime_action_context));
memset(srt_action_context, 0, sizeof(struct session_runtime_action_context)); memset(srt_action_context, 0, sizeof(struct session_runtime_action_context));
int ret=session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)srt_action_context); int ret=session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)srt_action_context);
if(ret<0) if(ret<0)
{ {
session_runtime_action_context_free(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)srt_action_context); session_runtime_action_context_free(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)srt_action_context);
srt_action_context=NULL; srt_action_context=NULL;
return NULL; return NULL;
} }
@@ -646,7 +646,7 @@ const struct session_runtime_action_context *session_runtime_action_context_new(
const struct session_runtime_action_context *session_runtime_action_context_get(const struct streaminfo *a_stream) const struct session_runtime_action_context *session_runtime_action_context_get(const struct streaminfo *a_stream)
{ {
return (const struct session_runtime_action_context *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id); return (const struct session_runtime_action_context *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id);
} }
int srt_action_context_set_after_n_packet(const struct streaminfo *a_stream, int after_n_packets, int thread_seq) int srt_action_context_set_after_n_packet(const struct streaminfo *a_stream, int after_n_packets, int thread_seq)
@@ -786,7 +786,7 @@ int session_mirror_packets_sync(const struct streaminfo *a_stream, struct maat_r
notify_data.compile_id=rules->rule_id; notify_data.compile_id=rules->rule_id;
notify_data.type=NOTIFY_TYPE_MIRRORED; notify_data.type=NOTIFY_TYPE_MIRRORED;
notify_data.vlan=vlan; notify_data.vlan=vlan;
stream_bridge_sync_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, (void *)&(notify_data)); stream_bridge_sync_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, (void *)&(notify_data));
return 1; return 1;
} }
@@ -798,7 +798,7 @@ int session_capture_packets_sync(const struct streaminfo *a_stream, struct maat_
notify_data.compile_id=result->rule_id; notify_data.compile_id=result->rule_id;
notify_data.type=NOTIFY_TYPE_CAPTURE; notify_data.type=NOTIFY_TYPE_CAPTURE;
notify_data.capture_depth=depth; notify_data.capture_depth=depth;
stream_bridge_sync_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, (void *)&(notify_data)); stream_bridge_sync_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, (void *)&(notify_data));
return 1; return 1;
} }
@@ -814,16 +814,16 @@ size_t session_matched_rules_copy(const struct streaminfo *a_stream, enum TSG_SE
switch(service) switch(service)
{ {
case TSG_SERVICE_SECURITY: case TSG_SERVICE_SECURITY:
matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id); matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id);
break; break;
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id); matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id);
break; break;
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id); matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id);
break; break;
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id); matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id);
break; break;
default: default:
break; break;
@@ -844,15 +844,15 @@ const struct matched_policy_rules *session_matched_rules_get(const struct stream
switch(service) switch(service)
{ {
case TSG_SERVICE_SECURITY: case TSG_SERVICE_SECURITY:
return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id); return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id);
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id); return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id);
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id); return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id);
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id); return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id);
case TSG_SERVICE_SIGNATURE: case TSG_SERVICE_SIGNATURE:
return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id); return (struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id);
default: default:
break; break;
} }
@@ -867,13 +867,13 @@ int session_matched_rules_sync(const struct streaminfo *a_stream, TSG_SERVICE se
case TSG_SERVICE_SECURITY: case TSG_SERVICE_SECURITY:
break; break;
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
return stream_bridge_sync_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, data); return stream_bridge_sync_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, data);
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
return stream_bridge_sync_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, data); return stream_bridge_sync_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, data);
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
return stream_bridge_sync_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, data); return stream_bridge_sync_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, data);
case TSG_SERVICE_SIGNATURE: case TSG_SERVICE_SIGNATURE:
return stream_bridge_sync_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, data); return stream_bridge_sync_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, data);
default: default:
break; break;
} }
@@ -886,18 +886,18 @@ int session_matched_rules_async(const struct streaminfo *a_stream, TSG_SERVICE s
switch(service) switch(service)
{ {
case TSG_SERVICE_SECURITY: case TSG_SERVICE_SECURITY:
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id, data);
break; break;
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, data);
break; break;
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, data);
break; break;
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, data);
case TSG_SERVICE_SIGNATURE: case TSG_SERVICE_SIGNATURE:
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, data);
default: default:
break; break;
} }
@@ -910,19 +910,19 @@ void session_matched_rules_free(const struct streaminfo *a_stream, TSG_SERVICE s
switch(service) switch(service)
{ {
case TSG_SERVICE_SECURITY: case TSG_SERVICE_SECURITY:
session_matched_rules_free_by_bridge(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id, data); session_matched_rules_free_by_bridge(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id, data);
break; break;
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
session_matched_rules_free_by_bridge(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, data); session_matched_rules_free_by_bridge(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, data);
break; break;
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
session_matched_rules_free_by_bridge(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, data); session_matched_rules_free_by_bridge(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, data);
break; break;
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
session_matched_rules_free_by_bridge(a_stream, g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, data); session_matched_rules_free_by_bridge(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, data);
break; break;
case TSG_SERVICE_SIGNATURE: case TSG_SERVICE_SIGNATURE:
session_matched_rules_free_by_bridge(a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, data); session_matched_rules_free_by_bridge(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, data);
default: default:
break; break;
} }
@@ -954,16 +954,16 @@ void session_matched_rules_notify(const struct streaminfo *a_stream, TSG_SERVICE
return ; return ;
} }
struct matched_policy_rules *matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tm_bridge_para[bridge_idx].id); struct matched_policy_rules *matched_policy=(struct matched_policy_rules *)session_async_bridge_get_data(a_stream, g_tsg_bridge_para[bridge_idx].id);
if(matched_policy==NULL) if(matched_policy==NULL)
{ {
matched_policy=(struct matched_policy_rules *)dictator_malloc(thread_seq, sizeof(struct matched_policy_rules)); matched_policy=(struct matched_policy_rules *)dictator_malloc(thread_seq, sizeof(struct matched_policy_rules));
memset(matched_policy, 0, sizeof(struct matched_policy_rules)); memset(matched_policy, 0, sizeof(struct matched_policy_rules));
int ret=session_async_bridge_set_data(a_stream, g_tm_bridge_para[bridge_idx].id, (void *)matched_policy); int ret=session_async_bridge_set_data(a_stream, g_tsg_bridge_para[bridge_idx].id, (void *)matched_policy);
if(ret<0) if(ret<0)
{ {
session_matched_rules_free_by_bridge(a_stream, g_tm_bridge_para[bridge_idx].id, (void *)matched_policy); session_matched_rules_free_by_bridge(a_stream, g_tsg_bridge_para[bridge_idx].id, (void *)matched_policy);
} }
} }
@@ -991,67 +991,67 @@ void session_matched_rules_notify(const struct streaminfo *a_stream, TSG_SERVICE
void *session_mac_linkinfo_get(const struct streaminfo *a_stream) void *session_mac_linkinfo_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].id);
} }
void *session_nat_c2s_linkinfo_get(const struct streaminfo *a_stream) void *session_nat_c2s_linkinfo_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].id);
} }
void *session_nat_s2c_linkinfo_get(const struct streaminfo *a_stream) void *session_nat_s2c_linkinfo_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].id);
} }
void *session_gather_app_results_get(const struct streaminfo *a_stream) void *session_gather_app_results_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].id);
} }
int session_gather_app_results_async(const struct streaminfo *a_stream, void *data) int session_gather_app_results_async(const struct streaminfo *a_stream, void *data)
{ {
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].id, data);
} }
int session_control_segment_ids_async(const struct streaminfo *a_stream, void *data) int session_control_segment_ids_async(const struct streaminfo *a_stream, void *data)
{ {
return session_async_bridge_set_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].id, data); return session_async_bridge_set_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].id, data);
} }
void *session_control_segment_ids_get(const struct streaminfo *a_stream) void *session_control_segment_ids_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].id);
} }
void *session_conn_sketch_notify_data_get(const struct streaminfo *a_stream) void *session_conn_sketch_notify_data_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].id);
} }
void *session_business_data_get(const struct streaminfo *a_stream) void *session_business_data_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].id);
} }
void *session_session_flags_get(const struct streaminfo *a_stream) void *session_session_flags_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].id);
} }
void *session_application_behavior_get(const struct streaminfo *a_stream) void *session_application_behavior_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].id);
} }
void *session_mirrored_and_capture_packets_exec_result_get(const struct streaminfo *a_stream) void *session_mirrored_and_capture_packets_exec_result_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].id);
} }
void *session_lua_user_defined_attribute_get(const struct streaminfo *a_stream) void *session_lua_user_defined_attribute_get(const struct streaminfo *a_stream)
{ {
return session_async_bridge_get_data(a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].id); return session_async_bridge_get_data(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].id);
} }
void *session_log_update_data_get(const struct streaminfo *a_stream, enum TSG_SERVICE service) void *session_log_update_data_get(const struct streaminfo *a_stream, enum TSG_SERVICE service)
@@ -1059,13 +1059,13 @@ void *session_log_update_data_get(const struct streaminfo *a_stream, enum TSG_SE
switch (service) switch (service)
{ {
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
return stream_bridge_async_data_get(a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].id); return stream_bridge_async_data_get(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].id);
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
return stream_bridge_async_data_get(a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].id); return stream_bridge_async_data_get(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].id);
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
return stream_bridge_async_data_get(a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].id); return stream_bridge_async_data_get(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].id);
default: default:
return NULL; return NULL;
@@ -1077,13 +1077,13 @@ int session_log_update_data_put(const struct streaminfo *a_stream, enum TSG_SERV
switch (service) switch (service)
{ {
case TSG_SERVICE_INTERCEPT: case TSG_SERVICE_INTERCEPT:
return stream_bridge_async_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].id, data); return stream_bridge_async_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].id, data);
case TSG_SERVICE_CHAINING: case TSG_SERVICE_CHAINING:
return stream_bridge_async_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].id, data); return stream_bridge_async_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].id, data);
case TSG_SERVICE_SHAPING: case TSG_SERVICE_SHAPING:
return stream_bridge_async_data_put(a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].id, data); return stream_bridge_async_data_put(a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].id, data);
default: default:
return 0; return 0;
@@ -1092,87 +1092,87 @@ int session_log_update_data_put(const struct streaminfo *a_stream, enum TSG_SERV
int tsg_bridge_init(const char *conffile) int tsg_bridge_init(const char *conffile)
{ {
MESA_load_profile_string_def(conffile, "BRIDGE", "APP_IDENTIFY_RESULT_BRIDGE", g_tm_bridge_para[BRIDGE_TYPE_SYNC_APP_IDENTIFY_RESULT].name, MAX_BRIDGE_NAME_LEN, "APP_IDENTIFY_RESULT_BRIDGE"); MESA_load_profile_string_def(conffile, "BRIDGE", "APP_IDENTIFY_RESULT_BRIDGE", g_tsg_bridge_para[BRIDGE_TYPE_SYNC_APP_IDENTIFY_RESULT].name, MAX_BRIDGE_NAME_LEN, "APP_IDENTIFY_RESULT_BRIDGE");
g_tm_bridge_para[BRIDGE_TYPE_SYNC_APP_IDENTIFY_RESULT].sync_cb=session_app_identify_result_cb; g_tsg_bridge_para[BRIDGE_TYPE_SYNC_APP_IDENTIFY_RESULT].sync_cb=session_app_identify_result_cb;
MESA_load_profile_string_def(conffile, "BRIDGE", "SKETCH_NOTIFY_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].name, MAX_BRIDGE_NAME_LEN, "TSG_CONN_SKETCH_NOTIFY_DATA"); MESA_load_profile_string_def(conffile, "BRIDGE", "SKETCH_NOTIFY_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].name, MAX_BRIDGE_NAME_LEN, "TSG_CONN_SKETCH_NOTIFY_DATA");
MESA_load_profile_string_def(conffile, "BRIDGE", "MASTER_NOTIFY_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].name, MAX_BRIDGE_NAME_LEN, "TSG_MASTER_NOTIFY_DATA"); MESA_load_profile_string_def(conffile, "BRIDGE", "MASTER_NOTIFY_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].name, MAX_BRIDGE_NAME_LEN, "TSG_MASTER_NOTIFY_DATA");
MESA_load_profile_string_def(conffile, "SESSION_FLAGS", "FLAGS_NOTIFY_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SYNC_SESSION_FLAGS].name, MAX_BRIDGE_NAME_LEN, "SESSION_FLAGS_SYNC_NOTIFY_DATA"); MESA_load_profile_string_def(conffile, "SESSION_FLAGS", "FLAGS_NOTIFY_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SYNC_SESSION_FLAGS].name, MAX_BRIDGE_NAME_LEN, "SESSION_FLAGS_SYNC_NOTIFY_DATA");
g_tm_bridge_para[BRIDGE_TYPE_SYNC_SESSION_FLAGS].sync_cb=session_flags_identify_result_cb; g_tsg_bridge_para[BRIDGE_TYPE_SYNC_SESSION_FLAGS].sync_cb=session_flags_identify_result_cb;
MESA_load_profile_string_def(conffile, "BRIDGE", "SHAPING_RESULT_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].name, MAX_BRIDGE_NAME_LEN, "NOTIFY_SHAPING_RESULT"); MESA_load_profile_string_def(conffile, "BRIDGE", "SHAPING_RESULT_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].name, MAX_BRIDGE_NAME_LEN, "NOTIFY_SHAPING_RESULT");
g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].free_cb=session_matched_rules_free_by_bridge; g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].free_cb=session_matched_rules_free_by_bridge;
MESA_load_profile_string_def(conffile, "BRIDGE", "DATA_CONTEXT_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].name, MAX_BRIDGE_NAME_LEN, "TSG_DATA_CONTEXT"); MESA_load_profile_string_def(conffile, "BRIDGE", "DATA_CONTEXT_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].name, MAX_BRIDGE_NAME_LEN, "TSG_DATA_CONTEXT");
g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].free_cb=session_runtime_process_context_free_cb; g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].free_cb=session_runtime_process_context_free_cb;
MESA_load_profile_string_def(conffile, "BRIDGE", "ALL_RESULT_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].name, MAX_BRIDGE_NAME_LEN, "TSG_ALL_CONTEXT"); MESA_load_profile_string_def(conffile, "BRIDGE", "ALL_RESULT_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].name, MAX_BRIDGE_NAME_LEN, "TSG_ALL_CONTEXT");
g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].free_cb=session_runtime_action_context_free; g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].free_cb=session_runtime_action_context_free;
MESA_load_profile_string_def(conffile, "BRIDGE", "GATHER_APP_RESULT_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].name, MAX_BRIDGE_NAME_LEN, "GATHER_APP_IDENTIFY_RESULT"); MESA_load_profile_string_def(conffile, "BRIDGE", "GATHER_APP_RESULT_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].name, MAX_BRIDGE_NAME_LEN, "GATHER_APP_IDENTIFY_RESULT");
g_tm_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].free_cb=session_gather_app_results_free; g_tsg_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].free_cb=session_gather_app_results_free;
MESA_load_profile_string_def(conffile, "BRIDGE", "SECURITY_RESULT_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_POLICY_PRIORITY"); MESA_load_profile_string_def(conffile, "BRIDGE", "SECURITY_RESULT_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_POLICY_PRIORITY");
g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].free_cb=session_matched_rules_free_by_bridge; g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].free_cb=session_matched_rules_free_by_bridge;
MESA_load_profile_string_def(conffile, "BRIDGE", "SESSION_ATTRIBUTE_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].name, MAX_BRIDGE_NAME_LEN, "TSG_SESSION_ATTRIBUTE"); MESA_load_profile_string_def(conffile, "BRIDGE", "SESSION_ATTRIBUTE_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].name, MAX_BRIDGE_NAME_LEN, "TSG_SESSION_ATTRIBUTE");
g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].free_cb=session_runtime_attribute_free; g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].free_cb=session_runtime_attribute_free;
MESA_load_profile_string_def(conffile, "BRIDGE", "LINKINFO_FROM_MAC", g_tm_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].name, MAX_BRIDGE_NAME_LEN, "mirror_linkinfo_from_mac"); MESA_load_profile_string_def(conffile, "BRIDGE", "LINKINFO_FROM_MAC", g_tsg_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].name, MAX_BRIDGE_NAME_LEN, "mirror_linkinfo_from_mac");
MESA_load_profile_string_def(conffile, "BRIDGE", "NAT_C2S_LINKINFO", g_tm_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].name, MAX_BRIDGE_NAME_LEN, "common_link_info_c2s"); MESA_load_profile_string_def(conffile, "BRIDGE", "NAT_C2S_LINKINFO", g_tsg_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].name, MAX_BRIDGE_NAME_LEN, "common_link_info_c2s");
MESA_load_profile_string_def(conffile, "BRIDGE", "NAT_S2C_LINKINFO", g_tm_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].name, MAX_BRIDGE_NAME_LEN, "common_link_info_s2c"); MESA_load_profile_string_def(conffile, "BRIDGE", "NAT_S2C_LINKINFO", g_tsg_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].name, MAX_BRIDGE_NAME_LEN, "common_link_info_s2c");
MESA_load_profile_string_def(conffile, "BRIDGE", "APP_LUA_SCRIPTS_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].name, MAX_BRIDGE_NAME_LEN, "LUA_USER_DEFINED_ATTRIBUTE"); MESA_load_profile_string_def(conffile, "BRIDGE", "APP_LUA_SCRIPTS_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].name, MAX_BRIDGE_NAME_LEN, "LUA_USER_DEFINED_ATTRIBUTE");
MESA_load_profile_string_def(conffile, "BRIDGE", "BUSINESS_S3_FILENAME", g_tm_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].name, MAX_BRIDGE_NAME_LEN, "TSG_BUSINESS_S3_FILENAME"); MESA_load_profile_string_def(conffile, "BRIDGE", "BUSINESS_S3_FILENAME", g_tsg_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].name, MAX_BRIDGE_NAME_LEN, "TSG_BUSINESS_S3_FILENAME");
MESA_load_profile_string_def(conffile, "BRIDGE", "APP_BEHAVIOR_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_APPLICATION_BEHAVIOR"); MESA_load_profile_string_def(conffile, "BRIDGE", "APP_BEHAVIOR_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_APPLICATION_BEHAVIOR");
MESA_load_profile_string_def(conffile, "BRIDGE", "POLICY_ACTION_PARA_EXEC_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_NOTIFICATION_EXECUTION_RESULT"); MESA_load_profile_string_def(conffile, "BRIDGE", "POLICY_ACTION_PARA_EXEC_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_NOTIFICATION_EXECUTION_RESULT");
MESA_load_profile_string_def(conffile, "BRIDGE", "NOTIFY_ASYNC_FLAGS_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].name, MAX_BRIDGE_NAME_LEN, "SESSION_FLAGS_ASYNC_NOTIFY_DATA"); MESA_load_profile_string_def(conffile, "BRIDGE", "NOTIFY_ASYNC_FLAGS_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].name, MAX_BRIDGE_NAME_LEN, "SESSION_FLAGS_ASYNC_NOTIFY_DATA");
MESA_load_profile_string_def(conffile, "BRIDGE", "SYNC_APP_SIGNATURE_ID_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_SYNC_APP_SIGNATURE_ID"); MESA_load_profile_string_def(conffile, "BRIDGE", "SYNC_APP_SIGNATURE_ID_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].name, MAX_BRIDGE_NAME_LEN, "TSG_SYNC_APP_SIGNATURE_ID");
MESA_load_profile_string_def(conffile, "BRIDGE", "S_CHAINING_RESULT_BRIDGE_NAME",g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].name, MAX_BRIDGE_NAME_LEN, "SERVICE_CHAINING_RESULT"); MESA_load_profile_string_def(conffile, "BRIDGE", "S_CHAINING_RESULT_BRIDGE_NAME",g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].name, MAX_BRIDGE_NAME_LEN, "SERVICE_CHAINING_RESULT");
g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].free_cb=session_matched_rules_free_by_bridge; g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].free_cb=session_matched_rules_free_by_bridge;
MESA_load_profile_string_def(conffile, "BRIDGE", "INTERCEPT_RESULT_BRIDGE_NAME",g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].name, MAX_BRIDGE_NAME_LEN, "INTERCEPT_RESULT"); MESA_load_profile_string_def(conffile, "BRIDGE", "INTERCEPT_RESULT_BRIDGE_NAME",g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].name, MAX_BRIDGE_NAME_LEN, "INTERCEPT_RESULT");
g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].free_cb=session_matched_rules_free_by_bridge; g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].free_cb=session_matched_rules_free_by_bridge;
MESA_load_profile_string_def(conffile, "BRIDGE", "SEGMENT_IDS_BRIDGE_NAME",g_tm_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].name, MAX_BRIDGE_NAME_LEN, "SEGMENT_IDS"); MESA_load_profile_string_def(conffile, "BRIDGE", "SEGMENT_IDS_BRIDGE_NAME",g_tsg_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].name, MAX_BRIDGE_NAME_LEN, "SEGMENT_IDS");
g_tm_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].free_cb=session_segment_id_free; g_tsg_bridge_para[BRIDGE_TYPE_SEGMENT_IDS].free_cb=session_segment_id_free;
MESA_load_profile_string_def(conffile, "BRIDGE", "SCE_LOG_UPDATE_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].name, MAX_BRIDGE_NAME_LEN, "SCE_LOG_UPDATE"); MESA_load_profile_string_def(conffile, "BRIDGE", "SCE_LOG_UPDATE_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].name, MAX_BRIDGE_NAME_LEN, "SCE_LOG_UPDATE");
g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].free_cb = session_sce_log_update_free; g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SCE].free_cb = session_sce_log_update_free;
MESA_load_profile_string_def(conffile, "BRIDGE", "SHAPER_LOG_UPDATE_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].name, MAX_BRIDGE_NAME_LEN, "SHAPER_LOG_UPDATE"); MESA_load_profile_string_def(conffile, "BRIDGE", "SHAPER_LOG_UPDATE_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].name, MAX_BRIDGE_NAME_LEN, "SHAPER_LOG_UPDATE");
g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].free_cb = session_shaper_log_update_free; g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_SHAPER].free_cb = session_shaper_log_update_free;
MESA_load_profile_string_def(conffile, "BRIDGE", "PROXY_LOG_UPDATE_BRIDGE_NAME", g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].name, MAX_BRIDGE_NAME_LEN, "PROXY_LOG_UPDATE"); MESA_load_profile_string_def(conffile, "BRIDGE", "PROXY_LOG_UPDATE_BRIDGE_NAME", g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].name, MAX_BRIDGE_NAME_LEN, "PROXY_LOG_UPDATE");
g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].free_cb = session_proxy_log_update_free; g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].free_cb = session_proxy_log_update_free;
for(int i=0; i<BRIDGE_TYPE_MAX; i++) for(int i=0; i<BRIDGE_TYPE_MAX; i++)
{ {
g_tm_bridge_para[i].id=stream_bridge_build(g_tm_bridge_para[i].name, "w"); g_tsg_bridge_para[i].id=stream_bridge_build(g_tsg_bridge_para[i].name, "w");
if(g_tm_bridge_para[i].id<0) if(g_tsg_bridge_para[i].id<0)
{ {
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_BRIDGE", "stream_bridge_build is error, bridge_name: %s", g_tm_bridge_para[i].name); MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_BRIDGE", "stream_bridge_build is error, bridge_name: %s", g_tsg_bridge_para[i].name);
return -1; return -1;
} }
if(g_tm_bridge_para[i].sync_cb) if(g_tsg_bridge_para[i].sync_cb)
{ {
int ret=stream_bridge_register_data_sync_cb(g_tm_bridge_para[i].id, g_tm_bridge_para[i].sync_cb); int ret=stream_bridge_register_data_sync_cb(g_tsg_bridge_para[i].id, g_tsg_bridge_para[i].sync_cb);
if(ret<0) if(ret<0)
{ {
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE_SYNC_CB", "Register callback failed, bridge_name: %d",g_tm_bridge_para[i].name); MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE_SYNC_CB", "Register callback failed, bridge_name: %d",g_tsg_bridge_para[i].name);
return -1; return -1;
} }
} }
if(g_tm_bridge_para[i].free_cb) if(g_tsg_bridge_para[i].free_cb)
{ {
int ret=stream_bridge_register_data_free_cb(g_tm_bridge_para[i].id, g_tm_bridge_para[i].free_cb); int ret=stream_bridge_register_data_free_cb(g_tsg_bridge_para[i].id, g_tsg_bridge_para[i].free_cb);
if(ret<0) if(ret<0)
{ {
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE_FREE_CB", "Register async free callback failed, bridge_name: %d", g_tm_bridge_para[i].name); MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE_FREE_CB", "Register async free callback failed, bridge_name: %d", g_tsg_bridge_para[i].name);
return -1; return -1;
} }
} }

View File

@@ -134,25 +134,25 @@ struct bridge_info
stream_bridge_free_cb_t *free_cb; stream_bridge_free_cb_t *free_cb;
stream_bridge_sync_cb_t *sync_cb; stream_bridge_sync_cb_t *sync_cb;
}; };
extern struct bridge_info g_tm_bridge_para[BRIDGE_TYPE_MAX]; extern struct bridge_info g_tsg_bridge_para[BRIDGE_TYPE_MAX];
TEST(TSG_Bridge, SyncAppIdentifyResultSync) TEST(TSGBridge, SyncAppIdentifyResultSync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
int SyncAppIdentifyResult_test_data_before = 10; int SyncAppIdentifyResult_test_data_before = 10;
stream_bridge_sync_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SYNC_APP_IDENTIFY_RESULT].id, (void *)&SyncAppIdentifyResult_test_data_before); stream_bridge_sync_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SYNC_APP_IDENTIFY_RESULT].id, (void *)&SyncAppIdentifyResult_test_data_before);
EXPECT_EQ(10, SyncAppIdentifyResult_test_data_after); EXPECT_EQ(10, SyncAppIdentifyResult_test_data_after);
SyncAppIdentifyResult_test_data_after = 0; SyncAppIdentifyResult_test_data_after = 0;
} }
TEST(TSG_Bridge, RecvConnSketchDataAsync) TEST(TSGBridge, RecvConnSketchDataAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct tsg_conn_sketch_notify_data RecvConnSketchData_test_data_before; struct tsg_conn_sketch_notify_data RecvConnSketchData_test_data_before;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].id, (void *)&RecvConnSketchData_test_data_before); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].id, (void *)&RecvConnSketchData_test_data_before);
struct tsg_conn_sketch_notify_data *RecvConnSketchData_test_data_after = (struct tsg_conn_sketch_notify_data *)session_conn_sketch_notify_data_get(&a_stream); struct tsg_conn_sketch_notify_data *RecvConnSketchData_test_data_after = (struct tsg_conn_sketch_notify_data *)session_conn_sketch_notify_data_get(&a_stream);
EXPECT_EQ(&RecvConnSketchData_test_data_before, RecvConnSketchData_test_data_after); EXPECT_EQ(&RecvConnSketchData_test_data_before, RecvConnSketchData_test_data_after);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_RECV_CONN_SKETCH_DATA].id, NULL);
} }
struct tsg_notify_data notify_data_for_test = {0}; struct tsg_notify_data notify_data_for_test = {0};
@@ -161,9 +161,9 @@ int send_conn_sketch_data_sync_cb(const struct streaminfo *a_stream, int bridge_
memcpy(&notify_data_for_test, data, sizeof(struct tsg_notify_data)); memcpy(&notify_data_for_test, data, sizeof(struct tsg_notify_data));
return 0; return 0;
} }
TEST(TSG_Bridge, SendConnSketchDataMirrorSync) TEST(TSGBridge, SendConnSketchDataMirrorSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, send_conn_sketch_data_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, send_conn_sketch_data_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct maat_rule rules = {0}; struct maat_rule rules = {0};
@@ -176,9 +176,9 @@ TEST(TSG_Bridge, SendConnSketchDataMirrorSync)
memset(&notify_data_for_test, 0, sizeof(struct tsg_notify_data)); memset(&notify_data_for_test, 0, sizeof(struct tsg_notify_data));
} }
TEST(TSG_Bridge, SendConnSketchDataCaptureSync) TEST(TSGBridge, SendConnSketchDataCaptureSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, send_conn_sketch_data_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_SEND_CONN_SKETCH_DATA].id, send_conn_sketch_data_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct maat_rule rules = {0}; struct maat_rule rules = {0};
@@ -190,11 +190,11 @@ TEST(TSG_Bridge, SendConnSketchDataCaptureSync)
memset(&notify_data_for_test, 0, sizeof(struct tsg_notify_data)); memset(&notify_data_for_test, 0, sizeof(struct tsg_notify_data));
} }
TEST(TSG_Bridge, SessionFlagsSync) TEST(TSGBridge, SessionFlagsSync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
int SyncSessionFlags_test_data_before = 20; int SyncSessionFlags_test_data_before = 20;
stream_bridge_sync_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SYNC_SESSION_FLAGS].id, (void *)&SyncSessionFlags_test_data_before); stream_bridge_sync_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SYNC_SESSION_FLAGS].id, (void *)&SyncSessionFlags_test_data_before);
EXPECT_EQ(20, SyncSessionFlags_test_data_after); EXPECT_EQ(20, SyncSessionFlags_test_data_after);
SyncSessionFlags_test_data_after = 0; SyncSessionFlags_test_data_after = 0;
} }
@@ -204,15 +204,15 @@ struct session_marker_notify_ctx
uint64_t flags; uint64_t flags;
char *identify_str; char *identify_str;
}; };
TEST(TSG_Bridge, SessionFlagsAsync) TEST(TSGBridge, SessionFlagsAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct session_marker_notify_ctx sm_notify = {0}; struct session_marker_notify_ctx sm_notify = {0};
sm_notify.flags = 40; sm_notify.flags = 40;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].id, (void *)&sm_notify); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].id, (void *)&sm_notify);
struct session_marker_notify_ctx *test = (struct session_marker_notify_ctx *)session_session_flags_get(&a_stream); struct session_marker_notify_ctx *test = (struct session_marker_notify_ctx *)session_session_flags_get(&a_stream);
EXPECT_EQ(test->flags, 40); EXPECT_EQ(test->flags, 40);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_ASYNC_SESSION_FLAGS].id, NULL);
EXPECT_EQ(nullptr, session_session_flags_get(&a_stream)); EXPECT_EQ(nullptr, session_session_flags_get(&a_stream));
} }
@@ -223,9 +223,9 @@ int session_matched_rules_result_sync_cb(const struct streaminfo *a_stream, int
memcpy(&matched_rules_test_data_after, data, sizeof(struct matched_policy_rules)); memcpy(&matched_rules_test_data_after, data, sizeof(struct matched_policy_rules));
return 0; return 0;
} }
TEST(TSG_Bridge, ShapingResultSync) TEST(TSGBridge, ShapingResultSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, session_matched_rules_result_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_SHAPING_RESULT].id, session_matched_rules_result_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules ShapingResultSync_test_data_before = {0}; struct matched_policy_rules ShapingResultSync_test_data_before = {0};
ShapingResultSync_test_data_before.n_rules = 1; ShapingResultSync_test_data_before.n_rules = 1;
@@ -234,7 +234,7 @@ TEST(TSG_Bridge, ShapingResultSync)
memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules)); memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules));
} }
TEST(TSG_Bridge, ShapingResultAsync) TEST(TSGBridge, ShapingResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules)); struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules));
@@ -249,9 +249,9 @@ TEST(TSG_Bridge, ShapingResultAsync)
session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL); session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL);
} }
TEST(TSG_Bridge, ServiceChainingResultSync) TEST(TSGBridge, ServiceChainingResultSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, session_matched_rules_result_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_SERVICE_CHAINING_RESULT].id, session_matched_rules_result_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules ServiceChainingResultSync_test_data_before = {0}; struct matched_policy_rules ServiceChainingResultSync_test_data_before = {0};
ServiceChainingResultSync_test_data_before.n_rules = 2; ServiceChainingResultSync_test_data_before.n_rules = 2;
@@ -260,7 +260,7 @@ TEST(TSG_Bridge, ServiceChainingResultSync)
memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules)); memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules));
} }
TEST(TSG_Bridge, ServiceChainingResultAsync) TEST(TSGBridge, ServiceChainingResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules)); struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules));
@@ -275,9 +275,9 @@ TEST(TSG_Bridge, ServiceChainingResultAsync)
session_matched_rules_async(&a_stream, TSG_SERVICE_CHAINING, NULL); session_matched_rules_async(&a_stream, TSG_SERVICE_CHAINING, NULL);
} }
TEST(TSG_Bridge, SecurityResultSync) TEST(TSGBridge, SecurityResultSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id, session_matched_rules_result_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_SECURITY_RESULT].id, session_matched_rules_result_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules SecurityResultSync_test_data_before = {0}; struct matched_policy_rules SecurityResultSync_test_data_before = {0};
SecurityResultSync_test_data_before.n_rules = 3; SecurityResultSync_test_data_before.n_rules = 3;
@@ -286,7 +286,7 @@ TEST(TSG_Bridge, SecurityResultSync)
memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules)); memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules));
} }
TEST(TSG_Bridge, SecurityResultAsync) TEST(TSGBridge, SecurityResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules)); struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules));
@@ -301,9 +301,9 @@ TEST(TSG_Bridge, SecurityResultAsync)
session_matched_rules_async(&a_stream, TSG_SERVICE_SECURITY, NULL); session_matched_rules_async(&a_stream, TSG_SERVICE_SECURITY, NULL);
} }
TEST(TSG_Bridge, InterceptResultSync) TEST(TSGBridge, InterceptResultSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, session_matched_rules_result_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_INTERCEPT_RESULT].id, session_matched_rules_result_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules InterceptResultSync_test_data_before = {0}; struct matched_policy_rules InterceptResultSync_test_data_before = {0};
InterceptResultSync_test_data_before.n_rules = 4; InterceptResultSync_test_data_before.n_rules = 4;
@@ -312,7 +312,7 @@ TEST(TSG_Bridge, InterceptResultSync)
memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules)); memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules));
} }
TEST(TSG_Bridge, InterceptResultAsync) TEST(TSGBridge, InterceptResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules)); struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules));
@@ -327,9 +327,9 @@ TEST(TSG_Bridge, InterceptResultAsync)
session_matched_rules_async(&a_stream, TSG_SERVICE_INTERCEPT, NULL); session_matched_rules_async(&a_stream, TSG_SERVICE_INTERCEPT, NULL);
} }
TEST(TSG_Bridge, AppSignatureResultSync) TEST(TSGBridge, AppSignatureResultSync)
{ {
stream_bridge_register_data_sync_cb(g_tm_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, session_matched_rules_result_sync_cb); stream_bridge_register_data_sync_cb(g_tsg_bridge_para[BRIDGE_TYPE_APP_SIGNATURE_RESULT].id, session_matched_rules_result_sync_cb);
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules AppSignaturegResultSync_test_data_before = {0}; struct matched_policy_rules AppSignaturegResultSync_test_data_before = {0};
AppSignaturegResultSync_test_data_before.n_rules = 5; AppSignaturegResultSync_test_data_before.n_rules = 5;
@@ -338,7 +338,7 @@ TEST(TSG_Bridge, AppSignatureResultSync)
memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules)); memset(&matched_rules_test_data_after, 0, sizeof(struct matched_policy_rules));
} }
TEST(TSG_Bridge, AppSignatureResultAsync) TEST(TSGBridge, AppSignatureResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules)); struct matched_policy_rules *rules = (struct matched_policy_rules *)dictator_malloc(a_stream.threadnum, sizeof(struct matched_policy_rules));
@@ -355,19 +355,19 @@ TEST(TSG_Bridge, AppSignatureResultAsync)
extern const struct session_runtime_process_context *session_runtime_process_context_new(const struct streaminfo *a_stream); extern const struct session_runtime_process_context *session_runtime_process_context_new(const struct streaminfo *a_stream);
extern void session_runtime_process_context_free_cb(const struct streaminfo *a_stream, int bridge_id, void *data); extern void session_runtime_process_context_free_cb(const struct streaminfo *a_stream, int bridge_id, void *data);
TEST(TSG_Bridge, SessionProcessContextAsync) TEST(TSGBridge, SessionProcessContextAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
const struct session_runtime_process_context *context = session_runtime_process_context_new(&a_stream); const struct session_runtime_process_context *context = session_runtime_process_context_new(&a_stream);
EXPECT_EQ(session_runtime_process_context_get(&a_stream), context); EXPECT_EQ(session_runtime_process_context_get(&a_stream), context);
EXPECT_EQ(session_runtime_process_context_get(&a_stream), session_runtime_process_context_new(&a_stream)); EXPECT_EQ(session_runtime_process_context_get(&a_stream), session_runtime_process_context_new(&a_stream));
session_runtime_process_context_free_cb(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)context); session_runtime_process_context_free_cb(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)context);
session_runtime_process_context_async(&a_stream, NULL); session_runtime_process_context_async(&a_stream, NULL);
EXPECT_EQ(nullptr, session_runtime_process_context_get(&a_stream)); EXPECT_EQ(nullptr, session_runtime_process_context_get(&a_stream));
} }
extern void session_runtime_action_context_free(const struct streaminfo *a_stream, int bridge_id, void *data); extern void session_runtime_action_context_free(const struct streaminfo *a_stream, int bridge_id, void *data);
TEST(TSG_Bridge, SessionActionContextAsync) TEST(TSGBridge, SessionActionContextAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct session_runtime_action_context *context = (struct session_runtime_action_context *)session_runtime_action_context_new(&a_stream); struct session_runtime_action_context *context = (struct session_runtime_action_context *)session_runtime_action_context_new(&a_stream);
@@ -375,7 +375,7 @@ TEST(TSG_Bridge, SessionActionContextAsync)
EXPECT_EQ(session_runtime_action_context_get(&a_stream), session_runtime_action_context_new(&a_stream)); EXPECT_EQ(session_runtime_action_context_get(&a_stream), session_runtime_action_context_new(&a_stream));
context->direction = DIR_S2C; context->direction = DIR_S2C;
EXPECT_EQ(srt_action_context_get_direction(context), DIR_S2C); EXPECT_EQ(srt_action_context_get_direction(context), DIR_S2C);
session_runtime_action_context_free(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)context); session_runtime_action_context_free(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)context);
session_runtime_action_context_async(&a_stream, NULL); session_runtime_action_context_async(&a_stream, NULL);
EXPECT_EQ(nullptr, session_runtime_action_context_get(&a_stream)); EXPECT_EQ(nullptr, session_runtime_action_context_get(&a_stream));
} }
@@ -391,7 +391,7 @@ static void tsg_bridge_test_init_process_ctx(const struct streaminfo *a_stream,
memcpy(process_ctx->http_url, "thisishttp_url", strlen("thisishttp_url")); memcpy(process_ctx->http_url, "thisishttp_url", strlen("thisishttp_url"));
} }
TEST(TSG_Bridge, ProcessAndActionContextAsync) TEST(TSGBridge, ProcessAndActionContextAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct session_runtime_action_context *action_ctx = (struct session_runtime_action_context *)session_runtime_action_context_new(&a_stream); struct session_runtime_action_context *action_ctx = (struct session_runtime_action_context *)session_runtime_action_context_new(&a_stream);
@@ -402,8 +402,8 @@ TEST(TSG_Bridge, ProcessAndActionContextAsync)
struct session_runtime_process_context *process_test = (struct session_runtime_process_context *)session_runtime_process_context_get(&a_stream); struct session_runtime_process_context *process_test = (struct session_runtime_process_context *)session_runtime_process_context_get(&a_stream);
EXPECT_STREQ(process_test->domain, "thisisdomain"); EXPECT_STREQ(process_test->domain, "thisisdomain");
EXPECT_STREQ(process_test->http_url, "thisishttp_url"); EXPECT_STREQ(process_test->http_url, "thisishttp_url");
session_runtime_action_context_free(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)action_ctx); session_runtime_action_context_free(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ACTION_CONTEXT].id, (void *)action_ctx);
session_runtime_process_context_free_cb(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)process_test); session_runtime_process_context_free_cb(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_PROCESS_CONTEXT].id, (void *)process_test);
session_runtime_action_context_async(&a_stream, NULL); session_runtime_action_context_async(&a_stream, NULL);
EXPECT_EQ(nullptr, session_runtime_action_context_get(&a_stream)); EXPECT_EQ(nullptr, session_runtime_action_context_get(&a_stream));
session_runtime_process_context_async(&a_stream, NULL); session_runtime_process_context_async(&a_stream, NULL);
@@ -411,7 +411,7 @@ TEST(TSG_Bridge, ProcessAndActionContextAsync)
} }
extern void session_gather_app_results_free(const struct streaminfo *a_stream, int bridge_id, void *data); extern void session_gather_app_results_free(const struct streaminfo *a_stream, int bridge_id, void *data);
TEST(TSG_Bridge, GatherAppResultAsync) TEST(TSGBridge, GatherAppResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct gather_app_result *gather_result_in = (struct gather_app_result *)dictator_malloc(a_stream.threadnum, sizeof(struct gather_app_result)); struct gather_app_result *gather_result_in = (struct gather_app_result *)dictator_malloc(a_stream.threadnum, sizeof(struct gather_app_result));
@@ -442,7 +442,7 @@ TEST(TSG_Bridge, GatherAppResultAsync)
EXPECT_EQ(nullptr, gather_result_out->qm_engine); EXPECT_EQ(nullptr, gather_result_out->qm_engine);
EXPECT_EQ(nullptr, gather_result_out->user_define); EXPECT_EQ(nullptr, gather_result_out->user_define);
session_gather_app_results_free(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].id, (void *)gather_result_out); session_gather_app_results_free(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_GATHER_APP_RESULT].id, (void *)gather_result_out);
session_gather_app_results_async(&a_stream, NULL); session_gather_app_results_async(&a_stream, NULL);
EXPECT_EQ(nullptr, session_gather_app_results_get(&a_stream)); EXPECT_EQ(nullptr, session_gather_app_results_get(&a_stream));
@@ -476,7 +476,7 @@ static void tsg_bridge_test_init_attribute(const struct streaminfo *a_stream, st
} }
extern void session_runtime_attribute_free(const struct streaminfo *a_stream, int bridge_id, void *data); extern void session_runtime_attribute_free(const struct streaminfo *a_stream, int bridge_id, void *data);
TEST(TSG_Bridge, SessionAttributeAsync) TEST(TSGBridge, SessionAttributeAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct session_runtime_attribute *attribute = (struct session_runtime_attribute *)session_runtime_attribute_new(&a_stream); struct session_runtime_attribute *attribute = (struct session_runtime_attribute *)session_runtime_attribute_new(&a_stream);
@@ -495,98 +495,98 @@ TEST(TSG_Bridge, SessionAttributeAsync)
EXPECT_EQ(attribute_test->user_info->ref_cnt, 9); EXPECT_EQ(attribute_test->user_info->ref_cnt, 9);
EXPECT_STREQ(attribute->ja3_fingerprint, "thisisja3_fingerprint"); EXPECT_STREQ(attribute->ja3_fingerprint, "thisisja3_fingerprint");
EXPECT_EQ(attribute_test->proxy_tcp_attr->tcp_seq, 10); EXPECT_EQ(attribute_test->proxy_tcp_attr->tcp_seq, 10);
session_runtime_attribute_free(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)attribute); session_runtime_attribute_free(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)attribute);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, NULL);
EXPECT_EQ(nullptr, session_runtime_attribute_get(&a_stream)); EXPECT_EQ(nullptr, session_runtime_attribute_get(&a_stream));
} }
TEST(TSG_Bridge, MacLinkinfoAsync) TEST(TSGBridge, MacLinkinfoAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
char linkinfo[10]; char linkinfo[10];
linkinfo[0] = 0x01; linkinfo[0] = 0x01;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].id, (void *)linkinfo); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].id, (void *)linkinfo);
char *test = (char *)session_mac_linkinfo_get(&a_stream); char *test = (char *)session_mac_linkinfo_get(&a_stream);
EXPECT_EQ(test[0], 0x01); EXPECT_EQ(test[0], 0x01);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_MAC_LINKINFO].id, NULL);
EXPECT_EQ(nullptr, session_mac_linkinfo_get(&a_stream)); EXPECT_EQ(nullptr, session_mac_linkinfo_get(&a_stream));
} }
TEST(TSG_Bridge, NatC2sLinkinfoAsync) TEST(TSGBridge, NatC2sLinkinfoAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
char linkinfo[10]; char linkinfo[10];
linkinfo[0] = 0x02; linkinfo[0] = 0x02;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].id, (void *)linkinfo); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].id, (void *)linkinfo);
char *test = (char *)session_nat_c2s_linkinfo_get(&a_stream); char *test = (char *)session_nat_c2s_linkinfo_get(&a_stream);
EXPECT_EQ(test[0], 0x02); EXPECT_EQ(test[0], 0x02);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_NAT_C2S_LINKINFO].id, NULL);
EXPECT_EQ(nullptr, session_nat_c2s_linkinfo_get(&a_stream)); EXPECT_EQ(nullptr, session_nat_c2s_linkinfo_get(&a_stream));
} }
TEST(TSG_Bridge, NatS2cLinkinfoAsync) TEST(TSGBridge, NatS2cLinkinfoAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
char linkinfo[10]; char linkinfo[10];
linkinfo[0] = 0x03; linkinfo[0] = 0x03;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].id, (void *)linkinfo); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].id, (void *)linkinfo);
char *test = (char *)session_nat_s2c_linkinfo_get(&a_stream); char *test = (char *)session_nat_s2c_linkinfo_get(&a_stream);
EXPECT_EQ(test[0], 0x03); EXPECT_EQ(test[0], 0x03);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_NAT_S2C_LINKINFO].id, NULL);
EXPECT_EQ(nullptr, session_nat_s2c_linkinfo_get(&a_stream)); EXPECT_EQ(nullptr, session_nat_s2c_linkinfo_get(&a_stream));
} }
TEST(TSG_Bridge, AppLuaResultAsync) TEST(TSGBridge, AppLuaResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct user_defined_attribute uda_label = {0}; struct user_defined_attribute uda_label = {0};
uda_label.n_akv = 4; uda_label.n_akv = 4;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].id, (void *)&uda_label); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].id, (void *)&uda_label);
struct user_defined_attribute *test = (struct user_defined_attribute *)session_lua_user_defined_attribute_get(&a_stream); struct user_defined_attribute *test = (struct user_defined_attribute *)session_lua_user_defined_attribute_get(&a_stream);
EXPECT_EQ(test->n_akv, 4); EXPECT_EQ(test->n_akv, 4);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_LUA_RESULT].id, NULL);
EXPECT_EQ(nullptr, session_lua_user_defined_attribute_get(&a_stream)); EXPECT_EQ(nullptr, session_lua_user_defined_attribute_get(&a_stream));
} }
TEST(TSG_Bridge, BusinessS3FilenameAsync) TEST(TSGBridge, BusinessS3FilenameAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct business_notify_data bnd_label; struct business_notify_data bnd_label;
memset(&bnd_label, 0, sizeof(struct business_notify_data)); memset(&bnd_label, 0, sizeof(struct business_notify_data));
bnd_label.proto = PROTO_HTTP; bnd_label.proto = PROTO_HTTP;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].id, (void *)&bnd_label); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].id, (void *)&bnd_label);
struct business_notify_data *test = (struct business_notify_data *)session_business_data_get(&a_stream); struct business_notify_data *test = (struct business_notify_data *)session_business_data_get(&a_stream);
EXPECT_EQ(test->proto, PROTO_HTTP); EXPECT_EQ(test->proto, PROTO_HTTP);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_BUSINESS_S3_FILENAME].id, NULL);
EXPECT_EQ(nullptr, session_business_data_get(&a_stream)); EXPECT_EQ(nullptr, session_business_data_get(&a_stream));
} }
TEST(TSG_Bridge, AppBehaviorResultAsync) TEST(TSGBridge, AppBehaviorResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
char stream_behavior[10]; char stream_behavior[10];
struct application_behavior behavior_result = {0}; struct application_behavior behavior_result = {0};
behavior_result.stream_behavior = stream_behavior; behavior_result.stream_behavior = stream_behavior;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].id, (void *)&behavior_result); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].id, (void *)&behavior_result);
struct application_behavior *test = (struct application_behavior *)session_application_behavior_get(&a_stream); struct application_behavior *test = (struct application_behavior *)session_application_behavior_get(&a_stream);
EXPECT_EQ(test->stream_behavior, stream_behavior); EXPECT_EQ(test->stream_behavior, stream_behavior);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_APP_BEHAVIOR_RESULT].id, NULL);
EXPECT_EQ(nullptr, session_application_behavior_get(&a_stream)); EXPECT_EQ(nullptr, session_application_behavior_get(&a_stream));
} }
TEST(TSG_Bridge, PolicyActionParaExecResultAsync) TEST(TSGBridge, PolicyActionParaExecResultAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct tsg_notify_execution_result execution_result = {0}; struct tsg_notify_execution_result execution_result = {0};
execution_result.capture_result_cnt = 20; execution_result.capture_result_cnt = 20;
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].id, (void *)&execution_result); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].id, (void *)&execution_result);
struct tsg_notify_execution_result *test = (struct tsg_notify_execution_result *)session_mirrored_and_capture_packets_exec_result_get(&a_stream); struct tsg_notify_execution_result *test = (struct tsg_notify_execution_result *)session_mirrored_and_capture_packets_exec_result_get(&a_stream);
EXPECT_EQ(test->capture_result_cnt, 20); EXPECT_EQ(test->capture_result_cnt, 20);
stream_bridge_async_data_put(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].id, NULL); stream_bridge_async_data_put(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_POLICY_ACTION_PARA_EXEC_RESULT].id, NULL);
EXPECT_EQ(nullptr, session_mirrored_and_capture_packets_exec_result_get(&a_stream)); EXPECT_EQ(nullptr, session_mirrored_and_capture_packets_exec_result_get(&a_stream));
} }
TEST(TSG_Bridge, SegmentIdsAsync) TEST(TSGBridge, SegmentIdsAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct segment_id_list segment_ids = {0}; struct segment_id_list segment_ids = {0};
@@ -618,7 +618,7 @@ static void tsg_bridge_test_init_proxy(const struct streaminfo *a_stream, struct
memcpy(proxy->ssl_upstream_version, "thisisssl_upstream_version", strlen("thisisssl_upstream_version")); memcpy(proxy->ssl_upstream_version, "thisisssl_upstream_version", strlen("thisisssl_upstream_version"));
} }
extern void session_proxy_log_update_free(const struct streaminfo *a_stream, int bridge_id, void *data); extern void session_proxy_log_update_free(const struct streaminfo *a_stream, int bridge_id, void *data);
TEST(TSG_Bridge, LogUpdateProxyAsync) TEST(TSGBridge, LogUpdateProxyAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct proxy_log_update *proxy = (struct proxy_log_update *)dictator_malloc(a_stream.threadnum, sizeof(struct proxy_log_update)); struct proxy_log_update *proxy = (struct proxy_log_update *)dictator_malloc(a_stream.threadnum, sizeof(struct proxy_log_update));
@@ -630,12 +630,12 @@ TEST(TSG_Bridge, LogUpdateProxyAsync)
EXPECT_STREQ(test->ssl_passthrough_reason, "thisisssl_passthrough_reason"); EXPECT_STREQ(test->ssl_passthrough_reason, "thisisssl_passthrough_reason");
EXPECT_STREQ(test->ssl_downstream_version, "thisisssl_downstream_version"); EXPECT_STREQ(test->ssl_downstream_version, "thisisssl_downstream_version");
EXPECT_STREQ(test->ssl_upstream_version, "thisisssl_upstream_version"); EXPECT_STREQ(test->ssl_upstream_version, "thisisssl_upstream_version");
session_proxy_log_update_free(&a_stream, g_tm_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].id, test); session_proxy_log_update_free(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_LOG_UPDATE_PROXY].id, test);
session_log_update_data_put(&a_stream, TSG_SERVICE_INTERCEPT, NULL); session_log_update_data_put(&a_stream, TSG_SERVICE_INTERCEPT, NULL);
EXPECT_EQ(nullptr, session_log_update_data_get(&a_stream, TSG_SERVICE_INTERCEPT)); EXPECT_EQ(nullptr, session_log_update_data_get(&a_stream, TSG_SERVICE_INTERCEPT));
} }
TEST(TSG_Bridge, LogUpdateSceAsync) TEST(TSGBridge, LogUpdateSceAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct sce_log_update sce = {0}; struct sce_log_update sce = {0};
@@ -647,7 +647,7 @@ TEST(TSG_Bridge, LogUpdateSceAsync)
EXPECT_EQ(nullptr, session_log_update_data_get(&a_stream, TSG_SERVICE_CHAINING)); EXPECT_EQ(nullptr, session_log_update_data_get(&a_stream, TSG_SERVICE_CHAINING));
} }
TEST(TSG_Bridge, LogUpdateShaperAsync) TEST(TSGBridge, LogUpdateShaperAsync)
{ {
const struct streaminfo a_stream = {0}; const struct streaminfo a_stream = {0};
struct shaper_log_update shaper = {0}; struct shaper_log_update shaper = {0};
@@ -659,6 +659,193 @@ TEST(TSG_Bridge, LogUpdateShaperAsync)
EXPECT_EQ(nullptr, session_log_update_data_get(&a_stream, TSG_SERVICE_SHAPING)); EXPECT_EQ(nullptr, session_log_update_data_get(&a_stream, TSG_SERVICE_SHAPING));
} }
TEST(TSGBridge, SessionSessionRuntimeProcessContext)
{
}
TEST(TSGBridge, SessionSessionRuntimeActionContext)
{
}
extern int session_async_bridge_set_data(const struct streaminfo * a_stream, int bridge_id, void * data);
extern void session_runtime_attribute_free(const struct streaminfo * a_stream, int bridge_id, void * data);
TEST(TSGBridge, SessionSessionRuntimeAttributeTSG15457)
{
const struct streaminfo a_stream = {0};
struct session_runtime_attribute *srt_attribute = (struct session_runtime_attribute *)session_runtime_attribute_new(&a_stream);
srt_attribute->proto=PROTO_SSL;
int length=strlen("30625db44eaf886e65bebc8d1e62f368");
srt_attribute->ja3_fingerprint=(const char *)dictator_malloc(0, length+1);
memset((char *)srt_attribute->ja3_fingerprint, 0, length+1);
memcpy((void *)srt_attribute->ja3_fingerprint, (const void *)"30625db44eaf886e65bebc8d1e62f368", length);
srt_attribute->n_fqdn_category_ids=8;
for(size_t i=0; i<srt_attribute->n_fqdn_category_ids; i++)
{
srt_attribute->fqdn_category_ids[i]=10000+i;
}
srt_attribute->client_asn=(struct asn_info *)dictator_malloc(0, sizeof(struct asn_info));
srt_attribute->client_asn->ref_cnt=1;
srt_attribute->client_asn->asn_id=(char *)"1003";
srt_attribute->client_asn->organization=(char *)"china";
srt_attribute->server_asn=(struct asn_info *)dictator_malloc(0, sizeof(struct asn_info));
srt_attribute->server_asn->ref_cnt=1;
srt_attribute->server_asn->asn_id=(char *)"1004";
srt_attribute->server_asn->organization=(char *)"china";
srt_attribute->client_location=(struct location_info *)dictator_malloc(0, sizeof(struct location_info));
srt_attribute->client_location->ref_cnt=1;
srt_attribute->client_location->country_full=(char *)"china";
srt_attribute->client_location->province_full=(char *)"beijing";
srt_attribute->client_location->city_full=(char *)"west";
srt_attribute->client_location->subdivision_addr=(char *)"yuming road";
srt_attribute->server_location=(struct location_info *)dictator_malloc(0, sizeof(struct location_info));
srt_attribute->server_location->ref_cnt=1;
srt_attribute->server_location->country_full=(char *)"china";
srt_attribute->server_location->province_full=(char *)"shanghai";
srt_attribute->server_location->city_full=(char *)"east";
srt_attribute->server_location->subdivision_addr=(char *)"zhongshan road";
srt_attribute->client_subscribe_id=(struct subscribe_id_info *)dictator_malloc(0, sizeof(struct subscribe_id_info));
srt_attribute->client_subscribe_id->ref_cnt=1;
srt_attribute->client_subscribe_id->subscribe_id=(char *)"zhansan";
srt_attribute->server_subscribe_id=(struct subscribe_id_info *)dictator_malloc(0, sizeof(struct subscribe_id_info));
srt_attribute->server_subscribe_id->ref_cnt=1;
srt_attribute->server_subscribe_id->subscribe_id=(char *)"lisi";
srt_attribute->client_endpoint=(struct tunnel_endpoint *)dictator_malloc(0, sizeof(struct tunnel_endpoint));
srt_attribute->client_endpoint->id=1005;
srt_attribute->client_endpoint->ref_cnt=1;
srt_attribute->client_endpoint->description=(char *)"GTP";
srt_attribute->server_endpoint=(struct tunnel_endpoint *)dictator_malloc(0, sizeof(struct tunnel_endpoint));
srt_attribute->server_endpoint->id=1006;
srt_attribute->server_endpoint->ref_cnt=1;
srt_attribute->server_endpoint->description=(char *)"GTP";
srt_attribute->user_info=(struct umts_user_info *)dictator_malloc(0, sizeof(struct umts_user_info));
srt_attribute->user_info->ref_cnt=1;
srt_attribute->user_info->apn=(char *)"apn.beijing.net";
srt_attribute->user_info->imsi=(char *)"IMSI=123456";
srt_attribute->user_info->imei=(char *)"IMEI=7890";
srt_attribute->user_info->msisdn=(char *)"13500912083";
struct session_runtime_attribute *srt_attribute_out=(struct session_runtime_attribute *)session_runtime_attribute_get(&a_stream);
EXPECT_NE(nullptr, srt_attribute_out);
EXPECT_EQ(PROTO_SSL, srt_attribute_out->proto);
EXPECT_EQ(8, srt_attribute_out->n_fqdn_category_ids);
for(size_t i=0; i<srt_attribute_out->n_fqdn_category_ids; i++)
{
EXPECT_EQ(10000+i, srt_attribute_out->fqdn_category_ids[i]);
}
unsigned int fqdn_category_ids[MAX_CATEGORY_ID_NUM]={0};
size_t n_fqdn_category_ids=srt_attribute_get_category_ids((const struct session_runtime_attribute *)srt_attribute, fqdn_category_ids, MAX_CATEGORY_ID_NUM);
EXPECT_EQ(8, n_fqdn_category_ids);
for(size_t i=0; i<n_fqdn_category_ids; i++)
{
EXPECT_EQ(10000+i, fqdn_category_ids[i]);
}
EXPECT_STREQ("30625db44eaf886e65bebc8d1e62f368", srt_attribute_out->ja3_fingerprint);
EXPECT_STREQ("30625db44eaf886e65bebc8d1e62f368", srt_attribute_get_ja3_fingerprint(srt_attribute_out));
EXPECT_NE(nullptr, srt_attribute_out->client_endpoint);
EXPECT_EQ(1, srt_attribute_out->client_endpoint->ref_cnt);
EXPECT_EQ(1005, srt_attribute_out->client_endpoint->id);
EXPECT_STREQ("GTP", srt_attribute_out->client_endpoint->description);
EXPECT_NE(nullptr, srt_attribute_out->server_endpoint);
EXPECT_EQ(1, srt_attribute_out->server_endpoint->ref_cnt);
EXPECT_EQ(1006, srt_attribute_out->server_endpoint->id);
EXPECT_STREQ("GTP", srt_attribute_out->server_endpoint->description);
EXPECT_NE(nullptr, srt_attribute_out->user_info);
EXPECT_EQ(1, srt_attribute_out->user_info->ref_cnt);
EXPECT_STREQ("apn.beijing.net", srt_attribute_out->user_info->apn);
EXPECT_STREQ("IMSI=123456", srt_attribute_out->user_info->imsi);
EXPECT_STREQ("IMEI=7890", srt_attribute_out->user_info->imei);
EXPECT_STREQ("13500912083", srt_attribute_out->user_info->msisdn);
EXPECT_NE(nullptr, srt_attribute_out->client_asn);
EXPECT_EQ(1, srt_attribute_out->client_asn->ref_cnt);
EXPECT_STREQ("1003", srt_attribute_out->client_asn->asn_id);
EXPECT_STREQ("china", srt_attribute_out->client_asn->organization);
const struct asn_info * c_asn=srt_attribute_get_client_ip_asn((const struct session_runtime_attribute *)srt_attribute_out);
EXPECT_NE(nullptr, c_asn);
EXPECT_EQ(1, c_asn->ref_cnt);
EXPECT_STREQ("1003", c_asn->asn_id);
EXPECT_STREQ("china", c_asn->organization);
EXPECT_NE(nullptr, srt_attribute_out->server_asn);
EXPECT_EQ(1, srt_attribute_out->server_asn->ref_cnt);
EXPECT_STREQ("1004", srt_attribute_out->server_asn->asn_id);
EXPECT_STREQ("china", srt_attribute_out->server_asn->organization);
const struct asn_info * s_asn=srt_attribute_get_server_ip_asn((const struct session_runtime_attribute *)srt_attribute_out);
EXPECT_NE(nullptr, s_asn);
EXPECT_EQ(1, s_asn->ref_cnt);
EXPECT_STREQ("1004", s_asn->asn_id);
EXPECT_STREQ("china", s_asn->organization);
EXPECT_NE(nullptr, srt_attribute_out->client_location);
EXPECT_EQ(1, srt_attribute_out->client_location->ref_cnt);
EXPECT_STREQ("china", srt_attribute_out->client_location->country_full);
EXPECT_STREQ("beijing", srt_attribute_out->client_location->province_full);
EXPECT_STREQ("west", srt_attribute_out->client_location->city_full);
EXPECT_STREQ("yuming road", srt_attribute_out->client_location->subdivision_addr);
const struct location_info *c_location=srt_attribute_get_client_ip_location((const struct session_runtime_attribute *)srt_attribute_out);
EXPECT_NE(nullptr, c_location);
EXPECT_EQ(1, c_location->ref_cnt);
EXPECT_STREQ("china", c_location->country_full);
EXPECT_STREQ("beijing", c_location->province_full);
EXPECT_STREQ("west", c_location->city_full);
EXPECT_STREQ("yuming road", c_location->subdivision_addr);
EXPECT_NE(nullptr, srt_attribute_out->server_location);
EXPECT_EQ(1, srt_attribute_out->server_location->ref_cnt);
EXPECT_STREQ("china", srt_attribute_out->server_location->country_full);
EXPECT_STREQ("shanghai", srt_attribute_out->server_location->province_full);
EXPECT_STREQ("east", srt_attribute_out->server_location->city_full);
EXPECT_STREQ("zhongshan road", srt_attribute_out->server_location->subdivision_addr);
const struct location_info *s_location=srt_attribute_get_server_ip_location((const struct session_runtime_attribute *)srt_attribute_out);
EXPECT_NE(nullptr, s_location);
EXPECT_EQ(1, s_location->ref_cnt);
EXPECT_STREQ("china", s_location->country_full);
EXPECT_STREQ("shanghai", s_location->province_full);
EXPECT_STREQ("east", s_location->city_full);
EXPECT_STREQ("zhongshan road", s_location->subdivision_addr);
EXPECT_NE(nullptr, srt_attribute_out->client_subscribe_id);
EXPECT_EQ(1, srt_attribute_out->client_subscribe_id->ref_cnt);
EXPECT_STREQ("zhansan", srt_attribute_out->client_subscribe_id->subscribe_id);
EXPECT_STREQ("zhansan", srt_attribute_get_client_subscriber_id((const struct session_runtime_attribute *)srt_attribute_out));
EXPECT_NE(nullptr, srt_attribute_out->server_subscribe_id);
EXPECT_EQ(1, srt_attribute_out->server_subscribe_id->ref_cnt);
EXPECT_STREQ("lisi", srt_attribute_out->server_subscribe_id->subscribe_id);
EXPECT_STREQ("lisi", srt_attribute_get_server_subscriber_id((const struct session_runtime_attribute *)srt_attribute_out));
session_runtime_attribute_free(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, (void *)srt_attribute_out);
session_async_bridge_set_data(&a_stream, g_tsg_bridge_para[BRIDGE_TYPE_SESSION_ATTRIBUTE].id, NULL);
EXPECT_EQ(nullptr, session_runtime_attribute_get(&a_stream));
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret=tsg_bridge_init("tsgconf/main.conf"); int ret=tsg_bridge_init("tsgconf/main.conf");

View File

@@ -1008,7 +1008,6 @@ TEST(TSGMaster, SessionApplicationMetrics)
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
TSG_MASTER_INIT(); TSG_MASTER_INIT();