code reorganization;

pull/12/head
Bryan Biedenkapp 4 years ago
parent 14a96cebf7
commit 328bd1024d

@ -43,13 +43,13 @@ HOST_OBJECTS = \
dmr/lc/LC.o \
dmr/lc/PrivacyLC.o \
dmr/lc/ShortLC.o \
dmr/packet/ControlSignaling.o \
dmr/packet/Data.o \
dmr/packet/Voice.o \
dmr/Control.o \
dmr/ControlPacket.o \
dmr/DataPacket.o \
dmr/Slot.o \
dmr/SlotType.o \
dmr/Sync.o \
dmr/VoicePacket.o \
lookups/IdenTableLookup.o \
lookups/RadioIdLookup.o \
lookups/RSSIInterpolator.o \
@ -59,20 +59,20 @@ HOST_OBJECTS = \
p25/data/DataHeader.o \
p25/data/LowSpeedData.o \
p25/dfsi/LC.o \
p25/dfsi/DFSITrunkPacket.o \
p25/dfsi/DFSIVoicePacket.o \
p25/dfsi/packet/DFSITrunk.o \
p25/dfsi/packet/DFSIVoice.o \
p25/edac/Trellis.o \
p25/lc/LC.o \
p25/lc/TDULC.o \
p25/lc/TSBK.o \
p25/packet/Data.o \
p25/packet/Trunk.o \
p25/packet/Voice.o \
p25/Audio.o \
p25/Control.o \
p25/DataPacket.o \
p25/NID.o \
p25/Sync.o \
p25/TrunkPacket.o \
p25/P25Utils.o \
p25/VoicePacket.o \
modem/port/IModemPort.o \
modem/port/ISerialPort.o \
modem/port/ModemNullPort.o \

@ -1,96 +0,0 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2020 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__DMR_CONTROL_PACKET_H__)
#define __DMR_CONTROL_PACKET_H__
#include "Defines.h"
#include "dmr/data/Data.h"
#include "dmr/data/EmbeddedData.h"
#include "dmr/lc/LC.h"
#include "dmr/Slot.h"
#include "modem/Modem.h"
#include "network/BaseNetwork.h"
#include "RingBuffer.h"
#include "lookups/RadioIdLookup.h"
#include "lookups/TalkgroupIdLookup.h"
#include "StopWatch.h"
#include "Timer.h"
#include <vector>
namespace dmr
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Slot;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements core logic for handling DMR control (CSBK) packets.
// ---------------------------------------------------------------------------
class HOST_SW_API ControlPacket {
public:
/// <summary>Process a data frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary>
void processNetwork(const data::Data& dmrData);
/// <summary>Helper to write a extended function packet on the RF interface.</summary>
void writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
/// <summary>Helper to write a call alert packet on the RF interface.</summary>
void writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId);
private:
friend class Slot;
Slot* m_slot;
bool m_dumpCSBKData;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the ControlPacket class.</summary>
ControlPacket(Slot* slot, network::BaseNetwork* network, bool dumpCSBKData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the DataPacket class.</summary>
~ControlPacket();
/// <summary>Helper to write a TSCC Aloha broadcast packet on the RF interface.</summary>
void writeRF_TSCC_Aloha();
/// <summary>Helper to write a TSCC Ann-Wd broadcast packet on the RF interface.</summary>
void writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd);
/// <summary>Helper to write a TSCC Sys_Parm broadcast packet on the RF interface.</summary>
void writeRF_TSCC_Bcast_Sys_Parm();
};
} // namespace dmr
#endif // __DMR_CONTROL_PACKET_H__

@ -37,6 +37,7 @@
#include "Utils.h"
using namespace dmr;
using namespace dmr::packet;
#include <cassert>
#include <ctime>
@ -153,9 +154,9 @@ Slot::Slot(uint32_t slotNo, uint32_t timeout, uint32_t tgHang, uint32_t queueSiz
{
m_interval.start();
m_voice = new VoicePacket(this, m_network, m_embeddedLCOnly, m_dumpTAData, debug, verbose);
m_data = new DataPacket(this, m_network, dumpDataPacket, repeatDataPacket, debug, verbose);
m_control = new ControlPacket(this, m_network, dumpCSBKData, debug, verbose);
m_voice = new Voice(this, m_network, m_embeddedLCOnly, m_dumpTAData, debug, verbose);
m_data = new Data(this, m_network, dumpDataPacket, repeatDataPacket, debug, verbose);
m_control = new ControlSignaling(this, m_network, dumpCSBKData, debug, verbose);
}
/// <summary>

@ -34,9 +34,9 @@
#include "Defines.h"
#include "dmr/Control.h"
#include "dmr/SiteData.h"
#include "dmr/ControlPacket.h"
#include "dmr/DataPacket.h"
#include "dmr/VoicePacket.h"
#include "dmr/packet/ControlSignaling.h"
#include "dmr/packet/Data.h"
#include "dmr/packet/Voice.h"
#include "modem/Modem.h"
#include "network/BaseNetwork.h"
#include "lookups/RSSIInterpolator.h"
@ -55,9 +55,9 @@ namespace dmr
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket;
class HOST_SW_API DataPacket;
class HOST_SW_API ControlPacket;
namespace packet { class HOST_SW_API Voice; }
namespace packet { class HOST_SW_API Data; }
namespace packet { class HOST_SW_API ControlSignaling; }
// ---------------------------------------------------------------------------
// Class Declaration
@ -86,8 +86,8 @@ namespace dmr
/// <summary>Updates the slot processor.</summary>
void clock();
/// <summary>Gets instance of the ControlPacket class.</summary>
ControlPacket* control() { return m_control; }
/// <summary>Gets instance of the ControlSignaling class.</summary>
packet::ControlSignaling* control() { return m_control; }
/// <summary>Helper to change the debug and verbose state.</summary>
void setDebugVerbose(bool debug, bool verbose);
@ -105,12 +105,12 @@ namespace dmr
static void setSiteData(uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo);
private:
friend class VoicePacket;
VoicePacket* m_voice;
friend class DataPacket;
DataPacket* m_data;
friend class ControlPacket;
ControlPacket* m_control;
friend class packet::Voice;
packet::Voice* m_voice;
friend class packet::Data;
packet::Data* m_data;
friend class packet::ControlSignaling;
packet::ControlSignaling* m_control;
uint32_t m_slotNo;

@ -1,118 +0,0 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2021 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__DMR_VOICE_PACKET_H__)
#define __DMR_VOICE_PACKET_H__
#include "Defines.h"
#include "dmr/data/Data.h"
#include "dmr/data/EmbeddedData.h"
#include "dmr/lc/LC.h"
#include "dmr/lc/PrivacyLC.h"
#include "dmr/Slot.h"
#include "edac/AMBEFEC.h"
#include "network/BaseNetwork.h"
#include "lookups/RadioIdLookup.h"
#include "lookups/TalkgroupIdLookup.h"
#include <vector>
namespace dmr
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API DataPacket;
class HOST_SW_API Slot;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements core logic for handling DMR voice packets.
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket {
public:
/// <summary>Process a voice frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
/// <summary>Process a voice frame from the network.</summary>
void processNetwork(const data::Data& dmrData);
private:
friend class DataPacket;
friend class Slot;
Slot* m_slot;
uint8_t* m_lastFrame;
bool m_lastFrameValid;
uint8_t m_rfN;
uint8_t m_lastRfN;
uint8_t m_netN;
data::EmbeddedData m_rfEmbeddedLC;
data::EmbeddedData* m_rfEmbeddedData;
uint32_t m_rfEmbeddedReadN;
uint32_t m_rfEmbeddedWriteN;
data::EmbeddedData m_netEmbeddedLC;
data::EmbeddedData* m_netEmbeddedData;
uint32_t m_netEmbeddedReadN;
uint32_t m_netEmbeddedWriteN;
uint8_t m_rfTalkerId;
uint8_t m_netTalkerId;
edac::AMBEFEC m_fec;
bool m_embeddedLCOnly;
bool m_dumpTAData;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the VoicePacket class.</summary>
VoicePacket(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the VoicePacket class.</summary>
~VoicePacket();
/// <summary></summary>
void logGPSPosition(const uint32_t srcId, const uint8_t* data);
/// <summary>Helper to insert AMBE null frames for missing audio.</summary>
void insertNullAudio(uint8_t* data);
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
bool insertSilence(const uint8_t* data, uint8_t seqNo);
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
void insertSilence(uint32_t count);
};
} // namespace dmr
#endif // __DMR_VOICE_PACKET_H__

