diff --git a/CMakeLists.txt b/CMakeLists.txt index 30f17591..d41d1f28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ option(COMPILE_WIN32 "Compile for Win32" off) if (COMPILE_WIN32) set(ARCH amd64) set(CMAKE_SYSTEM_PROCESSOR amd64) + message(CHECK_START "Detect Host Architecture - ${ARCH}") # No TUI for this set(ENABLE_TUI_SUPPORT OFF) @@ -49,7 +50,25 @@ if (COMPILE_WIN32) else() set(CMAKE_C_COMPILER /usr/bin/gcc CACHE STRING "C compiler") set(CMAKE_CXX_COMPILER /usr/bin/g++ CACHE STRING "C++ compiler") + + # detect and set architecture set(ARCH amd64) + + if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + set(ARCH amd64) + set(CMAKE_SYSTEM_PROCESSOR amd64) + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) + else() + if (CMAKE_SYSTEM_PROCESSOR MATCHES "") + execute_process(COMMAND uname -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) + string(REGEX REPLACE "\n$" "" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}") + set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) + else() + set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) + endif (CMAKE_SYSTEM_PROCESSOR MATCHES "") + endif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + message(CHECK_START "Detect Host Architecture - ${ARCH}") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) endif (COMPILE_WIN32) @@ -60,6 +79,7 @@ if (CROSS_COMPILE_ARM) set(CMAKE_SYSTEM_PROCESSOR armhf) set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf) set(OPENSSL_ROOT_DIR /usr/lib/arm-linux-gnueabihf) + message(CHECK_START "Target Architecture - ${ARCH}") message(CHECK_START "Cross compiling for 32-bit ARM - ${CMAKE_C_COMPILER}") endif (CROSS_COMPILE_ARM) if (CROSS_COMPILE_AARCH64) @@ -69,6 +89,7 @@ if (CROSS_COMPILE_AARCH64) set(CMAKE_SYSTEM_PROCESSOR arm64) set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64) set(OPENSSL_ROOT_DIR /usr/lib/aarch64-linux-gnu) + message(CHECK_START "Target Architecture - ${ARCH}") message(CHECK_START "Cross compiling for 64-bit ARM - ${CMAKE_C_COMPILER}") endif (CROSS_COMPILE_AARCH64) @@ -107,6 +128,7 @@ if (CROSS_COMPILE_RPI_ARM) set(ARCH armhf) set(CMAKE_SYSTEM_PROCESSOR armhf) set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf) + message(CHECK_START "Target Architecture - ${ARCH}") message(CHECK_START "Cross compiling for (old RPi) 32-bit ARM - ${CMAKE_C_COMPILER}") # No TUI for this diff --git a/configs/config.example.yml b/configs/config.example.yml index 96e7e68c..f7d045c6 100644 --- a/configs/config.example.yml +++ b/configs/config.example.yml @@ -224,6 +224,8 @@ protocols: enableTimeDateAnn: false # Flag indicating whether or not the source ID validation before granting disabled. disableGrantSourceIdCheck: false + # Flag indicating whether or not the adjacent site broadcasts are disabled. + disableAdjSiteBroadcast: false # Flag indicating immediate TSDUs will be sent twice. redundantImmediate: true # Flag indicating whether redundant grant responses should be transmitted. @@ -401,8 +403,10 @@ system: supervisor: false # Channel Identity (corresponds to the appropriate entry in the iden_table file). + # Note: When using explicit channels, this represents the transmit channel number. channelId: 2 # Channel Number (used to calculate actual host frequency based on the identity table). + # Note: When using explicit channels, this represents the transmit channel number. channelNo: 1 # @@ -429,9 +433,17 @@ system: # voiceChNo: # Channel Identity (corresponds to the appropriate entry in the iden_table file). + # Note: When using explicit channels, this represents the transmit channel identity. - channelId: 2 # Channel Number (used to calculate actual host frequency based on the identity table). + # Note: When using explicit channels, this represents the transmit channel number. channelNo: 1 + # Rx Channel Identity (corresponds to the appropriate entry in the iden_table file). + # Note: When this is defined, the voice channel is using explicit channel frequencies. + #rxChannelId: 2 + # Rx Channel Number (used to calculate actual host frequency based on the identity table). + # Note: when this is defined, the voice channel is using explicit channel frequencies. + #rxChannelNo: 2 # RPC IP Address for voice channel. rpcAddress: 127.0.0.1 # RPC Port number for voice channel. diff --git a/configs/fne-config.example.yml b/configs/fne-config.example.yml index 72b5c900..86cef87a 100644 --- a/configs/fne-config.example.yml +++ b/configs/fne-config.example.yml @@ -38,6 +38,8 @@ master: # Hostname/IP address to listen on (blank for all). address: 0.0.0.0 # Port number to listen on. + # NOTE: This port number includes itself for traffic, and master port + 1 for diagnostics and activity logging. (For + # example, a master port of 62031 will use 62032 for diagnostic and activity messages.) port: 62031 # FNE access password. password: RPT1234 @@ -211,22 +213,16 @@ system: # Maximum number of missable pings before a peer is considered disconnected. maxMissedPings: 10 - # Time in minutes between updates of the talkgroup rules. - tgRuleUpdateTime: 10 + # Time in minutes between updates of the ACL rules. + aclRuleUpdateTime: 10 # Flag indicating the TGID information for this master will be sent to its peers. sendTalkgroups: true - # Flag indicating the FNE should use an alternate port dedicated to diagnostic and activity - # log processing. This port number is always: master port + 1 (so for example, a master port - # of 62031 will use 62032 for diagnostic and activity messages.) - # NOTE: Disabling useAlternatePortForDiagnostics will result in some tools like, SysView, to stop working properly. - # SysView requires useAlternatePortForDiagnostics to receive peer status updates. - useAlternatePortForDiagnostics: true - # Flag indicating whether or not the host activity log will be sent to the network. - # NOTE: Disabling allowActivityTransfer will result in some tools like, SysView, to stop working properly. - # SysView requires allowActivityTransfer to receive peer status updates. - allowActivityTransfer: true + # Flag indicating when this FNE instance receives peer link configuration updates, it will save those + # peer link configurations. + peerLinkSaveACL: false + # Flag indicating whether or not the host diagnostic log will be sent to the network. allowDiagnosticTransfer: true diff --git a/src/bridge/BridgeMain.cpp b/src/bridge/BridgeMain.cpp index ea03b492..1bfdb2e9 100644 --- a/src/bridge/BridgeMain.cpp +++ b/src/bridge/BridgeMain.cpp @@ -263,7 +263,7 @@ int main(int argc, char** argv) #endif uint32_t hash = ::strtoul(__GIT_VER_HASH__, 0, 16); - __SET_UINT32(hash, g_gitHashBytes, 0U); + SET_UINT32(hash, g_gitHashBytes, 0U); if (argv[0] != nullptr && *argv[0] != 0) g_progExe = std::string(argv[0]); diff --git a/src/bridge/HostBridge.cpp b/src/bridge/HostBridge.cpp index e4cd1c9e..a6607420 100644 --- a/src/bridge/HostBridge.cpp +++ b/src/bridge/HostBridge.cpp @@ -324,7 +324,7 @@ HostBridge::HostBridge(const std::string& confFile) : m_voxSampleLevel(30.0f), m_dropTimeMS(180U), m_localDropTime(1000U, 0U, 180U), - m_udpCallClock(1000U, 0U, 80U), + m_udpCallClock(1000U, 0U, 160U), m_udpHangTime(1000U, 0U, 180U), m_udpDropTime(1000U, 0U, 180U), m_detectAnalogMDC1200(false), @@ -1100,9 +1100,6 @@ bool HostBridge::createNetwork() if (m_udpUseULaw && m_udpMetadata) m_udpMetadata = false; // metadata isn't supported when encoding uLaw - if (m_udpSilenceDuringHang && m_udpRTPFrames) - m_udpCallClock = Timer(1000U, 0U, 160U); // packets every 160ms - yaml::Node tekConf = networkConf["tek"]; bool tekEnable = tekConf["enable"].as(false); std::string tekAlgo = tekConf["tekAlgo"].as(); @@ -1326,14 +1323,13 @@ void HostBridge::processUDPAudio() if (m_udpNoIncludeLength) { pcmLength = length; } else { - pcmLength = __GET_UINT32(buffer, 0U); + pcmLength = GET_UINT32(buffer, 0U); } if (m_udpRTPFrames || m_udpUsrp) pcmLength = MBE_SAMPLES_LENGTH * 2U; - UInt8Array __pcm = std::make_unique(pcmLength); - uint8_t* pcm = __pcm.get(); + DECLARE_UINT8_ARRAY(pcm, pcmLength); if (!m_udpUsrp) { if (m_udpRTPFrames) { @@ -1404,7 +1400,7 @@ void HostBridge::processUDPAudio() } if (m_udpMetadata) { - req->srcId = __GET_UINT32(buffer, pcmLength + 8U); + req->srcId = GET_UINT32(buffer, pcmLength + 8U); } m_udpPackets.push_back(req); @@ -1454,8 +1450,8 @@ void HostBridge::processDMRNetwork(uint8_t* buffer, uint32_t length) // process network message header uint8_t seqNo = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); FLCO::E flco = (buffer[15U] & 0x40U) == 0x40U ? FLCO::PRIVATE : FLCO::GROUP; @@ -1699,7 +1695,7 @@ void HostBridge::decodeDMRAudioFrame(uint8_t* ambe, uint32_t srcId, uint32_t dst ::memcpy(audioData, pcm, MBE_SAMPLES_LENGTH); } else { - __SET_UINT32(MBE_SAMPLES_LENGTH, audioData, 0U); + SET_UINT32(MBE_SAMPLES_LENGTH, audioData, 0U); ::memcpy(audioData + 4U, pcm, MBE_SAMPLES_LENGTH); } @@ -1720,19 +1716,19 @@ void HostBridge::decodeDMRAudioFrame(uint8_t* ambe, uint32_t srcId, uint32_t dst } } else { - __SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); + SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); ::memcpy(audioData + 4U, pcm, MBE_SAMPLES_LENGTH * 2U); } } else { length = (MBE_SAMPLES_LENGTH * 2U) + 12U; audioData = new uint8_t[(MBE_SAMPLES_LENGTH * 2U) + 12U]; // PCM + (4 bytes (PCM length) + 4 bytes (srcId) + 4 bytes (dstId)) - __SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); + SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); ::memcpy(audioData + 4U, pcm, MBE_SAMPLES_LENGTH * 2U); // embed destination and source IDs - __SET_UINT32(dstId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 4U)); - __SET_UINT32(srcId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 8U)); + SET_UINT32(dstId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 4U)); + SET_UINT32(srcId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 8U)); } } else { @@ -1743,7 +1739,7 @@ void HostBridge::decodeDMRAudioFrame(uint8_t* ambe, uint32_t srcId, uint32_t dst m_usrpSeqNo++; usrpHeader[15U] = 1; // set PTT state to true - __SET_UINT32(m_usrpSeqNo, usrpHeader, 4U); + SET_UINT32(m_usrpSeqNo, usrpHeader, 4U); ::memcpy(usrpHeader, "USRP", 4); ::memcpy(audioData, usrpHeader, USRP_HEADER_LENGTH); // copy USRP header into the UDP payload @@ -1975,8 +1971,8 @@ void HostBridge::processP25Network(uint8_t* buffer, uint32_t length) // handle LDU, TDU or TSDU frame uint8_t lco = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); uint8_t lsd1 = buffer[20U]; uint8_t lsd2 = buffer[21U]; @@ -2026,7 +2022,7 @@ void HostBridge::processP25Network(uint8_t* buffer, uint32_t length) if (frameType == FrameType::HDU_VALID) { m_callAlgoId = buffer[181U]; if (m_callAlgoId != ALGO_UNENCRYPT) { - callKID = __GET_UINT16B(buffer, 182U); + callKID = GET_UINT16(buffer, 182U); if (m_callAlgoId != m_tekAlgoId && callKID != m_tekKeyId) { m_callAlgoId = ALGO_UNENCRYPT; @@ -2089,7 +2085,7 @@ void HostBridge::processP25Network(uint8_t* buffer, uint32_t length) if (duid == DUID::LDU2 && !m_ignoreCall) { m_callAlgoId = data[88U]; - callKID = __GET_UINT16B(buffer, 89U); + callKID = GET_UINT16(buffer, 89U); } if (m_callAlgoId != ALGO_UNENCRYPT) { @@ -2379,7 +2375,7 @@ void HostBridge::decodeP25AudioFrame(uint8_t* ldu, uint32_t srcId, uint32_t dstI ::memcpy(audioData, pcm, MBE_SAMPLES_LENGTH); } else { - __SET_UINT32(MBE_SAMPLES_LENGTH, audioData, 0U); + SET_UINT32(MBE_SAMPLES_LENGTH, audioData, 0U); ::memcpy(audioData + 4U, pcm, MBE_SAMPLES_LENGTH); } @@ -2400,19 +2396,19 @@ void HostBridge::decodeP25AudioFrame(uint8_t* ldu, uint32_t srcId, uint32_t dstI } } else { - __SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); + SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); ::memcpy(audioData + 4U, pcm, MBE_SAMPLES_LENGTH * 2U); } } else { length = (MBE_SAMPLES_LENGTH * 2U) + 12U; audioData = new uint8_t[(MBE_SAMPLES_LENGTH * 2U) + 12U]; // PCM + (4 bytes (PCM length) + 4 bytes (srcId) + 4 bytes (dstId)) - __SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); + SET_UINT32((MBE_SAMPLES_LENGTH * 2U), audioData, 0U); ::memcpy(audioData + 4U, pcm, MBE_SAMPLES_LENGTH * 2U); // embed destination and source IDs - __SET_UINT32(dstId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 4U)); - __SET_UINT32(srcId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 8U)); + SET_UINT32(dstId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 4U)); + SET_UINT32(srcId, audioData, ((MBE_SAMPLES_LENGTH * 2U) + 8U)); } } else { @@ -2423,7 +2419,7 @@ void HostBridge::decodeP25AudioFrame(uint8_t* ldu, uint32_t srcId, uint32_t dstI m_usrpSeqNo++; usrpHeader[15U] = 1; // set PTT state to true - __SET_UINT32(m_usrpSeqNo, usrpHeader, 4U); + SET_UINT32(m_usrpSeqNo, usrpHeader, 4U); ::memcpy(usrpHeader, "USRP", 4); ::memcpy(audioData, usrpHeader, USRP_HEADER_LENGTH); // copy USRP header into the UDP payload @@ -2669,8 +2665,7 @@ void HostBridge::generatePreambleTone() ma_waveform_set_frequency(&m_maSineWaveform, m_preambleTone); ma_uint32 pcmBytes = frameCount * ma_get_bytes_per_frame(m_maDevice.capture.format, m_maDevice.capture.channels); - UInt8Array __sine = std::make_unique(pcmBytes); - uint8_t* sine = __sine.get(); + DECLARE_UINT8_ARRAY(sine, pcmBytes); ma_waveform_read_pcm_frames(&m_maSineWaveform, sine, frameCount, NULL); @@ -2956,8 +2951,7 @@ void* HostBridge::threadAudioProcess(void* arg) if (bridge->m_audioDetect && !bridge->m_callInProgress) { ma_uint32 pcmBytes = MBE_SAMPLES_LENGTH * ma_get_bytes_per_frame(bridge->m_maDevice.capture.format, bridge->m_maDevice.capture.channels); - UInt8Array __pcm = std::make_unique(pcmBytes); - uint8_t* pcm = __pcm.get(); + DECLARE_UINT8_ARRAY(pcm, pcmBytes); int pcmIdx = 0; for (uint32_t smpIdx = 0; smpIdx < MBE_SAMPLES_LENGTH; smpIdx++) { @@ -3095,7 +3089,6 @@ void* HostBridge::threadUDPAudioProcess(void* arg) } } - bridge->m_inputAudio.addData(samples, MBE_SAMPLES_LENGTH); bridge->m_trafficFromUDP = true; // force start a call if one isn't already in progress diff --git a/src/bridge/mdc/mdc_common.c b/src/bridge/mdc/mdc_common.c index 9d7e6c81..2bda8109 100644 --- a/src/bridge/mdc/mdc_common.c +++ b/src/bridge/mdc/mdc_common.c @@ -4,6 +4,8 @@ * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * + * Copyright (c) 2011 Matthew Kaufman + * */ /*- * mdc_common.c diff --git a/src/bridge/mdc/mdc_decode.c b/src/bridge/mdc/mdc_decode.c index 82328b64..52fabe55 100644 --- a/src/bridge/mdc/mdc_decode.c +++ b/src/bridge/mdc/mdc_decode.c @@ -4,6 +4,8 @@ * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * + * Copyright (c) 2011 Matthew Kaufman + * */ /*- * mdc_decode.c diff --git a/src/bridge/mdc/mdc_decode.h b/src/bridge/mdc/mdc_decode.h index 34e13a49..8263dd7e 100644 --- a/src/bridge/mdc/mdc_decode.h +++ b/src/bridge/mdc/mdc_decode.h @@ -4,6 +4,8 @@ * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * + * Copyright (c) 2011 Matthew Kaufman + * */ /** * @file mdc_decode.h diff --git a/src/bridge/mdc/mdc_encode.c b/src/bridge/mdc/mdc_encode.c index 61b41ce2..5dd0e113 100644 --- a/src/bridge/mdc/mdc_encode.c +++ b/src/bridge/mdc/mdc_encode.c @@ -4,6 +4,8 @@ * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * + * Copyright (c) 2011 Matthew Kaufman + * */ /*- * mdc_encode.c diff --git a/src/bridge/mdc/mdc_encode.h b/src/bridge/mdc/mdc_encode.h index 35a7563f..142af8b3 100644 --- a/src/bridge/mdc/mdc_encode.h +++ b/src/bridge/mdc/mdc_encode.h @@ -4,6 +4,8 @@ * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * + * Copyright (c) 2011 Matthew Kaufman + * */ /** * @file mdc_encode.h diff --git a/src/bridge/network/PeerNetwork.cpp b/src/bridge/network/PeerNetwork.cpp index bb82c167..80f980e2 100644 --- a/src/bridge/network/PeerNetwork.cpp +++ b/src/bridge/network/PeerNetwork.cpp @@ -192,8 +192,7 @@ bool PeerNetwork::writeConfig() json::value v = json::value(config); std::string json = v.serialize(); - CharArray __buffer = std::make_unique(json.length() + 9U); - char* buffer = __buffer.get(); + DECLARE_CHAR_ARRAY(buffer, json.length() + 9U); ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); ::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str()); diff --git a/src/common/BitManipulation.h b/src/common/BitManipulation.h new file mode 100644 index 00000000..589bc74d --- /dev/null +++ b/src/common/BitManipulation.h @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file BitManipulation.h + * @ingroup common + */ +#pragma once +#if !defined(__BIT_MANIPULATION_H__) +#define __BIT_MANIPULATION_H__ + +#if !defined(__COMMON_DEFINES_H__) +#warning "BitManipulation.h included before Defines.h, please check include order" +#include "common/Defines.h" +#endif + +// --------------------------------------------------------------------------- +// Constants +// --------------------------------------------------------------------------- + +/** + * @brief Bit mask table used for WRITE_BIT and READ_BIT. + * @ingroup utils + */ +const uint8_t BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U }; + +// --------------------------------------------------------------------------- +// Macros +// --------------------------------------------------------------------------- + +/** + * @brief Macro helper to write a specific bit in a byte array. + * @ingroup common + * @param p Byte array. + * @param i Bit offset. + * @param b Bit to write. + */ +#define WRITE_BIT(p, i, b) p[(i) >> 3] = (b) ? (p[(i) >> 3] | BIT_MASK_TABLE[(i) & 7]) : (p[(i) >> 3] & ~BIT_MASK_TABLE[(i) & 7]) +/** + * @brief Macro helper to read a specific bit from a byte array. + * @ingroup common + * @param p Byte array. + * @param i Bit offset. + * @returns bool Bit. + */ +#define READ_BIT(p, i) (p[(i) >> 3] & BIT_MASK_TABLE[(i) & 7]) + +/** + * @brief Sets a uint32_t into 4 bytes of a buffer/array. (32-bit value). + * @ingroup common + * @param val uint32_t value to set + * @param buffer uint8_t buffer to set value on + * @param offset Offset within uint8_t buffer + */ +#define SET_UINT32(val, buffer, offset) \ + buffer[0U + offset] = (val >> 24) & 0xFFU; \ + buffer[1U + offset] = (val >> 16) & 0xFFU; \ + buffer[2U + offset] = (val >> 8) & 0xFFU; \ + buffer[3U + offset] = (val >> 0) & 0xFFU; +/** + * @brief Gets a uint32_t consisting of 4 bytes from a buffer/array. (32-bit value). + * @ingroup common + * @param buffer uint8_t buffer to get value from + * @param offset Offset within uint8_t buffer + */ +#define GET_UINT32(buffer, offset) \ + (buffer[offset + 0U] << 24) | \ + (buffer[offset + 1U] << 16) | \ + (buffer[offset + 2U] << 8) | \ + (buffer[offset + 3U] << 0); +/** + * @brief Sets a uint32_t into 3 bytes of a buffer/array. (24-bit value). + * @ingroup common + * @param val uint32_t value to set + * @param buffer uint8_t buffer to set value on + * @param offset Offset within uint8_t buffer + */ +#define SET_UINT24(val, buffer, offset) \ + buffer[0U + offset] = (val >> 16) & 0xFFU; \ + buffer[1U + offset] = (val >> 8) & 0xFFU; \ + buffer[2U + offset] = (val >> 0) & 0xFFU; +/** + * @brief Gets a uint32_t consisting of 3 bytes from a buffer/array. (24-bit value). + * @ingroup common + * @param buffer uint8_t buffer to get value from + * @param offset Offset within uint8_t buffer + */ +#define GET_UINT24(buffer, offset) \ + (buffer[offset + 0U] << 16) | \ + (buffer[offset + 1U] << 8) | \ + (buffer[offset + 2U] << 0); +/** + * @brief Sets a uint16_t into 2 bytes of a buffer/array. (16-bit value). + * @ingroup common + * @param val uint16_t value to set + * @param buffer uint8_t buffer to set value on + * @param offset Offset within uint8_t buffer + */ +#define SET_UINT16(val, buffer, offset) \ + buffer[0U + offset] = (val >> 8) & 0xFFU; \ + buffer[1U + offset] = (val >> 0) & 0xFFU; +/** + * @brief Gets a uint16_t consisting of 2 bytes from a buffer/array. (16-bit value). + * @ingroup common + * @param buffer uint8_t buffer to get value from + * @param offset Offset within uint8_t buffer + */ +#define GET_UINT16(buffer, offset) \ + ((buffer[offset + 0U] << 8) & 0xFF00U) | \ + ((buffer[offset + 1U] << 0) & 0x00FFU); + +#endif // __BIT_MANIPULATION_H__ \ No newline at end of file diff --git a/src/common/ClassProperties.h b/src/common/ClassProperties.h new file mode 100644 index 00000000..da075768 --- /dev/null +++ b/src/common/ClassProperties.h @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file ClassProperties.h + * @ingroup common + */ +#pragma once +#if !defined(__CLASS_PROPERTIES_H__) +#define __CLASS_PROPERTIES_H__ + +#if !defined(__COMMON_DEFINES_H__) +#warning "ClassProperties.h included before Defines.h, please check include order" +#include "common/Defines.h" +#endif + +// --------------------------------------------------------------------------- +// Macros +// --------------------------------------------------------------------------- + +/** + * @addtogroup common + * @{ + */ + +/** + * Class Copy Code Pattern + */ + +/** + * @brief Declare a private copy implementation. + * This requires the copy(const type& data) to be declared in the class definition. + * @ingroup common + * @param type Atomic type. + */ +#define DECLARE_COPY(type) \ + private: virtual void copy(const type& data); \ + public: __forceinline type& operator=(const type& data) { \ + if (this != &data) { \ + copy(data); \ + } \ + return *this; \ + } +/** + * @brief Declare a protected copy implementation. + * This requires the copy(const type& data) to be declared in the class definition. + * @ingroup common + * @param type Atomic type. + */ +#define DECLARE_PROTECTED_COPY(type) \ + protected: virtual void copy(const type& data); \ + public: __forceinline type& operator=(const type& data) { \ + if (this != &data) { \ + copy(data); \ + } \ + return *this; \ + } + +/** + * Property Declaration + * These macros should always be used LAST in a "public" section of a class definition. + */ + +/** + * @brief Declare a read-only get property. + * This creates a "property" that is read-only and can only be set internally to the class. Properties created + * with this macro generate an internal variable with the name "m_", and a getter method + * with the name "get()". The getter method is inline and returns the value of the internal + * variable. The internal variable is private, and the getter method is public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + * @param propName Property name. + */ +#define DECLARE_RO_PROPERTY(type, variableName, propName) \ + private: type m_##variableName; \ + public: __forceinline type get##propName(void) const { return m_##variableName; } +/** + * @brief Declare a read-only get property. + * This creates a "property" that is read-only and can only be set internally to the class. Properties created + * with this macro generate an internal variable with the name "m_", and a getter method + * with the name "get()". The getter method is inline and returns the value of the internal + * variable. The internal variable is protected, and the getter method is public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + * @param propName Property name. + */ +#define DECLARE_PROTECTED_RO_PROPERTY(type, variableName, propName) \ + protected: type m_##variableName; \ + public: __forceinline type get##propName(void) const { return m_##variableName; } + +/** + * @brief Declare a read-only property, does not use "get" prefix for getter. + * This creates a "property" that is read-only and can only be set internally to the class. Properties created + * with this macro generate an internal variable with the name "m_", and a getter method + * with the name "()". The getter method is inline and returns the value of the internal + * variable. The internal variable is private, and the getter method is public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + */ +#define DECLARE_PROTECTED_RO_PROPERTY_PLAIN(type, variableName) \ + protected: type m_##variableName; \ + public: __forceinline type variableName(void) const { return m_##variableName; } +/** + * @brief Declare a read-only get property, does not use "get" prefix for getter. + * This creates a "property" that is read-only and can only be set internally to the class. Properties created + * with this macro generate an internal variable with the name "m_", and a getter method + * with the name "()". The getter method is inline and returns the value of the internal + * variable. The internal variable is private, and the getter method is public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + */ +#define DECLARE_RO_PROPERTY_PLAIN(type, variableName) \ + private: type m_##variableName; \ + public: __forceinline type variableName(void) const { return m_##variableName; } + +/** + * @brief Declare a get and set private property. + * This creates a "property" that is read/write. Properties created with this macro generate an internal variable + * with the name "m_", a getter method with the name "get()", and a setter method + * with the name "set(value)". The getter method is inline and returns the value of the internal variable. + * The internal variable is private, and the getter and setter methods are public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + * @param propName Property name. + */ +#define DECLARE_PROPERTY(type, variableName, propName) \ + private: type m_##variableName; \ + public: __forceinline type get##propName(void) const { return m_##variableName; } \ + __forceinline void set##propName(type val) { m_##variableName = val; } +/** + * @brief Declare a get and set protected property. + * This creates a "property" that is read/write. Properties created with this macro generate an internal variable + * with the name "m_", a getter method with the name "get()", and a setter method + * with the name "set(value)". The getter method is inline and returns the value of the internal variable. + * The internal variable is protected, and the getter and setter methods are public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + * @param propName Property name. + */ +#define DECLARE_PROTECTED_PROPERTY(type, variableName, propName) \ + protected: type m_##variableName; \ + public: __forceinline type get##propName(void) const { return m_##variableName; } \ + __forceinline void set##propName(type val) { m_##variableName = val; } + +/** + * @brief Declare a private property, does not use "get"/"set" prefix. + * This creates a "property" that is read/write. Properties created with this macro generate an internal variable + * with the name "m_", and a getter method with the name "()", and a setter method + * "(value)". The getter method is inline and returns the value of the internal variable. The internal + * variable is private, and the getter and setter methods are public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + */ +#define DECLARE_PROPERTY_PLAIN(type, variableName) \ + private: type m_##variableName; \ + public: __forceinline type variableName(void) const { return m_##variableName; } \ + __forceinline void variableName(type val) { m_##variableName = val; } +/** + * @brief Declare a protected property, does not use "get"/"set" prefix. + * This creates a "property" that is read/write. Properties created with this macro generate an internal variable + * with the name "m_", and a getter method with the name "()", and a setter method + * "(value)". The getter method is inline and returns the value of the internal variable. The internal + * variable is protected, and the getter and setter methods are public. + * @ingroup common + * @param type Atomic type for property. + * @param variableName Variable name for property. + */ +#define DECLARE_PROTECTED_PROPERTY_PLAIN(type, variableName) \ + protected: type m_##variableName; \ + public: __forceinline type variableName(void) const { return m_##variableName; } \ + __forceinline void variableName(type val) { m_##variableName = val; } + +/** @} */ + +#endif // __CLASS_PROPERTIES_H__ \ No newline at end of file diff --git a/src/common/Defines.h b/src/common/Defines.h index 6dce8186..2c4b29be 100644 --- a/src/common/Defines.h +++ b/src/common/Defines.h @@ -5,7 +5,7 @@ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX - * Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2018-2025 Bryan Biedenkapp, N2PLL * */ /** @@ -21,6 +21,7 @@ * @file Defines.h * @ingroup common */ +#pragma once #if !defined(__COMMON_DEFINES_H__) #define __COMMON_DEFINES_H__ @@ -93,6 +94,14 @@ typedef unsigned long long ulong64_t; #define PACK(decl) __pragma(pack(push, 1)) decl __pragma(pack(pop)) #endif +// --------------------------------------------------------------------------- +// Meta-Programming Macro Includes +// --------------------------------------------------------------------------- + +#include "common/ClassProperties.h" +#include "common/BitManipulation.h" +#include "common/VariableLengthArray.h" + // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- @@ -108,7 +117,7 @@ typedef unsigned long long ulong64_t; #define __EXE_NAME__ "" #define VERSION_MAJOR "04" -#define VERSION_MINOR "30" +#define VERSION_MINOR "31" #define VERSION_REV "H" #define __NETVER__ "DVM_R" VERSION_MAJOR VERSION_REV VERSION_MINOR @@ -193,121 +202,6 @@ const uint8_t IP_COMPRESS_NONE = 0x00U; const uint8_t IP_COMPRESS_RFC1144_COMPRESS = 0x01U; const uint8_t IP_COMPRESS_RFC1144_UNCOMPRESS = 0x02U; -// --------------------------------------------------------------------------- -// Class Helper Macros -// --------------------------------------------------------------------------- - -/** - * Class Copy Code Pattern - */ - -/** - * @brief Creates a private copy implementation. - * This requires the copy(const type& data) to be declared in the class definition. - * @param type Atomic type. - */ -#define __COPY(type) \ - private: virtual void copy(const type& data); \ - public: __forceinline type& operator=(const type& data) { \ - if (this != &data) { \ - copy(data); \ - } \ - return *this; \ - } -/** - * @brief Creates a protected copy implementation. - * This requires the copy(const type& data) to be declared in the class definition. - * @param type Atomic type. - */ -#define __PROTECTED_COPY(type) \ - protected: virtual void copy(const type& data); \ - public: __forceinline type& operator=(const type& data) { \ - if (this != &data) { \ - copy(data); \ - } \ - return *this; \ - } - -/** - * Property Creation - * These macros should always be used LAST in the "public" section of a class definition. - */ - -/** - * @brief Creates a read-only get property. - * @param type Atomic type for property. - * @param variableName Variable name for property. - * @param propName Property name. - */ -#define __READONLY_PROPERTY(type, variableName, propName) \ - private: type m_##variableName; \ - public: __forceinline type get##propName(void) const { return m_##variableName; } -/** - * @brief Creates a read-only get property. - * @param type Atomic type for property. - * @param variableName Variable name for property. - * @param propName Property name. - */ -#define __PROTECTED_READONLY_PROPERTY(type, variableName, propName) \ - protected: type m_##variableName; \ - public: __forceinline type get##propName(void) const { return m_##variableName; } - -/** - * @brief Creates a read-only get property, does not use "get". - * @param type Atomic type for property. - * @param variableName Variable name for property. - */ -#define __PROTECTED_READONLY_PROPERTY_PLAIN(type, variableName) \ - protected: type m_##variableName; \ - public: __forceinline type variableName(void) const { return m_##variableName; } -/** - * @brief Creates a read-only get property, does not use "get". - * @param type Atomic type for property. - * @param variableName Variable name for property. - */ -#define __READONLY_PROPERTY_PLAIN(type, variableName) \ - private: type m_##variableName; \ - public: __forceinline type variableName(void) const { return m_##variableName; } - -/** - * @brief Creates a get and set private property. - * @param type Atomic type for property. - * @param variableName Variable name for property. - * @param propName Property name. - */ -#define __PROPERTY(type, variableName, propName) \ - private: type m_##variableName; \ - public: __forceinline type get##propName(void) const { return m_##variableName; } \ - __forceinline void set##propName(type val) { m_##variableName = val; } -/** - * @brief Creates a get and set protected property. - * @param type Atomic type for property. - * @param variableName Variable name for property. - * @param propName Property name. - */ -#define __PROTECTED_PROPERTY(type, variableName, propName) \ - protected: type m_##variableName; \ - public: __forceinline type get##propName(void) const { return m_##variableName; } \ - __forceinline void set##propName(type val) { m_##variableName = val; } - -/** - * @brief Creates a get and set private property, does not use "get"/"set". - * @param type Atomic type for property. - * @param variableName Variable name for property. - */ -#define __PROPERTY_PLAIN(type, variableName) \ - private: type m_##variableName; \ - public: __forceinline type variableName(void) const { return m_##variableName; }\ - __forceinline void variableName(type val) { m_##variableName = val; } -/** - * @brief Creates a get and set protected property, does not use "get"/"set". - * @param type Atomic type for property. - * @param variableName Variable name for property. - */ -#define __PROTECTED_PROPERTY_PLAIN(type, variableName) \ - protected: type m_##variableName; \ - public: __forceinline type variableName(void) const { return m_##variableName; }\ - __forceinline void variableName(type val) { m_##variableName = val; } - /** @} */ + #endif // __COMMON_DEFINES_H__ diff --git a/src/common/Thread.h b/src/common/Thread.h index 9b5cf31b..7232e012 100644 --- a/src/common/Thread.h +++ b/src/common/Thread.h @@ -134,7 +134,7 @@ public: /** * @brief Flag indicating if the thread was started. */ - __PROTECTED_READONLY_PROPERTY_PLAIN(bool, started); + DECLARE_PROTECTED_RO_PROPERTY_PLAIN(bool, started); }; #endif // __THREAD_H__ diff --git a/src/common/ThreadPool.h b/src/common/ThreadPool.h index 8b9253c0..38018383 100644 --- a/src/common/ThreadPool.h +++ b/src/common/ThreadPool.h @@ -115,11 +115,11 @@ public: /** * @brief Maximum number of worker threads. */ - __PROPERTY(uint16_t, maxWorkerCnt, MaxWorkerCnt); + DECLARE_PROPERTY(uint16_t, maxWorkerCnt, MaxWorkerCnt); /** * @brief Maximum number of queued tasks. */ - __PROPERTY(uint16_t, maxQueuedTasks, MaxQueuedTasks); + DECLARE_PROPERTY(uint16_t, maxQueuedTasks, MaxQueuedTasks); private: diff --git a/src/common/Utils.h b/src/common/Utils.h index ea42d895..1279ed1e 100644 --- a/src/common/Utils.h +++ b/src/common/Utils.h @@ -5,11 +5,11 @@ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright (C) 2009,2014,2015 Jonathan Naylor, G4KLX - * Copyright (C) 2018-2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2018-2025 Bryan Biedenkapp, N2PLL * */ /** - * @defgroup utils Utility Routines + * @defgroup utils Common Utility Routines * @brief Defines and implements utility routines. * @ingroup common * @@ -31,17 +31,24 @@ #endif // !defined(WIN32) // --------------------------------------------------------------------------- -// Constants +// Macros // --------------------------------------------------------------------------- /** - * @brief Bit mask table used for WRITE_BIT and READ_BIT. + * @brief Pointer magic to get the memory address of a floating point number. * @ingroup utils + * @param x Floating Point Variable */ -const uint8_t BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U }; +#define __FLOAT_ADDR(x) (*(uint32_t*)& x) +/** + * @brief Pointer magic to get the memory address of a double precision number. + * @ingroup utils + * @param x Double Precision Variable + */ +#define __DOUBLE_ADDR(x) (*(uint64_t*)& x) // --------------------------------------------------------------------------- -// Inlines +// Inline Global Functions // --------------------------------------------------------------------------- /** @@ -153,115 +160,6 @@ inline std::string strtoupper(const std::string value) { return v; } -// --------------------------------------------------------------------------- -// Macros -// --------------------------------------------------------------------------- - -/** - * @brief Pointer magic to get the memory address of a floating point number. - * @ingroup utils - * @param x Floating Point Variable - */ -#define __FLOAT_ADDR(x) (*(uint32_t*)& x) -/** - * @brief Pointer magic to get the memory address of a double precision number. - * @ingroup utils - * @param x Double Precision Variable - */ -#define __DOUBLE_ADDR(x) (*(uint64_t*)& x) - -/** - * @brief Macro helper to write a specific bit in a byte array. - * @ingroup utils - * @param p Byte array. - * @param i Bit offset. - * @param b Bit to write. - */ -#define WRITE_BIT(p, i, b) p[(i) >> 3] = (b) ? (p[(i) >> 3] | BIT_MASK_TABLE[(i) & 7]) : (p[(i) >> 3] & ~BIT_MASK_TABLE[(i) & 7]) -/** - * @brief Macro helper to read a specific bit from a byte array. - * @ingroup utils - * @param p Byte array. - * @param i Bit offset. - * @returns bool Bit. - */ -#define READ_BIT(p, i) (p[(i) >> 3] & BIT_MASK_TABLE[(i) & 7]) - -/** - * @brief Sets a uint32_t into 4 bytes. - * @ingroup utils - * @param val uint32_t value to set - * @param buffer uint8_t buffer to set value on - * @param offset Offset within uint8_t buffer - */ -#define __SET_UINT32(val, buffer, offset) \ - buffer[0U + offset] = (val >> 24) & 0xFFU; \ - buffer[1U + offset] = (val >> 16) & 0xFFU; \ - buffer[2U + offset] = (val >> 8) & 0xFFU; \ - buffer[3U + offset] = (val >> 0) & 0xFFU; -/** - * @brief Gets a uint32_t consisting of 4 bytes. - * @ingroup utils - * @param buffer uint8_t buffer to get value from - * @param offset Offset within uint8_t buffer - */ -#define __GET_UINT32(buffer, offset) \ - (buffer[offset + 0U] << 24) | \ - (buffer[offset + 1U] << 16) | \ - (buffer[offset + 2U] << 8) | \ - (buffer[offset + 3U] << 0); -/** - * @brief Sets a uint32_t into 3 bytes. - * @ingroup utils - * @param val uint32_t value to set - * @param buffer uint8_t buffer to set value on - * @param offset Offset within uint8_t buffer - */ -#define __SET_UINT16(val, buffer, offset) \ - buffer[0U + offset] = (val >> 16) & 0xFFU; \ - buffer[1U + offset] = (val >> 8) & 0xFFU; \ - buffer[2U + offset] = (val >> 0) & 0xFFU; -/** - * @brief Gets a uint32_t consisting of 3 bytes. (This is a shortened uint32_t). - * @ingroup utils - * @param buffer uint8_t buffer to get value from - * @param offset Offset within uint8_t buffer - */ -#define __GET_UINT16(buffer, offset) \ - (buffer[offset + 0U] << 16) | \ - (buffer[offset + 1U] << 8) | \ - (buffer[offset + 2U] << 0); -/** - * @brief Sets a uint16_t into 2 bytes. - * @ingroup utils - * @param val uint16_t value to set - * @param buffer uint8_t buffer to set value on - * @param offset Offset within uint8_t buffer - */ -#define __SET_UINT16B(val, buffer, offset) \ - buffer[0U + offset] = (val >> 8) & 0xFFU; \ - buffer[1U + offset] = (val >> 0) & 0xFFU; -/** - * @brief Gets a uint16_t consisting of 2 bytes. - * @ingroup utils - * @param buffer uint8_t buffer to get value from - * @param offset Offset within uint8_t buffer - */ -#define __GET_UINT16B(buffer, offset) \ - ((buffer[offset + 0U] << 8) & 0xFF00U) | \ - ((buffer[offset + 1U] << 0) & 0x00FFU); - -/** - * @brief Unique uint8_t array. - * @ingroup utils - */ -typedef std::unique_ptr UInt8Array; -/** - * @brief Unique char array. - * @ingroup utils - */ -typedef std::unique_ptr CharArray; - // --------------------------------------------------------------------------- // Class Declaration // --------------------------------------------------------------------------- diff --git a/src/common/VariableLengthArray.h b/src/common/VariableLengthArray.h new file mode 100644 index 00000000..24364839 --- /dev/null +++ b/src/common/VariableLengthArray.h @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file VariableLengthArray.h + * @ingroup common + */ +#pragma once +#if !defined(__VARIABLE_LENGTH_ARRAY_H__) +#define __VARIABLE_LENGTH_ARRAY_H__ + +#if !defined(__COMMON_DEFINES_H__) +#warning "VariableLengthArray.h included before Defines.h, please check include order" +#include "common/Defines.h" +#endif + +// --------------------------------------------------------------------------- +// Types +// --------------------------------------------------------------------------- + +/** + * @addtogroup common + * @{ + */ + +/** + * @brief Unique uint8_t array. + * @ingroup common + */ +typedef std::unique_ptr UInt8Array; + +/** + * @brief Unique char array. + * @ingroup common + */ +typedef std::unique_ptr CharArray; + +/** @} */ + +// --------------------------------------------------------------------------- +// Macros +// --------------------------------------------------------------------------- + +/** + * @addtogroup common + * @{ + */ + +/** + * @brief Declares a unique uint8_t array/buffer. + * This macro creates a unique pointer to a uint8_t array of the specified length and initializes it to zero. + * The resulting pointer is named after the parameter name passed to the macro. + * @param name Name of array/buffer. + * @param len Length of array/buffer. + */ +#define DECLARE_UINT8_ARRAY(name, len) \ + UInt8Array __##name##__UInt8Array = std::make_unique(len); \ + uint8_t* name = __##name##__UInt8Array.get(); \ + ::memset(name, 0x00U, len); + +/** + * @brief Declares a unique char array/buffer. + * This macro creates a unique pointer to a uint8_t array of the specified length and initializes it to zero. + * The resulting pointer is named after the parameter name passed to the macro. + * @ingroup common + * @param name Name of array/buffer. + * @param len Length of array/buffer. + */ +#define DECLARE_CHAR_ARRAY(name, len) \ + CharArray __##name##__CharArray = std::make_unique(len); \ + char* name = __##name##__CharArray.get(); \ + ::memset(name, 0, len); + +/** @} */ + +#endif // __VARIABLE_LENGTH_ARRAY_H__ \ No newline at end of file diff --git a/src/common/dmr/DMRDefines.h b/src/common/dmr/DMRDefines.h index 86bd049c..30f84b2a 100644 --- a/src/common/dmr/DMRDefines.h +++ b/src/common/dmr/DMRDefines.h @@ -5,7 +5,7 @@ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright (C) 2015,2016 Jonathan Naylor, G4KLX - * Copyright (C) 2019-2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2019-2025 Bryan Biedenkapp, N2PLL * */ /** @@ -209,6 +209,15 @@ namespace dmr const uint8_t FID_DVM_OCS = 0x9CU; /** @} */ + /** @name Encryption Algorithms */ + /** @brief ARC4 */ + const uint8_t ALGO_ARC4 = 0x01U; + /** @brief DES-OFB */ + const uint8_t ALGO_DES = 0x02U; + /** @brief AES-256 */ + const uint8_t ALGO_AES_256 = 0x05U; + /** @} */ + /** @name LC Service Options */ const uint8_t LC_SVC_OPT_EMERGENCY = 0x80U; const uint8_t LC_SVC_OPT_PRIVACY = 0x40U; diff --git a/src/common/dmr/SiteData.h b/src/common/dmr/SiteData.h index 9329db4e..7b4c20de 100644 --- a/src/common/dmr/SiteData.h +++ b/src/common/dmr/SiteData.h @@ -156,27 +156,27 @@ namespace dmr /** * @brief DMR site model type. */ - __READONLY_PROPERTY_PLAIN(defines::SiteModel::E, siteModel); + DECLARE_RO_PROPERTY_PLAIN(defines::SiteModel::E, siteModel); /** * @brief DMR site network ID. */ - __READONLY_PROPERTY_PLAIN(uint16_t, netId); + DECLARE_RO_PROPERTY_PLAIN(uint16_t, netId); /** * @brief DMR site ID. */ - __READONLY_PROPERTY_PLAIN(uint16_t, siteId); + DECLARE_RO_PROPERTY_PLAIN(uint16_t, siteId); /** * @brief DMR partition ID. */ - __READONLY_PROPERTY_PLAIN(uint8_t, parId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, parId); /** * @brief DMR require registration. */ - __READONLY_PROPERTY_PLAIN(bool, requireReg); + DECLARE_RO_PROPERTY_PLAIN(bool, requireReg); /** * @brief Flag indicating whether this site is a linked active network member. */ - __READONLY_PROPERTY_PLAIN(bool, netActive); + DECLARE_RO_PROPERTY_PLAIN(bool, netActive); /** @} */ }; } // namespace dmr diff --git a/src/common/dmr/SlotType.h b/src/common/dmr/SlotType.h index 2dc1aed7..35d6b37c 100644 --- a/src/common/dmr/SlotType.h +++ b/src/common/dmr/SlotType.h @@ -56,12 +56,12 @@ namespace dmr /** * @brief DMR access color code. */ - __PROPERTY(uint8_t, colorCode, ColorCode); + DECLARE_PROPERTY(uint8_t, colorCode, ColorCode); /** * @brief Slot data type. */ - __PROPERTY(defines::DataType::E, dataType, DataType); + DECLARE_PROPERTY(defines::DataType::E, dataType, DataType); }; } // namespace dmr diff --git a/src/common/dmr/data/DataBlock.h b/src/common/dmr/data/DataBlock.h index 5a1d5eef..240051f0 100644 --- a/src/common/dmr/data/DataBlock.h +++ b/src/common/dmr/data/DataBlock.h @@ -102,12 +102,12 @@ namespace dmr /** * @brief Sets the data block serial number. */ - __PROPERTY(uint8_t, serialNo, SerialNo); + DECLARE_PROPERTY(uint8_t, serialNo, SerialNo); /** * @brief Flag indicating this is the last block in a sequence of block. */ - __PROPERTY(bool, lastBlock, LastBlock); + DECLARE_PROPERTY(bool, lastBlock, LastBlock); private: edac::BPTC19696 m_bptc; diff --git a/src/common/dmr/data/DataHeader.h b/src/common/dmr/data/DataHeader.h index 231cc5ea..e308c491 100644 --- a/src/common/dmr/data/DataHeader.h +++ b/src/common/dmr/data/DataHeader.h @@ -106,82 +106,82 @@ namespace dmr /** * @brief Flag indicating whether the data header is group or individual. */ - __PROPERTY(bool, GI, GI); + DECLARE_PROPERTY(bool, GI, GI); /** * @brief Flag indicating whether the data header requires acknowledgement. */ - __PROPERTY(bool, A, A); + DECLARE_PROPERTY(bool, A, A); /** * @brief Data packet format. */ - __PROPERTY(defines::DPF::E, DPF, DPF); + DECLARE_PROPERTY(defines::DPF::E, DPF, DPF); /** * @brief Service access point. */ - __PROPERTY(uint8_t, sap, SAP); + DECLARE_PROPERTY(uint8_t, sap, SAP); /** * @brief Fragment Sequence Number. */ - __PROPERTY(uint8_t, fsn, FSN); + DECLARE_PROPERTY(uint8_t, fsn, FSN); /** * @brief Send Sequence Number. */ - __PROPERTY(uint8_t, Ns, Ns); + DECLARE_PROPERTY(uint8_t, Ns, Ns); /** * @brief Gets the number of data blocks following the header. */ - __PROPERTY(uint32_t, blocksToFollow, BlocksToFollow); + DECLARE_PROPERTY(uint32_t, blocksToFollow, BlocksToFollow); /** * @brief Count of block padding. */ - __PROPERTY(uint8_t, padLength, PadLength); + DECLARE_PROPERTY(uint8_t, padLength, PadLength); /** * @brief Full Message Flag. */ - __PROPERTY(bool, F, FullMesage); + DECLARE_PROPERTY(bool, F, FullMesage); /** * @brief Synchronize Flag. */ - __PROPERTY(bool, S, Synchronize); + DECLARE_PROPERTY(bool, S, Synchronize); /** * @brief Unified Data or Defined Data Format. */ - __PROPERTY(uint8_t, dataFormat, DataFormat); + DECLARE_PROPERTY(uint8_t, dataFormat, DataFormat); /** * @brief Source ID. */ - __PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROPERTY(uint32_t, dstId, DstId); /** * @brief Response class. */ - __PROPERTY(uint8_t, rspClass, ResponseClass); + DECLARE_PROPERTY(uint8_t, rspClass, ResponseClass); /** * @brief Response type. */ - __PROPERTY(uint8_t, rspType, ResponseType); + DECLARE_PROPERTY(uint8_t, rspType, ResponseType); /** * @brief Response status. */ - __PROPERTY(uint8_t, rspStatus, ResponseStatus); + DECLARE_PROPERTY(uint8_t, rspStatus, ResponseStatus); /** * @brief Source Port. */ - __PROPERTY(uint8_t, srcPort, SrcPort); + DECLARE_PROPERTY(uint8_t, srcPort, SrcPort); /** * @brief Destination Port. */ - __PROPERTY(uint8_t, dstPort, DstPort); + DECLARE_PROPERTY(uint8_t, dstPort, DstPort); private: edac::BPTC19696 m_bptc; diff --git a/src/common/dmr/data/EMB.h b/src/common/dmr/data/EMB.h index e7779ac3..c0bec59e 100644 --- a/src/common/dmr/data/EMB.h +++ b/src/common/dmr/data/EMB.h @@ -56,17 +56,17 @@ namespace dmr /** * @brief DMR access color code. */ - __PROPERTY(uint8_t, colorCode, ColorCode); + DECLARE_PROPERTY(uint8_t, colorCode, ColorCode); /** * @brief Flag indicating whether the privacy indicator is set or not. */ - __PROPERTY(bool, PI, PI); + DECLARE_PROPERTY(bool, PI, PI); /** * @brief Link control start/stop. */ - __PROPERTY(uint8_t, LCSS, LCSS); + DECLARE_PROPERTY(uint8_t, LCSS, LCSS); }; } // namespace data } // namespace dmr diff --git a/src/common/dmr/data/EmbeddedData.h b/src/common/dmr/data/EmbeddedData.h index 889acc1c..d00808c8 100644 --- a/src/common/dmr/data/EmbeddedData.h +++ b/src/common/dmr/data/EmbeddedData.h @@ -96,11 +96,11 @@ namespace dmr /** * @brief Flag indicating whether or not the embedded data is valid. */ - __READONLY_PROPERTY_PLAIN(bool, valid); + DECLARE_RO_PROPERTY_PLAIN(bool, valid); /** * @brief Full-link control opcode. */ - __READONLY_PROPERTY(defines::FLCO::E, FLCO, FLCO); + DECLARE_RO_PROPERTY(defines::FLCO::E, FLCO, FLCO); private: LC_STATE m_state; diff --git a/src/common/dmr/data/NetData.h b/src/common/dmr/data/NetData.h index ecb7bde7..5c1587c4 100644 --- a/src/common/dmr/data/NetData.h +++ b/src/common/dmr/data/NetData.h @@ -69,51 +69,51 @@ namespace dmr /** * @brief DMR slot number. */ - __PROPERTY(uint32_t, slotNo, SlotNo); + DECLARE_PROPERTY(uint32_t, slotNo, SlotNo); /** * @brief Source ID. */ - __PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROPERTY(uint32_t, dstId, DstId); /** * @brief Sets the full-link control opcode. */ - __PROPERTY(defines::FLCO::E, flco, FLCO); + DECLARE_PROPERTY(defines::FLCO::E, flco, FLCO); /** * @brief */ - __PROPERTY(uint8_t, control, Control); + DECLARE_PROPERTY(uint8_t, control, Control); /** * @brief */ - __PROPERTY(uint8_t, n, N); + DECLARE_PROPERTY(uint8_t, n, N); /** * @brief Sequence number. */ - __PROPERTY(uint8_t, seqNo, SeqNo); + DECLARE_PROPERTY(uint8_t, seqNo, SeqNo); /** * @brief Embedded data type. */ - __PROPERTY(defines::DataType::E, dataType, DataType); + DECLARE_PROPERTY(defines::DataType::E, dataType, DataType); /** * @brief Bit Error Rate. */ - __PROPERTY(uint8_t, ber, BER); + DECLARE_PROPERTY(uint8_t, ber, BER); /** * @brief Received Signal Strength Indicator. */ - __PROPERTY(uint8_t, rssi, RSSI); + DECLARE_PROPERTY(uint8_t, rssi, RSSI); private: uint8_t* m_data; diff --git a/src/common/dmr/lc/CSBK.h b/src/common/dmr/lc/CSBK.h index 9ef97f16..91d57da5 100644 --- a/src/common/dmr/lc/CSBK.h +++ b/src/common/dmr/lc/CSBK.h @@ -117,116 +117,116 @@ namespace dmr /** * @brief DMR access color code. */ - __PROTECTED_PROPERTY(uint8_t, colorCode, ColorCode); + DECLARE_PROTECTED_PROPERTY(uint8_t, colorCode, ColorCode); /** * @brief Flag indicating this is the last CSBK in a sequence of CSBKs. */ - __PROTECTED_PROPERTY(bool, lastBlock, LastBlock); + DECLARE_PROTECTED_PROPERTY(bool, lastBlock, LastBlock); /** * @brief Flag indicating whether the CSBK is a Cdef block. */ - __PROTECTED_PROPERTY(bool, Cdef, Cdef); + DECLARE_PROTECTED_PROPERTY(bool, Cdef, Cdef); /** * @brief CSBK opcode. */ - __PROTECTED_PROPERTY(uint8_t, CSBKO, CSBKO); + DECLARE_PROTECTED_PROPERTY(uint8_t, CSBKO, CSBKO); /** * @brief */ - __PROTECTED_PROPERTY(uint8_t, FID, FID); + DECLARE_PROTECTED_PROPERTY(uint8_t, FID, FID); /** * @brief Flag indicating whether the CSBK is group or individual. */ - __PROTECTED_PROPERTY(bool, GI, GI); + DECLARE_PROTECTED_PROPERTY(bool, GI, GI); /** * @brief Source ID. */ - __PROTECTED_PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROTECTED_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROTECTED_PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROTECTED_PROPERTY(uint32_t, dstId, DstId); /** * @brief */ - __PROTECTED_READONLY_PROPERTY(bool, dataContent, DataContent); + DECLARE_PROTECTED_RO_PROPERTY(bool, dataContent, DataContent); /** * @brief Number of blocks to follow. */ - __PROTECTED_PROPERTY(uint8_t, CBF, CBF); + DECLARE_PROTECTED_PROPERTY(uint8_t, CBF, CBF); /** * @brief Data type for this CSBK. */ - __PROTECTED_PROPERTY(defines::DataType::E, dataType, DataType); + DECLARE_PROTECTED_PROPERTY(defines::DataType::E, dataType, DataType); /** @} */ /** @name Common Service Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROTECTED_PROPERTY(bool, emergency, Emergency); + DECLARE_PROTECTED_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that privacy is enabled. */ - __PROTECTED_PROPERTY(bool, privacy, Privacy); + DECLARE_PROTECTED_PROPERTY(bool, privacy, Privacy); /** * @brief Flag indicating that supplementary data is required. */ - __PROTECTED_PROPERTY(bool, supplementData, SupplementData); + DECLARE_PROTECTED_PROPERTY(bool, supplementData, SupplementData); /** * @brief Priority level for the traffic. */ - __PROTECTED_PROPERTY(uint8_t, priority, Priority); + DECLARE_PROTECTED_PROPERTY(uint8_t, priority, Priority); /** * @brief Flag indicating a broadcast service. */ - __PROTECTED_PROPERTY(bool, broadcast, Broadcast); + DECLARE_PROTECTED_PROPERTY(bool, broadcast, Broadcast); /** * @brief Flag indicating a proxy. */ - __PROTECTED_PROPERTY(bool, proxy, Proxy); + DECLARE_PROTECTED_PROPERTY(bool, proxy, Proxy); /** * @brief Response information. */ - __PROTECTED_PROPERTY(uint8_t, response, Response); + DECLARE_PROTECTED_PROPERTY(uint8_t, response, Response); /** * @brief Reason type. */ - __PROTECTED_PROPERTY(uint8_t, reason, Reason); + DECLARE_PROTECTED_PROPERTY(uint8_t, reason, Reason); /** @} */ /** @name Tier 3 */ /** * @brief Site offset timing. */ - __PROTECTED_PROPERTY(bool, siteOffsetTiming, SiteOffsetTiming); + DECLARE_PROTECTED_PROPERTY(bool, siteOffsetTiming, SiteOffsetTiming); /** * @brief Broadcast Logical Channel ID 1. */ - __PROTECTED_PROPERTY(uint16_t, logicalCh1, LogicalCh1); + DECLARE_PROTECTED_PROPERTY(uint16_t, logicalCh1, LogicalCh1); /** * @brief Broadcast Logical Channel ID 2. */ - __PROTECTED_PROPERTY(uint16_t, logicalCh2, LogicalCh2); + DECLARE_PROTECTED_PROPERTY(uint16_t, logicalCh2, LogicalCh2); /** * @brief Logical Channel Slot Number. */ - __PROTECTED_PROPERTY(uint8_t, slotNo, SlotNo); + DECLARE_PROTECTED_PROPERTY(uint8_t, slotNo, SlotNo); /** @} */ /** @name Local Site data */ /** * @brief Local Site Identity Entry. */ - __PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry); + DECLARE_PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry); /** @} */ protected: @@ -261,7 +261,7 @@ namespace dmr */ void encode(uint8_t* data, const uint8_t* payload); - __PROTECTED_COPY(CSBK); + DECLARE_PROTECTED_COPY(CSBK); private: uint8_t* m_raw; diff --git a/src/common/dmr/lc/LC.h b/src/common/dmr/lc/LC.h index 5acd6630..fcf934ba 100644 --- a/src/common/dmr/lc/LC.h +++ b/src/common/dmr/lc/LC.h @@ -80,49 +80,49 @@ namespace dmr /** * @brief Flag indicating whether link protection is enabled. */ - __PROPERTY(bool, PF, PF); + DECLARE_PROPERTY(bool, PF, PF); /** * @brief Full-link control opcode. */ - __PROPERTY(defines::FLCO::E, FLCO, FLCO); + DECLARE_PROPERTY(defines::FLCO::E, FLCO, FLCO); /** * @brief Feature ID */ - __PROPERTY(uint8_t, FID, FID); + DECLARE_PROPERTY(uint8_t, FID, FID); /** * @brief Source ID. */ - __PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROPERTY(uint32_t, dstId, DstId); /** @} */ /** @name Service Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROPERTY(bool, emergency, Emergency); + DECLARE_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that encryption is enabled. */ - __PROPERTY(bool, encrypted, Encrypted); + DECLARE_PROPERTY(bool, encrypted, Encrypted); /** * @brief Flag indicating broadcast operation. */ - __PROPERTY(bool, broadcast, Broadcast); + DECLARE_PROPERTY(bool, broadcast, Broadcast); /** * @brief Flag indicating OVCM operation. */ - __PROPERTY(bool, ovcm, OVCM); + DECLARE_PROPERTY(bool, ovcm, OVCM); /** * @brief Priority level for the traffic. */ - __PROPERTY(uint8_t, priority, Priority); + DECLARE_PROPERTY(uint8_t, priority, Priority); /** @} */ private: diff --git a/src/common/dmr/lc/PrivacyLC.cpp b/src/common/dmr/lc/PrivacyLC.cpp index fabe45c5..80be911b 100644 --- a/src/common/dmr/lc/PrivacyLC.cpp +++ b/src/common/dmr/lc/PrivacyLC.cpp @@ -7,7 +7,7 @@ * @package DVM / Common Library * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * - * Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2021,2024,2025 Bryan Biedenkapp, N2PLL * */ #include "Defines.h" @@ -160,3 +160,25 @@ void PrivacyLC::getData(bool* bits) const Utils::byteToBitsBE(bytes[8U], bits + 64U); Utils::byteToBitsBE(bytes[9U], bits + 72U); } + +/* +** Encryption data +*/ + +/* Sets the encryption message indicator. */ + +void PrivacyLC::setMI(const uint8_t* mi) +{ + assert(mi != nullptr); + + ::memcpy(m_mi, mi, MI_LENGTH_BYTES); +} + +/* Gets the encryption message indicator. */ + +void PrivacyLC::getMI(uint8_t* mi) const +{ + assert(mi != nullptr); + + ::memcpy(mi, m_mi, MI_LENGTH_BYTES); +} diff --git a/src/common/dmr/lc/PrivacyLC.h b/src/common/dmr/lc/PrivacyLC.h index 5baf8364..9935c51a 100644 --- a/src/common/dmr/lc/PrivacyLC.h +++ b/src/common/dmr/lc/PrivacyLC.h @@ -7,7 +7,7 @@ * @package DVM / Common Library * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2021 Bryan Biedenkapp, N2PLL +* Copyright (C) 2021,2025 Bryan Biedenkapp, N2PLL * */ /** @@ -65,35 +65,48 @@ namespace dmr */ void getData(bool* bits) const; + /** @name Encryption data */ + /** + * @brief Sets the encryption message indicator. + * @param[in] mi Buffer containing the 9-byte Message Indicator. + */ + void setMI(const uint8_t* mi); + /** + * @brief Gets the encryption message indicator. + * @param[out] mi Buffer containing the 9-byte Message Indicator. + */ + void getMI(uint8_t* mi) const; + /** @} */ + public: /** @name Common Data */ /** * @brief Feature ID */ - __PROPERTY(uint8_t, FID, FID); + DECLARE_PROPERTY(uint8_t, FID, FID); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROPERTY(uint32_t, dstId, DstId); /** @} */ /** @name Service Options */ /** * @brief Flag indicating a group/talkgroup operation. */ - __PROPERTY(bool, group, Group); + DECLARE_PROPERTY(bool, group, Group); /** @} */ /** @name Encryption data */ /** * @brief Encryption algorithm ID. */ - __PROPERTY(uint8_t, algId, AlgId); + DECLARE_PROPERTY(uint8_t, algId, AlgId); /** * @brief Encryption key ID. */ - __PROPERTY(uint32_t, kId, KId); + DECLARE_PROPERTY(uint32_t, kId, KId); /** @} */ private: diff --git a/src/common/dmr/lc/csbk/CSBK_ALOHA.h b/src/common/dmr/lc/csbk/CSBK_ALOHA.h index 08b7e338..4a731354 100644 --- a/src/common/dmr/lc/csbk/CSBK_ALOHA.h +++ b/src/common/dmr/lc/csbk/CSBK_ALOHA.h @@ -61,22 +61,22 @@ namespace dmr /** * @brief Aloha Site Time Slot Synchronization. */ - __PROPERTY(bool, siteTSSync, SiteTSSync); + DECLARE_PROPERTY(bool, siteTSSync, SiteTSSync); /** * @brief Aloha MS mask. */ - __PROPERTY(uint8_t, alohaMask, AlohaMask); + DECLARE_PROPERTY(uint8_t, alohaMask, AlohaMask); /** * @brief Backoff Number. */ - __PROPERTY(uint8_t, backoffNo, BackoffNo); + DECLARE_PROPERTY(uint8_t, backoffNo, BackoffNo); /** * @brief Random Access Wait Delay. */ - __PROPERTY(uint8_t, nRandWait, NRandWait); + DECLARE_PROPERTY(uint8_t, nRandWait, NRandWait); - __COPY(CSBK_ALOHA); + DECLARE_COPY(CSBK_ALOHA); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_BROADCAST.h b/src/common/dmr/lc/csbk/CSBK_BROADCAST.h index 9a5270b5..a7d8370f 100644 --- a/src/common/dmr/lc/csbk/CSBK_BROADCAST.h +++ b/src/common/dmr/lc/csbk/CSBK_BROADCAST.h @@ -61,36 +61,36 @@ namespace dmr /** * @brief Broadcast Announcment Type. */ - __PROPERTY(uint8_t, anncType, AnncType); + DECLARE_PROPERTY(uint8_t, anncType, AnncType); /** * @brief Broadcast Hibernation Flag. */ - __PROPERTY(bool, hibernating, Hibernating); + DECLARE_PROPERTY(bool, hibernating, Hibernating); /** * @brief Broadcast Announce/Withdraw Channel 1 Flag. */ - __PROPERTY(bool, annWdCh1, AnnWdCh1); + DECLARE_PROPERTY(bool, annWdCh1, AnnWdCh1); /** * @brief Broadcast Announce/Withdraw Channel 2 Flag. */ - __PROPERTY(bool, annWdCh2, AnnWdCh2); + DECLARE_PROPERTY(bool, annWdCh2, AnnWdCh2); /** * @brief Require Registration. */ - __PROPERTY(bool, requireReg, RequireReg); + DECLARE_PROPERTY(bool, requireReg, RequireReg); /** * @brief System Identity. */ - __PROPERTY(uint32_t, systemId, SystemId); + DECLARE_PROPERTY(uint32_t, systemId, SystemId); /** * @brief Backoff Number. */ - __PROPERTY(uint8_t, backoffNo, BackoffNo); + DECLARE_PROPERTY(uint8_t, backoffNo, BackoffNo); - __COPY(CSBK_BROADCAST); + DECLARE_COPY(CSBK_BROADCAST); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_BSDWNACT.h b/src/common/dmr/lc/csbk/CSBK_BSDWNACT.h index 354eda54..d164956b 100644 --- a/src/common/dmr/lc/csbk/CSBK_BSDWNACT.h +++ b/src/common/dmr/lc/csbk/CSBK_BSDWNACT.h @@ -61,9 +61,9 @@ namespace dmr /** * @brief Base Station ID. */ - __READONLY_PROPERTY(uint32_t, bsId, BSId); + DECLARE_RO_PROPERTY(uint32_t, bsId, BSId); - __COPY(CSBK_BSDWNACT); + DECLARE_COPY(CSBK_BSDWNACT); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.h b/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.h index 2ffd2974..92d7086f 100644 --- a/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.h +++ b/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.h @@ -61,9 +61,9 @@ namespace dmr /** * @brief Extended function opcode. */ - __PROPERTY(uint8_t, extendedFunction, ExtendedFunction); + DECLARE_PROPERTY(uint8_t, extendedFunction, ExtendedFunction); - __COPY(CSBK_EXT_FNCT); + DECLARE_COPY(CSBK_EXT_FNCT); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_MAINT.h b/src/common/dmr/lc/csbk/CSBK_MAINT.h index ca1e778e..6b3f2a74 100644 --- a/src/common/dmr/lc/csbk/CSBK_MAINT.h +++ b/src/common/dmr/lc/csbk/CSBK_MAINT.h @@ -64,9 +64,9 @@ namespace dmr /** * @brief Maintainence Kind. */ - __PROPERTY(uint8_t, maintKind, MaintKind); + DECLARE_PROPERTY(uint8_t, maintKind, MaintKind); - __COPY(CSBK_MAINT); + DECLARE_COPY(CSBK_MAINT); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_NACK_RSP.h b/src/common/dmr/lc/csbk/CSBK_NACK_RSP.h index a45b5efc..c31ce19e 100644 --- a/src/common/dmr/lc/csbk/CSBK_NACK_RSP.h +++ b/src/common/dmr/lc/csbk/CSBK_NACK_RSP.h @@ -61,9 +61,9 @@ namespace dmr /** * @brief Service Kind. */ - __PROPERTY(uint8_t, serviceKind, ServiceKind); + DECLARE_PROPERTY(uint8_t, serviceKind, ServiceKind); - __COPY(CSBK_NACK_RSP); + DECLARE_COPY(CSBK_NACK_RSP); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_RAND.h b/src/common/dmr/lc/csbk/CSBK_RAND.h index cbecd5a4..119cacb1 100644 --- a/src/common/dmr/lc/csbk/CSBK_RAND.h +++ b/src/common/dmr/lc/csbk/CSBK_RAND.h @@ -61,17 +61,17 @@ namespace dmr /** * @brief Service Options. */ - __PROPERTY(uint8_t, serviceOptions, ServiceOptions); + DECLARE_PROPERTY(uint8_t, serviceOptions, ServiceOptions); /** * @brief Service Extra Options. */ - __PROPERTY(uint8_t, serviceExtra, ServiceExtra); + DECLARE_PROPERTY(uint8_t, serviceExtra, ServiceExtra); /** * @brief Service Kind. */ - __PROPERTY(uint8_t, serviceKind, ServiceKind); + DECLARE_PROPERTY(uint8_t, serviceKind, ServiceKind); - __COPY(CSBK_RAND); + DECLARE_COPY(CSBK_RAND); }; } // namespace csbk } // namespace lc diff --git a/src/common/dmr/lc/csbk/CSBK_TV_GRANT.h b/src/common/dmr/lc/csbk/CSBK_TV_GRANT.h index 36810d29..12418ec6 100644 --- a/src/common/dmr/lc/csbk/CSBK_TV_GRANT.h +++ b/src/common/dmr/lc/csbk/CSBK_TV_GRANT.h @@ -61,9 +61,9 @@ namespace dmr /** * @brief Flag indicating whether the grant is a late entry. */ - __PROPERTY(bool, lateEntry, LateEntry); + DECLARE_PROPERTY(bool, lateEntry, LateEntry); - __COPY(CSBK_TV_GRANT); + DECLARE_COPY(CSBK_TV_GRANT); }; } // namespace csbk } // namespace lc diff --git a/src/common/lookups/ChannelLookup.h b/src/common/lookups/ChannelLookup.h index c5ce28b5..545fe151 100644 --- a/src/common/lookups/ChannelLookup.h +++ b/src/common/lookups/ChannelLookup.h @@ -48,6 +48,8 @@ namespace lookups VoiceChData() : m_chId(0U), m_chNo(0U), + m_rxChId(0xFFU), + m_rxChNo(0xFFFFU), m_address(), m_port(), m_password(), @@ -67,6 +69,31 @@ namespace lookups VoiceChData(uint8_t chId, uint32_t chNo, std::string address, uint16_t port, std::string password, bool ssl = false) : m_chId(chId), m_chNo(chNo), + m_rxChId(0xFFU), + m_rxChNo(0xFFFFU), + m_address(address), + m_port(port), + m_password(password), + m_ssl(ssl) + { + /* stub */ + } + /** + * @brief Initializes a new instance of the VoiceChData class. + * @param chId Voice Channel Identity. + * @param chNo Voice Channel Number. + * @param chId Voice Rx Channel Identity. + * @param chNo Voice Rx Channel Number. + * @param address RPC/REST API Address. + * @param port RPC/REST API Port. + * @param password RPC/REST API Password. + * @param ssl Flag indicating REST is using SSL. + */ + VoiceChData(uint8_t chId, uint32_t chNo, uint8_t rxChId, uint32_t rxChNo, std::string address, uint16_t port, std::string password, bool ssl = false) : + m_chId(chId), + m_chNo(chNo), + m_rxChId(rxChId), + m_rxChNo(rxChNo), m_address(address), m_port(port), m_password(password), @@ -84,6 +111,8 @@ namespace lookups if (this != &data) { m_chId = data.m_chId; m_chNo = data.m_chNo; + m_rxChId = data.m_rxChId; + m_rxChNo = data.m_rxChNo; m_address = data.m_address; m_port = data.m_port; m_password = data.m_password; @@ -103,32 +132,56 @@ namespace lookups * @returns True, if channel is valid, otherwise false. */ bool isValidCh() const { return m_chNo != 0U; } + /** + * @brief Helper to determine if the Rx channel identity is valid. + * @returns True, if channel identity is valid, otherwise false. + */ + bool isValidRxChId() const { return m_rxChId != 0U && m_rxChId != 0xFFU; } + /** + * @brief Helper to determine if the Rx channel is valid. + * @returns True, if channel is valid, otherwise false. + */ + bool isValidRxCh() const { return m_rxChNo != 0U && m_rxChNo != 0xFFFFU; } + + /** + * @brief Helper to determine if the channel is explicitly defined with independant Rx and Tx channels. + * @returns True, if channel is explicit, otherwise false. + */ + bool isExplicitCh() const { return (m_rxChId != 0xFFU && m_rxChId > 0U) && (m_rxChNo != 0xFFFFU && m_rxChNo > 0U); } public: /** * @brief Voice Channel Identity. */ - __READONLY_PROPERTY_PLAIN(uint8_t, chId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, chId); /** * @brief Voice Channel Number. */ - __READONLY_PROPERTY_PLAIN(uint32_t, chNo); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, chNo); + /** + * @brief Voice Rx Channel Identity. + */ + DECLARE_RO_PROPERTY_PLAIN(uint8_t, rxChId); + /** + * @brief Voice Rx Channel Number. + */ + DECLARE_RO_PROPERTY_PLAIN(uint32_t, rxChNo); /** * @brief RPC/REST API Address. */ - __PROPERTY_PLAIN(std::string, address); + DECLARE_PROPERTY_PLAIN(std::string, address); /** * @brief RPC/REST API Port. */ - __PROPERTY_PLAIN(uint16_t, port); + DECLARE_PROPERTY_PLAIN(uint16_t, port); /** * @brief RPC/REST API Password. */ - __READONLY_PROPERTY_PLAIN(std::string, password); + DECLARE_RO_PROPERTY_PLAIN(std::string, password); /** * @brief Flag indicating REST is using SSL. */ - __PROPERTY_PLAIN(bool, ssl); + DECLARE_PROPERTY_PLAIN(bool, ssl); }; // --------------------------------------------------------------------------- diff --git a/src/common/lookups/IdenTableLookup.h b/src/common/lookups/IdenTableLookup.h index d6fc042b..68fd1080 100644 --- a/src/common/lookups/IdenTableLookup.h +++ b/src/common/lookups/IdenTableLookup.h @@ -91,23 +91,23 @@ namespace lookups /** * @brief Channel ID for this entry. */ - __READONLY_PROPERTY_PLAIN(uint8_t, channelId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, channelId); /** * @brief Base frequency for this entry. */ - __READONLY_PROPERTY_PLAIN(uint32_t, baseFrequency); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, baseFrequency); /** * @brief Channel spacing in kHz for this entry. */ - __READONLY_PROPERTY_PLAIN(float, chSpaceKhz); + DECLARE_RO_PROPERTY_PLAIN(float, chSpaceKhz); /** * @brief Channel transmit offset in MHz for this entry. */ - __READONLY_PROPERTY_PLAIN(float, txOffsetMhz); + DECLARE_RO_PROPERTY_PLAIN(float, txOffsetMhz); /** * @brief Channel bandwith in kHz for this entry. */ - __READONLY_PROPERTY_PLAIN(float, chBandwidthKhz); + DECLARE_RO_PROPERTY_PLAIN(float, chBandwidthKhz); }; // --------------------------------------------------------------------------- diff --git a/src/common/lookups/PeerListLookup.h b/src/common/lookups/PeerListLookup.h index 8738a1e1..5a55a627 100644 --- a/src/common/lookups/PeerListLookup.h +++ b/src/common/lookups/PeerListLookup.h @@ -118,27 +118,27 @@ namespace lookups /** * @brief Peer ID. */ - __PROPERTY_PLAIN(uint32_t, peerId); + DECLARE_PROPERTY_PLAIN(uint32_t, peerId); /** * @breif Peer Alias */ - __PROPERTY_PLAIN(std::string, peerAlias); + DECLARE_PROPERTY_PLAIN(std::string, peerAlias); /** * @brief Per Peer Password. */ - __PROPERTY_PLAIN(std::string, peerPassword); + DECLARE_PROPERTY_PLAIN(std::string, peerPassword); /** * @brief Flag indicating if the peer participates in peer link and should be sent configuration. */ - __PROPERTY_PLAIN(bool, peerLink); + DECLARE_PROPERTY_PLAIN(bool, peerLink); /** * @brief Flag indicating if the peer can request encryption keys. */ - __PROPERTY_PLAIN(bool, canRequestKeys); + DECLARE_PROPERTY_PLAIN(bool, canRequestKeys); /** * @brief Flag indicating if the peer is default. */ - __READONLY_PROPERTY_PLAIN(bool, peerDefault); + DECLARE_RO_PROPERTY_PLAIN(bool, peerDefault); }; // --------------------------------------------------------------------------- diff --git a/src/common/lookups/RadioIdLookup.h b/src/common/lookups/RadioIdLookup.h index e26d800f..2e65400a 100644 --- a/src/common/lookups/RadioIdLookup.h +++ b/src/common/lookups/RadioIdLookup.h @@ -116,19 +116,19 @@ namespace lookups /** * @brief Flag indicating if the radio is enabled. */ - __READONLY_PROPERTY_PLAIN(bool, radioEnabled); + DECLARE_RO_PROPERTY_PLAIN(bool, radioEnabled); /** * @brief Flag indicating if the radio is default. */ - __READONLY_PROPERTY_PLAIN(bool, radioDefault); + DECLARE_RO_PROPERTY_PLAIN(bool, radioDefault); /** * @brief Alias for the radio. */ - __READONLY_PROPERTY_PLAIN(std::string, radioAlias); + DECLARE_RO_PROPERTY_PLAIN(std::string, radioAlias); /** * @brief IP Address for the radio. */ - __READONLY_PROPERTY_PLAIN(std::string, radioIPAddress); + DECLARE_RO_PROPERTY_PLAIN(std::string, radioIPAddress); }; // --------------------------------------------------------------------------- diff --git a/src/common/lookups/TalkgroupRulesLookup.h b/src/common/lookups/TalkgroupRulesLookup.h index 68e22cb3..0b52b4a7 100644 --- a/src/common/lookups/TalkgroupRulesLookup.h +++ b/src/common/lookups/TalkgroupRulesLookup.h @@ -91,11 +91,11 @@ namespace lookups /** * @brief Talkgroup ID. */ - __PROPERTY_PLAIN(uint32_t, tgId); + DECLARE_PROPERTY_PLAIN(uint32_t, tgId); /** * @brief Talkgroup DMR slot. */ - __PROPERTY_PLAIN(uint8_t, tgSlot); + DECLARE_PROPERTY_PLAIN(uint8_t, tgSlot); }; // --------------------------------------------------------------------------- @@ -160,15 +160,15 @@ namespace lookups /** * @brief Peer ID. */ - __PROPERTY_PLAIN(uint32_t, peerId); + DECLARE_PROPERTY_PLAIN(uint32_t, peerId); /** * @brief Talkgroup ID. */ - __PROPERTY_PLAIN(uint32_t, tgId); + DECLARE_PROPERTY_PLAIN(uint32_t, tgId); /** * @brief Talkgroup DMR slot. */ - __PROPERTY_PLAIN(uint8_t, tgSlot); + DECLARE_PROPERTY_PLAIN(uint8_t, tgSlot); }; // --------------------------------------------------------------------------- @@ -382,45 +382,45 @@ namespace lookups /** * @brief Flag indicating whether the rule is active. */ - __PROPERTY_PLAIN(bool, active); + DECLARE_PROPERTY_PLAIN(bool, active); /** * @brief Flag indicating whether this talkgroup will only repeat with affiliations. */ - __PROPERTY_PLAIN(bool, affiliated); + DECLARE_PROPERTY_PLAIN(bool, affiliated); /** * @brief Flag indicating whether or not the talkgroup is a parrot. */ - __PROPERTY_PLAIN(bool, parrot); + DECLARE_PROPERTY_PLAIN(bool, parrot); /** * @brief List of peer IDs included by this rule. */ - __PROPERTY_PLAIN(std::vector, inclusion); + DECLARE_PROPERTY_PLAIN(std::vector, inclusion); /** * @brief List of peer IDs excluded by this rule. */ - __PROPERTY_PLAIN(std::vector, exclusion); + DECLARE_PROPERTY_PLAIN(std::vector, exclusion); /** * @brief List of rewrites performed by this rule. */ - __PROPERTY_PLAIN(std::vector, rewrite); + DECLARE_PROPERTY_PLAIN(std::vector, rewrite); /** * @brief List of always send performed by this rule. */ - __PROPERTY_PLAIN(std::vector, alwaysSend); + DECLARE_PROPERTY_PLAIN(std::vector, alwaysSend); /** * @brief List of peer IDs preferred by this rule. */ - __PROPERTY_PLAIN(std::vector, preferred); + DECLARE_PROPERTY_PLAIN(std::vector, preferred); /** * @brief List of radios IDs permitted to transmit on the talkgroup. */ - __PROPERTY_PLAIN(std::vector, permittedRIDs); + DECLARE_PROPERTY_PLAIN(std::vector, permittedRIDs); /** * @brief Flag indicating whether or not the talkgroup is a non-preferred. */ - __PROPERTY_PLAIN(bool, nonPreferred); + DECLARE_PROPERTY_PLAIN(bool, nonPreferred); }; // --------------------------------------------------------------------------- @@ -506,19 +506,19 @@ namespace lookups /** * @brief Textual name for the routing rule. */ - __PROPERTY_PLAIN(std::string, name); + DECLARE_PROPERTY_PLAIN(std::string, name); /** * @brief (Optional) Secondary textual name for the routing rule. */ - __PROPERTY_PLAIN(std::string, nameAlias); + DECLARE_PROPERTY_PLAIN(std::string, nameAlias); /** * @brief Configuration for the routing rule. */ - __PROPERTY_PLAIN(TalkgroupRuleConfig, config); + DECLARE_PROPERTY_PLAIN(TalkgroupRuleConfig, config); /** * @brief Source talkgroup information for the routing rule. */ - __PROPERTY_PLAIN(TalkgroupRuleGroupVoiceSource, source); + DECLARE_PROPERTY_PLAIN(TalkgroupRuleGroupVoiceSource, source); }; // --------------------------------------------------------------------------- @@ -661,15 +661,15 @@ namespace lookups /** * @brief Number indicating the number of seconds to hang on a talkgroup. */ - __PROPERTY_PLAIN(uint32_t, groupHangTime); + DECLARE_PROPERTY_PLAIN(uint32_t, groupHangTime); /** * @brief Flag indicating whether or not the network layer should send the talkgroups to peers. */ - __PROPERTY_PLAIN(bool, sendTalkgroups); + DECLARE_PROPERTY_PLAIN(bool, sendTalkgroups); /** * @brief List of group voice rules. */ - __PROPERTY_PLAIN(std::vector, groupVoice); + DECLARE_PROPERTY_PLAIN(std::vector, groupVoice); }; } // namespace lookups diff --git a/src/common/network/BaseNetwork.cpp b/src/common/network/BaseNetwork.cpp index 8fa7ea7e..ead726ed 100644 --- a/src/common/network/BaseNetwork.cpp +++ b/src/common/network/BaseNetwork.cpp @@ -101,8 +101,8 @@ bool BaseNetwork::writeGrantReq(const uint8_t mode, const uint32_t srcId, const uint8_t buffer[MSG_HDR_SIZE]; ::memset(buffer, 0x00U, MSG_HDR_SIZE); - __SET_UINT32(srcId, buffer, 11U); // Source Address - __SET_UINT32(dstId, buffer, 15U); // Destination Address + SET_UINT32(srcId, buffer, 11U); // Source Address + SET_UINT32(dstId, buffer, 15U); // Destination Address buffer[19U] = slot; // Slot Number if (unitToUnit) @@ -220,8 +220,8 @@ bool BaseNetwork::announceGroupAffiliation(uint32_t srcId, uint32_t dstId) uint8_t buffer[DATA_PACKET_LENGTH]; - __SET_UINT16(srcId, buffer, 0U); - __SET_UINT16(dstId, buffer, 3U); + SET_UINT24(srcId, buffer, 0U); + SET_UINT24(dstId, buffer, 3U); return writeMaster({ NET_FUNC::ANNOUNCE, NET_SUBFUNC::ANNC_SUBFUNC_GRP_AFFIL }, buffer, MSG_ANNC_GRP_AFFIL, RTP_END_OF_CALL_SEQ, 0U); } @@ -235,7 +235,7 @@ bool BaseNetwork::announceGroupAffiliationRemoval(uint32_t srcId) uint8_t buffer[DATA_PACKET_LENGTH]; - __SET_UINT16(srcId, buffer, 0U); + SET_UINT24(srcId, buffer, 0U); return writeMaster({ NET_FUNC::ANNOUNCE, NET_SUBFUNC::ANNC_SUBFUNC_GRP_UNAFFIL }, buffer, MSG_ANNC_GRP_UNAFFIL, RTP_END_OF_CALL_SEQ, 0U); } @@ -249,7 +249,7 @@ bool BaseNetwork::announceUnitRegistration(uint32_t srcId) uint8_t buffer[DATA_PACKET_LENGTH]; - __SET_UINT16(srcId, buffer, 0U); + SET_UINT24(srcId, buffer, 0U); return writeMaster({ NET_FUNC::ANNOUNCE, NET_SUBFUNC::ANNC_SUBFUNC_UNIT_REG }, buffer, MSG_ANNC_UNIT_REG, RTP_END_OF_CALL_SEQ, 0U); } @@ -263,7 +263,7 @@ bool BaseNetwork::announceUnitDeregistration(uint32_t srcId) uint8_t buffer[DATA_PACKET_LENGTH]; - __SET_UINT16(srcId, buffer, 0U); + SET_UINT24(srcId, buffer, 0U); return writeMaster({ NET_FUNC::ANNOUNCE, NET_SUBFUNC::ANNC_SUBFUNC_UNIT_DEREG }, buffer, MSG_ANNC_UNIT_REG, RTP_END_OF_CALL_SEQ, 0U); } @@ -275,17 +275,15 @@ bool BaseNetwork::announceAffiliationUpdate(const std::unordered_map(4U + (affs.size() * 8U)); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, 4U + (affs.size() * 8U)); + DECLARE_UINT8_ARRAY(buffer, 4U + (affs.size() * 8U)); - __SET_UINT32(affs.size(), buffer, 0U); + SET_UINT32(affs.size(), buffer, 0U); // write talkgroup IDs to active TGID payload uint32_t offs = 4U; for (auto it : affs) { - __SET_UINT16(it.first, buffer, offs); - __SET_UINT16(it.second, buffer, offs + 4U); + SET_UINT24(it.first, buffer, offs); + SET_UINT24(it.second, buffer, offs + 4U); offs += 8U; } @@ -299,16 +297,14 @@ bool BaseNetwork::announceSiteVCs(const std::vector peers) if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) return false; - UInt8Array __buffer = std::make_unique(4U + (peers.size() * 4U)); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, 4U + (peers.size() * 4U)); + DECLARE_UINT8_ARRAY(buffer, 4U + (peers.size() * 4U)); - __SET_UINT32(peers.size(), buffer, 0U); + SET_UINT32(peers.size(), buffer, 0U); // write peer IDs to active TGID payload uint32_t offs = 4U; for (auto it : peers) { - __SET_UINT32(it, buffer, offs); + SET_UINT32(it, buffer, offs); offs += 4U; } @@ -762,10 +758,10 @@ UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t strea ::memcpy(buffer + 0U, TAG_DMR_DATA, 4U); uint32_t srcId = data.getSrcId(); // Source Address - __SET_UINT16(srcId, buffer, 5U); + SET_UINT24(srcId, buffer, 5U); uint32_t dstId = data.getDstId(); // Target Address - __SET_UINT16(dstId, buffer, 8U); + SET_UINT24(dstId, buffer, 8U); uint32_t slotNo = data.getSlotNo(); @@ -826,20 +822,20 @@ void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E du buffer[4U] = control.getLCO(); // LCO uint32_t srcId = control.getSrcId(); // Source Address - __SET_UINT16(srcId, buffer, 5U); + SET_UINT24(srcId, buffer, 5U); uint32_t dstId = control.getDstId(); // Target Address - __SET_UINT16(dstId, buffer, 8U); + SET_UINT24(dstId, buffer, 8U); uint16_t sysId = control.getSiteData().sysId(); // System ID - __SET_UINT16B(sysId, buffer, 11U); + SET_UINT16(sysId, buffer, 11U); buffer[14U] = 0U; // Control Bits buffer[15U] = control.getMFId(); // MFId uint32_t netId = control.getSiteData().netId(); // Network ID - __SET_UINT16(netId, buffer, 16U); + SET_UINT24(netId, buffer, 16U); buffer[20U] = lsd.getLSD1(); // LSD 1 buffer[21U] = lsd.getLSD2(); // LSD 2 @@ -855,7 +851,7 @@ void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E du buffer[181U] = control.getAlgId(); // Algorithm ID uint32_t kid = control.getKId(); - __SET_UINT16B(kid, buffer, 182U); // Key ID + SET_UINT16(kid, buffer, 182U); // Key ID // copy MI data uint8_t mi[MI_LENGTH_BYTES]; @@ -1125,7 +1121,7 @@ UInt8Array BaseNetwork::createP25_PDUMessage(uint32_t& length, const p25::data:: buffer[4U] |= 0x80U; } - __SET_UINT16(len, buffer, 8U); // PDU Length [bytes] + SET_UINT24(len, buffer, 8U); // PDU Length [bytes] buffer[15U] = header.getMFId(); // MFId @@ -1164,10 +1160,10 @@ UInt8Array BaseNetwork::createNXDN_Message(uint32_t& length, const nxdn::lc::RTC buffer[4U] = lc.getMessageType(); // Message Type uint32_t srcId = lc.getSrcId(); // Source Address - __SET_UINT16(srcId, buffer, 5U); + SET_UINT24(srcId, buffer, 5U); uint32_t dstId = lc.getDstId(); // Target Address - __SET_UINT16(dstId, buffer, 8U); + SET_UINT24(dstId, buffer, 8U); buffer[14U] = 0U; // Control Bits diff --git a/src/common/network/BaseNetwork.h b/src/common/network/BaseNetwork.h index bdac4713..c89c7a01 100644 --- a/src/common/network/BaseNetwork.h +++ b/src/common/network/BaseNetwork.h @@ -444,34 +444,34 @@ namespace network /** * @brief Gets the peer ID of the network. */ - __PROTECTED_READONLY_PROPERTY(uint32_t, peerId, PeerId); + DECLARE_PROTECTED_RO_PROPERTY(uint32_t, peerId, PeerId); /** * @brief Gets the current status of the network. */ - __PROTECTED_READONLY_PROPERTY(NET_CONN_STATUS, status, Status); + DECLARE_PROTECTED_RO_PROPERTY(NET_CONN_STATUS, status, Status); /** * @brief Unix socket storage containing the connected address. */ - __PROTECTED_READONLY_PROPERTY_PLAIN(sockaddr_storage, addr); + DECLARE_PROTECTED_RO_PROPERTY_PLAIN(sockaddr_storage, addr); /** * @brief Length of the sockaddr_storage structure. */ - __PROTECTED_READONLY_PROPERTY_PLAIN(uint32_t, addrLen); + DECLARE_PROTECTED_RO_PROPERTY_PLAIN(uint32_t, addrLen); /** * @brief Flag indicating whether network DMR slot 1 traffic is permitted. */ - __PROTECTED_READONLY_PROPERTY(bool, slot1, DMRSlot1); + DECLARE_PROTECTED_RO_PROPERTY(bool, slot1, DMRSlot1); /** * @brief Flag indicating whether network DMR slot 2 traffic is permitted. */ - __PROTECTED_READONLY_PROPERTY(bool, slot2, DMRSlot2); + DECLARE_PROTECTED_RO_PROPERTY(bool, slot2, DMRSlot2); /** * @brief Flag indicating whether network traffic is duplex. */ - __PROTECTED_READONLY_PROPERTY(bool, duplex, Duplex); + DECLARE_PROTECTED_RO_PROPERTY(bool, duplex, Duplex); protected: bool m_useAlternatePortForDiagnostics; diff --git a/src/common/network/FrameQueue.cpp b/src/common/network/FrameQueue.cpp index 880691a8..1d5b0422 100644 --- a/src/common/network/FrameQueue.cpp +++ b/src/common/network/FrameQueue.cpp @@ -32,6 +32,9 @@ using namespace network::frame; FrameQueue::FrameQueue(udp::Socket* socket, uint32_t peerId, bool debug) : RawFrameQueue(socket, debug), m_peerId(peerId), +#if defined(_WIN32) + m_streamTSMtx(), +#endif // defined(_WIN32) m_streamTimestamps() { assert(peerId < 999999999U); @@ -148,6 +151,12 @@ bool FrameQueue::write(const uint8_t* message, uint32_t length, uint32_t streamI uint32_t bufferLen = 0U; uint8_t* buffer = generateMessage(message, length, streamId, peerId, ssrc, opcode, rtpSeq, &bufferLen); + // bryanb: this is really a developer warning not a end-user warning, there's nothing the end-users can do about + // this message + if (bufferLen > (DATA_PACKET_LENGTH - OVERSIZED_PACKET_WARN)) { + LogDebug(LOG_NET, "FrameQueue::write(), WARN: packet length is possibly oversized, possible data truncation - BUGBUG"); + } + bool ret = true; if (!m_socket->write(buffer, bufferLen, addr, addrLen)) { // LogError(LOG_NET, "Failed writing data to the network"); @@ -183,6 +192,12 @@ void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_ uint32_t bufferLen = 0U; uint8_t* buffer = generateMessage(message, length, streamId, peerId, ssrc, opcode, rtpSeq, &bufferLen); + // bryanb: this is really a developer warning not a end-user warning, there's nothing the end-users can do about + // this message + if (bufferLen > (DATA_PACKET_LENGTH - OVERSIZED_PACKET_WARN)) { + LogDebug(LOG_NET, "FrameQueue::enqueueMessage(), WARN: packet length is possibly oversized, possible data truncation - BUGBUG"); + } + udp::UDPDatagram *dgram = new udp::UDPDatagram; dgram->buffer = buffer; dgram->length = bufferLen; @@ -219,7 +234,11 @@ uint8_t* FrameQueue::generateMessage(const uint8_t* message, uint32_t length, ui uint32_t timestamp = INVALID_TS; if (streamId != 0U) { +#if defined(_WIN32) + std::lock_guard lock(m_streamTSMtx); +#else m_streamTimestamps.lock(false); +#endif // defined(_WIN32) auto entry = m_streamTimestamps.find(streamId); if (entry != m_streamTimestamps.end()) { timestamp = entry->second; @@ -231,7 +250,9 @@ uint8_t* FrameQueue::generateMessage(const uint8_t* message, uint32_t length, ui LogDebugEx(LOG_NET, "FrameQueue::generateMessage()", "RTP streamId = %u, previous TS = %u, TS = %u, rtpSeq = %u", streamId, m_streamTimestamps[streamId], timestamp, rtpSeq); m_streamTimestamps[streamId] = timestamp; } +#if !defined(_WIN32) m_streamTimestamps.unlock(); +#endif // defined(_WIN32) } uint32_t bufferLen = RTP_HEADER_LENGTH_BYTES + RTP_EXTENSION_HEADER_LENGTH_BYTES + RTP_FNE_HEADER_LENGTH_BYTES + length; @@ -253,21 +274,34 @@ uint8_t* FrameQueue::generateMessage(const uint8_t* message, uint32_t length, ui timestamp = (uint32_t)system_clock::ntp::now(); header.setTimestamp(timestamp); +#if defined(_WIN32) + std::lock_guard lock(m_streamTSMtx); + m_streamTimestamps.insert({ streamId, timestamp }); +#else m_streamTimestamps.insert(streamId, timestamp); +#endif // defined(_WIN32) } header.encode(buffer); if (streamId != 0U && rtpSeq == RTP_END_OF_CALL_SEQ) { +#if defined(_WIN32) + std::lock_guard lock(m_streamTSMtx); +#else m_streamTimestamps.lock(false); +#endif // defined(_WIN32) auto entry = m_streamTimestamps.find(streamId); if (entry != m_streamTimestamps.end()) { if (m_debug) LogDebugEx(LOG_NET, "FrameQueue::generateMessage()", "RTP streamId = %u, rtpSeq = %u", streamId, rtpSeq); +#if !defined(_WIN32) m_streamTimestamps.unlock(); +#endif // defined(_WIN32) m_streamTimestamps.erase(streamId); } +#if !defined(_WIN32) m_streamTimestamps.unlock(); +#endif // defined(_WIN32) } RTPFNEHeader fneHeader = RTPFNEHeader(); diff --git a/src/common/network/FrameQueue.h b/src/common/network/FrameQueue.h index 6806d51f..041863f1 100644 --- a/src/common/network/FrameQueue.h +++ b/src/common/network/FrameQueue.h @@ -115,7 +115,12 @@ namespace network private: uint32_t m_peerId; +#if defined(_WIN32) + std::mutex m_streamTSMtx; + std::unordered_map m_streamTimestamps; +#else concurrent::unordered_map m_streamTimestamps; +#endif // defined(_WIN32) /** * @brief Generate RTP message for the frame queue. diff --git a/src/common/network/NetRPC.cpp b/src/common/network/NetRPC.cpp index 1e774820..f03824b2 100644 --- a/src/common/network/NetRPC.cpp +++ b/src/common/network/NetRPC.cpp @@ -210,8 +210,7 @@ bool NetRPC::req(uint16_t func, const json::object& request, RPCType reply, sock header.setMessageLength(json.length() + 1U); // generate message - CharArray __message = std::make_unique(json.length() + 1U); - char* message = __message.get(); + DECLARE_CHAR_ARRAY(message, json.length() + 1U); ::snprintf(message, json.length() + 1U, "%s", json.c_str()); @@ -223,8 +222,7 @@ bool NetRPC::req(uint16_t func, const json::object& request, RPCType reply, sock header.setCRC(crc); // generate RPC message - UInt8Array __buffer = std::make_unique(json.length() + 9U); - uint8_t* buffer = __buffer.get(); + DECLARE_UINT8_ARRAY(buffer, json.length() + 9U); header.encode(buffer); ::memcpy(buffer + 8U, message, json.length() + 1U); @@ -338,8 +336,7 @@ bool NetRPC::reply(uint16_t func, json::object& reply, sockaddr_storage& address header.setMessageLength(json.length() + 1U); // generate message - CharArray __message = std::make_unique(json.length() + 1U); - char* message = __message.get(); + DECLARE_CHAR_ARRAY(message, json.length() + 1U); ::snprintf(message, json.length() + 1U, "%s", json.c_str()); @@ -347,8 +344,7 @@ bool NetRPC::reply(uint16_t func, json::object& reply, sockaddr_storage& address header.setCRC(crc); // generate RPC message - UInt8Array __buffer = std::make_unique(json.length() + 9U); - uint8_t* buffer = __buffer.get(); + DECLARE_UINT8_ARRAY(buffer, json.length() + 9U); header.encode(buffer); ::memcpy(buffer + 8U, message, json.length() + 1U); diff --git a/src/common/network/Network.cpp b/src/common/network/Network.cpp index 4ac152a1..e3b155e7 100644 --- a/src/common/network/Network.cpp +++ b/src/common/network/Network.cpp @@ -444,10 +444,10 @@ void Network::clock(uint32_t ms) if (m_ridLookup != nullptr) { // update RID lists - uint32_t len = __GET_UINT32(buffer, 6U); + uint32_t len = GET_UINT32(buffer, 6U); uint32_t offs = 11U; for (uint32_t i = 0; i < len; i++) { - uint32_t id = __GET_UINT16(buffer, offs); + uint32_t id = GET_UINT24(buffer, offs); m_ridLookup->toggleEntry(id, true); offs += 4U; } @@ -470,10 +470,10 @@ void Network::clock(uint32_t ms) if (m_ridLookup != nullptr) { // update RID lists - uint32_t len = __GET_UINT32(buffer, 6U); + uint32_t len = GET_UINT32(buffer, 6U); uint32_t offs = 11U; for (uint32_t i = 0; i < len; i++) { - uint32_t id = __GET_UINT16(buffer, offs); + uint32_t id = GET_UINT24(buffer, offs); m_ridLookup->toggleEntry(id, false); offs += 4U; } @@ -497,10 +497,10 @@ void Network::clock(uint32_t ms) if (m_tidLookup != nullptr) { // update TGID lists - uint32_t len = __GET_UINT32(buffer, 6U); + uint32_t len = GET_UINT32(buffer, 6U); uint32_t offs = 11U; for (uint32_t i = 0; i < len; i++) { - uint32_t id = __GET_UINT16(buffer, offs); + uint32_t id = GET_UINT24(buffer, offs); uint8_t slot = (buffer[offs + 3U]) & 0x03U; bool affiliated = (buffer[offs + 3U] & 0x40U) == 0x40U; bool nonPreferred = (buffer[offs + 3U] & 0x80U) == 0x80U; @@ -547,10 +547,10 @@ void Network::clock(uint32_t ms) if (m_tidLookup != nullptr) { // update TGID lists - uint32_t len = __GET_UINT32(buffer, 6U); + uint32_t len = GET_UINT32(buffer, 6U); uint32_t offs = 11U; for (uint32_t i = 0; i < len; i++) { - uint32_t id = __GET_UINT16(buffer, offs); + uint32_t id = GET_UINT24(buffer, offs); uint8_t slot = (buffer[offs + 3U]); lookups::TalkgroupRuleGroupVoice tid = m_tidLookup->find(id, slot); @@ -588,7 +588,7 @@ void Network::clock(uint32_t ms) { if (m_enabled && m_dmrEnabled) { NET_ICC::ENUM command = (NET_ICC::ENUM)buffer[10U]; - uint32_t dstId = __GET_UINT16(buffer, 11U); + uint32_t dstId = GET_UINT24(buffer, 11U); uint8_t slot = buffer[14U]; // fire off DMR in-call callback if we have one @@ -602,7 +602,7 @@ void Network::clock(uint32_t ms) { if (m_enabled && m_p25Enabled) { NET_ICC::ENUM command = (NET_ICC::ENUM)buffer[10U]; - uint32_t dstId = __GET_UINT16(buffer, 11U); + uint32_t dstId = GET_UINT24(buffer, 11U); // fire off P25 in-call callback if we have one if (m_p25InCallCallback != nullptr) { @@ -615,7 +615,7 @@ void Network::clock(uint32_t ms) { if (m_enabled && m_nxdnEnabled) { NET_ICC::ENUM command = (NET_ICC::ENUM)buffer[10U]; - uint32_t dstId = __GET_UINT16(buffer, 11U); + uint32_t dstId = GET_UINT24(buffer, 11U); // fire off NXDN in-call callback if we have one if (m_nxdnInCallCallback != nullptr) { @@ -677,7 +677,7 @@ void Network::clock(uint32_t ms) // then 10 bytes and process the reason value uint16_t reason = 0U; if (length > 10) { - reason = __GET_UINT16B(buffer, 10U); + reason = GET_UINT16(buffer, 10U); switch (reason) { case NET_CONN_NAK_MODE_NOT_ENABLED: LogWarning(LOG_NET, "PEER %u master NAK; digital mode not enabled on FNE, remotePeerId = %u", m_peerId, rtpHeader.getSSRC()); @@ -773,6 +773,11 @@ void Network::clock(uint32_t ms) m_useAlternatePortForDiagnostics = (buffer[6U] & 0x80U) == 0x80U; if (m_useAlternatePortForDiagnostics) { LogMessage(LOG_NET, "PEER %u RPTC ACK, master commanded alternate port for diagnostics and activity logging, remotePeerId = %u", m_peerId, rtpHeader.getSSRC()); + } else { + // disable diagnostic and activity logging automatically if the master doesn't utilize the alternate port + m_allowDiagnosticTransfer = false; + m_allowActivityTransfer = false; + LogWarning(LOG_NET, "PEER %u RPTC ACK, master does not enable alternate port for diagnostics and activity logging, diagnostic and activity logging are disabled, remotePeerId = %u", m_peerId, rtpHeader.getSSRC()); } } break; @@ -781,9 +786,9 @@ void Network::clock(uint32_t ms) } } break; - case NET_FUNC::MST_CLOSING: // Master Shutdown + case NET_FUNC::MST_DISC: // Master Disconnect { - LogError(LOG_NET, "PEER %u master is closing down, remotePeerId = %u", m_peerId, m_remotePeerId); + LogError(LOG_NET, "PEER %u master disconnect, remotePeerId = %u", m_peerId, m_remotePeerId); m_status = NET_STAT_WAITING_CONNECT; // fire off peer disconnected callback if we have one @@ -895,7 +900,7 @@ void Network::close() uint8_t buffer[1U]; ::memset(buffer, 0x00U, 1U); - writeMaster({ NET_FUNC::RPT_CLOSING, NET_SUBFUNC::NOP }, buffer, 1U, pktSeq(true), createStreamId()); + writeMaster({ NET_FUNC::RPT_DISC, NET_SUBFUNC::NOP }, buffer, 1U, pktSeq(true), createStreamId()); } m_socket->close(); @@ -934,7 +939,7 @@ bool Network::writeLogin() uint8_t buffer[8U]; ::memcpy(buffer + 0U, TAG_REPEATER_LOGIN, 4U); - __SET_UINT32(m_peerId, buffer, 4U); // Peer ID + SET_UINT32(m_peerId, buffer, 4U); // Peer ID if (m_debug) Utils::dump(1U, "Network Message, Login", buffer, 8U); @@ -962,7 +967,7 @@ bool Network::writeAuthorisation() uint8_t out[40U]; ::memcpy(out + 0U, TAG_REPEATER_AUTH, 4U); - __SET_UINT32(m_peerId, out, 4U); // Peer ID + SET_UINT32(m_peerId, out, 4U); // Peer ID edac::SHA256 sha256; sha256.buffer(in, (uint32_t)(size + sizeof(uint32_t)), out + 8U); @@ -1025,8 +1030,7 @@ bool Network::writeConfig() json::value v = json::value(config); std::string json = v.serialize(); - CharArray __buffer = std::make_unique(json.length() + 9U); - char* buffer = __buffer.get(); + DECLARE_CHAR_ARRAY(buffer, json.length() + 9U); ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); ::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str()); diff --git a/src/common/network/Network.h b/src/common/network/Network.h index a037abc5..290b77e2 100644 --- a/src/common/network/Network.h +++ b/src/common/network/Network.h @@ -222,7 +222,7 @@ namespace network /** * @brief Last received RTP sequence number. */ - __READONLY_PROPERTY_PLAIN(uint16_t, pktLastSeq); + DECLARE_RO_PROPERTY_PLAIN(uint16_t, pktLastSeq); protected: std::string m_address; diff --git a/src/common/network/PacketBuffer.cpp b/src/common/network/PacketBuffer.cpp new file mode 100644 index 00000000..5bb9fe8a --- /dev/null +++ b/src/common/network/PacketBuffer.cpp @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +#include "Defines.h" +#include "network/PacketBuffer.h" +#include "Log.h" +#include "Utils.h" + +using namespace network; +using namespace compress; + +#include + +// --------------------------------------------------------------------------- +// Public Class Members +// --------------------------------------------------------------------------- + +/* Initializes a new instance of the PacketBuffer class. */ + +PacketBuffer::PacketBuffer(bool compression, const char* name) : + fragments(), + m_compression(compression), + m_name(name) +{ + /* stub */ +} + +/* Finalizes a instance of the PacketBuffer class. */ + +PacketBuffer::~PacketBuffer() +{ + clear(); +} + +/* Decode a network packet fragment. */ + +bool PacketBuffer::decode(const uint8_t* data, uint8_t** message, uint32_t* outLength) +{ + assert(data != nullptr); + + *message = nullptr; + if (outLength != nullptr) { + *outLength = 0; + } + + uint8_t curBlock = data[8U]; + uint8_t blockCnt = data[9U]; + + Fragment* frag = new Fragment(); + + // if this is the first block store sizes and initialize temp buffer + if (curBlock == 0U) { + uint32_t size = GET_UINT32(data, 0U); + uint32_t compressedSize = GET_UINT32(data, 4U); + + frag->size = size; + frag->compressedSize = compressedSize; + } + + // scope is intentional + { + frag->blockId = curBlock; + if (frag->size < FRAG_BLOCK_SIZE) + frag->data = new uint8_t[FRAG_BLOCK_SIZE + 1U]; + else + frag->data = new uint8_t[frag->size + 1U]; + + ::memcpy(frag->data, data + FRAG_HDR_SIZE, FRAG_BLOCK_SIZE); + // Utils::dump(1U, "Block Payload", frag->data, FRAG_BLOCK_SIZE); + fragments.insert(curBlock, frag); + } + + LogInfoEx(LOG_NET, "%s, Inbound Packet Fragment, block %u of %u, rxFragments = %u", m_name, curBlock, blockCnt, fragments.size()); + + // do we have all the blocks? + if (fragments.size() == blockCnt + 1U) { + uint8_t* buffer = nullptr; + fragments.lock(false); + if (fragments[0] == nullptr) { + LogError(LOG_NET, "%s, Packet Fragment, error missing block 0? Packet dropped.", m_name); + fragments.unlock(); + clear(); + return false; + } + + if (fragments[0]->size == 0U) { + LogError(LOG_NET, "%s, Packet Fragment, error missing size information", m_name); + fragments.unlock(); + clear(); + return false; + } + + if (fragments[0]->compressedSize == 0U) { + LogError(LOG_NET, "%s, Packet Fragment, error missing compressed size information", m_name); + fragments.unlock(); + clear(); + return false; + } + + uint32_t compressedLen = fragments[0]->compressedSize; + uint32_t len = fragments[0]->size; + + buffer = new uint8_t[len +1U]; + ::memset(buffer, 0x00U, len + 1U); + if (fragments.size() == 1U) { + ::memcpy(buffer, fragments[0U]->data, len); + } else { + for (uint8_t i = 0U; i < fragments.size(); i++) { + uint32_t offs = i * FRAG_BLOCK_SIZE; + ::memcpy(buffer + offs, fragments[i]->data, FRAG_BLOCK_SIZE); + } + } + + if (m_compression) { + uint32_t decompressedLen = 0U; + *message = Compression::decompress(buffer, compressedLen, &decompressedLen); + + // check that we got the appropriate data + if (decompressedLen == len && message != nullptr) { + if (outLength != nullptr) { + *outLength = len; + } + + fragments.unlock(); + clear(); + return true; + } + } + else { + *message = buffer; + if (outLength != nullptr) { + *outLength = len; + } + + fragments.unlock(); + clear(); + return true; + } + + fragments.unlock(); + } + + return false; +} + +/* Encode a network packet fragment. */ + +void PacketBuffer::encode(uint8_t* data, uint32_t length) +{ + assert(data != nullptr); + assert(length > 0U); + + // erase any buffered fragments + clear(); + + // create temporary buffer + uint32_t compressedLen = 0U; + uint8_t* buffer = nullptr; + if (m_compression) { + buffer = Compression::compress(data, length, &compressedLen); + } else { + buffer = new uint8_t[length]; + ::memset(buffer, 0x00U, length); + ::memcpy(buffer, data, length); + compressedLen = length; + } + + // create packet fragments + uint8_t blockCnt = (compressedLen / FRAG_BLOCK_SIZE) + (compressedLen % FRAG_BLOCK_SIZE ? 1U : 0U); + uint32_t offs = 0U; + for (uint8_t i = 0U; i < blockCnt; i++) { + // build dataset + uint16_t bufSize = FRAG_SIZE; + + Fragment* frag = new Fragment(); + frag->blockId = i; + + frag->data = new uint8_t[bufSize]; + ::memset(frag->data, 0x00U, bufSize); + + if (i == 0U) { + SET_UINT32(length, frag->data, 0U); + frag->size = length; + SET_UINT32(compressedLen, frag->data, 4U); + frag->compressedSize = compressedLen; + } + + frag->data[8U] = i; + frag->data[9U] = blockCnt - 1U; + + uint32_t blockSize = FRAG_BLOCK_SIZE; + if (offs + FRAG_BLOCK_SIZE > compressedLen) + blockSize = FRAG_BLOCK_SIZE - ((offs + FRAG_BLOCK_SIZE) - compressedLen); + + ::memcpy(frag->data + FRAG_HDR_SIZE, buffer + offs, blockSize); + + offs += FRAG_BLOCK_SIZE; + + fragments.insert(i, frag); + LogInfoEx(LOG_NET, "%s, Outbound Packet Fragment, block %u of %u, txFragments = %u", m_name, i, blockCnt - 1U, fragments.size()); + } + + delete[] buffer; +} + +/* Helper to clear currently buffered fragments. */ + +void PacketBuffer::clear() +{ + fragments.lock(false); + for (auto entry : fragments) { + Fragment* frag = entry.second; + if (frag != nullptr) { + if (frag->data != nullptr) + delete[] frag->data; + frag->data = nullptr; + delete frag; + } + } + fragments.unlock(); + + fragments.clear(); +} diff --git a/src/common/network/PacketBuffer.h b/src/common/network/PacketBuffer.h new file mode 100644 index 00000000..c26f2a21 --- /dev/null +++ b/src/common/network/PacketBuffer.h @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file PacketBuffer.h + * @ingroup network_core + * @file PacketBuffer.cpp + * @ingroup network_core + */ +#if !defined(__PACKET_BUFFER_H__) +#define __PACKET_BUFFER_H__ + +#include "common/Defines.h" +#include "common/concurrent/unordered_map.h" +#include "common/zlib/Compression.h" + +#include + +// --------------------------------------------------------------------------- +// Constants +// --------------------------------------------------------------------------- + +#define FRAG_HDR_SIZE 10 +#define FRAG_BLOCK_SIZE 534 +#define FRAG_SIZE (FRAG_HDR_SIZE + FRAG_BLOCK_SIZE) + +namespace network +{ + // --------------------------------------------------------------------------- + // Class Declaration + // --------------------------------------------------------------------------- + + /** + * @brief Represents a fragmented packet buffer. + * @ingroup network_core + */ + class HOST_SW_API PacketBuffer { + public: + /** + * @brief Initializes a new instance of the PacketBuffer class. + * @param compression Flag indicating whether packet data should be compressed automatically. + * @param name Name of buffer. + */ + explicit PacketBuffer(bool compression, const char* name); + /** + * @brief Finalizes a instance of the PacketBuffer class. + */ + ~PacketBuffer(); + + /** + * @brief Decode a network packet fragment. + * @param[in] data Buffer containing packet fragment to decode. + * @param[out] message Buffer containing assembled message. + * @param[out] outLength Length of assembled message. + */ + bool decode(const uint8_t* data, uint8_t** message, uint32_t* outLength); + /** + * @brief Encode a network packet fragment. + * @param[out] data Message to encode. + * @param length Length of message. + */ + void encode(uint8_t* data, uint32_t length); + + /** + * @brief Helper to clear currently buffered fragments. + */ + void clear(); + + public: + /** + * @brief Represents a packet buffer fragment. + */ + class Fragment { + public: + /** + * @brief Compressed size of the packet. + */ + uint32_t compressedSize; + /** + * @brief Uncompressed size of the packet. + */ + uint32_t size; + + /** + * @brief Size of the packet fragment block. + */ + uint32_t blockSize; + /** + * @brief Block ID of the fragment. + */ + uint8_t blockId; + + /** + * @brief Fragment data. + */ + uint8_t* data; + }; + concurrent::unordered_map fragments; + + private: + bool m_compression; + const char* m_name; + }; +} // namespace network + +#endif // __PACKET_BUFFER_H__ diff --git a/src/common/network/RPCHeader.cpp b/src/common/network/RPCHeader.cpp index 80cb4e72..7ab79bb3 100644 --- a/src/common/network/RPCHeader.cpp +++ b/src/common/network/RPCHeader.cpp @@ -40,8 +40,8 @@ bool RPCHeader::decode(const uint8_t* data) assert(data != nullptr); m_crc16 = (data[0U] << 8) | (data[1U] << 0); // CRC-16 - m_func = __GET_UINT16B(data, 2U); // Function - m_messageLength = __GET_UINT32(data, 4U); // Message Length + m_func = GET_UINT16(data, 2U); // Function + m_messageLength = GET_UINT32(data, 4U); // Message Length return true; } @@ -54,7 +54,7 @@ void RPCHeader::encode(uint8_t* data) data[0U] = (m_crc16 >> 8) & 0xFFU; // CRC-16 MSB data[1U] = (m_crc16 >> 0) & 0xFFU; // CRC-16 LSB - __SET_UINT16B(m_func, data, 2U); // Function + SET_UINT16(m_func, data, 2U); // Function - __SET_UINT32(m_messageLength, data, 4U); // Message Length + SET_UINT32(m_messageLength, data, 4U); // Message Length } diff --git a/src/common/network/RPCHeader.h b/src/common/network/RPCHeader.h index f6d8ec81..40caa92a 100644 --- a/src/common/network/RPCHeader.h +++ b/src/common/network/RPCHeader.h @@ -72,15 +72,15 @@ namespace network /** * @brief Payload packet CRC-16. */ - __PROPERTY(uint16_t, crc16, CRC); + DECLARE_PROPERTY(uint16_t, crc16, CRC); /** * @brief Function. */ - __PROPERTY(uint16_t, func, Function); + DECLARE_PROPERTY(uint16_t, func, Function); /** * @brief Message Length. */ - __PROPERTY(uint32_t, messageLength, MessageLength); + DECLARE_PROPERTY(uint32_t, messageLength, MessageLength); }; } // namespace frame } // namespace network diff --git a/src/common/network/RTPExtensionHeader.h b/src/common/network/RTPExtensionHeader.h index c789afb3..658054de 100644 --- a/src/common/network/RTPExtensionHeader.h +++ b/src/common/network/RTPExtensionHeader.h @@ -73,11 +73,11 @@ namespace network /** * @brief Format of the extension header payload contained within the packet. */ - __PROTECTED_PROPERTY(uint16_t, payloadType, PayloadType); + DECLARE_PROTECTED_PROPERTY(uint16_t, payloadType, PayloadType); /** * @brief Length of the extension header payload (in 32-bit units). */ - __PROTECTED_PROPERTY(uint16_t, payloadLength, PayloadLength); + DECLARE_PROTECTED_PROPERTY(uint16_t, payloadLength, PayloadLength); }; } // namespace frame } // namespace network diff --git a/src/common/network/RTPFNEHeader.cpp b/src/common/network/RTPFNEHeader.cpp index 487d2672..0e412110 100644 --- a/src/common/network/RTPFNEHeader.cpp +++ b/src/common/network/RTPFNEHeader.cpp @@ -55,9 +55,9 @@ bool RTPFNEHeader::decode(const uint8_t* data) m_crc16 = (data[4U] << 8) | (data[5U] << 0); // CRC-16 m_func = (NET_FUNC::ENUM)data[6U]; // Function m_subFunc = (NET_SUBFUNC::ENUM)data[7U]; // Sub-Function - m_streamId = __GET_UINT32(data, 8U); // Stream ID - m_peerId = __GET_UINT32(data, 12U); // Peer ID - m_messageLength = __GET_UINT32(data, 16U); // Message Length + m_streamId = GET_UINT32(data, 8U); // Stream ID + m_peerId = GET_UINT32(data, 12U); // Peer ID + m_messageLength = GET_UINT32(data, 16U); // Message Length return true; } @@ -77,7 +77,7 @@ void RTPFNEHeader::encode(uint8_t* data) data[6U] = m_func; // Function data[7U] = m_subFunc; // Sub-Function - __SET_UINT32(m_streamId, data, 8U); // Stream ID - __SET_UINT32(m_peerId, data, 12U); // Peer ID - __SET_UINT32(m_messageLength, data, 16U); // Message Length + SET_UINT32(m_streamId, data, 8U); // Stream ID + SET_UINT32(m_peerId, data, 12U); // Peer ID + SET_UINT32(m_messageLength, data, 16U); // Message Length } diff --git a/src/common/network/RTPFNEHeader.h b/src/common/network/RTPFNEHeader.h index d615ac01..02d106fe 100644 --- a/src/common/network/RTPFNEHeader.h +++ b/src/common/network/RTPFNEHeader.h @@ -27,8 +27,6 @@ // Constants // --------------------------------------------------------------------------- -#define PEER_LINK_BLOCK_SIZE 534 - #define RTP_FNE_HEADER_LENGTH_BYTES 16 #define RTP_FNE_HEADER_LENGTH_EXT_LEN 4 @@ -48,7 +46,7 @@ namespace network enum ENUM : uint8_t { ILLEGAL = 0xFFU, //! Illegal Function - PROTOCOL = 0x00U, //! Network Protocol Function + PROTOCOL = 0x00U, //! Digital Protocol Function MASTER = 0x01U, //! Network Master Function @@ -56,8 +54,8 @@ namespace network RPTK = 0x61U, //! Repeater Authorisation RPTC = 0x62U, //! Repeater Configuration - RPT_CLOSING = 0x70U, //! Repeater Closing - MST_CLOSING = 0x71U, //! Master Closing + RPT_DISC = 0x70U, //! Repeater Disconnect + MST_DISC = 0x71U, //! Master Disconnect PING = 0x74U, //! Ping PONG = 0x75U, //! Pong @@ -184,27 +182,27 @@ namespace network /** * @brief Traffic payload packet CRC-16. */ - __PROPERTY(uint16_t, crc16, CRC); + DECLARE_PROPERTY(uint16_t, crc16, CRC); /** * @brief Function. */ - __PROPERTY(NET_FUNC::ENUM, func, Function); + DECLARE_PROPERTY(NET_FUNC::ENUM, func, Function); /** * @brief Sub-function. */ - __PROPERTY(NET_SUBFUNC::ENUM, subFunc, SubFunction); + DECLARE_PROPERTY(NET_SUBFUNC::ENUM, subFunc, SubFunction); /** * @brief Traffic Stream ID. */ - __PROPERTY(uint32_t, streamId, StreamId); + DECLARE_PROPERTY(uint32_t, streamId, StreamId); /** * @brief Traffic Peer ID. */ - __PROPERTY(uint32_t, peerId, PeerId); + DECLARE_PROPERTY(uint32_t, peerId, PeerId); /** * @brief Traffic Message Length. */ - __PROPERTY(uint32_t, messageLength, MessageLength); + DECLARE_PROPERTY(uint32_t, messageLength, MessageLength); }; } // namespace frame } // namespace network diff --git a/src/common/network/RTPHeader.cpp b/src/common/network/RTPHeader.cpp index d3d39247..9734d038 100644 --- a/src/common/network/RTPHeader.cpp +++ b/src/common/network/RTPHeader.cpp @@ -66,8 +66,8 @@ bool RTPHeader::decode(const uint8_t* data) m_payloadType = (data[1U] & 0x7FU); // Payload Type m_seq = (data[2U] << 8) | (data[3U] << 0); // Sequence - m_timestamp = __GET_UINT32(data, 4U); // Timestamp - m_ssrc = __GET_UINT32(data, 8U); // Synchronization Source ID + m_timestamp = GET_UINT32(data, 4U); // Timestamp + m_ssrc = GET_UINT32(data, 8U); // Synchronization Source ID return true; } @@ -93,8 +93,8 @@ void RTPHeader::encode(uint8_t* data) m_timestamp = uint32_t(microSeconds / 1000000); } - __SET_UINT32(m_timestamp, data, 4U); // Timestamp - __SET_UINT32(m_ssrc, data, 8U); // Synchronization Source Identifier + SET_UINT32(m_timestamp, data, 4U); // Timestamp + SET_UINT32(m_ssrc, data, 8U); // Synchronization Source Identifier } /* Helper to reset the start timestamp. */ diff --git a/src/common/network/RTPHeader.h b/src/common/network/RTPHeader.h index f03495a5..5b719888 100644 --- a/src/common/network/RTPHeader.h +++ b/src/common/network/RTPHeader.h @@ -85,39 +85,39 @@ namespace network /** * @brief RTP Protocol Version. */ - __READONLY_PROPERTY(uint8_t, version, Version); + DECLARE_RO_PROPERTY(uint8_t, version, Version); /** * @brief Flag indicating if the packet has trailing padding. */ - __READONLY_PROPERTY(bool, padding, Padding); + DECLARE_RO_PROPERTY(bool, padding, Padding); /** * @brief Flag indicating the presence of an extension header. */ - __PROPERTY(bool, extension, Extension); + DECLARE_PROPERTY(bool, extension, Extension); /** * @brief Count of contributing source IDs that follow the SSRC. */ - __READONLY_PROPERTY(uint8_t, cc, CSRCCount); + DECLARE_RO_PROPERTY(uint8_t, cc, CSRCCount); /** * @brief Flag indicating application-specific behavior. */ - __PROPERTY(bool, marker, Marker); + DECLARE_PROPERTY(bool, marker, Marker); /** * @brief Format of the payload contained within the packet. */ - __PROPERTY(uint8_t, payloadType, PayloadType); + DECLARE_PROPERTY(uint8_t, payloadType, PayloadType); /** * @brief Sequence number for the RTP packet. */ - __PROPERTY(uint16_t, seq, Sequence); + DECLARE_PROPERTY(uint16_t, seq, Sequence); /** * @brief RTP packet timestamp. */ - __PROPERTY(uint32_t, timestamp, Timestamp); + DECLARE_PROPERTY(uint32_t, timestamp, Timestamp); /** * @brief Synchronization Source ID. */ - __PROPERTY(uint32_t, ssrc, SSRC); + DECLARE_PROPERTY(uint32_t, ssrc, SSRC); private: static std::chrono::time_point m_wcStart; diff --git a/src/common/network/RawFrameQueue.cpp b/src/common/network/RawFrameQueue.cpp index cd250b73..fbd87459 100644 --- a/src/common/network/RawFrameQueue.cpp +++ b/src/common/network/RawFrameQueue.cpp @@ -106,6 +106,12 @@ bool RawFrameQueue::write(const uint8_t* message, uint32_t length, sockaddr_stor if (m_debug) Utils::dump(1U, "RawFrameQueue::write() Message", buffer, length); + // bryanb: this is really a developer warning not a end-user warning, there's nothing the end-users can do about + // this message + if (length > (DATA_PACKET_LENGTH - OVERSIZED_PACKET_WARN)) { + LogDebug(LOG_NET, "RawFrameQueue::write(), WARN: packet length is possibly oversized, possible data truncation - BUGBUG"); + } + bool ret = true; if (!m_socket->write(buffer, length, addr, addrLen, lenWritten)) { // LogError(LOG_NET, "Failed writing data to the network"); @@ -136,6 +142,12 @@ void RawFrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, sock Thread::sleep(2U); } + // bryanb: this is really a developer warning not a end-user warning, there's nothing the end-users can do about + // this message + if (length > (DATA_PACKET_LENGTH - OVERSIZED_PACKET_WARN)) { + LogDebug(LOG_NET, "RawFrameQueue::enqueueMessage(), WARN: packet length is possibly oversized, possible data truncation - BUGBUG"); + } + uint8_t* buffer = new uint8_t[length]; ::memset(buffer, 0x00U, length); ::memcpy(buffer, message, length); diff --git a/src/common/network/RawFrameQueue.h b/src/common/network/RawFrameQueue.h index 60a968e5..74e566bf 100644 --- a/src/common/network/RawFrameQueue.h +++ b/src/common/network/RawFrameQueue.h @@ -29,6 +29,7 @@ namespace network // --------------------------------------------------------------------------- const uint32_t DATA_PACKET_LENGTH = 8192U; + const uint32_t OVERSIZED_PACKET_WARN = 1536U; const uint8_t MAX_FAILED_READ_CNT_LOGGING = 5U; // --------------------------------------------------------------------------- diff --git a/src/common/network/udp/Socket.cpp b/src/common/network/udp/Socket.cpp index ec418998..0d55a210 100644 --- a/src/common/network/udp/Socket.cpp +++ b/src/common/network/udp/Socket.cpp @@ -239,7 +239,7 @@ ssize_t Socket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address } // does the network packet contain the appropriate magic leader? - uint16_t magic = __GET_UINT16B(buffer, 0U); + uint16_t magic = GET_UINT16(buffer, 0U); if (magic == AES_WRAPPED_PCKT_MAGIC) { uint32_t cryptedLen = (len - 2U) * sizeof(uint8_t); uint8_t* cryptoBuffer = buffer + 2U; @@ -347,7 +347,7 @@ bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storag delete[] cryptoBuffer; if (crypted != nullptr) { ::memcpy(out.get() + 2U, crypted, cryptedLen); - __SET_UINT16B(AES_WRAPPED_PCKT_MAGIC, out.get(), 0U); + SET_UINT16(AES_WRAPPED_PCKT_MAGIC, out.get(), 0U); delete[] crypted; length = cryptedLen + 2U; } else { @@ -494,10 +494,9 @@ bool Socket::write(BufferVector& buffers, ssize_t* lenWritten) noexcept // Utils::dump(1U, "Socket::write() crypted", crypted, cryptedLen); // finalize - UInt8Array __outBuf = std::make_unique(cryptedLen + 2U); - uint8_t* out = __outBuf.get(); + DECLARE_UINT8_ARRAY(out, cryptedLen + 2U); ::memcpy(out + 2U, crypted, cryptedLen); - __SET_UINT16B(AES_WRAPPED_PCKT_MAGIC, out, 0U); + SET_UINT16(AES_WRAPPED_PCKT_MAGIC, out, 0U); // cleanup buffers and replace with new delete[] crypted; diff --git a/src/common/network/viface/VIFace.h b/src/common/network/viface/VIFace.h index 8abd639b..ff304465 100644 --- a/src/common/network/viface/VIFace.h +++ b/src/common/network/viface/VIFace.h @@ -217,7 +217,7 @@ namespace network /** * @brief Virtual Interface associated name. */ - __PROPERTY(std::string, name, Name); + DECLARE_PROPERTY(std::string, name, Name); private: struct viface_queues m_queues; diff --git a/src/common/nxdn/SiteData.h b/src/common/nxdn/SiteData.h index b59be646..576845d9 100644 --- a/src/common/nxdn/SiteData.h +++ b/src/common/nxdn/SiteData.h @@ -173,39 +173,39 @@ namespace nxdn /** * @brief NXDN location ID. */ - __READONLY_PROPERTY_PLAIN(uint32_t, locId); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, locId); /** * @brief Channel ID. */ - __READONLY_PROPERTY_PLAIN(uint8_t, channelId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, channelId); /** * @brief Channel number. */ - __READONLY_PROPERTY_PLAIN(uint32_t, channelNo); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, channelNo); /** * @brief Site Information 1. */ - __READONLY_PROPERTY_PLAIN(uint8_t, siteInfo1); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, siteInfo1); /** * @brief Site Information 2. */ - __READONLY_PROPERTY_PLAIN(uint8_t, siteInfo2); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, siteInfo2); /** * @brief Flag indicating whether this site data is for an adjacent site. */ - __READONLY_PROPERTY_PLAIN(bool, isAdjSite); + DECLARE_RO_PROPERTY_PLAIN(bool, isAdjSite); /** * @brief Callsign. */ - __READONLY_PROPERTY_PLAIN(std::string, callsign); + DECLARE_RO_PROPERTY_PLAIN(std::string, callsign); /** * @brief NXDN require registration. */ - __READONLY_PROPERTY_PLAIN(bool, requireReg); + DECLARE_RO_PROPERTY_PLAIN(bool, requireReg); /** * @brief Flag indicating whether this site is a linked active network member. */ - __READONLY_PROPERTY_PLAIN(bool, netActive); + DECLARE_RO_PROPERTY_PLAIN(bool, netActive); /** @} */ }; } // namespace nxdn diff --git a/src/common/nxdn/channel/CAC.h b/src/common/nxdn/channel/CAC.h index 60e86db4..b5d299bf 100644 --- a/src/common/nxdn/channel/CAC.h +++ b/src/common/nxdn/channel/CAC.h @@ -82,29 +82,29 @@ namespace nxdn /** * @brief Radio Access Number */ - __PROPERTY(uint8_t, ran, RAN); + DECLARE_PROPERTY(uint8_t, ran, RAN); /** * @brief Channel Structure */ - __PROPERTY(defines::ChStructure::E, structure, Structure); + DECLARE_PROPERTY(defines::ChStructure::E, structure, Structure); /** * @brief Flag indicating whether the inbound CAC is long or short. */ - __PROPERTY(bool, longInbound, LongInbound); + DECLARE_PROPERTY(bool, longInbound, LongInbound); // Collision Control Field /** * @brief Idle/Busy. */ - __PROPERTY(bool, idleBusy, IdleBusy); + DECLARE_PROPERTY(bool, idleBusy, IdleBusy); /** * @brief Tx Continuously. */ - __PROPERTY(bool, txContinuous, TxContinuous); + DECLARE_PROPERTY(bool, txContinuous, TxContinuous); /** * @brief Receive/No Receive. */ - __PROPERTY(bool, receive, Receive); + DECLARE_PROPERTY(bool, receive, Receive); private: uint8_t* m_data; diff --git a/src/common/nxdn/channel/LICH.h b/src/common/nxdn/channel/LICH.h index b9384a55..3eedaf01 100644 --- a/src/common/nxdn/channel/LICH.h +++ b/src/common/nxdn/channel/LICH.h @@ -75,19 +75,19 @@ namespace nxdn /** * @brief RF Channel Type */ - __PROPERTY(defines::RFChannelType::E, rfct, RFCT); + DECLARE_PROPERTY(defines::RFChannelType::E, rfct, RFCT); /** * @brief Functional Channel Type */ - __PROPERTY(defines::FuncChannelType::E, fct, FCT); + DECLARE_PROPERTY(defines::FuncChannelType::E, fct, FCT); /** * @brief Channel Options */ - __PROPERTY(defines::ChOption::E, option, Option); + DECLARE_PROPERTY(defines::ChOption::E, option, Option); /** * @brief Flag indicating outbound traffic direction */ - __PROPERTY(bool, outbound, Outbound); + DECLARE_PROPERTY(bool, outbound, Outbound); private: uint8_t m_lich; diff --git a/src/common/nxdn/channel/SACCH.h b/src/common/nxdn/channel/SACCH.h index e0706716..fdf29408 100644 --- a/src/common/nxdn/channel/SACCH.h +++ b/src/common/nxdn/channel/SACCH.h @@ -82,11 +82,11 @@ namespace nxdn /** * @brief Radio Access Number */ - __PROPERTY(uint8_t, ran, RAN); + DECLARE_PROPERTY(uint8_t, ran, RAN); /** * @brief Channel Structure */ - __PROPERTY(defines::ChStructure::E, structure, Structure); + DECLARE_PROPERTY(defines::ChStructure::E, structure, Structure); private: uint8_t* m_data; diff --git a/src/common/nxdn/channel/UDCH.h b/src/common/nxdn/channel/UDCH.h index 837f917d..a5d93e2d 100644 --- a/src/common/nxdn/channel/UDCH.h +++ b/src/common/nxdn/channel/UDCH.h @@ -80,7 +80,7 @@ namespace nxdn /** * @brief Radio Access Number */ - __PROPERTY(uint8_t, ran, RAN); + DECLARE_PROPERTY(uint8_t, ran, RAN); private: uint8_t* m_data; diff --git a/src/common/nxdn/lc/PacketInformation.h b/src/common/nxdn/lc/PacketInformation.h index 1447243c..57e0187d 100644 --- a/src/common/nxdn/lc/PacketInformation.h +++ b/src/common/nxdn/lc/PacketInformation.h @@ -65,45 +65,45 @@ namespace nxdn /** * @brief Flag indicating if confirmed delivery is needed. */ - __PROPERTY(bool, delivery, Delivery); + DECLARE_PROPERTY(bool, delivery, Delivery); /** * @brief Flag indicating if the packet is a selective retry packet. */ - __PROPERTY(bool, selectiveRetry, SelectiveRetry); + DECLARE_PROPERTY(bool, selectiveRetry, SelectiveRetry); /** * @brief Count of data blocks in t he transmission packet. */ - __PROPERTY(uint8_t, blockCount, BlockCount); + DECLARE_PROPERTY(uint8_t, blockCount, BlockCount); /** * @brief Number of padding octets of the last block. */ - __PROPERTY(uint8_t, padCount, PadCount); + DECLARE_PROPERTY(uint8_t, padCount, PadCount); /** * @brief Flag indicating the first fragment. */ - __PROPERTY(bool, start, Start); + DECLARE_PROPERTY(bool, start, Start); /** * @brief Flag indicating if the Tx fragment count circulates. */ - __PROPERTY(bool, circular, Circular); + DECLARE_PROPERTY(bool, circular, Circular); /** * @brief The number and sequence of fragments. */ - __PROPERTY(uint16_t, fragmentCount, FragmentCount); + DECLARE_PROPERTY(uint16_t, fragmentCount, FragmentCount); // Response Data /** * @brief Response class. */ - __PROPERTY(uint8_t, rspClass, ResponseClass); + DECLARE_PROPERTY(uint8_t, rspClass, ResponseClass); /** * @brief Response type. */ - __PROPERTY(uint8_t, rspType, ResponseType); + DECLARE_PROPERTY(uint8_t, rspType, ResponseType); /** * @brief Error Block Flag. */ - __PROPERTY(uint16_t, rspErrorBlock, ResponseErrorBlock); + DECLARE_PROPERTY(uint16_t, rspErrorBlock, ResponseErrorBlock); }; } // namespace lc } // namespace nxdn diff --git a/src/common/nxdn/lc/RCCH.h b/src/common/nxdn/lc/RCCH.h index 7fff3a9f..c56cde62 100644 --- a/src/common/nxdn/lc/RCCH.h +++ b/src/common/nxdn/lc/RCCH.h @@ -104,82 +104,82 @@ namespace nxdn /** * @brief Message Type */ - __PROTECTED_PROPERTY(uint8_t, messageType, MessageType); + DECLARE_PROTECTED_PROPERTY(uint8_t, messageType, MessageType); /** * @brief Source ID. */ - __PROTECTED_PROPERTY(uint16_t, srcId, SrcId); + DECLARE_PROTECTED_PROPERTY(uint16_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROTECTED_PROPERTY(uint16_t, dstId, DstId); + DECLARE_PROTECTED_PROPERTY(uint16_t, dstId, DstId); /** * @brief Location ID. */ - __PROTECTED_PROPERTY(uint32_t, locId, LocId); + DECLARE_PROTECTED_PROPERTY(uint32_t, locId, LocId); /** * @brief Registration Option. */ - __PROTECTED_PROPERTY(uint8_t, regOption, RegOption); + DECLARE_PROTECTED_PROPERTY(uint8_t, regOption, RegOption); /** * @brief Version Number. */ - __PROTECTED_PROPERTY(uint8_t, version, Version); + DECLARE_PROTECTED_PROPERTY(uint8_t, version, Version); /** * @brief Cause Response. */ - __PROTECTED_PROPERTY(uint8_t, causeRsp, CauseResponse); + DECLARE_PROTECTED_PROPERTY(uint8_t, causeRsp, CauseResponse); /** * @brief Voice channel number. */ - __PROTECTED_PROPERTY(uint32_t, grpVchNo, GrpVchNo); + DECLARE_PROTECTED_PROPERTY(uint32_t, grpVchNo, GrpVchNo); /** @} */ /** @name Call Data */ /** * @brief Call Type */ - __PROTECTED_PROPERTY(uint8_t, callType, CallType); + DECLARE_PROTECTED_PROPERTY(uint8_t, callType, CallType); /** @} */ /** @name Common Call Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROTECTED_PROPERTY(bool, emergency, Emergency); + DECLARE_PROTECTED_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that encryption is enabled. */ - __PROTECTED_PROPERTY(bool, encrypted, Encrypted); + DECLARE_PROTECTED_PROPERTY(bool, encrypted, Encrypted); /** * @brief Flag indicating priority paging. */ - __PROTECTED_PROPERTY(bool, priority, Priority); + DECLARE_PROTECTED_PROPERTY(bool, priority, Priority); /** * @brief Flag indicating a group/talkgroup operation. */ - __PROTECTED_PROPERTY(bool, group, Group); + DECLARE_PROTECTED_PROPERTY(bool, group, Group); /** * @brief Flag indicating a half/full duplex operation. */ - __PROTECTED_PROPERTY(bool, duplex, Duplex); + DECLARE_PROTECTED_PROPERTY(bool, duplex, Duplex); /** * @brief Transmission mode. */ - __PROTECTED_PROPERTY(uint8_t, transmissionMode, TransmissionMode); + DECLARE_PROTECTED_PROPERTY(uint8_t, transmissionMode, TransmissionMode); /** @} */ /** @name Local Site data */ /** * @brief Local Site Identity Entry. */ - __PROTECTED_PROPERTY_PLAIN(lookups::IdenTable, siteIdenEntry); + DECLARE_PROTECTED_PROPERTY_PLAIN(lookups::IdenTable, siteIdenEntry); /** @} */ protected: @@ -206,7 +206,7 @@ namespace nxdn */ void encode(uint8_t* data, const uint8_t* rcch, uint32_t length, uint32_t offset = 0U); - __PROTECTED_COPY(RCCH); + DECLARE_PROTECTED_COPY(RCCH); }; } // namespace lc } // namespace nxdn diff --git a/src/common/nxdn/lc/RTCH.h b/src/common/nxdn/lc/RTCH.h index fe1da7f2..abfd87c1 100644 --- a/src/common/nxdn/lc/RTCH.h +++ b/src/common/nxdn/lc/RTCH.h @@ -89,92 +89,92 @@ namespace nxdn /** * @brief Message Type */ - __PROPERTY(uint8_t, messageType, MessageType); + DECLARE_PROPERTY(uint8_t, messageType, MessageType); /** * @brief Call Type */ - __PROPERTY(uint8_t, callType, CallType); + DECLARE_PROPERTY(uint8_t, callType, CallType); /** * @brief Source ID. */ - __PROPERTY(uint16_t, srcId, SrcId); + DECLARE_PROPERTY(uint16_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROPERTY(uint16_t, dstId, DstId); + DECLARE_PROPERTY(uint16_t, dstId, DstId); /** @} */ /** @name Common Call Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROPERTY(bool, emergency, Emergency); + DECLARE_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that encryption is enabled. */ - __PROPERTY(bool, encrypted, Encrypted); + DECLARE_PROPERTY(bool, encrypted, Encrypted); /** * @brief Flag indicating priority paging. */ - __PROPERTY(bool, priority, Priority); + DECLARE_PROPERTY(bool, priority, Priority); /** * @brief Flag indicating a group/talkgroup operation. */ - __PROPERTY(bool, group, Group); + DECLARE_PROPERTY(bool, group, Group); /** * @brief Flag indicating a half/full duplex operation. */ - __PROPERTY(bool, duplex, Duplex); + DECLARE_PROPERTY(bool, duplex, Duplex); /** * @brief Transmission mode. */ - __PROPERTY(uint8_t, transmissionMode, TransmissionMode); + DECLARE_PROPERTY(uint8_t, transmissionMode, TransmissionMode); /** @} */ /** @name Data Call Data */ /** * @brief Data packet information. */ - __PROPERTY(PacketInformation, packetInfo, PacketInfo); + DECLARE_PROPERTY(PacketInformation, packetInfo, PacketInfo); /** * @brief Data packet information. */ - __PROPERTY(PacketInformation, rsp, Response); + DECLARE_PROPERTY(PacketInformation, rsp, Response); /** * @brief Data packet frame number. */ - __PROPERTY(uint8_t, dataFrameNumber, DataFrameNumber); + DECLARE_PROPERTY(uint8_t, dataFrameNumber, DataFrameNumber); /** * @brief Data packet block number. */ - __PROPERTY(uint8_t, dataBlockNumber, DataBlockNumber); + DECLARE_PROPERTY(uint8_t, dataBlockNumber, DataBlockNumber); /** @} */ /** @name Header Delay Data */ /** * @brief Delay count. */ - __PROPERTY(uint16_t, delayCount, DelayCount); + DECLARE_PROPERTY(uint16_t, delayCount, DelayCount); /** @} */ /** @name Encryption data */ /** * @brief Encryption algorithm ID. */ - __PROPERTY(uint8_t, algId, AlgId); + DECLARE_PROPERTY(uint8_t, algId, AlgId); /** * @brief Encryption key ID. */ - __PROPERTY(uint8_t, kId, KId); + DECLARE_PROPERTY(uint8_t, kId, KId); /** @} */ /** * @brief Cause Response. */ - __PROPERTY(uint8_t, causeRsp, CauseResponse); + DECLARE_PROPERTY(uint8_t, causeRsp, CauseResponse); private: static bool m_verbose; diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG.cpp index b9a2679d..b6f496ed 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG.cpp @@ -57,7 +57,7 @@ void MESSAGE_TYPE_REG::encode(uint8_t* data, uint32_t length, uint32_t offset) ::memset(rcch, 0x00U, NXDN_RCCH_LC_LENGTH_BYTES + 4U); rcch[1U] = (m_regOption << 3) + // Registration Option - (m_siteData.locId() >> 22U) & 0x03U; // Location ID + ((m_siteData.locId() >> 22U) & 0x03U); // Location ID uint16_t systemCode = (m_siteData.locId() >> 12U) << 7U; rcch[2U] = (systemCode >> 8U) & 0x03U; // ... diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.h b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.h index 97be7bc8..a374db2b 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.h +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.h @@ -66,25 +66,25 @@ namespace nxdn /** * @brief Count of BCCH frames per RCCH superframe. */ - __PROPERTY(uint8_t, bcchCnt, BcchCnt); + DECLARE_PROPERTY(uint8_t, bcchCnt, BcchCnt); /** * @brief Count of RCCH frame groupings per RCCH superframe. */ - __PROPERTY(uint8_t, rcchGroupingCnt, RcchGroupingCnt); + DECLARE_PROPERTY(uint8_t, rcchGroupingCnt, RcchGroupingCnt); /** * @brief Count of CCCH/UPCH paging frames per RCCH superframe. */ - __PROPERTY(uint8_t, ccchPagingCnt, CcchPagingCnt); + DECLARE_PROPERTY(uint8_t, ccchPagingCnt, CcchPagingCnt); /** * @brief Count of CCCH/UPCH multi-purpose frames per RCCH superframe. */ - __PROPERTY(uint8_t, ccchMultiCnt, CcchMultiCnt); + DECLARE_PROPERTY(uint8_t, ccchMultiCnt, CcchMultiCnt); /** * @brief Count of group iterations per RCCH superframe. */ - __PROPERTY(uint8_t, rcchIterateCnt, RcchIterateCount); + DECLARE_PROPERTY(uint8_t, rcchIterateCnt, RcchIterateCount); - __COPY(MESSAGE_TYPE_SITE_INFO); + DECLARE_COPY(MESSAGE_TYPE_SITE_INFO); }; } // namespace rcch } // namespace lc diff --git a/src/common/p25/Crypto.h b/src/common/p25/Crypto.h index 630b4695..7ced74ae 100644 --- a/src/common/p25/Crypto.h +++ b/src/common/p25/Crypto.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: GPL-2.0-only /* * Digital Voice Modem - Common Library * MIT Open Source. Use is subject to license terms. @@ -126,16 +126,16 @@ namespace p25 /** * @brief Traffic Encryption Key Algorithm ID. */ - __PROPERTY(uint8_t, tekAlgoId, TEKAlgoId); + DECLARE_PROPERTY(uint8_t, tekAlgoId, TEKAlgoId); /** * @brief Traffic Encryption Key ID. */ - __PROPERTY(uint16_t, tekKeyId, TEKKeyId); + DECLARE_PROPERTY(uint16_t, tekKeyId, TEKKeyId); /** * @brief Traffic Encryption Key Length. */ - __READONLY_PROPERTY(uint8_t, tekLength, TEKLength); + DECLARE_RO_PROPERTY(uint8_t, tekLength, TEKLength); private: uint8_t* m_keystream; diff --git a/src/common/p25/NID.h b/src/common/p25/NID.h index d067f69d..78fc68b4 100644 --- a/src/common/p25/NID.h +++ b/src/common/p25/NID.h @@ -65,7 +65,7 @@ namespace p25 /** * @brief Data unit ID. */ - __READONLY_PROPERTY(defines::DUID::E, duid, DUID); + DECLARE_RO_PROPERTY(defines::DUID::E, duid, DUID); private: uint32_t m_nac; diff --git a/src/common/p25/SiteData.h b/src/common/p25/SiteData.h index 899cb861..f8162dcd 100644 --- a/src/common/p25/SiteData.h +++ b/src/common/p25/SiteData.h @@ -260,55 +260,55 @@ namespace p25 /** * @brief P25 location resource area. */ - __READONLY_PROPERTY_PLAIN(uint8_t, lra); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, lra); /** * @brief P25 network ID. */ - __READONLY_PROPERTY_PLAIN(uint32_t, netId); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, netId); /** * @brief Gets the P25 system ID. */ - __READONLY_PROPERTY_PLAIN(uint32_t, sysId); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, sysId); /** * @brief P25 RFSS ID. */ - __READONLY_PROPERTY_PLAIN(uint8_t, rfssId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, rfssId); /** * @brief P25 site ID. */ - __READONLY_PROPERTY_PLAIN(uint8_t, siteId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, siteId); /** * @brief Channel ID. */ - __READONLY_PROPERTY_PLAIN(uint8_t, channelId); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, channelId); /** * @brief Channel number. */ - __READONLY_PROPERTY_PLAIN(uint32_t, channelNo); + DECLARE_RO_PROPERTY_PLAIN(uint32_t, channelNo); /** * @brief Service class. */ - __READONLY_PROPERTY_PLAIN(uint8_t, serviceClass); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, serviceClass); /** * @brief Flag indicating whether this site data is for an adjacent site. */ - __READONLY_PROPERTY_PLAIN(bool, isAdjSite); + DECLARE_RO_PROPERTY_PLAIN(bool, isAdjSite); /** * @brief Callsign. */ - __READONLY_PROPERTY_PLAIN(std::string, callsign); + DECLARE_RO_PROPERTY_PLAIN(std::string, callsign); /** * @brief Count of available channels. */ - __READONLY_PROPERTY_PLAIN(uint8_t, chCnt); + DECLARE_RO_PROPERTY_PLAIN(uint8_t, chCnt); /** * @brief Flag indicating whether this site is a linked active network member. */ - __READONLY_PROPERTY_PLAIN(bool, netActive); + DECLARE_RO_PROPERTY_PLAIN(bool, netActive); /** * @brief Local Time Offset. */ - __READONLY_PROPERTY_PLAIN(int8_t, lto); + DECLARE_RO_PROPERTY_PLAIN(int8_t, lto); /** @} */ }; } // namespace p25 diff --git a/src/common/p25/data/DataBlock.h b/src/common/p25/data/DataBlock.h index 19f6fa1c..303e8b0b 100644 --- a/src/common/p25/data/DataBlock.h +++ b/src/common/p25/data/DataBlock.h @@ -90,12 +90,12 @@ namespace p25 /** * @brief Sets the data block serial number. */ - __PROPERTY(uint8_t, serialNo, SerialNo); + DECLARE_PROPERTY(uint8_t, serialNo, SerialNo); /** * @brief Flag indicating this is the last block in a sequence of block. */ - __PROPERTY(bool, lastBlock, LastBlock); + DECLARE_PROPERTY(bool, lastBlock, LastBlock); private: edac::Trellis m_trellis; diff --git a/src/common/p25/data/DataHeader.h b/src/common/p25/data/DataHeader.h index 4d2117f6..97164d6b 100644 --- a/src/common/p25/data/DataHeader.h +++ b/src/common/p25/data/DataHeader.h @@ -129,97 +129,97 @@ namespace p25 /** * @brief Flag indicating if acknowledgement is needed. */ - __PROPERTY(bool, ackNeeded, AckNeeded); + DECLARE_PROPERTY(bool, ackNeeded, AckNeeded); /** * @brief Flag indicating if this is an outbound data packet. */ - __PROPERTY(bool, outbound, Outbound); + DECLARE_PROPERTY(bool, outbound, Outbound); /** * @brief Data packet format. */ - __PROPERTY(uint8_t, fmt, Format); + DECLARE_PROPERTY(uint8_t, fmt, Format); /** * @brief Service access point. */ - __PROPERTY(uint8_t, sap, SAP); + DECLARE_PROPERTY(uint8_t, sap, SAP); /** * @brief Manufacturer ID. */ - __PROPERTY(uint8_t, mfId, MFId); + DECLARE_PROPERTY(uint8_t, mfId, MFId); /** * @brief Logical link ID. */ - __PROPERTY(uint32_t, llId, LLId); + DECLARE_PROPERTY(uint32_t, llId, LLId); /** * @brief Total number of blocks following this header. */ - __PROPERTY(uint8_t, blocksToFollow, BlocksToFollow); + DECLARE_PROPERTY(uint8_t, blocksToFollow, BlocksToFollow); /** * @brief Total number of padding bytes. */ - __PROPERTY(uint8_t, padLength, PadLength); + DECLARE_PROPERTY(uint8_t, padLength, PadLength); /** * @brief Flag indicating whether or not this data packet is a full message. */ - __PROPERTY(bool, F, FullMessage); + DECLARE_PROPERTY(bool, F, FullMessage); /** * @brief Synchronize Flag. */ - __PROPERTY(bool, S, Synchronize); + DECLARE_PROPERTY(bool, S, Synchronize); /** * @brief Fragment Sequence Number. */ - __PROPERTY(uint8_t, fsn, FSN); + DECLARE_PROPERTY(uint8_t, fsn, FSN); /** * @brief Send Sequence Number. */ - __PROPERTY(uint8_t, Ns, Ns); + DECLARE_PROPERTY(uint8_t, Ns, Ns); /** * @brief Flag indicating whether or not this is the last fragment in a message. */ - __PROPERTY(bool, lastFragment, LastFragment); + DECLARE_PROPERTY(bool, lastFragment, LastFragment); /** * @brief Offset of the header. */ - __PROPERTY(uint8_t, headerOffset, HeaderOffset); + DECLARE_PROPERTY(uint8_t, headerOffset, HeaderOffset); // Extended Addressing Data /** * @brief Service access point. */ - __PROPERTY(uint8_t, exSap, EXSAP); + DECLARE_PROPERTY(uint8_t, exSap, EXSAP); /** * @brief Source Logical link ID. */ - __PROPERTY(uint32_t, srcLlId, SrcLLId); + DECLARE_PROPERTY(uint32_t, srcLlId, SrcLLId); // Response Data /** * @brief Response class. */ - __PROPERTY(uint8_t, rspClass, ResponseClass); + DECLARE_PROPERTY(uint8_t, rspClass, ResponseClass); /** * @brief Response type. */ - __PROPERTY(uint8_t, rspType, ResponseType); + DECLARE_PROPERTY(uint8_t, rspType, ResponseType); /** * @brief Response status. */ - __PROPERTY(uint8_t, rspStatus, ResponseStatus); + DECLARE_PROPERTY(uint8_t, rspStatus, ResponseStatus); // AMBT Data /** * @brief Alternate Trunking Block Opcode */ - __PROPERTY(uint8_t, ambtOpcode, AMBTOpcode); + DECLARE_PROPERTY(uint8_t, ambtOpcode, AMBTOpcode); /** * @brief Alternate Trunking Block Field 8 */ - __PROPERTY(uint8_t, ambtField8, AMBTField8); + DECLARE_PROPERTY(uint8_t, ambtField8, AMBTField8); /** * @brief Alternate Trunking Block Field 9 */ - __PROPERTY(uint8_t, ambtField9, AMBTField9); + DECLARE_PROPERTY(uint8_t, ambtField9, AMBTField9); private: edac::Trellis m_trellis; diff --git a/src/common/p25/data/LowSpeedData.cpp b/src/common/p25/data/LowSpeedData.cpp index 2ccab554..83891b49 100644 --- a/src/common/p25/data/LowSpeedData.cpp +++ b/src/common/p25/data/LowSpeedData.cpp @@ -11,6 +11,7 @@ #include "Defines.h" #include "p25/data/LowSpeedData.h" #include "p25/P25Utils.h" +#include "Utils.h" using namespace p25; using namespace p25::data; @@ -105,6 +106,8 @@ void LowSpeedData::process(uint8_t* data) } } + // Utils::dump(1U, "P25 Low Speed Data", lsd, 4U); + m_lsd1 = lsd[0U]; m_lsd2 = lsd[2U]; diff --git a/src/common/p25/data/LowSpeedData.h b/src/common/p25/data/LowSpeedData.h index e35a62c5..03382913 100644 --- a/src/common/p25/data/LowSpeedData.h +++ b/src/common/p25/data/LowSpeedData.h @@ -63,11 +63,11 @@ namespace p25 /** * @brief Low speed data 1 value. */ - __PROPERTY(uint8_t, lsd1, LSD1); + DECLARE_PROPERTY(uint8_t, lsd1, LSD1); /** * @brief Low speed data 2 value. */ - __PROPERTY(uint8_t, lsd2, LSD2); + DECLARE_PROPERTY(uint8_t, lsd2, LSD2); private: /** diff --git a/src/common/p25/dfsi/LC.cpp b/src/common/p25/dfsi/LC.cpp index 70d5b15e..bfd9cfe2 100644 --- a/src/common/p25/dfsi/LC.cpp +++ b/src/common/p25/dfsi/LC.cpp @@ -326,8 +326,7 @@ void LC::encodeLDU1(uint8_t* data, const uint8_t* imbe) // encode RS (24,12,13) FEC m_rs.encode241213(rs); - UInt8Array __dfsiFrame = std::make_unique(frameLength); - uint8_t* dfsiFrame = __dfsiFrame.get(); + DECLARE_UINT8_ARRAY(dfsiFrame, frameLength); dfsiFrame[0U] = m_frameType; // Frame Type @@ -567,8 +566,7 @@ void LC::encodeLDU2(uint8_t* data, const uint8_t* imbe) // encode RS (24,16,9) FEC m_rs.encode24169(rs); - UInt8Array __dfsiFrame = std::make_unique(frameLength); - uint8_t* dfsiFrame = __dfsiFrame.get(); + DECLARE_UINT8_ARRAY(dfsiFrame, frameLength); dfsiFrame[0U] = m_frameType; // Frame Type diff --git a/src/common/p25/dfsi/LC.h b/src/common/p25/dfsi/LC.h index 858ea245..7af0492b 100644 --- a/src/common/p25/dfsi/LC.h +++ b/src/common/p25/dfsi/LC.h @@ -103,21 +103,21 @@ namespace p25 /** * @brief Frame Type. */ - __PROPERTY(defines::DFSIFrameType::E, frameType, FrameType); + DECLARE_PROPERTY(defines::DFSIFrameType::E, frameType, FrameType); /** * @brief RSSI. */ - __PROPERTY(uint8_t, rssi, RSSI); + DECLARE_PROPERTY(uint8_t, rssi, RSSI); /** * @brief Link control data. */ - __READONLY_PROPERTY_PLAIN(p25::lc::LC*, control); + DECLARE_RO_PROPERTY_PLAIN(p25::lc::LC*, control); /** * @brief Low speed data. */ - __READONLY_PROPERTY_PLAIN(p25::data::LowSpeedData*, lsd); + DECLARE_RO_PROPERTY_PLAIN(p25::data::LowSpeedData*, lsd); private: edac::RS634717 m_rs; diff --git a/src/common/p25/dfsi/frames/BlockHeader.h b/src/common/p25/dfsi/frames/BlockHeader.h index 9d47a6e7..69c5005d 100644 --- a/src/common/p25/dfsi/frames/BlockHeader.h +++ b/src/common/p25/dfsi/frames/BlockHeader.h @@ -85,19 +85,19 @@ namespace p25 * @brief Payload type. * This simple boolean marks this header as either IANA standard, or profile specific. */ - __PROPERTY(bool, payloadType, PayloadType); + DECLARE_PROPERTY(bool, payloadType, PayloadType); /** * @brief Block type. */ - __PROPERTY(BlockType::E, blockType, BlockType); + DECLARE_PROPERTY(BlockType::E, blockType, BlockType); /** * @brief Timestamp Offset. */ - __PROPERTY(uint16_t, timestampOffset, TimestampOffset); + DECLARE_PROPERTY(uint16_t, timestampOffset, TimestampOffset); /** * @brief Block length. */ - __PROPERTY(uint16_t, blockLength, BlockLength); + DECLARE_PROPERTY(uint16_t, blockLength, BlockLength); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/ControlOctet.h b/src/common/p25/dfsi/frames/ControlOctet.h index 3395408b..f8419270 100644 --- a/src/common/p25/dfsi/frames/ControlOctet.h +++ b/src/common/p25/dfsi/frames/ControlOctet.h @@ -72,15 +72,15 @@ namespace p25 /** * @brief */ - __PROPERTY(bool, signal, Signal); + DECLARE_PROPERTY(bool, signal, Signal); /** * @brief Indicates a compact (1) or verbose (0) block header. */ - __PROPERTY(bool, compact, Compact); + DECLARE_PROPERTY(bool, compact, Compact); /** * @brief Number of block headers following this control octet. */ - __PROPERTY(uint8_t, blockHeaderCnt, BlockHeaderCnt); + DECLARE_PROPERTY(uint8_t, blockHeaderCnt, BlockHeaderCnt); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/FullRateVoice.h b/src/common/p25/dfsi/frames/FullRateVoice.h index 100fa7b9..ac34cd0d 100644 --- a/src/common/p25/dfsi/frames/FullRateVoice.h +++ b/src/common/p25/dfsi/frames/FullRateVoice.h @@ -231,27 +231,27 @@ namespace p25 /** * @brief Frame Type. */ - __PROPERTY(defines::DFSIFrameType::E, frameType, FrameType); + DECLARE_PROPERTY(defines::DFSIFrameType::E, frameType, FrameType); /** * @brief Total errors detected in the frame. */ - __PROPERTY(uint8_t, totalErrors, TotalErrors); + DECLARE_PROPERTY(uint8_t, totalErrors, TotalErrors); /** * @brief Flag indicating the frame should be muted. */ - __PROPERTY(bool, muteFrame, MuteFrame); + DECLARE_PROPERTY(bool, muteFrame, MuteFrame); /** * @brief Flag indicating the frame was lost. */ - __PROPERTY(bool, lostFrame, LostFrame); + DECLARE_PROPERTY(bool, lostFrame, LostFrame); /** * @brief Superframe Counter. */ - __PROPERTY(uint8_t, superframeCnt, SuperframeCnt); + DECLARE_PROPERTY(uint8_t, superframeCnt, SuperframeCnt); /** * @brief Busy Status. */ - __PROPERTY(uint8_t, busy, Busy); + DECLARE_PROPERTY(uint8_t, busy, Busy); private: /** diff --git a/src/common/p25/dfsi/frames/MotFullRateVoice.h b/src/common/p25/dfsi/frames/MotFullRateVoice.h index 111a0bbd..51da7152 100644 --- a/src/common/p25/dfsi/frames/MotFullRateVoice.h +++ b/src/common/p25/dfsi/frames/MotFullRateVoice.h @@ -97,11 +97,11 @@ namespace p25 /** * @brief Frame Type. */ - __PROPERTY(defines::DFSIFrameType::E, frameType, FrameType); + DECLARE_PROPERTY(defines::DFSIFrameType::E, frameType, FrameType); /** * @brief V.24 Data Source. */ - __PROPERTY(SourceFlag::E, source, Source); + DECLARE_PROPERTY(SourceFlag::E, source, Source); private: /** diff --git a/src/common/p25/dfsi/frames/MotStartOfStream.h b/src/common/p25/dfsi/frames/MotStartOfStream.h index 4afcab92..14f4897b 100644 --- a/src/common/p25/dfsi/frames/MotStartOfStream.h +++ b/src/common/p25/dfsi/frames/MotStartOfStream.h @@ -78,19 +78,19 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, marker, Marker); + DECLARE_PROPERTY(uint8_t, marker, Marker); /** * @brief RT/RT Flag. */ - __PROPERTY(RTFlag::E, rt, RT); + DECLARE_PROPERTY(RTFlag::E, rt, RT); /** * @brief Start/Stop. */ - __PROPERTY(StartStopFlag::E, startStop, StartStop); + DECLARE_PROPERTY(StartStopFlag::E, startStop, StartStop); /** * @brief Stream Type. */ - __PROPERTY(StreamTypeFlag::E, streamType, StreamType); + DECLARE_PROPERTY(StreamTypeFlag::E, streamType, StreamType); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/MotStartVoiceFrame.h b/src/common/p25/dfsi/frames/MotStartVoiceFrame.h index acaede19..0f287724 100644 --- a/src/common/p25/dfsi/frames/MotStartVoiceFrame.h +++ b/src/common/p25/dfsi/frames/MotStartVoiceFrame.h @@ -92,23 +92,23 @@ namespace p25 /** * @brief */ - __PROPERTY(ICWFlag::E, icw, ICW); + DECLARE_PROPERTY(ICWFlag::E, icw, ICW); /** * @brief RSSI Value. */ - __PROPERTY(uint8_t, rssi, RSSI); + DECLARE_PROPERTY(uint8_t, rssi, RSSI); /** * @brief Flag indicating whether or not the RSSI field is valid. */ - __PROPERTY(RssiValidityFlag::E, rssiValidity, RSSIValidity); + DECLARE_PROPERTY(RssiValidityFlag::E, rssiValidity, RSSIValidity); /** * @brief */ - __PROPERTY(uint8_t, nRssi, NRSSI); + DECLARE_PROPERTY(uint8_t, nRssi, NRSSI); /** * @brief */ - __PROPERTY(uint8_t, adjMM, AdjMM); + DECLARE_PROPERTY(uint8_t, adjMM, AdjMM); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/MotVoiceHeader1.h b/src/common/p25/dfsi/frames/MotVoiceHeader1.h index 049572bd..05951a0a 100644 --- a/src/common/p25/dfsi/frames/MotVoiceHeader1.h +++ b/src/common/p25/dfsi/frames/MotVoiceHeader1.h @@ -96,19 +96,19 @@ namespace p25 /** * @brief */ - __PROPERTY(ICWFlag::E, icw, ICW); + DECLARE_PROPERTY(ICWFlag::E, icw, ICW); /** * @brief RSSI Value. */ - __PROPERTY(uint8_t, rssi, RSSI); + DECLARE_PROPERTY(uint8_t, rssi, RSSI); /** * @brief Flag indicating whether or not the RSSI field is valid. */ - __PROPERTY(RssiValidityFlag::E, rssiValidity, RSSIValidity); + DECLARE_PROPERTY(RssiValidityFlag::E, rssiValidity, RSSIValidity); /** * @brief */ - __PROPERTY(uint8_t, nRssi, NRSSI); + DECLARE_PROPERTY(uint8_t, nRssi, NRSSI); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/MotVoiceHeader2.h b/src/common/p25/dfsi/frames/MotVoiceHeader2.h index 07af5245..a1918a77 100644 --- a/src/common/p25/dfsi/frames/MotVoiceHeader2.h +++ b/src/common/p25/dfsi/frames/MotVoiceHeader2.h @@ -91,7 +91,7 @@ namespace p25 /** * @brief V.24 Data Source. */ - __PROPERTY(SourceFlag::E, source, Source); + DECLARE_PROPERTY(SourceFlag::E, source, Source); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/StartOfStream.cpp b/src/common/p25/dfsi/frames/StartOfStream.cpp index ce4e28ff..f477e494 100644 --- a/src/common/p25/dfsi/frames/StartOfStream.cpp +++ b/src/common/p25/dfsi/frames/StartOfStream.cpp @@ -47,7 +47,7 @@ bool StartOfStream::decode(const uint8_t* data) { assert(data != nullptr); - m_nid = __GET_UINT16B(data, 0U); // Network Identifier + m_nid = GET_UINT16(data, 0U); // Network Identifier m_errorCount = (data[2U] & 0x0FU); // Error Count return true; @@ -59,6 +59,6 @@ void StartOfStream::encode(uint8_t* data) { assert(data != nullptr); - __SET_UINT16B(m_nid, data, 0U); // Network Identifier + SET_UINT16(m_nid, data, 0U); // Network Identifier data[2U] = m_errorCount & 0x0FU; // Error Count } diff --git a/src/common/p25/dfsi/frames/StartOfStream.h b/src/common/p25/dfsi/frames/StartOfStream.h index 06972926..42680375 100644 --- a/src/common/p25/dfsi/frames/StartOfStream.h +++ b/src/common/p25/dfsi/frames/StartOfStream.h @@ -72,11 +72,11 @@ namespace p25 /** * @brief Network Identifier. */ - __PROPERTY(uint16_t, nid, NID); + DECLARE_PROPERTY(uint16_t, nid, NID); /** * @brief Error count. */ - __PROPERTY(uint8_t, errorCount, ErrorCount); + DECLARE_PROPERTY(uint8_t, errorCount, ErrorCount); }; } // namespace frames } // namespace dfsi diff --git a/src/common/p25/dfsi/frames/fsc/FSCACK.h b/src/common/p25/dfsi/frames/fsc/FSCACK.h index 2c378a82..26aeab92 100644 --- a/src/common/p25/dfsi/frames/fsc/FSCACK.h +++ b/src/common/p25/dfsi/frames/fsc/FSCACK.h @@ -65,23 +65,23 @@ namespace p25 /** * @brief Acknowledged Message ID. */ - __PROPERTY(FSCMessageType::E, ackMessageId, AckMessageId); + DECLARE_PROPERTY(FSCMessageType::E, ackMessageId, AckMessageId); /** * @brief Acknowledged Message Version. */ - __READONLY_PROPERTY(uint8_t, ackVersion, AckVersion); + DECLARE_RO_PROPERTY(uint8_t, ackVersion, AckVersion); /** * @brief */ - __PROPERTY(uint8_t, ackCorrelationTag, AckCorrelationTag); + DECLARE_PROPERTY(uint8_t, ackCorrelationTag, AckCorrelationTag); /** * @brief Response code. */ - __PROPERTY(FSCAckResponseCode::E, responseCode, ResponseCode); + DECLARE_PROPERTY(FSCAckResponseCode::E, responseCode, ResponseCode); /** * @brief Response Data Length. */ - __PROPERTY(uint8_t, respLength, ResponseLength); + DECLARE_PROPERTY(uint8_t, respLength, ResponseLength); }; } // namespace fsc } // namespace frames diff --git a/src/common/p25/dfsi/frames/fsc/FSCConnect.cpp b/src/common/p25/dfsi/frames/fsc/FSCConnect.cpp index ed0f7149..3601792b 100644 --- a/src/common/p25/dfsi/frames/fsc/FSCConnect.cpp +++ b/src/common/p25/dfsi/frames/fsc/FSCConnect.cpp @@ -41,8 +41,8 @@ bool FSCConnect::decode(const uint8_t* data) assert(data != nullptr); FSCMessage::decode(data); - m_vcBasePort = __GET_UINT16B(data, 3U); // Voice Conveyance RTP Port - m_vcSSRC = __GET_UINT32(data, 5U); // Voice Conveyance SSRC + m_vcBasePort = GET_UINT16(data, 3U); // Voice Conveyance RTP Port + m_vcSSRC = GET_UINT32(data, 5U); // Voice Conveyance SSRC m_fsHeartbeatPeriod = data[9U]; // Fixed Station Heartbeat Period m_hostHeartbeatPeriod = data[10U]; // Host Heartbeat Period @@ -56,8 +56,8 @@ void FSCConnect::encode(uint8_t* data) assert(data != nullptr); FSCMessage::encode(data); - __SET_UINT16B(m_vcBasePort, data, 3U); // Voice Conveyance RTP Port - __SET_UINT32(m_vcSSRC, data, 5U); // Voice Conveyance SSRC + SET_UINT16(m_vcBasePort, data, 3U); // Voice Conveyance RTP Port + SET_UINT32(m_vcSSRC, data, 5U); // Voice Conveyance SSRC data[9U] = m_fsHeartbeatPeriod; // Fixed Station Heartbeat Period data[10U] = m_hostHeartbeatPeriod; // Host Heartbeat Period } diff --git a/src/common/p25/dfsi/frames/fsc/FSCConnect.h b/src/common/p25/dfsi/frames/fsc/FSCConnect.h index f199ba05..5f337f82 100644 --- a/src/common/p25/dfsi/frames/fsc/FSCConnect.h +++ b/src/common/p25/dfsi/frames/fsc/FSCConnect.h @@ -63,19 +63,19 @@ namespace p25 /** * @brief Voice Conveyance RTP Port. */ - __PROPERTY(uint16_t, vcBasePort, VCBasePort); + DECLARE_PROPERTY(uint16_t, vcBasePort, VCBasePort); /** * @brief SSRC Identifier for all RTP transmissions. */ - __PROPERTY(uint32_t, vcSSRC, VCSSRC); + DECLARE_PROPERTY(uint32_t, vcSSRC, VCSSRC); /** * @brief Fixed Station Heartbeat Period. */ - __PROPERTY(uint8_t, fsHeartbeatPeriod, FSHeartbeatPeriod); + DECLARE_PROPERTY(uint8_t, fsHeartbeatPeriod, FSHeartbeatPeriod); /** * @brief Host Heartbeat Period. */ - __PROPERTY(uint8_t, hostHeartbeatPeriod, HostHeartbeatPeriod); + DECLARE_PROPERTY(uint8_t, hostHeartbeatPeriod, HostHeartbeatPeriod); }; } // namespace fsc } // namespace frames diff --git a/src/common/p25/dfsi/frames/fsc/FSCMessage.h b/src/common/p25/dfsi/frames/fsc/FSCMessage.h index 08398c7a..1086d596 100644 --- a/src/common/p25/dfsi/frames/fsc/FSCMessage.h +++ b/src/common/p25/dfsi/frames/fsc/FSCMessage.h @@ -69,15 +69,15 @@ namespace p25 /** * @brief Message ID. */ - __PROTECTED_PROPERTY(FSCMessageType::E, messageId, MessageId); + DECLARE_PROTECTED_PROPERTY(FSCMessageType::E, messageId, MessageId); /** * @brief Message Version. */ - __PROTECTED_READONLY_PROPERTY(uint8_t, version, Version); + DECLARE_PROTECTED_RO_PROPERTY(uint8_t, version, Version); /** * @brief */ - __PROPERTY(uint8_t, correlationTag, CorrelationTag); + DECLARE_PROPERTY(uint8_t, correlationTag, CorrelationTag); }; } // namespace fsc } // namespace frames diff --git a/src/common/p25/dfsi/frames/fsc/FSCSelChannel.h b/src/common/p25/dfsi/frames/fsc/FSCSelChannel.h index 31727576..c36ffa00 100644 --- a/src/common/p25/dfsi/frames/fsc/FSCSelChannel.h +++ b/src/common/p25/dfsi/frames/fsc/FSCSelChannel.h @@ -63,11 +63,11 @@ namespace p25 /** * @brief Receive Channel Number. */ - __PROPERTY(uint8_t, rxChan, RxChan); + DECLARE_PROPERTY(uint8_t, rxChan, RxChan); /** * @brief Transmit Channel Number. */ - __PROPERTY(uint8_t, txChan, TxChan); + DECLARE_PROPERTY(uint8_t, txChan, TxChan); }; } // namespace fsc } // namespace frames diff --git a/src/common/p25/kmm/KMMDeregistrationCommand.cpp b/src/common/p25/kmm/KMMDeregistrationCommand.cpp index 16d2012c..c26a81b6 100644 --- a/src/common/p25/kmm/KMMDeregistrationCommand.cpp +++ b/src/common/p25/kmm/KMMDeregistrationCommand.cpp @@ -45,7 +45,7 @@ bool KMMDeregistrationCommand::decode(const uint8_t* data) KMMFrame::decodeHeader(data); m_bodyFormat = data[10U]; // Body Format - m_kmfRSI = __GET_UINT16(data, 11U); // KMF RSI + m_kmfRSI = GET_UINT24(data, 11U); // KMF RSI return true; } @@ -61,7 +61,7 @@ void KMMDeregistrationCommand::encode(uint8_t* data) KMMFrame::encodeHeader(data); data[10U] = m_bodyFormat; // Body Format - __SET_UINT16(m_kmfRSI, data, 11U); // KMF RSI + SET_UINT24(m_kmfRSI, data, 11U); // KMF RSI } // --------------------------------------------------------------------------- diff --git a/src/common/p25/kmm/KMMDeregistrationCommand.h b/src/common/p25/kmm/KMMDeregistrationCommand.h index 053a690a..e93c8a27 100644 --- a/src/common/p25/kmm/KMMDeregistrationCommand.h +++ b/src/common/p25/kmm/KMMDeregistrationCommand.h @@ -71,13 +71,13 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, bodyFormat, BodyFormat); + DECLARE_PROPERTY(uint8_t, bodyFormat, BodyFormat); /** - * @brief + * @brief KMF RSI. */ - __PROPERTY(uint32_t, kmfRSI, KMFRSI); + DECLARE_PROPERTY(uint32_t, kmfRSI, KMFRSI); - __COPY(KMMDeregistrationCommand); + DECLARE_COPY(KMMDeregistrationCommand); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMDeregistrationResponse.h b/src/common/p25/kmm/KMMDeregistrationResponse.h index ab5b3876..2b1badba 100644 --- a/src/common/p25/kmm/KMMDeregistrationResponse.h +++ b/src/common/p25/kmm/KMMDeregistrationResponse.h @@ -69,11 +69,11 @@ namespace p25 public: /** - * @brief + * @brief Deregistration response status. */ - __PROPERTY(uint8_t, status, Status); + DECLARE_PROPERTY(uint8_t, status, Status); - __COPY(KMMDeregistrationResponse); + DECLARE_COPY(KMMDeregistrationResponse); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMFrame.cpp b/src/common/p25/kmm/KMMFrame.cpp index b86800fb..dbd9a586 100644 --- a/src/common/p25/kmm/KMMFrame.cpp +++ b/src/common/p25/kmm/KMMFrame.cpp @@ -57,7 +57,7 @@ bool KMMFrame::decodeHeader(const uint8_t* data) assert(data != nullptr); m_messageId = data[0U]; // Message ID - m_messageLength = __GET_UINT16B(data, 1U); // Message Length + m_messageLength = GET_UINT16(data, 1U); // Message Length m_respKind = (data[3U] >> 6U) & 0x03U; // Response Kind m_mfMessageNumber = (data[3U] >> 4U) & 0x03U; // Message Number @@ -69,8 +69,8 @@ bool KMMFrame::decodeHeader(const uint8_t* data) else m_complete = false; - m_dstLlId = __GET_UINT16(data, 4U); // Destination RSI - m_srcLlId = __GET_UINT16(data, 7U); // Source RSI + m_dstLlId = GET_UINT24(data, 4U); // Destination RSI + m_srcLlId = GET_UINT24(data, 7U); // Source RSI return true; } @@ -82,15 +82,15 @@ void KMMFrame::encodeHeader(uint8_t* data) assert(data != nullptr); data[0U] = m_messageId; // Message ID - __SET_UINT16B(m_messageLength, data, 1U); // Message Length + SET_UINT16(m_messageLength, data, 1U); // Message Length data[3U] = ((m_respKind & 0x03U) << 6U) + // Response Kind ((m_mfMessageNumber & 0x03U) << 4U) + // Message Number ((m_mfMac & 0x03U) << 2U) + // MAC ((!m_complete) ? 0x01U : 0x00U); // Done Flag - __SET_UINT16(m_dstLlId, data, 4U); // Destination RSI - __SET_UINT16(m_srcLlId, data, 7U); // Source RSI + SET_UINT24(m_dstLlId, data, 4U); // Destination RSI + SET_UINT24(m_srcLlId, data, 7U); // Source RSI } /* Internal helper to copy the the class. */ diff --git a/src/common/p25/kmm/KMMFrame.h b/src/common/p25/kmm/KMMFrame.h index 9c6f3900..5b758132 100644 --- a/src/common/p25/kmm/KMMFrame.h +++ b/src/common/p25/kmm/KMMFrame.h @@ -87,32 +87,32 @@ namespace p25 public: // Common Data /** - * @brief + * @brief KMM Message ID. */ - __PROTECTED_PROPERTY(uint8_t, messageId, MessageId); + DECLARE_PROTECTED_PROPERTY(uint8_t, messageId, MessageId); /** - * @brief + * @brief Message Length. */ - __PROTECTED_PROPERTY(uint16_t, messageLength, MessageLength); + DECLARE_PROTECTED_PROPERTY(uint16_t, messageLength, MessageLength); /** - * @brief + * @brief Response Kind. */ - __PROTECTED_PROPERTY(uint8_t, respKind, ResponseKind); + DECLARE_PROTECTED_PROPERTY(uint8_t, respKind, ResponseKind); /** * @brief Destination Logical link ID. */ - __PROTECTED_PROPERTY(uint32_t, dstLlId, DstLLId); + DECLARE_PROTECTED_PROPERTY(uint32_t, dstLlId, DstLLId); /** * @brief Source Logical link ID. */ - __PROTECTED_PROPERTY(uint32_t, srcLlId, SrcLLId); + DECLARE_PROTECTED_PROPERTY(uint32_t, srcLlId, SrcLLId); /** - * @brief + * @brief Flag indicating the KMM frame is complete. */ - __PROTECTED_PROPERTY(bool, complete, Complete); + DECLARE_PROTECTED_PROPERTY(bool, complete, Complete); protected: uint8_t m_mfMessageNumber; @@ -130,7 +130,7 @@ namespace p25 */ void encodeHeader(uint8_t* data); - __PROTECTED_COPY(KMMFrame); + DECLARE_PROTECTED_COPY(KMMFrame); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMHello.h b/src/common/p25/kmm/KMMHello.h index 0d220243..251b18f8 100644 --- a/src/common/p25/kmm/KMMHello.h +++ b/src/common/p25/kmm/KMMHello.h @@ -71,9 +71,9 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, flag, Flag); + DECLARE_PROPERTY(uint8_t, flag, Flag); - __COPY(KMMHello); + DECLARE_COPY(KMMHello); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMInventoryCommand.h b/src/common/p25/kmm/KMMInventoryCommand.h index 1f18bed6..81d1c3a1 100644 --- a/src/common/p25/kmm/KMMInventoryCommand.h +++ b/src/common/p25/kmm/KMMInventoryCommand.h @@ -69,11 +69,11 @@ namespace p25 public: /** - * @brief + * @brief Inventory type. */ - __PROPERTY(uint8_t, inventoryType, InventoryType); + DECLARE_PROPERTY(uint8_t, inventoryType, InventoryType); - __COPY(KMMInventoryCommand); + DECLARE_COPY(KMMInventoryCommand); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMInventoryResponseHeader.cpp b/src/common/p25/kmm/KMMInventoryResponseHeader.cpp index 254df4d2..89bc8744 100644 --- a/src/common/p25/kmm/KMMInventoryResponseHeader.cpp +++ b/src/common/p25/kmm/KMMInventoryResponseHeader.cpp @@ -44,7 +44,7 @@ bool KMMInventoryResponseHeader::decode(const uint8_t* data) KMMFrame::decodeHeader(data); m_inventoryType = data[10U]; // Inventory Type - m_numberOfItems = __GET_UINT16B(data, 11U); // Number of Items + m_numberOfItems = GET_UINT16(data, 11U); // Number of Items return true; } @@ -59,7 +59,7 @@ void KMMInventoryResponseHeader::encode(uint8_t* data) KMMFrame::encodeHeader(data); data[10U] = m_inventoryType; // Inventory Type - __SET_UINT16B(m_numberOfItems, data, 11U); // Number of Items + SET_UINT16(m_numberOfItems, data, 11U); // Number of Items } // --------------------------------------------------------------------------- diff --git a/src/common/p25/kmm/KMMInventoryResponseHeader.h b/src/common/p25/kmm/KMMInventoryResponseHeader.h index 07d3877c..816b60eb 100644 --- a/src/common/p25/kmm/KMMInventoryResponseHeader.h +++ b/src/common/p25/kmm/KMMInventoryResponseHeader.h @@ -69,15 +69,15 @@ namespace p25 public: /** - * @brief + * @brief Inventory type. */ - __PROTECTED_PROPERTY(uint8_t, inventoryType, InventoryType); + DECLARE_PROTECTED_PROPERTY(uint8_t, inventoryType, InventoryType); /** - * @brief + * @brief Number of items in the inventory response. */ - __PROTECTED_PROPERTY(uint16_t, numberOfItems, NumberOfItems); + DECLARE_PROTECTED_PROPERTY(uint16_t, numberOfItems, NumberOfItems); - __PROTECTED_COPY(KMMInventoryResponseHeader); + DECLARE_PROTECTED_COPY(KMMInventoryResponseHeader); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.cpp b/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.cpp index fee94b2b..38ea812f 100644 --- a/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.cpp +++ b/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.cpp @@ -68,7 +68,7 @@ bool KMMInventoryResponseListKeyIDs::decode(const uint8_t* data) uint16_t offset = 0U; for (uint16_t i = 0U; i < m_numberOfKeyIDs; i++) { - uint16_t keyId = __GET_UINT16B(data, 16U + offset); + uint16_t keyId = GET_UINT16(data, 16U + offset); m_keyIds.push_back(keyId); offset += 2U; } @@ -92,7 +92,7 @@ void KMMInventoryResponseListKeyIDs::encode(uint8_t* data) uint16_t offset = 0U; for (auto entry : m_keyIds) { - __SET_UINT16B(entry, data, 16U + offset); + SET_UINT16(entry, data, 16U + offset); offset += 2U; } } diff --git a/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.h b/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.h index 6f56a2cd..0ab5ea9e 100644 --- a/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.h +++ b/src/common/p25/kmm/KMMInventoryResponseListKeyIDs.h @@ -63,24 +63,24 @@ namespace p25 public: /** - * @brief + * @brief Encryption keyset ID. */ - __PROPERTY(uint8_t, keysetId, KeysetId); + DECLARE_PROPERTY(uint8_t, keysetId, KeysetId); /** * @brief Encryption algorithm ID. */ - __PROPERTY(uint8_t, algId, AlgId); + DECLARE_PROPERTY(uint8_t, algId, AlgId); /** * @brief Encryption algorithm ID. */ - __PROPERTY(uint8_t, numberOfKeyIDs, NumberOfKeyIDs); + DECLARE_PROPERTY(uint8_t, numberOfKeyIDs, NumberOfKeyIDs); /** - * @brief + * @brief List of key IDs. */ - __PROPERTY(std::vector, keyIds, KeyIds); + DECLARE_PROPERTY(std::vector, keyIds, KeyIds); - __COPY(KMMInventoryResponseListKeyIDs); + DECLARE_COPY(KMMInventoryResponseListKeyIDs); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMInventoryResponseListKeysets.h b/src/common/p25/kmm/KMMInventoryResponseListKeysets.h index 403ce7fc..a04f06d2 100644 --- a/src/common/p25/kmm/KMMInventoryResponseListKeysets.h +++ b/src/common/p25/kmm/KMMInventoryResponseListKeysets.h @@ -63,11 +63,11 @@ namespace p25 public: /** - * @brief + * @brief List of keyset IDs. */ - __PROPERTY(std::vector, keysetIds, KeysetIds); + DECLARE_PROPERTY(std::vector, keysetIds, KeysetIds); - __COPY(KMMInventoryResponseListKeysets); + DECLARE_COPY(KMMInventoryResponseListKeysets); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMModifyKey.cpp b/src/common/p25/kmm/KMMModifyKey.cpp index 1415976e..cefb1434 100644 --- a/src/common/p25/kmm/KMMModifyKey.cpp +++ b/src/common/p25/kmm/KMMModifyKey.cpp @@ -70,7 +70,7 @@ bool KMMModifyKey::decode(const uint8_t* data) m_decryptInfoFmt = data[10U]; // Decryption Instruction Format m_algId = data[11U]; // Algorithm ID - m_kId = __GET_UINT16B(data, 12U); // Key ID + m_kId = GET_UINT16(data, 12U); // Key ID uint16_t offset = 0U; if (m_decryptInfoFmt == KMM_DECRYPT_INSTRUCT_MI) { @@ -87,18 +87,17 @@ bool KMMModifyKey::decode(const uint8_t* data) for (uint8_t i = 0U; i < keyCount; i++) { KeyItem key = KeyItem(); - UInt8Array __keyPayload = std::make_unique(m_keysetItem.keyLength()); - uint8_t* keyPayload = __keyPayload.get(); + DECLARE_UINT8_ARRAY(keyPayload, m_keysetItem.keyLength()); uint8_t keyFormat = data[18U + offset]; uint8_t keyNameLen = keyFormat & 0x1FU; key.keyFormat(keyFormat & 0xE0U); - uint16_t sln = __GET_UINT16B(data, 19U + offset); + uint16_t sln = GET_UINT16(data, 19U + offset); key.sln(sln); - uint16_t kId = __GET_UINT16B(data, 21U + offset); + uint16_t kId = GET_UINT16(data, 21U + offset); key.kId(kId); ::memcpy(keyPayload, data + (23U + offset), m_keysetItem.keyLength()); @@ -127,7 +126,7 @@ void KMMModifyKey::encode(uint8_t* data) data[10U] = m_decryptInfoFmt; // Decryption Instruction Format data[11U] = m_algId; // Algorithm ID - __SET_UINT16B(m_kId, data, 12U); // Key ID + SET_UINT16(m_kId, data, 12U); // Key ID uint16_t offset = 0U; if (m_decryptInfoFmt == KMM_DECRYPT_INSTRUCT_MI) { @@ -144,11 +143,10 @@ void KMMModifyKey::encode(uint8_t* data) for (auto key : m_keysetItem.keys()) { uint8_t keyNameLen = key.keyFormat() & 0x1FU; data[18U + offset] = key.keyFormat(); - __SET_UINT16B(key.sln(), data, 19U + offset); - __SET_UINT16B(key.kId(), data, 21U + offset); + SET_UINT16(key.sln(), data, 19U + offset); + SET_UINT16(key.kId(), data, 21U + offset); - UInt8Array __keyPayload = std::make_unique(m_keysetItem.keyLength()); - uint8_t* keyPayload = __keyPayload.get(); + DECLARE_UINT8_ARRAY(keyPayload, m_keysetItem.keyLength()); key.getKey(keyPayload); ::memcpy(data + (23U + offset), keyPayload, m_keysetItem.keyLength()); diff --git a/src/common/p25/kmm/KMMModifyKey.h b/src/common/p25/kmm/KMMModifyKey.h index 5a831e17..86fc9501 100644 --- a/src/common/p25/kmm/KMMModifyKey.h +++ b/src/common/p25/kmm/KMMModifyKey.h @@ -91,22 +91,22 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, decryptInfoFmt, DecryptInfoFmt); + DECLARE_PROPERTY(uint8_t, decryptInfoFmt, DecryptInfoFmt); /** * @brief Encryption algorithm ID. */ - __PROPERTY(uint8_t, algId, AlgId); + DECLARE_PROPERTY(uint8_t, algId, AlgId); /** * @brief Encryption key ID. */ - __PROPERTY(uint32_t, kId, KId); + DECLARE_PROPERTY(uint32_t, kId, KId); /** * @brief */ - __PROPERTY(KeysetItem, keysetItem, KeysetItem); + DECLARE_PROPERTY(KeysetItem, keysetItem, KeysetItem); - __COPY(KMMModifyKey); + DECLARE_COPY(KMMModifyKey); private: // Encryption data diff --git a/src/common/p25/kmm/KMMNegativeAck.cpp b/src/common/p25/kmm/KMMNegativeAck.cpp index 82f16dcf..c3c45ce0 100644 --- a/src/common/p25/kmm/KMMNegativeAck.cpp +++ b/src/common/p25/kmm/KMMNegativeAck.cpp @@ -46,7 +46,7 @@ bool KMMNegativeAck::decode(const uint8_t* data) KMMFrame::decodeHeader(data); m_messageId = data[10U]; // Message ID - m_messageNo = __GET_UINT16B(data, 11U); // Message Number + m_messageNo = GET_UINT16(data, 11U); // Message Number m_status = data[13U]; // Status return true; @@ -62,7 +62,7 @@ void KMMNegativeAck::encode(uint8_t* data) KMMFrame::encodeHeader(data); data[10U] = m_messageId; // Message ID - __SET_UINT16B(m_messageNo, data, 11U); // Message Number + SET_UINT16(m_messageNo, data, 11U); // Message Number data[13U] = m_status; } diff --git a/src/common/p25/kmm/KMMNegativeAck.h b/src/common/p25/kmm/KMMNegativeAck.h index e0e8967c..bf3669ff 100644 --- a/src/common/p25/kmm/KMMNegativeAck.h +++ b/src/common/p25/kmm/KMMNegativeAck.h @@ -71,17 +71,17 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, messageId, MessageId); + DECLARE_PROPERTY(uint8_t, messageId, MessageId); /** * @brief */ - __PROPERTY(uint16_t, messageNo, MessageNumber); + DECLARE_PROPERTY(uint16_t, messageNo, MessageNumber); /** * @brief */ - __PROPERTY(uint8_t, status, Status); + DECLARE_PROPERTY(uint8_t, status, Status); - __COPY(KMMNegativeAck); + DECLARE_COPY(KMMNegativeAck); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMNoService.h b/src/common/p25/kmm/KMMNoService.h index 5cccdf3e..62d5540a 100644 --- a/src/common/p25/kmm/KMMNoService.h +++ b/src/common/p25/kmm/KMMNoService.h @@ -68,7 +68,7 @@ namespace p25 void encode(uint8_t* data) override; public: - __COPY(KMMNoService); + DECLARE_COPY(KMMNoService); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMRegistrationCommand.cpp b/src/common/p25/kmm/KMMRegistrationCommand.cpp index 464f7378..c45101ec 100644 --- a/src/common/p25/kmm/KMMRegistrationCommand.cpp +++ b/src/common/p25/kmm/KMMRegistrationCommand.cpp @@ -45,7 +45,7 @@ bool KMMRegistrationCommand::decode(const uint8_t* data) KMMFrame::decodeHeader(data); m_bodyFormat = data[10U]; // Body Format - m_kmfRSI = __GET_UINT16(data, 11U); // KMF RSI + m_kmfRSI = GET_UINT24(data, 11U); // KMF RSI return true; } @@ -61,7 +61,7 @@ void KMMRegistrationCommand::encode(uint8_t* data) KMMFrame::encodeHeader(data); data[10U] = m_bodyFormat; // Body Format - __SET_UINT16(m_kmfRSI, data, 11U); // KMF RSI + SET_UINT24(m_kmfRSI, data, 11U); // KMF RSI } // --------------------------------------------------------------------------- diff --git a/src/common/p25/kmm/KMMRegistrationCommand.h b/src/common/p25/kmm/KMMRegistrationCommand.h index efc944a6..95a060fa 100644 --- a/src/common/p25/kmm/KMMRegistrationCommand.h +++ b/src/common/p25/kmm/KMMRegistrationCommand.h @@ -71,13 +71,13 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, bodyFormat, BodyFormat); + DECLARE_PROPERTY(uint8_t, bodyFormat, BodyFormat); /** * @brief */ - __PROPERTY(uint32_t, kmfRSI, KMFRSI); + DECLARE_PROPERTY(uint32_t, kmfRSI, KMFRSI); - __COPY(KMMRegistrationCommand); + DECLARE_COPY(KMMRegistrationCommand); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMRegistrationResponse.h b/src/common/p25/kmm/KMMRegistrationResponse.h index 0f6f3fb7..5dadbeb3 100644 --- a/src/common/p25/kmm/KMMRegistrationResponse.h +++ b/src/common/p25/kmm/KMMRegistrationResponse.h @@ -71,9 +71,9 @@ namespace p25 /** * @brief */ - __PROPERTY(uint8_t, status, Status); + DECLARE_PROPERTY(uint8_t, status, Status); - __COPY(KMMRegistrationResponse); + DECLARE_COPY(KMMRegistrationResponse); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KMMZeroize.h b/src/common/p25/kmm/KMMZeroize.h index 69ef4a50..a405a69e 100644 --- a/src/common/p25/kmm/KMMZeroize.h +++ b/src/common/p25/kmm/KMMZeroize.h @@ -68,7 +68,7 @@ namespace p25 void encode(uint8_t* data) override; public: - __COPY(KMMZeroize); + DECLARE_COPY(KMMZeroize); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/kmm/KeysetItem.h b/src/common/p25/kmm/KeysetItem.h index 059fb26e..07391b9a 100644 --- a/src/common/p25/kmm/KeysetItem.h +++ b/src/common/p25/kmm/KeysetItem.h @@ -109,15 +109,15 @@ namespace p25 /** * @brief */ - __PROPERTY_PLAIN(uint8_t, keyFormat); + DECLARE_PROPERTY_PLAIN(uint8_t, keyFormat); /** - * @brief + * @brief Slot Logical Number. */ - __PROPERTY_PLAIN(uint16_t, sln); + DECLARE_PROPERTY_PLAIN(uint16_t, sln); /** - * @brief + * @brief Key ID. */ - __PROPERTY_PLAIN(uint16_t, kId); + DECLARE_PROPERTY_PLAIN(uint16_t, kId); private: uint32_t m_keyLength; @@ -193,22 +193,22 @@ namespace p25 public: /** - * @brief + * @brief Encryption keyset ID. */ - __PROPERTY_PLAIN(uint8_t, keysetId); + DECLARE_PROPERTY_PLAIN(uint8_t, keysetId); /** * @brief Encryption algorithm ID. */ - __PROPERTY_PLAIN(uint8_t, algId); + DECLARE_PROPERTY_PLAIN(uint8_t, algId); /** * @brief */ - __PROPERTY_PLAIN(uint8_t, keyLength); + DECLARE_PROPERTY_PLAIN(uint8_t, keyLength); /** * @brief List of keys. */ - __PROPERTY_PLAIN(std::vector, keys); + DECLARE_PROPERTY_PLAIN(std::vector, keys); }; } // namespace kmm } // namespace p25 diff --git a/src/common/p25/lc/LC.h b/src/common/p25/lc/LC.h index bab14773..0a54f933 100644 --- a/src/common/p25/lc/LC.h +++ b/src/common/p25/lc/LC.h @@ -146,89 +146,89 @@ namespace p25 /** * @brief Flag indicating the link control data is protected. */ - __PROPERTY(bool, protect, Protect); + DECLARE_PROPERTY(bool, protect, Protect); /** * @brief Link control opcode. */ - __PROPERTY(uint8_t, lco, LCO); + DECLARE_PROPERTY(uint8_t, lco, LCO); /** * @brief Manufacturer ID. */ - __PROPERTY(uint8_t, mfId, MFId); + DECLARE_PROPERTY(uint8_t, mfId, MFId); /** * @brief Source ID. */ - __PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROPERTY(uint32_t, dstId, DstId); /** * @brief Voice channel number. */ - __PROPERTY(uint32_t, grpVchNo, GrpVchNo); + DECLARE_PROPERTY(uint32_t, grpVchNo, GrpVchNo); /** * @brief Voice channel number. */ - __PROPERTY(uint32_t, grpVchNoB, GrpVchNoB); + DECLARE_PROPERTY(uint32_t, grpVchNoB, GrpVchNoB); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstIdB, DstIdB); + DECLARE_PROPERTY(uint32_t, dstIdB, DstIdB); /** * @brief Flag indicating explicit addressing. */ - __PROPERTY(bool, explicitId, ExplicitId); + DECLARE_PROPERTY(bool, explicitId, ExplicitId); /** * @brief Network ID. */ - __PROPERTY(uint32_t, netId, NetId); + DECLARE_PROPERTY(uint32_t, netId, NetId); /** * @brief System ID. */ - __PROPERTY(uint32_t, sysId, SysId); + DECLARE_PROPERTY(uint32_t, sysId, SysId); /** @} */ /** @name Service Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROPERTY(bool, emergency, Emergency); + DECLARE_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that encryption is enabled. */ - __PROPERTY(bool, encrypted, Encrypted); + DECLARE_PROPERTY(bool, encrypted, Encrypted); /** * @brief Priority level for the traffic. */ - __PROPERTY(uint8_t, priority, Priority); + DECLARE_PROPERTY(uint8_t, priority, Priority); /** * @brief Flag indicating a group/talkgroup operation. */ - __PROPERTY(bool, group, Group); + DECLARE_PROPERTY(bool, group, Group); /** @} */ /** @name Encryption data */ /** * @brief Encryption algorithm ID. */ - __PROPERTY(uint8_t, algId, AlgId); + DECLARE_PROPERTY(uint8_t, algId, AlgId); /** * @brief Encryption key ID. */ - __PROPERTY(uint32_t, kId, KId); + DECLARE_PROPERTY(uint32_t, kId, KId); /** @} */ /** @name Packed RS Data */ /** * @brief Packed RS Data. */ - __PROPERTY(ulong64_t, rsValue, RS); + DECLARE_PROPERTY(ulong64_t, rsValue, RS); /** @} */ private: diff --git a/src/common/p25/lc/TDULC.h b/src/common/p25/lc/TDULC.h index 40286a7e..163afa89 100644 --- a/src/common/p25/lc/TDULC.h +++ b/src/common/p25/lc/TDULC.h @@ -103,55 +103,55 @@ namespace p25 /** * @brief Flag indicating the link control data is protected. */ - __PROTECTED_PROPERTY(bool, protect, Protect); + DECLARE_PROTECTED_PROPERTY(bool, protect, Protect); /** * @brief Link control opcode. */ - __PROTECTED_PROPERTY(uint8_t, lco, LCO); + DECLARE_PROTECTED_PROPERTY(uint8_t, lco, LCO); /** * @brief Manufacturer ID. */ - __PROTECTED_PROPERTY(uint8_t, mfId, MFId); + DECLARE_PROTECTED_PROPERTY(uint8_t, mfId, MFId); /** * @brief Source ID. */ - __PROTECTED_PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROTECTED_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROTECTED_PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROTECTED_PROPERTY(uint32_t, dstId, DstId); /** * @brief Voice channel number. */ - __PROTECTED_PROPERTY(uint32_t, grpVchNo, GrpVchNo); + DECLARE_PROTECTED_PROPERTY(uint32_t, grpVchNo, GrpVchNo); /** @} */ /** @name Service Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROTECTED_PROPERTY(bool, emergency, Emergency); + DECLARE_PROTECTED_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that encryption is enabled. */ - __PROTECTED_PROPERTY(bool, encrypted, Encrypted); + DECLARE_PROTECTED_PROPERTY(bool, encrypted, Encrypted); /** * @brief Priority level for the traffic. */ - __PROTECTED_PROPERTY(uint8_t, priority, Priority); + DECLARE_PROTECTED_PROPERTY(uint8_t, priority, Priority); /** * @brief Flag indicating a group/talkgroup operation. */ - __PROTECTED_PROPERTY(bool, group, Group); + DECLARE_PROTECTED_PROPERTY(bool, group, Group); /** @} */ /** @name Local Site data */ /** * @brief Local Site Identity Entry. */ - __PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry); + DECLARE_PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry); /** @} */ protected: @@ -193,7 +193,7 @@ namespace p25 */ void encode(uint8_t* data, const uint8_t* payload); - __PROTECTED_COPY(TDULC); + DECLARE_PROTECTED_COPY(TDULC); }; } // namespace lc } // namespace p25 diff --git a/src/common/p25/lc/TSBK.h b/src/common/p25/lc/TSBK.h index 684958fc..8b7453a3 100644 --- a/src/common/p25/lc/TSBK.h +++ b/src/common/p25/lc/TSBK.h @@ -144,90 +144,90 @@ namespace p25 /** * @brief Flag indicating the link control data is protected. */ - __PROTECTED_PROPERTY(bool, protect, Protect); + DECLARE_PROTECTED_PROPERTY(bool, protect, Protect); /** * @brief Link control opcode. */ - __PROTECTED_PROPERTY(uint8_t, lco, LCO); + DECLARE_PROTECTED_PROPERTY(uint8_t, lco, LCO); /** * @brief Manufacturer ID. */ - __PROTECTED_PROPERTY(uint8_t, mfId, MFId); + DECLARE_PROTECTED_PROPERTY(uint8_t, mfId, MFId); /** * @brief Source ID. */ - __PROTECTED_PROPERTY(uint32_t, srcId, SrcId); + DECLARE_PROTECTED_PROPERTY(uint32_t, srcId, SrcId); /** * @brief Destination ID. */ - __PROTECTED_PROPERTY(uint32_t, dstId, DstId); + DECLARE_PROTECTED_PROPERTY(uint32_t, dstId, DstId); /** * @brief Flag indicating this is the last TSBK in a sequence of TSBKs. */ - __PROTECTED_PROPERTY(bool, lastBlock, LastBlock); + DECLARE_PROTECTED_PROPERTY(bool, lastBlock, LastBlock); /** * @brief Flag indicating this TSBK contains additional information. */ - __PROTECTED_PROPERTY(bool, aivFlag, AIV); + DECLARE_PROTECTED_PROPERTY(bool, aivFlag, AIV); /** * @brief Flag indicating this TSBK contains extended addressing. */ - __PROTECTED_PROPERTY(bool, extendedAddrFlag, EX); + DECLARE_PROTECTED_PROPERTY(bool, extendedAddrFlag, EX); /** * @brief Service type. */ - __PROTECTED_PROPERTY(uint8_t, service, Service); + DECLARE_PROTECTED_PROPERTY(uint8_t, service, Service); /** * @brief Response type. */ - __PROTECTED_PROPERTY(uint8_t, response, Response); + DECLARE_PROTECTED_PROPERTY(uint8_t, response, Response); /** * @brief Configured network ID. */ - __PROTECTED_READONLY_PROPERTY(uint32_t, netId, NetId); + DECLARE_PROTECTED_RO_PROPERTY(uint32_t, netId, NetId); /** * @brief Configured system ID. */ - __PROTECTED_READONLY_PROPERTY(uint32_t, sysId, SysId); + DECLARE_PROTECTED_RO_PROPERTY(uint32_t, sysId, SysId); /** * @brief Voice channel ID. */ - __PROTECTED_PROPERTY(uint8_t, grpVchId, GrpVchId); + DECLARE_PROTECTED_PROPERTY(uint8_t, grpVchId, GrpVchId); /** * @brief Voice channel number. */ - __PROTECTED_PROPERTY(uint32_t, grpVchNo, GrpVchNo); + DECLARE_PROTECTED_PROPERTY(uint32_t, grpVchNo, GrpVchNo); /** @} */ /** @name Common Service Options */ /** * @brief Flag indicating the emergency bits are set. */ - __PROTECTED_PROPERTY(bool, emergency, Emergency); + DECLARE_PROTECTED_PROPERTY(bool, emergency, Emergency); /** * @brief Flag indicating that encryption is enabled. */ - __PROTECTED_PROPERTY(bool, encrypted, Encrypted); + DECLARE_PROTECTED_PROPERTY(bool, encrypted, Encrypted); /** * @brief Priority level for the traffic. */ - __PROTECTED_PROPERTY(uint8_t, priority, Priority); + DECLARE_PROTECTED_PROPERTY(uint8_t, priority, Priority); /** * @brief Flag indicating a group/talkgroup operation. */ - __PROTECTED_PROPERTY(bool, group, Group); + DECLARE_PROTECTED_PROPERTY(bool, group, Group); /** @} */ /** @name Local Site data */ /** * @brief Local Site Identity Entry. */ - __PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry); + DECLARE_PROTECTED_PROPERTY_PLAIN(::lookups::IdenTable, siteIdenEntry); /** @} */ protected: @@ -274,7 +274,7 @@ namespace p25 */ void encode(uint8_t* data, const uint8_t* payload, bool rawTSBK = false, bool noTrellis = false); - __PROTECTED_COPY(TSBK); + DECLARE_PROTECTED_COPY(TSBK); private: uint8_t* m_raw; diff --git a/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.h b/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.h index 928d6e69..c0b52204 100644 --- a/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.h +++ b/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.h @@ -56,33 +56,33 @@ namespace p25 /** * @brief Adjacent site CFVA flags. */ - __PROPERTY(uint8_t, adjCFVA, AdjSiteCFVA); + DECLARE_PROPERTY(uint8_t, adjCFVA, AdjSiteCFVA); /** * @brief Adjacent site system ID. */ - __PROPERTY(uint32_t, adjSysId, AdjSiteSysId); + DECLARE_PROPERTY(uint32_t, adjSysId, AdjSiteSysId); /** * @brief Adjacent site RFSS ID. */ - __PROPERTY(uint8_t, adjRfssId, AdjSiteRFSSId); + DECLARE_PROPERTY(uint8_t, adjRfssId, AdjSiteRFSSId); /** * @brief Adjacent site ID. */ - __PROPERTY(uint8_t, adjSiteId, AdjSiteId); + DECLARE_PROPERTY(uint8_t, adjSiteId, AdjSiteId); /** * @brief Adjacent site channel ID. */ - __PROPERTY(uint8_t, adjChannelId, AdjSiteChnId); + DECLARE_PROPERTY(uint8_t, adjChannelId, AdjSiteChnId); /** * @brief Adjacent site channel number. */ - __PROPERTY(uint32_t, adjChannelNo, AdjSiteChnNo); + DECLARE_PROPERTY(uint32_t, adjChannelNo, AdjSiteChnNo); /** * @brief Adjacent site service class. */ - __PROPERTY(uint8_t, adjServiceClass, AdjSiteSvcClass); + DECLARE_PROPERTY(uint8_t, adjServiceClass, AdjSiteSvcClass); - __COPY(LC_ADJ_STS_BCAST); + DECLARE_COPY(LC_ADJ_STS_BCAST); }; } // namespace tdulc } // namespace lc diff --git a/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.h b/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.h index 1bbc66be..a5bea84d 100644 --- a/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.h +++ b/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.h @@ -66,9 +66,9 @@ namespace p25 /** * @brief Extended function opcode. */ - __PROPERTY(uint32_t, extendedFunction, ExtendedFunction); + DECLARE_PROPERTY(uint32_t, extendedFunction, ExtendedFunction); - __COPY(IOSP_EXT_FNCT); + DECLARE_COPY(IOSP_EXT_FNCT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/IOSP_GRP_AFF.h b/src/common/p25/lc/tsbk/IOSP_GRP_AFF.h index 0920694b..d362375a 100644 --- a/src/common/p25/lc/tsbk/IOSP_GRP_AFF.h +++ b/src/common/p25/lc/tsbk/IOSP_GRP_AFF.h @@ -66,9 +66,9 @@ namespace p25 /** * @brief Announcement group. */ - __PROPERTY(uint32_t, announceGroup, AnnounceGroup); + DECLARE_PROPERTY(uint32_t, announceGroup, AnnounceGroup); - __COPY(IOSP_GRP_AFF); + DECLARE_COPY(IOSP_GRP_AFF); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/IOSP_GRP_VCH.h b/src/common/p25/lc/tsbk/IOSP_GRP_VCH.h index 9ab76e10..d38dd6e7 100644 --- a/src/common/p25/lc/tsbk/IOSP_GRP_VCH.h +++ b/src/common/p25/lc/tsbk/IOSP_GRP_VCH.h @@ -66,7 +66,7 @@ namespace p25 /** * @brief Flag forcing the use of the group voice channel ID regardless of value. */ - __PROPERTY(bool, forceChannelId, ForceChannelId); + DECLARE_PROPERTY(bool, forceChannelId, ForceChannelId); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.h b/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.h index d2634619..a19204f7 100644 --- a/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.h +++ b/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.h @@ -66,9 +66,9 @@ namespace p25 /** * @brief Status value. */ - __PROPERTY(uint8_t, messageValue, Message); + DECLARE_PROPERTY(uint8_t, messageValue, Message); - __COPY(IOSP_MSG_UPDT); + DECLARE_COPY(IOSP_MSG_UPDT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/IOSP_RAD_MON.h b/src/common/p25/lc/tsbk/IOSP_RAD_MON.h index 4c783749..546b7d80 100644 --- a/src/common/p25/lc/tsbk/IOSP_RAD_MON.h +++ b/src/common/p25/lc/tsbk/IOSP_RAD_MON.h @@ -67,9 +67,9 @@ namespace p25 /** * @brief Radio Unit Monitor. */ - __PROPERTY(uint8_t, txMult, TxMult); + DECLARE_PROPERTY(uint8_t, txMult, TxMult); - __COPY(IOSP_RAD_MON); + DECLARE_COPY(IOSP_RAD_MON); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/IOSP_STS_UPDT.h b/src/common/p25/lc/tsbk/IOSP_STS_UPDT.h index e4e2fd27..aeeb7e0c 100644 --- a/src/common/p25/lc/tsbk/IOSP_STS_UPDT.h +++ b/src/common/p25/lc/tsbk/IOSP_STS_UPDT.h @@ -66,9 +66,9 @@ namespace p25 /** * @brief Status value. */ - __PROPERTY(uint8_t, statusValue, Status); + DECLARE_PROPERTY(uint8_t, statusValue, Status); - __COPY(IOSP_STS_UPDT); + DECLARE_COPY(IOSP_STS_UPDT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.h b/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.h index 8f8eb9f9..847991a3 100644 --- a/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.h +++ b/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.h @@ -65,13 +65,13 @@ namespace p25 /** * @brief Flag indicating authentication was successful. */ - __PROPERTY(bool, authSuccess, AuthSuccess); + DECLARE_PROPERTY(bool, authSuccess, AuthSuccess); /** * @brief Flag indicating authentication is standalone. */ - __PROPERTY(bool, authStandalone, AuthStandalone); + DECLARE_PROPERTY(bool, authStandalone, AuthStandalone); - __COPY(ISP_AUTH_FNE_RST); + DECLARE_COPY(ISP_AUTH_FNE_RST); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/ISP_AUTH_RESP.h b/src/common/p25/lc/tsbk/ISP_AUTH_RESP.h index 5c4db114..10f0e746 100644 --- a/src/common/p25/lc/tsbk/ISP_AUTH_RESP.h +++ b/src/common/p25/lc/tsbk/ISP_AUTH_RESP.h @@ -76,13 +76,13 @@ namespace p25 /** * @brief Flag indicating authentication is standalone. */ - __PROPERTY(bool, authStandalone, AuthStandalone); + DECLARE_PROPERTY(bool, authStandalone, AuthStandalone); private: // Authentication data uint8_t* m_authRes; - __COPY(ISP_AUTH_RESP); + DECLARE_COPY(ISP_AUTH_RESP); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.h b/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.h index 8ae9af10..0c883908 100644 --- a/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.h +++ b/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.h @@ -65,9 +65,9 @@ namespace p25 /** * @brief Announcement group. */ - __PROPERTY(uint32_t, announceGroup, AnnounceGroup); + DECLARE_PROPERTY(uint32_t, announceGroup, AnnounceGroup); - __COPY(ISP_GRP_AFF_Q_RSP); + DECLARE_COPY(ISP_GRP_AFF_Q_RSP); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.h b/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.h index bcb62b77..de147ecf 100644 --- a/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.h +++ b/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.h @@ -65,9 +65,9 @@ namespace p25 /** * @brief Location registration area. */ - __PROPERTY(uint8_t, lra, LRA); + DECLARE_PROPERTY(uint8_t, lra, LRA); - __COPY(ISP_LOC_REG_REQ); + DECLARE_COPY(ISP_LOC_REG_REQ); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.h b/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.h index d5a1468b..0ff5b45a 100644 --- a/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.h +++ b/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.h @@ -65,13 +65,13 @@ namespace p25 /** * @brief SNDCP Data Service Options */ - __PROPERTY(uint8_t, dataServiceOptions, DataServiceOptions); + DECLARE_PROPERTY(uint8_t, dataServiceOptions, DataServiceOptions); /** * @brief SNDCP Data Access Control */ - __PROPERTY(uint16_t, dataAccessControl, DataAccessControl); + DECLARE_PROPERTY(uint16_t, dataAccessControl, DataAccessControl); - __COPY(ISP_SNDCP_CH_REQ); + DECLARE_COPY(ISP_SNDCP_CH_REQ); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.h b/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.h index aed9c64a..b90824af 100644 --- a/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.h +++ b/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.h @@ -65,17 +65,17 @@ namespace p25 /** * @brief Flag indicationg SU has buffered data to send */ - __PROPERTY(bool, dataToSend, DataToSend); + DECLARE_PROPERTY(bool, dataToSend, DataToSend); /** * @brief SNDCP Data Service Options */ - __PROPERTY(uint8_t, dataServiceOptions, DataServiceOptions); + DECLARE_PROPERTY(uint8_t, dataServiceOptions, DataServiceOptions); /** * @brief SNDCP Data Access Control */ - __PROPERTY(uint32_t, dataAccessControl, DataAccessControl); + DECLARE_PROPERTY(uint32_t, dataAccessControl, DataAccessControl); - __COPY(ISP_SNDCP_REC_REQ); + DECLARE_COPY(ISP_SNDCP_REC_REQ); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.h b/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.h index 01eadb3a..9dedb604 100644 --- a/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.h +++ b/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.h @@ -66,33 +66,33 @@ namespace p25 /** * @brief Adjacent site CFVA flags. */ - __PROPERTY(uint8_t, adjCFVA, AdjSiteCFVA); + DECLARE_PROPERTY(uint8_t, adjCFVA, AdjSiteCFVA); /** * @brief Adjacent site system ID. */ - __PROPERTY(uint32_t, adjSysId, AdjSiteSysId); + DECLARE_PROPERTY(uint32_t, adjSysId, AdjSiteSysId); /** * @brief Adjacent site RFSS ID. */ - __PROPERTY(uint8_t, adjRfssId, AdjSiteRFSSId); + DECLARE_PROPERTY(uint8_t, adjRfssId, AdjSiteRFSSId); /** * @brief Adjacent site ID. */ - __PROPERTY(uint8_t, adjSiteId, AdjSiteId); + DECLARE_PROPERTY(uint8_t, adjSiteId, AdjSiteId); /** * @brief Adjacent site channel ID. */ - __PROPERTY(uint8_t, adjChannelId, AdjSiteChnId); + DECLARE_PROPERTY(uint8_t, adjChannelId, AdjSiteChnId); /** * @brief Adjacent site channel number. */ - __PROPERTY(uint32_t, adjChannelNo, AdjSiteChnNo); + DECLARE_PROPERTY(uint32_t, adjChannelNo, AdjSiteChnNo); /** * @brief Adjacent site service class. */ - __PROPERTY(uint8_t, adjServiceClass, AdjSiteSvcClass); + DECLARE_PROPERTY(uint8_t, adjServiceClass, AdjSiteSvcClass); - __COPY(OSP_ADJ_STS_BCAST); + DECLARE_COPY(OSP_ADJ_STS_BCAST); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.h b/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.h index 403fda6c..880104f5 100644 --- a/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.h +++ b/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.h @@ -76,7 +76,7 @@ namespace p25 // Authentication data uint8_t* m_authRes; - __COPY(OSP_AUTH_FNE_RESP); + DECLARE_COPY(OSP_AUTH_FNE_RESP); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.h b/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.h index f21a9f4c..ec71aae7 100644 --- a/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.h +++ b/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.h @@ -65,15 +65,15 @@ namespace p25 /** * @brief Voice channel ID. */ - __PROPERTY(uint8_t, grpVchIdB, GrpVchIdB); + DECLARE_PROPERTY(uint8_t, grpVchIdB, GrpVchIdB); /** * @brief Voice channel number. */ - __PROPERTY(uint32_t, grpVchNoB, GrpVchNoB); + DECLARE_PROPERTY(uint32_t, grpVchNoB, GrpVchNoB); /** * @brief Destination ID. */ - __PROPERTY(uint32_t, dstIdB, DstIdB); + DECLARE_PROPERTY(uint32_t, dstIdB, DstIdB); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.h b/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.h index 88def9f9..322c7566 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.h +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.h @@ -65,21 +65,21 @@ namespace p25 /** * @brief Patch super group ID. */ - __PROPERTY(uint32_t, patchSuperGroupId, PatchSuperGroupId); + DECLARE_PROPERTY(uint32_t, patchSuperGroupId, PatchSuperGroupId); /** * @brief 1st patch group ID. */ - __PROPERTY(uint32_t, patchGroup1Id, PatchGroup1Id); + DECLARE_PROPERTY(uint32_t, patchGroup1Id, PatchGroup1Id); /** * @brief 2nd patch group ID. */ - __PROPERTY(uint32_t, patchGroup2Id, PatchGroup2Id); + DECLARE_PROPERTY(uint32_t, patchGroup2Id, PatchGroup2Id); /** * @brief 3rd patch group ID. */ - __PROPERTY(uint32_t, patchGroup3Id, PatchGroup3Id); + DECLARE_PROPERTY(uint32_t, patchGroup3Id, PatchGroup3Id); - __COPY(OSP_MOT_GRG_ADD); + DECLARE_COPY(OSP_MOT_GRG_ADD); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.h b/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.h index c8674407..8a5aa143 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.h +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.h @@ -65,21 +65,21 @@ namespace p25 /** * @brief Patch super group ID. */ - __PROPERTY(uint32_t, patchSuperGroupId, PatchSuperGroupId); + DECLARE_PROPERTY(uint32_t, patchSuperGroupId, PatchSuperGroupId); /** * @brief 1st patch group ID. */ - __PROPERTY(uint32_t, patchGroup1Id, PatchGroup1Id); + DECLARE_PROPERTY(uint32_t, patchGroup1Id, PatchGroup1Id); /** * @brief 2nd patch group ID. */ - __PROPERTY(uint32_t, patchGroup2Id, PatchGroup2Id); + DECLARE_PROPERTY(uint32_t, patchGroup2Id, PatchGroup2Id); /** * @brief 3rd patch group ID. */ - __PROPERTY(uint32_t, patchGroup3Id, PatchGroup3Id); + DECLARE_PROPERTY(uint32_t, patchGroup3Id, PatchGroup3Id); - __COPY(OSP_MOT_GRG_DEL); + DECLARE_COPY(OSP_MOT_GRG_DEL); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.h b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.h index a33e3f4a..7f10baef 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.h +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.h @@ -65,9 +65,9 @@ namespace p25 /** * @brief Patch super group ID. */ - __PROPERTY(uint32_t, patchSuperGroupId, PatchSuperGroupId); + DECLARE_PROPERTY(uint32_t, patchSuperGroupId, PatchSuperGroupId); - __COPY(OSP_MOT_GRG_VCH_GRANT); + DECLARE_COPY(OSP_MOT_GRG_VCH_GRANT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.h b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.h index cea004ac..ff6947f6 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.h +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.h @@ -65,13 +65,13 @@ namespace p25 /** * @brief 1st patch group ID. */ - __PROPERTY(uint32_t, patchGroup1Id, PatchGroup1Id); + DECLARE_PROPERTY(uint32_t, patchGroup1Id, PatchGroup1Id); /** * @brief 2nd patch group ID. */ - __PROPERTY(uint32_t, patchGroup2Id, PatchGroup2Id); + DECLARE_PROPERTY(uint32_t, patchGroup2Id, PatchGroup2Id); - __COPY(OSP_MOT_GRG_VCH_UPD); + DECLARE_COPY(OSP_MOT_GRG_VCH_UPD); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.h b/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.h index 1190e2fc..ef85de03 100644 --- a/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.h +++ b/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.h @@ -65,7 +65,7 @@ namespace p25 /** * @brief Roamer Reaccess Method. */ - __PROPERTY(bool, roamerReaccess, RoamerReaccess); + DECLARE_PROPERTY(bool, roamerReaccess, RoamerReaccess); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_SCCB.h b/src/common/p25/lc/tsbk/OSP_SCCB.h index 1699335e..771f6dee 100644 --- a/src/common/p25/lc/tsbk/OSP_SCCB.h +++ b/src/common/p25/lc/tsbk/OSP_SCCB.h @@ -65,13 +65,13 @@ namespace p25 /** * @brief SCCB channel ID 1. */ - __PROPERTY(uint8_t, sccbChannelId1, SCCBChnId1); + DECLARE_PROPERTY(uint8_t, sccbChannelId1, SCCBChnId1); /** * @brief SCCB channel ID 2. */ - __PROPERTY(uint8_t, sccbChannelId2, SCCBChnId2); + DECLARE_PROPERTY(uint8_t, sccbChannelId2, SCCBChnId2); - __COPY(OSP_SCCB); + DECLARE_COPY(OSP_SCCB); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_SCCB_EXP.h b/src/common/p25/lc/tsbk/OSP_SCCB_EXP.h index 7398a018..39301ae0 100644 --- a/src/common/p25/lc/tsbk/OSP_SCCB_EXP.h +++ b/src/common/p25/lc/tsbk/OSP_SCCB_EXP.h @@ -68,13 +68,13 @@ namespace p25 /** * @brief SCCB channel ID 1. */ - __PROPERTY(uint8_t, sccbChannelId1, SCCBChnId1); + DECLARE_PROPERTY(uint8_t, sccbChannelId1, SCCBChnId1); /** * @brief Explicit SCCB channel number. */ - __PROPERTY(uint32_t, sccbChannelNo, SCCBChnNo); + DECLARE_PROPERTY(uint32_t, sccbChannelNo, SCCBChnNo); - __COPY(OSP_SCCB_EXP); + DECLARE_COPY(OSP_SCCB_EXP); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.h b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.h index f4d8a78a..c3a2a111 100644 --- a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.h +++ b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.h @@ -68,14 +68,14 @@ namespace p25 /** * @brief Flag indicating explicit channel frequncies should not be transmitted. */ - __PROPERTY(bool, implicitChannel, ImplicitChannel); + DECLARE_PROPERTY(bool, implicitChannel, ImplicitChannel); private: bool m_sndcpAutoAccess; bool m_sndcpRequestedAccess; uint16_t m_sndcpDAC; - __COPY(OSP_SNDCP_CH_ANN); + DECLARE_COPY(OSP_SNDCP_CH_ANN); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.h b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.h index 8f9c5870..2729b53f 100644 --- a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.h +++ b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.h @@ -65,13 +65,13 @@ namespace p25 /** * @brief SNDCP Data Service Options */ - __PROPERTY(uint8_t, dataServiceOptions, DataServiceOptions); + DECLARE_PROPERTY(uint8_t, dataServiceOptions, DataServiceOptions); /** * @brief SNDCP grant channel number. */ - __PROPERTY(uint32_t, dataChannelNo, DataChnNo); + DECLARE_PROPERTY(uint32_t, dataChannelNo, DataChnNo); - __COPY(OSP_SNDCP_CH_GNT); + DECLARE_COPY(OSP_SNDCP_CH_GNT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.h b/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.h index 894e711a..3afc6674 100644 --- a/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.h +++ b/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.h @@ -65,9 +65,9 @@ namespace p25 /** * @brief Microslot count. */ - __PROPERTY(uint16_t, microslotCount, MicroslotCount); + DECLARE_PROPERTY(uint16_t, microslotCount, MicroslotCount); - __COPY(OSP_SYNC_BCAST); + DECLARE_COPY(OSP_SYNC_BCAST); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/TSBKFactory.h b/src/common/p25/lc/tsbk/TSBKFactory.h index 522ea02b..b86728d7 100644 --- a/src/common/p25/lc/tsbk/TSBKFactory.h +++ b/src/common/p25/lc/tsbk/TSBKFactory.h @@ -95,8 +95,10 @@ #include "common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.h" #include "common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.h" #include "common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.h" +#include "common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.h" #include "common/p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.h" #include "common/p25/lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.h" +#include "common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.h" namespace p25 { diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp index 7ff5d6b9..086d5c6a 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp @@ -34,9 +34,7 @@ bool MBT_IOSP_ACK_RSP::decodeMBT(const data::DataHeader& dataHeader, const data: { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp index ae892667..f58f8ea5 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp @@ -34,9 +34,7 @@ bool MBT_IOSP_CALL_ALRT::decodeMBT(const data::DataHeader& dataHeader, const dat { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp index 0e79c555..05ebb5de 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp @@ -35,9 +35,7 @@ bool MBT_IOSP_EXT_FNCT::decodeMBT(const data::DataHeader& dataHeader, const data { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.h b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.h index 0f52ec72..6570bfeb 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.h @@ -66,9 +66,9 @@ namespace p25 /** * @brief Extended function opcode. */ - __PROPERTY(uint32_t, extendedFunction, ExtendedFunction); + DECLARE_PROPERTY(uint32_t, extendedFunction, ExtendedFunction); - __COPY(MBT_IOSP_EXT_FNCT); + DECLARE_COPY(MBT_IOSP_EXT_FNCT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp index 6dfbce06..591b25c6 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp @@ -35,9 +35,7 @@ bool MBT_IOSP_GRP_AFF::decodeMBT(const data::DataHeader& dataHeader, const data: { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) @@ -69,9 +67,9 @@ void MBT_IOSP_GRP_AFF::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserD ((m_siteData.sysId() >> 8) & 0xFFU); // System ID (b11-b8) pduUserData[1U] = (m_siteData.sysId() & 0xFFU); // System ID (b7-b0) - __SET_UINT16B(m_dstId, pduUserData, 2U); // Group ID - __SET_UINT16B(m_announceGroup, pduUserData, 4U); // Announcement Group - __SET_UINT16B(m_dstId, pduUserData, 6U); // Talkgroup Address + SET_UINT16(m_dstId, pduUserData, 2U); // Group ID + SET_UINT16(m_announceGroup, pduUserData, 4U); // Announcement Group + SET_UINT16(m_dstId, pduUserData, 6U); // Talkgroup Address /** Block 2 */ ::memset(pduUserData + 12U, 0x00U, 7U); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.h b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.h index efaf3b1a..7fa661c7 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.h @@ -65,7 +65,7 @@ namespace p25 /** * @brief Announcement group. */ - __PROPERTY(uint32_t, announceGroup, AnnounceGroup); + DECLARE_PROPERTY(uint32_t, announceGroup, AnnounceGroup); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp index 78aeb450..3da84ea3 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp @@ -35,9 +35,7 @@ bool MBT_IOSP_MSG_UPDT::decodeMBT(const data::DataHeader& dataHeader, const data { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.h b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.h index 47603c43..3e289bfe 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.h @@ -66,9 +66,9 @@ namespace p25 /** * @brief Message value. */ - __PROPERTY(uint8_t, messageValue, Message); + DECLARE_PROPERTY(uint8_t, messageValue, Message); - __COPY(MBT_IOSP_MSG_UPDT); + DECLARE_COPY(MBT_IOSP_MSG_UPDT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp index c748f2c0..f61b21c9 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp @@ -35,9 +35,7 @@ bool MBT_IOSP_STS_UPDT::decodeMBT(const data::DataHeader& dataHeader, const data { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.h b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.h index b330a56a..e240a1d7 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.h @@ -65,9 +65,9 @@ namespace p25 /** * @brief Status value. */ - __PROPERTY(uint8_t, statusValue, Status); + DECLARE_PROPERTY(uint8_t, statusValue, Status); - __COPY(MBT_IOSP_STS_UPDT); + DECLARE_COPY(MBT_IOSP_STS_UPDT); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp index 002f933f..ac1a93a8 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp @@ -56,9 +56,7 @@ bool MBT_ISP_AUTH_RESP_M::decodeMBT(const data::DataHeader& dataHeader, const da { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.h b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.h index 00398816..f57dd402 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.h @@ -86,14 +86,14 @@ namespace p25 /** * @brief Flag indicating authentication is standalone. */ - __PROPERTY(bool, authStandalone, AuthStandalone); + DECLARE_PROPERTY(bool, authStandalone, AuthStandalone); private: // Authentication data uint8_t* m_authRes; uint8_t* m_authRC; - __COPY(MBT_ISP_AUTH_RESP_M); + DECLARE_COPY(MBT_ISP_AUTH_RESP_M); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp index 01f8854d..55a216aa 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp @@ -34,9 +34,7 @@ bool MBT_ISP_AUTH_SU_DMD::decodeMBT(const data::DataHeader& dataHeader, const da { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp index ee4e59dc..d059089a 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp @@ -34,9 +34,7 @@ bool MBT_ISP_CAN_SRV_REQ::decodeMBT(const data::DataHeader& dataHeader, const da { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp index 726684ad..4a4b84a5 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp @@ -34,9 +34,7 @@ bool MBT_ISP_GRP_AFF_Q_RSP::decodeMBT(const data::DataHeader& dataHeader, const { assert(blocks != nullptr); - UInt8Array __pduUserData = std::make_unique(P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); + DECLARE_UINT8_ARRAY(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES * dataHeader.getBlocksToFollow()); bool ret = AMBT::decode(dataHeader, blocks, pduUserData); if (!ret) diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.h b/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.h index ebf475e2..bba893dc 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.h @@ -65,33 +65,33 @@ namespace p25 /** * @brief Adjacent site CFVA flags. */ - __PROPERTY(uint8_t, adjCFVA, AdjSiteCFVA); + DECLARE_PROPERTY(uint8_t, adjCFVA, AdjSiteCFVA); /** * @brief Adjacent site system ID. */ - __PROPERTY(uint32_t, adjSysId, AdjSiteSysId); + DECLARE_PROPERTY(uint32_t, adjSysId, AdjSiteSysId); /** * @brief Adjacent site RFSS ID. */ - __PROPERTY(uint8_t, adjRfssId, AdjSiteRFSSId); + DECLARE_PROPERTY(uint8_t, adjRfssId, AdjSiteRFSSId); /** * @brief Adjacent site ID. */ - __PROPERTY(uint8_t, adjSiteId, AdjSiteId); + DECLARE_PROPERTY(uint8_t, adjSiteId, AdjSiteId); /** * @brief Adjacent site channel ID. */ - __PROPERTY(uint8_t, adjChannelId, AdjSiteChnId); + DECLARE_PROPERTY(uint8_t, adjChannelId, AdjSiteChnId); /** * @brief Adjacent site channel number. */ - __PROPERTY(uint32_t, adjChannelNo, AdjSiteChnNo); + DECLARE_PROPERTY(uint32_t, adjChannelNo, AdjSiteChnNo); /** * @brief Adjacent site service class. */ - __PROPERTY(uint8_t, adjServiceClass, AdjSiteSvcClass); + DECLARE_PROPERTY(uint8_t, adjServiceClass, AdjSiteSvcClass); - __COPY(MBT_OSP_ADJ_STS_BCAST); + DECLARE_COPY(MBT_OSP_ADJ_STS_BCAST); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp index 48ed5e10..eb23b1bf 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp @@ -76,7 +76,7 @@ void MBT_OSP_AUTH_DMD::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserD ((m_siteData.sysId() >> 8) & 0xFFU); // System ID (b11-b8) pduUserData[1U] = (m_siteData.sysId() & 0xFFU); // System ID (b7-b0) - __SET_UINT16(m_dstId, pduUserData, 2U); // Target Radio Address + SET_UINT24(m_dstId, pduUserData, 2U); // Target Radio Address pduUserData[5U] = m_authRS[0U]; // Random Salt b9 pduUserData[6U] = m_authRS[1U]; // Random Salt b8 diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.h b/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.h index 86fb0755..11272224 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.h +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.h @@ -91,7 +91,7 @@ namespace p25 uint8_t* m_authRS; uint8_t* m_authRC; - __COPY(MBT_OSP_AUTH_DMD); + DECLARE_COPY(MBT_OSP_AUTH_DMD); }; } // namespace tsbk } // namespace lc diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.cpp new file mode 100644 index 00000000..84860504 --- /dev/null +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.cpp @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +#include "Defines.h" +#include "p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.h" + +using namespace p25; +using namespace p25::defines; +using namespace p25::lc; +using namespace p25::lc::tsbk; + +#include + +// --------------------------------------------------------------------------- +// Public Class Members +// --------------------------------------------------------------------------- + +/* Initializes a new instance of the MBT_OSP_GRP_VCH_GRANT class. */ + +MBT_OSP_GRP_VCH_GRANT::MBT_OSP_GRP_VCH_GRANT() : AMBT(), + m_forceChannelId(false), + m_rxGrpVchId(0U), + m_rxGrpVchNo(0U) +{ + m_lco = TSBKO::IOSP_GRP_VCH; +} + +/* Decode a alternate trunking signalling block. */ + +bool MBT_OSP_GRP_VCH_GRANT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) +{ + assert(blocks != nullptr); + + /* stub */ + + return true; +} + +/* Encode a alternate trunking signalling block. */ + +void MBT_OSP_GRP_VCH_GRANT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) +{ + assert(pduUserData != nullptr); + + uint8_t serviceOptions = + (m_emergency ? 0x80U : 0x00U) + // Emergency Flag + (m_encrypted ? 0x40U : 0x00U) + // Encrypted Flag + (m_priority & 0x07U); // Priority + + dataHeader.setAMBTField8(serviceOptions); + + uint16_t txFrequency = 0U; + if ((m_grpVchId != 0U) || m_forceChannelId) { + txFrequency = (txFrequency << 4) + m_grpVchId; // Tx Channel ID + } + else { + txFrequency = (txFrequency << 4) + m_siteData.channelId(); // Tx Channel ID + } + txFrequency = (txFrequency << 12) + m_grpVchNo; // Tx Channel Number + + + uint16_t rxFrequency = 0U; + if ((m_rxGrpVchId != 0U) || m_forceChannelId) { + rxFrequency = (rxFrequency << 4) + m_rxGrpVchId; // Rx Channel ID + } + else { + rxFrequency = (rxFrequency << 4) + m_siteData.channelId(); // Rx Channel ID + } + rxFrequency = (rxFrequency << 12) + m_rxGrpVchNo; // Rx Channel Number + + /** Block 1 */ + SET_UINT16(txFrequency, pduUserData, 2U); // Transmit Frequency + SET_UINT16(rxFrequency, pduUserData, 4U); // Receive Frequency + SET_UINT16(m_dstId, pduUserData, 6U); // Talkgroup Address + + AMBT::encode(dataHeader, pduUserData); +} + +/* Returns a string that represents the current TSBK. */ + +std::string MBT_OSP_GRP_VCH_GRANT::toString(bool isp) +{ + return std::string("TSBKO, IOSP_GRP_VCH (Group Voice Channel Grant - Explicit)"); +} diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.h b/src/common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.h new file mode 100644 index 00000000..37dba29c --- /dev/null +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.h @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file MBT_OSP_GRP_VCH_GRANT.h + * @ingroup p25_ambt + * @file MBT_OSP_GRP_VCH_GRANT.cpp + * @ingroup p25_ambt + */ +#if !defined(__P25_LC_TSBK__MBT_OSP_GRP_VCH_GRANT_H__) +#define __P25_LC_TSBK__MBT_OSP_GRP_VCH_GRANT_H__ + +#include "common/Defines.h" +#include "common/p25/lc/AMBT.h" + +namespace p25 +{ + namespace lc + { + namespace tsbk + { + // --------------------------------------------------------------------------- + // Class Declaration + // --------------------------------------------------------------------------- + + /** + * @brief Implements GRP VCH GRANT - Group Voice Channel Grant (OSP). + * @ingroup p25_ambt + */ + class HOST_SW_API MBT_OSP_GRP_VCH_GRANT : public AMBT { + public: + /** + * @brief Initializes a new instance of the MBT_OSP_GRP_VCH_GRANT class. + */ + MBT_OSP_GRP_VCH_GRANT(); + + /** + * @brief Decode a alternate trunking signalling block. + * @param[in] dataHeader P25 PDU data header + * @param[in] blocks P25 PDU data blocks + * @returns bool True, if AMBT decoded, otherwise false. + */ + bool decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) override; + /** + * @brief Encode a alternate trunking signalling block. + * @param[out] dataHeader P25 PDU data header + * @param[out] pduUserData P25 PDU user data + */ + void encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) override; + + /** + * @brief Returns a string that represents the current AMBT. + * @returns std::string String representation of the AMBT. + */ + std::string toString(bool isp = false) override; + + public: + /** + * @brief Flag forcing the use of the group voice channel ID regardless of value. + */ + DECLARE_PROPERTY(bool, forceChannelId, ForceChannelId); + + /** @name Common Data */ + /** + * @brief Rx Voice channel ID. + */ + DECLARE_PROTECTED_PROPERTY(uint8_t, rxGrpVchId, RxGrpVchId); + /** + * @brief Rx Voice channel number. + */ + DECLARE_PROTECTED_PROPERTY(uint32_t, rxGrpVchNo, RxGrpVchNo); + /** @} */ + }; + } // namespace tsbk + } // namespace lc +} // namespace p25 + +#endif // __P25_LC_TSBK__MBT_OSP_GRP_VCH_GRANT_H__ diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.cpp new file mode 100644 index 00000000..8c6278c8 --- /dev/null +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.cpp @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +#include "Defines.h" +#include "p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.h" + +using namespace p25; +using namespace p25::defines; +using namespace p25::lc; +using namespace p25::lc::tsbk; + +#include + +// --------------------------------------------------------------------------- +// Public Class Members +// --------------------------------------------------------------------------- + +/* Initializes a new instance of the MBT_OSP_UU_VCH_GRANT class. */ + +MBT_OSP_UU_VCH_GRANT::MBT_OSP_UU_VCH_GRANT() : AMBT(), + m_forceChannelId(false), + m_rxGrpVchId(0U), + m_rxGrpVchNo(0U) +{ + m_lco = TSBKO::IOSP_GRP_VCH; +} + +/* Decode a alternate trunking signalling block. */ + +bool MBT_OSP_UU_VCH_GRANT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) +{ + assert(blocks != nullptr); + + /* stub */ + + return true; +} + +/* Encode a alternate trunking signalling block. */ + +void MBT_OSP_UU_VCH_GRANT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) +{ + assert(pduUserData != nullptr); + + dataHeader.setBlocksToFollow(2U); + + uint8_t serviceOptions = + (m_emergency ? 0x80U : 0x00U) + // Emergency Flag + (m_encrypted ? 0x40U : 0x00U) + // Encrypted Flag + (m_priority & 0x07U); // Priority + + dataHeader.setAMBTField8(serviceOptions); + dataHeader.setAMBTField9((m_siteData.netId() >> 12) & 0xFFU); // Target Network ID (b19-12) + + uint16_t txFrequency = 0U; + if ((m_grpVchId != 0U) || m_forceChannelId) { + txFrequency = (txFrequency << 4) + m_grpVchId; // Tx Channel ID + } + else { + txFrequency = (txFrequency << 4) + m_siteData.channelId(); // Tx Channel ID + } + txFrequency = (txFrequency << 12) + m_grpVchNo; // Tx Channel Number + + + uint16_t rxFrequency = 0U; + if ((m_rxGrpVchId != 0U) || m_forceChannelId) { + rxFrequency = (rxFrequency << 4) + m_rxGrpVchId; // Rx Channel ID + } + else { + rxFrequency = (rxFrequency << 4) + m_siteData.channelId(); // Rx Channel ID + } + rxFrequency = (rxFrequency << 12) + m_rxGrpVchNo; // Rx Channel Number + + /** Block 1 */ + pduUserData[0U] = ((m_siteData.netId() >> 12) & 0xFFU); // Source Network ID (b19-12) + pduUserData[1U] = ((m_siteData.netId() >> 4) & 0xFFU); // Source Network ID (b11-b4) + pduUserData[2U] = ((m_siteData.netId() & 0x0FU) << 4) + // Source Network ID (b3-b0) + ((m_siteData.sysId() >> 8) & 0xFFU); // Source System ID (b11-b8) + pduUserData[3U] = (m_siteData.sysId() & 0xFFU); // Source System ID (b7-b0) + SET_UINT24(m_srcId, pduUserData, 4U); // Source Radio Address + SET_UINT24(m_dstId, pduUserData, 7U); // Target Radio Address + SET_UINT16(txFrequency, pduUserData, 10U); // Transmit Frequency + + /** Block 2 */ + SET_UINT16(rxFrequency, pduUserData, 12U); // Receive Frequency + pduUserData[14U] = ((m_siteData.netId() >> 4) & 0xFFU); // Target Network ID (b11-b4) + pduUserData[15U] = ((m_siteData.netId() & 0x0FU) << 4) + // Target Network ID (b3-b0) + ((m_siteData.sysId() >> 8) & 0xFFU); // Target System ID (b11-b8) + pduUserData[16U] = (m_siteData.sysId() & 0xFFU); // Target System ID (b7-b0) + SET_UINT24(m_dstId, pduUserData, 17U); // Target Radio Address + + AMBT::encode(dataHeader, pduUserData); +} + +/* Returns a string that represents the current TSBK. */ + +std::string MBT_OSP_UU_VCH_GRANT::toString(bool isp) +{ + return std::string("TSBKO, IOSP_UU_VCH (Unit-to-Unit Voice Channel Grant - Explicit)"); +} diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.h b/src/common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.h new file mode 100644 index 00000000..63e38f08 --- /dev/null +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.h @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Common Library + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2025 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file MBT_OSP_UU_VCH_GRANT.h + * @ingroup p25_ambt + * @file MBT_OSP_UU_VCH_GRANT.cpp + * @ingroup p25_ambt + */ +#if !defined(__P25_LC_TSBK__MBT_OSP_UU_VCH_GRANT_H__) +#define __P25_LC_TSBK__MBT_OSP_UU_VCH_GRANT_H__ + +#include "common/Defines.h" +#include "common/p25/lc/AMBT.h" + +namespace p25 +{ + namespace lc + { + namespace tsbk + { + // --------------------------------------------------------------------------- + // Class Declaration + // --------------------------------------------------------------------------- + + /** + * @brief Implements UU VCH GRANT - Unit-to-Unit Voice Channel Grant (OSP). + * @ingroup p25_ambt + */ + class HOST_SW_API MBT_OSP_UU_VCH_GRANT : public AMBT { + public: + /** + * @brief Initializes a new instance of the MBT_OSP_UU_VCH_GRANT class. + */ + MBT_OSP_UU_VCH_GRANT(); + + /** + * @brief Decode a alternate trunking signalling block. + * @param[in] dataHeader P25 PDU data header + * @param[in] blocks P25 PDU data blocks + * @returns bool True, if AMBT decoded, otherwise false. + */ + bool decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) override; + /** + * @brief Encode a alternate trunking signalling block. + * @param[out] dataHeader P25 PDU data header + * @param[out] pduUserData P25 PDU user data + */ + void encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) override; + + /** + * @brief Returns a string that represents the current AMBT. + * @returns std::string String representation of the AMBT. + */ + std::string toString(bool isp = false) override; + + public: + /** + * @brief Flag forcing the use of the group voice channel ID regardless of value. + */ + DECLARE_PROPERTY(bool, forceChannelId, ForceChannelId); + + /** @name Common Data */ + /** + * @brief Rx Voice channel ID. + */ + DECLARE_PROTECTED_PROPERTY(uint8_t, rxGrpVchId, RxGrpVchId); + /** + * @brief Rx Voice channel number. + */ + DECLARE_PROTECTED_PROPERTY(uint32_t, rxGrpVchNo, RxGrpVchNo); + /** @} */ + }; + } // namespace tsbk + } // namespace lc +} // namespace p25 + +#endif // __P25_LC_TSBK__MBT_OSP_UU_VCH_GRANT_H__ diff --git a/src/common/p25/sndcp/SNDCPCtxActAccept.cpp b/src/common/p25/sndcp/SNDCPCtxActAccept.cpp index dd7010ce..3e4179fe 100644 --- a/src/common/p25/sndcp/SNDCPCtxActAccept.cpp +++ b/src/common/p25/sndcp/SNDCPCtxActAccept.cpp @@ -70,7 +70,7 @@ void SNDCPCtxActAccept::encode(uint8_t* data) data[10U] = (m_mdpco & 0x0FU); // MDPCO - __SET_UINT16B(m_sndcpDAC, data, 11U); // Data Access Control + SET_UINT16(m_sndcpDAC, data, 11U); // Data Access Control } // --------------------------------------------------------------------------- diff --git a/src/common/p25/sndcp/SNDCPCtxActAccept.h b/src/common/p25/sndcp/SNDCPCtxActAccept.h index a913d6e2..bf3b03ad 100644 --- a/src/common/p25/sndcp/SNDCPCtxActAccept.h +++ b/src/common/p25/sndcp/SNDCPCtxActAccept.h @@ -57,36 +57,36 @@ namespace p25 /** * @brief Priority */ - __PROPERTY(uint8_t, priority, Priority); + DECLARE_PROPERTY(uint8_t, priority, Priority); /** * @brief Ready Timer */ - __PROPERTY(uint8_t, readyTimer, ReadyTimer); + DECLARE_PROPERTY(uint8_t, readyTimer, ReadyTimer); /** * @brief Ready Timer */ - __PROPERTY(uint8_t, standbyTimer, StandbyTimer); + DECLARE_PROPERTY(uint8_t, standbyTimer, StandbyTimer); /** * @brief Network Address Type */ - __PROPERTY(uint8_t, nat, NAT); + DECLARE_PROPERTY(uint8_t, nat, NAT); /** * @brief IP Address */ - __PROPERTY(uint32_t, ipAddress, IPAddress); + DECLARE_PROPERTY(uint32_t, ipAddress, IPAddress); /** * @brief MTU */ - __PROPERTY(uint8_t, mtu, MTU); + DECLARE_PROPERTY(uint8_t, mtu, MTU); /** * @brief MDPCO */ - __PROPERTY(uint8_t, mdpco, MDPCO); + DECLARE_PROPERTY(uint8_t, mdpco, MDPCO); - __COPY(SNDCPCtxActAccept); + DECLARE_COPY(SNDCPCtxActAccept); private: uint16_t m_sndcpDAC; diff --git a/src/common/p25/sndcp/SNDCPCtxActReject.h b/src/common/p25/sndcp/SNDCPCtxActReject.h index dc9f6047..cc4f7294 100644 --- a/src/common/p25/sndcp/SNDCPCtxActReject.h +++ b/src/common/p25/sndcp/SNDCPCtxActReject.h @@ -57,9 +57,9 @@ namespace p25 /** * @brief Reject Code */ - __PROPERTY(uint8_t, rejectCode, RejectCode); + DECLARE_PROPERTY(uint8_t, rejectCode, RejectCode); - __COPY(SNDCPCtxActReject); + DECLARE_COPY(SNDCPCtxActReject); }; } // namespace sndcp } // namespace p25 diff --git a/src/common/p25/sndcp/SNDCPCtxActRequest.h b/src/common/p25/sndcp/SNDCPCtxActRequest.h index 9022a37d..39c99fb9 100644 --- a/src/common/p25/sndcp/SNDCPCtxActRequest.h +++ b/src/common/p25/sndcp/SNDCPCtxActRequest.h @@ -57,24 +57,24 @@ namespace p25 /** * @brief Network Address Type */ - __PROPERTY(uint8_t, nat, NAT); + DECLARE_PROPERTY(uint8_t, nat, NAT); /** * @brief IP Address */ - __PROPERTY(ulong64_t, ipAddress, IPAddress); + DECLARE_PROPERTY(ulong64_t, ipAddress, IPAddress); /** * @brief Data Subscriber Unit Type */ - __PROPERTY(uint8_t, dsut, DSUT); + DECLARE_PROPERTY(uint8_t, dsut, DSUT); /** * @brief MDPCO */ - __PROPERTY(uint8_t, mdpco, MDPCO); + DECLARE_PROPERTY(uint8_t, mdpco, MDPCO); - __COPY(SNDCPCtxActRequest); + DECLARE_COPY(SNDCPCtxActRequest); }; } // namespace sndcp } // namespace p25 diff --git a/src/common/p25/sndcp/SNDCPCtxDeactivation.h b/src/common/p25/sndcp/SNDCPCtxDeactivation.h index 06b1a00c..f2aed3fc 100644 --- a/src/common/p25/sndcp/SNDCPCtxDeactivation.h +++ b/src/common/p25/sndcp/SNDCPCtxDeactivation.h @@ -57,9 +57,9 @@ namespace p25 /** * @brief Deactivation Type */ - __PROPERTY(uint8_t, deactType, DeactType); + DECLARE_PROPERTY(uint8_t, deactType, DeactType); - __COPY(SNDCPCtxDeactivation); + DECLARE_COPY(SNDCPCtxDeactivation); }; } // namespace sndcp } // namespace p25 diff --git a/src/common/p25/sndcp/SNDCPPacket.h b/src/common/p25/sndcp/SNDCPPacket.h index ec71d9a2..beac1570 100644 --- a/src/common/p25/sndcp/SNDCPPacket.h +++ b/src/common/p25/sndcp/SNDCPPacket.h @@ -70,15 +70,15 @@ namespace p25 /** * @brief SNDCP PDU Type. */ - __PROTECTED_PROPERTY(uint8_t, pduType, PDUType); + DECLARE_PROTECTED_PROPERTY(uint8_t, pduType, PDUType); /** * @brief Link control opcode. */ - __READONLY_PROPERTY(uint8_t, sndcpVersion, SNDCPVersion); + DECLARE_RO_PROPERTY(uint8_t, sndcpVersion, SNDCPVersion); /** * @brief Network Service Access Point Identifier */ - __PROTECTED_PROPERTY(uint8_t, nsapi, NSAPI); + DECLARE_PROTECTED_PROPERTY(uint8_t, nsapi, NSAPI); protected: /** @@ -95,7 +95,7 @@ namespace p25 */ void encodeHeader(uint8_t* data, bool outbound = false); - __PROTECTED_COPY(SNDCPPacket); + DECLARE_PROTECTED_COPY(SNDCPPacket); }; } // namespace sndcp } // namespace p25 diff --git a/src/fne/CryptoContainer.h b/src/fne/CryptoContainer.h index 5d9842c6..d72a0256 100644 --- a/src/fne/CryptoContainer.h +++ b/src/fne/CryptoContainer.h @@ -122,34 +122,34 @@ public: /** * @brief */ - __PROPERTY_PLAIN(uint32_t, id); + DECLARE_PROPERTY_PLAIN(uint32_t, id); /** * @brief */ - __PROPERTY_PLAIN(std::string, name); + DECLARE_PROPERTY_PLAIN(std::string, name); /** * @brief */ - __PROPERTY_PLAIN(uint32_t, keysetId); + DECLARE_PROPERTY_PLAIN(uint32_t, keysetId); /** * @brief */ - __PROPERTY_PLAIN(uint32_t, sln); + DECLARE_PROPERTY_PLAIN(uint32_t, sln); /** * @brief Encryption algorithm ID. */ - __PROPERTY_PLAIN(uint8_t, algId); + DECLARE_PROPERTY_PLAIN(uint8_t, algId); /** * @brief Encryption key ID. */ - __PROPERTY_PLAIN(uint32_t, kId); + DECLARE_PROPERTY_PLAIN(uint32_t, kId); /** * @brief Encryption key material. */ - __PROPERTY_PLAIN(std::string, keyMaterial); + DECLARE_PROPERTY_PLAIN(std::string, keyMaterial); }; // --------------------------------------------------------------------------- @@ -252,7 +252,7 @@ public: /** * @brief List of keys. */ - __PROPERTY_PLAIN(std::vector, keys); + DECLARE_PROPERTY_PLAIN(std::vector, keys); }; #endif // __CRYPTO_CONTAINER_H__ diff --git a/src/fne/FNEMain.cpp b/src/fne/FNEMain.cpp index 7b93f36a..5b61eacc 100644 --- a/src/fne/FNEMain.cpp +++ b/src/fne/FNEMain.cpp @@ -192,7 +192,7 @@ int main(int argc, char** argv) ::memset(g_gitHashBytes, 0x00U, 4U); uint32_t hash = ::strtoul(__GIT_VER_HASH__, 0, 16); - __SET_UINT32(hash, g_gitHashBytes, 0U); + SET_UINT32(hash, g_gitHashBytes, 0U); if (argv[0] != nullptr && *argv[0] != 0) g_progExe = std::string(argv[0]); diff --git a/src/fne/HostFNE.cpp b/src/fne/HostFNE.cpp index f99070a7..674bf52e 100644 --- a/src/fne/HostFNE.cpp +++ b/src/fne/HostFNE.cpp @@ -74,6 +74,7 @@ HostFNE::HostFNE(const std::string& confFile) : m_pingTime(5U), m_maxMissedPings(5U), m_updateLookupTime(10U), + m_peerLinkSavesACL(false), m_useAlternatePortForDiagnostics(false), m_allowActivityTransfer(false), m_allowDiagnosticTransfer(false), @@ -328,8 +329,9 @@ bool HostFNE::readParams() yaml::Node systemConf = m_conf["system"]; m_pingTime = systemConf["pingTime"].as(5U); m_maxMissedPings = systemConf["maxMissedPings"].as(5U); - m_updateLookupTime = systemConf["tgRuleUpdateTime"].as(10U); + m_updateLookupTime = systemConf["aclRuleUpdateTime"].as(10U); bool sendTalkgroups = systemConf["sendTalkgroups"].as(true); + m_peerLinkSavesACL = systemConf["peerLinkSaveACL"].as(false); if (m_pingTime == 0U) { m_pingTime = 5U; @@ -347,15 +349,32 @@ bool HostFNE::readParams() m_allowActivityTransfer = systemConf["allowActivityTransfer"].as(true); m_allowDiagnosticTransfer = systemConf["allowDiagnosticTransfer"].as(true); + if (!m_useAlternatePortForDiagnostics) { + LogWarning(LOG_HOST, "Alternate port for diagnostics and activity logging is disabled, this severely limits functionality and will prevent peer connections from transmitting diagnostic and activity logging to this FNE!"); + LogWarning(LOG_HOST, "It is *not* recommended to disable the \"useAlternatePortForDiagnostics\" option."); + } + + if (!m_allowActivityTransfer) { + LogWarning(LOG_HOST, "Peer activity logging is disabled, this severely limits functionality and can prevent proper operations by prohibiting activity logging to this FNE!"); + LogWarning(LOG_HOST, "It is *not* recommended to disable the \"allowActivityTransfer\" option."); + } + LogInfo("General Parameters"); LogInfo(" Peer Ping Time: %us", m_pingTime); LogInfo(" Maximum Missed Pings: %u", m_maxMissedPings); - LogInfo(" Talkgroup Rule Update Time: %u mins", m_updateLookupTime); + LogInfo(" ACL Rule Update Time: %u mins", m_updateLookupTime); LogInfo(" Send Talkgroups: %s", sendTalkgroups ? "yes" : "no"); - - LogInfo(" Use Alternate Port for Diagnostics: %s", m_useAlternatePortForDiagnostics ? "yes" : "no"); - LogInfo(" Allow Activity Log Transfer: %s", m_allowActivityTransfer ? "yes" : "no"); + LogInfo(" Peer Link ACL is retained: %s", m_peerLinkSavesACL ? "yes" : "no"); + + if (m_useAlternatePortForDiagnostics) + LogInfo(" Use Alternate Port for Diagnostics: yes"); + else + LogInfo(" !! Use Alternate Port for Diagnostics: no"); + if (m_allowActivityTransfer) + LogInfo(" Allow Activity Log Transfer: yes"); + else + LogInfo(" !! Allow Activity Log Transfer: no"); LogInfo(" Allow Diagnostic Log Transfer: %s", m_allowDiagnosticTransfer ? "yes" : "no"); // attempt to load and populate routing rules @@ -807,6 +826,7 @@ bool HostFNE::createPeerNetworks() network->setMetadata(identity, rxFrequency, txFrequency, 0.0F, 0.0F, 0, 0, 0, latitude, longitude, 0, location); network->setLookups(m_ridLookup, m_tidLookup); network->setPeerLookups(m_peerListLookup); + network->setPeerLinkSaveACL(m_peerLinkSavesACL); if (encrypted) { network->setPresharedKey(presharedKey); } diff --git a/src/fne/HostFNE.h b/src/fne/HostFNE.h index 727e05ca..d3e0da48 100644 --- a/src/fne/HostFNE.h +++ b/src/fne/HostFNE.h @@ -113,6 +113,8 @@ private: uint32_t m_maxMissedPings; uint32_t m_updateLookupTime; + bool m_peerLinkSavesACL; + bool m_useAlternatePortForDiagnostics; bool m_allowActivityTransfer; diff --git a/src/fne/network/DiagNetwork.cpp b/src/fne/network/DiagNetwork.cpp index 1c0b4511..42834eed 100644 --- a/src/fne/network/DiagNetwork.cpp +++ b/src/fne/network/DiagNetwork.cpp @@ -214,9 +214,7 @@ void DiagNetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip) { - UInt8Array __rawPayload = std::make_unique(req->length - 11U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, req->length - 11U); + DECLARE_UINT8_ARRAY(rawPayload, req->length - 11U); ::memcpy(rawPayload, req->buffer + 11U, req->length - 11U); std::string payload(rawPayload, rawPayload + (req->length - 11U)); @@ -281,9 +279,7 @@ void DiagNetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip) { - UInt8Array __rawPayload = std::make_unique(req->length - 11U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, req->length - 11U); + DECLARE_UINT8_ARRAY(rawPayload, req->length - 11U); ::memcpy(rawPayload, req->buffer + 11U, req->length - 11U); std::string payload(rawPayload, rawPayload + (req->length - 11U)); @@ -380,35 +376,24 @@ void DiagNetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip && connection->isExternalPeer() && connection->isPeerLink()) { - UInt8Array __rawPayload = std::make_unique(req->length); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, req->length); + DECLARE_UINT8_ARRAY(rawPayload, req->length); ::memcpy(rawPayload, req->buffer, req->length); // Utils::dump(1U, "Raw Payload", rawPayload, req->length); - uint8_t curBlock = rawPayload[8U]; - uint8_t blockCnt = rawPayload[9U]; - if (network->m_peerLinkActPkt.find(peerId) == network->m_peerLinkActPkt.end()) { - network->m_peerLinkActPkt.insert(peerId, FNENetwork::PLActPeerPkt()); + network->m_peerLinkActPkt.insert(peerId, FNENetwork::PacketBufferEntry()); - FNENetwork::PLActPeerPkt& pkt = network->m_peerLinkActPkt[peerId]; - pkt.fragments = std::unordered_map(); + FNENetwork::PacketBufferEntry& pkt = network->m_peerLinkActPkt[peerId]; + pkt.buffer = new PacketBuffer(true, "Peer-Link, Active Peer List"); pkt.streamId = streamId; pkt.locked = false; } else { - FNENetwork::PLActPeerPkt& pkt = network->m_peerLinkActPkt[peerId]; + FNENetwork::PacketBufferEntry& pkt = network->m_peerLinkActPkt[peerId]; if (!pkt.locked && pkt.streamId != streamId) { LogError(LOG_NET, "PEER %u Peer-Link, Active Peer List, stream ID mismatch, expected %u, got %u", peerId, pkt.streamId, streamId); - - for (auto& frag : pkt.fragments) { - if (frag.second != nullptr) - delete[] frag.second; - } - - pkt.fragments = std::unordered_map(); + pkt.buffer->clear(); pkt.streamId = streamId; } @@ -418,7 +403,7 @@ void DiagNetwork::taskNetworkRx(NetPacketRequest* req) } } - FNENetwork::PLActPeerPkt& pkt = network->m_peerLinkActPkt[peerId]; + FNENetwork::PacketBufferEntry& pkt = network->m_peerLinkActPkt[peerId]; if (pkt.locked) { while (pkt.locked) Thread::sleep(1U); @@ -426,106 +411,50 @@ void DiagNetwork::taskNetworkRx(NetPacketRequest* req) pkt.locked = true; - // if this is the first block store sizes and initialize temp buffer - if (curBlock == 0U) { - uint32_t size = __GET_UINT32(rawPayload, 0U); - uint32_t compressedSize = __GET_UINT32(rawPayload, 4U); - - FNENetwork::PLActPeerPkt& pkt = network->m_peerLinkActPkt[peerId]; - pkt.size = size; - pkt.compressedSize = compressedSize; - } - - // scope is intentional - { - pkt.lastBlock = curBlock; - uint8_t* buffer = nullptr; - if (pkt.size < PEER_LINK_BLOCK_SIZE) - buffer = new uint8_t[PEER_LINK_BLOCK_SIZE + 1U]; - else - buffer = new uint8_t[pkt.size + 1U]; - - ::memcpy(buffer, rawPayload + 10U, PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Block Payload", buffer, PEER_LINK_BLOCK_SIZE); - pkt.fragments.insert({curBlock, buffer}); - } - - LogInfoEx(LOG_NET, "PEER %u Peer-Link, Active Peer List, block %u of %u, rxFragments = %u, streamId = %u", peerId, curBlock, blockCnt, pkt.fragments.size(), streamId); - - // do we have all the blocks? - if (pkt.fragments.size() == blockCnt + 1U) { - uint8_t* buffer = nullptr; - if (pkt.size == 0U) { - LogError(LOG_NET, "PEER %u Peer-Link, Active Peer List, error missing size information", peerId); - goto pl_act_cleanup; - } - - if (pkt.compressedSize == 0U) { - LogError(LOG_NET, "PEER %u Peer-Link, Active Peer List, error missing compressed size information", peerId); - goto pl_act_cleanup; - } - - buffer = new uint8_t[pkt.size + 1U]; - ::memset(buffer, 0x00U, pkt.size + 1U); - if (pkt.fragments.size() == 1U) { - ::memcpy(buffer, pkt.fragments[0U], pkt.size); - } else { - for (uint8_t i = 0U; i < pkt.fragments.size(); i++) { - uint32_t offs = i * PEER_LINK_BLOCK_SIZE; - ::memcpy(buffer + offs, pkt.fragments[i], PEER_LINK_BLOCK_SIZE); + uint32_t decompressedLen = 0U; + uint8_t* decompressed = nullptr; + + if (pkt.buffer->decode(rawPayload, &decompressed, &decompressedLen)) { + std::string payload(decompressed + 8U, decompressed + decompressedLen); + + // parse JSON body + json::value v; + std::string err = json::parse(v, payload); + if (!err.empty()) { + LogError(LOG_NET, "PEER %u error parsing active peer list, %s", peerId, err.c_str()); + pkt.buffer->clear(); + pkt.streamId = 0U; + if (decompressed != nullptr) { + delete[] decompressed; } + network->m_peerLinkActPkt.erase(peerId); + break; } - - // Utils::dump(1U, "Peer-Link Active Peer List", buffer, pkt.size + 1U); - - // scope is intentional - { - uint32_t decompressedLen = 0U; - uint8_t* decompressed = Compression::decompress(buffer, pkt.compressedSize, &decompressedLen); - - // check that we got the appropriate data - if (decompressedLen == pkt.size && decompressed != nullptr) { - std::string payload(decompressed + 8U, decompressed + decompressedLen); - - // parse JSON body - json::value v; - std::string err = json::parse(v, payload); - if (!err.empty()) { - LogError(LOG_NET, "PEER %u error parsing active peer list, %s", peerId, err.c_str()); - break; - } - else { - // ensure parsed JSON is an array - if (!v.is()) { - LogError(LOG_NET, "PEER %u error parsing active peer list, data was not valid", peerId); - break; - } - else { - json::array arr = v.get(); - LogInfoEx(LOG_NET, "PEER %u Peer-Link, Active Peer List, updating %u peer entries", peerId, arr.size()); - network->m_peerLinkPeers[peerId] = arr; - } + else { + // ensure parsed JSON is an array + if (!v.is()) { + LogError(LOG_NET, "PEER %u error parsing active peer list, data was not valid", peerId); + pkt.buffer->clear(); + pkt.streamId = 0U; + if (decompressed != nullptr) { + delete[] decompressed; } + network->m_peerLinkActPkt.erase(peerId); + break; } else { - LogError(LOG_NET, "PEER %u Peer-Link, error decompressed list, was not of expected size! %u != %u", peerId, decompressedLen, pkt.size); + json::array arr = v.get(); + LogInfoEx(LOG_NET, "PEER %u Peer-Link, Active Peer List, updating %u peer entries", peerId, arr.size()); + network->m_peerLinkPeers[peerId] = arr; } } - pl_act_cleanup: - pkt.size = 0U; - pkt.compressedSize = 0U; - - if (buffer != nullptr) - delete[] buffer; - for (auto& frag : pkt.fragments) { - if (frag.second != nullptr) - delete[] frag.second; - } - - pkt.fragments = std::unordered_map(); + pkt.buffer->clear(); + delete pkt.buffer; pkt.streamId = 0U; - + if (decompressed != nullptr) { + delete[] decompressed; + } network->m_peerLinkActPkt.erase(peerId); } else { pkt.locked = false; diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index 9ffb7843..9aca8e7a 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -39,6 +39,8 @@ const uint32_t MAX_HARD_CONN_CAP = 250U; const uint8_t MAX_PEER_LIST_BEFORE_FLUSH = 10U; const uint32_t MAX_RID_LIST_CHUNK = 50U; +const uint32_t MAX_MISSED_ACL_UPDATES = 10U; + const uint64_t PACKET_LATE_TIME = 200U; // 200ms // --------------------------------------------------------------------------- @@ -82,7 +84,7 @@ FNENetwork::FNENetwork(HostFNE* host, const std::string& address, uint16_t port, m_peerLinkKeyQueue(), m_peerLinkActPkt(), m_maintainenceTimer(1000U, pingTime), - m_updateLookupTime(updateLookupTime * 60U), + m_updateLookupTimer(1000U, (updateLookupTime * 60U)), m_softConnLimit(0U), m_callInProgress(false), m_disallowAdjStsBcast(false), @@ -383,25 +385,44 @@ void FNENetwork::clock(uint32_t ms) } } - // send ACL updates forcibly to any Peer-Link peers + m_maintainenceTimer.start(); + } + + m_updateLookupTimer.clock(ms); + if (m_updateLookupTimer.isRunning() && m_updateLookupTimer.hasExpired()) { + // send ACL updates to peers + m_peers.lock(false); for (auto peer : m_peers) { uint32_t id = peer.first; FNEPeerConnection* connection = peer.second; if (connection != nullptr) { + // if this connection is a peer link *always* send the update -- no stream checking if (connection->connected() && connection->isPeerLink()) { - // does this peer need an ACL update? - uint64_t dt = connection->lastACLUpdate() + (m_updateLookupTime * 1000); - if (dt < now) { - LogInfoEx(LOG_NET, "PEER %u (%s) updating ACL list, dt = %u, now = %u", id, connection->identity().c_str(), - dt, now); + LogInfoEx(LOG_NET, "PEER %u (%s), Peer-Link, updating ACL list", id, connection->identity().c_str()); + + peerACLUpdate(id); + connection->missedACLUpdates(0U); + continue; + } + + if (connection->connected()) { + if ((connection->streamCount() <= 1) || (connection->missedACLUpdates() > MAX_MISSED_ACL_UPDATES)) { + LogInfoEx(LOG_NET, "PEER %u (%s) updating ACL list", id, connection->identity().c_str()); peerACLUpdate(id); - connection->lastACLUpdate(now); + connection->missedACLUpdates(0U); + } else { + uint32_t missed = connection->missedACLUpdates(); + missed++; + + LogInfoEx(LOG_NET, "PEER %u (%s) skipped for ACL update, traffic in progress", id, connection->identity().c_str()); + connection->missedACLUpdates(missed); } } } } + m_peers.unlock(); - m_maintainenceTimer.start(); + m_updateLookupTimer.start(); } m_parrotDelayTimer.clock(ms); @@ -445,6 +466,7 @@ bool FNENetwork::open() m_status = NET_STAT_MST_RUNNING; m_maintainenceTimer.start(); + m_updateLookupTimer.start(); m_socket = new udp::Socket(m_address, m_port); @@ -475,11 +497,12 @@ void FNENetwork::close() uint32_t streamId = createStreamId(); for (auto peer : m_peers) { - writePeer(peer.first, { NET_FUNC::MST_CLOSING, NET_SUBFUNC::NOP }, buffer, 1U, RTP_END_OF_CALL_SEQ, streamId, false); + writePeer(peer.first, { NET_FUNC::MST_DISC, NET_SUBFUNC::NOP }, buffer, 1U, RTP_END_OF_CALL_SEQ, streamId, false); } } m_maintainenceTimer.stop(); + m_updateLookupTimer.stop(); // stop thread pool m_threadPool.stop(); @@ -768,15 +791,13 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) if (connection->connectionState() == NET_STAT_WAITING_AUTHORISATION) { // get the hash from the frame message - UInt8Array __hash = std::make_unique(req->length - 8U); - uint8_t* hash = __hash.get(); - ::memset(hash, 0x00U, req->length - 8U); + DECLARE_UINT8_ARRAY(hash, req->length - 8U); ::memcpy(hash, req->buffer + 8U, req->length - 8U); // generate our own hash uint8_t salt[4U]; ::memset(salt, 0x00U, 4U); - __SET_UINT32(connection->salt(), salt, 0U); + SET_UINT32(connection->salt(), salt, 0U); std::string passwordForPeer = network->m_password; @@ -875,9 +896,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) connection->lastPing(now); if (connection->connectionState() == NET_STAT_WAITING_CONFIG) { - UInt8Array __rawPayload = std::make_unique(req->length - 8U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, req->length - 8U); + DECLARE_UINT8_ARRAY(rawPayload, req->length - 8U); ::memcpy(rawPayload, req->buffer + 8U, req->length - 8U); std::string payload(rawPayload, rawPayload + (req->length - 8U)); @@ -904,7 +923,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) connection->connected(true); connection->pingsReceived(0U); connection->lastPing(now); - connection->lastACLUpdate(now); + connection->missedACLUpdates(0U); network->m_peers[peerId] = connection; // attach extra notification data to the RPTC ACK to notify the peer of @@ -997,7 +1016,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) } break; - case NET_FUNC::RPT_CLOSING: // Repeater Closing (Disconnect) + case NET_FUNC::RPT_DISC: // Repeater Disconnect { if (peerId > 0 && (network->m_peers.find(peerId) != network->m_peers.end())) { FNEPeerConnection* connection = network->m_peers[peerId]; @@ -1006,7 +1025,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip) { - LogInfoEx(LOG_NET, "PEER %u (%s) is closing down", peerId, connection->identity().c_str()); + LogInfoEx(LOG_NET, "PEER %u (%s) disconnected", peerId, connection->identity().c_str()); network->erasePeer(peerId); delete connection; } @@ -1030,22 +1049,6 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) connection->pingsReceived(pingsRx); connection->lastPing(now); - // does this peer need an ACL update? - uint64_t dt = connection->lastACLUpdate() + (network->m_updateLookupTime * 1000); - if (dt < now) { - if (connection->streamCount() <= 1 || ((dt * 2) < now)) { - if ((dt * 2) < now) - LogInfoEx(LOG_NET, "PEER %u (%s) late updating ACL list, dt = %u, ddt = %u, now = %u", peerId, connection->identity().c_str(), - dt, dt * 2, now); - else - LogInfoEx(LOG_NET, "PEER %u (%s) updating ACL list, dt = %u, now = %u", peerId, connection->identity().c_str(), - dt, now); - - network->peerACLUpdate(peerId); - connection->lastACLUpdate(now); - } - } - uint8_t payload[8U]; ::memset(payload, 0x00U, 8U); @@ -1084,8 +1087,8 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip) { - uint32_t srcId = __GET_UINT16(req->buffer, 11U); // Source Address - uint32_t dstId = __GET_UINT16(req->buffer, 15U); // Destination Address + uint32_t srcId = GET_UINT24(req->buffer, 11U); // Source Address + uint32_t dstId = GET_UINT24(req->buffer, 15U); // Destination Address uint8_t slot = req->buffer[19U]; @@ -1261,104 +1264,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) break; case NET_FUNC::TRANSFER: // Transfer - { - // are activity/diagnostic transfers occurring from the alternate port? - if (network->m_host->m_useAlternatePortForDiagnostics) { - break; // for performance and other reasons -- simply ignore the entire NET_FUNC::TRANSFER at this point - // since they should be coming from the alternate port anyway - } - - // process incoming message subfunction opcodes - switch (req->fneHeader.getSubFunction()) { - case NET_SUBFUNC::TRANSFER_SUBFUNC_ACTIVITY: // Peer Activity Log Transfer - { - if (network->m_allowActivityTransfer) { - if (peerId > 0 && (network->m_peers.find(peerId) != network->m_peers.end())) { - FNEPeerConnection* connection = network->m_peers[peerId]; - if (connection != nullptr) { - std::string ip = udp::Socket::address(req->address); - - // validate peer (simple validation really) - if (connection->connected() && connection->address() == ip) { - UInt8Array __rawPayload = std::make_unique(req->length - 11U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, req->length - 11U); - ::memcpy(rawPayload, req->buffer + 11U, req->length - 11U); - std::string payload(rawPayload, rawPayload + (req->length - 11U)); - - ::ActivityLog("%.9u (%8s) %s", peerId, connection->identity().c_str(), payload.c_str()); - - // report activity log to InfluxDB - if (network->m_enableInfluxDB) { - influxdb::QueryBuilder() - .meas("activity") - .tag("peerId", std::to_string(peerId)) - .field("identity", connection->identity()) - .field("msg", payload) - .timestamp(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()) - .requestAsync(network->m_influxServer); - } - } - else { - network->writePeerNAK(peerId, streamId, TAG_TRANSFER_ACT_LOG, NET_CONN_NAK_FNE_UNAUTHORIZED); - } - } - } - } - } - break; - - case NET_SUBFUNC::TRANSFER_SUBFUNC_DIAG: // Peer Diagnostic Log Transfer - { - if (network->m_allowDiagnosticTransfer) { - if (peerId > 0 && (network->m_peers.find(peerId) != network->m_peers.end())) { - FNEPeerConnection* connection = network->m_peers[peerId]; - if (connection != nullptr) { - std::string ip = udp::Socket::address(req->address); - - // validate peer (simple validation really) - if (connection->connected() && connection->address() == ip) { - UInt8Array __rawPayload = std::make_unique(req->length - 11U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, req->length - 11U); - ::memcpy(rawPayload, req->buffer + 11U, req->length - 11U); - std::string payload(rawPayload, rawPayload + (req->length - 11U)); - - bool currState = g_disableTimeDisplay; - g_disableTimeDisplay = true; - ::Log(9999U, nullptr, nullptr, 0U, nullptr, "%.9u (%8s) %s", peerId, connection->identity().c_str(), payload.c_str()); - g_disableTimeDisplay = currState; - - // report diagnostic log to InfluxDB - if (network->m_enableInfluxDB) { - influxdb::QueryBuilder() - .meas("diag") - .tag("peerId", std::to_string(peerId)) - .field("identity", connection->identity()) - .field("msg", payload) - .timestamp(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()) - .requestAsync(network->m_influxServer); - } - } - else { - network->writePeerNAK(peerId, streamId, TAG_TRANSFER_DIAG_LOG, NET_CONN_NAK_FNE_UNAUTHORIZED); - } - } - } - } - } - break; - - case NET_SUBFUNC::TRANSFER_SUBFUNC_STATUS: // Peer Status Transfer - // main traffic port status transfers aren't supported for performance reasons - break; - - default: - network->writePeerNAK(peerId, streamId, TAG_TRANSFER, NET_CONN_NAK_ILLEGAL_PACKET); - Utils::dump("unknown transfer opcode from the peer", req->buffer, req->length); - break; - } - } + // transfer command is not supported for performance reasons on the main traffic port break; case NET_FUNC::ANNOUNCE: // Announce @@ -1379,8 +1285,8 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip && aff != nullptr) { - uint32_t srcId = __GET_UINT16(req->buffer, 0U); // Source Address - uint32_t dstId = __GET_UINT16(req->buffer, 3U); // Destination Address + uint32_t srcId = GET_UINT24(req->buffer, 0U); // Source Address + uint32_t dstId = GET_UINT24(req->buffer, 3U); // Destination Address aff->groupUnaff(srcId); aff->groupAff(srcId, dstId); @@ -1418,7 +1324,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip && aff != nullptr) { - uint32_t srcId = __GET_UINT16(req->buffer, 0U); // Source Address + uint32_t srcId = GET_UINT24(req->buffer, 0U); // Source Address aff->unitReg(srcId); // attempt to repeat traffic to Peer-Link masters @@ -1454,7 +1360,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip && aff != nullptr) { - uint32_t srcId = __GET_UINT16(req->buffer, 0U); // Source Address + uint32_t srcId = GET_UINT24(req->buffer, 0U); // Source Address aff->unitDereg(srcId); // attempt to repeat traffic to Peer-Link masters @@ -1491,7 +1397,7 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) // validate peer (simple validation really) if (connection->connected() && connection->address() == ip && aff != nullptr) { - uint32_t srcId = __GET_UINT16(req->buffer, 0U); // Source Address + uint32_t srcId = GET_UINT24(req->buffer, 0U); // Source Address aff->groupUnaff(srcId); // attempt to repeat traffic to Peer-Link masters @@ -1533,11 +1439,11 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) aff->clearGroupAff(0U, true); // update TGID lists - uint32_t len = __GET_UINT32(req->buffer, 0U); + uint32_t len = GET_UINT32(req->buffer, 0U); uint32_t offs = 4U; for (uint32_t i = 0; i < len; i++) { - uint32_t srcId = __GET_UINT16(req->buffer, offs); - uint32_t dstId = __GET_UINT16(req->buffer, offs + 4U); + uint32_t srcId = GET_UINT24(req->buffer, offs); + uint32_t dstId = GET_UINT24(req->buffer, offs + 4U); aff->groupAff(srcId, dstId); offs += 8U; @@ -1577,10 +1483,10 @@ void FNENetwork::taskNetworkRx(NetPacketRequest* req) std::vector vcPeers; // update peer association - uint32_t len = __GET_UINT32(req->buffer, 0U); + uint32_t len = GET_UINT32(req->buffer, 0U); uint32_t offs = 4U; for (uint32_t i = 0; i < len; i++) { - uint32_t vcPeerId = __GET_UINT32(req->buffer, offs); + uint32_t vcPeerId = GET_UINT32(req->buffer, offs); if (vcPeerId > 0 && (network->m_peers.find(vcPeerId) != network->m_peers.end())) { FNEPeerConnection* vcConnection = network->m_peers[vcPeerId]; if (vcConnection != nullptr) { @@ -1816,7 +1722,7 @@ void FNENetwork::setupRepeaterLogin(uint32_t peerId, uint32_t streamId, FNEPeerC // transmit salt to peer uint8_t salt[4U]; ::memset(salt, 0x00U, 4U); - __SET_UINT32(connection->salt(), salt, 0U); + SET_UINT32(connection->salt(), salt, 0U); writePeerACK(peerId, streamId, salt, 4U); LogInfoEx(LOG_NET, "PEER %u RPTL ACK, challenge response sent for login", peerId); @@ -1910,51 +1816,19 @@ void FNENetwork::writeWhitelistRIDs(uint32_t peerId, uint32_t streamId, bool isE // convert to a byte array uint32_t len = b.str().size(); - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, len); + DECLARE_UINT8_ARRAY(buffer, len); ::memcpy(buffer, b.str().data(), len); - uint32_t compressedLen = 0U; - uint8_t* compressed = Compression::compress((uint8_t*)buffer, len, &compressedLen); - - if (compressed != nullptr) { - // transmit TGIDs - uint8_t blockCnt = (compressedLen / PEER_LINK_BLOCK_SIZE) + (compressedLen % PEER_LINK_BLOCK_SIZE ? 1U : 0U); - uint32_t offs = 0U; - for (uint8_t i = 0U; i < blockCnt; i++) { - // build dataset - uint16_t bufSize = 10U + (PEER_LINK_BLOCK_SIZE); - UInt8Array __payload = std::make_unique(bufSize); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, bufSize); - - if (i == 0U) { - __SET_UINT32(len, payload, 0U); - __SET_UINT32(compressedLen, payload, 4U); - } - - payload[8U] = i; - payload[9U] = blockCnt - 1U; - - uint32_t blockSize = PEER_LINK_BLOCK_SIZE; - if (offs + PEER_LINK_BLOCK_SIZE > compressedLen) - blockSize = PEER_LINK_BLOCK_SIZE - ((offs + PEER_LINK_BLOCK_SIZE) - compressedLen); - - ::memcpy(payload + 10U, compressed + offs, blockSize); - - if (m_debug) - Utils::dump(1U, "Peer-Link RID Block Payload", payload, bufSize); - - offs += PEER_LINK_BLOCK_SIZE; + PacketBuffer pkt(true, "Peer-Link, RID List"); + pkt.encode((uint8_t*)buffer, len); + LogInfoEx(LOG_NET, "PEER %u Peer-Link, RID List, blocks %u, streamId = %u", peerId, pkt.fragments.size(), streamId); + if (pkt.fragments.size() > 0U) { + for (auto frag : pkt.fragments) { writePeer(peerId, { NET_FUNC::PEER_LINK, NET_SUBFUNC::PL_RID_LIST }, - payload, bufSize, 0U, streamId, false, true, true); + frag.second->data, FRAG_SIZE, 0U, streamId, false, true, true); + Thread::sleep(60U); // pace block transmission } - - connection->lastPing(now); - } else { - LogError(LOG_NET, "PEER %u error compressing RID list", peerId); } } @@ -2002,11 +1876,9 @@ void FNENetwork::writeWhitelistRIDs(uint32_t peerId, uint32_t streamId, bool isE // build dataset uint16_t bufSize = 4U + (listSize * 4U); - UInt8Array __payload = std::make_unique(bufSize); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, bufSize); + DECLARE_UINT8_ARRAY(payload, bufSize); - __SET_UINT32(listSize, payload, 0U); + SET_UINT32(listSize, payload, 0U); // write whitelisted IDs to whitelist payload uint32_t offs = 4U; @@ -2017,7 +1889,7 @@ void FNENetwork::writeWhitelistRIDs(uint32_t peerId, uint32_t streamId, bool isE LogDebug(LOG_NET, "PEER %u (%s) whitelisting RID %u (%d / %d)", peerId, connection->identity().c_str(), id, i, j); - __SET_UINT32(id, payload, offs); + SET_UINT32(id, payload, offs); offs += 4U; } @@ -2076,11 +1948,9 @@ void FNENetwork::writeBlacklistRIDs(uint32_t peerId, uint32_t streamId) // build dataset uint16_t bufSize = 4U + (listSize * 4U); - UInt8Array __payload = std::make_unique(bufSize); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, bufSize); + DECLARE_UINT8_ARRAY(payload, bufSize); - __SET_UINT32(listSize, payload, 0U); + SET_UINT32(listSize, payload, 0U); // write blacklisted IDs to blacklist payload uint32_t offs = 4U; @@ -2091,7 +1961,7 @@ void FNENetwork::writeBlacklistRIDs(uint32_t peerId, uint32_t streamId) LogDebug(LOG_NET, "PEER %u (%s) blacklisting RID %u (%d / %d)", peerId, connection->identity().c_str(), id, i, j); - __SET_UINT32(id, payload, offs); + SET_UINT32(id, payload, offs); offs += 4U; } @@ -2135,51 +2005,19 @@ void FNENetwork::writeTGIDs(uint32_t peerId, uint32_t streamId, bool isExternalP // convert to a byte array uint32_t len = b.str().size(); - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, len); + DECLARE_UINT8_ARRAY(buffer, len); ::memcpy(buffer, b.str().data(), len); - uint32_t compressedLen = 0U; - uint8_t* compressed = Compression::compress((uint8_t*)buffer, len, &compressedLen); - - if (compressed != nullptr) { - // transmit TGIDs - uint8_t blockCnt = (compressedLen / PEER_LINK_BLOCK_SIZE) + (compressedLen % PEER_LINK_BLOCK_SIZE ? 1U : 0U); - uint32_t offs = 0U; - for (uint8_t i = 0U; i < blockCnt; i++) { - // build dataset - uint16_t bufSize = 10U + (PEER_LINK_BLOCK_SIZE); - UInt8Array __payload = std::make_unique(bufSize); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, bufSize); - - if (i == 0U) { - __SET_UINT32(len, payload, 0U); - __SET_UINT32(compressedLen, payload, 4U); - } - - payload[8U] = i; - payload[9U] = blockCnt - 1U; - - uint32_t blockSize = PEER_LINK_BLOCK_SIZE; - if (offs + PEER_LINK_BLOCK_SIZE > compressedLen) - blockSize = PEER_LINK_BLOCK_SIZE - ((offs + PEER_LINK_BLOCK_SIZE) - compressedLen); - - ::memcpy(payload + 10U, compressed + offs, blockSize); - - if (m_debug) - Utils::dump(1U, "Peer-Link TGID Block Payload", payload, bufSize); - - offs += PEER_LINK_BLOCK_SIZE; + PacketBuffer pkt(true, "Peer-Link, TGID List"); + pkt.encode((uint8_t*)buffer, len); + LogInfoEx(LOG_NET, "PEER %u Peer-Link, TGID List, blocks %u, streamId = %u", peerId, pkt.fragments.size(), streamId); + if (pkt.fragments.size() > 0U) { + for (auto frag : pkt.fragments) { writePeer(peerId, { NET_FUNC::PEER_LINK, NET_SUBFUNC::PL_TALKGROUP_LIST }, - payload, bufSize, 0U, streamId, false, true, true); + frag.second->data, FRAG_SIZE, 0U, streamId, false, true, true); + Thread::sleep(60U); // pace block transmission } - - connection->lastPing(now); - } else { - LogError(LOG_NET, "PEER %u error compressing TGID list", peerId); } } @@ -2238,11 +2076,9 @@ void FNENetwork::writeTGIDs(uint32_t peerId, uint32_t streamId, bool isExternalP } // build dataset - UInt8Array __payload = std::make_unique(4U + (tgidList.size() * 5U)); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, 4U + (tgidList.size() * 5U)); + DECLARE_UINT8_ARRAY(payload, 4U + (tgidList.size() * 5U)); - __SET_UINT32(tgidList.size(), payload, 0U); + SET_UINT32(tgidList.size(), payload, 0U); // write talkgroup IDs to active TGID payload uint32_t offs = 4U; @@ -2252,7 +2088,7 @@ void FNENetwork::writeTGIDs(uint32_t peerId, uint32_t streamId, bool isExternalP LogDebug(LOG_NET, "PEER %u (%s) activating TGID %u TS %u", peerId, peerIdentity.c_str(), tg.first, tg.second); } - __SET_UINT32(tg.first, payload, offs); + SET_UINT32(tg.first, payload, offs); payload[offs + 4U] = tg.second; offs += 5U; } @@ -2299,11 +2135,9 @@ void FNENetwork::writeDeactiveTGIDs(uint32_t peerId, uint32_t streamId) } // build dataset - UInt8Array __payload = std::make_unique(4U + (tgidList.size() * 5U)); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, 4U + (tgidList.size() * 5U)); + DECLARE_UINT8_ARRAY(payload, 4U + (tgidList.size() * 5U)); - __SET_UINT32(tgidList.size(), payload, 0U); + SET_UINT32(tgidList.size(), payload, 0U); // write talkgroup IDs to deactive TGID payload uint32_t offs = 4U; @@ -2313,7 +2147,7 @@ void FNENetwork::writeDeactiveTGIDs(uint32_t peerId, uint32_t streamId) LogDebug(LOG_NET, "PEER %u (%s) deactivating TGID %u TS %u", peerId, peerIdentity.c_str(), tg.first, tg.second); } - __SET_UINT32(tg.first, payload, offs); + SET_UINT32(tg.first, payload, offs); payload[offs + 4U] = tg.second; offs += 5U; } @@ -2349,51 +2183,19 @@ void FNENetwork::writePeerList(uint32_t peerId, uint32_t streamId) // convert to a byte array uint32_t len = b.str().size(); - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, len); + DECLARE_UINT8_ARRAY(buffer, len); ::memcpy(buffer, b.str().data(), len); - uint32_t compressedLen = 0U; - uint8_t* compressed = Compression::compress((uint8_t*)buffer, len, &compressedLen); - - if (compressed != nullptr) { - // transmit PIDs - uint8_t blockCnt = (compressedLen / PEER_LINK_BLOCK_SIZE) + (compressedLen % PEER_LINK_BLOCK_SIZE ? 1U : 0U); - uint32_t offs = 0U; - for (uint8_t i = 0U; i < blockCnt; i++) { - // build dataset - uint16_t bufSize = 10U + (PEER_LINK_BLOCK_SIZE); - UInt8Array __payload = std::make_unique(bufSize); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, bufSize); - - if (i == 0U) { - __SET_UINT32(len, payload, 0U); - __SET_UINT32(compressedLen, payload, 4U); - } - - payload[8U] = i; - payload[9U] = blockCnt - 1U; - - uint32_t blockSize = PEER_LINK_BLOCK_SIZE; - if (offs + PEER_LINK_BLOCK_SIZE > compressedLen) - blockSize = PEER_LINK_BLOCK_SIZE - ((offs + PEER_LINK_BLOCK_SIZE) - compressedLen); - - ::memcpy(payload + 10U, compressed + offs, blockSize); - - if (m_debug) - Utils::dump(1U, "Peer-Link Peer List Block Payload", payload, bufSize); - - offs += PEER_LINK_BLOCK_SIZE; + PacketBuffer pkt(true, "Peer-Link, PID List"); + pkt.encode((uint8_t*)buffer, len); + LogInfoEx(LOG_NET, "PEER %u Peer-Link, PID List, blocks %u, streamId = %u", peerId, pkt.fragments.size(), streamId); + if (pkt.fragments.size() > 0U) { + for (auto frag : pkt.fragments) { writePeer(peerId, { NET_FUNC::PEER_LINK, NET_SUBFUNC::PL_PEER_LIST }, - payload, bufSize, 0U, streamId, false, true, true); + frag.second->data, FRAG_SIZE, 0U, streamId, false, true, true); + Thread::sleep(60U); // pace block transmission } - - connection->lastPing(now); - } else { - LogError(LOG_NET, "PEER %u error compressing PID list", peerId); } } @@ -2414,9 +2216,9 @@ bool FNENetwork::writePeerICC(uint32_t peerId, uint32_t streamId, NET_SUBFUNC::E uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); - __SET_UINT32(peerId, buffer, 6U); // Peer ID + SET_UINT32(peerId, buffer, 6U); // Peer ID buffer[10U] = (uint8_t)command; // In-Call Control Command - __SET_UINT16(dstId, buffer, 11U); // Destination ID + SET_UINT24(dstId, buffer, 11U); // Destination ID buffer[14U] = slotNo; // DMR Slot No return writePeer(peerId, { NET_FUNC::INCALL_CTRL, subFunc }, buffer, 15U, RTP_END_OF_CALL_SEQ, streamId, false); @@ -2482,7 +2284,7 @@ bool FNENetwork::writePeerACK(uint32_t peerId, uint32_t streamId, const uint8_t* uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); - __SET_UINT32(peerId, buffer, 0U); // Peer ID + SET_UINT32(peerId, buffer, 0U); // Peer ID if (data != nullptr && length > 0U) { ::memcpy(buffer + 6U, data, length); @@ -2541,8 +2343,8 @@ bool FNENetwork::writePeerNAK(uint32_t peerId, uint32_t streamId, const char* ta uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); - __SET_UINT32(peerId, buffer, 6U); // Peer ID - __SET_UINT16B((uint16_t)reason, buffer, 10U); // Reason + SET_UINT32(peerId, buffer, 6U); // Peer ID + SET_UINT16((uint16_t)reason, buffer, 10U); // Reason logPeerNAKReason(peerId, tag, reason); return writePeer(peerId, { NET_FUNC::NAK, NET_SUBFUNC::NOP }, buffer, 10U, RTP_END_OF_CALL_SEQ, streamId, false); @@ -2560,8 +2362,8 @@ bool FNENetwork::writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REA uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); - __SET_UINT32(peerId, buffer, 6U); // Peer ID - __SET_UINT16B((uint16_t)reason, buffer, 10U); // Reason + SET_UINT32(peerId, buffer, 6U); // Peer ID + SET_UINT16((uint16_t)reason, buffer, 10U); // Reason logPeerNAKReason(peerId, tag, reason); LogWarning(LOG_NET, "PEER %u NAK %s -> %s:%u", peerId, tag, udp::Socket::address(addr).c_str(), udp::Socket::port(addr)); diff --git a/src/fne/network/FNENetwork.h b/src/fne/network/FNENetwork.h index db18a3de..d19baa64 100644 --- a/src/fne/network/FNENetwork.h +++ b/src/fne/network/FNENetwork.h @@ -33,6 +33,7 @@ #include "common/lookups/TalkgroupRulesLookup.h" #include "common/lookups/PeerListLookup.h" #include "common/network/Network.h" +#include "common/network/PacketBuffer.h" #include "common/ThreadPool.h" #include "fne/network/influxdb/InfluxDB.h" #include "fne/CryptoContainer.h" @@ -116,7 +117,7 @@ namespace network m_connectionState(NET_STAT_INVALID), m_pingsReceived(0U), m_lastPing(0U), - m_lastACLUpdate(0U), + m_missedACLUpdates(0U), m_isExternalPeer(false), m_isConventionalPeer(false), m_isSysView(false), @@ -145,7 +146,7 @@ namespace network m_connectionState(NET_STAT_INVALID), m_pingsReceived(0U), m_lastPing(0U), - m_lastACLUpdate(0U), + m_missedACLUpdates(0U), m_isExternalPeer(false), m_isConventionalPeer(false), m_isSysView(false), @@ -280,84 +281,84 @@ namespace network /** * @brief Peer ID. */ - __PROPERTY_PLAIN(uint32_t, id); + DECLARE_PROPERTY_PLAIN(uint32_t, id); /** * @brief Peer Identity. */ - __PROPERTY_PLAIN(std::string, identity); + DECLARE_PROPERTY_PLAIN(std::string, identity); /** * @brief Control Channel Peer ID. */ - __PROPERTY_PLAIN(uint32_t, ccPeerId); + DECLARE_PROPERTY_PLAIN(uint32_t, ccPeerId); /** * @brief Unix socket storage containing the connected address. */ - __PROPERTY_PLAIN(sockaddr_storage, socketStorage); + DECLARE_PROPERTY_PLAIN(sockaddr_storage, socketStorage); /** * @brief Length of the sockaddr_storage structure. */ - __PROPERTY_PLAIN(uint32_t, sockStorageLen); + DECLARE_PROPERTY_PLAIN(uint32_t, sockStorageLen); /** * @brief */ - __PROPERTY_PLAIN(std::string, address); + DECLARE_PROPERTY_PLAIN(std::string, address); /** * @brief Port number peer connected with. */ - __PROPERTY_PLAIN(uint16_t, port); + DECLARE_PROPERTY_PLAIN(uint16_t, port); /** * @brief Salt value used for peer authentication. */ - __PROPERTY_PLAIN(uint32_t, salt); + DECLARE_PROPERTY_PLAIN(uint32_t, salt); /** * @brief Flag indicating whether or not the peer is connected. */ - __PROPERTY_PLAIN(bool, connected); + DECLARE_PROPERTY_PLAIN(bool, connected); /** * @brief Connection state. */ - __PROPERTY_PLAIN(NET_CONN_STATUS, connectionState); + DECLARE_PROPERTY_PLAIN(NET_CONN_STATUS, connectionState); /** * @brief Number of pings received. */ - __PROPERTY_PLAIN(uint32_t, pingsReceived); + DECLARE_PROPERTY_PLAIN(uint32_t, pingsReceived); /** * @brief Last ping received. */ - __PROPERTY_PLAIN(uint64_t, lastPing); + DECLARE_PROPERTY_PLAIN(uint64_t, lastPing); /** - * @brief Last ACL update sent. + * @brief Number of missed ACL updates. */ - __PROPERTY_PLAIN(uint64_t, lastACLUpdate); + DECLARE_PROPERTY_PLAIN(uint32_t, missedACLUpdates); /** * @brief Flag indicating this connection is from an external peer. */ - __PROPERTY_PLAIN(bool, isExternalPeer); + DECLARE_PROPERTY_PLAIN(bool, isExternalPeer); /** * @brief Flag indicating this connection is from an conventional peer. */ - __PROPERTY_PLAIN(bool, isConventionalPeer); + DECLARE_PROPERTY_PLAIN(bool, isConventionalPeer); /** * @brief Flag indicating this connection is from an SysView peer. */ - __PROPERTY_PLAIN(bool, isSysView); + DECLARE_PROPERTY_PLAIN(bool, isSysView); /** * @brief Flag indicating this connection is from an external peer that is peer link enabled. */ - __PROPERTY_PLAIN(bool, isPeerLink); + DECLARE_PROPERTY_PLAIN(bool, isPeerLink); /** * @brief JSON objecting containing peer configuration information. */ - __PROPERTY_PLAIN(json::object, config); + DECLARE_PROPERTY_PLAIN(json::object, config); private: std::timed_mutex m_streamSeqMutex; @@ -563,40 +564,27 @@ namespace network std::unordered_map m_peerLinkKeyQueue; /** - * @brief Represents a Peer-Link Active Peer List fragment packet. + * @brief Represents a packet buffer entry in a map. */ - class PLActPeerPkt { + class PacketBufferEntry { public: - /** - * @brief Compressed size of the packet. - */ - uint32_t compressedSize; - /** - * @brief Uncompressed size of the packet. - */ - uint32_t size; - - /** - * @brief Last block of the packet. - */ - uint8_t lastBlock; /** * @brief Stream ID of the packet. */ uint32_t streamId; /** - * @brief Packet fragments. + * @brief Packet fragment buffer. */ - std::unordered_map fragments; + PacketBuffer* buffer; bool locked; }; - concurrent::unordered_map m_peerLinkActPkt; + concurrent::unordered_map m_peerLinkActPkt; Timer m_maintainenceTimer; + Timer m_updateLookupTimer; - uint32_t m_updateLookupTime; uint32_t m_softConnLimit; bool m_callInProgress; diff --git a/src/fne/network/PeerNetwork.cpp b/src/fne/network/PeerNetwork.cpp index f4e70c74..6677afb3 100644 --- a/src/fne/network/PeerNetwork.cpp +++ b/src/fne/network/PeerNetwork.cpp @@ -36,15 +36,10 @@ PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t loc m_blockTrafficToTable(), m_pidLookup(nullptr), m_peerLink(false), - m_tgidCompressedSize(0U), - m_tgidSize(0U), - m_tgidBuffer(nullptr), - m_ridCompressedSize(0U), - m_ridSize(0U), - m_ridBuffer(nullptr), - m_pidCompressedSize(0U), - m_pidSize(0U), - m_pidBuffer(nullptr) + m_peerLinkSavesACL(false), + m_tgidPkt(true, "Peer-Link, TGID List"), + m_ridPkt(true, "Peer-Link, RID List"), + m_pidPkt(true, "Peer-Link, PID List") { assert(!address.empty()); assert(port > 0U); @@ -115,55 +110,25 @@ bool PeerNetwork::writePeerLinkPeers(json::array* peerList) std::string json = std::string(v.serialize()); size_t len = json.length() + 9U; - CharArray __buffer = std::make_unique(len); - char* buffer = __buffer.get(); + DECLARE_CHAR_ARRAY(buffer, len); ::memcpy(buffer + 0U, TAG_PEER_LINK, 4U); ::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str()); - uint32_t compressedLen = 0U; - uint8_t* compressed = Compression::compress((uint8_t*)buffer, len, &compressedLen); - if (compressed != nullptr) { - // transmit peer link active peer list - uint32_t streamId = createStreamId(); - uint8_t blockCnt = (compressedLen / PEER_LINK_BLOCK_SIZE) + (compressedLen % PEER_LINK_BLOCK_SIZE ? 1U : 0U); - uint32_t offs = 0U; - for (uint8_t i = 0U; i < blockCnt; i++) { - // build dataset - uint16_t bufSize = 10U + (PEER_LINK_BLOCK_SIZE); - UInt8Array __payload = std::make_unique(bufSize); - uint8_t* payload = __payload.get(); - ::memset(payload, 0x00U, bufSize); - - if (i == 0U) { - __SET_UINT32(len, payload, 0U); - __SET_UINT32(compressedLen, payload, 4U); - } - - payload[8U] = i; - payload[9U] = blockCnt - 1U; - - uint32_t blockSize = PEER_LINK_BLOCK_SIZE; - if (offs + PEER_LINK_BLOCK_SIZE > compressedLen) - blockSize = PEER_LINK_BLOCK_SIZE - ((offs + PEER_LINK_BLOCK_SIZE) - compressedLen); - - ::memcpy(payload + 10U, compressed + offs, blockSize); - - if (m_debug) - Utils::dump(1U, "Peer-Link Active Peer Payload", payload, bufSize); - - offs += PEER_LINK_BLOCK_SIZE; + PacketBuffer pkt(true, "Peer-Link, Active Peer List"); + pkt.encode((uint8_t*)buffer, len); + uint32_t streamId = createStreamId(); + LogInfoEx(LOG_NET, "PEER %u Peer-Link, Active Peer List, blocks %u, streamId = %u", m_peerId, pkt.fragments.size(), streamId); + if (pkt.fragments.size() > 0U) { + for (auto frag : pkt.fragments) { writeMaster({ NET_FUNC::PEER_LINK, NET_SUBFUNC::PL_ACT_PEER_LIST }, - payload, bufSize, RTP_END_OF_CALL_SEQ, streamId, false, true); + frag.second->data, FRAG_SIZE, RTP_END_OF_CALL_SEQ, streamId, false, true); Thread::sleep(60U); // pace block transmission } - - return true; - } else { - LogError(LOG_NET, "PEER %u error compressing active peer list", m_peerId); - return false; } + + return true; } return false; @@ -183,273 +148,171 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco switch (opcode.second) { case NET_SUBFUNC::PL_TALKGROUP_LIST: { - uint8_t curBlock = data[8U]; - uint8_t blockCnt = data[9U]; - - // if this is the first block store sizes and initialize temp buffer - if (curBlock == 0U) { - m_tgidSize = __GET_UINT32(data, 0U); - m_tgidCompressedSize = __GET_UINT32(data, 4U); - - if (m_tgidBuffer != nullptr) - delete[] m_tgidBuffer; - if (m_tgidSize < PEER_LINK_BLOCK_SIZE) - m_tgidBuffer = new uint8_t[PEER_LINK_BLOCK_SIZE + 1U]; - else - m_tgidBuffer = new uint8_t[m_tgidSize + 1U]; - } + uint32_t decompressedLen = 0U; + uint8_t* decompressed = nullptr; + + if (m_tgidPkt.decode(data, &decompressed, &decompressedLen)) { + if (m_tidLookup == nullptr) { + LogError(LOG_NET, "Talkgroup ID lookup not available yet."); + m_tgidPkt.clear(); + delete[] decompressed; + break; + } - if (m_tgidBuffer != nullptr) { - if (curBlock < blockCnt) { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_tgidBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); + // store to file + DECLARE_CHAR_ARRAY(str, decompressedLen + 1U); + ::memcpy(str, decompressed, decompressedLen); + str[decompressedLen] = 0; // null termination + + // randomize filename + std::ostringstream s; + if (!m_peerLinkSavesACL) { + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); + s << "/tmp/talkgroup_rules.yml." << dist(mt); } else { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_tgidBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - - // scope is intentional - { - uint32_t decompressedLen = 0U; - uint8_t* decompressed = Compression::decompress(m_tgidBuffer, m_tgidCompressedSize, &decompressedLen); - - // check that we got the appropriate data - if (decompressedLen == m_tgidSize && decompressed != nullptr) { - if (m_tidLookup == nullptr) { - LogError(LOG_NET, "Talkgroup ID lookup not available yet."); - goto tid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - // store to file - std::unique_ptr __str = std::make_unique(decompressedLen + 1U); - char* str = __str.get(); - ::memcpy(str, decompressed, decompressedLen); - str[decompressedLen] = 0; // null termination - - // randomize filename - std::ostringstream s; - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); - s << "/tmp/talkgroup_rules.yml." << dist(mt); - - std::string filename = s.str(); - std::ofstream file(filename, std::ofstream::out); - if (file.fail()) { - LogError(LOG_NET, "Cannot open the talkgroup ID lookup file - %s", filename.c_str()); - goto tid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - file << str; - file.close(); - - m_tidLookup->stop(true); - m_tidLookup->setReloadTime(0U); - m_tidLookup->filename(filename); - m_tidLookup->reload(); - - // flag this peer as Peer-Link enabled - m_peerLink = true; - - // cleanup temporary file - ::remove(filename.c_str()); - } - else { - LogError(LOG_NET, "PEER %u error decompressed TGID list, was not of expected size! %u != %u", peerId, decompressedLen, m_tgidSize); - } - } - - tid_lookup_cleanup: - m_tgidSize = 0U; - m_tgidCompressedSize = 0U; - if (m_tgidBuffer != nullptr) - delete[] m_tgidBuffer; - m_tgidBuffer = nullptr; + s << m_tidLookup->filename(); + } + + std::string filename = s.str(); + std::ofstream file(filename, std::ofstream::out); + if (file.fail()) { + LogError(LOG_NET, "Cannot open the talkgroup ID lookup file - %s", filename.c_str()); + m_tgidPkt.clear(); + delete[] decompressed; + break; } + + file << str; + file.close(); + + m_tidLookup->stop(true); + m_tidLookup->setReloadTime(0U); + m_tidLookup->filename(filename); + m_tidLookup->reload(); + + // flag this peer as Peer-Link enabled + m_peerLink = true; + + // cleanup temporary file + ::remove(filename.c_str()); + m_tgidPkt.clear(); + delete[] decompressed; } } break; case NET_SUBFUNC::PL_RID_LIST: { - uint8_t curBlock = data[8U]; - uint8_t blockCnt = data[9U]; - - // if this is the first block store sizes and initialize temp buffer - if (curBlock == 0U) { - m_ridSize = __GET_UINT32(data, 0U); - m_ridCompressedSize = __GET_UINT32(data, 4U); - - if (m_ridBuffer != nullptr) - delete[] m_ridBuffer; - if (m_ridSize < PEER_LINK_BLOCK_SIZE) - m_ridBuffer = new uint8_t[PEER_LINK_BLOCK_SIZE + 1U]; - else - m_ridBuffer = new uint8_t[m_ridSize + 1U]; - } + uint32_t decompressedLen = 0U; + uint8_t* decompressed = nullptr; + + if (m_ridPkt.decode(data, &decompressed, &decompressedLen)) { + if (m_ridLookup == nullptr) { + LogError(LOG_NET, "Radio ID lookup not available yet."); + m_ridPkt.clear(); + delete[] decompressed; + break; + } - if (m_ridBuffer != nullptr) { - if (curBlock < blockCnt) { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_ridBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); + // store to file + DECLARE_CHAR_ARRAY(str, decompressedLen + 1U); + ::memcpy(str, decompressed, decompressedLen); + str[decompressedLen] = 0; // null termination + + // randomize filename + std::ostringstream s; + if (!m_peerLinkSavesACL) { + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); + s << "/tmp/rid_acl.dat." << dist(mt); } else { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_ridBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - - // scope is intentional - { - uint32_t decompressedLen = 0U; - uint8_t* decompressed = Compression::decompress(m_ridBuffer, m_ridCompressedSize, &decompressedLen); - - // check that we got the appropriate data - if (decompressedLen == m_ridSize && decompressed != nullptr) { - if (m_ridLookup == nullptr) { - LogError(LOG_NET, "Radio ID lookup not available yet."); - goto rid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - // store to file - std::unique_ptr __str = std::make_unique(decompressedLen + 1U); - char* str = __str.get(); - ::memcpy(str, decompressed, decompressedLen); - str[decompressedLen] = 0; // null termination - - // randomize filename - std::ostringstream s; - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); - s << "/tmp/rid_acl.dat." << dist(mt); - - std::string filename = s.str(); - std::ofstream file(filename, std::ofstream::out); - if (file.fail()) { - LogError(LOG_NET, "Cannot open the radio ID lookup file - %s", filename.c_str()); - goto rid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - file << str; - file.close(); - - m_ridLookup->stop(true); - m_ridLookup->setReloadTime(0U); - m_ridLookup->filename(filename); - m_ridLookup->reload(); - - // flag this peer as Peer-Link enabled - m_peerLink = true; - - // cleanup temporary file - ::remove(filename.c_str()); - } - else { - LogError(LOG_NET, "PEER %u error decompressed RID list, was not of expected size! %u != %u", peerId, decompressedLen, m_ridSize); - } - } - - rid_lookup_cleanup: - m_ridSize = 0U; - m_ridCompressedSize = 0U; - if (m_ridBuffer != nullptr) - delete[] m_ridBuffer; - m_ridBuffer = nullptr; + s << m_ridLookup->filename(); + } + + std::string filename = s.str(); + std::ofstream file(filename, std::ofstream::out); + if (file.fail()) { + LogError(LOG_NET, "Cannot open the radio ID lookup file - %s", filename.c_str()); + m_ridPkt.clear(); + delete[] decompressed; + break; } + + file << str; + file.close(); + + m_ridLookup->stop(true); + m_ridLookup->setReloadTime(0U); + m_ridLookup->filename(filename); + m_ridLookup->reload(); + + // flag this peer as Peer-Link enabled + m_peerLink = true; + + // cleanup temporary file + ::remove(filename.c_str()); + m_ridPkt.clear(); + delete[] decompressed; } } break; case NET_SUBFUNC::PL_PEER_LIST: { - uint8_t curBlock = data[8U]; - uint8_t blockCnt = data[9U]; - - // if this is the first block store sizes and initialize temp buffer - if (curBlock == 0U) { - m_pidSize = __GET_UINT32(data, 0U); - m_pidCompressedSize = __GET_UINT32(data, 4U); - - if (m_pidBuffer != nullptr) - delete[] m_pidBuffer; - if (m_pidSize < PEER_LINK_BLOCK_SIZE) - m_pidBuffer = new uint8_t[PEER_LINK_BLOCK_SIZE + 1U]; - else - m_pidBuffer = new uint8_t[m_pidSize + 1U]; - } + uint32_t decompressedLen = 0U; + uint8_t* decompressed = nullptr; + + if (m_pidPkt.decode(data, &decompressed, &decompressedLen)) { + if (m_pidLookup == nullptr) { + LogError(LOG_NET, "Peer ID lookup not available yet."); + m_pidPkt.clear(); + delete[] decompressed; + break; + } - if (m_pidBuffer != nullptr) { - if (curBlock < blockCnt) { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_pidBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); + // store to file + DECLARE_CHAR_ARRAY(str, decompressedLen + 1U); + ::memcpy(str, decompressed, decompressedLen); + str[decompressedLen] = 0; // null termination + + // randomize filename + std::ostringstream s; + if (!m_peerLinkSavesACL) { + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); + s << "/tmp/peer_list.dat." << dist(mt); } else { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_pidBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - - // scope is intentional - { - uint32_t decompressedLen = 0U; - uint8_t* decompressed = Compression::decompress(m_pidBuffer, m_pidCompressedSize, &decompressedLen); - - // check that we got the appropriate data - if (decompressedLen == m_pidSize && decompressed != nullptr) { - if (m_pidLookup == nullptr) { - LogError(LOG_NET, "Peer ID lookup not available yet."); - goto pid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - // store to file - std::unique_ptr __str = std::make_unique(decompressedLen + 1U); - char* str = __str.get(); - ::memcpy(str, decompressed, decompressedLen); - str[decompressedLen] = 0; // null termination - - // randomize filename - std::ostringstream s; - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); - s << "/tmp/peer_list.dat." << dist(mt); - - std::string filename = s.str(); - std::ofstream file(filename, std::ofstream::out); - if (file.fail()) { - LogError(LOG_NET, "Cannot open the peer ID lookup file - %s", filename.c_str()); - goto pid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - file << str; - file.close(); - - m_pidLookup->stop(true); - m_pidLookup->setReloadTime(0U); - m_pidLookup->filename(filename); - m_pidLookup->reload(); - - // flag this peer as Peer-Link enabled - m_peerLink = true; - - // cleanup temporary file - ::remove(filename.c_str()); - } - else { - LogError(LOG_NET, "PEER %u error decompressed peer ID list, was not of expected size! %u != %u", peerId, decompressedLen, m_pidSize); - } - } - - pid_lookup_cleanup: - m_pidSize = 0U; - m_pidCompressedSize = 0U; - if (m_pidBuffer != nullptr) - delete[] m_pidBuffer; - m_pidBuffer = nullptr; + s << m_pidLookup->filename(); + } + + std::string filename = s.str(); + std::ofstream file(filename, std::ofstream::out); + if (file.fail()) { + LogError(LOG_NET, "Cannot open the peer ID lookup file - %s", filename.c_str()); + m_pidPkt.clear(); + delete[] decompressed; + break; } + + file << str; + file.close(); + + m_pidLookup->stop(true); + m_pidLookup->setReloadTime(0U); + m_pidLookup->filename(filename); + m_pidLookup->reload(); + + // flag this peer as Peer-Link enabled + m_peerLink = true; + + // cleanup temporary file + ::remove(filename.c_str()); + m_pidPkt.clear(); + delete[] decompressed; } } break; @@ -517,8 +380,7 @@ bool PeerNetwork::writeConfig() json::value v = json::value(config); std::string json = v.serialize(); - CharArray __buffer = std::make_unique(json.length() + 9U); - char* buffer = __buffer.get(); + DECLARE_CHAR_ARRAY(buffer, json.length() + 9U); ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); ::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str()); diff --git a/src/fne/network/PeerNetwork.h b/src/fne/network/PeerNetwork.h index 748e238f..4e3016c5 100644 --- a/src/fne/network/PeerNetwork.h +++ b/src/fne/network/PeerNetwork.h @@ -19,6 +19,7 @@ #include "Defines.h" #include "common/lookups/PeerListLookup.h" #include "common/network/Network.h" +#include "common/network/PacketBuffer.h" #include #include @@ -109,11 +110,17 @@ namespace network */ bool isPeerLink() const { return m_peerLink; } + /** + * @brief Enables the option that will save the pushed peer link ACL data to the local ACL files. + * @param enabled Flag to enable ACL data saving. + */ + void setPeerLinkSaveACL(bool enabled) { m_peerLinkSavesACL = enabled; } + public: /** * @brief Flag indicating whether or not this peer network has a key response handler attached. */ - __PROPERTY(bool, attachedKeyRSPHandler, AttachedKeyRSPHandler); + DECLARE_PROPERTY(bool, attachedKeyRSPHandler, AttachedKeyRSPHandler); protected: std::vector m_blockTrafficToTable; @@ -138,21 +145,11 @@ namespace network private: lookups::PeerListLookup* m_pidLookup; bool m_peerLink; + bool m_peerLinkSavesACL; - uint32_t m_tgidCompressedSize; - uint32_t m_tgidSize; - - uint8_t* m_tgidBuffer; - - uint32_t m_ridCompressedSize; - uint32_t m_ridSize; - - uint8_t* m_ridBuffer; - - uint32_t m_pidCompressedSize; - uint32_t m_pidSize; - - uint8_t* m_pidBuffer; + PacketBuffer m_tgidPkt; + PacketBuffer m_ridPkt; + PacketBuffer m_pidPkt; }; } // namespace network diff --git a/src/fne/network/callhandler/TagDMRData.cpp b/src/fne/network/callhandler/TagDMRData.cpp index f5eb5dff..e0064539 100644 --- a/src/fne/network/callhandler/TagDMRData.cpp +++ b/src/fne/network/callhandler/TagDMRData.cpp @@ -67,15 +67,13 @@ bool TagDMRData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId { hrc::hrc_t pktTime = hrc::now(); - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, len); + DECLARE_UINT8_ARRAY(buffer, len); ::memcpy(buffer, data, len); uint8_t seqNo = data[4U]; - uint32_t srcId = __GET_UINT16(data, 5U); - uint32_t dstId = __GET_UINT16(data, 8U); + uint32_t srcId = GET_UINT24(data, 5U); + uint32_t dstId = GET_UINT24(data, 8U); FLCO::E flco = (data[15U] & 0x40U) == 0x40U ? FLCO::PRIVATE : FLCO::GROUP; @@ -124,7 +122,7 @@ bool TagDMRData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId // perform TGID route rewrites if configured routeRewrite(buffer, peerId, dmrData, dataType, dstId, slotNo, false); - dstId = __GET_UINT16(buffer, 8U); + dstId = GET_UINT24(buffer, 8U); // is the stream valid? if (validate(peerId, dmrData, streamId)) { @@ -312,9 +310,7 @@ bool TagDMRData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId m_network->m_frameQueue->flushQueue(); } - UInt8Array __outboundPeerBuffer = std::make_unique(len); - uint8_t* outboundPeerBuffer = __outboundPeerBuffer.get(); - ::memset(outboundPeerBuffer, 0x00U, len); + DECLARE_UINT8_ARRAY(outboundPeerBuffer, len); ::memcpy(outboundPeerBuffer, buffer, len); // perform TGID route rewrites if configured @@ -357,9 +353,7 @@ bool TagDMRData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId continue; } - UInt8Array __outboundPeerBuffer = std::make_unique(len); - uint8_t* outboundPeerBuffer = __outboundPeerBuffer.get(); - ::memset(outboundPeerBuffer, 0x00U, len); + DECLARE_UINT8_ARRAY(outboundPeerBuffer, len); ::memcpy(outboundPeerBuffer, buffer, len); // perform TGID route rewrites if configured @@ -510,7 +504,7 @@ void TagDMRData::routeRewrite(uint8_t* buffer, uint32_t peerId, dmr::data::NetDa // does the data require route rewriting? if (peerRewrite(peerId, rewriteDstId, rewriteSlotNo, outbound)) { // rewrite destination TGID in the frame - __SET_UINT16(rewriteDstId, buffer, 8U); + SET_UINT24(rewriteDstId, buffer, 8U); // set or clear the e.Slot flag (if 0x80 is set Slot 2 otherwise Slot 1) if (rewriteSlotNo == 2 && (buffer[15U] & 0x80U) == 0x00U) diff --git a/src/fne/network/callhandler/TagNXDNData.cpp b/src/fne/network/callhandler/TagNXDNData.cpp index 00264b98..3efc82f9 100644 --- a/src/fne/network/callhandler/TagNXDNData.cpp +++ b/src/fne/network/callhandler/TagNXDNData.cpp @@ -63,15 +63,13 @@ bool TagNXDNData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerI { hrc::hrc_t pktTime = hrc::now(); - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, len); + DECLARE_UINT8_ARRAY(buffer, len); ::memcpy(buffer, data, len); uint8_t messageType = data[4U]; - uint32_t srcId = __GET_UINT16(data, 5U); - uint32_t dstId = __GET_UINT16(data, 8U); + uint32_t srcId = GET_UINT24(data, 5U); + uint32_t dstId = GET_UINT24(data, 8U); if (messageType == MessageType::RTCH_DCALL_HDR || messageType == MessageType::RTCH_DCALL_DATA) { @@ -81,7 +79,7 @@ bool TagNXDNData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerI // perform TGID route rewrites if configured routeRewrite(buffer, peerId, messageType, dstId, false); - dstId = __GET_UINT16(buffer, 8U); + dstId = GET_UINT24(buffer, 8U); lc::RTCH lc; @@ -257,9 +255,7 @@ bool TagNXDNData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerI m_network->m_frameQueue->flushQueue(); } - UInt8Array __outboundPeerBuffer = std::make_unique(len); - uint8_t* outboundPeerBuffer = __outboundPeerBuffer.get(); - ::memset(outboundPeerBuffer, 0x00U, len); + DECLARE_UINT8_ARRAY(outboundPeerBuffer, len); ::memcpy(outboundPeerBuffer, buffer, len); // perform TGID route rewrites if configured @@ -302,9 +298,7 @@ bool TagNXDNData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerI continue; } - UInt8Array __outboundPeerBuffer = std::make_unique(len); - uint8_t* outboundPeerBuffer = __outboundPeerBuffer.get(); - ::memset(outboundPeerBuffer, 0x00U, len); + DECLARE_UINT8_ARRAY(outboundPeerBuffer, len); ::memcpy(outboundPeerBuffer, buffer, len); // perform TGID route rewrites if configured @@ -423,7 +417,7 @@ void TagNXDNData::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t message // does the data require route writing? if (peerRewrite(peerId, rewriteDstId, outbound)) { // rewrite destination TGID in the frame - __SET_UINT16(rewriteDstId, buffer, 8U); + SET_UINT24(rewriteDstId, buffer, 8U); } } diff --git a/src/fne/network/callhandler/TagP25Data.cpp b/src/fne/network/callhandler/TagP25Data.cpp index 43ef6e3d..766240c3 100644 --- a/src/fne/network/callhandler/TagP25Data.cpp +++ b/src/fne/network/callhandler/TagP25Data.cpp @@ -69,15 +69,13 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId { hrc::hrc_t pktTime = hrc::now(); - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, len); + DECLARE_UINT8_ARRAY(buffer, len); ::memcpy(buffer, data, len); uint8_t lco = data[4U]; - uint32_t srcId = __GET_UINT16(data, 5U); - uint32_t dstId = __GET_UINT16(data, 8U); + uint32_t srcId = GET_UINT24(data, 5U); + uint32_t dstId = GET_UINT24(data, 8U); uint8_t MFId = data[15U]; @@ -95,7 +93,7 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId // perform TGID route rewrites if configured routeRewrite(buffer, peerId, duid, dstId, false); - dstId = __GET_UINT16(buffer, 8U); + dstId = GET_UINT24(buffer, 8U); lc::LC control; data::LowSpeedData lsd; @@ -121,8 +119,12 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId } if (m_debug) { - LogDebug(LOG_NET, "P25, HDU algId = $%02X, kId = $%02X", algId, kid); - Utils::dump(1U, "P25 HDU Network MI", mi, MI_LENGTH_BYTES); + LogDebug(LOG_NET, P25_HDU_STR ", HDU_BSDWNACT, dstId = %u, algo = $%02X, kid = $%04X", dstId, algId, kid); + + if (algId != ALGO_UNENCRYPT) { + LogDebug(LOG_NET, P25_HDU_STR ", Enc Sync, MI = %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); + } } control.setAlgId(algId); @@ -341,9 +343,7 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId m_network->m_frameQueue->flushQueue(); } - UInt8Array __outboundPeerBuffer = std::make_unique(len); - uint8_t* outboundPeerBuffer = __outboundPeerBuffer.get(); - ::memset(outboundPeerBuffer, 0x00U, len); + DECLARE_UINT8_ARRAY(outboundPeerBuffer, len); ::memcpy(outboundPeerBuffer, buffer, len); // perform TGID route rewrites if configured @@ -386,9 +386,7 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId continue; } - UInt8Array __outboundPeerBuffer = std::make_unique(len); - uint8_t* outboundPeerBuffer = __outboundPeerBuffer.get(); - ::memset(outboundPeerBuffer, 0x00U, len); + DECLARE_UINT8_ARRAY(outboundPeerBuffer, len); ::memcpy(outboundPeerBuffer, buffer, len); // perform TGID route rewrites if configured @@ -615,7 +613,7 @@ void TagP25Data::write_TSDU_U_Reg_Cmd(uint32_t peerId, uint32_t dstId) void TagP25Data::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t duid, uint32_t dstId, bool outbound) { - uint32_t srcId = __GET_UINT16(buffer, 5U); + uint32_t srcId = GET_UINT24(buffer, 5U); uint32_t frameLength = buffer[23U]; uint32_t rewriteDstId = dstId; @@ -623,7 +621,7 @@ void TagP25Data::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t duid, ui // does the data require route writing? if (peerRewrite(peerId, rewriteDstId, outbound)) { // rewrite destination TGID in the frame - __SET_UINT16(rewriteDstId, buffer, 8U); + SET_UINT24(rewriteDstId, buffer, 8U); // are we receiving a TSDU? if (duid == DUID::TSDU) { @@ -637,8 +635,8 @@ void TagP25Data::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t duid, ui switch (tsbk->getLCO()) { case TSBKO::IOSP_GRP_VCH: { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u, dstId = %u", - tsbk->toString(true).c_str(), tsbk->getEmergency(), tsbk->getEncrypted(), tsbk->getPriority(), tsbk->getGrpVchNo(), srcId, rewriteDstId); + LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u", + tsbk->toString(true).c_str(), tsbk->getEmergency(), tsbk->getEncrypted(), tsbk->getPriority(), tsbk->getGrpVchId(), tsbk->getGrpVchNo(), srcId, rewriteDstId); tsbk->setDstId(rewriteDstId); } @@ -753,7 +751,7 @@ bool TagP25Data::processTSDUFrom(uint8_t* buffer, uint32_t peerId, uint8_t duid) lc::tsbk::OSP_ADJ_STS_BCAST* osp = static_cast(tsbk.get()); if (m_network->m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X, peerId = %u", tsbk->toString().c_str(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X, peerId = %u", tsbk->toString().c_str(), osp->getAdjSiteSysId(), osp->getAdjSiteRFSSId(), osp->getAdjSiteId(), osp->getAdjSiteChnId(), osp->getAdjSiteChnNo(), osp->getAdjSiteSvcClass(), peerId); } } @@ -888,7 +886,7 @@ bool TagP25Data::processTSDUToExternal(uint8_t* buffer, uint32_t srcPeerId, uint lc::tsbk::OSP_ADJ_STS_BCAST* osp = static_cast(tsbk.get()); if (m_network->m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X, peerId = %u", tsbk->toString().c_str(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X, peerId = %u", tsbk->toString().c_str(), osp->getAdjSiteSysId(), osp->getAdjSiteRFSSId(), osp->getAdjSiteId(), osp->getAdjSiteChnId(), osp->getAdjSiteChnNo(), osp->getAdjSiteSvcClass(), srcPeerId); } } @@ -1411,8 +1409,8 @@ bool TagP25Data::write_TSDU_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstI iosp->setPriority(priority); if (m_network->m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u, dstId = %u, peerId = %u", - iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId(), peerId); + LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u, peerId = %u", + iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchId(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId(), peerId); } write_TSDU(peerId, iosp.get()); @@ -1428,8 +1426,8 @@ bool TagP25Data::write_TSDU_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstI iosp->setPriority(priority); if (m_network->m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u, dstId = %u, peerId = %u", - iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId(), peerId); + LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u, peerId = %u", + iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchId(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId(), peerId); } write_TSDU(peerId, iosp.get()); diff --git a/src/fne/network/callhandler/packetdata/DMRPacketData.cpp b/src/fne/network/callhandler/packetdata/DMRPacketData.cpp index cbfaf0cc..e12fc72c 100644 --- a/src/fne/network/callhandler/packetdata/DMRPacketData.cpp +++ b/src/fne/network/callhandler/packetdata/DMRPacketData.cpp @@ -64,8 +64,8 @@ bool DMRPacketData::processFrame(const uint8_t* data, uint32_t len, uint32_t pee uint8_t seqNo = data[4U]; - uint32_t srcId = __GET_UINT16(data, 5U); - uint32_t dstId = __GET_UINT16(data, 8U); + uint32_t srcId = GET_UINT24(data, 5U); + uint32_t dstId = GET_UINT24(data, 8U); FLCO::E flco = (data[15U] & 0x40U) == 0x40U ? FLCO::PRIVATE : FLCO::GROUP; diff --git a/src/fne/network/callhandler/packetdata/P25PacketData.cpp b/src/fne/network/callhandler/packetdata/P25PacketData.cpp index 956ec5e3..3e8d3c4d 100644 --- a/src/fne/network/callhandler/packetdata/P25PacketData.cpp +++ b/src/fne/network/callhandler/packetdata/P25PacketData.cpp @@ -78,7 +78,7 @@ bool P25PacketData::processFrame(const uint8_t* data, uint32_t len, uint32_t pee { hrc::hrc_t pktTime = hrc::now(); - uint32_t blockLength = __GET_UINT16(data, 8U); + uint32_t blockLength = GET_UINT24(data, 8U); uint8_t currentBlock = data[21U]; @@ -447,9 +447,7 @@ void P25PacketData::clock(uint32_t ms) rspHeader.calculateLength(dataFrame->pktLen); uint32_t pduLength = rspHeader.getPDULength(); - UInt8Array __pduUserData = std::make_unique(pduLength); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, pduLength); + DECLARE_UINT8_ARRAY(pduUserData, pduLength); ::memcpy(pduUserData + 4U, dataFrame->buffer, dataFrame->pktLen); #if DEBUG_P25_PDU_DATA Utils::dump(1U, "P25PacketData::clock() pduUserData", pduUserData, pduLength); @@ -539,11 +537,11 @@ void P25PacketData::dispatch(uint32_t peerId) ::memset(arpPacket, 0x00U, P25_PDU_ARP_PCKT_LENGTH); ::memcpy(arpPacket, status->pduUserData + 12U, P25_PDU_ARP_PCKT_LENGTH); - uint16_t opcode = __GET_UINT16B(arpPacket, 6U); - uint32_t srcHWAddr = __GET_UINT16(arpPacket, 8U); - uint32_t srcProtoAddr = __GET_UINT32(arpPacket, 11U); - //uint32_t tgtHWAddr = __GET_UINT16(arpPacket, 15U); - uint32_t tgtProtoAddr = __GET_UINT32(arpPacket, 18U); + uint16_t opcode = GET_UINT16(arpPacket, 6U); + uint32_t srcHWAddr = GET_UINT24(arpPacket, 8U); + uint32_t srcProtoAddr = GET_UINT32(arpPacket, 11U); + //uint32_t tgtHWAddr = GET_UINT24(arpPacket, 15U); + uint32_t tgtProtoAddr = GET_UINT32(arpPacket, 18U); if (opcode == P25_PDU_ARP_REQUEST) { LogMessage(LOG_NET, P25_PDU_STR ", ARP request, who has %s? tell %s (%u)", __IP_FROM_UINT(tgtProtoAddr).c_str(), __IP_FROM_UINT(srcProtoAddr).c_str(), srcHWAddr); @@ -639,9 +637,7 @@ void P25PacketData::dispatch(uint32_t peerId) LogMessage(LOG_NET, "P25, PDU -> VTUN, IP Data, srcIp = %s (%u), dstIp = %s (%u), pktLen = %u, proto = %02X", srcIp, status->header.getSrcLLId(), dstIp, status->header.getLLId(), pktLen, proto); - UInt8Array __ipFrame = std::make_unique(pktLen); - uint8_t* ipFrame = __ipFrame.get(); - ::memset(ipFrame, 0x00U, pktLen); + DECLARE_UINT8_ARRAY(ipFrame, pktLen); ::memcpy(ipFrame, status->pduUserData + dataPktOffset, pktLen); #if DEBUG_P25_PDU_DATA Utils::dump(1U, "P25PacketData::dispatch() ipFrame", ipFrame, pktLen); @@ -849,9 +845,7 @@ bool P25PacketData::processKMM(RxStatus* status) dataHeader.calculateLength(KMM_NO_SERVICE_LENGTH); uint32_t pduLength = dataHeader.getPDULength(); - UInt8Array __pduUserData = std::make_unique(pduLength); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, pduLength); + DECLARE_UINT8_ARRAY(pduUserData, pduLength); uint8_t buffer[KMM_NO_SERVICE_LENGTH]; KMMNoService outKmm = KMMNoService(); @@ -881,18 +875,18 @@ void P25PacketData::write_PDU_ARP(uint32_t addr) uint8_t arpPacket[P25_PDU_ARP_PCKT_LENGTH]; ::memset(arpPacket, 0x00U, P25_PDU_ARP_PCKT_LENGTH); - __SET_UINT16B(P25_PDU_ARP_CAI_TYPE, arpPacket, 0U); // Hardware Address Type - __SET_UINT16B(PDUSAP::PACKET_DATA, arpPacket, 2U); // Protocol Address Type + SET_UINT16(P25_PDU_ARP_CAI_TYPE, arpPacket, 0U); // Hardware Address Type + SET_UINT16(PDUSAP::PACKET_DATA, arpPacket, 2U); // Protocol Address Type arpPacket[4U] = P25_PDU_ARP_HW_ADDR_LENGTH; // Hardware Address Length arpPacket[5U] = P25_PDU_ARP_PROTO_ADDR_LENGTH; // Protocol Address Length - __SET_UINT16B(P25_PDU_ARP_REQUEST, arpPacket, 6U); // Opcode + SET_UINT16(P25_PDU_ARP_REQUEST, arpPacket, 6U); // Opcode - __SET_UINT16(WUID_FNE, arpPacket, 8U); // Sender Hardware Address + SET_UINT24(WUID_FNE, arpPacket, 8U); // Sender Hardware Address std::string fneIPv4 = m_network->m_host->m_tun->getIPv4(); - __SET_UINT32(__IP_FROM_STR(fneIPv4), arpPacket, 11U); // Sender Protocol Address + SET_UINT32(__IP_FROM_STR(fneIPv4), arpPacket, 11U); // Sender Protocol Address - __SET_UINT32(addr, arpPacket, 18U); // Target Protocol Address + SET_UINT32(addr, arpPacket, 18U); // Target Protocol Address #if DEBUG_P25_PDU_DATA Utils::dump(1U, "P25PacketData::write_PDU_ARP() arpPacket", arpPacket, P25_PDU_ARP_PCKT_LENGTH); #endif @@ -914,9 +908,7 @@ void P25PacketData::write_PDU_ARP(uint32_t addr) rspHeader.calculateLength(P25_PDU_ARP_PCKT_LENGTH); uint32_t pduLength = rspHeader.getPDULength(); - UInt8Array __pduUserData = std::make_unique(pduLength); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, pduLength); + DECLARE_UINT8_ARRAY(pduUserData, pduLength); ::memcpy(pduUserData + P25_PDU_HEADER_LENGTH_BYTES, arpPacket, P25_PDU_ARP_PCKT_LENGTH); dispatchUserFrameToFNE(rspHeader, true, pduUserData); @@ -940,17 +932,17 @@ void P25PacketData::write_PDU_ARP_Reply(uint32_t targetAddr, uint32_t requestorL uint8_t arpPacket[P25_PDU_ARP_PCKT_LENGTH]; ::memset(arpPacket, 0x00U, P25_PDU_ARP_PCKT_LENGTH); - __SET_UINT16B(P25_PDU_ARP_CAI_TYPE, arpPacket, 0U); // Hardware Address Type - __SET_UINT16B(PDUSAP::PACKET_DATA, arpPacket, 2U); // Protocol Address Type + SET_UINT16(P25_PDU_ARP_CAI_TYPE, arpPacket, 0U); // Hardware Address Type + SET_UINT16(PDUSAP::PACKET_DATA, arpPacket, 2U); // Protocol Address Type arpPacket[4U] = P25_PDU_ARP_HW_ADDR_LENGTH; // Hardware Address Length arpPacket[5U] = P25_PDU_ARP_PROTO_ADDR_LENGTH; // Protocol Address Length - __SET_UINT16B(P25_PDU_ARP_REPLY, arpPacket, 6U); // Opcode + SET_UINT16(P25_PDU_ARP_REPLY, arpPacket, 6U); // Opcode - __SET_UINT16(tgtLlid, arpPacket, 8U); // Sender Hardware Address - __SET_UINT32(targetAddr, arpPacket, 11U); // Sender Protocol Address + SET_UINT24(tgtLlid, arpPacket, 8U); // Sender Hardware Address + SET_UINT32(targetAddr, arpPacket, 11U); // Sender Protocol Address - __SET_UINT16(requestorLlid, arpPacket, 15U); // Requestor Hardware Address - __SET_UINT32(requestorAddr, arpPacket, 18U); // Requestor Protocol Address + SET_UINT24(requestorLlid, arpPacket, 15U); // Requestor Hardware Address + SET_UINT32(requestorAddr, arpPacket, 18U); // Requestor Protocol Address #if DEBUG_P25_PDU_DATA Utils::dump(1U, "P25PacketData::write_PDU_ARP_Reply() arpPacket", arpPacket, P25_PDU_ARP_PCKT_LENGTH); #endif @@ -972,9 +964,7 @@ void P25PacketData::write_PDU_ARP_Reply(uint32_t targetAddr, uint32_t requestorL rspHeader.calculateLength(P25_PDU_ARP_PCKT_LENGTH); uint32_t pduLength = rspHeader.getPDULength(); - UInt8Array __pduUserData = std::make_unique(pduLength); - uint8_t* pduUserData = __pduUserData.get(); - ::memset(pduUserData, 0x00U, pduLength); + DECLARE_UINT8_ARRAY(pduUserData, pduLength); ::memcpy(pduUserData + P25_PDU_HEADER_LENGTH_BYTES, arpPacket, P25_PDU_ARP_PCKT_LENGTH); dispatchUserFrameToFNE(rspHeader, true, pduUserData); diff --git a/src/fne/network/influxdb/InfluxDB.cpp b/src/fne/network/influxdb/InfluxDB.cpp index d0c82cbd..a070571c 100644 --- a/src/fne/network/influxdb/InfluxDB.cpp +++ b/src/fne/network/influxdb/InfluxDB.cpp @@ -34,16 +34,11 @@ ThreadPool detail::TSCaller::m_fluxReqThreadPool{MAX_INFLUXQL_THREAD_CNT, "fluxq /* Generates a InfluxDB REST API request. */ int detail::inner::request(const char* method, const char* uri, const std::string& queryString, const std::string& body, - const ServerInfo& si, std::string* resp) + const ServerInfo& si) { std::string header; struct iovec iv[2]; - int fd, contentLength = 0, len = 0; - char ch; - unsigned char chunked = 0; - - if (resp) - resp->clear(); + int fd, len = 0; struct addrinfo hints, *addr = nullptr; struct in6_addr serverAddr; @@ -127,6 +122,7 @@ int detail::inner::request(const char* method, const char* uri, const std::strin struct timeval tv; // connect to the server + uint8_t retryCnt = 0U; ret = connect(fd, addr->ai_addr, addr->ai_addrlen); if (ret < 0) { if (errno == EINPROGRESS) { @@ -138,6 +134,18 @@ int detail::inner::request(const char* method, const char* uri, const std::strin FD_SET(fd, &fdset); ret = select(fd + 1, NULL, &fdset, NULL, &tv); + if (errno == EINTR) { + ++retryCnt; + + if (retryCnt > 5U) { + ::LogError(LOG_HOST, "Failed to connect to InfluxDB server, timed out while connecting"); + closesocket(fd); + return 1; + } + + Thread::sleep(1U); + } + if (ret < 0 && errno != EINTR) { #if defined(_WIN32) ::LogError(LOG_HOST, "Failed to connect to InfluxDB server, err: %lu", ::GetLastError()); @@ -199,11 +207,13 @@ int detail::inner::request(const char* method, const char* uri, const std::strin // ensure the remaining TCP operations timeout #if defined(_WIN32) - int sendTimeout = SOCK_CONNECT_TIMEOUT; - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&sendTimeout, sizeof(sendTimeout)); + int timeout = SOCK_CONNECT_TIMEOUT; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof(timeout)); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&timeout, sizeof(timeout)); #else tv.tv_sec = SOCK_CONNECT_TIMEOUT; tv.tv_usec = 0; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); #endif // defined(_WIN32) @@ -231,70 +241,13 @@ int detail::inner::request(const char* method, const char* uri, const std::strin iv[1].iov_base = (void*)&body[0]; iv[1].iov_len = body.length(); + ret = 0; + if (writev(fd, iv, 2) < (int)(iv[0].iov_len + iv[1].iov_len)) { + ::LogError(LOG_HOST, "Failed to write statistical data to InfluxDB server, err: %d", errno); ret = -6; - goto END; - } - - iv[0].iov_len = len; - -#define _NO_MORE() (len >= (int)iv[0].iov_len && (iv[0].iov_len = recv(fd, &header[0], header.length(), len = 0)) == size_t(-1)) -#define _GET_NEXT_CHAR() (ch = _NO_MORE() ? 0 : header[len++]) -#define _LOOP_NEXT(statement) for(;;) { if(!(_GET_NEXT_CHAR())) { ret = -7; goto END; } statement } -#define _UNTIL(c) _LOOP_NEXT( if(ch == c) break; ) -#define _GET_NUMBER(n) _LOOP_NEXT( if(ch >= '0' && ch <= '9') n = n * 10 + (ch - '0'); else break; ) -#define _GET_CHUNKED_LEN(n, c) _LOOP_NEXT( if(ch >= '0' && ch <= '9') n = n * 16 + (ch - '0'); \ -else if(ch >= 'A' && ch <= 'F') n = n * 16 + (ch - 'A') + 10; \ -else if(ch >= 'a' && ch <= 'f') n = n * 16 + (ch - 'a') + 10; else {if(ch != c) { ret = -8; goto END; } break;} ) -#define _(c) if((_GET_NEXT_CHAR()) != c) break; -#define __(c) if((_GET_NEXT_CHAR()) != c) { ret = -9; goto END; } - - if (resp) - resp->clear(); - - _UNTIL(' ')_GET_NUMBER(ret) - while (true) { - _UNTIL('\n') - switch (_GET_NEXT_CHAR()) { - case 'C':_('o')_('n')_('t')_('e')_('n')_('t')_('-') - _('L')_('e')_('n')_('g')_('t')_('h')_(':')_(' ') - _GET_NUMBER(contentLength) - break; - case 'T':_('r')_('a')_('n')_('s')_('f')_('e')_('r')_('-') - _('E')_('n')_('c')_('o')_('d')_('i')_('n')_('g')_(':') - _(' ')_('c')_('h')_('u')_('n')_('k')_('e')_('d') - chunked = 1; - break; - case '\r':__('\n') - switch (chunked) { - do {__('\r')__('\n') - case 1: - _GET_CHUNKED_LEN(contentLength, '\r')__('\n') - if (!contentLength) { - __('\r')__('\n') - goto END; - } - case 0: - while (contentLength > 0 && !_NO_MORE()) { - //contentLength -= (iv[1].iov_len = std::min(contentLength, (int)iv[0].iov_len - len)); - contentLength -= (iv[1].iov_len = (((contentLength) < ((int)iv[0].iov_len - len)) ? (contentLength) : ((int)iv[0].iov_len - len))); - if (resp) - resp->append(&header[len], iv[1].iov_len); - len += iv[1].iov_len; - } - } while(chunked); - } - goto END; - } - - if (!ch) { - ret = -10; - goto END; - } } - ret = -11; -END: // set SO_LINGER option struct linger sl; sl.l_onoff = 1; /* non-zero value enables linger option in kernel */ @@ -306,13 +259,5 @@ END: #endif // close socket closesocket(fd); - return ret / 100 == 2 ? 0 : ret; -#undef _NO_MORE -#undef _GET_NEXT_CHAR -#undef _LOOP_NEXT -#undef _UNTIL -#undef _GET_NUMBER -#undef _GET_CHUNKED_LEN -#undef _ -#undef __ + return ret; } diff --git a/src/fne/network/influxdb/InfluxDB.h b/src/fne/network/influxdb/InfluxDB.h index 5c974830..1e9ea955 100644 --- a/src/fne/network/influxdb/InfluxDB.h +++ b/src/fne/network/influxdb/InfluxDB.h @@ -111,23 +111,23 @@ namespace network /** * @brief Hostname/IP Address. */ - __PROPERTY_PLAIN(std::string, host); + DECLARE_PROPERTY_PLAIN(std::string, host); /** * @brief Port. */ - __PROPERTY_PLAIN(uint16_t, port); + DECLARE_PROPERTY_PLAIN(uint16_t, port); /** * @brief Organization. */ - __PROPERTY_PLAIN(std::string, org); + DECLARE_PROPERTY_PLAIN(std::string, org); /** * @brief Bucket. */ - __PROPERTY_PLAIN(std::string, bucket); + DECLARE_PROPERTY_PLAIN(std::string, bucket); /** * @brief Token. */ - __PROPERTY_PLAIN(std::string, token); + DECLARE_PROPERTY_PLAIN(std::string, token); }; namespace detail @@ -148,12 +148,11 @@ namespace network * @param uri URI. * @param queryString Query. * @param body Content body. - * @param si - * @param resp + * @param si Server Information. * @returns int */ static int request(const char* method, const char* uri, const std::string& queryString, const std::string& body, - const ServerInfo& si, std::string* resp); + const ServerInfo& si); private: /** @@ -188,23 +187,6 @@ namespace network out.append(src.c_str() + start, src.length() - start); } }; - - /** - * @brief Helper to generate a InfluxDB query. - * @param resp - * @param query - * @param si - */ - inline int fluxQL(std::string& resp, const std::string& query, const ServerInfo& si) - { - // query JSON body - std::stringstream body; - body << "{\"query\": \""; - body << query; - body << "\", \"type\": \"flux\" }"; - - return detail::inner::request("POST", "query", "", body.str(), si, &resp); - } } // namespace detail // --------------------------------------------------------------------------- @@ -428,7 +410,7 @@ namespace network struct HOST_SW_API TSCaller : public QueryBuilder { detail::TagCaller& meas(const std::string& m) { m_lines << '\n'; return this->m(m); } - int request(const ServerInfo& si, std::string* resp = nullptr) { return detail::inner::request("POST", "write", "", m_lines.str(), si, resp); } + int request(const ServerInfo& si) { return detail::inner::request("POST", "write", "", m_lines.str(), si); } int requestAsync(const ServerInfo& si) { TSCallerRequest* req = new TSCallerRequest(); @@ -478,7 +460,7 @@ namespace network } const ServerInfo& si = req->si; - detail::inner::request("POST", "write", "", req->lines, si, nullptr); + detail::inner::request("POST", "write", "", req->lines, si); delete req; } diff --git a/src/fw/modem b/src/fw/modem index 0a4c7844..a8b417ff 160000 --- a/src/fw/modem +++ b/src/fw/modem @@ -1 +1 @@ -Subproject commit 0a4c78445fb0c6929a3f351f3f4e693ec0b6d969 +Subproject commit a8b417ff020f4b173403bab5b63bb5f4530aa80a diff --git a/src/host/Host.Config.cpp b/src/host/Host.Config.cpp index e9779e3e..470e18fc 100644 --- a/src/host/Host.Config.cpp +++ b/src/host/Host.Config.cpp @@ -252,6 +252,24 @@ bool Host::readParams() chNo = 4095U; } + uint8_t rxChId = (uint8_t)channel["rxChannelId"].as(255U); + uint32_t rxChNo = (uint32_t)::strtoul(channel["rxChannelNo"].as("FFFF").c_str(), NULL, 16); + + // special case default handling for if the channelId field is missing from the + // configuration + if (rxChId != 255U) { + if (rxChId > 15U) { // clamp to 15 + rxChId = 15U; + } + + if (rxChNo == 0U) { // clamp to 1 + rxChNo = 1U; + } + if (rxChNo > 4095U) { // clamp to 4095 + rxChNo = 4095U; + } + } + std::string rpcApiAddress = channel["rpcAddress"].as("0.0.0.0"); uint16_t rpcApiPort = (uint16_t)channel["rpcPort"].as(RPC_DEFAULT_PORT); std::string rpcApiPassword = channel["rpcPassword"].as(); @@ -264,11 +282,19 @@ bool Host::readParams() } } - ::LogInfoEx(LOG_HOST, "Voice Channel Id %u Channel No $%04X RPC Address %s:%u", chId, chNo, rpcApiAddress.c_str(), rpcApiPort); + if (rxChId != 255U) { + ::LogInfoEx(LOG_HOST, "Voice Channel Id %u Channel No $%04X (%u-%u) Rx Channel Id %u Rx Channel No $%04X (%u-%u) RPC Address %s:%u", chId, chNo, chId, chNo, rxChId, rxChNo, rxChId, rxChNo, rpcApiAddress.c_str(), rpcApiPort); + + VoiceChData data = VoiceChData(chId, chNo, rxChId, rxChNo, rpcApiAddress, rpcApiPort, rpcApiPassword); + m_channelLookup->setRFChData(chNo, data); + m_channelLookup->addRFCh(chNo); + } else { + ::LogInfoEx(LOG_HOST, "Voice Channel Id %u Channel No $%04X (%u-%u) RPC Address %s:%u", chId, chNo, chId, chNo, rpcApiAddress.c_str(), rpcApiPort); - VoiceChData data = VoiceChData(chId, chNo, rpcApiAddress, rpcApiPort, rpcApiPassword); - m_channelLookup->setRFChData(chNo, data); - m_channelLookup->addRFCh(chNo); + VoiceChData data = VoiceChData(chId, chNo, rpcApiAddress, rpcApiPort, rpcApiPassword); + m_channelLookup->setRFChData(chNo, data); + m_channelLookup->addRFCh(chNo); + } } std::string strVoiceChNo = ""; @@ -277,9 +303,14 @@ bool Host::readParams() uint32_t chNo = ::atoi(std::to_string(*it).c_str()); ::lookups::VoiceChData voiceChData = m_channelLookup->getRFChData(chNo); - char hexStr[29]; + char hexStr[66]; - ::sprintf(hexStr, "$%01X.%01X (%u.%u)", voiceChData.chId(), chNo, voiceChData.chId(), chNo); + if (voiceChData.isExplicitCh()) { + ::sprintf(hexStr, "Tx $%01X-%04X (%u-%u) Rx $%01X-%04X (%u-%u)", voiceChData.chId(), chNo, voiceChData.chId(), chNo, voiceChData.rxChId(), voiceChData.rxChNo(), voiceChData.rxChId(), voiceChData.rxChNo()); + } + else { + ::sprintf(hexStr, "$%01X-%04X (%u-%u)", voiceChData.chId(), chNo, voiceChData.chId(), chNo); + } strVoiceChNo.append(std::string(hexStr)); strVoiceChNo.append(","); diff --git a/src/host/Host.cpp b/src/host/Host.cpp index c067d834..bbb8d616 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -2210,7 +2210,7 @@ void* Host::threadPresence(void* arg) host->rfCh()->setRFChData(channelNo, voiceCh); host->m_voiceChPeerId[channelNo] = peerId; - LogMessage(LOG_REST, "VC %s:%u, registration notice, peerId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), peerId, voiceCh.chId(), channelNo); + LogMessage(LOG_REST, "VC %s:%u, registration notice, peerId = %u, chNo = %u-%u", voiceCh.address().c_str(), voiceCh.port(), peerId, voiceCh.chId(), channelNo); LogInfoEx(LOG_HOST, "Voice Channel Id %u Channel No $%04X REST API Address %s:%u", voiceCh.chId(), channelNo, voiceCh.address().c_str(), voiceCh.port()); g_fireCCVCNotification = true; // announce this registration immediately to the FNE diff --git a/src/host/HostMain.cpp b/src/host/HostMain.cpp index 694d0f60..6047517e 100644 --- a/src/host/HostMain.cpp +++ b/src/host/HostMain.cpp @@ -272,7 +272,7 @@ int main(int argc, char** argv) ::memset(g_gitHashBytes, 0x00U, 4U); uint32_t hash = ::strtoul(__GIT_VER_HASH__, 0, 16); - __SET_UINT32(hash, g_gitHashBytes, 0U); + SET_UINT32(hash, g_gitHashBytes, 0U); if (argv[0] != nullptr && *argv[0] != 0) g_progExe = std::string(argv[0]); diff --git a/src/host/calibrate/HostCal.cpp b/src/host/calibrate/HostCal.cpp index 2b2e2cb0..0aa658ca 100644 --- a/src/host/calibrate/HostCal.cpp +++ b/src/host/calibrate/HostCal.cpp @@ -58,7 +58,7 @@ int HostCal::run(int argc, char **argv) } ::LogInfo(__BANNER__ "\r\n" __PROG_NAME__ " " __VER__ " (built " __BUILD__ ")\r\n" \ - "Copyright (c) 2017-2024 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\r\n" \ + "Copyright (c) 2017-2025 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\r\n" \ "Portions Copyright (c) 2015-2021 by Jonathan Naylor, G4KLX and others\r\n" \ ">> Modem Calibration\r\n"); diff --git a/src/host/dmr/Control.cpp b/src/host/dmr/Control.cpp index 852112eb..e3bf7e8d 100644 --- a/src/host/dmr/Control.cpp +++ b/src/host/dmr/Control.cpp @@ -688,8 +688,8 @@ void Control::processNetwork() // process network message header uint8_t seqNo = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); uint8_t controlByte = buffer[14U]; diff --git a/src/host/dmr/Slot.cpp b/src/host/dmr/Slot.cpp index 8419c5ed..44730d50 100644 --- a/src/host/dmr/Slot.cpp +++ b/src/host/dmr/Slot.cpp @@ -868,7 +868,7 @@ void Slot::releaseGrantTG(uint32_t dstId) ::lookups::VoiceChData voiceCh = m_affiliations->rfCh()->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_DMR, "DMR Slot %u, VC %s:%u, TG grant released, srcId = %u, dstId = %u, chId = %u, chNo = %u", m_slotNo, voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_DMR, "DMR Slot %u, VC %s:%u, TG grant released, srcId = %u, dstId = %u, chNo = %u-%u", m_slotNo, voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->releaseGrant(dstId, false); @@ -889,7 +889,7 @@ void Slot::touchGrantTG(uint32_t dstId) ::lookups::VoiceChData voiceCh = m_affiliations->rfCh()->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_DMR, "DMR Slot %u, VC %s:%u, call in progress, srcId = %u, dstId = %u, chId = %u, chNo = %u", m_slotNo, voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_DMR, "DMR Slot %u, VC %s:%u, call in progress, srcId = %u, dstId = %u, chNo = %u-%u", m_slotNo, voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->touchGrant(dstId); diff --git a/src/host/dmr/packet/Voice.cpp b/src/host/dmr/packet/Voice.cpp index dbc18767..bcd56c52 100644 --- a/src/host/dmr/packet/Voice.cpp +++ b/src/host/dmr/packet/Voice.cpp @@ -255,6 +255,12 @@ bool Voice::process(uint8_t* data, uint32_t len) if (m_verbose) { LogMessage(LOG_RF, DMR_DT_VOICE_PI_HEADER ", slot = %u, algId = %u, kId = %u, dstId = %u", m_slot->m_slotNo, m_slot->m_rfPrivacyLC->getAlgId(), m_slot->m_rfPrivacyLC->getKId(), m_slot->m_rfPrivacyLC->getDstId()); + + uint8_t mi[MI_LENGTH_BYTES]; + m_slot->m_rfPrivacyLC->getMI(mi); + + LogMessage(LOG_RF, DMR_DT_VOICE_PI_HEADER ", slot = %u, Enc Sync, MI = %02X %02X %02X %02X", + m_slot->m_slotNo, mi[0U], mi[1U], mi[2U], mi[3U]); } return true; @@ -845,6 +851,12 @@ void Voice::processNetwork(const data::NetData& dmrData) if (m_verbose) { LogMessage(LOG_NET, DMR_DT_VOICE_PI_HEADER ", slot = %u, algId = %u, kId = %u, dstId = %u", m_slot->m_slotNo, m_slot->m_netPrivacyLC->getAlgId(), m_slot->m_netPrivacyLC->getKId(), m_slot->m_netPrivacyLC->getDstId()); + + uint8_t mi[MI_LENGTH_BYTES]; + m_slot->m_netPrivacyLC->getMI(mi); + + LogMessage(LOG_NET, DMR_DT_VOICE_PI_HEADER ", slot = %u, Enc Sync, MI = %02X %02X %02X %02X", + m_slot->m_slotNo, mi[0U], mi[1U], mi[2U], mi[3U]); } } else if (dataType == DataType::VOICE_SYNC) { diff --git a/src/host/modem/Modem.cpp b/src/host/modem/Modem.cpp index b3e6d500..dd595605 100644 --- a/src/host/modem/Modem.cpp +++ b/src/host/modem/Modem.cpp @@ -1497,8 +1497,7 @@ bool Modem::writeP25Frame(const uint8_t* data, uint32_t length) return false; } - UInt8Array __buffer = std::make_unique(MAX_LENGTH); - uint8_t* buffer = __buffer.get(); + DECLARE_UINT8_ARRAY(buffer, MAX_LENGTH); if (length < 252U) { buffer[0U] = DVM_SHORT_FRAME_START; @@ -2268,10 +2267,10 @@ void Modem::processFlashConfig(const uint8_t *buffer) ADF_GAIN_MODE adfGainMode = (ADF_GAIN_MODE)buffer[24U]; FLASH_VALUE_CHECK(m_adfGainMode, adfGainMode, ADF_GAIN_AUTO, "adfGainMode"); - uint32_t txTuningRaw = __GET_UINT32(buffer, 25U); + uint32_t txTuningRaw = GET_UINT32(buffer, 25U); int txTuning = int(txTuningRaw); FLASH_VALUE_CHECK(m_txTuning, txTuning, 0, "txTuning"); - uint32_t rxTuningRaw = __GET_UINT32(buffer, 29U); + uint32_t rxTuningRaw = GET_UINT32(buffer, 29U); int rxTuning = int(rxTuningRaw); FLASH_VALUE_CHECK(m_rxTuning, rxTuning, 0, "rxTuning"); diff --git a/src/host/modem/Modem.h b/src/host/modem/Modem.h index 93e6711f..fe1e4db9 100644 --- a/src/host/modem/Modem.h +++ b/src/host/modem/Modem.h @@ -900,15 +900,15 @@ namespace modem /** * @brief Flag indicating if modem response trace is enabled. */ - __PROTECTED_PROPERTY(bool, respTrace, ResponseTrace); + DECLARE_PROTECTED_PROPERTY(bool, respTrace, ResponseTrace); /** * @brief Flag indicating if modem trace is enabled. */ - __PROTECTED_READONLY_PROPERTY(bool, trace, Trace); + DECLARE_PROTECTED_RO_PROPERTY(bool, trace, Trace); /** * @brief Flag indicating if modem debugging is enabled. */ - __PROTECTED_READONLY_PROPERTY(bool, debug, Debug); + DECLARE_PROTECTED_RO_PROPERTY(bool, debug, Debug); }; } // namespace modem diff --git a/src/host/modem/ModemV24.cpp b/src/host/modem/ModemV24.cpp index b5b02b01..3b5b9bba 100644 --- a/src/host/modem/ModemV24.cpp +++ b/src/host/modem/ModemV24.cpp @@ -441,9 +441,7 @@ int ModemV24::write(const uint8_t* data, uint32_t length) } if (modemCommand == CMD_P25_DATA) { - UInt8Array __buffer = std::make_unique(length); - uint8_t* buffer = __buffer.get(); - ::memset(buffer, 0x00U, length); + DECLARE_UINT8_ARRAY(buffer, length); ::memcpy(buffer, data + 2U, length); if (m_useTIAFormat) @@ -517,8 +515,7 @@ int ModemV24::writeSerial() m_txP25Queue.get(lengthTagTs, 11U); // Get the actual data - UInt8Array __buffer = std::make_unique(len); - uint8_t* buffer = __buffer.get(); + DECLARE_UINT8_ARRAY(buffer, len); m_txP25Queue.get(buffer, len); // Sanity check on data tag @@ -587,9 +584,7 @@ void ModemV24::convertToAir(const uint8_t *data, uint32_t length) ::memset(buffer, 0x00U, P25_PDU_FRAME_LENGTH_BYTES + 2U); // get the DFSI data (skip the 0x00 padded byte at the start) - UInt8Array __dfsiData = std::make_unique(length - 1U); - uint8_t* dfsiData = __dfsiData.get(); - ::memset(dfsiData, 0x00U, length - 1U); + DECLARE_UINT8_ARRAY(dfsiData, length - 1U); ::memcpy(dfsiData, data + 1U, length - 1U); if (m_debug) @@ -678,8 +673,8 @@ void ModemV24::convertToAir(const uint8_t *data, uint32_t length) m_rxCall->mfId = vhdr[9U]; m_rxCall->algoId = vhdr[10U]; - m_rxCall->kId = __GET_UINT16B(vhdr, 11U); - m_rxCall->dstId = __GET_UINT16B(vhdr, 13U); + m_rxCall->kId = GET_UINT16(vhdr, 11U); + m_rxCall->dstId = GET_UINT16(vhdr, 13U); if (m_debug) { LogDebug(LOG_MODEM, "P25, VHDR algId = $%02X, kId = $%04X, dstId = $%04X", m_rxCall->algoId, m_rxCall->kId, m_rxCall->dstId); @@ -742,10 +737,8 @@ void ModemV24::convertToAir(const uint8_t *data, uint32_t length) uint32_t bitLength = ((dataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS; uint32_t offset = P25_PREAMBLE_LENGTH_BITS; - UInt8Array __data = std::make_unique((bitLength / 8U) + 1U); - uint8_t* data = __data.get(); + DECLARE_UINT8_ARRAY(data, (bitLength / 8U) + 1U); - ::memset(data, 0x00U, bitLength / 8U); uint8_t block[P25_PDU_FEC_LENGTH_BYTES]; ::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES); @@ -860,7 +853,7 @@ void ModemV24::convertToAir(const uint8_t *data, uint32_t length) { ::memcpy(m_rxCall->netLDU1 + 80U, voice.imbeData, RAW_IMBE_LENGTH_BYTES); if (voice.additionalData != nullptr) { - m_rxCall->dstId = __GET_UINT16(voice.additionalData, 0U); + m_rxCall->dstId = GET_UINT24(voice.additionalData, 0U); } else { LogWarning(LOG_MODEM, "V.24/DFSI VC4 traffic missing metadata"); } @@ -870,7 +863,7 @@ void ModemV24::convertToAir(const uint8_t *data, uint32_t length) { ::memcpy(m_rxCall->netLDU1 + 105U, voice.imbeData, RAW_IMBE_LENGTH_BYTES); if (voice.additionalData != nullptr) { - m_rxCall->srcId = __GET_UINT16(voice.additionalData, 0U); + m_rxCall->srcId = GET_UINT24(voice.additionalData, 0U); } else { LogWarning(LOG_MODEM, "V.24/DFSI VC5 traffic missing metadata"); } @@ -942,7 +935,7 @@ void ModemV24::convertToAir(const uint8_t *data, uint32_t length) ::memcpy(m_rxCall->netLDU2 + 130U, voice.imbeData, RAW_IMBE_LENGTH_BYTES); if (voice.additionalData != nullptr) { m_rxCall->algoId = voice.additionalData[0U]; - m_rxCall->kId = __GET_UINT16B(voice.additionalData, 1U); + m_rxCall->kId = GET_UINT16(voice.additionalData, 1U); } else { LogWarning(LOG_MODEM, "V.24/DFSI VC15 traffic missing metadata"); } @@ -1115,9 +1108,7 @@ void ModemV24::convertToAirTIA(const uint8_t *data, uint32_t length) ::memset(buffer, 0x00U, P25_PDU_FRAME_LENGTH_BYTES + 2U); // get the DFSI data (skip the 0x00 padded byte at the start) - UInt8Array __dfsiData = std::make_unique(length - 1U); - uint8_t* dfsiData = __dfsiData.get(); - ::memset(dfsiData, 0x00U, length - 1U); + DECLARE_UINT8_ARRAY(dfsiData, length - 1U); ::memcpy(dfsiData, data + 1U, length - 1U); if (m_debug) @@ -1242,8 +1233,8 @@ void ModemV24::convertToAirTIA(const uint8_t *data, uint32_t length) m_rxCall->mfId = vhdr[9U]; m_rxCall->algoId = vhdr[10U]; - m_rxCall->kId = __GET_UINT16B(vhdr, 11U); - m_rxCall->dstId = __GET_UINT16B(vhdr, 13U); + m_rxCall->kId = GET_UINT16(vhdr, 11U); + m_rxCall->dstId = GET_UINT16(vhdr, 13U); if (m_debug) { LogDebug(LOG_MODEM, "P25, VHDR algId = $%02X, kId = $%04X, dstId = $%04X", m_rxCall->algoId, m_rxCall->kId, m_rxCall->dstId); @@ -1320,7 +1311,7 @@ void ModemV24::convertToAirTIA(const uint8_t *data, uint32_t length) { ::memcpy(m_rxCall->netLDU1 + 80U, voice.imbeData, RAW_IMBE_LENGTH_BYTES); if (voice.additionalData != nullptr) { - m_rxCall->dstId = __GET_UINT16(voice.additionalData, 0U); + m_rxCall->dstId = GET_UINT24(voice.additionalData, 0U); } else { LogWarning(LOG_MODEM, "V.24/DFSI VC4 traffic missing metadata"); } @@ -1330,7 +1321,7 @@ void ModemV24::convertToAirTIA(const uint8_t *data, uint32_t length) { ::memcpy(m_rxCall->netLDU1 + 105U, voice.imbeData, RAW_IMBE_LENGTH_BYTES); if (voice.additionalData != nullptr) { - m_rxCall->srcId = __GET_UINT16(voice.additionalData, 0U); + m_rxCall->srcId = GET_UINT24(voice.additionalData, 0U); } else { LogWarning(LOG_MODEM, "V.24/DFSI VC5 traffic missing metadata"); } @@ -1408,7 +1399,7 @@ void ModemV24::convertToAirTIA(const uint8_t *data, uint32_t length) ::memcpy(m_rxCall->netLDU2 + 130U, voice.imbeData, RAW_IMBE_LENGTH_BYTES); if (voice.additionalData != nullptr) { m_rxCall->algoId = voice.additionalData[0U]; - m_rxCall->kId = __GET_UINT16B(voice.additionalData, 1U); + m_rxCall->kId = GET_UINT16(voice.additionalData, 1U); } else { LogWarning(LOG_MODEM, "V.24/DFSI VC15 traffic missing metadata"); } @@ -1690,8 +1681,8 @@ void ModemV24::startOfStream(const p25::lc::LC& control) vhdr[9U] = control.getMFId(); vhdr[10U] = control.getAlgId(); - __SET_UINT16B(control.getKId(), vhdr, 11U); - __SET_UINT16B(control.getDstId(), vhdr, 13U); + SET_UINT16(control.getKId(), vhdr, 11U); + SET_UINT16(control.getDstId(), vhdr, 13U); // perform RS encoding m_rs.encode362017(vhdr); @@ -1771,7 +1762,7 @@ uint16_t ModemV24::generateNID(DUID::E duid) nid[1U] = (m_p25NAC << 4) & 0xF0U; nid[1U] |= duid; - return __GET_UINT16B(nid, 0U); + return GET_UINT16(nid, 0U); } /* Send a start of stream sequence (HDU, etc) to the connected UDP TIA-102 device. */ @@ -1821,8 +1812,8 @@ void ModemV24::startOfStreamTIA(const p25::lc::LC& control) vhdr[9U] = control.getMFId(); vhdr[10U] = control.getAlgId(); - __SET_UINT16B(control.getKId(), vhdr, 11U); - __SET_UINT16B(control.getDstId(), vhdr, 13U); + SET_UINT16(control.getKId(), vhdr, 11U); + SET_UINT16(control.getDstId(), vhdr, 13U); // perform RS encoding m_rs.encode362017(vhdr); diff --git a/src/host/modem/port/specialized/V24UDPPort.cpp b/src/host/modem/port/specialized/V24UDPPort.cpp index 563ac0bd..2c2dfa4d 100644 --- a/src/host/modem/port/specialized/V24UDPPort.cpp +++ b/src/host/modem/port/specialized/V24UDPPort.cpp @@ -424,7 +424,7 @@ void V24UDPPort::taskCtrlNetworkRx(V24PacketRequest* req) switch (ackMessage->getAckMessageId()) { case FSCMessageType::FSC_CONNECT: { - uint16_t vcBasePort = __GET_UINT16B(ackMessage->responseData, 1U); + uint16_t vcBasePort = GET_UINT16(ackMessage->responseData, 1U); if (network->m_socket != nullptr) { network->m_socket->close(); @@ -548,7 +548,7 @@ void V24UDPPort::taskCtrlNetworkRx(V24PacketRequest* req) ::memset(respData, 0x00U, 3U); respData[0U] = 1U; // Version 1 - __SET_UINT16B(network->m_localPort, respData, 1U); + SET_UINT16(network->m_localPort, respData, 1U); // pack ack ackResp.setResponseLength(3U); @@ -717,8 +717,7 @@ void V24UDPPort::taskVCNetworkRx(V24PacketRequest* req) if (req->length > 0) { if (udp::Socket::match(req->address, network->m_remoteRTPAddr)) { - UInt8Array __reply = std::make_unique(req->length + 4U); - uint8_t* reply = __reply.get(); + DECLARE_UINT8_ARRAY(reply, req->length + 4U); reply[0U] = DVM_SHORT_FRAME_START; reply[1U] = (req->length + 4U) & 0xFFU; diff --git a/src/host/nxdn/Control.cpp b/src/host/nxdn/Control.cpp index 62f78d62..69581b9b 100644 --- a/src/host/nxdn/Control.cpp +++ b/src/host/nxdn/Control.cpp @@ -933,8 +933,8 @@ void Control::processNetwork() // process network message header uint8_t messageType = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); if (m_debug) { LogDebug(LOG_NET, "NXDN, messageType = $%02X, srcId = %u, dstId = %u, len = %u", messageType, srcId, dstId, length); @@ -1197,7 +1197,7 @@ void Control::RPC_releaseGrantTG(json::object& req, json::object& reply) ::lookups::VoiceChData voiceCh = m_affiliations->rfCh()->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_P25, "VC %s:%u, TG grant released, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_P25, "VC %s:%u, TG grant released, srcId = %u, dstId = %u, chNo = %u-%u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->releaseGrant(dstId, false); @@ -1236,7 +1236,7 @@ void Control::RPC_touchGrantTG(json::object& req, json::object& reply) ::lookups::VoiceChData voiceCh = m_affiliations->rfCh()->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_P25, "VC %s:%u, call in progress, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_P25, "VC %s:%u, call in progress, srcId = %u, dstId = %u, chNo = %u-%u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->touchGrant(dstId); diff --git a/src/host/p25/Control.cpp b/src/host/p25/Control.cpp index ba80e271..6c8b775a 100644 --- a/src/host/p25/Control.cpp +++ b/src/host/p25/Control.cpp @@ -130,6 +130,7 @@ Control::Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t q m_aveRSSI(0U), m_rssiCount(0U), m_ccNotifyActiveTG(false), + m_disableAdjSiteBroadcast(false), m_notifyCC(true), m_ccDebug(debug), m_verbose(verbose), @@ -334,6 +335,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw m_control->m_adjSiteUpdateInterval += ccBcstInterval; m_control->m_disableGrantSrcIdCheck = p25Protocol["control"]["disableGrantSourceIdCheck"].as(false); + m_disableAdjSiteBroadcast = p25Protocol["disableAdjSiteBroadcast"].as(false); yaml::Node controlCh = rfssConfig["controlCh"]; m_notifyCC = controlCh["notifyEnable"].as(false); @@ -531,6 +533,10 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw LogInfo(" Disable Unit Registration Timeout: yes"); } + if (m_disableAdjSiteBroadcast) { + LogInfo(" Disable Adjacent Site Broadcast: yes"); + } + LogInfo(" Redundant Immediate: %s", m_control->m_redundantImmediate ? "yes" : "no"); if (m_control->m_redundantGrant) { LogInfo(" Redundant Grant Transmit: yes"); @@ -909,6 +915,11 @@ void Control::clock() if (!m_authoritative && m_permittedDstId != 0U) { m_permittedDstId = 0U; } + + // has the talkgroup hang timer expired while the modem is in a non-listening state? + if (m_rfState != RS_RF_LISTENING) { + processFrameLoss(); + } } } @@ -1035,7 +1046,7 @@ void Control::clockSiteData(uint32_t ms) if (updateCnt == 0U) { SiteData siteData = m_control->m_adjSiteTable[siteId]; - LogWarning(LOG_NET, "P25, Adjacent Site Status Expired, no data [FAILED], sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", + LogWarning(LOG_NET, "P25, Adjacent Site Status Expired, no data [FAILED], sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X", siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass()); } @@ -1054,7 +1065,7 @@ void Control::clockSiteData(uint32_t ms) if (updateCnt == 0U) { SiteData siteData = m_control->m_sccbTable[rfssId]; - LogWarning(LOG_NET, "P25, Secondary Control Channel Expired, no data [FAILED], sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", + LogWarning(LOG_NET, "P25, Secondary Control Channel Expired, no data [FAILED], sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X", siteData.sysId(), siteData.rfssId(), siteData.siteId(), siteData.channelId(), siteData.channelNo(), siteData.serviceClass()); } @@ -1398,7 +1409,7 @@ void Control::processNetwork() return; } - uint32_t blockLength = __GET_UINT16(buffer, 8U); + uint32_t blockLength = GET_UINT24(buffer, 8U); if (m_debug) { LogDebug(LOG_NET, "P25, duid = $%02X, MFId = $%02X, blockLength = %u, len = %u", duid, MFId, blockLength, length); @@ -1413,11 +1424,11 @@ void Control::processNetwork() // handle LDU, TDU or TSDU frame uint8_t lco = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); uint32_t sysId = (buffer[11U] << 8) | (buffer[12U] << 0); - uint32_t netId = __GET_UINT16(buffer, 16U); + uint32_t netId = GET_UINT24(buffer, 16U); uint8_t lsd1 = buffer[20U]; uint8_t lsd2 = buffer[21U]; @@ -2001,7 +2012,7 @@ void Control::RPC_releaseGrantTG(json::object& req, json::object& reply) ::lookups::VoiceChData voiceCh = m_affiliations->rfCh()->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_P25, "VC %s:%u, TG grant released, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_P25, "VC %s:%u, TG grant released, srcId = %u, dstId = %u, chNo = %u-%u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->releaseGrant(dstId, false); @@ -2040,7 +2051,7 @@ void Control::RPC_touchGrantTG(json::object& req, json::object& reply) ::lookups::VoiceChData voiceCh = m_affiliations->rfCh()->getRFChData(chNo); if (m_verbose) { - LogMessage(LOG_P25, "VC %s:%u, call in progress, srcId = %u, dstId = %u, chId = %u, chNo = %u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); + LogMessage(LOG_P25, "VC %s:%u, call in progress, srcId = %u, dstId = %u, chNo = %u-%u", voiceCh.address().c_str(), voiceCh.port(), srcId, dstId, voiceCh.chId(), chNo); } m_affiliations->touchGrant(dstId); @@ -2065,10 +2076,10 @@ void Control::generateLLA_AM1_Parameters() uint8_t RS[AUTH_RAND_SEED_LENGTH_BYTES]; std::uniform_int_distribution dist(DVM_RAND_MIN, DVM_RAND_MAX); uint32_t rnd = dist(m_random); - __SET_UINT32(rnd, RS, 0U); + SET_UINT32(rnd, RS, 0U); rnd = dist(m_random); - __SET_UINT32(rnd, RS, 4U); + SET_UINT32(rnd, RS, 4U); rnd = dist(m_random); RS[9U] = (uint8_t)(rnd & 0xFFU); diff --git a/src/host/p25/Control.h b/src/host/p25/Control.h index 07e17dbc..013e2c13 100644 --- a/src/host/p25/Control.h +++ b/src/host/p25/Control.h @@ -384,6 +384,8 @@ namespace p25 static std::mutex m_activeTGLock; bool m_ccNotifyActiveTG; + bool m_disableAdjSiteBroadcast; + bool m_notifyCC; bool m_ccDebug; diff --git a/src/host/p25/packet/ControlSignaling.cpp b/src/host/p25/packet/ControlSignaling.cpp index 045912c1..699e314f 100644 --- a/src/host/p25/packet/ControlSignaling.cpp +++ b/src/host/p25/packet/ControlSignaling.cpp @@ -659,7 +659,7 @@ bool ControlSignaling::process(uint8_t* data, uint32_t len, std::unique_ptr> 8, RC, 0); + SET_UINT32(challenge >> 8, RC, 0); RC[4U] = (uint8_t)(challenge & 0xFFU); // expand RAND1 to 16 bytes @@ -736,6 +736,10 @@ bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& contr return false; } + if (m_p25->m_disableAdjSiteBroadcast) { + return false; + } + OSP_ADJ_STS_BCAST* osp = static_cast(tsbk.get()); if (osp->getAdjSiteId() != m_p25->m_siteData.siteId()) { // update site table data @@ -747,7 +751,7 @@ bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& contr } if (m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", tsbk->toString().c_str(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X", tsbk->toString().c_str(), osp->getAdjSiteSysId(), osp->getAdjSiteRFSSId(), osp->getAdjSiteId(), osp->getAdjSiteChnId(), osp->getAdjSiteChnNo(), osp->getAdjSiteSvcClass()); } @@ -769,7 +773,7 @@ bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& contr } if (m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", tsbk->toString().c_str(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X", tsbk->toString().c_str(), osp->getAdjSiteSysId(), osp->getAdjSiteRFSSId(), osp->getAdjSiteId(), osp->getAdjSiteChnId(), osp->getAdjSiteChnNo(), osp->getAdjSiteSvcClass()); } @@ -826,8 +830,8 @@ bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& contr if (m_p25->m_enableControl && m_p25->m_dedicatedControl) { if (!m_p25->m_affiliations->isGranted(dstId)) { if (m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u, dstId = %u", - tsbk->toString(true).c_str(), tsbk->getEmergency(), tsbk->getEncrypted(), tsbk->getPriority(), tsbk->getGrpVchNo(), srcId, dstId); + LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u", + tsbk->toString(true).c_str(), tsbk->getEmergency(), tsbk->getEncrypted(), tsbk->getPriority(), tsbk->getGrpVchId(), tsbk->getGrpVchNo(), srcId, dstId); } uint8_t serviceOptions = (tsbk->getEmergency() ? 0x80U : 0x00U) + // Emergency Flag @@ -1043,6 +1047,10 @@ void ControlSignaling::writeAdjSSNetwork() return; } + if (m_p25->m_disableAdjSiteBroadcast) { + return; + } + if (m_p25->m_network != nullptr) { uint8_t cfva = CFVA::VALID; if (m_p25->m_enableControl && !m_p25->m_dedicatedControl) { @@ -1061,7 +1069,7 @@ void ControlSignaling::writeAdjSSNetwork() osp->setAdjSiteSvcClass(m_p25->m_siteData.serviceClass()); if (m_verbose) { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, network announce, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", osp->toString().c_str(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, network announce, sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X", osp->toString().c_str(), m_p25->m_siteData.sysId(), m_p25->m_siteData.rfssId(), m_p25->m_siteData.siteId(), m_p25->m_siteData.channelId(), m_p25->m_siteData.channelNo(), m_p25->m_siteData.serviceClass()); } @@ -2321,7 +2329,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ // if the request failed block grant if (requestFailed) { - ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_GRP_VCH (Group Voice Channel Request), failed to permit TG for use, chNo = %u", chNo); + ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_GRP_VCH (Group Voice Channel Request), failed to permit TG for use, chNo = %u-%u", voiceChData.chId(), chNo); m_p25->m_affiliations->releaseGrant(dstId, false); if (!net) { @@ -2333,7 +2341,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ } } else { - ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_GRP_VCH (Group Voice Channel Request), failed to permit TG for use, chNo = %u", chNo); + ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_GRP_VCH (Group Voice Channel Request), failed to permit TG for use, chNo = %u-%u", voiceChData.chId(), chNo); } } @@ -2341,6 +2349,34 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ ::ActivityLog("P25", true, "group grant request from %u to TG %u", srcId, dstId); } + if (voiceChData.isExplicitCh()) { + std::unique_ptr osp = std::make_unique(); + osp->setMFId(m_lastMFID); + osp->setSrcId(srcId); + osp->setDstId(dstId); + osp->setGrpVchId(voiceChData.chId()); + osp->setGrpVchNo(chNo); + osp->setRxGrpVchId(voiceChData.rxChId()); + osp->setRxGrpVchNo(voiceChData.rxChNo()); + osp->setEmergency(emergency); + osp->setEncrypted(encryption); + osp->setPriority(priority); + + osp->setForceChannelId(true); + + if (m_verbose) { + LogMessage((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u", + osp->toString().c_str(), osp->getEmergency(), osp->getEncrypted(), osp->getPriority(), osp->getGrpVchId(), osp->getGrpVchNo(), osp->getSrcId(), osp->getDstId()); + } + + // transmit group grant + writeRF_TSDU_AMBT(osp.get(), true); + if (m_redundantGrant) { + for (int i = 0; i < 3; i++) + writeRF_TSDU_AMBT(osp.get(), true); + } + } + std::unique_ptr iosp = std::make_unique(); iosp->setMFId(m_lastMFID); iosp->setSrcId(srcId); @@ -2351,16 +2387,22 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ iosp->setEncrypted(encryption); iosp->setPriority(priority); - if (m_verbose) { - LogMessage((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u, dstId = %u", - iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId()); - } + if (!voiceChData.isExplicitCh()) { + if (m_verbose) { + LogMessage((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u", + iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchId(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId()); + } - // transmit group grant - writeRF_TSDU_SBF_Imm(iosp.get(), net); - if (m_redundantGrant) { - for (int i = 0; i < 3; i++) - writeRF_TSDU_SBF(iosp.get(), net); + // transmit group grant + writeRF_TSDU_SBF_Imm(iosp.get(), net); + if (m_redundantGrant) { + for (int i = 0; i < 3; i++) + writeRF_TSDU_SBF(iosp.get(), net); + } + } else { + if (!net) { + writeNet_TSDU(iosp.get()); + } } } else { @@ -2391,7 +2433,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ // if the request failed block grant if (requestFailed) { - ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_UU_VCH (Unit-to-Unit Voice Channel Request), failed to permit TG for use, chNo = %u", chNo); + ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_UU_VCH (Unit-to-Unit Voice Channel Request), failed to permit TG for use, chNo = %u-%u", voiceChData.chId(), chNo); m_p25->m_affiliations->releaseGrant(dstId, false); if (!net) { @@ -2403,7 +2445,7 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ } } else { - ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_UU_VCH (Unit-to-Unit Voice Channel Request), failed to permit TG for use, chNo = %u", chNo); + ::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, IOSP_UU_VCH (Unit-to-Unit Voice Channel Request), failed to permit TG for use, chNo = %u-%u", voiceChData.chId(), chNo); } } @@ -2411,6 +2453,34 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ ::ActivityLog("P25", true, "unit-to-unit grant request from %u to %u", srcId, dstId); } + if (voiceChData.isExplicitCh()) { + std::unique_ptr osp = std::make_unique(); + osp->setMFId(m_lastMFID); + osp->setSrcId(srcId); + osp->setDstId(dstId); + osp->setGrpVchId(voiceChData.chId()); + osp->setGrpVchNo(chNo); + osp->setRxGrpVchId(voiceChData.rxChId()); + osp->setRxGrpVchNo(voiceChData.rxChNo()); + osp->setEmergency(emergency); + osp->setEncrypted(encryption); + osp->setPriority(priority); + + osp->setForceChannelId(true); + + if (m_verbose) { + LogMessage((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u", + osp->toString().c_str(), osp->getEmergency(), osp->getEncrypted(), osp->getPriority(), osp->getGrpVchId(), osp->getGrpVchNo(), osp->getSrcId(), osp->getDstId()); + } + + // transmit private grant + writeRF_TSDU_AMBT(osp.get(), true); + if (m_redundantGrant) { + for (int i = 0; i < 3; i++) + writeRF_TSDU_AMBT(osp.get(), true); + } + } + std::unique_ptr iosp = std::make_unique(); iosp->setMFId(m_lastMFID); iosp->setSrcId(srcId); @@ -2421,16 +2491,22 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ iosp->setEncrypted(encryption); iosp->setPriority(priority); - if (m_verbose) { - LogMessage((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u, dstId = %u", - iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId()); - } + if (!voiceChData.isExplicitCh()) { + if (m_verbose) { + LogMessage((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u, dstId = %u", + iosp->toString().c_str(), iosp->getEmergency(), iosp->getEncrypted(), iosp->getPriority(), iosp->getGrpVchId(), iosp->getGrpVchNo(), iosp->getSrcId(), iosp->getDstId()); + } - // transmit private grant - writeRF_TSDU_SBF_Imm(iosp.get(), net); - if (m_redundantGrant) { - for (int i = 0; i < 3; i++) - writeRF_TSDU_SBF(iosp.get(), net); + // transmit private grant + writeRF_TSDU_SBF_Imm(iosp.get(), net); + if (m_redundantGrant) { + for (int i = 0; i < 3; i++) + writeRF_TSDU_SBF(iosp.get(), net); + } + } else { + if (!net) { + writeNet_TSDU(iosp.get()); + } } } } @@ -2609,7 +2685,7 @@ bool ControlSignaling::writeRF_TSDU_SNDCP_Grant(uint32_t srcId, bool skip, uint3 // if the request failed block grant if (requestFailed) { - ::LogError(LOG_RF, P25_TSDU_STR ", TSBKO, ISP_SNDCP_CH_REQ (SNDCP Data Channel Request), failed to permit for use, chNo = %u", chNo); + ::LogError(LOG_RF, P25_TSDU_STR ", TSBKO, ISP_SNDCP_CH_REQ (SNDCP Data Channel Request), failed to permit for use, chNo = %u-%u", voiceChData.chId(), chNo); m_p25->m_affiliations->releaseGrant(srcId, false); writeRF_TSDU_Deny(srcId, srcId, ReasonCode::DENY_PTT_BONK, TSBKO::ISP_SNDCP_CH_REQ, false, true); @@ -2619,15 +2695,15 @@ bool ControlSignaling::writeRF_TSDU_SNDCP_Grant(uint32_t srcId, bool skip, uint3 } } else { - ::LogError(LOG_RF, P25_TSDU_STR ", TSBKO, ISP_SNDCP_CH_REQ (SNDCP Data Channel Request), failed to permit for use, chNo = %u", chNo); + ::LogError(LOG_RF, P25_TSDU_STR ", TSBKO, ISP_SNDCP_CH_REQ (SNDCP Data Channel Request), failed to permit for use, chNo = %u-%u", voiceChData.chId(), chNo); } } ::ActivityLog("P25", true, "SNDCP grant request from %u", srcId); if (m_verbose) { - LogMessage(LOG_RF, P25_TSDU_STR ", %s, chNo = %u, srcId = %u", - osp->toString().c_str(), osp->getDataChnNo(), osp->getSrcId()); + LogMessage(LOG_RF, P25_TSDU_STR ", %s, chNo = %u-%u, srcId = %u", + osp->toString().c_str(), voiceChData.chId(), osp->getDataChnNo(), osp->getSrcId()); } // transmit group grant @@ -2966,12 +3042,12 @@ void ControlSignaling::writeRF_TSDU_Auth_Dmd(uint32_t srcId) uint8_t RC[AUTH_RAND_CHLNG_LENGTH_BYTES]; std::uniform_int_distribution dist(DVM_RAND_MIN, DVM_RAND_MAX); uint32_t rnd = dist(m_p25->m_random); - __SET_UINT32(rnd, RC, 0U); + SET_UINT32(rnd, RC, 0U); rnd = dist(m_p25->m_random); RC[4U] = (uint8_t)(rnd & 0xFFU); - ulong64_t challenge = __GET_UINT32(RC, 0U); + ulong64_t challenge = GET_UINT32(RC, 0U); challenge = (challenge << 8) + RC[4U]; osp->setAuthRC(RC); diff --git a/src/host/p25/packet/Data.cpp b/src/host/p25/packet/Data.cpp index 66660bec..a15b0c50 100644 --- a/src/host/p25/packet/Data.cpp +++ b/src/host/p25/packet/Data.cpp @@ -408,11 +408,11 @@ bool Data::process(uint8_t* data, uint32_t len) ::memset(arpPacket, 0x00U, P25_PDU_ARP_PCKT_LENGTH); ::memcpy(arpPacket, m_rfPduUserData + P25_PDU_HEADER_LENGTH_BYTES, P25_PDU_ARP_PCKT_LENGTH); - uint16_t opcode = __GET_UINT16B(arpPacket, 6U); - uint32_t srcHWAddr = __GET_UINT16(arpPacket, 8U); - uint32_t srcProtoAddr = __GET_UINT32(arpPacket, 11U); - //uint32_t tgtHWAddr = __GET_UINT16(arpPacket, 15U); - uint32_t tgtProtoAddr = __GET_UINT32(arpPacket, 18U); + uint16_t opcode = GET_UINT16(arpPacket, 6U); + uint32_t srcHWAddr = GET_UINT24(arpPacket, 8U); + uint32_t srcProtoAddr = GET_UINT32(arpPacket, 11U); + //uint32_t tgtHWAddr = GET_UINT24(arpPacket, 15U); + uint32_t tgtProtoAddr = GET_UINT32(arpPacket, 18U); if (m_verbose) { if (opcode == P25_PDU_ARP_REQUEST) { @@ -755,11 +755,11 @@ bool Data::processNetwork(uint8_t* data, uint32_t len, uint32_t blockLength) ::memset(arpPacket, 0x00U, P25_PDU_ARP_PCKT_LENGTH); ::memcpy(arpPacket, m_netPduUserData + P25_PDU_HEADER_LENGTH_BYTES, P25_PDU_ARP_PCKT_LENGTH); - uint16_t opcode = __GET_UINT16B(arpPacket, 6U); - uint32_t srcHWAddr = __GET_UINT16(arpPacket, 8U); - uint32_t srcProtoAddr = __GET_UINT32(arpPacket, 11U); - //uint32_t tgtHWAddr = __GET_UINT16(arpPacket, 15U); - uint32_t tgtProtoAddr = __GET_UINT32(arpPacket, 18U); + uint16_t opcode = GET_UINT16(arpPacket, 6U); + uint32_t srcHWAddr = GET_UINT24(arpPacket, 8U); + uint32_t srcProtoAddr = GET_UINT32(arpPacket, 11U); + //uint32_t tgtHWAddr = GET_UINT24(arpPacket, 15U); + uint32_t tgtProtoAddr = GET_UINT32(arpPacket, 18U); if (m_verbose) { if (opcode == P25_PDU_ARP_REQUEST) { @@ -831,10 +831,8 @@ void Data::writeRF_PDU_User(data::DataHeader& dataHeader, bool extendedAddress, uint32_t offset = P25_PREAMBLE_LENGTH_BITS; - UInt8Array __data = std::make_unique((bitLength / 8U) + 1U); - uint8_t* data = __data.get(); + DECLARE_UINT8_ARRAY(data, (bitLength / 8U) + 1U); - ::memset(data, 0x00U, bitLength / 8U); uint8_t block[P25_PDU_FEC_LENGTH_BYTES]; ::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES); @@ -1467,10 +1465,8 @@ void Data::writeNet_PDU_Buffered() uint32_t offset = P25_PREAMBLE_LENGTH_BITS; - UInt8Array __data = std::make_unique((bitLength / 8U) + 1U); - uint8_t* data = __data.get(); + DECLARE_UINT8_ARRAY(data, (bitLength / 8U) + 1U); - ::memset(data, 0x00U, bitLength / 8U); uint8_t block[P25_PDU_FEC_LENGTH_BYTES]; ::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES); @@ -1561,10 +1557,8 @@ void Data::writeRF_PDU_Buffered() uint32_t offset = P25_PREAMBLE_LENGTH_BITS; - UInt8Array __data = std::make_unique((bitLength / 8U) + 1U); - uint8_t* data = __data.get(); + DECLARE_UINT8_ARRAY(data, (bitLength / 8U) + 1U); - ::memset(data, 0x00U, bitLength / 8U); uint8_t block[P25_PDU_FEC_LENGTH_BYTES]; ::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES); @@ -1688,10 +1682,8 @@ void Data::writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint8_t a uint32_t bitLength = (1U * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS; uint32_t offset = P25_PREAMBLE_LENGTH_BITS; - UInt8Array __data = std::make_unique((bitLength / 8U) + 1U); - uint8_t* data = __data.get(); + DECLARE_UINT8_ARRAY(data, (bitLength / 8U) + 1U); - ::memset(data, 0x00U, bitLength / 8U); uint8_t block[P25_PDU_FEC_LENGTH_BYTES]; ::memset(block, 0x00U, P25_PDU_FEC_LENGTH_BYTES); diff --git a/src/host/p25/packet/Voice.cpp b/src/host/p25/packet/Voice.cpp index 408d2e61..2382c18a 100644 --- a/src/host/p25/packet/Voice.cpp +++ b/src/host/p25/packet/Voice.cpp @@ -128,16 +128,18 @@ bool Voice::process(uint8_t* data, uint32_t len) return false; } - if (m_verbose && m_debug) { - uint8_t mi[MI_LENGTH_BYTES]; - ::memset(mi, 0x00U, MI_LENGTH_BYTES); - lc.getMI(mi); - - Utils::dump(1U, "P25 HDU MI read from RF", mi, MI_LENGTH_BYTES); - } - if (m_verbose) { LogMessage(LOG_RF, P25_HDU_STR ", HDU_BSDWNACT, dstId = %u, algo = $%02X, kid = $%04X", lc.getDstId(), lc.getAlgId(), lc.getKId()); + + if (lc.getAlgId() != ALGO_UNENCRYPT) { + uint8_t mi[MI_LENGTH_BYTES]; + ::memset(mi, 0x00U, MI_LENGTH_BYTES); + + lc.getMI(mi); + + LogMessage(LOG_RF, P25_HDU_STR ", Enc Sync, MI = %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); + } } // don't process RF frames if this modem isn't authoritative @@ -919,6 +921,16 @@ bool Voice::process(uint8_t* data, uint32_t len) if (m_verbose) { LogMessage(LOG_RF, P25_LDU2_STR ", audio, algo = $%02X, kid = $%04X, errs = %u/1233 (%.1f%%)", m_rfLC.getAlgId(), m_rfLC.getKId(), errors, float(errors) / 12.33F); + + if (m_rfLC.getAlgId() != ALGO_UNENCRYPT) { + uint8_t mi[MI_LENGTH_BYTES]; + ::memset(mi, 0x00U, MI_LENGTH_BYTES); + + m_rfLC.getMI(mi); + + LogMessage(LOG_RF, P25_LDU2_STR ", Enc Sync, MI = %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); + } } return true; @@ -1737,10 +1749,6 @@ void Voice::writeNet_LDU1() // restore MI from member variable ::memcpy(mi, m_lastMI, MI_LENGTH_BYTES); - if (m_verbose && m_debug) { - Utils::dump(1U, "P25 HDU MI from network to RF", mi, MI_LENGTH_BYTES); - } - m_netLC.setMI(mi); m_rfLC.setMI(mi); m_netLC.setAlgId(control.getAlgId()); @@ -1890,6 +1898,11 @@ void Voice::writeNet_LDU1() if (m_verbose) { LogMessage(LOG_NET, P25_HDU_STR ", dstId = %u, algo = $%02X, kid = $%04X", m_netLC.getDstId(), m_netLC.getAlgId(), m_netLC.getKId()); + + if (control.getAlgId() != ALGO_UNENCRYPT) { + LogMessage(LOG_NET, P25_HDU_STR ", Enc Sync, MI = %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); + } } } else { @@ -2071,10 +2084,6 @@ void Voice::writeNet_LDU2() uint8_t mi[MI_LENGTH_BYTES]; control.getMI(mi); - if (m_verbose && m_debug) { - Utils::dump(1U, "Network LDU2 MI", mi, MI_LENGTH_BYTES); - } - m_netLC.setMI(mi); m_netLC.setAlgId(control.getAlgId()); m_netLC.setKId(control.getKId()); @@ -2117,6 +2126,11 @@ void Voice::writeNet_LDU2() if (m_verbose) { LogMessage(LOG_NET, P25_LDU2_STR " audio, algo = $%02X, kid = $%04X", m_netLC.getAlgId(), m_netLC.getKId()); + + if (control.getAlgId() != ALGO_UNENCRYPT) { + LogMessage(LOG_NET, P25_LDU2_STR ", Enc Sync, MI = %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); + } } resetWithNullAudio(m_netLDU2, m_netLC.getAlgId() != P25DEF::ALGO_UNENCRYPT); diff --git a/src/host/setup/HostSetup.cpp b/src/host/setup/HostSetup.cpp index 08726c36..5b413b8d 100644 --- a/src/host/setup/HostSetup.cpp +++ b/src/host/setup/HostSetup.cpp @@ -179,7 +179,7 @@ int HostSetup::run(int argc, char** argv) } ::LogInfo(__PROG_NAME__ " " __VER__ " (built " __BUILD__ ")\r\n" \ - "Copyright (c) 2017-2024 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\r\n" \ + "Copyright (c) 2017-2025 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\r\n" \ "Portions Copyright (c) 2015-2021 by Jonathan Naylor, G4KLX and others\r\n" \ ">> Modem Setup\r\n"); @@ -414,7 +414,11 @@ bool HostSetup::portModemHandler(Modem* modem, uint32_t ms, RESP_TYPE_DVM rspTyp /** Project 25 */ case CMD_P25_DATA: - processP25BER(buffer + 4U); + if (rspDblLen) { + processP25BER(buffer + 5U); + } else { + processP25BER(buffer + 4U); + } break; case CMD_P25_LOST: @@ -1126,6 +1130,14 @@ void HostSetup::processP25BER(const uint8_t* buffer) } else { LogMessage(LOG_CAL, P25_HDU_STR ", dstId = %u, algo = %X, kid = %X", lc.getDstId(), lc.getAlgId(), lc.getKId()); + + uint8_t mi[MI_LENGTH_BYTES]; + ::memset(mi, 0x00U, MI_LENGTH_BYTES); + + lc.getMI(mi); + + LogMessage(LOG_CAL, P25_HDU_STR ", MI %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); } m_berBits = 0U; @@ -1218,6 +1230,14 @@ void HostSetup::processP25BER(const uint8_t* buffer) else { LogMessage(LOG_CAL, P25_LDU2_STR " LC, mfId = $%02X, algo = %X, kid = %X", lc.getMFId(), lc.getAlgId(), lc.getKId()); + + uint8_t mi[MI_LENGTH_BYTES]; + ::memset(mi, 0x00U, MI_LENGTH_BYTES); + + lc.getMI(mi); + + LogMessage(LOG_CAL, P25_LDU2_STR ", MI %02X %02X %02X %02X %02X %02X %02X %02X %02X", + mi[0U], mi[1U], mi[2U], mi[3U], mi[4U], mi[5U], mi[6U], mi[7U], mi[8U]); } P25Utils::decode(buffer, imbe, 114U, 262U); @@ -1266,22 +1286,25 @@ void HostSetup::processP25BER(const uint8_t* buffer) timerStop(); // note: for the calibrator we will only process the PDU header -- and not the PDU data - uint8_t pduBuffer[P25_LDU_FRAME_LENGTH_BYTES]; - uint32_t bits = P25Utils::decode(buffer, pduBuffer, 0, P25_LDU_FRAME_LENGTH_BITS); + uint8_t pduBuffer[P25_PDU_FRAME_LENGTH_BYTES]; + ::memset(pduBuffer, 0x00U, P25_PDU_FRAME_LENGTH_BYTES); + + uint32_t bits = P25Utils::decode(buffer, pduBuffer, 0, P25_PDU_FRAME_LENGTH_BITS); + + Utils::dump(1U, "Raw PDU Dump", buffer, P25_PDU_FRAME_LENGTH_BYTES); uint8_t* rfPDU = new uint8_t[P25_MAX_PDU_BLOCKS * P25_PDU_CONFIRMED_LENGTH_BYTES + 2U]; ::memset(rfPDU, 0x00U, P25_MAX_PDU_BLOCKS * P25_PDU_CONFIRMED_LENGTH_BYTES + 2U); - uint32_t rfPDUBits = 0U; - for (uint32_t i = 0U; i < bits; i++, rfPDUBits++) { - bool b = READ_BIT(buffer, i); - WRITE_BIT(rfPDU, rfPDUBits, b); - } + uint32_t rfPDUBits = 0U; + rfPDUBits = Utils::getBits(pduBuffer, rfPDU, 0U, bits); - bool ret = dataHeader.decode(rfPDU + P25_SYNC_LENGTH_BYTES + P25_NID_LENGTH_BYTES); + ::memset(pduBuffer, 0x00U, P25_PDU_FEC_LENGTH_BYTES); + Utils::getBitRange(rfPDU, pduBuffer, P25_PREAMBLE_LENGTH_BITS, P25_PDU_FEC_LENGTH_BITS); + bool ret = dataHeader.decode(pduBuffer); if (!ret) { - LogWarning(LOG_RF, P25_PDU_STR ", unfixable RF 1/2 rate header data"); - Utils::dump(1U, "Unfixable PDU Data", rfPDU + P25_SYNC_LENGTH_BYTES + P25_NID_LENGTH_BYTES, P25_PDU_HEADER_LENGTH_BYTES); + LogWarning(LOG_CAL, P25_PDU_STR ", unfixable RF 1/2 rate header data"); + Utils::dump(1U, "Unfixable PDU Data", pduBuffer, P25_PDU_FEC_LENGTH_BYTES); } else { LogMessage(LOG_CAL, P25_PDU_STR ", ack = %u, outbound = %u, fmt = $%02X, mfId = $%02X, sap = $%02X, fullMessage = %u, blocksToFollow = %u, padLength = %u, n = %u, seqNo = %u, lastFragment = %u, hdrOffset = %u", @@ -1983,9 +2006,9 @@ bool HostSetup::writeFlash() buffer[24U] = (uint8_t)m_modem->m_adfGainMode; uint32_t txTuning = (uint32_t)m_modem->m_txTuning; - __SET_UINT32(txTuning, buffer, 25U); + SET_UINT32(txTuning, buffer, 25U); uint32_t rxTuning = (uint32_t)m_modem->m_rxTuning; - __SET_UINT32(rxTuning, buffer, 29U); + SET_UINT32(rxTuning, buffer, 29U); // symbol adjust buffer[35U] = (uint8_t)(m_modem->m_dmrSymLevel3Adj + 128); diff --git a/src/patch/HostPatch.cpp b/src/patch/HostPatch.cpp index 6f575669..cd040b0d 100644 --- a/src/patch/HostPatch.cpp +++ b/src/patch/HostPatch.cpp @@ -415,8 +415,8 @@ void HostPatch::processDMRNetwork(uint8_t* buffer, uint32_t length) // process network message header uint32_t seqNo = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); uint8_t controlByte = buffer[14U]; @@ -725,8 +725,8 @@ void HostPatch::processP25Network(uint8_t* buffer, uint32_t length) // handle LDU, TDU or TSDU frame uint8_t lco = buffer[4U]; - uint32_t srcId = __GET_UINT16(buffer, 5U); - uint32_t dstId = __GET_UINT16(buffer, 8U); + uint32_t srcId = GET_UINT24(buffer, 5U); + uint32_t dstId = GET_UINT24(buffer, 8U); uint8_t lsd1 = buffer[20U]; uint8_t lsd2 = buffer[21U]; @@ -888,7 +888,7 @@ void HostPatch::processP25Network(uint8_t* buffer, uint32_t length) if (frameType == FrameType::HDU_VALID) { uint8_t algoId = buffer[181U]; if (algoId != ALGO_UNENCRYPT) { - uint16_t kid = __GET_UINT16B(buffer, 182U); + uint16_t kid = GET_UINT16(buffer, 182U); uint8_t mi[MI_LENGTH_BYTES]; ::memset(mi, 0x00U, MI_LENGTH_BYTES); diff --git a/src/patch/PatchMain.cpp b/src/patch/PatchMain.cpp index 382c05cf..f03ef9b7 100644 --- a/src/patch/PatchMain.cpp +++ b/src/patch/PatchMain.cpp @@ -176,7 +176,7 @@ int main(int argc, char** argv) ::memset(g_gitHashBytes, 0x00U, 4U); uint32_t hash = ::strtoul(__GIT_VER_HASH__, 0, 16); - __SET_UINT32(hash, g_gitHashBytes, 0U); + SET_UINT32(hash, g_gitHashBytes, 0U); if (argv[0] != nullptr && *argv[0] != 0) g_progExe = std::string(argv[0]); diff --git a/src/patch/network/PeerNetwork.cpp b/src/patch/network/PeerNetwork.cpp index 63cd8c22..a16c0ecf 100644 --- a/src/patch/network/PeerNetwork.cpp +++ b/src/patch/network/PeerNetwork.cpp @@ -192,8 +192,7 @@ bool PeerNetwork::writeConfig() json::value v = json::value(config); std::string json = v.serialize(); - CharArray __buffer = std::make_unique(json.length() + 9U); - char* buffer = __buffer.get(); + DECLARE_CHAR_ARRAY(buffer, json.length() + 9U); ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); ::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str()); diff --git a/src/sysview/SysViewMain.cpp b/src/sysview/SysViewMain.cpp index cf099344..d7923c18 100644 --- a/src/sysview/SysViewMain.cpp +++ b/src/sysview/SysViewMain.cpp @@ -318,8 +318,8 @@ void* threadNetworkPump(void* arg) uint8_t seqNo = dmrBuffer[4U]; - uint32_t srcId = __GET_UINT16(dmrBuffer, 5U); - uint32_t dstId = __GET_UINT16(dmrBuffer, 8U); + uint32_t srcId = GET_UINT24(dmrBuffer, 5U); + uint32_t dstId = GET_UINT24(dmrBuffer, 8U); DMRDEF::FLCO::E flco = (dmrBuffer[15U] & 0x40U) == 0x40U ? DMRDEF::FLCO::PRIVATE : DMRDEF::FLCO::GROUP; @@ -497,11 +497,11 @@ void* threadNetworkPump(void* arg) uint8_t lco = p25Buffer[4U]; - uint32_t srcId = __GET_UINT16(p25Buffer, 5U); - uint32_t dstId = __GET_UINT16(p25Buffer, 8U); + uint32_t srcId = GET_UINT24(p25Buffer, 5U); + uint32_t dstId = GET_UINT24(p25Buffer, 8U); uint32_t sysId = (p25Buffer[11U] << 8) | (p25Buffer[12U] << 0); - uint32_t netId = __GET_UINT16(p25Buffer, 16U); + uint32_t netId = GET_UINT24(p25Buffer, 16U); // log call status if (duid != P25DEF::DUID::TSDU && duid != P25DEF::DUID::PDU) { @@ -583,8 +583,8 @@ void* threadNetworkPump(void* arg) case P25DEF::TSBKO::IOSP_GRP_VCH: case P25DEF::TSBKO::IOSP_UU_VCH: { - LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u, srcId = %u (%s), dstId = %u (%s)", - tsbk->toString(true).c_str(), tsbk->getEmergency(), tsbk->getEncrypted(), tsbk->getPriority(), tsbk->getGrpVchNo(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, srcId = %u (%s), dstId = %u (%s)", + tsbk->toString(true).c_str(), tsbk->getEmergency(), tsbk->getEncrypted(), tsbk->getPriority(), tsbk->getGrpVchId(), tsbk->getGrpVchNo(), srcId, resolveRID(srcId).c_str(), dstId, resolveTGID(dstId).c_str()); // generate a net event for this @@ -595,6 +595,8 @@ void* threadNetworkPump(void* arg) netEvent["encry"].set(encry); uint8_t prio = tsbk->getPriority(); netEvent["prio"].set(prio); + uint32_t chId = tsbk->getGrpVchId(); + netEvent["chId"].set(chId); uint32_t chNo = tsbk->getGrpVchNo(); netEvent["chNo"].set(chNo); @@ -865,7 +867,7 @@ void* threadNetworkPump(void* arg) case P25DEF::TSBKO::OSP_ADJ_STS_BCAST: { lc::tsbk::OSP_ADJ_STS_BCAST* osp = static_cast(tsbk.get()); - LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", tsbk->toString().c_str(), + LogMessage(LOG_NET, P25_TSDU_STR ", %s, sysId = $%03X, rfss = $%02X, site = $%02X, chNo = %u-%u, svcClass = $%02X", tsbk->toString().c_str(), osp->getAdjSiteSysId(), osp->getAdjSiteRFSSId(), osp->getAdjSiteId(), osp->getAdjSiteChnId(), osp->getAdjSiteChnNo(), osp->getAdjSiteSvcClass()); // generate a net event for this @@ -920,8 +922,8 @@ void* threadNetworkPump(void* arg) uint8_t messageType = nxdnBuffer[4U]; - uint32_t srcId = __GET_UINT16(nxdnBuffer, 5U); - uint32_t dstId = __GET_UINT16(nxdnBuffer, 8U); + uint32_t srcId = GET_UINT24(nxdnBuffer, 5U); + uint32_t dstId = GET_UINT24(nxdnBuffer, 8U); lc::RTCH lc; diff --git a/src/sysview/network/PeerNetwork.cpp b/src/sysview/network/PeerNetwork.cpp index 043de10a..cd8f174b 100644 --- a/src/sysview/network/PeerNetwork.cpp +++ b/src/sysview/network/PeerNetwork.cpp @@ -39,12 +39,8 @@ PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t loc Network(address, port, localPort, peerId, password, duplex, debug, dmr, p25, nxdn, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup, saveLookup), peerStatus(), m_peerLink(false), - m_tgidCompressedSize(0U), - m_tgidSize(0U), - m_tgidBuffer(nullptr), - m_ridCompressedSize(0U), - m_ridSize(0U), - m_ridBuffer(nullptr) + m_tgidPkt(true, "Peer-Link, TGID List"), + m_ridPkt(true, "Peer-Link, RID List") { assert(!address.empty()); assert(port > 0U); @@ -68,9 +64,7 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco switch (opcode.second) { case NET_SUBFUNC::TRANSFER_SUBFUNC_ACTIVITY: { - UInt8Array __rawPayload = std::make_unique(length - 11U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, length - 11U); + DECLARE_UINT8_ARRAY(rawPayload, length - 11U); ::memcpy(rawPayload, data + 11U, length - 11U); std::string payload(rawPayload, rawPayload + (length - 11U)); @@ -89,9 +83,7 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco case NET_SUBFUNC::TRANSFER_SUBFUNC_STATUS: { - UInt8Array __rawPayload = std::make_unique(length - 11U); - uint8_t* rawPayload = __rawPayload.get(); - ::memset(rawPayload, 0x00U, length - 11U); + DECLARE_UINT8_ARRAY(rawPayload, length - 11U); ::memcpy(rawPayload, data + 11U, length - 11U); std::string payload(rawPayload, rawPayload + (length - 11U)); @@ -128,274 +120,104 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco switch (opcode.second) { case NET_SUBFUNC::PL_TALKGROUP_LIST: { - uint8_t curBlock = data[8U]; - uint8_t blockCnt = data[9U]; - - // if this is the first block store sizes and initialize temp buffer - if (curBlock == 0U) { - m_tgidSize = __GET_UINT32(data, 0U); - m_tgidCompressedSize = __GET_UINT32(data, 4U); - - if (m_tgidBuffer != nullptr) - delete[] m_tgidBuffer; - if (m_tgidSize < PEER_LINK_BLOCK_SIZE) - m_tgidBuffer = new uint8_t[PEER_LINK_BLOCK_SIZE + 1U]; - else - m_tgidBuffer = new uint8_t[m_tgidSize + 1U]; - } + uint32_t decompressedLen = 0U; + uint8_t* decompressed = nullptr; + + if (m_tgidPkt.decode(data, &decompressed, &decompressedLen)) { + if (m_tidLookup == nullptr) { + LogError(LOG_NET, "Talkgroup ID lookups not available yet."); + m_tgidPkt.clear(); + delete[] decompressed; + break; + } - if (m_tgidBuffer != nullptr) { - if (curBlock < blockCnt) { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_tgidBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - } else { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_tgidBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Compressed Payload", m_tgidBuffer, m_tgidCompressedSize); - - // handle last block - // compression structures - z_stream strm; - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - - // set input data - strm.avail_in = m_tgidCompressedSize; - strm.next_in = m_tgidBuffer; - - // initialize decompression - int ret = inflateInit(&strm); - if (ret != Z_OK) { - LogError(LOG_NET, "PEER %u error initializing ZLIB", peerId); - - m_tgidSize = 0U; - m_tgidCompressedSize = 0U; - if (m_tgidBuffer != nullptr) - delete[] m_tgidBuffer; - m_tgidBuffer = nullptr; - break; - } - - // decompress data - std::vector decompressedData; - uint8_t outbuffer[1024]; - do { - strm.avail_out = sizeof(outbuffer); - strm.next_out = outbuffer; - - ret = inflate(&strm, Z_NO_FLUSH); - if (ret == Z_STREAM_ERROR) { - LogError(LOG_NET, "PEER %u error decompressing TGID list", peerId); - inflateEnd(&strm); - goto tid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - decompressedData.insert(decompressedData.end(), outbuffer, outbuffer + sizeof(outbuffer) - strm.avail_out); - } while (ret != Z_STREAM_END); - - // cleanup - inflateEnd(&strm); - - // scope is intentional - { - uint32_t decompressedLen = strm.total_out; - uint8_t* decompressed = decompressedData.data(); - - // Utils::dump(1U, "Raw TGID Data", decompressed, decompressedLen); - - // check that we got the appropriate data - if (decompressedLen == m_tgidSize) { - if (m_tidLookup == nullptr) { - LogError(LOG_NET, "Talkgroup ID lookups not available yet."); - goto tid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - // store to file - std::unique_ptr __str = std::make_unique(decompressedLen + 1U); - char* str = __str.get(); - ::memcpy(str, decompressed, decompressedLen); - str[decompressedLen] = 0; // null termination - - // randomize filename - std::ostringstream s; - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); - s << "/tmp/talkgroup_rules.yml." << dist(mt); - - std::string filename = s.str(); - std::ofstream file(filename, std::ofstream::out); - if (file.fail()) { - LogError(LOG_NET, "Cannot open the talkgroup ID lookup file - %s", filename.c_str()); - goto tid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - file << str; - file.close(); - - m_tidLookup->stop(true); - m_tidLookup->filename(filename); - m_tidLookup->reload(); - - // flag this peer as Peer-Link enabled - m_peerLink = true; - - // cleanup temporary file - ::remove(filename.c_str()); - } - else { - LogError(LOG_NET, "PEER %u error decompressed TGID list, was not of expected size! %u != %u", peerId, decompressedLen, m_tgidSize); - } - } - - tid_lookup_cleanup: - m_tgidSize = 0U; - m_tgidCompressedSize = 0U; - if (m_tgidBuffer != nullptr) - delete[] m_tgidBuffer; - m_tgidBuffer = nullptr; + // store to file + DECLARE_CHAR_ARRAY(str, decompressedLen + 1U); + ::memcpy(str, decompressed, decompressedLen); + str[decompressedLen] = 0; // null termination + + // randomize filename + std::ostringstream s; + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); + s << "/tmp/talkgroup_rules.yml." << dist(mt); + + std::string filename = s.str(); + std::ofstream file(filename, std::ofstream::out); + if (file.fail()) { + LogError(LOG_NET, "Cannot open the talkgroup ID lookup file - %s", filename.c_str()); + m_tgidPkt.clear(); + delete[] decompressed; + break; } + + file << str; + file.close(); + + m_tidLookup->stop(true); + m_tidLookup->filename(filename); + m_tidLookup->reload(); + + // flag this peer as Peer-Link enabled + m_peerLink = true; + + // cleanup temporary file + ::remove(filename.c_str()); + m_tgidPkt.clear(); + delete[] decompressed; } } break; case NET_SUBFUNC::PL_RID_LIST: { - uint8_t curBlock = data[8U]; - uint8_t blockCnt = data[9U]; - - // if this is the first block store sizes and initialize temp buffer - if (curBlock == 0U) { - m_ridSize = __GET_UINT32(data, 0U); - m_ridCompressedSize = __GET_UINT32(data, 4U); - - if (m_ridBuffer != nullptr) - delete[] m_ridBuffer; - if (m_ridSize < PEER_LINK_BLOCK_SIZE) - m_ridBuffer = new uint8_t[PEER_LINK_BLOCK_SIZE + 1U]; - else - m_ridBuffer = new uint8_t[m_ridSize + 1U]; - } + uint32_t decompressedLen = 0U; + uint8_t* decompressed = nullptr; + + if (m_ridPkt.decode(data, &decompressed, &decompressedLen)) { + if (m_ridLookup == nullptr) { + LogError(LOG_NET, "Radio ID lookups not available yet."); + m_ridPkt.clear(); + delete[] decompressed; + break; + } - if (m_ridBuffer != nullptr) { - if (curBlock < blockCnt) { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_ridBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - } else { - uint32_t offs = curBlock * PEER_LINK_BLOCK_SIZE; - ::memcpy(m_ridBuffer + offs, data + 10U, PEER_LINK_BLOCK_SIZE); - - // Utils::dump(1U, "Block Payload", data, 10U + PEER_LINK_BLOCK_SIZE); - // Utils::dump(1U, "Compressed Payload", m_ridBuffer, m_ridCompressedSize); - - // handle last block - // compression structures - z_stream strm; - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - - // set input data - strm.avail_in = m_ridCompressedSize; - strm.next_in = m_ridBuffer; - - // initialize decompression - int ret = inflateInit(&strm); - if (ret != Z_OK) { - LogError(LOG_NET, "PEER %u error initializing ZLIB", peerId); - - m_ridSize = 0U; - m_ridCompressedSize = 0U; - if (m_ridBuffer != nullptr) - delete[] m_ridBuffer; - m_ridBuffer = nullptr; - break; - } - - // decompress data - std::vector decompressedData; - uint8_t outbuffer[1024]; - do { - strm.avail_out = sizeof(outbuffer); - strm.next_out = outbuffer; - - ret = inflate(&strm, Z_NO_FLUSH); - if (ret == Z_STREAM_ERROR) { - LogError(LOG_NET, "PEER %u error decompressing RID list", peerId); - inflateEnd(&strm); - goto rid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - decompressedData.insert(decompressedData.end(), outbuffer, outbuffer + sizeof(outbuffer) - strm.avail_out); - } while (ret != Z_STREAM_END); - - // cleanup - inflateEnd(&strm); - - // scope is intentional - { - uint32_t decompressedLen = strm.total_out; - uint8_t* decompressed = decompressedData.data(); - - // Utils::dump(1U, "Raw RID Data", decompressed, decompressedLen); - - // check that we got the appropriate data - if (decompressedLen == m_ridSize) { - if (m_ridLookup == nullptr) { - LogError(LOG_NET, "Radio ID lookups not available yet."); - goto rid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - // store to file - std::unique_ptr __str = std::make_unique(decompressedLen + 1U); - char* str = __str.get(); - ::memcpy(str, decompressed, decompressedLen); - str[decompressedLen] = 0; // null termination - - // randomize filename - std::ostringstream s; - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); - s << "/tmp/rid_acl.dat." << dist(mt); - - std::string filename = s.str(); - std::ofstream file(filename, std::ofstream::out); - if (file.fail()) { - LogError(LOG_NET, "Cannot open the radio ID lookup file - %s", filename.c_str()); - goto rid_lookup_cleanup; // yes - I hate myself; but this is quick - } - - file << str; - file.close(); - - m_ridLookup->stop(true); - m_ridLookup->filename(filename); - m_ridLookup->reload(); - - // flag this peer as Peer-Link enabled - m_peerLink = true; - - // cleanup temporary file - ::remove(filename.c_str()); - } - else { - LogError(LOG_NET, "PEER %u error decompressed RID list, was not of expected size! %u != %u", peerId, decompressedLen, m_ridSize); - } - } - - rid_lookup_cleanup: - m_ridSize = 0U; - m_ridCompressedSize = 0U; - if (m_ridBuffer != nullptr) - delete[] m_ridBuffer; - m_ridBuffer = nullptr; + // store to file + DECLARE_CHAR_ARRAY(str, decompressedLen + 1U); + ::memcpy(str, decompressed, decompressedLen); + str[decompressedLen] = 0; // null termination + + // randomize filename + std::ostringstream s; + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution dist(0x00U, 0xFFFFFFFFU); + s << "/tmp/rid_acl.dat." << dist(mt); + + std::string filename = s.str(); + std::ofstream file(filename, std::ofstream::out); + if (file.fail()) { + LogError(LOG_NET, "Cannot open the radio ID lookup file - %s", filename.c_str()); + m_ridPkt.clear(); + delete[] decompressed; + break; } + + file << str; + file.close(); + + m_ridLookup->stop(true); + m_ridLookup->filename(filename); + m_ridLookup->reload(); + + // flag this peer as Peer-Link enabled + m_peerLink = true; + + // cleanup temporary file + ::remove(filename.c_str()); + m_ridPkt.clear(); + delete[] decompressed; } } break; @@ -467,8 +289,7 @@ bool PeerNetwork::writeConfig() json::value v = json::value(config); std::string json = v.serialize(); - CharArray __buffer = std::make_unique(json.length() + 9U); - char* buffer = __buffer.get(); + DECLARE_CHAR_ARRAY(buffer, json.length() + 9U); ::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U); ::snprintf(buffer + 8U, json.length() + 1U, "%s", json.c_str()); diff --git a/src/sysview/network/PeerNetwork.h b/src/sysview/network/PeerNetwork.h index b4729c67..7c1aa20a 100644 --- a/src/sysview/network/PeerNetwork.h +++ b/src/sysview/network/PeerNetwork.h @@ -22,6 +22,7 @@ #include "Defines.h" #include "common/network/Network.h" +#include "common/network/PacketBuffer.h" #include #include @@ -101,15 +102,8 @@ namespace network static std::mutex m_peerStatusMutex; bool m_peerLink; - uint32_t m_tgidCompressedSize; - uint32_t m_tgidSize; - - uint8_t* m_tgidBuffer; - - uint32_t m_ridCompressedSize; - uint32_t m_ridSize; - - uint8_t* m_ridBuffer; + PacketBuffer m_tgidPkt; + PacketBuffer m_ridPkt; }; } // namespace network diff --git a/src/sysview/p25/tsbk/OSP_GRP_AFF.h b/src/sysview/p25/tsbk/OSP_GRP_AFF.h index 6d19d555..14f775ac 100644 --- a/src/sysview/p25/tsbk/OSP_GRP_AFF.h +++ b/src/sysview/p25/tsbk/OSP_GRP_AFF.h @@ -65,9 +65,9 @@ namespace p25 /** * @brief Announcement group. */ - __PROPERTY(uint32_t, announceGroup, AnnounceGroup); + DECLARE_PROPERTY(uint32_t, announceGroup, AnnounceGroup); - __COPY(OSP_GRP_AFF); + DECLARE_COPY(OSP_GRP_AFF); }; } // namespace tsbk } // namespace lc diff --git a/src/vocoder/MBEDecoder.h b/src/vocoder/MBEDecoder.h index e18615ad..1aef85c6 100644 --- a/src/vocoder/MBEDecoder.h +++ b/src/vocoder/MBEDecoder.h @@ -130,11 +130,11 @@ namespace vocoder /** * @brief Gain adjustment. */ - __PROPERTY(float, gainAdjust, GainAdjust); + DECLARE_PROPERTY(float, gainAdjust, GainAdjust); /** * @brief Flag indicating automatic gain adjustment is enabled. */ - __PROPERTY(bool, autoGain, AutoGain); + DECLARE_PROPERTY(bool, autoGain, AutoGain); }; } // namespace vocoder diff --git a/src/vocoder/MBEEncoder.h b/src/vocoder/MBEEncoder.h index f4447399..c4fbb061 100644 --- a/src/vocoder/MBEEncoder.h +++ b/src/vocoder/MBEEncoder.h @@ -77,7 +77,7 @@ namespace vocoder /** * @brief Gain adjustment. */ - __PROPERTY(float, gainAdjust, GainAdjust); + DECLARE_PROPERTY(float, gainAdjust, GainAdjust); }; } // namespace vocoder