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

Corsaro Prefix Filter plugin. More...

Go to the source code of this file.

Macros

#define CORSARO_FILTERPFX_MAGIC   0x46504658
 The magic number for this plugin - "FPFX". More...
 
#define PLUGIN_NAME   "filterpfx"
 The name of this plugin. More...
 
#define BUFFER_LEN   1024
 The length of the static line buffer. More...
 
#define MAX_COMMAND_LINE_PREFIXES   100
 The max number of prefixes 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, filterpfx, CORSARO_PLUGIN_ID_FILTERPFX))
 Extends the generic plugin state convenience macro in corsaro_plugin.h. More...
 
#define PLUGIN(corsaro)   (CORSARO_PLUGIN_PLUGIN(corsaro, CORSARO_PLUGIN_ID_FILTERPFX))
 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_prefix (corsaro_t *corsaro, char *pfx_str)
 Parse a prefix string and add it to the trie. More...
 
static int read_pfx_file (corsaro_t *corsaro, corsaro_file_in_t *file)
 Read a file containing a list of prefixes. More...
 
static int process_generic (corsaro_t *corsaro, corsaro_packet_state_t *state, uint32_t ip_addr)
 Common code between process_packet and process_flowtuple. More...
 
corsaro_plugin_tcorsaro_filterpfx_alloc (corsaro_t *corsaro)
 Implements the alloc function of the plugin API. More...
 
int corsaro_filterpfx_probe_filename (const char *fname)
 Implements the probe_filename function of the plugin API. More...
 
int corsaro_filterpfx_probe_magic (corsaro_in_t *corsaro, corsaro_file_in_t *file)
 Implements the probe_magic function of the plugin API. More...
 
int corsaro_filterpfx_init_output (corsaro_t *corsaro)
 Implements the init_output function of the plugin API. More...
 
int corsaro_filterpfx_init_input (corsaro_in_t *corsaro)
 Implements the init_input function of the plugin API. More...
 
int corsaro_filterpfx_close_input (corsaro_in_t *corsaro)
 Implements the close_input function of the plugin API. More...
 
int corsaro_filterpfx_close_output (corsaro_t *corsaro)
 Implements the close_output function of the plugin API. More...
 
off_t corsaro_filterpfx_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_filterpfx_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_filterpfx_start_interval (corsaro_t *corsaro, corsaro_interval_t *int_start)
 Implements the start_interval function of the plugin API. More...
 
int corsaro_filterpfx_end_interval (corsaro_t *corsaro, corsaro_interval_t *int_end)
 Implements the end_interval function of the plugin API. More...
 
int corsaro_filterpfx_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_filterpfx_plugin
 Common plugin information across all instances. More...
 

Detailed Description

Corsaro Prefix Filter plugin.

Author
Alistair King

Definition in file corsaro_filterpfx.c.

Macro Definition Documentation

#define BUFFER_LEN   1024

The length of the static line buffer.

Definition at line 67 of file corsaro_filterpfx.c.

Referenced by read_pfx_file().

#define CORSARO_FILTERPFX_MAGIC   0x46504658

The magic number for this plugin - "FPFX".

Definition at line 61 of file corsaro_filterpfx.c.

#define MAX_COMMAND_LINE_PREFIXES   100

The max number of prefixes 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_filterpfx.c.

Referenced by parse_args(), and usage().

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

Definition at line 108 of file corsaro_filterpfx.c.

Referenced by corsaro_filterpfx_close_output(), corsaro_filterpfx_init_output(), and parse_args().

#define PLUGIN_NAME   "filterpfx"

The name of this plugin.

Definition at line 64 of file corsaro_filterpfx.c.

#define STATE (   corsaro)    (CORSARO_PLUGIN_STATE(corsaro, filterpfx, CORSARO_PLUGIN_ID_FILTERPFX))

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

Definition at line 104 of file corsaro_filterpfx.c.

