From: Maksym Mamontov Date: Mon, 24 Feb 2020 16:15:14 +0000 (+0200) Subject: Some more BSD-related issues. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/83ce40b2a471b560ec7516efebcb5ddcf7519071?hp=1345c0a23da2a0dc0bbeb6a91783abef1b235fbe Some more BSD-related issues. --- diff --git a/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp b/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp index 685eb618..fcf262fa 100644 --- a/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp +++ b/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp @@ -56,15 +56,15 @@ $Author: faust $ //#define CAP_DEBUG 1 -extern "C" Plugin* GetPlugin() +extern "C" STG::Plugin* GetPlugin() { -static BPF_CAP plugin; -return &plugin; + static BPF_CAP plugin; + return &plugin; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int BPF_CAP_SETTINGS::ParseSettings(const MODULE_SETTINGS & s) +int BPF_CAP_SETTINGS::ParseSettings(const STG::ModuleSettings & s) { iface.erase(iface.begin(), iface.end()); @@ -113,7 +113,7 @@ BPF_CAP::BPF_CAP() isRunning(false), capSock(-1), traffCnt(NULL), - logger(PluginLogger::get("cap_bpf")) + logger(STG::PluginLogger::get("cap_bpf")) { } //----------------------------------------------------------------------------- @@ -199,7 +199,7 @@ dc->isRunning = true; uint8_t hdr[96]; //68 + 14 + 4(size) + 9(SYS_IFACE) + 1(align to 4) = 96 -RAW_PACKET * rpp = (RAW_PACKET *)&hdr[14]; +STG::RawPacket * rpp = (STG::RawPacket *)&hdr[14]; memset(hdr, 0, sizeof(hdr)); rpp->dataLen = -1; @@ -213,7 +213,7 @@ while (dc->nonstop) if (!(hdr[12] == 0x8 && hdr[13] == 0x0)) continue; - dc->traffCnt->Process(*rpp); + dc->traffCnt->process(*rpp); } dc->isRunning = false; diff --git a/stargazer/plugins/capture/ether_freebsd/ether_cap.h b/stargazer/plugins/capture/ether_freebsd/ether_cap.h index 29ad8419..96761d3a 100644 --- a/stargazer/plugins/capture/ether_freebsd/ether_cap.h +++ b/stargazer/plugins/capture/ether_freebsd/ether_cap.h @@ -24,22 +24,24 @@ * Author : Boris Mikhailenko */ -#ifndef ETHER_CAP_H -#define ETHER_CAP_H +#pragma once -#include +#include "stg/plugin.h" +#include "stg/module_settings.h" +#include "stg/logger.h" #include #include #include -#include "stg/plugin.h" -#include "stg/module_settings.h" -#include "stg/logger.h" +#include #define BUFF_LEN (128) -class TRAFFCOUNTER; +namespace STG +{ +struct TraffCounter; +} //----------------------------------------------------------------------------- struct BPF_DATA { @@ -79,9 +81,8 @@ std::string iface; //----------------------------------------------------------------------------- class BPF_CAP_SETTINGS { public: - virtual ~BPF_CAP_SETTINGS() {} const std::string & GetStrError() const { return errorStr; } - int ParseSettings(const MODULE_SETTINGS & s); + int ParseSettings(const STG::ModuleSettings & s); std::string GetIface(unsigned int num); private: @@ -89,25 +90,24 @@ private: mutable std::string errorStr; }; //----------------------------------------------------------------------------- -class BPF_CAP : public PLUGIN { +class BPF_CAP : public STG::Plugin { public: BPF_CAP(); - virtual ~BPF_CAP() {} - void SetTraffcounter(TRAFFCOUNTER * tc) { traffCnt = tc; } + void SetTraffcounter(STG::TraffCounter * tc) override { traffCnt = tc; } - int Start(); - int Stop(); - int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } - bool IsRunning() { return isRunning; } + int Start() override; + int Stop() override; + int Reload(const STG::ModuleSettings & /*ms*/) override { return 0; } + bool IsRunning() override { return isRunning; } - void SetSettings(const MODULE_SETTINGS & s) { settings = s; } - int ParseSettings(); + void SetSettings(const STG::ModuleSettings & s) override { settings = s; } + int ParseSettings() override; - const std::string & GetStrError() const { return errorStr; } - std::string GetVersion() const; - uint16_t GetStartPosition() const { return 40; } - uint16_t GetStopPosition() const { return 40; } + const std::string & GetStrError() const override { return errorStr; } + std::string GetVersion() const override; + uint16_t GetStartPosition() const override { return 40; } + uint16_t GetStopPosition() const override { return 40; } private: BPF_CAP(const BPF_CAP & rvalue); @@ -131,12 +131,9 @@ private: bool nonstop; bool isRunning; int capSock; - MODULE_SETTINGS settings; + STG::ModuleSettings settings; - TRAFFCOUNTER * traffCnt; + STG::TraffCounter * traffCnt; - PLUGIN_LOGGER logger; + STG::PluginLogger logger; }; -//----------------------------------------------------------------------------- - -#endif