diff options
| author | 李佳 <[email protected]> | 2020-11-24 18:28:05 +0800 |
|---|---|---|
| committer | 李佳 <[email protected]> | 2020-11-24 18:28:05 +0800 |
| commit | 938a21ac332ff0969ee836dd22337340217eeb25 (patch) | |
| tree | 527e1c126b4c16224c67b44c6a324f37fe1e4ce9 | |
| parent | 87a352990460d2790f8f59547f27d0c14c75c9ec (diff) | |
Fix dev4.1 charset error
| -rw-r--r-- | include/public/stream_inc/stream_control.h | 57 | ||||
| -rw-r--r-- | include/public/stream_inc/stream_project.h | 2 | ||||
| -rw-r--r-- | src/dealpkt/deal_tcp.c | 598 | ||||
| -rw-r--r-- | src/dealpkt/deal_udp.c | 2 | ||||
| -rw-r--r-- | src/dealpkt/plug_support.c | 17 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 58 |
6 files changed, 355 insertions, 379 deletions
diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h index b808f57..93130d7 100644 --- a/include/public/stream_inc/stream_control.h +++ b/include/public/stream_inc/stream_control.h @@ -39,7 +39,6 @@ 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,
@@ -124,8 +123,8 @@ struct max_unorder_opt{ unsigned short max_unorder_val;
};
-#define MAX_TCP_OPT_LEN (38) /* TCPͷ�������Ϊ60�ֽ�, ȥ����ͷ��ʣ��ѡ����40�ֽ�, ѡ�����ݲ����38�ֽ� */
-#define MAX_TCP_OPT_NUM (20) /* ����TCP�����ѡ������ */
+#define MAX_TCP_OPT_LEN (38) /* TCPͷ�������Ϊ60�ֽ�, ȥ����ͷ��ʣ��ѡ����40�ֽ�, ѡ�����ݲ����38�ֽ� */
+#define MAX_TCP_OPT_NUM (20) /* ����TCP�����ѡ������ */
enum tcp_option_value{
TCP_OPT_EOL = 0,
@@ -172,21 +171,21 @@ struct tcp_option_ext{ } __attribute__((packed, aligned(1)));
-/* 2018-10-24 lijia add, for pangu ��Ŀmac_in_mac����.
- ������, sappƽ̨��Ӧ�ù��ĺ�ҵ��������صĶ���, ����mac���ĸ��ֶ���link_id, �ĸ���dev_id,
- ���������̫�ײ���, ƽ̨����GDEV����RST��ҲҪ�����Щֵ, ����ƽ̨����!!
+/* 2018-10-24 lijia add, for pangu ��Ŀmac_in_mac����.
+ ������, sappƽ̨��Ӧ�ù��ĺ�ҵ��������صĶ���, ����mac���ĸ��ֶ���link_id, �ĸ���dev_id,
+ ���������̫�ײ���, ƽ̨����GDEV����RST��ҲҪ�����Щֵ, ����ƽ̨����!!
*/
-/* Ϊ�˷���ҵ������ȡmac_in_mac��ַ��ľ�����Ϣ, ����ʹ��ԭʼ��bitλ��, ת���ɱ�����ʽ */
+/* Ϊ�˷���ҵ������ȡmac_in_mac��ַ��ľ�����Ϣ, ����ʹ��ԭʼ��bitλ��, ת���ɱ�����ʽ */
struct vxlan_info{
- unsigned char encap_type; /* ԭʼ�����װ��ʽ */
- unsigned char entrance_id; /* �豸���ڳ����ID */
- unsigned char dev_id; /* �豸ID */
- unsigned char link_id; /* ��·ID */
- unsigned char link_dir; /* ��·����, ָ��ǰ��Ԫ���IP������ʱ�Ĵ��䷽��, ����TCP, SYN���Ĵ��䷽��; ����UDP, �˿ڴ�IP�Ĵ��䷽�� */
- unsigned char inner_smac[18]; /* �ڲ���ʵSMAC, string����, ��: "11:22:33:44:55:66" */
- unsigned char inner_dmac[18]; /* �ڲ���ʵDMAC, string����, ��: "11:22:33:44:55:66" */
- unsigned char inner_smac_hex[6]; /* �ڲ���ʵSMAC, ԭʼ���������� */
- unsigned char inner_dmac_hex[6]; /* �ڲ���ʵDMAC, ԭʼ���������� */
+ unsigned char encap_type; /* ԭʼ�����װ��ʽ */
+ unsigned char entrance_id; /* �豸���ڳ����ID */
+ unsigned char dev_id; /* �豸ID */
+ unsigned char link_id; /* ��·ID */
+ unsigned char link_dir; /* ��·����, ָ��ǰ��Ԫ���IP������ʱ�Ĵ��䷽��, ����TCP, SYN���Ĵ��䷽��; ����UDP, �˿ڴ�IP�Ĵ��䷽�� */
+ unsigned char inner_smac[18]; /* �ڲ���ʵSMAC, string����, ��: "11:22:33:44:55:66" */
+ unsigned char inner_dmac[18]; /* �ڲ���ʵDMAC, string����, ��: "11:22:33:44:55:66" */
+ unsigned char inner_smac_hex[6]; /* �ڲ���ʵSMAC, ԭʼ���������� */
+ unsigned char inner_dmac_hex[6]; /* �ڲ���ʵDMAC, ԭʼ���������� */
};
@@ -262,14 +261,14 @@ int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_type, void /***************************************************************************************
NOTE:
- �ڱ���ģʽ��, ����������route_dir�ľ���ֵ, ֻ��Ҫ����ͬ��ͷ���,
- ��������������Ҫ��ȷ����route_dir��0����1, �������������ģʽ��ͬ, ������ʱ��仯,
- �������ô˽ӿ�, ���ֻ�贫����������ķ���human_dir, ���ص�ǰ��·��link route dir,
- ע���״β���ʱ, etc/sapp.toml->inbound_route_dirһ��Ҫ������ȷ.
+ �ڱ���ģʽ��, ����������route_dir�ľ���ֵ, ֻ��Ҫ����ͬ��ͷ���,
+ ��������������Ҫ��ȷ����route_dir��0����1, �������������ģʽ��ͬ, ������ʱ��仯,
+ �������ô˽ӿ�, ���ֻ�贫����������ķ���human_dir, ���ص�ǰ��·��link route dir,
+ ע���״β���ʱ, etc/sapp.toml->inbound_route_dirһ��Ҫ������ȷ.
- args: ��ʾ����Ŀ������ڵ�ǰ�豸���ڵĵ���λ��,
- 'E' or 'e': ��ʾ���ݰ����䷽���Ǵ�Internal to External.
- 'I' or 'i': ��ʾ���ݰ����䷽���Ǵ�External to Internal.
+ args: ��ʾ����Ŀ������ڵ�ǰ�豸���ڵĵ���λ��,
+ 'E' or 'e': ��ʾ���ݰ����䷽���Ǵ�Internal to External.
+ 'I' or 'i': ��ʾ���ݰ����䷽���Ǵ�External to Internal.
return value:
0 or 1: success.
@@ -279,19 +278,19 @@ int MESA_dir_human_to_link(int human_dir); /*
args:
- ��·���䷽��: 0��1, ͨ������stream->routedir;
+ ��·���䷽��: 0��1, ͨ������stream->routedir;
- ����ֵ:
- 'E' or 'e': ��ʾ���ݰ����䷽���Ǵ�Internal to External.
- 'I' or 'i': ��ʾ���ݰ����䷽���Ǵ�External to Internal.
- 'x': ��������;
+ ����ֵ:
+ 'E' or 'e': ��ʾ���ݰ����䷽���Ǵ�Internal to External.
+ 'I' or 'i': ��ʾ���ݰ����䷽���Ǵ�External to Internal.
+ 'x': ��������;
*/
int MESA_dir_link_to_human(int link_route_dir);
/****************************************************************************************
- CHN : ��Ϊ��ʷ��������,���ຯ��������Ϊ������,��ʹ���½ӿ�:MESA_set_stream_opt().
+ CHN : ��Ϊ��ʷ��������,���ຯ��������Ϊ������,��ʹ���½ӿ�:MESA_set_stream_opt().
ENG : for compat old version, keep these functions, but we suggest you use new API MESA_set_stream_opt().
*****************************************************************************************/
int tcp_set_single_stream_max_unorder(const struct streaminfo *stream, UCHAR dir, unsigned short unorder_num);
diff --git a/include/public/stream_inc/stream_project.h b/include/public/stream_inc/stream_project.h index bd41719..c6b679b 100644 --- a/include/public/stream_inc/stream_project.h +++ b/include/public/stream_inc/stream_project.h @@ -58,7 +58,6 @@ 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;
@@ -70,7 +69,6 @@ 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 e47f0eb..d1e3a4c 100644 --- a/src/dealpkt/deal_tcp.c +++ b/src/dealpkt/deal_tcp.c @@ -1,38 +1,38 @@ /* -20120603 : 1)�Ľ������ӵIJ��� ��datalen>0�İ�ֱ�ӽ������� - 2)Ӧ�ò㲻��Ҫ�����ӣ�ת��nouse״̬��������ֱ���ͷ� +20120603 : 1)�Ľ������ӵIJ��� ��datalen>0�İ�ֱ�ӽ������� + 2)Ӧ�ò㲻��Ҫ�����ӣ�ת��nouse״̬��������ֱ���ͷ� -20140322 : 1)ԭ�����ֻ�е�����data״̬�ŷ���pdetail�Ŀռ䣻������Ϊ - ��һ�����ͷ���pdetail�Ŀռ䣬������data��ŷ���half�Ŀռ� - 2)ԭ��������ص�һЩ������ȫ������pdetail - 3) �����Ĺ������������ĵ�ַ��hash���ö���ַ���бȽ� +20140322 : 1)ԭ�����ֻ�е�����data״̬�ŷ���pdetail�Ŀռ䣻������Ϊ + ��һ�����ͷ���pdetail�Ŀռ䣬������data��ŷ���half�Ŀռ� + 2)ԭ��������ص�һЩ������ȫ������pdetail + 3) �����Ĺ������������ĵ�ַ��hash���ö���ַ���бȽ� -20140329 1)�ָ���tcpdetail��¼���ζ����ֽ���pdetail->lostlen - 2)������tcpallpktģʽ�����ڲ������������飬����ȷ��fin��rst�ȵĵ���shunx - ˳����˲���������close״̬��ֻ�ܵ���̭�� - 3)�������м�¼ÿ��İ����ֽ�����λ�õ�����Ϊʵ�ʵ����˳�� - ��¼����¼�а����˲������صİ���Ŀ����ͳϵͳ�м�¼�˴����صİ��� - -20141210 1)ȫ�����streaminfo����ؽṹ�壬ʹ�÷���ṹ��IJ�ͬ���� -20141213 1)����tcp_add_new_stream_bydata���水tcplen=0�İ������ӣ�����nouse���� - nouse���������������һ����data��������opstate=close����� - �ڶ����Ǵ�һ�����ͽ�����nouse����ʱopsate=pending, - 2) �������ڶ������nouse���������ݰ�ʱ���ָ���data������ - -20141217 1)����c2s�������ĵڶ�������ack���Ƿ������ڣ�һֱ�������飬 - Ŀǰ�汾�в����ϸ��� - - -20150114 ���ں����ĵ���˳�����ȵ���tcpall�ӿڣ������ȵ���tcp�ӿڽ����˷������� - ԭ���ȵ���tcpall�������tcp�����ֶ�syn�ش����ж��Ƿ���Ч���Ƿ����� - ���Ϊ�ȵ���tcp���ٵ���tcpall������ ����ijˮ䰹��̣�tcp�ӿڣ�����tcpall�ı�ǩ - ���ڵ���Ϊ���½���������data�����ӣ������ȵ���all���ڵ���tcp�� -20150126 ������ - ����tcp_free_stream,tcp_reset_stream�IJ�������Ϊ�ȵ���tcp���ٵ���tcpall +20140329 1)�ָ���tcpdetail��¼���ζ����ֽ���pdetail->lostlen + 2)������tcpallpktģʽ�����ڲ������������飬����ȷ��fin��rst�ȵĵ���shunx + ˳����˲���������close״̬��ֻ�ܵ���̭�� + 3)�������м�¼ÿ��İ����ֽ�����λ�õ�����Ϊʵ�ʵ����˳�� + ��¼����¼�а����˲������صİ���Ŀ����ͳϵͳ�м�¼�˴����صİ��� + +20141210 1)ȫ�����streaminfo����ؽṹ�壬ʹ�÷���ṹ��IJ�ͬ���� +20141213 1)����tcp_add_new_stream_bydata���水tcplen=0�İ������ӣ�����nouse���� + nouse���������������һ����data��������opstate=close����� + �ڶ����Ǵ�һ�����ͽ�����nouse����ʱopsate=pending, + 2) �������ڶ������nouse���������ݰ�ʱ���ָ���data������ + +20141217 1)����c2s�������ĵڶ�������ack���Ƿ������ڣ�һֱ�������飬 + Ŀǰ�汾�в����ϸ��� + + +20150114 ���ں����ĵ���˳�����ȵ���tcpall�ӿڣ������ȵ���tcp�ӿڽ����˷������� + ԭ���ȵ���tcpall�������tcp�����ֶ�syn�ش����ж��Ƿ���Ч���Ƿ����� + ���Ϊ�ȵ���tcp���ٵ���tcpall������ ����ijˮ䰹��̣�tcp�ӿڣ�����tcpall�ı�ǩ + ���ڵ���Ϊ���½���������data�����ӣ������ȵ���all���ڵ���tcp�� +20150126 ������ + ����tcp_free_stream,tcp_reset_stream�IJ�������Ϊ�ȵ���tcp���ٵ���tcpall 20150210 lqy - ����syn+ack����syn�����ݵ���������±�������seqʱҪ�ж��Ƿ��syn - nouse�����ĵ�������� - ���Ӹ��� ,syn״̬��Ҫ����tcp��״̬ + ����syn+ack����syn�����ݵ���������±�������seqʱҪ�ж��Ƿ��syn + nouse�����ĵ�������� + ���Ӹ��� ,syn״̬��Ҫ����tcp��״̬ */ #include "sapp_api.h" #include "sapp_private_api.h" @@ -56,10 +56,10 @@ int copy_ipport_union_addr(struct streaminfo *pstream_heap, struct streaminfo *p void iterate_stream_list(const struct streaminfo *stream); int del_stream_by_time(struct stream_list *plist, const struct streamindex *current_drive_index); -//int g_kill_tcp_remedy_sw = 0; /* 2016-06-21 lijia add, �Ƿ����FD���� */ +//int g_kill_tcp_remedy_sw = 0; /* 2016-06-21 lijia add, �Ƿ����FD���� */ int G_TCP_FLOW_STAT_PROJECT_ID = -1; /* 2016-07-14 lijia copy from sapp */ -int G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = -1; /* ������, ����ACK����ƶϳ��ĶԶ����۽��յ����ݳ��� */ +int G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = -1; /* ������, ����ACK����ƶϳ��ĶԶ����۽��յ����ݳ��� */ #if DEBUG static void packet_io_status_tcp_pkt_update(int tid, unsigned char tcp_flags, int payload_len); @@ -104,9 +104,9 @@ static int checkcreatlinkseq(struct streaminfo_private*pstream_pr,int this_seq) curseq=pdetail_pr->iclientseq; } //adjust by lqy 20120923 - //��һ�γ������ݣ���Ϊ������ + //��һ�γ������ݣ���Ϊ������ if(curseq==0) return 1; - //��γ���syn����һ�����ݰ����Ϊ + //��γ���syn����һ�����ݰ����Ϊ if(pdetail_pr->multisynflag==1) { if(pstream->curdir == DIR_C2S) @@ -137,7 +137,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re const unsigned char *opt; int opt_num = 0, opt_len; struct tcp_option *out_raw_result = raw_result; - int parsed_opt; /* ��ȷ������OPT��λ */ + int parsed_opt; /* ��ȷ������OPT��λ */ if((NULL == raw_result) || (res_num <= 0)){ return -1; @@ -156,11 +156,11 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re memset(out_raw_result, 0, sizeof(struct tcp_option)); switch(*opt){ - case TCP_OPT_EOL: /* ��ʵ������, ����¼��ѡ�������� */ + case TCP_OPT_EOL: /* ��ʵ������, ����¼��ѡ�������� */ goto done; break; - case TCP_OPT_NOP: /* ��ʵ������, ����¼��ѡ�������� */ + case TCP_OPT_NOP: /* ��ʵ������, ����¼��ѡ�������� */ opt++; opt_len--; break; @@ -217,7 +217,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re goto err; } out_raw_result->len -= 2; - out_raw_result->char_value = 1; /* SACKʵ��û��ֵ, �˴���ֵ��Ϊ�˱����ⲿ���ʹ�� */ + out_raw_result->char_value = 1; /* SACKʵ��û��ֵ, �˴���ֵ��Ϊ�˱����ⲿ���ʹ�� */ opt_len -= 2; parsed_opt = 1; break; @@ -243,7 +243,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re parsed_opt = 1; break; - /* ����ʶ���ݲ�������ѡ��, ���� */ + /* ����ʶ���ݲ�������ѡ��, ���� */ case TCP_OPT_SACK_EDGE: case TCP_OPT_MD5: case TCP_OPT_MULTI_PATH_TCP: @@ -252,7 +252,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re /* */ int this_opt_len; - if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ + if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ goto err; } this_opt_len = opt[1]; @@ -269,7 +269,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re { int this_opt_len; - if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ + if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ goto err; } this_opt_len = opt[1]; @@ -310,7 +310,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext const unsigned char *opt; int opt_num = 0, opt_len; struct tcp_option_ext *out_raw_result = raw_result; - int parsed_opt; /* ��ȷ������OPT��λ */ + int parsed_opt; /* ��ȷ������OPT��λ */ if((NULL == raw_result) || (res_num <= 0)){ return -1; @@ -329,11 +329,11 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext memset(out_raw_result, 0, sizeof(struct tcp_option_ext)); switch(*opt){ - case TCP_OPT_EOL: /* ��ʵ������, ����¼��ѡ�������� */ + case TCP_OPT_EOL: /* ��ʵ������, ����¼��ѡ�������� */ goto done; break; - case TCP_OPT_NOP: /* ��ʵ������, ����¼��ѡ�������� */ + case TCP_OPT_NOP: /* ��ʵ������, ����¼��ѡ�������� */ opt++; opt_len--; break; @@ -390,7 +390,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext goto err; } out_raw_result->len -= 2; - out_raw_result->char_value = 1; /* SACKʵ��û��ֵ, �˴���ֵ��Ϊ�˱����ⲿ���ʹ�� */ + out_raw_result->char_value = 1; /* SACKʵ��û��ֵ, �˴���ֵ��Ϊ�˱����ⲿ���ʹ�� */ opt_len -= 2; parsed_opt = 1; break; @@ -434,7 +434,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext } break; - /* ����ʶ���ݲ�������ѡ��, ���� */ + /* ����ʶ���ݲ�������ѡ��, ���� */ case TCP_OPT_SACK_EDGE: case TCP_OPT_MD5: case TCP_OPT_RIVER_PROBE: @@ -442,7 +442,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext /* */ int this_opt_len; - if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ + if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ goto err; } this_opt_len = opt[1]; @@ -459,7 +459,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext { int this_opt_len; - if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ + if(opt_len <= 1){ /* ��ǰѡ���Ϊ0, ��ʣ��ѡ���ֻ��һ���ֽ�, ��ѡ�����ͷ�0��1, �����! */ goto err; } this_opt_len = opt[1]; @@ -546,8 +546,8 @@ static char tcp_processallpkt( struct streaminfo *pstream, const void *this_iphd } -/* LiJia comment: ������½�����, ��resetflag=0, ����pindexָ��ջ����ڴ�; - �������Ԫ������, ����pindexָ�������ڴ�; +/* LiJia comment: ������½�����, ��resetflag=0, ����pindexָ��ջ����ڴ�; + �������Ԫ������, ����pindexָ�������ڴ�; */ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, const void *this_iphdr, struct mesa_tcp_hdr *this_tcphdr,int datalen,int resetflag, const raw_pkt_t *raw_pkt) @@ -559,7 +559,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, struct streaminfo *pstream; struct tcpdetail *pdetail=NULL; struct tcpdetail_private *pdetail_pr=NULL; - int need_reverse = 0; /* copy��ַʱ, �Ƿ���Ҫ��src, dst�ߵ� */ + int need_reverse = 0; /* copy��ַʱ, �Ƿ���Ҫ��src, dst�ߵ� */ if ((this_tcphdr->th_flags & TH_SYN) && !(this_tcphdr->th_flags & TH_ACK) @@ -577,12 +577,12 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, { //runtime_log(RLOG_LV_FATAL, "[tcp_add_new_stream_bysyn]:","tcpflags=:%0x\n",this_tcphdr->th_flags); //adjust by lqy 20130530 - //ֻ�е����ν���ʱֱ�ӷ��� + //ֻ�е����ν���ʱֱ�ӷ��� if(resetflag==0) return NULL; } if(likely(0 == resetflag)){ - /* �˺���copy������pindex�ṹ, ��addr��ַ��������һ���ڴ�, ���Բ�û��copy, ʵ�ʻ�����pindexָ����ڴ���� */ + /* �˺���copy������pindex�ṹ, ��addr��ַ��������һ���ڴ�, ���Բ�û��copy, ʵ�ʻ�����pindexָ����ڴ���� */ pindex_tcp=malloc_and_copy_streamindex(threadnum, pindex); //memcpy(pindex_tcp,pindex,sizeof(struct streamindex)); @@ -590,9 +590,9 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pstream = &pstream_pr->stream_public; /* 2014-11-13 lijia modify */ - if(DIR_C2S == createdir){ /* ��ǰ��ַ��TCP�������Ϸ���C->S���䷽�� */ + if(DIR_C2S == createdir){ /* ��ǰ��ַ��TCP�������Ϸ���C->S���䷽�� */ if(1 == pstream_pr->layer_dir){ - pstream_pr->stream_dir = 1; /* �ڵ�ַ�������, ��"���ַ�ǿͻ���"�����෴ */ + pstream_pr->stream_dir = 1; /* �ڵ�ַ�������, ��"���ַ�ǿͻ���"�����෴ */ //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir; }else{ pstream_pr->stream_dir = 0; @@ -600,9 +600,9 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, } need_reverse = 0; }else{ - need_reverse = 1; /* ���뽫��ַ����ߵ�, �����ȡ��ַ�ṹʱ, src�̶�ָ�����ϵ�Դ��ַ */ + need_reverse = 1; /* ���뽫��ַ����ߵ�, �����ȡ��ַ�ṹʱ, src�̶�ָ�����ϵ�Դ��ַ */ if(1 == pstream_pr->layer_dir){ - /* ��Ϊ��copy_stream_info_to_heap()�л�����ַ�ߵ�, ���Դ˴��ͺ�"���ַ�ǿͻ���"������ͬ�� */ + /* ��Ϊ��copy_stream_info_to_heap()�л�����ַ�ߵ�, ���Դ˴��ͺ�"���ַ�ǿͻ���"������ͬ�� */ pstream_pr->stream_dir = 0; //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; }else{ @@ -613,9 +613,9 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, #if USE_RBTREE_INSTEAD_LIST /* note: - ��Ϊ����rbtreeʱ��Ҫ���������������Ƚ�, ����ȷ������left����right��֧, - ���ڱ�����˵, layer_dir����û��������, ��Ҫ���ں��������Ƚϵ�ַ��С, - ���Խ�layer_dir = stream_dir; + ��Ϊ����rbtreeʱ��Ҫ���������������Ƚ�, ����ȷ������left����right��֧, + ���ڱ�����˵, layer_dir����û��������, ��Ҫ���ں��������Ƚϵ�ַ��С, + ���Խ�layer_dir = stream_dir; */ pstream_pr->layer_dir = pstream_pr->stream_dir; #endif @@ -629,11 +629,11 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, #if SAPP_INSECTICIDE iterate_stream_list(pstream); #endif - /* 2016-07-25 lijia add, ��¼��ǰ����ײ���������, ÿ����ֻ�ڴ���ʱ��һ�μ��� */ + /* 2016-07-25 lijia add, ��¼��ǰ����ײ���������, ÿ����ֻ�ڴ���ʱ��һ�μ��� */ get_stream_carry_tunnel_type(pstream, NULL, &pstream_pr->stream_low_layer_tunnel_type); #if 0 - /* TCP��洢����ָ��, ��ʵ��ַ���ݴ洢��IP��, ����� */ + /* TCP��洢����ָ��, ��ʵ��ַ���ݴ洢��IP��, ����� */ //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream.addr); //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream); @@ -649,7 +649,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, memset(pdetail_pr,0,sizeof(struct tcpdetail_private)); pdetail->createtime=g_CurrentTime; pstream_pr->stream_create_timestamp_ms=sapp_global_val->individual_volatile->current_time_ms; - //adjust by lqy 20140515 ֻ���½�ʱ���� + //adjust by lqy 20140515 ֻ���½�ʱ���� if(createdir==DIR_S2C){ pdetail->clientpktnum++; pdetail->clientbytes+= datalen; /* 2014-12-19 lijia add, for SYN pkt append data */ @@ -661,15 +661,15 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, else { /* TODO 1: - �����������, ��ò�ʹ��ԭ����streamindex�ṹ, free��������һ���µ�, - ����ʹstreamindex��ַ��ԭ����һ��, ��Ҫ����DEBUG. + �����������, ��ò�ʹ��ԭ����streamindex�ṹ, free��������һ���µ�, + ����ʹstreamindex��ַ��ԭ����һ��, ��Ҫ����DEBUG. */ pindex_tcp=pindex; pstream_pr = &pindex_tcp->stream; pstream = &pstream_pr->stream_public; pdetail_pr = (struct tcpdetail_private *)pstream->pdetail; pdetail=(struct tcpdetail *)pdetail_pr; - //add by lqy 20150107, ���ü��� + //add by lqy 20150107, ���ü��� if(createdir==DIR_S2C) { pdetail->clientpktnum=1; @@ -685,7 +685,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pdetail->serverbytes=datalen; } pstream_pr->stream_killed_flag = 0; - /* ���Ӹ���, ��������һ���µ�streamid */ + /* ���Ӹ���, ��������һ���µ�streamid */ pindex_tcp->stream.global_stream_id = get_global_stream_id(threadnum); } @@ -702,7 +702,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pstream->dir=createdir; pstream->curdir=createdir; - //δ����ȫ���ӿ�ģʽ�£�ֱ�ӹر�, add by lqy 20141213 + //δ����ȫ���ӿ�ģʽ�£�ֱ�ӹر�, add by lqy 20141213 if(tcp_support_all==TCP_SUPPORT_ENTRYALL_OFF) { pstream->pktstate=OP_STATE_CLOSE; @@ -716,18 +716,18 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, if(createdir==DIR_S2C) { - //��ʱ������ʼ��seq + //��ʱ������ʼ��seq pdetail_pr->iclientseq =ntohl (this_tcphdr->th_seq) + 1; pdetail_pr->iserverseq=ntohl (this_tcphdr->th_ack); - //pdetail->clientpkt++; //adjust by lqy 20140515 ֻ���½�ʱ���� + //pdetail->clientpkt++; //adjust by lqy 20140515 ֻ���½�ʱ���� pdetail_pr->S2C_first_ack_seq = pdetail_pr->iserverseq; pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir ^ 1; } else if(createdir==DIR_C2S) { - pdetail_pr->iclientseq = 0; /* 2017-12-06 lijia add, ��ʱS2C�����ISN��δ��ȡ�� */ + pdetail_pr->iclientseq = 0; /* 2017-12-06 lijia add, ��ʱS2C�����ISN��δ��ȡ�� */ pdetail_pr->iserverseq=ntohl (this_tcphdr->th_seq)+1; - //pdetail->serverpkt++; //adjust by lqy 20140515 ֻ���½�ʱ���� + //pdetail->serverpkt++; //adjust by lqy 20140515 ֻ���½�ʱ���� pdetail_pr->C2S_first_ack_seq = ntohl (this_tcphdr->th_ack); pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir; } @@ -736,7 +736,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pstream->stream_state=TCP_SYN_STATE; streamaddlist(pindex_tcp,&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[TCP_SYN_STATE])); - /* LiJia add, ijЩ��Ŀ����Ӧ�ó�ʼ��, ���ǩ��ԭʼIP��Ƭ�б��� */ + /* LiJia add, ijЩ��Ŀ����Ӧ�ó�ʼ��, ���ǩ��ԭʼIP��Ƭ�б��� */ pstream_pr->pproject = project_requirement_create(pstream->threadnum); /* 2015-12-28 lijia add */ @@ -776,7 +776,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, if(DIR_S2C == createdir){ pdetail_pr->S2C_first_ack_seq = ntohl(this_tcphdr->th_ack); }else{ - ; /* SYN��ľ��ACK, ���� */ + ; /* SYN��ľ��ACK, ���� */ } } @@ -796,10 +796,10 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, } /* - 1)ԭ�����Ϊû��syn������£�ֱ�ӿ���һ�����ݰ��������� - 2) Ϊ�˼���ȫ���ӿڣ�����û�����ݵİ�Ҳ���������ӽ���NOUSE ״̬ + 1)ԭ�����Ϊû��syn������£�ֱ�ӿ���һ�����ݰ��������� + 2) Ϊ�˼���ȫ���ӿڣ�����û�����ݵİ�Ҳ���������ӽ���NOUSE ״̬ - 2015-06-10 lijia add "resetflag", ��������ʱ��̭�½�����. + 2015-06-10 lijia add "resetflag", ��������ʱ��̭�½�����. */ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, struct mesa_tcp_hdr *this_tcphdr, int datalen, int resetflag, const raw_pkt_t * raw_pkt) @@ -829,7 +829,7 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, iterate_stream_list(pstream); #endif - /* 2016-07-25 lijia add, ��¼��ǰ����ײ���������, ÿ����ֻ�ڴ���ʱ��һ�μ��� */ + /* 2016-07-25 lijia add, ��¼��ǰ����ײ���������, ÿ����ֻ�ڴ���ʱ��һ�μ��� */ get_stream_carry_tunnel_type(pstream, NULL, &pstream_pr->stream_low_layer_tunnel_type); pstream->dir=createdir; @@ -840,19 +840,19 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, #if USE_RBTREE_INSTEAD_LIST if(1 == pstream_pr->layer_dir){ - pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ + pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir; //set_stream_addr(pstream->pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, pstream); }else{ - pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ - //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; /* IP�㴴�����ķ����뵱ǰ�����䷽���෴ */ + pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ + //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; /* IP�㴴�����ķ����뵱ǰ�����䷽���෴ */ //set_stream_addr(pstream->pfather, this_tcphdr->th_dport, this_tcphdr->th_sport, pstream); } /* note: - ��Ϊ����rbtreeʱ��Ҫ���������������Ƚ�, ����ȷ������left����right��֧, - ���ڱ�����˵, layer_dir����û��������, ��Ҫ���ں��������Ƚϵ�ַ��С, - ��data��������, layer_dir = 1; + ��Ϊ����rbtreeʱ��Ҫ���������������Ƚ�, ����ȷ������left����right��֧, + ���ڱ�����˵, layer_dir����û��������, ��Ҫ���ں��������Ƚϵ�ַ��С, + ��data��������, layer_dir = 1; */ pstream_pr->layer_dir = 1; #endif @@ -884,7 +884,7 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, } pstream_pr->stream_killed_flag = 0; - /* ���Ӹ���, ��������һ���µ�streamid */ + /* ���Ӹ���, ��������һ���µ�streamid */ pindex_tcp->stream.global_stream_id = get_global_stream_id(threadnum); } @@ -892,9 +892,9 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pstream->curdir=createdir; //pindex_tcp->stream.stream_dir=pindex_tcp->stream.layer_dir; - //�����ݱ���ֱ�ӽ���data״̬, by lqy 20141213 + //�����ݱ���ֱ�ӽ���data״̬, by lqy 20141213 //if(datalen>0) - //�����ĵ��Dz���������־�ı���adjust by lqy 20150215 + //�����ĵ��Dz���������־�ı���adjust by lqy 20150215 if((datalen>0) && (!(this_tcphdr->th_flags & TH_FIN)) && (!(this_tcphdr->th_flags & TH_RST))) { pstream->stream_state=TCP_DATA_STATE; @@ -904,7 +904,7 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pstream->stream_state=TCP_NOUSE_STATE; } - /* TCP��洢����ָ��, ��ʵ��ַ���ݴ洢��IP��, ����� */ + /* TCP��洢����ָ��, ��ʵ��ַ���ݴ洢��IP��, ����� */ //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream.addr); //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream); @@ -912,12 +912,12 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream); #else /* 2014-12-16 lijia modify */ if(1 == pstream_pr->layer_dir){ - pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ + pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir; //set_stream_addr(pstream->pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, pstream); }else{ - pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ - //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; /* IP�㴴�����ķ����뵱ǰ�����䷽���෴ */ + pstream_pr->stream_dir = 1; /* ��Ϊ�ǰ�DATA������, ����stream_dir�϶���Ĭ�Ϲ�����ͬ */ + //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; /* IP�㴴�����ķ����뵱ǰ�����䷽���෴ */ //set_stream_addr(pstream->pfather, this_tcphdr->th_dport, this_tcphdr->th_sport, pstream); } #endif @@ -940,14 +940,14 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pdetail->lastmtime=g_CurrentTime; pdetail_pr->link_state=STREAM_LINK_DATA; //if(datalen>0) - //�����ĵ��Dz���������־�ı���adjust by lqy 20150325 + //�����ĵ��Dz���������־�ı���adjust by lqy 20150325 if((datalen>0) && (!(this_tcphdr->th_flags & TH_FIN)) && (!(this_tcphdr->th_flags & TH_RST))) { if(pstream->dir==DIR_C2S) { pdetail_pr->pserver=(struct half_tcpstream *)dictator_malloc(threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pserver,0,sizeof(struct half_tcpstream)); - //������ + //������ pdetail_pr->pserver->first_data_seq=(ntohl (this_tcphdr->th_seq) ); /* 2014-07-31 LiJia add, for set one stream unorder number */ pdetail_pr->pserver->maxunorder = tcp_default_unorder; @@ -956,17 +956,17 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, { pdetail_pr->pclient=(struct half_tcpstream *)dictator_malloc(threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pclient,0,sizeof(struct half_tcpstream)); - //������ + //������ pdetail_pr->pclient->first_data_seq=(ntohl (this_tcphdr->th_seq) ); /* 2014-07-31 LiJia add, for set one stream unorder number */ pdetail_pr->pclient->maxunorder = tcp_default_unorder; } } - else //�����ݵ������¼��ʱseqֵ + else //�����ݵ������¼��ʱseqֵ { if(createdir==DIR_S2C) { - //��ʱ������ʼ��seq + //��ʱ������ʼ��seq pdetail_pr->iclientseq =ntohl (this_tcphdr->th_seq) ; pdetail_pr->iserverseq=ntohl (this_tcphdr->th_ack); @@ -979,7 +979,7 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, } pstream->pdetail=(void *)pdetail_pr; - /* 2014-03-26 LiJia add, ijЩ��Ŀ����Ӧ�ó�ʼ��, ���ǩ��ԭʼIP��Ƭ�б��� */ + /* 2014-03-26 LiJia add, ijЩ��Ŀ����Ӧ�ó�ʼ��, ���ǩ��ԭʼIP��Ƭ�б��� */ pstream_pr->pproject = project_requirement_create(threadnum); /* 2016-07-14 lijia add */ @@ -995,11 +995,11 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, 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()���ۼ� */ + /* NOTE, tcp_data������stream_process_tcp()���ۼ� */ } if(G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID != -1){ @@ -1057,9 +1057,9 @@ static void tcp_change_stream_todata(struct streamindex *pindex,struct mesa_tcp_ if(NULL == pdetail_pr->pserver){ pdetail_pr->pserver=(struct half_tcpstream *)dictator_malloc(threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pserver,0,sizeof(struct half_tcpstream)); - //������ + //������ pdetail_pr->pserver->first_data_seq=pdetail_pr->iserverseq; - /* pdetail_pr->iserverseq=0; */ /* 2016-04-27 lijia modify, ���ڻ�ȡ��ǰ����ISN */ + /* pdetail_pr->iserverseq=0; */ /* 2016-04-27 lijia modify, ���ڻ�ȡ��ǰ����ISN */ /* 2014-10-20 LiJia add, for set one stream unorder number */ pdetail_pr->pserver->maxunorder = tcp_default_unorder; @@ -1070,9 +1070,9 @@ static void tcp_change_stream_todata(struct streamindex *pindex,struct mesa_tcp_ if(NULL == pdetail_pr->pclient){ pdetail_pr->pclient=(struct half_tcpstream *)dictator_malloc(threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pclient,0,sizeof(struct half_tcpstream)); - //������ + //������ pdetail_pr->pclient->first_data_seq=pdetail_pr->iclientseq; - /* pdetail_pr->iclientseq=0; */ /* 2016-04-27 lijia modify, ���ڻ�ȡ��ǰ����ISN */ + /* pdetail_pr->iclientseq=0; */ /* 2016-04-27 lijia modify, ���ڻ�ȡ��ǰ����ISN */ /* 2014-10-20 LiJia add, for set one stream unorder number */ pdetail_pr->pclient->maxunorder = tcp_default_unorder; @@ -1116,18 +1116,18 @@ static void tcp_free_half(struct half_tcpstream *phalf,int threadnum) //phalf = NULL; } -/* ������֤pindex�Ƿ���plist�� */ +/* ������֤pindex�Ƿ���plist�� */ static int inline stream_in_timeout_list(const struct streamindex *pindex, const struct stream_list *plist) { if(plist->cnt <= 1){ - /* ֻ��һ��Ԫ��ʱ, head==tail==pindex */ + /* ֻ��һ��Ԫ��ʱ, head==tail==pindex */ if(plist->head == pindex){ return 1; }else{ return 0; } }else{ - /* ���Ԫ��ʱ, next��prev�ض���һ����ΪNULL */ + /* ���Ԫ��ʱ, next��prev�ض���һ����ΪNULL */ if((NULL == pindex->next) &&(NULL == pindex->prev)){ return 0; } @@ -1147,8 +1147,8 @@ static void tcp_change_stream_tonouse(struct streamindex *pindex) plist=&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state]); /* 2017-01-03 lijia add, - �����tcp_reset_stream()����ջ��, ������tcp_change_stream_tonouse, - pindex�Ѿ����Ƴ���ǰ����list, �����ټ���ִ��streamleavlist��streamaddlist��. + �����tcp_reset_stream()����ջ��, ������tcp_change_stream_tonouse, + pindex�Ѿ����Ƴ���ǰ����list, �����ټ���ִ��streamleavlist��streamaddlist��. */ if(stream_in_timeout_list(pindex, plist) == 0){ return; @@ -1173,10 +1173,10 @@ static void tcp_change_stream_tonouse(struct streamindex *pindex) pdetail_pr->pserver = NULL; } /* 2017-12-20 lijia add, - ��FIN������������NOUSE״̬, - deal_tcp_stream()ÿ�ζ���TCP_SYN_STATE��TCP_DATA_STATE״̬, - ����TCP_NOUSE_STATE״̬�µ�����̭��ȥ, - ���Դ˴���ɨ��һ��TCP_NOUSE_STATE�ij�ʱ��. + ��FIN������������NOUSE״̬, + deal_tcp_stream()ÿ�ζ���TCP_SYN_STATE��TCP_DATA_STATE״̬, + ����TCP_NOUSE_STATE״̬�µ�����̭��ȥ, + ���Դ˴���ɨ��һ��TCP_NOUSE_STATE�ij�ʱ��. */ del_stream_by_time(plist, pindex); } @@ -1201,42 +1201,42 @@ int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const v plist=&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state]); /* TODO 1, - free��ƽ̨��time, list_lruԭ��, ��ʱ����������free, - ����Dz������CLOSEME, ��ֻ�ͷ����pdetail�ڴ�, ���Խ�tcp���ṹ����, Ϊ��FD���ȹ���. + free��ƽ̨��time, list_lruԭ��, ��ʱ����������free, + ����Dz������CLOSEME, ��ֻ�ͷ����pdetail�ڴ�, ���Խ�tcp���ṹ����, Ϊ��FD���ȹ���. - ���Ϊ��������: - tcp_lite_free(); //ֻfree data, ���������ṹ + ���Ϊ��������: + tcp_lite_free(); //ֻfree data, ���������ṹ - tcp_struct_free(); //free Ӧ�ò����� + tcp_struct_free(); //free Ӧ�ò����� - tcp_thorough_free(); // del_stream_by_time(), streamaddlist()ʱ������������Ⱥ���Ҫ����, ������free - // ����tcp_light_free(); tcp_struct_free();�������� + tcp_thorough_free(); // del_stream_by_time(), streamaddlist()ʱ������������Ⱥ���Ҫ����, ������free + // ����tcp_light_free(); tcp_struct_free();�������� TODO 1: - ����ڵ���tcp_deal_unorder()��, �������������kill_tcp, Ӧ���ж�stream_killed_flag���, - ���stream_killed_flag=1, ������İ����ٴ���, ֱ��tcp_free_half()�ͷ�. + ����ڵ���tcp_deal_unorder()��, �������������kill_tcp, Ӧ���ж�stream_killed_flag���, + ���stream_killed_flag=1, ������İ����ٴ���, ֱ��tcp_free_half()�ͷ�. */ - /* 2014-07-24 lijia add, ������ǰ��������� */ - saved_curdir = pstream->curdir; /* 2015-11-16 LiJia add, ���浱ǰ������, �����������Ҫ�ָ���ǰֵ */ + /* 2014-07-24 lijia add, ������ǰ��������� */ + saved_curdir = pstream->curdir; /* 2015-11-16 LiJia add, ���浱ǰ������, �����������Ҫ�ָ���ǰֵ */ if(pclient && (pclient->unorderlist != NULL)){ - pstream->curdir = DIR_S2C; /* ��ʱ�� */ + pstream->curdir = DIR_S2C; /* ��ʱ�� */ tcp_deal_unorder(pindex, pstream, pclient, pserver, !CHECK_ORDER_DATA); } if(pserver && (pserver->unorderlist != NULL)){ - pstream->curdir = DIR_C2S; /* ��ʱ�� */ + pstream->curdir = DIR_C2S; /* ��ʱ�� */ tcp_deal_unorder(pindex, pstream, pserver, pclient, !CHECK_ORDER_DATA); } pstream->curdir = saved_curdir; - pstream_pr->raw_pkt = raw_pkt; /* �������ʱ��̭, ��ֵΪNULL; �����RST������̭, Ϊ��ʵԭʼ�� */ + pstream_pr->raw_pkt = raw_pkt; /* �������ʱ��̭, ��ֵΪNULL; �����RST������̭, Ϊ��ʵԭʼ�� */ if(pstream->stream_state==TCP_DATA_STATE) { if(pdetail_pr->apme!=NULL) { pstream->opstate=OP_STATE_CLOSE; - //tcp stream �ص� + //tcp stream �ص� pkt_ret = stream_process_tcp(pstream, this_ip_hdr, transport_hdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); pdetail_pr->apme=NULL; } @@ -1250,21 +1250,21 @@ int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const v } } - //�����κ�״̬�ص�ȫ�������������� + //�����κ�״̬�ص�ȫ�������������� if(pdetail_pr->pAllpktpme!=NULL) { pstream->pktstate=OP_STATE_CLOSE; - //tcp stream �ص� + //tcp stream �ص� #if 0 pkt_ret = stream_process_tcp_allpkt(pstream, this_ip_hdr, transport_hdr, raw_pkt,&(pdetail_pr->pAllpktpme),&(pstream->pktstate)); #else - /* 2017-12-13 lijia modify, TCPALL��Ϊ�ȵ���, ������tcp_free_stream��, ���ֻ��TCPALL���������CLOSE״̬, ���ٸ�ԭʼ��, ָ��̶�ΪNULL, ������ظ��� */ + /* 2017-12-13 lijia modify, TCPALL��Ϊ�ȵ���, ������tcp_free_stream��, ���ֻ��TCPALL���������CLOSE״̬, ���ٸ�ԭʼ��, ָ��̶�ΪNULL, ������ظ��� */ pkt_ret = stream_process_tcp_allpkt(pstream, NULL, NULL, NULL, &(pdetail_pr->pAllpktpme),&(pstream->pktstate)); #endif pdetail_pr->pAllpktpme=NULL; } - /* �����������ٴӽṹ���Ƴ�, ��Ϊ���ò��ʱ, ���ܻ����stream_set_single_stream_timeout(), �������ǰ����LRU�����е�λ�� */ + /* �����������ٴӽṹ���Ƴ�, ��Ϊ���ò��ʱ, ���ܻ����stream_set_single_stream_timeout(), �������ǰ����LRU�����е�λ�� */ streamleavlist(pindex, plist); hash_del_stream(pindex); @@ -1277,7 +1277,7 @@ int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const v project_requirement_destroy(threadnum, pstream_pr->pproject); pstream_pr->pproject = NULL; - if(pstream_pr->timeout > link_default_nopkt_time){ /* ���Ӷ��г�ʱʱ��, ���ټ��� */ + if(pstream_pr->timeout > link_default_nopkt_time){ /* ���Ӷ��г�ʱʱ��, ���ټ��� */ sapp_global_mthread[threadnum].tcp_stream_special_timeout_num--; } @@ -1318,7 +1318,7 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, int ret = 0; sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[threadnum]->sys_stat; - //add by lqy 20150107 ���˼��� + //add by lqy 20150107 ���˼��� if(pstream->curdir==DIR_S2C) { pdetail->clientpktnum--; @@ -1354,8 +1354,8 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, plist=&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state]); - /* 2014-07-24 lijia add, ������ǰ��������� */ - saved_curdir = pstream->curdir; /* 2015-11-16 LiJia add, ���浱ǰ������, �����������Ҫ�ָ���ǰֵ */ + /* 2014-07-24 lijia add, ������ǰ��������� */ + saved_curdir = pstream->curdir; /* 2015-11-16 LiJia add, ���浱ǰ������, �����������Ҫ�ָ���ǰֵ */ if(pdetail_pr->pclient && pdetail_pr->pclient->unorderlist != NULL){ pstream->curdir = DIR_S2C; tcp_deal_unorder(pindex, pstream, pdetail_pr->pclient, pdetail_pr->pserver, !CHECK_ORDER_DATA); @@ -1364,13 +1364,13 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, pstream->curdir = DIR_C2S; tcp_deal_unorder(pindex, pstream, pdetail_pr->pserver, pdetail_pr->pclient, !CHECK_ORDER_DATA); } - /* tcp_deal_unorder()�������ܻ���pstream_pr->raw_pkt, �˴��ָ�raw_pkt */ + /* tcp_deal_unorder()�������ܻ���pstream_pr->raw_pkt, �˴��ָ�raw_pkt */ pstream_pr->raw_pkt = raw_pkt; pstream->curdir = saved_curdir; /* 2015-02-04 lijia add, - �Ƚ�������ʱ������Ԫ��������̭, ��ǰ��������Ϊ������ԭʼ��, - ������˵��ò���������MESA_kill_xxx, ������pstream_pr->raw_pkt = NULL. + �Ƚ�������ʱ������Ԫ��������̭, ��ǰ��������Ϊ������ԭʼ��, + ������˵��ò���������MESA_kill_xxx, ������pstream_pr->raw_pkt = NULL. */ const raw_pkt_t *saved_raw_pkt = pstream_pr->raw_pkt; pstream_pr->raw_pkt = NULL; @@ -1399,22 +1399,22 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, if(pdetail_pr->pAllpktpme!=NULL) { pstream->pktstate=OP_STATE_CLOSE; - //tcp stream �ص� + //tcp stream �ص� stream_process_tcp_allpkt(pstream,NULL,NULL,NULL,&(pdetail_pr->pAllpktpme),&(pstream->pktstate)); pdetail_pr->pAllpktpme=NULL; } - /* �����������ٴӽṹ���Ƴ�, ��Ϊ���ò��ʱ, ���ܻ����stream_set_single_stream_timeout(), �������ǰ����LRU�����е�λ�� */ + /* �����������ٴӽṹ���Ƴ�, ��Ϊ���ò��ʱ, ���ܻ����stream_set_single_stream_timeout(), �������ǰ����LRU�����е�λ�� */ streamleavlist(pindex, plist); project_requirement_destroy(threadnum, pstream_pr->pproject); pstream_pr->pproject = NULL; - /* �ָ�֮ǰ�洢��raw_pkt */ + /* �ָ�֮ǰ�洢��raw_pkt */ pstream_pr->raw_pkt = saved_raw_pkt; - pstream_pr->syn_opt_num = 0; /* ���ѡ����� */ - pstream_pr->synack_opt_num = 0; /* ���ѡ����� */ + pstream_pr->syn_opt_num = 0; /* ���ѡ����� */ + pstream_pr->synack_opt_num = 0; /* ���ѡ����� */ if(pstream_pr->syn_opt_array){ dictator_free(threadnum, pstream_pr->syn_opt_array); pstream_pr->syn_opt_array = NULL; @@ -1435,14 +1435,14 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, tcp_add_new_stream_bydata(pindex,this_tcphdr,datalen,REUSE_OLD_LINK, raw_pkt); ret = 1; }else{ - /* 20190506 lijia add, reset֮�������������, ֱ��free�� */ + /* 20190506 lijia add, reset֮�������������, ֱ��free�� */ hash_del_stream(pindex); if(pstream->pdetail != NULL) { dictator_free(threadnum,pstream->pdetail); pstream->pdetail=NULL; } - if(pstream_pr->timeout > link_default_nopkt_time){ /* ���Ӷ��г�ʱʱ��, ���ټ��� */ + if(pstream_pr->timeout > link_default_nopkt_time){ /* ���Ӷ��г�ʱʱ��, ���ټ��� */ sapp_global_mthread[threadnum].tcp_stream_special_timeout_num--; } free_heap_stream_info(pstream, 0); @@ -1479,14 +1479,14 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p { if(thisack==curseq) { - pstream->dir=DIR_DOUBLE; /* ����dir */ + pstream->dir=DIR_DOUBLE; /* ����dir */ pdetail_pr->link_state=STREAM_LINK_RESET; tcp_free_stream(pindex, this_iphdr, this_tcphdr, raw_pkt); return PASS; } } else - //������������������ + //������������������ if(thisack==curseq) { pstream->dir=DIR_DOUBLE; @@ -1502,9 +1502,9 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p } } - else //ͬ������ + else //ͬ������ { - //������ + //������ if(thisseq==curseq) { if((this_tcphdr->th_flags & TH_RST)&&(datalen==0)) @@ -1513,8 +1513,8 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p tcp_free_stream(pindex, this_iphdr, this_tcphdr, raw_pkt); return PASS; } - //add by lqy 20130802 �����������������е������� - //�������ڶ���ack + //add by lqy 20130802 �����������������е������� + //�������ڶ���ack else if((this_tcphdr->th_flags == TH_ACK)&&(datalen==0)) { pdetail_pr->tcpstateflag=TCP_SYN_RECV; @@ -1539,7 +1539,7 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p { if((this_tcphdr->th_flags & TH_RST)&&(datalen==0)) { - pstream->dir=DIR_DOUBLE; /* ����dir */ + pstream->dir=DIR_DOUBLE; /* ����dir */ pdetail_pr->link_state=STREAM_LINK_RESET; tcp_free_stream(pindex, this_iphdr, this_tcphdr, raw_pkt); return PASS; @@ -1554,9 +1554,9 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p return PASS; } } - else //ͬ������ + else //ͬ������ { - //����rst + //����rst if((thisseq==curseq) &&(this_tcphdr->th_flags & TH_RST) &&(datalen==0)) @@ -1569,7 +1569,7 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p } } - //add by lqy 20130805 ˫�����������������������data�� + //add by lqy 20130805 ˫�����������������������data�� else if( pstream->dir == DIR_DOUBLE) { if((pdetail_pr->tcpstateflag==TCP_SYN_RECV)&&(curdir==DIR_C2S)) @@ -1581,11 +1581,11 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p } } } - //syn�ش� + //syn�ش� /* TODO, - ��Ԫ����ͬ������SYN��, ��Ҫ��һ���ж�SEQ�Ƿ�һ�²������ش�, ��������Ԫ������, - ��Ҫreset. + ��Ԫ����ͬ������SYN��, ��Ҫ��һ���ж�SEQ�Ƿ�һ�²������ش�, ��������Ԫ������, + ��Ҫreset. */ if((this_tcphdr->th_flags == TH_SYN)) { @@ -1613,32 +1613,32 @@ static void tcp_half_handle_ack_and_seq(struct half_tcpstream *phalf, struct mes rcv = phalf; - //���տ�ʼ��ack_seq��Ϊ0����ʱֱ�ӽ���ͷ��ack_seq��ֵ��rcv->ack_seq + //���տ�ʼ��ack_seq��Ϊ0����ʱֱ�ӽ���ͷ��ack_seq��ֵ��rcv->ack_seq if (0 == *cur_half_stream_ack) *cur_half_stream_ack = ntohl(this_tcphdr->th_ack); else { ackdiff = (int)(ntohl (this_tcphdr->th_ack) - *cur_half_stream_ack); -#if 0 /* 20160930 lijia modify, �������뾯�� */ - if (ackdiff > 0 || ackdiff < -(2 << 30)) //��ֹ�ش�����Խ������� +#if 0 /* 20160930 lijia modify, �������뾯�� */ + if (ackdiff > 0 || ackdiff < -(2 << 30)) //��ֹ�ش�����Խ������� #else - if (ackdiff > 0 || ackdiff < (int)0x80000000) //��ֹ�ش�����Խ������� + if (ackdiff > 0 || ackdiff < (int)0x80000000) //��ֹ�ش�����Խ������� #endif { *cur_half_stream_ack = ntohl (this_tcphdr->th_ack); } } - //ͬ�� + //ͬ�� if (0 == rcv->seq) rcv->seq = ntohl(this_tcphdr->th_seq); else { seqdiff = (int)(ntohl(this_tcphdr->th_seq) - rcv->seq); -#if 0 /* 20160930 lijia modify, �������뾯��, ʹ��������0x80000000 */ +#if 0 /* 20160930 lijia modify, �������뾯��, ʹ��������0x80000000 */ if (seqdiff > 0 || seqdiff < -(2 << 30)) #else - if (seqdiff > 0 || seqdiff < (int)0x80000000) //��ֹ�ش�����Խ������� + if (seqdiff > 0 || seqdiff < (int)0x80000000) //��ֹ�ش�����Խ������� #endif { rcv->seq = ntohl(this_tcphdr->th_seq); @@ -1691,7 +1691,7 @@ static int tcp_deal_ack(struct streaminfo *a_tcp,struct mesa_tcp_hdr *this_tcphd { phalf=pdetail_pr->pclient; phother=pdetail_pr->pserver; - /* 2017-08-02 lijia modify, ��¼�����һ��ACK��, ��ack_seqһ����Լ�����������Բ���������� */ + /* 2017-08-02 lijia modify, ��¼�����һ��ACK��, ��ack_seqһ����Լ�����������Բ���������� */ if(0 == pdetail_pr->S2C_first_ack_seq){ pdetail_pr->S2C_first_ack_seq = ntohl (this_tcphdr->th_ack); } @@ -1702,12 +1702,12 @@ static int tcp_deal_ack(struct streaminfo *a_tcp,struct mesa_tcp_hdr *this_tcphd { phalf=pdetail_pr->pserver; phother=pdetail_pr->pclient; - /* 2017-08-02 lijia add, C2S��������ȡ�Զ�ISN */ + /* 2017-08-02 lijia add, C2S��������ȡ�Զ�ISN */ if((0 == pdetail_pr->iclientseq) - &&(ntohl(this_tcphdr->th_seq) == pdetail_pr->iserverseq)){ /* C2S����SYN����ĵ�һ��ACK�� */ + &&(ntohl(this_tcphdr->th_seq) == pdetail_pr->iserverseq)){ /* C2S����SYN����ĵ�һ��ACK�� */ pdetail_pr->iclientseq = ntohl (this_tcphdr->th_ack); } - /* 2017-08-02 lijia modify, ��¼�����һ��ACK��, ��ack_seqһ����Լ�����������Բ���������� */ + /* 2017-08-02 lijia modify, ��¼�����һ��ACK��, ��ack_seqһ����Լ�����������Բ���������� */ if(0 == pdetail_pr->C2S_first_ack_seq){ pdetail_pr->C2S_first_ack_seq = ntohl (this_tcphdr->th_ack); } @@ -1715,23 +1715,23 @@ static int tcp_deal_ack(struct streaminfo *a_tcp,struct mesa_tcp_hdr *this_tcphd cur_half_stream_ack = &pdetail_pr->C2S_ack_seq; } - /* 2017-08-03 lijia add, ������, ������ack�ƶϳ��Բ�������Ӧ���յ������� */ + /* 2017-08-03 lijia add, ������, ������ack�ƶϳ��Բ�������Ӧ���յ������� */ if(DIR_C2S == a_tcp->dir){ pdetail = a_tcp->ptcpdetail; //pdetail->clientbytes = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; if(G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID != -1){ - pdetail_pr->deduce_flow_stat->C2S_data_byte = pdetail->serverbytes; /* ���������˸������ṹ���еı��� */ - pdetail_pr->deduce_flow_stat->C2S_data_pkt = pdetail->serverpktnum;/* ���������˸������ṹ���еı��� */ + pdetail_pr->deduce_flow_stat->C2S_data_byte = pdetail->serverbytes; /* ���������˸������ṹ���еı��� */ + pdetail_pr->deduce_flow_stat->C2S_data_pkt = pdetail->serverpktnum;/* ���������˸������ṹ���еı��� */ - pdetail_pr->deduce_flow_stat->S2C_all_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; /* �ƶϳ��Ľ��, all��data��һ����, ��û��pkt */ - pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; /* �ƶϳ��Ľ��, all��data��һ����, ��û��pkt */ + pdetail_pr->deduce_flow_stat->S2C_all_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; /* �ƶϳ��Ľ��, all��data��һ����, ��û��pkt */ + pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; /* �ƶϳ��Ľ��, all��data��һ����, ��û��pkt */ } }else if(DIR_S2C == a_tcp->dir){ pdetail = a_tcp->ptcpdetail; //pdetail->serverbytes = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; if(G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID != -1){ - pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail->clientbytes; /* ���������˸������ṹ���еı��� */ - pdetail_pr->deduce_flow_stat->S2C_data_pkt = pdetail->clientpktnum;/* ���������˸������ṹ���еı��� */ + pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail->clientbytes; /* ���������˸������ṹ���еı��� */ + pdetail_pr->deduce_flow_stat->S2C_data_pkt = pdetail->clientpktnum;/* ���������˸������ṹ���еı��� */ pdetail_pr->deduce_flow_stat->C2S_all_byte = pdetail_pr->S2C_ack_seq - pdetail_pr->S2C_first_ack_seq; pdetail_pr->deduce_flow_stat->C2S_data_byte = pdetail_pr->S2C_ack_seq - pdetail_pr->S2C_first_ack_seq; @@ -1774,19 +1774,19 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream * struct tcpdetail_private*pdetail_pr=(struct tcpdetail_private*)a_tcp->pdetail; struct tcpdetail *pdetail=(struct tcpdetail *)&pdetail_pr->tcpdetail_public; - //��һ��������Ŀ������ش������dz��ȱ�ԭ���� + //��һ��������Ŀ������ش������dz��ȱ�ԭ���� if(this_seq< EXP_SEQ) { havelen = EXP_SEQ - this_seq; if (datalen - havelen > 0) { - //20150225 ��¼�ص��ij��� + //20150225 ��¼�ص��ij��� pdetail_pr->tcpoverlen=havelen; len_new= datalen - havelen; pdata_new=data+havelen; } } - else //����ı��� + else //����ı��� { len_new=datalen; pdata_new=data; @@ -1816,12 +1816,12 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream * /* LiJia add, to do: - �����Ϊ��������, 1,2,3,4,x,6, ��5��������, ��6����������, - �����6��������������Ϣ, ��Ҫkill_tcp, - ����5��������ʱ, streaminfo��洢�Ķ��ǵ�5��������Ϣ, - Ȼ���ٴ��������е�6����������, ��ʱ����kill_tcp, ��ز����Dz��Ե�, - ʵ�ʵ�seq��ackʹ�õ��ǵ�5������! - Ӧ��ʹ��buf_unorder�е�seq��ack, �����ǵ�ǰ����ԭʼ��. + �����Ϊ��������, 1,2,3,4,x,6, ��5��������, ��6����������, + �����6��������������Ϣ, ��Ҫkill_tcp, + ����5��������ʱ, streaminfo��洢�Ķ��ǵ�5��������Ϣ, + Ȼ���ٴ��������е�6����������, ��ʱ����kill_tcp, ��ز����Dz��Ե�, + ʵ�ʵ�seq��ackʹ�õ��ǵ�5������! + Ӧ��ʹ��buf_unorder�е�seq��ack, �����ǵ�ǰ����ԭʼ��. */ #if 0 int tcp_save_unorder(struct streaminfo *a_tcp,struct half_tcpstream *rcv,char *rawdata,int rawlen,struct mesa_tcp_hdr *this_tcphdr,int tcpdatalen) @@ -1840,9 +1840,9 @@ static int tcp_save_unorder(struct streaminfo *a_tcp,struct half_tcpstream *rc pakiet = (struct buf_unorder*)dictator_malloc(threadnum,sizeof(struct buf_unorder)); memset(pakiet, 0, sizeof(struct buf_unorder)); -/* 2014-10-20 lijia modify, ��IP��Ƭ�����, raw_pkt��tcpdatalen����Ӧ -raw_pktָ�����һ����Ƭ��, ��tcpdatalen��������ɺ������IP������! -�ֱ�洢! +/* 2014-10-20 lijia modify, ��IP��Ƭ�����, raw_pkt��tcpdatalen����Ӧ +raw_pktָ�����һ����Ƭ��, ��tcpdatalen��������ɺ������IP������! +�ֱ�洢! */ if(tcpdatalen > 0){ pakiet->data = dictator_malloc(threadnum,tcpdatalen); @@ -1971,7 +1971,7 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, break; if (after (pakiet->seq + pakiet->tcpdatalen+pakiet->fin+pakiet->rst, EXP_SEQ)) { - /* 2015-01-13 lijia add, ��������������kill_tcp��inject��غ���, ��Ҫ����ԭʼ����Ϣ */ + /* 2015-01-13 lijia add, ��������������kill_tcp��inject��غ���, ��Ҫ����ԭʼ����Ϣ */ update_stream_list_raw_pkt_pointer(a_tcp_pr, &pakiet->raw_pkt); if(pakiet->rst )//add by lqy 20100805) @@ -1984,7 +1984,7 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, pakiet->ipfrag_list = NULL; #endif tmpktype=a_tcp->addr.pkttype; - //a_tcp->addr.pkttype=tmpktype|PKT_TYPE_TCPUNORDER|a_tcp->pfather->addr.pkttype; /* lijia add, ��IP��Ƭ���ʹ����ϲ� */ + //a_tcp->addr.pkttype=tmpktype|PKT_TYPE_TCPUNORDER|a_tcp->pfather->addr.pkttype; /* lijia add, ��IP��Ƭ���ʹ����ϲ� */ a_tcp->addr.pkttype=PKT_TYPE_TCPREORDER; //ret=stream_process_tcp(a_tcp,pakiet->data,&(pdetail->apme),&(a_tcp->opstate)); ret=stream_process_tcp(a_tcp,pakiet->this_ip_hdr, pakiet->this_tcp_hdr, &(pakiet->raw_pkt),&(pdetail_pr->apme),&(a_tcp->opstate)); @@ -1992,12 +1992,12 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, #if (0 == HIGH_PERF) raw_frags_list_free_stream(a_tcp->threadnum, a_tcp);/* lijia add for raw ip frag list */ #endif - /* 2016-05-12 lijia add, ��������������unorder_list����BUG, �˴�Ӧ��������nouse״̬ */ + /* 2016-05-12 lijia add, ��������������unorder_list����BUG, �˴�Ӧ��������nouse״̬ */ if(STREAM_LINK_DATA == last_link_state){ tcp_change_stream_tonouse(pindex); return DROP; } - /* ��Ϊ������update_stream_list_raw_pkt_pointer, �˴����ܷ���, �Ȼָ�ԭʼ��ָ�� */ + /* ��Ϊ������update_stream_list_raw_pkt_pointer, �˴����ܷ���, �Ȼָ�ԭʼ��ָ�� */ ret = PASS; goto done; } @@ -2015,7 +2015,7 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, orderflag = CHECK_ORDER_DATA; } - //get tcp��data��len + //get tcp��data��len #if 0 /* 2014-01-12 lijia modify */ tcp_set_new_data(a_tcp,rcv,snd,(u_char *)(pakiet->data)+(pakiet->len-pakiet->tcpdatalen), pakiet->tcpdatalen,pakiet->seq,pakiet->fin); @@ -2039,13 +2039,13 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, raw_frags_list_free_stream(a_tcp->threadnum, a_tcp); #endif tcp_clear_newdata(a_tcp,rcv); - //���ֵ���Ϣ���������� + //���ֵ���Ϣ���������� //if(ret!=PASS) - /* 2015-01-16 lijia modify, ����ģʽ��, ���������Kill_tcp(), �����᷵��DROP, Ϊ������������Կ��Կ����˰� */ + /* 2015-01-16 lijia modify, ����ģʽ��, ���������Kill_tcp(), �����᷵��DROP, Ϊ������������Կ��Կ����˰� */ //if((ret!=PASS) || (a_tcp_pr->stream_killed_flag != 0)) - if(a_tcp_pr->stream_killed_flag != 0) /* 2015-11-02 lqy modify, ������������жϷ���ֵ */ + if(a_tcp_pr->stream_killed_flag != 0) /* 2015-11-02 lqy modify, ������������жϷ���ֵ */ { - /* ��Ϊ������update_stream_list_raw_pkt_pointer, �˴����ܷ���, �Ȼָ�ԭʼ��ָ�� */ + /* ��Ϊ������update_stream_list_raw_pkt_pointer, �˴����ܷ���, �Ȼָ�ԭʼ��ָ�� */ goto done; } } @@ -2116,7 +2116,7 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const if (!after (this_seq, EXP_SEQ)) { - //�������ݰ� + //�������ݰ� if (after(this_seq + datalen + (this_tcphdr->th_flags & TH_FIN), EXP_SEQ)) { @@ -2126,16 +2126,16 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const ret=stream_process_tcp(pstream,this_iphdr,(const void *)this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); //tcp_clear_newdata(pstream,rcv); /* 2016-09-12 lijia move to outside if(datalen > 0) */ } - tcp_clear_newdata(pstream,rcv); /* 2016-09-12 lijia move to here, ����datalen�Ƿ�>0, ��Ϊ������tcp_set_new_data, ����Ҫ����clear */ + tcp_clear_newdata(pstream,rcv); /* 2016-09-12 lijia move to here, ����datalen�Ƿ�>0, ��Ϊ������tcp_set_new_data, ����Ҫ����clear */ -#if 0 /* lqy 2015-11-02 modify, ��������Ĵ������, ��Ӱ�쵱ǰ���ķ���ֵ */ +#if 0 /* lqy 2015-11-02 modify, ��������Ĵ������, ��Ӱ�쵱ǰ���ķ���ֵ */ if(ret==PASS) { ret = tcp_deal_unorder(pindex,pstream,rcv,snd,CHECK_ORDER_DATA); } #else - /* 2020-04-24 lijia modify, ���ret=stream_process_tcp����ֵ��DROP, tcp_deal_unorder()����ֵ��PASS, ��ǰ������PASS, �����CT��! */ + /* 2020-04-24 lijia modify, ���ret=stream_process_tcp����ֵ��DROP, tcp_deal_unorder()����ֵ��PASS, ��ǰ������PASS, �����CT��! */ ret_unorder = tcp_deal_unorder(pindex,pstream,rcv,snd,CHECK_ORDER_DATA); #endif if((DROP == ret_unorder) || (DROP == ret)){ @@ -2143,11 +2143,11 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const } return ret; } - //����ԭ����������ݰ��Ƿ��Ѿ������д��� + //����ԭ����������ݰ��Ƿ��Ѿ������д��� } else { - //�������ݰ����� + //�������ݰ����� tcp_save_unorder(pstream,rcv,this_iphdr,raw_pkt,this_tcphdr,tcpdata, datalen); if(rcv->unorder_cnt > rcv->maxunorder) { @@ -2200,7 +2200,7 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pcurhalf->pktcout++; curseq=pcurhalf->first_data_seq + pcurhalf->count_ideal ; thisseq=ntohl (this_tcphdr->th_seq); - //�ش������� + //�ش������� //if((thisseq<curseq)&&(thisseq+datalen<=curseq)&&(!(this_tcphdr->th_flags & TH_SYN))){ // modify by lqy 20150325 if(before(thisseq,curseq)&&before(thisseq+datalen,curseq+1)&&(!(th_flags & TH_SYN))){ pstream->addr.pkttype = PKT_TYPE_TCPRETRANS; @@ -2220,7 +2220,7 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd //syn+rst drop packet if(th_flags & TH_SYN) return PASS; - //�����rst���� + //�����rst���� //if((thisseq-curseq<=1)&&(datalen==0)) if(before(thisseq, curseq+2)&&(datalen==0))//modify by lqy 20150325 { @@ -2243,13 +2243,13 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd return PASS; } - //�����rst���ģ��������δ�������ᶪ���������Ѿ���������������� + //�����rst���ģ��������δ�������ᶪ���������Ѿ���������������� } assert(rcv->count >= 0); - //���Ӹ��� + //���Ӹ��� if (th_flags & TH_SYN) { - //syn�ش� add by lqy 20100808 + //syn�ش� add by lqy 20100808 #if 0 if(thisseq+1 == rcv->first_data_seq) return PASS; #else @@ -2259,11 +2259,11 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd return PASS; }else{ /* 2017-12-19 lijia add, - ��SYN�ش�, Ҫ�жϳ�ʱʱ��, �پ����Ƿ���Ԫ���������õ�ǰ���� , - ������һ���յ���, ��������3��, ������̫��������Ԫ������, - ��Ϊ�Ƕ�������. + ��SYN�ش�, Ҫ�жϳ�ʱʱ��, �پ����Ƿ���Ԫ���������õ�ǰ���� , + ������һ���յ���, ��������3��, ������̫��������Ԫ������, + ��Ϊ�Ƕ�������. - ��������ͳ��ֵ, ��Ԫ�������������ӵ�ʱ����һ���ڷ��Ӽ�. + ��������ͳ��ֵ, ��Ԫ�������������ӵ�ʱ����һ���ڷ��Ӽ�. */ if(pdetail->lastmtime + 3 > (UINT64)g_CurrentTime){ return PASS; @@ -2272,7 +2272,7 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd #endif //adjust by lqy 20150107 //if(thisseq==rcv->first_data_seq) return PASS; - //add by lqy 20110507 syn�����ݵ���Ϊ�ǹ������� + //add by lqy 20110507 syn�����ݵ���Ϊ�ǹ������� //if(datalen>0) return PASS; //return PASS; if(th_flags & TH_RST) @@ -2283,21 +2283,21 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pdetail_pr->link_state=STREAM_LINK_REUSE_BYSYN; pstream->opstate= OP_STATE_CLOSE; -#if 0 //del by lqy 20150107 tcp_reset_stream����������������� +#if 0 //del by lqy 20150107 tcp_reset_stream����������������� ret=stream_process_tcp(pstream,raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); #endif tcp_reset_stream(pindex,this_iphdr,this_tcphdr,datalen,raw_pkt); return PASS; } - if(datalen + (th_flags & TH_FIN) +(th_flags & TH_RST)> 0)//����TCP���� + if(datalen + (th_flags & TH_FIN) +(th_flags & TH_RST)> 0)//����TCP���� { tcpdata=(unsigned char*)(this_tcphdr) + 4 * this_tcphdr->th_off; ret=tcp_deal_data(pindex,this_iphdr,raw_pkt,this_tcphdr,tcpdata,datalen); -/* 2016-05-12 lijia modify, ��������������unorder_list����BUG, ��ǰ������Ѿ���CLOSE״̬, �˴�Ӧ������return, ���ü���ִ�� */ +/* 2016-05-12 lijia modify, ��������������unorder_list����BUG, ��ǰ������Ѿ���CLOSE״̬, �˴�Ӧ������return, ���ü���ִ�� */ - //���ϲ�ر����ӣ����ߴ������������rst���� + //���ϲ�ر����ӣ����ߴ������������rst���� if((pstream->opstate==OP_STATE_CLOSE)&&(pdetail_pr->link_state!=STREAM_LINK_RESET)) { tcp_change_stream_tonouse(pindex); @@ -2307,12 +2307,12 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd if(ret==DROP) return DROP; } - //add by lqy 20120922 �ϲ���Ҫack����Ϣʱ�ϴ��������ݵı��� + //add by lqy 20120922 �ϲ���Ҫack����Ϣʱ�ϴ��������ݵı��� else if(pdetail_pr->needackflag!=0) { ret=stream_process_tcp(pstream,this_iphdr,this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); - //���ϲ�ر����ӣ����ߴ������������rst���� - /* 2017-08-01 lijia modify, ��Ҫ�ж�TCPALL���״̬, ����ֻ����TCPALL���ʱ, opstate�Ѿ���CLOSE��, ��������NOUSE̬ */ + //���ϲ�ر����ӣ����ߴ������������rst���� + /* 2017-08-01 lijia modify, ��Ҫ�ж�TCPALL���״̬, ����ֻ����TCPALL���ʱ, opstate�Ѿ���CLOSE��, ��������NOUSE̬ */ if((pstream->opstate==OP_STATE_CLOSE) && (OP_STATE_CLOSE == pstream->pktstate) &&(pdetail_pr->link_state!=STREAM_LINK_RESET)) @@ -2343,13 +2343,13 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pdetail_pr->link_state=STREAM_LINK_CLOSE; finclose=1; } - //��������ݵ�rst����Ҫ�ر� + //��������ݵ�rst����Ҫ�ر� if ((th_flags & TH_RST)&&(thisseq==curseq) &&(datalen!=0)) { pdetail_pr->link_state=STREAM_LINK_RESET; finclose=1; } - /* 2015-11-12 lijia add, ������RST, FIN���������� */ + /* 2015-11-12 lijia add, ������RST, FIN���������� */ if(pdetail_pr->ignore_rst_fin != 0){ finclose = 0; } @@ -2358,7 +2358,7 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pstream->opstate = OP_STATE_CLOSE; ret=stream_process_tcp(pstream,this_iphdr,this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); - //adjust by lqy �����ȫ�����յĺ�������ʱ + //adjust by lqy �����ȫ�����յĺ�������ʱ if(pstream->pktstate!=OP_STATE_CLOSE) { tcp_change_stream_tonouse(pindex); @@ -2375,9 +2375,9 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd /* 2017-10-16 lijia add, - �ж�NOUSE״̬��, �յ�SYN, SYN/ACK�������Ԫ������, ���������ش�, �������۵��µ�ʱ�����. + �ж�NOUSE״̬��, �յ�SYN, SYN/ACK�������Ԫ������, ���������ش�, �������۵��µ�ʱ�����. TODO: - ���ӳ�ʱ�ж�, ����ͳ�Ʒ���, ��������Ԫ������ͨ������30������. + ���ӳ�ʱ�ж�, ����ͳ�Ʒ���, ��������Ԫ������ͨ������30������. */ static inline int tcp_tuple4_reuse(const struct streaminfo *pstream, const struct tcpdetail_private *pdetail_pr, const struct mesa_tcp_hdr *this_tcphdr) { @@ -2401,7 +2401,7 @@ static inline int tcp_tuple4_reuse(const struct streaminfo *pstream, const struc /* lijia 2017-12-06 add */ if((1 == is_reuse) && (sapp_global_val->config.stream.tcp.tuple4_reuse_time_interval > 0)){ if(pdetail_pr->tcpdetail_public.createtime + sapp_global_val->config.stream.tcp.tuple4_reuse_time_interval >= (UINT64)g_CurrentTime){ - is_reuse = 0; /* ��Ԫ����ͬ, ����Ų�ͬ�����������ʱ��̫��, һ��30������, ���ƹ��������� */ + is_reuse = 0; /* ��Ԫ����ͬ, ����Ų�ͬ�����������ʱ��̫��, һ��30������, ���ƹ��������� */ } } @@ -2414,7 +2414,7 @@ static int tcp_deal_nouse_stream(struct streamindex *pindex,const void *this_iph struct tcpdetail_private *pdetail_pr=(struct tcpdetail_private *)pstream->pdetail; //add by lqy 20141213 - //����ǿ�ack���������ӣ�Ӧ�ò�δ������,��ָ������������з��� + //����ǿ�ack���������ӣ�Ӧ�ò�δ������,��ָ������������з��� //if((pstream->opstate == OP_STATE_PENDING) && (datalen>0)) //modify by lqy 20150325 if((pstream->opstate == OP_STATE_PENDING) && (datalen>0) @@ -2427,10 +2427,10 @@ static int tcp_deal_nouse_stream(struct streamindex *pindex,const void *this_iph } - //fin��rst���п����������ģ�����ڴ˴���̭�����������п��ܻ����ȥ�������ݽ������ӣ���˲���̭ + //fin��rst���п����������ģ�����ڴ˴���̭�����������п��ܻ����ȥ�������ݽ������ӣ���˲���̭ - //���Ӹ��� add by lqy 20150210 �������Ӻ��������ʱ�ָܻ���data������ - //add by lqy 20130822 �������а������յĺ�������ʱ������������̭ + //���Ӹ��� add by lqy 20150210 �������Ӻ��������ʱ�ָܻ���data������ + //add by lqy 20130822 �������а������յĺ�������ʱ������������̭ if (this_tcphdr->th_flags & TH_SYN) { if(1 == tcp_tuple4_reuse(pstream, pdetail_pr, this_tcphdr)){ @@ -2479,12 +2479,12 @@ static char tcp_process_newstreambydata(struct streamindex *pindex_tcp,const voi } } - //�½����ӱ����ȵ���all���� + //�½����ӱ����ȵ���all���� ret=tcp_processallpkt(pstream,this_iphdr,this_tcphdr,tcplen,raw_pkt); if(DROP == ret){ /* 2016-06-08 lijia add, - for HMD, ������й���ǰ����kill, �������ٵ��ú������. + for HMD, ������й���ǰ����kill, �������ٵ��ú������. */ return DROP; } @@ -2502,7 +2502,7 @@ static char tcp_process_newstreambydata(struct streamindex *pindex_tcp,const voi } -/* LiJia comment: pstreamָ��ջ����ڴ� */ +/* LiJia comment: pstreamָ��ջ����ڴ� */ //int deal_tcp_stream(struct streamindex *pstream,struct mesa_tcp_hdr *this_tcphdr,int tcplen,const void *rawippkt,int iplen) static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, struct mesa_tcp_hdr *this_tcphdr, int tcplen,const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr) @@ -2515,7 +2515,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s struct streaminfo_private *pstream_pr = &pindex->stream; struct streaminfo *pstream = &pstream_pr->stream_public; int try_to_update_addr_info = 0; - int call_tcpall_after_reset = 0; /* 2019-10-18 lijia modify, ��ǰ����reset֮��,��֤�ȵ���tcpall,�ٵ���tcp */ + int call_tcpall_after_reset = 0; /* 2019-10-18 lijia modify, ��ǰ����reset֮��,��֤�ȵ���tcpall,�ٵ���tcp */ pindex_tcp = findstreamindex (pindex, raw_pkt); if(unlikely(!pindex_tcp)){ @@ -2559,13 +2559,13 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s else { /* 2017-12-07 lijia add, - TCPRFC�涨, �����ӻ�δ�����������, �յ��Զ˵����ݰ�, ��Ӧ��RST�����Ϊ0, - ���һ�����ĵ�һ����, ���Ǹ�seq=0��RST��, ��ʱ����������, ������. + TCPRFC�涨, �����ӻ�δ�����������, �յ��Զ˵����ݰ�, ��Ӧ��RST�����Ϊ0, + ���һ�����ĵ�һ����, ���Ǹ�seq=0��RST��, ��ʱ����������, ������. */ if((this_tcphdr->th_flags & TH_RST) && (0 == this_tcphdr->th_seq)){ return PASS; } - //add by lqy 20141213ȫ���ӿ��²���tcplen=0�İ������� + //add by lqy 20141213ȫ���ӿ��²���tcplen=0�İ������� if((tcplen==0)&&(tcp_support_all==TCP_SUPPORT_ENTRYALL_OFF)) return PASS; if(TCP_CTEAT_LINK_BYDATA & tcp_creatlink_model ) @@ -2587,7 +2587,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s pstream_pr = &pindex_tcp->stream; pstream = &pstream_pr->stream_public; pstream_pr->raw_pkt = raw_pkt; //add by lijia 20171206 - //add by lqy 20150114 �½��������ӱ����ȵ���all���� + //add by lqy 20150114 �½��������ӱ����ȵ���all���� return tcp_process_newstreambydata(pindex_tcp,this_iphdr, this_tcphdr,tcplen,raw_pkt); } } @@ -2605,16 +2605,16 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s // pindex_tcp->stream.offset_to_raw_pkt_hdr = (char *)this_tcphdr - (char *)raw_pkt->raw_pkt_data; //pstream_pr->offset_to_raw_pkt_hdr = offset_to_raw_pkt_hdr; pstream_pr->raw_pkt = raw_pkt; /* 2014-12-30 lijia add */ - /* 2015-11-04 lijia add, IP��Ƭ������, pstreamָ�������еĽṹ, pindexΪջ�ﵱǰ���ṹ */ + /* 2015-11-04 lijia add, IP��Ƭ������, pstreamָ�������еĽṹ, pindexΪջ�ﵱǰ���ṹ */ pstream->addr.pktipfragtype = pindex->stream.stream_public.addr.pktipfragtype; } pdetail_pr =(struct tcpdetail_private*)(pstream->pdetail); pdetail =(struct tcpdetail *)(&pdetail_pr->tcpdetail_public); - /* 2014-10-11 lijia add, Fd������ƽ̨ʵ�� */ + /* 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 */ + if((pdetail_pr->auto_remedy_flag != 0) && (tcplen > 0)){ /* ��ֹflood����, ֻ�д����ݵİ��ŷ�RST */ 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); @@ -2626,7 +2626,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s tcp_processallpkt(pstream,this_iphdr,this_tcphdr,tcplen,raw_pkt); } #endif - //return DROP; /* 2019-11-20 lijia modify, kill_tcp��Ĭ����Ϊ����DROP, ȡ����drop_stream_flag */ + //return DROP; /* 2019-11-20 lijia modify, kill_tcp��Ĭ����Ϊ����DROP, ȡ����drop_stream_flag */ } if(unlikely(pdetail_pr->drop_stream_flag != 0)){ @@ -2637,7 +2637,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s if(pstream->curdir==DIR_S2C) { - if(pdetail->clientpktnum == 0) /* ��ǰ����ĵ�һ����, ���Ը��µײ������ĵ����ַ��Ϣ(��MPLS, GTP) */ + if(pdetail->clientpktnum == 0) /* ��ǰ����ĵ�һ����, ���Ը��µײ������ĵ����ַ��Ϣ(��MPLS, GTP) */ { try_to_update_addr_info = 1; } @@ -2646,7 +2646,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } else { - if(pdetail->serverpktnum == 0) /* ��ǰ����ĵ�һ����, ���Ը��µײ������ĵ����ַ��Ϣ(��MPLS, GTP) */ + if(pdetail->serverpktnum == 0) /* ��ǰ����ĵ�һ����, ���Ը��µײ������ĵ����ַ��Ϣ(��MPLS, GTP) */ { try_to_update_addr_info = 1; } @@ -2660,7 +2660,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s (struct streaminfo_private *)(pindex->stream.stream_public.pfather), pstream->curdir); } - /* flow_stat��ȫ����״̬��¼, �������ش����������� */ + /* flow_stat��ȫ����״̬��¼, �������ش����������� */ if(G_TCP_FLOW_STAT_PROJECT_ID != -1){ if(DIR_C2S == pstream->curdir){ pdetail_pr->flow_stat->C2S_all_pkt++; @@ -2685,7 +2685,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s update_polling_inject_context(pstream_pr, raw_pkt); - /* note: reset�����ü���, ����clientbytes+=, clientpktnum++����֮�� */ + /* note: reset�����ü���, ����clientbytes+=, clientpktnum++����֮�� */ if(1 == lrustream(pindex_tcp)){ ret = tcp_reset_stream(pindex_tcp, this_iphdr,this_tcphdr, tcplen,raw_pkt); if(0 == ret){ @@ -2718,10 +2718,10 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s else if(pstream->stream_state==TCP_SYN_STATE) { ret=tcp_deal_syn_stream(pindex_tcp,raw_pkt,this_iphdr, this_tcphdr,tcplen); - // �������ı��ģ����������к�̴��� + // �������ı��ģ����������к�̴��� if(DROP==ret) { - //return PASS;//�����к�̴��������DZ��뷵��PASS������������ + //return PASS;//�����к�̴��������DZ��뷵��PASS������������ ret = PASS; goto fun_exit; } @@ -2731,7 +2731,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s //ret=tcp_deal_data_stream(pindex_tcp,rawippkt,iplen,this_tcphdr,tcplen); ret=tcp_deal_data_stream(pindex_tcp,this_iphdr,raw_pkt,this_tcphdr,tcplen); } - //add by lqy 20150215 �½����Ӹտ�ʼ�������� + //add by lqy 20150215 �½����Ӹտ�ʼ�������� else { pindex_tcp->stream.stream_public.addr.pkttype=PKT_TYPE_TCPUNORDER; @@ -2743,10 +2743,10 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } } - //adjust by lqy 20150107 Ϊ�˷�ֹSYN�ؽ�����ʱSYN�ڵ�һ�������� + //adjust by lqy 20150107 Ϊ�˷�ֹSYN�ؽ�����ʱSYN�ڵ�һ�������� if((0 == call_tcpall_after_reset) && pindex_tcp && (pstream->pktstate!=OP_STATE_CLOSE)) { - //ȫ���ӿ��õ�������ָ��ǰ����ԭʼ���� + //ȫ���ӿ��õ�������ָ��ǰ����ԭʼ���� if(tcplen == 0) { pdetail->pdata = NULL; @@ -2769,18 +2769,16 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } fun_exit: - if(DROP == ret){ 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); } - return ret; } /* lijia 2015-01-12 add this_iphdr, - �����IP��Ƭ����İ�, ������ʽ�Ĵ���IP��ͷ, ����ֻ��tcp_hdr��raw_hdr, ����ȡ������IP��ͷ. + �����IP��Ƭ����İ�, ������ʽ�Ĵ���IP��ͷ, ����ֻ��tcp_hdr��raw_hdr, ����ȡ������IP��ͷ. */ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struct mesa_tcp_hdr *this_tcphdr, int thread_num,unsigned char routedir, int tcpdatalen, const raw_pkt_t *raw_packet, int offset_to_raw_pkt_hdr) @@ -2791,7 +2789,7 @@ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struc //struct layer_addr *tcp_stream_addr; #endif - /* IPPORT-union�汾, IP��TCP��ʹ��ͬһ��index�ṹ, ��ֱ��ͨ��IP�㴫�ݵ�pfindex */ + /* IPPORT-union�汾, IP��TCP��ʹ��ͬһ��index�ṹ, ��ֱ��ͨ��IP�㴫�ݵ�pfindex */ //struct streamindex tmp_tcp_stream; //struct streamindex *ptmp=&tmp_tcp_stream; struct streaminfo_private *pstream_pr = (struct streaminfo_private *)(&pfindex->stream); @@ -2821,7 +2819,7 @@ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struc pstream->addr.pkttype = PKT_TYPE_NORMAL;//add by lqy 20151222, init pkttype - pstream_pr->addr_use_as_hash = 1; /* ��Ԫ����Ϣ����IP�� */ + pstream_pr->addr_use_as_hash = 1; /* ��Ԫ����Ϣ����IP�� */ // ptmp->stream.p_layer_header = this_tcphdr; //ptmp->stream.offset_to_raw_pkt_hdr = (char *)this_tcphdr - (char *)raw_packet->raw_pkt_data; pstream_pr->offset_to_ip_hdr = (char *)this_tcphdr - (char *)this_iphdr; @@ -2836,7 +2834,7 @@ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struc return deal_tcp_stream(pfindex,this_iphdr, this_tcphdr,tcpdatalen, raw_packet, offset_to_raw_pkt_hdr); } -/* lijia comment: this_iphdr��������ʵԭʼ��, Ҳ������malloc��IP�����, ��addr.pkttype���� */ +/* lijia comment: this_iphdr��������ʵԭʼ��, Ҳ������malloc��IP�����, ��addr.pkttype���� */ int dealipv4tcppkt(struct streamindex *pfindex, const struct mesa_ip4_hdr *this_iphdr,int thread_num, unsigned char routedir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr) { @@ -2855,8 +2853,8 @@ int dealipv4tcppkt(struct streamindex *pfindex, const struct mesa_ip4_hdr *this_ return PASS; } - /* lijia 2016-06-15 add, �����Ż�, ������ACK�� */ -#if HIGH_PERF /* ������ģʽ���Զ�����ACK */ + /* lijia 2016-06-15 add, �����Ż�, ������ACK�� */ +#if HIGH_PERF /* ������ģʽ���Զ�����ACK */ if((0 == datalen) && (TH_ACK == this_tcphdr->th_flags)){ return PASS; } @@ -2985,10 +2983,10 @@ int set_transport_addr(struct streaminfo *this_stream, UINT16 sport, UINT16 dpor if(__ADDR_TYPE_IP_PAIR_V4 == this_addr->addrtype){ struct stream_tuple4_v4 *ip4_addr = this_addr->tuple4_v4; - /* ���ö˿�, ��IP-PORT-union�汾��port˳����Ϊlayer_dir�IJ���, - ͬʱ����layer_dir, ���ڼ���HASHʱ, ��ַ����˳�� */ + /* ���ö˿�, ��IP-PORT-union�汾��port˳����Ϊlayer_dir�IJ���, + ͬʱ����layer_dir, ���ڼ���HASHʱ, ��ַ����˳�� */ if(ntohs(sport) > ntohs(dport)){ - this_stream_pr->layer_dir = 1; /* ���˿�˳�������Ԫ��layer_dir */ + this_stream_pr->layer_dir = 1; /* ���˿�˳�������Ԫ��layer_dir */ this_stream->curdir = DIR_C2S; }else{ if(unlikely(sport == dport)){ @@ -3006,7 +3004,7 @@ int set_transport_addr(struct streaminfo *this_stream, UINT16 sport, UINT16 dpor } ip4_addr->source = sport; ip4_addr->dest = dport; - this_addr->addrtype = ADDR_TYPE_IPV4; /* ����pappƽ̨, ��������Ԫ��ʹ��'ADDR_TYPE_IPV4��ʾ' */ + this_addr->addrtype = ADDR_TYPE_IPV4; /* ����pappƽ̨, ��������Ԫ��ʹ��'ADDR_TYPE_IPV4��ʾ' */ this_addr->addrlen = sizeof(struct stream_tuple4_v4); }else if(__ADDR_TYPE_IP_PAIR_V6 == this_addr->addrtype){ struct stream_tuple4_v6 *ip6_addr = this_addr->tuple4_v6; @@ -3030,7 +3028,7 @@ int set_transport_addr(struct streaminfo *this_stream, UINT16 sport, UINT16 dpor ip6_addr->source = sport; ip6_addr->dest = dport; - this_addr->addrtype = ADDR_TYPE_IPV6; /* ����pappƽ̨, ��������Ԫ��ʹ��'ADDR_TYPE_IPV6��ʾ' */ + this_addr->addrtype = ADDR_TYPE_IPV6; /* ����pappƽ̨, ��������Ԫ��ʹ��'ADDR_TYPE_IPV6��ʾ' */ this_addr->addrlen = sizeof(struct stream_tuple4_v6); }else{ assert(0); @@ -3066,7 +3064,7 @@ int set_stream_addr_transport(struct streaminfo_private *this_stream_pr, UINT16 } ip4_addr->source = sport; ip4_addr->dest = dport; - this_addr->addrtype = ADDR_TYPE_IPV4; /* ����pappƽ̨, TCP�����Ԫ��ʹ��'ADDR_TYPE_IPV4��ʾ' */ + this_addr->addrtype = ADDR_TYPE_IPV4; /* ����pappƽ̨, TCP�����Ԫ��ʹ��'ADDR_TYPE_IPV4��ʾ' */ this_stream->addr.addrlen = sizeof(struct stream_tuple4_v4); }else if(__ADDR_TYPE_IP_PAIR_V6 == this_stream->addr.addrtype){ struct stream_tuple4_v6 *ip6_addr = this_stream->addr.tuple4_v6; @@ -3089,7 +3087,7 @@ int set_stream_addr_transport(struct streaminfo_private *this_stream_pr, UINT16 } ip6_addr->source = sport; ip6_addr->dest = dport; - this_addr->addrtype = ADDR_TYPE_IPV6;/* ����pappƽ̨, TCP-v6�����Ԫ��ʹ��'ADDR_TYPE_IPV6��ʾ' */ + this_addr->addrtype = ADDR_TYPE_IPV6;/* ����pappƽ̨, TCP-v6�����Ԫ��ʹ��'ADDR_TYPE_IPV6��ʾ' */ this_stream->addr.addrlen = sizeof(struct stream_tuple4_v6); }else{ //printf("set_stream_addr_transport() error, addr type is not IPv4 or IPv6!\n"); @@ -3098,14 +3096,14 @@ int set_stream_addr_transport(struct streaminfo_private *this_stream_pr, UINT16 } //this_addr->paddr = pfstream->addr.paddr; - //this_addr->pktipfragtype = pfstream->addr.pktipfragtype; /* 2015-01-29 lijia add, IP��Ƭ���Ͳ�� */ + //this_addr->pktipfragtype = pfstream->addr.pktipfragtype; /* 2015-01-29 lijia add, IP��Ƭ���Ͳ�� */ return 0; } /* 2014-04-08 LiJia add, - ÿ�����ĵ�ַ��Ϣ��ʱ����ջ�ռ�, �������غ�˿��ڴ��ַ����Ч��, - ��������ʱ, ��copy��malloc�Ķѿռ���, �����Ժ�ĵ�ַ�ȶ�. + ÿ�����ĵ�ַ��Ϣ��ʱ����ջ�ռ�, �������غ�˿��ڴ��ַ����Ч��, + ��������ʱ, ��copy��malloc�Ķѿռ���, �����Ժ�ĵ�ַ�ȶ�. */ struct streaminfo_private *copy_stream_info_to_heap(const struct streaminfo_private *stack_stream_pr, int reverse) { @@ -3131,9 +3129,9 @@ struct streaminfo_private *copy_stream_info_to_heap(const struct streaminfo_priv if(reverse){ heap_stream_pr->dirreverse=1; - heap_stream_pr->stream_dir = 1 ^ heap_stream_pr->layer_dir; /* lijia comment, ��"src>=dst"Ĭ�Ϲ���һ�� */ + heap_stream_pr->stream_dir = 1 ^ heap_stream_pr->layer_dir; /* lijia comment, ��"src>=dst"Ĭ�Ϲ���һ�� */ //reverse_addr_new(heap_addr, heap_stream->addr.addrtype); - /* ��ַCOPYʱ, �����Ҫ��ת, ֱ�ӷ���COPY, ��Ҫ��memcpy, �ٽ�����ַԴ��Ŀ�ĵ�˳�� */ + /* ��ַCOPYʱ, �����Ҫ��ת, ֱ�ӷ���COPY, ��Ҫ��memcpy, �ٽ�����ַԴ��Ŀ�ĵ�˳�� */ addr_reverse_memcpy(heap_addr, stack_stream->addr.paddr, stack_stream->addr.addrtype, stack_stream->addr.addrlen); }else{ heap_stream_pr->stream_dir = heap_stream_pr->layer_dir; @@ -3147,7 +3145,7 @@ struct streaminfo_private *copy_stream_info_to_heap(const struct streaminfo_priv return (struct streaminfo_private *)heap_stream; } -/* 2014-12-30 lijia add, ��������Ϊһ������ṹ, ����Ϊ��ȡ��ַ��ʵ�ʽṹ, ����֮ */ +/* 2014-12-30 lijia add, ��������Ϊһ������ṹ, ����Ϊ��ȡ��ַ��ʵ�ʽṹ, ����֮ */ struct streaminfo *skip_proxy_phony_stream(struct streaminfo *a_tcp) { int proxy_layer_num = 0; @@ -3185,26 +3183,26 @@ static struct buf_unorder *tcp_save_unorder_pkt(struct streaminfo *a_tcp,const v //carry_ip_stream = skip_proxy_phony_stream(a_tcp->pfather); carry_ip_stream = skip_proxy_phony_stream(a_tcp); - /* �洢ԭʼ�� */ + /* �洢ԭʼ�� */ memcpy(&(uo_packet->raw_pkt), stack_raw_pkt, sizeof(raw_pkt_t)); uo_packet->raw_pkt.raw_pkt_data = dictator_malloc(a_tcp->threadnum, stack_raw_pkt->raw_pkt_len); memcpy((void *)uo_packet->raw_pkt.raw_pkt_data, stack_raw_pkt->raw_pkt_data, stack_raw_pkt->raw_pkt_len); - /* iphdr���������: - 1)��IP��Ƭ��: - ֻ��洢������ԭʼ��, �����Ķ���ָ������, ֻ��freeһ��; - 2)IP����İ�: - �洢������ԭʼ��(���һ����Ƭ), �������malloc��IP��, ����ʹ��ָ������; + /* iphdr���������: + 1)��IP��Ƭ��: + ֻ��洢������ԭʼ��, �����Ķ���ָ������, ֻ��freeһ��; + 2)IP����İ�: + �洢������ԭʼ��(���һ����Ƭ), �������malloc��IP��, ����ʹ��ָ������; */ #if 0 if(carry_ip_stream->addr.pktipfragtype & PKT_TYPE_IPREBUILD){ #else - /* ��ΪIPv4�п��ܶ��Ƕ��, ����: MAC->IPv4->UDP->IPv6->IPv4->TCP->APP, - ���ܽ��жϵ�ǰ����IPv4���Ƿ��Ƿ�Ƭ, ��ײ��IPv4��Ҳ������Դ��IP��Ƭ����İ�. - ����, ʹ��ԭʼ��ָ��͵�ǰIPͷָ��ľ���ֵƫ�����ж�, - �����İ�, ��ǰ��ͷ��ԭʼ��ͷ�ĵ�ַƫ�����϶���MTU��Χ��, - ���������MTU, ��ǰIP���϶�����malloc��, ����Ƭ����İ�. + /* ��ΪIPv4�п��ܶ��Ƕ��, ����: MAC->IPv4->UDP->IPv6->IPv4->TCP->APP, + ���ܽ��жϵ�ǰ����IPv4���Ƿ��Ƿ�Ƭ, ��ײ��IPv4��Ҳ������Դ��IP��Ƭ����İ�. + ����, ʹ��ԭʼ��ָ��͵�ǰIPͷָ��ľ���ֵƫ�����ж�, + �����İ�, ��ǰ��ͷ��ԭʼ��ͷ�ĵ�ַƫ�����϶���MTU��Χ��, + ���������MTU, ��ǰIP���϶�����malloc��, ����Ƭ����İ�. */ if(abs((char *)this_iphdr - (char *)stack_raw_pkt->raw_pkt_data) > MTU_MAX){ #endif @@ -3236,7 +3234,7 @@ static struct buf_unorder *tcp_save_unorder_pkt(struct streaminfo *a_tcp,const v uo_packet->urg = (this_tcphdr->th_flags & TH_URG); uo_packet->urg_ptr = ntohs (this_tcphdr->th_urp); - /* IP��Ƭ����ָ���ƶ���pakiet�ṹ��, ��ȫ�ֵ�G_IP_FRAG_LIST[tid]ָ���ÿ�, ���ⱻip_entry���ͷ� */ + /* IP��Ƭ����ָ���ƶ���pakiet�ṹ��, ��ȫ�ֵ�G_IP_FRAG_LIST[tid]ָ���ÿ�, ���ⱻip_entry���ͷ� */ uo_packet->ipfrag_list = raw_ip_frag_list_global_move_pkt(a_tcp); a_tcp->addr.pkttype = PKT_TYPE_TCPUNORDER;//add by lqy 20151222, mark unorder @@ -3279,24 +3277,24 @@ static int get_ip_pkt_tot_len(struct streaminfo *ipinfo, const void *this_iphdr) } /* 2015-01-13 lijia add, - ��Ϊkill_xxxϵ�к���ʹ��stream_pr�ṹ�е�raw_pktָ��, - ����������������ij����, ����kill_xxxϵ�к���, - ��ʱ�� + ��Ϊkill_xxxϵ�к���ʹ��stream_pr�ṹ�е�raw_pktָ��, + ����������������ij����, ����kill_xxxϵ�к���, + ��ʱ�� */ static inline void update_stream_list_raw_pkt_pointer(struct streaminfo_private *a_tcp_pr, const raw_pkt_t *raw_pkt) { a_tcp_pr->raw_pkt = raw_pkt; - /* TODO 3: �Ƿ���Ҫ�ݹ�Ľ�a_tcp->pfather->raw_pktҲȫ������?! */ + /* TODO 3: �Ƿ���Ҫ�ݹ�Ľ�a_tcp->pfather->raw_pktҲȫ������?! */ return; } -/* TODO 1: ����ÿ������ƽ������, �ֽ���, ƽ����ʱ����ͳ�� */ +/* TODO 1: ����ÿ������ƽ������, �ֽ���, ƽ����ʱ����ͳ�� */ #if IKNOW_ENABLE #include "iknow.h" typedef struct{ - packet_io_status_base_t io_base_status; /* TCP���ܼ��� */ + packet_io_status_base_t io_base_status; /* TCP���ܼ��� */ unsigned long long syn_pkt_num; unsigned long long synack_pkt_num; unsigned long long rst_pkt_num; @@ -3314,11 +3312,11 @@ typedef struct{ }packet_io_status_tcp_stream_t; typedef struct{ - time_t max_live_time; /* ȫ���������ʱ��, ��������������, Ҳ��������ʱ����̭�� */ + time_t max_live_time; /* ȫ���������ʱ��, ��������������, Ҳ��������ʱ����̭�� */ time_t min_live_time; time_t avg_live_time; - time_t normal_finish_max_live_time; /* ���������������ʱ��, ����FIN����RST������ */ - time_t normal_finish_avg_live_time; /* ���������������ʱ��, ����FIN����RST������ */ + time_t normal_finish_max_live_time; /* ���������������ʱ��, ����FIN����RST������ */ + time_t normal_finish_avg_live_time; /* ���������������ʱ��, ����FIN����RST������ */ }packet_io_status_tcp_stream_time_t; //extern int g_packet_io_thread_num; @@ -3343,8 +3341,8 @@ void packet_io_status_tcp_pkt_time_cb(void) int i; packet_io_status_tcp_pkt_t *p_tcp_pkt_status; - memcpy((void *)&g_last_tcp_pkt_status, (void*)&g_cur_tcp_pkt_status, sizeof(packet_io_status_tcp_pkt_t)); /* ������һ���ֵ */ - memset((void *)&g_cur_tcp_pkt_status, 0, sizeof(packet_io_status_tcp_pkt_t)); /* ���� */ + memcpy((void *)&g_last_tcp_pkt_status, (void*)&g_cur_tcp_pkt_status, sizeof(packet_io_status_tcp_pkt_t)); /* ������һ���ֵ */ + memset((void *)&g_cur_tcp_pkt_status, 0, sizeof(packet_io_status_tcp_pkt_t)); /* ���� */ for(i = 0; i < g_packet_io_thread_num; i++){ p_tcp_pkt_status = (packet_io_status_tcp_pkt_t *)(g_packet_io_status_pool[i]->packet_io_status[IO_STATUS_TCP_PKT]); @@ -3450,7 +3448,7 @@ static inline void packet_io_status_tcp_stream_update(int tid, UCHAR stream_stat static long ifuncb_show_tcp_pkt_summary(iknow_handle ihandle, iknow_conn iconn, const void *cb_fun_arg, const char *cmd_args) { - /* ȫ���ܰ���, ���ֽ��� */ + /* ȫ���ܰ���, ���ֽ��� */ iprintf(ihandle, iconn,"NOTE: unit of byte for total is 'byte', for realtime is 'bps, bit per second'!\n"); iprintf(ihandle, iconn, "%8s %10s %12s %8s %10s %8s %10s %11s\n", " ", "packet", "byte", "SYN-PKT", "SYNACK-PKT", "RST-PKT", "NO-PAYLOAD", "AVG-PKT-LEN"); @@ -3634,7 +3632,7 @@ static void tcp_flow_stat_free(int thread_seq, void *project_req_value) } -/* 2015-12-25 lijia add, for TCP/UDP����ͳ�� */ +/* 2015-12-25 lijia add, for TCP/UDP����ͳ�� */ int tcp_flow_stat_init(void) { int project_req_id; @@ -3643,7 +3641,7 @@ int tcp_flow_stat_init(void) if(project_req_id >= 0){ G_TCP_FLOW_STAT_PROJECT_ID = project_req_id; }else{ - /* �����ļ�û��'tcp_flow_stat'��, �رմ˹��� */ + /* �����ļ�û��'tcp_flow_stat'��, �رմ˹��� */ G_TCP_FLOW_STAT_PROJECT_ID = -1; } @@ -3651,7 +3649,7 @@ int tcp_flow_stat_init(void) if(project_req_id >= 0){ G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = project_req_id; }else{ - /* �����ļ�û��'tcp_flow_stat'��, �رմ˹��� */ + /* �����ļ�û��'tcp_flow_stat'��, �رմ˹��� */ G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = -1; } diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c index 4ddda7f..4bac4fb 100644 --- a/src/dealpkt/deal_udp.c +++ b/src/dealpkt/deal_udp.c @@ -610,7 +610,6 @@ static int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr // } // } #endif - if(DROP == ret){ sapp_runtime_log(RLOG_LV_DEBUG, "UDP stream: %s, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); } @@ -757,7 +756,6 @@ 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_DEBUG, "UDP stream: %s, curdir:%d, return DROP.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); } diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c index 7507242..b68d88c 100644 --- a/src/dealpkt/plug_support.c +++ b/src/dealpkt/plug_support.c @@ -11,6 +11,8 @@ extern "C" { 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 @@ -503,16 +505,10 @@ 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){ @@ -574,12 +570,9 @@ static inline unsigned long long __get_stream_opt_traffic_raw(int cltype, int io } } } - return tval; } - - /* ctype: 'c':count; @@ -1212,13 +1205,10 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o 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)){ @@ -1230,7 +1220,6 @@ 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){ @@ -1250,12 +1239,10 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o 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 7d68c3d..d7afa77 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -1,4 +1,4 @@ -#include "sapp_api.h" +#include "sapp_api.h" #include "sapp_private_api.h" #ifdef __cplusplus @@ -39,7 +39,7 @@ void phony_protocol_get_plugid(unsigned short plugid) phony_protocol_plugid= plugid; } -/* ģ�������, �������ļ�PLUGNAME=xxxʶ�� */ +/* 模拟解析层, 靠配置文件PLUGNAME=xxx识别 */ char phony_protocol_test(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet) { stSessionInfo stinfo; @@ -187,7 +187,7 @@ char test_get_pkt_tcp_opts_ext(struct streaminfo *a_tcp, void **pme, int thread return APP_STATE_GIVEME; } -/* ���Ե�����ͳ�� */ +/* 测试单向流统计 */ char test_tcp_uni_stream_stats(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet) { struct tcpdetail *raw_pdetail; @@ -202,7 +202,7 @@ char test_tcp_uni_stream_stats(struct streaminfo *a_tcp, void **pme, int thread if(OP_STATE_CLOSE == a_tcp->opstate){ if(DIR_DOUBLE == a_tcp->dir){ - /* ֻ�������� */ + /* 只看单向流 */ return APP_STATE_DROPME; } @@ -287,10 +287,10 @@ char test_set_stream_timeout(struct streaminfo *pstream, void **pme, int thread if(pstream->opstate== OP_STATE_PENDING){ /* for test, port 11111=timeout=11s, port 22222=timeout=22s, - ������nc����3��udp����, �˿ڷֱ�Ϊ11111, 22222, 33333, - ��11s֮��, 11111Ӧ�ý���, - 22s֮��, 22222Ӧ�ý���, - 33333����Ĭ��ȫ�ֳ�ʱ��̭ʱ��, �������ȫ�ֳ�ʱ��̭, Ӧ�ò������(dumpfileģʽ����). + 测试用nc产生3个udp流量, 端口分别为11111, 22222, 33333, + 等11s之后, 11111应该结束, + 22s之后, 22222应该结束, + 33333按照默认全局超时淘汰时间, 如果不设全局超时淘汰, 应该不会结束(dumpfile模式除外). */ if((pstream->addr.tuple4_v4->source == ntohs(11111)) || (pstream->addr.tuple4_v4->dest == ntohs(11111))){ @@ -367,6 +367,7 @@ char test_sapp_get_platform_opt(struct streaminfo *pstream, void **pme, int thr } + char test_get_stream_in_out_bound(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) { int ret; @@ -400,7 +401,6 @@ 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; @@ -443,8 +443,6 @@ char test_stream_with_platform_in_out_traffic(struct streaminfo *pstream, void return APP_STATE_GIVEME; } - - int test_sapp_get_device_opt(const char *device) { int ret; @@ -862,7 +860,7 @@ struct __inline_vxlan_hdr{ #if 0 unsigned char reserved[3]; #else - unsigned char nat_type; /* 复用一个保留字段, 表示NAT类型 */ + unsigned char nat_type; unsigned char reserved[2]; #endif /*--------int delim -------*/ @@ -1214,7 +1212,7 @@ static void print_tuple4(struct streaminfo *stream) } -/* ����ֵ 1:���Լ��İ� 0:�����Լ��İ� -1:�������ݴ��� */ +/* 返回值 1:是自己的包 0:不是自己的包 -1:输入数据错误 */ static int check_rst_ip_new (unsigned int dip_net_order,unsigned short dport_net_order, unsigned short ipid_host_order, unsigned short win_host_order, int iMaxRandVal, int iRandKey) { @@ -1230,7 +1228,7 @@ static int check_rst_ip_new (unsigned int dip_net_order,unsigned short dport_net return 1; } -/* ����ֵ 1:���Լ��İ� 0:�����Լ��İ� -1:�������ݴ��� */ +/* 返回值 1:是自己的包 0:不是自己的包 -1:输入数据错误 */ static int check_rst_ip_old (unsigned int sip_net_order, unsigned int dip_net_order, unsigned short ipid, unsigned short window, int iMaxRandVal, int iRandKey) { @@ -1247,7 +1245,7 @@ static int check_rst_ip_old (unsigned int sip_net_order, unsigned int dip_net_or if (window == 0) return 0; - if ((iMaxRandVal - ipid + sip_net_order%window)%iRandKey != 0) // ������������ + if ((iMaxRandVal - ipid + sip_net_order%window)%iRandKey != 0) // 必须整除才行 return 0; int val = (iMaxRandVal - ipid + sip_net_order%window)/iRandKey; window_compute = (unsigned short)(val+dip_net_order%iRandKey); @@ -1257,7 +1255,7 @@ static int check_rst_ip_old (unsigned int sip_net_order, unsigned int dip_net_or if (window_compute == 0 || window_compute == 1 ) return 1; } - if (window == window_compute) { // ����ȣ�������������Լ������� + if (window == window_compute) { // 若相等,则表明可能是自己产生的 return 1; } return 0; @@ -1488,7 +1486,7 @@ char test_kill_connection( struct streaminfo *stream,void **pme, int thread_seq, char ip1[16], ip2[16]; struct stream_tuple4_v4 *tuple_v4; - if(OP_STATE_DATA != stream->opstate){ /* ֻ��DATA״̬����KILL */ + if(OP_STATE_DATA != stream->opstate){ /* 只在DATA状态调用KILL */ return APP_STATE_GIVEME; } @@ -1629,7 +1627,7 @@ static void test_inject_tcp_pkt_with_this_hdr(struct streaminfo *stream,void **p raw_thdr = (struct mesa_tcp_hdr *)((char *)raw_ihdr + raw_ihdr->ip_hl*4); raw_tcp_payload_len = ntohs(raw_ihdr->ip_len) - raw_ihdr->ip_hl*4 - raw_thdr->th_off * 4; - /* 当前包是C2S方向的GET, 需要回复一个虚假的S2C方向的RESPONSE */ + /* 褰撳墠鍖呮槸C2S鏂瑰悜鐨凣ET, 闇€瑕佸洖澶嶄竴涓櫄鍋囩殑S2C鏂瑰悜鐨凴ESPONSE */ send_ihdr = (struct mesa_ip4_hdr *)pkt_header_payload; send_thdr = (struct mesa_tcp_hdr *)((char *)send_ihdr + sizeof(struct mesa_ip4_hdr)); @@ -1697,7 +1695,7 @@ char test_inject_tcp_pkt(struct streaminfo *stream,void **pme, int thread_seq,co return plug_ret; } -/* ʹ���µķ����ӿ� sapp_inject_pkt()����α��� */ +/* 使用新的发包接口 sapp_inject_pkt()发送伪造包 */ static int send_by_sapp_inject_pkt(struct streaminfo *a_tcp, const struct mesa_ip4_hdr *raw_ip4hdr) { #define HIJACK_RESPONSE_HDR "HTTP/1.1 200 OK\r\nServer: hijack.com\r\nContent-Length:%d\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\n\r\n" @@ -1820,7 +1818,7 @@ char test_sapp_inject_pkt(struct streaminfo *stream,void **pme, int thread_seq,c static struct streaminfo *g_polling_stream = NULL; char polling_inject_tcpall_entry(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt) { - /* polling_inject_tcp_entry��polling������, �ò���stream, ��tcpall_entry����ȫ�ֱ���g_polling_stream,�Ի�ȡij���������� */ + /* polling_inject_tcp_entry在polling上下文, 拿不到stream, 靠tcpall_entry更新全局变量g_polling_stream,以获取某个流上下文 */ if((OP_STATE_DATA == stream->pktstate) && (stream->addr.tuple4_v4->dest == htons(22))){ printf("update polling stream %p: %s \n", stream, printaddr(&stream->addr, thread_seq)); @@ -2307,7 +2305,7 @@ char test_get_rawpkt_opt_from_streaminfo(struct streaminfo *f_stream,unsigned ch int tot_len = -1, this_layer_remain_len = -1; int ret; - if((OP_STATE_DATA != f_stream->opstate) && (OP_STATE_DATA != f_stream->pktstate)){ /* ��ͬʱ���ص�tcp,tcpall */ + if((OP_STATE_DATA != f_stream->opstate) && (OP_STATE_DATA != f_stream->pktstate)){ /* 可同时挂载到tcp,tcpall */ return APP_STATE_GIVEME; } @@ -2490,20 +2488,20 @@ char TEST_TCP_LOST(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a if(a_tcp->ptcpdetail->datalen > 0){ ipv4_hdr = (const struct mesa_ip4_hdr *)a_packet; tcp_hdr = (const struct mesa_tcp_hdr *)((char *)ipv4_hdr + ipv4_hdr->ip_hl * 4); - pkt_raw_data = (char *)tcp_hdr + tcp_hdr->th_off * 4; /* ���ݰ�ԭʼ����ָ�� */ - /* �����ش������ݵ�ԭ��, ƽ̨�����������a_tcp->ptcpdetail->pdata����һ������pkt_raw_data, �������ƫ���� */ + pkt_raw_data = (char *)tcp_hdr + tcp_hdr->th_off * 4; /* 数据包原始数据指针 */ + /* 由于重传追加数据等原因, 平台给插件的数据a_tcp->ptcpdetail->pdata并不一定等于pkt_raw_data, 可能向后偏移了 */ actual_data_seq = ntohl(tcp_hdr->th_seq) + ((char *)a_tcp->ptcpdetail->pdata - pkt_raw_data); printf("stream:%s, dir:%d, pkt-seq:%u, actual-data-seq:%u\n", printaddr(&a_tcp->addr, a_tcp->threadnum),a_tcp->curdir, ntohl(tcp_hdr->th_seq), actual_data_seq); if(DIR_C2S == a_tcp->curdir){ - /* ����ʵ����� == ���ϴμ���ó�������Ӧ�õ������ + ���μ���ó��Ķ������� */ + /* 本次实际序号 == 由上次计算得出的理论应该到达序号 + 本次计算得出的丢包长度 */ if(actual_data_seq != tcp_status->seq_next_c2s + a_tcp->ptcpdetail->lostlen){ printf("\033[41mstream:%s, seq check fail!\033[0m\n", printaddr(&a_tcp->addr, a_tcp->threadnum)); //assert(0); goto err_exit; } - /* ��һ���ڴ��������: ��ǰʵ����� + ʵ�����ݳ��� */ + /* 下一个期待的序号是: 当前实际序号 + 实际数据长度 */ tcp_status->seq_next_c2s = actual_data_seq + a_tcp->ptcpdetail->datalen; }else{ if(actual_data_seq != tcp_status->seq_next_s2c + a_tcp->ptcpdetail->lostlen){ @@ -2511,7 +2509,7 @@ char TEST_TCP_LOST(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a //assert(0); goto err_exit; } - /* ��һ���ڴ��������: ��ǰʵ����� + ʵ�����ݳ��� */ + /* 下一个期待的序号是: 当前实际序号 + 实际数据长度 */ tcp_status->seq_next_s2c = actual_data_seq + a_tcp->ptcpdetail->datalen; } } @@ -2892,8 +2890,8 @@ int CHAR_INIT() int demo_plugid = 51; -// ����ʵ���Զ��� -// ֻҪ��������ֵΪ���ID�� +// 函数实现自定义 +// 只要求函数返回值为插件ID; stream_register_arp((SAPP_PKT_CB_FUN_T)arp_plug_entry); @@ -2928,6 +2926,4 @@ void test_destroy(void) #ifdef __cplusplus } -#endif - - +#endif
\ No newline at end of file |
