From eadf2aa34853b6b037bc388a87eac6982aab802a Mon Sep 17 00:00:00 2001 From: liuxueli Date: Fri, 15 May 2020 17:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E4=BF=9D=E8=AF=81pinnigl?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=AE=A1=E6=95=B0=E6=97=B6=E9=97=B4=E4=B8=8E?= =?UTF-8?q?intecept=E7=9A=84=E9=93=BE=E6=8E=A5=E8=AE=A1=E6=95=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E4=BE=9Btsg=5Fset=5Fintercept=5Fflow=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/tsg_statistic.h | 10 ++++++++++ src/tsg_entry.h | 9 --------- src/tsg_statistic.cpp | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) 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;