implement TIA-102 Harris User Alias support for trunked VCs;

r05a06_dev
Bryan Biedenkapp 11 hours ago
parent 58801a99af
commit 41be1eaa2b

@ -339,6 +339,14 @@ protocols:
ignoreDataCRC: false
# Flag indicating whether verbose dumping of P25 TSBK data is enabled.
dumpTsbkData: false
# Trunked P25 OTA radio alias transmission.
# (dvmhost currently does not support any conventional radio alias transmission, the current OTA
# implementation only supports trunked OTA radio alias transmission.)
radioAlias:
# Flag indicating whether OTA radio alias transmission is enabled.
enable: false
# Flag indicating Motorola TDULCs are used instead of Harris in-call LCWs.
motorola: false
# Amount of time to hang after a voice call.
callHang: 5
# Flag indicating whether or not the host will acknowledge status packets.
@ -826,6 +834,17 @@ system:
# Flag indicating whether or not the RID ACL updates are logged.
verbose: false
#
# Radio Alias Configuration
#
radio_alias:
# Local cache used for P25 OTA radio alias transmission.
file: rid_alias.dat
# Amount of time between local file reloads. (minutes)
time: 0
# Flag indicating whether radio alias updates are logged.
verbose: false
#
# Talkgroupd ID ACL Configuration
#

