diff --git a/NXDNGateway/NXDNGateway.cpp b/NXDNGateway/NXDNGateway.cpp index 250f634..d44ba48 100644 --- a/NXDNGateway/NXDNGateway.cpp +++ b/NXDNGateway/NXDNGateway.cpp @@ -247,8 +247,16 @@ void CNXDNGateway::run() // If we're linked and it's from the right place, send it on if (currentId != 9999U && currentAddr.s_addr == address.s_addr && currentPort == port) { // Don't pass reflector control data through to the MMDVM - if (::memcmp(buffer, "NXDND", 5U) == 0) - localNetwork.write(buffer + 10U, len - 10U, rptAddr, rptPort); + if (::memcmp(buffer, "NXDND", 5U) == 0) { + unsigned short dstId = 0U; + dstId |= (buffer[7U] << 8) & 0xFF00U; + dstId |= (buffer[8U] << 0) & 0x00FFU; + + bool grp = (buffer[9U] & 0x01U) == 0x01U; + + if (grp && currentId == dstId) + localNetwork.write(buffer + 10U, len - 10U, rptAddr, rptPort); + } // Any network activity is proof that the reflector is alive lostTimer.start(); diff --git a/NXDNReflector/Conf.cpp b/NXDNReflector/Conf.cpp index d9d6a01..0564d15 100644 --- a/NXDNReflector/Conf.cpp +++ b/NXDNReflector/Conf.cpp @@ -37,6 +37,7 @@ enum SECTION { CConf::CConf(const std::string& file) : m_file(file), +m_tg(9999U), m_daemon(false), m_lookupName(), m_lookupTime(0U), @@ -98,6 +99,8 @@ bool CConf::read() if (section == SECTION_GENERAL) { if (::strcmp(key, "Daemon") == 0) m_daemon = ::atoi(value) == 1; + else if (::strcmp(key, "TG") == 0) + m_tg = (unsigned short)::atoi(value); } else if (section == SECTION_ID_LOOKUP) { if (::strcmp(key, "Name") == 0) m_lookupName = value; @@ -141,6 +144,11 @@ bool CConf::getDaemon() const return m_daemon; } +unsigned short CConf::getTG() const +{ + return m_tg; +} + std::string CConf::getLookupName() const { return m_lookupName; diff --git a/NXDNReflector/Conf.h b/NXDNReflector/Conf.h index b2a8f99..d5c4c2e 100644 --- a/NXDNReflector/Conf.h +++ b/NXDNReflector/Conf.h @@ -31,21 +31,22 @@ public: bool read(); // The General section - bool getDaemon() const; + unsigned short getTG() const; + bool getDaemon() const; // The Id Lookup section - std::string getLookupName() const; - unsigned int getLookupTime() const; + std::string getLookupName() const; + unsigned int getLookupTime() const; // The Log section - unsigned int getLogDisplayLevel() const; - unsigned int getLogFileLevel() const; - std::string getLogFilePath() const; - std::string getLogFileRoot() const; + unsigned int getLogDisplayLevel() const; + unsigned int getLogFileLevel() const; + std::string getLogFilePath() const; + std::string getLogFileRoot() const; // The Network section - unsigned int getNetworkPort() const; - bool getNetworkDebug() const; + unsigned int getNetworkPort() const; + bool getNetworkDebug() const; // The NXCore section bool getNXCoreEnabled() const; @@ -55,19 +56,20 @@ public: bool getNXCoreDebug() const; private: - std::string m_file; - bool m_daemon; + std::string m_file; + unsigned short m_tg; + bool m_daemon; - std::string m_lookupName; - unsigned int m_lookupTime; + std::string m_lookupName; + unsigned int m_lookupTime; - unsigned int m_logDisplayLevel; - unsigned int m_logFileLevel; - std::string m_logFilePath; - std::string m_logFileRoot; + unsigned int m_logDisplayLevel; + unsigned int m_logFileLevel; + std::string m_logFilePath; + std::string m_logFileRoot; - unsigned int m_networkPort; - bool m_networkDebug; + unsigned int m_networkPort; + bool m_networkDebug; bool m_nxCoreEnabled; std::string m_nxCoreAddress; diff --git a/NXDNReflector/NXDNReflector.cpp b/NXDNReflector/NXDNReflector.cpp index 9ef545d..060c76e 100644 --- a/NXDNReflector/NXDNReflector.cpp +++ b/NXDNReflector/NXDNReflector.cpp @@ -161,6 +161,8 @@ void CNXDNReflector::run() } #endif + unsigned short tg = m_conf.getTG(); + CNXDNNetwork nxdnNetwork(m_conf.getNetworkPort(), m_conf.getNetworkDebug()); ret = nxdnNetwork.open(); if (!ret) { @@ -262,7 +264,7 @@ void CNXDNReflector::run() LogMessage("NXCore link disabled by %s at %s", callsign.c_str(), current->m_callsign.c_str()); closeNXCore(); } - } else { + } else if (grp && dstId == tg) { rpt->m_timer.start(); if (current == NULL && !nxCoreActive) { @@ -305,15 +307,21 @@ void CNXDNReflector::run() if (current == NULL) { if (!nxCoreActive) { if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && buffer[5U] == 0x01U) { - // Save the grp, src and dest for use in the NXDN Protocol messages - grp = (buffer[7U] & 0x20U) == 0x20U; - srcId = (buffer[8U] << 8) | buffer[9U]; - dstId = (buffer[10U] << 8) | buffer[11U]; + bool tempGrp = (buffer[7U] & 0x20U) == 0x20U; + unsigned short tempSrcId = (buffer[8U] << 8) | buffer[9U]; + unsigned short tempDstId = (buffer[10U] << 8) | buffer[11U]; - std::string callsign = lookup->find(srcId); - LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId); + if (tempGrp && tempDstId == tg) { + // Save the grp, src and dest for use in the NXDN Protocol messages + grp = tempGrp; + srcId = tempSrcId; + dstId = tempDstId; - nxCoreActive = true; + std::string callsign = lookup->find(srcId); + LogMessage("Transmission from %s at NXCore to %s%u", callsign.c_str(), grp ? "TG " : "", dstId); + + nxCoreActive = true; + } } } diff --git a/NXDNReflector/NXDNReflector.ini b/NXDNReflector/NXDNReflector.ini index 56a9f6c..a59ccd5 100644 --- a/NXDNReflector/NXDNReflector.ini +++ b/NXDNReflector/NXDNReflector.ini @@ -1,4 +1,5 @@ [General] +TG=9999 Daemon=1 [Id Lookup]