summaryrefslogtreecommitdiff
path: root/include/MESA/stream_inc/stream_project.h
diff options
context:
space:
mode:
author[email protected] <[email protected]>2021-11-02 12:34:05 +0800
committer[email protected] <[email protected]>2021-11-02 12:34:05 +0800
commit31f55f0b88d4af34a8a36497f5e49c69b88b2fbf (patch)
tree63515b3ceb361369cdc88ae6db1a808fc80e5b42 /include/MESA/stream_inc/stream_project.h
Diffstat (limited to 'include/MESA/stream_inc/stream_project.h')
-rw-r--r--include/MESA/stream_inc/stream_project.h160
1 files changed, 160 insertions, 0 deletions
diff --git a/include/MESA/stream_inc/stream_project.h b/include/MESA/stream_inc/stream_project.h
new file mode 100644
index 0000000..f28fc17
--- /dev/null
+++ b/include/MESA/stream_inc/stream_project.h
@@ -0,0 +1,160 @@
+#ifndef _STREAM_PROJECT_H_
+#define _STREAM_PROJECT_H_
+
+#include "stream_base.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define STREAM_PROJECT_H_VERSION (20210422)
+
+#define PROJECT_REQ_NAME_MAX_LEN (64)
+
+typedef void (project_req_free_t)(int thread_seq, void *project_req_value);
+
+#define PROJECT_VAL_TYPE_CHAR "char"
+#define PROJECT_VAL_TYPE_SHORT "short"
+#define PROJECT_VAL_TYPE_INT "int"
+#define PROJECT_VAL_TYPE_LONG "long"
+#define PROJECT_VAL_TYPE_STRUCT "struct"
+
+/*
+ CHN : ���ڴ洢ȫ��IP��Ƭԭʼ��
+ ENG : for store all ip frag packet in non-ip-frag entry.
+*/
+#define PROJECT_REQ_IPV4_FRAG_LIST "ipv4_frag_list"
+#define PROJECT_REQ_IPV6_FRAG_LIST "ipv6_frag_list"
+
+
+/*
+ CHN : �˺궨���ʾTCP����ͳ�ƹ�����project_list.conf������, ��Ӧ��project_id��Ҫʹ�����º�����ȡ:
+ ENG : this MARCO is use for tcp flow statistics, should enable this in project_list.conf.
+ project_customer_register(PROJECT_REQ_TCP_FLOW, "struct");
+*/
+#define PROJECT_REQ_TCP_FLOW "tcp_flow_stat"
+
+
+#define PROJECT_REQ_TCP_DEDUCE_FLOW "tcp_deduce_flow_stat"
+
+/*
+ CHN : UDP����ͳ�ƹ���ƽ̨�̶�����, ������project_list.conf����, ��Ӧ��project_id��Ҫʹ�����º�����ȡ:
+ ENG : this MARCO is use for tcp flow statistics, it's always enable.
+ project_customer_register(PROJECT_REQ_UDP_FLOW, "struct");
+*/
+#define PROJECT_REQ_UDP_FLOW "udp_flow_stat"
+
+/*
+ CHN : ������,�ֽ���ͳ��ֵ��pdetail���ƶ���project,�ֽ�����չΪ64bit.
+ ENG : before 2015-12-31, this statistics in struct streaminfo, after 2015-12-31, you must get these use project_req_get_struct().
+*/
+struct tcp_flow_stat
+{
+ UINT32 C2S_all_pkt; /* All tcp packets, include SYN, ACK, FIN, RST, etc. */
+ UINT32 C2S_data_pkt; /* TCP reassemble packet, payload size more than zero, no retransmit packet */
+ UINT32 S2C_all_pkt;
+ UINT32 S2C_data_pkt;
+ UINT64 C2S_all_byte; /* All tcp packet's data size, include retransmit packet */
+ UINT64 C2S_data_byte;
+ UINT64 S2C_all_byte;
+ UINT64 S2C_data_byte;
+
+ /* ������2020-11-17����, �������еײ��ͷ��ԭʼ������, ֮ǰ���ڴ�ṹ����, ��ǰ���� */
+ UINT64 C2S_all_byte_raw;
+ UINT64 S2C_all_byte_raw;
+};
+
+struct udp_flow_stat
+{
+ UINT32 C2S_pkt;
+ UINT32 S2C_pkt;
+ UINT64 C2S_byte;
+ UINT64 S2C_byte;
+
+ /* ������2020-11-17����, �������еײ��ͷ��ԭʼ������, ֮ǰ���ڴ�ṹ����, ��ǰ���� */
+ UINT64 C2S_all_byte_raw;
+ UINT64 S2C_all_byte_raw;
+};
+
+/*
+ must call this function in initialization, only one times,
+ the 'free_cb' should be NULL if 'project_req_val_type' is simple type,
+ otherwise must implement it by youself.
+
+ args:
+ project_req_name: for example, "terminal_tag", "stream_id", "tcp_flow_stat".
+ project_req_val_type: support "char","short","int","long","struct".
+ free_cb: used to free resource when 'project_req_val_type' is "struct".
+
+ return value: 'project_req_id' of this project_req_name, must use this id in following functions.
+ >= 0 : success;
+ -1 : error.
+*/
+int project_producer_register(const char *project_req_name, const char *project_req_val_type, project_req_free_t *free_cb);
+
+/* args and return value same with project_producer_register() */
+int project_customer_register(const char *project_req_name, const char *project_req_val_type);
+
+
+/*
+ Function project_req_add_struct(): 'project_req_value' must be a pointer to heap memory(obtain by malloc).
+
+ return value:
+ 0 : success;
+ -1: error.
+*/
+int project_req_add_char(struct streaminfo *stream, int project_req_id, char project_req_value);
+int project_req_add_short(struct streaminfo *stream, int project_req_id, short project_req_value);
+int project_req_add_int(struct streaminfo *stream, int project_req_id, int project_req_value);
+int project_req_add_long(struct streaminfo *stream, int project_req_id, long project_req_value);
+
+int project_req_add_uchar(struct streaminfo *stream, int project_req_id, unsigned char project_req_value);
+int project_req_add_ushort(struct streaminfo *stream, int project_req_id, unsigned short project_req_value);
+int project_req_add_uint(struct streaminfo *stream, int project_req_id, unsigned int project_req_value);
+int project_req_add_ulong(struct streaminfo *stream, int project_req_id, unsigned long project_req_value);
+
+
+int project_req_add_struct(struct streaminfo *stream, int project_req_id, const void *project_req_value);
+
+
+/*
+ return value:
+ -1(or all bit is '1' in Hex mode, 0xFF, 0xFFFF, etc.):
+ maybe error, maybe the actual project_req_value is -1 indeed,
+ must check tht 'errno' in this case,
+ the 'errno' will be set to 'ERANGE' indicate an error.
+ other: success, get the stored value.
+
+ For example:
+ int value = project_req_get_int(stream, req_id);
+ if((-1 == value) && (ERANGE == errno)){
+ error_handle();
+ }else{
+ // this is not an error!!
+ do_something();
+ }
+*/
+char project_req_get_char(const struct streaminfo *stream, int project_req_id);
+short project_req_get_short(const struct streaminfo *stream, int project_req_id);
+int project_req_get_int(const struct streaminfo *stream, int project_req_id);
+long project_req_get_long(const struct streaminfo *stream, int project_req_id);
+
+unsigned char project_req_get_uchar(const struct streaminfo *stream, int project_req_id);
+unsigned short project_req_get_ushort(const struct streaminfo *stream, int project_req_id);
+unsigned int project_req_get_uint(const struct streaminfo *stream, int project_req_id);
+unsigned long project_req_get_ulong(const struct streaminfo *stream, int project_req_id);
+
+/*
+ return value:
+ NULL : error;
+ others: success.
+*/
+const void *project_req_get_struct(const struct streaminfo *stream, int project_req_id);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+