X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/597f6f31e3801612273886481381df509d8bcd12..36f332ceb538480aeaed0dfa9917e983cac77389:/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp index 9a9d1543..5cf5358f 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp @@ -45,7 +45,7 @@ $Date: 2010/09/10 06:43:03 $ #include "stg/common.h" #include "stg/traffcounter.h" -#include "sg/plugin_creator.h" +#include "stg/plugin_creator.h" #include "divert_cap.h" #define BUFF_LEN (16384) /* max mtu -> lo=16436 TODO why?*/ @@ -54,7 +54,6 @@ $Date: 2010/09/10 06:43:03 $ struct DIVERT_DATA { int sock; short int port; -unsigned char buffer[BUFF_LEN]; char iface[10]; }; //----------------------------------------------------------------------------- @@ -82,6 +81,7 @@ return "Divert_cap v.1.0"; DIVERT_CAP::DIVERT_CAP() : settings(), port(0), + disableForwarding(false), errorStr(), thread(), nonstop(false), @@ -166,7 +166,7 @@ while (dc->nonstop) if (buffer[12] != 0x8) continue; - memcpy(rp.pckt, &buffer[14], pcktSize); + memcpy(rp.rawPacket.pckt, &buffer[14], pcktSize); dc->traffCnt->Process(rp); } @@ -251,7 +251,8 @@ if ((bytes = recvfrom (cddiv.sock, buf, BUFF_LEN, if (iface) *iface = cddiv.iface; - sendto(cddiv.sock, buf, bytes, 0, (struct sockaddr*)&divertaddr, divertaddrSize); + if (!disableForwarding) + sendto(cddiv.sock, buf, bytes, 0, (struct sockaddr*)&divertaddr, divertaddrSize); } return 0; @@ -273,11 +274,9 @@ pv.param = "Port"; pvi = std::find(settings.moduleParams.begin(), settings.moduleParams.end(), pv); if (pvi == settings.moduleParams.end()) { - port = 15701; - return 0; + p = 15701; } - -if (ParseIntInRange(pvi->value[0], 1, 65535, &p)) +else if (ParseIntInRange(pvi->value[0], 1, 65535, &p)) { errorStr = "Cannot parse parameter \'Port\': " + errorStr; printfd(__FILE__, "Cannot parse parameter 'Port'\n"); @@ -286,6 +285,22 @@ if (ParseIntInRange(pvi->value[0], 1, 65535, &p)) port = p; +bool d = false; +pv.param = "DisableForwarding"; +pvi = std::find(settings.moduleParams.begin(), settings.moduleParams.end(), pv); +if (pvi == settings.moduleParams.end()) + { + disableForwarding = false; + } +else if (ParseYesNo(pvi->value[0], &d)) + { + errorStr = "Cannot parse parameter \'DisableForwarding\': " + errorStr; + printfd(__FILE__, "Cannot parse parameter 'DisableForwarding'\n"); + return -1; + } + +disableForwarding = d; + return 0; } //-----------------------------------------------------------------------------