diff --git a/inc/tsg_statistic.h b/inc/tsg_statistic.h index 9abe6ad..980ffef 100644 --- a/inc/tsg_statistic.h +++ b/inc/tsg_statistic.h @@ -1,6 +1,16 @@ #ifndef __TSG_STATISTIC_H__ #define __TSG_STATISTIC_H__ +struct _traffic_info +{ + long long con_num; + long long in_bytes; + long long out_bytes; + long long in_packets; + long long out_packets; +}; + int tsg_set_policy_flow(struct streaminfo *a_stream, Maat_rule_t *p_result, int thread_seq); +int tsg_set_intercept_flow(Maat_rule_t *p_result, struct _traffic_info *traffic_info, int thread_seq); #endif diff --git a/src/tsg_entry.h b/src/tsg_entry.h index c0e6ff8..6777163 100644 --- a/src/tsg_entry.h +++ b/src/tsg_entry.h @@ -127,15 +127,6 @@ enum TRAFFIC_INFO_IDX TRAFFIC_INFO_MAX }; -struct _traffic_info -{ - long long con_num; - long long in_bytes; - long long out_bytes; - long long in_packets; - long long out_packets; -}; - typedef struct _tsg_statistic { int cycle; diff --git a/src/tsg_statistic.cpp b/src/tsg_statistic.cpp index 92e54ec..67a787a 100644 --- a/src/tsg_statistic.cpp +++ b/src/tsg_statistic.cpp @@ -12,6 +12,24 @@ tsg_statis_para_t g_tsg_statis_para; +int tsg_set_intercept_flow(Maat_rule_t *p_result, struct _traffic_info *traffic_info, int thread_seq) +{ + struct _traffic_info *_info=NULL; + + if(p_result!=NULL && traffic_info!=NULL && thread_seq>=0) + { + _info=&(g_tsg_statis_para.traffic_info[(unsigned char)p_result->action][thread_seq]); + + _info->con_num+=traffic_info->con_num; + _info->in_bytes+=traffic_info->in_bytes; + _info->in_packets+=traffic_info->in_packets; + _info->out_bytes+=traffic_info->out_bytes; + _info->out_packets+=traffic_info->out_packets; + } + + return 0; +} + int tsg_set_policy_flow(struct streaminfo *a_stream, Maat_rule_t *p_result, int thread_seq) { unsigned long long value=0;