From d1e265bd8e3b711e2666213e21c7b8f577b17d97 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sat, 1 May 2021 05:15:39 +0000 Subject: [PATCH] expand DMR LC service options out to proper class fields; --- dmr/DMRDefines.h | 10 +++++ dmr/lc/LC.cpp | 92 ++++++++++++++++++++++++--------------------- dmr/lc/LC.h | 18 ++++++--- p25/P25Defines.h | 3 ++ p25/TrunkPacket.cpp | 2 +- 5 files changed, 76 insertions(+), 49 deletions(-) diff --git a/dmr/DMRDefines.h b/dmr/DMRDefines.h index bde06d1e..84615b47 100644 --- a/dmr/DMRDefines.h +++ b/dmr/DMRDefines.h @@ -134,6 +134,16 @@ namespace dmr const uint8_t FID_ETSI = 0x00U; // ETSI Standard Feature Set const uint8_t FID_DMRA = 0x10U; // + const uint8_t LC_SVC_OPT_EMERGENCY = 0x80U; + const uint8_t LC_SVC_OPT_PRIVACY = 0x40U; + const uint8_t LC_SVC_OPT_BCAST = 0x08U; + const uint8_t LC_SVC_OPT_OVCM = 0x04U; + + const uint8_t CALL_PRIORITY_NONE = 0x00U; + const uint8_t CALL_PRIORITY_1 = 0x01U; + const uint8_t CALL_PRIORITY_2 = 0x02U; + const uint8_t CALL_PRIORITY_3 = 0x03U; + const uint32_t DMR_EXT_FNCT_CHECK = 0x0000U; // Radio Check const uint32_t DMR_EXT_FNCT_UNINHIBIT = 0x007EU; // Radio Uninhibit const uint32_t DMR_EXT_FNCT_INHIBIT = 0x007FU; // Radio Inhibit diff --git a/dmr/lc/LC.cpp b/dmr/lc/LC.cpp index 4fa28a34..b36f026a 100644 --- a/dmr/lc/LC.cpp +++ b/dmr/lc/LC.cpp @@ -52,8 +52,12 @@ LC::LC(uint8_t flco, uint32_t srcId, uint32_t dstId) : m_FID(0U), m_srcId(srcId), m_dstId(dstId), - m_R(false), - m_options(0U) + m_emergency(false), + m_encrypted(false), + m_broadcast(false), + m_ovcm(false), + m_priority(CALL_PRIORITY_2), + m_R(false) { /* stub */ } @@ -67,8 +71,12 @@ LC::LC(const uint8_t* bytes) : m_FID(0U), m_srcId(0U), m_dstId(0U), - m_R(false), - m_options(0U) + m_emergency(false), + m_encrypted(false), + m_broadcast(false), + m_ovcm(false), + m_priority(CALL_PRIORITY_2), + m_R(false) { assert(bytes != NULL); @@ -79,10 +87,14 @@ LC::LC(const uint8_t* bytes) : m_FID = bytes[1U]; - m_options = bytes[2U]; + m_emergency = (bytes[2U] & 0x80U) == 0x80U; // Emergency Flag + m_encrypted = (bytes[2U] & 0x40U) == 0x40U; // Encryption Flag + m_broadcast = (bytes[2U] & 0x08U) == 0x08U; // Broadcast Flag + m_ovcm = (bytes[2U] & 0x04U) == 0x04U; // OVCM Flag + m_priority = (bytes[2U] & 0x03U); // Priority - m_dstId = bytes[3U] << 16 | bytes[4U] << 8 | bytes[5U]; - m_srcId = bytes[6U] << 16 | bytes[7U] << 8 | bytes[8U]; + m_dstId = bytes[3U] << 16 | bytes[4U] << 8 | bytes[5U]; // Destination Address + m_srcId = bytes[6U] << 16 | bytes[7U] << 8 | bytes[8U]; // Source Address } /// /// Initializes a new instance of the LC class. @@ -94,8 +106,12 @@ LC::LC(const bool* bits) : m_FID(0U), m_srcId(0U), m_dstId(0U), - m_R(false), - m_options(0U) + m_emergency(false), + m_encrypted(false), + m_broadcast(false), + m_ovcm(false), + m_priority(CALL_PRIORITY_2), + m_R(false) { assert(bits != NULL); @@ -110,7 +126,12 @@ LC::LC(const bool* bits) : m_FID = temp2; Utils::bitsToByteBE(bits + 16U, temp3); - m_options = temp3; + + m_emergency = (temp3 & 0x80U) == 0x80U; // Emergency Flag + m_encrypted = (temp3 & 0x40U) == 0x40U; // Encryption Flag + m_broadcast = (temp3 & 0x08U) == 0x08U; // Broadcast Flag + m_ovcm = (temp3 & 0x04U) == 0x04U; // OVCM Flag + m_priority = (temp3 & 0x03U); // Priority uint8_t d1, d2, d3; Utils::bitsToByteBE(bits + 24U, d1); @@ -122,8 +143,8 @@ LC::LC(const bool* bits) : Utils::bitsToByteBE(bits + 56U, s2); Utils::bitsToByteBE(bits + 64U, s3); - m_srcId = s1 << 16 | s2 << 8 | s3; - m_dstId = d1 << 16 | d2 << 8 | d3; + m_srcId = s1 << 16 | s2 << 8 | s3; // Source Address + m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address } /// /// Initializes a new instance of the LC class. @@ -134,8 +155,12 @@ LC::LC() : m_FID(0U), m_srcId(0U), m_dstId(0U), - m_R(false), - m_options(0U) + m_emergency(false), + m_encrypted(false), + m_broadcast(false), + m_ovcm(false), + m_priority(CALL_PRIORITY_2), + m_R(false) { /* stub */ } @@ -166,15 +191,19 @@ void LC::getData(uint8_t* bytes) const bytes[1U] = m_FID; - bytes[2U] = m_options; + bytes[2U] = (m_emergency ? 0x80U : 0x00U) + // Emergency Flag + (m_encrypted ? 0x40U : 0x00U) + // Encrypted Flag + (m_broadcast ? 0x08U : 0x00U) + // Broadcast Flag + (m_ovcm ? 0x04U : 0x00U) + // OVCM Flag + (m_priority & 0x03U); // Priority - bytes[3U] = m_dstId >> 16; - bytes[4U] = m_dstId >> 8; - bytes[5U] = m_dstId >> 0; + bytes[3U] = m_dstId >> 16; // Destination Address + bytes[4U] = m_dstId >> 8; // .. + bytes[5U] = m_dstId >> 0; // .. - bytes[6U] = m_srcId >> 16; - bytes[7U] = m_srcId >> 8; - bytes[8U] = m_srcId >> 0; + bytes[6U] = m_srcId >> 16; // Source Address + bytes[7U] = m_srcId >> 8; // .. + bytes[8U] = m_srcId >> 0; // .. } /// @@ -198,24 +227,3 @@ void LC::getData(bool* bits) const Utils::byteToBitsBE(bytes[7U], bits + 56U); Utils::byteToBitsBE(bytes[8U], bits + 64U); } - -/// -/// -/// -/// -bool LC::getOVCM() const -{ - return (m_options & 0x04U) == 0x04U; -} - -/// -/// -/// -/// -void LC::setOVCM(bool ovcm) -{ - if (ovcm) - m_options |= 0x04U; - else - m_options &= 0xFBU; -} diff --git a/dmr/lc/LC.h b/dmr/lc/LC.h index 61a24f15..44da10be 100644 --- a/dmr/lc/LC.h +++ b/dmr/lc/LC.h @@ -60,10 +60,6 @@ namespace dmr /// Gets LC data as bits. void getData(bool* bits) const; - /// Gets the OVCM flag. - bool getOVCM() const; - /// Sets the OVCM flag. - void setOVCM(bool ovcm); public: /// Flag indicating whether link protection is enabled. __PROPERTY(bool, PF, PF); @@ -79,10 +75,20 @@ namespace dmr /// Destination ID. __PROPERTY(uint32_t, dstId, DstId); + /** Service Options */ + /// Flag indicating the emergency bits are set. + __PROPERTY(bool, emergency, Emergency); + /// Flag indicating that encryption is enabled. + __PROPERTY(bool, encrypted, Encrypted); + /// Priority level for the traffic. + __PROPERTY(uint8_t, priority, Priority); + /// Flag indicating broadcast operation. + __PROPERTY(bool, broadcast, Broadcast); + /// Flag indicating OVCM operation. + __PROPERTY(bool, ovcm, OVCM); + private: bool m_R; - - uint8_t m_options; }; } // namespace lc } // namespace dmr diff --git a/p25/P25Defines.h b/p25/P25Defines.h index 32dd2ba5..2fd017ed 100644 --- a/p25/P25Defines.h +++ b/p25/P25Defines.h @@ -249,6 +249,9 @@ namespace p25 const uint8_t PDU_TYPE_SNDCP_RF_UNCONFIRMED = 0x04U; const uint8_t PDU_TYPE_SNDCP_RF_CONFIRMED = 0x05U; + const uint8_t LC_SVC_OPT_EMERGENCY = 0x80U; + const uint8_t LC_SVC_OPT_ENCRYPTION = 0x40U; + // LDUx/TDULC Link Control Opcode(s) const uint8_t LC_GROUP = 0x00U; // GRP VCH USER - Group Voice Channel User const uint8_t LC_GROUP_UPDT = 0x02U; // GRP VCH UPDT - Group Voice Channel Update diff --git a/p25/TrunkPacket.cpp b/p25/TrunkPacket.cpp index ba221d95..a6a58b7f 100644 --- a/p25/TrunkPacket.cpp +++ b/p25/TrunkPacket.cpp @@ -1555,7 +1555,7 @@ void TrunkPacket::writeRF_TDULC(uint8_t duid, bool noNetwork) } //if (m_verbose) { - // LogMessage(LOG_RF, P25_TDULC_STR ", lc = $%02X, srcId = %u", m_netTDULC.getLCO(), m_netTDULC.getSrcId()); + // LogMessage(LOG_RF, P25_TDULC_STR ", lc = $%02X, srcId = %u", m_rfTDULC.getLCO(), m_rfTDULC.getSrcId()); //} }