Header file dealing with the corsaro file IO. More...

Go to the source code of this file.
Macros | |
| #define | CORSARO_IO_HEADER_FIXED_BYTE_LEN (4+4+1+1+4+2) |
| Length of the fixed part of the global corsaro header. | |
| #define | CORSARO_IO_INTERVAL_HEADER_BYTE_LEN (4+4+2+4) |
| Length of the interval header. | |
| #define | CORSARO_IO_INTERVAL_DATA_HEADER_BYTE_LEN (4+4+2) |
| Length of the data block header. | |
| #define | CORSARO_IO_TRAILER_BYTE_LEN (4+4+8+4+4+4+4) |
| Length of the corsaro trailer. | |
| #define | CORSARO_IO_PLUGIN_PATTERN "%P" |
| The pattern to replace in the output file name with the name of the plugin. | |
| #define | CORSARO_IO_GLOBAL_NAME "global" |
| The name to use for the global 'plugin' file. | |
| #define | CORSARO_IO_LOG_NAME "log" |
| The name to use for the log 'plugin' file. | |
Functions | |
| corsaro_file_t * | corsaro_io_prepare_file_full (corsaro_t *corsaro, const char *plugin_name, 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. | |
| corsaro_file_t * | corsaro_io_prepare_file (corsaro_t *corsaro, const char *plugin_name) |
| Uses the current settings to open an corsaro file for the given plugin. | |
| int | corsaro_io_validate_template (corsaro_t *corsaro, char *template) |
| Validates a output file template for needed features. | |
| off_t | corsaro_io_write_header (corsaro_t *corsaro, corsaro_file_t *file, corsaro_header_t *header) |
| Write the corsaro headers to the file. | |
| void | corsaro_io_print_header (corsaro_plugin_manager_t *plugin_manager, corsaro_header_t *header) |
| Write the corsaro headers to stdout. | |
| off_t | corsaro_io_write_trailer (corsaro_t *corsaro, corsaro_file_t *file, corsaro_trailer_t *trailer) |
| Write the corsaro trailers to the file. | |
| void | corsaro_io_print_trailer (corsaro_trailer_t *trailer) |
| Write the corsaro trailers to stdout. | |
| 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. | |
| void | corsaro_io_print_interval_start (corsaro_interval_t *int_start) |
| Write the interval headers to stdout. | |
| 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. | |
| void | corsaro_io_print_interval_end (corsaro_interval_t *int_end) |
| Write the interval trailers to stdout. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
Header file dealing with the corsaro file IO.
Definition in file corsaro_io.h.
| #define CORSARO_IO_GLOBAL_NAME "global" |
The name to use for the global 'plugin' file.
Definition at line 59 of file corsaro_io.h.
| #define CORSARO_IO_HEADER_FIXED_BYTE_LEN (4+4+1+1+4+2) |
Length of the fixed part of the global corsaro header.
Definition at line 45 of file corsaro_io.h.
Referenced by corsaro_io_read_header().
| #define CORSARO_IO_INTERVAL_DATA_HEADER_BYTE_LEN (4+4+2) |
Length of the data block header.
Definition at line 51 of file corsaro_io.h.
| #define CORSARO_IO_INTERVAL_HEADER_BYTE_LEN (4+4+2+4) |
Length of the interval header.
Definition at line 48 of file corsaro_io.h.
Referenced by corsaro_io_read_interval_end(), and corsaro_io_read_interval_start().
| #define CORSARO_IO_LOG_NAME "log" |
The name to use for the log 'plugin' file.
Definition at line 61 of file corsaro_io.h.
Referenced by corsaro_log_init().
| #define CORSARO_IO_PLUGIN_PATTERN "%P" |
The pattern to replace in the output file name with the name of the plugin.
Definition at line 57 of file corsaro_io.h.
Referenced by corsaro_io_validate_template().
| #define CORSARO_IO_TRAILER_BYTE_LEN (4+4+8+4+4+4+4) |
Length of the corsaro trailer.
Definition at line 54 of file corsaro_io.h.
| corsaro_file_t* corsaro_io_prepare_file | ( | corsaro_t * | corsaro, |
| const char * | plugin_name | ||
| ) |
Uses the current settings to open an corsaro file for the given plugin.
| corsaro | The corsaro object associated with the file |
| plugin_name | The name of the plugin (inserted into the template) |
Definition at line 635 of file corsaro_io.c.
References corsaro::compress, corsaro::compress_level, and corsaro::output_mode.
| corsaro_file_t* corsaro_io_prepare_file_full | ( | corsaro_t * | corsaro, |
| const char * | plugin_name, | ||
| 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.
| corsaro | The corsaro object associated with the file |
| plugin_name | The name of the plugin (inserted into the template) |
| mode | The corsaro file mode to use |
| compress | The corsaro file compression type to use |
| compress_level | The corsaro file compression level to use |
| flags | The flags to use when opening the file (e.g. O_CREAT) |
Definition at line 642 of file corsaro_io.c.
| void corsaro_io_print_header | ( | corsaro_plugin_manager_t * | plugin_manager, |
| corsaro_header_t * | header | ||
| ) |
Write the corsaro headers to stdout.
| header | The header to write out |
Definition at line 712 of file corsaro_io.c.
References corsaro_header::interval_length, corsaro_header::local_init_time, corsaro_header::plugin_cnt, corsaro_header::plugin_ids, corsaro_header::traceuri, corsaro_header::version_major, and corsaro_header::version_minor.
| void corsaro_io_print_interval_end | ( | corsaro_interval_t * | int_end | ) |
Write the interval trailers to stdout.
| int_end | The end interval to write out |
Definition at line 784 of file corsaro_io.c.
References corsaro_interval::number, and corsaro_interval::time.
| void corsaro_io_print_interval_start | ( | corsaro_interval_t * | int_start | ) |
Write the interval headers to stdout.
| int_start | The start interval to write out |
Definition at line 768 of file corsaro_io.c.
References corsaro_interval::number, and corsaro_interval::time.
| 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.
| record_type | The type of the record |
| record | The record to be written |
Definition at line 932 of file corsaro_io.c.
References corsaro_in_record::buffer, corsaro_dos_record_print(), corsaro_flowtuple_record_print(), CORSARO_IN_RECORD_TYPE_DISTRIBUTIONS_ELEMENT, CORSARO_IN_RECORD_TYPE_DISTRIBUTIONS_END, CORSARO_IN_RECORD_TYPE_DISTRIBUTIONS_START, CORSARO_IN_RECORD_TYPE_DOS_ATTACK_VECTOR, CORSARO_IN_RECORD_TYPE_DOS_GLOBAL_HEADER, CORSARO_IN_RECORD_TYPE_DOS_HEADER, CORSARO_IN_RECORD_TYPE_FLOWTUPLE_CLASS_END, CORSARO_IN_RECORD_TYPE_FLOWTUPLE_CLASS_START, CORSARO_IN_RECORD_TYPE_FLOWTUPLE_FLOWTUPLE, CORSARO_IN_RECORD_TYPE_IO_HEADER, CORSARO_IN_RECORD_TYPE_IO_INTERVAL_END, CORSARO_IN_RECORD_TYPE_IO_INTERVAL_START, CORSARO_IN_RECORD_TYPE_IO_PLUGIN_END, CORSARO_IN_RECORD_TYPE_IO_PLUGIN_START, CORSARO_IN_RECORD_TYPE_IO_TRAILER, CORSARO_IN_RECORD_TYPE_NULL, and corsaro_plugin_data::plugin_id.
| void corsaro_io_print_trailer | ( | corsaro_trailer_t * | trailer | ) |
Write the corsaro trailers to stdout.
| trailer | The trailer to write out |
Definition at line 744 of file corsaro_io.c.
References corsaro_trailer::first_packet_time, corsaro_trailer::last_packet_time, corsaro_trailer::local_final_time, corsaro_trailer::packet_cnt, and corsaro_trailer::runtime.
| 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.
| corsaro | The corsaro object to read from |
| record | The record to read into |
| len | The number of bytes to read |
Definition at line 1244 of file corsaro_io.c.
References corsaro_in_record::buffer, corsaro_in_record::buffer_len, and corsaro_in::file.
| 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.
| corsaro | The corsaro object to read from |
| record | The record to read into |
| offset | The offset into the record buffer to read data to |
| len | The number of bytes to read |
This function can be useful to store data that a record points to without actually having to malloc memory. Beware that the record buffer is a fixed size so don't use this for massive objects. Also remember to update the pointer in the record object to this data.
Definition at line 1253 of file corsaro_io.c.
References corsaro_in_record::buffer, corsaro_in_record::buffer_len, and corsaro_in::file.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro input file to read from |
Definition at line 1033 of file corsaro_io.c.
References corsaro_in_record::buffer, CORSARO_IN_RECORD_TYPE_IO_HEADER, CORSARO_IN_RECORD_TYPE_NULL, and CORSARO_IO_HEADER_FIXED_BYTE_LEN.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro input file to read from |
Definition at line 1187 of file corsaro_io.c.
References corsaro_in_record::buffer, CORSARO_IN_RECORD_TYPE_IO_INTERVAL_END, CORSARO_IN_RECORD_TYPE_NULL, and CORSARO_IO_INTERVAL_HEADER_BYTE_LEN.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro input file to read from |
Definition at line 1159 of file corsaro_io.c.
References corsaro_in_record::buffer, CORSARO_IN_RECORD_TYPE_IO_INTERVAL_START, CORSARO_IN_RECORD_TYPE_NULL, and CORSARO_IO_INTERVAL_HEADER_BYTE_LEN.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro input file to read from |
Definition at line 1230 of file corsaro_io.c.
References CORSARO_IN_RECORD_TYPE_IO_PLUGIN_END.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro input file to read from |
Definition at line 1215 of file corsaro_io.c.
References CORSARO_IN_RECORD_TYPE_IO_PLUGIN_START.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro input file to read from |
Definition at line 1133 of file corsaro_io.c.
References corsaro_in_record::buffer, CORSARO_IN_RECORD_TYPE_IO_TRAILER, and CORSARO_IN_RECORD_TYPE_NULL.
| int corsaro_io_validate_template | ( | corsaro_t * | corsaro, |
| char * | template | ||
| ) |
Validates a output file template for needed features.
| template | The file template to be validated |
Definition at line 674 of file corsaro_io.c.
References CORSARO_IO_PLUGIN_PATTERN.
| off_t corsaro_io_write_header | ( | corsaro_t * | corsaro, |
| corsaro_file_t * | file, | ||
| corsaro_header_t * | header | ||
| ) |
Write the corsaro headers to the file.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
| header | The header to write out (NULL to generate one) |
Definition at line 704 of file corsaro_io.c.
References CORSARO_FILE_MODE, CORSARO_FILE_MODE_ASCII, and CORSARO_FILE_MODE_BINARY.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
| int_end | The end interval to write out |
Definition at line 775 of file corsaro_io.c.
References CORSARO_FILE_MODE, CORSARO_FILE_MODE_ASCII, and CORSARO_FILE_MODE_BINARY.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
| int_start | The start interval to write out |
Definition at line 759 of file corsaro_io.c.
References CORSARO_FILE_MODE, CORSARO_FILE_MODE_ASCII, and CORSARO_FILE_MODE_BINARY.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
Definition at line 808 of file corsaro_io.c.
References CORSARO_FILE_MODE, CORSARO_FILE_MODE_ASCII, and CORSARO_FILE_MODE_BINARY.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
Definition at line 792 of file corsaro_io.c.
References CORSARO_FILE_MODE, CORSARO_FILE_MODE_ASCII, and CORSARO_FILE_MODE_BINARY.
| 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.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
| record_type | The type of the record |
| record | The record to be written |
change the switch to an array of function pointers, one for each type
add code to corsaro_file_open that creates a special 'stdout' file
Definition at line 828 of file corsaro_io.c.
References corsaro_in_record::buffer, corsaro_dos_record_fprint(), corsaro_flowtuple_record_fprint(), CORSARO_IN_RECORD_TYPE_DISTRIBUTIONS_ELEMENT, CORSARO_IN_RECORD_TYPE_DISTRIBUTIONS_END, CORSARO_IN_RECORD_TYPE_DISTRIBUTIONS_START, CORSARO_IN_RECORD_TYPE_DOS_ATTACK_VECTOR, CORSARO_IN_RECORD_TYPE_DOS_GLOBAL_HEADER, CORSARO_IN_RECORD_TYPE_DOS_HEADER, CORSARO_IN_RECORD_TYPE_FLOWTUPLE_CLASS_END, CORSARO_IN_RECORD_TYPE_FLOWTUPLE_CLASS_START, CORSARO_IN_RECORD_TYPE_FLOWTUPLE_FLOWTUPLE, CORSARO_IN_RECORD_TYPE_IO_HEADER, CORSARO_IN_RECORD_TYPE_IO_INTERVAL_END, CORSARO_IN_RECORD_TYPE_IO_INTERVAL_START, CORSARO_IN_RECORD_TYPE_IO_PLUGIN_END, CORSARO_IN_RECORD_TYPE_IO_PLUGIN_START, CORSARO_IN_RECORD_TYPE_IO_TRAILER, CORSARO_IN_RECORD_TYPE_NULL, corsaro_plugin_data::plugin_id, and corsaro::plugin_manager.
| off_t corsaro_io_write_trailer | ( | corsaro_t * | corsaro, |
| corsaro_file_t * | file, | ||
| corsaro_trailer_t * | trailer | ||
| ) |
Write the corsaro trailers to the file.
| corsaro | The corsaro object associated with the file |
| file | The corsaro output file to write to |
| trailer | The trailer to write out (NULL to generate one) |
Definition at line 735 of file corsaro_io.c.
References CORSARO_FILE_MODE, CORSARO_FILE_MODE_ASCII, and CORSARO_FILE_MODE_BINARY.