add the explicit channel form of the P25 telephone interconnect channel grant (MBT_OSP_TELE_INT_VCH_GRANT, AMBT); grant telephone interconnect calls on explicit channel sites with the AMBT grant instead of refusing them;

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pull/133/head
majmongoose 2 weeks ago
parent 969c604622
commit aad59f9390

@ -101,6 +101,7 @@
#include "common/p25/lc/tsbk/mbt/MBT_OSP_GRP_VCH_GRANT.h"
#include "common/p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.h"
#include "common/p25/lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.h"
#include "common/p25/lc/tsbk/mbt/MBT_OSP_TELE_INT_VCH_GRANT.h"
#include "common/p25/lc/tsbk/mbt/MBT_OSP_UU_VCH_GRANT.h"
namespace p25

@ -0,0 +1,94 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2026 Charles Bricker, K3NOP
*
*/
#include "Defines.h"
#include "p25/lc/tsbk/mbt/MBT_OSP_TELE_INT_VCH_GRANT.h"
using namespace p25;
using namespace p25::defines;
using namespace p25::lc;
using namespace p25::lc::tsbk;
#include <cassert>
// ---------------------------------------------------------------------------
// Public Class Members
// ---------------------------------------------------------------------------
/* Initializes a new instance of the MBT_OSP_TELE_INT_VCH_GRANT class. */
MBT_OSP_TELE_INT_VCH_GRANT::MBT_OSP_TELE_INT_VCH_GRANT() : AMBT(),
m_forceChannelId(false),
m_callTimer(0U),
m_rxGrpVchId(0U),
m_rxGrpVchNo(0U)
{
m_lco = TSBKO::IOSP_TELE_INT_DIAL;
}
/* Decode a alternate trunking signalling block. */
bool MBT_OSP_TELE_INT_VCH_GRANT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks)
{
assert(blocks != nullptr);
/* stub */
return true;
}
/* Encode a alternate trunking signalling block. */
void MBT_OSP_TELE_INT_VCH_GRANT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData)
{
assert(pduUserData != nullptr);
dataHeader.setBlocksToFollow(1U);
uint8_t serviceOptions =
(m_emergency ? 0x80U : 0x00U) + // Emergency Flag
(m_encrypted ? 0x40U : 0x00U) + // Encrypted Flag
(m_priority & 0x07U); // Priority
dataHeader.setAMBTField8(serviceOptions);
dataHeader.setAMBTField9(0U); // Reserved
uint16_t txFrequency = 0U;
if ((m_grpVchId != 0U) || m_forceChannelId) {
txFrequency = (txFrequency << 4) + m_grpVchId; // Tx Channel ID
}
else {
txFrequency = (txFrequency << 4) + s_siteData.channelId(); // Tx Channel ID
}
txFrequency = (txFrequency << 12) + m_grpVchNo; // Tx Channel Number
uint16_t rxFrequency = 0U;
if ((m_rxGrpVchId != 0U) || m_forceChannelId) {
rxFrequency = (rxFrequency << 4) + m_rxGrpVchId; // Rx Channel ID
}
else {
rxFrequency = (rxFrequency << 4) + s_siteData.channelId(); // Rx Channel ID
}
rxFrequency = (rxFrequency << 12) + m_rxGrpVchNo; // Rx Channel Number
/** Block 1 */
SET_UINT16(txFrequency, pduUserData, 0U); // Transmit Frequency
SET_UINT16(rxFrequency, pduUserData, 2U); // Receive Frequency
SET_UINT16(m_callTimer, pduUserData, 4U); // Call Timer
// the source/target radio address is carried in the header (LLId)
AMBT::encode(dataHeader, pduUserData);
}
/* Returns a string that represents the current TSBK. */
std::string MBT_OSP_TELE_INT_VCH_GRANT::toString(bool isp)
{
return std::string("TSBKO, OSP_TELE_INT_VCH_GRANT (Telephone Interconnect Voice Channel Grant - Explicit)");
}

