|
|
|
|
|
|
|
|
// #include "tcp_watchdog.hpp" No longer using TCPWatchdog -- see below _M |
|
|
// #include "tcp_watchdog.hpp" No longer using TCPWatchdog -- see below _M |
|
|
|
|
|
|
|
|
using namespace std; |
|
|
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 ///////////////////////////////////////////////////////////////// |
|
|
//// snfNETmgr ///////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snfNETmgr::snfNETmgr() : // Starting up the NETmgr |
|
|
snfNETmgr::snfNETmgr() : // Starting up the NETmgr |
|
|
Thread(snfNETmgr::Type, "NET Manager"), // Network manager and Name. |
|
|
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. |
|
|
isTimeToStop(false), // Not time to stop yet. |
|
|
isConfigured(false), // Not configured 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. |
|
|
run(); // Run the thread. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ReportsBatch; // Return a batch of Reports. |
|
|
return ReportsBatch; // Return a batch of Reports. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RuntimeCheck RulebaseUTCGoodTimestampLength("SNFNetmgr.cpp:RulebaseUTC snprintf(...) != CorrectTimestampLength"); |
|
|
|
|
|
|
|
|
string& snfNETmgr::RulebaseUTC(string& t) { // Gets local rulebase file UTC. |
|
|
string& snfNETmgr::RulebaseUTC(string& t) { // Gets local rulebase file UTC. |
|
|
struct stat RulebaseStat; // First we need a stat buffer. |
|
|
struct stat RulebaseStat; // First we need a stat buffer. |
|
|
if(0 != stat(RulebaseFilePath.c_str(), &RulebaseStat)) { // If we can't get the stat we |
|
|
if(0 != stat(RulebaseFilePath.c_str(), &RulebaseStat)) { // If we can't get the stat we |
|
|
|
|
|
|
|
|
struct tm RulebaseTime; // Allocate a time structure. |
|
|
struct tm RulebaseTime; // Allocate a time structure. |
|
|
RulebaseTime = *(gmtime(&RulebaseStat.st_mtime)); // Copy the file time to it as UTC. |
|
|
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_year+1900, |
|
|
RulebaseTime.tm_mon+1, |
|
|
RulebaseTime.tm_mon+1, |
|
|
RulebaseTime.tm_mday, |
|
|
RulebaseTime.tm_mday, |
|
|
|
|
|
|
|
|
RulebaseTime.tm_sec |
|
|
RulebaseTime.tm_sec |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const size_t CorrectTimestampLength = 4+2+2+2+2+2; |
|
|
|
|
|
RulebaseUTCGoodTimestampLength(l == CorrectTimestampLength); |
|
|
|
|
|
|
|
|
t.append(TimestampBfr); // Append the timestamp to t |
|
|
t.append(TimestampBfr); // Append the timestamp to t |
|
|
return t; // and return it to the caller. |
|
|
return t; // and return it to the caller. |
|
|
} |
|
|
} |