Skip to Content
[CAIDA - Center for Applied Internet Data Analysis logo]
The Center for Applied Internet Data Analysis
corsaro_io.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_IO_H
27 #define __CORSARO_IO_H
28 
29 #include "config.h"
30 
31 #include "corsaro_int.h"
32 
33 #include "corsaro_file.h"
34 #include "corsaro_plugin.h"
35 
45 #define CORSARO_IO_HEADER_FIXED_BYTE_LEN (4+4+1+1+4+2)
46 
48 #define CORSARO_IO_INTERVAL_HEADER_BYTE_LEN sizeof(corsaro_interval_t)
49 /*(4+4+2+4)*/
50 
52 #define CORSARO_IO_TRAILER_BYTE_LEN sizeof(corsaro_trailer_t)
53 /* (4+4+8+8+8+4+4+4+4) */
54 
56 #define CORSARO_IO_PLUGIN_PATTERN 'P'
57 
58 #define CORSARO_IO_PLUGIN_PATTERN_STR "%P"
59 
61 #define CORSARO_IO_MONITOR_PATTERN 'N'
62 
63 #define CORSARO_IO_MONITOR_PATTERN_STR "%N"
64 
66 #define CORSARO_IO_GLOBAL_NAME "global"
67 
68 #define CORSARO_IO_LOG_NAME "log"
69 
83  const char *plugin_name,
86  corsaro_file_compress_t compress,
87  int compress_level,
88  int flags);
89 
99  const char *plugin_name,
101 
108 int corsaro_io_validate_template(corsaro_t *corsaro, char *template);
109 
116 
125  corsaro_header_t *header);
126 
133  corsaro_header_t *header);
134 
143  corsaro_trailer_t *trailer);
144 
150 
159  corsaro_interval_t *int_start);
160 
166 
175  corsaro_interval_t *int_end);
176 
182 
191  corsaro_plugin_t *plugin);
192 
201  corsaro_plugin_t *plugin);
202 
212  corsaro_in_record_type_t record_type,
214 
223  corsaro_in_record_type_t record_type,
225 
235  corsaro_in_record_type_t *record_type,
237 
247  corsaro_in_record_type_t *record_type,
249 
259  corsaro_file_in_t *file,
260  corsaro_in_record_type_t *record_type,
262 
272  corsaro_file_in_t *file,
273  corsaro_in_record_type_t *record_type,
275 
285  corsaro_file_in_t *file,
286  corsaro_in_record_type_t *record_type,
288 
298  corsaro_file_in_t *file,
299  corsaro_in_record_type_t *record_type,
301 
310  off_t len);
311 
327  off_t offset, off_t len);
328 
329 #endif /* __CORSARO_IO_H */
Structure representing the start or end of an interval.
Definition: corsaro_int.h:156
An opaque structure defining an corsaro input file.
Definition: corsaro_file.h:86
off_t corsaro_io_write_record(corsaro_t *corsaro, corsaro_file_t *file, corsaro_in_record_type_t record_type, corsaro_in_record_t *record)
Write a generic corsaro record to the file.
Definition: corsaro_io.c:925
off_t corsaro_io_read_plugin_start(corsaro_in_t *corsaro, corsaro_file_in_t *file, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read the appropriate plugin header from the file.
Definition: corsaro_io.c:1288
Header file dealing with the corsaro plugin manager.
void corsaro_io_print_interval_start(corsaro_interval_t *int_start)
Write the interval headers to stdout.
Definition: corsaro_io.c:865
An opaque structure defining an corsaro output file.
Definition: corsaro_file.h:60
A reusable opaque structure for corsaro to read an input record into.
Definition: corsaro_int.h:350
void corsaro_io_print_interval_end(corsaro_interval_t *int_end)
Write the interval trailers to stdout.
Definition: corsaro_io.c:881
corsaro_file_t * corsaro_io_prepare_file_full(corsaro_t *corsaro, const char *plugin_name, corsaro_interval_t *interval, corsaro_file_mode_t mode, corsaro_file_compress_t compress, int compress_level, int flags)
Uses the given settings to open an corsaro file for the given plugin.
Definition: corsaro_io.c:699
off_t corsaro_io_read_plugin_end(corsaro_in_t *corsaro, corsaro_file_in_t *file, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read the appropriate plugin trailer from the file.
Definition: corsaro_io.c:1303
off_t corsaro_io_read_trailer(corsaro_in_t *corsaro, corsaro_file_in_t *file, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read the corsaro trailers from the file.
Definition: corsaro_io.c:1206
void corsaro_io_print_trailer(corsaro_trailer_t *trailer)
Write the corsaro trailers to stdout.
Definition: corsaro_io.c:831
off_t corsaro_io_read_bytes_offset(corsaro_in_t *corsaro, corsaro_in_record_t *record, off_t offset, off_t len)
Read the given number of bytes into the record buffer at the given offset.
Definition: corsaro_io.c:1326
Structure representing a corsaro file header.
Definition: corsaro_int.h:88
Holds the metadata for the plugin manager.
Structure representing a corsaro file trailer.
Definition: corsaro_int.h:116
corsaro_file_t * corsaro_io_prepare_file(corsaro_t *corsaro, const char *plugin_name, corsaro_interval_t *interval)
Uses the current settings to open an corsaro file for the given plugin.
Definition: corsaro_io.c:688
off_t corsaro_io_read_interval_end(corsaro_in_t *corsaro, corsaro_file_in_t *file, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read the appropriate interval trailers from the file.
Definition: corsaro_io.c:1260
off_t corsaro_io_write_interval_end(corsaro_t *corsaro, corsaro_file_t *file, corsaro_interval_t *int_end)
Write the appropriate interval trailers to the file.
Definition: corsaro_io.c:872
Header file dealing with the low-level file IO.
off_t corsaro_io_write_header(corsaro_t *corsaro, corsaro_file_t *file, corsaro_header_t *header)
Write the corsaro headers to the file.
Definition: corsaro_io.c:787
static int interval
The amount of time to wait until we dump the hash.
static corsaro_in_record_t * record
A pointer to a corsaro record.
Definition: corsaro_main.c:76
off_t corsaro_io_read_interval_start(corsaro_in_t *corsaro, corsaro_file_in_t *file, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read the appropriate interval headers from the file.
Definition: corsaro_io.c:1232
int corsaro_io_template_has_timestamp(corsaro_t *corsaro)
Determines whether there are any time-related patterns in the file template.
Definition: corsaro_io.c:758
off_t corsaro_io_read_bytes(corsaro_in_t *corsaro, corsaro_in_record_t *record, off_t len)
Read the given number of bytes into the record.
Definition: corsaro_io.c:1317
int corsaro_io_print_record(corsaro_plugin_manager_t *plugin_manager, corsaro_in_record_type_t record_type, corsaro_in_record_t *record)
Print a generic corsaro record to stdout.
Definition: corsaro_io.c:1016
enum corsaro_file_compress corsaro_file_compress_t
Supported compression types (must be kept in sync with wandio)
int corsaro_io_validate_template(corsaro_t *corsaro, char *template)
Validates a output file template for needed features.
Definition: corsaro_io.c:735
off_t corsaro_io_write_plugin_end(corsaro_t *corsaro, corsaro_file_t *file, corsaro_plugin_t *plugin)
Write the appropriate plugin trailer to the file.
Definition: corsaro_io.c:905
Corsaro input state.
Definition: corsaro_int.h:323
void corsaro_io_print_header(corsaro_plugin_manager_t *plugin_manager, corsaro_header_t *header)
Write the corsaro headers to stdout.
Definition: corsaro_io.c:795
Corsaro output state.
Definition: corsaro_int.h:230
off_t corsaro_io_write_trailer(corsaro_t *corsaro, corsaro_file_t *file, corsaro_trailer_t *trailer)
Write the corsaro trailers to the file.
Definition: corsaro_io.c:822
off_t corsaro_io_write_interval_start(corsaro_t *corsaro, corsaro_file_t *file, corsaro_interval_t *int_start)
Write the appropriate interval headers to the file.
Definition: corsaro_io.c:856
enum corsaro_file_mode corsaro_file_mode_t
Enum of supported file modes.
off_t corsaro_io_write_plugin_start(corsaro_t *corsaro, corsaro_file_t *file, corsaro_plugin_t *plugin)
Write the appropriate plugin header to the file.
Definition: corsaro_io.c:889
off_t corsaro_io_read_header(corsaro_in_t *corsaro, corsaro_file_in_t *file, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
Read an corsaro header from the file.
Definition: corsaro_io.c:1106
enum corsaro_in_record_type corsaro_in_record_type_t
Corsaro input record types.
An corsaro packet processing plugin.
Header file dealing with the internal corsaro functions.