cleanup trailing whitespace;

pull/28/head
Bryan Biedenkapp 3 years ago
parent da863f6785
commit ca161aa402

@ -112,7 +112,7 @@ typedef unsigned long long ulong64_t;
#define __VER__ "D03.00.00 (" __GIT_VER__ ")"
#define __BUILD__ __DATE__ " " __TIME__
#define HOST_SW_API
#define HOST_SW_API
#if defined(_WIN32) || defined(_WIN64)
#define DEFAULT_CONF_FILE "config.yml"
@ -265,7 +265,7 @@ inline std::string strtoupper(const std::string value) {
buffer[0U + offset] = (val >> 24) & 0xFFU; \
buffer[1U + offset] = (val >> 16) & 0xFFU; \
buffer[2U + offset] = (val >> 8) & 0xFFU; \
buffer[3U + offset] = (val >> 0) & 0xFFU;
buffer[3U + offset] = (val >> 0) & 0xFFU;
#define __GET_UINT32(buffer, offset) \
(buffer[offset + 0U] << 24) | \
(buffer[offset + 1U] << 16) | \
@ -274,7 +274,7 @@ inline std::string strtoupper(const std::string value) {
#define __SET_UINT16(val, buffer, offset) \
buffer[0U + offset] = (val >> 16) & 0xFFU; \
buffer[1U + offset] = (val >> 8) & 0xFFU; \
buffer[2U + offset] = (val >> 0) & 0xFFU;
buffer[2U + offset] = (val >> 0) & 0xFFU;
#define __GET_UINT16(buffer, offset) \
(buffer[offset + 0U] << 16) | \
(buffer[offset + 1U] << 8) | \

@ -318,7 +318,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...)
else {
::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
}
}
}
else {
if (module != nullptr) {
::sprintf(buffer, "%c: (%s) ", LEVELS[level], module);
@ -340,7 +340,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...)
else {
::sprintf(buffer, "%c: %04d-%02d-%02d %02d:%02d:%02d.%03lu ", LEVELS[level], tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec / 1000U);
}
}
}
else {
if (module != nullptr) {
::sprintf(buffer, "%c: (%s) ", LEVELS[level], module);

@ -97,7 +97,7 @@ Control::Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint
acl::AccessControl::init(m_ridLookup, m_tidLookup);
Slot::init(this, authoritative, colorCode, SiteData(), embeddedLCOnly, dumpTAData, callHang, modem, network, duplex, m_ridLookup, m_tidLookup, m_idenTable, rssiMapper, jitter, verbose);
m_slot1 = new Slot(1U, timeout, tgHang, queueSize, dumpDataPacket, repeatDataPacket, dumpCSBKData, debug, verbose);
m_slot2 = new Slot(2U, timeout, tgHang, queueSize, dumpDataPacket, repeatDataPacket, dumpCSBKData, debug, verbose);
@ -185,7 +185,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::vector<ui
LogWarning(LOG_DMR, "Silence threshold set to zero, defaulting to %u", dmr::MAX_DMR_VOICE_ERRORS);
silenceThreshold = dmr::MAX_DMR_VOICE_ERRORS;
}
m_slot1->setSilenceThreshold(silenceThreshold);
m_slot2->setSilenceThreshold(silenceThreshold);

@ -48,7 +48,7 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Slot;
namespace packet { class HOST_SW_API ControlSignaling; }
@ -68,9 +68,9 @@ namespace dmr
~Control();
/// <summary>Helper to set DMR configuration options.</summary>
void setOptions(yaml::Node& conf, bool supervisor, const std::vector<uint32_t> voiceChNo, const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData,
void setOptions(yaml::Node& conf, bool supervisor, const std::vector<uint32_t> voiceChNo, const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData,
uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions);
/// <summary>Gets a flag indicating whether the DMR control channel is running.</summary>
bool getCCRunning() { return m_ccRunning; }
/// <summary>Sets a flag indicating whether the DMR control channel is running.</summary>

@ -132,7 +132,7 @@ namespace dmr
const uint8_t DMR_ALOHA_VER_151 = 0x00U;
const uint8_t DMR_CHNULL = 0x00U;
const uint16_t DMR_LOGICAL_CH_ABSOLUTE = 0xFFFU;
const uint8_t DEFAULT_NRAND_WAIT = 8U;

@ -121,7 +121,7 @@ namespace dmr
break;
case SITE_MODEL_HUGE:
{
value = (value << 2) + (m_netId & 0x03U);
value = (value << 2) + (m_netId & 0x03U);
value = (value << 10) + (m_siteId & 0x3FFU);
}
break;

@ -193,15 +193,15 @@ bool Slot::processFrame(uint8_t *data, uint32_t len)
if (data[0U] == modem::TAG_LOST && m_rfState == RS_RF_AUDIO) {
if (m_rssi != 0U) {
::ActivityLog("DMR", true, "Slot %u RF voice transmission lost, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm",
::ActivityLog("DMR", true, "Slot %u RF voice transmission lost, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm",
m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
}
else {
::ActivityLog("DMR", true, "Slot %u RF voice transmission lost, %.1f seconds, BER: %.1f%%",
::ActivityLog("DMR", true, "Slot %u RF voice transmission lost, %.1f seconds, BER: %.1f%%",
m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
}
LogMessage(LOG_RF, "DMR Slot %u, total frames: %d, total bits: %d, errors: %d, BER: %.4f%%",
LogMessage(LOG_RF, "DMR Slot %u, total frames: %d, total bits: %d, errors: %d, BER: %.4f%%",
m_slotNo, m_rfFrames, m_rfBits, m_rfErrs, float(m_rfErrs * 100U) / float(m_rfBits));
// release trunked grant (if necessary)
@ -440,7 +440,7 @@ void Slot::clock()
if ((m_dmr->m_tsccCnt % 2) == 0) {
setShortLC_Payload(m_siteData, m_dmr->m_tsccCnt);
}
}
}
else {
setShortLC_TSCC(m_siteData, m_dmr->m_tsccCnt);
}
@ -514,7 +514,7 @@ void Slot::clock()
if (m_netState == RS_NET_AUDIO) {
// We've received the voice header haven't we?
m_netFrames += 1U;
::ActivityLog("DMR", false, "Slot %u network watchdog has expired, %.1f seconds, %u%% packet loss, BER: %.1f%%",
::ActivityLog("DMR", false, "Slot %u network watchdog has expired, %.1f seconds, %u%% packet loss, BER: %.1f%%",
m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
writeEndNet(true);
}
@ -605,7 +605,7 @@ void Slot::setTSCC(bool enable, bool dedicated)
/// <param name="srcId"></param>
/// <param name="group"></param>
/// <param name="voice"></param>
void Slot::setTSCCActivated(uint32_t dstId, uint32_t srcId, bool group, bool voice)
void Slot::setTSCCActivated(uint32_t dstId, uint32_t srcId, bool group, bool voice)
{
m_tsccPayloadDstId = dstId;
m_tsccPayloadGroup = group;
@ -658,7 +658,7 @@ void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData s
m_colorCode = colorCode;
m_siteData = siteData;
m_embeddedLCOnly = embeddedLCOnly;
m_dumpTAData = dumpTAData;
@ -673,7 +673,7 @@ void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData s
m_affiliations = new dmr::lookups::DMRAffiliationLookup(verbose);
// set the grant release callback
m_affiliations->setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
m_affiliations->setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
Slot* tscc = m_dmr->getTSCCSlot();
if (tscc != nullptr) {
if (chNo == tscc->m_channelNo) {

@ -55,7 +55,7 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Control;
namespace packet { class HOST_SW_API Voice; }
namespace packet { class HOST_SW_API Data; }
@ -117,7 +117,7 @@ namespace dmr
network::BaseNetwork* network, bool duplex, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupIdLookup* tidLookup,
::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper, uint32_t jitter, bool verbose);
/// <summary>Sets local configured site data.</summary>
static void setSiteData(const std::vector<uint32_t> voiceChNo, const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData,
static void setSiteData(const std::vector<uint32_t> voiceChNo, const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData,
uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool requireReq);
/// <summary>Sets TSCC Aloha configuration.</summary>
static void setAlohaConfig(uint8_t nRandWait, uint8_t backOff);

@ -53,7 +53,7 @@ PrivacyLC::PrivacyLC(const uint8_t* data) :
assert(data != nullptr);
m_mi = new uint8_t[DMR_MI_LENGTH_BYTES];
m_group = (data[0U] & 0x20U) == 0x20U;
m_algId = data[0U] & 7; // Algorithm ID

@ -120,7 +120,7 @@ std::unique_ptr<CSBK> CSBKFactory::createCSBK(const uint8_t* data)
break;
}
return nullptr;
return nullptr;
}
// ---------------------------------------------------------------------------
@ -128,7 +128,7 @@ std::unique_ptr<CSBK> CSBKFactory::createCSBK(const uint8_t* data)
// ---------------------------------------------------------------------------
/// <summary>
///
///
/// </summary>
/// <param name="csbk"></param>
/// <param name="data"></param>

@ -64,7 +64,7 @@ bool CSBK_ACK_RSP::decode(const uint8_t* data)
return false;
ulong64_t csbkValue = CSBK::toValue(csbk);
m_GI = (((csbkValue >> 56) & 0xFFU) & 0x40U) == 0x40U; // Group/Individual Flag
m_reason = (uint8_t)((csbkValue >> 33) & 0xFFU); // Reason Code
m_dstId = (uint32_t)((csbkValue >> 24) & 0xFFFFU); // Target Radio Address

@ -65,7 +65,7 @@ bool CSBK_BSDWNACT::decode(const uint8_t* data)
return false;
ulong64_t csbkValue = CSBK::toValue(csbk);
m_bsId = (uint32_t)((csbkValue >> 24) & 0xFFFFFFU); // Base Station Address
m_srcId = (uint32_t)(csbkValue & 0xFFFFFFU); // Source Radio Address

@ -65,7 +65,7 @@ bool CSBK_CALL_ALRT::decode(const uint8_t* data)
return false;
ulong64_t csbkValue = CSBK::toValue(csbk);
m_GI = (((csbkValue >> 56) & 0xFFU) & 0x40U) == 0x40U; // Group/Individual Flag
m_dstId = (uint32_t)((csbkValue >> 24) & 0xFFFFFFU); // Target Radio Address
m_srcId = (uint32_t)(csbkValue & 0xFFFFFFU); // Source Radio Address

@ -85,7 +85,7 @@ void CSBK_EXT_FNCT::encode(uint8_t* data)
ulong64_t csbkValue = 0U;
csbkValue =
csbkValue =
(m_GI ? 0x40U : 0x00U) + // Group or Invididual
(m_dataContent ? 0x80U : 0x00U);
csbkValue = (csbkValue << 8) + m_extendedFunction; // Function

@ -64,7 +64,7 @@ bool CSBK_PRECCSBK::decode(const uint8_t* data)
return false;
ulong64_t csbkValue = CSBK::toValue(csbk);
m_GI = (((csbkValue >> 56) & 0xFFU) & 0x40U) == 0x40U; // Group/Individual Flag
m_dataContent = (((csbkValue >> 56) & 0xFFU) & 0x80U) == 0x80U; //
m_CBF = (uint8_t)((csbkValue >> 48) & 0xFFU); // Blocks to Follow

@ -54,7 +54,7 @@ namespace dmr
/// <summary>Sets the CSBK to encode.</summary>
void setCSBK(const uint8_t* csbk);
private:
uint8_t* m_csbk;
};

@ -54,7 +54,7 @@ namespace dmr
/// <summary>Flag indicating whether the grant is a late entry.</summary>
__PROPERTY(bool, lateEntry, LateEntry);
__COPY(CSBK_TV_GRANT);
__COPY(CSBK_TV_GRANT);
};
} // namespace csbk
} // namespace lc

@ -64,7 +64,7 @@ bool CSBK_UU_ANS_RSP::decode(const uint8_t* data)
return false;
ulong64_t csbkValue = CSBK::toValue(csbk);
m_dstId = (uint32_t)((csbkValue >> 24) & 0xFFFFFFU); // Target Radio Address
m_srcId = (uint32_t)(csbkValue & 0xFFFFFFU); // Source Radio Address

@ -64,7 +64,7 @@ bool CSBK_UU_V_REQ::decode(const uint8_t* data)
return false;
ulong64_t csbkValue = CSBK::toValue(csbk);
m_dstId = (uint32_t)((csbkValue >> 24) & 0xFFFFFFU); // Target Radio Address
m_srcId = (uint32_t)(csbkValue & 0xFFFFFFU); // Source Radio Address

@ -72,6 +72,6 @@ namespace dmr
uint8_t m_tsccSlot;
};
} // namespace lookups
} // namespace dmr
} // namespace dmr
#endif // __DMR_AFFILIATION_LOOKUP_H__

@ -51,7 +51,7 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Slot;
namespace packet

@ -374,7 +374,7 @@ void Data::processNetwork(const data::Data& dmrData)
m_slot->m_slotNo, float(m_slot->m_netFrames) / 16.667F, (m_slot->m_netLost * 100U) / m_slot->m_netFrames, float(m_slot->m_netErrs * 100U) / float(m_slot->m_netBits));
m_slot->m_dmr->tsccClearActivatedSlot(m_slot->m_slotNo);
m_slot->writeEndNet();
}
else if (dataType == DT_DATA_HEADER) {

@ -52,7 +52,7 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Voice; }
namespace packet { class HOST_SW_API ControlSignaling; }
class HOST_SW_API Slot;

