mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 15:09:23 +08:00
Reject out of order packets.
This commit is contained in:
@@ -515,15 +515,18 @@ void CDStarControl::writeNetwork()
|
|||||||
|
|
||||||
unsigned char n = data[1U];
|
unsigned char n = data[1U];
|
||||||
|
|
||||||
insertSilence(data + 1U, n);
|
|
||||||
|
|
||||||
unsigned int errors = m_fec.regenerateDStar(data + 2U);
|
unsigned int errors = m_fec.regenerateDStar(data + 2U);
|
||||||
|
|
||||||
|
blankDTMF(data + 2U);
|
||||||
|
|
||||||
|
// Insert silence and reject if in the past
|
||||||
|
bool ret = insertSilence(data + 2U, n);
|
||||||
|
if (!ret)
|
||||||
|
return;
|
||||||
|
|
||||||
m_netErrs += errors;
|
m_netErrs += errors;
|
||||||
m_netBits += 48U;
|
m_netBits += 48U;
|
||||||
|
|
||||||
blankDTMF(data + 2U);
|
|
||||||
|
|
||||||
// Regenerate the sync
|
// Regenerate the sync
|
||||||
if (n == 0U)
|
if (n == 0U)
|
||||||
CSync::addDStarSync(data + 2U);
|
CSync::addDStarSync(data + 2U);
|
||||||
@@ -791,7 +794,7 @@ void CDStarControl::closeFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarControl::insertSilence(const unsigned char* data, unsigned char seqNo)
|
bool CDStarControl::insertSilence(const unsigned char* data, unsigned char seqNo)
|
||||||
{
|
{
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
|
||||||
@@ -799,8 +802,8 @@ void CDStarControl::insertSilence(const unsigned char* data, unsigned char seqNo
|
|||||||
unsigned int oldSeqNo = (m_netN + 1U) % 21U;
|
unsigned int oldSeqNo = (m_netN + 1U) % 21U;
|
||||||
if (oldSeqNo == seqNo) {
|
if (oldSeqNo == seqNo) {
|
||||||
// Just copy the data, nothing else to do here
|
// Just copy the data, nothing else to do here
|
||||||
::memcpy(m_lastFrame, data, DSTAR_FRAME_LENGTH_BYTES + 1U);
|
::memcpy(m_lastFrame, data + 1U, DSTAR_FRAME_LENGTH_BYTES + 1U);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogDebug("D-Star, current=%u last=%u", seqNo, m_netN);
|
LogDebug("D-Star, current=%u last=%u", seqNo, m_netN);
|
||||||
@@ -811,10 +814,14 @@ void CDStarControl::insertSilence(const unsigned char* data, unsigned char seqNo
|
|||||||
else
|
else
|
||||||
count = (21U + seqNo) - oldSeqNo;
|
count = (21U + seqNo) - oldSeqNo;
|
||||||
|
|
||||||
if (count < 10U)
|
if (count >= 10U)
|
||||||
insertSilence(count);
|
return false;
|
||||||
|
|
||||||
::memcpy(m_lastFrame, data, DSTAR_FRAME_LENGTH_BYTES + 1U);
|
insertSilence(count);
|
||||||
|
|
||||||
|
::memcpy(m_lastFrame, data + 1U, DSTAR_FRAME_LENGTH_BYTES + 1U);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarControl::insertSilence(unsigned int count)
|
void CDStarControl::insertSilence(unsigned int count)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ private:
|
|||||||
bool writeFile(const unsigned char* data, unsigned int length);
|
bool writeFile(const unsigned char* data, unsigned int length);
|
||||||
void closeFile();
|
void closeFile();
|
||||||
|
|
||||||
void insertSilence(const unsigned char* data, unsigned char seqNo);
|
bool insertSilence(const unsigned char* data, unsigned char seqNo);
|
||||||
void insertSilence(unsigned int count);
|
void insertSilence(unsigned int count);
|
||||||
|
|
||||||
void blankDTMF(unsigned char* data) const;
|
void blankDTMF(unsigned char* data) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user