Skip to content

Commit

Permalink
split dispatch functions into dispatch and dispatchToFNE; correct var…
Browse files Browse the repository at this point in the history
…iable shadowing in DMRPacketData::processFrame();
  • Loading branch information
gatekeep committed Jul 9, 2024
1 parent dc29208 commit 98f620e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 18 deletions.
43 changes: 26 additions & 17 deletions src/fne/network/callhandler/packetdata/DMRPacketData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool DMRPacketData::processFrame(const uint8_t* data, uint32_t len, uint32_t pee
m_status[peerId] = status;

LogMessage(LOG_NET, "DMR, Data Call Start, peer = %u, slot = %u, srcId = %u, dstId = %u, streamId = %u, external = %u", peerId, status->slotNo, status->srcId, status->dstId, streamId, external);
dispatch(peerId, dmrData, data, len, seqNo, pktSeq, streamId);
dispatchToFNE(peerId, dmrData, data, len, seqNo, pktSeq, streamId);

return true;
} else {
Expand All @@ -184,8 +184,8 @@ bool DMRPacketData::processFrame(const uint8_t* data, uint32_t len, uint32_t pee

bool ret = dataBlock.decode(frame, status->header);
if (ret) {
uint32_t len = dataBlock.getData(status->pduUserData + status->pduDataOffset);
status->pduDataOffset += len;
uint32_t blockLen = dataBlock.getData(status->pduUserData + status->pduDataOffset);
status->pduDataOffset += blockLen;

status->frames--;
if (status->frames == 0U)
Expand All @@ -200,22 +200,13 @@ bool DMRPacketData::processFrame(const uint8_t* data, uint32_t len, uint32_t pee
LogMessage(LOG_NET, DMR_DT_RATE_1_DATA ", ISP, block %u, peer = %u, dataType = $%02X, dpf = $%02X", status->dataBlockCnt, peerId, dataBlock.getDataType(), dataBlock.getFormat());
}

dispatch(peerId, dmrData, data, len, seqNo, pktSeq, streamId);
dispatchToFNE(peerId, dmrData, data, len, seqNo, pktSeq, streamId);
status->dataBlockCnt++;
}

// dispatch the PDU data
if (status->dataBlockCnt > 0U && status->frames == 0U) {
if (status->header.getBlocksToFollow() > 0U && status->frames == 0U) {
bool crcRet = edac::CRC::checkCRC32(status->pduUserData, status->pduDataOffset);
if (!crcRet) {
LogWarning(LOG_NET, P25_PDU_STR ", failed CRC-32 check, blocks %u, len %u", status->header.getBlocksToFollow(), status->pduDataOffset);
}

if (m_network->m_dumpDataPacket) {
Utils::dump(1U, "PDU Packet", status->pduUserData, status->pduDataOffset);
}
}
dispatch(peerId, dmrData, data, len);

uint64_t duration = hrc::diff(pktTime, status->callStartTime);
bool gi = status->header.getGI();
Expand Down Expand Up @@ -253,7 +244,25 @@ bool DMRPacketData::processFrame(const uint8_t* data, uint32_t len, uint32_t pee

/* Helper to dispatch PDU user data. */

void DMRPacketData::dispatch(uint32_t peerId, dmr::data::NetData& dmrData, const uint8_t* data, uint32_t len, uint8_t seqNo, uint16_t pktSeq, uint32_t streamId)
void DMRPacketData::dispatch(uint32_t peerId, dmr::data::NetData& dmrData, const uint8_t* data, uint32_t len)
{
RxStatus *status = m_status[peerId];

if (status->header.getBlocksToFollow() > 0U && status->frames == 0U) {
bool crcRet = edac::CRC::checkCRC32(status->pduUserData, status->pduDataOffset);
if (!crcRet) {
LogWarning(LOG_NET, P25_PDU_STR ", failed CRC-32 check, blocks %u, len %u", status->header.getBlocksToFollow(), status->pduDataOffset);
}

if (m_network->m_dumpDataPacket) {
Utils::dump(1U, "PDU Packet", status->pduUserData, status->pduDataOffset);
}
}
}

/* Helper to dispatch PDU user data back to the FNE network. */

void DMRPacketData::dispatchToFNE(uint32_t peerId, dmr::data::NetData& dmrData, const uint8_t* data, uint32_t len, uint8_t seqNo, uint16_t pktSeq, uint32_t streamId)
{
RxStatus* status = m_status[peerId];

Expand All @@ -267,7 +276,7 @@ void DMRPacketData::dispatch(uint32_t peerId, dmr::data::NetData& dmrData, const
for (auto peer : m_network->m_peers) {
if (peerId != peer.first) {
// is this peer ignored?
if (!m_tag->isPeerPermitted(peer.first, dmrData, status->streamId)) {
if (!m_tag->isPeerPermitted(peer.first, dmrData, streamId)) {
continue;
}

Expand Down Expand Up @@ -299,7 +308,7 @@ void DMRPacketData::dispatch(uint32_t peerId, dmr::data::NetData& dmrData, const
// is coming from a external peer
if (dstPeerId != peerId) {
// is this peer ignored?
if (!m_tag->isPeerPermitted(dstPeerId, dmrData, status->streamId, true)) {
if (!m_tag->isPeerPermitted(dstPeerId, dmrData, streamId, true)) {
continue;
}

Expand Down
10 changes: 9 additions & 1 deletion src/fne/network/callhandler/packetdata/DMRPacketData.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,19 @@ namespace network
* @param dmrData Instance of data::NetData DMR data container class.
* @param data Network data buffer.
* @param len Length of data.
*/
void dispatch(uint32_t peerId, dmr::data::NetData& dmrData, const uint8_t* data, uint32_t len);
/**
* @brief Helper to dispatch PDU user data back to the FNE network.
* @param peerId Peer ID.
* @param dmrData Instance of data::NetData DMR data container class.
* @param data Network data buffer.
* @param len Length of data.
* @param seqNo
* @param pktSeq RTP packet sequence.
* @param streamId Stream ID.
*/
void dispatch(uint32_t peerId, dmr::data::NetData& dmrData, const uint8_t* data, uint32_t len, uint8_t seqNo, uint16_t pktSeq, uint32_t streamId);
void dispatchToFNE(uint32_t peerId, dmr::data::NetData& dmrData, const uint8_t* data, uint32_t len, uint8_t seqNo, uint16_t pktSeq, uint32_t streamId);
};
} // namespace packetdata
} // namespace callhandler
Expand Down
9 changes: 9 additions & 0 deletions src/fne/network/callhandler/packetdata/P25PacketData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ void P25PacketData::dispatch(uint32_t peerId)
Utils::dump(1U, "PDU Packet", status->pduUserData, status->pduUserDataLength);
}

dispatchToFNE(peerId);
}

/* Helper to dispatch PDU user data back to the FNE network. */

void P25PacketData::dispatchToFNE(uint32_t peerId)
{
RxStatus* status = m_status[peerId];

uint32_t srcId = (status->extendedAddress) ? status->header.getSrcLLId() : status->header.getLLId();
uint32_t dstId = status->header.getLLId();

Expand Down
5 changes: 5 additions & 0 deletions src/fne/network/callhandler/packetdata/P25PacketData.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ namespace network
* @param peerId Peer ID.
*/
void dispatch(uint32_t peerId);
/**
* @brief Helper to dispatch PDU user data back to the FNE network.
* @param peerId Peer ID.
*/
void dispatchToFNE(uint32_t peerId);

/**
* @brief Helper to write user data as a P25 PDU packet.
Expand Down

0 comments on commit 98f620e

Please sign in to comment.