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
|
#ifndef _MESA_TRACE_H_
#define _MESA_TRACE_H_
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#define H_TRACE_VERSION_1_20150204 0
typedef void* MESA_trace_addr_handle_t;
typedef void* MESA_trace_fullstr_handle_t;
typedef void* MESA_trace_substr_handle_t;
typedef void* MESA_trace_numerical_handle_t;
struct trace_tuple4_v4
{
unsigned int saddr;
unsigned int daddr;
unsigned short source;
unsigned short dest;
};
#ifndef IPV6_ADDR_LEN
#define IPV6_ADDR_LEN (sizeof(struct in6_addr))
#endif
struct trace_tuple4_v6
{
unsigned char saddr[IPV6_ADDR_LEN] ;
unsigned char daddr[IPV6_ADDR_LEN] ;
unsigned short source;
unsigned short dest;
};
enum trace_addr_type_t
{
_TRACE_ADDR_TYPE_INIT = 0,
TRACE_ADDR_TYPE_IPV4 = 1,
TRACE_ADDR_TYPE_IPV6 = 2,
TRACE__ADDR_TYPE_IP_PAIR_V4 = 12,
TRACE__ADDR_TYPE_IP_PAIR_V6 = 13,
};
/*stream.h*/
typedef struct
{
unsigned char addrtype;
unsigned char pkttype;
unsigned char addrlen;
unsigned char __pad[5];
union
{
struct trace_tuple4_v4 *tuple4_v4;
struct trace_tuple4_v6 *tuple4_v6;
};
}trace_layer_addr;
#ifdef __cplusplus
extern "C"
{
#endif
/*-------------------------------Part1-------------------------------------------*/
/*
*Paras: logger: trace runtime_log; filename: configure file
*Return: addr_trace_handle_t, NULL means error.
*configure file form: addr_type\tsip\tsource\tdip\tdest (separator : '\t', ' ', ';')
*such as:
*4 192.168.10.147 125 10.10.6.203 80
*6 10::25:156::5 20662 10::25:156::45 80
*4 0 0 0 0 0 (means all IPV4 tuple4)
*6 0 0 0 0 0 (means all IPV6 tuple4)
*/
MESA_trace_addr_handle_t MESA_trace_create_addr_handle(void* logger, const char *filename);
/*
*Paras: handle: addr_trace_handle_t paddr:addr
*Return: 1 when match success, return 0 when match failed
*/
int MESA_trace_match_addr(MESA_trace_addr_handle_t handle, trace_layer_addr *paddr);
void MESA_trace_destory_addr_handle(MESA_trace_addr_handle_t handle);
/*--------------------------------Part2------------------------------------------*/
/*
*Paras: logger: trace runtime_log; filename: configure file
*Return: trace_substr_handle_t
*configure file form: string
*such as:
*192.168.10.123:26662
*10:25::68:58
*then 192.168.10.123:2545-55.25.65.55:123 will match
*/
MESA_trace_substr_handle_t MESA_trace_create_substr_handle(void* logger, const char *filename);
/*
*Paras: handle: trace_substr_handle_t ; str: str_len:
*Return: 1 when match success, return 0 when match failed
*func: sub match
*/
int MESA_trace_match_substr(MESA_trace_substr_handle_t handle, const char *str, int str_len);
void MESA_trace_destory_substr_handle(MESA_trace_substr_handle_t handle);
/*-------------------------------Part3-------------------------------------------*/
/*
*Paras: logger: trace runtime_log; filename: configure file
*Return: trace_fullstr_handle_t
*configure file form: string
*such as:
*HTTP
*MAIL
*then HTTP will match , HTTP_UP will not match
*/
MESA_trace_fullstr_handle_t MESA_trace_create_fullstr_handle(void* logger, const char *filename);
/*
*Paras: handle: addr_trace_handle_t ; str: str_len:
*Return: 1 when match success, return 0 when match failed
*func: complete match
*/
int MESA_trace_match_fullstr(MESA_trace_fullstr_handle_t handle, const char *str, int str_len);
void MESA_trace_destory_fullstr_handle(MESA_trace_fullstr_handle_t handle);
/*-------------------------------Part4-------------------------------------------*/
/*
*Paras: logger: trace runtime_log; filename: configure file
*Return: trace_fullstr_handle_t
*configure file form: string
*such as:
*HTTP
*MAIL
*then HTTP will match , HTTP_UP will not match
*/
MESA_trace_numerical_handle_t MESA_trace_create_numerical_handle(void* logger, const char *filename);
/*
*Paras: handle: addr_trace_handle_t ; str: str_len:
*Return: 1 when match success, return 0 when match failed
*func: complete match
*/
int MESA_trace_match_numerial(MESA_trace_numerical_handle_t handle, uint64_t value);
void MESA_trace_destory_numberial_handle(MESA_trace_numerical_handle_t handle);
#ifdef __cplusplus
}
#endif
#endif
|