From 4a201b3380b12674a88e57407c835b89efbedc6f Mon Sep 17 00:00:00 2001 From: majmongoose Date: Mon, 12 Oct 2026 10:58:52 -0400 Subject: [PATCH] add telephoneInterconnect control channel option; forward P25 telephone interconnect PSTN requests, answer responses and interconnect cancels to the network, and only transmit network answer requests for units registered to the site; Co-Authored-By: Claude Opus 5.5 --- configs/config.example.yml | 3 + src/host/p25/Control.cpp | 2 + src/host/p25/packet/ControlSignaling.cpp | 83 +++++++++++++++++++++++- src/host/p25/packet/ControlSignaling.h | 1 + 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/configs/config.example.yml b/configs/config.example.yml index 8a27f84f..559a588e 100644 --- a/configs/config.example.yml +++ b/configs/config.example.yml @@ -343,6 +343,9 @@ protocols: noMessageAck: true # Flag indicating that unit-to-unit availiability checks should be performed for a private call. unitToUnitAvailCheck: false + # Flag indicating telephone interconnect requests are forwarded to the network for a telephone + # interconnect gateway peer to service. (If disabled, telephone interconnect requests are denied.) + telephoneInterconnect: false # Flag indicating explicit source ID support is enabled. allowExplicitSourceId: false # Flag indicating whether or not the host will disable sending deny responses when operating in conventional. diff --git a/src/host/p25/Control.cpp b/src/host/p25/Control.cpp index 5dea949a..3c3bc4d8 100644 --- a/src/host/p25/Control.cpp +++ b/src/host/p25/Control.cpp @@ -271,6 +271,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw m_control->m_noStatusAck = p25Protocol["noStatusAck"].as(false); m_control->m_noMessageAck = p25Protocol["noMessageAck"].as(true); m_control->m_unitToUnitAvailCheck = p25Protocol["unitToUnitAvailCheck"].as(true); + m_control->m_telephoneInterconnect = p25Protocol["telephoneInterconnect"].as(false); m_sndcpSupport = p25Protocol["sndcpSupport"].as(false); @@ -531,6 +532,7 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw LogInfo(" No Status ACK: %s", m_control->m_noStatusAck ? "yes" : "no"); LogInfo(" No Message ACK: %s", m_control->m_noMessageAck ? "yes" : "no"); LogInfo(" Unit-to-Unit Availability Check: %s", m_control->m_unitToUnitAvailCheck ? "yes" : "no"); + LogInfo(" Telephone Interconnect: %s", m_control->m_telephoneInterconnect ? "yes" : "no"); LogInfo(" Explicit Source ID Support: %s", m_allowExplicitSourceId ? "yes" : "no"); LogInfo(" Conventional Network Grant Demand: %s", m_convNetGrantDemand ? "yes" : "no"); LogInfo(" Demand Unit Registration for Refused Affiliation: %s", m_demandUnitRegForRefusedAff ? "yes" : "no"); diff --git a/src/host/p25/packet/ControlSignaling.cpp b/src/host/p25/packet/ControlSignaling.cpp index 97662099..c149d8c1 100644 --- a/src/host/p25/packet/ControlSignaling.cpp +++ b/src/host/p25/packet/ControlSignaling.cpp @@ -310,6 +310,37 @@ bool ControlSignaling::process(uint8_t* data, uint32_t len, std::unique_ptrtoString(true), TSBKO::ISP_TELE_INT_PSTN_REQ, srcId); + + // validate the source RID + VALID_SRCID(tsbk->toString(true), TSBKO::ISP_TELE_INT_PSTN_REQ, srcId); + + if (!m_telephoneInterconnect || m_p25->m_network == nullptr) { + LogWarning(LOG_RF, P25_TSDU_STR ", %s denial, unsupported service, srcId = %u", tsbk->toString(true).c_str(), srcId); + writeRF_TSDU_Deny(srcId, WUID_FNE, ReasonCode::DENY_SYS_UNSUPPORTED_SVC, TSBKO::ISP_TELE_INT_PSTN_REQ); + m_p25->m_rfState = RS_RF_REJECTED; + return false; + } + + // verify the source RID is registered + VERIFY_SRCID_REG(tsbk->toString(true), TSBKO::ISP_TELE_INT_PSTN_REQ, srcId); + + ISP_TELE_INT_PSTN_REQ* isp = static_cast(tsbk.get()); + if (m_verbose) { + LogInfoEx(LOG_RF, P25_TSDU_STR ", %s, pstnAddress = %u, srcId = %u", + tsbk->toString(true).c_str(), isp->getPSTNAddress(), srcId); + } + + ::ActivityLog("P25", true, "telephone interconnect request from %u to PSTN address %u", srcId, isp->getPSTNAddress()); + + // the telephone interconnect gateway places the call and demands the channel grant + RF_TO_WRITE_NET(isp); + writeRF_TSDU_ACK_FNE(srcId, TSBKO::ISP_TELE_INT_PSTN_REQ, false, true); + } + break; case TSBKO::IOSP_TELE_INT_ANS: { // make sure control data is supported @@ -318,7 +349,23 @@ bool ControlSignaling::process(uint8_t* data, uint32_t len, std::unique_ptrtoString(true), TSBKO::IOSP_TELE_INT_ANS, srcId); - writeRF_TSDU_Deny(srcId, WUID_FNE, ReasonCode::DENY_SYS_UNSUPPORTED_SVC, TSBKO::IOSP_TELE_INT_ANS); + if (!m_telephoneInterconnect || m_p25->m_network == nullptr) { + LogWarning(LOG_RF, P25_TSDU_STR ", %s denial, unsupported service, srcId = %u", tsbk->toString(true).c_str(), srcId); + writeRF_TSDU_Deny(srcId, WUID_FNE, ReasonCode::DENY_SYS_UNSUPPORTED_SVC, TSBKO::IOSP_TELE_INT_ANS); + m_p25->m_rfState = RS_RF_REJECTED; + return false; + } + + IOSP_TELE_INT_ANS* iosp = static_cast(tsbk.get()); + if (m_verbose) { + LogInfoEx(LOG_RF, P25_TSDU_STR ", %s, response = $%02X, srcId = %u", + tsbk->toString(true).c_str(), iosp->getResponse(), srcId); + } + + ::ActivityLog("P25", true, "telephone interconnect answer response from %u", srcId); + + // forward the received frame as-is; re-encoding would produce the OSP (answer request) layout + writeNetworkRF(iosp, data + 2U, true); } break; case TSBKO::ISP_SNDCP_CH_REQ: @@ -475,6 +522,13 @@ bool ControlSignaling::process(uint8_t* data, uint32_t len, std::unique_ptrgetService(); + if (m_telephoneInterconnect && (service == TSBKO::IOSP_TELE_INT_DIAL || service == TSBKO::ISP_TELE_INT_PSTN_REQ || + service == TSBKO::IOSP_TELE_INT_ANS)) { + RF_TO_WRITE_NET(isp); + } + writeRF_TSDU_ACK_FNE(srcId, isp->getService(), false, true); } break; @@ -872,6 +926,32 @@ bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& contr } } break; + case TSBKO::IOSP_TELE_INT_DIAL: + case TSBKO::ISP_TELE_INT_PSTN_REQ: + return true; // don't allow this to write to the air + case TSBKO::IOSP_TELE_INT_ANS: + { + if (!m_telephoneInterconnect) { + return true; // don't allow this to write to the air + } + + // validate the target RID + VALID_DSTID_NET(tsbk->toString(), dstId); + + // only alert units registered to this site + if (!m_p25->m_affiliations->isUnitReg(dstId)) { + return true; // don't allow this to write to the air + } + + IOSP_TELE_INT_ANS* iosp = static_cast(tsbk.get()); + if (m_verbose) { + LogInfoEx(LOG_NET, P25_TSDU_STR ", %s, digits = %s, dstId = %u", + tsbk->toString().c_str(), iosp->getDigits().c_str(), dstId); + } + + ::ActivityLog("P25", false, "telephone interconnect answer request to %u", dstId); + } + break; case TSBKO::IOSP_STS_UPDT: { // validate the source RID @@ -1295,6 +1375,7 @@ ControlSignaling::ControlSignaling(Control* p25, bool dumpTSBKData, bool debug, m_noStatusAck(false), m_noMessageAck(true), m_unitToUnitAvailCheck(true), + m_telephoneInterconnect(false), m_convFallbackPacketDelay(0U), m_convFallback(false), m_adjSiteUpdateTimer(1000U), diff --git a/src/host/p25/packet/ControlSignaling.h b/src/host/p25/packet/ControlSignaling.h index a7f19790..a3ff6313 100644 --- a/src/host/p25/packet/ControlSignaling.h +++ b/src/host/p25/packet/ControlSignaling.h @@ -189,6 +189,7 @@ namespace p25 bool m_noStatusAck; bool m_noMessageAck; bool m_unitToUnitAvailCheck; + bool m_telephoneInterconnect; uint8_t m_convFallbackPacketDelay; bool m_convFallback;