mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Add the SelfOnly processing for M17.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user