]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
Move authorization from USER to USERS
[stg.git] / projects / stargazer / plugins / capture / cap_nf / cap_nf.cpp
index 23d6413c7bf132d1602d9400857eba4ac653ce92..a572e8a17af9efc02ab86c8c28e11a79a20302ea 100644 (file)
@@ -42,28 +42,14 @@ $Author: faust $
 #include "stg/common.h" 
 #include "stg/raw_ip_packet.h"
 #include "stg/traffcounter.h"
 #include "stg/common.h" 
 #include "stg/raw_ip_packet.h"
 #include "stg/traffcounter.h"
+#include "stg/plugin_creator.h"
 #include "cap_nf.h"
 
 #include "cap_nf.h"
 
-class CAP_NF_CREATOR {
-public:
-    CAP_NF_CREATOR()
-        : nf(new NF_CAP())
-        {
-        }
-
-    ~CAP_NF_CREATOR()
-        {
-        delete nf;
-        }
-
-    NF_CAP * GetCapturer() { return nf; }
-private:
-    NF_CAP * nf;
-} cnc;
+PLUGIN_CREATOR<NF_CAP> cnc;
 
 PLUGIN * GetPlugin()
 {
 
 PLUGIN * GetPlugin()
 {
-return cnc.GetCapturer();
+return cnc.GetPlugin();
 }
 
 NF_CAP::NF_CAP()
 }
 
 NF_CAP::NF_CAP()
@@ -262,7 +248,7 @@ socklen_t slen;
 cap->stoppedUDP = false;
 while (cap->runningUDP)
     {
 cap->stoppedUDP = false;
 while (cap->runningUDP)
     {
-    if (!cap->WaitPackets(cap->sockUDP))
+    if (!WaitPackets(cap->sockUDP))
         {
         continue;
         }
         {
         continue;
         }
@@ -305,7 +291,7 @@ socklen_t slen;
 cap->stoppedTCP = false;
 while (cap->runningTCP)
     {
 cap->stoppedTCP = false;
 while (cap->runningTCP)
     {
-    if (!cap->WaitPackets(cap->sockTCP))
+    if (!WaitPackets(cap->sockTCP))
         {
         continue;
         }
         {
         continue;
         }
@@ -326,7 +312,7 @@ while (cap->runningTCP)
         continue;
         }
 
         continue;
         }
 
-    if (!cap->WaitPackets(sd))
+    if (!WaitPackets(sd))
         {
         close(sd);
         continue;
         {
         close(sd);
         continue;
@@ -399,31 +385,3 @@ for (int i = 0; i < packets; ++i)
     traffCnt->Process(ip);
     }
 }
     traffCnt->Process(ip);
     }
 }
-
-bool NF_CAP::WaitPackets(int sd) const
-{
-fd_set rfds;
-FD_ZERO(&rfds);
-FD_SET(sd, &rfds);
-
-struct timeval tv;
-tv.tv_sec = 0;
-tv.tv_usec = 500000;
-
-int res = select(sd + 1, &rfds, NULL, NULL, &tv);
-if (res == -1) // Error
-    {
-    if (errno != EINTR)
-        {
-        printfd(__FILE__, "Error on select: '%s'\n", strerror(errno));
-        }
-    return false;
-    }
-
-if (res == 0) // Timeout
-    {
-    return false;
-    }
-
-return true;
-}