cleanup copy assignment implementation for LC and TSBK;

pull/1/head
Bryan Biedenkapp 5 years ago
parent 8cf3d10630
commit ab56ce8a3a

@ -269,9 +269,8 @@ void Control::setOptions(yaml::Node& conf, const std::string cwCallsign, const s
m_voice->resetRF(); m_voice->resetRF();
m_voice->resetNet(); m_voice->resetNet();
m_data->resetRF(); m_data->resetRF();
m_trunk->resetRF();
m_trunk->m_rfTSBK = lc::TSBK(m_siteData, m_idenEntry); m_trunk->resetNet();
m_trunk->m_netTSBK = lc::TSBK(m_siteData, m_idenEntry);
} }
/// <summary> /// <summary>

@ -138,6 +138,24 @@ const uint32_t GRANT_TIMER_TIMEOUT = 15U;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Public Class Members // Public Class Members
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/// <summary>
/// Resets the data states for the RF interface.
/// </summary>
void TrunkPacket::resetRF()
{
lc::TSBK tsbk = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK);
m_rfTSBK = tsbk;
}
/// <summary>
/// Resets the data states for the network.
/// </summary>
void TrunkPacket::resetNet()
{
lc::TSBK tsbk = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK);
m_netTSBK = tsbk;
}
/// <summary> /// <summary>
/// Process a data frame from the RF interface. /// Process a data frame from the RF interface.
/// </summary> /// </summary>
@ -168,8 +186,8 @@ bool TrunkPacket::process(uint8_t* data, uint32_t len)
m_p25->m_queue.clear(); m_p25->m_queue.clear();
m_rfTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetRF();
m_netTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetNet();
bool ret = m_rfTSBK.decode(data + 2U); bool ret = m_rfTSBK.decode(data + 2U);
if (!ret) { if (!ret) {
@ -480,8 +498,8 @@ bool TrunkPacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, d
switch (duid) { switch (duid) {
case P25_DUID_TSDU: case P25_DUID_TSDU:
if (m_p25->m_netState == RS_NET_IDLE) { if (m_p25->m_netState == RS_NET_IDLE) {
m_rfTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetRF();
m_netTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetNet();
bool ret = m_netTSBK.decode(data); bool ret = m_netTSBK.decode(data);
if (!ret) { if (!ret) {
@ -667,8 +685,8 @@ void TrunkPacket::writeAdjSSNetwork()
return; return;
} }
m_rfTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetRF();
m_netTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetNet();
if (m_network != NULL) { if (m_network != NULL) {
if (m_verbose) { if (m_verbose) {
@ -1195,7 +1213,7 @@ void TrunkPacket::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS)
do do
{ {
m_rfTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetRF();
if (m_debug) { if (m_debug) {
LogDebug(LOG_P25, "writeRF_ControlData, mbfCnt = %u, frameCnt = %u, seq = %u, adjSS = %u", m_mbfCnt, frameCnt, n, adjSS); LogDebug(LOG_P25, "writeRF_ControlData, mbfCnt = %u, frameCnt = %u, seq = %u, adjSS = %u", m_mbfCnt, frameCnt, n, adjSS);
@ -1528,7 +1546,7 @@ void TrunkPacket::queueRF_TSBK_Ctrl_MBF(uint8_t lco)
if (!m_p25->m_control) if (!m_p25->m_control)
return; return;
m_rfTSBK = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK); resetRF();
switch (lco) { switch (lco) {
case TSBK_OSP_IDEN_UP: case TSBK_OSP_IDEN_UP:

@ -59,6 +59,11 @@ namespace p25
class HOST_SW_API TrunkPacket { class HOST_SW_API TrunkPacket {
public: public:
/// <summary>Resets the data states for the RF interface.</summary>
void resetRF();
/// <summary>Resets the data states for the network.</summary>
void resetNet();
/// <summary>Process a data frame from the RF interface.</summary> /// <summary>Process a data frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len); bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary> /// <summary>Process a data frame from the network.</summary>

@ -60,10 +60,12 @@ const uint32_t VOC_LDU1_COUNT = 3U;
/// </summary> /// </summary>
void VoicePacket::resetRF() void VoicePacket::resetRF()
{ {
m_rfLC = lc::LC(m_p25->m_siteData); lc::LC lc = lc::LC(m_p25->m_siteData);
//m_rfLastHDU = lc::LC(m_p25->m_siteData);
m_rfLastLDU1 = lc::LC(m_p25->m_siteData); m_rfLC = lc;
m_rfLastLDU2 = lc::LC(m_p25->m_siteData);; //m_rfLastHDU = lc;
m_rfLastLDU1 = lc;
m_rfLastLDU2 = lc;
m_rfFrames = 0U; m_rfFrames = 0U;
m_rfErrs = 0U; m_rfErrs = 0U;
@ -77,8 +79,10 @@ void VoicePacket::resetRF()
/// </summary> /// </summary>
void VoicePacket::resetNet() void VoicePacket::resetNet()
{ {
m_netLC = lc::LC(m_p25->m_siteData); lc::LC lc = lc::LC(m_p25->m_siteData);
m_netLastLDU1 = lc::LC(m_p25->m_siteData);
m_netLC = lc;
m_netLastLDU1 = lc;
m_netFrames = 0U; m_netFrames = 0U;
m_netLost = 0U; m_netLost = 0U;

@ -120,8 +120,12 @@ LC& LC::operator=(const LC& data)
m_algId = data.m_algId; m_algId = data.m_algId;
if (m_algId != P25_ALGO_UNENCRYPT) { if (m_algId != P25_ALGO_UNENCRYPT) {
::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES); delete[] m_mi;
::memcpy(m_mi, data.m_mi, P25_MI_LENGTH_BYTES);
uint8_t* mi = new uint8_t[P25_MI_LENGTH_BYTES];
::memcpy(mi, data.m_mi, P25_MI_LENGTH_BYTES);
m_mi = mi;
m_kId = data.m_kId; m_kId = data.m_kId;
if (!m_encrypted) { if (!m_encrypted) {
@ -130,8 +134,13 @@ LC& LC::operator=(const LC& data)
} }
} }
else { else {
delete[] m_mi;
uint8_t* mi = new uint8_t[P25_MI_LENGTH_BYTES];
::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES); ::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES);
m_mi = mi;
m_kId = 0x0000U; m_kId = 0x0000U;
if (m_encrypted) { if (m_encrypted) {
m_encryptOverride = true; m_encryptOverride = true;

@ -157,8 +157,12 @@ TSBK& TSBK::operator=(const TSBK& data)
m_siteData = data.m_siteData; m_siteData = data.m_siteData;
m_siteIdenEntry = data.m_siteIdenEntry; m_siteIdenEntry = data.m_siteIdenEntry;
m_siteCallsign = new uint8_t[P25_MOT_CALLSIGN_LENGTH_BYTES]; delete[] m_siteCallsign;
::memcpy(m_siteCallsign, data.m_siteCallsign, P25_MOT_CALLSIGN_LENGTH_BYTES);
uint8_t* callsign = new uint8_t[P25_MOT_CALLSIGN_LENGTH_BYTES];
::memcpy(callsign, data.m_siteCallsign, P25_MOT_CALLSIGN_LENGTH_BYTES);
m_siteCallsign = callsign;
} }
return *this; return *this;

Loading…
Cancel
Save

Powered by TurnKey Linux.