#include "nfqueue.h"
#include "stg/traffcounter.h"
-#include "stg/plugin_creator.h"
#include "stg/common.h"
#include "stg/raw_ip_packet.h"
namespace
{
-PLUGIN_CREATOR<NFQ_CAP> ncc;
-
int Callback(struct nfq_q_handle * queueHandle, struct nfgenmsg * /*msg*/,
struct nfq_data * nfqData, void *data)
{
if (nfq_get_payload(nfqData, &payload) < 0 || payload == NULL)
return id;
-RAW_PACKET packet;
+STG::RawPacket packet;
memcpy(&packet.rawPacket, payload, sizeof(packet.rawPacket));
}
-extern "C" PLUGIN * GetPlugin();
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-PLUGIN * GetPlugin()
+extern "C" STG::Plugin* GetPlugin()
{
-return ncc.GetPlugin();
+ static NFQ_CAP plugin;
+ return &plugin;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
nfqHandle(NULL),
queueHandle(NULL),
traffCnt(NULL),
- logger(GetPluginLogger(GetStgLogger(), "cap_nfqueue"))
+ logger(STG::PluginLogger::get("cap_nfqueue"))
{
}
//-----------------------------------------------------------------------------
queueHandle = nfq_create_queue(nfqHandle, queueNumber, &Callback, this);
if (queueHandle == NULL)
{
- errorStr = "Failed to create queue " + x2str(queueNumber) + ".";
+ errorStr = "Failed to create queue " + std::to_string(queueNumber) + ".";
logger(errorStr);
return -1;
}
if (nfq_set_mode(queueHandle, NFQNL_COPY_PACKET, 0xffFF) < 0)
{
- errorStr = "Failed to set queue " + x2str(queueNumber) + " mode.";
+ errorStr = "Failed to set queue " + std::to_string(queueNumber) + " mode.";
logger(errorStr);
return -1;
}
return NULL;
}
//-----------------------------------------------------------------------------
-void NFQ_CAP::Process(const RAW_PACKET & packet)
+void NFQ_CAP::Process(const STG::RawPacket & packet)
{
-traffCnt->Process(packet);
+traffCnt->process(packet);
}