From 139be054be42503b52f6b03fea972d287a2395a7 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 17 Sep 2017 12:16:14 +0100 Subject: [PATCH] Add better validation of DG-ID for DSQ use. --- YSFControl.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/YSFControl.cpp b/YSFControl.cpp index d41ff2d..0eb3225 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -154,13 +154,23 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len) if (valid) m_lastFICH = fich; - // Validate the DSQ value if enabled + // Validate the DSQ/DG-ID value if enabled if (m_sqlEnabled) { - bool sql = m_lastFICH.getSQL(); - unsigned char value = m_lastFICH.getSQ(); + unsigned char cm = m_lastFICH.getCM(); + if (cm == YSF_CM_GROUP2) { + // Using the DG-ID value + unsigned char value = m_lastFICH.getSQ(); - if (!sql || value != m_sqlValue) - return false; + if (value != m_sqlValue) + return false; + } else { + // Using the DSQ value + bool sql = m_lastFICH.getSQL(); + unsigned char value = m_lastFICH.getSQ(); + + if (!sql || value != m_sqlValue) + return false; + } } // Stop repeater packets coming through, unless we're acting as a remote gateway