correct some debug message ordering and debug message typos; fix issue where P25 conventional data registration was failing;

3.0-rcon_maint
Bryan Biedenkapp 3 years ago
parent aa335ac86f
commit 16dc1ac374

@ -253,7 +253,7 @@ bool CRC::checkCCITT162(const uint8_t *in, uint32_t length)
#if DEBUG_CRC #if DEBUG_CRC
uint16_t inCrc = (in[length - 2U] << 8) | (in[length - 1U] << 0); uint16_t inCrc = (in[length - 2U] << 8) | (in[length - 1U] << 0);
LogDebug(LOG_HOST, "CRC::checkCCITT161(), crc = $%04X, in = $%04X, len = %u", crc16, inCrc, length); LogDebug(LOG_HOST, "CRC::checkCCITT162(), crc = $%04X, in = $%04X, len = %u", crc16, inCrc, length);
#endif #endif
return crc8[0U] == in[length - 1U] && crc8[1U] == in[length - 2U]; return crc8[0U] == in[length - 1U] && crc8[1U] == in[length - 2U];

@ -124,10 +124,6 @@ bool DataBlock::decode(const uint8_t* data, const DataHeader header)
::memcpy(m_data, buffer + 2U, count); // Payload Data ::memcpy(m_data, buffer + 2U, count); // Payload Data
} }
#if DEBUG_P25_PDU_DATA
Utils::dump(1U, "P25, DataBlock::decode(), Confirmed PDU Block Data", m_data, count);
#endif
// compute CRC-9 for the packet // compute CRC-9 for the packet
uint16_t calculated = edac::CRC::crc9(buffer, 144U); uint16_t calculated = edac::CRC::crc9(buffer, 144U);
if (((crc ^ calculated) != 0) && ((crc ^ calculated) != 0x1FFU)) { if (((crc ^ calculated) != 0) && ((crc ^ calculated) != 0x1FFU)) {
@ -136,6 +132,7 @@ bool DataBlock::decode(const uint8_t* data, const DataHeader header)
#if DEBUG_P25_PDU_DATA #if DEBUG_P25_PDU_DATA
LogDebug(LOG_P25, "P25_DUID_PDU, fmt = $%02X, crc = $%04X, calculated = $%04X", m_fmt, crc, calculated); LogDebug(LOG_P25, "P25_DUID_PDU, fmt = $%02X, crc = $%04X, calculated = $%04X", m_fmt, crc, calculated);
Utils::dump(1U, "P25, DataBlock::decode(), Confirmed PDU Block Data", m_data, count);
#endif #endif
} }
catch (...) { catch (...) {

@ -101,12 +101,12 @@ bool DataHeader::decode(const uint8_t* data)
} }
#if DEBUG_P25_PDU_DATA #if DEBUG_P25_PDU_DATA
Utils::dump(1U, "P25, DataHeader::decode(), PDU Header Data", data, P25_PDU_HEADER_LENGTH_BYTES); Utils::dump(1U, "P25, DataHeader::decode(), PDU Header Data", header, P25_PDU_HEADER_LENGTH_BYTES);
#endif #endif
m_ackNeeded = (header[0U] & 0x40U) == 0x40U; // Acknowledge Needed m_ackNeeded = (header[0U] & 0x40U) == 0x40U; // Acknowledge Needed
m_outbound = (header[0U] & 0x20U) == 0x20U; // Inbound/Outbound m_outbound = (header[0U] & 0x20U) == 0x20U; // Inbound/Outbound
m_fmt = header[0U] & 0x1F; // Packet Format m_fmt = header[0U] & 0x1FU; // Packet Format
m_sap = header[1U] & 0x3FU; // Service Access Point m_sap = header[1U] & 0x3FU; // Service Access Point
@ -193,7 +193,7 @@ void DataHeader::encode(uint8_t* data)
(m_fmt & 0x1FU); // Packet Format (m_fmt & 0x1FU); // Packet Format
header[1U] = m_sap & 0x3FU; // Service Access Point header[1U] = m_sap & 0x3FU; // Service Access Point
header[1U] |= 0xC0; header[1U] |= 0xC0U;
header[2U] = m_mfId; // Mfg Id. header[2U] = m_mfId; // Mfg Id.