@ -0,0 +1,88 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Digital Voice Modem - Common Library
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2026 Charles Bricker, K3NOP
*
*/
/**
* @file MBT_OSP_TELE_INT_VCH_GRANT.h
* @ingroup p25_ambt
* @file MBT_OSP_TELE_INT_VCH_GRANT.cpp
* @ingroup p25_ambt
*/
#if !defined(__P25_LC_TSBK__MBT_OSP_TELE_INT_VCH_GRANT_H__)
#define __P25_LC_TSBK__MBT_OSP_TELE_INT_VCH_GRANT_H__
#include "common/Defines.h"
#include "common/p25/lc/AMBT.h"
namespace p25
{
namespace lc
{
namespace tsbk
{
// ---------------------------------------------------------------------------
// Class Declaration
// ---------------------------------------------------------------------------
/**
* @brief Implements TELE INT VCH GRANT - Telephone Interconnect Voice Channel Grant - Explicit (OSP).
* @ingroup p25_ambt
*/
class DVM_COMMON_API MBT_OSP_TELE_INT_VCH_GRANT : public AMBT {
public:
/**
* @brief Initializes a new instance of the MBT_OSP_TELE_INT_VCH_GRANT class.
*/
MBT_OSP_TELE_INT_VCH_GRANT();
/**
* @brief Decode a alternate trunking signalling block.
* @param[in] dataHeader P25 PDU data header
* @param[in] blocks P25 PDU data blocks
* @returns bool True, if AMBT decoded, otherwise false.
*/
bool decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) override;
/**
* @brief Encode a alternate trunking signalling block.
* @param[out] dataHeader P25 PDU data header
* @param[out] pduUserData P25 PDU user data
*/
void encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) override;
/**
* @brief Returns a string that represents the current AMBT.
* @returns std::string String representation of the AMBT.
*/
std::string toString(bool isp = false) override;
public:
/**
* @brief Flag forcing the use of the voice channel ID regardless of value.
*/
DECLARE_PROPERTY(bool, forceChannelId, ForceChannelId);
/**
* @brief Call timer, in 100ms units (0 = no timer).
*/
DECLARE_PROPERTY(uint16_t, callTimer, CallTimer);
/** @name Common Data */
/**
* @brief Rx Voice channel ID.
*/
DECLARE_PROTECTED_PROPERTY(uint8_t, rxGrpVchId, RxGrpVchId);
/**
* @brief Rx Voice channel number.
*/
DECLARE_PROTECTED_PROPERTY(uint32_t, rxGrpVchNo, RxGrpVchNo);
/** @} */
};
} // namespace tsbk
} // namespace lc
} // namespace p25
#endif // __P25_LC_TSBK__MBT_OSP_TELE_INT_VCH_GRANT_H__

