From a2fa303217a7bfcc9824c1e520bef191aea1f27b Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Wed, 19 Mar 2025 10:18:13 -0400 Subject: [PATCH] reorganize code, move Network class from host into common as its being used more as a generic peer network class; add some warning messaging to the FNE when a peer link or external peer (i.e. intra-FNE connection) drops; --- src/CMakeLists.txt | 4 +- src/bridge/CMakeLists.txt | 3 - src/bridge/network/PeerNetwork.cpp | 28 +++---- src/bridge/network/PeerNetwork.h | 2 +- src/{host => common}/network/Network.cpp | 97 +++++++++++---------- src/{host => common}/network/Network.h | 102 ++++++++++++++++------- src/fne/CMakeLists.txt | 3 - src/fne/network/FNENetwork.cpp | 13 +++ src/fne/network/FNENetwork.h | 2 +- src/fne/network/PeerNetwork.cpp | 30 +++---- src/fne/network/PeerNetwork.h | 4 +- src/host/Host.h | 2 +- src/host/dmr/Control.h | 2 +- src/host/dmr/Slot.h | 2 +- src/host/nxdn/Control.h | 2 +- src/host/p25/Control.h | 2 +- src/sysview/CMakeLists.txt | 2 - src/sysview/network/PeerNetwork.cpp | 32 +++---- src/sysview/network/PeerNetwork.h | 19 +++-- 19 files changed, 201 insertions(+), 150 deletions(-) rename src/{host => common}/network/Network.cpp (94%) rename src/{host => common}/network/Network.h (76%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 82dae26b..a55f5332 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,7 +77,7 @@ include(CPack) include(src/fne/CMakeLists.txt) add_executable(dvmfne ${common_INCLUDE} ${dvmfne_SRC}) target_link_libraries(dvmfne PRIVATE common ${OPENSSL_LIBRARIES} asio::asio Threads::Threads) -target_include_directories(dvmfne PRIVATE ${OPENSSL_INCLUDE_DIR} src src/host src/fne) +target_include_directories(dvmfne PRIVATE ${OPENSSL_INCLUDE_DIR} src src/fne) # ## dvmmon @@ -141,4 +141,4 @@ if (COMPILE_WIN32) else () target_link_libraries(dvmbridge PRIVATE common vocoder ${OPENSSL_LIBRARIES} dl asio::asio Threads::Threads) endif (COMPILE_WIN32) -target_include_directories(dvmbridge PRIVATE ${OPENSSL_INCLUDE_DIR} src src/host src/bridge) +target_include_directories(dvmbridge PRIVATE ${OPENSSL_INCLUDE_DIR} src src/bridge) diff --git a/src/bridge/CMakeLists.txt b/src/bridge/CMakeLists.txt index cb0add19..647081a2 100644 --- a/src/bridge/CMakeLists.txt +++ b/src/bridge/CMakeLists.txt @@ -8,9 +8,6 @@ # * # */ file(GLOB bridge_SRC - "src/host/network/Network.h" - "src/host/network/Network.cpp" - "src/bridge/audio/*.h" "src/bridge/audio/*.c" diff --git a/src/bridge/network/PeerNetwork.cpp b/src/bridge/network/PeerNetwork.cpp index 9e782161..bb82c167 100644 --- a/src/bridge/network/PeerNetwork.cpp +++ b/src/bridge/network/PeerNetwork.cpp @@ -159,32 +159,32 @@ bool PeerNetwork::writeConfig() json::object config = json::object(); // identity and frequency - config["identity"].set(m_identity); // Identity - config["rxFrequency"].set(m_rxFrequency); // Rx Frequency - config["txFrequency"].set(m_txFrequency); // Tx Frequency + config["identity"].set(m_metadata->identity); // Identity + config["rxFrequency"].set(m_metadata->rxFrequency); // Rx Frequency + config["txFrequency"].set(m_metadata->txFrequency); // Tx Frequency // system info json::object sysInfo = json::object(); - sysInfo["latitude"].set(m_latitude); // Latitude - sysInfo["longitude"].set(m_longitude); // Longitude + sysInfo["latitude"].set(m_metadata->latitude); // Latitude + sysInfo["longitude"].set(m_metadata->longitude); // Longitude - sysInfo["height"].set(m_height); // Height - sysInfo["location"].set(m_location); // Location + sysInfo["height"].set(m_metadata->height); // Height + sysInfo["location"].set(m_metadata->location); // Location config["info"].set(sysInfo); // channel data json::object channel = json::object(); - channel["txPower"].set(m_power); // Tx Power - channel["txOffsetMhz"].set(m_txOffsetMhz); // Tx Offset (Mhz) - channel["chBandwidthKhz"].set(m_chBandwidthKhz); // Ch. Bandwidth (khz) - channel["channelId"].set(m_channelId); // Channel ID - channel["channelNo"].set(m_channelNo); // Channel No + channel["txPower"].set(m_metadata->power); // Tx Power + channel["txOffsetMhz"].set(m_metadata->txOffsetMhz); // Tx Offset (Mhz) + channel["chBandwidthKhz"].set(m_metadata->chBandwidthKhz); // Ch. Bandwidth (khz) + channel["channelId"].set(m_metadata->channelId); // Channel ID + channel["channelNo"].set(m_metadata->channelNo); // Channel No config["channel"].set(channel); // RCON json::object rcon = json::object(); - rcon["password"].set(m_restApiPassword); // REST API Password - rcon["port"].set(m_restApiPort); // REST API Port + rcon["password"].set(m_metadata->restApiPassword); // REST API Password + rcon["port"].set(m_metadata->restApiPort); // REST API Port config["rcon"].set(rcon); config["software"].set(std::string(software)); // Software ID diff --git a/src/bridge/network/PeerNetwork.h b/src/bridge/network/PeerNetwork.h index 436f3693..0d58146a 100644 --- a/src/bridge/network/PeerNetwork.h +++ b/src/bridge/network/PeerNetwork.h @@ -22,7 +22,7 @@ #include "Defines.h" #include "common/dmr/data/EmbeddedData.h" -#include "host/network/Network.h" +#include "common/network/Network.h" #include #include diff --git a/src/host/network/Network.cpp b/src/common/network/Network.cpp similarity index 94% rename from src/host/network/Network.cpp rename to src/common/network/Network.cpp index 632e71f9..e288e8eb 100644 --- a/src/host/network/Network.cpp +++ b/src/common/network/Network.cpp @@ -1,10 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Digital Voice Modem - Modem Host Software + * Digital Voice Modem - Common Library * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX * Copyright (C) 2017-2025 Bryan Biedenkapp, N2PLL * */ @@ -56,23 +55,10 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort, m_timeoutTimer(1000U, 60U), m_pktSeq(0U), m_loginStreamId(0U), - m_identity(), - m_rxFrequency(0U), - m_txFrequency(0U), - m_txOffsetMhz(0.0F), - m_chBandwidthKhz(0.0F), - m_channelId(0U), - m_channelNo(0U), - m_power(0U), - m_latitude(0.0F), - m_longitude(0.0F), - m_height(0), - m_location(), - m_restApiPassword(), - m_restApiPort(0), - m_conventional(false), + m_metadata(nullptr), m_remotePeerId(0U), m_promiscuousPeer(false), + m_userHandleProtocol(false), m_dmrInCallCallback(nullptr), m_p25InCallCallback(nullptr), m_nxdnInCallCallback(nullptr), @@ -89,6 +75,8 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort, m_rxDMRStreamId[1U] = 0U; m_rxP25StreamId = 0U; m_rxNXDNStreamId = 0U; + + m_metadata = new PeerMetadata(); } /* Finalizes a instance of the Network class. */ @@ -97,6 +85,7 @@ Network::~Network() { delete[] m_salt; delete[] m_rxDMRStreamId; + delete m_metadata; } /* Resets the DMR ring buffer for the given slot. */ @@ -143,28 +132,29 @@ void Network::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRu void Network::setMetadata(const std::string& identity, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz, uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location) { - m_identity = identity; - m_rxFrequency = rxFrequency; - m_txFrequency = txFrequency; - - m_txOffsetMhz = txOffsetMhz; - m_chBandwidthKhz = chBandwidthKhz; - m_channelId = channelId; - m_channelNo = channelNo; - - m_power = power; - m_latitude = latitude; - m_longitude = longitude; - m_height = height; - m_location = location; + m_metadata->identity = identity; + + m_metadata->rxFrequency = rxFrequency; + m_metadata->txFrequency = txFrequency; + + m_metadata->txOffsetMhz = txOffsetMhz; + m_metadata->chBandwidthKhz = chBandwidthKhz; + m_metadata->channelId = channelId; + m_metadata->channelNo = channelNo; + + m_metadata->power = power; + m_metadata->latitude = latitude; + m_metadata->longitude = longitude; + m_metadata->height = height; + m_metadata->location = location; } /* Sets REST API configuration settings from the modem. */ void Network::setRESTAPIData(const std::string& password, uint16_t port) { - m_restApiPassword = password; - m_restApiPort = port; + m_metadata->restApiPassword = password; + m_metadata->restApiPort = port; } /* Sets endpoint preshared encryption key. */ @@ -265,6 +255,13 @@ void Network::clock(uint32_t ms) switch (fneHeader.getFunction()) { case NET_FUNC::PROTOCOL: { + // are protocol messages being user handled? + if (m_userHandleProtocol) { + userPacketHandler(fneHeader.getPeerId(), { fneHeader.getFunction(), fneHeader.getSubFunction() }, + buffer.get(), length, fneHeader.getStreamId()); + break; + } + if (fneHeader.getSubFunction() == NET_SUBFUNC::PROTOCOL_SUBFUNC_DMR) { // Encapsulated DMR data frame if (m_enabled && m_dmrEnabled) { uint32_t slotNo = (buffer[15U] & 0x80U) == 0x80U ? 1U : 0U; // this is the raw index for the stream ID array @@ -931,36 +928,38 @@ bool Network::writeConfig() json::object config = json::object(); // identity and frequency - config["identity"].set(m_identity); // Identity - config["rxFrequency"].set(m_rxFrequency); // Rx Frequency - config["txFrequency"].set(m_txFrequency); // Tx Frequency + config["identity"].set(m_metadata->identity); // Identity + config["rxFrequency"].set(m_metadata->rxFrequency); // Rx Frequency + config["txFrequency"].set(m_metadata->txFrequency); // Tx Frequency // system info json::object sysInfo = json::object(); - sysInfo["latitude"].set(m_latitude); // Latitude - sysInfo["longitude"].set(m_longitude); // Longitude + sysInfo["latitude"].set(m_metadata->latitude); // Latitude + sysInfo["longitude"].set(m_metadata->longitude); // Longitude - sysInfo["height"].set(m_height); // Height - sysInfo["location"].set(m_location); // Location + sysInfo["height"].set(m_metadata->height); // Height + sysInfo["location"].set(m_metadata->location); // Location config["info"].set(sysInfo); // channel data json::object channel = json::object(); - channel["txPower"].set(m_power); // Tx Power - channel["txOffsetMhz"].set(m_txOffsetMhz); // Tx Offset (Mhz) - channel["chBandwidthKhz"].set(m_chBandwidthKhz); // Ch. Bandwidth (khz) - channel["channelId"].set(m_channelId); // Channel ID - channel["channelNo"].set(m_channelNo); // Channel No + channel["txPower"].set(m_metadata->power); // Tx Power + channel["txOffsetMhz"].set(m_metadata->txOffsetMhz); // Tx Offset (Mhz) + channel["chBandwidthKhz"].set(m_metadata->chBandwidthKhz); // Ch. Bandwidth (khz) + channel["channelId"].set(m_metadata->channelId); // Channel ID + channel["channelNo"].set(m_metadata->channelNo); // Channel No config["channel"].set(channel); // RCON json::object rcon = json::object(); - rcon["password"].set(m_restApiPassword); // REST API Password - rcon["port"].set(m_restApiPort); // REST API Port + rcon["password"].set(m_metadata->restApiPassword); // REST API Password + rcon["port"].set(m_metadata->restApiPort); // REST API Port config["rcon"].set(rcon); - config["conventionalPeer"].set(m_conventional); // Conventional Peer Marker - config["software"].set(std::string(software)); // Software ID + // Flags + config["conventionalPeer"].set(m_metadata->isConventional); // Conventional Peer Marker + + config["software"].set(std::string(software)); json::value v = json::value(config); std::string json = v.serialize(); diff --git a/src/host/network/Network.h b/src/common/network/Network.h similarity index 76% rename from src/host/network/Network.h rename to src/common/network/Network.h index 53489cad..b7d75809 100644 --- a/src/host/network/Network.h +++ b/src/common/network/Network.h @@ -1,27 +1,22 @@ // SPDX-License-Identifier: GPL-2.0-only /** -* Digital Voice Modem - Modem Host Software + * Digital Voice Modem - Common Library * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * -* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2023 Bryan Biedenkapp, N2PLL +* Copyright (C) 2017-2025 Bryan Biedenkapp, N2PLL * */ /** - * @defgroup network Host Networking - * @brief Implementation for the host networking. - * @ingroup host - * * @file Network.h - * @ingroup network + * @ingroup network_core * @file Network.cpp - * @ingroup network + * @ingroup network_core */ #if !defined(__NETWORK_H__) #define __NETWORK_H__ -#include "Defines.h" +#include "common/Defines.h" #include "common/network/BaseNetwork.h" #include "common/lookups/RadioIdLookup.h" #include "common/lookups/TalkgroupRulesLookup.h" @@ -33,6 +28,46 @@ namespace network { + // --------------------------------------------------------------------------- + // Structure Declaration + // --------------------------------------------------------------------------- + + /** + * @brief This structure represents a peer metadata. + * @ingroup network_core + */ + struct PeerMetadata { + /** @name Identity and Frequency */ + std::string identity; //! Peer Identity + uint32_t rxFrequency; //! Peer Rx Frequency + uint32_t txFrequency; //! Peer Tx Frequency + /** @} */ + + /** @name System Info */ + uint32_t power; //! Peer Tx Power (W) + float latitude; //! Location Latitude (decmial notation) + float longitude; //! Location Longitude (decmial notation) + int height; //! Height (M) + std::string location; //! Textual Location + /** @} */ + + /** @name Channel Data */ + float txOffsetMhz; //! Tx Offset (MHz) + float chBandwidthKhz; //! Channel Bandwidth (kHz) + uint8_t channelId; //! Channel ID + uint32_t channelNo; //! Channel Number + /** @} */ + + /** @name RCON */ + std::string restApiPassword; //! REST API Password + uint16_t restApiPort; //! REST API Port + /** @} */ + + /** @name Flags */ + bool isConventional; //! Flag indicating peer is a conventional peer. + /** @} */ + }; + // --------------------------------------------------------------------------- // Class Declaration // --------------------------------------------------------------------------- @@ -115,7 +150,7 @@ namespace network * @brief Sets a flag indicating whether the conventional option is sent to the FNE. * @param conv Flag indicating conventional operation. */ - void setConventional(bool conv) { m_conventional = conv; } + void setConventional(bool conv) { m_metadata->isConventional = conv; } /** * @brief Sets endpoint preshared encryption key. * @param presharedKey Encryption preshared key for networking. @@ -208,35 +243,40 @@ namespace network uint16_t m_pktSeq; uint32_t m_loginStreamId; - /** station metadata */ - std::string m_identity; - uint32_t m_rxFrequency; - uint32_t m_txFrequency; - - float m_txOffsetMhz; - float m_chBandwidthKhz; - uint8_t m_channelId; - uint32_t m_channelNo; - - uint32_t m_power; - float m_latitude; - float m_longitude; - int m_height; - std::string m_location; - - std::string m_restApiPassword; - uint16_t m_restApiPort; - - bool m_conventional; + PeerMetadata* m_metadata; uint32_t m_remotePeerId; + /** + * @brief Flag indicating this peer will not perform peer ID checking and will process most incoming packets. + */ bool m_promiscuousPeer; + /** + * @brief Flag indicating this peer will not handle protocol processing internally, and will forward processing + * to the defined user packet handler. + */ + bool m_userHandleProtocol; + /** + * @brief DMR In-Call Control Function Callback. + * (This is called when the master sends a In-Call Control request.) + */ std::function m_dmrInCallCallback; + /** + * @brief P25 In-Call Control Function Callback. + * (This is called once the master sends a In-Call Control request.) + */ std::function m_p25InCallCallback; + /** + * @brief NXDN In-Call Control Function Callback. + * (This is called once the master sends a In-Call Control request.) + */ std::function m_nxdnInCallCallback; + /** + * @brief Encryption Key Response Function Callback. + * (This is called once the master responds to a key request.) + */ std::function m_keyRespCallback; /** diff --git a/src/fne/CMakeLists.txt b/src/fne/CMakeLists.txt index c7fdd654..695a0bac 100644 --- a/src/fne/CMakeLists.txt +++ b/src/fne/CMakeLists.txt @@ -8,9 +8,6 @@ # * # */ file(GLOB dvmfne_SRC - "src/host/network/Network.h" - "src/host/network/Network.cpp" - "src/fne/network/callhandler/*.h" "src/fne/network/callhandler/*.cpp" "src/fne/network/callhandler/packetdata/*.h" diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index 7d1ff244..e15b04d4 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -303,6 +303,19 @@ void FNENetwork::clock(uint32_t ms) if (dt < now) { LogInfoEx(LOG_NET, "PEER %u (%s) timed out, dt = %u, now = %u", id, connection->identity().c_str(), dt, now); + + // set connection states for this stale connection + connection->connected(false); + connection->connectionState(NET_STAT_INVALID); + + // if the connection was an external peer or a peer link -- be noisy about a possible + // netsplit + if (connection->isExternalPeer() || connection->isPeerLink()) { + for (uint8_t i = 0U; i < 3U; i++) + LogWarning(LOG_NET, "PEER %u (%s) downstream netsplit, dt = %u, now = %u", id, connection->identity().c_str(), + dt, now); + } + peersToRemove.push_back(id); } } diff --git a/src/fne/network/FNENetwork.h b/src/fne/network/FNENetwork.h index 87989c72..d2f9a4d6 100644 --- a/src/fne/network/FNENetwork.h +++ b/src/fne/network/FNENetwork.h @@ -31,9 +31,9 @@ #include "common/lookups/RadioIdLookup.h" #include "common/lookups/TalkgroupRulesLookup.h" #include "common/lookups/PeerListLookup.h" +#include "common/network/Network.h" #include "fne/network/influxdb/InfluxDB.h" #include "fne/CryptoContainer.h" -#include "host/network/Network.h" #include #include diff --git a/src/fne/network/PeerNetwork.cpp b/src/fne/network/PeerNetwork.cpp index b2397242..c1f812e9 100644 --- a/src/fne/network/PeerNetwork.cpp +++ b/src/fne/network/PeerNetwork.cpp @@ -565,36 +565,38 @@ bool PeerNetwork::writeConfig() json::object config = json::object(); // identity and frequency - config["identity"].set(m_identity); // Identity - config["rxFrequency"].set(m_rxFrequency); // Rx Frequency - config["txFrequency"].set(m_txFrequency); // Tx Frequency + config["identity"].set(m_metadata->identity); // Identity + config["rxFrequency"].set(m_metadata->rxFrequency); // Rx Frequency + config["txFrequency"].set(m_metadata->txFrequency); // Tx Frequency // system info json::object sysInfo = json::object(); - sysInfo["latitude"].set(m_latitude); // Latitude - sysInfo["longitude"].set(m_longitude); // Longitude + sysInfo["latitude"].set(m_metadata->latitude); // Latitude + sysInfo["longitude"].set(m_metadata->longitude); // Longitude - sysInfo["height"].set(m_height); // Height - sysInfo["location"].set(m_location); // Location + sysInfo["height"].set(m_metadata->height); // Height + sysInfo["location"].set(m_metadata->location); // Location config["info"].set(sysInfo); // channel data json::object channel = json::object(); - channel["txPower"].set(m_power); // Tx Power - channel["txOffsetMhz"].set(m_txOffsetMhz); // Tx Offset (Mhz) - channel["chBandwidthKhz"].set(m_chBandwidthKhz); // Ch. Bandwidth (khz) - channel["channelId"].set(m_channelId); // Channel ID - channel["channelNo"].set(m_channelNo); // Channel No + channel["txPower"].set(m_metadata->power); // Tx Power + channel["txOffsetMhz"].set(m_metadata->txOffsetMhz); // Tx Offset (Mhz) + channel["chBandwidthKhz"].set(m_metadata->chBandwidthKhz); // Ch. Bandwidth (khz) + channel["channelId"].set(m_metadata->channelId); // Channel ID + channel["channelNo"].set(m_metadata->channelNo); // Channel No config["channel"].set(channel); // RCON json::object rcon = json::object(); - rcon["password"].set(m_restApiPassword); // REST API Password - rcon["port"].set(m_restApiPort); // REST API Port + rcon["password"].set(m_metadata->restApiPassword); // REST API Password + rcon["port"].set(m_metadata->restApiPort); // REST API Port config["rcon"].set(rcon); + // Flags bool external = true; config["externalPeer"].set(external); // External Peer Marker + config["software"].set(std::string(software)); // Software ID json::value v = json::value(config); diff --git a/src/fne/network/PeerNetwork.h b/src/fne/network/PeerNetwork.h index efb88a9b..748e238f 100644 --- a/src/fne/network/PeerNetwork.h +++ b/src/fne/network/PeerNetwork.h @@ -18,7 +18,7 @@ #include "Defines.h" #include "common/lookups/PeerListLookup.h" -#include "host/network/Network.h" +#include "common/network/Network.h" #include #include @@ -31,7 +31,7 @@ namespace network // --------------------------------------------------------------------------- /** - * @brief Implements the core peer networking logic. + * @brief Implements the FNE peer networking logic. * @ingroup fne_network */ class HOST_SW_API PeerNetwork : public Network { diff --git a/src/host/Host.h b/src/host/Host.h index 0dd04fb9..aaccb0fe 100644 --- a/src/host/Host.h +++ b/src/host/Host.h @@ -33,11 +33,11 @@ #include "common/lookups/RadioIdLookup.h" #include "common/lookups/TalkgroupRulesLookup.h" #include "common/network/json/json.h" +#include "common/network/Network.h" #include "common/yaml/Yaml.h" #include "dmr/Control.h" #include "p25/Control.h" #include "nxdn/Control.h" -#include "network/Network.h" #include "network/RESTAPI.h" #include "modem/Modem.h" #include "modem/ModemV24.h" diff --git a/src/host/dmr/Control.h b/src/host/dmr/Control.h index d4ae8323..5e8f6931 100644 --- a/src/host/dmr/Control.h +++ b/src/host/dmr/Control.h @@ -32,11 +32,11 @@ #include "common/lookups/RadioIdLookup.h" #include "common/lookups/TalkgroupRulesLookup.h" #include "common/network/RTPFNEHeader.h" +#include "common/network/Network.h" #include "common/yaml/Yaml.h" #include "dmr/lookups/DMRAffiliationLookup.h" #include "dmr/Slot.h" #include "modem/Modem.h" -#include "network/Network.h" namespace dmr { diff --git a/src/host/dmr/Slot.h b/src/host/dmr/Slot.h index 543e2075..277af5c5 100644 --- a/src/host/dmr/Slot.h +++ b/src/host/dmr/Slot.h @@ -23,6 +23,7 @@ #include "common/lookups/IdenTableLookup.h" #include "common/lookups/RadioIdLookup.h" #include "common/lookups/TalkgroupRulesLookup.h" +#include "common/network/Network.h" #include "common/RingBuffer.h" #include "common/StopWatch.h" #include "common/Timer.h" @@ -32,7 +33,6 @@ #include "dmr/packet/Data.h" #include "dmr/packet/Voice.h" #include "modem/Modem.h" -#include "network/Network.h" #include #include diff --git a/src/host/nxdn/Control.h b/src/host/nxdn/Control.h index 08b272b3..b1d66ec6 100644 --- a/src/host/nxdn/Control.h +++ b/src/host/nxdn/Control.h @@ -32,6 +32,7 @@ #include "common/lookups/TalkgroupRulesLookup.h" #include "common/lookups/AffiliationLookup.h" #include "common/network/RTPFNEHeader.h" +#include "common/network/Network.h" #include "common/RingBuffer.h" #include "common/StopWatch.h" #include "common/Timer.h" @@ -39,7 +40,6 @@ #include "nxdn/packet/Voice.h" #include "nxdn/packet/ControlSignaling.h" #include "nxdn/packet/Data.h" -#include "network/Network.h" #include "modem/Modem.h" #include diff --git a/src/host/p25/Control.h b/src/host/p25/Control.h index 6b0d7a0c..e5476eec 100644 --- a/src/host/p25/Control.h +++ b/src/host/p25/Control.h @@ -32,6 +32,7 @@ #include "common/lookups/RadioIdLookup.h" #include "common/lookups/TalkgroupRulesLookup.h" #include "common/network/RTPFNEHeader.h" +#include "common/network/Network.h" #include "common/p25/SiteData.h" #include "common/RingBuffer.h" #include "common/StopWatch.h" @@ -40,7 +41,6 @@ #include "p25/packet/Data.h" #include "p25/packet/Voice.h" #include "p25/packet/ControlSignaling.h" -#include "network/Network.h" #include "p25/lookups/P25AffiliationLookup.h" #include "modem/Modem.h" diff --git a/src/sysview/CMakeLists.txt b/src/sysview/CMakeLists.txt index 1d9459e0..fef875be 100644 --- a/src/sysview/CMakeLists.txt +++ b/src/sysview/CMakeLists.txt @@ -9,8 +9,6 @@ # */ file(GLOB sysView_SRC "src/host/modem/Modem.h" - "src/host/network/Network.h" - "src/host/network/Network.cpp" "src/remote/RESTClient.cpp" "src/remote/RESTClient.h" diff --git a/src/sysview/network/PeerNetwork.cpp b/src/sysview/network/PeerNetwork.cpp index 1de24f5d..043de10a 100644 --- a/src/sysview/network/PeerNetwork.cpp +++ b/src/sysview/network/PeerNetwork.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: PROPRIETARY /* - * Digital Voice Modem - FNE Affiliations View + * Digital Voice Modem - FNE System View * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -426,40 +426,42 @@ bool PeerNetwork::writeConfig() json::object config = json::object(); // identity and frequency - config["identity"].set(m_identity); // Identity - config["rxFrequency"].set(m_rxFrequency); // Rx Frequency - config["txFrequency"].set(m_txFrequency); // Tx Frequency + config["identity"].set(m_metadata->identity); // Identity + config["rxFrequency"].set(m_metadata->rxFrequency); // Rx Frequency + config["txFrequency"].set(m_metadata->txFrequency); // Tx Frequency // system info json::object sysInfo = json::object(); - sysInfo["latitude"].set(m_latitude); // Latitude - sysInfo["longitude"].set(m_longitude); // Longitude + sysInfo["latitude"].set(m_metadata->latitude); // Latitude + sysInfo["longitude"].set(m_metadata->longitude); // Longitude - sysInfo["height"].set(m_height); // Height - sysInfo["location"].set(m_location); // Location + sysInfo["height"].set(m_metadata->height); // Height + sysInfo["location"].set(m_metadata->location); // Location config["info"].set(sysInfo); // channel data json::object channel = json::object(); - channel["txPower"].set(m_power); // Tx Power - channel["txOffsetMhz"].set(m_txOffsetMhz); // Tx Offset (Mhz) - channel["chBandwidthKhz"].set(m_chBandwidthKhz); // Ch. Bandwidth (khz) - channel["channelId"].set(m_channelId); // Channel ID - channel["channelNo"].set(m_channelNo); // Channel No + channel["txPower"].set(m_metadata->power); // Tx Power + channel["txOffsetMhz"].set(m_metadata->txOffsetMhz); // Tx Offset (Mhz) + channel["chBandwidthKhz"].set(m_metadata->chBandwidthKhz); // Ch. Bandwidth (khz) + channel["channelId"].set(m_metadata->channelId); // Channel ID + channel["channelNo"].set(m_metadata->channelNo); // Channel No config["channel"].set(channel); // RCON json::object rcon = json::object(); - rcon["password"].set(m_restApiPassword); // REST API Password - rcon["port"].set(m_restApiPort); // REST API Port + rcon["password"].set(m_metadata->restApiPassword); // REST API Password + rcon["port"].set(m_metadata->restApiPort); // REST API Port config["rcon"].set(rcon); + // Flags bool external = true; config["externalPeer"].set(external); // External Peer Marker bool convPeer = true; config["conventionalPeer"].set(convPeer); // Conventional Peer Marker bool sysView = true; config["sysView"].set(sysView); // SysView Peer Marker + config["software"].set(std::string(software)); // Software ID json::value v = json::value(config); diff --git a/src/sysview/network/PeerNetwork.h b/src/sysview/network/PeerNetwork.h index c02efdce..b4729c67 100644 --- a/src/sysview/network/PeerNetwork.h +++ b/src/sysview/network/PeerNetwork.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: PROPRIETARY /* - * Digital Voice Modem - FNE Affiliations View + * Digital Voice Modem - FNE System View * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -8,20 +8,20 @@ * */ /** - * @defgroup fneAffView_network Networking - * @brief Implementation for the FNE networking. - * @ingroup fneAffView + * @defgroup fneSysView_network Networking + * @brief Implementation for the SysView networking. + * @ingroup fneSysView * * @file PeerNetwork.h - * @ingroup fneAffView_network + * @ingroup fneSysView * @file PeerNetwork.cpp - * @ingroup fneAffView_network + * @ingroup fneSysView */ #if !defined(__PEER_NETWORK_H__) #define __PEER_NETWORK_H__ #include "Defines.h" -#include "host/network/Network.h" +#include "common/network/Network.h" #include #include @@ -31,9 +31,12 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the core peer networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the SysView peer networking logic. + * @ingroup fneAffView_network + */ class HOST_SW_API PeerNetwork : public Network { public: /**