fixed bm protocol issue

unstable
Tom Early 4 years ago
parent 4877e24a3a
commit 284595cd74

@ -32,7 +32,7 @@ public:
virtual ~CBmClient() {}; virtual ~CBmClient() {};
// identity // identity
EProtocol GetProtocol(void) const { return EProtocol::xlx; } EProtocol GetProtocol(void) const { return EProtocol::bm; }
EProtoRev GetProtocolRevision(void) const { return EProtoRev::ambe; } EProtoRev GetProtocolRevision(void) const { return EProtoRev::ambe; }
const char *GetProtocolName(void) const { return "XLX"; } const char *GetProtocolName(void) const { return "XLX"; }
bool IsPeer(void) const { return true; } bool IsPeer(void) const { return true; }

@ -40,7 +40,7 @@ public:
bool IsAlive(void) const; bool IsAlive(void) const;
// identity // identity
EProtocol GetProtocol(void) const { return EProtocol::xlx; } EProtocol GetProtocol(void) const { return EProtocol::bm; }
const char *GetProtocolName(void) const { return "XLX"; } const char *GetProtocolName(void) const { return "XLX"; }
// revision helper // revision helper

@ -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; std::cout << "XLX (" << Version.GetMajor() << "." << Version.GetMinor() << "." << Version.GetRevision() << ") connect packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::bm, Modules) )
{ {
// acknowledge the request // acknowledge the request
EncodeConnectAckPacket(&Buffer, Modules); 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; std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::bm, Modules) )
{ {
// already connected ? // already connected ?
CPeers *peers = g_Reflector.GetPeers(); 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 // create the new peer
// this also create one client per module // this also create one client per module
@ -124,7 +124,7 @@ void CBMProtocol::Task(void)
// find peer // find peer
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx); std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::bm);
if ( peer != nullptr ) if ( peer != nullptr )
{ {
// remove it from reflector peer list // remove it from reflector peer list
@ -144,7 +144,7 @@ void CBMProtocol::Task(void)
// find peer // find peer
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx); std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::bm);
if ( peer != nullptr ) if ( peer != nullptr )
{ {
// keep it alive // keep it alive
@ -218,7 +218,7 @@ void CBMProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(EProtocol::xlx, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::bm, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
@ -264,7 +264,7 @@ void CBMProtocol::HandleKeepalives(void)
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::bm, pit)) != nullptr )
{ {
// send keepalive // send keepalive
Send(keepalive, peer->GetIp()); Send(keepalive, peer->GetIp());
@ -306,7 +306,7 @@ void CBMProtocol::HandlePeerLinks(void)
// if not, disconnect // if not, disconnect
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::bm, pit)) != nullptr )
{ {
if ( list->FindListItem(peer->GetCallsign()) == nullptr ) if ( list->FindListItem(peer->GetCallsign()) == nullptr )
{ {
@ -325,7 +325,7 @@ void CBMProtocol::HandlePeerLinks(void)
{ {
if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) ) if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) )
continue; 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 // resolve again peer's IP in case it's a dynamic IP
(*it).ResolveIp(); (*it).ResolveIp();
@ -370,7 +370,7 @@ void CBMProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, c
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// no stream open yet, open a new one // no stream open yet, open a new one
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::xlx, Header->GetRpt2Module()); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::bm, Header->GetRpt2Module());
if ( client ) if ( client )
{ {
// and try to open the stream // and try to open the stream

@ -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 // todo: then apply any protocol specific authorisation for the operation
break; break;
// XLX interlinks // URF and BM interlinks
case EProtocol::bm:
case EProtocol::urf: case EProtocol::urf:
ok &= IsPeerListedOk(callsign, ip, modules); ok &= IsPeerListedOk(callsign, ip, modules);
break; 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 // todo: then apply any protocol specific authorisation for the operation
break; break;
// XLX interlinks // URF interlinks
case EProtocol::urf: case EProtocol::urf:
case EProtocol::bm:
ok = ok && IsPeerListedOk(callsign, ip, module); ok = ok && IsPeerListedOk(callsign, ip, module);
break; break;
@ -284,6 +286,8 @@ const std::string CGateKeeper::ProtocolName(const EProtocol p) const
return "URF"; return "URF";
case EProtocol::ysf: case EProtocol::ysf:
return "YSF"; return "YSF";
case EProtocol::bm:
return "Brandmeister";
#ifndef NO_G3 #ifndef NO_G3
case EProtocol::g3: case EProtocol::g3:
return "Icom G3"; return "Icom G3";

@ -79,7 +79,7 @@
#ifndef NO_G3 #ifndef NO_G3
enum class EProtocol { any, none, dextra, dplus, dcs, xlx, urf, dmrplus, dmrmmdvm, ysf, m17, g3 }; enum class EProtocol { any, none, dextra, dplus, dcs, xlx, urf, dmrplus, dmrmmdvm, ysf, m17, g3 };
#else #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 #endif
// DExtra // DExtra
@ -180,8 +180,7 @@ enum class EProtocol { any, none, dextra, dplus, dcs, xlx, urf, dmrplus, dmrmmdv
#endif #endif
// system paths ------------------------------------------------- // system paths -------------------------------------------------
//#define XML_PATH "/var/log/xlxd.xml" #define XML_PATH "/var/log/xlxd.xml"
#define XML_PATH "./urfd.xml"
#define WHITELIST_PATH "/usr/local/etc/urfd.whitelist" #define WHITELIST_PATH "/usr/local/etc/urfd.whitelist"
#define BLACKLIST_PATH "/usr/local/etc/urfd.blacklist" #define BLACKLIST_PATH "/usr/local/etc/urfd.blacklist"
#define INTERLINKLIST_PATH "/usr/local/etc/urfd.interlink" #define INTERLINKLIST_PATH "/usr/local/etc/urfd.interlink"

@ -63,7 +63,7 @@ bool CProtocols::Init(void)
return false; return false;
m_Protocols.emplace_back(std::unique_ptr<CBMProtocol>(new CBMProtocol)); m_Protocols.emplace_back(std::unique_ptr<CBMProtocol>(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; return false;
m_Protocols.emplace_back(std::unique_ptr<CDmrplusProtocol>(new CDmrplusProtocol)); m_Protocols.emplace_back(std::unique_ptr<CDmrplusProtocol>(new CDmrplusProtocol));

@ -91,7 +91,7 @@ void CURFProtocol::Task(void)
{ {
// already connected ? // already connected ?
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
if ( peers->FindPeer(Callsign, Ip, EProtocol::xlx) == nullptr ) if ( peers->FindPeer(Callsign, Ip, EProtocol::urf) == nullptr )
{ {
// acknowledge the request // acknowledge the request
EncodeConnectAckPacket(&Buffer, Modules); 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; std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl;
// callsign authorized? // callsign authorized?
if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::xlx, Modules) ) if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::urf, Modules) )
{ {
// already connected ? // already connected ?
CPeers *peers = g_Reflector.GetPeers(); 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 // create the new peer
// this also create one client per module // this also create one client per module
@ -141,7 +141,7 @@ void CURFProtocol::Task(void)
// find peer // find peer
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx); std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::urf);
if ( peer != nullptr ) if ( peer != nullptr )
{ {
// remove it from reflector peer list // remove it from reflector peer list
@ -161,7 +161,7 @@ void CURFProtocol::Task(void)
// find peer // find peer
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx); std::shared_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::urf);
if ( peer != nullptr ) if ( peer != nullptr )
{ {
// keep it alive // keep it alive
@ -228,7 +228,7 @@ void CURFProtocol::HandleQueue(void)
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(EProtocol::xlx, it)) != nullptr ) while ( (client = clients->FindNextClient(EProtocol::urf, it)) != nullptr )
{ {
// is this client busy ? // is this client busy ?
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) ) if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
@ -263,7 +263,7 @@ void CURFProtocol::HandleKeepalives(void)
CPeers *peers = g_Reflector.GetPeers(); CPeers *peers = g_Reflector.GetPeers();
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::urf, pit)) != nullptr )
{ {
// send keepalive // send keepalive
Send(keepalive, peer->GetIp()); Send(keepalive, peer->GetIp());
@ -305,7 +305,7 @@ void CURFProtocol::HandlePeerLinks(void)
// if not, disconnect // if not, disconnect
auto pit = peers->begin(); auto pit = peers->begin();
std::shared_ptr<CPeer>peer = nullptr; std::shared_ptr<CPeer>peer = nullptr;
while ( (peer = peers->FindNextPeer(EProtocol::xlx, pit)) != nullptr ) while ( (peer = peers->FindNextPeer(EProtocol::urf, pit)) != nullptr )
{ {
if ( list->FindListItem(peer->GetCallsign()) == nullptr ) if ( list->FindListItem(peer->GetCallsign()) == nullptr )
{ {
@ -324,7 +324,7 @@ void CURFProtocol::HandlePeerLinks(void)
{ {
if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) ) if ( (*it).GetCallsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) )
continue; 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 // resolve again peer's IP in case it's a dynamic IP
(*it).ResolveIp(); (*it).ResolveIp();
@ -369,7 +369,7 @@ void CURFProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
CCallsign rpt2(Header->GetRpt2Callsign()); CCallsign rpt2(Header->GetRpt2Callsign());
// no stream open yet, open a new one // no stream open yet, open a new one
// find this client // find this client
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::xlx, Header->GetRpt2Module()); std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::urf, Header->GetRpt2Module());
if ( client ) if ( client )
{ {
// and try to open the stream // and try to open the stream

Loading…
Cancel
Save

Powered by TurnKey Linux.