diff --git a/radmin b/radmin index e361db6..0bd9a6b 100755 --- a/radmin +++ b/radmin @@ -130,11 +130,12 @@ do ps -aux | grep -e xlxd -e xrfd -e ambed | grep -v grep fi echo - echo " Reflector Administration, Version #200716" + echo " Reflector Administration, Version #200723" echo echo "ls : List the configuration file" echo "cl : Clean (remove) compiled objects and executables" echo "gp : Pull the latest software from the repo" + echo "br : Change git branch to " echo "co : Compile the system executable(s)" if [ -e $xlxserv ] || [ -e $xrfserv ]; then if [ -e $xlxserv ] && [ -e $xrfserv ]; then @@ -195,6 +196,11 @@ do git pull echo read -p " to continue: " ans + elif [[ "$key" == br* ]]; then + echo + git checkout "$value" + echo + read -p " to continue: " ans elif [[ "$key" == rr* ]]; then if [[ "$callsign" == XLX* ]] && [ -e $xlxserv ]; then sudo systemctl restart xlxd diff --git a/src/cdcsprotocol.cpp b/src/cdcsprotocol.cpp index f7cca2f..56e2afe 100644 --- a/src/cdcsprotocol.cpp +++ b/src/cdcsprotocol.cpp @@ -36,7 +36,7 @@ bool CDcsProtocol::Init(void) { // base class - if (! Initialize("DCS", DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! CProtocol::Initialize("DCS", DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; // update time diff --git a/src/cdextraprotocol.cpp b/src/cdextraprotocol.cpp index 8b52b11..93e6507 100644 --- a/src/cdextraprotocol.cpp +++ b/src/cdextraprotocol.cpp @@ -35,10 +35,10 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDextraProtocol::Init(void) +bool CDextraProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! Initialize("XRF", DEXTRA_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdextraprotocol.h b/src/cdextraprotocol.h index ab4889f..46e9a45 100644 --- a/src/cdextraprotocol.h +++ b/src/cdextraprotocol.h @@ -59,7 +59,7 @@ class CDextraProtocol : public CProtocol { public: // initialization - bool Init(void); + bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdmrmmdvmprotocol.cpp b/src/cdmrmmdvmprotocol.cpp index 8be9c81..5325745 100644 --- a/src/cdmrmmdvmprotocol.cpp +++ b/src/cdmrmmdvmprotocol.cpp @@ -54,10 +54,10 @@ static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDmrmmdvmProtocol::Init(void) +bool CDmrmmdvmProtocol::Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! Initialize(nullptr, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6)) + if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdmrmmdvmprotocol.h b/src/cdmrmmdvmprotocol.h index 71d31f4..a20bbe0 100644 --- a/src/cdmrmmdvmprotocol.h +++ b/src/cdmrmmdvmprotocol.h @@ -67,7 +67,7 @@ class CDmrmmdvmProtocol : public CProtocol { public: // initialization - bool Init(void); + bool Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdmrplusprotocol.cpp b/src/cdmrplusprotocol.cpp index 5323412..2c3c809 100644 --- a/src/cdmrplusprotocol.cpp +++ b/src/cdmrplusprotocol.cpp @@ -47,10 +47,10 @@ static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDmrplusProtocol::Init() +bool CDmrplusProtocol::Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! Initialize(nullptr, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6)) + if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdmrplusprotocol.h b/src/cdmrplusprotocol.h index 5c02ba0..4823fd2 100644 --- a/src/cdmrplusprotocol.h +++ b/src/cdmrplusprotocol.h @@ -57,7 +57,7 @@ class CDmrplusProtocol : public CProtocol { public: // initialization - bool Init(); + bool Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdplusprotocol.cpp b/src/cdplusprotocol.cpp index a4dfce6..acb72ea 100644 --- a/src/cdplusprotocol.cpp +++ b/src/cdplusprotocol.cpp @@ -34,10 +34,10 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDplusProtocol::Init(void) +bool CDplusProtocol::Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! Initialize("REF", DPLUS_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdplusprotocol.h b/src/cdplusprotocol.h index bdbf45f..38715f2 100644 --- a/src/cdplusprotocol.h +++ b/src/cdplusprotocol.h @@ -52,7 +52,7 @@ class CDplusProtocol : public CProtocol { public: // initialization - bool Init(void); + bool Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cg3protocol.cpp b/src/cg3protocol.cpp index d27abea..bec6c16 100644 --- a/src/cg3protocol.cpp +++ b/src/cg3protocol.cpp @@ -38,7 +38,7 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CG3Protocol::Init(void) +bool CG3Protocol::Initalize(const char */*type*/, const uint16 /*port*/, const bool /*has_ipv4*/, const bool /*has_ipv6*/) { ReadOptions(); diff --git a/src/cg3protocol.h b/src/cg3protocol.h index 1ae056b..2192f08 100644 --- a/src/cg3protocol.h +++ b/src/cg3protocol.h @@ -67,7 +67,7 @@ public: CG3Protocol() : m_GwAddress(0u), m_Modules("*"), m_LastModTime(0) {} // initialization - bool Init(void); + bool Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); // close void Close(void); diff --git a/src/cprotocol.h b/src/cprotocol.h index 92b4165..876d333 100644 --- a/src/cprotocol.h +++ b/src/cprotocol.h @@ -77,7 +77,7 @@ public: virtual ~CProtocol(); // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + virtual bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); virtual void Close(void); // queue diff --git a/src/cprotocols.cpp b/src/cprotocols.cpp index 75fd1b3..9fc9336 100644 --- a/src/cprotocols.cpp +++ b/src/cprotocols.cpp @@ -43,16 +43,7 @@ CProtocols::~CProtocols() { - m_Mutex.lock(); - { - for ( auto it=m_Protocols.begin(); it!=m_Protocols.end(); it++) - { - (*it)->Close(); - delete *it; - } - m_Protocols.clear(); - } - m_Mutex.unlock(); + Close(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -62,88 +53,40 @@ bool CProtocols::Init(void) { m_Mutex.lock(); { - auto dextra = new CDextraProtocol; - if (dextra->Init()) - m_Protocols.push_back(dextra); - else - { - delete dextra; + m_Protocols.emplace_back(std::unique_ptr(new CDextraProtocol)); + if (! m_Protocols.back()->Initialize("XRF", DEXTRA_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; - } - - // create and initialize DPLUS - auto dplus = new CDplusProtocol; - if (dplus->Init()) - m_Protocols.push_back(dplus); - else - { - delete dplus; + m_Protocols.emplace_back(std::unique_ptr(new CDplusProtocol)); + if (! m_Protocols.back()->Initialize("REF", DPLUS_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; - } - // create and initialize DCS - auto dcs = new CDcsProtocol; - if (dcs->Init()) - m_Protocols.push_back(dcs); - else - { - delete dcs; + m_Protocols.emplace_back(std::unique_ptr(new CDcsProtocol)); + if (! m_Protocols.back()->Initialize("DCS", DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; - } #ifndef NO_XLX - // create and initialize XLX - interlink - auto xlx = new CXlxProtocol; - if (xlx->Init()) - m_Protocols.push_back(xlx); - else - { - delete xlx; + m_Protocols.emplace_back(std::unique_ptr(new CDmrmmdvmProtocol)); + if (! m_Protocols.back()->Initialize(nullptr, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6)) return false; - } - // create and initialize DMRPLUS - auto dmrplus = new CDmrplusProtocol; - if (dmrplus->Init()) - m_Protocols.push_back(dmrplus); - else - { - delete dmrplus; + m_Protocols.emplace_back(std::unique_ptr(new CDmrplusProtocol)); + if (! m_Protocols.back()->Initialize(nullptr, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6)) return false; - } - // create and initialize DMRMMDVM - auto dmrmmdvm = new CDmrmmdvmProtocol; - if (dmrmmdvm->Init()) - m_Protocols.push_back(dmrmmdvm); - else - { - delete dmrmmdvm; + m_Protocols.emplace_back(std::unique_ptr(new CYsfProtocol)); + if (! m_Protocols.back()->Initialize("YSF", YSF_PORT, DMR_IPV4, DMR_IPV6)) return false; - } - // create and initialize YSF - auto ysf = new CYsfProtocol; - if (ysf->Init()) - m_Protocols.push_back(ysf); - else - { - delete ysf; + m_Protocols.emplace_back(std::unique_ptr(new CXlxProtocol)); + if (! m_Protocols.back()->Initialize("XLX", XLX_PORT, DMR_IPV4, DMR_IPV6)) return false; - } #endif #ifndef NO_G3 - // create and initialize G3 - auto g3 = new CG3Protocol; - if (g3->Init()) - m_Protocols.push_back(g3); - else - { - delete g3; - return true; - } + m_Protocols.emplace_back(std::unique_ptr(new CG3Protocol)); + if (! m_Protocols.back()->Initialize("XLX", G3_PORT, DMR_IPV4, DMR_IPV6)) + return false; #endif } @@ -156,13 +99,6 @@ bool CProtocols::Init(void) void CProtocols::Close(void) { m_Mutex.lock(); - { - for ( auto it=m_Protocols.begin(); it!=m_Protocols.end(); it++) - { - (*it)->Close(); - delete *it; - } - m_Protocols.clear(); - } + m_Protocols.clear(); m_Mutex.unlock(); } diff --git a/src/cprotocols.h b/src/cprotocols.h index 452efdc..a126f93 100644 --- a/src/cprotocols.h +++ b/src/cprotocols.h @@ -44,15 +44,17 @@ public: // initialization bool Init(void); void Close(void); + void Lock(void) { m_Mutex.lock(); } + void Unlock(void) { m_Mutex.unlock(); } // pass-thru - std::list::iterator begin() { return m_Protocols.begin(); } - std::list::iterator end() { return m_Protocols.end(); } + std::list>::iterator begin() { return m_Protocols.begin(); } + std::list>::iterator end() { return m_Protocols.end(); } protected: // data std::mutex m_Mutex; - std::list m_Protocols; + std::list> m_Protocols; }; diff --git a/src/creflector.cpp b/src/creflector.cpp index acc6863..cf57f1b 100644 --- a/src/creflector.cpp +++ b/src/creflector.cpp @@ -347,6 +347,7 @@ void CReflector::RouterThread(CReflector *This, CPacketStream *streamIn) packet->SetModuleId(uiModuleId); // iterate on all protocols + This->m_Protocols.Lock(); for ( auto it=This->m_Protocols.begin(); it!=This->m_Protocols.end(); it++ ) { // duplicate packet @@ -366,6 +367,7 @@ void CReflector::RouterThread(CReflector *This, CPacketStream *streamIn) queue->push(packetClone); (*it)->ReleaseQueue(); } + This->m_Protocols.Unlock(); // done delete packet; packet = nullptr; diff --git a/src/cxlxprotocol.cpp b/src/cxlxprotocol.cpp index 312dddc..06fd52f 100644 --- a/src/cxlxprotocol.cpp +++ b/src/cxlxprotocol.cpp @@ -35,9 +35,9 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CXlxProtocol::Init(void) +bool CXlxProtocol::Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) { - if (! Initialize("XLX", XLX_PORT, XLX_IPV4, XLX_IPV6)) + if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cxlxprotocol.h b/src/cxlxprotocol.h index 7fe4597..4b55e6e 100644 --- a/src/cxlxprotocol.h +++ b/src/cxlxprotocol.h @@ -41,7 +41,7 @@ class CXlxProtocol : public CDextraProtocol { public: // initialization - bool Init(void); + bool Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cysfprotocol.cpp b/src/cysfprotocol.cpp index acd9fbe..a4770da 100644 --- a/src/cysfprotocol.cpp +++ b/src/cysfprotocol.cpp @@ -45,10 +45,10 @@ CYsfProtocol::CYsfProtocol() //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CYsfProtocol::Init(void) +bool CYsfProtocol::Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! Initialize("YSF", YSF_PORT, YSF_IPV4, YSF_IPV6)) + if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) return false; // init the wiresx cmd handler diff --git a/src/cysfprotocol.h b/src/cysfprotocol.h index b71f306..ca2a4cf 100644 --- a/src/cysfprotocol.h +++ b/src/cysfprotocol.h @@ -74,10 +74,10 @@ public: CYsfProtocol(); // destructor - virtual ~CYsfProtocol() {}; + ~CYsfProtocol() {} // initialization - bool Init(void); + bool Initalize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); void Close(void); // task