|
|
@@ -20,14 +20,14 @@ |
|
|
|
// #include "tcp_watchdog.hpp" No longer using TCPWatchdog -- see below _M |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
///// utilities ////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const int MSecsInSecs = 1000; // Multiplier - seconds to milliseconds.
|
|
|
|
unsigned long long int SecsAsMSecs(unsigned int Secs) {
|
|
|
|
return (MSecsInSecs * Secs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///// utilities //////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
const int MSecsInSecs = 1000; // Multiplier - seconds to milliseconds. |
|
|
|
unsigned long long int SecsAsMSecs(unsigned int Secs) { |
|
|
|
return (MSecsInSecs * Secs); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// snfNETmgr ///////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
@@ -50,11 +50,11 @@ const ThreadState snfNETmgr::SYNC_Log_Event("Logging SYNC"); |
|
|
|
|
|
|
|
snfNETmgr::snfNETmgr() : // Starting up the NETmgr |
|
|
|
Thread(snfNETmgr::Type, "NET Manager"), // Network manager and Name. |
|
|
|
myLOGmgr(NULL), // No LOGmgr yet.
|
|
|
|
myLOGmgr(NULL), // No LOGmgr yet. |
|
|
|
isTimeToStop(false), // Not time to stop yet. |
|
|
|
isConfigured(false), // Not configured yet. |
|
|
|
SYNCTimer(30000), // Sync every 30 secs by default.
|
|
|
|
SyncSecsOverride(-1) { // Override is -1 (off) by default.
|
|
|
|
SYNCTimer(30000), // Sync every 30 secs by default. |
|
|
|
SyncSecsOverride(-1) { // Override is -1 (off) by default. |
|
|
|
run(); // Run the thread. |
|
|
|
} |
|
|
|
|
|
|
@@ -246,6 +246,8 @@ string snfNETmgr::getReports() { |
|
|
|
return ReportsBatch; // Return a batch of Reports. |
|
|
|
} |
|
|
|
|
|
|
|
RuntimeCheck RulebaseUTCGoodTimestampLength("SNFNetmgr.cpp:RulebaseUTC snprintf(...) != CorrectTimestampLength"); |
|
|
|
|
|
|
|
string& snfNETmgr::RulebaseUTC(string& t) { // Gets local rulebase file UTC. |
|
|
|
struct stat RulebaseStat; // First we need a stat buffer. |
|
|
|
if(0 != stat(RulebaseFilePath.c_str(), &RulebaseStat)) { // If we can't get the stat we |
|
|
@@ -254,9 +256,11 @@ string& snfNETmgr::RulebaseUTC(string& t) { |
|
|
|
struct tm RulebaseTime; // Allocate a time structure. |
|
|
|
RulebaseTime = *(gmtime(&RulebaseStat.st_mtime)); // Copy the file time to it as UTC. |
|
|
|
|
|
|
|
char TimestampBfr[20]; // Timestamp buffer. |
|
|
|
char TimestampBfr[16]; // Timestamp buffer. |
|
|
|
|
|
|
|
sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d", // Format yyyymmddhhmmss |
|
|
|
size_t l = snprintf( // Format yyyymmddhhmmss |
|
|
|
TimestampBfr, sizeof(TimestampBfr), |
|
|
|
"%04d%02d%02d%02d%02d%02d", |
|
|
|
RulebaseTime.tm_year+1900, |
|
|
|
RulebaseTime.tm_mon+1, |
|
|
|
RulebaseTime.tm_mday, |
|
|
@@ -265,6 +269,9 @@ string& snfNETmgr::RulebaseUTC(string& t) { |
|
|
|
RulebaseTime.tm_sec |
|
|
|
); |
|
|
|
|
|
|
|
const size_t CorrectTimestampLength = 4+2+2+2+2+2; |
|
|
|
RulebaseUTCGoodTimestampLength(l == CorrectTimestampLength); |
|
|
|
|
|
|
|
t.append(TimestampBfr); // Append the timestamp to t |
|
|
|
return t; // and return it to the caller. |
|
|
|
} |