Skip to Content
[CAIDA - Cooperative Association for Internet Data Analysis logo]
The Cooperative Association for 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 (4+4+2+4)
49 
51 #define CORSARO_IO_INTERVAL_DATA_HEADER_BYTE_LEN (4+4+2)
52 
54 #define CORSARO_IO_TRAILER_BYTE_LEN (4+4+8+4+4+4+4)
55 
57 #define CORSARO_IO_PLUGIN_PATTERN "%P"
58 
59 #define CORSARO_IO_GLOBAL_NAME "global"
60 
61 #define CORSARO_IO_LOG_NAME "log"
62 
73 corsaro_file_t *corsaro_io_prepare_file_full(corsaro_t *corsaro, const char *plugin_name,
75  corsaro_file_compress_t compress,
76  int compress_level,
77  int flags);
78 
85 corsaro_file_t *corsaro_io_prepare_file(corsaro_t* corsaro, const char *plugin_name);
86 
92 int corsaro_io_validate_template(corsaro_t *corsaro, char *template);
93 
101 off_t corsaro_io_write_header(corsaro_t *corsaro, corsaro_file_t *file,
102  corsaro_header_t *header);
103 
108 void corsaro_io_print_header(corsaro_plugin_manager_t *plugin_manager,
109  corsaro_header_t *header);
110 
118 off_t corsaro_io_write_trailer(corsaro_t *corsaro, corsaro_file_t *file,
119  corsaro_trailer_t *trailer);
120 
125 void corsaro_io_print_trailer(corsaro_trailer_t *trailer);
126 
134 off_t corsaro_io_write_interval_start(corsaro_t *corsaro, corsaro_file_t *file,
135  corsaro_interval_t *int_start);
136 
141 void corsaro_io_print_interval_start(corsaro_interval_t *int_start);
142 
150 off_t corsaro_io_write_interval_end(corsaro_t *corsaro, corsaro_file_t *file,
151  corsaro_interval_t *int_end);
152 
157 void corsaro_io_print_interval_end(corsaro_interval_t *int_end);
158 
165 off_t corsaro_io_write_plugin_start(corsaro_t *corsaro, corsaro_file_t *file,
166  corsaro_plugin_t *plugin);
167 
174 off_t corsaro_io_write_plugin_end(corsaro_t *corsaro, corsaro_file_t *file,
175  corsaro_plugin_t *plugin);
176 
185 off_t corsaro_io_write_record(corsaro_t *corsaro, corsaro_file_t *file,
186  corsaro_in_record_type_t record_type,
187  corsaro_in_record_t *record);
188 
195 int corsaro_io_print_record(corsaro_plugin_manager_t *plugin_manager,
196  corsaro_in_record_type_t record_type,
197  corsaro_in_record_t *record);
198 
205 off_t corsaro_io_read_header(corsaro_in_t *corsaro, corsaro_file_in_t *file,
206  corsaro_in_record_type_t *record_type,
207  corsaro_in_record_t *record);
208 
215 off_t corsaro_io_read_trailer(corsaro_in_t *corsaro, corsaro_file_in_t *file,
216  corsaro_in_record_type_t *record_type,
217  corsaro_in_record_t *record);
218 
225 off_t corsaro_io_read_interval_start(corsaro_in_t *corsaro, corsaro_file_in_t *file,
226  corsaro_in_record_type_t *record_type,
227  corsaro_in_record_t *record);
228 
235 off_t corsaro_io_read_interval_end(corsaro_in_t *corsaro, corsaro_file_in_t *file,
236  corsaro_in_record_type_t *record_type,
237  corsaro_in_record_t *record);
238 
245 off_t corsaro_io_read_plugin_start(corsaro_in_t *corsaro, corsaro_file_in_t *file,
246  corsaro_in_record_type_t *record_type,
247  corsaro_in_record_t *record);
248 
255 off_t corsaro_io_read_plugin_end(corsaro_in_t *corsaro, corsaro_file_in_t *file,
256  corsaro_in_record_type_t *record_type,
257  corsaro_in_record_t *record);
258 
266 off_t corsaro_io_read_bytes(corsaro_in_t *corsaro, corsaro_in_record_t *record,
267  off_t len);
268 
282 off_t corsaro_io_read_bytes_offset(corsaro_in_t *corsaro,
283  corsaro_in_record_t *record,
284  off_t offset, off_t len);
285 
286 #endif /* __CORSARO_IO_H */