summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-10-11 11:31:30 +0800
committeryangwei <[email protected]>2024-10-12 10:36:47 +0800
commit7bdafae69cea437b3e174862287e0bdb145ef0e1 (patch)
treeb10b6bcd97857c1e5fb40a792945b76124b63daf
parent07feab9f472f1cf987fd05024a61b127a7b403af (diff)
🐞 fix(__sapp_inject_ctrl_pkt): fix update raw_pkt return null
-rw-r--r--include/private/sapp_pkt_stat.h145
-rw-r--r--src/extensions/sapp_metrics.cpp6
-rw-r--r--src/packet_io/packet_io_status.cpp4
-rw-r--r--src/packet_io/sapp_inject.c34
-rw-r--r--src/packet_io/sendpacket.c455
5 files changed, 345 insertions, 299 deletions
diff --git a/include/private/sapp_pkt_stat.h b/include/private/sapp_pkt_stat.h
index 417ab66..51dd92a 100644
--- a/include/private/sapp_pkt_stat.h
+++ b/include/private/sapp_pkt_stat.h
@@ -2,36 +2,36 @@
#define _SAPP_PKT_STAT_H_ 1
/*
- ʹ��enum����, ����ԭ��sysinfo.h���ú궨��̶�ֵ��ʽ,
- ��Ϊ��Щ���������⿪��, ���������Ҫ����������, ������λ�ö����������±���,
- ���±��뼴��!
+ ʹ��enum����, ����ԭ��sysinfo.h���ú궨��̶�ֵ��ʽ,
+ ��Ϊ��Щ���������⿪��, ���������Ҫ����������, ������λ�ö����������±���,
+ ���±��뼴��!
*/
typedef enum __sapp_sys_stat_type{
- SAPP_STAT_FETCH_PKT, /* sapp���Դ�pcap, marsio��ȡ���ݰ��Ĵ���, �����Ľ��, ��Ҫ����������� */
+ SAPP_STAT_FETCH_PKT, /* sapp���Դ�pcap, marsio��ȡ���ݰ��Ĵ���, �����Ľ��, ��Ҫ����������� */
/*
- LINE����overlay������, ���²���LINE�Ķ��������е���ʵͨ��˫��������, ����vxlan�ȷ�װ���ֽ���,
- ����һ��vxlan���ܳ�����1000�ֽ�, vxlan overlay�����ethernet,ipv4,udp,vxlan, �ܳ�����50�ֽ�,
- ��SAPP_STAT_RCV_LINE��1000�ֽ�, SAPP_STAT_RCV_RAW��950�ֽ�.
+ LINE����overlay������, ���²���LINE�Ķ��������е���ʵͨ��˫��������, ����vxlan�ȷ�װ���ֽ���,
+ ����һ��vxlan���ܳ�����1000�ֽ�, vxlan overlay�����ethernet,ipv4,udp,vxlan, �ܳ�����50�ֽ�,
+ ��SAPP_STAT_RCV_LINE��1000�ֽ�, SAPP_STAT_RCV_RAW��950�ֽ�.
*/
SAPP_STAT_RCV_LINE,
/************* receive packet ****************/
- SAPP_STAT_RCV_RAW, /* �յ�����ʵԭʼ������, ��һ������ethernet, ethernet����mac-in-mac, vpls��ԭ��Ҳ���ܻ��ظ����� */
+ SAPP_STAT_RCV_RAW, /* �յ�����ʵԭʼ������, ��һ������ethernet, ethernet����mac-in-mac, vpls��ԭ��Ҳ���ܻ��ظ����� */
SAPP_STAT_RCV_ETHERNET,
- SAPP_STAT_RCV_IPV4, /* ������SAPP_STAT_RCV_IPV4_FRAG */
- SAPP_STAT_RCV_IPV4_FRAG, /* ������SAPP_STAT_RCV_IPV4֮��, �������� */
- SAPP_STAT_RCV_IPV6, /* ������SAPP_STAT_RCV_IPV6_FRAG */
- SAPP_STAT_RCV_IPV6_FRAG, /* ������SAPP_STAT_RCV_IPV6֮��, �������� */
+ SAPP_STAT_RCV_IPV4, /* ������SAPP_STAT_RCV_IPV4_FRAG */
+ SAPP_STAT_RCV_IPV4_FRAG, /* ������SAPP_STAT_RCV_IPV4֮��, �������� */
+ SAPP_STAT_RCV_IPV6, /* ������SAPP_STAT_RCV_IPV6_FRAG */
+ SAPP_STAT_RCV_IPV6_FRAG, /* ������SAPP_STAT_RCV_IPV6֮��, �������� */
SAPP_STAT_RCV_TCP,
SAPP_STAT_RCV_UDP,
- SAPP_STAT_RCV_DUP_TCP, /* �ظ����� */
- SAPP_STAT_RCV_DUP_UDP, /* �ظ����� */
+ SAPP_STAT_RCV_DUP_TCP, /* �ظ����� */
+ SAPP_STAT_RCV_DUP_UDP, /* �ظ����� */
- SAPP_STAT_DUP_IDENTIFY_ERR, /* �ظ�����ʶ��key���Ӵ��� */
+ SAPP_STAT_DUP_IDENTIFY_ERR, /* �ظ�����ʶ��key���Ӵ��� */
SAPP_STAT_RCV_UNKNOWN,
@@ -40,20 +40,20 @@ typedef enum __sapp_sys_stat_type{
SAPP_STAT_RAW_INBOUND,
SAPP_STAT_RAW_OUTBOUND,
- SAPP_STAT_ETH_INBOUND, /* ����ģʽ��, �ǵ�ǰ������I/O����, ��������ڵ�ǰ�豸��������λ��, ���뾳�������� */
- SAPP_STAT_ETH_OUTBOUND, /* ����ģʽ��, �ǵ�ǰ������I/O����, ��������ڵ�ǰ�豸��������λ��, ���뾳�������� */
+ SAPP_STAT_ETH_INBOUND, /* ����ģʽ��, �ǵ�ǰ������I/O����, ��������ڵ�ǰ�豸��������λ��, ���뾳�������� */
+ SAPP_STAT_ETH_OUTBOUND, /* ����ģʽ��, �ǵ�ǰ������I/O����, ��������ڵ�ǰ�豸��������λ��, ���뾳�������� */
- SAPP_STAT_IPV4_INBOUND, /* ������SAPP_STAT_RCV_IPV4_FRAG */
- SAPP_STAT_IPV4_FRAG_INBOUND, /* ������SAPP_STAT_RCV_IPV4֮��, �������� */
- SAPP_STAT_IPV6_INBOUND, /* ������SAPP_STAT_RCV_IPV6_FRAG */
- SAPP_STAT_IPV6_FRAG_INBOUND, /* ������SAPP_STAT_RCV_IPV6֮��, �������� */
+ SAPP_STAT_IPV4_INBOUND, /* ������SAPP_STAT_RCV_IPV4_FRAG */
+ SAPP_STAT_IPV4_FRAG_INBOUND, /* ������SAPP_STAT_RCV_IPV4֮��, �������� */
+ SAPP_STAT_IPV6_INBOUND, /* ������SAPP_STAT_RCV_IPV6_FRAG */
+ SAPP_STAT_IPV6_FRAG_INBOUND, /* ������SAPP_STAT_RCV_IPV6֮��, �������� */
SAPP_STAT_TCP_INBOUND,
SAPP_STAT_UDP_INBOUND,
- SAPP_STAT_IPV4_OUTBOUND, /* ������SAPP_STAT_RCV_IPV4_FRAG */
- SAPP_STAT_IPV4_FRAG_OUTBOUND, /* ������SAPP_STAT_RCV_IPV4֮��, �������� */
- SAPP_STAT_IPV6_OUTBOUND, /* ������SAPP_STAT_RCV_IPV6_FRAG */
- SAPP_STAT_IPV6_FRAG_OUTBOUND, /* ������SAPP_STAT_RCV_IPV6֮��, �������� */
+ SAPP_STAT_IPV4_OUTBOUND, /* ������SAPP_STAT_RCV_IPV4_FRAG */
+ SAPP_STAT_IPV4_FRAG_OUTBOUND, /* ������SAPP_STAT_RCV_IPV4֮��, �������� */
+ SAPP_STAT_IPV6_OUTBOUND, /* ������SAPP_STAT_RCV_IPV6_FRAG */
+ SAPP_STAT_IPV6_FRAG_OUTBOUND, /* ������SAPP_STAT_RCV_IPV6֮��, �������� */
SAPP_STAT_TCP_OUTBOUND,
SAPP_STAT_UDP_OUTBOUND,
@@ -61,13 +61,14 @@ typedef enum __sapp_sys_stat_type{
SAPP_STAT_UNKNOWN_OUTBOUND,
- SAPP_STAT_SND_ETHERNET, /* ����������͵�����, ������������������ */
+ SAPP_STAT_SND_ETHERNET, /* ����������͵�����, ������������������ */
SAPP_STAT_SND_IPV4,
SAPP_STAT_SND_IPV6,
SAPP_STAT_SND_TCP,
SAPP_STAT_SND_TCP_RST,
SAPP_STAT_SND_TCP_SYNACK,
SAPP_STAT_SND_UDP,
+ SAPP_STAT_SND_CTRL,
SAPP_STAT_SND_ERROR,
@@ -94,17 +95,17 @@ typedef enum __sapp_sys_stat_type{
SAPP_STAT_TCP_STREAM_DATA,
SAPP_STAT_TCP_STREAM_NOUSE,
- SAPP_STAT_TCP_STREAM_C2S, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_S2C,/* ��������������ͳ��(total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_DOUBLE,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_C2S, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_S2C,/* ��������������ͳ��(total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_DOUBLE,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_C2S_PKTS, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_S2C_PKTS,/* ��������������ͳ��(total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_DOUBLE_PKTS,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_C2S_PKTS, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_S2C_PKTS,/* ��������������ͳ��(total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_DOUBLE_PKTS,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_C2S_BYTES, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_S2C_BYTES,/* ��������������ͳ��(total pkt num > m and total byte > n) */
- SAPP_STAT_TCP_STREAM_DOUBLE_BYTES,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_C2S_BYTES, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_S2C_BYTES,/* ��������������ͳ��(total pkt num > m and total byte > n) */
+ SAPP_STAT_TCP_STREAM_DOUBLE_BYTES,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
SAPP_STAT_TCP_STREAM_NEW,
SAPP_STAT_TCP_STREAM_DEL,
@@ -117,56 +118,56 @@ typedef enum __sapp_sys_stat_type{
SAPP_STAT_UDP_STREAM_DEL,
SAPP_STAT_UDP_STREAM_RESET,
- SAPP_STAT_TCP_STREAM_TOTAL_C2S, /* ȫ��TCP��ͳ�� ������*/
- SAPP_STAT_TCP_STREAM_TOTAL_S2C,/* ȫ��TCP��ͳ�� ������*/
- SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE, /* ȫ��TCP��ͳ�� ������*/
+ SAPP_STAT_TCP_STREAM_TOTAL_C2S, /* ȫ��TCP��ͳ�� ������*/
+ SAPP_STAT_TCP_STREAM_TOTAL_S2C,/* ȫ��TCP��ͳ�� ������*/
+ SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE, /* ȫ��TCP��ͳ�� ������*/
- SAPP_STAT_TCP_STREAM_TOTAL_C2S_PKTS, /* ȫ��TCP��ͳ�� ���� */
- SAPP_STAT_TCP_STREAM_TOTAL_S2C_PKTS,/* ȫ��TCP��ͳ�� ����*/
- SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_PKTS, /* ȫ��TCP��ͳ�� ����*/
+ SAPP_STAT_TCP_STREAM_TOTAL_C2S_PKTS, /* ȫ��TCP��ͳ�� ���� */
+ SAPP_STAT_TCP_STREAM_TOTAL_S2C_PKTS,/* ȫ��TCP��ͳ�� ����*/
+ SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_PKTS, /* ȫ��TCP��ͳ�� ����*/
- SAPP_STAT_TCP_STREAM_TOTAL_C2S_BYTES, /* ȫ��TCP��ͳ�� �ֽ��� */
- SAPP_STAT_TCP_STREAM_TOTAL_S2C_BYTES,/* ȫ��TCP��ͳ�� �ֽ���*/
- SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_BYTES, /* ȫ��TCP��ͳ�� �ֽ���*/
+ SAPP_STAT_TCP_STREAM_TOTAL_C2S_BYTES, /* ȫ��TCP��ͳ�� �ֽ��� */
+ SAPP_STAT_TCP_STREAM_TOTAL_S2C_BYTES,/* ȫ��TCP��ͳ�� �ֽ���*/
+ SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_BYTES, /* ȫ��TCP��ͳ�� �ֽ���*/
- SAPP_STAT_TCP_LOST_PKT_STREAM_NUM, /* ���������������� */
- SAPP_STAT_TCP_LOST_PKT, /* �����ֽ��ܼ��� */
+ SAPP_STAT_TCP_LOST_PKT_STREAM_NUM, /* ���������������� */
+ SAPP_STAT_TCP_LOST_PKT, /* �����ֽ��ܼ��� */
- SAPP_STAT_UDP_STREAM_C2S, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_S2C,/* ��������������ͳ��(total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_DOUBLE,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_C2S, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_S2C,/* ��������������ͳ��(total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_DOUBLE,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_C2S_PKTS, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_S2C_PKTS,/* ��������������ͳ��(total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_DOUBLE_PKTS,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_C2S_PKTS, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_S2C_PKTS,/* ��������������ͳ��(total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_DOUBLE_PKTS,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_C2S_BYTES, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_S2C_BYTES,/* ��������������ͳ��(total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_DOUBLE_BYTES,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_C2S_BYTES, /* ��������������ͳ�� (total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_S2C_BYTES,/* ��������������ͳ��(total pkt num > m and total byte > n) */
+ SAPP_STAT_UDP_STREAM_DOUBLE_BYTES,/* ��������������ͳ�� (total pkt num > m and total byte > n) */
- SAPP_STAT_UDP_STREAM_TOTAL_C2S, /* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_S2C,/* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE, /* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_C2S, /* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_S2C,/* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE, /* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_C2S_PKTS, /* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_S2C_PKTS,/* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_PKTS, /* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_C2S_PKTS, /* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_S2C_PKTS,/* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_PKTS, /* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_C2S_BYTES, /* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_S2C_BYTES,/* ȫ��UDP��ͳ�� */
- SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_BYTES, /* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_C2S_BYTES, /* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_S2C_BYTES,/* ȫ��UDP��ͳ�� */
+ SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_BYTES, /* ȫ��UDP��ͳ�� */
SAPP_STAT_TCP_HASH_LIST_MAX,
SAPP_STAT_UDP_HASH_LIST_MAX,
- SAPP_STAT_TCP_CLOSE_BY_FIN, /* ���������TCP_ALL���, ��ʵû���״̬, ���dz�ʱ���DZ�ǿ���߳� */
- SAPP_STAT_TCP_CLOSE_BY_RST, /* ���������TCP_ALL���, ��ʵû���״̬, ���dz�ʱ���DZ�ǿ���߳� */
- SAPP_STAT_TCP_CLOSE_BY_TIMEOUT, /* ��ʱ����̭ */
- SAPP_STAT_TCP_CLOSE_BY_KICKOUT, /* ������������̭ */
- SAPP_STAT_TCP_CLOSE_BY_REUSE, /* ����Ԫ�����ñ���̭ */
- SAPP_STAT_TCP_CLOSE_BY_DUMPFILE_END, /* ��pcap dumpfileģʽ��Ч, ��ʵ��������»�û�н���, ��pcap��������ǿ��������е������˳� */
- SAPP_STAT_TCP_SHOULD_CLOSE_BUT_TCPALL, /* ���������tcp�����Ѿ�������, ����Ϊ��TCP_ALL���, ����ʵ�ʻ�����free, ���������ջ���TIMEOUT��KICKOUT���� */
+ SAPP_STAT_TCP_CLOSE_BY_FIN, /* ���������TCP_ALL���, ��ʵû���״̬, ���dz�ʱ���DZ�ǿ���߳� */
+ SAPP_STAT_TCP_CLOSE_BY_RST, /* ���������TCP_ALL���, ��ʵû���״̬, ���dz�ʱ���DZ�ǿ���߳� */
+ SAPP_STAT_TCP_CLOSE_BY_TIMEOUT, /* ��ʱ����̭ */
+ SAPP_STAT_TCP_CLOSE_BY_KICKOUT, /* ������������̭ */
+ SAPP_STAT_TCP_CLOSE_BY_REUSE, /* ����Ԫ�����ñ���̭ */
+ SAPP_STAT_TCP_CLOSE_BY_DUMPFILE_END, /* ��pcap dumpfileģʽ��Ч, ��ʵ��������»�û�н���, ��pcap��������ǿ��������е������˳� */
+ SAPP_STAT_TCP_SHOULD_CLOSE_BUT_TCPALL, /* ���������tcp�����Ѿ�������, ����Ϊ��TCP_ALL���, ����ʵ�ʻ�����free, ���������ջ���TIMEOUT��KICKOUT���� */
SAPP_STAT_UDP_CLOSE_BY_TIMEOUT,
SAPP_STAT_UDP_CLOSE_BY_KICKOUT,
@@ -174,7 +175,7 @@ typedef enum __sapp_sys_stat_type{
/* under ddos bypass */
- SAPP_STAT_GLOBAL_BYPASS, /* �����߳�cpu����, ��������ȫ��bypass��־ */
+ SAPP_STAT_GLOBAL_BYPASS, /* �����߳�cpu����, ��������ȫ��bypass��־ */
SAPP_STAT_TCP_BYPASS_STREAM,
SAPP_STAT_TCP_BYPASS_PKTS,
SAPP_STAT_TCP_BYPASS_BYTES,
diff --git a/src/extensions/sapp_metrics.cpp b/src/extensions/sapp_metrics.cpp
index 978fb8b..9a0c3b3 100644
--- a/src/extensions/sapp_metrics.cpp
+++ b/src/extensions/sapp_metrics.cpp
@@ -352,6 +352,7 @@ static int sapp_fs2_init(sapp_global_t *global_paramters)
p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_RST] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_Rst");
p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_SYNACK] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_S/A");
p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Udp");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_CTRL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_CTRL");
p_fs2_rt->fs_id_count_array[SAPP_STAT_GLOBAL_BYPASS] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "DDOS_Bypass");
@@ -572,7 +573,9 @@ static int sapp_fs3_init(sapp_global_t *global_paramters)
NULL, 0);
fs3_rt->metrics_ids[0][SAPP_STAT_SND_UDP] = fieldstat_register(fs3_handle, FIELD_METRIC_TYPE_COUNTER, "Send_Udp",
NULL, 0);
-
+
+ fs3_rt->metrics_ids[0][SAPP_STAT_SND_CTRL] = fieldstat_register(fs3_handle, FIELD_METRIC_TYPE_COUNTER, "Send_CTRL",
+ NULL, 0);
fs3_rt->metrics_ids[0][SAPP_STAT_GLOBAL_BYPASS] = fieldstat_register(fs3_handle, FIELD_METRIC_TYPE_GAUGE, "DDOS_Bypass",
NULL, 0);
@@ -783,6 +786,7 @@ static int sapp_fs4_init(sapp_global_t *global_paramters)
fs4_rt->metrics_ids[0][SAPP_STAT_SND_TCP_RST] = fieldstat_easy_register_counter(fs4_handle, "Send_Tcp_Rst");
fs4_rt->metrics_ids[0][SAPP_STAT_SND_TCP_SYNACK] = fieldstat_easy_register_counter(fs4_handle, "Send_Tcp_S/A");
fs4_rt->metrics_ids[0][SAPP_STAT_SND_UDP] = fieldstat_easy_register_counter(fs4_handle, "Send_Udp");
+ fs4_rt->metrics_ids[0][SAPP_STAT_SND_CTRL] = fieldstat_easy_register_counter(fs4_handle, "Send_CTRL");
fs4_rt->metrics_ids[0][SAPP_STAT_GLOBAL_BYPASS] = fieldstat_easy_register_counter(fs4_handle, "DDOS_Bypass");
diff --git a/src/packet_io/packet_io_status.cpp b/src/packet_io/packet_io_status.cpp
index 6109af9..6b43ad3 100644
--- a/src/packet_io/packet_io_status.cpp
+++ b/src/packet_io/packet_io_status.cpp
@@ -108,6 +108,7 @@ static void packet_io_update_metrics_fs2(void)
sapp_fs2_update_count(SAPP_STAT_SND_TCP_RST, cur_count[SAPP_STAT_SND_TCP_RST]);
sapp_fs2_update_count(SAPP_STAT_SND_TCP_SYNACK, cur_count[SAPP_STAT_SND_TCP_SYNACK]);
sapp_fs2_update_count(SAPP_STAT_SND_UDP, cur_count[SAPP_STAT_SND_UDP]);
+ sapp_fs2_update_count(SAPP_STAT_SND_CTRL, cur_count[SAPP_STAT_SND_CTRL]);
sapp_fs2_update_count(SAPP_STAT_GLOBAL_BYPASS, packet_io_under_ddos_global_status());
@@ -207,6 +208,7 @@ static void packet_io_update_metrics_fs3(void)
sapp_fs3_metric_incrby(0, SAPP_STAT_SND_TCP_RST,cur_count[SAPP_STAT_SND_TCP_RST]-history_count[SAPP_STAT_SND_TCP_RST]);
sapp_fs3_metric_incrby(0, SAPP_STAT_SND_TCP_SYNACK,cur_count[SAPP_STAT_SND_TCP_SYNACK]-history_count[SAPP_STAT_SND_TCP_SYNACK]);
sapp_fs3_metric_incrby(0, SAPP_STAT_SND_UDP,cur_count[SAPP_STAT_SND_UDP]-history_count[SAPP_STAT_SND_UDP]);
+ sapp_fs3_metric_incrby(0, SAPP_STAT_SND_CTRL,cur_count[SAPP_STAT_SND_CTRL]-history_count[SAPP_STAT_SND_CTRL]);
sapp_fs3_metric_set(0, SAPP_STAT_GLOBAL_BYPASS,packet_io_under_ddos_global_status());
@@ -334,6 +336,7 @@ static void packet_io_update_metrics_fs4(void)
sapp_fs4_metric_incrby(0, SAPP_STAT_SND_TCP_RST,cur_count[SAPP_STAT_SND_TCP_RST]-history_count[SAPP_STAT_SND_TCP_RST]);
sapp_fs4_metric_incrby(0, SAPP_STAT_SND_TCP_SYNACK,cur_count[SAPP_STAT_SND_TCP_SYNACK]-history_count[SAPP_STAT_SND_TCP_SYNACK]);
sapp_fs4_metric_incrby(0, SAPP_STAT_SND_UDP,cur_count[SAPP_STAT_SND_UDP]-history_count[SAPP_STAT_SND_UDP]);
+ sapp_fs4_metric_incrby(0, SAPP_STAT_SND_CTRL,cur_count[SAPP_STAT_SND_CTRL]-history_count[SAPP_STAT_SND_CTRL]);
sapp_fs4_metric_set(0, SAPP_STAT_GLOBAL_BYPASS,packet_io_under_ddos_global_status());
@@ -696,6 +699,7 @@ void sysinfo_output(void)
fprintf(fp,"%-12s %12llu %12s %12llu %12s\n", "TCP_RST", cur_count[SAPP_STAT_SND_TCP_RST], byte_convert_human(cur_length[SAPP_STAT_SND_TCP_RST], 1, 1, s1),(cur_count[SAPP_STAT_SND_TCP_RST]-history_count[SAPP_STAT_SND_TCP_RST]), byte_convert_human((cur_length[SAPP_STAT_SND_TCP_RST]-history_length[SAPP_STAT_SND_TCP_RST]), 1,8,s2));
fprintf(fp,"%-12s %12llu %12s %12llu %12s\n", "TCP_S/A", cur_count[SAPP_STAT_SND_TCP_SYNACK], byte_convert_human(cur_length[SAPP_STAT_SND_TCP_SYNACK], 1, 1, s1),(cur_count[SAPP_STAT_SND_TCP_SYNACK]-history_count[SAPP_STAT_SND_TCP_SYNACK]), byte_convert_human((cur_length[SAPP_STAT_SND_TCP_SYNACK]-history_length[SAPP_STAT_SND_TCP_SYNACK]),1,8,s2));
fprintf(fp,"%-12s %12llu %12s %12llu %12s\n", "UDP", cur_count[SAPP_STAT_SND_UDP], byte_convert_human(cur_length[SAPP_STAT_SND_UDP],1,1,s1),(cur_count[SAPP_STAT_SND_UDP]-history_count[SAPP_STAT_SND_UDP]), byte_convert_human((cur_length[SAPP_STAT_SND_UDP]-history_length[SAPP_STAT_SND_UDP]),1,8,s2));
+ fprintf(fp,"%-12s %12llu %12s %12llu %12s\n", "CTRL", cur_count[SAPP_STAT_SND_CTRL], byte_convert_human(cur_length[SAPP_STAT_SND_CTRL],1,1,s1),(cur_count[SAPP_STAT_SND_CTRL]-history_count[SAPP_STAT_SND_CTRL]), byte_convert_human((cur_length[SAPP_STAT_SND_CTRL]-history_length[SAPP_STAT_SND_CTRL]),1,8,s2));
fprintf(fp,"%-12s %12llu %12s %12llu %12s\n", "SEND-ERR", cur_count[SAPP_STAT_SND_ERROR], byte_convert_human(cur_length[SAPP_STAT_SND_ERROR],1,1,s1),(cur_count[SAPP_STAT_SND_ERROR]-history_count[SAPP_STAT_SND_ERROR]), byte_convert_human((cur_length[SAPP_STAT_SND_ERROR]-history_length[SAPP_STAT_SND_ERROR]),1,8,s2));
fprintf(fp,"#################################################################\n\n");
fclose(fp);
diff --git a/src/packet_io/sapp_inject.c b/src/packet_io/sapp_inject.c
index aec05a6..877c3dc 100644
--- a/src/packet_io/sapp_inject.c
+++ b/src/packet_io/sapp_inject.c
@@ -9,14 +9,14 @@ extern "C" {
#endif
/*
- MESA_kill_tcpʵ�����ȹ���õ�ǰ���IP, TCPͷ��,
- �����Ҫ����ָ����Ϣ, Ҳ��дһ��assistantģ��, ��ô����ipttl, ipid, tcpwin��ֵ.
- Ȼ�����__sapp_inject_pkt(), sio = SIO_EXCLUDE_THIS_LAYER_HDR.
+ MESA_kill_tcpʵ�����ȹ���õ�ǰ���IP, TCPͷ��,
+ �����Ҫ����ָ����Ϣ, Ҳ��дһ��assistantģ��, ��ô����ipttl, ipid, tcpwin��ֵ.
+ Ȼ�����__sapp_inject_pkt(), sio = SIO_EXCLUDE_THIS_LAYER_HDR.
- sapp����ֱ�Ӹ���ij��ͷ���ֶ���ô��ֵ, ��assistantģ�鸺��, sapp�����հ�����������.
+ sapp����ֱ�Ӹ���ij��ͷ���ֶ���ô��ֵ, ��assistantģ�鸺��, sapp�����հ�����������.
- kill_remedyҲ�ǿ�assistant���ݵ�ǰseq, ����rst����seq, ���Ƶ��fd���ɹ�, ��Ҫ���׷�Ӷ���.
- ����assistant����.
+ kill_remedyҲ�ǿ�assistant���ݵ�ǰseq, ����rst����seq, ���Ƶ��fd���ɹ�, ��Ҫ���׷�Ӷ���.
+ ����assistant����.
*/
@@ -32,10 +32,10 @@ int sapp_inject_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const v
if(MESA_handle_runtime_log_level_enabled(ABBR_SAPP_LOG_HANDLE, RLOG_LV_DEBUG)){
int log_level;
const char *string_res;
- /* injectʹ�õ���routedir, �˴�ת����stream dir,
- ע��: ��������Ķ������ܲ����ɵ�ǰ��������, ����kni, �Ǵ����������յ����ݰ�, ��ע����·��,
- ���ܴ�raw_pkt��raw_stream->routedir�жϷ���,
- Ҫ������������ʷ��¼���ж�route_dir��stream_dir�Ĺ�ϵ!!!!
+ /* injectʹ�õ���routedir, �˴�ת����stream dir,
+ ע��: ��������Ķ������ܲ����ɵ�ǰ��������, ����kni, �Ǵ����������յ����ݰ�, ��ע����·��,
+ ���ܴ�raw_pkt��raw_stream->routedir�жϷ���,
+ Ҫ������������ʷ��¼���ж�route_dir��stream_dir�Ĺ�ϵ!!!!
*/
if(stream_pr->stream_c2s_route_dir == snd_routedir){
send_stream_dir = DIR_C2S;
@@ -52,7 +52,7 @@ int sapp_inject_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const v
}
if(SIO_EXCLUDE_THIS_LAYER_HDR & sio){
- /* ipԭʼ����ҵ�������й��� */
+ /* ipԭʼ����ҵ�������й��� */
if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
const struct mesa_ip4_hdr *ip4hdr = (struct mesa_ip4_hdr *)payload;
sapp_runtime_log(log_level, "sapp_inject_pkt()->IPV4 %s, exclude ip header, stream:%s, stream_curdir:%d, stream_cur_routedir:%d, stream_C2S_routedir:%d, send_ipv4_pkt_hdr:%s, send_routedir:%d, send_stream_dir:%d, send_payload_len:%d, ttl:%d, ipid:%u, ip_checksum:0x%x",
@@ -70,7 +70,7 @@ int sapp_inject_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const v
snd_routedir, send_stream_dir, payload_len, ip6hdr->ip6_hop);
}
}else{
- /* ���ֻ����Ӧ�ò㸺�ؼ�ָ����������, ip��ͷ��sapp���� */
+ /* ���ֻ����Ӧ�ò㸺�ؼ�ָ����������, ip��ͷ��sapp���� */
sapp_runtime_log(log_level, "sapp_inject_pkt() with SIO_DEFAULT %s, stream:%s, stream_curdir:%d, stream_cur_routedir:%d, stream_C2S_routedir:%d, send_routedir:%d, send_stream_dir:%d, send_payload_len:%d",
string_res, printaddr(&stream->addr, stream->threadnum),
stream->curdir, stream->routedir, stream_pr->stream_c2s_route_dir,
@@ -84,17 +84,7 @@ int sapp_inject_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const v
int sapp_inject_ctrl_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const void *payload, int payload_len, unsigned char snd_routedir)
{
- struct streaminfo_private *stream_pr = (struct streaminfo_private *)stream;
- if(stream_pr == NULL)
- {
- return -1;
- }
-/*
- stream_pr->is_ctrl_pkt=1;
- int ret=sapp_inject_pkt(stream, SIO_DEFAULT, payload, payload_len, snd_routedir);
- stream_pr->is_ctrl_pkt=0;
-*/
return __sapp_inject_ctrl_pkt(stream, sio, payload, payload_len, snd_routedir);
}
diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c
index cc89b09..b2f2d0e 100644
--- a/src/packet_io/sendpacket.c
+++ b/src/packet_io/sendpacket.c
@@ -10,7 +10,7 @@ extern "C" {
//#define KILL_TCP_RST_NUM (3)
-#define KILL_TCP_SYN_ACK_NUM (1) /* ���SYN/ACKֻ����һ������ */
+#define KILL_TCP_SYN_ACK_NUM (1) /* ���SYN/ACKֻ����һ������ */
typedef struct{
UINT32 gateway_ip; /* network order */
@@ -22,7 +22,7 @@ typedef struct{
MESA_send_handle g_send_handle[MAX_THREAD_NUM];
static volatile UINT64 g_rand_seed = 0x013579ABCDEF;
-/* ������ƽ̨����randֵ���㷨, ����У��RST���Ƿ�Ϊ��ϵͳ���� */
+/* ������ƽ̨����randֵ���㷨, ����У��RST���Ƿ�Ϊ��ϵͳ���� */
static int randgroup[MAX_THREAD_NUM];
//static int g_iRandKey=13;
//static int g_iMaxRandVal=65535;
@@ -30,7 +30,7 @@ static int randgroup[MAX_THREAD_NUM];
typedef struct{
unsigned char ip_ttl;
unsigned short ip_id_host_order;
- char __cache_align_pad_[60]; /* ���߳�ȫ�ֱ���, ��֤64�ֽ�cache����߽� */
+ char __cache_align_pad_[60]; /* ���߳�ȫ�ֱ���, ��֤64�ֽ�cache����߽� */
}bulid_layer_ipv4_args_t;
typedef struct{
@@ -41,7 +41,7 @@ typedef struct{
unsigned char tcp_flags;
unsigned short tcp_win_host_order;
unsigned int tcp_seq;
- char __cache_align_pad_[56]; /* ���߳�ȫ�ֱ���, ��֤64�ֽ�cache����߽� */
+ char __cache_align_pad_[56]; /* ���߳�ȫ�ֱ���, ��֤64�ֽ�cache����߽� */
}bulid_layer_tcp_args_t;
@@ -49,7 +49,7 @@ typedef struct{
unsigned char ip_ttl;
unsigned short ip_id_host_order;
unsigned short tcp_win_host_order;
- char __cache_align_pad_[58]; /* ���߳�ȫ�ֱ���, ��֤64�ֽ�cache����߽� */
+ char __cache_align_pad_[58]; /* ���߳�ȫ�ֱ���, ��֤64�ֽ�cache����߽� */
}tcp_rst_finger_mark_t;
static bulid_layer_ipv4_args_t g_build_ipv4_args[MAX_THREAD_NUM];
@@ -87,7 +87,7 @@ struct gtp_cache_addr_t g_addr_register_for_gtp_cache[MAX_THREAD_NUM];
//struct layer_addr_mpls g_mpls_register_addr[MAX_THREAD_NUM];
/*
- �����յ����ֽ��������ϸ����ij��Ȳ�����ݰ��ĵ�ַ����, �õ����������������.
+ �����յ����ֽ��������ϸ����ij��Ȳ�����ݰ��ĵ�ַ����, �õ����������������.
*/
#if 0
void random_seed(int pkt_len, UINT64 *pkt_rand)
@@ -135,7 +135,7 @@ int set_rst_max_rnd_val(int max_rnd_val)
}
/*
- Ϊ�˼����ϰ�ϵͳ, ��׷�ٱ�ϵͳ������RST��.
+ Ϊ�˼����ϰ�ϵͳ, ��׷�ٱ�ϵͳ������RST��.
IN ARG:
sip, dip: network order;
@@ -184,7 +184,7 @@ static void trick_algo_getrandval_with_seed(int thread_id,unsigned sip,unsigned
}
-/* 2014-08-26 lijia add, ��׷�ٱ�ϵͳ������RST��.*/
+/* 2014-08-26 lijia add, ��׷�ٱ�ϵͳ������RST��.*/
static tcp_rst_finger_mark_t *make_tcp_rst_finger_mark(int thread_id, const raw_pkt_t *raw_pkt)
{
tcp_rst_finger_mark_t *rst_finger;
@@ -192,10 +192,10 @@ static tcp_rst_finger_mark_t *make_tcp_rst_finger_mark(int thread_id, const raw
rst_finger = &g_tcp_rst_finger[thread_id];
- /* NOTE, ֻ��IPv4����ip_id����Щ���, IPv6�ݲ�֧��RSTָ�� */
- /* TODO 2, �˴����������, ��jump_to_layer��֪��������һ��, Ӧ����stream_private->offset_to_ip_hdrƫ�Ƶ������IPͷ�� */
+ /* NOTE, ֻ��IPv4����ip_id����Щ���, IPv6�ݲ�֧��RSTָ�� */
+ /* TODO 2, �˴����������, ��jump_to_layer��֪��������һ��, Ӧ����stream_private->offset_to_ip_hdrƫ�Ƶ������IPͷ�� */
ip4_hdr = (const struct mesa_ip4_hdr *)MESA_jump_layer(raw_pkt->raw_pkt_data, raw_pkt->low_layer_type, __ADDR_TYPE_IP_PAIR_V4);
- if((NULL == ip4_hdr) || (0 == ABBR_INJECT_RST_SIGN)){ /* ������, ��ָ����Ϣ */
+ if((NULL == ip4_hdr) || (0 == ABBR_INJECT_RST_SIGN)){ /* ������, ��ָ����Ϣ */
rst_finger->ip_id_host_order = (unsigned short)MESA_rand();
rst_finger->ip_ttl = (unsigned short)MESA_rand_range(48, 120);
rst_finger->tcp_win_host_order = (unsigned short)MESA_rand_range(1000, 1460);
@@ -219,13 +219,13 @@ static tcp_rst_finger_mark_t *make_tcp_rst_finger_mark(int thread_id, const raw
(x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
-/* 2012-04-10 LiJia add, ��ȡ����IPv4��ַ
-����:
- device: ��������
- ip_add: �洢IP��ַ��ָ�룬���Ϊ������.
-����ֵ:
- 0: ����
- -1:����
+/* 2012-04-10 LiJia add, ��ȡ����IPv4��ַ
+����:
+ device: ��������
+ ip_add: �洢IP��ַ��ָ�룬���Ϊ������.
+����ֵ:
+ 0: ����
+ -1:����
*/
int MESA_get_dev_ipv4(const char *device, int *ip_add)
{
@@ -258,14 +258,14 @@ err_exit:
}
-/* 2012-04-10 LiJia add, ��ȡ����MAC��ַ
-����:
- device: ��������
- mac: �洢MAC��ַ������,���Ϊ������,
- ������MAC��ַΪ11:22:33:44:55:66,��mac[0]Ϊ0x11,mac[5]Ϊ0x66.
-����ֵ:
- 0: ����
- -1:����
+/* 2012-04-10 LiJia add, ��ȡ����MAC��ַ
+����:
+ device: ��������
+ mac: �洢MAC��ַ������,���Ϊ������,
+ ������MAC��ַΪ11:22:33:44:55:66,��mac[0]Ϊ0x11,mac[5]Ϊ0x66.
+����ֵ:
+ 0: ����
+ -1:����
*/
int MESA_get_dev_mac(const char *device, unsigned char mac[6])
{
@@ -304,16 +304,16 @@ err_exit:
}
-/* 2012-04-11 LiJia add,��MAC�ַ�����ʽת��Ϊ16����MAC��ַ.
-����:
- str: MAC��ַ�ַ���
- delim: �ַ����ָ���������Ϊ':', '-'��,��: xx:xx:xx:xx:xx:xx
- ����ַ����޷ָ�����delim��Ϊ-1.
- mac: �洢MAC��ַ������(ָ��),���Ϊ������,
- ������MAC��ַΪ11:22:33:44:55:66,��mac[0]Ϊ0x11,mac[5]Ϊ0x66.
-����ֵ:
- 0: ����
- -1:����
+/* 2012-04-11 LiJia add,��MAC�ַ�����ʽת��Ϊ16����MAC��ַ.
+����:
+ str: MAC��ַ�ַ���
+ delim: �ַ����ָ���������Ϊ':', '-'��,��: xx:xx:xx:xx:xx:xx
+ ����ַ����޷ָ�����delim��Ϊ-1.
+ mac: �洢MAC��ַ������(ָ��),���Ϊ������,
+ ������MAC��ַΪ11:22:33:44:55:66,��mac[0]Ϊ0x11,mac[5]Ϊ0x66.
+����ֵ:
+ 0: ����
+ -1:����
*/
int MESA_mac_pton(const char *str, int delim, char *mac)
{
@@ -322,7 +322,7 @@ int MESA_mac_pton(const char *str, int delim, char *mac)
const char *s = str;
int i;
- /* �������Ϸ��� */
+ /* �������Ϸ��� */
if(delim != -1)
{
if(strlen(str) != MAC_STR_LEN_DELIM)
@@ -340,10 +340,10 @@ int MESA_mac_pton(const char *str, int delim, char *mac)
}
}
- /* �������Ϸ��ԣ�ͬʱת����16����ֵ */
+ /* �������Ϸ��ԣ�ͬʱת����16����ֵ */
for(i = 0; i < 6; i++)
{
- mac[i] = 0; /* �����㣬��ֵ��䶼�ǻ���� */
+ mac[i] = 0; /* �����㣬��ֵ��䶼�ǻ���� */
if(isxdigit(*s)==0)
{
printf("MAC string type error!\n");
@@ -449,7 +449,7 @@ int sendpacket_do_checksum(unsigned char *buf, int protocol, int len)
sum = 0;
iph_p = (struct mesa_ip4_hdr *)buf;
- if(4 == iph_p->ip_v) /* IP�汾���ֶΣ�IPv4��IPv6��ʽ����ͬ�� */
+ if(4 == iph_p->ip_v) /* IP�汾���ֶΣ�IPv4��IPv6��ʽ����ͬ�� */
{
ip_hl = iph_p->ip_hl << 2;
ip6h_p = NULL;
@@ -575,8 +575,8 @@ int sendpacket_build_ipv4(u_int16_t carry_layer_len, u_int8_t tos, u_int16_t id,
ip_hdr->ip_ttl = ttl; /* time to live */
ip_hdr->ip_p = prot; /* transport protocol */
ip_hdr->ip_sum = 0; /* do this later */
- ip_hdr->ip_src.s_addr = src; /* Ϊʲô��ַ��������? ��ʷ����ԭ��, �Ķ�̫��,ֻ����ô������ */
- ip_hdr->ip_dst.s_addr = dst; /* Ϊʲô��ַ��������? ��ʷ����ԭ��, �Ķ�̫��,ֻ����ô������ */
+ ip_hdr->ip_src.s_addr = src; /* Ϊʲô��ַ��������? ��ʷ����ԭ��, �Ķ�̫��,ֻ����ô������ */
+ ip_hdr->ip_dst.s_addr = dst; /* Ϊʲô��ַ��������? ��ʷ����ԭ��, �Ķ�̫��,ֻ����ô������ */
if (payload && payload_s){
/*
* Unchecked runtime error for buf + IP_H + payload to be greater than
@@ -590,7 +590,7 @@ int sendpacket_build_ipv4(u_int16_t carry_layer_len, u_int8_t tos, u_int16_t id,
}
-/* TODO 2: ����չͷ����IPv6�� */
+/* TODO 2: ����չͷ����IPv6�� */
int sendpacket_build_ipv6(u_int8_t traffic_class, u_int32_t flow_lable,
u_int16_t len, u_int8_t next_header, u_int8_t hop,
const struct in6_addr *src, const struct in6_addr *dst,
@@ -630,7 +630,7 @@ int sendpacket_build_ipv6(u_int8_t traffic_class, u_int32_t flow_lable,
return 0;
}
-/* 2012-04-10 LiJia add, ���ڹ���ICMP-ECHO-REQUEST, ICMP-ECHO-REPLAY�� */
+/* 2012-04-10 LiJia add, ���ڹ���ICMP-ECHO-REQUEST, ICMP-ECHO-REPLAY�� */
int sendpacket_build_icmpv4_echo(u_int8_t type, u_int8_t code, u_int16_t sum,
u_int16_t id, u_int16_t seq, u_int8_t *payload, u_int32_t payload_s, unsigned char *buf)
{
@@ -769,7 +769,7 @@ int sendpacket_build_udp(u_int16_t sp, u_int16_t dp, const char *payload, int pa
}
/* lijia add carry_layer_len args,
- ��Ƕ�ס�����ģʽ�¹������ݰ�, û��payload, ��ʵ�ʻ����ϲ�Э��, ��teredo, ��Э��ʱʹ��.
+ ��Ƕ�ס�����ģʽ�¹������ݰ�, û��payload, ��ʵ�ʻ����ϲ�Э��, ��teredo, ��Э��ʱʹ��.
*/
int sendpacket_build_udp_dual_stack(u_int16_t sp, u_int16_t dp, const char *payload,
int payload_s, int carry_layer_len, unsigned char *buf)
@@ -879,7 +879,7 @@ static int calc_mpls_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_s
}
}
}else{
- /* �����ǿ��Ҫ��ǶԳƵ�ַ, �������û�е�ַ, ��ʹ�öԲ��ַ��Ϣ */
+ /* �����ǿ��Ҫ��ǶԳƵ�ַ, �������û�е�ַ, ��ʹ�öԲ��ַ��Ϣ */
if(send_stream_dir == DIR_C2S){
if(mpls_addr->c2s_layer_num > 0){
mpls_layer_len = sizeof(struct mesa_mpls_hdr) * mpls_addr->c2s_layer_num;
@@ -922,7 +922,7 @@ static int calc_vlan_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_s
vlan_layer_len = sizeof(struct mesa_vlan_hdr) * vlan_addr->s2c_layer_num;
}
}else{
- /* �����ǿ��Ҫ��ǶԳƵ�ַ, �������û��, ��ʹ�öԲ��ַ��Ϣ */
+ /* �����ǿ��Ҫ��ǶԳƵ�ַ, �������û��, ��ʹ�öԲ��ַ��Ϣ */
if(send_stream_dir == DIR_C2S){
if(vlan_addr->c2s_layer_num != 0){
vlan_layer_len = sizeof(struct mesa_vlan_hdr) * vlan_addr->c2s_layer_num;
@@ -950,11 +950,11 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st
raw_net_gtp_hdr = (const struct gtp_hdr *)((const char *)stream_pr->raw_pkt->raw_pkt_data + stream_pr->offset_to_raw_pkt_hdr);
/*
- �ݲ�֧�ִ���ŵ�GTP����,
- һ��GTP�������ܳ��ض���ڲ���Ԫ��, ���ڲ��Ԫ���������һ���ֵ�ͬһ���߳���,
- ��ô��֤����ڲ�TCP/UDP����֮���GTP���ͬ��??
- ̫������!
- TODO��!!
+ �ݲ�֧�ִ���ŵ�GTP����,
+ һ��GTP�������ܳ��ض���ڲ���Ԫ��, ���ڲ��Ԫ���������һ���ֵ�ͬһ���߳���,
+ ��ô��֤����ڲ�TCP/UDP����֮���GTP���ͬ��??
+ ̫������!
+ TODO��!!
*/
if(raw_net_gtp_hdr->flags & (GTP_HDR_FLAG_SEQ_NUM | GTP_HDR_FLAG_N_PDU | GTP_HDR_FLAG_NEXT_EXT_HDR))
{
@@ -966,7 +966,7 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st
}
if(g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_GPRS_TUNNEL][stream_pr->layer_index] != 0){
- /* ���GTP�����˷ǶԳƱ��, ���뱣֤��ǰע�뷽��֮ǰ���������ݰ� */
+ /* ���GTP�����˷ǶԳƱ��, ���뱣֤��ǰע�뷽��֮ǰ���������ݰ� */
if(send_stream_dir == DIR_C2S){
if(0 == p_gtp_layer_addr->teid_c2s){
sapp_global_val->mthread_volatile[stream_pr->stream_public.threadnum]->sys_stat.count[SAPP_STAT_SND_ERROR]++;
@@ -981,7 +981,7 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st
}
}
}else{
- /* ��ǿ��GTP��ַ�ǶԳ�, sapp�����϶��ǿ��Ե�, ���ǿ��ܶԶ˲����� */
+ /* ��ǿ��GTP��ַ�ǶԳ�, sapp�����϶��ǿ��Ե�, ���ǿ��ܶԶ˲����� */
}
return hdr_len;
@@ -989,11 +989,11 @@ static int calc_gtp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_st
extern int calc_l2tp_hdr_len(struct streaminfo_private * stream_pr, UCHAR send_stream_dir);
/*
- 1-�������а�ͷ�ij���, ����Ԥ���ռ�. ���㵽��ײ�Э��, �����MACҲ����MACͷ�ռ�;
- 2-�ݹ�����л�ȡEthernet����ص�Э������.
+ 1-�������а�ͷ�ij���, ����Ԥ���ռ�. ���㵽��ײ�Э��, �����MACҲ����MACͷ�ռ�;
+ 2-�ݹ�����л�ȡEthernet����ص�Э������.
2020-09-25 lijia add args send_stream_dir,
- send_stream_dir: ��MPLSЭ��ֻ�е����ַ, ���ܲ������ǷǶԳƵ�, ��Ҫ֪����������, ����ȷ��Ԥ��ͷ������.
+ send_stream_dir: ��MPLSЭ��ֻ�е����ַ, ���ܲ������ǷǶԳƵ�, ��Ҫ֪����������, ����ȷ��Ԥ��ͷ������.
*/
static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type, UCHAR send_stream_dir)
{
@@ -1001,38 +1001,38 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type,
struct streaminfo_private *stream_pr = (struct streaminfo_private *)stream;
int pfather_hdr_len;
- if(NULL == stream){ /* �ݹ�����ս�����! */
+ if(NULL == stream){ /* �ݹ�����ս�����! */
return 0;
}
- if(is_proxy_stream(stream)){ /* �������ṹΪ����ṹ, ʵ�ʹ����ʱ���������� */
+ if(is_proxy_stream(stream)){ /* �������ṹΪ����ṹ, ʵ�ʹ����ʱ���������� */
return calc_reserved_hdr_len((struct streaminfo *)stream->pfather, net_layer_type, send_stream_dir);
}
switch(stream->addr.addrtype){
case ADDR_TYPE_IPV4:
- /* 2015-12-30 lijia modify, IP�Ͷ˿�ͬʱ�洢�ڴ˽ṹ */
+ /* 2015-12-30 lijia modify, IP�Ͷ˿�ͬʱ�洢�ڴ˽ṹ */
if(STREAM_TYPE_TCP == stream->type){
reserved_hdr_len = sizeof(struct mesa_tcp_hdr) + sizeof(struct mesa_ip4_hdr);
}else if (STREAM_TYPE_UDP == stream->type){
reserved_hdr_len = sizeof(struct mesa_udp_hdr) + sizeof(struct mesa_ip4_hdr);
}else{
//printf("addr type is tuple4v4, but stream type is not TCP or UDP!\n");
- sapp_runtime_log(RLOG_LV_FATAL, "calc_reserved_hdr_len(): addr type is tuple4v4, but stream type is :%d, not TCP or UDP.\n", stream->type);
+ sapp_runtime_log(RLOG_LV_FATAL, "calc_reserved_hdr_len(): addr type is tuple4v4, but stream type is :%d, not TCP or UDP.", stream->type);
return -1;
//assert(0);
}
break;
case ADDR_TYPE_IPV6:
- /* 2015-12-30 lijia modify, IP�Ͷ˿�ͬʱ�洢�ڴ˽ṹ */
+ /* 2015-12-30 lijia modify, IP�Ͷ˿�ͬʱ�洢�ڴ˽ṹ */
if(STREAM_TYPE_TCP == stream->type){
reserved_hdr_len = sizeof(struct mesa_tcp_hdr) + sizeof(struct mesa_ip6_hdr);;
}else if (STREAM_TYPE_UDP == stream->type){
reserved_hdr_len = sizeof(struct mesa_udp_hdr) + sizeof(struct mesa_ip6_hdr);;
}else{
//printf("addr type is tuple4v6, but stream type is not TCP or UDP!\n");
- sapp_runtime_log(RLOG_LV_FATAL, "calc_reserved_hdr_len(): addr type is tuple4v6, but stream type is :%d, not TCP or UDP.\n", stream->type);
+ sapp_runtime_log(RLOG_LV_FATAL, "calc_reserved_hdr_len(): addr type is tuple4v6, but stream type is :%d, not TCP or UDP.", stream->type);
return -1;
//assert(0);
}
@@ -1048,7 +1048,7 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type,
case ADDR_TYPE_ARP:
//printf("Sendpacket use ARP!\n");
- sapp_runtime_log(RLOG_LV_INFO, "calc_reserved_hdr_len(): Sendpacket use ARP.\n");
+ sapp_runtime_log(RLOG_LV_INFO, "calc_reserved_hdr_len(): Sendpacket use ARP.");
return -1;
//assert(0);
break;
@@ -1069,8 +1069,8 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type,
break;
case ADDR_TYPE_TCP:
- /* to do, ������ʹ�ѡ��İ�, ���Һ�ԭʼ����һ���Ļ�, ��ô����?
- ��Ԥ����󳤶�, Ȼ�����ʵ��ѡ���, ��memmove�ƶ��ѹ���ĸ���.
+ /* to do, ������ʹ�ѡ��İ�, ���Һ�ԭʼ����һ���Ļ�, ��ô����?
+ ��Ԥ����󳤶�, Ȼ�����ʵ��ѡ���, ��memmove�ƶ��ѹ���ĸ���.
*/
reserved_hdr_len = sizeof(struct mesa_tcp_hdr);
break;
@@ -1092,17 +1092,17 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type,
break;
case __ADDR_TYPE_IP_PAIR_V4:
- /* to do, ��������ѡ��İ�, ��ô����? */
+ /* to do, ��������ѡ��İ�, ��ô����? */
reserved_hdr_len = sizeof(struct mesa_ip4_hdr);
break;
case __ADDR_TYPE_IP_PAIR_V6:
- /* to do, ��������ѡ��İ�, ��ô����? */
+ /* to do, ��������ѡ��İ�, ��ô����? */
reserved_hdr_len = sizeof(struct mesa_ip6_hdr);
break;
case ADDR_TYPE_PPP:
- assert(0); /* ���ٵ�����PPP��, ��L2TP, PPTP��Ϊһ�� */
+ assert(0); /* ���ٵ�����PPP��, ��L2TP, PPTP��Ϊһ�� */
reserved_hdr_len = sizeof(struct mesa_ppp_hdr);
break;
@@ -1140,12 +1140,12 @@ static int calc_reserved_hdr_len(struct streaminfo *stream, int *net_layer_type,
if(CAP_LEVEL_MAC == g_packet_io_cap_level) {
if(stream_pr->pfather_pr
&& ((ADDR_TYPE_MAC_IN_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype) || (ADDR_TYPE_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype))){
- /* ��¼MAC��֮�ϵ�Э���ַ����, �������Ethernet->type�ֶ�, ����MAC-in-MAC��inner_eth, ��¼�ϲ�Э������ */
+ /* ��¼MAC��֮�ϵ�Э���ַ����, �������Ethernet->type�ֶ�, ����MAC-in-MAC��inner_eth, ��¼�ϲ�Э������ */
*net_layer_type = (int)stream->addr.addrtype;
}
}else{
/* to do:
- ����������Զ�������ethernet��, ����������vlan�Ȳ���һ�Ҫ������ô��?
+ ����������Զ�������ethernet��, ����������vlan�Ȳ���һ�Ҫ������ô��?
*/
if(NULL == stream_pr->pfather_pr){
if(g_packet_io_cap_level == stream->addr.addrtype){
@@ -1250,9 +1250,9 @@ static int build_net_layer_ethernet(const struct streaminfo *top_stream, struct
int carry_layer_len, unsigned char *buf, UCHAR send_stream_dir, const raw_pkt_t *raw_pkt)
{
/*
- ע��˴�����ʹ��ԭʼ���еĵ�ַ, ��Ϊ�漰�������ַ���Գ�, ����ip��ַ�Ͷ˿�, �ߵ�src��dst����,
- ���C2S��S2C�����ֱ�����������·, C2S��S2C�����macȫ����һ��, һ�������ĸ�MAC��ַ, ����������!
- ����Ƿ��򷢰�, ��ʹ�ߵ�src, dstҲ�Ǵ����!!
+ ע��˴�����ʹ��ԭʼ���еĵ�ַ, ��Ϊ�漰�������ַ���Գ�, ����ip��ַ�Ͷ˿�, �ߵ�src��dst����,
+ ���C2S��S2C�����ֱ�����������·, C2S��S2C�����macȫ����һ��, һ�������ĸ�MAC��ַ, ����������!
+ ����Ƿ��򷢰�, ��ʹ�ߵ�src, dstҲ�Ǵ����!!
*/
const struct layer_addr_mac *in_stream_addr;
in_stream_addr = (struct layer_addr_mac *)(stream_pr->stream_public.addr.mac);
@@ -1260,9 +1260,9 @@ static int build_net_layer_ethernet(const struct streaminfo *top_stream, struct
send_hdr->ether_type = htons(eth_type_host);
- /* ����ģʽ��,��ײ����蹹��ethernet��ַ,
- ����inject_pkt_mode��ʲôģʽ, sys_route����raw_ethernet_single_gateway�ȵ�, �����macʵ�ʶ�����ԭʼ���е�mac��ַ,
- ��ʱҲ�����������ļ�etc/asymmetric_addr_layer.conf��ethernet[0]�Ƿ���, �Ӷ����µ������ķ��򷢰���Ч.
+ /* ����ģʽ��,��ײ����蹹��ethernet��ַ,
+ ����inject_pkt_mode��ʲôģʽ, sys_route����raw_ethernet_single_gateway�ȵ�, �����macʵ�ʶ�����ԭʼ���е�mac��ַ,
+ ��ʱҲ�����������ļ�etc/asymmetric_addr_layer.conf��ethernet[0]�Ƿ���, �Ӷ����µ������ķ��򷢰���Ч.
*/
if((NULL == stream_pr->pfather_pr)
&& (DEPLOYMENT_MODE_MIRROR == sapp_global_val->config.packet_io.deployment_mode_bin)){
@@ -1284,10 +1284,10 @@ static int build_net_layer_ethernet(const struct streaminfo *top_stream, struct
return -1;
}
if(DIR_C2S == send_stream_dir){
- memcpy(send_hdr->ether_shost, in_stream_addr->src_addr.h_source, ETHER_ADDR_LEN); /* ��ַͬ��copy */
+ memcpy(send_hdr->ether_shost, in_stream_addr->src_addr.h_source, ETHER_ADDR_LEN); /* ��ַͬ��copy */
memcpy(send_hdr->ether_dhost, in_stream_addr->src_addr.h_dest, ETHER_ADDR_LEN);
}else{
- memcpy(send_hdr->ether_shost, in_stream_addr->dst_addr.h_source, ETHER_ADDR_LEN); /* ��ַͬ��copy */
+ memcpy(send_hdr->ether_shost, in_stream_addr->dst_addr.h_source, ETHER_ADDR_LEN); /* ��ַͬ��copy */
memcpy(send_hdr->ether_dhost, in_stream_addr->dst_addr.h_dest, ETHER_ADDR_LEN);
}
}
@@ -1374,7 +1374,7 @@ static int build_net_layer_udp(struct streaminfo_private *stream_pr, int carry_l
#endif
if((reverse)
- && (g_overlay_layer_set[ADDR_TYPE_UDP][stream_pr->layer_index] == 0)){ /* vxlan��overlay�㲻��ת�˿� */
+ && (g_overlay_layer_set[ADDR_TYPE_UDP][stream_pr->layer_index] == 0)){ /* vxlan��overlay�㲻��ת�˿� */
sendpacket_build_udp_dual_stack(ntohs(raw_udp_hdr->uh_dport),
ntohs(raw_udp_hdr->uh_sport),
NULL,
@@ -1510,20 +1510,20 @@ static int build_net_layer_pppoe_ses(struct streaminfo_private *stream_pr, int c
raw_hdr = (struct mesa_pppoe_session_hdr *)(stream_pr->offset_to_raw_pkt_hdr + (char *)raw_pkt->raw_pkt_data);
- /* PPPOE�޷�����, ��ԭʼ����copy���� */
+ /* PPPOE�޷�����, ��ԭʼ����copy���� */
(void)reverse;
memcpy(send_hdr, raw_hdr, sizeof(struct mesa_pppoe_session_hdr));
/* lijia comment:
- �˴�Ϊ��Ҫ��sizeof(send_hdr->ppp_protocol)?
- ��ΪPPPOE_SES��ͷ�����Dz���PPPЭ�������ֶε�, ��Ϊ�˷��㴦��, ������2��1��.
+ �˴�Ϊ��Ҫ��sizeof(send_hdr->ppp_protocol)?
+ ��ΪPPPOE_SES��ͷ�����Dz���PPPЭ�������ֶε�, ��Ϊ�˷��㴦��, ������2��1��.
*/
send_hdr->len = htons(carry_layer_len + sizeof(send_hdr->ppp_protocol));
return sizeof(struct mesa_pppoe_session_hdr);
}
-/* �����紫��ĵ�ַת��Ϊ�ڴ�ṹ, ����ҵ�������� */
+/* �����紫��ĵ�ַת��Ϊ�ڴ�ṹ, ����ҵ�������� */
int vlan_addr_net_to_mem(const struct mesa_vlan_detail_hdr *net_vlan_hdr, struct single_layer_vlan_addr *mem_vlan_hdr)
{
mem_vlan_hdr->VID = htons(net_vlan_hdr->vlan_id_high << 8 | net_vlan_hdr->vlan_id_low);
@@ -1534,7 +1534,7 @@ int vlan_addr_net_to_mem(const struct mesa_vlan_detail_hdr *net_vlan_hdr, struct
return 0;
}
-/* ���ڴ��ַ�ṹת��ΪRFC��׼ͷ����ʽ, ���͵������� */
+/* ���ڴ��ַ�ṹת��ΪRFC��׼ͷ����ʽ, ���͵������� */
int vlan_addr_mem_to_net(const struct single_layer_vlan_addr *mem_vlan_hdr, struct mesa_vlan_detail_hdr *net_vlan_hdr)
{
net_vlan_hdr->vlan_id_high = (ntohs(mem_vlan_hdr->VID) & 0xF00) >> 8;
@@ -1574,7 +1574,7 @@ static int build_net_layer_vlan(struct streaminfo_private *stream_pr, int carry_
//memcpy(buf, in_stream_addr->c2s_addr_array, layer_len);
build_net_multilayer_vlan(in_stream_addr->c2s_addr_array, in_stream_addr->c2s_layer_num, (struct mesa_vlan_detail_hdr *)buf);
}else{
- /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
+ /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
if(0 == g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_VLAN][stream_pr->layer_index]){
layer_len = sizeof(struct mesa_vlan_hdr) * in_stream_addr->s2c_layer_num;
build_net_multilayer_vlan(in_stream_addr->s2c_addr_array, in_stream_addr->s2c_layer_num, (struct mesa_vlan_detail_hdr *)buf);
@@ -1591,7 +1591,7 @@ static int build_net_layer_vlan(struct streaminfo_private *stream_pr, int carry_
//memcpy(buf, in_stream_addr->s2c_addr_array, layer_len);
build_net_multilayer_vlan(in_stream_addr->s2c_addr_array, in_stream_addr->s2c_layer_num, (struct mesa_vlan_detail_hdr *)buf);
}else{
- /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
+ /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
if(0 == g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_VLAN][stream_pr->layer_index]){
layer_len = sizeof(struct mesa_vlan_hdr) * in_stream_addr->c2s_layer_num;
//memcpy(buf, in_stream_addr->c2s_addr_array, layer_len);
@@ -1645,10 +1645,10 @@ static int build_net_layer_gerv1_exthdr(const struct mesa_gre_hdr *parsed_hdr,
unsigned short payload_len = (unsigned short)carry_layer_len;
payload_len = htons(payload_len);
- memcpy(send_ext_value, &payload_len, sizeof(short)); /* GREv1 �ض���length�ֶ� */
+ memcpy(send_ext_value, &payload_len, sizeof(short)); /* GREv1 �ض���length�ֶ� */
send_ext_value += sizeof(short);
- memcpy(send_ext_value, &send_call_id, sizeof(short)); /* GREv1 �ض���callid�ֶ� */
+ memcpy(send_ext_value, &send_call_id, sizeof(short)); /* GREv1 �ض���callid�ֶ� */
send_ext_value += sizeof(short);
if(0 == reverse){
@@ -1699,7 +1699,7 @@ static int build_net_layer_gre(const struct streaminfo *top_stream, struct strea
int gre_hdr_len, ret;
const struct layer_addr_pptp *raw_pptp_addr = stream_pr->stream_public.addr.pptp;
#if 0
- /* NOTE: BUGFIX, ��ǰ����curdir���ܲ�û������, ��Ϊֻ��TCP��������curdir, ���Բ���ȡ��������curdirֵ */
+ /* NOTE: BUGFIX, ��ǰ����curdir���ܲ�û������, ��Ϊֻ��TCP��������curdir, ���Բ���ȡ��������curdirֵ */
UCHAR curdir = stream_pr->stream_public.curdir;
#endif
UINT16 send_call_id;
@@ -1711,20 +1711,20 @@ static int build_net_layer_gre(const struct streaminfo *top_stream, struct strea
}
if((reverse != 0) && (top_stream->dir != DIR_DOUBLE)){
- /* ������û���յ�����, �������޷���� */
+ /* ������û���յ�����, �������޷���� */
sapp_runtime_log(20, "in gre layer, send dir is reverse, but haven't get opposite single stream info!\n");
return -1;
}
if(0 == reverse){
if(stack_hdr.gre_extend.call_id == raw_pptp_addr->C2S_call_id){
- /* ͬ�򷢰�, �͵�ǰ����һ�� */
+ /* ͬ�򷢰�, �͵�ǰ����һ�� */
send_call_id = raw_pptp_addr->C2S_call_id;
}else{
send_call_id = raw_pptp_addr->S2C_call_id;
}
}else{
- /* ���򷢰�, ʹ�öԶ˵�callid */
+ /* ���򷢰�, ʹ�öԶ˵�callid */
if(stack_hdr.gre_extend.call_id == raw_pptp_addr->C2S_call_id){
send_call_id = raw_pptp_addr->S2C_call_id;
}else{
@@ -1749,7 +1749,7 @@ static int build_net_layer_gre(const struct streaminfo *top_stream, struct strea
return gre_hdr_len;
}
-/* �����紫��ĵ�ַת��Ϊ�ڴ�ṹ, ����ҵ�������� */
+/* �����紫��ĵ�ַת��Ϊ�ڴ�ṹ, ����ҵ�������� */
int mpls_addr_net_to_mem(const struct mesa_mpls_hdr *net_mpls_hdr, struct single_layer_mpls_addr *mem_mpls_hdr)
{
memset(mem_mpls_hdr, 0, sizeof(struct single_layer_mpls_addr));
@@ -1762,7 +1762,7 @@ int mpls_addr_net_to_mem(const struct mesa_mpls_hdr *net_mpls_hdr, struct single
return 0;
}
-/* ���ڴ��ַ�ṹת��ΪRFC��׼ͷ����ʽ, ���͵������� */
+/* ���ڴ��ַ�ṹת��ΪRFC��׼ͷ����ʽ, ���͵������� */
int mpls_addr_mem_to_net(const struct single_layer_mpls_addr *mem_mpls_hdr, struct mesa_mpls_hdr *net_mpls_hdr)
{
memset(net_mpls_hdr, 0, sizeof(struct mesa_mpls_hdr));
@@ -1810,7 +1810,7 @@ static int build_net_layer_mpls(struct streaminfo_private *stream_pr, int carry_
layer_len += sizeof(int);
}
}else{
- /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
+ /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
if(0 == g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_MPLS][stream_pr->layer_index]){
layer_len = sizeof(struct mesa_mpls_hdr) * in_stream_addr->s2c_layer_num;
//memcpy(buf, in_stream_addr->dest_mpls_pkt, layer_len);
@@ -1835,7 +1835,7 @@ static int build_net_layer_mpls(struct streaminfo_private *stream_pr, int carry_
layer_len += sizeof(int);
}
}else{
- /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
+ /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
if(0 == g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_MPLS][stream_pr->layer_index]){
layer_len = sizeof(struct mesa_mpls_hdr) * in_stream_addr->c2s_layer_num;
//memcpy(buf, in_stream_addr->src_mpls_pkt, layer_len);
@@ -1891,7 +1891,7 @@ static int build_net_layer_gtp(struct streaminfo_private *stream_pr, int carry_l
}
}
- gtp_send_hdr->flags = 0x30; /* ��ʱֻ֧��v1�汾, ����seq */
+ gtp_send_hdr->flags = 0x30; /* ��ʱֻ֧��v1�汾, ����seq */
gtp_send_hdr->msg_type = 0xFF; /* T-PDU */
gtp_send_hdr->len = htons(carry_layer_len);
gtp_send_hdr->teid = this_pkt_teid;
@@ -1918,7 +1918,7 @@ static int build_net_layer_ppp(struct streaminfo_private *stream_pr, int carry_l
int carry_layer_len, unsigned char *buf, int reverse, const raw_pkt_t *raw_pkt, int ppp_hdr_len)
{
- /* PPP�޷�����, ��ԭʼ����copy���� */
+ /* PPP�޷�����, ��ԭʼ����copy���� */
(void)reverse;
memcpy(buf, stream_pr->offset_to_raw_pkt_hdr + (char *)raw_pkt->raw_pkt_data, ppp_hdr_len);
@@ -2004,7 +2004,7 @@ static int build_net_layer_vxlan(struct streaminfo_private *stream_pr, int carry
if(in_stream_addr->C2S_vxlan_addr.flag != 0){
build_net_single_layer_vxlan(stream_pr, send_vxlan_hdr, raw_vxlan_hdr, send_stream_dir);
}else{
- /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
+ /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
if(0 == g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_VXLAN][stream_pr->layer_index]){
build_net_single_layer_vxlan(stream_pr, send_vxlan_hdr, raw_vxlan_hdr, send_stream_dir ^ DIR_DOUBLE);
}else{
@@ -2017,7 +2017,7 @@ static int build_net_layer_vxlan(struct streaminfo_private *stream_pr, int carry
if(in_stream_addr->S2C_vxlan_addr.flag > 0){
build_net_single_layer_vxlan(stream_pr, send_vxlan_hdr, raw_vxlan_hdr, send_stream_dir);
}else{
- /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
+ /* ����û�е�ַ, ȡ���������ļ�asymmetric_addr_layer�Ƿ�����öԲ��ַ */
if(0 == g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_VXLAN][stream_pr->layer_index]){
build_net_single_layer_vxlan(stream_pr, send_vxlan_hdr, raw_vxlan_hdr, send_stream_dir ^ DIR_DOUBLE);
}else{
@@ -2029,7 +2029,7 @@ static int build_net_layer_vxlan(struct streaminfo_private *stream_pr, int carry
}
/*
- TODO: ppp, hdlc��Ҳ��c2s, s2c��������洢.
+ TODO: ppp, hdlc��Ҳ��c2s, s2c��������洢.
*/
if(VXLAN_ENCAP_HDLC == raw_vxlan_hdr->addr_public.C2S_vxlan_addr.link_type){
struct hdlc_net_hdr *snd_hdlc_hdr = (struct hdlc_net_hdr *)(buf + sizeof(inline_vxlan_hdr_t));
@@ -2061,8 +2061,8 @@ static int build_net_layer_l2tp(const struct streaminfo *top_stream, struct stre
if(0 == (top_stream->dir & send_stream_dir)){
/* TODO 2:
- L2TP��c2s��s2c����TUNNEL-ID��һ��, Ŀǰû���γ�L2TP��, �޷�������һ���������Ϣ ,
- ����, ��֧�ֵ���������ע�����ݰ�.
+ L2TP��c2s��s2c����TUNNEL-ID��һ��, Ŀǰû���γ�L2TP��, �޷�������һ���������Ϣ ,
+ ����, ��֧�ֵ���������ע�����ݰ�.
*/
sapp_runtime_log(RLOG_LV_INFO, "build_net_layer_l2tp() error, not support inject reverse pkt for single dir stream!");
return -1;
@@ -2071,16 +2071,16 @@ static int build_net_layer_l2tp(const struct streaminfo *top_stream, struct stre
memset(buf, 0, l2tp_raw_hdr_len);
inject_net_hdr = (struct l2tp_hdr_v2 *)buf;
- inject_ptr = buf + sizeof(struct l2tp_hdr_v2); /* ָ��̶�ͷ������Ļ����� */
+ inject_ptr = buf + sizeof(struct l2tp_hdr_v2); /* ָ��̶�ͷ������Ļ����� */
- inject_net_hdr->type = 0; /* Ŀǰ��֧��ע��data message */
+ inject_net_hdr->type = 0; /* Ŀǰ��֧��ע��data message */
inject_net_hdr->offset_present = 0;
inject_net_hdr->priority = 0;
inject_net_hdr->seq_present = 0;
- inject_net_hdr->version = 2; /* Ŀǰ�̶�֧��v2 */
+ inject_net_hdr->version = 2; /* Ŀǰ�̶�֧��v2 */
/*
- ע��l2tp���ݰ��̶�����length�ֶ�
+ ע��l2tp���ݰ��̶�����length�ֶ�
*/
{
inject_net_hdr->length_present = 1;
@@ -2124,20 +2124,20 @@ static int build_net_layer_l2tp(const struct streaminfo *top_stream, struct stre
/*
- �˺����ڲ��������ж��Ƿ���Ҫ����bloom filter, �ں����ⲿ�Ѿ��ж�.
+ �˺����ڲ��������ж��Ƿ���Ҫ����bloom filter, �ں����ⲿ�Ѿ��ж�.
*/
extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_pkt_t *rawpkt);
/*
- buf: ִ��Ӧ�ò㸺�ص�ַ, skip hdr.
- reverse: ��Ӧ�ò�ĽǶ�����dir, ��ʾ�뵱ǰraw_pkt�����, �����Ƿ�һ��, �����з����Եĵ�ַ, �跴�����.
+ buf: ִ��Ӧ�ò㸺�ص�ַ, skip hdr.
+ reverse: ��Ӧ�ò�ĽǶ�����dir, ��ʾ�뵱ǰraw_pkt�����, �����Ƿ�һ��, �����з����Եĵ�ַ, �跴�����.
2020-09-25 lijia add args send_stream_dir:
- send_stream_dir: ��ʾ��ǰ������������, DIR_C2S����DIR_S2C,
- ��ΪMPLS, GTP�Ȳ�ԭʼ����ֻ�е����ַ, reverse�ĺ��岻�ܾ�ȷ��ʾmpls, gtp�Ȳ㵽��ʹ���ĸ�����ĵ�ַ.
- top_stream: ���ϲ�����ṹ��, ͨ����tcp��udp��, ��ֵ���к���ջ�б��ֲ���.
+ send_stream_dir: ��ʾ��ǰ������������, DIR_C2S����DIR_S2C,
+ ��ΪMPLS, GTP�Ȳ�ԭʼ����ֻ�е����ַ, reverse�ĺ��岻�ܾ�ȷ��ʾmpls, gtp�Ȳ㵽��ʹ���ĸ�����ĵ�ַ.
+ top_stream: ���ϲ�����ṹ��, ͨ����tcp��udp��, ��ֵ���к���ջ�б��ֲ���.
*/
static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct streaminfo *up_stream, struct streaminfo_private *stream_pr, int carry_layer_type,
int carry_layer_len, unsigned char *buf, int reverse, const raw_pkt_t *raw_pkt, UCHAR send_stream_dir)
@@ -2162,7 +2162,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
return -1;
}
- if(is_proxy_stream(stream)){ /* �������ṹΪ����ṹ, ʵ�ʵİ������ڴ˲�, �����ʱ���������� */
+ if(is_proxy_stream(stream)){ /* �������ṹΪ����ṹ, ʵ�ʵİ������ڴ˲�, �����ʱ���������� */
return build_net_layer_pkt(top_stream, carry_layer_stream, (struct streaminfo_private *)stream->pfather, carry_layer_type,
this_layer_len+carry_layer_len, buf, reverse, raw_pkt, send_stream_dir);
}
@@ -2170,7 +2170,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
switch(stream->addr.addrtype){
case ADDR_TYPE_IPV4:
{
- /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, �ȹ���TCP/UDP�� */
+ /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, �ȹ���TCP/UDP�� */
if(STREAM_TYPE_TCP == stream->type){
transport_layer_len = sizeof(struct mesa_tcp_hdr);
buf -= sizeof(struct mesa_tcp_hdr);
@@ -2183,12 +2183,12 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
carry_layer_type = ADDR_TYPE_UDP;
}
- /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, ��������IPv4�� */
+ /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, ��������IPv4�� */
this_layer_len += sizeof(struct mesa_ip4_hdr) + transport_layer_len;
buf -= sizeof(struct mesa_ip4_hdr);
build_net_layer_ipv4(stream_pr, carry_layer_type, carry_layer_len + transport_layer_len, buf, reverse, raw_pkt);
- /* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
+ /* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
checksum_for_carry_layer(buf, __ADDR_TYPE_IP_PAIR_V4, carry_layer_type, carry_layer_len+transport_layer_len);
carry_layer_type = __ADDR_TYPE_IP_PAIR_V4;
const struct mesa_ip4_hdr *ip4hdr = (struct mesa_ip4_hdr *)buf;
@@ -2196,8 +2196,8 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
sapp_raw_ipv4_ntop(ip4hdr, debug_print_buf, sizeof(debug_print_buf)), send_stream_dir,
ntohs(ip4hdr->ip_id), ntohs(ip4hdr->ip_sum));
- /* �ظ�����ע���ʶ��, �ӵ���������Ϊ���������, ���ܻ��ж��, �Ҳ����پ���jump_layer��ת���ڲ�udp/tcp����
- vxlanģʽ�ײ�udpû��ҪƵ������bloom filter, �ȵ���sapp_is_overlay_layer()ʶ��һ��.
+ /* �ظ�����ע���ʶ��, �ӵ���������Ϊ���������, ���ܻ��ж��, �Ҳ����پ���jump_layer��ת���ڲ�udp/tcp����
+ vxlanģʽ�ײ�udpû��ҪƵ������bloom filter, �ȵ���sapp_is_overlay_layer()ʶ��һ��.
*/
if((sapp_global_val->config.packet_io.dup_pkt_para.dup_pkt_distinguish_all_inject != 0)
&& (sapp_is_overlay_layer(stream_pr, raw_pkt) == 0)){
@@ -2207,7 +2207,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
break;
case ADDR_TYPE_IPV6:
- /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, �ȹ���TCP/UDP�� */
+ /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, �ȹ���TCP/UDP�� */
if(STREAM_TYPE_TCP == stream->type){
transport_layer_len = sizeof(struct mesa_tcp_hdr);
buf -= sizeof(struct mesa_tcp_hdr);
@@ -2220,28 +2220,28 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
carry_layer_type = ADDR_TYPE_UDP;
}
- /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, ��������IPv6�� */
+ /* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, ��������IPv6�� */
this_layer_len += sizeof(struct mesa_ip6_hdr) + transport_layer_len;
buf -= sizeof(struct mesa_ip6_hdr);
build_net_layer_ipv6(stream_pr, carry_layer_type, carry_layer_len + transport_layer_len, buf, reverse, raw_pkt);
- /* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
+ /* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
checksum_for_carry_layer(buf, __ADDR_TYPE_IP_PAIR_V6, carry_layer_type, carry_layer_len+transport_layer_len);
carry_layer_type = __ADDR_TYPE_IP_PAIR_V6;
- /* �ظ�����ʶ��, �ӵ���������Ϊ���������, ���ܻ��ж��, �Ҳ����پ���jump_layer��ת���ڲ�udp/tcp���� */
+ /* �ظ�����ʶ��, �ӵ���������Ϊ���������, ���ܻ��ж��, �Ҳ����پ���jump_layer��ת���ڲ�udp/tcp���� */
if(sapp_global_val->config.packet_io.dup_pkt_para.dup_pkt_distinguish_all_inject != 0){
sapp_dup_pkt_mark_l4((struct streaminfo *)top_stream, (const void *)buf, (const char *)buf+sizeof(struct mesa_ip6_hdr));
}
break;
case __ADDR_TYPE_IP_PAIR_V4:
- /* to do, ��������ѡ��İ�, ��ô����? */
+ /* to do, ��������ѡ��İ�, ��ô����? */
this_layer_len = sizeof(struct mesa_ip4_hdr);
buf -= sizeof(struct mesa_ip4_hdr);
build_net_layer_ipv4(stream_pr, carry_layer_type, carry_layer_len, buf, reverse, raw_pkt);
- /* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
+ /* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
checksum_for_carry_layer(buf, __ADDR_TYPE_IP_PAIR_V4, carry_layer_type, carry_layer_len);
carry_layer_type = __ADDR_TYPE_IP_PAIR_V4;
break;
@@ -2258,7 +2258,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
this_layer_len = calc_vlan_hdr_len(stream_pr, send_stream_dir);
if(0 == this_layer_len){
if(0 == stream_pr->need_update_opposite_addr){
- /* ���÷����ַ, ���¼��㳤��, ����vlan��ַ */
+ /* ���÷����ַ, ���¼��㳤��, ����vlan��ַ */
this_layer_len = calc_vlan_hdr_len(stream_pr, send_stream_dir ^ DIR_DOUBLE);
buf -= this_layer_len;
ret = build_net_layer_vlan(stream_pr, carry_layer_type, carry_layer_len, buf, send_stream_dir ^ DIR_DOUBLE, raw_pkt);
@@ -2286,8 +2286,8 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
case ADDR_TYPE_MAC:
{
buf -= sizeof(struct mesa_ethernet_hdr);
- /* ����Dz���ģʽ, �˴����Բ�����mac��ַ, ����֪packet_io_send_fake_pkt�����ײ�����, MAC����MAC_IN_MAC
- ����ģʽ��Ҫ���ݵ�ǰԭʼ��, ��send_dir����mac��ַ.
+ /* ����Dz���ģʽ, �˴����Բ�����mac��ַ, ����֪packet_io_send_fake_pkt�����ײ�����, MAC����MAC_IN_MAC
+ ����ģʽ��Ҫ���ݵ�ǰԭʼ��, ��send_dir����mac��ַ.
*/
unsigned short eth_type_host = net_layer_to_ethernet_protocol_by_stream(up_stream);
if((unsigned short)-1 == eth_type_host){
@@ -2302,13 +2302,13 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
this_layer_len = sizeof(struct mesa_ethernet_hdr);
carry_layer_type = ADDR_TYPE_MAC;
- //ethernet��һ�������һ��, ��Ϊ��MAC-in-MAC, �������ݹ�������ж�NULL == fstream_pr����.
+ //ethernet��һ�������һ��, ��Ϊ��MAC-in-MAC, �������ݹ�������ж�NULL == fstream_pr����.
//return carry_layer_len;
//sapp_runtime_log(RLOG_LV_DEBUG, "build_net_layer_pkt()-->ADDR_TYPE_MAC, buf start addr:%p, this_layer_len:%d\n", buf, this_layer_len);
}
break;
- /* TODO 2: GRE v1��callid, �ֱ�洢��C2S, S2C������������ݰ�, ����˫��RST��Ҫ��¼��һ�����ֵ */
+ /* TODO 2: GRE v1��callid, �ֱ�洢��C2S, S2C������������ݰ�, ����˫��RST��Ҫ��¼��һ�����ֵ */
case ADDR_TYPE_GRE:
this_layer_len = calc_gre_hdr_len(
(const struct mesa_gre_hdr *)((const char *)stream_pr->raw_pkt->raw_pkt_data + stream_pr->offset_to_raw_pkt_hdr));
@@ -2325,7 +2325,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
{
this_layer_len = calc_mpls_hdr_len(stream_pr, send_stream_dir);
if(0 == this_layer_len){
- /* �ǶԳ�MPLS, Ϊ�����������������һ��, ������ʵ�ʰ�ͷ */
+ /* �ǶԳ�MPLS, Ϊ�����������������һ��, ������ʵ�ʰ�ͷ */
sapp_runtime_log(RLOG_LV_DEBUG, "%s, build_net_layer_mpls() send streamdir:%d, skip fake mpls layer.\n", printaddr(&stream->addr, stream->threadnum), send_stream_dir);
carry_layer_stream = up_stream;
break;
@@ -2367,7 +2367,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
break;
case ADDR_TYPE_TCP:
- /* to do, ��������ѡ��İ�, ��ô����? */
+ /* to do, ��������ѡ��İ�, ��ô����? */
this_layer_len = sizeof(struct mesa_tcp_hdr);
buf -= sizeof(struct mesa_tcp_hdr);
build_net_layer_tcp(stream_pr, carry_layer_type, carry_layer_len, buf, reverse, raw_pkt);
@@ -2397,7 +2397,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
break;
case ADDR_TYPE_PPP:
- assert(0); /* PPTP������gre��ppp�ϲ�Ϊһ��, ���벻����ִ�е��˴� */
+ assert(0); /* PPTP������gre��ppp�ϲ�Ϊһ��, ���벻����ִ�е��˴� */
break;
case ADDR_TYPE_PPTP:
@@ -2419,7 +2419,7 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
buf -= ppp_hdr_len;
build_net_layer_ppp(stream_pr, carry_layer_type, carry_layer_len, buf, reverse, raw_pkt, ppp_hdr_len);
- /* ֱ��copy pppͷ������ */
+ /* ֱ��copy pppͷ������ */
memcpy(buf, (char *)raw_pkt->raw_pkt_data + stream_pr->offset_to_raw_pkt_hdr + gre_layer_len, ppp_hdr_len);
buf -= gre_layer_len;
@@ -2465,7 +2465,7 @@ static raw_pkt_t *update_raw_pkt(struct streaminfo_private *stream_pr, uchar snd
if (stream_pr->plugin_process_context != 0)
{
- /* �ڰ�����������, ����û�п���polling, do nothing */
+ /* �ڰ�����������, ����û�п���polling, do nothing */
*inject_dir_reverse = ((snd_dir == stream_pr->stream_public.routedir) ? 0 : 1);
inject_raw_pkt = (raw_pkt_t *)stream_pr->raw_pkt;
}
@@ -2491,8 +2491,8 @@ static raw_pkt_t *update_raw_pkt(struct streaminfo_private *stream_pr, uchar snd
*inject_dir_reverse = (((snd_dir & DIR_ROUTE_DOWN) == DIR_ROUTE_DOWN) ? 0 : 1);
}
else
- { /* ���˻�û�յ�����,ʹ�öԶ����ݰ����챾�˵İ�,����ijЩ�ǶԳ�Э��,��GRE, MPLS��,��������!
- reverse��Ҫ���� */
+ { /* ���˻�û�յ�����,ʹ�öԶ����ݰ����챾�˵İ�,����ijЩ�ǶԳ�Э��,��GRE, MPLS��,��������!
+ reverse��Ҫ���� */
inject_raw_pkt = (raw_pkt_t *)stream_pr->polling_inject_context->raw_pkt_up;
*inject_dir_reverse = (((snd_dir & DIR_ROUTE_DOWN) == DIR_ROUTE_DOWN) ? 1 : 0);
}
@@ -2505,8 +2505,8 @@ static raw_pkt_t *update_raw_pkt(struct streaminfo_private *stream_pr, uchar snd
*inject_dir_reverse = (((snd_dir & DIR_ROUTE_DOWN) == DIR_ROUTE_DOWN) ? 1 : 0);
}
else
- { /* ���˻�û�յ�����,ʹ�öԶ����ݰ����챾�˵İ�,����ijЩ�ǶԳ�Э��,��GRE, MPLS��,��������!
- reverse��Ҫ���� */
+ { /* ���˻�û�յ�����,ʹ�öԶ����ݰ����챾�˵İ�,����ijЩ�ǶԳ�Э��,��GRE, MPLS��,��������!
+ reverse��Ҫ���� */
inject_raw_pkt = (raw_pkt_t *)stream_pr->polling_inject_context->raw_pkt_down;
*inject_dir_reverse = (((snd_dir & DIR_ROUTE_DOWN) == DIR_ROUTE_DOWN) ? 0 : 1);
}
@@ -2546,12 +2546,12 @@ static raw_pkt_t *update_raw_pkt(struct streaminfo_private *stream_pr, uchar snd
/*
LiJia note, 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, �����ǵ�ǰ����ԭʼ��.
*/
int MESA_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt)
@@ -2572,11 +2572,11 @@ int MESA_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt)
rst_paras.signature_seed2 = sapp_global_val->config.stream.tcp.inject.rst_signature_seed2;
ret1 = MESA_rst_tcp(stream, &rst_paras, sizeof(struct rst_tcp_para));
- /* �˴������Ƿ�������, �������ҲҪ����, ij��������ɹ�Ҳ�ǿ��Բ���ʵ��Ч���� */
+ /* �˴������Ƿ�������, �������ҲҪ����, ij��������ɹ�Ҳ�ǿ��Բ���ʵ��Ч���� */
rst_paras.dir = stream->curdir ^ DIR_DOUBLE;
ret2 = MESA_rst_tcp(stream, &rst_paras, sizeof(struct rst_tcp_para));
- /* �����µı�־λ, kill_tcp�Զ�����, ���ֹ��ܸ�֮ǰһ�� */
+ /* �����µı�־λ, kill_tcp�Զ�����, ���ֹ��ܸ�֮ǰһ�� */
stream_pr->stream_killed_flag = 1;
struct tcpdetail_private *pdetail_pr=(struct tcpdetail_private*)(stream->pdetail);
@@ -2678,7 +2678,7 @@ int __MESA_rst_tcp(struct streaminfo *stream, unsigned char rst_th_flags, int rs
rst_pkt_len = sizeof(struct mesa_ip4_hdr) + sizeof(struct mesa_tcp_hdr);
build_net_layer_tcp(stream_pr, stream->addr.addrtype, 0, rst_pkt_buf+sizeof(struct mesa_ip4_hdr), 0, raw_pkt);
build_net_layer_ipv4(stream_pr, ADDR_TYPE_TCP, sizeof(struct mesa_tcp_hdr), rst_pkt_buf, 0, raw_pkt);
- /* ʹ��SIO_EXCLUDE_THIS_LAYER_HDR����, ��Ҫ���м���У��� */
+ /* ʹ��SIO_EXCLUDE_THIS_LAYER_HDR����, ��Ҫ���м���У��� */
checksum_for_carry_layer(rst_pkt_buf, __ADDR_TYPE_IP_PAIR_V4, ADDR_TYPE_TCP, sizeof(struct mesa_tcp_hdr));
}else{
rst_pkt_len = sizeof(struct mesa_ip6_hdr) + sizeof(struct mesa_tcp_hdr);
@@ -2693,8 +2693,8 @@ int __MESA_rst_tcp(struct streaminfo *stream, unsigned char rst_th_flags, int rs
}
local_sys_stat->count[SAPP_STAT_SND_TCP_RST]++;
}
- /* ������˫�򷢰�, �������ﲻ��else if */
- if((DIR_DOUBLE == snd_rst_dir) || ((stream->curdir ^ snd_rst_dir) & 0x3) == DIR_DOUBLE){ /* ���򷢰� */
+ /* ������˫�򷢰�, �������ﲻ��else if */
+ if((DIR_DOUBLE == snd_rst_dir) || ((stream->curdir ^ snd_rst_dir) & 0x3) == DIR_DOUBLE){ /* ���򷢰� */
if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
rst_pkt_len = sizeof(struct mesa_ip4_hdr) + sizeof(struct mesa_tcp_hdr);
build_net_layer_tcp(stream_pr, stream->addr.addrtype, 0, rst_pkt_buf+sizeof(struct mesa_ip4_hdr), 1, raw_pkt);
@@ -2789,8 +2789,8 @@ inline int MESA_inject_pkt(struct streaminfo *stream, const char *payload, int p
/*
TODO:
- ���ж���һ���Dz���asymmetric_presence_layer,
- Ȼ�����жϱ����ַ��û��.
+ ���ж���һ���Dz���asymmetric_presence_layer,
+ Ȼ�����жϱ����ַ��û��.
*/
static int skip_asymmetric_presence_layer(const struct streaminfo *stream, UCHAR send_stream_dir)
{
@@ -2802,17 +2802,17 @@ static int skip_asymmetric_presence_layer(const struct streaminfo *stream, UCHAR
{
const struct layer_addr_vlan *vaddr = stream->addr.vlan;
- /* ��������������������ղ�, ���п����ǵ�����, ��Ҫ��ʵ����û�е�ַ */
+ /* ��������������������ղ�, ���п����ǵ�����, ��Ҫ��ʵ����û�е�ַ */
if(DIR_C2S == send_stream_dir){
if(0 == vaddr->c2s_layer_num){
- /* �������û�е�ַ, ���Ƿ�ǿ��Ҫ��ǶԳ�ԭ��, �����, ��ʵ���߲�������,�����ʱ��ʧ����; ������ǿ��Ը��öԲ��ַ */
+ /* �������û�е�ַ, ���Ƿ�ǿ��Ҫ��ǶԳ�ԭ��, �����, ��ʵ���߲�������,�����ʱ��ʧ����; ������ǿ��Ը��öԲ��ַ */
if(g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_VLAN][stream_pr->layer_index] != 0){
need_skip = 1;
}
}
}else{
if(0 == vaddr->s2c_layer_num){
- /* �������û�е�ַ, ���Ƿ�ǿ��Ҫ��ǶԳ�ԭ��, �����, ��ʵ���߲�������,�����ʱ��ʧ����; ������ǿ��Ը��öԲ��ַ */
+ /* �������û�е�ַ, ���Ƿ�ǿ��Ҫ��ǶԳ�ԭ��, �����, ��ʵ���߲�������,�����ʱ��ʧ����; ������ǿ��Ը��öԲ��ַ */
if(g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_VLAN][stream_pr->layer_index] != 0){
need_skip = 1;
}
@@ -2827,7 +2827,7 @@ static int skip_asymmetric_presence_layer(const struct streaminfo *stream, UCHAR
if(DIR_C2S == send_stream_dir){
if(0 == maddr->c2s_layer_num){
- /* �������û�е�ַ, ���Ƿ�ǿ��Ҫ��ǶԳ�ԭ��, �����, ��ʵ���߲�������,�����ʱ��ʧ����; ������ǿ��Ը��öԲ��ַ */
+ /* �������û�е�ַ, ���Ƿ�ǿ��Ҫ��ǶԳ�ԭ��, �����, ��ʵ���߲�������,�����ʱ��ʧ����; ������ǿ��Ը��öԲ��ַ */
if(g_asymmetric_addr_layer_set.layer_type_index[ADDR_TYPE_MPLS][stream_pr->layer_index] != 0){
need_skip = 1;
}
@@ -2862,7 +2862,7 @@ static int get_eth_carry_layer_type(struct streaminfo *stream, UCHAR send_stream
((ADDR_TYPE_MAC_IN_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype) ||
(ADDR_TYPE_MAC == stream_pr->pfather_pr->stream_public.addr.addrtype)))
{
- /* ��¼MAC��֮�ϵ�Э���ַ����, �������Ethernet->type�ֶ�, ����MAC-in-MAC��inner_eth, ��¼�ϲ�Э������
+ /* ��¼MAC��֮�ϵ�Э���ַ����, �������Ethernet->type�ֶ�, ����MAC-in-MAC��inner_eth, ��¼�ϲ�Э������
*/
ret = (int)stream->addr.addrtype;
}
@@ -2870,7 +2870,7 @@ static int get_eth_carry_layer_type(struct streaminfo *stream, UCHAR send_stream
else
{
/* to do:
- ����������Զ�������ethernet��, ����������vlan�Ȳ���һ�Ҫ������ô��?
+ ����������Զ�������ethernet��, ����������vlan�Ȳ���һ�Ҫ������ô��?
*/
}
@@ -2883,27 +2883,62 @@ static int get_eth_carry_layer_type(struct streaminfo *stream, UCHAR send_stream
int __sapp_inject_ctrl_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const void *payload, int payload_len, unsigned char snd_routedir)
{
- if(dir_check(snd_routedir) < 0){
+ sapp_gval_mthread_sys_stat_t *local_sys_stat=&sapp_global_val->mthread_volatile[stream->threadnum]->sys_stat;
+ if(dir_check(snd_routedir) < 0 || stream == NULL || payload == NULL || payload_len <=0){
+ local_sys_stat->count[SAPP_STAT_SND_ERROR]++;
+ sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_ctrl_pkt() error, dir_check < 0 or payload_len illgel!");
return -1;
}
- int snd_routedir_reverse;
struct streaminfo_private *raw_stream_pr = (struct streaminfo_private *)stream;
- const raw_pkt_t *raw_pkt = update_raw_pkt(raw_stream_pr, snd_routedir, &snd_routedir_reverse);
- if(NULL == raw_pkt){
- sapp_runtime_log(RLOG_LV_INFO, "__sapp_inject_ctrl_pkt() error, not found raw_pkt!");
- return -1;
- }
+ //raw_pkt_t *raw_pkt = update_raw_pkt(raw_stream_pr, snd_routedir, &snd_routedir_reverse);
+ raw_pkt_t *raw_pkt=(raw_pkt_t *)raw_stream_pr->raw_pkt;
+ if(NULL == raw_pkt)
+ {
+
+ if (raw_stream_pr->polling_inject_context == NULL ||
+ (raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_C2S-1] == NULL &&
+ raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_S2C-1] == NULL))
+ {
+ local_sys_stat->count[SAPP_STAT_SND_ERROR]++;
+ sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_ctrl_pkt() error, not found raw_pkt!");
+ return -1;
+ }
+
+ if(snd_routedir==raw_stream_pr->stream_c2s_route_dir)
+ {
+ if(raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_C2S-1])
+ raw_pkt=(raw_pkt_t *)raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_C2S-1];
+ else
+ {
+ raw_pkt=(raw_pkt_t *)raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_S2C-1];
+ snd_routedir^=1;
+ }
+ }
+ else
+ {
+ if(raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_S2C-1])
+ raw_pkt=(raw_pkt_t *)raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_S2C-1];
+ else
+ {
+ raw_pkt=(raw_pkt_t *)raw_stream_pr->polling_inject_context->raw_pkt_stream_dir[DIR_C2S-1];
+ snd_routedir^=1;
+ };
+ }
+ }
+ raw_pkt->meta_route_dir[raw_stream_pr->stream_c2s_route_dir]=raw_stream_pr->polling_inject_context->meta_stream_dir[DIR_C2S-1];
+ raw_pkt->meta_route_dir[raw_stream_pr->stream_c2s_route_dir^1]=raw_stream_pr->polling_inject_context->meta_stream_dir[DIR_S2C-1];
+
if(raw_stream_pr->sid_prepend_list != NULL)
{
- ((raw_pkt_t *)raw_pkt)->prepend_list=raw_stream_pr->sid_prepend_list;
+ raw_pkt->prepend_list=raw_stream_pr->sid_prepend_list;
}
if(raw_stream_pr->sid_append_list != NULL)
{
- ((raw_pkt_t *)raw_pkt)->append_list=raw_stream_pr->sid_append_list;
+ raw_pkt->append_list=raw_stream_pr->sid_append_list;
}
if (raw_stream_pr->stream_trace_id != 0)
{
- ((raw_pkt_t *)raw_pkt)->stream_trace_id = raw_stream_pr->stream_trace_id;
+ raw_pkt->stream_trace_id = raw_stream_pr->stream_trace_id;
}
int low_net_layer_type = get_eth_carry_layer_type(stream, stream->curdir);
@@ -2913,6 +2948,7 @@ int __sapp_inject_ctrl_pkt(struct streaminfo *stream, enum sapp_inject_opt sio,
{
if(raw_pkt->raw_pkt_len < raw_pkt_l2_l3_hdr_len + (int)sizeof(struct mesa_tcp_hdr))
{
+ local_sys_stat->count[SAPP_STAT_SND_ERROR]++;
sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_ctrl_pkt() error! raw_pkt_len:%d < raw_pkt_l3_hdr_len:%d+tcphdr_len:d\n",
raw_pkt->raw_pkt_len, raw_pkt_l2_l3_hdr_len, (int)sizeof(struct mesa_tcp_hdr));
return -1;
@@ -2926,6 +2962,7 @@ int __sapp_inject_ctrl_pkt(struct streaminfo *stream, enum sapp_inject_opt sio,
}
else
{
+ local_sys_stat->count[SAPP_STAT_SND_ERROR]++;
sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_ctrl_pkt() error! not support stream_type:%d.\n",
stream->type);
return -1;
@@ -2933,13 +2970,15 @@ int __sapp_inject_ctrl_pkt(struct streaminfo *stream, enum sapp_inject_opt sio,
if(raw_pkt->overlay_layer_bytes + raw_pkt_l2_l3_hdr_len + raw_pkt_l4_hdr_len > raw_pkt->raw_pkt_len)
{
- sapp_runtime_log(RLOG_LV_INFO, "__sapp_inject_ctrl_pkt() error! overlay_len:%d, l3_hdr_len:%d + l4_hdr_len:%d > raw_pkt_len:%d.\n",
+ local_sys_stat->count[SAPP_STAT_SND_ERROR]++;
+ sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_ctrl_pkt() error! overlay_len:%d, l3_hdr_len:%d + l4_hdr_len:%d > raw_pkt_len:%d.\n",
raw_pkt->overlay_layer_bytes, raw_pkt_l2_l3_hdr_len, raw_pkt_l2_l3_hdr_len, raw_pkt->raw_pkt_len);
return -1;
}
if (payload_len + raw_pkt_l2_l3_hdr_len + raw_pkt_l4_hdr_len > MTU_MAX)
{
- sapp_runtime_log(RLOG_LV_INFO, "__sapp_inject_ctrl_pkt() error! payload_len too long:%d.\n",
+ local_sys_stat->count[SAPP_STAT_SND_ERROR]++;
+ sapp_runtime_log(RLOG_LV_FATAL, "__sapp_inject_ctrl_pkt() error! payload_len too long:%d.\n",
payload_len + raw_pkt_l2_l3_hdr_len);
return -1;
}
@@ -2955,12 +2994,20 @@ int __sapp_inject_ctrl_pkt(struct streaminfo *stream, enum sapp_inject_opt sio,
low_net_layer_type, snd_routedir, stream->threadnum,
(char *)KILL_TCP_PHONY_POINTER, (int *)KILL_TCP_PHONY_POINTER,
raw_pkt);
- ((raw_pkt_t *)raw_pkt)->is_ctrl_pkt=0;
- ((raw_pkt_t *)raw_pkt)->payload_len=raw_payload_len;
if(ret < 0)
{
+ send_handle->tot_send_err++;
sapp_runtime_log(RLOG_LV_FATAL, "packet_io_send() ret < 0, stream_type:%d, addrtype:%d\n", stream->type, stream->addr.addrtype);
}
+ else
+ {
+ send_handle->tot_send_pkt++;
+ send_handle->tot_send_byte += payload_len;
+ local_sys_stat->count[SAPP_STAT_SND_CTRL]++;
+ local_sys_stat->length[SAPP_STAT_SND_CTRL]+= raw_pkt->raw_pkt_len;
+ }
+ ((raw_pkt_t *)raw_pkt)->is_ctrl_pkt=0;
+ ((raw_pkt_t *)raw_pkt)->payload_len=raw_payload_len;
packet_io_free_sendbuf(SEND_TYPE_LINK_INJECT, stream->threadnum);
return ret;
}
@@ -2996,11 +3043,11 @@ int __sapp_inject_pkt(struct streaminfo *raw_stream, enum sapp_inject_opt sio,
local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
if ((SIO_EXCLUDE_THIS_LAYER_HDR & sio) != 0)
{
- /* ������ǰ�� */
+ /* ������ǰ�� */
inject_stream = raw_stream->pfather;
inject_stream_pr = (struct streaminfo_private *)inject_stream;
- /* ����������ʱָ����SIO_EXCLUDE_THIS_LAYER_HDR, ˵���ڲ���Ԫ�����ɲ�������, ����kni,
- һ�㲻�����ߵ�build_pkt�ĺ�����, �˴���Ҫ����ip��������bloom filter */
+ /* ����������ʱָ����SIO_EXCLUDE_THIS_LAYER_HDR, ˵���ڲ���Ԫ�����ɲ�������, ����kni,
+ һ�㲻�����ߵ�build_pkt�ĺ�����, �˴���Ҫ����ip��������bloom filter */
if (sapp_global_val->config.packet_io.dup_pkt_para.dup_pkt_distinguish_all_inject != 0)
{
const struct mesa_ip4_hdr *ip4hdr;
@@ -3022,15 +3069,15 @@ int __sapp_inject_pkt(struct streaminfo *raw_stream, enum sapp_inject_opt sio,
{
/*
2021-09-18 fix bug:
- ԭ����Ipv4����build-args, ԭ������ipv4��tcp��ͷ����ָ��,
- ��Ϊipv6Ҳ�� build_args,
- ������build_net_layer_tcp()ʱ�ж�build_tcp_args��NULL, ��ʹ��������, �����Ͳ�����!!
+ ԭ����Ipv4����build-args, ԭ������ipv4��tcp��ͷ����ָ��,
+ ��Ϊipv6Ҳ�� build_args,
+ ������build_net_layer_tcp()ʱ�ж�build_tcp_args��NULL, ��ʹ��������, �����Ͳ�����!!
*/
set_build_layer_tcp_args(thread_num, TH_PUSH | TH_ACK, MESA_rand_range(1000, 1460), 0);
}
raw_stream_pr = (struct streaminfo_private *)raw_stream;
- /* ��ı���ijЩ�ص�������ԭʼ������ΪIP��ͷ, ���Բ���Ҫ�������ԭʼ��, ��Ϣ���洢��˽�����ṹ���� */
+ /* ��ı���ijЩ�ص�������ԭʼ������ΪIP��ͷ, ���Բ���Ҫ�������ԭʼ��, ��Ϣ���洢��˽�����ṹ���� */
raw_pkt = update_raw_pkt(raw_stream_pr, snd_routedir, &snd_routedir_reverse);
if(NULL == raw_pkt){
sapp_global_val->mthread_volatile[thread_num]->sys_stat.count[SAPP_STAT_SND_ERROR]++;
@@ -3061,9 +3108,9 @@ int __sapp_inject_pkt(struct streaminfo *raw_stream, enum sapp_inject_opt sio,
{
((raw_pkt_t *)raw_pkt)->stream_trace_id = raw_stream_pr->stream_trace_id;
}
- /* injectʹ�õ���routedir, �˴�ת����stream dir,
- ע��: ��������Ķ������ܲ����ɵ�ǰ��������, ����kni, �Ǵ����������յ����ݰ�, ��ע����·��,
- ���ܴ�raw_pkt��raw_stream->routedir�жϷ���!!!!
+ /* injectʹ�õ���routedir, �˴�ת����stream dir,
+ ע��: ��������Ķ������ܲ����ɵ�ǰ��������, ����kni, �Ǵ����������յ����ݰ�, ��ע����·��,
+ ���ܴ�raw_pkt��raw_stream->routedir�жϷ���!!!!
*/
if(snd_routedir == raw_stream_pr->stream_c2s_route_dir){
send_stream_dir = DIR_C2S;
@@ -3167,7 +3214,7 @@ static int send_handle_init(int tot_thread_num)
int i, ret;
int max_thread_num;
const sapp_config_packet_io_t *pcfg_io = &sapp_global_val->config.packet_io;
-#if 0 /* 2018 lijia modify , ���Ӳ���������߳������������� */
+#if 0 /* 2018 lijia modify , ���Ӳ���������߳������������� */
for(i = 0; i < tot_thread_num; i++){
#else
@@ -3199,7 +3246,7 @@ static int send_handle_init(int tot_thread_num)
struct sockaddr_in listen_addr;
memset(&listen_addr, 0, sizeof(listen_addr));
listen_addr.sin_family = AF_INET;
- listen_addr.sin_port = htons((unsigned short)sapp_global_val->config.packet_io.inject_mode_inline_device_sport); /* ���������ļ���дvxlanԴ�˿� */
+ listen_addr.sin_port = htons((unsigned short)sapp_global_val->config.packet_io.inject_mode_inline_device_sport); /* ���������ļ���дvxlanԴ�˿� */
if(bind(g_send_handle[i].raw_udp_fd, (struct sockaddr *) &listen_addr, sizeof(listen_addr)) != 0){
sapp_log(30, ~0, ~0, "socket bind udp port '%u' error", sapp_global_val->config.packet_io.inject_mode_inline_device_sport);
return -1;
@@ -3256,7 +3303,7 @@ void send_handle_destroy(int thread_index)
}
-/* 2015-01-04 lijia add, ��pappƽ̨Ǩ�Ƶ�sappƽ̨, �ײ㷢���ӿڲ�ͬ */
+/* 2015-01-04 lijia add, ��pappƽ̨Ǩ�Ƶ�sappƽ̨, �ײ㷢���ӿڲ�ͬ */
int MESA_sendpacket_ethlayer(int thread_num,const char *data, int data_len, unsigned int target_id)
{
int ret;
@@ -3289,7 +3336,7 @@ int sendpacket_init_new(int tot_thread_num)
/* to do, TODO 1,
//get_gateway_info();
- ����һ���߳�, ��̬��ȡĬ�����ص�MAC��ַ, ����Ŀ�������IPv4��ַ����������IP,����arp����,
+ ����һ���߳�, ��̬��ȡĬ�����ص�MAC��ַ, ����Ŀ�������IPv4��ַ����������IP,����arp����,
pthread_create(sendpacket_keepalive_with_gateway);
*/
@@ -3332,10 +3379,10 @@ void sendpacket_destroy(int tot_thread_num)
/***************************************************************************************
NOTE:
- MESA_sendpacket_xxx��MESA_fakepacket_send_xxxϵ�к�����, dir��sapp�е�routedir���岻ͬ,
- pappƽ̨�е�dirʹ�����λbit��ʾ����, ������Ϊ0x00, ����Ϊ0x80,
- ��sapp�е�routedir�����λ��ʾ����, ������Ϊ0x00, ����Ϊ0x01.
- Ϊ��ͬʱ���ݴ�����ƽ̨�Ͳ��, ����MESA_dir_reverse()����, ���ڷ��򷢰�.
+ MESA_sendpacket_xxx��MESA_fakepacket_send_xxxϵ�к�����, dir��sapp�е�routedir���岻ͬ,
+ pappƽ̨�е�dirʹ�����λbit��ʾ����, ������Ϊ0x00, ����Ϊ0x80,
+ ��sapp�е�routedir�����λ��ʾ����, ������Ϊ0x00, ����Ϊ0x01.
+ Ϊ��ͬʱ���ݴ�����ƽ̨�Ͳ��, ����MESA_dir_reverse()����, ���ڷ��򷢰�.
****************************************************************************************/
unsigned char MESA_dir_reverse(unsigned char raw_dir)
{
@@ -3365,14 +3412,14 @@ unsigned char MESA_dir_reverse(unsigned char raw_dir)
/***************************************************************************************
NOTE:
- �ڱ���ģʽ��, ����������route_dir�ľ���ֵ, ֻ��Ҫ����ͬ��ͷ��򼴿�,
- ��������������Ҫ��ȷ����route_dir��0����1, �������������ģʽ��ͬ, ������ʱ��仯,
- �������ô˽ӿ�, ���ֻ�贫����������ķ���, ���ص�ǰ��·��link route dir,
- ע��etc/sapp.toml inbound_route_dirҪ������ȷ.
+ �ڱ���ģʽ��, ����������route_dir�ľ���ֵ, ֻ��Ҫ����ͬ��ͷ��򼴿�,
+ ��������������Ҫ��ȷ����route_dir��0����1, �������������ģʽ��ͬ, ������ʱ��仯,
+ �������ô˽ӿ�, ���ֻ�贫����������ķ���, ���ص�ǰ��·��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.
@@ -3403,12 +3450,12 @@ 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)
{
@@ -3439,7 +3486,7 @@ int MESA_dir_link_to_human(int link_route_dir)
static inline int dir_check(unsigned char raw_dir)
{
- if(raw_dir & DIR_BIT_UNUSE_MASK){ /* ����ֻʹ������ߺ����λbit, �����������ֵ,˵�������ת��dirʱ���˴��� */
+ if(raw_dir & DIR_BIT_UNUSE_MASK){ /* ����ֻʹ������ߺ����λbit, �����������ֵ,˵�������ת��dirʱ���˴��� */
sapp_runtime_log(30, "dir = 0x%x, is invalid, only the most or least significant bit can be used!", raw_dir);
//assert(0);
return -1;