]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp
TEST_SETTINGS_LOCAL moved outside the namespace, more assertions added
[stg.git] / projects / stargazer / plugins / capture / cap_nf / cap_nf.cpp
index 11a96ef1ef281ffffa6621d6ba67707aec3d7e92..23d6413c7bf132d1602d9400857eba4ac653ce92 100644 (file)
@@ -37,31 +37,31 @@ $Author: faust $
 #include <cerrno>
 #include <cstring>
 
 #include <cerrno>
 #include <cstring>
 
-#include "common.h" 
-#include "cap_nf.h"
-#include "raw_ip_packet.h"
+#include <vector>
 
 
-#include "../../../traffcounter.h"
+#include "stg/common.h" 
+#include "stg/raw_ip_packet.h"
+#include "stg/traffcounter.h"
+#include "cap_nf.h"
 
 
-class CAP_NF_CREATOR
-{
+class CAP_NF_CREATOR {
 public:
     CAP_NF_CREATOR()
         : nf(new NF_CAP())
         {
 public:
     CAP_NF_CREATOR()
         : nf(new NF_CAP())
         {
-        };
+        }
 
     ~CAP_NF_CREATOR()
         {
         delete nf;
 
     ~CAP_NF_CREATOR()
         {
         delete nf;
-        };
+        }
 
 
-    NF_CAP * GetCapturer() { return nf; };
+    NF_CAP * GetCapturer() { return nf; }
 private:
     NF_CAP * nf;
 } cnc;
 
 private:
     NF_CAP * nf;
 } cnc;
 
-BASE_PLUGIN * GetPlugin()
+PLUGIN * GetPlugin()
 {
 return cnc.GetCapturer();
 }
 {
 return cnc.GetCapturer();
 }
@@ -87,7 +87,7 @@ NF_CAP::~NF_CAP()
 
 int NF_CAP::ParseSettings()
 {
 
 int NF_CAP::ParseSettings()
 {
-vector<PARAM_VALUE>::iterator it;
+std::vector<PARAM_VALUE>::iterator it;
 for (it = settings.moduleParams.begin(); it != settings.moduleParams.end(); ++it)
     {
     if (it->param == "TCPPort")
 for (it = settings.moduleParams.begin(); it != settings.moduleParams.end(); ++it)
     {
     if (it->param == "TCPPort")
@@ -278,9 +278,6 @@ while (cap->runningUDP)
         continue;
         }
 
         continue;
         }
 
-
-    // Wrong logic!
-    // Need to check actual data length and wait all data to receive
     if (res < 24)
         {
         if (errno != EINTR)
     if (res < 24)
         {
         if (errno != EINTR)
@@ -390,22 +387,14 @@ for (int i = 0; i < packets; ++i)
     {
     NF_DATA * data = reinterpret_cast<NF_DATA *>(buf + 24 + i * 48);
 
     {
     NF_DATA * data = reinterpret_cast<NF_DATA *>(buf + 24 + i * 48);
 
-    /*ip.pckt[0] = 4 << 4;
-    ip.pckt[0] |= 5;
-    ip.pckt[9] = data->proto;
-    ip.dataLen = ntohl(data->octets);
-    *(uint32_t *)(ip.pckt + 12) = data->srcAddr;
-    *(uint32_t *)(ip.pckt + 16) = data->dstAddr;
-    *(uint16_t *)(ip.pckt + 20) = data->srcPort;
-    *(uint16_t *)(ip.pckt + 22) = data->dstPort;*/
-    ip.ipHeader.ip_v = 4;
-    ip.ipHeader.ip_hl = 5;
-    ip.ipHeader.ip_p = data->proto;
+    ip.header.ipHeader.ip_v = 4;
+    ip.header.ipHeader.ip_hl = 5;
+    ip.header.ipHeader.ip_p = data->proto;
     ip.dataLen = ntohl(data->octets);
     ip.dataLen = ntohl(data->octets);
-    ip.ipHeader.ip_src.s_addr = data->srcAddr;
-    ip.ipHeader.ip_dst.s_addr = data->dstAddr;
-    ip.sPort = data->srcPort;
-    ip.dPort = data->dstPort;
+    ip.header.ipHeader.ip_src.s_addr = data->srcAddr;
+    ip.header.ipHeader.ip_dst.s_addr = data->dstAddr;
+    ip.header.sPort = data->srcPort;
+    ip.header.dPort = data->dstPort;
 
     traffCnt->Process(ip);
     }
 
     traffCnt->Process(ip);
     }