diff --git a/Constants.cs b/Constants.cs index cfe719b..fb18c66 100644 --- a/Constants.cs +++ b/Constants.cs @@ -141,7 +141,6 @@ namespace fnecore public const uint RtpGenericClockRate = 8000; public const byte DVMRtpPayloadType = 0x56; - public const byte DVMRtpControlPayloadType = 0x57; public const byte DVMFrameStart = 0xFE; /* @@ -179,6 +178,12 @@ namespace fnecore public const byte NET_TRANSFER_SUBFUNC_ACTIVITY = 0x01; // Activity Log Transfer public const byte NET_TRANSFER_SUBFUNC_DIAG = 0x02; // Diagnostic Log Transfer + public const byte NET_FUNC_ANNOUNCE = 0x91U; // Network Announce Function + public const byte NET_ANNC_SUBFUNC_GRP_AFFIL = 0x00U; // Announce Group Affiliation + public const byte NET_ANNC_SUBFUNC_UNIT_REG = 0x01U; // Announce Unit Registration + public const byte NET_ANNC_SUBFUNC_UNIT_DEREG = 0x02U; // Announce Unit Deregistration + public const byte NET_ANNC_SUBFUNC_AFFILS = 0x90U; // Update All Affiliations + /* ** Protocol Tags (as strings) */ diff --git a/FneMaster.cs b/FneMaster.cs index 20c544f..7e17304 100644 --- a/FneMaster.cs +++ b/FneMaster.cs @@ -7,7 +7,7 @@ * @package DVM / Fixed Network Equipment Core Library * @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0) * -* Copyright (C) 2022-2023 Bryan Biedenkapp, N2PLL +* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL * */ @@ -217,6 +217,21 @@ namespace fnecore /// public Action DiagnosticTransfer = null; + /// + /// Event action that handles peer unit registration announcements. + /// + public Action UnitRegistration = null; + + /// + /// Event action that handles peer unit deregistration announcements + /// + public Action UnitDeregistration = null; + + /// + /// Event action that handles peer group affiliation announcements + /// + public Action UnitGroupAffiliation = null; + /* ** Methods */ @@ -1104,6 +1119,65 @@ namespace fnecore } break; + case Constants.NET_FUNC_ANNOUNCE: + { + else if (fneHeader.SubFunction == Constants.NET_ANNC_SUBFUNC_GRP_AFFIL) // Announce Group Affiliation + { + // can we do activity transfers? + if (AllowActivityTransfer) + { + if (peerId > 0 && peers.ContainsKey(peerId)) + { + // validate peer (simple validation really + if (peers[peerId].Connection && peers[peerId].EndPoint.ToString() == frame.Endpoint.ToString()) + { + uint srcId = FneUtils.Bytes3ToUInt32(buffer, 0); + uint dstId = FneUtils.Bytes3ToUInt32(buffer, 3); + if (UnitGroupAffiliation != null) + UnitGroupAffiliation(peerId, srcId, dstId); + } + } + } + } + else if (fneHeader.SubFunction == Constants.NET_ANNC_SUBFUNC_UNIT_REG) // Announce Unit Registration + { + // can we do activity transfers? + if (AllowActivityTransfer) + { + if (peerId > 0 && peers.ContainsKey(peerId)) + { + // validate peer (simple validation really + if (peers[peerId].Connection && peers[peerId].EndPoint.ToString() == frame.Endpoint.ToString()) + { + uint srcId = FneUtils.Bytes3ToUInt32(buffer, 0); + if (UnitRegistration != null) + UnitRegistration(peerId, srcId); + } + } + } + } + else if (fneHeader.SubFunction == Constants.NET_ANNC_SUBFUNC_UNIT_DEREG) // Announce Unit Deregistration + { + // can we do diagnostic transfers? + if (AllowDiagnosticTransfer) + { + if (peerId > 0 && peers.ContainsKey(peerId)) + { + // validate peer (simple validation really) + if (peers[peerId].Connection && peers[peerId].EndPoint.ToString() == frame.Endpoint.ToString()) + { + uint srcId = FneUtils.Bytes3ToUInt32(buffer, 0); + if (UnitDeregistration != null) + UnitDeregistration(peerId, srcId); + } + } + } + } + else + Log(LogLevel.ERROR, $"({systemName}) Unknown transfer opcode {FneUtils.BytesToString(message, 0, 4)} -- {FneUtils.HexDump(message, 0)}"); + } + break; + default: Log(LogLevel.ERROR, $"({systemName}) Unknown opcode {FneUtils.BytesToString(message, 0, 4)} -- {FneUtils.HexDump(message, 0)}"); break;