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"
20 extern "C" PLUGIN * GetPlugin();
30 typedef bool (SMUX::*SMUXPacketHandler)(const SMUX_PDUs_t * pdus);
31 typedef bool (SMUX::*PDUsHandler)(const PDUs_t * pdus);
32 typedef std::map<SMUX_PDUs_PR, SMUXPacketHandler> SMUXHandlers;
33 typedef std::map<PDUs_PR, PDUsHandler> PDUsHandlers;
34 //-----------------------------------------------------------------------------
38 virtual ~SMUX_SETTINGS() {}
39 const std::string & GetStrError() const { return errorStr; }
40 int ParseSettings(const MODULE_SETTINGS & s);
42 uint32_t GetIP() const { return ip; }
43 uint16_t GetPort() const { return port; }
44 const std::string GetPassword() const { return password; }
47 mutable std::string errorStr;
53 //-----------------------------------------------------------------------------
54 class SMUX : public PLUGIN {
59 void SetUsers(USERS * u) { users = u; }
60 void SetTariffs(TARIFFS * t) { tariffs = t; }
61 void SetAdmins(ADMINS * a) { admins = a; }
62 void SetServices(SERVICES * s) { services = s; }
63 void SetCorporations(CORPORATIONS * c) { corporations = c; }
64 void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
69 int Reload() { return 0; }
70 bool IsRunning() { return running && !stopped; }
72 const std::string & GetStrError() const { return errorStr; }
73 const std::string GetVersion() const { return "Stg SMUX Plugin 1.1"; }
74 uint16_t GetStartPosition() const { return 100; }
75 uint16_t GetStopPosition() const { return 100; }
78 static void * Runner(void * d);
82 bool DispatchPDUs(const SMUX_PDUs_t * pdus);
84 bool CloseHandler(const SMUX_PDUs_t * pdus);
85 bool RegisterResponseHandler(const SMUX_PDUs_t * pdus);
86 bool PDUsRequestHandler(const SMUX_PDUs_t * pdus);
87 bool CommitOrRollbackHandler(const SMUX_PDUs_t * pdus);
89 bool GetRequestHandler(const PDUs_t * pdus);
90 bool GetNextRequestHandler(const PDUs_t * pdus);
91 bool SetRequestHandler(const PDUs_t * pdus);
99 CORPORATIONS * corporations;
101 mutable std::string errorStr;
102 SMUX_SETTINGS smuxSettings;
103 MODULE_SETTINGS settings;
106 pthread_mutex_t mutex;
112 SMUXHandlers smuxHandlers;
113 PDUsHandlers pdusHandlers;
118 //-----------------------------------------------------------------------------
120 extern "C" PLUGIN * GetPlugin();