]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/snmp/snmp.h
Use data sensors in queries
[stg.git] / projects / stargazer / plugins / other / snmp / snmp.h
index fe5fa05e9f34ab46eb39bccd5931d97bc3e84d00..540bd3d7c328eba9d7519fa6ab29d0548b143405 100644 (file)
@@ -4,16 +4,29 @@
 #include <pthread.h>
 
 #include <string>
+#include <map>
+
+#include "asn1/SMUX-PDUs.h"
+#include "asn1/ObjectSyntax.h"
 
 #include "stg/os_int.h"
 #include "stg/plugin.h"
 #include "stg/module_settings.h"
 #include "stg/users.h"
+#include "stg/tariffs.h"
+
+#include "sensors.h"
 
 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<SMUX_PDUs_PR, SMUXPacketHandler> SMUXHandlers;
+typedef std::map<PDUs_PR, PDUsHandler> PDUsHandlers;
 //-----------------------------------------------------------------------------
 class SNMP_AGENT_SETTINGS {
 public:
@@ -39,8 +52,8 @@ public:
     SNMP_AGENT();
     virtual ~SNMP_AGENT();
 
-    void SetUsers(USERS *) {}
-    void SetTariffs(TARIFFS *) {}
+    void SetUsers(USERS * u) { users = u; }
+    void SetTariffs(TARIFFS * t) { tariffs = t; }
     void SetAdmins(ADMINS *) {}
     void SetTraffcounter(TRAFFCOUNTER *) {}
     void SetStore(STORE *) {}
@@ -63,6 +76,20 @@ private:
     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);
+
+    USERS * users;
+    TARIFFS * tariffs;
+
     mutable std::string errorStr;
     SNMP_AGENT_SETTINGS snmpAgentSettings;
     MODULE_SETTINGS settings;
@@ -73,6 +100,10 @@ private:
     bool stopped;
 
     int sock;
+
+    SMUXHandlers smuxHandlers;
+    PDUsHandlers pdusHandlers;
+    Sensors sensors;
 };
 //-----------------------------------------------------------------------------