9 #include "stg/SMUX-PDUs.h"
10 #include "stg/ObjectSyntax.h"
12 #include "stg/os_int.h"
13 #include "stg/plugin.h"
14 #include "stg/module_settings.h"
15 #include "stg/users.h"
16 #include "stg/tariffs.h"
22 extern "C" PLUGIN * GetPlugin();
28 typedef bool (SMUX::*SMUXPacketHandler)(const SMUX_PDUs_t * pdus);
29 typedef bool (SMUX::*PDUsHandler)(const PDUs_t * pdus);
30 typedef std::map<SMUX_PDUs_PR, SMUXPacketHandler> SMUXHandlers;
31 typedef std::map<PDUs_PR, PDUsHandler> PDUsHandlers;
32 //-----------------------------------------------------------------------------
36 virtual ~SMUX_SETTINGS() {}
37 const std::string & GetStrError() const { return errorStr; }
38 int ParseSettings(const MODULE_SETTINGS & s);
40 uint32_t GetIP() const { return ip; }
41 uint16_t GetPort() const { return port; }
42 const std::string GetPassword() const { return password; }
45 mutable std::string errorStr;
51 //-----------------------------------------------------------------------------
52 class SMUX : public PLUGIN {
57 void SetUsers(USERS * u) { users = u; }
58 void SetTariffs(TARIFFS * t) { tariffs = t; }
59 void SetAdmins(ADMINS *) {}
60 void SetTraffcounter(TRAFFCOUNTER *) {}
61 void SetStore(STORE *) {}
62 void SetStgSettings(const SETTINGS *) {}
63 void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
68 int Reload() { return 0; }
69 bool IsRunning() { return running && !stopped; }
71 const std::string & GetStrError() const { return errorStr; }
72 const std::string GetVersion() const { return "Stg SMUX Plugin 1.1"; }
73 uint16_t GetStartPosition() const { return 100; }
74 uint16_t GetStopPosition() const { return 100; }
77 static void * Runner(void * d);
81 bool DispatchPDUs(const SMUX_PDUs_t * pdus);
83 bool CloseHandler(const SMUX_PDUs_t * pdus);
84 bool RegisterResponseHandler(const SMUX_PDUs_t * pdus);
85 bool PDUsRequestHandler(const SMUX_PDUs_t * pdus);
86 bool CommitOrRollbackHandler(const SMUX_PDUs_t * pdus);
88 bool GetRequestHandler(const PDUs_t * pdus);
89 bool GetNextRequestHandler(const PDUs_t * pdus);
90 bool SetRequestHandler(const PDUs_t * pdus);
97 mutable std::string errorStr;
98 SMUX_SETTINGS smuxSettings;
99 MODULE_SETTINGS settings;
102 pthread_mutex_t mutex;
108 SMUXHandlers smuxHandlers;
109 PDUsHandlers pdusHandlers;
114 //-----------------------------------------------------------------------------
116 extern "C" PLUGIN * GetPlugin();