@ -2533,13 +2533,6 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
}
}
else {
// there is no explicit channel form of the telephone interconnect grant
if (telInt && voiceChData.isExplicitCh()) {
::LogError((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", TSBKO, OSP_TELE_INT_VCH_GRANT (Telephone Interconnect Voice Channel Grant), explicit channels are not supported, chNo = %u-%u", voiceChData.chId(), chNo);
m_p25->m_affiliations->releaseGrant(dstId, false);
return false;
}
// callback RPC to permit the granted TG on the specified voice channel
if (m_p25->m_authoritative && m_p25->m_supervisor) {
if (voiceChData.isValidCh() && !voiceChData.address().empty() && voiceChData.port() > 0 &&
@ -2589,6 +2582,39 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
if (telInt) {
::ActivityLog("P25", !net, "telephone interconnect grant to %u", dstId);
// the grant is held for the whole call (message trunking) instead of per transmission
m_telIntGrants.insert(dstId);
if (voiceChData.isExplicitCh()) {
std::unique_ptr<MBT_OSP_TELE_INT_VCH_GRANT> osp = std::make_unique<MBT_OSP_TELE_INT_VCH_GRANT>();
osp->setMFId(MFG_STANDARD); // under MFG_MOT this opcode is not a telephone interconnect grant
osp->setSrcId(dstId);
osp->setGrpVchId(voiceChData.chId());
osp->setGrpVchNo(chNo);
osp->setRxGrpVchId(voiceChData.rxChId());
osp->setRxGrpVchNo(voiceChData.rxChNo());
osp->setEmergency(emergency);
osp->setEncrypted(encryption);
osp->setPriority(priority);
osp->setForceChannelId(true);
if (m_verbose) {
LogInfoEx((net) ? LOG_NET : LOG_RF, P25_TSDU_STR ", %s, emerg = %u, encrypt = %u, prio = %u, chNo = %u-%u, rxChNo = %u-%u, callTimer = %u, dstId = %u",
osp->toString().c_str(), osp->getEmergency(), osp->getEncrypted(), osp->getPriority(), osp->getGrpVchId(), osp->getGrpVchNo(),
osp->getRxGrpVchId(), osp->getRxGrpVchNo(), osp->getCallTimer(), dstId);
}
// transmit telephone interconnect grant
writeRF_TSDU_AMBT(osp.get(), true);
if (m_redundantGrant) {
for (int i = 0; i < 3; i++)
writeRF_TSDU_AMBT(osp.get(), true);
}
return true;
}
std::unique_ptr<OSP_TELE_INT_VCH_GRANT> osp = std::make_unique<OSP_TELE_INT_VCH_GRANT>();
osp->setMFId(MFG_STANDARD); // under MFG_MOT this opcode is not a telephone interconnect grant
osp->setSrcId(dstId);
@ -2603,9 +2629,6 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_
osp->toString().c_str(), osp->getEmergency(), osp->getEncrypted(), osp->getPriority(), osp->getGrpVchId(), osp->getGrpVchNo(), osp->getCallTimer(), dstId);
}
// the grant is held for the whole call (message trunking) instead of per transmission
m_telIntGrants.insert(dstId);
// transmit telephone interconnect grant
writeRF_TSDU_SBF_Imm(osp.get(), net);
if (m_redundantGrant) {

@ -54,6 +54,50 @@ TEST_CASE("TSBK Telephone Interconnect", "[p25][tsbk]") {
REQUIRE(decoded->getDstId() == 0x123456U);
}
SECTION("MBT_OSP_TELE_INT_VCH_GRANT_Layout") {
MBT_OSP_TELE_INT_VCH_GRANT osp;
osp.setMFId(MFG_STANDARD);
osp.setPriority(4U);
osp.setGrpVchId(1U);
osp.setGrpVchNo(0x123U);
osp.setRxGrpVchId(2U);
osp.setRxGrpVchNo(0x456U);
osp.setCallTimer(600U);
osp.setSrcId(0x123456U);
osp.setForceChannelId(true);
data::DataHeader dataHeader = data::DataHeader();
uint8_t pduUserData[P25_PDU_UNCONFIRMED_LENGTH_BYTES];
::memset(pduUserData, 0x00U, P25_PDU_UNCONFIRMED_LENGTH_BYTES);
osp.encodeMBT(dataHeader, pduUserData);
uint8_t header[P25_PDU_HEADER_LENGTH_BYTES];
::memset(header, 0x00U, P25_PDU_HEADER_LENGTH_BYTES);
dataHeader.encode(header, true);
REQUIRE((header[0U] & 0x1FU) == PDUFormatType::AMBT);
REQUIRE((header[0U] & 0x20U) == 0x20U); // Outbound
REQUIRE((header[1U] & 0x3FU) == PDUSAP::TRUNK_CTRL);
REQUIRE(header[2U] == MFG_STANDARD);
REQUIRE(header[3U] == 0x12U); // Address
REQUIRE(header[4U] == 0x34U);
REQUIRE(header[5U] == 0x56U);
REQUIRE((header[6U] & 0x7FU) == 1U); // Blocks to Follow
REQUIRE((header[7U] & 0x3FU) == TSBKO::IOSP_TELE_INT_DIAL);
REQUIRE(header[8U] == 0x04U); // Service Options
REQUIRE(header[9U] == 0x00U); // Reserved
REQUIRE(pduUserData[0U] == 0x11U); // Channel (T)
REQUIRE(pduUserData[1U] == 0x23U);
REQUIRE(pduUserData[2U] == 0x24U); // Channel (R)
REQUIRE(pduUserData[3U] == 0x56U);
REQUIRE(pduUserData[4U] == 0x02U); // Call Timer
REQUIRE(pduUserData[5U] == 0x58U);
REQUIRE(pduUserData[6U] == 0x00U); // Reserved
REQUIRE(pduUserData[7U] == 0x00U);
REQUIRE(edac::CRC::checkCRC32(pduUserData, P25_PDU_UNCONFIRMED_LENGTH_BYTES));
}
SECTION("ISP_TELE_INT_PSTN_REQ_Layout") {
ISP_TELE_INT_PSTN_REQ isp;
isp.setEmergency(true);

Loading…
Cancel
Save

Powered by TurnKey Linux.