]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/snmp/snmp.h
Core functionality implemented
[stg.git] / projects / stargazer / plugins / other / snmp / snmp.h
index 7f4d67d1566b22ee598ed1f13f08260fc14d6919..90dba45e8d3d6da072bdf1ad56b5c7ab73b5da07 100644 (file)
@@ -4,7 +4,9 @@
 #include <pthread.h>
 
 #include <string>
-#include <list>
+#include <map>
+
+#include "asn1/SMUX-PDUs.h"
 
 #include "stg/os_int.h"
 #include "stg/plugin.h"
@@ -15,6 +17,9 @@ extern "C" PLUGIN * GetPlugin();
 
 class USER;
 class SETTINGS;
+class SNMP_AGENT;
+
+typedef bool (SNMP_AGENT::*SNMPPacketHandler)(const SMUX_PDUs_t * pdus);
 //-----------------------------------------------------------------------------
 class SNMP_AGENT_SETTINGS {
 public:
@@ -23,8 +28,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 +51,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 +67,14 @@ 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);
 
     mutable std::string errorStr;
     SNMP_AGENT_SETTINGS snmpAgentSettings;
@@ -63,7 +84,13 @@ private:
     pthread_mutex_t mutex;
     bool running;
     bool stopped;
+
+    int sock;
+
+    std::map<SMUX_PDUs_PR, SNMPPacketHandler> handlers;
 };
 //-----------------------------------------------------------------------------
 
+extern "C" PLUGIN * GetPlugin();
+
 #endif