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"
 
  21 extern "C" PLUGIN * GetPlugin();
 
  27 typedef bool (SMUX::*SMUXPacketHandler)(const SMUX_PDUs_t * pdus);
 
  28 typedef bool (SMUX::*PDUsHandler)(const PDUs_t * pdus);
 
  29 typedef std::map<SMUX_PDUs_PR, SMUXPacketHandler> SMUXHandlers;
 
  30 typedef std::map<PDUs_PR, PDUsHandler> PDUsHandlers;
 
  31 //-----------------------------------------------------------------------------
 
  35     virtual ~SMUX_SETTINGS() {}
 
  36     const std::string & GetStrError() const { return errorStr; }
 
  37     int ParseSettings(const MODULE_SETTINGS & s);
 
  39     uint32_t GetIP() const { return ip; }
 
  40     uint16_t GetPort() const { return port; }
 
  41     const std::string GetPassword() const { return password; }
 
  44     mutable std::string errorStr;
 
  50 //-----------------------------------------------------------------------------
 
  51 class SMUX : public PLUGIN {
 
  56     void SetUsers(USERS * u) { users = u; }
 
  57     void SetTariffs(TARIFFS * t) { tariffs = t; }
 
  58     void SetAdmins(ADMINS *) {}
 
  59     void SetTraffcounter(TRAFFCOUNTER *) {}
 
  60     void SetStore(STORE *) {}
 
  61     void SetStgSettings(const SETTINGS *) {}
 
  62     void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
 
  67     int Reload() { return 0; }
 
  68     bool IsRunning() { return running && !stopped; }
 
  70     const std::string & GetStrError() const { return errorStr; }
 
  71     const std::string GetVersion() const { return "Stg SMUX Plugin 1.1"; }
 
  72     uint16_t GetStartPosition() const { return 100; }
 
  73     uint16_t GetStopPosition() const { return 100; }
 
  76     static void * Runner(void * d);
 
  80     bool DispatchPDUs(const SMUX_PDUs_t * pdus);
 
  82     bool CloseHandler(const SMUX_PDUs_t * pdus);
 
  83     bool RegisterResponseHandler(const SMUX_PDUs_t * pdus);
 
  84     bool PDUsRequestHandler(const SMUX_PDUs_t * pdus);
 
  85     bool CommitOrRollbackHandler(const SMUX_PDUs_t * pdus);
 
  87     bool GetRequestHandler(const PDUs_t * pdus);
 
  88     bool GetNextRequestHandler(const PDUs_t * pdus);
 
  89     bool SetRequestHandler(const PDUs_t * pdus);
 
  94     mutable std::string errorStr;
 
  95     SMUX_SETTINGS smuxSettings;
 
  96     MODULE_SETTINGS settings;
 
  99     pthread_mutex_t mutex;
 
 105     SMUXHandlers smuxHandlers;
 
 106     PDUsHandlers pdusHandlers;
 
 110 //-----------------------------------------------------------------------------
 
 112 extern "C" PLUGIN * GetPlugin();