Referenced by add_prefix(), corsaro_filterpfx_close_output(), corsaro_filterpfx_process_packet(), parse_args(), and process_generic().

Function Documentation

static int add_prefix ( corsaro_t corsaro,
char *  pfx_str 
)
static

Parse a prefix string and add it to the trie.

Definition at line 194 of file corsaro_filterpfx.c.

References corsaro_log(), and STATE.

Referenced by corsaro_filterpfx_init_output(), and read_pfx_file().

corsaro_plugin_t* corsaro_filterpfx_alloc ( corsaro_t corsaro)

Implements the alloc function of the plugin API.

Definition at line 275 of file corsaro_filterpfx.c.

References corsaro_filterpfx_plugin.

int corsaro_filterpfx_close_input ( corsaro_in_t corsaro)

Implements the close_input function of the plugin API.

Definition at line 380 of file corsaro_filterpfx.c.

int corsaro_filterpfx_close_output ( corsaro_t corsaro)

Implements the close_output function of the plugin API.

Definition at line 387 of file corsaro_filterpfx.c.

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

int corsaro_filterpfx_end_interval ( corsaro_t corsaro,
corsaro_interval_t int_end 
)

Implements the end_interval function of the plugin API.

Definition at line 429 of file corsaro_filterpfx.c.

int corsaro_filterpfx_init_input ( corsaro_in_t corsaro)

Implements the init_input function of the plugin API.

Definition at line 373 of file corsaro_filterpfx.c.

int corsaro_filterpfx_init_output ( corsaro_t corsaro)
int corsaro_filterpfx_probe_filename ( const char *  fname)

Implements the probe_filename function of the plugin API.

Definition at line 281 of file corsaro_filterpfx.c.

int corsaro_filterpfx_probe_magic ( corsaro_in_t corsaro,
corsaro_file_in_t file 
)

Implements the probe_magic function of the plugin API.

Definition at line 288 of file corsaro_filterpfx.c.

int corsaro_filterpfx_process_packet ( corsaro_t corsaro,
corsaro_packet_t packet 
)

Implements the process_packet function of the plugin API.

Definition at line 437 of file corsaro_filterpfx.c.

References LT_PKT, process_generic(), STATE, and corsaro_packet::state.

off_t corsaro_filterpfx_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 412 of file corsaro_filterpfx.c.

off_t corsaro_filterpfx_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 403 of file corsaro_filterpfx.c.

int corsaro_filterpfx_start_interval ( corsaro_t corsaro,
corsaro_interval_t int_start 
)

Implements the start_interval function of the plugin API.

Definition at line 421 of file corsaro_filterpfx.c.

static int parse_args ( corsaro_t corsaro)
static

Parse the arguments given to the plugin.

Definition at line 126 of file corsaro_filterpfx.c.

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

Referenced by corsaro_filterpfx_init_output().

static int process_generic ( corsaro_t corsaro,
corsaro_packet_state_t state,
uint32_t  ip_addr 
)
static

Common code between process_packet and process_flowtuple.

Definition at line 241 of file corsaro_filterpfx.c.

References CORSARO_PACKET_STATE_IGNORE, corsaro_packet_state::flags, and STATE.

Referenced by corsaro_filterpfx_process_packet().

static int read_pfx_file ( corsaro_t corsaro,
corsaro_file_in_t file 
)
static

Read a file containing a list of prefixes.

Definition at line 222 of file corsaro_filterpfx.c.

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

Referenced by corsaro_filterpfx_init_output().

static void usage ( corsaro_plugin_t plugin)
static

Print usage information to stderr.

Definition at line 112 of file corsaro_filterpfx.c.

References corsaro_plugin::argv, and MAX_COMMAND_LINE_PREFIXES.

Referenced by corsaro_filterpfx_init_output(), and parse_args().

Variable Documentation

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

Common plugin information across all instances.

Definition at line 74 of file corsaro_filterpfx.c.

Referenced by corsaro_filterpfx_alloc().