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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
#ifndef DNS_ANALYSE_INTERNAL_H
#define DNS_ANALYSE_INTERNAL_H
#include <MESA/stream.h>
//#include <MESA/MESA_handle_logger.h>
//#include <MESA/MESA_prof_load.h>
//#include "dfb_dns_config.h"
//#include "dns_analyse.h"
#ifndef MIN
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#endif
#define RUNTIME_DNSMODULE "[DNS MODULE:]"
#define DNS_PORT 53
#define PROTID_DNS 6
#define DNS_MAX_LABEL 63
#define MAX_FLAG_LEN 30
#define DNS_MAX_UDP_MESSAGE 512
#define DNSHDR_OPCODE_QUERY 0
#define DNSHDR_OPCODE_IQUERY 1
#define DNSHDR_OPCODE_STATUS 2
#define DNSHDR_RCODE_NOERR 0
#define DNSHDR_RCODE_FMTERR 1
#define DNSHDR_RCODE_SRVFAIL 2
#define DNSHDR_RCODE_NAMEERR 3
#define DNSHDR_RCODE_NOTIMPL 4
#define DNSHDR_RCODE_REFUSE 5
#define GET_TYPE_YD1 1
#define GET_TYPE_YD2 2
#define GET_TYPE_AUTH 3
#define GET_TYPE_ADDIT 4
#define NS_INT16SZ 2
#define NS_INT32SZ 4
#define DNS_RR_TYPE_ALL 0
#define DNS_RR_TYPE_ANS 1
#define DNS_RR_TYPE_AUTH 2
#define DNS_RR_TYPE_ADD 3
#define DNS_ERROR_UNKNOWN 0
#define DNS_ERROR_QUESTION 1
#define DNS_ERROR_PAYLOAD_SHORT 2
#define DNS_ERROR_CLASS_UNKNOWN 3
#define DNS_ERROR_RR 4
#define DNS_ERROR_ALL 5
#define NS_GET32(l, cp) do { \
register u_char *t_cp = (u_char *)(cp); \
(l) = ((u_int32_t)t_cp[0] << 24) \
| ((u_int32_t)t_cp[1] << 16) \
| ((u_int32_t)t_cp[2] << 8) \
| ((u_int32_t)t_cp[3]) \
; \
(cp) += NS_INT32SZ; \
} while (0)
#define NS_PUT16(s, cp) do { \
register u_int16_t t_s = (u_int16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += NS_INT16SZ; \
} while (0)
#define NS_PUT32(l, cp) do { \
register u_int32_t t_l = (u_int32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += NS_INT32SZ; \
} while (0)
#define NS_GET16(s, cp) do { \
register u_char *t_cp = (u_char *)(cp); \
(s) = ((u_int16_t)t_cp[0] << 8) \
| ((u_int16_t)t_cp[1]) \
; \
(cp) += NS_INT16SZ; \
} while (0)
#define SET_BIT(flag, bit) (flag&(~bit))
/* 2015-09-07 lijia add, for get_plug_id() bug. */
typedef struct
{
const char *str;
unsigned long long id;
}dns_str_contrast_id_t;
typedef struct _save_dns_business_info
{
void *business_pme;
int session_state;
int skip_len;/* 2 bytes */
}save_dns_business_info_t;
typedef struct _pcap_hdr
{
u_int32_t tv_sec;
u_int32_t tv_usec;
u_int32_t len;
u_int32_t caplen;
}pcap_hdr_t;
#define MAX_LOG_PATH_LEN 256
enum dns_statis_info_t
{
V4_T_PPS=0,
V4_T_BPS,
V4_U_PPS,
V4_U_BPS,
V6_T_PPS,
V6_T_BPS,
V6_U_PPS,
V6_U_BPS,
PKT_UNKNOWN,
Q_PKT,
R_PKT,
ERR_PKT,
Q_A,
Q_AAAA,
Q_CNAME,
Q_QUESTION,
Q_UNKNOWN
};
#define DNS_MAX_FIELD_ID_NUM 17
typedef struct _dns_proto_info
{
int log_level;
int cycle_time;
int fild_id[DNS_MAX_FIELD_ID_NUM];
char log_path[MAX_LOG_PATH_LEN];
void *logger;
void *stat_handle;
}g_dns_proto_info_t;
#ifdef __cplusplus
extern "C"
{
#endif
int get_rr_domain( char * msg,unsigned char ** ptr, unsigned char * buf, int buflen, char * end);
int DNS_INIT();
void DNS_DESTROY();
void PROT_FUNSTAT(long long protflag);
void GET_PLUGID(unsigned short plugid);
long long FLAG_CHANGE(char* raw_flag_str);
char DNS_UDP_ENTRY(struct streaminfo *a_udp, void **pme, int thread_seq, void *a_packet);
char DNS_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq, void *a_packet);
#ifdef __cplusplus
}
#endif
#endif
|