X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/911b6d1f5643bf4d353774f82a8b742bec4e5677..691067e681cb883bccb7f4acdd2e4b4946776042:/projects/stargazer/plugins/other/snmp/snmp.cpp diff --git a/projects/stargazer/plugins/other/snmp/snmp.cpp b/projects/stargazer/plugins/other/snmp/snmp.cpp index 3ea7d70a..ff0cb614 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); } @@ -449,6 +453,29 @@ bool SNMP_AGENT::PDUsHandler(const SMUX_PDUs_t * pdus) { printfd(__FILE__, "SNMP_AGENT::PDUsHandler()\n"); asn_fprint(stderr, &asn_DEF_SMUX_PDUs, pdus); +PDUsHandlers::iterator it; +it = pdusHandlers.find(pdus->choice.pdus.present); +if (it != pdusHandlers.end()) + { + return (this->*(it->second))(&pdus->choice.pdus); + } +else + { + switch (pdus->present) + { + case PDUs_PR_NOTHING: + printfd(__FILE__, "SNMP_AGENT::PDUsHandler() - nothing\n"); + break; + case PDUs_PR_get_response: + printfd(__FILE__, "SNMP_AGENT::PDUsHandler() - get response\n"); + break; + case PDUs_PR_trap: + printfd(__FILE__, "SNMP_AGENT::PDUsHandler() - trap\n"); + break; + default: + printfd(__FILE__, "SNMP_AGENT::PDUsHandler() - undefined\n"); + } + } return false; } @@ -458,3 +485,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; +} +