From 374b3411c242bd965030bf046755e4a96a77c39c Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Wed, 1 Jun 2011 11:57:49 +0300 Subject: [PATCH] Request handlers added --- .../stargazer/plugins/other/snmp/snmp.cpp | 40 +++++++++++++++---- projects/stargazer/plugins/other/snmp/snmp.h | 12 +++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/projects/stargazer/plugins/other/snmp/snmp.cpp b/projects/stargazer/plugins/other/snmp/snmp.cpp index 3ea7d70a..444b812b 100644 --- a/projects/stargazer/plugins/other/snmp/snmp.cpp +++ b/projects/stargazer/plugins/other/snmp/snmp.cpp @@ -244,10 +244,14 @@ SNMP_AGENT::SNMP_AGENT() { pthread_mutex_init(&mutex, NULL); -handlers[SMUX_PDUs_PR_close] = &SNMP_AGENT::CloseHandler; -handlers[SMUX_PDUs_PR_registerResponse] = &SNMP_AGENT::RegisterResponseHandler; -handlers[SMUX_PDUs_PR_pdus] = &SNMP_AGENT::PDUsHandler; -handlers[SMUX_PDUs_PR_commitOrRollback] = &SNMP_AGENT::CommitOrRollbackHandler; +smuxHandlers[SMUX_PDUs_PR_close] = &SNMP_AGENT::CloseHandler; +smuxHandlers[SMUX_PDUs_PR_registerResponse] = &SNMP_AGENT::RegisterResponseHandler; +smuxHandlers[SMUX_PDUs_PR_pdus] = &SNMP_AGENT::PDUsHandler; +smuxHandlers[SMUX_PDUs_PR_commitOrRollback] = &SNMP_AGENT::CommitOrRollbackHandler; + +pdusHandlers[PDUs_PR_get_request] = &SNMP_AGENT::GetRequestHandler; +pdusHandlers[PDUs_PR_get_next_request] = &SNMP_AGENT::GetNextRequestHandler; +pdusHandlers[PDUs_PR_set_request] = &SNMP_AGENT::SetRequestHandler; } SNMP_AGENT::~SNMP_AGENT() @@ -404,9 +408,9 @@ return true; bool SNMP_AGENT::DispatchPDUs(const SMUX_PDUs_t * pdus) { -std::map::iterator it; -it = handlers.find(pdus->present); -if (it != handlers.end()) +SMUXHandlers::iterator it; +it = smuxHandlers.find(pdus->present); +if (it != smuxHandlers.end()) { return (this->*(it->second))(pdus); } @@ -458,3 +462,25 @@ printfd(__FILE__, "SNMP_AGENT::CommitOrRollbackHandler()\n"); asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); return false; } + +bool SNMP_AGENT::GetRequestHandler(const PDUs_t * pdus) +{ +printfd(__FILE__, "SNMP_AGENT::GetRequestHandler()\n"); +asn_fprint(stderr, &asn_DEF_PDUs, pdus); +return false; +} + +bool SNMP_AGENT::GetNextRequestHandler(const PDUs_t * pdus) +{ +printfd(__FILE__, "SNMP_AGENT::GetNextRequestHandler()\n"); +asn_fprint(stderr, &asn_DEF_PDUs, pdus); +return false; +} + +bool SNMP_AGENT::SetRequestHandler(const PDUs_t * pdus) +{ +printfd(__FILE__, "SNMP_AGENT::SetRequestHandler()\n"); +asn_fprint(stderr, &asn_DEF_PDUs, pdus); +return false; +} + diff --git a/projects/stargazer/plugins/other/snmp/snmp.h b/projects/stargazer/plugins/other/snmp/snmp.h index 90dba45e..c872523a 100644 --- a/projects/stargazer/plugins/other/snmp/snmp.h +++ b/projects/stargazer/plugins/other/snmp/snmp.h @@ -19,7 +19,10 @@ class USER; class SETTINGS; class SNMP_AGENT; -typedef bool (SNMP_AGENT::*SNMPPacketHandler)(const SMUX_PDUs_t * pdus); +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: @@ -76,6 +79,10 @@ private: 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; MODULE_SETTINGS settings; @@ -87,7 +94,8 @@ private: int sock; - std::map handlers; + SMUXHandlers smuxHandlers; + PDUsHandlers pdusHandlers; }; //----------------------------------------------------------------------------- -- 2.44.2