add telephone interconnect gateway peer flag (peer list, REST API, peered); route P25 telephone interconnect voice and signalling only between gateway peers and the peer the unit is registered to, and validate interconnect calls against the RID ACL instead of talkgroup rules;

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pull/133/head
majmongoose 1 month ago
parent 7e73b2ca71
commit 15deda0e4a

@ -25,11 +25,15 @@
# * JITTER ENABLED [OPTIONAL] - Flag indicating whether the adaptive jitter buffer is enabled.
# * JITTER MAX FRAMES [OPTIONAL] - Maximum buffer size in frames (range: 2-8 frames).
# * JITTER MAX WAIT [OPTIONAL] - Maximum wait time in microseconds (range: 10000-200000 us).
# * TELEPHONE INTERCONNECT [OPTIONAL] - Flag indicating the peer connection is a telephone interconnect gateway.
# Telephone interconnect requests and calls are only routed between interconnect
# gateway peers and the peer the subscriber unit is registered to.
#
# Entry Format: "Peer ID,Peer Password,Peer Replication (1 = Enabled / 0 = Disabled),Peer Alias (optional),Can Request Keys (1 = Enabled / 0 = Disabled),Can Issue Inhibit (1 = Enabled / 0 = Disabled),Has Call Priority (1 = Enabled / 0 = Disabled),Jitter Enabled (1 = Enabled / 0 = Disabled),Jitter Max Size, Jitter Max Wait<newline>"
# Entry Format: "Peer ID,Peer Password,Peer Replication (1 = Enabled / 0 = Disabled),Peer Alias (optional),Can Request Keys (1 = Enabled / 0 = Disabled),Can Issue Inhibit (1 = Enabled / 0 = Disabled),Has Call Priority (1 = Enabled / 0 = Disabled),Jitter Enabled (1 = Enabled / 0 = Disabled),Jitter Max Size, Jitter Max Wait,Telephone Interconnect (1 = Enabled / 0 = Disabled)<newline>"
# Examples:
#1234,,0,,1,0,0,0,4,40000,
#5678,MYSECUREPASSWORD,0,,0,0,0,0,4,40000,
#9876,MYSECUREPASSWORD,1,,0,0,0,0,4,40000,
#5432,MYSECUREPASSWORD,,Peer Alias 1,0,0,0,0,4,40000,
#1012,MYSECUREPASSWORD,1,Peer Alias 2,1,0,0,0,4,40000,
#2468,MYSECUREPASSWORD,0,Interconnect Gateway,0,0,0,0,4,40000,1,

