From 1bada70ca4ef1a18f1f7ac262cd3418a396303d7 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Thu, 25 Jul 2024 17:00:58 -0400 Subject: [PATCH] better fix then the previous commit, flag a LC decode from an LDU1 as "raw only", use raw RS bytes always for a ModemV24 convertFromAir; --- src/common/p25/lc/LC.cpp | 20 ++++++----------- src/common/p25/lc/LC.h | 12 ++++------- src/host/modem/ModemV24.cpp | 43 +++++++++++-------------------------- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/src/common/p25/lc/LC.cpp b/src/common/p25/lc/LC.cpp index ee1a057f..98e35693 100644 --- a/src/common/p25/lc/LC.cpp +++ b/src/common/p25/lc/LC.cpp @@ -66,7 +66,6 @@ LC::LC() : m_rs(), m_encryptOverride(false), m_tsbkVendorSkip(false), - m_demandUseRawLC(false), m_callTimer(0U), m_mi(nullptr) { @@ -213,7 +212,7 @@ void LC::encodeHDU(uint8_t* data) /* Decode a logical link data unit 1. */ -bool LC::decodeLDU1(const uint8_t* data) +bool LC::decodeLDU1(const uint8_t* data, bool rawOnly) { assert(data != nullptr); @@ -260,7 +259,7 @@ bool LC::decodeLDU1(const uint8_t* data) Utils::dump(2U, "LC::decodeLDU1(), LDU1 LC", rs, P25_LDU_LC_LENGTH_BYTES); #endif - return decodeLC(rs); + return decodeLC(rs, rawOnly); } /* Encode a logical link data unit 1. */ @@ -508,7 +507,6 @@ void LC::copy(const LC& data) m_callTimer = data.m_callTimer; m_rsValue = data.m_rsValue; - m_demandUseRawLC = data.m_demandUseRawLC; m_algId = data.m_algId; if (m_algId != ALGO_UNENCRYPT) { @@ -541,10 +539,8 @@ void LC::copy(const LC& data) /* Decode link control. */ -bool LC::decodeLC(const uint8_t* rs) +bool LC::decodeLC(const uint8_t* rs, bool rawOnly) { - m_demandUseRawLC = false; - ulong64_t rsValue = 0U; // combine bytes into ulong64_t (8 byte) value @@ -563,11 +559,13 @@ bool LC::decodeLC(const uint8_t* rs) m_mfId = rs[1U]; // Mfg Id. + if (rawOnly) + return true; + // non-standard P25 vendor opcodes (these are just detected for passthru, and stored // as the packed RS value) if ((m_mfId != MFG_STANDARD) && (m_mfId != MFG_STANDARD_ALT)) { //Utils::dump(1U, "Decoded P25 Non-Standard RS", rs, P25_LDU_LC_FEC_LENGTH_BYTES); - m_demandUseRawLC = true; return true; } @@ -585,9 +583,6 @@ bool LC::decodeLC(const uint8_t* rs) m_dstId = (uint32_t)((rsValue >> 24) & 0xFFFFU); // Talkgroup Address m_srcId = (uint32_t)(rsValue & 0xFFFFFFU); // Source Radio Address break; - case LCO::GROUP_UPDT: - m_demandUseRawLC = true; - break; case LCO::PRIVATE: m_mfId = rs[1U]; // Mfg Id. m_group = false; @@ -615,9 +610,6 @@ bool LC::decodeLC(const uint8_t* rs) m_sysId = (uint32_t)((rsValue >> 24) & 0xFFFU); // System ID m_srcId = (uint32_t)(rsValue & 0xFFFFFFU); // Source Radio Address break; - case LCO::RFSS_STS_BCAST: - m_demandUseRawLC = true; - break; default: LogError(LOG_P25, "LC::decodeLC(), unknown LC value, mfId = $%02X, lco = $%02X", m_mfId, m_lco); return false; diff --git a/src/common/p25/lc/LC.h b/src/common/p25/lc/LC.h index 97b0fa77..1b854af5 100644 --- a/src/common/p25/lc/LC.h +++ b/src/common/p25/lc/LC.h @@ -85,9 +85,10 @@ namespace p25 /** * @brief Decode a logical link data unit 1. * @param[in] data Buffer containing an LDU1 to decode. + * @param rawOnly Flag indicating only the raw bytes of the LC should be decoded. * @returns True, if LDU1 decoded, otherwise false. */ - bool decodeLDU1(const uint8_t* data); + bool decodeLDU1(const uint8_t* data, bool rawOnly = false); /** * @brief Encode a logical link data unit 1. * @param[out] data Buffer to encode an LDU1. @@ -111,11 +112,6 @@ namespace p25 * @returns bool True, if the MFId contained for this LC is standard, otherwise false. */ bool isStandardMFId() const; - /** - * @brief Helper to determine if we should utilize the raw RS data from the decode. - * @returns bool True, if the raw LC value should be used, otherwise false. - */ - bool isDemandUseRawLC() const { return m_demandUseRawLC; } /** @name Encryption data */ /** @@ -239,7 +235,6 @@ namespace p25 edac::RS634717 m_rs; bool m_encryptOverride; bool m_tsbkVendorSkip; - bool m_demandUseRawLC; uint32_t m_callTimer; @@ -257,9 +252,10 @@ namespace p25 /** * @brief Decode link control. * @param[in] rs Buffer containing the decoded Reed-Solomon LC data. + * @param rawOnly Flag indicating only the raw bytes of the LC should be decoded. * @returns bool True, if LC is decoded, otherwise false. */ - bool decodeLC(const uint8_t* rs); + bool decodeLC(const uint8_t* rs, bool rawOnly = false); /** * @brief Encode link control. * @param[out] rs Buffer to encode LC data. diff --git a/src/host/modem/ModemV24.cpp b/src/host/modem/ModemV24.cpp index 23273c45..a6a27a90 100644 --- a/src/host/modem/ModemV24.cpp +++ b/src/host/modem/ModemV24.cpp @@ -1206,7 +1206,7 @@ void ModemV24::convertFromAir(uint8_t* data, uint32_t length) break; case DUID::LDU1: { - bool ret = lc.decodeLDU1(data + 2U); + bool ret = lc.decodeLDU1(data + 2U, true); if (!ret) { LogWarning(LOG_MODEM, P25_LDU1_STR ", undecodable LC"); return; @@ -1329,36 +1329,17 @@ void ModemV24::convertFromAir(uint8_t* data, uint32_t length) ::memset(rs, 0x00U, P25_LDU_LC_FEC_LENGTH_BYTES); if (duid == DUID::LDU1) { - if (lc.isStandardMFId() && !lc.isDemandUseRawLC()) { - uint8_t serviceOptions = - (lc.getEmergency() ? 0x80U : 0x00U) + - (lc.getEncrypted() ? 0x40U : 0x00U) + - (lc.getPriority() & 0x07U); - - rs[0U] = lc.getLCO(); // LCO - rs[1U] = lc.getMFId(); // MFId - rs[2U] = serviceOptions; // Service Options - uint32_t dstId = lc.getDstId(); - rs[3U] = (dstId >> 16) & 0xFFU; // Target Address - rs[4U] = (dstId >> 8) & 0xFFU; - rs[5U] = (dstId >> 0) & 0xFFU; - uint32_t srcId = lc.getSrcId(); - rs[6U] = (srcId >> 16) & 0xFFU; // Source Address - rs[7U] = (srcId >> 8) & 0xFFU; - rs[8U] = (srcId >> 0) & 0xFFU; - } else { - rs[0U] = lc.getLCO(); // LCO - - // split ulong64_t (8 byte) value into bytes - rs[1U] = (uint8_t)((lc.getRS() >> 56) & 0xFFU); - rs[2U] = (uint8_t)((lc.getRS() >> 48) & 0xFFU); - rs[3U] = (uint8_t)((lc.getRS() >> 40) & 0xFFU); - rs[4U] = (uint8_t)((lc.getRS() >> 32) & 0xFFU); - rs[5U] = (uint8_t)((lc.getRS() >> 24) & 0xFFU); - rs[6U] = (uint8_t)((lc.getRS() >> 16) & 0xFFU); - rs[7U] = (uint8_t)((lc.getRS() >> 8) & 0xFFU); - rs[8U] = (uint8_t)((lc.getRS() >> 0) & 0xFFU); - } + rs[0U] = lc.getLCO(); // LCO + + // split ulong64_t (8 byte) value into bytes + rs[1U] = (uint8_t)((lc.getRS() >> 56) & 0xFFU); + rs[2U] = (uint8_t)((lc.getRS() >> 48) & 0xFFU); + rs[3U] = (uint8_t)((lc.getRS() >> 40) & 0xFFU); + rs[4U] = (uint8_t)((lc.getRS() >> 32) & 0xFFU); + rs[5U] = (uint8_t)((lc.getRS() >> 24) & 0xFFU); + rs[6U] = (uint8_t)((lc.getRS() >> 16) & 0xFFU); + rs[7U] = (uint8_t)((lc.getRS() >> 8) & 0xFFU); + rs[8U] = (uint8_t)((lc.getRS() >> 0) & 0xFFU); // encode RS (24,12,13) FEC m_rs.encode241213(rs);