diff --git a/reflector/Configure.cpp b/reflector/Configure.cpp index 445e953..ca28935 100644 --- a/reflector/Configure.cpp +++ b/reflector/Configure.cpp @@ -83,6 +83,7 @@ #define JTRANSCODER "Transcoder" #define JTXPORT "TxPort" #define JURF "URF" +#define JENABLEDGID "EnableDGID" #define JURL "URL" #define JUSRP "USRP" #define JWHITELISTPATH "WhitelistPath" @@ -428,6 +429,8 @@ bool CConfigure::ReadData(const std::string &path) data[g_Keys.ysf.port] = getUnsigned(value, "YSF Port", 1024, 65535, 42000); else if (0 == key.compare(JAUTOLINKMODULE)) setAutolink(JYSF, g_Keys.ysf.autolinkmod, value); + else if (0 == key.compare(JENABLEDGID)) + data[g_Keys.ysf.enabledgid] = IS_TRUE(value[0]); else if (0 == key.compare(JDEFAULTTXFREQ)) data[g_Keys.ysf.defaulttxfreq] = getUnsigned(value, "YSF DefaultTxFreq", 40000000, 2600000000, 439000000); else if (0 == key.compare(JDEFAULTRXFREQ)) @@ -753,6 +756,7 @@ bool CConfigure::ReadData(const std::string &path) // YSF isDefined(ErrorLevel::fatal, JYSF, JPORT, g_Keys.ysf.port, rval); + isDefined(ErrorLevel::mild, JYSF, JENABLEDGID, g_Keys.ysf.enabledgid, rval); checkAutoLink(JYSF, JAUTOLINKMODULE, g_Keys.ysf.autolinkmod, rval); isDefined(ErrorLevel::fatal, JYSF, JDEFAULTRXFREQ, g_Keys.ysf.defaultrxfreq, rval); isDefined(ErrorLevel::fatal, JYSF, JDEFAULTTXFREQ, g_Keys.ysf.defaulttxfreq, rval); diff --git a/reflector/JsonKeys.h b/reflector/JsonKeys.h index 72cfc0d..64a86e9 100644 --- a/reflector/JsonKeys.h +++ b/reflector/JsonKeys.h @@ -59,9 +59,9 @@ struct SJsonKeys { p25 { "P25Port", "P25AutolinkMod", "P25ReflectorID" }, nxdn { "NXDNPort", "NXDNAutolinkMod", "NXDNReflectorID" }; - struct YSF { const std::string port, autolinkmod, defaulttxfreq, defaultrxfreq; + struct YSF { const std::string port, autolinkmod, enabledgid, defaulttxfreq, defaultrxfreq; struct YSLREG { const std::string id, name, description; } ysfreflectordb; } - ysf { "YSFPort", "YSFAutoLinkMod", "YSFDefaultTxFreq", "YSFDefaultRxFreq", + ysf { "YSFPort", "YSFAutoLinkMod", "YSFEnableDGID", "YSFDefaultTxFreq", "YSFDefaultRxFreq", { "ysfrefdbid", "ysfrefdbname", "ysfrefdbdesc" } }; struct DB { const std::string url, mode, refreshmin, filepath; } diff --git a/reflector/YSFProtocol.cpp b/reflector/YSFProtocol.cpp index 0795db0..4c8e6ab 100644 --- a/reflector/YSFProtocol.cpp +++ b/reflector/YSFProtocol.cpp @@ -42,6 +42,7 @@ bool CYsfProtocol::Initialize(const char *type, const EProtocol ptype, const uin { // config data m_AutolinkModule = g_Configure.GetAutolinkModule(g_Keys.ysf.autolinkmod); + m_EnableDGID = g_Configure.GetBoolean(g_Keys.ysf.enabledgid); 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)); @@ -130,7 +131,7 @@ void CYsfProtocol::Task(void) if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::ysf, Header->GetRpt2Module()) ) { // handle it - OnDvHeaderPacketIn(Header, Ip); + OnDvHeaderPacketIn(Header, Ip, Fich.getSQ()); //OnDvFramePacketIn(Frames[0], &Ip); //OnDvFramePacketIn(Frames[1], &Ip); } @@ -252,7 +253,7 @@ void CYsfProtocol::Task(void) //////////////////////////////////////////////////////////////////////////////////////// // streams helpers -void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, const CIp &Ip) +void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, const CIp &Ip, uint8_t dgid) { // find the stream auto stream = GetStream(Header->GetStreamId()); @@ -275,6 +276,16 @@ void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr &Header, { // get client callsign rpt1 = client->GetCallsign(); + + // module selection by DGID + if (m_EnableDGID && dgid >= 10 && dgid <= 35) { + char newModule = 'A' + (dgid - 10); + if (client->GetReflectorModule() != newModule) { + std::cout << "YSF: DGID module switch for " << client->GetCallsign() << " from " << client->GetReflectorModule() << " to " << newModule << std::endl; + client->SetReflectorModule(newModule); + } + } + // get module it's linked to auto m = client->GetReflectorModule(); Header->SetRpt2Module(m); @@ -537,7 +548,7 @@ bool CYsfProtocol::IsValidDvFramePacket(const CIp &Ip, const CYSFFICH &Fich, con if ( g_GateKeeper.MayTransmit(header->GetMyCallsign(), Ip, EProtocol::ysf, header->GetRpt2Module()) ) { - OnDvHeaderPacketIn(header, Ip); + OnDvHeaderPacketIn(header, Ip, Fich.getSQ()); } } diff --git a/reflector/YSFProtocol.h b/reflector/YSFProtocol.h index b3060c2..059dc37 100644 --- a/reflector/YSFProtocol.h +++ b/reflector/YSFProtocol.h @@ -79,7 +79,7 @@ protected: void HandleKeepalives(void); // stream helpers - void OnDvHeaderPacketIn(std::unique_ptr &, const CIp &); + void OnDvHeaderPacketIn(std::unique_ptr &, const CIp &, uint8_t = 0); // DV packet decoding helpers bool IsValidConnectPacket(const CBuffer &, CCallsign *); @@ -132,6 +132,7 @@ protected: // config data char m_AutolinkModule; + bool m_EnableDGID; unsigned m_RegistrationId; std::string m_RegistrationName, m_RegistrationDesc; };