Skip to Content
[CAIDA - Center for Applied Internet Data Analysis logo]
The Center for Applied Internet Data Analysis
corsaro_smee.c File Reference

Corsaro plugin wrapper for the iat-smee 'library'. More...

Go to the source code of this file.

Macros

#define CORSARO_SMEE_MAGIC   0x534D4545
 The magic number for this plugin - "SMEE". More...
 
#define PLUGIN_NAME   "smee"
 The name of this plugin. More...
 
#define CORSARO_SMEE_STATFILE   PLUGIN_NAME"-stat"
 The name for the stat file. More...
 
#define CORSARO_SMEE_SUMFILE   PLUGIN_NAME"-sum"
 The name for the sum file. More...
 
#define CORSARO_SMEE_SRCFILE   PLUGIN_NAME"-sources"
 The name for the src file. More...
 
#define CORSARO_SMEE_MX_LIFETIME   3600
 Default max lifetime for source to stay in hashtable. More...
 
#define CORSARO_SMEE_MX_SOURCES   4000000
 Default memory size allocated for source hash table (in KB) More...
 
#define CORSARO_SMEE_TIME_REC_INTERVAL   3600
 Default interval in seconds to write summary files. More...
 
#define STATE(corsaro)   (CORSARO_PLUGIN_STATE(corsaro, smee, CORSARO_PLUGIN_ID_SMEE))
 Extends the generic plugin state convenience macro in corsaro_plugin.h. More...
 
#define PLUGIN(corsaro)   (CORSARO_PLUGIN_PLUGIN(corsaro, CORSARO_PLUGIN_ID_SMEE))
 Extends the generic plugin plugin convenience macro in corsaro_plugin.h. More...
 
#define CORSARO_SMEE_FPRINTF(outfile)
 Helper macro for IO callbacks to write to a Corsaro file. More...
 

Functions

static int parse_local_address (corsaro_t *corsaro, char *address_str)
 Parse a local address prefix. More...
 
static void usage (corsaro_t *corsaro)
 Print plugin usage to stderr. More...
 
static int parse_args (corsaro_t *corsaro)
 Parse the arguments given to the plugin. More...
 
static void smee_log_callback (void *user_data, int priority, int die, const char *fmt,...)
 Called by smee to log messages. More...
 
static int smee_stat_callback (void *user_data, const char *fmt,...)
 Called by smee to write stats lines. More...
 
static int smee_sum_callback (void *user_data, const char *fmt,...)
 Called by smee to populate the summary file. More...
 
static int smee_sources_callback (void *user_data, const char *fmt,...)
 Called by smee to populate the sources file. More...
 
static uint64_t smee_pkt_drops (void *user_data)
 Called by smee to determine the number of dropped packets. More...
 
corsaro_plugin_tcorsaro_smee_alloc (corsaro_t *corsaro)
 Implements the alloc function of the plugin API. More...
 
int corsaro_smee_probe_filename (const char *fname)
 Implements the probe_filename function of the plugin API. More...
 
int corsaro_smee_probe_magic (corsaro_in_t *corsaro, corsaro_file_in_t *file)
 Implements the probe_magic function of the plugin API. More...
 
int corsaro_smee_init_output (corsaro_t *corsaro)
 Implements the init_output function of the plugin API. More...
 
int corsaro_smee_init_input (corsaro_in_t *corsaro)
 Implements the init_input function of the plugin API. More...
 
int corsaro_smee_close_input (corsaro_in_t *corsaro)
 Implements the close_input function of the plugin API. More...
 
int corsaro_smee_close_output (corsaro_t *corsaro)
 Implements the close_output function of the plugin API. More...
 
off_t corsaro_smee_read_record (struct corsaro_in *corsaro, corsaro_in_record_type_t *record_type, corsaro_in_record_t *record)
 Implements the read_record function of the plugin API. More...
 
off_t corsaro_smee_read_global_data_record (struct corsaro_in *corsaro, enum corsaro_in_record_type *record_type, struct corsaro_in_record *record)
 Implements the read_global_data_record function of the plugin API. More...
 
int corsaro_smee_start_interval (corsaro_t *corsaro, corsaro_interval_t *int_start)
 Implements the start_interval function of the plugin API. More...
 
int corsaro_smee_end_interval (corsaro_t *corsaro, corsaro_interval_t *int_end)
 Implements the end_interval function of the plugin API. More...
 
int corsaro_smee_process_packet (corsaro_t *corsaro, corsaro_packet_t *packet)
 Implements the process_packet function of the plugin API. More...
 

Variables

static corsaro_plugin_t corsaro_smee_plugin
 Common plugin information across all instances. More...
 

