26 #ifndef __CORSARO_PLUGIN_H
27 #define __CORSARO_PLUGIN_H
44 #define CORSARO_PLUGIN_GENERATE_PROTOS(plugin) \
45 corsaro_plugin_t * plugin##_alloc(); \
46 int plugin##_probe_filename(const char *fname); \
47 int plugin##_probe_magic(struct corsaro_in * corsaro, corsaro_file_in_t *file); \
48 int plugin##_init_input(struct corsaro_in *corsaro); \
49 int plugin##_init_output(struct corsaro *corsaro); \
50 int plugin##_close_input(struct corsaro_in *corsaro); \
51 int plugin##_close_output(struct corsaro *corsaro); \
52 off_t plugin##_read_record(struct corsaro_in *corsaro, \
53 enum corsaro_in_record_type *record_type, \
54 struct corsaro_in_record *record); \
55 off_t plugin##_read_global_data_record(struct corsaro_in *corsaro, \
56 enum corsaro_in_record_type *record_type, \
57 struct corsaro_in_record *record); \
58 int plugin##_start_interval(struct corsaro *corsaro, \
59 struct corsaro_interval *int_start); \
60 int plugin##_end_interval(struct corsaro *corsaro, \
61 struct corsaro_interval *int_end); \
62 int plugin##_process_packet(struct corsaro *corsaro, \
63 struct corsaro_packet *packet);
65 #ifdef WITH_PLUGIN_SIXT
66 #define CORSARO_PLUGIN_GENERATE_FT_PROTO(plugin) \
67 int plugin##_process_flowtuple(struct corsaro *corsaro, \
68 corsaro_flowtuple_t *flowtuple, \
69 struct corsaro_packet_state *state); \
70 int plugin##_process_flowtuple_class_start(struct corsaro *corsaro, \
71 corsaro_flowtuple_class_start_t *class); \
72 int plugin##_process_flowtuple_class_end(struct corsaro *corsaro, \
73 corsaro_flowtuple_class_end_t *class);
84 #ifdef WITH_PLUGIN_SIXT
85 #define CORSARO_PLUGIN_GENERATE_PTRS(plugin) \
86 plugin##_probe_filename, \
87 plugin##_probe_magic, \
88 plugin##_init_input, \
89 plugin##_init_output, \
90 plugin##_close_input, \
91 plugin##_close_output, \
92 plugin##_read_record, \
93 plugin##_read_global_data_record, \
94 plugin##_start_interval, \
95 plugin##_end_interval, \
96 plugin##_process_packet, \
101 #define CORSARO_PLUGIN_GENERATE_PTRS_FT(plugin) \
102 plugin##_probe_filename, \
103 plugin##_probe_magic, \
104 plugin##_init_input, \
105 plugin##_init_output, \
106 plugin##_close_input, \
107 plugin##_close_output, \
108 plugin##_read_record, \
109 plugin##_read_global_data_record, \
110 plugin##_start_interval, \
111 plugin##_end_interval, \
112 plugin##_process_packet, \
113 plugin##_process_flowtuple, \
114 plugin##_process_flowtuple_class_start, \
115 plugin##_process_flowtuple_class_end
117 #define CORSARO_PLUGIN_GENERATE_PTRS(plugin) \
118 plugin##_probe_filename, \
119 plugin##_probe_magic, \
120 plugin##_init_input, \
121 plugin##_init_output, \
122 plugin##_close_input, \
123 plugin##_close_output, \
124 plugin##_read_record, \
125 plugin##_read_global_data_record, \
126 plugin##_start_interval, \
127 plugin##_end_interval, \
128 plugin##_process_packet
138 #define CORSARO_PLUGIN_GENERATE_TAIL \
147 #define CORSARO_PLUGIN_STATE(corsaro, type, id) \
148 ((struct corsaro_##type##_state_t*) \
149 ((corsaro)->plugin_manager->plugins_state[(id)-1]))
155 #define CORSARO_PLUGIN_PLUGIN(corsaro, id) \
156 ((corsaro)->plugin_manager->plugins[(id)-1])
332 #ifdef WITH_PLUGIN_SIXT
344 corsaro_flowtuple_t *flowtuple,
358 corsaro_flowtuple_class_start_t *
class);
371 corsaro_flowtuple_class_end_t *
class);
551 const char *plugin_name,
552 const char *plugin_args);
Structure representing the start or end of an interval.
An opaque structure defining an corsaro input file.
int corsaro_plugin_is_enabled(corsaro_plugin_manager_t *manager, corsaro_plugin_t *plugin)
Determine whether this plugin is enabled for use.
const char * name
The name of this plugin used in the ascii output and eventually to allow plugins to be enabled and di...
enum corsaro_plugin_id corsaro_plugin_id_t
A unique identifier for a plugin, used when writing binary data.
An opaque structure defining an corsaro output file.
A reusable opaque structure for corsaro to read an input record into.
int(* close_input)(struct corsaro_in *corsaro)
Concludes an input file and cleans up the plugin data.
char ** argv
Array of plugin arguments This is populated by the plugin manager in corsaro_plugin_enable_plugin.
int(* close_output)(struct corsaro *corsaro)
Concludes an output file and cleans up the plugin data.
int corsaro_plugin_enable_plugin(corsaro_plugin_manager_t *manager, const char *plugin_name, const char *plugin_args)
Attempt to enable a plugin by its name.
corsaro_plugin_t * corsaro_plugin_next(corsaro_plugin_manager_t *manager, corsaro_plugin_t *plugin)
Retrieve the next plugin in the list.
uint16_t plugins_cnt
The number of active plugins.
static libtrace_packet_t * packet
A pointer to a libtrace packet.
void corsaro_plugin_free_state(corsaro_plugin_manager_t *manager, corsaro_plugin_t *plugin)
Free the state for a plugin.
corsaro_plugin_t * corsaro_plugin_get_by_magic(corsaro_plugin_manager_t *manager, uint32_t id)
Attempt to retrieve a plugin by magic number (not by using magic)
void ** plugins_state
A pointer to the array of plugin states.
uint16_t * plugins_enabled
An array of plugin ids that have been enabled by the user.
A lightweight wrapper around a libtrace packet.
void corsaro_plugin_manager_free(corsaro_plugin_manager_t *manager)
Free the plugin manager and all in-use plugins.
Holds the metadata for the plugin manager.
corsaro_in_record_type
Corsaro input record types.
int corsaro_plugin_manager_start(corsaro_plugin_manager_t *manager)
Start the plugin manager.
const char * corsaro_plugin_get_name_by_id(corsaro_plugin_manager_t *manager, int id)
Get the name of a plugin given it's ID number.
void corsaro_plugin_register_state(corsaro_plugin_manager_t *manager, corsaro_plugin_t *plugin, void *state)
Register the state for a plugin.
int corsaro_plugin_probe_filename(const char *fname, corsaro_plugin_t *plugin)
Check a filename to see if it contains a plugin's name.
const char * corsaro_plugin_get_name_by_magic(corsaro_plugin_manager_t *manager, uint32_t magic)
Get the name of a plugin given it's magic number.
int(* init_output)(struct corsaro *corsaro)
Initialises an output file using the plugin.
static corsaro_in_record_t * record
A pointer to a corsaro record.
int argc
Count of arguments in argv.
Geolocation Database Lookup Plugin.
corsaro_plugin_manager_t * corsaro_plugin_manager_init()
Initialize the plugin manager and all in-use plugins.
int(* probe_filename)(const char *fname)
Given a filename, return if this is the most likely plugin.
static corsaro_t * corsaro
A pointer to the instance of corsaro that we will drive.
int(* start_interval)(struct corsaro *corsaro, struct corsaro_interval *int_start)
Starts a new interval.
const corsaro_plugin_id_t id
The corsaro plugin id for this plugin.
CAIDA Prefix2AS lookup plugin.
struct corsaro_plugin corsaro_plugin_t
An corsaro packet processing plugin.
corsaro_plugin_t * corsaro_plugin_get_by_id(corsaro_plugin_manager_t *manager, int id)
Attempt to retrieve a plugin by id.
struct corsaro_plugin * next
Next pointer, should always be NULL - used by the plugin manager.
static int process_flowtuple(corsaro_flowtuple_t *tuple)
Process a FlowTuple record.
IP address anonymization plugin.
corsaro_plugin_t * corsaro_plugin_get_by_name(corsaro_plugin_manager_t *manager, const char *name)
Attempt to retrieve a plugin by name.
int(* end_interval)(struct corsaro *corsaro, struct corsaro_interval *int_end)
Ends an interval.
corsaro_plugin_t ** plugins
A pointer to the array of plugins in use.
int(* process_packet)(struct corsaro *corsaro, struct corsaro_packet *packet)
Process a packet.
Corsaro state for a packet.
uint16_t plugins_enabled_cnt
The number of plugin ids in the plugins_enabled array.
corsaro_plugin_id
A unique identifier for a plugin, used when writing binary data.
Maximum plugin ID assigned.
off_t(* read_global_data_record)(struct corsaro_in *corsaro, enum corsaro_in_record_type *record_type, struct corsaro_in_record *record)
Reads a plugin global data block from an input file.
int(* init_input)(struct corsaro_in *corsaro)
Initialises an input file using the plugin.
struct corsaro_plugin_manager corsaro_plugin_manager_t
Holds the metadata for the plugin manager.
const uint32_t magic
The magic number for this plugin's data.
corsaro_file_t * logfile
A pointer to the logfile to use.
corsaro_plugin_t * first_plugin
A pointer to the first plugin in the list.
Pass-through PCAP plugin.
An corsaro packet processing plugin.
int(* probe_magic)(struct corsaro_in *corsaro, corsaro_file_in_t *file)
Given a file, looks at next 4 bytes to determine if this is the right plugin.
off_t(* read_record)(struct corsaro_in *corsaro, enum corsaro_in_record_type *record_type, struct corsaro_in_record *record)
Reads the next block of plugin data from an input file.
corsaro_file_in_t * file
The corsaro input file to read data from.
Header file dealing with the internal corsaro functions.