fixed bm protocol issue

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

@ -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; }

@ -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

@ -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_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx);
std::shared_ptr<CPeer>peer = 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_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx);
std::shared_ptr<CPeer>peer = 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_ptr<CClient>client = 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_ptr<CPeer>peer = 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_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 )
{
@ -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<CDvHeaderPacket> &Header, c
CCallsign rpt2(Header->GetRpt2Callsign());
// no stream open yet, open a new one
// 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 )
{
// 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
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";

@ -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"

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

@ -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_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx);
std::shared_ptr<CPeer>peer = 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_ptr<CPeer>peer = peers->FindPeer(Ip, EProtocol::xlx);
std::shared_ptr<CPeer>peer = 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_ptr<CClient>client = 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_ptr<CPeer>peer = 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_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 )
{
@ -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<CDvHeaderPacket> &Header,
CCallsign rpt2(Header->GetRpt2Callsign());
// no stream open yet, open a new one
// 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 )
{
// and try to open the stream

Loading…
Cancel
Save

Powered by TurnKey Linux.