Detailed Description

Corsaro plugin wrapper for the iat-smee 'library'.

Author
Alistair King

Definition in file corsaro_smee.c.

Macro Definition Documentation

#define CORSARO_SMEE_FPRINTF (   outfile)
Value:
va_list ap; \
corsaro_t *corsaro = (corsaro_t*)user_data; \
va_start(ap, fmt); \
corsaro_file_vprintf(corsaro, (outfile), fmt, ap); \
/* smee expects a newline to be written. \
this is a little hacky, but... */ \
corsaro_file_printf(corsaro, (outfile), "\n"); \
va_end(ap); \
return 0;
off_t corsaro_file_printf(struct corsaro *corsaro, corsaro_file_t *file, const char *format,...)
Print a string to an corsaro file.
Definition: corsaro_file.c:214
off_t corsaro_file_vprintf(struct corsaro *corsaro, corsaro_file_t *file, const char *format, va_list args)
Print a string to an corsaro file.
Definition: corsaro_file.c:200
Corsaro output state.
Definition: corsaro_int.h:230
struct corsaro corsaro_t
Opaque struct holding corsaro output state.
Definition: corsaro.h:48

Helper macro for IO callbacks to write to a Corsaro file.

Definition at line 281 of file corsaro_smee.c.

Referenced by smee_sources_callback(), smee_stat_callback(), and smee_sum_callback().

#define CORSARO_SMEE_MAGIC   0x534D4545

The magic number for this plugin - "SMEE".

Definition at line 60 of file corsaro_smee.c.

#define CORSARO_SMEE_MX_LIFETIME   3600

Default max lifetime for source to stay in hashtable.

Definition at line 73 of file corsaro_smee.c.

Referenced by corsaro_smee_init_output(), and usage().

#define CORSARO_SMEE_MX_SOURCES   4000000

Default memory size allocated for source hash table (in KB)

Definition at line 75 of file corsaro_smee.c.

Referenced by corsaro_smee_init_output(), and usage().

#define CORSARO_SMEE_SRCFILE   PLUGIN_NAME"-sources"

The name for the src file.

Definition at line 70 of file corsaro_smee.c.

Referenced by corsaro_smee_start_interval().

#define CORSARO_SMEE_STATFILE   PLUGIN_NAME"-stat"

The name for the stat file.

Definition at line 66 of file corsaro_smee.c.

Referenced by corsaro_smee_start_interval().

#define CORSARO_SMEE_SUMFILE   PLUGIN_NAME"-sum"

The name for the sum file.

Definition at line 68 of file corsaro_smee.c.

Referenced by corsaro_smee_start_interval().

#define CORSARO_SMEE_TIME_REC_INTERVAL   3600

Default interval in seconds to write summary files.

Definition at line 77 of file corsaro_smee.c.

Referenced by corsaro_smee_init_output(), and usage().

Extends the generic plugin plugin convenience macro in corsaro_plugin.h.

Definition at line 121 of file corsaro_smee.c.

Referenced by corsaro_smee_close_output(), corsaro_smee_init_output(), parse_args(), and usage().

#define PLUGIN_NAME   "smee"

The name of this plugin.

Definition at line 63 of file corsaro_smee.c.

Function Documentation

corsaro_plugin_t* corsaro_smee_alloc ( corsaro_t corsaro)

Implements the alloc function of the plugin API.

Definition at line 320 of file corsaro_smee.c.

References corsaro_smee_plugin.

int corsaro_smee_close_input ( corsaro_in_t corsaro)

Implements the close_input function of the plugin API.

Definition at line 436 of file corsaro_smee.c.

int corsaro_smee_close_output ( corsaro_t corsaro)

Implements the close_output function of the plugin API.

Definition at line 442 of file corsaro_smee.c.

References corsaro_file_close(), corsaro_plugin_free_state(), PLUGIN, corsaro::plugin_manager, and STATE.

Referenced by corsaro_smee_init_output(), and corsaro_smee_start_interval().

int corsaro_smee_end_interval ( corsaro_t corsaro,
corsaro_interval_t int_end 
)

Implements the end_interval function of the plugin API.

Definition at line 574 of file corsaro_smee.c.

References corsaro_is_rotate_interval(), and STATE.

int corsaro_smee_init_input ( corsaro_in_t corsaro)

Implements the init_input function of the plugin API.

Definition at line 430 of file corsaro_smee.c.

int corsaro_smee_probe_filename ( const char *  fname)

Implements the probe_filename function of the plugin API.

Definition at line 326 of file corsaro_smee.c.

References corsaro_plugin_probe_filename().

