Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

snfLOGmgr.inline.hpp 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // snfLOGmgr.inline.hpp
  2. //
  3. // (C) Copyright 2006 - 2009 ARM Research Labs, LLC.
  4. // Inline methods for the snfLOGmgr
  5. //// snfScanData ///////////////////////////////////////////////////////////////
  6. inline int snfScanData::IPScanCount() { // Return the number of IPs.
  7. return MyIPCount;
  8. }
  9. inline IPScanRecord& snfScanData::newIPScanRecord() { // Get the next free IP scan record.
  10. if(MaxIPsPerMessage <= MyIPCount) { // Check that we have more records.
  11. throw NoFreeIPScanRecords(); // If we do not then throw!
  12. } // If we do have more records then
  13. IPScanRecord& NewRecord = MyIPScanData[MyIPCount]; // Pick the next available one,
  14. NewRecord.Ordinal = MyIPCount; // set the ordinal value,
  15. ++MyIPCount; // increase our count, and
  16. return NewRecord; // return the one we picked.
  17. }
  18. inline IPScanRecord& snfScanData::IPScanData(int i) { // Return the IP scan record i.
  19. if(MyIPCount <= i || 0 > i) { // First check that i is in bounds.
  20. throw OutOfBounds(); // if it is not then throw!
  21. } // If the record for [i] is available
  22. return MyIPScanData[i]; // return it.
  23. }
  24. inline void snfScanData::drillPastOrdinal(int O) { // Sets Drill Down flag for IP record O.
  25. if(0 <= O && O < MaxIPsPerMessage) { // If O is a useable Received ordinal
  26. DrillDownFlags[O] = true; // then set the Drill Down Flag for O.
  27. }
  28. }
  29. inline bool snfScanData::isDrillDownSource(IPScanRecord& X) { // True if we drill through this source.
  30. if(
  31. (0UL != myCallerForcedSourceIP) || // If the source IP has been forced by
  32. (0UL != myHeaderDirectiveSourceIP) // the caller or by a header directive
  33. ) return false; // then drilldowns are disabled.
  34. // Otherwise check for a drilldown flag.
  35. return DrillDownFlags[X.Ordinal]; // Presuming X is valid, return the flag.
  36. } // If X is not valid we may blow up!
  37. inline IPScanRecord& snfScanData::SourceIPRecord(IPScanRecord& X) { // Sets the source IP record.
  38. SourceIPOrdinal = X.Ordinal; // Here's the ordinal.
  39. SourceIPFoundFlag = true; // Here's the truth flag.
  40. }
  41. inline IPScanRecord& snfScanData::SourceIPRecord() { // Gets the source IP record.
  42. return IPScanData(SourceIPOrdinal); // Return the IP record, or throw
  43. } // OutOfBounds.
  44. inline bool snfScanData::FoundSourceIP() { // True if the source IP record was set.
  45. return SourceIPFoundFlag; // Return what the flag says.
  46. }
  47. inline snfIPRange snfScanData::SourceIPRange(snfIPRange R) { // Establish the IP range.
  48. return (SourceIPRangeFlag = R); // set and return the value w/ R.
  49. }
  50. inline snfIPRange snfScanData::SourceIPRange() { // Gets the source IP detection range.
  51. return SourceIPRangeFlag; // Return what the flag says.
  52. }
  53. inline IP4Address snfScanData::HeaderDirectiveSourceIP(IP4Address A) { // set Header directive source IP.
  54. if(0UL == myHeaderDirectiveSourceIP) myHeaderDirectiveSourceIP = A; // If this value is not set, set it.
  55. return myHeaderDirectiveSourceIP; // Return the value.
  56. }
  57. inline IP4Address snfScanData::HeaderDirectiveSourceIP() { // get Header directive source IP.
  58. return myHeaderDirectiveSourceIP; // Return the current value.
  59. }
  60. inline IP4Address snfScanData::CallerForcedSourceIP(IP4Address A) { // set Caller forced source IP.
  61. if(0UL == myCallerForcedSourceIP) myCallerForcedSourceIP = A; // If this value is not set, set it.
  62. return myCallerForcedSourceIP; // Return the value.
  63. }
  64. inline IP4Address snfScanData::CallerForcedSourceIP() { // get Caller forced source IP.
  65. return myCallerForcedSourceIP; // Return the current value.
  66. }
  67. //// snfLOGmgr /////////////////////////////////////////////////////////////////
  68. inline void snfLOGmgr::updateActiveUTC(string ActiveUTC) { // Update Active Rulebase UTC.
  69. ScopeMutex Freeze(MyMutex); // Protect the strings.
  70. ActiveRulebaseUTC = ActiveUTC; // Update the active timestamp.
  71. NewerRulebaseIsAvailable = false; // Update availability is now unknown.
  72. }
  73. inline void snfLOGmgr::updateAvailableUTC(string& AvailableRulebaseTimestamp) { // Changes update avialability stamp.
  74. ScopeMutex Freeze(MyMutex); // Protect the strings.
  75. AvailableRulebaseUTC = AvailableRulebaseTimestamp; // Store the new timestamp.
  76. if(0 < AvailableRulebaseUTC.compare(ActiveRulebaseUTC)) { // If the available timestamp is newer
  77. NewerRulebaseIsAvailable = true; // than the active then set the flag.
  78. } else { // If it is not newer then
  79. NewerRulebaseIsAvailable = false; // reset the flag.
  80. }
  81. }
  82. inline string snfLOGmgr::ActiveRulebaseTimestamp() { // Get active rulebase timestamp.
  83. ScopeMutex Freeze(MyMutex); // Protect the string.
  84. return ActiveRulebaseUTC; // Return it.
  85. }
  86. inline string snfLOGmgr::AvailableRulebaseTimestamp() { // Get available rulebase timestamp.
  87. ScopeMutex Freeze(MyMutex); // Protect the strings.
  88. return AvailableRulebaseUTC; // Return the available timestamp.
  89. }
  90. inline bool snfLOGmgr::isUpdateAvailable() { // True if update is available.
  91. return NewerRulebaseIsAvailable; // Return the flag's value.
  92. }
  93. inline int snfLOGmgr::LatestRuleID() { // Query the latest rule id.
  94. return Status.LatestRuleID; // This simple value is atomic
  95. } // so we can read it without the mutex.
  96. inline int snfLOGmgr::RunningTime() { // Get the time we've been alive.
  97. return (int) difftime(Timestamp(), StartupTime);
  98. }