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

Corsaro FlowTuple Reporting plugin. More...

Go to the source code of this file.

Macros

#define CORSARO_ANON_MAGIC   0x4647454F
 The magic number for this plugin - "FGEO". More...
 
#define PLUGIN_NAME   "filtergeo"
 The name of this plugin. More...
 
#define BUFFER_LEN   1024
 The length of the static line buffer. More...
 
#define MAX_COMMAND_LINE_COUNTRIES   100
 The max number of countries which can be supplied on the command line, if you have more than this, just use a file... More...
 
#define STATE(corsaro)   (CORSARO_PLUGIN_STATE(corsaro, filtergeo, CORSARO_PLUGIN_ID_FILTERGEO))
 Extends the generic plugin state convenience macro in corsaro_plugin.h. More...
 
#define PLUGIN(corsaro)   (CORSARO_PLUGIN_PLUGIN(corsaro, CORSARO_PLUGIN_ID_FILTERGEO))
 Extends the generic plugin plugin convenience macro in corsaro_plugin.h. More...
 

Functions

static void usage (corsaro_plugin_t *plugin)
 Print usage information to stderr. More...
 
static int parse_args (corsaro_t *corsaro)
 Parse the arguments given to the plugin. More...
 
static int add_country (corsaro_t *corsaro, char *cc_str)
 Parse a country code string and add it to the hash. More...
 
static int read_country_file (corsaro_t *corsaro, corsaro_file_in_t *file)
 Read a file containing a list of country codes. More...
 
static void process_generic (corsaro_t *corsaro, corsaro_packet_state_t *state)
 Common code between process_packet and process_flowtuple. More...
 
static void str_free (const char *str)
 Free a string (used to clear the hash) More...
 
corsaro_plugin_tcorsaro_filtergeo_alloc (corsaro_t *corsaro)
 Implements the alloc function of the plugin API. More...
 
int corsaro_filtergeo_probe_filename (const char *fname)
 Implements the probe_filename function of the plugin API. More...
 
int corsaro_filtergeo_probe_magic (corsaro_in_t *corsaro, corsaro_file_in_t *file)
 Implements the probe_magic function of the plugin API. More...
 
int corsaro_filtergeo_init_output (corsaro_t *corsaro)
 Implements the init_output function of the plugin API. More...
 
int corsaro_filtergeo_init_input (corsaro_in_t *corsaro)
 Implements the init_input function of the plugin API. More...
 
int corsaro_filtergeo_close_input (corsaro_in_t *corsaro)
 Implements the close_input function of the plugin API. More...
 
int corsaro_filtergeo_close_output (corsaro_t *corsaro)
 Implements the close_output function of the plugin API. More...
 
off_t corsaro_filtergeo_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_filtergeo_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_filtergeo_start_interval (corsaro_t *corsaro, corsaro_interval_t *int_start)
 Implements the start_interval function of the plugin API. More...
 
int corsaro_filtergeo_end_interval (corsaro_t *corsaro, corsaro_interval_t *int_end)
 Implements the end_interval function of the plugin API. More...
 
int corsaro_filtergeo_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_filtergeo_plugin
 Common plugin information across all instances. More...
 

Detailed Description

Corsaro FlowTuple Reporting plugin.

Author
Alistair King

Definition in file corsaro_filtergeo.c.

Macro Definition Documentation

#define BUFFER_LEN   1024

The length of the static line buffer.

Definition at line 67 of file corsaro_filtergeo.c.

Referenced by add_country(), and read_country_file().

#define CORSARO_ANON_MAGIC   0x4647454F

The magic number for this plugin - "FGEO".

Definition at line 61 of file corsaro_filtergeo.c.

#define MAX_COMMAND_LINE_COUNTRIES   100

The max number of countries which can be supplied on the command line, if you have more than this, just use a file...

Definition at line 71 of file corsaro_filtergeo.c.

Referenced by parse_args(), and usage().

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

Definition at line 113 of file corsaro_filtergeo.c.

Referenced by corsaro_filtergeo_close_output(), corsaro_filtergeo_init_output(), and parse_args().

#define PLUGIN_NAME   "filtergeo"

The name of this plugin.

Definition at line 64 of file corsaro_filtergeo.c.

#define STATE (   corsaro)    (CORSARO_PLUGIN_STATE(corsaro, filtergeo, CORSARO_PLUGIN_ID_FILTERGEO))

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

