1 #ifndef __SNMP_AGENT_H__
2 #define __SNMP_AGENT_H__
9 #include "asn1/SMUX-PDUs.h"
11 #include "stg/os_int.h"
12 #include "stg/plugin.h"
13 #include "stg/module_settings.h"
14 #include "stg/users.h"
16 extern "C" PLUGIN * GetPlugin();
22 typedef bool (SNMP_AGENT::*SNMPPacketHandler)(const SMUX_PDUs_t * pdus);
23 //-----------------------------------------------------------------------------
24 class SNMP_AGENT_SETTINGS {
26 SNMP_AGENT_SETTINGS();
27 virtual ~SNMP_AGENT_SETTINGS() {}
28 const std::string & GetStrError() const { return errorStr; }
29 int ParseSettings(const MODULE_SETTINGS & s);
31 uint32_t GetIP() const { return ip; }
32 uint16_t GetPort() const { return port; }
33 const std::string GetPassword() const { return password; }
36 mutable std::string errorStr;
42 //-----------------------------------------------------------------------------
43 class SNMP_AGENT : public PLUGIN {
46 virtual ~SNMP_AGENT();
48 void SetUsers(USERS *) {}
49 void SetTariffs(TARIFFS *) {}
50 void SetAdmins(ADMINS *) {}
51 void SetTraffcounter(TRAFFCOUNTER *) {}
52 void SetStore(STORE *) {}
53 void SetStgSettings(const SETTINGS *) {}
54 void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
59 int Reload() { return 0; }
60 bool IsRunning() { return running && !stopped; }
62 const std::string & GetStrError() const { return errorStr; }
63 const std::string GetVersion() const { return "Stg SNMP Agent 1.0"; }
64 uint16_t GetStartPosition() const { return 100; }
65 uint16_t GetStopPosition() const { return 100; }
68 static void * Runner(void * d);
72 bool DispatchPDUs(const SMUX_PDUs_t * pdus);
74 bool CloseHandler(const SMUX_PDUs_t * pdus);
75 bool RegisterResponseHandler(const SMUX_PDUs_t * pdus);
76 bool PDUsHandler(const SMUX_PDUs_t * pdus);
77 bool CommitOrRollbackHandler(const SMUX_PDUs_t * pdus);
79 mutable std::string errorStr;
80 SNMP_AGENT_SETTINGS snmpAgentSettings;
81 MODULE_SETTINGS settings;
84 pthread_mutex_t mutex;
90 std::map<SMUX_PDUs_PR, SNMPPacketHandler> handlers;
92 //-----------------------------------------------------------------------------
94 extern "C" PLUGIN * GetPlugin();