@ -209,7 +209,7 @@ bool Voice::process(uint8_t* data, uint32_t len)
}
if (m_verbose) {
LogMessage(LOG_RF, DMR_DT_VOICE_LC_HEADER ", slot = %u, srcId = %u, dstId = %u, FLCO = $%02X, FID = $%02X, PF = %u", m_slot->m_slotNo,
LogMessage(LOG_RF, DMR_DT_VOICE_LC_HEADER ", slot = %u, srcId = %u, dstId = %u, FLCO = $%02X, FID = $%02X, PF = %u", m_slot->m_slotNo,
m_slot->m_rfLC->getSrcId(), m_slot->m_rfLC->getDstId(), m_slot->m_rfLC->getFLCO(), m_slot->m_rfLC->getFID(), m_slot->m_rfLC->getPF());
}
@ -248,7 +248,7 @@ bool Voice::process(uint8_t* data, uint32_t len)
m_slot->writeNetwork(data, DT_VOICE_PI_HEADER);
if (m_verbose) {
LogMessage(LOG_RF, DMR_DT_VOICE_PI_HEADER ", slot = %u, algId = %u, kId = %u, dstId = %u", m_slot->m_slotNo,
LogMessage(LOG_RF, DMR_DT_VOICE_PI_HEADER ", slot = %u, algId = %u, kId = %u, dstId = %u", m_slot->m_slotNo,
m_slot->m_rfPrivacyLC->getAlgId(), m_slot->m_rfPrivacyLC->getKId(), m_slot->m_rfPrivacyLC->getDstId());
}
@ -635,7 +635,7 @@ void Voice::processNetwork(const data::Data& dmrData)
uint8_t data[DMR_FRAME_LENGTH_BYTES + 2U];
dmrData.getData(data + 2U);
if (dataType == DT_VOICE_LC_HEADER) {
if (m_slot->m_netState == RS_NET_AUDIO)
return;

@ -48,7 +48,7 @@ namespace dmr
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Data; }
class HOST_SW_API Slot;

@ -102,8 +102,8 @@ uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const
if (READ_BIT(bytes, b2Pos))
b2 |= MASK;
if (READ_BIT(bytes, b3Pos))
b3 |= MASK;
}
b3 |= MASK;
}
MASK = 0x1000000U;
for (uint32_t i = 0U; i < 25U; i++, MASK >>= 1) {
@ -209,8 +209,8 @@ uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const
if (READ_BIT(bytes, b2Pos))
b2 |= MASK;
if (READ_BIT(bytes, b3Pos))
b3 |= MASK;
}
b3 |= MASK;
}
MASK = 0x1000000U;
for (uint32_t i = 0U; i < 25U; i++, MASK >>= 1) {

@ -451,7 +451,7 @@ namespace edac
0xECDB0FU, 0xB542DAU, 0x9E5131U, 0xC7ABA5U, 0x8C38FEU, 0x97010BU, 0xDED290U, 0xA4CC7DU, 0xAD3D2EU, 0xF6B6B3U,
0xF9A540U, 0x205ED9U, 0x634EB6U, 0x5A9567U, 0x11A6D8U, 0x0B3F09U };
const uint32_t AMBE_A_TABLE[] = {
const uint32_t AMBE_A_TABLE[] = {
0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U, 32U, 36U, 40U, 44U,
48U, 52U, 56U, 60U, 64U, 68U, 1U, 5U, 9U, 13U, 17U, 21U };
const uint32_t AMBE_B_TABLE[] = {

@ -96,9 +96,9 @@ using namespace edac;
const int length = 63;
const int k = 16;
const int g[] = {
const int g[] = {
1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1,
1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1
1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1
};
// ---------------------------------------------------------------------------

@ -474,7 +474,7 @@ uint16_t CRC::crc9(const uint8_t* in, uint32_t bitLength)
#if DEBUG_CRC_CHECK
LogDebug(LOG_HOST, "CRC::crc9(), crc = $%03X, bitlen = %u", crc, bitLength);
#endif
return crc;
}
@ -717,7 +717,7 @@ uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength)
// ---------------------------------------------------------------------------
/// <summary>
///
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
@ -740,7 +740,7 @@ uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength)
}
/// <summary>
///
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
@ -763,7 +763,7 @@ uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength)
}
/// <summary>
///
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>
@ -786,7 +786,7 @@ uint16_t CRC::createCRC15(const uint8_t* in, uint32_t bitLength)
}
/// <summary>
///
///
/// </summary>
/// <param name="in">Input byte array.</param>
/// <param name="bitLength">Length of byte array in bits.</param>

@ -37,7 +37,7 @@ namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements Golay (23,12,7) and Golay (24,12,8) forward error
// Implements Golay (23,12,7) and Golay (24,12,8) forward error
// correction.
// ---------------------------------------------------------------------------

@ -61,9 +61,9 @@ using namespace edac;
// Constants
// ---------------------------------------------------------------------------
/*
/*
* This array contains the bytes used to pad the buffer to the next 64-byte
* boundary.
* boundary.
*/
static const uint8_t fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };

@ -90,7 +90,7 @@ namespace edac
/// <summary></summary>
void init();
/// <summary>Process the remaining bytes in the internal buffer and the usual prolog according to
/// <summary>Process the remaining bytes in the internal buffer and the usual prolog according to
/// the standard and write the result to the buffer.</summary>
void conclude();
};

