From 4399e46b9d716c17d53e6a36e52faa175d9f803d Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sat, 21 Nov 2026 13:03:09 -0500 Subject: [PATCH] prevent P25 response, unconfirmed, and AMBT packets from consuming the LLC send sequence; preserve N(S) and SYN advancement for new confirmed data packets only; --- .../callhandler/packetdata/P25PacketData.cpp | 14 +++++++++++--- .../callhandler/packetdata/P25PacketData.h | 19 +++++++++++++++++++ tests/fne/FNETestHooks.cpp | 8 ++++++++ tests/fne/FNETestHooks.h | 8 ++++++++ tests/p25/P25_PacketDataState_Tests.cpp | 10 ++++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/fne/network/callhandler/packetdata/P25PacketData.cpp b/src/fne/network/callhandler/packetdata/P25PacketData.cpp index 0c135863..e7f2bc20 100644 --- a/src/fne/network/callhandler/packetdata/P25PacketData.cpp +++ b/src/fne/network/callhandler/packetdata/P25PacketData.cpp @@ -1371,6 +1371,13 @@ void P25PacketData::dispatchToFNE(uint32_t peerId) } } +/* Determines whether an outbound PDU requires a new LLC send sequence. */ + +bool P25PacketData::requiresSendSequence(uint8_t format, bool retransmit) +{ + return !retransmit && format == PDUFormatType::CONFIRMED; +} + /* Helper to dispatch PDU user data back to the local FNE network. (Will not transmit to neighbor FNE peers.) */ bool P25PacketData::dispatchUserFrameToFNE(DataHeader& dataHeader, bool extendedAddress, bool auxiliaryES, uint8_t* pduUserData, bool retransmit) @@ -1399,9 +1406,10 @@ bool P25PacketData::dispatchUserFrameToFNE(DataHeader& dataHeader, bool extended return false; } - // update V(S) only after a usable RF route has been selected; a retransmission - // keeps the N(S) already in its header, so the SU can discard a duplicate - if (!retransmit) { + // N(S) and SYN exist only in confirmed-data headers; Responses, unconfirmed + // data, and AMBT packets must not consume V(S); a retransmission keeps the + // N(S) already in its header so the SU can discard a duplicate + if (requiresSendSequence(dataHeader.getFormat(), retransmit)) { bool synchronize = false; uint8_t sendSequence = m_dataLinkManager.nextSendSequence(srcId, synchronize); if (synchronize) diff --git a/src/fne/network/callhandler/packetdata/P25PacketData.h b/src/fne/network/callhandler/packetdata/P25PacketData.h index e6f5317e..523a1cd7 100644 --- a/src/fne/network/callhandler/packetdata/P25PacketData.h +++ b/src/fne/network/callhandler/packetdata/P25PacketData.h @@ -36,6 +36,14 @@ #include #include +// --------------------------------------------------------------------------- +// Class Prototypes +// --------------------------------------------------------------------------- + +#if defined(CATCH2_TEST_COMPILATION) +class FNETestHooks; +#endif + namespace network { namespace callhandler @@ -134,6 +142,9 @@ namespace network void setDebug(bool debug) { m_debug = debug; } private: +#if defined(CATCH2_TEST_COMPILATION) + friend class ::FNETestHooks; +#endif TrafficNetwork* m_network; TagP25Data* m_tag; @@ -288,6 +299,14 @@ namespace network std::mutex m_sndcpPendingLock; // never nested with m_sndcpContextLock std::unordered_map m_sndcpPending; + /** + * @brief Determines whether an outbound PDU requires a new LLC send sequence. + * @param format PDU header format. + * @param retransmit Flag indicating the PDU is a retransmission. + * @return True when the PDU requires a new send sequence; otherwise, false. + */ + static bool requiresSendSequence(uint8_t format, bool retransmit); + /** * @brief Helper to refresh SNDCP state when a PDU is received from a subscriber. * @param llId Logical Link ID of the SU. diff --git a/tests/fne/FNETestHooks.cpp b/tests/fne/FNETestHooks.cpp index 9bea356c..fe0aa2db 100644 --- a/tests/fne/FNETestHooks.cpp +++ b/tests/fne/FNETestHooks.cpp @@ -10,6 +10,7 @@ #include "fne/FNETestHooks.h" #include "fne/HostFNE.h" #include "fne/network/P25OTARService.h" +#include "fne/network/callhandler/packetdata/P25PacketData.h" #include "fne/network/callhandler/TagP25Data.h" #include "fne/network/callhandler/TagDMRData.h" #include "fne/network/callhandler/TagP25P2Data.h" @@ -39,6 +40,13 @@ bool g_promiscuousHub = false; // Public Class Members // --------------------------------------------------------------------------- +/* Determines whether an outbound P25 PDU requires a new LLC send sequence. */ + +bool FNETestHooks::p25RequiresSendSequence(uint8_t format, bool retransmit) +{ + return network::callhandler::packetdata::P25PacketData::requiresSendSequence(format, retransmit); +} + /* Tests whether a P25 frame is telephone interconnect traffic. */ bool FNETestHooks::isP25TelIntTraffic(TrafficNetwork& network, p25::lc::LC& control, diff --git a/tests/fne/FNETestHooks.h b/tests/fne/FNETestHooks.h index 18c4000a..1984f0f8 100644 --- a/tests/fne/FNETestHooks.h +++ b/tests/fne/FNETestHooks.h @@ -81,6 +81,14 @@ public: uint32_t peerId, uint32_t ssrc, uint32_t streamId, uint16_t pktSeq = 1U, bool fromUpstream = false); + /** + * @brief Determines whether an outbound P25 PDU requires a new LLC send sequence. + * @param format PDU header format. + * @param retransmit Flag indicating the PDU is a retransmission. + * @return True when the PDU requires a new send sequence; otherwise, false. + */ + static bool p25RequiresSendSequence(uint8_t format, bool retransmit); + /** * @brief Tests whether a P25 frame is classified as telephone interconnect traffic. * @param network The TrafficNetwork instance. diff --git a/tests/p25/P25_PacketDataState_Tests.cpp b/tests/p25/P25_PacketDataState_Tests.cpp index 5196f10b..db528be4 100644 --- a/tests/p25/P25_PacketDataState_Tests.cpp +++ b/tests/p25/P25_PacketDataState_Tests.cpp @@ -8,6 +8,7 @@ * */ #include "host/Defines.h" +#include "fne/FNETestHooks.h" #include "common/p25/P25Defines.h" #include "common/p25/data/ConventionalRegistration.h" #include "common/p25/data/IPv4Packet.h" @@ -174,6 +175,15 @@ TEST_CASE("P25 LLC state is isolated by LLID", "[p25][packet-data][llc]") CHECK_FALSE(links.hasState(1001U)); } +TEST_CASE("P25 LLC send sequences are assigned only to new confirmed PDUs", "[p25][packet-data][llc]") +{ + CHECK(FNETestHooks::p25RequiresSendSequence(PDUFormatType::CONFIRMED, false)); + CHECK_FALSE(FNETestHooks::p25RequiresSendSequence(PDUFormatType::CONFIRMED, true)); + CHECK_FALSE(FNETestHooks::p25RequiresSendSequence(PDUFormatType::RSP, false)); + CHECK_FALSE(FNETestHooks::p25RequiresSendSequence(PDUFormatType::UNCONFIRMED, false)); + CHECK_FALSE(FNETestHooks::p25RequiresSendSequence(PDUFormatType::AMBT, false)); +} + TEST_CASE("P25 LLC receive sequence wraps and suppresses duplicates", "[p25][packet-data][llc]") { DataLinkManager links;