ensure FNE software reports itself differently; make host Network class private section protected so the FNE codebase can inherit from it; create PeerNetwork inherited class on FNE;

pull/48/head
Bryan Biedenkapp 2 years ago
parent cf0d8bb430
commit bde6284308

@ -42,6 +42,9 @@
#undef __EXE_NAME__
#define __EXE_NAME__ "dvmfne"
#undef __NETVER__
#define __NETVER__ "FNE_R" VERSION_MAJOR VERSION_REV VERSION_MINOR
#undef DEFAULT_CONF_FILE
#define DEFAULT_CONF_FILE "fne-config.yml"
#undef DEFAULT_LOCK_FILE

@ -219,7 +219,7 @@ int HostFNE::run()
// clock peers
for (auto network : m_peerNetworks) {
network::Network* peerNetwork = network.second;
network::PeerNetwork* peerNetwork = network.second;
if (peerNetwork != nullptr) {
peerNetwork->clock(ms);
@ -483,7 +483,7 @@ bool HostFNE::createPeerNetworks()
}
// initialize networking
network::Network* network = new Network(masterAddress, masterPort, 0U, id, password, true, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, true, true, m_allowActivityTransfer, m_allowDiagnosticTransfer, false);
network::PeerNetwork* network = new PeerNetwork(masterAddress, masterPort, 0U, id, password, true, debug, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled, true, true, m_allowActivityTransfer, m_allowDiagnosticTransfer, false);
network->setMetadata(identity, rxFrequency, txFrequency, 0.0F, 0.0F, 0, 0, 0, latitude, longitude, 0, location);
network->enable(enabled);
@ -507,7 +507,7 @@ bool HostFNE::createPeerNetworks()
/// Processes any peer network traffic.
/// </summary>
/// <param name="peerNetwork"></param>
void HostFNE::processPeer(network::Network* peerNetwork)
void HostFNE::processPeer(network::PeerNetwork* peerNetwork)
{
if (peerNetwork == nullptr)
return; // this shouldn't happen...

@ -32,8 +32,8 @@
#include "common/yaml/Yaml.h"
#include "common/Timer.h"
#include "network/FNENetwork.h"
#include "network/PeerNetwork.h"
#include "network/RESTAPI.h"
#include "host/network/Network.h"
#include <string>
#include <unordered_map>
@ -79,7 +79,7 @@ private:
lookups::RadioIdLookup* m_ridLookup;
lookups::TalkgroupRulesLookup* m_tidLookup;
std::unordered_map<std::string, network::Network*> m_peerNetworks;
std::unordered_map<std::string, network::PeerNetwork*> m_peerNetworks;
uint32_t m_pingTime;
uint32_t m_maxMissedPings;
@ -101,7 +101,7 @@ private:
bool createPeerNetworks();
/// <summary>Processes any peer network traffic.</summary>
void processPeer(network::Network* peerNetwork);
void processPeer(network::PeerNetwork* peerNetwork);
};
#endif // __HOST_FNE_H__

@ -443,6 +443,12 @@ void FNENetwork::clock(uint32_t ms)
writeTGIDs(peerId, true);
writeDeactiveTGIDs(peerId, true);
m_frameQueue->flushQueue();
json::object peerConfig = connection.config();
if (peerConfig["software"].is<std::string>()) {
std::string software = peerConfig["software"].get<std::string>();
LogInfoEx(LOG_NET, "PEER %u reports software %s", peerId, software.c_str());
}
}
}
}