Definition at line 109 of file corsaro_filtergeo.c.

Referenced by add_country(), corsaro_filtergeo_close_output(), parse_args(), and process_generic().

Function Documentation

static int add_country ( corsaro_t corsaro,
char *  cc_str 
)
static

Parse a country code string and add it to the hash.

Definition at line 197 of file corsaro_filtergeo.c.

References BUFFER_LEN, corsaro_log(), and STATE.

Referenced by corsaro_filtergeo_init_output(), and read_country_file().

corsaro_plugin_t* corsaro_filtergeo_alloc ( corsaro_t corsaro)

Implements the alloc function of the plugin API.

Definition at line 303 of file corsaro_filtergeo.c.

References corsaro_filtergeo_plugin.

int corsaro_filtergeo_close_input ( corsaro_in_t corsaro)

Implements the close_input function of the plugin API.

Definition at line 396 of file corsaro_filtergeo.c.

int corsaro_filtergeo_close_output ( corsaro_t corsaro)

Implements the close_output function of the plugin API.

Definition at line 403 of file corsaro_filtergeo.c.

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

Referenced by corsaro_filtergeo_init_output().

int corsaro_filtergeo_end_interval ( corsaro_t corsaro,
corsaro_interval_t int_end 
)

Implements the end_interval function of the plugin API.

Definition at line 449 of file corsaro_filtergeo.c.

int corsaro_filtergeo_init_input ( corsaro_in_t corsaro)

Implements the init_input function of the plugin API.

Definition at line 389 of file corsaro_filtergeo.c.

int corsaro_filtergeo_init_output ( corsaro_t corsaro)
int corsaro_filtergeo_probe_filename ( const char *  fname)

Implements the probe_filename function of the plugin API.

Definition at line 309 of file corsaro_filtergeo.c.

int corsaro_filtergeo_probe_magic ( corsaro_in_t corsaro,
corsaro_file_in_t file 
)

Implements the probe_magic function of the plugin API.

Definition at line 316 of file corsaro_filtergeo.c.

int corsaro_filtergeo_process_packet ( corsaro_t corsaro,
corsaro_packet_t packet 
)

Implements the process_packet function of the plugin API.

Definition at line 457 of file corsaro_filtergeo.c.

References process_generic(), and corsaro_packet::state.

off_t corsaro_filtergeo_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 432 of file corsaro_filtergeo.c.

off_t corsaro_filtergeo_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 423 of file corsaro_filtergeo.c.

int corsaro_filtergeo_start_interval ( corsaro_t corsaro,
corsaro_interval_t int_start 
)

Implements the start_interval function of the plugin API.

Definition at line 441 of file corsaro_filtergeo.c.

static int parse_args ( corsaro_t corsaro)
static

Parse the arguments given to the plugin.

Definition at line 131 of file corsaro_filtergeo.c.

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

Referenced by corsaro_filtergeo_init_output().

static void process_generic ( corsaro_t corsaro,
corsaro_packet_state_t state 
)
static
static int read_country_file ( corsaro_t corsaro,
corsaro_file_in_t file 
)
static

Read a file containing a list of country codes.

Definition at line 221 of file corsaro_filtergeo.c.

References add_country(), BUFFER_LEN, chomp(), and corsaro_file_rgets().

Referenced by corsaro_filtergeo_init_output().

static void str_free ( const char *  str)
inlinestatic

Free a string (used to clear the hash)

Definition at line 295 of file corsaro_filtergeo.c.

Referenced by corsaro_filtergeo_close_output().

static void usage ( corsaro_plugin_t plugin)
static

Print usage information to stderr.

Definition at line 117 of file corsaro_filtergeo.c.

References corsaro_plugin::argv, and MAX_COMMAND_LINE_COUNTRIES.

Referenced by parse_args().

Variable Documentation

corsaro_plugin_t corsaro_filtergeo_plugin
static
Initial value:
= {
CORSARO_PLUGIN_GENERATE_PTRS(corsaro_filtergeo),
}
#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 CORSARO_ANON_MAGIC
The magic number for this plugin - "FGEO".
#define PLUGIN_NAME
The name of this plugin.

Common plugin information across all instances.

Definition at line 74 of file corsaro_filtergeo.c.

Referenced by corsaro_filtergeo_alloc().