// SPDX-License-Identifier: AGPL-3.0-only /** * Digital Voice Modem - Desktop Dispatch Console * AGPLv3 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * @package DVM / Desktop Dispatch Console * @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0) * * Copyright (C) 2024-2025 Caleb, K4PHP * Copyright (C) 2025 Bryan Biedenkapp, N2PLL * */ using fnecore.P25; namespace dvmconsole { /// /// Codeplug object used to configure the console. /// public class Codeplug { /* ** Properties */ /// /// /// public List Systems { get; set; } /// /// /// public List Zones { get; set; } /* ** Classes */ /// /// /// public class System { /* ** Properties */ /// /// /// public string Name { get; set; } /// /// /// public string Identity { get; set; } /// /// /// public string Address { get; set; } /// /// /// public string Password { get; set; } /// /// /// public string PresharedKey { get; set; } /// /// /// public bool Encrypted { get; set; } /// /// /// public uint PeerId { get; set; } /// /// /// public int Port { get; set; } /// /// /// public string Rid { get; set; } /// /// /// public string AliasPath { get; set; } = "./alias.yml"; /// /// /// public List RidAlias { get; set; } = null; /* ** Methods */ /// /// /// /// public override string ToString() { return Name; } } // public class System /// /// /// public class Zone { /* ** Properties */ /// /// /// public string Name { get; set; } /// /// /// public List Channels { get; set; } } // public class Zone /// /// /// public class Channel { /* ** Properties */ /// /// /// public string Name { get; set; } /// /// /// public string System { get; set; } /// /// /// public string Tgid { get; set; } /// /// /// public string EncryptionKey { get; set; } /// /// /// public string Algo { get; set; } = "none"; /// /// /// public string KeyId { get; set; } /* ** Methods */ /// /// /// /// public ushort GetKeyId() { return Convert.ToUInt16(KeyId, 16); } /// /// /// /// public byte GetAlgoId() { switch (Algo.ToLowerInvariant()) { case "aes": return P25Defines.P25_ALGO_AES; case "arc4": return P25Defines.P25_ALGO_ARC4; default: return P25Defines.P25_ALGO_UNENCRYPT; } } /// /// /// /// public byte[] GetEncryptionKey() { if (EncryptionKey == null) return []; return EncryptionKey.Split(',').Select(s => Convert.ToByte(s.Trim(), 16)).ToArray(); } } // public class Channel /// /// Helper to return a system by looking up a /// /// /// public System GetSystemForChannel(Channel channel) { return Systems.FirstOrDefault(s => s.Name == channel.System); } /// /// Helper to return a system by looking up a channel name /// /// /// public System GetSystemForChannel(string channelName) { foreach (var zone in Zones) { var channel = zone.Channels.FirstOrDefault(c => c.Name == channelName); if (channel != null) return Systems.FirstOrDefault(s => s.Name == channel.System); } return null; } /// /// Helper to return a by channel name /// /// /// public Channel GetChannelByName(string channelName) { foreach (var zone in Zones) { var channel = zone.Channels.FirstOrDefault(c => c.Name == channelName); if (channel != null) return channel; } return null; } } //public class Codeplug } // namespace dvmconsole