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;

pull/65/head
Bryan Biedenkapp 2 years ago
parent c8a60af83c
commit 1bada70ca4

@ -66,7 +66,6 @@ LC::LC() :
m_rs(), m_rs(),
m_encryptOverride(false), m_encryptOverride(false),
m_tsbkVendorSkip(false), m_tsbkVendorSkip(false),
m_demandUseRawLC(false),
m_callTimer(0U), m_callTimer(0U),
m_mi(nullptr) m_mi(nullptr)
{ {
@ -213,7 +212,7 @@ void LC::encodeHDU(uint8_t* data)
/* Decode a logical link data unit 1. */ /* 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); 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); Utils::dump(2U, "LC::decodeLDU1(), LDU1 LC", rs, P25_LDU_LC_LENGTH_BYTES);
#endif #endif
return decodeLC(rs); return decodeLC(rs, rawOnly);
} }
/* Encode a logical link data unit 1. */ /* Encode a logical link data unit 1. */
@ -508,7 +507,6 @@ void LC::copy(const LC& data)
m_callTimer = data.m_callTimer; m_callTimer = data.m_callTimer;
m_rsValue = data.m_rsValue; m_rsValue = data.m_rsValue;
m_demandUseRawLC = data.m_demandUseRawLC;
m_algId = data.m_algId; m_algId = data.m_algId;
if (m_algId != ALGO_UNENCRYPT) { if (m_algId != ALGO_UNENCRYPT) {
@ -541,10 +539,8 @@ void LC::copy(const LC& data)
/* Decode link control. */ /* 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; ulong64_t rsValue = 0U;
// combine bytes into ulong64_t (8 byte) value // 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. m_mfId = rs[1U]; // Mfg Id.
if (rawOnly)
return true;
// non-standard P25 vendor opcodes (these are just detected for passthru, and stored // non-standard P25 vendor opcodes (these are just detected for passthru, and stored
// as the packed RS value) // as the packed RS value)
if ((m_mfId != MFG_STANDARD) && (m_mfId != MFG_STANDARD_ALT)) { 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); //Utils::dump(1U, "Decoded P25 Non-Standard RS", rs, P25_LDU_LC_FEC_LENGTH_BYTES);
m_demandUseRawLC = true;
return true; return true;
} }
@ -585,9 +583,6 @@ bool LC::decodeLC(const uint8_t* rs)
m_dstId = (uint32_t)((rsValue >> 24) & 0xFFFFU); // Talkgroup Address m_dstId = (uint32_t)((rsValue >> 24) & 0xFFFFU); // Talkgroup Address
m_srcId = (uint32_t)(rsValue & 0xFFFFFFU); // Source Radio Address m_srcId = (uint32_t)(rsValue & 0xFFFFFFU); // Source Radio Address
break; break;
case LCO::GROUP_UPDT:
m_demandUseRawLC = true;
break;
case LCO::PRIVATE: case LCO::PRIVATE:
m_mfId = rs[1U]; // Mfg Id. m_mfId = rs[1U]; // Mfg Id.
m_group = false; m_group = false;
@ -615,9 +610,6 @@ bool LC::decodeLC(const uint8_t* rs)
m_sysId = (uint32_t)((rsValue >> 24) & 0xFFFU); // System ID m_sysId = (uint32_t)((rsValue >> 24) & 0xFFFU); // System ID
m_srcId = (uint32_t)(rsValue & 0xFFFFFFU); // Source Radio Address m_srcId = (uint32_t)(rsValue & 0xFFFFFFU); // Source Radio Address
break; break;
case LCO::RFSS_STS_BCAST:
m_demandUseRawLC = true;
break;
default: default:
LogError(LOG_P25, "LC::decodeLC(), unknown LC value, mfId = $%02X, lco = $%02X", m_mfId, m_lco); LogError(LOG_P25, "LC::decodeLC(), unknown LC value, mfId = $%02X, lco = $%02X", m_mfId, m_lco);
return false; return false;

@ -85,9 +85,10 @@ namespace p25
/** /**
* @brief Decode a logical link data unit 1. * @brief Decode a logical link data unit 1.
* @param[in] data Buffer containing an LDU1 to decode. * @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. * @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. * @brief Encode a logical link data unit 1.
* @param[out] data Buffer to encode an LDU1. * @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. * @returns bool True, if the MFId contained for this LC is standard, otherwise false.
*/ */
bool isStandardMFId() const; 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 */ /** @name Encryption data */
/** /**
@ -239,7 +235,6 @@ namespace p25
edac::RS634717 m_rs; edac::RS634717 m_rs;
bool m_encryptOverride; bool m_encryptOverride;
bool m_tsbkVendorSkip; bool m_tsbkVendorSkip;
bool m_demandUseRawLC;
uint32_t m_callTimer; uint32_t m_callTimer;
@ -257,9 +252,10 @@ namespace p25
/** /**
* @brief Decode link control. * @brief Decode link control.
* @param[in] rs Buffer containing the decoded Reed-Solomon LC data. * @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. * @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. * @brief Encode link control.
* @param[out] rs Buffer to encode LC data. * @param[out] rs Buffer to encode LC data.

@ -1206,7 +1206,7 @@ void ModemV24::convertFromAir(uint8_t* data, uint32_t length)
break; break;
case DUID::LDU1: case DUID::LDU1:
{ {
bool ret = lc.decodeLDU1(data + 2U); bool ret = lc.decodeLDU1(data + 2U, true);
if (!ret) { if (!ret) {
LogWarning(LOG_MODEM, P25_LDU1_STR ", undecodable LC"); LogWarning(LOG_MODEM, P25_LDU1_STR ", undecodable LC");
return; return;
@ -1329,24 +1329,6 @@ void ModemV24::convertFromAir(uint8_t* data, uint32_t length)
::memset(rs, 0x00U, P25_LDU_LC_FEC_LENGTH_BYTES); ::memset(rs, 0x00U, P25_LDU_LC_FEC_LENGTH_BYTES);
if (duid == DUID::LDU1) { 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 rs[0U] = lc.getLCO(); // LCO
// split ulong64_t (8 byte) value into bytes // split ulong64_t (8 byte) value into bytes
@ -1358,7 +1340,6 @@ void ModemV24::convertFromAir(uint8_t* data, uint32_t length)
rs[6U] = (uint8_t)((lc.getRS() >> 16) & 0xFFU); rs[6U] = (uint8_t)((lc.getRS() >> 16) & 0xFFU);
rs[7U] = (uint8_t)((lc.getRS() >> 8) & 0xFFU); rs[7U] = (uint8_t)((lc.getRS() >> 8) & 0xFFU);
rs[8U] = (uint8_t)((lc.getRS() >> 0) & 0xFFU); rs[8U] = (uint8_t)((lc.getRS() >> 0) & 0xFFU);
}
// encode RS (24,12,13) FEC // encode RS (24,12,13) FEC
m_rs.encode241213(rs); m_rs.encode241213(rs);

Loading…
Cancel
Save

Powered by TurnKey Linux.