diff --git a/M17Control.cpp b/M17Control.cpp index 3f98e5a..59ef2de 100644 --- a/M17Control.cpp +++ b/M17Control.cpp @@ -180,6 +180,15 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) std::string source = m_rfLICH.getSource(); std::string dest = m_rfLICH.getDest(); + if (m_selfOnly) { + bool ret = checkCallsign(source); + if (!ret) { + LogMessage("M17, invalid access attempt from %s to %s", source.c_str(), dest.c_str()); + m_rfState = RS_RF_REJECTED; + return false; + } + } + unsigned char dataType = m_rfLICH.getDataType(); switch (dataType) { case 1U: @@ -269,6 +278,15 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) std::string source = m_rfLICH.getSource(); std::string dest = m_rfLICH.getDest(); + if (m_selfOnly) { + bool ret = checkCallsign(source); + if (!ret) { + LogMessage("M17, invalid access attempt from %s to %s", source.c_str(), dest.c_str()); + m_rfState = RS_RF_REJECTED; + return false; + } + } + unsigned char dataType = m_rfLICH.getDataType(); switch (dataType) { case 1U: @@ -693,6 +711,13 @@ void CM17Control::decorrelator(const unsigned char* in, unsigned char* out) cons } } +bool CM17Control::checkCallsign(const std::string& callsign) const +{ + size_t len = m_callsign.size(); + + return m_callsign.compare(0U, len, callsign, 0U, len) == 0; +} + bool CM17Control::openFile() { if (m_fp != NULL) diff --git a/M17Control.h b/M17Control.h index 1c2a271..71c402d 100644 --- a/M17Control.h +++ b/M17Control.h @@ -85,6 +85,8 @@ private: void interleaver(const unsigned char* in, unsigned char* out) const; void decorrelator(const unsigned char* in, unsigned char* out) const; + bool checkCallsign(const std::string& source) const; + unsigned int countBits(unsigned char byte); void writeEndRF(); diff --git a/Version.h b/Version.h index 0117c94..f1c220d 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20201019"; +const char* VERSION = "20201020"; #endif