From 10f3f35131f37f67b0c65771c68ac5b5aaa57627 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Thu, 24 Oct 2024 13:58:58 -0400 Subject: [PATCH] add destination ID to ICC messages; --- src/fne/network/FNENetwork.cpp | 9 ++++++--- src/fne/network/FNENetwork.h | 3 ++- src/fne/network/callhandler/TagDMRData.cpp | 6 +++--- src/fne/network/callhandler/TagNXDNData.cpp | 7 ++++--- src/fne/network/callhandler/TagP25Data.cpp | 7 ++++--- src/host/dmr/Control.cpp | 8 ++++---- src/host/dmr/Control.h | 3 ++- src/host/dmr/Slot.cpp | 14 ++++++++------ src/host/dmr/Slot.h | 3 ++- src/host/network/Network.cpp | 11 +++++++---- src/host/network/Network.h | 12 ++++++------ src/host/nxdn/Control.cpp | 16 +++++++++------- src/host/nxdn/Control.h | 3 ++- src/host/p25/Control.cpp | 16 +++++++++------- src/host/p25/Control.h | 3 ++- 15 files changed, 70 insertions(+), 51 deletions(-) diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index 8af3a55c..f311744c 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -2253,20 +2253,23 @@ void FNENetwork::writePeerList(uint32_t peerId) /* Helper to send a In-Call Control command to the specified peer. */ -bool FNENetwork::writePeerICC(uint32_t peerId, NET_SUBFUNC::ENUM subFunc, NET_ICC::ENUM command, uint8_t slotNo) +bool FNENetwork::writePeerICC(uint32_t peerId, NET_SUBFUNC::ENUM subFunc, NET_ICC::ENUM command, uint32_t dstId, uint8_t slotNo) { assert(peerId > 0); if (!m_enableInCallCtrl) return false; + if (dstId == 0U) + return false; uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); __SET_UINT32(peerId, buffer, 6U); // Peer ID buffer[10U] = (uint8_t)command; // In-Call Control Command - buffer[11U] = slotNo; + __SET_UINT16(dstId, buffer, 11U); // Destination ID + buffer[14U] = slotNo; // DMR Slot No - return writePeer(peerId, { NET_FUNC::INCALL_CTRL, subFunc }, buffer, 12U, RTP_END_OF_CALL_SEQ, false, true); + return writePeer(peerId, { NET_FUNC::INCALL_CTRL, subFunc }, buffer, 15U, RTP_END_OF_CALL_SEQ, false, true); } /* Helper to send a data message to the specified peer. */ diff --git a/src/fne/network/FNENetwork.h b/src/fne/network/FNENetwork.h index af6c2c04..010825e2 100644 --- a/src/fne/network/FNENetwork.h +++ b/src/fne/network/FNENetwork.h @@ -573,10 +573,11 @@ namespace network * @param peerId Peer ID. * @param subFunc Network Sub-Function. * @param command In-Call Control Command. + * @param dstId Destination ID. * @param slotNo DMR slot. */ bool writePeerICC(uint32_t peerId, NET_SUBFUNC::ENUM subFunc = NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, - NET_ICC::ENUM command = NET_ICC::NOP, uint8_t slotNo = 0U); + NET_ICC::ENUM command = NET_ICC::NOP, uint32_t dstId = 0U, uint8_t slotNo = 0U); /** * @brief Helper to send a data message to the specified peer. diff --git a/src/fne/network/callhandler/TagDMRData.cpp b/src/fne/network/callhandler/TagDMRData.cpp index 857bd723..1298d9ff 100644 --- a/src/fne/network/callhandler/TagDMRData.cpp +++ b/src/fne/network/callhandler/TagDMRData.cpp @@ -790,7 +790,7 @@ bool TagDMRData::validate(uint32_t peerId, data::NetData& data, uint32_t streamI .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, NET_ICC::REJECT_TRAFFIC, data.getSlotNo()); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, NET_ICC::REJECT_TRAFFIC, data.getDstId(), data.getSlotNo()); return false; } @@ -810,7 +810,7 @@ bool TagDMRData::validate(uint32_t peerId, data::NetData& data, uint32_t streamI .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, NET_ICC::REJECT_TRAFFIC, data.getSlotNo()); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, NET_ICC::REJECT_TRAFFIC, data.getDstId(), data.getSlotNo()); return false; } @@ -829,7 +829,7 @@ bool TagDMRData::validate(uint32_t peerId, data::NetData& data, uint32_t streamI .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, NET_ICC::REJECT_TRAFFIC, data.getSlotNo()); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR, NET_ICC::REJECT_TRAFFIC, data.getDstId(), data.getSlotNo()); return false; } } diff --git a/src/fne/network/callhandler/TagNXDNData.cpp b/src/fne/network/callhandler/TagNXDNData.cpp index 8dc858f0..0fab289b 100644 --- a/src/fne/network/callhandler/TagNXDNData.cpp +++ b/src/fne/network/callhandler/TagNXDNData.cpp @@ -552,7 +552,7 @@ bool TagNXDNData::validate(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, u .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC, lc.getDstId()); return false; } } @@ -580,6 +580,7 @@ bool TagNXDNData::validate(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, u .request(m_network->m_influxServer); } + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC, lc.getDstId()); return false; } } @@ -604,7 +605,7 @@ bool TagNXDNData::validate(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, u .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC, lc.getDstId()); return false; } @@ -622,7 +623,7 @@ bool TagNXDNData::validate(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, u .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN, NET_ICC::REJECT_TRAFFIC, lc.getDstId()); return false; } diff --git a/src/fne/network/callhandler/TagP25Data.cpp b/src/fne/network/callhandler/TagP25Data.cpp index 30f67a30..9a99d5a8 100644 --- a/src/fne/network/callhandler/TagP25Data.cpp +++ b/src/fne/network/callhandler/TagP25Data.cpp @@ -1034,7 +1034,7 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC, control.getDstId()); return false; } } @@ -1066,6 +1066,7 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const .request(m_network->m_influxServer); } + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC, control.getDstId()); return false; } } @@ -1114,7 +1115,7 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC, control.getDstId()); return false; } @@ -1132,7 +1133,7 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const .request(m_network->m_influxServer); } - m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC); + m_network->writePeerICC(peerId, NET_SUBFUNC::PROTOCOL_SUBFUNC_P25, NET_ICC::REJECT_TRAFFIC, control.getDstId()); return false; } diff --git a/src/host/dmr/Control.cpp b/src/host/dmr/Control.cpp index 95e0fc48..df6c182e 100644 --- a/src/host/dmr/Control.cpp +++ b/src/host/dmr/Control.cpp @@ -178,7 +178,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, ::lookups::VoiceChDa // set the In-Call Control function callback if (m_network != nullptr) { - m_network->setDMRICCCallback([=](network::NET_ICC::ENUM command, uint8_t slotNo) { processInCallCtrl(command, slotNo); }); + m_network->setDMRICCCallback([=](network::NET_ICC::ENUM command, uint32_t dstId, uint8_t slotNo) { processInCallCtrl(command, dstId, slotNo); }); } if (printOptions) { @@ -745,13 +745,13 @@ void Control::processNetwork() /* Helper to process an In-Call Control message. */ -void Control::processInCallCtrl(network::NET_ICC::ENUM command, uint8_t slotNo) +void Control::processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId, uint8_t slotNo) { switch (slotNo) { case 1U: - return m_slot1->processInCallCtrl(command); + return m_slot1->processInCallCtrl(command, dstId); case 2U: - return m_slot2->processInCallCtrl(command); + return m_slot2->processInCallCtrl(command, dstId); default: LogError(LOG_DMR, "DMR, invalid slot, slotNo = %u", slotNo); break; diff --git a/src/host/dmr/Control.h b/src/host/dmr/Control.h index 1fdab63f..1b7cad2c 100644 --- a/src/host/dmr/Control.h +++ b/src/host/dmr/Control.h @@ -334,9 +334,10 @@ namespace dmr /** * @brief Helper to process an In-Call Control message. * @param command In-Call Control Command. + * @param dstId Destination ID. * @param slotNo DMR slot. */ - void processInCallCtrl(network::NET_ICC::ENUM command, uint8_t slotNo); + void processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId, uint8_t slotNo); }; } // namespace dmr diff --git a/src/host/dmr/Slot.cpp b/src/host/dmr/Slot.cpp index c17eb9e1..39980092 100644 --- a/src/host/dmr/Slot.cpp +++ b/src/host/dmr/Slot.cpp @@ -455,17 +455,19 @@ void Slot::processNetwork(const data::NetData& dmrData) /* Helper to process an In-Call Control message. */ -void Slot::processInCallCtrl(network::NET_ICC::ENUM command) +void Slot::processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId) { switch (command) { case network::NET_ICC::REJECT_TRAFFIC: { - processFrameLoss(); + if (m_rfState == RS_RF_AUDIO && m_rfLC->getDstId() == dstId) { + processFrameLoss(); - m_rfLastDstId = 0U; - m_rfLastSrcId = 0U; - m_rfTGHang.stop(); - m_rfState = RS_RF_REJECTED; + m_rfLastDstId = 0U; + m_rfLastSrcId = 0U; + m_rfTGHang.stop(); + m_rfState = RS_RF_REJECTED; + } } break; diff --git a/src/host/dmr/Slot.h b/src/host/dmr/Slot.h index 490dd3ec..98cbad0d 100644 --- a/src/host/dmr/Slot.h +++ b/src/host/dmr/Slot.h @@ -161,8 +161,9 @@ namespace dmr /** * @brief Helper to process an In-Call Control message. * @param command In-Call Control Command. + * @param dstId Destination ID. */ - void processInCallCtrl(network::NET_ICC::ENUM command); + void processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId); /** @} */ /** @name Data Clocking */ diff --git a/src/host/network/Network.cpp b/src/host/network/Network.cpp index e0735c2b..cc5d21df 100644 --- a/src/host/network/Network.cpp +++ b/src/host/network/Network.cpp @@ -494,28 +494,31 @@ void Network::clock(uint32_t ms) if (fneHeader.getSubFunction() == NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR) { // DMR In-Call Control if (m_enabled && m_dmrEnabled) { NET_ICC::ENUM command = (NET_ICC::ENUM)buffer[10U]; - uint8_t slot = buffer[11U]; + uint32_t dstId = __GET_UINT16(buffer, 11U); + uint8_t slot = buffer[14U]; if (m_dmrInCallCallback != nullptr) { - m_dmrInCallCallback(command, slot); + m_dmrInCallCallback(command, dstId, slot); } } } else if (fneHeader.getSubFunction() == NET_SUBFUNC::PROTOCOL_SUBFUNC_P25) { // P25 In-Call Control if (m_enabled && m_p25Enabled) { NET_ICC::ENUM command = (NET_ICC::ENUM)buffer[10U]; + uint32_t dstId = __GET_UINT16(buffer, 11U); if (m_p25InCallCallback != nullptr) { - m_p25InCallCallback(command); + m_p25InCallCallback(command, dstId); } } } else if (fneHeader.getSubFunction() == NET_SUBFUNC::PROTOCOL_SUBFUNC_NXDN) { // NXDN In-Call Control if (m_enabled && m_nxdnEnabled) { NET_ICC::ENUM command = (NET_ICC::ENUM)buffer[10U]; + uint32_t dstId = __GET_UINT16(buffer, 11U); if (m_nxdnInCallCallback != nullptr) { - m_nxdnInCallCallback(command); + m_nxdnInCallCallback(command, dstId); } } } diff --git a/src/host/network/Network.h b/src/host/network/Network.h index 7698178f..a5e9f297 100644 --- a/src/host/network/Network.h +++ b/src/host/network/Network.h @@ -157,17 +157,17 @@ namespace network * @brief Helper to set the DMR In-Call Control callback. * @param callback */ - void setDMRICCCallback(std::function&& callback) { m_dmrInCallCallback = callback; } + void setDMRICCCallback(std::function&& callback) { m_dmrInCallCallback = callback; } /** * @brief Helper to set the P25 In-Call Control callback. * @param callback */ - void setP25ICCCallback(std::function&& callback) { m_p25InCallCallback = callback; } + void setP25ICCCallback(std::function&& callback) { m_p25InCallCallback = callback; } /** * @brief Helper to set the NXDN In-Call Control callback. * @param callback */ - void setNXDNICCCallback(std::function&& callback) { m_nxdnInCallCallback = callback; } + void setNXDNICCCallback(std::function&& callback) { m_nxdnInCallCallback = callback; } public: /** @@ -230,9 +230,9 @@ namespace network bool m_promiscuousPeer; - std::function m_dmrInCallCallback; - std::function m_p25InCallCallback; - std::function m_nxdnInCallCallback; + std::function m_dmrInCallCallback; + std::function m_p25InCallCallback; + std::function m_nxdnInCallCallback; /** * @brief User overrideable handler that allows user code to process network packets not handled by this class. diff --git a/src/host/nxdn/Control.cpp b/src/host/nxdn/Control.cpp index 7b699f7d..ca663113 100644 --- a/src/host/nxdn/Control.cpp +++ b/src/host/nxdn/Control.cpp @@ -298,7 +298,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw // set the In-Call Control function callback if (m_network != nullptr) { - m_network->setNXDNICCCallback([=](network::NET_ICC::ENUM command) { processInCallCtrl(command); }); + m_network->setNXDNICCCallback([=](network::NET_ICC::ENUM command, uint32_t dstId) { processInCallCtrl(command, dstId); }); } if (printOptions) { @@ -1039,17 +1039,19 @@ void Control::processFrameLoss() /* Helper to process an In-Call Control message. */ -void Control::processInCallCtrl(network::NET_ICC::ENUM command) +void Control::processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId) { switch (command) { case network::NET_ICC::REJECT_TRAFFIC: { - processFrameLoss(); + if (m_rfState == RS_RF_AUDIO && m_rfLC.getDstId() == dstId) { + processFrameLoss(); - m_rfLastDstId = 0U; - m_rfLastSrcId = 0U; - m_rfTGHang.stop(); - m_rfState = RS_RF_REJECTED; + m_rfLastDstId = 0U; + m_rfLastSrcId = 0U; + m_rfTGHang.stop(); + m_rfState = RS_RF_REJECTED; + } } break; diff --git a/src/host/nxdn/Control.h b/src/host/nxdn/Control.h index bf943ae2..d4cb4e95 100644 --- a/src/host/nxdn/Control.h +++ b/src/host/nxdn/Control.h @@ -365,8 +365,9 @@ namespace nxdn /** * @brief Helper to process an In-Call Control message. * @param command In-Call Control Command. + * @param dstId Destination ID. */ - void processInCallCtrl(network::NET_ICC::ENUM command); + void processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId); /** * @brief Helper to send a REST API request to the CC to release a channel grant at the end of a call. diff --git a/src/host/p25/Control.cpp b/src/host/p25/Control.cpp index 944cb036..69cc43dd 100644 --- a/src/host/p25/Control.cpp +++ b/src/host/p25/Control.cpp @@ -441,7 +441,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw // set the In-Call Control function callback if (m_network != nullptr) { - m_network->setP25ICCCallback([=](network::NET_ICC::ENUM command) { processInCallCtrl(command); }); + m_network->setP25ICCCallback([=](network::NET_ICC::ENUM command, uint32_t dstId) { processInCallCtrl(command, dstId); }); } if (printOptions) { @@ -1541,17 +1541,19 @@ void Control::processFrameLoss() /* Helper to process an In-Call Control message. */ -void Control::processInCallCtrl(network::NET_ICC::ENUM command) +void Control::processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId) { switch (command) { case network::NET_ICC::REJECT_TRAFFIC: { - processFrameLoss(); + if (m_rfState == RS_RF_AUDIO && m_voice->m_rfLC.getDstId() == dstId) { + processFrameLoss(); - m_rfLastDstId = 0U; - m_rfLastSrcId = 0U; - m_rfTGHang.stop(); - m_rfState = RS_RF_REJECTED; + m_rfLastDstId = 0U; + m_rfLastSrcId = 0U; + m_rfTGHang.stop(); + m_rfState = RS_RF_REJECTED; + } } break; diff --git a/src/host/p25/Control.h b/src/host/p25/Control.h index 02242a6e..d8ed72d1 100644 --- a/src/host/p25/Control.h +++ b/src/host/p25/Control.h @@ -401,8 +401,9 @@ namespace p25 /** * @brief Helper to process an In-Call Control message. * @param command In-Call Control Command. + * @param dstId Destination ID. */ - void processInCallCtrl(network::NET_ICC::ENUM command); + void processInCallCtrl(network::NET_ICC::ENUM command, uint32_t dstId); /** * @brief Helper to send a REST API request to the CC to release a channel grant at the end of a call.