diff options
| author | lijia <[email protected]> | 2020-11-17 22:07:02 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2020-11-17 22:07:02 +0800 |
| commit | 5f789f63d66c65916a13788d54f3097b9202b4b8 (patch) | |
| tree | 81ff40ec92097735d4fd232bcfd46e3f7eca1765 | |
| parent | cd822b1e60cb55c65421d97d1ce966efe1a47ad0 (diff) | |
增加新的选项MSO_TOTAL_INBOUND_BYTE_RAW,MSO_TOTAL_OUTBOUND_BYTE_RAW,用于获取当前流的真实原始包长度(包括ip header, ethernet header, etc.)v4.2.7
| -rw-r--r-- | include/public/stream_inc/stream_control.h | 5 | ||||
| -rw-r--r-- | include/public/stream_inc/stream_project.h | 10 | ||||
| -rw-r--r-- | src/dealpkt/deal_tcp.c | 20 | ||||
| -rw-r--r-- | src/dealpkt/deal_udp.c | 12 | ||||
| -rw-r--r-- | src/dealpkt/plug_support.c | 148 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 57 |
6 files changed, 231 insertions, 21 deletions
diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h index b38c651..2ff890c 100644 --- a/include/public/stream_inc/stream_control.h +++ b/include/public/stream_inc/stream_control.h @@ -5,7 +5,7 @@ extern "C" {
#endif
-#define STREAM_CONTROL_H_VERSION (20200915)
+#define STREAM_CONTROL_H_VERSION (20201117)
#define TCP_CTEAT_LINK_BYSYN 0x01 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
#define TCP_CTEAT_LINK_BYDATA 0x02 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
@@ -39,6 +39,9 @@ enum MESA_stream_opt{ MSO_TOTAL_OUTBOUND_PKT, /* outbound packet pkt of this stream, opt_val type must be unsigned long long */
MSO_TOTAL_OUTBOUND_BYTE,/* outbound packet byte of this stream, opt_val type must be unsigned long long */
MSO_STREAM_CREATE_TIMESTAMP_MS,/* first c2s pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
+
+ MSO_TOTAL_INBOUND_BYTE_RAW, /* inbound packet byte of this stream, raw packet len, include ip hdr, ethernet hdr... opt_val type must be unsigned long long */
+ MSO_TOTAL_OUTBOUND_BYTE_RAW,/* outbound packet byte of this stream, raw packet len, include ip hdr, ethernet hdr... opt_val type must be unsigned long long */
__MSO_MAX,
};
diff --git a/include/public/stream_inc/stream_project.h b/include/public/stream_inc/stream_project.h index 35cc685..bd41719 100644 --- a/include/public/stream_inc/stream_project.h +++ b/include/public/stream_inc/stream_project.h @@ -7,7 +7,7 @@ extern "C" {
#endif
-#define STREAM_PROJECT_H_VERSION (20160118)
+#define STREAM_PROJECT_H_VERSION (20201117)
#define PROJECT_REQ_NAME_MAX_LEN (64)
@@ -58,6 +58,10 @@ struct tcp_flow_stat UINT64 C2S_data_byte;
UINT64 S2C_all_byte;
UINT64 S2C_data_byte;
+
+ /* ������2020-11-17����, �������еײ��ͷ��ԭʼ������, ֮ǰ���ڴ�ṹ����, ��ǰ���� */
+ UINT64 C2S_all_byte_raw;
+ UINT64 S2C_all_byte_raw;
};
struct udp_flow_stat
@@ -66,6 +70,10 @@ struct udp_flow_stat UINT32 S2C_pkt;
UINT64 C2S_byte;
UINT64 S2C_byte;
+
+ /* ������2020-11-17����, �������еײ��ͷ��ԭʼ������, ֮ǰ���ڴ�ṹ����, ��ǰ���� */
+ UINT64 C2S_all_byte_raw;
+ UINT64 S2C_all_byte_raw;
};
/*
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c index c413bba..5321549 100644 --- a/src/dealpkt/deal_tcp.c +++ b/src/dealpkt/deal_tcp.c @@ -743,17 +743,21 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, if(DIR_C2S == pstream->curdir){ pdetail_pr->flow_stat->C2S_all_pkt++; pdetail_pr->flow_stat->C2S_all_byte += datalen; + pdetail_pr->flow_stat->C2S_all_byte_raw += raw_pkt->raw_pkt_len; }else{ pdetail_pr->flow_stat->S2C_all_pkt++; pdetail_pr->flow_stat->S2C_all_byte += datalen; + pdetail_pr->flow_stat->S2C_all_byte_raw += raw_pkt->raw_pkt_len; } }else{ if(DIR_C2S == pstream->curdir){ pdetail_pr->flow_stat->C2S_all_pkt = 1; pdetail_pr->flow_stat->C2S_all_byte = datalen; + pdetail_pr->flow_stat->C2S_all_byte_raw = raw_pkt->raw_pkt_len; }else{ pdetail_pr->flow_stat->S2C_all_pkt = 1; pdetail_pr->flow_stat->S2C_all_byte = datalen; + pdetail_pr->flow_stat->S2C_all_byte_raw = raw_pkt->raw_pkt_len; } } } @@ -987,9 +991,11 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, if(pstream->curdir == DIR_C2S){ pdetail_pr->flow_stat->C2S_all_pkt = 1; pdetail_pr->flow_stat->C2S_all_byte = datalen; + pdetail_pr->flow_stat->C2S_all_byte_raw = raw_pkt->raw_pkt_len; }else{ pdetail_pr->flow_stat->S2C_all_pkt = 1; - pdetail_pr->flow_stat->S2C_all_byte = datalen; + pdetail_pr->flow_stat->S2C_all_byte = datalen; + pdetail_pr->flow_stat->S2C_all_byte_raw = raw_pkt->raw_pkt_len; } } /* NOTE, tcp_data������stream_process_tcp()���ۼ� */ @@ -1322,9 +1328,11 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, if(DIR_C2S == pstream->curdir){ pdetail_pr->flow_stat->C2S_all_pkt--; pdetail_pr->flow_stat->C2S_all_byte -= datalen; + pdetail_pr->flow_stat->C2S_all_byte_raw -= raw_pkt->raw_pkt_len; }else{ pdetail_pr->flow_stat->S2C_all_pkt--; pdetail_pr->flow_stat->S2C_all_byte -= datalen; + pdetail_pr->flow_stat->S2C_all_byte_raw -= raw_pkt->raw_pkt_len; } } @@ -2456,9 +2464,11 @@ static char tcp_process_newstreambydata(struct streamindex *pindex_tcp,const voi if(DIR_S2C == pstream->curdir){ pdetail_pr->flow_stat->S2C_all_pkt++; pdetail_pr->flow_stat->S2C_all_byte += tcplen; + pdetail_pr->flow_stat->S2C_all_byte_raw += raw_pkt->raw_pkt_len; }else{ pdetail_pr->flow_stat->C2S_all_pkt++; pdetail_pr->flow_stat->C2S_all_byte += tcplen; + pdetail_pr->flow_stat->C2S_all_byte_raw += raw_pkt->raw_pkt_len; } } @@ -2602,7 +2612,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s /* 2014-10-11 lijia add, Fd������ƽ̨ʵ�� */ if(unlikely(pstream_pr->stream_killed_flag != 0)){ if((pdetail_pr->auto_remedy_flag != 0) && (tcplen > 0)){ /* ��ֹflood����, ֻ�д����ݵİ��ŷ�RST */ - sapp_runtime_log(RLOG_LV_INFO, "TCP stream: %s, kill_tcp remedy, curdir:%d, send RST pkt.", + sapp_runtime_log(RLOG_LV_DEBUG, "TCP stream: %s, kill_tcp remedy, curdir:%d, send RST pkt.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); MESA_kill_tcp_remedy(pstream, raw_pkt); } @@ -2617,7 +2627,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } if(unlikely(pdetail_pr->drop_stream_flag != 0)){ - sapp_runtime_log(RLOG_LV_INFO, "TCP stream: %s, has been set drop flag, curdir:%d, return DROP.", + sapp_runtime_log(RLOG_LV_DEBUG, "TCP stream: %s, has been set drop flag, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); return DROP; } @@ -2652,9 +2662,11 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s if(DIR_C2S == pstream->curdir){ pdetail_pr->flow_stat->C2S_all_pkt++; pdetail_pr->flow_stat->C2S_all_byte += tcplen; + pdetail_pr->flow_stat->C2S_all_byte_raw += raw_pkt->raw_pkt_len; }else{ pdetail_pr->flow_stat->S2C_all_pkt++; pdetail_pr->flow_stat->S2C_all_byte += tcplen; + pdetail_pr->flow_stat->S2C_all_byte_raw += raw_pkt->raw_pkt_len; } } @@ -2756,7 +2768,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s fun_exit: if(DROP == ret){ - sapp_runtime_log(RLOG_LV_INFO, "TCP stream: %s, tcphdr->checksum:0x%x, curdir:%d, return DROP.", + sapp_runtime_log(RLOG_LV_DEBUG, "TCP stream: %s, tcphdr->checksum:0x%x, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), ntohs(this_tcphdr->th_sum), pstream->curdir); } diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c index fa0f45e..b5c5e67 100644 --- a/src/dealpkt/deal_udp.c +++ b/src/dealpkt/deal_udp.c @@ -21,7 +21,7 @@ extern int guess_if_teredo(const struct streaminfo *pstream, struct mesa_udp_hdr int G_UDP_FLOW_STAT_PROJECT_ID = -1; int G_UDP_TEREDO_IDENTIFY_PROJECT_ID = -1; -static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_hdr *udph) +static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_hdr *udph, const raw_pkt_t *raw_pkt) { int ulen =0; int datalen =0; @@ -47,6 +47,7 @@ static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_ if(G_UDP_FLOW_STAT_PROJECT_ID != -1){ pdetail_pr->flow_stat->C2S_pkt++; pdetail_pr->flow_stat->C2S_byte += datalen; + pdetail_pr->flow_stat->C2S_all_byte_raw += raw_pkt->raw_pkt_len; } } else @@ -60,6 +61,7 @@ static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_ if(G_UDP_FLOW_STAT_PROJECT_ID != -1){ pdetail_pr->flow_stat->S2C_pkt++; pdetail_pr->flow_stat->S2C_byte += datalen; + pdetail_pr->flow_stat->S2C_all_byte_raw += raw_pkt->raw_pkt_len; } } @@ -570,7 +572,7 @@ static int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr update_polling_inject_context(pstream_pr, raw_pkt); - udp_change_stream_state(a_index,udph); + udp_change_stream_state(a_index,udph, raw_pkt); //udp stream �ص� /* IP, UDP��ϲ���, ���ٸ���UDP���offset_to_raw_pkt_hdr */ @@ -621,7 +623,7 @@ static int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr #endif if(DROP == ret){ - sapp_runtime_log(RLOG_LV_INFO, "UDP stream: %s, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); + sapp_runtime_log(RLOG_LV_DEBUG, "UDP stream: %s, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); } return ret; @@ -764,7 +766,7 @@ int dealipv6udppkt(struct streamindex *pindex,const struct mesa_ip6_hdr *a_packe (struct streaminfo_private *)(pindex->stream.stream_public.pfather), pstream->curdir); } - udp_change_stream_state(a_index,udph); + udp_change_stream_state(a_index,udph, raw_pkt); /* ����pstreamָ�� */ pstream_pr=&(a_index->stream); @@ -786,7 +788,7 @@ int dealipv6udppkt(struct streamindex *pindex,const struct mesa_ip6_hdr *a_packe /* TODO 2, ����IPv6��UDP port 1701 L2TPЭ�� */ if(DROP == ret){ - sapp_runtime_log(RLOG_LV_INFO, "UDP stream: %s, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); + sapp_runtime_log(RLOG_LV_DEBUG, "UDP stream: %s, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); } return ret; diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c index a008c5e..66e2a9a 100644 --- a/src/dealpkt/plug_support.c +++ b/src/dealpkt/plug_support.c @@ -8,9 +8,9 @@ #ifdef __cplusplus extern "C" { #endif +extern int G_TCP_FLOW_STAT_PROJECT_ID ; +extern int G_UDP_FLOW_STAT_PROJECT_ID ; -//int G_DICTATOR_SW = 1; -//extern int g_packet_io_thread_num; extern const raw_ipfrag_list_t *get_raw_frag_list(const struct streaminfo *stream); #if IOMODE_MARSIO @@ -513,6 +513,82 @@ int get_thread_count(void) return g_packet_io_thread_num; } +/* + ctype: + 'c':count; + 'l':length; +*/ +static inline unsigned long long __get_stream_opt_traffic_raw(int cltype, int iotype, struct streaminfo_private *pstream_pr) +{ + unsigned long long tval; + struct streaminfo *pstream = &pstream_pr->stream_public; + + if('c' == cltype){ /* count */ + if('i' == iotype){ /* inbound */ + if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = pstream->ptcpdetail->serverpktnum; + }else{ + tval = pstream->pudpdetail->serverpktnum; + } + }else{ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = pstream->ptcpdetail->clientpktnum; + }else{ + tval = pstream->pudpdetail->clientpktnum; + } + } + }else{ /* outbound */ + if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = pstream->ptcpdetail->clientpktnum; + }else{ + tval = pstream->pudpdetail->clientpktnum; + } + }else{ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = pstream->ptcpdetail->serverpktnum; + }else{ + tval = pstream->pudpdetail->serverpktnum; + } + } + } + }else{/* length */ + if('i' == iotype){ /* inbound */ + if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = ((struct tcpdetail_private *)pstream->ptcpdetail)->flow_stat->C2S_all_byte_raw; + }else{ + tval = ((struct udpdetail_private *)pstream->pudpdetail)->flow_stat->C2S_all_byte_raw; + } + }else{ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = ((struct tcpdetail_private *)pstream->ptcpdetail)->flow_stat->S2C_all_byte_raw; + }else{ + tval = ((struct udpdetail_private *)pstream->pudpdetail)->flow_stat->S2C_all_byte_raw; + } + } + }else{ /* outbound */ + if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = ((struct tcpdetail_private *)pstream->ptcpdetail)->flow_stat->S2C_all_byte_raw; + }else{ + tval = ((struct udpdetail_private *)pstream->pudpdetail)->flow_stat->S2C_all_byte_raw; + } + }else{ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ + tval = ((struct tcpdetail_private *)pstream->ptcpdetail)->flow_stat->C2S_all_byte_raw; + }else{ + tval = ((struct udpdetail_private *)pstream->pudpdetail)->flow_stat->C2S_all_byte_raw; + } + } + } + } + + return tval; +} + + /* ctype: @@ -527,13 +603,13 @@ static inline unsigned long long __get_stream_opt_traffic(int cltype, int iotype if('c' == cltype){ /* count */ if('i' == iotype){ /* inbound */ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->serverpktnum; }else{ tval = pstream->pudpdetail->serverpktnum; } }else{ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->clientpktnum; }else{ tval = pstream->pudpdetail->clientpktnum; @@ -541,13 +617,13 @@ static inline unsigned long long __get_stream_opt_traffic(int cltype, int iotype } }else{ /* outbound */ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->clientpktnum; }else{ tval = pstream->pudpdetail->clientpktnum; } }else{ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->serverpktnum; }else{ tval = pstream->pudpdetail->serverpktnum; @@ -557,13 +633,13 @@ static inline unsigned long long __get_stream_opt_traffic(int cltype, int iotype }else{/* length */ if('i' == iotype){ /* inbound */ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->serverbytes; }else{ tval = pstream->pudpdetail->serverbytes; } }else{ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->clientbytes; }else{ tval = pstream->pudpdetail->clientbytes; @@ -571,13 +647,13 @@ static inline unsigned long long __get_stream_opt_traffic(int cltype, int iotype } }else{ /* outbound */ if(sapp_global_val->config.packet_io.inbound_route_dir == pstream_pr->stream_c2s_route_dir){ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->clientbytes; }else{ tval = pstream->pudpdetail->clientbytes; } }else{ - if(STREAM_TYPE_TCP != pstream_pr->stream_public.type){ + if(STREAM_TYPE_TCP == pstream_pr->stream_public.type){ tval = pstream->ptcpdetail->serverbytes; }else{ tval = pstream->pudpdetail->serverbytes; @@ -1127,6 +1203,32 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o } break; + case MSO_TOTAL_INBOUND_BYTE_RAW: + { + if(STREAM_TYPE_TCP == pstream->type){ + if(G_TCP_FLOW_STAT_PROJECT_ID == -1){ + ret = -1; + sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE_RAW error: project tcp_flow_stat is not enable!\n"); + break; + } + }else if(STREAM_TYPE_UDP == pstream->type){ + if(G_UDP_FLOW_STAT_PROJECT_ID == -1){ + ret = -1; + sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE_RAW error: project udp_flow_stat is not enable!\n"); + break; + } + }else{ + sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE error: stream type is not tcp or udp!\n"); + ret = -1; + break; + } + + unsigned long long *inbound_byte = (unsigned long long *)opt_val; + *inbound_byte = __get_stream_opt_traffic_raw('l', 'i', (struct streaminfo_private *)pstream); + } + break; + + case MSO_TOTAL_OUTBOUND_BYTE: { if((STREAM_TYPE_TCP != pstream->type) && (STREAM_TYPE_UDP != pstream->type)){ @@ -1138,6 +1240,32 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o *outbound_byte = __get_stream_opt_traffic('l', 'o', (struct streaminfo_private *)pstream); } break; + + case MSO_TOTAL_OUTBOUND_BYTE_RAW: + { + if(STREAM_TYPE_TCP == pstream->type){ + if(G_TCP_FLOW_STAT_PROJECT_ID == -1){ + ret = -1; + sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE_RAW error: project tcp_flow_stat is not enable!\n"); + break; + } + }else if(STREAM_TYPE_UDP == pstream->type){ + if(G_UDP_FLOW_STAT_PROJECT_ID == -1){ + ret = -1; + sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE_RAW error: project udp_flow_stat is not enable!\n"); + break; + } + }else{ + sapp_runtime_log(RLOG_LV_INFO, "MESA_get_stream_opt() MSO_TOTAL_INBOUND_BYTE error: stream type is not tcp or udp!\n"); + ret = -1; + break; + } + + unsigned long long *outbound_byte = (unsigned long long *)opt_val; + *outbound_byte = __get_stream_opt_traffic_raw('l', 'o', (struct streaminfo_private *)pstream); + } + break; + case MSO_STREAM_CREATE_TIMESTAMP_MS: { if ((STREAM_TYPE_TCP != pstream->type) && (STREAM_TYPE_UDP != pstream->type)) diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c index 46a6bb7..30d4520 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -452,6 +452,7 @@ char test_set_stream_timeout(struct streaminfo *pstream, void **pme, int thread char test_sapp_get_platform_opt(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) { unsigned long long totpkt, totbyte, rand_num; + unsigned long long totpkt_in, totpkt_out; int opt_len; char time_str[32]; @@ -466,6 +467,13 @@ char test_sapp_get_platform_opt(struct streaminfo *pstream, void **pme, int thr opt_len = sizeof(long long ); sapp_get_platform_opt(SPO_RAND_NUMBER, &rand_num, &opt_len); + opt_len = sizeof(long long ); + sapp_get_platform_opt(SPO_TOTAL_INBOUND_PKT, &totpkt_in, &opt_len); + + opt_len = sizeof(long long ); + sapp_get_platform_opt(SPO_TOTAL_OUTBOUND_PKT, &totpkt_out, &opt_len); + + printf("tot recv pkt by sapp_get_platform_opt is:%llu\n", totpkt); printf("tot recv byte by sapp_get_platform_opt is:%llu\n", totbyte); @@ -474,6 +482,10 @@ char test_sapp_get_platform_opt(struct streaminfo *pstream, void **pme, int thr printf("randnum by sapp_get_platform_opt is:%llu\n", rand_num); + printf("tot recv inbound pkt by sapp_get_platform_opt is:%llu\n", totpkt_in); + printf("tot recv outbound pkt by sapp_get_platform_opt is:%llu\n", totpkt_out); + + return APP_STATE_GIVEME; } @@ -511,6 +523,51 @@ char test_get_stream_in_out_bound(struct streaminfo *pstream, void **pme, int t return APP_STATE_GIVEME; } + +char test_stream_with_platform_in_out_traffic(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) +{ + unsigned long long stream_totpkt_in = 0, stream_totpkt_out = 0, stream_totbyte_in = 0, stream_totbyte_out = 0; + unsigned long long platform_totpkt_in = 0, platform_totpkt_out = 0, platform_totbyte_in = 0, platform_totbyte_out = 0; + + int opt_len; + + if(pstream->opstate== OP_STATE_CLOSE){ + opt_len = sizeof(long long ); + sapp_get_platform_opt(SPO_TOTAL_INBOUND_PKT, &platform_totpkt_in, &opt_len); + + opt_len = sizeof(long long ); + sapp_get_platform_opt(SPO_TOTAL_OUTBOUND_PKT, &platform_totpkt_out, &opt_len); + + opt_len = sizeof(long long ); + sapp_get_platform_opt(SPO_TOTAL_INBOUND_BYTE, &platform_totbyte_in, &opt_len); + + opt_len = sizeof(long long ); + sapp_get_platform_opt(SPO_TOTAL_OUTBOUND_BYTE, &platform_totbyte_out, &opt_len); + + + + opt_len = sizeof(long long); + MESA_get_stream_opt(pstream, MSO_TOTAL_INBOUND_PKT, &stream_totpkt_in, &opt_len); + + opt_len = sizeof(long long); + //MESA_get_stream_opt(pstream, MSO_TOTAL_INBOUND_BYTE, &stream_totbyte_in, &opt_len); + MESA_get_stream_opt(pstream, MSO_TOTAL_INBOUND_BYTE_RAW, &stream_totbyte_in, &opt_len); + + opt_len = sizeof(long long); + MESA_get_stream_opt(pstream, MSO_TOTAL_OUTBOUND_PKT, &stream_totpkt_out, &opt_len); + + opt_len = sizeof(long long); + //MESA_get_stream_opt(pstream, MSO_TOTAL_OUTBOUND_BYTE, &stream_totbyte_out, &opt_len); + MESA_get_stream_opt(pstream, MSO_TOTAL_OUTBOUND_BYTE_RAW, &stream_totbyte_out, &opt_len); + + printf("stream : pkt_in:%llu, pkt_out:%llu, byte_in:%llu, byte_out:%llu\n", stream_totpkt_in, stream_totpkt_out, stream_totbyte_in, stream_totbyte_out); + printf("platform: pkt_in:%llu, pkt_out:%llu, byte_in:%llu, byte_out:%llu\n", platform_totpkt_in, platform_totpkt_out, platform_totbyte_in, platform_totbyte_out); + } + + return APP_STATE_GIVEME; +} + + int test_sapp_get_device_opt(const char *device) { int ret; |
