Skip to Content
The Cooperative Association for Internet Data Analysis
DONATE
CONTACT US
HOME
RESEARCH
DATA
TOOLS
PUBLICATIONS
WORKSHOPS
PROJECTS
FUNDING
www.caida.org
>
tools
:
measurement
:
corsaro
: docs
corsaro_int.h
Go to the documentation of this file.
1
/*
2
* corsaro
3
*
4
* Alistair King, CAIDA, UC San Diego
5
* corsaro-info@caida.org
6
*
7
* Copyright (C) 2012 The Regents of the University of California.
8
*
9
* This file is part of corsaro.
10
*
11
* corsaro is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* corsaro is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
20
*
21
* You should have received a copy of the GNU General Public License
22
* along with corsaro. If not, see <http://www.gnu.org/licenses/>.
23
*
24
*/
25
26
#ifndef __CORSARO_INT_H
27
#define __CORSARO_INT_H
28
29
#include "config.h"
30
31
#include "
corsaro.h
"
32
33
#include "
corsaro_file.h
"
34
#include "
corsaro_plugin.h
"
35
44
/* GCC optimizations */
45
#if __GNUC__ >= 3
46
# define DEPRECATED __attribute__((deprecated))
47
# define SIMPLE_FUNCTION __attribute__((pure))
48
# define UNUSED __attribute__((unused))
49
# define PACKED __attribute__((packed))
50
# define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
51
#else
52
# define DEPRECATED
53
# define SIMPLE_FUNCTION
54
# define UNUSED
55
# define PACKED
56
# define PRINTF(formatpos,argpos)
57
#endif
58
67
typedef
enum
corsaro_magic
68
{
70
CORSARO_MAGIC
= 0x45444752,
72
CORSARO_MAGIC_HEADER
= 0x48454144,
74
CORSARO_MAGIC_INTERVAL
= 0x494E5452,
75
/* corsaro data block magic number - "DATA" */
76
CORSARO_MAGIC_DATA = 0x44415441,
77
/* corsaro trailer magic number - "FOOT" */
78
CORSARO_MAGIC_TRAILER = 0x464F4F54
79
}
corsaro_magic_t
;
80
85
struct
corsaro_header
86
{
88
uint32_t
corsaro_magic
;
90
uint32_t
magic
;
92
uint8_t
version_major
;
94
uint8_t
version_minor
;
96
uint32_t
local_init_time
;
98
uint16_t
interval_length
;
100
uint16_t
traceuri_len
;
102
uint8_t *
traceuri
;
104
uint16_t
plugin_cnt
;
106
uint16_t *
plugin_ids
;
107
} PACKED;
108
113
struct
corsaro_trailer
114
{
116
uint32_t
corsaro_magic
;
118
uint32_t
magic
;
120
uint64_t
packet_cnt
;
122
uint32_t
first_packet_time
;
124
uint32_t
last_packet_time
;
126
uint32_t
local_final_time
;
128
uint32_t
runtime
;
129
} PACKED;
130
149
struct
corsaro_interval
150
{
152
uint32_t
corsaro_magic
;
154
uint32_t
magic
;
156
uint16_t
number
;
158
uint32_t
time
;
159
} PACKED;
160
165
struct
corsaro_plugin_data
166
{
168
uint32_t
corsaro_magic
;
170
uint32_t
magic
;
172
uint16_t
plugin_id
;
173
} PACKED;
174
178
#define CORSARO_INTERVAL_DEFAULT 60
179
187
typedef
struct
corsaro_packet_state
188
{
190
uint8_t
flags
;
192
uint32_t
asn
;
193
}
corsaro_packet_state_t
;
194
196
enum
197
{
198
CORSARO_PACKET_STATE_FLAG_BACKSCATTER = 0x01
199
};
200
202
struct
corsaro_packet
203
{
205
corsaro_packet_state_t
state
;
207
libtrace_packet_t *
ltpacket
;
208
};
209
211
#define LT_PKT(corsaro_packet) (corsaro_packet->ltpacket)
212
214
struct
corsaro
215
{
217
struct
timeval
init_time
;
218
220
char
*
uridata
;
221
223
char
*
monitorname
;
224
226
char
*
template
;
227
229
corsaro_file_mode_t
output_mode
;
230
232
corsaro_file_compress_t
compress
;
233
235
int
compress_level
;
236
238
corsaro_file_t
*
global_file
;
239
241
corsaro_file_t
*
logfile
;
242
244
corsaro_packet_t
*
packet
;
245
247
/* this is what gets passed to any function relating to plugin management */
248
corsaro_plugin_manager_t
*
plugin_manager
;
249
251
int
interval
;
252
254
corsaro_interval_t
interval_start
;
255
257
uint32_t
next_report
;
258
260
struct
timeval
first_ts
;
261
263
struct
timeval
last_ts
;
264
266
uint64_t
packet_cnt
;
267
269
int
started
;
270
271
};
272
274
struct
corsaro_in
275
{
277
char
*
uridata
;
278
280
corsaro_file_in_t
*
file
;
281
283
corsaro_in_record_type_t
expected_type
;
284
286
/* this is what gets passed to any function relating to plugin management */
287
corsaro_plugin_manager_t
*
plugin_manager
;
288
290
corsaro_plugin_t
*
plugin
;
291
293
int
started
;
294
295
};
296
298
#define CORSARO_IN_RECORD_DEFAULT_BUFFER_LEN LIBTRACE_PACKET_BUFSIZE+1024
299
301
struct
corsaro_in_record
302
{
304
corsaro_in_t
*
corsaro
;
305
307
uint8_t *
buffer
;
308
310
size_t
buffer_len
;
311
313
corsaro_in_record_type_t
type
;
314
315
};
316
317
#endif
/* __CORSARO_INT_H */