From 284595cd7445449b8a189d5e70ccf4fa77c2013c Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 5 Jan 2022 06:47:51 -0700 Subject: [PATCH] fixed bm protocol issue --- reflector/BMClient.h | 2 +- reflector/BMPeer.h | 2 +- reflector/BMProtocol.cpp | 20 ++++++++++---------- reflector/GateKeeper.cpp | 8 ++++++-- reflector/Main.h | 5 ++--- reflector/Protocols.cpp | 2 +- reflector/URFProtocol.cpp | 20 ++++++++++---------- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/reflector/BMClient.h b/reflector/BMClient.h index e25eab6..1708bf6 100644 --- a/reflector/BMClient.h +++ b/reflector/BMClient.h @@ -32,7 +32,7 @@ public: virtual ~CBmClient() {}; // identity - EProtocol GetProtocol(void) const { return EProtocol::xlx; } + EProtocol GetProtocol(void) const { return EProtocol::bm; } EProtoRev GetProtocolRevision(void) const { return EProtoRev::ambe; } const char *GetProtocolName(void) const { return "XLX"; } bool IsPeer(void) const { return true; } diff --git a/reflector/BMPeer.h b/reflector/BMPeer.h index fff2268..03a825f 100644 --- a/reflector/BMPeer.h +++ b/reflector/BMPeer.h @@ -40,7 +40,7 @@ public: bool IsAlive(void) const; // identity - EProtocol GetProtocol(void) const { return EProtocol::xlx; } + EProtocol GetProtocol(void) const { return EProtocol::bm; } const char *GetProtocolName(void) const { return "XLX"; } // revision helper diff --git a/reflector/BMProtocol.cpp b/reflector/BMProtocol.cpp index 6ba0bed..ef954d1 100644 --- a/reflector/BMProtocol.cpp +++ b/reflector/BMProtocol.cpp @@ -83,7 +83,7 @@ void CBMProtocol::Task(void) std::cout << "XLX (" << Version.GetMajor() << "." << Version.GetMinor() << "." << Version.GetRevision() << ") connect packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::bm, Modules) ) { // acknowledge the request EncodeConnectAckPacket(&Buffer, Modules); @@ -101,11 +101,11 @@ void CBMProtocol::Task(void) std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::bm, Modules) ) { // already connected ? CPeers *peers = g_Reflector.GetPeers(); - if ( peers->FindPeer(Callsign, Ip, EProtocol::xlx) == nullptr ) + if ( peers->FindPeer(Callsign, Ip, EProtocol::bm) == nullptr ) { // create the new peer // this also create one client per module @@ -124,7 +124,7 @@ void CBMProtocol::Task(void) // find peer CPeers *peers = g_Reflector.GetPeers(); - std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::xlx); + std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::bm); if ( peer != nullptr ) { // remove it from reflector peer list @@ -144,7 +144,7 @@ void CBMProtocol::Task(void) // find peer CPeers *peers = g_Reflector.GetPeers(); - std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::xlx); + std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::bm); if ( peer != nullptr ) { // keep it alive @@ -218,7 +218,7 @@ void CBMProtocol::HandleQueue(void) CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; - while ( (client = clients->FindNextClient(EProtocol::xlx, it)) != nullptr ) + while ( (client = clients->FindNextClient(EProtocol::bm, it)) != nullptr ) { // is this client busy ? if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) ) @@ -264,7 +264,7 @@ void CBMProtocol::HandleKeepalives(void) CPeers *peers = g_Reflector.GetPeers(); auto pit = peers->begin(); std::shared_ptrpeer = nullptr; - while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) + while ( (peer = peers->FindNextPeer(EProtocol::bm, pit)) != nullptr ) { // send keepalive Send(keepalive, peer->GetIp()); @@ -306,7 +306,7 @@ void CBMProtocol::HandlePeerLinks(void) // if not, disconnect auto pit = peers->begin(); std::shared_ptrpeer = nullptr; - while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) + while ( (peer = peers->FindNextPeer(EProtocol::bm, pit)) != nullptr ) { if ( list->FindListItem(peer->GetCallsign()) == nullptr ) { @@ -325,7 +325,7 @@ void CBMProtocol::HandlePeerLinks(void) { if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) ) continue; - if ( peers->FindPeer((*it).GetCallsign(), EProtocol::xlx) == nullptr ) + if ( peers->FindPeer((*it).GetCallsign(), EProtocol::bm) == nullptr ) { // resolve again peer's IP in case it's a dynamic IP (*it).ResolveIp(); @@ -370,7 +370,7 @@ void CBMProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, c CCallsign rpt2(Header->GetRpt2Callsign()); // no stream open yet, open a new one // find this client - std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::xlx, Header->GetRpt2Module()); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::bm, Header->GetRpt2Module()); if ( client ) { // and try to open the stream diff --git a/reflector/GateKeeper.cpp b/reflector/GateKeeper.cpp index 208839f..69e0efd 100644 --- a/reflector/GateKeeper.cpp +++ b/reflector/GateKeeper.cpp @@ -97,7 +97,8 @@ bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, EProtocol pr // todo: then apply any protocol specific authorisation for the operation break; - // XLX interlinks + // URF and BM interlinks + case EProtocol::bm: case EProtocol::urf: ok &= IsPeerListedOk(callsign, ip, modules); break; @@ -142,8 +143,9 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, const EP // todo: then apply any protocol specific authorisation for the operation break; - // XLX interlinks + // URF interlinks case EProtocol::urf: + case EProtocol::bm: ok = ok && IsPeerListedOk(callsign, ip, module); break; @@ -284,6 +286,8 @@ const std::string CGateKeeper::ProtocolName(const EProtocol p) const return "URF"; case EProtocol::ysf: return "YSF"; + case EProtocol::bm: + return "Brandmeister"; #ifndef NO_G3 case EProtocol::g3: return "Icom G3"; diff --git a/reflector/Main.h b/reflector/Main.h index 7861e25..9888aaa 100644 --- a/reflector/Main.h +++ b/reflector/Main.h @@ -79,7 +79,7 @@ #ifndef NO_G3 enum class EProtocol { any, none, dextra, dplus, dcs, xlx, urf, dmrplus, dmrmmdvm, ysf, m17, g3 }; #else -enum class EProtocol { any, none, dextra, dplus, dcs, xlx, urf, dmrplus, dmrmmdvm, ysf, m17 }; +enum class EProtocol { any, none, dextra, dplus, dcs, bm, urf, dmrplus, dmrmmdvm, ysf, m17 }; #endif // DExtra @@ -180,8 +180,7 @@ enum class EProtocol { any, none, dextra, dplus, dcs, xlx, urf, dmrplus, dmrmmdv #endif // system paths ------------------------------------------------- -//#define XML_PATH "/var/log/xlxd.xml" -#define XML_PATH "./urfd.xml" +#define XML_PATH "/var/log/xlxd.xml" #define WHITELIST_PATH "/usr/local/etc/urfd.whitelist" #define BLACKLIST_PATH "/usr/local/etc/urfd.blacklist" #define INTERLINKLIST_PATH "/usr/local/etc/urfd.interlink" diff --git a/reflector/Protocols.cpp b/reflector/Protocols.cpp index 6fc0352..e6b5e6b 100644 --- a/reflector/Protocols.cpp +++ b/reflector/Protocols.cpp @@ -63,7 +63,7 @@ bool CProtocols::Init(void) return false; m_Protocols.emplace_back(std::unique_ptr(new CBMProtocol)); - if (! m_Protocols.back()->Initialize(nullptr, EProtocol::xlx, XLX_PORT, DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize(nullptr, EProtocol::bm, XLX_PORT, DMR_IPV4, DMR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDmrplusProtocol)); diff --git a/reflector/URFProtocol.cpp b/reflector/URFProtocol.cpp index 7f0fd03..5e9fda5 100644 --- a/reflector/URFProtocol.cpp +++ b/reflector/URFProtocol.cpp @@ -91,7 +91,7 @@ void CURFProtocol::Task(void) { // already connected ? CPeers *peers = g_Reflector.GetPeers(); - if ( peers->FindPeer(Callsign, Ip, EProtocol::xlx) == nullptr ) + if ( peers->FindPeer(Callsign, Ip, EProtocol::urf) == nullptr ) { // acknowledge the request EncodeConnectAckPacket(&Buffer, Modules); @@ -118,11 +118,11 @@ void CURFProtocol::Task(void) std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::urf, Modules) ) { // already connected ? CPeers *peers = g_Reflector.GetPeers(); - if ( peers->FindPeer(Callsign, Ip, EProtocol::xlx) == nullptr ) + if ( peers->FindPeer(Callsign, Ip, EProtocol::urf) == nullptr ) { // create the new peer // this also create one client per module @@ -141,7 +141,7 @@ void CURFProtocol::Task(void) // find peer CPeers *peers = g_Reflector.GetPeers(); - std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::xlx); + std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::urf); if ( peer != nullptr ) { // remove it from reflector peer list @@ -161,7 +161,7 @@ void CURFProtocol::Task(void) // find peer CPeers *peers = g_Reflector.GetPeers(); - std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::xlx); + std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::urf); if ( peer != nullptr ) { // keep it alive @@ -228,7 +228,7 @@ void CURFProtocol::HandleQueue(void) CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; - while ( (client = clients->FindNextClient(EProtocol::xlx, it)) != nullptr ) + while ( (client = clients->FindNextClient(EProtocol::urf, it)) != nullptr ) { // is this client busy ? if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) ) @@ -263,7 +263,7 @@ void CURFProtocol::HandleKeepalives(void) CPeers *peers = g_Reflector.GetPeers(); auto pit = peers->begin(); std::shared_ptrpeer = nullptr; - while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) + while ( (peer = peers->FindNextPeer(EProtocol::urf, pit)) != nullptr ) { // send keepalive Send(keepalive, peer->GetIp()); @@ -305,7 +305,7 @@ void CURFProtocol::HandlePeerLinks(void) // if not, disconnect auto pit = peers->begin(); std::shared_ptrpeer = nullptr; - while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) + while ( (peer = peers->FindNextPeer(EProtocol::urf, pit)) != nullptr ) { if ( list->FindListItem(peer->GetCallsign()) == nullptr ) { @@ -324,7 +324,7 @@ void CURFProtocol::HandlePeerLinks(void) { if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) ) continue; - if ( peers->FindPeer((*it).GetCallsign(), EProtocol::xlx) == nullptr ) + if ( peers->FindPeer((*it).GetCallsign(), EProtocol::urf) == nullptr ) { // resolve again peer's IP in case it's a dynamic IP (*it).ResolveIp(); @@ -369,7 +369,7 @@ void CURFProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // no stream open yet, open a new one // find this client - std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::xlx, Header->GetRpt2Module()); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::urf, Header->GetRpt2Module()); if ( client ) { // and try to open the stream