1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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
|