|
|
@@ -23,7 +23,7 @@ using namespace std; |
|
|
|
|
|
|
|
//// Version Info |
|
|
|
|
|
|
|
const char* SNF_ENGINE_VERSION = "SNFMulti Engine Version 3.0.5 Build: " __DATE__ " " __TIME__; |
|
|
|
const char* SNF_ENGINE_VERSION = "SNFMulti Engine Version 3.0.6 Build: " __DATE__ " " __TIME__; |
|
|
|
|
|
|
|
//// Script Caller Methods |
|
|
|
|
|
|
@@ -41,7 +41,8 @@ ScriptCaller::ScriptCaller(string S) : |
|
|
|
Thread(ScriptCaller::Type, S), // Set up the thread type and name. |
|
|
|
GuardTimer(ScriptGuardDefault), // Initialize the guard time. |
|
|
|
GoFlag(false), // Not ready to go yet. |
|
|
|
DieFlag(false) { // Not ready to die yet. |
|
|
|
DieFlag(false), // Not ready to die yet. |
|
|
|
myLastResult(0) { // No last result yet. |
|
|
|
run(); // Launch the thread. |
|
|
|
} |
|
|
|
|
|
|
@@ -81,6 +82,10 @@ void ScriptCaller::trigger() { |
|
|
|
GoFlag = true; // Set the flag. |
|
|
|
} |
|
|
|
|
|
|
|
int ScriptCaller::LastResult() { // Return the result code from |
|
|
|
return myLastResult; // the last system() call. |
|
|
|
} |
|
|
|
|
|
|
|
void ScriptCaller::myTask() { // Safely call system() when triggered. |
|
|
|
Sleeper WaitATic(1000); // One second sleeper. |
|
|
|
while(false == DieFlag) { // While it's not time to die: |
|
|
@@ -90,11 +95,12 @@ void ScriptCaller::myTask() { |
|
|
|
if(true == GoFlag) { // If GoFlag is triggered and |
|
|
|
if(hasGuardExpired()) { // Guard time is expired: |
|
|
|
CurrentThreadState(CallingSystem); // Publish our state. |
|
|
|
system(ScriptThisRound.c_str()); // Make the system call. |
|
|
|
myLastResult = system(ScriptThisRound.c_str()); // Make the system call. |
|
|
|
GoFlag = false; // Done with that trigger. |
|
|
|
GuardTimer.restart(); // Restart our Guard Time. |
|
|
|
} else { // If we're waiting for Guard Time: |
|
|
|
CurrentThreadState(PendingGuardTime); // publish that state. |
|
|
|
CurrentThreadState(PendingGuardTime); // publish that state and hold down |
|
|
|
GoFlag = false; // the trigger signal (no stale go). |
|
|
|
} |
|
|
|
} else { // If nothing is triggered yet then |
|
|
|
CurrentThreadState(StandingBy); // we are standing by. |
|
|
@@ -212,10 +218,10 @@ const ThreadType snf_Reloader::Type("snf_Reloader"); |
|
|
|
|
|
|
|
snf_Reloader::snf_Reloader(snf_RulebaseHandler& R) : // When we are created, we |
|
|
|
Thread(snf_Reloader::Type, "Reloader"), // brand and name our thread. |
|
|
|
MyRulebase(R), // Capture the rulebase handler.
|
|
|
|
TimeToStop(false), // It's not time to stop yet.
|
|
|
|
MyRulebase(R), // Capture the rulebase handler. |
|
|
|
TimeToStop(false), // It's not time to stop yet. |
|
|
|
RulebaseGetter("RulebaseGetter"), // Setup our ScriptCaller thread. |
|
|
|
RulebaseGetterIsTurnedOn(false) { // Rulebase getter is off at first.
|
|
|
|
RulebaseGetterIsTurnedOn(false) { // Rulebase getter is off at first. |
|
|
|
captureFileStats(); // Set up the initial stats. |
|
|
|
captureGetterConfig(); // Set up RulebaseGetter config. |
|
|
|
run(); // Run our maintenenace thread. |
|
|
@@ -331,8 +337,8 @@ bool snf_RulebaseHandler::AutoRefresh() { |
|
|
|
// done it will reset from the "RefreshInProgress" state and along the way will throw any errors that |
|
|
|
// are appropriate. The other functions can count on this one to polish off the various forms of rulebase |
|
|
|
// load activity. |
|
|
|
|
|
|
|
const LogicCheck SaneRefreshProcessCheck("snf_RulebaseHandler::_snf_LoadNewRulebase():SaneRefreshProcessCheck(RefreshInProgress)");
|
|
|
|
|
|
|
|
const LogicCheck SaneRefreshProcessCheck("snf_RulebaseHandler::_snf_LoadNewRulebase():SaneRefreshProcessCheck(RefreshInProgress)"); |
|
|
|
|
|
|
|
void snf_RulebaseHandler::_snf_LoadNewRulebase(){ // Common internal load/check routine. |
|
|
|
SaneRefreshProcessCheck(RefreshInProgress); // We only get called when this flag is set. |
|
|
@@ -1267,9 +1273,9 @@ string snf_EngineHandler::extractMessageID( |
|
|
|
|
|
|
|
return ExtractedID; // Return the extracted id or substitute. |
|
|
|
} |
|
|
|
|
|
|
|
const LogicFault FaultBadMessageBuffer1("snf_EngineHandler::scanMessage():FaultBadMessageBuffer1(NULL == inputMessageBuffer)");
|
|
|
|
const LogicFault FaultBadMessageBuffer2("snf_EngineHandler::scanMessage():FaultBadMessageBuffer2(0 >= inputMessageLength)");
|
|
|
|
|
|
|
|
const LogicFault FaultBadMessageBuffer1("snf_EngineHandler::scanMessage():FaultBadMessageBuffer1(NULL == inputMessageBuffer)"); |
|
|
|
const LogicFault FaultBadMessageBuffer2("snf_EngineHandler::scanMessage():FaultBadMessageBuffer2(0 >= inputMessageLength)"); |
|
|
|
|
|
|
|
int snf_EngineHandler::scanMessage( // Scan this message (in buffer). |
|
|
|
const unsigned char* inputMessageBuffer, // -- this is the message buffer. |
|
|
@@ -1279,14 +1285,14 @@ int snf_EngineHandler::scanMessage( |
|
|
|
const IP4Address MessageSource // -- message source IP (for injection). |
|
|
|
) { |
|
|
|
|
|
|
|
ScopeTimer ScanTimeCapture(MyScanData.ScanTime); // Start the scan time clock.
|
|
|
|
|
|
|
|
unsigned char* MessageBuffer = NULL; // Explicitly initialize these two
|
|
|
|
int MessageLength = 0; // so the compiler will be happy.
|
|
|
|
|
|
|
|
FaultBadMessageBuffer1(NULL == inputMessageBuffer); // Fault on null message buffer.
|
|
|
|
FaultBadMessageBuffer2(0 >= inputMessageLength); // Fault on bad message bfr length.
|
|
|
|
|
|
|
|
ScopeTimer ScanTimeCapture(MyScanData.ScanTime); // Start the scan time clock. |
|
|
|
|
|
|
|
unsigned char* MessageBuffer = NULL; // Explicitly initialize these two |
|
|
|
int MessageLength = 0; // so the compiler will be happy. |
|
|
|
|
|
|
|
FaultBadMessageBuffer1(NULL == inputMessageBuffer); // Fault on null message buffer. |
|
|
|
FaultBadMessageBuffer2(0 >= inputMessageLength); // Fault on bad message bfr length. |
|
|
|
|
|
|
|
// Protect this engine - only one scan at a time per EngineHandler ;-) |
|
|
|
|
|
|
|
ScopeMutex ScannerIsBusy(MyMutex); // Serialize this... |
|
|
@@ -1726,7 +1732,7 @@ int snf_EngineHandler::scanMessage( |
|
|
|
break; // That's all. |
|
|
|
} |
|
|
|
|
|
|
|
case New: {
|
|
|
|
case New: { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@@ -1796,11 +1802,11 @@ int snf_EngineHandler::scanMessage( |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
}
|
|
|
|
|
|
|
|
case Unknown: // Unknown - most likely we couldn't
|
|
|
|
default: { // find a usable source.
|
|
|
|
break; // Do nothing.
|
|
|
|
} |
|
|
|
|
|
|
|
case Unknown: // Unknown - most likely we couldn't |
|
|
|
default: { // find a usable source. |
|
|
|
break; // Do nothing. |
|
|
|
} |
|
|
|
} |
|
|
|
} // End of IP source depended work (GBUdbOverrides) |