satellite: honor SATELLITE_FILTER on parent and satellite legs

Adds optional SATELLITE_FILTER in [GLOBAL] on the satellite side using
TgFilter grammar (exact, "24*" prefix, "2427-2438" range, comma-separated).

Flow:
  - SatelliteClient parses SATELLITE_FILTER at init and applies it to its
    own outbound (onLocalTalkerStart/Stop/Audio/Flush): events for TGs
    outside the filter are not forwarded to the parent.
  - After authenticating, the satellite sends the filter to the parent via
    MsgTrunkFilter (type 122, already defined in ReflectorMsg.h and
    reserved for this use).
  - SatelliteLink (parent side) dispatches MsgTrunkFilter and stores a
    TgFilter. Every parent->satellite send is gated by filterPassesTg();
    empty filter = pass-all (pre-existing behavior).

Backwards compatible: older satellites never send the message; older
parents silently ignore unknown message types. The patched parent keeps
forwarding all TGs until it receives a MsgTrunkFilter.

Fixes the bug where a satellite could not restrict the TGs it received
from its parent — prior to this change SatelliteLink explicitly relayed
ALL TGs bidirectionally regardless of any local filter.
This commit is contained in:
Jens DJ1JAY authored and Audric committed 2026-04-20 14:05:32 +02:00
1 parent ba5d03e491
commit 719aa3e37c
5 files changed
+91 -1

No files matched your search

+43
View File
@@ -62,6 +62,7 @@ void SatelliteLink::onParentTalkerStart(uint32_t tg,
const std::string& callsign)
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkTalkerStart(tg, callsign));
} /* SatelliteLink::onParentTalkerStart */
@@ -69,6 +70,7 @@ void SatelliteLink::onParentTalkerStart(uint32_t tg,
void SatelliteLink::onParentTalkerStop(uint32_t tg)
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkTalkerStop(tg));
} /* SatelliteLink::onParentTalkerStop */
@@ -77,6 +79,7 @@ void SatelliteLink::onParentAudio(uint32_t tg,
const std::vector<uint8_t>& audio)
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkAudio(tg, audio));
} /* SatelliteLink::onParentAudio */
@@ -84,6 +87,7 @@ void SatelliteLink::onParentAudio(uint32_t tg,
void SatelliteLink::onParentFlush(uint32_t tg)
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkFlush(tg));
} /* SatelliteLink::onParentFlush */
@@ -133,6 +137,9 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
break;
case MsgTrunkFilter::TYPE:
handleMsgTrunkFilter(ss);
break;
default:
geulog::warn("satellite", "Unknown message type=", header.type());
break;
@@ -295,3 +302,39 @@ void SatelliteLink::heartbeatTick(Async::Timer* t)
linkFailed(this);
}
} /* SatelliteLink::heartbeatTick */
void SatelliteLink::handleMsgTrunkFilter(std::istream& is)
{
MsgTrunkFilter msg;
if (!msg.unpack(is))
{
geulog::error("satellite", "Failed to unpack MsgTrunkFilter from '",
m_satellite_id, "'");
return;
}
if (msg.filter().empty())
{
// Empty filter = clear any previously set filter (allow all)
m_tg_filter = TgFilter();
geulog::info("satellite", "Satellite '", m_satellite_id,
"': TG filter cleared (all TGs forwarded)");
}
else
{
m_tg_filter = TgFilter::parse(msg.filter());
geulog::info("satellite", "Satellite '", m_satellite_id,
"': TG filter set: ", m_tg_filter.toString());
}
statusChanged(this);
} /* SatelliteLink::handleMsgTrunkFilter */
bool SatelliteLink::filterPassesTg(uint32_t tg) const
{
// Empty filter = no filtering = pass everything
if (m_tg_filter.empty()) return true;
return m_tg_filter.matches(tg);
} /* SatelliteLink::filterPassesTg */