]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp
Code deduplication (plugin creation via template PLUGIN_CREATOR)
[stg.git] / projects / stargazer / plugins / capture / cap_debug / debug_cap.cpp
index 799e399d39c9884541f37a6e9109b386b3671923..f4b4f8ae373af102877d7c03b1ec3fa4fde8b6e1 100644 (file)
@@ -37,6 +37,7 @@ $Author: faust $
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+#include "stg/plugin_creator.h"
 #include "debug_cap.h"
 #include "../../../traffcounter.h"
 #include "libpal.h"
@@ -53,46 +54,26 @@ fprintf(f, "up %5.2f Mbit, down %5.2f Mbit, sum %5.2f Mbit\n",
 fclose(f);
 }
 //-----------------------------------------------------------------------------
-
-class CAP_DEBUG_CREATOR
-{
-private:
-    DEBUG_CAP * dc;
-
-public:
-    CAP_DEBUG_CREATOR()
-        : dc(new DEBUG_CAP())
-        {
-        };
-    ~CAP_DEBUG_CREATOR()
-        {
-        delete dc;
-        };
-
-    DEBUG_CAP * GetCapturer()
-    {
-        return dc;
-    };
-};
-//-----------------------------------------------------------------------------
-RAW_PACKET MakeTCPPacket(const char * src,
-                         const char * dst,
-                         uint16_t sport,
-                         uint16_t dport,
-                         uint16_t len);
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-CAP_DEBUG_CREATOR cdc;
+PLUGIN_CREATOR<DEBUG_CAP> cdc;
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 BASE_PLUGIN * GetPlugin()
 {
-return cdc.GetCapturer();
+return cdc.GetPlugin();
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+RAW_PACKET MakeTCPPacket(const char * src,
+                         const char * dst,
+                         uint16_t sport,
+                         uint16_t dport,
+                         uint16_t len);
 const string DEBUG_CAP::GetVersion() const
 {
 return "Debug_cap v.0.01a";