]> git.stg.codes - stg.git/blobdiff - projects/stargazer/traffcounter_impl.h
Minor changes.
[stg.git] / projects / stargazer / traffcounter_impl.h
index 2a9fca5a61590dddb0bd4bb716a028e20f989fd8..a1dfa74303aa8a4844fcf443550a53b712b4b359 100644 (file)
 #ifndef TRAFFCOUNTER_IMPL_H
 #define TRAFFCOUNTER_IMPL_H
 
-#include <pthread.h>
-
-#include <ctime>
-#include <list>
-#include <map>
-#include <string>
-
 #include "stg/traffcounter.h"
 #include "stg/os_int.h"
 #include "stg/logger.h"
 #include "eventloop.h"
 #include "user_impl.h"
 
+#include <ctime>
+#include <list>
+#include <map>
+#include <string>
+
+#include <pthread.h>
+
 #define PROTOMAX    (5)
 
 class USERS_IMPL;
@@ -147,7 +147,7 @@ private:
 //-----------------------------------------------------------------------------
 class ADD_USER_NONIFIER: public NOTIFIER_BASE<USER_IMPL_PTR> {
 public:
-            ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
+            explicit ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
                 NOTIFIER_BASE<USER_IMPL_PTR>(),
                 traffCnt(t)
             {}
@@ -163,7 +163,7 @@ private:
 //-----------------------------------------------------------------------------
 class DEL_USER_NONIFIER: public NOTIFIER_BASE<USER_IMPL_PTR> {
 public:
-            DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
+            explicit DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
                 NOTIFIER_BASE<USER_IMPL_PTR>(),
                 traffCnt(t)
             {}
@@ -186,8 +186,6 @@ public:
     TRAFFCOUNTER_IMPL(USERS_IMPL * users, const std::string & rulesFileName);
     ~TRAFFCOUNTER_IMPL();
 
-    void        SetRulesFile(const std::string & rulesFileName);
-
     int         Reload();
     int         Start();
     int         Stop();
@@ -204,7 +202,6 @@ private:
     bool        ParseAddress(const char * ta, RULE * rule) const;
     uint32_t    CalcMask(uint32_t msk) const;
     void        FreeRules();
-    void        PrintRule(RULE rule) const;
     bool        ReadRules(bool test = false);
 
     static void * Run(void * data);
@@ -221,15 +218,18 @@ private:
     void        UnSetUserNotifiers(USER_IMPL * user);
 
     typedef std::list<RULE>::iterator rule_iter;
-    typedef std::map<RAW_PACKET, PACKET_EXTRA_DATA>::iterator pp_iter;
-    typedef std::multimap<uint32_t, pp_iter>::iterator ip2p_iter;
-    typedef std::multimap<uint32_t, pp_iter>::const_iterator ip2p_citer;
 
     std::list<RULE>          rules;
 
-    std::map<RAW_PACKET, PACKET_EXTRA_DATA> packets; // Packets tree
+    typedef std::map<RAW_PACKET, PACKET_EXTRA_DATA> Packets;
+    typedef Packets::iterator pp_iter;
+    typedef std::multimap<uint32_t, pp_iter> Index;
+    typedef Index::iterator ip2p_iter;
+    typedef Index::const_iterator ip2p_citer;
+
+    Packets packets; // Packets tree
 
-    std::multimap<uint32_t, pp_iter> ip2packets; // IP-to-Packet index
+    Index ip2packets; // IP-to-Packet index
 
     std::string              dirName[DIR_NUM + 1];
 
@@ -238,6 +238,7 @@ private:
 
     std::string              monitorDir;
     bool                     monitoring;
+    time_t                   touchTimeP;
 
     USERS_IMPL *             users;