@ -24,7 +24,7 @@
* GNU General Public License for more details.
*/
#include "Defines.h"
#include "dmr/ControlPacket.h"
#include "dmr/packet/ControlSignaling.h"
#include "dmr/acl/AccessControl.h"
#include "dmr/data/DataHeader.h"
#include "dmr/data/EMB.h"
@ -40,6 +40,7 @@
#include "Utils.h"
using namespace dmr;
using namespace dmr::packet;
#include <cassert>
#include <ctime>
@ -74,7 +75,7 @@ using namespace dmr;
/// <param name="data">Buffer containing data frame.</param>
/// <param name="len">Length of data frame.</param>
/// <returns></returns>
bool ControlPacket::process(uint8_t* data, uint32_t len)
bool ControlSignaling::process(uint8_t* data, uint32_t len)
{
assert(data != NULL);
@ -224,7 +225,7 @@ bool ControlPacket::process(uint8_t* data, uint32_t len)
/// Process a data frame from the network.
/// </summary>
/// <param name="dmrData"></param>
void ControlPacket::processNetwork(const data::Data & dmrData)
void ControlSignaling::processNetwork(const data::Data & dmrData)
{
uint8_t dataType = dmrData.getDataType();
@ -376,7 +377,7 @@ void ControlPacket::processNetwork(const data::Data & dmrData)
/// <param name="func">Extended function opcode.</param>
/// <param name="arg">Extended function argument.</param>
/// <param name="dstId">Destination radio ID.</param>
void ControlPacket::writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId)
void ControlSignaling::writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId)
{
if (m_verbose) {
LogMessage(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_EXT_FNCT (Extended Function), op = $%02X, arg = %u, tgt = %u",
@ -434,7 +435,7 @@ void ControlPacket::writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId
/// </summary>
/// <param name="srcId">Source radio ID.</param>
/// <param name="dstId">Destination radio ID.</param>
void ControlPacket::writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId)
void ControlSignaling::writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId)
{
if (m_verbose) {
LogMessage(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_CALL_ALRT (Call Alert), src = %u, dst = %u",
@ -482,14 +483,14 @@ void ControlPacket::writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId)
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the ControlPacket class.
/// Initializes a new instance of the ControlSignaling class.
/// </summary>
/// <param name="slot">DMR slot.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
/// <param name="dumpCSBKData"></param>
/// <param name="debug">Flag indicating whether DMR debug is enabled.</param>
/// <param name="verbose">Flag indicating whether DMR verbose logging is enabled.</param>
ControlPacket::ControlPacket(Slot * slot, network::BaseNetwork * network, bool dumpCSBKData, bool debug, bool verbose) :
ControlSignaling::ControlSignaling(Slot * slot, network::BaseNetwork * network, bool dumpCSBKData, bool debug, bool verbose) :
m_slot(slot),
m_dumpCSBKData(dumpCSBKData),
m_verbose(verbose),
@ -499,9 +500,9 @@ ControlPacket::ControlPacket(Slot * slot, network::BaseNetwork * network, bool d
}
/// <summary>
/// Finalizes a instance of the ControlPacket class.
/// Finalizes a instance of the ControlSignaling class.
/// </summary>
ControlPacket::~ControlPacket()
ControlSignaling::~ControlSignaling()
{
/* stub */
}
@ -509,7 +510,7 @@ ControlPacket::~ControlPacket()
/// <summary>
/// Helper to write a TSCC Aloha broadcast packet on the RF interface.
/// </summary>
void ControlPacket::writeRF_TSCC_Aloha()
void ControlSignaling::writeRF_TSCC_Aloha()
{
if (m_debug) {
LogMessage(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_ALOHA (Aloha)", m_slot->m_slotNo);
@ -550,7 +551,7 @@ void ControlPacket::writeRF_TSCC_Aloha()
/// </summary>
/// <param name="channelNo"></param>
/// <param name="annWd"></param>
void ControlPacket::writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd)
void ControlSignaling::writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd)
{
if (m_debug) {
LogMessage(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_BROADCAST (Broadcast), BCAST_ANNC_ANN_WD_TSCC (Announce-WD TSCC Channel), channelNo = %u, annWd = %u",
@ -595,7 +596,7 @@ void ControlPacket::writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd)
/// <summary>
/// Helper to write a TSCC Sys_Parm broadcast packet on the RF interface.
/// </summary>
void ControlPacket::writeRF_TSCC_Bcast_Sys_Parm()
void ControlSignaling::writeRF_TSCC_Bcast_Sys_Parm()
{
if (m_debug) {
LogMessage(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_BROADCAST (Broadcast), BCAST_ANNC_SITE_PARMS (Announce Site Parms)", m_slot->m_slotNo);

@ -0,0 +1,100 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2020 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__DMR_PACKET_CONTROL_SIGNALING_H__)
#define __DMR_PACKET_CONTROL_SIGNALING_H__
#include "Defines.h"
#include "dmr/data/Data.h"
#include "dmr/data/EmbeddedData.h"
#include "dmr/lc/LC.h"
#include "dmr/Slot.h"
#include "modem/Modem.h"
#include "network/BaseNetwork.h"
#include "RingBuffer.h"
#include "lookups/RadioIdLookup.h"
#include "lookups/TalkgroupIdLookup.h"
#include "StopWatch.h"
#include "Timer.h"
#include <vector>
namespace dmr
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Slot;
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements core logic for handling DMR control signaling (CSBK)
// packets.
// ---------------------------------------------------------------------------
class HOST_SW_API ControlSignaling {
public:
/// <summary>Process a data frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary>
void processNetwork(const data::Data& dmrData);
/// <summary>Helper to write a extended function packet on the RF interface.</summary>
void writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
/// <summary>Helper to write a call alert packet on the RF interface.</summary>
void writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId);
private:
friend class dmr::Slot;
Slot* m_slot;
bool m_dumpCSBKData;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the ControlSignaling class.</summary>
ControlSignaling(Slot* slot, network::BaseNetwork* network, bool dumpCSBKData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the ControlSignaling class.</summary>
~ControlSignaling();
/// <summary>Helper to write a TSCC Aloha broadcast packet on the RF interface.</summary>
void writeRF_TSCC_Aloha();
/// <summary>Helper to write a TSCC Ann-Wd broadcast packet on the RF interface.</summary>
void writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd);
/// <summary>Helper to write a TSCC Sys_Parm broadcast packet on the RF interface.</summary>
void writeRF_TSCC_Bcast_Sys_Parm();
};
} // namespace packet
} // namespace dmr
#endif // __DMR_PACKET_CONTROL_SIGNALING_H__

@ -24,7 +24,7 @@
* GNU General Public License for more details.
*/
#include "Defines.h"
#include "dmr/DataPacket.h"
#include "dmr/packet/Data.h"
#include "dmr/acl/AccessControl.h"
#include "dmr/data/EMB.h"
#include "dmr/edac/Trellis.h"
@ -39,6 +39,7 @@
#include "Utils.h"
using namespace dmr;
using namespace dmr::packet;
#include <cassert>
#include <ctime>
@ -73,7 +74,7 @@ using namespace dmr;
/// <param name="data">Buffer containing data frame.</param>
/// <param name="len">Length of data frame.</param>
/// <returns></returns>
bool DataPacket::process(uint8_t* data, uint32_t len)
bool Data::process(uint8_t* data, uint32_t len)
{
assert(data != NULL);
@ -302,7 +303,7 @@ bool DataPacket::process(uint8_t* data, uint32_t len)
/// Process a data frame from the network.
/// </summary>
/// <param name="dmrData"></param>
void DataPacket::processNetwork(const data::Data& dmrData)
void Data::processNetwork(const data::Data& dmrData)
{
uint8_t dataType = dmrData.getDataType();
@ -506,7 +507,7 @@ void DataPacket::processNetwork(const data::Data& dmrData)
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the DataPacket class.
/// Initializes a new instance of the Data class.
/// </summary>
/// <param name="slot">DMR slot.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
@ -514,7 +515,7 @@ void DataPacket::processNetwork(const data::Data& dmrData)
/// <param name="repeatDataPacket"></param>
/// <param name="debug">Flag indicating whether DMR debug is enabled.</param>
/// <param name="verbose">Flag indicating whether DMR verbose logging is enabled.</param>
DataPacket::DataPacket(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose) :
Data::Data(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose) :
m_slot(slot),
m_pduUserData(NULL),
m_pduDataOffset(0U),
@ -529,9 +530,9 @@ DataPacket::DataPacket(Slot* slot, network::BaseNetwork* network, bool dumpDataP
}
/// <summary>
/// Finalizes a instance of the DataPacket class.
/// Finalizes a instance of the Data class.
/// </summary>
DataPacket::~DataPacket()
Data::~Data()
{
delete[] m_pduUserData;
}

@ -28,8 +28,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__DMR_DATA_PACKET_H__)
#define __DMR_DATA_PACKET_H__
#if !defined(__DMR_PACKET_DATA_H__)
#define __DMR_PACKET_DATA_H__
#include "Defines.h"
#include "dmr/data/Data.h"
@ -54,16 +54,18 @@ namespace dmr
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket;
class HOST_SW_API ControlPacket;
namespace packet { class HOST_SW_API Voice; }
namespace packet { class HOST_SW_API ControlSignaling; }
class HOST_SW_API Slot;
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements core logic for handling DMR data packets.
// ---------------------------------------------------------------------------
class HOST_SW_API DataPacket {
class HOST_SW_API Data {
public:
/// <summary>Process a data frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
@ -71,9 +73,9 @@ namespace dmr
void processNetwork(const data::Data& dmrData);
private:
friend class VoicePacket;
friend class ControlPacket;
friend class Slot;
friend class packet::Voice;
friend class packet::ControlSignaling;
friend class dmr::Slot;
Slot* m_slot;
uint8_t* m_pduUserData;
@ -86,11 +88,12 @@ namespace dmr
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the DataPacket class.</summary>
DataPacket(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose);
/// <summary>Finalizes a instance of the DataPacket class.</summary>
~DataPacket();
/// <summary>Initializes a new instance of the Data class.</summary>
Data(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose);
/// <summary>Finalizes a instance of the Data class.</summary>
~Data();
};
} // namespace packet
} // namespace dmr
#endif // __DMR_DATA_PACKET_H__
#endif // __DMR_PACKET_DATA_H__

@ -24,7 +24,7 @@
* GNU General Public License for more details.
*/
#include "Defines.h"
#include "dmr/VoicePacket.h"
#include "dmr/packet/Voice.h"
#include "dmr/acl/AccessControl.h"
#include "dmr/data/DataHeader.h"
#include "dmr/data/EMB.h"
@ -40,6 +40,7 @@
#include "Utils.h"
using namespace dmr;
using namespace dmr::packet;
#include <cassert>
#include <ctime>
@ -75,7 +76,7 @@ using namespace dmr;
/// <param name="data">Buffer containing data frame.</param>
/// <param name="len">Length of data frame.</param>
/// <returns></returns>
bool VoicePacket::process(uint8_t* data, uint32_t len)
bool Voice::process(uint8_t* data, uint32_t len)
{
assert(data != NULL);
@ -617,7 +618,7 @@ bool VoicePacket::process(uint8_t* data, uint32_t len)
/// Process a voice frame from the network.
/// </summary>
/// <param name="dmrData"></param>
void VoicePacket::processNetwork(const data::Data& dmrData)
void Voice::processNetwork(const data::Data& dmrData)
{
uint8_t dataType = dmrData.getDataType();
@ -1059,7 +1060,7 @@ void VoicePacket::processNetwork(const data::Data& dmrData)
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the VoicePacket class.
/// Initializes a new instance of the Voice class.
/// </summary>
/// <param name="slot">DMR slot.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
@ -1067,7 +1068,7 @@ void VoicePacket::processNetwork(const data::Data& dmrData)
/// <param name="dumpTAData"></param>
/// <param name="debug">Flag indicating whether DMR debug is enabled.</param>
/// <param name="verbose">Flag indicating whether DMR verbose logging is enabled.</param>
VoicePacket::VoicePacket(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose) :
Voice::Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose) :
m_slot(slot),
m_lastFrame(NULL),
m_lastFrameValid(false),
@ -1097,9 +1098,9 @@ VoicePacket::VoicePacket(Slot* slot, network::BaseNetwork* network, bool embedde
}
/// <summary>
/// Finalizes a instance of the VoicePacket class.
/// Finalizes a instance of the Voice class.
/// </summary>
VoicePacket::~VoicePacket()
Voice::~Voice()
{
delete[] m_lastFrame;
@ -1112,7 +1113,7 @@ VoicePacket::~VoicePacket()
/// </summary>
/// <param name="srcId">Source radio ID.</param>
/// <param name="data"></param>
void VoicePacket::logGPSPosition(const uint32_t srcId, const uint8_t* data)
void Voice::logGPSPosition(const uint32_t srcId, const uint8_t* data)
{
uint32_t errorVal = (data[2U] & 0x0E) >> 1U;
@ -1163,7 +1164,7 @@ void VoicePacket::logGPSPosition(const uint32_t srcId, const uint8_t* data)
/// Helper to insert AMBE null frames for missing audio.
/// </summary>
/// <param name="data"></param>
void VoicePacket::insertNullAudio(uint8_t* data)
void Voice::insertNullAudio(uint8_t* data)
{
uint8_t* ambeBuffer = new uint8_t[dmr::DMR_AMBE_LENGTH_BYTES];
::memset(ambeBuffer, 0x00U, dmr::DMR_AMBE_LENGTH_BYTES);
@ -1186,7 +1187,7 @@ void VoicePacket::insertNullAudio(uint8_t* data)
/// <param name="data"></param>
/// <param name="seqNo"></param>
/// <returns></returns>
bool VoicePacket::insertSilence(const uint8_t* data, uint8_t seqNo)
bool Voice::insertSilence(const uint8_t* data, uint8_t seqNo)
{
assert(data != NULL);
@ -1217,7 +1218,7 @@ bool VoicePacket::insertSilence(const uint8_t* data, uint8_t seqNo)
/// Helper to insert DMR AMBE silence frames.
/// </summary>
/// <param name="count"></param>
void VoicePacket::insertSilence(uint32_t count)
void Voice::insertSilence(uint32_t count)
{
uint8_t data[DMR_FRAME_LENGTH_BYTES + 2U];

@ -0,0 +1,121 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2021 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__DMR_PACKET_VOICE_H__)
#define __DMR_PACKET_VOICE_H__
#include "Defines.h"
#include "dmr/data/Data.h"
#include "dmr/data/EmbeddedData.h"
#include "dmr/lc/LC.h"
#include "dmr/lc/PrivacyLC.h"
#include "dmr/Slot.h"
#include "edac/AMBEFEC.h"
#include "network/BaseNetwork.h"
#include "lookups/RadioIdLookup.h"
#include "lookups/TalkgroupIdLookup.h"
#include <vector>
namespace dmr
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Data; }
class HOST_SW_API Slot;
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements core logic for handling DMR voice packets.
// ---------------------------------------------------------------------------
class HOST_SW_API Voice {
public:
/// <summary>Process a voice frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
/// <summary>Process a voice frame from the network.</summary>
void processNetwork(const data::Data& dmrData);
private:
friend class packet::Data;
friend class dmr::Slot;
Slot* m_slot;
uint8_t* m_lastFrame;
bool m_lastFrameValid;
uint8_t m_rfN;
uint8_t m_lastRfN;
uint8_t m_netN;
data::EmbeddedData m_rfEmbeddedLC;
data::EmbeddedData* m_rfEmbeddedData;
uint32_t m_rfEmbeddedReadN;
uint32_t m_rfEmbeddedWriteN;
data::EmbeddedData m_netEmbeddedLC;
data::EmbeddedData* m_netEmbeddedData;
uint32_t m_netEmbeddedReadN;
uint32_t m_netEmbeddedWriteN;
uint8_t m_rfTalkerId;
uint8_t m_netTalkerId;
edac::AMBEFEC m_fec;
bool m_embeddedLCOnly;
bool m_dumpTAData;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the Voice class.</summary>
Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the Voice class.</summary>
~Voice();
/// <summary></summary>
void logGPSPosition(const uint32_t srcId, const uint8_t* data);
/// <summary>Helper to insert AMBE null frames for missing audio.</summary>
void insertNullAudio(uint8_t* data);
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
bool insertSilence(const uint8_t* data, uint8_t seqNo);
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
void insertSilence(uint32_t count);
};
} // namespace packet
} // namespace dmr
#endif // __DMR_PACKET_VOICE_H__

@ -32,8 +32,8 @@
#include "p25/P25Defines.h"
#include "p25/Control.h"
#include "p25/acl/AccessControl.h"
#include "p25/dfsi/DFSITrunkPacket.h"
#include "p25/dfsi/DFSIVoicePacket.h"
#include "p25/dfsi/packet/DFSITrunk.h"
#include "p25/dfsi/packet/DFSIVoice.h"
#include "p25/P25Utils.h"
#include "p25/Sync.h"
#include "edac/CRC.h"
@ -42,6 +42,7 @@
#include "Utils.h"
using namespace p25;
using namespace p25::packet;
#include <cassert>
#include <cstdio>
@ -147,18 +148,18 @@ Control::Control(uint32_t nac, uint32_t callHang, uint32_t queueSize, modem::Mod
#if ENABLE_DFSI_SUPPORT
if (m_modem->isP25DFSI()) {
LogMessage(LOG_P25, "DFSI protocol mode is enabled.");
m_voice = new dfsi::DFSIVoicePacket(this, network, debug, verbose);
m_trunk = new dfsi::DFSITrunkPacket(this, network, dumpTSBKData, debug, verbose);
m_voice = new dfsi::packet::DFSIVoice(this, network, debug, verbose);
m_trunk = new dfsi::packet::DFSITrunk(this, network, dumpTSBKData, debug, verbose);
}
else {
m_voice = new VoicePacket(this, network, debug, verbose);
m_trunk = new TrunkPacket(this, network, dumpTSBKData, debug, verbose);
m_data = new DataPacket(this, network, dumpPDUData, repeatPDU, debug, verbose);
m_voice = new Voice(this, network, debug, verbose);
m_trunk = new Trunk(this, network, dumpTSBKData, debug, verbose);
m_data = new Data(this, network, dumpPDUData, repeatPDU, debug, verbose);
}
#else
m_voice = new VoicePacket(this, network, debug, verbose);
m_trunk = new TrunkPacket(this, network, dumpTSBKData, debug, verbose);
m_data = new DataPacket(this, network, dumpPDUData, repeatPDU, debug, verbose);
m_voice = new Voice(this, network, debug, verbose);
m_trunk = new Trunk(this, network, dumpTSBKData, debug, verbose);
m_data = new Data(this, network, dumpPDUData, repeatPDU, debug, verbose);
#endif
}

@ -32,9 +32,9 @@
#define __P25_CONTROL_H__
#include "Defines.h"
#include "p25/TrunkPacket.h"
#include "p25/DataPacket.h"
#include "p25/VoicePacket.h"
#include "p25/packet/Trunk.h"
#include "p25/packet/Data.h"
#include "p25/packet/Voice.h"
#include "p25/NID.h"
#include "p25/SiteData.h"
#include "network/BaseNetwork.h"
@ -56,11 +56,11 @@ namespace p25
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket;
namespace dfsi { class HOST_SW_API DFSIVoicePacket; }
class HOST_SW_API DataPacket;
class HOST_SW_API TrunkPacket;
namespace dfsi { class HOST_SW_API DFSITrunkPacket; }
namespace packet { class HOST_SW_API Voice; }
namespace dfsi::packet { class HOST_SW_API DFSIVoice; }
namespace packet { class HOST_SW_API Data; }
namespace packet { class HOST_SW_API Trunk; }
namespace dfsi::packet { class HOST_SW_API DFSITrunk; }
// ---------------------------------------------------------------------------
// Class Declaration
@ -110,21 +110,21 @@ namespace p25
/// <summary>Gets instance of the NID class.</summary>
NID nid() { return m_nid; }
/// <summary>Gets instance of the TrunkPacket class.</summary>
TrunkPacket* trunk() { return m_trunk; }
/// <summary>Gets instance of the Trunk class.</summary>
packet::Trunk* trunk() { return m_trunk; }
/// <summary>Helper to change the debug and verbose state.</summary>
void setDebugVerbose(bool debug, bool verbose);
private:
friend class VoicePacket;
friend class dfsi::DFSIVoicePacket;
VoicePacket* m_voice;
friend class DataPacket;
DataPacket* m_data;
friend class TrunkPacket;
friend class dfsi::DFSITrunkPacket;
TrunkPacket* m_trunk;
friend class packet::Voice;
friend class dfsi::packet::DFSIVoice;
packet::Voice* m_voice;
friend class packet::Data;
packet::Data* m_data;
friend class packet::Trunk;
friend class dfsi::packet::DFSITrunk;
packet::Trunk* m_trunk;
uint32_t m_nac;
uint32_t m_txNAC;

@ -1,137 +0,0 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_DATA_PACKET_H__)
#define __P25_DATA_PACKET_H__
#include "Defines.h"
#include "p25/data/DataBlock.h"
#include "p25/data/DataHeader.h"
#include "p25/data/LowSpeedData.h"
#include "p25/lc/LC.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
#include "Timer.h"
#include <cstdio>
#include <string>
#include <unordered_map>
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Control;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 data packets.
// ---------------------------------------------------------------------------
class HOST_SW_API DataPacket {
public:
/// <summary>Resets the data states for the RF interface.</summary>
void resetRF();
/// <summary>Process a data frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary>
bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
/// <summary>Helper to check if a logical link ID has registered with data services.</summary>
bool hasLLIdFNEReg(uint32_t llId) const;
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
void clock(uint32_t ms);
private:
friend class Control;
Control* m_p25;
network::BaseNetwork* m_network;
RPT_RF_STATE m_prevRfState;
data::DataBlock* m_rfData;
data::DataHeader m_rfDataHeader;
data::DataHeader m_rfSecondHeader;
bool m_rfUseSecondHeader;
uint8_t m_rfDataBlockCnt;
uint8_t* m_rfPDU;
uint32_t m_rfPDUCount;
uint32_t m_rfPDUBits;
data::DataBlock* m_netData;
data::DataHeader m_netDataHeader;
data::DataHeader m_netSecondHeader;
bool m_netUseSecondHeader;
uint32_t m_netDataOffset;
uint8_t m_netDataBlockCnt;
uint8_t* m_netPDU;
uint32_t m_netPDUCount;
uint8_t* m_pduUserData;
uint32_t m_pduUserDataLength;
std::unordered_map<uint32_t, ulong64_t> m_fneRegTable;
std::unordered_map<uint32_t, ulong64_t> m_connQueueTable;
std::unordered_map<uint32_t, Timer> m_connTimerTable;
bool m_dumpPDUData;
bool m_repeatPDU;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the DataPacket class.</summary>
DataPacket(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose);
/// <summary>Finalizes a instance of the DataPacket class.</summary>
~DataPacket();
/// <summary>Write data processed from RF to the network.</summary>
void writeNetwork(const uint8_t currentBlock, const uint8_t* data, uint32_t len);
/// <summary>Helper to write a P25 PDU packet.</summary>
void writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls = false);
/// <summary>Helper to write a network P25 PDU packet.</summary>
void writeNet_PDU_Buffered();
/// <summary>Helper to re-write a received P25 PDU packet.</summary>
void writeRF_PDU_Buffered();
/// <summary>Helper to write a PDU registration response.</summary>
void writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr);
/// <summary>Helper to write a PDU acknowledge response.</summary>
void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls = false);
};
} // namespace p25
#endif // __P25_DATA_PACKET_H__

@ -1,241 +0,0 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
/*
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_TRUNK_PACKET_H__)
#define __P25_TRUNK_PACKET_H__
#include "Defines.h"
#include "p25/data/DataHeader.h"
#include "p25/data/DataBlock.h"
#include "p25/lc/TSBK.h"
#include "p25/lc/TDULC.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
#include "network/RemoteControl.h"
#include "Timer.h"
#include <cstdio>
#include <string>
#include <unordered_map>
#include <algorithm>
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket;
namespace dfsi { class HOST_SW_API DFSIVoicePacket; }
class HOST_SW_API DataPacket;
class HOST_SW_API Control;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 trunking packets.
// ---------------------------------------------------------------------------
class HOST_SW_API TrunkPacket {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
/// <summary>Resets the data states for the network.</summary>
virtual void resetNet();
/// <summary>Process a data frame from the RF interface.</summary>
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
/// <summary>Process a data frame from the network.</summary>
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
/// <summary>Helper used to process AMBTs from PDU data.</summary>
bool processMBT(data::DataHeader dataHeader, data::DataBlock* blocks);
/// <summary>Helper to write P25 adjacent site information to the network.</summary>
void writeAdjSSNetwork();
/// <summary>Helper to determine if the source ID has affiliated to the group destination ID.</summary>
bool hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const;
/// <summary>Helper to determine if the source ID has unit registered.</summary>
bool hasSrcIdUnitReg(uint32_t srcId) const;
/// <summary>Helper to determine if the channel number is busy.</summary>
bool isChBusy(uint32_t chNo) const;
/// <summary>Helper to determine if the destination ID is already granted.</summary>
bool hasDstIdGranted(uint32_t dstId) const;
/// <summary>Helper to start the destination ID grant timer.</summary>
void touchDstIdGrant(uint32_t dstId);
/// <summary>Helper to release the channel grant for the destination ID.</summary>
void releaseDstIdGrant(uint32_t dstId, bool releaseAll);
/// <summary>Helper to release group affiliations.</summary>
void clearGrpAff(uint32_t dstId, bool releaseAll);
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
void clock(uint32_t ms);
/// <summary>Helper to set the TSBK manufacturer ID.</summary>
void setMFId(uint8_t val) { m_rfTSBK.setMFId(val); }
/// <summary>Helper to write a call alert packet.</summary>
void writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a extended function packet.</summary>
void writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
/// <summary>Helper to write a group affiliation query packet.</summary>
void writeRF_TSDU_Grp_Aff_Q(uint32_t dstId);
/// <summary>Helper to write a unit registration command packet.</summary>
void writeRF_TSDU_U_Reg_Cmd(uint32_t dstId);
/// <summary>Helper to write a Motorola patch packet.</summary>
void writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint32_t group3);
/// <summary>Helper to change the conventional fallback state.</summary>
void setConvFallback(bool fallback);
/// <summary>Helper to change the TSBK verbose state.</summary>
void setTSBKVerbose(bool verbose);
protected:
friend class VoicePacket;
friend class dfsi::DFSIVoicePacket;
friend class DataPacket;
friend class Control;
Control* m_p25;
network::BaseNetwork* m_network;
uint32_t m_patchSuperGroup;
bool m_verifyAff;
bool m_verifyReg;
lc::TSBK m_rfTSBK;
lc::TSBK m_netTSBK;
uint8_t* m_rfMBF;
uint8_t m_mbfCnt;
uint8_t m_mbfIdenCnt;
uint8_t m_mbfAdjSSCnt;
uint8_t m_mbfSCCBCnt;
uint8_t m_mbfGrpGrntCnt;
std::vector<uint32_t> m_voiceChTable;
std::unordered_map<uint8_t, SiteData> m_adjSiteTable;
std::unordered_map<uint8_t, uint8_t> m_adjSiteUpdateCnt;
std::unordered_map<uint8_t, SiteData> m_sccbTable;
std::unordered_map<uint8_t, uint8_t> m_sccbUpdateCnt;
std::vector<uint32_t> m_unitRegTable;
std::unordered_map<uint32_t, uint32_t> m_grpAffTable;
std::unordered_map<uint32_t, uint32_t> m_grantChTable;
std::unordered_map<uint32_t, Timer> m_grantTimers;
uint8_t m_voiceChCnt;
uint8_t m_voiceGrantChCnt;
bool m_noStatusAck;
bool m_noMessageAck;
bool m_unitToUnitAvailCheck;
uint8_t m_convFallbackPacketDelay;
bool m_convFallback;
Timer m_adjSiteUpdateTimer;
uint32_t m_adjSiteUpdateInterval;
bool m_ctrlTSDUMBF;
bool m_sndcpChGrant;
bool m_dumpTSBK;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the TrunkPacket class.</summary>
TrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the TrunkPacket class.</summary>
virtual ~TrunkPacket();
/// <summary>Write data processed from RF to the network.</summary>
void writeNetworkRF(const uint8_t* data, bool autoReset);
/// <summary>Helper to write control channel packet data.</summary>
void writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS);
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
/// <summary>Helper to write a P25 TDU w/ link control channel release packet.</summary>
void writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
/// <summary>Helper to write a multi-block (3-block) P25 TSDU packet.</summary>
void writeRF_TSDU_MBF(bool clearBeforeWrite = false);
/// <summary>Helper to generate the given control TSBK into the TSDU frame queue.</summary>
void queueRF_TSBK_Ctrl(uint8_t lco);
/// <summary>Helper to write a grant packet.</summary>
bool writeRF_TSDU_Grant(bool grp, bool skip = false, bool net = false, bool skipNetCheck = false);
/// <summary>Helper to write a SNDCP grant packet.</summary>
bool writeRF_TSDU_SNDCP_Grant(bool skip = false, bool net = false);
/// <summary>Helper to write a unit to unit answer request packet.</summary>
void writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a acknowledge packet.</summary>
void writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noActivityLog);
/// <summary>Helper to write a deny packet.</summary>
void writeRF_TSDU_Deny(uint8_t reason, uint8_t service);
/// <summary>Helper to write a group affiliation response packet.</summary>
bool writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a unit registration response packet.</summary>
void writeRF_TSDU_U_Reg_Rsp(uint32_t srcId);
/// <summary>Helper to write a unit de-registration acknowledge packet.</summary>
void writeRF_TSDU_U_Dereg_Ack(uint32_t srcId);
/// <summary>Helper to write a queue packet.</summary>
void writeRF_TSDU_Queue(uint8_t reason, uint8_t service);
/// <summary>Helper to write a location registration response packet.</summary>
bool writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a call termination packet.</summary>
bool writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a network TSDU from the RF data queue.</summary>
void writeNet_TSDU_From_RF(uint8_t* data);
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
virtual void writeNet_TDULC(lc::TDULC lc);
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
virtual void writeNet_TSDU();
/// <summary>Helper to automatically inhibit a source ID on a denial.</summary>
void denialInhibit(uint32_t srcId);
/// <summary>Helper to add the idle status bits on P25 frame data.</summary>
void addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2);
};
} // namespace p25
#endif // __P25_TRUNK_PACKET_H__

@ -1,144 +0,0 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_VOICE_PACKET_H__)
#define __P25_VOICE_PACKET_H__
#include "Defines.h"
#include "p25/data/LowSpeedData.h"
#include "p25/dfsi/LC.h"
#include "p25/lc/LC.h"
#include "p25/Control.h"
#include "p25/Audio.h"
#include "network/BaseNetwork.h"
#include <cstdio>
#include <string>
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API TrunkPacket;
class HOST_SW_API Control;
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 voice packets.
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
/// <summary>Resets the data states for the network.</summary>
virtual void resetNet();
/// <summary>Process a data frame from the RF interface.</summary>
virtual bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary>
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
protected:
friend class TrunkPacket;
friend class Control;
Control* m_p25;
network::BaseNetwork* m_network;
uint32_t m_rfFrames;
uint32_t m_rfBits;
uint32_t m_rfErrs;
uint32_t m_rfUndecodableLC;
uint32_t m_netFrames;
uint32_t m_netLost;
Audio m_audio;
lc::LC m_rfLC;
lc::LC m_rfLastHDU;
lc::LC m_rfLastLDU1;
lc::LC m_rfLastLDU2;
lc::LC m_netLC;
lc::LC m_netLastLDU1;
data::LowSpeedData m_rfLSD;
data::LowSpeedData m_netLSD;
dfsi::LC m_dfsiLC;
uint8_t* m_netLDU1;
uint8_t* m_netLDU2;
uint8_t m_lastDUID;
uint8_t* m_lastIMBE;
bool m_hadVoice;
uint32_t m_lastRejectId;
uint32_t m_silenceThreshold;
uint8_t m_vocLDU1Count;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the VoicePacket class.</summary>
VoicePacket(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
/// <summary>Finalizes a instance of the VoicePacket class.</summary>
virtual ~VoicePacket();
/// <summary>Write data processed from RF to the network.</summary>
void writeNetwork(const uint8_t* data, uint8_t duid);
/// <summary>Helper to write end of voice frame data.</summary>
void writeRF_EndOfVoice();
/// <summary>Helper to write a network P25 TDU packet.</summary>
virtual void writeNet_TDU();
/// <summary>Helper to check for an unflushed LDU1 packet.</summary>
void checkNet_LDU1();
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
virtual void writeNet_LDU1();
/// <summary>Helper to check for an unflushed LDU2 packet.</summary>
void checkNet_LDU2();
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
virtual void writeNet_LDU2();
/// <summary>Helper to insert IMBE silence frames for missing audio.</summary>
void insertMissingAudio(uint8_t* data);
/// <summary>Helper to insert IMBE null frames for missing audio.</summary>
void insertNullAudio(uint8_t* data);
};
} // namespace p25
#endif // __P25_VOICE_PACKET_H__

@ -1,94 +0,0 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
/*
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_DFSI_TRUNK_PACKET_H__)
#define __P25_DFSI_TRUNK_PACKET_H__
#include "Defines.h"
#include "p25/dfsi/LC.h"
#include "p25/TrunkPacket.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API TrunkPacket;
class HOST_SW_API Control;
namespace dfsi
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 trunking packets using
// the DFSI protocol instead of the P25 OTA protocol.
// ---------------------------------------------------------------------------
class HOST_SW_API DFSITrunkPacket : public TrunkPacket {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
/// <summary>Resets the data states for the network.</summary>
virtual void resetNet();
/// <summary>Process a data frame from the RF interface.</summary>
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
protected:
LC m_rfDFSILC;
LC m_netDFSILC;
/// <summary>Initializes a new instance of the DFSITrunkPacket class.</summary>
DFSITrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the DFSITrunkPacket class.</summary>
virtual ~DFSITrunkPacket();
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
virtual void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
//virtual void writeNet_TDULC(lc::TDULC lc);
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
virtual void writeNet_TSDU();
/// <suimmary>Helper to write start DFSI data.</summary>
void writeRF_DFSI_Start(uint8_t type);
/// <suimmary>Helper to write stop DFSI data.</summary>
void writeRF_DSFI_Stop(uint8_t type);
private:
friend class DFSIVoicePacket;
friend class p25::Control;
};
} // namespace dfsi
} // namespace p25
#endif // __P25_DFSI_TRUNK_PACKET_H__

@ -26,7 +26,7 @@
#include "Defines.h"
#include "p25/P25Defines.h"
#include "p25/dfsi/DFSIDefines.h"
#include "p25/dfsi/DFSITrunkPacket.h"
#include "p25/dfsi/packet/DFSITrunk.h"
#include "p25/P25Utils.h"
#include "p25/Sync.h"
#include "Log.h"
@ -34,6 +34,7 @@
using namespace p25;
using namespace p25::dfsi;
using namespace p25::dfsi::packet;
// ---------------------------------------------------------------------------
// Public Class Members
@ -42,9 +43,9 @@ using namespace p25::dfsi;
/// <summary>
/// Resets the data states for the RF interface.
/// </summary>
void DFSITrunkPacket::resetRF()
void DFSITrunk::resetRF()
{
TrunkPacket::resetRF();
Trunk::resetRF();
LC lc = LC();
m_rfDFSILC = lc;
}
@ -52,9 +53,9 @@ void DFSITrunkPacket::resetRF()
/// <summary>
/// Resets the data states for the network.
/// </summary>
void DFSITrunkPacket::resetNet()
void DFSITrunk::resetNet()
{
TrunkPacket::resetNet();
Trunk::resetNet();
LC lc = LC();
m_netDFSILC = lc;
}
@ -66,7 +67,7 @@ void DFSITrunkPacket::resetNet()
/// <param name="len">Length of data frame.</param>
/// <param name="preDecoded">Flag indicating the TSBK data is pre-decoded TSBK data.</param>
/// <returns></returns>
bool DFSITrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
bool DFSITrunk::process(uint8_t* data, uint32_t len, bool preDecoded)
{
assert(data != NULL);
@ -77,7 +78,7 @@ bool DFSITrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
return false;
if (preDecoded) {
return TrunkPacket::process(data + 2U, len, preDecoded);
return Trunk::process(data + 2U, len, preDecoded);
}
else {
resetRF();
@ -85,7 +86,7 @@ bool DFSITrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
if (m_rfDFSILC.decodeTSBK(data + 2U)) {
m_rfTSBK = m_rfDFSILC.tsbk();
return TrunkPacket::process(tsbk, P25_TSBK_LENGTH_BYTES, true);
return Trunk::process(tsbk, P25_TSBK_LENGTH_BYTES, true);
}
}
@ -97,23 +98,23 @@ bool DFSITrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the DFSITrunkPacket class.
/// Initializes a new instance of the DFSITrunk class.
/// </summary>
/// <param name="p25">Instance of the Control class.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
/// <param name="dumpTSBKData">Flag indicating whether TSBK data is dumped to the log.</param>
/// <param name="debug">Flag indicating whether P25 debug is enabled.</param>
/// <param name="verbose">Flag indicating whether P25 verbose logging is enabled.</param>
DFSITrunkPacket::DFSITrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose) :
TrunkPacket(p25, network, dumpTSBKData, debug, verbose)
DFSITrunk::DFSITrunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose) :
Trunk(p25, network, dumpTSBKData, debug, verbose)
{
/* stub */
}
/// <summary>
/// Finalizes a instance of the DFSITrunkPacket class.
/// Finalizes a instance of the DFSITrunk class.
/// </summary>
DFSITrunkPacket::~DFSITrunkPacket()
DFSITrunk::~DFSITrunk()
{
/* stub */
}
@ -123,7 +124,7 @@ DFSITrunkPacket::~DFSITrunkPacket()
/// </summary>
/// <param name="lc"></param>
/// <param name="noNetwork"></param>
void DFSITrunkPacket::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
void DFSITrunk::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
{
// for now this is ignored...
}
@ -134,7 +135,7 @@ void DFSITrunkPacket::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
/// <param name="noNetwork"></param>
/// <param name="clearBeforeWrite"></param>
/// <param name="force"></param>
void DFSITrunkPacket::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool force)
void DFSITrunk::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool force)
{
if (!m_p25->m_control)
return;
@ -199,7 +200,7 @@ void DFSITrunkPacket::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bo
/// <summary>
/// Helper to write a network single-block P25 TSDU packet.
/// </summary>
void DFSITrunkPacket::writeNet_TSDU()
void DFSITrunk::writeNet_TSDU()
{
uint8_t buffer[P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U);
@ -221,7 +222,7 @@ void DFSITrunkPacket::writeNet_TSDU()
/// Helper to write start DFSI data.
/// </summary>
/// <param name="type"></param>
void DFSITrunkPacket::writeRF_DFSI_Start(uint8_t type)
void DFSITrunk::writeRF_DFSI_Start(uint8_t type)
{
uint8_t buffer[P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U);
@ -244,7 +245,7 @@ void DFSITrunkPacket::writeRF_DFSI_Start(uint8_t type)
/// Helper to write stop DFSI data.
/// </summary>
/// <param name="type"></param>
void DFSITrunkPacket::writeRF_DSFI_Stop(uint8_t type)
void DFSITrunk::writeRF_DSFI_Stop(uint8_t type)
{
uint8_t buffer[P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_DFSI_SS_FRAME_LENGTH_BYTES + 2U);

@ -0,0 +1,97 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
/*
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_DFSI_PACKET_TRUNK_H__)
#define __P25_DFSI_PACKET_TRUNK_H__
#include "Defines.h"
#include "p25/dfsi/LC.h"
#include "p25/packet/Trunk.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Trunk; }
class HOST_SW_API Control;
namespace dfsi
{
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 trunking packets using
// the DFSI protocol instead of the P25 OTA protocol.
// ---------------------------------------------------------------------------
class HOST_SW_API DFSITrunk : public p25::packet::Trunk {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
/// <summary>Resets the data states for the network.</summary>
virtual void resetNet();
/// <summary>Process a data frame from the RF interface.</summary>
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
protected:
LC m_rfDFSILC;
LC m_netDFSILC;
/// <summary>Initializes a new instance of the DFSITrunk class.</summary>
DFSITrunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the DFSITrunk class.</summary>
virtual ~DFSITrunk();
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
virtual void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
//virtual void writeNet_TDULC(lc::TDULC lc);
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
virtual void writeNet_TSDU();
/// <suimmary>Helper to write start DFSI data.</summary>
void writeRF_DFSI_Start(uint8_t type);
/// <suimmary>Helper to write stop DFSI data.</summary>
void writeRF_DSFI_Stop(uint8_t type);
private:
friend class packet::DFSIVoice;
friend class p25::Control;
};
} // namespace packet
} // namespace dfsi
} // namespace p25
#endif // __P25_DFSI_PACKET_TRUNK_H__

@ -31,7 +31,7 @@
#include "p25/P25Defines.h"
#include "p25/acl/AccessControl.h"
#include "p25/dfsi/DFSIDefines.h"
#include "p25/dfsi/DFSIVoicePacket.h"
#include "p25/dfsi/packet/DFSIVoice.h"
#include "p25/P25Utils.h"
#include "p25/Sync.h"
#include "HostMain.h"
@ -40,6 +40,7 @@
using namespace p25;
using namespace p25::dfsi;
using namespace p25::dfsi::packet;
// ---------------------------------------------------------------------------
// Constants
@ -54,9 +55,9 @@ const uint32_t VOC_LDU1_COUNT = 3U;
/// <summary>
/// Resets the data states for the RF interface.
/// </summary>
void DFSIVoicePacket::resetRF()
void DFSIVoice::resetRF()
{
VoicePacket::resetRF();
Voice::resetRF();
LC lc = LC();
m_rfDFSILC = lc;
@ -65,9 +66,9 @@ void DFSIVoicePacket::resetRF()
/// <summary>
/// Resets the data states for the network.
/// </summary>
void DFSIVoicePacket::resetNet()
void DFSIVoice::resetNet()
{
VoicePacket::resetNet();
Voice::resetNet();
LC lc = LC();
m_netDFSILC = lc;
@ -79,7 +80,7 @@ void DFSIVoicePacket::resetNet()
/// <param name="data">Buffer containing data frame.</param>
/// <param name="len">Length of data frame.</param>
/// <returns></returns>
bool DFSIVoicePacket::process(uint8_t* data, uint32_t len)
bool DFSIVoice::process(uint8_t* data, uint32_t len)
{
assert(data != NULL);
@ -632,7 +633,7 @@ bool DFSIVoicePacket::process(uint8_t* data, uint32_t len)
/// <param name="lsd"></param>
/// <param name="duid"></param>
/// <returns></returns>
bool DFSIVoicePacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
bool DFSIVoice::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
{
uint32_t count = 0U;
@ -791,14 +792,14 @@ bool DFSIVoicePacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& contro
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the DFSIVoicePacket class.
/// Initializes a new instance of the DFSIVoice class.
/// </summary>
/// <param name="p25">Instance of the Control class.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
/// <param name="debug">Flag indicating whether P25 debug is enabled.</param>
/// <param name="verbose">Flag indicating whether P25 verbose logging is enabled.</param>
DFSIVoicePacket::DFSIVoicePacket(Control* p25, network::BaseNetwork* network, bool debug, bool verbose) :
VoicePacket(p25, network, debug, verbose),
DFSIVoice::DFSIVoice(Control* p25, network::BaseNetwork* network, bool debug, bool verbose) :
Voice(p25, network, debug, verbose),
m_trunk(NULL),
m_rfDFSILC(),
m_netDFSILC(),
@ -812,13 +813,13 @@ DFSIVoicePacket::DFSIVoicePacket(Control* p25, network::BaseNetwork* network, bo
::memset(m_dfsiLDU2, 0x00U, 9U * 25U);
// hmmm...this should hopefully be a safe cast...right?
m_trunk = (DFSITrunkPacket *)p25->m_trunk;
m_trunk = (DFSITrunk *)p25->m_trunk;
}
/// <summary>
/// Finalizes a instance of the DFSIVoicePacket class.
/// Finalizes a instance of the DFSIVoice class.
/// </summary>
DFSIVoicePacket::~DFSIVoicePacket()
DFSIVoice::~DFSIVoice()
{
delete[] m_dfsiLDU1;
delete[] m_dfsiLDU2;
@ -827,7 +828,7 @@ DFSIVoicePacket::~DFSIVoicePacket()
/// <summary>
/// Helper to write a network P25 TDU packet.
/// </summary>
void DFSIVoicePacket::writeNet_TDU()
void DFSIVoice::writeNet_TDU()
{
if (m_p25->m_control) {
m_p25->m_trunk->releaseDstIdGrant(m_netLC.getDstId(), false);
@ -866,7 +867,7 @@ void DFSIVoicePacket::writeNet_TDU()
/// </summary>
/// <param name="control"></param>
/// <param name="lsd"></param>
void DFSIVoicePacket::writeNet_LDU1()
void DFSIVoice::writeNet_LDU1()
{
lc::LC control = lc::LC(m_dfsiLC.control());
data::LowSpeedData lsd = data::LowSpeedData(m_dfsiLC.lsd());
@ -1161,7 +1162,7 @@ void DFSIVoicePacket::writeNet_LDU1()
/// </summary>
/// <param name="control"></param>
/// <param name="lsd"></param>
void DFSIVoicePacket::writeNet_LDU2()
void DFSIVoice::writeNet_LDU2()
{
lc::LC control = lc::LC(m_dfsiLC.control());
data::LowSpeedData lsd = data::LowSpeedData(m_dfsiLC.lsd());

@ -0,0 +1,100 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_DFSI_PACKET_VOICE_H__)
#define __P25_DFSI_PACKET_VOICE_H__
#include "Defines.h"
#include "p25/dfsi/LC.h"
#include "p25/dfsi/packet/DFSITrunk.h"
#include "p25/packet/Trunk.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Voice; }
class HOST_SW_API Control;
namespace dfsi
{
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 voice packets using
// the DFSI protocol instead of the P25 OTA protocol.
// ---------------------------------------------------------------------------
class HOST_SW_API DFSIVoice : public p25::packet::Voice {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
/// <summary>Resets the data states for the network.</summary>
virtual void resetNet();
/// <summary>Process a data frame from the RF interface.</summary>
virtual bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary>
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
protected:
DFSITrunk* m_trunk;
LC m_rfDFSILC;
LC m_netDFSILC;
uint8_t* m_dfsiLDU1;
uint8_t* m_dfsiLDU2;
/// <summary>Initializes a new instance of the DFSIVoice class.</summary>
DFSIVoice(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
/// <summary>Finalizes a instance of the DFSIVoice class.</summary>
virtual ~DFSIVoice();
/// <summary>Helper to write a network P25 TDU packet.</summary>
virtual void writeNet_TDU();
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
virtual void writeNet_LDU1();
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
virtual void writeNet_LDU2();
private:
friend class packet::DFSITrunk;
friend class p25::Control;
};
} // namespace packet
} // namespace dfsi
} // namespace p25
#endif // __P25_DFSI_PACKET_VOICE_H__

@ -30,7 +30,7 @@
*/
#include "Defines.h"
#include "p25/P25Defines.h"
#include "p25/DataPacket.h"
#include "p25/packet/Data.h"
#include "p25/acl/AccessControl.h"
#include "p25/P25Utils.h"
#include "p25/Sync.h"
@ -41,6 +41,7 @@
using namespace p25;
using namespace p25::data;
using namespace p25::packet;
#include <cassert>
#include <cstdio>
@ -60,7 +61,7 @@ const uint32_t CONN_WAIT_TIMEOUT = 1U;
/// <summary>
/// Resets the data states for the RF interface.
/// </summary>
void DataPacket::resetRF()
void Data::resetRF()
{
m_rfDataBlockCnt = 0U;
m_rfPDUCount = 0U;
@ -75,7 +76,7 @@ void DataPacket::resetRF()
/// <param name="data">Buffer containing data frame.</param>
/// <param name="len">Length of data frame.</param>
/// <returns></returns>
bool DataPacket::process(uint8_t* data, uint32_t len)
bool Data::process(uint8_t* data, uint32_t len)
{
assert(data != NULL);
@ -383,7 +384,7 @@ bool DataPacket::process(uint8_t* data, uint32_t len)
/// <param name="lsd"></param>
/// <param name="duid"></param>
/// <returns></returns>
bool DataPacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
bool Data::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
{
if (m_p25->m_rfState != RS_RF_LISTENING && m_p25->m_netState == RS_NET_IDLE)
return false;
@ -489,7 +490,7 @@ bool DataPacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, da
/// </summary>
/// <param name="llId">Logical Link ID.</param>
/// <returns>True, if ID has registered, otherwise false.</returns>
bool DataPacket::hasLLIdFNEReg(uint32_t llId) const
bool Data::hasLLIdFNEReg(uint32_t llId) const
{
// lookup dynamic FNE registration table entry
try {
@ -509,7 +510,7 @@ bool DataPacket::hasLLIdFNEReg(uint32_t llId) const
/// Updates the processor by the passed number of milliseconds.
/// </summary>
/// <param name="ms"></param>
void DataPacket::clock(uint32_t ms)
void Data::clock(uint32_t ms)
{
// clock all the connect timers
std::vector<uint32_t> connToClear = std::vector<uint32_t>();
@ -554,7 +555,7 @@ void DataPacket::clock(uint32_t ms)
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the DataPacket class.
/// Initializes a new instance of the Data class.
/// </summary>
/// <param name="p25">Instance of the Control class.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
@ -562,7 +563,7 @@ void DataPacket::clock(uint32_t ms)
/// <param name="repeatPDU"></param>
/// <param name="debug">Flag indicating whether P25 debug is enabled.</param>
/// <param name="verbose">Flag indicating whether P25 verbose logging is enabled.</param>
DataPacket::DataPacket(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose) :
Data::Data(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose) :
m_p25(p25),
m_network(network),
m_prevRfState(RS_RF_LISTENING),
@ -611,9 +612,9 @@ DataPacket::DataPacket(Control* p25, network::BaseNetwork* network, bool dumpPDU
}
/// <summary>
/// Finalizes a instance of the DataPacket class.
/// Finalizes a instance of the Data class.
/// </summary>
DataPacket::~DataPacket()
Data::~Data()
{
delete[] m_rfPDU;
delete[] m_netPDU;
@ -626,7 +627,7 @@ DataPacket::~DataPacket()
/// <param name="currentBlock"></param>
/// <param name="data"></param>
/// <param name="len"></param>
void DataPacket::writeNetwork(const uint8_t currentBlock, const uint8_t *data, uint32_t len)
void Data::writeNetwork(const uint8_t currentBlock, const uint8_t *data, uint32_t len)
{
assert(data != NULL);
@ -646,7 +647,7 @@ void DataPacket::writeNetwork(const uint8_t currentBlock, const uint8_t *data, u
/// <param name="bitlength"></param>
/// <param name="noNulls"></param>
/// <remarks>This simply takes data packed into m_rfPDU and transmits it.</remarks>
void DataPacket::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls)
void Data::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls)
{
assert(pdu != NULL);
assert(bitLength > 0U);
@ -690,7 +691,7 @@ void DataPacket::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNull
/// Helper to write a network P25 PDU packet.
/// </summary>
/// <remarks>This will take buffered network PDU data and repeat it over the air.</remarks>
void DataPacket::writeNet_PDU_Buffered()
void Data::writeNet_PDU_Buffered()
{
uint32_t bitLength = ((m_netDataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS;
uint32_t offset = P25_PREAMBLE_LENGTH_BITS;
@ -741,7 +742,7 @@ void DataPacket::writeNet_PDU_Buffered()
/// Helper to re-write a received P25 PDU packet.
/// </summary>
/// <remarks>This will take buffered received PDU data and repeat it over the air.</remarks>
void DataPacket::writeRF_PDU_Buffered()
void Data::writeRF_PDU_Buffered()
{
uint32_t bitLength = ((m_rfDataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS;
uint32_t offset = P25_PREAMBLE_LENGTH_BITS;
@ -794,7 +795,7 @@ void DataPacket::writeRF_PDU_Buffered()
/// <param name="regType"></param>
/// <param name="llId"></param>
/// <param name="ipAddr"></param>
void DataPacket::writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr)
void Data::writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr)
{
if ((regType != PDU_REG_TYPE_RSP_ACCPT) && (regType != PDU_REG_TYPE_RSP_DENY))
return;
@ -859,7 +860,7 @@ void DataPacket::writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong6
/// <param name="ackType"></param>
/// <param name="llId"></param>
/// <param name="noNulls"></param>
void DataPacket::writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls)
void Data::writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls)
{
if (ackClass == PDU_ACK_CLASS_ACK && ackType != PDU_ACK_TYPE_ACK)
return;

@ -0,0 +1,140 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_PACKET_DATA_H__)
#define __P25_PACKET_DATA_H__
#include "Defines.h"
#include "p25/data/DataBlock.h"
#include "p25/data/DataHeader.h"
#include "p25/data/LowSpeedData.h"
#include "p25/lc/LC.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
#include "Timer.h"
#include <cstdio>
#include <string>
#include <unordered_map>
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API Control;
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 data packets.
// ---------------------------------------------------------------------------
class HOST_SW_API Data {
public:
/// <summary>Resets the data states for the RF interface.</summary>
void resetRF();
/// <summary>Process a data frame from the RF interface.</summary>
bool process(uint8_t* data, uint32_t len);
/// <summary>Process a data frame from the network.</summary>
bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
/// <summary>Helper to check if a logical link ID has registered with data services.</summary>
bool hasLLIdFNEReg(uint32_t llId) const;
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
void clock(uint32_t ms);
private:
friend class p25::Control;
Control* m_p25;
network::BaseNetwork* m_network;
RPT_RF_STATE m_prevRfState;
data::DataBlock* m_rfData;
data::DataHeader m_rfDataHeader;
data::DataHeader m_rfSecondHeader;
bool m_rfUseSecondHeader;
uint8_t m_rfDataBlockCnt;
uint8_t* m_rfPDU;
uint32_t m_rfPDUCount;
uint32_t m_rfPDUBits;
data::DataBlock* m_netData;
data::DataHeader m_netDataHeader;
data::DataHeader m_netSecondHeader;
bool m_netUseSecondHeader;
uint32_t m_netDataOffset;
uint8_t m_netDataBlockCnt;
uint8_t* m_netPDU;
uint32_t m_netPDUCount;
uint8_t* m_pduUserData;
uint32_t m_pduUserDataLength;
std::unordered_map<uint32_t, ulong64_t> m_fneRegTable;
std::unordered_map<uint32_t, ulong64_t> m_connQueueTable;
std::unordered_map<uint32_t, Timer> m_connTimerTable;
bool m_dumpPDUData;
bool m_repeatPDU;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the Data class.</summary>
Data(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose);
/// <summary>Finalizes a instance of the Data class.</summary>
~Data();
/// <summary>Write data processed from RF to the network.</summary>
void writeNetwork(const uint8_t currentBlock, const uint8_t* data, uint32_t len);
/// <summary>Helper to write a P25 PDU packet.</summary>
void writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls = false);
/// <summary>Helper to write a network P25 PDU packet.</summary>
void writeNet_PDU_Buffered();
/// <summary>Helper to re-write a received P25 PDU packet.</summary>
void writeRF_PDU_Buffered();
/// <summary>Helper to write a PDU registration response.</summary>
void writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr);
/// <summary>Helper to write a PDU acknowledge response.</summary>
void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls = false);
};
} // namespace packet
} // namespace p25
#endif // __P25_PACKET_DATA_H__

@ -25,7 +25,7 @@
*/
#include "Defines.h"
#include "p25/P25Defines.h"
#include "p25/TrunkPacket.h"
#include "p25/packet/Trunk.h"
#include "p25/acl/AccessControl.h"
#include "p25/P25Utils.h"
#include "p25/Sync.h"
@ -35,6 +35,7 @@
using namespace p25;
using namespace p25::data;
using namespace p25::packet;
#include <cassert>
#include <cstdio>
@ -141,7 +142,7 @@ const uint8_t CONV_FALLBACK_PACKET_DELAY = 8U;
/// <summary>
/// Resets the data states for the RF interface.
/// </summary>
void TrunkPacket::resetRF()
void Trunk::resetRF()
{
lc::TSBK tsbk = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK);
m_rfTSBK = tsbk;
@ -150,7 +151,7 @@ void TrunkPacket::resetRF()
/// <summary>
/// Resets the data states for the network.
/// </summary>
void TrunkPacket::resetNet()
void Trunk::resetNet()
{
lc::TSBK tsbk = lc::TSBK(m_p25->m_siteData, m_p25->m_idenEntry, m_dumpTSBK);
m_netTSBK = tsbk;
@ -163,7 +164,7 @@ void TrunkPacket::resetNet()
/// <param name="len">Length of data frame.</param>
/// <param name="preDecoded">Flag indicating the TSBK data is pre-decoded TSBK data.</param>
/// <returns></returns>
bool TrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
bool Trunk::process(uint8_t* data, uint32_t len, bool preDecoded)
{
assert(data != NULL);
@ -527,7 +528,7 @@ bool TrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
/// <param name="lsd"></param>
/// <param name="duid"></param>
/// <returns></returns>
bool TrunkPacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
bool Trunk::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
{
if (!m_p25->m_control)
return false;
@ -794,7 +795,7 @@ bool TrunkPacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, d
/// </summary>
/// <param name="dataHeader"></param>
/// <param name="dataBlock"></param>
bool TrunkPacket::processMBT(DataHeader dataHeader, DataBlock* blocks)
bool Trunk::processMBT(DataHeader dataHeader, DataBlock* blocks)
{
uint8_t data[1U];
::memset(data, 0x00U, 1U);
@ -807,7 +808,7 @@ bool TrunkPacket::processMBT(DataHeader dataHeader, DataBlock* blocks)
uint8_t raw[P25_PDU_UNCONFIRMED_LENGTH_BYTES];
uint32_t len = blocks[i].getData(raw);
if (len != P25_PDU_UNCONFIRMED_LENGTH_BYTES) {
LogError(LOG_P25, "TrunkPacket::processMBT(), failed to read PDU data block");
LogError(LOG_P25, "Trunk::processMBT(), failed to read PDU data block");
blockRead = false;
}
@ -827,7 +828,7 @@ bool TrunkPacket::processMBT(DataHeader dataHeader, DataBlock* blocks)
/// <summary>
/// Helper to write P25 adjacent site information to the network.
/// </summary>
void TrunkPacket::writeAdjSSNetwork()
void Trunk::writeAdjSSNetwork()
{
if (!m_p25->m_control) {
return;
@ -867,7 +868,7 @@ void TrunkPacket::writeAdjSSNetwork()
/// <param name="srcId"></param>
/// <param name="dstId"></param>
/// <returns></returns>
bool TrunkPacket::hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const
bool Trunk::hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const
{
// lookup dynamic affiliation table entry
try {
@ -888,7 +889,7 @@ bool TrunkPacket::hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const
/// </summary>
/// <param name="srcId"></param>
/// <returns></returns>
bool TrunkPacket::hasSrcIdUnitReg(uint32_t srcId) const
bool Trunk::hasSrcIdUnitReg(uint32_t srcId) const
{
// lookup dynamic unit registration table entry
if (std::find(m_unitRegTable.begin(), m_unitRegTable.end(), srcId) != m_unitRegTable.end()) {
@ -904,7 +905,7 @@ bool TrunkPacket::hasSrcIdUnitReg(uint32_t srcId) const
/// </summary>
/// <param name="chNo"></param>
/// <returns></returns>
bool TrunkPacket::isChBusy(uint32_t chNo) const
bool Trunk::isChBusy(uint32_t chNo) const
{
if (chNo == 0U) {
return false;
@ -925,7 +926,7 @@ bool TrunkPacket::isChBusy(uint32_t chNo) const
/// </summary>
/// <param name="dstId"></param>
/// <returns></returns>
bool TrunkPacket::hasDstIdGranted(uint32_t dstId) const
bool Trunk::hasDstIdGranted(uint32_t dstId) const
{
if (dstId == 0U) {
return false;
@ -950,7 +951,7 @@ bool TrunkPacket::hasDstIdGranted(uint32_t dstId) const
/// </summary>
/// <param name="dstId"></param>
/// <returns></returns>
void TrunkPacket::touchDstIdGrant(uint32_t dstId)
void Trunk::touchDstIdGrant(uint32_t dstId)
{
if (dstId == 0U) {
return;
@ -966,7 +967,7 @@ void TrunkPacket::touchDstIdGrant(uint32_t dstId)
/// </summary>
/// <param name="dstId"></param>
/// <param name="releaseAll"></param>
void TrunkPacket::releaseDstIdGrant(uint32_t dstId, bool releaseAll)
void Trunk::releaseDstIdGrant(uint32_t dstId, bool releaseAll)
{
if (dstId == 0U && !releaseAll) {
return;
@ -1018,7 +1019,7 @@ void TrunkPacket::releaseDstIdGrant(uint32_t dstId, bool releaseAll)
/// </summary>
/// <param name="dstId"></param>
/// <param name="releaseAll"></param>
void TrunkPacket::clearGrpAff(uint32_t dstId, bool releaseAll)
void Trunk::clearGrpAff(uint32_t dstId, bool releaseAll)
{
if (dstId == 0U && !releaseAll) {
return;
@ -1053,7 +1054,7 @@ void TrunkPacket::clearGrpAff(uint32_t dstId, bool releaseAll)
/// Updates the processor by the passed number of milliseconds.
/// </summary>
/// <param name="ms"></param>
void TrunkPacket::clock(uint32_t ms)
void Trunk::clock(uint32_t ms)
{
if (m_p25->m_control) {
if (m_p25->m_network != NULL) {
@ -1140,7 +1141,7 @@ void TrunkPacket::clock(uint32_t ms)
/// </summary>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
void TrunkPacket::writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId)
void Trunk::writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId)
{
if (m_verbose) {
LogMessage(LOG_RF, P25_TSDU_STR ", TSBK_IOSP_CALL_ALRT (Call Alert), srcId = %u, dstId = %u", srcId, dstId);
@ -1160,7 +1161,7 @@ void TrunkPacket::writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId)
/// <param name="func"></param>
/// <param name="arg"></param>
/// <param name="dstId"></param>
void TrunkPacket::writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId)
void Trunk::writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId)
{
uint8_t lco = m_rfTSBK.getLCO();
uint8_t mfId = m_rfTSBK.getMFId();
@ -1198,7 +1199,7 @@ void TrunkPacket::writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t ds
/// Helper to write a group affiliation query packet.
/// </summary>
/// <param name="dstId"></param>
void TrunkPacket::writeRF_TSDU_Grp_Aff_Q(uint32_t dstId)
void Trunk::writeRF_TSDU_Grp_Aff_Q(uint32_t dstId)
{
if (m_verbose) {
LogMessage(LOG_RF, P25_TSDU_STR ", TSBK_OSP_GRP_AFF_Q (Group Affiliation Query), dstId = %u", dstId);
@ -1216,7 +1217,7 @@ void TrunkPacket::writeRF_TSDU_Grp_Aff_Q(uint32_t dstId)
/// Helper to write a unit registration command packet.
/// </summary>
/// <param name="dstId"></param>
void TrunkPacket::writeRF_TSDU_U_Reg_Cmd(uint32_t dstId)
void Trunk::writeRF_TSDU_U_Reg_Cmd(uint32_t dstId)
{
if (m_verbose) {
LogMessage(LOG_RF, P25_TSDU_STR ", TSBK_OSP_U_REG_CMD (Unit Registration Command), dstId = %u", dstId);
@ -1236,7 +1237,7 @@ void TrunkPacket::writeRF_TSDU_U_Reg_Cmd(uint32_t dstId)
/// <param name="group1"></param>
/// <param name="group2"></param>
/// <param name="group3"></param>
void TrunkPacket::writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint32_t group3)
void Trunk::writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint32_t group3)
{
uint8_t lco = m_rfTSBK.getLCO();
@ -1261,7 +1262,7 @@ void TrunkPacket::writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint3
/// Helper to change the conventional fallback state.
/// </summary>
/// <param name="verbose">Flag indicating whether conventional fallback is enabled.</param>
void TrunkPacket::setConvFallback(bool fallback)
void Trunk::setConvFallback(bool fallback)
{
m_convFallback = fallback;
if (m_convFallback && m_p25->m_control) {
@ -1284,7 +1285,7 @@ void TrunkPacket::setConvFallback(bool fallback)
/// Helper to change the TSBK verbose state.
/// </summary>
/// <param name="verbose">Flag indicating whether TSBK dumping is enabled.</param>
void TrunkPacket::setTSBKVerbose(bool verbose)
void Trunk::setTSBKVerbose(bool verbose)
{
m_dumpTSBK = verbose;
}
@ -1294,14 +1295,14 @@ void TrunkPacket::setTSBKVerbose(bool verbose)
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the TrunkPacket class.
/// Initializes a new instance of the Trunk class.
/// </summary>
/// <param name="p25">Instance of the Control class.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
/// <param name="dumpTSBKData">Flag indicating whether TSBK data is dumped to the log.</param>
/// <param name="debug">Flag indicating whether P25 debug is enabled.</param>
/// <param name="verbose">Flag indicating whether P25 verbose logging is enabled.</param>
TrunkPacket::TrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose) :
Trunk::Trunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose) :
m_p25(p25),
m_network(network),
m_patchSuperGroup(0xFFFFU),
@ -1362,9 +1363,9 @@ TrunkPacket::TrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpT
}
/// <summary>
/// Finalizes a instance of the TrunkPacket class.
/// Finalizes a instance of the Trunk class.
/// </summary>
TrunkPacket::~TrunkPacket()
Trunk::~Trunk()
{
delete[] m_rfMBF;
}
@ -1374,7 +1375,7 @@ TrunkPacket::~TrunkPacket()
/// </summary>
/// <param name="data"></param>
/// <param name="autoReset"></param>
void TrunkPacket::writeNetworkRF(const uint8_t* data, bool autoReset)
void Trunk::writeNetworkRF(const uint8_t* data, bool autoReset)
{
assert(data != NULL);
@ -1395,7 +1396,7 @@ void TrunkPacket::writeNetworkRF(const uint8_t* data, bool autoReset)
/// <param name="frameCnt"></param>
/// <param name="n"></param>
/// <param name="adjSS"></param>
void TrunkPacket::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS)
void Trunk::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS)
{
if (!m_p25->m_control)
return;
@ -1525,7 +1526,7 @@ void TrunkPacket::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS)
/// </summary>
/// <param name="lc"></param>
/// <param name="noNetwork"></param>
void TrunkPacket::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
void Trunk::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
{
uint8_t data[P25_TDULC_FRAME_LENGTH_BYTES + 2U];
::memset(data + 2U, 0x00U, P25_TDULC_FRAME_LENGTH_BYTES);
@ -1565,7 +1566,7 @@ void TrunkPacket::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
/// <param name="grp"></param>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
void TrunkPacket::writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId)
void Trunk::writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId)
{
if (!m_p25->m_duplex) {
return;
@ -1616,7 +1617,7 @@ void TrunkPacket::writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t d
/// <param name="noNetwork"></param>
/// <param name="clearBeforeWrite"></param>
/// <param name="force"></param>
void TrunkPacket::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool force)
void Trunk::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool force)
{
if (!m_p25->m_control)
return;
@ -1680,7 +1681,7 @@ void TrunkPacket::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool f
/// Helper to write a multi-block (3-block) P25 TSDU packet.
/// </summary>
/// <param name="clearBeforeWrite"></param>
void TrunkPacket::writeRF_TSDU_MBF(bool clearBeforeWrite)
void Trunk::writeRF_TSDU_MBF(bool clearBeforeWrite)
{
if (!m_p25->m_control) {
::memset(m_rfMBF, 0x00U, P25_MAX_PDU_COUNT * P25_LDU_FRAME_LENGTH_BYTES + 2U);
@ -1798,7 +1799,7 @@ void TrunkPacket::writeRF_TSDU_MBF(bool clearBeforeWrite)
/// Helper to generate the given control TSBK into the TSDU frame queue.
/// </summary>
/// <param name="lco"></param>
void TrunkPacket::queueRF_TSBK_Ctrl(uint8_t lco)
void Trunk::queueRF_TSBK_Ctrl(uint8_t lco)
{
if (!m_p25->m_control)
return;
@ -2044,7 +2045,7 @@ void TrunkPacket::queueRF_TSBK_Ctrl(uint8_t lco)
/// <param name="net"></param>
/// <param name="skipNetCheck"></param>
/// <returns></returns>
bool TrunkPacket::writeRF_TSDU_Grant(bool grp, bool skip, bool net, bool skipNetCheck)
bool Trunk::writeRF_TSDU_Grant(bool grp, bool skip, bool net, bool skipNetCheck)
{
uint8_t lco = m_rfTSBK.getLCO();
@ -2193,7 +2194,7 @@ bool TrunkPacket::writeRF_TSDU_Grant(bool grp, bool skip, bool net, bool skipNet
/// <param name="skip"></param>
/// <param name="net"></param>
/// <returns></returns>
bool TrunkPacket::writeRF_TSDU_SNDCP_Grant(bool skip, bool net)
bool Trunk::writeRF_TSDU_SNDCP_Grant(bool skip, bool net)
{
uint8_t lco = m_rfTSBK.getLCO();
@ -2276,7 +2277,7 @@ bool TrunkPacket::writeRF_TSDU_SNDCP_Grant(bool skip, bool net)
/// </summary>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
void TrunkPacket::writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId)
void Trunk::writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId)
{
uint8_t lco = m_rfTSBK.getLCO();
@ -2300,7 +2301,7 @@ void TrunkPacket::writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId)
/// <param name="srcId"></param>
/// <param name="service"></param>
/// <param name="noNetwork"></param>
void TrunkPacket::writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noNetwork)
void Trunk::writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noNetwork)
{
uint8_t lco = m_rfTSBK.getLCO();
uint8_t mfId = m_rfTSBK.getMFId();
@ -2333,7 +2334,7 @@ void TrunkPacket::writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool ex
/// </summary>
/// <param name="reason"></param>
/// <param name="service"></param>
void TrunkPacket::writeRF_TSDU_Deny(uint8_t reason, uint8_t service)
void Trunk::writeRF_TSDU_Deny(uint8_t reason, uint8_t service)
{
uint8_t lco = m_rfTSBK.getLCO();
uint32_t srcId = m_rfTSBK.getSrcId();
@ -2359,7 +2360,7 @@ void TrunkPacket::writeRF_TSDU_Deny(uint8_t reason, uint8_t service)
/// </summary>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
bool TrunkPacket::writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId)
bool Trunk::writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId)
{
bool ret = false;
@ -2416,7 +2417,7 @@ bool TrunkPacket::writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId)
/// Helper to write a unit registration response packet.
/// </summary>
/// <param name="srcId"></param>
void TrunkPacket::writeRF_TSDU_U_Reg_Rsp(uint32_t srcId)
void Trunk::writeRF_TSDU_U_Reg_Rsp(uint32_t srcId)
{
m_rfTSBK.setLCO(TSBK_IOSP_U_REG);
m_rfTSBK.setResponse(P25_RSP_ACCEPT);
@ -2464,7 +2465,7 @@ void TrunkPacket::writeRF_TSDU_U_Reg_Rsp(uint32_t srcId)
/// Helper to write a unit de-registration acknowledge packet.
/// </summary>
/// <param name="srcId"></param>
void TrunkPacket::writeRF_TSDU_U_Dereg_Ack(uint32_t srcId)
void Trunk::writeRF_TSDU_U_Dereg_Ack(uint32_t srcId)
{
bool dereged = false;
@ -2510,7 +2511,7 @@ void TrunkPacket::writeRF_TSDU_U_Dereg_Ack(uint32_t srcId)
/// </summary>
/// <param name="reason"></param>
/// <param name="service"></param>
void TrunkPacket::writeRF_TSDU_Queue(uint8_t reason, uint8_t service)
void Trunk::writeRF_TSDU_Queue(uint8_t reason, uint8_t service)
{
uint8_t lco = m_rfTSBK.getLCO();
uint32_t srcId = m_rfTSBK.getSrcId();
@ -2536,7 +2537,7 @@ void TrunkPacket::writeRF_TSDU_Queue(uint8_t reason, uint8_t service)
/// </summary>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
bool TrunkPacket::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId)
bool Trunk::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId)
{
bool ret = false;
@ -2593,7 +2594,7 @@ bool TrunkPacket::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId)
/// </summary>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
bool TrunkPacket::writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId)
bool Trunk::writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId)
{
bool ret = false;
@ -2612,7 +2613,7 @@ bool TrunkPacket::writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId)
/// Helper to write a network TSDU from the RF data queue.
/// </summary>
/// <param name="data"></param>
void TrunkPacket::writeNet_TSDU_From_RF(uint8_t* data)
void Trunk::writeNet_TSDU_From_RF(uint8_t* data)
{
::memset(data, 0x00U, P25_TSDU_FRAME_LENGTH_BYTES);
@ -2637,7 +2638,7 @@ void TrunkPacket::writeNet_TSDU_From_RF(uint8_t* data)
/// Helper to write a network P25 TDU w/ link control packet.
/// </summary>
/// <param name="lc"></param>
void TrunkPacket::writeNet_TDULC(lc::TDULC lc)
void Trunk::writeNet_TDULC(lc::TDULC lc)
{
uint8_t buffer[P25_TDULC_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_TDULC_FRAME_LENGTH_BYTES + 2U);
@ -2683,7 +2684,7 @@ void TrunkPacket::writeNet_TDULC(lc::TDULC lc)
/// <summary>
/// Helper to write a network single-block P25 TSDU packet.
/// </summary>
void TrunkPacket::writeNet_TSDU()
void Trunk::writeNet_TSDU()
{
uint8_t buffer[P25_TSDU_FRAME_LENGTH_BYTES + 2U];
::memset(buffer, 0x00U, P25_TSDU_FRAME_LENGTH_BYTES + 2U);
@ -2717,7 +2718,7 @@ void TrunkPacket::writeNet_TSDU()
/// Helper to automatically inhibit a source ID on a denial.
/// </summary>
/// <param name="srcId"></param>
void TrunkPacket::denialInhibit(uint32_t srcId)
void Trunk::denialInhibit(uint32_t srcId)
{
if (!m_p25->m_inhibitIllegal) {
return;
@ -2737,7 +2738,7 @@ void TrunkPacket::denialInhibit(uint32_t srcId)
/// <param name="length"></param>
/// <param name="b1"></param>
/// <param name="b2"></param>
void TrunkPacket::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2)
void Trunk::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2)
{
assert(data != NULL);

@ -0,0 +1,244 @@
/**
* Digital Voice Modem - Host Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Host Software
*
*/
/*
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_PACKET_TRUNK_H__)
#define __P25_PACKET_TRUNK_H__
#include "Defines.h"
#include "p25/data/DataHeader.h"
#include "p25/data/DataBlock.h"
#include "p25/lc/TSBK.h"
#include "p25/lc/TDULC.h"
#include "p25/Control.h"
#include "network/BaseNetwork.h"
#include "network/RemoteControl.h"
#include "Timer.h"
#include <cstdio>
#include <string>
#include <unordered_map>
#include <algorithm>
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
namespace packet { class HOST_SW_API Voice; }
namespace dfsi::packet { class HOST_SW_API DFSIVoice; }
namespace packet { class HOST_SW_API Data; }
class HOST_SW_API Control;
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 trunking packets.
// ---------------------------------------------------------------------------
class HOST_SW_API Trunk {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
/// <summary>Resets the data states for the network.</summary>
virtual void resetNet();
/// <summary>Process a data frame from the RF interface.</summary>
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
/// <summary>Process a data frame from the network.</summary>
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
/// <summary>Helper used to process AMBTs from PDU data.</summary>
bool processMBT(data::DataHeader dataHeader, data::DataBlock* blocks);
/// <summary>Helper to write P25 adjacent site information to the network.</summary>
void writeAdjSSNetwork();
/// <summary>Helper to determine if the source ID has affiliated to the group destination ID.</summary>
bool hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const;
/// <summary>Helper to determine if the source ID has unit registered.</summary>
bool hasSrcIdUnitReg(uint32_t srcId) const;
/// <summary>Helper to determine if the channel number is busy.</summary>
bool isChBusy(uint32_t chNo) const;
/// <summary>Helper to determine if the destination ID is already granted.</summary>
bool hasDstIdGranted(uint32_t dstId) const;
/// <summary>Helper to start the destination ID grant timer.</summary>
void touchDstIdGrant(uint32_t dstId);
/// <summary>Helper to release the channel grant for the destination ID.</summary>
void releaseDstIdGrant(uint32_t dstId, bool releaseAll);
/// <summary>Helper to release group affiliations.</summary>
void clearGrpAff(uint32_t dstId, bool releaseAll);
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
void clock(uint32_t ms);
/// <summary>Helper to set the TSBK manufacturer ID.</summary>
void setMFId(uint8_t val) { m_rfTSBK.setMFId(val); }
/// <summary>Helper to write a call alert packet.</summary>
void writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a extended function packet.</summary>
void writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
/// <summary>Helper to write a group affiliation query packet.</summary>
void writeRF_TSDU_Grp_Aff_Q(uint32_t dstId);
/// <summary>Helper to write a unit registration command packet.</summary>
void writeRF_TSDU_U_Reg_Cmd(uint32_t dstId);
/// <summary>Helper to write a Motorola patch packet.</summary>
void writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint32_t group3);
/// <summary>Helper to change the conventional fallback state.</summary>
void setConvFallback(bool fallback);
/// <summary>Helper to change the TSBK verbose state.</summary>
void setTSBKVerbose(bool verbose);
protected:
friend class packet::Voice;
friend class dfsi::packet::DFSIVoice;
friend class packet::Data;
friend class p25::Control;
Control* m_p25;
network::BaseNetwork* m_network;
uint32_t m_patchSuperGroup;
bool m_verifyAff;
bool m_verifyReg;
lc::TSBK m_rfTSBK;
lc::TSBK m_netTSBK;
uint8_t* m_rfMBF;
uint8_t m_mbfCnt;
uint8_t m_mbfIdenCnt;
uint8_t m_mbfAdjSSCnt;
uint8_t m_mbfSCCBCnt;
uint8_t m_mbfGrpGrntCnt;
std::vector<uint32_t> m_voiceChTable;
std::unordered_map<uint8_t, SiteData> m_adjSiteTable;
std::unordered_map<uint8_t, uint8_t> m_adjSiteUpdateCnt;
std::unordered_map<uint8_t, SiteData> m_sccbTable;
std::unordered_map<uint8_t, uint8_t> m_sccbUpdateCnt;
std::vector<uint32_t> m_unitRegTable;
std::unordered_map<uint32_t, uint32_t> m_grpAffTable;
std::unordered_map<uint32_t, uint32_t> m_grantChTable;
std::unordered_map<uint32_t, Timer> m_grantTimers;
uint8_t m_voiceChCnt;
uint8_t m_voiceGrantChCnt;
bool m_noStatusAck;
bool m_noMessageAck;
bool m_unitToUnitAvailCheck;
uint8_t m_convFallbackPacketDelay;
bool m_convFallback;
Timer m_adjSiteUpdateTimer;
uint32_t m_adjSiteUpdateInterval;
bool m_ctrlTSDUMBF;
bool m_sndcpChGrant;
bool m_dumpTSBK;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the Trunk class.</summary>
Trunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
/// <summary>Finalizes a instance of the Trunk class.</summary>
virtual ~Trunk();
/// <summary>Write data processed from RF to the network.</summary>
void writeNetworkRF(const uint8_t* data, bool autoReset);
/// <summary>Helper to write control channel packet data.</summary>
void writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS);
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
/// <summary>Helper to write a P25 TDU w/ link control channel release packet.</summary>
void writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
/// <summary>Helper to write a multi-block (3-block) P25 TSDU packet.</summary>
void writeRF_TSDU_MBF(bool clearBeforeWrite = false);
/// <summary>Helper to generate the given control TSBK into the TSDU frame queue.</summary>
void queueRF_TSBK_Ctrl(uint8_t lco);
/// <summary>Helper to write a grant packet.</summary>
bool writeRF_TSDU_Grant(bool grp, bool skip = false, bool net = false, bool skipNetCheck = false);
/// <summary>Helper to write a SNDCP grant packet.</summary>
bool writeRF_TSDU_SNDCP_Grant(bool skip = false, bool net = false);
/// <summary>Helper to write a unit to unit answer request packet.</summary>
void writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a acknowledge packet.</summary>
void writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noActivityLog);
/// <summary>Helper to write a deny packet.</summary>
void writeRF_TSDU_Deny(uint8_t reason, uint8_t service);
/// <summary>Helper to write a group affiliation response packet.</summary>
bool writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a unit registration response packet.</summary>
void writeRF_TSDU_U_Reg_Rsp(uint32_t srcId);
/// <summary>Helper to write a unit de-registration acknowledge packet.</summary>
void writeRF_TSDU_U_Dereg_Ack(uint32_t srcId);
/// <summary>Helper to write a queue packet.</summary>
void writeRF_TSDU_Queue(uint8_t reason, uint8_t service);
/// <summary>Helper to write a location registration response packet.</summary>
bool writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a call termination packet.</summary>
bool writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId);
/// <summary>Helper to write a network TSDU from the RF data queue.</summary>
void writeNet_TSDU_From_RF(uint8_t* data);
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
virtual void writeNet_TDULC(lc::TDULC lc);
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
virtual void writeNet_TSDU();
/// <summary>Helper to automatically inhibit a source ID on a denial.</summary>
void denialInhibit(uint32_t srcId);
/// <summary>Helper to add the idle status bits on P25 frame data.</summary>
void addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2);
};
} // namespace packet
} // namespace p25
#endif // __P25_PACKET_TRUNK_H__

@ -30,7 +30,7 @@
*/
#include "Defines.h"
#include "p25/P25Defines.h"
#include "p25/VoicePacket.h"
#include "p25/packet/Voice.h"
#include "p25/acl/AccessControl.h"
#include "p25/dfsi/DFSIDefines.h"
#include "p25/P25Utils.h"
@ -41,6 +41,7 @@
#include "Utils.h"
using namespace p25;
using namespace p25::packet;
#include <cassert>
#include <cstdio>
@ -60,7 +61,7 @@ const uint32_t VOC_LDU1_COUNT = 3U;
/// <summary>
/// Resets the data states for the RF interface.
/// </summary>
void VoicePacket::resetRF()
void Voice::resetRF()
{
lc::LC lc = lc::LC(m_p25->m_siteData);
@ -79,7 +80,7 @@ void VoicePacket::resetRF()
/// <summary>
/// Resets the data states for the network.
/// </summary>
void VoicePacket::resetNet()
void Voice::resetNet()
{
lc::LC lc = lc::LC(m_p25->m_siteData);
@ -97,7 +98,7 @@ void VoicePacket::resetNet()
/// <param name="data">Buffer containing data frame.</param>
/// <param name="len">Length of data frame.</param>
/// <returns></returns>
bool VoicePacket::process(uint8_t* data, uint32_t len)
bool Voice::process(uint8_t* data, uint32_t len)
{
assert(data != NULL);
@ -689,7 +690,7 @@ bool VoicePacket::process(uint8_t* data, uint32_t len)
/// <param name="lsd"></param>
/// <param name="duid"></param>
/// <returns></returns>
bool VoicePacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
bool Voice::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid)
{
uint32_t count = 0U;
@ -848,13 +849,13 @@ bool VoicePacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, d
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the VoicePacket class.
/// Initializes a new instance of the Voice class.
/// </summary>
/// <param name="p25">Instance of the Control class.</param>
/// <param name="network">Instance of the BaseNetwork class.</param>
/// <param name="debug">Flag indicating whether P25 debug is enabled.</param>
/// <param name="verbose">Flag indicating whether P25 verbose logging is enabled.</param>
VoicePacket::VoicePacket(Control* p25, network::BaseNetwork* network, bool debug, bool verbose) :
Voice::Voice(Control* p25, network::BaseNetwork* network, bool debug, bool verbose) :
m_p25(p25),
m_network(network),
m_rfFrames(0U),
@ -895,9 +896,9 @@ VoicePacket::VoicePacket(Control* p25, network::BaseNetwork* network, bool debug
}
/// <summary>
/// Finalizes a instance of the VoicePacket class.
/// Finalizes a instance of the Voice class.
/// </summary>
VoicePacket::~VoicePacket()
Voice::~Voice()
{
delete[] m_netLDU1;
delete[] m_netLDU2;
@ -909,7 +910,7 @@ VoicePacket::~VoicePacket()
/// </summary>
/// <param name="data"></param>
/// <param name="duid"></param>
void VoicePacket::writeNetwork(const uint8_t *data, uint8_t duid)
void Voice::writeNetwork(const uint8_t *data, uint8_t duid)
{
assert(data != NULL);
@ -943,7 +944,7 @@ void VoicePacket::writeNetwork(const uint8_t *data, uint8_t duid)
/// Helper to write end of frame data.
/// </summary>
/// <returns></returns>
void VoicePacket::writeRF_EndOfVoice()
void Voice::writeRF_EndOfVoice()
{
if (!m_hadVoice) {
return;
@ -963,7 +964,7 @@ void VoicePacket::writeRF_EndOfVoice()
/// <summary>
/// Helper to write a network P25 TDU packet.
/// </summary>
void VoicePacket::writeNet_TDU()
void Voice::writeNet_TDU()
{
if (m_p25->m_control) {
m_p25->m_trunk->releaseDstIdGrant(m_netLC.getDstId(), false);
@ -1017,7 +1018,7 @@ void VoicePacket::writeNet_TDU()
/// </summary>
/// <param name="control"></param>
/// <param name="lsd"></param>
void VoicePacket::checkNet_LDU1()
void Voice::checkNet_LDU1()
{
if (m_p25->m_netState == RS_NET_IDLE)
return;
@ -1034,7 +1035,7 @@ void VoicePacket::checkNet_LDU1()
/// </summary>
/// <param name="control"></param>
/// <param name="lsd"></param>
void VoicePacket::writeNet_LDU1()
void Voice::writeNet_LDU1()
{
lc::LC control = lc::LC(m_dfsiLC.control());
data::LowSpeedData lsd = data::LowSpeedData(m_dfsiLC.lsd());
@ -1308,7 +1309,7 @@ void VoicePacket::writeNet_LDU1()
/// </summary>
/// <param name="control"></param>
/// <param name="lsd"></param>
void VoicePacket::checkNet_LDU2()
void Voice::checkNet_LDU2()
{
if (m_p25->m_netState == RS_NET_IDLE)
return;
@ -1325,7 +1326,7 @@ void VoicePacket::checkNet_LDU2()
/// </summary>
/// <param name="control"></param>
/// <param name="lsd"></param>
void VoicePacket::writeNet_LDU2()
void Voice::writeNet_LDU2()
{
lc::LC control = lc::LC(m_dfsiLC.control());
data::LowSpeedData lsd = data::LowSpeedData(m_dfsiLC.lsd());
@ -1411,7 +1412,7 @@ void VoicePacket::writeNet_LDU2()
/// Helper to insert IMBE silence frames for missing audio.
/// </summary>
/// <param name="data"></param>
void VoicePacket::insertMissingAudio(uint8_t* data)
void Voice::insertMissingAudio(uint8_t* data)
{
if (data[10U] == 0x00U) {
::memcpy(data + 10U, m_lastIMBE, 11U);
@ -1490,7 +1491,7 @@ void VoicePacket::insertMissingAudio(uint8_t* data)
/// Helper to insert IMBE null frames for missing audio.
/// </summary>
/// <param name="data"></param>
void VoicePacket::insertNullAudio(uint8_t* data)
void Voice::insertNullAudio(uint8_t* data)
{
if (data[0U] == 0x00U) {
::memcpy(data + 10U, P25_NULL_IMBE, 11U);

@ -11,7 +11,8 @@
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,34 +28,37 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__P25_DFSI_VOICE_PACKET_H__)
#define __P25_DFSI_VOICE_PACKET_H__
#if !defined(__P25_PACKET_VOICE_H__)
#define __P25_PACKET_VOICE_H__
#include "Defines.h"
#include "p25/data/LowSpeedData.h"
#include "p25/dfsi/LC.h"
#include "p25/dfsi/DFSITrunkPacket.h"
#include "p25/TrunkPacket.h"
#include "p25/lc/LC.h"
#include "p25/Control.h"
#include "p25/Audio.h"
#include "network/BaseNetwork.h"
#include <cstdio>
#include <string>
namespace p25
{
// ---------------------------------------------------------------------------
// Class Prototypes
// ---------------------------------------------------------------------------
class HOST_SW_API VoicePacket;
namespace packet { class HOST_SW_API Trunk; }
class HOST_SW_API Control;
namespace dfsi
namespace packet
{
// ---------------------------------------------------------------------------
// Class Declaration
// This class implements handling logic for P25 voice packets using
// the DFSI protocol instead of the P25 OTA protocol.
// This class implements handling logic for P25 voice packets.
// ---------------------------------------------------------------------------
class HOST_SW_API DFSIVoicePacket : public VoicePacket {
class HOST_SW_API Voice {
public:
/// <summary>Resets the data states for the RF interface.</summary>
virtual void resetRF();
@ -67,31 +71,77 @@ namespace p25
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
protected:
DFSITrunkPacket* m_trunk;
friend class packet::Trunk;
friend class p25::Control;
Control* m_p25;
network::BaseNetwork* m_network;
uint32_t m_rfFrames;
uint32_t m_rfBits;
uint32_t m_rfErrs;
uint32_t m_rfUndecodableLC;
uint32_t m_netFrames;
uint32_t m_netLost;
Audio m_audio;
lc::LC m_rfLC;
lc::LC m_rfLastHDU;
lc::LC m_rfLastLDU1;
lc::LC m_rfLastLDU2;
lc::LC m_netLC;
lc::LC m_netLastLDU1;
data::LowSpeedData m_rfLSD;
data::LowSpeedData m_netLSD;
LC m_rfDFSILC;
LC m_netDFSILC;
dfsi::LC m_dfsiLC;
uint8_t* m_netLDU1;
uint8_t* m_netLDU2;
uint8_t* m_dfsiLDU1;
uint8_t* m_dfsiLDU2;
uint8_t m_lastDUID;
uint8_t* m_lastIMBE;
/// <summary>Initializes a new instance of the VoicePacket class.</summary>
DFSIVoicePacket(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
/// <summary>Finalizes a instance of the VoicePacket class.</summary>
virtual ~DFSIVoicePacket();
bool m_hadVoice;
uint32_t m_lastRejectId;
uint32_t m_silenceThreshold;
uint8_t m_vocLDU1Count;
bool m_verbose;
bool m_debug;
/// <summary>Initializes a new instance of the Voice class.</summary>
Voice(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
/// <summary>Finalizes a instance of the Voice class.</summary>
virtual ~Voice();
/// <summary>Write data processed from RF to the network.</summary>
void writeNetwork(const uint8_t* data, uint8_t duid);
/// <summary>Helper to write end of voice frame data.</summary>
void writeRF_EndOfVoice();
/// <summary>Helper to write a network P25 TDU packet.</summary>
virtual void writeNet_TDU();
/// <summary>Helper to check for an unflushed LDU1 packet.</summary>
void checkNet_LDU1();
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
virtual void writeNet_LDU1();
/// <summary>Helper to check for an unflushed LDU2 packet.</summary>
void checkNet_LDU2();
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
virtual void writeNet_LDU2();
private:
friend class DFSITrunkPacket;
friend class p25::Control;
/// <summary>Helper to insert IMBE silence frames for missing audio.</summary>
void insertMissingAudio(uint8_t* data);
/// <summary>Helper to insert IMBE null frames for missing audio.</summary>
void insertNullAudio(uint8_t* data);
};
} // namespace dfsi
} // namespace packet
} // namespace p25
#endif // __P25_DFSI_VOICE_PACKET_H__
#endif // __P25_PACKET_VOICE_H__
Loading…
Cancel
Save

Powered by TurnKey Linux.