|
@@ -458,7 +458,8 @@ void statistics_db::writeDbVersion(){
|
|
* Writes the unrecognized PDUs into the database.
|
|
* Writes the unrecognized PDUs into the database.
|
|
* @param unrecognized_PDUs The unrecognized PDUs from class statistics.
|
|
* @param unrecognized_PDUs The unrecognized PDUs from class statistics.
|
|
*/
|
|
*/
|
|
-void statistics_db::writeStatisticsUnrecognizedPDUs(std::unordered_map<unrecognized_PDU, int> unrecognized_PDUs) {
|
|
|
|
|
|
+void statistics_db::writeStatisticsUnrecognizedPDUs(std::unordered_map<unrecognized_PDU, unrecognized_PDU_stat>
|
|
|
|
+ unrecognized_PDUs) {
|
|
try {
|
|
try {
|
|
db->exec("DROP TABLE IF EXISTS unrecognized_pdus");
|
|
db->exec("DROP TABLE IF EXISTS unrecognized_pdus");
|
|
SQLite::Transaction transaction(*db);
|
|
SQLite::Transaction transaction(*db);
|
|
@@ -467,15 +468,17 @@ void statistics_db::writeStatisticsUnrecognizedPDUs(std::unordered_map<unrecogni
|
|
"dstMac TEXT COLLATE NOCASE,"
|
|
"dstMac TEXT COLLATE NOCASE,"
|
|
"etherType INTEGER,"
|
|
"etherType INTEGER,"
|
|
"pktCount INTEGER,"
|
|
"pktCount INTEGER,"
|
|
|
|
+ "timestampLastOccurrence TEXT,"
|
|
"PRIMARY KEY(srcMac,dstMac,etherType));";
|
|
"PRIMARY KEY(srcMac,dstMac,etherType));";
|
|
db->exec(createTable);
|
|
db->exec(createTable);
|
|
- SQLite::Statement query(*db, "INSERT INTO unrecognized_pdus VALUES (?, ?, ?, ?)");
|
|
|
|
|
|
+ SQLite::Statement query(*db, "INSERT INTO unrecognized_pdus VALUES (?, ?, ?, ?, ?)");
|
|
for (auto it = unrecognized_PDUs.begin(); it != unrecognized_PDUs.end(); ++it) {
|
|
for (auto it = unrecognized_PDUs.begin(); it != unrecognized_PDUs.end(); ++it) {
|
|
unrecognized_PDU e = it->first;
|
|
unrecognized_PDU e = it->first;
|
|
query.bind(1, e.srcMacAddress);
|
|
query.bind(1, e.srcMacAddress);
|
|
query.bind(2, e.dstMacAddress);
|
|
query.bind(2, e.dstMacAddress);
|
|
query.bind(3, e.typeNumber);
|
|
query.bind(3, e.typeNumber);
|
|
- query.bind(4, it->second);
|
|
|
|
|
|
+ query.bind(4, it->second.count);
|
|
|
|
+ query.bind(5, it->second.timestamp_last_occurrence);
|
|
query.exec();
|
|
query.exec();
|
|
query.reset();
|
|
query.reset();
|
|
}
|
|
}
|