@ -29,7 +29,7 @@
*/
/*
* Ezpwd Reed-Solomon -- Reed-Solomon encoder / decoder library
*
*
* Copyright (c) 2014, Hard Consulting Corporation.
*
* Ezpwd Reed-Solomon is free software: you can redistribute it and/or modify it under the terms of
@ -38,43 +38,43 @@
* source tree. Ezpwd Reed-Solomon is also available under Commercial license. The
* c++/ezpwd/rs_base file is redistributed under the terms of the LGPL, regardless of the overall
* licensing terms.
*
*
* Ezpwd Reed-Solomon is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
*
* The core Reed-Solomon codec implementation in c++/ezpwd/rs_base is by Phil Karn, converted to C++
* by Perry Kundert (perry@hardconsulting.com), and may be used under the terms of the LGPL. Here
* is the terms from Phil's README file (see phil-karn/fec-3.0.1/README):
*
*
* COPYRIGHT
*
*
* This package is copyright 2006 by Phil Karn, KA9Q. It may be used
* under the terms of the GNU Lesser General Public License (LGPL). See
* the file "lesser.txt" in this package for license details.
*
*
* The c++/ezpwd/rs_base file is, therefore, redistributed under the terms of the LGPL, while the
* rest of Ezpwd Reed-Solomon is distributed under either the GPL or Commercial licenses.
* Therefore, even if you have obtained Ezpwd Reed-Solomon under a Commercial license, you must make
* available the source code of the c++/ezpwd/rs_base file with your product. One simple way to
* accomplish this is to include the following URL in your code or documentation:
*
*
* https://github.com/pjkundert/ezpwd-reed-solomon/blob/master/c++/ezpwd/rs_base
*
*
*
*
* The Linux 3.15.1 version of lib/reed_solomon was also consulted as a cross-reference, which (in
* turn) is basically verbatim copied from Phil Karn's LGPL implementation, to ensure that no new
* defects had been found and fixed; there were no meaningful changes made to Phil's implementation.
* I've personally been using Phil's implementation for years in a heavy industrial use, and it is
* rock-solid.
*
*
* However, both Phil's and the Linux kernel's (copy of Phil's) implementation will return a
* "corrected" decoding with impossible error positions, in some cases where the error load
* completely overwhelms the R-S encoding. These cases, when detected, are rejected in this
* implementation. This could be considered a defect in Phil's (and hence the Linux kernel's)
* implementations, which results in them accepting clearly incorrect R-S decoded values as valid
* (corrected) R-S codewords. We chose the report failure on these attempts.
*
*
*/
#if !defined(__RS_H__)
#define __RS_H__
@ -91,14 +91,14 @@
#include <type_traits>
#include <vector>
//
//
// Preprocessor defines available:
//
//
// EZPWD_NO_EXCEPTS -- define to use no exceptions; return -1, or abort on catastrophic failures
// EZPWD_NO_MOD_TAB -- define to force no "modnn" Galois modulo table acceleration
// EZPWD_ARRAY_SAFE -- define to force usage of bounds-checked arrays for most tabular data
// EZPWD_ARRAY_TEST -- define to force erroneous sizing of some arrays for non-production testing
//
//
#if defined(EZPWD_NO_EXCEPTS)
#include <cstdio>
@ -114,7 +114,7 @@
namespace edac
{
namespace rs
namespace rs
{
// ezpwd::log_<N,B> -- compute the log base B of N at compile-time
template <size_t N, size_t B = 2> struct log_{ enum { value = 1 + log_<N / B, B>::value }; };
@ -147,27 +147,27 @@ namespace edac
/// <summary></summary>
virtual std::ostream &output(std::ostream &lhs) const { return lhs << "RS(" << this->size() << "," << this->load() << ")"; }
//
//
// {en,de}code -- Compute/Correct errors/erasures in a Reed-Solomon encoded container
//
//
// The encoded parity symbols may be included in 'data' (len includes nroots() parity
// symbols), or may (optionally) supplied separately in (at least nroots()-sized)
// 'parity'.
//
// 'parity'.
//
// For decode, optionally specify some known erasure positions (up to nroots()). If
// non-empty 'erasures' is provided, it contains the positions of each erasure. If a
// non-zero pointer to a 'position' vector is provided, its capacity will be increased to
// be capable of storing up to 'nroots()' ints; the actual deduced error locations will be
// returned.
//
//
// RETURN VALUE
//
//
// Return -1 on error. The encode returns the number of parity symbols produced;
// decode returns the number of symbols corrected. Both errors and erasures are included,
// so long as they are actually different than the deduced value. In other words, if a
// symbol is marked as an erasure but it actually turns out to be correct, it's index will
// NOT be included in the returned count, nor the modified erasure vector!
//
//
int encode(std::string &data) const
{
@ -180,7 +180,7 @@ namespace edac
int encode(const std::string &data, std::string &parity) const
{
typedef uint8_t uT;
typedef std::pair<const uT*, const uT*> cuTpair;
typedef std::pair<const uT*, const uT*> cuTpair;
typedef std::pair<uT*, uT*> uTpair;
parity.resize(nroots());
return encode(cuTpair((const uT*)&data.front(), (const uT*)&data.front() + data.size()),
@ -195,10 +195,10 @@ namespace edac
return encode(uTpair((uT*)&data.front(), (uT*)&data.front() + data.size()));
}
template<typename T> int encode(const std::vector<T>&data, std::vector<T> &parity) const
template<typename T> int encode(const std::vector<T>&data, std::vector<T> &parity) const
{
typedef typename std::make_unsigned<T>::type uT;
typedef std::pair<const uT*, const uT*> cuTpair;
typedef std::pair<const uT*, const uT*> cuTpair;
typedef std::pair<uT*, uT*> uTpair;
parity.resize(nroots());
return encode(cuTpair((uT*)&data.front(), (uT*)&data.front() + data.size()),
@ -213,8 +213,8 @@ namespace edac
}
virtual int encode(const std::pair<uint8_t*, uint8_t*> &data) const = 0;
virtual int encode(const std::pair<const uint8_t*, const uint8_t*> &data,
virtual int encode(const std::pair<const uint8_t*, const uint8_t*> &data,
const std::pair<uint8_t*, uint8_t*> &parity) const = 0;
virtual int encode(const std::pair<uint16_t*, uint16_t*> &data) const = 0;
virtual int encode(const std::pair<const uint16_t*, const uint16_t*> &data,
@ -223,7 +223,7 @@ namespace edac
virtual int encode(const std::pair<const uint32_t*, const uint32_t*> &data,
const std::pair<uint32_t*, uint32_t*> &parity) const = 0;
int decode(std::string &data, const std::vector<int> &erasure = std::vector<int>(),
int decode(std::string &data, const std::vector<int> &erasure = std::vector<int>(),
std::vector<int>* position = 0) const
{
typedef uint8_t uT;
@ -231,16 +231,16 @@ namespace edac
return decode(uTpair((uT*)&data.front(), (uT*)&data.front() + data.size()), erasure, position);
}
int decode(std::string &data, std::string &parity, const std::vector<int> &erasure = std::vector<int>(),
int decode(std::string &data, std::string &parity, const std::vector<int> &erasure = std::vector<int>(),
std::vector<int>* position = 0) const
{
typedef uint8_t uT;
typedef std::pair<uT*, uT*> uTpair;
return decode(uTpair((uT*)&data.front(), (uT*)&data.front() + data.size()),
return decode(uTpair((uT*)&data.front(), (uT*)&data.front() + data.size()),
uTpair((uT*)&parity.front(), (uT*)&parity.front() + parity.size()), erasure, position);
}
template<typename T> int decode(std::vector<T> &data, const std::vector<int> &erasure = std::vector<int>(),
template<typename T> int decode(std::vector<T> &data, const std::vector<int> &erasure = std::vector<int>(),
std::vector<int>* position = 0) const
{
typedef typename std::make_unsigned<T>::type uT;
@ -248,7 +248,7 @@ namespace edac
return decode(uTpair((uT*)&data.front(), (uT*)&data.front() + data.size()), erasure, position);
}
template<typename T> int decode(std::vector<T> &data, std::vector<T> &parity,
template<typename T> int decode(std::vector<T> &data, std::vector<T> &parity,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const
{
typedef typename std::make_unsigned<T>::type uT;
@ -257,7 +257,7 @@ namespace edac
uTpair((uT*)&parity.front(), (uT*)&parity.front() + parity.size()), erasure, position);
}
template<typename T, size_t N> int decode(std::array<T,N> &data, int pad = 0,
template<typename T, size_t N> int decode(std::array<T,N> &data, int pad = 0,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const
{
typedef typename std::make_unsigned<T>::type uT;
@ -269,21 +269,21 @@ namespace edac
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const = 0;
virtual int decode(const std::pair<uint8_t*, uint8_t*> &data, const std::pair<uint8_t*, uint8_t*> &parity,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const = 0;
virtual int decode(const std::pair<uint16_t*, uint16_t*> &data,
virtual int decode(const std::pair<uint16_t*, uint16_t*> &data,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const = 0;
virtual int decode(const std::pair<uint16_t*, uint16_t*> &data, const std::pair<uint16_t*, uint16_t*> &parity,
virtual int decode(const std::pair<uint16_t*, uint16_t*> &data, const std::pair<uint16_t*, uint16_t*> &parity,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const = 0;
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const = 0;
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data, const std::pair<uint32_t*, uint32_t*> &parity,
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data, const std::pair<uint32_t*, uint32_t*> &parity,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position= 0 ) const = 0;
};
//
//
// std::ostream << edac::rs::reed_solomon<...>
//
//
// Output a R-S codec description in standard form eg. RS(255,253)
//
//
inline std::ostream &operator<<(std::ostream &lhs, const edac::rs::reed_solomon_base &rhs) { return rhs.output(lhs); }
// ---------------------------------------------------------------------------
@ -306,7 +306,7 @@ namespace edac
return sr;
}
};
// ---------------------------------------------------------------------------
// Class Declaration
// R-S tables common to all RS(NN,*) with same SYM, PRM and PLY.
@ -324,7 +324,7 @@ namespace edac
static const int SIZE = (1 << SYM) - 1; // maximum symbols in field
static const int NN = SIZE;
static const int A0 = SIZE;
// modulo table: 1/2 the symbol size squared, up to 4k
static const int MODS = SYM > 8 ? (1 << 12) : (1 << SYM << SYM / 2);
@ -351,7 +351,7 @@ namespace edac
// Generate Galois field lookup tables
index_of[0] = A0; // log(zero) = -inf
alpha_to[A0] = 0; // alpha**-inf = 0
PLY poly;
int sr = poly(0);
for (int i = 0; i < NN; i++) {
@ -380,7 +380,7 @@ namespace edac
/// <summary>Finalizes a instance of the reed_solomon_tabs class.</summary>
virtual ~reed_solomon_tabs() { /* stub */ }
//
//
// modnn -- modulo replacement for galois field arithmetics, optionally w/ table acceleration
//
// @x: the value to reduce (will never be -'ve)
@ -407,7 +407,7 @@ namespace edac
x -= NN;
x = (x >> MM) + (x & NN);
}
if ( MODS && x >= NN) {
x = mod_of[x - NN];
}
@ -415,7 +415,7 @@ namespace edac
}
};
// ---------------------------------------------------------------------------
// Class Declaration
// Reed-Solomon codec.
@ -436,7 +436,7 @@ namespace edac
// All reed_solomon<T, ...> instances with the same template type parameters share a common
// (static) set of alpha_to, index_of and genpoly tables. The first instance to be constructed
// initializes the tables.
//
//
// Each specialized type of reed_solomon implements a specific encode/decode method
// appropriate to its datum 'TYP'. When accessed via a generic reed_solomon_base pointer, only
// access via "safe" (size specifying) containers or iterators is available.
@ -480,7 +480,7 @@ namespace edac
#if DEBUG_RS
LogDebug(LOG_HOST, "reed_solomon::reed_solomon() RS(%d,%d): initialized for %d roots", SIZE, LOAD, NROOTS);
#endif
std::array<TYP, NROOTS + 1> tmppoly; // uninitialized
// Form RS code generator polynomial from its roots. Only lower-index entries are
@ -488,7 +488,7 @@ namespace edac
tmppoly[0] = 1;
for (int i = 0, root = FCR * PRM; i < NROOTS; i++, root += PRM) {
tmppoly[i + 1] = 1;
// Multiply tmppoly[] by @**(root + x)
for (int j = i; j > 0; j--) {
if (tmppoly[j] != 0) {
@ -497,7 +497,7 @@ namespace edac
tmppoly[j] = tmppoly[j - 1];
}
}
// tmppoly[0] can never be zero
tmppoly[0] = alpha_to[modnn(index_of[tmppoly[0]] + root)];
}
@ -524,18 +524,18 @@ namespace edac
using reed_solomon_base::encode;
virtual int encode(const std::pair<uint8_t*, uint8_t*> &data) const { return encode_mask(data.first, data.second - data.first - NROOTS, data.second - NROOTS); }
virtual int encode(const std::pair<const uint8_t*, const uint8_t*> &data,
virtual int encode(const std::pair<const uint8_t*, const uint8_t*> &data,
const std::pair<uint8_t*, uint8_t*> &parity) const
{
if (parity.second - parity.first != NROOTS) {
EZPWD_RAISE_OR_RETURN(std::runtime_error, "reed-solomon: parity length incompatible with number of roots", -1);
}
return encode_mask(data.first, data.second - data.first, parity.first);
}
virtual int encode(const std::pair<uint16_t*, uint16_t*> &data) const { return encode_mask(data.first, data.second - data.first - NROOTS, data.second - NROOTS); }
virtual int encode(const std::pair<const uint16_t*, const uint16_t*> &data,
virtual int encode(const std::pair<const uint16_t*, const uint16_t*> &data,
const std::pair<uint16_t*, uint16_t*> &parity) const
{
if (parity.second - parity.first != NROOTS) {
@ -546,7 +546,7 @@ namespace edac
}
virtual int encode(const std::pair<uint32_t*, uint32_t*> &data) const { return encode_mask(data.first, data.second - data.first - NROOTS, data.second - NROOTS); }
virtual int encode(const std::pair<const uint32_t*, const uint32_t*> &data,
virtual int encode(const std::pair<const uint32_t*, const uint32_t*> &data,
const std::pair<uint32_t*, uint32_t*> &parity) const
{
if (parity.second - parity.first != NROOTS) {
@ -574,7 +574,7 @@ namespace edac
if (SYMBOL > INPUT) {
EZPWD_RAISE_OR_RETURN(std::runtime_error, "reed-solomon: output data type too small to contain symbols", -1);
}
std::array<TYP, SIZE> tmp;
TYP msk = static_cast<TYP>(~0UL << SYMBOL);
for (int i = 0; i < len; ++i) {
@ -600,7 +600,7 @@ namespace edac
return NROOTS;
}
using reed_solomon_base::decode;
virtual int decode(const std::pair<uint8_t*, uint8_t*> &data,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const
@ -608,7 +608,7 @@ namespace edac
return decode_mask(data.first, data.second - data.first, (uint8_t*)0, erasure, position);
}
virtual int decode(const std::pair<uint8_t*, uint8_t*> &data, const std::pair<uint8_t*, uint8_t*> &parity,
virtual int decode(const std::pair<uint8_t*, uint8_t*> &data, const std::pair<uint8_t*, uint8_t*> &parity,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const
{
if (parity.second - parity.first != NROOTS) {
@ -618,7 +618,7 @@ namespace edac
return decode_mask(data.first, data.second - data.first, parity.first, erasure, position);
}
virtual int decode(const std::pair<uint16_t*, uint16_t*> &data,
virtual int decode(const std::pair<uint16_t*, uint16_t*> &data,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const
{
return decode_mask(data.first, data.second - data.first, (uint16_t*)0, erasure, position);
@ -634,13 +634,13 @@ namespace edac
return decode_mask(data.first, data.second - data.first, parity.first, erasure, position);
}
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data,
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position = 0) const
{
return decode_mask(data.first, data.second - data.first, (uint32_t*)0, erasure, position);
}
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data, const std::pair<uint32_t*, uint32_t*> &parity,
virtual int decode(const std::pair<uint32_t*, uint32_t*> &data, const std::pair<uint32_t*, uint32_t*> &parity,
const std::vector<int> &erasure = std::vector<int>(), std::vector<int>* position= 0 ) const
{
if (parity.second - parity.first != NROOTS) {
@ -650,14 +650,14 @@ namespace edac
return decode_mask(data.first, data.second - data.first, parity.first, erasure, position);
}
//
//
// decode_mask -- mask INP data into valid SYMBOL data
//
//
// Incoming data may be in a variety of sizes, and may contain information beyond the
// R-S symbol capacity. For example, we might use a 6-bit R-S symbol to correct the lower
// 6 bits of an 8-bit data character. This would allow us to correct common substitution
// errors (such as '2' for '3', 'R' for 'T', 'n' for 'm').
//
//
template<typename INP>
int decode_mask(INP *data, int len, INP *parity = 0, const std::vector<int> &erasure = std::vector<int>(),
@ -870,7 +870,7 @@ namespace edac
#if DEBUG_RS
// Test code that verifies the erasure locator polynomial just constructed
// Needed only for decoder debugging.
// find roots of the erasure location polynomial
for (int i = 1; i<= no_eras; i++) {
reg[i] = index_of[lambda[i]];
@ -955,7 +955,7 @@ namespace edac
if (2 * el <= r + no_eras - 1) {
el = r + no_eras - el;
// 2 lines below: B(x) <-- inv(discr_r) * lambda(x)
for (int i = 0; i <= NROOTS; i++) {
b[i] = ((lambda[i] == 0) ? A0 : modnn(index_of[lambda[i]] - discr_r + NN));
@ -1067,7 +1067,7 @@ namespace edac
// correction location outside of the data and parity we've been provided!
#if DEBUG_RS
std::stringstream ss;
ss << "reed_solomon::decode(): ERROR: RS(" << SIZE <<"," << LOAD << ") computed error location: " << loc[j] <<
ss << "reed_solomon::decode(): ERROR: RS(" << SIZE <<"," << LOAD << ") computed error location: " << loc[j] <<
" within " << pad << " pad symbols, not within " << LOAD - pad << " data or " << NROOTS << " parity";
LogDebug(LOG_HOST, "%s", ss.str().c_str());
#endif
@ -1113,7 +1113,7 @@ finish:
errors[2 * (eras_pos[i]) + 0] = 'e';
errors[2 * (eras_pos[i]) + 1] = 'e';
}
std::stringstream ss;
ss << "reed_solomon::decode(): e)rase, E)rror; count = " << count << ": " << std::endl << errors;
LogDebug(LOG_HOST, "%s", ss.str().c_str());
@ -1129,12 +1129,12 @@ finish:
}
};
//
//
// Define the static reed_solomon...<...> members; allowed in header for template types.
//
//
// The reed_solomon_tags<...>::iprim < 0 is used to indicate to the first instance that the
// static tables require initialization.
//
//
template<typename TYP, int SYM, int PRM, class PLY> int reed_solomon_tabs<TYP, SYM, PRM, PLY>::iprim = -1;
template<typename TYP, int SYM, int PRM, class PLY> std::array<TYP, reed_solomon_tabs<TYP, SYM, PRM, PLY>::NN + 1> reed_solomon_tabs<TYP, SYM, PRM, PLY>::alpha_to;
template<typename TYP, int SYM, int PRM, class PLY> std::array<TYP, reed_solomon_tabs<TYP, SYM, PRM, PLY>::NN + 1> reed_solomon_tabs<TYP, SYM, PRM, PLY>::index_of;
@ -1142,5 +1142,5 @@ finish:
template<typename TYP, int SYM, int RTS, int FCR, int PRM, class PLY> std::array<TYP, reed_solomon< TYP, SYM, RTS, FCR, PRM, PLY>::NROOTS + 1> reed_solomon<TYP, SYM, RTS, FCR, PRM, PLY>::genpoly;
} // namespace rs
} // namespace edac
#endif // __RS_H__

@ -570,7 +570,7 @@ int Host::run()
}
nxdn = std::unique_ptr<nxdn::Control>(new nxdn::Control(m_authoritative, m_nxdnRAN, callHang, m_nxdnQueueSizeBytes, m_timeout, m_rfTalkgroupHang,
m_modem, m_network, m_duplex, m_ridLookup, m_tidLookup, m_idenTable, rssi,
m_modem, m_network, m_duplex, m_ridLookup, m_tidLookup, m_idenTable, rssi,
nxdnDumpRcchData, nxdnDebug, nxdnVerbose));
nxdn->setOptions(m_conf, m_supervisor, m_cwCallsign, m_voiceChNo, m_voiceChData, m_siteId, m_sysId, m_channelId, m_channelNo, true);
@ -974,7 +974,7 @@ int Host::run()
// if the state is P25; write P25 data
if (m_state == STATE_P25) {
m_modem->writeP25Data(data, len);
INTERRUPT_DMR_BEACON;
// if there is a NXDN CC running; halt the CC
@ -983,7 +983,7 @@ int Host::run()
INTERRUPT_NXDN_CONTROL;
}
}
m_modeTimer.start();
}
}
@ -994,7 +994,7 @@ int Host::run()
}
if (nextLen == 0U) {
// if we have no P25 data, and we're either idle or P25 state, check if we
// if we have no P25 data, and we're either idle or P25 state, check if we
// need to be starting the CC running flag or writing end of voice call data
if (m_state == STATE_IDLE || m_state == STATE_P25) {
if (p25->getCCHalted()) {
@ -1052,9 +1052,9 @@ int Host::run()
// if the state is NXDN; write NXDN data
if (m_state == STATE_NXDN) {
m_modem->writeNXDNData(data, len);
INTERRUPT_DMR_BEACON;
// if there is a P25 CC running; halt the CC
if (p25 != nullptr) {
if (p25->getCCRunning() && !p25->getCCHalted()) {
@ -1096,9 +1096,9 @@ int Host::run()
if (ret) {
m_modeTimer.setTimeout(m_rfModeHang);
setState(STATE_DMR);
START_DMR_DUPLEX_IDLE(true);
INTERRUPT_DMR_BEACON;
INTERRUPT_P25_CONTROL;
INTERRUPT_NXDN_CONTROL;
@ -1597,7 +1597,7 @@ int Host::run()
m_modem->clearDMRData1();
m_modem->clearDMRData2();
}
dmr->setCCRunning(false);
dmr->setCCHalted(true);
@ -1712,7 +1712,7 @@ bool Host::readParams()
if (!systemConf["modeHang"].isNone()) {
m_rfModeHang = m_netModeHang = systemConf["modeHang"].as<uint32_t>();
}
m_activeTickDelay = (uint8_t)systemConf["activeTickDelay"].as<uint32_t>(5U);
if (m_activeTickDelay < 1U)
m_activeTickDelay = 1U;
@ -1957,7 +1957,7 @@ bool Host::createModem()
}
if (dmrQueueSize > 100U) {
LogWarning(LOG_HOST, "DMR queue size must be less then 100 frames, defaulting to 100 frames!");
dmrQueueSize = 100U;
dmrQueueSize = 100U;
}
if (dmrQueueSize > 60U) {
LogWarning(LOG_HOST, "DMR queue size is excessive, >60 frames!");
@ -1975,7 +1975,7 @@ bool Host::createModem()
}
if (p25QueueSize > 50U) {
LogWarning(LOG_HOST, "P25 queue size must be less then 50 frames, defaulting to 50 frames!");
p25QueueSize = 50U;
p25QueueSize = 50U;
}
if (p25QueueSize > 30U) {
LogWarning(LOG_HOST, "P25 queue size is excessive, >30 frames!");
@ -1993,7 +1993,7 @@ bool Host::createModem()
}
if (nxdnQueueSize > 50U) {
LogWarning(LOG_HOST, "NXDN queue size must be less then 50 frames, defaulting to 50 frames!");
nxdnQueueSize = 50U;
nxdnQueueSize = 50U;
}
m_nxdnQueueSizeBytes = nxdnQueueSize * nxdn::NXDN_FRAME_LENGTH_BYTES;
@ -2007,7 +2007,7 @@ bool Host::createModem()
#else
m_useDFSI = false;
#endif // defined(ENABLE_P25) && defined(ENABLE_DFSI)
yaml::Node uartProtocol = modemProtocol["uart"];
std::string uartPort = uartProtocol["port"].as<std::string>();
uint32_t uartSpeed = uartProtocol["speed"].as<uint32_t>(115200);
@ -2209,14 +2209,14 @@ bool Host::createModem()
LogInfo(" Debug: yes");
}
m_modem = new Modem(modemPort, m_duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, p25CorrCount,
m_modem = new Modem(modemPort, m_duplex, rxInvert, txInvert, pttInvert, dcBlocker, cosLockout, fdmaPreamble, dmrRxDelay, p25CorrCount,
m_dmrQueueSizeBytes, m_p25QueueSizeBytes, m_nxdnQueueSizeBytes, disableOFlowReset, ignoreModemConfigArea, dumpModemStatus, trace, debug);
if (!m_modemRemote) {
m_modem->setModeParams(m_dmrEnabled, m_p25Enabled, m_nxdnEnabled);
m_modem->setLevels(rxLevel, cwIdTXLevel, dmrTXLevel, p25TXLevel, nxdnTXLevel);
m_modem->setSymbolAdjust(dmrSymLevel3Adj, dmrSymLevel1Adj, p25SymLevel3Adj, p25SymLevel1Adj, nxdnSymLevel3Adj, nxdnSymLevel1Adj);
m_modem->setDCOffsetParams(txDCOffset, rxDCOffset);
m_modem->setRFParams(m_rxFrequency, m_txFrequency, rxTuning, txTuning, rfPower, dmrDiscBWAdj, p25DiscBWAdj, nxdnDiscBWAdj, dmrPostBWAdj,
m_modem->setRFParams(m_rxFrequency, m_txFrequency, rxTuning, txTuning, rfPower, dmrDiscBWAdj, p25DiscBWAdj, nxdnDiscBWAdj, dmrPostBWAdj,
p25PostBWAdj, nxdnPostBWAdj, adfGainMode, afcEnable, afcKI, afcKP, afcRange);
m_modem->setSoftPot(rxCoarse, rxFine, txCoarse, txFine, rssiCoarse, rssiFine);
m_modem->setDMRColorCode(m_dmrColorCode);
@ -2512,7 +2512,7 @@ void Host::setState(uint8_t state)
m_modem->writeDMRStart(false);
m_dmrTXTimer.stop();
}
m_state = HOST_STATE_ERROR;
m_modeTimer.stop();
m_cwIdTimer.stop();
@ -2527,7 +2527,7 @@ void Host::setState(uint8_t state)
m_modem->writeDMRStart(false);
m_dmrTXTimer.stop();
}
m_modem->setState(STATE_IDLE);
m_modem->clearDMRData1();

@ -82,7 +82,7 @@ private:
modem::port::IModemPort* m_modemRemotePort;
uint8_t m_state;
Timer m_modeTimer;
Timer m_dmrTXTimer;
Timer m_cwIdTimer;
@ -114,7 +114,7 @@ private:
uint32_t m_txFrequency;
uint8_t m_channelId;
uint32_t m_channelNo;
std::vector<uint32_t> m_voiceChNo;
std::unordered_map<uint32_t, lookups::VoiceChData> m_voiceChData;
@ -161,7 +161,7 @@ private:
bool createModem();
/// <summary>Initializes network connectivity.</summary>
bool createNetwork();
/// <summary>Modem port open callback.</summary>
bool rmtPortModemOpen(modem::Modem* modem);
/// <summary>Modem port close callback.</summary>

@ -2011,7 +2011,7 @@ void HostCal::processDMR1KBER(const uint8_t* buffer, uint8_t seq)
uint8_t dmrSeq = seq & 0x0FU;
if (dmrSeq > 5U)
dmrSeq = 5U;
errs = 0U;
for (uint32_t i = 0U; i < 33U; i++)
errs += countErrs(buffer[i], VOICE_1K[i]);
@ -2068,7 +2068,7 @@ void HostCal::processP25BER(const uint8_t* buffer)
else {
LogMessage(LOG_CAL, P25_HDU_STR ", dstId = %u, algo = %X, kid = %X", lc.getDstId(), lc.getAlgId(), lc.getKId());
}
m_berBits = 0U;
m_berErrs = 0U;
m_berFrames = 0U;
@ -2098,7 +2098,7 @@ void HostCal::processP25BER(const uint8_t* buffer)
m_berUndecodableLC++;
}
else {
LogMessage(LOG_CAL, P25_LDU1_STR " LC, mfId = $%02X, lco = $%02X, emerg = %u, encrypt = %u, prio = %u, group = %u, srcId = %u, dstId = %u",
LogMessage(LOG_CAL, P25_LDU1_STR " LC, mfId = $%02X, lco = $%02X, emerg = %u, encrypt = %u, prio = %u, group = %u, srcId = %u, dstId = %u",
lc.getMFId(), lc.getLCO(), lc.getEmergency(), lc.getEncrypted(), lc.getPriority(), lc.getGroup(), lc.getSrcId(), lc.getDstId());
}
@ -2150,7 +2150,7 @@ void HostCal::processP25BER(const uint8_t* buffer)
m_berUndecodableLC++;
}
else {
LogMessage(LOG_CAL, P25_LDU2_STR " LC, mfId = $%02X, algo = %X, kid = %X",
LogMessage(LOG_CAL, P25_LDU2_STR " LC, mfId = $%02X, algo = %X, kid = %X",
lc.getMFId(), lc.getAlgId(), lc.getKId());
}
@ -2216,7 +2216,7 @@ void HostCal::processP25BER(const uint8_t* buffer)
}
else {
LogMessage(LOG_CAL, P25_PDU_STR ", ack = %u, outbound = %u, fmt = $%02X, mfId = $%02X, sap = $%02X, fullMessage = %u, blocksToFollow = %u, padCount = %u, n = %u, seqNo = %u, lastFragment = %u, hdrOffset = %u",
dataHeader.getAckNeeded(), dataHeader.getOutbound(), dataHeader.getFormat(), dataHeader.getMFId(), dataHeader.getSAP(), dataHeader.getFullMessage(),
dataHeader.getAckNeeded(), dataHeader.getOutbound(), dataHeader.getFormat(), dataHeader.getMFId(), dataHeader.getSAP(), dataHeader.getFullMessage(),
dataHeader.getBlocksToFollow(), dataHeader.getPadCount(), dataHeader.getNs(), dataHeader.getFSN(), dataHeader.getLastFragment(),
dataHeader.getHeaderOffset());
}
@ -2477,7 +2477,7 @@ bool HostCal::writeConfig(uint8_t modeOverride)
m_conf["system"]["modem"]["dmrRxDelay"] = __INT_STR(m_modem->m_dmrRxDelay);
buffer[10U] = m_modem->m_dmrRxDelay;
uint32_t nac = 0xF7EU;
buffer[11U] = (nac >> 4) & 0xFFU;
buffer[12U] = (nac << 4) & 0xF0U;
@ -2821,7 +2821,7 @@ bool HostCal::eraseFlash()
m_updateConfigFromModem = false;
LogMessage(LOG_CAL, " - Erased configuration area on modem");
m_modem->clock(0U);
return true;
}
@ -2868,7 +2868,7 @@ bool HostCal::writeFlash()
buffer[16U] = (uint8_t)(m_modem->m_txDCOffset + 128);
buffer[17U] = (uint8_t)(m_modem->m_rxDCOffset + 128);
// RF parameters
buffer[20U] = (uint8_t)(m_modem->m_dmrDiscBWAdj + 128);
buffer[21U] = (uint8_t)(m_modem->m_p25DiscBWAdj + 128);
@ -3025,7 +3025,7 @@ void HostCal::printStatus()
if (!m_isHotspot) {
LogMessage(LOG_CAL, " - DMR Symbol +/- 3 Level Adj.: %d, DMR Symbol +/- 1 Level Adj.: %d, P25 Symbol +/- 3 Level Adj.: %d, P25 Symbol +/- 1 Level Adj.: %d",
m_modem->m_dmrSymLevel3Adj, m_modem->m_dmrSymLevel1Adj, m_modem->m_p25SymLevel3Adj, m_modem->m_p25SymLevel1Adj);
// are we on a protocol version 3 firmware?
if (m_modem->getVersion() >= 3U) {
LogMessage(LOG_CAL, " - NXDN Symbol +/- 3 Level Adj.: %d, NXDN Symbol +/- 1 Level Adj.: %d",

@ -508,7 +508,7 @@ int HostSetup::run()
printStatus();
}
break;
case 'a':
{
rfssConfig = m_conf["system"]["config"];

@ -56,7 +56,7 @@ AffiliationLookup::AffiliationLookup(const char* name, bool verbose) :
m_verbose(verbose)
{
m_rfChTable.clear();
m_unitRegTable.clear();
m_grpAffTable.clear();

@ -149,7 +149,7 @@ namespace lookups
virtual bool isGranted(uint32_t dstId) const;
/// <summary>Helper to get the channel granted for the given destination ID.</summary>
virtual uint32_t getGrantedCh(uint32_t dstId);
/// <summary>Helper to get the source ID granted for the given destination ID.</summary>
/// <summary>Helper to get the source ID granted for the given destination ID.</summary>
virtual uint32_t getGrantedSrcId(uint32_t srcId);
/// <summary>Helper to set RF channel data.</summary>

@ -101,7 +101,7 @@ namespace lookups
// ---------------------------------------------------------------------------
// Class Declaration
// Implements a threading lookup table class that contains the bandplan
// Implements a threading lookup table class that contains the bandplan
// identity table.
// ---------------------------------------------------------------------------

@ -53,7 +53,7 @@ using namespace lookups;
/// <param name="filename">Full-path to the radio ID table file.</param>
/// <param name="reloadTime">Interval of time to reload the radio ID table.</param>
/// <param name="ridAcl">Flag indicating whether radio ID access control is enabled.</param>
RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl) : LookupTable(filename, reloadTime),
RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl) : LookupTable(filename, reloadTime),
m_acl(ridAcl)
{
/* stub */

@ -2189,7 +2189,7 @@ void Modem::processFlashConfig(const uint8_t *buffer)
int rxDCOffset = int(buffer[17U]) - 128;
FLASH_VALUE_CHECK(m_rxDCOffset, rxDCOffset, 0, "rxDCOffset");
// RF parameters
int8_t dmrDiscBWAdj = int8_t(buffer[20U]) - 128;
FLASH_VALUE_CHECK(m_dmrDiscBWAdj, dmrDiscBWAdj, 0, "dmrDiscBWAdj");
@ -2270,7 +2270,7 @@ void Modem::printDebug(const uint8_t* buffer, uint16_t len)
Utils::dump(1U, "Modem Debug Dump", data, len);
return;
}
}
else {
if (m_rspDoubleLength) {
LogError(LOG_MODEM, "Invalid debug data received from the modem, len = %u", len);
@ -2308,7 +2308,7 @@ void Modem::printDebug(const uint8_t* buffer, uint16_t len)
::memset(data, 0x00U, 255U);
::memcpy(data, buffer, len);
Utils::dump(1U, "Modem Debug Dump", data, len);
Utils::dump(1U, "Modem Debug Dump", data, len);
}
}

@ -256,7 +256,7 @@ namespace modem
/// <remarks>If the response handler returns true, processing will stop, otherwise it will continue.</remarks>
void setResponseHandler(std::function<MODEM_RESP_HANDLER> handler);
/// <summary>Sets a custom modem open port handler.</summary>
/// <remarks>If the open handler is set, it is the responsibility of the handler to complete air interface
/// <remarks>If the open handler is set, it is the responsibility of the handler to complete air interface
/// initialization (i.e. write configuration, etc).</remarks>
void setOpenHandler(std::function<MODEM_OC_PORT_HANDLER> handler);
/// <summary>Sets a custom modem close port handler.</summary>
@ -288,10 +288,10 @@ namespace modem
bool hasP25Space(uint32_t length) const;
/// <summary>Helper to test if the NXDN ring buffer has free space.</summary>
bool hasNXDNSpace() const;
/// <summary>Helper to test if the modem is a hotspot.</summary>
bool isHotspot() const;
/// <summary>Helper to test if the modem is in P25 DFSI data mode.</summary>
bool isP25DFSI() const;
@ -401,7 +401,7 @@ namespace modem
int m_txTuning; // hotspot modem - Tx Frequency Offset
uint8_t m_rfPower; // hotspot modem - RF power
int8_t m_dmrDiscBWAdj; // hotspot modem - DMR discriminator BW adjustment
int8_t m_dmrDiscBWAdj; // hotspot modem - DMR discriminator BW adjustment
int8_t m_p25DiscBWAdj; // hotspot modem - P25 discriminator BW adjustment
int8_t m_nxdnDiscBWAdj; // hotspot modem - NXDN discriminator BW adjustment
int8_t m_dmrPostBWAdj; // hotspot modem - DMR post demod BW adjustment

@ -47,7 +47,7 @@ namespace modem
// PTY serial port.
// ---------------------------------------------------------------------------
class HOST_SW_API PseudoPTYPort : public UARTPort
class HOST_SW_API PseudoPTYPort : public UARTPort
{
public:
/// <summary>Initializes a new instance of the PseudoPTYPort class.</summary>

@ -258,7 +258,7 @@ void UARTPort::close()
/// <param name="device">Serial port device.</param>
/// <param name="speed">Serial port speed.</param>
/// <param name="assertRTS"></param>
UARTPort::UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS) :
UARTPort::UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS) :
m_isOpen(false),
m_device(device),
m_speed(speed),
@ -500,7 +500,7 @@ int UARTPort::readNonblock(uint8_t* buffer, uint32_t length)
///
/// </summary>
/// <returns></returns>
bool UARTPort::canWrite()
bool UARTPort::canWrite()
{
#if defined(__APPLE__)
fd_set wset;

@ -209,7 +209,7 @@ void Network::clock(uint32_t ms)
}
if (::memcmp(m_buffer, TAG_DMR_DATA, 4U) == 0) {
#if defined(ENABLE_DMR)
#if defined(ENABLE_DMR)
if (m_enabled && m_dmrEnabled) {
if (m_debug)
Utils::dump(1U, "Network Received, DMR", m_buffer, length);
@ -285,7 +285,7 @@ void Network::clock(uint32_t ms)
for (uint8_t i = 0; i < len; i++) {
uint32_t id = (m_buffer[11U + j] << 16) | (m_buffer[12U + j] << 8) | (m_buffer[13U + j] << 0);
uint8_t slot = (m_buffer[14U + j]);
lookups::TalkgroupId tid = m_tidLookup->find(id);
if (tid.tgEnabled() == false && tid.tgDefault() == true) {
LogMessage(LOG_NET, "Activated TG %u TS %u in TGID table", id, slot);

@ -57,7 +57,7 @@ namespace network
/// <summary>Sets the instances of the Radio ID and Talkgroup ID lookup tables.</summary>
void setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupIdLookup* tidLookup);
/// <summary>Sets metadata configuration settings from the modem.</summary>
void setMetadata(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz,
void setMetadata(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz,
uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location);
/// <summary>Sets REST API configuration settings from the modem.</summary>
void setRESTAPIData(const std::string& password, uint16_t port);

@ -75,11 +75,11 @@ std::string string_format(const std::string& format, FormatArgs ... args)
std::unique_ptr<char[]> buf(new char[ size ]);
std::snprintf(buf.get(), size, format.c_str(), args ...);
return std::string(buf.get(), buf.get() + size - 1);
return std::string(buf.get(), buf.get() + size - 1);
}
/// <summary>
///
///
/// </summary>
/// <param name="obj"></param>
void setResponseDefaultStatus(json::object& obj)
@ -89,7 +89,7 @@ void setResponseDefaultStatus(json::object& obj)
}
/// <summary>
///
///
/// </summary>
/// <param name="reply"></param>
/// <param name="message"></param>
@ -267,7 +267,7 @@ void RESTAPI::entry()
void RESTAPI::initializeEndpoints()
{
m_dispatcher.match(PUT_AUTHENTICATE).put(REST_API_BIND(RESTAPI::restAPI_PutAuth, this));
m_dispatcher.match(GET_VERSION).get(REST_API_BIND(RESTAPI::restAPI_GetVersion, this));
m_dispatcher.match(GET_STATUS).get(REST_API_BIND(RESTAPI::restAPI_GetStatus, this));
m_dispatcher.match(GET_VOICE_CH).get(REST_API_BIND(RESTAPI::restAPI_GetVoiceCh, this));
@ -426,7 +426,7 @@ void RESTAPI::restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, co
}
if (m_debug) {
Utils::dump("Password Hash", passwordHash, 32U);
Utils::dump("Password Hash", passwordHash, 32U);
}
// compare hashes
@ -532,7 +532,7 @@ void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply,
modemInfo["dmrSymLevel1Adj"].set<int>(m_host->m_modem->m_dmrSymLevel1Adj);
modemInfo["p25SymLevel3Adj"].set<int>(m_host->m_modem->m_p25SymLevel3Adj);
modemInfo["p25SymLevel1Adj"].set<int>(m_host->m_modem->m_p25SymLevel1Adj);
// are we on a protocol version 3 firmware?
if (m_host->m_modem->getVersion() >= 3U) {
modemInfo["nxdnSymLevel3Adj"].set<int>(m_host->m_modem->m_nxdnSymLevel3Adj);
@ -577,7 +577,7 @@ void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply,
modemInfo["fdmaPreambles"].set<uint8_t>(m_host->m_modem->m_fdmaPreamble);
modemInfo["dmrRxDelay"].set<uint8_t>(m_host->m_modem->m_dmrRxDelay);
modemInfo["p25CorrCount"].set<uint8_t>(m_host->m_modem->m_p25CorrCount);
modemInfo["rxFrequency"].set<uint32_t>(m_host->m_modem->m_rxFrequency);
modemInfo["txFrequency"].set<uint32_t>(m_host->m_modem->m_txFrequency);
modemInfo["rxTuning"].set<int>(m_host->m_modem->m_rxTuning);
@ -606,7 +606,7 @@ void RESTAPI::restAPI_GetVoiceCh(const HTTPPayload& request, HTTPPayload& reply,
json::object response = json::object();
setResponseDefaultStatus(response);
json::array channels = json::array();
if (m_host->m_voiceChData.size() > 0) {
for (auto entry : m_host->m_voiceChData) {
@ -1172,7 +1172,7 @@ void RESTAPI::restAPI_GetRIDWhitelist(const HTTPPayload& request, HTTPPayload& r
errorPayload(reply, "OK", HTTPPayload::OK);
uint32_t srcId = (uint32_t)::strtoul(match.str(1).c_str(), NULL, 10);
if (srcId != 0U) {
m_ridLookup->toggleEntry(srcId, true);
}
@ -1200,7 +1200,7 @@ void RESTAPI::restAPI_GetRIDBlacklist(const HTTPPayload& request, HTTPPayload& r
errorPayload(reply, "OK", HTTPPayload::OK);
uint32_t srcId = (uint32_t)::strtoul(match.str(1).c_str(), NULL, 10);
if (srcId != 0U) {
m_ridLookup->toggleEntry(srcId, false);
}
@ -1268,7 +1268,7 @@ void RESTAPI::restAPI_GetDMRDebug(const HTTPPayload& request, HTTPPayload& reply
response["debug"].set<bool>(debug);
response["verbose"].set<bool>(verbose);
reply.payload(response);
return;
}
@ -1276,7 +1276,7 @@ void RESTAPI::restAPI_GetDMRDebug(const HTTPPayload& request, HTTPPayload& reply
if (match.size() == 3) {
uint8_t debug = (uint8_t)::strtoul(match.str(1).c_str(), NULL, 10);
uint8_t verbose = (uint8_t)::strtoul(match.str(2).c_str(), NULL, 10);
m_dmr->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false);
m_dmr->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false);
}
}
}
@ -1310,7 +1310,7 @@ void RESTAPI::restAPI_GetDMRDumpCSBK(const HTTPPayload& request, HTTPPayload& re
bool csbkDump = m_dmr->getCSBKVerbose();
response["verbose"].set<bool>(csbkDump);
reply.payload(response);
return;
}
@ -1435,7 +1435,7 @@ void RESTAPI::restAPI_GetDMRCCEnable(const HTTPPayload& request, HTTPPayload& re
}
else {
errorPayload(reply, "DMR control data is not enabled!");
}
}
}
else {
errorPayload(reply, "DMR mode is not enabled", HTTPPayload::SERVICE_UNAVAILABLE);
@ -1619,7 +1619,7 @@ void RESTAPI::restAPI_GetP25Debug(const HTTPPayload& request, HTTPPayload& reply
response["debug"].set<bool>(debug);
response["verbose"].set<bool>(verbose);
reply.payload(response);
return;
}
@ -1627,7 +1627,7 @@ void RESTAPI::restAPI_GetP25Debug(const HTTPPayload& request, HTTPPayload& reply
if (match.size() == 3) {
uint8_t debug = (uint8_t)::strtoul(match.str(1).c_str(), NULL, 10);
uint8_t verbose = (uint8_t)::strtoul(match.str(2).c_str(), NULL, 10);
m_p25->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false);
m_p25->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false);
}
}
}
@ -1661,7 +1661,7 @@ void RESTAPI::restAPI_GetP25DumpTSBK(const HTTPPayload& request, HTTPPayload& re
bool tsbkDump = m_p25->trunk()->getTSBKVerbose();
response["verbose"].set<bool>(tsbkDump);
reply.payload(response);
return;
}
@ -1726,7 +1726,7 @@ void RESTAPI::restAPI_PutP25RID(const HTTPPayload& request, HTTPPayload& reply,
return;
}
}
errorPayload(reply, "OK", HTTPPayload::OK);
if (::strtolower(command) == RID_CMD_P25_SET_MFID) {
@ -1810,13 +1810,13 @@ void RESTAPI::restAPI_GetP25CCEnable(const HTTPPayload& request, HTTPPayload& re
m_host->m_p25CtrlChannel = !m_host->m_p25CtrlChannel;
m_host->m_p25CtrlBroadcast = true;
g_fireP25Control = true;
m_p25->setCCHalted(false);
m_p25->setCCHalted(false);
errorPayload(reply, string_format("P25 CC is %s", m_host->m_p25CtrlChannel ? "enabled" : "disabled"), HTTPPayload::OK);
}
else {
errorPayload(reply, "P25 control data is not enabled!");
}
}
}
else {
errorPayload(reply, "P25 mode is not enabled", HTTPPayload::SERVICE_UNAVAILABLE);
@ -1857,7 +1857,7 @@ void RESTAPI::restAPI_GetP25CCBroadcast(const HTTPPayload& request, HTTPPayload&
}
else {
errorPayload(reply, "P25 control data is not enabled!");
}
}
}
else {
errorPayload(reply, "P25 mode is not enabled", HTTPPayload::SERVICE_UNAVAILABLE);
@ -1919,7 +1919,7 @@ void RESTAPI::restAPI_PutP25RawTSBK(const HTTPPayload& request, HTTPPayload& rep
}
if (m_debug) {
Utils::dump("Raw TSBK", tsbk, p25::P25_TSBK_LENGTH_BYTES);
Utils::dump("Raw TSBK", tsbk, p25::P25_TSBK_LENGTH_BYTES);
}
m_p25->trunk()->writeRF_TSDU_Raw(tsbk);
@ -1987,7 +1987,7 @@ void RESTAPI::restAPI_GetNXDNDebug(const HTTPPayload& request, HTTPPayload& repl
response["debug"].set<bool>(debug);
response["verbose"].set<bool>(verbose);
reply.payload(response);
return;
}
@ -1995,7 +1995,7 @@ void RESTAPI::restAPI_GetNXDNDebug(const HTTPPayload& request, HTTPPayload& repl
if (match.size() == 3) {
uint8_t debug = (uint8_t)::strtoul(match.str(1).c_str(), NULL, 10);
uint8_t verbose = (uint8_t)::strtoul(match.str(2).c_str(), NULL, 10);
m_nxdn->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false);
m_nxdn->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false);
}
}
}
@ -2029,7 +2029,7 @@ void RESTAPI::restAPI_GetNXDNDumpRCCH(const HTTPPayload& request, HTTPPayload& r
bool rcchDump = m_nxdn->getRCCHVerbose();
response["verbose"].set<bool>(rcchDump);
reply.payload(response);
return;
}
@ -2083,7 +2083,7 @@ void RESTAPI::restAPI_GetNXDNCCEnable(const HTTPPayload& request, HTTPPayload& r
}
else {
errorPayload(reply, "NXDN control data is not enabled!");
}
}
}
else {
errorPayload(reply, "NXDN mode is not enabled", HTTPPayload::SERVICE_UNAVAILABLE);

@ -73,7 +73,7 @@
#define GET_DMR_DEBUG_BASE "/dmr/debug/"
#define GET_DMR_DEBUG GET_DMR_DEBUG_BASE"(\\d+)/(\\d+)"
#define GET_DMR_DUMP_CSBK_BASE "/dmr/dump-csbk/"
#define GET_DMR_DUMP_CSBK GET_DMR_DUMP_CSBK_BASE"(\\d+)"
#define GET_DMR_DUMP_CSBK GET_DMR_DUMP_CSBK_BASE"(\\d+)"
#define PUT_DMR_RID "/dmr/rid"
#define GET_DMR_CC_DEDICATED "/dmr/cc-enable"
#define GET_DMR_CC_BCAST "/dmr/cc-broadcast"

@ -331,7 +331,7 @@ void UDPSocket::close(const uint32_t index)
}
/// <summary>
///
///
/// </summary>
void UDPSocket::startup()
{
@ -345,7 +345,7 @@ void UDPSocket::startup()
}
/// <summary>
///
///
/// </summary>
void UDPSocket::shutdown()
{

@ -118,7 +118,7 @@ namespace network
uint32_t m_af[UDP_SOCKET_MAX];
int m_fd[UDP_SOCKET_MAX];
uint32_t m_counter;
};
} // namespace network

@ -456,10 +456,10 @@ namespace json
GET(int,
(type_ == number_type && (const_cast<value *>(this)->type_ = int32_type, (const_cast<value *>(this)->u_.int32_ = u_.number_)),
u_.int32_))
GET(uint32_t,
GET(uint32_t,
(type_ == number_type && (const_cast<value *>(this)->type_ = uint32_type, (const_cast<value *>(this)->u_.uint32_ = u_.number_)),
u_.uint32_))
GET(uint16_t,
GET(uint16_t,
(type_ == number_type && (const_cast<value *>(this)->type_ = uint16_type, (const_cast<value *>(this)->u_.uint16_ = u_.number_)),
u_.uint16_))
GET(uint8_t,
@ -744,7 +744,7 @@ namespace json
case string_type:
serialize_str(*u_.string_, oi);
break;
case array_type:
case array_type:
{
*oi++ = '[';
if (indent != -1) {
@ -773,13 +773,13 @@ namespace json
*oi++ = ']';
break;
}
case object_type:
case object_type:
{
*oi++ = '{';
if (indent != -1) {
++indent;
}
for (object::const_iterator i = u_.object_->begin(); i != u_.object_->end(); ++i) {
if (i != u_.object_->begin()) {
*oi++ = ',';
@ -1021,7 +1021,7 @@ namespace json
if (!ctx.parse_array_start()) {
return false;
}
size_t idx = 0;
if (in.expect(']')) {
return ctx.parse_array_stop(idx);

@ -29,35 +29,35 @@
#include "Defines.h"
#include "network/rest/http/HTTPPayload.h"
#include "Log.h"
#include <functional>
#include <map>
#include <string>
#include <regex>
#include <memory>
namespace network
namespace network
{
namespace rest
namespace rest
{
// ---------------------------------------------------------------------------
// Structure Declaration
//
//
// ---------------------------------------------------------------------------
struct RequestMatch : std::smatch
struct RequestMatch : std::smatch
{
/// <summary>Initializes a new instance of the RequestMatch structure.</summary>
RequestMatch(const std::smatch& m, const std::string& c) : std::smatch(m), content(c) { /* stub */ }
std::string content;
};
// ---------------------------------------------------------------------------
// Structure Declaration
//
//
// ---------------------------------------------------------------------------
template<typename Request, typename Reply>
struct RequestMatcher {
typedef std::function<void(const Request&, Reply&, const RequestMatch&)> RequestHandlerType;
@ -103,7 +103,7 @@ namespace network
handler(request, reply, match);
}
}
private:
std::string m_expression;
bool m_isRegEx;
@ -127,7 +127,7 @@ namespace network
RequestDispatcher(const std::string& basePath, bool debug) : m_basePath(basePath), m_debug(debug) { /* stub */ }
/// <summary></summary>
MatcherType& match(const std::string& expression, bool regex = false)
MatcherType& match(const std::string& expression, bool regex = false)
{
MatcherTypePtr& p = m_matchers[expression];
if (!p) {
@ -146,7 +146,7 @@ namespace network
}
/// <summary></summary>
void handleRequest(const Request& request, Reply& reply)
void handleRequest(const Request& request, Reply& reply)
{
for (const auto& matcher : m_matchers) {
std::smatch what;
@ -175,7 +175,7 @@ namespace network
::LogError(LOG_REST, "unknown endpoint, uri = %s", request.uri.c_str());
reply = http::HTTPPayload::statusPayload(http::HTTPPayload::BAD_REQUEST, "application/json");
}
private:
typedef std::shared_ptr<MatcherType> MatcherTypePtr;
@ -201,7 +201,7 @@ namespace network
BasicRequestDispatcher(RequestHandlerType handler) : m_handler(handler) { /* stub */ }
/// <summary></summary>
void handleRequest(const Request& request, Reply& reply)
void handleRequest(const Request& request, Reply& reply)
{
if (m_handler) {
m_handler(request, reply);
@ -224,7 +224,7 @@ namespace network
DebugRequestDispatcher() { /* stub */ }
/// <summary></summary>
void handleRequest(const Request& request, Reply& reply)
void handleRequest(const Request& request, Reply& reply)
{
for (auto header : request.headers.headers())
::LogDebug(LOG_REST, "DebugRequestDispatcher::handleRequest() header = %s, value = %s", header.name.c_str(), header.value.c_str());
@ -233,8 +233,8 @@ namespace network
}
};
typedef RequestDispatcher<http::HTTPPayload, http::HTTPPayload> DefaultRequestDispatcher;
typedef RequestDispatcher<http::HTTPPayload, http::HTTPPayload> DefaultRequestDispatcher;
} // namespace rest
} // namespace network
#endif // __REST__DISPATCHER_H__
#endif // __REST__DISPATCHER_H__

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -37,7 +37,7 @@
#if !defined(__REST_HTTP__CLIENT_CONNECTION_H__)
#define __REST_HTTP__CLIENT_CONNECTION_H__
#include "Defines.h"
#include "Defines.h"
#include "network/rest/http/HTTPLexer.h"
#include "network/rest/http/HTTPPayload.h"
#include "Utils.h"
@ -47,18 +47,18 @@
#include <utility>
#include <iterator>
#include <asio.hpp>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class represents a single connection from a client.
// ---------------------------------------------------------------------------
template <typename RequestHandlerType>
class ClientConnection
{
@ -73,29 +73,29 @@ namespace network
}
/// <summary>Initializes a copy instance of the ClientConnection class.</summary>
ClientConnection(const ClientConnection&) = delete;
/// <summary></summary>
ClientConnection& operator=(const ClientConnection&) = delete;
/// <summary>Start the first asynchronous operation for the connection.</summary>
void start() { read(); }
/// <summary>Stop all asynchronous operations associated with the connection.</summary>
void stop()
void stop()
{
try
{
if (m_socket.is_open()) {
m_socket.close();
m_socket.close();
}
}
catch(const std::exception&) { /* ignore */ }
}
/// <summary>Perform an synchronous write operation.</summary>
void send(HTTPPayload request)
void send(HTTPPayload request)
{
request.attachHostHeader(m_socket.remote_endpoint());
write(request);
write(request);
}
private:
/// <summary>Perform an asynchronous read operation.</summary>
@ -166,5 +166,5 @@ namespace network
} // namespace http
} // namespace rest
} // namespace network
#endif // __REST_HTTP__CLIENT_CONNECTION_H__

@ -9,9 +9,9 @@
/*
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -46,11 +46,11 @@
#include <memory>
#include <mutex>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
@ -66,22 +66,22 @@ namespace network
m_address(address),
m_port(port),
m_connection(nullptr),
m_ioContext(),
m_socket(m_ioContext),
m_requestHandler()
{
/* stub */
m_ioContext(),
m_socket(m_ioContext),
m_requestHandler()
{
/* stub */
}
/// <summary>Initializes a copy instance of the HTTPClient class.</summary>
HTTPClient(const HTTPClient&) = delete;
/// <summary>Finalizes a instance of the HTTPClient class.</summary>
~HTTPClient()
~HTTPClient()
{
if (m_connection != nullptr) {
close();
}
}
/// <summary></summary>
HTTPClient& operator=(const HTTPClient&) = delete;
@ -150,7 +150,7 @@ namespace network
// the entry() call will block until all asynchronous operations
// have finished
m_ioContext.run();
if (m_connection != nullptr) {
m_connection->stop();
}
@ -175,7 +175,7 @@ namespace network
asio::io_context m_ioContext;
asio::ip::tcp::socket m_socket;
RequestHandlerType m_requestHandler;
std::mutex m_lock;
@ -183,5 +183,5 @@ namespace network
} // namespace http
} // namespace rest
} // namespace network
#endif // __REST_HTTP__HTTP_CLIENT_H__

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -43,11 +43,11 @@
#include <string>
#include <vector>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
@ -58,7 +58,7 @@ namespace network
// ---------------------------------------------------------------------------
// Structure Declaration
//
//
// ---------------------------------------------------------------------------
struct HTTPHeaders
@ -81,7 +81,7 @@ namespace network
/// <summary>Clears the list of HTTP headers.</summary>
void clearHeaders() { m_headers = std::vector<Header>(); }
/// <summary>Helper to add a HTTP header.</summary>
void add(const std::string& name, const std::string& value)
void add(const std::string& name, const std::string& value)
{
//::LogDebug(LOG_REST, "HTTPHeaders::add(), header = %s, value = %s", name.c_str(), value.c_str());
for (auto& header : m_headers) {
@ -91,12 +91,12 @@ namespace network
}
}
m_headers.push_back(Header(name, value));
m_headers.push_back(Header(name, value));
//for (auto header : m_headers)
// ::LogDebug(LOG_REST, "HTTPHeaders::add() m_headers.header = %s, m_headers.value = %s", header.name.c_str(), header.value.c_str());
}
/// <summary>Helper to add a HTTP header.</summary>
void remove(const std::string headerName)
void remove(const std::string headerName)
{
auto header = std::find_if(m_headers.begin(), m_headers.end(), [&](const Header& h) {
return ::strtolower(h.name) == ::strtolower(headerName);

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -51,7 +51,7 @@ using namespace network::rest::http;
/// Initializes a new instance of the HTTPLexer class.
/// </summary>
/// <param name="clientLexer"></param>
HTTPLexer::HTTPLexer(bool clientLexer) :
HTTPLexer::HTTPLexer(bool clientLexer) :
m_headers(),
m_clientLexer(clientLexer),
m_state(METHOD_START)
@ -395,7 +395,7 @@ HTTPLexer::ResultType HTTPLexer::consume(HTTPPayload& req, char input)
} else {
return BAD;
}
default:
return BAD;
}

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -42,11 +42,11 @@
#include <tuple>
#include <vector>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
@ -54,7 +54,7 @@ namespace network
// ---------------------------------------------------------------------------
struct HTTPPayload;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements the lexer for incoming payloads.

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -404,7 +404,7 @@ HTTPPayload HTTPPayload::statusPayload(HTTPPayload::StatusType status, const std
rep.content = stock_replies::to_string(status, contentType);
rep.ensureDefaultHeaders(contentType);
}
return rep;
}

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -37,7 +37,7 @@
#if !defined(__REST_HTTP__HTTP_REPLY_H__)
#define __REST_HTTP__HTTP_REPLY_H__
#include "Defines.h"
#include "Defines.h"
#include "network/json/json.h"
#include "network/rest/http/HTTPHeaders.h"
@ -46,11 +46,11 @@
#include <asio.hpp>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
@ -65,7 +65,7 @@ namespace network
// ---------------------------------------------------------------------------
// Structure Declaration
// This struct implements a model of a payload to be sent to a
// This struct implements a model of a payload to be sent to a
// HTTP client/server.
// ---------------------------------------------------------------------------

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -71,7 +71,7 @@ void HTTPRequestHandler::handleRequest(const HTTPPayload& request, HTTPPayload&
}
// request path must be absolute and not contain "..".
if (requestPath.empty() || requestPath[0] != '/' ||
if (requestPath.empty() || requestPath[0] != '/' ||
requestPath.find("..") != std::string::npos) {
reply = HTTPPayload::statusPayload(HTTPPayload::BAD_REQUEST);
return;
@ -100,7 +100,7 @@ void HTTPRequestHandler::handleRequest(const HTTPPayload& request, HTTPPayload&
// fill out the reply to be sent to the client
reply.status = HTTPPayload::OK;
char buf[512];
while (is.read(buf, sizeof(buf)).gcount() > 0)
reply.content.append(buf, is.gcount());
@ -144,6 +144,6 @@ bool HTTPRequestHandler::urlDecode(const std::string& in, std::string& out)
out += in[i];
}
}
return true;
}

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -41,11 +41,11 @@
#include <string>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
@ -53,7 +53,7 @@ namespace network
// ---------------------------------------------------------------------------
struct HTTPPayload;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements the common handler for all incoming requests.
@ -68,7 +68,7 @@ namespace network
HTTPRequestHandler(const HTTPRequestHandler&) = delete;
/// <summary></summary>
HTTPRequestHandler(HTTPRequestHandler&&) = default;
/// <summary></summary>
HTTPRequestHandler& operator=(const HTTPRequestHandler&) = delete;
/// <summary></summary>

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -49,12 +49,12 @@
#include <signal.h>
#include <utility>
#include <memory>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
@ -67,10 +67,10 @@ namespace network
public:
/// <summary>Initializes a new instance of the HTTPServer class.</summary>
explicit HTTPServer(const std::string& address, uint16_t port) :
m_ioService(),
m_acceptor(m_ioService),
m_ioService(),
m_acceptor(m_ioService),
m_connectionManager(),
m_socket(m_ioService),
m_socket(m_ioService),
m_requestHandler()
{
// open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR)
@ -82,12 +82,12 @@ namespace network
m_acceptor.set_option(asio::socket_base::keep_alive(true));
m_acceptor.bind(endpoint);
m_acceptor.listen();
accept();
}
/// <summary>Initializes a copy instance of the HTTPServer class.</summary>
HTTPServer(const HTTPServer&) = delete;
/// <summary></summary>
HTTPServer& operator=(const HTTPServer&) = delete;
@ -117,7 +117,7 @@ namespace network
m_acceptor.close();
m_connectionManager.stopAll();
}
private:
/// <summary>Perform an asynchronous accept operation.</summary>
void accept()
@ -128,29 +128,29 @@ namespace network
if (!m_acceptor.is_open()) {
return;
}
if (!ec) {
m_connectionManager.start(std::make_shared<ConnectionType>(std::move(m_socket), m_connectionManager, m_requestHandler));
}
accept();
});
}
typedef ConnectionImpl<RequestHandlerType> ConnectionType;
typedef std::shared_ptr<ConnectionType> ConnectionTypePtr;
asio::io_service m_ioService;
asio::ip::tcp::acceptor m_acceptor;
ServerConnectionManager<ConnectionTypePtr> m_connectionManager;
asio::ip::tcp::socket m_socket;
RequestHandlerType m_requestHandler;
};
} // namespace http
} // namespace rest
} // namespace network
#endif // __REST_HTTP__HTTP_SERVER_H__

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -37,7 +37,7 @@
#if !defined(__REST_HTTP__SERVER_CONNECTION_H__)
#define __REST_HTTP__SERVER_CONNECTION_H__
#include "Defines.h"
#include "Defines.h"
#include "network/rest/http/HTTPLexer.h"
#include "network/rest/http/HTTPPayload.h"
#include "Utils.h"
@ -47,12 +47,12 @@
#include <utility>
#include <iterator>
#include <asio.hpp>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
// Class Prototypes
@ -64,7 +64,7 @@ namespace network
// Class Declaration
// This class represents a single connection from a client.
// ---------------------------------------------------------------------------
template <typename RequestHandlerType>
class ServerConnection : public std::enable_shared_from_this<ServerConnection<RequestHandlerType>>
{
@ -73,7 +73,7 @@ namespace network
typedef ServerConnectionManager<selfTypePtr> ConnectionManagerType;
public:
/// <summary>Initializes a new instance of the ServerConnection class.</summary>
explicit ServerConnection(asio::ip::tcp::socket socket, ConnectionManagerType& manager, RequestHandlerType& handler,
explicit ServerConnection(asio::ip::tcp::socket socket, ConnectionManagerType& manager, RequestHandlerType& handler,
bool persistent = false) :
m_socket(std::move(socket)),
m_connectionManager(manager),
@ -85,19 +85,19 @@ namespace network
}
/// <summary>Initializes a copy instance of the ServerConnection class.</summary>
ServerConnection(const ServerConnection&) = delete;
/// <summary></summary>
ServerConnection& operator=(const ServerConnection&) = delete;
/// <summary>Start the first asynchronous operation for the connection.</summary>
void start() { read(); }
/// <summary>Stop all asynchronous operations associated with the connection.</summary>
void stop()
void stop()
{
try
{
if (m_socket.is_open()) {
m_socket.close();
m_socket.close();
}
}
catch(const std::exception&) { /* ignore */ }
@ -143,7 +143,7 @@ namespace network
}
});
}
/// <summary>Perform an asynchronous write operation.</summary>
void write()
{
@ -169,7 +169,7 @@ namespace network
asio::error_code ignored_ec;
m_socket.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec);
}
if (ec != asio::error::operation_aborted) {
m_connectionManager.stop(this->shared_from_this());
}
@ -193,5 +193,5 @@ namespace network
} // namespace http
} // namespace rest
} // namespace network
#endif // __REST_HTTP__SERVER_CONNECTION_H__

@ -14,9 +14,9 @@
* Copyright (c) 2003-2013 Christopher M. Kohlhoff
* Copyright (C) 2023 by Bryan Biedenkapp N2PLL
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the Software) to use, reproduce, display, distribute, execute,
* and transmit the Software, and to prepare derivative works of the Software, and
* to permit third-parties to whom the Software is furnished to do so, all subject
* to the following:
@ -41,21 +41,21 @@
#include <set>
#include <mutex>
namespace network
namespace network
{
namespace rest
namespace rest
{
namespace http
namespace http
{
// ---------------------------------------------------------------------------
// Class Declaration
// Manages open connections so that they may be cleanly stopped when the server
// needs to shut down.
// ---------------------------------------------------------------------------
template<typename ConnectionPtr>
template<typename ConnectionPtr>
class ServerConnectionManager
{
public:
@ -66,7 +66,7 @@ namespace network
/// <summary></summary>
ServerConnectionManager& operator=(const ServerConnectionManager&) = delete;
/// <summary>Add the specified connection to the manager and start it.</summary>
void start(ConnectionPtr c)
{
@ -76,7 +76,7 @@ namespace network
}
c->start();
}
/// <summary>Stop the specified connection.</summary>
void stop(ConnectionPtr c)
{
@ -86,7 +86,7 @@ namespace network
}
c->stop();
}
/// <summary>Stop all connections.</summary>
void stopAll()
{
@ -96,7 +96,7 @@ namespace network
std::lock_guard<std::mutex> guard(m_lock);
m_connections.clear();
}
private:
std::set<ConnectionPtr> m_connections;
std::mutex m_lock;
@ -106,4 +106,3 @@ namespace network
} // namespace network
#endif // __REST_HTTP__SERVER_CONNECTION_MANAGER_H__

@ -450,13 +450,13 @@ namespace nxdn
0xECDB0FU, 0xB542DAU, 0x9E5131U, 0xC7ABA5U, 0x8C38FEU, 0x97010BU, 0xDED290U, 0xA4CC7DU, 0xAD3D2EU, 0xF6B6B3U,
0xF9A540U, 0x205ED9U, 0x634EB6U, 0x5A9567U, 0x11A6D8U, 0x0B3F09U };
const uint32_t A_TABLE[] = {
const uint32_t A_TABLE[] = {
0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U, 32U, 36U, 40U, 44U,
48U, 52U, 56U, 60U, 64U, 68U, 1U, 5U, 9U, 13U, 17U, 21U };
const uint32_t B_TABLE[] = {
const uint32_t B_TABLE[] = {
25U, 29U, 33U, 37U, 41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U,
2U, 6U, 10U, 14U, 18U, 22U, 26U, 30U, 34U, 38U, 42U };
const uint32_t C_TABLE[] = {
const uint32_t C_TABLE[] = {
46U, 50U, 54U, 58U, 62U, 66U, 70U, 3U, 7U, 11U, 15U, 19U,
23U, 27U, 31U, 35U, 39U, 43U, 47U, 51U, 55U, 59U, 63U, 67U, 71U };

@ -214,7 +214,7 @@ void Control::reset()
/// <param name="channelId">Channel ID.</param>
/// <param name="channelNo">Channel Number.</param>
/// <param name="printOptions"></param>
void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
const std::unordered_map<uint32_t, lookups::VoiceChData> voiceChData, uint16_t siteId, uint32_t sysId,
uint8_t channelId, uint32_t channelNo, bool printOptions)
{
@ -248,7 +248,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw
LogWarning(LOG_NXDN, "Silence threshold set to zero, defaulting to %u", nxdn::MAX_NXDN_VOICE_ERRORS);
m_voice->m_silenceThreshold = nxdn::MAX_NXDN_VOICE_ERRORS;
}
bool disableCompositeFlag = nxdnProtocol["disableCompositeFlag"].as<bool>(false);
uint8_t serviceClass = NXDN_SIF1_VOICE_CALL_SVC | NXDN_SIF1_DATA_CALL_SVC;
if (m_control) {
@ -277,7 +277,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw
m_affiliations.setRFChData(chData);
// set the grant release callback
m_affiliations.setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
m_affiliations.setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
// callback REST API to clear TG permit for the granted TG on the specified voice channel
if (m_authoritative && m_supervisor) {
::lookups::VoiceChData voiceChData = m_affiliations.getRFChData(chNo);
@ -345,15 +345,15 @@ bool Control::processFrame(uint8_t* data, uint32_t len)
if (type == modem::TAG_LOST && m_rfState == RS_RF_AUDIO) {
if (m_rssi != 0U) {
::ActivityLog("NXDN", true, "transmission lost, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm",
::ActivityLog("NXDN", true, "transmission lost, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm",
float(m_voice->m_rfFrames) / 12.5F, float(m_voice->m_rfErrs * 100U) / float(m_voice->m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
}
else {
::ActivityLog("NXDN", true, "transmission lost, %.1f seconds, BER: %.1f%%",
::ActivityLog("NXDN", true, "transmission lost, %.1f seconds, BER: %.1f%%",
float(m_voice->m_rfFrames) / 12.5F, float(m_voice->m_rfErrs * 100U) / float(m_voice->m_rfBits));
}
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%",
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%",
m_voice->m_rfFrames, m_voice->m_rfBits, m_voice->m_rfUndecodableLC, m_voice->m_rfErrs, float(m_voice->m_rfErrs * 100U) / float(m_voice->m_rfBits));
if (m_control) {
@ -801,12 +801,12 @@ bool Control::writeRF_ControlData()
if (m_netState == RS_NET_IDLE && m_rfState == RS_RF_LISTENING) {
m_trunk->writeRF_ControlData(m_ccFrameCnt, m_ccSeq, true);
m_ccSeq++;
if (m_ccSeq == maxSeq) {
m_ccFrameCnt++;
}
return true;
}

@ -58,7 +58,7 @@ namespace nxdn
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Voice; }
namespace packet { class HOST_SW_API Trunk; }
namespace packet { class HOST_SW_API Data; }
@ -71,7 +71,7 @@ namespace nxdn
class HOST_SW_API Control {
public:
/// <summary>Initializes a new instance of the Control class.</summary>
Control(bool authoritative, uint32_t ran, uint32_t callHang, uint32_t queueSize, uint32_t timeout, uint32_t tgHang,
Control(bool authoritative, uint32_t ran, uint32_t callHang, uint32_t queueSize, uint32_t timeout, uint32_t tgHang,
modem::Modem* modem, network::BaseNetwork* network, bool duplex, lookups::RadioIdLookup* ridLookup,
lookups::TalkgroupIdLookup* tidLookup, lookups::IdenTableLookup* idenTable, lookups::RSSIInterpolator* rssiMapper,
bool dumpRCCHData, bool debug, bool verbose);
@ -82,10 +82,10 @@ namespace nxdn
void reset();
/// <summary>Helper to set NXDN configuration options.</summary>
void setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
void setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
const std::unordered_map<uint32_t, lookups::VoiceChData> voiceChData, uint16_t siteId, uint32_t sysId,
uint8_t channelId, uint32_t channelNo, bool printOptions);
/// <summary>Gets a flag indicating whether the NXDN control channel is running.</summary>
bool getCCRunning() { return m_ccRunning; }
/// <summary>Sets a flag indicating whether the NXDN control channel is running.</summary>
@ -180,7 +180,7 @@ namespace nxdn
Timer m_networkWatchdog;
Timer m_ccPacketInterval;
uint8_t m_ccFrameCnt;
uint8_t m_ccSeq;

@ -191,7 +191,7 @@ namespace nxdn
const uint8_t NXDN_LOC_CAT_GLOBAL = 0x00U;
const uint8_t NXDN_LOC_CAT_LOCAL = 0x01U;
const uint8_t NXDN_LOC_CAT_REGIONAL = 0x02U;
const uint8_t NXDN_CAUSE_RSRC_NOT_AVAIL_NETWORK = 0x51U;
const uint8_t NXDN_CAUSE_RSRC_NOT_AVAIL_TEMP = 0x52U;
const uint8_t NXDN_CAUSE_RSRC_NOT_AVAIL_QUEUED = 0x53U;

@ -56,9 +56,9 @@ const uint32_t INTERLEAVE_TABLE[] = {
7U, 16U, 25U, 34U, 43U, 52U, 61U, 70U, 79U, 88U, 97U, 106U, 115U, 124U, 133U, 142U,
8U, 17U, 26U, 35U, 44U, 53U, 62U, 71U, 80U, 89U, 98U, 107U, 116U, 125U, 134U, 143U };
const uint32_t PUNCTURE_LIST[] = {
1U, 5U, 9U, 13U, 17U, 21U, 25U, 29U, 33U, 37U,
41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U, 73U, 77U,
const uint32_t PUNCTURE_LIST[] = {
1U, 5U, 9U, 13U, 17U, 21U, 25U, 29U, 33U, 37U,
41U, 45U, 49U, 53U, 57U, 61U, 65U, 69U, 73U, 77U,
81U, 85U, 89U, 93U, 97U, 101U, 105U, 109U, 113U, 117U,
121U, 125U, 129U, 133U, 137U, 141U, 145U, 149U, 153U, 157U,
161U, 165U, 169U, 173U, 177U, 181U, 185U, 189U };

@ -198,7 +198,7 @@ void LICH::copy(const LICH& data)
}
/// <summary>
///
///
/// </summary>
/// <returns></returns>
bool LICH::getParity() const

@ -77,7 +77,7 @@ const uint32_t INTERLEAVE_TABLE[] = {
27U, 56U, 85U, 114U, 143U, 172U, 201U, 230U, 259U, 288U, 317U, 346U,
28U, 57U, 86U, 115U, 144U, 173U, 202U, 231U, 260U, 289U, 318U, 347U };
const uint32_t PUNCTURE_LIST[] = {
const uint32_t PUNCTURE_LIST[] = {
3U, 11U, 17U, 25U, 31U, 39U, 45U, 53U, 59U, 67U,
73U, 81U, 87U, 95U, 101U, 109U, 115U, 123U, 129U, 137U,
143U, 151U, 157U, 165U, 171U, 179U, 185U, 193U, 199U, 207U,

@ -55,7 +55,7 @@ namespace nxdn
void start();
/// <summary></summary>
uint32_t chainback(uint8_t* out, uint32_t nBits);
/// <summary></summary>
bool decode(uint8_t s0, uint8_t s1);
/// <summary></summary>

@ -281,7 +281,7 @@ bool RTCH::decodeLC(const uint8_t* data)
m_transmissionMode = (data[2U] & 0x07U); // Transmission Mode
m_srcId = (uint16_t)((data[3U] << 8) | data[4U]) & 0xFFFFU; // Source Radio Address
m_dstId = (uint16_t)((data[5U] << 8) | data[6U]) & 0xFFFFU; // Target Radio Address
m_rsp = PacketInformation();
m_rsp.decode(m_messageType, data + 7U); // Response
break;

@ -89,7 +89,7 @@ void MESSAGE_TYPE_VCALL_ASSGN::encode(uint8_t* data, uint32_t length, uint32_t o
rcch[7U] = (m_grpVchNo >> 10) & 0x03U; // Channel
rcch[8U] = (m_grpVchNo & 0xFFU); // ...
rcch[10U] = (m_siteData.locId() >> 8) & 0xFFU; // Location ID
rcch[11U] = (m_siteData.locId() >> 0) & 0xFFU; // ...

@ -95,7 +95,7 @@ std::unique_ptr<RCCH> RCCHFactory::createRCCH(const uint8_t* data, uint32_t leng
return nullptr;
}
return nullptr;
return nullptr;
}
// ---------------------------------------------------------------------------
@ -103,7 +103,7 @@ std::unique_ptr<RCCH> RCCHFactory::createRCCH(const uint8_t* data, uint32_t leng
// ---------------------------------------------------------------------------
/// <summary>
///
///
/// </summary>
/// <param name="rcch"></param>
/// <param name="data"></param>

@ -52,8 +52,8 @@ using namespace nxdn::packet;
// Macros
// ---------------------------------------------------------------------------
// Don't process RF frames if the network isn't in a idle state and the RF destination
// is the network destination and stop network frames from processing -- RF wants to
// Don't process RF frames if the network isn't in a idle state and the RF destination
// is the network destination and stop network frames from processing -- RF wants to
// transmit on a different talkgroup
#define CHECK_TRAFFIC_COLLISION(_SRC_ID, _DST_ID) \
if (m_nxdn->m_netState != RS_NET_IDLE && _DST_ID == m_nxdn->m_netLastDstId) { \
@ -76,7 +76,7 @@ using namespace nxdn::packet;
} \
}
// Don't process network frames if the destination ID's don't match and the network TG hang
// Don't process network frames if the destination ID's don't match and the network TG hang
// timer is running, and don't process network frames if the RF modem isn't in a listening state
#define CHECK_NET_TRAFFIC_COLLISION(_LAYER3, _SRC_ID, _DST_ID) \
if (m_nxdn->m_rfLastDstId != 0U) { \
@ -269,7 +269,7 @@ bool Data::process(uint8_t option, uint8_t* data, uint32_t len)
if (data[0U] == modem::TAG_EOT) {
::ActivityLog("NXDN", true, "RF ended RF data transmission");
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d",
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d",
m_nxdn->m_voice->m_rfFrames);
m_nxdn->writeEndRF();
@ -292,7 +292,7 @@ bool Data::processNetwork(uint8_t option, lc::RTCH& netLC, uint8_t* data, uint32
if (m_nxdn->m_netState == RS_NET_IDLE) {
m_nxdn->m_queue.clear();
resetRF();
resetNet();
}
@ -374,7 +374,7 @@ bool Data::processNetwork(uint8_t option, lc::RTCH& netLC, uint8_t* data, uint32
if (data[0U] == modem::TAG_EOT) {
::ActivityLog("NXDN", true, "network ended RF data transmission");
LogMessage(LOG_NET, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d",
LogMessage(LOG_NET, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d",
m_nxdn->m_voice->m_netFrames);
m_nxdn->writeEndNet();

@ -43,7 +43,7 @@ namespace nxdn
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Control;
namespace packet

@ -378,7 +378,7 @@ void Trunk::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS)
}
switch (n)
{
{
case 0:
writeRF_CC_Message_Site_Info();
break;
@ -624,7 +624,7 @@ void Trunk::writeRF_Message_Deny(uint32_t srcId, uint32_t dstId, uint8_t reason,
rcch->setDstId(dstId);
if (m_verbose) {
LogMessage(LOG_RF, "NXDN, MSG_DENIAL (Message Denial), reason = $%02X, service = $%02X, srcId = %u, dstId = %u",
LogMessage(LOG_RF, "NXDN, MSG_DENIAL (Message Denial), reason = $%02X, service = $%02X, srcId = %u, dstId = %u",
service, srcId, dstId);
}

@ -43,7 +43,7 @@ namespace nxdn
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Data; }
namespace packet { class HOST_SW_API Voice; }
class HOST_SW_API Control;

@ -54,8 +54,8 @@ using namespace nxdn::packet;
// Macros
// ---------------------------------------------------------------------------
// Don't process RF frames if the network isn't in a idle state and the RF destination
// is the network destination and stop network frames from processing -- RF wants to
// Don't process RF frames if the network isn't in a idle state and the RF destination
// is the network destination and stop network frames from processing -- RF wants to
// transmit on a different talkgroup
#define CHECK_TRAFFIC_COLLISION(_SRC_ID, _DST_ID) \
if (m_nxdn->m_netState != RS_NET_IDLE && _DST_ID == m_nxdn->m_netLastDstId) { \
@ -78,7 +78,7 @@ using namespace nxdn::packet;
} \
}
// Don't process network frames if the destination ID's don't match and the network TG hang
// Don't process network frames if the destination ID's don't match and the network TG hang
// timer is running, and don't process network frames if the RF modem isn't in a listening state
#define CHECK_NET_TRAFFIC_COLLISION(_LAYER3, _SRC_ID, _DST_ID) \
if (m_nxdn->m_rfLastDstId != 0U) { \
@ -290,16 +290,16 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
if (data[0U] == modem::TAG_EOT) {
m_rfFrames++;
if (m_nxdn->m_rssi != 0U) {
::ActivityLog("NXDN", true, "RF end of transmission, %.1f seconds, BER: %.1f%%, RSSI : -%u / -%u / -%u dBm",
float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_nxdn->m_minRSSI, m_nxdn->m_maxRSSI,
::ActivityLog("NXDN", true, "RF end of transmission, %.1f seconds, BER: %.1f%%, RSSI : -%u / -%u / -%u dBm",
float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_nxdn->m_minRSSI, m_nxdn->m_maxRSSI,
m_nxdn->m_aveRSSI / m_nxdn->m_rssiCount);
}
else {
::ActivityLog("NXDN", true, "RF end of transmission, %.1f seconds, BER: %.1f%%",
::ActivityLog("NXDN", true, "RF end of transmission, %.1f seconds, BER: %.1f%%",
float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits));
}
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%",
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%",
m_rfFrames, m_rfBits, m_rfUndecodableLC, m_rfErrs, float(m_rfErrs * 100U) / float(m_rfBits));
m_nxdn->writeEndRF();
@ -309,7 +309,7 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
m_rfBits = 1U;
m_nxdn->m_rfTimeout.start();
m_nxdn->m_rfState = RS_RF_AUDIO;
m_nxdn->m_minRSSI = m_nxdn->m_rssi;
m_nxdn->m_maxRSSI = m_nxdn->m_rssi;
m_nxdn->m_aveRSSI = m_nxdn->m_rssi;
@ -500,7 +500,7 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
// regenerate the audio and interpret the FACCH1 data
if (option == NXDN_LICH_STEAL_NONE) {
edac::AMBEFEC ambe;
uint32_t errors = 0U;
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 0U);
@ -536,7 +536,7 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
edac::AMBEFEC ambe;
uint32_t errors = 0U;
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 18U);
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 27U);
@ -550,10 +550,10 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
LogWarning(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_VCALL ", exceeded lost audio threshold, filling in");
}
m_rfErrs += errors;
m_rfBits += 94U;
if (m_verbose) {
LogMessage(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_VCALL ", audio, errs = %u/94 (%.1f%%)", errors, float(errors) / 0.94F);
}
@ -561,7 +561,7 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
edac::AMBEFEC ambe;
uint32_t errors = 0U;
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 0U);
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 9U);
@ -575,7 +575,7 @@ bool Voice::process(uint8_t fct, uint8_t option, uint8_t* data, uint32_t len)
LogWarning(LOG_RF, "NXDN, " NXDN_RTCH_MSG_TYPE_VCALL ", exceeded lost audio threshold, filling in");
}
m_rfErrs += errors;
m_rfBits += 94U;
@ -634,7 +634,7 @@ bool Voice::processNetwork(uint8_t fct, uint8_t option, lc::RTCH& netLC, uint8_t
if (m_nxdn->m_netState == RS_NET_IDLE) {
m_nxdn->m_queue.clear();
resetRF();
resetNet();
}
@ -727,7 +727,7 @@ bool Voice::processNetwork(uint8_t fct, uint8_t option, lc::RTCH& netLC, uint8_t
if (data[0U] == modem::TAG_EOT) {
m_netFrames++;
::ActivityLog("NXDN", false, "network end of transmission, %.1f seconds",
::ActivityLog("NXDN", false, "network end of transmission, %.1f seconds",
float(m_netFrames) / 12.5F);
LogMessage(LOG_NET, "NXDN, " NXDN_RTCH_MSG_TYPE_TX_REL ", total frames: %d", m_netFrames);
@ -909,7 +909,7 @@ bool Voice::processNetwork(uint8_t fct, uint8_t option, lc::RTCH& netLC, uint8_t
// regenerate the audio and interpret the FACCH1 data
if (option == NXDN_LICH_STEAL_NONE) {
edac::AMBEFEC ambe;
uint32_t errors = 0U;
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 0U);
@ -932,13 +932,13 @@ bool Voice::processNetwork(uint8_t fct, uint8_t option, lc::RTCH& netLC, uint8_t
edac::AMBEFEC ambe;
uint32_t errors = 0U;
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 18U);
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 27U);
m_rfErrs += errors;
m_rfBits += 94U;
if (m_verbose) {
LogMessage(LOG_NET, "NXDN, " NXDN_RTCH_MSG_TYPE_VCALL ", audio, errs = %u/94 (%.1f%%)", errors, float(errors) / 0.94F);
}
@ -946,10 +946,10 @@ bool Voice::processNetwork(uint8_t fct, uint8_t option, lc::RTCH& netLC, uint8_t
edac::AMBEFEC ambe;
uint32_t errors = 0U;
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES);
errors += ambe.regenerateNXDN(data + 2U + NXDN_FSW_LICH_SACCH_LENGTH_BYTES + 9U);
m_rfErrs += errors;
m_rfBits += 94U;

@ -43,7 +43,7 @@ namespace nxdn
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Data; }
class HOST_SW_API Control;

@ -221,8 +221,8 @@ void Control::reset()
/// <param name="channelId">Channel ID.</param>
/// <param name="channelNo">Channel Number.</param>
/// <param name="printOptions"></param>
void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData, uint32_t pSuperGroup, uint32_t netId,
void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData, uint32_t pSuperGroup, uint32_t netId,
uint32_t sysId, uint8_t rfssId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions)
{
yaml::Node systemConf = conf["system"];
@ -278,7 +278,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw
LogWarning(LOG_P25, "Silence threshold set to zero, defaulting to %u", p25::MAX_P25_VOICE_ERRORS);
m_voice->m_silenceThreshold = p25::MAX_P25_VOICE_ERRORS;
}
m_disableNetworkHDU = p25Protocol["disableNetworkHDU"].as<bool>(false);
bool disableCompositeFlag = p25Protocol["disableCompositeFlag"].as<bool>(false);
@ -321,7 +321,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw
m_affiliations.setRFChData(chData);
// set the grant release callback
m_affiliations.setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
m_affiliations.setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
// callback REST API to clear TG permit for the granted TG on the specified voice channel
if (m_authoritative && m_supervisor) {
::lookups::VoiceChData voiceChData = m_affiliations.getRFChData(chNo);

@ -57,7 +57,7 @@ namespace p25
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Voice; }
namespace dfsi { namespace packet { class HOST_SW_API DFSIVoice; } }
namespace packet { class HOST_SW_API Data; }
@ -84,10 +84,10 @@ namespace p25
void reset();
/// <summary>Helper to set P25 configuration options.</summary>
void setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData, uint32_t pSuperGroup, uint32_t netId,
void setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const std::vector<uint32_t> voiceChNo,
const std::unordered_map<uint32_t, ::lookups::VoiceChData> voiceChData, uint32_t pSuperGroup, uint32_t netId,
uint32_t sysId, uint8_t rfssId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions);
/// <summary>Gets a flag indicating whether the P25 control channel is running.</summary>
bool getCCRunning() { return m_ccRunning; }
/// <summary>Sets a flag indicating whether the P25 control channel is running.</summary>
@ -197,7 +197,7 @@ namespace p25
uint32_t m_hangCount;
uint32_t m_tduPreambleCount;
uint8_t m_ccFrameCnt;
uint8_t m_ccSeq;

@ -113,7 +113,7 @@ bool DataBlock::decode(const uint8_t* data, const DataHeader header)
// if this is extended addressing and the first block decode the SAP and LLId
if (m_headerSap == PDU_SAP_EXT_ADDR && m_serialNo == 0U) {
count = P25_PDU_CONFIRMED_DATA_LENGTH_BYTES - 4U;
count = P25_PDU_CONFIRMED_DATA_LENGTH_BYTES - 4U;
m_sap = buffer[5U] & 0x3FU; // Service Access Point
m_llId = (buffer[2U] << 16) + (buffer[3U] << 8) + buffer[4U]; // Logical Link ID
@ -275,7 +275,7 @@ uint32_t DataBlock::getData(uint8_t* buffer) const
if (m_fmt == PDU_FMT_CONFIRMED) {
::memcpy(buffer, m_data, P25_PDU_CONFIRMED_DATA_LENGTH_BYTES);
return P25_PDU_CONFIRMED_DATA_LENGTH_BYTES;
}
}
else if (m_fmt == PDU_FMT_UNCONFIRMED || m_fmt == PDU_FMT_RSP || m_fmt == PDU_FMT_AMBT) {
::memcpy(buffer, m_data, P25_PDU_UNCONFIRMED_LENGTH_BYTES);
return P25_PDU_UNCONFIRMED_LENGTH_BYTES;

@ -280,7 +280,7 @@ void DataHeader::reset()
m_rspClass = PDU_ACK_CLASS_NACK;
m_rspType = PDU_ACK_TYPE_NACK_ILLEGAL;
m_rspStatus = 0U;
m_ambtOpcode = 0U;
m_ambtField8 = 0U;
m_ambtField9 = 0U;

@ -551,7 +551,7 @@ bool LC::decodeLDU2(const uint8_t* data, uint8_t* imbe)
case P25_DFSI_LDU2_VOICE12:
{
m_mi[0U] = data[1U]; // Message Indicator
m_mi[1U] = data[2U];
m_mi[1U] = data[2U];
m_mi[2U] = data[3U];
::memcpy(imbe, data + 5U, P25_RAW_IMBE_LENGTH_BYTES); // IMBE
}
@ -559,7 +559,7 @@ bool LC::decodeLDU2(const uint8_t* data, uint8_t* imbe)
case P25_DFSI_LDU2_VOICE13:
{
m_mi[3U] = data[1U]; // Message Indicator
m_mi[4U] = data[2U];
m_mi[4U] = data[2U];
m_mi[5U] = data[3U];
::memcpy(imbe, data + 5U, P25_RAW_IMBE_LENGTH_BYTES); // IMBE
}
@ -567,7 +567,7 @@ bool LC::decodeLDU2(const uint8_t* data, uint8_t* imbe)
case P25_DFSI_LDU2_VOICE14:
{
m_mi[6U] = data[1U]; // Message Indicator
m_mi[7U] = data[2U];
m_mi[7U] = data[2U];
m_mi[8U] = data[3U];
m_control->setMI(m_mi);
::memcpy(imbe, data + 5U, P25_RAW_IMBE_LENGTH_BYTES); // IMBE

@ -224,7 +224,7 @@ void DFSITrunk::writeRF_DFSI_Start(uint8_t type)
{
uint8_t buffer[P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U);
// Generate Start/Stop
m_rfDFSILC.setFrameType(P25_DFSI_START_STOP);
m_rfDFSILC.setStartStop(P25_DFSI_START_FLAG);
@ -247,7 +247,7 @@ void DFSITrunk::writeRF_DSFI_Stop(uint8_t type)
{
uint8_t buffer[P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U);
// Generate Start/Stop
m_rfDFSILC.setFrameType(P25_DFSI_START_STOP);
m_rfDFSILC.setStartStop(P25_DFSI_STOP_FLAG);

@ -36,7 +36,7 @@ namespace p25
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Trunk; }
class HOST_SW_API Control;

@ -595,16 +595,16 @@ bool DFSIVoice::process(uint8_t* data, uint32_t len)
if (m_p25->m_rfState == RS_RF_AUDIO) {
if (m_p25->m_rssi != 0U) {
::ActivityLog("P25", true, "RF end of transmission, %.1f seconds, BER: %.1f%%, RSSI : -%u / -%u / -%u dBm",
float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_p25->m_minRSSI, m_p25->m_maxRSSI,
::ActivityLog("P25", true, "RF end of transmission, %.1f seconds, BER: %.1f%%, RSSI : -%u / -%u / -%u dBm",
float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_p25->m_minRSSI, m_p25->m_maxRSSI,
m_p25->m_aveRSSI / m_p25->m_rssiCount);
}
else {
::ActivityLog("P25", true, "RF end of transmission, %.1f seconds, BER: %.1f%%",
::ActivityLog("P25", true, "RF end of transmission, %.1f seconds, BER: %.1f%%",
float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
}
LogMessage(LOG_RF, P25_TDU_STR " DFSI, total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%",
LogMessage(LOG_RF, P25_TDU_STR " DFSI, total frames: %d, bits: %d, undecodable LC: %d, errors: %d, BER: %.4f%%",
m_rfFrames, m_rfBits, m_rfUndecodableLC, m_rfErrs, float(m_rfErrs * 100U) / float(m_rfBits));
if (m_p25->m_dedicatedControl) {
@ -1127,10 +1127,10 @@ void DFSIVoice::writeNet_LDU1()
// Generate Voice Frame
m_netDFSILC.setFrameType(i);
m_netDFSILC.encodeLDU1(buffer + 2U, m_netLDU1 + n);
buffer[0U] = modem::TAG_DATA;
buffer[1U] = 0x00U;
m_p25->addFrame(buffer, len + 2U, true);
}

@ -41,7 +41,7 @@ namespace p25
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Voice; }
class HOST_SW_API Control;

@ -54,7 +54,7 @@ namespace p25
virtual bool decode(const uint8_t* data, bool rawTSBK = false);
/// <summary>Encode a trunking signalling block.</summary>
virtual void encode(uint8_t* data, bool rawTSBK = false, bool noTrellis = false);
protected:
/// <summary>Internal helper to convert TSBK bytes to a 64-bit long value.</summary>
static ulong64_t toValue(const data::DataHeader dataHeader, const uint8_t* pduUserData);

@ -445,7 +445,7 @@ void LC::encodeLDU2(uint8_t* data)
// encode RS (24,16,9) FEC
m_rs.encode24169(rs);
#if DEBUG_P25_LDU2
Utils::dump(2U, "LC::encodeLDU2(), LDU2 RS", rs, P25_LDU_LC_LENGTH_BYTES);
#endif
@ -572,7 +572,7 @@ bool LC::decodeLC(const uint8_t* rs)
m_protect = (rs[0U] & 0x80U) == 0x80U; // Protect Flag
m_lco = rs[0U] & 0x3FU; // LCO
m_mfId = rs[1U]; // Mfg Id.
// Motorola P25 vendor opcodes (these are just detected for passthru)

@ -43,7 +43,7 @@ namespace p25
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API LC;
class HOST_SW_API TSBK;

@ -99,7 +99,7 @@ TSBK::TSBK() :
m_service(0U),
m_response(P25_RSP_ACCEPT),
m_netId(P25_WACN_STD_DEFAULT),
m_sysId(P25_SID_STD_DEFAULT),
m_sysId(P25_SID_STD_DEFAULT),
m_emergency(false),
m_encrypted(false),
m_priority(4U),

@ -71,7 +71,7 @@ namespace p25
TSBK();
/// <summary>Finalizes a instance of the TSBK class.</summary>
virtual ~TSBK();
/// <summary>Decode a trunking signalling block.</summary>
virtual bool decode(const uint8_t* data, bool rawTSBK = false) = 0;
/// <summary>Encode a trunking signalling block.</summary>

@ -64,7 +64,7 @@ bool LC_GROUP::decode(const uint8_t* data)
return false;
ulong64_t rsValue = TDULC::toValue(rs);
m_mfId = rs[1U]; // Mfg Id.
m_group = true;
m_emergency = (rs[2U] & 0x80U) == 0x80U; // Emergency Flag

@ -64,7 +64,7 @@ bool LC_PRIVATE::decode(const uint8_t* data)
return false;
ulong64_t rsValue = TDULC::toValue(rs);
m_mfId = rs[1U]; // Mfg Id.
m_group = false;
m_emergency = (rs[2U] & 0x80U) == 0x80U; // Emergency Flag

@ -64,7 +64,7 @@ bool LC_TEL_INT_VCH_USER::decode(const uint8_t* data)
return false;
ulong64_t rsValue = TDULC::toValue(rs);
m_emergency = (rs[2U] & 0x80U) == 0x80U; // Emergency Flag
m_encrypted = (rs[2U] & 0x40U) == 0x40U; // Encryption Flag
m_priority = (rs[2U] & 0x07U); // Priority

@ -110,7 +110,7 @@ std::unique_ptr<TDULC> TDULCFactory::createTDULC(const uint8_t* data)
break;
}
return nullptr;
return nullptr;
}
// ---------------------------------------------------------------------------
@ -118,7 +118,7 @@ std::unique_ptr<TDULC> TDULCFactory::createTDULC(const uint8_t* data)
// ---------------------------------------------------------------------------
/// <summary>
///
///
/// </summary>
/// <param name="tdulc"></param>
/// <param name="data"></param>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.