BACnet CSV output plugin

Plugin prints commands for PostgreSQL to insert exported data into the database. Plugin supports optional dividing of the exported data into the database partitions according to a date (for each year/month/day/hour/minute). More...

Data Structures

struct  bacnet_export_csv_private_t
 Plugin's private structure with information passed from init to the calls of PLUGIN_EXPORT_* functions. More...
struct  getter_pair
 Auxiliary container connecting name string of the getter with the ID needed for processing in PLUGIN_EXPORT_EXPORT function. More...

Defines

#define VERSION   "1.0"
#define PRINT(format, args...)
#define PRINTERR(format, args...)   fprintf(stderr,format,##args)
#define PRINTWARN(format, args...)   fprintf(stderr,format,##args)
#define PRINT_SQL_INIT   char obuf[16384],dummy[1024];obuf[0]='\0'
#define PRINT_SQL(format, args...)   sprintf(dummy,format,##args);strcat(obuf, dummy)
#define PRINT_SQL_FLUSH   printf("%s", obuf);fflush(stdout)
#define ADDR_BUF_SIZE   128

Enumerations

enum  TIME_UNITS {
  TU_NO,
  TU_YEAR,
  TU_MONTH,
  TU_DAY,
  TU_HOUR,
  TU_MINUTE
}
 Time units for DB partitioning. More...
enum  GETTER_ID {
  FLOW_START_USEC,
  FLOW_END_USEC,
  L2_VLAN_0,
  L2_VLAN_1,
  L2_VLAN_2,
  L2_VLAN_3,
  L2_SRC_MAC,
  L2_DST_MAC,
  ETHERTYPE,
  L3_PROTO,
  L3_IPV4_ADDR_SRC,
  L3_IPV4_ADDR_DST,
  L3_IPV4_TOS,
  L3_IPV6_ADDR_SRC,
  L3_IPV6_ADDR_DST,
  L4_PROTO,
  L4_TCP_FLAGS,
  L4_PORT_SRC,
  L4_PORT_DST,
  L4_ICMP_TYPE_CODE,
  BACNET_CONTROL,
  BACNET_HOP_COUNT,
  BACNET_MESSAGE_TYPE,
  BACNET_VENDOR_ID,
  BACNET_SNET,
  BACNET_DNET,
  BACNET_SADR,
  BACNET_DADR,
  PACKETS,
  BYTES,
  GETTER_MAX
}
 List of possible getters that have implemented a printer in the EXPORT function. Feel free to add any new item with its printer implemented in PLUGIN_EXPORT_EXPORT, but the last item must not be changed. This list do not actually affects currently printed items - see selected_getters[].

Functions

plugin_desc_t * plugin_export_desc ()
 API for flowmonexp to get plugin description structure.
void * plugin_export_init (char *params, flow_record_getter_t *getter_list)
 Initialize all needed structures/devices/files etc. The function is called once as the first part of the plugin.
void print_headers (flow_record_getter_t *getters)
 Print titles of used columns in records.
int plugin_export_export (void *plugin_private, flow_record_t *record)
 Export (print record content as CSV) expired flow records.
int plugin_export_flush (void *plugin_private)
 Flush data.

Variables

unsigned int plugin_type = (PLUGIN_TYPE_EXPORT)
struct getter_pair selected_getters []
 The list of the printed getters. The order in this list determine the order of the information printed to the output.

Detailed Description

Plugin prints commands for PostgreSQL to insert exported data into the database. Plugin supports optional dividing of the exported data into the database partitions according to a date (for each year/month/day/hour/minute).

Example of using the plugin with flowmonexp and enabled partitioning for each day:

$ flowmonexp -X export-bacnet-csv.so -I pcap:device=eth0 -E export-bacnet-csv:day

Define Documentation

#define ADDR_BUF_SIZE   128

Size of the buffer for printing network address

Definition at line 107 of file export-bacnet-csv.c.

#define PRINT ( format,
args...   ) 

Message printer

Definition at line 76 of file export-bacnet-csv.c.