@ -290,7 +290,7 @@ bool Data::process(uint8_t* data, uint32_t len)
LogMessage(LOG_RF, P25_PDU_STR ", PDU_REG_TYPE_REQ_CNCT (Registration Request Connect), llId = %u, ipAddr = %s", llId, __IP_FROM_ULONG(ipAddr).c_str()); LogMessage(LOG_RF, P25_PDU_STR ", PDU_REG_TYPE_REQ_CNCT (Registration Request Connect), llId = %u, ipAddr = %s", llId, __IP_FROM_ULONG(ipAddr).c_str());
} }
m_connQueueTable[llId] = ipAddr; m_connQueueTable[llId] = std::make_tuple(m_rfDataHeader.getMFId(), ipAddr);
m_connTimerTable[llId] = Timer(1000U, CONN_WAIT_TIMEOUT); m_connTimerTable[llId] = Timer(1000U, CONN_WAIT_TIMEOUT);
m_connTimerTable[llId].start(); m_connTimerTable[llId].start();
@ -569,11 +569,12 @@ void Data::clock(uint32_t ms)
// handle PDU connection registration // handle PDU connection registration
for (auto it = connToClear.begin(); it != connToClear.end(); ++it) { for (auto it = connToClear.begin(); it != connToClear.end(); ++it) {
uint32_t llId = *it; uint32_t llId = *it;
uint64_t ipAddr = m_connQueueTable[llId]; uint8_t mfId = std::get<0>(m_connQueueTable[llId]);
uint64_t ipAddr = std::get<1>(m_connQueueTable[llId]);
if (!acl::AccessControl::validateSrcId(llId)) { if (!acl::AccessControl::validateSrcId(llId)) {
LogWarning(LOG_RF, P25_PDU_STR ", PDU_REG_TYPE_RSP_DENY (Registration Response Deny), llId = %u, ipAddr = %s", llId, __IP_FROM_ULONG(ipAddr).c_str()); LogWarning(LOG_RF, P25_PDU_STR ", PDU_REG_TYPE_RSP_DENY (Registration Response Deny), llId = %u, ipAddr = %s", llId, __IP_FROM_ULONG(ipAddr).c_str());
writeRF_PDU_Reg_Response(PDU_REG_TYPE_RSP_DENY, llId, ipAddr); writeRF_PDU_Reg_Response(PDU_REG_TYPE_RSP_DENY, mfId, llId, ipAddr);
} }
else { else {
if (!hasLLIdFNEReg(llId)) { if (!hasLLIdFNEReg(llId)) {
@ -585,7 +586,7 @@ void Data::clock(uint32_t ms)
LogMessage(LOG_RF, P25_PDU_STR ", PDU_REG_TYPE_RSP_ACCPT (Registration Response Accept), llId = %u, ipAddr = %s", llId, __IP_FROM_ULONG(ipAddr).c_str()); LogMessage(LOG_RF, P25_PDU_STR ", PDU_REG_TYPE_RSP_ACCPT (Registration Response Accept), llId = %u, ipAddr = %s", llId, __IP_FROM_ULONG(ipAddr).c_str());
} }
writeRF_PDU_Reg_Response(PDU_REG_TYPE_RSP_ACCPT, llId, ipAddr); writeRF_PDU_Reg_Response(PDU_REG_TYPE_RSP_ACCPT, mfId, llId, ipAddr);
} }
m_connQueueTable.erase(llId); m_connQueueTable.erase(llId);
@ -833,9 +834,10 @@ void Data::writeRF_PDU_Buffered()
/// Helper to write a PDU registration response. /// Helper to write a PDU registration response.
/// </summary> /// </summary>
/// <param name="regType"></param> /// <param name="regType"></param>
/// <param name="mfId"></param>
/// <param name="llId"></param> /// <param name="llId"></param>
/// <param name="ipAddr"></param> /// <param name="ipAddr"></param>
void Data::writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr) void Data::writeRF_PDU_Reg_Response(uint8_t regType, uint8_t mfId, uint32_t llId, ulong64_t ipAddr)
{ {
if ((regType != PDU_REG_TYPE_RSP_ACCPT) && (regType != PDU_REG_TYPE_RSP_DENY)) if ((regType != PDU_REG_TYPE_RSP_ACCPT) && (regType != PDU_REG_TYPE_RSP_DENY))
return; return;
@ -850,11 +852,11 @@ void Data::writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ip
DataHeader rspHeader = DataHeader(); DataHeader rspHeader = DataHeader();
rspHeader.setFormat(PDU_FMT_CONFIRMED); rspHeader.setFormat(PDU_FMT_CONFIRMED);
rspHeader.setMFId(m_rfDataHeader.getMFId()); rspHeader.setMFId(mfId);
rspHeader.setAckNeeded(true); rspHeader.setAckNeeded(true);
rspHeader.setOutbound(true); rspHeader.setOutbound(true);
rspHeader.setSAP(PDU_SAP_REG); rspHeader.setSAP(PDU_SAP_REG);
rspHeader.setLLId(m_rfDataHeader.getLLId()); rspHeader.setLLId(llId);
rspHeader.setBlocksToFollow(1U); rspHeader.setBlocksToFollow(1U);
// Generate the PDU header and 1/2 rate Trellis // Generate the PDU header and 1/2 rate Trellis

@ -110,7 +110,7 @@ namespace p25
std::unordered_map<uint32_t, ulong64_t> m_fneRegTable; std::unordered_map<uint32_t, ulong64_t> m_fneRegTable;
std::unordered_map<uint32_t, ulong64_t> m_connQueueTable; std::unordered_map<uint32_t, std::tuple<uint8_t, ulong64_t>> m_connQueueTable;
std::unordered_map<uint32_t, Timer> m_connTimerTable; std::unordered_map<uint32_t, Timer> m_connTimerTable;
bool m_dumpPDUData; bool m_dumpPDUData;
@ -134,7 +134,7 @@ namespace p25
/// <summary>Helper to re-write a received P25 PDU packet.</summary> /// <summary>Helper to re-write a received P25 PDU packet.</summary>
void writeRF_PDU_Buffered(); void writeRF_PDU_Buffered();
/// <summary>Helper to write a PDU registration response.</summary> /// <summary>Helper to write a PDU registration response.</summary>
void writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr); void writeRF_PDU_Reg_Response(uint8_t regType, uint8_t mfId, uint32_t llId, ulong64_t ipAddr);
/// <summary>Helper to write a PDU acknowledge response.</summary> /// <summary>Helper to write a PDU acknowledge response.</summary>
void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls = false); void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls = false);
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.