From 320523a668db2361b04de9602e50e037433ba91b Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Tue, 18 Apr 2023 10:35:40 -0400 Subject: [PATCH] fix a problem where the source for a grant isn't being checked for a "grant retry" condition; --- src/dmr/packet/ControlSignaling.cpp | 16 ++++++++++++++++ src/lookups/AffiliationLookup.h | 2 +- src/nxdn/packet/Trunk.cpp | 16 ++++++++++++++++ src/p25/packet/Trunk.cpp | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/dmr/packet/ControlSignaling.cpp b/src/dmr/packet/ControlSignaling.cpp index dede269d..968b3b36 100644 --- a/src/dmr/packet/ControlSignaling.cpp +++ b/src/dmr/packet/ControlSignaling.cpp @@ -867,6 +867,22 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ } } else { + // do collision check between grants to see if a SU is attempting a "grant retry" or if this is a + // different source from the original grant + uint32_t grantedSrcId = m_tscc->m_affiliations->getGrantedSrcId(dstId); + if (srcId != grantedSrcId) { + if (!net) { + LogWarning(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), SVC_KIND_VOICE_CALL (Voice Call) denied, traffic in progress, dstId = %u", m_tscc->m_slotNo, dstId); + writeRF_CSBK_ACK_RSP(srcId, TS_DENY_RSN_TGT_BUSY, (grp) ? 1U : 0U); + + ::ActivityLog("DMR", true, "Slot %u group grant request %u to TG %u denied", m_tscc->m_slotNo, srcId, dstId); + m_slot->m_rfState = RS_RF_REJECTED; + } + + return false; + } + + chNo = m_tscc->m_affiliations->getGrantedCh(dstId); slot = m_tscc->m_affiliations->getGrantedSlot(dstId); diff --git a/src/lookups/AffiliationLookup.h b/src/lookups/AffiliationLookup.h index 08ac858d..15967de1 100644 --- a/src/lookups/AffiliationLookup.h +++ b/src/lookups/AffiliationLookup.h @@ -150,7 +150,7 @@ namespace lookups /// Helper to get the channel granted for the given destination ID. virtual uint32_t getGrantedCh(uint32_t dstId); /// Helper to get the source ID granted for the given destination ID. - virtual uint32_t getGrantedSrcId(uint32_t srcId); + virtual uint32_t getGrantedSrcId(uint32_t dstId); /// Helper to set RF channel data. void setRFChData(const std::unordered_map& chData) { m_rfChDataTable = chData; } diff --git a/src/nxdn/packet/Trunk.cpp b/src/nxdn/packet/Trunk.cpp index e3cc1e76..71793be9 100644 --- a/src/nxdn/packet/Trunk.cpp +++ b/src/nxdn/packet/Trunk.cpp @@ -536,7 +536,23 @@ bool Trunk::writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uint8_t servic } } else { + // do collision check between grants to see if a SU is attempting a "grant retry" or if this is a + // different source from the original grant + uint32_t grantedSrcId = m_nxdn->m_affiliations.getGrantedSrcId(dstId); + if (srcId != grantedSrcId) { + if (!net) { + LogWarning(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_VCALL_REQ " denied, traffic in progress, dstId = %u", dstId); + writeRF_Message_Deny(0U, srcId, NXDN_CAUSE_VD_QUE_GRP_BUSY, RTCH_MESSAGE_TYPE_VCALL); + + ::ActivityLog("NXDN", true, "group grant request from %u to TG %u denied", srcId, dstId); + m_nxdn->m_rfState = RS_RF_REJECTED; + } + + return false; + } + chNo = m_nxdn->m_affiliations.getGrantedCh(dstId); + m_nxdn->m_affiliations.touchGrant(dstId); } } diff --git a/src/p25/packet/Trunk.cpp b/src/p25/packet/Trunk.cpp index 4f541229..e1bf6f35 100644 --- a/src/p25/packet/Trunk.cpp +++ b/src/p25/packet/Trunk.cpp @@ -688,6 +688,9 @@ bool Trunk::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::L } } break; + case TSBK_OSP_DVM_GIT_HASH: + // ignore + return true; // don't allow this to write to the air default: LogError(LOG_NET, P25_TSDU_STR ", unhandled LCO, mfId = $%02X, lco = $%02X", tsbk->getMFId(), tsbk->getLCO()); return false; @@ -2224,6 +2227,21 @@ bool Trunk::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOp } } else { + // do collision check between grants to see if a SU is attempting a "grant retry" or if this is a + // different source from the original grant + uint32_t grantedSrcId = m_p25->m_affiliations.getGrantedSrcId(dstId); + if (srcId != grantedSrcId) { + if (!net) { + LogWarning(LOG_RF, P25_TSDU_STR ", TSBK_IOSP_GRP_VCH (Group Voice Channel Request) denied, traffic in progress, dstId = %u", dstId); + writeRF_TSDU_Deny(srcId, dstId, P25_DENY_RSN_PTT_COLLIDE, (grp) ? TSBK_IOSP_GRP_VCH : TSBK_IOSP_UU_VCH); + + ::ActivityLog("P25", true, "group grant request from %u to TG %u denied", srcId, dstId); + m_p25->m_rfState = RS_RF_REJECTED; + } + + return false; + } + chNo = m_p25->m_affiliations.getGrantedCh(dstId); m_p25->m_affiliations.touchGrant(dstId); }