@ -905,7 +905,8 @@ X-DVM-Auth-Token: {token}
"peerReplica": false,
"canRequestKeys": false,
"canIssueInhibit": false,
"hasCallPriority": false
"hasCallPriority": false,
"telephoneInterconnect": false
}
]
}
@ -919,6 +920,7 @@ X-DVM-Auth-Token: {token}
- `canRequestKeys`: Whether peer can request encryption keys
- `canIssueInhibit`: Whether peer can issue radio inhibit commands
- `hasCallPriority`: Whether peer has call priority (can preempt other calls)
- `telephoneInterconnect`: Whether peer is a telephone interconnect gateway
---
@ -943,7 +945,8 @@ Content-Type: application/json
"peerReplica": false,
"canRequestKeys": false,
"canIssueInhibit": false,
"hasCallPriority": false
"hasCallPriority": false,
"telephoneInterconnect": false
}
```
@ -955,6 +958,7 @@ Content-Type: application/json
- `canRequestKeys` (optional): Whether peer can request encryption keys (default: false)
- `canIssueInhibit` (optional): Whether peer can issue radio inhibit commands (default: false)
- `hasCallPriority` (optional): Whether peer has call priority (default: false)
- `telephoneInterconnect` (optional): Whether peer is a telephone interconnect gateway (default: false)
**Response (Success):**
```json
@ -991,7 +995,7 @@ or
"message": "peerReplica was not a valid boolean"
}
```
or similar validation errors for `canRequestKeys`, `canIssueInhibit`, or `hasCallPriority`
or similar validation errors for `canRequestKeys`, `canIssueInhibit`, `hasCallPriority`, or `telephoneInterconnect`
**Notes:**
- Changes are in-memory only until `/peer/commit` is called

@ -258,6 +258,11 @@ bool PeerListLookup::load()
if (parsed.size() >= 10)
jitterBufferMaxWait = (uint32_t)::atoi(parsed[9].c_str());
// parse telephone interconnect flag
bool telephoneInterconnect = false;
if (parsed.size() >= 11)
telephoneInterconnect = ::atoi(parsed[10].c_str()) == 1;
// parse optional password
std::string password = "";
if (parsed.size() >= 2)
@ -269,6 +274,7 @@ bool PeerListLookup::load()
entry.canRequestKeys(canRequestKeys);
entry.canIssueInhibit(canIssueInhibit);
entry.hasCallPriority(hasCallPriority);
entry.telephoneInterconnect(telephoneInterconnect);
entry.jitterBufferEnabled(jitterBufferEnabled);
entry.jitterBufferMaxSize(jitterBufferMaxSize);
entry.jitterBufferMaxWait(jitterBufferMaxWait);
@ -277,14 +283,15 @@ bool PeerListLookup::load()
// log depending on what was loaded
if (m_verbose) {
LogInfoEx(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s%s%s%s%s", id,
LogInfoEx(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s%s%s%s%s%s", id,
(!alias.empty() ? (" (" + alias + ")").c_str() : ""),
(!password.empty() ? "using unique peer password" : "using master password"),
(peerReplica) ? ", Replication Enabled" : "",
(canRequestKeys) ? ", Can Request Keys" : "",
(canIssueInhibit) ? ", Can Issue Inhibit" : "",
(hasCallPriority) ? ", Has Call Priority" : "",
(jitterBufferEnabled) ? ", Jitter Buffer Enabled" : "");
(jitterBufferEnabled) ? ", Jitter Buffer Enabled" : "",
(telephoneInterconnect) ? ", Telephone Interconnect" : "");
}
}
}
@ -397,7 +404,15 @@ bool PeerListLookup::save(bool quiet)
// add jitter buffer max wait time
uint32_t jitterBufferMaxWait = entry.second.jitterBufferMaxWait();
line += std::to_string(jitterBufferMaxWait);
line += std::to_string(jitterBufferMaxWait) + ",";
// add telephone interconnect flag
bool telephoneInterconnect = entry.second.telephoneInterconnect();
if (telephoneInterconnect) {
line += "1";
} else {
line += "0";
}
line += "\n";
file << line;

@ -54,6 +54,7 @@ namespace lookups
m_canRequestKeys(false),
m_canIssueInhibit(false),
m_hasCallPriority(false),
m_telephoneInterconnect(false),
m_jitterBufferEnabled(false),
m_jitterBufferMaxSize(4U),
m_jitterBufferMaxWait(40000U),
@ -77,6 +78,7 @@ namespace lookups
m_canRequestKeys(false),
m_canIssueInhibit(false),
m_hasCallPriority(false),
m_telephoneInterconnect(false),
m_jitterBufferEnabled(false),
m_jitterBufferMaxSize(4U),
m_jitterBufferMaxWait(40000U),
@ -99,6 +101,7 @@ namespace lookups
m_canRequestKeys = data.m_canRequestKeys;
m_canIssueInhibit = data.m_canIssueInhibit;
m_hasCallPriority = data.m_hasCallPriority;
m_telephoneInterconnect = data.m_telephoneInterconnect;
m_jitterBufferEnabled = data.m_jitterBufferEnabled;
m_jitterBufferMaxSize = data.m_jitterBufferMaxSize;
m_jitterBufferMaxWait = data.m_jitterBufferMaxWait;
@ -176,6 +179,10 @@ namespace lookups
* @brief Flag indicating if the peer has call transmit priority.
*/
DECLARE_PROPERTY_PLAIN(bool, hasCallPriority);
/**
* @brief Flag indicating if the peer is a telephone interconnect gateway.
*/
DECLARE_PROPERTY_PLAIN(bool, telephoneInterconnect);
/**
* @brief Jitter buffer enabled flag.

@ -5,6 +5,7 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023-2026 Bryan Biedenkapp, N2PLL
* Copyright (C) 2026 Charles Bricker, K3NOP
*
*/
#include "fne/Defines.h"
@ -601,6 +602,16 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId
else if (!fromUpstream)
LogInfoEx(LOG_MASTER, PRV_CALL_START_LOG);
}
else if (isTelIntTraffic(control, duid, nullptr)) {
if (!m_network->m_globalAff->isGranted(dstId))
m_network->m_globalAff->grantCh(dstId, srcId, ssrc, fne_lookups::GRANT_TIMER_TIMEOUT, false);
#define TEL_INT_CALL_START_LOG "P25, Telephone Interconnect Call Start, peer = %u, ssrc = %u, sysId = $%03X, netId = $%05X, srcId = %u, dstId = %u, streamId = %u, fromUpstream = %u", peerId, ssrc, sysId, netId, srcId, dstId, streamId, fromUpstream
if (m_network->m_logUpstreamCallStartEnd && fromUpstream)
LogInfoEx(LOG_PEER, TEL_INT_CALL_START_LOG);
else if (!fromUpstream)
LogInfoEx(LOG_MASTER, TEL_INT_CALL_START_LOG);
}
else {
if (!m_network->m_globalAff->isGranted(dstId))
m_network->m_globalAff->grantCh(dstId, srcId, ssrc, fne_lookups::GRANT_TIMER_TIMEOUT, true);
@ -650,6 +661,7 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId
bool noConnectedPeerRepeat = false;
bool privateCallInProgress = false;
bool telInt = isTelIntTraffic(control, duid, tsbk.get());
// is this a private call in-progress?
if (m_network->m_restrictPVCallToRegOnly) {
@ -721,6 +733,11 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId
continue;
}
// telephone interconnect traffic only flows between gateway peers and the peer the unit is registered to
if (telInt && !isTelIntPeerPermitted(ssrc, peer.first, conn, dstId)) {
continue;
}
if (m_network->m_restrictPVCallToRegOnly) {
// is this peer an upstream neighbor peer?
bool neighbor = false;
@ -1456,6 +1473,70 @@ bool TagP25Data::processTSDUToNeighbor(uint8_t* buffer, uint32_t srcPeerId, uint
return true;
}
/* Helper to determine if the P25 traffic is telephone interconnect traffic. */
bool TagP25Data::isTelIntTraffic(lc::LC& control, DUID::E duid, const lc::TSBK* tsbk)
{
if (duid == DUID::TSDU) {
if (tsbk == nullptr)
return false;
// Motorola SUs may send interconnect TSBKs with their MFId (see TSBKFactory)
if (tsbk->getMFId() != MFG_STANDARD && tsbk->getMFId() != MFG_MOT)
return false;
switch (tsbk->getLCO()) {
case TSBKO::IOSP_TELE_INT_DIAL:
case TSBKO::ISP_TELE_INT_PSTN_REQ:
case TSBKO::IOSP_TELE_INT_ANS:
return true;
case TSBKO::ISP_CAN_SRV_REQ:
return tsbk->getService() == TSBKO::IOSP_TELE_INT_DIAL || tsbk->getService() == TSBKO::ISP_TELE_INT_PSTN_REQ ||
tsbk->getService() == TSBKO::IOSP_TELE_INT_ANS;
default:
return false;
}
}
// a TSDU network header carries the TSBK opcode, the LCO is only meaningful for voice and terminators
if (duid == DUID::PDU)
return false;
return control.getLCO() == LCO::TEL_INT_VCH_USER && control.isStandardMFId();
}
/* Helper to determine if the peer is a telephone interconnect gateway. */
bool TagP25Data::isTelIntGateway(uint32_t peerId)
{
lookups::PeerId pid = m_network->m_peerListLookup->find(peerId);
return !pid.peerDefault() && pid.telephoneInterconnect();
}
/* Helper to determine if telephone interconnect traffic may be repeated to a peer. */
bool TagP25Data::isTelIntPeerPermitted(uint32_t srcPeerId, uint32_t dstPeerId, FNEPeerConnection* dstConn, uint32_t dstId)
{
// replica, SysView and neighbor FNE peers apply their own routing
if (dstConn != nullptr) {
if (dstConn->isReplica() || dstConn->peerClass() == PEER_CONN_CLASS_SYSVIEW || dstConn->peerClass() == PEER_CONN_CLASS_NEIGHBOR)
return true;
}
bool dstIsGateway = isTelIntGateway(dstPeerId);
// traffic from a site is only repeated to gateway peers
if (!isTelIntGateway(srcPeerId))
return dstIsGateway;
// traffic from a gateway is only repeated to the site the unit is registered to
if (dstIsGateway)
return false;
uint32_t regPeerId = m_network->findPeerUnitReg(dstId);
return regPeerId == 0U || regPeerId == dstPeerId;
}
/* Helper to determine if the peer is permitted for traffic. */
bool TagP25Data::isPeerPermitted(uint32_t peerId, lc::LC& control, DUID::E duid, uint32_t streamId, bool fromUpstream)
@ -1479,6 +1560,11 @@ bool TagP25Data::isPeerPermitted(uint32_t peerId, lc::LC& control, DUID::E duid,
return false;
}
// telephone interconnect calls are individual calls routed by isTelIntPeerPermitted()
if (duid != DUID::TSDU && isTelIntTraffic(control, duid, nullptr)) {
return true;
}
FNEPeerConnection* connection = nullptr; // bryanb: this is a possible null ref concurrency issue
// it is possible if the timing is just right to get a valid
// connection back initially, and then for it to be deleted
@ -1669,6 +1755,11 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const
// always validate a terminator if the source is valid
if (m_network->m_filterTerminators) {
if ((duid == DUID::TDU || duid == DUID::TDULC) && control.getDstId() != 0U) {
// is this a telephone interconnect call?
if (isTelIntTraffic(control, duid, nullptr)) {
return true;
}
// is this a private call?
auto it = std::find_if(m_statusPVCall.begin(), m_statusPVCall.end(), [&](StatusMapPair& x) {
if (x.second.dstId == control.getDstId()) {
@ -1737,8 +1828,9 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const
}
}
// is this a private call?
if ((control.getLCO() == LCO::PRIVATE) || privateCallInProgress) {
// is this a private or telephone interconnect call?
bool telIntCall = (duid != DUID::TSDU) && isTelIntTraffic(control, duid, nullptr);
if ((control.getLCO() == LCO::PRIVATE) || telIntCall || privateCallInProgress) {
// is the destination ID a blacklisted ID?
lookups::RadioId rid = m_network->m_ridLookup->find(control.getDstId());
if (!rid.radioDefault()) {

@ -5,6 +5,7 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (C) 2023-2026 Bryan Biedenkapp, N2PLL
* Copyright (C) 2026 Charles Bricker, K3NOP
*
*/
/**
@ -340,6 +341,32 @@ namespace network
*/
bool validate(uint32_t peerId, p25::lc::LC& control, P25DEF::DUID::E duid, const p25::lc::TSBK* tsbk, uint8_t frameType, uint32_t streamId);
/**
* @brief Helper to determine if the P25 traffic is telephone interconnect traffic.
* @param control Instance of p25::lc::LC.
* @param duid DUID.
* @param[in] tsbk Instance of p25::lc::TSBK.
* @returns bool True, if telephone interconnect traffic, otherwise false.
*/
bool isTelIntTraffic(p25::lc::LC& control, P25DEF::DUID::E duid, const p25::lc::TSBK* tsbk);
/**
* @brief Helper to determine if the peer is a telephone interconnect gateway.
* @param peerId Peer ID.
* @returns bool True, if the peer is a telephone interconnect gateway, otherwise false.
*/
bool isTelIntGateway(uint32_t peerId);
/**
* @brief Helper to determine if telephone interconnect traffic may be repeated to a peer. Traffic from a
* site is only repeated to gateway peers, and traffic from a gateway is only repeated to the peer the
* subscriber unit is registered to (or every site, if the registration is unknown).
* @param srcPeerId Originating Peer ID.
* @param dstPeerId Destination Peer ID.
* @param dstConn Instance of the FNEPeerConnection for the destination peer.
* @param dstId Subscriber unit radio ID.
* @returns bool True, if permitted, otherwise false.
*/
bool isTelIntPeerPermitted(uint32_t srcPeerId, uint32_t dstPeerId, FNEPeerConnection* dstConn, uint32_t dstId);
/**
* @brief Helper to write a grant packet.
* @param peerId Peer ID.

@ -1051,6 +1051,7 @@ void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply
bool canRequestKeys = entry.second.canRequestKeys();
bool canIssueInhibit = entry.second.canIssueInhibit();
bool hasCallPriority = entry.second.hasCallPriority();
bool telephoneInterconnect = entry.second.telephoneInterconnect();
peerObj["peerId"].set<uint32_t>(peerId);
peerObj["peerAlias"].set<std::string>(peerAlias);
peerObj["peerPassword"].set<bool>(peerPassword);
@ -1058,6 +1059,7 @@ void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply
peerObj["canRequestKeys"].set<bool>(canRequestKeys);
peerObj["canIssueInhibit"].set<bool>(canIssueInhibit);
peerObj["hasCallPriority"].set<bool>(hasCallPriority);
peerObj["telephoneInterconnect"].set<bool>(telephoneInterconnect);
peers.push_back(json::value(peerObj));
}
}
@ -1162,6 +1164,18 @@ void RESTAPI::restAPI_PutPeerAdd(const HTTPPayload& request, HTTPPayload& reply,
hasCallPriority = req["hasCallPriority"].get<bool>();
}
// Get telephoneInterconnect
bool telephoneInterconnect = false;
if (req.find("telephoneInterconnect") != req.end()) {
// Validate
if (!req["telephoneInterconnect"].is<bool>()) {
errorPayload(reply, "telephoneInterconnect was not a valid boolean");
return;
}
// Get
telephoneInterconnect = req["telephoneInterconnect"].get<bool>();
}
PeerId entry = PeerId(peerId, peerAlias, peerPassword, false);
// Set additional values
@ -1169,6 +1183,7 @@ void RESTAPI::restAPI_PutPeerAdd(const HTTPPayload& request, HTTPPayload& reply,
entry.canRequestKeys(canRequestKeys);
entry.canIssueInhibit(canIssueInhibit);
entry.hasCallPriority(hasCallPriority);
entry.telephoneInterconnect(telephoneInterconnect);
LogInfoEx(LOG_REST, "request to add peer ACL, peerId = %u", peerId);

@ -154,6 +154,7 @@ private:
FCheckBox m_canReqKeysEnabled{"Request Keys", &m_configGroup};
FCheckBox m_canInhibitEnabled{"Issue Inhibit", &m_configGroup};
FCheckBox m_callPriorityEnabled{"Call Priority", &m_configGroup};
FCheckBox m_telIntEnabled{"Interconnect", &m_configGroup};
FButtonGroup m_jitterGroup{"Adaptive Jitter Buffer", this};
FCheckBox m_jitterEnabled{"Enabled", &m_jitterGroup};
@ -271,7 +272,7 @@ private:
// configuration
{
m_configGroup.setGeometry(FPoint(39, 5), FSize(23, 6));
m_configGroup.setGeometry(FPoint(39, 5), FSize(23, 7));
m_peerReplicaEnabled.setGeometry(FPoint(2, 1), FSize(10, 1));
m_peerReplicaEnabled.setChecked(m_rule.peerReplica());
@ -296,6 +297,12 @@ private:
m_callPriorityEnabled.addCallback("toggled", [&]() {
m_rule.hasCallPriority(m_callPriorityEnabled.isChecked());
});
m_telIntEnabled.setGeometry(FPoint(2, 5), FSize(10, 1));
m_telIntEnabled.setChecked(m_rule.telephoneInterconnect());
m_telIntEnabled.addCallback("toggled", [&]() {
m_rule.telephoneInterconnect(m_telIntEnabled.isChecked());
});
}
// jitter buffer
@ -384,9 +391,10 @@ private:
bool canRequestKeys = m_rule.canRequestKeys();
bool canIssueInhibit = m_rule.canIssueInhibit();
bool hasCallPriority = m_rule.hasCallPriority();
bool telephoneInterconnect = m_rule.telephoneInterconnect();
bool jitterBufferEnabled = m_rule.jitterBufferEnabled();
::LogInfoEx(LOG_HOST, "Peer ALIAS: %s PEERID: %u REPLICA: %u CAN REQUEST KEYS: %u CAN ISSUE INHIBIT: %u HAS CALL PRIORITY: %u JITTER BUFFER ENABLED: %u", peerAlias.c_str(), peerId, peerReplica, canRequestKeys, canIssueInhibit, hasCallPriority, jitterBufferEnabled);
::LogInfoEx(LOG_HOST, "Peer ALIAS: %s PEERID: %u REPLICA: %u CAN REQUEST KEYS: %u CAN ISSUE INHIBIT: %u HAS CALL PRIORITY: %u TELEPHONE INTERCONNECT: %u JITTER BUFFER ENABLED: %u", peerAlias.c_str(), peerId, peerReplica, canRequestKeys, canIssueInhibit, hasCallPriority, telephoneInterconnect, jitterBufferEnabled);
}
/*
@ -457,6 +465,7 @@ private:
entry.canRequestKeys(m_rule.canRequestKeys());
entry.canIssueInhibit(m_rule.canIssueInhibit());
entry.hasCallPriority(m_rule.hasCallPriority());
entry.telephoneInterconnect(m_rule.telephoneInterconnect());
entry.jitterBufferEnabled(m_rule.jitterBufferEnabled());
entry.jitterBufferMaxSize(m_rule.jitterBufferMaxSize());
@ -498,6 +507,7 @@ private:
entry.canRequestKeys(m_rule.canRequestKeys());
entry.canIssueInhibit(m_rule.canIssueInhibit());
entry.hasCallPriority(m_rule.hasCallPriority());
entry.telephoneInterconnect(m_rule.telephoneInterconnect());
entry.jitterBufferEnabled(m_rule.jitterBufferEnabled());
entry.jitterBufferMaxSize(m_rule.jitterBufferMaxSize());

@ -312,6 +312,7 @@ TEST_CASE("FNE REST peer endpoints query, persist, and delete ACL entries", "[fn
add["canRequestKeys"] = json::value(true);
add["canIssueInhibit"] = json::value(true);
add["hasCallPriority"] = json::value(true);
add["telephoneInterconnect"] = json::value(true);
sendRequest(port, HTTP_PUT, FNE_PUT_PEER_ADD, add);
CHECK(readFileContents(aclFile.path) == initialContents);
@ -322,10 +323,12 @@ TEST_CASE("FNE REST peer endpoints query, persist, and delete ACL entries", "[fn
CHECK(peer.canRequestKeys());
CHECK(peer.canIssueInhibit());
CHECK(peer.hasCallPriority());
CHECK(peer.telephoneInterconnect());
json::object query = sendRequest(port, HTTP_GET, FNE_GET_PEER_LIST);
REQUIRE(query["peers"].get<json::array>().size() == 1U);
CHECK(query["peers"].get<json::array>()[0U].get<json::object>()["peerPassword"].get<bool>());
CHECK(query["peers"].get<json::array>()[0U].get<json::object>()["telephoneInterconnect"].get<bool>());
sendRequest(port, HTTP_GET, FNE_GET_PEER_COMMIT);
const std::string committedContents = readFileContents(aclFile.path);

Loading…
Cancel
Save

Powered by TurnKey Linux.