int corsaro_smee_probe_magic ( corsaro_in_t corsaro,
corsaro_file_in_t file 
)

Implements the probe_magic function of the plugin API.

Definition at line 333 of file corsaro_smee.c.

int corsaro_smee_process_packet ( corsaro_t corsaro,
corsaro_packet_t packet 
)

Implements the process_packet function of the plugin API.

Definition at line 594 of file corsaro_smee.c.

References corsaro_log(), LT_PKT, and STATE.

off_t corsaro_smee_read_global_data_record ( struct corsaro_in corsaro,
enum corsaro_in_record_type record_type,
struct corsaro_in_record record 
)

Implements the read_global_data_record function of the plugin API.

Definition at line 494 of file corsaro_smee.c.

off_t corsaro_smee_read_record ( struct corsaro_in corsaro,
corsaro_in_record_type_t record_type,
corsaro_in_record_t record 
)

Implements the read_record function of the plugin API.

Definition at line 485 of file corsaro_smee.c.

References corsaro_log_in().

int corsaro_smee_start_interval ( corsaro_t corsaro,
corsaro_interval_t int_start 
)

Implements the start_interval function of the plugin API.

Definition at line 503 of file corsaro_smee.c.

References corsaro_file_close(), corsaro_io_prepare_file(), corsaro_log(), corsaro_smee_close_output(), CORSARO_SMEE_SRCFILE, CORSARO_SMEE_STATFILE, CORSARO_SMEE_SUMFILE, and STATE.

static int parse_args ( corsaro_t corsaro)
static

Parse the arguments given to the plugin.

Todo:
upgrade the address parsing to support IPv6

Definition at line 202 of file corsaro_smee.c.

References corsaro_plugin::argc, corsaro_plugin::argv, parse_local_address(), PLUGIN, STATE, and usage().

Referenced by corsaro_smee_init_output().

static int parse_local_address ( corsaro_t corsaro,
char *  address_str 
)
static

Parse a local address prefix.

Definition at line 125 of file corsaro_smee.c.

References STATE.

Referenced by parse_args().

static void smee_log_callback ( void *  user_data,
int  priority,
int  die,
const char *  fmt,
  ... 
)
static

Called by smee to log messages.

Definition at line 266 of file corsaro_smee.c.

References corsaro_log_va().

Referenced by corsaro_smee_init_output().

static uint64_t smee_pkt_drops ( void *  user_data)
static

Called by smee to determine the number of dropped packets.

Definition at line 311 of file corsaro_smee.c.

References corsaro_get_dropped_packets().

Referenced by corsaro_smee_init_output().

static int smee_sources_callback ( void *  user_data,
const char *  fmt,
  ... 
)
static

Called by smee to populate the sources file.

Definition at line 305 of file corsaro_smee.c.

References CORSARO_SMEE_FPRINTF, and STATE.

Referenced by corsaro_smee_init_output().

static int smee_stat_callback ( void *  user_data,
const char *  fmt,
  ... 
)
static

Called by smee to write stats lines.

Definition at line 293 of file corsaro_smee.c.

References CORSARO_SMEE_FPRINTF, and STATE.

Referenced by corsaro_smee_init_output().

static int smee_sum_callback ( void *  user_data,
const char *  fmt,
  ... 
)
static

Called by smee to populate the summary file.

Definition at line 299 of file corsaro_smee.c.

References CORSARO_SMEE_FPRINTF, and STATE.

Referenced by corsaro_smee_init_output().

static void usage ( corsaro_t corsaro)
static

Print plugin usage to stderr.

Definition at line 175 of file corsaro_smee.c.

References corsaro_get_monitorname(), CORSARO_SMEE_MX_LIFETIME, CORSARO_SMEE_MX_SOURCES, CORSARO_SMEE_TIME_REC_INTERVAL, and PLUGIN.

Referenced by parse_args().

Variable Documentation

corsaro_plugin_t corsaro_smee_plugin
static
Initial value:
= {
}
#define CORSARO_SMEE_MAGIC
The magic number for this plugin - "SMEE".
Definition: corsaro_smee.c:60
#define CORSARO_PLUGIN_GENERATE_PTRS(plugin)
Convenience macro that defines all the function pointers for the corsaro plugin API.
#define CORSARO_PLUGIN_GENERATE_TAIL
Convenience macro that defines all the 'remaining' blank fields in a corsaro plugin object...
#define PLUGIN_NAME
The name of this plugin.
Definition: corsaro_smee.c:63

Common plugin information across all instances.

Definition at line 80 of file corsaro_smee.c.

Referenced by corsaro_smee_alloc().