From 4c0aa33cec92c79993d24cd02ebf0c75c104dd10 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 9 Jul 2017 14:37:27 +0100 Subject: [PATCH 1/2] Update DMRAccessControl.cpp Modified to match the first 7 digit of the DMR ID received over RF when in 'Self-Only' mode. --- DMRAccessControl.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index 121fc45..803886a 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -22,6 +22,7 @@ #include #include #include +#include std::vector CDMRAccessControl::m_blackList; std::vector CDMRAccessControl::m_whiteList; @@ -48,8 +49,16 @@ void CDMRAccessControl::init(const std::vector& blacklist, const s bool CDMRAccessControl::validateSrcId(unsigned int id) { - if (m_selfOnly) - return id == m_id; + std::string str_id = std::to_string(id); // DMR ID from RF + std::string str_m_id = std::to_string(m_id); // MMDVMHost ID from Config + if (m_selfOnly) { +// return id == m_id; + if (str_m_id.compare(0,7,str_id) == 0) {// if the first 7 digits of the MMDVMHost ID match the WHOLE of the RF ID + return true; // then allow the connection + } else { + return false; // if not, reject it + } + } if (std::find(m_blackList.begin(), m_blackList.end(), id) != m_blackList.end()) return false; From fc34ea916f9d858bf172602cb36158b2e4330f94 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 9 Jul 2017 16:40:16 +0100 Subject: [PATCH 2/2] Update DMRAccessControl.cpp Updated to make string conversion only when needed and to re-add the id == m_id compare --- DMRAccessControl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/DMRAccessControl.cpp b/DMRAccessControl.cpp index 803886a..3c88ab4 100644 --- a/DMRAccessControl.cpp +++ b/DMRAccessControl.cpp @@ -49,11 +49,10 @@ void CDMRAccessControl::init(const std::vector& blacklist, const s bool CDMRAccessControl::validateSrcId(unsigned int id) { - std::string str_id = std::to_string(id); // DMR ID from RF - std::string str_m_id = std::to_string(m_id); // MMDVMHost ID from Config if (m_selfOnly) { -// return id == m_id; - if (str_m_id.compare(0,7,str_id) == 0) {// if the first 7 digits of the MMDVMHost ID match the WHOLE of the RF ID + std::string str_id = std::to_string(id); // DMR ID from RF + std::string str_m_id = std::to_string(m_id); // MMDVMHost ID from Config + if ((id == m_id) || (str_m_id.compare(0,7,str_id) == 0)) {// if the RF ID matched the configured ID or if the first 7 digits of the MMDVMHost ID match the WHOLE of the RF ID return true; // then allow the connection } else { return false; // if not, reject it