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