Myra Canyon  v0.0.1-768
network control
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Myra::DB Class Referencefinal

Class DB is used to gain access to the database. More...

#include "DB.hpp"

Public Types

typedef pqxx::result Result
 Database result. More...
 
typedef pqxx::work T
 A normal database transaction. More...
 
typedef pqxx::nontransaction NT
 A database non-transaction (perform immediately). More...
 
typedef uint64_t Id
 Database ID. More...
 

Public Member Functions

 ~DB (void)
 Destructor. More...
 
 DB (void)
 Constructor. This automatically does a synchronous connect to the database. More...
 
DBcheck_tables (void)
 Check the Myra Canyon tables. More...
 
DBadd_history (const std::string &msg)
 Add a line into the history table. More...
 
DBreset_all_tables (void)
 Delete and re-create all known tables. More...
 
DBcreate_tables (void)
 Ensure everything in the database exists as we expect. This will build the tables the first time we connect. More...
 
DBupdate_traffic_types (void)
 Ensure the traffic types table has all of the known traffic types. More...
 
DBupdate_ethertypes (void)
 Ensure the ethertype table has all of the known values from Myra::L2::Ethertype. More...
 
DBupdate_protocol_types (void)
 Ensure the protocol table has all of the known IP protocol values from Myra::L3_IP::Protocol. More...
 
DBrecord_flow (Myra::Flow &flow)
 Record an entry for the given flow. More...
 
DBrecord_stats (Myra::Flow &flow)
 Record statistics for this flow. More...
 
DBrecord_hosts (Myra::Flow &flow)
 Record host entries for this flow. More...
 
DBadd_or_update_inside_host (const std::string &ip_address, const time_t lease_start, const time_t lease_end, const std::string &mac_address, const std::string &hostname)
 Add or update the 'inside host' record. More...
 
bool flow_exists (const Myra::FlowHash hash)
 Check to see if this hash already exists in the table flows. More...
 

Public Attributes

pqxx::connection connection
 

Static Public Attributes

static constexpr int Version = 1
 

Detailed Description

Class DB is used to gain access to the database.

Member Typedef Documentation

typedef uint64_t Myra::DB::Id

Database ID.

typedef pqxx::nontransaction Myra::DB::NT

A database non-transaction (perform immediately).

typedef pqxx::result Myra::DB::Result

Database result.

typedef pqxx::work Myra::DB::T

A normal database transaction.

Constructor & Destructor Documentation

Myra::DB::~DB ( void  )

Destructor.

Myra::DB::DB ( void  )

Constructor. This automatically does a synchronous connect to the database.

Warning
The pqxx::connection constructor will throw if it has a problem connecting. If this happens, take a peek at the configuration file /etc/postgresql/x.y/main/pg_hba.conf to ensure that all the right permissions are still in place. Likely culprit is a locally modified configuration file, or an upgrade to a newer version of PostgreSQL where the configuration file is no longer stored at /etc/postgresql/x.y.

Member Function Documentation

Myra::DB & Myra::DB::add_history ( const std::string &  msg)

Add a line into the history table.

Myra::DB & Myra::DB::add_or_update_inside_host ( const std::string &  ip_address,
const time_t  lease_start,
const time_t  lease_end,
const std::string &  mac_address,
const std::string &  hostname 
)

Add or update the 'inside host' record.

Here is the call graph for this function:

Here is the caller graph for this function:

Myra::DB & Myra::DB::check_tables ( void  )

Check the Myra Canyon tables.

Here is the caller graph for this function:

Myra::DB & Myra::DB::create_tables ( void  )

Ensure everything in the database exists as we expect. This will build the tables the first time we connect.

Here is the call graph for this function:

bool Myra::DB::flow_exists ( const Myra::FlowHash  hash)

Check to see if this hash already exists in the table flows.

Here is the call graph for this function:

Here is the caller graph for this function:

Myra::DB & Myra::DB::record_flow ( Myra::Flow flow)

Record an entry for the given flow.

Here is the call graph for this function:

Here is the caller graph for this function:

Myra::DB & Myra::DB::record_hosts ( Myra::Flow flow)

Record host entries for this flow.

Here is the call graph for this function:

Here is the caller graph for this function:

Myra::DB & Myra::DB::record_stats ( Myra::Flow flow)

Record statistics for this flow.

Here is the call graph for this function:

Here is the caller graph for this function:

Myra::DB & Myra::DB::reset_all_tables ( void  )

Delete and re-create all known tables.

Myra::DB & Myra::DB::update_ethertypes ( void  )

Ensure the ethertype table has all of the known values from Myra::L2::Ethertype.

Here is the call graph for this function:

Myra::DB & Myra::DB::update_protocol_types ( void  )

Ensure the protocol table has all of the known IP protocol values from Myra::L3_IP::Protocol.

Here is the call graph for this function:

Myra::DB & Myra::DB::update_traffic_types ( void  )

Ensure the traffic types table has all of the known traffic types.

See also
Myra::Traffic::Type

Here is the call graph for this function:

Member Data Documentation

pqxx::connection Myra::DB::connection
constexpr int Myra::DB::Version = 1
static

The documentation for this class was generated from the following files: