correct double spaced formatting of CPP files in common; convert dvmhost to Doxygen documentation format; convert dvmfne to Doxygen documentation format; convert dvmcmd to Doxygen documentation format;

pull/61/head
Bryan Biedenkapp 2 years ago
parent 10e1e12be0
commit 882c2564ca

@ -243,6 +243,7 @@ static const uint8_t INV_CMDS[4][4] = { {14, 11, 13, 9}, {9, 14, 11, 13}, {13, 9
// ---------------------------------------------------------------------------
/* Initializes a new instance of the AES class. */
AES::AES(const AESKeyLength keyLength) {
switch (keyLength) {
case AESKeyLength::AES_128:
@ -261,6 +262,7 @@ AES::AES(const AESKeyLength keyLength) {
}
/* Encrypt input buffer with given key in AES-ECB. */
uint8_t* AES::encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[])
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -283,6 +285,7 @@ uint8_t* AES::encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
}
/* Decrypt input buffer with given key in AES-ECB. */
uint8_t* AES::decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[])
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -305,6 +308,7 @@ uint8_t* AES::decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
}
/* Encrypt input buffer with given key and IV in AES-CBC. */
uint8_t* AES::encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -331,6 +335,7 @@ uint8_t* AES::encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[]
}
/* Decrypt input buffer with given key and IV in AES-CBC. */
uint8_t* AES::decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -357,6 +362,7 @@ uint8_t* AES::decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[]
}
/* Encrypt input buffer with given key and IV in AES-CFB. */
uint8_t* AES::encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -384,6 +390,7 @@ uint8_t* AES::encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
}
/* Decrypt input buffer with given key and IV in AES-CFB. */
uint8_t* AES::decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv)
{
if (inLen % BLOCK_BYTES_LEN != 0) {
@ -415,6 +422,7 @@ uint8_t* AES::decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[]
// ---------------------------------------------------------------------------
/* */
void AES::subBytes(uint8_t state[4][AES_NB])
{
for (uint32_t i = 0; i < 4; i++) {
@ -426,6 +434,7 @@ void AES::subBytes(uint8_t state[4][AES_NB])
}
/* */
void AES::invSubBytes(uint8_t state[4][AES_NB])
{
for (uint32_t i = 0; i < 4; i++) {
@ -437,6 +446,7 @@ void AES::invSubBytes(uint8_t state[4][AES_NB])
}
/* Shift row i on n positions. */
void AES::shiftRow(uint8_t state[4][AES_NB], uint32_t i, uint32_t n)
{
uint8_t tmp[AES_NB];
@ -447,6 +457,7 @@ void AES::shiftRow(uint8_t state[4][AES_NB], uint32_t i, uint32_t n)
}
/* */
void AES::shiftRows(uint8_t state[4][AES_NB])
{
shiftRow(state, 1, 1);
@ -455,6 +466,7 @@ void AES::shiftRows(uint8_t state[4][AES_NB])
}
/* */
void AES::invShiftRows(uint8_t state[4][AES_NB])
{
shiftRow(state, 1, AES_NB - 1);
@ -463,6 +475,7 @@ void AES::invShiftRows(uint8_t state[4][AES_NB])
}
/* */
void AES::mixColumns(uint8_t state[4][AES_NB]) {
uint8_t tempState[4][AES_NB];
for (size_t i = 0; i < 4; ++i) {
@ -486,6 +499,7 @@ void AES::mixColumns(uint8_t state[4][AES_NB]) {
}
/* */
void AES::invMixColumns(uint8_t state[4][AES_NB]) {
uint8_t tempState[4][AES_NB];
for (size_t i = 0; i < 4; ++i) {
@ -506,6 +520,7 @@ void AES::invMixColumns(uint8_t state[4][AES_NB]) {
}
/* */
void AES::addRoundKey(uint8_t state[4][AES_NB], uint8_t* key)
{
for (uint32_t i = 0; i < 4; i++) {
@ -516,6 +531,7 @@ void AES::addRoundKey(uint8_t state[4][AES_NB], uint8_t* key)
}
/* */
void AES::subWord(uint8_t* a)
{
for (uint32_t i = 0; i < 4; i++) {
@ -524,6 +540,7 @@ void AES::subWord(uint8_t* a)
}
/* */
void AES::rotWord(uint8_t* a)
{
uint8_t c = a[0];
@ -534,6 +551,7 @@ void AES::rotWord(uint8_t* a)
}
/* */
void AES::xorWords(uint8_t* a, uint8_t* b, uint8_t* c)
{
for (uint32_t i = 0; i < 4; i++) {
@ -542,6 +560,7 @@ void AES::xorWords(uint8_t* a, uint8_t* b, uint8_t* c)
}
/* */
void AES::rCon(uint8_t *a, uint32_t n)
{
uint8_t c = 1;
@ -554,6 +573,7 @@ void AES::rCon(uint8_t *a, uint32_t n)
}
/* */
void AES::keyExpansion(const uint8_t key[], uint8_t w[]) {
uint8_t temp[4], rcon[4];
@ -588,6 +608,7 @@ void AES::keyExpansion(const uint8_t key[], uint8_t w[]) {
}
/* */
void AES::encryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
{
uint8_t state[4][AES_NB];
@ -618,6 +639,7 @@ void AES::encryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
}
/* */
void AES::decryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
{
uint8_t state[4][AES_NB];
@ -648,6 +670,7 @@ void AES::decryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys)
}
/* */
void AES::xorBlocks(const uint8_t *a, const uint8_t *b, uint8_t *c, uint32_t len)
{
for (uint32_t i = 0; i < len; i++) {

@ -27,6 +27,7 @@ static const uint64_t NTP_SCALE_FRAC = 4294967296ULL;
// ---------------------------------------------------------------------------
/* */
static inline uint32_t ntpDiffMS(uint64_t older, uint64_t newer)
{
if (older > newer) {
@ -49,6 +50,7 @@ static inline uint32_t ntpDiffMS(uint64_t older, uint64_t newer)
}
/* Get current time in NTP units. */
uint64_t ntp::now()
{
struct timeval tv;
@ -61,6 +63,7 @@ uint64_t ntp::now()
}
/* Calculate the time difference of two NTP times. */
uint64_t ntp::diff(uint64_t ntp1, uint64_t ntp2)
{
return ntpDiffMS(ntp1, ntp2);
@ -70,6 +73,7 @@ uint64_t ntp::diff(uint64_t ntp1, uint64_t ntp2)
* Calculate the time difference of two NTP times.
* This function calls clock::ntp::now() and then subtracts the input parameter from that timestamp value.
*/
uint64_t ntp::diffNow(uint64_t then)
{
uint64_t now = ntp::now();
@ -77,12 +81,14 @@ uint64_t ntp::diffNow(uint64_t then)
}
/* Get current time in HRC units. */
hrc::hrc_t hrc::now()
{
return std::chrono::high_resolution_clock::now();
}
/* Calculate the time difference of two HRC times. */
uint64_t hrc::diff(hrc::hrc_t hrc1, hrc::hrc_t hrc2)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(hrc1 - hrc2).count();
@ -92,6 +98,7 @@ uint64_t hrc::diff(hrc::hrc_t hrc1, hrc::hrc_t hrc2)
* Calculate the time difference of two HRC times.
* This function calls clock::hrc::now() and then subtracts the input parameter from that timestamp value.
*/
uint64_t hrc::diffNow(hrc::hrc_t then)
{
return (uint64_t)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - then).count();
@ -101,18 +108,21 @@ uint64_t hrc::diffNow(hrc::hrc_t then)
* Calculate the time difference of two HRC times.
* This function calls clock::hrc::now() and then subtracts the input parameter from that timestamp value.
*/
uint64_t hrc::diffNowUS(hrc::hrc_t& then)
{
return (uint64_t)std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - then).count();
}
/* Convert milliseconds to jiffies. */
uint64_t system_clock::msToJiffies(uint64_t ms)
{
return (uint64_t)(((double)ms / 1000) * 65536);
}
/* Convert jiffies to milliseconds. */
uint64_t system_clock::jiffiesToMs(uint64_t jiffies)
{
return (uint64_t)(((double)jiffies / 65536) * 1000);

@ -62,15 +62,19 @@ static char LEVELS[] = " DMIWEF";
// ---------------------------------------------------------------------------
/* Helper to get the current log file level. */
uint32_t CurrentLogFileLevel() { return m_fileLevel; }
/* Helper to get the current log file path. */
std::string LogGetFilePath() { return m_filePath; }
/* Helper to get the current log file root. */
std::string LogGetFileRoot() { return m_fileRoot; }
/* Helper to open the detailed log file, file handle. */
static bool LogOpen()
{
#if defined(CATCH2_TEST_COMPILATION)
@ -128,12 +132,14 @@ static bool LogOpen()
}
/* Internal helper to set an output stream to direct logging to. */
void __InternalOutputStream(std::ostream& stream)
{
m_outStream.rdbuf(stream.rdbuf());
}
/* Gets the instance of the Network class to transfer the activity log with. */
void* LogGetNetwork()
{
// NO GOOD, VERY BAD, TERRIBLE HACK
@ -141,6 +147,7 @@ void* LogGetNetwork()
}
/* Sets the instance of the Network class to transfer the activity log with. */
void LogSetNetwork(void* network)
{
#if defined(CATCH2_TEST_COMPILATION)
@ -152,6 +159,7 @@ void LogSetNetwork(void* network)
}
/* Initializes the diagnostics log. */
bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uint32_t fileLevel, uint32_t displayLevel, bool disableTimeDisplay, bool useSyslog)
{
m_filePath = filePath;
@ -165,6 +173,7 @@ bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uin
}
/* Finalizes the diagnostics log. */
void LogFinalise()
{
#if defined(CATCH2_TEST_COMPILATION)
@ -177,6 +186,7 @@ void LogFinalise()
}
/* Writes a new entry to the diagnostics log. */
void Log(uint32_t level, const char *module, const char* fmt, ...)
{
assert(fmt != nullptr);

@ -17,6 +17,7 @@
// ---------------------------------------------------------------------------
/* Initializes a new instance of the StopWatch class. */
StopWatch::StopWatch() :
m_startMS(0ULL)
{
@ -24,12 +25,14 @@ StopWatch::StopWatch() :
}
/* Finalizes a instance of the StopWatch class. */
StopWatch::~StopWatch()
{
/* stub */
}
/* Gets the current running time. */
ulong64_t StopWatch::time() const
{
struct timeval now;
@ -39,6 +42,7 @@ ulong64_t StopWatch::time() const
}
/* Starts the stopwatch. */
ulong64_t StopWatch::start()
{
struct timespec now;
@ -50,6 +54,7 @@ ulong64_t StopWatch::start()
}
/* Gets the elapsed time since the stopwatch started. */
uint32_t StopWatch::elapsed()
{
struct timespec now;

@ -20,6 +20,7 @@
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Thread class. */
Thread::Thread() :
m_thread(),
m_started(false)
@ -28,9 +29,11 @@ Thread::Thread() :
}
/* Finalizes a instance of the Thread class. */
Thread::~Thread() = default;
/* Starts the thread execution. */
bool Thread::run()
{
if (m_started)
@ -47,12 +50,14 @@ bool Thread::run()
}
/* Make calling thread wait for termination of the thread. */
void Thread::wait()
{
::pthread_join(m_thread, NULL);
}
/* Set thread name visible in the kernel and its interfaces. */
void Thread::setName(std::string name)
{
if (!m_started)
@ -69,6 +74,7 @@ void Thread::setName(std::string name)
* The resources of thread will therefore be freed immediately when it terminates, instead
* of waiting for another thread to perform wait() on it.
*/
void Thread::detach()
{
if (!m_started)
@ -76,7 +82,8 @@ void Thread::detach()
::pthread_detach(m_thread);
}
/* */
/* Helper to sleep the current thread. */
void Thread::sleep(uint32_t ms)
{
::usleep(ms * 1000);
@ -87,6 +94,7 @@ void Thread::sleep(uint32_t ms)
// ---------------------------------------------------------------------------
/* Internal helper thats used as the entry point for the thread. */
void* Thread::helper(void* arg)
{
Thread* p = (Thread*)arg;

@ -19,6 +19,7 @@
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Timer class. */
Timer::Timer() :
m_ticksPerSec(1000U),
m_timeout(0U),
@ -29,6 +30,7 @@ Timer::Timer() :
}
/* Initializes a new instance of the Timer class. */
Timer::Timer(uint32_t ticksPerSec, uint32_t secs, uint32_t msecs) :
m_ticksPerSec(ticksPerSec),
m_timeout(0U),
@ -45,9 +47,11 @@ Timer::Timer(uint32_t ticksPerSec, uint32_t secs, uint32_t msecs) :
}
/* Finalizes a instance of the Timer class. */
Timer::~Timer() = default;
/* Sets the timeout for the timer. */
void Timer::setTimeout(uint32_t secs, uint32_t msecs)
{
if (secs > 0U || msecs > 0U) {
@ -62,6 +66,7 @@ void Timer::setTimeout(uint32_t secs, uint32_t msecs)
}
/* Gets the timeout for the timer. */
uint32_t Timer::getTimeout() const
{
if (m_timeout == 0U)
@ -71,6 +76,7 @@ uint32_t Timer::getTimeout() const
}
/* Gets the current time for the timer. */
uint32_t Timer::getTimer() const
{
if (m_timer == 0U)

@ -30,6 +30,7 @@ const uint8_t BITS_TABLE[] = {
// ---------------------------------------------------------------------------
/* Helper to dump the input buffer and display the hexadecimal output in the log. */
void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length)
{
assert(data != nullptr);
@ -38,6 +39,7 @@ void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length)
}
/* Helper to dump the input buffer and display the hexadecimal output in the log. */
void Utils::dump(int level, const std::string& title, const uint8_t* data, uint32_t length)
{
assert(data != nullptr);
@ -85,6 +87,7 @@ void Utils::dump(int level, const std::string& title, const uint8_t* data, uint3
}
/* Helper to dump the input boolean bit buffer and display the hexadecimal output in the log. */
void Utils::dump(const std::string& title, const bool* bits, uint32_t length)
{
assert(bits != nullptr);
@ -93,6 +96,7 @@ void Utils::dump(const std::string& title, const bool* bits, uint32_t length)
}
/* Helper to dump the input boolean bit buffer and display the hexadecimal output in the log. */
void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t length)
{
assert(bits != nullptr);
@ -106,6 +110,7 @@ void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t
}
/* Helper to dump the input buffer and display the output as a symbolic microslot output. */
void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t length)
{
assert(data != nullptr);
@ -168,6 +173,7 @@ void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t leng
}
/* Helper to convert the input byte to a boolean array of bits in big-endian. */
void Utils::byteToBitsBE(uint8_t byte, bool* bits)
{
assert(bits != nullptr);
@ -183,6 +189,7 @@ void Utils::byteToBitsBE(uint8_t byte, bool* bits)
}
/* Helper to convert the input byte to a boolean array of bits in little-endian. */
void Utils::byteToBitsLE(uint8_t byte, bool* bits)
{
assert(bits != nullptr);
@ -198,6 +205,7 @@ void Utils::byteToBitsLE(uint8_t byte, bool* bits)
}
/* Helper to convert the input boolean array of bits to a byte in big-endian. */
void Utils::bitsToByteBE(const bool* bits, uint8_t& byte)
{
assert(bits != nullptr);
@ -213,6 +221,7 @@ void Utils::bitsToByteBE(const bool* bits, uint8_t& byte)
}
/* Helper to convert the input boolean array of bits to a byte in little-endian. */
void Utils::bitsToByteLE(const bool* bits, uint8_t& byte)
{
assert(bits != nullptr);
@ -228,18 +237,21 @@ void Utils::bitsToByteLE(const bool* bits, uint8_t& byte)
}
/* Helper to reverse the endianness of the passed value. */
uint16_t Utils::reverseEndian(uint16_t value)
{
return (value << 8 & 0xff00) | (value >> 8);
}
/* Helper to reverse the endianness of the passed value. */
uint32_t Utils::reverseEndian(uint32_t value)
{
return (value << 24 | (value & 0xFF00U) << 8 | (value & 0xFF0000U) >> 8 | value >> 24);
}
/* Helper to reverse the endianness of the passed value. */
uint64_t Utils::reverseEndian(uint64_t value)
{
return (value << 56 | (value & 0xFF00U) << 40 | (value & 0xFF0000U) << 24 | (value & 0xFF000000U) << 8 |
@ -247,6 +259,7 @@ uint64_t Utils::reverseEndian(uint64_t value)
}
/* Helper to retreive arbitrary length of bits from an input buffer. */
uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop)
{
assert(in != nullptr);
@ -262,12 +275,14 @@ uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_
}
/* Helper to retreive arbitrary length of bits from an input buffer. */
uint32_t Utils::getBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length)
{
return getBits(in, out, start, start + length);
}
/* Helper to set an arbitrary length of bits from an input buffer. */
uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop)
{
assert(in != nullptr);
@ -283,12 +298,14 @@ uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_
}
/* Helper to set an arbitrary length of bits from an input buffer. */
uint32_t Utils::setBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length)
{
return setBits(in, out, start, start + length);
}
/* Helper to convert a binary input buffer into representative 6-bit byte. */
uint8_t Utils::bin2Hex(const uint8_t* input, uint32_t offset)
{
uint8_t output = 0x00U;
@ -304,6 +321,7 @@ uint8_t Utils::bin2Hex(const uint8_t* input, uint32_t offset)
}
/* Helper to convert 6-bit input byte into representative binary buffer. */
void Utils::hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset)
{
WRITE_BIT(output, offset + 0U, input & 0x20U);
@ -315,12 +333,14 @@ void Utils::hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset)
}
/* Returns the count of bits in the passed 8 byte value. */
uint8_t Utils::countBits8(uint8_t bits)
{
return BITS_TABLE[bits];
}
/* Returns the count of bits in the passed 32 byte value. */
uint8_t Utils::countBits32(uint32_t bits)
{
uint8_t* p = (uint8_t*)&bits;
@ -333,6 +353,7 @@ uint8_t Utils::countBits32(uint32_t bits)
}
/* Returns the count of bits in the passed 64 byte value. */
uint8_t Utils::countBits64(ulong64_t bits)
{
uint8_t* p = (uint8_t*)&bits;

@ -21,6 +21,7 @@ using namespace dmr::defines;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the SlotType class. */
SlotType::SlotType() :
m_colorCode(0U),
m_dataType(DataType::IDLE)
@ -29,9 +30,11 @@ SlotType::SlotType() :
}
/* Finalizes a instance of the SlotType class. */
SlotType::~SlotType() = default;
/* Decodes DMR slot type. */
void SlotType::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -53,6 +56,7 @@ void SlotType::decode(const uint8_t* data)
}
/* Encodes DMR slot type. */
void SlotType::encode(uint8_t* data) const
{
assert(data != nullptr);

@ -21,6 +21,7 @@ using namespace dmr::defines;
// ---------------------------------------------------------------------------
/* Helper to append DMR data sync bytes to the passed buffer. */
void Sync::addDMRDataSync(uint8_t* data, bool duplex)
{
assert(data != nullptr);
@ -36,6 +37,7 @@ void Sync::addDMRDataSync(uint8_t* data, bool duplex)
}
/* Helper to append DMR voice sync bytes to the passed buffer. */
void Sync::addDMRAudioSync(uint8_t* data, bool duplex)
{
assert(data != nullptr);

@ -22,6 +22,7 @@ RadioIdLookup* AccessControl::m_ridLookup;
TalkgroupRulesLookup* AccessControl::m_tidLookup;
/* Initializes the DMR access control. */
void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup)
{
m_ridLookup = ridLookup;
@ -29,6 +30,7 @@ void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLook
}
/* Helper to validate a source radio ID. */
bool AccessControl::validateSrcId(uint32_t id)
{
// check if RID ACLs are enabled
@ -50,6 +52,7 @@ bool AccessControl::validateSrcId(uint32_t id)
}
/* Helper to validate a talkgroup ID. */
bool AccessControl::validateTGId(uint32_t slotNo, uint32_t id)
{
// TG0 is never valid
@ -80,6 +83,7 @@ bool AccessControl::validateTGId(uint32_t slotNo, uint32_t id)
}
/* Helper to determine if a talkgroup ID is non-preferred. */
bool AccessControl::tgidNonPreferred(uint32_t slotNo, uint32_t id)
{
// TG0 is never valid

@ -24,6 +24,7 @@ using namespace dmr::data;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Data class. */
Data::Data(const Data& data) :
m_slotNo(data.m_slotNo),
m_srcId(data.m_srcId),
@ -41,6 +42,7 @@ Data::Data(const Data& data) :
}
/* Initializes a new instance of the Data class. */
Data::Data() :
m_slotNo(1U),
m_srcId(0U),
@ -57,12 +59,14 @@ Data::Data() :
}
/* Finalizes a instance of the Data class. */
Data::~Data()
{
delete[] m_data;
}
/* Equals operator. */
Data& Data::operator=(const Data& data)
{
if (this != &data) {
@ -83,6 +87,7 @@ Data& Data::operator=(const Data& data)
}
/* Sets raw data. */
void Data::setData(const uint8_t* buffer)
{
assert(buffer != nullptr);
@ -91,6 +96,7 @@ void Data::setData(const uint8_t* buffer)
}
/* Gets raw data. */
uint32_t Data::getData(uint8_t* buffer) const
{
assert(buffer != nullptr);

@ -34,6 +34,7 @@ const uint8_t UDTF_NMEA = 0x05U;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the DataHeader class. */
DataHeader::DataHeader() :
m_GI(false),
m_DPF(DPF::UDT),
@ -62,12 +63,14 @@ DataHeader::DataHeader() :
}
/* Finalizes a instance of the DataHeader class. */
DataHeader::~DataHeader()
{
delete[] m_data;
}
/* Equals operator. */
DataHeader& DataHeader::operator=(const DataHeader& header)
{
if (&header != this) {
@ -100,6 +103,7 @@ DataHeader& DataHeader::operator=(const DataHeader& header)
}
/* Decodes a DMR data header. */
bool DataHeader::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -215,6 +219,7 @@ bool DataHeader::decode(const uint8_t* data)
}
/* Encodes a DMR data header. */
void DataHeader::encode(uint8_t* data) const
{
assert(data != nullptr);

@ -22,6 +22,7 @@ using namespace dmr;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the EMB class. */
EMB::EMB() :
m_colorCode(0U),
m_PI(false),
@ -31,9 +32,11 @@ EMB::EMB() :
}
/* Finalizes a instance of the EMB class. */
EMB::~EMB() = default;
/* Decodes DMR embedded signalling data. */
void EMB::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -53,6 +56,7 @@ void EMB::decode(const uint8_t* data)
}
/* Encodes DMR embedded signalling data. */
void EMB::encode(uint8_t* data) const
{
assert(data != nullptr);

@ -28,6 +28,7 @@ using namespace dmr::data;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the EmbeddedData class. */
EmbeddedData::EmbeddedData() :
m_valid(false),
m_FLCO(FLCO::GROUP),
@ -40,6 +41,7 @@ EmbeddedData::EmbeddedData() :
}
/* Finalizes a instance of the EmbeddedData class. */
EmbeddedData::~EmbeddedData()
{
delete[] m_raw;
@ -47,6 +49,7 @@ EmbeddedData::~EmbeddedData()
}
/* Add LC data (which may consist of 4 blocks) to the data store. */
bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss)
{
assert(data != nullptr);
@ -112,6 +115,7 @@ bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss)
}
/* Get LC data from the data store. */
uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const
{
assert(data != nullptr);
@ -157,6 +161,7 @@ uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const
}
/* Sets link control data. */
void EmbeddedData::setLC(const lc::LC& lc)
{
lc.getData(m_data);
@ -168,6 +173,7 @@ void EmbeddedData::setLC(const lc::LC& lc)
}
/* Gets link control data. */
std::unique_ptr<lc::LC> EmbeddedData::getLC() const
{
if (!m_valid)
@ -180,6 +186,7 @@ std::unique_ptr<lc::LC> EmbeddedData::getLC() const
}
/* Get raw embedded data buffer. */
bool EmbeddedData::getRawData(uint8_t* data) const
{
assert(data != nullptr);
@ -201,6 +208,7 @@ bool EmbeddedData::getRawData(uint8_t* data) const
}
/* Helper to reset data values to defaults. */
void EmbeddedData::reset()
{
m_state = LCS_NONE;
@ -212,6 +220,7 @@ void EmbeddedData::reset()
// ---------------------------------------------------------------------------
/* Unpack and error check an embedded LC. */
void EmbeddedData::decodeEmbeddedData()
{
// the data is unpacked downwards in columns
@ -277,6 +286,7 @@ void EmbeddedData::decodeEmbeddedData()
}
/* Pack and FEC for an embedded LC. */
void EmbeddedData::encodeEmbeddedData()
{
uint32_t crc;

@ -34,12 +34,14 @@ SiteData CSBK::m_siteData = SiteData();
// ---------------------------------------------------------------------------
/* Initializes a copy instance of the CSBK class. */
CSBK::CSBK(const CSBK& data) : CSBK()
{
copy(data);
}
/* Initializes a new instance of the CSBK class. */
CSBK::CSBK() :
m_colorCode(0U),
m_lastBlock(true),
@ -71,6 +73,7 @@ CSBK::CSBK() :
}
/* Finalizes a instance of the CSBK class. */
CSBK::~CSBK()
{
if (m_raw != nullptr)
@ -78,18 +81,21 @@ CSBK::~CSBK()
}
/* Returns a string that represents the current CSBK. */
std::string CSBK::toString()
{
return std::string("CSBKO, UNKNOWN (Unknown CSBK)");
}
/* Returns a copy of the raw decoded CSBK bytes. */
uint8_t* CSBK::getDecodedRaw() const
{
return m_raw;
}
/* Regenerate a DMR CSBK without decoding. */
bool CSBK::regenerate(uint8_t* data, uint8_t dataType)
{
uint8_t csbk[DMR_CSBK_LENGTH_BYTES];
@ -177,6 +183,7 @@ bool CSBK::regenerate(uint8_t* data, uint8_t dataType)
// ---------------------------------------------------------------------------
/* Internal helper to convert payload bytes to a 64-bit long value. */
ulong64_t CSBK::toValue(const uint8_t* payload)
{
ulong64_t value = 0U;
@ -195,6 +202,7 @@ ulong64_t CSBK::toValue(const uint8_t* payload)
}
/* Internal helper to convert a 64-bit long value to payload bytes. */
UInt8Array CSBK::fromValue(const ulong64_t value)
{
UInt8Array payload = std::unique_ptr<uint8_t[]>(new uint8_t[DMR_CSBK_LENGTH_BYTES - 4U]);
@ -214,6 +222,7 @@ UInt8Array CSBK::fromValue(const ulong64_t value)
}
/* Internal helper to decode a control signalling block. */
bool CSBK::decode(const uint8_t* data, uint8_t* payload)
{
assert(data != nullptr);
@ -281,6 +290,7 @@ bool CSBK::decode(const uint8_t* data, uint8_t* payload)
}
/* Internal helper to encode a control signalling block. */
void CSBK::encode(uint8_t* data, const uint8_t* payload)
{
assert(data != nullptr);
@ -339,6 +349,7 @@ void CSBK::encode(uint8_t* data, const uint8_t* payload)
}
/* Internal helper to copy the the class. */
void CSBK::copy(const CSBK& data)
{
m_colorCode = data.m_colorCode;

@ -28,6 +28,7 @@ using namespace dmr::lc;
// ---------------------------------------------------------------------------
/* Initialize a new instance of the FullLC class. */
FullLC::FullLC() :
m_bptc()
{
@ -35,9 +36,11 @@ FullLC::FullLC() :
}
/* Finalizes a instance of the FullLC class. */
FullLC::~FullLC() = default;
/* Decode DMR full-link control data. */
std::unique_ptr<LC> FullLC::decode(const uint8_t* data, DataType::E type)
{
assert(data != nullptr);
@ -72,6 +75,7 @@ std::unique_ptr<LC> FullLC::decode(const uint8_t* data, DataType::E type)
}
/* Encode DMR full-link control data. */
void FullLC::encode(const LC& lc, uint8_t* data, DataType::E type)
{
assert(data != nullptr);
@ -106,6 +110,7 @@ void FullLC::encode(const LC& lc, uint8_t* data, DataType::E type)
}
/* Decode DMR privacy control data. */
std::unique_ptr<PrivacyLC> FullLC::decodePI(const uint8_t* data)
{
assert(data != nullptr);
@ -132,6 +137,7 @@ std::unique_ptr<PrivacyLC> FullLC::decodePI(const uint8_t* data)
}
/* Encode DMR privacy control data. */
void FullLC::encodePI(const PrivacyLC& lc, uint8_t* data)
{
assert(data != nullptr);

@ -24,6 +24,7 @@ using namespace dmr::lc;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the LC class. */
LC::LC(FLCO::E flco, uint32_t srcId, uint32_t dstId) :
m_PF(false),
m_FLCO(flco),
@ -41,6 +42,7 @@ LC::LC(FLCO::E flco, uint32_t srcId, uint32_t dstId) :
}
/* Initializes a new instance of the LC class. */
LC::LC(const uint8_t* data) :
m_PF(false),
m_FLCO(FLCO::GROUP),
@ -74,6 +76,7 @@ LC::LC(const uint8_t* data) :
}
/* Initializes a new instance of the LC class. */
LC::LC(const bool* bits) :
m_PF(false),
m_FLCO(FLCO::GROUP),
@ -120,7 +123,9 @@ LC::LC(const bool* bits) :
m_srcId = s1 << 16 | s2 << 8 | s3; // Source Address
m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address
}
/* Initializes a new instance of the LC class. */
LC::LC() :
m_PF(false),
m_FLCO(FLCO::GROUP),
@ -138,9 +143,11 @@ LC::LC() :
}
/* Finalizes a instance of the LC class. */
LC::~LC() = default;
/* Gets LC data as bytes. */
void LC::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -171,6 +178,7 @@ void LC::getData(uint8_t* data) const
}
/* Gets LC data as bits. */
void LC::getData(bool* bits) const
{
assert(bits != nullptr);

@ -26,6 +26,7 @@ using namespace dmr::lc;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the PrivacyLC class. */
PrivacyLC::PrivacyLC(const uint8_t* data) :
m_FID(FID_ETSI),
m_dstId(0U),
@ -51,7 +52,9 @@ PrivacyLC::PrivacyLC(const uint8_t* data) :
m_dstId = data[7U] << 16 | data[8U] << 8 | data[9U]; // Destination Address
}
/* Initializes a new instance of the PrivacyLC class. */
PrivacyLC::PrivacyLC(const bool* bits) :
m_FID(FID_ETSI),
m_dstId(0U),
@ -94,7 +97,9 @@ PrivacyLC::PrivacyLC(const bool* bits) :
m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address
}
/* Initializes a new instance of the PrivacyLC class. */
PrivacyLC::PrivacyLC() :
m_FID(FID_ETSI),
m_dstId(0U),
@ -107,12 +112,14 @@ PrivacyLC::PrivacyLC() :
}
/* Finalizes a instance of the PrivacyLC class. */
PrivacyLC::~PrivacyLC()
{
delete m_mi;
}
/* Gets LC data as bytes. */
void PrivacyLC::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -134,6 +141,7 @@ void PrivacyLC::getData(uint8_t* data) const
}
/* Gets LC data as bits. */
void PrivacyLC::getData(bool* bits) const
{
assert(bits != nullptr);

@ -22,6 +22,7 @@ using namespace dmr::lc;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the ShortLC class. */
ShortLC::ShortLC() :
m_rawData(nullptr),
m_deInterData(nullptr)
@ -31,6 +32,7 @@ ShortLC::ShortLC() :
}
/* Finalizes a instance of the ShortLC class. */
ShortLC::~ShortLC()
{
delete[] m_rawData;
@ -38,6 +40,7 @@ ShortLC::~ShortLC()
}
/* Decode DMR short-link control data. */
bool ShortLC::decode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -61,6 +64,7 @@ bool ShortLC::decode(const uint8_t* in, uint8_t* out)
}
/* Encode DMR short-link control data. */
void ShortLC::encode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -84,6 +88,7 @@ void ShortLC::encode(const uint8_t* in, uint8_t* out)
// ---------------------------------------------------------------------------
/* */
void ShortLC::decodeExtractBinary(const uint8_t* in)
{
assert(in != nullptr);
@ -100,6 +105,7 @@ void ShortLC::decodeExtractBinary(const uint8_t* in)
}
/* */
void ShortLC::decodeDeInterleave()
{
for (uint32_t i = 0U; i < 68U; i++)
@ -116,6 +122,7 @@ void ShortLC::decodeDeInterleave()
}
/* */
bool ShortLC::decodeErrorCheck()
{
// run through each of the 3 rows containing data
@ -134,6 +141,7 @@ bool ShortLC::decodeErrorCheck()
}
/* */
void ShortLC::decodeExtractData(uint8_t* data) const
{
assert(data != nullptr);
@ -161,6 +169,7 @@ void ShortLC::decodeExtractData(uint8_t* data) const
}
/* */
void ShortLC::encodeExtractData(const uint8_t* in) const
{
assert(in != nullptr);
@ -187,6 +196,7 @@ void ShortLC::encodeExtractData(const uint8_t* in) const
}
/* */
void ShortLC::encodeErrorCheck()
{
// run through each of the 3 rows containing data
@ -200,6 +210,7 @@ void ShortLC::encodeErrorCheck()
}
/* */
void ShortLC::encodeInterleave()
{
for (uint32_t i = 0U; i < 72U; i++)
@ -217,6 +228,7 @@ void ShortLC::encodeInterleave()
}
/* */
void ShortLC::encodeExtractBinary(uint8_t* data)
{
assert(data != nullptr);

@ -26,12 +26,15 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBKFactory class. */
CSBKFactory::CSBKFactory() = default;
/* Finalizes a instance of CSBKFactory class. */
CSBKFactory::~CSBKFactory() = default;
/* Create an instance of a CSBK. */
std::unique_ptr<CSBK> CSBKFactory::createCSBK(const uint8_t* data, DataType::E dataType)
{
assert(data != nullptr);
@ -125,6 +128,7 @@ std::unique_ptr<CSBK> CSBKFactory::createCSBK(const uint8_t* data, DataType::E d
// ---------------------------------------------------------------------------
/* Decode a CSBK. */
std::unique_ptr<CSBK> CSBKFactory::decode(CSBK* csbk, const uint8_t* data)
{
assert(csbk != nullptr);

@ -12,7 +12,7 @@
*/
/**
* @defgroup dmr_csbk Control Signalling Block
* @brief Implementation for the data handling of the ETSI TS-102 control signalling block (CSBK).
* @brief Implementation for the data handling of the ETSI TS-102 control signalling block (CSBK)
* @ingroup dmr_lc
*
* @file CSBKFactory.h

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_ACK_RSP class. */
CSBK_ACK_RSP::CSBK_ACK_RSP() : CSBK()
{
m_CSBKO = CSBKO::ACK_RSP;
}
/* Decode a control signalling block. */
bool CSBK_ACK_RSP::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -50,6 +52,7 @@ bool CSBK_ACK_RSP::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_ACK_RSP::encode(uint8_t* data)
{
assert(data != nullptr);
@ -72,6 +75,7 @@ void CSBK_ACK_RSP::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_ACK_RSP::toString()
{
return std::string("CSBKO, ACK_RSP (Acknowledge Response)");

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_ALOHA class. */
CSBK_ALOHA::CSBK_ALOHA() : CSBK(),
m_siteTSSync(false),
m_alohaMask(0U),
@ -32,6 +33,7 @@ CSBK_ALOHA::CSBK_ALOHA() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_ALOHA::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -42,6 +44,7 @@ bool CSBK_ALOHA::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_ALOHA::encode(uint8_t* data)
{
assert(data != nullptr);
@ -66,6 +69,7 @@ void CSBK_ALOHA::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_ALOHA::toString()
{
return std::string("CSBKO, ALOHA (Aloha PDU)");
@ -76,6 +80,7 @@ std::string CSBK_ALOHA::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_ALOHA::copy(const CSBK_ALOHA& data)
{
CSBK::copy(data);

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_BROADCAST class. */
CSBK_BROADCAST::CSBK_BROADCAST() : CSBK(),
m_anncType(BroadcastAnncType::SITE_PARMS),
m_hibernating(false),
@ -35,6 +36,7 @@ CSBK_BROADCAST::CSBK_BROADCAST() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_BROADCAST::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -72,6 +74,7 @@ bool CSBK_BROADCAST::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_BROADCAST::encode(uint8_t* data)
{
assert(data != nullptr);
@ -157,6 +160,7 @@ void CSBK_BROADCAST::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_BROADCAST::toString()
{
switch (m_anncType) {
@ -172,6 +176,7 @@ std::string CSBK_BROADCAST::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_BROADCAST::copy(const CSBK_BROADCAST& data)
{
CSBK::copy(data);

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_BSDWNACT class. */
CSBK_BSDWNACT::CSBK_BSDWNACT() : CSBK(),
m_bsId(0U)
{
@ -29,6 +30,7 @@ CSBK_BSDWNACT::CSBK_BSDWNACT() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_BSDWNACT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -49,6 +51,7 @@ bool CSBK_BSDWNACT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_BSDWNACT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -57,6 +60,7 @@ void CSBK_BSDWNACT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_BSDWNACT::toString()
{
return std::string("CSBKO, BSDWNACT (BS Outbound Activation)");
@ -67,6 +71,7 @@ std::string CSBK_BSDWNACT::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_BSDWNACT::copy(const CSBK_BSDWNACT& data)
{
CSBK::copy(data);

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_CALL_ALRT class. */
CSBK_CALL_ALRT::CSBK_CALL_ALRT() : CSBK()
{
m_CSBKO = CSBKO::RAND;
@ -29,6 +30,7 @@ CSBK_CALL_ALRT::CSBK_CALL_ALRT() : CSBK()
}
/* Decode a control signalling block. */
bool CSBK_CALL_ALRT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -50,6 +52,7 @@ bool CSBK_CALL_ALRT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_CALL_ALRT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -65,6 +68,7 @@ void CSBK_CALL_ALRT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_CALL_ALRT::toString()
{
return std::string("CSBKO, RAND (Call Alert)");

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_EXT_FNCT class. */
CSBK_EXT_FNCT::CSBK_EXT_FNCT() : CSBK(),
m_extendedFunction(ExtendedFunctions::CHECK)
{
@ -30,6 +31,7 @@ CSBK_EXT_FNCT::CSBK_EXT_FNCT() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_EXT_FNCT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -52,6 +54,7 @@ bool CSBK_EXT_FNCT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_EXT_FNCT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -70,6 +73,7 @@ void CSBK_EXT_FNCT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_EXT_FNCT::toString()
{
return std::string("CSBKO, EXT_FNCT (Extended Function)");
@ -80,6 +84,7 @@ std::string CSBK_EXT_FNCT::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_EXT_FNCT::copy(const CSBK_EXT_FNCT& data)
{
CSBK::copy(data);

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_MAINT class. */
CSBK_MAINT::CSBK_MAINT() : CSBK(),
m_maintKind(0U)
{
@ -29,6 +30,7 @@ CSBK_MAINT::CSBK_MAINT() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_MAINT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -50,6 +52,7 @@ bool CSBK_MAINT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_MAINT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -65,6 +68,7 @@ void CSBK_MAINT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_MAINT::toString()
{
return std::string("CSBKO, MAINT (Call Maintainence)");
@ -75,6 +79,7 @@ std::string CSBK_MAINT::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_MAINT::copy(const CSBK_MAINT& data)
{
CSBK::copy(data);

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_NACK_RSP class. */
CSBK_NACK_RSP::CSBK_NACK_RSP() : CSBK(),
m_serviceKind(0U)
{
@ -29,6 +30,7 @@ CSBK_NACK_RSP::CSBK_NACK_RSP() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_NACK_RSP::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -52,6 +54,7 @@ bool CSBK_NACK_RSP::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_NACK_RSP::encode(uint8_t* data)
{
assert(data != nullptr);
@ -70,6 +73,7 @@ void CSBK_NACK_RSP::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_NACK_RSP::toString()
{
return std::string("CSBKO, NACK_RSP (Negative Acknowledgement Response)");
@ -80,6 +84,7 @@ std::string CSBK_NACK_RSP::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_NACK_RSP::copy(const CSBK_NACK_RSP& data)
{
CSBK::copy(data);

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_PD_GRANT class. */
CSBK_PD_GRANT::CSBK_PD_GRANT() : CSBK()
{
m_CSBKO = CSBKO::PD_GRANT;
}
/* Decode a control signalling block. */
bool CSBK_PD_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -38,6 +40,7 @@ bool CSBK_PD_GRANT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_PD_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -57,6 +60,7 @@ void CSBK_PD_GRANT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_PD_GRANT::toString()
{
return std::string("CSBKO, PD_GRANT (Private Data Channel Grant)");

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_PRECCSBK class. */
CSBK_PRECCSBK::CSBK_PRECCSBK() : CSBK()
{
m_CSBKO = CSBKO::PRECCSBK;
}
/* Decode a control signalling block. */
bool CSBK_PRECCSBK::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -51,6 +53,7 @@ bool CSBK_PRECCSBK::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_PRECCSBK::encode(uint8_t* data)
{
assert(data != nullptr);
@ -59,6 +62,7 @@ void CSBK_PRECCSBK::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_PRECCSBK::toString()
{
return std::string("CSBKO, PRECCSBK (Preamble CSBK)");

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_PV_GRANT class. */
CSBK_PV_GRANT::CSBK_PV_GRANT() : CSBK()
{
m_CSBKO = CSBKO::PV_GRANT;
}
/* Decode a control signalling block. */
bool CSBK_PV_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -38,6 +40,7 @@ bool CSBK_PV_GRANT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_PV_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -57,6 +60,7 @@ void CSBK_PV_GRANT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_PV_GRANT::toString()
{
return std::string("CSBKO, PV_GRANT (Private Voice Channel Grant)");

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_P_CLEAR class. */
CSBK_P_CLEAR::CSBK_P_CLEAR() : CSBK()
{
m_CSBKO = CSBKO::P_CLEAR;
}
/* Decode a control signalling block. */
bool CSBK_P_CLEAR::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -38,6 +40,7 @@ bool CSBK_P_CLEAR::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_P_CLEAR::encode(uint8_t* data)
{
assert(data != nullptr);
@ -56,6 +59,7 @@ void CSBK_P_CLEAR::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_P_CLEAR::toString()
{
return std::string("CSBKO, P_CLEAR (Payload Channel Clear)");

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_P_GRANT class. */
CSBK_P_GRANT::CSBK_P_GRANT() : CSBK()
{
m_CSBKO = CSBKO::TV_GRANT;
}
/* Decode a control signalling block. */
bool CSBK_P_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -38,6 +40,7 @@ bool CSBK_P_GRANT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_P_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -57,6 +60,7 @@ void CSBK_P_GRANT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_P_GRANT::toString()
{
return std::string("CSBKO, P_GRANT (Payload Grant)");

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_RAND class. */
CSBK_RAND::CSBK_RAND() : CSBK(),
m_serviceOptions(0U),
m_serviceExtra(0U),
@ -31,6 +32,7 @@ CSBK_RAND::CSBK_RAND() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_RAND::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -55,6 +57,7 @@ bool CSBK_RAND::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_RAND::encode(uint8_t* data)
{
assert(data != nullptr);
@ -73,6 +76,7 @@ void CSBK_RAND::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_RAND::toString()
{
switch (m_serviceKind) {
@ -98,6 +102,7 @@ std::string CSBK_RAND::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_RAND::copy(const CSBK_RAND& data)
{
CSBK::copy(data);

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_RAW class. */
CSBK_RAW::CSBK_RAW() : CSBK(),
m_csbk(nullptr)
{
@ -29,6 +30,7 @@ CSBK_RAW::CSBK_RAW() : CSBK(),
}
/* Finalizes a new instance of the CSBK_RAW class. */
CSBK_RAW::~CSBK_RAW()
{
if (m_csbk != nullptr) {
@ -37,6 +39,7 @@ CSBK_RAW::~CSBK_RAW()
}
/* Decode a control signalling block. */
bool CSBK_RAW::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -47,6 +50,7 @@ bool CSBK_RAW::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_RAW::encode(uint8_t* data)
{
assert(data != nullptr);
@ -58,6 +62,7 @@ void CSBK_RAW::encode(uint8_t* data)
}
/* Sets the CSBK to encode. */
void CSBK_RAW::setCSBK(const uint8_t* csbk)
{
assert(csbk != nullptr);

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_TD_GRANT class. */
CSBK_TD_GRANT::CSBK_TD_GRANT() : CSBK()
{
m_CSBKO = CSBKO::TD_GRANT;
}
/* Decode a control signalling block. */
bool CSBK_TD_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -38,6 +40,7 @@ bool CSBK_TD_GRANT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_TD_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -57,6 +60,7 @@ void CSBK_TD_GRANT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_TD_GRANT::toString()
{
return std::string("CSBKO, TD_GRANT (Talkgroup Data Channel Grant)");

@ -22,6 +22,7 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_TV_GRANT class. */
CSBK_TV_GRANT::CSBK_TV_GRANT() : CSBK(),
m_lateEntry(false)
{
@ -29,6 +30,7 @@ CSBK_TV_GRANT::CSBK_TV_GRANT() : CSBK(),
}
/* Decode a control signalling block. */
bool CSBK_TV_GRANT::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -39,6 +41,7 @@ bool CSBK_TV_GRANT::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_TV_GRANT::encode(uint8_t* data)
{
assert(data != nullptr);
@ -58,6 +61,7 @@ void CSBK_TV_GRANT::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_TV_GRANT::toString()
{
return std::string("CSBKO, TV_GRANT (Talkgroup Voice Channel Grant)");
@ -68,6 +72,7 @@ std::string CSBK_TV_GRANT::toString()
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CSBK_TV_GRANT::copy(const CSBK_TV_GRANT& data)
{
CSBK::copy(data);

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_UU_ANS_RSP class. */
CSBK_UU_ANS_RSP::CSBK_UU_ANS_RSP() : CSBK()
{
m_CSBKO = CSBKO::UU_ANS_RSP;
}
/* Decode a control signalling block. */
bool CSBK_UU_ANS_RSP::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -48,6 +50,7 @@ bool CSBK_UU_ANS_RSP::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_UU_ANS_RSP::encode(uint8_t* data)
{
assert(data != nullptr);
@ -56,6 +59,7 @@ void CSBK_UU_ANS_RSP::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_UU_ANS_RSP::toString()
{
return std::string("CSBKO, UU_ANS_RSP (Unit-to-Unit Answer Response)");

@ -22,12 +22,14 @@ using namespace dmr::lc::csbk;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CSBK_UU_V_REQ class. */
CSBK_UU_V_REQ::CSBK_UU_V_REQ() : CSBK()
{
m_CSBKO = CSBKO::UU_V_REQ;
}
/* Decode a control signalling block. */
bool CSBK_UU_V_REQ::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -48,6 +50,7 @@ bool CSBK_UU_V_REQ::decode(const uint8_t* data)
}
/* Encode a control signalling block. */
void CSBK_UU_V_REQ::encode(uint8_t* data)
{
assert(data != nullptr);
@ -56,6 +59,7 @@ void CSBK_UU_V_REQ::encode(uint8_t* data)
}
/* Returns a string that represents the current CSBK. */
std::string CSBK_UU_V_REQ::toString()
{
return std::string("CSBKO, UU_V_REQ (Unit-to-Unit Voice Channel Request)");

@ -26,12 +26,15 @@ using namespace edac;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the AMBEFEC class. */
AMBEFEC::AMBEFEC() = default;
/* Finalizes a instance of the AMBEFEC class. */
AMBEFEC::~AMBEFEC() = default;
/* Regenerates the DMR AMBE FEC for the input bytes. */
uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -135,6 +138,7 @@ uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const
}
/* Returns the number of errors on the DMR BER input bytes. */
uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -199,6 +203,7 @@ uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const
}
/* Regenerates the P25 IMBE FEC for the input bytes. */
uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -334,6 +339,7 @@ uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const
}
/* Returns the number of errors on the P25 BER input bytes. */
uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -463,6 +469,7 @@ uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const
}
/* Regenerates the NXDN AMBE FEC for the input bytes. */
uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -515,6 +522,7 @@ uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const
}
/* Returns the number of errors on the NXDN BER input bytes. */
uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const
{
assert(bytes != nullptr);
@ -552,6 +560,7 @@ uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const
// ---------------------------------------------------------------------------
/* */
uint32_t AMBEFEC::regenerate(uint32_t& a, uint32_t& b, uint32_t& c) const
{
uint32_t old_a = a;

@ -100,12 +100,15 @@ const int g[] = {
// ---------------------------------------------------------------------------
/* Initializes a new instance of the BCH class. */
BCH::BCH() = default;
/* Finalizes a instance of the BCH class. */
BCH::~BCH() = default;
/* Encodes input data with BCH. */
void BCH::encode(uint8_t* nid)
{
assert(nid != nullptr);
@ -129,6 +132,7 @@ void BCH::encode(uint8_t* nid)
/* Compute redundancy bb[], the coefficients of b(x). The redundancy polynomial b(x) is the
remainder after dividing x^(length-k)*data(x) by the generator polynomial g(x). */
void BCH::encode(const int* data, int* bb)
{
for (int i = 0; i < length - k; i++)

@ -22,6 +22,7 @@ using namespace edac;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the BPTC19696 class. */
BPTC19696::BPTC19696() :
m_rawData(nullptr),
m_deInterData(nullptr)
@ -31,6 +32,7 @@ BPTC19696::BPTC19696() :
}
/* Finalizes a instance of the BPTC19696 class. */
BPTC19696::~BPTC19696()
{
delete[] m_rawData;
@ -38,6 +40,7 @@ BPTC19696::~BPTC19696()
}
/* Decode BPTC (196,96) FEC. */
void BPTC19696::decode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -57,6 +60,7 @@ void BPTC19696::decode(const uint8_t* in, uint8_t* out)
}
/* Encode BPTC (196,96) FEC. */
void BPTC19696::encode(const uint8_t* in, uint8_t* out)
{
assert(in != nullptr);
@ -80,6 +84,7 @@ void BPTC19696::encode(const uint8_t* in, uint8_t* out)
// ---------------------------------------------------------------------------
/* */
void BPTC19696::decodeExtractBinary(const uint8_t* in)
{
// first block
@ -119,6 +124,7 @@ void BPTC19696::decodeExtractBinary(const uint8_t* in)
}
/* */
void BPTC19696::decodeDeInterleave()
{
for (uint32_t i = 0U; i < 196U; i++)
@ -134,6 +140,7 @@ void BPTC19696::decodeDeInterleave()
}
/* */
void BPTC19696::decodeErrorCheck()
{
bool fixing;
@ -173,6 +180,7 @@ void BPTC19696::decodeErrorCheck()
}
/* */
void BPTC19696::decodeExtractData(uint8_t* data) const
{
bool bData[96U];
@ -219,6 +227,7 @@ void BPTC19696::decodeExtractData(uint8_t* data) const
}
/* */
void BPTC19696::encodeExtractData(const uint8_t* in) const
{
bool bData[96U];
@ -268,6 +277,7 @@ void BPTC19696::encodeExtractData(const uint8_t* in) const
}
/* */
void BPTC19696::encodeErrorCheck()
{
// run through each of the 9 rows containing data
@ -296,6 +306,7 @@ void BPTC19696::encodeErrorCheck()
}
/* */
void BPTC19696::encodeInterleave()
{
for (uint32_t i = 0U; i < 196U; i++)
@ -311,6 +322,7 @@ void BPTC19696::encodeInterleave()
}
/* */
void BPTC19696::encodeExtractBinary(uint8_t* data)
{
// first block

@ -152,6 +152,7 @@ const uint32_t CRC32_TABLE[] = {
// ---------------------------------------------------------------------------
/* Check 5-bit CRC. */
bool CRC::checkFiveBit(bool* in, uint32_t tcrc)
{
assert(in != nullptr);
@ -163,6 +164,7 @@ bool CRC::checkFiveBit(bool* in, uint32_t tcrc)
}
/* Encode 5-bit CRC. */
void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc)
{
assert(in != nullptr);
@ -180,6 +182,7 @@ void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc)
}
/* Check 16-bit CRC CCITT-162. */
bool CRC::checkCCITT162(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -206,6 +209,7 @@ bool CRC::checkCCITT162(const uint8_t *in, uint32_t length)
}
/* Encode 16-bit CRC CCITT-162. */
void CRC::addCCITT162(uint8_t* in, uint32_t length)
{
assert(in != nullptr);
@ -232,6 +236,7 @@ void CRC::addCCITT162(uint8_t* in, uint32_t length)
}
/* Check 16-bit CRC CCITT-161. */
bool CRC::checkCCITT161(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -258,6 +263,7 @@ bool CRC::checkCCITT161(const uint8_t *in, uint32_t length)
}
/* Encode 16-bit CRC CCITT-161. */
void CRC::addCCITT161(uint8_t* in, uint32_t length)
{
assert(in != nullptr);
@ -284,6 +290,7 @@ void CRC::addCCITT161(uint8_t* in, uint32_t length)
}
/* Check 32-bit CRC. */
bool CRC::checkCRC32(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -314,6 +321,7 @@ bool CRC::checkCRC32(const uint8_t *in, uint32_t length)
}
/* Encode 32-bit CRC. */
void CRC::addCRC32(uint8_t* in, uint32_t length)
{
assert(in != nullptr);
@ -346,6 +354,7 @@ void CRC::addCRC32(uint8_t* in, uint32_t length)
}
/* Generate 8-bit CRC. */
uint8_t CRC::crc8(const uint8_t *in, uint32_t length)
{
assert(in != nullptr);
@ -363,6 +372,7 @@ uint8_t CRC::crc8(const uint8_t *in, uint32_t length)
}
/* Check 6-bit CRC. */
bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -386,6 +396,7 @@ bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength)
}
/* Encode 6-bit CRC. */
uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -406,6 +417,7 @@ uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength)
}
/* Check 12-bit CRC. */
bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -433,6 +445,7 @@ bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength)
}
/* Encode 12-bit CRC. */
uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -456,6 +469,7 @@ uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength)
}
/* Check 15-bit CRC. */
bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -483,6 +497,7 @@ bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength)
}
/* Encode 15-bit CRC. */
uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -506,6 +521,7 @@ uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength)
}
/* Check 16-bit CRC CCITT-162 w/ initial generator of 1. */
bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -533,6 +549,7 @@ bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength)
}
/* Encode 16-bit CRC CCITT-162 w/ initial generator of 1. */
uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength)
{
assert(in != nullptr);
@ -556,6 +573,7 @@ uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength)
}
/* Generate 9-bit CRC. */
uint16_t CRC::createCRC9(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0U;
@ -575,6 +593,7 @@ uint16_t CRC::createCRC9(const uint8_t* in, uint32_t bitLength)
}
/* Generate 16-bit CRC. */
uint16_t CRC::createCRC16(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0xFFFFU;
@ -597,6 +616,7 @@ uint16_t CRC::createCRC16(const uint8_t* in, uint32_t bitLength)
// ---------------------------------------------------------------------------
/* Generate 6-bit CRC. */
uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength)
{
uint8_t crc = 0x3FU;
@ -615,6 +635,7 @@ uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength)
}
/* Generate 12-bit CRC. */
uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0x0FFFU;
@ -633,6 +654,7 @@ uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength)
}
/* Generate 15-bit CRC. */
uint16_t CRC::createCRC15(const uint8_t* in, uint32_t bitLength)
{
uint16_t crc = 0x7FFFU;

@ -213,6 +213,7 @@ const uint32_t DECODING_TABLE_1987[] = {
// ---------------------------------------------------------------------------
/* Decode Golay (20,8,7) FEC. */
uint8_t Golay2087::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -228,6 +229,7 @@ uint8_t Golay2087::decode(const uint8_t* data)
}
/* Encode Golay (20,8,7) FEC. */
void Golay2087::encode(uint8_t* data)
{
assert(data != nullptr);
@ -249,6 +251,7 @@ void Golay2087::encode(uint8_t* data)
polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits,
when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding
table; and (3) pattern = received vector, to obtain its syndrome in decoding. */
uint32_t Golay2087::getSyndrome1987(uint32_t pattern)
{
uint32_t aux = X18;

@ -1062,6 +1062,7 @@ static const uint32_t DECODING_TABLE_23127[] = {
// ---------------------------------------------------------------------------
/* Decode Golay (23,12,7) FEC. */
uint32_t Golay24128::decode23127(uint32_t code)
{
uint32_t syndrome = getSyndrome23127(code);
@ -1073,6 +1074,7 @@ uint32_t Golay24128::decode23127(uint32_t code)
}
/* Decode Golay (24,12,8) FEC. */
bool Golay24128::decode24128(uint32_t code, uint32_t& out)
{
uint32_t syndrome = getSyndrome23127(code >> 1);
@ -1087,6 +1089,7 @@ bool Golay24128::decode24128(uint32_t code, uint32_t& out)
}
/* Decode Golay (24,12,8) FEC. */
bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out)
{
assert(bytes != nullptr);
@ -1096,6 +1099,7 @@ bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out)
}
/* Decode Golay (24,12,8) FEC. */
void Golay24128::decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
{
uint32_t i = 0; // decoded byte counter
@ -1153,18 +1157,21 @@ void Golay24128::decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
}
/* Encode Golay (23,12,7) FEC. */
uint32_t Golay24128::encode23127(uint32_t data)
{
return ENCODING_TABLE_23127[data];
}
/* Encode Golay (24,12,8) FEC. */
uint32_t Golay24128::encode24128(uint32_t data)
{
return ENCODING_TABLE_24128[data];
}
/* Encode Golay (24,12,8) FEC. */
void Golay24128::encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
{
uint32_t j = 0;
@ -1231,6 +1238,7 @@ void Golay24128::encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen)
polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits,
when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding
table; and (3) pattern = received vector, to obtain its syndrome in decoding. */
uint32_t Golay24128::getSyndrome23127(uint32_t pattern)
{
uint32_t aux = X22;

@ -18,6 +18,7 @@ using namespace edac;
// ---------------------------------------------------------------------------
/* Decode Hamming (15,11,3). */
bool Hamming::decode15113_1(bool* d)
{
assert(d != nullptr);
@ -60,6 +61,7 @@ bool Hamming::decode15113_1(bool* d)
}
/* Encode Hamming (15,11,3). */
void Hamming::encode15113_1(bool* d)
{
assert(d != nullptr);
@ -72,6 +74,7 @@ void Hamming::encode15113_1(bool* d)
}
/* Decode Hamming (15,11,3). */
bool Hamming::decode15113_2(bool* d)
{
assert(d != nullptr);
@ -114,6 +117,7 @@ bool Hamming::decode15113_2(bool* d)
}
/* Encode Hamming (15,11,3). */
void Hamming::encode15113_2(bool* d)
{
assert(d != nullptr);
@ -126,6 +130,7 @@ void Hamming::encode15113_2(bool* d)
}
/* Decode Hamming (13,9,3). */
bool Hamming::decode1393(bool* d)
{
assert(d != nullptr);
@ -166,6 +171,7 @@ bool Hamming::decode1393(bool* d)
}
/* Encode Hamming (13,9,3). */
void Hamming::encode1393(bool* d)
{
assert(d != nullptr);
@ -178,6 +184,7 @@ void Hamming::encode1393(bool* d)
}
/* Decode Hamming (10,6,3). */
bool Hamming::decode1063(bool* d)
{
assert(d != nullptr);
@ -215,6 +222,7 @@ bool Hamming::decode1063(bool* d)
}
/* Encode Hamming (10,6,3). */
void Hamming::encode1063(bool* d)
{
assert(d != nullptr);
@ -227,6 +235,7 @@ void Hamming::encode1063(bool* d)
}
/* Decode Hamming (16,11,4). */
bool Hamming::decode16114(bool* d)
{
assert(d != nullptr);
@ -276,6 +285,7 @@ bool Hamming::decode16114(bool* d)
}
/* Encode Hamming (10,6,3). */
void Hamming::encode16114(bool* d)
{
assert(d != nullptr);
@ -288,6 +298,7 @@ void Hamming::encode16114(bool* d)
}
/* Decode Hamming (17,12,3). */
bool Hamming::decode17123(bool* d)
{
assert(d != nullptr);
@ -338,6 +349,7 @@ bool Hamming::decode17123(bool* d)
}
/* Encode Hamming (17,12,3). */
void Hamming::encode17123(bool* d)
{
assert(d != nullptr);

@ -65,6 +65,7 @@ const uint32_t DECODING_TABLE_1576[] = {
// ---------------------------------------------------------------------------
/* Decode QR (16,7,6) FEC. */
uint8_t QR1676::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -79,6 +80,7 @@ uint8_t QR1676::decode(const uint8_t* data)
}
/* Encode QR (16,7,6) FEC. */
void QR1676::encode(uint8_t* data)
{
assert(data != nullptr);
@ -99,6 +101,7 @@ void QR1676::encode(uint8_t* data)
polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits,
when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding
table; and (3) pattern = received vector, to obtain its syndrome in decoding. */
uint32_t QR1676::getSyndrome1576(uint32_t pattern)
{
uint32_t aux = X14;

@ -83,6 +83,7 @@ const uint8_t LOG_TABLE[] = {
// ---------------------------------------------------------------------------
/* Check RS (12,9) FEC. */
bool RS129::check(const uint8_t* in)
{
assert(in != nullptr);
@ -96,6 +97,7 @@ bool RS129::check(const uint8_t* in)
/* Encode RS (12,9) FEC. */
/* Simulate a LFSR with generator polynomial for n byte RS code. Pass in a pointer to the data
array, and amount of data. The parity bytes are deposited into parity. */
void RS129::encode(const uint8_t* msg, uint32_t nbytes, uint8_t* parity)
{
assert(msg != nullptr);
@ -119,6 +121,7 @@ void RS129::encode(const uint8_t* msg, uint32_t nbytes, uint8_t* parity)
// ---------------------------------------------------------------------------
/* */
uint8_t RS129::gmult(uint8_t a, uint8_t b)
{
if (a == 0U || b == 0U)

@ -134,12 +134,15 @@ RS6355 rs24169; // 8 bit / 4 bit corrections max / 2 bytes total
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RS634717 class. */
RS634717::RS634717() = default;
/* Finalizes a instance of the RS634717 class. */
RS634717::~RS634717() = default;
/* Decode RS (24,12,13) FEC. */
bool RS634717::decode241213(uint8_t* data)
{
assert(data != nullptr);
@ -166,6 +169,7 @@ bool RS634717::decode241213(uint8_t* data)
}
/* Encode RS (24,12,13) FEC. */
void RS634717::encode241213(uint8_t* data)
{
assert(data != nullptr);
@ -188,6 +192,7 @@ void RS634717::encode241213(uint8_t* data)
}
/* Decode RS (24,16,9) FEC. */
bool RS634717::decode24169(uint8_t* data)
{
assert(data != nullptr);
@ -214,6 +219,7 @@ bool RS634717::decode24169(uint8_t* data)
}
/* Encode RS (24,16,9) FEC. */
void RS634717::encode24169(uint8_t* data)
{
assert(data != nullptr);
@ -236,6 +242,7 @@ void RS634717::encode24169(uint8_t* data)
}
/* Decode RS (36,20,17) FEC. */
bool RS634717::decode362017(uint8_t* data)
{
assert(data != nullptr);
@ -262,6 +269,7 @@ bool RS634717::decode362017(uint8_t* data)
}
/* Encode RS (36,20,17) FEC. */
void RS634717::encode362017(uint8_t* data)
{
assert(data != nullptr);
@ -288,6 +296,7 @@ void RS634717::encode362017(uint8_t* data)
// ---------------------------------------------------------------------------
/* GF(2 ^ 6) multiply (for Reed-Solomon encoder). */
uint8_t RS634717::gf6Mult(uint8_t a, uint8_t b) const
{
uint8_t p = 0x00U;

@ -92,6 +92,7 @@ static inline void set_uint32(uint8_t* cp, uint32_t v)
/* Takes a pointer to a 256 bit block of data (eight 32 bit ints) and initializes it to the start
constants of the SHA256 algorithm. This must be called before using hash in the call to
sha256_hash */
SHA256::SHA256() :
m_state(nullptr),
m_total(nullptr),
@ -106,6 +107,7 @@ SHA256::SHA256() :
}
/* Finalizes a instance of the SHA256 class. */
SHA256::~SHA256()
{
delete[] m_state;
@ -118,6 +120,7 @@ SHA256::~SHA256()
of 64!!! */
/* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. Most
of this code comes from GnuPG's cipher/sha1.c. */
void SHA256::processBlock(const uint8_t* buffer, uint32_t len)
{
assert(buffer != nullptr);
@ -243,6 +246,7 @@ void SHA256::processBlock(const uint8_t* buffer, uint32_t len)
/* Starting with the result of former calls of this function (or the initialization function update
the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of
64. */
void SHA256::processBytes(const uint8_t* buffer, uint32_t len)
{
assert(buffer != nullptr);
@ -296,6 +300,7 @@ void SHA256::processBytes(const uint8_t* buffer, uint32_t len)
/* Process the remaining bytes in the buffer and put result from context in first 32 bytes following
buffer. The result is always in little endian byte order, so that a byte - wise output yields to
the wanted ASCII representation of the message digest. */
uint8_t* SHA256::finish(uint8_t* buffer)
{
assert(buffer != nullptr);
@ -308,6 +313,7 @@ uint8_t* SHA256::finish(uint8_t* buffer)
/* Put result from context in first 32 bytes following buffer. The result is always in little endian
byte order, so that a byte - wise output yields to the wanted ASCII representation of the message
digest. */
uint8_t* SHA256::read(uint8_t* buffer)
{
assert(buffer != nullptr);
@ -321,6 +327,7 @@ uint8_t* SHA256::read(uint8_t* buffer)
/* Compute SHA256 message digest for the length bytes beginning at buffer. The result is always in
little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of
the message digest. */
uint8_t* SHA256::buffer(const uint8_t* buffer, uint32_t len, uint8_t* resblock)
{
assert(buffer != nullptr);
@ -341,6 +348,7 @@ uint8_t* SHA256::buffer(const uint8_t* buffer, uint32_t len, uint8_t* resblock)
// ---------------------------------------------------------------------------
/* Initialize SHA256 machine states. */
void SHA256::init()
{
m_state[0] = 0x6a09e667UL;
@ -358,6 +366,7 @@ void SHA256::init()
/* Process the remaining bytes in the internal buffer and the usual prolog according to the standard
and write the result to the buffer. */
void SHA256::conclude()
{
// Take yet unprocessed bytes into account.

@ -48,12 +48,15 @@ const uint8_t ENCODE_TABLE_12[] = {
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Trellis class. */
Trellis::Trellis() = default;
/* Finalizes a instance of the Trellis class. */
Trellis::~Trellis() = default;
/* Decodes 3/4 rate Trellis. */
bool Trellis::decode34(const uint8_t* data, uint8_t* payload)
{
assert(data != nullptr);
@ -89,6 +92,7 @@ bool Trellis::decode34(const uint8_t* data, uint8_t* payload)
}
/* Encodes 3/4 rate Trellis. */
void Trellis::encode34(const uint8_t* payload, uint8_t* data)
{
assert(payload != nullptr);
@ -115,6 +119,7 @@ void Trellis::encode34(const uint8_t* payload, uint8_t* data)
}
/* Decodes 1/2 rate Trellis. */
bool Trellis::decode12(const uint8_t* data, uint8_t* payload)
{
assert(data != nullptr);
@ -150,6 +155,7 @@ bool Trellis::decode12(const uint8_t* data, uint8_t* payload)
}
/* Encodes 1/2 rate Trellis. */
void Trellis::encode12(const uint8_t* payload, uint8_t* data)
{
assert(payload != nullptr);
@ -180,6 +186,7 @@ void Trellis::encode12(const uint8_t* payload, uint8_t* data)
// ---------------------------------------------------------------------------
/* Helper to deinterleave the input symbols into dibits. */
void Trellis::deinterleave(const uint8_t* data, int8_t* dibits) const
{
for (uint32_t i = 0U; i < 98U; i++) {
@ -205,6 +212,7 @@ void Trellis::deinterleave(const uint8_t* data, int8_t* dibits) const
}
/* Helper to interleave the input dibits into symbols. */
void Trellis::interleave(const int8_t* dibits, uint8_t* data) const
{
for (uint32_t i = 0U; i < 98U; i++) {
@ -239,6 +247,7 @@ void Trellis::interleave(const int8_t* dibits, uint8_t* data) const
}
/* Helper to map dibits to 4FSK constellation points. */
void Trellis::dibitsToPoints(const int8_t* dibits, uint8_t* points) const
{
for (uint32_t i = 0U; i < 49U; i++) {
@ -278,6 +287,7 @@ void Trellis::dibitsToPoints(const int8_t* dibits, uint8_t* points) const
}
/* Helper to map 4FSK constellation points to dibits. */
void Trellis::pointsToDibits(const uint8_t* points, int8_t* dibits) const
{
for (uint32_t i = 0U; i < 49U; i++) {
@ -351,6 +361,7 @@ void Trellis::pointsToDibits(const uint8_t* points, int8_t* dibits) const
}
/* Helper to convert a byte payload into tribits. */
void Trellis::bitsToTribits(const uint8_t* payload, uint8_t* tribits) const
{
for (uint32_t i = 0U; i < 48U; i++) {
@ -374,6 +385,7 @@ void Trellis::bitsToTribits(const uint8_t* payload, uint8_t* tribits) const
}
/* Helper to convert a byte payload into dibits. */
void Trellis::bitsToDibits(const uint8_t* payload, uint8_t* dibits) const
{
for (uint32_t i = 0U; i < 48U; i++) {
@ -394,6 +406,7 @@ void Trellis::bitsToDibits(const uint8_t* payload, uint8_t* dibits) const
}
/* Helper to convert tribits into a byte payload. */
void Trellis::tribitsToBits(const uint8_t* tribits, uint8_t* payload) const
{
for (uint32_t i = 0U; i < 48U; i++) {
@ -414,6 +427,7 @@ void Trellis::tribitsToBits(const uint8_t* tribits, uint8_t* payload) const
}
/* Helper to convert tribits into a byte payload. */
void Trellis::dibitsToBits(const uint8_t* dibits, uint8_t* payload) const
{
for (uint32_t i = 0U; i < 48U; i++) {
@ -431,6 +445,7 @@ void Trellis::dibitsToBits(const uint8_t* dibits, uint8_t* payload) const
}
/* Helper to fix errors in Trellis coding. */
bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) const
{
#if DEBUG_TRELLIS
@ -467,6 +482,7 @@ bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) con
}
/* Helper to detect errors in Trellis coding. */
uint32_t Trellis::checkCode34(const uint8_t* points, uint8_t* tribits) const
{
uint8_t state = 0U;
@ -495,6 +511,7 @@ uint32_t Trellis::checkCode34(const uint8_t* points, uint8_t* tribits) const
/* Helper to fix errors in Trellis coding. */
bool Trellis::fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) const
{
#if DEBUG_TRELLIS
@ -531,6 +548,7 @@ bool Trellis::fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) con
}
/* Helper to detect errors in Trellis coding. */
uint32_t Trellis::checkCode12(const uint8_t* points, uint8_t* dibits) const
{
uint8_t state = 0U;

@ -25,6 +25,7 @@ const uint32_t UNIT_REG_TIMEOUT = 43200U; // 12 hours
// ---------------------------------------------------------------------------
/* Initializes a new instance of the AffiliationLookup class. */
AffiliationLookup::AffiliationLookup(const std::string name, ChannelLookup* channelLookup, bool verbose) :
m_rfGrantChCnt(0U),
m_unitRegTable(),
@ -55,9 +56,11 @@ AffiliationLookup::AffiliationLookup(const std::string name, ChannelLookup* chan
}
/* Finalizes a instance of the AffiliationLookup class. */
AffiliationLookup::~AffiliationLookup() = default;
/* Helper to group affiliate a source ID. */
void AffiliationLookup::unitReg(uint32_t srcId)
{
if (isUnitReg(srcId)) {
@ -110,6 +113,7 @@ bool AffiliationLookup::unitDereg(uint32_t srcId)
}
/* Helper to start the source ID registration timer. */
void AffiliationLookup::touchUnitReg(uint32_t srcId)
{
if (srcId == 0U) {
@ -122,6 +126,7 @@ void AffiliationLookup::touchUnitReg(uint32_t srcId)
}
/* Gets the current timer timeout for this unit registration. */
uint32_t AffiliationLookup::unitRegTimeout(uint32_t srcId)
{
if (srcId == 0U) {
@ -136,6 +141,7 @@ uint32_t AffiliationLookup::unitRegTimeout(uint32_t srcId)
}
/* Gets the current timer value for this unit registration. */
uint32_t AffiliationLookup::unitRegTimer(uint32_t srcId)
{
if (srcId == 0U) {
@ -150,6 +156,7 @@ uint32_t AffiliationLookup::unitRegTimer(uint32_t srcId)
}
/* Helper to determine if the source ID has unit registered. */
bool AffiliationLookup::isUnitReg(uint32_t srcId) const
{
// lookup dynamic unit registration table entry
@ -162,6 +169,7 @@ bool AffiliationLookup::isUnitReg(uint32_t srcId) const
}
/* Helper to release unit registrations. */
void AffiliationLookup::clearUnitReg()
{
std::vector<uint32_t> srcToRel = std::vector<uint32_t>();
@ -170,6 +178,7 @@ void AffiliationLookup::clearUnitReg()
}
/* Helper to group affiliate a source ID. */
void AffiliationLookup::groupAff(uint32_t srcId, uint32_t dstId)
{
if (!isGroupAff(srcId, dstId)) {
@ -184,6 +193,7 @@ void AffiliationLookup::groupAff(uint32_t srcId, uint32_t dstId)
}
/* Helper to group unaffiliate a source ID. */
bool AffiliationLookup::groupUnaff(uint32_t srcId)
{
// lookup dynamic affiliation table entry
@ -209,6 +219,7 @@ bool AffiliationLookup::groupUnaff(uint32_t srcId)
}
/* Helper to determine if the group destination ID has any affiations. */
bool AffiliationLookup::hasGroupAff(uint32_t dstId) const
{
for (auto entry : m_grpAffTable) {
@ -221,6 +232,7 @@ bool AffiliationLookup::hasGroupAff(uint32_t dstId) const
}
/* Helper to determine if the source ID has affiliated to the group destination ID. */
bool AffiliationLookup::isGroupAff(uint32_t srcId, uint32_t dstId) const
{
// lookup dynamic affiliation table entry
@ -238,6 +250,7 @@ bool AffiliationLookup::isGroupAff(uint32_t srcId, uint32_t dstId) const
}
/* Helper to release group affiliations. */
std::vector<uint32_t> AffiliationLookup::clearGroupAff(uint32_t dstId, bool releaseAll)
{
std::vector<uint32_t> srcToRel = std::vector<uint32_t>();
@ -271,6 +284,7 @@ std::vector<uint32_t> AffiliationLookup::clearGroupAff(uint32_t dstId, bool rele
}
/* Helper to grant a channel. */
bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool grp, bool netGranted)
{
if (dstId == 0U) {
@ -303,6 +317,7 @@ bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTi
}
/* Helper to start the destination ID grant timer. */
void AffiliationLookup::touchGrant(uint32_t dstId)
{
if (dstId == 0U) {
@ -315,6 +330,7 @@ void AffiliationLookup::touchGrant(uint32_t dstId)
}
/* Helper to release the channel grant for the destination ID. */
bool AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
{
if (dstId == 0U && !releaseAll) {
@ -372,6 +388,7 @@ bool AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
}
/* Helper to determine if the channel number is busy. */
bool AffiliationLookup::isChBusy(uint32_t chNo) const
{
if (chNo == 0U) {
@ -389,6 +406,7 @@ bool AffiliationLookup::isChBusy(uint32_t chNo) const
}
/* Helper to determine if the destination ID is already granted. */
bool AffiliationLookup::isGranted(uint32_t dstId) const
{
if (dstId == 0U) {
@ -410,6 +428,7 @@ bool AffiliationLookup::isGranted(uint32_t dstId) const
}
/* Helper to determine if the destination ID is network granted. */
bool AffiliationLookup::isGroup(uint32_t dstId) const
{
if (dstId == 0U) {
@ -426,6 +445,7 @@ bool AffiliationLookup::isGroup(uint32_t dstId) const
}
/* Helper to determine if the destination ID is network granted. */
bool AffiliationLookup::isNetGranted(uint32_t dstId) const
{
if (dstId == 0U) {
@ -442,6 +462,7 @@ bool AffiliationLookup::isNetGranted(uint32_t dstId) const
}
/* Helper to get the channel granted for the given destination ID. */
uint32_t AffiliationLookup::getGrantedCh(uint32_t dstId)
{
if (dstId == 0U) {
@ -456,6 +477,7 @@ uint32_t AffiliationLookup::getGrantedCh(uint32_t dstId)
}
/* Helper to get the destination ID granted to the given source ID. */
uint32_t AffiliationLookup::getGrantedBySrcId(uint32_t srcId)
{
if (srcId == 0U) {
@ -473,6 +495,7 @@ uint32_t AffiliationLookup::getGrantedBySrcId(uint32_t srcId)
}
/* Helper to get the source ID granted for the given destination ID. */
uint32_t AffiliationLookup::getGrantedSrcId(uint32_t dstId)
{
if (dstId == 0U) {
@ -487,6 +510,7 @@ uint32_t AffiliationLookup::getGrantedSrcId(uint32_t dstId)
}
/* Updates the processor by the passed number of milliseconds. */
void AffiliationLookup::clock(uint32_t ms)
{
// clock all the grant timers

@ -17,6 +17,7 @@ using namespace lookups;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the ChannelLookup class. */
ChannelLookup::ChannelLookup() :
m_rfChTable(),
m_rfChDataTable()
@ -25,9 +26,11 @@ ChannelLookup::ChannelLookup() :
}
/* Finalizes a instance of the ChannelLookup class. */
ChannelLookup::~ChannelLookup() = default;
/* Helper to get RF channel data. */
VoiceChData ChannelLookup::getRFChData(uint32_t chNo) const
{
if (chNo == 0U) {
@ -45,6 +48,7 @@ VoiceChData ChannelLookup::getRFChData(uint32_t chNo) const
}
/* Helper to add a RF channel. */
bool ChannelLookup::addRFCh(uint32_t chNo, bool force)
{
if (chNo == 0U) {
@ -66,6 +70,7 @@ bool ChannelLookup::addRFCh(uint32_t chNo, bool force)
}
/* Helper to remove a RF channel. */
void ChannelLookup::removeRFCh(uint32_t chNo)
{
if (chNo == 0U) {

@ -29,12 +29,14 @@ std::mutex IdenTableLookup::m_mutex;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the IdenTableLookup class. */
IdenTableLookup::IdenTableLookup(const std::string& filename, uint32_t reloadTime) : LookupTable(filename, reloadTime)
{
/* stub */
}
/* Clears all entries from the lookup table. */
void IdenTableLookup::clear()
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -42,6 +44,7 @@ void IdenTableLookup::clear()
}
/* Finds a table entry in this lookup table. */
IdenTable IdenTableLookup::find(uint32_t id)
{
IdenTable entry;
@ -66,6 +69,7 @@ IdenTable IdenTableLookup::find(uint32_t id)
}
/* Returns the list of entries in this lookup table. */
std::vector<IdenTable> IdenTableLookup::list()
{
std::vector<IdenTable> list = std::vector<IdenTable>();
@ -83,6 +87,7 @@ std::vector<IdenTable> IdenTableLookup::list()
// ---------------------------------------------------------------------------
/* Loads the table from the passed lookup table file. */
bool IdenTableLookup::load()
{
if (m_filename.empty()) {
@ -160,6 +165,7 @@ bool IdenTableLookup::load()
}
/* Saves the table to the passed lookup table file. */
bool IdenTableLookup::save()
{
return false;

@ -29,6 +29,7 @@ std::mutex PeerListLookup::m_mutex;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the PeerListLookup class. */
PeerListLookup::PeerListLookup(const std::string& filename, Mode mode, uint32_t reloadTime, bool peerAcl) : LookupTable(filename, reloadTime),
m_acl(peerAcl), m_mode(mode)
{
@ -36,6 +37,7 @@ PeerListLookup::PeerListLookup(const std::string& filename, Mode mode, uint32_t
}
/* Clears all entries from the list. */
void PeerListLookup::clear()
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -43,6 +45,7 @@ void PeerListLookup::clear()
}
/* Adds a new entry to the list. */
void PeerListLookup::addEntry(uint32_t id, const std::string& password)
{
PeerId entry = PeerId(id, password, false);
@ -61,6 +64,7 @@ void PeerListLookup::addEntry(uint32_t id, const std::string& password)
}
/* Removes an existing entry from the list. */
void PeerListLookup::eraseEntry(uint32_t id)
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -73,6 +77,7 @@ void PeerListLookup::eraseEntry(uint32_t id)
}
/* Finds a table entry in this lookup table. */
PeerId PeerListLookup::find(uint32_t id)
{
PeerId entry;
@ -88,18 +93,21 @@ PeerId PeerListLookup::find(uint32_t id)
}
/* Commit the table. */
void PeerListLookup::commit()
{
save();
}
/* Gets whether the lookup is enabled. */
bool PeerListLookup::getACL() const
{
return m_acl;
}
/* Checks if a peer ID is in the list. */
bool PeerListLookup::isPeerInList(uint32_t id) const
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -111,6 +119,7 @@ bool PeerListLookup::isPeerInList(uint32_t id) const
}
/* Checks if a peer ID is allowed based on the mode and enabled flag. */
bool PeerListLookup::isPeerAllowed(uint32_t id) const
{
if (!m_acl) {
@ -128,6 +137,7 @@ bool PeerListLookup::isPeerAllowed(uint32_t id) const
}
/* Sets the mode to either WHITELIST or BLACKLIST. */
void PeerListLookup::setMode(Mode mode)
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -135,6 +145,7 @@ void PeerListLookup::setMode(Mode mode)
}
/* Gets the current mode. */
PeerListLookup::Mode PeerListLookup::getMode() const
{
return m_mode;
@ -145,6 +156,7 @@ PeerListLookup::Mode PeerListLookup::getMode() const
// ---------------------------------------------------------------------------
/* Loads the table from the passed lookup table file. */
bool PeerListLookup::load()
{
if (m_filename.empty()) {
@ -211,6 +223,7 @@ bool PeerListLookup::load()
}
/* Saves the table to the passed lookup table file. */
bool PeerListLookup::save()
{
LogDebug(LOG_HOST, "Saving peer lookup file to %s", m_filename.c_str());

@ -21,6 +21,7 @@ using namespace lookups;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RSSIInterpolator class. */
RSSIInterpolator::RSSIInterpolator() :
m_map()
{
@ -28,12 +29,14 @@ RSSIInterpolator::RSSIInterpolator() :
}
/* Finalizes a instance of the RSSIInterpolator class. */
RSSIInterpolator::~RSSIInterpolator()
{
m_map.clear();
}
/* Loads the table from the passed RSSI mapping file. */
bool RSSIInterpolator::load(const std::string& filename)
{
FILE* fp = ::fopen(filename.c_str(), "rt");
@ -65,6 +68,7 @@ bool RSSIInterpolator::load(const std::string& filename)
}
/* Interpolates the given raw RSSI value with the lookup map. */
int RSSIInterpolator::interpolate(uint16_t val) const
{
if (m_map.empty())

@ -31,6 +31,7 @@ std::mutex RadioIdLookup::m_mutex;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RadioIdLookup class. */
RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl) : LookupTable(filename, reloadTime),
m_acl(ridAcl)
{
@ -38,6 +39,7 @@ RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, b
}
/* Clears all entries from the lookup table. */
void RadioIdLookup::clear()
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -45,6 +47,7 @@ void RadioIdLookup::clear()
}
/* Toggles the specified radio ID enabled or disabled. */
void RadioIdLookup::toggleEntry(uint32_t id, bool enabled)
{
RadioId rid = find(id);
@ -52,6 +55,7 @@ void RadioIdLookup::toggleEntry(uint32_t id, bool enabled)
}
/* Adds a new entry to the lookup table by the specified unique ID. */
void RadioIdLookup::addEntry(uint32_t id, bool enabled, const std::string& alias)
{
if ((id == p25::defines::WUID_ALL) || (id == p25::defines::WUID_FNE)) {
@ -78,6 +82,7 @@ void RadioIdLookup::addEntry(uint32_t id, bool enabled, const std::string& alias
}
/* Erases an existing entry from the lookup table by the specified unique ID. */
void RadioIdLookup::eraseEntry(uint32_t id)
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -90,6 +95,7 @@ void RadioIdLookup::eraseEntry(uint32_t id)
}
/* Finds a table entry in this lookup table. */
RadioId RadioIdLookup::find(uint32_t id)
{
RadioId entry;
@ -109,12 +115,14 @@ RadioId RadioIdLookup::find(uint32_t id)
}
/* Saves loaded talkgroup rules. */
void RadioIdLookup::commit()
{
save();
}
/* Flag indicating whether radio ID access control is enabled or not. */
bool RadioIdLookup::getACL()
{
return m_acl;
@ -125,6 +133,7 @@ bool RadioIdLookup::getACL()
// ---------------------------------------------------------------------------
/* Loads the table from the passed lookup table file. */
bool RadioIdLookup::load()
{
if (m_filename.empty()) {
@ -195,6 +204,7 @@ bool RadioIdLookup::load()
}
/* Saves the table to the passed lookup table file. */
bool RadioIdLookup::save()
{
LogDebug(LOG_HOST, "Saving RID lookup file to %s", m_filename.c_str());

@ -29,6 +29,7 @@ std::mutex TalkgroupRulesLookup::m_mutex;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the TalkgroupRulesLookup class. */
TalkgroupRulesLookup::TalkgroupRulesLookup(const std::string& filename, uint32_t reloadTime, bool acl) : Thread(),
m_rulesFile(filename),
m_reloadTime(reloadTime),
@ -42,9 +43,11 @@ TalkgroupRulesLookup::TalkgroupRulesLookup(const std::string& filename, uint32_t
}
/* Finalizes a instance of the TalkgroupRulesLookup class. */
TalkgroupRulesLookup::~TalkgroupRulesLookup() = default;
/* Thread entry point. This function is provided to run the thread for the lookup table. */
void TalkgroupRulesLookup::entry()
{
if (m_reloadTime == 0U) {
@ -66,6 +69,7 @@ void TalkgroupRulesLookup::entry()
}
/* Stops and unloads this lookup table. */
void TalkgroupRulesLookup::stop()
{
if (m_reloadTime == 0U) {
@ -79,6 +83,7 @@ void TalkgroupRulesLookup::stop()
}
/* Reads the lookup table from the specified lookup table file. */
bool TalkgroupRulesLookup::read()
{
bool ret = load();
@ -90,6 +95,7 @@ bool TalkgroupRulesLookup::read()
}
/* Clears all entries from the lookup table. */
void TalkgroupRulesLookup::clear()
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -97,6 +103,7 @@ void TalkgroupRulesLookup::clear()
}
/* Adds a new entry to the lookup table by the specified unique ID. */
void TalkgroupRulesLookup::addEntry(uint32_t id, uint8_t slot, bool enabled, bool nonPreferred)
{
TalkgroupRuleGroupVoiceSource source;
@ -141,6 +148,7 @@ void TalkgroupRulesLookup::addEntry(uint32_t id, uint8_t slot, bool enabled, boo
}
/* Adds a new entry to the lookup table by the specified unique ID. */
void TalkgroupRulesLookup::addEntry(TalkgroupRuleGroupVoice groupVoice)
{
if (groupVoice.isInvalid())
@ -169,6 +177,7 @@ void TalkgroupRulesLookup::addEntry(TalkgroupRuleGroupVoice groupVoice)
}
/* Erases an existing entry from the lookup table by the specified unique ID. */
void TalkgroupRulesLookup::eraseEntry(uint32_t id, uint8_t slot)
{
std::lock_guard<std::mutex> lock(m_mutex);
@ -179,6 +188,7 @@ void TalkgroupRulesLookup::eraseEntry(uint32_t id, uint8_t slot)
}
/* Finds a table entry in this lookup table. */
TalkgroupRuleGroupVoice TalkgroupRulesLookup::find(uint32_t id, uint8_t slot)
{
TalkgroupRuleGroupVoice entry;
@ -203,6 +213,7 @@ TalkgroupRuleGroupVoice TalkgroupRulesLookup::find(uint32_t id, uint8_t slot)
}
/* Finds a table entry in this lookup table. */
TalkgroupRuleGroupVoice TalkgroupRulesLookup::findByRewrite(uint32_t peerId, uint32_t id, uint8_t slot)
{
TalkgroupRuleGroupVoice entry;
@ -239,12 +250,14 @@ TalkgroupRuleGroupVoice TalkgroupRulesLookup::findByRewrite(uint32_t peerId, uin
}
/* Saves loaded talkgroup rules. */
bool TalkgroupRulesLookup::commit()
{
return save();
}
/* Flag indicating whether talkgroup ID access control is enabled or not. */
bool TalkgroupRulesLookup::getACL()
{
return m_acl;
@ -255,6 +268,7 @@ bool TalkgroupRulesLookup::getACL()
// ---------------------------------------------------------------------------
/* Loads the table from the passed lookup table file. */
bool TalkgroupRulesLookup::load()
{
if (m_rulesFile.length() <= 0) {
@ -322,6 +336,7 @@ bool TalkgroupRulesLookup::load()
}
/* Saves the table to the passed lookup table file. */
bool TalkgroupRulesLookup::save()
{
// Make sure file is valid

@ -27,6 +27,7 @@ using namespace network::frame;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the BaseNetwork class. */
BaseNetwork::BaseNetwork(uint32_t peerId, bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, uint16_t localPort) :
m_peerId(peerId),
m_status(NET_STAT_INVALID),
@ -68,6 +69,7 @@ BaseNetwork::BaseNetwork(uint32_t peerId, bool duplex, bool debug, bool slot1, b
}
/* Finalizes a instance of the BaseNetwork class. */
BaseNetwork::~BaseNetwork()
{
if (m_frameQueue != nullptr) {
@ -82,6 +84,7 @@ BaseNetwork::~BaseNetwork()
}
/* Writes grant request to the network. */
bool BaseNetwork::writeGrantReq(const uint8_t mode, const uint32_t srcId, const uint32_t dstId, const uint8_t slot, const bool unitToUnit)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -103,6 +106,7 @@ bool BaseNetwork::writeGrantReq(const uint8_t mode, const uint32_t srcId, const
}
/* Writes the local activity log to the network. */
bool BaseNetwork::writeActLog(const char* message)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -123,6 +127,7 @@ bool BaseNetwork::writeActLog(const char* message)
}
/* Writes the local diagnostics log to the network. */
bool BaseNetwork::writeDiagLog(const char* message)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -143,6 +148,7 @@ bool BaseNetwork::writeDiagLog(const char* message)
}
/* Writes the local status to the network. */
bool BaseNetwork::writePeerStatus(json::object obj)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -167,6 +173,7 @@ bool BaseNetwork::writePeerStatus(json::object obj)
}
/* Writes a group affiliation to the network. */
bool BaseNetwork::announceGroupAffiliation(uint32_t srcId, uint32_t dstId)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -181,6 +188,7 @@ bool BaseNetwork::announceGroupAffiliation(uint32_t srcId, uint32_t dstId)
}
/* Writes a unit registration to the network. */
bool BaseNetwork::announceUnitRegistration(uint32_t srcId)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -194,6 +202,7 @@ bool BaseNetwork::announceUnitRegistration(uint32_t srcId)
}
/* Writes a unit deregistration to the network. */
bool BaseNetwork::announceUnitDeregistration(uint32_t srcId)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -207,6 +216,7 @@ bool BaseNetwork::announceUnitDeregistration(uint32_t srcId)
}
/* Writes a complete update of the peer affiliation list to the network. */
bool BaseNetwork::announceAffiliationUpdate(const std::unordered_map<uint32_t, uint32_t> affs)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -229,6 +239,7 @@ bool BaseNetwork::announceAffiliationUpdate(const std::unordered_map<uint32_t, u
}
/* Writes a complete update of the peer's voice channel list to the network. */
bool BaseNetwork::announceSiteVCs(const std::vector<uint32_t> peers)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -250,6 +261,7 @@ bool BaseNetwork::announceSiteVCs(const std::vector<uint32_t> peers)
}
/* Resets the DMR ring buffer for the given slot. */
void BaseNetwork::resetDMR(uint32_t slotNo)
{
assert(slotNo == 1U || slotNo == 2U);
@ -266,6 +278,7 @@ void BaseNetwork::resetDMR(uint32_t slotNo)
}
/* Resets the P25 ring buffer. */
void BaseNetwork::resetP25()
{
m_p25StreamId = createStreamId();
@ -274,6 +287,7 @@ void BaseNetwork::resetP25()
}
/* Resets the NXDN ring buffer. */
void BaseNetwork::resetNXDN()
{
m_nxdnStreamId = createStreamId();
@ -282,6 +296,7 @@ void BaseNetwork::resetNXDN()
}
/* Gets the current DMR stream ID. */
uint32_t BaseNetwork::getDMRStreamId(uint32_t slotNo) const
{
assert(slotNo == 1U || slotNo == 2U);
@ -295,6 +310,7 @@ uint32_t BaseNetwork::getDMRStreamId(uint32_t slotNo) const
}
/* Helper to send a data message to the master. */
bool BaseNetwork::writeMaster(FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, uint16_t pktSeq, uint32_t streamId,
bool queueOnly, bool useAlternatePort)
{
@ -323,6 +339,7 @@ bool BaseNetwork::writeMaster(FrameQueue::OpcodePair opcode, const uint8_t* data
}
/* Reads DMR raw frame data from the DMR ring buffer. */
UInt8Array BaseNetwork::readDMR(bool& ret, uint32_t& frameLength)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -351,6 +368,7 @@ UInt8Array BaseNetwork::readDMR(bool& ret, uint32_t& frameLength)
}
/* Writes DMR frame data to the network. */
bool BaseNetwork::writeDMR(const dmr::data::Data& data, bool noSequence)
{
using namespace dmr::defines;
@ -399,6 +417,7 @@ bool BaseNetwork::writeDMR(const dmr::data::Data& data, bool noSequence)
}
/* Helper to test if the DMR ring buffer has data. */
bool BaseNetwork::hasDMRData() const
{
if (m_rxDMRData.isEmpty())
@ -408,6 +427,7 @@ bool BaseNetwork::hasDMRData() const
}
/* Reads P25 raw frame data from the P25 ring buffer. */
UInt8Array BaseNetwork::readP25(bool& ret, uint32_t& frameLength)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -436,6 +456,7 @@ UInt8Array BaseNetwork::readP25(bool& ret, uint32_t& frameLength)
}
/* Writes P25 LDU1 frame data to the network. */
bool BaseNetwork::writeP25LDU1(const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t* data, p25::defines::FrameType::E frameType)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -457,6 +478,7 @@ bool BaseNetwork::writeP25LDU1(const p25::lc::LC& control, const p25::data::LowS
}
/* Writes P25 LDU2 frame data to the network. */
bool BaseNetwork::writeP25LDU2(const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t* data)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -478,6 +500,7 @@ bool BaseNetwork::writeP25LDU2(const p25::lc::LC& control, const p25::data::LowS
}
/* Writes P25 TDU frame data to the network. */
bool BaseNetwork::writeP25TDU(const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t controlByte)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -504,6 +527,7 @@ bool BaseNetwork::writeP25TDU(const p25::lc::LC& control, const p25::data::LowSp
}
/* Writes P25 TSDU frame data to the network. */
bool BaseNetwork::writeP25TSDU(const p25::lc::LC& control, const uint8_t* data)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -523,6 +547,7 @@ bool BaseNetwork::writeP25TSDU(const p25::lc::LC& control, const uint8_t* data)
}
/* Writes P25 PDU frame data to the network. */
bool BaseNetwork::writeP25PDU(const p25::data::DataHeader& header, const uint8_t currentBlock, const uint8_t* data,
const uint32_t len, bool lastBlock)
{
@ -550,6 +575,7 @@ bool BaseNetwork::writeP25PDU(const p25::data::DataHeader& header, const uint8_t
}
/* Helper to test if the P25 ring buffer has data. */
bool BaseNetwork::hasP25Data() const
{
if (m_rxP25Data.isEmpty())
@ -559,6 +585,7 @@ bool BaseNetwork::hasP25Data() const
}
/* Reads NXDN raw frame data from the NXDN ring buffer. */
UInt8Array BaseNetwork::readNXDN(bool& ret, uint32_t& frameLength)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
@ -587,6 +614,7 @@ UInt8Array BaseNetwork::readNXDN(bool& ret, uint32_t& frameLength)
}
/* Writes NXDN frame data to the network. */
bool BaseNetwork::writeNXDN(const nxdn::lc::RTCH& lc, const uint8_t* data, const uint32_t len, bool noSequence)
{
using namespace nxdn::defines;
@ -619,6 +647,7 @@ bool BaseNetwork::writeNXDN(const nxdn::lc::RTCH& lc, const uint8_t* data, const
}
/* Helper to test if the NXDN ring buffer has data. */
bool BaseNetwork::hasNXDNData() const
{
if (m_rxNXDNData.isEmpty())
@ -632,6 +661,7 @@ bool BaseNetwork::hasNXDNData() const
// ---------------------------------------------------------------------------
/* Helper to update the RTP packet sequence. */
uint16_t BaseNetwork::pktSeq(bool reset)
{
if (reset) {
@ -648,6 +678,7 @@ uint16_t BaseNetwork::pktSeq(bool reset)
}
/* Creates an DMR frame message. */
UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t streamId, const dmr::data::Data& data)
{
using namespace dmr::defines;
@ -705,6 +736,7 @@ UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t strea
}
/* Creates an P25 frame message header. */
void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E duid, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd,
p25::defines::FrameType::E frameType)
{
@ -764,6 +796,7 @@ void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E du
}
/* Creates an P25 LDU1 frame message. */
UInt8Array BaseNetwork::createP25_LDU1Message(uint32_t& length, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd,
const uint8_t* data, p25::defines::FrameType::E frameType)
{
@ -838,6 +871,7 @@ UInt8Array BaseNetwork::createP25_LDU1Message(uint32_t& length, const p25::lc::L
}
/* Creates an P25 LDU2 frame message. */
UInt8Array BaseNetwork::createP25_LDU2Message(uint32_t& length, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd,
const uint8_t* data)
{
@ -912,6 +946,7 @@ UInt8Array BaseNetwork::createP25_LDU2Message(uint32_t& length, const p25::lc::L
}
/* Creates an P25 TDU frame message. */
UInt8Array BaseNetwork::createP25_TDUMessage(uint32_t& length, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t controlByte)
{
using namespace p25::defines;
@ -932,6 +967,7 @@ UInt8Array BaseNetwork::createP25_TDUMessage(uint32_t& length, const p25::lc::LC
}
/* Creates an P25 TSDU frame message. */
UInt8Array BaseNetwork::createP25_TSDUMessage(uint32_t& length, const p25::lc::LC& control, const uint8_t* data)
{
using namespace p25::defines;
@ -960,6 +996,7 @@ UInt8Array BaseNetwork::createP25_TSDUMessage(uint32_t& length, const p25::lc::L
}
/* Writes P25 PDU frame data to the network. */
UInt8Array BaseNetwork::createP25_PDUMessage(uint32_t& length, const p25::data::DataHeader& header,
const uint8_t currentBlock, const uint8_t* data, const uint32_t len)
{
@ -1007,6 +1044,7 @@ UInt8Array BaseNetwork::createP25_PDUMessage(uint32_t& length, const p25::data::
}
/* Writes NXDN frame data to the network. */
UInt8Array BaseNetwork::createNXDN_Message(uint32_t& length, const nxdn::lc::RTCH& lc, const uint8_t* data, const uint32_t len)
{
assert(data != nullptr);

@ -28,6 +28,7 @@ using namespace network::frame;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the FrameQueue class. */
FrameQueue::FrameQueue(udp::Socket* socket, uint32_t peerId, bool debug) : RawFrameQueue(socket, debug),
m_peerId(peerId),
m_streamTimestamps()
@ -36,6 +37,7 @@ FrameQueue::FrameQueue(udp::Socket* socket, uint32_t peerId, bool debug) : RawFr
}
/* Read message from the received UDP packet. */
UInt8Array FrameQueue::read(int& messageLength, sockaddr_storage& address, uint32_t& addrLen,
RTPHeader* rtpHeader, RTPFNEHeader* fneHeader)
{
@ -116,6 +118,7 @@ UInt8Array FrameQueue::read(int& messageLength, sockaddr_storage& address, uint3
}
/* Write message to the UDP socket. */
bool FrameQueue::write(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId,
uint32_t ssrc, OpcodePair opcode, uint16_t rtpSeq, sockaddr_storage& addr, uint32_t addrLen)
{
@ -136,6 +139,7 @@ bool FrameQueue::write(const uint8_t* message, uint32_t length, uint32_t streamI
}
/* Cache message to frame queue. */
void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId,
OpcodePair opcode, uint16_t rtpSeq, sockaddr_storage& addr, uint32_t addrLen)
{
@ -143,6 +147,7 @@ void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_
}
/* Cache message to frame queue. */
void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId,
uint32_t ssrc, OpcodePair opcode, uint16_t rtpSeq, sockaddr_storage& addr, uint32_t addrLen)
{
@ -162,6 +167,7 @@ void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_
}
/* Helper method to clear any tracked stream timestamps. */
void FrameQueue::clearTimestamps()
{
m_streamTimestamps.clear();
@ -172,6 +178,7 @@ void FrameQueue::clearTimestamps()
// ---------------------------------------------------------------------------
/* Generate RTP message for the frame queue. */
uint8_t* FrameQueue::generateMessage(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId,
uint32_t ssrc, OpcodePair opcode, uint16_t rtpSeq, uint32_t* outBufferLen)
{

@ -19,6 +19,7 @@ using namespace network::frame;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RTPExtensionHeader class. */
RTPExtensionHeader::RTPExtensionHeader() :
m_payloadType(0U),
m_payloadLength(0U)
@ -27,9 +28,11 @@ RTPExtensionHeader::RTPExtensionHeader() :
}
/* Finalizes a instance of the RTPExtensionHeader class. */
RTPExtensionHeader::~RTPExtensionHeader() = default;
/* Decode a RTP header. */
bool RTPExtensionHeader::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -41,6 +44,7 @@ bool RTPExtensionHeader::decode(const uint8_t* data)
}
/* Encode a RTP header. */
void RTPExtensionHeader::encode(uint8_t* data)
{
assert(data != nullptr);

@ -20,6 +20,7 @@ using namespace network::frame;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RTPFNEHeader class. */
RTPFNEHeader::RTPFNEHeader() :
RTPExtensionHeader(),
m_crc16(0U),
@ -33,9 +34,11 @@ RTPFNEHeader::RTPFNEHeader() :
}
/* Finalizes a instance of the RTPFNEHeader class. */
RTPFNEHeader::~RTPFNEHeader() = default;
/* Decode a RTP header. */
bool RTPFNEHeader::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -60,6 +63,7 @@ bool RTPFNEHeader::decode(const uint8_t* data)
}
/* Encode a RTP header. */
void RTPFNEHeader::encode(uint8_t* data)
{
assert(data != nullptr);

@ -28,6 +28,7 @@ hrc::hrc_t RTPHeader::m_wcStart = hrc::hrc_t();
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RTPHeader class. */
RTPHeader::RTPHeader() :
m_version(2U),
m_padding(false),
@ -43,9 +44,11 @@ RTPHeader::RTPHeader() :
}
/* Finalizes a instance of the RTPHeader class. */
RTPHeader::~RTPHeader() = default;
/* Decode a RTP header. */
bool RTPHeader::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -70,6 +73,7 @@ bool RTPHeader::decode(const uint8_t* data)
}
/* Encode a RTP header. */
void RTPHeader::encode(uint8_t* data)
{
assert(data != nullptr);
@ -94,6 +98,7 @@ void RTPHeader::encode(uint8_t* data)
}
/* Helper to reset the start timestamp. */
void RTPHeader::resetStartTime()
{
m_wcStart = hrc::hrc_t();

@ -29,6 +29,7 @@ std::mutex RawFrameQueue::m_flushMutex;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RawFrameQueue class. */
RawFrameQueue::RawFrameQueue(udp::Socket* socket, bool debug) :
m_socket(socket),
m_buffers(),
@ -38,12 +39,14 @@ RawFrameQueue::RawFrameQueue(udp::Socket* socket, bool debug) :
}
/* Finalizes a instance of the RawFrameQueue class. */
RawFrameQueue::~RawFrameQueue()
{
deleteBuffers();
}
/* Read message from the received UDP packet. */
UInt8Array RawFrameQueue::read(int& messageLength, sockaddr_storage& address, uint32_t& addrLen)
{
messageLength = -1;
@ -73,6 +76,7 @@ UInt8Array RawFrameQueue::read(int& messageLength, sockaddr_storage& address, ui
}
/* Write message to the UDP socket. */
bool RawFrameQueue::write(const uint8_t* message, uint32_t length, sockaddr_storage& addr, uint32_t addrLen)
{
assert(message != nullptr);
@ -95,6 +99,7 @@ bool RawFrameQueue::write(const uint8_t* message, uint32_t length, sockaddr_stor
}
/* Cache message to frame queue. */
void RawFrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, sockaddr_storage& addr, uint32_t addrLen)
{
assert(message != nullptr);
@ -117,6 +122,7 @@ void RawFrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, sock
}
/* Flush the message queue. */
bool RawFrameQueue::flushQueue()
{
bool ret = true;
@ -149,6 +155,7 @@ bool RawFrameQueue::flushQueue()
// ---------------------------------------------------------------------------
/* Helper to ensure buffers are deleted. */
void RawFrameQueue::deleteBuffers()
{
for (auto& buffer : m_buffers) {

@ -22,6 +22,7 @@ using namespace network::rest::http;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the HTTPLexer class. */
HTTPLexer::HTTPLexer(bool clientLexer) :
m_headers(),
m_clientLexer(clientLexer),
@ -34,6 +35,7 @@ HTTPLexer::HTTPLexer(bool clientLexer) :
}
/* Reset to initial parser state. */
void HTTPLexer::reset()
{
m_state = METHOD_START;
@ -49,6 +51,7 @@ void HTTPLexer::reset()
// ---------------------------------------------------------------------------
/* Handle the next character of input. */
HTTPLexer::ResultType HTTPLexer::consume(HTTPPayload& req, char input)
{
m_consumed++;
@ -370,18 +373,21 @@ HTTPLexer::ResultType HTTPLexer::consume(HTTPPayload& req, char input)
}
/* Check if a byte is an HTTP character. */
bool HTTPLexer::isChar(int c)
{
return c >= 0 && c <= 127;
}
/* Check if a byte is an HTTP control character. */
bool HTTPLexer::isControl(int c)
{
return (c >= 0 && c <= 31) || (c == 127);
}
/* Check if a byte is an HTTP special character. */
bool HTTPLexer::isSpecial(int c)
{
switch (c)
@ -397,6 +403,7 @@ bool HTTPLexer::isSpecial(int c)
}
/* Check if a byte is an digit. */
bool HTTPLexer::isDigit(int c)
{
return c >= '0' && c <= '9';

@ -268,6 +268,7 @@ namespace stock_replies {
// ---------------------------------------------------------------------------
/* Convert the reply into a vector of buffers. The buffers do not own the underlying memory blocks, therefore the reply object must remain valid and not be changed until the write operation has completed. */
std::vector<asio::const_buffer> HTTPPayload::toBuffers()
{
std::vector<asio::const_buffer> buffers;
@ -317,6 +318,7 @@ std::vector<asio::const_buffer> HTTPPayload::toBuffers()
}
/* Prepares payload for transmission by finalizing status and content type. */
void HTTPPayload::payload(json::object& obj, HTTPPayload::StatusType s)
{
json::value v = json::value(obj);
@ -325,6 +327,7 @@ void HTTPPayload::payload(json::object& obj, HTTPPayload::StatusType s)
}
/* Prepares payload for transmission by finalizing status and content type. */
void HTTPPayload::payload(std::string& c, HTTPPayload::StatusType s, const std::string& contentType)
{
content = c;
@ -337,6 +340,7 @@ void HTTPPayload::payload(std::string& c, HTTPPayload::StatusType s, const std::
// ---------------------------------------------------------------------------
/* Get a status payload. */
HTTPPayload HTTPPayload::requestPayload(std::string method, std::string uri)
{
HTTPPayload rep;
@ -347,6 +351,7 @@ HTTPPayload HTTPPayload::requestPayload(std::string method, std::string uri)
}
/* Get a status payload. */
HTTPPayload HTTPPayload::statusPayload(HTTPPayload::StatusType status, const std::string& contentType)
{
HTTPPayload rep;
@ -363,6 +368,7 @@ HTTPPayload HTTPPayload::statusPayload(HTTPPayload::StatusType status, const std
/* Helper to attach a host TCP stream reader. */
void HTTPPayload::attachHostHeader(const asio::ip::tcp::endpoint remoteEndpoint)
{
headers.add("Host", std::string(remoteEndpoint.address().to_string() + ":" + std::to_string(remoteEndpoint.port())));
@ -373,6 +379,7 @@ void HTTPPayload::attachHostHeader(const asio::ip::tcp::endpoint remoteEndpoint)
// ---------------------------------------------------------------------------
/* Internal helper to ensure the headers are of a default for the given content type. */
void HTTPPayload::ensureDefaultHeaders(const std::string& contentType)
{
if (!isClientPayload) {

@ -23,6 +23,7 @@ using namespace network::rest::http;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the HTTPRequestHandler class. */
HTTPRequestHandler::HTTPRequestHandler(const std::string& docRoot) :
m_docRoot(docRoot)
{
@ -30,6 +31,7 @@ HTTPRequestHandler::HTTPRequestHandler(const std::string& docRoot) :
}
/* Handle a request and produce a reply. */
void HTTPRequestHandler::handleRequest(const HTTPPayload& request, HTTPPayload& reply)
{
// decode url to path
@ -84,6 +86,7 @@ void HTTPRequestHandler::handleRequest(const HTTPPayload& request, HTTPPayload&
// ---------------------------------------------------------------------------
/* Perform URL-decoding on a string. Returns false if the encoding was invalid. */
bool HTTPRequestHandler::urlDecode(const std::string& in, std::string& out)
{
out.clear();

@ -24,6 +24,7 @@ using namespace network::tcp;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Socket class. */
Socket::Socket() :
m_localAddress(),
m_localPort(0U),
@ -34,6 +35,7 @@ Socket::Socket() :
}
/* Initializes a new instance of the Socket class. */
Socket::Socket(const int fd) noexcept :
m_localAddress(),
m_localPort(0U),
@ -44,12 +46,14 @@ Socket::Socket(const int fd) noexcept :
}
/* Initializes a new instance of the Socket class. */
Socket::Socket(const int domain, const int type, const int protocol) : Socket()
{
initSocket(domain, type, protocol);
}
/* Finalizes a instance of the Socket class. */
Socket::~Socket()
{
static_cast<void>(::shutdown(m_fd, SHUT_RDWR));
@ -57,6 +61,7 @@ Socket::~Socket()
}
/* Accepts a pending connection request. */
int Socket::accept(sockaddr* address, socklen_t* addrlen) noexcept
{
// check that the accept() won't block
@ -95,6 +100,7 @@ int Socket::accept(sockaddr* address, socklen_t* addrlen) noexcept
}
/* Connects the client to a remote TCP host using the specified host name and port number. */
bool Socket::connect(const std::string& ipAddr, const uint16_t port)
{
sockaddr_in addr = {};
@ -112,6 +118,7 @@ bool Socket::connect(const std::string& ipAddr, const uint16_t port)
}
/* Starts listening for incoming connection requests with a maximum number of pending connection. */
ssize_t Socket::listen(const std::string& ipAddr, const uint16_t port, int backlog) noexcept
{
m_localAddress = ipAddr;
@ -126,6 +133,7 @@ ssize_t Socket::listen(const std::string& ipAddr, const uint16_t port, int backl
}
/* Read data from the socket. */
[[nodiscard]] ssize_t Socket::read(uint8_t* buffer, size_t length) noexcept
{
assert(buffer != nullptr);
@ -171,6 +179,7 @@ ssize_t Socket::listen(const std::string& ipAddr, const uint16_t port, int backl
}
/* Write data to the socket. */
ssize_t Socket::write(const uint8_t* buffer, size_t length) noexcept
{
assert(buffer != nullptr);
@ -183,6 +192,7 @@ ssize_t Socket::write(const uint8_t* buffer, size_t length) noexcept
}
/* Gets the numeric representation of an address from a sockaddr_storage socket address structure. */
uint32_t Socket::addr(const sockaddr_storage& addr)
{
switch (addr.ss_family) {
@ -201,6 +211,7 @@ uint32_t Socket::addr(const sockaddr_storage& addr)
}
/* Gets the string representation of an address from a sockaddr_storage socket address structure. */
std::string Socket::address(const sockaddr_storage& addr)
{
std::string address = std::string();
@ -231,6 +242,7 @@ std::string Socket::address(const sockaddr_storage& addr)
}
/* Gets the port from a sockaddr_storage socket address structure. */
uint16_t Socket::port(const sockaddr_storage& addr)
{
uint16_t port = 0U;
@ -258,6 +270,7 @@ uint16_t Socket::port(const sockaddr_storage& addr)
}
/* Helper to check if the address stored in a sockaddr_storage socket address structure is INADDR_NONE. */
bool Socket::isNone(const sockaddr_storage& addr)
{
struct sockaddr_in* in = (struct sockaddr_in*)& addr;
@ -270,6 +283,7 @@ bool Socket::isNone(const sockaddr_storage& addr)
// ---------------------------------------------------------------------------
/* Internal helper to initialize the socket. */
bool Socket::initSocket(const int domain, const int type, const int protocol)
{
m_fd = ::socket(domain, type, protocol);
@ -282,6 +296,7 @@ bool Socket::initSocket(const int domain, const int type, const int protocol)
}
/* Internal helper to bind to a address and port. */
bool Socket::bind(const std::string& ipAddr, const uint16_t port)
{
m_localAddress = std::string(ipAddr);
@ -301,6 +316,7 @@ bool Socket::bind(const std::string& ipAddr, const uint16_t port)
}
/* Helper to lookup a hostname and resolve it to an IP address. */
[[nodiscard]] std::string Socket::getIpAddress(const in_addr inaddr)
{
char* receivedAddr = ::inet_ntoa(inaddr);
@ -311,6 +327,7 @@ bool Socket::bind(const std::string& ipAddr, const uint16_t port)
}
/* Initialize the sockaddr_in structure with the provided IP and port */
void Socket::initAddr(const std::string& ipAddr, const int port, sockaddr_in& addr) noexcept(false)
{
addr.sin_family = AF_INET;

@ -33,6 +33,7 @@ using namespace network::udp;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Socket class. */
Socket::Socket(const std::string& address, uint16_t port) :
m_localAddress(address),
m_localPort(port),
@ -48,6 +49,7 @@ Socket::Socket(const std::string& address, uint16_t port) :
}
/* Initializes a new instance of the Socket class. */
Socket::Socket(uint16_t port) :
m_localAddress(),
m_localPort(port),
@ -63,6 +65,7 @@ Socket::Socket(uint16_t port) :
}
/* Finalizes a instance of the Socket class. */
Socket::~Socket()
{
if (m_aes != nullptr)
@ -72,18 +75,21 @@ Socket::~Socket()
}
/* Opens UDP socket connection. */
bool Socket::open(const sockaddr_storage& address) noexcept
{
return open(address.ss_family);
}
/* Opens UDP socket connection. */
bool Socket::open(uint32_t af) noexcept
{
return open(af, m_localAddress, m_localPort);
}
/* Opens UDP socket connection. */
bool Socket::open(const uint32_t af, const std::string& address, const uint16_t port) noexcept
{
sockaddr_storage addr;
@ -124,6 +130,7 @@ bool Socket::open(const uint32_t af, const std::string& address, const uint16_t
}
/* Closes the UDP socket connection. */
void Socket::close()
{
if (m_fd >= 0) {
@ -133,6 +140,7 @@ void Socket::close()
}
/* Read data from the UDP socket. */
ssize_t Socket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address, uint32_t& addrLen) noexcept
{
assert(buffer != nullptr);
@ -241,6 +249,7 @@ ssize_t Socket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address
}
/* Write data to the UDP socket. */
bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storage& address, uint32_t addrLen, ssize_t* lenWritten) noexcept
{
assert(buffer != nullptr);
@ -327,6 +336,7 @@ bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storag
}
/* Write data to the UDP socket. */
bool Socket::write(BufferVector& buffers, ssize_t* lenWritten) noexcept
{
bool result = false;
@ -509,6 +519,7 @@ bool Socket::write(BufferVector& buffers, ssize_t* lenWritten) noexcept
}
/* Sets the preshared encryption key. */
void Socket::setPresharedKey(const uint8_t* presharedKey)
{
if (presharedKey != nullptr) {
@ -522,6 +533,7 @@ void Socket::setPresharedKey(const uint8_t* presharedKey)
}
/* Helper to lookup a hostname and resolve it to an IP address. */
int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& address, uint32_t& addrLen)
{
struct addrinfo hints;
@ -531,6 +543,7 @@ int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage&
}
/* Helper to lookup a hostname and resolve it to an IP address. */
int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& address, uint32_t& addrLen, struct addrinfo& hints)
{
std::string portstr = std::to_string(port);
@ -558,6 +571,7 @@ int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage&
}
/* Helper to return the local address of the machine the socket is running on. */
std::string Socket::getLocalAddress()
{
struct ifaddrs *ifaddr, *ifa;
@ -598,6 +612,7 @@ std::string Socket::getLocalAddress()
}
/* */
bool Socket::match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type)
{
if (addr1.ss_family != addr2.ss_family)
@ -641,6 +656,7 @@ bool Socket::match(const sockaddr_storage& addr1, const sockaddr_storage& addr2,
}
/* Gets the string representation of an address from a sockaddr_storage socket address structure. */
std::string Socket::address(const sockaddr_storage& addr)
{
std::string address = std::string();
@ -671,6 +687,7 @@ std::string Socket::address(const sockaddr_storage& addr)
}
/* Gets the port from a sockaddr_storage socket address structure. */
uint16_t Socket::port(const sockaddr_storage& addr)
{
uint16_t port = 0U;
@ -698,6 +715,7 @@ uint16_t Socket::port(const sockaddr_storage& addr)
}
/* Helper to check if the address stored in a sockaddr_storage socket address structure is INADDR_NONE. */
bool Socket::isNone(const sockaddr_storage& addr)
{
struct sockaddr_in* in = (struct sockaddr_in*)& addr;
@ -710,6 +728,7 @@ bool Socket::isNone(const sockaddr_storage& addr)
// ---------------------------------------------------------------------------
/* Internal helper to initialize the socket. */
bool Socket::initSocket(const int domain, const int type, const int protocol) noexcept(false)
{
m_fd = ::socket(domain, type, protocol);
@ -723,6 +742,7 @@ bool Socket::initSocket(const int domain, const int type, const int protocol) no
}
/* Internal helper to bind to a address and port. */
bool Socket::bind(const std::string& ipAddr, const uint16_t port) noexcept(false)
{
m_localAddress = std::string(ipAddr);
@ -742,6 +762,7 @@ bool Socket::bind(const std::string& ipAddr, const uint16_t port) noexcept(false
}
/* Initialize the sockaddr_in structure with the provided IP and port */
void Socket::initAddr(const std::string& ipAddr, const int port, sockaddr_in& addr) noexcept(false)
{
addr.sin_family = AF_INET;

@ -33,6 +33,7 @@ const uint8_t SCRAMBLER[] = {
// ---------------------------------------------------------------------------
/* Helper to scramble the NXDN frame data. */
void NXDNUtils::scrambler(uint8_t* data)
{
assert(data != nullptr);
@ -42,6 +43,7 @@ void NXDNUtils::scrambler(uint8_t* data)
}
/* Helper to add the post field bits on NXDN frame data. */
void NXDNUtils::addPostBits(uint8_t* data)
{
assert(data != nullptr);

@ -22,6 +22,7 @@ using namespace nxdn::defines;
// ---------------------------------------------------------------------------
/* Helper to append NXDN sync bytes to the passed buffer. */
void Sync::addNXDNSync(uint8_t* data)
{
assert(data != nullptr);

@ -26,6 +26,7 @@ RadioIdLookup* AccessControl::m_ridLookup;
TalkgroupRulesLookup* AccessControl::m_tidLookup;
/* Initializes the NXDN access control. */
void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup)
{
m_ridLookup = ridLookup;
@ -33,6 +34,7 @@ void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLook
}
/* Helper to validate a source radio ID. */
bool AccessControl::validateSrcId(uint32_t id)
{
// check if RID ACLs are enabled
@ -54,6 +56,7 @@ bool AccessControl::validateSrcId(uint32_t id)
}
/* Helper to validate a talkgroup ID. */
bool AccessControl::validateTGId(uint32_t id)
{
// TG0 is never valid
@ -77,6 +80,7 @@ bool AccessControl::validateTGId(uint32_t id)
}
/* Helper to determine if a talkgroup ID is non-preferred. */
bool AccessControl::tgidNonPreferred(uint32_t id)
{
// TG0 is never valid

@ -95,6 +95,7 @@ const uint32_t PUNCTURE_LIST_OUT[] = {
// ---------------------------------------------------------------------------
/* Initializes a new instance of the CAC class. */
CAC::CAC() :
m_ran(0U),
m_structure(ChStructure::SR_RCCH_SINGLE),
@ -109,6 +110,7 @@ CAC::CAC() :
}
/* Initializes a copy instance of the CAC class. */
CAC::CAC(const CAC& data) :
m_ran(0U),
m_structure(ChStructure::SR_RCCH_SINGLE),
@ -123,12 +125,14 @@ CAC::CAC(const CAC& data) :
}
/* Finalizes a instance of CAC class. */
CAC::~CAC()
{
delete[] m_data;
}
/* Equals operator. */
CAC& CAC::operator=(const CAC& data)
{
if (&data != this) {
@ -150,6 +154,7 @@ CAC& CAC::operator=(const CAC& data)
}
/* Decode a common access channel. */
bool CAC::decode(const uint8_t* data, bool longInbound)
{
assert(data != nullptr);
@ -300,6 +305,7 @@ bool CAC::decode(const uint8_t* data, bool longInbound)
}
/* Encode a common access channel. */
void CAC::encode(uint8_t* data) const
{
assert(data != nullptr);
@ -379,6 +385,7 @@ void CAC::encode(uint8_t* data) const
}
/* Gets the raw CAC data. */
void CAC::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -398,6 +405,7 @@ void CAC::getData(uint8_t* data) const
}
/* Sets the raw CAC data. */
void CAC::setData(const uint8_t* data)
{
assert(data != nullptr);
@ -416,6 +424,7 @@ void CAC::setData(const uint8_t* data)
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void CAC::copy(const CAC& data)
{
m_data = new uint8_t[NXDN_CAC_CRC_LENGTH_BYTES];

@ -48,6 +48,7 @@ const uint32_t PUNCTURE_LIST[] = {
// ---------------------------------------------------------------------------
/* Initializes a new instance of the FACCH1 class. */
FACCH1::FACCH1() :
m_data(nullptr)
{
@ -56,6 +57,7 @@ FACCH1::FACCH1() :
}
/* Initializes a copy instance of the FACCH1 class. */
FACCH1::FACCH1(const FACCH1& data) :
m_data(nullptr)
{
@ -63,12 +65,14 @@ FACCH1::FACCH1(const FACCH1& data) :
}
/* Finalizes a instance of FACCH1 class. */
FACCH1::~FACCH1()
{
delete[] m_data;
}
/* Equals operator. */
FACCH1& FACCH1::operator=(const FACCH1& data)
{
if (&data != this) {
@ -79,6 +83,7 @@ FACCH1& FACCH1::operator=(const FACCH1& data)
}
/* Decode a fast associated control channel 1. */
bool FACCH1::decode(const uint8_t* data, uint32_t offset)
{
assert(data != nullptr);
@ -146,6 +151,7 @@ bool FACCH1::decode(const uint8_t* data, uint32_t offset)
}
/* Encode a fast associated control channel 1. */
void FACCH1::encode(uint8_t* data, uint32_t offset) const
{
assert(data != nullptr);
@ -195,6 +201,7 @@ void FACCH1::encode(uint8_t* data, uint32_t offset) const
}
/* Gets the raw FACCH1 data. */
void FACCH1::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -203,6 +210,7 @@ void FACCH1::getData(uint8_t* data) const
}
/* Sets the raw FACCH1 data. */
void FACCH1::setData(const uint8_t* data)
{
assert(data != nullptr);
@ -215,6 +223,7 @@ void FACCH1::setData(const uint8_t* data)
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void FACCH1::copy(const FACCH1& data)
{
m_data = new uint8_t[NXDN_FACCH1_CRC_LENGTH_BYTES];

@ -25,6 +25,7 @@ using namespace nxdn::channel;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the LICH class. */
LICH::LICH() :
m_rfct(RFChannelType::RCCH),
m_fct(FuncChannelType::USC_SACCH_NS),
@ -36,6 +37,7 @@ LICH::LICH() :
}
/* Initializes a copy instance of the LICH class. */
LICH::LICH(const LICH& data) :
m_rfct(RFChannelType::RCCH),
m_fct(FuncChannelType::USC_SACCH_NS),
@ -47,12 +49,11 @@ LICH::LICH(const LICH& data) :
}
/* Finalizes a instance of LICH class. */
LICH::~LICH()
{
/* stub */
}
LICH::~LICH() = default;
/* Equals operator. */
LICH& LICH::operator=(const LICH& data)
{
if (&data != this) {
@ -68,6 +69,7 @@ LICH& LICH::operator=(const LICH& data)
}
/* Decode a link information channel. */
bool LICH::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -99,6 +101,7 @@ bool LICH::decode(const uint8_t* data)
}
/* Encode a link information channel. */
void LICH::encode(uint8_t* data)
{
assert(data != nullptr);
@ -147,6 +150,7 @@ void LICH::encode(uint8_t* data)
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void LICH::copy(const LICH& data)
{
m_lich = data.m_lich;
@ -158,6 +162,7 @@ void LICH::copy(const LICH& data)
}
/* Internal helper to generate the parity bit for the LICH. */
bool LICH::getParity() const
{
switch (m_lich & 0xF0U) {

@ -41,6 +41,7 @@ const uint32_t PUNCTURE_LIST[] = { 5U, 11U, 17U, 23U, 29U, 35U, 41U, 47U, 53U, 5
// ---------------------------------------------------------------------------
/* Initializes a new instance of the SACCH class. */
SACCH::SACCH() :
m_ran(0U),
m_structure(ChStructure::SR_SINGLE),
@ -51,6 +52,7 @@ SACCH::SACCH() :
}
/* Initializes a copy instance of the SACCH class. */
SACCH::SACCH(const SACCH& data) :
m_ran(0U),
m_structure(ChStructure::SR_SINGLE),
@ -60,12 +62,14 @@ SACCH::SACCH(const SACCH& data) :
}
/* Finalizes a instance of SACCH class. */
SACCH::~SACCH()
{
delete[] m_data;
}
/* Equals operator. */
SACCH& SACCH::operator=(const SACCH& data)
{
if (&data != this) {
@ -79,6 +83,7 @@ SACCH& SACCH::operator=(const SACCH& data)
}
/* Decode a slow associated control channel. */
bool SACCH::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -151,6 +156,7 @@ bool SACCH::decode(const uint8_t* data)
}
/* Encode a slow associated control channel. */
void SACCH::encode(uint8_t* data) const
{
assert(data != nullptr);
@ -210,6 +216,7 @@ void SACCH::encode(uint8_t* data) const
}
/* Gets the raw SACCH data. */
void SACCH::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -222,6 +229,7 @@ void SACCH::getData(uint8_t* data) const
}
/* Sets the raw SACCH data. */
void SACCH::setData(const uint8_t* data)
{
assert(data != nullptr);
@ -238,6 +246,7 @@ void SACCH::setData(const uint8_t* data)
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void SACCH::copy(const SACCH& data)
{
m_data = new uint8_t[NXDN_SACCH_CRC_LENGTH_BYTES];

@ -70,6 +70,7 @@ const uint32_t PUNCTURE_LIST[] = {
// ---------------------------------------------------------------------------
/* Initializes a new instance of the UDCH class. */
UDCH::UDCH() :
m_ran(0U),
m_data(nullptr)
@ -79,6 +80,7 @@ UDCH::UDCH() :
}
/* Initializes a copy instance of the UDCH class. */
UDCH::UDCH(const UDCH& data) :
m_ran(0U),
m_data(nullptr)
@ -87,12 +89,14 @@ UDCH::UDCH(const UDCH& data) :
}
/* Finalizes a instance of UDCH class. */
UDCH::~UDCH()
{
delete[] m_data;
}
/* Equals operator. */
UDCH& UDCH::operator=(const UDCH& data)
{
if (&data != this) {
@ -105,6 +109,7 @@ UDCH& UDCH::operator=(const UDCH& data)
}
/* Decode a user data channel. */
bool UDCH::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -174,6 +179,7 @@ bool UDCH::decode(const uint8_t* data)
}
/* Encode a user data channel. */
void UDCH::encode(uint8_t* data) const
{
assert(data != nullptr);
@ -225,6 +231,7 @@ void UDCH::encode(uint8_t* data) const
}
/* Gets the raw UDCH data. */
void UDCH::getData(uint8_t* data) const
{
assert(data != nullptr);
@ -233,6 +240,7 @@ void UDCH::getData(uint8_t* data) const
}
/* Sets the raw UDCH data. */
void UDCH::setData(const uint8_t* data)
{
assert(data != nullptr);
@ -245,6 +253,7 @@ void UDCH::setData(const uint8_t* data)
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void UDCH::copy(const UDCH& data)
{
m_data = new uint8_t[NXDN_UDCH_CRC_LENGTH_BYTES];

@ -34,6 +34,7 @@ const uint32_t K = 5U;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Convolution class. */
Convolution::Convolution() :
m_metrics1(nullptr),
m_metrics2(nullptr),
@ -48,6 +49,7 @@ Convolution::Convolution() :
}
/* Finalizes a instance of the Convolution class. */
Convolution::~Convolution()
{
delete[] m_metrics1;
@ -56,6 +58,7 @@ Convolution::~Convolution()
}
/* Starts convolution processing. */
void Convolution::start()
{
::memset(m_metrics1, 0x00U, NUM_OF_STATES * sizeof(uint16_t));
@ -67,6 +70,7 @@ void Convolution::start()
}
/* */
uint32_t Convolution::chainback(uint8_t* out, uint32_t nBits)
{
assert(out != nullptr);
@ -94,6 +98,7 @@ uint32_t Convolution::chainback(uint8_t* out, uint32_t nBits)
}
/* */
bool Convolution::decode(uint8_t s0, uint8_t s1)
{
*m_dp = 0U;
@ -130,6 +135,7 @@ bool Convolution::decode(uint8_t s0, uint8_t s1)
}
/* */
void Convolution::encode(const uint8_t* in, uint8_t* out, uint32_t nBits) const
{
assert(in != nullptr);

@ -24,6 +24,7 @@ using namespace nxdn::lc;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the PacketInformation class. */
PacketInformation::PacketInformation() :
m_delivery(false),
m_selectiveRetry(false),
@ -40,9 +41,11 @@ PacketInformation::PacketInformation() :
}
/* Finalizes a instance of the PacketInformation class. */
PacketInformation::~PacketInformation() = default;
/* Decodes packet information. */
bool PacketInformation::decode(const uint8_t messageType, const uint8_t* data)
{
assert(data != nullptr);
@ -83,6 +86,7 @@ bool PacketInformation::decode(const uint8_t messageType, const uint8_t* data)
}
/* Encodes packet information. */
void PacketInformation::encode(const uint8_t messageType, uint8_t* data)
{
assert(data != nullptr);
@ -134,6 +138,7 @@ void PacketInformation::encode(const uint8_t messageType, uint8_t* data)
}
/* Helper to reset data values to defaults. */
void PacketInformation::reset()
{
m_delivery = false;

@ -32,6 +32,7 @@ SiteData RCCH::m_siteData = SiteData();
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RCCH class. */
RCCH::RCCH() :
m_messageType(MessageType::IDLE),
m_srcId(0U),
@ -57,24 +58,28 @@ RCCH::RCCH() :
}
/* Initializes a copy instance of the RCCH class. */
RCCH::RCCH(const RCCH& data) : RCCH()
{
copy(data);
}
/* Finalizes a instance of RCCH class. */
RCCH::~RCCH()
{
/* stub */
}
/* Returns a string that represents the current RCCH. */
std::string RCCH::toString(bool isp)
{
return std::string("MESSAGE_TYPE_UNKWN (Unknown RCCH)");
}
/* Sets the callsign. */
void RCCH::setCallsign(std::string callsign)
{
if (m_siteCallsign == nullptr) {
@ -98,6 +103,7 @@ void RCCH::setCallsign(std::string callsign)
// ---------------------------------------------------------------------------
/* Internal helper to decode a RCCH link control message. */
void RCCH::decode(const uint8_t* data, uint8_t* rcch, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -116,6 +122,7 @@ void RCCH::decode(const uint8_t* data, uint8_t* rcch, uint32_t length, uint32_t
}
/* Internal helper to encode a RCCH link control message. */
void RCCH::encode(uint8_t* data, const uint8_t* rcch, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -136,6 +143,7 @@ void RCCH::encode(uint8_t* data, const uint8_t* rcch, uint32_t length, uint32_t
}
/* Internal helper to copy the the class. */
void RCCH::copy(const RCCH& data)
{
m_messageType = data.m_messageType;

@ -31,6 +31,7 @@ bool RTCH::m_verbose = false;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RTCH class. */
RTCH::RTCH() :
m_messageType(MessageType::IDLE),
m_callType(CallType::UNSPECIFIED),
@ -56,6 +57,7 @@ RTCH::RTCH() :
}
/* Initializes a copy instance of the RTCH class. */
RTCH::RTCH(const RTCH& data) :
m_messageType(MessageType::IDLE),
m_callType(CallType::UNSPECIFIED),
@ -80,12 +82,14 @@ RTCH::RTCH(const RTCH& data) :
}
/* Finalizes a instance of RTCH class. */
RTCH::~RTCH()
{
delete[] m_mi;
}
/* Equals operator. */
RTCH& RTCH::operator=(const RTCH& data)
{
if (&data != this) {
@ -96,6 +100,7 @@ RTCH& RTCH::operator=(const RTCH& data)
}
/* Decode call link control data. */
void RTCH::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -116,6 +121,7 @@ void RTCH::decode(const uint8_t* data, uint32_t length, uint32_t offset)
}
/* Encode call link control data. */
void RTCH::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -136,6 +142,7 @@ void RTCH::encode(uint8_t* data, uint32_t length, uint32_t offset)
}
/* Helper to reset data values to defaults. */
void RTCH::reset()
{
m_messageType = MessageType::IDLE;
@ -169,6 +176,7 @@ void RTCH::reset()
// ---------------------------------------------------------------------------
/* Internal helper to decode a RTCH link control message. */
bool RTCH::decodeLC(const uint8_t* data)
{
assert(data != nullptr);
@ -282,6 +290,7 @@ bool RTCH::decodeLC(const uint8_t* data)
}
/* Internal helper to encode a RTCH link control message. */
void RTCH::encodeLC(uint8_t* data)
{
assert(data != nullptr);
@ -399,6 +408,7 @@ void RTCH::encodeLC(uint8_t* data)
}
/* Internal helper to copy the the class. */
void RTCH::copy(const RTCH& data)
{
m_messageType = data.m_messageType;

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_DCALL_HDR class. */
MESSAGE_TYPE_DCALL_HDR::MESSAGE_TYPE_DCALL_HDR() : RCCH()
{
m_messageType = MessageType::RTCH_DCALL_HDR;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_DCALL_HDR::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -47,6 +49,7 @@ void MESSAGE_TYPE_DCALL_HDR::decode(const uint8_t* data, uint32_t length, uint32
}
/* Encode RCCH data. */
void MESSAGE_TYPE_DCALL_HDR::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -73,6 +76,7 @@ void MESSAGE_TYPE_DCALL_HDR::encode(uint8_t* data, uint32_t length, uint32_t off
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_DCALL_HDR::toString(bool isp)
{
return std::string("RTCH_DCALL_HDR (Data Call Header)");

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_DST_ID_INFO class. */
MESSAGE_TYPE_DST_ID_INFO::MESSAGE_TYPE_DST_ID_INFO() : RCCH()
{
m_messageType = MessageType::DST_ID_INFO;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_DST_ID_INFO::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -39,6 +41,7 @@ void MESSAGE_TYPE_DST_ID_INFO::decode(const uint8_t* data, uint32_t length, uint
}
/* Encode RCCH data. */
void MESSAGE_TYPE_DST_ID_INFO::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -56,6 +59,7 @@ void MESSAGE_TYPE_DST_ID_INFO::encode(uint8_t* data, uint32_t length, uint32_t o
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_DST_ID_INFO::toString(bool isp)
{
return std::string("DST_ID_INFO (Digital Station ID)");

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_GRP_REG class. */
MESSAGE_TYPE_GRP_REG::MESSAGE_TYPE_GRP_REG() : RCCH()
{
m_messageType = MessageType::RCCH_GRP_REG;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_GRP_REG::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -43,6 +45,7 @@ void MESSAGE_TYPE_GRP_REG::decode(const uint8_t* data, uint32_t length, uint32_t
}
/* Encode RCCH data. */
void MESSAGE_TYPE_GRP_REG::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -62,6 +65,7 @@ void MESSAGE_TYPE_GRP_REG::encode(uint8_t* data, uint32_t length, uint32_t offse
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_GRP_REG::toString(bool isp)
{
return (isp) ? std::string("RCCH_GRP_REG (Group Registration Request)") :

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_IDLE class. */
MESSAGE_TYPE_IDLE::MESSAGE_TYPE_IDLE() : RCCH()
{
m_messageType = MessageType::IDLE;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_IDLE::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -39,6 +41,7 @@ void MESSAGE_TYPE_IDLE::decode(const uint8_t* data, uint32_t length, uint32_t of
}
/* Encode RCCH data. */
void MESSAGE_TYPE_IDLE::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -50,6 +53,7 @@ void MESSAGE_TYPE_IDLE::encode(uint8_t* data, uint32_t length, uint32_t offset)
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_IDLE::toString(bool isp)
{
return std::string("IDLE (Idle)");

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_REG_C class. */
MESSAGE_TYPE_REG_C::MESSAGE_TYPE_REG_C() : RCCH()
{
m_messageType = MessageType::RCCH_REG_C;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_REG_C::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -43,6 +45,7 @@ void MESSAGE_TYPE_REG_C::decode(const uint8_t* data, uint32_t length, uint32_t o
}
/* Encode RCCH data. */
void MESSAGE_TYPE_REG_C::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -60,6 +63,7 @@ void MESSAGE_TYPE_REG_C::encode(uint8_t* data, uint32_t length, uint32_t offset)
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_REG_C::toString(bool isp)
{
return (isp) ? std::string("RCCH_REG_C (Registration Clear Request)") :

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_REG_COMM class. */
MESSAGE_TYPE_REG_COMM::MESSAGE_TYPE_REG_COMM() : RCCH()
{
m_messageType = MessageType::RCCH_REG_COMM;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_REG_COMM::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -39,6 +41,7 @@ void MESSAGE_TYPE_REG_COMM::decode(const uint8_t* data, uint32_t length, uint32_
}
/* Encode RCCH data. */
void MESSAGE_TYPE_REG_COMM::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -55,6 +58,7 @@ void MESSAGE_TYPE_REG_COMM::encode(uint8_t* data, uint32_t length, uint32_t offs
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_REG_COMM::toString(bool isp)
{
return std::string("RCCH_REG_COMM (Registration Command)");

@ -22,6 +22,7 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_SITE_INFO class. */
MESSAGE_TYPE_SITE_INFO::MESSAGE_TYPE_SITE_INFO() : RCCH(),
m_bcchCnt(1U),
m_rcchGroupingCnt(1U),
@ -33,6 +34,7 @@ MESSAGE_TYPE_SITE_INFO::MESSAGE_TYPE_SITE_INFO() : RCCH(),
}
/* Decode RCCH data. */
void MESSAGE_TYPE_SITE_INFO::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -44,6 +46,7 @@ void MESSAGE_TYPE_SITE_INFO::decode(const uint8_t* data, uint32_t length, uint32
}
/* Encode RCCH data. */
void MESSAGE_TYPE_SITE_INFO::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -89,6 +92,7 @@ void MESSAGE_TYPE_SITE_INFO::encode(uint8_t* data, uint32_t length, uint32_t off
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_SITE_INFO::toString(bool isp)
{
return std::string("RCCH_SITE_INFO (Site Information)");
@ -99,6 +103,7 @@ std::string MESSAGE_TYPE_SITE_INFO::toString(bool isp)
// ---------------------------------------------------------------------------
/* Internal helper to copy the the class. */
void MESSAGE_TYPE_SITE_INFO::copy(const MESSAGE_TYPE_SITE_INFO& data)
{
RCCH::copy(data);

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_SRV_INFO class. */
MESSAGE_TYPE_SRV_INFO::MESSAGE_TYPE_SRV_INFO() : RCCH()
{
m_messageType = MessageType::SRV_INFO;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_SRV_INFO::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -39,6 +41,7 @@ void MESSAGE_TYPE_SRV_INFO::decode(const uint8_t* data, uint32_t length, uint32_
}
/* Encode RCCH data. */
void MESSAGE_TYPE_SRV_INFO::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -66,6 +69,7 @@ void MESSAGE_TYPE_SRV_INFO::encode(uint8_t* data, uint32_t length, uint32_t offs
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_SRV_INFO::toString(bool isp)
{
return std::string("SRV_INFO (Service Information)");

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_VCALL_ASSGN class. */
MESSAGE_TYPE_VCALL_ASSGN::MESSAGE_TYPE_VCALL_ASSGN() : RCCH()
{
m_messageType = MessageType::RCCH_VCALL_ASSGN;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_VCALL_ASSGN::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -39,6 +41,7 @@ void MESSAGE_TYPE_VCALL_ASSGN::decode(const uint8_t* data, uint32_t length, uint
}
/* Encode RCCH data. */
void MESSAGE_TYPE_VCALL_ASSGN::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -67,6 +70,7 @@ void MESSAGE_TYPE_VCALL_ASSGN::encode(uint8_t* data, uint32_t length, uint32_t o
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_VCALL_ASSGN::toString(bool isp)
{
return std::string("RCCH_VCALL_ASSGN (Voice Call Assignment)");

@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MESSAGE_TYPE_VCALL_CONN class. */
MESSAGE_TYPE_VCALL_CONN::MESSAGE_TYPE_VCALL_CONN() : RCCH()
{
m_messageType = MessageType::RCCH_VCALL_CONN;
}
/* Decode RCCH data. */
void MESSAGE_TYPE_VCALL_CONN::decode(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -47,6 +49,7 @@ void MESSAGE_TYPE_VCALL_CONN::decode(const uint8_t* data, uint32_t length, uint3
}
/* Encode RCCH data. */
void MESSAGE_TYPE_VCALL_CONN::encode(uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -73,6 +76,7 @@ void MESSAGE_TYPE_VCALL_CONN::encode(uint8_t* data, uint32_t length, uint32_t of
}
/* Returns a string that represents the current RCCH. */
std::string MESSAGE_TYPE_VCALL_CONN::toString(bool isp)
{
return (isp) ? std::string("RCCH_VCALL_CONN (Voice Call Connection Request)") :

@ -24,12 +24,15 @@ using namespace nxdn::lc::rcch;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the RCCHFactory class. */
RCCHFactory::RCCHFactory() = default;
/* Finalizes a instance of RCCHFactory class. */
RCCHFactory::~RCCHFactory() = default;
/* Create an instance of a RCCH. */
std::unique_ptr<RCCH> RCCHFactory::createRCCH(const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(data != nullptr);
@ -64,6 +67,7 @@ std::unique_ptr<RCCH> RCCHFactory::createRCCH(const uint8_t* data, uint32_t leng
// ---------------------------------------------------------------------------
/* Internal helper to decode a RCCH link control message. */
std::unique_ptr<RCCH> RCCHFactory::decode(RCCH* rcch, const uint8_t* data, uint32_t length, uint32_t offset)
{
assert(rcch != nullptr);

@ -23,6 +23,7 @@ using namespace p25;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the Audio class. */
Audio::Audio() :
m_fec()
{
@ -30,9 +31,11 @@ Audio::Audio() :
}
/* Finalizes a instance of the Audio class. */
Audio::~Audio() = default;
/* Process P25 IMBE audio data. */
uint32_t Audio::process(uint8_t* data)
{
assert(data != nullptr);
@ -81,6 +84,7 @@ uint32_t Audio::process(uint8_t* data)
}
/* Decode a P25 IMBE audio frame. */
void Audio::decode(const uint8_t* data, uint8_t* imbe, uint32_t n)
{
assert(data != nullptr);
@ -193,6 +197,7 @@ void Audio::decode(const uint8_t* data, uint8_t* imbe, uint32_t n)
}
/* Encode a P25 IMBE audio frame. */
void Audio::encode(uint8_t* data, const uint8_t* imbe, uint32_t n)
{
assert(data != nullptr);

@ -31,6 +31,7 @@ const uint32_t MAX_NID_ERRS = 7U;//5U;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the NID class. */
NID::NID(uint32_t nac) :
m_duid(DUID::HDU),
m_nac(nac),
@ -50,6 +51,7 @@ NID::NID(uint32_t nac) :
}
/* Finalizes a instance of the NID class. */
NID::~NID()
{
cleanupArrays();
@ -58,6 +60,7 @@ NID::~NID()
}
/* Decodes P25 network identifier data. */
bool NID::decode(const uint8_t* data)
{
assert(data != nullptr);
@ -118,6 +121,7 @@ bool NID::decode(const uint8_t* data)
}
/* Encodes P25 network identifier data. */
void NID::encode(uint8_t* data, defines::DUID::E duid)
{
assert(data != nullptr);
@ -161,6 +165,7 @@ void NID::encode(uint8_t* data, defines::DUID::E duid)
}
/* Helper to configure a separate Tx NAC. */
void NID::setTxNAC(uint32_t nac)
{
if (nac == m_nac) {
@ -176,6 +181,7 @@ void NID::setTxNAC(uint32_t nac)
// ---------------------------------------------------------------------------
/* Cleanup NID arrays. */
void NID::cleanupArrays()
{
for (uint8_t i = 0; i < 16U; i++)
@ -191,6 +197,7 @@ void NID::cleanupArrays()
}
/* Internal helper to create the Rx/Tx NID. */
void NID::createRxTxNID(uint32_t nac)
{
edac::BCH bch;
@ -246,6 +253,7 @@ void NID::createRxTxNID(uint32_t nac)
}
/* Internal helper to create Tx NID. */
void NID::createTxNID(uint32_t nac)
{
edac::BCH bch;

@ -22,6 +22,7 @@ using namespace p25::defines;
// ---------------------------------------------------------------------------
/* Helper to set the busy status bits on P25 frame data. */
void P25Utils::setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2)
{
assert(data != nullptr);
@ -31,6 +32,7 @@ void P25Utils::setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2)
}
/* Helper to add the busy status bits on P25 frame data. */
void P25Utils::addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2)
{
assert(data != nullptr);
@ -51,6 +53,7 @@ void P25Utils::addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2)
}
/* Helper to add the idle status bits on P25 frame data. */
void P25Utils::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2)
{
assert(data != nullptr);
@ -63,6 +66,7 @@ void P25Utils::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2)
}
/* Decode bit interleaving. */
uint32_t P25Utils::decode(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop)
{
assert(in != nullptr);
@ -96,6 +100,7 @@ uint32_t P25Utils::decode(const uint8_t* in, uint8_t* out, uint32_t start, uint3
}
/* Encode bit interleaving. */
uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop)
{
assert(in != nullptr);
@ -129,6 +134,7 @@ uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t start, uint3
}
/* Encode bit interleaving. */
uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t length)
{
assert(in != nullptr);
@ -163,6 +169,7 @@ uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t length)
}
/* Compare two datasets for the given length. */
uint32_t P25Utils::compare(const uint8_t* data1, const uint8_t* data2, uint32_t length)
{
assert(data1 != nullptr);

@ -23,6 +23,7 @@ using namespace p25::defines;
// ---------------------------------------------------------------------------
/* Helper to append P25 sync bytes to the passed buffer. */
void Sync::addP25Sync(uint8_t* data)
{
assert(data != nullptr);

@ -22,6 +22,7 @@ RadioIdLookup* AccessControl::m_ridLookup;
TalkgroupRulesLookup* AccessControl::m_tidLookup;
/* Initializes the P25 access control. */
void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup)
{
m_ridLookup = ridLookup;
@ -29,6 +30,7 @@ void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLook
}
/* Helper to validate a source radio ID. */
bool AccessControl::validateSrcId(uint32_t id)
{
// check if RID ACLs are enabled
@ -50,6 +52,7 @@ bool AccessControl::validateSrcId(uint32_t id)
}
/* Helper to validate a talkgroup ID. */
bool AccessControl::validateTGId(uint32_t id)
{
// TG0 is never valid
@ -73,6 +76,7 @@ bool AccessControl::validateTGId(uint32_t id)
}
/* Helper to determine if a talkgroup ID is non-preferred. */
bool AccessControl::tgidNonPreferred(uint32_t id)
{
// TG0 is never valid

@ -26,6 +26,7 @@ using namespace p25::data;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the DataBlock class. */
DataBlock::DataBlock() :
m_serialNo(0U),
m_lastBlock(false),
@ -40,12 +41,14 @@ DataBlock::DataBlock() :
}
/* Finalizes a instance of the DataBlock class. */
DataBlock::~DataBlock()
{
delete[] m_data;
}
/* Decodes P25 PDU data block. */
bool DataBlock::decode(const uint8_t* data, const DataHeader& header)
{
assert(data != nullptr);
@ -150,6 +153,7 @@ bool DataBlock::decode(const uint8_t* data, const DataHeader& header)
}
/* Encodes a P25 PDU data block. */
void DataBlock::encode(uint8_t* data)
{
assert(data != nullptr);
@ -217,24 +221,28 @@ void DataBlock::encode(uint8_t* data)
}
/* Sets the data format. */
void DataBlock::setFormat(const uint8_t fmt)
{
m_fmt = fmt;
}
/* Sets the data format from the data header. */
void DataBlock::setFormat(const DataHeader& header)
{
m_fmt = header.getFormat();
}
/* Gets the data format. */
uint8_t DataBlock::getFormat() const
{
return m_fmt;
}
/* Sets the raw data stored in the data block. */
void DataBlock::setData(const uint8_t* buffer)
{
assert(buffer != nullptr);
@ -252,6 +260,7 @@ void DataBlock::setData(const uint8_t* buffer)
}
/* Gets the raw data stored in the data block. */
uint32_t DataBlock::getData(uint8_t* buffer) const
{
assert(buffer != nullptr);

@ -36,6 +36,7 @@ bool DataHeader::m_warnCRC = false;
// ---------------------------------------------------------------------------
/* Initializes a new instance of the DataHeader class. */
DataHeader::DataHeader() :
m_ackNeeded(false),
m_outbound(false),
@ -66,12 +67,14 @@ DataHeader::DataHeader() :
}
/* Finalizes a instance of the DataHeader class. */
DataHeader::~DataHeader()
{
delete[] m_data;
}
/* Decodes P25 PDU data header. */
bool DataHeader::decode(const uint8_t* data, bool noTrellis)
{
assert(data != nullptr);
@ -169,6 +172,7 @@ bool DataHeader::decode(const uint8_t* data, bool noTrellis)
}
/* Encodes P25 PDU data header. */
void DataHeader::encode(uint8_t* data, bool noTrellis)
{
assert(data != nullptr);
@ -250,6 +254,7 @@ void DataHeader::encode(uint8_t* data, bool noTrellis)
}
/* Helper to reset data values to defaults. */
void DataHeader::reset()
{
m_ackNeeded = false;
@ -286,6 +291,7 @@ void DataHeader::reset()
}
/* Gets the total length in bytes of enclosed packet data. */
uint32_t DataHeader::getPacketLength() const
{
if (m_fmt == PDUFormatType::CONFIRMED) {
@ -297,6 +303,7 @@ uint32_t DataHeader::getPacketLength() const
}
/* Gets the raw header data. */
uint32_t DataHeader::getData(uint8_t* buffer) const
{
assert(buffer != nullptr);
@ -307,6 +314,7 @@ uint32_t DataHeader::getData(uint8_t* buffer) const
}
/* Helper to determine the pad length for a given packet length. */
uint32_t DataHeader::calculatePadLength(uint8_t fmt, uint32_t packetLength)
{
uint32_t len = packetLength + 4;

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

Loading…
Cancel
Save

Powered by TurnKey Linux.