refactor: rename MsgTrunk* -> MsgPeer*

The eight MsgTrunk* types flow over trunk, satellite, and twin links —
"Trunk" was a misleading prefix for what is actually a shared peer
protocol. Wire IDs (115-122) and field layouts are unchanged, so this
is wire-equivalent: a renamed reflector and an old reflector
interoperate identically.

Also renames docs/TRUNK_PROTOCOL.md -> docs/PEER_PROTOCOL.md.

Twin-only types MsgTwinExt* (123/124) stay as-is.
This commit is contained in:
Audric committed 2026-04-28 18:00:24 +02:00
1 parent 3d281e16d7
commit 18d92a2b11
17 files changed
+424 -422

No files matched your search

+1 -1
View File
@@ -521,7 +521,7 @@ The PTY path is set by `COMMAND_PTY` in `[GLOBAL]` (default
as a drop-in replacement for an existing SvxReflector installation as a drop-in replacement for an existing SvxReflector installation
- [`docs/DOCKER.md`](docs/DOCKER.md) — running GeuReflector in a Docker container - [`docs/DOCKER.md`](docs/DOCKER.md) — running GeuReflector in a Docker container
as a drop-in replacement for an existing SvxReflector installation as a drop-in replacement for an existing SvxReflector installation
- [`docs/TRUNK_PROTOCOL.md`](docs/TRUNK_PROTOCOL.md) — full wire protocol - [`docs/PEER_PROTOCOL.md`](docs/PEER_PROTOCOL.md) — full wire protocol
specification: message format, handshake sequence, talker arbitration specification: message format, handshake sequence, talker arbitration
tie-breaking, heartbeat, and the complete message type table tie-breaking, heartbeat, and the complete message type table
- [`docs/DEPLOYMENT_ITALY.md`](docs/DEPLOYMENT_ITALY.md) — complete national - [`docs/DEPLOYMENT_ITALY.md`](docs/DEPLOYMENT_ITALY.md) — complete national
+1 -1
View File
@@ -241,6 +241,6 @@ the `LOCAL_PREFIX` and `[TRUNK_x]` entries.
## Further reading ## Further reading
- [`docs/TRUNK_PROTOCOL.md`](TRUNK_PROTOCOL.md) — wire protocol specification - [`docs/PEER_PROTOCOL.md`](PEER_PROTOCOL.md) — wire protocol specification
- [`docs/DEPLOYMENT_ITALY.md`](DEPLOYMENT_ITALY.md) — full national deployment - [`docs/DEPLOYMENT_ITALY.md`](DEPLOYMENT_ITALY.md) — full national deployment
example with configuration for all regions example with configuration for all regions
@@ -1,4 +1,6 @@
# GeuReflector — Server-to-Server Trunk Protocol # GeuReflector — Server-to-Server Peer Protocol
> **Renamed in 2026-04 (wire-format unchanged).** Message types were previously called `MsgTrunk*`; they are now `MsgPeer*`. Wire IDs (115-122) and field layouts are identical — a renamed reflector and an old reflector interoperate identically.
## Overview ## Overview
@@ -18,7 +20,7 @@ authoritative home reflector (the one whose prefix matches); all other
reflectors are transparent proxies for that TG. reflectors are transparent proxies for that TG.
> **Important:** Both reflectors in a trunk link **must use the same `[TRUNK_x]` > **Important:** Both reflectors in a trunk link **must use the same `[TRUNK_x]`
> section name**. The section name is transmitted in the `MsgTrunkHello` > section name**. The section name is transmitted in the `MsgPeerHello`
> handshake and both sides must agree on it for the connection to be matched to > handshake and both sides must agree on it for the connection to be matched to
> the correct `TrunkLink` instance. The convention is to use sorted pair > the correct `TrunkLink` instance. The convention is to use sorted pair
> identifiers — for example, the link between reflector 1 and reflector 2 uses > identifiers — for example, the link between reflector 1 and reflector 2 uses
@@ -104,8 +106,8 @@ reflectors, the owner is also the only reflector that sees every non-owner's
traffic on that TG — so for every non-owner to hear every other, the owner traffic on that TG — so for every non-owner to hear every other, the owner
must fan out. must fan out.
When `TrunkLink::handleMsgTrunkTalkerStart` / `handleMsgTrunkTalkerStop` / When `TrunkLink::handleMsgPeerTalkerStart` / `handleMsgPeerTalkerStop` /
`handleMsgTrunkAudio` / `handleMsgTrunkFlush` runs on the reflector that `handleMsgPeerAudio` / `handleMsgPeerFlush` runs on the reflector that
**owns** the TG (`Reflector::isLocalTG(tg)`), after the existing local **owns** the TG (`Reflector::isLocalTG(tg)`), after the existing local
delivery the event is re-forwarded to every **other** trunk peer through the delivery the event is re-forwarded to every **other** trunk peer through the
same per-link filter (`isSharedTG` / `isClusterTG` / `isPeerInterestedTG`). same per-link filter (`isSharedTG` / `isClusterTG` / `isPeerInterestedTG`).
@@ -179,8 +181,8 @@ using different prefix checks appropriate to each direction:
to the peer. Additionally, `isPeerInterestedTG` matches TGs that the to the peer. Additionally, `isPeerInterestedTG` matches TGs that the
peer has previously sent traffic for, enabling the return path for peer has previously sent traffic for, enabling the return path for
bidirectional conversations (see below). bidirectional conversations (see below).
- **Receiving side:** `TrunkLink::handleMsgTrunkTalkerStart`, - **Receiving side:** `TrunkLink::handleMsgPeerTalkerStart`,
`handleMsgTrunkAudio`, and `handleMsgTrunkFlush` check `handleMsgPeerAudio`, and `handleMsgPeerFlush` check
`isOwnedTG(tg) || isClusterTG(tg)` before accepting. `isOwnedTG` matches `isOwnedTG(tg) || isClusterTG(tg)` before accepting. `isOwnedTG` matches
the TG against both the **local** prefix (TG belongs to us — a peer's client the TG against both the **local** prefix (TG belongs to us — a peer's client
is talking on one of our TGs) and the **remote** prefix (TG belongs to the is talking on one of our TGs) and the **remote** prefix (TG belongs to the
@@ -201,11 +203,11 @@ forward to B. But when B's client replies on that same TG, B sees it as a
local TG and has no reason to forward back to A. local TG and has no reason to forward back to A.
To enable the return path, each `TrunkLink` tracks **peer interest**: when To enable the return path, each `TrunkLink` tracks **peer interest**: when
a peer sends `MsgTrunkTalkerStart(tg)`, the receiving side records that the a peer sends `MsgPeerTalkerStart(tg)`, the receiving side records that the
peer has active clients on that TG. From that point, local talker activity peer has active clients on that TG. From that point, local talker activity
on the same TG is also forwarded to the peer via `isPeerInterestedTG`. on the same TG is also forwarded to the peer via `isPeerInterestedTG`.
Interest is refreshed on each `MsgTrunkAudio` received for the TG (keeping Interest is refreshed on each `MsgPeerAudio` received for the TG (keeping
it alive during long transmissions). It expires after 10 minutes of it alive during long transmissions). It expires after 10 minutes of
inactivity on that TG from the peer, and is cleared immediately on trunk inactivity on that TG from the peer, and is cleared immediately on trunk
disconnect. The interest map is per-link — disconnecting one peer does not disconnect. The interest map is per-link — disconnecting one peer does not
@@ -237,16 +239,16 @@ not ready, the inbound connection is used as fallback.
### Outbound connection ### Outbound connection
When a `TrunkLink` connects outbound to a peer, it immediately sends When a `TrunkLink` connects outbound to a peer, it immediately sends
`MsgTrunkHello`. The peer's trunk server accepts the connection, verifies the `MsgPeerHello`. The peer's trunk server accepts the connection, verifies the
HMAC-authenticated shared secret, matches it to the corresponding `TrunkLink`, HMAC-authenticated shared secret, matches it to the corresponding `TrunkLink`,
and sends its own `MsgTrunkHello` in response. and sends its own `MsgPeerHello` in response.
``` ```
Reflector A (prefix "1") Reflector B (prefix "2") Reflector A (prefix "1") Reflector B (prefix "2")
│──── TCP connect to B:5302 ──────────────────────────►│ │──── TCP connect to B:5302 ──────────────────────────►│
│──── MsgTrunkHello(id, prefix="1", priority, HMAC) ──►│ │──── MsgPeerHello(id, prefix="1", priority, HMAC) ──►│
│ B verifies HMAC, matches TrunkLink │ B verifies HMAC, matches TrunkLink
│◀─── MsgTrunkHello(id, prefix="2", priority, HMAC) ───│ │◀─── MsgPeerHello(id, prefix="2", priority, HMAC) ───│
│ (both sides ready) │ │ (both sides ready) │
``` ```
@@ -256,7 +258,7 @@ The trunk server (`Reflector::m_trunk_srv`) listens on the configured
`TRUNK_LISTEN_PORT` (default 5302). When a peer connects: `TRUNK_LISTEN_PORT` (default 5302). When a peer connects:
1. The connection enters a **pending** state with a 10-second hello timeout 1. The connection enters a **pending** state with a 10-second hello timeout
2. The server waits for a `MsgTrunkHello` frame 2. The server waits for a `MsgPeerHello` frame
3. The shared secret is verified via HMAC against each configured `TrunkLink` 3. The shared secret is verified via HMAC against each configured `TrunkLink`
4. On match, the connection is handed off to the corresponding `TrunkLink` 4. On match, the connection is handed off to the corresponding `TrunkLink`
5. The `TrunkLink` stores the inbound connection alongside any existing 5. The `TrunkLink` stores the inbound connection alongside any existing
@@ -282,7 +284,7 @@ If a second inbound connection arrives while one is already active, the new one
is rejected. Outbound reconnection is handled automatically by is rejected. Outbound reconnection is handled automatically by
`TcpPrioClient`. `TcpPrioClient`.
### `MsgTrunkHello` fields ### `MsgPeerHello` fields
- `id` — the config section name (e.g. `TRUNK_1_2`), used for logging and - `id` — the config section name (e.g. `TRUNK_1_2`), used for logging and
connection matching — both sides must use the same section name connection matching — both sides must use the same section name
@@ -301,15 +303,15 @@ When a local client starts transmitting on a TG owned by the peer:
Reflector A (owns prefix "1") Reflector B (owns prefix "2") Reflector A (owns prefix "1") Reflector B (owns prefix "2")
│ SM0ABC starts on TG 25 │ │ SM0ABC starts on TG 25 │
│ setTalkerForTG(25, SM0ABC) │ │ setTalkerForTG(25, SM0ABC) │
│──── MsgTrunkTalkerStart(25, "SM0ABC") ──►│ │──── MsgPeerTalkerStart(25, "SM0ABC") ──►│
│ setTrunkTalkerForTG(25, "SM0ABC") │ setTrunkTalkerForTG(25, "SM0ABC")
│ broadcast MsgTalkerStart(25, "SM0ABC") to B clients │ broadcast MsgTalkerStart(25, "SM0ABC") to B clients
│──── MsgTrunkAudio(25, <frame>) ─►│ │──── MsgPeerAudio(25, <frame>) ─►│
│ broadcast MsgUdpAudio to B TG25 clients │ broadcast MsgUdpAudio to B TG25 clients
│ (repeats for each audio frame) │ │ (repeats for each audio frame) │
│──── MsgTrunkFlush(25) ──────────►│ │──── MsgPeerFlush(25) ──────────►│
│ setTalkerForTG(25, null) │ │ setTalkerForTG(25, null) │
│──── MsgTrunkTalkerStop(25) ─────►│ │──── MsgPeerTalkerStop(25) ─────►│
│ clearTrunkTalkerForTG(25) │ clearTrunkTalkerForTG(25)
│ broadcast MsgTalkerStop(25, "SM0ABC") to B clients │ broadcast MsgTalkerStop(25, "SM0ABC") to B clients
│ broadcast MsgUdpFlushSamples to B TG25 clients │ broadcast MsgUdpFlushSamples to B TG25 clients
@@ -324,19 +326,19 @@ The reverse direction (B client talking on a TG owned by A) is symmetric.
Each reflector arbitrates talkers independently for its own clients. The trunk Each reflector arbitrates talkers independently for its own clients. The trunk
adds a second layer of arbitration for shared TGs. adds a second layer of arbitration for shared TGs.
**Normal case (one side talking at a time):** the first `MsgTrunkTalkerStart` **Normal case (one side talking at a time):** the first `MsgPeerTalkerStart`
to arrive locks the TG on the receiving side. Local clients on that side cannot to arrive locks the TG on the receiving side. Local clients on that side cannot
grab the talker slot while the trunk lock is held — their audio packets are grab the talker slot while the trunk lock is held — their audio packets are
silently dropped by the existing `talker != client` check in the reflector's silently dropped by the existing `talker != client` check in the reflector's
UDP handler. UDP handler.
**Simultaneous claim (both sides start at the same instant):** resolved using **Simultaneous claim (both sides start at the same instant):** resolved using
the `priority` nonce exchanged in `MsgTrunkHello`: the `priority` nonce exchanged in `MsgPeerHello`:
- The side with the **lower** priority value wins - The side with the **lower** priority value wins
- The losing side calls `setTalkerForTG(tg, nullptr)` to clear its local talker, - The losing side calls `setTalkerForTG(tg, nullptr)` to clear its local talker,
then calls `setTrunkTalkerForTG(tg, peer_callsign)` to accept the remote claim then calls `setTrunkTalkerForTG(tg, peer_callsign)` to accept the remote claim
- The losing side suppresses the spurious `MsgTrunkTalkerStop` that would - The losing side suppresses the spurious `MsgPeerTalkerStop` that would
otherwise be sent when the local talker is cleared (tracked via `m_yielded_tgs`) otherwise be sent when the local talker is cleared (tracked via `m_yielded_tgs`)
--- ---
@@ -362,7 +364,7 @@ interruption by local clients.
## Keepalive / Heartbeat ## Keepalive / Heartbeat
Both sides send `MsgTrunkHeartbeat` periodically to keep the TCP connection Both sides send `MsgPeerHeartbeat` periodically to keep the TCP connection
alive and detect peer disconnection: alive and detect peer disconnection:
- TX: sent when no other message has been sent for 10 timer ticks (10 s) - TX: sent when no other message has been sent for 10 timer ticks (10 s)
@@ -382,14 +384,14 @@ payload, packed using the `ASYNC_MSG_MEMBERS` macro.
| Type | Name | Fields | | Type | Name | Fields |
|------|-----------------------|--------------------------------------------------| |------|-----------------------|--------------------------------------------------|
| 115 | `MsgTrunkHello` | `string id`, `string local_prefix`, `uint32 priority`, `uint8[] nonce`, `uint8[] hmac`, `uint8 role` | | 115 | `MsgPeerHello` | `string id`, `string local_prefix`, `uint32 priority`, `uint8[] nonce`, `uint8[] hmac`, `uint8 role` |
| 116 | `MsgTrunkTalkerStart` | `uint32 tg`, `string callsign` | | 116 | `MsgPeerTalkerStart` | `uint32 tg`, `string callsign` |
| 117 | `MsgTrunkTalkerStop` | `uint32 tg` | | 117 | `MsgPeerTalkerStop` | `uint32 tg` |
| 118 | `MsgTrunkAudio` | `uint32 tg`, `uint8[] audio` | | 118 | `MsgPeerAudio` | `uint32 tg`, `uint8[] audio` |
| 119 | `MsgTrunkFlush` | `uint32 tg` | | 119 | `MsgPeerFlush` | `uint32 tg` |
| 120 | `MsgTrunkHeartbeat` | *(no fields)* | | 120 | `MsgPeerHeartbeat` | *(no fields)* |
| 121 | `MsgTrunkNodeList` | `string[] callsigns`, `uint32[] tgs`, `float[] lats`, `float[] lons`, `string[] qth_names`, `string[] status_blobs`, `string[] sat_ids` | | 121 | `MsgPeerNodeList` | `string[] callsigns`, `uint32[] tgs`, `float[] lats`, `float[] lons`, `string[] qth_names`, `string[] status_blobs`, `string[] sat_ids` |
| 122 | `MsgTrunkFilter` | `string filter` (shared-syntax TG filter: exact / `24*` / `10-20`, comma-separated) | | 122 | `MsgPeerFilter` | `string filter` (shared-syntax TG filter: exact / `24*` / `10-20`, comma-separated) |
Type numbers 115–120 are chosen to follow the last existing SvxReflector TCP Type numbers 115–120 are chosen to follow the last existing SvxReflector TCP
message type (114 = `MsgStartUdpEncryption`) without collision. Types 121–122 message type (114 = `MsgStartUdpEncryption`) without collision. Types 121–122
@@ -397,7 +399,7 @@ were added by the jayReflector integration (v1.1.0) and are optional —
older peers silently ignore unknown message types, preserving backward older peers silently ignore unknown message types, preserving backward
compatibility. compatibility.
`MsgTrunkNodeList` is emitted by the reflector on local client login, logout, `MsgPeerNodeList` is emitted by the reflector on local client login, logout,
or TG change, debounced to 500 ms, and broadcast to every trunk peer. Peers or TG change, debounced to 500 ms, and broadcast to every trunk peer. Peers
republish it via MQTT under `nodes/<peer_id>` so a central dashboard can see republish it via MQTT under `nodes/<peer_id>` so a central dashboard can see
who is connected to each reflector. who is connected to each reflector.
@@ -411,8 +413,8 @@ under `/status.trunks[<section>].nodes[i]`, MQTT `nodes/<peer_id>`, and
the `status` field of Redis hash `live:peer_node:<peer_id>:<callsign>`. the `status` field of Redis hash `live:peer_node:<peer_id>:<callsign>`.
The `isTalker` flag on each peer node is **not** carried in the blob (it The `isTalker` flag on each peer node is **not** carried in the blob (it
would be stale by the time it arrives); it is derived on the receive side would be stale by the time it arrives); it is derived on the receive side
from the live trunk-talker map maintained by `MsgTrunkTalkerStart` / from the live trunk-talker map maintained by `MsgPeerTalkerStart` /
`MsgTrunkTalkerStop`. `MsgPeerTalkerStop`.
The optional `sat_ids[i]` field tags each entry with the satellite that The optional `sat_ids[i]` field tags each entry with the satellite that
the client is actually attached to. Interpretation is **recipient-relative**: the client is actually attached to. Interpretation is **recipient-relative**:
@@ -456,8 +458,8 @@ physically lives. Re-broadcasts are debounced (500 ms) and triggered by:
local client login/logout/TG change, satellite hello completion, and local client login/logout/TG change, satellite hello completion, and
inbound satellite node-list updates. inbound satellite node-list updates.
`MsgTrunkFilter` is used by satellite links to advertise TG interest to the `MsgPeerFilter` is used by satellite links to advertise TG interest to the
parent. A satellite with `SATELLITE_FILTER` set sends one `MsgTrunkFilter` parent. A satellite with `SATELLITE_FILTER` set sends one `MsgPeerFilter`
right after authenticating; the parent stores the filter and skips forwarding right after authenticating; the parent stores the filter and skips forwarding
non-matching TGs to that satellite. Absent or empty filter means pass-all non-matching TGs to that satellite. Absent or empty filter means pass-all
(pre-existing behavior). Trunk peers do not emit it. (pre-existing behavior). Trunk peers do not emit it.
@@ -596,7 +598,7 @@ REMOTE_PREFIX=2
| File | Change | | File | Change |
|------|--------| |------|--------|
| `src/svxlink/reflector/ReflectorMsg.h` | Added `MsgTrunkHello`–`MsgTrunkHeartbeat` (types 115–120); `MsgTrunkHello` carries `local_prefix` string instead of TG list | | `src/svxlink/reflector/ReflectorMsg.h` | Added `MsgPeerHello`–`MsgPeerHeartbeat` (types 115–120); `MsgPeerHello` carries `local_prefix` string instead of TG list |
| `src/svxlink/reflector/TGHandler.h` | Added trunk talker map, 5 methods + snapshot accessor, `trunkTalkerUpdated` signal | | `src/svxlink/reflector/TGHandler.h` | Added trunk talker map, 5 methods + snapshot accessor, `trunkTalkerUpdated` signal |
| `src/svxlink/reflector/TGHandler.cpp` | Implemented trunk talker methods including `clearAllTrunkTalkers` | | `src/svxlink/reflector/TGHandler.cpp` | Implemented trunk talker methods including `clearAllTrunkTalkers` |
| `src/svxlink/reflector/Reflector.h` | Added `m_trunk_links`, `m_trunk_srv`, `initTrunkLinks()`, `initTrunkServer()`, `onTrunkTalkerUpdated()`, trunk inbound connection handling | | `src/svxlink/reflector/Reflector.h` | Added `m_trunk_links`, `m_trunk_srv`, `initTrunkLinks()`, `initTrunkServer()`, `onTrunkTalkerUpdated()`, trunk inbound connection handling |
+3 -3
View File
@@ -329,7 +329,7 @@ void MqttPublisher::publishFullStatus(const Json::Value& status)
static Json::Value nodeListToJson( static Json::Value nodeListToJson(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
Json::Value arr(Json::arrayValue); Json::Value arr(Json::arrayValue);
for (const auto& n : nodes) for (const auto& n : nodes)
@@ -356,7 +356,7 @@ static Json::Value nodeListToJson(
void MqttPublisher::publishLocalNodes( void MqttPublisher::publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
Json::StreamWriterBuilder wb; Json::StreamWriterBuilder wb;
wb["indentation"] = ""; wb["indentation"] = "";
@@ -366,7 +366,7 @@ void MqttPublisher::publishLocalNodes(
void MqttPublisher::publishPeerNodes(const std::string& peer_id, void MqttPublisher::publishPeerNodes(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
Json::StreamWriterBuilder wb; Json::StreamWriterBuilder wb;
wb["indentation"] = ""; wb["indentation"] = "";
+4 -4
View File
@@ -45,9 +45,9 @@ class MqttPublisher
// Node-list snapshots — published retained // Node-list snapshots — published retained
void publishLocalNodes( void publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
void publishPeerNodes(const std::string& peer_id, void publishPeerNodes(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
private: private:
Async::Config& m_cfg; Async::Config& m_cfg;
@@ -98,9 +98,9 @@ class MqttPublisher
void onRxUpdate(const std::string&, const Json::Value&) {} void onRxUpdate(const std::string&, const Json::Value&) {}
void publishFullStatus(const Json::Value&) {} void publishFullStatus(const Json::Value&) {}
void publishLocalNodes( void publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>&) {} const std::vector<MsgPeerNodeList::NodeEntry>&) {}
void publishPeerNodes(const std::string&, void publishPeerNodes(const std::string&,
const std::vector<MsgTrunkNodeList::NodeEntry>&) {} const std::vector<MsgPeerNodeList::NodeEntry>&) {}
}; };
#endif /* WITH_MQTT */ #endif /* WITH_MQTT */
+17 -17
View File
@@ -2428,7 +2428,7 @@ void Reflector::trunkClientConnected(Async::FramedTcpConnection* con)
m_trunk_pending_cons[con] = timer; m_trunk_pending_cons[con] = timer;
// Use a limited frame size — only a hello message is expected. // Use a limited frame size — only a hello message is expected.
// MsgTrunkHello contains strings + HMAC, so needs more than PREAUTH (64). // MsgPeerHello contains strings + HMAC, so needs more than PREAUTH (64).
// Cap at SSL_SETUP size (4096) which is plenty for a hello. // Cap at SSL_SETUP size (4096) which is plenty for a hello.
con->setMaxFrameSize(ReflectorMsg::MAX_SSL_SETUP_FRAME_SIZE); con->setMaxFrameSize(ReflectorMsg::MAX_SSL_SETUP_FRAME_SIZE);
con->frameReceived.connect( con->frameReceived.connect(
@@ -2492,18 +2492,18 @@ void Reflector::trunkPendingFrameReceived(Async::FramedTcpConnection* con,
return; return;
} }
if (header.type() != MsgTrunkHello::TYPE) if (header.type() != MsgPeerHello::TYPE)
{ {
geulog::warn("trunk", "TRUNK inbound: expected MsgTrunkHello, got type=", geulog::warn("trunk", "TRUNK inbound: expected MsgPeerHello, got type=",
header.type()); header.type());
rejectPending(); rejectPending();
return; return;
} }
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(ss)) if (!msg.unpack(ss))
{ {
geulog::error("trunk", "TRUNK inbound: failed to unpack MsgTrunkHello"); geulog::error("trunk", "TRUNK inbound: failed to unpack MsgPeerHello");
rejectPending(); rejectPending();
return; return;
} }
@@ -3243,12 +3243,12 @@ void Reflector::scheduleNodeListUpdate(void)
void Reflector::sendNodeListToAllPeers(void) void Reflector::sendNodeListToAllPeers(void)
{ {
// 1. Local clients — sat_id stays empty (recipient-relative: "on me"). // 1. Local clients — sat_id stays empty (recipient-relative: "on me").
std::vector<MsgTrunkNodeList::NodeEntry> local_nodes; std::vector<MsgPeerNodeList::NodeEntry> local_nodes;
for (const auto& kv : m_client_con_map) for (const auto& kv : m_client_con_map)
{ {
ReflectorClient* c = kv.second; ReflectorClient* c = kv.second;
if (c->callsign().empty()) continue; if (c->callsign().empty()) continue;
MsgTrunkNodeList::NodeEntry e; MsgPeerNodeList::NodeEntry e;
e.callsign = c->callsign(); e.callsign = c->callsign();
e.tg = c->currentTG(); e.tg = c->currentTG();
// Attach the rich per-client status blob so peers can render partner // Attach the rich per-client status blob so peers can render partner
@@ -3278,7 +3278,7 @@ void Reflector::sendNodeListToAllPeers(void)
// 2. Combined view = local + every connected satellite's stamped roster. // 2. Combined view = local + every connected satellite's stamped roster.
// Each sat-supplied entry already carries sat_id == its satelliteId. // Each sat-supplied entry already carries sat_id == its satelliteId.
std::vector<MsgTrunkNodeList::NodeEntry> combined = local_nodes; std::vector<MsgPeerNodeList::NodeEntry> combined = local_nodes;
for (const auto& kv : m_satellite_con_map) for (const auto& kv : m_satellite_con_map)
{ {
const auto& sat_nodes = kv.second->partnerNodes(); const auto& sat_nodes = kv.second->partnerNodes();
@@ -3306,7 +3306,7 @@ void Reflector::sendNodeListToAllPeers(void)
SatelliteLink* link = kv.second; SatelliteLink* link = kv.second;
const std::string& this_sat_id = link->satelliteId(); const std::string& this_sat_id = link->satelliteId();
std::vector<MsgTrunkNodeList::NodeEntry> for_this_sat; std::vector<MsgPeerNodeList::NodeEntry> for_this_sat;
for_this_sat.reserve(combined.size()); for_this_sat.reserve(combined.size());
for (const auto& n : combined) for (const auto& n : combined)
{ {
@@ -3325,7 +3325,7 @@ void Reflector::sendNodeListToAllPeers(void)
} }
// 6. MQTT — keep scope to parent-local clients (sat-supplied entries // 6. MQTT — keep scope to parent-local clients (sat-supplied entries
// already get a publish via SatelliteLink::handleMsgTrunkNodeList // already get a publish via SatelliteLink::handleMsgPeerNodeList
// calling onPeerNodeList → MqttPublisher::publishPeerNodes). // calling onPeerNodeList → MqttPublisher::publishPeerNodes).
if (m_mqtt != nullptr) if (m_mqtt != nullptr)
{ {
@@ -3335,7 +3335,7 @@ void Reflector::sendNodeListToAllPeers(void)
void Reflector::onPeerNodeList(const std::string& peer_id, void Reflector::onPeerNodeList(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
if (m_mqtt != nullptr) if (m_mqtt != nullptr)
{ {
@@ -4374,26 +4374,26 @@ void Reflector::twinPendingFrameReceived(Async::FramedTcpConnection* con,
return; return;
} }
if (header.type() != MsgTrunkHello::TYPE) if (header.type() != MsgPeerHello::TYPE)
{ {
geulog::warn("twin", "TWIN inbound: expected MsgTrunkHello, got type=", geulog::warn("twin", "TWIN inbound: expected MsgPeerHello, got type=",
header.type()); header.type());
rejectPending(); rejectPending();
return; return;
} }
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(ss)) if (!msg.unpack(ss))
{ {
geulog::error("twin", "TWIN inbound: failed to unpack MsgTrunkHello"); geulog::error("twin", "TWIN inbound: failed to unpack MsgPeerHello");
rejectPending(); rejectPending();
return; return;
} }
if (msg.role() != MsgTrunkHello::ROLE_TWIN) if (msg.role() != MsgPeerHello::ROLE_TWIN)
{ {
geulog::error("twin", "TWIN inbound: peer sent role=", int(msg.role()), geulog::error("twin", "TWIN inbound: peer sent role=", int(msg.role()),
", expected ROLE_TWIN (", int(MsgTrunkHello::ROLE_TWIN), ", expected ROLE_TWIN (", int(MsgPeerHello::ROLE_TWIN),
")"); ")");
rejectPending(); rejectPending();
return; return;
+3 -3
View File
@@ -308,7 +308,7 @@ class Reflector : public sigc::trackable
void scheduleNodeListUpdate(void); void scheduleNodeListUpdate(void);
// Called by TrunkLink when a peer sends us its node list. // Called by TrunkLink when a peer sends us its node list.
void onPeerNodeList(const std::string& peer_id, void onPeerNodeList(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
protected: protected:
@@ -370,7 +370,7 @@ class Reflector : public sigc::trackable
static const size_t TRUNK_MAX_PENDING_CONS = 5; static const size_t TRUNK_MAX_PENDING_CONS = 5;
FramedTcpServer* m_trunk_srv = nullptr; FramedTcpServer* m_trunk_srv = nullptr;
// Inbound trunk connections waiting for MsgTrunkHello identification // Inbound trunk connections waiting for MsgPeerHello identification
std::map<Async::FramedTcpConnection*, Async::Timer*> m_trunk_pending_cons; std::map<Async::FramedTcpConnection*, Async::Timer*> m_trunk_pending_cons;
// Handed-off inbound trunk connections mapped to their TrunkLink // Handed-off inbound trunk connections mapped to their TrunkLink
std::map<Async::FramedTcpConnection*, TrunkLink*> m_trunk_inbound_map; std::map<Async::FramedTcpConnection*, TrunkLink*> m_trunk_inbound_map;
@@ -379,7 +379,7 @@ class Reflector : public sigc::trackable
TwinLink* m_twin_link = nullptr; TwinLink* m_twin_link = nullptr;
Async::TcpServer<Async::FramedTcpConnection>* m_twin_srv = nullptr; Async::TcpServer<Async::FramedTcpConnection>* m_twin_srv = nullptr;
uint16_t m_twin_listen_port = 5304; uint16_t m_twin_listen_port = 5304;
// Pending inbound twin connections awaiting MsgTrunkHello // Pending inbound twin connections awaiting MsgPeerHello
std::map<Async::FramedTcpConnection*, Async::Timer*> m_twin_pending_cons; std::map<Async::FramedTcpConnection*, Async::Timer*> m_twin_pending_cons;
// Satellite support // Satellite support
+47 -47
View File
@@ -1399,19 +1399,19 @@ class MsgStartUdpEncryption : public ReflectorMsgBase<114>
}; /* MsgStartUdpEncryption */ }; /* MsgStartUdpEncryption */
/***************************** Trunk Messages *****************************/ /***************************** Peer Messages *****************************/
/** /**
@brief Trunk handshake message @brief Peer handshake message
@date 2026-03-20 @date 2026-03-20
Sent by both sides immediately after TCP connection is established. Exchanges Sent by both sides immediately after TCP connection is established. Exchanges
the local trunk ID, this side's local TG prefix (the digit string that all TGs the local peer ID, this side's local TG prefix (the digit string that all TGs
owned by this reflector start with, e.g. "1" means TGs 1, 10, 100, 1000 ...), owned by this reflector start with, e.g. "1" means TGs 1, 10, 100, 1000 ...),
and a random priority nonce used for tie-breaking when both sides claim the and a random priority nonce used for tie-breaking when both sides claim the
same TG simultaneously (lower priority value defers to the peer). same TG simultaneously (lower priority value defers to the peer).
*/ */
class MsgTrunkHello : public ReflectorMsgBase<115> class MsgPeerHello : public ReflectorMsgBase<115>
{ {
public: public:
static const size_t NONCE_LEN = 20; static const size_t NONCE_LEN = 20;
@@ -1420,7 +1420,7 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
static const uint8_t ROLE_SATELLITE = 1; static const uint8_t ROLE_SATELLITE = 1;
static const uint8_t ROLE_TWIN = 2; // HA-pair partner static const uint8_t ROLE_TWIN = 2; // HA-pair partner
MsgTrunkHello(void) : m_priority(0), m_role(ROLE_PEER) {} MsgPeerHello(void) : m_priority(0), m_role(ROLE_PEER) {}
/** /**
* @brief Constructor that generates a nonce and computes HMAC * @brief Constructor that generates a nonce and computes HMAC
@@ -1430,7 +1430,7 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
* @param secret Shared secret for HMAC authentication * @param secret Shared secret for HMAC authentication
* @param role ROLE_PEER (default) or ROLE_SATELLITE * @param role ROLE_PEER (default) or ROLE_SATELLITE
*/ */
MsgTrunkHello(const std::string& id, MsgPeerHello(const std::string& id,
const std::string& local_prefix, const std::string& local_prefix,
uint32_t priority, uint32_t priority,
const std::string& secret, const std::string& secret,
@@ -1441,13 +1441,13 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
int rc = RAND_bytes(&m_nonce.front(), NONCE_LEN); int rc = RAND_bytes(&m_nonce.front(), NONCE_LEN);
if (rc != 1) if (rc != 1)
{ {
geulog::warn("trunk", "RAND_bytes failed in MsgTrunkHello"); geulog::warn("trunk", "RAND_bytes failed in MsgPeerHello");
m_nonce.clear(); m_nonce.clear();
return; return;
} }
if (!calcHMAC(m_digest, secret, m_nonce.data(), m_nonce.size())) if (!calcHMAC(m_digest, secret, m_nonce.data(), m_nonce.size()))
{ {
geulog::error("trunk", "HMAC calculation failed in MsgTrunkHello"); geulog::error("trunk", "HMAC calculation failed in MsgPeerHello");
} }
} }
@@ -1498,21 +1498,21 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
ok = ok && dgst.sign(hmac, data, len); ok = ok && dgst.sign(hmac, data, len);
return ok; return ok;
} }
}; /* MsgTrunkHello */ }; /* MsgPeerHello */
/** /**
@brief Trunk talker start message @brief Peer talker start message
@date 2026-03-20 @date 2026-03-20
Sent when a local client starts talking on a shared TG. The receiving reflector Sent when a local client starts talking on a shared TG. The receiving reflector
locks that TG to the trunk so its own clients cannot pre-empt the remote talker. locks that TG to the trunk so its own clients cannot pre-empt the remote talker.
*/ */
class MsgTrunkTalkerStart : public ReflectorMsgBase<116> class MsgPeerTalkerStart : public ReflectorMsgBase<116>
{ {
public: public:
MsgTrunkTalkerStart(void) : m_tg(0) {} MsgPeerTalkerStart(void) : m_tg(0) {}
MsgTrunkTalkerStart(uint32_t tg, const std::string& callsign) MsgPeerTalkerStart(uint32_t tg, const std::string& callsign)
: m_tg(tg), m_callsign(callsign) {} : m_tg(tg), m_callsign(callsign) {}
uint32_t tg(void) const { return m_tg; } uint32_t tg(void) const { return m_tg; }
const std::string& callsign(void) const { return m_callsign; } const std::string& callsign(void) const { return m_callsign; }
@@ -1520,41 +1520,41 @@ class MsgTrunkTalkerStart : public ReflectorMsgBase<116>
private: private:
uint32_t m_tg; uint32_t m_tg;
std::string m_callsign; std::string m_callsign;
}; /* MsgTrunkTalkerStart */ }; /* MsgPeerTalkerStart */
/** /**
@brief Trunk talker stop message @brief Peer talker stop message
@date 2026-03-20 @date 2026-03-20
Sent when the active talker on a shared TG releases the channel. The receiving Sent when the active talker on a shared TG releases the channel. The receiving
reflector clears the trunk lock on that TG and broadcasts a flush to its clients. reflector clears the peer lock on that TG and broadcasts a flush to its clients.
*/ */
class MsgTrunkTalkerStop : public ReflectorMsgBase<117> class MsgPeerTalkerStop : public ReflectorMsgBase<117>
{ {
public: public:
MsgTrunkTalkerStop(void) : m_tg(0) {} MsgPeerTalkerStop(void) : m_tg(0) {}
MsgTrunkTalkerStop(uint32_t tg) : m_tg(tg) {} MsgPeerTalkerStop(uint32_t tg) : m_tg(tg) {}
uint32_t tg(void) const { return m_tg; } uint32_t tg(void) const { return m_tg; }
ASYNC_MSG_MEMBERS(m_tg) ASYNC_MSG_MEMBERS(m_tg)
private: private:
uint32_t m_tg; uint32_t m_tg;
}; /* MsgTrunkTalkerStop */ }; /* MsgPeerTalkerStop */
/** /**
@brief Trunk audio message @brief Peer audio message
@date 2026-03-20 @date 2026-03-20
Carries a single encoded audio frame for a shared TG over the trunk TCP Carries a single encoded audio frame for a shared TG over the peer TCP
connection. The receiving reflector broadcasts it to all local clients connection. The receiving reflector broadcasts it to all local clients
subscribed to that TG. subscribed to that TG.
*/ */
class MsgTrunkAudio : public ReflectorMsgBase<118> class MsgPeerAudio : public ReflectorMsgBase<118>
{ {
public: public:
MsgTrunkAudio(void) : m_tg(0) {} MsgPeerAudio(void) : m_tg(0) {}
MsgTrunkAudio(uint32_t tg, const std::vector<uint8_t>& audio) MsgPeerAudio(uint32_t tg, const std::vector<uint8_t>& audio)
: m_tg(tg), m_audio(audio) {} : m_tg(tg), m_audio(audio) {}
uint32_t tg(void) const { return m_tg; } uint32_t tg(void) const { return m_tg; }
const std::vector<uint8_t>& audio(void) const { return m_audio; } const std::vector<uint8_t>& audio(void) const { return m_audio; }
@@ -1562,40 +1562,40 @@ class MsgTrunkAudio : public ReflectorMsgBase<118>
private: private:
uint32_t m_tg; uint32_t m_tg;
std::vector<uint8_t> m_audio; std::vector<uint8_t> m_audio;
}; /* MsgTrunkAudio */ }; /* MsgPeerAudio */
/** /**
@brief Trunk flush message @brief Peer flush message
@date 2026-03-20 @date 2026-03-20
Sent after the last audio frame of a transmission to signal end-of-audio on Sent after the last audio frame of a transmission to signal end-of-audio on
a shared TG. Triggers MsgUdpFlushSamples broadcast on the receiving side. a shared TG. Triggers MsgUdpFlushSamples broadcast on the receiving side.
*/ */
class MsgTrunkFlush : public ReflectorMsgBase<119> class MsgPeerFlush : public ReflectorMsgBase<119>
{ {
public: public:
MsgTrunkFlush(void) : m_tg(0) {} MsgPeerFlush(void) : m_tg(0) {}
MsgTrunkFlush(uint32_t tg) : m_tg(tg) {} MsgPeerFlush(uint32_t tg) : m_tg(tg) {}
uint32_t tg(void) const { return m_tg; } uint32_t tg(void) const { return m_tg; }
ASYNC_MSG_MEMBERS(m_tg) ASYNC_MSG_MEMBERS(m_tg)
private: private:
uint32_t m_tg; uint32_t m_tg;
}; /* MsgTrunkFlush */ }; /* MsgPeerFlush */
/** /**
@brief Trunk heartbeat message @brief Peer heartbeat message
@date 2026-03-20 @date 2026-03-20
Sent periodically in both directions to keep the TCP connection alive and Sent periodically in both directions to keep the TCP connection alive and
detect peer disconnection. detect peer disconnection.
*/ */
class MsgTrunkHeartbeat : public ReflectorMsgBase<120> class MsgPeerHeartbeat : public ReflectorMsgBase<120>
{ {
public: public:
ASYNC_MSG_NO_MEMBERS ASYNC_MSG_NO_MEMBERS
}; /* MsgTrunkHeartbeat */ }; /* MsgPeerHeartbeat */
/***************************** UDP Messages *****************************/ /***************************** UDP Messages *****************************/
@@ -1822,7 +1822,7 @@ class MsgUdpAudio : public ReflectorUdpMsgBase<101>
/** /**
@brief Trunk node list message (jayReflector extension, type 121) @brief Peer node list message (jayReflector extension, type 121)
Sent by a reflector to its trunk peer whenever its local client list changes Sent by a reflector to its trunk peer whenever its local client list changes
(login, logout, TG change). The receiving peer can publish it via its own (login, logout, TG change). The receiving peer can publish it via its own
@@ -1848,7 +1848,7 @@ m_status_blobs, then to add m_sat_ids. Each extension is a hard
lockstep bump because the unpack expects an exact vector count. All lockstep bump because the unpack expects an exact vector count. All
peers in a mesh must be upgraded together. peers in a mesh must be upgraded together.
*/ */
class MsgTrunkNodeList : public ReflectorMsgBase<121> class MsgPeerNodeList : public ReflectorMsgBase<121>
{ {
public: public:
struct NodeEntry struct NodeEntry
@@ -1865,8 +1865,8 @@ class MsgTrunkNodeList : public ReflectorMsgBase<121>
// the sender that this client lives on // the sender that this client lives on
}; };
MsgTrunkNodeList(void) {} MsgPeerNodeList(void) {}
explicit MsgTrunkNodeList(const std::vector<NodeEntry>& nodes) explicit MsgPeerNodeList(const std::vector<NodeEntry>& nodes)
{ {
Json::StreamWriterBuilder wb; Json::StreamWriterBuilder wb;
wb["indentation"] = ""; wb["indentation"] = "";
@@ -1929,22 +1929,22 @@ class MsgTrunkNodeList : public ReflectorMsgBase<121>
std::vector<std::string> m_qth_names; std::vector<std::string> m_qth_names;
std::vector<std::string> m_status_blobs; std::vector<std::string> m_status_blobs;
std::vector<std::string> m_sat_ids; std::vector<std::string> m_sat_ids;
}; /* MsgTrunkNodeList */ }; /* MsgPeerNodeList */
/** /**
@brief Trunk filter advertisement (jayReflector extension, type 122) @brief Peer filter advertisement (jayReflector extension, type 122)
Optional message sent (typically by a satellite after Hello) to tell the Optional message sent (typically by a satellite after Hello) to tell the
parent which TGs it wants to receive. Filter syntax matches TgFilter parent which TGs it wants to receive. Filter syntax matches TgFilter
(exact / "24*" prefix / "10-20" range, comma-separated). Older peers (exact / "24*" prefix / "10-20" range, comma-separated). Older peers
silently ignore unknown message types. silently ignore unknown message types.
*/ */
class MsgTrunkFilter : public ReflectorMsgBase<122> class MsgPeerFilter : public ReflectorMsgBase<122>
{ {
public: public:
MsgTrunkFilter(void) {} MsgPeerFilter(void) {}
explicit MsgTrunkFilter(const std::string& filter) explicit MsgPeerFilter(const std::string& filter)
: m_filter(filter) {} : m_filter(filter) {}
const std::string& filter(void) const { return m_filter; } const std::string& filter(void) const { return m_filter; }
@@ -1953,14 +1953,14 @@ class MsgTrunkFilter : public ReflectorMsgBase<122>
private: private:
std::string m_filter; std::string m_filter;
}; /* MsgTrunkFilter */ }; /* MsgPeerFilter */
/** /**
* @brief Twin-link message: mirror an external trunk's talker-start * @brief Twin-link message: mirror an external peer's talker-start
* *
* Sent over the [TWIN] link when this reflector receives a * Sent over the [TWIN] link when this reflector receives a
* MsgTrunkTalkerStart from one of its external trunk peers, so that the * MsgPeerTalkerStart from one of its external peer reflectors, so that the
* partner twin can update its own TGHandler state and block local clients * partner twin can update its own TGHandler state and block local clients
* from keying up the TG. * from keying up the TG.
*/ */
@@ -1986,7 +1986,7 @@ class MsgTwinExtTalkerStart : public ReflectorMsgBase<123>
/** /**
* @brief Twin-link message: mirror an external trunk's talker-stop * @brief Twin-link message: mirror an external peer's talker-stop
*/ */
class MsgTwinExtTalkerStop : public ReflectorMsgBase<124> class MsgTwinExtTalkerStop : public ReflectorMsgBase<124>
{ {
+52 -52
View File
@@ -159,7 +159,7 @@ void SatelliteClient::onLocalTalkerStart(uint32_t tg,
{ {
if (!m_con.isConnected() || !m_hello_received) return; if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return; if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkTalkerStart(tg, callsign)); sendMsg(MsgPeerTalkerStart(tg, callsign));
} /* SatelliteClient::onLocalTalkerStart */ } /* SatelliteClient::onLocalTalkerStart */
@@ -167,7 +167,7 @@ void SatelliteClient::onLocalTalkerStop(uint32_t tg)
{ {
if (!m_con.isConnected() || !m_hello_received) return; if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return; if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkTalkerStop(tg)); sendMsg(MsgPeerTalkerStop(tg));
} /* SatelliteClient::onLocalTalkerStop */ } /* SatelliteClient::onLocalTalkerStop */
@@ -176,7 +176,7 @@ void SatelliteClient::onLocalAudio(uint32_t tg,
{ {
if (!m_con.isConnected() || !m_hello_received) return; if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return; if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkAudio(tg, audio)); sendMsg(MsgPeerAudio(tg, audio));
} /* SatelliteClient::onLocalAudio */ } /* SatelliteClient::onLocalAudio */
@@ -184,7 +184,7 @@ void SatelliteClient::onLocalFlush(uint32_t tg)
{ {
if (!m_con.isConnected() || !m_hello_received) return; if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return; if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkFlush(tg)); sendMsg(MsgPeerFlush(tg));
} /* SatelliteClient::onLocalFlush */ } /* SatelliteClient::onLocalFlush */
@@ -197,8 +197,8 @@ void SatelliteClient::onConnected(void)
m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET; m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET;
m_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET; m_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET;
sendMsg(MsgTrunkHello(m_satellite_id, "", m_priority, m_secret, sendMsg(MsgPeerHello(m_satellite_id, "", m_priority, m_secret,
MsgTrunkHello::ROLE_SATELLITE)); MsgPeerHello::ROLE_SATELLITE));
m_heartbeat_timer.setEnable(true); m_heartbeat_timer.setEnable(true);
} /* SatelliteClient::onConnected */ } /* SatelliteClient::onConnected */
@@ -219,7 +219,7 @@ void SatelliteClient::onDisconnected(TcpConnection* con,
// Tombstone-clear Redis live:peer_node:<parent_id>:* and let MQTT // Tombstone-clear Redis live:peer_node:<parent_id>:* and let MQTT
// emit an empty list so consumers see the partner roster drop. // emit an empty list so consumers see the partner roster drop.
m_reflector->onPeerNodeList(m_parent_id, m_reflector->onPeerNodeList(m_parent_id,
std::vector<MsgTrunkNodeList::NodeEntry>{}); std::vector<MsgPeerNodeList::NodeEntry>{});
m_parent_nodes.clear(); m_parent_nodes.clear();
} }
} /* SatelliteClient::onDisconnected */ } /* SatelliteClient::onDisconnected */
@@ -240,8 +240,8 @@ void SatelliteClient::onFrameReceived(FramedTcpConnection* con,
} }
if (!m_hello_received && if (!m_hello_received &&
header.type() != MsgTrunkHello::TYPE && header.type() != MsgPeerHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE) header.type() != MsgPeerHeartbeat::TYPE)
{ {
return; return;
} }
@@ -250,26 +250,26 @@ void SatelliteClient::onFrameReceived(FramedTcpConnection* con,
switch (header.type()) switch (header.type())
{ {
case MsgTrunkHeartbeat::TYPE: case MsgPeerHeartbeat::TYPE:
handleMsgTrunkHeartbeat(); handleMsgPeerHeartbeat();
break; break;
case MsgTrunkHello::TYPE: case MsgPeerHello::TYPE:
handleMsgTrunkHello(ss); handleMsgPeerHello(ss);
break; break;
case MsgTrunkTalkerStart::TYPE: case MsgPeerTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss); handleMsgPeerTalkerStart(ss);
break; break;
case MsgTrunkTalkerStop::TYPE: case MsgPeerTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss); handleMsgPeerTalkerStop(ss);
break; break;
case MsgTrunkAudio::TYPE: case MsgPeerAudio::TYPE:
handleMsgTrunkAudio(ss); handleMsgPeerAudio(ss);
break; break;
case MsgTrunkFlush::TYPE: case MsgPeerFlush::TYPE:
handleMsgTrunkFlush(ss); handleMsgPeerFlush(ss);
break; break;
case MsgTrunkNodeList::TYPE: case MsgPeerNodeList::TYPE:
handleMsgTrunkNodeList(ss); handleMsgPeerNodeList(ss);
break; break;
default: default:
break; break;
@@ -277,17 +277,17 @@ void SatelliteClient::onFrameReceived(FramedTcpConnection* con,
} /* SatelliteClient::onFrameReceived */ } /* SatelliteClient::onFrameReceived */
void SatelliteClient::handleMsgTrunkHeartbeat(void) void SatelliteClient::handleMsgPeerHeartbeat(void)
{ {
} /* SatelliteClient::handleMsgTrunkHeartbeat */ } /* SatelliteClient::handleMsgPeerHeartbeat */
void SatelliteClient::handleMsgTrunkHello(std::istream& is) void SatelliteClient::handleMsgPeerHello(std::istream& is)
{ {
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("satellite", "Failed to unpack MsgTrunkHello"); geulog::error("satellite", "Failed to unpack MsgPeerHello");
return; return;
} }
@@ -310,40 +310,40 @@ void SatelliteClient::handleMsgTrunkHello(std::istream& is)
// parent can fan it out (debounced) — otherwise the first node-list // parent can fan it out (debounced) — otherwise the first node-list
// emission only happens on the next client login/TG-change. // emission only happens on the next client login/TG-change.
m_reflector->scheduleNodeListUpdate(); m_reflector->scheduleNodeListUpdate();
} /* SatelliteClient::handleMsgTrunkHello */ } /* SatelliteClient::handleMsgPeerHello */
void SatelliteClient::sendFilter(void) void SatelliteClient::sendFilter(void)
{ {
if (m_filter_str.empty()) return; if (m_filter_str.empty()) return;
sendMsg(MsgTrunkFilter(m_filter_str)); sendMsg(MsgPeerFilter(m_filter_str));
geulog::info("satellite", "Sent TG filter to parent: ", m_filter_str); geulog::info("satellite", "Sent TG filter to parent: ", m_filter_str);
} /* SatelliteClient::sendFilter */ } /* SatelliteClient::sendFilter */
void SatelliteClient::handleMsgTrunkTalkerStart(std::istream& is) void SatelliteClient::handleMsgPeerTalkerStart(std::istream& is)
{ {
MsgTrunkTalkerStart msg; MsgPeerTalkerStart msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
// Register as trunk talker — fires trunkTalkerUpdated which // Register as trunk talker — fires trunkTalkerUpdated which
// broadcasts MsgTalkerStart to local clients // broadcasts MsgTalkerStart to local clients
TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign()); TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign());
} /* SatelliteClient::handleMsgTrunkTalkerStart */ } /* SatelliteClient::handleMsgPeerTalkerStart */
void SatelliteClient::handleMsgTrunkTalkerStop(std::istream& is) void SatelliteClient::handleMsgPeerTalkerStop(std::istream& is)
{ {
MsgTrunkTalkerStop msg; MsgPeerTalkerStop msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
TGHandler::instance()->clearTrunkTalkerForTG(msg.tg()); TGHandler::instance()->clearTrunkTalkerForTG(msg.tg());
} /* SatelliteClient::handleMsgTrunkTalkerStop */ } /* SatelliteClient::handleMsgPeerTalkerStop */
void SatelliteClient::handleMsgTrunkAudio(std::istream& is) void SatelliteClient::handleMsgPeerAudio(std::istream& is)
{ {
MsgTrunkAudio msg; MsgPeerAudio msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
if (msg.audio().empty()) return; if (msg.audio().empty()) return;
@@ -351,34 +351,34 @@ void SatelliteClient::handleMsgTrunkAudio(std::istream& is)
MsgUdpAudio udp_msg(msg.audio()); MsgUdpAudio udp_msg(msg.audio());
m_reflector->broadcastUdpMsg(udp_msg, m_reflector->broadcastUdpMsg(udp_msg,
ReflectorClient::TgFilter(msg.tg())); ReflectorClient::TgFilter(msg.tg()));
} /* SatelliteClient::handleMsgTrunkAudio */ } /* SatelliteClient::handleMsgPeerAudio */
void SatelliteClient::handleMsgTrunkFlush(std::istream& is) void SatelliteClient::handleMsgPeerFlush(std::istream& is)
{ {
MsgTrunkFlush msg; MsgPeerFlush msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
m_reflector->broadcastUdpMsg(MsgUdpFlushSamples(), m_reflector->broadcastUdpMsg(MsgUdpFlushSamples(),
ReflectorClient::TgFilter(msg.tg())); ReflectorClient::TgFilter(msg.tg()));
} /* SatelliteClient::handleMsgTrunkFlush */ } /* SatelliteClient::handleMsgPeerFlush */
void SatelliteClient::handleMsgTrunkNodeList(std::istream& is) void SatelliteClient::handleMsgPeerNodeList(std::istream& is)
{ {
MsgTrunkNodeList msg; MsgPeerNodeList msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("satellite", "Failed to unpack MsgTrunkNodeList"); geulog::error("satellite", "Failed to unpack MsgPeerNodeList");
return; return;
} }
std::vector<MsgTrunkNodeList::NodeEntry> sanitized; std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size()); sanitized.reserve(msg.nodes().size());
unsigned dropped = 0; unsigned dropped = 0;
for (const auto& n : msg.nodes()) for (const auto& n : msg.nodes())
{ {
MsgTrunkNodeList::NodeEntry e; MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32); e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty()) { ++dropped; continue; } if (e.callsign.empty()) { ++dropped; continue; }
e.tg = n.tg; e.tg = n.tg;
@@ -409,24 +409,24 @@ void SatelliteClient::handleMsgTrunkNodeList(std::istream& is)
m_reflector->onPeerNodeList(m_parent_id, sanitized); m_reflector->onPeerNodeList(m_parent_id, sanitized);
} }
m_parent_nodes = std::move(sanitized); m_parent_nodes = std::move(sanitized);
} /* SatelliteClient::handleMsgTrunkNodeList */ } /* SatelliteClient::handleMsgPeerNodeList */
void SatelliteClient::sendNodeList( void SatelliteClient::sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
if (!m_con.isConnected() || !m_hello_received) return; if (!m_con.isConnected() || !m_hello_received) return;
// Apply our outbound TG filter so we only push roster entries the // Apply our outbound TG filter so we only push roster entries the
// parent cares about (consistent with the audio-path scoping rule). // parent cares about (consistent with the audio-path scoping rule).
std::vector<MsgTrunkNodeList::NodeEntry> filtered; std::vector<MsgPeerNodeList::NodeEntry> filtered;
filtered.reserve(nodes.size()); filtered.reserve(nodes.size());
for (const auto& n : nodes) for (const auto& n : nodes)
{ {
if (!m_filter.empty() && !m_filter.matches(n.tg)) continue; if (!m_filter.empty() && !m_filter.matches(n.tg)) continue;
filtered.push_back(n); filtered.push_back(n);
} }
sendMsg(MsgTrunkNodeList(filtered)); sendMsg(MsgPeerNodeList(filtered));
} /* SatelliteClient::sendNodeList */ } /* SatelliteClient::sendNodeList */
@@ -449,7 +449,7 @@ void SatelliteClient::heartbeatTick(Async::Timer* t)
if (--m_hb_tx_cnt == 0) if (--m_hb_tx_cnt == 0)
{ {
m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET; m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET;
sendMsg(MsgTrunkHeartbeat()); sendMsg(MsgPeerHeartbeat());
} }
if (--m_hb_rx_cnt == 0) if (--m_hb_rx_cnt == 0)
+13 -13
View File
@@ -26,7 +26,7 @@ An optional SATELLITE_FILTER scopes which TGs this satellite cares about,
in both directions (TgFilter syntax: exact, prefix "24*", range in both directions (TgFilter syntax: exact, prefix "24*", range
"2427-2438", comma-separated): "2427-2438", comma-separated):
- outbound: local events for non-matching TGs are not sent to the parent; - outbound: local events for non-matching TGs are not sent to the parent;
- inbound: the filter is sent to the parent via MsgTrunkFilter (type 122) - inbound: the filter is sent to the parent via MsgPeerFilter (type 122)
after authentication; the parent skips forwarding non-matching TGs. after authentication; the parent skips forwarding non-matching TGs.
*/ */
class SatelliteClient : public sigc::trackable class SatelliteClient : public sigc::trackable
@@ -46,11 +46,11 @@ class SatelliteClient : public sigc::trackable
// Send our local roster up to the parent. Caller has already filtered // Send our local roster up to the parent. Caller has already filtered
// to "this satellite's local clients" (sat_id empty on the wire). // to "this satellite's local clients" (sat_id empty on the wire).
void sendNodeList( void sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
// Read-only access to the parent's combined-view roster, surfaced // Read-only access to the parent's combined-view roster, surfaced
// by Reflector::statusJson under /status.parent.nodes. // by Reflector::statusJson under /status.parent.nodes.
const std::vector<MsgTrunkNodeList::NodeEntry>& parentNodes(void) const const std::vector<MsgPeerNodeList::NodeEntry>& parentNodes(void) const
{ {
return m_parent_nodes; return m_parent_nodes;
} }
@@ -76,26 +76,26 @@ class SatelliteClient : public sigc::trackable
unsigned m_hb_tx_cnt; unsigned m_hb_tx_cnt;
unsigned m_hb_rx_cnt; unsigned m_hb_rx_cnt;
TgFilter m_filter; // optional TG filter (SATELLITE_FILTER) TgFilter m_filter; // optional TG filter (SATELLITE_FILTER)
std::string m_filter_str; // raw config string for MsgTrunkFilter std::string m_filter_str; // raw config string for MsgPeerFilter
// Parent's id from MsgTrunkHello (used as the peer_id key for Redis // Parent's id from MsgPeerHello (used as the peer_id key for Redis
// tombstone bookkeeping when storing the parent-supplied roster). // tombstone bookkeeping when storing the parent-supplied roster).
std::string m_parent_id; std::string m_parent_id;
// Parent's combined roster (parent-local + every sibling satellite, // Parent's combined roster (parent-local + every sibling satellite,
// minus our own contribution). Surfaced via /status.parent.nodes. // minus our own contribution). Surfaced via /status.parent.nodes.
std::vector<MsgTrunkNodeList::NodeEntry> m_parent_nodes; std::vector<MsgPeerNodeList::NodeEntry> m_parent_nodes;
void onConnected(void); void onConnected(void);
void onDisconnected(Async::TcpConnection* con, void onDisconnected(Async::TcpConnection* con,
Async::TcpConnection::DisconnectReason reason); Async::TcpConnection::DisconnectReason reason);
void onFrameReceived(Async::FramedTcpConnection* con, void onFrameReceived(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data); std::vector<uint8_t>& data);
void handleMsgTrunkHello(std::istream& is); void handleMsgPeerHello(std::istream& is);
void handleMsgTrunkTalkerStart(std::istream& is); void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgTrunkTalkerStop(std::istream& is); void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgTrunkAudio(std::istream& is); void handleMsgPeerAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is); void handleMsgPeerFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void); void handleMsgPeerHeartbeat(void);
void handleMsgTrunkNodeList(std::istream& is); void handleMsgPeerNodeList(std::istream& is);
void sendMsg(const ReflectorMsg& msg); void sendMsg(const ReflectorMsg& msg);
void sendFilter(void); void sendFilter(void);
void heartbeatTick(Async::Timer* t); void heartbeatTick(Async::Timer* t);
+58 -58
View File
@@ -118,7 +118,7 @@ SatelliteLink::~SatelliteLink(void)
if (!m_partner_nodes.empty() && !m_satellite_id.empty()) if (!m_partner_nodes.empty() && !m_satellite_id.empty())
{ {
m_reflector->onPeerNodeList(m_satellite_id, m_reflector->onPeerNodeList(m_satellite_id,
std::vector<MsgTrunkNodeList::NodeEntry>{}); std::vector<MsgPeerNodeList::NodeEntry>{});
m_partner_nodes.clear(); m_partner_nodes.clear();
} }
} /* SatelliteLink::~SatelliteLink */ } /* SatelliteLink::~SatelliteLink */
@@ -171,7 +171,7 @@ void SatelliteLink::onParentTalkerStart(uint32_t tg,
{ {
if (!m_hello_received) return; if (!m_hello_received) return;
if (!filterPassesTg(tg)) return; if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkTalkerStart(tg, callsign)); sendMsg(MsgPeerTalkerStart(tg, callsign));
} /* SatelliteLink::onParentTalkerStart */ } /* SatelliteLink::onParentTalkerStart */
@@ -179,7 +179,7 @@ void SatelliteLink::onParentTalkerStop(uint32_t tg)
{ {
if (!m_hello_received) return; if (!m_hello_received) return;
if (!filterPassesTg(tg)) return; if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkTalkerStop(tg)); sendMsg(MsgPeerTalkerStop(tg));
} /* SatelliteLink::onParentTalkerStop */ } /* SatelliteLink::onParentTalkerStop */
@@ -188,7 +188,7 @@ void SatelliteLink::onParentAudio(uint32_t tg,
{ {
if (!m_hello_received) return; if (!m_hello_received) return;
if (!filterPassesTg(tg)) return; if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkAudio(tg, audio)); sendMsg(MsgPeerAudio(tg, audio));
} /* SatelliteLink::onParentAudio */ } /* SatelliteLink::onParentAudio */
@@ -196,7 +196,7 @@ void SatelliteLink::onParentFlush(uint32_t tg)
{ {
if (!m_hello_received) return; if (!m_hello_received) return;
if (!filterPassesTg(tg)) return; if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkFlush(tg)); sendMsg(MsgPeerFlush(tg));
} /* SatelliteLink::onParentFlush */ } /* SatelliteLink::onParentFlush */
@@ -215,8 +215,8 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
} }
if (!m_hello_received && if (!m_hello_received &&
header.type() != MsgTrunkHello::TYPE && header.type() != MsgPeerHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE) header.type() != MsgPeerHeartbeat::TYPE)
{ {
geulog::warn("satellite", "Ignoring message type=", header.type(), geulog::warn("satellite", "Ignoring message type=", header.type(),
" before hello"); " before hello");
@@ -227,29 +227,29 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
switch (header.type()) switch (header.type())
{ {
case MsgTrunkHeartbeat::TYPE: case MsgPeerHeartbeat::TYPE:
handleMsgTrunkHeartbeat(); handleMsgPeerHeartbeat();
break; break;
case MsgTrunkHello::TYPE: case MsgPeerHello::TYPE:
handleMsgTrunkHello(ss); handleMsgPeerHello(ss);
break; break;
case MsgTrunkTalkerStart::TYPE: case MsgPeerTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss); handleMsgPeerTalkerStart(ss);
break; break;
case MsgTrunkTalkerStop::TYPE: case MsgPeerTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss); handleMsgPeerTalkerStop(ss);
break; break;
case MsgTrunkAudio::TYPE: case MsgPeerAudio::TYPE:
handleMsgTrunkAudio(ss); handleMsgPeerAudio(ss);
break; break;
case MsgTrunkFlush::TYPE: case MsgPeerFlush::TYPE:
handleMsgTrunkFlush(ss); handleMsgPeerFlush(ss);
break; break;
case MsgTrunkFilter::TYPE: case MsgPeerFilter::TYPE:
handleMsgTrunkFilter(ss); handleMsgPeerFilter(ss);
break; break;
case MsgTrunkNodeList::TYPE: case MsgPeerNodeList::TYPE:
handleMsgTrunkNodeList(ss); handleMsgPeerNodeList(ss);
break; break;
default: default:
geulog::warn("satellite", "Unknown message type=", header.type()); geulog::warn("satellite", "Unknown message type=", header.type());
@@ -258,17 +258,17 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
} /* SatelliteLink::onFrameReceived */ } /* SatelliteLink::onFrameReceived */
void SatelliteLink::handleMsgTrunkHeartbeat(void) void SatelliteLink::handleMsgPeerHeartbeat(void)
{ {
} /* SatelliteLink::handleMsgTrunkHeartbeat */ } /* SatelliteLink::handleMsgPeerHeartbeat */
void SatelliteLink::handleMsgTrunkHello(std::istream& is) void SatelliteLink::handleMsgPeerHello(std::istream& is)
{ {
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("satellite", "Failed to unpack MsgTrunkHello"); geulog::error("satellite", "Failed to unpack MsgPeerHello");
return; return;
} }
@@ -279,7 +279,7 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
return; return;
} }
if (msg.role() != MsgTrunkHello::ROLE_SATELLITE) if (msg.role() != MsgPeerHello::ROLE_SATELLITE)
{ {
geulog::error("satellite", "Expected ROLE_SATELLITE from '", msg.id(), geulog::error("satellite", "Expected ROLE_SATELLITE from '", msg.id(),
"' but got role=", (int)msg.role()); "' but got role=", (int)msg.role());
@@ -304,8 +304,8 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
// and start forwarding local events. This also generates early // and start forwarding local events. This also generates early
// parent→satellite traffic, keeping the connection alive through // parent→satellite traffic, keeping the connection alive through
// firewalls / NAT devices that drop idle TCP sessions. // firewalls / NAT devices that drop idle TCP sessions.
sendMsg(MsgTrunkHello("PARENT", "", 0, m_secret, sendMsg(MsgPeerHello("PARENT", "", 0, m_secret,
MsgTrunkHello::ROLE_PEER)); MsgPeerHello::ROLE_PEER));
// Bring the new satellite up to speed: schedule a debounced node-list // Bring the new satellite up to speed: schedule a debounced node-list
// emission so it receives the parent's combined view (parent-local // emission so it receives the parent's combined view (parent-local
@@ -313,12 +313,12 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
m_reflector->scheduleNodeListUpdate(); m_reflector->scheduleNodeListUpdate();
statusChanged(this); statusChanged(this);
} /* SatelliteLink::handleMsgTrunkHello */ } /* SatelliteLink::handleMsgPeerHello */
void SatelliteLink::handleMsgTrunkTalkerStart(std::istream& is) void SatelliteLink::handleMsgPeerTalkerStart(std::istream& is)
{ {
MsgTrunkTalkerStart msg; MsgPeerTalkerStart msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
uint32_t tg = msg.tg(); uint32_t tg = msg.tg();
@@ -333,12 +333,12 @@ void SatelliteLink::handleMsgTrunkTalkerStart(std::istream& is)
m_reflector->forwardSatelliteAudioToTrunks(tg, msg.callsign()); m_reflector->forwardSatelliteAudioToTrunks(tg, msg.callsign());
statusChanged(this); statusChanged(this);
} /* SatelliteLink::handleMsgTrunkTalkerStart */ } /* SatelliteLink::handleMsgPeerTalkerStart */
void SatelliteLink::handleMsgTrunkTalkerStop(std::istream& is) void SatelliteLink::handleMsgPeerTalkerStop(std::istream& is)
{ {
MsgTrunkTalkerStop msg; MsgPeerTalkerStop msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
uint32_t tg = msg.tg(); uint32_t tg = msg.tg();
@@ -349,12 +349,12 @@ void SatelliteLink::handleMsgTrunkTalkerStop(std::istream& is)
m_reflector->forwardSatelliteStopToTrunks(tg); m_reflector->forwardSatelliteStopToTrunks(tg);
statusChanged(this); statusChanged(this);
} /* SatelliteLink::handleMsgTrunkTalkerStop */ } /* SatelliteLink::handleMsgPeerTalkerStop */
void SatelliteLink::handleMsgTrunkAudio(std::istream& is) void SatelliteLink::handleMsgPeerAudio(std::istream& is)
{ {
MsgTrunkAudio msg; MsgPeerAudio msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
uint32_t tg = msg.tg(); uint32_t tg = msg.tg();
@@ -370,12 +370,12 @@ void SatelliteLink::handleMsgTrunkAudio(std::istream& is)
// Forward to other satellites (not this one) // Forward to other satellites (not this one)
m_reflector->forwardAudioToSatellitesExcept(this, tg, msg.audio()); m_reflector->forwardAudioToSatellitesExcept(this, tg, msg.audio());
} /* SatelliteLink::handleMsgTrunkAudio */ } /* SatelliteLink::handleMsgPeerAudio */
void SatelliteLink::handleMsgTrunkFlush(std::istream& is) void SatelliteLink::handleMsgPeerFlush(std::istream& is)
{ {
MsgTrunkFlush msg; MsgPeerFlush msg;
if (!msg.unpack(is)) return; if (!msg.unpack(is)) return;
uint32_t tg = msg.tg(); uint32_t tg = msg.tg();
@@ -385,7 +385,7 @@ void SatelliteLink::handleMsgTrunkFlush(std::istream& is)
m_reflector->forwardSatelliteFlushToTrunks(tg); m_reflector->forwardSatelliteFlushToTrunks(tg);
m_reflector->forwardFlushToSatellitesExcept(this, tg); m_reflector->forwardFlushToSatellitesExcept(this, tg);
} /* SatelliteLink::handleMsgTrunkFlush */ } /* SatelliteLink::handleMsgPeerFlush */
void SatelliteLink::sendMsg(const ReflectorMsg& msg) void SatelliteLink::sendMsg(const ReflectorMsg& msg)
@@ -407,7 +407,7 @@ void SatelliteLink::heartbeatTick(Async::Timer* t)
if (--m_hb_tx_cnt == 0) if (--m_hb_tx_cnt == 0)
{ {
m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET; m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET;
sendMsg(MsgTrunkHeartbeat()); sendMsg(MsgPeerHeartbeat());
} }
if (--m_hb_rx_cnt == 0) if (--m_hb_rx_cnt == 0)
@@ -420,12 +420,12 @@ void SatelliteLink::heartbeatTick(Async::Timer* t)
} /* SatelliteLink::heartbeatTick */ } /* SatelliteLink::heartbeatTick */
void SatelliteLink::handleMsgTrunkFilter(std::istream& is) void SatelliteLink::handleMsgPeerFilter(std::istream& is)
{ {
MsgTrunkFilter msg; MsgPeerFilter msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("satellite", "Failed to unpack MsgTrunkFilter from '", geulog::error("satellite", "Failed to unpack MsgPeerFilter from '",
m_satellite_id, "'"); m_satellite_id, "'");
return; return;
} }
@@ -445,7 +445,7 @@ void SatelliteLink::handleMsgTrunkFilter(std::istream& is)
} }
statusChanged(this); statusChanged(this);
} /* SatelliteLink::handleMsgTrunkFilter */ } /* SatelliteLink::handleMsgPeerFilter */
bool SatelliteLink::filterPassesTg(uint32_t tg) const bool SatelliteLink::filterPassesTg(uint32_t tg) const
@@ -456,22 +456,22 @@ bool SatelliteLink::filterPassesTg(uint32_t tg) const
} /* SatelliteLink::filterPassesTg */ } /* SatelliteLink::filterPassesTg */
void SatelliteLink::handleMsgTrunkNodeList(std::istream& is) void SatelliteLink::handleMsgPeerNodeList(std::istream& is)
{ {
MsgTrunkNodeList msg; MsgPeerNodeList msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("satellite", "Failed to unpack MsgTrunkNodeList from '", geulog::error("satellite", "Failed to unpack MsgPeerNodeList from '",
m_satellite_id, "'"); m_satellite_id, "'");
return; return;
} }
std::vector<MsgTrunkNodeList::NodeEntry> sanitized; std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size()); sanitized.reserve(msg.nodes().size());
unsigned dropped = 0; unsigned dropped = 0;
for (const auto& n : msg.nodes()) for (const auto& n : msg.nodes())
{ {
MsgTrunkNodeList::NodeEntry e; MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32); e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty()) { ++dropped; continue; } if (e.callsign.empty()) { ++dropped; continue; }
e.tg = n.tg; e.tg = n.tg;
@@ -507,22 +507,22 @@ void SatelliteLink::handleMsgTrunkNodeList(std::istream& is)
m_reflector->scheduleNodeListUpdate(); m_reflector->scheduleNodeListUpdate();
statusChanged(this); statusChanged(this);
} /* SatelliteLink::handleMsgTrunkNodeList */ } /* SatelliteLink::handleMsgPeerNodeList */
void SatelliteLink::sendNodeList( void SatelliteLink::sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
if (!m_hello_received) return; if (!m_hello_received) return;
// Apply this satellite's announced filter so we only forward TGs the // Apply this satellite's announced filter so we only forward TGs the
// satellite cares about (matches the audio-path scoping rule). // satellite cares about (matches the audio-path scoping rule).
std::vector<MsgTrunkNodeList::NodeEntry> filtered; std::vector<MsgPeerNodeList::NodeEntry> filtered;
filtered.reserve(nodes.size()); filtered.reserve(nodes.size());
for (const auto& n : nodes) for (const auto& n : nodes)
{ {
if (!filterPassesTg(n.tg)) continue; if (!filterPassesTg(n.tg)) continue;
filtered.push_back(n); filtered.push_back(n);
} }
sendMsg(MsgTrunkNodeList(filtered)); sendMsg(MsgPeerNodeList(filtered));
} /* SatelliteLink::sendNodeList */ } /* SatelliteLink::sendNodeList */
+13 -13
View File
@@ -19,7 +19,7 @@ class Reflector;
A SatelliteLink is created for each satellite that connects to the parent's A SatelliteLink is created for each satellite that connects to the parent's
satellite port. By default it relays ALL TGs bidirectionally. When the satellite port. By default it relays ALL TGs bidirectionally. When the
satellite sends a MsgTrunkFilter (type 122), the parent applies the filter satellite sends a MsgPeerFilter (type 122), the parent applies the filter
to outbound traffic — only matching TGs are forwarded to this satellite. to outbound traffic — only matching TGs are forwarded to this satellite.
The parent always wins talker arbitration over satellites. The parent always wins talker arbitration over satellites.
*/ */
@@ -60,13 +60,13 @@ class SatelliteLink : public sigc::trackable
// method additionally drops entries whose TG falls outside the // method additionally drops entries whose TG falls outside the
// satellite's announced filter (if any). // satellite's announced filter (if any).
void sendNodeList( void sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
// Read-only access to the satellite-supplied roster (this satellite's // Read-only access to the satellite-supplied roster (this satellite's
// local clients), already sanitised and stamped with sat_id = // local clients), already sanitised and stamped with sat_id =
// satelliteId(). Used by Reflector to merge into the parent's // satelliteId(). Used by Reflector to merge into the parent's
// outbound advertisements. // outbound advertisements.
const std::vector<MsgTrunkNodeList::NodeEntry>& partnerNodes(void) const const std::vector<MsgPeerNodeList::NodeEntry>& partnerNodes(void) const
{ {
return m_partner_nodes; return m_partner_nodes;
} }
@@ -86,22 +86,22 @@ class SatelliteLink : public sigc::trackable
std::set<uint32_t> m_sat_active_tgs; std::set<uint32_t> m_sat_active_tgs;
TgFilter m_tg_filter; TgFilter m_tg_filter;
// Roster of clients attached to this satellite, learned via // Roster of clients attached to this satellite, learned via
// MsgTrunkNodeList from the satellite. Each entry carries // MsgPeerNodeList from the satellite. Each entry carries
// sat_id == m_satellite_id (stamped on ingest) so the Reflector can // sat_id == m_satellite_id (stamped on ingest) so the Reflector can
// merge it into outbound trunk/twin/sibling-sat lists with correct // merge it into outbound trunk/twin/sibling-sat lists with correct
// attribution. // attribution.
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes; std::vector<MsgPeerNodeList::NodeEntry> m_partner_nodes;
void onFrameReceived(Async::FramedTcpConnection* con, void onFrameReceived(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data); std::vector<uint8_t>& data);
void handleMsgTrunkHello(std::istream& is); void handleMsgPeerHello(std::istream& is);
void handleMsgTrunkTalkerStart(std::istream& is); void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgTrunkTalkerStop(std::istream& is); void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgTrunkAudio(std::istream& is); void handleMsgPeerAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is); void handleMsgPeerFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void); void handleMsgPeerHeartbeat(void);
void handleMsgTrunkFilter(std::istream& is); void handleMsgPeerFilter(std::istream& is);
void handleMsgTrunkNodeList(std::istream& is); void handleMsgPeerNodeList(std::istream& is);
bool filterPassesTg(uint32_t tg) const; bool filterPassesTg(uint32_t tg) const;
void sendMsg(const ReflectorMsg& msg); void sendMsg(const ReflectorMsg& msg);
void heartbeatTick(Async::Timer* t); void heartbeatTick(Async::Timer* t);
+90 -90
View File
@@ -573,7 +573,7 @@ Json::Value TrunkLink::statusJson(void) const
if (!n.qth_name.empty()) entry["qth_name"] = n.qth_name; if (!n.qth_name.empty()) entry["qth_name"] = n.qth_name;
if (!n.sat_id.empty()) entry["sat_id"] = n.sat_id; if (!n.sat_id.empty()) entry["sat_id"] = n.sat_id;
// Derive isTalker from the live trunk-talker map maintained by // Derive isTalker from the live trunk-talker map maintained by
// MsgTrunkTalkerStart/Stop. Authoritative for partner nodes; the // MsgPeerTalkerStart/Stop. Authoritative for partner nodes; the
// sender's own isTalker is stale by the time it arrives in the // sender's own isTalker is stale by the time it arrives in the
// periodic node-list push. // periodic node-list push.
entry["isTalker"] = entry["isTalker"] =
@@ -587,7 +587,7 @@ Json::Value TrunkLink::statusJson(void) const
void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con, void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello) const MsgPeerHello& hello)
{ {
if (m_paired) if (m_paired)
{ {
@@ -620,7 +620,7 @@ void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con,
// Send our hello back on this inbound connection // Send our hello back on this inbound connection
sendMsgOnPairedInbound(m_ib_cons.size() - 1, sendMsgOnPairedInbound(m_ib_cons.size() - 1,
MsgTrunkHello(m_peer_id_config, joinPrefixes(m_local_prefix), MsgPeerHello(m_peer_id_config, joinPrefixes(m_local_prefix),
m_priority, m_secret)); m_priority, m_secret));
return; return;
} }
@@ -667,7 +667,7 @@ void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con,
" ib_hb_tx=", m_ib_hb_tx_cnt, " ib_hb_rx=", m_ib_hb_rx_cnt); " ib_hb_tx=", m_ib_hb_tx_cnt, " ib_hb_rx=", m_ib_hb_rx_cnt);
// Send our hello back on the inbound connection // Send our hello back on the inbound connection
sendMsgOnInbound(MsgTrunkHello(m_peer_id_config, sendMsgOnInbound(MsgPeerHello(m_peer_id_config,
joinPrefixes(m_local_prefix), joinPrefixes(m_local_prefix),
m_priority, m_secret)); m_priority, m_secret));
} /* TrunkLink::acceptInboundConnection */ } /* TrunkLink::acceptInboundConnection */
@@ -729,7 +729,7 @@ void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign)
{ {
return; return;
} }
sendMsg(MsgTrunkTalkerStart(mapTgOut(tg), callsign)); sendMsg(MsgPeerTalkerStart(mapTgOut(tg), callsign));
} /* TrunkLink::onLocalTalkerStart */ } /* TrunkLink::onLocalTalkerStart */
@@ -749,7 +749,7 @@ void TrunkLink::onLocalTalkerStop(uint32_t tg)
{ {
return; return;
} }
sendMsg(MsgTrunkTalkerStop(mapTgOut(tg))); sendMsg(MsgPeerTalkerStop(mapTgOut(tg)));
} /* TrunkLink::onLocalTalkerStop */ } /* TrunkLink::onLocalTalkerStop */
@@ -767,7 +767,7 @@ void TrunkLink::onLocalAudio(uint32_t tg, const std::vector<uint8_t>& audio)
{ {
return; return;
} }
sendMsg(MsgTrunkAudio(mapTgOut(tg), audio)); sendMsg(MsgPeerAudio(mapTgOut(tg), audio));
} /* TrunkLink::onLocalAudio */ } /* TrunkLink::onLocalAudio */
@@ -781,7 +781,7 @@ void TrunkLink::onLocalFlush(uint32_t tg)
{ {
return; return;
} }
sendMsg(MsgTrunkFlush(mapTgOut(tg))); sendMsg(MsgPeerFlush(mapTgOut(tg)));
} /* TrunkLink::onLocalFlush */ } /* TrunkLink::onLocalFlush */
@@ -808,7 +808,7 @@ void TrunkLink::onConnected(void)
m_ob_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET; m_ob_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET;
m_heartbeat_timer.setEnable(true); m_heartbeat_timer.setEnable(true);
sendMsgOnOutbound(MsgTrunkHello(m_peer_id_config, sendMsgOnOutbound(MsgPeerHello(m_peer_id_config,
joinPrefixes(m_local_prefix), joinPrefixes(m_local_prefix),
m_priority, m_secret)); m_priority, m_secret));
} /* TrunkLink::onConnected */ } /* TrunkLink::onConnected */
@@ -864,8 +864,8 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
// Only allow hello and heartbeat before hello exchange completes // Only allow hello and heartbeat before hello exchange completes
if (!hello_done && if (!hello_done &&
header.type() != MsgTrunkHello::TYPE && header.type() != MsgPeerHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE) header.type() != MsgPeerHeartbeat::TYPE)
{ {
geulog::warn("trunk", "[", m_section, "] Ignoring trunk message type=", geulog::warn("trunk", "[", m_section, "] Ignoring trunk message type=",
header.type(), " before hello"); header.type(), " before hello");
@@ -882,7 +882,7 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
m_ob_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET; m_ob_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET;
} }
if (header.type() != MsgTrunkHeartbeat::TYPE) if (header.type() != MsgPeerHeartbeat::TYPE)
{ {
geulog::debug("trunk", m_section, ": rx ", (is_inbound ? "IB" : "OB"), geulog::debug("trunk", m_section, ": rx ", (is_inbound ? "IB" : "OB"),
" type=", header.type(), " len=", data.size()); " type=", header.type(), " len=", data.size());
@@ -890,26 +890,26 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
switch (header.type()) switch (header.type())
{ {
case MsgTrunkHeartbeat::TYPE: case MsgPeerHeartbeat::TYPE:
handleMsgTrunkHeartbeat(); handleMsgPeerHeartbeat();
break; break;
case MsgTrunkHello::TYPE: case MsgPeerHello::TYPE:
handleMsgTrunkHello(ss, is_inbound); handleMsgPeerHello(ss, is_inbound);
break; break;
case MsgTrunkTalkerStart::TYPE: case MsgPeerTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss); handleMsgPeerTalkerStart(ss);
break; break;
case MsgTrunkTalkerStop::TYPE: case MsgPeerTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss); handleMsgPeerTalkerStop(ss);
break; break;
case MsgTrunkAudio::TYPE: case MsgPeerAudio::TYPE:
handleMsgTrunkAudio(ss); handleMsgPeerAudio(ss);
break; break;
case MsgTrunkFlush::TYPE: case MsgPeerFlush::TYPE:
handleMsgTrunkFlush(ss); handleMsgPeerFlush(ss);
break; break;
case MsgTrunkNodeList::TYPE: case MsgPeerNodeList::TYPE:
handleMsgTrunkNodeList(ss); handleMsgPeerNodeList(ss);
break; break;
default: default:
geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=", geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=",
@@ -919,13 +919,13 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
} /* TrunkLink::onFrameReceived */ } /* TrunkLink::onFrameReceived */
void TrunkLink::handleMsgTrunkHeartbeat(void) void TrunkLink::handleMsgPeerHeartbeat(void)
{ {
// rx counter already reset in onFrameReceived // rx counter already reset in onFrameReceived
} /* TrunkLink::handleMsgTrunkHeartbeat */ } /* TrunkLink::handleMsgPeerHeartbeat */
void TrunkLink::handleMsgTrunkHello(std::istream& is, bool is_inbound) void TrunkLink::handleMsgPeerHello(std::istream& is, bool is_inbound)
{ {
// Inbound hellos are already handled by acceptInboundConnection. // Inbound hellos are already handled by acceptInboundConnection.
// A duplicate arriving here means the peer re-sent (e.g. TcpPrioClient // A duplicate arriving here means the peer re-sent (e.g. TcpPrioClient
@@ -937,17 +937,17 @@ void TrunkLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
} }
// Hello on outbound = peer's reply to our outbound hello // Hello on outbound = peer's reply to our outbound hello
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkHello"); geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerHello");
return; return;
} }
if (msg.id().empty()) if (msg.id().empty())
{ {
geulog::error("trunk", "[", m_section, geulog::error("trunk", "[", m_section,
"] Peer sent empty trunk ID in MsgTrunkHello"); "] Peer sent empty trunk ID in MsgPeerHello");
m_con.disconnect(); m_con.disconnect();
return; return;
} }
@@ -974,15 +974,15 @@ void TrunkLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
" ib_connected=", (m_inbound_con != nullptr), " ib_connected=", (m_inbound_con != nullptr),
" ib_hello=", m_ib_hello_received, " ib_hello=", m_ib_hello_received,
" isActive=", isActive()); " isActive=", isActive());
} /* TrunkLink::handleMsgTrunkHello */ } /* TrunkLink::handleMsgPeerHello */
void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is) void TrunkLink::handleMsgPeerTalkerStart(std::istream& is)
{ {
MsgTrunkTalkerStart msg; MsgPeerTalkerStart msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkTalkerStart"); geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerTalkerStart");
return; return;
} }
@@ -1034,15 +1034,15 @@ void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is)
m_reflector->forwardTrunkTalkerStartToOtherTrunks(this, local_tg, m_reflector->forwardTrunkTalkerStartToOtherTrunks(this, local_tg,
msg.callsign()); msg.callsign());
} }
} /* TrunkLink::handleMsgTrunkTalkerStart */ } /* TrunkLink::handleMsgPeerTalkerStart */
void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is) void TrunkLink::handleMsgPeerTalkerStop(std::istream& is)
{ {
MsgTrunkTalkerStop msg; MsgPeerTalkerStop msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkTalkerStop"); geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerTalkerStop");
return; return;
} }
@@ -1068,15 +1068,15 @@ void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is)
{ {
m_reflector->forwardTrunkTalkerStopToOtherTrunks(this, local_tg); m_reflector->forwardTrunkTalkerStopToOtherTrunks(this, local_tg);
} }
} /* TrunkLink::handleMsgTrunkTalkerStop */ } /* TrunkLink::handleMsgPeerTalkerStop */
void TrunkLink::handleMsgTrunkAudio(std::istream& is) void TrunkLink::handleMsgPeerAudio(std::istream& is)
{ {
MsgTrunkAudio msg; MsgPeerAudio msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkAudio"); geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerAudio");
return; return;
} }
@@ -1122,15 +1122,15 @@ void TrunkLink::handleMsgTrunkAudio(std::istream& is)
{ {
m_reflector->forwardTrunkAudioToOtherTrunks(this, local_tg, msg.audio()); m_reflector->forwardTrunkAudioToOtherTrunks(this, local_tg, msg.audio());
} }
} /* TrunkLink::handleMsgTrunkAudio */ } /* TrunkLink::handleMsgPeerAudio */
void TrunkLink::handleMsgTrunkFlush(std::istream& is) void TrunkLink::handleMsgPeerFlush(std::istream& is)
{ {
MsgTrunkFlush msg; MsgPeerFlush msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkFlush"); geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerFlush");
return; return;
} }
@@ -1158,7 +1158,7 @@ void TrunkLink::handleMsgTrunkFlush(std::istream& is)
{ {
m_reflector->forwardTrunkFlushToOtherTrunks(this, local_tg); m_reflector->forwardTrunkFlushToOtherTrunks(this, local_tg);
} }
} /* TrunkLink::handleMsgTrunkFlush */ } /* TrunkLink::handleMsgPeerFlush */
void TrunkLink::sendMsg(const ReflectorMsg& msg) void TrunkLink::sendMsg(const ReflectorMsg& msg)
@@ -1264,7 +1264,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{ {
geulog::debug("trunk", m_section, ": paired OB#", i, " heartbeat tx", geulog::debug("trunk", m_section, ": paired OB#", i, " heartbeat tx",
" hb_rx=", m_ob_states[i].hb_rx_cnt); " hb_rx=", m_ob_states[i].hb_rx_cnt);
sendMsgOnPairedOutbound(i, MsgTrunkHeartbeat()); sendMsgOnPairedOutbound(i, MsgPeerHeartbeat());
} }
if (--m_ob_states[i].hb_rx_cnt == 0) if (--m_ob_states[i].hb_rx_cnt == 0)
{ {
@@ -1290,7 +1290,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{ {
geulog::debug("trunk", m_section, ": paired IB#", i, " heartbeat tx", geulog::debug("trunk", m_section, ": paired IB#", i, " heartbeat tx",
" hb_rx=", m_ib_states[i].hb_rx_cnt); " hb_rx=", m_ib_states[i].hb_rx_cnt);
sendMsgOnPairedInbound(i, MsgTrunkHeartbeat()); sendMsgOnPairedInbound(i, MsgPeerHeartbeat());
} }
if (--m_ib_states[i].hb_rx_cnt == 0) if (--m_ib_states[i].hb_rx_cnt == 0)
{ {
@@ -1331,7 +1331,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{ {
geulog::debug("trunk", m_section, ": OB heartbeat tx ob_hb_rx=", geulog::debug("trunk", m_section, ": OB heartbeat tx ob_hb_rx=",
m_ob_hb_rx_cnt); m_ob_hb_rx_cnt);
sendMsgOnOutbound(MsgTrunkHeartbeat()); sendMsgOnOutbound(MsgPeerHeartbeat());
} }
if (--m_ob_hb_rx_cnt == 0) if (--m_ob_hb_rx_cnt == 0)
{ {
@@ -1352,7 +1352,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{ {
geulog::debug("trunk", m_section, ": IB heartbeat tx ib_hb_rx=", geulog::debug("trunk", m_section, ": IB heartbeat tx ib_hb_rx=",
m_ib_hb_rx_cnt); m_ib_hb_rx_cnt);
sendMsgOnInbound(MsgTrunkHeartbeat()); sendMsgOnInbound(MsgPeerHeartbeat());
} }
if (--m_ib_hb_rx_cnt == 0) if (--m_ib_hb_rx_cnt == 0)
{ {
@@ -1505,12 +1505,12 @@ void TrunkLink::onPairedInboundFrame(Async::FramedTcpConnection* con,
switch (header.type()) switch (header.type())
{ {
case MsgTrunkHello::TYPE: case MsgPeerHello::TYPE:
// Duplicate hello — the hello was already processed by Reflector's // Duplicate hello — the hello was already processed by Reflector's
// acceptInboundConnection path; ignore silently. // acceptInboundConnection path; ignore silently.
break; break;
case MsgTrunkHeartbeat::TYPE: case MsgPeerHeartbeat::TYPE:
// hb_rx_cnt already reset above; nothing else needed // hb_rx_cnt already reset above; nothing else needed
break; break;
@@ -1518,20 +1518,20 @@ void TrunkLink::onPairedInboundFrame(Async::FramedTcpConnection* con,
// Dispatch data messages to shared handlers // Dispatch data messages to shared handlers
switch (header.type()) switch (header.type())
{ {
case MsgTrunkTalkerStart::TYPE: case MsgPeerTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss); handleMsgPeerTalkerStart(ss);
break; break;
case MsgTrunkTalkerStop::TYPE: case MsgPeerTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss); handleMsgPeerTalkerStop(ss);
break; break;
case MsgTrunkAudio::TYPE: case MsgPeerAudio::TYPE:
handleMsgTrunkAudio(ss); handleMsgPeerAudio(ss);
break; break;
case MsgTrunkFlush::TYPE: case MsgPeerFlush::TYPE:
handleMsgTrunkFlush(ss); handleMsgPeerFlush(ss);
break; break;
case MsgTrunkNodeList::TYPE: case MsgPeerNodeList::TYPE:
handleMsgTrunkNodeList(ss); handleMsgPeerNodeList(ss);
break; break;
default: default:
geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=", geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=",
@@ -1574,8 +1574,8 @@ void TrunkLink::onPairedOutboundConnected(FramedTcpClient* client)
" sending hello with priority=", m_priority); " sending hello with priority=", m_priority);
sendMsgOnPairedOutbound(idx, sendMsgOnPairedOutbound(idx,
MsgTrunkHello(m_peer_id_config, joinPrefixes(m_local_prefix), MsgPeerHello(m_peer_id_config, joinPrefixes(m_local_prefix),
m_priority, m_secret, MsgTrunkHello::ROLE_PEER)); m_priority, m_secret, MsgPeerHello::ROLE_PEER));
} /* TrunkLink::onPairedOutboundConnected */ } /* TrunkLink::onPairedOutboundConnected */
@@ -1628,8 +1628,8 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
// Only allow hello and heartbeat before handshake completes // Only allow hello and heartbeat before handshake completes
if (!m_ob_states[idx].hello_received && if (!m_ob_states[idx].hello_received &&
header.type() != MsgTrunkHello::TYPE && header.type() != MsgPeerHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE) header.type() != MsgPeerHeartbeat::TYPE)
{ {
geulog::warn("trunk", "[", m_section, "] Ignoring paired ob#", idx, geulog::warn("trunk", "[", m_section, "] Ignoring paired ob#", idx,
" msg type=", header.type(), " before hello"); " msg type=", header.type(), " before hello");
@@ -1638,9 +1638,9 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
switch (header.type()) switch (header.type())
{ {
case MsgTrunkHello::TYPE: case MsgPeerHello::TYPE:
{ {
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(ss)) return; if (!msg.unpack(ss)) return;
if (msg.id().empty()) if (msg.id().empty())
@@ -1672,7 +1672,7 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
break; break;
} }
case MsgTrunkHeartbeat::TYPE: case MsgPeerHeartbeat::TYPE:
// hb_rx_cnt already reset above; nothing else needed // hb_rx_cnt already reset above; nothing else needed
break; break;
@@ -1682,20 +1682,20 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
// `ss` is already positioned past the header so we can pass it directly. // `ss` is already positioned past the header so we can pass it directly.
switch (header.type()) switch (header.type())
{ {
case MsgTrunkTalkerStart::TYPE: case MsgPeerTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss); handleMsgPeerTalkerStart(ss);
break; break;
case MsgTrunkTalkerStop::TYPE: case MsgPeerTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss); handleMsgPeerTalkerStop(ss);
break; break;
case MsgTrunkAudio::TYPE: case MsgPeerAudio::TYPE:
handleMsgTrunkAudio(ss); handleMsgPeerAudio(ss);
break; break;
case MsgTrunkFlush::TYPE: case MsgPeerFlush::TYPE:
handleMsgTrunkFlush(ss); handleMsgPeerFlush(ss);
break; break;
case MsgTrunkNodeList::TYPE: case MsgPeerNodeList::TYPE:
handleMsgTrunkNodeList(ss); handleMsgPeerNodeList(ss);
break; break;
default: default:
geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=", geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=",
@@ -1787,31 +1787,31 @@ void TrunkLink::reloadConfig(void)
void TrunkLink::sendNodeList( void TrunkLink::sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
if (!isActive()) return; if (!isActive()) return;
sendMsg(MsgTrunkNodeList(nodes)); sendMsg(MsgPeerNodeList(nodes));
} /* TrunkLink::sendNodeList */ } /* TrunkLink::sendNodeList */
void TrunkLink::handleMsgTrunkNodeList(std::istream& is) void TrunkLink::handleMsgPeerNodeList(std::istream& is)
{ {
MsgTrunkNodeList msg; MsgPeerNodeList msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkNodeList"); geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerNodeList");
return; return;
} }
// Sanitize every entry before handing off. Untrusted strings from peer // Sanitize every entry before handing off. Untrusted strings from peer
// reflectors flow into Redis key names, MQTT payloads and log output; // reflectors flow into Redis key names, MQTT payloads and log output;
// keep them byte-bounded and free of control / delimiter characters. // keep them byte-bounded and free of control / delimiter characters.
std::vector<MsgTrunkNodeList::NodeEntry> sanitized; std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size()); sanitized.reserve(msg.nodes().size());
unsigned dropped = 0; unsigned dropped = 0;
for (const auto& n : msg.nodes()) for (const auto& n : msg.nodes())
{ {
MsgTrunkNodeList::NodeEntry e; MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32); e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty()) if (e.callsign.empty())
{ {
@@ -1852,7 +1852,7 @@ void TrunkLink::handleMsgTrunkNodeList(std::istream& is)
m_reflector->onPeerNodeList(peerId(), sanitized); m_reflector->onPeerNodeList(peerId(), sanitized);
m_partner_nodes = std::move(sanitized); m_partner_nodes = std::move(sanitized);
} /* TrunkLink::handleMsgTrunkNodeList */ } /* TrunkLink::handleMsgPeerNodeList */
std::string TrunkLink::statusLine(void) const std::string TrunkLink::statusLine(void) const
+14 -14
View File
@@ -64,7 +64,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
class Reflector; class Reflector;
class ReflectorMsg; class ReflectorMsg;
class MsgTrunkHello; class MsgPeerHello;
class MsgUdpAudio; class MsgUdpAudio;
@@ -87,7 +87,7 @@ connection (with inbound as fallback). Heartbeats are sent on each connection
independently to detect dead sockets. independently to detect dead sockets.
Talker arbitration tie-break: each side generates a random 32-bit priority at Talker arbitration tie-break: each side generates a random 32-bit priority at
startup and exchanges it in MsgTrunkHello. When both sides claim the same TG startup and exchanges it in MsgPeerHello. When both sides claim the same TG
simultaneously, the side with the lower priority value defers (clears its local simultaneously, the side with the lower priority value defers (clears its local
talker and accepts the remote one). talker and accepts the remote one).
*/ */
@@ -129,7 +129,7 @@ class TrunkLink : public sigc::trackable
// Accept an inbound connection from a peer that has already sent a hello // Accept an inbound connection from a peer that has already sent a hello
void acceptInboundConnection(Async::FramedTcpConnection* con, void acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello); const MsgPeerHello& hello);
// Called by Reflector when the inbound connection disconnects // Called by Reflector when the inbound connection disconnects
void onInboundDisconnected(Async::FramedTcpConnection* con, void onInboundDisconnected(Async::FramedTcpConnection* con,
@@ -147,7 +147,7 @@ class TrunkLink : public sigc::trackable
// Send the local node list (callsign + current TG per local client) // Send the local node list (callsign + current TG per local client)
// to the peer. Called from Reflector after debounce. // to the peer. Called from Reflector after debounce.
void sendNodeList(const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); void sendNodeList(const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
// PTY-driven controls // PTY-driven controls
void muteCallsign(const std::string& callsign) void muteCallsign(const std::string& callsign)
@@ -189,7 +189,7 @@ class TrunkLink : public sigc::trackable
std::vector<std::string> m_local_prefix; // our authoritative TG prefixes std::vector<std::string> m_local_prefix; // our authoritative TG prefixes
std::vector<std::string> m_remote_prefix; // peer's authoritative TG prefixes std::vector<std::string> m_remote_prefix; // peer's authoritative TG prefixes
uint32_t m_priority; // our tie-break nonce (random, set once) uint32_t m_priority; // our tie-break nonce (random, set once)
uint32_t m_peer_priority; // peer's nonce, from MsgTrunkHello uint32_t m_peer_priority; // peer's nonce, from MsgPeerHello
FramedTcpClient m_con; // outbound client connection FramedTcpClient m_con; // outbound client connection
Async::FramedTcpConnection* m_inbound_con = nullptr; // accepted inbound Async::FramedTcpConnection* m_inbound_con = nullptr; // accepted inbound
Async::Timer m_heartbeat_timer; Async::Timer m_heartbeat_timer;
@@ -204,10 +204,10 @@ class TrunkLink : public sigc::trackable
// TGs currently held by this specific trunk peer (for scoped cleanup) // TGs currently held by this specific trunk peer (for scoped cleanup)
std::set<uint32_t> m_peer_active_tgs; std::set<uint32_t> m_peer_active_tgs;
// Most recent MsgTrunkNodeList we received from the peer, sanitized. // Most recent MsgPeerNodeList we received from the peer, sanitized.
// Surfaced in statusJson() so /status can attribute nodes to a peer. // Surfaced in statusJson() so /status can attribute nodes to a peer.
// Cleared when the link goes fully inactive. // Cleared when the link goes fully inactive.
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes; std::vector<MsgPeerNodeList::NodeEntry> m_partner_nodes;
// TGs the peer has shown interest in (sent TalkerStart for). // TGs the peer has shown interest in (sent TalkerStart for).
// Maps TG number to last activity timestamp. Entries expire after // Maps TG number to last activity timestamp. Entries expire after
@@ -256,13 +256,13 @@ class TrunkLink : public sigc::trackable
void onFrameReceived(Async::FramedTcpConnection* con, void onFrameReceived(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data); std::vector<uint8_t>& data);
void handleMsgTrunkHello(std::istream& is, bool is_inbound); void handleMsgPeerHello(std::istream& is, bool is_inbound);
void handleMsgTrunkTalkerStart(std::istream& is); void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgTrunkTalkerStop(std::istream& is); void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgTrunkAudio(std::istream& is); void handleMsgPeerAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is); void handleMsgPeerFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void); void handleMsgPeerHeartbeat(void);
void handleMsgTrunkNodeList(std::istream& is); void handleMsgPeerNodeList(std::istream& is);
void sendMsg(const ReflectorMsg& msg); void sendMsg(const ReflectorMsg& msg);
void sendMsgOnOutbound(const ReflectorMsg& msg); void sendMsgOnOutbound(const ReflectorMsg& msg);
+59 -59
View File
@@ -242,7 +242,7 @@ bool TwinLink::initialize(void)
void TwinLink::acceptInboundConnection(Async::FramedTcpConnection* con, void TwinLink::acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello) const MsgPeerHello& hello)
{ {
if (m_inbound_con != nullptr) if (m_inbound_con != nullptr)
{ {
@@ -294,9 +294,9 @@ void TwinLink::acceptInboundConnection(Async::FramedTcpConnection* con,
"' priority=", m_peer_priority); "' priority=", m_peer_priority);
// Send our hello back on the inbound connection // Send our hello back on the inbound connection
sendMsgOnInbound(MsgTrunkHello(m_peer_id_config, m_local_prefix, sendMsgOnInbound(MsgPeerHello(m_peer_id_config, m_local_prefix,
m_priority, m_secret, m_priority, m_secret,
MsgTrunkHello::ROLE_TWIN)); MsgPeerHello::ROLE_TWIN));
} /* TwinLink::acceptInboundConnection */ } /* TwinLink::acceptInboundConnection */
@@ -306,11 +306,11 @@ void TwinLink::onLocalTalkerUpdated(uint32_t tg,
if (!isActive()) return; if (!isActive()) return;
if (callsign.empty()) if (callsign.empty())
{ {
sendMsg(MsgTrunkTalkerStop(tg)); sendMsg(MsgPeerTalkerStop(tg));
} }
else else
{ {
sendMsg(MsgTrunkTalkerStart(tg, callsign)); sendMsg(MsgPeerTalkerStart(tg, callsign));
} }
} /* TwinLink::onLocalTalkerUpdated */ } /* TwinLink::onLocalTalkerUpdated */
@@ -319,14 +319,14 @@ void TwinLink::onLocalAudio(uint32_t tg,
const std::vector<uint8_t>& audio) const std::vector<uint8_t>& audio)
{ {
if (!isActive()) return; if (!isActive()) return;
sendMsg(MsgTrunkAudio(tg, audio)); sendMsg(MsgPeerAudio(tg, audio));
} /* TwinLink::onLocalAudio */ } /* TwinLink::onLocalAudio */
void TwinLink::onLocalFlush(uint32_t tg) void TwinLink::onLocalFlush(uint32_t tg)
{ {
if (!isActive()) return; if (!isActive()) return;
sendMsg(MsgTrunkFlush(tg)); sendMsg(MsgPeerFlush(tg));
} /* TwinLink::onLocalFlush */ } /* TwinLink::onLocalFlush */
@@ -348,10 +348,10 @@ void TwinLink::onExternalTrunkTalkerStop(uint32_t tg,
void TwinLink::onLocalNodeListUpdated( void TwinLink::onLocalNodeListUpdated(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes) const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{ {
if (!isActive()) return; if (!isActive()) return;
sendMsg(MsgTrunkNodeList(nodes)); sendMsg(MsgPeerNodeList(nodes));
} /* TwinLink::onLocalNodeListUpdated */ } /* TwinLink::onLocalNodeListUpdated */
@@ -415,9 +415,9 @@ void TwinLink::onConnected(void)
m_ob_hb_rx_cnt = 0; m_ob_hb_rx_cnt = 0;
m_heartbeat_timer.setEnable(true); m_heartbeat_timer.setEnable(true);
sendMsgOnOutbound(MsgTrunkHello(m_peer_id_config, m_local_prefix, sendMsgOnOutbound(MsgPeerHello(m_peer_id_config, m_local_prefix,
m_priority, m_secret, m_priority, m_secret,
MsgTrunkHello::ROLE_TWIN)); MsgPeerHello::ROLE_TWIN));
} /* TwinLink::onConnected */ } /* TwinLink::onConnected */
@@ -461,8 +461,8 @@ void TwinLink::onFrameReceived(FramedTcpConnection* con,
// Only allow hello and heartbeat before hello exchange completes // Only allow hello and heartbeat before hello exchange completes
if (!hello_done && if (!hello_done &&
header.type() != MsgTrunkHello::TYPE && header.type() != MsgPeerHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE) header.type() != MsgPeerHeartbeat::TYPE)
{ {
geulog::warn("twin", "TWIN: Ignoring message type=", header.type(), " before hello"); geulog::warn("twin", "TWIN: Ignoring message type=", header.type(), " before hello");
return; return;
@@ -480,26 +480,26 @@ void TwinLink::onFrameReceived(FramedTcpConnection* con,
switch (header.type()) switch (header.type())
{ {
case MsgTrunkHello::TYPE: case MsgPeerHello::TYPE:
handleMsgTrunkHello(ss, is_inbound); handleMsgPeerHello(ss, is_inbound);
break; break;
case MsgTrunkHeartbeat::TYPE: case MsgPeerHeartbeat::TYPE:
handleMsgTrunkHeartbeat(); handleMsgPeerHeartbeat();
break; break;
case MsgTrunkTalkerStart::TYPE: case MsgPeerTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss); handleMsgPeerTalkerStart(ss);
break; break;
case MsgTrunkTalkerStop::TYPE: case MsgPeerTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss); handleMsgPeerTalkerStop(ss);
break; break;
case MsgTrunkAudio::TYPE: case MsgPeerAudio::TYPE:
handleMsgTrunkAudio(ss); handleMsgPeerAudio(ss);
break; break;
case MsgTrunkFlush::TYPE: case MsgPeerFlush::TYPE:
handleMsgTrunkFlush(ss); handleMsgPeerFlush(ss);
break; break;
case MsgTrunkNodeList::TYPE: case MsgPeerNodeList::TYPE:
handleMsgTrunkNodeList(ss); handleMsgPeerNodeList(ss);
break; break;
case MsgTwinExtTalkerStart::TYPE: case MsgTwinExtTalkerStart::TYPE:
handleMsgTwinExtTalkerStart(ss); handleMsgTwinExtTalkerStart(ss);
@@ -514,7 +514,7 @@ void TwinLink::onFrameReceived(FramedTcpConnection* con,
} /* TwinLink::onFrameReceived */ } /* TwinLink::onFrameReceived */
void TwinLink::handleMsgTrunkHello(std::istream& is, bool is_inbound) void TwinLink::handleMsgPeerHello(std::istream& is, bool is_inbound)
{ {
// Inbound hellos are already handled by acceptInboundConnection. // Inbound hellos are already handled by acceptInboundConnection.
// A duplicate arriving here means the peer re-sent — ignore it silently. // A duplicate arriving here means the peer re-sent — ignore it silently.
@@ -524,14 +524,14 @@ void TwinLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
} }
// Hello on outbound = peer's reply to our outbound hello // Hello on outbound = peer's reply to our outbound hello
MsgTrunkHello msg; MsgPeerHello msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkHello"); geulog::error("twin", "TWIN: Failed to unpack MsgPeerHello");
return; return;
} }
if (msg.role() != MsgTrunkHello::ROLE_TWIN) if (msg.role() != MsgPeerHello::ROLE_TWIN)
{ {
geulog::error("twin", "TWIN: peer sent role=", int(msg.role()), geulog::error("twin", "TWIN: peer sent role=", int(msg.role()),
" but we expect ROLE_TWIN"); " but we expect ROLE_TWIN");
@@ -563,70 +563,70 @@ void TwinLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
geulog::info("twin", "TWIN: hello from partner '", msg.id(), geulog::info("twin", "TWIN: hello from partner '", msg.id(),
"' priority=", m_peer_priority, " (authenticated)"); "' priority=", m_peer_priority, " (authenticated)");
} /* TwinLink::handleMsgTrunkHello */ } /* TwinLink::handleMsgPeerHello */
void TwinLink::handleMsgTrunkTalkerStart(std::istream& is) void TwinLink::handleMsgPeerTalkerStart(std::istream& is)
{ {
MsgTrunkTalkerStart msg; MsgPeerTalkerStart msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkTalkerStart"); geulog::error("twin", "TWIN: Failed to unpack MsgPeerTalkerStart");
return; return;
} }
// setTrunkTalkerForTG fires trunkTalkerUpdated → onTrunkTalkerUpdated in // setTrunkTalkerForTG fires trunkTalkerUpdated → onTrunkTalkerUpdated in
// Reflector, which broadcasts MsgTalkerStart to all local clients on this TG. // Reflector, which broadcasts MsgTalkerStart to all local clients on this TG.
TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign()); TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign());
} /* TwinLink::handleMsgTrunkTalkerStart */ } /* TwinLink::handleMsgPeerTalkerStart */
void TwinLink::handleMsgTrunkTalkerStop(std::istream& is) void TwinLink::handleMsgPeerTalkerStop(std::istream& is)
{ {
MsgTrunkTalkerStop msg; MsgPeerTalkerStop msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkTalkerStop"); geulog::error("twin", "TWIN: Failed to unpack MsgPeerTalkerStop");
return; return;
} }
// clearTrunkTalkerForTG fires trunkTalkerUpdated → onTrunkTalkerUpdated, // clearTrunkTalkerForTG fires trunkTalkerUpdated → onTrunkTalkerUpdated,
// which broadcasts MsgTalkerStop and MsgUdpFlushSamples to local clients. // which broadcasts MsgTalkerStop and MsgUdpFlushSamples to local clients.
TGHandler::instance()->clearTrunkTalkerForTG(msg.tg()); TGHandler::instance()->clearTrunkTalkerForTG(msg.tg());
} /* TwinLink::handleMsgTrunkTalkerStop */ } /* TwinLink::handleMsgPeerTalkerStop */
void TwinLink::handleMsgTrunkAudio(std::istream& is) void TwinLink::handleMsgPeerAudio(std::istream& is)
{ {
MsgTrunkAudio msg; MsgPeerAudio msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkAudio"); geulog::error("twin", "TWIN: Failed to unpack MsgPeerAudio");
return; return;
} }
if (msg.audio().empty()) return; if (msg.audio().empty()) return;
MsgUdpAudio udp_msg(msg.audio()); MsgUdpAudio udp_msg(msg.audio());
m_reflector->broadcastUdpMsg(udp_msg, ReflectorClient::TgFilter(msg.tg())); m_reflector->broadcastUdpMsg(udp_msg, ReflectorClient::TgFilter(msg.tg()));
m_reflector->forwardAudioToSatellitesExcept(nullptr, msg.tg(), msg.audio()); m_reflector->forwardAudioToSatellitesExcept(nullptr, msg.tg(), msg.audio());
} /* TwinLink::handleMsgTrunkAudio */ } /* TwinLink::handleMsgPeerAudio */
void TwinLink::handleMsgTrunkFlush(std::istream& is) void TwinLink::handleMsgPeerFlush(std::istream& is)
{ {
MsgTrunkFlush msg; MsgPeerFlush msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkFlush"); geulog::error("twin", "TWIN: Failed to unpack MsgPeerFlush");
return; return;
} }
m_reflector->broadcastUdpMsg(MsgUdpFlushSamples(), m_reflector->broadcastUdpMsg(MsgUdpFlushSamples(),
ReflectorClient::TgFilter(msg.tg())); ReflectorClient::TgFilter(msg.tg()));
m_reflector->forwardFlushToSatellitesExcept(nullptr, msg.tg()); m_reflector->forwardFlushToSatellitesExcept(nullptr, msg.tg());
} /* TwinLink::handleMsgTrunkFlush */ } /* TwinLink::handleMsgPeerFlush */
void TwinLink::handleMsgTrunkHeartbeat(void) void TwinLink::handleMsgPeerHeartbeat(void)
{ {
// RX counter already reset in onFrameReceived // RX counter already reset in onFrameReceived
} /* TwinLink::handleMsgTrunkHeartbeat */ } /* TwinLink::handleMsgPeerHeartbeat */
void TwinLink::handleMsgTwinExtTalkerStart(std::istream& is) void TwinLink::handleMsgTwinExtTalkerStart(std::istream& is)
@@ -660,21 +660,21 @@ void TwinLink::handleMsgTwinExtTalkerStop(std::istream& is)
} /* TwinLink::handleMsgTwinExtTalkerStop */ } /* TwinLink::handleMsgTwinExtTalkerStop */
void TwinLink::handleMsgTrunkNodeList(std::istream& is) void TwinLink::handleMsgPeerNodeList(std::istream& is)
{ {
MsgTrunkNodeList msg; MsgPeerNodeList msg;
if (!msg.unpack(is)) if (!msg.unpack(is))
{ {
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkNodeList"); geulog::error("twin", "TWIN: Failed to unpack MsgPeerNodeList");
return; return;
} }
std::vector<MsgTrunkNodeList::NodeEntry> sanitized; std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size()); sanitized.reserve(msg.nodes().size());
unsigned dropped = 0; unsigned dropped = 0;
for (const auto& n : msg.nodes()) for (const auto& n : msg.nodes())
{ {
MsgTrunkNodeList::NodeEntry e; MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32); e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty()) if (e.callsign.empty())
{ {
@@ -705,7 +705,7 @@ void TwinLink::handleMsgTrunkNodeList(std::istream& is)
// the twin's peer_id. Keeps /status, MQTT and Redis consistent. // the twin's peer_id. Keeps /status, MQTT and Redis consistent.
m_reflector->onPeerNodeList(peerId(), sanitized); m_reflector->onPeerNodeList(peerId(), sanitized);
m_partner_nodes = std::move(sanitized); m_partner_nodes = std::move(sanitized);
} /* TwinLink::handleMsgTrunkNodeList */ } /* TwinLink::handleMsgPeerNodeList */
void TwinLink::clearPartnerRosterIfInactive(void) void TwinLink::clearPartnerRosterIfInactive(void)
@@ -717,7 +717,7 @@ void TwinLink::clearPartnerRosterIfInactive(void)
// clearPeerNode each callsign previously cached under peerId() in // clearPeerNode each callsign previously cached under peerId() in
// Redis and publish an empty list to MQTT. // Redis and publish an empty list to MQTT.
m_reflector->onPeerNodeList(peerId(), m_reflector->onPeerNodeList(peerId(),
std::vector<MsgTrunkNodeList::NodeEntry>{}); std::vector<MsgPeerNodeList::NodeEntry>{});
} /* TwinLink::clearPartnerRosterIfInactive */ } /* TwinLink::clearPartnerRosterIfInactive */
@@ -728,7 +728,7 @@ void TwinLink::heartbeatTick(Async::Timer* /*t*/)
{ {
if (++m_ob_hb_tx_cnt >= TWIN_HB_TX_THRESHOLD) if (++m_ob_hb_tx_cnt >= TWIN_HB_TX_THRESHOLD)
{ {
sendMsgOnOutbound(MsgTrunkHeartbeat()); sendMsgOnOutbound(MsgPeerHeartbeat());
m_ob_hb_tx_cnt = 0; m_ob_hb_tx_cnt = 0;
} }
if (++m_ob_hb_rx_cnt >= TWIN_HB_RX_THRESHOLD) if (++m_ob_hb_rx_cnt >= TWIN_HB_RX_THRESHOLD)
@@ -744,7 +744,7 @@ void TwinLink::heartbeatTick(Async::Timer* /*t*/)
{ {
if (++m_ib_hb_tx_cnt >= TWIN_HB_TX_THRESHOLD) if (++m_ib_hb_tx_cnt >= TWIN_HB_TX_THRESHOLD)
{ {
sendMsgOnInbound(MsgTrunkHeartbeat()); sendMsgOnInbound(MsgPeerHeartbeat());
m_ib_hb_tx_cnt = 0; m_ib_hb_tx_cnt = 0;
} }
if (++m_ib_hb_rx_cnt >= TWIN_HB_RX_THRESHOLD) if (++m_ib_hb_rx_cnt >= TWIN_HB_RX_THRESHOLD)
+10 -10
View File
@@ -86,7 +86,7 @@ class TwinLink
// Inbound path: the twin server accepted a connection and the hello // Inbound path: the twin server accepted a connection and the hello
// HMAC verified — hand it off here. // HMAC verified — hand it off here.
void acceptInboundConnection(Async::FramedTcpConnection* con, void acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello); const MsgPeerHello& hello);
// Called by Reflector when local TGHandler state changes // Called by Reflector when local TGHandler state changes
void onLocalTalkerUpdated(uint32_t tg, const std::string& callsign); void onLocalTalkerUpdated(uint32_t tg, const std::string& callsign);
@@ -104,7 +104,7 @@ class TwinLink
// Called by Reflector when the local node roster changes, to mirror // Called by Reflector when the local node roster changes, to mirror
// our connected-stations list to the twin partner. // our connected-stations list to the twin partner.
void onLocalNodeListUpdated( void onLocalNodeListUpdated(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes); const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
bool isActive(void) const; bool isActive(void) const;
const std::string& partnerHost(void) const { return m_peer_host; } const std::string& partnerHost(void) const { return m_peer_host; }
@@ -145,7 +145,7 @@ class TwinLink
bool m_ib_hello_received; bool m_ib_hello_received;
unsigned m_ib_hb_tx_cnt; unsigned m_ib_hb_tx_cnt;
unsigned m_ib_hb_rx_cnt; unsigned m_ib_hb_rx_cnt;
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes; std::vector<MsgPeerNodeList::NodeEntry> m_partner_nodes;
// No copy // No copy
TwinLink(const TwinLink&); TwinLink(const TwinLink&);
@@ -156,13 +156,13 @@ class TwinLink
Async::TcpConnection::DisconnectReason reason); Async::TcpConnection::DisconnectReason reason);
void onFrameReceived(Async::FramedTcpConnection* con, void onFrameReceived(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data); std::vector<uint8_t>& data);
void handleMsgTrunkHello(std::istream& is, bool is_inbound); void handleMsgPeerHello(std::istream& is, bool is_inbound);
void handleMsgTrunkTalkerStart(std::istream& is); void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgTrunkTalkerStop(std::istream& is); void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgTrunkAudio(std::istream& is); void handleMsgPeerAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is); void handleMsgPeerFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void); void handleMsgPeerHeartbeat(void);
void handleMsgTrunkNodeList(std::istream& is); void handleMsgPeerNodeList(std::istream& is);
void clearPartnerRosterIfInactive(void); void clearPartnerRosterIfInactive(void);
void handleMsgTwinExtTalkerStart(std::istream& is); void handleMsgTwinExtTalkerStart(std::istream& is);
void handleMsgTwinExtTalkerStop(std::istream& is); void handleMsgTwinExtTalkerStop(std::istream& is);
+1 -1
View File
@@ -178,7 +178,7 @@ CERT_CA_HOOK=@SVX_SHARE_INSTALL_DIR@/ca-hook.py
# Optional TG filter — restricts which TGs this satellite cares about. # Optional TG filter — restricts which TGs this satellite cares about.
# Applied in both directions: the satellite skips sending local events for # Applied in both directions: the satellite skips sending local events for
# non-matching TGs, and advertises the filter to the parent via # non-matching TGs, and advertises the filter to the parent via
# MsgTrunkFilter (type 122) so the parent skips forwarding them back. # MsgPeerFilter (type 122) so the parent skips forwarding them back.
# Syntax: exact "26200", prefix "24*", range "2427-2438", comma-separated. # Syntax: exact "26200", prefix "24*", range "2427-2438", comma-separated.
# Empty or absent = no filtering (all TGs pass in both directions). # Empty or absent = no filtering (all TGs pass in both directions).
#SATELLITE_FILTER=24*,262* #SATELLITE_FILTER=24*,262*