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();
31 typedef bool (SMUX::*SMUXPacketHandler)(const SMUX_PDUs_t * pdus);
32 typedef bool (SMUX::*PDUsHandler)(const PDUs_t * pdus);
33 typedef std::map<SMUX_PDUs_PR, SMUXPacketHandler> SMUXHandlers;
34 typedef std::map<PDUs_PR, PDUsHandler> PDUsHandlers;
35 //-----------------------------------------------------------------------------
39 virtual ~SMUX_SETTINGS() {}
40 const std::string & GetStrError() const { return errorStr; }
41 int ParseSettings(const MODULE_SETTINGS & s);
43 uint32_t GetIP() const { return ip; }
44 uint16_t GetPort() const { return port; }
45 const std::string GetPassword() const { return password; }
48 mutable std::string errorStr;
54 //-----------------------------------------------------------------------------
55 class SMUX : public PLUGIN {
60 void SetUsers(USERS * u) { users = u; }
61 void SetTariffs(TARIFFS * t) { tariffs = t; }
62 void SetAdmins(ADMINS * a) { admins = a; }
63 void SetServices(SERVICES * s) { services = s; }
64 void SetTraffcounter(TRAFFCOUNTER * tc) { traffcounter = tc; }
65 void SetCorporations(CORPORATIONS * c) { corporations = c; }
66 void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
71 int Reload() { return 0; }
72 bool IsRunning() { return running && !stopped; }
74 const std::string & GetStrError() const { return errorStr; }
75 const std::string GetVersion() const { return "Stg SMUX Plugin 1.1"; }
76 uint16_t GetStartPosition() const { return 100; }
77 uint16_t GetStopPosition() const { return 100; }
80 static void * Runner(void * d);
84 bool DispatchPDUs(const SMUX_PDUs_t * pdus);
86 bool CloseHandler(const SMUX_PDUs_t * pdus);
87 bool RegisterResponseHandler(const SMUX_PDUs_t * pdus);
88 bool PDUsRequestHandler(const SMUX_PDUs_t * pdus);
89 bool CommitOrRollbackHandler(const SMUX_PDUs_t * pdus);
91 bool GetRequestHandler(const PDUs_t * pdus);
92 bool GetNextRequestHandler(const PDUs_t * pdus);
93 bool SetRequestHandler(const PDUs_t * pdus);
101 CORPORATIONS * corporations;
102 TRAFFCOUNTER * traffcounter;
104 mutable std::string errorStr;
105 SMUX_SETTINGS smuxSettings;
106 MODULE_SETTINGS settings;
109 pthread_mutex_t mutex;
115 SMUXHandlers smuxHandlers;
116 PDUsHandlers pdusHandlers;
121 //-----------------------------------------------------------------------------
123 extern "C" PLUGIN * GetPlugin();