X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/5223bc7c163c9cd52e9ae4d8ad93a96e40e86632..374b3411c242bd965030bf046755e4a96a77c39c:/projects/stargazer/plugins/other/snmp/snmp.h diff --git a/projects/stargazer/plugins/other/snmp/snmp.h b/projects/stargazer/plugins/other/snmp/snmp.h index 7f4d67d1..c872523a 100644 --- a/projects/stargazer/plugins/other/snmp/snmp.h +++ b/projects/stargazer/plugins/other/snmp/snmp.h @@ -4,7 +4,9 @@ #include #include -#include +#include + +#include "asn1/SMUX-PDUs.h" #include "stg/os_int.h" #include "stg/plugin.h" @@ -15,6 +17,12 @@ extern "C" PLUGIN * GetPlugin(); class USER; class SETTINGS; +class SNMP_AGENT; + +typedef bool (SNMP_AGENT::*SMUXPacketHandler)(const SMUX_PDUs_t * pdus); +typedef bool (SNMP_AGENT::*PDUsHandler)(const PDUs_t * pdus); +typedef std::map SMUXHandlers; +typedef std::map PDUsHandlers; //----------------------------------------------------------------------------- class SNMP_AGENT_SETTINGS { public: @@ -23,8 +31,16 @@ public: const std::string & GetStrError() const { return errorStr; } int ParseSettings(const MODULE_SETTINGS & s); + uint32_t GetIP() const { return ip; } + uint16_t GetPort() const { return port; } + const std::string GetPassword() const { return password; } + private: mutable std::string errorStr; + + uint32_t ip; + uint16_t port; + std::string password; }; //----------------------------------------------------------------------------- class SNMP_AGENT : public PLUGIN { @@ -38,7 +54,7 @@ public: void SetTraffcounter(TRAFFCOUNTER *) {} void SetStore(STORE *) {} void SetStgSettings(const SETTINGS *) {} - void SetSettings(const MODULE_SETTINGS &) {} + void SetSettings(const MODULE_SETTINGS & s) { settings = s; } int ParseSettings(); int Start(); @@ -54,6 +70,18 @@ public: private: static void * Runner(void * d); void Run(); + bool PrepareNet(); + + bool DispatchPDUs(const SMUX_PDUs_t * pdus); + + bool CloseHandler(const SMUX_PDUs_t * pdus); + bool RegisterResponseHandler(const SMUX_PDUs_t * pdus); + bool PDUsHandler(const SMUX_PDUs_t * pdus); + bool CommitOrRollbackHandler(const SMUX_PDUs_t * pdus); + + bool GetRequestHandler(const PDUs_t * pdus); + bool GetNextRequestHandler(const PDUs_t * pdus); + bool SetRequestHandler(const PDUs_t * pdus); mutable std::string errorStr; SNMP_AGENT_SETTINGS snmpAgentSettings; @@ -63,7 +91,14 @@ private: pthread_mutex_t mutex; bool running; bool stopped; + + int sock; + + SMUXHandlers smuxHandlers; + PDUsHandlers pdusHandlers; }; //----------------------------------------------------------------------------- +extern "C" PLUGIN * GetPlugin(); + #endif