diff options
| author | lijia <[email protected]> | 2024-11-19 10:10:51 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2024-11-20 18:54:08 +0800 |
| commit | 8d24a9cc945c2a6d0b0bfa447c7b4d1caec9397c (patch) | |
| tree | 98ab11fcdf4d9ce7497da687f5564666718ab0cb /include | |
| parent | 6dd815e9e42ed52130c136e671bd83a05aaa34fd (diff) | |
TSG-23816: support stream uuid_t id
Diffstat (limited to 'include')
| -rw-r--r-- | include/private/stream_internal.h | 116 | ||||
| -rw-r--r-- | include/public/stream_inc/stream_control.h | 745 |
2 files changed, 434 insertions, 427 deletions
diff --git a/include/private/stream_internal.h b/include/private/stream_internal.h index f68b518..044bc32 100644 --- a/include/private/stream_internal.h +++ b/include/private/stream_internal.h @@ -17,8 +17,8 @@ //#define STREAM_TUNNEL_MD5_CHECK "d20aa6b4f5683b7b0040676547997be0" #define IP_PORT_UNION_VERSION (1) /* �Ƿ�IP-PORT�ϲ� */ -#define COMPAT_PAPP_FOR_BENCHMARK (0) /* 2015-01-07 lijia add, ͬpapp�ԱȽ��ʱ, ��ʱ�ر�Ƕ�ס���������Э��, ����һ�� */ -#define USE_RBTREE_INSTEAD_LIST (0) /* ��HASH��ͻʱ, ʹ�ú������������, ������������±��� */ +#define COMPAT_PAPP_FOR_BENCHMARK (0) /* 2015-01-07 lijia add, ͬpapp�ԱȽ���?, ��ʱ�ر�Ƕ�ס���������Э��, ����һ�� */ +#define USE_RBTREE_INSTEAD_LIST (0) /* ��HASH��ͻʱ, ʹ�ú������������?, ������������±���? */ //#define USE_LINUX_KERNEL_HASH_ALGO (1) /* ʹ��LINUX�ں�HASH�㷨 */ #define SAPP_INSECTICIDE (0) /* ɱ��(DEBUG)��ʱ����, ������Ī�������BUGʱ��ʱ����, ���緢������, �����糬�� */ @@ -28,7 +28,7 @@ #define PCAP_CAP_FROM_IP (0) /* Ϊ��ģ��pag��������, ��pcapҲģ���IPv4ͷ����ʼ��ȡ */ -//#define NON_PKT_THREAD_SEND_QUEUE (64) /* �����������߳�����Ͷ������� */ +//#define NON_PKT_THREAD_SEND_QUEUE (64) /* �����������߳�����Ͷ�������? */ #define IKNOW_ENABLE (0) @@ -50,10 +50,13 @@ #define sapp_get_struct_header(ptr, type, member) container_of(ptr, type, member) -#define RAW_PKT_MAGIC_NUM (0xF1E2D3C4) /* 1:���ڼ��ݾ���Ŀ, ��call_old��������ݽṹʱ,ʶ��ԭʼ������Դ; 2:��ȫ�Լ�� */ +#define RAW_PKT_MAGIC_NUM (0xF1E2D3C4) /* 1:���ڼ��ݾ���Ŀ, ��call_old��������ݽṹ�?,ʶ��ԭʼ������Դ; 2:��ȫ�Լ��? */ #define SAPP_DESTROY_DONE_FLAG (0x7FFFFFFF) +#ifndef uuid_t +typedef unsigned char uuid_t[16]; +#endif #ifdef __cplusplus extern "C" { @@ -84,13 +87,13 @@ typedef struct { const void *__lib_raw_pkt_data; /* �ײ㲶�����ṩ����ʵԭʼ��ָ�� */ const void *raw_pkt_data; /* ���ϲ�Ӧ�ÿ���ԭʼ��ͷָ��, �п���������Ethernet��, ����low_layer_type�ж�Э������ */ - struct timeval raw_pkt_ts; /* ԭʼ������ʱ���, ���ȫΪ0��֧�ִ˹���(��pagģʽ) */ + struct timeval raw_pkt_ts; /* ԭʼ������ʱ���?, ���ȫ�?0��֧�ִ˹���(��pagģʽ) */ //2*8 Bytes - const void *io_lib_pkt_reference; /* ���õײ�I/O���ԭʼ�������ṹ, ����:����marsio��˵, ���ײ��mbuf�ṹ */ + const void *io_lib_pkt_reference; /* ���õײ�I/O���ԭʼ��������?, ����:����marsio��˵, ���ײ��mbuf�ṹ */ /* ---8 bytes-- */ int payload_len; /* ���س��� */ - int device_index;/* �ж������ʱ, Ҫ��֤���ĸ������ʹ��ĸ����� */ + int device_index;/* �ж�������?, Ҫ��֤���ĸ������ʹ��ĸ����� */ /* ===8 bytes=== */ /* ---8 bytes-- */ @@ -98,7 +101,7 @@ typedef struct { unsigned char is_overlay_pkt:1; /* ��ʾ����ʵ��·�е����ݰ�, Ҫ��������ע, ��������������һ������; ����Ҫ���� */ unsigned char is_ctrl_pkt:1; unsigned char diagnose_error_to_dump:1; /* ��ij�ִ������ݰ�, ����pkt_dump�洢��udp socket����tcpdump_mesa */ - unsigned char drop_current_pkt_flag:1; /* �������MSO_DROP_CURRENT_PKT���ö�����ǰ��, ÿ�δ�����Ҫ��� */ + unsigned char drop_current_pkt_flag:1; /* �������MSO_DROP_CURRENT_PKT���ö�����ǰ��, ÿ�δ�����Ҫ���? */ unsigned char mac_flipping_enable:1; unsigned char padding_flags:2; //1 Bytes @@ -151,8 +154,8 @@ struct buf_unorder unsigned char ip_reassemble_pkt; UINT32 seq; UINT32 ack; - raw_ipfrag_list_t *ipfrag_list; /* �����ǰ����IP��Ƭ����İ�, ��Ҫ�洢����IP��Ƭ������ */ - raw_pkt_t raw_pkt; /* ������洢ԭʼ�� */ + raw_ipfrag_list_t *ipfrag_list; /* �����ǰ����IP��Ƭ����İ�?, ��Ҫ�洢����IP��Ƭ������ */ + raw_pkt_t raw_pkt; /* ������洢ԭʼ��? */ }; /*�����ṹ�嶨�壺*/ @@ -160,13 +163,13 @@ struct half_tcpstream { UCHAR *data; UINT32 offset; /*data�е�һ���ֽ���TCP�������е�ƫ����*/ - UINT32 count; /*�����ӽ���������Ϊֹ������������ܳ����ֽ���*/ + UINT32 count; /*�����ӽ���������Ϊֹ������������ܳ����ֽ���?*/ UINT32 count_new; /*�����µ��������ֽ���*/ - UINT32 count_ideal; /*�����ӽ���������Ϊֹ��������Ӧ�õ���������ܳ���*/ - UINT32 pktcout; /*�����ۼƵ���İ�����, �����ش���, ACK, ������SYN */ + UINT32 count_ideal; /*�����ӽ���������Ϊֹ��������Ӧ�õ���������ܳ���?*/ + UINT32 pktcout; /*�����ۼƵ���İ�����?, �����ش���, ACK, ������SYN */ UINT32 totallost; /*�����ۼƶ�������*/ - UINT32 seq; /*���������ڴ���seq���*/ - UINT32 first_data_seq; /*����������ʼ�ĵ�seq���*/ + UINT32 seq; /*���������ڴ���seq���?*/ + UINT32 first_data_seq; /*����������ʼ�ĵ�seq���?*/ //UINT32 ack_seq; /*�����������ʹ�õ�Ӧ���, 2017-08-02 lijia modify , �ƶ���struct tcpdetail_private */ @@ -175,11 +178,11 @@ struct half_tcpstream UCHAR finstate; /*fin״̬*/ UINT16 unorder_cnt;/* 2014-11-27 lijia modify, ijЩ����������, UCHAR�Ͳ���, ��չΪUINT16 */ UINT16 maxunorder; /* 2014-11-27 lijia modify, ijЩ����������, UCHAR�Ͳ���, ��չΪUINT16 */ - struct buf_unorder *unorderlist; /*�����������*/ - struct buf_unorder *unorderlisttail; /*�����������β��ָ��*/ + struct buf_unorder *unorderlist; /*�����������?*/ + struct buf_unorder *unorderlisttail; /*�����������β��ָ��?*/ }; -/* ����ÿ�������������һ����, ����polling entry����ʹ�� */ +/* ����ÿ�������������һ����?, ����polling entry����ʹ�� */ typedef struct { const raw_pkt_t *raw_pkt_stream_dir[2]; struct rawpkt_metadata* meta_stream_dir[2];// ÿ������metadata��[0:c2s, 1:s2c]����洢��polling_inject_context��, update_raw_pkt��������ʱ����������䵽���ص�rawpkt�� @@ -187,32 +190,32 @@ typedef struct { struct streaminfo_private { - /* ����ṹ�����ڽṹ����ǰ, ָ���ַ���Ի���ǿת */ + /* ����ṹ�����ڽṹ�����?, ָ���ַ���Ի���ǿ�? */ struct streaminfo stream_public; - struct streaminfo_private *pfather_pr; /* ��ʵ�������ϲ���ָ��, ������vxlan�ȷ�װ��, stream_public.pfather�Ǹ�ҵ��������,������vxlan��� */ + struct streaminfo_private *pfather_pr; /* ��ʵ�������ϲ���ָ��, ������vxlan�ȷ�װ��, stream_public.pfather�Ǹ�ҵ��������,������vxlan���? */ /* ���±���Ϊƽ̨�ڲ�˽��, ���ⲻ�ɼ� */ void *cur_plugin_cb_func; void *pproject; //ÿ�����̿����Զ���ʹ�ã� /* ---8 bytes-- */ - UCHAR layer_dir:2; /* ������Ч, ��ǰ��ĵ�ַ�Ƿ��Ĭ�Ϲ���"��˿��ǿͻ���"��ͬ */ - UCHAR stream_dir:1; /* ��������������Ч, ���Ĵ洢�ĵ�ַ�Ƿ��Ĭ�Ϲ���"��˿��ǿͻ���"��ͬ */ - UCHAR stream_c2s_route_dir:1; /* c2s����İ�, ��Ӧ����·route dir����, ���ڻ�ȡinbound, outbound���� */ - UCHAR addr_use_as_hash:1; /* �����addr�Ƿ���ΪHASH����ͱȽϵIJ���, ��:MAC��ַ��������� */ + UCHAR layer_dir:2; /* ������Ч, ��ǰ��ĵ�ַ�Ƿ��Ĭ�Ϲ���"��˿��ǿͻ���?"��ͬ */ + UCHAR stream_dir:1; /* ��������������Ч, ���Ĵ洢�ĵ�ַ�Ƿ��Ĭ�Ϲ���?"��˿��ǿͻ���?"��ͬ */ + UCHAR stream_c2s_route_dir:1; /* c2s����İ�?, ��Ӧ����·route dir����, ���ڻ�ȡinbound, outbound���� */ + UCHAR addr_use_as_hash:1; /* �����addr�Ƿ���ΪHASH����ͱȽϵIJ���?, ��:MAC��ַ���������? */ UCHAR set_special_timeout:1; UCHAR need_update_opposite_addr:1;/*�����addr�Ƿ��ڶԲ�����ʱ���£��磺MPLS��ǩ�ǶԳ�ʱ��Ҫ��S2C���һ������¼�����ǩ,��ֵĬ��Ϊ0��������Ҫ����*/ UCHAR stream_killed_flag:1; /* 2014-08-22 lijia add, ����ģʽ��, �Ѿ������Kill, ֮�������ֱ��Drop��Kill, �����ٸ��ϲ��� */ - UCHAR dirreverse; /* ��������ʱ�Ƿ������ip��ַ��ת, ����"��˿��ǿͻ���"�����෴ */ - UINT16 timeout;/* ÿ�����ӵĶ��г�ʱʱ��, ��ֵ��������;, 1:���ھ�����̭��ʱ���ް��������, �Խ�Լ�ڴ�; 2:���ڱ�����ʱ���ް�����, ����IM�ʱ���ް������Ӳ�δ����, �����ýϴ��timeout */ - unsigned short offset_to_raw_pkt_hdr; /* ����ͷ�����ԭʼ������ʼ��ַ��ƫ���� */ + UCHAR dirreverse; /* ��������ʱ�Ƿ������ip��ַ��ת, ����"��˿��ǿͻ���?"�����෴ */ + UINT16 timeout;/* ÿ�����ӵĶ��г�ʱʱ��, ��ֵ��������;, 1:���ھ�����̭��ʱ���ް��������?, �Խ�Լ�ڴ�; 2:���ڱ�����ʱ���ް�����, ����IM�ʱ���ް������Ӳ�δ����, �����ýϴ��timeout */ + unsigned short offset_to_raw_pkt_hdr; /* ����ͷ�����ԭʼ������ʼ��ַ��ƫ����? */ unsigned short offset_to_ip_hdr; /* 2015-12-07 lijia add, UDP/TCP ��ͷ����ڳ��ص�IP��ͷƫ���� */ /* ===8 bytes=== */ const raw_pkt_t *raw_pkt; /* 2014-12-30 lijia add, ��Щ�ص�������֧��ԭʼ��, ����������Ҫ, �洢��private�ṹ�� */ /* ---8 bytes-- */ - unsigned int hash_slave; /* 2015-12-14 lijia add, ʹ��linux_jhash����ʱ, ����ͬʱ�õ��������ϵ�HASHֵ, ��HASH����ȷ����HASH����SLOTλ��, slave_HASH���ڿ��ٱȽϵ�ַ�Ƿ���� */ + unsigned int hash_slave; /* 2015-12-14 lijia add, ʹ��linux_jhash����ʱ, ����ͬʱ�õ��������ϵ�HASHֵ, ��HASH����ȷ����HASH����SLOTλ��, slave_HASH���ڿ��ٱȽϵ�ַ�Ƿ����? */ unsigned char hash_not_head_times;/* 2015-12-15 lijia add, ��ǰindex����HASH SLOT�ĵ�һλ�Ĵ��� */ - unsigned char cur_layer_raw_hdr_len; /* 2017-10-31 lijia add, ��ǰ���ԭʼ����ַ����, ��pppͷ��ѹ��, ԭ���汾���������״̬, ����ʱҲ����֪��ַ������ */ + unsigned char cur_layer_raw_hdr_len; /* 2017-10-31 lijia add, ��ǰ���ԭʼ����ַ����?, ��pppͷ��ѹ��, ԭ���汾���������״�?, ����ʱҲ����֪��ַ������ */ unsigned char __pad:1; unsigned char packet_process_context:1; unsigned char is_ctrl_pkt:1; @@ -222,8 +225,8 @@ struct streaminfo_private /* ===8 bytes=== */ /* ---8 bytes-- */ - unsigned short stream_low_layer_tunnel_type; /* 2016-07-25 lijia add, ��¼�����ײ���������, 0Ϊ������, �������:enum stream_carry_tunnel_t */ - unsigned short stream_carry_up_layer_tunnel_type; /* ��ǰ���ϲ����������, ���統ǰ��ΪUDP, ���صĿ�����teredo������L2TP���� */ + unsigned short stream_low_layer_tunnel_type; /* 2016-07-25 lijia add, ��¼�����ײ���������, 0Ϊ������, �������?:enum stream_carry_tunnel_t */ + unsigned short stream_carry_up_layer_tunnel_type; /* ��ǰ���ϲ����������?, ���統ǰ��ΪUDP, ���صĿ�����teredo������L2TP���� */ /* 2016-07-08 lijia add, for janus hijack, ��Ӧ�ô洢��half_stream, �����յ�SYNʱ, ��û�д���half_streamʵ��, �����ݴ���streaminfo_private */ unsigned short syn_opt_num; unsigned short synack_opt_num; @@ -247,10 +250,10 @@ struct streaminfo_private unsigned long long stream_create_timestamp_ms; unsigned long long stream_lastupdate_timestamp_ms; /* ---8 bytes-- */ - unsigned char layer_index:4; /* ��ʾ��ǰ��ļ���, ����ײ㿪ʼ,һ����ethernet��ʼ, ��0��ʼ����, 4bit���֧��15��Ƕ��, Ҳ�ܷ�ֹ����Ƕ����(Ŀǰ��û��������) */ - unsigned char create_dir_by_well_known_port:1; /* UDP��TCP��data������, ����well_known_port����, �����ǰ���˿��ǿͻ���ԭ���� */ + unsigned char layer_index:4; /* ��ʾ��ǰ��ļ���?, ����ײ㿪�?,һ����ethernet��ʼ, ��0��ʼ����, 4bit���֧��?15��Ƕ��, Ҳ�ܷ�ֹ����Ƕ����(Ŀǰ��û��������) */ + unsigned char create_dir_by_well_known_port:1; /* UDP��TCP��data������, ����well_known_port����, �����ǰ���˿��ǿͻ���ԭ����? */ char __pad2:3; - char has_duplicate_pkt; /* ��ǰ�������й��ظ����ݰ�, ����������Ӧ��ÿ������� */ + char has_duplicate_pkt; /* ��ǰ�������й��ظ����ݰ�, ����������Ӧ��ÿ�������? */ char under_ddos_bypass; char __pad3[3]; /* ===8 bytes=== */ @@ -258,11 +261,12 @@ struct streaminfo_private unsigned char ip_ttl_c2s; unsigned char ip_ttl_s2c; void *stream_bridge; /* 20210425 lijia add, ����project����, ֧��ͬ�����첽����ģʽ, ԭ��project�����첽ģʽ */ + uuid_t stream_uuid; }; struct tcpdetail_private { - /* ����ṹ�����ڽṹ����ǰ, ָ���ַ���Ի���ǿת */ + /* ����ṹ�����ڽṹ�����?, ָ���ַ���Ի���ǿ�? */ struct tcpdetail tcpdetail_public; /* ---8 bytes-- */ @@ -273,7 +277,7 @@ struct tcpdetail_private UCHAR needackflag:1; //��Ҫ�ϴ�ack���� UCHAR takeoverflag:1; UCHAR has_lost_pkt_flag:1; //2020-08-23 lijia add, ����������������־λ - UCHAR tcpstateflag; // ���ڼ�¼tcp�ĻỰSYN���״̬ + UCHAR tcpstateflag; // ���ڼ�¼tcp�ĻỰSYN���״�? UCHAR link_state; // ���ӵ�״̬ UCHAR creat_mod; UINT16 tcpoverlen; // modify by lqy 20150225, ��¼��ǰ������һ�������ص�tcp���ȣ� @@ -288,18 +292,18 @@ struct tcpdetail_private UINT32 iclientseq; //���ӽ���ʱ��ʱ�洢seq, ��ֵ��S2C->SYN+1 /* NOTE: Ϊ��first_ack_seq������half_tcpstream��? - ��half_tcpstream�����յ���һ�����и��صİ��ŷ����, + ��half_tcpstream�����յ���һ�����и��صİ��ŷ����?, �����tcp_deal_ack()����������, �����S2C����, ��ô��һ��S2C���ݰ�����ʱ, �Ѿ�����first_ack_seq��. �����Է�ֹDDOS����. */ - UINT32 C2S_first_ack_seq; /* 2017-08-02 lijia modify, C2S���һ��ACK��, ��half_tcpstream->ack_seqһ����Լ�����������Բ���������� */ + UINT32 C2S_first_ack_seq; /* 2017-08-02 lijia modify, C2S���һ��ACK��, ��half_tcpstream->ack_seqһ����Լ�����������Բ����������? */ UINT32 C2S_ack_seq; /* 2017-08-02 lijia add, C2S�൱ǰ��ACK�� */ - UINT32 S2C_first_ack_seq; /* 2017-08-02 lijia modify, C2S���һ��ACK��, ��half_tcpstream->ack_seqһ����Լ�����������Բ���������� */ + UINT32 S2C_first_ack_seq; /* 2017-08-02 lijia modify, C2S���һ��ACK��, ��half_tcpstream->ack_seqһ����Լ�����������Բ����������? */ UINT32 S2C_ack_seq; /* 2017-08-02 lijia add, S2C�൱ǰ��ACK�� */ void *apme; //Ӧ�ò������� void *pAllpktpme; //��״̬��tcp���������� - struct tcp_flow_stat *flow_stat; /* 2016-07-14 lijia add, ���ڼ�¼TCP��data���ļ���, ʵ���ڴ������ͷ���projectģ�����, ����ΪNULL, */ - struct tcp_flow_stat *deduce_flow_stat; /* 2018-10-30 lijia add, ���ڼ�¼������ƶϳ������ϴ��������, ���������ij���; �Լ������������, �Զ�Ӧ���յ������� */ + struct tcp_flow_stat *flow_stat; /* 2016-07-14 lijia add, ���ڼ�¼TCP��data���ļ���, ʵ���ڴ������ͷ���projectģ�����?, ����ΪNULL, */ + struct tcp_flow_stat *deduce_flow_stat; /* 2018-10-30 lijia add, ���ڼ�¼������ƶϳ������ϴ��������, ���������ij���; �Լ������������?, �Զ�Ӧ���յ������� */ unsigned short rtt_csc; unsigned short rtt_scs; long long last_c2s_pkt_rcv_time; @@ -308,10 +312,10 @@ struct tcpdetail_private struct udpdetail_private { - /* ����ṹ�����ڽṹ����ǰ, ָ���ַ���Ի���ǿת */ + /* ����ṹ�����ڽṹ�����?, ָ���ַ���Ի���ǿ�? */ struct udpdetail udpdetail_public; void *apme; //Ӧ�ò������� - struct udp_flow_stat *flow_stat; /* 2015-12-28 lijia add, udpdetail�е���ϸ����(64bit), ʵ���ڴ������ͷ���projectģ�����, ����ΪNULL */ + struct udp_flow_stat *flow_stat; /* 2015-12-28 lijia add, udpdetail�е���ϸ����(64bit), ʵ���ڴ������ͷ���projectģ�����?, ����ΪNULL */ UCHAR drop_stream_flag; //2020-06-02 lijia add, ����ͬDROPPKT, ֻ����������������stream UCHAR offload_stream_flag; //2022-04-13 liuxueli add, ������������stream UCHAR pad[6]; @@ -321,7 +325,7 @@ struct udpdetail_private /* 2015-02-26 lijia add, for stream-addr-list ntop, pton */ typedef struct{ struct streaminfo stream; - char addr_value[MAX_ADDR_BIN_VALUE_LEN]; /* Ϊ��paddr������malloc, �������, ��stream������һ�黺�� */ + char addr_value[MAX_ADDR_BIN_VALUE_LEN]; /* Ϊ��paddr������malloc, �������?, ��stream������һ�黺�� */ }addr_continuous_bin_t; typedef struct{ @@ -340,15 +344,15 @@ struct pptp_stream_key{ UINT32 dip; /* sip,dip are network order */ UINT16 sip_side_call_id; /* �������ݰ�����sip������GRE����callid, ʵ�������ʾpeer call id, network order */ UINT16 dip_side_call_id; /* �������ݰ�����dip������GRE����callid, ʵ�������ʾpeer call id, network order */ - //struct streaminfo_private *stream_pr; /* TODO 1, ���ڱ����ַ����, Ŀǰ��������ײ��IP��call_id */ + //struct streaminfo_private *stream_pr; /* TODO 1, ���ڱ����ַ����?, Ŀǰ��������ײ��IP��call_id */ }; /* PPTPЭ�����������ṹ, sapp�ڲ�ʹ�� */ struct pptp_info_pri{ struct MESA_tunnel_info tunnel_context; struct pptp_stream_key pptp_key; - stSessionInfo ssinfo; /* ����ҵ�����������Ϣ */ - void *biz_pme; /* ҵ����Զ������� */ + stSessionInfo ssinfo; /* ����ҵ������������? */ + void *biz_pme; /* ҵ����Զ�������? */ struct streaminfo *my_stream; /* pptp�ײ�UDP�� */ unsigned char threadnum; char insert_hash_flag; /* ���������ѽ�key����HASH�� */ @@ -370,13 +374,13 @@ struct l2tp_stream_key{ UINT16 sip_side_session_id; /* sip�ⷢ������tunnelid, network order */ UINT16 dip_side_tunnel_id; /* dip�ⷢ������tunnelid, network order */ UINT16 dip_side_session_id; /* dip�ⷢ������tunnelid, network order */ - //struct streaminfo_private *stream_pr; /* TODO 1, ���ڱ����ַ����, Ŀǰ��������ײ��IP��call_id */ + //struct streaminfo_private *stream_pr; /* TODO 1, ���ڱ����ַ����?, Ŀǰ��������ײ��IP��call_id */ }; struct l2tp_info_pri{ struct MESA_tunnel_info tunnel_context; struct l2tp_stream_key l2tp_key; - stSessionInfo ssinfo; /* ����ҵ��������� */ + stSessionInfo ssinfo; /* ����ҵ���������? */ void *biz_pme; const struct streaminfo *my_stream; /* l2tp�ײ�UDP�� */ unsigned char thread_seq; @@ -386,13 +390,13 @@ struct l2tp_info_pri{ #define STATSD_SEND_MSS (1472) /* ȫ��Ψһ��ȫ�ֱ���, ͨ���ǿ�����������, ���仯��ȫ�ֱ���, ����������, ������ֻ�� */ struct sapp_global_single_t{ - int signal_take_over_sw; /* �Ƿ�ӹܳ���ϵͳ�ź�, ��SIGSEGV, SIGABRT�ȵ� */ + int signal_take_over_sw; /* �Ƿ�ӹܳ���ϵͳ�ź�?, ��SIGSEGV, SIGABRT�ȵ� */ int ipentry_priority_over_ipfrag; /* IP_entry���ȼ�����IP_frag_entry, Ĭ��Ϊ0, ��ӦWY�����ض����� */ //int kill_tcp_with_gdev; /* FDδ��Чʱ, ����gdev�������� */ int cfg_send_tcp_offload_sw; /* ��������MTUʱ, ������Ƭ�ɶ��С��MTU�İ����� */ //int cfg_kill_tcp_rst_num; /* kill_tcp����rst������ */ //int cfg_kill_tcp_rst_signature; /* kill_tcp���͵�rst�Ƿ���Ҫָ����Ϣ, ����ʶ�� */ - //int tuple4_reuse_time_interval; /* ��Ԫ�����õ���С���ʱ�� */ + //int tuple4_reuse_time_interval; /* ��Ԫ�����õ���С���ʱ��? */ //void *fs2_handle; const char *fs2_server_ip; unsigned short fs2_server_port_host; @@ -404,9 +408,9 @@ struct sapp_global_single_t{ }; #define TIMESTAMP_SINGLE_PKT_REGION (4) /* ������ʱͳ������ */ -#define TIMESTAMP_SINGLE_PKT_REGION_MAX (5) /* ��������ͳ�������ֵ */ +#define TIMESTAMP_SINGLE_PKT_REGION_MAX (5) /* ��������ͳ��������? */ typedef struct{ - unsigned int runtime_pkt_max_delay; /* �����������ʱ */ + unsigned int runtime_pkt_max_delay; /* ������������? */ unsigned long long pkt_total_num[TIMESTAMP_SINGLE_PKT_REGION_MAX]; /* ��¼��������ʱ���ܰ���, ������ͳ�� */ unsigned long long pkt_total_time; /* ���һ��ʱ�������ʱ, ���ڼ���ƽ������������ʱ */ }timestamp_record_region_t; @@ -420,15 +424,15 @@ struct sapp_global_mthread_t{ char __pad1[4]; double pptp_hash_avg_search_times; double l2tp_hash_avg_search_times; - int tcp_stream_special_timeout_num; /* ���õ�����ʱʱ�����, Ĭ�ϲ�����������������10% */ - int udp_stream_special_timeout_num;/* ���õ�����ʱʱ�����, Ĭ�ϲ�����������������10% */ + int tcp_stream_special_timeout_num; /* ���õ�����ʱʱ�����?, Ĭ�ϲ�����������������10% */ + int udp_stream_special_timeout_num;/* ���õ�����ʱʱ�����?, Ĭ�ϲ�����������������10% */ timestamp_record_region_t runtime_record; timestamp_record_region_t runtime_record_driver; /* �����������õ���, ��ƽ̨�õ�������ʱ */ }__attribute__ ((aligned (64))); typedef struct{ #ifdef DEBUG - unsigned int magic; /* malloc�����0x4D4D4D4D, ��MMMM ��16����; free�����0xFEFEFEFE */ + unsigned int magic; /* malloc�����?0x4D4D4D4D, ��MMMM ��16����; free�����?0xFEFEFEFE */ #endif unsigned int user_buf_size; }sapp_private_mem_t; diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h index 0f7ec24..4353f70 100644 --- a/include/public/stream_inc/stream_control.h +++ b/include/public/stream_inc/stream_control.h @@ -1,386 +1,389 @@ #ifndef _APP_STREAM_CONTROL_H_
-#define _APP_STREAM_CONTROL_H_
+#define _APP_STREAM_CONTROL_H_
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-#define STREAM_CONTROL_H_VERSION (20210818)
-
-#define TCP_CTEAT_LINK_BYSYN 0x01 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
-#define TCP_CTEAT_LINK_BYDATA 0x02 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
-
-/*
- option of stream,
-
- MSO_IGNORE_RST_FIN: will not be terminated by RST, FIN packet, only if timeout or in LRU tail, it will be eliminated.
-*/
-enum MESA_stream_opt{
- __MSO_PAD = 0, /* placeholder */
- MSO_MAX_UNORDER = 1, /* opt_val type must be struct max_unorder_opt */
- MSO_NEED_ACK, /* opt_val type must be unsigned char, value only be [0,1] */
- MSO_TAKEOVER, /* opt_val type must be int, value only be [0,1] */
- MSO_TIMEOUT, /* opt_val type must be unsigned short */
- MSO_IGNORE_RST_FIN, /* opt_val type must be unsigned char, value only be [0,1] */
- MSO_TCP_CREATE_LINK_MODE, /* opt_val must be unsigned char, refer to TCP_CTEAT_LINK_xxx */
- MSO_TCP_ISN_C2S, /* Host-order, opt_val type must be unsigned int */
- MSO_TCP_ISN_S2C, /* Host-order, opt_val type must be unsigned int */
- MSO_TCP_SYN_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN packet is captured */
- MSO_TCP_SYNACK_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN/ACK packet is captured */
- MSO_STREAM_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
- MSO_STREAM_CLOSE_REASON, /* opt_val type must be unsigned char, refer to stream_close_reason_t */
- MSO_STREAM_VXLAN_INFO, /* opt_val type must be struct vxlan_info, only support for MAC-in-MAC encapsulation in mirror mode */
- MSO_TCPALL_VALID_AFTER_KILL, /* opt_val type must be unsigned char, value only be [0,1]; Warning, this option is obsolete, use MESA_rst_tcp() instead */
- MSO_GLOBAL_STREAM_ID, /* opt_val type must be unsigned long long, is value-result argument, IN: device_id, value range[0, 4095]; OUT:global stream id */
- MSO_DROP_STREAM, /* opt_val type must be int, value only be [0,1]; similar to DROPPKT, but effective scope is all subsequent packets of this stream. */
- MSO_TCP_RST_REMEDY, /* opt_val type must be int, value only be [0,1]; if not set this, default is disable. */
- MSO_TOTAL_INBOUND_PKT, /* inbound packet number of this stream, opt_val type must be unsigned long long */
- MSO_TOTAL_INBOUND_BYTE, /* inbound packet byte of this stream, opt_val type must be unsigned long long */
- 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 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_STREAM_UP_LAYER_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
- MSO_STREAM_PLUG_PME, /* opt_val type must be struct mso_plug_pme, this is a value-result argument, the caller should set plug_name and plug_entry_type, only support: TCP, TCP_ALL, UDP */
- MSO_DROP_CURRENT_PKT, /* opt_val type must be int, value only be [0,1], notice the difference between MSO_DROP_CURRENT_PKT and MSO_DROP_STREAM, MSO_DROP_CURRENT_PKT only discard current packet, but MSO_DROP_STREAM discard all subsequent packets of stream */
- MSO_HAVE_DUP_PKT, /* opt_val type must be int, value only be [0, 1, -2], if the current stream found duplicate packets ? 0:no; 1:yes; -2: not sure */
- MSO_STREAM_LASTUPDATE_TIMESTAMP_MS,/* latest pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
- MSO_STREAM_TIMED,
- MSO_STREAM_APPLEND_SEGMENT_ID_LIST,
- MSO_STREAM_PREPLEND_SEGMENT_ID_LIST,
- MSO_STREAM_SET_DATAMETA_TRACE_ID,
- MSO_STREAM_C2S_RAWPKT_HDR,
- MSO_STREAM_S2C_RAWPKT_HDR,
- MSO_STREAM_C2S_SYN_NUM,
- MSO_STREAM_S2C_SYN_NUM,
- MSO_STREAM_INBOND_LINK_ID,
- MSO_STREAM_OUTBOND_LINK_ID,
- MSO_STREAM_C2S_ROUTE_DIRECTION,
- MSO_STREAM_INBOND_ROUTE_CTX,
- MSO_STREAM_OUTBOND_ROUTE_CTX,
- MSO_STREAM_C2S_LINK_ID,
- MSO_STREAM_S2C_LINK_ID,
- MSO_STREAM_C2S_ROUTE_CTX,
- MSO_STREAM_S2C_ROUTE_CTX,
- MSO_IP_TTL_C2S, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
- MSO_IP_TTL_S2C, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
- MSO_TCP_RTT_CSC, /* opt_val type must be unsigned short, the full RTT is client->tsg->server->tsg->client, this is |tsg->server->tsg| */
- MSO_TCP_RTT_SCS, /* opt_val type must be unsigned short, the full RTT is server->tsg->client->tsg->server, this is |tsg->client->tsg| */
- MSO_STREAM_C2S_SEGMENT_ID_LIST,
- MSO_STREAM_S2C_SEGMENT_ID_LIST,
- MSO_STREAM_INBOND_SEGMENT_ID_LIST,
- MSO_STREAM_OUTBOND_SEGMENT_ID_LIST,
- __MSO_MAX,
-};
-
-/* for MSO_STREAM_CLOSE_REASON,
- don't confuse, these values is not consecutive indeed, because some value(1,2) is obsoleted!
-*/
-enum stream_close_reason_t{
- STREAM_CLOSE_REASON_SYN_REUSE = 0, /* for TCP tuple4 reuse */
- STREAM_CLOSE_REASON_NORMAL = 3, /* for TCP FIN, FIN/ACK */
- STREAM_CLOSE_REASON_RESET = 4, /* for TCP RESET */
- STREAM_CLOSE_REASON_TIMEOUT = 5, /* timeout */
- STREAM_CLOSE_REASON_LRUOUT = 6, /* stream table full, kick out */
- STREAM_CLOSE_REASON_DEPRIVE = 7, /* deprive by some plug who return KILL_FOLLOW or KILL_OTHER */
- STREAM_CLOSE_REASON_DUMPFILE = 8, /* only for pcap dumpfile mode */
-};
-
-
-enum sapp_platform_opt{
- SPO_TOTAL_RCV_PKT, /* total recv packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_BYTE, /* total recv packet byte, opt_val type must be unsigned long long */
- SPO_REALTIME_RCV_PKT, /* realtime recv packet number, opt_val type must be unsigned long long */
- SPO_REALTIME_RCV_BYTE, /* realtime recv packet byte, opt_val type must be unsigned long long */
- SPO_THREAD_COUNT, /* total thread count, opt_val type must be int */
- SPO_CURTIME_TIMET, /* current time, opt_val type must be time_t */
- SPO_CURTIME_STRING, /* current time, opt_val type must be char[], opt_val_len must more than strlen("1970-01-01 01:01:01") */
- SPO_START_TIME, /* platform start time, opt_val type must be time_t */
- SPO_RUN_TIME, /* platform running time, opt_val type must be time_t */
- SPO_RAND_NUMBER, /* get a rand number, opt_val type must be long long */
- SPO_FIELD_STAT_HANDLE, /* field stat output handle, opt_val type must be void * */
- SPO_INDEPENDENT_THREAD_ID, /* plug independent thread which is created by pthread_create(), opt_val type must be int */
- SPO_DEPLOYMENT_MODE_STR, /* opt_val type is char[], optional value is:["mirror", "inline", "transparent"] */
- SPO_TCP_STREAM_NEW, /* total created tcp streams from start, opt_val type must be unsigned long long */
- SPO_TCP_STREAM_CLOSE, /* total closed tcp streams from start, opt_val type must be unsigned long long */
- SPO_TCP_STREAM_ESTAB, /* realtime established tcp streams, opt_val type must be unsigned long long */
- SPO_TOTAL_INBOUND_PKT, /* total inbound packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_INBOUND_BYTE, /* total inbound packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_OUTBOUND_PKT, /* total outbound packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_OUTBOUND_BYTE, /* total outbound packet bytes, opt_val type must be unsigned long long */
- SPO_UDP_STREAM_NEW, /* total created udp streams from start, opt_val type must be unsigned long long */
- SPO_UDP_STREAM_CLOSE, /* total closed udp streams from start, opt_val type must be unsigned long long */
- SPO_UDP_STREAM_CONCURRENT, /* realtime Concurrent udp streams, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_IPV4_PKT, /* total recv ipv4 packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_IPV4_BYTE, /* total recv ipv4 packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_IPV4_PKT, /* total recv ipv4 packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_IPV4_BYTE, /* total recv ipv4 packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_IPV6_PKT, /* total recv ipv6 packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_IPV6_BYTE, /* total recv ipv6 packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_IPV6_PKT, /* total recv ipv6 packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_IPV6_BYTE, /* total recv ipv6 packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_TCP_PKT, /* total recv tcp packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_TCP_BYTE, /* total recv tcp packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_TCP_PKT, /* total recv tcp packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_TCP_BYTE, /* total recv tcp packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_UDP_PKT, /* total recv udp packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_INBOUND_UDP_BYTE, /* total recv udp packet number, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_UDP_PKT, /* total recv udp packet bytes, opt_val type must be unsigned long long */
- SPO_TOTAL_RCV_OUTBOUND_UDP_BYTE, /* total recv udp packet bytes, opt_val type must be unsigned long long */
- SPO_CURTIME_TIMET_MS, /* current time in millisecond, opt_val type must be long long */
- SPO_CURRENT_STATE, /* running stage of sapp, opt_val type is enum sapp_state_t */
- SPO_CONFIG_ROOT_DIR, /* config file root directory, opt_val type must be char[], opt_val_len is value-result argument */
- SPO_DATA_ROOT_DIR, /* data or state file root directory, opt_val type must be char[], opt_val_len is value-result argument */
- SPO_DEPLOYMENT_MODE, /* Similar to SPO_DEPLOYMENT_MODE_STR, opt_val type is sapp_deploment_mode_t */
- SPO_TCP_STREAM_C2S, /* total number of TCP c2s flows processed since start of run, opt_val type must be unsigned long long */
- SPO_TCP_STREAM_S2C, /* total number of TCP s2c flows processed since start of run, opt_val type must be unsigned long long */
- SPO_TCP_STREAM_DOUBLE, /* total number of TCP bidirectional flows processed since start of run, opt_val type must be unsigned long long */
- SPO_UDP_STREAM_C2S, /* total number of TCP c2s flows processed since start of run, opt_val type must be unsigned long long */
- SPO_UDP_STREAM_S2C, /* total number of TCP s2c flows processed since start of run, opt_val type must be unsigned long long */
- SPO_UDP_STREAM_DOUBLE, /* total number of TCP bidirectional flows processed since start of run, opt_val type must be unsigned long long */
-};
-
-
-/*
- option of device,
-*/
-enum sapp_device_opt{
- __SDO_PAD = 0, /* placeholder */
- SDO_MAC_ADDR, /* device mac addr, opt_val type must be at least char[6] */
- SDO_IPV4_ADDR, /* device ipv4 addr in network order, opt_val type must be int */
- SDO_MTU, /* device MTU, opt_val type must be int */
- __SDO_MAX,
-};
-
-/* for MSO_MAX_UNORDER */
-struct max_unorder_opt{
- unsigned short stream_dir; /* refer to stream_base.h, DIR_C2S, DIR_S2C, DIR_DOUBLE */
- unsigned short max_unorder_val;
-};
-
-
-enum stream_timer_return_value{
- KEEP = 0,
- DROP = 1,
-};
-
-
-#define MAX_TCP_OPT_LEN (38) /* TCP max hdr length 60Bytes, set max opt length 38 Bytes */
-#define MAX_TCP_OPT_NUM (20)
-
-enum tcp_option_value{
- TCP_OPT_EOL = 0,
- TCP_OPT_NOP = 1,
- TCP_OPT_MSS = 2,
- TCP_OPT_WIN_SCALE = 3,
- TCP_OPT_SACK = 4,
- TCP_OPT_SACK_EDGE = 5,
- TCP_OPT_TIME_STAMP = 8, /* refer to struct tcp_option_ts */
- TCP_OPT_MD5 = 19,
- TCP_OPT_MULTI_PATH_TCP = 0x1E,
- TCP_OPT_RIVER_PROBE = 0x4c,
-};
-
-struct tcp_option_ts{
- unsigned int ts_self;
- unsigned int ts_echo_reply;
-};
-
-struct tcp_option{
- unsigned char type;
- unsigned char len; /* pure payload len, not contain type and this len field */
- union{
- unsigned char char_value;
- unsigned short short_value;
- unsigned int int_value;
- unsigned long long long_value;
- char *variable_value;
- struct tcp_option_ts opt_ts_val;
- };
-} __attribute__((packed, aligned(1)));
-
-struct tcp_option_ext{
- unsigned char type;
- unsigned char len;
- union{
- unsigned char char_value;
- unsigned short short_value;
- unsigned int int_value;
- unsigned long long long_value;
- char variable_value[MAX_TCP_OPT_LEN];
- struct tcp_option_ts opt_ts_val;
- };
-} __attribute__((packed, aligned(1)));
-
-
-struct vxlan_info{
- unsigned char encap_type;
- unsigned char entrance_id;
- unsigned char dev_id;
- unsigned char link_id;
- unsigned char link_dir;
- unsigned char inner_smac[18]; /*string, "11:22:33:44:55:66" */
- unsigned char inner_dmac[18]; /* string, "11:22:33:44:55:66" */
- unsigned char inner_smac_hex[6]; /* hex */
- unsigned char inner_dmac_hex[6]; /* hex */
-};
-
-
-enum sapp_state_t{
- SAPP_STATE_JUST_START, /* main() called by shell command */
- SAPP_STATE_CONFIG_PARSE,
- SAPP_STATE_PLATFORM_INITING,
- SAPP_STATE_PLATFORM_INITED, /* 3 */
- SAPP_STATE_PLUG_INITING,
- SAPP_STATE_PLUG_INITED, /* 5 */
- SAPP_STATE_PKT_IO_INITING,
- SAPP_STATE_PKT_IO_INITED,
- SAPP_STATE_PROCESSING, /* 8 */
- SAPP_STATE_READY_TO_EXIT, /* 9, pcap dumpfile mode, or recv custom signal */
- SAPP_STATE_EXIT,
-};
-
-
-struct mso_plug_pme{
- const char *plug_name; /* argument: IN, comes from plug.inf-->[PLUGINFO]-->PLUGNAME */
- const char *plug_entry_type; /* argument: IN, only support: TCP, TCP_ALL, UDP. */
- void *plug_pme; /* argument: OUT, plug private memory address of current stream */
-};
-
-enum sapp_deploment_mode_t{
- DEPLOYMENT_MODE_MIRROR = 1,
- DEPLOYMENT_MODE_TRANSPARENT = 2,
- DEPLOYMENT_MODE_INLINE = 3,
-};
-
+#define STREAM_CONTROL_H_VERSION (20210818)
+
+#define TCP_CTEAT_LINK_BYSYN 0x01 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
+#define TCP_CTEAT_LINK_BYDATA 0x02 /* for MESA_stream_opt->MSO_TCP_CREATE_LINK_MODE */
+
+ /*
+ option of stream,
+
+ MSO_IGNORE_RST_FIN: will not be terminated by RST, FIN packet, only if timeout or in LRU tail, it will be eliminated.
+ */
+ enum MESA_stream_opt
+ {
+ __MSO_PAD = 0, /* placeholder */
+ MSO_MAX_UNORDER = 1, /* opt_val type must be struct max_unorder_opt */
+ MSO_NEED_ACK, /* opt_val type must be unsigned char, value only be [0,1] */
+ MSO_TAKEOVER, /* opt_val type must be int, value only be [0,1] */
+ MSO_TIMEOUT, /* opt_val type must be unsigned short */
+ MSO_IGNORE_RST_FIN, /* opt_val type must be unsigned char, value only be [0,1] */
+ MSO_TCP_CREATE_LINK_MODE, /* opt_val must be unsigned char, refer to TCP_CTEAT_LINK_xxx */
+ MSO_TCP_ISN_C2S, /* Host-order, opt_val type must be unsigned int */
+ MSO_TCP_ISN_S2C, /* Host-order, opt_val type must be unsigned int */
+ MSO_TCP_SYN_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN packet is captured */
+ MSO_TCP_SYNACK_OPT, /* opt_val must be struct tcp_option **, opt_val_len [OUT} is struct tcp_option number, valid only if SYN/ACK packet is captured */
+ MSO_STREAM_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
+ MSO_STREAM_CLOSE_REASON, /* opt_val type must be unsigned char, refer to stream_close_reason_t */
+ MSO_STREAM_VXLAN_INFO, /* opt_val type must be struct vxlan_info, only support for MAC-in-MAC encapsulation in mirror mode */
+ MSO_TCPALL_VALID_AFTER_KILL, /* opt_val type must be unsigned char, value only be [0,1]; Warning, this option is obsolete, use MESA_rst_tcp() instead */
+ MSO_GLOBAL_STREAM_ID, /* opt_val type must be unsigned long long, is value-result argument, IN: device_id, value range[0, 4095]; OUT:global stream id */
+ MSO_DROP_STREAM, /* opt_val type must be int, value only be [0,1]; similar to DROPPKT, but effective scope is all subsequent packets of this stream. */
+ MSO_TCP_RST_REMEDY, /* opt_val type must be int, value only be [0,1]; if not set this, default is disable. */
+ MSO_TOTAL_INBOUND_PKT, /* inbound packet number of this stream, opt_val type must be unsigned long long */
+ MSO_TOTAL_INBOUND_BYTE, /* inbound packet byte of this stream, opt_val type must be unsigned long long */
+ 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 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_STREAM_UP_LAYER_TUNNEL_TYPE, /* opt_val must be unsigned short, refer to enum stream_carry_tunnel_t */
+ MSO_STREAM_PLUG_PME, /* opt_val type must be struct mso_plug_pme, this is a value-result argument, the caller should set plug_name and plug_entry_type, only support: TCP, TCP_ALL, UDP */
+ MSO_DROP_CURRENT_PKT, /* opt_val type must be int, value only be [0,1], notice the difference between MSO_DROP_CURRENT_PKT and MSO_DROP_STREAM, MSO_DROP_CURRENT_PKT only discard current packet, but MSO_DROP_STREAM discard all subsequent packets of stream */
+ MSO_HAVE_DUP_PKT, /* opt_val type must be int, value only be [0, 1, -2], if the current stream found duplicate packets ? 0:no; 1:yes; -2: not sure */
+ MSO_STREAM_LASTUPDATE_TIMESTAMP_MS, /* latest pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
+ MSO_STREAM_TIMED,
+ MSO_STREAM_APPLEND_SEGMENT_ID_LIST,
+ MSO_STREAM_PREPLEND_SEGMENT_ID_LIST,
+ MSO_STREAM_SET_DATAMETA_TRACE_ID,
+ MSO_STREAM_C2S_RAWPKT_HDR,
+ MSO_STREAM_S2C_RAWPKT_HDR,
+ MSO_STREAM_C2S_SYN_NUM,
+ MSO_STREAM_S2C_SYN_NUM,
+ MSO_STREAM_INBOND_LINK_ID,
+ MSO_STREAM_OUTBOND_LINK_ID,
+ MSO_STREAM_C2S_ROUTE_DIRECTION,
+ MSO_STREAM_INBOND_ROUTE_CTX,
+ MSO_STREAM_OUTBOND_ROUTE_CTX,
+ MSO_STREAM_C2S_LINK_ID,
+ MSO_STREAM_S2C_LINK_ID,
+ MSO_STREAM_C2S_ROUTE_CTX,
+ MSO_STREAM_S2C_ROUTE_CTX,
+ MSO_IP_TTL_C2S, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
+ MSO_IP_TTL_S2C, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
+ MSO_TCP_RTT_CSC, /* opt_val type must be unsigned short, the full RTT is client->tsg->server->tsg->client, this is |tsg->server->tsg| */
+ MSO_TCP_RTT_SCS, /* opt_val type must be unsigned short, the full RTT is server->tsg->client->tsg->server, this is |tsg->client->tsg| */
+ MSO_STREAM_C2S_SEGMENT_ID_LIST,
+ MSO_STREAM_S2C_SEGMENT_ID_LIST,
+ MSO_STREAM_INBOND_SEGMENT_ID_LIST,
+ MSO_STREAM_OUTBOND_SEGMENT_ID_LIST,
+ MSO_STREAM_UUID, /* opt_val is uuid_t (unsigned char [16]) */
+ __MSO_MAX,
+ };
+
+ /* for MSO_STREAM_CLOSE_REASON,
+ don't confuse, these values is not consecutive indeed, because some value(1,2) is obsoleted!
+ */
+ enum stream_close_reason_t
+ {
+ STREAM_CLOSE_REASON_SYN_REUSE = 0, /* for TCP tuple4 reuse */
+ STREAM_CLOSE_REASON_NORMAL = 3, /* for TCP FIN, FIN/ACK */
+ STREAM_CLOSE_REASON_RESET = 4, /* for TCP RESET */
+ STREAM_CLOSE_REASON_TIMEOUT = 5, /* timeout */
+ STREAM_CLOSE_REASON_LRUOUT = 6, /* stream table full, kick out */
+ STREAM_CLOSE_REASON_DEPRIVE = 7, /* deprive by some plug who return KILL_FOLLOW or KILL_OTHER */
+ STREAM_CLOSE_REASON_DUMPFILE = 8, /* only for pcap dumpfile mode */
+ };
+
+ enum sapp_platform_opt
+ {
+ SPO_TOTAL_RCV_PKT, /* total recv packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_BYTE, /* total recv packet byte, opt_val type must be unsigned long long */
+ SPO_REALTIME_RCV_PKT, /* realtime recv packet number, opt_val type must be unsigned long long */
+ SPO_REALTIME_RCV_BYTE, /* realtime recv packet byte, opt_val type must be unsigned long long */
+ SPO_THREAD_COUNT, /* total thread count, opt_val type must be int */
+ SPO_CURTIME_TIMET, /* current time, opt_val type must be time_t */
+ SPO_CURTIME_STRING, /* current time, opt_val type must be char[], opt_val_len must more than strlen("1970-01-01 01:01:01") */
+ SPO_START_TIME, /* platform start time, opt_val type must be time_t */
+ SPO_RUN_TIME, /* platform running time, opt_val type must be time_t */
+ SPO_RAND_NUMBER, /* get a rand number, opt_val type must be long long */
+ SPO_FIELD_STAT_HANDLE, /* field stat output handle, opt_val type must be void * */
+ SPO_INDEPENDENT_THREAD_ID, /* plug independent thread which is created by pthread_create(), opt_val type must be int */
+ SPO_DEPLOYMENT_MODE_STR, /* opt_val type is char[], optional value is:["mirror", "inline", "transparent"] */
+ SPO_TCP_STREAM_NEW, /* total created tcp streams from start, opt_val type must be unsigned long long */
+ SPO_TCP_STREAM_CLOSE, /* total closed tcp streams from start, opt_val type must be unsigned long long */
+ SPO_TCP_STREAM_ESTAB, /* realtime established tcp streams, opt_val type must be unsigned long long */
+ SPO_TOTAL_INBOUND_PKT, /* total inbound packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_INBOUND_BYTE, /* total inbound packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_OUTBOUND_PKT, /* total outbound packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_OUTBOUND_BYTE, /* total outbound packet bytes, opt_val type must be unsigned long long */
+ SPO_UDP_STREAM_NEW, /* total created udp streams from start, opt_val type must be unsigned long long */
+ SPO_UDP_STREAM_CLOSE, /* total closed udp streams from start, opt_val type must be unsigned long long */
+ SPO_UDP_STREAM_CONCURRENT, /* realtime Concurrent udp streams, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_IPV4_PKT, /* total recv ipv4 packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_IPV4_BYTE, /* total recv ipv4 packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_IPV4_PKT, /* total recv ipv4 packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_IPV4_BYTE, /* total recv ipv4 packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_IPV6_PKT, /* total recv ipv6 packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_IPV6_BYTE, /* total recv ipv6 packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_IPV6_PKT, /* total recv ipv6 packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_IPV6_BYTE, /* total recv ipv6 packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_TCP_PKT, /* total recv tcp packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_TCP_BYTE, /* total recv tcp packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_TCP_PKT, /* total recv tcp packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_TCP_BYTE, /* total recv tcp packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_UDP_PKT, /* total recv udp packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_INBOUND_UDP_BYTE, /* total recv udp packet number, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_UDP_PKT, /* total recv udp packet bytes, opt_val type must be unsigned long long */
+ SPO_TOTAL_RCV_OUTBOUND_UDP_BYTE, /* total recv udp packet bytes, opt_val type must be unsigned long long */
+ SPO_CURTIME_TIMET_MS, /* current time in millisecond, opt_val type must be long long */
+ SPO_CURRENT_STATE, /* running stage of sapp, opt_val type is enum sapp_state_t */
+ SPO_CONFIG_ROOT_DIR, /* config file root directory, opt_val type must be char[], opt_val_len is value-result argument */
+ SPO_DATA_ROOT_DIR, /* data or state file root directory, opt_val type must be char[], opt_val_len is value-result argument */
+ SPO_DEPLOYMENT_MODE, /* Similar to SPO_DEPLOYMENT_MODE_STR, opt_val type is sapp_deploment_mode_t */
+ SPO_TCP_STREAM_C2S, /* total number of TCP c2s flows processed since start of run, opt_val type must be unsigned long long */
+ SPO_TCP_STREAM_S2C, /* total number of TCP s2c flows processed since start of run, opt_val type must be unsigned long long */
+ SPO_TCP_STREAM_DOUBLE, /* total number of TCP bidirectional flows processed since start of run, opt_val type must be unsigned long long */
+ SPO_UDP_STREAM_C2S, /* total number of TCP c2s flows processed since start of run, opt_val type must be unsigned long long */
+ SPO_UDP_STREAM_S2C, /* total number of TCP s2c flows processed since start of run, opt_val type must be unsigned long long */
+ SPO_UDP_STREAM_DOUBLE, /* total number of TCP bidirectional flows processed since start of run, opt_val type must be unsigned long long */
+ };
+
+ /*
+ option of device,
+ */
+ enum sapp_device_opt
+ {
+ __SDO_PAD = 0, /* placeholder */
+ SDO_MAC_ADDR, /* device mac addr, opt_val type must be at least char[6] */
+ SDO_IPV4_ADDR, /* device ipv4 addr in network order, opt_val type must be int */
+ SDO_MTU, /* device MTU, opt_val type must be int */
+ __SDO_MAX,
+ };
+
+ /* for MSO_MAX_UNORDER */
+ struct max_unorder_opt
+ {
+ unsigned short stream_dir; /* refer to stream_base.h, DIR_C2S, DIR_S2C, DIR_DOUBLE */
+ unsigned short max_unorder_val;
+ };
+
+ enum stream_timer_return_value
+ {
+ KEEP = 0,
+ DROP = 1,
+ };
+
+#define MAX_TCP_OPT_LEN (38) /* TCP max hdr length 60Bytes, set max opt length 38 Bytes */
+#define MAX_TCP_OPT_NUM (20)
+
+ enum tcp_option_value
+ {
+ TCP_OPT_EOL = 0,
+ TCP_OPT_NOP = 1,
+ TCP_OPT_MSS = 2,
+ TCP_OPT_WIN_SCALE = 3,
+ TCP_OPT_SACK = 4,
+ TCP_OPT_SACK_EDGE = 5,
+ TCP_OPT_TIME_STAMP = 8, /* refer to struct tcp_option_ts */
+ TCP_OPT_MD5 = 19,
+ TCP_OPT_MULTI_PATH_TCP = 0x1E,
+ TCP_OPT_RIVER_PROBE = 0x4c,
+ };
+
+ struct tcp_option_ts
+ {
+ unsigned int ts_self;
+ unsigned int ts_echo_reply;
+ };
+
+ struct tcp_option
+ {
+ unsigned char type;
+ unsigned char len; /* pure payload len, not contain type and this len field */
+ union
+ {
+ unsigned char char_value;
+ unsigned short short_value;
+ unsigned int int_value;
+ unsigned long long long_value;
+ char *variable_value;
+ struct tcp_option_ts opt_ts_val;
+ };
+ } __attribute__((packed, aligned(1)));
+
+ struct tcp_option_ext
+ {
+ unsigned char type;
+ unsigned char len;
+ union
+ {
+ unsigned char char_value;
+ unsigned short short_value;
+ unsigned int int_value;
+ unsigned long long long_value;
+ char variable_value[MAX_TCP_OPT_LEN];
+ struct tcp_option_ts opt_ts_val;
+ };
+ } __attribute__((packed, aligned(1)));
+
+ struct vxlan_info
+ {
+ unsigned char encap_type;
+ unsigned char entrance_id;
+ unsigned char dev_id;
+ unsigned char link_id;
+ unsigned char link_dir;
+ unsigned char inner_smac[18]; /*string, "11:22:33:44:55:66" */
+ unsigned char inner_dmac[18]; /* string, "11:22:33:44:55:66" */
+ unsigned char inner_smac_hex[6]; /* hex */
+ unsigned char inner_dmac_hex[6]; /* hex */
+ };
+
+ enum sapp_state_t
+ {
+ SAPP_STATE_JUST_START, /* main() called by shell command */
+ SAPP_STATE_CONFIG_PARSE,
+ SAPP_STATE_PLATFORM_INITING,
+ SAPP_STATE_PLATFORM_INITED, /* 3 */
+ SAPP_STATE_PLUG_INITING,
+ SAPP_STATE_PLUG_INITED, /* 5 */
+ SAPP_STATE_PKT_IO_INITING,
+ SAPP_STATE_PKT_IO_INITED,
+ SAPP_STATE_PROCESSING, /* 8 */
+ SAPP_STATE_READY_TO_EXIT, /* 9, pcap dumpfile mode, or recv custom signal */
+ SAPP_STATE_EXIT,
+ };
+
+ struct mso_plug_pme
+ {
+ const char *plug_name; /* argument: IN, comes from plug.inf-->[PLUGINFO]-->PLUGNAME */
+ const char *plug_entry_type; /* argument: IN, only support: TCP, TCP_ALL, UDP. */
+ void *plug_pme; /* argument: OUT, plug private memory address of current stream */
+ };
+
+ enum sapp_deploment_mode_t
+ {
+ DEPLOYMENT_MODE_MIRROR = 1,
+ DEPLOYMENT_MODE_TRANSPARENT = 2,
+ DEPLOYMENT_MODE_INLINE = 3,
+ };
#ifndef MAX_SID_NUM
#define MAX_SID_NUM 8
#endif
-struct segment_id_list
-{
- unsigned short sid_list[MAX_SID_NUM];
- unsigned int sz_sidlist;
-};
-
-int append_sid_to_rawpkt(const void *rawpkt, struct segment_id_list *sid_list);
-int prepend_sid_to_rawpkt(const void *rawpkt, struct segment_id_list *sid_list);
-
-struct streaminfo;
-/*
- plug call MESA_set_stream_opt() to set feature of specified stream.
- opt: option type, refer to enum MESA_stream_opt;
- opt_val: option value, depend on opt type;
- opt_val_len: opt_val size;
-
- return value:
- 0 :OK;
- <0:error;
-*/
-int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt opt, void *opt_val, int opt_val_len);
-
-
-/*
- plug call MESA_get_stream_opt() to get feature of specified stream.
- opt: option type, refer to enum MESA_stream_opt;
- opt_val: option value, depend on opt type;
- opt_val_len: value-result argment, IN:opt_val buf size, OUT:opt_val actual size;
-
- return value:
- 0 :OK;
- <0:error;
-*/
-int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt opt, void *opt_val, int *opt_val_len);
-
-
-struct tcphdr;
-/*
- Get options from tcphdr, and store them in raw_result.
- return value:
- = 0: no option;
- > 0: opt number;
- < 0: error.
-*/
-int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_result, int res_num);
-
-
-/*
- Get options from tcphdr, and store them in raw_result.
- return value:
- = 0: no option;
- > 0: opt number;
- < 0: error.
-*/
-int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext *raw_result, int res_num);
-
-/*
- plug call sapp_get_platform_opt() to get feature of platform.
- opt: option type, refer to enum sapp_platform_opt;
- opt_val: option value, depend on opt type;
- opt_val_len: value-result argment, IN:opt_val buf size, OUT:opt_val actual size;
-
- return value:
- 0 :OK;
- <0:error;
-*/
-int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_val_len);
-
-
-/*
- Get some options of hardware .
- opt: option type, refer to enum sapp_device_opt;
- opt_val: option value, depend on opt type;
- opt_val_len: value-result argment, IN:opt_val buf size, OUT:opt_val actual size;
-
- return value:
- 0 :OK;
- <0:error;
-*/
-int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_type, void *opt_val, int *opt_val_len);
-
-/***************************************************************************************
- NOTE:
- convernt by etc/sapp.toml->inbound_route_dir.
-
- args:
- 'E' or 'e': Internal to External.
- 'I' or 'i': External to Internal.
-
- return value:
- 0 or 1: success.
- -1 : error.
-****************************************************************************************/
-int MESA_dir_human_to_link(int human_dir);
-
-/*
- args:
- 0 or 1, stream->routedir;
-
- return value:
- 'E' or 'e': Internal to External.
- 'I' or 'i': External to Internal.
- 'x': error;
-*/
-int MESA_dir_link_to_human(int link_route_dir);
-
-
-
-/****************************************************************************************
- 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, unsigned char dir, unsigned short unorder_num);
-int tcp_set_single_stream_needack(const struct streaminfo *pstream);
-int tcp_set_single_stream_takeoverflag(const struct streaminfo *pstream,int flag);
-int stream_set_single_stream_timeout(const struct streaminfo *pstream,unsigned short timeout);
-int get_thread_count(void);
-/****************************************************************************************
-****************************************************************************************
-****************************************************************************************/
+ struct segment_id_list
+ {
+ unsigned short sid_list[MAX_SID_NUM];
+ unsigned int sz_sidlist;
+ };
+
+ int append_sid_to_rawpkt(const void *rawpkt, struct segment_id_list *sid_list);
+ int prepend_sid_to_rawpkt(const void *rawpkt, struct segment_id_list *sid_list);
+
+ struct streaminfo;
+ /*
+ plug call MESA_set_stream_opt() to set feature of specified stream.
+ opt: option type, refer to enum MESA_stream_opt;
+ opt_val: option value, depend on opt type;
+ opt_val_len: opt_val size;
+
+ return value:
+ 0 :OK;
+ <0:error;
+ */
+ int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt opt, void *opt_val, int opt_val_len);
+
+ /*
+ plug call MESA_get_stream_opt() to get feature of specified stream.
+ opt: option type, refer to enum MESA_stream_opt;
+ opt_val: option value, depend on opt type;
+ opt_val_len: value-result argment, IN:opt_val buf size, OUT:opt_val actual size;
+
+ return value:
+ 0 :OK;
+ <0:error;
+ */
+ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt opt, void *opt_val, int *opt_val_len);
+
+ struct tcphdr;
+ /*
+ Get options from tcphdr, and store them in raw_result.
+ return value:
+ = 0: no option;
+ > 0: opt number;
+ < 0: error.
+ */
+ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_result, int res_num);
+
+ /*
+ Get options from tcphdr, and store them in raw_result.
+ return value:
+ = 0: no option;
+ > 0: opt number;
+ < 0: error.
+ */
+ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext *raw_result, int res_num);
+
+ /*
+ plug call sapp_get_platform_opt() to get feature of platform.
+ opt: option type, refer to enum sapp_platform_opt;
+ opt_val: option value, depend on opt type;
+ opt_val_len: value-result argment, IN:opt_val buf size, OUT:opt_val actual size;
+
+ return value:
+ 0 :OK;
+ <0:error;
+ */
+ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_val_len);
+
+ /*
+ Get some options of hardware .
+ opt: option type, refer to enum sapp_device_opt;
+ opt_val: option value, depend on opt type;
+ opt_val_len: value-result argment, IN:opt_val buf size, OUT:opt_val actual size;
+
+ return value:
+ 0 :OK;
+ <0:error;
+ */
+ int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_type, void *opt_val, int *opt_val_len);
+
+ /***************************************************************************************
+ NOTE:
+ convernt by etc/sapp.toml->inbound_route_dir.
+
+ args:
+ 'E' or 'e': Internal to External.
+ 'I' or 'i': External to Internal.
+
+ return value:
+ 0 or 1: success.
+ -1 : error.
+ ****************************************************************************************/
+ int MESA_dir_human_to_link(int human_dir);
+
+ /*
+ args:
+ 0 or 1, stream->routedir;
+
+ return value:
+ 'E' or 'e': Internal to External.
+ 'I' or 'i': External to Internal.
+ 'x': error;
+ */
+ int MESA_dir_link_to_human(int link_route_dir);
+
+ /****************************************************************************************
+ 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, unsigned char dir, unsigned short unorder_num);
+ int tcp_set_single_stream_needack(const struct streaminfo *pstream);
+ int tcp_set_single_stream_takeoverflag(const struct streaminfo *pstream, int flag);
+ int stream_set_single_stream_timeout(const struct streaminfo *pstream, unsigned short timeout);
+ int get_thread_count(void);
+ /****************************************************************************************
+ ****************************************************************************************
+ ****************************************************************************************/
#ifdef __cplusplus
}
#endif
#endif
-
|
