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... | |
DB & | check_tables (void) |
Check the Myra Canyon tables. More... | |
DB & | add_history (const std::string &msg) |
Add a line into the history table. More... | |
DB & | reset_all_tables (void) |
Delete and re-create all known tables. More... | |
DB & | create_tables (void) |
Ensure everything in the database exists as we expect. This will build the tables the first time we connect. More... | |
DB & | update_traffic_types (void) |
Ensure the traffic types table has all of the known traffic types. More... | |
DB & | update_ethertypes (void) |
Ensure the ethertype table has all of the known values from Myra::L2::Ethertype. More... | |
DB & | update_protocol_types (void) |
Ensure the protocol table has all of the known IP protocol values from Myra::L3_IP::Protocol. More... | |
DB & | record_flow (Myra::Flow &flow) |
Record an entry for the given flow. More... | |
DB & | record_stats (Myra::Flow &flow) |
Record statistics for this flow. More... | |
DB & | record_hosts (Myra::Flow &flow) |
Record host entries for this flow. More... | |
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. 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 |
Class DB is used to gain access to the database.
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.
Myra::DB::~DB | ( | void | ) |
Destructor.
Myra::DB::DB | ( | void | ) |
Constructor. This automatically does a synchronous connect to the database.
/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
.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.
Myra::DB & Myra::DB::check_tables | ( | void | ) |
Check the Myra Canyon tables.
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.
bool Myra::DB::flow_exists | ( | const Myra::FlowHash | hash | ) |
Check to see if this hash already exists in the table flows
.
Myra::DB & Myra::DB::record_flow | ( | Myra::Flow & | flow | ) |
Record an entry for the given flow.
Myra::DB & Myra::DB::record_hosts | ( | Myra::Flow & | flow | ) |
Record host entries for this flow.
Myra::DB & Myra::DB::record_stats | ( | Myra::Flow & | flow | ) |
Record statistics for this flow.
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.
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.
Myra::DB & Myra::DB::update_traffic_types | ( | void | ) |
Ensure the traffic types table has all of the known traffic types.
pqxx::connection Myra::DB::connection |
|
static |