]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/snmp/snmp.h
Base plugin structure implemented for SNMP Agent plugin
[stg.git] / projects / stargazer / plugins / other / snmp / snmp.h
1 #ifndef __SNMP_AGENT_H__
2 #define __SNMP_AGENT_H__
3
4 #include <pthread.h>
5
6 #include <string>
7 #include <list>
8
9 #include "stg/os_int.h"
10 #include "stg/plugin.h"
11 #include "stg/module_settings.h"
12 #include "stg/users.h"
13
14 extern "C" PLUGIN * GetPlugin();
15
16 class USER;
17 class SETTINGS;
18 //-----------------------------------------------------------------------------
19 class SNMP_AGENT_SETTINGS {
20 public:
21     SNMP_AGENT_SETTINGS();
22     virtual ~SNMP_AGENT_SETTINGS() {}
23     const std::string & GetStrError() const { return errorStr; }
24     int ParseSettings(const MODULE_SETTINGS & s);
25
26 private:
27     mutable std::string errorStr;
28 };
29 //-----------------------------------------------------------------------------
30 class SNMP_AGENT : public PLUGIN {
31 public:
32     SNMP_AGENT();
33     virtual ~SNMP_AGENT();
34
35     void SetUsers(USERS *) {}
36     void SetTariffs(TARIFFS *) {}
37     void SetAdmins(ADMINS *) {}
38     void SetTraffcounter(TRAFFCOUNTER *) {}
39     void SetStore(STORE *) {}
40     void SetStgSettings(const SETTINGS *) {}
41     void SetSettings(const MODULE_SETTINGS &) {}
42     int ParseSettings();
43
44     int Start();
45     int Stop();
46     int Reload() { return 0; }
47     bool IsRunning() { return running && !stopped; }
48
49     const std::string & GetStrError() const { return errorStr; }
50     const std::string GetVersion() const { return "Stg SNMP Agent 1.0"; }
51     uint16_t GetStartPosition() const { return 100; }
52     uint16_t GetStopPosition() const { return 100; }
53
54 private:
55     static void * Runner(void * d);
56     void Run();
57
58     mutable std::string errorStr;
59     SNMP_AGENT_SETTINGS snmpAgentSettings;
60     MODULE_SETTINGS settings;
61
62     pthread_t thread;
63     pthread_mutex_t mutex;
64     bool running;
65     bool stopped;
66 };
67 //-----------------------------------------------------------------------------
68
69 #endif