Skip to Content
[CAIDA - Center for Applied Internet Data Analysis logo]
The Center for Applied Internet Data Analysis
corsaro.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_H
27 #define __CORSARO_H
28 
29 #include "config.h"
30 
31 #include "libtrace.h"
32 #include "wandio.h"
33 
48 typedef struct corsaro corsaro_t;
50 typedef struct corsaro_in corsaro_in_t;
65 
66 #ifdef WITH_PLUGIN_SIXT
67 
68 typedef struct corsaro_flowtuple corsaro_flowtuple_t;
71 typedef struct corsaro_flowtuple_class_start corsaro_flowtuple_class_start_t;
74 typedef struct corsaro_flowtuple_class_end corsaro_flowtuple_class_end_t;
75 #endif
76 
98  {
101 
104 
107 
110 
113 
116 
119 
122 
123  /* plugin specific records */
124 
125  /* corsaro_flowtuple has 20-29 */
126 
129 
132 
135 
136  /* corsaro_dos has 30-39 */
137 
140 
143 
146 
148 
150 typedef enum corsaro_file_mode
151  {
160 
164 
167  {
169  CORSARO_FILE_COMPRESS_NONE = WANDIO_COMPRESS_NONE,
171  CORSARO_FILE_COMPRESS_ZLIB = WANDIO_COMPRESS_ZLIB,
173  CORSARO_FILE_COMPRESS_BZ2 = WANDIO_COMPRESS_BZ2,
175  CORSARO_FILE_COMPRESS_LZO = WANDIO_COMPRESS_LZO,
176 
180 
183  {
184  CORSARO_INTERVAL_ALIGN_NO = 0,
185  CORSARO_INTERVAL_ALIGN_YES = 1,
186  CORSARO_INTERVAL_ALIGN_DEFAULT = CORSARO_INTERVAL_ALIGN_NO,
188 
230 corsaro_t *corsaro_alloc_output(char *template, corsaro_file_mode_t mode);
231 
245 
257  corsaro_interval_align_t interval_align);
258 
267 void corsaro_set_interval(corsaro_t *corsaro, unsigned int interval);
268 
279  int intervals);
280 
292  int intervals);
293 
301 
302 
312 int corsaro_set_trace(corsaro_t *corsaro, libtrace_t *trace);
313 
324 int corsaro_set_traceuri(corsaro_t *corsaro, char *traceuri);
325 
335 
345 
357 int corsaro_enable_plugin(corsaro_t *corsaro, const char *plugin_name,
358  const char *plugin_args);
359 
367 int corsaro_get_plugin_names(char ***plugin_names);
368 
374 void corsaro_free_plugin_names(char **plugin_names, int plugin_cnt);
375 
386 
397 
405 
416 int corsaro_set_monitorname(corsaro_t *corsaro, char *name);
417 
425 
437 int corsaro_per_packet(corsaro_t *corsaro, libtrace_packet_t *packet);
438 
452 
459 
483 /*
484  * === This comment is commented out... ===
485  * The file uri can optionally contain a prefix which tells corsaro the type
486  * of the file (ascii or binary) and the plugin which created it.
487  * For example, binary:corsaro_flowtuple:/path/to/file.gz indicates that the
488  * file is written in binary format, by the corsaro_flowtuple plugin.
489  *
490  * If no prefix is given, corsaro will attempt to guess the type and plugin.
491  */
492 corsaro_in_t *corsaro_alloc_input(const char *corsarouri);
493 
500 
507 
513 
522  corsaro_in_record_type_t *record_type,
524 
531 
538 
541 #endif /* __CORSARO_H */
Structure representing the start or end of an interval.
Definition: corsaro_int.h:156
corsaro_in_t * corsaro_alloc_input(const char *corsarouri)
Allocate an corsaro object for reading an corsaro file.
Definition: corsaro.c:1414
The start of a plugin data section.
Definition: corsaro.h:118
Zlib compression (gzip)
Definition: corsaro.h:171
corsaro_t * corsaro_alloc_output(char *template, corsaro_file_mode_t mode)
Allocate an corsaro object.
Definition: corsaro.c:893
Structure representing the start or end of a plugin data block.
Definition: corsaro_int.h:172
int corsaro_enable_plugin(corsaro_t *corsaro, const char *plugin_name, const char *plugin_args)
Attempt to enable a plugin using the given plugin name.
Definition: corsaro.c:1125
A reusable opaque structure for corsaro to read an input record into.
Definition: corsaro_int.h:350
off_t corsaro_in_read_record(corsaro_in_t *corsaro, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read the next corsaro record from the given corsaro input file.
Definition: corsaro.c:1562
ASCII IO mode.
Definition: corsaro.h:153
Binary IO mode.
Definition: corsaro.h:155
int corsaro_per_packet(corsaro_t *corsaro, libtrace_packet_t *packet)
Perform corsaro processing on a given libtrace packet.
Definition: corsaro.c:1246
void corsaro_disable_logfile(corsaro_t *corsaro)
Accessor function to disable logging to a file.
Definition: corsaro.c:1113
int corsaro_finalize_output(corsaro_t *corsaro)
Write the final interval and free resources allocated by corsaro.
Definition: corsaro.c:1382
void corsaro_set_output_rotation(corsaro_t *corsaro, int intervals)
Accessor function to set the rotation frequency of output files.
Definition: corsaro.c:1000
const char * corsaro_get_monitorname(corsaro_t *corsaro)
Accessor function to get the monitor name string.
Definition: corsaro.c:1241
static libtrace_packet_t * packet
A pointer to a libtrace packet.
Definition: corsaro_main.c:67
A lightweight wrapper around a libtrace packet.
Definition: corsaro_int.h:211
Structure representing a corsaro file header.
Definition: corsaro_int.h:88
int corsaro_is_rotate_interval(corsaro_t *corsaro)
Convenience function to determine if the output files should be rotated.
Definition: corsaro.c:1041
Represents the start record of a flowtuple class.
corsaro_in_record_type
Corsaro input record types.
Definition: corsaro.h:97
Structure representing a corsaro file trailer.
Definition: corsaro_int.h:116
int corsaro_set_trace(corsaro_t *corsaro, libtrace_t *trace)
Accessor function to set the trace pointer.
Definition: corsaro.c:1059
enum corsaro_interval_align corsaro_interval_align_t
Settings for interval alignment.
The corsaro_flowtuple flowtuple record.
Definition: corsaro.h:134
Represents the end record of a flowtuple class.
uint64_t corsaro_get_dropped_packets(corsaro_t *corsaro)
Accessor function to get the number of dropped packets in this interval.
Definition: corsaro.c:1195
LZO Compression.
Definition: corsaro.h:175
The end of an interval.
Definition: corsaro.h:115
void corsaro_disable_globalfile(corsaro_t *corsaro)
Accessor function to disable the global metadata file.
Definition: corsaro.c:1119
static int interval
The amount of time to wait until we dump the hash.
int corsaro_finalize_input(corsaro_in_t *corsaro)
Close the input file and free resources allocated by corsaro.
Definition: corsaro.c:1588
static corsaro_in_record_t * record
A pointer to a corsaro record.
Definition: corsaro_main.c:76
The overall corsaro trailer (currently only in global)
Definition: corsaro.h:109
void corsaro_set_interval(corsaro_t *corsaro, unsigned int interval)
Accessor function to set the interval length.
Definition: corsaro.c:988
corsaro_file_mode
Enum of supported file modes.
Definition: corsaro.h:150
Pseudo IO mode which allows trace files to be written.
Definition: corsaro.h:157
enum corsaro_file_compress corsaro_file_compress_t
Supported compression types (must be kept in sync with wandio)
The corsaro_flowtuple flowtuple classification type end record.
Definition: corsaro.h:131
static libtrace_t * trace
A pointer to a libtrace object.
Definition: corsaro_main.c:65
int corsaro_start_input(corsaro_in_t *corsaro)
Initialize an corsaro input object that has already been allocated.
Definition: corsaro.c:1428
Represents the eight important fields in the ip header that we will use to 'uniquely' identify a pack...
void corsaro_in_free_record(corsaro_in_record_t *record)
Free an corsaro record object.
Definition: corsaro.c:1542
The end of a plugin data section.
Definition: corsaro.h:121
Corsaro input state.
Definition: corsaro_int.h:323
The corsaro_flowtuple flowtuple classification type start record.
Definition: corsaro.h:128
uint64_t corsaro_get_accepted_packets(corsaro_t *corsaro)
Accessor function to get the number of accepted packets in this interval.
Definition: corsaro.c:1188
The start of an interval.
Definition: corsaro.h:112
The overall corsaro header (currently only in global)
Definition: corsaro.h:106
The corsaro_dos attack vector record.
Definition: corsaro.h:145
The corsaro_dos global header record.
Definition: corsaro.h:139
corsaro_in_record_t * corsaro_in_alloc_record(corsaro_in_t *corsaro)
Allocate a reusable corsaro record object.
Definition: corsaro.c:1514
The corsaro_dos header record.
Definition: corsaro.h:142
int corsaro_set_monitorname(corsaro_t *corsaro, char *name)
Accessor function to set the monitor name.
Definition: corsaro.c:1207
Corsaro state for a packet.
Definition: corsaro_int.h:194
void corsaro_free_plugin_names(char **plugin_names, int plugin_cnt)
Free the array of plugin names returned by corsaro_get_plugin_names.
Definition: corsaro.c:1170
Unknown IO mode.
Definition: corsaro.h:159
const char * corsaro_get_traceuri(corsaro_t *corsaro)
Accessor function to get the trace uri string.
Definition: corsaro.c:1202
int corsaro_start_output(corsaro_t *corsaro)
Initialize an corsaro object that has already been allocated.
Definition: corsaro.c:917
The null type used for wildcard matching.
Definition: corsaro.h:100
Internal type for directing read requests.
Definition: corsaro.h:103
Corsaro output state.
Definition: corsaro_int.h:230
int corsaro_get_plugin_names(char ***plugin_names)
Return an array of the names of plugins which are compiled into corsaro.
Definition: corsaro.c:1135
Default compression.
Definition: corsaro.h:178
corsaro_file_compress
Supported compression types (must be kept in sync with wandio)
Definition: corsaro.h:166
No compression.
Definition: corsaro.h:169
corsaro_interval_align
Settings for interval alignment.
Definition: corsaro.h:182
Default IO mode.
Definition: corsaro.h:162
enum corsaro_file_mode corsaro_file_mode_t
Enum of supported file modes.
int corsaro_set_traceuri(corsaro_t *corsaro, char *traceuri)
Accessor function to set the trace uri string.
Definition: corsaro.c:1081
enum corsaro_in_record_type corsaro_in_record_type_t
Corsaro input record types.
void * corsaro_in_get_record_data(corsaro_in_record_t *record)
Get a pointer data in a record.
Definition: corsaro.c:1583
void corsaro_set_interval_alignment(corsaro_t *corsaro, corsaro_interval_align_t interval_align)
Accessor function to enable/disable the alignment of the initial interval.
Definition: corsaro.c:975
void corsaro_set_meta_output_rotation(corsaro_t *corsaro, int intervals)
Accessor function to set the rotation frequency of meta output files.
Definition: corsaro.c:1027
Bzip compression.
Definition: corsaro.h:173
int corsaro_per_record(corsaro_t *corsaro, corsaro_in_record_type_t type, corsaro_in_record_t *record)
Perform corsaro processing on a given corsaro record.
Definition: corsaro.c:1327