@ -0,0 +1,131 @@
/**
* Digital Voice Modem - Converged FNE Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Converged FNE Software
*
*/
/*
* Copyright (C) 2024 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "fne/Defines.h"
#include "common/network/json/json.h"
#include "common/Utils.h"
#include "fne/network/PeerNetwork.h"
using namespace network;
#include <cstdio>
#include <cassert>
#include <cstdlib>
// ---------------------------------------------------------------------------
// Public Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the PeerNetwork class.
/// </summary>
/// <param name="address">Network Hostname/IP address to connect to.</param>
/// <param name="port">Network port number.</param>
/// <param name="local"></param>
/// <param name="peerId">Unique ID on the network.</param>
/// <param name="password">Network authentication password.</param>
/// <param name="duplex">Flag indicating full-duplex operation.</param>
/// <param name="debug">Flag indicating whether network debug is enabled.</param>
/// <param name="dmr">Flag indicating whether DMR is enabled.</param>
/// <param name="p25">Flag indicating whether P25 is enabled.</param>
/// <param name="nxdn">Flag indicating whether NXDN is enabled.</param>
/// <param name="slot1">Flag indicating whether DMR slot 1 is enabled for network traffic.</param>
/// <param name="slot2">Flag indicating whether DMR slot 2 is enabled for network traffic.</param>
/// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param>
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
/// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param>
PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password,
bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup) :
Network(address, port, localPort, peerId, password, duplex, debug, dmr, p25, nxdn, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup)
{
assert(!address.empty());
assert(port > 0U);
assert(!password.empty());
}
// ---------------------------------------------------------------------------
// Protected Class Members
// ---------------------------------------------------------------------------
/// <summary>
/// Writes configuration to the network.
/// </summary>
/// <returns></returns>
bool PeerNetwork::writeConfig()
{
if (m_loginStreamId == 0U) {
LogWarning(LOG_NET, "BUGBUG: tried to write network authorisation with no stream ID?");
return false;
}
const char* software = __NETVER__;
json::object config = json::object();
// identity and frequency
config["identity"].set<std::string>(m_identity); // Identity
config["rxFrequency"].set<uint32_t>(m_rxFrequency); // Rx Frequency
config["txFrequency"].set<uint32_t>(m_txFrequency); // Tx Frequency
// system info
json::object sysInfo = json::object();
sysInfo["latitude"].set<float>(m_latitude); // Latitude
sysInfo["longitude"].set<float>(m_longitude); // Longitude
sysInfo["height"].set<int>(m_height); // Height
sysInfo["location"].set<std::string>(m_location); // Location
config["info"].set<json::object>(sysInfo);
// channel data
json::object channel = json::object();
channel["txPower"].set<uint32_t>(m_power); // Tx Power
channel["txOffsetMhz"].set<float>(m_txOffsetMhz); // Tx Offset (Mhz)
channel["chBandwidthKhz"].set<float>(m_chBandwidthKhz); // Ch. Bandwidth (khz)
channel["channelId"].set<uint8_t>(m_channelId); // Channel ID
channel["channelNo"].set<uint32_t>(m_channelNo); // Channel No
config["channel"].set<json::object>(channel);
// RCON
json::object rcon = json::object();
rcon["password"].set<std::string>(m_restApiPassword); // REST API Password
rcon["port"].set<uint16_t>(m_restApiPort); // REST API Port
config["rcon"].set<json::object>(rcon);
config["software"].set<std::string>(std::string(software)); // Software ID
json::value v = json::value(config);
std::string json = v.serialize();
char buffer[json.length() + 8U];
::memcpy(buffer + 0U, TAG_REPEATER_CONFIG, 4U);
::sprintf(buffer + 8U, "%s", json.c_str());
if (m_debug) {
Utils::dump(1U, "Network Message, Configuration", (uint8_t*)buffer, json.length() + 8U);
}
return writeMaster({ NET_FUNC_RPTC, NET_SUBFUNC_NOP }, (uint8_t*)buffer, json.length() + 8U, pktSeq(), m_loginStreamId);
}

@ -0,0 +1,54 @@
/**
* Digital Voice Modem - Converged FNE Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Converged FNE Software
*
*/
/*
* Copyright (C) 2024 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__PEER_NETWORK_H__)
#define __PEER_NETWORK_H__
#include "Defines.h"
#include "host/network/Network.h"
#include <string>
#include <cstdint>
namespace network
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements the core peer networking logic.
// ---------------------------------------------------------------------------
class HOST_SW_API PeerNetwork : public Network {
public:
/// <summary>Initializes a new instance of the PeerNetwork class.</summary>
PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password,
bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup);
protected:
/// <summary>Writes configuration to the network.</summary>
bool writeConfig() override;
};
} // namespace network
#endif // __NETWORK_H__

@ -630,7 +630,7 @@ void Network::close()
}
// ---------------------------------------------------------------------------
// Private Class Members
// Protected Class Members
// ---------------------------------------------------------------------------
/// <summary>
@ -732,7 +732,7 @@ bool Network::writeConfig()
rcon["port"].set<uint16_t>(m_restApiPort); // REST API Port
config["rcon"].set<json::object>(rcon);
config["software"].set<std::string>(std::string(software)); // Software ID
config["software"].set<std::string>(std::string(software)); // Software ID
json::value v = json::value(config);
std::string json = v.serialize();

@ -85,7 +85,7 @@ namespace network
/// <summary>Last received RTP sequence number.</summary>
__READONLY_PROPERTY_PLAIN(uint16_t, pktLastSeq, pktLastSeq);
private:
protected:
std::string m_address;
uint16_t m_port;
@ -140,7 +140,7 @@ namespace network
/// <summary>Writes network authentication challenge.</summary>
bool writeAuthorisation();
/// <summary>Writes modem configuration to the network.</summary>
bool writeConfig();
virtual bool writeConfig();
/// <summary>Writes a network stay-alive ping.</summary>
bool writePing();
};

Loading…
Cancel
Save

Powered by TurnKey Linux.