@ -61,6 +61,7 @@ BaseNetwork::BaseNetwork(uint32_t peerId, bool duplex, bool debug, bool slot1, b
m_p25StreamId(0U),
m_nxdnStreamId(0U),
m_analogStreamId(0U),
m_radioAliasSyncStreamId(0U),
m_pktSeq(0U),
m_audio()
{
@ -255,8 +256,17 @@ bool BaseNetwork::writeRadioAliasSyncRequest()
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
return false;
if (m_radioAliasSyncStreamId != 0U)
return false;
m_radioAliasSyncStreamId = createStreamId();
uint8_t buffer[1U] = { 0U };
return writeMaster({ NET_FUNC::RADIO_ALIAS_SYNC, NET_SUBFUNC::NOP }, buffer, 1U, RTP_END_OF_CALL_SEQ, 0U, true);
const bool written = writeMaster({ NET_FUNC::RADIO_ALIAS_SYNC, NET_SUBFUNC::NOP }, buffer, 1U, RTP_END_OF_CALL_SEQ, m_radioAliasSyncStreamId, true);
if (!written)
m_radioAliasSyncStreamId = 0U;
return written;
}
/* Writes the local activity log to the network. */

@ -1103,6 +1103,7 @@ namespace network
uint32_t* m_p25P2StreamId;
uint32_t m_nxdnStreamId;
uint32_t m_analogStreamId;
uint32_t m_radioAliasSyncStreamId;
/**
* @brief Helper to update the RTP packet sequence.

@ -54,7 +54,6 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort,
m_tgAdmissionPkt(true, "Talkgroup RID Admission"),
m_tgAdmissionStreamId(0U),
m_radioAliasSyncPkt(true, "Radio Alias Sync"),
m_radioAliasSyncStreamId(0U),
m_salt(nullptr),
m_kmfPresharedKey(nullptr),
m_initRetry(true),

@ -400,7 +400,6 @@ namespace network
uint32_t m_tgAdmissionStreamId;
PacketBuffer m_radioAliasSyncPkt;
uint32_t m_radioAliasSyncStreamId;
uint8_t* m_salt;

@ -53,13 +53,13 @@ bool Network::PacketHandler::ack(Network* network, uint32_t peerId, uint32_t str
network->m_remotePeerId = rtpHeader.getSSRC();
network->pktSeq(true);
network->m_status = NET_STAT_RUNNING;
// fire off peer connected callback if we have one
if (network->m_peerConnectedCallback != nullptr) {
network->m_peerConnectedCallback();
}
network->m_status = NET_STAT_RUNNING;
network->m_timeoutTimer.start();
network->m_retryTimer.setTimeout(DEFAULT_RETRY_TIME);
network->m_retryTimer.start();

@ -96,7 +96,7 @@ bool MotTalkerAlias::decode(const uint8_t* lc, MotTalkerAliasResult& result)
return false;
const uint8_t sequence = lc[7U] >> 4U;
if (m_sequence != sequence) {
if (m_sequence != sequence || m_haveHeader || m_complete) {
reset();
m_sequence = sequence;
}

@ -99,5 +99,8 @@ void LC_TDULC_RAW::setTDULC(const uint8_t* tdulc)
m_tdulc = new uint8_t[P25_TDULC_PAYLOAD_LENGTH_BYTES];
::memset(m_tdulc, 0x00U, P25_TDULC_PAYLOAD_LENGTH_BYTES);
::memcpy(m_tdulc, tdulc, P25_TDULC_PAYLOAD_LENGTH_BYTES);
// TDULC::encode() supplies the LCO separately in RS byte zero. Store only
// the eight bytes following the LCO so the complete nine-byte LC word is
// preserved on air.
::memcpy(m_tdulc, tdulc + 1U, P25_TDULC_PAYLOAD_LENGTH_BYTES);
}

@ -1030,6 +1030,12 @@ bool Host::createNetwork()
m_network->setPacketDump(packetDump);
m_network->setLookups(m_ridLookup, m_tidLookup);
m_network->setRadioAliasLookups(m_ridAliasLookup);
m_network->setPeerConnectedCallback([this, updateLookup]() {
yaml::Node radioAlias = m_conf["protocols"]["p25"]["radioAlias"];
if (updateLookup && radioAlias["enable"].as<bool>(false))
m_network->writeRadioAliasSyncRequest();
});
m_network->setMetadata(m_identity, m_rxFrequency, m_txFrequency, entry.txOffsetMhz(), entry.chBandwidthKhz(), m_channelId, m_channelNo,
m_power, m_latitude, m_longitude, m_height, m_location);

@ -105,6 +105,7 @@ Host::Host(const std::string& confFile) :
m_controlChData(),
m_idenTable(nullptr),
m_ridLookup(nullptr),
m_ridAliasLookup(nullptr),
m_tidLookup(nullptr),
m_dmrBeacons(false),
m_dmrTSCCData(false),
@ -329,6 +330,19 @@ int Host::run()
m_ridLookup = new RadioIdLookup(ridLookupFile, ridReloadTime, ridAcl, verboseRIDRules);
m_ridLookup->read();
std::string ridAliasLookupFile = systemConf["radio_alias"]["file"].as<std::string>("rid_alias.dat");
uint32_t ridAliasReloadTime = systemConf["radio_alias"]["time"].as<uint32_t>(0U);
bool verboseRIDAliasRules = systemConf["radio_alias"]["verbose"].as<bool>(false);
LogInfo("Radio Alias Lookups");
LogInfo(" File: %s", ridAliasLookupFile.length() > 0U ? ridAliasLookupFile.c_str() : "None");
if (ridAliasReloadTime > 0U)
LogInfo(" Reload: %u mins", ridAliasReloadTime);
LogInfo(" Verbose: %s", verboseRIDAliasRules ? "true" : "false");
m_ridAliasLookup = new RadioAliasLookup(ridAliasLookupFile, ridAliasReloadTime, verboseRIDAliasRules);
m_ridAliasLookup->read();
// try to load talkgroup IDs table
std::string tidLookupFile = systemConf["talkgroup_id"]["file"].as<std::string>();
uint32_t tidReloadTime = systemConf["talkgroup_id"]["time"].as<uint32_t>(0U);
@ -519,7 +533,7 @@ int Host::run()
}
m_p25 = std::make_unique<p25::Control>(m_authoritative, m_p25NAC, callHang, m_p25QueueSizeBytes, m_modem,
m_network, m_timeout, m_rfTalkgroupHang, m_duplex, m_channelLookup, m_ridLookup, m_tidLookup, m_idenTable, rssi, p25DumpDataPacket,
m_network, m_timeout, m_rfTalkgroupHang, m_duplex, m_channelLookup, m_ridLookup, m_ridAliasLookup, m_tidLookup, m_idenTable, rssi, p25DumpDataPacket,
p25RepeatDataPacket, p25DumpTsbkData, p25Debug, p25Verbose);
m_p25->setOptions(m_conf, m_cwCallsign, m_controlChData,
m_p25NetId, m_sysId, m_p25RfssId, m_siteId, m_channelId, m_channelNo, true);
@ -1735,9 +1749,13 @@ void Host::setState(uint8_t state)
m_tidLookup->stop();
}
if (m_ridLookup != nullptr) {
m_tidLookup->setReloadTime(0U);
m_ridLookup->setReloadTime(0U);
m_ridLookup->stop();
}
if (m_ridAliasLookup != nullptr) {
m_ridAliasLookup->setReloadTime(0U);
m_ridAliasLookup->stop();
}
}
else {
m_state = STATE_IDLE;

@ -31,6 +31,7 @@
#include "common/lookups/ChannelLookup.h"
#include "common/lookups/IdenTableLookup.h"
#include "common/lookups/RadioIdLookup.h"
#include "common/lookups/RadioAliasLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h"
#include "common/json/json.h"
#include "common/network/Network.h"
@ -159,6 +160,7 @@ private:
lookups::IdenTableLookup* m_idenTable;
lookups::RadioIdLookup* m_ridLookup;
lookups::RadioAliasLookup* m_ridAliasLookup;
lookups::TalkgroupRulesLookup* m_tidLookup;
bool m_dmrBeacons;

@ -54,6 +54,7 @@ std::mutex Control::s_activeTGLock;
Control::Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t queueSize, modem::Modem* modem, network::Network* network,
uint32_t timeout, uint32_t tgHang, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup,
::lookups::RadioAliasLookup* ridAliasLookup,
::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper,
bool dumpPDUData, bool repeatPDU, bool dumpTSBKData, bool debug, bool verbose) :
m_voice(nullptr),
@ -92,6 +93,7 @@ Control::Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t q
m_defaultNetIdleTalkgroup(0U),
m_idenTable(idenTable),
m_ridLookup(ridLookup),
m_ridAliasLookup(ridAliasLookup),
m_tidLookup(tidLookup),
m_affiliations(nullptr),
m_controlChData(),
@ -356,6 +358,10 @@ void Control::setOptions(yaml::Node& conf, const std::string cwCallsign, const :
m_explicitTDUGrantRelease = p25Protocol["explicitTDUGrantRelease"].as<bool>(true);
m_disableDenyResponse = p25Protocol["disableDenyResponse"].as<bool>(false);
yaml::Node radioAlias = p25Protocol["radioAlias"];
m_voice->m_radioAliasEnabled = radioAlias["enable"].as<bool>(false);
m_voice->m_motRadioAlias = radioAlias["motorola"].as<bool>(false);
/*
** Voice Silence and Frame Loss Thresholds
*/
@ -551,6 +557,11 @@ void Control::setOptions(yaml::Node& conf, const std::string cwCallsign, const :
LogInfo(" Immediate Call Termination: %s", m_immediateCallTerm ? "yes" : "no");
LogInfo(" Explicit TDU Grant Release: %s", m_explicitTDUGrantRelease ? "yes" : "no");
LogInfo(" Radio Alias Enabled: %s", m_voice->m_radioAliasEnabled ? "yes" : "no");
if (m_voice->m_radioAliasEnabled) {
LogInfo(" Motorola Radio Alias: %s", m_voice->m_motRadioAlias ? "yes" : "no");
}
LogInfo(" Notify VCs of Active TGs: %s", m_ccNotifyActiveTG ? "yes" : "no");
if (disableGrpAffTimeout) {

@ -39,6 +39,7 @@
#include "common/RingBuffer.h"
#include "common/StopWatch.h"
#include "common/Timer.h"
#include "common/lookups/RadioAliasLookup.h"
#include "common/yaml/Yaml.h"
#include "p25/packet/Data.h"
#include "p25/packet/Voice.h"
@ -94,6 +95,7 @@ namespace p25
* @param duplex Flag indicating full-duplex operation.
* @param chLookup Instance of the ChannelLookup class.
* @param ridLookup Instance of the RadioIdLookup class.
* @param ridAliasLookup Instance of the RadioAliasLookup class.
* @param tidLookup Instance of the TalkgroupRulesLookup class.
* @param idenTable Instance of the IdenTableLookup class.
* @param rssi Instance of the RSSIInterpolator class.
@ -105,6 +107,7 @@ namespace p25
*/
Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t queueSize, modem::Modem* modem, network::Network* network,
uint32_t timeout, uint32_t tgHang, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup,
::lookups::RadioAliasLookup* ridAliasLookup,
::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper,
bool dumpPDUData, bool repeatPDU, bool dumpTSBKData, bool debug, bool verbose);
/**
@ -344,6 +347,7 @@ namespace p25
::lookups::IdenTableLookup* m_idenTable;
::lookups::RadioIdLookup* m_ridLookup;
::lookups::RadioAliasLookup* m_ridAliasLookup;
::lookups::TalkgroupRulesLookup* m_tidLookup;
lookups::P25AffiliationLookup* m_affiliations;
::lookups::VoiceChData m_controlChData;

@ -15,6 +15,8 @@
#include "common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.h"
#include "common/p25/lc/tsbk/OSP_UU_VCH_GRANT_UPD.h"
#include "common/p25/lc/tdulc/TDULCFactory.h"
#include "common/p25/lc/tdulc/LC_TDULC_RAW.h"
#include "common/p25/lc/MotTalkerAlias.h"
#include "common/p25/P25Utils.h"
#include "common/p25/Sync.h"
#include "common/Log.h"
@ -782,7 +784,9 @@ bool Voice::process(uint8_t* data, uint32_t len)
m_rfLC.setRS(rsValue);
}
m_rfLC.encodeLDU1(data + 2U);
lc::LC outboundLC(m_rfLC);
applyUserAlias(outboundLC, m_rfUserAliasPhase);
outboundLC.encodeLDU1(data + 2U);
// generate Low Speed Data
m_rfLSD.process(data + 2U);
@ -1161,6 +1165,9 @@ bool Voice::process(uint8_t* data, uint32_t len)
}
if (duid == DUID::TDU) {
if (m_p25->m_rfState == RS_RF_AUDIO)
writeMotAlias(m_rfLC);
if (m_p25->m_immediateCallTerm)
m_p25->writeRF_TDU(false);
else {
@ -1185,6 +1192,8 @@ bool Voice::process(uint8_t* data, uint32_t len)
LogWarning(LOG_RF, P25_TDULC_STR ", undecodable TDULC");
}
else {
if (m_p25->m_rfState == RS_RF_AUDIO && tdulc->getLCO() == LCO::CALL_TERM)
writeMotAlias(m_rfLC);
m_p25->m_control->writeRF_TDULC(tdulc.get(), false);
}
}
@ -1395,6 +1404,8 @@ bool Voice::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::L
}
if (m_p25->m_netState != RS_NET_IDLE) {
writeMotAlias(m_netLC);
if (duid == DUID::TDU)
writeNet_TDU();
@ -1454,6 +1465,9 @@ Voice::Voice(Control* p25, bool debug, bool verbose) :
m_roamLDU1Count(0U),
m_rfUserAliasPhase(0U),
m_netUserAliasPhase(0U),
m_radioAliasEnabled(false),
m_motRadioAlias(false),
m_motAliasSequence(0U),
m_inbound(false),
m_verbose(verbose),
m_debug(debug)
@ -2146,7 +2160,9 @@ void Voice::writeNet_LDU1()
m_netLC.setRS(rsValue);
}
m_netLC.encodeLDU1(buffer + 2U);
lc::LC outboundLC(m_netLC);
applyUserAlias(outboundLC, m_netUserAliasPhase);
outboundLC.encodeLDU1(buffer + 2U);
// add the Audio
m_audio.encode(buffer + 2U, m_netLDU1 + 10U, 0U);
@ -2399,14 +2415,20 @@ void Voice::resetWithNullAudio(uint8_t* data, bool encrypted)
bool Voice::applyUserAlias(lc::LC& control, uint8_t& phase)
{
// User Alias is an outbound voice-channel LC. Do not displace scheduled
// status, update, explicit-source-ID, or vendor-specific LCs.
if (!control.isStandardMFId() ||
(control.getLCO() != LCO::GROUP && control.getLCO() != LCO::PRIVATE &&
control.getLCO() != LCO::PRIVATE_EXT)) {
if (!m_radioAliasEnabled || m_motRadioAlias || m_p25->m_ridAliasLookup == nullptr)
return false;
// user Alias is an outbound voice-channel LC; do not displace scheduled
// status, update, explicit-source-ID, or vendor-specific LCs
if (!control.isStandardMFId() || control.getExplicitId() ||
(control.getLCO() != LCO::GROUP && control.getLCO() != LCO::PRIVATE)) {
return false;
}
const std::string radioAlias = m_p25->m_ridAliasLookup->find(control.getSrcId());
if (radioAlias.empty() || radioAlias == "UNKNOWN")
return false;
const uint8_t currentPhase = phase;
phase = (phase + 1U) % USER_ALIAS_PHASE_COUNT;
@ -2414,15 +2436,6 @@ bool Voice::applyUserAlias(lc::LC& control, uint8_t& phase)
if (currentPhase == 2U || currentPhase == 5U)
return false;
// bryanb: this needs to be changed to use the actual Radio Alias from the new radio alias lookups
// and not the radio ID ACL alias data
// TODO FIXME TODO
::lookups::RadioId rid = m_p25->m_ridLookup->find(control.getSrcId());
if (rid.radioDefault())
return false;
std::string radioAlias = rid.radioAlias();
control.setUserAlias(radioAlias);
control.setMFId(MFG_HARRIS);
@ -2446,6 +2459,28 @@ bool Voice::applyUserAlias(lc::LC& control, uint8_t& phase)
return true;
}
/* Transmits Motorola talker-alias TDULCs for a completed call. */
void Voice::writeMotAlias(const lc::LC& control)
{
if (!m_radioAliasEnabled || !m_motRadioAlias || m_p25->m_ridAliasLookup == nullptr || !m_p25->m_duplex)
return;
const std::string alias = m_p25->m_ridAliasLookup->find(control.getSrcId());
if (alias.empty() || alias == "UNKNOWN")
return;
const SiteData site = lc::LC::getSiteData();
const std::vector<std::vector<uint8_t>> words = lc::MotTalkerAlias::encode(site.netId(), site.sysId(),
control.getSrcId(), (uint16_t)control.getDstId(), alias, m_motAliasSequence++);
for (const std::vector<uint8_t>& word : words) {
lc::tdulc::LC_TDULC_RAW raw;
raw.setTDULC(word.data());
m_p25->m_control->writeRF_TDULC(&raw, true);
}
}
/* Helper to determine the next active talkgroup in a active multi-group scenario. */
bool Voice::nextActiveTalkgroups(const std::vector<uint32_t>& activeTG, uint8_t& groupUpdtIndex, const uint32_t dstId, uint32_t& dstIdB, bool& hasDstIdB)

@ -139,6 +139,9 @@ namespace p25
uint8_t m_rfUserAliasPhase;
uint8_t m_netUserAliasPhase;
bool m_radioAliasEnabled;
bool m_motRadioAlias;
uint8_t m_motAliasSequence;
bool m_inbound;
@ -234,6 +237,11 @@ namespace p25
* @returns bool True if a User Alias LC was selected.
*/
bool applyUserAlias(lc::LC& control, uint8_t& phase);
/**
* @brief Transmits Motorola talker-alias TDULCs for a completed call.
* @param control Link control identifying the completed call.
*/
void writeMotAlias(const lc::LC& control);
/**
* @brief Helper to determine the next active talkgroup in a active multi-group scenario,

@ -773,6 +773,28 @@ void HostTestHooks::p25ProcessNetworkQueue(p25::Control& control)
control.processNetwork();
}
/* Configures synthetic P25 OTA radio-alias transmission. */
void HostTestHooks::p25ConfigureRadioAlias(p25::Control& control, bool enabled, bool motorola)
{
control.m_voice->m_radioAliasEnabled = enabled;
control.m_voice->m_motRadioAlias = motorola;
}
/* Applies one synthetic Harris radio-alias scheduling step. */
bool HostTestHooks::p25ApplyRadioAlias(p25::Control& control, p25::lc::LC& lc, uint8_t& phase)
{
return control.m_voice->applyUserAlias(lc, phase);
}
/* Queues Motorola radio-alias TDULCs for a synthetic completed call. */
void HostTestHooks::p25WriteMotorolaAlias(p25::Control& control, const p25::lc::LC& lc)
{
control.m_voice->writeMotAlias(lc);
}
/* Selects the next secondary active talkgroup for a P25 voice channel. */
bool HostTestHooks::p25NextActiveTalkgroups(p25::Control& control, const std::vector<uint32_t>& activeTG,

@ -656,6 +656,27 @@ public:
* @param control P25 control instance.
*/
static void p25ProcessNetworkQueue(p25::Control& control);
/**
* @brief Configures synthetic P25 OTA radio-alias transmission.
* @param control P25 control instance.
* @param enabled Flag indicating alias transmission is enabled.
* @param motorola Flag indicating Motorola TDULCs are selected.
*/
static void p25ConfigureRadioAlias(p25::Control& control, bool enabled, bool motorola);
/**
* @brief Applies one synthetic Harris radio-alias scheduling step.
* @param control P25 control instance.
* @param lc Link control candidate to modify.
* @param phase Alias conveyance phase.
* @return bool True when the candidate was replaced by an alias LC.
*/
static bool p25ApplyRadioAlias(p25::Control& control, p25::lc::LC& lc, uint8_t& phase);
/**
* @brief Queues Motorola radio-alias TDULCs for a synthetic completed call.
* @param control P25 control instance.
* @param lc Completed-call link control.
*/
static void p25WriteMotorolaAlias(p25::Control& control, const p25::lc::LC& lc);
/**
* @brief Selects the next secondary active talkgroup for a P25 voice channel.
*/

@ -286,8 +286,10 @@ TEST_CASE("Network performs a full loopback login handshake", "[network][loopbac
REQUIRE(network.open());
bool connected = false;
network.setPeerConnectedCallback([&connected]() {
bool aliasRequestWritten = false;
network.setPeerConnectedCallback([&network, &connected, &aliasRequestWritten]() {
connected = true;
aliasRequestWritten = network.writeRadioAliasSyncRequest();
});
network.clock(11000U);
@ -336,6 +338,7 @@ TEST_CASE("Network performs a full loopback login handshake", "[network][loopbac
network.clock(1000U);
REQUIRE(connected);
REQUIRE(aliasRequestWritten);
masterReceiver.close();
}

@ -12,6 +12,7 @@
#include "common/lookups/IdenTableLookup.h"
#include "common/lookups/RSSIInterpolator.h"
#include "common/lookups/RadioIdLookup.h"
#include "common/lookups/RadioAliasLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h"
#include "common/network/NetRPC.h"
#include "common/network/Network.h"
@ -19,6 +20,8 @@
#include "common/p25/P25Defines.h"
#include "common/p25/data/LowSpeedData.h"
#include "common/p25/lc/LC.h"
#include "common/p25/lc/MotTalkerAlias.h"
#include "common/p25/lc/tdulc/LC_TDULC_RAW.h"
#include "common/p25/lc/tdulc/TDULCFactory.h"
#include "common/p25/lc/tsbk/IOSP_EXT_FNCT.h"
#include "host/modem/Modem.h"
@ -575,6 +578,7 @@ public:
0U, 0U, 0U, 1024U, 4096U, 1024U, true, true, false, false, false, false),
m_chLookup(),
m_ridLookup("", 0U, false, false),
m_ridAliasLookup("", 0U, false),
m_tidLookup("", 0U, tgAcl, false),
m_idenLookup("", 0U),
m_rssiMapper(),
@ -583,9 +587,10 @@ public:
{
g_RPC = &m_rpc;
m_modem.setModeParams(false, true, false);
m_ridAliasLookup.clear();
m_control = new p25::Control(authoritative, 0x293U, 1U, 4096U, &m_modem, m_network,
5U, 2U, duplex, &m_chLookup, &m_ridLookup, &m_tidLookup, &m_idenLookup,
5U, 2U, duplex, &m_chLookup, &m_ridLookup, &m_ridAliasLookup, &m_tidLookup, &m_idenLookup,
&m_rssiMapper, false, false, false, true, true);
}
/**
@ -626,6 +631,7 @@ public:
modem::Modem m_modem;
lookups::ChannelLookup m_chLookup;
lookups::RadioIdLookup m_ridLookup;
lookups::RadioAliasLookup m_ridAliasLookup;
lookups::TalkgroupRulesLookup m_tidLookup;
lookups::IdenTableLookup m_idenLookup;
lookups::RSSIInterpolator m_rssiMapper;
@ -633,6 +639,128 @@ public:
p25::Control* m_control;
};
TEST_CASE("P25 Harris radio aliases preserve scheduled link control", "[p25][host][radio-alias][harris]")
{
P25HostHarness harness(true, false, 0U, 1U, false, false, true);
harness.m_ridAliasLookup.addEntry(1001U, "TEST RADIO");
HostTestHooks::p25ConfigureRadioAlias(*harness.m_control, true, false);
uint8_t phase = 0U;
p25::lc::LC control;
control.setMFId(p25::defines::MFG_STANDARD);
control.setSrcId(1001U);
control.setDstId(2001U);
SECTION("timed replacement LCOs take precedence") {
control.setLCO(p25::defines::LCO::RFSS_STS_BCAST);
CHECK_FALSE(HostTestHooks::p25ApplyRadioAlias(*harness.m_control, control, phase));
CHECK(control.getLCO() == p25::defines::LCO::RFSS_STS_BCAST);
CHECK(phase == 0U);
control.setLCO(p25::defines::LCO::GROUP_UPDT);
CHECK_FALSE(HostTestHooks::p25ApplyRadioAlias(*harness.m_control, control, phase));
CHECK(control.getLCO() == p25::defines::LCO::GROUP_UPDT);
CHECK(phase == 0U);
}
SECTION("explicit source signaling takes precedence") {
control.setLCO(p25::defines::LCO::GROUP);
control.setExplicitId(true);
CHECK_FALSE(HostTestHooks::p25ApplyRadioAlias(*harness.m_control, control, phase));
CHECK(control.getLCO() == p25::defines::LCO::GROUP);
CHECK(phase == 0U);
control.setExplicitId(false);
control.setLCO(p25::defines::LCO::PRIVATE_EXT);
CHECK_FALSE(HostTestHooks::p25ApplyRadioAlias(*harness.m_control, control, phase));
CHECK(control.getLCO() == p25::defines::LCO::PRIVATE_EXT);
CHECK(phase == 0U);
}
}
TEST_CASE("P25 Harris radio aliases follow the odd-even conveyance cadence", "[p25][host][radio-alias][harris]")
{
P25HostHarness harness;
harness.m_ridAliasLookup.addEntry(1001U, "TEST RADIO");
HostTestHooks::p25ConfigureRadioAlias(*harness.m_control, true, false);
uint8_t phase = 0U;
const uint8_t expected[] = {
p25::defines::LCO::HARRIS_USER_ALIAS_A_ODD,
p25::defines::LCO::HARRIS_USER_ALIAS_B_ODD,
p25::defines::LCO::GROUP,
p25::defines::LCO::HARRIS_USER_ALIAS_A_EVEN,
p25::defines::LCO::HARRIS_USER_ALIAS_B_EVEN,
p25::defines::LCO::GROUP
};
for (uint8_t i = 0U; i < sizeof(expected); ++i) {
p25::lc::LC control;
control.setLCO(p25::defines::LCO::GROUP);
control.setMFId(p25::defines::MFG_STANDARD);
control.setSrcId(1001U);
control.setDstId(2001U);
const bool applied = HostTestHooks::p25ApplyRadioAlias(*harness.m_control, control, phase);
CHECK(applied == (i != 2U && i != 5U));
CHECK(control.getLCO() == expected[i]);
if (applied) {
CHECK(control.getMFId() == p25::defines::MFG_HARRIS);
CHECK(control.getUserAlias() == "TEST RADIO");
}
}
CHECK(phase == 0U);
}
TEST_CASE("P25 missing radio aliases leave voice link control unchanged", "[p25][host][radio-alias]")
{
P25HostHarness harness;
HostTestHooks::p25ConfigureRadioAlias(*harness.m_control, true, false);
uint8_t phase = 0U;
p25::lc::LC control;
control.setLCO(p25::defines::LCO::GROUP);
control.setMFId(p25::defines::MFG_STANDARD);
control.setSrcId(1001U);
control.setDstId(2001U);
CHECK_FALSE(HostTestHooks::p25ApplyRadioAlias(*harness.m_control, control, phase));
CHECK(control.getLCO() == p25::defines::LCO::GROUP);
CHECK(control.getMFId() == p25::defines::MFG_STANDARD);
CHECK(phase == 0U);
}
TEST_CASE("P25 Motorola radio aliases queue captured TDULCs in order", "[p25][host][radio-alias][motorola]")
{
P25HostHarness harness(true, false, 0U, 1U, false, false, true);
harness.m_ridAliasLookup.addEntry(0xE67852U, "NYSP-1D82UHFM");
HostTestHooks::p25ConfigureRadioAlias(*harness.m_control, true, true);
p25::lc::LC control;
control.setLCO(p25::defines::LCO::GROUP);
control.setMFId(p25::defines::MFG_STANDARD);
control.setSrcId(0xE67852U);
control.setDstId(0x1BBDU);
const std::vector<std::vector<uint8_t>> expected = p25::lc::MotTalkerAlias::encode(
p25::lc::LC::getSiteData().netId(), p25::lc::LC::getSiteData().sysId(),
control.getSrcId(), (uint16_t)control.getDstId(), "NYSP-1D82UHFM", 0U);
HostTestHooks::p25WriteMotorolaAlias(*harness.m_control, control);
for (const std::vector<uint8_t>& word : expected) {
uint8_t frame[p25::defines::P25_TDULC_FRAME_LENGTH_BYTES + 2U] = { 0U };
REQUIRE(harness.m_control->getFrame(frame) == sizeof(frame));
p25::lc::tdulc::LC_TDULC_RAW raw;
REQUIRE(raw.decode(frame + 2U));
REQUIRE(raw.getDecodedRaw() != nullptr);
CHECK(::memcmp(raw.getDecodedRaw(), word.data(), word.size()) == 0);
}
uint8_t extra[p25::defines::P25_TDULC_FRAME_LENGTH_BYTES + 2U] = { 0U };
CHECK(harness.m_control->getFrame(extra) == 0U);
}
TEST_CASE("P25 group call termination addresses all subscriber units",
"[p25][host][control][tdulc][call-termination]")
{

@ -11,6 +11,7 @@
#include "common/p25/lc/tdulc/LC_GROUP.h"
#include "common/p25/lc/tdulc/LC_GROUP_UPDT.h"
#include "common/p25/lc/tdulc/LC_PRIVATE.h"
#include "common/p25/lc/tdulc/LC_TDULC_RAW.h"
#include "common/p25/lc/tdulc/LC_TEL_INT_VCH_USER.h"
#include "common/p25/P25Defines.h"
#include "common/edac/Golay24128.h"
@ -24,6 +25,28 @@ using namespace p25::lc::tdulc;
#include <catch2/catch_test_macros.hpp>
TEST_CASE("TDULC", "[p25][tdulc]") {
SECTION("Raw LC words preserve the LCO and all eight payload bytes") {
const uint8_t word[P25_TDULC_PAYLOAD_LENGTH_BYTES + 1U] = {
LCO::MOT_TALKER_ALIAS_DATA, MFG_MOT, 0x07U, 0xF9U, 0x4BU,
0x30U, 0x12U, 0x34U, 0x56U
};
LC_TDULC_RAW encoded;
encoded.setTDULC(word);
uint8_t frame[P25_TDULC_FRAME_LENGTH_BYTES] = { 0U };
encoded.encode(frame);
LC_TDULC_RAW decoded;
REQUIRE(decoded.decode(frame));
REQUIRE(decoded.getDecodedRaw() != nullptr);
CHECK(::memcmp(decoded.getDecodedRaw(), word, sizeof(word)) == 0);
uint8_t rawPayload[P25_TDULC_PAYLOAD_LENGTH_BYTES] = { 0U };
encoded.encode(rawPayload, true);
CHECK(::memcmp(rawPayload, word + 1U, sizeof(rawPayload)) == 0);
}
SECTION("Constants_Valid") {
// Verify TDULC length constants
REQUIRE(P25_TDULC_LENGTH_BYTES == 18); // Total length with RS FEC

@ -125,3 +125,22 @@ TEST_CASE("P25 Motorola talker alias captured encoding", "[p25][lc][user-alias][
REQUIRE(::memcmp(words[word].data(), expected[word], sizeof(expected[word])) == 0);
}
}
TEST_CASE("P25 Motorola talker alias sequence reuse starts a new message", "[p25][lc][user-alias][motorola]")
{
const std::vector<std::vector<uint8_t>> first = MotTalkerAlias::encode(
0xBB800U, 0x123U, 0x456789U, 0x2345U, "FIRST", 0x03U);
const std::vector<std::vector<uint8_t>> second = MotTalkerAlias::encode(
0xBB800U, 0x123U, 0x456789U, 0x2345U, "SECOND", 0x03U);
MotTalkerAlias assembler;
MotTalkerAliasResult result;
for (const std::vector<uint8_t>& word : first)
assembler.decode(word.data(), result);
REQUIRE(result.alias == "FIRST");
REQUIRE_FALSE(assembler.decode(second.front().data(), result));
for (std::size_t i = 1U; i < second.size(); ++i)
assembler.decode(second[i].data(), result);
REQUIRE(result.alias == "SECOND");
}

Loading…
Cancel
Save

Powered by TurnKey Linux.