diff --git a/reflector/BMProtocol.cpp b/reflector/BMProtocol.cpp index 3d848ce..d733977 100644 --- a/reflector/BMProtocol.cpp +++ b/reflector/BMProtocol.cpp @@ -27,6 +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); if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; @@ -225,11 +226,10 @@ void CBMProtocol::HandleQueue(void) break; case EProtoRev::ambe: default: -#ifdef TRANSCODED_MODULES - Send(buffer, client->GetIp()); -#else - Send(bufferLegacy, client->GetIp()); -#endif + if (m_HasTranscoder) + Send(buffer, client->GetIp()); + else + Send(bufferLegacy, client->GetIp()); break; } } diff --git a/reflector/BMProtocol.h b/reflector/BMProtocol.h index 74dfe15..08c0593 100644 --- a/reflector/BMProtocol.h +++ b/reflector/BMProtocol.h @@ -73,4 +73,6 @@ protected: // time CTimer m_LastKeepaliveTime; CTimer m_LastPeersLinkTime; + // config data; + bool m_HasTranscoder; }; diff --git a/reflector/GateKeeper.cpp b/reflector/GateKeeper.cpp index 1ec17e9..8949377 100644 --- a/reflector/GateKeeper.cpp +++ b/reflector/GateKeeper.cpp @@ -92,9 +92,7 @@ bool CGateKeeper::MayLink(const CCallsign &callsign, const CIp &ip, EProtocol pr case EProtocol::p25: case EProtocol::usrp: case EProtocol::nxdn: -#ifndef NO_G3 case EProtocol::g3: -#endif // first check is IP & callsigned listed OK ok &= IsNodeListedOk(callsign, ip); // todo: then apply any protocol specific authorisation for the operation @@ -141,9 +139,7 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, const EP case EProtocol::p25: case EProtocol::nxdn: case EProtocol::usrp: -#ifndef NO_G3 case EProtocol::g3: -#endif // first check is IP & callsigned listed OK ok = ok && IsNodeListedOk(callsign, ip, module); // todo: then apply any protocol specific authorisation for the operation @@ -300,10 +296,8 @@ const std::string CGateKeeper::ProtocolName(const EProtocol p) const return "USRP"; case EProtocol::bm: return "Brandmeister"; -#ifndef NO_G3 case EProtocol::g3: return "Icom G3"; -#endif default: return "NONE"; } diff --git a/reflector/Makefile b/reflector/Makefile index 8a2a1f8..7930dff 100644 --- a/reflector/Makefile +++ b/reflector/Makefile @@ -25,7 +25,7 @@ INICHECK = inicheck include configure.mk ifeq ($(debug), true) -CFLAGS = -ggdb3 -W -Werror -c -std=c++11 -MMD -MD +CFLAGS = -ggdb3 -DDEBUG -W -Werror -c -std=c++11 -MMD -MD else CFLAGS = -W -Werror -std=c++11 -MMD -MD endif diff --git a/reflector/PacketStream.cpp b/reflector/PacketStream.cpp index a5df4a8..2f6ea53 100644 --- a/reflector/PacketStream.cpp +++ b/reflector/PacketStream.cpp @@ -22,11 +22,7 @@ //////////////////////////////////////////////////////////////////////////////////////// // constructor -#ifdef TRANSCODED_MODULES -CPacketStream::CPacketStream(std::shared_ptr reader) -#else CPacketStream::CPacketStream() -#endif { m_bOpen = false; m_uiStreamId = 0; diff --git a/reflector/YSFProtocol.cpp b/reflector/YSFProtocol.cpp index 6869148..68fcfe9 100644 --- a/reflector/YSFProtocol.cpp +++ b/reflector/YSFProtocol.cpp @@ -25,6 +25,9 @@ #include "YSFProtocol.h" #include "Global.h" +#define REG_NAME_SIZE 16 +#define REG_DESC_SIZE 14 + //////////////////////////////////////////////////////////////////////////////////////// // constructor CYsfProtocol::CYsfProtocol() @@ -39,6 +42,11 @@ bool CYsfProtocol::Initialize(const char *type, const EProtocol ptype, const uin { // 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_RegistrationName.resize(REG_NAME_SIZE, ' '); + m_RegistrationDesc.resize(REG_DESC_SIZE, ' '); // base class if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) @@ -982,32 +990,20 @@ bool CYsfProtocol::IsValidOptionsPacket(const CBuffer &Buffer) const bool CYsfProtocol::EncodeServerStatusPacket(CBuffer *Buffer) const { uint8_t tag[] = { 'Y','S','F','S' }; - uint8_t description[14]; - uint8_t callsign[16]; -#ifdef YSF_REFLECTOR_DESCRIPTION - const std::string desc = YSF_REFLECTOR_DESCRIPTION; -#else - const std::string desc("URF Reflector"); -#endif + uint8_t description[REG_DESC_SIZE]; + uint8_t callsign[REG_NAME_SIZE]; // tag Buffer->Set(tag, sizeof(tag)); // hash - memset(callsign, ' ', sizeof(callsign)); -#ifdef YSF_REFLECTOR_NAME - const std::string cs = YSF_REFLECTOR_NAME; - memcpy(callsign, cs.c_str(), cs.size() > 16 ? 16 : cs.size()); -#else - g_Refl.GetCallsign().GetCallsign(callsign); -#endif + memcpy(callsign, m_RegistrationName.c_str(), 16); char sz[16]; - ::sprintf(sz, "%05u", CalcHash(callsign, 16) % 100000U); + ::sprintf(sz, "%05u", CalcHash(callsign, REG_NAME_SIZE) % 100000U); Buffer->Append((uint8_t *)sz, 5); // name - Buffer->Append(callsign, 16); + Buffer->Append(callsign, REG_NAME_SIZE); // description - memset(description, ' ', sizeof(description)); - memcpy(description, desc.c_str(), desc.size() > 14 ? 14 : desc.size()); - Buffer->Append(description, 14); + memcpy(description, m_RegistrationDesc.c_str(), REG_DESC_SIZE); + Buffer->Append(description, REG_DESC_SIZE); // connected clients CClients *clients = g_Refl.GetClients(); int count = MIN(999, clients->GetSize()); @@ -1021,10 +1017,7 @@ bool CYsfProtocol::EncodeServerStatusPacket(CBuffer *Buffer) const uint32_t CYsfProtocol::CalcHash(const uint8_t *buffer, int len) const { -#ifdef YSF_REFLECTOR_ID - uint32_t hash = YSF_REFLECTOR_ID; -#else - uint32_t hash = 0U; + uint32_t hash = m_RegistrationId; for ( int i = 0; i < len; i++) { @@ -1032,7 +1025,6 @@ uint32_t CYsfProtocol::CalcHash(const uint8_t *buffer, int len) const hash += (hash << 10); hash ^= (hash >> 6); } -#endif hash += (hash << 3); hash ^= (hash >> 11); diff --git a/reflector/YSFProtocol.h b/reflector/YSFProtocol.h index da1eee4..4c30da9 100644 --- a/reflector/YSFProtocol.h +++ b/reflector/YSFProtocol.h @@ -133,4 +133,6 @@ protected: // config data char m_AutolinkModule; + unsigned m_RegistrationId; + std::string m_RegistrationName, m_RegistrationDesc; };