#define PRINT_SQL ( format,
args...   )     sprintf(dummy,format,##args);strcat(obuf, dummy)

SQL commands printer

Definition at line 96 of file export-bacnet-csv.c.

#define PRINT_SQL_FLUSH   printf("%s", obuf);fflush(stdout)

SQL printer flush

Definition at line 101 of file export-bacnet-csv.c.

#define PRINT_SQL_INIT   char obuf[16384],dummy[1024];obuf[0]='\0'

SQL printer init

Definition at line 91 of file export-bacnet-csv.c.

#define PRINTERR ( format,
args...   )     fprintf(stderr,format,##args)

Error message printer

Definition at line 81 of file export-bacnet-csv.c.

#define PRINTWARN ( format,
args...   )     fprintf(stderr,format,##args)

Warning message printer

Definition at line 86 of file export-bacnet-csv.c.

#define VERSION   "1.0"

Plugin version

Definition at line 65 of file export-bacnet-csv.c.


Enumeration Type Documentation

enum TIME_UNITS

Time units for DB partitioning.

Enumerator:
TU_NO  No partitioning
TU_YEAR  New partition is available each year
TU_MONTH  New partition is available each month
TU_DAY  New partition is available each day
TU_HOUR  New partition is available each hour
TU_MINUTE  New partition is available each minute

Definition at line 112 of file export-bacnet-csv.c.


Function Documentation

plugin_desc_t* plugin_export_desc (  ) 

API for flowmonexp to get plugin description structure.

Returns:
Plugin description structure

Definition at line 238 of file export-bacnet-csv.c.

int plugin_export_export ( void *  plugin_private,
flow_record_t *  record 
)

Export (print record content as CSV) expired flow records.

Parameters:
[in] plugin_private Plugin's private structure from init with all necessary information
[in] record Flow record from input plugin(s)
Returns:
  • zero on success,
  • nonzero on error

Definition at line 332 of file export-bacnet-csv.c.

int plugin_export_flush ( void *  plugin_private  ) 

Flush data.

Parameters:
[in] plugin_private Plugin's private structure from init with all necessary information
Returns:
  • zero on success,
  • nonzero on error

Definition at line 489 of file export-bacnet-csv.c.

void* plugin_export_init ( char *  params,
flow_record_getter_t *  getter_list 
)

Initialize all needed structures/devices/files etc. The function is called once as the first part of the plugin.

Parameters:
[in] params Plugin parameters as string from command line
[in] getter_list List of available getters for a complete flow record
Returns:
Created and initialized plugin internal structure (export_bacnet_csv_private_t)

Definition at line 252 of file export-bacnet-csv.c.

void print_headers ( flow_record_getter_t *  getters  ) 

Print titles of used columns in records.

Parameters:
[in] getters List of available getters for a complete flow record

Definition at line 314 of file export-bacnet-csv.c.


Variable Documentation

unsigned int plugin_type = (PLUGIN_TYPE_EXPORT)

Set type of the flowmonexp's plugin

Definition at line 70 of file export-bacnet-csv.c.

Initial value:

 {
        {"FLOW_START_USEC", FLOW_START_USEC},
        {"FLOW_END_USEC", FLOW_END_USEC},
        {"L2_VLAN_0", L2_VLAN_0},
        {"L2_SRC_MAC", L2_SRC_MAC},
        {"L2_DST_MAC", L2_DST_MAC},
        {"ETHERTYPE", ETHERTYPE},
        {"L3_PROTO", L3_PROTO},
        {"L3_IPV4_ADDR_SRC", L3_IPV4_ADDR_SRC},
        {"L3_IPV4_ADDR_DST", L3_IPV4_ADDR_DST},
        {"L3_IPV6_ADDR_SRC", L3_IPV6_ADDR_SRC},
        {"L3_IPV6_ADDR_DST", L3_IPV6_ADDR_DST},
        {"L4_PROTO", L4_PROTO},
        {"L4_TCP_FLAGS", L4_TCP_FLAGS},
        {"L4_PORT_SRC", L4_PORT_SRC},
        {"L4_PORT_DST", L4_PORT_DST},
        {"L4_ICMP_TYPE_CODE", L4_ICMP_TYPE_CODE},
        {"BACNET_CONTROL", BACNET_CONTROL},
        {"BACNET_HOP_COUNT", BACNET_HOP_COUNT},
        {"BACNET_MESSAGE_TYPE", BACNET_MESSAGE_TYPE},
        {"BACNET_SNET", BACNET_SNET},
        {"BACNET_DNET", BACNET_DNET},
        {"BACNET_SADR", BACNET_SADR},
        {"BACNET_DADR", BACNET_DADR},
        {"PACKETS", PACKETS},
        {"BYTES", BYTES},
        
        {NULL, GETTER_MAX}
}
The list of the printed getters. The order in this list determine the order of the information printed to the output.

The case branch in PLUGIN_EXPORT_EXPORT's switch of the first item should contain start of the printed string - in our case there is INSERT... SQL command.

Definition at line 200 of file export-bacnet-csv.c.


© 2011 Masaryk University - Institute of Computer Science - visit http://www.muni.cz/ics/