Add the SelfOnly processing for M17.

This commit is contained in:
Jonathan Naylor 2020-10-20 09:40:29 +01:00
parent 9567ac0b20
commit d58a0c53b5
3 changed files with 28 additions and 1 deletions

View file

@ -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)

View file

@ -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();

View file

@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20201019";
const char* VERSION = "20201020";
#endif