diff --git a/reflector/BMProtocol.cpp b/reflector/BMProtocol.cpp index 0b6018b..f16752d 100644 --- a/reflector/BMProtocol.cpp +++ b/reflector/BMProtocol.cpp @@ -27,7 +27,7 @@ bool CBMProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) { - m_HasTranscoder = g_Conf.IsString(g_Keys.modules.tcmodules); + m_HasTranscoder = g_Configure.IsString(g_Keys.modules.tcmodules); if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; @@ -71,7 +71,7 @@ void CBMProtocol::Task(void) else if ( IsValidDvHeaderPacket(Buffer, Header) ) { // callsign allowed? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip) ) { OnDvHeaderPacketIn(Header, Ip); } @@ -81,7 +81,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_Gate.MayLink(Callsign, Ip, EProtocol::bm, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::bm, Modules) ) { // acknowledge the request EncodeConnectAckPacket(&Buffer, Modules); @@ -99,10 +99,10 @@ void CBMProtocol::Task(void) std::cout << "XLX ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::bm, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::bm, Modules) ) { // already connected ? - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); if ( peers->FindPeer(Callsign, Ip, EProtocol::bm) == nullptr ) { // create the new peer @@ -113,7 +113,7 @@ void CBMProtocol::Task(void) // this also add all new clients to reflector client list peers->AddPeer(peer); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } } else if ( IsValidDisconnectPacket(Buffer, &Callsign) ) @@ -121,7 +121,7 @@ void CBMProtocol::Task(void) std::cout << "XLX disconnect packet from " << Callsign << " at " << Ip << std::endl; // find peer - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::bm); if ( peer != nullptr ) { @@ -130,7 +130,7 @@ void CBMProtocol::Task(void) // and delete them peers->RemovePeer(peer); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } else if ( IsValidNackPacket(Buffer, &Callsign) ) { @@ -141,14 +141,14 @@ void CBMProtocol::Task(void) //std::cout << "XLX keepalive packet from " << Callsign << " at " << Ip << std::endl; // find peer - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::bm); if ( peer != nullptr ) { // keep it alive peer->Alive(); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } else { @@ -207,7 +207,7 @@ void CBMProtocol::HandleQueue(void) } // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::bm, it)) != nullptr ) @@ -233,7 +233,7 @@ void CBMProtocol::HandleQueue(void) } } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -250,7 +250,7 @@ void CBMProtocol::HandleKeepalives(void) EncodeKeepAlivePacket(&keepalive); // iterate on peers - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); auto pit = peers->begin(); std::shared_ptrpeer = nullptr; while ( (peer = peers->FindNextPeer(EProtocol::bm, pit)) != nullptr ) @@ -277,7 +277,7 @@ void CBMProtocol::HandleKeepalives(void) peers->RemovePeer(peer); } } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -288,8 +288,8 @@ void CBMProtocol::HandlePeerLinks(void) CBuffer buffer; // get the list of peers - CPeerCallsignList *list = g_Gate.GetPeerList(); - CPeers *peers = g_Refl.GetPeers(); + CPeerCallsignList *list = g_GateKeeper.GetPeerList(); + CPeers *peers = g_Reflector.GetPeers(); // check if all our connected peers are still listed by gatekeeper // if not, disconnect @@ -325,8 +325,8 @@ void CBMProtocol::HandlePeerLinks(void) } // done - g_Refl.ReleasePeers(); - g_Gate.ReleasePeerList(); + g_Reflector.ReleasePeers(); + g_GateKeeper.ReleasePeerList(); } @@ -355,11 +355,11 @@ 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_Refl.GetClients()->FindClient(Ip, EProtocol::bm, Header->GetRpt2Module()); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::bm, Header->GetRpt2Module()); if ( client ) { // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; @@ -368,10 +368,10 @@ void CBMProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, c peer = client->GetCallsign(); } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2, peer); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2, peer); + g_Reflector.ReleaseUsers(); } } diff --git a/reflector/CallsignListItem.cpp b/reflector/CallsignListItem.cpp index 27cfba8..40328bf 100644 --- a/reflector/CallsignListItem.cpp +++ b/reflector/CallsignListItem.cpp @@ -33,7 +33,7 @@ CCallsignListItem::CCallsignListItem() CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, const char *modules) { - const std::string mods(g_Conf.GetString(g_Keys.modules.modules)); + const std::string mods(g_Configure.GetString(g_Keys.modules.modules)); m_Callsign = callsign; memset(m_szUrl, 0, sizeof(m_szUrl)); m_Ip = ip; @@ -60,7 +60,7 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, c CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const char *url, const char *modules) { - const std::string mods(g_Conf.GetString(g_Keys.modules.modules)); + const std::string mods(g_Configure.GetString(g_Keys.modules.modules)); m_Callsign = callsign; ::strncpy(m_szUrl, url, URL_MAXLEN); m_Ip = CIp(m_szUrl); diff --git a/reflector/Clients.cpp b/reflector/Clients.cpp index b53455e..fcddd63 100644 --- a/reflector/Clients.cpp +++ b/reflector/Clients.cpp @@ -64,7 +64,7 @@ void CClients::AddClient(std::shared_ptr client) } std::cout << std::endl; // notify - g_Refl.OnClientsChanged(); + g_Reflector.OnClientsChanged(); } void CClients::RemoveClient(std::shared_ptr client) @@ -88,7 +88,7 @@ void CClients::RemoveClient(std::shared_ptr client) std::cout << std::endl; m_Clients.erase(it); // notify - g_Refl.OnClientsChanged(); + g_Reflector.OnClientsChanged(); break; } } diff --git a/reflector/DCSProtocol.cpp b/reflector/DCSProtocol.cpp index 0efecfe..29dc576 100644 --- a/reflector/DCSProtocol.cpp +++ b/reflector/DCSProtocol.cpp @@ -67,7 +67,7 @@ void CDcsProtocol::Task(void) if ( IsValidDvPacket(Buffer, Header, Frame) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dcs, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dcs, Header->GetRpt2Module()) ) { OnDvHeaderPacketIn(Header, Ip); @@ -79,18 +79,18 @@ void CDcsProtocol::Task(void) std::cout << "DCS connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::dcs) && g_Refl.IsValidModule(ToLinkModule) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dcs) && g_Reflector.IsValidModule(ToLinkModule) ) { // valid module ? - if ( g_Refl.IsValidModule(ToLinkModule) ) + if ( g_Reflector.IsValidModule(ToLinkModule) ) { // acknowledge the request EncodeConnectAckPacket(Callsign, ToLinkModule, &Buffer); Send(Buffer, Ip); // create the client and append - g_Refl.GetClients()->AddClient(std::make_shared(Callsign, Ip, ToLinkModule)); - g_Refl.ReleaseClients(); + g_Reflector.GetClients()->AddClient(std::make_shared(Callsign, Ip, ToLinkModule)); + g_Reflector.ReleaseClients(); } else { @@ -114,7 +114,7 @@ void CDcsProtocol::Task(void) std::cout << "DCS disconnect packet from " << Callsign << " at " << Ip << std::endl; // find client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::dcs); if ( client != nullptr ) { @@ -124,21 +124,21 @@ void CDcsProtocol::Task(void) EncodeConnectNackPacket(Callsign, ' ', &Buffer); Send(Buffer, Ip); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidKeepAlivePacket(Buffer, &Callsign) ) { //std::cout << "DCS keepalive packet from " << Callsign << " at " << Ip << std::endl; // find all clients with that callsign & ip and keep them alive - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::dcs, it)) != nullptr ) { client->Alive(); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsIgnorePacket(Buffer) ) { @@ -192,24 +192,24 @@ void CDcsProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::dcs); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dcs); if ( client ) { // get client callsign rpt1 = client->GetCallsign(); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } @@ -251,7 +251,7 @@ void CDcsProtocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dcs, it)) != nullptr ) @@ -264,7 +264,7 @@ void CDcsProtocol::HandleQueue(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -282,7 +282,7 @@ void CDcsProtocol::HandleKeepalives(void) EncodeKeepAlivePacket(&keepalive1); // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dcs, it)) != nullptr ) @@ -315,7 +315,7 @@ void CDcsProtocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// diff --git a/reflector/DExtraProtocol.cpp b/reflector/DExtraProtocol.cpp index 9e4c64b..88ed7ef 100644 --- a/reflector/DExtraProtocol.cpp +++ b/reflector/DExtraProtocol.cpp @@ -72,7 +72,7 @@ void CDextraProtocol::Task(void) else if ( IsValidDvHeaderPacket(Buffer, Header) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dextra, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dextra, Header->GetRpt2Module()) ) { OnDvHeaderPacketIn(Header, Ip); } @@ -96,18 +96,18 @@ void CDextraProtocol::Task(void) } // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::dextra) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dextra) ) { // valid module ? - if ( g_Refl.IsValidModule(ToLinkModule) ) + if ( g_Reflector.IsValidModule(ToLinkModule) ) { // acknowledge the request EncodeConnectAckPacket(&Buffer, ProtRev); Send(Buffer, Ip); // create the client and append - g_Refl.GetClients()->AddClient(std::make_shared(Callsign, Ip, ToLinkModule, ProtRev)); - g_Refl.ReleaseClients(); + g_Reflector.GetClients()->AddClient(std::make_shared(Callsign, Ip, ToLinkModule, ProtRev)); + g_Reflector.ReleaseClients(); } else { @@ -130,7 +130,7 @@ void CDextraProtocol::Task(void) std::cout << "DExtra disconnect packet from " << Callsign << " at " << Ip << std::endl; // find client & remove it - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::dextra); if ( client != nullptr ) { @@ -147,21 +147,21 @@ void CDextraProtocol::Task(void) // and remove it clients->RemoveClient(client); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidKeepAlivePacket(Buffer, &Callsign) ) { //std::cout << "DExtra keepalive packet from " << Callsign << " at " << Ip << std::endl; // find all clients with that callsign & ip and keep them alive - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::dextra, it)) != nullptr ) { client->Alive(); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -203,7 +203,7 @@ void CDextraProtocol::HandleQueue(void) if ( EncodeDvPacket(*packet, buffer) ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dextra, it)) != nullptr ) @@ -219,7 +219,7 @@ void CDextraProtocol::HandleQueue(void) } } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -236,7 +236,7 @@ void CDextraProtocol::HandleKeepalives(void) EncodeKeepAlivePacket(&keepalive); // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dextra, it)) != nullptr ) @@ -253,7 +253,7 @@ void CDextraProtocol::HandleKeepalives(void) // otherwise check if still with us else if ( !client->IsAlive() ) { - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); std::shared_ptrpeer = peers->FindPeer(client->GetCallsign(), client->GetIp(), EProtocol::dextra); if ( peer != nullptr && peer->GetReflectorModules()[0] == client->GetReflectorModule() ) { @@ -270,14 +270,14 @@ void CDextraProtocol::HandleKeepalives(void) std::cout << "DExtra client " << client->GetCallsign() << " keepalive timeout" << std::endl; clients->RemoveClient(client); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // iterate on peers - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); auto pit = peers->begin(); std::shared_ptrpeer = nullptr; while ( (peer = peers->FindNextPeer(EProtocol::dextra, pit)) != nullptr ) @@ -290,19 +290,19 @@ void CDextraProtocol::HandleKeepalives(void) // no, disconnect all clients CBuffer disconnect; EncodeDisconnectPacket(&disconnect, peer->GetReflectorModules()[0]); - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); for ( auto cit=peer->cbegin(); cit!=peer->cend(); cit++ ) { Send(disconnect, (*cit)->GetIp()); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // remove it std::cout << "DExtra peer " << peer->GetCallsign() << " keepalive timeout" << std::endl; peers->RemovePeer(peer); } } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -326,7 +326,7 @@ void CDextraProtocol::OnDvHeaderPacketIn(std::unique_ptr &Heade CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::dextra); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dextra); if ( client ) { // get client callsign @@ -341,18 +341,18 @@ void CDextraProtocol::OnDvHeaderPacketIn(std::unique_ptr &Heade rpt2.SetCSModule(m); } // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } diff --git a/reflector/DMRMMDVMProtocol.cpp b/reflector/DMRMMDVMProtocol.cpp index e50a943..12bbe38 100644 --- a/reflector/DMRMMDVMProtocol.cpp +++ b/reflector/DMRMMDVMProtocol.cpp @@ -48,7 +48,7 @@ static uint8_t g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; bool CDmrmmdvmProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) { - m_DefaultId = g_Conf.GetUnsigned(g_Keys.mmdvm.defaultid); + m_DefaultId = g_Configure.GetUnsigned(g_Keys.mmdvm.defaultid); // base class if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; @@ -93,7 +93,7 @@ void CDmrmmdvmProtocol::Task(void) if ( Receive4(Buffer, Ip, 20) ) #endif { - //Buffer.DebugDump(g_Refl.m_DebugFile); + //Buffer.DebugDump(g_Reflector.m_DebugFile); // crack the packet if ( IsValidDvFramePacket(Buffer, Frames) ) { @@ -105,7 +105,7 @@ void CDmrmmdvmProtocol::Task(void) else if ( IsValidDvHeaderPacket(Buffer, Header, &Cmd, &CallType) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dmrmmdvm) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dmrmmdvm) ) { // handle it OnDvHeaderPacketIn(Header, Ip, Cmd, CallType); @@ -120,7 +120,7 @@ void CDmrmmdvmProtocol::Task(void) std::cout << "DMRmmdvm connect packet from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::dmrmmdvm) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dmrmmdvm) ) { // acknowledge the request EncodeConnectAckPacket(&Buffer, Callsign, m_uiAuthSeed); @@ -139,14 +139,14 @@ void CDmrmmdvmProtocol::Task(void) std::cout << "DMRmmdvm authentication packet from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::dmrmmdvm) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dmrmmdvm) ) { // acknowledge the request EncodeAckPacket(&Buffer, Callsign); Send(Buffer, Ip); // add client if needed - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Callsign, Ip, EProtocol::dmrmmdvm); // client already connected ? if ( client == nullptr ) @@ -161,7 +161,7 @@ void CDmrmmdvmProtocol::Task(void) client->Alive(); } // and done - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -176,13 +176,13 @@ void CDmrmmdvmProtocol::Task(void) std::cout << "DMRmmdvm disconnect packet from " << Callsign << " at " << Ip << std::endl; // find client & remove it - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::dmrmmdvm); if ( client != nullptr ) { clients->RemoveClient(client); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidConfigPacket(Buffer, &Callsign, Ip) ) { @@ -197,7 +197,7 @@ void CDmrmmdvmProtocol::Task(void) //std::cout << "DMRmmdvm keepalive packet from " << Callsign << " at " << Ip << std::endl; // find all clients with that callsign & ip and keep them alive - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::dmrmmdvm, it)) != nullptr ) @@ -209,7 +209,7 @@ void CDmrmmdvmProtocol::Task(void) // and mark as alive client->Alive(); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidRssiPacket(Buffer, &Callsign, &iRssi) ) { @@ -273,7 +273,7 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr &Hea CCallsign rpt2(Header->GetRpt2Callsign()); // no stream open yet, open a new one // firstfind this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::dmrmmdvm); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dmrmmdvm); if ( client ) { // process cmd if any @@ -282,7 +282,7 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr &Hea // not linked yet if ( cmd == CMD_LINK ) { - if ( g_Refl.IsValidModule(rpt2.GetCSModule()) ) + if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) ) { std::cout << "DMRmmdvm client " << client->GetCallsign() << " linking on module " << rpt2.GetCSModule() << std::endl; // link @@ -313,10 +313,10 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr &Hea } // and now, re-check module is valid && that it's not a private call - if ( g_Refl.IsValidModule(rpt2.GetCSModule()) && (CallType == DMR_GROUP_CALL) ) + if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) && (CallType == DMR_GROUP_CALL) ) { // yes, try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; @@ -330,13 +330,13 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr &Hea } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard if ( lastheard ) { - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } } @@ -401,7 +401,7 @@ void CDmrmmdvmProtocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dmrmmdvm, it)) != nullptr ) @@ -414,7 +414,7 @@ void CDmrmmdvmProtocol::HandleQueue(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -429,7 +429,7 @@ void CDmrmmdvmProtocol::HandleKeepalives(void) // and disconnect them if not // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dmrmmdvm, it)) != nullptr ) @@ -453,7 +453,7 @@ void CDmrmmdvmProtocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -693,7 +693,7 @@ bool CDmrmmdvmProtocol::IsValidDvFramePacket(const CBuffer &Buffer, std::arraydata()[33]), 7); - //dump.DebugDump(g_Refl.m_DebugFile); + //dump.DebugDump(g_Reflector.m_DebugFile); // BER Buffer->Append((uint8_t)0); @@ -979,7 +979,7 @@ char CDmrmmdvmProtocol::DmrDstIdToModule(uint32_t tg) const if (tg > 4000 && tg < 4027) { const char mod = 'A' + (tg - 4001U); - if (g_Refl.IsValidModule(mod)) + if (g_Reflector.IsValidModule(mod)) { return mod; } diff --git a/reflector/DMRPlusProtocol.cpp b/reflector/DMRPlusProtocol.cpp index a625a74..4de295f 100644 --- a/reflector/DMRPlusProtocol.cpp +++ b/reflector/DMRPlusProtocol.cpp @@ -92,7 +92,7 @@ void CDmrplusProtocol::Task(void) else if ( IsValidDvHeaderPacket(Ip, Buffer, Header) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dmrplus) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dmrplus) ) { // handle it OnDvHeaderPacketIn(Header, Ip); @@ -103,14 +103,14 @@ void CDmrplusProtocol::Task(void) //std::cout << "DMRplus keepalive/connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::dmrplus) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dmrplus) ) { // acknowledge the request EncodeConnectAckPacket(&Buffer); Send(Buffer, Ip); // add client if needed - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Callsign, Ip, EProtocol::dmrplus); // client already connected ? if ( client == nullptr ) @@ -125,7 +125,7 @@ void CDmrplusProtocol::Task(void) client->Alive(); } // and done - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -140,13 +140,13 @@ void CDmrplusProtocol::Task(void) std::cout << "DMRplus disconnect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; // find client & remove it - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::dmrplus); if ( client != nullptr ) { clients->RemoveClient(client); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -195,21 +195,21 @@ void CDmrplusProtocol::OnDvHeaderPacketIn(std::unique_ptr &Head // no stream open yet, open a new one // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::dmrplus); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dmrplus); if ( client ) { // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } @@ -265,7 +265,7 @@ void CDmrplusProtocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr ) @@ -277,10 +277,10 @@ void CDmrplusProtocol::HandleQueue(void) Send(buffer, client->GetIp()); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // debug - //buffer.DebugDump(g_Refl.m_DebugFile); + //buffer.DebugDump(g_Reflector.m_DebugFile); } } } @@ -290,7 +290,7 @@ void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8_t module if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr ) @@ -302,10 +302,10 @@ void CDmrplusProtocol::SendBufferToClients(const CBuffer &buffer, uint8_t module Send(buffer, client->GetIp()); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // debug - //buffer.DebugDump(g_Refl.m_DebugFile); + //buffer.DebugDump(g_Reflector.m_DebugFile); } } @@ -320,7 +320,7 @@ void CDmrplusProtocol::HandleKeepalives(void) // and disconnect them if not // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr ) @@ -345,7 +345,7 @@ void CDmrplusProtocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -638,7 +638,7 @@ char CDmrplusProtocol::DmrDstIdToModule(uint32_t tg) const // is it a 4xxx ? if (tg > 4000 && tg < 4027) { char mod = 'A' + (tg - 4001U); - if (g_Refl.IsValidModule(mod)) + if (g_Reflector.IsValidModule(mod)) { return mod; } diff --git a/reflector/DPlusProtocol.cpp b/reflector/DPlusProtocol.cpp index cd7ac07..14682fe 100644 --- a/reflector/DPlusProtocol.cpp +++ b/reflector/DPlusProtocol.cpp @@ -71,7 +71,7 @@ void CDplusProtocol::Task(void) else if ( IsValidDvHeaderPacket(Buffer, Header) ) { // is muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dplus, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::dplus, Header->GetRpt2Module()) ) { // handle it OnDvHeaderPacketIn(Header, Ip); @@ -89,15 +89,15 @@ void CDplusProtocol::Task(void) std::cout << "DPlus login packet from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::dplus) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::dplus) ) { // acknowledge the request EncodeLoginAckPacket(&Buffer); Send(Buffer, Ip); // create the client and append - g_Refl.GetClients()->AddClient(std::make_shared(Callsign, Ip)); - g_Refl.ReleaseClients(); + g_Reflector.GetClients()->AddClient(std::make_shared(Callsign, Ip)); + g_Reflector.ReleaseClients(); } else { @@ -112,7 +112,7 @@ void CDplusProtocol::Task(void) std::cout << "DPlus disconnect packet from " << Ip << std::endl; // find client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::dplus); if ( client != nullptr ) { @@ -122,21 +122,21 @@ void CDplusProtocol::Task(void) EncodeDisconnectPacket(&Buffer); Send(Buffer, Ip); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidKeepAlivePacket(Buffer) ) { //std::cout << "DPlus keepalive packet from " << Ip << std::endl; // find all clients with that callsign & ip and keep them alive - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(Ip, EProtocol::dplus, it)) != nullptr ) { client->Alive(); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -184,10 +184,10 @@ void CDplusProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header CCallsign rpt2(Header->GetRpt2Callsign()); // first, check module is valid - if ( g_Refl.IsValidModule(rpt2.GetCSModule()) ) + if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) ) { // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::dplus); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dplus); if ( client ) { // now we know if it's a dextra dongle or a genuine dplus node @@ -203,18 +203,18 @@ void CDplusProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header // get client callsign rpt1 = client->GetCallsign(); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } else { @@ -251,7 +251,7 @@ void CDplusProtocol::HandleQueue(void) // and push it to all our clients who are not streaming in // note that for dplus protocol, all stream of all modules are push to all clients // it's client who decide which stream he's interrrested in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dplus, it)) != nullptr ) @@ -288,7 +288,7 @@ void CDplusProtocol::HandleQueue(void) } } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -340,7 +340,7 @@ void CDplusProtocol::HandleKeepalives(void) EncodeKeepAlivePacket(&keepalive); // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::dplus, it)) != nullptr ) @@ -368,7 +368,7 @@ void CDplusProtocol::HandleKeepalives(void) clients->RemoveClient(client); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// diff --git a/reflector/G3Protocol.cpp b/reflector/G3Protocol.cpp index c075c14..7c15ca8 100644 --- a/reflector/G3Protocol.cpp +++ b/reflector/G3Protocol.cpp @@ -33,13 +33,13 @@ bool CG3Protocol::Initialize(const char */*type*/, const EProtocol /*type*/, con // everything is hard coded until ICOM gets their act together and start supporting IPv6 { //config data - m_TerminalPath.assign(g_Conf.GetString(g_Keys.files.terminal)); - const std::string ipv4address(g_Conf.GetString(g_Keys.ip.ipv4bind)); + m_TerminalPath.assign(g_Configure.GetString(g_Keys.files.terminal)); + const std::string ipv4address(g_Configure.GetString(g_Keys.ip.ipv4bind)); ReadOptions(); // init reflector apparent callsign - m_ReflectorCallsign = g_Refl.GetCallsign(); + m_ReflectorCallsign = g_Reflector.GetCallsign(); // reset stop flag keep_running = true; @@ -179,7 +179,7 @@ void CG3Protocol::PresenceTask(void) Buffer.Append(m_GwAddress); } - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrextant = nullptr; while ( (extant = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -221,7 +221,7 @@ void CG3Protocol::PresenceTask(void) clients->AddClient(std::make_shared(Terminal, Ip)); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); m_PresenceSocket.Send(Buffer, ReqIp); } @@ -262,7 +262,7 @@ void CG3Protocol::ConfigTask(void) if (isRepeaterCall) { - if ((Call.HasSameCallsign(GetReflectorCallsign())) && (g_Refl.IsValidModule(Call.GetCSModule()))) + if ((Call.HasSameCallsign(GetReflectorCallsign())) && (g_Reflector.IsValidModule(Call.GetCSModule()))) { Buffer.data()[3] = 0x00; // ok } @@ -345,7 +345,7 @@ void CG3Protocol::IcmpTask(void) { if (iIcmpType == ICMP_DEST_UNREACH) { - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -356,7 +356,7 @@ void CG3Protocol::IcmpTask(void) clients->RemoveClient(client); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -380,7 +380,7 @@ void CG3Protocol::Task(void) { CIp ClIp; CIp *BaseIp = nullptr; - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -396,7 +396,7 @@ void CG3Protocol::Task(void) break; } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); if (BaseIp != nullptr) { @@ -408,7 +408,7 @@ void CG3Protocol::Task(void) else if ( IsValidDvHeaderPacket(Buffer, Header) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::g3, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::g3, Header->GetRpt2Module()) ) { // handle it OnDvHeaderPacketIn(Header, *BaseIp); @@ -455,7 +455,7 @@ void CG3Protocol::HandleQueue(void) if ( EncodeDvPacket(*packet, buffer) ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -471,7 +471,7 @@ void CG3Protocol::HandleQueue(void) } } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -487,7 +487,7 @@ void CG3Protocol::HandleKeepalives(void) CBuffer keepalive((uint8_t *)"PING", 4); // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -502,7 +502,7 @@ void CG3Protocol::HandleKeepalives(void) Send(keepalive, client->GetIp()); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -527,7 +527,7 @@ void CG3Protocol::OnDvHeaderPacketIn(std::unique_ptr &Header, c CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -554,7 +554,7 @@ void CG3Protocol::OnDvHeaderPacketIn(std::unique_ptr &Header, c } else { - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); return; } } @@ -563,19 +563,19 @@ void CG3Protocol::OnDvHeaderPacketIn(std::unique_ptr &Header, c rpt1 = client->GetCallsign(); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } @@ -679,7 +679,7 @@ void CG3Protocol::NeedReload(void) ReadOptions(); // we have new options - iterate on clients for potential removal - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr ) @@ -690,7 +690,7 @@ void CG3Protocol::NeedReload(void) clients->RemoveClient(client); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } diff --git a/reflector/GateKeeper.cpp b/reflector/GateKeeper.cpp index f91db6e..8afb9f3 100644 --- a/reflector/GateKeeper.cpp +++ b/reflector/GateKeeper.cpp @@ -44,9 +44,9 @@ bool CGateKeeper::Init(void) { // load lists from files - m_NodeWhiteList.LoadFromFile(g_Conf.GetString(g_Keys.files.white)); - m_NodeBlackList.LoadFromFile(g_Conf.GetString(g_Keys.files.black)); - m_PeerList.LoadFromFile(g_Conf.GetString(g_Keys.files.interlink)); + m_NodeWhiteList.LoadFromFile(g_Configure.GetString(g_Keys.files.white)); + m_NodeBlackList.LoadFromFile(g_Configure.GetString(g_Keys.files.black)); + m_PeerList.LoadFromFile(g_Configure.GetString(g_Keys.files.interlink)); // reset run flag keep_running = true; diff --git a/reflector/Global.h b/reflector/Global.h index 611f347..0a3c43c 100644 --- a/reflector/Global.h +++ b/reflector/Global.h @@ -23,10 +23,10 @@ #include "LookupYsf.h" #include "JsonKeys.h" -extern CReflector g_Refl; -extern CGateKeeper g_Gate; -extern CConfigure g_Conf; -extern CVersion g_Vers; +extern CReflector g_Reflector; +extern CGateKeeper g_GateKeeper; +extern CConfigure g_Configure; +extern CVersion g_Version; extern CLookupDmr g_LDid; extern CLookupNxdn g_LNid; extern CLookupYsf g_LYtr; diff --git a/reflector/Lookup.cpp b/reflector/Lookup.cpp index 27bc6af..9d1fbc6 100644 --- a/reflector/Lookup.cpp +++ b/reflector/Lookup.cpp @@ -69,8 +69,7 @@ void CLookup::Thread() // load the file if http was loaded or if we haven't loaded since the last mod time if (ERefreshType::http != m_Type) { - GetLastModTime(); - if (http_loaded || m_LastLoadTime < m_LastModTime) + if (http_loaded || m_LastLoadTime < GetLastModTime()) { file_loaded = LoadContentFile(ss); time(&m_LastLoadTime); diff --git a/reflector/Lookup.h b/reflector/Lookup.h index d4638d0..e7edd78 100644 --- a/reflector/Lookup.h +++ b/reflector/Lookup.h @@ -53,7 +53,7 @@ class CLookup { public: // constructor - CLookup() : keep_running(true), m_LastModTime(0), m_LastLoadTime(0) {} + CLookup() : keep_running(true), m_LastLoadTime(0) {} void LookupInit(); void LookupClose(); @@ -78,7 +78,7 @@ protected: ERefreshType m_Type; unsigned m_Refresh; std::string m_Path, m_Url; - std::time_t m_LastModTime, m_LastLoadTime; + std::time_t m_LastLoadTime; std::atomic keep_running; std::future m_Future; diff --git a/reflector/LookupDmr.cpp b/reflector/LookupDmr.cpp index a3c202c..04ab0e1 100644 --- a/reflector/LookupDmr.cpp +++ b/reflector/LookupDmr.cpp @@ -31,10 +31,10 @@ void CLookupDmr::ClearContents() void CLookupDmr::LoadParameters() { - m_Type = g_Conf.GetRefreshType(g_Keys.dmriddb.mode); - m_Refresh = g_Conf.GetUnsigned(g_Keys.dmriddb.refreshmin); - m_Path.assign(g_Conf.GetString(g_Keys.dmriddb.filepath)); - m_Url.assign(g_Conf.GetString(g_Keys.dmriddb.url)); + m_Type = g_Configure.GetRefreshType(g_Keys.dmriddb.mode); + m_Refresh = g_Configure.GetUnsigned(g_Keys.dmriddb.refreshmin); + m_Path.assign(g_Configure.GetString(g_Keys.dmriddb.filepath)); + m_Url.assign(g_Configure.GetString(g_Keys.dmriddb.url)); } uint32_t CLookupDmr::FindDmrid(const UCallsign &ucs) const diff --git a/reflector/LookupNxdn.cpp b/reflector/LookupNxdn.cpp index 95b4f00..7189b8f 100644 --- a/reflector/LookupNxdn.cpp +++ b/reflector/LookupNxdn.cpp @@ -31,10 +31,10 @@ void CLookupNxdn::ClearContents() void CLookupNxdn::LoadParameters() { - m_Type = g_Conf.GetRefreshType(g_Keys.nxdniddb.mode); - m_Refresh = g_Conf.GetUnsigned(g_Keys.nxdniddb.refreshmin); - m_Path.assign(g_Conf.GetString(g_Keys.nxdniddb.filepath)); - m_Url.assign(g_Conf.GetString(g_Keys.nxdniddb.url)); + m_Type = g_Configure.GetRefreshType(g_Keys.nxdniddb.mode); + m_Refresh = g_Configure.GetUnsigned(g_Keys.nxdniddb.refreshmin); + m_Path.assign(g_Configure.GetString(g_Keys.nxdniddb.filepath)); + m_Url.assign(g_Configure.GetString(g_Keys.nxdniddb.url)); } const UCallsign *CLookupNxdn::FindCallsign(uint16_t nxdnid) const diff --git a/reflector/LookupYsf.cpp b/reflector/LookupYsf.cpp index e2fc5a3..b30f6b6 100644 --- a/reflector/LookupYsf.cpp +++ b/reflector/LookupYsf.cpp @@ -31,12 +31,12 @@ void CLookupYsf::ClearContents() void CLookupYsf::LoadParameters() { - m_Type = g_Conf.GetRefreshType(g_Keys.ysftxrxdb.mode); - m_Refresh = g_Conf.GetUnsigned(g_Keys.ysftxrxdb.refreshmin); - m_Path.assign(g_Conf.GetString(g_Keys.ysftxrxdb.filepath)); - m_Url.assign(g_Conf.GetString(g_Keys.ysftxrxdb.url)); - m_DefaultTx = g_Conf.GetUnsigned(g_Keys.ysf.defaulttxfreq); - m_DefaultRx = g_Conf.GetUnsigned(g_Keys.ysf.defaultrxfreq); + m_Type = g_Configure.GetRefreshType(g_Keys.ysftxrxdb.mode); + m_Refresh = g_Configure.GetUnsigned(g_Keys.ysftxrxdb.refreshmin); + m_Path.assign(g_Configure.GetString(g_Keys.ysftxrxdb.filepath)); + m_Url.assign(g_Configure.GetString(g_Keys.ysftxrxdb.url)); + m_DefaultTx = g_Configure.GetUnsigned(g_Keys.ysf.defaulttxfreq); + m_DefaultRx = g_Configure.GetUnsigned(g_Keys.ysf.defaultrxfreq); } void CLookupYsf::UpdateContent(std::stringstream &ss, Eaction action) diff --git a/reflector/M17Protocol.cpp b/reflector/M17Protocol.cpp index cbbfe74..2516389 100644 --- a/reflector/M17Protocol.cpp +++ b/reflector/M17Protocol.cpp @@ -68,7 +68,7 @@ void CM17Protocol::Task(void) if ( IsValidDvPacket(Buffer, Header, Frame) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::m17, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::m17, Header->GetRpt2Module()) ) { OnDvHeaderPacketIn(Header, Ip); @@ -92,17 +92,17 @@ void CM17Protocol::Task(void) std::cout << "M17 connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::m17) && g_Refl.IsValidModule(ToLinkModule) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::m17) && g_Reflector.IsValidModule(ToLinkModule) ) { // valid module ? - if ( g_Refl.IsValidModule(ToLinkModule) ) + if ( g_Reflector.IsValidModule(ToLinkModule) ) { // acknowledge the request Send("ACKN", Ip); // create the client and append - g_Refl.GetClients()->AddClient(std::make_shared(Callsign, Ip, ToLinkModule)); - g_Refl.ReleaseClients(); + g_Reflector.GetClients()->AddClient(std::make_shared(Callsign, Ip, ToLinkModule)); + g_Reflector.ReleaseClients(); } else { @@ -124,7 +124,7 @@ void CM17Protocol::Task(void) std::cout << "M17 disconnect packet from " << Callsign << " at " << Ip << std::endl; // find client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::m17); if ( client != nullptr ) { @@ -133,19 +133,19 @@ void CM17Protocol::Task(void) // and acknowledge the disconnect Send("DISC", Ip); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidKeepAlivePacket(Buffer, Callsign) ) { // find all clients with that callsign & ip and keep them alive - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::m17, it)) != nullptr ) { client->Alive(); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -195,24 +195,24 @@ void CM17Protocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::m17); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::m17); if ( client ) { // get client callsign rpt1 = client->GetCallsign(); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } @@ -247,7 +247,7 @@ void CM17Protocol::HandleQueue(void) EncodeM17Packet(frame, m_StreamsCache[module].m_dvHeader, (CDvFramePacket *)packet.get(), m_StreamsCache[module].m_iSeqCounter); // push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::m17, it)) != nullptr ) @@ -264,7 +264,7 @@ void CM17Protocol::HandleQueue(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } m_StreamsCache[module].m_iSeqCounter++; } @@ -283,7 +283,7 @@ void CM17Protocol::HandleKeepalives(void) EncodeKeepAlivePacket(keepalive); // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::m17, it)) != nullptr ) @@ -309,7 +309,7 @@ void CM17Protocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -386,7 +386,7 @@ void CM17Protocol::EncodeKeepAlivePacket(CBuffer &Buffer) { Buffer.resize(10); memcpy(Buffer.data(), "PING", 4); - g_Refl.GetCallsign().CodeOut(Buffer.data() + 4); + g_Reflector.GetCallsign().CodeOut(Buffer.data() + 4); } void CM17Protocol::EncodeM17Packet(SM17Frame &frame, const CDvHeaderPacket &Header, const CDvFramePacket *DvFrame, uint32_t iSeq) const diff --git a/reflector/Main.cpp b/reflector/Main.cpp index a2fe4d4..afa2209 100644 --- a/reflector/Main.cpp +++ b/reflector/Main.cpp @@ -25,10 +25,10 @@ // global objects SJsonKeys g_Keys; -CReflector g_Refl; -CGateKeeper g_Gate; -CConfigure g_Conf; -CVersion g_Vers(3,0,0); // The major byte should only change if the interlink packet changes! +CReflector g_Reflector; +CGateKeeper g_GateKeeper; +CConfigure g_Configure; +CVersion g_Version(3,0,0); // The major byte should only change if the interlink packet changes! CLookupDmr g_LDid; CLookupNxdn g_LNid; CLookupYsf g_LYtr; @@ -43,20 +43,20 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - if (g_Conf.ReadData(argv[1])) + if (g_Configure.ReadData(argv[1])) return EXIT_FAILURE; - std::cout << "IPv4 binding address is '" << g_Conf.GetString(g_Keys.ip.ipv4bind) << "'" << std::endl; + std::cout << "IPv4 binding address is '" << g_Configure.GetString(g_Keys.ip.ipv4bind) << "'" << std::endl; // remove pidfile - const std::string pidpath(g_Conf.GetString(g_Keys.files.pid)); - const std::string callsign(g_Conf.GetString(g_Keys.names.callsign)); + const std::string pidpath(g_Configure.GetString(g_Keys.files.pid)); + const std::string callsign(g_Configure.GetString(g_Keys.names.callsign)); remove(pidpath.c_str()); // splash - std::cout << "Starting " << callsign << " " << g_Vers << std::endl; + std::cout << "Starting " << callsign << " " << g_Version << std::endl; // and let it run - if (g_Refl.Start()) + if (g_Reflector.Start()) { std::cout << "Error starting reflector" << std::endl; return EXIT_FAILURE; @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) pause(); // wait for any signal - g_Refl.Stop(); + g_Reflector.Stop(); std::cout << "Reflector stopped" << std::endl; // done @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) // global objects SJsonKeys g_Keys; -CConfigure g_Conf; +CConfigure g_Configure; CLookupDmr g_LDid; CLookupNxdn g_LNid; CLookupYsf g_LYtr; @@ -185,7 +185,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - if (g_Conf.ReadData(argv[4])) + if (g_Configure.ReadData(argv[4])) return EXIT_FAILURE; switch (db) diff --git a/reflector/NXDNProtocol.cpp b/reflector/NXDNProtocol.cpp index 9bb4434..fb2381d 100644 --- a/reflector/NXDNProtocol.cpp +++ b/reflector/NXDNProtocol.cpp @@ -53,8 +53,8 @@ CNXDNProtocol::CNXDNProtocol() bool CNXDNProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) { // config value - m_ReflectorId = g_Conf.GetUnsigned(g_Keys.nxdn.reflectorid); - m_AutolinkModule = g_Conf.GetAutolinkModule(g_Keys.nxdn.autolinkmod); + m_ReflectorId = g_Configure.GetUnsigned(g_Keys.nxdn.reflectorid); + m_AutolinkModule = g_Configure.GetAutolinkModule(g_Keys.nxdn.autolinkmod); // base class if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) @@ -106,7 +106,7 @@ void CNXDNProtocol::Task(void) else if ( IsValidDvHeaderPacket(Ip, Buffer, Header) ) { // node linked and callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::nxdn, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::nxdn, Header->GetRpt2Module()) ) { // handle it OnDvHeaderPacketIn(Header, Ip); @@ -119,10 +119,10 @@ void CNXDNProtocol::Task(void) else if ( IsValidConnectPacket(Buffer, &Callsign) ) { // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::nxdn) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::nxdn) ) { // add client if needed - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Callsign, Ip, EProtocol::nxdn); // client already connected ? if ( client == nullptr ) @@ -147,7 +147,7 @@ void CNXDNProtocol::Task(void) // acknowledge the request -- NXDNReflector simply echoes the packet Send(Buffer, Ip); // and done - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } else if ( IsValidDisconnectPacket(Buffer) ) @@ -155,14 +155,14 @@ void CNXDNProtocol::Task(void) std::cout << "NXDN disconnect packet from " << Ip << std::endl; // find client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::nxdn); if ( client != nullptr ) { // remove it clients->RemoveClient(client); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -212,7 +212,7 @@ void CNXDNProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::nxdn); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::nxdn); if ( client ) { // get client callsign @@ -223,20 +223,20 @@ void CNXDNProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, rpt2.SetCSModule(m); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - if ( g_Refl.IsValidModule(rpt2.GetCSModule()) ) + if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) ) { - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } } @@ -293,7 +293,7 @@ void CNXDNProtocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::nxdn, it)) != nullptr ) @@ -306,7 +306,7 @@ void CNXDNProtocol::HandleQueue(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -321,7 +321,7 @@ void CNXDNProtocol::HandleKeepalives(void) // and disconnect them if not // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::nxdn, it)) != nullptr ) @@ -341,7 +341,7 @@ void CNXDNProtocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -409,7 +409,7 @@ bool CNXDNProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffer, s rpt2.SetCSModule(' '); header = std::unique_ptr(new CDvHeaderPacket(csMY, CCallsign("CQCQCQ"), rpt1, rpt2, m_uiStreamId, false)); - if ( g_Gate.MayTransmit(header->GetMyCallsign(), Ip, EProtocol::nxdn, header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(header->GetMyCallsign(), Ip, EProtocol::nxdn, header->GetRpt2Module()) ) { OnDvHeaderPacketIn(header, Ip); } diff --git a/reflector/P25Protocol.cpp b/reflector/P25Protocol.cpp index 449e2e3..c83e33c 100644 --- a/reflector/P25Protocol.cpp +++ b/reflector/P25Protocol.cpp @@ -50,9 +50,9 @@ const uint8_t REC80[] = {0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, bool CP25Protocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) { // config data - m_ReflectorId = g_Conf.GetUnsigned(g_Keys.p25.reflectorid); - m_DefaultId = g_Conf.GetUnsigned(g_Keys.mmdvm.defaultid); - m_AutolinkModule = g_Conf.GetAutolinkModule(g_Keys.p25.autolinkmod); + m_ReflectorId = g_Configure.GetUnsigned(g_Keys.p25.reflectorid); + m_DefaultId = g_Configure.GetUnsigned(g_Keys.mmdvm.defaultid); + m_AutolinkModule = g_Configure.GetAutolinkModule(g_Keys.p25.autolinkmod); m_uiStreamId = 0; // base class @@ -97,7 +97,7 @@ void CP25Protocol::Task(void) if( !m_uiStreamId && IsValidDvHeaderPacket(Ip, Buffer, Header) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::p25) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::p25) ) { OnDvHeaderPacketIn(Header, Ip); } @@ -108,10 +108,10 @@ void CP25Protocol::Task(void) else if ( IsValidConnectPacket(Buffer, &Callsign) ) { // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::p25) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::p25) ) { // add client if needed - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Callsign, Ip, EProtocol::p25); // client already connected ? if ( client == nullptr ) @@ -136,7 +136,7 @@ void CP25Protocol::Task(void) // acknowledge the request -- P25Reflector simply echoes the packet Send(Buffer, Ip); // and done - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } else if ( IsValidDisconnectPacket(Buffer, &Callsign) ) @@ -144,14 +144,14 @@ void CP25Protocol::Task(void) std::cout << "P25 disconnect packet from " << Callsign << " at " << Ip << std::endl; // find client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::p25); if ( client != nullptr ) { // remove it clients->RemoveClient(client); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -200,7 +200,7 @@ void CP25Protocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::p25); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::p25); if ( client ) { // get client callsign @@ -209,18 +209,18 @@ void CP25Protocol::OnDvHeaderPacketIn(std::unique_ptr &Header, Header->SetRpt2Module(m); rpt2.SetCSModule(m); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } @@ -258,7 +258,7 @@ void CP25Protocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::p25, it)) != nullptr ) @@ -271,7 +271,7 @@ void CP25Protocol::HandleQueue(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -506,7 +506,7 @@ void CP25Protocol::EncodeP25Packet(const CDvHeaderPacket &Header, const CDvFrame void CP25Protocol::HandleKeepalives(void) { // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::p25, it)) != nullptr ) @@ -526,5 +526,5 @@ void CP25Protocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } diff --git a/reflector/Peers.cpp b/reflector/Peers.cpp index df3497b..9be9c04 100644 --- a/reflector/Peers.cpp +++ b/reflector/Peers.cpp @@ -58,15 +58,15 @@ void CPeers::AddPeer(std::shared_ptr peer) std::cout << "New peer " << peer->GetCallsign() << " at " << peer->GetIp() << " added with protocol " << peer->GetProtocolName() << std::endl; // and append all peer's client to reflector client list // it is double lock safe to lock Clients list after Peers list - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); for ( auto cit=peer->cbegin(); cit!=peer->cend(); cit++ ) { clients->AddClient(*cit); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // notify - g_Refl.OnPeersChanged(); + g_Reflector.OnPeersChanged(); } void CPeers::RemovePeer(std::shared_ptr peer) @@ -79,7 +79,7 @@ void CPeers::RemovePeer(std::shared_ptr peer) { // remove all clients from reflector client list // it is double lock safe to lock Clients list after Peers list - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); for ( auto cit=peer->begin(); cit!=peer->end(); cit++ ) { // this also delete the client object @@ -87,13 +87,13 @@ void CPeers::RemovePeer(std::shared_ptr peer) } // so clear it then (*pit)->ClearClients(); - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // remove it std::cout << "Peer " << (*pit)->GetCallsign() << " at " << (*pit)->GetIp() << " removed" << std::endl; pit = m_Peers.erase(pit); // notify - g_Refl.OnPeersChanged(); + g_Reflector.OnPeersChanged(); } else { diff --git a/reflector/Protocol.cpp b/reflector/Protocol.cpp index 5998127..47b948b 100644 --- a/reflector/Protocol.cpp +++ b/reflector/Protocol.cpp @@ -50,7 +50,7 @@ bool CProtocol::Initialize(const char *type, const EProtocol ptype, const uint16 { m_Port = port; // init reflector apparent callsign - m_ReflectorCallsign = g_Refl.GetCallsign(); + m_ReflectorCallsign = g_Reflector.GetCallsign(); // reset stop flag keep_running = true; @@ -62,7 +62,7 @@ bool CProtocol::Initialize(const char *type, const EProtocol ptype, const uint16 // create our sockets if (has_ipv4) { - const std::string ipv4binding(g_Conf.GetString(g_Keys.ip.ipv4bind)); + const std::string ipv4binding(g_Configure.GetString(g_Keys.ip.ipv4bind)); CIp ip4(AF_INET, port, ipv4binding.c_str()); if ( ip4.IsSet() ) { @@ -72,7 +72,7 @@ bool CProtocol::Initialize(const char *type, const EProtocol ptype, const uint16 std::cout << "Listening on " << ip4 << std::endl; } - if (g_Conf.IsString(g_Keys.ip.ipv6bind)) + if (g_Configure.IsString(g_Keys.ip.ipv6bind)) { if (has_ipv6) { @@ -175,7 +175,7 @@ void CProtocol::CheckStreamsTimeout(void) if ( it->second->IsExpired() ) { // yes, close it - g_Refl.CloseStream(it->second); + g_Reflector.CloseStream(it->second); // and remove it from the m_Streams map it = m_Streams.erase(it); } diff --git a/reflector/Protocols.cpp b/reflector/Protocols.cpp index 6781573..5109b93 100644 --- a/reflector/Protocols.cpp +++ b/reflector/Protocols.cpp @@ -49,60 +49,60 @@ bool CProtocols::Init(void) m_Mutex.lock(); { m_Protocols.emplace_back(std::unique_ptr(new CDextraProtocol)); - if (! m_Protocols.back()->Initialize("XRF", EProtocol::dextra, uint16_t(g_Conf.GetUnsigned(g_Keys.dextra.port)), DSTAR_IPV4, DSTAR_IPV6)) + if (! m_Protocols.back()->Initialize("XRF", EProtocol::dextra, uint16_t(g_Configure.GetUnsigned(g_Keys.dextra.port)), DSTAR_IPV4, DSTAR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDplusProtocol)); - if (! m_Protocols.back()->Initialize("REF", EProtocol::dplus, uint16_t(g_Conf.GetUnsigned(g_Keys.dplus.port)), DSTAR_IPV4, DSTAR_IPV6)) + if (! m_Protocols.back()->Initialize("REF", EProtocol::dplus, uint16_t(g_Configure.GetUnsigned(g_Keys.dplus.port)), DSTAR_IPV4, DSTAR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDcsProtocol)); - if (! m_Protocols.back()->Initialize("DCS", EProtocol::dcs, uint16_t(g_Conf.GetUnsigned(g_Keys.dcs.port)), DSTAR_IPV4, DSTAR_IPV6)) + if (! m_Protocols.back()->Initialize("DCS", EProtocol::dcs, uint16_t(g_Configure.GetUnsigned(g_Keys.dcs.port)), DSTAR_IPV4, DSTAR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDmrmmdvmProtocol)); - if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrmmdvm, uint16_t(g_Conf.GetUnsigned(g_Keys.mmdvm.port)), DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrmmdvm, uint16_t(g_Configure.GetUnsigned(g_Keys.mmdvm.port)), DMR_IPV4, DMR_IPV6)) return false; - if (g_Conf.GetBoolean(g_Keys.bm.enable)) + if (g_Configure.GetBoolean(g_Keys.bm.enable)) { m_Protocols.emplace_back(std::unique_ptr(new CBMProtocol)); - if (! m_Protocols.back()->Initialize("XLX", EProtocol::bm, uint16_t(g_Conf.GetUnsigned(g_Keys.bm.port)), DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize("XLX", EProtocol::bm, uint16_t(g_Configure.GetUnsigned(g_Keys.bm.port)), DMR_IPV4, DMR_IPV6)) return false; } m_Protocols.emplace_back(std::unique_ptr(new CDmrplusProtocol)); - if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrplus, uint16_t(g_Conf.GetUnsigned(g_Keys.dmrplus.port)), DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize(nullptr, EProtocol::dmrplus, uint16_t(g_Configure.GetUnsigned(g_Keys.dmrplus.port)), DMR_IPV4, DMR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CYsfProtocol)); - if (! m_Protocols.back()->Initialize("YSF", EProtocol::ysf, uint16_t(g_Conf.GetUnsigned(g_Keys.ysf.port)), YSF_IPV4, YSF_IPV6)) + if (! m_Protocols.back()->Initialize("YSF", EProtocol::ysf, uint16_t(g_Configure.GetUnsigned(g_Keys.ysf.port)), YSF_IPV4, YSF_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CM17Protocol)); - if (! m_Protocols.back()->Initialize("URF", EProtocol::m17, uint16_t(g_Conf.GetUnsigned(g_Keys.m17.port)), M17_IPV4, M17_IPV6)) + if (! m_Protocols.back()->Initialize("URF", EProtocol::m17, uint16_t(g_Configure.GetUnsigned(g_Keys.m17.port)), M17_IPV4, M17_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CP25Protocol)); - if (! m_Protocols.back()->Initialize("P25", EProtocol::p25, uint16_t(g_Conf.GetUnsigned(g_Keys.p25.port)), P25_IPV4, P25_IPV6)) + if (! m_Protocols.back()->Initialize("P25", EProtocol::p25, uint16_t(g_Configure.GetUnsigned(g_Keys.p25.port)), P25_IPV4, P25_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CNXDNProtocol)); - if (! m_Protocols.back()->Initialize("NXDN", EProtocol::nxdn, uint16_t(g_Conf.GetUnsigned(g_Keys.nxdn.port)), NXDN_IPV4, NXDN_IPV6)) + if (! m_Protocols.back()->Initialize("NXDN", EProtocol::nxdn, uint16_t(g_Configure.GetUnsigned(g_Keys.nxdn.port)), NXDN_IPV4, NXDN_IPV6)) return false; - if (g_Conf.GetBoolean(g_Keys.usrp.enable)) + if (g_Configure.GetBoolean(g_Keys.usrp.enable)) { m_Protocols.emplace_back(std::unique_ptr(new CUSRPProtocol)); - if (! m_Protocols.back()->Initialize("USRP", EProtocol::usrp, uint16_t(g_Conf.GetUnsigned(g_Keys.usrp.rxport)), USRP_IPV4, USRP_IPV6)) + if (! m_Protocols.back()->Initialize("USRP", EProtocol::usrp, uint16_t(g_Configure.GetUnsigned(g_Keys.usrp.rxport)), USRP_IPV4, USRP_IPV6)) return false; } m_Protocols.emplace_back(std::unique_ptr(new CURFProtocol)); - if (! m_Protocols.back()->Initialize("URF", EProtocol::urf, uint16_t(g_Conf.GetUnsigned(g_Keys.urf.port)), URF_IPV4, URF_IPV6)) + if (! m_Protocols.back()->Initialize("URF", EProtocol::urf, uint16_t(g_Configure.GetUnsigned(g_Keys.urf.port)), URF_IPV4, URF_IPV6)) return false; - if (g_Conf.GetBoolean(g_Keys.g3.enable)) + if (g_Configure.GetBoolean(g_Keys.g3.enable)) { m_Protocols.emplace_back(std::unique_ptr(new CG3Protocol)); if (! m_Protocols.back()->Initialize("XLX", EProtocol::g3, G3_DV_PORT, DMR_IPV4, DMR_IPV6)) diff --git a/reflector/Reflector.cpp b/reflector/Reflector.cpp index 11dc4dc..956758c 100644 --- a/reflector/Reflector.cpp +++ b/reflector/Reflector.cpp @@ -47,15 +47,15 @@ CReflector::~CReflector() bool CReflector::Start(void) { // get config stuff - m_Callsign = CCallsign(g_Conf.GetString(g_Keys.names.callsign).c_str(), false); - m_Modules.assign(g_Conf.GetString(g_Keys.modules.modules)); - std::string tcmods(g_Conf.GetString(g_Keys.modules.tcmodules)); + m_Callsign = CCallsign(g_Configure.GetString(g_Keys.names.callsign).c_str(), false); + m_Modules.assign(g_Configure.GetString(g_Keys.modules.modules)); + std::string tcmods(g_Configure.GetString(g_Keys.modules.tcmodules)); // let's go! keep_running = true; // init gate keeper. It can only return true! - g_Gate.Init(); + g_GateKeeper.Init(); // init dmrid directory. No need to check the return value. g_LDid.LookupInit(); @@ -139,7 +139,7 @@ void CReflector::Stop(void) m_Protocols.Close(); // close gatekeeper - g_Gate.Close(); + g_GateKeeper.Close(); // close databases g_LDid.LookupClose(); @@ -298,7 +298,7 @@ void CReflector::RouterThread(const char ThisModule) void CReflector::XmlReportThread() { - const std::string path(g_Conf.GetString(g_Keys.files.xml)); + const std::string path(g_Configure.GetString(g_Keys.files.xml)); while (keep_running) { // report to xml file @@ -412,7 +412,7 @@ void CReflector::WriteXmlFile(std::ofstream &xmlFile) xmlFile << "" << std::endl; // software version - xmlFile << "" << g_Vers << "" << std::endl; + xmlFile << "" << g_Version << "" << std::endl; CCallsign cs = m_Callsign; cs.PatchCallsign(0, "XLX", 3); diff --git a/reflector/URFProtocol.cpp b/reflector/URFProtocol.cpp index c9d4f12..673f21d 100644 --- a/reflector/URFProtocol.cpp +++ b/reflector/URFProtocol.cpp @@ -73,19 +73,19 @@ void CURFProtocol::Task(void) else if ( IsValidKeepAlivePacket(Buffer, &Callsign) ) { // find peer - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::urf); if ( peer != nullptr ) { // keep it alive peer->Alive(); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } else if ( IsValidDvHeaderPacket(Buffer, Header) ) { // callsign allowed? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip) ) { OnDvHeaderPacketIn(Header, Ip); } @@ -95,7 +95,7 @@ void CURFProtocol::Task(void) std::cout << "URF (" << Version.GetMajor() << "." << Version.GetMinor() << "." << Version.GetRevision() << ") connect packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::urf, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::urf, Modules) ) { // acknowledge connecting request // following is version dependent @@ -123,10 +123,10 @@ void CURFProtocol::Task(void) std::cout << "URF ack packet for modules " << Modules << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::urf, Modules) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::urf, Modules) ) { // already connected ? - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); if ( peers->FindPeer(Callsign, Ip, EProtocol::urf) == nullptr ) { // create the new peer @@ -137,7 +137,7 @@ void CURFProtocol::Task(void) // this also add all new clients to reflector client list peers->AddPeer(peer); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } } else if ( IsValidDisconnectPacket(Buffer, &Callsign) ) @@ -145,7 +145,7 @@ void CURFProtocol::Task(void) std::cout << "URF disconnect packet from " << Callsign << " at " << Ip << std::endl; // find peer - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); std::shared_ptrpeer = peers->FindPeer(Ip, EProtocol::urf); if ( peer != nullptr ) { @@ -154,7 +154,7 @@ void CURFProtocol::Task(void) // and delete them peers->RemovePeer(peer); } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } else if ( IsValidNackPacket(Buffer, &Callsign) ) { @@ -215,7 +215,7 @@ void CURFProtocol::HandleQueue(void) if ( EncodeDvPacket(*packet, buffer) ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::urf, it)) != nullptr ) @@ -231,7 +231,7 @@ void CURFProtocol::HandleQueue(void) } } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -249,7 +249,7 @@ void CURFProtocol::HandleKeepalives(void) EncodeKeepAlivePacket(&keepalive); // iterate on peers - CPeers *peers = g_Refl.GetPeers(); + CPeers *peers = g_Reflector.GetPeers(); auto pit = peers->begin(); std::shared_ptrpeer = nullptr; while ( (peer = peers->FindNextPeer(EProtocol::urf, pit)) != nullptr ) @@ -276,7 +276,7 @@ void CURFProtocol::HandleKeepalives(void) peers->RemovePeer(peer); } } - g_Refl.ReleasePeers(); + g_Reflector.ReleasePeers(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -287,8 +287,8 @@ void CURFProtocol::HandlePeerLinks(void) CBuffer buffer; // get the list of peers - CPeerCallsignList *list = g_Gate.GetPeerList(); - CPeers *peers = g_Refl.GetPeers(); + CPeerCallsignList *list = g_GateKeeper.GetPeerList(); + CPeers *peers = g_Reflector.GetPeers(); // check if all our connected peers are still listed by gatekeeper // if not, disconnect @@ -328,8 +328,8 @@ void CURFProtocol::HandlePeerLinks(void) } // done - g_Refl.ReleasePeers(); - g_Gate.ReleasePeerList(); + g_Reflector.ReleasePeers(); + g_GateKeeper.ReleasePeerList(); } @@ -361,11 +361,11 @@ 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_Refl.GetClients()->FindClient(Ip, EProtocol::urf, Header->GetRpt2Module()); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::urf, Header->GetRpt2Module()); if ( client ) { // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; @@ -374,10 +374,10 @@ void CURFProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, peer = client->GetCallsign(); } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2, peer); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2, peer); + g_Reflector.ReleaseUsers(); } } @@ -418,7 +418,7 @@ bool CURFProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsi memcpy(modules, Buffer.data()+10, 27); for ( unsigned i = 0; i < strlen(modules); i++ ) { - valid = valid && (g_Refl.IsValidModule (modules[i])); + valid = valid && (g_Reflector.IsValidModule (modules[i])); } } return valid; @@ -448,7 +448,7 @@ bool CURFProtocol::IsValidAckPacket(const CBuffer &Buffer, CCallsign *callsign, memcpy(modules, Buffer.data()+10, 27); for ( unsigned i = 0; i < strlen(modules); i++ ) { - valid = valid && (g_Refl.IsValidModule(modules[i])); + valid = valid && (g_Reflector.IsValidModule(modules[i])); } } return valid; @@ -519,7 +519,7 @@ void CURFProtocol::EncodeKeepAlivePacket(CBuffer *Buffer) { Buffer->Set("PING"); Buffer->resize(10); - g_Refl.GetCallsign().CodeOut(Buffer->data()+4); + g_Reflector.GetCallsign().CodeOut(Buffer->data()+4); } void CURFProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules) @@ -528,12 +528,12 @@ void CURFProtocol::EncodeConnectPacket(CBuffer *Buffer, const char *Modules) Buffer->Set("CONN"); // our callsign Buffer->resize(37); - g_Refl.GetCallsign().CodeOut(Buffer->data()+4); + g_Reflector.GetCallsign().CodeOut(Buffer->data()+4); // our version Buffer->ReplaceAt(10, (uint8_t *)Modules, strlen(Modules)); - Buffer->Append((uint8_t)g_Vers.GetMajor()); - Buffer->Append((uint8_t)g_Vers.GetMinor()); - Buffer->Append((uint8_t)g_Vers.GetRevision()); + Buffer->Append((uint8_t)g_Version.GetMajor()); + Buffer->Append((uint8_t)g_Version.GetMinor()); + Buffer->Append((uint8_t)g_Version.GetRevision()); } void CURFProtocol::EncodeDisconnectPacket(CBuffer *Buffer) @@ -541,7 +541,7 @@ void CURFProtocol::EncodeDisconnectPacket(CBuffer *Buffer) Buffer->Set("DISC"); // our callsign Buffer->resize(10); - g_Refl.GetCallsign().CodeOut(Buffer->data()+4); + g_Reflector.GetCallsign().CodeOut(Buffer->data()+4); } void CURFProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const char *Modules) @@ -549,18 +549,18 @@ void CURFProtocol::EncodeConnectAckPacket(CBuffer *Buffer, const char *Modules) Buffer->Set("ACKN"); // our callsign Buffer->resize(37); - g_Refl.GetCallsign().CodeOut(Buffer->data()+4); + g_Reflector.GetCallsign().CodeOut(Buffer->data()+4); // the shared modules Buffer->ReplaceAt(10, (uint8_t *)Modules, strlen(Modules)); // our version - Buffer->Append((uint8_t)g_Vers.GetMajor()); - Buffer->Append((uint8_t)g_Vers.GetMinor()); - Buffer->Append((uint8_t)g_Vers.GetRevision()); + Buffer->Append((uint8_t)g_Version.GetMajor()); + Buffer->Append((uint8_t)g_Version.GetMinor()); + Buffer->Append((uint8_t)g_Version.GetRevision()); } void CURFProtocol::EncodeConnectNackPacket(CBuffer *Buffer) { Buffer->Set("NACK"); Buffer->resize(10); - g_Refl.GetCallsign().CodeOut(Buffer->data()+4); + g_Reflector.GetCallsign().CodeOut(Buffer->data()+4); } diff --git a/reflector/USRPProtocol.cpp b/reflector/USRPProtocol.cpp index 7738680..a5beab8 100644 --- a/reflector/USRPProtocol.cpp +++ b/reflector/USRPProtocol.cpp @@ -46,18 +46,18 @@ bool CUSRPProtocol::Initialize(const char *type, const EProtocol ptype, const ui if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; - m_Module = g_Conf.GetAutolinkModule(g_Keys.usrp.module); + m_Module = g_Configure.GetAutolinkModule(g_Keys.usrp.module); // create the one special USRP Tx/Rx client - m_Callsign.SetCallsign(g_Conf.GetString(g_Keys.usrp.callsign), false); - CIp ip(AF_INET, uint16_t(g_Conf.GetUnsigned(g_Keys.usrp.txport)), g_Conf.GetString(g_Keys.ip.ipv4bind).c_str()); + m_Callsign.SetCallsign(g_Configure.GetString(g_Keys.usrp.callsign), false); + CIp ip(AF_INET, uint16_t(g_Configure.GetUnsigned(g_Keys.usrp.txport)), g_Configure.GetString(g_Keys.ip.ipv4bind).c_str()); auto newclient = std::make_shared(m_Callsign, ip); newclient->SetReflectorModule(m_Module); - g_Refl.GetClients()->AddClient(newclient); - g_Refl.ReleaseClients(); + g_Reflector.GetClients()->AddClient(newclient); + g_Reflector.ReleaseClients(); // now create "listen-only" clients, as many as specified - file.open(g_Conf.GetString(g_Keys.usrp.filepath), std::ios::in | std::ios::binary | std::ios::ate); + file.open(g_Configure.GetString(g_Keys.usrp.filepath), std::ios::in | std::ios::binary | std::ios::ate); if ( file.is_open() ) { // read file @@ -96,8 +96,8 @@ bool CUSRPProtocol::Initialize(const char *type, const EProtocol ptype, const ui cs.SetCallsign(clientcs, false); auto newclient = std::make_shared(cs, Ip); newclient->SetReflectorModule(m_Module); - g_Refl.GetClients()->AddClient(newclient); - g_Refl.ReleaseClients(); + g_Reflector.GetClients()->AddClient(newclient); + g_Reflector.ReleaseClients(); } ptr1 = ptr2+1; } @@ -144,7 +144,7 @@ void CUSRPProtocol::Task(void) else if( IsValidDvHeaderPacket(Ip, Buffer, Header) ) { // callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::usrp) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::usrp) ) { OnDvHeaderPacketIn(Header, Ip); } @@ -201,7 +201,7 @@ void CUSRPProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::usrp); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::usrp); if ( client ) { // get client callsign @@ -210,18 +210,18 @@ void CUSRPProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, Header->SetRpt2Module(m); rpt2.SetCSModule(m); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } @@ -257,7 +257,7 @@ void CUSRPProtocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::usrp, it)) != nullptr ) @@ -269,7 +269,7 @@ void CUSRPProtocol::HandleQueue(void) Send(buffer, client->GetIp()); } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -382,7 +382,7 @@ void CUSRPProtocol::EncodeUSRPPacket(const CDvHeaderPacket &Header, const CDvFra void CUSRPProtocol::HandleKeepalives(void) { // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::usrp, it)) != nullptr ) @@ -402,5 +402,5 @@ void CUSRPProtocol::HandleKeepalives(void) //} } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } diff --git a/reflector/Users.cpp b/reflector/Users.cpp index 8027503..ac7d774 100644 --- a/reflector/Users.cpp +++ b/reflector/Users.cpp @@ -41,7 +41,7 @@ void CUsers::AddUser(const CUser &user) } // notify - g_Refl.OnUsersChanged(); + g_Reflector.OnUsersChanged(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ void CUsers::AddUser(const CUser &user) void CUsers::Hearing(const CCallsign &my, const CCallsign &rpt1, const CCallsign &rpt2) { - Hearing(my, rpt1, rpt2, g_Refl.GetCallsign()); + Hearing(my, rpt1, rpt2, g_Reflector.GetCallsign()); } void CUsers::Hearing(const CCallsign &my, const CCallsign &rpt1, const CCallsign &rpt2, const CCallsign &xlx) diff --git a/reflector/WiresXCmdHandler.cpp b/reflector/WiresXCmdHandler.cpp index d02bdc5..195eca2 100644 --- a/reflector/WiresXCmdHandler.cpp +++ b/reflector/WiresXCmdHandler.cpp @@ -59,8 +59,8 @@ CWiresxCmdHandler::~CWiresxCmdHandler() bool CWiresxCmdHandler::Init(void) { // fill our wiresx info - m_ReflectorWiresxInfo.SetCallsign(g_Refl.GetCallsign()); - m_ReflectorWiresxInfo.SetNode(g_Refl.GetCallsign()); + m_ReflectorWiresxInfo.SetCallsign(g_Reflector.GetCallsign()); + m_ReflectorWiresxInfo.SetNode(g_Reflector.GetCallsign()); m_ReflectorWiresxInfo.SetName("Reflector"); // reset stop flag @@ -146,13 +146,13 @@ void CWiresxCmdHandler::Task(void) // find our client and the module it's currentlink linked to cModule = ' '; - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), EProtocol::ysf); if ( client ) { cModule = client->GetReflectorModule(); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // and crack the cmd switch ( Cmd.GetCmd() ) @@ -170,19 +170,19 @@ void CWiresxCmdHandler::Task(void) break; case WIRESX_CMD_CONN_REQ: cModule = 'A' + (char)(Cmd.GetArg() - 1); - if (g_Refl.IsValidModule(cModule)) + if (g_Reflector.IsValidModule(cModule)) { std::cout << "Wires-X CONN_REQ command to link on module " << cModule << " from " << Cmd.GetCallsign() << " at " << Cmd.GetIp() << std::endl; // acknowledge ReplyToWiresxConnReqPacket(Cmd.GetIp(), Info, cModule); // change client's module - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), EProtocol::ysf); if ( client ) { client->SetReflectorModule(cModule); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else { @@ -195,13 +195,13 @@ void CWiresxCmdHandler::Task(void) ReplyToWiresxDiscReqPacket(Cmd.GetIp(), Info); // change client's module { - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Cmd.GetCallsign(), Cmd.GetIp(), EProtocol::ysf); if ( client != nullptr ) { client->SetReflectorModule(' '); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } break; case WIRESX_CMD_UNKNOWN: @@ -334,7 +334,7 @@ bool CWiresxCmdHandler::ReplyToWiresxAllReqPacket(const CIp &Ip, const CWiresxIn memcpy(data + 12U, WiresxInfo.GetNode(), 10U); // number of entries - const std::string modules(g_Conf.GetString(g_Keys.modules.modules)); + const std::string modules(g_Configure.GetString(g_Keys.modules.modules)); uint NB_OF_MODULES = modules.size(); uint total = NB_OF_MODULES; uint n = NB_OF_MODULES - Start; @@ -738,8 +738,8 @@ bool CWiresxCmdHandler::DebugTestDecodePacket(const CBuffer &Buffer) std::cout << "Trailer" << std::endl; std::cout << "length of payload : " << len << std::endl; dump.Set(command, len); - dump.DebugDump(g_Refl.m_DebugFile); - dump.DebugDumpAscii(g_Refl.m_DebugFile); + dump.DebugDump(g_Reflector.m_DebugFile); + dump.DebugDumpAscii(g_Reflector.m_DebugFile); break; case YSF_FI_COMMUNICATIONS: if ( Fich.getDT() == YSF_DT_DATA_FR_MODE ) diff --git a/reflector/YSFProtocol.cpp b/reflector/YSFProtocol.cpp index 20190e0..1a40ba4 100644 --- a/reflector/YSFProtocol.cpp +++ b/reflector/YSFProtocol.cpp @@ -41,10 +41,10 @@ CYsfProtocol::CYsfProtocol() bool CYsfProtocol::Initialize(const char *type, const EProtocol ptype, const uint16_t port, const bool has_ipv4, const bool has_ipv6) { // config data - m_AutolinkModule = g_Conf.GetAutolinkModule(g_Keys.ysf.autolinkmod); - m_RegistrationId = g_Conf.GetUnsigned(g_Keys.ysf.ysfreflectordb.id); - m_RegistrationName.assign(g_Conf.GetString(g_Keys.ysf.ysfreflectordb.name)); - m_RegistrationDesc.assign(g_Conf.GetString(g_Keys.ysf.ysfreflectordb.description)); + m_AutolinkModule = g_Configure.GetAutolinkModule(g_Keys.ysf.autolinkmod); + m_RegistrationId = g_Configure.GetUnsigned(g_Keys.ysf.ysfreflectordb.id); + m_RegistrationName.assign(g_Configure.GetString(g_Keys.ysf.ysfreflectordb.name)); + m_RegistrationDesc.assign(g_Configure.GetString(g_Keys.ysf.ysfreflectordb.description)); m_RegistrationName.resize(REG_NAME_SIZE, ' '); m_RegistrationDesc.resize(REG_DESC_SIZE, ' '); @@ -127,7 +127,7 @@ void CYsfProtocol::Task(void) else if ( IsValidDvHeaderPacket(Ip, Fich, Buffer, Header, Frames) ) { // node linked and callsign muted? - if ( g_Gate.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::ysf, Header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::ysf, Header->GetRpt2Module()) ) { // handle it OnDvHeaderPacketIn(Header, Ip); @@ -146,14 +146,14 @@ void CYsfProtocol::Task(void) //std::cout << "YSF keepalive/connect packet from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_Gate.MayLink(Callsign, Ip, EProtocol::ysf) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, EProtocol::ysf) ) { // acknowledge the request EncodeConnectAckPacket(&Buffer); Send(Buffer, Ip); // add client if needed - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Callsign, Ip, EProtocol::ysf); // client already connected ? if ( client == nullptr ) @@ -175,7 +175,7 @@ void CYsfProtocol::Task(void) client->Alive(); } // and done - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } else if ( IsValidDisconnectPacket(Buffer) ) @@ -183,7 +183,7 @@ void CYsfProtocol::Task(void) std::cout << "YSF disconnect packet from " << Ip << std::endl; // find client - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); std::shared_ptrclient = clients->FindClient(Ip, EProtocol::ysf); if ( client != nullptr ) { @@ -193,7 +193,7 @@ void CYsfProtocol::Task(void) //EncodeDisconnectPacket(&Buffer); //Send(Buffer, Ip); } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } else if ( IsValidwirexPacket(Buffer, &Fich, &Callsign, &iWiresxCmd, &iWiresxArg) ) { @@ -270,7 +270,7 @@ void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, CCallsign rpt2(Header->GetRpt2Callsign()); // find this client - std::shared_ptrclient = g_Refl.GetClients()->FindClient(Ip, EProtocol::ysf); + std::shared_ptrclient = g_Reflector.GetClients()->FindClient(Ip, EProtocol::ysf); if ( client ) { // get client callsign @@ -281,20 +281,20 @@ void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, rpt2.SetCSModule(m); // and try to open the stream - if ( (stream = g_Refl.OpenStream(Header, client)) != nullptr ) + if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr ) { // keep the handle m_Streams[stream->GetStreamId()] = stream; } } // release - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); // update last heard - if ( g_Refl.IsValidModule(rpt2.GetCSModule()) ) + if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) ) { - g_Refl.GetUsers()->Hearing(my, rpt1, rpt2); - g_Refl.ReleaseUsers(); + g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2); + g_Reflector.ReleaseUsers(); } } } @@ -352,7 +352,7 @@ void CYsfProtocol::HandleQueue(void) if ( buffer.size() > 0 ) { // and push it to all our clients linked to the module and who are not streaming in - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::ysf, it)) != nullptr ) @@ -365,7 +365,7 @@ void CYsfProtocol::HandleQueue(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } } } @@ -380,7 +380,7 @@ void CYsfProtocol::HandleKeepalives(void) // and disconnect them if not // iterate on clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); auto it = clients->begin(); std::shared_ptrclient = nullptr; while ( (client = clients->FindNextClient(EProtocol::ysf, it)) != nullptr ) @@ -400,7 +400,7 @@ void CYsfProtocol::HandleKeepalives(void) } } - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); } //////////////////////////////////////////////////////////////////////////////////////// @@ -537,7 +537,7 @@ bool CYsfProtocol::IsValidDvFramePacket(const CIp &Ip, const CYSFFICH &Fich, con rpt2.SetCSModule(' '); header = std::unique_ptr(new CDvHeaderPacket(csMY, CCallsign("CQCQCQ"), rpt1, rpt2, m_uiStreamId, Fich.getFN())); - if ( g_Gate.MayTransmit(header->GetMyCallsign(), Ip, EProtocol::ysf, header->GetRpt2Module()) ) + if ( g_GateKeeper.MayTransmit(header->GetMyCallsign(), Ip, EProtocol::ysf, header->GetRpt2Module()) ) { OnDvHeaderPacketIn(header, Ip); } @@ -1003,9 +1003,9 @@ bool CYsfProtocol::EncodeServerStatusPacket(CBuffer *Buffer) const memcpy(description, m_RegistrationDesc.c_str(), REG_DESC_SIZE); Buffer->Append(description, REG_DESC_SIZE); // connected clients - CClients *clients = g_Refl.GetClients(); + CClients *clients = g_Reflector.GetClients(); int count = MIN(999, clients->GetSize()); - g_Refl.ReleaseClients(); + g_Reflector.ReleaseClients(); ::sprintf(sz, "%03u", count); Buffer->Append((uint8_t *)sz, 3); @@ -1079,8 +1079,8 @@ bool CYsfProtocol::DebugTestDecodePacket(const CBuffer &Buffer) std::cout << "Trailer" << std::endl; std::cout << "length of payload : " << len << std::endl; dump.Set(command, len); - dump.DebugDump(g_Refl.m_DebugFile); - dump.DebugDumpAscii(g_Refl.m_DebugFile); + dump.DebugDump(g_Reflector.m_DebugFile); + dump.DebugDumpAscii(g_Reflector.m_DebugFile); break; case YSF_FI_COMMUNICATIONS: if ( Fich.getDT() == YSF_DT_DATA_FR_MODE )